You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/nmi/pollkeyboard.asm
+15-14Lines changed: 15 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -37,21 +37,22 @@ kbMappedStart = keyReturn
37
37
38
38
; ($4016 reads from the data recorder.)
39
39
40
-
; Similar to the Family Trainer Mat, there are parasitic capacitances that the program must wait for to get a valid result. Family
41
-
; BASIC waits approximately 50 cycles after advancing rows before assuming the output is valid.
42
-
; Usage
43
-
44
-
; Family BASIC reads the keyboard state with the following procedure:
45
-
46
-
; Write $05 to $4016 (reset to row 0, column 0)
47
-
; Write $04 to $4016 (select column 0, next row if not just reset)
48
-
; Read column 0 data from $4017
49
-
; Write $06 to $4016 (select column 1)
50
-
; Read column 1 data from $4017
51
-
; Repeat steps 2-5 eight more times
52
-
53
-
; Note that Family BASIC never writes to $4016 with bit 2 clear, there is no need to disable the keyboard matrix.
40
+
; Similar to the Family Trainer Mat, there are parasitic capacitances that the program must wait for to get a valid result. Family BASIC and the FDS BIOS wait at least 12 cycles (16 if load instructions are considered) between resetting the keyboard and reselecting column 0, and approximately 50 cycles after selecting each column before assuming the output is valid.
54
41
42
+
; Usage
43
+
; Family BASIC and the FDS BIOS read the keyboard state with the following procedure:
44
+
45
+
; Write $05 to $4016 (reset to row 0, column 0), followed by 6 NOPs (12 cycles)
46
+
; Write $04 to $4016 (select column 0, next row if not just reset), followed by a delay of ~50 cycles
47
+
; Read column 0 data from $4017
48
+
; Write $06 to $4016 (select column 1), followed by a delay of ~50 cycles
49
+
; Read column 1 data from $4017
50
+
; Repeat steps 2-5 eight more times
51
+
; Differences between Family BASIC and the FDS BIOS:
52
+
53
+
; The FDS BIOS terminates the routine early if all keys are pressed on column 0 of any row (it determines that the keyboard is disconnected). Family BASIC always reads all rows/columns.
54
+
; The FDS BIOS writes to $4016 with bit 2 clear at the end of the routine (thus disabling the keyboard matrix), but Family BASIC does not.
55
+
; There are currently no known commercial FDS games which use the BIOS routine for keyboard reading[footnotes 1].
0 commit comments