Jim Blimey

Home Archive Games Random Games Lucky Dips Links

The SpecPi

22/03/2021

Since returning to the world of the Speccy I have been hankering for something closer to that original experience. I got myself a very nice "water droplet" style keyboard to give me that Speccy + feel, but it still wasn't quite right and with the prices on ebay sky high I had almost reserved myself to having to make do.

That was until I came across from an issue of The MagPi magazine from 2018 which contained an article detailing how you can connect the keyboard membrane of a Speccy (almost) directly to the GPIO on a Raspberry Pi. This was incredible news to me! I'd seen a few different projects for connecting a Speccy membrane to a modern computer but these were all very pricey - I already have a Pi or two kicking round the place so I figured it'd be worth me investing in a nice new case from ZX Renew - still cheaper than trying to get a beaten up Speccy from ebay!

The concept is simple: KB1 (data lines) are connected directly to the GPIO, KB2 (address lines) are connected via 1N4148 diodes to stop short circuits.

KB2 on a breadboard

The MagPi article goes for a fully internal approach using a Pi Zero and stripboard, but due to the fiddly nature and my inability to solder I got myself a couple of mini breadboards and placed them inside the Speccy's case with the wires coming out of the back connecting to the Pi 3B+ on my desk. You can see the internal version on page 26 of The MagPi issue 67 linked above.

The main required components are:

KB1 connects to GPIO pins 26,19,13,6,5 and KB2 to 25,24,23,22,27,18,17,4. These assignments keep the wires pretty tidy but you can use whichever GPIO pins you wish and if you're using a Pi 1 you will have to. The momentary button sits on GPIO 12 and GND.

The software side of things is very interesting, using Linux's uinput module key presses are read through the GPIO and then translated into keys on a virtual keyboard device. The momentary button is used to switch between the standard Spectrum mode and a special mode that treats the lower numbers as function keys and the higher numbers as arrow keys to allow controlling of the fuse emulator. This script is written in Python and not event driven so there can be a lag or missed key press, I am currently in the process of writing my own C based program using events which will hopefully remove the lag and missed key presses problem. See the github project page for more information.

Another solution is an emulator called ZXBaremulator, this is a "bare metal" emulator which does not have an underlying OS and boots up in about 6 seconds on my Pi 3B+ - that's pretty close to the real thing! The input on the Spectrum keyboard is quick and doesn't miss key presses. The downside to this emulator is it lacks save states and USB controller support and is no longer being actively developed.

My final solution has been to have a minimal Raspbian install to get the networking and USB controller goodness and just have an fb or SDL build of fuse run on boot, I really don't mind a bit of boot time.

All credit for this fantastic method goes to PJ Evans of The MagPi.

Mastodon