Rev 485 | Go to most recent revision | 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 | ;****************************************************************************** |
||
8 | use32 |
||
9 | org 0x0 |
||
10 | db 'MENUET01' ; 8 byte id |
||
11 | dd 0x01 ; header version |
||
12 | dd START ; start of code |
||
13 | dd IM_END ; size of image |
||
14 | dd 0x300000 ; memory for app |
||
15 | dd 0x300000 ; esp |
||
16 | dd temp_area , 0x0 ; I_Param , I_Icon |
||
17 | |||
18 | ;****************************************************************************** |
||
19 | |||
485 | heavyiron | 20 | include '..\..\..\macros.inc' |
31 | halyavin | 21 | include 'ascl.inc' |
22 | include 'ascgl.inc' |
||
23 | include 'ascgml.inc' |
||
24 | |||
25 | |||
26 | START: ; start of execution |
||
27 | call draw_window |
||
28 | |||
29 | ; loadbmp '/RD/1/PONG.BMP',temp_area,I_END,tsoi |
||
30 | convbmp pongfile,tsoi |
||
31 | bmptoimg pongfile,tsoi,pong |
||
32 | getimg pong,0,0,80,4,img |
||
33 | getimg pong,0,4,80,4,img2 |
||
34 | getimg pong,5,38,15,15,img3 |
||
35 | getimg pong,0,8,80,20,img5 |
||
36 | fullimg img4 , 80 ,20 ,0x00000000 ;black for rocket |
||
37 | fullimg img6 , 15 ,15 ,0x00000000 ;black for ball |
||
38 | |||
39 | |||
40 | |||
41 | still: |
||
42 | |||
43 | scevent red,key,button |
||
44 | |||
2674 | leency | 45 | ;mcall 48, 4 ;get skin width |
46 | ;sub [skin_h], 16 |
||
47 | ;div eax, 2 |
||
48 | ;mov [skin_h], eax |
||
49 | |||
31 | halyavin | 50 | outcount dword [scoreb],300,8,cl_Blue,5*65536 |
51 | outcount dword [scorea],350,8,cl_Red,5*65536 |
||
52 | |||
53 | del_images: |
||
54 | setimg dword [ply1x],dword [ply1y],img4 |
||
55 | setimg dword [ply2x],dword [ply2y],img4 |
||
56 | setimg dword [ballx],dword [bally],img6 |
||
57 | setimg dword [gravx],dword [gravy],img4 |
||
58 | |||
59 | move_ply1: |
||
60 | |||
61 | correct [ply1x],[ply1rx],4 |
||
62 | correct [ply1y],[ply1ry],2 |
||
63 | |||
64 | ;automove ball |
||
65 | mov eax,dword [ballxv] |
||
66 | add dword [ballx],eax |
||
67 | mov eax,dword [ballyv] |
||
68 | add dword [bally],eax |
||
69 | |||
70 | |||
71 | ;autoslow ball |
||
72 | cmp dword [ballxv],0 |
||
73 | jl ballb |
||
74 | balla: |
||
75 | cmp dword [ballxv],2 |
||
76 | jng balln |
||
77 | dec dword [ballxv] |
||
78 | jmp balln |
||
79 | ballb: |
||
80 | cmp dword [ballxv],-2 |
||
81 | jnl balln |
||
82 | inc dword [ballxv] |
||
83 | jmp balln |
||
84 | balln: |
||
85 | cmp dword [ballyv],2 |
||
86 | jng by_n |
||
87 | dec dword [ballyv] |
||
88 | by_n: |
||
89 | |||
90 | ;ball collusion of screen |
||
91 | cmp dword [ballx],640-32 |
||
92 | jna xa_ok |
||
93 | neg dword [ballxv] |
||
94 | xa_ok: |
||
95 | cmp dword [ballx],6 |
||
96 | jnb xb_ok |
||
97 | neg dword [ballxv] |
||
98 | xb_ok: |
||
99 | |||
100 | ;if ball far out of screen come back |
||
101 | ; is not work already |
||
102 | cmp dword [bally],466 |
||
103 | jng yax_ok |
||
104 | call draw_window |
||
105 | inc dword [scoreb] |
||
106 | mov dword [bally],240 |
||
107 | mov dword [ballx],310 |
||
108 | mov dword [ballyv],2 |
||
109 | random 5,dword [ballxv] |
||
110 | sub dword [ballxv],2 |
||
111 | yax_ok: |
||
112 | cmp dword [bally],30 |
||
113 | jnl yax_ok2 |
||
114 | call draw_window |
||
115 | inc dword [scorea] |
||
116 | mov dword [bally],240 |
||
117 | mov dword [ballx],310 |
||
118 | mov dword [ballyv],2 |
||
119 | random 5,dword [ballxv] |
||
120 | sub dword [ballxv],2 |
||
121 | yax_ok2: |
||
122 | |||
123 | xorx: |
||
124 | cmp dword [ballxv],0 |
||
125 | jne norx |
||
126 | random 5,dword [ballxv] |
||
127 | sub dword [ballxv],2 |
||
128 | cmp dword [ballxv],0 |
||
129 | je xorx |
||
130 | norx: |
||
131 | |||
132 | ;test on collusion ply1 of ball |
||
133 | collusion_test: |
||
134 | collimg img,[ply1x],[ply1y],img3,[ballx],[bally],eax |
||
135 | cmp eax,1 |
||
136 | jne not_coll |
||
137 | neg dword [ballyv] |
||
138 | add dword [bally],4 |
||
139 | ; neg dword [ballxv] |
||
140 | not_coll: |
||
141 | |||
142 | ;test on collusion com of ball |
||
143 | collusion_com: |
||
144 | collimg img,[ply2x],[ply2y],img3,[ballx],[bally],eax |
||
145 | cmp eax,1 |
||
146 | jne not_collcom |
||
147 | neg dword [ballyv] |
||
148 | sub dword [bally],4 |
||
149 | ; neg dword [ballxv] |
||
150 | not_collcom: |
||
151 | |||
152 | ;test on collusion gravity of ball |
||
153 | collusion_grav: |
||
154 | collimg img,[gravx],[gravy],img3,[ballx],[bally],eax |
||
155 | cmp eax,1 |
||
156 | jne not_collg |
||
157 | neg dword [ballyv] |
||
158 | |||
159 | ; mov dword [ballxv],-20 |
||
160 | |||
161 | cmp dword [ballyv],0 |
||
162 | jl ab |
||
163 | jg bf |
||
164 | jmp not_collgx |
||
165 | ab: |
||
166 | sub dword [ballyv],25 |
||
167 | jmp not_collgx |
||
168 | bf: |
||
169 | add dword [ballyv],25 |
||
170 | not_collgx: |
||
171 | cmp dword [ballxv],0 |
||
172 | jl abx |
||
173 | jg bfx |
||
174 | jmp not_collg |
||
175 | abx: |
||
176 | sub dword [ballxv],8 ;15 |
||
177 | jmp not_collg |
||
178 | bfx: |
||
179 | add dword [ballxv],8 |
||
180 | |||
181 | |||
182 | ; mov dword [ballyv],20 |
||
183 | not_collg: |
||
184 | |||
185 | ;ply contorl |
||
186 | cmp dword [ply1rx],560 |
||
187 | jna plyok |
||
188 | cmp dword [ply1rx],12000 |
||
189 | jna paa |
||
190 | mov dword [ply1rx],4 |
||
191 | jmp plyok |
||
192 | paa: |
||
193 | mov dword [ply1rx],560 |
||
194 | plyok: |
||
195 | |||
196 | |||
197 | ;com contorl |
||
198 | cmp dword [ply2x],560 |
||
199 | jna cplyok |
||
200 | cmp dword [ply2x],12000 |
||
201 | jna cpaa |
||
202 | mov dword [ply2x],4 |
||
203 | jmp cplyok |
||
204 | cpaa: |
||
205 | mov dword [ply2x],560 |
||
206 | cplyok: |
||
207 | |||
208 | |||
209 | ;com move |
||
210 | cx_move: |
||
211 | cmp dword [bally],160 |
||
212 | jna cno_m |
||
213 | mov eax,dword [ballx] |
||
214 | sub eax,30 |
||
215 | cmp dword [ply2x],eax |
||
216 | je cno_m |
||
217 | cmp dword [ply2x],eax |
||
218 | ja cm_m |
||
219 | cm_p: |
||
220 | add dword [ply2x],3 |
||
221 | jmp cno_m |
||
222 | cm_m: |
||
223 | sub dword [ply2x],3 |
||
224 | cno_m: |
||
225 | |||
226 | ;garvity |
||
227 | gravity: |
||
228 | cmp dword [gravtime],0 |
||
229 | je no_dg |
||
230 | dec dword [gravtime] |
||
231 | no_dg: |
||
232 | |||
233 | draw_gravity: |
||
234 | cmp dword [gravtime],0 |
||
235 | je nograv |
||
236 | mov eax,dword [ply1x] |
||
237 | mov ebx,dword [ply1y] |
||
238 | add ebx,10 |
||
239 | mov dword [gravx],eax |
||
240 | mov dword [gravy],ebx |
||
241 | jmp endgrav |
||
242 | nograv: |
||
243 | mov dword [gravx],1000 |
||
244 | mov dword [gravy],1000 |
||
245 | endgrav: |
||
246 | |||
247 | redraw_images: |
||
248 | setimg dword [ply1x],dword [ply1y],img |
||
249 | setimg dword [ply2x],dword [ply2y],img2 ;2 |
||
250 | setimg dword [ballx],dword [bally],img3 |
||
251 | setimg dword [gravx],dword [gravy],img5 |
||
252 | |||
253 | |||
254 | delay 1 ;don't generate delay for fast speed programm |
||
255 | |||
256 | jmp still |
||
257 | |||
258 | red: |
||
259 | call draw_window |
||
260 | jmp still |
||
261 | |||
262 | key: ; key |
||
263 | mov eax,2 |
||
485 | heavyiron | 264 | mcall |
31 | halyavin | 265 | cmp ah,key_Left |
266 | jne no_l |
||
267 | sub dword [ply1rx],32 ;16 |
||
268 | no_l: |
||
269 | cmp ah,key_Right |
||
270 | jne no_r |
||
271 | add dword [ply1rx],32 ;16 |
||
272 | no_r: |
||
273 | cmp ah,key_Up |
||
274 | jne no_u |
||
275 | sub dword [ply1ry],16 |
||
276 | no_u: |
||
277 | cmp ah,key_Down |
||
278 | jne no_d |
||
279 | add dword [ply1ry],16 |
||
280 | no_d: |
||
281 | cmp ah,key_Space |
||
282 | jne no_sp |
||
283 | mov dword [gravtime],100 |
||
284 | no_sp: |
||
285 | |||
286 | jmp still |
||
287 | |||
288 | button: ; button |
||
289 | mov eax,17 ; get id |
||
485 | heavyiron | 290 | mcall |
31 | halyavin | 291 | cmp ah,1 ; button id=1 ? |
292 | jne noclose |
||
293 | mov eax,-1 ; close this program |
||
485 | heavyiron | 294 | mcall |
31 | halyavin | 295 | noclose: |
296 | jmp still |
||
297 | |||
298 | |||
299 | draw_window: |
||
2674 | leency | 300 | mcall 12,1 ;start window redraw |
301 | mcall 0, <10, 640+8>, <10, 480+24>, 0x14000000,, wtitle |
||
302 | mcall 12,2 ;end window redraw |
||
31 | halyavin | 303 | ret |
304 | |||
305 | |||
306 | ; DATA AREA |
||
2674 | leency | 307 | wtitle db 'PONG: USE ARROW KEYS SCORE:',0 |
308 | ;skin_h dd 25 |
||
309 | |||
31 | halyavin | 310 | xt dd 100 |
311 | yt dd 100 |
||
312 | |||
313 | gravtime dd 10 |
||
314 | gravx dd 1000 |
||
315 | gravy dd 1000 |
||
316 | |||
317 | ply1rx dd 200 |
||
318 | ply1ry dd 50 |
||
319 | |||
320 | ply1x dd 200 |
||
321 | ply1y dd 50 |
||
322 | |||
323 | ply2x dd 200 |
||
324 | ply2y dd 400 |
||
325 | |||
326 | ballx dd 200 |
||
327 | bally dd 200 |
||
328 | |||
329 | ballyv dd 3 |
||
330 | ballxv dd 3 |
||
331 | |||
332 | scorea dd 0 |
||
333 | scoreb dd 0 |
||
334 | |||
335 | counter dd 0 |
||
336 | tsoi dd 0 |
||
337 | |||
338 | pongfile: |
||
339 | file 'pong.bmp' |
||
340 | |||
341 | IM_END: |
||
342 | |||
343 | temp: |
||
344 | rb 20000 |
||
345 | |||
346 | pong: |
||
347 | rb 80*60*3+8 |
||
348 | img: |
||
349 | rb 32*32*3+8 |
||
350 | img2: |
||
351 | rb 32*32*3+8 |
||
352 | img3: |
||
353 | rb 32*32*3+8 |
||
354 | img4: |
||
355 | rb 80*20*3+8 |
||
356 | img5: |
||
357 | rb 32*32*3+8 |
||
358 | img6: |
||
359 | rb 15*15*3+8 |
||
360 | |||
361 | temp_area: |
||
362 | rb 0x15000 |
||
363 | |||
364 | I_END:10,>10,> |