Apps: fixed 3 programs for using a long path in parameters
[kolibrios.git] / programs / games / nu_pogodi / trunk / nu_pogod.asm
blobbde9bd6063d1cd18763e2294151b3241fe8b3080
1 use32
2 org 0
3 db 'MENUET01' ;¨¤¥­â¨ä. ¨á¯®«­ï¥¬®£® ä ©«  ¢á¥£¤  8 ¡ ©â
4 dd 1, start, i_end, mem, stacktop, 0, sys_path
6 include '../../../macros.inc'
7 include '../../../proc32.inc'
8 include '../../../KOSfuncs.inc'
9 include '../../../load_lib.mac'
10 include '../../../develop/libraries/box_lib/trunk/box_lib.mac' ;¬ ªà®áë ¤«ï § ¤ ­¨ï í«¥¬¥­â®¢ box_lib
11 include '../../../dll.inc'
13 @use_library mem.Alloc,mem.Free,mem.ReAlloc, dll.Load
15 ;ä« £¨, ¤«ï ä㭪樨 ®¡à¥§ ­¨ï ¡ãä¥à 
16 BUF2D_OPT_CROP_TOP equ 1 ;®¡à¥§ª  ᢥàåã
17 BUF2D_OPT_CROP_LEFT equ 2 ;®¡à¥§ª  á«¥¢ 
18 BUF2D_OPT_CROP_BOTTOM equ 4 ;®¡à¥§ª  á­¨§ã
19 BUF2D_OPT_CROP_RIGHT equ 8 ;®¡à¥§ª  á¯à ¢ 
20 BUF2D_BIT_OPT_CROP_TOP equ 0
21 BUF2D_BIT_OPT_CROP_LEFT equ 1
22 BUF2D_BIT_OPT_CROP_BOTTOM equ 2
23 BUF2D_BIT_OPT_CROP_RIGHT equ 3
25 BUF_STRUCT_SIZE equ 21
26 buf2d_data equ dword[edi] ;¤ ­­ë¥ ¡ãä¥à  ¨§®¡à ¦¥­¨ï
27 buf2d_w equ dword[edi+8] ;è¨à¨­  ¡ãä¥à 
28 buf2d_h equ dword[edi+12] ;¢ëá®â  ¡ãä¥à 
29 buf2d_l equ word[edi+4] ;®âáâ㯠᫥¢ 
30 buf2d_t equ word[edi+6] ;®âáâ㯠ᢥàåã
31 buf2d_size_lt equ dword[edi+4] ;®âáâ㯠᫥¢  ¨ á¯à ¢  ¤«ï ¡ãä¥à 
32 buf2d_color equ dword[edi+16] ;梥â ä®­  ¡ãä¥à 
33 buf2d_bits equ byte[edi+20] ;ª®«¨ç¥á⢮ ¡¨â ¢ 1-© â®çª¥ ¨§®¡à ¦¥­¨ï
35 struct FileInfoBlock
36 Function dd ?
37 Position dd ?
38 Flags dd ?
39 Count dd ?
40 Buffer dd ?
41 db ?
42 FileName dd ?
43 ends
45 displ_w dd ? ;è¨à¨­  ¯®«ï
46 displ_h dd ? ;¢ëá®â  ¯®«ï
47 displ_bytes dd ? ;à §¬¥à 1-£® ä ©«  á ¨§®¡à ¦¥­¨¥¬
48 offs_shadow_x dd ? ;ᤢ¨£ ⥭¥© ¯® ®á¨ 'x'
49 offs_shadow_y dd ? ;ᤢ¨£ ⥭¥© ¯® ®á¨ 'y'
51 IMAGE_FONT_SIZE equ 128*144*3
53 BUT1_T equ 10 ;®âáâ㯠ᢥàåã
54 BUT1_L equ 15 ;®âáâ㯠᫥¢ 
55 BUT1_W equ 50 ;è¨à¨­ 
56 BUT1_H equ 20 ;¢ëá®â 
57 BUT1_NEXT_TOP equ (BUT1_T+BUT1_H)*65536
59 game_select_mode db 1 ;०¨¬ ¢ë¡®à  ¨£àë
61 FILE_NAME_MAX equ 20 ;¬ ªá¨¬ «ì­ ï ¤«¨­­  ¨¬¥­¨ ä ©«  (¡¥§ ¯ ¯®ª, ®â­®á¨â¥«ì­® ⥪ã饩)
62 ;§­ ç¥­¨ï ¨¬¥­ ¯® 㬮«ç ­¨î
63 ini_def_decorat_file db 'curici.png',0
64 ini_def_unit_file db 'wolf.png',0
65 ini_def_objects_file db 'eggs.png',0
66 ini_def_lost_file db 'chi.png',0
67 ;¨¬¥­  ä ©«®¢
68 fn_icon0 rb FILE_NAME_MAX ;¨¬ï ä ©«  á ¤¥ª®à æ¨ï¬¨
69 fn_icon1 rb FILE_NAME_MAX ;¨¬ï ä ©«  á ¢®«ª®¬ ¨ § ©æ¥¬
70 fn_icon2 rb FILE_NAME_MAX ;¨¬ï ä ©«  á ï©æ ¬¨
71 fn_icon3 rb FILE_NAME_MAX ;¨¬ï ä ©«  á 樯«ïâ ¬¨
73 TREE_ICON_SYS16_BMP_SIZE equ 256*3*11+54 ;à §¬¥à bmp ä ©«  á á¨á⥬­ë¬¨ ¨ª®­ª ¬¨
75 ini_m_name db 'main.ini',0
76 key_count db 'count',0
77 key_game db 'g'
78 key_game_ind db 0,0,0
80 ini_name rb FILE_NAME_MAX ;¨¬ï ini ä ©«  c ¢ë¡à ­­®© ¨£à®©
81 ini_sec_files db 'Files',0
82 key_file_decorat db 'file_decorat',0
83 key_file_unit db 'file_unit',0
84 key_file_objects db 'file_objects',0
85 key_file_lost db 'file_lost',0
86 key_displ_w db 'displ_w',0
87 key_displ_h db 'displ_h',0
88 key_shadow_x db 'offs_shadow_x',0
89 key_shadow_y db 'offs_shadow_y',0
91 ini_sec_game db 'Game',0
92 key_delay_a db 'delay_a',0
93 key_delay_b db 'delay_b',0
94 key_delay_min db 'delay_min',0
96 ini_sec_color db 'Colors',0
97 ;ª«îç¨ ¤«ï áç¨â뢠­¨ï 梥⮢ ¨§ *.ini ä ©« 
98 key_color_fon db 'background',0
99 key_color_shadows db 'shadows',0
100 key_color_egg db 'objects',0
101 key_color_chick db 'lost',0
102 key_color_decorat: db 'dec'
103 .ind: db '?',0
104 key_color_unit db 'unit',0
106 ;æ¢¥â  ¢ ¨£à¥
107 color_fon dd ? ;梥â ä®­ 
108 color_shadows dd ? ;梥â ⥭¥©
109 color_wolf dd ? ;梥⠢®«ª  ¨ § ©æ 
110 color_egg dd ? ;梥â ï©æ 
111 color_chick dd ? ;梥â 樯«¥­ª 
112 color_decorat dd ?,?,? ;æ¢¥â  ¤¥ª®à æ¨© (ªãà¨æë, ¯¥à¨« , ...)
114 ;æ¢¥â  ¨­â¥à䥩á 
115 color_but_sm dd 0x808080 ;梥⠬ «¥­ìª¨å ª­®¯®ª
116 color_but_te dd 0xffffff ;梥â ⥪áâ  ­  ª­®¯ª å
118 macro load_image_file path,buf,size { ;¬ ªà®á ¤«ï § £à㧪¨ ¨§®¡à ¦¥­¨©
119 ;path - ¬®¦¥â ¡ëâì ¯¥à¥¬¥­­®© ¨«¨ áâப®¢ë¬ ¯ à ¬¥â஬
120 if path eqtype '' ;¯à®¢¥à塞 § ¤ ­ «¨ áâப®© ¯ à ¬¥âà path
121 jmp @f
122 local .path_str
123 .path_str db path ;ä®à¬¨à㥬 «®ª «ì­ãî ¯¥à¥¬¥­­ãî
124 db 0
126 ;32 - áâ ­¤ àâ­ë©  ¤à¥á ¯® ª®â®à®¬ã ¤®«¦¥­ ¡ëâì ¡ãä¥à á á¨á⥬­ë¬ ¯ã⥬
127 copy_path .path_str,[32],file_name,0
128 else
129 copy_path path,[32],file_name,0 ;ä®à¬¨à㥬 ¯®«­ë© ¯ãâì ª ä ©«ã ¨§®¡à ¦¥­¨ï, ¯®¤à §ã¬¥¢ ¥¬ çâ® ®­ ¢ ®¤­®© ¯ ¯ª¥ á ¯à®£à ¬¬®©
130 end if
132 stdcall mem.Alloc, dword size ;¢ë¤¥«ï¥¬ ¯ ¬ïâì ¤«ï ¨§®¡à ¦¥­¨ï
133 mov [buf],eax
135 mov eax,SF_FILE
136 mov [run_file_70.Function], SSF_READ_FILE
137 mov [run_file_70.Position], 0
138 mov [run_file_70.Flags], 0
139 mov [run_file_70.Count], dword size
140 m2m [run_file_70.Buffer], [buf]
141 mov byte[run_file_70+20], 0
142 mov [run_file_70.FileName], file_name
143 mov ebx,run_file_70
144 int 0x40 ;§ £à㦠¥¬ ä ©« ¨§®¡à ¦¥­¨ï
145 cmp ebx,0xffffffff
146 je @f
147 ;®¯à¥¤¥«ï¥¬ ¢¨¤ ¨§®¡à ¦¥­¨ï ¨ ¯¥à¥¢®¤¨¬ ¥£® ¢® ¢à¥¬¥­­ë© ¡ãä¥à image_data
148 stdcall [img_decode], [buf],ebx,0
149 mov [image_data],eax
150 ;¯à¥®¡à §ã¥¬ ¨§®¡à ¦¥­¨¥ ª ä®à¬ âã rgb
151 stdcall [img_to_rgb2], [image_data],[buf]
152 ;㤠«ï¥¬ ¢à¥¬¥­­ë© ¡ãä¥à image_data
153 stdcall [img_destroy], [image_data]
157 ;¤ ­­ë¥ ¨£àë
158 bit_zaac equ 2 ;¡¨â § ©æ 
159 val_zaac equ 4 ;æ¨äà  ®â¢¥ç îé ï §  ¡¨â § ©æ 
160 bit_mig equ 3 ;¡¨â ¬¨£ ­¨ï
161 val_mig equ 8 ;æ¨äà  ®â¢¥ç îé ï §  ¡¨â ¬¨£ ­¨ï
162 mask_lot_lu equ 1b ;¬ áª  ¤«ï «¥¢®£® ¢¥àå­¥£® «®âª 
163 mask_lot_ld equ 100000b ;¬ áª  ¤«ï «¥¢®£® ­¨¦­¥£® «®âª 
164 mask_lot_ru equ 10000000000b ;¬ áª  ¤«ï ¯à ¢®£® ¢¥àå­¥£® «®âª 
165 mask_lot_rd equ 1000000000000000b ;¬ áª  ¤«ï ¯à ¢®£® ­¨¦­¥£® «®âª 
166 mask_clear_all equ 11111011111011110111101111011110b ;¬ áª  ¤«ï ®ç¨á⪨ ¯ ¤ îé¨å ï¨æ ¨ ¯à¨¡¥¦ ¢è¨å 樯«ïâ
167 mask_move_eggs equ 11111111111111111111b ;¬ áª  ¤¢¨¦ãé¨åáï ï¨æ
168 mask_fail_eggs equ 100001000010000100000b ;¬ áª  ¯ ¤ îé¨å ï¨æ
169 mask_chi_left equ 11111000000000000000000000b ;¬ áª  «¥¢ëå 樯«ïâ
170 mask_chi_right equ 11111000000000000000000000000000b ;¬ áª  ¯à ¢ëå 樯«ïâ
171 mask_chi_cr_l equ 1000000000000000000000b ;¬ áª  ¤«ï ᮧ¤ ­¨ï «¥¢®£®
172 mask_chi_cr_r equ 1000000000000000000000000000b ;¬ áª  ¤«ï ᮧ¤ ­¨ï ¯à ¢®£®
173 bit_chi_left equ 21 ;1-© ¡¨â ª®â®àë© ®â¢¥ç ¥â §  ¡¥£ã饣® á«¥¢ 
174 bit_chi_right equ 27 ;1-© ¡¨â ª®â®àë© ®â¢¥ç ¥â §  ¡¥£ã饣® ¯à ¢ 
175 val_zaac_time_y equ 5 ;ª®««¨ç¥á⢮ ⠪⮢, ª®â®à®¥ ®¡ï§ â¥«ì­® ¤®«¦¥­ ¯à®¢¨á¥âì § ïæ
176 val_zaac_time_n equ 7 ;ª®««¨ç¥á⢮ ⠪⮢, ª®â®à®¥ ®¡ï§ â¥«ì­® ¤®«¦¥­ ¡ëâì á¯àïâ ­­ë¬ § ïæ
178 txt_game_a db 'ˆ£à  €',0
179 txt_game_b db 'ˆ£à  �',0
181 zaac_status db 0 ;ç¨á«® ⠪⮢, ª®â®à®¥ § ïæ ­¥ ¤®«¦¥­ ¬¥­ïâì ᢮¥ ¯®«®¦¥­¨¥
182 pos_wolf db 0 ;¯®§¨æ¨ï ¢®«ª  0-© ¡¨â á«¥¢ /á¯à ¢ , 1-© ¡¨â ᢥàåã/¢­¨§
183 ;rb 1
184 pos_eggs dd 0 ;¯®§¨æ¨¨ à á¯®«®¦¥­¨ï ï¨æ ¨ 樯«ïâ
185 eggs_count dw 0 ;ª®««¨ç¥á⢮ ¯®©¬ ­ëå ï¨æ
186 game_text db 'ˆ£à  _',13
187 some_text db '0'
188 rb 8 ;⥪áâ á ç¨á«®¬ ¯®©¬ ­­ëå ï¨æ
189 count_last db 0 ;áç¥â稪 ¯à®¯ã饭­ëå ï¨æ
190 game_spd dd 0 ;§ ¤¥à¦ª  ¨£àë
191 game_delay_a dd ? ;¯¥à¢®­ ç «ì­ ï § ¤¥à¦ª  ¤«ï ¨£àë €
192 game_delay_b dd ? ;¯¥à¢®­ ç «ì­ ï § ¤¥à¦ª  ¤«ï ¨£àë �
193 game_delay_min dd ? ;¬¨­¨¬ «ì­ ï § ¤¥à¦ª 
195 ;¤«ï £¥­¥à æ¨¨ á«ãç ©­ëå ç¨á¥«
196 rand_x dd 0
198 align 4
199 rand_next:
200 ;x(k+1) = (a*x(k)+c) mod m
201 ; a=22695477, c=1, m=2^32
202 push eax
203 mov eax,[rand_x]
204 imul eax,22695477
205 inc eax
206 mov [rand_x],eax
207 pop eax
210 ;ᮧ¤ ¥¬ ¯à®§à ç­ë¥ ¡ãä¥à  ¯® 8 ¡¨â (âà ä à¥âë), ¤«ï à¨á®¢ ­¨ï
211 ;£¤¥ buf - ¡ãä¥à ­  ®á­®¢¥ ª®â®à®£® ¡ã¤¥â ᮧ¤ ­ âà ä à¥â
212 ;ä®­®¢ë© 梥⠡ãä¥à  ¤®«¦¥­ ¡ëâì 0xffffff, ¨­ ç¥ ­¥ ¯à®¨§®©¤¥â ®¡à¥§ª 
213 ;¯® ä®­®¢®¬ã 梥âã ¨ âà ä à¥â ¡ã¤¥â § ­¨¬ â 쬭®£® ¬¥áâ  ¢ ¯ ¬ïâ¨
214 align 4
215 proc CreateTrapharetBuffer uses eax edi, buf:dword, img_data:dword
216 mov edi,[buf]
218 ;§ ¯®«­¥­¨¥ ¤ ­­ëå ¡ãä¥à 
219 mov buf2d_size_lt,0
220 mov eax,[displ_w]
221 mov buf2d_w,eax
222 mov eax,[displ_h]
223 mov buf2d_h,eax
224 mov buf2d_color,0xffffff
225 mov buf2d_bits,24
227 stdcall [buf2d_create_f_img], edi,[img_data] ;ᮧ¤ ¥¬ ¡ãä¥à
228 stdcall [buf2d_conv_24_to_8], edi,1 ;¤¥« ¥¬ ¡ãä¥à ¯à®§à ç­®á⨠8¡¨â
229 ;®¡à¥§ ¥¬ «¨è­¨¥ ªà ï ¡ãä¥à , ¤«ï ¡®«¥¥ ¡ëáâண® à¨á®¢ ­¨ï
230 stdcall [buf2d_crop_color], edi,buf2d_color,BUF2D_OPT_CROP_TOP+BUF2D_OPT_CROP_BOTTOM+BUF2D_OPT_CROP_RIGHT+BUF2D_OPT_CROP_LEFT
232 endp
234 align 4
235 InitBackgroundBuffer: ;ᮧ¤ ­¨¥ ä®­®¢®£® ¨§®¡à ¦¥­¨ï
236 pushad
237 mov edi,buf_fon
238 mov eax,[color_fon]
239 mov buf2d_color,eax
240 stdcall [buf2d_clear], edi,eax
241 mov esi,edi
243 xor eax,eax
245 cmp dword[offs_shadow_x],0
246 jne @f
247 cmp dword[offs_shadow_y],0
248 jne @f
249 jmp .end_shadows
251 mov edi,buf_decor
252 xor ebx,ebx
253 mov ecx,3
255 mov ax,buf2d_t
256 add eax,[offs_shadow_y]
257 mov bx,buf2d_l
258 add ebx,[offs_shadow_x]
259 stdcall [buf2d_bit_blt_alpha], esi, ebx,eax, edi,[color_shadows] ;à¨á㥬 ⥭¨ ¤¥ª®à æ¨©
260 add edi,BUF_STRUCT_SIZE
261 loop @b
262 .end_shadows:
264 mov edi,buf_decor
265 mov ebx,color_decorat
266 mov ecx,3
268 mov ax,buf2d_t
269 stdcall [buf2d_bit_blt_alpha], esi, 0,eax, edi,[ebx] ;à¨á㥬 ¤¥ª®à æ¨¨
270 add edi,BUF_STRUCT_SIZE
271 add ebx,4
272 loop @b
273 popad
276 ;à¨áã¥â ª à⨭ªã ¢ ¡ãä¥à¥ buf ¨§ ¬ áᨢ  ¡ãä¥à®¢ buf_img á ¨­¤¥ªá®¬ ind
277 ;â. ¥. buf <- buf_img[ind]
278 align 4
279 proc DrawArrayImg, buf:dword, buf_img:dword, ind:dword, color:dword
280 pushad
281 mov edi,dword[ind]
282 imul edi,BUF_STRUCT_SIZE
283 add edi,dword[buf_img]
285 mov esi,dword[buf]
286 xor eax,eax
287 mov ax,buf2d_t
288 xor ebx,ebx
289 mov bx,buf2d_l
290 stdcall [buf2d_bit_blt_alpha], esi, ebx,eax, edi,[color]
291 popad
293 endp
295 align 4
296 DrawZaac: ;à¨á®¢ ­¨¥ § ©æ 
297 push eax
298 bt word[pos_wolf],bit_zaac
299 jae .end_mig
301 stdcall DrawArrayImg, buf_displ,buf_wolf,6,[color_wolf] ;à¨á㥬 ⥫® § ©æ 
302 mov eax,dword[pos_eggs]
303 and eax,mask_chi_right+mask_chi_left
304 cmp eax,0
305 je .end_mig ;¥á«¨ ­¥â ¡¥£ îé¨å 樯«ïâ, â® § ïæ à㪮© ­¥ ¬ è¥â
306 bt word[pos_wolf],bit_mig
307 jc @f
308 stdcall DrawArrayImg, buf_displ,buf_wolf,7,[color_wolf] ;à¨á㥬 àãªã § ©æ  ¢¢¥àåã
309 jmp .end_mig
311 stdcall DrawArrayImg, buf_displ,buf_wolf,8,[color_wolf] ;à¨á㥬 àãªã § ©æ  ¢­¨§ã
312 .end_mig:
313 pop eax
316 align 4
317 DrawWolf: ;à¨áã¥â ¢®«ª  á ª®à§¨­ ¬¨
318 bt word[pos_wolf],0
319 jc @f
320 stdcall DrawArrayImg, buf_displ,buf_wolf,0,[color_wolf]
321 bt word[pos_wolf],1
322 jc .corz_ldn
323 stdcall DrawArrayImg, buf_displ,buf_wolf,1,[color_wolf]
324 jmp .corz_lend
325 .corz_ldn:
326 stdcall DrawArrayImg, buf_displ,buf_wolf,2,[color_wolf]
327 .corz_lend:
328 jmp .wolf_b
330 stdcall DrawArrayImg, buf_displ,buf_wolf,3,[color_wolf]
331 bt word[pos_wolf],1
332 jc .corz_rdn
333 stdcall DrawArrayImg, buf_displ,buf_wolf,4,[color_wolf]
334 jmp .corz_rend
335 .corz_rdn:
336 stdcall DrawArrayImg, buf_displ,buf_wolf,5,[color_wolf]
337 .corz_rend:
338 .wolf_b:
341 align 4
342 DrawEggs: ;à¨áã¥â ï©æ 
343 pushad
346 mov eax,dword[pos_eggs]
347 xor ebx,ebx
348 mov ecx,20 ;横« ¤«ï à¨á®¢ ­¨ï ª®âïé¨åáï ï¨æ
350 bt eax,ebx
351 jae .draw_egg
352 stdcall DrawArrayImg, buf_displ,buf_egg,ebx,[color_egg]
353 .draw_egg:
354 inc ebx
355 loop @b
357 ;mov eax,dword[pos_eggs]
358 and eax,mask_chi_left
359 cmp eax,0
360 je @f
361 stdcall DrawArrayImg, buf_displ,buf_egg,20,[color_egg] ;à §¡¨â®¥ ï©æ® á«¥¢ 
363 mov eax,dword[pos_eggs]
364 and eax,mask_chi_right
365 cmp eax,0
366 je @f
367 stdcall DrawArrayImg, buf_displ,buf_egg,21,[color_egg] ;à §¡¨â®¥ ï©æ® á¯à ¢ 
370 mov eax,dword[pos_eggs]
371 xor edx,edx
372 mov ebx,bit_chi_left
373 mov ecx,5 ;横« ¤«ï à¨á®¢ ­¨ï «¥¢ëå 樯«ïâ
375 bt eax,ebx
376 jae .draw_chick_l
377 stdcall DrawArrayImg, buf_displ,buf_chi,edx,[color_chick]
378 .draw_chick_l:
379 inc ebx
380 inc edx
381 loop @b
382 mov ebx,bit_chi_right
383 mov ecx,5 ;横« ¤«ï à¨á®¢ ­¨ï ¯à ¢ëå 樯«ïâ
385 bt eax,ebx
386 jae .draw_chick_r
387 stdcall DrawArrayImg, buf_displ,buf_chi,edx,[color_chick]
388 .draw_chick_r:
389 inc ebx
390 inc edx
391 loop @b
393 xor eax,eax
394 mov al,byte[count_last]
395 mov ecx,eax ;横« ¤«ï à¨á®¢ ­¨ï èâà ä­ëå ®çª®¢
396 shr ecx,1
397 mov edx,10 ;¨­¤¥ªá ­ ç «  èâà ä­ëå ¨ª®­®ª ¢ ¡ãä¥à¥ buf_chi
398 cmp ecx,0
399 je .no_unit_last
401 stdcall DrawArrayImg, buf_displ,buf_chi,edx,[color_chick]
402 inc edx
403 loop @b
404 .no_unit_last:
406 bt ax,0 ;¯à®¢¥à塞 ¬¨£ î饥 ­¥ ç¥â­®¥ ®çª®
407 jae @f
408 bt word[pos_wolf],bit_mig
409 jc @f
410 stdcall DrawArrayImg, buf_displ,buf_chi,edx,[color_chick] ;¬¨£ î饥 èâà ä­®¥ ®çª®
413 popad
416 align 4
417 CountEggsInc: ;㢥«¨ç¨¢ ¥¬ áç¥â稪 ï¨æ ­  1
418 push eax edi
419 xor eax,eax
420 inc word[eggs_count] ;㢥«¨ç¨¢ ¥¬ áç¥â稪 ï¨æ
421 cmp word[eggs_count],200 ;¡®­ãá­ë¥ ®çª¨
422 je @f
423 cmp word[eggs_count],500 ;¡®­ãá­ë¥ ®çª¨
424 je @f
425 jmp .no_bonus
427 mov byte[count_last],0
428 .no_bonus:
430 mov ax,word[eggs_count]
431 mov edi,some_text
432 call convert_to_str ;®¡­®¢«ï¥¬ ⥪á⮢ãî áâபã
433 and ax,0xf ;ç¥à¥§ ª ¦¤ë¥ 16 ï¨æ 㬥­ìè ¥¬ ¢à¥¬ï
434 cmp ax,0
435 jne @f
436 mov edi,[game_delay_min] ;¬¨­¨¬ «ì­ ï § ¤¥à¦ª 
437 cmp dword[game_spd],edi
438 jle @f
439 dec dword[game_spd]
441 pop edi eax
444 ;input:
445 ; eax - ¬ áª , 㪠§ë¢ îé ï á ª ª®© áâà®­ë 㯠«® ï©æ®
446 align 4
447 CountLastInc: ;­ ç¨á«¥­¨¥ èâà ä­ëå ®çª®¢
448 inc byte[count_last] ;¯®«®¢¨­ ® èâà ä­®£® ®çª 
449 bt word[pos_wolf],bit_zaac
450 jc @f
451 inc byte[count_last] ;¥á«¨ ­¥â § ©æ  â® ¥é¥ 1-­  ¯®«®¢¨­  èâà ä­®£® ®çª 
453 cmp byte[count_last],6
454 jle @f
455 mov byte[count_last],6 ;áâ ¢¨¬ ®£à ­¨ç¥­¨ ­  ç¨á«® èâà ä­ëå ®çª®¢
457 or dword[pos_eggs],eax ;ᮧ¤ ¥¬ ¡¥£ã饣® 樯«¥­ª 
460 align 4
461 MoveEggs:
462 pushad
463 xor byte[pos_wolf],val_mig ;¡¨â ¤«ï ¬¨£ ­¨ï
465 cmp byte[count_last],6 ;¬ ªá¨¬ «ì­®¥ ç¨á«® èâà ä­ëå ®çª®¢
466 je .end_fun
468 rol dword[pos_eggs],1
469 mov ecx,dword[pos_eggs]
470 and ecx,mask_fail_eggs
471 cmp ecx,0
472 je .no_fail ;­¥â ¯ ¤ îé¨å ï¨æ
473 ;­ ç¨á«¥­¨¥ ï¨æ ¯®¯ ¢è¨å ¢ ª®à§¨­ã
474 ;¨«¨ ­ ç¨á«¥­¨¥ èâà ä­ëå ®çª®¢
475 xor ebx,ebx
476 mov bl,byte[pos_wolf] ;¡¥à¥¬ ¯ à ¬¥âàë (¯®§¨æ¨î) ¢®«ª 
477 and bl,3 ;­  ¢á直© á«ãç ©
479 bt ecx,5 ;¯à®¢¥à塞 ¢¥àå­¥¥ «¥¢®¥ ¯¥à¨«®
480 jae .perilo_lu
481 cmp bx,0 ;¯à®¢¥à塞 ­ «¨ç¨¥ ª®à§¨­ë
482 jne @f
483 call CountEggsInc
484 jmp .perilo_lu
486 mov eax,mask_chi_cr_l
487 call CountLastInc
488 .perilo_lu:
489 bt ecx,10 ;¯à®¢¥à塞 ­¨¦­¥¥ «¥¢®¥ ¯¥à¨«®
490 jae .perilo_ld
491 cmp bx,2 ;¯à®¢¥à塞 ­ «¨ç¨¥ ª®à§¨­ë
492 jne @f
493 call CountEggsInc
494 jmp .perilo_ld
496 mov eax,mask_chi_cr_l
497 call CountLastInc
498 .perilo_ld:
499 bt ecx,15 ;¯à®¢¥à塞 ¢¥àå­¥¥ ¯à ¢®¥ ¯¥à¨«®
500 jae .perilo_ru
501 cmp bx,1 ;¯à®¢¥à塞 ­ «¨ç¨¥ ª®à§¨­ë
502 jne @f
503 call CountEggsInc
504 jmp .perilo_ru
506 mov eax,mask_chi_cr_r
507 call CountLastInc
508 .perilo_ru:
509 bt ecx,20 ;¯à®¢¥à塞 ­¨¦­¥¥ ¯à ¢®¥ ¯¥à¨«®
510 jae .perilo_rd
511 cmp bx,3 ;¯à®¢¥à塞 ­ «¨ç¨¥ ª®à§¨­ë
512 jne @f
513 call CountEggsInc
514 jmp .perilo_rd
516 mov eax,mask_chi_cr_r
517 call CountLastInc
518 .perilo_rd:
519 .no_fail:
521 and dword[pos_eggs],mask_clear_all ;®ç¨á⪠ 㯠¢è¨å ï¨æ ¨ ¤®¡¥¦ ¢è¨å ªã३
523 call rand_next
524 cmp byte[zaac_status],0
525 jle @f
526 dec byte[zaac_status]
527 jmp .no_zaac_move ;§ ïæ ¯®ª  ­¥ ¤¢¨£ ¥âáï
530 bt dword[rand_x],6 ;§ ïæ ®â ä®­ àï ¬¥­ï¥â áâ âãá
531 jc @f
532 xor byte[pos_wolf],val_zaac ;¢ëᮢ뢠¥¬/§ á®¢ë¢ ¥¬ § ©æ 
533 bt word[pos_wolf],val_zaac
534 jc .zaac_n
535 mov byte[zaac_status],val_zaac_time_y ;áâ ¢¨¬ ¬¨­¨¬ «ì­®¥ ¢à¥¬ï ¤«ï ᬥ­ë áâ âãá 
536 jmp @f
537 .zaac_n:
538 mov byte[zaac_status],val_zaac_time_n ;áâ ¢¨¬ ¬¨­¨¬ «ì­®¥ ¢à¥¬ï ¤«ï ᬥ­ë áâ âãá 
540 .no_zaac_move:
542 ;ᮧ¤ ­¨¥ ­®¢ëå ï¨æ
543 cmp word[eggs_count],5 ;¯¥à¢ë¥ 5 ï¨æ ª âïâáï ¯® 1-¬ã
544 jge @f
545 mov ecx,dword[pos_eggs]
546 and ecx,mask_move_eggs
547 ;cmp ecx,0
548 jnz .end_creat
551 bt dword[rand_x],4 ;¯à®¢¥à塞 ¡ã¤¥¬ «¨ ᮧ¤ ¢ âì ­®¢®¥ ï©æ®
552 jc .end_creat
553 bt dword[rand_x],5 ;¯à®¢¥à塞 á ª ª®© áâ®à®­ë ¡ã¤¥¬ ᮧ¤ ¢ âì ­®¢®¥ ï©æ®
554 jc .creat_r
555 bt dword[rand_x],7
556 jc @f
557 or dword[pos_eggs],mask_lot_lu
558 jmp .end_creat
560 or dword[pos_eggs],mask_lot_ld
561 jmp .end_creat
562 .creat_r:
563 bt dword[rand_x],7
564 jc @f
565 or dword[pos_eggs],mask_lot_ru
566 jmp .end_creat
568 or dword[pos_eggs],mask_lot_rd
569 ;jmp .end_creat
570 .end_creat:
572 .end_fun:
573 popad
576 align 4
577 proc InitGame, b:dword ;¯¥à¢®­ ç «ì­ë¥ ­ áâனª¨ ¨£àë
578 mov word[eggs_count],0 ;ª®««¨ç¥á⢮ ¯®©¬ ­ëå ï¨æ
579 mov byte[some_text],'0'
580 mov byte[some_text+1],0 ;⥪áâ á ç¨á«®¬ ¯®©¬ ­­ëå ï¨æ
581 mov byte[count_last],0 ;èâà ä­ë¥ ®çª¨
582 mov dword[pos_eggs],0
583 mov byte[zaac_status],0
585 push eax ebx
586 cmp dword[b],0
587 jne @f
588 mov byte[game_text+5],'€'
589 mov eax,dword[game_delay_a]
590 mov dword[game_spd],eax ;§ ¤¥à¦ª  ¨£àë
591 jmp .end_init
593 mov byte[game_text+5],'�'
594 mov eax,dword[game_delay_b]
595 mov dword[game_spd],eax ;§ ¤¥à¦ª  ¨£àë
596 .end_init:
598 mcall SF_SYSTEM_GET,SSF_TIME_COUNT
599 mov [rand_x],eax ;§ ¯®«­ï¥¬ 1-¥ á«ãç ©­®¥ ç¨á«®
600 pop ebx eax
603 endp
605 align 4
606 proc LoadArrayBuffer, f_name:dword, buf_start:dword, count:dword
607 pushad
608 mov edx,[displ_bytes]
609 mov ecx,edx
610 imul ecx,[count]
611 mov eax,[f_name]
612 load_image_file eax,image_data_gray,ecx
613 mov edx,[displ_bytes]
614 mov eax,[image_data_gray]
615 mov edi,[buf_start]
616 mov ecx,[count]
618 @@: ;áç¨â뢠¥¬ 3 ¡ãä¥à  á ¤¥ª®à æ¨ï¬¨
619 stdcall CreateTrapharetBuffer,edi,eax
620 add eax,edx
621 add edi,BUF_STRUCT_SIZE
622 loop @b
623 stdcall mem.Free,[image_data_gray] ;®á¢®¡®¦¤ ¥¬ ¯ ¬ïâì
624 popad
626 endp
628 txt_tile_type_0 rb FILE_NAME_MAX
630 align 4
631 user_is_select:
632 push eax ecx esi edi
633 stdcall [tl_node_get_data], tree1
634 or eax,eax ;¥á«¨ ¨¬ï ¨£àë ¯ãá⮥
635 jz @f
636 mov esi,eax
637 mov edi,ini_name
638 mov ecx,FILE_NAME_MAX
640 rep movsb
642 mov byte[game_select_mode],0
643 call InitAll
645 pop edi esi ecx eax
647 call draw_window
650 ;******************************************************************************
651 ; äã­ªæ¨ï, ª®â®à ï 1 à § ¤¥« ¥â ¢á¥ ­ áâனª¨ ­ã¦­ë¥ ¤«ï ¨£àë
652 ;******************************************************************************
653 align 4
654 InitAll:
655 pushad
656 ;à ¡®â  á ä ©«®¬ ­ áâ஥ª
657 copy_path ini_name,sys_path,file_name,0
658 stdcall [ini_get_int],file_name,ini_sec_files,key_displ_w,210
659 mov [displ_w],eax
660 stdcall [ini_get_int],file_name,ini_sec_files,key_displ_h,140
661 mov [displ_h],eax
662 stdcall [ini_get_str],file_name,ini_sec_files,key_file_decorat,fn_icon0,FILE_NAME_MAX,ini_def_decorat_file
663 stdcall [ini_get_str],file_name,ini_sec_files,key_file_unit,fn_icon1,FILE_NAME_MAX,ini_def_unit_file
664 stdcall [ini_get_str],file_name,ini_sec_files,key_file_objects,fn_icon2,FILE_NAME_MAX,ini_def_objects_file
665 stdcall [ini_get_str],file_name,ini_sec_files,key_file_lost,fn_icon3,FILE_NAME_MAX,ini_def_lost_file
667 stdcall [ini_get_int],file_name,ini_sec_files,key_shadow_x,2
668 mov [offs_shadow_x],eax
669 stdcall [ini_get_int],file_name,ini_sec_files,key_shadow_y,2
670 mov [offs_shadow_y],eax
672 ;áç¨â뢠­¨¥ ­ áâ஥ª ¢«¨ïîé¨å ­  ᪮àáâì ¨£àë
673 stdcall [ini_get_int],file_name,ini_sec_game,key_delay_a,65
674 mov [game_delay_a],eax
675 stdcall [ini_get_int],file_name,ini_sec_game,key_delay_b,35
676 mov [game_delay_b],eax
677 stdcall [ini_get_int],file_name,ini_sec_game,key_delay_min,15
678 mov [game_delay_min],eax
680 stdcall [ini_get_color],file_name,ini_sec_color,key_color_fon,0xffffff
681 mov [color_fon],eax
682 stdcall [ini_get_color],file_name,ini_sec_color,key_color_shadows,0xd0d0d0
683 mov [color_shadows],eax
684 stdcall [ini_get_color],file_name,ini_sec_color,key_color_unit,0
685 mov [color_wolf],eax
686 stdcall [ini_get_color],file_name,ini_sec_color,key_color_egg,0x404080
687 mov [color_egg],eax
688 stdcall [ini_get_color],file_name,ini_sec_color,key_color_chick,0x00d0d0
689 mov [color_chick],eax
691 mov ebx,color_decorat
692 mov byte[key_color_decorat.ind],'0'
693 mov ecx,3
696 push ecx ;äã­ªæ¨ï ini_get_color ¨¬¥¥â ¯à ¢® ¬ ­ïâì ॣ¨áâà ecx
697 stdcall [ini_get_color],file_name,ini_sec_color,key_color_decorat,0x000080
698 pop ecx
699 mov [ebx],eax
700 add ebx,4
701 inc byte[key_color_decorat.ind]
702 loop @b
704 mov edx,[displ_w]
705 imul edx,[displ_h]
706 lea edx,[edx+edx*2]
707 mov [displ_bytes],edx ;¢ëç¨á«ï¥¬ à §¬¥à ¨£à®¢®£® ¯®«ï
709 stdcall LoadArrayBuffer, fn_icon0, buf_decor,3 ;áç¨â뢠¥¬ 3 ¡ãä¥à  á ¤¥ª®à æ¨ï¬¨
710 stdcall LoadArrayBuffer, fn_icon1, buf_wolf,9 ;áç¨â뢠¥¬ 9 ¡ãä¥à®¢ á ¢®«ª®¬ ¨ § ©æ¥¬
711 stdcall LoadArrayBuffer, fn_icon2, buf_egg,22 ;áç¨â뢠¥¬ 22 ¡ãä¥à®¢ á ï©æ ¬¨
712 stdcall LoadArrayBuffer, fn_icon3, buf_chi,13 ;áç¨â뢠¥¬ 13 ¡ãä¥à®¢ á 樯«ïâ ¬¨
714 load_image_file 'font8x9.bmp', image_data_gray,IMAGE_FONT_SIZE
715 stdcall [buf2d_create_f_img], buf_font,[image_data_gray] ;ᮧ¤ ¥¬ ¡ãä¥à
716 stdcall mem.Free,[image_data_gray] ;®á¢®¡®¦¤ ¥¬ ¯ ¬ïâì
718 stdcall [buf2d_conv_24_to_8], buf_font,1 ;¤¥« ¥¬ ¡ãä¥à ¯à®§à ç­®á⨠8 ¡¨â
719 stdcall [buf2d_convert_text_matrix], buf_font
721 ;¯à®¢¥àª  § ­¨¬ ¥¬®£® ¡ãä¥à®¬ ¬¥áâ 
722 ;mov edi,buf_wolf
723 ;add edi,BUF_STRUCT_SIZE ;¯¥à¥å®¤¨¬ ­  ¡ãä¥à ª®à§¨­ë
724 ;stdcall [buf2d_clear],edi,0x808080 ;§ «¨¢ ¥¬ ¥£® á¥àë¬ æ¢¥â®¬
726 mov ebx,dword[displ_w]
727 mov edx,dword[displ_h]
729 mov edi,buf_displ
730 mov buf2d_w,ebx
731 mov buf2d_h,edx
732 stdcall [buf2d_create], buf_displ ;ᮧ¤ ¥¬ ¡ãä¥à ¤«ï ¢ë¢®¤  ­  íªà ­
734 mov edi,buf_fon
735 mov buf2d_w,ebx
736 mov buf2d_h,edx
737 stdcall [buf2d_create], buf_fon ;ᮧ¤ ¥¬ ¡ãä¥à á ä®­®¢ë¬¨ ¤¥ª®à æ¨ï¬¨
739 call InitBackgroundBuffer ;§ ¯®«­ï¥¬ ¡ãä¥à á ä®­®¢ë¬¨ ¤¥ª®à æ¨ï¬¨
740 stdcall InitGame,0
741 popad
744 align 4
745 start:
746 load_libraries l_libs_start,load_lib_end
748 ;¯à®¢¥àª  ­  ᪮«ìª® 㤠筮 § £ã§¨«¨áì ¡¨¡«¨®â¥ª¨
749 cmp dword [lib0+ll_struc_size-4],0
750 jnz @f
751 cmp dword [lib1+ll_struc_size-4],0
752 jnz @f
753 cmp dword [lib2+ll_struc_size-4],0
754 jnz @f
755 cmp dword [lib3+ll_struc_size-4],0
756 jnz @f
757 jmp .lib
759 mcall SF_TERMINATE_PROCESS
760 .lib:
762 mcall SF_SET_EVENTS_MASK,0x27
763 mcall SF_STYLE_SETTINGS,SSF_GET_COLORS,sc,sizeof.system_colors
765 ;******************************************************************************
766 ; ¯®¤£®â®¢ª  ᯨ᪠ ¨£à
767 ;******************************************************************************
768 stdcall dword[tl_data_init], tree1
770 load_image_file 'tl_sys_16.png', image_data_gray,TREE_ICON_SYS16_BMP_SIZE
771 stdcall [buf2d_create_f_img], buf_tree_sys,[image_data_gray] ;ᮧ¤ ¥¬ ¡ãä¥à
772 stdcall mem.Free,[image_data_gray] ;®á¢®¡®¦¤ ¥¬ ¯ ¬ïâì
774 mov edi,buf_tree_sys
775 m2m dword[tree1.data_img_sys],buf2d_data
777 ;à ¡®â  á £« ¢­ë¬ ä ©«®¬ ­ áâ஥ª
778 copy_path ini_m_name,sys_path,file_name,0
780 stdcall [ini_get_int],file_name,ini_sec_files,key_count,1
781 mov ecx,eax
782 mov dl,'0'
785 mov byte[key_game_ind],dl
786 inc dl
787 push ecx edx
788 stdcall [ini_get_str],file_name,ini_sec_files,key_game,txt_tile_type_0,FILE_NAME_MAX,ini_def_decorat_file
789 stdcall [tl_node_add], tree1, 0, txt_tile_type_0 ;¤®¡ ¢«ï¥¬ ­ §¢ ­¨¥ ¨£àë
790 stdcall [tl_cur_next], tree1 ;¯¥à¥­®á¨¬ ªãàá®à ¢­¨§, çâ®-¡ë ­¥ ¯®¬¥­ï«áï ¯®à冷ª ¨£à
791 pop edx ecx
792 loop @b
793 stdcall [tl_cur_beg], tree1 ;¯¥à¥­®á¨¬ ªãàá®à ¢¢¥àå
795 mcall SF_SYSTEM_GET,SSF_TIME_COUNT
796 mov [last_time],eax
800 align 4
801 red_win:
802 call draw_window
804 align 4
805 still: ;£« ¢­ë© 横«
807 cmp byte[game_select_mode],0
808 jne .select_mode
810 mcall SF_SYSTEM_GET,SSF_TIME_COUNT
811 mov ebx,[last_time]
812 add ebx,[game_spd] ;delay
813 sub ebx,eax
814 cmp ebx,[game_spd] ;delay
815 ja it_is_time_now
816 test ebx,ebx
817 jz it_is_time_now
818 mcall SF_WAIT_EVENT_TIMEOUT
819 or eax,eax
820 jz it_is_time_now
822 jmp @f
823 .select_mode:
824 mcall SF_WAIT_EVENT
827 cmp al,1 ;¨§¬¥­¨«®áì ¯®«®¦¥­¨¥ ®ª­ 
828 jz red_win
829 cmp al,2
830 jz key
831 cmp al,3
832 jz button
833 cmp al,6
834 jz mouse
836 jmp still
838 align 4
839 mouse:
840 cmp byte[game_select_mode],0
841 je @f
842 stdcall [tl_mouse], tree1 ;¥á«¨ ¨£à  ¥é¥ ­¥ ¢ë¡à ­ 
844 jmp still
846 align 4
847 it_is_time_now:
848 mcall SF_SYSTEM_GET,SSF_TIME_COUNT
849 mov [last_time],eax
851 ;cmp byte[game_select_mode],0
852 ;jne still
854 ;...§¤¥áì ¨¤ãâ ¤¥©á⢨ï, ¢ë§ë¢ ¥¬ë¥ ª ¦¤ë¥ delay á®âëå ¤®«¥© ᥪ㭤...
855 call MoveEggs
856 call draw_display
857 jmp still
859 align 4
860 key:
861 push eax ebx
862 mcall SF_GET_KEY
864 cmp byte[game_select_mode],0
865 je @f
866 stdcall [tl_key], tree1
869 cmp ah,176 ;Left
870 jne @f
871 and byte[pos_wolf],0xfe
873 cmp ah,179 ;Right
874 jne @f
875 or byte[pos_wolf],1
877 cmp ah,178 ;Up
878 jne @f
879 and byte[pos_wolf],0xff-2
881 cmp ah,177 ;Down
882 jne @f
883 or byte[pos_wolf],2
886 cmp ah,97 ;a
887 jne @f
888 and byte[pos_wolf],0xff-3 ;00
890 cmp ah,122 ;z
891 jne @f
892 and byte[pos_wolf],0xff-1
893 or byte[pos_wolf],2 ;10
895 cmp ah,39 ;'
896 jne @f
897 and byte[pos_wolf],0xff-2
898 or byte[pos_wolf],1 ;01
900 cmp ah,47 ;/
901 jne @f
902 or byte[pos_wolf],3 ;11
905 pop ebx eax
906 jmp still
909 align 4
910 draw_window:
911 pushad
912 mcall SF_REDRAW,SSF_BEGIN_DRAW
914 xor eax,eax
915 mov ebx,20*65536+480
916 mov ecx,20*65536+270
917 mov edx,[sc.work]
918 ;or edx,0x33000000
919 or edx,0x73000000
920 mov edi,hed
921 mcall ;ᮧ¤ ­¨¥ ®ª­ 
922 mcall SF_THREAD_INFO,procinfo,-1
924 cmp byte[game_select_mode],0
925 jne .select_mode
927 mov edi,buf_displ
928 mov eax,[procinfo.client_box.width]
929 cmp eax,[displ_w]
930 jle @f
931 sub eax,[displ_w]
932 shr eax,1
933 mov buf2d_l,ax ;¢ë¯à ¢­¨¢ ¥¬ ¡ãä¥à ¯® 業âàã ®ª­ 
936 call draw_display
938 mov eax,SF_DRAW_RECT
939 mov edx,[sc.work]
940 xor esi,esi
941 mov si,buf2d_l
942 add esi,[displ_w]
943 mov ebx,[procinfo.client_box.width]
944 inc ebx
945 cmp esi,ebx
946 jge @f
947 sub ebx,esi
948 rol ebx,16
949 mov bx,si
950 rol ebx,16
951 mov ecx,[procinfo.client_box.height]
952 inc ecx
953 int 0x40 ;à¨á®¢ ­¨¥ ¯à ¢®£® ¡®ª®¢®£® ¯®«ï
954 jmp .draw_s
956 mov esi,[procinfo.client_box.width] ;ª®£¤  ¯® è¨à¨­¥ ­¥ ¢« §¨â
957 inc esi
958 .draw_s:
960 ; *** à¨á®¢ ­¨¥ ª­®¯®ª ***
961 push esi
962 movzx ebx,buf2d_l
963 add ebx,buf2d_w
964 add ebx,BUT1_L
965 shl ebx,16
966 mov bx,BUT1_W
967 mov ecx,BUT1_T*65536+BUT1_H
968 mov esi,[color_but_sm]
969 mcall SF_DEFINE_BUTTON,,,5
971 inc edx
972 add ecx,BUT1_NEXT_TOP
973 int 0x40
974 pop esi
976 mov bx,BUT1_H-4
977 add ebx,8 shl 16
978 mov ecx,[color_but_te]
979 or ecx,0x80000000
980 mov edx,txt_game_a
981 mcall SF_DRAW_TEXT
983 ror ebx,16
984 add ebx,BUT1_NEXT_TOP
985 ror ebx,16
986 mov edx,txt_game_b
987 int 0x40
989 ; *** ¢®ááâ ­®¢«¥­¨¥ ¯ à ¬¥â஢ ***
990 mov eax,SF_DRAW_RECT
991 mov edx,[sc.work]
993 mov ebx,esi
994 mov ecx,[procinfo.client_box.height]
995 inc ecx
996 mov esi,[displ_h]
997 cmp esi,ebx
998 jge @f
999 sub ecx,esi
1000 rol ecx,16
1001 mov cx,si
1002 rol ecx,16
1003 int 0x40 ;à¨á®¢ ­¨¥ ­¨¦­¥£® ¯®«ï
1006 xor ebx,ebx
1007 mov bx,buf2d_l
1008 mov ecx,[displ_h]
1009 int 0x40 ;à¨á®¢ ­¨¥ «¥¢®£® ¡®ª®¢®£® ¯®«ï
1011 jmp @f
1012 .select_mode:
1013 stdcall [tl_draw], tree1
1014 mov edi,tree1
1015 add edi,tl_offs_box
1016 stdcall draw_rect_border, procinfo.client_box, edi
1019 mcall SF_REDRAW,SSF_END_DRAW
1020 popad
1023 ; äã­ªæ¨ï à¨áã¥â ¯®«ï ¢®ªà㣠¯àאַ㣮«ì­¨ª  user_box
1024 ; à §¬¥à ¯®«¥© ¢ëç¨á«ï¥âáï ¨áå®¤ï ¨§ à §¬¥à®¢ client_rect
1025 ; ¯à¥¤¯®« £ ¥âáï, çâ® ¢ ¡®«ì設á⢥ á«ãç ¥¢ client_rect > user_box
1026 align 4
1027 proc draw_rect_border, client_rect:dword, user_box:dword
1028 pushad
1029 mov esi,[user_box]
1030 cmp esi,0
1031 je @f
1032 mov edi,[client_rect]
1033 mov ebx,dword[edi+8] ;+8 = width
1034 inc bx
1035 mov ecx,dword[esi+4] ;+4 = top
1036 mov edx,[sc.work]
1037 mcall SF_DRAW_RECT ;top
1039 mov eax,dword[esi+4] ;+4 = top
1040 add eax,dword[esi+12] ;+12 = height
1041 cmp eax,dword[edi+12]
1042 jge .no_bottom
1043 mov ecx,eax
1044 shl ecx,16
1045 mov cx,word[edi+12] ;+12 = bottom
1046 inc cx
1047 sub cx,ax
1048 mcall SF_DRAW_RECT ;bottom
1049 .no_bottom:
1051 mov ebx,dword[esi] ;+0 left
1052 mov ecx,dword[esi+4] ;+4 = top
1053 shl ecx,16
1054 mov cx,word[esi+12] ;+12 = height
1055 inc cx
1056 mcall SF_DRAW_RECT ;left
1058 mov eax,dword[esi] ;+0 left
1059 add eax,dword[esi+8] ;+8 = width
1060 mov ebx,eax
1061 shl ebx,16
1062 mov bx,word[edi+8] ;+8 = right
1063 sub bx,ax
1064 inc bx
1065 mcall SF_DRAW_RECT ;right
1067 popad
1069 endp
1071 align 4
1072 draw_display:
1074 stdcall mem_copy, [buf_fon],[buf_displ],[displ_bytes] ;ª®¯¨à®¢ ­¨¥ ¨§®¡à ¦¥­¨ï ¨§ ä®­®¢®£® ¡ãä¥à 
1075 call DrawZaac ;à¨á㥬 § ©æ 
1076 call DrawWolf ;à¨á㥬 ¢®«ª 
1077 call DrawEggs ;à¨á㥬 ï©æ 
1079 push eax
1080 mov eax,[displ_w]
1081 shr eax,1
1082 stdcall [buf2d_draw_text], buf_displ, buf_font,game_text,eax,[offs_shadow_x],[color_wolf] ;à¨á㥬 áâபã á ⥪á⮬
1083 pop eax
1084 stdcall [buf2d_draw], buf_displ
1087 align 4
1088 button:
1089 mcall SF_GET_BUTTON
1091 cmp ah,5
1092 jne @f
1093 stdcall InitGame,0
1095 cmp ah,6
1096 jne @f
1097 stdcall InitGame,1
1099 cmp ah,1
1100 jne still
1101 .exit:
1102 stdcall [buf2d_delete],buf_fon ;㤠«ï¥¬ ¡ãä¥à
1103 stdcall [buf2d_delete],buf_displ ;㤠«ï¥¬ ¡ãä¥à
1105 stdcall [buf2d_delete],buf_tree_sys
1106 stdcall [buf2d_delete],buf_font
1109 mov ecx,3
1110 mov edi,buf_decor
1111 @@: ;㤠«ï¥¬ 3 ¡ãä¥à 
1112 stdcall [buf2d_delete],edi
1113 add edi,BUF_STRUCT_SIZE
1114 loop @b
1115 mov ecx,9
1116 mov edi,buf_wolf
1117 @@: ;㤠«ï¥¬ 9 ¡ãä¥à®¢ á ¢®«ª®¬ ¨ § ©æ¥¬
1118 stdcall [buf2d_delete],edi
1119 add edi,BUF_STRUCT_SIZE
1120 loop @b
1121 mov ecx,13
1122 mov edi,buf_chi
1123 @@: ;㤠«ï¥¬ 13 ¡ãä¥à®¢
1124 stdcall [buf2d_delete],edi
1125 add edi,BUF_STRUCT_SIZE
1126 loop @b
1127 mov ecx,22
1128 mov edi,buf_egg
1129 @@: ;㤠«ï¥¬ 22 ¡ãä¥à 
1130 stdcall [buf2d_delete],edi
1131 add edi,BUF_STRUCT_SIZE
1132 loop @b
1134 mov dword[tree1.data_img_sys],0 ;ç¨á⨬ 㪠§ â¥«ì ­  ¨§®¡à ¦¥­¨¥
1135 stdcall dword[tl_data_clear], tree1
1136 mcall SF_TERMINATE_PROCESS
1138 system_dir0 db '/sys/lib/'
1139 lib0_name db 'buf2d.obj',0
1140 system_dir1 db '/sys/lib/'
1141 lib1_name db 'libimg.obj',0
1142 system_dir2 db '/sys/lib/'
1143 lib2_name db 'libini.obj',0
1144 system_dir3 db '/sys/lib/'
1145 lib3_name db 'box_lib.obj',0
1147 ;library structures
1148 l_libs_start:
1149 lib0 l_libs lib0_name, file_name, system_dir0, import_buf2d_lib
1150 lib1 l_libs lib1_name, file_name, system_dir1, import_libimg
1151 lib2 l_libs lib2_name, file_name, system_dir2, import_libini
1152 lib3 l_libs lib3_name, file_name, system_dir3, import_box_lib
1153 load_lib_end:
1155 align 4
1156 proc mem_copy uses ecx esi edi, source:dword, destination:dword, len:dword
1158 mov esi, [source]
1159 mov edi, [destination]
1160 mov ecx, [len]
1161 rep movsb
1163 endp
1165 ;input:
1166 ; eax - ç¨á«®
1167 ; edi - ¡ãä¥à ¤«ï áâப¨
1168 align 4
1169 convert_to_str:
1170 pushad
1171 lea esi,[edi+8] ;8 - ¤«¨­­  ¡ãä¥à  -1
1172 call .str
1173 popad
1176 align 4
1177 .str:
1178 mov ecx,10
1179 cmp eax,ecx
1180 jb @f
1181 xor edx,edx
1182 div ecx
1183 push edx
1184 ;dec edi ;ᬥ饭¨¥ ­¥®¡å®¤¨¬®¥ ¤«ï § ¯¨á¨ á ª®­æ  áâப¨
1185 call .str
1186 pop eax
1188 cmp edi,esi
1189 jge @f
1190 or al,0x30
1191 stosb
1192 mov byte[edi],0 ;¢ ª®­¥æ áâப¨ áâ ¢¨¬ 0, çâ®-¡ë ­¥ ¢ë« §¨« ¬ãá®à
1197 last_time dd 0
1198 image_data dd 0 ;¯ ¬ïâì ¤«ï ¯à¥®¡à §®¢ ­¨ï ª à⨭ª¨ äã­ªæ¨ï¬¨ libimg
1199 image_data_gray dd 0 ;¯ ¬ïâì á ¢à¥¬¥­­ë¬¨ á¥à묨 ¨§®¡à ¦¥­¨ï¬¨ ¢ ä®à¬ â¥ 24-bit, ¨§ ª®â®àëå ¡ã¤ãâ ᮧ¤ ¢ âìáï âà ä à¥âë
1201 run_file_70 FileInfoBlock
1202 hed db 'Nu pogodi 10.12.20',0 ;¯®¤¯¨áì ®ª­ 
1203 sc system_colors ;á¨á⥬­ë¥ 梥â 
1205 count_of_dir_list_files equ 10
1206 el_focus dd tree1
1207 tree1 tree_list FILE_NAME_MAX,count_of_dir_list_files+2, tl_key_no_edit+tl_draw_par_line+tl_list_box_mode,\
1208 16,16, 0x8080ff,0x0000ff,0xffffff, 10,10,140,100, 0,0,0, el_focus,\
1209 0,user_is_select
1211 align 4
1212 buf_tree_sys:
1213 dd 0 ;㪠§ â¥«ì ­  ¡ãä¥à ¨§®¡à ¦¥­¨ï
1214 dw 0 ;+4 left
1215 dw 0 ;+6 top
1216 dd 16 ;+8 w
1217 dd 16*11 ;+12 h
1218 dd 0 ;+16 color
1219 db 24 ;+20 bit in pixel
1221 align 4
1222 buf_font: ;¡ãä¥à á® èà¨ä⮬
1223 dd 0 ;㪠§ â¥«ì ­  ¡ãä¥à ¨§®¡à ¦¥­¨ï
1224 dw 25 ;+4 left
1225 dw 25 ;+6 top
1226 dd 128 ;+8 w
1227 dd 144 ;+12 h
1228 dd 0 ;+16 color
1229 db 24 ;+20 bit in pixel
1231 align 4
1232 buf_displ:
1233 dd 0 ;㪠§ â¥«ì ­  ¡ãä¥à ¨§®¡à ¦¥­¨ï
1234 dw 25,0
1235 dd ? ;+8 w
1236 dd ? ;+12 h
1237 dd 0 ;+16 color
1238 db 24 ;+20 bit in pixel
1240 align 4
1241 buf_fon: ;ä®­®¢ë© ¡ãä¥à
1242 dd 0 ;㪠§ â¥«ì ­  ¡ãä¥à ¨§®¡à ¦¥­¨ï
1243 dw 0 ;+4 left
1244 dw 0 ;+6 top
1245 dd ? ;+8 w
1246 dd ? ;+12 h
1247 dd 0xffffff ;+16 color
1248 db 24 ;+20 bit in pixel
1250 align 4
1251 buf_decor: ;¡ãä¥à  á ¤¥ª®à æ¨ï¬¨: ¤®¬¨ª ¬¨ ¨ ३ª ¬¨; á ªãà¨æ ¬¨; á à á⥭¨ï¬¨
1252 rb 3*BUF_STRUCT_SIZE
1254 align 4
1255 buf_wolf:
1256 rb 9*BUF_STRUCT_SIZE
1258 align 4
1259 buf_egg:
1260 rb 22*BUF_STRUCT_SIZE
1262 align 4
1263 buf_chi:
1264 rb 13*BUF_STRUCT_SIZE
1268 align 4
1269 import_libini:
1270 dd alib_init0
1271 ini_get_str dd aini_get_str
1272 ini_get_int dd aini_get_int
1273 ini_get_color dd aini_get_color
1274 dd 0,0
1275 alib_init0 db 'lib_init',0
1276 aini_get_str db 'ini_get_str',0
1277 aini_get_int db 'ini_get_int',0
1278 aini_get_color db 'ini_get_color',0
1280 align 4
1281 import_libimg:
1282 dd alib_init1
1283 img_is_img dd aimg_is_img
1284 img_info dd aimg_info
1285 img_from_file dd aimg_from_file
1286 img_to_file dd aimg_to_file
1287 img_from_rgb dd aimg_from_rgb
1288 img_to_rgb dd aimg_to_rgb
1289 img_to_rgb2 dd aimg_to_rgb2
1290 img_decode dd aimg_decode
1291 img_encode dd aimg_encode
1292 img_create dd aimg_create
1293 img_destroy dd aimg_destroy
1294 img_destroy_layer dd aimg_destroy_layer
1295 img_count dd aimg_count
1296 img_lock_bits dd aimg_lock_bits
1297 img_unlock_bits dd aimg_unlock_bits
1298 img_flip dd aimg_flip
1299 img_flip_layer dd aimg_flip_layer
1300 img_rotate dd aimg_rotate
1301 img_rotate_layer dd aimg_rotate_layer
1302 img_draw dd aimg_draw
1304 dd 0,0
1305 alib_init1 db 'lib_init',0
1306 aimg_is_img db 'img_is_img',0 ;®¯à¥¤¥«ï¥â ¯® ¤ ­­ë¬, ¬®¦¥â «¨ ¡¨¡«¨®â¥ª  ᤥ« âì ¨§ ­¨å ¨§®¡à ¦¥­¨¥
1307 aimg_info db 'img_info',0
1308 aimg_from_file db 'img_from_file',0
1309 aimg_to_file db 'img_to_file',0
1310 aimg_from_rgb db 'img_from_rgb',0
1311 aimg_to_rgb db 'img_to_rgb',0 ;¯à¥®¡à §®¢ ­¨¥ ¨§®¡à ¦¥­¨ï ¢ ¤ ­­ë¥ RGB
1312 aimg_to_rgb2 db 'img_to_rgb2',0
1313 aimg_decode db 'img_decode',0 ; ¢â®¬ â¨ç¥áª¨ ®¯à¥¤¥«ï¥â ä®à¬ â £à ä¨ç¥áª¨å ¤ ­­ëå
1314 aimg_encode db 'img_encode',0
1315 aimg_create db 'img_create',0
1316 aimg_destroy db 'img_destroy',0
1317 aimg_destroy_layer db 'img_destroy_layer',0
1318 aimg_count db 'img_count',0
1319 aimg_lock_bits db 'img_lock_bits',0
1320 aimg_unlock_bits db 'img_unlock_bits',0
1321 aimg_flip db 'img_flip',0
1322 aimg_flip_layer db 'img_flip_layer',0
1323 aimg_rotate db 'img_rotate',0
1324 aimg_rotate_layer db 'img_rotate_layer',0
1325 aimg_draw db 'img_draw',0
1327 align 4
1328 import_buf2d_lib:
1329 dd sz_lib_init
1330 buf2d_create dd sz_buf2d_create
1331 buf2d_create_f_img dd sz_buf2d_create_f_img
1332 buf2d_clear dd sz_buf2d_clear
1333 buf2d_draw dd sz_buf2d_draw
1334 buf2d_delete dd sz_buf2d_delete
1335 buf2d_line dd sz_buf2d_line
1336 buf2d_circle dd sz_buf2d_circle
1337 buf2d_img_hdiv2 dd sz_buf2d_img_hdiv2
1338 buf2d_img_wdiv2 dd sz_buf2d_img_wdiv2
1339 buf2d_conv_24_to_8 dd sz_buf2d_conv_24_to_8
1340 buf2d_conv_24_to_32 dd sz_buf2d_conv_24_to_32
1341 buf2d_bit_blt dd sz_buf2d_bit_blt
1342 buf2d_bit_blt_transp dd sz_buf2d_bit_blt_transp
1343 buf2d_bit_blt_alpha dd sz_buf2d_bit_blt_alpha
1344 buf2d_curve_bezier dd sz_buf2d_curve_bezier
1345 buf2d_convert_text_matrix dd sz_buf2d_convert_text_matrix
1346 buf2d_draw_text dd sz_buf2d_draw_text
1347 buf2d_crop_color dd sz_buf2d_crop_color
1348 buf2d_offset_h dd sz_buf2d_offset_h
1349 dd 0,0
1350 sz_lib_init db 'lib_init',0
1351 sz_buf2d_create db 'buf2d_create',0
1352 sz_buf2d_create_f_img db 'buf2d_create_f_img',0
1353 sz_buf2d_clear db 'buf2d_clear',0
1354 sz_buf2d_draw db 'buf2d_draw',0
1355 sz_buf2d_delete db 'buf2d_delete',0
1356 sz_buf2d_line db 'buf2d_line',0
1357 sz_buf2d_circle db 'buf2d_circle',0 ;à¨á®¢ ­¨¥ ®ªà㦭®áâ¨
1358 sz_buf2d_img_hdiv2 db 'buf2d_img_hdiv2',0
1359 sz_buf2d_img_wdiv2 db 'buf2d_img_wdiv2',0
1360 sz_buf2d_conv_24_to_8 db 'buf2d_conv_24_to_8',0
1361 sz_buf2d_conv_24_to_32 db 'buf2d_conv_24_to_32',0
1362 sz_buf2d_bit_blt db 'buf2d_bit_blt',0
1363 sz_buf2d_bit_blt_transp db 'buf2d_bit_blt_transp',0
1364 sz_buf2d_bit_blt_alpha db 'buf2d_bit_blt_alpha',0
1365 sz_buf2d_curve_bezier db 'buf2d_curve_bezier',0
1366 sz_buf2d_convert_text_matrix db 'buf2d_convert_text_matrix',0
1367 sz_buf2d_draw_text db 'buf2d_draw_text',0
1368 sz_buf2d_crop_color db 'buf2d_crop_color',0
1369 sz_buf2d_offset_h db 'buf2d_offset_h',0
1371 align 4
1372 import_box_lib:
1373 dd alib_init2
1375 ;scrollbar_ver_draw dd aScrollbar_ver_draw
1377 tl_data_init dd sz_tl_data_init
1378 tl_data_clear dd sz_tl_data_clear
1379 tl_info_clear dd sz_tl_info_clear
1380 tl_key dd sz_tl_key
1381 tl_mouse dd sz_tl_mouse
1382 tl_draw dd sz_tl_draw
1383 tl_info_undo dd sz_tl_info_undo
1384 tl_info_redo dd sz_tl_info_redo
1385 tl_node_add dd sz_tl_node_add
1386 tl_node_set_data dd sz_tl_node_set_data
1387 tl_node_get_data dd sz_tl_node_get_data
1388 tl_node_delete dd sz_tl_node_delete
1389 tl_cur_beg dd sz_tl_cur_beg
1390 tl_cur_next dd sz_tl_cur_next
1391 tl_cur_perv dd sz_tl_cur_perv
1392 tl_node_close_open dd sz_tl_node_close_open
1393 tl_node_lev_inc dd sz_tl_node_lev_inc
1394 tl_node_lev_dec dd sz_tl_node_lev_dec
1396 dd 0,0
1397 alib_init2 db 'lib_init',0
1399 ;aScrollbar_ver_draw db 'scrollbar_v_draw',0
1401 sz_tl_data_init db 'tl_data_init',0
1402 sz_tl_data_clear db 'tl_data_clear',0
1403 sz_tl_info_clear db 'tl_info_clear',0
1404 sz_tl_key db 'tl_key',0
1405 sz_tl_mouse db 'tl_mouse',0
1406 sz_tl_draw db 'tl_draw',0
1407 sz_tl_info_undo db 'tl_info_undo',0
1408 sz_tl_info_redo db 'tl_info_redo',0
1409 sz_tl_node_add db 'tl_node_add',0
1410 sz_tl_node_set_data db 'tl_node_set_data',0
1411 sz_tl_node_get_data db 'tl_node_get_data',0
1412 sz_tl_node_delete db 'tl_node_delete',0
1413 sz_tl_cur_beg db 'tl_cur_beg',0
1414 sz_tl_cur_next db 'tl_cur_next',0
1415 sz_tl_cur_perv db 'tl_cur_perv',0
1416 sz_tl_node_close_open db 'tl_node_close_open',0
1417 sz_tl_node_lev_inc db 'tl_node_lev_inc',0
1418 sz_tl_node_lev_dec db 'tl_node_lev_dec',0
1421 align 16
1422 i_end:
1423 procinfo process_information
1424 rb 1024
1425 stacktop:
1426 sys_path rb 4096
1427 file_name:
1428 rb 4096
1429 openfile_path:
1430 rb 4096
1431 filename_area:
1432 rb 256
1433 mem: