Fixing Bugs In A 37 Year Old Apple II Game

Emulators are a great way to reminisce about games and software from yesteryear. [Jorj Bauer] found himself doing just that back in 2002, when they decided to boot up Three Mile Island for the Apple II. It played well enough, but for some reason, crashed instantly if you happened to press the ‘7’ key. This was a problem — the game takes hours to play, and ‘7’ is the key for saving and restoring your progress. In 2002, [Jorj] was content to put up with this. But finally, enough was enough – [Jorj] set out to fix the bug in Three Mile Island once and for all.

The project is written up in three parts — the history of how [Jorj] came to play Three Mile Island and learn about Apple IIs in the first place, the problem with the game, and finally the approach to finding a solution. After first discovering the problem, [Jorj] searched online to see if it was just a bad disk image causing the problem. But every copy they found was the same. There was nothing left for it to be but problem in the binary.

title-screen
The revised title screen, with bugfix noted.

It’s a tale of disassembly and dredging though decades-old scanned literature. The key to the bug was found in a copy of the Micro 6502 Journal from June 1980. If you don’t want the story spoiled, stop here — the problem came about when someone copied an Apple DOS 3.1 version of the game to an Apple DOS 3.3 disk. The disk formats aren’t backwards compatible, so the 3.3 disk version would only play on a DOS 3.3 machine. However, the game’s code uses bytecodes in the save routine that refer to DOS 3.1 functions that had changed in DOS 3.3. It was by searching for this bytecode that the journal popped up on Google with a hint. The article mentions the changes in bytecodes between DOS versions, giving [Jorj] the clue he needed to solve the mystery.

In the end, to get the game to function properly under DOS 3.3, all that was required was to change the code to point to the proper register for DOS 3.3. With this done, the finishing touch was a modified title screen highlighting [Jorj]’s hard work. Credit where credit is due.

Kindly, [Jorj] has uploaded the fixed game for the world to enjoy (.gz file download)! It’s always great to see people still working with and enjoying these old systems. The Apple IIGS even got itself an OS update at age 29.

16 thoughts on “Fixing Bugs In A 37 Year Old Apple II Game

  1. The difference between features and bugs is simple.
    BUG: a problem within code which is found and fixed.
    Feature: A problem within code which has not been found after 5 years.

    This has been a feature for a very long time. So this is not a bug fix.
    It’s a feature change plain and simple!

      1. Thanks!

        I think it’s fair to say it’s a feature change, although that wasn’t obvious when I started. Unless they actually distributed it on DOS 3.3 disks in this broken state at some point, which seems unlikely.

  2. Change bytecodes -> addresses in this summary to make sense.

    All of the old Apple II stuff did this. They’d jump directly to routines in ROM and the DOS so if the devs weren’t careful, they’d break random programs because they’d end up jumping into the wrong part. A lot of work by Apple was spent keeping all the popular addresses the same when they altered code.

    1. Were the programmers doing things they shouldn’t have, or did Apple not have any kind of function dispatch mechanism in their OS? The Commodore Kernal (sic) used a jump table which provided some compatibility across their 8-bit computers.

      1. The latter. This is really early days, bootstrapped off of the history of the Apple I then II. Developers were creative about how to get things done using routines that existed in the ROM. I don’t know that any of them were initially documented. As they became commonly used, Apple worked hard to keep the memory addresses the same for the ones that were most popular — which explains the well-defined dispatch mechanism of the Macintosh. Lesson well learned :)

  3. Great stuff !

    I remember one of my favorite Apple ][ games was Robotron, but it was a hard one.
    So to achieve unlimited game life, I did some research inside the disassembled code and I changed “DEC lives” by “INC lives” at each kill !

  4. Can someone less lazy than me make sure that the Internet Archive gets a fixed version? There’s more than one Three Mile Island up there already, and it’s nice that it plays in-place, but the one I tried crashed to the prompt when 7 was pressed.

  5. Those lo-res graphics are downright adorable.

    I’ve been reading the Micro 6502 Journal archives recently and wow I have a whole new appreciation for personal computing from that era.

    1. I remember days of meticulously typing in programs from publications like this by hand. There’s nothing quite like having to type byte-by-byte, trying like hell to avoid mistakes in transcription. I certainly don’t miss that part of it…

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s