mirror of
https://github.com/KolibriOS/kolibrios.git
synced 2024-11-23 17:29:37 +03:00
v0.4 (16/10/2004)
- small fixes - resizing by kernel v0.3c (16/09/2003) - mines indicator fixed - better timer v0.3b (13/08/2003) - mines indicator fixed git-svn-id: svn://kolibrios.org@126 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
615d8e83ab
commit
c0ef030710
@ -1,15 +0,0 @@
|
||||
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
|
@ -1,7 +1,7 @@
|
||||
/*******************************************************************************
|
||||
|
||||
MenuetOS MineSweeper
|
||||
Copyright (C) 2003 Ivan Poddubny
|
||||
Copyright (C) 2003, 2004 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,7 +22,6 @@
|
||||
void draw_window()
|
||||
// Ïðîöåäóðà îòðèñîâêè îêíà
|
||||
{
|
||||
mouse_disable();
|
||||
|
||||
sys_window_redraw(1);
|
||||
sys_get_colors(#colors, 40);
|
||||
@ -33,7 +32,7 @@ void draw_window()
|
||||
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, "MeOS MineSweeper", 16);
|
||||
sys_write_text(8<<16+8, colors.w_grab_text | 0x10000000, "MineSweeper", 11);
|
||||
|
||||
// <CLOSE> BUTTON (1)
|
||||
EBX = xsize - 19; EBX = EBX<<16 + 12;
|
||||
@ -44,11 +43,16 @@ void draw_window()
|
||||
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);
|
||||
|
||||
// <USER FIELD> BUTTON (1002)
|
||||
//sys_draw_button(20<<16+7, ECX, EDX+1, 0xddbb44);
|
||||
// sys_draw_button(20<<16+7, ECX, EDX+1, 0xddbb44);
|
||||
|
||||
// <OPTIONS> BUTTON (1003)
|
||||
// sys_draw_button();
|
||||
@ -65,7 +69,6 @@ void draw_window()
|
||||
draw_minesi(); // draw mines
|
||||
draw_squares(); // draw field
|
||||
|
||||
mouse_enable();
|
||||
}
|
||||
|
||||
dword num_colors[8]=
|
||||
@ -80,12 +83,13 @@ dword num_colors[8]=
|
||||
0x808080 // 8
|
||||
};
|
||||
|
||||
void draw_square(int x, y)
|
||||
|
||||
// Îòðèñîâêà îäíîé êëåòêè
|
||||
void draw_square(int x, y)
|
||||
{
|
||||
int xl, xr, yt, yb;
|
||||
dword tcolor = clBlack;
|
||||
byte tchar,tval;
|
||||
int xl, xr, yt, yb; // ñëåâà, ñïðàâà, ñâåðõó, ñíèçó
|
||||
dword tcolor = clBlack; // öâåò çíà÷åíèÿ êëåòêè ïî óìîë÷àíèþ ÷åðíûé
|
||||
byte tchar, tval;
|
||||
|
||||
xl = XPX * x + XST;
|
||||
xr = xl + XPX - 1;
|
||||
@ -96,10 +100,11 @@ void draw_square(int x, y)
|
||||
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;
|
||||
@ -125,56 +130,54 @@ void draw_square(int x, y)
|
||||
else // get_open(x,y)==TRUE
|
||||
{
|
||||
tval = get_value(x, y);
|
||||
IF (tval == 0)
|
||||
IF (tval != 0)
|
||||
{
|
||||
//tcolor=clLightGray;
|
||||
//tchar=' ';
|
||||
GOTO NOCHAR;
|
||||
IF (tval == MINE)
|
||||
{
|
||||
tcolor = 0xee1111;
|
||||
tchar = '*';
|
||||
}
|
||||
ELSE
|
||||
{
|
||||
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);
|
||||
}
|
||||
ELSE IF (tval == MINE)
|
||||
{
|
||||
tcolor = 0xee1111;
|
||||
tchar = '*';
|
||||
}
|
||||
ELSE
|
||||
{
|
||||
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;
|
||||
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+12, 0xCCCCCC);
|
||||
sys_draw_bar(EBX, 31<<16+10, 0xCCCCCC);
|
||||
$POP EDX
|
||||
EDX <<= 16; EDX += 30;
|
||||
EDX <<= 16; EDX += 32;
|
||||
EBX = 0x00030000;
|
||||
sys_write_number(EBX, cmines, EDX, 0x10ff0000);
|
||||
}
|
||||
|
||||
void draw_squares()
|
||||
|
||||
// Îòðèñîâêà ìèííîãî ïîëÿ
|
||||
void draw_squares()
|
||||
{
|
||||
int x,y;
|
||||
|
||||
|
2
programs/games/mine/trunk/make.bat
Normal file
2
programs/games/mine/trunk/make.bat
Normal file
@ -0,0 +1,2 @@
|
||||
@E:\C--\bin\c-- mine.c-- /meos
|
||||
@pause > nul
|
@ -1,7 +1,7 @@
|
||||
/*******************************************************************************
|
||||
|
||||
MenuetOS MineSweeper
|
||||
Copyright (C) 2003 Ivan Poddubny
|
||||
Copyright (C) 2003, 2004 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 meos
|
||||
? pragma option LST // generate ASM listing file - ñîçäàòü àññåìáëåðíûé ëèñòèíã
|
||||
? warning TRUE // âêëþ÷èòü ðåæèì âûâîäà ïðåäóïðåæäåíèé
|
||||
? jumptomain NONE
|
||||
? include "msys.h--" // MenuetOS system functions - ñèñòåìíûå ôóíêöèè MenuetOS
|
||||
? include "msys.h--" // MenuetOS system functions - ñèñòåìíûå ôóíêöèè MenuetOS
|
||||
//? define DEBUG 1
|
||||
|
||||
? print "\nÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿"
|
||||
? print "\n³ MeOS MineSweeper v0.3 ³"
|
||||
? print "\n³ (C) Ivan Poddubny (ivan-yar@bk.ru) 2003 ³"
|
||||
? print "\nÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ\n\n"
|
||||
? print "\nÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿"
|
||||
? print "\n³ MenuetOS MineSweeper v0.4 ³"
|
||||
? print "\n³ (C) Ivan Poddubny (ivan-yar@bk.ru) 2003,2004 ³"
|
||||
? print "\nÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ\n\n"
|
||||
|
||||
/************************************** DATA **************************************/
|
||||
|
||||
? define XPX 16 // X pixels by square - ðàçìåð êëåòêè â ïèêñåëÿõ
|
||||
? define YPX 16 // Y pixels by square
|
||||
? define MINE 255 // çíà÷åíèå äëÿ ìèíû â ïîëå value
|
||||
? define MINE 255 // â êëåòêå ìèíà, åñëè value = MINE
|
||||
|
||||
struct
|
||||
{
|
||||
@ -59,7 +59,7 @@ struct
|
||||
|
||||
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,6 +88,7 @@ inline void fastcall mouse_enable()
|
||||
$int 0x40
|
||||
}
|
||||
|
||||
|
||||
inline void fastcall mouse_disable()
|
||||
{
|
||||
$mov eax,40
|
||||
@ -95,14 +96,16 @@ inline void fastcall mouse_disable()
|
||||
$int 0x40
|
||||
}
|
||||
|
||||
|
||||
? include "timer.h--" // timer functions
|
||||
? include "draw.h--" // drawing functions
|
||||
? include "access.h--" // get & set functions
|
||||
? include "random.h--" // random number generator
|
||||
//? include "uf.h--" // user field window
|
||||
|
||||
|
||||
void init()
|
||||
// Èíèöèàëèçàöè
|
||||
// Èíèöèàëèçàöèÿ
|
||||
{
|
||||
XST = 10; YST = 52; // FIELD POSITION IN WINDOW
|
||||
|
||||
@ -126,6 +129,7 @@ void init()
|
||||
ysize = ncy * YPX + YST + XST;
|
||||
} // init
|
||||
|
||||
|
||||
void clear_all()
|
||||
// Î÷èñòèòü ïîëå
|
||||
{
|
||||
@ -135,10 +139,11 @@ void clear_all()
|
||||
$REP $STOSD
|
||||
} // clear_all
|
||||
|
||||
|
||||
void new_game()
|
||||
// Íîâàÿ èãðà
|
||||
{
|
||||
init(); // èíèöèàëèçàöè
|
||||
init(); // èíèöèàëèçàöèÿ
|
||||
randomize(); // ãåíåðàòîð ñëó÷àéíûõ ÷èñåë
|
||||
clear_all(); // î÷èñòèòü ïîëå
|
||||
|
||||
@ -149,16 +154,22 @@ void new_game()
|
||||
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);
|
||||
@ -190,13 +201,18 @@ void set_mines(int nminas, no_x, no_y)
|
||||
}
|
||||
} // set_mines
|
||||
|
||||
|
||||
inline void do_mouse(void)
|
||||
// Îáðàáîò÷èê ìûøè
|
||||
{
|
||||
int x,y;
|
||||
|
||||
EAX = sys_read_mouse(2); // ìûøü íå íàæàòà -> âûõîä
|
||||
IF (EAX == 0) return;
|
||||
IF (EAX == 0)
|
||||
{
|
||||
// sys_debug_write_string("Strange\n");
|
||||
return;
|
||||
}
|
||||
|
||||
mouse_status = AL;
|
||||
|
||||
@ -216,8 +232,10 @@ inline void do_mouse(void)
|
||||
IF (firstmine == TRUE)
|
||||
{
|
||||
firstmine = FALSE;
|
||||
set_mines(cmines, x, y);
|
||||
set_mines(initmines, x, y);
|
||||
start_timer();
|
||||
time = 1;
|
||||
draw_time();
|
||||
}
|
||||
IF (get_value(x, y) == MINE)
|
||||
{
|
||||
@ -252,10 +270,10 @@ inline void do_mouse(void)
|
||||
end_game();
|
||||
}
|
||||
|
||||
if (sqclosed == 0)
|
||||
// îòêðûòû âñå êëåòêè
|
||||
// all squares are opened
|
||||
IF (sqclosed == 0)
|
||||
{
|
||||
// îòêðûòû âñå êëåòêè
|
||||
// all squares are opened
|
||||
mouse_en = FALSE; // çàïðåòèòü ìûøü
|
||||
stop_timer();
|
||||
stop_game = TRUE; // èãðà çàâåðøåíà
|
||||
@ -273,11 +291,16 @@ inline void do_mouse(void)
|
||||
}
|
||||
} // 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--;
|
||||
|
||||
@ -305,12 +328,17 @@ void open_square(int x, y)
|
||||
}
|
||||
} // open_square
|
||||
|
||||
|
||||
int open_near_squares(int x, y)
|
||||
// Îòêðûòü áëèçëåæàùèå êëåòêè (îáå êíîïêè ìûøè âìåñòå)
|
||||
{
|
||||
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++)
|
||||
@ -349,16 +377,21 @@ int open_near_squares(int x, y)
|
||||
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++)
|
||||
@ -397,7 +430,7 @@ void end_game()
|
||||
|
||||
void main()
|
||||
{
|
||||
sys_delay(5); // for old kernel only!
|
||||
//sys_delay(5); // for old kernel only!
|
||||
new_game();
|
||||
draw_window();
|
||||
|
||||
@ -406,16 +439,16 @@ void main()
|
||||
{
|
||||
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
|
||||
{
|
||||
@ -429,32 +462,31 @@ void main()
|
||||
// mode++; mode%=3; mode++;
|
||||
EAX = mode; EAX++; EAX = EAX%3; EAX++; mode = AL;
|
||||
|
||||
// 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();
|
||||
new_game();
|
||||
EBX = ECX = -1;
|
||||
EDX = xsize;
|
||||
ESI = ysize;
|
||||
EAX = 67;
|
||||
$int 0x40
|
||||
continue;
|
||||
}
|
||||
//ELSE IF (EAX == 1002)
|
||||
//{
|
||||
// start_uf();
|
||||
//}
|
||||
// ELSE IF (EAX == 1002)
|
||||
// {
|
||||
// start_uf();
|
||||
// }
|
||||
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(6);
|
||||
sys_delay(3);
|
||||
CONTINUE;
|
||||
}
|
||||
check_timer();
|
||||
@ -465,4 +497,4 @@ void main()
|
||||
check_timer();
|
||||
sys_delay(2);
|
||||
}
|
||||
} // main
|
||||
} // main
|
File diff suppressed because it is too large
Load Diff
@ -1,7 +1,7 @@
|
||||
/*******************************************************************************
|
||||
|
||||
MenuetOS MineSweeper
|
||||
Copyright (C) 2003 Ivan Poddubny
|
||||
Copyright (C) 2003, 2004 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
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*******************************************************************************
|
||||
|
||||
MenuetOS MineSweeper
|
||||
Copyright (C) 2003 Ivan Poddubny
|
||||
Copyright (C) 2003, 2004 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,12 +26,20 @@ byte timer_life;
|
||||
|
||||
start_timer()
|
||||
{
|
||||
#ifdef DEBUG
|
||||
sys_debug_write_string("MINE: timer started\n");
|
||||
#endif
|
||||
|
||||
timer_life = TRUE;
|
||||
ttime = sys_get_clock();
|
||||
ttime = sys_get_setup_devices(9); //sys_get_clock();
|
||||
}
|
||||
|
||||
stop_timer()
|
||||
{
|
||||
#ifdef DEBUG
|
||||
sys_debug_write_string("MINE: timer stopped\n");
|
||||
#endif
|
||||
|
||||
timer_life = FALSE;
|
||||
}
|
||||
|
||||
@ -39,12 +47,11 @@ check_timer()
|
||||
{
|
||||
IF (!timer_life) return;
|
||||
|
||||
EAX = sys_get_clock();
|
||||
IF (EAX == 0xffffff) return;
|
||||
ECX = sys_get_setup_devices(9); //sys_get_clock();
|
||||
|
||||
IF (ttime != EAX)
|
||||
IF (ttime+100 < ECX)
|
||||
{
|
||||
ttime = EAX;
|
||||
ttime += 100;
|
||||
IF (time < 999)
|
||||
time++;
|
||||
draw_time();
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*******************************************************************************
|
||||
|
||||
MenuetOS MineSweeper
|
||||
Copyright (C) 2003 Ivan Poddubny
|
||||
Copyright (C) 2003, 2004 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,29 +26,69 @@ byte px,py,pm;
|
||||
byte uf_open = FALSE;
|
||||
byte uf_stack[2048];
|
||||
|
||||
byte str1[5];
|
||||
byte str2[5];
|
||||
byte str3[5];
|
||||
dword active_textbox = #str1;
|
||||
|
||||
dword uf_x,
|
||||
uf_y;
|
||||
byte str1[4] = {'1','1','1',0};
|
||||
byte str2[4] = {'2','2','2',0};
|
||||
byte str3[4] = {'3','2','1',0};
|
||||
|
||||
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
|
||||
sys_draw_window(uf_x, uf_y, EDX, colors.w_grab | 0x80000000, colors.w_frames);
|
||||
EBX = uf_x;
|
||||
ECX = uf_y;
|
||||
sys_draw_window(EBX, ECX, EDX, colors.w_grab | 0x80000000, colors.w_frames);
|
||||
ECX = colors.w_grab_text | 0x10000000;
|
||||
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);
|
||||
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);
|
||||
|
||||
// three buttons:
|
||||
// 1) WIDTH 10
|
||||
@ -66,17 +106,39 @@ void draw_uf_window()
|
||||
sys_draw_button( 8<<16+38, ECX, 20, ESI); EDX++;
|
||||
sys_draw_button(54<<16+38, ECX, EDX, ESI);
|
||||
|
||||
sys_write_text(21<<16+85, colors.w_work_button_text, "OK Cancel", 12);
|
||||
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(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())
|
||||
@ -84,10 +146,21 @@ void uf_main()
|
||||
case 1: draw_uf_window();
|
||||
break;
|
||||
|
||||
case 2: IF (sys_get_key() == 27)
|
||||
case 2: //IF (sys_get_key() == 27)
|
||||
//{
|
||||
// uf_open = FALSE;
|
||||
// sys_exit_process();
|
||||
//}
|
||||
//EAX = key now!
|
||||
EAX = sys_get_key();
|
||||
if (active_textbox != 0)
|
||||
{
|
||||
uf_open = FALSE;
|
||||
sys_exit_process();
|
||||
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();
|
||||
}
|
||||
break;
|
||||
|
||||
@ -100,26 +173,50 @@ uf_button()
|
||||
{
|
||||
switch (sys_get_button_id())
|
||||
{
|
||||
//case 10:
|
||||
//case 11:
|
||||
//case 12:
|
||||
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 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;
|
||||
sys_exit_process();
|
||||
uf_open = FALSE;
|
||||
sys_exit_process();
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user