Ten Key Pad

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:

  1. Write $20 to data port and wait a bit
  2. Read data from bits 3-0 (becomes lower nibble)
  3. Write $00 to data port and wait a bit
  4. Read data from bits 3-0 (becomes upper nibble)

Write $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):

Ten Key Pad packet format
Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
1st byte d c
2nd byte
3rd byte b x
4th byte r y s
5th byte 7 6 5 4 3 2 1 0
6th byte # 9 8
7th byte n *
8th byte U R
9th byte
10th byte D L

The numbers, * and # 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 labels):

Mega Anser key names
KeyJapaneseEnglish
n次頁Next page
b前頁Previous page
r実行Execute
x漢字変換Kanji conversion
yカナ漢字Kana / Kanji
cキャンセルCancel
d削除Delete
s通信終了Disconnect

Anybody who can help verify if the x and y keys are correct? Going by Mega Anser behavior here (the x 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:

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).

Keypad layout

The keypad is split into three sections vertically. The top row, with a light blue background, has the keys Disconnect, Cancel and Delete. The middle block has the numbers, * and # to the right (in the same arrangement as a phone), while the left column has the Kanji Conversion and Kana/Kanji keys. In the bottom block, to the right are the four arrows, while the column at the left (with a purple background) has the Previous Page, Next Page and Execute keys. There's a small red light located at the top of the keypad, right above the Disconnect key.