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