The Ten Key Pad is the main input peripheral for Mega Anser (as opposed to the controller), although it may also be supported by other modem software. It includes a phone-like keypad, arrows, and some other buttons for entering commands.
The keypad has only ever been released in Japan and the labels are in Japanese. The names provided here are just a straightforward translation and the labels may have changed if localized.
Setting up the keypad
Setting up the keypad is a matter of writing
$60 to both
the control and data ports (check the page on setting up controllers for details on those ports):
; a0 = IoData1 or IoData2 FastPauseZ80 move.b #$60, 6(a0) ; Control port move.b #$60, (a0) ; Data port ResumeZ80
Reading the keypad
To read the state of the keypad, do the following 10 times, giving you a byte every time:
$20to data port and wait a bit
- Read data from bits 3-0 (becomes lower nibble)
$00to data port and wait a bit
- Read data from bits 3-0 (becomes upper nibble)
$60 when you're done.
; a0 = IoData1 or IoData2 lea (Buffer), a1 moveq #10-1, d0 @Loop: ; Gotta stop Z80 a bit FastPauseZ80 ; Read lower nibble move.b #$20, (a0) nop nop nop move.b (a0), d1 ; Read upper nibble move.b #$00, (a0) nop nop nop move.b (a0), d2 ; Let Z80 run meanwhile ResumeZ80 ; Add byte to buffer and.b #$0F, d1 lsl.b #4, d2 or.b d2, d1 move.b d1, (a1)+ ; Keep going dbf d0, @Loop ; Let keypad idle again FastPauseZ80 move.b #$60, (a0) ResumeZ80
The above procedure should give you 10 bytes. Every bit is a different key, where 1 = pressed and 0 = released (unused bits are always 0). The meaning of the bits are as follows (yes, most of them go unused):
|Bit 7||Bit 6||Bit 5||Bit 4||Bit 3||Bit 2||Bit 1||Bit 0|
# are exactly what they
say. The uppercase letters are the arrows (up, down, left, right). The
lowercase letters are as follows (note that the keypad has Japanese
|カナ漢字||Kana / Kanji|
Anybody who can help verify if the
keys are correct? Going by Mega Anser behavior here (the
key starts text input, if you wonder), but without a keypad at hand and
not so obvious names it becomes hard to verify.
Some notes about key names:
- "Execute" is what we'd call "Enter" nowadays.
- "Delete" is what we'd call "Backspace" nowadays.
- "Cancel" is what we'd call "Escape" nowadays.
- The term "kanji conversion" refers to IME input.
The above discrepancies (aside from the last one) are not a case of a too literal translation, but that key naming conventions have changed a lot since then (especially true for the Delete key, the name Backspace only became the norm when PC took over).