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
|
|
|
|
|
|
|
|
|
|
*******************************************************************************/
|
2019-05-21 20:04:27 +02:00
|
|
|
|
?define HEADER_Y 4
|
|
|
|
|
?define BTNSIZE 19
|
|
|
|
|
char game_mode[] = "1/3";
|
2006-01-03 10:43:31 +01:00
|
|
|
|
|
2008-12-16 21:16:18 +01:00
|
|
|
|
void draw_window() // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
2006-01-03 10:43:31 +01:00
|
|
|
|
{
|
|
|
|
|
sys_get_colors(#colors, 40);
|
|
|
|
|
|
|
|
|
|
// WINDOW
|
2011-08-18 18:37:24 +02:00
|
|
|
|
sys_window_redraw(1);
|
2019-05-21 20:04:27 +02:00
|
|
|
|
EBX = xpos << 16 + xsize + 9;
|
2006-01-03 10:43:31 +01:00
|
|
|
|
ECX = ypos << 16 + ysize;
|
2019-05-21 20:04:27 +02:00
|
|
|
|
sys_draw_window(EBX, ECX, 0x34CCCCCC, colors.w_work | 0x80000000, "MineSweeper");
|
2011-08-18 18:37:24 +02:00
|
|
|
|
sys_window_redraw(2);
|
|
|
|
|
|
|
|
|
|
// Leency ROLLED UP FIX
|
|
|
|
|
sys_process_info(#procinfo, -1);
|
|
|
|
|
IF (procinfo.ysize<70) return;
|
2008-12-16 21:16:18 +01:00
|
|
|
|
|
2019-05-21 20:04:27 +02:00
|
|
|
|
// <NEW GAME> BUTTON (911)
|
2006-01-03 10:43:31 +01:00
|
|
|
|
EBX = xsize / 2 - 10;
|
2019-05-21 20:04:27 +02:00
|
|
|
|
EBX = EBX << 16 + BTNSIZE;
|
|
|
|
|
sys_draw_button(EBX, HEADER_Y<<16+BTNSIZE, 911+BT_HIDE, clLightGray);
|
|
|
|
|
draw_rectangle(xsize/2-10,HEADER_Y,BTNSIZE,BTNSIZE,clWhite,clDarkGray);
|
2006-01-03 10:43:31 +01:00
|
|
|
|
|
|
|
|
|
// <CHANGE MODE> BUTTON (1001)
|
2019-05-21 20:04:27 +02:00
|
|
|
|
sys_draw_button(5<<16+32, HEADER_Y<<16+BTNSIZE, 1001+BT_HIDE, clLightGray);
|
|
|
|
|
draw_rectangle(5,HEADER_Y,32,BTNSIZE,clWhite,clDarkGray);
|
|
|
|
|
game_mode[0] = mode + '0';
|
|
|
|
|
sys_write_text(9<<16+HEADER_Y+3, 0x90000000+clDarkGray, #game_mode, 3);
|
2006-01-03 10:43:31 +01:00
|
|
|
|
|
|
|
|
|
// <USER FIELD> BUTTON (1002)
|
2019-05-21 20:04:27 +02:00
|
|
|
|
//sys_draw_button(BTNSIZE<<16+7, ECX, EDX+1, 0xddbb44);
|
2006-01-03 10:43:31 +01:00
|
|
|
|
|
|
|
|
|
draw_time(); // draw timer
|
2019-05-21 20:04:27 +02:00
|
|
|
|
draw_mines_left(); // draw mines
|
2006-01-03 10:43:31 +01:00
|
|
|
|
draw_squares(); // draw field
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dword num_colors[8]=
|
|
|
|
|
{
|
|
|
|
|
0x4444d0, // 1
|
|
|
|
|
0x118811, // 2
|
|
|
|
|
0xd04444, // 3
|
|
|
|
|
0x111199, // 4
|
|
|
|
|
0x991111, // 5
|
|
|
|
|
0x117089, // 6
|
|
|
|
|
0x000000, // 7
|
|
|
|
|
0x808080 // 8
|
|
|
|
|
};
|
|
|
|
|
|
2006-08-14 16:06:52 +02:00
|
|
|
|
|
2006-01-03 10:43:31 +01:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2006-08-14 16:06:52 +02:00
|
|
|
|
void draw_square(int x, y)
|
2006-01-03 10:43:31 +01:00
|
|
|
|
{
|
2006-08-14 16:06:52 +02:00
|
|
|
|
int xl, xr, yt, yb; // <20><><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
dword tcolor = clBlack; // <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
byte tchar, tval;
|
2006-01-03 10:43:31 +01:00
|
|
|
|
|
|
|
|
|
xl = XPX * x + XST;
|
|
|
|
|
xr = xl + XPX - 1;
|
|
|
|
|
yt = YPX * y + YST;
|
|
|
|
|
yb = yt + YPX - 1;
|
|
|
|
|
|
2008-12-16 21:16:18 +01:00
|
|
|
|
EBX = xl+1 << 16 + xr - xl-1;
|
|
|
|
|
ECX = yt+1 << 16 + yb - yt-1;
|
2006-01-03 10:43:31 +01:00
|
|
|
|
$inc ebx
|
|
|
|
|
$inc ecx
|
2006-08-14 16:06:52 +02:00
|
|
|
|
sys_draw_bar(EBX, ECX, clLightGray); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2006-01-03 10:43:31 +01:00
|
|
|
|
|
|
|
|
|
if (!get_open(x, y))
|
|
|
|
|
{
|
2006-08-14 16:06:52 +02:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>
|
2006-01-03 10:43:31 +01:00
|
|
|
|
ECX = yt << 16 + yb - 1;
|
|
|
|
|
sys_draw_line(xl<<16+xl, ECX, clWhite);
|
|
|
|
|
EBX = xl << 16 + xr - 1;
|
|
|
|
|
sys_draw_line(EBX, yt << 16 + yt, EDX);
|
|
|
|
|
sys_draw_line(xr << 16 + xl, yb << 16 + yb, clDarkGray);
|
|
|
|
|
sys_draw_line(xr << 16 + xr, yb << 16 + yt, EDX);
|
|
|
|
|
|
|
|
|
|
SWITCH (get_mark(x, y))
|
|
|
|
|
{
|
|
|
|
|
CASE 2: tcolor = 0x121288; tchar = '?'; BREAK;
|
|
|
|
|
CASE 1: tcolor = 0xd04444; tchar = 'P';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IF (get_mark(x,y))
|
|
|
|
|
{
|
2008-12-16 21:16:18 +01:00
|
|
|
|
EBX = xl + 5 << 16 + yt + 4;
|
2006-01-03 10:43:31 +01:00
|
|
|
|
sys_write_text(EBX, tcolor, #tchar, 1);
|
|
|
|
|
EBX += 0x00010000;
|
|
|
|
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
sys_write_text(EBX, ECX, EDX, ESI);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else // get_open(x,y)==TRUE
|
|
|
|
|
{
|
|
|
|
|
tval = get_value(x, y);
|
2006-08-14 16:06:52 +02:00
|
|
|
|
IF (tval != 0)
|
2006-01-03 10:43:31 +01:00
|
|
|
|
{
|
2006-08-14 16:06:52 +02:00
|
|
|
|
IF (tval == MINE)
|
|
|
|
|
{
|
|
|
|
|
tcolor = 0xee1111;
|
|
|
|
|
tchar = '*';
|
|
|
|
|
}
|
|
|
|
|
ELSE
|
|
|
|
|
{
|
|
|
|
|
tchar = tval + '0';
|
|
|
|
|
tcolor = num_colors[tval-1];
|
|
|
|
|
}
|
2008-12-16 21:16:18 +01:00
|
|
|
|
EBX = xl + 5 << 16 + yt + 5;
|
2006-08-14 16:06:52 +02:00
|
|
|
|
sys_write_text(EBX, tcolor, #tchar, 1);
|
|
|
|
|
EBX += 0x00010000;
|
|
|
|
|
sys_write_text(EBX, ECX, EDX, ESI);
|
2006-01-03 10:43:31 +01:00
|
|
|
|
}
|
|
|
|
|
sys_draw_line(xl << 16 + xl, yt << 16 + yb, clDarkGray);
|
|
|
|
|
sys_draw_line(xl << 16 + xr, yt << 16 + yt, EDX);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2006-08-14 16:06:52 +02:00
|
|
|
|
void draw_time()
|
2006-01-03 10:43:31 +01:00
|
|
|
|
{
|
2019-05-21 20:04:27 +02:00
|
|
|
|
sys_draw_bar(xsize-XST-58<<16+29, HEADER_Y<<16+20, clWhiteGray);
|
|
|
|
|
sys_write_number(0x00030000, time, xsize-XST-56<<16+HEADER_Y+3, 0x101166C3);
|
2006-01-03 10:43:31 +01:00
|
|
|
|
}
|
|
|
|
|
|
2006-08-14 16:06:52 +02:00
|
|
|
|
|
2019-05-21 20:04:27 +02:00
|
|
|
|
void draw_mines_left()
|
2006-01-03 10:43:31 +01:00
|
|
|
|
{
|
2019-05-21 20:04:27 +02:00
|
|
|
|
sys_draw_bar(xsize-XST-29<<16+29, HEADER_Y<<16+20, clWhiteGray);
|
|
|
|
|
sys_write_number(0x00030000, cmines, xsize-XST-27<<16+HEADER_Y+3, 0x10ff0000);
|
2006-01-03 10:43:31 +01:00
|
|
|
|
}
|
|
|
|
|
|
2006-08-14 16:06:52 +02:00
|
|
|
|
|
2006-01-03 10:43:31 +01:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
2006-08-14 16:06:52 +02:00
|
|
|
|
void draw_squares()
|
2006-01-03 10:43:31 +01:00
|
|
|
|
{
|
|
|
|
|
int x,y;
|
|
|
|
|
|
2008-12-16 21:16:18 +01:00
|
|
|
|
FOR (y=0; y < ncy; y++)
|
|
|
|
|
FOR (x=0; x < ncx; x++)
|
2006-01-03 10:43:31 +01:00
|
|
|
|
draw_square(x, y);
|
2008-12-16 21:16:18 +01:00
|
|
|
|
}
|
2019-05-21 20:04:27 +02:00
|
|
|
|
|
|
|
|
|
void draw_rectangle(dword x,y,w,h,color1,color2)
|
|
|
|
|
{
|
|
|
|
|
sys_draw_bar(x<<16+w+1,y<<16+1,color1);
|
|
|
|
|
sys_draw_bar(x<<16+1,y+1<<16+h-1,color1);
|
|
|
|
|
sys_draw_bar(x+w<<16+1,y+1<<16+h,color2);
|
|
|
|
|
sys_draw_bar(x<<16+w,y+h<<16+1,color2);
|
|
|
|
|
}
|