Saturday, February 14, 2015

programming the atari 2600 part ii: loaded4bear

(2018 Update: I'm putting backups of some of the tools here)

I went to the MIT site for the Global Game Jam, a worldwide "make some new friends and make a game with them, in one weekend!" event I've annually since 2009. One of their optional "diversifier" bonuses (extra gimmicks to aim for, beyond the main theme) was
NES: Make the game playable on an old school console, either directly or through an emulator.
I could do that! I'd made an Atari 2600 game before! And thanks to a kind of amazing creation called batari Basic I thought it might even be doable over a weekend, instead of a year and a half.

Enter Batari

Batari Basic is a genius, enabling tool for the creation of Atari 2600 games; it lets you code game logic in something like good ol' BASIC (and then formally compiles that into assembly language, rather than being interpreted) but more importantly it takes care of the all important, super-difficult display kernel. It also uses some of the precious Atari 128-bytes-of-RAM to store a big, clunky playfield that can be manipulated on the fly. In short, it's one of those homebrew things I never would have thought possible until Fred "Batari" Quimby came and did it.

I pitched a vague idea for an Atari game (something about 2 players indirectly fighting each other, maybe by pushing blocks around - initial game proposals are notoriously disconnected from final results at Game Jams) and attracted a small team consisting of me, Oliver Getz on music, and Winnie Gong for art.

It was pretty touch & go the first night; I tried to get a development environment going, just to make sure that what I was proposing was even feasible. I was an early proponent of batari Basic in 2005, and even created its first homepage, but it had been years since I've played with it, and in the years since I'd switch to Mac, so that was another known risk factor.

The Setup

The first step was getting an emulator going to play any results on: Stella (go to Downloads | Stable Releases on the sidebar) seems to be the default choice.

A few of the Stella defaults were a little wonky (by default, it uses ctrl for the fire button, which when combined with arrow keys becomes the OSX "Change Desktop" keypress... and while my first USB gamepad was sensibly detected and assigned, with the second one I had to go into settings and manually configure up, down, left, right, and fire. Also, PROTIP: for a more fun/authentic experience, go to Options | Video Settings | TV Effects and put it on "Bad Adjust" - it's a bit more true to the old crappy switchbox connections we had back in the day.)
See? It's too pure, too clean!

"Bad Adjust": That's more what we remember, scanlines color bleed and all

Of course here the temptation is to just spend the night playing old Atari games ("for inspiration"). (By the way, a great spot for ROMs as well as community (players and programmers alike is http://atariage.com - they're even the place to go if you want physical versions of your game made.)

The second step was to make sure I could run batari Basic. At the moment I'm working with some of the bB keepers to improve this process, but I think the easiest path at this moment is to get the .zip file from http://atariage.com/forums/topic/214909-bb-with-native-64k-cart-support-11dreveng/
(I found it better to not have any spaces in the path to those files or my build files.) I unzipped the contents of that file into ~/dev/atari2600, then I added

export bB=~/dev/atari2600
export PATH=$PATH:$bB

to my .profile, at which point I could go into the samples/ folder and run

2600basic.sh zombie_chase.bas

which produced zombie_chase.bas.bin, and I could play that in Stella.

The Music

Once I had proved I could make Atari programs on the Mac, I wanted to make sure I could set up Oliver to do his music thing; he was enthusiastic about learning about and working within the constraints of the system's sounds. Years ago I had made the page do re bB: the BASICS of batari music that provides an overview of the theory and practice of the beast, and includes webTune2600, an HTML front end I had made to a command line program that would find the "nearest hit" note sounds for Western music so I was able to point him to that.

(I was a little surprised webTune2600 still worked - my sample batari Basic music code on the page had (memory-wasting) loops with some code that was busted on modern bB, but I've since updated the page with corrected versions.)

The Panic

The chronology is a little fuzzy to me; I think of as of Saturday morning, I was just getting over the issue with music, and I was still nervous about taking on this project. I had a fallback Plan B of making Yet Another Processing / html5 game, which had the secondary benefit of giving our artist Winnie more stuff to do. (Integrating art and keeping non-programmers occupied while the code grinding is underway are frequent challenges for Global Game Jams - and even more so with the minimal "pixel art" I needed for this game.)

But Oliver encouraged us to step up and just DO this, and that's what we did. I was impressed with the aplomb with which he took on the techie aspects of this; I showed him "do re bB" and made sure his compiling system worked, and he took it from there, and provided 3 great sets of music. He also listened to my feedback for specific musical bits (I'm an amateur tuba player myself, so just full of bad ideas) and he seemed an eager audience for some of my old school video game music knowledge (I showed him the hyped up Toccata and Fugue from Atari 2600 Gyruss, Rob Hubbard's C=64 Intro to Skate or Die, and the jazz improv of Atari Ballblazer (comparable to Coltrane, according to musician Pat Metheny) - Oliver himself sings in Berklee's "Video Game Music Choir" so he has a bit of an abiding interest in this stuff.)

The Grind

From here, it was time to hunker down. Some of the modern batari Basic users are fans of "Visual batari Basic", which has some integrated graphics editors and what not, but it's Windows only, and I prefer command line tools (In retrospect, I should have at least set up an editor to do syntax color highlighting.) However, my past self was more into this than I remembered - I had made a browser based sprite editor called playerPal 2600... a little clunky now, but pretty slick for 2007 or whenever it was. You can draw up multiple frames of a multiple color sprite, go to "generate code" and it will output code you can put into a "foobar.bas" file, type "2600basic.sh foobar.bas" and get out "foobar.bas.bin" - this is a binary you can immeditely run in stella, or even dump to a real Atari (especially if you have a Harmony Cartridge), and just like that your little character is running around in real Atari space. (And unlike my music sample code, the code produced by PlayerPal works fine on modern bB!)

The semi-canonical reference for the language is the GIANT batari Basic Commands page, kept up to date by "Random Terrain". This page is... kind of overwhelming.  It's so much information, and not always put together in a way a newbie might find intuitive (I've been collaborating with RT to help smooth out some of the rough edges.) Still, I was able to piece together stuff I had forgotten along with new stuff that had been added.

The game evolved organically from this point, based on what seemed fun with what batari Basic made easy. It's very good at shoving the Playfield Pixels around (big blocks on the screen, vs the smaller playfield graphics), and so one early thing I tried was having the blocks move the opposite way than the main character (which turned into a bear, for no reason better than that's what emerged when I started playing with playerPal 2600) Even without having the playfield blocking movement or shots, it added a kind of pleasing, noisy "camouflage" aspect to things. I added a second player and had them start shooting at each other - not such an original choice, but promisingly reliable for the game jam.

The nice thing was at this point we were making playable demos, and I was able to have Oliver (who was toiling by my side, sometimes on Atari music, but also moonlighting on some of the other GGJ games) test out various ideas, and then we would choose what seemed the most promising. I started with typical "bullet moves in direction player was last moving" (which was tricker to make than I had suspected), then switched to "spears" - horizontal or vertical, and you could steer perpendicular to the main movement. Over playtests this (d)evolved to a simple "you can totally steer your bullet, but you are frozen (and vulnerable) as you do so". Similarly, while more subtle movement is possible on the Atari, it was easier to keep the players and the bullets moving at the same frenetic speed. (Since the Atari 2600 runs at 60 Frames Per Second and has low resolution, it's easy to make things run pretty fast and harder to make them move more slowly.)

The Result

So that was the game!  I liked the balance of offense and defense; you freeze and become more visible when you fire, and you can also wrap around the screen, so there's a lot of opportunity to try to catch your opponent unawares. There are little psych-out strategies like making your opponent think you're focused on your bullet, but then immediately firing a new bullet as they try to sneak up on you. (And again, bullets and bears move at the same pace, so there are some fun race around the screen times that happen as well.)

Before the next afternoon we added scoring, a splotchy-explosiony sound, a title screen, an end screen, and I integrated Olivers' 3 songs (a catchy, funky title song, an anxiety-producing gameplay tune (using only one voice, so the other could do the explosions) and a small victory ditty.) You can download loaded4bear.bin at the project website, or here is a demo if it in action:


You might have noticed I didn't talk about Winnie's role much... unfortunately she was sick for Saturday and Sunday, but she made up this awesome 2600-style box art for it:


(I love the box art tradition that has so little to do with the game inside...)

Oliver and I also made a cheesy old school rap, to liven up our presentation in the truest of 80s spirits:
My name is Kirk
and I'm here to say
I love Atari
in a major way!

We made a game
that's lots of fun!
You play a bear 
with a BIG SHOTGUN

(Ok, by this point in the weekend we were both pretty loopy.)

Anyway, a new Atari game in a weekend! Its been nice getting back into the scene a little bit, and maybe I'll get some more Atari work in before the year is out.

No comments:

Post a Comment