ZX Speculator: A Cross-Platform ZX Spectrum Emulator

Overview

ZX Speculator is a robust, cross-platform ZX Spectrum 48K emulator developed in C#. It’s built using Avalonia for compatibility across various operating systems. The emulator supports a variety of file formats, including .z80, .bin, .scr, .tap, and .sna, and can even load files directly from .zip archives.

Key Features

  • Cross-Platform Compatibility: Ensured by Avalonia.
  • File and Archive Support: Handles multiple ZX Spectrum file formats and .zip archives.
  • Display Options: Includes CRT TV and Ambient Blur effects.
  • Joystick Emulation: Supports Kempston and Cursor joysticks.
  • Sound Emulation: Utilizes OpenAL on Mac and Windows.
  • Integrated Debugger: Features instruction stepping, breakpoints, and instruction history.
  • Rollback Functionality: Allows users to revert to an earlier state using continuous recording.
  • Theming: Customizable Sinclair BASIC ROM with various color schemes and fonts, including ZX Spectrum, BBC Micro, and Commodore 64.

Download and Setup

Users can download the emulator from the releases section. Mac users may need to unblock the application using a specific command. For developers, the source code is available, and the project can be built using a .NET compatible IDE like JetBrains Rider or Visual Studio 2022.

Development and Testing

Developed primarily on a Mac, ZX Speculator is also tested on Windows, ensuring broad compatibility. It successfully passes all ZEXDOC tests and FUSE emulator tests.

Experiments and Contributions

The emulator also includes various experimental projects such as a ray-tracer (No mean feat on a Spectrum!), Conway’s Game of Life, and other graphical effects.

Community and Resources

For more updates, users can follow me on Twitter. Additionally, the README provides useful resources for those interested in ZX Spectrum and Z80 programming.

Personal Journey and Project Inspiration

I’ve been a software developer for most of my life, but it all began with the humble ZX Spectrum 48K. BASIC was a fantastic starting point for coding, especially in those days when you could learn by typing out listings from books and magazines, essentially getting games for (almost) free.

In tribute to those early days, and driven by my interest in emulation, I embarked on creating my own emulator. Thus, the ZX Speculator project was born. My goal was to develop a fully functional 48K emulator that incorporated a few features rarely seen in other emulators—such as the ability to rewind time, a robust debugger, and CRT-like screen effects.

Conclusion

ZX Speculator is a comprehensive and versatile emulator for ZX Spectrum enthusiasts, offering a range of features and customization options. Whether for gaming nostalgia or development purposes, it serves as a powerful tool for exploring the ZX Spectrum ecosystem.

The C# code is freely available.

For more detailed information, visit the ZX Speculator GitHub Repository.

Star Wars: X-Wing from The Force Awakens

GLSL Shadertoy Shader

When I first watched The Force Awakens I saw the scene where a group of X-Wings flew down a river, kicking up water spray behind them. And now I’ve created a GLSL shader inspired by it!

Trying to get the correct scale modelling the X-Wing was initially quite tricky, but then I found the Lego X-Wing build instructions – MUCH better than any schematic! Counting the Lego ‘studs’ gives a very easy to follow guide on the size of each dimension!
I’m definitely going to be using this trick again in the future…

The water surface is simply a flat plane with some ‘bump’ added to the material (Just displacing the X/Z components of the normal). This in itself is quite effective, but adding the reflection of the sky (including atmosphere and clouds) really adds a level of realism.

Note: It would be just as easy to displace the water surface in the SDF function, but that would take longer for the marched ray to converge on the surface, incurring a slight FPS hit.

The mountains in the distance are modelled as a infinite cylinder with a FBM displacement applied to it. I usually model these things as a flat plane with a displacement, but that introduces many rendering artefacts that require shortening the ray marching step size to remove. Modelling as a cylinder reduces these artefacts, and helps keep the performance as high as possible.

…And of course, I couldn’t miss out BB-8!

The scene uses depth of field, fish eye lens, and chromatic aberration to add some subtle finishing details.

The GLSL shader source can be found here and here.

But Can It Run Crysis?

GLSL Shadertoy Shader

For years now I’ve loved the Crysis games, and so I’ve finally created a small tribute.

The recently release ‘Remastered’ version introduced ray tracing, which really added some impressive detail, especially in reflections. My GLSL version also implements reflections, and is completely procedural – Both the texture and models are generated using math.

These scene uses depth of field, fish eye lens, and chromatic aberration to add some subtle finishing details.

The GLSL shader source can be found here and here.

Revised Reality (Revision 2022 4Kb Graphics Demo)

I’ve been watching graphics demos for many years now, and never thought that one day I’d actually make one myself. But this year I finally plucked up enough courage to create an entry for the awesome Revision 2022 competition.

I figured the best category for me would be ‘4Kb Executable Graphics’. The challenge is to write a single executable in less than 4096 bytes (which is tiny!) which produces a single static image.

To put this into perspective, if you were to take a screenshot of the image it would come in at over 6,000,000 bytes. So the code that creates the image must be over 1,500 times smaller than the image itself!

As frame rate is not a problem here I had to use different techniques to make this image – I actually only get 2 FPS on my machine!
Instead of performance I had to keep in mind code compressibility. That means firstly writing a small amount of code (obviously), and secondly reusing terms so the data compressor can do a better job of compressing.

I came in 8th place, which I’m extremely happy with. It was awesome to compete with such great coders!

The GLSL shader source can be found here.

Demozoo link
Pouët link

GLSL Shader Shrinker

I have been writing a tool over the last few months which will take GLSL shader code and optimize it in a variety of ways.

It can apply a range of changes from simply code reformatting, optimizing maths and function calls, all the way to GOLFing code.

‘Code golf’ is where you make attempts to make the source code as small as possible. Making a tool do this automatically (without breaking the code!) is quite a challenge, but the latest incarnation of my app has got the ‘The Small Step‘ shader code down to a little over 2Kb.

GLSL Shader Shrinker – Feel free to check it out – It’s free!
https://github.com/deanthecoder/GLSLShaderShrinker

Aliens (Scanner scene)

GLSL Shadertoy Shader

Another Aliens-themed shader, motivated by me watching this clip from the movie.

I try to add add something new each time I make a shader, and this time it was the ‘frost’ effect on the cryo pod and the noise in the ‘laser’.

The reflective helmet glass and laser effect were calculated using ray-sphere ray-plane intersections, allowing me to keep the ray-marching loop simple and fast.

The GLSL shader source can be found here.

The Exorcist (1973)

GLSL Shadertoy Shader

This is my first black and white shader, and also the first time I’ve mixed 2D and 3D content.

As ever, in an attempt to keep the code small and frame rate fast I make heavy use of domain repetition. For example, there’s actually only one window pane, and that makes all the windows on both walls!

The man is defined using 2D functions, and has a subtle animation to add some realism.

The GLSL shader source can be found here.

Happy New Year!

Innerspace (1989)

GLSL Shadertoy Shader

I challenge anyone to not like the Innerspace movie!

There’s a lot of new (to me) lighting effects in this shader. The headlights of the ‘pod’ are light cones with analytically solved ray start/end points, used to calculate the amount of ‘glow’ to apply.

I also make heavy use of domain repetition (where you use math to ‘duplicate’ regions of space) to make a whole stream of blood cells using only three modelled originals.

This is one of my longer shaders, running in at just under a minute.

The GLSL shader source can be found here.

The Alien

GLSL Shadertoy Shader

Another shader based on Alien, this one was an exercise in modelling and animation.

I started off with the dome of the head and the texture on it. It’s actually a simple gyroid pattern with a few colors mixed into it, but quite effective!

My awesome cousin (Check out his art here) gave me some tips for the animation – I added some ‘anticipation’ before the alien strikes. This means the head pulls back before striking forward, showing a build up of ‘energy’ and really improving the effect.

The GLSL shader source can be found here.