]> github.com/historicalsource and other repositories - asteroids-7800.git/commitdiff
Initial import. master
authorSimon Morgan <sjm@sjm.io>
Mon, 22 Jun 2015 23:12:01 +0000 (00:12 +0100)
committerSimon Morgan <sjm@sjm.io>
Mon, 22 Jun 2015 23:12:01 +0000 (00:12 +0100)
27 files changed:
ASTEROID.O [new file with mode: 0644]
ASTEST.S [new file with mode: 0644]
BASE78.IMG [new file with mode: 0644]
BASE78.O [new file with mode: 0644]
BASE78.S [new file with mode: 0644]
COLLIDE.S [new file with mode: 0644]
DLTEST.S [new file with mode: 0644]
EXPLODE.S [new file with mode: 0644]
FSM.S [new file with mode: 0644]
HISCORE.S [new file with mode: 0644]
INIT.S [new file with mode: 0644]
JOY.S [new file with mode: 0644]
MAIN.S [new file with mode: 0644]
MARIA.S [new file with mode: 0644]
MARIAOS.S [new file with mode: 0644]
MORESTMP.S [new file with mode: 0644]
OS7800.S [new file with mode: 0644]
RASTA.S [new file with mode: 0644]
RASTDEF.S [new file with mode: 0644]
RASTLOAD.S [new file with mode: 0644]
ROCKMOVE.S [new file with mode: 0644]
SCORE.S [new file with mode: 0644]
STAMPS.S [new file with mode: 0644]
TABLES.S [new file with mode: 0644]
TUNES.S [new file with mode: 0644]
UFO.S [new file with mode: 0644]
UTILS.S [new file with mode: 0644]

diff --git a/ASTEROID.O b/ASTEROID.O
new file mode 100644 (file)
index 0000000..c47377f
Binary files /dev/null and b/ASTEROID.O differ
diff --git a/ASTEST.S b/ASTEST.S
new file mode 100644 (file)
index 0000000..0253f11
--- /dev/null
+++ b/ASTEST.S
@@ -0,0 +1,14 @@
+       .6502\r
+frmcnt equ     $76\r
+       .org    $8000\r
+       lda     frmcnt\r
+       lsr\r
+       bcc     .10\r
+       nop\r
+       bcs     .20\r
+.10:\r
+       nop\r
+.20:\r
+       asl\r
+       sta     frmcnt\r
+       jmp     $d069\r
diff --git a/BASE78.IMG b/BASE78.IMG
new file mode 100644 (file)
index 0000000..5fed686
Binary files /dev/null and b/BASE78.IMG differ
diff --git a/BASE78.O b/BASE78.O
new file mode 100644 (file)
index 0000000..a57995f
Binary files /dev/null and b/BASE78.O differ
diff --git a/BASE78.S b/BASE78.S
new file mode 100644 (file)
index 0000000..d971ea9
--- /dev/null
+++ b/BASE78.S
@@ -0,0 +1,35 @@
+*****************************************************************\r
+*                                                              *\r
+*              7800 Base Unit Rom Code                         *\r
+*      Modified Asteroids with a bit of O.S                    *\r
+*                      16-May-88                               *\r
+*                                                              *\r
+*              Dave Staugas, programmer                        *\r
+*****************************************************************\r
+*\r
+*\r
+       .include        "RASTDEF.S"\r
+       .include        "STAMPS.S"\r
+       .include        "MAIN.S"\r
+       .include        "JOY.S"\r
+       .include        "FSM.S"\r
+       .include        "EXPLODE.S"\r
+       .include        "COLLIDE.S"\r
+       .include        "SCORE.S"\r
+       .include        "MORESTMP.S"\r
+       .include        "TUNES.S"\r
+       .include        "ROCKMOVE.S"\r
+       .include        "INIT.S"\r
+       .include        "UFO.S"\r
+       .include        "UTILS.S"\r
+       .include        "RASTLOAD.S"\r
+       .include        "TABLES.S"\r
+       .include        "os7800.s"\r
+*\r
+avail  equ     *\r
+*\r
+*\r
+       .org    $fffa\r
+       .dc.w   NMI\r
+       .dc.w   startup\r
+       .dc.w   IRQ\r
diff --git a/COLLIDE.S b/COLLIDE.S
new file mode 100644 (file)
index 0000000..8671275
--- /dev/null
+++ b/COLLIDE.S
@@ -0,0 +1,631 @@
+*         1515    030784\r
+*\r
+*\r
+** COLLIDE.S **\r
+** ASTEROIDS FOR THE ATARI 3600 **\r
+** THIS FILE CONTAINS THE COLLISION HANDLING ROUTINE. **\r
+**\r
+**        INDEXING - ROCKS               0 THRU 23\r
+**                   SHIP                24\r
+**                   UFO                 25\r
+**                   UFOSHOT             26 THRU 27\r
+**                   SHIPSHOT            28 THRU 31\r
+**                   SHIP2               32\r
+**\r
+**        STATUS - LO NYBBLE - OBJECT TYPE - 0 - SMALL ROCK\r
+**                                           1 - MEDIUM ROCK\r
+**                                           2 - LARGE ROCK\r
+**                                           3 - SHIP\r
+**                                           4 - SMALL UFO\r
+**                                           5 - LARGE UFO\r
+**                                           6 - SHOT\r
+**                                           7 - SHIP'S PARTS (+MISC JUNK)\r
+**                 HI NYBBLE - OBJECT SIZE - INDEX INTO SIZE TABLES\r
+**                                           (UNUSED, I BELIEVE)\r
+**\r
+**                  < 0 - NULL OBJECT\r
+**\r
+**        USES TEMP LOCATIONS AS FOLLOWS:\r
+**                TEMP                   DX (REUSED LATER)\r
+**                TEMP+1                 DY\r
+**                TEMP+2                 DX+DY (MANHATTAN DISTANCE)\r
+**                TEMP+3,TEMP+4          SAVE AREA FOR INDEX REGISTERS X & Y\r
+**                TEMP+5,TEMP+6          SAVE AREA FOR 'TYPE NYBBLES'\r
+**                                       (IE, LO NYBBLE OF STATUS BYTE)\r
+**                TEMP+7                 ROCK TYPE, IN THE EVENT OF AN EXPLOSION\r
+**                TEMP+8,TEMP+9          SHORT TERM SCRATCH TEMP\r
+**                TEMP+10                SHIP'S DIRECTION INDEX\r
+**\r
+********************************************************************************\r
+\r
+\r
+COLLIDE:\r
+       LDA     RUBFLAG         ;DECREMENT RUBBER SHIP FLAG IF NEEDED\r
+       BMI     ZNODERUB\r
+       DEC     RUBFLAG\r
+ZNODERUB:\r
+       LDX     #32             ;START CHECKING WITH SHIP2\r
+COLNXTX:\r
+       LDA     STATUS,X        ;IF OBJECT X DOESN'T EXIST THEN\r
+       BMI     DECX            ;GO ON TO NEXT X\r
+\r
+       LDY     COLTAB-24,X     ;FETCH FIRST OBJECT TO CHECK\r
+COLNXTY:\r
+       LDA     STATUS,Y        ;IF OBJECT Y DOESN'T EXIST THEN\r
+       BMI     DECY            ;GO ON TO NEXT Y\r
+\r
+       STX     TEMP+3          ;SAVE X AND Y\r
+       STY     TEMP+4\r
+\r
+       JMP     COLCHK          ;CHECK FOR COLLISION\r
+\r
+RESTORE:\r
+       LDX     TEMP+3  ;RESTORE X AND Y\r
+       LDY     TEMP+4\r
+\r
+DECY:\r
+       DEY\r
+       BPL     COLNXTY\r
+DECX:\r
+       DEX\r
+       CPX     #24\r
+       BPL     COLNXTX\r
+COLRTS:\r
+       RTS\r
+\r
+\r
+\r
+* CHECK FOR AN ACTUAL COLLISION BETWEEN OBJECTS WHOSE INDICES ARE IN X AND Y.\r
+COLCHK:\r
+       LDA     COLXPOSH,X      ;COMPUTE DX\r
+       SEC\r
+       SBC     COLXPOSH,Y\r
+       BCS     DXPOS           ;TAKE ABSOLUTE VALUE\r
+       EOR     #$FF\r
+;      CLC                     ;CARRY MUST ALREADY BE CLR (BCS ABOVE)\r
+       ADC     #1\r
+\r
+DXPOS:\r
+       CMP     #XPOSMAX-13     ;CHECK FOR WRAPAROUND (WIDEST OBJ=12)\r
+       BCC     DXOK            ;NO WRAP\r
+       CPX     #25             ;DON'T X-WRAP THE UFO\r
+       BEQ     DXOK\r
+       CPY     #25\r
+       BEQ     DXOK\r
+       SEC\r
+       SBC     #XPOSMAX+1      ;USE WRAPPED DISTANCE\r
+       EOR     #$FF\r
+;      CLC                     ;CARRY IS CLEAR FROM SBC (IE, BORROW)\r
+       ADC     #1\r
+\r
+DXOK:\r
+       CMP     #10             ;FURTHEST COLLISION HAS DX OF ONLY 10\r
+       BCS     NOCOL           ; IF >= 11, NO COLLISION.\r
+       STA     TEMP\r
+\r
+       LDA     COLYPOSH,X      ;COMPUTE DY\r
+       SEC\r
+       SBC     COLYPOSH,Y\r
+       BCS     DYPOS           ;TAKE ABSOLUTE VALUE\r
+       EOR     #$FF\r
+;      CLC             ;CARRY MUST ALREADY BE CLR (BCS ABOVE)\r
+       ADC     #1\r
+\r
+DYPOS:\r
+       CMP     #YPOSMAX-17     ;CHECK FOR WRAPAROUND (TALLEST OBJ=16)\r
+       BCC     DYOK            ;NO WRAP\r
+       SBC     #YPOSMAX+1      ;USE WRAPPED DISTANCE\r
+       EOR     #$FF\r
+;      CLC             ;CARRY IS CLEAR FROM SBC (IE, BORROW)\r
+       ADC     #1\r
+\r
+DYOK:\r
+       CMP     #14             ;FURTHEST COLLISION HAS DY OF ONLY 14\r
+       BCS     NOCOL           ; IF >= 15, NO COLLISION.\r
+       STA     TEMP+1\r
+\r
+* AT THIS POINT, WE MUST DO CLOSER INSPECTION, SINCE THE OBJECTS ARE CLOSE.\r
+       CLC                     ;COMPUTE MANHATTAN DISTANCE (DX+DY)\r
+       ADC     TEMP\r
+       STA     TEMP+2\r
+\r
+       LDA     STATUS,X        ;TEMP+5 <- TYPE OF OBJECT X\r
+       AND     #$0F\r
+       STA     TEMP+5\r
+\r
+       LDA     STATUS,Y        ;TEMP+6 <- TYPE OF OBJECT Y\r
+       AND     #$0F\r
+       STA     TEMP+6\r
+\r
+       STY     TEMP+9          ;SAVE Y, WE NEED AN INDEX REGISTER!\r
+\r
+       TAY\r
+       LDA     OBJDIAG,Y       ;GET WIDTH OF SECOND OBJECT\r
+       LDY     TEMP+5\r
+       ADC     OBJDIAG,Y       ;ADD IN WIDTH OF FIRST OBJECT\r
+       CMP     TEMP+2          ;COMPARE WITH MANHATTAN DISTANCE\r
+       BMI     NOCOL1          ;TOO FAR AWAY, NO COLLISION.\r
+\r
+       LDA     OBJWID,Y        ;DO MORE PRECISE XTENT CHECKING\r
+       LDY     TEMP+6\r
+       CLC\r
+       ADC     OBJWID,Y\r
+       CMP     TEMP\r
+       BCC     NOCOL1          ;TOO FAR TO THE SIDE: NO COLLISION\r
+\r
+       LDA     OBJHEIT,Y       ;DO MORE PRECISE YTENT CHECKING\r
+       LDY     TEMP+5\r
+       CLC\r
+       ADC     OBJHEIT,Y\r
+       CMP     TEMP+1\r
+       BCS     YESCOL  ;WE HAVE A COLLISION.\r
+\r
+\r
+NOCOL1:\r
+       LDY     TEMP+9  ;RESTORE Y\r
+NOCOL:\r
+       CPY     #40             ;DECREMENT INDICES WITHOUT RESTORING\r
+       BEQ     COLSETX         ; IF WE ARE DOING SPECIAL CHECKING\r
+       BCS     DECY1\r
+       CPX     #40\r
+       BEQ     RESTORE1\r
+       CPX     #37\r
+       BCC     RESTORE1\r
+       BCS     DECX1           ;(UNCONDITIONAL)\r
+\r
+COLSETX:\r
+       CPX     #37             ;SET X AND Y TO LOOP OVER SHIP'S PARTS\r
+       BCC     RESTORE1\r
+       BCS     COLSETY         ;(UNCONDITIONAL)\r
+\r
+COLSETY:\r
+       LDY     #43             ;RESET Y FOR NEXT ROUND\r
+DECX1:\r
+       DEX\r
+       JMP     COLCHK\r
+DECY1:\r
+       DEY\r
+       JMP     COLCHK\r
+\r
+\r
+* COME HERE IN THE EVENT OF A POSSIBLE COLLISION.\r
+YESCOL:\r
+       ;COMPUTE LOWEST P2 BULLET OR SHIP FOR THIS MODE.  IN TEAM MODES\r
+       ;WE SHARE BULLETS.  RESULT IS LEFT IN TEMP FOR LATER.\r
+       LDA     #32             ;ASSUME 30 AND 31 ARE NOT P2'S\r
+       LDY     MODE\r
+       CPY     #1\r
+       BMI     NOTEAMSC        ;NOT TEAMPLAY, DON'T SPLIT BULLETS\r
+       LDA     #30             ;30 AND 31 ARE P2'S\r
+NOTEAMSC:\r
+       STA     TEMP\r
+\r
+       LDY     TEMP+9          ;RESTORE Y\r
+\r
+* PERFORM ACTIONS DEPENDENT UPON THE SPECIAL CASE OBJECTS\r
+       CPX     #32\r
+       BEQ     COLP2X          ;FIRST OBJECT IS P2 SHIP\r
+       CPX     #24\r
+       BEQ     COLP1X          ;FIRST OBJECT IS P1 SHIP\r
+       CPY     #24\r
+       BEQ     COLP1Y          ;SECOND OBJECT IS P1 SHIP\r
+\r
+       LDX     TEMP+3          ;RESTORE X AND Y\r
+       LDY     TEMP+4\r
+       JSR     DOCOL           ;DO THE COLLISION\r
+       JMP     DECX            ;AND THE NEXT ITERATION\r
+RESTORE1:\r
+       JMP     RESTORE         ;AND CONTINUE\r
+\r
+\r
+COLP2X:\r
+       LDA     STATE+1         ;DON'T COLLIDE IF SHIP ISN'T OK\r
+       BNE     RESTORE1\r
+\r
+       LDA     MODE            ;IN COMPETITIVE, P1'S SHOTS KILL P2\r
+       CMP     #2\r
+       BEQ     COLP2XGO\r
+       CPY     #28             ; (P1'S SHOTS ARE 28 AND 29)\r
+       BCS     RESTORE1        ;OTHERWISE, IGNORE THEM\r
+COLP2XGO:\r
+       LDX     #39             ;POINT TO SHIP2'S PARTS\r
+       JSR     P2SETUP         ;SET UP FOR SPECIAL P2 CHECKING\r
+       CPY     #24             ;IS IT SHIP1 VS SHIP2?\r
+       BNE     COLNOP1Y        ;NOPE\r
+       LDA     MODE\r
+       CMP     #2              ;IN COMPETITIVE PLAY, DON'T BOUNCE,\r
+       BEQ     COLP1Y          ; COLLIDE!\r
+\r
+       LDA     STATE           ;IF SHIP NOT OK, DON'T COLLIDE\r
+       BNE     RESTORE1\r
+       JMP     RUBBERS         ;LET'S GO BOUNCY BOUNCY...\r
+\r
+COLP1Y:\r
+       LDA     STATE           ;DON'T COLLIDE IF SHIP ISN'T OK\r
+       BNE     RESTORE1\r
+\r
+       CPX     #28             ;ANYTHING LESS THAN 28 IS HARMFUL\r
+       BCC     COLP1YGO\r
+\r
+       ;IN TEAM PLAY, IGNORE THE COLLISION: THEY ARE FRIENDS\r
+       LDA     MODE\r
+       CMP     #1\r
+       BEQ     RESTORE1\r
+\r
+       CPX     TEMP            ;CHECK AGAINST P2'S BULLETS.\r
+       BCC     RESTORE1        ; IF < TEMP, IT IS SAFE\r
+\r
+       ;NOT SAFE: CHECK SHIP'S PARTS\r
+COLP1YGO:\r
+       LDY     #43             ;POINT TO SHIP1'S PARTS\r
+COLP1GO:\r
+       JSR     P1SETUP         ;SET THEM UP\r
+COLNOP1Y:\r
+       JMP     COLCHK          ;AND CONTINUE\r
+\r
+\r
+COLP1X:\r
+       LDA     STATE           ;DON'T COLLIDE IF SHIP ISN'T OK\r
+       BNE     RESTORE1\r
+\r
+       LDX     #43             ;POINT TO SHIP1'S PARTS\r
+       BNE     COLP1GO         ;CONTINUE AS ABOVE (UNCONDITIONAL)\r
+\r
+\r
+* P1SETUP: SET UP STATUS ENTRIES FOR THE PARTS OF THE SHIP TO CHECK\r
+P1SETUP:\r
+       STX     TEMP+8\r
+       LDA     SHIPDIR         ;GENERATE SHIP DIRECTION INDEX\r
+       LSR\r
+       LSR\r
+       LSR\r
+       LSR\r
+       TAX\r
+       LDA     SHNOSEX,X\r
+       CLC\r
+       ADC     XPOSH+24\r
+       STA     COLXPOSH+40\r
+       LDA     SHNOSEY,X\r
+       ADC     YPOSH+24\r
+       STA     COLYPOSH+40\r
+\r
+       LDA     SHRTAILX,X\r
+;      CLC\r
+       ADC     XPOSH+24\r
+       STA     COLXPOSH+41\r
+       LDA     SHRTAILY,X\r
+       ADC     YPOSH+24\r
+       STA     COLYPOSH+41\r
+\r
+       LDA     SHLTAILX,X\r
+;      CLC\r
+       ADC     XPOSH+24\r
+       STA     COLXPOSH+42\r
+       LDA     SHLTAILY,X\r
+       ADC     YPOSH+24\r
+       STA     COLYPOSH+42\r
+\r
+       LDA     COLXPOSH+24\r
+       STA     COLXPOSH+43\r
+       LDA     COLYPOSH+24\r
+       STA     COLYPOSH+43\r
+\r
+       LDX     TEMP+8\r
+       RTS\r
+\r
+* P2SETUP: SET UP STATUS ENTRIES FOR THE PARTS OF THE SHIP TO CHECK\r
+P2SETUP:\r
+       STX     TEMP+8\r
+       LDA     SHIPDIR+1       ;GENERATE SHIP DIRECTION INDEX\r
+       LSR\r
+       LSR\r
+       LSR\r
+       LSR\r
+       TAX\r
+       LDA     SHNOSEX,X\r
+       CLC\r
+       ADC     XPOSH+32\r
+       STA     COLXPOSH+36\r
+       LDA     SHNOSEY,X\r
+       ADC     YPOSH+32\r
+       STA     COLYPOSH+36\r
+\r
+       LDA     SHRTAILX,X\r
+;      CLC\r
+       ADC     XPOSH+32\r
+       STA     COLXPOSH+37\r
+       LDA     SHRTAILY,X\r
+       ADC     YPOSH+32\r
+       STA     COLYPOSH+37\r
+\r
+       LDA     SHLTAILX,X\r
+;      CLC\r
+       ADC     XPOSH+32\r
+       STA     COLXPOSH+38\r
+       LDA     SHLTAILY,X\r
+       ADC     YPOSH+32\r
+       STA     COLYPOSH+38\r
+\r
+       LDA     COLXPOSH+32\r
+       STA     COLXPOSH+39\r
+       LDA     COLYPOSH+32\r
+       STA     COLYPOSH+39\r
+\r
+       LDX     TEMP+8\r
+       RTS\r
+\r
+* DOCOL1: PERFORM CERTAIN COMMON ACTIONS ON AN OBJECT EXPLODING.\r
+* ON ENTRANCE, X IS THE INDEX OF OBJECT COLLIDING.  ON EXIT, TEMP+6 HAS THE\r
+* 'TYPE NYBBLE'.  OH, AND BY THE WAY, X AND Y ARE TRASHED.\r
+DOCOL1:\r
+       STX     TEMP+8          ;SAVE X\r
+       LDA     STATUS,X\r
+       ORA     #$80            ;TAG THIS OBJECT AS "EXPLODING"\r
+       STA     STATUS,X\r
+       AND     #$0F            ;COMPUTE OBJECT TYPE (AGAIN)\r
+       STA     TEMP+6          ;STORE IT\r
+\r
+       CMP     #6\r
+       BCS     NOEXPSND        ;OBJECTS >= 6 MAKE NO EXPLOSION SOUNDS\r
+       CMP     #4\r
+       BCS     COLUFO          ;UFO COLLIDING: HANDLE IT\r
+       CMP     #3\r
+       BCS     COLSHIP         ;SHIP COLLIDING: HANDLE IT\r
+\r
+;      CLC                     ;CARRY IS CLEAR\r
+       ADC     #$0A            ;ADD OFFSET OF ROCK TUNES\r
+       PHA                     ;THIS IS 'ROCKSND'\r
+       LDA     #$0A            ; (KILL OFF ANY CURRENT ROCK SOUNDS)\r
+       JSR     KILLTUNE\r
+       LDA     #$0B\r
+       JSR     KILLTUNE\r
+       LDA     #$0C\r
+       JSR     KILLTUNE\r
+       PLA\r
+\r
+CONT:\r
+       JSR     DOTUNE\r
+       LDX     TEMP+8          ;RESTORE X, TRASHED BY DOTUNE\r
+NOEXPSND:\r
+       LDY     TEMP+6          ;GET TYPE NYBBLE\r
+       LDA     ELBOUND,Y       ;SET UP EXPLOSION ANIMATION\r
+       STA     ACYC,X\r
+       RTS\r
+\r
+COLUFO:\r
+       TAX\r
+       SEC\r
+       SBC     #2              ;COMPUTE INDEX INTO LVLINC\r
+       JSR     INCLVL          ;MAKE IT HARDER NOW\r
+       CPX     #4              ;ONLY MR. BILL CHANGES ACCURACY\r
+       BNE     ZNOBILAC\r
+       LDA     UFOACC\r
+       CMP     #4              ;DON'T GO BELOW 3\r
+       BCC     ZNOBILAC\r
+       DEC     UFOACC          ;TIGHTEN UP MR. BILL'S ACCURACY\r
+ZNOBILAC:\r
+       TXA                     ;DO TUNES: CANCEL THEME AND PLAY EXPL.\r
+       CLC\r
+       ADC     #2              ;EXPLOSION = TYPE + 2\r
+       PHA                     ;PUSH IT FOR LATER\r
+       ADC     #2              ;THEME = TYPE + 4\r
+       JSR     KILLTUNE\r
+       PLA                     ;PULL EXPLOSION SOUND\r
+       BPL     CONT            ;BPL = JMP\r
+\r
+COLSHIP:\r
+       LDA     TEMP+8          ;FIGURE OUT WHICH SHIP DIED\r
+       LDX     #0              ;DEFAULT TO SHIP 1\r
+       CMP     #32             ;FIGURE OUT WHICH SHIP DIED\r
+       BNE     NOP2DIE\r
+       INX                     ;INCREMENT TO SHIP 2\r
+NOP2DIE:\r
+       LDA     #DEATH          ;INDUCE A FATAL DEATH\r
+       STA     STATE,X\r
+       LDA     #DIET+$28       ;AT TIMER 'DIE TIME' + $28\r
+       STA     TIMER,X\r
+\r
+       LDA     #$05            ;SHIP EXPLOSION = 05\r
+       BPL     CONT            ;BPL = JMP\r
+\r
+* WE HAVE A COLLISION, FOLKS!  DO WHAT NEEDS TO BE DONE (EXPLODING, SCORING)\r
+DOCOL:\r
+;DEBUGGING PATCH\r
+;        LDA     #$0A  ;USE SMALL ROCK EXPLOSION SOUND\r
+;        JSR     DOTUNE\r
+;        LDX     TEMP+3\r
+;        LDY     TEMP+4\r
+;        RTS\r
+\r
+* FIRST DO TUNES AND EXPLOSION ANIMATIONS\r
+;      LDX     TEMP+3\r
+       JSR     DOCOL1\r
+       LDA     TEMP+6          ;TRANSFER TYPE NYBBLE\r
+       STA     TEMP+5          ; TO PROPER PLACE\r
+\r
+       LDX     TEMP+4\r
+       JSR     DOCOL1\r
+\r
+* NOW DO SCORING\r
+       LDX     TEMP+6          ;SCORE ONE OBJECT\r
+       LDY     TEMP+3\r
+       JSR     DOSCOR\r
+       LDX     TEMP+5          ;SCORE OTHER OBJECT\r
+       LDY     TEMP+4\r
+       JSR     DOSCOR\r
+\r
+       CPY     #24             ;SEE IF WE HAVE ANY EXPLODING ROCKS\r
+       BCC     ROCKEXPL\r
+       LDX     TEMP+3          ;RESTORE X\r
+       RTS\r
+\r
+* SCORE OBJECT OF TYPE X ACCORDINGLY AS IT WERE SHOT BY OBJECT Y\r
+* I.E., IF Y CONTAINS INDEX OF PLAYER ONE'S SHOT, SCORE A HIT ON AN 'X' TO\r
+* PLAYER ONE.\r
+DOSCOR:\r
+       CPY     TEMP            ;CHECK P2'S BULLETS OR SHIP\r
+       BPL     SCORP2          ;CREDIT OBJECT TO P2'S SCORE\r
+       CPY     #28             ;CHECK P1'S BULLETS\r
+       BPL     SCORPL          ;CREDIT OBJECT TO CURRENT PLAYER\r
+       CPY     #24             ;CHECK P1'S SHIP\r
+       BNE     SCORERTS        ;NONE OF THE ABOVE: RTS\r
+       CPX     #3              ;IS IT A SHIP THAT #24 IS HITTING?\r
+       BNE     SCORPL          ;NO.  JUST SCORE IT.\r
+       LDA     #17             ;SOUR THE GOATMILK\r
+       STA     GOATMILK\r
+;      RTS             ;RTS IF YOU DON'T WANT TO SCORE THESE.\r
+\r
+SCORPL:\r
+       LDA     PLAYER          ;SCORE IT TO THE CURRENT PLAYER\r
+SCORIT:\r
+       STA     SCORER          ;MARK THE SCORER\r
+       JSR     ADDPOINT        ;RACK 'EM UP\r
+SCORERTS:\r
+       RTS\r
+\r
+SCORP2:\r
+       LDA     #1              ;SCORE FOR P2 REGARDLESS OF PLAYER\r
+       BPL     SCORIT          ;BPL = JMP\r
+\r
+\r
+* HANDLE EXPLODING (="SPLITTING") ROCKS.\r
+ROCKEXPL:\r
+       LDA     STATUS,Y        ;CHECK THE EXPLODING ROCK\r
+       SEC\r
+       SBC     #$91            ;WIDTH IS LO NYBBLE. IF =1, THEN SMALL\r
+       BMI     SPLITRTS        ;THIS IS CLEVER.  B2-91=21, ETC...\r
+       STA     TEMP+7          ;SAVE IT FOR NEWROCK TO USE...\r
+\r
+       LDA     #$50            ;RESET 5.2 SEC UFO COUNTER\r
+       STA     RTIMER\r
+\r
+       ;CREATE ONE, TWO, OR THREE NEW ROCKS, BASED ON DIFF.\r
+       LDA     DIFF            ;UNLESS AT A WHIPPY LEVEL THEN ONE\r
+       BEQ     ONEROCK\r
+       CMP     #3              ;AT EXPERT LEVEL, MAYBE > 2 ROCKS!\r
+       BCC     TWOROCKS\r
+       LDA     RANDPTR0        ;USE PTR AS RANDOM (NEWRAND SCREWS Y)\r
+       AND     #$03\r
+       BNE     TWOROCKS\r
+       JSR     NEWROCK         ;CREATE EACH NEW ROCK IF POSSIBLE;\r
+TWOROCKS:\r
+       JSR     NEWROCK ;NEWROCK RETURNS "EMPTY HANDED" IF NOT.\r
+ONEROCK:\r
+       JSR     NEWROCK\r
+\r
+       LDX     TEMP+3          ;RESTORE X, TRASHED IN NEWROCK\r
+SPLITRTS:\r
+       RTS\r
+\r
+NEWROCK:\r
+       LDX     #23             ;FIND A FREE ROCK SLOT\r
+ROCKLOOP:\r
+       LDA     STATUS,X\r
+       CMP     #$FF\r
+       BEQ     THISROCK\r
+       DEX\r
+       BPL     ROCKLOOP\r
+       RTS\r
+\r
+THISROCK:\r
+       LDA     XPOSL,Y         ;INITIALIZE NEW ROCK (X) FROM OLD (Y)\r
+       STA     XPOSL,X\r
+       LDA     XPOSH,Y\r
+       STA     XPOSH,X\r
+       LDA     YPOSL,Y\r
+       STA     YPOSL,X\r
+       LDA     YPOSH,Y\r
+       STA     YPOSH,X\r
+       LDA     COLXPOSH,Y      ;THESE AREN'T QUITE RIGHT, BUT CLOSE.\r
+       STA     COLXPOSH,X\r
+       LDA     COLYPOSH,Y\r
+       STA     COLYPOSH,X\r
+       LDA     PALS,Y          ;ADJUST WIDTH TO SMALLER ROCK SIZE\r
+       CLC\r
+       ADC     #1\r
+       STA     PALS,X\r
+\r
+       LDA     TEMP+7          ;GIVE IT THE PROPER ROCK TYPE STATUS\r
+       STA     STATUS,X\r
+       AND     #$0F            ;SET FIRST ANIMATION FRAME\r
+       TAY\r
+       LDA     ROCKCYC,Y\r
+       STA     ACYC,X\r
+       JSR     RANDVEL         ;SET UP RANDOM VELOCITIES.\r
+       LDX     PLAYER\r
+       INC     ROCKTOT,X       ;THERE IS NOW ONE MORE ROCK!\r
+       LDY     TEMP+4          ;RESTORE Y, TRASHED ABOVE\r
+       RTS\r
+\r
+;RUBBER SHIPS\r
+RUBBERS:\r
+       LDA     RUBFLAG         ;HAVE WE BEEN HERE BEFORE?\r
+       BPL     ZNORUB          ;YUP.  DON'T BOUNCE BACK\r
+\r
+       LDA     XVELH+24\r
+       CMP     #$80            ;SIGNED 16 BIT DIVIDE BY TWO\r
+       ROR\r
+       PHA\r
+       LDA     XVELL+24\r
+       ROR\r
+       PHA\r
+       LDA     XVELH+32\r
+       CMP     #$80\r
+       ROR\r
+       STA     XVELH+24\r
+       LDA     XVELL+32\r
+       ROR\r
+       STA     XVELL+24\r
+       PLA\r
+       STA     XVELL+32\r
+       PLA\r
+       STA     XVELH+32\r
+\r
+       LDA     YVELH+24\r
+       CMP     #$80\r
+       ROR\r
+       PHA\r
+       LDA     YVELL+24\r
+       ROR\r
+       PHA\r
+       LDA     YVELH+32\r
+       CMP     #$80\r
+       ROR\r
+       STA     YVELH+24\r
+       LDA     YVELL+32\r
+       ROR\r
+       STA     YVELL+24\r
+       PLA\r
+       STA     YVELL+32\r
+       PLA\r
+       STA     YVELH+32\r
+\r
+ZNORUB:\r
+       LDA     #1              ;PREVENT A SECOND BOUNCE\r
+       STA     RUBFLAG\r
+       JMP     RESTORE\r
+\r
+* TABLE OF STARTING VALUES FOR 'Y' IN COLLIDE LOOP: ESSENTIALLY, THESE ARE\r
+* THE HIGHEST NUMBERED OBJECTS WE MUST COMPARE TO FOR A GIVEN X.\r
+* THESE ARE OFFSET BY 24, SINCE THE LOWEST X WE CHECK IS 24 (SHIP1)\r
+*\r
+COLTAB:\r
+       .DC.B   23,24,24,24,25,25,25,25,29\r
+\r
+* WIDTH TABLES FOR COLLISION PURPOSES\r
+OBJWID:\r
+       .DC.B    2,4,5,3,2,4,1,1;X-EXTENTS (XTENTS)\r
+OBJHEIT:\r
+       .DC.B    3,6,8,6,2,3,1,1;Y-EXTENTS (YTENTS)\r
+OBJDIAG:\r
+       .DC.B    3,6,9,6,2,3,2,1;DIAGONALS\r
+\r
+* OFFSET (INTO THE STAMP) OF SHARP POINTS OF THE SHIP\r
+SHLTAILX:\r
+       .DC.B    1,0,0,1,1,2,3,4,5,5,6,5,5,4,3,2\r
+SHLTAILY:\r
+       .DC.B    5,7,9,11,12,13,14,14,13,11,9,7,6,5,4,4\r
+SHRTAILX:\r
+       .DC.B    5,4,3,2,1,1,0,0,1,2,3,4,5,5,6,5\r
+SHRTAILY:\r
+       .DC.B    5,4,4,5,6,7,9,11,13,14,14,13,12,11,9,7\r
diff --git a/DLTEST.S b/DLTEST.S
new file mode 100644 (file)
index 0000000..1b4d46f
--- /dev/null
+++ b/DLTEST.S
@@ -0,0 +1,423 @@
+*\r
+*\r
+*\r
+       .subttl         "Remnants of old Maria OS"\r
+*\r
+       .include        "maria.s"\r
+*\r
+ramcode        equ     $2300           ;AREA RESERVED FOR CODE\r
+tiaram equ     $480\r
+*\r
+*\r
+;\r
+;  STELLA (TIA) REGISTER ADDRESSES USED BY THIS MODULE\r
+;\r
+VBLANK equ     $01     ; BIT        1  VERTICAL BLANK SET-CLR\r
+TWSYNC equ     $02     ; STROBE        WAIT FOR HORIZ BLANK\r
+RSYNC  equ     $03     ; STROBE        RESET HORIZ SYNC COUNTER\r
+COLUP0 equ     $06     ; BITS 7654321  COLOR(4)-LUM(3) PLAYER 0\r
+COLUPF equ     $08     ; BITS 7654321  COLOR(4)-LUM(3) PLAYFIELD\r
+COLUBK equ     $09     ; BITS 7654321  COLOR(4)-LUM(3) BACKGROUND\r
+PF2    equ     $0F     ; BITS ALL      PLAYFIELD REG BYTE 2\r
+RESP0  equ     $10     ; STROBE        RESET PLAYER 0\r
+RESP1  equ     $11     ; STROBE        RESET PLAYER 1\r
+GRP0   equ     $1B     ; BITS ALL      GRAPHICS FOR PLAYER 0\r
+GRP1   equ     $1C     ; BITS ALL      GRAPHICS FOR PLAYER 1\r
+CXCLR  equ     $2C     ; STROBE        CLEAR COLLISION LATCHES\r
+;\r
+;  READ ADDRESSES -    BIT 7   BIT 6 (ONLY)\r
+;\r
+CXP0FB equ     $32     ;       P0.PF   P0.BL\r
+CXP1FB equ     $33     ;       P1.PF   P1.BL\r
+*\r
+       .org    $f000\r
+*\r
+fakedli        equ     $2700\r
+fakelist:\r
+       .dc.b   $0,$40,$f0,$1f,$bb\r
+       .dc.b   0,0\r
+       .dc.b   $0f,$27,0\r
+*\r
+*\r
+*\r
+NMI:\r
+IRQ:\r
+       rti\r
+\r
+*\r
+*\r
+startup:\r
+       SEI                     ;INITIALIZE\r
+       CLD\r
+*\r
+       LDA     #$07            ;PUT BASE UNIT INTO MARIA ENABLE\r
+       STA     PTCTRL\r
+*\r
+       ldx     #$ff\r
+       txs\r
+*\r
+*\r
+       LDA     #$7F\r
+       STA     CTRL            ;TURN OFF DMA\r
+       LDA     #$00\r
+       STA     BACKGRND        ;BACKGROUND COLOR TO BLACK\r
+*\r
+*\r
+*\r
+*   copy 2600 code to tia RAM\r
+*\r
+       LDX     #$7F            ;LOCK CART IN 2600 MODE, CART ON\r
+L2LOOP:\r
+       LDA     SYNC,X          ;MOVE CODE TO RAM\r
+       STA     tiaram,X        ;MOVE INTO 6532 RAM\r
+       DEX\r
+       BPL     L2LOOP\r
+*\r
+*\r
+*   Copy 7800 validation code from rom to ram..\r
+*\r
+*\r
+       ldx     #ROMEND-ROMCODE\r
+copylp:\r
+       lda     ROMCODE-1,x\r
+       sta     ramcode-1,x\r
+       dex\r
+       bne     copylp\r
+*\r
+*  Now, zero out the TIA\r
+*\r
+       lda     #0              ;zero out the TIA\r
+       tax\r
+tia0loop:\r
+       sta     VBLANK,x\r
+       inx\r
+       cpx     #CXCLR\r
+       bne     tia0loop\r
+*\r
+       LDA     #$02            ;PUT BASE UNIT INTO MARIA ENABLE\r
+       STA     PTCTRL\r
+*\r
+*\r
+*   7800 One-on-One Basketball needs ram initialized to $ff (for shame!!!)\r
+*      it also needs a fake display list initialized since it\r
+*      turns on Maria before loading the display list pointer\r
+*\r
+       .if     0\r
+basktptr       equ     $90\r
+*\r
+       lda     #0\r
+       sta     basktptr\r
+       lda     #$18\r
+       sta     basktptr+1\r
+*\r
+       ldx     #15\r
+       ldy     #0\r
+onelp:\r
+       lda     #$ff\r
+oneonlp:\r
+       sta     (basktptr),y\r
+       dey\r
+       bne     oneonlp\r
+       inc     basktptr+1\r
+       lda     basktptr+1\r
+       and     #(%11011110)&255        ;check for $20 or $21\r
+       bne     .10\r
+       lda     #$ff\r
+       sta     (basktptr),y\r
+       ldy     #$3f\r
+       bne     oneonlp \r
+.10:   \r
+       dex\r
+       bpl     onelp\r
+*\r
+       .endif\r
+*\r
+*\r
+       ldx     #9\r
+fakeload:\r
+       lda     fakelist,x\r
+       sta     fakedli,x\r
+       dex\r
+       bpl     fakeload\r
+*\r
+       inx                     ;x=0\r
+       ldy     #80\r
+fakeinc:\r
+       lda     fakedli+7,x\r
+       sta     fakedli+10,x\r
+       inx\r
+       dey\r
+       bne     fakeinc\r
+*\r
+       jsr     wait00\r
+*\r
+*\r
+       lda     #$27\r
+       sta     DPPH\r
+       lda     #07\r
+       sta     DPPL\r
+       lda     #$43\r
+       sta     CTRL\r
+*      sta     NMICTRL\r
+*\r
+*\r
+       ldx     #$7f\r
+frame4:\r
+       jsr     wait00\r
+       dex\r
+       bpl     frame4\r
+       lda     #$60\r
+       sta     CTRL\r
+*\r
+       brk\r
+*\r
+wait00:\r
+       bit     MSTAT\r
+       bmi     wait00\r
+wait01:\r
+       bit     MSTAT\r
+       bpl     wait01\r
+       rts\r
+*\r
+*   the following code is copied to ram for execution\r
+*\r
+ROMCODE:\r
+NOCART:\r
+       lda     #2\r
+       sta     PTCTRL                  ;turn "security" ROM on\r
+       JMP     startup                 ;NO CART, do asteroids\r
+*\r
+CARTTEST:\r
+       LDA     #$16                    ;TURN EXTERNAL CART ON\r
+       STA     PTCTRL\r
+\r
+       LDY     #$FF\r
+       LDX     #$7F                    ;SEE IF A CART PLUGGED IN\r
+CTSTLOOP:\r
+       LDA     $FE00,X\r
+       CMP     $FD80,Y\r
+       BNE     NOCART\r
+       DEY\r
+       DEX\r
+       BPL     CTSTLOOP                ;X LEFT = FF, Y LEFT = 7F\r
+*\r
+       LDA     $FFFC                   ;SEE IF START AT FFFF\r
+       AND     $FFFD\r
+       CMP     #$FF\r
+       BEQ     NOCART                  ;ALL LINES DRAWN HIGH, NO CART\r
+       LDA     $FFFC                   ;SEE IF START AT 0000\r
+       ORA     $FFFD\r
+       BEQ     NOCART                  ;ALL LINES DRAWN LOW, NO CART\r
+*\r
+       LDA     $FFF8                   ;CHECK FOR REGION VERIFICATION\r
+       ORA     #$fe\r
+       CMP     #$FF\r
+       BNE     CART26\r
+       LDA     $FFF8                   ;TOP 4 BITS OF FFF8 SHOULD BE 0F0\r
+       EOR     #$F0\r
+       AND     #$F0\r
+       BNE     CART26\r
+       LDA     $FFF9                   ;SEE IF MARIA SIGNATURE EXISTS\r
+       AND     #$0B                    ;0X7 OR 0X3 VALID\r
+       CMP     #$03\r
+       BNE     CART26\r
+       LDA     $FFF9                   ;GET BOTTOM OF CART ADDRESS\r
+       AND     #$F0\r
+       cmp     #$40                    ;not too low\r
+       bcc     CART26\r
+       sbc     #1\r
+       cmp     $fffd\r
+       bcs     CART26\r
+*\r
+       lda     $1BEA           ;2600 ROM responds to this address\r
+       eor     #$FF\r
+       sta     $1BEA           ;stuff some data in MARIA ram space\r
+       tay\r
+*\r
+       ldx     #5              ;check hardware vectors\r
+vecheck:\r
+       lda     $FFFA,x         ;   2600 should always\r
+       cmp     $DFFA,x         ;     read the same data\r
+       bne     SETMARIA        ;       in DXXX as in FXXX\r
+       dex\r
+       bpl     vecheck\r
+*\r
+*  Some 7800 carts get here...\r
+*\r
+       cpy     $1BEA           ;does this act like 7800 ram or 2600 ROM?\r
+       bne     CART26\r
+*      jmp     CART26          ;1 chance in 2**48 it's still a 7800 cart\r
+*\r
+*     We favor 7800 more than before so 2600 might get run in 7800 mode \r
+*     ...may need to do more 2600/7800 discrimination here...\r
+*\r
+*\r
+*  we must be 7800 cart;  go to it...\r
+*\r
+SETMARIA:\r
+       LDX     #$16    ;PUT CART IN 7800 MODE, CART ON\r
+       STX     PTCTRL\r
+       TXS\r
+       SED\r
+       JMP     ($FFFC) ;VECTOR INTO THE CART IN 3600 MODE\r
+*\r
+*  tests indicate we must be a 2600 cart...\r
+*\r
+CART26:\r
+       LDA     #$02\r
+       STA     PTCTRL                  ;TURN SECURITY ROM ON\r
+       jmp     tiaram                  ;perform this from tia ram\r
+*\r
+ROMEND:\r
+*\r
+*\r
+; First zero out TIA without doing a TWSYNC. This must be done in a loop that\r
+; counts up so that graphics are turned off before the collision registers are\r
+; cleared. RSYNC should turn case C into a case A. Note also that the stores\r
+; of zero puts the system in TIA space but does not lock it there. This code\r
+; must all run out of 6532 RAM since the memory map will change as we change\r
+; mode.        The 6532 RAM exists in all memory maps.\r
+*\r
+SYNC:\r
+       LDA     #0\r
+       TAX\r
+       STA     VBLANK\r
+ZEROLP:\r
+       STA     RSYNC,X\r
+       INX\r
+       CPX     #(CXCLR-RSYNC+1)\r
+       BNE     ZEROLP\r
+\r
+; Test now for a possible E case. In some E cases, TWSYNCs do not work properly\r
+; and this must be detected. In an E case failure, the LDA is prefetched and\r
+; the 04 following it is skipped over and NOP ($EA) is loaded into A causing\r
+; the branch on minus to be taken. If this happens the E case can now be\r
+; corrected.   NOTE: All E cases do not get trapped here and must be handled\r
+; latter by collisions.\r
+       STA     TWSYNC\r
+       LDA     #4\r
+       NOP\r
+       BMI     ECASE\r
+\r
+; Position player 0 on the left side of the screen and player 1 on the right\r
+; side of the screen so that they will overlap (or not overlap as the case may\r
+; be) playfield 2 that has a copy on both sides of the screen. Resets occur at\r
+; the 38th and 65th cycle.\r
+       LDX     #4\r
+STALL4:\r
+       DEX                             ;Stall loop\r
+       BPL     STALL4\r
+       TXS                             ;Set the stack to 0FF for stall JSRs\r
+       STA     RESP0+$100              ;38th cylce\r
+       JSR     DUMMY+1-SYNC+$480       ;12 cycle stall\r
+       JSR     DUMMY+1-SYNC+$480       ;Ditto\r
+       STA     RESP1   ;65th cycle\r
+\r
+; Turn on graphics to cause the collisions\r
+       STA     GRP0    ;68th cycle\r
+       STA     GRP1    ;71st cycle\r
+       STA     PF2     ;74th cycle\r
+\r
+; Stall an entire scan line to allow collisions to take place. The E case test\r
+; should follow all TWSYNCs to be safe.\r
+       NOP             ;76th cycle\r
+       STA     TWSYNC  ;3rd cycle\r
+       LDA     #0\r
+       NOP\r
+       BMI     ECASE\r
+\r
+; Test now for a collision between player 1 and playfield.     If there is no\r
+; collision, we must shift the clock once. If there is a collision, we must\r
+; do further testing.\r
+       BIT     CXP1FB-$30\r
+       BMI     NOCOL2\r
+\r
+; This section shifts the clock once.  Storing a 2 switches the system into\r
+; MARIA MODe and the following store to 0FXXX causes a clock speed-up for one\r
+; cycle and thus shifts the clock once.\r
+ECASE:\r
+       LDA     #2\r
+       STA     COLUBK  ;changes to MARIA MODe\r
+       STA     $F112\r
+       BNE     DONE    ;JMP\r
+\r
+; Test now for a collision between player 0 and playfield.     If there is no\r
+; collision, we must shift the clock twice. If there is a collision, we must\r
+; do further testing.\r
+NOCOL2:\r
+       BIT     CXP0FB-$30\r
+       BMI     NOCOL0\r
+\r
+; This section shifts the clock twice. Storing a 2 switches the system into\r
+; MARIA MODe and the following stores to 0FXXX causes two clock speed-ups for\r
+; one cycle and thus shifts the clock twice.\r
+       LDA     #2\r
+       STA     COLUP0  ;changes to MARIA MODe\r
+       STA     $F118\r
+DUMMY:\r
+       STA     $F460   ;Note that the 060 is a RTS\r
+       BNE     DONE\r
+\r
+; If we've fotten to this point the only possible failure left is an E case that\r
+; was not detected by the TWSYNC trap. Test for this by clearing the collision\r
+; registers, shifting the graphics for player 0 to the left one pixel by\r
+; changing GRP0 from a 4 to an 8, and then retesting for a collision.  If there\r
+; is still a collision between player 0 and the playfield, we have an E case,\r
+; otherwise we are done. Be careful not to test for collisions until after they\r
+; occur (about the 40th cycle).\r
+NOCOL0:\r
+       STA     CXCLR                   ;21st cycle\r
+       LDA     #8                      ;23rd cycle - one pixel to the left\r
+       STA     GRP0                    ;26th cycle\r
+       JSR     DUMMY+1-SYNC+$480       ;12 cycle stall\r
+       NOP                             ;40th cycle - just to be safe\r
+       BIT     CXP0FB-$30              ;43rd cycle\r
+       BMI     ECASE\r
+\r
+; We are now synced and should lock ourselves into TIA mopde with the external\r
+; cart enabled and jump to the reset vector.   Thanks for stopping by...\r
+DONE:\r
+       LDA     #$FD\r
+       STA     COLUPF  ;Change MODes to TIA with EXT and lock.\r
+       JMP     ($FFFC)\r
+NROM:\r
+*\r
+*  some necessary code from HISCORE.S module that was omitted...\r
+*\r
+HSCSUCK:\r
+*      JSR     ZEROHS\r
+*\r
+HSCDOENT:\r
+*\r
+* HSCSETDM -- SET DIFF/MODE LEVEL ARGUMENT BASED ON DIFF AND MODE\r
+*\r
+HSCSETDM:\r
+*      LDA     MODE            ;COMPUTE DIFF/MODE LEVEL VALUE BYTE\r
+       BPL     ZHSCMOK\r
+       LDA     #0\r
+ZHSCMOK:\r
+       ASL\r
+       ASL\r
+       CLC\r
+*      ADC     DIFF\r
+*      STA     TEMP            ;SAVE IT WHERE WE CAN INSERT LATER\r
+HSCSHOW:\r
+       LDA     #1\r
+HSCRET:\r
+       RTS\r
+*\r
+*\r
+HSCTAB:\r
+       .dc.b   $20,$20,$20,$20,$20,$20,$20,$20,$20,$20\r
+       .dc.b   $4F,$68,$21,$20,$57,$68,$61,$74,$20,$61\r
+       .dc.b   $20,$66,$69,$6E,$65,$20,$62,$6F,$79,$20   \r
+       .dc.b   $69,$73,$20,$44,$61,$76,$65,$20,$53,$74   \r
+       .dc.b   $61,$75,$67,$61,$73,$2E           \r
+       .dc.b   $20,$20,$20,$20,$20,$20,$20,$20,$20,$20\r
+*\r
+CODEDIF        equ     ROMCODE-ramcode         ;DIFFERENCE BETWEEN OLD AND NEW ADDRESS\r
+*\r
+       .org    $FFFA\r
+       .dc.w   NMI\r
+       .dc.w   startup\r
+       .dc.w   IRQ\r
diff --git a/EXPLODE.S b/EXPLODE.S
new file mode 100644 (file)
index 0000000..7f98028
--- /dev/null
+++ b/EXPLODE.S
@@ -0,0 +1,52 @@
+*         2150    251083\r
+*\r
+*\r
+** EXPLODE.S **\r
+** ASTEROIDS FOR THE ATARI 3600 **\r
+** THIS FILE CONTAINS THE EXPLOSION HANDLING ROUTINE. **\r
+\r
+EXPLODE:\r
+       LDY     #32\r
+EXPLLOOP:\r
+       LDA     STATUS,Y\r
+       BPL     NEXTEXPL\r
+       CMP     #$FF\r
+       BEQ     NEXTEXPL\r
+\r
+       TYA                     ;GET NEW ANIMATION INDEX\r
+       ASL\r
+       ADC     FRMCNT\r
+       LSR\r
+       AND     #$3             ;3 ANDED WITH FRMCNT TO DECIDE\r
+       BNE     NEXTEXPL        ;WHEN NEXT ANIMATION\r
+\r
+       LDA     STATUS,Y\r
+       AND     #$0F\r
+       TAX\r
+       LDA     ACYC,Y\r
+       CMP     EHBOUND,X\r
+       BNE     NEXTECYC\r
+\r
+       CPX     #3\r
+       BCS     DONULL\r
+\r
+       LDX     PLAYER\r
+       DEC     ROCKTOT,X       ;ONE LESS ROCK FOR CURRENT PLAYER\r
+\r
+DONULL:\r
+       LDA     #$FF\r
+       STA     STATUS,Y\r
+       BMI     NEXTEXPL\r
+\r
+NEXTECYC:\r
+       CLC\r
+       ADC     ESIZE,X\r
+       STA     ACYC,Y\r
+\r
+NEXTEXPL:\r
+       DEY\r
+       BPL     EXPLLOOP\r
+       RTS\r
+\r
+ESIZE:\r
+       .DC.B   1,2,3,2,1,2,0\r
diff --git a/FSM.S b/FSM.S
new file mode 100644 (file)
index 0000000..c3b956c
--- /dev/null
+++ b/FSM.S
@@ -0,0 +1,613 @@
+*          1830    040784\r
+*\r
+** FSM.S **\r
+** ASTEROIDS FOR THE ATARI 3600 **\r
+** THIS FILE CONTAINS THE FINITE STATE MACHINE FOR ASTEROIDS. **\r
+** GAME SEQUENCER TO HANDLE INDIVIDUAL PLAYER'S EVENT TIMING. **\r
+\r
+\r
+FSM:\r
+       LDX     PLAYER          ;PLAYER MUST CONTAIN CURRENT PLAYER\r
+       LDA     STATE,X         ;CURRENT STATE OF PLAYER\r
+       BEQ     CKCOMPLY        ;CHECK IF COMP PLAY\r
+       BPL     DECTIMER        ;IF IN ACTIVE STATE THEN TAKE ACTION\r
+       RTS                     ;IF MINUS, RTS (I GUESS)\r
+\r
+DECTIMER:\r
+       DEC     TIMER,X         ;DECREMENT EVENT TIMER\r
+       CMP     #BIRTH          ;BIRTH STATE?\r
+       BEQ     BIRTHD\r
+       CMP     #HYPER          ;HYPERSPACE STATE?\r
+       BNE     ZCKCOMP\r
+       JMP     HYPERD\r
+ZCKCOMP:\r
+       CMP     #COMPOVER       ;COMP PLAY OVER?\r
+       BNE     ZCKDTH\r
+       JMP     COVERD\r
+ZCKDTH:\r
+       CMP     #DEATH          ;DEATH STATE?\r
+       BNE     FSMRTS\r
+       JMP     DEATHD\r
+FSMRTS:\r
+       RTS\r
+\r
+CKCOMPLY:\r
+       LDA     COMPFLAG        ;CHECK IF ANYBODY DIED YET\r
+       BEQ     FSMRTS\r
+       JSR     CMPSCOR         ;COMPARE SCORES\r
+       BMI     FSMRTS\r
+       CMP     PLAYER          ;HISCORE = FIRST TO DIE?\r
+       BNE     FSMRTS          ;YES, CONTINUE PLAY\r
+       TAX\r
+       LDA     #COMPOVER\r
+       STA     STATE,X         ;STATE IS REZ OUT VICTOR\r
+       LDA     #$FF\r
+       STA     COMPFLAG\r
+       LDA     #0\r
+       STA     MENLEFT,X       ;NO MORE LIVES\r
+       LDA     #$0D\r
+       STA     FLASH\r
+       LDA     #$0\r
+       JSR     DOTUNE          ;VICTOR REZOUT SOUND\r
+       RTS\r
+\r
+CMPSCOR:\r
+       LDX     #0              ;COMPARE SCORES\r
+CMPSLOOP:\r
+       LDA     SCORE,X         ;FIRST SCORE\r
+       CMP     SCORE2,X        ;SECOND SCORE\r
+       BCC     P2BIGGR         ;SCORE < SCORE2\r
+       BEQ     BUMPX\r
+       BCS     P1BIGGR         ;SCORE > SCORE2\r
+BUMPX:\r
+       INX                     ;LOOK AT NEXT BYTE\r
+       CPX     #5\r
+       BNE     CMPSLOOP\r
+       LDA     #$FF            ;SCORE = SCORE2\r
+       RTS\r
+P2BIGGR:\r
+       LDA     #1\r
+       RTS\r
+P1BIGGR:\r
+       LDA     #0\r
+       RTS\r
+\r
+** BIRTH DISPACHER - HANDLES TIMING OF BIRTH EVENTS. **\r
+BIRTHD:\r
+       LDY     OFFPLAY2        ;IF PLAYER IS NOT THERE, DON'T\r
+       LDA     STATUS+24,Y     ; DO REZ TWINKLE\r
+       BMI     ZNOREZ\r
+\r
+       ;DO REZ TWINKLE\r
+       LDA     #$05            ;DEFAULT LUME FOR AUTOPLAY\r
+       LDY     GAMSTATE\r
+       CPY     #PLAYST\r
+       BNE     ZREZGO          ;IF NOT IN PLAY STATE, DO AUTO REZ\r
+       LDA     FRMCNT          ;USE FRAME COUNT LO BITS FOR LUME\r
+       ASL\r
+ZREZGO:\r
+       JSR     PAINTSHP        ;PAINT THE SHIP, BODY AND DEJAG COLORS\r
+       LDX     PLAYER\r
+ZNOREZ:\r
+       LDA     TIMER,X         ;CHECK TIMER TO DISPATCH\r
+       CMP     #PMSGT          ;TIME TO PUT UP PLAYER MESSAGE?\r
+       BEQ     PMSG            ; YES, PUT IT UP\r
+       CMP     #PMSGOFFT       ;TIME TO TAKE DOWN MESSAGE?\r
+       BEQ     PMSGOFF         ; YES, TAKE IT DOWN\r
+       CMP     #RESINT         ;TIME TO RES IN?\r
+       BEQ     RESIN           ; YES, RES IN.  IF LATER THAN RESINT,\r
+       BCC     OPTENTER        ; CHECK FOR OPTIONAL ENTER (JSTICK)\r
+       RTS                     ;OTHERWISE, JUST RTS\r
+\r
+* ROUTINE TO PUT UP THE PLAYER X MESSAGE IF NEEDED. *\r
+PMSG:\r
+       LDA     MODE            ;NO MESSAGES IN TEAM MODES\r
+       CMP     #1\r
+       BPL     ZPLRTS\r
+       JSR     SETMSG\r
+ZPLRTS:\r
+       RTS\r
+\r
+* ROUTINE TO TURN PLAYER X MESSAGE OFF. *\r
+PMSGOFF:\r
+       LDA     #$FF            ;TURN OFF HIGH MESSAGE\r
+       STA     STATUS+34\r
+       RTS\r
+\r
+\r
+* ROUTINE TO ENTER THE SHIP IF DESIRED OR NEEDED. *\r
+OPTENTER:\r
+\r
+       LDA     GAMSTATE        ;DO ONLY IF GAMEPLAY STATE\r
+       CMP     #PLAYST\r
+       BNE     ZCKTIMM\r
+\r
+       ;FIRST CHECK TO SEE IF PLAYER IS FORCING SHIP IN\r
+       LDA     FIREBUT1,X      ;FIRE BUTTON\r
+       AND     HYPBUT1,X       ;HYPERSPACE BUTTON\r
+       BPL     ENTSHIP         ; IS PRESSED! ENTER HIM\r
+       LDA     SWCHA           ;JOYSTICK\r
+       EOR     #$FF            ; (INVERTED)\r
+       AND     JOYTBL,X        ; (LOOK AT ONLY CORRECT PLAYER'S BITS)\r
+       BNE     ENTSHIP         ; IS HIT! ENTER HIM\r
+\r
+       ;NOW CHECK IF IT IS TIME, AND IS SAFE.\r
+ZCKTIMM:\r
+       LDA     TIMER,X         ;CHECK TIMER\r
+       CMP     #ENTERT\r
+       BCS     ENTRTS          ;NOT TIME YET, DON'T BOTHER\r
+\r
+       LDA     OFFPLAY2        ;CHECK SAFTEY\r
+       CLC\r
+       ADC     #24\r
+       TAX\r
+       JSR     ISSAFE          ;CHECK IF AREA SAFE TO ENTER\r
+       BEQ     ENTSHIP         ;YES, CONTINUE\r
+\r
+       ;NOT SAFE, HOLD TIMER HERE INDEFINITELY\r
+       LDX     PLAYER\r
+       INC     TIMER,X\r
+ENTRTS:\r
+       RTS\r
+\r
+ENTSHIP:\r
+       LDA     #2              ;KILL TWINKLING\r
+       JSR     KILLTUNE\r
+       LDA     #$3             ;ADD BUZZING IN\r
+       JSR     DOTUNE\r
+\r
+       LDA     PLAYER          ;CHANGE BODY COLOR\r
+       ASL\r
+       ASL\r
+       TAX\r
+       LDA     COLORS+2,X\r
+       STA     SOFTCOLR+2,X\r
+       LDA     COLORS+3,X\r
+       STA     SOFTCOLR+3,X\r
+\r
+       LDX     PLAYER\r
+       LDA     #1              ;DEBOUNCE ENTER/FIRE BUTTON\r
+       STA     FIRESTAT,X\r
+\r
+       LDA     #OK             ;SET STATE AS OK\r
+       STA     STATE,X\r
+       RTS\r
+\r
+** ROUTINE TO RESIN AND TWINKLE SHIP AT ENTERING. **\r
+RESIN:\r
+       LDA     STATUS+25       ;CHECK STATUS OF UFO\r
+       BMI     ZGONOW          ;DON'T BRING SHIP IN IF UFO\r
+       INC     TIMER,X\r
+       RTS\r
+\r
+ZGONOW:\r
+       LDA     GAMSTATE        ;DON'T DECREMENT IF AUTOPLAY\r
+       CMP     #AUTOST\r
+       BEQ     ZNODECM\r
+       LDA     MODE            ;CHECK TO DEC FROM COMMON POOL\r
+       CMP     #1\r
+       BNE     ZNOPOOL\r
+       LDA     MENLEFTC        ;CHECK: IF NO MENLEFT, JUST HANG OUT\r
+       CMP     #1              ; AND WAIT; PERHAPS OTHER PLAYER WILL\r
+       BCS     ZYESMEN         ; BRING HIM IN A LIFE.\r
+       INC     TIMER,X         ; (HOLD TIMER AT THIS POINT IN TIME)\r
+       RTS\r
+\r
+ZYESMEN:\r
+       LDX     #2              ;2 = COMMON POOL\r
+ZNOPOOL:\r
+       DEC     MENLEFT,X       ;DEC FROM PLAYERS LIVES\r
+       JSR     UPDATMEN\r
+\r
+ZNODECM:\r
+       LDA     #2              ;TWINKLING SOUND\r
+       JSR     DOTUNE\r
+\r
+\r
+ZINITPOS:\r
+       LDX     OFFPLAY2        ;INITIALIZE THE SHIP'S POSITION\r
+       LDA     #0\r
+       STA     XVELH+24,X\r
+       STA     YVELH+24,X\r
+       STA     XVELL+24,X\r
+       STA     YVELL+24,X\r
+       STA     GOATMILK        ;??\r
+       LDA     MODE\r
+       CMP     #1\r
+       BMI     ZCENTERS\r
+       LDY     PLAYER\r
+       LDA     INITSX,Y        ;GET X POS VALUE FOR PLAYER\r
+       BPL     ZSTORSX         ;BPL = JMP HERE.\r
+ZCENTERS:\r
+       LDA     #$50\r
+ZSTORSX:\r
+       STA     XPOSH+24,X\r
+       CLC\r
+       ADC     DELTAX+3        ;COULD SQUEEZE A BYTE HERE: USE IMMED.\r
+       STA     COLXPOSH+24,X\r
+       LDA     #$50\r
+       STA     YPOSH+24,X\r
+       CLC\r
+       ADC     DELTAY+3        ;COULD SQUEEZE HERE TOO.\r
+       STA     COLYPOSH+24,X\r
+\r
+       LDX     PLAYER          ;STORE FIRST ANIMATION\r
+       LDA     SHIPDIR,X\r
+       LSR\r
+       LSR\r
+       LSR\r
+       AND     #$FE\r
+       CLC\r
+       ADC     #SHIP1 & 255\r
+       LDX     OFFPLAY2\r
+       STA     ACYC+24,X\r
+\r
+       LDA     #SHIP           ;STORE STATUS AS SHIP\r
+       STA     STATUS+24,X\r
+\r
+       RTS\r
+\r
+\r
+INITSX:\r
+       .DC.B   $30,$70         ;XPOS VALUES FOR INITIAL SHIP POS\r
+JOYTBL:\r
+       .DC.B   $F0,$0F         ;JSTICK MASKS, INDEXED BY PLAYER.\r
+\r
+\r
+** HYPER SPACE DISPACHER - HANDLES TIMING OF HYPER SPACE EVENTS. **\r
+HYPERD:\r
+       LDA     TIMER,X         ;CURRENT PLAYERS EVENT TIMER\r
+       CMP     #HYPERT         ;TIME TO JUMP HYPERSPACE?\r
+       BEQ     HYPERGO         ; YES, DO IT.\r
+       CMP     #HYPENDT        ;TIME TO END HYPERSPACE\r
+       BEQ     HYPEND          ; YES, DO IT.\r
+       RTS                     ;OTHERWISE, JUST RTS\r
+\r
+* ROUTINE TO HANDLE THE JUMP TO HYPERSPACE. *\r
+HYPERGO:\r
+       LDA     #$01            ;SOUND\r
+       JSR     DOTUNE\r
+\r
+       LDX     OFFPLAY2        ;NULL OUT SHIP\r
+       LDA     #$FF\r
+       STA     STATUS+24,X\r
+\r
+       LDA     #0              ;NULL VELOCITY\r
+       STA     XVELL+24,X\r
+       STA     XVELH+24,X\r
+       STA     YVELL+24,X\r
+       STA     YVELH+24,X\r
+\r
+       RTS\r
+\r
+\r
+* ROUTINE TO HANDLE THE RETURN FROM HYPERSPACE. *\r
+HYPEND:\r
+       LDA     #24\r
+       CLC\r
+       ADC     OFFPLAY2\r
+       TAX\r
+       JSR     NEWRAND         ;GET NEW SHIP POSITION\r
+       LSR                     ; AVOID EXTREME SIDES\r
+       ADC     #$D             ; (BETWEEN $D AND $8C)\r
+       STA     XPOSH,X\r
+       JSR     NEWRAND         ;GET Y POSITION; AVOID TOP AND BOTTOM\r
+       LSR\r
+       ADC     #$10            ; (BETWEEN $10 AND $90)\r
+       STA     YPOSH,X\r
+       JSR     ISSAFE          ;SAFE TO ENTER\r
+       BEQ     GOBIGRED        ;YOU BET\r
+       LDX     PLAYER          ;SORRY CHARLIE\r
+       INC     TIMER,X\r
+       RTS\r
+GOBIGRED:\r
+       JSR     NEWRAND         ;GET RANDOM VALUE\r
+       CMP     #50             ;SOMETIMES LET THE SHIP EXPLODE\r
+       BCS     NOBLOW          ;OTHERWISE SET NEW POSITION\r
+\r
+       ;EXPLODE HIM!\r
+       LDA     #24             ;WITHOUT THIS X = 'FF' SOMETIMES\r
+       CLC\r
+       ADC     OFFPLAY2\r
+       TAX\r
+       LDA     #$A3            ;BOOM !! SET HIGH BIT OF STATUS\r
+       STA     STATUS,X\r
+       LDA     ELBOUND+3       ;SET ANIMATION STAMP\r
+       STA     ACYC,X\r
+       LDA     #5              ;START SHIP EXPLOSION SOUND\r
+       JSR     DOTUNE\r
+       LDX     PLAYER\r
+BLOW:\r
+       LDA     #DEATH          ;SET STATE\r
+       LDX     PLAYER\r
+       STA     STATE,X\r
+       LDA     #DIET+$28       ;ENTER TIMELINE AT TOP\r
+       STA     TIMER,X\r
+       RTS\r
+\r
+NOBLOW:\r
+       LDA     #3              ;BUZZ SOUND\r
+       JSR     DOTUNE\r
+       LDA     #SHIP           ;RESTORE SHIP\r
+       LDX     TEMP\r
+       STA     STATUS,X\r
+       LDX     PLAYER\r
+       LDA     #OK             ;RETURN STATE TO OK.\r
+       STA     STATE,X\r
+       RTS\r
+\r
+\r
+** COMP PLAY OVER DISPACHER - HANDLES TAKING SHIP OUT. **\r
+COVERD:\r
+*      LDX     PLAYER\r
+       LDA     FLASH\r
+       INC     FLASH\r
+       CMP     #$20\r
+       BEQ     ZTAB\r
+       CMP     #$2E\r
+       BNE     CCONTIN         ;ALL DONE\r
+       JMP     BLOW            ;JUMP INTO HYPER CODE\r
+CCONTIN:\r
+       BIT     BPLOP\r
+       BEQ     DOPAINT\r
+       EOR     #$1F\r
+DOPAINT:\r
+       JSR     PAINTSHP\r
+       RTS\r
+ZTAB:\r
+       LDX     OFFPLAY2        ;NUKE SHIP\r
+       LDA     #$FF\r
+       STA     STATUS+24,X\r
+       RTS\r
+\r
+** DEATH DISPACHER - HANDLES TIMING OF DEATH SEQUENCE. **\r
+DEATHD:\r
+       LDA     TIMER,X         ;CURRENT PLAYERS EVENT TIMER\r
+       CMP     #DIET           ;TOP OF DEATH TIMELINE?\r
+       BEQ     DIE             ; YES, GO TO DIE HANDLER\r
+       CMP     #SWITCHT        ;TIME TO SWITCH PLAYER?\r
+       BNE     ZCKPOT\r
+       JMP     SWITCH          ; YES, SWITCH.\r
+ZCKPOT:\r
+       CMP     #POMSGT ;TIME TO DISPLAY PLAYERX OVER?\r
+       BNE     ZCOKE\r
+       JMP     POMSG           ; YES, DO IT.\r
+ZCOKE:\r
+       CMP     #POMSGOFT       ;TIME TO TURN OFF MESSAGE?\r
+       BEQ     POMSGOFF        ; YES, DO IT.\r
+       CMP     #GOVERT         ;TIME TO DISPLAY GAME OVER MESSAGE?\r
+       BEQ     GOVER           ; YES, DO IT.\r
+       CMP     #NEWGAMET       ;END OF DEATH TIMELINE?\r
+       BNE     DEATHRTS\r
+                               ;YES, SET UP FOR HIGH SCORE CART\r
+       JSR     CLEARTUN        ;GET RID OF ANY TUNES\r
+       JSR     NULLOBJS        ;GET RID OF ANY OBJECTS\r
+       JSR     HSCDOENT\r
+       JMP     DOTITLE\r
+DEATHRTS:\r
+       RTS\r
+\r
+\r
+* ROUTINE TO TAKE DOWN THE ABOVE *\r
+POMSGOFF:\r
+       LDA     #$FF            ;NULL OUT BOTH MESSAGES\r
+       STA     STATUS+34\r
+       STA     STATUS+35\r
+\r
+       TXA                     ;CHECK OTHER PLAYER FOR GAME OVER COND.\r
+       EOR     #$01            ; HERE'S HOW IT WORKS: ONLY ONE PLAYER\r
+       TAY                     ; ACTUALLY MAKES IT TO THE GAME OVER\r
+       LDA     #DEAD           ; MESSAGE TIME.  SO, THE FIRST PLAYER\r
+       CMP     STATE,Y         ; TO MAKE IT TO POMSGOFF BECOMES DEAD\r
+       BEQ     DEATHRTS        ; THE OTHER LIVES ON TO GET TO GOVER!\r
+       STA     STATE,X         ;MAKE PLAYER DEAD, SINCE OTHER IS LIVE.\r
+       LDA     MODE            ;IN TWO PLAYER MODE, SWITCH DATA NOW\r
+       BNE     DEATHRTS        ; SO WE DON'T GET STUCK PLAYING\r
+       JMP     SWITCH          ; A DEAD PLAYER (FSM WON'T RUN ON HIM)\r
+       RTS\r
+\r
+* ROUTINE TO PUT UP GAME OVER MESSAGE *\r
+GOVER:\r
+       LDX     #2              ;GAME OVER MESSAGE\r
+       JSR     SETMSG\r
+       JSR     HIGHSCOR\r
+       RTS\r
+\r
+* ROUTINE TO HANDLE DEATH OF A SHIP. *\r
+* ALL DEATHS GO HERE.  THIS ROUTINE FIGURES OUT WHERE WE SHOULD BE GOING. *\r
+DIE:\r
+       JSR     INITHUMP        ;REINIT THUMP RATE\r
+\r
+       LDA     #$11            ;KILL THRUST SOUND\r
+       JSR     KILLTUNE\r
+       LDX     PLAYER          ;RESTORE X, TRASHED BY KILLTUNE\r
+\r
+       ;HANDLE MODES DIFFERENTLY\r
+       LDY     MODE\r
+       LDA     MENLEFTC        ;LOAD TEAMPLAY MENLEFT AS DEFAULT\r
+       CPY     #1\r
+       BEQ     ZDIEMN1         ;IF NOT TEAMPLAY MODE\r
+       LDA     MENLEFT,X       ; USE CURRENT MENLEFT\r
+ZDIEMN1:\r
+       CMP     #1              ;IF WE HAVE NO MEN LEFT\r
+       BCC     NOMENLFT        ; HANDLE THIS SITUATION\r
+       CPY     #0              ;ELSE IF NOT TWO PLAYER MODE\r
+       BNE     GIVEBRTH        ; SIMPLY TRY TO GIVE BIRTH.\r
+\r
+       TXA                     ;ELSE TWO PLAYER MODE:\r
+       EOR     #$01            ; CHECK OTHER PLAYER'S MENLEFT.\r
+       TAX\r
+       LDA     MENLEFT,X\r
+       CMP     #1              ; IF HE HAS MEN LEFT THEN\r
+       BCS     DEATHRTS        ;  SIMPLY RTS. SWITCH WILL DO THE TRICK\r
+       JMP     GIVBRTH2        ; ELES SKIP THE SWITCH.  GIVE BIRTH NOW\r
+\r
+NOMENLFT:\r
+       CPY     #$FF            ;ELSE, IF ONE PLAYER MODE\r
+       BEQ     DIEGOVER        ; DIE WITH SIMPLE GAMEOVER (NO PMSG)\r
+       CPY     #$1             ;ELSE, IF NOT IN TEAM PLAY MODE\r
+       BNE     DIEPOVER        ; DIE WITH PLAYER OVER MESSAGE\r
+       TXA                     ;ELSE CHECK OTHER PLAYER'S STATE\r
+       EOR     #$01            ; TO SEE WHETHER TO END THE GAME\r
+       TAX\r
+       LDA     STATE,X\r
+       CMP     #BIRTH          ; IF OTHER PLAYER IS NOT IN BIRTH\r
+       BNE     GIVEBRTH        ;  THEN TRY TO GIVE BIRTH.\r
+       LDA     OFFPLAY2        ; OTHERWISE,\r
+       EOR     #$08            ;  (TOGGLE OFFPLAY2)\r
+       TAY\r
+       LDA     STATUS+24,Y     ;  IF HE IS NOT YET BORN, THEN\r
+       CMP     #SHIP           ;  FORGET IT BUD.  AIN'T NO LIVES LEFT\r
+       BEQ     GIVEBRTH        ;  FOR EITHER OF THEM.\r
+       LDA     #DEAD           ;   NUKE OTHER PLAYER OUT OF BIRTHST\r
+       STA     STATE,X         ;   TO PREVENT A NEW RACK FROM STARTING\r
+DIEGOVER:\r
+       LDA     #GOVERT+3       ;DIE WITH GAME OVER MESSAGE ONLY\r
+       BNE     ZDIEOVER        ; BNE = JMP\r
+\r
+DIEPOVER:\r
+       LDA     #POMSGT+3       ;DIE WITH PLAYER N GAME OVER MESSAGE\r
+ZDIEOVER:\r
+       LDX     PLAYER\r
+       STA     TIMER,X\r
+       RTS\r
+\r
+GIVEBRTH:\r
+       LDX     PLAYER\r
+       LDA     #BIRTH          ;GIVE BIRTH\r
+       STA     STATE,X\r
+       LDA     #RESINT+3       ;AT TIMER RESIN+3\r
+       STA     TIMER,X\r
+       RTS\r
+\r
+* ROUTINE TO PUT UP PLAYERX GAME OVER MESSAGE *\r
+POMSG:\r
+       LDX     PLAYER          ;PLAYERX MESSAGE\r
+       LDA     COMPFLAG\r
+       BMI     PVICTOR\r
+       BEQ     PPLAYER\r
+       JSR     CMPSCOR         ;COMPARE SCORES\r
+       TAX\r
+       BPL     PVICTOR\r
+;          TIE SCORE\r
+       LDA     GOATMILK        ;CHECK FLAG\r
+       BNE     PUNTTHIS        ;SHIP TO SHIP\r
+       LDX     PLAYER          ;NO, PUT MESSAGE FOR THIS GUY\r
+       BPL     PVICTOR         ; = JMP\r
+PUNTTHIS:\r
+       LDA     #$FF            ;RETURN W/OUT MSG IF EQUAL\r
+       STA     STATUS+34       ;TAKE MSG DOWN BEFORE SEEN\r
+       STA     STATUS+35\r
+       RTS\r
+\r
+PPLAYER:\r
+       JSR     SETMSG\r
+       LDX     #2\r
+DOMSG:\r
+       JSR     SETMSG\r
+       LDX     MODE\r
+       CPX     #2\r
+       BNE     ZPORTS\r
+       STX     COMPFLAG\r
+ZPORTS:\r
+       RTS\r
+\r
+PVICTOR:\r
+       JSR     SETMSG          ;X HAS PLAYER\r
+       LDX     #3\r
+       BPL     DOMSG           ;BPL  =  JMP\r
+\r
+* ROUTINE TO SWITCH THE TWO DATA SETS WHEN NEEDED. *\r
+SWITCH:\r
+       TXA                     ;TOGGLE CURRENT PLAYER # AND OFFSET\r
+       EOR     #$01\r
+       TAX\r
+       STA     PLAYER\r
+       BEQ     ZSTOFFP2\r
+       LDA     #8\r
+ZSTOFFP2:\r
+       STA     OFFPLAY2\r
+\r
+       LDA     #$FF            ;NULL OUT SPACE OBJECTS\r
+       LDX     #7              ; (31-23=8 OBJECTS)\r
+SWCHNULL:\r
+       STA     STATUS+24,X\r
+       DEX\r
+       BPL     SWCHNULL\r
+\r
+       LDA     #0\r
+       STA     RACKDLY         ;NO DELAY AFTER SWITCH\r
+       LDA     #$50\r
+       STA     RTIMER          ;RESET UFO FREQUENCY AND TIMER\r
+       LDA     #$92\r
+       STA     SDELAY\r
+       STA     EDELAY\r
+       JSR     CLEARTUN        ;KILL TUNES, ESP. UFO\r
+\r
+       LDY     #23\r
+SWCHLOOP:\r
+       LDX     STATUS,Y\r
+       LDA     STATUS2,Y\r
+       STA     STATUS,Y\r
+       TXA\r
+       STA     STATUS2,Y\r
+*\r
+       LDX     ACYC,Y\r
+       LDA     ACYC2,Y\r
+       STA     ACYC,Y\r
+       TXA\r
+       STA     ACYC2,Y\r
+*\r
+       LDX     PALS,Y\r
+       LDA     PALS2,Y\r
+       STA     PALS,Y\r
+       TXA\r
+       STA     PALS2,Y\r
+*\r
+       LDX     XVELH,Y\r
+       LDA     XVELH2,Y\r
+       STA     XVELH,Y\r
+       TXA\r
+       STA     XVELH2,Y\r
+*\r
+       LDX     YVELH,Y\r
+       LDA     YVELH2,Y\r
+       STA     YVELH,Y\r
+       TXA\r
+       STA     YVELH2,Y\r
+*\r
+       LDX     XVELL,Y\r
+       LDA     XVELL2,Y\r
+       STA     XVELL,Y\r
+       TXA\r
+       STA     XVELL2,Y\r
+*\r
+       LDX     YVELL,Y\r
+       LDA     YVELL2,Y\r
+       STA     YVELL,Y\r
+       TXA\r
+       STA     YVELL2,Y\r
+*\r
+       LDX     XPOSH,Y\r
+       LDA     XPOSH2,Y\r
+       STA     XPOSH,Y\r
+       TXA\r
+       STA     XPOSH2,Y\r
+*\r
+       LDX     YPOSH,Y\r
+       LDA     YPOSH2,Y\r
+       STA     YPOSH,Y\r
+       TXA\r
+       STA     YPOSH2,Y\r
+\r
+       DEY\r
+       BPL     SWCHLOOP\r
+\r
+GIVBRTH2:\r
+       LDX     PLAYER          ;GIVE BIRTH, TWO PLAYER STYLE (PMSG)\r
+       LDA     #BIRTH          ;GIVE BIRTH\r
+       STA     STATE,X\r
+       LDA     #PMSGT+$20      ;AT TIMER PMSGT+20\r
+       STA     TIMER,X\r
+\r
+       RTS\r
diff --git a/HISCORE.S b/HISCORE.S
new file mode 100644 (file)
index 0000000..f49e4d9
--- /dev/null
+++ b/HISCORE.S
@@ -0,0 +1,255 @@
+*         1415    280384\r
+*\r
+** HISCORE.S\r
+** ASTEROIDS FOR THAT DAMN ATARI 3600, OR IS IT 7000, I FORGET. *\r
+** WRONG!! IT'S THE ATARI 7800 PRO SYSTEM.  TA DA! *\r
+** THIS FILE CONTAINS THE HANDLERS FOR THE INTERFACE TO THE HISCORE CART *\r
+**  UPDATED TO HSC REV 7.X *\r
+\r
+* HSCINIT -- INITIALIZE HIGH SCORE CART DATA.  DOES HSCSTAT.\r
+* RETURNS > 0 IF NO HSC EXISTS, < 0 IF ENTRY NOT FOUND, ZERO IF OK\r
+HSCINIT:\r
+       JSR     HSCSETDM        ;SET UP DIFF/MODE LEVEL ARGUMENT\r
+HSCINIT2:\r
+       LDA     #$C6            ;CHECK EXISTANCE.\r
+       CMP     $3900\r
+       BNE     NOHSC\r
+       LDA     #$FE\r
+       CMP     $3904\r
+       BNE     NOHSC\r
+\r
+       LDX     #$0E            ;COPY HSC ROM INTO RAM ARGUMENT BLOCK\r
+HSCCOPY:\r
+       LDA     HSCROM,X\r
+       STA     HSCRAM,X\r
+       DEX\r
+       BPL     HSCCOPY\r
+\r
+       LDA     TEMP            ;INSTALL LEVEL ARGUMENT\r
+       ASL\r
+       ASL\r
+       STA     HSCRAM+2\r
+\r
+;      LDX     #L(HSCRAM)      ;WHY BOTHER; HSC TRASHES X ANYWAY\r
+       LDY     #HSCRAM >> 8\r
+       JMP     HSCSTAT\r
+\r
+NOHSC:\r
+       LDA     #1              ;POSITIVE NUMBER = NO HIGH SCORE\r
+       RTS\r
+\r
+* HSSUCK -- SUCK IN HIGH SCORE, IF AVAILABLE.  IF NOT ZAP IT OUT.\r
+HSCSUCK:\r
+       JSR     ZEROHS          ;FIRST ZAP IT OUT\r
+       JSR     HSCINIT         ;SUCK IN HIGH SCORE, IF AVAILABLE\r
+       BNE     NOHSC\r
+       LDX     #3\r
+SUCKHSIN:\r
+       LDA     HSCRAM+$F,X\r
+       STA     HISCORE,X\r
+       DEX\r
+       BPL     SUCKHSIN\r
+       RTS\r
+\r
+* HSCSHOW -- DISPLAY ONE DIFF/MODE LEVEL\r
+HSCSHOW:\r
+       JSR     HSCINIT2        ;USE INIT2 SO NOT TO DISTURB TEMP VAL\r
+       BNE     NOHSC\r
+\r
+       LDX     HSCRAM+4        ;COMPUTE DISPLAY TIMES FOR EACH LEVEL\r
+       CPX     #5              ;USE MINIMUM TIME IF >= 5 ENTRIES\r
+       BCC     ZNHSOK\r
+       LDX     #5\r
+ZNHSOK:\r
+       LDA     HSTIME,X        ;TABLE LOOKUP FOR DISPLAY TIME\r
+       STA     HSCRAM+$E\r
+\r
+       LDA     TEMP            ;TEMP CONTAINS THE DIFF/MODE LEVEL\r
+       ASL                     ; SHIFT UP FOR ARG FORMAT\r
+       ASL\r
+       STA     HSCRAM+2\r
+\r
+       JSR     HSCDM           ;PUT UP OUR OWN DIFFICULTY/MODE NAMES\r
+       JSR     ONTITLE         ;PUT UP THE LOGO\r
+\r
+       JSR     WAITLOAD        ;WAIT FOR LOADER TO UPDATE\r
+       LDA     #$60            ;TURN OFF DMA NOW, SO WE DON'T GET\r
+       STA     CTRL            ; A GLITCHY SCREEN IN BETWEEN\r
+       LDA     #$40            ;TELL NMI HANDLER TO DO FANCY\r
+       STA     NMICTRL         ; ALTERNATING READ MODES ON CTRL\r
+\r
+;      JSR     OLDBUTON        ;GO BACK TO ONE BUTTON MODE\r
+;      LDX     #L(HSCRAM)\r
+       LDY     #HSCRAM>>8\r
+       JSR     HSCATRCT\r
+;      JSR     NEWBUTON        ;REVERT TO WHATEVER MODE WAS BEFORE\r
+\r
+       RTS\r
+\r
+* HSCDOENT -- DO CALLS TO HSCENTER FOR ALL PLAYERS WHAT NEEDS IT\r
+HSCDOENT:\r
+       JSR     HSCINIT         ;SET UP HSC\r
+       BEQ     ZHSENTOK        ;DOES THE HSC EXIST?\r
+       BPL     NOHSC           ;NO.  DO NOTHING.\r
+ZHSENTOK:\r
+       LDA     HSCRAM+2        ;SET UP TEMP TO DM VALUE\r
+       LSR\r
+       LSR\r
+       STA     TEMP\r
+\r
+       JSR     HSCDM           ;PUT UP DIFF/MODE INDICATORS\r
+       JSR     ONTITLE         ;PUT UP THE LOGO\r
+\r
+       LDA     MODE            ;SET UP ENTER DELAY FOR THIS MODE\r
+       LSR\r
+       BCC     ZNOWAIT         ;ON EVEN MODES, DON'T WAIT HERE.\r
+       LDA     #10             ;ON ODD MODES, WAIT 10 SECONDS.  THERE\r
+       STA     HSCRAM+$E       ; IS ONLY ONE SCORE BEING ENTERED.\r
+ZNOWAIT:\r
+       LDA     MODE            ;IF IN ONE PLAYER MODE JUST\r
+       BMI     ZHSCENT         ;  DO THIS ONE.\r
+\r
+       LDX     #0              ;PICK HIGHER OF THE TWO FIRST!\r
+ZCOMPLOP:\r
+       LDA     SCORE,X         ; COMPARE EACH DIGIT OF P1 SCORE\r
+       CMP     SCORE+4,X       ;  AGAINST EACH DIGIT OF P2 SCORE\r
+       BEQ     ZP2EQU          ; P1 EQUALS P2, MOVE ON TO NEXT DIGIT\r
+       BCS     ZPNGO           ; P1 > P2, LET P1 ENTER\r
+ZP2GO:                         ; P2 > P1, LET P2 ENTER\r
+       INC     HSCRAM+2        ; TOGGLE PLAYER BIT TO P2\r
+       LDA     #SCORE2 & 255   ; CHANGE TO P2 SCORE\r
+       STA     HSCRAM+8\r
+ZPNGO:\r
+\r
+       LDA     MODE            ;IN TEAMPLAY MODE, USE COMBINED SCORE\r
+       CMP     #1\r
+       BNE     ZHSCENT\r
+       LDA     #COMBSCOR & 255\r
+       STA     HSCRAM+8        ;LOW ADDR OF SCORE PTR.  HI ADDR = 0 ZP\r
+\r
+ZHSCENT:\r
+       JSR     WAITLOAD        ;WAIT FOR LOADER TO UPDATE\r
+       LDA     #$60            ;TURN OFF DMA NOW, SO WE DON'T GET\r
+       STA     CTRL            ; A GLITCHY SCREEN IN BETWEEN\r
+       LDA     #$40            ;TELL NMI HANDLER TO DO FANCY\r
+       STA     NMICTRL         ; ALTERNATING READ MODES ON CTRL\r
+\r
+;      JSR     OLDBUTON        ;GO BACK TO ONE BUTTON MODE\r
+;      LDX     #L(HSCRAM)\r
+       LDY     #HSCRAM >> 8\r
+       JSR     HSCENTER\r
+;      JSR     NEWBUTON        ;REVERT TO WHATEVER MODE WAS BEFORE\r
+\r
+       LDA     HSCRAM+$E       ;CHECK DELAY TIME:\r
+       BNE     ZHSCRTS         ; IF NOT ZERO, WE'RE DONE.\r
+\r
+       LDA     #10             ;SET DELAY TIME TO FINAL DELAY.\r
+       STA     HSCRAM+$E\r
+\r
+       LDA     HSCRAM+2        ;CHECK PLAYER BIT TO SEE WHICH PLAYER\r
+       LSR\r
+       BCC     ZP2GO           ;IF WE JUST DID P1, THEN DO P2\r
+ZP1GO:\r
+       LDA     #SCORE & 255    ;GO BACK TO P1 SCORE\r
+       STA     HSCRAM+8\r
+       DEC     HSCRAM+2        ;GO BACK TO P1 JOYSTICK\r
+       JMP     ZHSCENT\r
+\r
+ZP2EQU:\r
+       INX                     ; MOVE ON TO NEXT DIGIT\r
+       CPX     #4              ; 4 DIGITS OF SCORE TO COMPARE\r
+       BEQ     ZPNGO           ; IF WE HAVE DONE ALL COMPARES, DFLT P1\r
+       BNE     ZCOMPLOP        ; IF NOT, DO NEXT COMPARE\r
+\r
+* HSCDM -- PUT UP DIFF/MODE ICONS ACCORDING TO VALUE OF TEMP\r
+HSCDM:\r
+       LDA     TEMP\r
+       AND     #$03            ;GET DIFF BITS\r
+       CLC\r
+       ADC     #10\r
+       TAY\r
+       LDX     #10\r
+       JSR     DOICON\r
+       LDA     TEMP\r
+       LSR                     ;GET MODE BITS\r
+       LSR\r
+       BEQ     HSCZAPM         ;ONLY DISPLAY TEAM AND COMPETITVE PLAY\r
+       CLC\r
+       ADC     #15\r
+       TAY\r
+       INX                     ;10+1=11\r
+       JSR     DOICON\r
+ZHSCRTS:\r
+       RTS\r
+\r
+HSCZAPM:\r
+       LDA     #$FF            ;ZAP OUT STATUS OF MODE ICON\r
+       STA     STATUS+11\r
+       RTS\r
+\r
+* HSCSETDM -- SET DIFF/MODE LEVEL ARGUMENT BASED ON DIFF AND MODE\r
+HSCSETDM:\r
+       LDA     MODE            ;COMPUTE DIFF/MODE LEVEL VALUE BYTE\r
+       BPL     ZHSCMOK\r
+       LDA     #0\r
+ZHSCMOK:\r
+       ASL\r
+       ASL\r
+       CLC\r
+       ADC     DIFF\r
+       STA     TEMP            ;SAVE IT WHERE WE CAN INSERT LATER\r
+       RTS\r
+\r
+* GO TO OLD ONE-BUTTON MODE FOR WAT'S HISCORE CART\r
+;OLDBUTON  LDA #$FF\r
+;ZOLDSTOR  STA SWCHB\r
+;          RTS\r
+* GO BACK TO PREVIOUS STATE\r
+;NEWBUTON  LDA ONEBUT\r
+;          BPL ZOLDSTOR\r
+\r
+; THIS TABLE IS COPIED INTO RAM WHEN HSC IS CALLED.  IT'S THE ARGUMENT BLOCK\r
+;          NEEDED BY THE HSC.\r
+\r
+HSCROM:\r
+       .DC.B   $49,$6C         ; CARTRIDGE ID NUMBER\r
+\r
+       .DC.B   $00             ; DIFFICULTY LEVEL\r
+                               ;  + PLAYER NUMBER (BOTTOM 2 BITS)\r
+\r
+       .DC.B   $01             ; CONTROLLER TYPE\r
+\r
+       .DC.B   $00,$00         ; GAME NAME; WE USE OUR OWN LOGO.\r
+\r
+       .DC.B   $00,$00         ; DIFFICULTY NAME; WE USE OUR OWN.\r
+\r
+       .DC.W   SCORE           ; POINTER TO THE SCORE\r
+\r
+       .DC.W   HSCDLL          ; POINTER TO DLL\r
+\r
+       .DC.W   LOGOBARS        ;SOUND ROUTINE. WE USE THIS TO TWINKLE\r
+                               ;  OUR LOGO BARS WHILE OFF SCREEN.\r
+\r
+       .DC.B   $00             ; SECONDS TO WAIT BEFORE RETURNING\r
+                               ;  (FOR EACH DIFFICULTY LEVEL)\r
+\r
+* HSCDLL -- DLL FOR HSC DISPLAY.  MERELY A RE-ARRANGED VERSION OF DLLTAB W/DLIS\r
+HSCDLL:\r
+       .DC.B   $8F\r
+       .DC.B   BLANKDL>>8,BLANKDL&255                  ;DLI + 16 BLANK LINES\r
+\r
+       .DC.B   $4F\r
+       .DC.B   (GAMEDL07+4)>>8,(GAMEDL07+4)&255        ;NO DLI + MODE\r
+\r
+       .DC.B   $4F\r
+       .DC.B   (GAMEDL04+4)>>8,(GAMEDL04+4)&255        ;NO DLI + TOP OF LOGO\r
+\r
+       .DC.B   $4F\r
+       .DC.B   (GAMEDL05+4)>>8,(GAMEDL05+4)&255        ;NO DLI + BOTTOM OF LOGO\r
+\r
+       .DC.B   $4F\r
+       .DC.B   (GAMEDL11+4)>>8,(GAMEDL11+4)&255        ;NO DLI + DIFF LEVEL\r
+\r
+* HSTIME -- TIME TO DISPLAY EACH ENTRY FOR A GIVEN TOTAL NUMBER OF ENTRIES.\r
+HSTIME:\r
+       .DC.B   0,10,6,5,4,3\r
diff --git a/INIT.S b/INIT.S
new file mode 100644 (file)
index 0000000..6405496
--- /dev/null
+++ b/INIT.S
@@ -0,0 +1,214 @@
+*         1522    030784\r
+*\r
+*\r
+*\r
+** INIT.S **\r
+** ASTEROIDS FOR THE ATARI 3600 **\r
+** THIS FILE CONTAINS VARIOUS INITIALIZATION ROUTINES. **\r
+\r
+* ROCK INITIALIZATION ROUTINE, SOFT PALETTES, RANDPOS AND VELOCITY TO ROCKS\r
+INITROCK:\r
+          LDA     #$FF                   ;FOR NEW RACK NULL OUT ROCKS.\r
+          LDX     #23\r
+NULLROCK: STA     STATUS,X\r
+          DEX\r
+          BPL     NULLROCK\r
+\r
+*         ;PUT UP DIFFICULTY ICON.\r
+*         LDA     #10\r
+*         CLC\r
+*         ADC     DIFF\r
+*         TAY\r
+*         LDX     #33\r
+*         JSR     DOICON\r
+*         LDA     #16                    ;REPOSITION ICON DURING GAMEPLAY\r
+*         STA     XPOSH,X\r
+\r
+          LDY     PLAYER\r
+          LDX     ROCKTOT,Y\r
+          DEX\r
+NROKLOOP: LDA     #LARGE                 ;INITIALIZE ROCKS\r
+          STA     STATUS,X\r
+          LDA     ASPIN,X\r
+          AND     #$7F\r
+          TAY\r
+          LDA     LBOUND,Y\r
+          STA     ACYC,X                 ;STORE INITIAL ANIMATION\r
+          JSR     RANDPOS                ;STORE A RANDOM BORDER POSITION\r
+          JSR     RANDVEL                ; AND RANDOM VELOCITY.\r
+          DEX\r
+          BPL     NROKLOOP\r
+\r
+COPYPALS: LDX     #32\r
+ZOPYPALS: LDA     PALTAB,X               ;LOAD UP SOFT PALETTE/WIDTH TABLE\r
+          STA     PALS,X\r
+          DEX\r
+          BPL     ZOPYPALS\r
+\r
+          RTS\r
+\r
+** ROUTINE TO INITIALIZE THE SCORE DISPLAY THE FIRST TIME. **\r
+INITSCOR:\r
+*         FIRST ZERO SCORE FOR BOTH PLAYERS\r
+          LDX     #11\r
+          LDA     #0\r
+ZEROSCOR: STA     SCORE,X\r
+          DEX\r
+          BPL     ZEROSCOR\r
+\r
+          RTS\r
+\r
+* ROUTINE TO ZERO OUT THE HIGH SCORE\r
+ZEROHS:   LDA     #0\r
+          STA     HISCORE                ;ZAP THE HIGH SCORE\r
+          STA     HISCORE+1\r
+          STA     HISCORE+2\r
+          STA     HISCORE+3\r
+          RTS\r
+\r
+INITPLAY:\r
+          JSR     CLEARTUN               ;CLEAR OUT AUDIO CHANNELS\r
+\r
+          ;SET UP STATUS FOR SHIP PARTS TO BE USED IN COLLIDE.\r
+          LDA     #7                     ;SHIP'S PARTS = #7\r
+          TAX                            ;THERE ARE EIGHT PARTS TO SET UP\r
+NXTPART:  STA     STATUS+36,X\r
+          DEX\r
+          BPL     NXTPART\r
+\r
+          ;SET UP TABLES FOR DIFF LEVELS.\r
+          LDY     DIFF\r
+          LDA     MAXLVLS,Y              ;HIGHEST ATTAINABLE LEVEL FOR DIFF\r
+          STA     MAXLVL\r
+          INY\r
+          TYA\r
+          LDX     #3                     ;FOUR TYPES OF INCREMENTS\r
+ZNXTDLVL: STA     LVLINC,X               ; THE INCREMENT IS BASED ON\r
+          ASL                            ; DIFF+1, SHIFTED LEFT BY\r
+          DEX                            ; THE TYPE.  I.E:\r
+          BPL     ZNXTDLVL               ; 8,4,2,1; 16,8,4,2; 24,12,6,3; ETC.\r
+\r
+          LDA     #3                     ;3 SHIPS FOR EACH PLAYER\r
+          STA     MENLEFT\r
+          STA     MENLEFT+1\r
+          LDA     #6                     ;6 FOR TEAM PLAY\r
+          STA     MENLEFT+2\r
+\r
+          LDA     #$FF                   ;INITIALIZE FOR BOTH PLAYERS\r
+          STA     RACKNUM\r
+          STA     RACKNUM+1\r
+          STA     RUBFLAG                ;PRIME 'RUBBER SHIP' FLAG\r
+\r
+          LDA     #0\r
+          STA     ROCKTOT\r
+          STA     ROCKTOT+1\r
+          STA     PLAYER\r
+          STA     OFFPLAY2\r
+          STA     SHIPDIR\r
+          STA     SHIPDIR2\r
+          STA     RACKDLY\r
+          STA     COMPFLAG\r
+\r
+          LDA     #BIRTH                 ;START PLAYER 1 AS BIRTH\r
+          STA     STATE\r
+\r
+          LDA     #$20                   ;EVERYBODY STARTS AT LEVEL $20\r
+          STA     LEVEL\r
+          STA     LEVEL+1\r
+\r
+          LDA     MODE\r
+          BPL     ZSETTWO\r
+\r
+          LDA     #DEAD                  ;IN ONE PLAYER GAME,\r
+          STA     STATE+1                ; OTHER PLAYER IS DEAD.\r
+\r
+          LDA     #RESINT+$10            ;START PLAYER 1 AT RESINT+10\r
+          STA     TIMER\r
+          RTS\r
+\r
+ZSETTWO:  LDA     #BIRTH                 ;IN > 1 PLAYER GAME,\r
+          STA     STATE+1                ; SECOND PLAYER WILL BE BORN.\r
+\r
+          LDA     #PMSGT+1               ;TWO AND TEAM PLAY\r
+          STA     TIMER\r
+          STA     TIMER+1\r
+          RTS\r
+\r
+MAXLVLS:  .DC.B   $40,$60,$80,$DF        ;$DF = "AVOID WRAP" WHEN ADDING $20!\r
+\r
+** ROUTINES THAT USED TO BE IN MAIN.S **\r
+\r
+* ZERO OUT RAM. *\r
+* ZERO OUT MEMORY PAGES 1F-18\r
+ZERORAM:  LDA     #0\r
+          TAY\r
+          STA     TEMP                   ;LOADDR ALWAYS = 0 (Y IS LOADDR INDEX)\r
+\r
+          LDX     #$1F                   ;START WITH PAGE 1F\r
+NEXTX:    STX     TEMP+1\r
+\r
+          ; ZAP ONE PAGE:\r
+NEXTY:    STA     (TEMP),Y\r
+          DEY\r
+          BNE     NEXTY\r
+\r
+          ; MOVE ON TO NEXT PAGE\r
+          DEX\r
+          CPX     #$17                   ;DON'T GO INTO PAGE 17\r
+          BNE     NEXTX\r
+\r
+* ZERO OUT THE ZEROPAGE (FF-86), BUT NOT THE RANDOMS (40-41)\r
+          LDX     #$BE\r
+ZPLOOP:   STA     $41,X\r
+          DEX\r
+          BNE     ZPLOOP\r
+          RTS\r
+\r
+* LOAD UP SOFTWARE COPY OF COLOR RAM FROM ROM COLORS\r
+INITPALS: LDX     #$0F\r
+ZNITPALS: LDA     COLORS,X\r
+          STA     SOFTCOLR,X\r
+          DEX\r
+          BPL     ZNITPALS\r
+          RTS\r
+\r
+* NULL OUT ALL THE OBJECTS. *\r
+NULLOBJS: LDX     #35                    ;NULL OUT OBJECTS\r
+          LDA     #$FF\r
+NEWNULL:  STA     STATUS,X\r
+          STA     STATUS2,X\r
+          DEX\r
+          BPL     NEWNULL\r
+          RTS\r
+\r
+\r
+* SET UP MARIA 2 LISTS, DUMMY DL HEADER FOR BLANK ZONES AT TOP AND BOTTOM,\r
+* SET UP DUMMY DL HEADER FOR TOP AND BOTTOM OF SCREEN:\r
+INITDMA:\r
+*         BUILD DLL.  ACTUALLLY, JUST COPY ROM TABLE INTO FASTER RAM.\r
+          LDX     #$33                   ;TABLE IS $33 BYTES LONG\r
+ZDLLOP:   LDA     DLLTAB,X\r
+          STA     DLL,X\r
+          DEX\r
+          BPL     ZDLLOP\r
+\r
+*         WAIT 'TILL VBLANK BEFORE DOING DELICATE OPERATIONS\r
+ZDODMA:   BIT     MSTAT\r
+          BPL     ZDODMA\r
+\r
+          LDA     #DLL&255                ;POINT DPP TO DLL\r
+          STA     DPPL\r
+          LDA     #DLL>>8\r
+          STA     DPPH\r
+\r
+          LDA     #0\r
+          STA     BLANKDL+1              ;SECOND BYTE ZERO = END OF DMA\r
+          STA     NMICTRL                ;TELL NMI HANDLER TO DO NORMAL DLI'S\r
+\r
+          LDA     #CHARS>>8            ;POINT CHARBASE TO OUR CHARACTERS\r
+          STA     CHARBASE\r
+\r
+          LDA     #$40                   ;TURN ON DMA\r
+          STA     CTRL\r
+\r
+          RTS\r
diff --git a/JOY.S b/JOY.S
new file mode 100644 (file)
index 0000000..b788de6
--- /dev/null
+++ b/JOY.S
@@ -0,0 +1,580 @@
+*         2040    180684\r
+*\r
+** JOY.S **\r
+** ASTEROIDS FOR THE ATARI 3600 **\r
+** THIS FILE CONTAINS THE JOYSTICK HANDLING ROUTINE. **\r
+\r
+JOY:\r
+       LDX     PLAYER\r
+       LDA     STATE,X         ;CHECK IF SHIP IS OK\r
+       BEQ     EXECJOY         ;ONLY CHECK JOYSTICK IF OK\r
+       RTS\r
+\r
+EXECJOY:\r
+       LDX     OFFPLAY2        ;POWER STEERING BABY!\r
+       LDA     XVELH+24,X      ;CALCULATE RATE OF TURN\r
+       BPL     ZSTTEMP         ;A VELOCITY DEPENDENT VALUE\r
+       EOR     #$FF\r
+       CLC\r
+       ADC     #1\r
+ZSTTEMP:\r
+       STA     TEMP\r
+       LDA     YVELH+24,X\r
+       BPL     ZADDTEMP\r
+       EOR     #$FF\r
+       CLC\r
+       ADC     #1\r
+ZADDTEMP:\r
+       CLC\r
+       ADC     TEMP\r
+       STA     TEMP\r
+       LDA     #9\r
+       SBC     TEMP\r
+       STA     TEMP\r
+\r
+       LDX     PLAYER            ;CHECK HYPERSPACE\r
+       LDA     HYPBUT1,X\r
+       BMI     LDSWCH\r
+       JSR     HYPERSPC\r
+\r
+LDSWCH:\r
+       LDA     SWCHAVAL        ;GET JOYSTICK INPUT\r
+       LDX     PLAYER\r
+       BEQ     JOYONE\r
+       ASL                     ;IF PLAYER2 THEN SHIFT 4 MORE\r
+       ASL\r
+       ASL\r
+       ASL\r
+JOYONE:\r
+CKWEST:\r
+       ASL                     ;SHIFT MSB INTO CARRY\r
+       PHA                     ;SAVE ACC\r
+       BCS     CKEAST          ;IF SET THEN NEXT, ACTIVE LOW\r
+       JSR     ROTLEFT         ;CLEAR, ROTATE LEFT\r
+CKEAST:\r
+       PLA                     ;RESTORE ACC\r
+       ASL                     ;CHECK WEST BIT\r
+       PHA                        ;SAVE ACC\r
+       BCS     CKSOUTH         ;IF SET THEN NEXT\r
+       JSR     ROTRIGHT        ;CLEAR, ROTATE RIGHT\r
+CKSOUTH:\r
+       PLA\r
+       ASL\r
+       PHA\r
+       BCS     CKNORTH\r
+       JSR     DAMPX\r
+       JSR     DAMPY\r
+CKNORTH:\r
+       PLA                     ;RESTORE ACC\r
+       ASL                     ;CHECK NORTH BIT\r
+       BCS     DAMPTHR         ;IF SET THEN DAMP\r
+       BCC     ADDTHRST        ;IF CLEAR THEN THRUST\r
+\r
+\r
+*          ROTATE SHIP ROUTINES\r
+ROTRIGHT:\r
+       LDA     SHIPDIR,X\r
+       SEC\r
+       SBC     TEMP\r
+       JMP     SETSDIR\r
+\r
+ROTLEFT:\r
+       LDA     SHIPDIR,X\r
+       CLC\r
+       ADC     TEMP\r
+SETSDIR:\r
+       STA     SHIPDIR,X\r
+       LDY     OFFPLAY2\r
+       LSR\r
+       LSR\r
+       LSR\r
+       AND     #$FE\r
+       CLC\r
+       ADC     #SHIP1&255\r
+       STA     ACYC+24,Y\r
+       RTS\r
+\r
+*          DAMPEN THRUST ROUTINE\r
+DAMPTHR:\r
+       LDA     MODE            ;IN ONE-AT-A-TIME PLAY,\r
+       CMP     #01             ; (I.E., MODES $FF AND $00),\r
+       BMI     DAMPTN          ; DON'T WORRY ABOUT OTHER PLAYER\r
+       LDA     STATE           ;ELSE MAKE SURE BOTH PLAYERS ARE OK.\r
+       ORA     STATE+1         ; IF EITHER IS NOT, IT MUST BE THE\r
+       BNE     DAMPTN          ; OTHER ONE! GO ON AS IF ONLY 1 IS OK.\r
+       LDA     SWCHAVAL        ;ELSE MAKE SURE ONLY ONE THRUST TUNE IS\r
+       AND     THRBITS,X       ; EVER PLAYING AT A TIME;\r
+       BEQ     NODAMPTN        ; (IF = 0, THEN *HE* IS THRUSTING)\r
+DAMPTN:\r
+       LDA     #$11            ;DAMP THRUST TUNE\r
+       JSR     KILLTUNE        ; (GET RID OF THE TUNE)\r
+NODAMPTN:\r
+\r
+       LDA     PLAYER\r
+       ASL\r
+       ASL\r
+       TAY\r
+       LDA     #$00\r
+       STA     SOFTCOLR+1,Y\r
+       JSR     DAMPX\r
+       JSR     DAMPY\r
+\r
+*          CHECK THE FIRE BUTTON\r
+CHKFIRE:\r
+       LDX     PLAYER\r
+       LDA     FIREBUT1,X\r
+       BMI     FRESET\r
+       LDA     FIRESTAT,X\r
+       BNE     JOYBYE\r
+       JMP     DNSHOT\r
+\r
+FRESET:\r
+       LDA     #0\r
+       STA     FIRESTAT,X\r
+JOYBYE:\r
+       RTS\r
+\r
+*          ADD THRUST ROUTINE\r
+ADDTHRST:\r
+       LDA     #$11            ;ADD THRUST SOUND\r
+       JSR     DOTUNE2         ;ONLY IF NOT ALREADY PLAYING\r
+\r
+       LDA     PLAYER          ;CHANGE COLOR OF THRUST FLAME\r
+       ASL\r
+       ASL\r
+       TAY\r
+       LDA     #$4F\r
+       STA     SOFTCOLR+1,Y\r
+\r
+       LDX     PLAYER\r
+       LDA     SHIPDIR,X\r
+       LSR\r
+       LSR\r
+       LSR\r
+       LSR\r
+       TAY\r
+\r
+       LDX     OFFPLAY2\r
+       LDA     XVELL+24,X\r
+       STA     TEMP+1\r
+       LDA     XVELH+24,X\r
+       LSR\r
+       ROR     TEMP+1\r
+       LSR\r
+       ROR     TEMP+1\r
+       LSR\r
+       ROR     TEMP+1\r
+       LSR\r
+       ROR     TEMP+1\r
+\r
+       LDA     YVELL+24,X\r
+       STA     TEMP+2\r
+       LDA     YVELH+24,X\r
+       LSR\r
+       ROR     TEMP+2\r
+       LSR\r
+       ROR     TEMP+2\r
+       LSR\r
+       ROR     TEMP+2\r
+       LSR\r
+       ROR     TEMP+2\r
+\r
+XTHRUST:\r
+       LDA     MAXVECT,Y\r
+       BPL     POSOXVEL\r
+\r
+NEGOXVEL:\r
+       LDX     TEMP+1\r
+       BPL     ADDXVEL\r
+       CMP     TEMP+1\r
+       BCC     ADDXVEL\r
+       BCS     DODAMPX\r
+\r
+POSOXVEL:\r
+       LDX     TEMP+1\r
+       BMI     ADDXVEL\r
+       CMP     TEMP+1\r
+       BCS     ADDXVEL\r
+\r
+DODAMPX:\r
+       JSR     DAMPX\r
+       JMP     YTHRUST\r
+\r
+ADDXVEL:\r
+       LDA     UNITVECT,Y\r
+       ASL\r
+       ASL\r
+       ASL\r
+       LDX     OFFPLAY2\r
+       CLC\r
+       ADC     XVELL+24,X\r
+       STA     XVELL+24,X\r
+       LDA     XVELH+24,X\r
+       ADC     HUNTVECT,Y\r
+       STA     XVELH+24,X\r
+\r
+YTHRUST:\r
+       TYA\r
+       CLC\r
+       ADC     #$10\r
+       TAY\r
+\r
+       LDA     MAXVECT,Y\r
+       BPL     POSOYVEL\r
+\r
+NEGOYVEL:\r
+       LDX     TEMP+2\r
+       BPL     ADDYVEL\r
+       CMP     TEMP+2\r
+       BCC     ADDYVEL\r
+       BCS     DODAMPY\r
+\r
+POSOYVEL:\r
+       LDX     TEMP+2\r
+       BMI     ADDYVEL\r
+       CMP     TEMP+2\r
+       BCS     ADDYVEL\r
+\r
+DODAMPY:\r
+       JSR     DAMPY\r
+       JMP     CHKFIRE\r
+\r
+ADDYVEL:\r
+       LDA     UNITVECT,Y\r
+       ASL\r
+       ASL\r
+       ASL\r
+       LDX     OFFPLAY2\r
+       CLC\r
+       ADC     YVELL+24,X\r
+       STA     YVELL+24,X\r
+       LDA     YVELH+24,X\r
+       ADC     HUNTVECT,Y\r
+       STA     YVELH+24,X\r
+       JMP     CHKFIRE\r
+\r
+\r
+DNSHOT:\r
+       LDA     MODE\r
+       CMP     #1              ;MODE - 1\r
+       BPL     TDNSHOT         ;MODES 1 AND 2 USE TDNSHOT\r
+       LDX     #3\r
+NEXTSHOT:\r
+       LDA     STATUS+28,X\r
+       BMI     THISSHOT\r
+       DEX\r
+       BPL     NEXTSHOT\r
+       RTS\r
+\r
+TDNSHOT:\r
+       LDX     PLAYER          ;ALLOW 2 SHOTS PER\r
+       BEQ     TPLAY1          ;PLAYER1 GETS 0 & 1\r
+       LDX     #2              ;PLAYER2 GETS 2 & 3\r
+TPLAY1:\r
+       LDA     STATUS+28,X\r
+       BMI     THISSHOT\r
+       INX\r
+       LDA     STATUS+28,X\r
+       BMI     THISSHOT\r
+       RTS\r
+\r
+THISSHOT:\r
+       LDY     PLAYER\r
+       LDA     SHIPDIR,Y\r
+       LSR\r
+       LSR\r
+       LSR\r
+       LSR\r
+       TAY\r
+       LDA     #SHOT\r
+       STA     STATUS+28,X\r
+       LDA     #$EC\r
+       STA     SHOTCNT+2,X\r
+       STX     TEMP            ;SAVE X\r
+       LDX     OFFPLAY2\r
+       LDA     XPOSH+24,X\r
+       LDX     TEMP            ;RESTORE\r
+       CLC\r
+       ADC     SHNOSEX,Y\r
+       CMP     #XPOSMAX\r
+       BCC     SHXOK\r
+       SBC     #XPOSMAX\r
+SHXOK:\r
+       STA     XPOSH+28,X\r
+       LDX     OFFPLAY2\r
+       LDA     YPOSH+24,X\r
+       LDX     TEMP            ;RESTORE\r
+       CLC\r
+       ADC     SHNOSEY,Y\r
+       CMP     #YPOSMAX\r
+       BCC     SHYOK\r
+       SBC     #YPOSMAX\r
+SHYOK:\r
+       STA     YPOSH+28,X\r
+       LDX     OFFPLAY2\r
+       LDA     XPOSL+24,X\r
+       LDX     TEMP\r
+       STA     XPOSL+28,X\r
+       LDX     OFFPLAY2\r
+       LDA     YPOSL+24,X\r
+       LDX     TEMP\r
+       STA     YPOSL+28,X\r
+\r
+       LDA     UNITVCTX,Y\r
+       LDX     OFFPLAY2\r
+       CLC\r
+       ADC     XVELH+24,X\r
+       LDX     TEMP\r
+       STA     XVELH+28,X\r
+       LDX     OFFPLAY2\r
+       LDA     XVELL+24,X\r
+       LDX     TEMP\r
+       STA     XVELL+28,X\r
+\r
+       LDA     UNITVCTY,Y\r
+       LDX     OFFPLAY2\r
+       CLC\r
+       ADC     YVELH+24,X\r
+       LDX     TEMP\r
+       STA     YVELH+28,X\r
+       LDX     OFFPLAY2\r
+       LDA     YVELL+24,X\r
+       LDX     TEMP\r
+       STA     YVELL+28,X\r
+\r
+       LDA     #$0E            ;LOAD SOUND FOR HERO SHOTS\r
+       JSR     DOTUNE1\r
+\r
+       LDX     PLAYER\r
+       LDA     #1\r
+       STA     FIRESTAT,X\r
+       RTS\r
+\r
+\r
+HYPERSPC:\r
+       LDX     PLAYER          ;WHICH PLAYER\r
+       LDA     STATE,X         ;STATE OF PLAYER\r
+       BNE     NOHYPER         ;IF OK THEN CONTINUE\r
+       LDA     #2              ;STATE FOR HYPERSPACE\r
+       STA     STATE,X\r
+       LDA     #$2C            ;$29+3\r
+       STA     TIMER,X\r
+NOHYPER:\r
+       RTS\r
+\r
+DAMPX:\r
+       LDX     OFFPLAY2\r
+       LDA     XVELL+24,X      ;IS VELOCITY ALREADY ZERO?\r
+       ORA     XVELH+24,X      ; (LOW *OR* HIGH IS CHEAP MAGNITUDE)\r
+       BEQ     DAMPXRTS        ;YES: NO DAMPING NEEDED\r
+\r
+       ;COMPUTE XVEL * 3/256\r
+       LDA     XVELL+24,X      ;FIRST COMPUTE XVEL/128\r
+       ASL\r
+       STA     TEMP+1\r
+       LDA     XVELH+24,X\r
+       ROL                     ;ROL IN THE CARRY BIT\r
+       STA     TEMP\r
+       LDA     XVELL+24,X      ;THEN ADD IN XVEL / 256\r
+       CLC\r
+       ADC     TEMP+1\r
+       STA     TEMP+1\r
+       LDA     XVELH+24,X\r
+       BPL     XHPOS\r
+       INC     XVELH+24,X      ;BORROW TO CORRECT SBC #0 BELOW\r
+XHPOS:\r
+       ADC     TEMP\r
+       STA     TEMP\r
+\r
+       LDX     PLAYER\r
+       LDA     XVELLL,X        ;ADJUST THE "NOISE" BYTE\r
+       SEC\r
+       SBC     TEMP+1\r
+       STA     XVELLL,X\r
+\r
+       LDX     OFFPLAY2\r
+       LDA     XVELL+24,X\r
+       SBC     TEMP\r
+       STA     XVELL+24,X\r
+       LDA     XVELH+24,X\r
+       SBC     #0\r
+       STA     XVELH+24,X\r
+\r
+       LDA     #0\r
+       STA     CLAMP\r
+       LDA     XVELH+24,X      ;CLAMP OFF TO STOP DRIFT\r
+       BEQ     ZCKPOSX\r
+       CLC\r
+       ADC     #1\r
+       BNE     DAMPXRTS\r
+       LDA     XVELL+24,X      ;ZCKMINX\r
+       CMP     #(0-$20) & 255\r
+       BCC     DAMPXRTS\r
+       BCS     ZSETX0\r
+ZCKPOSX:\r
+       LDA     XVELL+24,X\r
+       CMP     #$20\r
+       BCS     DAMPXRTS\r
+ZSETX0:\r
+       LDA     #1\r
+       STA     CLAMP\r
+\r
+DAMPXRTS:\r
+       RTS\r
+\r
+DAMPY:\r
+       LDX     OFFPLAY2\r
+       LDA     YVELL+24,X      ;IS VELOCITY ALREADY ZERO?\r
+       ORA     YVELH+24,X      ; (LOW *OR* HIGH IS CHEAP MAGNITUDE)\r
+       BEQ     DAMPYRTS        ;YES: NO DAMPING NEEDED\r
+\r
+       ;COMPUTE YVEL * 3/256\r
+       LDA     YVELL+24,X      ;FIRST COMPUTE YVEL/128\r
+       ASL\r
+       STA     TEMP+1\r
+       LDA     YVELH+24,X\r
+       ROL                     ;ROL IN THE CARRY BIT\r
+       STA     TEMP\r
+       LDA     YVELL+24,X      ;THEN ADD IN YVEL / 256\r
+       CLC\r
+       ADC     TEMP+1\r
+       STA     TEMP+1\r
+       LDA     YVELH+24,X\r
+       BPL     YHPOS\r
+       INC     YVELH+24,X      ;BORROW TO CORRECT SBC #0 BELOW\r
+YHPOS:\r
+       ADC     TEMP\r
+       STA     TEMP\r
+\r
+       LDX     PLAYER\r
+       LDA     YVELLL,X        ;ADJUST THE "NOISE" BYTE\r
+       SEC\r
+       SBC     TEMP+1\r
+       STA     YVELLL,X\r
+\r
+       LDX     OFFPLAY2\r
+       LDA     YVELL+24,X\r
+       SBC     TEMP\r
+       STA     YVELL+24,X\r
+       LDA     YVELH+24,X\r
+       SBC     #0\r
+       STA     YVELH+24,X\r
+\r
+       LDA     YVELH+24,X      ;CLAMP OFF TO STOP DRIFT\r
+       BEQ     ZCKPOSY\r
+       CLC\r
+       ADC     #1\r
+       BNE     DAMPYRTS\r
+       LDA     YVELL+24,X      ;ZCKMINX\r
+       CMP     #(0-$20) & 255\r
+       BCC     DAMPYRTS\r
+       BCS     ZSETY0\r
+ZCKPOSY:\r
+       LDA     YVELL+24,X\r
+       CMP     #$20\r
+       BCS     DAMPYRTS\r
+ZSETY0:\r
+       LDA     CLAMP\r
+       BEQ     DAMPYRTS\r
+       LDA     #0\r
+       STA     XVELL+24,X\r
+       STA     XVELH+24,X\r
+       STA     YVELL+24,X\r
+       STA     YVELH+24,X\r
+\r
+DAMPYRTS:\r
+       RTS\r
+\r
+** ROUTINE TO CHECK THE JOYSTICK AND UPDATE SOFTWARE REGISTERS. **\r
+CKJOY:\r
+       LDA     SWCHA           ;GET VALUES FROM TIA\r
+       STA     SWCHAVAL        ;STORE IN SOFT REGISTERS\r
+\r
+       LDX     #1              ;DO PLAYERS 1 AND 0\r
+ZNXTRJ:\r
+       JSR     READJOY         ;READ HIS JOYSTICK\r
+       DEX\r
+       BPL     ZNXTRJ\r
+       LDA     FIREBUT1        ;PLAYER 0 FIRE BUTTON IS STARTBUT\r
+       STA     STARTBUT\r
+\r
+       LDA     GAMSTATE        ;CHECK IF IN AUTO PLAY STATE\r
+       CMP     #AUTOST\r
+       BNE     CKJOYRTS        ;NO.  DON'T DO RANDOM VIOLENCE\r
+\r
+PICKJOY:\r
+       LDA     #$FF            ;CLEAR ALL BUTTONS\r
+       STA     FIREBUT1\r
+       STA     FIREBUT2\r
+       STA     HYPBUT1\r
+       STA     HYPBUT2\r
+\r
+       LDA     FRMCNT          ;DON'T ALWAYS DO\r
+       AND     #$0C\r
+       BNE     CKJOYRTS\r
+       LDA     FRMCNT          ;ALTERNATE FIRING\r
+       LSR\r
+       AND     #1\r
+       TAX\r
+       LDA     #$7F\r
+       STA     FIREBUT1,X\r
+\r
+       JSR     NEWRAND         ;RANDOM SHIP MOVEMENT\r
+       AND     #$07\r
+       TAX\r
+       LDA     JOYVALS,X\r
+       STA     SWCHAVAL\r
+\r
+CKJOYRTS:\r
+       RTS\r
+\r
+* READJOY: READ JOYSTICK/BUTTONS.  ON ENTRY X = PLAYER.  Y IS TRASHED\r
+READJOY:\r
+       LDY     INPT4,X\r
+       BPL     GOTONE          ;IF BIT 7 IS LO, OLD-STYLE BUTTON HIT\r
+\r
+       LDA     ONEBUT          ;ARE WE ALREADY IN OLD-STYLE MODE?\r
+       AND     RJBITS,X\r
+       BNE     GOTONE2         ;YES.  GO RIGHT TO ONE-BUTTON HANDLER.\r
+\r
+       TXA                     ;OTHERWISE, COMPUTE INDEX INTO\r
+       ASL                     ; PADDLE PORTS, FOR PLAYER X,\r
+       TAY                     ; IN Y (X * 2)\r
+\r
+       LDA     INPT4A,Y        ;READ LEFT BUTTON\r
+       EOR     #$FF            ;INVERT THE SENSE!\r
+       STA     FIREBUT1,X\r
+       LDA     INPT4B,Y        ; RIGHT BUTTON\r
+       EOR     #$FF\r
+RJSTOREH:\r
+       STA     HYPBUT1,X\r
+\r
+RJRTS:\r
+       RTS\r
+\r
+       ;HERE ON OLD-STYLE SINGLE BUTTON JOYSTICK PRESS.\r
+GOTONE:\r
+       LDA     ONEBUT          ;TURN OFF TWO-PLAYER BIT IMMEDIATELY\r
+       ORA     RJBITS,X        ; TO AVOID BURNING OUT HARDWARE\r
+       STA     SWCHB\r
+       STA     ONEBUT          ;SAVE THE NEW VALUE\r
+GOTONE2:\r
+       STY     FIREBUT1,X      ;Y CONTAINS CONTENTS OF INPT4 NOW\r
+       LDA     #$FF\r
+       STA     HYPBUT1,X       ;CLEAR HYPERSPACE BUTTON\r
+       LDA     SWCHAVAL        ;CHECK JOYSTICK REGISTER\r
+       AND     JOYTBL,X        ; FOR THIS PLAYER'S\r
+       CMP     RJSBITS,X       ;  HYPERSPACE BIT\r
+       BNE     RJRTS           ;IF BIT NOT LO, THEN NO HYPERSPACE\r
+       LDA     #$7F            ;OTHERWISE, SET THE BIT LO\r
+       BNE     RJSTOREH        ;BNE = JMP\r
+\r
+\r
+RJBITS:\r
+       .DC.B   $04,$10         ;TWO-PLAYER MODE BITS PER PLAYER\r
+RJSBITS:\r
+       .DC.B   $D0,$0D         ;SOUTH JOYSTICK BITS PER PLAYER\r
+THRBITS:\r
+       .DC.B   $01,$10         ;NORTH BITS PER *OTHER* PLAYER\r
+JOYVALS:\r
+       .DC.B   $7F,$BF,$EF,$F7,$FB,$FE,$FF,$EE ;AUTOPLAY JOYSTICK VALUES\r
diff --git a/MAIN.S b/MAIN.S
new file mode 100644 (file)
index 0000000..18129e4
--- /dev/null
+++ b/MAIN.S
@@ -0,0 +1,603 @@
+*         2100    030784\r
+*\r
+*\r
+** MAIN.S **\r
+** ASTEROIDS FOR THE ATARI 3600 *\r
+** THIS FILE CONTAINS THE MAIN DRIVER. **\r
+       .ORG    $D000           ;MUST BE ON ODD (BLANK HOLY DMA) 4K PAG\r
+CODE:\r
+\r
+ASTEROID:\r
+       SEI                     ;AND AWAY WE GO.....\r
+       CLD\r
+\r
+       LDA     #$13            ;LOCK INTO MARIA MODE, base unit rom\r
+                               ; *AND* DISCHARGE PADDLE INPUT CAPS\r
+       STA     PTCTRL          ;STORE TO INPTCTRL\r
+\r
+       LDX     #$FF            ;SET UP THE STACK POINTER\r
+       TXS\r
+\r
+       LDX     #$60\r
+       STX     CTRL            ;OFF DMA\r
+\r
+       LDA     #$14            ;SET JOYSTICK DIRECTION REGISTER\r
+       STA     CTLSWB          ;TO SELECT TWO BUTTON MODE\r
+\r
+       LDA     #0\r
+       STA     BACKGRND        ;BLACK BACKGROUND\r
+       STA     OFFSET          ;FOR FUTURE EXPANSION\r
+       STA     SWCHB           ;SELECT TWO BUTTON MODE\r
+;\r
+       JSR     ZERORAM         ;ZERO OUT RAM\r
+\r
+       LDA     INTIM           ;SEED RANDOM PTRS FROM TIMER\r
+       AND     #31             ; ROUGHLY RANGE IT (NOTE: PTR1 MAY GO\r
+       STA     RANDPTR0        ; OUT OF RANGE HERE, BUT IT'S OK AS\r
+       CLC                     ; LONG AS PTR0 DOESN'T GO OUT OF RANGE)\r
+       ADC     #31             ;31 IS A GOOD NUMBER FOR THIS\r
+       STA     RANDPTR1\r
+\r
+       LDX     #54             ;DROP SOME CODE IN TO INIT RAND ARRAY\r
+DROPCODE:\r
+       LDA     CODE,X          ;CODE IS PRETTY RANDOM.\r
+       STA     RAND,X          ;AT LEAST OURS IS.\r
+       DEX\r
+       BPL     DROPCODE\r
+\r
+       LDA     #1              ;SET UP MODE/DIFF\r
+       STA     DIFF\r
+       STX     MODE\r
+*\r
+       JSR     HSCSUCK         ;SUCK IN HIGH SCORE, IF POSSIBLE\r
+       JSR     INITSCOR        ;INITIALIZE SCORES\r
+       JSR     LOADSTAR\r
+\r
+       LDA     #$00            ;UNLOCK DISCHARGE TRANSISTOR FROM\r
+       STA     $0001           ; PADDLE INPUT CAPS.\r
+\r
+\r
+       LDA     #TITLEST        ;INITIALIZE GAME STATE\r
+                               ;FALL THROUGH INTO....\r
+* PROGRAM DRIVER STATE CHANGER: JMP HERE WITH NEW GAME STATE IN AC.\r
+NEWDRVR:\r
+       STA     GAMSTATE\r
+       LDX     #$FF            ;MASH OUT THE STACK POINTER\r
+       TXS\r
+       INX                     ;INITIALIZE DTIMER\r
+;\r
+;      LDX     #0\r
+;\r
+       STX     DTIMER\r
+       STX     DTIMER+1\r
+       JSR     INITPALS        ;PUT UP STANDARD COLORS\r
+       JSR     CLEARTUN        ;CLEAR OUT ALL TUNES\r
+       JSR     NULLOBJS        ;NULL OUT ALL OBJECTS.\r
+       JSR     WAITLOAD        ;WAIT FOR LOADER TO UPDATE\r
+       JSR     INITDMA         ;BUILD DLLS FOR MARIA2\r
+                               ; AND STARTS DMA DURING VBLANK\r
+                               ;FALL THROUGH INTO....\r
+* PROGRAM DRIVER: NEEDED TO HANDLE THE VARIOUS PROGRAM STATES.\r
+DRIVER:\r
+       LDA     FRMCNT          ;INSURE THAT FRMCNT IS EVEN HERE\r
+       AND     #$FE\r
+       STA     FRMCNT\r
+\r
+       LDA     GAMSTATE        ; FRAME COUNT AIN'T INC'ED DURING HSC\r
+       CMP     #HSCST\r
+       BEQ     PASTINCF\r
+\r
+FRAMSYNC:\r
+       LDA     FRMCNT          ;MAKE SURE AT LEAST ONE FRAME HAS\r
+       SEC                     ; GONE BY SINCE LAST FRAME SYNCH.\r
+       SBC     LASTFRMC\r
+       CMP     #2\r
+       BCC     FRAMSYNC\r
+       LDA     FRMCNT\r
+       STA     LASTFRMC        ;UPDATE LAST FRAME COUNT\r
+\r
+PASTINCF:\r
+       INC     DTIMER+1        ;INCREMENT THE TWO BYTE TIMER\r
+       BNE     ZZNOINC9\r
+       INC     DTIMER\r
+ZZNOINC9:\r
+       JSR     CKJOY           ;GET FRESH JOYSTICK INPUTS.\r
+       JSR     CKBUTS          ;GET FRESH BUTTON INPUTS (DEBOUNCED).\r
+       JSR     TWINKLE         ;TWINKLE STARS ETC.\r
+\r
+       LDA     GAMSTATE        ;CHECK GAME STATE\r
+       CMP     #PLAYST         ;GAMEPLAY STATE\r
+       BEQ     PLAYD\r
+       CMP     #AUTOST         ;AUTO PLAY STATE\r
+       BEQ     AUTOD\r
+       CMP     #MENUST         ;MENU STATE\r
+       BEQ     MENUD\r
+       CMP     #TITLEST        ;TITLE STATE\r
+       BEQ     TITLED\r
+       CMP     #HSCST          ;HIGH SCORE CART STATE\r
+       BEQ     HSCD\r
+\r
+       BNE     DRIVER          ;SAFETY TO PREVENT GOING ASTRAY\r
+                               ;NOT NEEDED IF WORKS PROPERLY SINCE\r
+                               ;MUST BE IN ONE OF THE ABOVE STATES.\r
+\r
+** DRIVER DISPACHER ROUTINES. **\r
+\r
+** TITLE PAGE STATE DISPACHER - HANDLES TIMING DURING TITLE PAGE. **\r
+TITLED:\r
+       LDA     FIREBUT2\r
+       BMI     HESDEAD\r
+       LDX     #$FF\r
+       STX     TURKEY\r
+       DEX\r
+       STX     CHICKEN\r
+HESDEAD:\r
+       LDA     SWCHBITS\r
+       AND     #$08\r
+       BEQ     JIM\r
+       LDA     SWCHA\r
+       ORA     CHICKEN\r
+       AND     TURKEY\r
+       STA     TURKEY\r
+       SEC\r
+       ROL     CHICKEN\r
+       CMP     #$F0\r
+       BNE     JIM\r
+       JMP     GO4IT\r
+JIM:\r
+\r
+       LDA     DTIMER         ;CHECK TIMER\r
+;\r
+;      CMP     #TITLEONT           ;TIME TO TURN TITLE ON?\r
+;\r
+       BNE     ZCKTOFF\r
+       JSR     ONTITLE       ;YES\r
+       JSR     CLSCORE       ;TAKE OFF THE SCORES\r
+ZSEEJOY:\r
+       JSR     SEEJOY\r
+       BCC     DRIVER         ;BCC = JMP\r
+\r
+ZCKTOFF:\r
+       CMP     #TITLEOFT\r
+       BNE     ZSEEJOY\r
+       JMP     DOHSC           ;FROM TITLE TO HSC\r
+\r
+** AUTO STATE DISPACHER. **\r
+AUTOD:\r
+       LDA     DTIMER\r
+       CMP     #AUTOOFFT           ;DONE WITH AUTO PLAY YET?\r
+       BNE     AUTOGO\r
+MENUTOUT:\r
+       JMP     DOTITLE       ;COME HERE AFTER AUTO OR MENU TIME OUT\r
+AUTOGO:\r
+       JSR     GAMELOOP\r
+       JSR     SEEJOY\r
+       JMP     DRIVER\r
+\r
+\r
+** HIGH SCORE CART DISPATCHER.\r
+HSCD:\r
+       JSR     HSCSHOW         ;PUT UP ONE TABLE\r
+       LDX     TEMP            ;ADVANCE TO NEXT ENTRY\r
+       INX\r
+       CPX     #12             ;12 ENTRIES\r
+       BCS     OVERHSC\r
+       STX     TEMP\r
+       TAX                     ;TEST AC BITS:\r
+       BNE     HSCD             ; IF AC NON-ZERO, THEN TRY AGAIN\r
+       JSR     SEEJOY         ;CHECK FOR USER ACTIONS.\r
+       JMP     DRIVER\r
+\r
+OVERHSC:\r
+       JMP     DOAUTO         ;FROM HSC TO AUTOPLAY\r
+\r
+\r
+** PLAY STATE DISPATCHER. **\r
+\r
+PLAYD:\r
+       JSR     GAMELOOP             ;DO ONE TIME THRU GAME PLAY\r
+\r
+       JSR     SEEPAUZ       ;CHANGE TO PAUSE IF PAUSE BUT. HIT\r
+       JSR     SEEBUTS\r
+       JMP     DRIVER\r
+\r
+\r
+** MENU STATE DISPATCHER. **\r
+MENUD:\r
+       LDA     DTIMER\r
+       CMP     #MENUOFFT\r
+       BEQ     MENUTOUT             ;MENU TIMED OUT\r
+\r
+       JSR     SELCHK         ;READ SELECT INPUT, SET MODES\r
+\r
+       JSR     ONTITLE       ;PUT UP THE LOGO\r
+\r
+       ;PUT UP DIFFICULTY LEVEL ICON\r
+       LDX     #10\r
+       TXA\r
+       CLC\r
+       ADC     DIFF\r
+       TAY\r
+       JSR     DOICON\r
+\r
+       ;PUT UP MODE ICON\r
+       LDX     #11\r
+       LDA     #15\r
+       CLC\r
+       ADC     MODE\r
+       TAY\r
+       JSR     DOICON\r
+\r
+       ;PUT UP SCORES\r
+       JSR     DOSCORE\r
+\r
+       ;NULL OUT BOTH SHIP ICONS\r
+       LDA     #$FF\r
+       STA     STATUS+12\r
+       STA     STATUS+13\r
+       ;PUT UP SHIP ICONS\r
+       LDX     #12\r
+       LDY     #22\r
+       LDA     MODE\r
+       BMI     MENU1PL       ;ONE PLAYER\r
+       INY\r
+       LDA     MODE\r
+       BEQ     MENU2PL       ;TWO PLAYER INDIVIDUAL\r
+       CMP     #2\r
+       BNE     MENUTEAM\r
+MENUCOMP:\r
+       INY                     ;TWO PLAYER COMPETITION\r
+       INY\r
+MENUTEAM:\r
+       INY                     ;TWO PLAYER TEAM PLAY\r
+       INY\r
+MENU2PL:\r
+       JSR     DOICON\r
+       INY\r
+       INX\r
+MENU1PL:\r
+       JSR     DOICON\r
+\r
+       ;CHECK FOR START GAME BUTTONS\r
+       ;CAN'T USE SEEJOY HERE; DON'T WANT TO DO DOMENU, ETC.\r
+       LDA     INPT4\r
+       BPL     ZDOPLAYS             ;JOYSTICK BUTTON HIT\r
+       LDA     INPT4A\r
+       BMI     ZDOPLAYS\r
+       LDA     SWCHBITS\r
+       LSR\r
+       BCS     ZDOPLAYS             ;RESET  BUTTON HIT\r
+       JMP     DRIVER         ;NOTHING HIT: CONTINUE\r
+ZDOPLAYS:\r
+       JMP     DOPLAY\r
+\r
+\r
+***************************************\r
+** ROUTINES USED BY THE DISPATCHERS. **\r
+***************************************\r
+\r
+* ROUTINE TO PUT TITLE ON\r
+ONTITLE:\r
+       LDX     #9               ;PUT UP THE FIRST 10 ICONS\r
+       LDY     #9\r
+TITLELOP:\r
+       JSR     DOICON         ;PUT UP ICON Y IN SLOT X\r
+       DEY\r
+       DEX\r
+       BPL     TITLELOP\r
+\r
+       LDA     #$0E             ;CHANGE COLOR FOR NAME\r
+       STA     SOFTCOLR+9\r
+       LDA     #$07\r
+       STA     SOFTCOLR+11\r
+;         LDA     #$75          ;BACKGROUND BARS WILL BE CYCLED\r
+;         STA     SOFTCOLR+10\r
+\r
+       RTS\r
+\r
+** MENU SELECT ROUTINES **\r
+\r
+* CHECK THE PAUSE BUTTON: HANG OUT HERE IF PRESSED, AND PERFORM PAUSE STUFF\r
+SEEPAUZ:\r
+       LDA     SWCHBITS             ;CHECK PAUSE BUTTON\r
+       AND     #$08\r
+       BEQ     PAUZRTS\r
+\r
+       ;WE NOW PAUSE FOR STATION IDENTIFICATION...\r
+DOPAUZ:\r
+       LDA     #PAUZST       ;SHUT OFF TUNER ETC.\r
+       STA     GAMSTATE\r
+       LDA     #0\r
+       STA     AUDV0\r
+       STA     AUDV1\r
+       STA     DTIMER         ;RESET TIMER FOR VIDEO OUT\r
+       STA     DTIMER+1\r
+\r
+PAUZLOOP:\r
+       BIT     MSTAT           ;SYNCH\r
+       BMI     PAUZLOOP             ; WAIT 'TILL ON SCREEN\r
+;         BIT     MSTAT                ; PROTECT AGAINST FLAKEY MSTAT\r
+;         BMI     PAUZLOOP\r
+ZPOSLOOP:\r
+       BIT     MSTAT\r
+       BPL     ZPOSLOOP             ; WAIT 'TILL OFF SCREEN (IN VBLANK)\r
+;         BIT     MSTAT\r
+;         BPL     ZPOSLOOP\r
+\r
+       INC     DTIMER+1             ;BUMP TIMER\r
+       BNE     ZZNOINC7\r
+       INC     DTIMER\r
+       BMI     VIDOFF         ;TURN VIDEO OFF WHEN CLOCK ROLLS AROUND\r
+ZZNOINC7:\r
+       JSR     CKBUTS         ;CHECK PAUSE BUTTON\r
+       AND     #$08\r
+       BEQ     PAUZCKJY\r
+\r
+       ;PAUSE MODE IS OVER\r
+       LDA     #PLAYST\r
+       STA     GAMSTATE             ;RESTORE TUNER\r
+\r
+       LDA     #$40             ;TURN ON DMA\r
+       STA     CTRL\r
+\r
+PAUZRTS:\r
+       RTS\r
+\r
+PAUZCKJY:\r
+       LDA     SWCHA\r
+       EOR     #$FF\r
+       BNE     VIDON           ;TURN VIDEO ON WHEN JOYSTICK OR\r
+       LDA     INPT4           ; EITHER PLAYER'S BUTTONS ARE HIT.\r
+       AND     INPT5           ; (AND HI BITS, ACTIVE LO)\r
+       BPL     VIDON\r
+       JSR     SEEBUTS       ;CHECK FOR SELECT & RESET\r
+       BCC     PAUZLOOP             ;BCC = JMP\r
+\r
+\r
+VIDOFF:\r
+       LDA     #$60             ; 60 = STOP DMA\r
+       BNE     VIDSTOR       ; BNE = JMP\r
+\r
+VIDON:\r
+       LDA     #$40             ; 40 = START DMA\r
+VIDSTOR:\r
+       STA     CTRL\r
+       BNE     DOPAUZ         ; BNE = JMP\r
+\r
+* CHECK BUTTONS (PAUSE, RESET, SELECT) SAVING STATE FOR DEBOUNCING.\r
+*         SETS ONES IN EACH BIT OF SWCHBITS ON POSITIVE TRANSITIONS.\r
+CKBUTS:\r
+       LDX     SWCHB\r
+       TXA\r
+       EOR     SWCHBVAL             ;GET ALL BITS WHICH HAVE CHANGED\r
+       AND     SWCHBVAL\r
+       STA     SWCHBITS             ;SAVE OLD VALUES OF CHANGED BITS\r
+       STX     SWCHBVAL             ;SAVE NEW VALUES OF ALL BITS\r
+       RTS\r
+\r
+* CHECK JOYSTICK/BUTTONS ETC. FOR CHANGE OF STATE\r
+SEEJOY:\r
+       LDA     STARTBUT             ;CHECK FIRE BUTTON, NOT SET IN AUTOST\r
+                                ;NEEDED TO PREVENT GOING FROM AUTOST\r
+       BPL     DOPLAY\r
+       LDA     SWCHA           ;CHECK JOYSTICK MOTION\r
+       AND     #$F0\r
+       EOR     #$F0\r
+       BNE     DOMENU\r
+SEEBUTS:\r
+       LDA     SWCHBITS             ;CHECK SELECT AND RESET BUTTONS\r
+       LSR\r
+       BCS     DOPLAY\r
+       LSR\r
+       BCS     DOMENU\r
+       RTS\r
+\r
+       ;ENTER HSC STATE\r
+DOHSC:\r
+       LDA     #0               ;LOWEST GAME OPTION FOR HSC\r
+       STA     TEMP\r
+\r
+       LDA     #HSCST\r
+       JMP     NEWDRVR\r
+\r
+       ;ENTER MENU STATE\r
+DOMENU:\r
+       LDA     #SELDLY       ;DEBOUNCE SELECTER\r
+       STA     SELCNT\r
+\r
+       LDA     #0               ;CLEAR MENLEFT\r
+       STA     MENLEFT\r
+       STA     MENLEFT2\r
+       STA     MENLEFTC\r
+\r
+       LDA     #MENUST       ;JUMP INTO MENU STATE\r
+       JMP     NEWDRVR\r
+\r
+       ;ENTER PLAY STATE\r
+DOPLAY:\r
+       JSR     INITSCOR\r
+       JSR     INITPLAY\r
+       JSR     DOSCORE\r
+\r
+       LDA     #PLAYST       ;GOTO PLAY STATE NOW\r
+       JMP     NEWDRVR\r
+\r
+       ;ENTER TITLE PAGE STATE\r
+DOTITLE:\r
+       LDA     #TITLEST\r
+       JMP     NEWDRVR\r
+\r
+       ;ENTER AUTOPLAY STATE\r
+DOAUTO:\r
+       LDA     #0               ;CLEAR MENLEFT\r
+       STA     MENLEFT\r
+       STA     MENLEFT2\r
+       STA     MENLEFTC\r
+\r
+       JSR     DOSCORE\r
+\r
+       JSR     INITPLAY             ;INITIALIZE FOR GAMEPLAY\r
+       LDA     #AUTOST       ;BUT ITS AUTOPLAY\r
+       JMP     NEWDRVR\r
+\r
+SELCHK:\r
+       LDA     SWCHA           ;P1 JSTICK\r
+       AND     #$F0\r
+       EOR     #$F0\r
+       BNE     SELJOY\r
+       LDA     SWCHB           ;SELECT BUTTON\r
+       AND     #$02\r
+       BEQ     SELBUT\r
+       LDA     #0\r
+       STA     SELCNT\r
+       RTS\r
+\r
+SELBUT:\r
+       DEC     SELCNT\r
+       BPL     SELRTS\r
+       LDX     #SELDLY\r
+       STX     SELCNT\r
+\r
+       JSR     INCDIFF\r
+       BNE     SELRTS         ;INC WORKED OK\r
+       LDA     #MINDIFF             ;INC HAD NO EFFECT, WRAP AROUND\r
+       STA     DIFF\r
+       JSR     INCMODE\r
+       BNE     SELRTS         ;INC WORKED OK\r
+       LDA     #MINMODE\r
+       STA     MODE\r
+       BNE     SELCHNG       ;MINMODE = $FF HERE, SO BNE = JMP\r
+\r
+SELJOY:\r
+       DEC     SELCNT\r
+       BPL     SELRTS\r
+       LDX     #SELDLY\r
+       STX     SELCNT\r
+\r
+       ASL\r
+       BCS     INCDIFF\r
+       ASL\r
+       BCS     DECDIFF\r
+       ASL\r
+       BCS     DECMODE\r
+* FALL THROUGH TO...\r
+INCMODE:\r
+       LDX     MODE             ;INCREMENT GAMEPLAY MODE\r
+       CPX     #1               ;HACK: WE STOP AT 1\r
+       BEQ     SELRTS\r
+       INX                     ;BIGGER HACK: PUSH X INTO RANGE.\r
+       LDA     ZHACKMOD+2,X     ;BIGGEST HACK: TABLE LOOKUP NEXT MODE.\r
+       STA     MODE\r
+       BPL     SELCHNG\r
+\r
+INCDIFF:\r
+       LDA     DIFF             ;INCREMENT INITIAL GAME DIFFICULTY\r
+       CMP     #MAXDIFF\r
+       BEQ     SELRTS\r
+       INC     DIFF\r
+       BPL     SELCHNG\r
+\r
+DECDIFF:\r
+       LDA     DIFF             ;DECREMENT DIFFICULTY\r
+       CMP     #MINDIFF\r
+       BEQ     SELRTS\r
+       DEC     DIFF\r
+       BPL     SELCHNG\r
+\r
+DECMODE:\r
+       LDX     MODE            ;DECREMENT MODE\r
+       CPX     #MINMODE\r
+       BEQ     SELRTS\r
+       LDA     ZHACKMOD,X\r
+       STA     MODE\r
+\r
+SELCHNG:\r
+       LDA     #0              ;HOLD DRIVER CLOCK AT ZERO\r
+       STA     DTIMER\r
+       STA     DTIMER+1\r
+*\r
+       JSR     HSCSUCK         ;SUCK IN A NEW HIGH SCORE FOR THIS LVL\r
+       LDA     #17             ;JUST TO KNOCK OFF THE 'EQ' BIT\r
+SELRTS:\r
+       RTS\r
+\r
+ZHACKMOD:\r
+       .DC.B   $FF,2,0,2,17,1         ;TABLE OF "NEXT MODES" TO KLUDGE IN.\r
+\r
+GO4IT:\r
+       LDX     #8\r
+       LDY     #LARGE+$80\r
+ZSNARD:\r
+       STY     STATUS,X\r
+       LDA     PALTAB,X\r
+       STA     PALS,X\r
+       LDA     ELBOUND+2\r
+       STA     ACYC,X\r
+       DEX\r
+       BPL     ZSNARD\r
+STAY4IT:\r
+       LDA     FRMCNT\r
+       AND     #$03             ;EVERY 4\r
+       BNE     ZEATME\r
+       LDA     FRMCNT\r
+       PHA\r
+       LSR\r
+       STA     FRMCNT\r
+       JSR     EXPLODE\r
+       PLA\r
+       STA     FRMCNT\r
+ZEATME:\r
+       JSR     WAITLOAD\r
+       LDA     #114\r
+       STA     YPOSH+9\r
+       LDA     #BEAG&255\r
+       STA     ACYC+9\r
+       LDA     #$4A\r
+       STA     PALS+9\r
+       JSR     LOGOBARS\r
+       JSR     CKJOY\r
+       JSR     CKBUTS\r
+       JSR     SEEJOY\r
+       BCC     STAY4IT       ;BCC = JMP\r
+\r
+\r
+* NMI HANDLER: HANDLES NMI'S GENERATED EACH FRAME BY MARIA AT END OF VISIBLE.\r
+NMI:\r
+       PHA                     ;SAVE STATE\r
+       TXA\r
+       PHA\r
+       TYA\r
+       PHA\r
+\r
+       CLD\r
+\r
+       LDA     NMICTRL       ;SEE IF WE ARE DOING HISCORE CART LOGO\r
+       BEQ     NMIHNDL       ; NO.  DO NORMAL HANDLER\r
+       bne     NMIOVER         ;br always  1-Sept-88 *** Dave ***\r
+*      STA     CTRL             ; YES. SET READ MODE BITS OF CTRL\r
+       EOR     #$03             ;      INVERT THE BITS\r
+       STA     NMICTRL\r
+       AND     #$03             ;      IF <> 0 (ENTERING VBLANK)\r
+       BNE     NMIINCFR             ;        BUMP FRAME COUNT\r
+       JSR     HSCSETRS             ;SET UP HSC REGISTERS (REFRESH COLORS)\r
+       JMP     NMIOVER\r
+\r
+NMIHNDL:\r
+       LDA     FRMCNT\r
+       LSR\r
+       BCC     NOLOAD         ;EVERY OTHER FRAME, DON'T CALL LOADER\r
+       JSR     LOADER\r
+NOLOAD:\r
+       JSR     TUNER           ;DO TUNES\r
+NMIINCFR:\r
+       INC     FRMCNT         ;BUMP FRAME COUNT\r
+       JSR     REFRESH       ;REFRESH OUR COLORS\r
+\r
+NMIOVER:\r
+       PLA                     ;RESTORE STATE\r
+       TAY\r
+       PLA\r
+       TAX\r
+       PLA\r
+IRQ:\r
+       RTI                     ;VECTOR IRQ'S TO THIS LABEL\r
diff --git a/MARIA.S b/MARIA.S
new file mode 100644 (file)
index 0000000..beb2f61
--- /dev/null
+++ b/MARIA.S
@@ -0,0 +1,245 @@
+       .6502\r
+       .SUBTTL "MARIA EQUATES -- ATARI CONFIDENTIAL"\r
+*************************************************************************\r
+*      THIS DOCUMENT CONTAINS CONFIDENTIAL PROPRIETARY INFORMATION     *\r
+*      OF ATARI WHICH MAY NOT BE COPIED, DISCLOSED, OR USED EXCEPT     *\r
+*      AS EXPRESSLY AUTHORIZED IN WRITING BY ATARI.                    *\r
+*************************************************************************\r
+*\r
+*      MEMORY MAP USAGE OF THE 7800\r
+*\r
+*      00-1F           TIA REGISTERS\r
+*      20-3F           MARIA REGISTERS\r
+*      40-FF           ZERO PAGE RAM\r
+*      100-13F         SHADOW OF TIA AND MARIA REGISTERS -- USED FOR \r
+*                      PUSHING ACCUMULATOR ONTO REGISTERS\r
+*      140-1FF         RAM (STACK)\r
+*      200-27F         NOT USED\r
+*      280-2FF         PIA PORTS AND TIMERS\r
+*      300-17FF        NOT USED\r
+*      1800-203F       RAM\r
+*      2040-20FF       SHADOW OF ZERO PAGE RAM\r
+*      2100-213F       RAM\r
+*      2140-21FF       SHADOW OF STACK RAM\r
+*      2200-27FF       RAM\r
+*      2800-3FFF       DUPLICATION OF ADDRESS SPACE 2000-27FF\r
+*      4000-FF7F       UNUSED ADDRESS SPACE\r
+*      FF80-FFF9       RESERVED FOR ENCRYPTION\r
+*      FFFA-FFFF       6502 VECTORS\r
+*\r
+       .org    0\r
+TIA:   ds.b    1       ;BASE ADDRESS FOR TIA CHIP\r
+\r
+PTCTRL:        ds.b    1       ;INPUT PORT CONTROL ("VBLANK" IN TIA )\r
+       ds.b    6\r
+*\r
+*   AFTER INITIALIZING SWCHB AS FOLLOWS:\r
+*\r
+*      LDA  #$14\r
+*      STA  CTLSWB\r
+*      LDA  #0\r
+*      STA  SWCHB\r
+*\r
+*   ...LEFT AND RIGHT FIRE BUTTONS CAN BE READ FROM THE FOLLOWING 4 LOCATIONS:\r
+*\r
+*                         THESE ARE ALSO USED FOR PADDLE INPUT\r
+INPT4B:        ds.b    1       ;PLAYER 0, RIGHT FIRE BUTTON (D7=1 WHEN PUSHED)\r
+INPT4A:        ds.b    1       ;PLAYER 0, LEFT FIRE BUTTON  (D7=1 WHEN PUSHED)\r
+INPT5B:        ds.b    1       ;PLAYER 1, RIGHT FIRE BUTTON (D7=1 WHEN PUSHED)\r
+INPT5A:        ds.b    1       ;PLAYER 1, LEFT FIRE BUTTON  (D7=1 WHEN PUSHED)\r
+*\r
+*   LEFT OR RIGHT FIRE BUTTONS READ FROM THESE LOCATIONS:\r
+*\r
+INPT4: ds.b    1       ;PLAYER 0 FIRE BUTTON INPUT (D7=0 WHEN PUSHED)\r
+INPT5: ds.b    1       ;PLAYER 1 FIRE BUTTON INPUT (D7=0 WHEN PUSHED)\r
+       ds.b    7\r
+*\r
+AUDC0: ds.b    1       ;AUDIO CONTROL CHANNEL 0\r
+AUDC1: ds.b    1       ;AUDIO CONTROL CHANNEL 1\r
+AUDF0: ds.b    1       ;AUDIO FREQUENCY CHANNEL 0\r
+AUDF1: ds.b    1       ;AUDIO FREQUENCY CHANNEL 1\r
+AUDV0: ds.b    1       ;AUDIO VOLUME CHANNEL 0\r
+AUDV1: ds.b    1       ;AUDIO VOLUME CHANNEL 1\r
+;\r
+;******************************************************************************\r
+;\r
+       .org    $20\r
+*\r
+MARIA:                         ;BASE ADDRESS FOR MARIA CHIP\r
+\r
+BKGRND:                                ;BACKGROUND COLOR\r
+BACKGRND:      ds.b    1       ;synonym used by GCC\r
+P0C1:          ds.b    1       ;PALETTE 0 - COLOR 1\r
+P0C2:          ds.b    1       ;          - COLOR 2\r
+P0C3:          ds.b    1       ;          - COLOR 3\r
+WSYNC:         ds.b    1       ;WAIT FOR SYNC\r
+P1C1:          ds.b    1       ;PALETTE 1 - COLOR 1\r
+P1C2:          ds.b    1       ;          - COLOR 2\r
+P1C3:          ds.b    1       ;          - COLOR 3\r
+MSTAT:         ds.b    1       ;MARIA STATUS\r
+P2C1:          ds.b    1       ;PALETTE 2 - COLOR 1\r
+P2C2:          ds.b    1       ;          - COLOR 2\r
+P2C3:          ds.b    1       ;          - COLOR 3\r
+DPPH:          ds.b    1       ;DISPLAY LIST LIST POINT HIGH BYTE\r
+P3C1:          ds.b    1       ;PALETTE 3 - COLOR 1\r
+P3C2:          ds.b    1       ;          - COLOR 2\r
+P3C3:          ds.b    1       ;          - COLOR 3\r
+DPPL:          ds.b    1       ;DISPLAY LIST LIST POINT LOW BYTE\r
+P4C1:          ds.b    1       ;PALETTE 4 - COLOR 1\r
+P4C2:          ds.b    1       ;          - COLOR 2\r
+P4C3:          ds.b    1       ;          - COLOR 3\r
+CHARBASE:      ds.b    1       ;CHARACTER BASE ADDRESS\r
+P5C1:          ds.b    1       ;PALETTE 5 - COLOR 1\r
+P5C2:          ds.b    1       ;          - COLOR 2\r
+P5C3:          ds.b    1       ;          - COLOR 3\r
+OFFSET:                ds.b    1       ;FOR FUTURE EXPANSION HERE - STORE ZER0 HERE\r
+P6C1:          ds.b    1       ;PALETTE 6 - COLOR 1\r
+P6C2:          ds.b    1       ;          - COLOR 2\r
+P6C3:          ds.b    1       ;          - COLOR 3\r
+CTRL:          ds.b    1       ;MARIA CONTROL REGISTER\r
+P7C1:          ds.b    1       ;PALETTE 7 - COLOR 1\r
+P7C2:          ds.b    1       ;          - COLOR 2\r
+P7C3:          ds.b    1       ;          - COLOR 3\r
+*\r
+*      PIA AND TIMER (6532) LOCATIONS\r
+*\r
+       .ORG    $280\r
+*\r
+SWCHA: .DS.B   1       ;LEFT & RIGHT JOYSTICKS\r
+*\r
+*      LEFT RITE\r
+*      7654 3210       ;BIT POSITION (=0 IF SWITCH IS CLOSED)\r
+*      ---- ----\r
+*      RLDU RLDU       ;RIGHT/LEFT/DOWN/UP\r
+*\r
+CTLSWA:        .DS.B   1       ;SWCHA DATA DIRECTION (0=INPUT)\r
+*\r
+SWCHB: .DS.B   1       ;CONSOLE SWITCHES\r
+*\r
+*      D7-RITE DIFFICULTY\r
+*      D6-LEFT DIFFICULTY\r
+*      D5/D4 NOT USED\r
+*      D3-PAUSE\r
+*      D2-NOT USED\r
+*      D1-GAME SELECT\r
+*      D0-GAME RESET\r
+*\r
+CTLSWB:        .DS.B   1       ;SWCHB DATA DIRECTION (0=INPUT)\r
+*\r
+INTIM: .DS.B   1       ;INTERVAL TIMER READ\r
+       .DS.B   15\r
+TIM1T: .DS.B   1       ;SET 1    CLK INTERVAL (838   NSEC/INTERVAL)\r
+TIM8T: .DS.B   1       ;SET 8    CLK INTERVAL (6.7   USEC/INTERVAL)\r
+TIM64T:        .DS.B   1       ;SET 64   CLK INTERVAL (53.6  USEC/INTERVAL)\r
+T1024T:        .DS.B   1       ;SET 1024 CLK INTERVAL (858.2 USEC/INTERVAL)\r
+       .DS.B   6\r
+TIM64TI:\r
+       .DS.B   1       ;INTERRUPT TIMER 64T\r
+*\r
+*\r
+*\r
+*\r
+RESET  =       1       ;bits for consle switches\r
+SELECT =       2\r
+PAUSE  =       8\r
+\r
+RAM1   =       $1800   ;FIRST SEGMENT OF MEMORY MINUS THE ZP,STACK, AND CHIPS\r
+RAM2   =       $2100   ;FIRST SEGMENT OF MEMORY MINUS THE ZP,STACK, AND CHIPS\r
+RAM3   =       $2200   ;FIRST SEGMENT OF MEMORY MINUS THE ZP,STACK, AND CHIPS\r
+R1SIZE =       ($2040-RAM1)    ;SIZE OF THE RAM1 BLOCK\r
+R2SIZE =       ($2140-RAM2)    ;SIZE OF THE RAM2 BLOCK\r
+R3SIZE =       ($2800-RAM3)    ;SIZE OF THE RAM3 BLOCK\r
+\r
+       .subttl "system macros 7800"\r
+*********************************************************\r
+*      MARIA MACROS FOR EASIER GRAPHICS CONSTRUCTION   *\r
+*********************************************************\r
+*\r
+*\r
+*this macro constructs a 4 byte header for display lists\r
+*\r
+       .macro  header  address,palette,width,hpos\r
+       dc.b    \address & $ff\r
+       dc.b    (\palette*$20) | ($1f & -\width)\r
+       dc.b    \address >> 8\r
+       dc.b    \hpos\r
+       .endm\r
+;\r
+;this macro constructs a 5 byte header for display lists\r
+;\r
+       .macro  xheader address,palette,width,hpos,wm,ind\r
+\r
+       dc.b    \address & $ff\r
+       dc.b    ((\wm*$80) | $40 | (\ind*$20))\r
+       dc.b    \address >> 8\r
+       dc.b    ((\palette*$20) | ($1F & -\width))\r
+       dc.b    \hpos\r
+       .endm\r
+\r
+;\r
+;this macro constructs a end-of-display-list header\r
+;\r
+       .macro  nullhdr\r
+\r
+       dc.b    0,0\r
+       .endm\r
+\r
+;\r
+;this macro constructs a display list entry for the display list list\r
+;\r
+       .macro  display dli,h16,h8,offset,address\r
+\r
+       dc.b    ((\dli*$80) | (\h16*$40) | (\h8*$20) | \offset)\r
+       dc.b    \address >> 8\r
+       dc.b    \address & $ff\r
+       .endm\r
+\r
+;\r
+;this macro loads a palette register with a color\r
+;\r
+       .macro  paint   palnum,colornum,color,lum\r
+\r
+       lda     #(\color*$10) | \lum\r
+       sta     \bkgrnd | ((\palnum*4) | (\colornum))\r
+       .endm\r
+\r
+;\r
+;this macro writes to the crtl register\r
+;\r
+ckoff  =       $0      ;normal color\r
+ckon   =       $1      ;kill the color\r
+\r
+dmaoff =       $3      ;turn off dma\r
+dmaon  =       $2      ;normal dma\r
+\r
+char1b =       $0      ;one byte character definition\r
+char2b =       $1      ;two byte character definition\r
+\r
+bcoff  =       $0      ;black border\r
+bcback =       $1      ;background colored border\r
+\r
+kangoff        =       $0      ;transparency\r
+kangon =       $1      ;"kangaroo" mode : no transparency!\r
+\r
+mode1  =       $0      ;160x2 or 160x4 modes\r
+modebd =       $2      ;320b or 320d modes\r
+modeac =       $3      ;320a or 320c modes\r
+\r
+       .macro  screen  ck,dma,cw,bc,km,mode\r
+       lda     #((\ck*$80) | (\dma*$20) | (\cw*$10) | (\bc*8) | (\km*4)|\mode)\r
+       sta     CTRL\r
+       .endm\r
+\r
+       .macro  dppload adr\r
+       lda     #\adr & $ff\r
+       sta     DPPL\r
+       sta     sdppl\r
+       lda     #\adr >> 8\r
+       sta     DPPH\r
+       sta     sdpph\r
+       .endm\r
+\r
+;********************************************************\r
+;      end of the system macros definitions            *\r
+;********************************************************\r
+\r
diff --git a/MARIAOS.S b/MARIAOS.S
new file mode 100644 (file)
index 0000000..f46c5a8
--- /dev/null
+++ b/MARIAOS.S
@@ -0,0 +1,1243 @@
+       .TITLE  "Decryption Rom O.S."\r
+       .6502\r
+\r
+\r
+;      MARIAOS MARIA DATA LOCATION DEFINITIONS\r
+\r
+;      NOTE THE FOLLOWING WIERD THINGS ABOUT THE RAM:\r
+;      000-03F <=> 0100-013F\r
+;      080-0FF <=> 0180-01FF\r
+;      040-0FF <=> 02040-020FF\r
+;      0140-01FF <=> 02140-021FF\r
+\r
+;      TIA REGISTERS\r
+INPTCTRL       =       $01     ;INPUT CONTROL\r
+INPT4  =       $0C     ;BITS 7 PLAYER 0 BUTTON\r
+INPT5  =       $0D     ;BITS 7 PLAYER 1 BUTTON\r
+AUDC0  =       $15     ;BITS   3210 AUDIO CONTROL 0\r
+AUDC1  =       $16     ;BITS   3210 AUDIO CONTROL 1\r
+AUDF0  =       $17     ;BITS   43210 AUDIO FREQUENCY 0\r
+AUDF1  =       $18     ;BITS   43210 AUDIO FREQUENCY 1\r
+AUDV0  =       $19     ;BITS   3210 AUDIO VOLUME 0\r
+AUDV1  =       $1A     ;BITS   3210 AUDIO VOLUME 1\r
+VSYNC  =       $00     ;BIT    1       VERTICAL SYNC SET-CLR\r
+VBLANK =       $01     ;BIT    1       VERTICAL BLANK SET-CLR\r
+TWSYNC =       $02     ;STROBE WAIT FOR HORIZ BLANK\r
+RSYNC  =       $03     ;STROBE RESET HORIZ SYNC COUNTER\r
+COLUP0 =       $06     ;BITS 7654321   COLOR(4)-LUM(3) PLAYER 0\r
+COLUP1 =       $07     ;BITS 7654321   COLOR(4)-LUM(3) PLAYER 1\r
+COLUPF =       $08     ;BITS 7654321   COLOR(4)-LUM(3) PLAYFIELD\r
+COLUBK =       $09     ;BITS 7654321   COLOR(4)-LUM(3) BACKGROUND\r
+PF2    =       $0F     ;BITS ALL       PLAYFIELD REG BYTE 2\r
+RESP0  =       $10     ;STROBE RESET PLAYER 0\r
+RESP1  =       $11     ;STROBE RESET PLAYER 1\r
+GRP0   =       $1B     ;BITS ALL       GRAPHICS FOR PLAYER 0\r
+GRP1   =       $1C     ;BITS ALL       GRAPHICS FOR PLAYER 1\r
+CXCLR  =       $2C     ;STROBE CLEAR ALL COLLISION LATCHES\r
+CXP0FB =       $32\r
+CXP1FB =       $33\r
+\r
+;      MARIA REGISTERS\r
+BACKGRND       =       $20     ;BACKGROUND COLOR\r
+P0C1   =       $21     ;PALETTE 0, COLOR 1\r
+P0C2   =       $22     ;PALETTE 0, COLOR 2\r
+P0C3   =       $23     ;PALETTE 0, COLOR 3\r
+WSYNC  =       $24     ;FAST MARIA WSYNC STROBE        WO\r
+P1C1   =       $25     ;PALETTE 1, COLOR 1\r
+P1C2   =       $26     ;PALETTE 1, COLOR 2\r
+P1C3   =       $27     ;PALETTE 1, COLOR 3\r
+MSTAT  =       $28     ;BIT 6 IN VBLANK, BIT ? IN DISPLAY      RO\r
+P2C1   =       $29     ;PALETTE 2, COLOR 1\r
+P2C2   =       $2A     ;PALETTE 2, COLOR 2\r
+P2C3   =       $2B     ;PALETTE 2, COLOR 3\r
+DPPH   =       $2C     ;DISPLAY LIST POINTER HIGH      WO\r
+P3C1   =       $2D     ;PALETTE 3, COLOR 1\r
+P3C2   =       $2E     ;PALETTE 3, COLOR 2\r
+P3C3   =       $2F     ;PALETTE 3, COLOR 3\r
+DPPL   =       $30     ;DISPLAY LIST POINTER LOW       WO\r
+P4C1   =       $31     ;PALETTE 4, COLOR 1\r
+P4C2   =       $32     ;PALETTE 4, COLOR 2\r
+P4C3   =       $33     ;PALETTE 4, COLOR 3\r
+CHARBASE       =       $34     ;CHARACTER MODE HIGH POINTER    WO\r
+P5C1   =       $35     ;PALETTE 5, COLOR 1\r
+P5C2   =       $36     ;PALETTE 5, COLOR 2\r
+P5C3   =       $37     ;PALETTE 5, COLOR 3\r
+OFFSET =       $38     ;NOT USED ******\r
+P6C1   =       $39     ;PALETTE 6, COLOR 1\r
+P6C2   =       $3A     ;PALETTE 6, COLOR 2\r
+P6C3   =       $3B     ;PALETTE 6, COLOR 3\r
+CTRL   =       $3C     ;BIT 7 CHARACTER WIDTH, BIT 6 BCNT      WO\r
+P7C1   =       $3D     ;PALETTE 7, COLOR 1\r
+P7C2   =       $3E     ;PALETTE 7, COLOR 2\r
+P7C3   =       $3F     ;PALETTE 7, COLOR 3\r
+\r
+;      FREE RAM - 040-0FF\r
+\r
+;      ALIASED RAM - 0100-013F\r
+\r
+;      STACK - 0140-01FF\r
+\r
+;      6532 TIMERS AND PORTS\r
+\r
+SWCHA  =       $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  =       $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 =       $281\r
+CTLSWB =       $283\r
+INTIM  =       $284    ;INTERVAL TIMER IN\r
+TIM8T  =       $295    ;TIMER 8T WRITE OUT\r
+TIM64T =       $296    ;TIMER 64T WRITE OUT\r
+TIM64TI        =       $29E    ;INTERRUPT TIMER 64T\r
+\r
+\r
+;      ENDEF.S ENCRYPTION SYMBOL DEFINITIONS\r
+;      ADDRESS DEFINITIONS\r
+\r
+;      PAGE 0 - 0080-00FF ($40-07F TAKEN BY A REGISTER)\r
+\r
+TEST0  =       $C0     ;TEST DATA FOR CPU TEST\r
+TEST1  =       $C1\r
+TESTW0 =       $C2     ;2 BYTES\r
+TESTW1 =       $C4     ;2 BYTES\r
+\r
+TEMP0  =       $D0     ;SCRATCH DATA FOR PROGRAM USE\r
+TEMP1  =       $D1     ;MORE SCRATCH DATA\r
+TEMP2  =       $D2     ;MORE SCRATCH DATA\r
+TEMP3  =       $D3     ;MORE SCRATCH DATA\r
+TEMP4  =       $D4     ;MORE SCRATCH DATA\r
+TEMP5  =       $D5     ;MORE SCRATCH DATA\r
+\r
+STARTA =       $E0     ;WHERE ACCUMULATOR STARTS\r
+OFFSETA        =       $E1     ;OFFSET INTO ACCUMULATOR\r
+OFFSETR        =       $E2     ;OFFSET INTO A REGISTER\r
+SIZEA  =       $E3     ;SIZE OF ACCUMULATOR\r
+SIZER0 =       $E4     ;SIZE OF REGISTER 0\r
+SIZER1 =       $E5     ;SIZE OF REGISTER 1\r
+SIZER3 =       $E6     ;SIZE OF REGISTER 3\r
+SIZER5 =       $E7     ;SIZE OF REGISTER 5\r
+\r
+CARTBOTM       =       $EE     ;BOTTOM OF CARTRIDGE ADDRESS\r
+FUJICOLR       =       $EF     ;STARTING COLOR FOR FUJI-A\r
+\r
+KNLSTATE       =       $F0     ;HOW MANY MORE ITERATIONS TILL KERNEL\r
+KNLCOUNT       =       $F1     ;TIMER FOR CHANGING FUJI COLOR\r
+KNLTIME                =       $F2     ;TIME THAT COUNT IS GOOD FOR\r
+KNLOFSET       =       $F3     ;HOW STAGGERED THE FUJI COLOR IS\r
+\r
+DLIADDR        =       $F4     ;SAME ADDRESS AS IN PACK-IN\r
+\r
+;      HIGH RAM - 01800-027FF\r
+\r
+ACC    =       $1800   ;256 BYTE ACCUMULATOR\r
+REG0   =       $1900   ;128 BYTE REGISTER\r
+REG2   =       $1A00   ;128 BYTE REGISTER\r
+REG4   =       $1B00   ;128 BYTE REGISTER\r
+REG6   =       $1C00   ;128 BYTE REGISTER\r
+REG8   =       $1D00   ;128 BYTE REGISTER\r
+REG10  =       $1E00   ;128 BYTE REGISTER\r
+REG12  =       $1F00   ;128 BYTE REGISTER\r
+\r
+RAMGRAPH       =       $1984   ;GRAPHICS IN RAM, 019XX-$1EXX\r
+RAMDLL =       $1F84   ;DLL\r
+\r
+REG1   =       $2000   ;128 BYTE REGISTER\r
+\r
+;      ***** HOLE FROM 02040 TO 020FF - SHADOWED IN PAGE 0 *****\r
+\r
+REG14  =       $2100   ;128 BYTE REGISTER (OVERLAPS PART OF S)\r
+\r
+;      ***** HOLE FROM 02140 TO 021FF SHADOWED IN PAGE 1 *****\r
+\r
+;      DISPLAY LIST RAM\r
+\r
+RAMDLIST       =       $2200   ;RAM FOR DLISTS FOR WORDS AND FUJI-A\r
+\r
+;      MEMORY LOCATIONS FOR CODE, BEFORE AND AFTER MOVING\r
+\r
+ROMCD  =       $F400   ;WHERE DROPPED CODE LIVES\r
+ROMCD2 =       $F880   ;WHERE NON-DROPPED CODE IS\r
+RAMCODE        =       $2300   ;AREA RESERVED FOR CODE\r
+CODEDIF        =       ROMCD-RAMCODE   ;DIFFERENCE BETWEEN OLD AND NEW ADDRESS\r
+\r
+\r
+;      ENCRYPTION CONSTANTS\r
+\r
+STACKPTR       =       $FF     ;WHERE STACK IS ON PAGE 1\r
+\r
+REGION =       $FE     ;MASK FOR COUNTRY\r
+\r
+RANDBYTE       =       $04     ;RANDOM BYTE IN CHECKSUM\r
+\r
+;NTGAME        =       $D804   ;INTERNAL GAME ROM START LOCATION\r
+;NTDLI =       $D800   ;INTERNAL GAME DLI HANDLER\r
+INTDLI =       $F000   ;OUR DLI\r
+\r
+\r
+;      SCAFFOLD.S\r
+;      THIS DOES THE DISPATCHING WHENEVER THE PACK-IN ISN'T AROUND\r
+\r
+       .org    INTDLI\r
+\r
+       PHA\r
+       JMP     (DLIADDR)\r
+\r
+\r
+;      CART.S  ROUTINES DEALING WITH CHECKING THE CARTRIDGE OUT\r
+\r
+       .org    ROMCD\r
+\r
+NOCART:        JMP     LOCK2600-CODEDIF        ;NO INTERNAL CART\r
+\r
+BADCART:\r
+       JMP     LOCK2600-CODEDIF        ;CART DOES NOT CHECK, DO 2600 MODE\r
+\r
+CARTTEST:\r
+       LDA     #$16    ;TURN EXTERNAL CART ON\r
+       STA     INPTCTRL\r
+\r
+       LDY     #$FF\r
+       LDX     #$7F    ;SEE IF A CART PLUGGED IN\r
+CTSTLOOP:\r
+       LDA     $FE00,X\r
+       CMP     $FD80,Y\r
+       BNE     NOCART\r
+       DEY\r
+       DEX\r
+       BPL     CTSTLOOP        ;X LEFT = FF, Y LEFT = 7F\r
+\r
+       LDA     $FFFC   ;SEE IF START AT FFFF\r
+       AND     $FFFD\r
+       CMP     #$FF\r
+       BEQ     NOCART  ;ALL LINES DRAWN HIGH, NO CART\r
+       LDA     $FFFC   ;SEE IF START AT 0000\r
+       ORA     $FFFD\r
+       BEQ     NOCART  ;ALL LINES DRAWN LOW, NO CART\r
+\r
+       LDA     $FFF8   ;CHECK FOR REGION VERIFICATION\r
+       ORA     #REGION\r
+       CMP     #$FF\r
+       BNE     BADCART\r
+       LDA     $FFF8   ;TOP 4 BITS OF FFF8 SHOULD BE 0F0\r
+       EOR     #$F0\r
+       AND     #$F0\r
+       BNE     BADCART\r
+       LDA     $FFF9   ;SEE IF MARIA SIGNATURE EXISTS\r
+       AND     #$0B    ;0X7 OR 0X3 VALID\r
+       CMP     #$03\r
+       BNE     BADCART\r
+       LDA     $FFF9   ;GET BOTTOM OF CART ADDRESS\r
+       AND     #$F0\r
+       STA     CARTBOTM\r
+\r
+\r
+*      .include        "decrypt.s"\r
+\r
+;      VECTOR.S        WE HAVE DETERMINED VALIDITY, VECTOR TO CART IN 2600 OR\r
+;      3600 MODE\r
+\r
+\r
+SETMARIA:\r
+       LDX     #$16    ;PUT CART IN 3600 MODE, CART ON\r
+       STX     INPTCTRL\r
+       TXS\r
+       SED\r
+       JMP     ($FFFC) ;VECTOR INTO THE CART IN 3600 MODE\r
+\r
+\r
+LOCK2600:\r
+       LDA     #$02\r
+       STA     INPTCTRL        ;TURN SECURITY ROM ON\r
+       LDX     #$7F    ;LOCK CART IN 2600 MODE, CART ON\r
+L2LOOP:\r
+       LDA     SYNC,X  ;MOVE CODE TO RAM\r
+       STA     $480,X  ;MOVE INTO 6532 RAM\r
+       DEX\r
+       BPL     L2LOOP\r
+       JMP     $480    ;AND EXECUTE OUT OF RAM\r
+; First zero out TIA without doing a TWSYNC. This must be done in a loop that\r
+; counts up so that graphics are turned off before the collision registers are\r
+; cleared. RSYNC should turn case C into a case A. Note also that the stores\r
+; of zero puts the system in TIA space but does not lock it there. This code\r
+; must all run out of 6532 RAM since the memory map will change as we change\r
+; mode.        The 6532 RAM exists in all memory maps.\r
+SYNC:\r
+       LDA     #0\r
+       TAX\r
+       STA     VBLANK\r
+ZEROLP:\r
+       STA     RSYNC,X\r
+       INX\r
+       CPX     #(CXCLR-RSYNC+1)\r
+       BNE     ZEROLP\r
+\r
+; Test now for a possible E case. In some E cases, TWSYNCs do not work properly\r
+; and this must be detected. In an E case failure, the LDA is prefetched and\r
+; the 04 following it is skipped over and NOP ($EA) is loaded into A causing\r
+; the branch on minus to be taken. If this happens the E case can now be\r
+; corrected.   NOTE: All E cases do not get trapped here and must be handled\r
+; latter by collisions.\r
+       STA     TWSYNC\r
+       LDA     #4\r
+       NOP\r
+       BMI     ECASE\r
+\r
+; Position player 0 on the left side of the screen and player 1 on the right\r
+; side of the screen so that they will overlap (or not overlap as the case may\r
+; be) playfield 2 that has a copy on both sides of the screen. Resets occur at\r
+; the 38th and 65th cycle.\r
+       LDX     #4\r
+STALL4:\r
+       DEX                             ;Stall loop\r
+       BPL     STALL4\r
+       TXS                             ;Set the stack to 0FF for stall JSRs\r
+       STA     RESP0+$100              ;38th cylce\r
+       JSR     DUMMY+1-SYNC+$480       ;12 cycle stall\r
+       JSR     DUMMY+1-SYNC+$480       ;Ditto\r
+       STA     RESP1   ;65th cycle\r
+\r
+; Turn on graphics to cause the collisions\r
+       STA     GRP0    ;68th cycle\r
+       STA     GRP1    ;71st cycle\r
+       STA     PF2     ;74th cycle\r
+\r
+; Stall an entire scan line to allow collisions to take place. The E case test\r
+; should follow all TWSYNCs to be safe.\r
+       NOP             ;76th cycle\r
+       STA     TWSYNC  ;3rd cycle\r
+       LDA     #0\r
+       NOP\r
+       BMI     ECASE\r
+\r
+; Test now for a collision between player 1 and playfield.     If there is no\r
+; collision, we must shift the clock once. If there is a collision, we must\r
+; do further testing.\r
+       BIT     CXP1FB-$30\r
+       BMI     NOCOL1\r
+\r
+; This section shifts the clock once.  Storing a 2 switches the system into\r
+; MARIA MODe and the following store to 0FXXX causes a clock speed-up for one\r
+; cycle and thus shifts the clock once.\r
+ECASE:\r
+       LDA     #2\r
+       STA     COLUBK  ;changes to MARIA MODe\r
+       STA     $F112\r
+       BNE     DONE    ;JMP\r
+\r
+; Test now for a collision between player 0 and playfield.     If there is no\r
+; collision, we must shift the clock twice. If there is a collision, we must\r
+; do further testing.\r
+NOCOL1:\r
+       BIT     CXP0FB-$30\r
+       BMI     NOCOL0\r
+\r
+; This section shifts the clock twice. Storing a 2 switches the system into\r
+; MARIA MODe and the following stores to 0FXXX causes two clock speed-ups for\r
+; one cycle and thus shifts the clock twice.\r
+       LDA     #2\r
+       STA     COLUP0  ;changes to MARIA MODe\r
+       STA     $F118\r
+DUMMY:\r
+       STA     $F460   ;Note that the 060 is a RTS\r
+       BNE     DONE\r
+\r
+; If we've fotten to this point the only possible failure left is an E case that\r
+; was not detected by the TWSYNC trap. Test for this by clearing the collision\r
+; registers, shifting the graphics for player 0 to the left one pixel by\r
+; changing GRP0 from a 4 to an 8, and then retesting for a collision.  If there\r
+; is still a collision between player 0 and the playfield, we have an E case,\r
+; otherwise we are done. Be careful not to test for collisions until after they\r
+; occur (about the 40th cycle).\r
+NOCOL0:\r
+       STA     CXCLR                   ;21st cycle\r
+       LDA     #8                      ;23rd cycle - one pixel to the left\r
+       STA     GRP0                    ;26th cycle\r
+       JSR     DUMMY+1-SYNC+$480       ;12 cycle stall\r
+       NOP                             ;40th cycle - just to be safe\r
+       BIT     CXP0FB-$30              ;43rd cycle\r
+       BMI     ECASE\r
+\r
+; We are now synced and should lock ourselves into TIA mopde with the external\r
+; cart enabled and jump to the reset vector.   Thanks for stopping by...\r
+DONE:\r
+       LDA     #$FD\r
+       STA     COLUPF  ;Change MODes to TIA with EXT and lock.\r
+       JMP     ($FFFC)\r
+\r
+\r
+NROM:\r
+       NOP     ;END OF FIRST PART OF ROM\r
+\r
+;      TESTS.S RAM AND CPU TESTS - IF EITHER ARE BAD, DECRYPTION WILL FAIL,\r
+;      THUS, THESE MUST BE TESTED FIRST\r
+\r
+; ***** NOTE: ***** THE FOLLOWING INSTRUCTIONS ARE NOT TESTED BY THE CPU TEST,\r
+;      AND THUS SHOULD NOT BE USED IN THE VALIDATION/DECRYPTION CODE:\r
+;      BRK, RTI, PLP, PHP, CLV, SEV, BVC, BVS, CLD, SED, BIT, SEI, CLI\r
+\r
+\r
+;      TEST FAILURE MODES\r
+BADCPU         =       $00     ;CPU ERROR\r
+BAD16A         =       $01     ;ERROR IN RAM 02000-$27FF\r
+BAD16B         =       $02     ;ERROR IN RAM 01800-$1FFF\r
+BADRAM         =       $03     ;CAN'T GET TO ANY OF THE RAM\r
+BADMARIA       =       $04     ;MARIA SHADOWING NOT WORKING\r
+BADVALID       =       $05     ;BAD VALIDATION OR DECRYPTION\r
+\r
+\r
+       .org    ROMCD2\r
+\r
+FATAL0:\r
+       LDA     #$1D    ;THERE HAS BEEN SOMETHING BAD FOUND\r
+       STA     INPTCTRL        ;LOCK IN 2600 MODE, TEST CART WILL FIND\r
+\r
+MAIN:\r
+       SEI     ;INITIALIZE\r
+       CLD\r
+\r
+       LDA     #$02    ;PUT BASE UNIT INTO MARIA ENABLE\r
+       STA     INPTCTRL\r
\r
+       LDA     #ENDDLI >> 8    ;WESTBERG SUX\r
+       STA     DLIADDR+1       ;WESTBERG SUX\r
+       LDA     #$ff & ENDDLI   ;WESTBERG SUX\r
+       STA     DLIADDR ;WESTBERG SUX\r
+\r
+       LDA     #$7F\r
+       STA     CTRL    ;TURN OFF DMA\r
+       LDA     #$00\r
+       STA     BACKGRND        ;BACKGROUND COLOR TO BLACK\r
+\r
+\r
+; ***** RAM TESTS *****\r
+\r
+;      SIMPLE RAM TEST TO CHECK PAGES 02000 AND 02100 IS DONE FIRST TO GIVE US\r
+;      RAM TO TEST OUT THE CPU (SHADOWED TO PAGES 00000 AND 00100).    AFTER\r
+;      THE CPU TEST, A FULL RAM TEST IS DONE.\r
+\r
+;      EARLY RAM TEST, JUST CHECK OUT OUR TWO PAGES USING MINIMAL INSTRUCTIONS\r
+RAMCHECK:\r
+       LDX     #$05    ;TEST OUT 4 PATTERNS OF RAM\r
+RCAGAIN:\r
+       LDA     RAMPAT,X\r
+       LDY     #$00\r
+RCLOOP:\r
+       STA     $2000,Y ;CHECK ZERO PAGE\r
+       CMP     $2000,Y\r
+       BNE     CHKRAMB\r
+       STA     $2100,Y ;CHECK PAGE 1\r
+       CMP     $2100,Y\r
+       BNE     CHKRAMB\r
+       DEY\r
+       BNE     RCLOOP\r
+       DEX\r
+       BPL     RCAGAIN\r
+\r
+; SEE IF MARIA SHADOWING WORKS\r
+       LDA     #$43    ;A SIMPLE TEST TO SEE IF SHADOWING WORK\r
+       STA     $2080\r
+       CMP     $0080\r
+       BNE     MARIAERR\r
+       STA     $2180\r
+       CMP     $0180\r
+       BNE     MARIAERR\r
+\r
+       JMP     CPUTEST ;IF SHADOWING AND RAM WORKS, CHECK CPU\r
+\r
+\r
+; RAM FAILURE ROUTINES\r
+\r
+MARIAERR:\r
+       LDY     #BADMARIA       ;MARIA SHADOWING BAD\r
+       JMP     FATAL0\r
+\r
+CHKRAMB:\r
+       STA     $1800   ;RAMA HAS FAILED IN SIMPLE TEST, CHECK\r
+       CMP     $1800   ;       TO SEE IF ANY RAM WORKS\r
+       BNE     RAMERR\r
+\r
+RAMAERR:\r
+       LDY     #BAD16A ;BAD RAM CHIP - 02000-$27FF\r
+       JMP     FATAL0\r
+\r
+RAMBERR:\r
+       LDY     #BAD16B ;BAD RAM CHIP - 01800-$1FFF\r
+       JMP     FATAL0\r
+\r
+RAMERR:\r
+       LDY     #BADRAM ;ALL RAM BAD - COULD BE ANOTHER PROBLEM\r
+       JMP     FATAL0\r
+\r
+\r
+;      A FULL RAM TEST, TO BE DONE AFTER THE CPU TEST SUCEEDS\r
+\r
+RAMTEST:\r
+       LDA     #$00    ;SET UP STATE TO MARCH THROUGH RAM\r
+       STA     $F0     ;(F0) = 02000\r
+       STA     $F2     ;(F2) = 01800\r
+       LDY     #$07    ;NUMBER OF PAGES TO CHECK\r
+       STY     $F4\r
+\r
+RTPAGE:\r
+       LDA     RAMAPAGE,Y      ;SET UP RAM A PAGE TO CHECK\r
+       STA     $F1\r
+       LDA     RAMBPAGE,Y      ;SET UP RAM B PAGE TO CHECK\r
+       STA     $F3\r
+       LDX     #$05    ;NUMBER OF RAM PATTERNS TO CHECK\r
+\r
+RTPAT:\r
+       LDA     RAMPAT,X        ;GET RAM PATTERN\r
+       LDY     #$00    ;INITIALIZE INDEX\r
+\r
+RTLOOP:\r
+       STA     ($F0),Y ;CHECK RAM A\r
+       CMP     ($F0),Y\r
+       BNE     RAMAERR\r
+       STA     ($F2),Y ;CHECK RAM B\r
+       CMP     ($F2),Y\r
+       BNE     RAMBERR\r
+       DEY\r
+       BNE     RTLOOP\r
+\r
+       DEX\r
+       BPL     RTPAT\r
+\r
+       DEC     $F4     ;ONE LESS PAGE\r
+       LDY     $F4\r
+       BPL     RTPAGE\r
+       JMP     STARTVND        ;START THE VALIDATION AND DECRYPTION\r
+\r
+\r
+RAMPAT:\r
+       dc.b    $00,$FF,$55,$AA,$69,$0F ;PATTERNS FOR RAM TEST\r
+RAMAPAGE:\r
+       dc.b    $22,$23,$24,$25,$26,$27,$22,$23 ;HI BYTES OF RAM A PAGES\r
+RAMBPAGE:\r
+       dc.b    $18,$19,$1A,$1B,$1C,$1D,$1E,$1F ;HI BYTES OF RAM B PAGES\r
+\r
+\r
+\r
+; ***** CPU TESTS *****\r
+\r
+IRQINT:\r
+       ;IF WE GET AN IRQ, IT IS A CPU ERROR\r
+CPERR:\r
+       LDY     #BADCPU ;CPU ERROR\r
+       JMP     FATAL0\r
+\r
+; CPU TEST, METHODICALLY CHECK ALL INSTRUCTIONS, ADDRESSING MODES, AND STATUS\r
+;      BITS THAT THE DECRYPTION WILL BE USING\r
+\r
+CPUTEST:\r
+       LDA     #$AA    ;FIRST, TEST OUT LDA AND BRANCHING\r
+       BEQ     CPERR   ;CHECK BEQ FAIL\r
+       BPL     CPERR   ;CHECK BPL FAIL\r
+       BMI     CTA     ;CHECK BMI SUCCEED\r
+       JMP     CPERR\r
+CTA:\r
+       BNE     CTB     ;CHECK BNE SUCCEED\r
+       JMP     CPERR\r
+CTB:\r
+       STA     $AA     ;STORE IT AWAY, 0AA = AA\r
+       CMP     $AA     ;SEE IF IT ADDRESSES AND COMPARES\r
+       BNE     CPERR\r
+\r
+       LDA     #$00    ;TEST ALTERNATE POLARITY\r
+       BNE     CPERR   ;CHECK BNE FAIL\r
+       BMI     CPERR   ;CHECK BMI FAIL\r
+       BPL     CTC     ;CHECK BPL SUCCEED\r
+       JMP     CPERR\r
+CTC:\r
+       BEQ     CTD     ;CHECK BEQ SUCCEED\r
+       JMP     CPERR\r
+CTD:\r
+       CMP     #$00\r
+       BNE     CPERR   ;CHECK CMP EQ\r
+       BCC     CPERR   ;CHECK BCC FAIL\r
+       BCS     CTE     ;CHECK BCS SUCCEED\r
+       JMP     CPERR\r
+CTE:\r
+       CMP     #$01\r
+       BCS     CPERR   ;CHECK BCS FAIL\r
+       BCC     CTF     ;CHECK BCC SUCCEED\r
+       JMP     CPERR\r
+\r
+\r
+CTF:\r
+       LDX     #$55    ;TEST X AND Y, LOADS, STORES, AND COMP\r
+       CPX     #$56    ;CHECK CPX\r
+       BEQ     CPERR\r
+       STX     $1AA    ;CHECK STX - 01AA = 55\r
+       CPX     $1AA    ;CHECK CPX\r
+       BNE     CPERR\r
+       LDY     $AA     ;CHECK LDY, - Y = AA\r
+       CPY     #$AB\r
+       BEQ     CPERR\r
+       STY     $155    ;CHECK STY - 0155 = AA\r
+       CPY     $155    ;CHECK CPY\r
+       BNE     CPERR\r
+\r
+\r
+       DEX             ;CHECK TRANSFER DATA PATHS AND STACK\r
+       TXS             ;TO POINT TO 0155, S MUST BE 54\r
+       INX\r
+       PLA             ;S HAS 55, A = 0155 (= AA)\r
+       CMP     #$AA    ;TEST TXS AND PLA\r
+       BNE     CPERR0\r
+       TXA             ;A = 55\r
+       PHA             ;0155 = 55\r
+       CPX     $155    ;TEST TXA AND PHA\r
+       BNE     CPERR0\r
+       TYA             ;A = AA\r
+       CMP     #$AA    ;TEST TYA\r
+       BNE     CPERR0\r
+       TAX             ;X = AA\r
+       LDA     $100,X  ;NORM,X - A = 01AA (= 55)\r
+       TAY             ;Y = 55\r
+       CPY     #$55    ;TEST NORM,X, TAX, TAY\r
+       BNE     CPERR0\r
+\r
+\r
+       ;TEST ADDRESSING MODES (NORM,X DONE)\r
+       LDA     $00,X   ;ZP,X - A = 0AA (= AA)\r
+       CMP     $AA     ;ZP, TEST ZP AND ZP,X\r
+       BNE     CPERR0\r
+       CMP     #$AA    ;TEST ZP AND ZP,X\r
+       BNE     CPERR0\r
+       EOR     #$FF    ;A = 55\r
+       STA     $00,Y   ;ZP,Y - 055 = 55\r
+       CMP     $55\r
+       BNE     CPERR0\r
+       CMP     $100,Y  ;NORM,Y ($155)\r
+       BNE     CPERR0\r
+       CMP     $20AB,X ;NORM,Y W/WRAP ($155)\r
+       BNE     CPERR0\r
+\r
+       LDA     #$20    ;SET UP ADDR, TEST (IND,X), (IND),Y\r
+       STA     $F1\r
+       LDA     #$CC\r
+       STA     $F0     ;($F0) = 020CC (WHICH IS 0CC)\r
+       STA     ($F0-$AA,X)     ;(IND,X) - 0CC = CC\r
+       CMP     $CC\r
+       BNE     CPERR0\r
+       STA     ($F0),Y ;(IND),Y - 02121 = CC\r
+       CMP     $2121\r
+       BNE     CPERR0\r
+       LDA     #$ff & CTCONT   ;TEST (IND), ONLY JMP USES\r
+       STA     $F0\r
+       LDA     #CTCONT >> 8\r
+       STA     $F1\r
+       JMP     ($F0)   ;(IND)\r
+       JMP     CPERR0\r
+\r
+\r
+CPERR0:\r
+       JMP     CPERR   ;ANOTHER CPERR\r
+\r
+\r
+CTCONT:\r
+       LDA     #$55    ;TEST ADDER\r
+       CLC\r
+       ADC     #$55    ;55 + 55 = AA\r
+       NOP             ;NOP, MAKE SURE IT DOESN'T ALTER STATE\r
+       BCS     CPERR0\r
+       BPL     CPERR0\r
+       BEQ     CPERR0\r
+       CMP     #$AA\r
+       BNE     CPERR0\r
+;      SEC\r
+       ADC     #$55    ;AA + 55 + C = 0 + C\r
+       NOP             ;NOP, MAKE SURE IT DOESN'T ALTER STATE\r
+       BCC     CPERR0\r
+       BMI     CPERR0\r
+       BNE     CPERR0\r
+\r
+;      SEC     ;TEST SUBTRACT\r
+       SBC     #$55    ;0 - 55 = AB - C'\r
+       BCS     CPERR0\r
+       BPL     CPERR0\r
+       BEQ     CPERR0\r
+       CMP     #$AB\r
+       BNE     CPERR0\r
+       CLC\r
+       SBC     #$AA    ;AB - AA + C' = 0\r
+       BCC     CPERR0\r
+       BMI     CPERR0\r
+       BNE     CPERR0\r
+\r
+\r
+       LDA     #$FF    ;TEST OUT INCREMENTS AND DECREMENTS\r
+       TAX     ;X = FF\r
+       INX             ;TEST INX - X = 0\r
+       BNE     CPERR1\r
+       DEX             ;TEST DEX - X = FF\r
+       BEQ     CPERR1\r
+       BPL     CPERR1\r
+       CPX     #$FF\r
+       BNE     CPERR1\r
+       TAY             ;Y = FF\r
+       INY             ;TEST INY - Y = 0\r
+       BNE     CPERR1\r
+       DEY             ;TEST DEY - Y = FF\r
+       BEQ     CPERR1\r
+       INY             ;Y = 0\r
+       BNE     CPERR1\r
+       STA     $F0     ;0F0 = FF\r
+       INC     $F0     ;TEST INC - 0F0 = 0\r
+       BNE     CPERR1\r
+       CPY     $F0\r
+       BNE     CPERR1\r
+       DEC     $F0     ;TEST DEC - 0F0 - FF\r
+       BEQ     CPERR1\r
+       CMP     $F0\r
+       BNE     CPERR1\r
+\r
+\r
+       LDA     #$AA    ;TEST SHIFTS AND ROTATES - 10101010\r
+       CLC     ;C = 0\r
+       ROL             ;01010100, C=1\r
+       ROL             ;10101001, C=0\r
+       ROL             ;01010010, C=1\r
+       CMP     #$52    ;01010010\r
+       BNE     CPERR1\r
+\r
+;      SEC             ;C = 1\r
+       ROR             ;10101001, C=0\r
+       ROR             ;01010100, C=1\r
+       ROR             ;10101010, C=0\r
+       CMP     #$AA    ;10101010\r
+       BEQ     CTSHIFT\r
+\r
+\r
+CPERR1:\r
+       JMP     CPERR   ;ANOTHER CPERR\r
+\r
+\r
+CTSHIFT:\r
+       ASL             ;01010100, C=1\r
+       BCC     CPERR1\r
+       ASL             ;10101000, C=0\r
+       BCS     CPERR1\r
+       ASL             ;01010000, C=1\r
+       CMP     #$50\r
+       BNE     CPERR1\r
+\r
+       EOR     #$05    ;01010101\r
+       LSR             ;00101010, C=1\r
+       BCC     CPERR1\r
+       LSR             ;00010101, C=0\r
+       BCS     CPERR1\r
+       LSR             ;00001010, C=1\r
+       CMP     #$0A\r
+       BNE     CPERR1\r
+\r
+\r
+       LDA     #$55    ;TEST LOGICAL OPERATIONS\r
+       ORA     #$1B    ;TEST OR - A = 5F\r
+       CMP     #$5F\r
+       BNE     CPERR1\r
+       AND     #$55    ;A = 55\r
+       AND     #$1B    ;TEST AND - A = 11\r
+       CMP     #$11\r
+       BNE     CPERR1\r
+       ORA     #$55    ;A = 55\r
+       EOR     #$1B    ;TEST EOR\r
+       CMP     #$4E\r
+       BNE     CPERR1\r
+\r
+\r
+       JSR     CTJSR   ;GRAND FINALE, TEST JSR, S = 55\r
+CTJSRRET:\r
+       JMP     CPERR1  ;NO GOOD IF WE DIDN'T JSR\r
+\r
+CTJSR:\r
+       TSX             ;SEE WHERE STACK IS\r
+       CPX     #$52\r
+       BNE     CPERR1\r
+       PLA             ;GET RETURN ADDRESS\r
+       CMP     #$ff & (CTJSRRET-1)\r
+       BNE     CPERR1\r
+       PLA\r
+       CMP     #(CTJSRRET-1)>>8\r
+       BNE     CPERR1\r
+       LDA     #(RAMTEST-1)>>8 ;PUT START OF CODE AS RETURN ADDRESS\r
+       PHA\r
+       LDA     #$ff & (RAMTEST-1)\r
+       PHA\r
+       RTS             ;DO IT\r
+       JMP     CPERR1  ;AGAIN, NO GOOD IF WE DIDN'T DO IT\r
+\r
+\r
+;      KERNEL.S        DLI ROUTINES FOR THE SECURITY ROM\r
+\r
+;      OUR DLI HANDLER\r
+DLI:\r
+       TXA     ;STACK REGISTERS, A ALREADY STACKED\r
+       PHA\r
+\r
+       LDA     #$43\r
+       STA     CTRL\r
+       LDX     #$0F\r
+       LDA     FUJICOLR\r
+       STA     P0C2    ;INITIALIZE COLOR\r
+       BIT     KNLOFSET        ;FIGURE OUT STAGGERING\r
+       BVC     DFJMP1\r
+       BPL     DFJMP0\r
+DFLOOP:\r
+       STA     WSYNC   ;CHANGE COLOR ONCE PER THREE LINES\r
+DFJMP0:\r
+       STA     WSYNC   ;SECOND LINE\r
+DFJMP1:\r
+       STA     WSYNC   ;THIRD LINE\r
+       SEC             ;GET A NEW COLOR FOR THE NEXT LINE\r
+       SBC     #$10\r
+       CMP     #$10\r
+       BCS     DFNEXT\r
+       SBC     #$0F\r
+DFNEXT:\r
+       STA     P0C2    ;CHANGE COLORS\r
+       DEX\r
+       BPL     DFLOOP\r
+\r
+DLIATARI:\r
+       LDX     #$40    ;SET UP CTRL FOR ATARI WORDS\r
+       STX     CTRL\r
+\r
+       AND     #$F0\r
+       ORA     #$0E\r
+       STA     P1C3\r
+\r
+       LDA     FUJICOLR\r
+       AND     #$F0\r
+       ORA     #$06\r
+       STA     P1C1\r
+       AND     #$F0\r
+       CLC     ;ROTATE BAR COLOR\r
+       ADC     #$40\r
+       BCC     DLAJMP\r
+       ADC     #$0F\r
+DLAJMP:\r
+       ORA     #$03\r
+       STA     P1C2\r
+\r
+       DEC     KNLCOUNT        ;SEE IF TIME FOR A COLOR CHANGE YET\r
+       BPL     DLIDONE\r
+\r
+       LDA     KNLOFSET        ;SEE IF TIME TO STAGGER, OR CHANGE CLR\r
+       ADC     #$60\r
+       BCC     DLIOFSET\r
+       LDA     FUJICOLR        ;ROTATE FUJI COLOR\r
+       CLC\r
+       ADC     #$10\r
+       BCC     DLJMP0\r
+       ADC     #$0F\r
+DLJMP0:\r
+       STA     FUJICOLR\r
+       LDA     KNLTIME ;RESET TIMER\r
+       STA     KNLCOUNT\r
+\r
+       LDA     #$00\r
+DLIOFSET:\r
+       STA     KNLOFSET        ;UPDATE KERNAL STAGGERING CONTROL\r
+DLIDONE:\r
+       LDA     #$02    ;NOTE THAT WE HAVE DONE KERNEL\r
+       STA     KNLSTATE\r
+       PLA     ;UNSTACK REGISTERS\r
+       TAX\r
+ENDDLI:\r
+       PLA\r
+       RTI\r
+\r
+INFLOOP:\r
+       JMP     INFLOOP\r
+\r
+;      MAIN.S  MAIN ROUTINE FOR DECRYPTION CODE\r
+;      CALLED FROM ROUTINES IN TESTS.S\r
+\r
+STARTVND:\r
+       LDX     #STACKPTR\r
+       TXS     ;SET STACK POINTER\r
+\r
+       LDA     #0      ;ZERO THE TIA REGISTERS OUT\r
+       TAX\r
+TIA0LOOP:\r
+       STA     1,X\r
+       INX\r
+       CPX     #$2C\r
+       BNE     TIA0LOOP\r
+       LDA     #$02    ;BACK INTO MARIA MODE\r
+       STA     INPTCTRL\r
+\r
+;      THIS ROUTINE DROPS OUR CODE INTO RAM\r
+DROPRAM:\r
+       LDX     #$00    ;X = 0, DROP CODE AND GRAPHICS INTO RAM\r
+       STX     BACKGRND        ;PUT BACKGROUND TO BLACK\r
+\r
+DRLOOP:\r
+       LDA     ROMCD+$000,X    ;DROP CODE\r
+       STA     RAMCODE+$000,X\r
+       LDA     ROMCD+$100,X\r
+       STA     RAMCODE+$100,X\r
+       LDA     ROMCD+$200,X\r
+       STA     RAMCODE+$200,X\r
+       LDA     ROMCD+$300,X\r
+       STA     RAMCODE+$300,X\r
+       LDA     ROMCD+$400,X\r
+       STA     RAMCODE+$400,X\r
+       LDA     ROMDLIST,X      ;DROP DISPLAY LISTS\r
+       STA     RAMDLIST,X\r
+       CPX     #$00\r
+       BMI     DRLJMP0\r
+       LDA     ROMDLL,X        ;DROP DLL\r
+       STA     RAMDLL,X\r
+       LDA     RMGRP6,X        ;DROP GRAPHICS INTO HALF PAGE\r
+       STA     RAMGRAPH+$000,X\r
+       LDA     RMGRP5,X\r
+       STA     RAMGRAPH+$100,X\r
+       LDA     RMGRP4,X\r
+       STA     RAMGRAPH+$200,X\r
+       LDA     RMGRP3,X\r
+       STA     RAMGRAPH+$300,X\r
+       LDA     RMGRP2,X\r
+       STA     RAMGRAPH+$400,X\r
+       LDA     RMGRP1,X\r
+       STA     RAMGRAPH+$500,X\r
+DRLJMP0:\r
+       DEX\r
+       BNE     DRLOOP\r
+\r
+       JMP     (CARTTEST-CODEDIF)      ;START THE DECRYPTION\r
+\r
+\r
+;      TURN THE GRAPHICS ON\r
+GRPON:\r
+       LDA     $FFF9   ;SEE IF DISPLAY IS TO BE STARTED\r
+       AND     #$04\r
+       BEQ     STRTCRPT\r
+\r
+GRPON2:\r
+       LDA     #$03    ;SET UP KERNEL\r
+       STA     KNLCOUNT\r
+       STA     KNLTIME\r
+\r
+       LDA     #$49    ;SET COLORS\r
+       STA     FUJICOLR\r
+       LDA     #$66\r
+       STA     P1C1\r
+       LDA     #$56\r
+       STA     P1C2\r
+       LDA     #$2E\r
+       STA     P1C3\r
+\r
+       LDA     #$ff & DLI      ;SET DLI\r
+       STA     DLIADDR\r
+       LDA     #DLI >> 8\r
+       STA     DLIADDR+1\r
+\r
+SCRNOF:\r
+       BIT     MSTAT   ;IS VBLANK ENDED YET?\r
+       BMI     SCRNOF\r
+SCRNON:\r
+       BIT     MSTAT   ;IS VBLANK STARTED YET?\r
+       BPL     SCRNON\r
+\r
+       LDA     #$ff & RAMDLL\r
+       STA     DPPL    ;SET DPPL AND DPPH TO DLLIST\r
+       LDA     #RAMDLL >> 8\r
+       STA     DPPH\r
+       LDA     #$43\r
+       STA     CTRL    ;TURN GRAPHICS ON\r
+\r
+STRTCRPT:\r
+       RTS\r
+\r
+\r
+\r
+;      DISPLAY LISTS\r
+ROMDLIST:\r
+       .dc.b   $ff & (RAMGRAPH),$1F,RAMGRAPH >> 8,$BB,$00,$00\r
+RDL5BYTE:\r
+       .dc.b   $ff & (RAMGRAPH),$40,RAMGRAPH >> 8,$1F,$BB,$00,$00\r
+RDLFJ1:\r
+       .dc.b   $ff & (RAMGRAPH+RMFUJ1-ROMGRAPH),$1C,RAMGRAPH >> 8,$4A,$00,$00\r
+RDLFJ2:\r
+       .dc.b   $ff & (RAMGRAPH+RMFUJ2-ROMGRAPH),$1C,RAMGRAPH >> 8,$4A,$00,$00\r
+RDLFJ3:\r
+       .dc.b   $ff & (RAMGRAPH+RMFUJ3-ROMGRAPH),$1C,RAMGRAPH >> 8,$48,$00,$00\r
+RDLFJ4:\r
+       .dc.b   $ff & (RAMGRAPH+RMFUJ4-ROMGRAPH),$1B,RAMGRAPH >> 8,$46,$00,$00\r
+RDLFJ5:\r
+       .dc.b   $ff & (RAMGRAPH+RMFUJ5-ROMGRAPH),$19,RAMGRAPH >> 8,$42,$00,$00\r
+RDLFJ6:\r
+       .dc.b   $ff & (RAMGRAPH+RMFUJ6-ROMGRAPH),$17,RAMGRAPH >> 8,$3E,$00,$00\r
+RDLFJ7:\r
+       .dc.b   $ff & (RAMGRAPH+RMFUJ7-ROMGRAPH),$17,RAMGRAPH >> 8,$3E,$00,$00\r
+RDLRC:\r
+       .dc.b   $ff & (RAMGRAPH+ROMSTRIP-RMGRP3),$2C,(RAMGRAPH+$300)>>8,$00\r
+       .dc.b   $ff & (RAMGRAPH+ROMSTRIP-RMGRP3),$2C,(RAMGRAPH+$300)>>8,$50\r
+       .dc.b   $00,$00\r
+RDLRCL:\r
+       .dc.b   $ff & (RAMGRAPH+ROMSTRIP-RMGRP3),$2C,(RAMGRAPH+$400)>>8,$00\r
+       .dc.b   $ff & (RAMGRAPH+ROMSTRIP-RMGRP3),$2C,(RAMGRAPH+$400)>>8,$50\r
+       .dc.b   $00,$00\r
+RDLN01:\r
+       .dc.b   $ff & (RAMGRAPH+RMLIN1-ROMGRAPH),$2D,(RAMGRAPH+$000)>>8,$28\r
+       .dc.b   $00,$00\r
+RDLN02:\r
+       .dc.b   $ff & (RAMGRAPH+RMLIN2-ROMGRAPH),$2D,(RAMGRAPH+$000)>>8,$28\r
+       .dc.b   $00,$00\r
+RDLN03:\r
+       .dc.b   $ff & (RAMGRAPH+RMLIN3-ROMGRAPH),$2D,(RAMGRAPH+$000)>>8,$28\r
+       .dc.b   $00,$00\r
+RDLN04:\r
+       .dc.b   $ff & (RAMGRAPH+RMLIN4-ROMGRAPH),$2D,(RAMGRAPH+$000)>>8,$28\r
+       .dc.b   $00,$00\r
+RDLN05:\r
+       .dc.b   $ff & (RAMGRAPH+RMLIN1-ROMGRAPH),$2D,(RAMGRAPH+$100)>>8,$28\r
+       .dc.b   $00,$00\r
+RDLN06:\r
+       .dc.b   $ff & (RAMGRAPH+RMLIN2-ROMGRAPH),$2D,(RAMGRAPH+$100)>>8,$28\r
+       .dc.b   $00,$00\r
+RDLN07:\r
+       .dc.b   $ff & (RAMGRAPH+RMLIN3-ROMGRAPH),$2D,(RAMGRAPH+$100)>>8,$28\r
+       .dc.b   $00,$00\r
+RDLN08:\r
+       .dc.b   $ff & (RAMGRAPH+RMLIN4-ROMGRAPH),$2D,(RAMGRAPH+$100)>>8,$28\r
+       .dc.b   $00,$00\r
+RDLN09:\r
+       .dc.b   $ff & (RAMGRAPH+RMLIN1-ROMGRAPH),$2D,(RAMGRAPH+$200)>>8,$28\r
+       .dc.b   $00,$00\r
+RDLN10:\r
+       .dc.b   $ff & (RAMGRAPH+RMLIN2-ROMGRAPH),$2D,(RAMGRAPH+$200)>>8,$28\r
+       .dc.b   $00,$00\r
+RDLN11:\r
+       .dc.b   $ff & (RAMGRAPH+RMLIN3-ROMGRAPH),$2D,(RAMGRAPH+$200)>>8,$28\r
+       .dc.b   $00,$00\r
+\r
+\r
+;      DISPLAY LIST LIST\r
+ROMDLL:\r
+       dc.b    $0F,RAMDLIST >> 8,$ff & (RAMDLIST+RDL5BYTE-ROMDLIST)\r
+       dc.b    $0F,RAMDLIST >> 8,$ff & (RAMDLIST+$00)\r
+       dc.b    $0F,RAMDLIST >> 8,$ff & (RAMDLIST+$00)\r
+       dc.b    $0F,RAMDLIST >> 8,$ff & (RAMDLIST+$00)\r
+       dc.b    $03,RAMDLIST >> 8,$ff & (RAMDLIST+$00)\r
+       dc.b    $85,RAMDLIST >> 8,$ff & (RAMDLIST+RDLFJ1-ROMDLIST)      ;FUJI-A\r
+       dc.b    $05,RAMDLIST >> 8,$ff & (RAMDLIST+RDLFJ2-ROMDLIST)\r
+       dc.b    $05,RAMDLIST >> 8,$ff & (RAMDLIST+RDLFJ3-ROMDLIST)\r
+       dc.b    $05,RAMDLIST >> 8,$ff & (RAMDLIST+RDLFJ4-ROMDLIST)\r
+       dc.b    $05,RAMDLIST >> 8,$ff & (RAMDLIST+RDLFJ5-ROMDLIST)\r
+       dc.b    $05,RAMDLIST >> 8,$ff & (RAMDLIST+RDLFJ6-ROMDLIST)\r
+       dc.b    $05,RAMDLIST >> 8,$ff & (RAMDLIST+RDLFJ7-ROMDLIST)\r
+       dc.b    $0F,RAMDLIST >> 8,$ff & (RAMDLIST+$00)  ;CENTER SPACE\r
+       dc.b    $01,RAMDLIST >> 8,$ff & (RAMDLIST+RDLRC-ROMDLIST)       \r
+       dc.b    $00,RAMDLIST >> 8,$ff & (RAMDLIST+RDLN01-ROMDLIST)\r
+       dc.b    $02,RAMDLIST >> 8,$ff & (RAMDLIST+RDLRC-ROMDLIST)\r
+       dc.b    $00,RAMDLIST >> 8,$ff & (RAMDLIST+RDLN02-ROMDLIST)\r
+       dc.b    $02,RAMDLIST >> 8,$ff & (RAMDLIST+RDLRC-ROMDLIST)\r
+       dc.b    $00,RAMDLIST >> 8,$ff & (RAMDLIST+RDLN03-ROMDLIST)\r
+       dc.b    $02,RAMDLIST >> 8,$ff & (RAMDLIST+RDLRC-ROMDLIST)\r
+       dc.b    $00,RAMDLIST >> 8,$ff & (RAMDLIST+RDLN04-ROMDLIST)\r
+       dc.b    $02,RAMDLIST >> 8,$ff & (RAMDLIST+RDLRC-ROMDLIST)\r
+       dc.b    $00,RAMDLIST >> 8,$ff & (RAMDLIST+RDLN05-ROMDLIST)\r
+       dc.b    $02,RAMDLIST >> 8,$ff & (RAMDLIST+RDLRC-ROMDLIST)\r
+       dc.b    $00,RAMDLIST >> 8,$ff & (RAMDLIST+RDLN06-ROMDLIST)\r
+       dc.b    $02,RAMDLIST >> 8,$ff & (RAMDLIST+RDLRC-ROMDLIST)\r
+       dc.b    $00,RAMDLIST >> 8,$ff & (RAMDLIST+RDLN07-ROMDLIST)\r
+       dc.b    $02,RAMDLIST >> 8,$ff & (RAMDLIST+RDLRC-ROMDLIST)\r
+       dc.b    $00,RAMDLIST >> 8,$ff & (RAMDLIST+RDLN08-ROMDLIST)\r
+       dc.b    $02,RAMDLIST >> 8,$ff & (RAMDLIST+RDLRC-ROMDLIST)\r
+       dc.b    $00,RAMDLIST >> 8,$ff & (RAMDLIST+RDLN09-ROMDLIST)\r
+       dc.b    $02,RAMDLIST >> 8,$ff & (RAMDLIST+RDLRC-ROMDLIST)\r
+       dc.b    $00,RAMDLIST >> 8,$ff & (RAMDLIST+RDLN10-ROMDLIST)\r
+       dc.b    $02,RAMDLIST >> 8,$ff & (RAMDLIST+RDLRC-ROMDLIST)\r
+       dc.b    $00,RAMDLIST >> 8,$ff & (RAMDLIST+RDLN11-ROMDLIST)\r
+       dc.b    $01,RAMDLIST >> 8,$ff & (RAMDLIST+RDLRCL-ROMDLIST)\r
+       dc.b    $0F,RAMDLIST >> 8,$ff & (RAMDLIST+$00)  ;TRAILING SPACE\r
+       dc.b    $0F,RAMDLIST >> 8,$ff & (RAMDLIST+$00)\r
+       dc.b    $0F,RAMDLIST >> 8,$ff & (RAMDLIST+$00)\r
+       dc.b    $0F,RAMDLIST >> 8,$ff & (RAMDLIST+$00)\r
+       dc.b    $0F,RAMDLIST >> 8,$ff & (RAMDLIST+$00)\r
+\r
+\r
+;      ROM GRAPHICS FOR THE FUJI-A AND WORDS\r
+ROMGRAPH:\r
+RMGRP6:\r
+       dc.b    $00     ;NULL INFO\r
+RMFUJ1:\r
+       dc.b    $7C,$7F,$8F,$80 ;LINE 6\r
+RMFUJ2:\r
+       dc.b    $FC,$7F,$8F,$C0\r
+RMFUJ3:\r
+       dc.b    $1F,$87,$F8,$7E\r
+RMFUJ4:\r
+       dc.b    $0F,$E0,$7F,$81,$FC\r
+RMFUJ5:\r
+       dc.b    $07,$FF,$80,$7F,$80,$7F,$F8\r
+RMFUJ6:\r
+       dc.b    $1F,$FF,$F0,$00,$7F,$80,$03,$FF,$FE\r
+RMFUJ7:\r
+       dc.b    $1F,$00,$00,$00,$7F,$80,$00,$00,$3E\r
+\r
+RMLIN1:\r
+       dc.b    $00,$00,$0C,$00,$3F,$FF,$FF,$FF ;LINE 1 OF ATARI\r
+       dc.b    $F0,$00,$C0,$00,$00,$3F,$FF,$FF\r
+       dc.b    $00,$03,$FC\r
+RMLIN2:\r
+       dc.b    $00,$00,$3F,$00,$3F,$FF,$FF,$FF ;LINE 2 OF ATARI\r
+       dc.b    $F0,$03,$F0,$00,$00,$3F,$FF,$FF\r
+       dc.b    $FC,$03,$FC\r
+RMLIN3:\r
+       dc.b    $00,$00,$FF,$C0,$00,$03,$FF,$00 ;LINE 3 OF ATARI\r
+       dc.b    $00,$0F,$FC,$00,$00,$3F,$F0,$03\r
+       dc.b    $FF,$C3,$FC\r
+RMLIN4:\r
+       dc.b    $00,$03,$FF,$F0,$00,$03,$FF,$00 ;LINE 4 OF ATARI\r
+       dc.b    $00,$3F,$FF,$00,$00,$3F,$F0,$00\r
+       dc.b    $3F,$C3,$FC\r
+\r
+RMGRP5:\r
+       dc.b    $00     ;NULL INFO\r
+       dc.b    $7C,$7F,$8F,$80 ;LINE 5\r
+       dc.b    $7C,$7F,$8F,$80\r
+       dc.b    $1F,$87,$F8,$7E\r
+       dc.b    $0F,$F0,$7F,$83,$FC\r
+       dc.b    $01,$FF,$80,$7F,$80,$7F,$E0\r
+       dc.b    $1F,$FF,$F8,$00,$7F,$80,$07,$FF,$FE\r
+       dc.b    $1F,$F0,$00,$00,$7F,$80,$00,$03,$FE\r
+\r
+       dc.b    $00,$0F,$F3,$FC,$00,$03,$FF,$00 ;LINE 5 OF ATARI\r
+       dc.b    $00,$FF,$3F,$C0,$00,$3F,$F0,$00\r
+       dc.b    $FF,$C3,$FC\r
+       dc.b    $00,$3F,$C0,$FF,$00,$03,$FF,$00 ;LINE 6 OF ATARI\r
+       dc.b    $03,$FC,$0F,$F0,$00,$3F,$F0,$3F\r
+       dc.b    $FC,$03,$FC\r
+       dc.b    $00,$FF,$00,$3F,$C0,$03,$FF,$00 ;LINE 7 OF ATARI\r
+       dc.b    $0F,$F0,$03,$FC,$00,$3F,$F0,$FF\r
+       dc.b    $C0,$03,$FC\r
+       dc.b    $03,$FF,$FF,$FF,$F0,$03,$FF,$00 ;LINE 8 OF ATARI\r
+       dc.b    $3F,$FF,$FF,$FF,$00,$3F,$F0,$3F\r
+       dc.b    $F0,$03,$FC\r
+\r
+RMGRP4:\r
+       dc.b    $00     ;NULL INFO\r
+       dc.b    $7C,$7F,$8F,$80 ;LINE 4\r
+       dc.b    $7C,$7F,$8F,$80\r
+       dc.b    $1F,$87,$F8,$7E\r
+       dc.b    $07,$F0,$7F,$83,$F8\r
+       dc.b    $00,$FF,$C0,$7F,$80,$FF,$C0\r
+       dc.b    $1F,$FF,$FC,$00,$7F,$80,$0F,$FF,$FE\r
+       dc.b    $1F,$FC,$00,$00,$7F,$80,$00,$0F,$FE\r
+\r
+       dc.b    $0F,$FF,$FF,$FF,$FC,$03,$FF,$00 ;LINE 9 OF ATARI\r
+       dc.b    $FF,$FF,$FF,$FF,$C0,$3F,$F0,$0F\r
+       dc.b    $FC,$03,$FC\r
+       dc.b    $3F,$F0,$00,$03,$FF,$03,$FF,$03 ;LINE 10 OF ATARI\r
+       dc.b    $FF,$00,$00,$3F,$F0,$3F,$F0,$03\r
+       dc.b    $FF,$03,$FC\r
+       dc.b    $FF,$C0,$00,$00,$FF,$C3,$FF,$0F ;LINE 11 OF ATARI\r
+       dc.b    $FC,$00,$00,$0F,$FC,$3F,$F0,$00\r
+       dc.b    $FF,$C3,$FC\r
+\r
+RMGRP3:\r
+       dc.b    $00     ;NULL INFO\r
+       dc.b    $7C,$7F,$8F,$80 ;LINE 3\r
+       dc.b    $7C,$7F,$8F,$80\r
+       dc.b    $0F,$87,$F8,$7C\r
+       dc.b    $07,$F0,$7F,$83,$F8\r
+       dc.b    $00,$7F,$C0,$7F,$80,$FF,$80\r
+       dc.b    $1F,$FF,$FE,$00,$7F,$80,$1F,$FF,$FE\r
+       dc.b    $1F,$FF,$00,$00,$7F,$80,$00,$3F,$FE\r
+\r
+ROMSTRIP:\r
+       dc.b    $55,$55,$55,$55,$55,$55,$55,$55 ;RACING STRIPE\r
+       dc.b    $55,$55,$55,$55,$55,$55,$55,$55\r
+       dc.b    $55,$55,$55,$55\r
+\r
+RMGRP2:\r
+       dc.b    $00     ;NULL INFO\r
+       dc.b    $7C,$7F,$8F,$80 ;LINE 2\r
+       dc.b    $7C,$7F,$8F,$80\r
+       dc.b    $0F,$C7,$F8,$FC\r
+       dc.b    $03,$F0,$7F,$83,$F0\r
+       dc.b    $00,$3F,$E0,$7F,$81,$FF,$00\r
+       dc.b    $01,$FF,$FE,$00,$7F,$80,$1F,$FF,$E0\r
+       dc.b    $1F,$FF,$C0,$00,$7F,$80,$00,$FF,$FE\r
+\r
+       dc.b    $AA,$AA,$AA,$AA,$AA,$AA,$AA,$AA ;RACING STRIPE\r
+       dc.b    $AA,$AA,$AA,$AA,$AA,$AA,$AA,$AA\r
+       dc.b    $AA,$AA,$AA,$AA\r
+\r
+RMGRP1:\r
+       dc.b    $00     ;NULL INFO\r
+       dc.b    $7C,$7F,$8F,$80 ;LINE 1\r
+       dc.b    $7C,$7F,$8F,$80\r
+       dc.b    $0F,$C7,$F8,$FC\r
+       dc.b    $03,$F8,$7F,$87,$F0\r
+       dc.b    $00,$1F,$E0,$7F,$81,$FE,$00\r
+       dc.b    $00,$1F,$FF,$00,$7F,$80,$3F,$FE,$00\r
+       dc.b    $1F,$FF,$E0,$00,$7F,$80,$01,$FF,$FE\r
+\r
+       dc.b    $55,$55,$55,$55,$55,$55,$55,$55 ;RACING STRIPE\r
+       dc.b    $55,$55,$55,$55,$55,$55,$55,$55\r
+       dc.b    $55,$55,$55,$55\r
+\r
+\r
+;      NUMBERS.S       NUMBERS FOR THE ENCRYPTION\r
+\r
+\r
+;      THIS IS A MASK APPLIED TO THE HI BYTE OF THE CHECKSUM TO MAKE SURE IT IS\r
+;      LESS THAN N\r
+NMASK  =       $07\r
+\r
+;      N = P*Q, THE BASIC MODULO OF DECRYPTION\r
+NLEN   =       $77\r
+N1:\r
+       .dc.b   $09,$CA,$C9,$C6,$B4,$12,$08,$1B\r
+       .dc.b   $60,$58,$81,$4B,$86,$01,$D8,$BF\r
+       .dc.b   $D9,$25,$A0,$7B,$DC,$32,$79,$84\r
+       .dc.b   $3B,$7C,$BC,$2F,$E2,$E2,$FA,$8D\r
+       .dc.b   $0A,$00,$3B,$C5,$EC,$AF,$2D,$8A\r
+       .dc.b   $CD,$06,$93,$6A,$A5,$14,$46,$77\r
+       .dc.b   $C4,$6A,$B2,$53,$36,$EF,$8C,$CE\r
+       .dc.b   $0C,$A2,$68,$71,$D3,$73,$E8,$F7\r
+       .dc.b   $6D,$06,$B5,$20,$EF,$23,$47,$0C\r
+       .dc.b   $51,$55,$C8,$FE,$F4,$58,$C4,$3F\r
+       .dc.b   $20,$A7,$67,$38,$B0,$76,$E2,$C4\r
+       .dc.b   $D8,$05,$63,$F8,$3C,$58,$3B,$2D\r
+       .dc.b   $22,$CC,$88,$B3,$71,$8F,$1D,$80\r
+       .dc.b   $0A,$87,$BD,$A1,$59,$23,$E9,$70\r
+       .dc.b   $E2,$D3,$EC,$46,$68,$80,$42,$39\r
+\r
+\r
+;      END.S   END OF CODE\r
+\r
+NROM2:\r
+       NOP\r
+\r
+       .org    $FFEE\r
+       .ds.b   'GCC(C)1984'\r
+\r
+       .org    $FFF8\r
+;      .dc.b   $F0     ;CHECKSUM, MAKES EOR CHECKSUM ZERO\r
+       .dc.b   $2D     ;CHECKSUM, MAKES EOR CHECKSUM ZERO\r
+       .dc.b   $F7     ;CART STARTS AT 0F000 - 7 JUST A FLAG\r
+       .dc.w   INTDLI  ;INTERNAL GAME DLI HANDLER\r
+       .dc.w   MAIN\r
+       .dc.w   IRQINT\r
+\r
+\r
+\r
diff --git a/MORESTMP.S b/MORESTMP.S
new file mode 100644 (file)
index 0000000..bee71b9
--- /dev/null
@@ -0,0 +1,882 @@
+*         0253    060283\r
+*\r
+*\r
+** MORESTMP.S **  UNCOVERTED GRAPHICS DATA  **\r
+** ASTEROIDS FOR THE ATARI 3600 **\r
+** CONVERTED FOR MARIA 2\r
+\r
+** OTHER STAMP DATA IS IN STAMPS.S **\r
+CHARS:\r
+       .ORG     GRAPHICS+$2000\r
+* BIG NUMERIALS USED FOR PLAYERS SCORE.  ALSO MINIATURE EXTRA SHIP. *\r
+       .DC.B    0,$A8,$A8,$A8,$A8,$08,$A8,$A8,$20,$A8,$A8,$00;B 0-9 SHIP\r
+* SMALL NUMERIALS USED FOR HIGH SCORE. *\r
+       .DC.B    0,0,0,0,0,0,0,0,0,0                    ;0-9\r
+* MESSAGES USED DURING GAMEPLAY. *\r
+PLAY1MES:\r
+       .DC.B   0,0,0,0,0,0,0,0,0,0,0           ;PLAYER 1\r
+PLAY2MES:\r
+       .DC.B   0,0,0,0,0,0,0,0,0,0,0           ;PLAYER 2\r
+WINSMESS:\r
+       .DC.B   0,0,0,0,0                               ;WINS\r
+OVERMESS:\r
+       .DC.B   0,0,0,0,0,0,0,0,0,0,0,0         ;GAMEOVER\r
+* BIG LETTERS TO SPELL ASTEROIDS. *\r
+NAMEA:\r
+       .DC.B   $00,$00,$3F,$F0,$3F,$F0         ;BIG LETTER A\r
+NAMES:\r
+       .DC.B   $03,$FF,$FF,$F0                 ;BIG LETTER S\r
+NAMET:\r
+       .DC.B   $00,$3F,$C0,$00                 ;BIG LETTER T\r
+NAMEE:\r
+       .DC.B   $FF,$FF,$FF,$00                 ;BIG LETTER E\r
+NAMER:\r
+       .DC.B   $FF,$C0,$FF,$C0                 ;BIG LETTER R\r
+NAMEO:\r
+       .DC.B   $FF,$FF,$FF,$C0                 ;BIG LETTER O\r
+NAMEI:\r
+       .DC.B   $FF,$F0                         ;BIG LETTER I\r
+NAMED:\r
+       .DC.B   $3F,$FF,$FF,$00                 ;BIG LETTER D\r
+NAMES2:\r
+       .DC.B   $03,$FF,$FF,$F0,$00,$00         ;BIG LETTER S\r
+* STARS BROUGHT OVER FROM STAMPS.S. *\r
+STARS:\r
+       .DC.B   $00,$00,$00,00                  ;ASSORTED STARS\r
+* MESSAGES USED DURING MENU. *\r
+MNOVICE:\r
+       .DC.B   $41,$15,$41,$41,$15,$45,$50     ;NOVICE\r
+MINTER:\r
+       .DC.B   $44,$10,$10,$15,$44,$11,$01     ;INTERMEDIATE\r
+       .DC.B   $15,$45,$41,$10,$40,$40,$55\r
+MEXPERT:\r
+       .DC.B   $55,$11,$10,$05,$51,$04,$04,$00 ;EXPERT\r
+MONEPL:\r
+       .DC.B   $55,$10,$45,$50,$04,$01,$54     ;ONE PLAYER\r
+       .DC.B   $41,$01,$01,$54,$41\r
+MTWOPL:\r
+       .DC.B   $04,$01,$10,$55,$00,$40,$15     ;TWO PLAYER\r
+       .DC.B   $44,$10,$10,$15,$44,$11,$54\r
+MTEAMPL:\r
+       .DC.B   $04,$05,$51,$04,$40,$40,$40             ;TEAM PLAY\r
+       .DC.B   $15,$44,$10,$10\r
+MCOMPPL:\r
+       .DC.B   $55,$15,$44,$04,$40,$15,$40             ;COMP PLAY\r
+       .DC.B   $40,$40,$40,$45,$51,$04,$00\r
+       .DC.B   $40,$15,$44,$10,$10\r
+MCOPYR:\r
+       .dc.b   $00,$05,$50,$00,$00,$00\r
+       .dc.b   $00,$00,$00,$00,$00,$00\r
+\r
+*      .DC.B   $55,$15,$44,$00,$10,$10         ;COPYRIGHT\r
+*      .DC.B   $44,$55,$10,$40,$40,$00\r
+MATARI:\r
+       .dc.b   $00,$00,$00,$00,$00,$00\r
+       .dc.b   $00,$00,$00,$00,$00,$00\r
+*      .DC.B   $41,$01,$01,$04,$41,$10         ;ATARI\r
+*      .DC.B   $01,$51,$54,$55,$00,$40\r
+MADVANCE:\r
+       .DC.B   $41,$15,$01,$41,$04,$41,$15,$45,$51,$50 ;ADVANCED\r
+BEAG:\r
+       .dc.b   $20,$0A,$00,$02,$02,$00,$A8,$00,$2A,$82,$00,$00,$80,$08,$A0,$00\r
+       .dc.b   $00,$28,$00,$28,$82,$00\r
+*\r
+*      .DC.B   $80,$08,$A0,$00,$0A,$00,$A0,$82,$8A,$08 ;EE\r
+*      .DC.B   $02,$88,$20,$22,$80,$00,$AA,$00,$00,$0A,$AA,$80\r
+*\r
+*  the following was added to make the source generate what is in the rom\r
+       .dc.b   $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff ;added by dave\r
+       .ORG     CHARS+$100\r
+       .DC.B   0,$88,$20,$80,$08,$08,$08,$88,$20,$88,$08,$0C\r
+       .DC.B   0,0,0,0,0,0,0,0,0,0\r
+       .DC.B   0,0,0,0,0,0,0,0,0,0,0\r
+       .DC.B   0,0,0,0,0,0,0,0,0,0,0\r
+       .DC.B   0,0,0,0,0\r
+       .DC.B   0,0,0,0,0,0,0,0,0,0,0,0\r
+       .DC.B   $00,$00,$3F,$F0,$3F,$F0\r
+       .DC.B   $03,$FF,$FF,$F0\r
+       .DC.B   $00,$3F,$C0,$00\r
+       .DC.B   $FF,$FF,$FF,$00\r
+       .DC.B   $FF,$C3,$FF,$C0\r
+       .DC.B   $FF,$FF,$FF,$C0\r
+       .DC.B   $FF,$F0\r
+       .DC.B   $3F,$FF,$FF,$C0\r
+       .DC.B   $03,$FF,$FF,$F0,$00,$00\r
+       .DC.B   $00,$00,$00,$00\r
+       .DC.B   $45,$10,$45,$51,$10,$04,$00             ;NOVICE\r
+       .DC.B   $44,$50,$10,$10,$04,$51,$01             ;INTERMEDIATE\r
+       .DC.B   $10,$04,$11,$15,$40,$40,$40\r
+       .DC.B   $40,$11,$10,$04,$01,$14,$04,$00         ;EXPERT\r
+       .DC.B   $41,$11,$44,$00,$04,$01,$00             ;ONE PLAYER\r
+       .DC.B   $55,$01,$01,$00,$45\r
+       .DC.B   $04,$04,$44,$41,$00,$40,$10             ;TWO PLAYER\r
+       .DC.B   $05,$50,$10,$10,$04,$50,$04\r
+       .DC.B   $04,$04,$01,$54,$40,$40,$40             ;TEAM PLAY\r
+       .DC.B   $10,$05,$50,$10\r
+       .DC.B   $40,$10,$44,$04,$40,$10,$00             ;COMP PLAY\r
+       .DC.B   $40,$40,$40,$44,$11,$14,$00\r
+       .DC.B   $40,$10,$05,$50,$10\r
+*\r
+       .dc.b   $00,$10,$04,$00,$54,$55\r
+       .dc.b   $15,$45,$50,$01,$04,$04\r
+*\r
+       .dc.b   $04,$11,$04,$40,$05,$51\r
+       .dc.b   $54,$41,$10,$04,$00,$00\r
+\r
+*      .DC.B   $40,$10,$44,$00,$10,$11                 ;COPYRIGHT\r
+*      .DC.B   $44,$41,$10,$40,$40,$00\r
+*\r
+*      .DC.B   $55,$01,$01,$54,$45,$10                 ;ATARI\r
+*      .DC.B   $00,$40,$04,$41,$00,$40\r
+*\r
+       .DC.B   $55,$10,$45,$51,$54,$45,$10,$04,$01,$04 ;ADVANCED\r
+*\r
+       .dc.b   $88,$28,$82,$88,$88,$88,$82,$00,$80,$82,$00,$00,$20,$2A,$88,$00\r
+       .dc.b   $00,$82,$00,$82,$02,$00\r
+*\r
+*      .DC.B   $20,$2A,$88,$00,$20,$82,$20,$A2,$28,$82 ;EE\r
+*      .DC.B   $08,$22,$20,$88,$20,$02,$00,$80,$00,$00,$00,$20\r
+*\r
+*  the following was added to make the source generate what is in the rom\r
+       .dc.b   $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff ;added by dave\r
+\r
+       .ORG     CHARS+$200\r
+       .DC.B   0,$88,$20,$80,$08,$08,$08,$88,$20,$88,$08,$38\r
+       .DC.B   0,0,0,0,0,0,0,0,0,0\r
+       .DC.B   0,0,0,0,0,0,0,0,0,0,0\r
+       .DC.B   0,0,0,0,0,0,0,0,0,0,0\r
+       .DC.B   0,0,0,0,0\r
+       .DC.B   0,0,0,0,0,0,0,0,0,0,0,0\r
+       .DC.B   $00,$00,$35,$70,$35,$70\r
+       .DC.B   $03,$55,$55,$70\r
+       .DC.B   $00,$35,$C0,$00\r
+       .DC.B   $D5,$55,$57,$00\r
+       .DC.B   $D5,$CF,$D5,$C0\r
+       .DC.B   $D5,$55,$55,$C0\r
+       .DC.B   $D5,$70\r
+       .DC.B   $35,$55,$55,$C0\r
+       .DC.B   $03,$55,$55,$70,$00,$00\r
+       .DC.B   $01,$00,$00,$00 ;STARS+0 -> COLOR 1, COLUMN 4\r
+       .DC.B   $55,$10,$44,$11,$10,$05,$40             ;NOVICE\r
+       .DC.B   $45,$50,$10,$15,$05,$41,$11             ;INTERMEDIATE\r
+       .DC.B   $15,$04,$11,$10,$40,$40,$54\r
+       .DC.B   $54,$04,$15,$45,$41,$50,$04,$00         ;EXPERT\r
+       .DC.B   $41,$15,$45,$40,$05,$41,$00             ;ONE PLAYER\r
+       .DC.B   $41,$05,$41,$50,$54\r
+       .DC.B   $04,$04,$44,$41,$00,$54,$10             ;TWO PLAYER\r
+       .DC.B   $04,$10,$54,$15,$05,$40,$50\r
+       .DC.B   $04,$05,$41,$04,$44,$40,$54             ;TEAM PLAY\r
+       .DC.B   $10,$04,$10,$54\r
+       .DC.B   $40,$10,$44,$44,$55,$15,$00             ;COMP PLAY\r
+       .DC.B   $40,$40,$40,$44,$11,$54,$00\r
+       .DC.B   $55,$10,$04,$10,$54\r
+*\r
+       .dc.b   $00,$11,$44,$00,$10,$01\r
+       .dc.b   $10,$44,$10,$01,$54,$04\r
+       .dc.b   $05,$51,$14,$40,$04,$01\r
+       .dc.b   $04,$45,$10,$04,$00,$00\r
+*\r
+*\r
+*      .DC.B   $40,$10,$45,$40,$54,$15                 ;COPYRIGHT\r
+*      .DC.B   $04,$45,$15,$40,$40,$00\r
+*      .DC.B   $41,$01,$01,$04,$54,$10                 ;ATARI\r
+*      .DC.B   $00,$41,$54,$55,$15,$40\r
+*\r
+       .DC.B   $41,$10,$44,$11,$04,$55,$10,$05,$41,$04 ;ADVANCED\r
+\r
+       .dc.b   $82,$20,$82,$28,$88,$22,$00,$02,$80,$20,$00,$00,$2A,$A2,$08,$00\r
+       .dc.b   $00,$82,$00,$82,$02,$00\r
+*\r
+*      .DC.B   $2A,$A2,$08,$00,$A0,$A8,$28,$2A,$08,$82 ;EE\r
+*      .DC.B   $08,$22,$20,$88,$20,$02,$00,$20,$A8,$AA,$8A,$20\r
+*\r
+*  the following was added to make the source generate what is in the rom\r
+       .dc.b   $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff ;added by dave\r
+\r
+       .ORG     CHARS+$300\r
+       .DC.B   0,$88,$20,$80,$08,$A8,$08,$88,$20,$88,$A8,$A8\r
+       .DC.B   0,0,0,0,0,0,0,0,0,0\r
+       .DC.B   0,0,0,0,0,0,0,0,0,0,0\r
+       .DC.B   0,0,0,0,0,0,0,0,0,0,0\r
+       .DC.B   0,0,0,0,0\r
+       .DC.B   0,0,0,0,0,0,0,0,0,0,0,0\r
+       .DC.B   $00,$00,$35,$70,$35,$70\r
+       .DC.B   $03,$55,$55,$70\r
+       .DC.B   $00,$35,$C0,$00\r
+       .DC.B   $D5,$55,$57,$00\r
+       .DC.B   $D5,$CF,$57,$00\r
+       .DC.B   $D5,$55,$55,$C0\r
+       .DC.B   $D5,$70\r
+       .DC.B   $35,$55,$55,$70\r
+       .DC.B   $03,$55,$55,$70,$00,$00\r
+       .DC.B   $00,$00,$00,$00\r
+       .DC.B   $51,$10,$44,$11,$10,$04,$00             ;NOVICE\r
+       .DC.B   $45,$10,$10,$10,$04,$11,$45             ;INTERMEDIATE\r
+       .DC.B   $10,$04,$11,$10,$40,$40,$40\r
+       .DC.B   $40,$11,$10,$44,$01,$04,$04,$00 ;EXPERT\r
+       .DC.B   $41,$14,$44,$00,$04,$11,$00             ;ONE PLAYER\r
+       .DC.B   $41,$14,$51,$00,$41\r
+       .DC.B   $04,$04,$44,$41,$00,$41,$10             ;TWO PLAYER\r
+       .DC.B   $04,$11,$45,$10,$04,$11,$00\r
+       .DC.B   $04,$04,$01,$04,$51,$40,$41             ;TEAM PLAY\r
+       .DC.B   $10,$04,$11,$45\r
+       .DC.B   $40,$10,$45,$14,$41,$10,$00             ;COMP PLAY\r
+       .DC.B   $40,$40,$40,$44,$11,$44,$00\r
+       .DC.B   $41,$10,$04,$11,$45\r
+*\r
+       .dc.b   $00,$11,$04,$00,$10,$55\r
+       .dc.b   $15,$45,$50,$01,$04,$04\r
+       .dc.b   $04,$11,$50,$40,$04,$01\r
+       .dc.b   $04,$54,$15,$00,$00,$00\r
+*\r
+*\r
+*      .DC.B   $40,$10,$44,$11,$45,$10         ;COPYRIGHT\r
+*      .DC.B   $44,$40,$10,$40,$40,$00\r
+*      .DC.B   $41,$01,$01,$04,$41,$10         ;ATARI\r
+*      .DC.B   $01,$41,$04,$41,$10,$40\r
+*\r
+       .DC.B   $41,$10,$44,$11,$04,$51,$10,$04,$01,$04 ;ADVANCED\r
+*\r
+       .dc.b   $82,$80,$8A,$08,$88,$22,$A8,$02,$00,$20,$08,$08,$0A,$80,$08,$02\r
+       .dc.b   $00,$82,$00,$82,$00,$00\r
+*\r
+*      .DC.B   $0A,$80,$08,$00,$80,$28,$08,$22,$08,$82 ;EE\r
+*      .DC.B   $02,$A2,$20,$88,$20,$0A,$00,$20,$82,$00,$A0,$A0\r
+*\r
+*  the following was added to make the source generate what is in the rom\r
+       .dc.b   $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff ;added by dave\r
+\r
+       .ORG     CHARS+$400\r
+       .DC.B   0,$88,$20,$A8,$28,$88,$A8,$A8,$08,$A8,$88,$E8\r
+       .DC.B   0,0,0,0,0,0,0,0,0,0\r
+       .DC.B   $40,$05,$51,$01,$01,$01,$54,$40,$40,$01,$50\r
+       .DC.B   $40,$05,$51,$01,$01,$01,$54,$40,$40,$01,$54\r
+       .DC.B   $55,$44,$41,$15,$40\r
+       .DC.B   $55,$44,$04,$40,$45,$50,$05,$50,$10,$15,$44,$04\r
+       .DC.B   $AA,$AA,$B5,$70,$35,$70\r
+       .DC.B   $A8,$00,$35,$70\r
+       .DC.B   $2A,$B5,$C2,$AA\r
+       .DC.B   $D5,$55,$57,$08\r
+       .DC.B   $D5,$CF,$54,$02\r
+       .DC.B   $D5,$C2,$D5,$C2\r
+       .DC.B   $D5,$42\r
+       .DC.B   $B5,$55,$55,$70\r
+       .DC.B   $AA,$00,$35,$72,$AA,$A8\r
+       .DC.B   $00,$00,$00,$00\r
+       .DC.B   $41,$15,$44,$11,$15,$45,$50             ;NOVICE\r
+       .DC.B   $44,$11,$55,$15,$45,$51,$01             ;INTERMEDIATE\r
+       .DC.B   $15,$45,$41,$05,$05,$54,$55\r
+       .DC.B   $55,$11,$15,$45,$51,$54,$55,$40 ;EXPERT\r
+       .DC.B   $55,$10,$45,$50,$05,$51,$00             ;ONE PLAYER\r
+       .DC.B   $14,$10,$11,$54,$55\r
+       .DC.B   $55,$44,$04,$55,$00,$55,$10             ;TWO PLAYER\r
+       .DC.B   $01,$41,$01,$15,$45,$51,$54\r
+       .DC.B   $55,$45,$50,$50,$40,$40,$55             ;TEAM PLAY\r
+       .DC.B   $10,$01,$41,$01\r
+       .DC.B   $55,$15,$44,$04,$55,$15,$45             ;COMP PLAY\r
+       .DC.B   $54,$45,$54,$45,$51,$04,$00\r
+       .DC.B   $55,$10,$01,$41,$01\r
+*\r
+       .dc.b   $00,$11,$44,$00,$50,$41\r
+       .dc.b   $10,$44,$10,$01,$04,$04\r
+       .dc.b   $04,$11,$04,$40,$04,$01\r
+       .dc.b   $04,$41,$10,$40,$00,$00\r
+*\r
+*      .DC.B   $55,$15,$45,$51,$01,$15         ;COPYRIGHT\r
+*      .DC.B   $44,$55,$10,$45,$54,$00\r
+*      .DC.B   $14,$15,$50,$50,$55,$10         ;ATARI\r
+*      .DC.B   $00,$41,$54,$55,$10,$40\r
+*\r
+       .DC.B   $14,$15,$04,$10,$50,$41,$15,$45,$51,$50 ;ADVANCED\r
+*\r
+       .dc.b   $22,$80,$22,$08,$88,$22,$02,$08,$00,$20,$02,$28,$80,$00,$0A,$8A\r
+       .dc.b   $00,$82,$00,$82,$00,$00\r
+*\r
+*      .DC.B   $00,$00,$08,$00,$80,$08,$08,$20,$88,$82 ;EE\r
+*      .DC.B   $00,$22,$20,$88,$20,$08,$00,$20,$82,$A8,$20,$20\r
+*\r
+*  the following was added to make the source generate what is in the rom\r
+       .dc.b   $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff ;added by dave\r
+\r
+       .ORG     CHARS+$500\r
+       .DC.B   0,$88,$20,$08,$08,$88,$80,$80,$08,$88,$88,$28\r
+       .DC.B   0,0,0,0,0,0,0,0,0,0\r
+       .DC.B   $40,$04,$01,$01,$01,$01,$00,$40,$40,$00,$40\r
+       .DC.B   $40,$04,$01,$01,$01,$01,$00,$40,$40,$01,$00\r
+       .DC.B   $44,$44,$41,$00,$40\r
+       .DC.B   $40,$44,$04,$40,$44,$00,$04,$10,$44,$10,$04,$04\r
+       .DC.B   $00,$00,$35,$F0,$3D,$70\r
+       .DC.B   $00,$00,$3D,$70\r
+       .DC.B   $00,$35,$C0,$00\r
+       .DC.B   $D5,$C0,$00,$00\r
+       .DC.B   $D7,$CF,$5C,$00\r
+       .DC.B   $D5,$C0,$D5,$C0\r
+       .DC.B   $35,$C0\r
+       .DC.B   $35,$70,$15,$70\r
+       .DC.B   $00,$00,$3D,$70,$00,$00\r
+       .DC.B   $00,$00,$00,$00\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00             ;NOVICE\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00             ;INTERMEDIATE\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00,$00 ;EXPERT\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00             ;ONE PLAYER\r
+       .DC.B   $00,$00,$00,$00,$00\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00             ;TWO PLAYER\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00             ;TEAM PLAY\r
+       .DC.B   $00,$00,$00,$00\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00             ;COMP PLAY\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00\r
+       .DC.B   $00,$00,$00,$00,$00\r
+*\r
+       .dc.b   $00,$10,$04,$00,$10,$55\r
+       .dc.b   $15,$45,$50,$00,$50,$55\r
+       .dc.b   $41,$41,$54,$40,$05,$51\r
+       .dc.b   $54,$55,$15,$40,$00,$00\r
+*\r
+*\r
+*      .DC.B   $00,$00,$00,$00,$00,$00         ;COPYRIGHT\r
+*      .DC.B   $00,$00,$00,$00,$00,$00\r
+*      .DC.B   $00,$00,$00,$00,$00,$00         ;ATARI\r
+*      .DC.B   $00,$00,$00,$00,$00,$00\r
+*\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ;ADVANCED\r
+\r
+*\r
+       .dc.b   $08,$80,$20,$88,$88,$22,$02,$08,$00,$20,$02,$82,$28,$A8,$08,$A0\r
+       .dc.b   $80,$22,$00,$82,$02,$00\r
+*\r
+*\r
+*      .DC.B   $2A,$00,$08,$00,$80,$08,$08,$20,$88,$A2 ;EE\r
+*      .DC.B   $08,$22,$20,$88,$20,$08,$00,$20,$82,$02,$20,$20\r
+*\r
+*  the following was added to make the source generate what is in the rom\r
+       .dc.b   $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff ;added by dave\r
+\r
+       .ORG     CHARS+$600\r
+       .DC.B   0,$A8,$A0,$A8,$A8,$80,$A8,$A8,$A8,$A8,$A8,$08\r
+       .DC.B   0,0,0,0,0,0,0,0,0,0\r
+       .DC.B   $40,$04,$01,$01,$01,$01,$00,$40,$40,$00,$40\r
+       .DC.B   $40,$04,$01,$01,$01,$01,$00,$40,$40,$01,$00\r
+       .DC.B   $44,$44,$45,$00,$40\r
+       .DC.B   $40,$44,$04,$40,$44,$00,$04,$11,$01,$10,$04,$04\r
+       .DC.B   $0A,$AA,$B7,$FF,$FF,$70\r
+       .DC.B   $BF,$FF,$FF,$70\r
+       .DC.B   $2A,$B5,$C2,$AA\r
+       .DC.B   $D7,$C0,$00,$08\r
+       .DC.B   $DF,$FF,$DF,$02\r
+       .DC.B   $D5,$C2,$D5,$C2\r
+       .DC.B   $B5,$C2\r
+       .DC.B   $B5,$70,$BD,$70\r
+       .DC.B   $BF,$FF,$FF,$72,$AA,$80\r
+       .DC.B   $00,$20,$00,$00 ;STARS+1 -> COLOR 2, COLUMN 2\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00             ;NOVICE\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00             ;INTERMEDIATE\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00,$00 ;EXPERT\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00             ;ONE PLAYER\r
+       .DC.B   $00,$00,$00,$00,$00\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00             ;TWO PLAYER\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00             ;TEAM PLAY\r
+       .DC.B   $00,$00,$00,$00\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00             ;COMP PLAY\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00\r
+       .DC.B   $00,$00,$00,$00,$00\r
+*\r
+       .dc.b   $00,$05,$50,$00,$00,$00\r
+       .dc.b   $00,$00,$00,$00,$00,$00\r
+       .dc.b   $00,$00,$00,$00,$00,$00\r
+       .dc.b   $00,$00,$00,$00,$00,$00\r
+*\r
+*\r
+*      .DC.B   $00,$00,$00,$00,$00,$00         ;COPYRIGHT\r
+*      .DC.B   $00,$00,$00,$00,$00,$00\r
+*      .DC.B   $00,$00,$00,$00,$00,$00         ;ATARI\r
+*      .DC.B   $00,$00,$00,$00,$00,$00\r
+*\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ;ADVANCED\r
+*\r
+       .dc.b   $00,$80,$20,$88,$88,$22,$02,$00,$00,$80,$02,$02,$22,$88,$A8,$80\r
+       .dc.b   $80,$2A,$00,$82,$02,$00\r
+*\r
+*\r
+*      .DC.B   $80,$80,$A8,$00,$80,$08,$0A,$80,$28,$88 ;EE\r
+*      .DC.B   $02,$80,$8A,$02,$A0,$08,$00,$A0,$22,$02,$20,$20\r
+*\r
+*  the following was added to make the source generate what is in the rom\r
+       .dc.b   $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff ;added by dave\r
+\r
+       .ORG     CHARS+$700\r
+       .DC.B   0,0,0,0,0,0,0,0,0,0,0,$08\r
+       .DC.B   0,0,0,0,0,0,0,0,0,0\r
+       .DC.B   $40,$04,$01,$01,$01,$01,$00,$40,$40,$00,$40\r
+       .DC.B   $40,$04,$01,$01,$01,$01,$00,$40,$40,$01,$00\r
+       .DC.B   $44,$44,$45,$00,$40\r
+       .DC.B   $41,$44,$04,$40,$44,$00,$04,$11,$01,$10,$04,$04\r
+       .DC.B   $00,$00,$35,$55,$55,$70\r
+       .DC.B   $35,$55,$55,$70\r
+       .DC.B   $00,$35,$C0,$00\r
+       .DC.B   $DF,$FF,$FF,$00\r
+       .DC.B   $D5,$55,$55,$C0\r
+       .DC.B   $D5,$C0,$D5,$C0\r
+       .DC.B   $35,$C0\r
+       .DC.B   $35,$70,$35,$70\r
+       .DC.B   $35,$55,$55,$70,$00,$00\r
+       .DC.B   $00,$00,$00,$00\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00             ;NOVICE\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00             ;INTERMEDIATE\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00,$00 ;EXPERT\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00             ;ONE PLAYER\r
+       .DC.B   $00,$00,$00,$00,$00\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00             ;TWO PLAYER\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00             ;TEAM PLAY\r
+       .DC.B   $00,$00,$00,$00\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00             ;COMP PLAY\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00\r
+       .DC.B   $00,$00,$00,$00,$00\r
+*\r
+       .dc.b   $00,$00,$00,$00,$00,$00\r
+       .dc.b   $00,$00,$00,$00,$00,$00\r
+       .dc.b   $00,$00,$00,$00,$00,$00\r
+       .dc.b   $00,$00,$00,$00,$00,$00\r
+*\r
+*      .DC.B   $00,$00,$00,$00,$00,$00         ;COPYRIGHT\r
+*      .DC.B   $00,$00,$00,$00,$00,$00\r
+*      .DC.B   $00,$00,$00,$00,$00,$00         ;ATARI\r
+*      .DC.B   $00,$00,$00,$00,$00,$00\r
+*\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ;ADVANCED\r
+*\r
+       .dc.b   $00,$80,$20,$28,$20,$20,$A8,$00,$2A,$80,$00,$82,$20,$8A,$08,$20\r
+       .dc.b   $80,$0A,$A8,$82,$02,$00\r
+*\r
+*      .DC.B   $80,$82,$08,$00,$20,$0A,$0A,$00,$00,$00 ;EE\r
+*      .DC.B   $00,$00,$00,$00,$20,$08,$0A,$08,$22,$02,$20,$20\r
+*\r
+*  the following was added to make the source generate what is in the rom\r
+       .dc.b   $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff ;added by dave\r
+\r
+       .ORG     CHARS+$800\r
+       .DC.B   0,0,0,0,0,0,0,0,0,0,0,0\r
+       .DC.B   0,0,0,0,0,0,0,0,0,0\r
+       .DC.B   $55,$44,$01,$55,$15,$51,$54,$55,$40,$00,$40\r
+       .DC.B   $55,$44,$01,$55,$15,$51,$54,$55,$40,$01,$54\r
+       .DC.B   $40,$44,$51,$15,$40\r
+       .DC.B   $40,$05,$54,$40,$45,$50,$04,$11,$01,$15,$45,$54\r
+       .DC.B   $00,$AA,$B5,$55,$55,$70\r
+       .DC.B   $B5,$55,$55,$70\r
+       .DC.B   $2A,$B5,$C0,$02\r
+       .DC.B   $D5,$55,$57,$08\r
+       .DC.B   $D5,$55,$55,$C2\r
+       .DC.B   $D5,$C2,$D5,$C2\r
+       .DC.B   $B5,$C0\r
+       .DC.B   $B5,$70,$B5,$70\r
+       .DC.B   $B5,$55,$55,$72,$A8,$00\r
+       .DC.B   $00,$00,$00,$00\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00             ;NOVICE\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00             ;INTERMEDIATE\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00,$00 ;EXPERT\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00             ;ONE PLAYER\r
+       .DC.B   $00,$00,$00,$00,$00\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00             ;TWO PLAYER\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00             ;TEAM PLAY\r
+       .DC.B   $00,$00,$00,$00\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00             ;COMP PLAY\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00\r
+       .DC.B   $00,$00,$00,$00,$00\r
+*\r
+       .dc.b   $00,$00,$00,$00,$00,$00\r
+       .dc.b   $00,$00,$00,$00,$00,$00\r
+       .dc.b   $00,$00,$00,$00,$00,$00\r
+       .dc.b   $00,$00,$00,$00,$00,$00\r
+*\r
+*      .DC.B   $00,$00,$00,$00,$00,$00         ;COPYRIGHT\r
+*      .DC.B   $00,$00,$00,$00,$00,$00\r
+*      .DC.B   $00,$00,$00,$00,$00,$00         ;ATARI\r
+*      .DC.B   $00,$00,$00,$00,$00,$00\r
+*\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ;ADVANCED\r
+*\r
+       .dc.b   $00,$80,$20,$00,$00,$00,$00,$00,$AA,$00,$00,$82,$20,$82,$08,$20\r
+       .dc.b   $80,$02,$02,$82,$02,$00\r
+*\r
+*      .DC.B   $80,$82,$08,$00,$0A,$02,$08,$00,$00,$00 ;EE\r
+*      .DC.B   $00,$00,$00,$00,$20,$08,$00,$02,$A0,$A8,$0A,$80\r
+*\r
+*  the following was added to make the source generate what is in the rom\r
+       .dc.b   $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff ;added by dave\r
+\r
+       .ORG     CHARS+$900\r
+       .DC.B   0,0,0,0,0,0,0,0,0,0,0,0\r
+       .DC.B   $54,$54,$54,$54,$04,$54,$54,$10,$54,$54\r
+       .DC.B   $40,$44,$01,$01,$10,$11,$00,$41,$00,$00,$40\r
+       .DC.B   $40,$44,$01,$01,$10,$11,$00,$41,$00,$00,$04\r
+       .DC.B   $40,$44,$51,$10,$00\r
+       .DC.B   $40,$44,$04,$44,$44,$00,$04,$11,$01,$10,$04,$10\r
+       .DC.B   $00,$00,$35,$55,$55,$70\r
+       .DC.B   $35,$55,$55,$70\r
+       .DC.B   $00,$35,$C0,$00\r
+       .DC.B   $D5,$55,$57,$00\r
+       .DC.B   $D5,$55,$55,$C0\r
+       .DC.B   $D5,$C0,$D5,$C0\r
+       .DC.B   $35,$C0\r
+       .DC.B   $35,$70,$35,$70\r
+       .DC.B   $35,$55,$55,$70,$00,$00\r
+       .DC.B   $00,$00,$00,$00\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00             ;NOVICE\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00             ;INTERMEDIATE\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00,$00 ;EXPERT\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00             ;ONE PLAYER\r
+       .DC.B   $00,$00,$00,$00,$00\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00             ;TWO PLAYER\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00             ;TEAM PLAY\r
+       .DC.B   $00,$00,$00,$00\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00             ;COMP PLAY\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00\r
+       .DC.B   $00,$00,$00,$00,$00\r
+*\r
+       .dc.b   $00,$00,$00,$00,$00,$00\r
+       .dc.b   $00,$00,$00,$00,$00,$00\r
+       .dc.b   $00,$00,$00,$00,$00,$00\r
+       .dc.b   $00,$00,$00,$00,$00,$00\r
+*\r
+*\r
+*      .DC.B   $00,$00,$00,$00,$00,$00         ;COPYRIGHT\r
+*      .DC.B   $00,$00,$00,$00,$00,$00\r
+*      .DC.B   $00,$00,$00,$00,$00,$00         ;ATARI\r
+*      .DC.B   $00,$00,$00,$00,$00,$00\r
+*\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ;ADVANCED\r
+*\r
+       .dc.b   $00,$80,$80,$00,$00,$00,$00,$00,$80,$00,$00,$88,$08,$82,$08,$22\r
+       .dc.b   $00,$02,$00,$82,$02,$00\r
+*\r
+*      .DC.B   $82,$82,$08,$00,$2A,$2A,$88,$00,$00,$00 ;EE\r
+*      .DC.B   $00,$00,$00,$00,$20,$08,$00,$00,$00,$00,$00,$00\r
+*\r
+*  the following was added to make the source generate what is in the rom\r
+       .dc.b   $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff ;added by dave\r
+\r
+       .ORG     CHARS+$A00\r
+       .DC.B   0,0,0,0,0,0,0,0,0,0,0,0\r
+       .DC.B   $44,$10,$40,$04,$04,$04,$44,$10,$44,$04\r
+       .DC.B   $40,$44,$01,$01,$10,$11,$00,$41,$00,$00,$40\r
+       .DC.B   $40,$44,$01,$01,$10,$11,$00,$41,$00,$00,$04\r
+       .DC.B   $40,$44,$41,$10,$00\r
+       .DC.B   $40,$44,$04,$44,$44,$00,$04,$11,$01,$10,$04,$10\r
+       .DC.B   $00,$0A,$B5,$70,$35,$70\r
+       .DC.B   $B5,$70,$00,$02\r
+       .DC.B   $AA,$B5,$C0,$02\r
+       .DC.B   $D5,$C0,$00,$08\r
+       .DC.B   $D5,$C0,$D5,$C2\r
+       .DC.B   $D5,$C0,$D5,$C2\r
+       .DC.B   $B5,$C0\r
+       .DC.B   $B5,$70,$3D,$70\r
+       .DC.B   $B5,$70,$00,$0A,$80,$00\r
+       .DC.B   $00,$00,$C0,$00 ;STARS+2 -> COLOR 3, COLUMN 3\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00             ;NOVICE\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00             ;INTERMEDIATE\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00,$00 ;EXPERT\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00             ;ONE PLAYER\r
+       .DC.B   $00,$00,$00,$00,$00\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00             ;TWO PLAYER\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00             ;TEAM PLAY\r
+       .DC.B   $00,$00,$00,$00\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00             ;COMP PLAY\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00\r
+       .DC.B   $00,$00,$00,$00,$00\r
+*\r
+       .dc.b   $00,$00,$00,$00,$00,$00\r
+       .dc.b   $00,$00,$00,$00,$00,$00\r
+       .dc.b   $00,$00,$00,$00,$00,$00\r
+       .dc.b   $00,$00,$00,$00,$00,$00\r
+*\r
+*\r
+*      .DC.B   $00,$00,$00,$00,$00,$00         ;COPYRIGHT\r
+*      .DC.B   $00,$00,$00,$00,$00,$00\r
+*      .DC.B   $00,$00,$00,$00,$00,$00         ;ATARI\r
+*      .DC.B   $00,$00,$00,$00,$00,$00\r
+*\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ;ADVANCED\r
+*\r
+       .dc.b   $00,$80,$80,$00,$00,$00,$00,$02,$00,$00,$00,$A0,$08,$82,$08,$28\r
+       .dc.b   $00,$02,$00,$80,$02,$00\r
+*\r
+*      .DC.B   $82,$AA,$08,$00,$20,$02,$0A,$00,$00,$00 ;EE\r
+*      .DC.B   $00,$00,$00,$00,$20,$0A,$00,$00,$00,$00,$00,$00\r
+*\r
+*  the following was added to make the source generate what is in the rom\r
+       .dc.b   $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff ;added by dave\r
+\r
+       .ORG     CHARS+$B00\r
+       .DC.B   0,0,0,0,0,0,0,0,0,0,0,0\r
+       .DC.B   $44,$10,$40,$04,$54,$04,$44,$10,$44,$54\r
+       .DC.B   $55,$44,$01,$55,$10,$11,$54,$55,$00,$01,$40\r
+       .DC.B   $55,$44,$01,$55,$10,$11,$54,$55,$00,$01,$54\r
+       .DC.B   $40,$44,$41,$15,$40\r
+       .DC.B   $55,$45,$54,$55,$45,$50,$05,$51,$01,$15,$45,$50\r
+       .DC.B   $00,$00,$35,$F0,$3D,$70\r
+       .DC.B   $35,$F0,$00,$00\r
+       .DC.B   $00,$35,$C0,$00\r
+       .DC.B   $D7,$C0,$00,$00\r
+       .DC.B   $D7,$C0,$F5,$C0\r
+       .DC.B   $D7,$C0,$F5,$C0\r
+       .DC.B   $35,$C0\r
+       .DC.B   $35,$F0,$3F,$70\r
+       .DC.B   $35,$F0,$00,$00,$00,$00\r
+       .DC.B   $00,$00,$00,$00\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00             ;NOVICE\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00             ;INTERMEDIATE\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00,$00 ;EXPERT\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00             ;ONE PLAYER\r
+       .DC.B   $00,$00,$00,$00,$00\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00             ;TWO PLAYER\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00             ;TEAM PLAY\r
+       .DC.B   $00,$00,$00,$00\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00             ;COMP PLAY\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00\r
+       .DC.B   $00,$00,$00,$00,$00\r
+*\r
+       .dc.b   $00,$00,$00,$00,$00,$00\r
+       .dc.b   $00,$00,$00,$00,$00,$00\r
+       .dc.b   $00,$00,$00,$00,$00,$00\r
+       .dc.b   $00,$00,$00,$00,$00,$00\r
+*\r
+*      .DC.B   $00,$00,$00,$00,$00,$00         ;COPYRIGHT\r
+*      .DC.B   $00,$00,$00,$00,$00,$00\r
+*      .DC.B   $00,$00,$00,$00,$00,$00         ;ATARI\r
+*      .DC.B   $00,$00,$00,$00,$00,$00\r
+*\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ;ADVANCED\r
+*\r
+       .dc.b   $08,$82,$00,$00,$00,$00,$00,$02,$00,$20,$00,$20,$02,$82,$00,$08\r
+       .dc.b   $00,$82,$00,$80,$02,$00\r
+*\r
+*      .DC.B   $80,$02,$00,$00,$20,$02,$08,$80,$00,$00 ;EE\r
+*      .DC.B   $00,$00,$80,$00,$20,$02,$00,$00,$00,$00,$00,$00\r
+*\r
+*  the following was added to make the source generate what is in the rom\r
+       .dc.b   $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff ;added by dave\r
+\r
+       .ORG     CHARS+$C00\r
+       .DC.B   0,0,0,0,0,0,0,0,0,0,0,0\r
+       .DC.B   $44,$10,$54,$14,$44,$54,$54,$04,$54,$44\r
+       .DC.B   0,0,0,0,0,0,0,0,0,0,0\r
+       .DC.B   0,0,0,0,0,0,0,0,0,0,0\r
+       .DC.B   0,0,0,0,0\r
+       .DC.B   0,0,0,0,0,0,0,0,0,0,0,0\r
+       .DC.B   $00,$00,$B7,$FF,$FF,$7A\r
+       .DC.B   $B7,$FF,$FF,$A8\r
+       .DC.B   $FF,$FD,$FF,$FA\r
+       .DC.B   $DF,$FF,$FF,$A8\r
+       .DC.B   $DF,$FF,$FD,$EA\r
+       .DC.B   $DF,$FF,$FD,$EA\r
+       .DC.B   $FD,$FA\r
+       .DC.B   $B7,$FF,$F5,$7A\r
+       .DC.B   $B7,$FF,$FF,$A8,$00,$00\r
+       .DC.B   $00,$00,$00,$00\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00             ;NOVICE\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00             ;INTERMEDIATE\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00,$00 ;EXPERT\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00             ;ONE PLAYER\r
+       .DC.B   $00,$00,$00,$00,$00\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00             ;TWO PLAYER\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00             ;TEAM PLAY\r
+       .DC.B   $00,$00,$00,$00\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00             ;COMP PLAY\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00\r
+       .DC.B   $00,$00,$00,$00,$00\r
+*\r
+       .dc.b   $00,$00,$00,$00,$00,$00\r
+       .dc.b   $00,$00,$00,$00,$00,$00\r
+       .dc.b   $00,$00,$00,$00,$00,$00\r
+       .dc.b   $00,$00,$00,$00,$00,$00\r
+\r
+*      .DC.B   $00,$00,$00,$00,$00,$00         ;COPYRIGHT\r
+*      .DC.B   $00,$00,$00,$00,$00,$00\r
+*      .DC.B   $00,$00,$00,$00,$00,$00         ;ATARI\r
+*      .DC.B   $00,$00,$00,$00,$00,$00\r
+*\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ;ADVANCED\r
+*\r
+       .dc.b   $02,$88,$00,$00,$00,$00,$00,$02,$00,$20,$00,$00,$00,$00,$00,$00\r
+       .dc.b   $20,$22,$00,$82,$02,$08\r
+*\r
+*      .DC.B   $80,$00,$00,$00,$20,$00,$08,$80,$00,$00 ;EE\r
+*      .DC.B   $00,$00,$20,$28,$A0,$02,$80,$00,$00,$00,$00,$00\r
+*\r
+*  the following was added to make the source generate what is in the rom\r
+       .dc.b   $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff ;added by dave\r
+\r
+       .ORG     CHARS+$D00\r
+       .DC.B   0,0,0,0,0,0,0,0,0,0,0,0\r
+       .DC.B   $44,$10,$04,$04,$44,$40,$40,$04,$44,$44\r
+       .DC.B   0,0,0,0,0,0,0,0,0,0,0\r
+       .DC.B   0,0,0,0,0,0,0,0,0,0,0\r
+       .DC.B   0,0,0,0,0\r
+       .DC.B   0,0,0,0,0,0,0,0,0,0,0,0\r
+       .DC.B   $00,$00,$35,$55,$55,$70\r
+       .DC.B   $35,$55,$57,$00\r
+       .DC.B   $D5,$55,$55,$70\r
+       .DC.B   $D5,$55,$57,$00\r
+       .DC.B   $D5,$55,$55,$C0\r
+       .DC.B   $D5,$55,$55,$C0\r
+       .DC.B   $D5,$70\r
+       .DC.B   $35,$55,$55,$70\r
+       .DC.B   $35,$55,$57,$00,$00,$00\r
+       .DC.B   $00,$00,$00,$00\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00             ;NOVICE\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00             ;INTERMEDIATE\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00,$00 ;EXPERT\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00             ;ONE PLAYER\r
+       .DC.B   $00,$00,$00,$00,$00\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00             ;TWO PLAYER\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00             ;TEAM PLAY\r
+       .DC.B   $00,$00,$00,$00\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00             ;COMP PLAY\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00\r
+       .DC.B   $00,$00,$00,$00,$00\r
+*\r
+       .dc.b   $00,$00,$00,$00,$00,$00\r
+       .dc.b   $00,$00,$00,$00,$00,$00\r
+       .dc.b   $00,$00,$00,$00,$00,$00\r
+       .dc.b   $00,$00,$00,$00,$00,$00\r
+*\r
+*\r
+*      .DC.B   $00,$00,$00,$00,$00,$00         ;COPYRIGHT\r
+*      .DC.B   $00,$00,$00,$00,$00,$00\r
+*      .DC.B   $00,$00,$00,$00,$00,$00         ;ATARI\r
+*      .DC.B   $00,$00,$00,$00,$00,$00\r
+*\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ;ADVANCED\r
+*\r
+       .dc.b   $00,$A0,$00,$00,$00,$00,$00,$00,$80,$80,$00,$00,$00,$00,$00,$00\r
+       .dc.b   $20,$0A,$00,$82,$02,$02\r
+*\r
+*      .DC.B   $20,$00,$00,$00,$08,$20,$08,$80,$00,$00 ;EE\r
+*      .DC.B   $00,$00,$2A,$A2,$80,$00,$80,$00,$00,$00,$00,$00\r
+*\r
+*  the following was added to make the source generate what is in the rom\r
+       .dc.b   $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff ;added by dave\r
+\r
+       .ORG     CHARS+$E00\r
+       .DC.B   0,0,0,0,0,0,0,0,0,0,0,0\r
+       .DC.B   $54,$50,$54,$54,$40,$54,$54,$54,$54,$54\r
+       .DC.B   0,0,0,0,0,0,0,0,0,0,0\r
+       .DC.B   0,0,0,0,0,0,0,0,0,0,0\r
+       .DC.B   0,0,0,0,0\r
+       .DC.B   0,0,0,0,0,0,0,0,0,0,0,0\r
+       .DC.B   $00,$00,$35,$55,$55,$70\r
+       .DC.B   $35,$55,$57,$00\r
+       .DC.B   $D5,$55,$55,$70\r
+       .DC.B   $D5,$55,$57,$00\r
+       .DC.B   $D5,$55,$55,$C0\r
+       .DC.B   $D5,$55,$55,$C0\r
+       .DC.B   $D5,$70\r
+       .DC.B   $35,$55,$55,$C0\r
+       .DC.B   $35,$55,$57,$00,$00,$00\r
+       .DC.B   $00,$00,$00,$00\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00             ;NOVICE\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00             ;INTERMEDIATE\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00,$00 ;EXPERT\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00             ;ONE PLAYER\r
+       .DC.B   $00,$00,$00,$00,$00\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00             ;TWO PLAYER\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00             ;TEAM PLAY\r
+       .DC.B   $00,$00,$00,$00\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00             ;COMP PLAY\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00\r
+       .DC.B   $00,$00,$00,$00,$00\r
+*\r
+       .dc.b   $00,$00,$00,$00,$00,$00\r
+       .dc.b   $00,$00,$00,$00,$00,$00\r
+       .dc.b   $00,$00,$00,$00,$00,$00\r
+       .dc.b   $00,$00,$00,$00,$00,$00\r
+*\r
+*\r
+*      .DC.B   $00,$00,$00,$00,$00,$00         ;COPYRIGHT\r
+*      .DC.B   $00,$00,$00,$00,$00,$00\r
+*      .DC.B   $00,$00,$00,$00,$00,$00         ;ATARI\r
+*      .DC.B   $00,$00,$00,$00,$00,$00\r
+*\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ;ADVANCED\r
+*\r
+       .dc.b   $00,$20,$00,$00,$00,$00,$00,$00,$82,$80,$00,$00,$00,$00,$00,$00\r
+       .dc.b   $20,$0A,$00,$80,$02,$02\r
+*\r
+*      .DC.B   $A0,$00,$00,$00,$02,$A0,$08,$80,$00,$00 ;EE\r
+*      .DC.B   $00,$00,$0A,$80,$80,$00,$A0,$00,$00,$00,$00,$00\r
+*\r
+*  the following was added to make the source generate what is in the rom\r
+       .dc.b   $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff ;added by dave\r
+\r
+       .ORG     CHARS+$F00\r
+       .DC.B   0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\r
+       .DC.B   0,0,0,0,0,0,0,0,0,0,0\r
+       .DC.B   0,0,0,0,0,0,0,0,0,0,0\r
+       .DC.B   0,0,0,0,0\r
+       .DC.B   0,0,0,0,0,0,0,0,0,0,0,0\r
+       .DC.B   $00,$00,$35,$55,$55,$70\r
+       .DC.B   $35,$55,$57,$00\r
+       .DC.B   $D5,$55,$55,$70\r
+       .DC.B   $D5,$55,$57,$00\r
+       .DC.B   $D5,$55,$55,$C0\r
+       .DC.B   $D5,$55,$55,$C0\r
+       .DC.B   $D5,$70\r
+       .DC.B   $35,$55,$57,$00\r
+       .DC.B   $35,$55,$57,$00,$00,$00\r
+       .DC.B   $00,$00,$00,$40 ;STARS+3 -> COLOR 1, COLUMN 1\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00             ;NOVICE\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00             ;INTERMEDIATE\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00,$00 ;EXPERT\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00             ;ONE PLAYER\r
+       .DC.B   $00,$00,$00,$00,$00\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00             ;TWO PLAYER\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00             ;TEAM PLAY\r
+       .DC.B   $00,$00,$00,$00\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00             ;COMP PLAY\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00\r
+       .DC.B   $00,$00,$00,$00,$00\r
+*\r
+       .dc.b   $00,$00,$00,$00,$00,$00\r
+       .dc.b   $00,$00,$00,$00,$00,$00\r
+       .dc.b   $00,$00,$00,$00,$00,$00\r
+       .dc.b   $00,$00,$00,$00,$00,$00\r
+*\r
+*\r
+*      .DC.B   $00,$00,$00,$00,$00,$00         ;COPYRIGHT\r
+*      .DC.B   $00,$00,$00,$00,$00,$00\r
+*      .DC.B   $00,$00,$00,$00,$00,$00         ;ATARI\r
+*      .DC.B   $00,$00,$00,$00,$00,$00\r
+*\r
+       .DC.B   $00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ;ADVANCED\r
+*\r
+       .dc.b   $00,$08,$00,$00,$00,$00,$00,$00,$28,$00,$00,$00,$00,$00,$00,$00\r
+       .dc.b   $08,$02,$00,$80,$00,$02\r
+*\r
+*      .DC.B   $20,$00,$00,$00,$00,$00,$0A,$00,$00,$00 ;EE\r
+*      .DC.B   $00,$00,$00,$00,$00,$00,$2A,$80,$00,$00,$00,$00\r
+*\r
+ENDSTAMP:\r
+*\r
+*  the following was added to make the source generate what is in the rom\r
+       .dc.b   $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff ;added by dave\r
diff --git a/OS7800.S b/OS7800.S
new file mode 100644 (file)
index 0000000..8d30336
--- /dev/null
+++ b/OS7800.S
@@ -0,0 +1,398 @@
+*\r
+*\r
+*\r
+       .subttl         "Remnants of old Maria OS"\r
+*\r
+ramcode        equ     $2300           ;AREA RESERVED FOR CODE\r
+tiaram equ     $480\r
+*\r
+*\r
+;\r
+;  STELLA (TIA) REGISTER ADDRESSES USED BY THIS MODULE\r
+;\r
+VBLANK equ     $01     ; BIT        1  VERTICAL BLANK SET-CLR\r
+TWSYNC equ     $02     ; STROBE        WAIT FOR HORIZ BLANK\r
+RSYNC  equ     $03     ; STROBE        RESET HORIZ SYNC COUNTER\r
+COLUP0 equ     $06     ; BITS 7654321  COLOR(4)-LUM(3) PLAYER 0\r
+COLUPF equ     $08     ; BITS 7654321  COLOR(4)-LUM(3) PLAYFIELD\r
+COLUBK equ     $09     ; BITS 7654321  COLOR(4)-LUM(3) BACKGROUND\r
+PF2    equ     $0F     ; BITS ALL      PLAYFIELD REG BYTE 2\r
+RESP0  equ     $10     ; STROBE        RESET PLAYER 0\r
+RESP1  equ     $11     ; STROBE        RESET PLAYER 1\r
+GRP0   equ     $1B     ; BITS ALL      GRAPHICS FOR PLAYER 0\r
+GRP1   equ     $1C     ; BITS ALL      GRAPHICS FOR PLAYER 1\r
+CXCLR  equ     $2C     ; STROBE        CLEAR COLLISION LATCHES\r
+;\r
+;  READ ADDRESSES -    BIT 7   BIT 6 (ONLY)\r
+;\r
+CXP0FB equ     $32     ;       P0.PF   P0.BL\r
+CXP1FB equ     $33     ;       P1.PF   P1.BL\r
+*\r
+fakedli        equ     $2700\r
+fakelist:\r
+       .dc.b   $0,$40,$f0,$1f,$bb\r
+       .dc.b   0,0\r
+       .dc.b   $8f,$27,0\r
+*\r
+*\r
+*\r
+*\r
+*\r
+startup:\r
+       SEI                     ;INITIALIZE\r
+       CLD\r
+*\r
+       LDA     #$02            ;PUT BASE UNIT INTO MARIA ENABLE\r
+       STA     PTCTRL\r
+*\r
+       ldx     #$ff\r
+       txs\r
+*\r
+*\r
+       LDA     #$7F\r
+       STA     CTRL            ;TURN OFF DMA\r
+       LDA     #$00\r
+       STA     BACKGRND        ;BACKGROUND COLOR TO BLACK\r
+*\r
+*\r
+*\r
+*   copy 2600 code to tia RAM\r
+*\r
+       LDX     #$7F            ;LOCK CART IN 2600 MODE, CART ON\r
+L2LOOP:\r
+       LDA     SYNC,X          ;MOVE CODE TO RAM\r
+       STA     tiaram,X        ;MOVE INTO 6532 RAM\r
+       DEX\r
+       BPL     L2LOOP\r
+*\r
+*\r
+*   Copy 7800 validation code from rom to ram..\r
+*\r
+*\r
+       ldx     #ROMEND-ROMCODE\r
+copylp:\r
+       lda     ROMCODE-1,x\r
+       sta     ramcode-1,x\r
+       dex\r
+       bne     copylp\r
+*\r
+*  Now, zero out the TIA\r
+*\r
+       lda     #0              ;zero out the TIA\r
+       tax\r
+tia0loop:\r
+       sta     VBLANK,x\r
+       inx\r
+       cpx     #CXCLR\r
+       bne     tia0loop\r
+*\r
+       LDA     #$02            ;PUT BASE UNIT INTO MARIA ENABLE\r
+       STA     PTCTRL\r
+*\r
+*\r
+*   7800 One-on-One Basketball needs some ram initialized to $ff (for shame!!!)\r
+*\r
+*\r
+*  Now make One-on-One Basketball happy\r
+*\r
+       lda     #$ff\r
+       ldx     #$3f\r
+framlp:\r
+       sta     $2000,x\r
+       sta     $2100,x\r
+       dex\r
+       bpl     framlp\r
+*\r
+*   Now load up some dumb display list in case maria needs some practice\r
+*\r
+       ldx     #9\r
+fakeload:\r
+       lda     fakelist,x\r
+       sta     fakedli,x\r
+       dex\r
+       bpl     fakeload\r
+*\r
+       inx                     ;x=0\r
+       ldy     #80\r
+fakeinc:\r
+       lda     fakedli+7,x\r
+       sta     fakedli+10,x\r
+       inx\r
+       dey\r
+       bne     fakeinc\r
+*\r
+       jmp     ramcode+(CARTTEST-ROMCODE)      ;jump in at CARTTEST\r
+*\r
+*\r
+*   the following code is copied to ram for execution\r
+*\r
+ROMCODE:\r
+NOCART:\r
+       lda     #2\r
+       sta     PTCTRL                  ;turn "security" ROM on\r
+       JMP     ASTEROID                ;NO CART, do asteroids\r
+*\r
+CARTTEST:\r
+       LDA     #$16                    ;TURN EXTERNAL CART ON\r
+       STA     PTCTRL\r
+\r
+       LDY     #$FF\r
+       LDX     #$7F                    ;SEE IF A CART PLUGGED IN\r
+CTSTLOOP:\r
+       LDA     $FE00,X\r
+       CMP     $FD80,Y\r
+       BNE     NOCART\r
+       DEY\r
+       DEX\r
+       BPL     CTSTLOOP                ;X LEFT = FF, Y LEFT = 7F\r
+*\r
+       LDA     $FFFC                   ;SEE IF START AT FFFF\r
+       AND     $FFFD\r
+       CMP     #$FF\r
+       BEQ     NOCART                  ;ALL LINES DRAWN HIGH, NO CART\r
+       LDA     $FFFC                   ;SEE IF START AT 0000\r
+       ORA     $FFFD\r
+       BEQ     NOCART                  ;ALL LINES DRAWN LOW, NO CART\r
+*\r
+       LDA     $FFF8                   ;CHECK FOR REGION VERIFICATION\r
+       ORA     #$fe\r
+       CMP     #$FF\r
+       BNE     CART26\r
+       LDA     $FFF8                   ;TOP 4 BITS OF FFF8 SHOULD BE 0F0\r
+       EOR     #$F0\r
+       AND     #$F0\r
+       BNE     CART26\r
+       LDA     $FFF9                   ;SEE IF MARIA SIGNATURE EXISTS\r
+       AND     #$0B                    ;0X7 OR 0X3 VALID\r
+       CMP     #$03\r
+       BNE     CART26\r
+       LDA     $FFF9                   ;GET BOTTOM OF CART ADDRESS\r
+       AND     #$F0\r
+       cmp     #$40                    ;not too low\r
+       bcc     CART26\r
+       sbc     #1\r
+       cmp     $fffd\r
+       bcs     CART26\r
+*\r
+       lda     $1BEA           ;2600 ROM responds to this address\r
+       eor     #$FF\r
+       sta     $1BEA           ;stuff some data in MARIA ram space\r
+       tay\r
+*\r
+       ldx     #5              ;check hardware vectors\r
+vecheck:\r
+       lda     $FFFA,x         ;   2600 should always\r
+       cmp     $DFFA,x         ;     read the same data\r
+       bne     SETMARIA        ;       in DXXX as in FXXX\r
+       dex\r
+       bpl     vecheck\r
+*\r
+*  Some 7800 carts get here...\r
+*\r
+       cpy     $1BEA           ;does this act like 7800 ram or 2600 ROM?\r
+       bne     CART26\r
+*\r
+*     We favor 7800 more than before so 2600 might get run in 7800 mode \r
+*     ...may need to do more 2600/7800 discrimination here...\r
+*\r
+*\r
+*\r
+*  we must be 7800 cart;  go to it...\r
+*\r
+SETMARIA:\r
+       lda     #02\r
+       sta     PTCTRL          ;turn on internal rom (for NMI processing)\r
+*\r
+       jsr     ramcode+(wait00-ROMCODE)        ;wait for V-blank start\r
+*\r
+       lda     #$27            ;install our practice zone list\r
+       sta     DPPH\r
+       lda     #07\r
+       sta     DPPL\r
+*\r
+       lda     #$43\r
+       sta     NMICTRL         ;tell ASTEROIDS nmi routine to do nothing \r
+       sta     CTRL            ;turn maria on in 320 mode\r
+*\r
+       ldx     #1\r
+frame2:\r
+       jsr     ramcode+(wait00-ROMCODE)        ;wait for V-blank start\r
+       dex                     ;do 2 frames of this stuff\r
+       bpl     frame2\r
+*\r
+       lda     #$60\r
+       sta     CTRL            ;turn maria off\r
+*\r
+       LDX     #$16    ;PUT CART IN 7800 MODE, CART ON\r
+       STX     PTCTRL\r
+       TXS\r
+       SED\r
+       JMP     ($FFFC) ;VECTOR INTO THE CART IN 3600 MODE\r
+*\r
+*  tests indicate we must be a 2600 cart...\r
+*\r
+CART26:\r
+       LDA     #$02\r
+       STA     PTCTRL                  ;TURN SECURITY ROM ON\r
+       jmp     tiaram                  ;perform this from tia ram\r
+*\r
+*\r
+*   This is a 7800 wait-for-beginning-of V-blank routine\r
+*\r
+wait00:\r
+       bit     MSTAT\r
+       bmi     wait00\r
+wait01:\r
+       bit     MSTAT\r
+       bpl     wait01\r
+       rts\r
+*\r
+ROMEND:\r
+*\r
+*\r
+; First zero out TIA without doing a TWSYNC. This must be done in a loop that\r
+; counts up so that graphics are turned off before the collision registers are\r
+; cleared. RSYNC should turn case C into a case A. Note also that the stores\r
+; of zero puts the system in TIA space but does not lock it there. This code\r
+; must all run out of 6532 RAM since the memory map will change as we change\r
+; mode.        The 6532 RAM exists in all memory maps.\r
+*\r
+SYNC:\r
+       LDA     #0\r
+       TAX\r
+       STA     VBLANK\r
+ZEROLP:\r
+       STA     RSYNC,X\r
+       INX\r
+       CPX     #(CXCLR-RSYNC+1)\r
+       BNE     ZEROLP\r
+\r
+; Test now for a possible E case. In some E cases, TWSYNCs do not work properly\r
+; and this must be detected. In an E case failure, the LDA is prefetched and\r
+; the 04 following it is skipped over and NOP ($EA) is loaded into A causing\r
+; the branch on minus to be taken. If this happens the E case can now be\r
+; corrected.   NOTE: All E cases do not get trapped here and must be handled\r
+; latter by collisions.\r
+       STA     TWSYNC\r
+       LDA     #4\r
+       NOP\r
+       BMI     ECASE\r
+\r
+; Position player 0 on the left side of the screen and player 1 on the right\r
+; side of the screen so that they will overlap (or not overlap as the case may\r
+; be) playfield 2 that has a copy on both sides of the screen. Resets occur at\r
+; the 38th and 65th cycle.\r
+       LDX     #4\r
+STALL4:\r
+       DEX                             ;Stall loop\r
+       BPL     STALL4\r
+       TXS                             ;Set the stack to 0FF for stall JSRs\r
+       STA     RESP0+$100              ;38th cylce\r
+       JSR     DUMMY+1-SYNC+$480       ;12 cycle stall\r
+       JSR     DUMMY+1-SYNC+$480       ;Ditto\r
+       STA     RESP1   ;65th cycle\r
+\r
+; Turn on graphics to cause the collisions\r
+       STA     GRP0    ;68th cycle\r
+       STA     GRP1    ;71st cycle\r
+       STA     PF2     ;74th cycle\r
+\r
+; Stall an entire scan line to allow collisions to take place. The E case test\r
+; should follow all TWSYNCs to be safe.\r
+       NOP             ;76th cycle\r
+       STA     TWSYNC  ;3rd cycle\r
+       LDA     #0\r
+       NOP\r
+       BMI     ECASE\r
+\r
+; Test now for a collision between player 1 and playfield.     If there is no\r
+; collision, we must shift the clock once. If there is a collision, we must\r
+; do further testing.\r
+       BIT     CXP1FB-$30\r
+       BMI     NOCOL2\r
+\r
+; This section shifts the clock once.  Storing a 2 switches the system into\r
+; MARIA MODe and the following store to 0FXXX causes a clock speed-up for one\r
+; cycle and thus shifts the clock once.\r
+ECASE:\r
+       LDA     #2\r
+       STA     COLUBK  ;changes to MARIA MODe\r
+       STA     $F112\r
+       BNE     DONE    ;JMP\r
+\r
+; Test now for a collision between player 0 and playfield.     If there is no\r
+; collision, we must shift the clock twice. If there is a collision, we must\r
+; do further testing.\r
+NOCOL2:\r
+       BIT     CXP0FB-$30\r
+       BMI     NOCOL0\r
+\r
+; This section shifts the clock twice. Storing a 2 switches the system into\r
+; MARIA MODe and the following stores to 0FXXX causes two clock speed-ups for\r
+; one cycle and thus shifts the clock twice.\r
+       LDA     #2\r
+       STA     COLUP0  ;changes to MARIA MODe\r
+       STA     $F118\r
+DUMMY:\r
+       STA     $F460   ;Note that the 060 is a RTS\r
+       BNE     DONE\r
+\r
+; If we've fotten to this point the only possible failure left is an E case that\r
+; was not detected by the TWSYNC trap. Test for this by clearing the collision\r
+; registers, shifting the graphics for player 0 to the left one pixel by\r
+; changing GRP0 from a 4 to an 8, and then retesting for a collision.  If there\r
+; is still a collision between player 0 and the playfield, we have an E case,\r
+; otherwise we are done. Be careful not to test for collisions until after they\r
+; occur (about the 40th cycle).\r
+NOCOL0:\r
+       STA     CXCLR                   ;21st cycle\r
+       LDA     #8                      ;23rd cycle - one pixel to the left\r
+       STA     GRP0                    ;26th cycle\r
+       JSR     DUMMY+1-SYNC+$480       ;12 cycle stall\r
+       NOP                             ;40th cycle - just to be safe\r
+       BIT     CXP0FB-$30              ;43rd cycle\r
+       BMI     ECASE\r
+\r
+; We are now synced and should lock ourselves into TIA mopde with the external\r
+; cart enabled and jump to the reset vector.   Thanks for stopping by...\r
+DONE:\r
+       LDA     #$FD\r
+       STA     COLUPF  ;Change MODes to TIA with EXT and lock.\r
+       JMP     ($FFFC)\r
+NROM:\r
+*\r
+*  some necessary code from HISCORE.S module that was omitted...\r
+*\r
+HSCSUCK:\r
+       JSR     ZEROHS\r
+*\r
+HSCDOENT:\r
+*\r
+* HSCSETDM -- SET DIFF/MODE LEVEL ARGUMENT BASED ON DIFF AND MODE\r
+*\r
+HSCSETDM:\r
+       LDA     MODE            ;COMPUTE DIFF/MODE LEVEL VALUE BYTE\r
+       BPL     ZHSCMOK\r
+       LDA     #0\r
+ZHSCMOK:\r
+       ASL\r
+       ASL\r
+       CLC\r
+       ADC     DIFF\r
+       STA     TEMP            ;SAVE IT WHERE WE CAN INSERT LATER\r
+HSCSHOW:\r
+       LDA     #1\r
+HSCRET:\r
+       RTS\r
+*\r
+*\r
+HSCTAB:\r
+       .dc.b   $20,$20,$20,$20,$20,$20,$20,$20,$20,$20\r
+       .dc.b   $4F,$68,$21,$20,$57,$68,$61,$74,$20,$61\r
+       .dc.b   $20,$66,$69,$6E,$65,$20,$62,$6F,$79,$20   \r
+       .dc.b   $69,$73,$20,$44,$61,$76,$65,$20,$53,$74   \r
+       .dc.b   $61,$75,$67,$61,$73,$2E           \r
+       .dc.b   $20,$20,$20,$20,$20,$20,$20,$20,$20\r
+*\r
+CODEDIF        equ     ROMCODE-ramcode         ;DIFFERENCE BETWEEN OLD AND NEW ADDRESS\r
+*\r
diff --git a/RASTA.S b/RASTA.S
new file mode 100644 (file)
index 0000000..c2aa077
--- /dev/null
+++ b/RASTA.S
@@ -0,0 +1,296 @@
+*         1900    200684\r
+*\r
+*\r
+** RASTLOAD.S *\r
+** ASTEROIDS FOR THE ATARI 3600. **\r
+** THIS FILE CONTAINS THE LOADER ASSUMING 16 HIGH ZONES. *\r
+\r
+** TRASHES ALL REGISTERS, TEMPI+0,+1,+2,+3,+4 **\r
+** USES FREE THRU FREE+11 AS POINTERS TO NEXT FREE POSITION IN HEADER. **\r
+\r
+LOADER    LDA     #4                     ;SET POINTER PAST FIRST HEADER FOR\r
+          LDX     #11                    ; EACH DISPLAY LIST\r
+ZAPFREE   STA     FREE,X\r
+          DEX\r
+          BPL     ZAPFREE\r
+\r
+          LDX     #35\r
+LOADLOOP  LDA     STATUS,X               ;CHECK STATUS OF EACH OBJECT\r
+          BEQ     NEXTLOAD               ;CHECK IF ZERO.\r
+          CMP     #$FF                   ;FORGET IF NULL, FF.\r
+          BEQ     NEXTLOAD               ;OTHERWISE, LOAD IT\r
+\r
+          AND     #$0F                   ;CHECK LOW NYBBLE\r
+          CMP     #6                     ;IF = 6 THEN SHOT\r
+          BNE     LOADOBJ\r
+\r
+LOADSHOT  LDA     YPOSH,X                ;A <- Y POSITION OF OBJECT\r
+          EOR     #$FF                   ;NEGATE POSITION\r
+          AND     #$0F                   ;MOD 16 IS LINE IN ZONE\r
+          STA     TEMPI+4\r
+          LDA     YPOSH,X                ;A <- Y POSITION OF OBJECT\r
+          LSR     A                      ;DIV 16 IS WHICH ZONE\r
+          LSR     A\r
+          LSR     A\r
+          LSR     A\r
+          TAY                            ;Y <- WHICH ZONE\r
+          LDA     FREE,Y                 ;A <- FREE POINTER FOR THAT ZONE\r
+          CLC\r
+          ADC     LOWZONE,Y\r
+          STA     TEMPI                  ;TEMPI = LO ADDR FOR FIRST FREE POS\r
+          LDA     HIGHZONE,Y\r
+          STA     TEMPI+1                ;TEMPI+1 = HI ADDRESS\r
+          LDA     FREE,Y                 ;A <- FREE POINTER FOR THAT ZONE\r
+;         CLC                            ;OPTIONAL\r
+          ADC     #4                     ;INCREMENT FREE POINTER\r
+          STA     FREE,Y\r
+          LDY     #0\r
+          LDA     #L(SHOT1)\r
+          STA     (TEMPI),Y              ;STORE LOW ADDRESS IN HEADER - 1ST BYTE\r
+          INY\r
+          LDA     #$7F                   ;PALETTE 4, WIDTH 1\r
+          STA     (TEMPI),Y              ;STORE IN HEADER - 2ND BYTE\r
+          INY\r
+          LDA     TEMPI+4                ;GET LINE IN ZONE\r
+          ORA     #H(GRAPHICS)           ;ADD TO START OF GRAPHICS DATA\r
+          STA     (TEMPI),Y              ;STORE HIGH ADDR IN HEADER - 3RD BYTE\r
+          INY\r
+          LDA     XPOSH,X                ;GET HORIZONTAL POSITION\r
+          STA     (TEMPI),Y              ;STORE IN HEADER - 4TH BYTE\r
+\r
+NEXTLOAD  DEX                            ;DECREMENT INDEX\r
+          BPL     LOADLOOP               ;CONTINUE IF NOT FINISHED\r
+          JMP     LOADSCOR               ;LOAD SCORE AT END OF DL IF DONE\r
+\r
+* LOAD A STANDARD OBJECT INTO TWO ZONES\r
+LOADOBJ   LDA     YPOSH,X                ;A <- Y POSITION OF OBJECT\r
+          EOR     #$FF                   ;NEGATE POSITION\r
+          AND     #$F                    ;MOD 16 IS LINE IN ZONE\r
+          STA     TEMPI+4\r
+          LDA     YPOSH,X                ;A <- Y POSITION OF OBJECT\r
+          LSR     A                      ;DIV 16 IS WHICH ZONE\r
+          LSR     A\r
+          LSR     A\r
+          LSR     A\r
+          TAY                            ;Y <- WHICH ZONE\r
+          LDA     FREE,Y                 ;A <- FREE POINTER FOR THAT ZONE\r
+          CLC\r
+          ADC     LOWZONE,Y\r
+          STA     TEMPI                  ;TEMPI = LO ADDR FOR FIRST FREE POS\r
+          LDA     HIGHZONE,Y\r
+          STA     TEMPI+1                ;TEMPI+1 = HI ADDRESS\r
+          LDA     FREE,Y                 ;A <- FREE POINTER FOR THAT ZONE\r
+;         CLC                            ;OPTIONAL\r
+          ADC     #4                     ;INCREMENT FREE POINTER\r
+          STA     FREE,Y\r
+          INY                            ;ALSO LOAD INTO HIGHER ZONE\r
+          CPY     #12\r
+          BCC     YOK                    ;NEW ZONE NUMBER OK?\r
+          LDY     #0                     ;NO, RESET TO LOWEST ZONE\r
+          CLC\r
+YOK       LDA     FREE,Y                 ;A <- FREE POINTER FOR THAT ZONE\r
+          ADC     LOWZONE,Y\r
+          STA     TEMPI+2                ;TEMPI = LO ADDR FOR FIRST FREE POS\r
+          LDA     HIGHZONE,Y\r
+          STA     TEMPI+3                ;TEMPI+1 = HI ADDRESS\r
+          LDA     FREE,Y                 ;A <- FREE POINTER FOR THAT ZONE\r
+;         CLC                            ;OPTIONAL\r
+          ADC     #4                     ;INCREMENT FREE POINTER\r
+          STA     FREE,Y\r
+          LDY     #0\r
+          LDA     ACYC,X\r
+          STA     (TEMPI),Y              ;STORE LO ADDR IN HEADER - 1ST BYTE\r
+          STA     (TEMPI+2),Y\r
+          INY\r
+          LDA     PALS,X\r
+          STA     (TEMPI),Y              ;STORE PALETTE + WIDTH INFO - 2ND BYTE\r
+          STA     (TEMPI+2),Y\r
+          INY\r
+          LDA     STATUS,X               ;FOR STATUS = ICON USES CHARS AS BASE\r
+          CMP     #ICON\r
+          CLC\r
+          BNE     ZHADSTMP               ;OTHERWISE USE GRAPHICS AS BASE\r
+          LDA     TEMPI+4\r
+          ADC     #H(CHARS-$0F00)\r
+          BNE     ZSTHADDR               ;BNE = JMP HERE\r
+ZHADSTMP  LDA     TEMPI+4\r
+          ADC     #H(GRAPHICS-$0F00)\r
+ZSTHADDR  STA     (TEMPI),Y              ;STORE HI ADDR IN HEADER - 3RD BYTE\r
+;         CLC                            ;OPTIONAL\r
+          ADC     #$10\r
+          STA     (TEMPI+2),Y            ;STORE HI ADDR IN HEADER - 3RD BYTE\r
+          INY\r
+          LDA     XPOSH,X\r
+          STA     (TEMPI),Y              ;STORE HOR POS IN HEADER - 4TH BYTE\r
+          STA     (TEMPI+2),Y\r
+\r
+* THIS CODE CHECKS FOR HORIZONTAL WRAP AROUND, AND LOADS THE OBJECT AGAIN\r
+* IF IT NEEDS TO, IN ORDER TO WRAP SMOOTHLY\r
+          CMP     #XPOSMAX-8             ;IS IT WITHIN A MARGIN OF THE EDGE?\r
+          BCC     NEXTLOAD               ;NO.  IT'S OK, GO ON TO NEXT OBJECT.\r
+          CPX     #25                    ;UFO IS CURRENTLY THE ONLY EXCEPTION\r
+          BEQ     STEPNEXT               ; TO X-WRAPPING.\r
+          CMP     #$F0                   ;HAS IT BEEN WRAPPED ALREADY?\r
+          BCS     UNWRAP                 ;YES.  UNWRAP IT\r
+          SBC     #XPOSMAX               ;WRAP IT: SUBTRACT OFF A SCREEN OFFSET\r
+          STA     XPOSH,X                ;WANTS.  WRAP IT.\r
+          JMP     LOADOBJ                ;LOAD IT AGAIN\r
+UNWRAP    ADC     #XPOSMAX               ;UNWRAP IT: ADD BACK THE OFFSET\r
+          STA     XPOSH,X\r
+STEPNEXT  JMP     NEXTLOAD\r
+\r
+\r
+LOADSCOR\r
+\r
+**        HIGH SCORE\r
+          LDY     #0\r
+          LDA     FREE+11                ;GET POINTER FOR TOP ZONE\r
+          CLC\r
+          ADC     LOWZONE+11             ;GET LOW ADDR FOR DL\r
+          STA     TEMPI\r
+          LDA     HIGHZONE+11            ;GET HIGH ADDR FOR DL\r
+          STA     TEMPI+1\r
+          LDA     #L(SCORCMHS)             ;ADD TOP SCORE\r
+          STA     (TEMPI),Y              ;LOW ADDR\r
+          INY\r
+          LDA     #$60                   ;WRITE MODE 0, INDIRECT\r
+          STA     (TEMPI),Y\r
+          INY\r
+          LDA     #H(SCORCMHS)\r
+          STA     (TEMPI),Y              ;HIGH ADDR\r
+          INY\r
+          LDA     #$78                   ;PALETTE 4, WIDTH 8\r
+          STA     (TEMPI),Y\r
+          INY\r
+          LDA     #$39\r
+          STA     (TEMPI),Y              ;HOR POSITION 39 HEX\r
+\r
+**        COMBINED SCORE\r
+          LDA     MODE                   ;ONLY DO FOR MODE 1\r
+          CMP     #1\r
+          BNE     LOADP1S\r
+\r
+          INY\r
+          LDA     #L(SCORECMC)\r
+          STA     (TEMPI),Y              ;STORE LOW ADDRESS OF CHARS.\r
+          INY\r
+          LDA     #$60                   ;WRITE MODE 0, INDIRECT\r
+          STA     (TEMPI),Y\r
+          INY\r
+          LDA     #H(SCORECMC)\r
+          STA     (TEMPI),Y              ;STORE HIGH ADDRESS OF CHARS.\r
+          INY\r
+          LDA     #$90                   ;PALETTE 4, WIDTH 16\r
+          STA     (TEMPI),Y\r
+          INY\r
+          LDA     #$39                   ;HOR POS 39 HEX\r
+          STA     (TEMPI),Y\r
+\r
+**        PLAYER 1 SCORE\r
+LOADP1S   LDY     #0\r
+          LDA     FREE+10                ;GET POINTER FOR NEXT ZONE\r
+          CLC\r
+          ADC     LOWZONE+10             ;GET LOW ADDR FOR DL\r
+          STA     TEMPI\r
+          LDA     HIGHZONE+10            ;GET HIGH ADDR FOR DL\r
+          STA     TEMPI+1\r
+          LDA     #L(SCORMAP1)\r
+          STA     (TEMPI),Y              ;STORE LOW ADDRESS OF CHARS.\r
+          INY\r
+          LDA     #$60                   ;WRITE MODE 0, INDIRECT\r
+          STA     (TEMPI),Y\r
+          INY\r
+          LDA     #H(SCORMAP1)\r
+          STA     (TEMPI),Y              ;STORE HIGH ADDRESS OF CHARS.\r
+          INY\r
+          LDA     #$10                   ;PALETTE 0, WIDTH 16\r
+          STA     (TEMPI),Y\r
+          INY\r
+          LDA     #$7                    ;HOR POS 7\r
+          STA     (TEMPI),Y\r
+\r
+**        PLAYER 2 SCORE\r
+          INY\r
+          LDA     #L(SCORMAP2)\r
+          STA     (TEMPI),Y              ;STORE LOW ADDRESS OF CHARS.\r
+          INY\r
+          LDA     #$60                   ;WRITE MODE 0, INDIRECT\r
+          STA     (TEMPI),Y\r
+          INY\r
+          LDA     #H(SCORMAP2)\r
+          STA     (TEMPI),Y              ;STORE HIGH ADDRESS OF CHARS.\r
+          INY\r
+          LDA     #$30                   ;PALETTE 1, WIDTH 16\r
+          STA     (TEMPI),Y\r
+          INY\r
+          LDA     #$65                   ;HOR POS 65 HEX\r
+          STA     (TEMPI),Y\r
+\r
+          LDA     FREE+11                ;INCREMENT POINTERS\r
+          CLC\r
+          ADC     #5\r
+          STA     FREE+11\r
+\r
+          LDX     MODE\r
+          CPX     #1\r
+          BNE     ZADDZ10\r
+          CLC\r
+          ADC     #5\r
+          STA     FREE+11\r
+\r
+ZADDZ10   LDA     FREE+10\r
+          CLC\r
+          ADC     #10\r
+          STA     FREE+10\r
+\r
+LOADZERO  LDX     #11                    ;LOAD ZEROS AT END OF DISPLAY LIST, DL\r
+          LDY     #1\r
+LOADZLP   LDA     FREE,X\r
+          CLC\r
+          ADC     LOWZONE,X\r
+          STA     TEMPI\r
+          LDA     HIGHZONE,X\r
+          STA     TEMPI+1\r
+          LDA     #0\r
+          STA     (TEMPI),Y\r
+          DEX\r
+          BPL     LOADZLP\r
+          STA     LOADFLAG               ;CLEAR FLAG SINCE DONE.\r
+          RTS\r
+\r
+LOADSTAR  LDX     #11\r
+STARLOOP  LDA     LOWZONE,X              ;ESTABLISH LO ADDR\r
+          STA     TEMPI\r
+          LDA     HIGHZONE,X             ;ESTABLISH HI ADDR\r
+          STA     TEMPI+1\r
+\r
+          JSR     NEWRAND                ;PICK A RANDOM STAR (0 TO 3)\r
+          AND     #$03\r
+          CLC\r
+          ADC     #L(STARS)              ;ADD IN BASE OF STARS\r
+\r
+          LDY     #0\r
+          STA     (TEMPI),Y              ;STORE LO ADDR\r
+\r
+          INY\r
+          LDA     STARPW,X\r
+          STA     (TEMPI),Y              ;STORE PALETTE & WIDTH INFO\r
+\r
+          INY\r
+          LDA     #H(CHARS)\r
+          STA     (TEMPI),Y              ;STORE HI ADDR\r
+\r
+          JSR     NEWRAND                ;GET A RANDOM HORIZONTAL POSITION\r
+\r
+          LSR     A                      ;BANG INTO RANGE\r
+          ADC     #$10\r
+\r
+          LDY     #3\r
+          STA     (TEMPI),Y              ;STORE HOR POS\r
+\r
+          DEX\r
+          BPL     STARLOOP\r
+          RTS\r
+\r
+STARPW    DB      $7F,$9F,$7F,$7F,$BF,$7F,$DF,$7F,$7F,$FF,$9F,$DF\r
+          EJE\r
diff --git a/RASTDEF.S b/RASTDEF.S
new file mode 100644 (file)
index 0000000..294793d
--- /dev/null
+++ b/RASTDEF.S
@@ -0,0 +1,430 @@
+*         1544    030784\r
+** * ** * ** * ** * ** * ** * ** * ** * **\r
+**                                      **\r
+**     Asteroids for the Atari 3600     **\r
+**                                      **\r
+** * ** * ** * ** * ** * ** * ** * ** * **\r
+\r
+*\r
+*\r
+** RASTDEF.S **\r
+** ASTEROIDS FOR THE ATARI 3600 **\r
+** THIS FILE CONTAINS MEMORY STORAGE **\r
+**  AND GENERAL EQUATES. **\r
+**\r
+** MODIFIED FOR MARIA 2 **\r
+*\r
+       .include        "maria.s"\r
+*\r
+*\r
+** HSC INTERFACE\r
+HSCRAM    EQU     $1E00\r
+HSCSETRS  EQU     $3FEB\r
+HSCSTAT   EQU     $3FF7\r
+HSCATRCT  EQU     $3FFA\r
+HSCENTER  EQU     $3FFD\r
+\r
+** IMMEDIATES\r
+ICON      EQU     $07\r
+SMALL     EQU     $10\r
+MEDIUM    EQU     $21\r
+LARGE     EQU     $32\r
+SHIP      EQU     $23\r
+SMALLUFO  EQU     $14\r
+LARGEUFO  EQU     $25\r
+SHOT      EQU     $06\r
+OPENSHIP  EQU     $FF\r
+\r
+XPOSMIN   EQU       0\r
+XPOSMAX   EQU     159\r
+YPOSMIN   EQU       0\r
+YPOSMAX   EQU     191\r
+\r
+NOVICED   EQU      60\r
+TOUGHD    EQU      90\r
+EXPERTD   EQU     110\r
+\r
+MAXVEL    EQU     $20\r
+\r
+MINDIFF   EQU     $00\r
+MAXDIFF   EQU     $03\r
+MINMODE   EQU     $FF\r
+MAXMODE   EQU     $02\r
+\r
+SELDLY    EQU     $10\r
+RACKDLYC  EQU     $25\r
+\r
+* EQUATES FOR DRIVER STATE MACHINE.\r
+TITLEST   EQU     1\r
+MENUST    EQU     2\r
+AUTOST    EQU     3\r
+HSCST     EQU     4\r
+PLAYST    EQU     5\r
+PAUZST    EQU     6\r
+\r
+TITLEONT  EQU     0\r
+TITLEOFT  EQU     TITLEONT+$02         ;2 * 8.3 = 17 SECONDS\r
+\r
+AUTOOFFT  EQU     $04\r
+\r
+MENUOFFT  EQU     $07\r
+\r
+* EQUATES FOR FINITE STATE MACHINE - FSM\r
+DEAD      EQU     $FF\r
+OK        EQU     0\r
+BIRTH     EQU     1\r
+HYPER     EQU     2\r
+DEATH     EQU     3\r
+COMPOVER  EQU     4\r
+\r
+ENTERT    EQU     1\r
+RESINT    EQU     ENTERT+$28\r
+PMSGOFFT  EQU     RESINT+$28\r
+PMSGT     EQU     PMSGOFFT+$28\r
+\r
+HYPENDT   EQU     1\r
+HYPERT    EQU     HYPENDT+$28\r
+\r
+NEWGAMET  EQU     1\r
+GOVERT    EQU     NEWGAMET+$60\r
+POMSGOFT  EQU     GOVERT+$10\r
+POMSGT    EQU     POMSGOFT+$30\r
+SWITCHT   EQU     POMSGT+$5\r
+DIET      EQU     SWITCHT+$10\r
+\r
+* 6116 RAM WHICH IS >ON< ZERO PAGE:\r
+       .ORG     $40\r
+RANDPTR0:\r
+       .DS.B           1\r
+RANDPTR1:\r
+       .DS.B           1\r
+\r
+HISCORE:\r
+       .DS.B           4               ;HIGH SCORE\r
+\r
+SCORE:\r
+       .DS.B           4               ;PLAYER ONE SCORE DEC. MODE\r
+SCORE2:\r
+       .DS.B           4               ;PLAYER TWO SCORE DEC. MODE\r
+COMBSCOR:\r
+       .DS.B           4               ;COMBINED SCORE DEC. MODE\r
+\r
+MENLEFT:\r
+       .DS.B           1               ;PLAYER1 NUMBER OF MEN LEFT\r
+MENLEFT2:\r
+       .DS.B           1               ;PLAYER2 NUMBER OF MEN LEFT\r
+MENLEFTC:\r
+       .DS.B           1               ;POOL OF LIVES FOR TEAM PLAY\r
+\r
+TEMP:\r
+       .DS.B           16              ;GAMEPLAY TEMP\r
+TEMPI:\r
+       .DS.B           5               ;LOADER TEMP\r
+\r
+FREE:\r
+       .DS.B           12              ;FREE POINTERS, NOT FREE SPACE\r
+\r
+\r
+FRMCNT:\r
+       .DS.B           1\r
+LASTFRMC:\r
+       .DS.B           1\r
+\r
+NMICTRL:\r
+       .DS.B           1               ;VALUE OF CTRL FOR HSC SPECIAL NMIHNDL\r
+\r
+PLAYER:\r
+       .DS.B           1               ;WHICH PLAYER\r
+SCORER:\r
+       .DS.B           1               ;WHICH PLAYER IS CURRENTLY SCORING\r
+GAMSTATE:\r
+       .DS.B           1               ;STATE FOR DRIVER.\r
+DTIMER:\r
+       .DS.B           2               ;TIMER FOR DRIVER - TWO BYTES ACCURACY\r
+STATE:\r
+       .DS.B           2               ;STATE FOR FSM, ONE FOR EACH PLAYER\r
+TIMER:\r
+       .DS.B           2               ;TIMER FOR FSM, ONE FOR EACH PLAYER\r
+MODE:\r
+       .DS.B           1               ;GAME MODE: FF = 1PL, 0=2PL, 1=TP, 2=CP\r
+DIFF:\r
+       .DS.B           1               ;GAME DIFFICULTY LEVEL\r
+MAXLVL:\r
+       .DS.B           1               ;MAXIMIUM LEVEL AT THIS DIFF SETTING\r
+LVLINC:\r
+       .DS.B           4               ;INCREMENTS TO LEVEL\r
+LEVEL:\r
+       .DS.B           2\r
+OFFPLAY2:\r
+       .DS.B           1               ;OFFSET FOR PLAYER2 DATA SET\r
+\r
+STATUS:\r
+       .DS.B           32              ;OBJECT STATUS FOR PLAYER1 GAME\r
+SH2STAT:\r
+       .DS.B           1               ;SHIP STATUS FOR 2 PLAYER GAME\r
+MSGICONS:\r
+       .DS.B           3               ;STATUS FOR MESSAGE ICONS\r
+PARTSTAT:\r
+       .DS.B           8               ;STATUS FOR SHIP'S PARTS FOR COLLISIONS\r
+\r
+FIREBUT1:\r
+       .DS.B           1               ;SOFT REGISTERS\r
+FIREBUT2:\r
+       .DS.B           1\r
+HYPBUT1:\r
+       .DS.B           1\r
+HYPBUT2:\r
+       .DS.B           1\r
+STARTBUT:\r
+       .DS.B           1               ;FIREBUT1 EXCEPT DURING AUTOST\r
+SWCHAVAL:\r
+       .DS.B           1\r
+SWCHBVAL:\r
+       .DS.B           1\r
+SWCHBITS:\r
+       .DS.B           1\r
+ONEBUT:\r
+       .DS.B           1               ;PLAYER HAS 1 BUTTON JOYSTICK:\r
+                                       ; BIT 4 = P0, BIT 3 = P1\r
+\r
+SHIPDIR:\r
+       .DS.B           1               ;PLAYER1 SHIP DIRECTION\r
+SHIPDIR2:\r
+       .DS.B           1               ;PLAYER2 SHIP DIRECTION\r
+RACKNUM:\r
+       .DS.B           1               ;PLAYER1 RACK NUMBER\r
+RACKNUM2:\r
+       .DS.B           1               ;PLAYER2 RACK NUMBER\r
+ROCKTOT:\r
+       .DS.B           1               ;PLAYER1 ROCK TOTAL\r
+ROCKTOT2:\r
+       .DS.B           1               ;PLAYER2 ROCK TOTAL\r
+STARTNUM:\r
+       .DS.B           2               ;STARTING NUMBER OF ROCKS FOR EACH\r
+\r
+BCOUNTER:\r
+       .DS.B           1               ;BEAT COUNTER FOR BACKGROUND TUNE\r
+BEATVAL:\r
+       .DS.B           1               ;BEAT VALUE FOR COUNTER, DECREASES\r
+BEATRATE:\r
+       .DS.B           1               ;BEAT RATE, FOR CHANGE OF BEATVAL\r
+WHICHBT:\r
+       .DS.B           1               ;BEAT NUMBER, TOGGLES BETWEEN 0 AND 1\r
+TUNNUM:\r
+       .DS.B           2               ;NUMBER OF TUNE IN EACH CHANNEL\r
+TINDEX:\r
+       .DS.B           6               ;INDEX INTO TUNE TABLE\r
+TDURCNT:\r
+       .DS.B           6               ;TUNE DURATION COUNTERS\r
+TTEMP     EQU     TEMPI                ;THIS IS PROBABLY SAFE, SINCE TUNER\r
+                               ; AND LOADER NEVER INTERRUPT EACH OTHER\r
+\r
+FIRESTAT:\r
+       .DS.B           2\r
+SHOTCNT:\r
+       .DS.B           6               ;TIMER FOR ALL SHOTS\r
+USHOTCNT:\r
+       .DS.B           1               ;COUNTDOWN TIMER FOR UFO SHOTS\r
+RTIMER:\r
+       .DS.B           1               ;TIMER FOR UFO ENTRY\r
+SDELAY:\r
+       .DS.B           1               ;PERCENTAGE OF LARGE\r
+EDELAY:\r
+       .DS.B           1               ;COUNTDOWN TIL NEXT\r
+UFOACC:\r
+       .DS.B           1               ;THRESHOLD OF UFO ACCURACY\r
+SOFTCOLR:\r
+       .DS.B           16              ;SOFT COPY OF FIRST 4 PALETTES.\r
+\r
+CLAMP:\r
+       .DS.B           1               ;CLAMP, USED BY DAMPING SYSTEM TO\r
+                                       ; STOP DRIFT\r
+LOADFLAG:\r
+       .DS.B           1               ;FLAG CLEARED AT END OF LOADER.\r
+\r
+SELCNT:\r
+       .DS.B           1               ;DEBOUNCER/COUNTER FOR MENU SELECT\r
+RACKDLY:\r
+       .DS.B           1               ;TIMER FOR NEW RACK START\r
+COMPFLAG:\r
+       .DS.B           1               ;FLAG FOR COMP PLAY TERMINATION\r
+RUBFLAG:\r
+       .DS.B           1               ;RUBBER SHIP BOUNCE FLAG.\r
+TURKEY:\r
+       .DS.B           1\r
+CHICKEN:\r
+       .DS.B           1\r
+\r
+\r
+* 6116 RAM WHICH IS >NOT< ON ZERO PAGE:\r
+       .ORG     $1800\r
+STATUS2:\r
+       .DS.B           32              ;OBJECT STATUS FOR TWOPLAYER GAME\r
+**                     ;$20 LONG ARRAYS FOR STATE VARIABLES\r
+**                     ;OF EACH OBJECT\r
+\r
+XVELL:\r
+       .DS.B           $20             ;LOW BYTE X VELOCITY\r
+XVELLP2:\r
+       .DS.B           1               ;SECOND PLAYER FOR TEAM PLAY\r
+\r
+XVELH:\r
+       .DS.B           $20             ;HIGH BYTE X VELOCITY\r
+XVELHP2:\r
+       .DS.B           1\r
+\r
+YVELL:\r
+       .DS.B           $20             ;LOW BYTE Y VELOCITY\r
+YVELLP2:\r
+       .DS.B           1\r
+\r
+YVELH:\r
+       .DS.B           $20             ;HIGH BYTE Y VELOCITY\r
+YVELHP2:\r
+       .DS.B           1\r
+\r
+XPOSH:\r
+       .DS.B           $20             ;HIGH BYTE X POSITION\r
+XPOSHP2:\r
+       .DS.B           1\r
+       .DS.B           3\r
+\r
+YPOSH:\r
+       .DS.B           $20             ;HIGH BYTE Y POSITION\r
+YPOSHP2:\r
+       .DS.B           1\r
+       .DS.B           3\r
+\r
+XPOSL:\r
+       .DS.B           $20             ;LOW BYTE X POSITION\r
+XPOSLP2:\r
+       .DS.B           1\r
+\r
+YPOSL:\r
+       .DS.B           $20             ;LOW BYTE Y POSITION\r
+YPOSLP2:\r
+       .DS.B           1\r
+\r
+ACYC:\r
+       .DS.B           $20             ;LOW BYTE STAMP ADDR\r
+ACYCP2:\r
+       .DS.B           1\r
+       .DS.B           3\r
+ANIMAT EQU             ACYC+24\r
+ACYC2:\r
+       .DS.B           $20\r
+COLXPOSH:\r
+       .DS.B           $20\r
+COLXP2:\r
+       .DS.B           1\r
+       .DS.B           3\r
+PARTPOSX:\r
+       .DS.B           8\r
+COLYPOSH:\r
+       .DS.B           $20\r
+COLYP2:\r
+       .DS.B           1\r
+       .DS.B           3\r
+PARTPOSY:\r
+       .DS.B           8\r
+\r
+XVELH2:\r
+       .DS.B           $20\r
+YVELH2:\r
+       .DS.B           $20\r
+XPOSH2:\r
+       .DS.B           $20\r
+YPOSH2:\r
+       .DS.B           $20\r
+XVELL2:\r
+       .DS.B           $20\r
+YVELL2:\r