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