Initial import. master
authorSimon Morgan <sjm@sjm.io>
Fri, 26 Jun 2015 17:05:39 +0000 (18:05 +0100)
committerSimon Morgan <sjm@sjm.io>
Fri, 26 Jun 2015 17:05:39 +0000 (18:05 +0100)
25 files changed:
ANIMATE.S [new file with mode: 0644]
END.S [new file with mode: 0644]
FRUIT.S [new file with mode: 0644]
GETJOY.S [new file with mode: 0644]
HIGH.S [new file with mode: 0644]
INIT.S [new file with mode: 0644]
INTRSECT.S [new file with mode: 0644]
KERNAL.S [new file with mode: 0644]
LOADMAP.S [new file with mode: 0644]
MACRO.S [new file with mode: 0644]
MAIN.S [new file with mode: 0644]
MARIAOS.S [new file with mode: 0644]
MDOIT.S [new file with mode: 0644]
MGET.S [new file with mode: 0644]
MONSTER.S [new file with mode: 0644]
MSCHAR.S [new file with mode: 0644]
MSDEF.S [new file with mode: 0644]
MSMOVE.S [new file with mode: 0644]
MUP.S [new file with mode: 0644]
PATH.S [new file with mode: 0644]
PUTCHAR.S [new file with mode: 0644]
SPEED.S [new file with mode: 0644]
TITLE.S [new file with mode: 0644]
TUNES.S [new file with mode: 0644]
UTIL.S [new file with mode: 0644]

diff --git a/ANIMATE.S b/ANIMATE.S
new file mode 100644 (file)
index 0000000..2433304
--- /dev/null
+++ b/ANIMATE.S
@@ -0,0 +1,537 @@
+\r
+*  ANIMATE.S      THE MS PAC MAN ANIMATIONS\r
+\r
+\r
+*  START THE ANIMATIONS\r
+ANIMATE   STA     ANWHICH                ;STORE WHICH ANIMATION\r
+          JSR     CLEARTUN\r
+          JSR     CLRSCRN                ;TURN OFF INDICATORS\r
+          PFILL   SCREEN,#$00,#$04       ;ERASE SCREEN\r
+*         JSR     LOADDLST               ;RE-LOAD DISPLAY LIST\r
+\r
+          LDA     #WHITE                 ;SET UP COLOR FOR WORDS\r
+          LDY     #$18\r
+ANLOOP0   STA     P0C3,Y\r
+          DEY\r
+          DEY\r
+          DEY\r
+          DEY\r
+          BPL     ANLOOP0\r
+          JSR     BARSOFF                ;GET BLACK BARS OFF THE SCREEN\r
+\r
+          JSR     ANITUNE                ;START TUNE\r
+          JSR     ANIWORDS               ;PUT UP ACT\r
+\r
+          PFILL   SCREEN,#$00,#$04       ;ERASE SCREEN\r
+\r
+          LDX     ANWHICH\r
+          LDA     ANASTART,X             ;GET OFFSET INTO ANIMATION DATA\r
+          STA     ANAOFF\r
+          LDA     ANSSTART,X             ;GET OFFSET INTO SEGMENT DATA\r
+          STA     ANSOFF\r
+          LDA     ANFRAMES,X             ;GET NUMBER OF FRAMES PER TIC\r
+          STA     ANFRM\r
+          JSR     ANINEXT                ;DO ANIMATION\r
+\r
+ABOGLOOP  JSR     SEEBNORM\r
+          LDA     TUNON                  ;MAKE SURE TUNE OVER\r
+          BNE     ABOGLOOP\r
+\r
+          RTS\r
+\r
+\r
+*  START THE ANIMATION TUNE\r
+ANITUNE   LDX     ANWHICH\r
+          LDA     TUNE1,X\r
+          JSR     DOTUNE\r
+          LDA     TUNE2,X\r
+          JMP     DOTUNE\r
+\r
+\r
+*  PUT THE INITIAL MESSAGE UP\r
+ANIWORDS  LDA     ANWHICH\r
+          CLC\r
+          ADC     #$1B\r
+          TAY\r
+          JSR     WRTMESG                ;WRITE THE ACT NUMBER\r
+\r
+          LDA     ANWHICH\r
+          CLC\r
+          ADC     #$1E\r
+          TAY\r
+          JSR     WRTMESG                ;WRITE THE MESSAGE\r
+\r
+          LDX     #$02                   ;SET UP BASE OF CLAPBOARD\r
+AWLOOP2   LDA     ACTBASH,X\r
+          STA     HPLIST+3,X\r
+          LDA     ACTBASV,X\r
+          JSR     VTOZO\r
+          STA     VOLIST+3,X\r
+          TYA\r
+          STA     VZLIST+3,X\r
+          LDA     ACTBASSL,X\r
+          STA     SLLIST+3,X\r
+          LDA     ACTBASSH,X\r
+          STA     SHLIST+3,X\r
+          STA     DOLIST+3,X\r
+          DEX\r
+          BPL     AWLOOP2\r
+\r
+          JSR     AWUPSTMP               ;WRITE UP CLAPBOARD\r
+          LDA     #$40                   ;DO A LITTLE WAIT\r
+          JSR     AWWAIT\r
+\r
+          JSR     AWDNSTMP               ;WRITE DOWN CLAPBOARD\r
+          LDA     #$10                   ;DO A LITTLE WAIT\r
+          JSR     AWWAIT\r
+\r
+          JSR     AWUPSTMP               ;WRITE UP CLAPBOARD\r
+          LDA     #$30                   ;DO A LITTLE WAIT\r
+          JSR     AWWAIT\r
+\r
+          RTS\r
+\r
+*  WAIT A BIT - VALUE OF RTLOCAL+1 IN A\r
+AWWAIT    CLC                            ;ADD IT TO PRESENT TIME\r
+          ADC     RTLOCAL+1\r
+          STA     TEMP16\r
+AWWLOOP   JSR     SEEBNORM               ;SEE IF ANYTHING TO DO\r
+          LDA     TEMP16                 ;SEE IF DONE YET\r
+          CMP     RTLOCAL+1\r
+          BPL     AWWLOOP\r
+          RTS\r
+\r
+\r
+*  SET UP STAMPS FOR UP CLAPBOARD\r
+AWUPSTMP  LDX     #$02                   ;SET UP BASE OF CLAPBOARD\r
+AULOOP    LDA     ACTUPH,X\r
+          STA     HPLIST,X\r
+          LDA     ACTUPV,X\r
+          JSR     VTOZO\r
+          STA     VOLIST,X\r
+          TYA\r
+          STA     VZLIST,X\r
+          LDA     ACTUPSL,X\r
+          STA     SLLIST,X\r
+          LDA     ACTUPSH,X\r
+          STA     SHLIST,X\r
+          STA     DOLIST,X\r
+          DEX\r
+          BPL     AULOOP\r
+          RTS\r
+\r
+\r
+*  SET UP STAMPS FOR DOWN CLAPBOARD\r
+AWDNSTMP  LDX     #$02                   ;SET UP BASE OF CLAPBOARD\r
+ADLOOP    LDA     ACTDNH,X\r
+          STA     HPLIST,X\r
+          LDA     ACTDNV,X\r
+          JSR     VTOZO\r
+          STA     VOLIST,X\r
+          TYA\r
+          STA     VZLIST,X\r
+          LDA     ACTDNSL,X\r
+          STA     SLLIST,X\r
+          LDA     ACTDNSH,X\r
+          STA     SHLIST,X\r
+          STA     DOLIST,X\r
+          DEX\r
+          BPL     ADLOOP\r
+          RTS\r
+\r
+\r
+* SET UP THE STATE FOR AN ANIMATION SEGMENT AND DO IT\r
+ANINEXT   JSR     ANICLEAR               ;CLEAR THE OLD ANIMATIONS\r
+          LDX     ANAOFF                 ;LOAD IN A SET OF ANIMATIONS\r
+          INC     ANAOFF\r
+          LDA     ANCHARS,X              ;NUMBER TO SET UP THIS TIME\r
+          BNE     ANCONT\r
+          RTS                            ;ALL DONE\r
+\r
+ANCONT    STA     TEMP0\r
+          LDA     ANTICS,X               ;SEE HOW MANY TICS TILL NEXT SEGMENT\r
+          STA     ANCOUNT\r
+          LDA     #$00                   ;WILL USE ANSTATE FOR WHICH CHAR SLOT\r
+          STA     ANSTATE\r
+\r
+ANLOOP    LDY     ANSOFF                 ;Y IS OFFSET INTO SEGMENT DATA\r
+          LDX     ANSTATE                ;X IS WHAT CHARACTER SLOT WE DEAL WITH\r
+          LDA     #$01\r
+          STA     A0ENABLE,X             ;TURN THIS ONE ON\r
+          LDA     ANIHPOS,Y              ;STORE THE STAMP INFO\r
+          BEQ     ANLJMP0                ;IF 0 - LEAVE CURRENT HPOS\r
+          STA     HPLIST,X\r
+ANLJMP0   LDA     ANIVPOS,Y\r
+          BEQ     ANLJMP1                ;IF 0 - LEAVE CURRENT VPOS\r
+          STA     A0VPOS,X               ;STORE VPOS\r
+ANLJMP1   LDA     ANICHAR,Y              ;STORE STARTING CHARACTER\r
+          STA     A0CHAR,X\r
+          LDA     ANIHPDIF,Y             ;STORE WHERE DELTAS TO POSITION ARE\r
+          STA     A0HPDIF,X\r
+          LDA     ANIVPDIF,Y\r
+          STA     A0VPDIF,X\r
+          LDA     ANIANDIF,Y             ;AND ANIMATION SEQUENCE\r
+          STA     A0ANDIF,X\r
+          LDA     ANIPALET,Y             ;SET COLORS\r
+          TAY                            ;Y IS NOW OFFSET INTO PALETTE INFO\r
+          TXA                            ;SET X TO 4*CHAR NUMBER\r
+          ASL     A                      ;  THUS, INDEX INTO PALETTES\r
+          ASL     A\r
+          TAX\r
+          LDA     ANPALET1,Y\r
+          STA     P1C1,X\r
+          LDA     ANPALET2,Y\r
+          STA     P1C2,X\r
+          LDA     ANPALET3,Y\r
+          STA     P1C3,X\r
+\r
+          INC     ANSTATE                ;UPDATE STATE VARIABLES\r
+          INC     ANSOFF\r
+          DEC     TEMP0\r
+          BNE     ANLOOP\r
+\r
+          JSR     CHRCLEAR               ;CLEAR SCREEN\r
+          LDA     #$07\r
+          STA     ANSTATE                ;THIS WILL NOW BE 7,6,5,4,3,2,1,0,7,...\r
+\r
+\r
+* MAIN LOOP FOR THE CURRENT ANIMATION\r
+ANIDOIT   JSR     ANIMOVE                ;MOVE THEM ALL\r
+          LDA     RTLOCAL+1              ;WAIT FOR A BIT\r
+          CLC\r
+          ADC     ANFRM\r
+          STA     TEMP16\r
+ADWLOOP   JSR     SEEBNORM               ;SEE IF ANY BUTTONS HIT\r
+          LDA     TEMP16                 ;SEE IF WAIT OVER YET\r
+          CMP     RTLOCAL+1\r
+          BNE     ADWLOOP\r
+\r
+          DEC     ANCOUNT\r
+          BNE     ANIDOIT\r
+          JMP     ANINEXT                ;TIME FOR NEXT READ\r
+\r
+\r
+*  MOVE THE ANIMATION CHARACTERS\r
+ANIMOVE   LDX     #$05                   ;MOVE THEM ALL\r
+ANMLOOP   LDA     A0ENABLE,X\r
+          BEQ     ANMNEXT\r
+          JSR     ANIDISP                ;SHOW THE ANIMATION\r
+ANMNEXT   DEX\r
+          BPL     ANMLOOP\r
+\r
+          LDX     #$05                   ;SET UP FOR WHICHEVER LOOP\r
+          DEC     ANSTATE                ;NEXT STATE\r
+          BPL     ANMINC                 ;SEE IF WRAP\r
+\r
+          LDA     ANSTATE                ;WRAP - GET ANSTATE BACK AGAIN\r
+          AND     #$07\r
+          STA     ANSTATE\r
+ANMWLOOP  LDA     A0HPDIF,X              ;AND WRAP THE OFFSETS BACK AGAIN\r
+          SEC\r
+          SBC     #$07\r
+          STA     A0HPDIF,X\r
+          LDA     A0VPDIF,X\r
+          SEC\r
+          SBC     #$07\r
+          STA     A0VPDIF,X\r
+          LDA     A0ANDIF,X\r
+          SEC\r
+          SBC     #$07\r
+          STA     A0ANDIF,X\r
+          DEX\r
+          BPL     ANMWLOOP\r
+          RTS\r
+\r
+ANMINC    INC     A0HPDIF,X              ;INCREMENT OUR OFFSETS\r
+          INC     A0VPDIF,X\r
+          INC     A0ANDIF,X\r
+          DEX\r
+          BPL     ANMINC\r
+          RTS\r
+\r
+\r
+*  THIS ROUTINE MOVES A SINGLE ANIMATION FIGURE.  THE CHARACTER IS IN X, THIS\r
+*  MUST BE PRESERVED\r
+ANIDISP   LDA     HPLIST,X               ;MODIFY HPOS\r
+          LDY     A0HPDIF,X              ;INDEX FOR MODIFICATION\r
+          CLC\r
+          ADC     ANHPMOVE,Y             ;MODIFICATION\r
+          STA     HPLIST,X\r
+\r
+          LDA     A0VPOS,X               ;MODIFY VPOS\r
+          LDY     A0VPDIF,X              ;INDEX FOR MODIFICATION\r
+          CLC\r
+          ADC     ANVPMOVE,Y             ;MODIFICATION\r
+          STA     A0VPOS,X\r
+          JSR     VTOZO                  ;CONVERT IT TO ZONE AND COLUMN\r
+          STA     VOLIST,X\r
+          TYA\r
+          STA     VZLIST,X\r
+\r
+          LDA     A0CHAR,X               ;MODIFY CHAR\r
+          LDY     A0ANDIF,X              ;INDEX FOR MODIFICATION\r
+          CLC\r
+          ADC     ANANMOVE,Y             ;MODIFICATION\r
+          STA     A0CHAR,X\r
+\r
+          TAY                            ;GET THE NEW STAMP\r
+          LDA     #L(MSCHAR)             ;OFFSET FROM THE BASE OF MSCHAR\r
+          CLC\r
+          ADC     CHAROFFL,Y\r
+          STA     SLLIST,X\r
+          LDA     #H(MSCHAR)\r
+          ADC     CHAROFFH,Y\r
+          STA     SHLIST,X\r
+          STA     DOLIST,X               ;AND TELL LOADER TO DISPLAY IT\r
+          RTS\r
+\r
+\r
+*  CLEAR OUT THE ANIMATION THINGS\r
+ANICLEAR  LDY     #$05\r
+          LDA     #$00\r
+ACLOOP    STA     A0ENABLE,Y\r
+          DEY\r
+          BPL     ACLOOP\r
+          RTS\r
+\r
+\r
+*  CLEAR OUT THE CHARACTER THINGS\r
+CHRCLEAR  LDY     #$05\r
+          LDA     #OFFSCRN\r
+CCLOOP    LDX     A0ENABLE,Y\r
+          BNE     CCNEXT\r
+          STA     HPLIST,Y\r
+          STA     DOLIST,Y\r
+CCNEXT    DEY\r
+          BPL     CCLOOP\r
+          RTS\r
+\r
+\r
+*  TUNES FOR THE ANIMATIONS\r
+TUNE1     DB      2,4,8\r
+TUNE2     DB      3,6,9\r
+\r
+*  TABLES FOR POSITIONS OF CLAPBOARD STAMPS\r
+ACTBASH                                  ;HORIZONTAL POSITIONS\r
+ACTUPH\r
+ACTDNH    DB      $0E+LEFTSIDE,$16+LEFTSIDE,$1E+LEFTSIDE\r
+ACTBASV   DB      $55,$55,$55            ;VERTICAL POSITONS\r
+ACTUPV    DB      $4A,$42,$3A\r
+ACTDNV    DB      $51,$51,$51\r
+ACTBASSL  DB      L(CLAPBRD),L(CLAPBRD+24),L(CLAPBRD+48)    ;STAMP LOW BYTE\r
+ACTUPSL   DB      L(CLAPBRDU),L(CLAPBRDU+24),L(CLAPBRDU+48)\r
+ACTDNSL   DB      L(CLAPBRDD),L(CLAPBRDD+24),L(CLAPBRDD+48)\r
+ACTBASSH  DB      H(CLAPBRD),H(CLAPBRD+24),H(CLAPBRD+48)    ;STAMP HI BYTE\r
+ACTUPSH   DB      H(CLAPBRDU),H(CLAPBRDU+24),H(CLAPBRDU+48)\r
+ACTDNSH   DB      H(CLAPBRDD),H(CLAPBRDD+24),H(CLAPBRDD+48)\r
+\r
+\r
+*  OFFSET TABLES FROM CHARACTER INDEX TO OFFSET\r
+CHAROFFL  DB      $00,$18,$30,$48,$60,$78,$90,$A8\r
+          DB      $C0,$D8,$F0,$08,$20,$38,$50,$68\r
+          DB      $80,$98,$B0,$C8,$E0,$F8,$10,$28\r
+          DB      $40,$58,$70,$88,$A0,$B8,$D0,$E8\r
+          DB      $00,$18,$30,$48,$60,$78,$90,$A8\r
+          DB      $C0,$D8,$F0,$08,$20,$38,$50,$68\r
+CHAROFFH  DB      $00,$00,$00,$00,$00,$00,$00,$00\r
+          DB      $00,$00,$00,$01,$01,$01,$01,$01\r
+          DB      $01,$01,$01,$01,$01,$01,$02,$02\r
+          DB      $02,$02,$02,$02,$02,$02,$02,$02\r
+          DB      $03,$03,$03,$03,$03,$03,$03,$03\r
+          DB      $03,$03,$03,$04,$04,$04,$04,$04\r
+\r
+\r
+*  GLOBAL INFORMATION FOR ANIMATIONS\r
+ANASTART  DB      $00,$07,$0F            ;OFFSET INTO ANIMATION INFORMATION\r
+ANSSTART  DB      $00,$16,$22            ;OFFSET INTO ANIMATION SEGMENT INFO\r
+ANFRAMES  DB      $01,$01,$02            ;FRAMES PER TIC\r
+\r
+\r
+*  INFORMATION ABOUT EACH ANIMATION\r
+ANTICS    DB      $DB,$4D,$0E,$18,$0C,$1D,$00    ;TICS PER ANIMATION SEGMENT\r
+          DB      $22,$D6,$BE,$BE,$32,$38,$60,$00\r
+          DB      $30,$20,$10,$30,$00\r
+ANCHARS   DB      4,4,4,4,3,3,0                  ;CHARACTERS PER ANIMATION\r
+          DB      1,2,2,2,2,2,1,0\r
+          DB      6,6,6,6,0\r
+\r
+\r
+*  INFORMATION ABOUT EACH ANIMATION SEGMENT\r
+ANIHPOS   DB      $FF,$90,$E0,$B0                ;STARTING HPOS\r
+          DB      $91,$FE,$A5,$EA\r
+          DB      $00,$00,$00,$00\r
+          DB      $00,$00,$00,$00\r
+          DB      $00,$00,$48\r
+          DB      $00,$00,$00\r
+\r
+          DB      $F0\r
+          DB      $E0,$FF\r
+          DB      $90,$B0\r
+          DB      $E0,$FF\r
+          DB      $90,$B0\r
+          DB      $E0,$FF\r
+          DB      $F0\r
+\r
+          DB      $10,$20,$8E,$90,$98,$A0\r
+          DB      $00,$00,$00,$00,$00,$00\r
+          DB      $00,$00,$00,$00,$00,$00\r
+          DB      $00,$00,$00,$00,$00,$00\r
+\r
+\r
+ANIVPOS   DB      $60,$A0,$60,$A0                ;STARTING VPOS\r
+          DB      $80,$80,$80,$80\r
+          DB      $00,$00,$00,$00\r
+          DB      $00,$00,$00,$00\r
+          DB      $00,$00,$28\r
+          DB      $00,$00,$00\r
+\r
+          DB      $00\r
+          DB      $40,$40\r
+          DB      $80,$80\r
+          DB      $60,$60\r
+          DB      $40,$40\r
+          DB      $80,$80\r
+          DB      $00\r
+\r
+          DB      $80,$80,$40,$3E,$3E,$3E\r
+          DB      $00,$00,$00,$00,$00,$00\r
+          DB      $00,$00,$00,$00,$00,$00\r
+          DB      $00,$00,$00,$00,$00,$00\r
+\r
+\r
+ANICHAR   DB      $00,$12,$18,$1C                ;STARTING CHARACTER\r
+          DB      $06,$0C,$1C,$18\r
+          DB      $09,$15,$1C,$18\r
+          DB      $09,$15,$18,$1C\r
+          DB      $06,$0C,$26\r
+          DB      $08,$0E,$26\r
+\r
+          DB      $00\r
+          DB      $00,$0C\r
+          DB      $06,$12\r
+          DB      $00,$0C\r
+          DB      $06,$12\r
+          DB      $00,$0C\r
+          DB      $00\r
+\r
+          DB      $02,$0E,$27,$29,$2A,$2C\r
+          DB      $02,$0E,$27,$29,$2A,$2C\r
+          DB      $02,$0E,$27,$29,$2A,$2C\r
+          DB      $02,$0E,$28,$29,$2A,$2C\r
+\r
+ANIPALET  DB      $00,$00,$01,$02                ;PALETTE\r
+          DB      $00,$00,$01,$02\r
+          DB      $00,$00,$01,$02\r
+          DB      $00,$00,$01,$02\r
+          DB      $00,$00,$00\r
+          DB      $00,$00,$00\r
+\r
+          DB      $00\r
+          DB      $00,$00\r
+          DB      $00,$00\r
+          DB      $00,$00\r
+          DB      $00,$00\r
+          DB      $00,$00\r
+          DB      $00\r
+\r
+          DB      $00,$00,$03,$03,$03,$03\r
+          DB      $00,$00,$03,$03,$03,$03\r
+          DB      $00,$00,$03,$03,$03,$03\r
+          DB      $00,$00,$00,$03,$03,$03\r
+\r
+ANIHPDIF  DB      $10,$28,$18,$30                ;CHANGES TO HPOS\r
+          DB      $28,$10,$30,$18\r
+          DB      $00,$00,$30,$18\r
+          DB      $00,$00,$08,$20\r
+          DB      $00,$00,$00\r
+          DB      $00,$00,$00\r
+\r
+          DB      $00\r
+          DB      $18,$10\r
+          DB      $28,$30\r
+          DB      $18,$10\r
+          DB      $48,$50\r
+          DB      $40,$38\r
+          DB      $00\r
+\r
+          DB      $00,$00,$30,$30,$30,$30\r
+          DB      $00,$00,$30,$30,$30,$30\r
+          DB      $00,$00,$20,$30,$30,$30\r
+          DB      $00,$00,$00,$30,$30,$30\r
+\r
+ANIVPDIF  DB      $00,$00,$00,$00                ;CHANGES TO VPOS\r
+          DB      $00,$00,$00,$00\r
+          DB      $08,$08,$00,$00\r
+          DB      $08,$08,$10,$10\r
+          DB      $00,$00,$00\r
+          DB      $00,$00,$00\r
+\r
+          DB      $00\r
+          DB      $00,$00\r
+          DB      $00,$00\r
+          DB      $00,$00\r
+          DB      $00,$00\r
+          DB      $00,$00\r
+          DB      $00\r
+\r
+          DB      $00,$00,$00,$00,$20,$20\r
+          DB      $00,$00,$18,$00,$20,$20\r
+          DB      $00,$00,$10,$00,$20,$20\r
+          DB      $00,$00,$00,$00,$20,$20\r
+\r
+ANIANDIF  DB      $08,$08,$10,$10                ;CHANGES TO ANIMATION CHARS\r
+          DB      $08,$08,$10,$10\r
+          DB      $08,$08,$10,$10\r
+          DB      $08,$08,$10,$10\r
+          DB      $08,$08,$00\r
+          DB      $00,$00,$00\r
+\r
+          DB      $00\r
+          DB      $08,$08\r
+          DB      $08,$08\r
+          DB      $08,$08\r
+          DB      $08,$08\r
+          DB      $08,$08\r
+          DB      $00\r
+\r
+          DB      $00,$00,$00,$00,$18,$18\r
+          DB      $00,$00,$00,$00,$18,$18\r
+          DB      $00,$00,$00,$00,$18,$18\r
+          DB      $00,$00,$00,$00,$18,$18\r
+\r
+\r
+*  PALETTE TABLES\r
+ANPALET1  DB      YELLOW,RED,LTBLUE,YELLOW       ;PALETTES FOR STAMPS\r
+ANPALET2  DB      PINK,WHITE,WHITE,BLUE\r
+ANPALET3  DB      BLACK,BLUE,BLUE,WHITE\r
+\r
+\r
+*  HPOS MOVEMENT TABLES\r
+ANHPMOVE  DB      0,0,0,0,0,0,0,0                ;0 POSSIBLE MOVEMENTS FOR CHARS\r
+          DB      1,0,1,0,1,0,1,0                ;8\r
+          DB      1,1,1,1,1,1,1,0                ;10\r
+          DB      1,1,1,1,1,1,1,1                ;18\r
+          DB      -1,0,-1,0,-1,0,-1,0            ;20\r
+          DB      -1,-1,-1,-1,-1,-1,-1,0         ;28\r
+          DB      -1,-1,-1,-1,-1,-1,-1,-1        ;30\r
+          DB      3,3,2,3,3,2,3,2                ;38\r
+          DB      3,3,3,3,3,3,3,3                ;40\r
+          DB      -3,-3,-2,-3,-3,-2,-3,-2        ;48\r
+          DB      -3,-3,-3,-3,-3,-3,-3,-3        ;50\r
+\r
+\r
+*  VPOS MOVEMENT TABLES\r
+ANVPMOVE  DB      0,0,0,0,0,0,0,0                ;0 POSSIBLE MOVEMENTS FOR CHARS\r
+          DB      -2,-2,-2,-2,-2,-2,-2,-2        ;8\r
+          DB      -1,-1,0,0,1,1,0,0              ;10\r
+          DB      2,2,2,2,2,2,2,2                ;18\r
+          DB      0,0,-2,0,0,0,2,0               ;20\r
+\r
+\r
+*  ANIMATION TABLES\r
+ANANMOVE  DB      0,0,0,0,0,0,0,0                ;0 MOVEMENTS FOR ANIMATIONS\r
+          DB      0,1,0,1,0,-1,0,-1              ;8\r
+          DB      0,1,0,-1,0,1,0,-1              ;10\r
+          DB      0,0,1,0,0,0,-1,0               ;18\r
+\r
+\r
diff --git a/END.S b/END.S
new file mode 100644 (file)
index 0000000..50845c4
--- /dev/null
+++ b/END.S
@@ -0,0 +1,13 @@
+\r
+*  END.S          CONTAINS THE END STATEMENT\r
+\r
+END       DB      'GCC(C)1984'           ;LABEL TO SEE WHERE END OF ROM IS\r
+\r
+          ORG     $FFF8\r
+          DB      $FF,$C7                ;START AT $C000, + MARIA SIGNATURE\r
+          DW      DLI                    ;INTERRUPT VECTOR\r
+          DW      MAIN                   ;START VECTOR\r
+          DW      NULLRTI                ;UNUSED VECTOR\r
+\r
+          END\r
+\r
diff --git a/FRUIT.S b/FRUIT.S
new file mode 100644 (file)
index 0000000..16e8e08
--- /dev/null
+++ b/FRUIT.S
@@ -0,0 +1,304 @@
+\r
+*  FRUIT.S        ROUTINES FOR THE FRUIT\r
+\r
+\r
+*  MOVE THE FRUIT\r
+MOVEFRT   JSR     SETFRT                 ;SET NEXT FRUIT MOVE\r
+          LDA     FENABLE\r
+          BEQ     MFOUT\r
+          LDA     FSCORE\r
+          BNE     MFSCORE\r
+          JSR     FRTSOUND               ;DO THE FRUIT SOUND, IF NEEDED\r
+          JMP     FRTDIR                 ;SET THE DIRECTION\r
+MFSCORE   DEC     FSCORE\r
+          BNE     MFOUT\r
+          JMP     CLEARFRT\r
+MFOUT     RTS\r
+\r
+\r
+*  SET THE NEXT FRUIT MOVE\r
+SETFRT    LDA     RTLOCAL+1\r
+          CLC\r
+          ADC     #WAITFRT\r
+          STA     FRTWAIT\r
+          RTS\r
+\r
+\r
+*  THIS ROUTINE DOES THE BOUNCING SOUND FOR THE FRUIT\r
+FRTSOUND  DEC     FSOUND                 ;SEE IF TIME FOR SOUND YET\r
+          BPL     FSOUT\r
+          LDA     #$03                   ;SET UP NEXT SOUND\r
+          STA     FSOUND\r
+          LDA     #$0B                   ;MAKE FRUIT BOUNCE NOISE\r
+          JSR     DOTUNE\r
+FSOUT     RTS\r
+\r
+\r
+*  THIS ROUTINE FINDS OUT WHAT DIRECTION TO MOVE\r
+FRTDIR    LDA     FCOUNT                 ;SEE IF IN 'CENTER' OF CHAR\r
+          AND     #$03\r
+          BNE     FDEND\r
+          LDA     FTUNNEL                ;SEE IF FRUIT IN TUNNEL\r
+          BNE     FDEND\r
+\r
+          LDA     FZONE                  ;SEE IF WE HAVE REACHED THE GOAL\r
+          CMP     FGZONE\r
+          BNE     FDIRCONT\r
+          LDA     FCOL\r
+          CMP     FGCOL\r
+          BNE     FDIRCONT\r
+          JSR     FRTGOAL                ;GET THE NEXT GOAL\r
+\r
+FDIRCONT  LDX     FZONE                  ;SET UP FOR CALL ON WHCHWAY\r
+          STX     TEMP4\r
+          LDA     FCOL\r
+          STA     TEMP5\r
+          LDA     FDIR\r
+          STA     TEMP6\r
+          JSR     CHECKDIR\r
+          LDX     FGZONE\r
+          STX     TEMP7\r
+          LDA     FGCOL\r
+          STA     TEMP8\r
+          JSR     WHCHWAY                ;FIND OUT WHICH WAY TO GO\r
+          STA     FDIR                   ;NEW DIRECTION\r
+\r
+FDEND     JMP     FRTMOVE\r
+FDCLEAR   JMP     CLEARFRT\r
+\r
+*  MOVE THE FRUIT\r
+FRTMOVE   LDY     FDIR\r
+          LDX     FOFF\r
+          LDA     FHPOS                  ;MOVE HORIZONTALLY\r
+          JSR     HPOSADJ\r
+          STA     FHPOS\r
+          LDA     FVPOS                  ;MOVE VERTICALLY\r
+          JSR     VPOSADJ\r
+          STA     FVPOS\r
+\r
+          LDY     FCOUNT\r
+          LDA     FVPOS                  ;MOVING VERTICALLY\r
+          CLC\r
+          ADC     BOUNCTB,Y              ;ADJUST FOR BOUNCE\r
+          STA     FVPOS\r
+\r
+          DEY                            ;ADJUST COUNT\r
+          BPL     FMJMP0\r
+          LDY     #$03\r
+FMJMP0    STY     FCOUNT\r
+\r
+          LDA     FHPOS                  ;SEE IF IN TUNNEL OR OFF SCREEN\r
+          CMP     #LEFTEDGE\r
+          BCS     FMCHKRGT\r
+          CMP     #LEFTWRAP\r
+          BCS     FMTUNNEL\r
+          JMP     CLEARFRT               ;OFF SCREEN - KILL IT\r
+FMCHKRGT  CMP     #RGHTEDGE\r
+          BCC     FMNORMAL\r
+          CMP     #RGHTWRAP\r
+          BCC     FMTUNNEL\r
+          JMP     CLEARFRT               ;OFF SCREEN - KILL IT\r
+\r
+FMTUNNEL  LDA     #$01                   ;MOVING THROUGH TUNNEL\r
+          STA     FTUNNEL\r
+          JMP     FMZONE                 ;ADJUST ZONE, BUT NOT COLUMN, COL BOGUS\r
+\r
+FMNORMAL  LDA     #$00                   ;MOVING AROUND MAZE\r
+          STA     FTUNNEL\r
+          LDA     FHPOS                  ;SET COLUMN\r
+          JSR     HTOC\r
+          STA     FCOL\r
+FMZONE    LDA     FVPOS                  ;SET ZONE\r
+          JSR     VTOZO\r
+          INY\r
+          STY     FZONE\r
+          STA     FOFF\r
+\r
+          JMP     WRITEFRT\r
+\r
+\r
+*  INITIALIZE THE FRUIT STATE\r
+INITFRT   LDA     FENABLE                ;MAKE SURE FRUIT IS NOT ON YET\r
+          BNE     IFOUT\r
+          LDA     #$01\r
+          STA     FENABLE                ;ENABLE\r
+          STA     FTUNNEL                ;STARTING IN TUNNEL\r
+          LDA     #$00\r
+          STA     FGCOUNT\r
+          STA     FSCORE\r
+          STA     FSOUND\r
+          LDA     #$02\r
+          STA     FCOUNT\r
+\r
+          LDA     LEVEL                  ;SET FRUIT TYPE\r
+          CMP     #$08\r
+          BMI     IFCONT\r
+IFRAND    JSR     RAND                   ;RANDOM FRUIT\r
+          AND     #$07\r
+          CMP     STLEVEL\r
+          BMI     IFRAND                 ;NO RANDOM FRUIT BELOW WHAT YOU STARTED\r
+IFCONT    STA     FFRUIT\r
+\r
+          JSR     RAND                   ;RANDOM TUNNEL TO COME THROUGH\r
+          AND     #$01                   ;SET STARTING ZONE\r
+          STA     TEMP0\r
+          LDA     RACK\r
+          ASL     A\r
+          ORA     TEMP0                  ;A = 2*RACK + [0..1], INDEX TO TUNNEL\r
+          TAX\r
+          LDA     #$02                   ;SET OFFSET\r
+          STA     FOFF\r
+          LDA     TNLZONE,X              ;SET ZONE\r
+          STA     FZONE\r
+          JSR     ZTOV\r
+          SEC\r
+          SBC     #$04                   ;SET VPOS\r
+          STA     FVPOS\r
+\r
+          JSR     RAND                   ;SET STARTING COLUMN/DIRECTION\r
+          AND     #$02                   ;EITHER 0 (RIGHT) OR 2 (LEFT)\r
+          STA     FDIR                   ;SET DIR\r
+          LSR     A                      ;EITHER 0 (LEFT COL) OR 1 (RIGHT COL)\r
+          TAX\r
+          LDA     TNLCOL,X\r
+          STA     FCOL                   ;SET COL\r
+          LDA     TNLHPOS,X\r
+          STA     FHPOS                  ;SET HPOS\r
+\r
+          JSR     FRTGOAL                ;GET A GOAL\r
+\r
+          JSR     FRTSTAMP               ;SET THE STAMP\r
+          JSR     WRITEFRT               ;WRITE IT\r
+\r
+IFOUT     LDA     #$70\r
+          STA     FDOTS                  ;SET UP THE NEXT FRUIT\r
+          RTS\r
+\r
+\r
+*  THIS ROUTINE FINDS THE NEXT GOAL FOR THE FRUIT\r
+*  RETURN VALUE IS BOTH 0 IN X AND THE EQ BIT SET WHEN NO MORE GOALS TO BE HAD\r
+FRTGOAL   LDX     FGCOUNT\r
+          CPX     #$04\r
+          BPL     FGOUT\r
+          CPX     #$03\r
+          BPL     FGLEAVE\r
+          LDA     GOALZONE,X             ;GET NEXT GOAL\r
+          STA     FGZONE\r
+          LDA     GOALCOL,X\r
+          STA     FGCOL\r
+          INX\r
+          STX     FGCOUNT\r
+          RTS\r
+FGLEAVE   JSR     RAND                   ;GET A RANDOM TUNNEL TO LEAVE\r
+          AND     #$03                   ;  GET THE COLUMN FIRST\r
+          STA     TEMP0\r
+          LDA     RACK\r
+          ASL     A\r
+          ASL     A\r
+          ORA     TEMP0                  ;A = 3*RACK + [0..3], INDEX TO TUNNEL\r
+          TAY\r
+          LDA     TNLCOLG,Y\r
+          STA     FGCOL\r
+          TYA                            ;GET THE ZONE\r
+          LSR     A\r
+          TAY\r
+          LDA     TNLZONE,Y\r
+          STA     FGZONE\r
+          INX\r
+          STX     FGCOUNT\r
+FGOUT     RTS\r
+\r
+\r
+*  CLEAR FRUIT\r
+CLEARFRT  LDA     #$00\r
+          STA     FENABLE\r
+\r
+\r
+*  ERASE THE FRUIT\r
+ERASEFRT  LDA     #OFFSCRN               ;SET HPOS AND DOLIST\r
+          STA     HPLIST+1\r
+          STA     DOLIST+1\r
+          RTS\r
+\r
+\r
+*  WRITE A FRUIT ON THE SCREEN\r
+WRITEFRT  LDA     FHPOS                  ;SET HPOS AND DOLIST\r
+          SEC\r
+          SBC     #$03\r
+          STA     HPLIST+1\r
+          LDX     FZONE\r
+          DEX\r
+          STX     VZLIST+1\r
+          STA     DOLIST+1\r
+          RTS\r
+\r
+\r
+*  PUT THE RIGHT FRUIT STAMPS INTO STAMPS\r
+FRTSTAMP  LDX     FFRUIT                 ;WHICH ONE IT IS\r
+          LDA     FLSTAMP,X              ;SET STAMP\r
+          STA     SLLIST+1\r
+          LDA     FHSTAMP,X\r
+          STA     SHLIST+1\r
+          LDY     FPALETTE,X\r
+          LDA     FCOLOR1,Y              ;SET PALETTE FOR FRUIT\r
+          STA     P2C1\r
+          LDA     FCOLOR2,Y\r
+          STA     P2C2\r
+          LDA     FCOLOR3,Y\r
+          STA     P2C3\r
+          RTS\r
+\r
+\r
+*  EAT THE FRUIT - MAKE IT GO AWAY\r
+EATFRT    LDX     FFRUIT\r
+          LDA     NLSTAMP,X              ;SET STAMP\r
+          STA     SLLIST+1\r
+          LDA     NHSTAMP,X\r
+          STA     SHLIST+1\r
+          STA     DOLIST+1\r
+\r
+          LDA     #LTGREEN\r
+          STA     P2C3\r
+\r
+          LDA     #$10                   ;SET TIME FOR IT TO STAY\r
+          STA     FSCORE\r
+\r
+          LDA     #$12                   ;MAKE FRUIT EAT SOUND\r
+          JSR     DOTUNE\r
+          RTS\r
+\r
+\r
+*  TABLE TO CONTROL FRUIT BOUNCING\r
+BOUNCTB   DB      $FF,$FF,$01,$01\r
+\r
+*  TABLES TO SET FRUIT STAMPS AND FRUIT NUMBER STAMPS\r
+FLSTAMP   DB      L(FRUITCHR),L(FRUITCHR+$18),L(FRUITCHR+$30)\r
+          DB      L(FRUITCHR+$48),L(FRUITCHR+$60),L(FRUITCHR+$78)\r
+          DB      L(FRUITCHR+$90),L(FRUITCHR+$A8)\r
+FHSTAMP   DB      H(FRUITCHR),H(FRUITCHR+$18),H(FRUITCHR+$30)\r
+          DB      H(FRUITCHR+$48),H(FRUITCHR+$60),H(FRUITCHR+$78)\r
+          DB      H(FRUITCHR+$90),H(FRUITCHR+$A8)\r
+NLSTAMP   DB      L(FRUITNUM),L(FRUITNUM+$18),L(FRUITNUM+$30)\r
+          DB      L(FRUITNUM+$48),L(FRUITNUM+$60),L(FRUITNUM+$78)\r
+          DB      L(FRUITNUM+$90),L(FRUITNUM+$A8)\r
+NHSTAMP   DB      H(FRUITNUM),H(FRUITNUM+$18),H(FRUITNUM+$30)\r
+          DB      H(FRUITNUM+$48),H(FRUITNUM+$60),H(FRUITNUM+$78)\r
+          DB      H(FRUITNUM+$90),H(FRUITNUM+$A8)\r
+\r
+*  TABLES TO SET FRUIT COLORS\r
+FPALETTE  DB      0,0,1,2,0,0,3,4\r
+FCOLOR1   DB      RED,RED,ORANGE,GREEN,YELLOW\r
+FCOLOR2   DB      WHITE,WHITE,BROWN,WHITE,BLACK\r
+FCOLOR3   DB      BROWN,GREEN,GREEN,BROWN,BLACK\r
+\r
+*  TABLES TO SET TUNNEL ENTRANCES\r
+TNLZONE   DB      $07,$10,$01,$16\r
+          DB      $08,$08,$0C,$0F\r
+TNLCOL    DB      $00,$1B\r
+TNLHPOS   DB      LEFTWRAP,RGHTWRAP\r
+TNLCOLG   DB      $02,$19,$02,$19,$05,$16,$02,$19\r
+          DB      $00,$1B,$00,$1B,$03,$18,$03,$18\r
+\r
+*  TABLES FOR FRUIT GOALS\r
+GOALZONE  DB      $10,$0A,$10\r
+GOALCOL   DB      $0F,$10,$0F\r
diff --git a/GETJOY.S b/GETJOY.S
new file mode 100644 (file)
index 0000000..7e42e95
--- /dev/null
+++ b/GETJOY.S
@@ -0,0 +1,50 @@
+\r
+*  GETJOY.S\r
+*  READ JOYSTICK DATA\r
+*\r
+*  GAME PLAY JOYSTICK ROUTINE\r
+GETJOY    TXA                            ;STORE X\r
+          PHA\r
+          LDX     PLAYER                 ;USE APPROPRIATE PORT\r
+\r
+GJDOIT    JSR     GETBUT                 ;FIND BUTTON STATE\r
+          STA     BUTSTATE               ;STORE IT\r
+          JSR     GETSTICK\r
+          STA     NEWDIR\r
+\r
+          PLA                            ;GET X BACK\r
+          TAX\r
+          RTS\r
+\r
+\r
+*  GET THE BUTTON STATE\r
+*  INPUT: PORT IN X\r
+*  OUTPUT: STATE IN A (0 IF NOT DEPRESSED)\r
+GETBUT    LDA     INPT4,X                ;GET BUTTON BIT\r
+          AND     #$80                   ;ISOLATE IT\r
+          EOR     #$80                   ;INVERT IT\r
+          RTS\r
+\r
+\r
+*  GET THE STICK STATE\r
+*  INPUT: JOYSTICK PORT IN X\r
+*  OUTPUT: DIRECTION IN A\r
+*  SMASHES: X\r
+GETSTICK  LDA     SWCHA                  ;GET JOYSTICK BITS\r
+          CPX     #$00\r
+          BNE     GSJMP0\r
+          LSR     A                      ;GET PLAYER 0 JOYSTICK IN LOW BITS\r
+          LSR     A\r
+          LSR     A\r
+          LSR     A\r
+GSJMP0    AND     #$0F                   ;GET RID OF ANY EXTRA BITS\r
+          TAX\r
+          LDA     JOYTAB,X               ;LOOK IT UP IN TABLE\r
+          RTS\r
+\r
+\r
+* TABLE OF JOYSTICK DIRECTIONS VS BIT READINGS\r
+JOYTAB    DB      DCENTER,DCENTER,DCENTER,DCENTER\r
+          DB      DCENTER,DDWRIGHT,DUPRIGHT,DRIGHT\r
+          DB      DCENTER,DDWLEFT,DUPLEFT,DLEFT\r
+          DB      DCENTER,DDOWN,DUP,DCENTER\r
diff --git a/HIGH.S b/HIGH.S
new file mode 100644 (file)
index 0000000..e3dff28
--- /dev/null
+++ b/HIGH.S
@@ -0,0 +1,138 @@
+\r
+*  HIGH           HIGH SCORE ROUTINES\r
+\r
+\r
+*  THIS ROUTINE DISPLAYS THE HIGH SCORES FOR THE GAME\r
+HOLDSCOR  LDA     HSCHERE                ;SEE IF HI SCORE CART IS THERE\r
+          BEQ     HOSOUT\r
+\r
+          LDX     #$07\r
+HOSLOOP   TXA                            ;SAVE X\r
+          PHA\r
+          JSR     HSETTEMP               ;SET UP TEMPLATE FOR HSC DATA BLOCK\r
+          LDA     #$04                   ;SET TIME TO SEE TABLE\r
+          STA     HSCRAM+$0E\r
+          PLA                            ;GET OUR X BACK\r
+          PHA\r
+          JSR     HSETDIF                ;UPDATE HSC DATA BLOCK FOR DIFFICULTY\r
+          JSR     HSCATRCT\r
+          PLA                            ;RESTORE X\r
+          TAX\r
+          DEX\r
+          BPL     HOSLOOP\r
+HOSOUT    RTS\r
+\r
+\r
+*  THIS ROUTINE ENTERS A NEW HI SCORE AND SHOWS THE HI SCORE TABLE\r
+HNEWSCOR  LDA     HSCHERE                ;SEE IF HI SCORE CART IS THERE\r
+          BEQ     HOSOUT\r
+\r
+          JSR     HSETTEMP               ;SET UP TEMPLATE FOR HSC DATA BLOCK\r
+          JSR     HSETDIFC               ;SET DIFFICULTY\r
+          LDA     #$00\r
+          JSR     HSETPLAY               ;SET PLAYER 1\r
+          JSR     HSCENTER               ;SHOW HSC TABLE\r
+          LDA     TWOPLAYR\r
+          BEQ     HNSOUT\r
+\r
+          JSR     HSETTEMP               ;SET UP TEMPLATE FOR HSC DATA BLOCK\r
+          JSR     HSETDIFC               ;SET DIFFICULTY\r
+          LDA     #$01\r
+          JSR     HSETPLAY               ;SET PLAYER 2\r
+          JSR     HSCENTER\r
+\r
+HNSOUT    JSR     HSETTEMP               ;SET UP TEMPLATE FOR HSC DATA BLOCK\r
+          LDA     #$09                   ;SET TIME TO SEE TABLE - 10 SECONDS\r
+          STA     HSCRAM+$0E\r
+          JSR     HSETDIFC\r
+                                         ;FALL THROUGH\r
+\r
+*  DO THE HSCATRCT\r
+HSCATRCT  LDX     #L(HSCRAM)             ;AND DO IT\r
+          LDY     #H(HSCRAM)\r
+          JSR     $3FFA                  ;DO HSCATRCT\r
+          JSR     OURINIT                ;FIX OUR STATE\r
+          JMP     SEEBAUTO\r
+\r
+\r
+*  DO THE HSCENTER\r
+HSCENTER  LDX     #L(HSCRAM)             ;AND DO IT\r
+          LDY     #H(HSCRAM)\r
+          JSR     $3FFD                  ;DO HSCENTER\r
+          JSR     OURINIT                ;FIX OUR STATE\r
+          JMP     SEEBALL\r
+\r
+\r
+*  THIS ROUTINE SETS UP A DEFAULT HSC TABLE IN THE START OF HSC RAM\r
+HSETTEMP  LDX     #$1F\r
+HSTLOOP   LDA     HSCTEMP,X              ;INITIALIZE HI SCORE TEMPLATE\r
+          STA     HSCRAM,X\r
+          LDA     #$1D                   ;CLEAR DIFFICULTY NAME\r
+          STA     HSCDIF,X\r
+          DEX\r
+          BPL     HSTLOOP\r
+          RTS\r
+\r
+\r
+*  THIS ROUTINE SETS THE DIFFICULTY IN A FOR THE HSCRAM\r
+HSETDIFC  LDA     STLEVEL                ;DEFAULT STARTING LEVEL\r
+HSETDIF   TAX\r
+          ASL     A                      ;SHIFT IT LEFT TWICE\r
+          ASL     A\r
+          STA     HSCRAM+2               ;STORE IT IN DIFFICULTY\r
+\r
+          LDY     HSCOFF,X               ;MOVE THE NAME IN\r
+          LDX     #$08\r
+HSDLOOP   LDA     TMESSAG2,Y\r
+          BNE     HSDLNORM\r
+          LDA     #$1D\r
+          JMP     HSDLSTOR\r
+HSDLNORM  SEC\r
+          SBC     #$5E\r
+HSDLSTOR  STA     HSCDIF,X\r
+          INY\r
+          INX\r
+          CPX     #$12\r
+          BMI     HSDLOOP\r
+\r
+          RTS\r
+\r
+\r
+*  THIS ROUTINE SETS THE PLAYER.  A IS THE PLAYER.  HSCDIF MUST BE CALLED FIRST.\r
+*  PLAYER 1 MUST BE DONE BEFORE PLAYER 2.\r
+HSETPLAY  TAX\r
+          ORA     HSCRAM+2               ;OR IN THE DIFFICULTY\r
+          STA     HSCRAM+2\r
+\r
+          LDA     #H(P1SCORE)            ;SET HI BYTE OF SCORE\r
+          STA     HSCRAM+9\r
+          CPX     #$00                   ;SEE WHICH PLAYER\r
+          BNE     HSCP2\r
+\r
+          LDA     #L(P1SCORE)            ;SET SCORE FOR PLAYER 1\r
+          STA     HSCRAM+8\r
+          RTS\r
+\r
+HSCP2     LDA     #L(P2SCORE)            ;SET SCORE FOR PLAYER 2\r
+          STA     HSCRAM+8\r
+\r
+*  WE HAVE NO SOUND FOR HSC\r
+HSCSOUND  RTS\r
+\r
+\r
+*  TEMPLATE FOR HSC TABLE\r
+HSCTEMP   DB      $80,$01                ;ID NUMBER AND TRAILING ZERO\r
+          DB      $00                    ;DIFFICULTY [7..2] AND PLAYER [1..0]\r
+          DB      $01                    ;CONTROLLER TYPE\r
+          DB      L(HSCMS),H(HSCMS)      ;POINTER TO MS PAC-MAN NAME\r
+          DB      L(HSCDIF),H(HSCDIF)    ;POINTER TO DIFFICULTY NAME\r
+          DB      $00,$00                ;POINTER TO SCORE\r
+          DB      $00,$00                ;POINTER TO DLL FOR LOGO\r
+          DB      L(HSCSOUND),H(HSCSOUND) ;POINTER TO SOUND ROUTINE\r
+          DB      $00                    ;TIME TO WAIT TILL RETURN\r
+\r
+*  WORDS FOR HSC - NAME OF GAME AND DIFFICULTIES\r
+HSCMS     DB      $1D,$1D,$1D,$1D,$1D,$1D,$1D,$1D\r
+          DB      $0C,$12,$1D,$0F,$00,$02,$1C,$0C,$00,$0D  ;MS PAC-MAN\r
+          DB      $1D,$1D,$1D,$1D,$1D,$1D,$1D,$1D\r
+\r
diff --git a/INIT.S b/INIT.S
new file mode 100644 (file)
index 0000000..9e5f837
--- /dev/null
+++ b/INIT.S
@@ -0,0 +1,641 @@
+\r
+*  INIT           INITIALIZATION ROUTINES FOR MS PAC MAN\r
+\r
+*  DO THE INITIALIZATION NEEDED AT THE VERY MINIMUM.\r
+STRTINIT  JSR     ZERORAM                ;ZERO RAM, TURN OFF DISPLAY\r
+          FILL    $40,#0,#$60            ;NULL OUT LOWER PART OF PAGE ZERO\r
+          JSR     ZEROSCOR\r
+\r
+          LDX     #$1F                   ;RANDOMIZE SEED\r
+SIRRLOOP  EOR     $00,X\r
+          DEX\r
+          BPL     SIRRLOOP\r
+          STA     NEWRAND\r
+\r
+          LDX     #$00                   ;GET JOYSTICK STATE SET UP\r
+          STX     INPTCTRL\r
+          LDA     $3900                  ;SEE IF HI SCORE CART IS THERE\r
+          CMP     #$C6\r
+          BNE     NOHSC\r
+          LDA     $3904\r
+          CMP     #$FE\r
+          BNE     NOHSC\r
+          INX\r
+NOHSC     STX     HSCHERE\r
+\r
+          LDA     #$00\r
+          STA     CTLSWA                 ;INITIALIZE JOYSTICKS AND SWITCHES\r
+          STA     CTLSWB\r
+          JSR     OURINIT                ;INIT IT OUR WAY\r
+\r
+          LDA     #$01\r
+          STA     STLEVEL                ;START DEFAULT AT CHERRY LEVEL\r
+\r
+          RTS\r
+\r
+\r
+*  INITIALIZE STATE OUR WAY - USED ALSO AFTER HSC STUFF\r
+OURINIT   JSR     SCREENNO               ;TURN SCREEN OFF\r
+\r
+          LDA     #BLACK\r
+          STA     BACKGRND               ;PUT BACKGROUND TO BLACK\r
+          JSR     LOADDLST               ;INITIALIZE DISPLAY LISTS\r
+\r
+          JSR     LOADFONT               ;LOAD FONT\r
+          LDA     #H(STAMPS)\r
+          STA     CHARBASE               ;INSTALL THE MS PAC MAN CHARACTERS\r
+          LDA     #L(DLL)\r
+          STA     DPPL                   ;SET DPPL AND DPPH TO DLLIST\r
+          LDA     #H(DLL)\r
+          STA     DPPH\r
+\r
+          JMP     SCREENON               ;TURN SCREEN DISPLAY ON\r
+\r
+\r
+*  INITIALIZE THE ENTIRE GAME.  ZERO DATA AREAS AND SET CONTROL REGISTERS.\r
+GAMEINIT  JSR     ZERORAM                ;ZERO RAM, TURN OFF SCREEN\r
+          JSR     SCREENON               ;SCREEN BACK ON AGAIN\r
+          LDA     AUTOPLAY\r
+          BNE     GIJMP0\r
+          JSR     ZEROSCOR               ;ZERO SCORE IF NOT IN AUTO-PLAY\r
+\r
+GIJMP0    LDA     #$01                   ;SET UP PLAYER 2\r
+          STA     PLAYER\r
+          LDA     STLEVEL                ;SET STARTING LEVEL\r
+          STA     LEVEL\r
+          STA     ADJLEVEL\r
+          JSR     SETRACK\r
+          JSR     INITLIV                ;INITIALIZE NUMBER OF LIVES\r
+          JSR     SCRNINIT               ;INITIALIZE SCREEN AND TIMERS\r
+\r
+          JSR     SWITCHPL               ;SET UP PLAYER 1\r
+          LDA     STLEVEL                ;SET STARTING LEVEL\r
+          STA     LEVEL\r
+          STA     ADJLEVEL\r
+          JSR     SETRACK\r
+          JSR     INITLIV                ;INITIALIZE NUMBER OF LIVES\r
+\r
+\r
+*  THIS ROUTINE INITIALIZES THE STATE FOR A RACK\r
+RACKINIT  JSR     SCRNINIT\r
+          JMP     COMNINIT\r
+\r
+\r
+*  THIS ROUTINE INITIALIZES THE SCREEN FOR A RACK\r
+SCRNINIT  JSR     LOADDOTS               ;SET UP DOTS\r
+          LDA     #$38                   ;SET NUMBER OF DOTS BEFORE FRUIT APPEAR\r
+          STA     FDOTS\r
+\r
+          LDA     #0\r
+          STA     DOTSEATN\r
+          STA     PINKDOTS\r
+          STA     BLUEDOTS\r
+          STA     GOLDDOTS\r
+          STA     DEATHFLG\r
+          STA     EATNDOTS\r
+          STA     TRELEASE\r
+\r
+SCRRAND   JSR     RAND                   ;GET A RANDOM NUMBER 0..3 FOR AUTOPLAY\r
+          AND     #$03\r
+          BEQ     SCRRAND                ;DO NOT ALLOW 0 (SHE DIES TOO MUCH)\r
+          STA     RACKRAND\r
+          RTS\r
+\r
+\r
+*  THIS ROUTINE INITIALIZES BETWEEN PLAYERS\r
+OTHRINIT  JSR     SAVEDOTS               ;UPDATE DOT ARRAY\r
+          JSR     SWITCHPL               ;SWITCH PLAYERS\r
+\r
+\r
+*  THIS ROUTINE IS USED IN COMMON BY RACKINIT AND OTHRINIT\r
+COMNINIT  LDA     #$00                   ;ZERO OUR LOCAL CLOCKS\r
+          STA     RTLOCAL\r
+          STA     RTLOCAL+1\r
+          STA     NORMTIME\r
+          STA     NORMTIME+1\r
+          JSR     CLRSCRN                ;TURN OFF THE SCREEN\r
+\r
+          LDX     RACK\r
+          LDA     DOTCOLOR,X             ;SET COLORS\r
+          STA     P0C1\r
+          LDA     BARCOLOR,X\r
+          STA     P0C2\r
+          LDA     OUTCOLOR,X\r
+          STA     P0C3\r
+          JSR     LOADDLST               ;RESTORE THE DISPLAY LISTS\r
+          JSR     LOADMAP                ;SET UP SCREEN\r
+          JSR     WRTINDS                ;WRITE INDICATORS - GO TO LIFEINIT\r
+\r
+\r
+*  THIS ROUTIINE INITIALIZES A NEW LIFE (OTHRINIT FALLS THROUGH TO HERE)\r
+LIFEINIT  JSR     CLEARFRT               ;SET UP FOR STARTING LIFE\r
+          JSR     INITPAC\r
+          JSR     INITMON\r
+          JSR     INITSPED\r
+          JSR     CLEARTUN\r
+          JSR     SETPAC\r
+          JSR     SETFRT\r
+          JMP     SETFLSH\r
+\r
+\r
+*  TURN THE SCREEN OFF\r
+SCREENOF  JSR     WAITVBL                ;WAIT TILL VBLANK STARTED\r
+          LDA     #$7F                   ;TURN GRAPHICS OFF\r
+          STA     CTRL\r
+\r
+          JSR     CLRSCRN                ;CLEAR OFF LIVES, FRUITS, AND MONSTERS\r
+\r
+          LDX     #$00                   ;CLEAR CHARACTER MAP, $1800-$1BFF\r
+          TXA\r
+SOLOOP    STA     $1800,X\r
+          STA     $1900,X\r
+          STA     $1A00,X\r
+          STA     $1B00,X\r
+          DEX\r
+          BNE     SOLOOP\r
+\r
+SOEND     STA     SCRNSTAT               ;ZERO SOME STATE\r
+          STA     KNLTEMP0\r
+          STA     KNLTEMP1\r
+          RTS\r
+\r
+\r
+*  TURN THE SCREEN OFF WITHOUT ZEROING THE SCREEN\r
+SCREENNO  JSR     WAITVBL                ;WAIT TILL VBLANK STARTED\r
+          LDA     #$7F                   ;TURN GRAPHICS OFF\r
+          STA     CTRL\r
+          LDA     #$00\r
+          BEQ     SOEND\r
+\r
+\r
+*  TURN THE SCREEN ON\r
+SCREENON  LDA     SCRNSTAT               ;SEE IF SCREEN WAS EVEN OFF\r
+          BNE     SOOUT\r
+\r
+          JSR     LOADER                 ;INITIALIZE KERNAL STATE\r
+          JSR     GETCOLOR               ;GET OUR COLORS\r
+\r
+          JSR     WAITVBL\r
+          LDA     #$FF                   ;SET THE KERNAL STATE\r
+          STA     KNLTEMP0\r
+          INC     SCRNSTAT               ;SAY THE SCREEN IS ON\r
+          LDA     #GRAPHON\r
+          STA     CTRL                   ;TURN GRAPHICS ON\r
+SOOUT     RTS\r
+\r
+\r
+*  A ROUTINE TO WATI TILL VBLANK\r
+WAITVBL   BIT     MSTAT                  ;IS VBLANK STARTED YET?\r
+          BPL     WAITVBL\r
+          BIT     MSTAT                  ;IS VBLANK STILL STARTED?\r
+          BPL     WAITVBL\r
+          RTS\r
+\r
+\r
+*  TURN MISCELLANEOUS GRAPHICS OFF.  THE MOVING OBJECTS AND INDICATORS ARE\r
+*  TURNED OFF.\r
+CLRSCRN   LDA     #OFFSCRN               ;TURN OFF MOVING OBJECTS\r
+          LDX     #$05\r
+CSMLOOP   STA     HPLIST,X\r
+          STA     DOLIST,X\r
+          DEX\r
+          BPL     CSMLOOP\r
+\r
+          LDY     #$0B                   ;PUT BONUS LIFE AND FRUIT INDICATORS\r
+          LDX     #$03                   ;  OFF SCREEN\r
+          LDA     #OFFSCRN\r
+CSBLOOP   STA     BDLIST0,X\r
+          STA     BDLIST1,X\r
+          INX\r
+          INX\r
+          INX\r
+          INX\r
+          DEY\r
+          BPL     CSBLOOP\r
+\r
+          RTS                            ;ALL DONE\r
+\r
+\r
+*  THIS ROUTINE WRITES ALL THE INDICATORS ON THE SCREEN\r
+WRTINDS   LDX     LEVEL                  ;SET TYPE OF FRUIT AT BOTTOM\r
+          CPX     #$07\r
+          BMI     WISETFRT\r
+          LDX     #$07\r
+WISETFRT  INX\r
+          STX     RACKFRT\r
+          JSR     LOADINDS               ;SET UP THE INDICATORS\r
+          JSR     WRTSCORE               ;WRITE THE SCORE\r
+          JMP     WRTLIVES               ;FALL THROUGH TO LIFEINIT\r
+\r
+\r
+*  THIS ROUTINE ADVANCES THE RACK\r
+NEXTRACK  JSR     CLEARTUN\r
+          JSR     FLASHBAR\r
+          LDA     AUTOPLAY               ;SEE IF IN AUTO-PLAY MODE\r
+          BNE     NRAUTO\r
+          LDX     ADJLEVEL\r
+          LDA     ANIMTAB,X              ;SEE IF ANIMATION DUE\r
+          BMI     NRCONT\r
+          JSR     ANIMATE                ;ANIMATE\r
+NRCONT    INC     LEVEL                  ;INCREMENT LEVEL\r
+          INC     ADJLEVEL               ;AND ADJUSTED LEVEL\r
+          LDA     ADJLEVEL               ;SEE IF OUT OF RANGE\r
+          CMP     #$0E\r
+          BMI     NRJMP0\r
+          LDA     #$06                   ;SET BACK TO LEVEL 6\r
+          STA     ADJLEVEL\r
+NRJMP0    JSR     SETRACK\r
+          JSR     RACKINIT               ;INIT THE NEW RACK\r
+          JSR     READY                  ;PUT PLAYER READY UP\r
+          JSR     WAIT\r
+          JMP     WCLEAR\r
+\r
+NRAUTO    INC     RACK                   ;AUTO-PLAY NEXT RACK\r
+          LDX     RACK\r
+          CPX     #NUMRACKS\r
+          BPL     NROVER\r
+          LDA     RACKLVL,X\r
+          STA     LEVEL\r
+          STA     ADJLEVEL\r
+          JMP     RACKINIT\r
+NROVER    LDX     #STACKPTR              ;ALL OVER - GO BACK TO TITLE PAGE\r
+          TXS\r
+          JMP     ATTRACT\r
+\r
+SETRACK   LDX     ADJLEVEL\r
+          LDA     RACKTAB,X              ;GET THE RACK\r
+          STA     RACK\r
+          RTS\r
+\r
+\r
+*  THIS ROUTINE INITIALIZES THE DISPLAY LISTS\r
+LOADDLST  LDX     #$58\r
+LDLLOOP0  LDA     DLISTS,X               ;INITIALIZE SCREEN AND INDICATOR LISTS\r
+          STA     DLIST0,X\r
+          STA     DLIST1,X\r
+          DEX\r
+          BPL     LDLLOOP0\r
+\r
+          LDX     #$06\r
+LDLLOOP1  LDA     TDLIST,X               ;INITIALIZE TOP DISPLAY LIST\r
+          STA     TOPDLIST,X\r
+          DEX\r
+          BPL     LDLLOOP1\r
+\r
+          LDX     #$6E\r
+LDLLOOP2  LDA     DLLIST,X\r
+          STA     DLL,X\r
+          DEX\r
+          BPL     LDLLOOP2\r
+\r
+          RTS\r
+\r
+\r
+*  THIS ROUTINE MOVES THE BLACK BARS OFF THE SCREEN\r
+BARSOFF   LDA     #OFFSCRN\r
+          STA     DLIST0+$20\r
+          STA     DLIST0+$24\r
+          STA     DLIST1+$20\r
+          STA     DLIST1+$24\r
+          RTS\r
+\r
+\r
+*  THIS ROUTINE FLASHES THE BAR COLOR\r
+FLASHBAR  LDY     #$02\r
+          LDX     RACK                   ;GET BAR COLOR\r
+FBLOOP    LDA     #BLACK                 ;TURN BAR OFF\r
+          STA     P0C2\r
+          JSR     FBWAIT                 ;PAUSE\r
+          LDA     BARCOLOR,X             ;TURN BAR ON\r
+          STA     P0C2\r
+          JSR     FBWAIT                 ;PAUSE\r
+          DEY\r
+          BPL     FBLOOP\r
+          RTS\r
+\r
+FBWAIT    LDA     RTLOCAL+1              ;WAIT A BIT FOR THE BAR FLASHING\r
+          CLC\r
+          ADC     #$0E\r
+          STA     TEMP16\r
+FBWLOOP   JSR     SEEBNORM\r
+          LDA     TEMP16\r
+          CMP     RTLOCAL+1\r
+          BPL     FBWLOOP\r
+          RTS\r
+\r
+\r
+*  THIS ROUTINE ZEROS OUT THE RAM\r
+ZERORAM   JSR     SCREENOF               ;TURN SCREEN OFF FIRST, ZERO $1800-1BFF\r
+\r
+          LDA     #$00\r
+          LDX     #$60                   ;ZERO OUT $A0-$FF\r
+ZRLOOP0   STA     $9F,X\r
+          DEX\r
+          BNE     ZRLOOP0\r
+ZRLOOP    STA     $1C00,X                ;ZERO OUT PAGES $1C00 AND $1D00\r
+          STA     $1D00,X\r
+          DEX\r
+          BNE     ZRLOOP\r
+          RTS\r
+\r
+\r
+*  THIS ROUTINE ZEROS OUT THE SCORE\r
+ZEROSCOR  LDX     #$05\r
+ZSCLOOP   LDA     INITSCOR,X\r
+          STA     P1SCORE,X\r
+          STA     P2SCORE,X\r
+          DEX\r
+          BPL     ZSCLOOP\r
+          RTS\r
+\r
+\r
+*  THIS ROUTINE SIMPLY DOES A BUSY-WAIT.  THIS IS USED TO HALT ACTION TEMPORARIL\r
+WAIT      LDA     RTLOCAL+1\r
+          CLC\r
+          ADC     #$40\r
+          STA     TEMP16\r
+WLOOP     JSR     SEEBNORM\r
+          LDA     TEMP16\r
+          CMP     RTLOCAL+1\r
+          BPL     WLOOP\r
+          RTS\r
+\r
+\r
+*  SWITCH DATA BETWEEN PLAYERS\r
+SWITCHPL  LDX     #$0B                   ;SWITCH PLAYER DEPENDANT DATA\r
+SPLLOOP   LDA     LIVES,X\r
+          LDY     BAKLIVES,X\r
+          STY     LIVES,X\r
+          STA     BAKLIVES,X\r
+          DEX\r
+          BPL     SPLLOOP\r
+\r
+          LDX     #$7F                   ;SWITCH DOT ARRAYS\r
+SDTLOOP   LDA     DOTARRAY,X\r
+          LDY     BAKDOTS,X\r
+          STA     BAKDOTS,X\r
+          TYA\r
+          STA     DOTARRAY,X\r
+          DEX\r
+          BPL     SDTLOOP\r
+\r
+          LDA     PLAYER                 ;SWITCH PLAYER\r
+          EOR     #$01\r
+          STA     PLAYER\r
+\r
+          LDA     LIVES                  ;SWITCH BACK IF NO LIVES LEFT\r
+          BMI     SWITCHPL\r
+          RTS\r
+\r
+\r
+*  ROUTINE TO LOAD MS PAC MAN FONT - ALSO INITIALIZES BLACK CHARACTERS\r
+LOADFONT  LDA     #L(MSFONT)             ;SET UP TEMP0 FOR READS FROM FONT\r
+          STA     TEMP0\r
+          LDA     #H(MSFONT)\r
+          STA     TEMP1\r
+          LDA     #$30                   ;SET UP TEMP2 FOR WRITES TO STAMP AREA\r
+          STA     TEMP2                  ;  FONT STARTS AT $30\r
+          LDA     #$90                   ;INDEX FOR OUTER LOOP - HOW MANY CHARS\r
+          STA     TEMP4                  ;  GET $60 CHARACTERS FROM FONT\r
+          LDY     #$00\r
+\r
+LFLOOP    LDA     #H(STAMPS+$500)        ;SET HI BYTE OF WRITE\r
+          STA     TEMP3\r
+          LDX     #$05                   ;INNER LOOP IS SIX BIG (SIZE OF CHAR)\r
+LFLOOP0   LDA     (TEMP0),Y              ;READ FROM FONT\r
+          STA     (TEMP2),Y              ;WRITE TO STAMPS\r
+          INC     TEMP0                  ;INCREMENT READ\r
+          BNE     LFLJMP0\r
+          INC     TEMP1\r
+LFLJMP0   DEC     TEMP3                  ;DECREMENT HI BYTE OF WRITE\r
+          DEX\r
+          BPL     LFLOOP0\r
+          INC     TEMP2                  ;INCREMENT TO NEXT RAM CHARACTER\r
+          DEC     TEMP4\r
+          BNE     LFLOOP\r
+\r
+          LDA     #$FF                   ;SET UP THE STAMP FOR BLACK BARS\r
+          STA     STAMPS+2               ;  CHARACTERS 2 AND 3\r
+          STA     STAMPS+3\r
+          STA     STAMPS+$102\r
+          STA     STAMPS+$103\r
+          STA     STAMPS+$202\r
+          STA     STAMPS+$203\r
+          STA     STAMPS+$302\r
+          STA     STAMPS+$303\r
+          STA     STAMPS+$402\r
+          STA     STAMPS+$403\r
+          STA     STAMPS+$502\r
+          STA     STAMPS+$503\r
+\r
+          LDA     #$00                   ;SET UP THE STAMP FOR BLANK AREA\r
+          STA     STAMPS+0               ;  CHARACTERS 2 AND 3\r
+          STA     STAMPS+1\r
+          STA     STAMPS+$100\r
+          STA     STAMPS+$101\r
+          STA     STAMPS+$200\r
+          STA     STAMPS+$201\r
+          STA     STAMPS+$300\r
+          STA     STAMPS+$301\r
+          STA     STAMPS+$400\r
+          STA     STAMPS+$401\r
+          STA     STAMPS+$500\r
+          STA     STAMPS+$501\r
+\r
+          LDX     #$1D                   ;ZERO OUT KERNAL LISTS\r
+          LDA     #$00\r
+LFLOOP1   STA     MSADDR,X\r
+          STA     FRTADDR,X\r
+          STA     M0ADDR,X\r
+          STA     M1ADDR,X\r
+          STA     M2ADDR,X\r
+          STA     M3ADDR,X\r
+          DEX\r
+          BPL     LFLOOP1\r
+\r
+          RTS\r
+\r
+\r
+*  THIS ROUTINE LOADS THE BITMAPS FOR THE INDICATORS AND SETS UP FRUIT INDS\r
+LOADINDS  LDA     #L(MSCHAR+48)          ;TEMP0 IS START OF MS PAC\r
+          STA     TEMP0\r
+          LDA     #H(MSCHAR+48)\r
+          STA     TEMP1\r
+          LDA     #$28\r
+          STA     TEMP4\r
+          JSR     LIBODY                 ;DO IT - WRITE THE MS PAC INDICATOR\r
+\r
+          LDA     #L(FRUITCHR)           ;TEMP0 IS START OF FRUIT\r
+          STA     TEMP0                  ;  ENTRY POINT FOR CHANGING FRUIT\r
+          LDA     #H(FRUITCHR)\r
+          STA     TEMP1\r
+\r
+          LDX     #$00                   ;WRITE THE FRUITS\r
+NFLOOP    LDA     FRTSTMP,X              ;WHERE IT'S GOING TO\r
+          STA     TEMP4\r
+          STX     TEMP15\r
+          JSR     LIBODY                 ;DO IT\r
+          LDX     TEMP15\r
+          LDA     TEMP0                  ;MOVE TO NEXT FRUIT STAMP\r
+          CLC\r
+          ADC     #24\r
+          STA     TEMP0\r
+          LDA     TEMP1\r
+          ADC     #$00\r
+          STA     TEMP1\r
+          INX\r
+          CPX     #$08\r
+          BMI     NFLOOP\r
+\r
+          LDX     STLEVEL                ;NOW - SET UP FRUIT INDS\r
+          BNE     LIFLOAD\r
+          LDA     RACKFRT                ;IF STARTING AT TDY BEAR AND GOING TO\r
+          CMP     #$07                   ;  BANANA, THEN DON'T DISPLAY TDY BEAR\r
+          BMI     LIFLOAD\r
+          INX\r
+LIFLOAD   LDY     #$2D                   ;INDEX INTO DISPLAY LISTS\r
+LIFLOOP   LDA     BDLIST0,Y              ;CHANGE PALETTE\r
+          AND     #$1F\r
+          ORA     FRTPAL,X\r
+          STA     BDLIST0,Y\r
+          STA     BDLIST1,Y\r
+          DEY\r
+          LDA     FRTSTMP,X              ;SET STAMP\r
+          STA     BDLIST0,Y\r
+          CLC\r
+          ADC     #$02\r
+          STA     BDLIST1,Y\r
+          DEY\r
+          DEY\r
+          DEY\r
+          INX\r
+          CPX     RACKFRT\r
+          BMI     LIFLOOP\r
+\r
+LIFOUT    RTS\r
+\r
+\r
+*  THIS ROUTINE DOES THE WORK FOR THE FRUIT AND PAC WRITING ROUTINES\r
+LIBODY    LDA     #H(STAMPS+$500)        ;SET TEMP8 TO DESTINATION\r
+          STA     TEMP9\r
+          LDA     TEMP0                  ;SET (TEMP2) TO POINT TO SECOND PART\r
+          CLC\r
+          ADC     #$0C\r
+          STA     TEMP2\r
+          LDA     TEMP1\r
+          ADC     #$00\r
+          STA     TEMP3\r
+\r
+          LDX     #$00                   ;AND DO IT\r
+          LDY     #$00\r
+LILOOP    LDA     TEMP4                  ;MOVING INTO STAMPS STARTING AT TEMP4\r
+          STA     TEMP8\r
+          LDA     (TEMP0),Y              ;UPPER STAMP FIRST BYTE\r
+          STA     (TEMP8,X)\r
+          INC     TEMP8\r
+          INY\r
+          LDA     (TEMP0),Y              ;UPPER STAMP SECOND BYTE\r
+          STA     (TEMP8,X)\r
+          INC     TEMP8\r
+          DEY\r
+          LDA     (TEMP2),Y              ;LOWER STAMP FIRST BYTE\r
+          STA     (TEMP8,X)\r
+          INC     TEMP8\r
+          INY\r
+          LDA     (TEMP2),Y              ;LOWER STAMP SECOND BYTE\r
+          STA     (TEMP8,X)\r
+          INC     TEMP8\r
+\r
+          INY                            ;GET SET FOR NEXT\r
+          DEC     TEMP9                  ;MOVE TO NEXT OUTPUT PAGE\r
+          LDA     TEMP9\r
+          CMP     #H(STAMPS)\r
+          BPL     LILOOP\r
+\r
+          RTS\r
+\r
+\r
+*  DEFAULT TEMPLATE FOR DISPLAY LIST\r
+DLISTS    DB      L(SCREEN),$60,H(SCREEN),$00+$04,$18      ;SCREEN - PLAY FIELD\r
+          DB      0,$20+$1E,H(STAMPS),OFFSCRN              ;MS PAC\r
+          DB      0,$40+$1E,H(STAMPS),OFFSCRN              ;FRUIT\r
+          DB      0,$60+$1E,H(STAMPS),OFFSCRN              ;MONSTER 0\r
+          DB      0,$80+$1E,H(STAMPS),OFFSCRN              ;MONSTER 1\r
+          DB      0,$A0+$1E,H(STAMPS),OFFSCRN              ;MONSTER 2\r
+          DB      0,$C0+$1E,H(STAMPS),OFFSCRN              ;MONSTER 3\r
+          DB      $02,$20+$1E,H(STAMPS),$10                ;BLACK BAR\r
+          DB      $02,$20+$1E,H(STAMPS),$88                ;BLACK BAR\r
+          DB      $00,$00\r
+          DB      $00,$20+$1E,H(STAMPS),LEFTSIDE-$01       ;INDICATOR ZONE\r
+          DB      $00,$20+$1E,H(STAMPS),LEFTSIDE+$08       ; 5 INDS WITH PAC PLT\r
+          DB      $00,$20+$1E,H(STAMPS),LEFTSIDE+$11\r
+          DB      $00,$20+$1E,H(STAMPS),LEFTSIDE+$1A\r
+          DB      $00,$20+$1E,H(STAMPS),LEFTSIDE+$23\r
+          DB      $00,$00+$1E,H(STAMPS),RGHTSIDE-$44       ;FRUIT INDICATORS\r
+          DB      $00,$00+$1E,H(STAMPS),RGHTSIDE-$3A       ;  STAMP AND PALETTES\r
+          DB      $00,$00+$1E,H(STAMPS),RGHTSIDE-$30       ;  MUST BE SET\r
+          DB      $00,$00+$1E,H(STAMPS),RGHTSIDE-$26\r
+          DB      $00,$00+$1E,H(STAMPS),RGHTSIDE-$1C\r
+          DB      $00,$00+$1E,H(STAMPS),RGHTSIDE-$12\r
+          DB      $00,$00+$1E,H(STAMPS),RGHTSIDE-$08\r
+          DB      $00,$00\r
+TDLIST    DB      L(SCORE),$60,H(SCORE),$00+$04,$18        ;SCORE DLIST\r
+          DB      $00,$00\r
+\r
+*  THIS IS THE DISPLAY LIST LIST.  THIS WILL BE DROPPED INTO RAM.\r
+DLLIST    DB      $0F,H(NULDLIST),L(NULDLIST)            ;16 BLANK LINES\r
+          DB      $08,H(NULDLIST),L(NULDLIST)            ;9 BLANK LINES\r
+          DB      $85,H(TOPDLIST),L(TOPDLIST)            ;SCORE ZONE\r
+          DB      $85,H(DLIST0),L(DLIST0)                ;PF ZONE - 0\r
+          DB      $85,H(DLIST1),L(DLIST1)                ;PF ZONE - 1\r
+          DB      $85,H(DLIST0),L(DLIST0)                ;PF ZONE - 0\r
+          DB      $85,H(DLIST1),L(DLIST1)                ;PF ZONE - 1\r
+          DB      $85,H(DLIST0),L(DLIST0)                ;PF ZONE - 0\r
+          DB      $85,H(DLIST1),L(DLIST1)                ;PF ZONE - 1\r
+          DB      $85,H(DLIST0),L(DLIST0)                ;PF ZONE - 0\r
+          DB      $85,H(DLIST1),L(DLIST1)                ;PF ZONE - 1\r
+          DB      $85,H(DLIST0),L(DLIST0)                ;PF ZONE - 0\r
+          DB      $85,H(DLIST1),L(DLIST1)                ;PF ZONE - 1\r
+          DB      $85,H(DLIST0),L(DLIST0)                ;PF ZONE - 0\r
+          DB      $85,H(DLIST1),L(DLIST1)                ;PF ZONE - 1\r
+          DB      $85,H(DLIST0),L(DLIST0)                ;PF ZONE - 0\r
+          DB      $85,H(DLIST1),L(DLIST1)                ;PF ZONE - 1\r
+          DB      $85,H(DLIST0),L(DLIST0)                ;PF ZONE - 0\r
+          DB      $85,H(DLIST1),L(DLIST1)                ;PF ZONE - 1\r
+          DB      $85,H(DLIST0),L(DLIST0)                ;PF ZONE - 0\r
+          DB      $85,H(DLIST1),L(DLIST1)                ;PF ZONE - 1\r
+          DB      $85,H(DLIST0),L(DLIST0)                ;PF ZONE - 0\r
+          DB      $85,H(DLIST1),L(DLIST1)                ;PF ZONE - 1\r
+          DB      $85,H(DLIST0),L(DLIST0)                ;PF ZONE - 0\r
+          DB      $85,H(DLIST1),L(DLIST1)                ;PF ZONE - 1\r
+          DB      $85,H(DLIST0),L(DLIST0)                ;PF ZONE - 0\r
+          DB      $85,H(DLIST1),L(DLIST1)                ;PF ZONE - 1\r
+          DB      $85,H(DLIST0),L(DLIST0)                ;PF ZONE - 0\r
+          DB      $85,H(DLIST1),L(DLIST1)                ;PF ZONE - 1\r
+          DB      $85,H(DLIST0),L(DLIST0)                ;PF ZONE - 0\r
+          DB      $85,H(DLIST1),L(DLIST1)                ;PF ZONE - 1\r
+          DB      $85,H(DLIST0),L(DLIST0)                ;PF ZONE - 0\r
+          DB      $05,H(DLIST1),L(DLIST1)                ;PF ZONE - 1\r
+          DB      $85,H(BDLIST0),L(BDLIST0)              ;INDICATOR ZONE - 0\r
+          DB      $85,H(BDLIST1),L(BDLIST1)              ;INDICATOR ZONE - 1\r
+          DB      $0F,H(NULDLIST),L(NULDLIST)            ;16 BLANK LINES\r
+          DB      $0F,H(NULDLIST),L(NULDLIST)            ;16 BLANK LINES\r
+\r
+*  COLORS FOR THE RACKS\r
+BARCOLOR  DB      PINK,BLUE,BROWN,DKBLUE\r
+OUTCOLOR  DB      LTPINK,LTBLUE,LTBROWN,LTGREEN\r
+DOTCOLOR  DB      BLUE,YELLOW,PINK,LTBLUE\r
+\r
+*  MAPPING FROM LEVEL TO RACK\r
+RACKTAB   DB      0,0,0,1,1,1,2,2,2,2,3,3,3,3\r
+ANIMTAB   DB      -1,-1,0,-1,-1,1,-1,-1,-1,2,-1,-1,-1,2\r
+\r
+*  MAPPING FROM RACK TO LEVEL FOR AUTO-PLAY\r
+RACKLVL   DB      $01,$03,$06,$0A\r
+\r
+*  TABLES TO INITIALIZE SCORES AND BONUSES\r
+INITSCOR  DB      $00,$00,$00,$00,$09,$99\r
+\r
+*  MAPPING OF FRUIT TO PALETTE AND STAMP\r
+FRTPAL    DB      $60,$60,$80,$A0,$60,$60,$C0,$20\r
+FRTSTMP   DB      $FC,$F8,$F4,$F0,$EC,$E8,$E4,$E0\r
diff --git a/INTRSECT.S b/INTRSECT.S
new file mode 100644 (file)
index 0000000..c36cd48
--- /dev/null
@@ -0,0 +1,152 @@
+*\r
+* INTRSECT.S      PAC-FRUIT AND PAC-MONSTER INTERSECT ROUTINES\r
+*\r
+\r
+* PFINTR          PAC-FRUIT INTERSECT ROUTINE\r
+*         IN:\r
+*         USES:\r
+\r
+PFINTR\r
+          LDA     FENABLE                ;MAKE SURE FRUIT ON\r
+          BEQ     PFIEND\r
+          LDA     FSCORE                 ;MAKE SURE FRUIT NOT SCORE\r
+          BNE     PFIEND\r
+\r
+          LDA     PHPOS\r
+          SEC\r
+          SBC     FHPOS\r
+          STA     TEMP0\r
+          BPL     PFINTR1\r
+          LDA     #0\r
+          SEC\r
+          SBC     TEMP0\r
+          STA     TEMP0                  ; TEMP0 = ABS(PHPOS-FHPOS)\r
+PFINTR1   CMP     #$06\r
+          BCS     PFIEND\r
+\r
+          LDA     PVPOS\r
+          SEC\r
+          SBC     FVPOS\r
+          STA     TEMP1\r
+          BPL     PFINTR2\r
+          LDA     #0\r
+          SEC\r
+          SBC     TEMP1\r
+          STA     TEMP1                  ; TEMP1 = ABS(PVPOS-FVPOS)\r
+PFINTR2   LDY     TEMP0\r
+          CMP     INTRSECT,Y\r
+          BCS     PFIEND\r
+\r
+          LDY     FFRUIT\r
+          LDA     FRTSCORH,Y\r
+          STA     TEMP11\r
+          LDA     FRTSCORL,Y\r
+          STA     TEMP12\r
+          JSR     ADDTOTAL\r
+          JMP     EATFRT\r
+\r
+PFIEND    RTS\r
+\r
+* PMINTR          PAC-MONSTER INTERSECT ROUTINE\r
+*         IN:\r
+*         USES:\r
+\r
+PMINTR\r
+          LDX     #3\r
+PMILOOP\r
+          LDA     PHPOS\r
+          SEC\r
+          SBC     M0HPOS,X\r
+          STA     TEMP0\r
+          BPL     PMINTR1\r
+          LDA     #0\r
+          SEC\r
+          SBC     TEMP0\r
+          STA     TEMP0                  ; TEMP0 = ABS(PHPOS-MHPOS)\r
+PMINTR1   CMP     #$06\r
+          BCS     PMIEND\r
+\r
+          LDA     PVPOS\r
+          SEC\r
+          SBC     M0VPOS,X\r
+          STA     TEMP1\r
+          BPL     PMINTR2\r
+          LDA     #0\r
+          SEC\r
+          SBC     TEMP1\r
+          STA     TEMP1                  ; TEMP1 = ABS(PVPOS-MVPOS)\r
+PMINTR2   LDY     TEMP0\r
+          CMP     INTRSECT,Y\r
+          BCS     PMIEND\r
+\r
+          LDA     M0STATE,X\r
+          BNE     PMIEND\r
+          LDA     M0BLUE,X\r
+          BNE     PMINTR3\r
+          JSR     KILLPAC\r
+          JMP     DECLIVES\r
+PMINTR3\r
+          CMP     #$08\r
+          BNE     PMIEND\r
+          JSR     MONDEATH\r
+          JSR     TURNEYES\r
+          LDY     GREEDCNT\r
+          LDA     MONSCORH,Y\r
+          STA     TEMP11\r
+          LDA     MONSCORL,Y\r
+          STA     TEMP12\r
+          JSR     ADDTOTAL\r
+          INC     GREEDCNT\r
+\r
+PMIEND    DEX\r
+          BPL     PMILOOP\r
+          RTS\r
+\r
+*\r
+* MONDEATH        -MONSTER DEATH CODE\r
+*         IN      X IS MONSTER NUMBER\r
+\r
+MONDEATH\r
+          JSR     SCORSTMP\r
+          JSR     ERASEPAC\r
+          JSR     CLEARTUN\r
+          LDA     #$11\r
+          JSR     DOTUNE\r
+          LDA     RTLOCAL\r
+          STA     RTSAVE\r
+          LDA     RTLOCAL+1\r
+          STA     RTSAVE+1\r
+\r
+          CLC\r
+          ADC     #1\r
+          STA     SCORWAIT\r
+          LDA     #60\r
+          STA     SCORTIME\r
+DEATHLP\r
+          JSR     SEEBNORM\r
+          LDA     RTLOCAL+1\r
+          CMP     SCORWAIT\r
+          BMI     DEATHLP\r
+          JSR     TIGHT\r
+          LDA     RTLOCAL+1\r
+          CLC\r
+          ADC     #1\r
+          STA     SCORWAIT\r
+DEATHEND\r
+          DEC     SCORTIME\r
+          BPL     DEATHLP\r
+\r
+          LDA     RTSAVE+1\r
+          STA     RTLOCAL+1\r
+          LDA     RTSAVE\r
+          STA     RTLOCAL\r
+          STX     TEMP16\r
+          JSR     WRITEPAC\r
+          LDX     TEMP16\r
+          RTS\r
+\r
+INTRSECT  DB      $05,$04,$03,$02,$01,$00\r
+MONSCORH  DB      $00,$00,$00,$01\r
+MONSCORL  DB      $20,$40,$80,$60\r
+FRTSCORH  DB      $00,$00,$00,$00,$00,$01,$02,$05\r
+FRTSCORL  DB      $05,$10,$20,$50,$70,$00,$00,$00\r
diff --git a/KERNAL.S b/KERNAL.S
new file mode 100644 (file)
index 0000000..619f445
--- /dev/null
+++ b/KERNAL.S
@@ -0,0 +1,344 @@
+\r
+* KERNAL          THE KERNAL AND LOADER FOR MARIA MS PAC-MAN\r
+\r
+\r
+*  THIS IS THE DLI FOR THE FRUIT - CHANGES COLORS FOR FRUIT\r
+DLIFRUIT  LDA     #RED                   ;ADJUST COLORS FOR FRUIT PALETTES\r
+          STA     Z3C1\r
+          STA     Z4C1\r
+          LDA     #WHITE\r
+          STA     Z3C2\r
+          STA     Z4C2\r
+          STA     Z6C2\r
+          LDA     #ORANGE\r
+          STA     Z5C1\r
+          LDA     #BROWN                 ;ADJUST COLORS FOR FRUIT PALETTES\r
+          STA     Z3C3\r
+          STA     Z5C2\r
+          STA     Z6C3\r
+          LDA     #GREEN                 ;ADJUST COLORS FOR FRUIT PALETTES\r
+          STA     Z4C3\r
+          STA     Z5C3\r
+          STA     Z6C1\r
+          LDA     #YELLOW                ;MAKE SURE BANANA AND MS GET RIGHT CLR\r
+          STA     Z1C1\r
+          STA     Z7C1\r
+\r
+          LDA     #$00                   ;SET 'VBLANK' TO HAPPEN NEXT\r
+          STA     KNLTEMP0\r
+          JMP     DLIOUT\r
+\r
+\r
+*  MAINTAIN THE ON-SCREEN DISPLAY\r
+DLI       PHA                            ;STACK REGISTERS\r
+          TXA\r
+          PHA\r
+\r
+          LDA     KNLTEMP0               ;SEE WHAT DLI HANDLER TO GO TO\r
+          BEQ     OTHERDLI\r
+          BMI     TOPDLIS\r
+          LDX     KNLTEMP1               ;'NORMAL' DLI, SEE WHICH ZONE\r
+          CPX     #LASTZONE\r
+          BPL     DLIFRUIT               ;IF ZONES FINISHED, THEN SET FRUIT CLR\r
+          TXA\r
+          AND     #$01\r
+          BEQ     DLI0\r
+          JMP     DLI1\r
+\r
+\r
+*  THIS IS THE DLI FOR THE SCORE\r
+DLISCORE  LDA     #WHITE                 ;SET UP SCORE COLORS\r
+          STA     Z0C3\r
+          LDA     #ORANGE\r
+          STA     Z0C2\r
+          LDA     #BLACK\r
+          STA     BACKGRND\r
+\r
+\r
+*  THIS ROUTINE TAKES CARE OF DLI HANDLERS WHERE THE OTHER DISPLAY LIST IS\r
+*  MODIFIED WHILE THE CURRENT DISPLAY LIST IS BEING USED\r
+DLI0      LDA     M0ADDR,X               ;UPDATE MONSTER 0 STAMP\r
+          STA     DLIST0+$0D\r
+          LDA     M1ADDR,X               ;UPDATE MONSTER 1 STAMP\r
+          STA     DLIST0+$11\r
+          LDA     M2ADDR,X               ;UPDATE MONSTER 2 STAMP\r
+          STA     DLIST0+$15\r
+          LDA     M3ADDR,X               ;UPDATE MONSTER 3 STAMP\r
+          STA     DLIST0+$19\r
+          LDA     SCRLOW,X               ;UPDATE PLAY FIELD LOW ADDR\r
+          STA     DLIST0+$00\r
+          LDA     SCRHI,X                ;UPDATE PLAY FIELD HI ADDR\r
+          STA     DLIST0+$02\r
+          LDA     MSADDR,X               ;UPDATE MS STAMP\r
+          STA     DLIST0+$05\r
+          LDA     FRTADDR,X              ;UPDATE FRUIT STAMP\r
+          STA     DLIST0+$09\r
+          INC     KNLTEMP1\r
+          JMP     DLIOUT\r
+\r
+\r
+*  THIS HANDLES THE 'ODD-BALL' DLIS, VBLANK AND NULL\r
+OTHERDLI  LDX     KNLTEMP1               ;SEE WHAT TO DO\r
+          BEQ     DLIWAIT                ;IF ZERO, THEN 'VERTICAL BLANK'\r
+          BPL     DLILAST                ;IF NEGATIVE, WE ARE WAITING FOR SYNC\r
+\r
+DLIWAIT   JMP     DLIOUT                 ;WAITING FOR DLI'S TO SYNC\r
+\r
+\r
+*  THIS TAKES CARE OF DLIS ON THE TOP OF THE SCREEN\r
+TOPDLIS   LDX     KNLTEMP1\r
+          BEQ     DLISCORE\r
+\r
+          LDA     #$01                   ;SET UP FOR NORMAL DLIS\r
+          STA     KNLTEMP0\r
+          LDA     P0C3                   ;RESTORE PLAYFIELD COLORS\r
+          STA     Z0C3\r
+          LDA     P0C2\r
+          STA     Z0C2\r
+\r
+\r
+*  THIS IS THE NORMAL DLI TO SET UP FOR ODD ZONES\r
+DLI1      LDA     M0ADDR,X               ;UPDATE MONSTER 0 STAMP\r
+          STA     DLIST1+$0D\r
+          LDA     M1ADDR,X               ;UPDATE MONSTER 1 STAMP\r
+          STA     DLIST1+$11\r
+          LDA     M2ADDR,X               ;UPDATE MONSTER 2 STAMP\r
+          STA     DLIST1+$15\r
+          LDA     M3ADDR,X               ;UPDATE MONSTER 3 STAMP\r
+          STA     DLIST1+$19\r
+          LDA     SCRLOW,X               ;UPDATE PLAY FIELD LOW ADDR\r
+          STA     DLIST1+$00\r
+          LDA     SCRHI,X                ;UPDATE PLAY FIELD HI ADDR\r
+          STA     DLIST1+$02\r
+          LDA     MSADDR,X               ;UPDATE MS STAMP\r
+          STA     DLIST1+$05\r
+          LDA     FRTADDR,X              ;UPDATE FRUIT STAMP\r
+          STA     DLIST1+$09\r
+          INC     KNLTEMP1\r
+          JMP     DLIOUT\r
+\r
+\r
+*  THIS ROUTINE TAKES CARE OF THE LAST DLI ON THE SCREEN, THE 'VERTICAL BLANK\r
+*  ROUTINE'.\r
+DLILAST   LDA     #$00\r
+          STA     KNLTEMP1               ;TURN DLI'S OFF TILL WE ARE DONE\r
+          STA     LDRTEMP7               ;NO NOTICES OF VBLANK YET\r
+          TYA                            ;WE NEED TO STACK Y\r
+          PHA\r
+\r
+          JSR     RAND                   ;UPDATE RANDOM NUMBER\r
+          JSR     LOADER                 ;LOAD UP NEXT FRAME\r
+\r
+          INC     RTLOCAL+1              ;INCREMENT CLOCK\r
+          BNE     DLITUNE\r
+          INC     RTLOCAL\r
+\r
+DLITUNE   JSR     TUNER                  ;DO TUNES\r
+\r
+          LDA     LDRTEMP7               ;IS VBLANK STARTED YET?\r
+          BNE     DLLCOLOR\r
+DLLWAIT   BIT     MSTAT                  ;IF NOT, BUSY WAIT\r
+          BPL     DLLWAIT\r
+\r
+DLLCOLOR  JSR     GETCOLOR               ;UPDATE PALETTES\r
+\r
+          DEC     KNLTEMP0               ;SET SCORE DLI TO HAPPEN NEXT\r
+\r
+          PLA                            ;UNSTACK AND LEAVE\r
+          TAY\r
+DLIOUT    PLA                            ;THIS IS WHERE MOST DLI'S LEAVE\r
+          TAX\r
+          PLA\r
+NULLRTI   RTI\r
+\r
+\r
+*  UPDATE BASE HEADER INFORMATION FOR NEXT RUN OF KERNAL\r
+LOADER    LDX     #$05\r
+LUPDATLP  LDA     DOLIST,X               ;SEE IF ANYTHING TO DO\r
+          BNE     LULBODY\r
+          JMP     LULNEXT\r
+\r
+LULBODY   TXA\r
+          ASL     A\r
+          ASL     A\r
+          TAY                            ;Y = 4*X\r
+          LDA     HPLIST,X               ;UPDATE HPOS\r
+          STA     DLIST0+8,Y\r
+          STA     DLIST1+8,Y\r
+\r
+          LDA     STDATALO,X             ;GET RID OF OLD STAMP DATA\r
+          STA     LDRTEMP0\r
+          LDA     STDATAHI,X\r
+          STA     LDRTEMP1\r
+          LDA     #$00\r
+          LDY     OLDZONE,X\r
+          STA     (LDRTEMP0),Y\r
+          INY\r
+          STA     (LDRTEMP0),Y\r
+          INY\r
+          STA     (LDRTEMP0),Y\r
+\r
+          LDA     VZLIST,X               ;PUT IN THE NEW STAMP DATA\r
+          STA     OLDZONE,X              ;SAVE AWAY WHERE IT IS\r
+          TAY\r
+          LDA     STAMPOFF,X\r
+          STA     (LDRTEMP0),Y\r
+          INY\r
+          CLC\r
+          ADC     #$02\r
+          STA     (LDRTEMP0),Y\r
+          INY\r
+          CLC\r
+          ADC     #$02\r
+          STA     (LDRTEMP0),Y\r
+\r
+          LDA     #L(STAMPS)             ;AND NOW, UPDATE THE STAMPS\r
+          CLC\r
+          ADC     STAMPOFF,X\r
+          STA     LDRTEMP0               ;(LDRTEMP0) IS THE OUTPUT\r
+          LDA     SLLIST,X               ;(LDRTEMP2) IS THE INPUT\r
+          STA     LDRTEMP2\r
+          LDA     SHLIST,X\r
+          STA     LDRTEMP3\r
+          LDA     VOLIST,X               ;FIND THE OFFSET - HOW MANY LEADING 0'S\r
+          STA     LDRTEMP5\r
+          STA     LDRTEMP6\r
+          STX     LDRTEMP4               ;STORE X\r
+\r
+          LDA     #H(STAMPS+$500)        ;RESET OUTPUT POINTER TO BEGINNING\r
+          STA     LDRTEMP1\r
+          LDX     #$05\r
+LSLOOP0   LDY     #$00\r
+          DEC     LDRTEMP5               ;SEE IF ANY STARTING BLANK PADDING\r
+          BMI     LSLJMP00\r
+          TYA                            ;BLANK PADDING\r
+          STA     (LDRTEMP0),Y\r
+          INY\r
+          STA     (LDRTEMP0),Y\r
+          JMP     LDLJMP01\r
+LSLJMP00  LDA     (LDRTEMP2),Y           ;GET DATA\r
+          STA     (LDRTEMP0),Y\r
+          INY\r
+          LDA     (LDRTEMP2),Y           ;GET DATA\r
+          STA     (LDRTEMP0),Y\r
+          INC     LDRTEMP2               ;INCREASE LDRTEMP2 BY 2\r
+          INC     LDRTEMP2\r
+          BNE     LDLJMP01               ;SEE IF PAGE BOUNDARY\r
+          INC     LDRTEMP3\r
+LDLJMP01  DEC     LDRTEMP1               ;INCREASE LDRTEMP0 BY 1 PAGE\r
+          DEX\r
+          BPL     LSLOOP0\r
+\r
+          INC     LDRTEMP0               ;MOVE TO NEXT STAMP\r
+          INC     LDRTEMP0\r
+          LDA     #H(STAMPS+$500)        ;RESET OUTPUT POINTER TO BEGINNING\r
+          STA     LDRTEMP1\r
+          LDX     #$05\r
+LSLOOP1   LDY     #$00\r
+          LDA     (LDRTEMP2),Y           ;GET DATA\r
+          STA     (LDRTEMP0),Y\r
+          INY\r
+          LDA     (LDRTEMP2),Y           ;GET DATA\r
+          STA     (LDRTEMP0),Y\r
+          INC     LDRTEMP2               ;INCREASE LDRTEMP2 BY 2\r
+          INC     LDRTEMP2\r
+          BNE     LDLPAGE1               ;SEE IF PAGE BOUNDARY\r
+          INC     LDRTEMP3\r
+LDLPAGE1  DEC     LDRTEMP1               ;INCREASE LDRTEMP0 BY 1 PAGE\r
+          DEX\r
+          BPL     LSLOOP1\r
+\r
+          INC     LDRTEMP0               ;MOVE TO NEXT STAMP\r
+          INC     LDRTEMP0\r
+          LDA     #H(STAMPS+$500)        ;RESET OUTPUT POINTER TO BEGINNING\r
+          STA     LDRTEMP1\r
+          LDX     #$05\r
+LSLOOP2   LDY     #$00\r
+          DEC     LDRTEMP6               ;SEE IF TIME FOR ANY ENDING BLANKS\r
+          BPL     LSLJMP20\r
+          TYA                            ;BLANK PADDING\r
+          STA     (LDRTEMP0),Y\r
+          INY\r
+          STA     (LDRTEMP0),Y\r
+          JMP     LSLJMP21\r
+LSLJMP20  LDA     (LDRTEMP2),Y           ;GET DATA\r
+          STA     (LDRTEMP0),Y\r
+          INY\r
+          LDA     (LDRTEMP2),Y           ;GET DATA\r
+          STA     (LDRTEMP0),Y\r
+          INC     LDRTEMP2               ;INCREASE LDRTEMP2 BY 2\r
+          INC     LDRTEMP2\r
+          BNE     LSLJMP21               ;SEE IF PAGE BOUNDARY\r
+          INC     LDRTEMP3\r
+LSLJMP21  DEC     LDRTEMP1               ;INCREASE LDRTEMP0 BY 1 PAGE\r
+          DEX\r
+          BPL     LSLOOP2\r
+\r
+          LDX     LDRTEMP4\r
+          LDA     #$00\r
+          STA     DOLIST,X               ;DON'T DO SAME AGAIN - Y IS STILL 0\r
+\r
+LULNEXT   BIT     MSTAT                  ;SEE IF VBLANK STARTED YET\r
+          BPL     LULNJMP\r
+          INC     LDRTEMP7               ;STARTED\r
+LULNJMP   DEX\r
+          BMI     LULOUT\r
+          JMP     LUPDATLP\r
+LULOUT    RTS\r
+\r
+\r
+*  RANDOM NUMBER GENERATOR - BOTH MAKES A NEW ONE AND LEAVES IT IN A\r
+RAND      ADC     RTLOCAL+1              ;MAKE A PRETTY RANDOM VALUE\r
+          ADC     NEWRAND\r
+          ADC     OLDRAND\r
+          PHA\r
+          LDA     NEWRAND                ;BACK UP NEWRAND\r
+          STA     OLDRAND\r
+          PLA\r
+          STA     NEWRAND                ;NEW VALUE - LEFT IN A\r
+          RTS\r
+\r
+\r
+*  THIS ROUTINE HITS THE PALETTES EVERY FRAME\r
+GETCOLOR  LDX     #$02\r
+          LDY     #$07\r
+GCLOOP    LDA     P0C1-2,X\r
+          STA     Z0C1-2,X\r
+          INX\r
+          LDA     P0C1-2,X\r
+          STA     Z0C1-2,X\r
+          INX\r
+          LDA     P0C1-2,X\r
+          STA     Z0C1-2,X\r
+          INX\r
+          INX\r
+          DEY\r
+          BPL     GCLOOP\r
+          RTS\r
+\r
+\r
+*  TABLE OF LOW AND HI BYTES OF PLAYFIELD ADDRESSES FOR ZONES\r
+SCRLOW    DB      $00,$1C,$38,$54,$70,$8C,$A8,$C4\r
+          DB      $E0,$FC,$18,$34,$50,$6C,$88,$A4\r
+          DB      $C0,$DC,$F8,$14,$30,$4C,$68,$84\r
+          DB      $A0,$BC,$D8,$F4,$10,$2C,$48\r
+SCRHI     DB      H(SCREEN+$000),H(SCREEN+$000),H(SCREEN+$000),H(SCREEN+$000)\r
+          DB      H(SCREEN+$000),H(SCREEN+$000),H(SCREEN+$000),H(SCREEN+$000)\r
+          DB      H(SCREEN+$000),H(SCREEN+$000),H(SCREEN+$100),H(SCREEN+$100)\r
+          DB      H(SCREEN+$100),H(SCREEN+$100),H(SCREEN+$100),H(SCREEN+$100)\r
+          DB      H(SCREEN+$100),H(SCREEN+$100),H(SCREEN+$100),H(SCREEN+$200)\r
+          DB      H(SCREEN+$200),H(SCREEN+$200),H(SCREEN+$200),H(SCREEN+$200)\r
+          DB      H(SCREEN+$200),H(SCREEN+$200),H(SCREEN+$200),H(SCREEN+$200)\r
+          DB      H(SCREEN+$300),H(SCREEN+$300),H(SCREEN+$300)\r
+\r
+*  TABLE FROM STAMP INDEX TO WHERE THE STAMP STARTS IN STAMP PAGE\r
+STAMPOFF  DB      4,10,16,22,28,34\r
+\r
+*  TABLE FROM STAMP INDEX TO WHAT TABLE THE STAMP OFFSET GOES IN\r
+STDATALO  DB      L(MSADDR),L(FRTADDR),L(M0ADDR),L(M1ADDR)\r
+          DB      L(M2ADDR),L(M3ADDR)\r
+STDATAHI  DB      H(MSADDR),H(FRTADDR),H(M0ADDR),H(M1ADDR)\r
+          DB      H(M2ADDR),H(M3ADDR)\r
+\r
+*  THE LAST ZONE OF THE MAZE\r
+LASTZONE  EQU     30\r
diff --git a/LOADMAP.S b/LOADMAP.S
new file mode 100644 (file)
index 0000000..7ad0766
--- /dev/null
+++ b/LOADMAP.S
@@ -0,0 +1,400 @@
+\r
+*  LOADMAP.S      ROUTINES DEALING WITH MAZE MAINTENANCE\r
+\r
+*  MAZE DRAWING ROUTINE: CALLED WITH THE NUMBER OF THE DESIRED MAZE IN RACK,\r
+*  WILL DRAW THE APPROPRIATE MAZE.\r
+\r
+          ;ZERO PAGE TEMPORARY VARIABLES.\r
+          ; TEMP0-7  : EIGHT BYTE SHIFT REGISTER\r
+          ; TEMP8-9  : POINTER TO MAZE DATA\r
+          ; TEMP10-11: POINTER TO PLAY FIELD (CHARACTER MAP)\r
+          ; TEMP12   : TEMPORARY VALUE STORAGE FOR COMPUTATIONS\r
+          ; TEMP13   : OFFSET TO PLAYFIELD POINTER FOR LEFT HALF OF MAZE\r
+          ; TEMP14   : OFFSET TO PLAYFIELD POINTER FOR RIGHT HALF OF MAZE\r
+          ; TEMP15   : COUNTER TO KEEP TRACK OF CURRENT ROW\r
+\r
+LOADMAP   LDA     #$00\r
+          STA     DOTS                   ;INITIALIZE DOT COUNTER\r
+          STA     DOTS+1\r
+\r
+          LDY     RACK\r
+          LDA     MAZEBEGL,Y\r
+          STA     TEMP8\r
+          LDA     MAZEBEGH,Y\r
+          STA     TEMP8+1\r
+\r
+          LDA     #0\r
+          STA     TEMP13\r
+          LDA     #WIDTH-1\r
+          STA     TEMP14\r
+\r
+          JSR     LDSHFTL\r
+\r
+NEXTCOL   JSR     LDSHFTH\r
+\r
+          LDA     #L(SCREEN)\r
+          STA     TEMP10\r
+          LDA     #H(SCREEN)\r
+          STA     TEMP10+1\r
+\r
+          LDA     #HEIGHT\r
+          STA     TEMP15\r
+\r
+NEXTROW   LDA     TEMP0+0\r
+          AND     #$03\r
+          STA     TEMP12\r
+          LDA     TEMP0+4\r
+          ASL     A\r
+          ASL     A\r
+          AND     #$0C\r
+          ORA     TEMP12\r
+          TAX\r
+\r
+          LDA     TEMP13\r
+          CMP     #10\r
+          BCC     NOTPEN\r
+          LDA     TEMP15\r
+          SBC     #15\r
+          CMP     #5\r
+          BCS     NOTPEN\r
+\r
+;PEN\r
+          TXA\r
+          ADC     #$10\r
+          TAX\r
+\r
+NOTPEN\r
+;NORMAL PLAYFIELD\r
+          TXA                            ;SEE IF SHOULD BE AN EMPTY CHARACTER\r
+          CMP     #$0F                   ;  NEAR THE BORDER INSTEAD OF FULL\r
+          BNE     DOCHAR\r
+          LDA     TEMP13\r
+          CMP     #$03\r
+          BPL     DOCHAR\r
+          LDX     #$00                   ;IT SHOULD BE EMPTY\r
+\r
+DOCHAR    LDA     LEFT,X\r
+          LDY     TEMP13\r
+          STA     (TEMP10),Y\r
+          LDA     RIGHT,X\r
+          LDY     TEMP14\r
+          STA     (TEMP10),Y\r
+\r
+          JSR     SHIFT\r
+\r
+          CLC\r
+          LDA     TEMP10\r
+          ADC     #WIDTH\r
+          STA     TEMP10\r
+          BCC     NOINC\r
+          INC     TEMP10+1\r
+\r
+NOINC     DEC     TEMP15\r
+          BNE     NEXTROW\r
+\r
+          INC     TEMP13\r
+          DEC     TEMP14\r
+          LDA     TEMP13\r
+          CMP     TEMP14\r
+          BCS     LOADDONE\r
+          JSR     SHIFT\r
+          JSR     SHIFT\r
+          JMP     NEXTCOL\r
+\r
+SHIFT     LDX     #$07\r
+          LSR     TEMP0+7\r
+SHIFT1    ROR     TEMP0-1,X\r
+          DEX\r
+          BNE     SHIFT1\r
+          RTS\r
+\r
+LOADDONE  LDA     #DOORCHAR              ;PEN ENTRANCE CHARACTER\r
+          STA     SCREEN+28*11+13        ;ENTRANCE AT 11TH ROW, 13TH COLUMN\r
+          STA     SCREEN+28*11+14        ; AND 11TH ROW, 14TH COLUMN.\r
+\r
+*  THIS CODE TAKES CARE OF PUTTING UP THE DOTS\r
+          LDA     #$00                   ;INITIALIZE EVERYTHING TO ZERO\r
+          TAY\r
+          STA     TEMP0\r
+          STA     TEMP1\r
+\r
+LMDLOOP   LDA     DOTARRAY,Y             ;GET NEW SET OF DOT BITS\r
+          STA     TEMP15\r
+          JSR     LMDOTS                 ;DO EACH OF THE 8 BITS\r
+          JSR     LMDOTS\r
+          JSR     LMDOTS\r
+          JSR     LMDOTS\r
+          JSR     LMDOTS\r
+          JSR     LMDOTS\r
+          JSR     LMDOTS\r
+          JSR     LMDOTS\r
+          INY\r
+          CPY     #$78\r
+          BNE     LMDLOOP\r
+\r
+*  AND FINALLY - DO THE POWER DOTS\r
+          LDY     RACK                   ;GET THE RACK\r
+          LDA     EDZONE0,Y\r
+          STA     TEMP0\r
+          LDA     EDCOL0,Y\r
+          STA     TEMP1\r
+          JSR     LMEDOTS                ;ZONE 0 COLUMN 0\r
+          LDA     EDCOL1,Y\r
+          STA     TEMP1\r
+          JSR     LMEDOTS                ;ZONE 0 COLUMN 1\r
+          LDA     EDZONE1,Y\r
+          STA     TEMP0\r
+          JSR     LMEDOTS                ;ZONE 1 COLUMN 1\r
+          LDA     EDCOL0,Y\r
+          STA     TEMP1\r
+          JSR     LMEDOTS                ;ZONE 1 COLUMN 0\r
+\r
+          RTS\r
+\r
+\r
+*  THIS ROUTINE CHECKS FOR A PARTICULAR POWER DOT\r
+LMEDOTS   JSR     GETCHAR                ;SEE WHAT'S THERE\r
+          CMP     #DOTCHAR               ;IS IT A DOT?\r
+          BNE     LMEDOUT\r
+          LDX     #EDOTCHAR              ;PUT AN EDOT DOWN\r
+          JSR     PLOPCHAR\r
+LMEDOUT   RTS\r
+\r
+\r
+*  THIS ROUTINE LOADS IN A PARTICULAR DOT\r
+LMDOTS    ASL     TEMP15                 ;GET A BIT OFF\r
+          BCC     LMDINC                 ;SEE IF A DOT HERE\r
+          LDX     #DOTCHAR               ;DOT HERE\r
+          JSR     PLOPCHAR               ;PUT IT IN\r
+          INC     DOTS                   ;ADD IT TO THE DOT COUNTER\r
+          BNE     LMDINC\r
+          INC     DOTS+1\r
+LMDINC    JMP     NEXTPLOP               ;INCREMENT COLUMN\r
+\r
+\r
+LEFT      DB    $50,$30,$31,$32,$33,$34,$50,$35,$36,$50,$37,$38,$39,$3A,$3B,$3C\r
+PLEFT     DB    $50,$3E,$3F,$40,$41,$42,$50,$50,$43,$50,$44,$50,$45,$50,$50,$50\r
+RIGHT     DB    $50,$33,$36,$39,$30,$34,$50,$3A,$31,$50,$37,$3B,$32,$35,$38,$3C\r
+PRIGHT    DB    $50,$41,$43,$45,$3E,$42,$50,$50,$3F,$50,$44,$50,$40,$50,$50,$50\r
+\r
+LDSHFTL   LDX     #$03\r
+          BNE     LDSHFT1\r
+LDSHFTH   LDX     #$07\r
+LDSHFT1   LDY     #$03\r
+LDSHFT2   LDA     (TEMP8),Y\r
+          STA     TEMP0,X\r
+          DEX\r
+          DEY\r
+          BPL     LDSHFT2\r
+          CLC\r
+          LDA     TEMP8\r
+          ADC     #$04\r
+          STA     TEMP8\r
+          BCC     LDSHFT3\r
+          INC     TEMP8+1\r
+LDSHFT3   RTS\r
+\r
+\r
+; <=======================================================================>\r
+\r
+*  THIS ROUTINE LOADS IN THE DOTS FOR A NEW RACK INTO DOTARRAY\r
+*  USES:  TEMP0-1, X\r
+LOADDOTS  LDX     RACK                   ;SET UP FOR TRANSFER\r
+          LDA     DOTBEGL,X\r
+          STA     TEMP0\r
+          LDA     DOTBEGH,X\r
+          STA     TEMP1\r
+\r
+          LDY     #$7F\r
+LDDLOOP   LDA     (TEMP0),Y              ;AND MOVE THEM\r
+          STA     DOTARRAY,Y\r
+          DEY\r
+          BPL     LDDLOOP\r
+          RTS\r
+\r
+\r
+; <=======================================================================>\r
+\r
+*  THIS ROUTINE USES THE CHARACTER MAP IN SCREEN TO UPDATE THE INFORMATION\r
+*  IN DOTARRAY.\r
+SAVEDOTS  LDA     #$00                   ;INITIALIZE EVERYTHING TO ZERO\r
+          TAY\r
+          STA     TEMP0\r
+          STA     TEMP1\r
+\r
+SDLOOP    JSR     SDDOTS                 ;DO EACH OF THE 8 BITS\r
+          JSR     SDDOTS\r
+          JSR     SDDOTS\r
+          JSR     SDDOTS\r
+          JSR     SDDOTS\r
+          JSR     SDDOTS\r
+          JSR     SDDOTS\r
+          JSR     SDDOTS\r
+          LDA     TEMP15\r
+          STA     DOTARRAY,Y\r
+          INY\r
+          CPY     #$78\r
+          BNE     SDLOOP\r
+          RTS\r
+\r
+\r
+*  THIS ROUTINE CHECKS FOR A PARTICULAR DOT\r
+SDDOTS    LDA     TEMP1                  ;SEE IF OUT OF RANGE\r
+          CMP     #$1C\r
+          BPL     SDNODOTS\r
+          JSR     GETCHAR                ;FIND OUT WHAT IS HERE\r
+          CMP     #DOTCHAR\r
+          BMI     SDNODOTS\r
+          SEC                            ;SHIFT IN A 1\r
+          JMP     SDDOIT\r
+SDNODOTS  CLC                            ;SHIFT IN A 0\r
+SDDOIT    ROL     TEMP15\r
+\r
+*  THIS ROUTINE INCREMENTS THE COLUMN FOR ROUTINES USING PUT/PLOPCHAR\r
+NEXTPLOP  INC     TEMP1                  ;NEXT COLUMN\r
+          LDA     TEMP1\r
+          CMP     #$20\r
+          BMI     NCOUT\r
+          LDA     #$00                   ;NEXT ZONE\r
+          STA     TEMP1\r
+          INC     TEMP0\r
+NCOUT     RTS\r
+\r
+; <=======================================================================>\r
+\r
+;TABLES OF POINTERS TO TABLES...\r
+\r
+MAZEBEGL  DB      L(MAZE1),L(MAZE2),L(MAZE3),L(MAZE4)\r
+MAZEBEGH  DB      H(MAZE1),H(MAZE2),H(MAZE3),H(MAZE4)\r
+\r
+DOTBEGL   DB      L(DOT1),L(DOT2),L(DOT3),L(DOT4)\r
+DOTBEGH   DB      H(DOT1),H(DOT2),H(DOT3),H(DOT4)\r
+\r
+; <=======================================================================>\r
+\r
+MAZE1     DB      $7F,$FE,$FC,$7F,$41,$FE,$3C,$40,$41,$FE,$3C,$40\r
+          DB      $09,$00,$00,$4F,$09,$00,$00,$4F,$C9,$F3,$24,$4F\r
+          DB      $01,$12,$24,$40,$01,$12,$24,$40,$4F,$92,$27,$4F\r
+          DB      $41,$00,$04,$41,$41,$00,$04,$41,$49,$F2,$24,$49\r
+          DB      $09,$F2,$20,$48,$09,$F2,$20,$48,$C9,$F3,$3C,$4F\r
+\r
+DOT1      DB      $00,$00,$00,$00,$7E,$7F,$E7,$E0\r
+          DB      $42,$40,$24,$20,$42,$40,$24,$20\r
+          DB      $7F,$FF,$FF,$E0,$12,$09,$04,$80\r
+          DB      $12,$09,$04,$80,$13,$F9,$FC,$80\r
+          DB      $10,$00,$00,$80,$10,$00,$00,$80\r
+          DB      $10,$00,$00,$80,$10,$00,$00,$80\r
+          DB      $10,$00,$00,$80,$10,$00,$00,$80\r
+          DB      $10,$00,$00,$80,$10,$00,$00,$80\r
+          DB      $10,$00,$00,$80,$10,$00,$00,$80\r
+          DB      $10,$00,$00,$80,$1F,$C0,$3F,$80\r
+          DB      $10,$40,$20,$80,$10,$40,$20,$80\r
+          DB      $7F,$F9,$FF,$E0,$42,$09,$04,$20\r
+          DB      $42,$09,$04,$20,$42,$79,$E4,$20\r
+          DB      $42,$40,$24,$20,$42,$40,$24,$20\r
+          DB      $7F,$FF,$FF,$E0,$00,$00,$00,$00\r
+\r
+; <=======================================================================>\r
+\r
+MAZE2     DB      $F9,$FF,$3F,$7F,$09,$10,$3C,$41,$09,$10,$3C,$41\r
+          DB      $C9,$93,$00,$48,$49,$90,$00,$48,$49,$90,$27,$4F\r
+          DB      $41,$02,$20,$40,$41,$02,$20,$40,$4F,$3E,$E7,$49\r
+          DB      $01,$00,$24,$48,$01,$00,$24,$48,$C9,$F3,$00,$49\r
+          DB      $09,$F2,$00,$41,$09,$F2,$3C,$41,$79,$F2,$3C,$4F\r
+\r
+DOT2      DB      $00,$00,$00,$00,$00,$7F,$E0,$00\r
+          DB      $00,$40,$20,$00,$00,$40,$20,$00\r
+          DB      $7F,$F9,$FF,$E0,$40,$49,$20,$20\r
+          DB      $40,$49,$20,$20,$4F,$CF,$3F,$20\r
+          DB      $48,$00,$01,$20,$48,$00,$01,$20\r
+          DB      $7E,$00,$07,$E0,$02,$00,$04,$00\r
+          DB      $02,$00,$04,$00,$7E,$00,$07,$E0\r
+          DB      $42,$00,$04,$20,$42,$00,$04,$20\r
+          DB      $72,$00,$04,$E0,$12,$00,$04,$80\r
+          DB      $12,$00,$04,$80,$1F,$F0,$FF,$80\r
+          DB      $10,$10,$80,$80,$10,$10,$80,$80\r
+          DB      $1E,$70,$E7,$80,$12,$40,$24,$80\r
+          DB      $12,$40,$24,$80,$73,$F9,$FC,$E0\r
+          DB      $42,$09,$04,$20,$42,$09,$04,$20\r
+          DB      $7F,$FF,$FF,$E0,$00,$00,$00,$00\r
+\r
+; <=======================================================================>\r
+\r
+MAZE3     DB      $FF,$FC,$FF,$7F\r
+          DB      $81,$00,$20,$40\r
+          DB      $81,$00,$20,$40\r
+          DB      $99,$9C,$07,$49\r
+          DB      $09,$10,$04,$49\r
+          DB      $09,$10,$E4,$49\r
+          DB      $C9,$83,$00,$40\r
+          DB      $09,$82,$00,$40\r
+          DB      $09,$F2,$3C,$7F\r
+          DB      $41,$00,$04,$41\r
+          DB      $41,$00,$04,$41\r
+          DB      $4F,$F2,$24,$49\r
+          DB      $01,$F2,$20,$48\r
+          DB      $01,$F2,$20,$48\r
+          DB      $79,$F2,$3C,$4F\r
+\r
+DOT3      DB      $00,$00,$00,$00,$7F,$CF,$3F,$E0\r
+          DB      $40,$49,$20,$20,$40,$49,$20,$20\r
+          DB      $4F,$F9,$FF,$20,$79,$09,$09,$E0\r
+          DB      $09,$09,$09,$00,$09,$FF,$F9,$00\r
+          DB      $78,$00,$01,$E0,$40,$00,$00,$20\r
+          DB      $40,$00,$00,$20,$40,$00,$00,$20\r
+          DB      $40,$00,$00,$20,$40,$00,$00,$20\r
+          DB      $40,$00,$00,$20,$40,$00,$00,$20\r
+          DB      $40,$00,$00,$20,$40,$00,$00,$20\r
+          DB      $40,$00,$00,$20,$7E,$79,$E7,$E0\r
+          DB      $12,$40,$24,$80,$12,$40,$24,$80\r
+          DB      $73,$F9,$FC,$E0,$42,$09,$04,$20\r
+          DB      $42,$09,$04,$20,$7E,$79,$E7,$E0\r
+          DB      $42,$40,$24,$20,$42,$40,$24,$20\r
+          DB      $7E,$7F,$E7,$E0,$00,$00,$00,$00\r
+\r
+; <=======================================================================>\r
+\r
+MAZE4     DB      $FF,$4F,$FE,$7F\r
+          DB      $01,$4E,$3E,$40\r
+          DB      $01,$4E,$3E,$40\r
+          DB      $79,$40,$00,$4F\r
+          DB      $41,$40,$00,$41\r
+          DB      $41,$F2,$39,$41\r
+          DB      $09,$02,$20,$48\r
+          DB      $09,$02,$20,$48\r
+          DB      $C9,$9F,$27,$4F\r
+          DB      $01,$02,$04,$48\r
+          DB      $01,$02,$04,$48\r
+          DB      $79,$F2,$E4,$49\r
+          DB      $09,$F0,$00,$41\r
+          DB      $09,$F0,$00,$41\r
+          DB      $C9,$F3,$3C,$79\r
+\r
+DOT4      DB      $00,$00,$00,$00,$7F,$FF,$FF,$E0\r
+          DB      $48,$40,$21,$20,$48,$40,$21,$20\r
+          DB      $4F,$CF,$3F,$20,$42,$49,$24,$20\r
+          DB      $42,$49,$24,$20,$7E,$79,$E7,$E0\r
+          DB      $10,$00,$00,$80,$10,$00,$00,$80\r
+          DB      $1E,$00,$07,$80,$02,$00,$04,$00\r
+          DB      $02,$00,$04,$00,$02,$00,$04,$00\r
+          DB      $02,$00,$04,$00,$02,$00,$04,$00\r
+          DB      $02,$00,$04,$00,$1E,$00,$07,$80\r
+          DB      $12,$00,$04,$80,$13,$C0,$3C,$80\r
+          DB      $10,$40,$20,$80,$10,$40,$20,$80\r
+          DB      $7F,$C0,$3F,$E0,$42,$40,$24,$20\r
+          DB      $42,$40,$24,$20,$4E,$7F,$E7,$20\r
+          DB      $48,$09,$01,$20,$48,$09,$01,$20\r
+          DB      $7F,$F9,$FF,$E0,$00,$00,$00,$00\r
+\r
+; <=======================================================================>\r
+\r
+          ;CONSTANT VALUES FOR MS.PACMAN\r
+WIDTH     EQU     28\r
+HEIGHT    EQU     30\r
+\r
+*  ZONES AND COLUMNS FOR THE ENERGY DOTS - INDEXED BY RACK\r
+EDZONE0   DB      $03,$04,$03,$03\r
+EDZONE1   DB      $19,$19,$16,$1A\r
+EDCOL0    DB      $01,$01,$01,$01\r
+EDCOL1    DB      $1A,$1A,$1A,$1A\r
+\r
diff --git a/MACRO.S b/MACRO.S
new file mode 100644 (file)
index 0000000..e8d0cad
--- /dev/null
+++ b/MACRO.S
@@ -0,0 +1,35 @@
+FILL      MACRO   ADDR,DATA,COUNT        ;THIS FILLS AN AREA WITH A CONSTANT\r
+          LDA     &DATA\r
+          LDX     &COUNT\r
+F&INDX    STA     &ADDR-1,X\r
+          DEX\r
+          BNE     F&INDX\r
+          ENDM\r
+LOAD      MACRO   ADDR1,ADDR2,COUNT      ;THIS MOVES DATA FROM ONE AREA TO ANOTH\r
+          LDX     &COUNT\r
+L&INDX    LDA     &ADDR2-1,X\r
+          STA     &ADDR1-1,X\r
+          DEX\r
+          BNE     L&INDX\r
+          ENDM\r
+PFILL     MACRO   ADDR,DATA,PAGENUM      ;THIS FILLS A NUMBER OF PAGES\r
+          LDA     #H(&ADDR)              ;TEMP0 AND TEMP1 ARE USED\r
+          STA     TEMP1\r
+          LDA     #L(&ADDR)\r
+          STA     TEMP0\r
+          LDA     &DATA\r
+          LDX     &PAGENUM\r
+          JSR     PFILLIT\r
+          ENDM\r
+PLOAD     MACRO   ADDR,ADDR2,PAGENUM     ;THIS LOADS A NUMBER OF PAGES\r
+          LDA     #H(&ADDR)              ;TEMP0 - TEMP3 ARE USED\r
+          STA     TEMP1\r
+          LDA     #L(&ADDR)\r
+          STA     TEMP0\r
+          LDA     #H(&ADDR2)\r
+          STA     TEMP3\r
+          LDA     #L(&ADDR2)\r
+          STA     TEMP2\r
+          LDX     &PAGENUM\r
+          JSR     PLOADIT\r
+          ENDM\r
diff --git a/MAIN.S b/MAIN.S
new file mode 100644 (file)
index 0000000..ec8a6fc
--- /dev/null
+++ b/MAIN.S
@@ -0,0 +1,222 @@
+\r
+*         MAIN ROUTINE FOR MS PAC MAN\r
+\r
+MAIN      LDA     #$17                   ;LOCK IN MARIA MODE\r
+          STA     INPTCTRL\r
+          SEI\r
+          CLD\r
+          LDX     #STACKPTR\r
+          TXS                            ;SET STACK POINTER\r
+          JSR     SCREENOF               ;TURN GRAPHICS OFF\r
+          LDA     #$00\r
+          STA     OFFSET                 ;FOR FUTURE EXPANSION\r
+          STA     INPTCTRL               ;TO MAKE JOYSTICKS NOT FREEZE\r
+          JSR     STRTINIT               ;ENTRY TO MS PAC MAN\r
+\r
+ATTRACT   JSR     DOTITLE                ;START ATTRACT MODE\r
+          JSR     HOLDSCOR               ;SHOW HI SCORE TABLES\r
+          LDA     #$01\r
+          STA     AUTOPLAY\r
+\r
+          JSR     GAMEINIT\r
+          JMP     AGAIN\r
+\r
+START     LDA     #$00                   ;START GAME PLAY\r
+          STA     AUTOPLAY\r
+          JSR     GAMEINIT\r
+          JSR     READY                  ;PUT PLAYER READY UP\r
+          LDA     #$00                   ;SET UP STARTING TUNE\r
+          JSR     DOTUNE\r
+          LDA     #$01\r
+          JSR     DOTUNE\r
+STLOOP    JSR     SEEBNORM\r
+          LDA     TUNON                  ;WAIT TILL TUNE OVER\r
+          BNE     STLOOP\r
+          JSR     WCLEAR                 ;GET RID OF PLAYER READY\r
+\r
+AGAIN     LDA     GAMEOVER               ;SEE IF GAME OVER\r
+          BEQ     AGSKP0\r
+          JMP     ENDGAME\r
+AGSKP0    JSR     SEEBNORM               ;SEE IF SELECT OR START HIT\r
+          LDA     RTLOCAL+1              ;CHECK EVENTS AGAINST TIMERS\r
+          CMP     PACWAIT\r
+          BMI     AGSKP1\r
+          JSR     MOVEPAC\r
+          LDA     RTLOCAL+1\r
+AGSKP1    CMP     FRTWAIT\r
+          BMI     AGSKP2\r
+          JSR     MOVEFRT\r
+          LDA     RTLOCAL+1\r
+AGSKP2    CMP     FLSHWAIT\r
+          BMI     AGSKP3\r
+          JSR     FLASHDOT\r
+          LDA     RTLOCAL+1\r
+AGSKP3    CMP     MONWAIT\r
+          BMI     AGOUT\r
+          JSR     MONSTER\r
+AGOUT\r
+          JMP     AGAIN\r
+\r
+\r
+*  END OF GAME HANDLER\r
+ENDGAME   LDA     #$00                   ;SET CONTROL TO JOYSTICK 0\r
+          STA     PLAYER\r
+          LDA     HSCHERE                ;IF HSC HERE, DON'T WASTE TIME WITH MSG\r
+          BNE     EGOUT\r
+\r
+          JSR     ALLOVER                ;WRITE GAME OVER\r
+          LDA     RTLOCAL                ;WAIT A BIT BEFORE TITLE PAGE\r
+          CLC\r
+          ADC     #$01\r
+          STA     TEMP16\r
+EGJMP0    JSR     SEEBENDG               ;GAME OVER - WAIT FOR SOMETHING\r
+          LDA     TEMP16\r
+          CMP     RTLOCAL\r
+          BPL     EGJMP0\r
+EGOUT     JSR     HNEWSCOR               ;SEE IF ANY SCORES QUALIFY FOR HI SCORE\r
+          JMP     DOATRACT               ;AND GO BACK TO ATTRACT MODE\r
+\r
+\r
+*  PAUSE BUTTON HAS BEEN HIT, WAIT TILL BUTTON HIT AGAIN\r
+PAUSE     LDA     RTLOCAL                ;STACK CLOCK\r
+          PHA\r
+          LDA     RTLOCAL+1\r
+          PHA\r
+          TXA                            ;STORE X\r
+          PHA\r
+\r
+          JSR     STOPTUN                ;TURN SOUNDS OFF\r
+\r
+          LDX     RTLOCAL                ;SET UP TIMER FOR GRAPHICS OFF\r
+          DEX\r
+PLOOPA    JSR     SEEBALL                ;SEE IF RESET OR SELECT HIT\r
+          CPX     RTLOCAL\r
+          BNE     PLJMP0\r
+          JSR     SCREENNO               ;TOO LONG A WAIT, TURN GRAPHICS OFF\r
+\r
+PLJMP0    JSR     GETJOY                 ;SEE IF USER WANTS GRAPHICS BACK ON\r
+          LDA     BUTSTATE               ;IS BUTTON PUSHED?\r
+          BNE     PLGRAFON\r
+          LDA     NEWDIR                 ;IS JOYSTICK MOVED?\r
+          CMP     #DCENTER\r
+          BEQ     PLJMP1\r
+PLGRAFON  JSR     SCREENON               ;TURN GRAPHICS ON IF NEEDED\r
+          LDX     RTLOCAL                ;RESET TIMER\r
+          DEX\r
+\r
+PLJMP1    LDA     DBPAUSE                ;SEE IF WE ARE DEBOUNCING PAUSE\r
+          BEQ     PLNORM\r
+          LDA     SWCHB                  ;SEE IF IT HAS BEEN RELEASED\r
+          AND     #$08\r
+          EOR     #$08\r
+          STA     DBPAUSE                ;FALL THROUGH TO SEEBALL\r
+          JMP     PLOOPA\r
+\r
+PLNORM    LDA     SWCHB                  ;SEE IF PAUSE BUTTON HIT\r
+          AND     #$08\r
+          BNE     PLOOPA                 ;IF NOT, TRY AGAIN\r
+\r
+          JSR     STARTTUN               ;TURN TUNES ON\r
+          JSR     SCREENON               ;TURN GRAPHICS ON IF NEEDED\r
+          PLA                            ;UNSTACK X\r
+          TAX\r
+          PLA                            ;UNSTACK CLOCK\r
+          STA     RTLOCAL+1\r
+          PLA\r
+          STA     RTLOCAL\r
+          LDA     #$01\r
+          STA     DBPAUSE                ;AND, OF COURSE, DEBOUNCE PAUSE SWITCH\r
+          RTS\r
+\r
+\r
+*  THIS ROUTINE CHECKS TO SEE IF TIME TO START OUT END GAME\r
+SEEBENDG  JSR     GETJOY                 ;SEE IF BUTTON PUSHED\r
+          LDA     BUTSTATE\r
+          BNE     DOSTART\r
+          JMP     SEEBALL                ;CHECK FOR SELECT AND RESET\r
+\r
+\r
+*  THIS ROUTINE CHECKS TO SEE IF TIME TO START OUT OF ATTRACT\r
+SEEBAUTO  JSR     GETJOY                 ;SEE IF BUTTON PUSHED\r
+          LDA     BUTSTATE\r
+          BNE     DOSTART\r
+          LDA     NEWDIR                 ;SEE IF JOYSTICK MOVED\r
+          CMP     #DCENTER\r
+          BNE     DOMENU\r
+          JMP     SEEBALL                ;CHECK FOR SELECT AND RESET\r
+\r
+\r
+*  THIS ROUTINE CHECKS TO SEE IF SELECT OR RESET HIT\r
+SEEBNORM  LDA     AUTOPLAY               ;SEE IF AUTOPLAY\r
+          BNE     SEEBAUTO\r
+          LDA     DBPAUSE                ;SEE IF WE ARE DEBOUNCING PAUSE\r
+          BNE     SBNDBPSE\r
+          LDA     SWCHB                  ;SEE IF PAUSE BUTTON HIT\r
+          AND     #$08\r
+          BNE     SEEBALL                ;IF NOT, FALL THROUGH TO SEEBALL CODE\r
+          LDA     #$01\r
+          STA     DBPAUSE\r
+          JMP     PAUSE                  ;WAIT TILL WE'RE UN-PAUSED\r
+\r
+SBNDBPSE  LDA     SWCHB                  ;SEE IF IT HAS BEEN RELEASED\r
+          AND     #$08\r
+          EOR     #$08\r
+          STA     DBPAUSE                ;FALL THROUGH TO SEEBALL\r
+\r
+\r
+*  THIS LOOKS FOR SELECT AND RESET - USED BY ALL\r
+SEEBALL   LDA     DBSELECT               ;SEE IF WE ARE DEBOUNCING SELECT\r
+          BNE     SBADBSEL\r
+          LDA     SWCHB                  ;SEE IF SELECT SWITCH HIT\r
+          AND     #$02                   ;SEE IF BIT 1 OFF\r
+          BNE     SBRESET\r
+          LDA     #$01                   ;SET DEBOUNCE VAR\r
+          STA     DBSELECT\r
+          JMP     DOMENU                 ;SELECT\r
+\r
+SBADBSEL  LDA     SWCHB                  ;SEE IF IT HAS BEEN RELEASED\r
+          AND     #$02\r
+          EOR     #$02\r
+          STA     DBSELECT\r
+\r
+SBRESET   LDA     DBRESET                ;SEE IF WE ARE DEBOUNCING RESET\r
+          BNE     SBADBRES\r
+          LDA     SWCHB                  ;SEE IF RESET SWITCH HIT\r
+          AND     #$01                   ;SEE IF BIT 0 OFF\r
+          BNE     SBAOUT\r
+          LDA     #$01                   ;SET DEBOUNCE VAR\r
+          STA     DBRESET\r
+          JMP     DOSTART                ;START\r
+\r
+SBADBRES  LDA     SWCHB                  ;SEE IF IT HAS BEEN RELEASED\r
+          AND     #$01\r
+          EOR     #$01\r
+          STA     DBRESET\r
+\r
+SBAOUT    RTS\r
+\r
+\r
+*  THIS ROUTINE CHECKS TO SEE IF TIME TO START OUT OF THE MENU\r
+SEEBMENU  JSR     GETJOY                 ;SEE IF BUTTON PUSHED\r
+          LDA     BUTSTATE\r
+          BEQ     SBRESET\r
+          JMP     DOSTART\r
+\r
+\r
+*  START A GAME\r
+DOSTART   LDX     #STACKPTR              ;START THE GAME\r
+          TXS\r
+          JMP     START\r
+\r
+\r
+*  GO TO THE MENU\r
+DOMENU    LDX     #STACKPTR              ;DO THE MENU\r
+          TXS\r
+          JMP     MENU\r
+\r
+\r
+*  GO TO THE TITLE PAGE\r
+DOATRACT  LDX     #STACKPTR              ;GO TO ATTRACT MODE\r
+          TXS\r
+          JMP     ATTRACT\r
+\r
diff --git a/MARIAOS.S b/MARIAOS.S
new file mode 100644 (file)
index 0000000..f4323f5
--- /dev/null
+++ b/MARIAOS.S
@@ -0,0 +1,86 @@
+\r
+*  MARIAOS        MARIA DATA LOCATION DEFINITIONS\r
+\r
+*  NOTE THE FOLLOWING WIERD THINGS ABOUT THE RAM:\r
+*           $00-$3F <=> $100-$13F\r
+*           $80-$FF <=> $180-$1FF\r
+*           $40-$FF <=> $2040-$20FF\r
+*         $140-$1FF <=> $2140-$21FF\r
+\r
+*  TIA REGISTERS\r
+INPTCTRL  EQU     $01                    ;INPUT CONTROL\r
+INPT4     EQU     $0C                    ;BITS 7        PLAYER 0 BUTTON\r
+INPT5     EQU     $0D                    ;BITS 7        PLAYER 1 BUTTON\r
+AUDC0     EQU     $15                    ;BITS     3210 AUDIO CONTROL 0\r
+AUDC1     EQU     $16                    ;BITS     3210 AUDIO CONTROL 1\r
+AUDF0     EQU     $17                    ;BITS    43210 AUDIO FREQUENCY 0\r
+AUDF1     EQU     $18                    ;BITS    43210 AUDIO FREQUENCY 1\r
+AUDV0     EQU     $19                    ;BITS     3210 AUDIO VOLUME 0\r
+AUDV1     EQU     $1A                    ;BITS     3210 AUDIO VOLUME 1\r
+\r
+*  MARIA REGISTERS\r
+BACKGRND  EQU     $20                    ;BACKGROUND COLOR\r
+Z0C1      EQU     $21                    ;PALETTE 0, COLOR 1\r
+Z0C2      EQU     $22                    ;PALETTE 0, COLOR 2\r
+Z0C3      EQU     $23                    ;PALETTE 0, COLOR 3\r
+WSYNC     EQU     $24                    ;FAST MARIA WSYNC STROBE             WO\r
+Z1C1      EQU     $25                    ;PALETTE 1, COLOR 1\r
+Z1C2      EQU     $26                    ;PALETTE 1, COLOR 2\r
+Z1C3      EQU     $27                    ;PALETTE 1, COLOR 3\r
+MSTAT     EQU     $28                    ;BIT 6 IN VBLANK, BIT ? IN DISPLAY   RO\r
+Z2C1      EQU     $29                    ;PALETTE 2, COLOR 1\r
+Z2C2      EQU     $2A                    ;PALETTE 2, COLOR 2\r
+Z2C3      EQU     $2B                    ;PALETTE 2, COLOR 3\r
+DPPH      EQU     $2C                    ;DISPLAY LIST POINTER HIGH           WO\r
+Z3C1      EQU     $2D                    ;PALETTE 3, COLOR 1\r
+Z3C2      EQU     $2E                    ;PALETTE 3, COLOR 2\r
+Z3C3      EQU     $2F                    ;PALETTE 3, COLOR 3\r
+DPPL      EQU     $30                    ;DISPLAY LIST POINTER LOW            WO\r
+Z4C1      EQU     $31                    ;PALETTE 4, COLOR 1\r
+Z4C2      EQU     $32                    ;PALETTE 4, COLOR 2\r
+Z4C3      EQU     $33                    ;PALETTE 4, COLOR 3\r
+CHARBASE  EQU     $34                    ;CHARACTER MODE HIGH POINTER         WO\r
+Z5C1      EQU     $35                    ;PALETTE 5, COLOR 1\r
+Z5C2      EQU     $36                    ;PALETTE 5, COLOR 2\r
+Z5C3      EQU     $37                    ;PALETTE 5, COLOR 3\r
+OFFSET    EQU     $38                    ;NOT USED ******\r
+Z6C1      EQU     $39                    ;PALETTE 6, COLOR 1\r
+Z6C2      EQU     $3A                    ;PALETTE 6, COLOR 2\r
+Z6C3      EQU     $3B                    ;PALETTE 6, COLOR 3\r
+CTRL      EQU     $3C                    ;BIT 7 CHARACTER WIDTH, BIT 6 BCNT   WO\r
+Z7C1      EQU     $3D                    ;PALETTE 7, COLOR 1\r
+Z7C2      EQU     $3E                    ;PALETTE 7, COLOR 2\r
+Z7C3      EQU     $3F                    ;PALETTE 7, COLOR 3\r
+\r
+*  FREE RAM - $40-$FF\r
+\r
+*  ALIASED RAM - $100-$13F\r
+\r
+*  STACK - $140-$1FF\r
+\r
+*  6532 TIMERS AND PORTS\r
+\r
+SWCHA     EQU     $280                   ;JOYSTICKS\r
+*         BIT 7   PLAYER 0 EAST IF CLEAR\r
+*         BIT 6            WEST\r
+*         BIT 5            SOUTH\r
+*         BIT 4            NORTH\r
+*         BIT 3   PLAYER 1 EAST IF CLEAR\r
+*         BIT 2            WEST\r
+*         BIT 1            SOUTH\r
+*         BIT 0            NORTH\r
+\r
+SWCHB     EQU     $282                   ;CONSOLE SWITCHES\r
+*         BIT 7   PLAYER 1 DIFFICULTY A IF SET, B IF CLEAR\r
+*         BIT 6   PLAYER 2 DIFFICULTY A IF SET, B IF CLEAR\r
+*         BIT 3   BLACK AND WHITE VS COLOR - COLOR WHEN SET\r
+*         BIT 1   GAME SELECT - CLEAR WHEN PRESSED\r
+*         BIT 0   GAME RESET - CLEAR WHEN PRESSED\r
+\r
+CTLSWA    EQU     $281\r
+CTLSWB    EQU     $283\r
+INTIM     EQU     $284                   ;INTERVAL TIMER IN\r
+TIM8T     EQU     $295                   ;TIMER 8T WRITE OUT\r
+TIM64T    EQU     $296                   ;TIMER 64T WRITE OUT\r
+TIM64TI   EQU     $29E                   ;INTERRUPT TIMER 64T\r
+\r
diff --git a/MDOIT.S b/MDOIT.S
new file mode 100644 (file)
index 0000000..237e226
--- /dev/null
+++ b/MDOIT.S
@@ -0,0 +1,50 @@
+JE\r
+LMARIAOS\r
+LMSDEF\r
+WR:MS.S\r
+LMSCHAR\r
+W\r
+LMAIN\r
+LINIT\r
+W\r
+LMSMOVE\r
+LFRUIT\r
+W\r
+LMONSTER\r
+LPATH\r
+W\r
+LSPEED\r
+LINTRSECT\r
+W\r
+LANIMATE\r
+W\r
+LTITLE\r
+LHIGH\r
+W\r
+LUTIL\r
+LTUNES\r
+W\r
+LKERNAL\r
+LGETJOY\r
+W\r
+LPUTCHAR\r
+LLOADMAP\r
+W\r
+LEND\r
+W\r
+JA\r
+SE\r
+MS.S\r
+MACRO\r
+R:1:MS.A\r
+\r
+\r
+JL\r
+S\r
+1:MS.A\r
+\r
+R:1:MS.Z\r
+\r
+\r
+\r
+J^^MUP\r
diff --git a/MGET.S b/MGET.S
new file mode 100644 (file)
index 0000000..42ddddc
--- /dev/null
+++ b/MGET.S
@@ -0,0 +1,25 @@
+JU\r
+MNH:PAC;HIGH,R:$\r
+MNH:PAC;MDOIT,R:$\r
+MNH:PAC;MUP,R:$\r
+MNH:PAC;MARIAOS,R:$\r
+MNH:PAC;MSDEF,R:$\r
+MNH:PAC;MAIN,R:$\r
+MNH:PAC;INIT,R:$\r
+MNH:PAC;MSMOVE,R:$\r
+MNH:PAC;FRUIT,R:$\r
+MNH:PAC;MONSTER,R:$\r
+MNH:PAC;PATH,R:$\r
+MNH:PAC;SPEED,R:$\r
+MNH:PAC;INTRSECT,R:$\r
+MNH:PAC;UTIL,R:$\r
+MNH:PAC;TUNES,R:$\r
+MNH:PAC;KERNAL,R:$\r
+MNH:PAC;GETJOY,R:$\r
+MNH:PAC;PUTCHAR,R:$\r
+MNH:PAC;LOADMAP,R:$\r
+MNH:PAC;MSCHAR,R:$\r
+MNH:PAC;ANIMATE,R:$\r
+MNH:PAC;TITLE,R:$\r
+MNH:PAC;END,R:$\r
+MNH:PAC;MACRO,R:$\r
diff --git a/MONSTER.S b/MONSTER.S
new file mode 100644 (file)
index 0000000..b753ec3
--- /dev/null
+++ b/MONSTER.S
@@ -0,0 +1,1020 @@
+*\r
+*  MONSTER.S       BASIC MONSTER CODE FOR MS PAC-MAN\r
+*\r
+\r
+* SETMON, SET THE NEXT INTERUPT\r
+SETMON\r
+          LDA     RTLOCAL+1\r
+          CLC\r
+          ADC     #WAITMON\r
+          STA     MONWAIT\r
+          RTS\r
+\r
+* MAIN LOOP FOR MONSTER ALGORITM, JUST CALL DOMONSTR WITH X=3->0\r
+MONSTER   JSR     MONTUNE\r
+          JSR     MONBEFOR\r
+          CLC\r
+          LDX     #3\r
+MONSTRLP  JSR     MONLOOP                ; TOP OF MONSTER LOOP\r
+          DEX\r
+          BPL     MONSTRLP\r
+          JMP     MONAFTER\r
+\r
+\r
+*  MAKE SURE THE MONSTER TUNE IS PLAYING\r
+MONTUNE   LDA     #$0A\r
+          CMP     TUNINDEX               ;MAKE SURE IT ISN'T PLAYING\r
+          BEQ     MTOUT\r
+          CMP     TUNINDEX+1\r
+          BEQ     MTOUT\r
+          JSR     DOTUNE                 ;JUST TRY TO PUT IT OUT\r
+MTOUT     RTS\r
+\r
+\r
+* MONBEFOR        -STUFF AT TOP OF MONSTER LOOP\r
+*\r
+\r
+MONBEFOR  JSR     SETMON\r
+          JSR     INCMSPED\r
+          LDA     ISBLUE\r
+          JSR     CHKBLUE                ;SEE IF TIME TO DO SOMETHING WITH BLUE\r
+          LDA     BLUWAIT                ;DO NOT CHECK FOR REVERSAL IF BLUE\r
+          BNE     MOREMON\r
+NOTBLUE\r
+          INC     NORMTIME+1\r
+          BNE     CHKREV\r
+          INC     NORMTIME\r
+CHKREV\r
+          LDA     NORMTIME\r
+          CMP     REVWAIT\r
+          BCC     MOREMON\r
+\r
+          LDA     NORMTIME+1\r
+          CMP     REVWAIT+1\r
+          BCC     MOREMON\r
+\r
+          LDA     REVWAIT\r
+          CMP     #$FF\r
+          BEQ     MOREMON\r
+\r
+          JMP     MONFLIP\r
+\r
+MOREMON\r
+MONLPEND  RTS\r
+\r
+* MONAFTER        -STUFF AT BOTTOM OF MONSTER LOOP\r
+*\r
+\r
+MONAFTER\r
+          JSR     PMINTR\r
+          JMP     RELEASE\r
+\r
+* MONLOOP         - MONSTER PROCESSING LOOP\r
+*         IN:     X IS THE MONSTER NUMBER\r
+*         OUT:\r
+*         USES:   EVERYTHING EXCEPT X\r
+\r
+MONLOOP   JSR     CHKMON                 ; TOP OF MONSTER LOOP\r
+          BEQ     MONLPEND               ;JUST AN RTS\r
+\r
+          LDA     M0STATE,X              ; CHECK THE MONSTER STATE\r
+          CMP     #MSTLVPEN\r
+          BMI     MONSTR1\r
+          JMP     MMVPEN                 ; IT'S IN THE PEN, SO SPCL CASE IT\r
+MONSTR1\r
+          LDA     M0OFF,X                ;MAKE SURE WE ARE AT THE CENTER\r
+          CMP     #3\r
+          BNE     MONSTRMV\r
+          LDA     M0HPOS,X\r
+          AND     #3\r
+          CMP     #1\r
+          BNE     MONSTRMV\r
+          LDA     M0FLIP,X               ;SEE IF MONSTER IS TO BE FLIPPED\r
+          BEQ     MONSTRZZ\r
+          LDA     M0DIR,X\r
+          EOR     #$02\r
+          STA     M0DIR,X\r
+          LDA     #$00\r
+          STA     M0FLIP,X\r
+          BEQ     MONSTRMV               ;DO NOT CHECK FOR TURN IF FLIPPED\r
+MONSTRZZ  LDA     M0TUNNEL,X             ;SEE IF IN TUNNEL, IF SO JUST MOVE\r
+          BNE     MONSTRMV\r
+          JSR     MNCHKDIR               ; FIND OUT IF WE ARE AT INTERSECT\r
+          CMP     #0\r
+          BNE     MONSTRMV               ;IF WE ARE NOT, JUST MOVE\r
+          JSR     MONNEWDR               ;GET NEW DIRECTION\r
+MONSTRMV  JMP     MOVEMON                ; MOVE THE MONSTER\r
+\r
+* WE NEED A NEW DIRECTION FOR THIS MONSTER\r
+MONNEWDR  LDA     M0STATE,X              ;LOOK AT THE STATE AGAIN\r
+          CMP     #MSTNORM\r
+          BNE     MONSTR2\r
+          LDA     M0BLUE,X               ; SEE IF IS IS BLUE\r
+          BEQ     MONSTR3\r
+          JMP     MMVBLUE\r
+MONSTR3   LDA     BORED                  ; SEE IF IT'S BORED\r
+          BEQ     MONSTR5\r
+          JMP     MMVBORED\r
+MONSTR5   JMP     MMVINTER               ; ELSE IT'S INTERESTED\r
+MONSTR2   JMP     MMVEYES                ; IT'S EYES\r
+\r
+\r
+* MMVBLUE         - BLUE MONSTER MOVEMENT\r
+*         IN:     X IS MONSTER NUMBER, TEMP12-15 IS INTERSECTION STATE\r
+*         OUT:\r
+*         USE: EVERYTHING EXCEPT X\r
+\r
+MMVBLUE   JSR     RAND\r
+          AND     #3\r
+          TAY\r
+          LDA     TEMP12,Y\r
+          BNE     MMVBLUE\r
+          TYA\r
+          STA     M0DIR,X\r
+          RTS\r
+\r
+* MMVEYES         - EYES MONSTER MOVEMENT\r
+*         IN:     X IS MONSTER NUMBER, TEMP12-15 IS INTERSECTION STATE\r
+*         OUT:\r
+*         USE: EVERYTHING EXCEPT X\r
+\r
+MMVEYES   LDA     #$0A\r
+          STA     TEMP7\r
+          LDA     #$0F\r
+          STA     TEMP8\r
+          JMP     STWHCHWY\r
+\r
+* MMVBORED        - BORED MONSTER MOVEMENT\r
+*         IN:     X CONTAINS MONSTER NUMBER, TEMP12-15 CONTAISN INTERSECT STATE\r
+*         OUT:    M0DIR,X IS SET TO NEW DIRECTION\r
+*         USES:   EVERYTHING EXCEPT X\r
+\r
+MMVBORED  TXA\r
+          CMP     #02\r
+          BEQ     MMVBORD1\r
+          BPL     MMVBORD2\r
+\r
+MMVBORD3  JSR     RAND                   ; RED AND PINK\r
+          AND     #3\r
+          TAY\r
+          LDA     TEMP12,Y\r
+          BNE     MMVBORD3\r
+          TYA\r
+          STA     M0DIR,X\r
+          RTS\r
+\r
+MMVBORD1  LDA     #$1C\r
+          STA     TEMP7\r
+          LDA     #$1A\r
+          STA     TEMP8\r
+          JMP     MMVBORD4\r
+\r
+MMVBORD2                                 ;GOLD\r
+          LDA     #$1C\r
+          STA     TEMP7\r
+          LDA     #$01\r
+          STA     TEMP8\r
+\r
+MMVBORD4  JMP     STWHCHWY\r
+\r
+* MMVINTER        - INTERESTED MONSTER MOVEMENT\r
+*         IN:     X HAS MONSTER NUMBER, TEMP12-15 HAS INTERSECTION STATE\r
+*         OUT:    M0DIR,X IS SET TO NEW DIRECTION\r
+*         USED:   EVERYTHING EXCEPT X\r
+\r
+MMVINTER  TXA\r
+          CMP     #2\r
+          BEQ     MMVINTR1\r
+          BPL     MMVINTR3\r
+          CMP     #1\r
+          BEQ     MMVINTR2\r
+\r
+          LDA     M0STATE+3              ;SEE IF GOLD GUY IN NORMAL STATE\r
+          CMP     #MSTNORM               ;  IF NOT, RED GUY MOVES NORMAL\r
+          BNE     REDSPD2\r
+          LDA     #$F0\r
+          SEC\r
+          SBC     DOTSEATN\r
+          CMP     REDTHRSH+1\r
+          BCS     REDSPD1\r
+          LDA     #SPDRED2\r
+          STA     M0SPEED                ;RED GUY MOVING FASTEST\r
+          JMP     REDSPD3\r
+REDSPD1\r
+          CMP     REDTHRSH\r
+          BCS     REDSPD2\r
+          LDA     #SPDRED1               ;RED GUY MOVING FASTER\r
+          STA     M0SPEED\r
+          JMP     REDSPD3\r
+REDSPD2\r
+          LDA     #SPDNORM               ;RED GUY MOVING NORMAL SPEED\r
+          STA     M0SPEED\r
+REDSPD3\r
+\r
+          LDA     PZONE                  ; RED\r
+          STA     TEMP7\r
+          LDA     PCOL\r
+          STA     TEMP8\r
+          JMP     MMVINTR4\r
+\r
+MMVINTR2\r
+          LDY     PDIR                   ; PINK\r
+          LDA     PZONE\r
+          CLC\r
+          ADC     DIROFFZ4,Y\r
+          STA     TEMP7\r
+          LDA     PCOL\r
+          CLC\r
+          ADC     DIROFFC4,Y\r
+          STA     TEMP8\r
+          JMP     MMVINTR4\r
+\r
+MMVINTR1  LDY     PDIR                   ;BLUE - GOAL ON OTHER SIDE OF MS FROM R\r
+          LDA     DIROFFZ2,Y             ;START WITH THE OFFSET TO LOOK AHEAD\r
+          CLC\r
+          ADC     PZONE                  ;ADD TO MS PAC'S ZONE\r
+          ASL     A\r
+          SEC\r
+          SBC     M0ZONE                 ;SUBTRACT RED MONSTER'S ZONE\r
+          STA     TEMP7                  ;= ADJ MS - (DELTA BETWEEN MS AND RED)\r
+          LDA     DIROFFC2,Y             ;START WITH THE OFFSET TO LOOK AHEAD\r
+          CLC\r
+          ADC     PCOL                   ;ADD TO MS PAC'S COLUMN\r
+          ASL     A\r
+          SEC\r
+          SBC     M0COL                  ;SUBTRACT RED MONSTER'S COLUMN\r
+          STA     TEMP8                  ;= ADJ MS - (DELTA BETWEEN MS AND RED)\r
+          JMP     MMVINTR4\r
+\r
+MMVINTR3\r
+          LDA     PZONE                  ; GOLD\r
+          STA     TEMP7\r
+          LDA     PCOL\r
+          STA     TEMP8\r
+          SEC\r
+          SBC     M0COL,X\r
+          STA     TEMP0\r
+          BPL     GOLD1\r
+          LDA     #0\r
+          SEC\r
+          SBC     TEMP0\r
+GOLD1     STA     TEMP1                  ; TEMP1 = ABS(PCOL-MCOL)\r
+          LDA     PZONE\r
+          SEC\r
+          SBC     M0ZONE,X\r
+          STA     TEMP0\r
+          BPL     GOLD2\r
+          LDA     #0\r
+          SEC\r
+          SBC     TEMP0\r
+GOLD2     CLC                            ; A = ABS(PZONE-MZONE)\r
+          ADC     TEMP1\r
+          CMP     #8                     ; IF ABS(PCOL-MCOL)+ABS(PZONE-MZONE)>8\r
+          BPL     MMVINTR4\r
+          LDA     #$15\r
+          STA     TEMP7\r
+          LDA     #$06\r
+          STA     TEMP8\r
+MMVINTR4  JMP     STWHCHWY\r
+\r
+* STWHCHWY        - SET UP FOR MONSTER'S WHCHWAY CALL\r
+*         IN:     MONSTER VALUE IN X, INTERSECTION STATE IN TEMP12-15\r
+*         OUT:    ALL PARAMETERS FOR WHCHWAY EXCEPT GOALZONE AND GOALCOL\r
+*         USES:   ALL EXCEPT X\r
+\r
+STWHCHWY  LDA     M0ZONE,X\r
+          STA     TEMP4\r
+          LDA     M0COL,X\r
+          STA     TEMP5\r
+          LDA     M0DIR,X\r
+          STA     TEMP6\r
+          JSR     WHCHWAY\r
+          STA     M0DIR,X\r
+          RTS\r
+\r
+* MMVPEN          - MONSTER PEN MOVEMENT STUFF\r
+*         IN:     X IS MONSTER NUMBER\r
+*         USE:\r
+\r
+MMVPEN    LDA     M0SLOW,X               ;SLOW THEM DOWN IN PEN\r
+          EOR     #$01\r
+          STA     M0SLOW,X\r
+          BNE     MMVPBODY\r
+          RTS\r
+\r
+MMVPBODY  LDA     M0STATE,X\r
+          CMP     #MSTATPEN              ; SEE IF HE'S JUST HANGING ARROUND\r
+          BNE     MMVPEN1\r
+\r
+          LDA     M0VPOS,X               ; SEE WHERE IT IS\r
+          CMP     #$48                    ; IF IT IS AT THE TOP\r
+          BCS     MMVPEN4\r
+          LDA     #DDOWN                 ; THEN MOVE IT DOWN\r
+          STA     M0DIR,X\r
+          JMP     MMVPEN3\r
+\r
+MMVPEN4   CMP     #$4E                    ; IF ITS AT THE BOTTOM\r
+          BCC     MMVPEN5\r
+          LDA     #DUP                   ; THEM MOVE IT UP\r
+          STA     M0DIR,X\r
+MMVPEN5   JMP     MMVPEN3                ; THEN GET OUT\r
+\r
+MMVPEN1   CMP     #MSTINPEN              ; SEE IF HE WANTS TO GET IN\r
+          BNE     MMVPEN2\r
+\r
+          LDA     M0VPOS,X               ; SEE IF ITS IN YET\r
+          CMP     #$4E\r
+          BCC     MMVPEN6\r
+          LDA     HOMEDIR,X              ; MOVE IT TOWATRDS IT'S HOME SLOT\r
+          STA     M0DIR,X\r
+          LDA     M0HPOS,X\r
+          CMP     IMHPOS,X\r
+          BNE     MMVPEN6\r
+          LDA     #MSTATPEN\r
+          STA     M0STATE,X\r
+          LDA     #DUP\r
+          STA     M0DIR,X\r
+          JSR     MONSTAMP               ;MAKE IT LOOK NORMAL\r
+          TXA\r
+          BNE     MMVPEN7\r
+          JSR     GETOUT\r
+MMVPEN7\r
+          JMP     MMVPEN3\r
+\r
+MMVPEN2                                  ; HE IS TRYING TO GET OUT\r
+          LDA     M0HPOS,X\r
+          CMP     #$37+LEFTSIDE\r
+          BNE     MMVPEN6\r
+          LDA     #DUP\r
+          STA     M0DIR,X\r
+          LDA     M0VPOS,X               ; SEE OF HE'S OUT YET\r
+          CMP     #$3A                   ;SZY-4C????\r
+          BCS     MMVPEN3\r
+\r
+          LDA     #DLEFT                 ;SET IT'S DIRECTION\r
+          LDY     M0BLUE,X\r
+          BEQ     MMVPENDR\r
+          LDA     #DRIGHT\r
+MMVPENDR  STA     M0DIR,X\r
+          LDA     #MSTNORM\r
+          STA     M0STATE,X              ; IF HE IS THEN ALL IS BACK TO NORMAL\r
+\r
+MMVPEN3\r
+MMVPEN6\r
+\r
+* MOVEMON         - MONSTER MOVEMENT STUFF\r
+*         IN:     X IS MONSTER NUMBER\r
+*         USE:\r
+\r
+MOVEMON   JSR     ADJSTMON               ;FIRST, ADJUST THE POSITION\r
+\r
+          LDA     M0TUNNEL,X\r
+          BNE     MVTUNNEL               ;DIFFERENT CODE FOR TUNNEL MOVEMENT\r
+\r
+          LDA     M0HPOS,X               ;SEE IF MOVING INTO TUNNEL\r
+          CMP     #RGHTEDGE\r
+          BCC     MVZZJMP0\r
+          STA     M0TUNNEL,X\r
+MVZZJMP0  CMP     #LEFTEDGE\r
+          BCS     MVZZJMP1\r
+          STA     M0TUNNEL,X\r
+\r
+MVZZJMP1  JSR     DISPMON                ;UPDATE THE MONSTER DISPLAY\r
+          JMP     CHKPEN\r
+\r
+MVTUNNEL  LDA     M0DIR,X                ;MOVEMENT THROUGH TUNNEL\r
+          BEQ     MVTRIGHT\r
+          LDA     M0HPOS,X               ;MOVING LEFT\r
+          CMP     #LEFTWRAP              ;SEE IF WRAP TIME\r
+          BCS     MVTLJMP0\r
+          CLC\r
+          ADC     #WRAPSIZE\r
+          STA     M0HPOS,X\r
+MVTLJMP0  CMP     #RGHTEDGE\r
+          BCS     MVTLJMP1\r
+          CMP     #80\r
+          BCC     MVTLJMP1\r
+          LDA     #$00\r
+          STA     M0TUNNEL,X\r
+MVTLJMP1  JMP     WRTMON                 ;WRITE IT AND LEAVE\r
+\r
+MVTRIGHT  LDA     M0HPOS,X               ;MOVING RIGHT\r
+          CMP     #RGHTWRAP              ;SEE IF WRAP TIME\r
+          BCC     MVTRJMP0\r
+          SEC\r
+          SBC     #WRAPSIZE\r
+          STA     M0HPOS,X\r
+MVTRJMP0  CMP     #LEFTEDGE\r
+          BCC     MVTRJMP1\r
+          CMP     #80\r
+          BCS     MVTRJMP1\r
+          LDA     #$00\r
+          STA     M0TUNNEL,X\r
+MVTRJMP1  JMP     WRTMON                 ;WRITE IT, THEN WE'RE DONE\r
+\r
+*  ADJUST THE POSITION OF THE MONSTER\r
+ADJSTMON  LDA     M0DISP,X               ;FIRST, ANIMATE THE MONSTER\r
+          EOR     #$10\r
+          STA     M0DISP,X\r
+\r
+          LDY     M0DIR,X                ;NOW, MOVE IT\r
+          LDA     M0HPOS,X\r
+          JSR     HPOSADJ                ;ADJUST HORIZONTALLY\r
+          STA     M0HPOS,X\r
+          STX     TEMP0\r
+          LDA     M0OFF,X\r
+          STA     TEMP1\r
+          LDA     M0VPOS,X\r
+          LDX     TEMP1\r
+          JSR     VPOSADJ                ;ADJUST VERTICALLY\r
+          LDX     TEMP0\r
+          STA     M0VPOS,X\r
+          RTS\r
+\r
+* SPECIAL CODE FOR GETTING EYES INTO PEN\r
+CHKPEN\r
+          LDA     M0STATE,X\r
+          CMP     #MSTEYES\r
+          BNE     MMOVEND               ; IF IT'S NOT EYES ITS NOT INTERESTED\r
+\r
+          LDA     #$13                   ;SEE IF EYE TUNE PLAYING\r
+          CMP     TUNINDEX\r
+          BEQ     CPJMP0\r
+          CMP     TUNINDEX+1\r
+          BEQ     CPJMP0\r
+          JSR     DOTUNE                 ;MAKE IT PLAY\r
+\r
+CPJMP0    LDA     #$39                   ; NOW SEE IF ITS AT THE ENTRY POINT\r
+          CMP     M0VPOS,X\r
+          BNE     MMOVEND\r
+          LDA     #$37+LEFTSIDE\r
+          CMP     M0HPOS,X\r
+          BNE     MMOVEND\r
+          LDA     #MSTINPEN\r
+          STA     M0STATE,X              ; IT IS NOW GOING INTO PEN\r
+          LDA     #DDOWN\r
+          STA     M0DIR,X\r
+\r
+          LDA     M0STATE+0\r
+          CMP     #MSTEYES\r
+          BEQ     MMOVEND\r
+          LDA     M0STATE+1\r
+          CMP     #MSTEYES\r
+          BEQ     MMOVEND\r
+          LDA     M0STATE+2\r
+          CMP     #MSTEYES\r
+          BEQ     MMOVEND\r
+          LDA     M0STATE+3\r
+          CMP     #MSTEYES\r
+          BEQ     MMOVEND\r
+          LDA     #$13\r
+          JSR     KILLTUNE\r
+\r
+MMOVEND   RTS\r
+\r
+\r
+*  THIS ROUTINE ADJUSTS THE CURRENT COLUMN, ZONE, AND OFFSET, THEN FALLS THROUGH\r
+*  TO WRTMON\r
+DISPMON   LDA     M0HPOS,X               ;ADJUST COLUMN\r
+          JSR     HTOC\r
+          STA     M0COL,X\r
+          LDA     M0VPOS,X               ;ADJUST ZONE AND OFFSET\r
+          JSR     VTOZO\r
+          STA     M0OFF,X\r
+          INY\r
+          TYA\r
+          STA     M0ZONE,X\r
+                                         ;NOW - FALL THROUGH TO WRTMON\r
+\r
+* WRTMON          - WRITE THE MONSTER ON THE SCREEN\r
+*         IN      X IS MONSTER NUMBER\r
+*         USES\r
+\r
+WRTMON    LDA     M0HPOS,X               ;UPDATE HPOS\r
+          SEC\r
+          SBC     #3\r
+          STA     HPLIST+2,X\r
+          LDY     M0ZONE,X               ;UPDATE ZONE\r
+          DEY\r
+          TYA\r
+          STA     VZLIST+2,X\r
+\r
+          LDA     M0DISP,X               ;FIND WHICH STAMP TO USE\r
+          AND     #$10                   ;FIRST, SET A TO 4 OR 0 DEPENDING\r
+          LSR     A                      ;  ON WHICH ANIMATION CURRENTLY IN\r
+          LSR     A\r
+          ORA     M0DIR,X                ;SET BOTTOM BITS TO DIRECTION\r
+          ORA     M0BLUE,X               ;NORMAL, BLUE, OR EYES\r
+          TAY                            ;THIS IS OUR INDEX\r
+          LDA     MONSTMPH,Y             ;SET THE STAMP\r
+          STA     SHLIST+2,X\r
+          LDA     MONSTMPL,Y\r
+          STA     SLLIST+2,X\r
+\r
+          LDA     #$01\r
+          STA     DOLIST+2,X             ;TELL LOADER TO GET IT\r
+          RTS\r
+\r
+\r
+* EYESTAMP        - FILL IN STAMP FOR EYES\r
+*         IN:     X IS MONSTER NUMBER\r
+*         OUT:\r
+*         USE:    TEMP0,Y\r
+\r
+EYESTAMP  LDA     #$10                   ;SET 'M0BLUE' TO EYES\r
+          STA     M0BLUE,X\r
+          TXA\r
+          ASL     A\r
+          ASL     A\r
+          TAY\r
+          LDA     #WHITE                 ;ADJUST COLOR\r
+          STA     P3C2,Y\r
+          RTS\r
+\r
+* BLUSTAMP        - FILL IN STAMP FOR BLUR MONSTERS\r
+*         IN:     X IS MONSTER NUMBER\r
+*         OUT:\r
+*         USE:    TEMP0,Y\r
+\r
+BLUSTAMP  LDA     #$08                   ;SET 'M0BLUE' TO BLUE\r
+          STA     M0BLUE,X\r
+          TXA\r
+          ASL     A\r
+          ASL     A\r
+          TAY\r
+          LDA     #DKBLUE                ;ADJUST COLOR\r
+          STA     P3C1,Y\r
+          LDA     #LTPINK\r
+          STA     P3C2,Y\r
+          RTS\r
+\r
+* MONSTAMP        - FILL IN STAMP FOR MONSTER\r
+*         IN:     X IS MONSTER NUMBER\r
+*         OUT:\r
+*         USE:    TEMP0,Y\r
+\r
+MONSTAMP  LDA     #$00                   ;SET 'M0BLUE' TO NORMAL MONSTER\r
+          STA     M0BLUE,X\r
+          TXA\r
+          ASL     A\r
+          ASL     A\r
+          TAY\r
+          LDA     IMCOLOR,X              ;ADJUST COLOR\r
+          STA     P3C1,Y\r
+          LDA     #WHITE\r
+          STA     P3C2,Y\r
+          LDA     #BLUE\r
+          STA     P3C3,Y\r
+          RTS\r
+\r
+* SCORSTMP        - FILL IN SCORE FOR MONSTER\r
+*         IN:     X IS MONSTER NUMBER\r
+*         OUT:\r
+*         USE:    TEMP0,Y\r
+\r
+SCORSTMP\r
+          LDY     GREEDCNT\r
+          LDA     MSCRTBLH,Y\r
+          STA     SHLIST+2,X\r
+          LDA     MSCRTBLL,Y\r
+          STA     SLLIST+2,X\r
+          LDA     #$01\r
+          STA     DOLIST+2,X\r
+          TXA\r
+          ASL     A\r
+          ASL     A\r
+          TAY\r
+          LDA     #LTGREEN               ;ADJUST COLOR\r
+          STA     P3C2,Y\r
+          RTS\r
+\r
+* INITMON         - INITIALIZE MONSTER DATA\r
+*         USES:\r
+*\r
+\r
+INITMON\r
+          LDX     #3\r
+INITMNLP\r
+\r
+          LDA     IMVPOS,X\r
+          STA     M0VPOS,X\r
+          LDA     IMHPOS,X\r
+          STA     M0HPOS,X\r
+          LDA     IMDIR,X\r
+          STA     M0DIR,X\r
+          LDA     #0\r
+          STA     M0DISP,X\r
+          STA     M0SPEED,X\r
+          STA     M0TUNNEL,X\r
+          STA     M0FLIP,X\r
+          STA     M0SLOW,X\r
+          LDA     IMSTATE,X\r
+          STA     M0STATE,X\r
+          JSR     MONSTAMP\r
+          JSR     DISPMON\r
+\r
+          DEX\r
+          BPL     INITMNLP\r
+\r
+          LDA     #1\r
+          STA     BORED\r
+          LDA     #0\r
+          STA     ISBLUE\r
+          STA     NORMTIME\r
+          STA     NORMTIME+1\r
+          STA     EATNDOTS\r
+          STA     TRELEASE\r
+          JSR     SETMON\r
+\r
+          LDA     LEVEL\r
+          CMP     #2\r
+          BPL     INITREL1\r
+          LDA     #$00\r
+          STA     M1REL\r
+          LDA     #$1A\r
+          STA     M2REL\r
+          LDA     #$34\r
+          STA     M3REL\r
+          JMP     INITBLTM\r
+INITREL1\r
+          CMP     #3\r
+          BPL     INITREL2\r
+          LDA     #$00\r
+          STA     M1REL\r
+          STA     M2REL\r
+          LDA     #$20\r
+          STA     M3REL\r
+          JMP     INITBLTM\r
+INITREL2\r
+          LDA     #$00\r
+          STA     M1REL\r
+          STA     M2REL\r
+          STA     M3REL\r
+\r
+INITBLTM                                 ;NOW SET UP BLUE TIME\r
+          LDA     LEVEL\r
+          CMP     #20\r
+          BMI     BLUTIM\r
+          LDA     #19\r
+BLUTIM    TAX\r
+          LDA     BTIME,X\r
+          STA     BLUETIME\r
+          RTS\r
+\r
+*         STATE CHANGE ROUTINES          *\r
+\r
+* GETOUT          DOES THE STATE CHANGE TO GET OUT OF THE PEN)\r
+*         IN:     A IS MONSTER NUMBER\r
+*         USES:\r
+\r
+GETOUT\r
+          TAX\r
+          LDA     #MSTLVPEN\r
+          STA     M0STATE,X\r
+          LDA     OUTDIR,X\r
+          STA     M0DIR,X\r
+          RTS\r
+\r
+* TURNBLUE        TURNS A MONSTER BLUE\r
+*         USES\r
+\r
+TURNBLUE\r
+          LDX     #3\r
+TRNBLULP\r
+          LDA     M0STATE,X\r
+          CMP     #MSTEYES\r
+          BEQ     TRNBLUND\r
+          CMP     #MSTINPEN\r
+          BEQ     TRNBLUND\r
+          LDA     #SPDBLUE\r
+          STA     M0SPEED,X\r
+          JSR     BLUSTAMP\r
+          LDA     M0STATE,X\r
+          BNE     TRNBLUND\r
+          INC     M0FLIP,X\r
+          JSR     WRTMON\r
+TRNBLUND  DEX\r
+          BPL     TRNBLULP\r
+\r
+          LDA     #1\r
+          STA     ISBLUE\r
+          LDA     #0\r
+          STA     GREEDCNT\r
+          LDA     BLUETIME\r
+          STA     BLUWAIT\r
+          LDA     #$0D                   ;MAKE ENERGIZED SOUND\r
+          JSR     DOTUNE\r
+          RTS\r
+\r
+* TURNNORM        TURNS A MONSTER NORMAL\r
+*         USES\r
+\r
+TURNNORM\r
+FOO       LDX     #3\r
+TRNNRMLP\r
+          LDA     M0STATE,X\r
+          CMP     #MSTEYES\r
+          BEQ     TRNNRMND\r
+          LDA     M0STATE,X\r
+          CMP     #MSTINPEN\r
+          BEQ     TRNNRMND\r
+          LDA     #SPDNORM\r
+          STA     M0SPEED,X\r
+          JSR     MONSTAMP\r
+          JSR     WRTMON\r
+TRNNRMND  DEX\r
+          BPL     TRNNRMLP\r
+\r
+          LDA     #0\r
+          STA     ISBLUE\r
+          STA     BLUWAIT\r
+          JSR     KILLBSND\r
+          RTS\r
+\r
+* TURNEYES        TURNS A MONSTER INTO EYES\r
+*         IN      X IS A MONETR NUMBER\r
+*         USES\r
+\r
+TURNEYES\r
+          LDA     #$00                   ;TURN FLIP OFF, JUST IN CASE\r
+          STA     M0FLIP,X\r
+          LDA     #MSTEYES\r
+          STA     M0STATE,X\r
+          LDA     #SPDNORM\r
+          STA     M0SPEED,X\r
+          JSR     EYESTAMP\r
+          JMP     WRTMON\r
+\r
+* MONFLIP         DOES THE MONSTER FLIP\r
+*         USES\r
+\r
+MONFLIP   LDX     #3\r
+FLIPLOOP  LDA     M0STATE,X\r
+          BNE     FLIPEND\r
+          INC     M0FLIP,X\r
+FLIPEND   DEX\r
+          BPL     FLIPLOOP\r
+\r
+          LDA     #0\r
+          STA     BORED\r
+          LDA     REVWAIT+2\r
+          STA     REVWAIT\r
+          LDA     REVWAIT+3\r
+          STA     REVWAIT+1\r
+          LDA     #$FF\r
+          STA     REVWAIT+2\r
+          STA     REVWAIT+3\r
+\r
+          RTS\r
+*\r
+* RELEASE         -CHECK FOR MONSTER RELEASES FORM PEN\r
+*\r
+\r
+RELEASE\r
+          LDA     LEVEL                  ; FIRST CHECK FOR TIMED RELEASE\r
+          CMP     #5\r
+          BMI     TIMEREL1\r
+          LDA     TRELEASE\r
+          CMP     #$B4\r
+          BCC     PINKREL\r
+          JMP     DOREL\r
+TIMEREL1\r
+          LDA     TRELEASE\r
+          CMP     #$F0\r
+          BCC     PINKREL\r
+DOREL                                    ;TIME TO RELEASE SOMEONE\r
+          LDA     #0\r
+          STA     TRELEASE\r
+          LDA     M0STATE+1\r
+          CMP     #MSTATPEN\r
+          BNE     WHCHREL1\r
+          LDA     #1\r
+          JSR     GETOUT\r
+          JMP     PINKREL\r
+WHCHREL1\r
+          LDA     M0STATE+2\r
+          CMP     #MSTATPEN\r
+          BNE     WHCHREL2\r
+          LDA     #2\r
+          JSR     GETOUT\r
+          JMP     PINKREL\r
+WHCHREL2\r
+          LDA     M0STATE+3\r
+          CMP     #MSTATPEN\r
+          BNE     PINKREL\r
+          LDA     #3\r
+          JSR     GETOUT\r
+          JMP     PINKREL\r
+PINKREL\r
+          LDA     M0STATE+1\r
+          CMP     #MSTATPEN\r
+          BNE     BLUEREL\r
+          LDA     DEATHFLG\r
+          BEQ     PINKREL1\r
+          LDA     EATNDOTS\r
+          CMP     #6\r
+          BNE     BLUEREL\r
+          LDA     #1\r
+          JSR     GETOUT\r
+          JMP     BLUEREL\r
+PINKREL1  LDA     PINKDOTS\r
+          CMP     M1REL\r
+          BCC     BLUEREL\r
+          LDA     #1\r
+          JSR     GETOUT\r
+\r
+BLUEREL\r
+          LDA     M0STATE+2\r
+          CMP     #MSTATPEN\r
+          BNE     GOLDREL\r
+          LDA     DEATHFLG\r
+          BEQ     BLUEREL1\r
+          LDA     EATNDOTS\r
+          CMP     #15\r
+          BNE     GOLDREL\r
+          LDA     #2\r
+          JSR     GETOUT\r
+          JMP     GOLDREL\r
+BLUEREL1  LDA     BLUEDOTS\r
+          CMP     M2REL\r
+          BCC     GOLDREL\r
+          LDA     #2\r
+          JSR     GETOUT\r
+\r
+GOLDREL\r
+          LDA     M0STATE+3\r
+          CMP     #MSTATPEN\r
+          BNE     RELOUT\r
+          LDA     DEATHFLG\r
+          BEQ     GOLDREL1\r
+          LDA     EATNDOTS\r
+          CMP     #28\r
+          BNE     RELOUT\r
+          LDA     #0\r
+          STA     DEATHFLG\r
+          STA     EATNDOTS\r
+          JMP     RELOUT\r
+GOLDREL1\r
+          LDA     GOLDDOTS\r
+          CMP     M3REL\r
+          BCC     RELOUT\r
+          LDA     #3\r
+          JSR     GETOUT\r
+RELOUT\r
+          RTS\r
+\r
+*\r
+* FLASHON\r
+\r
+FLASHON   LDA     #DKBLUE                ;FLASH COLOR\r
+          STA     TEMP17\r
+          LDA     #LTPINK\r
+          STA     TEMP18\r
+          JMP     FLASHMON\r
+\r
+*\r
+* FLASHOFF\r
+\r
+FLASHOFF  LDA     #WHITE                 ;FLASH COLOR\r
+          STA     TEMP17\r
+          LDA     #PINK\r
+          STA     TEMP18\r
+\r
+\r
+*  THIS ROUTINE FLASHES A MONSTER\r
+FLASHMON  LDX     #3                     ;DO FOR EACH MONSTER\r
+FLSHLOOP  LDA     M0BLUE,X\r
+          CMP     #$08\r
+          BNE     FLASHEND\r
+          LDA     M0STATE,X\r
+          CMP     #MSTINPEN\r
+          BEQ     FLASHEND\r
+          TXA\r
+          ASL     A\r
+          ASL     A\r
+          TAY\r
+          LDA     TEMP17                 ;BLUE MONSTER - FLASH COLOR\r
+          STA     P3C1,Y\r
+          LDA     TEMP18\r
+          STA     P3C2,Y\r
+\r
+FLASHEND  DEX\r
+          BPL     FLSHLOOP\r
+          RTS\r
+\r
+\r
+* CHKBLUE\r
+*\r
+CHKBLUE   LDA     RTLOCAL+1              ;ONLY EXECUTE EVERY OTHER TIME\r
+          AND     #$01\r
+          BEQ     CKBOUT\r
+          LDA     BLUWAIT                ;IF BLUWAIT <> 0, WE ARE BLUE\r
+          BEQ     CKBOUT\r
+          DEC     BLUWAIT\r
+          BEQ     CKBNORM\r
+\r
+          LDY     #$04                   ;SEE IF TIME TO FLASH\r
+CKBLOOP   CMP     ONFLASH,Y\r
+          BEQ     CKBONFL\r
+          CMP     OFFFLASH,Y\r
+          BEQ     CKBOFFFL\r
+          DEY\r
+          BPL     CKBLOOP\r
+CKBOUT    RTS\r
+\r
+CKBNORM   JMP     TURNNORM               ;TURN MONSTER NORMAL\r
+CKBONFL   JMP     FLASHON                ;FLASH MONSTER ON\r
+CKBOFFFL  JMP     FLASHOFF               ;FLASH MONSTER OFF\r
+\r
+OFFFLASH  DB      $07,$13,$1F,$2B,$37    ;TIMES MONSTERS FLASH PINK\r
+ONFLASH   DB      $0D,$19,$25,$31,$3D    ;TIMES MONSTERS FLASH BLUE\r
+\r
+\r
+* TIGHT LOOP FOR MOVING EYES DURRING SCORE DISPLAY\r
+TIGHT\r
+          STX     TEMP16\r
+          LDX     #3\r
+TIGHTLP                                  ; TOP OF TIGHT LOOP\r
+          LDA     M0STATE,X\r
+          CMP     #MSTEYES\r
+          BEQ     DOTIGHT\r
+          CMP     #MSTINPEN\r
+          BNE     TIGHTEND\r
+          JSR     MMVPEN\r
+          JMP     TIGHTEND\r
+DOTIGHT\r
+          JSR     MNCHKDIR               ; FIND OUT IF WE ARE AT INTERSECT\r
+          CMP     #0\r
+          BNE     TIGHTMV                ; WE ARE NOT, SO JUST MOVE\r
+          LDA     M0OFF,X                ; AND MAKE SURE WE ARE AT THE CENTER\r
+          CMP     #3\r
+          BNE     TIGHTMV\r
+          LDA     M0HPOS,X\r
+          AND     #3\r
+          CMP     #1\r
+          BNE     TIGHTMV\r
+          JSR     MMVEYES                ; IT'S EYES\r
+TIGHTMV   JSR     MOVEMON                ; MOVE THE MONSTER\r
+TIGHTEND\r
+          DEX\r
+          BPL     TIGHTLP\r
+          LDX     TEMP16\r
+          RTS\r
+\r
+\r
+*  THIS ROUTINE IS SIMPLY ONE TO CHECK IF A MONSTER IS IN AN INTERSECTION\r
+MNCHKDIR  LDA     M0ZONE,X\r
+          STA     TEMP4\r
+          LDA     M0COL,X\r
+          STA     TEMP5\r
+          LDA     M0DIR,X\r
+          STA     TEMP6\r
+          JMP     CHECKDIR\r
+\r
+\r
+*  THIS ROUTINE GETS RID OF THE ENERGIZED SOUND\r
+KILLBSND  LDA     #$0D                   ;3 TUNES - D, E, AND F - TO KILL\r
+          JSR     KILLTUNE\r
+          LDA     #$0E\r
+          JSR     KILLTUNE\r
+          LDA     #$0F\r
+          JMP     KILLTUNE\r
+\r
+\r
+IMVPOS    DB      $39,$4B,$4B,$4B\r
+IMHPOS    DB      $37+LEFTSIDE,$37+LEFTSIDE,$2F+LEFTSIDE,$3F+LEFTSIDE\r
+IMDIR     DB      DLEFT,DUP,DDOWN,DDOWN\r
+IMSTATE   DB      MSTNORM,MSTATPEN,MSTATPEN,MSTATPEN\r
+IMCOLOR   DB      PINK,LTPINK,LTBLUE,GOLD\r
+\r
+HOMEDIR   DB      DUP,DUP,DLEFT,DRIGHT\r
+OUTDIR    DB      DUP,DUP,DRIGHT,DLEFT\r
+\r
+DIROFFZ4  DB      $00,$04,$00,$FC\r
+DIROFFC4  DB      $04,$00,$FC,$00\r
+DIROFFZ2  DB      $00,$02,$00,$FE\r
+DIROFFC2  DB      $02,$00,$FE,$00\r
+\r
+BTIME     DB      $C0,$B4,$96,$78,$5A,$3C,$96,$3C,$3C,$1E\r
+          DB      $96,$3C,$1E,$1E,$5A,$1E,$1E,$01,$1E,$01\r
+\r
+*  STAMPS FOR THE MONSTERS - INDEX: M0BLUE + M0DIR + (M0STATE ^ $10)/4\r
+MONSTMPH  DB      H(NRMMONST),H(NRMMONST+48),H(NRMMONST+96),H(NRMMONST+144)\r
+          DB      H(NRMMONST+24),H(NRMMONST+72),H(NRMMONST+120),H(NRMMONST+168)\r
+          DB      H(BLUMONST),H(BLUMONST),H(BLUMONST),H(BLUMONST)\r
+          DB      H(BLUMONST+24),H(BLUMONST+24),H(BLUMONST+24),H(BLUMONST+24)\r
+          DB      H(EYEMONST),H(EYEMONST+24),H(EYEMONST+48),H(EYEMONST+72)\r
+          DB      H(EYEMONST),H(EYEMONST+24),H(EYEMONST+48),H(EYEMONST+72)\r
+MONSTMPL  DB      L(NRMMONST),L(NRMMONST+48),L(NRMMONST+96),L(NRMMONST+144)\r
+          DB      L(NRMMONST+24),L(NRMMONST+72),L(NRMMONST+120),L(NRMMONST+168)\r
+          DB      L(BLUMONST),L(BLUMONST),L(BLUMONST),L(BLUMONST)\r
+          DB      L(BLUMONST+24),L(BLUMONST+24),L(BLUMONST+24),L(BLUMONST+24)\r
+          DB      L(EYEMONST),L(EYEMONST+24),L(EYEMONST+48),L(EYEMONST+72)\r
+          DB      L(EYEMONST),L(EYEMONST+24),L(EYEMONST+48),L(EYEMONST+72)\r
+\r
+*  TABLES OF SCORE BITMAPS\r
+MSCRTBLH  DB      H(MONSTNUM),H(MONSTNUM+24),H(MONSTNUM+48),H(MONSTNUM+72)\r
+MSCRTBLL  DB      L(MONSTNUM),L(MONSTNUM+24),L(MONSTNUM+48),L(MONSTNUM+72)\r
+\r
+*  HACK TABLE TO SLOW MONSTERS IN PEN\r
+HACKVPOS  DB      $00,$FF,$00,$01\r
diff --git a/MSCHAR.S b/MSCHAR.S
new file mode 100644 (file)
index 0000000..ac5876b
--- /dev/null
+++ b/MSCHAR.S
@@ -0,0 +1,353 @@
+\r
+*  MSCHAR.S        CHARACTER SET FOR MS PAC MAN\r
+*                 FIRST FILE TO BE LOADED TO MAKE SURE ALL GRAPHICS ON EVEN\r
+*                 CHARACTERS\r
+\r
+          ASEG\r
+\r
+          ORG     $C000                  ; CART STARTS AT C000\r
+\r
+*  MS PAC MAN CHARACTER SET\r
+*         MAZE CHARACTERS\r
+MSFONT    DB      $B0,$B0,$C0,$00,$00,$00        ; 30 -  UPPER LEFT FULL\r
+          DB      $00,$00,$00,$C0,$B0,$B0        ; 31 -  LOWER LEFT FULL\r
+          DB      $B0,$B0,$B0,$B0,$B0,$B0        ; 32 -  LEFT FULL\r
+          DB      $0E,$0E,$03,$00,$00,$00        ; 33 -  UPPER RIGHT FULL\r
+          DB      $AA,$AA,$FF,$00,$00,$00        ; 34 -  UPPER HALF FULL\r
+          DB      $AA,$AA,$AF,$B0,$B0,$B0        ; 35 -  LOWER RIGHT EMPTY\r
+          DB      $00,$00,$00,$03,$0E,$0E        ; 36 -  LOWER RIGHT FULL\r
+          DB      $00,$00,$00,$FF,$AA,$AA        ; 37 -  LOWER FULL\r
+          DB      $B0,$B0,$B0,$AF,$AA,$AA        ; 38 -  UPPER RIGHT EMPTY\r
+          DB      $0E,$0E,$0E,$0E,$0E,$0E        ; 39 -  RIGHT FULL\r
+          DB      $AA,$AA,$FA,$0E,$0E,$0E        ; 3A -  LOWER LEFT EMPTY\r
+          DB      $0E,$0E,$0E,$FA,$AA,$AA        ; 3B -  UPPER LEFT EMPTY\r
+          DB      $AA,$AA,$AA,$AA,$AA,$AA        ; 3C -  ALL FULL\r
+\r
+* PEN CHARACTERS\r
+          DB      $00,$00,$00,$AA,$AA,$AA        ; 3D -  PEN ENTRANCE\r
+          DB      $B0,$B0,$F0,$00,$00,$00        ; 3E -  LOWER LEFT CORNER\r
+          DB      $00,$00,$00,$F0,$B0,$B0        ; 3F -  UPPER LEFT CORNER\r
+          DB      $B0,$B0,$B0,$B0,$B0,$B0        ; 40 -  LEFT SIDE\r
+          DB      $0E,$0E,$0F,$00,$00,$00        ; 41 -  LOWER RIGHT CORNER\r
+          DB      $AA,$AA,$FF,$00,$00,$00        ; 42 -  LOWER SIDE\r
+          DB      $00,$00,$00,$0F,$0E,$0E        ; 43 -  UPPER LEFT CORNER\r
+          DB      $00,$00,$00,$FF,$AA,$AA        ; 44 -  UPPER SIDE\r
+          DB      $0E,$0E,$0E,$0E,$0E,$0E        ; 45 -  RIGHT SIDE\r
+\r
+* 3X5 NUMBERS     - ALTERNATE SET FOR OTHER PLAYER SCORE\r
+          DB      $2A,$22,$22,$22,$2A,$00        ;46  0\r
+          DB      $08,$28,$08,$08,$2A,$00        ;47  1\r
+          DB      $2A,$02,$2A,$20,$2A,$00        ;48  2\r
+          DB      $2A,$02,$2A,$02,$2A,$00        ;49  3\r
+          DB      $22,$22,$2A,$02,$02,$00        ;4A  4\r
+          DB      $2A,$20,$2A,$02,$2A,$00        ;4B  5\r
+          DB      $2A,$20,$2A,$22,$2A,$00        ;4C  6\r
+          DB      $2A,$02,$02,$02,$02,$00        ;4D  7\r
+          DB      $2A,$22,$2A,$22,$2A,$00        ;4E  8\r
+          DB      $2A,$22,$2A,$02,$02,$00        ;4F  9\r
+\r
+* OTHER MAZE CHARACTERS\r
+          DB      $00,$00,$00,$00,$00,$00        ; 50 - BLANK\r
+          DB      $00,$00,$14,$14,$00,$00        ; 51 - REGULAR DOT.\r
+          DB      $14,$55,$55,$55,$55,$14        ; 52 - POWER DOT\r
+          DB      $00,$00,$00,$00,$00,$00        ; 53 - POWER DOT FLASHED\r
+\r
+* 3X5 NUMBERS\r
+          DB      $3F,$33,$33,$33,$3F,$00        ;54  0\r
+          DB      $0C,$3C,$0C,$0C,$3F,$00        ;55  1\r
+          DB      $3F,$03,$3F,$30,$3F,$00        ;56  2\r
+          DB      $3F,$03,$3F,$03,$3F,$00        ;57  3\r
+          DB      $33,$33,$3F,$03,$03,$00        ;58  4\r
+          DB      $3F,$30,$3F,$03,$3F,$00        ;59  5\r
+          DB      $3F,$30,$3F,$33,$3F,$00        ;5A  6\r
+          DB      $3F,$03,$03,$03,$03,$00        ;5B  7\r
+          DB      $3F,$33,$3F,$33,$3F,$00        ;5C  8\r
+          DB      $3F,$33,$3F,$03,$03,$00        ;5D  9\r
+\r
+* 3X5 LETTERS\r
+          DB      $3F,$33,$3F,$33,$33,$00        ;5E     A\r
+          DB      $3C,$33,$3C,$33,$3C,$00        ;5F     B\r
+          DB      $3F,$30,$30,$30,$3F,$00        ;60     C\r
+          DB      $3C,$33,$33,$33,$3C,$00        ;61     D\r
+          DB      $3F,$30,$3F,$30,$3F,$00        ;62     E\r
+          DB      $3F,$30,$3F,$30,$30,$00        ;63     F\r
+          DB      $3F,$30,$33,$33,$3F,$00        ;64     G\r
+          DB      $33,$33,$3F,$33,$33,$00        ;65     H\r
+          DB      $3F,$0C,$0C,$0C,$3F,$00        ;66     I\r
+          DB      $3F,$0C,$0C,$0C,$3C,$00        ;67     J\r
+          DB      $33,$3C,$30,$3C,$33,$00        ;68     K\r
+          DB      $30,$30,$30,$30,$3F,$00        ;69     L\r
+          DB      $33,$3F,$33,$33,$33,$00        ;6A     M\r
+          DB      $33,$3F,$3F,$33,$33,$00        ;6B     N\r
+          DB      $3F,$33,$33,$33,$3F,$00        ;6C     O\r
+          DB      $3F,$33,$3F,$30,$30,$00        ;6D     P\r
+          DB      $3F,$33,$33,$3F,$0F,$00        ;6E     Q\r
+          DB      $3F,$33,$3F,$3C,$33,$00        ;6F     R\r
+          DB      $3F,$30,$3F,$03,$3F,$00        ;70     S\r
+          DB      $3F,$0C,$0C,$0C,$0C,$00        ;71     T\r
+          DB      $33,$33,$33,$33,$3F,$00        ;72     U\r
+          DB      $33,$33,$33,$0C,$0C,$00        ;73     V\r
+          DB      $33,$33,$33,$3F,$33,$00        ;74     W\r
+          DB      $33,$33,$0C,$33,$33,$00        ;75     X\r
+          DB      $33,$33,$0C,$0C,$0C,$00        ;76     Y\r
+          DB      $3F,$03,$0C,$30,$3F,$00        ;77     Z\r
+          DB      $0C,$0C,$0C,$00,$0C,$00        ;78     !\r
+          DB      $33,$33,$00,$00,$00,$00        ;79     "\r
+          DB      $00,$00,$3F,$00,$00,$00        ;7A     - \r
+\r
+*  DOTS FOR MARQUEE\r
+          DB      $00,$00,$14,$14,$00,$00        ;7B\r
+          DB      $00,$00,$14,$14,$00,$00        ;7C\r
+          DB      $00,$00,$14,$14,$00,$00        ;7D\r
+          DB      $00,$00,$14,$14,$00,$00        ;7E\r
+          DB      $00,$00,$14,$14,$00,$00        ;7F\r
+          DB      $00,$00,$3C,$3C,$00,$00        ;80\r
+          DB      $00,$00,$3C,$3C,$00,$00        ;81\r
+          DB      $00,$00,$3C,$3C,$00,$00        ;82\r
+\r
+*  STAMPS FOR "MS. PAC-MAN" LOGO\r
+          DB      $04,$05,$05,$06,$06,$06        ;83\r
+          DB      $06,$06,$06,$06,$06,$06        ;84\r
+          DB      $06,$55,$55,$6A,$6A,$6A        ;85\r
+          DB      $6A,$6A,$6A,$6A,$6A,$69        ;86\r
+          DB      $69,$69,$65,$6A,$55,$55        ;87\r
+          DB      $00,$00,$40,$51,$95,$A6        ;88\r
+          DB      $AA,$AA,$AA,$AA,$AA,$95        ;89\r
+          DB      $AA,$55,$55,$AA,$AA,$96        ;8A\r
+          DB      $96,$96,$AA,$AA,$95,$95        ;8B\r
+          DB      $95,$95,$95,$95,$55,$55        ;8C\r
+          DB      $04,$14,$54,$65,$A5,$A5        ;8D\r
+          DB      $A6,$A6,$65,$65,$66,$66        ;8E\r
+          DB      $A6,$55,$55,$51,$91,$95        ;8F\r
+          DB      $96,$96,$9A,$5A,$59,$69        ;90\r
+          DB      $69,$AA,$AA,$AA,$55,$55        ;91\r
+          DB      $00,$00,$00,$55,$55,$AA        ;92\r
+          DB      $9A,$9A,$A9,$6A,$A6,$A6        ;93\r
+          DB      $AA,$55,$55,$90,$90,$94        ;94\r
+          DB      $A4,$A5,$A9,$A9,$69,$6A        ;95\r
+          DB      $66,$A6,$56,$AA,$55,$55        ;96\r
+          DB      $00,$00,$00,$50,$50,$90        ;97\r
+          DB      $91,$95,$56,$5A,$9A,$9A        ;98\r
+          DB      $56,$45,$01,$05,$16,$1A        ;99\r
+          DB      $5A,$6A,$6A,$6A,$6A,$6A        ;9A\r
+          DB      $5A,$9A,$96,$95,$51,$50        ;9B\r
+          DB      $40,$50,$94,$A4,$A4,$A4        ;9C\r
+          DB      $94,$55,$55,$AA,$AA,$AA        ;9D\r
+          DB      $AA,$AA,$A9,$A5,$A9,$AA        ;9E\r
+          DB      $A6,$A9,$96,$AA,$55,$55        ;9F\r
+          DB      $00,$00,$50,$54,$A4,$A4        ;A0\r
+          DB      $94,$50,$40,$00,$40,$50        ;A1\r
+          DB      $94,$A4,$A4,$54,$50,$00        ;A2\r
+          DB      $00,$00,$55,$69,$55,$00        ;A3\r
+          DB      $10,$14,$15,$19,$1A,$1A        ;A4\r
+          DB      $1A,$1A,$1A,$1A,$1A,$1A        ;A5\r
+          DB      $1A,$1A,$1A,$1A,$15,$15        ;A6\r
+          DB      $00,$00,$00,$40,$51,$95        ;A7\r
+          DB      $A6,$AA,$AA,$AA,$AA,$AA        ;A8\r
+          DB      $AA,$AA,$95,$AA,$55,$55        ;A9\r
+          DB      $01,$05,$15,$59,$69,$A9        ;AA\r
+          DB      $A9,$A9,$A9,$99,$99,$99        ;AB\r
+          DB      $99,$99,$59,$A9,$55,$55        ;AC\r
+          DB      $00,$00,$01,$01,$01,$05        ;AD\r
+          DB      $06,$16,$1A,$1A,$59,$69        ;AE\r
+          DB      $00,$40,$50,$90,$90,$90        ;AF\r
+          DB      $1A,$1A,$1A,$1A,$5A,$5A        ;B0\r
+          DB      $5A,$9A,$9A,$9A,$55,$55        ;B1\r
+          DB      $00,$05,$05,$46,$56,$96        ;B2\r
+          DB      $00,$55,$55,$A9,$A9,$A9        ;B3\r
+\r
+\r
+*  STAMP CHARACTERS\r
+          ;MS RIGHT, CLOSED\r
+MSCHAR    DB      $08,$00,$0A,$50,$A5,$54,$25,$55,$17,$D5,$15,$55\r
+          DB      $15,$55,$15,$55,$15,$55,$05,$54,$01,$50,$00,$00\r
+          ;MS RIGHT, HALF OPEN\r
+          DB      $08,$00,$0A,$50,$A5,$54,$25,$D5,$17,$55,$15,$50\r
+          DB      $15,$00,$15,$50,$15,$55,$05,$54,$01,$50,$00,$00\r
+          ;MS RIGHT, OPEN\r
+          DB      $08,$00,$0A,$50,$A5,$54,$25,$D4,$17,$50,$15,$40\r
+          DB      $15,$00,$15,$40,$15,$50,$05,$54,$01,$50,$00,$00\r
+          ;MS DOWN, CLOSED\r
+          DB      $00,$20,$05,$A0,$15,$5A,$55,$58,$55,$D4,$55,$D4\r
+          DB      $55,$54,$55,$54,$55,$54,$15,$50,$05,$40,$00,$00\r
+          ;MS DOWN, HALF OPEN\r
+          DB      $00,$20,$05,$A0,$15,$5A,$55,$58,$55,$D4,$55,$74\r
+          DB      $54,$54,$54,$54,$50,$14,$10,$10,$00,$00,$00,$00\r
+          ;MS DOWN, OPEN\r
+          DB      $00,$20,$05,$A0,$15,$5A,$55,$58,$55,$D4,$55,$74\r
+          DB      $54,$54,$50,$14,$40,$04,$00,$00,$00,$00,$00,$00\r
+          ;MS LEFT, CLOSED\r
+          DB      $00,$20,$05,$A0,$15,$5A,$55,$58,$57,$D4,$55,$54\r
+          DB      $55,$54,$55,$54,$55,$54,$15,$50,$05,$40,$00,$00\r
+          ;MS LEFT, HALF OPEN\r
+          DB      $00,$20,$05,$A0,$15,$5A,$57,$58,$55,$D4,$05,$54\r
+          DB      $00,$54,$05,$54,$55,$54,$15,$50,$05,$40,$00,$00\r
+          ;MS LEFT, OPEN\r
+          DB      $00,$20,$05,$A0,$15,$5A,$17,$58,$05,$D4,$01,$54\r
+          DB      $00,$54,$01,$54,$05,$54,$15,$50,$05,$40,$00,$00\r
+          ;MS UP, CLOSED\r
+          DB      $00,$00,$01,$50,$05,$54,$15,$55,$15,$55,$15,$55\r
+          DB      $17,$55,$17,$55,$25,$55,$A5,$54,$0A,$50,$08,$00\r
+          ;MS UP, HALF OPEN\r
+          DB      $00,$00,$00,$00,$04,$04,$14,$05,$15,$15,$15,$15\r
+          DB      $1D,$55,$17,$55,$25,$55,$A5,$54,$0A,$50,$08,$00\r
+          ;MS UP, OPEN\r
+          DB      $00,$00,$00,$00,$00,$00,$10,$01,$14,$05,$15,$15\r
+          DB      $1D,$55,$17,$55,$25,$55,$A5,$54,$0A,$50,$08,$00\r
+\r
+\r
+*  PAC-MAN STAMPS (FOR ANIMATION)\r
+          ;PAC RIGHT, CLOSED\r
+PACCHAR   DB      $00,$00,$01,$50,$05,$54,$15,$55,$15,$55,$15,$55\r
+          DB      $15,$55,$15,$55,$15,$55,$05,$54,$01,$50,$00,$00\r
+          ;PAC RIGHT, HALF OPEN\r
+          DB      $00,$00,$01,$50,$05,$54,$15,$55,$15,$55,$15,$50\r
+          DB      $15,$00,$15,$50,$15,$55,$05,$54,$01,$50,$00,$00\r
+          ;PAC RIGHT, OPEN\r
+          DB      $00,$00,$01,$50,$05,$54,$15,$54,$15,$50,$15,$40\r
+          DB      $15,$00,$15,$40,$15,$50,$05,$54,$01,$50,$00,$00\r
+          ;PAC DOWN, CLOSED\r
+          DB      $00,$00,$05,$40,$15,$50,$55,$54,$55,$54,$55,$54\r
+          DB      $55,$54,$55,$54,$55,$54,$15,$50,$05,$40,$00,$00\r
+          ;PAC DOWN, HALF OPEN\r
+          DB      $00,$00,$05,$40,$15,$50,$55,$54,$55,$54,$55,$54\r
+          DB      $54,$54,$54,$54,$50,$14,$10,$10,$00,$00,$00,$00\r
+          ;PAC DOWN, OPEN\r
+          DB      $00,$00,$05,$40,$15,$50,$55,$54,$55,$54,$55,$54\r
+          DB      $54,$54,$50,$14,$40,$04,$00,$00,$00,$00,$00,$00\r
+          ;PAC LEFT, CLOSED\r
+          DB      $00,$00,$05,$40,$15,$50,$55,$54,$55,$54,$55,$54\r
+          DB      $55,$54,$55,$54,$55,$54,$15,$50,$05,$40,$00,$00\r
+          ;PAC LEFT, HALF OPEN\r
+          DB      $00,$00,$05,$40,$15,$50,$55,$54,$55,$54,$05,$54\r
+          DB      $00,$54,$05,$54,$55,$54,$15,$50,$05,$40,$00,$00\r
+          ;PAC LEFT, OPEN\r
+          DB      $00,$00,$05,$40,$15,$50,$15,$54,$05,$54,$01,$54\r
+          DB      $00,$54,$01,$54,$05,$54,$15,$50,$05,$40,$00,$00\r
+          ;PAC UP, CLOSED\r
+          DB      $00,$00,$01,$50,$05,$54,$15,$55,$15,$55,$15,$55\r
+          DB      $15,$55,$15,$55,$15,$55,$05,$54,$01,$54,$00,$00\r
+          ;PAC UP, HALF OPEN\r
+          DB      $00,$00,$00,$00,$04,$04,$14,$05,$15,$15,$15,$15\r
+          DB      $15,$55,$15,$55,$15,$55,$05,$54,$01,$50,$00,$00\r
+          ;PAC UP, OPEN\r
+          DB      $00,$00,$00,$00,$00,$00,$10,$01,$14,$05,$15,$15\r
+          DB      $15,$55,$15,$55,$15,$55,$05,$54,$01,$50,$00,$00\r
+\r
+\r
+* BITMAPS FOR THE MONSTER IN ALL IT'S STATES\r
+NRMMONST  DB      $05,$50,$15,$54,$55,$55,$5A,$69,$5B,$6D,$5B,$6D  ;V1 RIGHT\r
+          DB      $55,$55,$55,$55,$55,$55,$55,$55,$55,$55,$44,$11\r
+          DB      $05,$50,$15,$54,$55,$55,$5A,$69,$5B,$6D,$5B,$6D  ;V2 RIGHT\r
+          DB      $55,$55,$55,$55,$55,$55,$55,$55,$55,$55,$11,$44\r
+          DB      $05,$50,$15,$54,$55,$55,$55,$55,$69,$69,$69,$69  ;V1 DOWN\r
+          DB      $7D,$7D,$55,$55,$55,$55,$55,$55,$55,$55,$44,$11\r
+          DB      $05,$50,$15,$54,$55,$55,$55,$55,$69,$69,$69,$69  ;V2 DOWN\r
+          DB      $7D,$7D,$55,$55,$55,$55,$55,$55,$55,$55,$11,$44\r
+          DB      $05,$50,$15,$54,$55,$55,$69,$A5,$79,$E5,$79,$E5  ;V1 LEFT\r
+          DB      $55,$55,$55,$55,$55,$55,$55,$55,$55,$55,$44,$11\r
+          DB      $05,$50,$15,$54,$55,$55,$69,$A5,$79,$E5,$79,$E5  ;V2 LEFT\r
+          DB      $55,$55,$55,$55,$55,$55,$55,$55,$55,$55,$11,$44\r
+          DB      $05,$50,$15,$54,$7D,$7D,$69,$69,$69,$69,$55,$55  ;V1 UP\r
+          DB      $55,$55,$55,$55,$55,$55,$55,$55,$55,$55,$44,$11\r
+          DB      $05,$50,$15,$54,$7D,$7D,$69,$69,$69,$69,$55,$55  ;V2 UP\r
+          DB      $55,$55,$55,$55,$55,$55,$55,$55,$55,$55,$11,$44\r
+BLUMONST  DB      $05,$50,$15,$54,$55,$55,$69,$69,$69,$69,$55,$55  ;V1\r
+          DB      $55,$55,$59,$65,$66,$99,$55,$55,$55,$55,$44,$11\r
+          DB      $05,$50,$15,$54,$55,$55,$69,$69,$69,$69,$55,$55  ;V2\r
+          DB      $55,$55,$59,$65,$66,$99,$55,$55,$55,$55,$11,$44\r
+EYEMONST  DB      $00,$00,$00,$00,$00,$00,$0A,$0A,$2B,$2B,$2B,$2B  ;RIGHT\r
+          DB      $0A,$0A,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00\r
+          DB      $00,$00,$00,$00,$00,$00,$00,$00,$20,$08,$A8,$2A  ;DOWN\r
+          DB      $A8,$2A,$FC,$3F,$00,$00,$00,$00,$00,$00,$00,$00\r
+          DB      $00,$00,$00,$00,$00,$00,$A0,$A0,$E8,$E8,$E8,$E8  ;LEFT\r
+          DB      $A0,$A0,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00\r
+          DB      $00,$00,$00,$00,$FC,$3F,$A8,$2A,$A8,$2A,$20,$08  ;UP\r
+          DB      $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00\r
+\r
+\r
+*  MISCELLANEOUS STAMPS FOR ANIMATION\r
+MISCCHAR  DB      $00,$00,$28,$A0,$AA,$A8,$AA,$A8,$AA,$A8,$2A,$A0  ;HEART\r
+          DB      $2A,$A0,$0A,$80,$0A,$80,$02,$00,$02,$00,$00,$00\r
+          DB      $00,$00,$00,$C0,$00,$C0,$00,$C0,$02,$A0,$0A,$A8  ;BAG\r
+          DB      $0A,$A8,$0A,$A8,$0A,$A8,$0A,$A8,$02,$A0,$00,$00\r
+          DB      $00,$00,$00,$00,$00,$00,$00,$00,$01,$40,$05,$50  ;JUNIOR\r
+          DB      $01,$50,$00,$50,$01,$50,$05,$50,$01,$40,$00,$00\r
+          DB      $00,$00,$00,$03,$00,$0F,$00,$3F,$15,$7F,$00,$3F  ;STORK HEAD\r
+          DB      $00,$0F,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00\r
+          DB      $00,$00,$C0,$00,$B0,$FF,$FF,$FF,$FF,$FF,$FF,$FF  ;BODY DOWN\r
+          DB      $CF,$FF,$03,$FF,$00,$FF,$00,$3F,$00,$0F,$00,$00\r
+          DB      $00,$00,$00,$0F,$00,$3F,$C0,$FF,$B3,$FF,$FF,$FF  ;BODY UP\r
+          DB      $FF,$FF,$FF,$FF,$C3,$FF,$00,$00,$00,$00,$00,$00\r
+          DB      $00,$00,$00,$00,$C0,$00,$FF,$00,$FF,$F0,$FF,$FC  ;TAIL DOWN\r
+          DB      $FC,$00,$C0,$00,$C0,$00,$F0,$00,$FC,$00,$FF,$00\r
+          DB      $FF,$00,$FC,$00,$F0,$00,$F0,$00,$F0,$00,$FF,$00  ;TAIL UP\r
+          DB      $FF,$F0,$FF,$FC,$FC,$00,$00,$00,$00,$00,$00,$00\r
+\r
+\r
+*  STAMPS FOR FRUIT\r
+FRUITCHR  DB      $00,$00,$3C,$3C,$C3,$C3,$FF,$FF,$33,$CC,$F3,$CF  ;TEDDY BEAR\r
+          DB      $FF,$FF,$FC,$3F,$FC,$3F,$3F,$FC,$0F,$F0,$00,$00\r
+          DB      $00,$00,$3C,$00,$C3,$C0,$03,$30,$03,$0C,$0C,$1C  ;CHERRIES\r
+          DB      $30,$55,$34,$65,$55,$14,$65,$00,$14,$00,$00,$00\r
+          DB      $00,$00,$0F,$F0,$17,$D4,$55,$65,$56,$55,$65,$59  ;SWRAWBERRY\r
+          DB      $55,$95,$19,$54,$15,$64,$06,$50,$01,$40,$00,$00\r
+          DB      $02,$3C,$02,$FF,$02,$3C,$06,$50,$15,$54,$55,$55  ;ORANGE\r
+          DB      $55,$55,$55,$55,$55,$55,$15,$54,$05,$50,$00,$00\r
+          DB      $00,$00,$3C,$3C,$CF,$F2,$C3,$C3,$82,$C3,$CC,$33  ;PRETZEL\r
+          DB      $CC,$3B,$38,$0C,$30,$0C,$CF,$B3,$C3,$C3,$00,$00\r
+          DB      $00,$00,$00,$F0,$03,$00,$13,$40,$55,$54,$55,$54  ;APPLE\r
+          DB      $55,$54,$65,$54,$65,$54,$19,$50,$05,$40,$00,$00\r
+          DB      $00,$00,$00,$3C,$00,$C0,$01,$C0,$05,$50,$05,$50  ;PEAR\r
+          DB      $05,$50,$19,$54,$19,$54,$16,$54,$05,$50,$00,$00\r
+          DB      $00,$00,$00,$01,$00,$01,$00,$01,$00,$05,$00,$15  ;BANANA\r
+          DB      $00,$55,$01,$54,$05,$54,$15,$50,$55,$00,$00,$00\r
+\r
+\r
+* NUMBERS FOR EATING FRUIT AND MONSTERS\r
+FRUITNUM  DB      $00,$00,$00,$00,$3F,$00,$30,$00,$3F,$00,$03,$FC  ;50\r
+          DB      $3F,$CC,$00,$CC,$00,$CC,$00,$FC,$00,$00,$00,$00\r
+          DB      $00,$00,$00,$00,$30,$00,$F0,$00,$30,$00,$33,$F0  ;100\r
+          DB      $FF,$30,$03,$3F,$03,$F3,$00,$33,$00,$3F,$00,$00\r
+          DB      $00,$00,$00,$00,$00,$3F,$00,$33,$03,$F3,$03,$3F  ;200\r
+          DB      $FF,$30,$0F,$F0,$FC,$00,$C0,$00,$FC,$00,$00,$00\r
+          DB      $00,$00,$00,$00,$FC,$00,$C0,$00,$FC,$00,$0F,$F0  ;500\r
+          DB      $FF,$30,$03,$3F,$03,$F3,$00,$33,$00,$3F,$00,$00\r
+          DB      $00,$00,$00,$00,$00,$3F,$00,$33,$03,$F3,$03,$3F  ;700\r
+          DB      $FF,$30,$0F,$F0,$0C,$00,$0C,$00,$0C,$00,$00,$00\r
+          DB      $00,$00,$0C,$00,$3C,$00,$0C,$00,$0C,$00,$3F,$C0  ;1000\r
+          DB      $0C,$C0,$0F,$F0,$03,$30,$03,$FC,$00,$CC,$00,$FC\r
+          DB      $00,$00,$00,$FC,$00,$CC,$03,$FC,$03,$30,$0F,$F0  ;2000\r
+          DB      $0C,$C0,$3F,$C0,$03,$00,$3F,$00,$30,$00,$3F,$00\r
+          DB      $00,$00,$3F,$00,$30,$00,$3F,$00,$03,$00,$3F,$C0  ;5000\r
+          DB      $0C,$C0,$0F,$F0,$03,$30,$03,$FC,$00,$CC,$00,$FC\r
+\r
+MONSTNUM  DB      $00,$00,$00,$00,$00,$2A,$00,$22,$02,$A2,$02,$2A  ;200\r
+          DB      $AA,$20,$0A,$A0,$A8,$00,$80,$00,$A8,$00,$00,$00\r
+          DB      $00,$00,$00,$00,$88,$00,$88,$00,$A8,$00,$0A,$A0  ;400\r
+          DB      $0A,$20,$02,$2A,$02,$A2,$00,$22,$00,$2A,$00,$00\r
+          DB      $00,$00,$00,$00,$00,$2A,$00,$22,$02,$A2,$02,$2A  ;800\r
+          DB      $AA,$20,$8A,$A0,$A8,$00,$88,$00,$A8,$00,$00,$00\r
+          DB      $20,$00,$A0,$00,$20,$00,$2A,$80,$A8,$00,$0A,$80  ;1600\r
+          DB      $08,$80,$0A,$A0,$02,$20,$02,$A8,$00,$88,$00,$A8\r
+\r
+* STAMPS FOR CLAPBOARD\r
+CLAPBRD   DB      $3F,$FF,$33,$C3,$3F,$0F,$3F,$FF,$30,$00,$30,$00  ;BASE C0\r
+          DB      $30,$00,$30,$00,$30,$00,$30,$00,$30,$00,$3F,$FF\r
+          DB      $FF,$FF,$C3,$C3,$0F,$0F,$FF,$FF,$00,$00,$00,$00  ;BASE C1\r
+          DB      $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$FF,$FF\r
+          DB      $FF,$FF,$C3,$C3,$0F,$0F,$FF,$FF,$00,$03,$00,$03  ;BASE C2\r
+          DB      $00,$03,$00,$03,$00,$03,$00,$03,$00,$03,$FF,$FF\r
+CLAPBRDD  DB      $3F,$FF,$33,$C3,$3F,$0F,$3F,$FF,$00,$00,$00,$00  ;DOWN C0\r
+          DB      $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00\r
+          DB      $FF,$FF,$C3,$C3,$0F,$0F,$FF,$FF,$00,$00,$00,$00  ;DOWN C1\r
+          DB      $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00\r
+          DB      $FF,$FF,$C3,$C3,$0F,$0F,$FF,$FF,$00,$00,$00,$00  ;DOWN C2\r
+          DB      $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00\r
+CLAPBRDU  DB      $00,$03,$00,$0C,$00,$30,$00,$F0,$03,$33,$0C,$3C  ;UP C0\r
+          DB      $3C,$30,$CC,$C0,$CF,$00,$CC,$00,$30,$00,$00,$00\r
+          DB      $00,$03,$00,$0C,$00,$3C,$00,$CC,$03,$0F,$0F,$0C  ;UP C1\r
+          DB      $33,$30,$C3,$C0,$C3,$00,$CC,$00,$F0,$00,$C0,$00\r
+          DB      $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00  ;UP C2\r
+          DB      $00,$00,$F0,$00,$30,$00,$3C,$00,$30,$00,$C0,$00\r
+\r
diff --git a/MSDEF.S b/MSDEF.S
new file mode 100644 (file)
index 0000000..21a21ff
--- /dev/null
+++ b/MSDEF.S
@@ -0,0 +1,398 @@
+\r
+*  MSDEF.S        MS PAC MAN SYMBOL DEFINITIONS\r
+*  ADDRESS DEFINITIONS\r
+\r
+*  ZERO PAGE\r
+\r
+*  ZERO PAGE VARIABLES THAT ARE NOT ERASED  $40-$9F\r
+\r
+STLEVEL   EQU     $40                    ;STARTING LEVEL OF GAME\r
+TWOPLAYR  EQU     $41                    ;WHETHER TWO-PLAYER MODE\r
+AUTOPLAY  EQU     $42                    ;1 IF AUTO-PLAY MODE\r
+\r
+NEWRAND   EQU     $43                    ;CURRENT SEED FOR RAND ROUTINE\r
+OLDRAND   EQU     $44                    ;OLD SEED FOR RAND ROUTINE\r
+\r
+PLAYER    EQU     $45                    ;WHICH PLAYER IS PLAYING\r
+P1SCORE   EQU     $46                    ;PLAYER 1 SCORE - 4 BYTES\r
+P1BONUS   EQU     $4A                    ;TIME TILL PLAYER 1 GETS BONUS LIFE\r
+P2SCORE   EQU     $4C                    ;PLAYER 2 SCORE - 4 BYTES\r
+P2BONUS   EQU     $50                    ;TIME TILL PLAYER 2 GETS BONUS LIFE\r
+\r
+RACKRAND  EQU     $52                    ;NUMBER BETWEEN 0..3 FOR THE RACK\r
+MENUFLAG  EQU     $53                    ;WHETHER IN MENU MODE OR NOT\r
+KNLTEMP0  EQU     $54                    ;STATE VARIABLE FOR KERNAL\r
+KNLTEMP1  EQU     $55                    ;STATE VARIABLE FOR KERNAL\r
+\r
+*  LOADER VARIABLES\r
+HPLIST    EQU     $56                    ;6 BYTES - HORIZONTAL POSITION\r
+VZLIST    EQU     $5C                    ;6 BYTES - VERTICAL ZONE\r
+VOLIST    EQU     $62                    ;6 BYTES - VERTICAL OFFSET\r
+SLLIST    EQU     $68                    ;6 BYTES - LOW BYTE STAMP ADDRESS\r
+SHLIST    EQU     $6E                    ;6 BYTES - HI BYTE STAMP ADDRESS\r
+DOLIST    EQU     $74                    ;6 BYTES - SOMETHING CHANGED - RELOAD\r
+OLDZONE   EQU     $7A                    ;6 BYTES - LAST ZONE CHARACTER IN\r
+\r
+*  SHADOWS FOR MONSTER COLORS (USED FOR FRUIT PALETTES)\r
+P0C1      EQU     $81                    ;PALETTE 2, COLOR 1\r
+P0C2      EQU     $82                    ;PALETTE 2, COLOR 2\r
+P0C3      EQU     $83                    ;PALETTE 2, COLOR 3\r
+\r
+RACKFRT   EQU     $84                    ;TYPE OF FRUIT TO DISPLAY UNDER RACK\r
+\r
+P1C1      EQU     $85                    ;PALETTE 3, COLOR 1\r
+P1C2      EQU     $86                    ;PALETTE 3, COLOR 2\r
+P1C3      EQU     $87                    ;PALETTE 3, COLOR 3\r
+\r
+DBSELECT  EQU     $88                    ;DEBOUNCE BYTE FOR SELECT\r
+\r
+P2C1      EQU     $89                    ;PALETTE 4, COLOR 1\r
+P2C2      EQU     $8A                    ;PALETTE 4, COLOR 2\r
+P2C3      EQU     $8B                    ;PALETTE 4, COLOR 3\r
+\r
+DBRESET   EQU     $8C                    ;DEBOUNCE BYTE FOR RESET\r
+\r
+P3C1      EQU     $8D                    ;PALETTE 5, COLOR 1\r
+P3C2      EQU     $8E                    ;PALETTE 5, COLOR 2\r
+P3C3      EQU     $8F                    ;PALETTE 5, COLOR 3\r
+\r
+DBPAUSE   EQU     $90                    ;DEBOUNCE BYTE FOR PAUSE\r
+\r
+P4C1      EQU     $91                    ;PALETTE 2, COLOR 1\r
+P4C2      EQU     $92                    ;PALETTE 2, COLOR 2\r
+P4C3      EQU     $93                    ;PALETTE 2, COLOR 3\r
+\r
+SCRNSTAT  EQU     $94                    ;SCREEN STATE, OFF IF $FF\r
+\r
+P5C1      EQU     $95                    ;PALETTE 3, COLOR 1\r
+P5C2      EQU     $96                    ;PALETTE 3, COLOR 2\r
+P5C3      EQU     $97                    ;PALETTE 3, COLOR 3\r
+\r
+TWOPORTS  EQU     $98                    ;WHETHER THE SECOND PORT HAS BEEN USED\r
+\r
+P6C1      EQU     $99                    ;PALETTE 4, COLOR 1\r
+P6C2      EQU     $9A                    ;PALETTE 4, COLOR 2\r
+P6C3      EQU     $9B                    ;PALETTE 4, COLOR 3\r
+\r
+HSCHERE   EQU     $9C                    ;IS HIGH SCORE CART PLUGGED IN\r
+\r
+P7C1      EQU     $9D                    ;PALETTE 5, COLOR 1\r
+P7C2      EQU     $9E                    ;PALETTE 5, COLOR 2\r
+P7C3      EQU     $9F                    ;PALETTE 5, COLOR 3\r
+\r
+*  ZERO PAGE VARIABLES THAT ARE ERASED IN GAMEINIT  $A0-$FF\r
+\r
+RTLOCAL   EQU     $A0                    ;TWO BYTES - MY CLOCK\r
+GAMEOVER  EQU     $A2                    ;FLAG FOR GAME OVER\r
+\r
+TOTLIVES  EQU     $A3                    ;TOTAL NUMBER OF LIVES\r
+*  $64-$6F ARE SWAPPED BETWEEN PLAYERS\r
+LIVES     EQU     $A4                    ;NUMBER OF LIVES\r
+RACK      EQU     $A5                    ;RACK PLAYER IS AT\r
+LEVEL     EQU     $A6                    ;LEVEL PLAYER IS AT\r
+ADJLEVEL  EQU     $A7                    ;LEVEL ADJUSTED FOR 'WRAP' AT HIGH LVL\r
+DOTS      EQU     $A8                    ;NUMBER OF DOTS\r
+DOTSEATN  EQU     $AA                    ;NUMBER OF DOTS EATEN\r
+DEATHFLG  EQU     $AB                    ;TRUE IF THE PAC HAS DIED YET\r
+PINKDOTS  EQU     $AC                    ;PINK RELEASE COUNTER\r
+BLUEDOTS  EQU     $AD                    ;BLUE RELEASE COUNTER\r
+GOLDDOTS  EQU     $AE                    ;GOLD RELEASE COUNTER\r
+FDOTS     EQU     $AF                    ;FRUIT RELEASE COUNTER\r
+\r
+*  TEMP VARIABLES\r
+TEMP0     EQU     $B0                    ;SCRATCH DATA FOR PROGRAM USE\r
+TEMP1     EQU     $B1                    ;MORE SCRATCH DATA\r
+TEMP2     EQU     $B2                    ;MORE SCRATCH DATA\r
+TEMP3     EQU     $B3                    ;MORE SCRATCH DATA\r
+TEMP4     EQU     $B4                    ;MORE SCRATCH DATA\r
+TEMP5     EQU     $B5                    ;MORE SCRATCH DATA\r
+TEMP6     EQU     $B6                    ;MORE SCRATCH DATA\r
+TEMP7     EQU     $B7                    ;MORE SCRATCH DATA\r
+TEMP8     EQU     $B8                    ;MORE SCRATCH DATA\r
+TEMP9     EQU     $B9                    ;MORE SCRATCH DATA\r
+TEMP10    EQU     $BA                    ;MORE SCRATCH DATA\r
+TEMP11    EQU     $BB                    ;MORE SCRATCH DATA\r
+TEMP12    EQU     $BC                    ;MORE SCRATCH DATA\r
+TEMP13    EQU     $BD                    ;MORE SCRATCH DATA\r
+TEMP14    EQU     $BE                    ;MORE SCRATCH DATA\r
+TEMP15    EQU     $BF                    ;MORE SCRATCH DATA\r
+TEMP16    EQU     $C0                    ;MORE SCRATCH DATA\r
+TEMP17    EQU     $C1                    ;MORE SCRATCH DATA\r
+TEMP18    EQU     $C2                    ;MORE SCRATCH DATA\r
+TEMP19    EQU     $C3                    ;MORE SCRATCH DATA\r
+TEMP20    EQU     $C4                    ;MORE SCRATCH DATA\r
+TEMP21    EQU     $C5                    ;MORE SCRATCH DATA\r
+TEMP22    EQU     $C6                    ;MORE SCRATCH DATA\r
+TEMP23    EQU     $C7                    ;MORE SCRATCH DATA\r
+\r
+LDRTEMP0  EQU     $C8                    ;SCRATCH DATA FOR KERNAL USE\r
+LDRTEMP1  EQU     $C9                    ;MORE SCRATCH DATA\r
+LDRTEMP2  EQU     $CA                    ;MORE SCRATCH DATA\r
+LDRTEMP3  EQU     $CB                    ;MORE SCRATCH DATA\r
+LDRTEMP4  EQU     $CC                    ;MORE SCRATCH DATA\r
+LDRTEMP5  EQU     $CD                    ;MORE SCRATCH DATA\r
+LDRTEMP6  EQU     $CE                    ;MORE SCRATCH DATA\r
+LDRTEMP7  EQU     $CF                    ;MORE SCRATCH DATA\r
+SOUNDZP   EQU     $C8                    ;ZERO PAGE FOR SOUND - SAME AS LOADER\r
+\r
+NEWDIR    EQU     $D0                    ;CURRENT JOYSTICK DIRECTION\r
+OLDDIR    EQU     $D1                    ;PREVIOUS DIFFERENT JOYSTICK DIRECTION\r
+BUTSTATE  EQU     $D2                    ;BOTTON STATUS - ON OR 0\r
+\r
+RTSAVE    EQU     $D4                    ;A PLACE TO SAVE RTLOCAL - 2 BYTES\r
+\r
+INDRJUMP  EQU     $D6                    ;PLACE TO PUT VALUES FOR INDERECT JUMP\r
+\r
+MONWAIT   EQU     $D8                    ;WAIT TILL NEXT MONSTER MOVE\r
+PACWAIT   EQU     $D9                    ;WAIT TILL NEXT PAC MOVE\r
+FRTWAIT   EQU     $DA                    ;WAIT TILL NEXT FRUIT MOVE\r
+FLSHWAIT  EQU     $DB                    ;WAIT TILL NEXT RACK INC\r
+BLUWAIT   EQU     $DC                    ;WAIT TILL END OF BLUE TIME\r
+SCORWAIT  EQU     $DD                    ;WAIT TILL NEXT ITER OF TIGHT LOOP\r
+RESWAIT   EQU     $DE                    ;WAIT TILL END OF RESET\r
+\r
+BAKLIVES  EQU     $E4                    ;OTHER PLAYER VERSION OF $54-$5F\r
+\r
+*  TIME LAST DOT WAS EATEN\r
+DOTTIME   EQU     $F0                    ;TWO BYTES\r
+\r
+* GLOBAL MONSTER STATE INFO\r
+SCORTIME  EQU     $F2                    ;MONSTER SCORE DELAY COUNTER\r
+BLUETIME  EQU     $F3                    ;BLUE TIME FOR THIS RACK\r
+M1REL     EQU     $F4                    ;MONSTER RELEASE THRESHHOLDS\r
+M2REL     EQU     $F5\r
+M3REL     EQU     $F6\r
+EATNDOTS  EQU     $F7                    ;DOTS EATEN SINCE LAST PAC DEATH\r
+TRELEASE  EQU     $F8                    ;COUNTER FOR MONSTER RELEASE\r
+REDTHRSH  EQU     $F9                    ;2 BYTES - RED SPEED THRESHHOLD\r
+NORMTIME  EQU     $FB                    ;2 BYTES - TIME SINCE BOR WHILE NOT BLU\r
+ISBLUE    EQU     $FD                    ;PAC IN BLUE MODE\r
+GREEDCNT  EQU     $FE                    ;MONSTERS EATEN ON THIS POWER DOT\r
+BORED     EQU     $FF                    ;MONSTERS ARE BORED\r
+\r
+\r
+*  HIGH RAM - NOTE, 1800-1DFF IS ZEROED IN ZERORAM\r
+\r
+*  HIGH SCORE RAM - SMASHED WHEN HIGH SCORE ROUTINES ARE CALLED\r
+HSCRAM    EQU     $1800                  ;$200 BYTES\r
+\r
+*  HIGH SCORE CART DIFFICULTY NAME\r
+HSCDIF    EQU     $1A00                  ;$20 BYTES\r
+\r
+*  SCREEN MAP - THROUGH $1BFF\r
+SCREEN    EQU     $1800                  ;SCREEN MAP\r
+SCORE     EQU     $1B48                  ;SCORE MAP - EFFECTIVELY THE 31ST LINE\r
+\r
+*  DOT ARRAYS - THROUGH $1CFF\r
+DOTARRAY  EQU     $1C00                  ;CURRENT PLAYER DOT ARRAY\r
+BAKDOTS   EQU     $1C80                  ;OTHER PLAYER DOT ARRAY\r
+\r
+*  TUNE VARIABLES\r
+TUNON     EQU     $1D00                  ;4 BYTES - WHETHER TUNE IS ACTIVE\r
+TUNINDEX  EQU     $1D04                  ;4 BYTES - WHAT TUNE IS PLAYING\r
+TUNPRIOR  EQU     $1D08                  ;4 BYTES - WHAT THE PRIORITY OF TUNE IS\r
+TUNBASE   EQU     $1D0C                  ;4 BYTES - BASE ADDRESS OF TUNE DATA\r
+TUNBASE1  EQU     $1D10                  ;4 BYTES - HI BYTE OF BASE ADDRESS\r
+FREQOFF   EQU     $1D14                  ;4 BYTES - OFFSET INTO DATA FOR FREQ'S\r
+CTLOFF    EQU     $1D18                  ;4 BYTES - OFFSET INTO DATA FOR CTL'S\r
+VOLOFF    EQU     $1D1C                  ;4 BYTES - OFFSET INTO DATA FOR VOL'S\r
+FREQTIME  EQU     $1D20                  ;4 BYTES - NUMBER FRAMES TILL NEXT FREQ\r
+CTLTIME   EQU     $1D24                  ;4 BYTES - NUMBER FRAMES TILL NEXT CTL\r
+VOLTIME   EQU     $1D28                  ;4 BYTES - NUMBER FRAMES TILL NEXT VOL\r
+TUNNUM    EQU     $1D2C                  ;WHAT TUNE YOU WANT - PARAMETER\r
+TUNTEMP0  EQU     $1D2D                  ;TEMP VALUE FOR TUNE DRIVER\r
+TUNTEMP1  EQU     $1D2E                  ;TEMP VALUE FOR TUNE DRIVER\r
+TUNOFF    EQU     $1D2F                  ;ARE TUNES TURNED OFF?\r
+\r
+*  KERNAL DISPLAY TABLES\r
+MSADDR    EQU     $1E40                  ;$1E BYTES - MS ADDRESS TABLE\r
+FRTADDR   EQU     $1E60                  ;$1E BYTES - FRUIT ADDRESS TABLE\r
+M0ADDR    EQU     $1E80                  ;$1E BYTES - MONSTER 0 ADDRESS TABLE\r
+M1ADDR    EQU     $1EA0                  ;$1E BYTES - MONSTER 1 ADDRESS TABLE\r
+M2ADDR    EQU     $1EC0                  ;$1E BYTES - MONSTER 2 ADDRESS TABLE\r
+M3ADDR    EQU     $1EE0                  ;$1E BYTES - MONSTER 3 ADDRESS TABLE\r
+\r
+*  KERNAL DISPLAY LISTS - MUST BE ON SAME PAGE\r
+DLIST0    EQU     $1F00                  ;$27 BYTES - DISPLAY LIST FOR GAME\r
+BDLIST0   EQU     $1F27                  ;$32 BYTES - DISPLAY LIST FOR INDICATOR\r
+DLIST1    EQU     $1F59                  ;$27 BYTES - DISPLAY LIST FOR GAME\r
+BDLIST1   EQU     $1F80                  ;$32 BYTES - DISPLAY LIST FOR INDICATOR\r
+TOPDLIST  EQU     $1FB2                  ;$07 BYTES - DISPLAY LIST FOR SCORE\r
+NULDLIST  EQU     $1FB7                  ;$02 BYTES - NULL DISPLAY LIST\r
+\r
+*  DISPLAY LIST LIST\r
+DLL       EQU     $1FC0                  ;$72 BYTES - LIST OF DISPLAY LISTS\r
+\r
+*         ***** HOLE FROM $2040 TO $20FF - SHADOWED IN PAGE 0 *****\r
+\r
+*  PAC STATE VARIABLES\r
+PVPOS     EQU     $2100                  ;VERTICAL POSITION\r
+PHPOS     EQU     $2101                  ;HORIZONTAL POSITION\r
+PZONE     EQU     $2102                  ;ROW\r
+POFF      EQU     VOLIST                 ;OFFSET\r
+PCOL      EQU     $2103                  ;COLUMN\r
+PDIR      EQU     $2104                  ;DIRECTION\r
+PDISP     EQU     $2105                  ;DISPLAY STATE\r
+PMOVING   EQU     $2106                  ;WHETHER IT IS STOPPED\r
+PTZONE    EQU     $2107                  ;ZONE OF LAST TURN\r
+PTCOL     EQU     $2108                  ;COLUMN OF LAST TURN\r
+PTEMP     EQU     $2109                  ;TEMP VARIABLE\r
+PDELAY    EQU     $210A                  ;DELAY FOR NEXT MOVE\r
+PTUNNEL   EQU     $210B                  ;WHETHER PAC IN TUNNEL\r
+\r
+*  FRUIT STATE VARIABLES\r
+FENABLE   EQU     $2110                  ;WHETHER FRUIT IS 'ON'\r
+FVPOS     EQU     $2111                  ;VERTICAL POSITION\r
+FHPOS     EQU     $2112                  ;HORIZONTAL POSITION\r
+FZONE     EQU     $2113                  ;ROW\r
+FOFF      EQU     VOLIST+1               ;OFFSET\r
+FCOL      EQU     $2114                  ;COLUMN\r
+FDIR      EQU     $2115                  ;DIRECTION\r
+FFRUIT    EQU     $2116                  ;WHICH FRUIT IT IS\r
+FCOUNT    EQU     $2117                  ;WHERE WE ARE RELATIVE TO CHAR CENTER\r
+FGZONE    EQU     $2118                  ;GOAL ZONE\r
+FGCOL     EQU     $2119                  ;GOAL COLUMN\r
+FGCOUNT   EQU     $211A                  ;WHAT GOAL TO LOOK FOR NEXT\r
+FSCORE    EQU     $211B                  ;IF NON-ZERO, FRUIT IS A SCORE\r
+FTUNNEL   EQU     $211C                  ;WHETHER FRUIT IN TUNNEL\r
+FSOUND    EQU     $211D                  ;SOUND STATE VARIABLE\r
+\r
+*  MONSTER STATE VARIABLES\r
+M0VPOS    EQU     $2120                  ;VERTICAL POSITION\r
+M0HPOS    EQU     $2124                  ;HORIZONTAL POSITION\r
+M0ZONE    EQU     $2128                  ;ROW\r
+M0OFF     EQU     VOLIST+2               ;OFFSET\r
+M0COL     EQU     $212C                  ;COLUMN\r
+M0DIR     EQU     $2130                  ;DIRECTION\r
+M0DISP    EQU     $2134                  ;DISPLAY STATE\r
+M0STATE   EQU     $2138                  ;STATE - ACTIVE, BLUE, EYES, ETC\r
+M0SLOW    EQU     $213C                  ;USED TO SLOW DOWN MONSTERS IN PEN\r
+M0BLUE    EQU     $2140                  ;BLUE MODE FLAG\r
+M0SPEED   EQU     $2144                  ;MONSTER SPEED\r
+M0TUNNEL  EQU     $2148                  ;IS IN TUNNEL\r
+M0FLIP    EQU     $214C                  ;IS ABOUT TO FLIP\r
+\r
+* SPEED REGISTER STUFF\r
+M0SPEED0  EQU     $2150                  ;MONSTER SPEED REGISTERS (BY 5 SPEEDS)\r
+M0SPEED1  EQU     $2155\r
+M0SPEED2  EQU     $215A\r
+M0SPEED3  EQU     $215F\r
+P0SPEED0  EQU     $2164                  ;PAC SPEED REGISTERS (BY 2 SPEEDS)\r
+P0SPEED1  EQU     $2166\r
+P0SPEED2  EQU     $2168\r
+P0SPEED3  EQU     $216A\r
+REVWAIT   EQU     $216C                  ; REVERSE TIME\r
+\r
+*  VARIABLES FOR ANIMATION DRIVER - OVERLAPS MONSTER VARIABLES\r
+ANAOFF    EQU     $2120                  ;OFFSET INTO ANIMATION DATA\r
+ANSOFF    EQU     $2121                  ;OFFSET INTO ANIMATION SEGMENT DATA\r
+ANCOUNT   EQU     $2122                  ;TICS TILL NEXT SEGMENT\r
+ANSTATE   EQU     $2123                  ;VARIOUS USES\r
+ANWHICH   EQU     $2124                  ;WHICH ANIMATION WE ARE WORKING ON\r
+ANFRM     EQU     $2125                  ;HOW MANY FRAMES PER TIC\r
+A0ENABLE  EQU     $2130                  ;WHETHER THIS CHARACTER IS ON\r
+A0VPOS    EQU     $2136                  ;VERTICAL POSITION OF THIS CHARACTER\r
+A0CHAR    EQU     $213C                  ;STAMP FOR THIS CHARACTER\r
+A0HPDIF   EQU     $2142                  ;INDEX INTO HPOS DELTA TABLE\r
+A0VPDIF   EQU     $2148                  ;INDEX INTO VPOS DELTA TABLE\r
+A0ANDIF   EQU     $214E                  ;INDEX INTO ANIMATE CHARACTER TABLE\r
+\r
+*         ***** HOLE FROM $2140 TO $21FF SHADOWED IN PAGE 1 *****\r
+\r
+*  STAMP DATA AREA - STAMPS IN $1X00-$1X2F, FONT IN $1X30-$1XFF\r
+STAMPS    EQU     $2200                  ;THROUGH THE END OF RAM - INCLUDES FONT\r
+*                 0-1                    BLANK\r
+*                 2-3                    BLACK BAR\r
+*                 4-9                    MS PAC\r
+*                 A-21                   MONSTERS (6 PER)\r
+*                 22-27                  FRUIT\r
+*                 28-2B                  MS PAC BONUS LIFE INDICATOR (4 PER)\r
+*                 30-BF                  FONT\r
+*                 E0-FF                  FRUIT INDICATORS (4 PER) - BANANA FIRST\r
+\r
+\r
+*\r
+*  MS CONSTANTS\r
+\r
+*  SOME SCREEN CONSTANTS\r
+LEFTSIDE  EQU     $18                    ;LEFT SIDE OF VISIBLE SCREEN\r
+RGHTSIDE  EQU     $88                    ;RIGHT SIDE OF VISIBLE SCREEN\r
+TOPSIDE   EQU     $00                    ;TOP SIDE OF VISIBLE SCREEN\r
+OFFSCRN   EQU     $B0                    ;AN OFF SCREEN LOCATION TO PUT INVIS.\r
+LEFTEDGE  EQU     27                     ;A MONSTER HERE IS ON LEFT OF SCREEN\r
+LEFTWRAP  EQU     19                     ;A MONSTER HERE IS ABOUT TO WRAP AROUND\r
+RGHTEDGE  EQU     131                    ;A MONSTER HERE IS ON RIGHT OF SCREEN\r
+RGHTWRAP  EQU     139                    ;A MONSTER HERE IS ABOUT TO WRAP AROUND\r
+WRAPSIZE  EQU     RGHTWRAP-LEFTWRAP      ;SIZE OF TUNNEL WRAP\r
+*\r
+NUMRACKS  EQU     $04                    ;NUMBER OF RACKS\r
+*\r
+*  MONSTER CONSTANTS\r
+MSTATPEN  EQU     $04                    ; IT IS SITTING IN THE PEN *\r
+MSTINPEN  EQU     $03                    ; EYES TRYING TO GET INTO PEN\r
+MSTLVPEN  EQU     $02                    ; MONSTER LEAVING PEN *\r
+MSTEYES   EQU     $01                    ; EYES MOVING ARROUND\r
+MSTNORM   EQU     $00                    ; NORMAL MOVEMENT *\r
+SPDNORM   EQU     $00\r
+SPDBLUE   EQU     $01\r
+SPDSLOW   EQU     $02\r
+SPDRED1   EQU     $03\r
+SPDRED2   EQU     $04\r
+*\r
+* EVENT DRIVER CONSTANTS\r
+MAXEVENT  EQU     $F\r
+*\r
+*  SCREEN LOCATIONS\r
+INITHPOS  EQU     $4F                    ;HPOS OF INITIAL MS PAC PLACE\r
+INITVPOS  EQU     $81                    ;VPOS OF INITIAL MS PAC PLACE\r
+*\r
+*  CONSTANT TIMES TO WAIT FOR THINGS\r
+WAITMON   EQU     $01                    ;WAIT FOR MONSTER MOVES\r
+WAITPAC   EQU     $01                    ;WAIT FOR PAC MOVES\r
+WAITFRT   EQU     $05                    ;WAIT FOR FRUIT MOVES\r
+WAITFLSH  EQU     $08                    ;WAIT FOR FLASHING POWER DOTS\r
+*\r
+*  COLOR DEFINITIONS\r
+BLACK     EQU     $00\r
+LTPINK    EQU     $5E\r
+WHITE     EQU     $0C\r
+PINK      EQU     $57\r
+RED       EQU     $32\r
+GREEN     EQU     $E7\r
+PURPLE    EQU     $63\r
+BLUE      EQU     $98\r
+YELLOW    EQU     $1E\r
+LTBLUE    EQU     $AE\r
+DKBLUE    EQU     $82\r
+BROWN     EQU     $15\r
+LTGREEN   EQU     $EB\r
+LTBROWN   EQU     $3B\r
+GOLD      EQU     $2A\r
+HOTPINK   EQU     $54\r
+ORANGE    EQU     $35\r
+*\r
+*  FONT DEFINITIONS\r
+BLNKCHAR  EQU     $50                    ;BLANK\r
+DOTCHAR   EQU     $51                    ;DOT\r
+EDOTCHAR  EQU     $52                    ;ENERGY DOT\r
+DOORCHAR  EQU     $3D                    ;DOOR TO THE PEN\r
+MARQCHAR  EQU     $7B                    ;START OF MARQUEE CHARACTERS\r
+*\r
+*  JOYSTICK DIRECTIONS\r
+DRIGHT    EQU     0\r
+DDOWN     EQU     1\r
+DLEFT     EQU     2\r
+DUP       EQU     3\r
+DCENTER   EQU     4\r
+DDWRIGHT  EQU     5\r
+DDWLEFT   EQU     6\r
+DUPLEFT   EQU     7\r
+DUPRIGHT  EQU     8\r
+*\r
+P1SCRCOL  EQU     $00                    ;COLUMN FOR PLAYER 1 SCORE\r
+P2SCRCOL  EQU     $15                    ;COLUMN FOR PLAYER 2 SCORE\r
+*\r
+STACKPTR  EQU     $FF                    ;WHERE STACK IS ON PAGE 1\r
+*\r
+GRAPHON   EQU     $48                    ;CTL VALUE FOR NORMAL GRAPHICS\r
+GRAPHOFF  EQU     $FF                    ;CTL VALUE FOR GRAPHICS OFF\r
diff --git a/MSMOVE.S b/MSMOVE.S
new file mode 100644 (file)
index 0000000..c33cd51
--- /dev/null
+++ b/MSMOVE.S
@@ -0,0 +1,510 @@
+\r
+*  PAC.S          ROUTINES FOR THE MS PAC\r
+\r
+\r
+*  MOVE THE MS PAC\r
+MOVEPAC   JSR     SETPAC                 ;SET NEXT PAC MOVE\r
+          INC     TRELEASE\r
+\r
+          JSR     INCPSPED\r
+          JSR     CHKPAC                 ;SEE IF SPEED REG SAYS ITS TIME\r
+          BEQ     MPOUT\r
+\r
+          DEC     PDELAY                 ;SEE IF WE ARE IN A DOT EATING DELAY\r
+          BNE     MPOUT\r
+          INC     PDELAY\r
+\r
+          LDA     PTUNNEL\r
+          BEQ     MPNORM\r
+          JSR     PACDIRT                ;SEE IF DIRECTION CHANGED IN TUNNEL\r
+          JSR     PACTUNNL               ;MOVE THROUGH THE TUNNEL\r
+          JMP     MPCHOMP\r
+\r
+MPNORM    JSR     PACDIR                 ;SET THE DIRECTION\r
+          LDA     PMOVING                ;IF NOT MOVING, DO NOTHING\r
+          BEQ     MPOUT\r
+          JSR     PACMOVE                ;MOVE THE PAC\r
+          JSR     PACEAT                 ;SEE IF ANYTHING GOOD TO EAT\r
+MPCHOMP   JSR     PACCHOMP               ;CHANGE THE DISPLAY STATE\r
+          JSR     WRITEPAC               ;WRITE THE PAC\r
+          JMP     PFINTR                 ;LOOK FOR ANY INTERSECTIONS\r
+\r
+\r
+*  SET THE NEXT MS PAC MOVE\r
+SETPAC    LDA     RTLOCAL+1\r
+          CLC\r
+          ADC     #WAITPAC\r
+          STA     PACWAIT\r
+MPOUT     RTS\r
+\r
+\r
+*  THIS ROUTINE FINDS OUT WHAT DIRECTION TO MOVE\r
+PACDIR    LDA     AUTOPLAY               ;SEE IF WE ARE PLAYING\r
+          BEQ     PACDCONT\r
+          JMP     AUTODIR\r
+\r
+PACDCONT  JSR     PACJOY                 ;GET A JOYSTICK DIRECTION\r
+\r
+          LDX     PZONE                  ;SET UP FOR CHECKDIR\r
+          STX     TEMP4\r
+          LDA     PCOL\r
+          STA     TEMP5\r
+          LDA     PDIR\r
+          STA     TEMP6\r
+          JSR     CHECKDIR               ;GET LEGITIMATE JOYSTICK DIRECTIONS\r
+\r
+          LDY     NEWDIR                 ;GET THE DIRECTION\r
+          CPY     PDIR                   ;SEE IF TURNED\r
+          BEQ     PDOUT\r
+          CPY     #$04                   ;SEE IF CENTERED\r
+          BPL     PDOUT\r
+\r
+          LDA     TEMP12,Y               ;SEE IF LEGITIMATE\r
+          BMI     PDOUT\r
+          STY     PDIR                   ;GOOD - SET DIRECTION\r
+          LDA     #$01\r
+          STA     PMOVING                ;START IT AGAIN IF IT WAS STOPPED\r
+\r
+PDOUT     LDA     PHPOS                  ;SEE IF IN 'CENTER' OF CHAR\r
+          AND     #$03\r
+          CMP     #$01\r
+          BNE     PDEND\r
+          LDA     POFF\r
+          CMP     #$03\r
+          BNE     PDEND\r
+          LDX     PDIR\r
+          LDA     TEMP12,X               ;SEE IF PAC STOPPED AGAINST WALL\r
+          BPL     PDEND\r
+          LDA     #$00\r
+          STA     PMOVING\r
+PDEND     RTS\r
+\r
+\r
+*  THIS ROUTINE GETS A JOYSTICK DIRECTION AND TURNS THE 8-WAY JOYSTICK INTO A\r
+*  4-WAY\r
+PACJOY    JSR     GETJOY                 ;GET THE JOYSTICK DIRECTION\r
+\r
+          LDA     NEWDIR                 ;SEE IF ANY INTERPRETATION NEEDED\r
+          SEC\r
+          SBC     #DDWRIGHT\r
+          BMI     PJOUT\r
+          STA     TEMP0                  ;THIS IS AMOUNT OVER DCENTER\r
+\r
+          LDA     PDIR                   ;GET CURRENT DIRECTION\r
+          ASL     A\r
+          ASL     A                      ;MULTIPLY BY 4\r
+          ORA     TEMP0                  ;ADD IN DIRECTION\r
+          TAX\r
+          LDA     PJOYTAB,X              ;FIND NEW DIRECTION\r
+          STA     NEWDIR                 ;AND STORE IT AWAY\r
+\r
+PJOUT     RTS\r
+\r
+\r
+*  MOVE THE MS PAC\r
+PACMOVE   LDY     PDIR                   ;MOVE THE PAC IN THE RIGHT DIRECTION\r
+          LDX     POFF\r
+          TYA\r
+          AND     #$01                   ;WILL BE NON-ZERO IF VERTICAL MOVE\r
+          BNE     PMVERT\r
+\r
+          LDA     PHPOS                  ;MOVE HORIZONTALLY\r
+          JSR     HPOSADJ\r
+          STA     PHPOS\r
+          CMP     #RGHTEDGE              ;CHECK FOR TUNNEL WRAP\r
+          BCC     PMHJMP0\r
+          STA     PTUNNEL\r
+PMHJMP0   CMP     #LEFTEDGE\r
+          BCS     PMHJMP1\r
+          STA     PTUNNEL\r
+\r
+PMHJMP1   LDA     PVPOSADJ,X             ;CENTER ADJUST VERTICALLY\r
+          CLC\r
+          ADC     PVPOS\r
+          STA     PVPOS\r
+          JMP     PMOUT\r
+\r
+PMVERT    LDA     PVPOS\r
+          JSR     VPOSADJ                ;MOVE VERTICALLY\r
+          STA     PVPOS\r
+\r
+          LDA     PHPOS                  ;CENTER ADJUST HORIZONTALLY\r
+          AND     #$03\r
+          TAX\r
+          LDA     PHPOSADJ,X\r
+          CLC\r
+          ADC     PHPOS\r
+          STA     PHPOS\r
+\r
+PMOUT     LDA     PHPOS\r
+          JSR     HTOC\r
+          STA     PCOL\r
+PACVTOZO  LDA     PVPOS                  ;OUTSIDE ENTRY TO SET ZONE AND OFFSET\r
+          JSR     VTOZO\r
+          INY\r
+          STY     PZONE\r
+          STA     POFF\r
+          RTS\r
+\r
+\r
+*  THIS ROUTINE FINDS OUT IF THE PLAYER IS CHANGING DIRECTION IN TUNNEL\r
+PACDIRT   LDA     AUTOPLAY               ;SEE IF WE ARE PLAYING\r
+          BNE     PDTOUT\r
+\r
+          JSR     PACJOY                 ;GET A JOYSTICK DIRECTION\r
+\r
+          LDA     NEWDIR                 ;GET THE DIRECTION\r
+          CMP     PDIR                   ;SEE IF TURNED\r
+          BEQ     PDTOUT\r
+          CMP     #DCENTER               ;SEE IF CENTERED\r
+          BPL     PDTOUT\r
+          AND     #$01                   ;MAKE SURE LEFT OR RIGHT\r
+          BNE     PDTOUT\r
+\r
+          LDA     NEWDIR\r
+          STA     PDIR                   ;GOOD - SET DIRECTION\r
+\r
+PDTOUT    RTS\r
+\r
+\r
+*  MOVE THE MS PAC THROUGH THE TUNNEL\r
+PACTUNNL  LDY     PDIR                   ;MOVE THE PAC IN THE RIGHT DIRECTION\r
+          LDX     POFF\r
+          LDA     PHPOS                  ;MOVE HORIZONTALLY\r
+          JSR     HPOSADJ\r
+          STA     PHPOS\r
+\r
+          CPY     #DRIGHT\r
+          BEQ     PTRIGHT\r
+          CMP     #LEFTWRAP              ;MOVING LEFT\r
+          BCS     PTLJMP0                ;SEE IF WRAP TIME YET\r
+          CLC\r
+          ADC     #WRAPSIZE\r
+          STA     PHPOS\r
+PTLJMP0   CMP     #RGHTEDGE              ;SEE IF END OF TUNNEL\r
+          BCS     PTLJMP1\r
+          CMP     #80\r
+          BCC     PTLJMP1\r
+          LDA     #$00\r
+          STA     PTUNNEL\r
+PTLJMP1   JMP     PMHJMP1\r
+\r
+PTRIGHT   CMP     #RGHTWRAP              ;MOVING RIGHT\r
+          BCC     PTRJMP0                ;SEE IF WRAP TIME YET\r
+          SEC\r
+          SBC     #WRAPSIZE\r
+          STA     PHPOS\r
+PTRJMP0   CMP     #LEFTEDGE              ;SEE IF END OF TUNNEL\r
+          BCC     PTRJMP1\r
+          CMP     #80\r
+          BCS     PTRJMP1\r
+          LDA     #$00\r
+          STA     PTUNNEL\r
+PTRJMP1   JMP     PMHJMP1\r
+\r
+\r
+*  ADJUST THE MS PAC DISPLAY STATE\r
+PACCHOMP  LDX     PDISP                  ;ADJUST MS PAC STATE\r
+          BMI     MPOPEN\r
+          DEX                            ;MS PAC CLOSING\r
+          BNE     MPSDISP\r
+          LDX     #$80\r
+          JMP     MPSDISP\r
+MPOPEN    INX                            ;MS PAC OPENING\r
+          CPX     #$82\r
+          BNE     MPSDISP\r
+          LDX     #$02\r
+MPSDISP   STX     PDISP\r
+          RTS\r
+\r
+\r
+*  SEE IF ANYTHING GOOD TO EAT WHERE MS PAC IS\r
+PACEAT    LDX     PZONE\r
+          STX     TEMP0\r
+          LDA     PCOL\r
+          STA     TEMP1\r
+          JSR     GETCHAR                ;SEE WHAT IS UNDER HER\r
+          CMP     #DOTCHAR               ;SEE IF NORMAL DOT\r
+          BEQ     PEATDOT\r
+          AND     #$FE                   ;GET RID OF LEFT/RIGHT PARITY\r
+          CMP     #EDOTCHAR              ;SEE IF ENERGY DOT\r
+          BEQ     PEATEDOT\r
+          RTS\r
+PEATEDOT  JSR     TURNBLUE               ;EATING AN ENERGY DOT\r
+          LDA     #$04                   ;ADD 50 TO SCORE\r
+          JSR     ADDSCORE\r
+AAAAA     LDA     #3\r
+          STA     PDELAY\r
+          JMP     PECLEAR\r
+PEATDOT   LDA     #$01                   ;EAT A DOT\r
+          JSR     ADDSCORE               ;ADD 10 TO SCORE\r
+          LDA     #$10                   ;MAKE DOT MUNCH SOUND\r
+          JSR     DOTUNE\r
+          LDA     #1\r
+          STA     PDELAY\r
+PECLEAR   JSR     SAVETIME               ;FIRST - SAY A DOT WAS EATEN NOW\r
+          LDX     PZONE\r
+          STX     TEMP0\r
+          LDA     PCOL\r
+          STA     TEMP1\r
+          LDX     #BLNKCHAR              ;CLEAR THE CURRENT POSITION\r
+          JSR     PLOPCHAR\r
+          DEC     FDOTS\r
+          BPL     PEDCONT\r
+          JSR     INITFRT\r
+PEDCONT   DEC     DOTS                   ;ONE LESS DOT TO EAT - SEE IF RACK DONE\r
+          BNE     PCCONT\r
+          DEC     DOTS+1                 ;SEE IF ALL OUT\r
+          BPL     PCCONT\r
+          JMP     PNEXTRCK               ;RACK ALL OVER\r
+PCCONT    INC     DOTSEATN\r
+          LDA     #0\r
+          STA     TRELEASE\r
+\r
+          LDA     DEATHFLG\r
+          BEQ     INCDOTZ\r
+          INC     EATNDOTS\r
+          RTS\r
+INCDOTZ\r
+          LDA     M0STATE+3\r
+          CMP     #MSTATPEN\r
+          BNE     INCDTOUT\r
+          LDA     M0STATE+2\r
+          CMP     #MSTATPEN\r
+          BEQ     INCDOTZ1\r
+          INC     GOLDDOTS\r
+          RTS\r
+INCDOTZ1  LDA     M0STATE+1\r
+          CMP     #MSTATPEN\r
+          BEQ     INCDOTZ2\r
+          INC     BLUEDOTS\r
+          RTS\r
+INCDOTZ2  INC     PINKDOTS\r
+INCDTOUT\r
+          RTS\r
+PNEXTRCK  JMP     NEXTRACK               ;ALL DONE\r
+\r
+\r
+*  INITIALIZE THE MS PAC STATE\r
+INITPAC   LDA     #INITVPOS              ;SET VERTICAL POSITION AND ZONE\r
+          STA     PVPOS\r
+          JSR     VTOZO\r
+          INY\r
+          STY     PZONE\r
+          STA     POFF\r
+          LDA     #INITHPOS              ;SET HORIZONTAL POSITION AND COLUMN\r
+          STA     PHPOS\r
+          JSR     HTOC\r
+          STA     PCOL\r
+          LDA     #DLEFT                 ;SET DIRECTION\r
+          STA     PDIR\r
+          STA     NEWDIR                 ;AND DEFAULT JOYSTICK DIRECTION\r
+          LDA     #$01                   ;SET DISPLAY STATE\r
+          STA     PDISP\r
+          STA     PMOVING\r
+          STA     PDELAY\r
+          LDA     #$00\r
+          STA     PTUNNEL\r
+\r
+          JSR     PACSTAMP\r
+          JSR     WRITEPAC               ;WRITE IT\r
+          JMP     SAVETIME               ;START TIME WITH NOW\r
+\r
+\r
+*  THIS ROUTINE SETS UP THE COLORS FOR MS PAC-MAN\r
+PACSTAMP  LDA     #YELLOW                ;SET MS PAC COLORS\r
+          STA     P1C1\r
+          LDA     #PINK\r
+          STA     P1C2\r
+          LDA     #BLACK\r
+          STA     P1C3\r
+          RTS\r
+\r
+\r
+*  WRITE A MS PAC ON THE SCREEN\r
+WRITEPAC  LDA     PDISP                  ;SET WHICH STAMP\r
+          ASL     A\r
+          ASL     A\r
+          ORA     PDIR                   ;A = MOUTH STATE*4 + DIRECTION\r
+          TAX\r
+          LDA     PACSTMPL,X             ;SET STAMP LISTS\r
+          STA     SLLIST\r
+          LDA     PACSTMPH,X\r
+          STA     SHLIST\r
+\r
+          LDA     PHPOS                  ;SET HPOS, DO FLAG, AND LEAVE\r
+          SEC\r
+          SBC     #$03\r
+          STA     HPLIST\r
+          LDX     PZONE\r
+          DEX\r
+          STX     VZLIST\r
+          STA     DOLIST\r
+          RTS\r
+\r
+\r
+*  ERASE THE MS PAC\r
+ERASEPAC  LDA     #OFFSCRN               ;PUT THE CHARACTER OFF SCREEN\r
+          STA     HPLIST\r
+          STA     DOLIST\r
+ADEND     RTS\r
+\r
+\r
+*  THIS ROUTINE GIVES A DIRECTION WHEN IN AUTO-PLAY MODE\r
+AUTODIR   LDA     PHPOS                  ;SEE IF IN 'CENTER' OF CHAR\r
+          AND     #$03\r
+          CMP     #$01\r
+          BNE     ADEND\r
+          LDA     POFF\r
+          CMP     #$03\r
+          BNE     ADEND\r
+\r
+          LDX     PZONE                  ;SET UP FOR CHECKDIR\r
+          STX     TEMP4\r
+          LDA     PCOL\r
+          STA     TEMP5\r
+          LDA     PDIR\r
+          STA     TEMP6\r
+\r
+          JSR     RAND                   ;PICK RANDOM CORNER AS DEFAULT GOAL\r
+          AND     #$03\r
+          TAX\r
+          LDA     RANDZONE,X\r
+          STA     TEMP7\r
+          LDA     RANDCOL,X\r
+          STA     TEMP8\r
+\r
+          LDX     #$00                   ;FIRST - SEE IF A MONSTER IS THE GOAL\r
+ADMLOOP   LDA     M0BLUE,X               ;MAKE SURE IT IS BLUE AND NORMAL\r
+          BEQ     ADMNEXT\r
+          LDA     M0STATE,X\r
+          CMP     #MSTNORM\r
+          BNE     ADMNEXT\r
+          LDY     M0ZONE,X\r
+          STY     TEMP7\r
+          LDA     M0COL,X\r
+          STA     TEMP8\r
+          JMP     ADOUT\r
+ADMNEXT   INX\r
+          CPX     #$04\r
+          BMI     ADMLOOP\r
+\r
+          LDY     RACKRAND               ;GET OUR STARTING POWER DOT\r
+ADPLOOP   LDA     RACK\r
+          EOR     RRZONE,Y\r
+          TAX                            ;GET ZONE FOR THIS DOT\r
+          LDA     EDZONE0,X\r
+          STA     TEMP0\r
+          LDA     RACK\r
+          EOR     RRCOL,Y\r
+          TAX                            ;GET COLUMN FOR THIS DOT\r
+          LDA     EDCOL0,X\r
+          STA     TEMP1\r
+          JSR     GETCHAR                ;SEE IF IT IS THERE\r
+          AND     #$FE                   ;MIGHT BE FLASHED\r
+          CMP     #EDOTCHAR\r
+          BEQ     ADEDOT\r
+          INY                            ;CHECK NEXT DOT\r
+          CPY     #$04\r
+          BMI     ADPJMP0\r
+          LDY     #$00\r
+ADPJMP0   CPY     RACKRAND               ;SEE IF WE'VE TRIED ALL DOTS\r
+          BNE     ADPLOOP\r
+          JMP     ADFRUIT\r
+\r
+ADEDOT    LDA     TEMP0                  ;FOUND A DOT\r
+          STA     TEMP7\r
+          LDA     TEMP1\r
+          STA     TEMP8\r
+\r
+ADFRUIT   LDA     FENABLE                ;SEE IF TRY FOR FRUIT\r
+          BEQ     ADOUT\r
+          LDA     FSCORE\r
+          BNE     ADOUT\r
+          LDX     FZONE\r
+          STX     TEMP7\r
+          LDA     FCOL\r
+          STA     TEMP8\r
+          JMP     ADOUT\r
+\r
+ADOUT     JSR     CHECKDIR               ;FIND VALID DIRECTIONS\r
+          CMP     #0\r
+          BNE     ADFINSH\r
+          JSR     WHCHWAY                ;FIND RIGHT DIRECTION\r
+          STA     PDIR                   ;STORE IT\r
+ADFINSH   RTS\r
+\r
+\r
+*  THIS PUTS THE MS PAC THROUGH THE DEATH SEQUENCE\r
+KILLPAC   JSR     CLEARTUN\r
+          JSR     FINALDOT\r
+          JSR     WAIT\r
+          LDA     #$00\r
+          STA     DEATHFLG\r
+          LDA     #$01\r
+          STA     PDIR                   ;MAKE HER POINT DOWN\r
+          STA     PDISP                  ;MAKE HER HALF OPEN\r
+          JSR     WRITEPAC\r
+          LDA     #$0C                   ;MAKE DEATH SOUND\r
+          JSR     DOTUNE\r
+\r
+          LDX     #$05\r
+          LDA     #OFFSCRN               ;TURN EVERYTHING ELSE OFF THE SCREEN\r
+KPCLLOOP  STA     HPLIST,X\r
+          STA     DOLIST,X\r
+          DEX\r
+          BNE     KPCLLOOP\r
+\r
+          LDA     #$09                   ;SPIN 2 1/2 TIMES\r
+          STA     TEMP0\r
+KPSLOOP   LDA     RTLOCAL+1              ;SPIN MS PAC\r
+          CLC\r
+          ADC     #$07\r
+          STA     TEMP16\r
+KPSLLOOP  JSR     SEEBNORM\r
+          LDA     TEMP16\r
+          CMP     RTLOCAL+1              ;WAIT FOR A BIT\r
+          BPL     KPSLLOOP\r
+          INC     PDIR\r
+          LDA     PDIR\r
+          AND     #$03\r
+          STA     PDIR\r
+          JSR     WRITEPAC\r
+          DEC     TEMP0\r
+          BPL     KPSLOOP\r
+          RTS\r
+\r
+\r
+*  THIS ROUTINE SAVES THE PRESENT TIME IN DOTTIME\r
+SAVETIME  LDA     RTLOCAL\r
+          STA     DOTTIME\r
+          LDA     RTLOCAL+1\r
+          STA     DOTTIME+1\r
+          RTS\r
+\r
+\r
+*  TABLES FOR PAC STAMPS\r
+PACSTMPL  DB      L(MSCHAR),L(MSCHAR+$48),L(MSCHAR+$90),L(MSCHAR+$D8)\r
+          DB      L(MSCHAR+$18),L(MSCHAR+$60),L(MSCHAR+$A8),L(MSCHAR+$F0)\r
+          DB      L(MSCHAR+$30),L(MSCHAR+$78),L(MSCHAR+$C0),L(MSCHAR+$108)\r
+PACSTMPH  DB      H(MSCHAR),H(MSCHAR+$48),H(MSCHAR+$90),H(MSCHAR+$D8)\r
+          DB      H(MSCHAR+$18),H(MSCHAR+$60),H(MSCHAR+$A8),H(MSCHAR+$F0)\r
+          DB      H(MSCHAR+$30),H(MSCHAR+$78),H(MSCHAR+$C0),H(MSCHAR+$108)\r
+\r
+*  TABLES FOR CENTERING ADJUSTMENT\r
+PHPOSADJ  DB      $01,$00,$FF,$FF\r
+PVPOSADJ  DB      $02,$02,$01,$00,$FF,$FE\r
+\r
+*  TABLES FOR RANDOM CORNERS\r
+RANDZONE  DB      $00,$1D,$00,$1D\r
+RANDCOL   DB      $00,$1B,$00,$1B\r
+\r
+*  TABLES FOR GOING FROM E-DOT INDEX TO ZONE AND COL FOR THAT DOT\r
+RRZONE    DB      $00,$00,$04,$04\r
+RRCOL     DB      $00,$04,$00,$04\r
+\r
+*  TABLES FOR CONVERTING THE JOYSTICK FROM 8-WAY TO 4-WAY\r
+PJOYTAB   DB      DRIGHT,DDOWN,DUP,DRIGHT\r
+          DB      DDOWN,DDOWN,DLEFT,DRIGHT\r
+          DB      DDOWN,DLEFT,DLEFT,DUP\r
+          DB      DRIGHT,DLEFT,DUP,DUP\r
diff --git a/MUP.S b/MUP.S
new file mode 100644 (file)
index 0000000..5ffc7b4
--- /dev/null
+++ b/MUP.S
@@ -0,0 +1,40 @@
+JS\r
+^L\r
+SW1\r
+\r
+edT\r
+0\r
+\r
+10000\r
+\r
+E\r
+A\r
+A000\r
+\r
+6000\r
+\r
+S\r
+A\r
+\r
+edS\r
+0\r
+A000\r
+1\r
+C000\r
+2\r
+E000\r
+\r
+D01\r
+ST17\r
+\r
+D3C\r
+STFF\r
+\r
+l1:ms.z\r
+\r
+\r
+\r
+ena\r
+\r
+ir\r
+SEPC#MAIN\r
diff --git a/PATH.S b/PATH.S
new file mode 100644 (file)
index 0000000..5d20d01
--- /dev/null
+++ b/PATH.S
@@ -0,0 +1,229 @@
+\r
+* PATH.S          ROUTINES FOR PATH ANALYSIS IN MS PAC-MAN\r
+*\r
+\r
+* CHECKDIR  - CHECK FOR DIRECTIONS FROM A LOCATION\r
+*         IN:     TEMP4 = ZONE, TEMP5 = COLUMN, TEMP6 = DIR\r
+*         OUT:    T12=RIGHT, T13=DOWN, T14=LEFT, T15=UP,(LEGIT=0,BACK=1,WALL=-1)\r
+*                 A=~INTERSECT\r
+*  Y IS DISTORTED, X IS SAVED\r
+*  TEMP0-3,10-11 ARE USED\r
+\r
+CHECKDIR  STX     TEMP11\r
+          LDA     #0\r
+          STA     TEMP12\r
+          STA     TEMP13\r
+          STA     TEMP14\r
+          STA     TEMP15\r
+          TAX\r
+\r
+CHDLOOP   LDA     T4OFF,X                ;GET ZONE AND COLUMN NEXT TO POS\r
+          CLC\r
+          ADC     TEMP4\r
+          STA     TEMP0\r
+          LDA     T5OFF,X\r
+          CLC\r
+          ADC     TEMP5\r
+          STA     TEMP1\r
+          JSR     GETCHAR                ;FIND OUT WHAT IS THERE\r
+          CMP     #BLNKCHAR              ;SEE IF VALID PLACE TO GO\r
+          BPL     CHDNEXT\r
+          LDA     #-1                    ;NO GOOD\r
+          STA     TEMP12,X\r
+CHDNEXT   INX\r
+          CPX     #$04\r
+          BMI     CHDLOOP\r
+\r
+          LDA     TEMP6                  ;SET DIRECTION WE CAME FROM\r
+          CLC\r
+          ADC     #2\r
+          AND     #3\r
+          TAX\r
+          LDA     #1\r
+          STA     TEMP12,X\r
+\r
+          LDA     TEMP6                  ;SEE IF IN INTERSECTION\r
+          CLC\r
+          ADC     #1\r
+          AND     #3\r
+          TAX\r
+          CLC\r
+          ADC     #2\r
+          AND     #3\r
+          TAY\r
+          LDA     #$FF\r
+          AND     TEMP12,X\r
+          AND     TEMP12,Y\r
+          LDX     TEMP11\r
+          RTS\r
+\r
+* WHCHWAY - GIVEN A INTERSECTION AND A GOAL, FIGURE OUT BEST PATH\r
+*         IN:     TEMP4=CURRENT ZONE, TEMP5=CURRENT COL, TEMP6= CURRENT DIR\r
+*                 TEMP7=GOAL ZONE, TEMP8=GOAL COL, TEMP12-15 INTERSECTION STATE\r
+*         OUT:    A=GOAL DIR\r
+*         USES:   TEMP0-3,9-11\r
+*         SAVES:  X,Y\r
+\r
+WHCHWAY   TXA                            ;STORE REGISTERS ON STACK\r
+          PHA\r
+          TYA\r
+          PHA\r
+          JSR     NORMGOAL               ;NORMALIZE GOAL\r
+          JSR     SETSQUAR\r
+          LDA     TEMP6\r
+          STA     TEMP2                  ; CURRENT BEST DIRECTION\r
+          LDA     #$8F                   ; LARGE NEG NUMBER\r
+          STA     TEMP3                  ; -(CURRENT DISTANCE IN BEST DIRECTION)\r
+          LDX     #0\r
+\r
+WWLOOP    LDA     T4OFF,X                ;ADJUST ZONE AND COLUMN\r
+          CLC\r
+          ADC     TEMP4\r
+          STA     TEMP9\r
+          LDA     T5OFF,X\r
+          CLC\r
+          ADC     TEMP5\r
+          STA     TEMP10\r
+          LDA     TEMP12,X               ;GET STATE THERE, SEE IF VALID\r
+          BNE     WWNEXT\r
+          JSR     CALCDIST               ;FIND DISTANCE TO GOAL\r
+          CMP     TEMP3                  ;SEE IF SHORTER\r
+          BCC     WWNEXT\r
+          STA     TEMP3                  ;NEW CURRENT DISTANCE\r
+          STX     TEMP2                  ;NEW DIRECTION\r
+WWNEXT    INX\r
+          CPX     #$04\r
+          BMI     WWLOOP\r
+\r
+          PLA                            ;RESTORE REGISTERS FROM STACK\r
+          TAY\r
+          PLA\r
+          TAX\r
+          LDA     TEMP2\r
+          RTS\r
+\r
+\r
+*  NORMGOAL       NORMALIZES THE GOAL ZONE AND COLUMN.  MAKES SURE THEY ARE IN\r
+*                 THE RANGE 0..3F\r
+*         IN:     TEMP7=GOAL ZONE, TEMP8=GOAL COLUMN\r
+*         OUT:    TEMP7, TEMP8 NORMALIZED\r
+NORMGOAL  LDA     TEMP7                  ;FIRST DO ZONE\r
+          JSR     NORMLIZE\r
+          STA     TEMP7\r
+          LDA     TEMP8                  ;THEN COLUMN\r
+          JSR     NORMLIZE\r
+          STA     TEMP8\r
+          RTS\r
+\r
+NORMLIZE  BMI     NMLFLOOR               ;SEE IF TOO LOW\r
+          CMP     #$40\r
+          BPL     NMLTOP                 ;SEE IF TOO HI\r
+          RTS\r
+NMLFLOOR  LDA     #$00                   ;TOO LOW - USE 0\r
+          RTS\r
+NMLTOP    LDA     #$3F                   ;TOO HI - USE 3F\r
+          RTS\r
+\r
+\r
+* CALCDIST        CALCULATES DISTANCE BETWEEN TWO POINTS\r
+*         INT:    (TEMP7,TEMP8) FIRST POINT (TEMP9, TEMP10) SECOND POINT\r
+*         OUT:    A= NEGOTIVE OF DISTANCE\r
+*         USES:   TEMP0,1\r
+\r
+CALCDIST\r
+          LDA     TEMP7\r
+          SEC\r
+          SBC     TEMP9\r
+          STA     TEMP1\r
+          BPL     CALCDIS1\r
+          LDA     #0\r
+          SEC\r
+          SBC     TEMP1\r
+          STA     TEMP1\r
+\r
+CALCDIS1\r
+          LDA     TEMP8\r
+          SEC\r
+          SBC     TEMP10\r
+          STA     TEMP0\r
+          BPL     CALCDIS2\r
+          LDA     #0\r
+          SEC\r
+          SBC     TEMP0\r
+          STA     TEMP0\r
+\r
+CALCDIS2  TXA                            ;GET TEMP11+X INTO Y\r
+          CLC\r
+          ADC     TEMP11\r
+          TAY\r
+          LDA     TEMP0                  ;GET SUM OF DISTANCES\r
+          CLC\r
+          ADC     TEMP1\r
+          CLC\r
+          ADC     #2                     ;GIVE SOME ROOM FOR SQUARE ADJUSTMENT\r
+          CLC\r
+          ADC     SQUARTAB,Y\r
+          STA     TEMP1                  ;AND NOW INVERT IT\r
+          LDA     #0\r
+          SEC\r
+          SBC     TEMP1\r
+          RTS\r
+\r
+\r
+*  THIS ROUTINE FINDS OUT WHAT DIRECTION SHOULD BE FAVORED, AND WHAT SHOULD BE\r
+*  SHUNNED.  THIS SETS UP TEMP11, WHICH SHOULD BE USED WITH THE DIRECTION AS\r
+*  AN OFFSET INTO SQUARTAB.\r
+*  THIS SHOULD BE CALLED SOON ENOUGH THAT TEMP0-3 CAN BE USED\r
+SETSQUAR  LDA     #$00\r
+          STA     TEMP0                  ;VERTICAL FLIP BIT\r
+          STA     TEMP1                  ;HORIZONTAL FLIP BIT\r
+\r
+          LDA     TEMP7                  ;GOAL FOR ZONE\r
+          SEC\r
+          SBC     TEMP4                  ;OUR ZONE\r
+          STA     TEMP2                  ;VERTICAL DELTA\r
+          BPL     SSQHOR\r
+          LDA     #$08\r
+          STA     TEMP0                  ;VERTICAL FLIP\r
+          LDA     #$00\r
+          SEC\r
+          SBC     TEMP2\r
+          STA     TEMP2\r
+\r
+SSQHOR    LDA     TEMP8                  ;GOAL FOR COLUMN\r
+          SEC\r
+          SBC     TEMP5                  ;OUR COLUMN\r
+          STA     TEMP3                  ;HORIZONTAL DELTA\r
+          BPL     SSQCOMP\r
+          LDA     #$08\r
+          STA     TEMP1                  ;HORIZONTAL FLIP\r
+          LDA     #$00\r
+          SEC\r
+          SBC     TEMP3\r
+          STA     TEMP3\r
+\r
+SSQCOMP   LDA     TEMP2                  ;VERTICAL DELTA\r
+          SEC\r
+          SBC     TEMP3                  ;HORIZONTAL DELTA\r
+          BMI     HORMORE\r
+\r
+          LDA     #$04                   ;VERTICAL MORE\r
+          CLC\r
+          ADC     TEMP0                  ;8 MORE IF VERTICAL FLIPPED\r
+          STA     TEMP11\r
+          RTS\r
+\r
+HORMORE   LDA     #$00                   ;HORIZONTAL MORE\r
+          CLC\r
+          ADC     TEMP1                  ;8 MORE IF HORIZONTAL FLIPPED\r
+          STA     TEMP11\r
+          RTS\r
+\r
+\r
+\r
+*  THIS TABLE IS TO ADD A SLIGHT COMPENSATION TO MAKE IT LOOK MORE LIKE A SQUARE\r
+SQUARTAB  DB      -1,0,1,0,0,-1,0,1,1,0,-1,0,0,1,0,-1\r
+\r
+*  THIS TABLE USED FOR OFFSETS FOR ZONES AROUND\r
+T4OFF     DB      0,1,0,-1\r
+T5OFF     DB      1,0,-1,0\r
diff --git a/PUTCHAR.S b/PUTCHAR.S
new file mode 100644 (file)
index 0000000..cf4c9a8
--- /dev/null
+++ b/PUTCHAR.S
@@ -0,0 +1,592 @@
+\r
+*  PUTCHAR.S      THIS PROVIDES ROUTINES FOR MODIFYING THE SCREEN\r
+\r
+*  THIS ROUTINE PUTS UP A SET OF CHARACTERS IN A BLOCK ON THE SCREEN.  IT'S\r
+*  PARAMETERS ARE:\r
+*         TEMP0   THE NUMBER OF LINES TO BE CHANGED\r
+*         TEMP1   THE NUMBER OF COLUMNS TO BE CHANGED\r
+*         TEMP2   WHAT CHARACTER IN THE FONT TO START WITH (THIS IS INCREMENTED)\r
+*         TEMP3   WHAT ZONE THE MODIFICATION STARTS IN\r
+*         TEMP4   WHAT COLUMN IN THE ZONE IT STARTS IN\r
+*         TEMP5, 6, AND 7 ARE USED FOR INTERNAL USE\r
+PUTCHARS  LDA     #$01\r
+          STA     TEMP5\r
+          JMP     PCHAR\r
+\r
+\r
+*  THIS ROUTINE IS THE SAME AS PUTCHARS, BUT THE CHARACTER USED FOR MODIFICATION\r
+*  DOES NOT CHANGE.\r
+PUTCHAR   LDA     #$00\r
+          STA     TEMP5\r
+          JMP     PCHAR\r
+\r
+\r
+*  THIS ROUTINE DOES THE WORK FOR PUTCHARS AND PUTCHAR\r
+PCHAR     LDX     TEMP3                  ;THE ZONE\r
+          LDA     SCRLOW,X               ;LOW BYTE OF ADDRESS FOR ZONE\r
+          STA     TEMP6                  ;TEMP LOCATION\r
+          LDA     SCRHI,X                ;HI BYTE OF ADDRESS FOR ZONE\r
+          STA     TEMP7\r
+\r
+          LDX     TEMP1                  ;NUMBER OF COLUMNS\r
+          LDY     TEMP4                  ;STARTING COLUMN\r
+PLOOP     LDA     TEMP2                  ;STARTING CHAR\r
+          STA     (TEMP6),Y\r
+          LDA     TEMP5                  ;SEE IF STARTING CHAR IS INCREMENTED\r
+          BEQ     PJMP0\r
+          INC     TEMP2                  ;NEXT CHAR\r
+PJMP0     INY\r
+          DEX\r
+          BNE     PLOOP\r
+\r
+          INC     TEMP3                  ;NEXT ZONE\r
+          DEC     TEMP0                  ;ONE LESS LINE\r
+          BNE     PCHAR                  ;DO IT AGAIN IF MORE LINES\r
+          RTS\r
+\r
+\r
+*  THIS ROUTINE PUTS A SINGLE CHARACTER INTO A SINGLE PLACE ON THE SCREEN.\r
+*  PARAMETERS:\r
+*         TEMP0   ZONE\r
+*         TEMP1   COLUMN\r
+*         X       CHARACTER\r
+*  TEMP2-3 ARE USED.\r
+PLOPCHAR  STY     TEMP23\r
+          LDY     TEMP0                  ;THE ZONE\r
+          LDA     SCRLOW,Y               ;LOW BYTE OF ADDRESS FOR ZONE\r
+          STA     TEMP2                  ;TEMP LOCATION\r
+          LDA     SCRHI,Y                ;HI BYTE OF ADDRESS FOR ZONE\r
+          STA     TEMP3\r
+          LDY     TEMP1\r
+          TXA\r
+          STA     (TEMP2),Y\r
+          LDY     TEMP23\r
+          RTS\r
+\r
+\r
+*  THIS RETURNS (IN A) THE CONTENTS OF A CHARACTER.\r
+*  PARAMETERS:  TEMP0 - ZONE, TEMP1 - COL\r
+*  TEMPS:  TEMP2-3\r
+GETCHAR   STY     TEMP23\r
+          LDY     TEMP0                  ;THE ZONE\r
+          LDA     SCRLOW,Y               ;LOW BYTE OF ADDRESS FOR ZONE\r
+          STA     TEMP2                  ;TEMP LOCATION\r
+          LDA     SCRHI,Y                ;HI BYTE OF ADDRESS FOR ZONE\r
+          STA     TEMP3\r
+\r
+          LDY     TEMP1                  ;STARTING COLUMN\r
+          LDA     (TEMP2),Y\r
+          LDY     TEMP23\r
+          RTS\r
+\r
+\r
+*  THIS ROUTINE ADDS THE ACCUMULATOR TO THE PRESENT SCORE.  NOTE THAT THE\r
+*  ACCUMULATOR SHOULD HAVE A DECIMAL NUMBER, THIS WILL BE MULTIPLIED BY 10\r
+*  TEMP 8-12 ARE USED.  REGISTERS ARE PRESERVED.  TEMP 6-7 ARE USED BY WRTSCORE\r
+*  IF ADDTOTAL IS CALLED, THE USER SETS UP TEMP11-12 TO THE ADDED SCORE\r
+ADDSCORE  STA     TEMP12\r
+          LDA     #$00\r
+          STA     TEMP11\r
+ADDTOTAL  TXA                            ;STACK REGISTERS\r
+          PHA\r
+          TYA\r
+          PHA\r
+\r
+          LDA     #$00                   ;CLEAR TOP TWO BYTES OF ADDED VALUE\r
+          STA     TEMP9\r
+          STA     TEMP10\r
+          LDX     AUTOPLAY\r
+          BNE     ADSOUT\r
+          LDY     PLAYER                 ;SEE WHICH PLAYER IS ACTIVE\r
+          BNE     ADSP2\r
+\r
+          LDY     #$03\r
+          SED                            ;DECIMAL MODE ON\r
+          CLC\r
+ADS1LOOP  LDA     TEMP9,Y\r
+          ADC     P1SCORE,Y\r
+          STA     P1SCORE,Y\r
+          LDA     #$00\r
+          DEY\r
+          BPL     ADS1LOOP\r
+          CLD                            ;DECIMAL MODE OFF\r
+          JSR     CHKSCOR1\r
+          JMP     ADSOUT\r
+\r
+ADSP2     LDY     #$03\r
+          SED                            ;DECIMAL MODE ON\r
+          CLC\r
+ADS2LOOP  LDA     TEMP9,Y\r
+          ADC     P2SCORE,Y\r
+          STA     P2SCORE,Y\r
+          LDA     #$00\r
+          DEY\r
+          BPL     ADS2LOOP\r
+          CLD                            ;DECIMAL MODE OFF\r
+          JSR     CHKSCOR2\r
+\r
+ADSOUT    JSR     WRTSCORE\r
+          PLA                            ;UNSTACK REGISTERS\r
+          TAY\r
+          PLA\r
+          TAX\r
+          RTS\r
+\r
+\r
+*  THIS ROUTINE CHECKS TO SEE IF PLAYER 1 HAS A BONUS LIFE COMING\r
+CHKSCOR1  LDA     P1BONUS                ;MAKE SURE BONUS IS ENABLED\r
+          BMI     CKS1OUT\r
+          SED\r
+          SEC                            ;DECIMAL MODE ON\r
+          LDA     P1BONUS+1\r
+          SBC     TEMP12\r
+          STA     P1BONUS+1\r
+          LDA     P1BONUS\r
+          SBC     TEMP11\r
+          STA     P1BONUS\r
+          CLD                            ;DECIMAL MODE OFF\r
+          LDA     P1BONUS                ;COMPENSATE FOR 6502 BUG\r
+          BPL     CKS1OUT\r
+          JSR     INCLIVES\r
+CKS1OUT   RTS\r
+\r
+\r
+*  THIS ROUTINE CHECKS TO SEE IF PLAYER 2 HAS A BONUS LIFE COMING\r
+CHKSCOR2  LDA     P2BONUS                ;MAKE SURE BONUS IS ENABLED\r
+          BMI     CKS2OUT\r
+          SED\r
+          SEC                            ;DECIMAL MODE ON\r
+          LDA     P2BONUS+1\r
+          SBC     TEMP12\r
+          STA     P2BONUS+1\r
+          LDA     P2BONUS\r
+          SBC     TEMP11\r
+          STA     P2BONUS\r
+          CLD                            ;DECIMAL MODE OFF\r
+          LDA     P2BONUS                ;COMPENSATE FOR 6502 BUG\r
+          BPL     CKS2OUT\r
+          JSR     INCLIVES\r
+CKS2OUT   RTS\r
+\r
+\r
+*  THIS ROUTINE INITIALIZES THE LIVES\r
+INITLIV   LDA     #$04\r
+          STA     LIVES\r
+          STA     TOTLIVES\r
+          LDX     TWOPLAYR\r
+          BEQ     ILOUT\r
+          STA     BAKLIVES               ;FOR THE OTHER PLAYER\r
+          LDA     #$09\r
+          STA     TOTLIVES\r
+ILOUT     RTS\r
+\r
+\r
+*  THIS ROUTINE DECREMENTS THE LIVES.\r
+DECLIVES  LDA     AUTOPLAY\r
+          BNE     DECALT\r
+          JSR     CLEARTUN\r
+          JSR     WAIT\r
+          DEC     LIVES\r
+          JSR     WRTLIVES\r
+          LDA     LIVES\r
+          BPL     DLCONT\r
+          JSR     OVER                   ;PUT GAME OVER UP\r
+          JSR     WAIT\r
+          JSR     WCLEAR\r
+DLCONT    DEC     TOTLIVES\r
+          BMI     DLDEAD\r
+          LDA     TWOPLAYR\r
+          BNE     DLSWITCH\r
+          JSR     LIFEINIT\r
+DLREADY   JSR     READY                  ;PUT PLAYER READY UP\r
+          JSR     WAIT\r
+          JMP     WCLEAR\r
+DLSWITCH  JSR     OTHRINIT               ;SWITCH TO OTHER PLAYER\r
+          JMP     DLREADY\r
+DLDEAD    LDA     #$01                   ;GAME OVER\r
+          STA     GAMEOVER\r
+          RTS\r
+DECALT    JMP     NEXTRACK               ;IF AUTOPLAY - SWITCH RACKS INSTEAD\r
+\r
+\r
+*  THIS ROUTINE INCREMENTS THE LIVES.\r
+INCLIVES  INC     LIVES\r
+          INC     TOTLIVES\r
+          LDA     #$14\r
+          JSR     DOTUNE\r
+          JMP     WRTLIVES\r
+\r
+\r
+*  THIS ROUTINE WRITES THE SCORES OF THE PLAYERS ON THE SCREEN\r
+*  TEMPS 6-7 AND 10 ARE USED\r
+*  NOTE:  SCORE+1 IS USED SINCE THE HI BYTE IS ONLY MAINTAINED FOR THE HIGH\r
+*         SCORE CART\r
+WRTSCORE  LDX     #$1E\r
+          LDA     SCRLOW,X               ;LOW BYTE OF ADDRESS FOR ZONE\r
+          STA     TEMP6                  ;TEMP LOCATION\r
+          LDA     SCRHI,X                ;HI BYTE OF ADDRESS FOR ZONE\r
+          STA     TEMP7                  ;NOW - ZONE LINE IS SET UP\r
+          LDY     #P1SCRCOL              ;STARTING COLUMN\r
+\r
+          LDX     PLAYER\r
+          LDA     NUMCHAR,X\r
+          STA     TEMP10                 ;SET STARTING CHARACTER FOR ZERO\r
+          LDX     #$00\r
+\r
+WRSALOOP  LDA     P1SCORE+1,X            ;ELIMINATE LEADING ZEROS\r
+          LSR     A\r
+          LSR     A\r
+          LSR     A\r
+          LSR     A\r
+          BNE     WRS1JMP0\r
+          JSR     WRTBLANK\r
+          LDA     P1SCORE+1,X\r
+          AND     #$0F\r
+          BNE     WRS1JMP1\r
+          JSR     WRTBLANK\r
+          INX\r
+          CPX     #$03\r
+          BMI     WRSALOOP\r
+          JMP     WRS1JMP2\r
+\r
+WRS1LOOP  LDA     P1SCORE+1,X            ;WRITE SCORE FOR PLAYER 1\r
+          LSR     A\r
+          LSR     A\r
+          LSR     A\r
+          LSR     A\r
+WRS1JMP0  JSR     WRTDIGIT\r
+          LDA     P1SCORE+1,X\r
+          AND     #$0F\r
+WRS1JMP1  JSR     WRTDIGIT\r
+          INX\r
+          CPX     #$03\r
+          BMI     WRS1LOOP\r
+\r
+WRS1JMP2  LDA     #$00                   ;TRAILING ZERO\r
+          JSR     WRTDIGIT\r
+\r
+WRSB      LDA     TWOPLAYR               ;DON'T DO SECOND IF ONE-PLAYER\r
+          BEQ     WRS2NONE\r
+          LDX     PLAYER\r
+          LDA     NUMCHAR2,X\r
+          STA     TEMP10                 ;SET STARTING CHARACTER FOR ZERO\r
+          LDX     #$00                   ;START WITH HIGH BYTE\r
+          LDY     #P2SCRCOL              ;STARTING COLUMN\r
+\r
+WRSBLOOP  LDA     P2SCORE+1,X            ;ELIMINATE LEADING ZEROS\r
+          LSR     A\r
+          LSR     A\r
+          LSR     A\r
+          LSR     A\r
+          BNE     WRS2JMP0\r
+          JSR     WRTBLANK\r
+          LDA     P2SCORE+1,X\r
+          AND     #$0F\r
+          BNE     WRS2JMP1\r
+          JSR     WRTBLANK\r
+          INX\r
+          CPX     #$03\r
+          BMI     WRSBLOOP\r
+          JMP     WRS2JMP2\r
+\r
+WRS2LOOP  LDA     P2SCORE+1,X            ;WRITE SCORE FOR PLAYER 2\r
+          LSR     A\r
+          LSR     A\r
+          LSR     A\r
+          LSR     A\r
+WRS2JMP0  JSR     WRTDIGIT\r
+          LDA     P2SCORE+1,X\r
+          AND     #$0F\r
+WRS2JMP1  JSR     WRTDIGIT\r
+          INX\r
+          CPX     #$03\r
+          BMI     WRS2LOOP\r
+\r
+WRS2JMP2  LDA     #$00                   ;TRAILING ZERO\r
+          JMP     WRTDIGIT               ;ALL DONE\r
+\r
+WRS2NONE  LDY     #P2SCRCOL              ;CLEAR OUT PLAYER 2 (JUST IN CASE)\r
+          LDX     #$06\r
+WRS2NLP   JSR     WRTBLANK\r
+          DEX\r
+          BPL     WRS2NLP\r
+          RTS\r
+\r
+*  THIS ROUTINE WRITES A DIGIT (IN THE ACCUMULATOR) TO THE NEXT SPOT ON THE\r
+*  SCREEN (TEMP6).  TEMP10 IS ADDED (TO GIVE OFFSET INTO FONT).\r
+WRTDIGIT  CLC\r
+          ADC     TEMP10\r
+          STA     (TEMP6),Y\r
+          INY\r
+          RTS\r
+\r
+*  THIS ROUTINE WRITES A BKANK TO THE NEXT SPOT ON THE SCREEN (TEMP6).\r
+WRTBLANK  LDA     #BLNKCHAR\r
+          STA     (TEMP6),Y\r
+          INY\r
+          RTS\r
+\r
+\r
+*  THIS ROUTINE WRITES THE LIVES ON THE SCREEN\r
+WRTLIVES  LDA     LIVES                  ;GET NUMBER OF LIVES\r
+          CMP     #$05                   ;MAKE SURE NOT TOO BIG\r
+          BMI     WLJMP0\r
+          LDA     #$05\r
+WLJMP0    ASL     A                      ;TURN IT INTO AN INDEX INTO DLISTS\r
+          ASL     A\r
+          STA     TEMP16\r
+\r
+          LDX     #$10                   ;NOW, GO THROUGH THE INDICATORS\r
+WLLOOP    CPX     TEMP16\r
+          BPL     WLBLANK\r
+          LDA     #$28                   ;TURN ON AN INDICATOR\r
+          STA     BDLIST0,X\r
+          LDA     #$2A\r
+          STA     BDLIST1,X\r
+          JMP     WLNEXT\r
+WLBLANK   LDA     #$00                   ;TURN ON A BLANK\r
+          STA     BDLIST0,X\r
+          STA     BDLIST1,X\r
+WLNEXT    DEX                            ;NEXT ONE IS 4 LESS\r
+          DEX\r
+          DEX\r
+          DEX\r
+          BPL     WLLOOP\r
+\r
+          RTS\r
+\r
+\r
+*  FLASH THE POWER DOTS\r
+FLASHDOT  JSR     SETFLSH                ;SET NEXT FLASH\r
+\r
+          LDY     RACK\r
+          LDA     EDZONE0,Y\r
+          STA     TEMP0\r
+          LDA     EDCOL0,Y\r
+          STA     TEMP1\r
+          JSR     SWTCHDOT               ;SWITCH ZONE 0 COLUMN 0\r
+          LDA     EDCOL1,Y\r
+          STA     TEMP1\r
+          JSR     SWTCHDOT               ;SWITCH ZONE 0 COLUMN 1\r
+          LDA     EDZONE1,Y\r
+          STA     TEMP0\r
+          JSR     SWTCHDOT               ;SWITCH ZONE 1 COLUMN 1\r
+          LDA     EDCOL0,Y\r
+          STA     TEMP1\r
+          JMP     SWTCHDOT               ;SWITCH ZONE 1 COLUMN 0\r
+\r
+\r
+*  SWITCH A SINGLE POWER DOT - ZONE AND COL IN TEMP0 AND 1\r
+SWTCHDOT  JSR     GETCHAR\r
+          CMP     #BLNKCHAR\r
+          BEQ     SDOUT\r
+          EOR     #$01\r
+          TAX\r
+          JMP     PLOPCHAR\r
+SDOUT     RTS\r
+\r
+\r
+*  MAKE THE POWER DOTS WHITE FOR END OF RACK\r
+FINALDOT  LDY     RACK\r
+          LDA     EDZONE0,Y\r
+          STA     TEMP0\r
+          LDA     EDCOL0,Y\r
+          STA     TEMP1\r
+          JSR     ONDOT                  ;TURN ON ZONE 0 COLUMN 0\r
+          LDA     EDCOL1,Y\r
+          STA     TEMP1\r
+          JSR     ONDOT                  ;TURN ON ZONE 0 COLUMN 1\r
+          LDA     EDZONE1,Y\r
+          STA     TEMP0\r
+          JSR     ONDOT                  ;TURN ON ZONE 1 COLUMN 1\r
+          LDA     EDCOL0,Y\r
+          STA     TEMP1\r
+          JMP     ONDOT                  ;TURN ON ZONE 1 COLUMN 0\r
+\r
+\r
+*  TURN ON SINGLE POWER DOT - ZONE AND COL IN TEMP0 AND 1\r
+ONDOT     JSR     GETCHAR\r
+          AND     #$FE\r
+          TAX\r
+          JMP     PLOPCHAR\r
+\r
+\r
+*  SET THE NEXT FLASH MOVE\r
+SETFLSH   LDA     RTLOCAL+1\r
+          CLC\r
+          ADC     #WAITFLSH\r
+          STA     FLSHWAIT\r
+          RTS\r
+\r
+\r
+*  THIS JUST SETS TEMP0 AND TEMP1 TO HAVE THE SCREEN LOCATION FOR ZONE Y\r
+SETSCRN   LDA     SCRLOW,Y               ;LOW BYTE OF ADDRESS FOR ZONE\r
+          STA     TEMP0                  ;TEMP LOCATION\r
+          LDA     SCRHI,Y                ;HI BYTE OF ADDRESS FOR ZONE\r
+          STA     TEMP1\r
+          RTS\r
+\r
+\r
+*  PUT THE READY MESSAGE UP\r
+READY     JSR     WPLAYR                 ;WRITE THE PLAYER\r
+          LDY     #$21\r
+          JMP     WRTMESG                ;WRITE READY\r
+\r
+\r
+*  PUT THE GAME OVER MESSAGE UP\r
+OVER      JSR     WPLAYR                 ;WRITE THE PLAYER\r
+ALLOVER   LDY     #$22\r
+          JMP     WRTMESG                ;WRITE GAME OVER\r
+\r
+\r
+*  PUT A PLAYER UP ON THE SCREEN\r
+WPLAYR    LDA     TWOPLAYR\r
+          BEQ     WPLOUT\r
+          LDA     #OFFSCRN               ;MOVE THE RED GUY AWAY\r
+          STA     HPLIST+1\r
+          STA     DOLIST+1\r
+\r