2006-01-03 10:43:31 +01:00
|
|
|
|
/*******************************************************************************
|
|
|
|
|
|
|
|
|
|
MenuetOS MineSweeper
|
2006-08-14 16:06:52 +02:00
|
|
|
|
Copyright (C) 2003, 2004 Ivan Poddubny
|
2006-01-03 10:43:31 +01:00
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
|
|
|
|
|
|
*******************************************************************************/
|
|
|
|
|
|
|
|
|
|
// USER FIELD WINDOW
|
|
|
|
|
|
|
|
|
|
byte px,py,pm;
|
|
|
|
|
|
|
|
|
|
byte uf_open = FALSE;
|
|
|
|
|
byte uf_stack[2048];
|
|
|
|
|
|
2006-08-14 16:06:52 +02:00
|
|
|
|
dword active_textbox = #str1;
|
2006-01-03 10:43:31 +01:00
|
|
|
|
|
2006-08-14 16:06:52 +02:00
|
|
|
|
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 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> 3<><33> <20><><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD>
|
|
|
|
|
// IN: EAX = <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
// OUT: EAX = <20><><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
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
|
|
|
|
|
}
|
2006-01-03 10:43:31 +01:00
|
|
|
|
|
|
|
|
|
void draw_uf_window()
|
|
|
|
|
{
|
2006-08-14 16:06:52 +02:00
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
sys_debug_write_string("MINE: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> UF\n"w);
|
|
|
|
|
#endif
|
|
|
|
|
|
2006-01-03 10:43:31 +01:00
|
|
|
|
sys_get_colors(#colors, 40);
|
|
|
|
|
sys_window_redraw(1);
|
|
|
|
|
|
|
|
|
|
EDX = colors.w_work;
|
|
|
|
|
$bts edx,25
|
2006-08-14 16:06:52 +02:00
|
|
|
|
EBX = uf_x;
|
|
|
|
|
ECX = uf_y;
|
|
|
|
|
sys_draw_window(EBX, ECX, EDX, colors.w_grab | 0x80000000, colors.w_frames);
|
2006-01-03 10:43:31 +01:00
|
|
|
|
ECX = colors.w_grab_text | 0x10000000;
|
2006-08-14 16:06:52 +02:00
|
|
|
|
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);
|
2006-01-03 10:43:31 +01:00
|
|
|
|
|
|
|
|
|
// three buttons:
|
|
|
|
|
// 1) WIDTH 10
|
|
|
|
|
// 2) HEIGHT 11
|
|
|
|
|
// 3) MINES 12
|
|
|
|
|
// and also:
|
|
|
|
|
// OK, Cancel - 20,21
|
|
|
|
|
|
|
|
|
|
sys_draw_button(54<<16+38, 30<<16+10, 10, 0xe0e0e0); // WIDTH
|
|
|
|
|
EDX++; sys_draw_button(EBX, 48<<16+10, EDX, ESI); // HEIGHT
|
|
|
|
|
EDX++; sys_draw_button(EBX, 66<<16+10, EDX, ESI); // MINES
|
|
|
|
|
|
|
|
|
|
ESI = colors.w_work_button;
|
|
|
|
|
ECX = 84<<16+10;
|
|
|
|
|
sys_draw_button( 8<<16+38, ECX, 20, ESI); EDX++;
|
|
|
|
|
sys_draw_button(54<<16+38, ECX, EDX, ESI);
|
|
|
|
|
|
2006-08-14 16:06:52 +02:00
|
|
|
|
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);
|
2006-01-03 10:43:31 +01:00
|
|
|
|
|
|
|
|
|
sys_window_redraw(2);
|
|
|
|
|
}
|
|
|
|
|
|
2006-08-14 16:06:52 +02:00
|
|
|
|
|
2006-01-03 10:43:31 +01:00
|
|
|
|
void uf_main()
|
|
|
|
|
{
|
2006-08-14 16:06:52 +02:00
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
sys_debug_write_string("MINE: <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n"w);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
// dword2str(13, #str1);
|
|
|
|
|
// EAX = str2dword(#str3);
|
|
|
|
|
// dword2str(EAX, #str2);
|
|
|
|
|
|
2006-01-03 10:43:31 +01:00
|
|
|
|
uf_x <<= 16; uf_x += 100;
|
|
|
|
|
uf_y <<= 16; uf_y += 104;
|
|
|
|
|
draw_uf_window();
|
|
|
|
|
|
2006-08-14 16:06:52 +02:00
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
sys_debug_write_string("MINE: <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n"w);
|
|
|
|
|
#endif
|
|
|
|
|
|
2006-01-03 10:43:31 +01:00
|
|
|
|
WHILE()
|
|
|
|
|
{
|
|
|
|
|
SWITCH (sys_wait_event())
|
|
|
|
|
{
|
|
|
|
|
case 1: draw_uf_window();
|
|
|
|
|
break;
|
|
|
|
|
|
2006-08-14 16:06:52 +02:00
|
|
|
|
case 2: //IF (sys_get_key() == 27)
|
|
|
|
|
//{
|
|
|
|
|
// uf_open = FALSE;
|
|
|
|
|
// sys_exit_process();
|
|
|
|
|
//}
|
|
|
|
|
//EAX = key now!
|
|
|
|
|
EAX = sys_get_key();
|
|
|
|
|
if (active_textbox != 0)
|
2006-01-03 10:43:31 +01:00
|
|
|
|
{
|
2006-08-14 16:06:52 +02:00
|
|
|
|
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();
|
2006-01-03 10:43:31 +01:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 3: uf_button();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uf_button()
|
|
|
|
|
{
|
|
|
|
|
switch (sys_get_button_id())
|
|
|
|
|
{
|
2006-08-14 16:06:52 +02:00
|
|
|
|
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;
|
2006-01-03 10:43:31 +01:00
|
|
|
|
|
|
|
|
|
case 20:
|
2006-08-14 16:06:52 +02:00
|
|
|
|
// [string -> byte] three times and save them
|
|
|
|
|
px = str2dword(#str1);
|
|
|
|
|
py = str2dword(#str2);
|
|
|
|
|
pm = str2dword(#str3);
|
|
|
|
|
mode = 4;
|
2006-01-03 10:43:31 +01:00
|
|
|
|
case 21:
|
2006-08-14 16:06:52 +02:00
|
|
|
|
// close UF window, forget all changes
|
2006-01-03 10:43:31 +01:00
|
|
|
|
|
|
|
|
|
case 1:
|
2006-08-14 16:06:52 +02:00
|
|
|
|
uf_open = FALSE;
|
|
|
|
|
sys_exit_process();
|
2006-01-03 10:43:31 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void start_uf()
|
|
|
|
|
{
|
2006-08-14 16:06:52 +02:00
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
sys_debug_write_string("MINE: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> start_uf\n"w);
|
|
|
|
|
#endif
|
|
|
|
|
|
2006-01-03 10:43:31 +01:00
|
|
|
|
sys_process_info(#procinfo, -1);
|
|
|
|
|
uf_x = procinfo.xstart + XST;
|
|
|
|
|
uf_y = procinfo.ystart + YST;
|
|
|
|
|
|
2006-08-14 16:06:52 +02:00
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
sys_debug_write_string("MINE: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>...\n"w);
|
|
|
|
|
#endif
|
|
|
|
|
|
2006-01-03 10:43:31 +01:00
|
|
|
|
sys_create_thread(#uf_main, #uf_stack + 2048);
|
2006-08-14 16:06:52 +02:00
|
|
|
|
|
|
|
|
|
IF(EAX > 0x80000000)
|
|
|
|
|
return;
|
|
|
|
|
|
2006-01-03 10:43:31 +01:00
|
|
|
|
uf_open = TRUE;
|
|
|
|
|
mouse_disable();
|
|
|
|
|
WHILE (uf_open == TRUE)
|
|
|
|
|
{
|
|
|
|
|
SWITCH (sys_wait_event_timeout(5))
|
|
|
|
|
{
|
|
|
|
|
CASE 1: draw_window(); CONTINUE;
|
|
|
|
|
CASE 2: sys_get_key(); CONTINUE;
|
|
|
|
|
CASE 3: sys_get_button_id(); CONTINUE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
mouse_enable();
|
|
|
|
|
}
|