Rev 31 | Rev 485 | 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 | ;****************************************************************************** |
||
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 | |||
20 | |||
21 | include 'ascl.inc' |
||
22 | include 'ascgl.inc' |
||
23 | include 'ascgml.inc' |
||
24 | |||
25 | |||
26 | START: ; start of execution |
||
27 | call draw_window |
||
28 | |||
29 | ; loadbmp '/RD/1/PONG.BMP',temp_area,I_END,tsoi |
||
30 | convbmp pongfile,tsoi |
||
31 | bmptoimg pongfile,tsoi,pong |
||
32 | getimg pong,0,0,80,4,img |
||
33 | getimg pong,0,4,80,4,img2 |
||
34 | getimg pong,5,38,15,15,img3 |
||
35 | getimg pong,0,8,80,20,img5 |
||
36 | fullimg img4 , 80 ,20 ,0x00000000 ;black for rocket |
||
37 | fullimg img6 , 15 ,15 ,0x00000000 ;black for ball |
||
38 | |||
39 | |||
40 | |||
41 | still: |
||
42 | |||
43 | scevent red,key,button |
||
44 | |||
45 | outcount dword [scoreb],300,8,cl_Blue,5*65536 |
||
46 | outcount dword [scorea],350,8,cl_Red,5*65536 |
||
47 | |||
48 | del_images: |
||
49 | setimg dword [ply1x],dword [ply1y],img4 |
||
50 | setimg dword [ply2x],dword [ply2y],img4 |
||
51 | setimg dword [ballx],dword [bally],img6 |
||
52 | setimg dword [gravx],dword [gravy],img4 |
||
53 | |||
54 | move_ply1: |
||
55 | |||
56 | correct [ply1x],[ply1rx],4 |
||
57 | correct [ply1y],[ply1ry],2 |
||
58 | |||
59 | ;automove ball |
||
60 | mov eax,dword [ballxv] |
||
61 | add dword [ballx],eax |
||
62 | mov eax,dword [ballyv] |
||
63 | add dword [bally],eax |
||
64 | |||
65 | |||
66 | ;autoslow ball |
||
67 | cmp dword [ballxv],0 |
||
68 | jl ballb |
||
69 | balla: |
||
70 | cmp dword [ballxv],2 |
||
71 | jng balln |
||
72 | dec dword [ballxv] |
||
73 | jmp balln |
||
74 | ballb: |
||
75 | cmp dword [ballxv],-2 |
||
76 | jnl balln |
||
77 | inc dword [ballxv] |
||
78 | jmp balln |
||
79 | balln: |
||
80 | cmp dword [ballyv],2 |
||
81 | jng by_n |
||
82 | dec dword [ballyv] |
||
83 | by_n: |
||
84 | |||
85 | ;ball collusion of screen |
||
86 | cmp dword [ballx],640-32 |
||
87 | jna xa_ok |
||
88 | neg dword [ballxv] |
||
89 | xa_ok: |
||
90 | cmp dword [ballx],6 |
||
91 | jnb xb_ok |
||
92 | neg dword [ballxv] |
||
93 | xb_ok: |
||
94 | |||
95 | ;if ball far out of screen come back |
||
96 | ; is not work already |
||
97 | cmp dword [bally],466 |
||
98 | jng yax_ok |
||
99 | call draw_window |
||
100 | inc dword [scoreb] |
||
101 | mov dword [bally],240 |
||
102 | mov dword [ballx],310 |
||
103 | mov dword [ballyv],2 |
||
104 | random 5,dword [ballxv] |
||
105 | sub dword [ballxv],2 |
||
106 | yax_ok: |
||
107 | cmp dword [bally],30 |
||
108 | jnl yax_ok2 |
||
109 | call draw_window |
||
110 | inc dword [scorea] |
||
111 | mov dword [bally],240 |
||
112 | mov dword [ballx],310 |
||
113 | mov dword [ballyv],2 |
||
114 | random 5,dword [ballxv] |
||
115 | sub dword [ballxv],2 |
||
116 | yax_ok2: |
||
117 | |||
118 | xorx: |
||
119 | cmp dword [ballxv],0 |
||
120 | jne norx |
||
121 | random 5,dword [ballxv] |
||
122 | sub dword [ballxv],2 |
||
123 | cmp dword [ballxv],0 |
||
124 | je xorx |
||
125 | norx: |
||
126 | |||
127 | ;test on collusion ply1 of ball |
||
128 | collusion_test: |
||
129 | collimg img,[ply1x],[ply1y],img3,[ballx],[bally],eax |
||
130 | cmp eax,1 |
||
131 | jne not_coll |
||
132 | neg dword [ballyv] |
||
133 | add dword [bally],4 |
||
134 | ; neg dword [ballxv] |
||
135 | not_coll: |
||
136 | |||
137 | ;test on collusion com of ball |
||
138 | collusion_com: |
||
139 | collimg img,[ply2x],[ply2y],img3,[ballx],[bally],eax |
||
140 | cmp eax,1 |
||
141 | jne not_collcom |
||
142 | neg dword [ballyv] |
||
143 | sub dword [bally],4 |
||
144 | ; neg dword [ballxv] |
||
145 | not_collcom: |
||
146 | |||
147 | ;test on collusion gravity of ball |
||
148 | collusion_grav: |
||
149 | collimg img,[gravx],[gravy],img3,[ballx],[bally],eax |
||
150 | cmp eax,1 |
||
151 | jne not_collg |
||
152 | neg dword [ballyv] |
||
153 | |||
154 | ; mov dword [ballxv],-20 |
||
155 | |||
156 | cmp dword [ballyv],0 |
||
157 | jl ab |
||
158 | jg bf |
||
159 | jmp not_collgx |
||
160 | ab: |
||
161 | sub dword [ballyv],25 |
||
162 | jmp not_collgx |
||
163 | bf: |
||
164 | add dword [ballyv],25 |
||
165 | not_collgx: |
||
166 | cmp dword [ballxv],0 |
||
167 | jl abx |
||
168 | jg bfx |
||
169 | jmp not_collg |
||
170 | abx: |
||
171 | sub dword [ballxv],8 ;15 |
||
172 | jmp not_collg |
||
173 | bfx: |
||
174 | add dword [ballxv],8 |
||
175 | |||
176 | |||
177 | ; mov dword [ballyv],20 |
||
178 | not_collg: |
||
179 | |||
180 | ;ply contorl |
||
181 | cmp dword [ply1rx],560 |
||
182 | jna plyok |
||
183 | cmp dword [ply1rx],12000 |
||
184 | jna paa |
||
185 | mov dword [ply1rx],4 |
||
186 | jmp plyok |
||
187 | paa: |
||
188 | mov dword [ply1rx],560 |
||
189 | plyok: |
||
190 | |||
191 | |||
192 | ;com contorl |
||
193 | cmp dword [ply2x],560 |
||
194 | jna cplyok |
||
195 | cmp dword [ply2x],12000 |
||
196 | jna cpaa |
||
197 | mov dword [ply2x],4 |
||
198 | jmp cplyok |
||
199 | cpaa: |
||
200 | mov dword [ply2x],560 |
||
201 | cplyok: |
||
202 | |||
203 | |||
204 | ;com move |
||
205 | cx_move: |
||
206 | cmp dword [bally],160 |
||
207 | jna cno_m |
||
208 | mov eax,dword [ballx] |
||
209 | sub eax,30 |
||
210 | cmp dword [ply2x],eax |
||
211 | je cno_m |
||
212 | cmp dword [ply2x],eax |
||
213 | ja cm_m |
||
214 | cm_p: |
||
215 | add dword [ply2x],3 |
||
216 | jmp cno_m |
||
217 | cm_m: |
||
218 | sub dword [ply2x],3 |
||
219 | cno_m: |
||
220 | |||
221 | ;garvity |
||
222 | gravity: |
||
223 | cmp dword [gravtime],0 |
||
224 | je no_dg |
||
225 | dec dword [gravtime] |
||
226 | no_dg: |
||
227 | |||
228 | draw_gravity: |
||
229 | cmp dword [gravtime],0 |
||
230 | je nograv |
||
231 | mov eax,dword [ply1x] |
||
232 | mov ebx,dword [ply1y] |
||
233 | add ebx,10 |
||
234 | mov dword [gravx],eax |
||
235 | mov dword [gravy],ebx |
||
236 | jmp endgrav |
||
237 | nograv: |
||
238 | mov dword [gravx],1000 |
||
239 | mov dword [gravy],1000 |
||
240 | endgrav: |
||
241 | |||
242 | redraw_images: |
||
243 | setimg dword [ply1x],dword [ply1y],img |
||
244 | setimg dword [ply2x],dword [ply2y],img2 ;2 |
||
245 | setimg dword [ballx],dword [bally],img3 |
||
246 | setimg dword [gravx],dword [gravy],img5 |
||
247 | |||
248 | |||
249 | delay 1 ;don't generate delay for fast speed programm |
||
250 | |||
251 | jmp still |
||
252 | |||
253 | red: |
||
254 | call draw_window |
||
255 | jmp still |
||
256 | |||
257 | key: ; key |
||
258 | mov eax,2 |
||
259 | int 0x40 |
||
260 | cmp ah,key_Left |
||
261 | jne no_l |
||
262 | sub dword [ply1rx],32 ;16 |
||
263 | no_l: |
||
264 | cmp ah,key_Right |
||
265 | jne no_r |
||
266 | add dword [ply1rx],32 ;16 |
||
267 | no_r: |
||
268 | cmp ah,key_Up |
||
269 | jne no_u |
||
270 | sub dword [ply1ry],16 |
||
271 | no_u: |
||
272 | cmp ah,key_Down |
||
273 | jne no_d |
||
274 | add dword [ply1ry],16 |
||
275 | no_d: |
||
276 | cmp ah,key_Space |
||
277 | jne no_sp |
||
278 |