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