ESP32 Rainbow

A ZX Spectrum single-board computer with a built-in keyboard and display

Crowdfunding now!

View Purchasing Options
Dec 02, 2024

Project update 4 of 5

Time Travel: A Fun New Firmware Feature

by Christopher G

The ESP32 Rainbow is powered by the impressive ESP32-S3, a dual-core 240 MHz processor with 512 KB of internal RAM. To make things even better, I’ve chosen to use one of Espressif’s modules which bundles essential support ICs and includes an extra 8 MB of PSRAM.

To put that into perspective, the ZX Spectrum—the machine we’re emulating—had just 48 KB of RAM. The PSRAM in the ESP32 module gives us about 170 times the memory of the original Spectrum! With so much extra capacity, I started wondering: what if we could use it to create something really fun? That’s when the idea for Time Travel was born.

How Time Travel Works

The concept is simple but powerful: every second or so, the firmware takes a snapshot of the emulator’s state and stores it in PSRAM. These snapshots act as save points, allowing you to step back and forth through time in a game. Lose a life? No problem! With Time Travel mode, you can rewind to just before things went wrong and try again.

Activating Time Travel is easy: press the boot button and the ESP32 Rainbow enters Time Travel mode. You can then navigate through the stored snapshots and resume gameplay from any point. It’s a real game-changer, literally!

Memory and Snapshot Storage

Of course, there are practical limits to how much history we can store. For standard 48 K Spectrum games, there’s plenty of space for snapshots. Even for 128 K games, where memory usage is higher, we can theoretically store around 60 snapshots, giving us about 60 seconds of gameplay history (if snapshots are taken once per second).

To make this even more efficient, I’ve implemented a system that checks which memory banks have changed between snapshots and only stores the differences. This approach allows us to extend the number of snapshots, potentially capturing even more history.

For now, I’m planning to strike a balance: about 30 seconds of snapshots seems ideal for most scenarios. This leaves plenty of headroom in the PSRAM for other exciting features I’m working on.

You can see it in action in this video, it works really well!

Project Progress

Thanks for reading,
Chris


Sign up to receive future updates for ESP32 Rainbow.

ESP32 Rainbow is part of PCBWay Assembly Hub

Subscribe to the Crowd Supply newsletter, highlighting the latest creators and projects