Rev 6024 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
31 | halyavin | 1 | ; |
2 | ; Pong Gaem 3Ver Mini Sample by Pavlushin Evgeni for ASCL |
||
3 | ; www.waptap@mail.ru |
||
4 | ; |
||
5 | ; Not use bmpfile! |
||
6 | |||
7 | ;****************************************************************************** |
||
6024 | hidnplayr | 8 | format binary as "" |
9 | |||
31 | halyavin | 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 |
||
7468 | leency | 18 | dd 0x0, 0x0 ; I_Param , I_Path |
31 | halyavin | 19 | |
20 | ;****************************************************************************** |
||
21 | |||
485 | heavyiron | 22 | include '..\..\..\macros.inc' |
31 | halyavin | 23 | include 'ascl.inc' |
24 | include 'ascgl.inc' |
||
25 | include 'ascgml.inc' |
||
26 | |||
7468 | leency | 27 | AREA_W = 640 |
28 | AREA_H = 480 |
||
31 | halyavin | 29 | |
7468 | leency | 30 | |
31 | halyavin | 31 | START: ; start of execution |
6024 | hidnplayr | 32 | convbmp pongfile, tsoi |
33 | bmptoimg pongfile, tsoi,pong |
||
7468 | leency | 34 | getimg pong, 0, 0, 80, 4, img |
35 | getimg pong, 0, 4, 80, 4, img2 |
||
6024 | hidnplayr | 36 | getimg pong, 5, 38, 15, 15, img3 |
7468 | leency | 37 | getimg pong, 0, 10, 80, 20, img5 |
38 | fullimg imgbr, 80, 4, 0x00000000 ;black for rocket |
||
39 | fullimg imgbg, 80, 20, 0x00000000 ;black for grav |
||
40 | fullimg imgbb, 12, 12, 0x00000000 ;black for ball |
||
31 | halyavin | 41 | |
42 | still: |
||
6024 | hidnplayr | 43 | scevent red,key,button |
31 | halyavin | 44 | |
7468 | leency | 45 | ;mcall 48, 4 ;get skin height |
6024 | hidnplayr | 46 | ;sub [skin_h], 16 |
47 | ;div eax, 2 |
||
48 | ;mov [skin_h], eax |
||
31 | halyavin | 49 | |
7468 | leency | 50 | remember_old_coordinates: |
51 | m2m [ply1x_old], [ply1x] |
||
52 | m2m [ply1y_old], [ply1y] |
||
53 | m2m [ply2x_old], [ply2x] |
||
54 | m2m [ply2y_old], [ply2y] |
||
55 | m2m [gravx_old], [gravx] |
||
56 | m2m [gravy_old], [gravy] |
||
57 | m2m [ballx_old], [ballx] |
||
58 | m2m [bally_old], [bally] |
||
31 | halyavin | 59 | |
60 | move_ply1: |
||
6024 | hidnplayr | 61 | correct [ply1x], [ply1rx], 4 |
62 | correct [ply1y], [ply1ry], 2 |
||
31 | halyavin | 63 | |
6024 | hidnplayr | 64 | ; automove ball |
65 | mov eax, [ballxv] |
||
66 | add [ballx], eax |
||
67 | mov eax, [ballyv] |
||
68 | add [bally], eax |
||
31 | halyavin | 69 | |
70 | ;autoslow ball |
||
6024 | hidnplayr | 71 | cmp [ballxv], 0 |
72 | jl ballb |
||
31 | halyavin | 73 | balla: |
6024 | hidnplayr | 74 | cmp [ballxv], 2 |
75 | jng balln |
||
76 | dec [ballxv] |
||
77 | jmp balln |
||
31 | halyavin | 78 | ballb: |
6024 | hidnplayr | 79 | cmp [ballxv], -2 |
80 | jnl balln |
||
81 | inc [ballxv] |
||
82 | jmp balln |
||
31 | halyavin | 83 | balln: |
6024 | hidnplayr | 84 | cmp [ballyv], 2 |
85 | jng by_n |
||
86 | dec [ballyv] |
||
31 | halyavin | 87 | by_n: |
88 | |||
89 | ;ball collusion of screen |
||
7468 | leency | 90 | cmp [ballx], AREA_W-12 |
6024 | hidnplayr | 91 | jna xa_ok |
92 | neg [ballxv] |
||
31 | halyavin | 93 | xa_ok: |
6024 | hidnplayr | 94 | cmp [ballx], 6 |
95 | jnb xb_ok |
||
96 | neg [ballxv] |
||
31 | halyavin | 97 | xb_ok: |
98 | |||
99 | ;if ball far out of screen come back |
||
100 | ; is not work already |
||
7468 | leency | 101 | cmp [bally], AREA_H-30 ;check RED fails |
6024 | hidnplayr | 102 | jng yax_ok |
103 | inc [scoreb] |
||
7468 | leency | 104 | call draw_score |
6024 | hidnplayr | 105 | mov [bally], 240 |
106 | mov [ballx], 310 |
||
107 | mov [ballyv], 2 |
||
108 | random 5, [ballxv] |
||
109 | sub [ballxv], 2 |
||
31 | halyavin | 110 | yax_ok: |
7468 | leency | 111 | cmp [bally], 0 ;check BLUE fails |
6024 | hidnplayr | 112 | jnl yax_ok2 |
113 | inc [scorea] |
||
7468 | leency | 114 | call draw_score |
6024 | hidnplayr | 115 | mov [bally], 240 |
116 | mov [ballx], 310 |
||
117 | mov [ballyv], 2 |
||
118 | random 5, [ballxv] |
||
119 | sub [ballxv], 2 |
||
31 | halyavin | 120 | yax_ok2: |
121 | |||
122 | xorx: |
||
6024 | hidnplayr | 123 | cmp [ballxv], 0 |
124 | jne norx |
||
125 | random 5, [ballxv] |
||
126 | sub [ballxv], 2 |
||
127 | cmp [ballxv], 0 |
||
128 | je xorx |
||
31 | halyavin | 129 | norx: |
130 | |||
131 | ;test on collusion ply1 of ball |
||
132 | collusion_test: |
||
6024 | hidnplayr | 133 | collimg img, [ply1x], [ply1y], img3, [ballx], [bally], eax |
134 | cmp eax, 1 |
||
135 | jne not_coll |
||
136 | neg [ballyv] |
||
137 | add [bally], 4 |
||
138 | ; neg [ballxv] |
||
31 | halyavin | 139 | not_coll: |
140 | |||
141 | ;test on collusion com of ball |
||
142 | collusion_com: |
||
6024 | hidnplayr | 143 | collimg img, [ply2x], [ply2y], img3, [ballx], [bally], eax |
144 | cmp eax, 1 |
||
145 | jne not_collcom |
||
146 | neg [ballyv] |
||
147 | sub [bally], 4 |
||
148 | ; neg dword [ballxv] |
||
31 | halyavin | 149 | not_collcom: |
150 | |||
151 | ;test on collusion gravity of ball |
||
152 | collusion_grav: |
||
6024 | hidnplayr | 153 | collimg img, [gravx], [gravy], img3, [ballx], [bally], eax |
154 | cmp eax, 1 |
||
155 | jne not_collg |
||
156 | neg [ballyv] |
||
31 | halyavin | 157 | |
6024 | hidnplayr | 158 | ; mov [ballxv], -20 |
31 | halyavin | 159 | |
6024 | hidnplayr | 160 | cmp [ballyv], 0 |
161 | jl ab |
||
162 | jg bf |
||
163 | jmp not_collgx |
||
31 | halyavin | 164 | ab: |
6024 | hidnplayr | 165 | sub [ballyv], 25 |
166 | jmp not_collgx |
||
31 | halyavin | 167 | bf: |
6024 | hidnplayr | 168 | add [ballyv], 25 |
31 | halyavin | 169 | not_collgx: |
6024 | hidnplayr | 170 | cmp [ballxv], 0 |
171 | jl abx |
||
172 | jg bfx |
||
173 | jmp not_collg |
||
31 | halyavin | 174 | abx: |
6024 | hidnplayr | 175 | sub [ballxv], 8 ;15 |
176 | jmp not_collg |
||
31 | halyavin | 177 | bfx: |
6024 | hidnplayr | 178 | add [ballxv], 8 |
31 | halyavin | 179 | |
180 | |||
6024 | hidnplayr | 181 | ; mov [ballyv], 20 |
31 | halyavin | 182 | not_collg: |
183 | |||
184 | ;ply contorl |
||
6024 | hidnplayr | 185 | cmp [ply1rx], 560 |
186 | jna plyok |
||
187 | cmp [ply1rx], 12000 |
||
188 | jna paa |
||
189 | mov [ply1rx], 4 |
||
190 | jmp plyok |
||
31 | halyavin | 191 | paa: |
6024 | hidnplayr | 192 | mov [ply1rx], 560 |
31 | halyavin | 193 | plyok: |
194 | |||
195 | |||
196 | ;com contorl |
||
6024 | hidnplayr | 197 | cmp [ply2x], 560 |
198 | jna cplyok |
||
199 | cmp [ply2x], 12000 |
||
200 | jna cpaa |
||
201 | mov [ply2x], 4 |
||
202 | jmp cplyok |
||
31 | halyavin | 203 | cpaa: |
6024 | hidnplayr | 204 | mov [ply2x], 560 |
31 | halyavin | 205 | cplyok: |
206 | |||
207 | |||
208 | ;com move |
||
209 | cx_move: |
||
6024 | hidnplayr | 210 | cmp [bally], 160 |
211 | jna cno_m |
||
212 | mov eax, [ballx] |
||
213 | sub eax, 30 |
||
214 | cmp [ply2x], eax |
||
215 | je cno_m |
||
216 | cmp [ply2x], eax |
||
217 | ja cm_m |
||
31 | halyavin | 218 | cm_p: |
6024 | hidnplayr | 219 | add [ply2x], 3 |
220 | jmp cno_m |
||
31 | halyavin | 221 | cm_m: |
6024 | hidnplayr | 222 | sub [ply2x], 3 |
31 | halyavin | 223 | cno_m: |
224 | |||
225 | ;garvity |
||
226 | gravity: |
||
6024 | hidnplayr | 227 | cmp [gravtime], 0 |
228 | je no_dg |
||
229 | dec [gravtime] |
||
31 | halyavin | 230 | no_dg: |
231 | |||
232 | draw_gravity: |
||
6024 | hidnplayr | 233 | cmp [gravtime], 0 |
234 | je nograv |
||
235 | mov eax, [ply1x] |
||
236 | mov ebx, [ply1y] |
||
237 | add ebx, 10 |
||
238 | mov [gravx], eax |
||
239 | mov [gravy], ebx |
||
240 | jmp endgrav |
||
31 | halyavin | 241 | nograv: |
6024 | hidnplayr | 242 | mov [gravx], 1000 |
243 | mov [gravy], 1000 |
||
31 | halyavin | 244 | endgrav: |
245 | |||
7468 | leency | 246 | ;next code checks were coordinates of player1 and player2 |
247 | ;changed or not |
||
248 | ; if yes => fill old |
||
249 | ; if no => do not fill old |
||
31 | halyavin | 250 | redraw_images: |
7468 | leency | 251 | ;player1 |
252 | ;if (ply1x!=ply1x_old) || (ply1y!=ply1y_old) fill1 |
||
253 | mov eax, [ply1x] |
||
254 | cmp [ply1x_old], eax |
||
255 | jne fill1 |
||
256 | mov eax, [ply1y] |
||
257 | cmp [ply1y_old],eax |
||
258 | jne fill1 |
||
259 | jmp no_fill1 |
||
260 | fill1: |
||
261 | setimg [ply1x_old], [ply1y_old], imgbr |
||
262 | no_fill1: |
||
6024 | hidnplayr | 263 | setimg [ply1x], [ply1y], img |
7468 | leency | 264 | |
265 | ;player2 |
||
266 | ;if (ply2x!=ply2x_old) || (ply2y!=ply2y_old) fill2 |
||
267 | mov eax, [ply2x] |
||
268 | cmp [ply2x_old], eax |
||
269 | jne fill2 |
||
270 | mov eax, [ply2y] |
||
271 | cmp [ply2y_old],eax |
||
272 | jne fill2 |
||
273 | jmp no_fill2 |
||
274 | fill2: |
||
275 | setimg [ply2x_old], [ply2y_old], imgbr |
||
276 | no_fill2: |
||
6024 | hidnplayr | 277 | setimg [ply2x], [ply2y], img2 |
7468 | leency | 278 | |
279 | ;ball |
||
280 | setimg [ballx_old], [bally_old], imgbb |
||
6024 | hidnplayr | 281 | setimg [ballx], [bally], img3 |
7468 | leency | 282 | |
283 | ;grav |
||
284 | setimg [gravx_old], [gravy_old], imgbg |
||
6024 | hidnplayr | 285 | setimg [gravx], [gravy], img5 |
31 | halyavin | 286 | |
6024 | hidnplayr | 287 | delay 1 ;don't generate delay for fast speed programm |
31 | halyavin | 288 | |
6024 | hidnplayr | 289 | jmp still |
31 | halyavin | 290 | |
291 | red: |
||
6024 | hidnplayr | 292 | call draw_window |
293 | jmp still |
||
31 | halyavin | 294 | |
295 | key: ; key |
||
6024 | hidnplayr | 296 | mov eax, 2 |
297 | mcall |
||
298 | cmp ah, key_Left |
||
299 | jne no_l |
||
300 | sub [ply1rx], 32 ;16 |
||
31 | halyavin | 301 | no_l: |
6024 | hidnplayr | 302 | cmp ah, key_Right |
303 | jne no_r |
||
304 | add [ply1rx], 32 ;16 |
||
31 | halyavin | 305 | no_r: |
6024 | hidnplayr | 306 | cmp ah, key_Up |
307 | jne no_u |
||
308 | sub [ply1ry], 16 |
||
7468 | leency | 309 | cmp [ply1ry], 0 |
310 | jb no_u |
||
311 | mov [ply1ry], 0 |
||
31 | halyavin | 312 | no_u: |
6024 | hidnplayr | 313 | cmp ah, key_Down |
314 | jne no_d |
||
315 | add [ply1ry], 16 |
||
7468 | leency | 316 | cmp [ply1ry], AREA_H-50 |
317 | jl no_d |
||
318 | mov [ply1ry], AREA_H-50 |
||
31 | halyavin | 319 | no_d: |
6024 | hidnplayr | 320 | cmp ah, key_Space |
321 | jne no_sp |
||
322 | mov [gravtime], 100 |
||
31 | halyavin | 323 | no_sp: |
324 | |||
6024 | hidnplayr | 325 | jmp still |
31 | halyavin | 326 | |
7468 | leency | 327 | button: |
328 | mcall 17 ; get id |
||
329 | cmp ah, 1 ; button id=1 ? |
||
6024 | hidnplayr | 330 | jne noclose |
7468 | leency | 331 | mcall -1 ; close this program |
31 | halyavin | 332 | noclose: |
6024 | hidnplayr | 333 | jmp still |
31 | halyavin | 334 | |
335 | |||
336 | draw_window: |
||
6024 | hidnplayr | 337 | mcall 12,1 ;start window redraw |
7468 | leency | 338 | mcall 0, <10, AREA_W+5+9>, <10, 480+35>, 0x34000000,, wtitle |
6024 | hidnplayr | 339 | mcall 12,2 ;end window redraw |
31 | halyavin | 340 | |
7468 | leency | 341 | draw_score: |
342 | mcall 13, <10, 100>, |
||
343 | outcount [scoreb], 10, AREA_H-17, 0x01000000 + cl_Blue, 3 shl 16 |
||
344 | outcount [scorea], 50, AREA_H-17, 0x01000000 + cl_Red, 3 shl 16 |
||
345 | ret |
||
31 | halyavin | 346 | |
347 | ; DATA AREA |
||
7468 | leency | 348 | wtitle db 'PONG: use Arrow Keys and Space',0 |
2674 | leency | 349 | ;skin_h dd 25 |
350 | |||
7468 | leency | 351 | ply1x_old dd ? |
352 | ply1y_old dd ? |
||
353 | ply2x_old dd ? |
||
354 | ply2y_old dd ? |
||
355 | gravx_old dd ? |
||
356 | gravy_old dd ? |
||
357 | ballx_old dd ? |
||
358 | bally_old dd ? |
||
359 | |||
6024 | hidnplayr | 360 | xt dd 100 |
361 | yt dd 100 |
||
31 | halyavin | 362 | |
6024 | hidnplayr | 363 | gravtime dd 10 |
364 | gravx dd 1000 |
||
365 | gravy dd 1000 |
||
31 | halyavin | 366 | |
6024 | hidnplayr | 367 | ply1rx dd 200 |
7468 | leency | 368 | ply1ry dd 40 |
31 | halyavin | 369 | |
6024 | hidnplayr | 370 | ply1x dd 200 |
7468 | leency | 371 | ply1y dd 40 |
31 | halyavin | 372 | |
6024 | hidnplayr | 373 | ply2x dd 200 |
374 | ply2y dd 400 |
||
31 | halyavin | 375 | |
6024 | hidnplayr | 376 | ballx dd 200 |
377 | bally dd 200 |
||
31 | halyavin | 378 | |
6024 | hidnplayr | 379 | ballyv dd 3 |
380 | ballxv dd 3 |
||
31 | halyavin | 381 | |
6024 | hidnplayr | 382 | scorea dd 0 |
383 | scoreb dd 0 |
||
31 | halyavin | 384 | |
6024 | hidnplayr | 385 | counter dd 0 |
386 | tsoi dd 0 |
||
31 | halyavin | 387 | |
6024 | hidnplayr | 388 | pongfile file 'pong.bmp' |
31 | halyavin | 389 | |
390 | IM_END: |
||
391 | |||
6024 | hidnplayr | 392 | temp rb 20000 |
31 | halyavin | 393 | |
7468 | leency | 394 | ;real images |
6024 | hidnplayr | 395 | pong rb 80*60*3+8 |
396 | img rb 32*32*3+8 |
||
397 | img2 rb 32*32*3+8 |
||
398 | img3 rb 32*32*3+8 |
||
399 | img5 rb 32*32*3+8 |
||
31 | halyavin | 400 | |
7468 | leency | 401 | ;black to clean old images |
402 | imgbr rb 80*4 *3+8 |
||
403 | imgbg rb 80*20*3+8 |
||
404 | imgbb rb 12*12*3+8 |
||
31 | halyavin | 405 | |
406 | I_END:10,>10,>10,> |