I finally emulated my childhood

Sir Clive

Last night I decided to dedicate some time to my old z80 emulator. I've squashed a few bugs and ported it to .NET 10. Then I added a ULA emulator.

The ULA is a custom chip on a ZX Spectrum that handles IO, in practice, as an emulated chip it reads memory and ports and writes to audio buffers, screen buffers, and reads the keyboard connectors. Initially I thought it'd be a lot of work, but it turns out that if you know how screen decoding works, which I still remember from the 80s, because some trauma is hard to erase, the code is almost trivial.

Finally I got Claude to wire this emulated hardware up in a thin shell with MonoGame (100 lines of code or so), and I got a personal Spectrum emulated from the ground up.

I know this means nothing to most people. But let me tell you what it means to me.

The magic box

I grew up with this thing. It's where I learnt how to write code. When I was a kid, the ZX Spectrum was an expensive, "magic" box that I needed to "crack" to make my ideas come true. Today, emulating it from scratch feels like I finally completed that particular loop.

The Spectrum was not, by any objective measure, a powerful machine: 48 kilobytes of RAM, a Z80 running at 3.5MHz, and a rubber keyboard. You loaded software from cassette tape, a process that took several minutes and frequently failed (especially on copied tapes, ahem). Yet, the software that ran on it was, in several cases, extraordinary.

Here are some of the games that defined that era for me. All the screenshots are generated from the emulator I wrote, let's go!

Manic Miner

Written entirely by Matthew Smith in 1983, Manic Miner was one person, 48KB, and twenty screens of platform gameplay with tight collision detection and smooth-enough scrolling on a machine that had no hardware scroll support whatsoever.

There was no tutorial. You fell into a cavern, figured out you could move and jump, and started dying. The learning was the game. It was an interesting design philosophy, conscious or not: trust the player to figure it out.

Chuckie Egg

A&F Software's Chuckie Egg is a game about collecting eggs while avoiding hens and a giant bird, and it is one of the most mechanically precise platform games ever made on any platform.

What makes it remarkable is the edge cases: the way you can climb a ladder at speed and jump off the top, the way the hens move in patterns that feel random but aren't, and the way the timer adds pressure without ever feeling unfair. Every parameter is tuned. You can feel the iteration behind it.

Chuckie Egg is the game that taught me what "polish" actually means. Not "it looks nice." Polish as in: everything has been thought about. The interface is its own specification, and the spec is correct.

Atic Atac

Ultimate Play the Game was the best software house on the Spectrum. Full stop. Rare, their later incarnation, would go on to be the best studio on the N64. But before all of that, there was a small team in Ashby-de-la-Zouch making games that looked nothing like anything else on the machine.

Atic Atac (1983) was a top-down adventure set in a haunted house where you chose one of three characters, wandered hundreds of rooms, and collected parts of a key to escape. The rooms scrolled with enemies moving at the same time, on a Spectrum. That this worked at all is an engineering achievement; that it was also atmospheric is something else entirely.

Design is not about fidelity. It's about intentionality. These people had almost nothing, and they made something genuinely creepy out of coloured squares.

Sabre Wulf

Sabre Wulf (1984) is where Ultimate reached peak Ultimate: a huge scrolling jungle maze with orchids that slowed you down if you stepped on them and a wolf that stalked you through the undergrowth and that you could only temporarily repel.

The scope of this game, for 1984, on 48KB, is almost offensive. I have shipped software on machines with gigabytes of RAM and dozens of cores that demonstrated less design ambition. Four amulet pieces, scattered across the jungle, were needed to complete the game, with no map and no clues, just exploration and the mental model you built as you played.

That mental model was the game. Worth thinking about.

The Hobbit

The Hobbit (1982, Melbourne House) is in a different category from the rest. It was a text adventure with graphics, a parser game where you typed commands in English and navigated through a surprisingly faithful adaptation of Tolkien's story.

What made it remarkable was Inglish, the natural language parser written by Veronika Megler and Philip Mitchell. For 1982, it was shockingly capable: you could write "ask Gandalf about the ring" and get a coherent response, characters had their own routines and moved around independently, and Gandalf might not be where you expected him.

This was, in a real sense, an early prototype of an intelligent interactive agent. The NPCs had state, had goals, and could be communicated with in something approaching natural language. We've come an impossibly long way since. But the lineage is visible, and the ambition, to build something that felt like talking to an entity rather than operating a machine, on 48KB, in 1982, is worth sitting with.

What it means to emulate all of this

Now I can run these on hardware I built myself, in software, from first principles!

Writing a Z80 emulator requires you to implement every opcode, get the timings right, and handle the undocumented instructions that real software accidentally relied on. Writing the ULA on top of that requires you to understand how the screen memory is laid out, a deliberately weird format that packed attributes separately from pixel data to save RAM, and reconstruct it correctly, pixel by pixel, frame by frame.

None of it is conceptually difficult, once you know it, but it is precise: every detail matters because real software from 1983 will happily expose every flaw in your implementation within seconds.

Getting it right, and then loading a ROM and watching the Spectrum boot screen appear, and then loading a game I played as a child, that's a particular kind of satisfaction that I don't have a better word for than "completion."

I built this machine in my head when I was eleven years old. I spent years learning its idiosyncrasies, its layout, and its constraints. I learnt to code on it, basic, then hand assembled machine code. I moved on to other things, better machines, higher-level languages, entire careers and now, a few decades later, I've built it again, from scratch in software, and it works.

That's enough for today.

The z80 and ULA emulator is on GitHub, BSD 3 clause license. If you're into this sort of thing, take a look. There's also a tiny ZX Spectrum emulator as a sample.


I am the Chief R&D at BaxEnergy, developer, hacker, blogger, conference lecturer. Bio: ex Stack Overflow core, ex Toptal core.

Read more

Newest Posts

I finally emulated my childhood

Last night I decided to dedicate some time to my old [z80 emulator](https://sklivvz.com/posts/z80). I've squashed a few bugs and ported it to .NET 10. Then I added a ULA emulator.

Read more
MoonBuggy: zero-allocation i18n for .NET

Compile-time translations via source generators, ICU MessageFormat + CLDR plurals, PO file workflows, no per-request allocations.

Read more
TDD and the Zero-Defects Myth

TDD can’t guarantee zero-defects. Let us debunk this software development myth.

Read more
What can Stack Overflow learn from ChatGPT?

Stack Overflow could benefit from adopting a using conversational AI to provide specific answers

Read more
Fan mail

Multiple people with my name use my email address and I can read their email, chaos ensues!

Read more

Gleanings

You Are Not Google
Ozan Onay • Jun 07, 2017

Software engineers go crazy for the most ridiculous things. We like to think that we’re hyper-rational, but when we have to choose a technology, we end up in a kind of frenzy 

Read more…