New project: ZX Spectrum Enigma

Project page

I’ve started a new project where I will attempt to make an Enigma simulator on the ZX Spectrum 48 in assembly. I’ve always had a fascination with the Enigma machine. Or I should say, I’ve always had a fascination with any vintage mechanical machines. And I really want to learn Z80 assembly, so I decided to write it for the ZX Spectrum.

I’m aware there have been implementations for the ZX Spectrum before – – and it isn’t only that this version is written in Basic, I think this project will be a good introduction for myself to program assembly again. At least the initial version will be limited in the visual aspect and it doesn’t include real animations, so quite a bit of it will be logic.

I intend to make my own Z80 processor based computer in a bit, but first want to experiment using an already working system. I have no special memories of any 8 bit processor so I looked at their specs and chose one based on those.

Some of my criteria that resulted in choosing the Z80: no multiple voltages (5V only), extensively used in period computers, still readily available (New, new old stock, second hand) and easy to build a circuit around (Not line multiplexing)

The 6502 and Z80 where the 2 big standouts. From there I picked the Z80 for a few reasons: separate IO addresses and execution starts at $0000. I personally think the way the 6502 has it memory organized very strange. The rom in the high part and starting code executing somewhere in the middle, and the limit of the 255 byte stack (The 6502 only uses 1 byte for the stack pointer).

I’ve never done any Z80 assembly programming, nor have I ever used the ZX Spectrum. I’ve done PLC programming and some x86 during my university years but that has been over 12 years ago (for PLC about 15 years). And while I now got about 12 years of professional Java programming experience, this won’t help me much in this case. I do know how to tackle problems and work out algorithms. But with assembly programming go to a much deeper level than I’m used to.

Basic project overview

In the basic version I plan to create 3 views in the program. The main one where you have a view of the 26 lighted characters. It won’t show the keyboard, since you will use the keyboard on the ZX Spectrum to enter the text. Then there will be a view showing an interface to choose and configure the rotors, and one for the plug-board.

I haven’t yet decided how to switch to the rotor or plug-board view or how these will be used. Also the design of those screens are something I need to think about.

For the screen with the bulbs I plan to show the 26 characters on discs and using the ZX Spectrum screen attributes change the colors. It will possibly also show an output of the processed character so you can see the encrypted or decrypted values for longer than you hold the key.

Optional extras

  • Show the rotor and plug-board settings on the main view. So you can also see the rotor positions progress.
  • Add a function to send the processed text to the printer.
  • Add the usage procedure instructions so you can follow these without having them externally.
  • Add support for the navy version of the Enigma (4 rotor positions and 8 rotors) or any of the others
  • Add code book generation. Since the ZX Spectrum has no persisted memory, we can’t store them.
    So they could be generated using a pseudo random value that the user enters. Or we could print them. The ZX Spectrum compatible printers have only a small amount of characters per line (the ZX Spectrum screen itself has the same problem) so printing the full settings on a single line won’t be possible (The plug-board settings take quite a bit of space)

Having original code books in the program won’t be possible due to size. And I don’t think the Germans used a pseudo random number generator to generate their code-books. (Joke)