§ ¶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!
Thank you for this very unexpected program :)
I'll give it a shot with some games/demos and see what happens :)
ggn - 31 10 08 - 19:48
Talking about emulators... Avery, do you think the shader compiler could be changed to interpret a bit different shader language, I'm looking for something that could create sse code dynamically on the users machine, the pixel processing pipeline of my rasterizer (pcsx2/gsdx) has a few conditions that could be eliminated that way to make it faster, it isn't much different from d3d's pipeline but enough to be impossible to emulate. Currently, I compile about 1000 different little functions into the plugin which isn't very elegant (run the game, explore the 10-20 different states it uses, recompile, a bit PGO-like). Meanwhile, waiting for Larrabee, or at least avx to double the rasterizers speed, even that would be enough for most games (it could reach about 200 mt/s fillrate on one thread).
Gabest - 01 11 08 - 21:38
You would have been better off to have waited until today when you could have replied to the next post, but that's fine. :)
Actually, it's funny that you mentioned it, because I once considered what it would be like to have a tracing 6502 emulation engine, until I realized that the memory aliasing issues would be insane.
Now, as to your question, VDShader internally is fairly modular. The compiler outputs vector IL to an effect structure, which is then converted into scalar IL and optimized by another module, and that is then either interpreted or JITted by one of the three execution engines. The current execution engines are modeled to be as similar as possible to pixel shader hardware in that they accept an array of interpolators and samplers and produce a scanline of pixels. You could either push vector IL and let the scalar engine do the transform and optimization, or you could even plug into the middle of the scalar transformer, as the individual optimization stages are modular, too.
There are a few possible nits. First, you'd have to still implement triangle setup and triangle rasterization, as the engines only do scanline rendering. They don't support perspective correction either, although that's not too hard. I doubt that the list of primitives I support would be sufficient. Another issue is that the engines currently do not support mipmapping, and if you need per-pixel mipmapping with dependent reads, you'd need to convert the SSE2 engine from a 4x1 pipe configuration to 2x2 in order to compute gradients on a per-quad basis. Finally, if you have dynamic branches, you'd have to do major rework, because the optimizers can only handle a single loop.
Phaeron - 02 11 08 - 16:31
The renderer is already done, in c++ with sse intrinsics. The problem is, there are still many if's inside the scanline drawing function that operates per pixel (four with sse) and msvc spills regs where it should not. Better would be if I had some kind of shader code where all the conditions could eliminated (or if Windows had a c++ compiler by default, hehe), their arguments are not known until the game configures the renderer.
I do not support mipmapping yet, 4x1 is what I already do (ps2 does 16x2), and there would be no dynamic branches, every input simplifies down to contants when rendering.
Btw, the source is here:
The only non-local data this fuction accesses are m_sel for the conditions and the m_slenv struct for constants and input/output buffers.
Gabest - 03 11 08 - 04:46
If you're looking for a better code generator than MSVC, you're definitely not going to find it in vdshader. A rather big problem is that currently I don't kill registers as soon as I hit the last use, which means that the code generator often spills dead values and/or unnecessarily duplicates them. That's mainly because I have a simple LRU register allocator rather than a proper register interference graph based one. You might want to look into LLVM instead, which has a much, much more sophisticated optimizer.
Probably should continue any more discussion in the vdshader post, though. :)
Phaeron - 04 11 08 - 00:07
Many games ask you to press START to begin. What is the START button?
Bruce - 27 05 09 - 21:40
Start/Select/Option are F2-F4.
By the way, make sure you get the newer version (1.1).
Phaeron - 28 05 09 - 15:49
Thanks. I have the 1.2 version.
Bruce - 28 05 09 - 17:58
Are most of the games not working or is it just me? For example, Castle Wolfenstein, Quasimodo, Bounty Bob Strike Back, Mr. Robot & His Robot Factory, Pharoh's Curse, Temple Of Apshai.
Bruce - 31 05 09 - 17:58
Are you running with real kernel ROM images? It'll be hit or miss if you're using the built-in ROM kernel, which is only partially compatible.
Phaeron - 01 06 09 - 22:57
I have atariosb.rom, atarixl.rom & ataribas.rom in the same folder as Altirra. Is that what you mean?
Bruce - 02 06 09 - 21:15
Those are the correct files and locations, but you need to select the OS-B or XL firmware as well in the menu.
Phaeron - 02 06 09 - 23:14
Ok. Thanks. I replaced some of the ROMs and I got some of them to work. Bounty Bob still doesn't work and Castle Wolfenstein creates a castle in the first level that you can't get out of.
Bruce - 05 06 09 - 15:41
Threw me for a loop for a moment, but I found the bug with Bounty Bob: I had forgotten to implement address wrapping on ANTIC, even though I did it for POKEY and GTIA. It was looping on an alias of the VCOUNT register. This version has the problem fixed:
The problem with Castle Wolfenstein is that it writes to the disk whenever you change levels and crashes if the write fails. By default, Altirra mounts disks in read-only mode because I hate it when base disks are inadvertently modified. You can change the disk mode in File / Disk Drives; read/write mode will allow writing to the disk image, and virtual read/write mode will keep modifications in-memory if you want to allow writes without affecting the disk image.
Phaeron - 09 06 09 - 04:50
I admire your skills! Writing an emulator has been something like a dream for me since many years! I consider such job very, very inspiring!
Georgi Petrov (gogothebee) - 09 06 09 - 10:59
Hmmmm. I still can't get them to work. Do they run properly for you? Bounty Bob just goes to a black screen after "Loading Bounty Bob Strikes Back" and Castle Wolfenstein creates a maze that you can cannot exit.
Bruce - 10 06 09 - 21:41
Yeah, I can run them. That was kind of the point.
Did you enable read/write or virtual read/write mode for Castle Wolfenstein like I said?
Bounty Bob seems a bit more temperamental: I can only get it running with memory size set to 64K. In both cases, I'd recommend 800XL hardware, XL or HLE kernel, and NTSC (PAL off).
Phaeron - 11 06 09 - 00:07
Ok. I got Bounty Bob working by using the settings you recommended. Also, for Castle Wolfenstein, I had to SAVE the virtual read/write mode overwriting the original ROM...perhaps I should not have done that. But then, I could load it and it doesn't create a room I can't get out of. Thanks a lot and keep up the great work!
Bruce - 13 06 09 - 19:00
Note that ROM stands for Read Only Memory, which refers to a firmware chip and not a disk. A floppy disk that you write to obviously isn't read only.
Phaeron - 14 06 09 - 02:01
I have som wav files of some atari 8 bit basic programs i wrote 20 years ago stored on cassete and recorded to pc as wav. i have tried many times loading ther wavs into altirra but havent been succefull yet.. what format should the wav files be ? 8 bit or 16 bit.. stereo or mono ? does the loading of cassette wav files into altirra actually work ?
would be amazing to se my old programming commming to life again.. my old atari 400 was defect and scrapped many years ago.
mr J - 08 09 09 - 01:24
First, make sure you are using the newest version (1.3).
Second, make sure you're not trying to boot the tape directly. The auto-boot, which is equivalent to holding START on boot and then pressing space, will not work with a BASIC program. You need to turn off auto-boot and let the Atari boot into BASIC before typing "CLOAD" to load the program.
Third, if you still get I/O errors after trying to load the tape, you can try using WAV2CAS to decode the tape. Altirra 1.3 will load .CAS files as well as raw .WAV files. WAV2CAS can be a bit picky about reading raw audio, though, since it is based on a wave crossing detector. I had one tape that wouldn't decode in WAV2CAS until I cleaned it up in Audacity with a bandpass filter, something like 1KHz to 7KHz.
Altirra will accept WAV files in 8-bit or 16-bit PCM format and at any sampling rate. However, if they are stereo, the data must appear in the LEFT track. The reason is that Altirra emulates the 850 cassette player, which plays one channel as audio and the other as data. There is a bug where Altirra is looking at the wrong channel for data; it should be looking at the right track for data instead.
Phaeron - 08 09 09 - 14:59
I have tried everything but still no luck loading wavs into altirra.. i use "cload" in atari basic..i tried some noise reduction and did try to expand and compress the wavs to see if the speed was a litte off.. i tried a lot of things..even wav2cas. My wavs should be
good enough ti load..so i dont understand whats not working.. i noticed that when video mode is pal in altirra, The loading of my wavs is even worse than in ntsc mode.. in ntsc mode i can get like 8 to 15 loaidng beeps before it stops with error 143.. its a bit strange becuase my atari basic programs is written on a atari 400 pal and saved to atari410 cassette recorder..
Mr J - 10 09 09 - 10:50
I been examing my atari wavs and it might be that the quality is a border case when it comes to quality, but still i hope one day to get them rescued, and converted into disk images, I did write mostly games, the best one was a dracula game with blood sucking and bats and dracula has to get into his coffin before daylight or he dies, a action game.
havent seen the game for over 25 years . it was never realeased.
MR J - 12 09 09 - 21:41
If you can drop the WAV file somewhere for download, I can take a crack at trying to decode it. The Atari FSK modulation is relatively insensitive to volume fluctutations, but it is susceptable to tape speed variation. A real Atari is only specced to accept a ~5% variation in clock rate; software decoders on PC are somewhat more tolerant, but there are still limits.
Phaeron - 13 09 09 - 07:39
I have uploaded the Wav file to http://www.filefactory.com/file/ah8119d/..
Its a Atari Basic program file (the atari basic cartigde).
Written on a atari 400 pal and saved to atari 410 cassette recorder.
Maybe you have the knowlegde to getting this to work.. i really have tried hard..
Mr J - 13 09 09 - 09:58
Most of your tape is OK, but Altirra's cassette engine is reporting nine bad blocks on your tape. They are:
27.99s - 31.03s (framing error at 28.880s)
49.68s - 52.98s (framing error at 51.178s)
61.73s - 64.92s (framing error at 62.315s)
68.96s - 72.16s (framing error at 69.741s)
105.12s - 108.10s (framing error at 106.950s)
126.82s - 129.52s (framing error at 129.185s)
213.61s - 216.41s (framing error at 214.640s)
230.48s - 233.45s (framing error at 232.472s)
233.45s - 238.23s (framing error at 236.934s)
A framing error means that the serial decoding engine has lost sync, which then results in a checksum error (error 138). A checksum error means that a valid data pattern was read but the data itself is corrupted. WAV2CAS unfortunately didn't have better luck. I tried fixing the tape manually in Audacity, but was only able to fix the first sector -- I was able to fix the framing error in the second but I still got a checksum failure.
Is there any chance you might have spliced audio sections while recording this tape? Looking at the waveform, it looks like very short sections of audio have been lost, and that's what's causing the decoding to fail.
Phaeron - 13 09 09 - 12:11
So thats it then, the game and other games might be lost.. the orginal tapes dont exist anymore, i actually dont think the audio is spliced, i did record it in a normal way as i would do a audio file. maybe the 25 years old tape just wasnt good enough, perhaps a small error did occur during the recording.. Thanks for your help and thank you very mutch for ALtirra.
Mr J - 13 09 09 - 21:37
I'm not understanding. Save a basic program into .CAS file. Is it possible with Altirra?
Gorosup - 16 09 09 - 07:30
Altirra is getting very good, but im having a little trouble with the keyboard layout, i dont know what key represent the Atari key and i dont seem to get the arrow keys to function in atari basic and memo pad and i dont know the key for special symbols..
i read the docs but no info on the atari key or special key.
Mr J - 16 09 09 - 12:27
Well, I have tested this emulator, and I liked the cassette support on WAV Format. The reason is, because in my country exist a cassette loader who has a pong game when the program is loading, and when I've tried to backup this old cassettes on WAV format and later on CAS format, using the WAV2CAS program, it cannot recognised an specific block on the WAV file (the WAV file works fine on real Atari).
I'll be grateful if you can help me to convert this WAV files on CAS format, or specifically the format that you are using to support the WAV files in your emulator.
Here is the link of the WAV file, who contains the PONG loader...
Tabson - 01 10 09 - 11:26
I tried your WAV file and it works as-is in Altirra 1.3, as long as the cassette SIO patch is disabled and the hardware mode is set to 800XL. I'm afraid you cannot store this game in CAS format, however, since there is a portion near the beginning where non-standard blocks are used -- specifically, a sync tone that is read by the loader by polling the data bit instead of reading from the serial port. The CAS format doesn't support storing raw data bits. I'm afraid that Altirra doesn't support anything in between -- it's either CAS or WAV.
Phaeron - 01 10 09 - 17:23
The emulator is great. You are doing a great job and keep well.
But I would like the tape recorder could handle as Atari800Win. See this picture for me to understand.
Excuse my English. Thank you very much.
NSonic - 14 11 09 - 08:53
I am having difficulty with Ulysses and the Golden Fleece. It has 3 .atr files. I can Boot the first one but then it says insert side B and press return. I don't know what to do at this point to get the came to continue properly. Anyone know?
Bruce - 11 12 09 - 12:31
Hello, using Altirra, wanted to dump audio from a CAS file
When recording RAW PCM audio, this record 32Khz stereo 32bit floating point.
The idea was to reconstruct audio from a cassette turbocharge.
Resurrecting audio cassette (wav2cas cas2wav), but as Altirra works in the cassette loading turbo.
Specifically my suggestions are:
I would like to record audio from the loading of data, audio unmixed with the emulator.
I record audio CD quality. 44.1Khz 16bit stereo PCM.
Grateful for your work with Altirra.
SmartFinder from Chile
Smartfinder - 04 02 10 - 09:55
Hi. Some .cfg file or something to edit manually the altirra options?
Marcus - 04 05 10 - 04:12
The simulator looks amazing, howvever I must confess to being a complete amateur iwth most technical aspects discussed here. Put simply, I used to play the amazing 'Draconus' on the Atari XL many years ago _ I assume this is still possible?
I have downloaded Altirra, and managed to locate .atr and .cas xip of Draconus. NOw it's trying to run it on a pc...I do apologise for asking here but was unable to locate any manuals for doing so...can you please help?
bazwag - 07 05 10 - 01:09
Please ignore the (atrociously spelt!) earlier post - managed to sort this at last. Thanks for the wonderful emulator - I believe it's twenty years since I heard the far out sounds of 'Draconus' - all the best!!!
bazwag - 07 05 10 - 03:38
Is there a key mapping for 'Atari Key' to do inverse text graphics? If so what is it?
William - 24 09 10 - 12:57
Is there a way to map the START, SELECT, OPTION, and RESET keys to gamepad buttons? Would like to use Altirra with only arcade controls. Thanks
GlitchBOy - 08 01 12 - 13:23
What I wish someone, anyone, would do is tack on to an emulator the ability to accept a telnet (or ssh) connection and pass "RING" to a BBS program.
Then all I would need is a way to get a telnet (or ssh) client to show ATASCII characters. Or, I suppose, it would be better to have another emulator running with the ability to make a telnet (or ssh) connection and have the term program think it's talking to a modem.
MrEntropy (link) - 14 01 12 - 23:11
Hello is there any plan for netcode this would be ideal for playing four player classic m.u.l.e game.I know this can be done on Atari WinPlus over kaillera rubbish but WinPlus is far to sensitive when out of focus from emulation also the sound is qite flakey too.
Ajx - 23 01 12 - 03:23
Is there anyway to map out a Windows 7 keyboard for Altirra? I have a few game ROMs that require multiple keystrokes but I can't seem to get any of my laptop's keys to work with the ROMs.
I'm a total noob to emulators, so I apologize in advance.
LastStrFtr - 22 08 12 - 15:17
This emulator kicks butt! My favorite emulator for the Atari 800. I'm new to the Atari 8-bit computers having just bought the first model 800 off of the bay, but I am learning fast. I love the games on this thing. I had a C64 back in the day, which arguably had the best graphics and definitely the best (SID chip) sound to my ears......but I am loving the GAMES on the 8-bit Atari, and just the whole experience. I have to say I feel this machine is equal to the C64, if not better! But I'm just glad I'm into it now, because really it's all about the games and Atari, well, they've got the games don't they! Anyway, This emulator Altirra, I think it is better than the other popular one, it just feels better, more user friendly and what a stack of options to choose from! Loads of things to change and menu's are worded descriptively. I also like how I didn't have to really do too much to get it looking great in full screen. Windowed mode though also nice and big by default. Another thing is the keyset A is perfect for me, cursor keys and left ctrl for fire. Perfect. So, basically I'm keeping the zip safe just in case it ever changes. Because at the moment this emulator is fantastic for me. I have to say as far as emulators go, this one is probably my favourite one, because of the sheer amount of options, and the layout of the menus. Very easy to get to grips with, but complex enough too.
Basically this emulator is a God Send! So Thank You Very Much Indeed to Who made it.
dave - 10 05 13 - 09:19
By the way my post above is regarding Altirra x64 2.20 running on Windows 8 Pro on an Asus Laptop with intel CPU and integrated intel graphics. $300 Asus laptop. Nothing fancy....Actually it's Asus model x401a.... So it's not like you need a supercomputer to run this either.. Excellent work, thanks Phaeron.
dave - 10 05 13 - 09:28