Motorcycle disk drive

For no particularly good reason I found myself looking at the boot code for Jordan Mechner’s Prince of Persia, the source code for which was released to the world a little while back. I was flipping through the protection code, and found a comment that said “Motorcycle disk drive“.

Pop motorcycle disk drive

A quick glance at it revealed that, indeed, it is code that is designed to make your disk drive sound like a motorcycle. It pulls the drive head back until it starts hitting the edge and keeps going, which is basically the same thing that happens when you boot a disk (causing the characteristic Apple II booting noise from the drive). This differs only in that it is using specific delays (controlled by paddle zero) to alter the frequency of the motor turns.

That’s kind of a weird thing. When does this get executed?

Backing up a bit, I saw that when the protection check succeeds, control passes to the point labeled “:yippee“, which does the following thing: Check to see if both the open-apple and closed-apple keys and one other key is pressed. If not, everything proceeds as normal, but if so, look up the key in a dispatch table (just below the code pictured below) and jump to the address in the table.

Pop dispatch

Looking at the dispatch table, it has a few different vectors in it. One of them is for “^” which has the address for the motorcycle disk drive routine in it.

Pop dispatch table

So, if you’re holding down (open-apple, closed-apple, and) ^ at this point very early in the boot process, the code to make your disk drive sound like a motorcycle will be executed, rather than Prince of Persia. (This code is quite likely actually written by Roland Gustafsson, rather than by Jordan Mechner, since Roland was mostly in charge of dealing with the disk drives as I understand it.)

There are in fact a couple of other Easter eggs available at this same point in the boot process. OA-CA-return will give you “confusion” and OA-CA-@ will give you “rotcube”, both graphics demos, and OA-CA-! will print a little message from Jordan (Mechner) and Roland (Gustafsson) to Robert (Cook?) dated 8/25/1989 wishing him well at college and then show some randomly colored blocks.

I have yet to see these run in meatspace, though I’ve hand-assembled the motorcycle code and tried it out on an emulator. Which is a ridiculous thing to do, really—this is code that uses hardware banging against other hardware to make a noise. However, if you can compile it, OpenEmulator does in fact do a good job of emulating the sound, though Virtual II didn’t manage it despite otherwise being pretty accurate with its emulated disk noises. Copying and pasting the assembly code below at the monitor prompt will get you the hand-assembled program, though:

6000: A2 60 BD 89 C0 BD 87 C0 BD 80 C0 20 2C 60 BD 85 C0 BD 86 C0 20 2C 60 BD 83 C0 BD 84 C0 20 2C 60 BD 81 C0 BD 82 C0 20 2C 60 4C 05 60 A9 06 85 00 2C 70 C0 EA EA 2C 64 C0 30 F9 C6 00 D0 F2 60 N6000G

The other Easter eggs would take too long to hand-assemble, and I haven’t yet imported the PoP code into a compilable form for any assembler, so I’ve left it at that for now. If anyone has a real disk, real hardware, and a video-capturing machine, I’d be interested to see these Easter eggs actually being triggered.

[Update: Antoine Vignau pointed out that the secret keys were already documented in the crack documentation, and pointed to a disk image that allows you to play with the Easter eggs by pressing 1-5 upon startup: Brain Trust’s Prince of Persia crack. Still was neat to discover myself, of course!]