Subversion Repositories Kolibri OS

Compare Revisions

No changes between revisions

Regard whitespace Rev 126 → Rev 125

/programs/games/mine/trunk/make.bat
File deleted
\ No newline at end of file
/programs/games/mine/trunk/changelog.txt
0,0 → 1,15
v0.3a (11/08/2003)
- fixed a bug on old kernels
 
v0.3 (09/08/2003)
- fixed some bugs
- new timer
- better random number generator
- user can't blow up after first mouse click
- uses system colors
 
v0.2 (29/06/2003)
- fixed a lot of bugs
 
v0.1 (22/06/2003)
- first public version
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/games/mine/trunk/draw.h--
1,7 → 1,7
/*******************************************************************************
 
MenuetOS MineSweeper
Copyright (C) 2003, 2004 Ivan Poddubny
Copyright (C) 2003 Ivan Poddubny
 
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
22,6 → 22,7
void draw_window()
// Ïðîöåäóðà îòðèñîâêè îêíà
{
mouse_disable();
 
sys_window_redraw(1);
sys_get_colors(#colors, 40);
32,7 → 33,7
sys_draw_window(EBX, ECX, 0x02CCCCCC, colors.w_grab | 0x80000000, colors.w_frames);
 
// LABEL
sys_write_text(8<<16+8, colors.w_grab_text | 0x10000000, "MineSweeper", 11);
sys_write_text(8<<16+8, colors.w_grab_text | 0x10000000, "MeOS MineSweeper", 16);
 
// <CLOSE> BUTTON (1)
EBX = xsize - 19; EBX = EBX<<16 + 12;
43,11 → 44,6
EBX = EBX << 16 + 20;
sys_draw_button(EBX, 25<<16+20, 911, clLightGray);
 
// <MAIN> BUTTON (1000)
// EBX = ncx * XPX; EBX += XST << 16;
// ECX = ncy * YPX; ECX += YST << 16;
// sys_draw_button(EBX, ECX, 1000, 0x60000000);
 
// <CHANGE MODE> BUTTON (1001)
sys_draw_button(10<<16+7, 23<<16+7, 1001, 0x118811);
 
69,6 → 65,7
draw_minesi(); // draw mines
draw_squares(); // draw field
 
mouse_enable();
}
 
dword num_colors[8]=
83,12 → 80,11
0x808080 // 8
};
 
 
void draw_square(int x, y)
// Îòðèñîâêà îäíîé êëåòêè
void draw_square(int x, y)
{
int xl, xr, yt, yb; // ñëåâà, ñïðàâà, ñâåðõó, ñíèçó
dword tcolor = clBlack; // öâåò çíà÷åíèÿ êëåòêè ïî óìîë÷àíèþ ÷åðíûé
int xl, xr, yt, yb;
dword tcolor = clBlack;
byte tchar, tval;
 
xl = XPX * x + XST;
100,11 → 96,10
ECX = yt << 16 + yb - yt;
$inc ebx
$inc ecx
sys_draw_bar(EBX, ECX, clLightGray); // ðèñóåò çàêðàøåííûé ïðÿìîóãîëüíèê
sys_draw_bar(EBX, ECX, clLightGray);
 
if (!get_open(x, y))
{
// ðèñóåì ðàìêó
ECX = yt << 16 + yb - 1;
sys_draw_line(xl<<16+xl, ECX, clWhite);
EBX = xl << 16 + xr - 1;
130,9 → 125,13
else // get_open(x,y)==TRUE
{
tval = get_value(x, y);
IF (tval != 0)
IF (tval == 0)
{
IF (tval == MINE)
//tcolor=clLightGray;
//tchar=' ';
GOTO NOCHAR;
}
ELSE IF (tval == MINE)
{
tcolor = 0xee1111;
tchar = '*';
142,19 → 141,19
tchar = tval + '0';
tcolor = num_colors[tval-1];
}
 
EBX = xl + 5; EBX <<= 16; EBX += yt + 5;
sys_write_text(EBX, tcolor, #tchar, 1);
EBX += 0x00010000;
sys_write_text(EBX, ECX, EDX, ESI);
}
NOCHAR:
sys_draw_line(xl << 16 + xl, yt << 16 + yb, clDarkGray);
sys_draw_line(xl << 16 + xr, yt << 16 + yt, EDX);
}
}
 
 
void draw_time()
// Òàéìåð
void draw_time()
{
sys_draw_bar(XST<<16+25, 31<<16+10, 0xCCCCCC);
EBX = 0x00030000;
161,23 → 160,21
sys_write_number(EBX, time, XST<<16+32, 0x10ff0000);
}
 
 
void draw_minesi()
// Èíäèêàòîð êîëè÷åñòâà íåðàññòàâëåííûõ ìèí
void draw_minesi()
{
EBX = xsize - XST - 25;
$PUSH EBX
EBX = EBX << 16 + 25;
sys_draw_bar(EBX, 31<<16+10, 0xCCCCCC);
sys_draw_bar(EBX, 31<<16+12, 0xCCCCCC);
$POP EDX
EDX <<= 16; EDX += 32;
EDX <<= 16; EDX += 30;
EBX = 0x00030000;
sys_write_number(EBX, cmines, EDX, 0x10ff0000);
}
 
 
void draw_squares()
// Îòðèñîâêà ìèííîãî ïîëÿ
void draw_squares()
{
int x,y;
 
/programs/games/mine/trunk/mine.c--
1,7 → 1,7
/*******************************************************************************
 
MenuetOS MineSweeper
Copyright (C) 2003, 2004 Ivan Poddubny
Copyright (C) 2003 Ivan Poddubny
 
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
19,22 → 19,22
 
*******************************************************************************/
 
? pragma option LST // generate ASM listing file - ñîçäàòü àññåìáëåðíûé ëèñòèíã
? warning TRUE // âêëþ÷èòü ðåæèì âûâîäà ïðåäóïðåæäåíèé
//? pragma option LST // generate ASM listing file - ñîçäàòü àññåìáëåðíûé ëèñòèíã
//? warning TRUE // âêëþ÷èòü ðåæèì âûâîäà ïðåäóïðåæäåíèé
? pragma option meos
? jumptomain NONE
? include "msys.h--" // MenuetOS system functions - ñèñòåìíûå ôóíêöèè MenuetOS
//? define DEBUG 1
 
? print "\nÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿"
? print "\n³ MenuetOS MineSweeper v0.4 ³"
? print "\n³ (C) Ivan Poddubny (ivan-yar@bk.ru) 2003,2004 ³"
? print "\nÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ\n\n"
? print "\nÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿"
? print "\n³ MeOS MineSweeper v0.3 ³"
? print "\n³ (C) Ivan Poddubny (ivan-yar@bk.ru) 2003 ³"
? print "\nÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ\n\n"
 
/************************************** DATA **************************************/
 
? define XPX 16 // X pixels by square - ðàçìåð êëåòêè â ïèêñåëÿõ
? define YPX 16 // Y pixels by square
? define MINE 255 // â êëåòêå ìèíà, åñëè value = MINE
? define MINE 255 // çíà÷åíèå äëÿ ìèíû â ïîëå value
 
struct
{
59,7 → 59,7
 
int XST, // offset of first pixel X - ñìåùåíèå ïîëÿ îò ãðàíèöû îêíà
YST,
ncx, // number of squares in X - ðàçìåð ïîëÿ
ncx, // number of squares in X - ðàçìåð ïîë
ncy,
cmines, // mines discovered - êîëè÷åñòâî íåîòêðûòûõ ìèí
initmines, // number of initial mines - èçíà÷àëüíîå êîëè÷åñòâî ìèí
88,7 → 88,6
$int 0x40
}
 
 
inline void fastcall mouse_disable()
{
$mov eax,40
96,7 → 95,6
$int 0x40
}
 
 
? include "timer.h--" // timer functions
? include "draw.h--" // drawing functions
? include "access.h--" // get & set functions
103,9 → 101,8
? include "random.h--" // random number generator
//? include "uf.h--" // user field window
 
 
void init()
// Èíèöèàëèçàöèÿ
// Èíèöèàëèçàöè
{
XST = 10; YST = 52; // FIELD POSITION IN WINDOW
 
129,7 → 126,6
ysize = ncy * YPX + YST + XST;
} // init
 
 
void clear_all()
// Î÷èñòèòü ïîëå
{
139,11 → 135,10
$REP $STOSD
} // clear_all
 
 
void new_game()
// Íîâàÿ èãðà
{
init(); // èíèöèàëèçàöèÿ
init(); // èíèöèàëèçàöè
randomize(); // ãåíåðàòîð ñëó÷àéíûõ ÷èñåë
clear_all(); // î÷èñòèòü ïîëå
 
154,22 → 149,16
time = 0; // âðåìÿ = 0
} // new_game
 
 
void set_mines(int nminas, no_x, no_y)
// Ðàññòàâèòü ìèíû
{
int i, x, y, a, b;
 
#ifdef DEBUG
sys_debug_write_string("MINE: set_mines called\n");
#endif
 
sqclosed = ncx * ncy - nminas; // êîëè÷åñòâî ÍÅîòêðûòûõ êëåòîê = ïëîùàäü ïîëÿ - êîë-âî ìèí
 
FOR (i = nminas; i > 0; i--) // ðàññòàâèòü ìèíû
{
x = random(ncx);
y = random(ncy);
x = random(ncx); y = random(ncy);
WHILE ((get_value(x, y) == MINE) || ((x == no_x) && (y == no_y)))
{
x = random(ncx);
201,7 → 190,6
}
} // set_mines
 
 
inline void do_mouse(void)
// Îáðàáîò÷èê ìûøè
{
208,11 → 196,7
int x,y;
 
EAX = sys_read_mouse(2); // ìûøü íå íàæàòà -> âûõîä
IF (EAX == 0)
{
// sys_debug_write_string("Strange\n");
return;
}
IF (EAX == 0) return;
 
mouse_status = AL;
 
232,10 → 216,8
IF (firstmine == TRUE)
{
firstmine = FALSE;
set_mines(initmines, x, y);
set_mines(cmines, x, y);
start_timer();
time = 1;
draw_time();
}
IF (get_value(x, y) == MINE)
{
270,10 → 252,10
end_game();
}
 
IF (sqclosed == 0)
{
if (sqclosed == 0)
// îòêðûòû âñå êëåòêè
// all squares are opened
{
mouse_en = FALSE; // çàïðåòèòü ìûøü
stop_timer();
stop_game = TRUE; // èãðà çàâåðøåíà
291,16 → 273,11
}
} // do_mouse
 
 
void open_square(int x, y)
// Îòêðûòü êëåòêó
{
int a, b, i;
 
#ifdef DEBUG
sys_debug_write_string("MINE: open_square called\n");
#endif
 
set_open(x, y, TRUE);
sqclosed--;
 
328,7 → 305,6
}
} // open_square
 
 
int open_near_squares(int x, y)
// Îòêðûòü áëèçëåæàùèå êëåòêè (îáå êíîïêè ìûøè âìåñòå)
{
335,10 → 311,6
int a, b, i;
dword suma = 0;
 
#ifdef DEBUG
sys_debug_write_string("MINE: open_near_squares called\n");
#endif
 
a = x;
b = y;
FOR (i = 0; i < 8; i++)
377,21 → 349,16
open_square(a, b);
}
}
return suma;
RETURN suma;
}
ELSE
return 0;
RETURN 0;
} // open_near_squares
 
 
void end_game()
{
int x,y;
 
#ifdef DEBUG
sys_debug_write_string("MINE: end_game called\n");
#endif
 
stop_game = TRUE;
stop_timer();
for (x=0; x<ncx; x++)
430,7 → 397,7
 
void main()
{
//sys_delay(5); // for old kernel only!
sys_delay(5); // for old kernel only!
new_game();
draw_window();
 
439,16 → 406,16
{
switch (sys_wait_event_timeout(100)) // wait for 1 second
{
case evReDraw:
CASE evReDraw:
draw_window();
continue;
 
case evKey:
CASE evKey:
IF (sys_get_key() == 27)
sys_exit_process();
continue;
 
case evButton:
CASE evButton:
EAX = sys_get_button_id();
IF (EAX == 911) // new game
{
462,13 → 429,14
// mode++; mode%=3; mode++;
EAX = mode; EAX++; EAX = EAX%3; EAX++; mode = AL;
 
new_game();
EBX = ECX = -1;
EDX = xsize;
ESI = ysize;
EAX = 67;
$int 0x40
continue;
// get window position - ïîëó÷èòü êîîðäèíàòû îêíà
sys_process_info(#procinfo, -1);
xpos = procinfo.xstart;
ypos = procinfo.ystart;
 
// start a new process and terminate this one
sys_create_thread(#main, ESP);
sys_exit_process();
}
// ELSE IF (EAX == 1002)
// {
476,17 → 444,17
// }
ELSE IF (EAX == 1) // close window
sys_exit_process();
continue;
CONTINUE;
 
case evMouse:
IF (!mouse_en) // is mouse enabled ?
continue;
CONTINUE;
do_mouse();
// wait for mouse release - æäàòü îòïóñêàíèÿ êíîïêè
WHILE (sys_read_mouse(2) == mouse_status)
{
check_timer();
sys_delay(3);
sys_delay(6);
CONTINUE;
}
check_timer();
/programs/games/mine/trunk/msys.h--
1,7 → 1,7
/*
Sphinx C-- header file for MenuetOS applications.
Based on msys.h-- written by Alexey Sugonyaev and modified by Barry Kauler.
This file is rewritten by Ivan Poddubny.
This extended version is written by Ivan Poddubny.
 
e-mail: ivan-yar@bk.ru
*/
24,13 → 24,11
#define clGreen 0x0000ff00
#define clBlue 0x000000ff
 
// Events
#define evReDraw 1
#define evKey 2
#define evButton 3
#define evMouse 6
#define evIPC 7
#define evStack 8
 
struct FileInfo
{
75,14 → 73,13
w_work_graph;
};
 
/*********************************************************
/*
0 = DEFINE WINDOW
{x_start|y_start}, {x_size|y_size}, color_back, color_title, color_frames
EBX = [x_start][x_size]
ECX = [y_start][y_size]
EDX, ESI, EDI = [00RRGGBB]
*********************************************************/
 
*/
inline fastcall void sys_draw_window(dword EBX, ECX, EDX, ESI, EDI)
{
EAX = 0; // function 0 : define and draw window
89,8 → 86,7
$int 0x40
}
 
 
/*********************************************************
/*
01 = PUTPIXEL
ebx [x]
ecx [y]
97,8 → 93,7
edx pixel color 0x0XRRGGBB
^ 0 normal put, 1 negative
ret: nothing changed
*********************************************************/
 
*/
inline fastcall void sys_put_pixel(dword EBX,ECX,EDX)
{
EAX=1;
105,14 → 100,12
$int 0x40
}
 
 
/*********************************************************
/*
02 = GET KEY
ret: al 0 successful -> ah = key
al 1 no key in buffer
MODIFIED, see below...
*********************************************************/
 
*/
inline fastcall dword sys_get_key()
{
EAX = 2; // just read it key from buffer
120,13 → 113,10
$shr eax,8
} //return eax=key code.
 
 
/*********************************************************
/*
03 = GET SYSTEM CLOCK
ret: eax 0x00SSMMHH sec,min,hour
*********************************************************/
 
#define sys_get_time sys_get_clock
*/
inline fastcall dword sys_get_clock()
{
EAX=3;
133,17 → 123,14
$int 0x40
}
 
 
/*********************************************************
/*
04 = WRITE TEXT TO WINDOW
ebx [x start]*65536 + [y start]
ecx text color 0x00RRGGBB
edx pointer to text beginning
esi text length
return: nothing changed
*********************************************************/
 
#define sys_print_text sys_write_text
ret: nothing changed
*/
inline fastcall void sys_write_text(dword EBX, ECX, EDX, ESI)
{
EAX = 4;
150,21 → 137,11
$int 0x40;
}
 
inline fastcall void sys_write_char(dword EBX, ECX, EDX)
{
EAX = 4;
ESI = 1;
$int 0x40
}
 
 
/*********************************************************
/*
05 = DELAY X/100 SECS
ebx delay in 1/100 secs
ret: nothing changed
*********************************************************/
 
#define sys_wait sys_delay
*/
inline fastcall void sys_delay(dword EBX)
{
EAX = 5;
171,33 → 148,29
$int 0x40
}
 
 
/*********************************************************
/*
06 = OPEN FILE FROM FLOPPY
ebx pointer to filename -> 11 capital letters
ecx set 0x00000000 - reserved
edx set 0xffffffff - reserved
esi read to mem position
ret: ebx = file size
*********************************************************/
 
inline fastcall dword sys_open_file_floppy(dword EBX, ESI)
ret: nothing changed
*/
inline fastcall void sys_open_file_floppy(dword EBX, ESI)
{
ECX = 0;
$xor ecx,ecx
EDX = -1;
EAX = 6;
$int 0x40
}
 
 
/*********************************************************
/*
07 = PUTIMAGE
ebx pointer to image in memory - RRGGBBRRGGBB..
ecx image size [x]*65536+[y]
edx image position in window [x]*65536+[y]
ret: eax 0 succesful, 1 overlapped
*********************************************************/
 
*/
inline fastcall dword sys_put_image(dword EBX, ECX, EDX)
{
EAX = 7;
204,8 → 177,7
$int 0x40
}
 
 
/*********************************************************
/*
08 = DEFINE BUTTON
ebx [x start]*65536 + [x size]
ecx [y start]*65536 + [y size]
212,8 → 184,7
edx button id number
esi button color 0x 00 RR GG BB
ret: nothing changed
*********************************************************/
 
*/
inline fastcall void sys_draw_button(dword EBX, ECX, EDX, ESI)
{
EAX = 8;
220,15 → 191,7
$int 0x40
}
 
inline fastcall void sys_delete_button(dword EDX)
{
EAX = 8;
EDX |= 0x80000000;
$int 0x40
}
 
 
/*********************************************************
/*
09 = PROCESS INFO
ebx pointer to 1024 bytes table
ecx process number or -1 = who am I
244,8 → 207,7
+38 dword window y start
+42 dword window x size
+46 dword window y size
*********************************************************/
 
*/
inline fastcall dword sys_process_info(dword EBX, ECX)
{
EAX = 9;
252,15 → 214,10
$int 0x40
}
 
 
/*********************************************************
/*
10 = WAIT FOR EVENT
ret: eax event type,
1 window redraw,
2 key in buffer,
3 button pressed
*********************************************************/
 
ret: eax event type, 1 window redraw, 2 key in buffer, 3 button pressed
*/
inline fastcall dword sys_wait_event()
{
EAX = 10; // wait here for event
267,15 → 224,10
$int 0x40
}
 
 
/*********************************************************
/*
11 = CHECK FOR EVENT, NO WAIT
ret: eax 0 no event,
1 window redraw,
2 key in buffer,
3 button pressed
*********************************************************/
 
ret: eax 0 no event, 1 window redraw, 2 key in buffer, 3 button pressed
*/
inline fastcall dword sys_nowait_event()
{
EAX = 11;
282,12 → 234,9
$int 0x40
}
 
 
/*********************************************************
12 = WINDOW REDRAW
/* 12 = WINDOW REDRAW
EBX=1 start of draw, =2 end of draw.
*********************************************************/
 
*/
inline fastcall void sys_window_redraw(dword EBX)
{
EAX = 12; // function 12:tell os about windowdraw
294,21 → 243,7
$int 0x40
}
 
inline fastcall void sys_begin_draw()
{
EAX = 12;
EBX = 1;
$int 0x40
}
 
inline fastcall void sys_end_draw()
{
EAX = 12;
EBX = 2;
$int 0x40
}
 
/*********************************************************
/*
13 = DRAW BAR
DrawBar(EBX=[xstart][xsize],ECX=[ystart][ysize],EDX=[0x00RRGGBB])
ebx [x start]*65536 + [x size]
315,8 → 250,7
ecx [y start]*65536 + [y size]
edx color 0x00RRGGBB
ret: nothing changed
*********************************************************/
 
*/
inline fastcall void sys_draw_bar(dword EBX, ECX, EDX)
{
EAX = 13;
323,12 → 257,10
$int 0x40
}
 
 
/*********************************************************
/*
14 = GET SCREEN MAX
ret: eax [screen x max]*65536 + [screen y max]
*********************************************************/
 
*/
inline fastcall dword sys_get_screen_size()
{
EAX = 14;
335,8 → 267,7
$int 0x40
}
 
 
/*********************************************************
/*
15 = BACKGROUND
ebx 1 : set background size
ecx x size
352,8 → 283,7
ecx - from
edx - to where in os bgr memory
esi - count of bytes to move
*********************************************************/
 
*/
inline fastcall void sys_set_background(dword EBX, ECX, EDX, ESI)
{
EAX = 15;
361,12 → 291,11
}
 
 
/*********************************************************
/*
17 = GET PRESSED BUTTON ID
ret: al 0 successful -> ah = id number al 1 no key in buffer.
MODIFIED, see below.
*********************************************************/
 
*/
inline fastcall dword sys_get_button_id()
{
EAX = 17; // Get ID
374,8 → 303,7
$shr eax,8
} //eax=id, eax=0 no id.
 
 
/*********************************************************
/*
18 = SYSTEM SERVICE
ebx 1 - system boot
ebx 2 - force terminate , ecx process no
382,8 → 310,7
ebx 4 - idle clock cycles / second
ebx 5 - time stamp counter / second - cpu speed
HD-> ebx 6 - save ramdisk to /hd/1/menuet.img
*********************************************************/
 
*/
inline fastcall dword sys_service(dword EBX, ECX)
{
EAX = 18;
390,43 → 317,13
$int 0x40
}
 
inline fastcall void sys_shutdown()
{
EAX = 18;
EBX = 1;
$int 0x40
}
 
inline fastcall void sys_kill(dword ECX)
{
EAX = 18;
EBX = 2;
$int 0x40
}
 
inline fastcall dword sys_get_idle()
{
EAX = 18;
EBX = 4;
$int 0x40
}
 
inline fastcall dword sys_get_tscsec()
{
EAX = 18;
EBX = 5;
$int 0x40
}
 
 
/*********************************************************
/*
19 = START PROGRAM from RAMDISK
ebx point to 11 char filename
ecx 0, or point to ASCIIZ start parameters - max 256 bytes
ret: eax 0 successful
eax other error code
*********************************************************/
 
*/
inline fastcall dword sys_exec_app_ramdisk(dword EBX, ECX)
{
EAX = 19;
433,13 → 330,11
$int 0x40
}
 
 
/*********************************************************
/*
20 = MIDI INTERFACE - MPU401
ebx 1 - reset device
ebx 2 - cl midi data to output
*********************************************************/
 
*/
inline fastcall void sys_midi(dword EBX)
{
EAX = 20;
446,8 → 341,7
$int 0x40
}
 
 
/*********************************************************
/*
21 = SETUP FOR DEVICES
ebx 1=roland mpu midi base , base io address
ebx 2=keyboard 1 base keymap 2 shift keymap (ecx pointer to keymap)
460,8 → 354,7
ebx 7=hd base, 1 pri.master 2 pri slave
3 sec master 4 sec slave
ebx 8=fat32 partition in hd
*********************************************************/
 
*/
inline fastcall void sys_setup_devices(dword EBX, ECX)
{
EAX = 21;
468,14 → 361,12
$int 0x40
}
 
 
/*********************************************************
/*
23 = WAIT FOR EVENT WITH TIMEOUT
ebx time to delay in hs
ret: eax event type: 0 no event, 1 window redraw,
2 key in buffer, 3 button
*********************************************************/
 
*/
inline fastcall dword sys_wait_event_timeout(dword EBX)
{
EAX = 23;
482,14 → 373,12
$int 0x40
}
 
 
/*********************************************************
/*
24 = CD AUDIO
ebx 1 - play from ecx 00 FR SS MM
ebx 2 - get playlist size of ecx to [edx]
ebx 3 - stop/pause play
*********************************************************/
 
*/
inline fastcall void sys_cd_audio(dword EBX, ECX, EDX)
{
EAX = 24;
496,13 → 385,11
$int 0x40
}
 
 
/*********************************************************
/*
25 = SB16 - mixer I
ebx 1 - set main volume cl [L]*16+[R]
ebx 2 - set cd volume cl [L]*16+[R]
*********************************************************/
 
*/
inline fastcall void sys_sb16_mixer_1(dword EBX, ECX)
{
EAX = 25;
509,8 → 396,7
$int 0x40
}
 
 
/*********************************************************
/*
26 = GET SETUP FOR DEVICES
ebx 1=roland mpu midi base , base io address
ebx 2=keyboard 1 base keymap 2 shift keymap
523,10 → 409,9
ebx 7=hd base, 1 pri.master 2 pri slave
3 sec master 4 sec slave
ebx 8=fat32 partition in hd
ebx 9=1/100 timer tics from start -> eax
ebx 9=1/100 timer tics from stard -> eax
return value in eax
*********************************************************/
 
*/
inline fastcall dword sys_get_setup_devices(dword EBX)
{
EAX = 26;
533,13 → 418,11
$int 0x40
}
 
 
/*********************************************************
/*
27 = WINDOWS SOUND SYSTEM
ebx 1 - set main volume to cl 0-255
ebx 2 - set cd volume to cl 0-255
*********************************************************/
 
*/
inline fastcall void sys_windows_sound_system(dword EBX, ECX)
{
EAX = 27;
546,13 → 429,11
$int 0x40
}
 
 
/*********************************************************
/*
28 = SB16 - mixer II
ebx 1 - set main volume to cl 0-255
ebx 2 - set cd volume to cl 0-255
*********************************************************/
 
*/
inline fastcall void sys_sb16_mixer_2(dword EBX, ECX)
{
EAX = 28;
559,12 → 440,10
$int 0x40
}
 
 
/*********************************************************
/*
29 = GET DATE
ret: eax 0x00YYDDMM year date month
*********************************************************/
 
*/
inline fastcall dword sys_get_date()
{
EAX = 29;
571,8 → 450,7
$int 0x40
}
 
 
/*********************************************************
/*
30 = READ HD
ebx pointer to file
ecx file lenght
580,8 → 458,7
esi reserved, set as 1
edi pointer to return/work area (atleast 20 000 bytes)
return: work_area+1024 <- requested block of 512 bytes
*********************************************************/
 
*/
inline fastcall dword sys_read_hd(dword EBX, ECX, EDX, ESI, EDI)
{
EAX = 30;
588,15 → 465,13
$int 0x40
}
 
 
/*********************************************************
/*
31 = START APP FROM HD
ebx pointer to file
ecx file lenght
edx pointer to return/work area (atleast 20 000 bytes)
ret eax=0 successful, eax<>0 errorcode
*********************************************************/
 
*/
inline fastcall dword sys_exec_app_hd()
{
EAX = 31;
603,11 → 478,10
$int 0x40
}
 
 
/*********************************************************
/*
32 = DELETE FILE FROM FLOPPY IMAGE IN MEMORY
ebx pointer to filename
*********************************************************/
*/
 
inline fastcall dword sys_floppy_delete(EBX)
{
615,15 → 489,13
$int 0x40
}
 
 
/*********************************************************
/*
33 = SAVE FILE TO FLOPPY IMAGE IN MEMORY
ebx pointer to file name
ecx pointer to data
edx count to write in bytes
esi 0 create new , ( 1 append - not implemented yet )
*********************************************************/
 
*/
inline fastcall dword sys_floppy_save(EBX,ECX,EDX)
{
EAX = 33;
631,8 → 503,7
$int 0x40
}
 
 
/*********************************************************
/*
34 = READ DIRECTORY FROM FLOPPY
ebx reserved : set as zero
ecx reserved : set as zero
639,29 → 510,20
edx start 512 block to read
esi reserved : set as 1
edi pointer to return area
*********************************************************/
 
/*********************************************************
 
35 = READ SCREEN PIXEL
ebx = pixel count from top left of the screen
return : eax = 0x00RRGGBB
*********************************************************/
*/
 
inline fastcall dword sys_read_pixel(dword EBX)
{
EAX = 35;
$int 0x40
}
 
 
/*********************************************************
/*
37 = READ MOUSE POSITION
ebx=0 screen relative
ebx=1 window relative
ebx=2 buttons pressed
return in eax
*********************************************************/
 
*/
inline fastcall dword sys_read_mouse(dword EBX)
{
EAX = 37;
668,15 → 530,13
$int 0x40
}
 
 
/*********************************************************
/*
38 = DRAW LINE
ebx [x start] shl 16 + [x end]
ecx [y start] shl 16 + [y end]
edx colour 0x00RRGGBB
return : nothing changed
*********************************************************/
 
*/
inline fastcall void sys_draw_line(dword EBX, ECX, EDX)
{
EAX = 38;
683,15 → 543,13
$int 0x40
}
 
 
/*********************************************************
/*
39 = GET BACKGROUND
ebx=1 -> eax=[bgr x size] shl 16 + [bgr y size]
ebx=2
ecx= postition of backgrounds memorymap to return in eax
ebx=4 -> eax=1 tiled, eax=2 stretched
*********************************************************/
 
*/
inline fastcall dword sys_get_background(dword EBX, ECX)
{
EAX = 39;
698,8 → 556,7
$int 0x40
}
 
 
/*********************************************************
/*
40 = SET BITFIELD FOR WANTED EVENTS
as default:
ebx = 00000000 00000000 00000000 00000111b events:
708,24 → 565,15
I button in buffer
I (end request)
I desktop background draw
I mouse change
I IPC message
I stack
I (mouse change)
I---------------I get irqs data
 
*********************************************************/
 
//sys_set_event_mask()
//{
//}
 
/*********************************************************
41 = GET IRQ OWNER
ebx = irq
return : PID of the process
*********************************************************/
 
/*********************************************************
 
42 = GET DATA READ BY IRQ
ebx IRQ number
return : eax number of bytes in buffer
733,106 → 581,33
ecx 0 = successful data read
1 = no data in buffer
2 = incorrect IRQ owner
*********************************************************/
 
/*********************************************************
43 = SEND/READ DATA TO/FROM DEVICE
SEND:
43 = SEND DATA TO DEVICE
bx : port
cl : data
return : eax = if 0 successful, other = error
 
bl : data
cx : port
 
return: eax: status of read ( 0 if successful, other if error )
 
READ:
 
ecx : bit 31 set + port
 
return: eax: 0 status of read ( 0 if successful, other if error )
ebx: low 8 bits : value
*********************************************************/
 
inline fastcall dword sys_read_port(word CX)
{
EAX = 43;
ECX |= 0x80000000; // set bit 31
$int 0x40
}
 
inline fastcall dword sys_read_port_fast(dword ECX)
{
EAX = 43;
$int 0x40
}
 
inline fastcall dword sys_write_port(word CX,byte BL)
{
EAX = 43;
$int 0x40
}
 
 
/*********************************************************
44 = PROGRAM IRQ's
ebx pointer to table
ecx irq number
*********************************************************/
 
inline fastcall void sys_program_irqs(dword EBX,ECX)
{
EAX = 44;
$int 0x40
}
 
 
/*********************************************************
45 = RESERVE/FREE IRQ
ebx 0 reserve 1 free
ecx IRQ number
 
ret eax 0 successful, 1 error
*********************************************************/
 
inline fastcall dword sys_reserve_irq(dword ECX)
{
EAX = 45;
EBX = 0;
$int 0x40
}
 
inline fastcall dword sys_free_irq(dword ECX)
{
EAX = 45;
EBX = 1;
$int 0x40
}
 
 
/*********************************************************
46 = RESERVE/FREE PORT AREA
ebx 0 reserve 1 free
ecx port area start
edx port area end
ret eax 0 successful, 1 error
*********************************************************/
*/
 
inline fastcall dword sys_reserve_port_area(dword ECX,EDX)
{
EAX = 46;
EBX = 0;
$int 0x40
}
 
inline fastcall dword sys_free_port_area()
{
EAX = 46;
EBX = 1;
$int 0x40
}
 
 
/*********************************************************
/*
47 = DISPLAY NUMBER TO WINDOW
ebx = print type, bl=0 -> ecx is number
bl=1 -> ecx is pointer
844,7 → 619,7
ecx = number or pointer
edx = x shl 16 + y
esi = color
*********************************************************/
*/
inline fastcall void sys_write_number(dword EBX, ECX, EDX, ESI)
{
EAX = 47;
851,8 → 626,7
$int 0x40
}
 
 
/*********************************************************
/*
48 = DEFINE GENERAL WINDOW PROPERTIES
ebx = 0 apply/redraw
ecx = 0 , apply/redraw desktop
865,8 → 639,7
ebx = 3 get define window colors
ecx = pointer to table
edx = number of bytes to get
ebx = 4 get window skin height
*********************************************************/
*/
 
inline fastcall void sys_redraw_desktop()
{
896,15 → 669,14
$int 0x40
}
 
inline fastcall dword sys_get_skin_height(dword)
{
EAX = 48;
EBX = 4;
$int 0x40
}
/*
49 = DEFINE APPLICATIONS INTERNAL INTERRUPTS
ebx = 0
ecx point to dword x 256 table of interrupt entries
inside the application
return : nothing changed
 
 
/*********************************************************
50 = FREE FORM WINDOW SHAPE AND SCALE
ebx = 0 ; shape reference area
ecx = pointer to reference area
912,22 → 684,14
ebx = 1 ; scale of reference area (default 1:1)
ecx : scale is set to 2^ecx
return: nothing changed
*********************************************************/
 
inline void sys_freeform_window(dword EBX,ECX)
{
EAX = 50;
$int 0x40
}
 
 
/*********************************************************
51 = CREATE THREAD
ebx = 1 ; create
ecx ; = thread entry point
edx ; = thread stack position
return : eax = pid or 0xfffffff0+ for error
*********************************************************/
*/
 
inline fastcall dword sys_create_thread(dword ECX,EDX)
{
936,56 → 700,26
$int 0x40
}
 
/*
 
/*********************************************************
52 = STACK DRIVER STATUS
- see stack.txt
net.h--
 
 
53 = SOCKET INTERFACE
- see stack.txt
net.h--
*********************************************************/
 
 
/*********************************************************
55 = SOUND INTERFACE
54 = USER EVENTS
- not ready yet
ebx = 0 ; load sound block
ecx = ; pointer to (default size 65536 byte) soundblock
ebx = 1 ; play (default 44 khz 8 bit mono) sound block
55 = SOUND INTERFACE
ebx = 0 ; load 44 khz 8 bit mono sound block
ecx ; = pointer to 65536 byte soundblock
ebx = 1 ; play 44 khz 8 bit mono sound block
 
ebx = 2 ; set format
ecx = 1 ; set play block length
edx = ; block length
*********************************************************/
 
inline fastcall void sys_sound_load(dword ECX)
{
EAX = 55;
EBX = 0;
$int 0x40
}
 
inline fastcall void sys_sound_play()
{
EAX = 55;
EBX = 1;
$int 0x40
}
 
inline fastcall void sys_sound_format_length(dword EDX)
{
EAX = 55;
EBX = 2;
ECX = 1;
$int 0x40
}
 
 
/*********************************************************
56 = WRITE FILE TO HD
ebx pointer to 12 char filename
ecx bytes to write
992,17 → 726,15
edx pointer to data to write
esi pointer to path
path db 0
*********************************************************/
 
 
/*********************************************************
57 = DELETE FILE FROM HD
ebx pointer to filename : 11 capital letters
edx pointer to path : path db 0
*********************************************************/
*/
 
 
/*********************************************************
/*
58 = SYSTEM TREE ACCESS
ebx pointer to fileinfo block
fileinfo:
1012,7 → 744,7
dd 0x20000 ; return data pointer
dd 0x10000 ; work area for os - 16384 bytes
db '/RAMDISK/FIRST/KERNEL.ASM',0 ; ASCIIZ dir & filename
*********************************************************/
*/
inline fastcall void sys_tree_access(dword EBX)
{
EAX = 58;
1019,8 → 751,7
$int 0x40
}
 
 
/*********************************************************
/*
59 = TRACE FOR SYSTEM CALLS FROM PROCESSES
ebx = 0 ; get system events
ecx ; pointer to table -> ; 64 bytes/system call descriptor
1037,17 → 768,9
return: eax = number of system calls from start
latest call is saved to (eax mod 16)*64 in table
ebx = 0 : above format
*********************************************************/
*/
 
inline fastcall void sys_syscall_trace(dword ECX,EDX)
{
EAX = 59;
EBX = 0;
$int 0x40
}
 
 
/*********************************************************
/*
60 = IPC
ebx = 1 ; define receive area
ecx = pointer to start
1057,7 → 780,7
ecx = PID
edx = pointer to message
esi = length
*********************************************************/
*/
 
inline fastcall void sys_ipc_init(dword ECX, EDX)
{
1073,48 → 796,11
$int 0x40
}
 
/* -1 = EXIT PROCESS */
 
/*********************************************************
63 = GENERAL DEBUG BOARD
ebx = 1 write byte in cl
ebx = 2 read byte : ebx = 1 -> byte in al ; ebx = 0 -> no data
*********************************************************/
 
inline fastcall void sys_debug_write_char(byte CL)
{
EAX = 63;
EBX = 1;
$int 0x40
}
 
:fastcall void sys_debug_write_string(dword ESI)
{
$pusha
CL = DSBYTE[ESI];
while(CL!=0)
{
sys_debug_write_char(CL);
ESI++;
CL = DSBYTE[ESI];
}
$popa
}
 
inline fastcall dword sys_debug_read_char(dword EBX)
{
EAX = 63;
EBX = 2;
$int 0x40
}
 
 
/*********************************************************
-1 = EXIT PROCESS
*********************************************************/
 
inline fastcall void sys_exit_process()
{
$or eax,0xffffffff
$xor eax,eax
$dec eax
$int 0x40
}
/programs/games/mine/trunk/random.h--
1,7 → 1,7
/*******************************************************************************
 
MenuetOS MineSweeper
Copyright (C) 2003, 2004 Ivan Poddubny
Copyright (C) 2003 Ivan Poddubny
 
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
/programs/games/mine/trunk/timer.h--
1,7 → 1,7
/*******************************************************************************
 
MenuetOS MineSweeper
Copyright (C) 2003, 2004 Ivan Poddubny
Copyright (C) 2003 Ivan Poddubny
 
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
26,20 → 26,12
 
start_timer()
{
#ifdef DEBUG
sys_debug_write_string("MINE: timer started\n");
#endif
 
timer_life = TRUE;
ttime = sys_get_setup_devices(9); //sys_get_clock();
ttime = sys_get_clock();
}
 
stop_timer()
{
#ifdef DEBUG
sys_debug_write_string("MINE: timer stopped\n");
#endif
 
timer_life = FALSE;
}
 
47,11 → 39,12
{
IF (!timer_life) return;
 
ECX = sys_get_setup_devices(9); //sys_get_clock();
EAX = sys_get_clock();
IF (EAX == 0xffffff) return;
IF (ttime+100 < ECX)
IF (ttime != EAX)
{
ttime += 100;
ttime = EAX;
IF (time < 999)
time++;
draw_time();
/programs/games/mine/trunk/uf.h--
1,7 → 1,7
/*******************************************************************************
 
MenuetOS MineSweeper
Copyright (C) 2003, 2004 Ivan Poddubny
Copyright (C) 2003 Ivan Poddubny
 
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
26,70 → 26,30
byte uf_open = FALSE;
byte uf_stack[2048];
 
dword active_textbox = #str1;
byte str1[5];
byte str2[5];
byte str3[5];
 
byte str1[4] = {'1','1','1',0};
byte str2[4] = {'2','2','2',0};
byte str3[4] = {'3','2','1',0};
dword uf_x,
uf_y;
 
dword uf_x=0,
uf_y=0;
 
:fastcall dword str2dword(dword EAX)
// str2byte ïåðåâîäèò ñòðîêó èç 3¸õ öèôð â áàéò
// IN: EAX = àäðåñ ñòîðêè
// OUT: EAX = áàéò
{
EDX = 0;
ECX = 0;
WHILE(ECX<3)
{
EDX *= 10;
EBX = DSBYTE[EAX+ECX];
EBX -= '0';
EDX += EBX;
ECX++;
}
EAX = EDX;
}
 
:fastcall void dword2str(dword EAX,ESI)
{
$PUSHA
DSDWORD[ESI]=0;
// EAX &= 255;
EDI = 10;
ECX = 2;
WHILE(ECX>=0)
{
IF(!EAX) BREAK;
$XOR EDX,EDX
$DIV EDI // al = div; dl = mod
DL += '0';
DSBYTE[ESI+ECX] = DL;
ECX--;
}
$POPA
}
 
void draw_uf_window()
{
#ifdef DEBUG
sys_debug_write_string("MINE: îòðèñîâêà UF\n"w);
#endif
 
sys_get_colors(#colors, 40);
sys_window_redraw(1);
 
EDX = colors.w_work;
$bts edx,25
EBX = uf_x;
ECX = uf_y;
sys_draw_window(EBX, ECX, EDX, colors.w_grab | 0x80000000, colors.w_frames);
sys_draw_window(uf_x, uf_y, EDX, colors.w_grab | 0x80000000, colors.w_frames);
ECX = colors.w_grab_text | 0x10000000;
sys_write_text(7<<16+8, colors.w_grab_text | 0x10000000, "USER FIELD"n, 10);
sys_draw_button(83<<16+12, 5<<16+12, 1, colors.w_grab_button);
sys_write_text(8<<16+8, colors.w_grab_text | 0x10000000, "USER FIELD", 10);
sys_draw_button(81<<16+12, 5<<16+12, 1, colors.w_grab_button);
 
ECX = colors.w_work_text | 0x10000000;
sys_write_text(8<<16+31, ECX, "WIDTH", 5);
sys_write_text(8<<16+49, ECX, "HEIGHT", 6);
sys_write_text(8<<16+67, ECX, "MINES", 5);
 
// three buttons:
// 1) WIDTH 10
// 2) HEIGHT 11
106,39 → 66,17
sys_draw_button( 8<<16+38, ECX, 20, ESI); EDX++;
sys_draw_button(54<<16+38, ECX, EDX, ESI);
 
ECX = colors.w_work_text | 0x10000000;
sys_write_text(8<<16+32, ECX, "WIDTH"n, 5);
sys_write_text(8<<16+50, ECX, "HEIGHT"n, 6);
sys_write_text(8<<16+68, ECX, "MINES"n, 5);
sys_write_text(21<<16+85, colors.w_work_button_text, "OK Cancel", 12);
 
sys_write_text(72<<16+32, 0, #str1, 3);
sys_write_text(72<<16+50, 0, #str2, 3);
sys_write_text(72<<16+68, 0, #str3, 3);
 
sys_write_text(21<<16+86, colors.w_work_button_text, "OK Cancel", 12);
 
sys_window_redraw(2);
}
 
 
void uf_main()
{
#ifdef DEBUG
sys_debug_write_string("MINE: ïîòîê ñîçäàí\n"w);
#endif
 
// dword2str(13, #str1);
// EAX = str2dword(#str3);
// dword2str(EAX, #str2);
 
uf_x <<= 16; uf_x += 100;
uf_y <<= 16; uf_y += 104;
draw_uf_window();
 
#ifdef DEBUG
sys_debug_write_string("MINE: æäó ñîáûòèé\n"w);
#endif
 
WHILE()
{
SWITCH (sys_wait_event())
146,21 → 84,10
case 1: draw_uf_window();
break;
 
case 2: //IF (sys_get_key() == 27)
//{
// uf_open = FALSE;
// sys_exit_process();
//}
//EAX = key now!
EAX = sys_get_key();
if (active_textbox != 0)
case 2: IF (sys_get_key() == 27)
{
EBX = #str1; //active_textbox;
DSBYTE[EBX] = 'A';
DSBYTE[EBX] = DSBYTE[EBX+1];
DSBYTE[EBX+1] = DSBYTE[EBX+2];
DSBYTE[EBX+2] = AL;
draw_uf_window();
uf_open = FALSE;
sys_exit_process();
}
break;
 
173,24 → 100,12
{
switch (sys_get_button_id())
{
case 10:
// set [width] INPUT active
active_textbox = #str1; break;
case 11:
// set [height] INPUT active
active_textbox = #str2; break;
case 12:
// set [mines] INPUT active
active_textbox = #str3; break;
//case 10:
//case 11:
//case 12:
 
case 20:
// [string -> byte] three times and save them
px = str2dword(#str1);
py = str2dword(#str2);
pm = str2dword(#str3);
mode = 4;
case 21:
// close UF window, forget all changes
 
case 1:
uf_open = FALSE;
200,23 → 115,11
 
void start_uf()
{
#ifdef DEBUG
sys_debug_write_string("MINE: âûçâàíà start_uf\n"w);
#endif
 
sys_process_info(#procinfo, -1);
uf_x = procinfo.xstart + XST;
uf_y = procinfo.ystart + YST;
 
#ifdef DEBUG
sys_debug_write_string("MINE: ñîçäàþ ïîòîê...\n"w);
#endif
 
sys_create_thread(#uf_main, #uf_stack + 2048);
 
IF(EAX > 0x80000000)
return;
 
uf_open = TRUE;
mouse_disable();
WHILE (uf_open == TRUE)