'libio' and 'libini': function 'get_color' not spoil register 'ecx'

game 'Nu_pogodi': revised

git-svn-id: svn://kolibrios.org@1573 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
IgorA 2010-08-20 10:31:17 +00:00
parent 7ea3c78d40
commit be3cceaea6
4 changed files with 113 additions and 59 deletions

View File

@ -81,12 +81,14 @@ proc libini._.get_char _f ;/////////////////////////////////////////////////////
;;------------------------------------------------------------------------------------------------;;
;< --- TBD --- ;;
;;================================================================================================;;
push ecx
mov ecx, [_f]
dec [ecx + IniFile.cnt]
jns @f
stdcall libini._.preload_block, [_f]
dec [ecx + IniFile.cnt]
@@: lodsb
pop ecx
ret
endp
@ -99,6 +101,7 @@ proc libini._.skip_nonblanks _f ;///////////////////////////////////////////////
;;------------------------------------------------------------------------------------------------;;
;< --- TBD --- ;;
;;================================================================================================;;
push ecx
mov ecx, [_f]
@@: stdcall libini._.get_char, [_f]
cmp al, 32
@ -114,6 +117,7 @@ proc libini._.skip_nonblanks _f ;///////////////////////////////////////////////
stdcall libini._.skip_line, [_f]
jmp @b
@@: stdcall libini._.unget_char, [_f]
pop ecx
ret
endp
@ -126,6 +130,7 @@ proc libini._.skip_spaces _f ;//////////////////////////////////////////////////
;;------------------------------------------------------------------------------------------------;;
;< --- TBD --- ;;
;;================================================================================================;;
push ecx
mov ecx, [_f]
@@: stdcall libini._.get_char, [_f]
cmp al, 32
@ -133,6 +138,7 @@ proc libini._.skip_spaces _f ;//////////////////////////////////////////////////
cmp al, 9
je @b
@@: stdcall libini._.unget_char, [_f]
pop ecx
ret
endp
@ -145,6 +151,7 @@ proc libini._.skip_line _f ;////////////////////////////////////////////////////
;;------------------------------------------------------------------------------------------------;;
;< --- TBD --- ;;
;;================================================================================================;;
push ecx
mov ecx, [_f]
@@: stdcall libini._.get_char, [_f]
or al, al
@ -154,6 +161,7 @@ proc libini._.skip_line _f ;////////////////////////////////////////////////////
cmp al, 10
jne @b
@@: stdcall libini._.unget_char, [_f]
pop ecx
ret
endp
@ -425,7 +433,7 @@ proc libini._.find_section _f, _sec_name ;//////////////////////////////////////
;< eax = -1 (fail) / 0 (ok) ;;
;< [_f.pos] = new cursor position (right after ']' char if eax = 0, at the end of file otherwise) ;;
;;================================================================================================;;
push ebx edi
push ebx ecx edi
mov ecx, [_f]
invoke file.seek, [ecx + IniFile.fh], 0, SEEK_SET
@ -461,12 +469,12 @@ proc libini._.find_section _f, _sec_name ;//////////////////////////////////////
@@:
cmp byte[edi], 0
jne .next_section
pop edi ebx
pop edi ecx ebx
xor eax, eax
ret
.exit_error:
pop edi ebx
pop edi ecx ebx
or eax, -1
ret
endp

View File

@ -179,7 +179,7 @@ locals
loc_buf rb 40
endl
push ebx esi edi
push ebx ecx esi edi
xor ebx, ebx
invoke mem.alloc, sizeof.InternalFileInfo
@ -212,7 +212,7 @@ endl
jne .exit_error.ex
@@:
mov eax, ebx
pop edi esi ebx
pop edi esi ecx ebx
ret
.exit_error.ex:
@ -233,7 +233,7 @@ endl
.exit_error:
invoke mem.free, ebx
xor eax, eax
pop edi esi ebx
pop edi esi ecx ebx
ret
endp

View File

@ -50,27 +50,24 @@ ends
displ_w dd ? ;è¨à¨­  ¯®«ï
displ_h dd ? ;¢ëá®â  ¯®«ï
displ_bytes dd ? ;à §¬¥à 1-£® ä ©«  á ¨§®¡à ¦¥­¨¥¬
;displ_bytes equ 315*210*3 ;à §¬¥à 1-£® ä ©«  á ¨§®¡à ¦¥­¨¥¬
offs_shadow_x dd ? ;ᤢ¨£ ⥭¥© ¯® ®á¨ 'x'
offs_shadow_y dd ? ;ᤢ¨£ ⥭¥© ¯® ®á¨ 'y'
OFFS_SHADOW_X equ 2 ;ᤢ¨£ ⥭¥© ¯® ®á¨ 'x'
OFFS_SHADOW_Y equ 2 ;ᤢ¨£ ⥭¥© ¯® ®á¨ 'y'
IMAGE_FONT_SIZE equ 128*144*3
use_but equ 1
if use_but eq 1
BUT1_T equ 10 ;®âáâ㯠ᢥàåã
BUT1_L equ 15 ;®âáâ㯠᫥¢ 
BUT1_W equ 50 ;è¨à¨­ 
BUT1_H equ 20 ;¢ëá®â 
BUT1_NEXT_TOP equ (BUT1_T+BUT1_H)*65536
end if
FILE_NAME_MAX equ 20 ;¬ ªá¨¬ «ì­ ï ¤«¨­­  ¨¬¥­¨ ä ©«  (¡¥§ ¯ ¯®ª, ®â­®á¨â¥«ì­® ⥪ã饩)
;§­ ç¥­¨ï ¨¬¥­ ¯® 㬮«ç ­¨î
ini_def_decorat_file db 'curici.png',0
ini_def_unit_file db 'wolf.png',0
;¨¬¥­  ä ©«®¢
fn_icon0 db 'curici.png',0 ;¨¬ï ä ©«  á ¤¥ª®à æ¨ï¬¨
fn_icon0 rb FILE_NAME_MAX ;¨¬ï ä ©«  á ¤¥ª®à æ¨ï¬¨
fn_icon1 rb FILE_NAME_MAX ;¨¬ï ä ©«  á ¢®«ª®¬ ¨ § ©æ¥¬
fn_icon2 db 'eggs.png',0 ;¨¬ï ä ©«  á ï©æ ¬¨
fn_icon3 db 'chi.png',0 ;¨¬ï ä ©«  á 樯«ïâ ¬¨
@ -78,22 +75,31 @@ fn_font db 'font8x9.bmp',0
ini_name db 'nu_pogod.ini',0
ini_sec_files db 'Files',0
key_file_decorat db 'file_decorat',0
key_file_unit db 'file_unit',0
key_displ_w db 'displ_w',0
key_displ_h db 'displ_h',0
key_shadow_x db 'offs_shadow_x',0
key_shadow_y db 'offs_shadow_y',0
ini_sec_color db 'Colors',0
;ª«îç¨ ¤«ï áç¨â뢠­¨ï 梥⮢ ¨§ *.ini ä ©« 
key_color_fon db 'background',0
key_color_shadows db 'shadows',0
key_color_egg db 'objects',0
key_color_chick db 'lost',0
key_color_decorat: db 'dec'
.ind: db '?',0
key_color_unit db 'unit',0
;æ¢¥â  ¢ ¨£à¥
color_fon dd 0xffffff
color_shadows dd 0xd0d0d0 ;梥â ⥭¥©
color_trees dd 0x008000 ;梥â âà ¢ë
color_wolf dd 0x800000 ;梥⠢®«ª  ¨ § ©æ 
color_egg dd 0x404080 ;梥â ï©æ 
color_chick dd 0x00d0d0 ;梥â 樯«¥­ª 
color_curici dd 0x8080d0 ;梥⠪ãà¨æë
color_perilo dd 0x000080 ;梥⠯¥à¨«  (£à¥¡­ï)
color_fon dd ? ;梥â ä®­ 
color_shadows dd ? ;梥â ⥭¥©
color_wolf dd ? ;梥⠢®«ª  ¨ § ©æ 
color_egg dd ? ;梥â ï©æ 
color_chick dd ? ;梥â 樯«¥­ª 
color_decorat dd ?,?,? ;æ¢¥â  ¤¥ª®à æ¨© (ªãà¨æë, ¯¥à¨« , ...)
;æ¢¥â  ¨­â¥à䥩á 
color_but_sm dd 0x808080 ;梥⠬ «¥­ìª¨å ª­®¯®ª
color_but_te dd 0xffffff ;梥â ⥪áâ  ­  ª­®¯ª å
@ -136,6 +142,7 @@ mask_lot_ld equ 100000b ;
mask_lot_ru equ 10000000000b ;¬ áª  ¤«ï ¯à ¢®£® ¢¥àå­¥£® «®âª 
mask_lot_rd equ 1000000000000000b ;¬ áª  ¤«ï ¯à ¢®£® ­¨¦­¥£® «®âª 
mask_clear_all equ 11111011111011110111101111011110b ;¬ áª  ¤«ï ®ç¨á⪨ ¯ ¤ îé¨å ï¨æ ¨ ¯à¨¡¥¦ ¢è¨å 樯«ïâ
mask_move_eggs equ 11111111111111111111b ;¬ áª  ¤¢¨¦ãé¨åáï ï¨æ
mask_fail_eggs equ 100001000010000100000b ;¬ áª  ¯ ¤ îé¨å ï¨æ
mask_chi_left equ 11111000000000000000000000b ;¬ áª  «¥¢ëå 樯«ïâ
mask_chi_right equ 11111000000000000000000000000000b ;¬ áª  ¯à ¢ëå 樯«ïâ
@ -149,7 +156,7 @@ val_zaac_time_n equ 7 ;
txt_game_a db 'ˆ£à  €',0
txt_game_b db 'ˆ£à  <20>',0
zaac_status db 0
zaac_status db 0 ;ç¨á«® ⠪⮢, ª®â®à®¥ § ïæ ­¥ ¤®«¦¥­ ¬¥­ïâì ᢮¥ ¯®«®¦¥­¨¥
pos_wolf db 0 ;¯®§¨æ¨ï ¢®«ª  0-© ¡¨â á«¥¢ /á¯à ¢ , 1-© ¡¨â ᢥàåã/¢­¨§
;rb 1
pos_eggs dd 0 ;¯®§¨æ¨¨ à á¯®«®¦¥­¨ï ï¨æ ¨ 樯«ïâ
@ -211,36 +218,35 @@ InitBackgroundBuffer: ;ᮧ
mov esi,edi
xor eax,eax
xor ebx,ebx
cld
cmp dword[offs_shadow_x],0
jne @f
cmp dword[offs_shadow_y],0
jne @f
jmp .end_shadows
@@:
mov edi,buf_decor
xor ebx,ebx
mov ecx,3
@@:
mov ax,buf2d_t
add eax,[offs_shadow_y]
mov bx,buf2d_l
add ebx,[offs_shadow_x]
stdcall [buf2d_bit_blt_alpha], esi, ebx,eax, edi,[color_shadows] ;à¨á㥬 ⥭¨ ¤¥ª®à æ¨©
add edi,BUF_STRUCT_SIZE
loop @b
.end_shadows:
mov edi,buf_decor
mov ax,buf2d_t
add eax,OFFS_SHADOW_Y
mov bx,buf2d_l
add ebx,OFFS_SHADOW_X
stdcall [buf2d_bit_blt_alpha], esi, ebx,eax, edi,[color_shadows] ;à¨á㥬 ⥭¨ ¤®¬¨ª®¢
add edi,BUF_STRUCT_SIZE
mov ax,buf2d_t
add eax,OFFS_SHADOW_Y
mov bx,buf2d_l
add ebx,OFFS_SHADOW_X
stdcall [buf2d_bit_blt_alpha], esi, ebx,eax, edi,[color_shadows] ;à¨á㥬 ⥭¨ ªãà¨æ
add edi,BUF_STRUCT_SIZE
mov ax,buf2d_t
add eax,OFFS_SHADOW_Y
mov bx,buf2d_l
add ebx,OFFS_SHADOW_X
stdcall [buf2d_bit_blt_alpha], esi, ebx,eax, edi,[color_shadows] ;à¨á㥬 ⥭¨ ¤¥à¥¢ì¥¢
mov edi,buf_decor
mov ax,buf2d_t
stdcall [buf2d_bit_blt_alpha], esi, 0,eax, edi,[color_perilo] ;à¨á㥬 ¤®¬¨ª¨
add edi,BUF_STRUCT_SIZE
mov ax,buf2d_t
stdcall [buf2d_bit_blt_alpha], esi, 0,eax, edi,[color_curici] ;à¨á㥬 ªãà¨æë
add edi,BUF_STRUCT_SIZE
mov ax,buf2d_t
stdcall [buf2d_bit_blt_alpha], esi, 0,eax, edi,[color_trees] ;à¨á㥬 ¤¥à¥¢ìï
mov ebx,color_decorat
mov ecx,3
@@:
mov ax,buf2d_t
stdcall [buf2d_bit_blt_alpha], esi, 0,eax, edi,[ebx] ;à¨á㥬 ¤¥ª®à æ¨¨
add edi,BUF_STRUCT_SIZE
add ebx,4
loop @b
popad
ret
@ -510,6 +516,14 @@ MoveEggs:
.no_zaac_move:
;ᮧ¤ ­¨¥ ­®¢ëå ï¨æ
cmp word[eggs_count],5 ;¯¥à¢ë¥ 5 ï¨æ ª âïâáï ¯® 1-¬ã
jge @f
mov ecx,dword[pos_eggs]
and ecx,mask_move_eggs
;cmp ecx,0
jnz .end_creat
@@:
bt dword[rand_x],4 ;¯à®¢¥à塞 ¡ã¤¥¬ «¨ ᮧ¤ ¢ âì ­®¢®¥ ï©æ®
jc .end_creat
bt dword[rand_x],5 ;¯à®¢¥à塞 á ª ª®© áâ®à®­ë ¡ã¤¥¬ ᮧ¤ ¢ âì ­®¢®¥ ï©æ®
@ -610,10 +624,34 @@ start:
mov dword[displ_w],eax
stdcall dword[ini_get_int],file_name,ini_sec_files,key_displ_h,140
mov dword[displ_h],eax
stdcall dword[ini_get_str],file_name,ini_sec_files,key_file_decorat,fn_icon0,FILE_NAME_MAX,ini_def_decorat_file
stdcall dword[ini_get_str],file_name,ini_sec_files,key_file_unit,fn_icon1,FILE_NAME_MAX,ini_def_unit_file
stdcall dword[ini_get_int],file_name,ini_sec_files,key_shadow_x,2
mov dword[offs_shadow_x],eax
stdcall dword[ini_get_int],file_name,ini_sec_files,key_shadow_y,2
mov dword[offs_shadow_y],eax
stdcall dword[ini_get_color],file_name,ini_sec_color,key_color_fon,0xffffff
mov dword[color_fon],eax
stdcall dword[ini_get_color],file_name,ini_sec_color,key_color_shadows,0xd0d0d0
mov dword[color_shadows],eax
stdcall dword[ini_get_color],file_name,ini_sec_color,key_color_unit,0
mov dword[color_wolf],eax
stdcall dword[ini_get_str],file_name,ini_sec_files,key_file_unit,fn_icon1,FILE_NAME_MAX,ini_def_unit_file
stdcall dword[ini_get_color],file_name,ini_sec_color,key_color_egg,0x404080
mov dword[color_egg],eax
stdcall dword[ini_get_color],file_name,ini_sec_color,key_color_chick,0x00d0d0
mov dword[color_chick],eax
mov ebx,color_decorat
mov byte[key_color_decorat.ind],'0'
mov ecx,3
cld
@@:
stdcall dword[ini_get_color],file_name,ini_sec_color,key_color_decorat,0x000080
mov dword[ebx],eax
add ebx,4
inc byte[key_color_decorat.ind]
loop @b
mov edx,dword[displ_w]
imul edx,dword[displ_h]
@ -790,7 +828,6 @@ draw_window:
inc esi
.draw_s:
if use_but eq 1
; *** à¨á®¢ ­¨¥ ª­®¯®ª ***
push esi
mov eax,8
@ -828,7 +865,6 @@ pop esi
; *** ¢®ááâ ­®¢«¥­¨¥ ¯ à ¬¥â஢ ***
mov eax,13 ;à¨á®¢ ­¨¥ ¯àאַ㣮«ì­¨ª 
mov edx,[sc.work]
end if
mov ebx,esi
mov ecx,dword[procinfo.client_box.height]
@ -863,7 +899,7 @@ draw_display:
push eax
mov eax,dword[displ_w]
shr eax,1
stdcall [buf2d_draw_text], buf_displ, buf_font,game_text,eax,OFFS_SHADOW_X,[color_curici] ;à¨á㥬 áâபã á ⥪á⮬
stdcall [buf2d_draw_text], buf_displ, buf_font,game_text,eax,[offs_shadow_x],[color_wolf] ;à¨á㥬 áâபã á ⥪á⮬
pop eax
stdcall [buf2d_draw], buf_displ
ret
@ -871,7 +907,7 @@ pop eax
align 4
button:
mcall 17 ;¯®«ãç¨âì ª®¤ ­ ¦ â®© ª­®¯ª¨
if use_but eq 1
cmp ah,5
jne @f
stdcall InitGame,0
@ -879,7 +915,7 @@ button:
cmp ah,6
jne @f
stdcall InitGame,1
@@: end if
@@:
cmp ah,1
jne still
.exit:
@ -990,7 +1026,7 @@ image_data dd 0 ;
image_data_gray dd 0 ;¯ ¬ïâì á ¢à¥¬¥­­ë¬¨ á¥à묨 ¨§®¡à ¦¥­¨ï¬¨ ¢ ä®à¬ â¥ 24-bit, ¨§ ª®â®àëå ¡ã¤ãâ ᮧ¤ ¢ âìáï âà ä à¥âë
run_file_70 FileInfoBlock
hed db 'Nu pogodi 03.08.10',0 ;¯®¤¯¨áì ®ª­ 
hed db 'Nu pogodi 20.08.10',0 ;¯®¤¯¨áì ®ª­ 
sc system_colors ;á¨á⥬­ë¥ 梥â 
align 4

View File

@ -1,6 +1,16 @@
[Files]
displ_w=315
displ_h=210
file_decorat=curici.png
file_unit=wolf.png
offs_shadow_x=2
offs_shadow_y=2
[Colors]
unit=128,0,0
background=255,255,255 ;цвет фона
shadows=200,200,200 ;цвет теней
unit=64,0,0 ;цвет играка
objects=64,64,128 ;цвет двигающихся предметов
lost=0,208,208 ;цвет пропущенных предметов
dec0=0,0,128
dec1=128,128,208
dec2=0,128,0