From 09769f5e258722eb260cbc5528221de009d77d3a Mon Sep 17 00:00:00 2001 From: leency Date: Fri, 21 Mar 2025 00:08:55 +0200 Subject: [PATCH] Mine game v0.60 (21/03/2025) - proper window rolling up fix - bigger cells and fonts - add icon to a new game button --- programs/games/mine/changelog.txt | 5 +++ programs/games/mine/draw.h-- | 52 ++++++++++++++++--------------- programs/games/mine/kos_sys.h-- | 47 +++++++++++++++++++++++++++- programs/games/mine/mine.c-- | 12 ++++--- 4 files changed, 85 insertions(+), 31 deletions(-) diff --git a/programs/games/mine/changelog.txt b/programs/games/mine/changelog.txt index 512f9f168..caaf7fbc9 100644 --- a/programs/games/mine/changelog.txt +++ b/programs/games/mine/changelog.txt @@ -1,5 +1,10 @@ ====Leency==== +v0.60 (21/03/2025) +- proper window rolling up fix +- bigger cells and fonts +- add icon to a new game button + v0.52 (16/12/2008) - window rolling up fix diff --git a/programs/games/mine/draw.h-- b/programs/games/mine/draw.h-- index 4d677848b..8d50377eb 100644 --- a/programs/games/mine/draw.h-- +++ b/programs/games/mine/draw.h-- @@ -19,29 +19,29 @@ *******************************************************************************/ ?define HEADER_Y 4 -?define BTNSIZE 19 +?define BTNSIZE 21 +?define CENTER_POS xsize / 2 - 10 char game_mode[] = "1/3"; -void draw_window() // Процедура отрисовки окна +void draw_window() { - sys_get_colors(#colors, 40); + dword iconimg = sys_memopen("ICONS18", 0, SHM_READ); + //sys_get_colors(#colors, 40); - // WINDOW sys_window_redraw(1); EBX = xpos << 16 + xsize + 9; ECX = ypos << 16 + ysize; - sys_draw_window(EBX, ECX, 0x34CCCCCC, colors.w_work | 0x80000000, "MineSweeper"); - sys_window_redraw(2); + sys_draw_window(EBX, ECX, 0x34CCCCCC, clGray | 0x80000000, "MineSweeper"); - // Leency ROLLED UP FIX sys_process_info(#procinfo, -1); - IF (procinfo.ysize<70) return; + #define ROLLED_UP 0x04 + IF (procinfo.status_window&ROLLED_UP) return; // BUTTON (911) - EBX = xsize / 2 - 10; - 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); + sys_draw_button(CENTER_POS << 16 + BTNSIZE, HEADER_Y<<16+BTNSIZE, 911+BT_HIDE, clLightGray); + draw_rectangle(CENTER_POS,HEADER_Y,BTNSIZE,BTNSIZE,clWhite,clDarkGray); + draw_rectangle(CENTER_POS+1,HEADER_Y+1,BTNSIZE-2,BTNSIZE-2,clWhite,clWhite); + sys_put_palette_image(18*18*4*58 + iconimg, 18<<16+18, CENTER_POS+2<<16+HEADER_Y+2, 32, 0); // BUTTON (1001) sys_draw_button(5<<16+32, HEADER_Y<<16+BTNSIZE, 1001+BT_HIDE, clLightGray); @@ -52,9 +52,11 @@ void draw_window() // // BUTTON (1002) //sys_draw_button(BTNSIZE<<16+7, ECX, EDX+1, 0xddbb44); - draw_time(); // draw timer - draw_mines_left(); // draw mines - draw_squares(); // draw field + draw_time(); + draw_mines_left(); + draw_squares(); + + sys_window_redraw(2); } dword num_colors[8]= @@ -70,11 +72,11 @@ dword num_colors[8]= }; -// Отрисовка одной клетки +// Draw a single square void draw_square(int x, y) { - int xl, xr, yt, yb; // слева, справа, сверху, снизу - dword tcolor = clBlack; // цвет значения клетки по умолчанию черный + int xl, xr, yt, yb; // lefx, right, top, bottom + dword tcolor = clBlack; // set default color as black byte tchar, tval; xl = XPX * x + XST; @@ -86,7 +88,7 @@ void draw_square(int x, y) ECX = yt+1 << 16 + yb - yt-1; $inc ebx $inc ecx - sys_draw_bar(EBX, ECX, clLightGray); // рисует закрашенный прямоугольник + sys_draw_bar(EBX, ECX, clLightGray); // fill bg if (!get_open(x, y)) { @@ -106,10 +108,10 @@ void draw_square(int x, y) IF (get_mark(x,y)) { - EBX = xl + 5 << 16 + yt + 4; - sys_write_text(EBX, tcolor, #tchar, 1); + EBX = xl + 6 << 16 + yt + 4; + sys_write_text(EBX, tcolor + 0x10000000, #tchar, 1); EBX += 0x00010000; - /* Второй раз - регистры сохраняются */ + /* Second run - registers are saved */ sys_write_text(EBX, ECX, EDX, ESI); } } @@ -128,8 +130,8 @@ void draw_square(int x, y) tchar = tval + '0'; tcolor = num_colors[tval-1]; } - EBX = xl + 5 << 16 + yt + 5; - sys_write_text(EBX, tcolor, #tchar, 1); + EBX = xl + 7 << 16 + yt + 4; + sys_write_text(EBX, tcolor+0x10000000, #tchar, 1); EBX += 0x00010000; sys_write_text(EBX, ECX, EDX, ESI); } @@ -152,7 +154,7 @@ void draw_mines_left() } -// Отрисовка минного поля +// Draw mine field void draw_squares() { int x,y; diff --git a/programs/games/mine/kos_sys.h-- b/programs/games/mine/kos_sys.h-- index 23e1a3103..15695ca3d 100644 --- a/programs/games/mine/kos_sys.h-- +++ b/programs/games/mine/kos_sys.h-- @@ -64,7 +64,8 @@ struct ProcessInfo ystart, xsize, ysize; - byte not_used2[974]; + char status_window; + byte reserved[1024-71]; }; #define SystemColors SystemColours // usa/british @@ -212,6 +213,17 @@ inline fastcall dword sys_put_image(dword EBX, ECX, EDX) $int 0x40 } +:void sys_put_palette_image(dword inbuf,wh,xy,bits,pal) +{ + EAX = 65; + EBX = inbuf; + ECX = wh; + EDX = xy; + ESI = bits; + EDI = pal; + EBP = 0; + $int 0x40 +} /********************************************************* 08 = DEFINE BUTTON @@ -1122,6 +1134,39 @@ inline fastcall dword window_move_size(dword EBX,ECX,EDX,ESI){ $int 0x40 } +/********************************************************* +68.11 = mem_init is required to work with heap +*********************************************************/ + +inline fastcall void sys_mem_init() +{ + $mov eax, 68 + $mov ebx, 11 + $int 0x40 +} + +/********************************************************* +68.22 = shared memory +in: + ecx = area name, 31 symbols max + edx = area size for SHM_CREATE SHM_OPEN_ALWAYS + esi = flags, see the list below +out: + eax = pointer to memory or 0 + edx = memsize +*********************************************************/ + +#define SHM_OPEN 0x00 +#define SHM_OPEN_ALWAYS 0x04 +#define SHM_CREATE 0x08 +#define SHM_READ 0x00 +#define SHM_WRITE 0x01 +inline fastcall dword sys_memopen(ECX, EDX, ESI) +{ + $mov eax, 68 + $mov ebx, 22 + $int 0x40 +} /********************************************************* -1 = EXIT PROCESS diff --git a/programs/games/mine/mine.c-- b/programs/games/mine/mine.c-- index e5ace9b9e..663674900 100644 --- a/programs/games/mine/mine.c-- +++ b/programs/games/mine/mine.c-- @@ -26,15 +26,15 @@ //? define DEBUG 1 ? print "\nЪДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДї" -? print "\nі KolibriOS MineSweeper v0.52 і" -? print "\nі (C) Leency (leency@mail.ru) 2010,2011 і" +? print "\nі KolibriOS MineSweeper v0.60 і" +? print "\nі (C) Leency (leency@mail.ru) 2010-2025 і" ? 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 XPX 21 // X pixels by square - размер клетки в пикселях +? define YPX 21 // Y pixels by square ? define MINE 255 // в клетке мина, если value = MINE struct @@ -59,7 +59,7 @@ struct } stdmodes[3] = {9,9,10, 16,16,40, 30,16,99}; // {x,y,m} ?define XST 5 // offset of first pixel X - смещение поля от границы окна -?define YST 28 +?define YST 30 int ncx, // number of squares in X - размер поля ncy, @@ -429,6 +429,8 @@ void end_game() void main() { + sys_mem_init(); + new_game(); draw_window();