jit.atari2600 for OS X

In February 2006, I ported Kyle Buza's jit.atari2600 jitter external to OS X. This was not an easy port. The main issues were properly handling C++ in C externals and fixing up the source a bit for Codewarrior's more strict C++ compiler as compared to Microsoft's VC++

The main issue in compiling jit.atari2600 was how to integrate the Stella emulater which is in C++ with Jitter. Kyle had done most of the work luckily, bit there were still some Codewarrior specific issues to be solved. In order to get the jitter C object to copmile, it needs to be wrapped in an extern "C" { } clause so that when the C++ compiler processes it, it uses C conventions instead. THe next trick is to get Codewarrior to use the C++ compiler on the file. There are at least 2 ways of doing this: enable the "Force C++ Compilation" option in the C/C++ Language Setting or rename the jitter file to have a .cxx or .cpp file extension. For this project, I chose the latter method.

Since this project is using C++, some extra libraries have to be added to the project. These are CarbonLib and MSL_All_Carbon.Lib. I also needed the header file Carbon.h. When I fist compiled with this setup, I got a host of errors referring to the Random object in the Stella distribution. This ended up being a name conflict with some CFM class, so I renambed it _Random and all of the errors disappeared. Excellent! Now the project compiled and loaded in Jitter. It even showed a red rectangle in the OpenGL window, but when I would go to load a ROM file, CRASH~

The ROM loading and crashing ended up being the biggest headache. After much trial and error and flailing questions to various newsgroups, I found out that CFM libraries have different file path delimiter than Mach-O or VC++. Basically, the Codewarrior libraries use the old-school Macintosh ':' to separate folder names in a path instead of the more modern '/'. Once I figured this out, I thought I was good, but I would still get crashes when I tried to load a ROM. Eventually, I made a debug target for jit.atari2600 and did a stack trace on the crash in Codewarrior. The culprit was the use of char arrays to represent a string instead of using the C++ string class when setting up the Stella emulator. This caused the C++ string destructor to be called on something that wasn't a string, triggering a bad access error. It seems the GCC and VC++ automatically recognize what's going on in this situation and properly handle it while Codewarrior's C++ compiler expects you to be more precise with your code, leading to crashes in your program. In any cae, once this was fixed, all was good

So, jit.atari2600 now works on OS X, but it not the best of builds right now. It's pretty sluggish and the sound doesn't work, so I wouldn't cdonsider this port finished until these issues are addressed. But, at least it works and you can now have some 8-bit good-ness on your mac. If anyone wants to tackle these outstanding problems, by all means go for it. The source code it avaialable in the download ZIP file and this page should help to orient you when examining the code.

Images

jit.atari2600

Download:

jit.atari2600 for OS X with source