← Back to Courses
module
1

What you're going to build

Why write a game in assembly?

Because on a machine this small, you can understand the whole thing.

A modern computer is built in layers, and almost all of them are hidden from you. Somewhere underneath the app you are using there is a processor doing one small thing at a time, but you will never see it, and nothing you do on a modern machine will show it to you.

An Einstein will. There are no layers here to speak of. You write an instruction, the processor carries it out, and something happens on screen. When your game runs slowly, the reason is a number you can count. When it breaks, the cause is somewhere inside a machine small enough to hold in your head. Everything on screen is there because you put it there, one byte at a time - and by the end of this course you will know exactly how each one got there.

You will also see where a lot of modern computing came from. Characters, memory addresses, interrupts, the loop that redraws the screen sixty times a second: these ideas are all here, in their simplest form, close enough to touch.

And it is satisfying. Moving something around the screen with code you wrote yourself, on a machine you understand completely, is a different feeling from watching something move because you called a function that somebody else wrote.

The machine

The Tatung Einstein is a British computer built around the Zilog Z80 processor - the same chip as the ZX Spectrum and the Amstrad CPC, though the machine around it is quite different. The ROM it boots from is dated 1983 and 1984.

It was aimed at small businesses and schools rather than the games market, and it never sold in the numbers the Spectrum did. That is part of the appeal. It is a capable little machine that comparatively few people have written games for, which means there is room to do something new on it.

You do not need to own one. Everything in this course runs on an emulator on your own computer, and the next section gets that working.

Where this is going

The goal is a complete game, written entirely in Z80 assembly, running on the Einstein. By the end you will be able to:

  • Write programs in Z80 assembly language.
  • Put characters and graphics on the screen, and move them around.
  • Read the keyboard and respond to what the player does.
  • Build game logic - collisions, scoring, the rules that make it a game.
  • Assemble, package and run your own programs on an emulated Einstein, or on a real one.

You will not start there. You start by getting a single word onto the screen, because before anything else you need to know that your code assembles, loads and runs. From there the course builds up in steps, each one adding a piece you will still be using at the end:

  • Getting your program onto the machine, and seeing that it ran.
  • Talking to the video hardware, and putting your own graphics on screen.
  • Moving things around, smoothly and without flicker.
  • Reading the keyboard, so the player can do something.
  • Putting those together into a game loop that runs frame after frame.
  • Everything a game needs beyond the basics - collision, score, sound, state.

Each section leaves you with a program that runs. Nothing is left as an exercise for later, and you are never asked to type in code that will only make sense in three sections' time.

Who this is for

  • Retro computing hobbyists and collectors.
  • Anyone who wants to understand how a computer actually works, at the level where there is nothing left to hide behind.
  • Game developers curious about where real-time programming came from.
  • Educators after project-based material with something to show at the end of every session.
  • Anyone who enjoys making things work from the ground up.

What you need to know already

Nothing.

You do not need to have programmed before, in assembly or in anything else. Registers, addresses, flags and the general business of a processor with nowhere to hide are all explained in plain English as they come up, in the order you need them, and nothing is assumed that has not been covered.

If you have programmed before, you will move faster, and you should expect assembly to feel strange rather than difficult. There are no variables, no functions in the sense you are used to, and no types. There is a small set of places to put numbers and a small set of things you can do to them, and everything else is built out of that.

If you have written assembly for another eight-bit machine, you will move faster still. Be ready for some of your habits to need adjusting: every one of these machines handles graphics and input its own way, and the Einstein is not the machine you learned on.

What you need

Four things, all free:

  • A code editor. The course uses Visual Studio Code.
  • The Tatung Einstein development extension for it. This assembles your source and runs it on an emulated Einstein at the press of a button, which keeps the loop between writing a line and seeing its effect down to a couple of seconds.
  • An assembler and an emulator. The extension drives both for you.
  • The Einstein ROM image, which the emulator needs in order to behave like an Einstein at all.

The next section installs all of it and finishes with an Einstein booting on your own machine. Nothing in this course asks you to buy anything.

How each section is laid out

From here, every section follows the same shape.

Part What it is for
Why this matters The problem your game runs into without this.
The explanation What the machine does, how to make it do it, and what it costs you - in cycles, in bytes, or in a register you no longer have free.
The code A complete program you can assemble and run. Short, and with nothing in it left unexplained.
Change one thing Two or three small edits to make yourself, each with a question attached.
When it goes wrong The mistakes that are easy to make here, and what they look like on screen.
Summary What you can now do.

Type the programs in and run them. Then do Change one thing, which is where most of the learning actually happens. Reading a listing that works gives you the feeling of understanding it, and that feeling is hard to tell apart from the real thing until something breaks. Changing one value, guessing what will happen and then finding out is quick, and it tells you honestly whether you have got it.

Summary

  • This course teaches Z80 assembly on the Tatung Einstein, building up to a complete game.
  • No prior programming experience is needed. Everything is explained as it comes up.
  • You need an editor, an extension, an assembler, an emulator and a ROM image. All free, all set up in the next section.
  • Every section ends with a program that runs, and small changes for you to make to it.

Next

S2. Setting up. Installing the assembler, the emulator, the editor and the extension that joins them together, and booting an Einstein for the first time.

Get the Newsletter

New guides, disk images and community finds, roughly once a quarter. No spam, we promise, this isn't Tatung's marketing department.
Your subscription could not be saved. Please try again.
Your subscription has been successful.

Newsletter

Subscribe to our newsletter and stay updated.