Mercurial > hg > Members > kono > nitros9-code
comparison 3rdparty/packages/pacos9/movpac90.a @ 1864:f351932fa6cd
Added pacos9
author | boisy |
---|---|
date | Tue, 26 Jul 2005 01:17:24 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
1863:ebec41c32d7d | 1864:f351932fa6cd |
---|---|
1 | |
2 NAM MOVPAC | |
3 TTL Move pacman routines | |
4 | |
5 * Program segment to be compiled using Level II RMA | |
6 * This is not a mainline program segment | |
7 * Written by Larry Olson | |
8 | |
9 IFP1 | |
10 * use /dd/defs/os9defs.a | |
11 ENDc | |
12 | |
13 | |
14 STACK EQU 100 | |
15 | |
16 | |
17 PSECT MOVPAC,0,0,2,STACK,MVPAC | |
18 | |
19 VSECT | |
20 | |
21 * Local variables | |
22 | |
23 RMB STACK | |
24 | |
25 ENDSECT | |
26 | |
27 | |
28 MVPAC: nop | |
29 | |
30 * Read joystick | |
31 | |
32 JOY lda PATH Set path to window | |
33 ldb #$13 Setup for SS.Joy | |
34 ldx PORT,U Get selected port | |
35 os9 I$GetStt | |
36 lbcs ERR1 | |
37 stx JOYSTX | |
38 sty JOYSTY | |
39 sta BUTTON | |
40 * Cycle is used to animate pacman | |
41 | |
42 CYC dec CYCLE Decrement cycle counter | |
43 bpl MVRT If >0 continue | |
44 lda #2 Reset counter to 2 | |
45 sta CYCLE | |
46 | |
47 clra | |
48 sta MOVFLG,U | |
49 | |
50 * Check direction of joystick & move pacman | |
51 | |
52 MVRT leay ARRAY,U Point to start of array | |
53 ldd POFSET Get pacman offset in array | |
54 leax D,Y | |
55 * X reg now points to pacman position in array | |
56 ldd JOYSTX Get joystick X value | |
57 cmpd #37 Is it greater than 37 ? | |
58 blo MVLFT Go to move left | |
59 | |
60 inc MOVFLG,U | |
61 | |
62 lda 1,X Get adjacent byte from array | |
63 lbmi MVDWN If wall then go check for down | |
64 ldd PCXLOC GET pseudo screen X location | |
65 cmpd PXNEW Is it equal to actual location? | |
66 beq SKIPR | |
67 addd #8 | |
68 std PCXLOC | |
69 SKIPR ldd PXNEW Get actual screen X location | |
70 addd #8 Add 8 to it | |
71 std PXNEW Put it back | |
72 ldd PYNEW Get screen Y location | |
73 std PCYLOC Set pyold = pynew | |
74 ldd POFSET Get pacman array offset | |
75 addd #1 Increment it | |
76 cmpd #1793 Is it off screen to the right ? | |
77 bne STBUF1 | |
78 * Erase pacman on right side of screen | |
79 * Before moving pacman to left side | |
80 lda #37 Set for blank pacman | |
81 sta PBFN Put it in putblk code | |
82 ldd #572 | |
83 std PXLOC | |
84 ldd #85 | |
85 std PYLOC | |
86 lbsr PUTBLK Go erase pacman | |
87 | |
88 ldd #44 | |
89 std PXNEW Reset pac screen X to 36 | |
90 subd #8 Set pseudo X location | |
91 std PCXLOC | |
92 lda #1 | |
93 ldd #1726 Move pacman to left side | |
94 STBUF1 std POFSET Store pacman array offset | |
95 leax D,Y Point to pacman position in array | |
96 lda #25 Set pacman direction buffer | |
97 sta BUFF for right facing pacman | |
98 ldb #1 | |
99 lda B,X Get the byte at this spot | |
100 bmi MVPAC1 Branch if wall | |
101 bita #6 Check for a dot or pill | |
102 beq MVPAC1 | |
103 lbsr ERPILL Go erase pill or dot | |
104 bra MVPAC1 | |
105 MVLFT ldd JOYSTX Get joystick X value | |
106 cmpd #27 | |
107 bhi MVDWN | |
108 inc MOVFLG,U | |
109 lda -1,X Get byte 1 move to the left | |
110 bmi MVDWN Branch if wall | |
111 ldd PXNEW Get new pac position | |
112 subd #8 Subtract 8 from it | |
113 std PXNEW Put it back | |
114 std PCXLOC Set pxold = pxnew | |
115 ldd PYNEW | |
116 std PCYLOC Set pyold = pynew | |
117 ldd POFSET Get pacman array offset | |
118 subd #1 Decrement it | |
119 cmpd #1725 Is it off left side of screen ? | |
120 bne STBUF2 If not then store hcount | |
121 * Erase pacman on left side of screen | |
122 * Before moving pacman to right side | |
123 lda #37 Set for blank pacman | |
124 sta PBFN Put it in PUTBLK code | |
125 ldd #44 | |
126 std PXLOC | |
127 ldd #85 | |
128 std PYLOC | |
129 lbsr PUTBLK Go erase pacman | |
130 | |
131 ldd #572 | |
132 std PXNEW Update screen location too. | |
133 std PCXLOC | |
134 ldd #1792 Move pacman to right side | |
135 STBUF2 std POFSET Store pacman array offset | |
136 leax D,Y X holds pacman position in array | |
137 lda #28 Set pacman direction buffer | |
138 sta BUFF for left facing pacman | |
139 ldb #-1 | |
140 lda B,X Get byte from array | |
141 bmi MVPAC1 Branch if wall | |
142 bita #6 Check for dot or pill | |
143 beq MVPAC1 | |
144 lbsr ERPILL Go erase pill or dot | |
145 MVPAC1 lda BUFF | |
146 adda CYCLE | |
147 sta PCBFN | |
148 leax PUTPACM,U | |
149 ldy #8 | |
150 lda PATH | |
151 os9 I$Write | |
152 lbcs ERR1 | |
153 | |
154 MVDWN leay ARRAY,U Point to start of array | |
155 ldd POFSET Get pacman array offset | |
156 leax D,Y X holds pacman array position | |
157 ldd JOYSTY Get joystick Y value | |
158 cmpd #27 Is it greater than 27 ? | |
159 bhi MVUP If not, then check for up move | |
160 inc MOVFLG,U | |
161 lda 69,X Look at byte one line down | |
162 lbmi LEAVE Branch if wall | |
163 ldd PCYLOC Get pseudo screen Y location | |
164 cmpd PYNEW Are they the same ? | |
165 beq SKIPD | |
166 addd #3 Add 3 to it | |
167 std PCYLOC | |
168 SKIPD ldd PYNEW Get actual screen Y location | |
169 addd #3 Add 3 to it | |
170 std PYNEW Put it back | |
171 ldd PXNEW | |
172 std PCXLOC | |
173 SKIPD2 ldd POFSET Get location in array | |
174 addd #69 Move down 1 line | |
175 cmpd #3692 Off screen at bottom? | |
176 bne STBUF3 | |
177 | |
178 lda #37 Blank pacman buffer | |
179 sta PBFN | |
180 ldd #316 | |
181 std PXLOC | |
182 ldd #166 | |
183 std PYLOC | |
184 lbsr PUTBLK Go erase pacman at bottom | |
185 | |
186 ldd #300 | |
187 std PXNEW | |
188 std PCXLOC | |
189 ldd #07 New Y scrn location | |
190 std PCYLOC | |
191 addd #3 | |
192 std PYNEW | |
193 ldd #33 Move to top of array | |
194 STBUF3 std POFSET | |
195 leax D,Y | |
196 lda #34 Set pacman direction buffer | |
197 sta BUFF for down facing pacman | |
198 ldb #69 Look one line down | |
199 lda B,X Get byte at this spot | |
200 bmi MVPAC2 Branch if wall | |
201 bita #6 Check for dot(2) or pill(4) | |
202 beq MVPAC2 Go move pacman | |
203 lbsr ERPILL Go erase pill or dot | |
204 bra MVPAC2 Go move pacman | |
205 | |
206 MVUP ldd JOYSTY Get joystick Y value | |
207 cmpd #37 Is it less than 37 ? | |
208 lblo LEAVE | |
209 inc MOVFLG,U | |
210 lda -69,X Get byte from array, 1 line up | |
211 bmi LEAVE Branch if wall | |
212 ldd PYNEW Get pac screen Y location | |
213 subd #3 Subtract 3 from it | |
214 std PYNEW Put it back | |
215 std PCYLOC Set pyold = pynew | |
216 ldd PXNEW | |
217 std PCXLOC Set pxold = pxnew | |
218 lda #31 Set direction buffer | |
219 sta BUFF to up facing pacman | |
220 ldd POFSET Get pacman array offset | |
221 subd #69 Move up one line | |
222 cmpd #33 At top of screen? | |
223 bne STBUF4 | |
224 | |
225 lda #37 Blank pacman buffer # | |
226 sta PBFN | |
227 ldd #300 | |
228 std PXLOC | |
229 ldd #13 | |
230 std PYLOC | |
231 lbsr PUTBLK Erase pacman at top | |
232 | |
233 ldd #316 | |
234 std PXNEW | |
235 std PCXLOC | |
236 ldd #169 | |
237 std PYNEW | |
238 std PCYLOC | |
239 ldd #3692 | |
240 STBUF4 std POFSET Put it back | |
241 leax D,Y X holds pacman array position | |
242 ldb #-69 | |
243 lda B,X Get byte at this spot | |
244 bmi MVPAC2 Branch if wall | |
245 bita #6 Check for dot(2) or pill(4) | |
246 beq MVPAC2 Go move pacman | |
247 lbsr ERPILL Go erase pill or dot | |
248 MVPAC2 lda BUFF Get current pac buffer | |
249 adda CYCLE Add cycle count | |
250 sta PCBFN Set putblk buffer | |
251 leax PUTPACM,U | |
252 ldy #8 | |
253 lda PATH | |
254 os9 I$Write | |
255 lbcs ERR1 | |
256 | |
257 LEAVE lda MOVFLG,U | |
258 bne EXTCHK | |
259 ldx #2 | |
260 lbsr WAIT | |
261 | |
262 EXTCHK ldb PACMAN Get # of pacmen left | |
263 cmpb #6 Only a total of 6 allowed | |
264 beq MVDONE If already 6, then exit | |
265 lda SCRBCD,U | |
266 anda #15 %00001111 strip high | |
267 cmpa EXTPAC,U Compare it with goal | |
268 blo MVDONE If not =, then exit | |
269 incb If =, then give bonus- | |
270 stb PACMAN pacman to player | |
271 inc EXTPAC,U Increment goal | |
272 ldd #181 | |
273 std PYLOC,U | |
274 lda #28 | |
275 sta PBFN,U | |
276 lda #30 | |
277 ldb PACMAN | |
278 subb #1 | |
279 mul | |
280 std PXLOC,U | |
281 ldd #600 | |
282 subd PXLOC,U | |
283 std PXLOC,U | |
284 lbsr PUTBLK | |
285 | |
286 MVDONE rts Return to MAIN | |
287 | |
288 PALCHG: clrb | |
289 stb STRLGH Save counter | |
290 leay STRING,U String to output | |
291 leax G1OFST,U Point to ghost tables | |
292 lda 10,X Get #1 ghost status | |
293 cmpa #1 | |
294 bne TEST2 | |
295 ldd #$1b31 Palette set code | |
296 std ,Y++ Put it in string | |
297 ldd #$043d | |
298 std ,Y++ Put it in string | |
299 inc STRLGH | |
300 lda #2 | |
301 sta 10,X Make ghost run from pacman | |
302 TEST2 lda 30,X Get #2 ghost status | |
303 cmpa #1 | |
304 bne TEST3 | |
305 ldd #$1b31 Palette set code | |
306 std ,Y++ Put it in string | |
307 ldd #$063d | |
308 std ,Y++ Put it in string | |
309 inc STRLGH | |
310 lda #2 | |
311 sta 30,X Make ghost run from pacman | |
312 TEST3 lda 50,X Get #3 ghost status | |
313 cmpa #1 | |
314 bne TEST4 | |
315 ldd #$1b31 Palette set code | |
316 std ,Y++ | |
317 ldd #$053d | |
318 std ,Y++ Put it in string | |
319 inc STRLGH | |
320 lda #2 | |
321 sta 50,X Make ghost run from pacman | |
322 TEST4 lda 70,X Get #4 ghost status | |
323 cmpa #1 | |
324 bne TESTCK | |
325 ldd #$1b31 Palette set code | |
326 std ,Y++ | |
327 ldd #$033d | |
328 std ,Y | |
329 inc STRLGH | |
330 lda #2 | |
331 sta 70,X Make ghost run from pacman | |
332 TESTCK ldb STRLGH | |
333 beq OTDONE | |
334 lda #4 | |
335 mul | |
336 tfr D,Y | |
337 leax STRING,U | |
338 lbsr OUTSTR | |
339 OTDONE rts | |
340 | |
341 * erase pill subroutine | |
342 * Erases DOT or PILL from array | |
343 * and updates score | |
344 * On entry, X reg points to spot in array | |
345 * B reg holds 1 byte offset 1,-1,96 or -96 | |
346 * A reg holds byte at that point in array | |
347 | |
348 ERPILL cmpa #6 Was it a bonus ? | |
349 beq ERBON | |
350 bita #4 Was it a power dot ? | |
351 beq ERDOT | |
352 anda #1 | |
353 sta B,X Erase power pill from array | |
354 lda #32 Add 20 to score | |
355 sta POINTS+2 | |
356 | |
357 ldd DOTTOT | |
358 addd #1 | |
359 std DOTTOT | |
360 | |
361 lda #100 Set timeout counter | |
362 sta POWFLG | |
363 lbsr PALCHG Go change color of ghosts | |
364 bra ADDUP | |
365 | |
366 ERBON clra | |
367 sta B,X | |
368 lbsr SETBON Go to Bonus Routines(in SCRNS) | |
369 lda #154 Add 100 to score | |
370 sta POINTS+2 | |
371 bra ADDUP | |
372 | |
373 ERDOT anda #1 | |
374 sta B,X Erase dot from array | |
375 lda #1 Add 1 point to score | |
376 sta POINTS+2 Put it back | |
377 | |
378 ldd DOTTOT | |
379 addd #1 | |
380 std DOTTOT | |
381 | |
382 * Add points to score | |
383 | |
384 ADDUP: leax SCRBCD+3,U | |
385 leay POINTS+3,U | |
386 ldb #3 Set loop counter to 3 | |
387 andcc #%11111110 Clear carry | |
388 ADLOOP lda ,-X Decrement X and get a byte | |
389 adca ,-Y Add new points | |
390 daa Decimal adjust bytes | |
391 sta ,X Put result back in score byte | |
392 decb Decrement loop counter | |
393 bne ADLOOP Loop till done | |
394 | |
395 SHIFT leay SCRASC,U Point to asc string | |
396 leax SCRBCD,U Point to score bytes | |
397 ldb #3 Set loop counter to 3 | |
398 stb SHCNT Set loop counter to 3 | |
399 clrb Clear leading zero flag | |
400 SFLOOP lda ,X Get a byte of score, bump pointer | |
401 lsra | |
402 lsra Shift high nibble to low | |
403 lsra | |
404 lsra | |
405 beq TSTFG1 | |
406 incb Set leading zero flag | |
407 TSTFG1 tstb Is leading zero flag set ? | |
408 bne ASCSET1 | |
409 lda #-16 48-16 = ascii space | |
410 ASCSET1 adda #48 Add ascii offset for number | |
411 sta ,Y+ Put result in score string | |
412 lda ,X+ Get bcd score byte again | |
413 anda #15 Mask off high nibble | |
414 beq TSTFG2 | |
415 incb | |
416 TSTFG2 tstb | |
417 bne ASCSET2 | |
418 lda #-16 | |
419 ASCSET2 adda #48 | |
420 sta ,Y+ | |
421 dec SHCNT | |
422 bne SFLOOP Loop 3 times | |
423 | |
424 JUST1 leax SCRPOS,U Point to score string | |
425 ldy #9 Output 9 characters | |
426 lbsr OUTSTR Go output string | |
427 | |
428 rts | |
429 | |
430 * Noise maker when pacman eats a dot | |
431 | |
432 | |
433 *WOCWOC lda PATH | |
434 * ldb #$98 | |
435 * ldx #$3202 | |
436 * ldy #3000 | |
437 * os9 I$SetStt | |
438 | |
439 * ldy #2000 | |
440 * os9 I$GetStt | |
441 | |
442 * Return to MAIN | |
443 | |
444 *SCDONE rts | |
445 | |
446 | |
447 ENDSECT | |
448 | |
449 | |
450 |