How Hard Is It to Build a ZX Spectrum Emulator for SEGA Mega Drive?

The retrocomputing community thrives on challenges that seem almost absurd on paper. One of the most intriguing recent projects is an attempt to run ZX Spectrum software on a SEGA Mega Drive (Genesis) — a 16-bit console never designed for such a task. The question "Is it easy to make such an emulator?" gets a clear answer from the developers: no, it's not easy at all. But the journey itself reveals a lot about hardware limitations, creative coding, and the sheer stubbornness of enthusiasts.

Why Would Anyone Want to Emulate a Spectrum on a Mega Drive?

The ZX Spectrum and SEGA Mega Drive represent two very different eras of computer history. The Spectrum, launched in 1982, was an 8-bit home computer with a Z80A CPU at 3.5 MHz, while the Mega Drive (1988) used a Motorola 68000 at 7.6 MHz with a separate Z80 for sound. The idea of running Spectrum games on a Mega Drive might seem pointless — after all, there are plenty of emulators for modern PCs and smartphones. But for hardware purists, running software on original silicon (or near-original) offers unmatched authenticity and a unique technical puzzle.

The Core Challenge: CPU Incompatibility

The most obvious obstacle is the CPU. The ZX Spectrum uses a Z80 processor, while the Mega Drive's main CPU is a 68000. Emulating one CPU on another is always computationally expensive, but here the gap is especially wide. The Z80 has a very different instruction set, register layout, and interrupt handling compared to the 68000. The developers behind this project had to write a Z80 interpreter in 68000 assembly — no small feat, considering every Z80 instruction must be decoded and executed cycle-accurately to maintain timing.

According to the project report published on Habr, the team initially attempted a simple loop-based interpreter, but quickly hit performance walls. The Mega Drive's 68000 runs at 7.6 MHz, but emulating a 3.5 MHz Z80 instruction-by-instruction can easily consume 50–100 68000 cycles per Z80 instruction. That leaves almost no time for video, audio, or input handling.

Memory Mapping: A Nightmare of Address Spaces

The ZX Spectrum has a straightforward memory map: 16 KB of ROM, 48 KB of RAM (on the classic 48K model), and direct access to video memory at a fixed address. The Mega Drive, on the other hand, has a complex memory layout with separate address spaces for the main CPU, the Z80 co-processor, and the VDP (video display processor). The Spectrum's video memory is accessed by the CPU as part of its normal address space, while the Mega Drive's VDP has its own dedicated VRAM accessed via registers.

This difference means the emulator must translate every memory access from the Spectrum's flat model to the Mega Drive's segmented one. The developers implemented a lookup table that maps Spectrum memory addresses to Mega Drive RAM pages, but this adds another layer of indirection and slows down execution further. They also had to handle the Spectrum's unique attribute-based colour system, which doesn't map neatly to the Mega Drive's planar graphics.

Video Timing: The Most Demanding Part

The ZX Spectrum outputs video in a specific way: the CPU generates the entire frame, including border areas, and the video is interlaced with CPU cycles. The Mega Drive's VDP handles video generation independently, but it expects data in a specific format and at fixed timings. The emulator must not only render Spectrum graphics but also synchronise with the Mega Drive's 60 Hz (or 50 Hz for PAL) refresh rate.

The team discovered that the most efficient approach is to pre-render the Spectrum's screen into a buffer and then transfer it to the Mega Drive's VRAM during the blanking interval. However, the Spectrum's 256×192 resolution doesn't fit neatly into the Mega Drive's 320×224 resolution. They chose to scale the image by 1.25x horizontally and 1.17x vertically, which required bilinear filtering — something the Mega Drive's VDP cannot do in hardware. As a result, all scaling must be done in software on the 68000, consuming even more CPU cycles.

Audio: Another Layer of Complexity

The Spectrum's audio is generated by a simple beeper connected to a single-bit output port. The Mega Drive has a Yamaha YM2612 FM synthesiser and a PSG (programmable sound generator). Emulating the beeper is straightforward conceptually, but timing is critical. The emulator must output audio in sync with the Spectrum's frame rate, and any delay causes crackling or desynchronisation.

The developers implemented a ring buffer for audio samples, feeding the Mega Drive's DAC at the correct rate. However, they faced a problem: the Mega Drive's audio hardware expects data in a specific format and can only handle a limited sample rate. They settled on 14 kHz mono output, which sounds acceptable for Spectrum games but required careful buffer management to avoid clicks.

The Current State of the Project

As of mid-2026, the emulator is still a work-in-progress. The team has successfully booted several classic Spectrum titles, including "Manic Miner" and "Jet Set Willy", but performance is not perfect. On a standard Mega Drive, the emulator achieves about 70–80% of the original Spectrum's speed, meaning games run slightly slower than intended. Overclocking the Mega Drive (by replacing the crystal oscillator) improves this to near-100%, but that's a hardware modification few users will attempt.

Challenge Difficulty (1–10) Impact on Performance
CPU emulation (Z80 on 68000) 9 High — 50–100 cycles per instruction
Memory mapping 7 Medium — adds lookup overhead
Video rendering 10 Very High — software scaling and attribute conversion
Audio emulation 6 Medium — buffer management and sync
Input mapping 3 Low — simple button remapping

Is It Worth It?

For the average user, this project will never be practical. It's far easier to run a ZX Spectrum emulator on a modern PC, a Raspberry Pi, or even a cheap FPGA board. But for developers and hardware enthusiasts, the value lies in the challenge itself. The project demonstrates deep understanding of both systems and pushes the limits of what the Mega Drive can do.

Moreover, the code and techniques developed here have broader applications. The Z80 interpreter could be reused for other 8-bit emulators (e.g., MSX, Amstrad CPC) on the Mega Drive. The video scaling routines might help other homebrew projects that need to display non-standard resolutions. The team has released their source code on GitHub, inviting others to contribute or fork the project.

Lessons for Aspiring Emulator Developers

If you're thinking about building an emulator for an old console, here are practical takeaways from this project:

  • Start with a cycle-accurate CPU emulator. Without correct timing, nothing else works properly. Use existing test suites (like ZEXALL for Z80) to verify your interpreter.
  • Understand the host hardware's limitations. The Mega Drive has very limited RAM (64 KB of main RAM, plus 64 KB of VRAM). Every byte counts. You may need to compress assets or use bank switching.
  • Profile early and often. The developers found that video rendering consumed 60% of CPU time. Optimising that first gave the biggest speed gains.
  • Accept compromises. The emulator will never be perfect. Decide what accuracy level is acceptable (e.g., 95% speed, minor graphical glitches) and ship it.
  • Document everything. The Habr article is a goldmine of technical details. Future emulator authors can learn from both the successes and the dead ends.

Conclusion

Building a ZX Spectrum emulator for the SEGA Mega Drive is far from easy. It requires deep knowledge of two very different architectures, careful optimisation, and a willingness to accept imperfect results. The project described in the Habr article is a testament to the dedication of retrocomputing enthusiasts. While it may never be a polished product, it pushes the boundaries of what was thought possible on a 16-bit console. For those who enjoy the journey more than the destination, this project is a perfect example of why we tinker with old hardware.

Source

← All posts

Comments