Yorgle Notebook - Pac Analysis
0. Table Of Contents
enable javascript to see the table of contents
1. Overview

There are various Pac-man romsets out there right now, and at quick glance, it is difficult to tell which one was made first, which are hacks, and so on. In this article, I hope to figure out the order in which they were released. I'll use disassemblies, and other means to attempt to figure out which ones were released in which order.

I'll be exploring a few romsets. The names used for the romsets are the common names used in MAME 0.128, and probably back through many previous versions. If there's any question about previous versions, I'll leave it as an exercise for the reader to cross-reference the romset checksums from this version to other versions.

2. Which Are Originals?

So, how can we figure out which sets are authentic originals, which are bootlegs, which are hacks. Turns out that it's fairly easy to do so.

To start with, authentic original boards have additional hardware for handling the timer interrupt, which gets fired with every screen refresh, 60 times a second. All of these use "Interrupt mode 2". Most, if not all bootlegs use a different interrupt mode, "Interrupt mode 1" which does not require any external hardware to operate, making it a little easier to make the hardware. If the romsets are disassembled, and the opcodes "im 2" and "im 1" are searched for, you can find out this first, crude level of which ones were the original.

IM2 games require the hardware, IM1 games will run on any hardware... that is to say that IM1 hacked bootleg romsets will run on authentic hardware, however IM2 authentic romsets will likely not work on bootleg hardware.

3. Patches in the code

Another way that we can tell that IM 2 is the original is that if you look at the asm for comperable romsets, you will see that the IM 1 version is patched to support the different interrupt mode. I will illustrate that here:

    ; puckmana.asm (Namco)
    ;add bytes     opcode
    233b ed5e      im      2
    233d 3efa      ld      a,0fah
    233f d300      out     (00h),a
	; 0f3c - 0ffd - unused
	; beginning of the IRQ handler...
    0038 af        xor     a
    0039 320050    ld      (5000h),a
	...

    ; pacman.asm (Midway)
    ;add bytes     opcode
    233b ed5e      im      2
    233d 3efa      ld      a,0fah
    233f d300      out     (00h),a
	; 0f3c - 0ffd - unused

And now the im 1 version...

    ; puckman
    233b ed56      im      1
    233d 3efa      ld      a,0fah
    233f 00        nop			; nops instead of code above
    2340 00        nop			; nops instead of code above

	; interrupt handler at 0x0038 is a jump to 0f3c
    0038 c33c0f    jp      0f3ch	; patch jump to new code
    003b 50        ld      d,b		; garbage opcode, leftover 
	...

	; additional patch which gets called instead of 0038-0058 - now unused
    0f3c f5        push    af
    0f3d ed57      ld      a,i
    0f3f b7        or      a
    0f40 2804      jr      z,0f46h
    0f42 f1        pop     af
    0f43 c38d00    jp      008dh
    0f46 f1        pop     af
    0f47 c30030    jp      3000h

One easy way to tell that there's been a patch that's been applied is that you will either see vestigial opcode garbage (the '50' at 003b above) or nops (233f, 2340), both of which you can see in the im 1 version. all IM 1 pacs have this in them. Nops espeically stick out like a sore thumb. You may see them in the IM 2 pacs, but they will either be the unused chunk of space, or in data tables. The disassembling tools do not know what are opcodes and what are data in the romsets, so they will just assume everything is opcodes.

4. Putting it together...

Following this, the authentic romsets are "puckmana", "pacman" and "mspacman". The capsulized history of the Pac-Man/Ms. Pac-Man line will tell us that Namco created Pac-Man in Japan, then licensed it to Midway who released it in the USA, after changing some ghost names, and the copyright screen of the game. After that, Crazy Otto enters into the picture through a series of details outside of the scope of this article... resulting in "Ms Pac-Man" being released by Midway after that.


Figure 1: Pac game family tree

In the above diagram, you can see Namco's "puckmana" in the top left, which got massaged into Midway's "pacman", and then modified into "mspacman" which shares the same four base ROMs as "pacman", hence its blue color, indicating that it is a hack. (green = original, blue = hack, pink = bootleg)

So, what about the other versions?

It doesn't take much sleuthing from here to determine the other family branches. Obviously, the IM 1 pacs are used as the basis for other 3rd party bootlegs and derivative games. Piranha is based on puckman, as is newpucx, and hangly. Piranha is interesting in that it makes the game so much more horrible by eliminating much of the maze, which is essential for making the game fun and playable. Hangly is quite interesting in that it changes the gameplay quite a bit. It adds vertical tunnels, as well as a maze that changes somewhat. Not quite to the extreme as Ms. Pac-Man, which adds multiple maps though. It is closer in style to "Pac Plus" which hides the map on you and makes tthe gameplay more challenging.

The "pacmanf" and "mspacmanf" mods are simply a replacement of the one chip (and only a byte or two on those chips) which controls Pac Man's speed in the maze. The "pacmanh" hard modification replaces a data table that determines the speed of the ghosts in various levels, as well as some other timing values.

5. Concluding thoughts

I went through this exercise because I wanted to figure out which romset was a good starting point for a pretty major Pac-Man game hack. I wanted one that didn't have extra patches which were unnecessary for my use, that I'd have to just reverse anyway. For example; Midway's Pac-Man ignores much of the names table, and adds a second one, using some ROM space. I also knew that I wanted an Interrupt Mode 1 based romset, since I want the greatest portability for making the game work on real hardware.


Figure 2: Pac Romsets by ROM name
6. External Reference