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