Conway’s Game of Life On a Z80

Ever since I was young, , I’ve wanted to build a computer from scratch.  From chips, I mean.  Something about it seemed so magical, to make a computer out of discrete components and make it work.  Some time ago, I found a website chock-full of information on how to do just that.  Grant Searle’s web page is a treasure trove for those interested in building retrocomputers.

Back when I was a teenager, I bought a Radio Shack TRS-80 Model III.  It came with 4K of RAM and I upgraded to 16K.  I had to mow a lot of lawns to pay for the computer and the upgrade.  I stored and retrieved programs on a cassette recorder, as I didn’t have any floppy drives.  But I got my first taste of programming on that computer, and hence a lifelong interest (and eventually a career) was born.  So it was natural that I connected with Mr. Searle’s construction of a Z80 computer from scratch.

I made several changes and additions to the Searle design:

  1. I used a socketed oscillator for the Z80 so that I could switch them out and experiment with different clocking (and overclocking) values.
  2. I used a separate 1.8432 MHz oscillator to drive the 68B50 ACIA chip.  I found this much more reliable in testing.
  3. I replaced the fixed A15-A14-A13 memory encoding (resulting in a fixed 8K ROM space and 56K RAM space) with a more flexible memory encoding using a combination of AND and OR chips and movable jumpers.  Combined with a 32K ROM, this allows me to select any amount of ROM, from 32K down to 512 bytes of ROM.
  4. I added a zero-insertion-force (ZIF) socket for the ROM so it would be easy and quick to replace the chip as I programmed new versions of software.
  5. I removed the MAX232 chip and all related circuitry, instead communicating with PC over a USB-serial conversion board based on the FTDI chip.
  6. All Z80 active-low inputs are pulled high with 1K resistors.

Here is a photo of the completed computer:

_DSC8811

I  assembled and loaded Searle’s custom version of BASIC in ROM.  After experimenting a bit with a few BASIC programs, I entered the BASIC code for a version of Conway’s Game of Life from “Basic Computer Games,” from Creative Computing (c) 1978.  Link to the book’s page on Amazon.com.  This game was a favorite of mine when I was a kid and I entered it and ran it.  Fun!

Then I thought I might like to try my own implementation of the game.  So I decided to teach myself some Z80 assembly language.  Using the assembler and related tools at z88dk, I took some of Grant Searle’s RS232 serial communications code and my own idea for the implementation of the Game of Life and started coding.

It didn’t take long.  Like the Game of Life itself, the program is not complicated — the code only takes about 1K of RAM — but it is cool to watch run.  It’s available on my gitlab site in both source and binary form.  The binary form is ideal for someone who’s built a Searle-inspired Z80 computer and just wants to burn a ROM with it on it.

This was a great way to learn some basic Z80 assembly language and gave me a keen appreciation for the limitations of that processor’s old-school CISC instruction set.  It’s not in any way orthogonal and it’s quite inefficient compared to modern orthogonal RISC instruction sets.  This is just another area where computers have come a long way since the 1970s.

life01

This image is from an evolution of the starting pattern hard-coded in my game.  It starts off very simply but things really start to happen after about one hundred generations, and by the time three hundred have passed, some very interesting patterns emerge, blossom, and die off.  This game lasts 1090 generations before devolving into static or simple oscillating patterns.

This was a fun hobby project, and I highly recommend Grant Searle’s basic design.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s