mirror of
https://github.com/tebl/RC-Project-Board.git
synced 2024-12-12 03:29:19 +00:00
209 lines
14 KiB
Plaintext
209 lines
14 KiB
Plaintext
|
0000- 4 ;
|
||
|
0000- 5 ; BINARY TRANSLATION GAME FOR THE KIM-1 USING '6502 GAMES' HARDWARE. BOARD
|
||
|
0000- 6 ; SHOULD BE JUMPERED WITH VIA CHIPS AT THE ADDRESSES SPECIFIED BELOW. CODE
|
||
|
0000- 7 ; IS MOSTLY UNCHANGED FROM THE BOOK, LOOKUP TABLE 'NUMTAB' WAS MOVED OUT OF
|
||
|
0000- 8 ; ZERO PAGE TO MAKE LOADING A BIT EASIER.
|
||
|
0000- 9 ;
|
||
|
C000- 10 VIA1 .EQ $C000
|
||
|
CC00- 11 VIA3 .EQ $CC00
|
||
|
0000- 12
|
||
|
0200- 13 .OR $0200
|
||
|
0200- 14 .TA $0200
|
||
|
0200- 15 .IN ../../common/CH03-Translate/game.asm
|
||
|
0200- I 1 ; 'TRANSLATE'
|
||
|
0200- I 2 ; PROGRAM TO TEST 2 PLAYERS SPEED IN TRANSLATING A BINARY NUMBER TO A SINGLE
|
||
|
0200- I 3 ; HEXADECIMAL DIGIT. EACH PLAYER IS GIVEN A TURN, AS SHOWN BY A LIGHTED LEFT
|
||
|
0200- I 4 ; OR RIGHT POINTER. THE NUMBER WILL SUDDENLY FLASH ON LEDS 12-15, ACCOMPANIED
|
||
|
0200- I 5 ; BY THE LIGHTING OF LED #10. THE PLAYER MUST THEN PUSH THE CORRESPONDING
|
||
|
0200- I 6 ; BUTTON. AFTER BOTH PLAYERS TAKE TURNS, RESULTS ARE SHOWN ON BOTTOM ROW. AFTER
|
||
|
0200- I 7 ; 10 WINS, A PLAYERS RESULT WILL FLASH, SHOWING THE BETTER PLAYER. THEN THE
|
||
|
0200- I 8 ; GAME RESTARTS.
|
||
|
0200- I 9 ;
|
||
|
C000- I 10 PORT1B .EQ VIA1 ; LEDS 9-15
|
||
|
C001- I 11 PORT1A .EQ VIA1+1 ; LEDS 1-8
|
||
|
C002- I 12 DDR1B .EQ VIA1+2
|
||
|
C003- I 13 DDR1A .EQ VIA1+3
|
||
|
CC00- I 14 PORT3B .EQ VIA3 ; KEY # OUTPUT
|
||
|
CC01- I 15 PORT3A .EQ VIA3+1 ; KEY STROBE INPUT.
|
||
|
CC02- I 16 DDR3B .EQ VIA3+2
|
||
|
CC03- I 17 DDR3A .EQ VIA3+3
|
||
|
0200- I 18 ;
|
||
|
0200- I 19 ; VARIABLE STORAGE:
|
||
|
0200- I 20 ;
|
||
|
0000- I 21 ZP .EQ $00
|
||
|
0000- I 22 TEMP .EQ ZP ; TEMPORARY STORAGE FOR AMOUNT OF TIME PLAYER
|
||
|
0200- I 23 ; USES TO GUESS.
|
||
|
0001- I 24 CNTHI .EQ ZP+1
|
||
|
0002- I 25 CNTLO .EQ ZP+2
|
||
|
0003- I 26 CNT1H .EQ ZP+3 ; AMOUNT OF TIME PLYR1 USES TO GUESS.
|
||
|
0004- I 27 CNT1L .EQ ZP+4
|
||
|
0005- I 28 PLYR1 .EQ ZP+5 ; SCORE OF # WON FOR PLAYER 1.
|
||
|
0006- I 29 PLYR2 .EQ ZP+6 ; PLAYER 2 SCORE.
|
||
|
0007- I 30 NUMBER .EQ ZP+7 ; STORES NUMBER TO BE GUESSED.
|
||
|
0008- I 31 SCR .EQ ZP+8 ; SCRATCHPAD FOR RND # GEN.
|
||
|
0200- I 32 ;
|
||
|
0200- I 33 ; MAIN PROGRAM
|
||
|
0200- I 34 ;
|
||
|
0200-A9 FF I 35 ( 2) START LDA #$FF : SET UP PORTS
|
||
|
0202-8D 03 C0 I 36 ( 4) STA DDR1A
|
||
|
0205-8D 02 C0 I 37 ( 4) STA DDR1B
|
||
|
0208-8D 02 CC I 38 ( 4) STA DDR3B
|
||
|
020B-A9 00 I 39 ( 2) LDA #0
|
||
|
020D-8D 03 CC I 40 ( 4) STA DDR3A
|
||
|
0210-85 05 I 41 ( 2) STA PLYR1 ; CLEAR NUMBER OF WINS.
|
||
|
0212-85 06 I 42 ( 2) STA PLYR2
|
||
|
0214-A9 79 I 43 ( 2) MOVE LDA #%01111001
|
||
|
0216-8D 01 C0 I 44 ( 4) STA PORT1A ; SHOW RIGHT ARROW
|
||
|
0219-A9 00 I 45 ( 2) LDA #0
|
||
|
021B-8D 00 C0 I 46 ( 4) STA PORT1B
|
||
|
021E-85 02 I 47 ( 2) STA CNTLO ; CLEAR COUNTERS
|
||
|
0220-85 01 I 48 ( 2) STA CNTHI
|
||
|
0222-20 8C 02 I 49 ( 6) JSR PLAY ; GET PLAYER 1S TIME.
|
||
|
0225-A5 02 I 50 ( 3) LDA CNTLO ; TRANSFER TEMP COUNT TO PERMANENT STORAGE
|
||
|
0227-85 04 I 51 ( 2) STA CNT1L
|
||
|
0229-A5 01 I 52 ( 3) LDA CNTHI
|
||
|
022B-85 03 I 53 ( 2) STA CNT1H
|
||
|
022D-A9 3C I 54 ( 2) LDA #%00111100 ; SHOW LEFT ARROW
|
||
|
022F-8D 01 C0 I 55 ( 4) STA PORT1A
|
||
|
0232-A9 01 I 56 ( 2) LDA #1
|
||
|
0234-8D 00 C0 I 57 ( 4) STA PORT1B
|
||
|
0237-A9 00 I 58 ( 2) LDA #0
|
||
|
0239-85 02 I 59 ( 2) STA CNTLO ; CLEAR COUNTERS
|
||
|
023B-85 01 I 60 ( 2) STA CNTHI
|
||
|
023D-20 8C 02 I 61 ( 6) JSR PLAY ; GET PLAYER 2S TIME.
|
||
|
0240-A5 01 I 62 ( 3) LDA CNTHI ; GET PLAYER 2S COUNT AND...
|
||
|
0242-C5 03 I 63 ( 3) CMP CNT1H ; COMPARE TO PLAYER 1S.
|
||
|
0244-F0 04 I 64 (2**) BEQ EQUAL ; CHECK LOW ORDER BYTES TO RESOLVE WINNER.
|
||
|
0246-90 27 I 65 (2**) BCC PLR2 ; PLAYER 2 HAS SMALLER COUNT, SHOW IT.
|
||
|
0248-B0 08 I 66 (2**) BCS PLR1 ; PLAYER 1 HAS SMALLER COUNT, SHOW IT.
|
||
|
024A-A5 02 I 67 ( 3) EQUAL LDA CNTLO ; HI BYTES WERE EQUAL, SO CHECK LOW BYTES.
|
||
|
024C-C5 04 I 68 ( 3) CMP CNT1L ; COMPARE SCORES.
|
||
|
024E-90 1F I 69 (2**) BCC PLR2 ; PLAYER 2 WINS, SHOW IT.
|
||
|
0250-B0 00 I 70 (2**) BCS PLR1 ; PLAYER 1 WINS, SHOW IT.
|
||
|
0252-A9 F0 I 71 ( 2) PLR1 LDA #%11110000 ; LIGTH RIGHT SIDE OF BOTTOM ROW
|
||
|
0254-8D 00 C0 I 72 ( 4) STA PORT1B ; TO SHOW WIN.
|
||
|
0257-A9 00 I 73 ( 2) LDA #0
|
||
|
0259-8D 01 C0 I 74 ( 4) STA PORT1A ; CLEAR LOW LEDS.
|
||
|
025C-A9 40 I 75 ( 2) LDA #$40 ; WAIT A WHILE TO SHOW WIN.
|
||
|
025E-20 E4 02 I 76 ( 6) JSR DELAY
|
||
|
0261-E6 05 I 77 ( 5) INC PLYR1 ; PLAYER 1 WINS ONE MORE...
|
||
|
0263-A9 0A I 78 ( 2) LDA #10 ; ... HAS HE WON 10?
|
||
|
0265-C5 05 I 79 ( 3) CMP PLYR1
|
||
|
0267-D0 AB I 80 (2**) BNE MOVE ; IF NOT, PLAY ANOTHER ROUND
|
||
|
0269-A9 F0 I 81 ( 2) LDA #%11110000 ; YES - GET BLINK PATTERN.
|
||
|
026B-20 CC 02 I 82 ( 6) JSR BLINK ; BLINK WINNING SIDE.
|
||
|
026E-60 I 83 ( 6) RTS ; END OF GAME: RETURN TO MONITOR.
|
||
|
026F-A9 0E I 84 ( 2) PLR2 LDA #%1110 ; LIGHT LEFT SIDE OF BOTTOM.
|
||
|
0271-8D 00 C0 I 85 ( 4) STA PORT1B
|
||
|
0274-A9 00 I 86 ( 2) LDA #0
|
||
|
0276-8D 01 C0 I 87 ( 4) STA PORT1A ; CLEAR LOW LEDS.
|
||
|
0279-A9 40 I 88 ( 2) LDA #$40 ; WAIT A WHILE TO SHOW WIN.
|
||
|
027B-20 E4 02 I 89 ( 6) JSR DELAY
|
||
|
027E-E6 06 I 90 ( 5) INC PLYR2 ; PLAYER 2 HAS WON ANOTHER ROUND...
|
||
|
0280-A9 0A I 91 ( 2) LDA #10 ; ... HAS HE WON 10?
|
||
|
0282-C5 06 I 92 ( 3) CMP PLYR2
|
||
|
0284-D0 8E I 93 (2**) BNE MOVE ; IF NOT, PLAY ANOTHER ROUND.
|
||
|
0286-A9 0E I 94 ( 2) LDA #%1110 ; YES - GET PATTERN TO BLINK LEDS.
|
||
|
0288-20 CC 02 I 95 ( 6) JSR BLINK ; BLINK THEM
|
||
|
028B-60 I 96 ( 6) RTS ; END.
|
||
|
028C- I 97 ;
|
||
|
028C- I 98 ; SUBROUTINE 'PLAY'
|
||
|
028C- I 99 ; GETS TIME COUNT OF EACH PLAYER, AND IF BAD GUESSES ARE MADE, THE PLAYER IS
|
||
|
028C- I 100 ; GIVEN ANOTHER CHANCE. THE NEW TIME ADDED TO THE OLD.
|
||
|
028C- I 101 ;
|
||
|
028C-20 F5 02 I 102 ( 6) PLAY JSR RANDOM ; GET RANDOM NUMBER.
|
||
|
028F-20 E4 02 I 103 ( 6) JSR DELAY ; RANDOM - LENGTH DELAY.
|
||
|
0292-20 F5 02 I 104 ( 6) JSR RANDOM ; GET ANOTHER
|
||
|
0295-29 0F I 105 ( 2) AND #$0F ; KEEP UNDER 16 FOR USE AS
|
||
|
0297-85 07 I 106 ( 2) STA NUMBER ; NUMBER TO GUESS.
|
||
|
0299-AA I 107 ( 2) TAX ; USE AS INDEX TO ...
|
||
|
029A-BD 08 03 I 108 ( 4*) LDA NUMTAB,X ; GET REVERSED PATTERN FROM TABLE
|
||
|
029D-0D 00 C0 I 109 ( 4) ORA PORT1B ; TO DISPLAY IN LEDS 12-15.
|
||
|
02A0-8D 00 C0 I 110 ( 4) STA PORT1B
|
||
|
02A3-20 B6 02 I 111 ( 6) JSR CNTSUB ; GET KEYSTROKE 1 DURATION COUNT.
|
||
|
02A6-C4 07 I 112 ( 3) CPY NUMBER ; IS KEYSTROKE CORRECT GUESS?
|
||
|
02A8-F0 0B I 113 (2**) BEQ DONE ; IF SO, DONE.
|
||
|
02AA-A9 01 I 114 ( 2) LDA #01 ; NO: CLEAR OLD GUESS FROM LEDS.
|
||
|
02AC-2D 00 C0 I 115 ( 4) AND PORT1B
|
||
|
02AF-8D 00 C0 I 116 ( 4) STA PORT1B
|
||
|
02B2-4C 8C 02 I 117 ( 3) JMP PLAY ; TRY AGAIN W/ANOTHER NUMBER.
|
||
|
02B5-60 I 118 ( 6) DONE RTS ; RETURN WITH DURATION IN CNTLO+CNTHI
|
||
|
02B6- I 119 ;
|
||
|
02B6- I 120 ; SUBROUTINE 'COUNTER'
|
||
|
02B6- I 121 ; GETS KEYSTROKE WHILE KEEPING TRACK OF AMOUNT OF TIME BEFORE KEYPRESS.
|
||
|
02B6- I 122 ;
|
||
|
02B6-A0 0F I 123 ( 2) CNTSUB LDY #$0F ; SET UP KEY # COUNTER.
|
||
|
02B8-8C 00 CC I 124 ( 4) KEYLP STY PORT3B ; OUTPUT KEY # TO KEYBOARD MPXR
|
||
|
02BB-2C 01 CC I 125 ( 4) BIT PORT3A ; KEY DOWN?
|
||
|
02BE-10 0B I 126 (2**) BPL FINISH ; IF YES, DONE.
|
||
|
02C0-88 I 127 ( 2) DEY ; COUNT DOWN KEY #.
|
||
|
02C1-10 F5 I 128 (2**) BPL KEYLP ; TRY NEXT KEY.
|
||
|
02C3-E6 02 I 129 ( 5) INC CNTLO ; ALL KEYS TRIED, INCREMENT COUNT.
|
||
|
02C5-D0 EF I 130 (2**) BNE CNTSUB ; TRY KEYS AGAIN IF NO OVERFLOW.
|
||
|
02C7-E6 01 I 131 ( 5) INC CNTHI ; OVERFLOW, INCREMENT HIGH BYTE.
|
||
|
02C9-D0 EB I 132 (2**) BNE CNTSUB ; TRY KEYS AGAIN.
|
||
|
02CB-60 I 133 ( 6) FINISH RTS ; DONE: TIME RAN OUT OR KEY PRESSED.
|
||
|
02CC- I 134 ;
|
||
|
02CC- I 135 ; SUBROUTINE 'BLINK'
|
||
|
02CC- I 136 ; BLINKS LEDS WHOSE BITS ARE SET IN ACCUMULATOR ON ENTRY.
|
||
|
02CC-A2 14 I 137 ( 2) BLINK LDX #20 ; 20 BLINKS.
|
||
|
02CE-86 01 I 138 ( 3) STX CNTHI ; SET BLINK COUNTER.
|
||
|
02D0-85 02 I 139 ( 2) STA CNTLO ; BLINK REGISTER
|
||
|
02D2-A5 02 I 140 ( 3) BLOOP LDA CNTLO ; GET BLINK PATTERN
|
||
|
02D4-4D 00 C0 I 141 ( 4) EOR PORT1B ; BLINK LEDS.
|
||
|
02D7-8D 00 C0 I 142 ( 4) STA PORT1B
|
||
|
02DA-A9 0A I 143 ( 2) LDA #10 ; SHORT DELAY
|
||
|
02DC-20 E4 02 I 144 ( 6) JSR DELAY
|
||
|
02DF-C6 01 I 145 ( 5) DEC CNTHI
|
||
|
02E1-D0 EF I 146 (2**) BNE BLOOP ; LOOP IF NOT DONE.
|
||
|
02E3-60 I 147 ( 6) RTS
|
||
|
02E4- I 148 ;
|
||
|
02E4- I 149 ; SUBROUTINE 'DELAY'
|
||
|
02E4- I 150 ; CONTENTS OF ACCUMULATOR DETERMINES DELAY LENGTH.
|
||
|
02E4- I 151 ;
|
||
|
02E4-85 00 I 152 ( 2) DELAY STA TEMP
|
||
|
02E6-A0 10 I 153 ( 2) DL1 LDY #$10
|
||
|
02E8-A2 FF I 154 ( 2) DL2 LDX #$FF
|
||
|
02EA-CA I 155 ( 2) DL3 DEX
|
||
|
02EB-D0 FD I 156 (2**) BNE DL3
|
||
|
02ED-88 I 157 ( 2) DEY
|
||
|
02EE-D0 F8 I 158 (2**) BNE DL2
|
||
|
02F0-C6 00 I 159 ( 5) DEC TEMP
|
||
|
02F2-D0 F2 I 160 (2**) BNE DL1
|
||
|
02F4-60 I 161 ( 6) RTS
|
||
|
02F5- I 162 ;
|
||
|
02F5- I 163 ; SUBROUTINE 'RANDOM'
|
||
|
02F5- I 164 ; RANDOM NUMBER GENERATOR, RETURNS RANDOM NUMBER IN ACCUMULATOR.
|
||
|
02F5- I 165 ;
|
||
|
02F5-38 I 166 ( 2) RANDOM SEC
|
||
|
02F6-A5 09 I 167 ( 3) LDA SCR+1
|
||
|
02F8-65 0C I 168 ( 3) ADC SCR+4
|
||
|
02FA-65 0D I 169 ( 3) ADC SCR+5
|
||
|
02FC-85 08 I 170 ( 2) STA SCR
|
||
|
02FE-A2 04 I 171 ( 2) LDX #4
|
||
|
0300-B5 08 I 172 ( 4) RNDLP LDA SCR,X
|
||
|
0302-95 09 I 173 ( 4) STA SCR+1,X
|
||
|
0304-CA I 174 ( 2) DEX
|
||
|
0305-10 F9 I 175 (2**) BPL RNDLP
|
||
|
0307-60 I 176 ( 6) RTS
|
||
|
0308- I 177 ;
|
||
|
0308- I 178 ; TABLE OF 'REVERSED' NUMBERS FOR DISPLAY
|
||
|
0308- I 179 ; IN BITS 3-8 OF PORT1B, OR LEDS 12-15.
|
||
|
0308- I 180 ;
|
||
|
0308-02 I 181 NUMTAB .DA #%00000010
|
||
|
0309-82 I 182 .DA #%10000010
|
||
|
030A-22 I 183 .DA #%00100010
|
||
|
030B-A2 I 184 .DA #%10100010
|
||
|
030C-12 I 185 .DA #%00010010
|
||
|
030D-92 I 186 .DA #%10010010
|
||
|
030E-32 I 187 .DA #%00110010
|
||
|
030F-B2 I 188 .DA #%10110010
|
||
|
0310-0A I 189 .DA #%00001010
|
||
|
0311-8A I 190 .DA #%10001010
|
||
|
0312-2A I 191 .DA #%00101010
|
||
|
0313-AA I 192 .DA #%10101010
|
||
|
0314-1A I 193 .DA #%00011010
|
||
|
0315-9A I 194 .DA #%10011010
|
||
|
0316-3A I 195 .DA #%00111010
|
||
|
0317-BA I 196 .DA #%10111010
|