|
GuyPerfect Catgirl Level: 68 Posts: 681/1096 EXP: 2665653 For next: 63147 Since: 07-23-07 Since last post: 1.7 years Last activity: 219 days |
|
| It's been quite a while since I hacked a ROM, I do say (and I certainly do value my opinion). I've been off doing/hacking other things, you see, and just got the idea to hack something in particular just a couple days ago.
The particular something in question is Mega Man 2, best known not only for addressing all the terrible design considerations of its predecessor, but for paving the way for practically all Mega Men to follow: 8 bosses, good weapons, letting Dr. Wily escape from the final battle, etc. etc. Mega Man-y things. I was poking around in my Wii channels and found a small collection of Mega Man titles: 2, 3 and 4 for Virtual Console, and 9 and 10 WiiWare. They were all subsequently beaten. Then I downloaded Special Stages 2 and 3 in Mega Man 10 (I already had Special Stage 1) and tried my hand at some speedrunnage. And it was smooth and enjoyable; something no other Mega Man game can match! For you see, Mega Man 10 allows you to switch weapons on the fly without opening the pause menu. Speed runs in other games wind up looking a lot like this:
You know how it is. I figured modifying one of the ancient NES titles to grant similar functionality couldn't be too difficult, so I got to looking into it and (as the existence of this thread I assume indicates) found that the idea is the very opposite of farfetched. It is... nearfetched... Unfortunately for me, it wasn't a simple matter of changing the variable that indicates which weapon you're using. That's most of it, but it doesn't update the graphics data at all. This includes the palette and tile pixels. The palette was easy enough to adjust thanks to a subprogram that Capcom wrote, but the tile graphics were tricky indeed... See, the NES only has room for 512 tiles in video memory. When you select a weapon in the pause menu, its graphics are loaded into a shared region of video memory that changes depending on the weapon selected. So you're basically looking at only the tiles needed for the current weapon, and all the other tiles aren't loaded. But that's just scratching the surface of the tip of the iceberg... Funny thing about NES tiles, you have to transfer them one byte at a time because the PPU has its own memory separate from the CPU memory space. Not surprisingly, you can only do this during VBlank, which gives you time for, like, two tiles' worth of data. Per frame. Every time you change your weapon. Compound this with the fact that the tile data in question is stored in a different memory bank within the ROM (accessed via our good friend MMC1's switching mechanism), and you get an ordeal just waiting to be overcome. Fortunately (ever so fortunately), the game was within its data size budget and the end of the ROM is padded with dummy data, which just so happens to be in the memory bank that's selected into CPU space during gameplay. There was room enough to copy the tile pixel data from elsewhere in the ROM, as well as a few bytes extra to insert some custom-made program code... And you totally know that's exactly what I did! I don't get to work in Assembly very often, so this was really fun (I like to have total control over computers, and this is certainly that). Let's take a look at the modifications I made:
When it was all said and done, I had maybe a dozen bytes of space leftover in that padding area. But that's fine, since I did everything I needed to do. It's not a perfect hack, since screwing with program code in unintended ways is far from guaranteed success, but the cases where it matters are few and far between and can easily be worked around with a little planning. Namely, some not-well-understood graphics code for things like those death beams in Quick Man's stage interferes with the code I wrote to copy weapon tiles to the PPU. But as long as you don't cycle weapons on those screens, you won't see any ill effects. There's nothing here that can cause the game to crash. So how does it work out in practice? Wonderfully. Here's a sample Time Attack run I made for demonstration purposes: <object width="425" height="349"><embed src="http://www.youtube.com/v/yvW8Lx6JXVc?version=3&hl=en_US&rel=0" type="application/x-shockwave-flash" width="425" height="349" allowscriptaccess="always" allowfullscreen="true"></embed></object> I know what you're thinking: where's the download link? Well, that's where I'd like some input. I've got an IPS file ready, but I'm curious as to where would be the best place to host it. I have my own server, but I'm not likely to keep something like this up there forever. What kinds of hacking resource sites are keen on this kind of thing? |





(Press D-pad to switch equipment for that godforsaken Water Temple...)




