Skip to content

alcarvalho/ruby2600

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ruby2600

An experimental Atari™ 2600 emulator, 100% written in Ruby.

ruby2600

Current status

Games working with no noticeable glitches include:

  • Pitfall!
  • Space Invaders
  • River Raid
  • Pac-Man
  • Tennis
  • Donkey Kong

You can load most 2K and 4K carts and try them out.

Speed is very low: about ~2 FPS (from the expected 60) on a 2.3Ghz computer. An accelerated video shows how the emulator would run in full speed.

Also, no sound is emulated, nor any controllers other than the console switches and player 0 joystick.

Check the Known Issues and FAQ below for more information.

screenshot

Installation

Once this gem is published, you'll be able to install it with:

gem install ruby2600

For now, do this:

git clone [email protected]:chesterbr/ruby2600.git
cd ruby2600
bundle install

Usage

bundle exec ruby -Ilib bin/ruby2600 /path/of/your/romfile.bin

If using jruby on Mac OS X:

bundle exec jruby -J-XstartOnFirstThread -Ilib bin/ruby2600 /path/of/your/romfile.bin

(it will be ruby2600 /path/of/your/romfile.bin once the gem is published)

There are a couple of test files under spec/fixtures/files you can try, but I suggest that you obtain a 2K or 4K .BIN file (for which you have the legal right to play, say, by owning the original cart).

Keys

  • ↑ ← ↓ → - Player 0 joystick
  • Space - Player 0 fire button
  • 1 - GAME SELECT switch
  • 2 - GAME RESET switch
  • 3/4 - Color switch (3 = Color; 4 = black and white)
  • 5/6 - Player 0 difficulty switch (5 = Beginner, 6 = Advanced)
  • 7/8 - Player 1 difficulty switch (7 = Beginner, 8 = Advanced)
  • W/A/S/D - "Sticky" Player 0 joystick (to stop moving, press the non-sticky arrow)

Technical details

  • Full 650x CPU instruction set emulation and test, cloc-ing less than 380 lines of code. (hardware interrupts not emulated, since the 2600 does not have those);
  • RIOT fully implemented and tested;
  • All bus mirrorings implemented and tested; console switches and P0 joystick bindings available for any pluggable front-end.
  • TIA registers are all emulated, with the exception of audio (AU*) and hardware test (RSYNC);
  • Every single aspect of the emulated code is spec-ed, except for some TIA parts I am still figuring out. CPU/RIOT are pretty final, TIA might still be refactored since it suffered a lot of crazy stabs due to the lack of documentation (see below).

Known issues

  • Objects rendered close to the left side (counter zeroing during HBLANK, I suppose) sometimes render in wrong positon (see diagonal.bin test);
  • Some games display an artifact at the left side (late hblank area) where there should be nothing (Freeway, Boxing);
  • Donkey Kong is rendered one pixel off its Stella position;
  • Seaquest renders a full scanline with the diver (missile?) at some specific situations. This bug and the three above it might be related (some odd rendering on a specific postion);
  • Enduro and Jawbreaker render their frames a few dozen scanlines after the right position (Enduro leaves some trash behind, Jawbreaker leaves a black space), cutting the lower part;
  • Maybe UI should dynamically adjust to games that (intentionally) generate larger/smaller frames;
  • Emulator only supports NTSC games - not sure if it's worth the hassle of supporting PAL/SECAM anyway, as most(all?) PAL games are NTSC versions, and SECAM, well… sucks.
  • Should display the logo during startup (either by overriding first few calls to frame, or by running a bootstrap ROM that shows it).

Technical debt:

  • UI code needs some love (just quickly slapped a Gosu script on /bin to make it playable; would seriously consider a JRuby-friendly version)
  • TIA tests don't cover a few aspects (see "Pending" specs);
  • Bus should auto-initialize the components when receiving a string (either on initialize or on a separate method);
  • Bus should forward the Bus#tia.frame call into Bus.frame (avoid indirect access to Tia)

FAQ

Why?

I had two (somewhat) unrelated goals for this year:

  • Learning more about the 2600 (to write a game in the future);
  • Getting more proficient with Ruby and RSpec.

The emulator is the way I found to tackle both at once.

Also, I wanted to test how well such tools coped with emulator development. Performance aside, it was a huge success: an emulator for a very tricky and under-documented system in ~3 months, written by someone that never wrote a full emulator before.

How good is it?

Not really good if your goal is playing games. Keep in mind that:

  • It is slow (~1/30 of a real Atari on my computer).
  • It has no sound.
  • It has a few glitches.

It is good, however, if you want to learn more about the 2600, as the lack of concerns with speed makes the code more accessible than the average emulator.

Will you make it faster/add sound?

Now that ruby2600 reached reasonable compatibility with general games (remaining glitches are unlikely to change the emulator structure in any aspect related to performance), it can be worked. See the slides mentioned below for some planned strategies.

If you want a full-speed emulator with sound and compatible with every single game under the sun, I wholehartedly recommend Stella - which has been an invaluable source of inspiration, debug help and implementation reference. It's what I use to play (other than my real Atari).

Where can I find more information?

  • There are some comments and links on the trickier parts of the code, which refer to interesting pieces of documentation;
  • Slides from the RubyConfBr 2013 presentation available on SlideShare. They show the overall architecture and are a good introduction for playing around.

Is this logo renderable on an Atari?

Not sure, I did it one day I was too bored to write code or slides. I'd say yes (as a playfield), as long as you are flexible with the background color (or use another object to render the characters). But I liked it, so I might eventually try to make a ROM that displays it.

Changelog

0.1.2
  • Separated MovableObject: now Player, Missile, Ball and Playfield are subclasses of Graphic (which only deals with drawing), which is composed from Counter (focused on position and movement) with no delegation. This design clarifies intentions on TIA ("reset this object's counter" = object.counter.reset) which is fundamental now.
0.1.1
  • BIT instruction bug fixed; Pitfall, River Raid and Space Invaders playable (except for some artifacts)
0.1.0
  • First release with full (sans sound) TIA emulation

License

This software is distributed under the terms of the MIT License.

Copyright (c) 2013 Carlos Duarte do Nascimento (Chester) [email protected]

Atari™ word trademarks owned by Atari Interactive, Inc., which this software and its authors do not claim to hold or represent in any way. Any other software mentioned is also property of its respective owners, being mentioned solely for reference purposes.

See the file LICENSE.txt for copying permission.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 88.1%
  • Assembly 7.7%
  • JavaScript 4.2%