]> github.com/historicalsource and other repositories - mspacman-7800.git/blob - LOADMAP.S
Initial import.
[mspacman-7800.git] / LOADMAP.S
1 \r
2 *  LOADMAP.S      ROUTINES DEALING WITH MAZE MAINTENANCE\r
3 \r
4 *  MAZE DRAWING ROUTINE: CALLED WITH THE NUMBER OF THE DESIRED MAZE IN RACK,\r
5 *  WILL DRAW THE APPROPRIATE MAZE.\r
6 \r
7           ;ZERO PAGE TEMPORARY VARIABLES.\r
8           ; TEMP0-7  : EIGHT BYTE SHIFT REGISTER\r
9           ; TEMP8-9  : POINTER TO MAZE DATA\r
10           ; TEMP10-11: POINTER TO PLAY FIELD (CHARACTER MAP)\r
11           ; TEMP12   : TEMPORARY VALUE STORAGE FOR COMPUTATIONS\r
12           ; TEMP13   : OFFSET TO PLAYFIELD POINTER FOR LEFT HALF OF MAZE\r
13           ; TEMP14   : OFFSET TO PLAYFIELD POINTER FOR RIGHT HALF OF MAZE\r
14           ; TEMP15   : COUNTER TO KEEP TRACK OF CURRENT ROW\r
15 \r
16 LOADMAP   LDA     #$00\r
17           STA     DOTS                   ;INITIALIZE DOT COUNTER\r
18           STA     DOTS+1\r
19 \r
20           LDY     RACK\r
21           LDA     MAZEBEGL,Y\r
22           STA     TEMP8\r
23           LDA     MAZEBEGH,Y\r
24           STA     TEMP8+1\r
25 \r
26           LDA     #0\r
27           STA     TEMP13\r
28           LDA     #WIDTH-1\r
29           STA     TEMP14\r
30 \r
31           JSR     LDSHFTL\r
32 \r
33 NEXTCOL   JSR     LDSHFTH\r
34 \r
35           LDA     #L(SCREEN)\r
36           STA     TEMP10\r
37           LDA     #H(SCREEN)\r
38           STA     TEMP10+1\r
39 \r
40           LDA     #HEIGHT\r
41           STA     TEMP15\r
42 \r
43 NEXTROW   LDA     TEMP0+0\r
44           AND     #$03\r
45           STA     TEMP12\r
46           LDA     TEMP0+4\r
47           ASL     A\r
48           ASL     A\r
49           AND     #$0C\r
50           ORA     TEMP12\r
51           TAX\r
52 \r
53           LDA     TEMP13\r
54           CMP     #10\r
55           BCC     NOTPEN\r
56           LDA     TEMP15\r
57           SBC     #15\r
58           CMP     #5\r
59           BCS     NOTPEN\r
60 \r
61 ;PEN\r
62           TXA\r
63           ADC     #$10\r
64           TAX\r
65 \r
66 NOTPEN\r
67 ;NORMAL PLAYFIELD\r
68           TXA                            ;SEE IF SHOULD BE AN EMPTY CHARACTER\r
69           CMP     #$0F                   ;  NEAR THE BORDER INSTEAD OF FULL\r
70           BNE     DOCHAR\r
71           LDA     TEMP13\r
72           CMP     #$03\r
73           BPL     DOCHAR\r
74           LDX     #$00                   ;IT SHOULD BE EMPTY\r
75 \r
76 DOCHAR    LDA     LEFT,X\r
77           LDY     TEMP13\r
78           STA     (TEMP10),Y\r
79           LDA     RIGHT,X\r
80           LDY     TEMP14\r
81           STA     (TEMP10),Y\r
82 \r
83           JSR     SHIFT\r
84 \r
85           CLC\r
86           LDA     TEMP10\r
87           ADC     #WIDTH\r
88           STA     TEMP10\r
89           BCC     NOINC\r
90           INC     TEMP10+1\r
91 \r
92 NOINC     DEC     TEMP15\r
93           BNE     NEXTROW\r
94 \r
95           INC     TEMP13\r
96           DEC     TEMP14\r
97           LDA     TEMP13\r
98           CMP     TEMP14\r
99           BCS     LOADDONE\r
100           JSR     SHIFT\r
101           JSR     SHIFT\r
102           JMP     NEXTCOL\r
103 \r
104 SHIFT     LDX     #$07\r
105           LSR     TEMP0+7\r
106 SHIFT1    ROR     TEMP0-1,X\r
107           DEX\r
108           BNE     SHIFT1\r
109           RTS\r
110 \r
111 LOADDONE  LDA     #DOORCHAR              ;PEN ENTRANCE CHARACTER\r
112           STA     SCREEN+28*11+13        ;ENTRANCE AT 11TH ROW, 13TH COLUMN\r
113           STA     SCREEN+28*11+14        ; AND 11TH ROW, 14TH COLUMN.\r
114 \r
115 *  THIS CODE TAKES CARE OF PUTTING UP THE DOTS\r
116           LDA     #$00                   ;INITIALIZE EVERYTHING TO ZERO\r
117           TAY\r
118           STA     TEMP0\r
119           STA     TEMP1\r
120 \r
121 LMDLOOP   LDA     DOTARRAY,Y             ;GET NEW SET OF DOT BITS\r
122           STA     TEMP15\r
123           JSR     LMDOTS                 ;DO EACH OF THE 8 BITS\r
124           JSR     LMDOTS\r
125           JSR     LMDOTS\r
126           JSR     LMDOTS\r
127           JSR     LMDOTS\r
128           JSR     LMDOTS\r
129           JSR     LMDOTS\r
130           JSR     LMDOTS\r
131           INY\r
132           CPY     #$78\r
133           BNE     LMDLOOP\r
134 \r
135 *  AND FINALLY - DO THE POWER DOTS\r
136           LDY     RACK                   ;GET THE RACK\r
137           LDA     EDZONE0,Y\r
138           STA     TEMP0\r
139           LDA     EDCOL0,Y\r
140           STA     TEMP1\r
141           JSR     LMEDOTS                ;ZONE 0 COLUMN 0\r
142           LDA     EDCOL1,Y\r
143           STA     TEMP1\r
144           JSR     LMEDOTS                ;ZONE 0 COLUMN 1\r
145           LDA     EDZONE1,Y\r
146           STA     TEMP0\r
147           JSR     LMEDOTS                ;ZONE 1 COLUMN 1\r
148           LDA     EDCOL0,Y\r
149           STA     TEMP1\r
150           JSR     LMEDOTS                ;ZONE 1 COLUMN 0\r
151 \r
152           RTS\r
153 \r
154 \r
155 *  THIS ROUTINE CHECKS FOR A PARTICULAR POWER DOT\r
156 LMEDOTS   JSR     GETCHAR                ;SEE WHAT'S THERE\r
157           CMP     #DOTCHAR               ;IS IT A DOT?\r
158           BNE     LMEDOUT\r
159           LDX     #EDOTCHAR              ;PUT AN EDOT DOWN\r
160           JSR     PLOPCHAR\r
161 LMEDOUT   RTS\r
162 \r
163 \r
164 *  THIS ROUTINE LOADS IN A PARTICULAR DOT\r
165 LMDOTS    ASL     TEMP15                 ;GET A BIT OFF\r
166           BCC     LMDINC                 ;SEE IF A DOT HERE\r
167           LDX     #DOTCHAR               ;DOT HERE\r
168           JSR     PLOPCHAR               ;PUT IT IN\r
169           INC     DOTS                   ;ADD IT TO THE DOT COUNTER\r
170           BNE     LMDINC\r
171           INC     DOTS+1\r
172 LMDINC    JMP     NEXTPLOP               ;INCREMENT COLUMN\r
173 \r
174 \r
175 LEFT      DB    $50,$30,$31,$32,$33,$34,$50,$35,$36,$50,$37,$38,$39,$3A,$3B,$3C\r
176 PLEFT     DB    $50,$3E,$3F,$40,$41,$42,$50,$50,$43,$50,$44,$50,$45,$50,$50,$50\r
177 RIGHT     DB    $50,$33,$36,$39,$30,$34,$50,$3A,$31,$50,$37,$3B,$32,$35,$38,$3C\r
178 PRIGHT    DB    $50,$41,$43,$45,$3E,$42,$50,$50,$3F,$50,$44,$50,$40,$50,$50,$50\r
179 \r
180 LDSHFTL   LDX     #$03\r
181           BNE     LDSHFT1\r
182 LDSHFTH   LDX     #$07\r
183 LDSHFT1   LDY     #$03\r
184 LDSHFT2   LDA     (TEMP8),Y\r
185           STA     TEMP0,X\r
186           DEX\r
187           DEY\r
188           BPL     LDSHFT2\r
189           CLC\r
190           LDA     TEMP8\r
191           ADC     #$04\r
192           STA     TEMP8\r
193           BCC     LDSHFT3\r
194           INC     TEMP8+1\r
195 LDSHFT3   RTS\r
196 \r
197 \r
198 ; <=======================================================================>\r
199 \r
200 *  THIS ROUTINE LOADS IN THE DOTS FOR A NEW RACK INTO DOTARRAY\r
201 *  USES:  TEMP0-1, X\r
202 LOADDOTS  LDX     RACK                   ;SET UP FOR TRANSFER\r
203           LDA     DOTBEGL,X\r
204           STA     TEMP0\r
205           LDA     DOTBEGH,X\r
206           STA     TEMP1\r
207 \r
208           LDY     #$7F\r
209 LDDLOOP   LDA     (TEMP0),Y              ;AND MOVE THEM\r
210           STA     DOTARRAY,Y\r
211           DEY\r
212           BPL     LDDLOOP\r
213           RTS\r
214 \r
215 \r
216 ; <=======================================================================>\r
217 \r
218 *  THIS ROUTINE USES THE CHARACTER MAP IN SCREEN TO UPDATE THE INFORMATION\r
219 *  IN DOTARRAY.\r
220 SAVEDOTS  LDA     #$00                   ;INITIALIZE EVERYTHING TO ZERO\r
221           TAY\r
222           STA     TEMP0\r
223           STA     TEMP1\r
224 \r
225 SDLOOP    JSR     SDDOTS                 ;DO EACH OF THE 8 BITS\r
226           JSR     SDDOTS\r
227           JSR     SDDOTS\r
228           JSR     SDDOTS\r
229           JSR     SDDOTS\r
230           JSR     SDDOTS\r
231           JSR     SDDOTS\r
232           JSR     SDDOTS\r
233           LDA     TEMP15\r
234           STA     DOTARRAY,Y\r
235           INY\r
236           CPY     #$78\r
237           BNE     SDLOOP\r
238           RTS\r
239 \r
240 \r
241 *  THIS ROUTINE CHECKS FOR A PARTICULAR DOT\r
242 SDDOTS    LDA     TEMP1                  ;SEE IF OUT OF RANGE\r
243           CMP     #$1C\r
244           BPL     SDNODOTS\r
245           JSR     GETCHAR                ;FIND OUT WHAT IS HERE\r
246           CMP     #DOTCHAR\r
247           BMI     SDNODOTS\r
248           SEC                            ;SHIFT IN A 1\r
249           JMP     SDDOIT\r
250 SDNODOTS  CLC                            ;SHIFT IN A 0\r
251 SDDOIT    ROL     TEMP15\r
252 \r
253 *  THIS ROUTINE INCREMENTS THE COLUMN FOR ROUTINES USING PUT/PLOPCHAR\r
254 NEXTPLOP  INC     TEMP1                  ;NEXT COLUMN\r
255           LDA     TEMP1\r
256           CMP     #$20\r
257           BMI     NCOUT\r
258           LDA     #$00                   ;NEXT ZONE\r
259           STA     TEMP1\r
260           INC     TEMP0\r
261 NCOUT     RTS\r
262 \r
263 ; <=======================================================================>\r
264 \r
265 ;TABLES OF POINTERS TO TABLES...\r
266 \r
267 MAZEBEGL  DB      L(MAZE1),L(MAZE2),L(MAZE3),L(MAZE4)\r
268 MAZEBEGH  DB      H(MAZE1),H(MAZE2),H(MAZE3),H(MAZE4)\r
269 \r
270 DOTBEGL   DB      L(DOT1),L(DOT2),L(DOT3),L(DOT4)\r
271 DOTBEGH   DB      H(DOT1),H(DOT2),H(DOT3),H(DOT4)\r
272 \r
273 ; <=======================================================================>\r
274 \r
275 MAZE1     DB      $7F,$FE,$FC,$7F,$41,$FE,$3C,$40,$41,$FE,$3C,$40\r
276           DB      $09,$00,$00,$4F,$09,$00,$00,$4F,$C9,$F3,$24,$4F\r
277           DB      $01,$12,$24,$40,$01,$12,$24,$40,$4F,$92,$27,$4F\r
278           DB      $41,$00,$04,$41,$41,$00,$04,$41,$49,$F2,$24,$49\r
279           DB      $09,$F2,$20,$48,$09,$F2,$20,$48,$C9,$F3,$3C,$4F\r
280 \r
281 DOT1      DB      $00,$00,$00,$00,$7E,$7F,$E7,$E0\r
282           DB      $42,$40,$24,$20,$42,$40,$24,$20\r
283           DB      $7F,$FF,$FF,$E0,$12,$09,$04,$80\r
284           DB      $12,$09,$04,$80,$13,$F9,$FC,$80\r
285           DB      $10,$00,$00,$80,$10,$00,$00,$80\r
286           DB      $10,$00,$00,$80,$10,$00,$00,$80\r
287           DB      $10,$00,$00,$80,$10,$00,$00,$80\r
288           DB      $10,$00,$00,$80,$10,$00,$00,$80\r
289           DB      $10,$00,$00,$80,$10,$00,$00,$80\r
290           DB      $10,$00,$00,$80,$1F,$C0,$3F,$80\r
291           DB      $10,$40,$20,$80,$10,$40,$20,$80\r
292           DB      $7F,$F9,$FF,$E0,$42,$09,$04,$20\r
293           DB      $42,$09,$04,$20,$42,$79,$E4,$20\r
294           DB      $42,$40,$24,$20,$42,$40,$24,$20\r
295           DB      $7F,$FF,$FF,$E0,$00,$00,$00,$00\r
296 \r
297 ; <=======================================================================>\r
298 \r
299 MAZE2     DB      $F9,$FF,$3F,$7F,$09,$10,$3C,$41,$09,$10,$3C,$41\r
300           DB      $C9,$93,$00,$48,$49,$90,$00,$48,$49,$90,$27,$4F\r
301           DB      $41,$02,$20,$40,$41,$02,$20,$40,$4F,$3E,$E7,$49\r
302           DB      $01,$00,$24,$48,$01,$00,$24,$48,$C9,$F3,$00,$49\r
303           DB      $09,$F2,$00,$41,$09,$F2,$3C,$41,$79,$F2,$3C,$4F\r
304 \r
305 DOT2      DB      $00,$00,$00,$00,$00,$7F,$E0,$00\r
306           DB      $00,$40,$20,$00,$00,$40,$20,$00\r
307           DB      $7F,$F9,$FF,$E0,$40,$49,$20,$20\r
308           DB      $40,$49,$20,$20,$4F,$CF,$3F,$20\r
309           DB      $48,$00,$01,$20,$48,$00,$01,$20\r
310           DB      $7E,$00,$07,$E0,$02,$00,$04,$00\r
311           DB      $02,$00,$04,$00,$7E,$00,$07,$E0\r
312           DB      $42,$00,$04,$20,$42,$00,$04,$20\r
313           DB      $72,$00,$04,$E0,$12,$00,$04,$80\r
314           DB      $12,$00,$04,$80,$1F,$F0,$FF,$80\r
315           DB      $10,$10,$80,$80,$10,$10,$80,$80\r
316           DB      $1E,$70,$E7,$80,$12,$40,$24,$80\r
317           DB      $12,$40,$24,$80,$73,$F9,$FC,$E0\r
318           DB      $42,$09,$04,$20,$42,$09,$04,$20\r
319           DB      $7F,$FF,$FF,$E0,$00,$00,$00,$00\r
320 \r
321 ; <=======================================================================>\r
322 \r
323 MAZE3     DB      $FF,$FC,$FF,$7F\r
324           DB      $81,$00,$20,$40\r
325           DB      $81,$00,$20,$40\r
326           DB      $99,$9C,$07,$49\r
327           DB      $09,$10,$04,$49\r
328           DB      $09,$10,$E4,$49\r
329           DB      $C9,$83,$00,$40\r
330           DB      $09,$82,$00,$40\r
331           DB      $09,$F2,$3C,$7F\r
332           DB      $41,$00,$04,$41\r
333           DB      $41,$00,$04,$41\r
334           DB      $4F,$F2,$24,$49\r
335           DB      $01,$F2,$20,$48\r
336           DB      $01,$F2,$20,$48\r
337           DB      $79,$F2,$3C,$4F\r
338 \r
339 DOT3      DB      $00,$00,$00,$00,$7F,$CF,$3F,$E0\r
340           DB      $40,$49,$20,$20,$40,$49,$20,$20\r
341           DB      $4F,$F9,$FF,$20,$79,$09,$09,$E0\r
342           DB      $09,$09,$09,$00,$09,$FF,$F9,$00\r
343           DB      $78,$00,$01,$E0,$40,$00,$00,$20\r
344           DB      $40,$00,$00,$20,$40,$00,$00,$20\r
345           DB      $40,$00,$00,$20,$40,$00,$00,$20\r
346           DB      $40,$00,$00,$20,$40,$00,$00,$20\r
347           DB      $40,$00,$00,$20,$40,$00,$00,$20\r
348           DB      $40,$00,$00,$20,$7E,$79,$E7,$E0\r
349           DB      $12,$40,$24,$80,$12,$40,$24,$80\r
350           DB      $73,$F9,$FC,$E0,$42,$09,$04,$20\r
351           DB      $42,$09,$04,$20,$7E,$79,$E7,$E0\r
352           DB      $42,$40,$24,$20,$42,$40,$24,$20\r
353           DB      $7E,$7F,$E7,$E0,$00,$00,$00,$00\r
354 \r
355 ; <=======================================================================>\r
356 \r
357 MAZE4     DB      $FF,$4F,$FE,$7F\r
358           DB      $01,$4E,$3E,$40\r
359           DB      $01,$4E,$3E,$40\r
360           DB      $79,$40,$00,$4F\r
361           DB      $41,$40,$00,$41\r
362           DB      $41,$F2,$39,$41\r
363           DB      $09,$02,$20,$48\r
364           DB      $09,$02,$20,$48\r
365           DB      $C9,$9F,$27,$4F\r
366           DB      $01,$02,$04,$48\r
367           DB      $01,$02,$04,$48\r
368           DB      $79,$F2,$E4,$49\r
369           DB      $09,$F0,$00,$41\r
370           DB      $09,$F0,$00,$41\r
371           DB      $C9,$F3,$3C,$79\r
372 \r
373 DOT4      DB      $00,$00,$00,$00,$7F,$FF,$FF,$E0\r
374           DB      $48,$40,$21,$20,$48,$40,$21,$20\r
375           DB      $4F,$CF,$3F,$20,$42,$49,$24,$20\r
376           DB      $42,$49,$24,$20,$7E,$79,$E7,$E0\r
377           DB      $10,$00,$00,$80,$10,$00,$00,$80\r
378           DB      $1E,$00,$07,$80,$02,$00,$04,$00\r
379           DB      $02,$00,$04,$00,$02,$00,$04,$00\r
380           DB      $02,$00,$04,$00,$02,$00,$04,$00\r
381           DB      $02,$00,$04,$00,$1E,$00,$07,$80\r
382           DB      $12,$00,$04,$80,$13,$C0,$3C,$80\r
383           DB      $10,$40,$20,$80,$10,$40,$20,$80\r
384           DB      $7F,$C0,$3F,$E0,$42,$40,$24,$20\r
385           DB      $42,$40,$24,$20,$4E,$7F,$E7,$20\r
386           DB      $48,$09,$01,$20,$48,$09,$01,$20\r
387           DB      $7F,$F9,$FF,$E0,$00,$00,$00,$00\r
388 \r
389 ; <=======================================================================>\r
390 \r
391           ;CONSTANT VALUES FOR MS.PACMAN\r
392 WIDTH     EQU     28\r
393 HEIGHT    EQU     30\r
394 \r
395 *  ZONES AND COLUMNS FOR THE ENERGY DOTS - INDEXED BY RACK\r
396 EDZONE0   DB      $03,$04,$03,$03\r
397 EDZONE1   DB      $19,$19,$16,$1A\r
398 EDCOL0    DB      $01,$01,$01,$01\r
399 EDCOL1    DB      $1A,$1A,$1A,$1A\r
400 \r