Emulating ZX81 with mbed LPC1768
Emulating ZX81 with mbed LPC1768
This is something I have been toying with for some time.
Just checking to see if there is any interest.
The NXP81 (as I named it) is a standard NXP mbed module with a LPC1768 cpu (ARM Cortex M3 with 64k RAM and 512k flash) mounted inside a ZX81 shell.
Some specs:
Mbed LPC1768 with only passive electronics to connect to SDcard, PS2 keyboard, joystick and VGA monitor
ZX81 emulator with VGA (monochrome) output on a 640x480 (double scan) canvas with the ZX81 screen display centered.
16k ram and added UDG ram at 0x3000
PS2 keyboard and original keyboard support.
ZXpand compatible joystick port
Built in Basic manual , Z80 disassembler, Z80 hexdumper with ZX81 characterset and Z80 register check function
SD card storage with FAT LFN support
Fileselector appears if you type LOAD "" but you can load and save programs by name.
Battery backed RTC for correct timestamps on the SDcard
Unoptimized speed is now roughly 4 times original ZX81 speed in 'turbo' mode and no annoying FAST/SLOW switching, display is always present.
Some ideas left to be done:
Subdirectory support from within the fileselector
Clean up the built in manual and add support for graphic images, maybe even add some Z80 reference books (the SDcard is the limit here)
Hex editor and assembler
Audio in/out support for tape loading/saving (possible through the onboard ADC/DAC pins which are already reserved)
AY-3-8910 or YM2149 emulation
Sorted directory (no ram space available for sorting the huge amount of files possible on the card)
ZX printer emulation over the USB serial link to a PC host
Adding the ZX80 rom, maybe even the Spectrum (alas no colour output possible)
Native conversion of ZX81 Basic to ARM for ridiculous fast speeds...
CVBS output when no VGA monitor detected
To get an idea of how it runs check:
http://youtu.be/2Q1VQDkFSwI
and
http://youtu.be/FTVhCxvLi2c
I can post some images/photos later on.
Just checking to see if there is any interest.
The NXP81 (as I named it) is a standard NXP mbed module with a LPC1768 cpu (ARM Cortex M3 with 64k RAM and 512k flash) mounted inside a ZX81 shell.
Some specs:
Mbed LPC1768 with only passive electronics to connect to SDcard, PS2 keyboard, joystick and VGA monitor
ZX81 emulator with VGA (monochrome) output on a 640x480 (double scan) canvas with the ZX81 screen display centered.
16k ram and added UDG ram at 0x3000
PS2 keyboard and original keyboard support.
ZXpand compatible joystick port
Built in Basic manual , Z80 disassembler, Z80 hexdumper with ZX81 characterset and Z80 register check function
SD card storage with FAT LFN support
Fileselector appears if you type LOAD "" but you can load and save programs by name.
Battery backed RTC for correct timestamps on the SDcard
Unoptimized speed is now roughly 4 times original ZX81 speed in 'turbo' mode and no annoying FAST/SLOW switching, display is always present.
Some ideas left to be done:
Subdirectory support from within the fileselector
Clean up the built in manual and add support for graphic images, maybe even add some Z80 reference books (the SDcard is the limit here)
Hex editor and assembler
Audio in/out support for tape loading/saving (possible through the onboard ADC/DAC pins which are already reserved)
AY-3-8910 or YM2149 emulation
Sorted directory (no ram space available for sorting the huge amount of files possible on the card)
ZX printer emulation over the USB serial link to a PC host
Adding the ZX80 rom, maybe even the Spectrum (alas no colour output possible)
Native conversion of ZX81 Basic to ARM for ridiculous fast speeds...
CVBS output when no VGA monitor detected
To get an idea of how it runs check:
http://youtu.be/2Q1VQDkFSwI
and
http://youtu.be/FTVhCxvLi2c
I can post some images/photos later on.
Last edited by gertk on Thu Oct 25, 2012 8:09 pm, edited 1 time in total.
Re: Emulating ZX81 with mbed LPC1768
Some pictures..
- Attachments
-
- PS2, CVBS, audio and power input
- small_2012-06-23 18.41.56.jpg (56.32 KiB) Viewed 6509 times
-
- VGA and joystick port fit perfectly in extension port
- small_2012-06-23 18.41.44.jpg (67.42 KiB) Viewed 6509 times
-
- Outside is still standard
- small_2012-06-23 18.42.17.jpg (70.27 KiB) Viewed 6509 times
Re: Emulating ZX81 with mbed LPC1768
Some more.. Note this is just a prototype, no commercial intentions so far..
- Attachments
-
- The finished backside, SD card slot and mini USB port of the mbed accessible
- small_2012-06-24 12.46.27.jpg (69.57 KiB) Viewed 6508 times
-
- A view under the hood...
- small_2012-07-18 22.01.16.jpg (133.85 KiB) Viewed 6509 times
Re: Emulating ZX81 with mbed LPC1768
very nice indeed
this is a software emulation then, with the Z80 core been emulated on the arm chip ?
does it do hi-res as well as udg ?
Regards Andy
this is a software emulation then, with the Z80 core been emulated on the arm chip ?
does it do hi-res as well as udg ?
Regards Andy
what's that Smell.... smells like fresh flux and solder fumes...
Re: Emulating ZX81 with mbed LPC1768
Great job!!
You've really worked hard on this and it shows
C
You've really worked hard on this and it shows
C
Re: Emulating ZX81 with mbed LPC1768
No hires yet, the Z80 core is emulated in a non cycle perfect way although I am not sure if cycle perfect is really needed for Hires to work, my emulator is running without Z80 interrupts even.Andy Rea wrote:very nice indeed
this is a software emulation then, with the Z80 core been emulated on the arm chip ?
does it do hi-res as well as udg ?
Regards Andy
The video timing is based on the refresh of the VGA output on which a flag is set which forces a mbed keyscan which fills in the pseudo IO registers for the keyboard and the ZX81 FRAMES variable is updated (only when not PAUSE-ed) so games which rely on FRAMES for timing run the video output at normal speed (60 Hz refresh that is)
I tried the new games from Revivalstudios and they work beautifully, they also gave me a chance to add the ZXpand joystick emulation.
Re: Emulating ZX81 with mbed LPC1768
Some pictures from programs running
- Attachments
-
- ZX galaxians with UDG
- small_2012-07-09 22.22.59.jpg (93.04 KiB) Viewed 6487 times
-
- small_2012-06-18 21.48.44.jpg (84.13 KiB) Viewed 6487 times
-
- small_2012-06-16 13.50.57.jpg (64.2 KiB) Viewed 6487 times
Re: Emulating ZX81 with mbed LPC1768
ah, i suspected that you were doing something funky with the display when you mentioned that the display stays updated even in fast see the problem with hi-res is there are so many different ways to create it, so it would be very difficult to create a catch all software solution for re-creating what would be displayed.
Hence the question, but please don't take it the wrong way, writting a Z80 core of any sort is a great achievment, and your machine is certainly more tidy than my 20Mhz ZX81.... i really like the SD menu, thats pretty slick.
who would have thought... maybe we can have our own ZX-Evo ('81 edition)
Regards Andy
P.s just in case anyone doesn;t know ZX-Evo is a rather splendid modern ZX Spectrum / pentagon Clone.
Hence the question, but please don't take it the wrong way, writting a Z80 core of any sort is a great achievment, and your machine is certainly more tidy than my 20Mhz ZX81.... i really like the SD menu, thats pretty slick.
who would have thought... maybe we can have our own ZX-Evo ('81 edition)
Regards Andy
P.s just in case anyone doesn;t know ZX-Evo is a rather splendid modern ZX Spectrum / pentagon Clone.
what's that Smell.... smells like fresh flux and solder fumes...
- RetroTechie
- Posts: 379
- Joined: Tue Nov 01, 2011 12:16 am
- Location: Hengelo, NL
- Contact:
Re: Emulating ZX81 with mbed LPC1768
Very cool project indeed!
Re: Emulating ZX81 with mbed LPC1768
Yes I already tried to understand some of the hires routines, basically they end up having some sort of framebuffer.Andy Rea wrote:ah, i suspected that you were doing something funky with the display when you mentioned that the display stays updated even in fast see the problem with hi-res is there are so many different ways to create it, so it would be very difficult to create a catch all software solution for re-creating what would be displayed.
The ways you can force the ULA to display anything are quite limited so that should not be such a problem.
The VGA (sub)system is a library which I created together with Ivo van Poorten on the mbed platform. He had made a text only 80x25 output to VGA using the I2S port of the mbed. I modified it heavily to get the timing right and make it into a full 640x480 framebuffer. Alas I needed more ram so the output is reduced to 640x240 which for the ZX81 emulation does not matter, only for the other screens I had to revert to 8x8 pixel font instead of the nice 8x16 pixel font.
So basically I have to video memory regions: one for the original ZX81 DFILE and a full bitmap 640x240 which is displayed. Each Vertical refresh the DFILE is read out and converted to the bitmap buffer... I first had a much simpler routine which bit tested the font bitmap and then put 4 pixels in black or white (pixel by pixel) onto the VGA framebuffer and it still could keep up.. This is how fast an ARM @ 100 MHz is.. I am currently fiddling with the RaspberryPi to create a programming environment based on the 'Bare Metal' lessons of the Cambridge University which uses no OS on the Pi, just your own program.
As the Pi runs at 700 MHz and has lots more ram and a dedicated GPU it should just fly, unfortunately the Pi is not as 'open' as the mbed...
Thanks,Hence the question, but please don't take it the wrong way, writting a Z80 core of any sort is a great achievment, and your machine is certainly more tidy than my 20Mhz ZX81.... i really like the SD menu, thats pretty slick.
The hexdumper and disassembler helped a lot in debugging, the final addition is under F4 which displays the current Z80 register contents. There I could see that all of Revivalstudios programs waited for FRAMES to change which at first did not happen in my emulator (no interrupts)
Yes, the ZX-Evo looks really nice but nowadays storage media is shifting more and more to (micro)SD, newer keyboards and mice are USB only, monitors and TV's have HDMI instead of VGA inputs and microprocessors are becoming so ridiculously fast that they can take the place of FGPA's at a fraction of the cost with the added bonus of being much more easily reprogrammed. As I said earlier, my whole emulator at this moment consists of the mbed LPC1768 module and some passive stuff like diodes (ZX keyboard matrix) and resistors (PS2 keyboard and VGA output) The power supply input is 5 Volt at a few hundred milliamps (mbed + PS2 keyboard). The bare ARM CPU costs only a few Euros (note: the mbed module itself is rather expensive at 50 Euros, for prototyping you could also replace it with the LPCxpresso LPC1769 which costs about 25 Euros)who would have thought... maybe we can have our own ZX-Evo ('81 edition)
Regards Andy
P.s just in case anyone doesn;t know ZX-Evo is a rather splendid modern ZX Spectrum / pentagon Clone.
- Attachments
-
- hex-dumper under F2
- small_2012-08-11 23.40.07.jpg (99.45 KiB) Viewed 6465 times
-
- dis-assembler under F3 (still showing relative offsets)
- small_2012-08-09 23.00.07.jpg (126.78 KiB) Viewed 6465 times