<< Part 1: My First Driver Table of Contents Part 3: Hunting for Color PROMs >>

Part 2: What's a Schematic?

My second major driver contribution was Dig Dug. Personally, I was never really that fond of Dig Dug... so why did I do it? Well, at the time, MacMAME was not kept strictly in sync with the DOS version of MAME. In part, this was a practical decision: the DOS version was updated so frequently that it was often a version or two ahead by the time the Mac version was released. This was always disappointing to us Mac users, so we would take our "revenge" by adding our drivers to MacMAME before they were added to the main MAME tree.

As a result of this, I sent Brad Oliver, the maintainer of MacMAME, a copy of my Mappy driver at the same time I submitted it to Mirko. I can't remember if Mac users got to play Mappy first or not, but Brad and I got to talking, and he revealed that Dig Dug had always been one of his favorite games. I took that as excuse enough to look into it, especially since it was made by Namco at around the same time as Galaga, which was, of course, already supported in MAME.

Dig Dug had a rather different architecture than Mappy: it was based around the Z80 microprocessor — 3 of them in fact. This made it much more similar to Galaga than to anything else. One of the nice things about switching over to a Z80-based game was that I was somewhat familiar with the architecture: my first assembly language experience was writing Intel 8080 assembly on my old Heathkit H-89 computer when I was in elementary(!) school. Of course, the Z80 was a pretty heavily "souped-up" version of the 8080, but it wasn't a very steep learning curve.

(Trivia note: the 16-bit Intel 8086 borrowed heavily from the 8-bit 8080 in a number of ways. One of these ways was the ordering of the flag bits in the flags register. Of course, the 8086 eventually became the 80286, the 80386, the 80486, and now the Pentium class of microprocessor. And if you look closely, you can see that the carry, parity, sign, zero, and half-carry flags still to this day map perfectly back to the Z80 and 8080. Which makes it kind of nice to write a Z80 emulator in x86 assembly language.)

One of the nice things I soon discovered about working on Dig Dug was that there was an official memory map available. I was surprised: I had assumed that most companies wouldn't want to reveal that level of detail about the systems their games ran on. Also, I had never heard of any official memory map for Mappy, so where did it come from? Well, it turns out that Namco had licensed Dig Dug to Atari for distribution in the United States, and Atari — as I later discovered — was amazingly thorough in their documentation for earlier (pre-1987 or so) games. This discovery would later influence my decision to work on the Atari raster games.

So with the memory map in hand, I took the Galaga driver, ripped it apart, and started putting Dig Dug in its place. The I/O chip once again proved to be a big pain, but that problem was soon overcome. The tricky part here turned out to be the video system.

Since I was basing the code on Galaga, the video system was set up to handle a simple sprite-plus-background video system. This was a common architecture for video games, dating back before Pac-Man. The background consisted of a number of tiles (usually 8 pixels by 8 pixels in the early days), layed out in a grid. The main CPU could specify a few parameters for each tile: which one of the available pixel patterns to draw in that tile, which color, and whether or not to flip the pixels horizontally and/or vertically. The sprites were generally overlayed on top of the background, not constrained to the grid. They had a larger set of parameters, including the X and Y screen positions of the sprite. So, for example, in Pac-Man the maze and the dots are all part of the background. Pac-Man and the ghosts are all sprites.

Dig Dug had a similar architecture, except for the fact that there was no background. When you played the game, you would see the digger and the enemies on a white background, and you would dig black tunnels through the whiteness, but the nicely colored dirt background was completely missing. This turned out to be the first time I needed to resort to schematics to figure out what was going on. The problem was, I had never read a schematic in my life!

Reading the Dig Dug schematic, I was bewildered for quite some time. There were lots of lines connecting lots of components that I knew nothing about. But I was able to understand a few things: there was a section called "Playfield Generator", and in that section were the ROMs I was currently using for the background, along with a couple of extra ROMs that I didn't know what to do with. Then it clicked: they must somehow be related to the missing background!

With that newfound insight, I set to work and realized that the dirt background was a "fixed" background that was drawn behind the background I was already drawing. The data for which pixel patterns and colors to draw for the fixed background came from the extra ROMs, and it turned out there were 4 different dirt backgrounds stored in them. From there, it was a simple matter to figure out how the game program selected from between the 4 fixed backgrounds, and finally I had it: arcade perfect Dig Dug!


<< Part 1: My First Driver Table of Contents Part 3: Hunting for Color PROMs >>