Page 1 of 1

ZX Spectrum emulator

Posted: Wed Sep 12, 2018 2:15 pm
by VilleK
This is a ZGE port of Jasper ZX Spectrum emulator: https://github.com/begoon/jasper

Features:
- Kempston joystick emulation (use a PC joypad, or cursor + ctrl keys)
- Supports .sna and .z80 format files. More available here: http://www.planetemu.net/roms/sinclair-zx-spectrum-z80

I did this project as a test to see if the ZGE scripting language is fast and powerful enough to run a emulator at full speed and I'm pleased with the results. Recent optimizations such as function inlining and switch-statement jump tables make all the difference here.

Re: ZX Spectrum emulator

Posted: Wed Sep 12, 2018 4:00 pm
by Kjell
:o

Very cool & nice benchmark! No sound though? Admittedly .. i can imagine it's a little tricky to do without being able to write to a sound buffer directly, especially when you want to for example support games that basically halt the program for a bit and write to the AY-3-8910 as fast as possible ( for rudimentary sample playback ).

K

Re: ZX Spectrum emulator

Posted: Thu Sep 13, 2018 6:54 am
by VilleK
The Jasper emulator does not try to emulate sound so I didn't attempt either. And I think you are right that it would require a method of writing to the sound buffer directly.

The 48k Spectrum is a very simple device with no additional support chips so the emulator is basically just Z80 emulation together with a shader to convert the ZX Spectrum video memory layout to the screen. Later 128k Spectrum model had AY-sound chip but initially there was just a speaker with on/off control (like the original PC).

If you run exe-compressor then all this will fit in 65kb: The emulator, the 16k Spectrum ROM, a 48kb game, and the ZGE engine itself. Also a good benchmark for compactness.

Re: ZX Spectrum emulator

Posted: Thu Sep 13, 2018 1:09 pm
by Kjell
Hej Ville,
VilleK wrote:The 48k Spectrum is a very simple device with no additional support chips so the emulator is basically just Z80 emulation together with a shader to convert the ZX Spectrum video memory layout to the screen. Later 128k Spectrum model had AY-sound chip but initially there was just a speaker with on/off control (like the original PC).
Oops .. i guess that's what i get by assuming the original ZX Spectrum even had a PSG ( and therefore Google'ing "ZX Spectrum PSG" ) :oops:

By the way, have you tried rendering to a 256×192 RenderTarget? Because of the complexity of the fragment-shader i suspect it might improve performance ( a bit ).

K

Re: ZX Spectrum emulator

Posted: Tue Apr 16, 2019 1:14 am
by Lupo
Simply amazing!!