Monday, October 14, 2013

Hacking Games for Political Gain -- River City Ransom: Fiscal Fisticuffs






It’s funny that it took me moving halfway across the world to get me to keep abreast of news in the US.  If I’m to believe what I read, then it’s a good thing I’m gone because apparently the country’s going to shortly collapse upon itself due to Congressional inertia and a House minority whose annual fiscal shenanigans bears a striking resemblance to Dr. Seuss’ Zax. 

While I’m told that violence never solves anything in real life, it seems to work as a reasonable solution to problems in video games.  So, I figured what better way to achieve catharsis in the current manufactured crisis than to have an old fashioned beat-down.

Despite being over 20 years old, River City Ransom seems to be the go-to game for hacks of this nature.  In my version, players control a Senate anti-hero (demos have this as Harry Reid because 1) both parties are equally childish, and 2) he’s got four letters in his name – more on that later) who’s fed up with this nonsense and decides to leave Capitol Hill to beat some sense into rank-and-file House Republicans and their Congressional leadership caste. 

The color and tile limitations of the NES, unfortunately, prevent me from making a more grassroots type game.  Some tiles are shared, meaning that the player character and enemies, including bosses, have overlapping graphics.  Because of this, I can’t have an “everyman” (or everywoman!) protagonist, nor can I easily vary the age or gender demographics of the rank-and-file.  The restrictions of the palette limit my ability in a similar fashion, precluding variations in race.  As luck would have it, though, these limitations appear to be built into the demographics of Congress as well, making one wonder if it, too, was rendered by 8-bit technologies.



To start my project, I need to change the tiles to make my Senate anti-hero and the House rank-and-file.  Here, I loaded the ROM through Tile Layer Pro to get this mess:

After some scrolling I find what I think are Alex’s original sprites and altered them to make my Senator.



 


Of course, there’s a lot more to the character sprites than this.  Walking is comprised of three different sprites, attacking has its own set of sprites, as does getting hit and knocked down.  Some are easily identifiable in the tile map, while others can take some time to discover.  Within the first 4x5 area from the top left of the tile map, for example, there are 6 pairs of feet.  With a little experimentation and a lot of triple checking, it’s possible to parse the sprites for each animation.


The game will play like this, but the original color palette will be in place, leaving something to be
desired.






What we need to do is fix this by playing with the palette.  We can see the color scheme of the game through a number of sources, but the easiest is to use an emulator that will display it.  I used FCEUX’s debug menu, where I discovered this palette:




The top row of colors is the background, while the bottom is the ones for sprites.  A quick glance brings home a stark reality:  there’s not many color options available.  In fact, the NES only allows for a total of 8 palettes – 4 of 4 colors for each the background and sprites.  But if you look even closer at the sprite palettes you’ll see something amiss – each sprite palette appears to be using 2 spaces for black, certainly a problem given the limited room for colors.  So why this doubling?  Well, in actuality the first “black” is really a color indicating no color at all:  it’s a marker for transparency. 

So, in actuality, the NES only allows for sprites of 3 different colors.  But that doesn't mean that each sprite can only use one palette.  For example, the sprite for our pissed off Senate anti-hero uses the first sprite palette for the torso and head, while the second one is used for the legs.

Let's get our Senate anti-hero into something a bit more appropriate by modifying the palette.  Highlighting each distinct color in the schema provided by FCEUX reveals its corresponding hexadecimal value.  In this case, the first set of colors for sprites is $00 $0F $30 $26; I discarded the first one and entered the others into a hex editor as a hex string.

Now the first hit I get doesn't necessarily mean these are the droids I'm looking for, so I examined the hex values after this string to see if they matched the ones provided by FCEUX.  They didn't, so I moved on.  The next string, though, was what I was looking for.

The difficult part came in figuring out which values to put in to get the colors I was looking for.  In this case, I was helped by the fact that many of the colors I wanted were in different palettes so all I had to do was rearrange them.  For the gray, which wasn't present, a quick Google search gave me a rough estimate of the values and I played with them until I got a hue I liked.  

As experimentation showed that tiles and palettes are shared I had limited options.  In the end I went with a color scheme as predictably vapid as the constant fiscal brinksmanship.





All that was left, really, was to edit the sprites to reflect the new color scheme.  I havne’t editing all the sprites yet, and the ones I have done still need some aesthetic work, but here’s a brief clip:

video


In addition to the character sprites, I made some other changes.  I’ve put Reid’s name in the top, and altered the background image from “Crosstown H.S.” to “U.S. Senate”.  The biggest problem with this game is that most everything is stored as graphic tiles, which makes changing names a challenge if you want something that will be cohesive across the game.

For example, “Reid” was initially “Alex”.  Because both names have four letters, I merely replaced the tiles for each letter in Alex’s name with those for “Reid”.  This is the lazy way to make alterations because, now, every time the game wants an “A” it will get an “R” instead.  The less lazy way requires more work at the Hex grindstone and necessitates that I change the values of tiles the game calls for that sprite or background, but that’s something I may or may not actually work on as I’ve got other projects.  As I promised to explain earlier, this was also why I used Reid’s name instead of Coburn or someone else.