ZX Speculator is a cross-platform ZX Spectrum 48K emulator written in C#.
.zip
archives.F1
will roll back 5 seconds.)
xattr -d com.apple.quarantine /Applications/ZX\ Speculator.app
Developed on a Mac environment, ZX Speculator is also tested on Windows and passes all the ZEXDOC tests and FUSE emulator tests.
Common ZX Spectrum image files (.z80, .sna, etc) can be opened from the File->Open menu.
Load ""
in BASIC.Move the mouse pointer to the small keyboard icon at the top-right of the screen to see a representation of the ZX Spectrum keyboard. Many keys on a modern keyboard are automatically mapped to their ZX Spectrum equivalent. For example, backspace, quotes, math symbols etc.
The left shift key maps to CAPS SHIFT on the Spectrum, and the right shift key maps to SYMBOL SHIFT.
ESCape will reset the machine.
The emulator will mimic either a Kempston or Cursor joystick.
In both cases the keyboard arrow keys are used for direction control, and the backslash or backtick keys will 'fire'.
The project is provided as C# source code:
Speculator.sln
) in your preferred IDE.There's a YouTube playlist showing some classic games played in the emulator.
As my other hobby is writing GLSL shaders on ShaderToy (See here for my GLSL Shader Shrinker application), I thought it'd be interesting to try a 'cross over' project.
I've taken inspiration from the Human Shader project and recreated the algorithm using ZX Spectrum BASIC, using this emulator.
Here's the result:
Earlier version, with a basic dither:
First iteration: Solid blocks:
I've included a .sna
snapshot of the code here.
I realized I had never written a Conway's Game Of Life, so decided to make one using the emulator.
Performance in this BASIC version isn't great... (See here - Requires the JGH ROM)
...so I rewrote it in C, compiled into Z80 machine code (here). Muuuch faster!
C compiled into Z80 machine code (here). Too slow to call 'real time', but not bad for the Speccy.
C compiled into Z80 machine code (here). This one runs in real time, which surprised me.
I first populate the entire screen with characters (black on black), then build up a 768 element array of color values with a repeated sequence ranging from green to bright green, white to bright white.
This array is then used to set the colors on the screen, and a memmove
command is used to scroll the buffer by one byte. This keeps the framerate up as it's only the color attributes that change - Not the characters on the screen.
C compiled into Z80 machine code (here).
The screen is filled with forward and backslashes (Drawn with a small gap in my case), then I randomly fill areas of the screen. Quite relaxing to watch!
C compiled into Z80 machine code (here).
Iterating over a fixed number of grains, advancing each depending on what is below them. I did try a different approach of iterating through all cells in an x/y grid which worked well, but wasn't anywhere near as performant.
I'm making use of the z88dk's 'chunky' pixel blitting routines too.
Pushing my graphical skills on the ZX Spectrum, resulting in the creation of a classic 'twister' effect. The code is written in C and compiled into Z80 machine code (here) - Needed to keep the performance up.
The twister effect, a staple of early computer graphics and demoscene productions, seemed like the perfect challenge - I've always wanted to make one of these but never got round to it. Helped with details from 8bitshack. It takes a while to complete the precaching, but I like the result.
Two balls fighting for dominance! I saw an effect similar to this on Twitter and thought it was a great idea. A little more of a 'demo-style' with this one - I've added a DTC logo (which I'll developed more in the future).
The code is written in C and compiled into Z80 machine code (here).
This is based on a GLSL shader I wrote a while ago. I built a library of GLSL-like functions in C to recreate the original code, then ran it over many hours.
The final quality was achieved with a Floyd-Steinberg dithering algorithm. A random dither is much easier to implement, but the result was way too noisy.
The executable is here.
ZX Speculator is an ongoing project and contributions are welcome. Whether it's improving emulation accuracy, testing on different platforms, or enhancing existing features, your input is valuable (although I can't always promise a fast response, as this is a side project).
Flux Capacitor icon licensed by CC BY 4.0.
Feel free to follow me on Twitter for more updates: @deanthecoder