Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 6166 → Rev 6024

/programs/games/mine/trunk/mine.c--
102,6 → 102,7
# 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()
/programs/games/mine/trunk/draw.h--
27,7 → 27,7
sys_window_redraw(1);
EBX = xpos << 16 + xsize;
ECX = ypos << 16 + ysize;
sys_draw_window(EBX, ECX, 0x14CCCCCC, colors.w_work | 0x80000000, "MineSweeper");
sys_draw_window(EBX, ECX, 0x14CCCCCC, colors.w_grab | 0x80000000, "MineSweeper");
sys_window_redraw(2);
// Leency ROLLED UP FIX
135,7 → 135,7
// Òàéìåð
void draw_time()
{
sys_draw_bar(XST<<16+25, 31<<16+14, 0xCCCCCC);
sys_draw_bar(XST<<16+25, 31<<16+10, 0xCCCCCC);
sys_write_number(0x00030000, time, XST<<16+32, 0x10ff0000);
}
 
146,7 → 146,7
EBX = xsize - XST - 25;
$PUSH EBX
EBX = EBX << 16 + 25;
sys_draw_bar(EBX, 31<<16+14, 0xCCCCCC);
sys_draw_bar(EBX, 31<<16+10, 0xCCCCCC);
$POP EDX
EDX <<= 16; EDX += 32;
sys_write_number(0x00030000, cmines, EDX, 0x10ff0000);
/programs/games/mine/trunk/kos_sys.h--
65,11 → 65,11
 
struct SystemColours
{
dword nonset1,
nonset2,
work_3d_dark,
work_3d_light,
w_title,
dword w_frames,
w_grab,
w_grab_button,
w_grab_button_text,
w_grab_text,
w_work,
w_work_button,
w_work_button_text,
/programs/games/mine/trunk/uf.h--
0,0 → 1,232
/*******************************************************************************
 
MenuetOS MineSweeper
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
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];
 
dword active_textbox = #str1;
 
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
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(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
// 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);
 
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())
{
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)
{
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;
 
case 3: uf_button();
}
}
}
 
uf_button()
{
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 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();
}
}
 
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)
{
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();
}
/programs/games/tetris/trunk/tetris.asm
26,6 → 26,7
; 31.10.2001 - rdtsc replaced - quickcode <quickcode@mail.ru>
; 28.06.2001 - fasm port & framed blocks - Ville Turjanmaa
;
;
 
LEN_X equ 19 ;width of table
LEN_Y equ 29 ; height of table
253,23 → 254,43
; *********************************************
draw_window:
 
mcall 48,3,sc,sizeof.system_colors
mcall 12,1
 
mov eax,48
mov ebx,3
mov ecx,sc
mov edx,sizeof.system_colors
int 0x40
 
mov eax,12 ; function 12:tell os about windowdraw
mov ebx,1 ; 1, start of draw
int 0x40
 
; DRAW WINDOW
xor eax,eax ; function 0 : define and draw window
mov ebx,320*65536+(LEN_X-BORDER_LEFT-BORDER_RIGHT)*ADOBE_SIZE+X_LOCATION*2
mov ecx,25*65536+ (LEN_Y-BORDER_TOP-BORDER_BOTTOM)*ADOBE_SIZE+Y_LOCATION+36
mov ecx,25*65536+ (LEN_Y-BORDER_TOP-BORDER_BOTTOM)*ADOBE_SIZE+Y_LOCATION+30
mov edx,[sc.work] ; color of work area RRGGBB
or edx,0x13000000
mov edi,title ; WINDOW LABEL
int 0x40
 
mcall 8, 30*65536+100,378*65536+22,2,[sc.work_button] ;new game
mcall ,132*65536+102, ,3 ;Wildwest's 'Pause' button
;///////////////////////////////////////////////
 
mov eax,8
mov ebx,30*65536+100
mov ecx,378*65536+18
mov edx,2
mov esi,[sc.work_button]
int 0x40
;/////////////////////////////////////////////// Wildwest's 'Pause' button
;mov eax,8
mov ebx,132*65536+102
mov ecx,378*65536+18
mov edx,3
mov esi,[sc.work_button];
int 0x40
 
mov eax,4 ; function 4 : write text to window
mov ebx,164*65536+383 ; [x start] *65536 + [y start]
mov ebx,164*65536+384 ; [x start] *65536 + [y start]
mov ecx,[sc.work_button_text] ; color of text RRGGBB
or ecx,0x90000000
mov edx,labe ; pointer to text
276,7 → 297,7
int 0x40
;///////////////////////////////////////////////
;mov eax,4
mov ebx,49*65536+383
mov ebx,49*65536+384
mov edx,game_finished
int 0x40
call draw_table
285,7 → 306,7
call draw_block
 
cld
mov ebx,38*65536+32 ; draw info text with function 4
mov ebx,38*65536+35 ; draw info text with function 4
mov ecx,[sc.work_text] ; color
or ecx,0x90000000
mov edx,text
637,7 → 658,7
mov eax,[score]
call number_to_str
 
mov ebx,90*65536+32 ; draw info text with function 4
mov ebx,90*65536+35 ; draw info text with function 4
mov ecx,[sc.work_text] ; color
or ecx,0x50000000
mov edx,number_str
820,7 → 841,7
 
if lang eq ru
 
title db '’¥âà¨á 1.62',0
title db '’…’ˆ‘ 1.61 - ‘’…‹Šˆ ˆ Ž…‹',0
labe db '€“‡€',0
text db 'Žçª¨:',0
game_finished: db ' Ž‚€Ÿ',0
827,7 → 848,7
 
else if lang eq et
 
title db 'Tetris 1.62',0
title db 'TETRIS 1.61 - NOOLED & TÜHIK',0
labe db 'PAUS',0
text db 'Tulemus:',0
game_finished: db 'UUS MÄNG',0
834,7 → 855,7
 
else
 
title db 'Tetris 1.62',0
title db 'TETRIS 1.61 - ARROWS & SPACE',0
labe db 'PAUSE',0
text db 'Score:',0
game_finished: db 'NEW GAME',0