mirror of
https://github.com/tebl/RC-Project-Board.git
synced 2025-01-05 18:29:20 +00:00
Chapter 3
This commit is contained in:
parent
bcd1d163f4
commit
d6a1f36d3c
@ -8,13 +8,15 @@
|
||||
; WHATEVER BUGS YOU MAY FIND CAN BE BLAMED ON ME AND NOT THE AUTHOR OF THE
|
||||
; BOOK.
|
||||
;
|
||||
.OR $0200
|
||||
.TA $0200
|
||||
POINTL .EQ $FA ; ADDRESS LO ON DISPLAY
|
||||
POINTH .EQ $FB ; ADDRESS HI ON DISPLAY
|
||||
INH .EQ $F9 ; INPUTBUFFER HI
|
||||
SCANDS .EQ $1F1F ; MONITOR FUNCTION TO OUTPUT A DIGIT
|
||||
VIA1 .EQ $C000
|
||||
VIA3 .EQ $CC00
|
||||
|
||||
.OR $0200
|
||||
.TA $0200
|
||||
RC_ONE LDA #0
|
||||
STA DDR3A ; SET KEY STROBE PORT FOR INPUT
|
||||
LDA #$FF
|
||||
|
@ -5,27 +5,29 @@
|
||||
0000- 8 ; WHATEVER BUGS YOU MAY FIND CAN BE BLAMED ON ME AND NOT THE AUTHOR OF THE
|
||||
0000- 9 ; BOOK.
|
||||
0000- 10 ;
|
||||
0200- 11 .OR $0200
|
||||
0200- 12 .TA $0200
|
||||
00FA- 13 POINTL .EQ $FA ; ADDRESS LO ON DISPLAY
|
||||
00FB- 14 POINTH .EQ $FB ; ADDRESS HI ON DISPLAY
|
||||
00F9- 15 INH .EQ $F9 ; INPUTBUFFER HI
|
||||
1F1F- 16 SCANDS .EQ $1F1F ; MONITOR FUNCTION TO OUTPUT A DIGIT
|
||||
0200- 17
|
||||
0200-A9 00 18 ( 2) RC_ONE LDA #0
|
||||
0202-8D 03 CC 19 ( 4) STA DDR3A ; SET KEY STROBE PORT FOR INPUT
|
||||
0205-A9 FF 20 ( 2) LDA #$FF
|
||||
0207-8D 02 CC 21 ( 4) STA DDR3B ; SET KEYS FOR OUTPUT
|
||||
020A-A9 00 22 ( 2) LDA #0
|
||||
020C-85 FB 23 ( 2) STA POINTH
|
||||
020E-85 FA 24 ( 2) STA POINTL
|
||||
0210-85 F9 25 ( 2) STA INH
|
||||
0212-20 27 02 26 ( 6) LOOP JSR GETKEY ; GET THE KEY USING THE SUB-ROUTINE FROM THE BOOK,
|
||||
0215-85 F9 27 ( 2) STA INH ; WE'LL HAVE IT IN A SO STORE IT TO DATA DIGITS.
|
||||
0217-20 1F 1F 28 ( 6) JSR SCANDS ; HAVE THE MONITOR OUTPUT THE VALUE
|
||||
021A-4C 12 02 29 ( 3) JMP LOOP ; DO IT ALL AGAIN
|
||||
021D- 30
|
||||
021D- 31 .IN ../../common/CH01-Getkey/getkey_routine.asm
|
||||
00FA- 11 POINTL .EQ $FA ; ADDRESS LO ON DISPLAY
|
||||
00FB- 12 POINTH .EQ $FB ; ADDRESS HI ON DISPLAY
|
||||
00F9- 13 INH .EQ $F9 ; INPUTBUFFER HI
|
||||
1F1F- 14 SCANDS .EQ $1F1F ; MONITOR FUNCTION TO OUTPUT A DIGIT
|
||||
C000- 15 VIA1 .EQ $C000
|
||||
CC00- 16 VIA3 .EQ $CC00
|
||||
0000- 17
|
||||
0200- 18 .OR $0200
|
||||
0200- 19 .TA $0200
|
||||
0200-A9 00 20 ( 2) RC_ONE LDA #0
|
||||
0202-8D 03 CC 21 ( 4) STA DDR3A ; SET KEY STROBE PORT FOR INPUT
|
||||
0205-A9 FF 22 ( 2) LDA #$FF
|
||||
0207-8D 02 CC 23 ( 4) STA DDR3B ; SET KEYS FOR OUTPUT
|
||||
020A-A9 00 24 ( 2) LDA #0
|
||||
020C-85 FB 25 ( 2) STA POINTH
|
||||
020E-85 FA 26 ( 2) STA POINTL
|
||||
0210-85 F9 27 ( 2) STA INH
|
||||
0212-20 27 02 28 ( 6) LOOP JSR GETKEY ; GET THE KEY USING THE SUB-ROUTINE FROM THE BOOK,
|
||||
0215-85 F9 29 ( 2) STA INH ; WE'LL HAVE IT IN A SO STORE IT TO DATA DIGITS.
|
||||
0217-20 1F 1F 30 ( 6) JSR SCANDS ; HAVE THE MONITOR OUTPUT THE VALUE
|
||||
021A-4C 12 02 31 ( 3) JMP LOOP ; DO IT ALL AGAIN
|
||||
021D- 32
|
||||
021D- 33 .IN ../../common/CH01-Getkey/getkey_routine.asm
|
||||
021D- I 1 ; 'GETKEY' KEYBOARD INPUT ROUTINE READS AND DEBOUNCES KEYBOARD. RETURNS WITH
|
||||
021D- I 2 ; KEY NUMBER IN ACCUMULATOR IF KEY DOWN. OPERATION: SENDS NUMBERS 0-F TO 74154
|
||||
021D- I 3 ; (4 TO 16 LINE DECODER), WHICH GROUNDS ONE SIDE OF KEYSWITCHES ONE AT A TIME.
|
||||
@ -34,10 +36,10 @@
|
||||
021D- I 6 ; CHECKS FOR KEY CLOSURE FOR 50 MS. TO ELIMINATE BOUNCE.
|
||||
021D- I 7 ; NOTE: IF NO KEY IS PRESSED, GETKEY WILL WAIT.
|
||||
021D- I 8 ;
|
||||
CC03- I 9 DDR3A .EQ $CC03 ; USING RC-ONE ADDRESS DECODING SCHEME, PLACING
|
||||
CC02- I 10 DDR3B .EQ $CC02 ; VIA3 AT $CC00 BY DEFAULT (INSTEAD OF $AC00)
|
||||
CC01- I 11 PORT3A .EQ $CC01 ; TO FIT RC-ONE ADDRESS DECODING THOUGH ORIGINAL
|
||||
CC00- I 12 PORT3B .EQ $CC00 ; CAN BE JUMPERED IF NEEDED/WANTED.
|
||||
CC03- I 9 DDR3A .EQ VIA3+3 ; USING RC-ONE ADDRESS DECODING SCHEME, PLACING
|
||||
CC02- I 10 DDR3B .EQ VIA3+2 ; VIA3 AT $CC00 BY DEFAULT (INSTEAD OF $AC00)
|
||||
CC01- I 11 PORT3A .EQ VIA3+1 ; TO FIT RC-ONE ADDRESS DECODING THOUGH ORIGINAL
|
||||
CC00- I 12 PORT3B .EQ VIA3 ; CAN BE JUMPERED IF NEEDED/WANTED.
|
||||
021D- I 13
|
||||
021D-A9 00 I 14 ( 2) LDA #0
|
||||
021F-8D 03 CC I 15 ( 4) STA DDR3A ; SET KEY STROBE PORT FOR INPUT
|
||||
@ -63,4 +65,4 @@ CC00- I 12 PORT3B .EQ $CC00 ; CAN BE JUMPERED IF
|
||||
0248-88 I 35 ( 2) DEY
|
||||
0249-D0 F3 I 36 (2**) BNE LP1 ; OUTER LOOP: TOTAL IS 50 MS.
|
||||
024B-60 I 37 ( 6) RTS ; DONE: KEY IN A.
|
||||
024C- 32
|
||||
024C- 34
|
||||
|
@ -2,10 +2,13 @@
|
||||
.TF music.hex,hex
|
||||
.LF music.list
|
||||
;
|
||||
; MUSIC PLAYER FOR THE KIM-1 USING '6502 GAMES' HARDWARE, THIS ASSUMES THE
|
||||
; BOARD IS JUMPERED FOR ADDRESSES $C000 AND $CC00 FOR VIA CHIPS. OTHER THAN
|
||||
; THAT THE CODE IS UNCHANGED FROM THE BOOK.
|
||||
; MUSIC PLAYER FOR THE KIM-1 USING '6502 GAMES' HARDWARE. BOARD SHOULD BE
|
||||
; JUMPERED WITH VIA CHIPS AT THE ADDRESSES SPECIFIED BELOW. OTHER THAN THAT
|
||||
; THE CODE IS UNCHANGED FROM THE BOOK.
|
||||
;
|
||||
VIA1 .EQ $C000
|
||||
VIA3 .EQ $CC00
|
||||
|
||||
.OR $0200
|
||||
.TA $0200
|
||||
.IN ../../common/CH02-Music/player.asm
|
||||
|
@ -1,11 +1,14 @@
|
||||
0000- 4 ;
|
||||
0000- 5 ; MUSIC PLAYER FOR THE KIM-1 USING '6502 GAMES' HARDWARE, THIS ASSUMES THE
|
||||
0000- 6 ; BOARD IS JUMPERED FOR ADDRESSES $C000 AND $CC00 FOR VIA CHIPS. OTHER THAN
|
||||
0000- 7 ; THAT THE CODE IS UNCHANGED FROM THE BOOK.
|
||||
0000- 5 ; MUSIC PLAYER FOR THE KIM-1 USING '6502 GAMES' HARDWARE. BOARD SHOULD BE
|
||||
0000- 6 ; JUMPERED WITH VIA CHIPS AT THE ADDRESSES SPECIFIED BELOW. OTHER THAN THAT
|
||||
0000- 7 ; THE CODE IS UNCHANGED FROM THE BOOK.
|
||||
0000- 8 ;
|
||||
0200- 9 .OR $0200
|
||||
0200- 10 .TA $0200
|
||||
0200- 11 .IN ../../common/CH02-Music/player.asm
|
||||
C000- 9 VIA1 .EQ $C000
|
||||
CC00- 10 VIA3 .EQ $CC00
|
||||
0000- 11
|
||||
0200- 12 .OR $0200
|
||||
0200- 13 .TA $0200
|
||||
0200- 14 .IN ../../common/CH02-Music/player.asm
|
||||
0200- I 1 ; MUSIC PLAYER PROGRAM
|
||||
0200- I 2 ; USES 16-KEY KEYBOARD AND BUFFERED SPEAKER
|
||||
0200- I 3 ; PROGRAM PLAYS STORED MUSICAL NOTES. THERE ARE TWO MODES OF OPERATION: INPUT
|
||||
@ -20,8 +23,8 @@
|
||||
0003- I 12 FREQ .EQ $03 ; TEMPORARY STORAGE FOR FREQUENCY
|
||||
0004- I 13 DUR .EQ $04 ; TEMP STORAGE FOR DURATION
|
||||
0300- I 14 TABEG .EQ $0300 ; TABLE TO STORE MUSIC
|
||||
CC00- I 15 PORT3B .EQ $CC00 ; VIA OUTPUT PORT B
|
||||
CC02- I 16 DDR3B .EQ $CC02 ; VIA PORT B DIRECTION REGISTER
|
||||
CC00- I 15 PORT3B .EQ VIA3 ; VIA OUTPUT PORT B
|
||||
CC02- I 16 DDR3B .EQ VIA3+2 ; VIA PORT B DIRECTION REGISTER
|
||||
0200- I 17 ;
|
||||
0200- I 18 ; COMMAND LINE INTERPRETER
|
||||
0200- I 19 ; $F AS INPUT MEANS RESET POINTERS, START OVER.
|
||||
@ -169,7 +172,7 @@ CC02- I 16 DDR3B .EQ $CC02 ; VIA PORT B DIRECTIO
|
||||
80 8F 94 A1
|
||||
AA B5 BF D7
|
||||
E4 I 157 DURTAB .HS 55.60.6B.72.80.8F.94.A1.AA.B5.BF.D7.E4
|
||||
02DE- 12 .IN ../../common/CH01-Getkey/getkey_routine.asm
|
||||
02DE- 15 .IN ../../common/CH01-Getkey/getkey_routine.asm
|
||||
02DE- I 1 ; 'GETKEY' KEYBOARD INPUT ROUTINE READS AND DEBOUNCES KEYBOARD. RETURNS WITH
|
||||
02DE- I 2 ; KEY NUMBER IN ACCUMULATOR IF KEY DOWN. OPERATION: SENDS NUMBERS 0-F TO 74154
|
||||
02DE- I 3 ; (4 TO 16 LINE DECODER), WHICH GROUNDS ONE SIDE OF KEYSWITCHES ONE AT A TIME.
|
||||
@ -178,10 +181,10 @@ CC02- I 16 DDR3B .EQ $CC02 ; VIA PORT B DIRECTIO
|
||||
02DE- I 6 ; CHECKS FOR KEY CLOSURE FOR 50 MS. TO ELIMINATE BOUNCE.
|
||||
02DE- I 7 ; NOTE: IF NO KEY IS PRESSED, GETKEY WILL WAIT.
|
||||
02DE- I 8 ;
|
||||
CC03- I 9 DDR3A .EQ $CC03 ; USING RC-ONE ADDRESS DECODING SCHEME, PLACING
|
||||
CC02- I 10 DDR3B .EQ $CC02 ; VIA3 AT $CC00 BY DEFAULT (INSTEAD OF $AC00)
|
||||
CC01- I 11 PORT3A .EQ $CC01 ; TO FIT RC-ONE ADDRESS DECODING THOUGH ORIGINAL
|
||||
CC00- I 12 PORT3B .EQ $CC00 ; CAN BE JUMPERED IF NEEDED/WANTED.
|
||||
CC03- I 9 DDR3A .EQ VIA3+3 ; USING RC-ONE ADDRESS DECODING SCHEME, PLACING
|
||||
CC02- I 10 DDR3B .EQ VIA3+2 ; VIA3 AT $CC00 BY DEFAULT (INSTEAD OF $AC00)
|
||||
CC01- I 11 PORT3A .EQ VIA3+1 ; TO FIT RC-ONE ADDRESS DECODING THOUGH ORIGINAL
|
||||
CC00- I 12 PORT3B .EQ VIA3 ; CAN BE JUMPERED IF NEEDED/WANTED.
|
||||
02DE- I 13
|
||||
02DE-A9 00 I 14 ( 2) LDA #0
|
||||
02E0-8D 03 CC I 15 ( 4) STA DDR3A ; SET KEY STROBE PORT FOR INPUT
|
||||
|
@ -0,0 +1,4 @@
|
||||
@echo off
|
||||
sbasm.py translate.asm
|
||||
type translate.list
|
||||
pause
|
@ -0,0 +1,15 @@
|
||||
.CR 6502
|
||||
.TF translate.hex,hex
|
||||
.LF translate.list
|
||||
;
|
||||
; BINARY TRANSLATION GAME FOR THE KIM-1 USING '6502 GAMES' HARDWARE. BOARD
|
||||
; SHOULD BE JUMPERED WITH VIA CHIPS AT THE ADDRESSES SPECIFIED BELOW. CODE
|
||||
; IS MOSTLY UNCHANGED FROM THE BOOK, LOOKUP TABLE 'NUMTAB' WAS MOVED OUT OF
|
||||
; ZERO PAGE TO MAKE LOADING A BIT EASIER.
|
||||
;
|
||||
VIA1 .EQ $C000
|
||||
VIA3 .EQ $CC00
|
||||
|
||||
.OR $0200
|
||||
.TA $0200
|
||||
.IN ../../common/CH03-Translate/game.asm
|
@ -0,0 +1,18 @@
|
||||
A9FF8D03C08D02C08D02CCA9008D03CC
|
||||
85058506A9798D01C0A9008D00C08502
|
||||
8501208C02A5028504A5018503A93C8D
|
||||
01C0A9018D00C0A90085028501208C02
|
||||
A501C503F0049027B008A502C504901F
|
||||
B000A9F08D00C0A9008D01C0A94020E4
|
||||
02E605A90AC505D0ABA9F020CC0260A9
|
||||
0E8D00C0A9008D01C0A94020E402E606
|
||||
A90AC506D08EA90E20CC026020F50220
|
||||
E40220F502290F8507AABD08030D00C0
|
||||
8D00C020B602C407F00BA9012D00C08D
|
||||
00C04C8C0260A00F8C00CC2C01CC100B
|
||||
8810F5E602D0EFE601D0EB60A2148601
|
||||
8502A5024D00C08D00C0A90A20E402C6
|
||||
01D0EF608500A010A2FFCAD0FD88D0F8
|
||||
C600D0F26038A509650C650D8508A204
|
||||
B5089509CA10F960028222A2129232B2
|
||||
0A8A2AAA1A9A3ABA
|
@ -0,0 +1,208 @@
|
||||
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
|
@ -1,6 +1,13 @@
|
||||
.CR 6502
|
||||
.TF getkey.hex,hex
|
||||
.LF getkey.list
|
||||
;
|
||||
; FROM THE BOOK '6502 GAMES', EXPECTS THE SAME HARDWARE AS DECRIBED WITHIN IT.
|
||||
; THIS PART WAS NOT MEANT TO BE RUN DIRECTLY, SO I'VE JUST KEPT THE ADDRESS
|
||||
; DEFINITIONS GIVEN IN THAT CHAPTER.
|
||||
;
|
||||
VIA1 .EQ $C000
|
||||
VIA3 .EQ $CC00
|
||||
|
||||
.OR $0100 ; NOTE: BOOK PLACES $0100 INSIDE STACK, MEANING
|
||||
.TA $0100 ; THAT ROUTINE MAY EASILY GET OVERWRITTEN.
|
||||
|
@ -1,41 +1,48 @@
|
||||
0000- 4
|
||||
0400- 5 .OR $0400 ; NOTE: BOOK PLACES $0100 INSIDE STACK, BUT WE HAVE
|
||||
0400- 6 .TA $0400 ; MORE MEMORY SO WE ASSEMBLE AT 0400 INSTEAD.
|
||||
0400- 7 .IN getkey_routine.asm
|
||||
0400- I 1 ; 'GETKEY' KEYBOARD INPUT ROUTINE READS AND DEBOUNCES KEYBOARD. RETURNS WITH
|
||||
0400- I 2 ; KEY NUMBER IN ACCUMULATOR IF KEY DOWN. OPERATION: SENDS NUMBERS 0-F TO 74154
|
||||
0400- I 3 ; (4 TO 16 LINE DECODER), WHICH GROUNDS ONE SIDE OF KEYSWITCHES ONE AT A TIME.
|
||||
0400- I 4 ; IF A KEY IS DOWN, PA7 OF VIA #3 WILL BE GROUNDED, AND THE CURRENT VALUE
|
||||
0400- I 5 ; APPLIED TO THE 74154 BE THE KEY NUMBER. WHEN THE PROGRAM DETECTS A KEY CLOSE
|
||||
0400- I 6 ; CHECKS FOR KEY CLOSURE FOR 50 MS. TO ELIMINATE BOUNCE.
|
||||
0400- I 7 ; NOTE: IF NO KEY IS PRESSED, GETKEY WILL WAIT.
|
||||
0400- I 8 ;
|
||||
CC03- I 9 DDR3A .EQ $CC03 ; USING RC-ONE ADDRESS DECODING SCHEME, PLACING
|
||||
CC02- I 10 DDR3B .EQ $CC02 ; VIA3 AT $CC00 BY DEFAULT (INSTEAD OF $AC00)
|
||||
CC01- I 11 PORT3A .EQ $CC01 ; TO FIT RC-ONE ADDRESS DECODING THOUGH ORIGINAL
|
||||
CC00- I 12 PORT3B .EQ $CC00 ; CAN BE JUMPERED IF NEEDED/WANTED.
|
||||
0400- I 13
|
||||
0400-A9 00 I 14 ( 2) LDA #0
|
||||
0402-8D 03 CC I 15 ( 4) STA DDR3A ; SET KEY STROBE PORT FOR INPUT
|
||||
0405-A9 FF I 16 ( 2) LDA #$FF
|
||||
0407-8D 02 CC I 17 ( 4) STA DDR3B ; SET KEYS FOR OUTPUT
|
||||
040A-2C 01 CC I 18 ( 4) GETKEY BIT PORT3A ; SEE IF KEY IS STILL DOWN FROM LAST KEY CLOSURE:
|
||||
040D- I 19 ; KEYSTROBE IN 'N' STATUS BIT.
|
||||
040D-10 FB I 20 (2**) BPL GETKEY ; IF YES, WAIT FOR KEY RELEASE
|
||||
040F-A2 0F I 21 ( 2) RSTART LDX #15 ; SET KEY COUNTER TO 15
|
||||
0411-8E 00 CC I 22 ( 4) NXTKEY STX PORT3B ; OUTPUT KEY # TO 74154
|
||||
0414-2C 01 CC I 23 ( 4) BIT PORT3A ; SEE IF KEY DOWN: STROBE IN 'N'
|
||||
0417-10 05 I 24 (2**) BPL BOUNCE ; IF YES, GO DEBOUNCE
|
||||
0419-CA I 25 ( 2) DEX ; DECREMENT KEY #
|
||||
041A-10 F5 I 26 (2**) BPL NXTKEY ; NO, DO NEXT KEY
|
||||
041C-30 F1 I 27 (2**) BMI RSTART ; START OVER
|
||||
041E-8A I 28 ( 2) BOUNCE TXA ; SAVE KEY NUMBER IN A
|
||||
041F-A0 12 I 29 ( 2) LDY #$12 ; OUTER LOOP CNT LOAD FOR DELAY OF 50 MS.
|
||||
0421-A2 FF I 30 ( 2) LP1 LDX #$FF ; INNER 11 US. LOOP
|
||||
0423-2C 01 CC I 31 ( 4) LP2 BIT PORT3A ; SEE IF KEY STILL DOWN
|
||||
0426-30 E7 I 32 (2**) BMI RSTART ; IF NOT, KEY NOT VALID, RESTART
|
||||
0428-CA I 33 ( 2) DEX
|
||||
0429-D0 F8 I 34 (2**) BNE LP2 ; THIS LOOP USES 2115*5 US.
|
||||
042B-88 I 35 ( 2) DEY
|
||||
042C-D0 F3 I 36 (2**) BNE LP1 ; OUTER LOOP: TOTAL IS 50 MS.
|
||||
042E-60 I 37 ( 6) RTS ; DONE: KEY IN A.
|
||||
0000- 4 ;
|
||||
0000- 5 ; FROM THE BOOK '6502 GAMES', EXPECTS THE SAME HARDWARE AS DECRIBED WITHIN IT.
|
||||
0000- 6 ; THIS PART WAS NOT MEANT TO BE RUN DIRECTLY, SO I'VE JUST KEPT THE ADDRESS
|
||||
0000- 7 ; DEFINITIONS GIVEN IN THAT CHAPTER.
|
||||
0000- 8 ;
|
||||
C000- 9 VIA1 .EQ $C000
|
||||
CC00- 10 VIA3 .EQ $CC00
|
||||
0000- 11
|
||||
0100- 12 .OR $0100 ; NOTE: BOOK PLACES $0100 INSIDE STACK, MEANING
|
||||
0100- 13 .TA $0100 ; THAT ROUTINE MAY EASILY GET OVERWRITTEN.
|
||||
0100- 14 .IN getkey_routine.asm
|
||||
0100- I 1 ; 'GETKEY' KEYBOARD INPUT ROUTINE READS AND DEBOUNCES KEYBOARD. RETURNS WITH
|
||||
0100- I 2 ; KEY NUMBER IN ACCUMULATOR IF KEY DOWN. OPERATION: SENDS NUMBERS 0-F TO 74154
|
||||
0100- I 3 ; (4 TO 16 LINE DECODER), WHICH GROUNDS ONE SIDE OF KEYSWITCHES ONE AT A TIME.
|
||||
0100- I 4 ; IF A KEY IS DOWN, PA7 OF VIA #3 WILL BE GROUNDED, AND THE CURRENT VALUE
|
||||
0100- I 5 ; APPLIED TO THE 74154 BE THE KEY NUMBER. WHEN THE PROGRAM DETECTS A KEY CLOSE
|
||||
0100- I 6 ; CHECKS FOR KEY CLOSURE FOR 50 MS. TO ELIMINATE BOUNCE.
|
||||
0100- I 7 ; NOTE: IF NO KEY IS PRESSED, GETKEY WILL WAIT.
|
||||
0100- I 8 ;
|
||||
CC03- I 9 DDR3A .EQ VIA3+3 ; USING RC-ONE ADDRESS DECODING SCHEME, PLACING
|
||||
CC02- I 10 DDR3B .EQ VIA3+2 ; VIA3 AT $CC00 BY DEFAULT (INSTEAD OF $AC00)
|
||||
CC01- I 11 PORT3A .EQ VIA3+1 ; TO FIT RC-ONE ADDRESS DECODING THOUGH ORIGINAL
|
||||
CC00- I 12 PORT3B .EQ VIA3 ; CAN BE JUMPERED IF NEEDED/WANTED.
|
||||
0100- I 13
|
||||
0100-A9 00 I 14 ( 2) LDA #0
|
||||
0102-8D 03 CC I 15 ( 4) STA DDR3A ; SET KEY STROBE PORT FOR INPUT
|
||||
0105-A9 FF I 16 ( 2) LDA #$FF
|
||||
0107-8D 02 CC I 17 ( 4) STA DDR3B ; SET KEYS FOR OUTPUT
|
||||
010A-2C 01 CC I 18 ( 4) GETKEY BIT PORT3A ; SEE IF KEY IS STILL DOWN FROM LAST KEY CLOSURE:
|
||||
010D- I 19 ; KEYSTROBE IN 'N' STATUS BIT.
|
||||
010D-10 FB I 20 (2**) BPL GETKEY ; IF YES, WAIT FOR KEY RELEASE
|
||||
010F-A2 0F I 21 ( 2) RSTART LDX #15 ; SET KEY COUNTER TO 15
|
||||
0111-8E 00 CC I 22 ( 4) NXTKEY STX PORT3B ; OUTPUT KEY # TO 74154
|
||||
0114-2C 01 CC I 23 ( 4) BIT PORT3A ; SEE IF KEY DOWN: STROBE IN 'N'
|
||||
0117-10 05 I 24 (2**) BPL BOUNCE ; IF YES, GO DEBOUNCE
|
||||
0119-CA I 25 ( 2) DEX ; DECREMENT KEY #
|
||||
011A-10 F5 I 26 (2**) BPL NXTKEY ; NO, DO NEXT KEY
|
||||
011C-30 F1 I 27 (2**) BMI RSTART ; START OVER
|
||||
011E-8A I 28 ( 2) BOUNCE TXA ; SAVE KEY NUMBER IN A
|
||||
011F-A0 12 I 29 ( 2) LDY #$12 ; OUTER LOOP CNT LOAD FOR DELAY OF 50 MS.
|
||||
0121-A2 FF I 30 ( 2) LP1 LDX #$FF ; INNER 11 US. LOOP
|
||||
0123-2C 01 CC I 31 ( 4) LP2 BIT PORT3A ; SEE IF KEY STILL DOWN
|
||||
0126-30 E7 I 32 (2**) BMI RSTART ; IF NOT, KEY NOT VALID, RESTART
|
||||
0128-CA I 33 ( 2) DEX
|
||||
0129-D0 F8 I 34 (2**) BNE LP2 ; THIS LOOP USES 2115*5 US.
|
||||
012B-88 I 35 ( 2) DEY
|
||||
012C-D0 F3 I 36 (2**) BNE LP1 ; OUTER LOOP: TOTAL IS 50 MS.
|
||||
012E-60 I 37 ( 6) RTS ; DONE: KEY IN A.
|
||||
|
@ -6,10 +6,10 @@
|
||||
; CHECKS FOR KEY CLOSURE FOR 50 MS. TO ELIMINATE BOUNCE.
|
||||
; NOTE: IF NO KEY IS PRESSED, GETKEY WILL WAIT.
|
||||
;
|
||||
DDR3A .EQ $CC03 ; USING RC-ONE ADDRESS DECODING SCHEME, PLACING
|
||||
DDR3B .EQ $CC02 ; VIA3 AT $CC00 BY DEFAULT (INSTEAD OF $AC00)
|
||||
PORT3A .EQ $CC01 ; TO FIT RC-ONE ADDRESS DECODING THOUGH ORIGINAL
|
||||
PORT3B .EQ $CC00 ; CAN BE JUMPERED IF NEEDED/WANTED.
|
||||
DDR3A .EQ VIA3+3 ; USING RC-ONE ADDRESS DECODING SCHEME, PLACING
|
||||
DDR3B .EQ VIA3+2 ; VIA3 AT $CC00 BY DEFAULT (INSTEAD OF $AC00)
|
||||
PORT3A .EQ VIA3+1 ; TO FIT RC-ONE ADDRESS DECODING THOUGH ORIGINAL
|
||||
PORT3B .EQ VIA3 ; CAN BE JUMPERED IF NEEDED/WANTED.
|
||||
|
||||
LDA #0
|
||||
STA DDR3A ; SET KEY STROBE PORT FOR INPUT
|
||||
|
@ -1,6 +1,14 @@
|
||||
.CR 6502
|
||||
.TF music.hex,hex
|
||||
.LF music.list
|
||||
;
|
||||
; MUSIC PLAYER USING '6502 GAMES' HARDWARE. BOARD SHOULD BE JUMPERED WITH VIA
|
||||
; CHIPS AT THE ADDRESSES SPECIFIED BELOW. OTHER THAN THAT THE CODE IS SHOULD
|
||||
; BE UNCHANGED FROM THE BOOK THOUGH THERE WILL BE SOME DIFFERENCES DUE TO
|
||||
; ASSEMBLER USED.
|
||||
;
|
||||
VIA1 .EQ $C000
|
||||
VIA3 .EQ $CC00
|
||||
|
||||
.OR $0200
|
||||
.TA $0200
|
||||
|
@ -1,7 +1,15 @@
|
||||
0000- 4
|
||||
0200- 5 .OR $0200
|
||||
0200- 6 .TA $0200
|
||||
0200- 7 .IN player.asm
|
||||
0000- 4 ;
|
||||
0000- 5 ; MUSIC PLAYER USING '6502 GAMES' HARDWARE. BOARD SHOULD BE JUMPERED WITH VIA
|
||||
0000- 6 ; CHIPS AT THE ADDRESSES SPECIFIED BELOW. OTHER THAN THAT THE CODE IS SHOULD
|
||||
0000- 7 ; BE UNCHANGED FROM THE BOOK THOUGH THERE WILL BE SOME DIFFERENCES DUE TO
|
||||
0000- 8 ; ASSEMBLER USED.
|
||||
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 player.asm
|
||||
0200- I 1 ; MUSIC PLAYER PROGRAM
|
||||
0200- I 2 ; USES 16-KEY KEYBOARD AND BUFFERED SPEAKER
|
||||
0200- I 3 ; PROGRAM PLAYS STORED MUSICAL NOTES. THERE ARE TWO MODES OF OPERATION: INPUT
|
||||
@ -16,8 +24,8 @@
|
||||
0003- I 12 FREQ .EQ $03 ; TEMPORARY STORAGE FOR FREQUENCY
|
||||
0004- I 13 DUR .EQ $04 ; TEMP STORAGE FOR DURATION
|
||||
0300- I 14 TABEG .EQ $0300 ; TABLE TO STORE MUSIC
|
||||
CC00- I 15 PORT3B .EQ $CC00 ; VIA OUTPUT PORT B
|
||||
CC02- I 16 DDR3B .EQ $CC02 ; VIA PORT B DIRECTION REGISTER
|
||||
CC00- I 15 PORT3B .EQ VIA3 ; VIA OUTPUT PORT B
|
||||
CC02- I 16 DDR3B .EQ VIA3+2 ; VIA PORT B DIRECTION REGISTER
|
||||
0200- I 17 ;
|
||||
0200- I 18 ; COMMAND LINE INTERPRETER
|
||||
0200- I 19 ; $F AS INPUT MEANS RESET POINTERS, START OVER.
|
||||
@ -165,7 +173,7 @@ CC02- I 16 DDR3B .EQ $CC02 ; VIA PORT B DIRECTIO
|
||||
80 8F 94 A1
|
||||
AA B5 BF D7
|
||||
E4 I 157 DURTAB .HS 55.60.6B.72.80.8F.94.A1.AA.B5.BF.D7.E4
|
||||
02DE- 8 .IN ../CH01-Getkey/getkey_routine.asm
|
||||
02DE- 16 .IN ../CH01-Getkey/getkey_routine.asm
|
||||
02DE- I 1 ; 'GETKEY' KEYBOARD INPUT ROUTINE READS AND DEBOUNCES KEYBOARD. RETURNS WITH
|
||||
02DE- I 2 ; KEY NUMBER IN ACCUMULATOR IF KEY DOWN. OPERATION: SENDS NUMBERS 0-F TO 74154
|
||||
02DE- I 3 ; (4 TO 16 LINE DECODER), WHICH GROUNDS ONE SIDE OF KEYSWITCHES ONE AT A TIME.
|
||||
@ -174,10 +182,10 @@ CC02- I 16 DDR3B .EQ $CC02 ; VIA PORT B DIRECTIO
|
||||
02DE- I 6 ; CHECKS FOR KEY CLOSURE FOR 50 MS. TO ELIMINATE BOUNCE.
|
||||
02DE- I 7 ; NOTE: IF NO KEY IS PRESSED, GETKEY WILL WAIT.
|
||||
02DE- I 8 ;
|
||||
CC03- I 9 DDR3A .EQ $CC03 ; USING RC-ONE ADDRESS DECODING SCHEME, PLACING
|
||||
CC02- I 10 DDR3B .EQ $CC02 ; VIA3 AT $CC00 BY DEFAULT (INSTEAD OF $AC00)
|
||||
CC01- I 11 PORT3A .EQ $CC01 ; TO FIT RC-ONE ADDRESS DECODING THOUGH ORIGINAL
|
||||
CC00- I 12 PORT3B .EQ $CC00 ; CAN BE JUMPERED IF NEEDED/WANTED.
|
||||
CC03- I 9 DDR3A .EQ VIA3+3 ; USING RC-ONE ADDRESS DECODING SCHEME, PLACING
|
||||
CC02- I 10 DDR3B .EQ VIA3+2 ; VIA3 AT $CC00 BY DEFAULT (INSTEAD OF $AC00)
|
||||
CC01- I 11 PORT3A .EQ VIA3+1 ; TO FIT RC-ONE ADDRESS DECODING THOUGH ORIGINAL
|
||||
CC00- I 12 PORT3B .EQ VIA3 ; CAN BE JUMPERED IF NEEDED/WANTED.
|
||||
02DE- I 13
|
||||
02DE-A9 00 I 14 ( 2) LDA #0
|
||||
02E0-8D 03 CC I 15 ( 4) STA DDR3A ; SET KEY STROBE PORT FOR INPUT
|
||||
|
@ -12,8 +12,8 @@ PTR .EQ $02 ; CURRENT LOCATION IN LIST
|
||||
FREQ .EQ $03 ; TEMPORARY STORAGE FOR FREQUENCY
|
||||
DUR .EQ $04 ; TEMP STORAGE FOR DURATION
|
||||
TABEG .EQ $0300 ; TABLE TO STORE MUSIC
|
||||
PORT3B .EQ $CC00 ; VIA OUTPUT PORT B
|
||||
DDR3B .EQ $CC02 ; VIA PORT B DIRECTION REGISTER
|
||||
PORT3B .EQ VIA3 ; VIA OUTPUT PORT B
|
||||
DDR3B .EQ VIA3+2 ; VIA PORT B DIRECTION REGISTER
|
||||
;
|
||||
; COMMAND LINE INTERPRETER
|
||||
; $F AS INPUT MEANS RESET POINTERS, START OVER.
|
||||
|
@ -0,0 +1,4 @@
|
||||
@echo off
|
||||
sbasm.py translate.asm
|
||||
type translate.list
|
||||
pause
|
@ -0,0 +1,196 @@
|
||||
; 'TRANSLATE'
|
||||
; PROGRAM TO TEST 2 PLAYERS SPEED IN TRANSLATING A BINARY NUMBER TO A SINGLE
|
||||
; HEXADECIMAL DIGIT. EACH PLAYER IS GIVEN A TURN, AS SHOWN BY A LIGHTED LEFT
|
||||
; OR RIGHT POINTER. THE NUMBER WILL SUDDENLY FLASH ON LEDS 12-15, ACCOMPANIED
|
||||
; BY THE LIGHTING OF LED #10. THE PLAYER MUST THEN PUSH THE CORRESPONDING
|
||||
; BUTTON. AFTER BOTH PLAYERS TAKE TURNS, RESULTS ARE SHOWN ON BOTTOM ROW. AFTER
|
||||
; 10 WINS, A PLAYERS RESULT WILL FLASH, SHOWING THE BETTER PLAYER. THEN THE
|
||||
; GAME RESTARTS.
|
||||
;
|
||||
PORT1B .EQ VIA1 ; LEDS 9-15
|
||||
PORT1A .EQ VIA1+1 ; LEDS 1-8
|
||||
DDR1B .EQ VIA1+2
|
||||
DDR1A .EQ VIA1+3
|
||||
PORT3B .EQ VIA3 ; KEY # OUTPUT
|
||||
PORT3A .EQ VIA3+1 ; KEY STROBE INPUT.
|
||||
DDR3B .EQ VIA3+2
|
||||
DDR3A .EQ VIA3+3
|
||||
;
|
||||
; VARIABLE STORAGE:
|
||||
;
|
||||
ZP .EQ $00
|
||||
TEMP .EQ ZP ; TEMPORARY STORAGE FOR AMOUNT OF TIME PLAYER
|
||||
; USES TO GUESS.
|
||||
CNTHI .EQ ZP+1
|
||||
CNTLO .EQ ZP+2
|
||||
CNT1H .EQ ZP+3 ; AMOUNT OF TIME PLYR1 USES TO GUESS.
|
||||
CNT1L .EQ ZP+4
|
||||
PLYR1 .EQ ZP+5 ; SCORE OF # WON FOR PLAYER 1.
|
||||
PLYR2 .EQ ZP+6 ; PLAYER 2 SCORE.
|
||||
NUMBER .EQ ZP+7 ; STORES NUMBER TO BE GUESSED.
|
||||
SCR .EQ ZP+8 ; SCRATCHPAD FOR RND # GEN.
|
||||
;
|
||||
; MAIN PROGRAM
|
||||
;
|
||||
START LDA #$FF : SET UP PORTS
|
||||
STA DDR1A
|
||||
STA DDR1B
|
||||
STA DDR3B
|
||||
LDA #0
|
||||
STA DDR3A
|
||||
STA PLYR1 ; CLEAR NUMBER OF WINS.
|
||||
STA PLYR2
|
||||
MOVE LDA #%01111001
|
||||
STA PORT1A ; SHOW RIGHT ARROW
|
||||
LDA #0
|
||||
STA PORT1B
|
||||
STA CNTLO ; CLEAR COUNTERS
|
||||
STA CNTHI
|
||||
JSR PLAY ; GET PLAYER 1S TIME.
|
||||
LDA CNTLO ; TRANSFER TEMP COUNT TO PERMANENT STORAGE
|
||||
STA CNT1L
|
||||
LDA CNTHI
|
||||
STA CNT1H
|
||||
LDA #%00111100 ; SHOW LEFT ARROW
|
||||
STA PORT1A
|
||||
LDA #1
|
||||
STA PORT1B
|
||||
LDA #0
|
||||
STA CNTLO ; CLEAR COUNTERS
|
||||
STA CNTHI
|
||||
JSR PLAY ; GET PLAYER 2S TIME.
|
||||
LDA CNTHI ; GET PLAYER 2S COUNT AND...
|
||||
CMP CNT1H ; COMPARE TO PLAYER 1S.
|
||||
BEQ EQUAL ; CHECK LOW ORDER BYTES TO RESOLVE WINNER.
|
||||
BCC PLR2 ; PLAYER 2 HAS SMALLER COUNT, SHOW IT.
|
||||
BCS PLR1 ; PLAYER 1 HAS SMALLER COUNT, SHOW IT.
|
||||
EQUAL LDA CNTLO ; HI BYTES WERE EQUAL, SO CHECK LOW BYTES.
|
||||
CMP CNT1L ; COMPARE SCORES.
|
||||
BCC PLR2 ; PLAYER 2 WINS, SHOW IT.
|
||||
BCS PLR1 ; PLAYER 1 WINS, SHOW IT.
|
||||
PLR1 LDA #%11110000 ; LIGTH RIGHT SIDE OF BOTTOM ROW
|
||||
STA PORT1B ; TO SHOW WIN.
|
||||
LDA #0
|
||||
STA PORT1A ; CLEAR LOW LEDS.
|
||||
LDA #$40 ; WAIT A WHILE TO SHOW WIN.
|
||||
JSR DELAY
|
||||
INC PLYR1 ; PLAYER 1 WINS ONE MORE...
|
||||
LDA #10 ; ... HAS HE WON 10?
|
||||
CMP PLYR1
|
||||
BNE MOVE ; IF NOT, PLAY ANOTHER ROUND
|
||||
LDA #%11110000 ; YES - GET BLINK PATTERN.
|
||||
JSR BLINK ; BLINK WINNING SIDE.
|
||||
RTS ; END OF GAME: RETURN TO MONITOR.
|
||||
PLR2 LDA #%1110 ; LIGHT LEFT SIDE OF BOTTOM.
|
||||
STA PORT1B
|
||||
LDA #0
|
||||
STA PORT1A ; CLEAR LOW LEDS.
|
||||
LDA #$40 ; WAIT A WHILE TO SHOW WIN.
|
||||
JSR DELAY
|
||||
INC PLYR2 ; PLAYER 2 HAS WON ANOTHER ROUND...
|
||||
LDA #10 ; ... HAS HE WON 10?
|
||||
CMP PLYR2
|
||||
BNE MOVE ; IF NOT, PLAY ANOTHER ROUND.
|
||||
LDA #%1110 ; YES - GET PATTERN TO BLINK LEDS.
|
||||
JSR BLINK ; BLINK THEM
|
||||
RTS ; END.
|
||||
;
|
||||
; SUBROUTINE 'PLAY'
|
||||
; GETS TIME COUNT OF EACH PLAYER, AND IF BAD GUESSES ARE MADE, THE PLAYER IS
|
||||
; GIVEN ANOTHER CHANCE. THE NEW TIME ADDED TO THE OLD.
|
||||
;
|
||||
PLAY JSR RANDOM ; GET RANDOM NUMBER.
|
||||
JSR DELAY ; RANDOM - LENGTH DELAY.
|
||||
JSR RANDOM ; GET ANOTHER
|
||||
AND #$0F ; KEEP UNDER 16 FOR USE AS
|
||||
STA NUMBER ; NUMBER TO GUESS.
|
||||
TAX ; USE AS INDEX TO ...
|
||||
LDA NUMTAB,X ; GET REVERSED PATTERN FROM TABLE
|
||||
ORA PORT1B ; TO DISPLAY IN LEDS 12-15.
|
||||
STA PORT1B
|
||||
JSR CNTSUB ; GET KEYSTROKE 1 DURATION COUNT.
|
||||
CPY NUMBER ; IS KEYSTROKE CORRECT GUESS?
|
||||
BEQ DONE ; IF SO, DONE.
|
||||
LDA #01 ; NO: CLEAR OLD GUESS FROM LEDS.
|
||||
AND PORT1B
|
||||
STA PORT1B
|
||||
JMP PLAY ; TRY AGAIN W/ANOTHER NUMBER.
|
||||
DONE RTS ; RETURN WITH DURATION IN CNTLO+CNTHI
|
||||
;
|
||||
; SUBROUTINE 'COUNTER'
|
||||
; GETS KEYSTROKE WHILE KEEPING TRACK OF AMOUNT OF TIME BEFORE KEYPRESS.
|
||||
;
|
||||
CNTSUB LDY #$0F ; SET UP KEY # COUNTER.
|
||||
KEYLP STY PORT3B ; OUTPUT KEY # TO KEYBOARD MPXR
|
||||
BIT PORT3A ; KEY DOWN?
|
||||
BPL FINISH ; IF YES, DONE.
|
||||
DEY ; COUNT DOWN KEY #.
|
||||
BPL KEYLP ; TRY NEXT KEY.
|
||||
INC CNTLO ; ALL KEYS TRIED, INCREMENT COUNT.
|
||||
BNE CNTSUB ; TRY KEYS AGAIN IF NO OVERFLOW.
|
||||
INC CNTHI ; OVERFLOW, INCREMENT HIGH BYTE.
|
||||
BNE CNTSUB ; TRY KEYS AGAIN.
|
||||
FINISH RTS ; DONE: TIME RAN OUT OR KEY PRESSED.
|
||||
;
|
||||
; SUBROUTINE 'BLINK'
|
||||
; BLINKS LEDS WHOSE BITS ARE SET IN ACCUMULATOR ON ENTRY.
|
||||
BLINK LDX #20 ; 20 BLINKS.
|
||||
STX CNTHI ; SET BLINK COUNTER.
|
||||
STA CNTLO ; BLINK REGISTER
|
||||
BLOOP LDA CNTLO ; GET BLINK PATTERN
|
||||
EOR PORT1B ; BLINK LEDS.
|
||||
STA PORT1B
|
||||
LDA #10 ; SHORT DELAY
|
||||
JSR DELAY
|
||||
DEC CNTHI
|
||||
BNE BLOOP ; LOOP IF NOT DONE.
|
||||
RTS
|
||||
;
|
||||
; SUBROUTINE 'DELAY'
|
||||
; CONTENTS OF ACCUMULATOR DETERMINES DELAY LENGTH.
|
||||
;
|
||||
DELAY STA TEMP
|
||||
DL1 LDY #$10
|
||||
DL2 LDX #$FF
|
||||
DL3 DEX
|
||||
BNE DL3
|
||||
DEY
|
||||
BNE DL2
|
||||
DEC TEMP
|
||||
BNE DL1
|
||||
RTS
|
||||
;
|
||||
; SUBROUTINE 'RANDOM'
|
||||
; RANDOM NUMBER GENERATOR, RETURNS RANDOM NUMBER IN ACCUMULATOR.
|
||||
;
|
||||
RANDOM SEC
|
||||
LDA SCR+1
|
||||
ADC SCR+4
|
||||
ADC SCR+5
|
||||
STA SCR
|
||||
LDX #4
|
||||
RNDLP LDA SCR,X
|
||||
STA SCR+1,X
|
||||
DEX
|
||||
BPL RNDLP
|
||||
RTS
|
||||
;
|
||||
; TABLE OF 'REVERSED' NUMBERS FOR DISPLAY
|
||||
; IN BITS 3-8 OF PORT1B, OR LEDS 12-15.
|
||||
;
|
||||
NUMTAB .DA #%00000010
|
||||
.DA #%10000010
|
||||
.DA #%00100010
|
||||
.DA #%10100010
|
||||
.DA #%00010010
|
||||
.DA #%10010010
|
||||
.DA #%00110010
|
||||
.DA #%10110010
|
||||
.DA #%00001010
|
||||
.DA #%10001010
|
||||
.DA #%00101010
|
||||
.DA #%10101010
|
||||
.DA #%00011010
|
||||
.DA #%10011010
|
||||
.DA #%00111010
|
||||
.DA #%10111010
|
@ -0,0 +1,15 @@
|
||||
.CR 6502
|
||||
.TF translate.hex,hex
|
||||
.LF translate.list
|
||||
;
|
||||
; BINARY TRANSLATION GAME FOR '6502 GAMES' HARDWARE. BOARD SHOULD BE JUMPERED
|
||||
; VIA ADDRESSES SPECIFIED BELOW. CODE IS MOSTLY UNCHANGED FROM THE BOOK,
|
||||
; LOOKUP TABLE 'NUMTAB' WAS MOVED OUT OF ZERO PAGE TO MAKE LOADING A BIT
|
||||
; EASIER.
|
||||
;
|
||||
VIA1 .EQ $C000
|
||||
VIA3 .EQ $CC00
|
||||
|
||||
.OR $0200
|
||||
.TA $0200
|
||||
.IN game.asm
|
@ -0,0 +1,18 @@
|
||||
A9FF8D03C08D02C08D02CCA9008D03CC
|
||||
85058506A9798D01C0A9008D00C08502
|
||||
8501208C02A5028504A5018503A93C8D
|
||||
01C0A9018D00C0A90085028501208C02
|
||||
A501C503F0049027B008A502C504901F
|
||||
B000A9F08D00C0A9008D01C0A94020E4
|
||||
02E605A90AC505D0ABA9F020CC0260A9
|
||||
0E8D00C0A9008D01C0A94020E402E606
|
||||
A90AC506D08EA90E20CC026020F50220
|
||||
E40220F502290F8507AABD08030D00C0
|
||||
8D00C020B602C407F00BA9012D00C08D
|
||||
00C04C8C0260A00F8C00CC2C01CC100B
|
||||
8810F5E602D0EFE601D0EB60A2148601
|
||||
8502A5024D00C08D00C0A90A20E402C6
|
||||
01D0EF608500A010A2FFCAD0FD88D0F8
|
||||
C600D0F26038A509650C650D8508A204
|
||||
B5089509CA10F960028222A2129232B2
|
||||
0A8A2AAA1A9A3ABA
|
@ -0,0 +1,208 @@
|
||||
0000- 4 ;
|
||||
0000- 5 ; BINARY TRANSLATION GAME FOR '6502 GAMES' HARDWARE. BOARD SHOULD BE JUMPERED
|
||||
0000- 6 ; VIA ADDRESSES SPECIFIED BELOW. CODE IS MOSTLY UNCHANGED FROM THE BOOK,
|
||||
0000- 7 ; LOOKUP TABLE 'NUMTAB' WAS MOVED OUT OF ZERO PAGE TO MAKE LOADING A BIT
|
||||
0000- 8 ; 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 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
|
Loading…
Reference in New Issue
Block a user