Rev 109 | Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
31 | halyavin | 1 | ; |
2 | ; Arcanoid Gaem 4Ver Mini Sample by Pavlushin Evgeni for ASCL |
||
3 | ; www.waptap@mail.ru www.cyberdeck.fatal.ru www.deck4.narod.ru |
||
4 | ; Play again and exit button added |
||
5 | ; |
||
6 | ; 3Ver Play again, Exit button. |
||
7 | ; 4Ver Next level function. |
||
8 | ; |
||
9 | ;****************************************************************************** |
||
10 | use32 |
||
11 | org 0x0 |
||
12 | db 'MENUET01' ; 8 byte id |
||
13 | dd 0x01 ; header version |
||
14 | dd START ; start of code |
||
15 | dd IM_END ; size of image |
||
16 | dd 0x300000 ; memory for app |
||
17 | dd 0x300000 ; esp |
||
18 | dd 0x0 , 0x0 ; I_Param , I_Icon |
||
19 | |||
20 | ;****************************************************************************** |
||
21 | |||
22 | include 'lang.inc' |
||
23 | include 'ascl.inc' |
||
24 | include 'ascgl.inc' |
||
25 | include 'ascgml.inc' |
||
26 | |||
27 | |||
28 | START: ; start of execution |
||
29 | bmptoimg arc_file,pong |
||
30 | getimg pong,0,0,80,4,img |
||
31 | getimg pong,0,4,80,4,img2 |
||
32 | getimg pong,5,38,15,15,img3 |
||
33 | getimg pong,0,8,80,20,img5 |
||
34 | fullimg img4 , 80 ,20 ,0x00000000 ;black for rocket |
||
35 | fullimg img6 , 15 ,15 ,0x00000000 ;black for ball |
||
36 | fullimg img7a , 60,20,0x0000cf00 |
||
37 | fullimg img7b , 60,20,0x00af0000 |
||
38 | fullimg img7c , 60,20,0x000000cf |
||
39 | fullimg img8 , 60,20,0x00000000 |
||
40 | |||
41 | call draw_window |
||
42 | |||
43 | still: |
||
44 | |||
45 | scevent red,key,button |
||
46 | |||
47 | cmp [againbut],1 |
||
48 | je stl2 |
||
49 | |||
50 | outcount dword [scoreb],256,8,cl_Blue,5*65536 |
||
51 | outcount dword [scorea],332,8,cl_Red,5*65536 |
||
52 | outcount dword [level],368,8,cl_White,2*65536 |
||
53 | |||
54 | del_images: |
||
55 | setimg dword [ply1x],dword [ply1y],img4 |
||
56 | setimg dword [ballx],dword [bally],img6 |
||
57 | setimg dword [gravx],dword [gravy],img4 |
||
58 | |||
59 | del_blocks: |
||
60 | mov ecx,0 |
||
61 | xxx: |
||
62 | pushad |
||
63 | mov esi,dword [mass+ecx] |
||
64 | mov edi,dword [mass+ecx+4] |
||
65 | mov ebp,dword [mass+ecx+8] |
||
66 | cmp ebp,0 |
||
67 | jne notptx |
||
68 | setimg esi,edi,img8 |
||
69 | notptx: |
||
70 | popad |
||
71 | add ecx,12 |
||
72 | cmp ecx,[blocks_max] |
||
73 | jne xxx |
||
74 | |||
75 | |||
76 | |||
77 | move_ply1: |
||
78 | |||
79 | correct [ply1x],[ply1rx],2 |
||
80 | correct [ply1y],[ply1ry],2 |
||
81 | |||
82 | ;automove ball |
||
83 | mov eax,dword [ballxv] |
||
84 | add dword [ballx],eax |
||
85 | mov eax,dword [ballyv] |
||
86 | add dword [bally],eax |
||
87 | |||
88 | ;autoslow ball for rocket gravitation (Space key) |
||
89 | cmp dword [ballxv],0 |
||
90 | jl ballb |
||
91 | balla: |
||
92 | cmp dword [ballxv],2 |
||
93 | jng balln |
||
94 | dec dword [ballxv] |
||
95 | jmp balln |
||
96 | ballb: |
||
97 | cmp dword [ballxv],-2 |
||
98 | jnl balln |
||
99 | inc dword [ballxv] |
||
100 | jmp balln |
||
101 | balln: |
||
102 | cmp dword [ballyv],2 |
||
103 | jng by_n |
||
104 | dec dword [ballyv] |
||
105 | by_n: |
||
106 | |||
107 | ;ball collusion of screen |
||
108 | cmp dword [ballx],400-12 |
||
109 | jna xa_ok |
||
110 | neg dword [ballxv] |
||
111 | xa_ok: |
||
112 | cmp dword [ballx],6 |
||
113 | jnb xb_ok |
||
114 | neg dword [ballxv] |
||
115 | xb_ok: |
||
116 | |||
117 | cmp dword [bally],30 |
||
118 | jnb yb_ok |
||
119 | neg dword [ballyv] |
||
120 | yb_ok: |
||
121 | |||
122 | |||
123 | ;if ball far out of screen come back |
||
124 | cmp dword [bally],466 |
||
125 | jng yax_ok |
||
126 | call draw_window |
||
127 | dec dword [scoreb] |
||
128 | mov eax,[ply1ry] |
||
129 | sub eax,6 |
||
130 | mov dword [bally],eax ;240 |
||
131 | mov eax,[ply1rx] |
||
132 | add eax,30 |
||
133 | mov dword [ballx],eax ;200 |
||
134 | mov dword [ballyv],2 |
||
135 | random 3,dword [ballxv] |
||
136 | sub dword [ballxv],1 |
||
137 | yax_ok: |
||
138 | |||
139 | xorx: |
||
140 | cmp dword [ballxv],0 |
||
141 | jne norx |
||
142 | random 3,dword [ballxv] |
||
143 | sub dword [ballxv],1 |
||
144 | cmp dword [ballxv],0 |
||
145 | je xorx |
||
146 | norx: |
||
147 | |||
148 | ;test on collusion ply1 of ball |
||
149 | collusion_test: |
||
150 | collimg img,[ply1x],[ply1y],img3,[ballx],[bally],eax |
||
151 | cmp eax,1 |
||
152 | jne not_coll |
||
153 | neg dword [ballyv] |
||
154 | sub dword [bally],4 |
||
155 | ; neg dword [ballxv] |
||
156 | not_coll: |
||
157 | |||
158 | ;test on collusion gravity of ball |
||
159 | collusion_grav: |
||
160 | collimg img,[gravx],[gravy],img3,[ballx],[bally],eax |
||
161 | cmp eax,1 |
||
162 | jne not_collg |
||
163 | sub dword [bally],30 |
||
164 | neg dword [ballyv] |
||
165 | cmp dword [ballyv],0 |
||
166 | jl ab |
||
167 | jg bf |
||
168 | jmp not_collgx |
||
169 | ab: |
||
170 | sub dword [ballyv],10 |
||
171 | jmp not_collgx |
||
172 | bf: |
||
173 | add dword [ballyv],10 |
||
174 | not_collgx: |
||
175 | cmp dword [ballxv],0 |
||
176 | jl abx |
||
177 | jg bfx |
||
178 | jmp not_collg |
||
179 | abx: |
||
180 | sub dword [ballxv],0 ;8 ;15 |
||
181 | jmp not_collg |
||
182 | bfx: |
||
183 | add dword [ballxv],0 ;8 |
||
184 | |||
185 | |||
186 | ; mov dword [ballyv],20 |
||
187 | not_collg: |
||
188 | |||
189 | ;ply contorl |
||
190 | control 12,316,[ply1rx] |
||
191 | control 380,470,[ply1ry] |
||
192 | |||
193 | ;garvity |
||
194 | gravity: |
||
195 | cmp dword [gravtime],0 |
||
196 | je no_dg |
||
197 | dec dword [gravtime] |
||
198 | no_dg: |
||
199 | |||
200 | draw_gravity: |
||
201 | cmp dword [gravtime],0 |
||
202 | je nograv |
||
203 | mov eax,dword [ply1x] |
||
204 | mov ebx,dword [ply1y] |
||
205 | sub ebx,30 |
||
206 | mov dword [gravx],eax |
||
207 | mov dword [gravy],ebx |
||
208 | jmp endgrav |
||
209 | nograv: |
||
210 | mov dword [gravx],1000 |
||
211 | mov dword [gravy],1000 |
||
212 | endgrav: |
||
213 | |||
214 | redraw_images: |
||
215 | setimg dword [ply1x],dword [ply1y],img2 |
||
216 | setimg dword [ballx],dword [bally],img3 |
||
217 | setimg dword [gravx],dword [gravy],img5 |
||
218 | |||
219 | draw_blocks: |
||
220 | mov ecx,0 |
||
221 | xxx2: |
||
222 | pushad |
||
223 | mov esi,dword [mass+ecx] |
||
224 | mov edi,dword [mass+ecx+4] |
||
225 | mov ebp,dword [mass+ecx+8] |
||
226 | cmp ebp,0 |
||
227 | je notpt |
||
228 | cmp ebp,1 |
||
229 | jne no_a |
||
230 | setimg esi,edi,img7a |
||
231 | jmp notpt |
||
232 | no_a: |
||
233 | cmp ebp,2 |
||
234 | jne no_b |
||
235 | setimg esi,edi,img7b |
||
236 | jmp notpt |
||
237 | no_b: |
||
238 | cmp ebp,3 |
||
239 | jne no_c |
||
240 | setimg esi,edi,img7c |
||
241 | jmp notpt |
||
242 | no_c: |
||
243 | |||
244 | notpt: |
||
245 | popad |
||
246 | add ecx,12 |
||
247 | cmp ecx,[blocks_max] |
||
248 | jne xxx2 |
||
249 | |||
250 | ;collusion ball of blocks |
||
251 | coll_blocks: |
||
252 | mov [temp3],0 |
||
253 | mov ecx,0 |
||
254 | testloop: |
||
255 | pushad |
||
256 | mov ebp,dword [mass+ecx+8] |
||
257 | cmp ebp,0 |
||
258 | jne testcol |
||
259 | jmp notest |
||
260 | testcol: |
||
261 | mov [temp3],1 |
||
262 | mov esi,dword [mass+ecx] |
||
263 | mov edi,dword [mass+ecx+4] |
||
264 | mov [temp1],esi |
||
265 | mov [temp2],edi |
||
266 | push ecx |
||
267 | collimg img8,[temp1],[temp2],img3,[ballx],[bally],eax |
||
268 | pop ecx |
||
269 | cmp eax,1 |
||
270 | jne notest |
||
271 | mov dword [mass+ecx+8],0 |
||
272 | ; neg [ballxv] |
||
273 | neg [ballyv] |
||
274 | add [scorea],30 |
||
275 | call draw_window |
||
276 | jmp end_col |
||
277 | notest: |
||
278 | popad |
||
279 | add ecx,12 |
||
280 | cmp ecx,[blocks_max] |
||
281 | jne testloop |
||
282 | end_col: |
||
283 | |||
284 | cmp [delay_cnt],0 |
||
285 | jne no_delay |
||
286 | mov [delay_cnt],1 |
||
287 | delay 1 ;don't generate delay for fast speed programm |
||
288 | no_delay: |
||
289 | dec [delay_cnt] |
||
290 | |||
291 | win_test: |
||
292 | cmp [temp3],1 |
||
293 | je stl |
||
294 | ; inc [level] |
||
295 | mov [nextlev],1 |
||
296 | mov [againbut],1 |
||
297 | call draw_window |
||
298 | ; label 160,200,'You Win!',cl_Green+font_Big |
||
299 | ; label 130,220,'Youre Score:',cl_Green+font_Big |
||
300 | ; outcount dword [scorea],230,220,cl_Green,5*65536 |
||
301 | ; label 130,234,'Youre Lives:',cl_Green+font_Big |
||
302 | ; outcount dword [scoreb],230,234,cl_Green,5*65536 |
||
303 | ; delay 600 ;wait 2sec |
||
304 | ; close ;exit from program |
||
305 | stl: |
||
306 | |||
307 | lose_test: |
||
308 | cmp [scoreb],0 |
||
309 | jne stl2 |
||
310 | ; call draw_window |
||
311 | ; label 160,200,'You Lose!',cl_Red+font_Big |
||
312 | ; label 130,220,'Youre Score:',cl_Red+font_Big |
||
313 | ; outcount dword [scorea],230,220,cl_Red,5*65536 |
||
314 | ; delay 300 ;wait 2sec |
||
315 | ; close ;exit from program |
||
316 | ; mov ebx,10*65536+40 |
||
317 | ; mov ebx,10*65536+20 |
||
318 | ; mov edx,2 |
||
319 | ; mov esi,0x0000ff00 |
||
320 | ; mov eax,8 |
||
321 | ; int 0x40 |
||
322 | mov [level],0 |
||
323 | mov [nextlev],0 |
||
324 | mov [againbut],1 |
||
325 | call draw_window |
||
326 | |||
327 | stl2: |
||
328 | |||
329 | jmp still |
||
330 | |||
331 | red: |
||
332 | call draw_window |
||
333 | jmp still |
||
334 | |||
335 | key: ; key |
||
336 | mov eax,2 |
||
337 | int 0x40 |
||
338 | cmp ah,key_Left |
||
339 | jne no_l |
||
340 | sub dword [ply1rx],50 ;24 ;16 |
||
341 | no_l: |
||
342 | cmp ah,key_Right |
||
343 | jne no_r |
||
344 | add dword [ply1rx],50 ;24 ;16 |
||
345 | no_r: |
||
346 | cmp ah,key_Up |
||
347 | jne no_u |
||
348 | sub dword [ply1ry],20 |
||
349 | no_u: |
||
350 | cmp ah,key_Down |
||
351 | jne no_d |
||
352 | add dword [ply1ry],20 |
||
353 | no_d: |
||
354 | cmp ah,key_Space |
||
355 | jne no_sp |
||
356 | mov dword [gravtime],100 |
||
357 | no_sp: |
||
358 | jmp still |
||
359 | |||
360 | button: ; button |
||
361 | mov eax,17 ; get id |
||
362 | int 0x40 |
||
363 | cmp ah,1 ; button id=1 ? |
||
364 | jne noclose |
||
365 | mov eax,-1 ; close this program |
||
366 | int 0x40 |
||
367 | noclose: |
||
368 | cmp ah,2 |
||
369 | jne noplayagain |
||
370 | mov [xt],100 |
||
371 | mov [yt],100 |
||
372 | mov [gravtime],10 |
||
373 | mov [gravx],1000 |
||
374 | mov [gravy],1000 |
||
375 | mov [ply1rx],160 |
||
376 | mov [ply1ry],460 |
||
377 | mov [ply1x],160 |
||
378 | mov [ply1y],400 |
||
379 | mov [ballx],200 |
||
380 | mov [bally],300 |
||
381 | mov [ballyv],2 |
||
382 | mov [ballxv],1 |
||
383 | |||
384 | cmp [nextlev],1 |
||
385 | je noch |
||
386 | mov [scorex],0 |
||
387 | mov [scorea],0 |
||
388 | mov [scoreb],3 |
||
389 | jmp noch2 |
||
390 | noch: |
||
391 | inc [scoreb] |
||
392 | inc [level] |
||
393 | mov eax,[maxlev] |
||
394 | cmp [level],eax |
||
395 | jna noch2 |
||
396 | mov [level],eax |
||
397 | noch2: |
||
398 | |||
399 | mov eax,18*4*5 |
||
400 | mul [level] |
||
401 | mov ebp,eax |
||
402 | add ebp,levels |
||
403 | mov ecx,18*4*5 ;bytes |
||
404 | loo: |
||
405 | mov eax,dword [ebp+ecx] |
||
406 | mov dword [mass+ecx],eax |
||
407 | sub ecx,4 |
||
408 | jnz loo |
||
409 | |||
410 | mov [againbut],0 |
||
411 | |||
412 | call draw_window |
||
413 | noplayagain: |
||
414 | jmp still |
||
415 | |||
416 | |||
417 | draw_window: |
||
418 | startwd |
||
419 | window 0,0,400+8,480+24,window_Skinned |
||
420 | label 12,8,'ARCANOID: USE ARROW KEYS LIVES SCORE',cl_White+font_Big |
||
421 | |||
422 | cmp [againbut],0 |
||
423 | je no_againbut |
||
424 | |||
425 | cmp [nextlev],1 |
||
426 | je nlev |
||
427 | label 160,200,'You Lose!',cl_Red+font_Big |
||
428 | label 130,220,'Youre Score:',cl_Red+font_Big |
||
429 | outcount dword [scorea],230,220,cl_Red,5*65536 |
||
430 | mov ebx,150*65536+80 |
||
431 | mov ecx,240*65536+12 |
||
432 | mov edx,2 |
||
433 | mov esi,0x0000aa00 |
||
434 | mov eax,8 |
||
435 | int 0x40 |
||
436 | mov ecx,260*65536+12 |
||
437 | mov edx,1 |
||
438 | int 0x40 |
||
439 | label 152,244,'Play again?',cl_Red+font_Big |
||
440 | jmp elev |
||
441 | nlev: |
||
442 | label 160,200,'You Win!',cl_Green+font_Big |
||
443 | label 130,220,'Youre Score:',cl_Green+font_Big |
||
444 | outcount dword [scorea],230,220,cl_Green,5*65536 |
||
445 | mov ebx,150*65536+80 |
||
446 | mov ecx,240*65536+12 |
||
447 | mov edx,2 |
||
448 | mov esi,0x0000aa00 |
||
449 | mov eax,8 |
||
450 | int 0x40 |
||
451 | mov ecx,260*65536+12 |
||
452 | mov edx,1 |
||
453 | int 0x40 |
||
454 | label 152,244,'Next level?',cl_Red+font_Big |
||
455 | elev: |
||
456 | |||
457 | label 178,264,'Exit?',cl_Red+font_Big |
||
458 | no_againbut: |
||
459 | |||
460 | endwd |
||
461 | ret |
||
462 | |||
463 | |||
464 | ; DATA AREA |
||
465 | againbut dd 0 |
||
466 | |||
467 | xt dd 100 |
||
468 | yt dd 100 |
||
469 | |||
470 | gravtime dd 10 |
||
471 | gravx dd 1000 |
||
472 | gravy dd 1000 |
||
473 | |||
474 | ply1rx dd 160 |
||
475 | ply1ry dd 460 |
||
476 | |||
477 | ply1x dd 160 |
||
478 | ply1y dd 400 |
||
479 | |||
480 | ballx dd 200 |
||
481 | bally dd 300 |
||
482 | |||
483 | ballyv dd 2 |
||
484 | ballxv dd 1 |
||
485 | |||
486 | temp1 dd 0 |
||
487 | temp2 dd 0 |
||
488 | temp3 dd 0 |
||
489 | |||
490 | scorex dd 0 |
||
491 | scorea dd 0 |
||
492 | scoreb dd 3 |
||
493 | |||
494 | level dd 0 |
||
495 | nextlev dd 0 |
||
496 | maxlev dd 2 |
||
497 | |||
498 | counter dd 0 |
||
499 | tsoi dd 0 |
||
500 | |||
501 | delay_cnt dd 0 |
||
502 | |||
503 | blocks_max dd 6*5*12 ;size in bytes 5*3 dd |
||
504 | |||
505 | mass: |
||
506 | dd 30,200,0 ,90,200,0 ,150,200,0 ,210,200,0 ,270,200,0 ,330,200,0 |
||
507 | dd 30,180,0 ,90,180,0 ,150,180,0 ,210,180,0 ,270,180,0 ,330,180,0 |
||
508 | dd 30,160,0 ,90,160,0 ,150,160,0 ,210,160,0 ,270,160,0 ,330,160,0 |
||
509 | dd 30,140,0 ,90,140,1 ,150,140,1 ,210,140,1 ,270,140,0 ,330,140,0 |
||
510 | dd 30,120,0 ,90,120,0 ,150,120,0 ,210,120,0 ,270,120,0 ,330,120,0 |
||
511 | |||
512 | levels: |
||
513 | dd 30,200,0 ,90,200,0 ,150,200,0 ,210,200,2 ,270,200,0 ,330,200,0 |
||
514 | dd 30,180,2 ,90,180,1 ,150,180,1 ,210,180,2 ,270,180,2 ,330,180,0 |
||
515 | dd 30,160,1 ,90,160,3 ,150,160,1 ,210,160,2 ,270,160,2 ,330,160,2 |
||
516 | dd 30,140,2 ,90,140,1 ,150,140,1 ,210,140,2 ,270,140,2 ,330,140,0 |
||
517 | dd 30,120,0 ,90,120,0 ,150,120,0 ,210,120,2 ,270,120,0 ,330,120,0 |
||
518 | ;level2 |
||
519 | dd 30,200,0 ,90,200,3 ,150,200,0 ,210,200,2 ,270,200,2 ,330,200,2 |
||
520 | dd 30,180,0 ,90,180,1 ,150,180,0 ,210,180,2 ,270,180,2 ,330,180,2 |
||
521 | dd 30,160,0 ,90,160,3 ,150,160,0 ,210,160,2 ,270,160,2 ,330,160,2 |
||
522 | dd 30,140,0 ,90,140,1 ,150,140,0 ,210,140,2 ,270,140,2 ,330,140,2 |
||
523 | dd 30,120,0 ,90,120,3 ,150,120,0 ,210,120,2 ,270,120,2 ,330,120,2 |
||
524 | ;level3 |
||
525 | dd 30,200,1 ,90,200,3 ,150,200,1 ,210,200,2 ,270,200,2 ,330,200,2 |
||
526 | dd 30,180,2 ,90,180,1 ,150,180,1 ,210,180,2 ,270,180,2 ,330,180,2 |
||
527 | dd 30,160,1 ,90,160,3 ,150,160,1 ,210,160,2 ,270,160,2 ,330,160,2 |
||
528 | dd 30,140,2 ,90,140,1 ,150,140,1 ,210,140,2 ,270,140,2 ,330,140,2 |
||
529 | dd 30,120,1 ,90,120,3 ,150,120,1 ,210,120,2 ,270,120,2 ,330,120,2 |
||
530 | |||
531 | arc_file: |
||
532 | file 'arc.bmp' |
||
533 | |||
534 | rb 20000 |
||
535 | |||
536 | IM_END: |
||
537 | |||
538 | pong: |
||
539 | rb 80*60*3+8 |
||
540 | img: |
||
541 | rb 32*32*3+8 |
||
542 | img2: |
||
543 | rb 32*32*3+8 |
||
544 | img3: |
||
545 | rb 32*32*3+8 |
||
546 | img4: |
||
547 | rb 80*20*3+8 |
||
548 | img5: |
||
549 | rb 80*20*3+8 |
||
550 | img6: |
||
551 | rb 15*15*3+8 |
||
552 | img7a: |
||
553 | rb 60*20*3+8 |
||
554 | img7b: |
||
555 | rb 60*20*3+8 |
||
556 | img7c: |
||
557 | rb 60*20*3+8 |
||
558 | img8: |
||
559 | rb 60*40*3+8 |
||
560 | |||
561 | I_END: |