¶Introducing Altirra, an 8-bit Atari emulator
A buddy's been bugging me to release this, and I don't have any VirtualDub news at the moment, so what the heck. :)
Introducing Altirra, my emulator for Atari 8-bit computer systems:
(Update: Links to version 1.0 removed -- superceded by current version.)
Why did I write this? Well, I grew up with a number of 8-bit computer systems, and the one that I liked the most was the Atari 800. The hardware design seemed the most versatile, and furthermore, it was the hardware predecessor to the Amiga, another one of my favorite systems. One day I got struck with a particularly bad case of nostalgia for it, without access to my real Atari 800. Normally I would have just launched Atari800Win, but for some reason I wanted to write my own emulator instead, since I'd never done a real one before, and this eventually was the result. Those of you who have followed VirtualDub's evolution know I like to do everything myself and in my own way. During one phase of its development, I was told: "You have the worst case of feature creep I've ever seen."
Altirra is not the most polished or complete Atari 800/800XL/130XE emulator by far, but it does run quite a lot of software. The main game I wanted to get running was The Last Starfighter, a.k.a. Star Raiders II, which has cool music and some pretty good graphics -- and turned out to be rather complicated to emulate, due to a bankswitched ROM, a complex display list, and lots of display list interrupts. I have an interest in old computer hardware, and I like to find out how hardware actually works instead of just what it does or what it was supposed to be used for. When writing Altirra, I tried to understand how the original hardware was constructed, and craft the emulator in the same fashion. As a result, it's pretty close to cycle exact and supports most of the features of the hardware. It isn't quite up to the level of Atari800Win, which I consider the gold standard, but most of the demos and games I've thrown at it work. It even emulates a few things that A8W doesn't, such as the SIO disk transfer beeping that I remember a lot from my childhood.
Now, the reason why I was asked to release this emulator? Definitely not for the UI, which sucks. The reason is protected disk support: Altirra can boot from APE (.pro) and VAPI (.atx) disk images, which preserve the original copy protection on software. It even supports SIO (serial input/output) call acceleration and burst I/O with protected disks, which means it can boot them very quickly. At the time, neither format was documented and the patched Atari800Win version with VAPI support could not do accelerated reads, so had I released this earlier, it would have been a first; I believe the VAPI format documentation has since been released, so I guess it's a bit late. Still, it was interesting to see what had been done to inhibit copying, such as phantom sectors, CRC errors, and missing sectors, and to see the unmodified games boot. At one point I thought it would be cool to hook up Altirra's disk emulator to a serial port and an SIO2PC cable to see if the emulation was good enough to boot a real Atari, but I never got around to it.
You might laugh when I say that I wrote Altirra for educational purposes, but I swear it's true. I learned more about the Atari than I ever thought I would, particularly all of the undocumented hardware quirks. Among the goofball issues I had to debug were:
- Getting DOS 2.0S to boot with a custom SIO implementation (it replaces serial interrupt vectors and still calls through SIOV)
- A program that read from an unused hardware address and then wrote that value to another port to clear interrupts
- A game that set the display list interrupt flag on a "wait for vertical blank" byte (which causes the DLI to fire every scanline until VBLANK)
- A demo that changed the DLI vector in HBLANK without disabling interrupts and used RTS instead of RTI to exit the handler, leading to crazy control flow
- A demo that alternated the vertical scroll register between two illegal values to get a low-overhead, quarter-resolution 9-color display
- A demo that displayed eight player sprites on a scanline by doing five mid-scanline register writes with exact cycle timing
I have to say, though, that although the demos were an absolute pain to get working, the things that some of the folks in Europe did in the later years on the Atari were utterly mindblowing, like real-time bump mapping, 3D texture mapping, and digital audio. On a 1.79MHz 6502.
To get the information I needed to write the emulator, I spent a lot of time reading the Atari hardware manual and poring over a gate-level chip schematic of POKEY that had been released to the public by the Atari Historical Society. I also ended up disassembling the Atari 810 disk drive control ROM at one point, because I needed to know the exact rate at which it bit-banged out data over the SIO bus and what head stepping parameters it fed to the floppy drive controller, and analyzing the schematics of the Atari 410 tape drive to replicate how it read tapes (it's two bandpass filters and a comparator glued onto the SIO bus).
It's doubtful that I'll work much more on Altirra, especially considering that I haven't really worked on it for months. One of the last things I had been doing was trying to enhance the source-level debugger and cassette support, because I had the idea that it would be possible to write a Guitar Hero or Rock Band clone on the Atari using the tape drive, since it supports an audio track... but of course, that never went far. Working on something like this, you realize quickly that, no, those weren't really the good old days... not when load times were measured in minutes and writing anything really cool meant debugging some really hairy 6502 assembly language. Heck, Altirra essentially amounts to the equivalent of a hardware in-circuit emulator (ICE), and it's still a pain to track down bugs in a machine language program. So, basically, I'm throwing it out there just to see if anyone else has the same curiosities as me and finds it interesting. Source is, of course, available under the GPL, and if you've looked at the VirtualDub source, much of it will look familiar as I used the same base libraries. Enjoy!