|
CONTENTS Home Projects Electronics Graphics Java Java Mobile Other Stuff Resume Music Links To Friends Pictures About Mike Contact |
JatariIntroduction This is an attempt to make an Atari 2600 emulator in Java. I actually started this a long time ago, but after getting the CPU fully implemented I didn't have time to finish it. A few weeks ago an I did an FPGA VGA project and it reminded me about Jatari.. plus I got a couple emails asking me about.. so I decided to start development up again. My ultimate goal was to get this working with J2ME for mobile phones, although I'm not sure if a mobile phone CPU will be fast enough. I actually ported the CPU part of the code to C so I could compile it on a Playstation 2 and to SPIN to run a propeller CPU. Maybe if I finish the Java version I'll finish those. Also further down this page I have a Perl script I recently made to convert to the Java code to C++. What It Does Right now Jatari consists of a number of Java class files: TIA (graphics and sound.. I believe this chip is also nicknamed Stella), Television (emulates the raster beam of a TV), PIA (the RIOT IO, timer chip, and RAM), ROM (where cartridge memory sits), m65xx (decodes instructions from a 6502/6507/6510 cpu), MemoryBus (routes to object/chip where memory read/writes should go), and Jatari (simply the "main" class that starts it all up). I normally stay away from heavily object oriented programming like this, but I decided to give this a try here. Originally I was trying to keep everything realtime with the TV and video drawing pieces asyncronous and everything in a few and bigger class files, but I changed my mind and decided to just try and get it working like this first. Most likely even on a desktop running this model it will be too slow to run a game, but we'll see. To make Jatari run as an applet or in J2ME should be as simple as adjusting the Television class to use an applet/midlet canvas instead of a Frame and making the ROM read from an HTTP socket to grab the game file. The Jatari class would have to be modified too to extend Applet or Midlet. In its current state, Jatari will render the test.bin file included in the download correctly. Now I have to make sure the PIA works, add sprites, collision dectection, and connect the keyboard with the Joystick interface. I think I won't add sound, at least not immediately, since sound on j2me (the ultimate goal here) is pretty goofy. Btw, I wrote a little javascript program to help define the colors in the system. If anyone is interested in playing with it it's here: yuv / rgb converter. I found some really nice example programs on http://khryssun.free.fr/programming.html. I've been using these to test and make sure Jatari is working properly. Right now I can perfectly render the heart picture with Jatari. I'm currently getting about 30 frames per second on an Althlon XP 1.8GHz. I'll have to optimize some code here when I get done implementing the full hardware. Java To C++ I've also been thinking of doing the Atari emulator for Playstation 2 or maybe iPod-Touch/iPhone, so I wrote a Perl script that would convert this Java code to C++. Everything should convert pretty much straight over except for the Monitor.java class which will have to be written specifically for the computer/device this is being ported to. I already converted the m65xx code to C by hand a long time ago, but I figured this would be better so if I find a bug ever in the Java code, I don't have to rewrite the fix by hand into the C/C++ code. I kinda freaked some of my friends out with this code since they know I'm not a fan of either C++ or Perl, but I have to admit here that using Perl made writing this converter really easy and C++ is a pretty obvious conversion from Java. This script may work on other code, but it's pretty much tuned to my style of coding and takes into account that I don't use much of the Java API, so I wouldn't count on it being helpful outside of this project. News I updated the m65xx class to use switch/case statements to see if jump tables would speed up the CPU. I didn't realize Java could do jump tables like that. Anyway, I think it might have sped things up a little bit, but nothing significant. I think most of the slow down is actually in the graphic drawing routines. Which may be a good thing. Maybe running on a virtual machine inside a phone, the graphics run much faster than Sun's J2SE virtual machine. Actually, a good test would be to try this with IBM's virtual machine or such and see if the frame rates go way up. Btw, running this on this dual core Intel box I have with 64 bit Java 1.6 I was getting frame rates around 124fps. Download
jatari-2009-04-26.tar.gz
Copyright 1997-2010 - Michael Kohn
This page was designed to work with all standard HTML compatible web browsers including Firefox, IE, Safari, and Links. |