Mercurial > hg > Members > kono > nitros9-code
comparison 3rdparty/packages/pacos9/ghosts90.as @ 2945:582b5b7232c0
pacos9: Rename assembler files to .as and port makefile to lwtools
And build pacos9 by default again.
Nowadays .a files are library archive files.
According to rules.mak, as. files are to be built as object files
for later linking with lwlink, similar to old RMA/RLINK.
author | Tormod Volden <debian.tormod@gmail.com> |
---|---|
date | Sat, 08 Feb 2014 01:03:26 +0100 (2014-02-08) |
parents | 3rdparty/packages/pacos9/ghosts90.a@f351932fa6cd |
children | 06508da42c98 |
comparison
equal
deleted
inserted
replaced
2944:ab3f9eb5fc5c | 2945:582b5b7232c0 |
---|---|
1 | |
2 NAM Ghosts | |
3 TTL Routines to move Ghosts | |
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 STACK EQU 250 | |
14 | |
15 PSECT Ghosts,0,0,2,STACK,GHCHCK | |
16 | |
17 VSECT | |
18 | |
19 * Lcoal Variables | |
20 | |
21 RMB STACK | |
22 | |
23 | |
24 ENDSECT | |
25 | |
26 | |
27 * Subtract 20 from ghost counter | |
28 * Then check ghost status to determine what action | |
29 * is to be preformed on ghost. | |
30 | |
31 GHCHCK: lda GCOUNT Get ghost counter | |
32 suba #20 Subtract 20 from it | |
33 bpl CKSTAT If =>0 then check status | |
34 lda #60 Reset counter to zero | |
35 CKSTAT sta GCOUNT Save ghost counter | |
36 leax G1OFST,U Point to start of tables | |
37 leax A,X Move to current ghost table | |
38 lda 10,X Get ghost status | |
39 lbeq MOVING If so then move it again | |
40 lbmi CAGED Check caged status | |
41 | |
42 GHMOVE leay ARRAY,U Point to start of array | |
43 ldd ,X Get ghost array offset | |
44 leay D,Y Move to that spot in array | |
45 lda ,Y Get the byte there | |
46 bita #1 Check for intersection | |
47 beq NOWALL If = then no intersection | |
48 | |
49 lda 10,X Check status | |
50 cmpa #1 Are we chasing pacman? | |
51 beq NORUN | |
52 lbsr RUN If not, then run | |
53 bra NOWALL | |
54 NORUN ldd ,X | |
55 lbsr HUNT At intersection, so go hunt | |
56 | |
57 * This routine is used to calc and add the offsets and | |
58 * fill the PUTBLK string, in order to move the ghosts | |
59 * Old ghost will be erased when new ghost is put on | |
60 * the screen. | |
61 | |
62 NOWALL lda 14,X Get direction flag | |
63 bne LEFT | |
64 * Move ghost up screen | |
65 UP ldd ,X Get ghost array offset | |
66 cmpd #33 At top of screen? | |
67 bne STGH1 | |
68 | |
69 pshs X Save X reg. | |
70 | |
71 lda #1 Set for blank ghost | |
72 sta PGBFN | |
73 ldd #300 | |
74 std PGXLOC | |
75 ldd #10 | |
76 std PGYLOC | |
77 lbsr PUTGHT | |
78 | |
79 puls X Restore X reg. | |
80 | |
81 ldd #317 Set new X screen location | |
82 std 2,X | |
83 std 6,X | |
84 std PGXLOC | |
85 ldd #169 Set new Y screen location | |
86 std 4,X | |
87 std 8,X | |
88 std PGYLOC | |
89 ldd #3692 Set new array location | |
90 std ,X | |
91 ldb 11,X | |
92 stb PGBFN | |
93 lbra PUTGH | |
94 | |
95 STGH1 subd #69 Move up one space in array | |
96 std ,X Save new array location | |
97 ldd 2,X Get NEW scrn X location | |
98 std 6,X G1XOLD = G1XNEW | |
99 std PGXLOC Put it in PUTGHT string | |
100 ldd 4,X Get NEW scrn Y location | |
101 subd #3 Move up 3 scrn lines | |
102 std 4,X Save new scrn Y location | |
103 std 8,X G1YOLD = G1YNEW | |
104 std PGYLOC Also put it in PUTGHS | |
105 ldb 11,X Get ghost buffer # | |
106 stb PGBFN Put it in PUTGHS string | |
107 lbra PUTGH Go put ghost back on scrn | |
108 * Move ghost left on screen | |
109 LEFT deca Decrement direction flag | |
110 bne RIGHT | |
111 ldd ,X Get ghost array offset | |
112 | |
113 cmpd #1725 Off screen to left ? | |
114 bne STGH2 | |
115 | |
116 pshs X Save X reg. | |
117 | |
118 lda #1 Set for blank ghost | |
119 sta PGBFN | |
120 ldd #37 | |
121 std PGXLOC | |
122 ldd #85 | |
123 std PGYLOC | |
124 lbsr PUTGHT | |
125 | |
126 puls X Restore X reg. | |
127 | |
128 ldd #581 | |
129 std 2,X | |
130 std 6,X | |
131 std PGXLOC | |
132 ldd #1793 | |
133 std ,X | |
134 lda 11,X | |
135 adda #1 | |
136 sta PGBFN | |
137 lbra PUTGH | |
138 | |
139 STGH2 subd #1 Move left 1 space in array | |
140 std ,X Save new array location | |
141 ldd 2,X Get NEW scrn X location | |
142 subd #8 Move 8 pixels left on scrn | |
143 std 2,X Save NEW scrn X location | |
144 std 6,X G1XOLD = G1XNEW | |
145 std PGXLOC Also put it in PUTGHT | |
146 ldd 4,X Get ghost scrn Y location | |
147 std 8,X G1YOLD = G1YNEW | |
148 std PGYLOC Put it in PUTGHT string | |
149 ldb 11,X Get ghost buffer # | |
150 addb #1 Add direction offset | |
151 stb PGBFN Put it in PUTGHT string | |
152 lbra PUTGH Go put ghost back on scrn | |
153 * Move ghost right on screen | |
154 RIGHT deca Decrement direction flag | |
155 bne DOWN | |
156 ldd ,X Get ghost array offset | |
157 | |
158 cmpd #1793 Off screen to right ? | |
159 bne STGH3 If not, continue | |
160 | |
161 pshs X Save X reg. | |
162 | |
163 lda #1 Set for blank ghost | |
164 sta PGBFN | |
165 ldd #581 | |
166 std PGXLOC | |
167 ldd #85 | |
168 std PGYLOC | |
169 lbsr PUTGHT | |
170 | |
171 puls X Restore X reg. | |
172 | |
173 ldd #37 | |
174 std 2,X | |
175 subd #8 | |
176 std 6,X | |
177 std PGXLOC | |
178 ldd #1725 | |
179 std ,X | |
180 lda 11,X | |
181 adda #2 | |
182 sta PGBFN | |
183 lbra PUTGH | |
184 | |
185 STGH3 addd #1 Move 1 space right in array | |
186 std ,X Save new array location | |
187 ldd 6,X Get OLD scrn X location | |
188 cmpd 2,X Compare it to NEW | |
189 beq SKIPRT | |
190 addd #8 Add 8 to it | |
191 std 6,X Save in OLD scrn x location | |
192 SKIPRT ldd 2,X Get NEW scrn X location | |
193 addd #8 Move 8 pixels right on scrn | |
194 std 2,X Save NEW scrn X location | |
195 ldd 6,X Get OLD scrn X location | |
196 std PGXLOC Also put it in PUTGHT | |
197 ldd 4,X Get ghost scrn Y location | |
198 std 8,X G1YOLD = G1YNEW | |
199 std PGYLOC Put it in PUTGHT string | |
200 ldb 11,X Get ghost buffer # | |
201 addb #2 Add direction offset | |
202 stb PGBFN Put it in PUTGHT string | |
203 bra PUTGH Go put ghost back on scrn | |
204 * Move ghost down on screen | |
205 DOWN ldd ,X Get ghost array offset | |
206 cmpd #3692 At bottom of screen? | |
207 bne STGH4 | |
208 | |
209 pshs X Save X reg. | |
210 | |
211 lda #1 | |
212 sta PGBFN | |
213 ldd #317 | |
214 std PGXLOC | |
215 ldd #169 | |
216 std PGYLOC | |
217 lbsr PUTGHT | |
218 | |
219 puls X Restore X reg. | |
220 | |
221 ldd #301 | |
222 std 2,X | |
223 std 6,X | |
224 std PGXLOC | |
225 ldd #07 | |
226 std 8,X | |
227 std PGYLOC | |
228 addd #3 | |
229 std 4,X | |
230 ldd #33 | |
231 std ,X | |
232 ldb 11,X | |
233 addb #3 | |
234 stb PGBFN | |
235 bra PUTGH | |
236 | |
237 STGH4 addd #69 Move 1 line down in array | |
238 std ,X Save new array location | |
239 ldd 8,X Get OLD Y location | |
240 cmpd 4,X Compare it to NEW Y | |
241 beq SKIPDN | |
242 addd #3 Add 3 to it | |
243 std 8,X Put result back in OLD Y | |
244 SKIPDN ldd 4,X Get NEW Y location | |
245 addd #3 Add 3 to it | |
246 std 4,X Put result back in NEW Y | |
247 ldd 8,X Get OLD scrn Y location | |
248 std PGYLOC Also put it in PUTGHT | |
249 ldd 2,X Get ghost scrn X location | |
250 std 6,X G1XOLD = G1XNEW | |
251 std PGXLOC Put it in PUTGHT string | |
252 ldb 11,X Get ghost buffer # | |
253 addb #3 Add direction offset | |
254 stb PGBFN Put it in PUTGHT string | |
255 | |
256 * Before we put ghost back on screen we first | |
257 * check to see if we got pacman, if so, set flag | |
258 * put any dots back on screen that were erased | |
259 * by the ghost when it moved | |
260 | |
261 PUTGH ldd 2,X Get ghost scrn X location | |
262 addd #20 | |
263 cmpd PXNEW Compare to left side of pman | |
264 ble GOLOOK | |
265 ldd PXNEW Get pacman scrn X location | |
266 addd #22 | |
267 cmpd 2,X Compare to left side of ghost | |
268 ble GOLOOK | |
269 ldd 4,X Get ghost scrn Y location | |
270 addd #10 | |
271 cmpd PYNEW Compare to top of pacman | |
272 ble GOLOOK | |
273 ldd PYNEW Get pacman scrn Y location | |
274 addd #10 | |
275 cmpd 4,X Compare to top of ghost | |
276 ble GOLOOK | |
277 | |
278 lda #1 | |
279 sta HITFLG Set HIT FLAG | |
280 ldb 10,X Check status | |
281 cmpb #1 | |
282 beq GOLOOK | |
283 lda #-1 | |
284 sta HITFLG | |
285 lda GCOUNT | |
286 sta GHTHIT | |
287 | |
288 GOLOOK ldd ,X | |
289 cmpd #33 | |
290 ble SKIPDT | |
291 cmpd #3692 | |
292 bge SKIPDT | |
293 bsr LOOK Go look for dots to restore | |
294 cmpa #0 A will be >0 if dot found | |
295 beq SKIPDT Branch if no dot to put back | |
296 sta PDBFN Put dot buff# in PUTDOT | |
297 | |
298 * Put both dot(or pill) and ghost | |
299 * This routine will output both DOTCODE & PUTCODE | |
300 | |
301 leax PUTGHS,U Point to Putghost's rmb's | |
302 ldy #16 8 for dot & 8 for ghost | |
303 lda PATH Set output path | |
304 os9 I$Write Output PUTBLK code | |
305 lbcs ERR1 Branch if any errors | |
306 rts Return to MAIN | |
307 | |
308 SKIPDT lbsr PUTGHT Go put ghost back on screen | |
309 MAINRT rts Return to MAIN | |
310 | |
311 * The following routines look for any dots to | |
312 * replace after ghosts move on. | |
313 | |
314 LOOK leay ARRAY,U Point to start of array | |
315 lda 14,X Get direction flag | |
316 lbeq LOOKDN Ghost moving up, look down | |
317 deca | |
318 lbeq LOOKRT Ghost moving left, look right | |
319 deca | |
320 lbeq LOOKLF Ghost moving right, look left | |
321 * Moving DOWN, so look UP | |
322 LOOKUP ldd ,X Get ghost array offset | |
323 subd #69 Move up 1 space in array | |
324 leay D,Y Point Y reg. here | |
325 ldb ,Y Look at byte there | |
326 lbmi NODOT | |
327 ldb -69,Y Look at byte 1 line up | |
328 lbmi NODOT | |
329 cmpb #1 Check for intersection | |
330 ble LOOKU3 Go look 3 spaces up | |
331 cmpb #3 Is it a power dot? | |
332 bhi POWU2 | |
333 ldd 2,X Get ghost scrn X location | |
334 addd #7 Move right 7 pixels | |
335 std PDXLOC Put result in PUTDOT | |
336 ldd 4,X Get ghost scrn Y location | |
337 subd #3 Move 3 pixel up | |
338 std PDYLOC Put result in PUTDOT | |
339 lda #42 Set flag(Buff# for dot) | |
340 rts Return to PUTGH | |
341 POWU2 ldd 2,X Get ghost scrn X location | |
342 addd #5 | |
343 std PDXLOC Put result in PUTDOT | |
344 ldd 4,X Get ghost scrn Y location | |
345 subd #3 | |
346 std PDYLOC Put result in PUTDOT | |
347 lda #52 Set flag(Buff# for power dot) | |
348 rts Return to PUTGH | |
349 | |
350 LOOKU3 ldb -138,Y Get byte there | |
351 cmpb #1 | |
352 lble NODOT | |
353 cmpb #3 Is it a wall? | |
354 bhi POWU3 | |
355 ldd 2,X Get ghost scrn X location | |
356 addd #7 Add offset to dot location | |
357 std PDXLOC Put result in PUTDOT string | |
358 ldd 4,X Get ghost scrn Y location | |
359 subd #6 Subtract offset | |
360 std PDYLOC Put result in PUTDOT string | |
361 lda #40 Set flag (Also Buff #) | |
362 rts | |
363 | |
364 POWU3 ldd 2,X Get ghost scrn X location | |
365 addd #5 Add offset to dot location | |
366 std PDXLOC Put result in PUTDOT string | |
367 ldd 4,X Get ghost scrn Y location | |
368 subd #6 Subtract offset | |
369 std PDYLOC Put result in PUTDOT string | |
370 lda #50 Set flag (Also Buff #) | |
371 rts | |
372 | |
373 * The following routines are not commented because | |
374 * they are all identical to the LOOKUP routines | |
375 * except for the use of different buffer numbers | |
376 * and different offset values. | |
377 * | |
378 * Moving UP, so look down | |
379 | |
380 LOOKDN ldd ,X | |
381 addd #69 | |
382 leay D,Y | |
383 ldb ,Y | |
384 lbmi NODOT | |
385 ldb 69,Y | |
386 lbmi NODOT | |
387 cmpb #1 | |
388 ble LOOKD3 | |
389 cmpb #3 | |
390 bhi POWD2 | |
391 ldd 2,X | |
392 addd #7 | |
393 std PDXLOC | |
394 ldd 4,X | |
395 addd #9 | |
396 std PDYLOC | |
397 lda #43 | |
398 rts | |
399 | |
400 POWD2 ldd 2,X | |
401 addd #5 | |
402 std PDXLOC | |
403 ldd 4,X | |
404 addd #9 | |
405 std PDYLOC | |
406 lda #53 | |
407 rts | |
408 | |
409 LOOKD3 ldb 138,Y | |
410 cmpb #1 | |
411 lble NODOT | |
412 cmpb #3 | |
413 bhi POWD3 | |
414 ldd 2,X | |
415 addd #7 | |
416 std PDXLOC | |
417 ldd 4,X | |
418 addd #12 | |
419 std PDYLOC | |
420 lda #40 | |
421 rts | |
422 | |
423 POWD3 ldd 2,X | |
424 addd #5 | |
425 std PDXLOC | |
426 ldd 4,X | |
427 addd #12 | |
428 std PDYLOC | |
429 lda #50 | |
430 rts | |
431 | |
432 * Moving LEFT, so look right | |
433 | |
434 LOOKRT ldd ,X | |
435 leay D,Y | |
436 ldb 1,Y | |
437 lbmi NODOT | |
438 ldb 2,Y | |
439 cmpb #1 | |
440 lble NODOT | |
441 cmpb #3 | |
442 bhi POWR2 | |
443 ldd 2,X | |
444 addd #23 | |
445 std PDXLOC | |
446 ldd 4,X | |
447 addd #3 | |
448 std PDYLOC | |
449 lda #40 | |
450 rts | |
451 | |
452 POWR2 cmpb #6 | |
453 beq BONR2 | |
454 ldd 2,X | |
455 addd #21 | |
456 std PDXLOC | |
457 ldd 4,X | |
458 addd #3 | |
459 std PDYLOC | |
460 lda #50 | |
461 rts | |
462 | |
463 BONR2 ldd 2,X | |
464 addd #15 | |
465 std PDXLOC | |
466 ldd 4,X | |
467 addd #1 | |
468 std PDYLOC | |
469 lda BONBUF | |
470 rts | |
471 | |
472 * Moving RIGHT, so look left | |
473 | |
474 LOOKLF ldd ,X | |
475 leay D,Y | |
476 ldb -1,Y | |
477 bmi NODOT | |
478 ldb -2,Y | |
479 cmpb #1 | |
480 ble NODOT | |
481 cmpb #3 | |
482 bhi POWL2 | |
483 ldd 2,X | |
484 subd #9 | |
485 std PDXLOC | |
486 ldd 4,X | |
487 addd #3 | |
488 std PDYLOC | |
489 lda #40 | |
490 rts | |
491 | |
492 POWL2 cmpb #6 | |
493 beq BONL2 | |
494 ldd 2,X | |
495 subd #11 | |
496 std PDXLOC | |
497 ldd 4,X | |
498 addd #3 | |
499 std PDYLOC | |
500 lda #50 | |
501 rts | |
502 | |
503 BONL2 ldd 2,X | |
504 subd #17 | |
505 std PDXLOC | |
506 ldd 4,X | |
507 addd #1 | |
508 std PDYLOC | |
509 lda BONBUF | |
510 rts | |
511 | |
512 * This is the common exit for all the LOOK | |
513 * routines if no dot was found to replace. | |
514 * Clearing the A reg. is a flag for the | |
515 * PUTGH routine to let it know that no dot | |
516 * needs to be put back on the screen | |
517 | |
518 NODOT clra Clear flag | |
519 rts | |
520 | |
521 | |
522 ENDSECT | |
523 | |
524 |