News:

11 March 2016 - Forum Rules

Main Menu

Kirby's Adventure ASM hacking

Started by PRIZZA, April 18, 2011, 05:28:46 PM

Previous topic - Next topic

PRIZZA

Over the past week I've been teaching myself NES ROM hacking via a few helpful guides on this website and with Kirby's Adventure. I need some help finding a few locations, however.

I've been wanting to change a few things, like what abilities certain enemies give you when they're swallowed, and what effects the abilities have when used. I wanted to start a sort of hack that amplifies the games attacks, kind of something like Kirby's EXTREME Adventure, where all of the attacks used are much better than usual.

I've been successful in changing the abilities gained by the enemies in the museums. I'll even list how I found the variables. Please note, these locations are for the PRG1 version of the game. I'm not sure if this matters or not:

Opening FCEUXD SP, I loaded the ROM and then entered the museum in World 1. Here you see a Blade Knight, that gives you the Sword ability. Next you open the debugger and set a break on the writing of 05E2, since I found that to be the ability the enemy gives you when inhaled (found via RAM Filter...).

When the game breaks when you go to inhale the enemy, you can see that the accumulator has the value "03" stored in it, which is the value for sword ability. Scrolling up a bit, I noticed that the address $8310 has this code:
LDA $6212,X @ $621B = #$03 (Note: the address "621B" is not a constant. It seems to change each time I reload the ROM).

I then left the room and set a breakpoint for write to "$621B", also turning off the other breakpoint so it wouldn't hassle me in my testing.  The first break that happens starts when the screen is still black, and I noticed that the accumulator still has "00" in it, so I pressed "Run" once again. The game breaks once more, and I saw this time the accumulator has something in it, so I scrolled up and voila, I found that the address "$BD81" contains the value we're looking for. I then opened the Hex editor and chose to go to that device in the ROM, and found the address to be "04BD91". You can change the 03 there to be anything you'd like, I changed mine to "17" for UFO.

This leads me to next next question: How do I find the other enemies ability values, such as the ones found on the regular game stages? I would love if someone could help me out and find some, or explain how to. I also would like to have some suggestions on how to find the effects of abilities.

For example, When you gain the ability of Beam, how would I go about perhaps extending the length of the beam? Or if I had fire ability, how could I make it so that it shoots a damaging fireball much like how Hotheads can shoot fireballs across the screen. How could I make the Ice ability simply create an icecube rather than blowing ice breath? I could go on forever, but I just would like to hear some feedback on how I can find these offsets. Thanks for any and all help I get! I'll be sure to credit you in the hack once I finish it ;__;

snarfblam

Quote from: PRIZZA on April 18, 2011, 05:28:46 PMWhen you gain the ability of Beam, how would I go about perhaps extending the length of the beam? Or if I had fire ability, how could I make it so that it shoots a damaging fireball much like how Hotheads can shoot fireballs across the screen. How could I make the Ice ability simply create an icecube rather than blowing ice breath?

These sort of changes involve modifying sprite layouts, changing when and how objects spawn, and so on. In order to do this kind of hacking you need some intimate knowledge of both the game's data and program. So step 1 would be disassembling and documenting the relevant game code, which can be tedious and difficult.

PRIZZA

QuoteThese sort of changes involve modifying sprite layouts, changing when and how objects spawn, and so on. In order to do this kind of hacking you need some intimate knowledge of both the game's data and program. So step 1 would be disassembling and documenting the relevant game code, which can be tedious and difficult.

Maybe so, but I do know that there are other variables that would be easier to buff, however, such as the distance that Kirby's Cutter travels when thrown, or perhaps the quantity. Even small things able to be changed like this would be nice. Kefka documented various changes to monster AI that was similar to this, but I'm just not sure of the methodology used to find these addresses.

Thanks for the response!

snarfblam

Quote from: PRIZZA on April 18, 2011, 09:26:57 PM
such as the distance that Kirby's Cutter travels when thrown...I'm just not sure of the methodology used to find these addresses.
You need to tackle small stuff first. The "how" comes with experience. I took a couple of minutes to mess with the cutter and wrote a log of what I did:

-Ran game in slow motion (makes some things easier)
-Used cheat search to find RAM address that stored cutter projectile speed: 60f8 (+ projectile index)
-Added write breakpoint for 60f8
-Enabled trace logger
-Threw cutter (breakpoint triggered)
-look at trace logger - value of zero being stored
    - Looks like a 'clear object data' routine:
        1F:CC6F:A9 00     LDA #$00
        1F:CC71:9D E0 60  STA $60E0,X ; X = projectile index
        1F:CC74:9D F2 60  STA $60F2,X
        1F:CC77:9D 04 61  STA $6104,X
        1F:CC7A:9D 16 61  STA $6116,X
        1F:CC7D:9D 5A 62  STA $625A,X
        1F:CC80:9D 6C 62  STA $626C,X
-click run, breakpoint is triggered again- Value of FC (-4) is being written
-look at trace logger
    -Not sure what value of Y means
    -Cutter speed is negated because I threw it to the left
        $E28C:B1 1E     LDA ($1E),Y @ $B5E8 = #$04 ; INITIAL PROJECTILE SPEED
        $E28E:49 FF     EOR #$FF                   ; A = (-A) - 1 = FB
        $E290:69 00     ADC #$00                   ; A = A + 1 (carry is set) = FC
-$B5E8 maps to 0x2d5f8 in ROM (you can right-click in the FCEUX hex editor and select "Go Here in ROM")
-Edit this value
-Disable trace logger and breakponts and run game
-???
-SUCCESS: cutter now goes much further

How did I know what to do at each step, having zero knowledge of this game's programming? Experience. (I don't even have that much.) Just start with small stuff, and learn the tools and techniques as you go.

PRIZZA

#4
From your detailed analysis of what you did to find the value, I retraced your steps and also found the cutter ability. Your methods outlined also helped me to figure out how to search for the cutter speed value via the cheat engine, and I found the cutter value on my own as well.

Also, thank you for showing me the usefulness of the Trace Logger as well.

Using your guidelines, I was also able to find the initial jump speed of the Hi-Jump ability! Thank you so much for your time, I'll be sure to mention you in my hack projects in the special thanks section.

You've helped to get me on my way, I'll also be sure to share any tips with other people that may come across this topic.

You're the best :D

April 21, 2011, 04:18:36 AM - (Auto Merged - Double Posts are not allowed before 7 days.)

I do have a question for you, though. You mentioned running the game in slow motion... Is there a way to do that with FCEUXD/SP, because I don't see an option for that anywhere.

What am I missing?

snarfblam

The "+" and "-" keys do the trick with the version I have.

PRIZZA

What emulator are you using that has both slowdown (I'm assuming it's in the options NES -> Slow down, or + and -)?

My version doesn't have that, and I found another version but this one doesn't have a trace logger. What gives?

snarfblam

FCEUX 2.1.4a, which is the most recent version on the download page. It sounds like you are using an old version.
QuoteFCEUX contains all features and enhancements from FCE, FCE Ultra, FCEU rerecording, FCEUXD, and FCEUXDSP as well as many new mappers from FCEU-mm.

You can go to Config->Map Hotkeys to see and configure the keyboard input.

PRIZZA

#8
Thanks for your help, snarfblam!