ZX80 / ZX81 Emulator for the Raspberry Pi Pico

Emulator and emulator development specific topics
Exile
Posts: 31
Joined: Tue Jan 03, 2023 9:50 pm

ZX80 / ZX81 Emulator for the Raspberry Pi Pico

Post by Exile »

This may be a very niche area, but I’ve recently pulled together code from the community to create a ZX80/81 emulator running on the Raspberry Pi Pico (ARM M0+ microcontroller). Perhaps the low cost, relatively low performance and software generated display of the Pico makes it a kind of 21st century relative of the ZX80 and ZX81?

Key features:
  • Runs on the Pimoroni Pico VGA demo board and Pimoroni Pico DVI demo board (HDMI). Supports sound over on-board DAC. Also supports custom VGA RGB 332 board (PWM sound)
  • Provides an immersive full screen experience, with a very fast boot time and no operating system
  • Simultaneous USB keyboard and joystick support (using a powered USB hub)
  • The small form factor makes the board easy to mount in period or reproduction cases
  • Emulates pseudo and Hi-res graphics
  • Emulates ZonX and Quicksilva sound
  • Emulates QS User Defined Graphics
  • Emulation runs at accurate speed of a 3.25MHz ZX81
  • Emulates 50Hz and 60Hz display
  • Support for up to 320 by 240 pixel display, i.e. 40 character width and 30 character height
  • Load .p, .81, .o and .80 files from micro SD Card. Save .p and .o files
  • Set-up of emulator (computer type, RAM, Hi-Res graphics, sound, joystick control etc) configurable on a per program basis, using config files
  • Optionally displays graphic of keyboard (taken from sz81). Can type in code with keyboard visible
The vast majority of the emulation code comes from sz81 and EightyOne. There is also input from MCUME and pico-zxspectrum. By design, the emulator is black and white only. That does mean that the excellent Chroma 81 is not supported.

Full source code, documentation, list of tested applications and release binaries can be found at: https://github.com/ikjordan/picozx81

It was a fun exercise that definitely helped me understand the inner workings of the ZX81 in more detail. Hopefully this may prove useful to someone! I’d value any feedback.
Spinnetti
Posts: 248
Joined: Sat Sep 12, 2020 11:29 pm

Re: ZX80 / ZX81 Emulator for the Raspberry Pi Pico

Post by Spinnetti »

Perfect timing! I just designed and made some replica ZX80 cases and got great replica keyboards with real switches out of Germany. Is there a way to connect the keyboard to the board?
Zeddy: ZX80, ZX81/ZXpand, TS1000/ZXpand, TS1500/Zxpand+
Speccy: 48k, +, +2, +3, TS2068, "Bare Metal" Pi, Next KS2, IF1/Microdrives/Vdrive/Light Gun/VGA-Joy
QL: Minerva/QL-VGA/Custom PSU
C5: 24v, LiFE battery, Disc brakes
User avatar
Paul
Posts: 1496
Joined: Thu May 27, 2010 8:15 am
Location: Germanys west end

Re: ZX80 / ZX81 Emulator for the Raspberry Pi Pico

Post by Paul »

Thank you VERY much.
I was looking forward to such an emulator.
It will be a joy to use and a help in understanding the Pico programming as well.
I had a quick look into the board definition header files.
Do I understand this right that I might adapt to different boards by changing the PIN definitions?
I would like to use the picomite VGA board I already have.
If you would be willing to help I could donor a picomite board (empty or built) or donate the money to you to buy one.

Kind regards
Paul

P.S. Original Keyboard support is also on my wishlist ;) Do the USB Keyboards support multiple keypresses at a time?
In theory, there is no difference between theory and practice. But, in practice, there is.
Exile
Posts: 31
Joined: Tue Jan 03, 2023 9:50 pm

Re: ZX80 / ZX81 Emulator for the Raspberry Pi Pico

Post by Exile »

Spinnetti wrote: Thu May 18, 2023 1:28 am Perfect timing! I just designed and made some replica ZX80 cases and got great replica keyboards with real switches out of Germany. Is there a way to connect the keyboard to the board?
Yes, there is a way to connect to such a keyboard. There are not enough free GPIO pins to connect direct to keyboard to the board, but it can be done by using another Pico to turn the ZX80/81 keyboard into a USB keyboard. It may seem excessive to use a whole pico as a keyboard controller, but they are cheap and I believe there is enough space to put the Pimoroni board, plus another Pico, plus a small USB hub into a ZX80 or ZX81 case

I've got a repo that includes code to convert a ZX80/81 keyboard to USB: https://github.com/ikjordan/ZX81_USB_KBD I have used the resulting keyboard with the Pico emulator. If the keyboard is the only peripheral, then it can be plugged straight into the USB port of the Pico on the emulator board with the power connected to the USB power socket of the Pimoroni board. If you want to connect other USB peripherals (such as another keyboard, or a USB joystick) then the ZX80/81 keyboard can be connected via a USB hub.

A challenge is to be able to trigger the emulator menus from a ZX80 / ZX81 keyboard, as function key and Escape key presses are used. Two options spring to mind:
1) Use a separate "full" wireless USB keyboard, as well as the ZX80/81 keyboard. I have tried this and it works well, function keys can be pressed and frankly it is easier to type in long listings using such a keyboard :)
2) Add a separate button on the side of the case, when that button is pressed, the number keys are translated to function key presses
Spinnetti
Posts: 248
Joined: Sat Sep 12, 2020 11:29 pm

Re: ZX80 / ZX81 Emulator for the Raspberry Pi Pico

Post by Spinnetti »

Thanks for the tips!
Zeddy: ZX80, ZX81/ZXpand, TS1000/ZXpand, TS1500/Zxpand+
Speccy: 48k, +, +2, +3, TS2068, "Bare Metal" Pi, Next KS2, IF1/Microdrives/Vdrive/Light Gun/VGA-Joy
QL: Minerva/QL-VGA/Custom PSU
C5: 24v, LiFE battery, Disc brakes
User avatar
Paul
Posts: 1496
Joined: Thu May 27, 2010 8:15 am
Location: Germanys west end

Re: ZX80 / ZX81 Emulator for the Raspberry Pi Pico

Post by Paul »

Where we were short of function Keys we like to use a shift-shift like a double-click to get into a function mode.
Shift-shift-1 for F1, shift-shift-9 for F9 etc.
In theory, there is no difference between theory and practice. But, in practice, there is.
Exile
Posts: 31
Joined: Tue Jan 03, 2023 9:50 pm

Re: ZX80 / ZX81 Emulator for the Raspberry Pi Pico

Post by Exile »

Paul wrote: Thu May 18, 2023 8:39 am Thank you VERY much.
I was looking forward to such an emulator.
It will be a joy to use and a help in understanding the Pico programming as well.
I had a quick look into the board definition header files.
Do I understand this right that I might adapt to different boards by changing the PIN definitions?
I would like to use the picomite VGA board I already have.
If you would be willing to help I could donor a picomite board (empty or built) or donate the money to you to buy one.

Kind regards
Paul

P.S. Original Keyboard support is also on my wishlist ;) Do the USB Keyboards support multiple keypresses at a time?
I've had a quick look at the picomite board. It looks like the VGA display should work. If you could lend me a board that would be great, I could then try out the changes and add a tested binary to the repo.

The USB keyboards do support multiple key presses, so for example you can move and fire simultaneously in Galaxians by pressing 8 and 0, but the emulator runs the standard Sinclair ROM routines, so when typing in a BASIC program only 1 keypress is detected at a time, in a similar way to a real ZX81.

Thanks for the suggestion regarding the double shift press, I'll experiment with that and try to add it.
Exile
Posts: 31
Joined: Tue Jan 03, 2023 9:50 pm

Re: ZX80 / ZX81 Emulator for the Raspberry Pi Pico

Post by Exile »

Paul wrote: Thu May 18, 2023 3:51 pm Where we were short of function Keys we like to use a shift-shift like a double-click to get into a function mode.
Shift-shift-1 for F1, shift-shift-9 for F9 etc.
What a great suggestion! I implemented this today as a runtime option and it works really nicely. It makes using the emulator with a ZX81 USB keyboard much easier. Thank you :)

I've updated the repo with new executables and added a section to the Readme
User avatar
Paul
Posts: 1496
Joined: Thu May 27, 2010 8:15 am
Location: Germanys west end

Re: ZX80 / ZX81 Emulator for the Raspberry Pi Pico

Post by Paul »

I know my reputation as a feature creeper :oops:
Next thing I'd like to see is a user programmable keyboard.
For example shift-shift-p could be translated to "PRINT PEEK 16388+255*PEEK 16389 RET"
Preferable user definable and with another command saveable to internal eeprom
In theory, there is no difference between theory and practice. But, in practice, there is.
User avatar
Paul
Posts: 1496
Joined: Thu May 27, 2010 8:15 am
Location: Germanys west end

Re: ZX80 / ZX81 Emulator for the Raspberry Pi Pico

Post by Paul »

Did you add this to the Emulator?
I thought it would be added to the USB-Keyboard enabling the usb keyboard to be used for other purposes as well (other emulators for example)
And it would be great if the (or an added) LED could show this new mode of the Keyboard.
In theory, there is no difference between theory and practice. But, in practice, there is.
Post Reply