RC-Project-Board/projects/GB-001 Game Board/software/RC-ONE/CH01-Getkey/readkey.list
Tor-Eirik Bakke Lunde d6a1f36d3c Chapter 3
2020-02-29 19:30:52 +01:00

69 lines
5.1 KiB
Plaintext

0000- 4 ;
0000- 5 ; SMALL PROGRAM FOR THE KIM-1 COMPUTER THAT SEEKS TO DEMONSTRATE THE GET KEY
0000- 6 ; ROUTINE FROM CH1 - ESSENTIALLY WE ATTEMPT TO READ THE KEY AND JUST OUTPUT
0000- 7 ; IT ONTO THE DISPLAYS. THE BOOK DETAILS THE USE OF A SYM-1 COMPUTER, SO
0000- 8 ; WHATEVER BUGS YOU MAY FIND CAN BE BLAMED ON ME AND NOT THE AUTHOR OF THE
0000- 9 ; BOOK.
0000- 10 ;
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.
021D- I 4 ; IF A KEY IS DOWN, PA7 OF VIA #3 WILL BE GROUNDED, AND THE CURRENT VALUE
021D- I 5 ; APPLIED TO THE 74154 BE THE KEY NUMBER. WHEN THE PROGRAM DETECTS A KEY CLOSE
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 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
0222-A9 FF I 16 ( 2) LDA #$FF
0224-8D 02 CC I 17 ( 4) STA DDR3B ; SET KEYS FOR OUTPUT
0227-2C 01 CC I 18 ( 4) GETKEY BIT PORT3A ; SEE IF KEY IS STILL DOWN FROM LAST KEY CLOSURE:
022A- I 19 ; KEYSTROBE IN 'N' STATUS BIT.
022A-10 FB I 20 (2**) BPL GETKEY ; IF YES, WAIT FOR KEY RELEASE
022C-A2 0F I 21 ( 2) RSTART LDX #15 ; SET KEY COUNTER TO 15
022E-8E 00 CC I 22 ( 4) NXTKEY STX PORT3B ; OUTPUT KEY # TO 74154
0231-2C 01 CC I 23 ( 4) BIT PORT3A ; SEE IF KEY DOWN: STROBE IN 'N'
0234-10 05 I 24 (2**) BPL BOUNCE ; IF YES, GO DEBOUNCE
0236-CA I 25 ( 2) DEX ; DECREMENT KEY #
0237-10 F5 I 26 (2**) BPL NXTKEY ; NO, DO NEXT KEY
0239-30 F1 I 27 (2**) BMI RSTART ; START OVER
023B-8A I 28 ( 2) BOUNCE TXA ; SAVE KEY NUMBER IN A
023C-A0 12 I 29 ( 2) LDY #$12 ; OUTER LOOP CNT LOAD FOR DELAY OF 50 MS.
023E-A2 FF I 30 ( 2) LP1 LDX #$FF ; INNER 11 US. LOOP
0240-2C 01 CC I 31 ( 4) LP2 BIT PORT3A ; SEE IF KEY STILL DOWN
0243-30 E7 I 32 (2**) BMI RSTART ; IF NOT, KEY NOT VALID, RESTART
0245-CA I 33 ( 2) DEX
0246-D0 F8 I 34 (2**) BNE LP2 ; THIS LOOP USES 2115*5 US.
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- 34