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