Converting RAM Modifications to ROM

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems.

Moderator: Moderators

Post Reply
User avatar
Zaxtr
Posts: 2
Joined: Tue Jan 15, 2019 10:13 pm
Location: Sydney, Australia

Converting RAM Modifications to ROM

Post by Zaxtr » Wed Jan 16, 2019 4:37 am

G'day everyone

So I have been mucking about with a Homebrew game called 田雞 (Frog) and I tried making the protagonist start the game with 5 lives rather than 3. I could do this by freezing a RAM Value and restarting FCEUX. I wanted to make this change apart of the ROM and I have spent hours trying to figure out the solution. Here are the steps that I have been taking:

1 Get RAM Address 0x0507 (Frog's starting amount of lives, I have checked this value) and
make a write breakpont using FCEUX Debugger

2 Run the debugger and reset the game, getting seemingly random values such as "CE 07 05" as seen in the image above

Have I made a mistake trying to locate these values? Do they direct me to the specific byte (02)? I would appreciate if somebody could lend a hand.

Cheers
Attachments
This is the debugger showing me the values "CE 07 05" which I don't understand
This is the debugger showing me the values "CE 07 05" which I don't understand

Oziphantom
Posts: 776
Joined: Tue Feb 07, 2017 2:03 am

Re: Converting RAM Modifications to ROM

Post by Oziphantom » Wed Jan 16, 2019 5:08 am

That is not random at all. that is code to decrement the life counter. DEC ( DECrement by 1 ) 07 05 6502 stores address LO HI so that is $0507 which is the address you found. That is the code that "takes a life away" you are looking for something like a9 03 8d 07 05

User avatar
Zaxtr
Posts: 2
Joined: Tue Jan 15, 2019 10:13 pm
Location: Sydney, Australia

Re: Converting RAM Modifications to ROM

Post by Zaxtr » Wed Jan 16, 2019 5:29 am

Thanks a tonne, I figured from what you said about DECrement that the debugger was triggered as I killed myself. In response, I left the debugger running as I restarted the game and it triggered with the STA Instruction, which I figured is Storage/Accumulation Data. Thanks again for the help, but how did you predict "A9 03 8D 07 05" (03 was actually 02, because 00 counts as 1) so accurately?

Oziphantom
Posts: 776
Joined: Tue Feb 07, 2017 2:03 am

Re: Converting RAM Modifications to ROM

Post by Oziphantom » Wed Jan 16, 2019 5:52 am

there are only so many ways to init a memory location in 6502
LDA #2
STA $0507
would be the number 1 way
having an array of numbers that it loads in with something like
ldx #7
lda XXXX,x
sta $0500,x
dex
bpl $XX
would be the 2nd

LDX #2
STX $0507 and
LDY #2
STY $0507
possible but very rare chance.

Post Reply