ROM to RAM Question

Are you new to 6502, NES, or even programming in general? Post any of your questions here. Remember - the only dumb question is the question that remains unasked.

Moderator: Moderators

Post Reply
User avatar
BioMechanical Dude
Formerly AlienX
Posts: 137
Joined: Fri Apr 18, 2014 7:41 am
Location: Bulgaria

ROM to RAM Question

Post by BioMechanical Dude »

So, I've been trying to hack NES games and hard code values like the number of lives you start with, weapons, etc. FCEUX's Game Genie Decoder/Encoder works great for finding the right ROM address in early titles like "Super Mario Bros.", but when it comes to games that use mappers, things got complicated.

Let's say we've got "Castlevania" and we want to change the number of lives you start with. I know, that the RAM address for them is $002A and the original value is 04. No matter how much I searched, none of the "Possible Affected ROM File Addresses" contained the value of 04!

After that, I decided to find out which addresses in the MMC1 Mapper are used for PRG code banks. I searched for addresses in NES Memory, then tried to change their values in the ROM file, but there was no effect. The game hadn't changed at all!

In the end, I said "screw it!" and made a dump of the Assembly Code in the game. So, naturally, somewhere in the code, there should be lines like:
LDA #$04
STA $002A
But no! There wasn't anything like that. In fact, there was no line of code, writing anything from the Accumulator, X or Y into that address!

So, what's wrong? Why is that address never used, when it clearly contains important information? Is it possible, that the game writes to a different address and, somehow, it gets changed in the emulator? I don't think the header has anything to do with that, but who knows? Somebody, please, help!
Greetings! I'm That Bio Mechanical Dude and I like creating various stuff like movies, games and of course chiptunes!
You can check out my YouTube Channel.
You can also follow me on Twitter.
User avatar
thefox
Posts: 3139
Joined: Mon Jan 03, 2005 10:36 am
Location: Tampere, Finland
Contact:

Re: ROM to RAM Question

Post by thefox »

Set a "write" breakpoint on $2A in an emulator like FCEUX or Nintendulator(DX). It should take you right to the place where the number of lives is written. Note that if the game clears RAM on init, you may get an extra break because of that.
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: fo.aspekt.fi
User avatar
Quietust
Posts: 1787
Joined: Sun Sep 19, 2004 10:59 pm
Contact:

Re: ROM to RAM Question

Post by Quietust »

thefox wrote:Set a "write" breakpoint on $2A in an emulator like FCEUX or Nintendulator(DX). It should take you right to the place where the number of lives is written. Note that if the game clears RAM on init, you may get an extra break because of that.
I was doing this while you made that post, and this is what it turned up:

Code: Select all

C92A: LDA #$04
C92C: STA $2A
"STA $002A" and "STA $2A" are not the same thing - the former is absolute, and the latter is zero-page.
Quietust, QMT Productions
P.S. If you don't get this note, let me know and I'll write you another.
User avatar
rainwarrior
Posts: 8062
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: ROM to RAM Question

Post by rainwarrior »

Did you try looking for 5 or 3? Often the remaining lives indicator is different by one from the internally stored value.

If you still can't find it, setup a trace log and put a breakpoint on the byte of the screen's PPU memory where the indicator is shown. Once the breakpoint is hit, save the trace then follow the data trail backwards until you learn where it came from.
mikaelmoizt
Posts: 120
Joined: Sat Apr 12, 2014 12:11 pm
Location: Gothenburg, Sweden

Re: ROM to RAM Question

Post by mikaelmoizt »

Like people already have suggested.. add a write breakpoint on $002a, reset the game.
The first write made is most likely for clearing RAM.

(found it..)
I´ve got %01100011 problems but the BITs aint one.
User avatar
BioMechanical Dude
Formerly AlienX
Posts: 137
Joined: Fri Apr 18, 2014 7:41 am
Location: Bulgaria

Re: ROM to RAM Question

Post by BioMechanical Dude »

Thanks, guys. This works pretty well. :)
Greetings! I'm That Bio Mechanical Dude and I like creating various stuff like movies, games and of course chiptunes!
You can check out my YouTube Channel.
You can also follow me on Twitter.
Post Reply