Family BASIC Keyboard: Difference between revisions
m (= is shift -, not shift ^ (see http://www.genkivideogames.com/imagesnew/HVC007back.jpg)) |
TakuikaNinja (talk | contribs) (Add/correct info, based on observations of code from Family BASIC, FDS BIOS, and some keyboard test programs.) |
||
(12 intermediate revisions by 7 users not shown) | |||
Line 1: | Line 1: | ||
The Family | The Family BASIC Keyboard (HVC-007) was a peripheral released with the Family BASIC package in 1984. With the [[Family BASIC Data Recorder|data recorder]] that could be attached to it, it allowed the [[Famicom]] to have the abilities of the average home computer of around that time (including using cassette tape to load/store data in supported games). It is a generic 72 button keyboard (using common matrix logic) which is connected to the Famicom's [[Expansion port#Famicom | expansion port]]. | ||
== Keyboard map == | == Keyboard map == | ||
[[File:Famicom_keyboard.jpg|thumb|Top-down photo of keyboard layout]] | |||
[[File:Family_keyboard.svg|frameless|786px]] | |||
In text format: | |||
F1 F2 F3 F4 F5 F6 F7 F8 | F1 F2 F3 F4 F5 F6 F7 F8 | ||
1 2 3 4 5 6 7 8 9 0 - ^ ¥ STOP | 1 2 3 4 5 6 7 8 9 0 - ^ ¥ STOP CH* INS DEL | ||
ESC Q W E R T Y U I O P @ [ RETURN | ESC Q W E R T Y U I O P @ [ RETURN UP | ||
CTR A S D F G H J K L ; : ] KANA | CTR A S D F G H J K L ; : ] KANA LEFT RIGHT | ||
SHIFT Z X C V B N M , . / _ SHIFT | SHIFT Z X C V B N M , . / _ SHIFT DOWN | ||
GRPH SPACE | GRPH SPACE | ||
* CH = CLR HOME | * CH = CLR HOME | ||
If you have proper font support: | If you have proper font support, with full-width spaces (i.e. "=" is above "-"): | ||
<pre> | <pre> | ||
F1 F2 F3 F4 F5 F6 F7 F8 | F1 F2 F3 F4 F5 F6 F7 F8 | ||
! " # $ % & ' ( ) = | |||
1 ァ 2 ィ 3 ゥ 4 ェ 5 ォ 6 7 8 9 0 - ^ ¥ STOP | 1 ァ 2 ィ 3 ゥ 4 ェ 5 ォ 6 7 8 9 0 - ^ ¥ STOP | ||
ア イ ウ エ オ ナ ニ ヌ ネ ノ ラ リ ル CLR | ア イ ウ エ オ ナ ニ ヌ ネ ノ ラ リ ル CLR | ||
Line 27: | Line 31: | ||
サ シ ス セ ソ マ ミ ム メ モ ー 。 | サ シ ス セ ソ マ ミ ム メ モ ー 。 | ||
〈 〉 ? ␣ ◀ ▶ | |||
SHIFT Z X C V B N M , . / SHIFT | SHIFT Z X C V B N M , . / SHIFT | ||
タ チ ツ テ ト ヤ ユ ヨ ワ ヲ ン | タ チ ツ テ ト ヤ ユ ヨ ワ ヲ ン | ||
Line 35: | Line 39: | ||
</pre> | </pre> | ||
Mind that the DEL key function is actually that of ''Backspace'' we all know and love. | Mind that the DEL key function is actually that of ''Backspace'' we all know and love. | ||
Line 60: | Line 65: | ||
($4016 reads from the data recorder.) | ($4016 reads from the data recorder.) | ||
Similar to the [[Power Pad|Family Trainer Mat]], there are parasitic capacitances that the program must wait for to get a valid result. Family BASIC and the [[FDS BIOS#Other BIOS Calls | 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. | |||
== Usage == | |||
Family BASIC and the FDS BIOS read the keyboard state with the following procedure: | |||
# Write $05 to $4016 (reset to row 0, column 0), followed by 6 NOPs (12 cycles) | |||
# Write $04 to $4016 (select column 0, next row if not just reset), followed by a delay of ~50 cycles | |||
# Read column 0 data from $4017 | |||
# Write $06 to $4016 (select column 1), followed by a delay of ~50 cycles | |||
# Read column 1 data from $4017 | |||
# Repeat steps 2-5 eight more times | |||
Differences between Family BASIC and the FDS BIOS: | |||
* 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 appears to read all rows/columns. (TODO: There may be a separate routine for detecting the keyboard.) | |||
* 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. | |||
There are currently no known [[FDS]] games which use the BIOS routine for keyboard reading. (TODO: Check for games which potentially read the keyboard, including cart-to-disk ports of games that support the data recorder.) | |||
== Matrix == | == Matrix == | ||
{| | {| class=wikitable | ||
! !! colspan="4" | Column 0 | ! !! colspan="4" | Column 0 | ||
! colspan="4" | Column 1 | ! colspan="4" | Column 1 | ||
Line 105: | Line 129: | ||
* There is no backslash key, however, historical reasons have given to using the yen key and symbol for the same meaning. | * There is no backslash key, however, historical reasons have given to using the yen key and symbol for the same meaning. | ||
* The kana are arranged in (grid) alphabetical order, not in the way that modern Japanese computers are. | * The kana are arranged in (grid) alphabetical order, not in the way that modern Japanese computers are. | ||
==Detection== | |||
The game ''Lode Runner'' allows saving level data to tape by pressing SELECT during Edit Mode, but will only provide that option if it detects the Family BASIC Keyboard. The detection procedure (CPU $E9B8) selects the tenth row and expects $4017 AND $1E to return $1E, then writes $00 to $4016 to disable the keyboard and expects $4017 AND $1E to return $00. | |||
==See Also== | |||
* Standalone Family BASIC Keyboard tests (Japanese): | |||
** http://rdev.php.xdomain.jp/makimura/archive/homebrew/keyboard-input-test (key status report only) | |||
** http://rdev.php.xdomain.jp/makimura/archive/homebrew/keyboard-input-test2 (key status report + key display) | |||
== References == | == References == | ||
* Reverse-engineered schematics by [http:// | * Reverse-engineered schematics by [http://cmpslv2.starfree.jp/ Enri]: | ||
** http:// | ** http://cmpslv2.starfree.jp/Famic/Fambas.htm | ||
** Also available [http://atariusa.com/Famicom_Schematics/FC%20Family%20Basic%20Keyboard%20and%20Sound%20Circuit%20Schematic.png here] and [http://atariusa.com/Famicom_Schematics/FC%20Keyboard%20Key%20Schematic.png here] | ** Also available [http://atariusa.com/Famicom_Schematics/FC%20Family%20Basic%20Keyboard%20and%20Sound%20Circuit%20Schematic.png here] and [http://atariusa.com/Famicom_Schematics/FC%20Keyboard%20Key%20Schematic.png here] | ||
* [ | * Photographs of the keyboard by [https://commons.wikimedia.org/wiki/File:Nintendo-Famicom-Family-Basic-Keyboard-wCart.jpg Evan-Amos] | ||
* [http://www.pfu.fujitsu.com/hhkeyboard/kb_collection/images/hvc-007.gif Stylized keycaps diagram] from [http://www.pfu.fujitsu.com/hhkeyboard/kb_collection/ PFU's Happy Hacking Keyboard keyboard history library] | * [http://www.pfu.fujitsu.com/hhkeyboard/kb_collection/images/hvc-007.gif Stylized keycaps diagram] from [http://www.pfu.fujitsu.com/hhkeyboard/kb_collection/ PFU's Happy Hacking Keyboard keyboard history library] | ||
[[Category:Controllers]] | [[Category:Controllers]] |
Latest revision as of 03:52, 27 September 2024
The Family BASIC Keyboard (HVC-007) was a peripheral released with the Family BASIC package in 1984. With the data recorder that could be attached to it, it allowed the Famicom to have the abilities of the average home computer of around that time (including using cassette tape to load/store data in supported games). It is a generic 72 button keyboard (using common matrix logic) which is connected to the Famicom's expansion port.
Keyboard map
In text format:
F1 F2 F3 F4 F5 F6 F7 F8 1 2 3 4 5 6 7 8 9 0 - ^ ¥ STOP CH* INS DEL ESC Q W E R T Y U I O P @ [ RETURN UP CTR A S D F G H J K L ; : ] KANA LEFT RIGHT SHIFT Z X C V B N M , . / _ SHIFT DOWN GRPH SPACE * CH = CLR HOME
If you have proper font support, with full-width spaces (i.e. "=" is above "-"):
F1 F2 F3 F4 F5 F6 F7 F8 ! " # $ % & ' ( ) = 1 ァ 2 ィ 3 ゥ 4 ェ 5 ォ 6 7 8 9 0 - ^ ¥ STOP ア イ ウ エ オ ナ ニ ヌ ネ ノ ラ リ ル CLR INS DEL ESC Q W E R T Y パ U ピ I プ O ペ P ポ @ [ 「 RETURN HOME カ キ ク ケ コ ハ ヒ フ ヘ ホ レ ロ + * ▲ CTR A S D F G H J K L ; : ] 」 カナ サ シ ス セ ソ マ ミ ム メ モ ー 。 〈 〉 ? ␣ ◀ ▶ SHIFT Z X C V B N M , . / SHIFT タ チ ツ テ ト ヤ ユ ヨ ワ ヲ ン ▼ GRPH [............SPACE............]
Mind that the DEL key function is actually that of Backspace we all know and love.
Hardware interface
Input ($4016 write)
7 bit 0 ---- ---- xxxx xKCR ||| ||+-- Reset the keyboard to the first row. |+--- Select column, row is incremented if this bit goes from high to low. +---- Enable keyboard matrix (if 0, all voltages inside the keyboard will be 5V, reading back as logical 0 always)
Incrementing the row from the (keyless) 10th row will cause it to wrap back to the first row.
Output ($4017 read)
7 bit 0 ---- ---- xxxK KKKx | ||| +-+++--- Receive key status of currently selected row/column.
Any key that is held down, will read back as 0.
($4016 reads from the data recorder.)
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.
Usage
Family BASIC and the FDS BIOS read the keyboard state with the following procedure:
- Write $05 to $4016 (reset to row 0, column 0), followed by 6 NOPs (12 cycles)
- Write $04 to $4016 (select column 0, next row if not just reset), followed by a delay of ~50 cycles
- Read column 0 data from $4017
- Write $06 to $4016 (select column 1), followed by a delay of ~50 cycles
- Read column 1 data from $4017
- Repeat steps 2-5 eight more times
Differences between Family BASIC and the FDS BIOS:
- 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 appears to read all rows/columns. (TODO: There may be a separate routine for detecting the keyboard.)
- 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.
There are currently no known FDS games which use the BIOS routine for keyboard reading. (TODO: Check for games which potentially read the keyboard, including cart-to-disk ports of games that support the data recorder.)
Matrix
Column 0 | Column 1 | |||||||
---|---|---|---|---|---|---|---|---|
$4017 bit | 4 | 3 | 2 | 1 | 4 | 3 | 2 | 1 |
Row 0 | ] | [ | RETURN | F8 | STOP | ¥ | RSHIFT | KANA |
Row 1 | ; | : | @ | F7 | ^ | - | / | _ |
Row 2 | K | L | O | F6 | 0 | P | , | . |
Row 3 | J | U | I | F5 | 8 | 9 | N | M |
Row 4 | H | G | Y | F4 | 6 | 7 | V | B |
Row 5 | D | R | T | F3 | 4 | 5 | C | F |
Row 6 | A | S | W | F2 | 3 | E | Z | X |
Row 7 | CTR | Q | ESC | F1 | 2 | 1 | GRPH | LSHIFT |
Row 8 | LEFT | RIGHT | UP | CLR HOME | INS | DEL | SPACE | DOWN |
Hardware
The Family BASIC Keyboard is implemented using a CD4017 decade counter (to scan the rows of the keyboard matrix), a CD4019 quad AND-OR gate, and one sixth of a CD4069 hex inverter. The latter two are combined to make a quad 1-of-2 selector, equivalent to a CD4519 or a 74'157. (Another three inverters are used to interface to the Family BASIC Data Recorder)
Miscellaneous
- Unlike the PC keyboard, but similar to the Commodore 64 keyboard, the sixteen keys corresponding to ASCII $2C-$3B all specify the ASCII code point should be XORed with $10 when the SHIFT key is pressed. This can be used to simplify the keyboard decoding logic in your program.
- There is no backslash key, however, historical reasons have given to using the yen key and symbol for the same meaning.
- The kana are arranged in (grid) alphabetical order, not in the way that modern Japanese computers are.
Detection
The game Lode Runner allows saving level data to tape by pressing SELECT during Edit Mode, but will only provide that option if it detects the Family BASIC Keyboard. The detection procedure (CPU $E9B8) selects the tenth row and expects $4017 AND $1E to return $1E, then writes $00 to $4016 to disable the keyboard and expects $4017 AND $1E to return $00.
See Also
- Standalone Family BASIC Keyboard tests (Japanese):
- http://rdev.php.xdomain.jp/makimura/archive/homebrew/keyboard-input-test (key status report only)
- http://rdev.php.xdomain.jp/makimura/archive/homebrew/keyboard-input-test2 (key status report + key display)
References
- Reverse-engineered schematics by Enri:
- http://cmpslv2.starfree.jp/Famic/Fambas.htm
- Also available here and here
- Photographs of the keyboard by Evan-Amos
- Stylized keycaps diagram from PFU's Happy Hacking Keyboard keyboard history library