Building a keyboard adapter for the early PC8801. (Part 1 - Research)
Tags: computer pc88 pc8801mkii keyboard nec retrochallenge retrochallenge-april-2018
If all goes well, I will soon be the owner of an NEC PC-8801mkII “Model 30.” The platform is famous in Japan, as later models of the PC88 featured a ton of independent games, including many from developers who would go on to create games that were popular worldwide (Thexder, Snatcher and Ys all got their start on this platform). It also has a lot of trash, but neither of these things are interesting to me right now. I’d be happier just getting the computer to work (not least, because as a non-SR mkII, there are very few games I can enjoy on it anyway).
The Problem
When I was shopping, there were almost no PC88 keyboards available. There were lots of PC98 keyboards for sale, and I got quite a few of those, but the PC88 is becoming thin on the ground. What’s more, its keyboards seem to be prized by mechanical-keyboard aficionados for having Alps switches, so there are probably thousands of them in some guy’s closet next to some Symbolics “space cadet” Lisp-machine keyboards.
Things are further complicated by the fact that there are apparently multiple PC-88 keyboards, with incompatible connectors:
- PC-8801 original model (14-pin BIG din)
- PC-8801mkII to FR/MR (13-pin DIN)
- PC-8801FH/MH and onwards (“Type-A”)
- PC-88VA (“Type-B”)
Notes
- On the “post-FH” PC-88, the keyboard connection moves to a serial bus and a 5-pin mini-DIN connector. There are some details on the serial protocol and the revised keycode table, but this article won’t go into it because if you have an FH+, I’m very jealous.
- It appears that all-non-B keyboards can be toggled via an on-board switch to work with the VA, which probably changes the serial protocol or something. Check for the switch in one of the “slots” under the little flip-out feet that prop the keyboard up.
- Type-C through Type-G also exist and also seem to be compatible with all FH+ machines.
What is there to do? This entry covers the initial research I have made to build an adapter from a more common breed of keyboard (USB or PS/2, haven’t decided which) so that my PC-8801mkII can be used. Hopefully in the future, it will also serve to help someone else revive an ancient machine instead of just throwing it in the trash because they can’t find a keyboard.
Future entries will go into the construction of the adapter, assuming I can’t locate a compatible keyboard.
Other Implementations
All of these other adapters have been developed by Koichi Nishida, and the links below go to the archives of those pages.
- USB -> 8801mkII keyboard adapter. AVR assembly.
- USB -> 8801 mkII keyboard adapter 2 a revised version from the same author.
- Windows -> USB -> 8801mkII keyboard adapter. Same developer as above, with C++ source code.
The Basics
As stated here, the PC-88 keyboard is not like modern, normal keyboards. For a keyboard like you would see on an Amiga, a Macintosh or a PS/2-equipped IBM PC, the keyboard and the computer usually communicate bidirectionally over a serial protocol. This keeps the pins down, and the extra microcontroller added to the keyboard isn’t that big of a deal in the long run, price-wise.
However, the PC-8001, the PC88’s ancestor, is from late 1979. It only has a 4MHz Z80; your average keyboard controller from the late 80s (such as the Amiga’s 6502-based MOS 6570-36) has way more beef than the main processor! I guess NEC decided that since they were the sole source of the keyboards, they might as well just build them as cheaply as possible. In fact, the PC-8001 (and earliest PC-8801s) had hardwired keyboards.
What this means in practice is that the PC88 itself does the key reading. The keyboard connector has 13 pins (14 if you count the ground sleeve), and in order to read a key, the computer triggers four of those pins. A multiplexer on the keyboard uses those four lines to activate the appropriate row on the keyboard matrix, and eight lines are triggered in response to tell the computer which keys on that row are pressed.
Open Questions
- What are the patterns of the four lines?
- Are they brought low or pulled high to signal a “1?”
- Is an off-the-shelf hobbyist-friendly microcontroller like the Atmel Atmega fast enough to respond and satisfy the PC88?
One assumption I have made, before having access to the actual machine, is that the keyboard matrix must follow the memory layout. It doesn’t make a lot of sense for it to be any other way, which brings us to…
Keyboard Layout in Memory
In order to determine the keyboard layout in memory, I looked at the source code of the popular M88 PC88 emulator. It has both a PC98 and a regular IBM PC 104-key keymap in win32/WinKeyIF.cpp
, but the structure that is generated in the end looks about the same.
There are 14 ‘rows,’ which seems to indicate that all four bits are needed (24 = 16).
Off. | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
---|---|---|---|---|---|---|---|---|
00 | Numpad 0 | Num1 | Num2 | Num3 | Num4 | Num5 | Num6 | Num7 |
01 | Numpad 8 | Num9 | Num* | Num+ | Num= | Num, | Num. | RET |
02 | @ | A | B | C | D | E | F | G |
03 | H | I | J | K | L | M | N | O |
04 | P | Q | R | S | T | U | V | W |
05 | X | Y | Z | [ | ¥ | ] | ^ | - |
06 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
07 | 8 | 9 | : | ; | , | . | / | _ |
08 | CLR | ↑ | → | BKSP | GRPH | カナ | Shift | Ctrl |
09 | STOP | F1 | F2 | F3 | F4 | F5 | Space | ESC |
0a | Tab | ↓ | ← | HELP | COPY | Num- | Num/ | Caps Lock |
0b | Roll Down | Roll Up | ||||||
0c | F6 | F7 | F8 | F9 | F10 | BKSP | INS | DEL |
0d | 変換 | 決定 | PC | 全角 |
There is also an additional row ($0e) for the PC-88 FH, which is described here: I/O Map. I don’t know what $0f would do, it might be a special code to make the keyboard do something, if anything at all.
I don’t know why they chose ABCDEF instead of QWERTY (as the PC98 does) in this memory map. Seems like you would have to wire the keyboard in a very strange way so that the ‘rows’ of the matrix are alphabetical. It makes more sense to me that you would wire it based on the physical layout of the keyboard, but perhaps the software team finished their work before the hardware guys started on the keyboard PCB.
Open Questions
- How do we map all these accelerators? The PC 104-key keyboards don’t really have a great equivalent for “変換”
Conclusions
For now, I think I will try to source an official keyboard.
If that doesn’t work, I’ll build the adapter that I found on Japanese Google up above. If that doesn’t work out, I’ll have to port their basic strategy to a different kind of adapter. In the meantime, this might be the only English-language information about the early PC88 keyboard, so hopefully it will help someone else.
Update History
This article is surprisingly popular, and I’m trying to keep it up to date so that it remains useful to people.
- November 29, 2021: Changed links to Nishida-san’s keyboard adapters to use archive.org instead of the original links. Fixed some typos.
- March 4, 2025: Updated information on the original NEC PC-8801 keyboard (it’s incompatible with mkII/mkIISR) and added information on the PC-88VA toggle switch.