Jump to content
IGNORED

My Failed Attempt at Programming an Atari Emulator


Ego Trip

Recommended Posts

I've been half-heartedly learning C programming for about a year now and am always looking for projects to improve my abilities. Way back in June 2006, my idea was to program an emulator or at least try to do so. After a little research, I decided that programming an emulator for the Atari 2600 would be the easiest. Immediately, there were a few problems:

 

1.) I've never seen an Atari 2600 in my life. I've only played the games on other emulators.

2.) I've never programmed an Atari 2600 game. I did a little programming for it, but it was only a slightly modified version of the source code that can be found on that 8-step Atari 2600 programming guide.

3.) At that time, the most complicated thing I had programmed before that was a halfway finished text-based adventure (I eventually finished it though).

4.) I still don't have any idea how to get Direct X to work with Dev-C++, and information on programming anything in 2D with OpenGL is hard to come by.

5.) I was forced to use the Windows API. Dev-C++ and the Windows API don't get along very well.

6.) I still have no real concept of program flow.

 

It took me about a week to figure out how to make a screen buffer for a Windows application that I could simply write to and then display. After that, I thought everything would be easy. I decided to start with emulating one game and building off of that. I chose Pac-Man and decided that first I would have to write the code for the 6502 (I didn't want to use anything pre-made). I looked for hours but couldn't find a list of 6502 opcodes and their functions. So what I did was open a disassembled version of Pac-Man next to the Pac-Man ROM opened up in a hex editor. I would figure out which opcode corresponded to which function and then make a spot for it in the switch statement. After I did all of the opcodes that appear in Pac-Man, I tried Pitfall and got a few more. I set up the emulator to run through the code until it reached an opcode it wasn't familiar with. I had it report the location of the opcode, the opcode itself, the state of the registers, and some other stuff. I did this with several ROMs until I felt I had enough opcodes.

 

Next I decided to tackle the TIA. The TIA is what caused my project to fail. I never got the timing right for it. VBLANK and VSYNC and handling strobes became a major headache. The farthest I ever got with the TIA was to display the background color, but it does so in a very distorted way. The longest part of all the programming I did was setting up a palette with the different colors the Atari 2600 can display. I used the image on this page in Paint to figure out the RGB values for each one.

 

I worked a little on the PIA. By "little," I mean that I looked at the concept of a timer and then decided to work on something else.

 

I had big plans for the emulator if I had gotten it to work. I was going to put in a lot of features that would (hopefully) help Atari programmers. Some of the things I was going to implement were register and memory logging, disabling graphic layers, and an on-the-spot graphics editor.

 

Currently, the emualtor, which I haven't touched since late June, only runs Pac-Man. And by runs, I mean it runs through the code of Pac-Man without ever freezing, and the TIA portion displays a horribly disfigured background. The only interaction the player can have with it is hitting the color/monochrome switch and watching the background switch between the two modes. I've recently considered working on it some more because I've learned about something called "UNIX timing." If I could figure out how to use it, I could make the timers work and run it at a constant 60FPS.

 

I would host the .exe and the source code somewhere, but I don't where I would do it. If anyone's curious enough to see how far I got, I'll happily send it to anyone who asks. If people are interested and anyone knows of a site where I could host a small file (not even 200KB including the source code), it would be greatly appreciated.

 

atari_emu.png

If you squint really hard, you can sort of see what appears to be the background of Pac-Man.

Link to comment
Share on other sites

If you were looking for an easy emulator project, then the 2600 was a really bad choice. The system may be old, but it's surprisingly complicated. It's sort of like a an old car engine that you somehow managed to get working, and then you never touch it because you know that if you do, it'll suddenly blow up in your face. If the timing isn't perfectly right, then nothing will work right at all.

 

If you want something that's a little friendlier to start with, you might want to try a ColecoVision emulator. The hardware is all very standard stuff, and the games generally don't rely on nearly as many tricks in order to do their stuff.

 

--Zero

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...