I remember writing my very first computer game in in 1996 at the age of 12, on a computer with an 8-bit, 10 MHz 8085 processor, that my father built a long time ago. Since it’s a custom and unique machine and operating system, the programs run nowhere else.
There was no assembler or compiler, so I had to write the game in machine code, which wasn’t actually too hard, because the 8-bit processor only has a very limited command set and even fewer were required to write simple text adventures.
Learning the absolute basics of computer programming helped me a lot to get a grip of efficient resource management and functionality of computers and programming languages.
Sometimes I pity programmers, who have never ever seen a register in the wild…
My first game
CD AF 15 11 00 70 21 00 60 CD 4A 08 CD 00 08 FE 31 CA 80 50 FE 32 CA 00 52 C3 00 50
The first game I can remember of is called “Lambada“, a simple text adventure that tells you a story and gives you choices of action to leave the current screen and proceed to the next one. The whole game consists of only 520 bytes of machine code, that I wrote in a hex editor, and about 3kb of text for the story of the game.
The only commands used, were clearing the screen, printing text on the screen, waiting for the key stroke and then jumping into the repective piece of code for that key.
All routines used are part of the operating system, which was written by my father.
The code explained
CD AF 15
Subroutine call to address 0x15AF, which is the operating system call to clear the screen.
11 00 70 21 00 60 CD 4A 08
Load the 16 bit register DE with the value 0x7000 and register HL with the value 0x6000. Then call subroutine at 0x084A, which copies text from the address stored in HL to the address stored in register DE. The video memory of the computer is mapped to the address 0x7000 – 0x75FF, so the copy operation will result in the text being displayed on the screen. The memory at address 0x6000 contains a text fragment to be shown to the user.
CD 00 08 FE 31 CA 80 50 FE 32 CA 00 52
The call to the subroutine 0x0800 will wait for the next key stroke and put the result byte into the accumulator, register A. That register will be compared with the value 0x31, which is the ascii ‘1’ and upon equity, the program will branch to address 0x5080. If not equal, the register A will be compared with the ascii ‘2’ and on success branch to address 0x5200.
C3 00 50
Unconditional jump to address 0x5000, the beginning of the program.
In 2010 I wrote an emulator for Windows, that emulated the 8085 CPU and some of the special hardware, like the graphics processor and keyboard. That way I was able to run my old games and programs on a 2,4 GHz quadcore with a 64 bit Windows 7. 🙂
The emulator emulates the 8085 CPU but because it also emulates the extra hardware, it can hardly be used for anything else than running my fathers operating system. You then can load binary files directly into the 64kb memory and use the operating system to jump into the piece code or use the editor, that is built into the system (not the emulator).
The state of the emulator and the registers of the CPU can be observed in the CPU status window, as well as control the emulating speed or perform single steps through the machine code.
Unfortunately the emulator yet lacks support for the 1 bit sound generator and the dedicated joystick and hardware interrupt buttons, so some features are still unaccessible.
Lots of games
Games, I’m most proud of, include (all self written in 8085 machine code, reaching up to 32kb):
- Lambada, as my first game ever
- Bomber Man
- Jurassic Park
- Mario World
- Rock’n’Roll Racing
- Zelda 1-3
See screenshots below.
The emulator and programs are available on request only.