Editing ROM Instructions/ Creating Game Genie Codes?

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

User avatar
Spindaboy
Posts: 9
Joined: Sat Jul 14, 2018 5:34 pm
Location: Kentucky
Contact:

Editing ROM Instructions/ Creating Game Genie Codes?

Post by Spindaboy »

I'd like to locate and edit certain RAM values for FF I, II, and III, but am not sure how to go about doing so. This question might be a bit complex so I apologize in advance!

Firstly, I'm not sure I understand exactly how Game Genie overwrites the values. Correct me if I'm wrong, but doesn't Game Genie only edit values in then RAM (as opposed to SRAM)? In other words, the Game Genie edits the loaded RAM values then once you save the game those values are updated in the SRAM?

Secondly, if I'm looking to modify specific values (e.g. for character stats) how can I locate them? I'm familiar with hexadecimal already, but I don't know how to find addresses that haven't already been documented. After I've found the address, then I can convert the hex into a custom Game Genie code, right?

Thirdly, from what I've read some people have said that you cannot change values from a loaded save file, but instead only from a new game.
Remember that these codes will only work on starting
(new game) characters, so don't use these codes on
saved games, because they won't work.
I think the reason this was mentioned was because the example code they gave looks for the default value that's assigned to the address and thus wouldn't work once the value has been changed (by leveling up for example). However, if I generate a new Game Genie code to look for the updated value at the same address then that would still work, right?

Thank you in advance for your help!! ^^
Last edited by Spindaboy on Sat Jul 14, 2018 10:04 pm, edited 1 time in total.
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: How to find RAM addresses/ How to make Game Genie Codes?

Post by tokumaru »

I'm pretty sure that Game Genie codes modify ROM, not RAM.
zzo38
Posts: 1096
Joined: Mon Feb 07, 2011 12:46 pm

Re: How to find RAM addresses/ How to make Game Genie Codes?

Post by zzo38 »

tokumaru wrote:I'm pretty sure that Game Genie codes modify ROM, not RAM.
I believe you are correct. But you might be able to intercept RAM values if the game cartridge maps RAM into $8000-$FFFF (although most cartridges don't do that).
(Free Hero Mesh - FOSS puzzle game engine)
User avatar
Spindaboy
Posts: 9
Joined: Sat Jul 14, 2018 5:34 pm
Location: Kentucky
Contact:

Re: How to find RAM addresses/ How to make Game Genie Codes?

Post by Spindaboy »

zzo38 wrote:
tokumaru wrote:I'm pretty sure that Game Genie codes modify ROM, not RAM.
I believe you are correct. But you might be able to intercept RAM values if the game cartridge maps RAM into $8000-$FFFF (although most cartridges don't do that).
So if that's the case, then I would have to input any stat-altering codes before starting a new game?
User avatar
dougeff
Posts: 3079
Joined: Fri May 08, 2015 7:17 pm

Re: How to find RAM addresses/ How to make Game Genie Codes?

Post by dougeff »

tokumaru wrote:I'm pretty sure that Game Genie codes modify ROM, not RAM.
The game genie always inserts a 1 into bit 15 of the address ($8000). Not only can it only modify ROM, but it can't modify things in the 6000-7fff range, which can be mapped to ROM.
nesdoug.com -- blog/tutorial on programming for the NES
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: How to find RAM addresses/ How to make Game Genie Codes?

Post by tepples »

Which makes me wonder why Nintendo never made a "Genie-proof mapper" that maps everything into $4800-$7FFF.
User avatar
Spindaboy
Posts: 9
Joined: Sat Jul 14, 2018 5:34 pm
Location: Kentucky
Contact:

Re: How to find RAM addresses/ How to make Game Genie Codes?

Post by Spindaboy »

This doesn't sound very promising... so what would the best course of action be?
User avatar
dougeff
Posts: 3079
Joined: Fri May 08, 2015 7:17 pm

Re: How to find RAM addresses/ How to make Game Genie Codes?

Post by dougeff »

Actually, MMC5 can map WRAM to banks above $8000. I guess, in theory you can modify RAM with a game genie.
nesdoug.com -- blog/tutorial on programming for the NES
User avatar
Spindaboy
Posts: 9
Joined: Sat Jul 14, 2018 5:34 pm
Location: Kentucky
Contact:

Re: How to find RAM addresses/ How to make Game Genie Codes?

Post by Spindaboy »

dougeff wrote:Actually, MMC5 can map WRAM to banks above $8000. I guess, in theory you can modify RAM with a game genie.
Can you explain how please?
User avatar
dougeff
Posts: 3079
Joined: Fri May 08, 2015 7:17 pm

Re: How to find RAM addresses/ How to make Game Genie Codes?

Post by dougeff »

Are you asking how the MMC5 mapper works (very few games had...Castlevania 3 was one)? Or how game genie works?

Actually, scratch that. I'm suddenly reminded that MMC5 is buggy with the game genie, and you can't even see the game genie code entry screen.

Relevant discussion...

viewtopic.php?f=9&t=4964
Last edited by dougeff on Sat Jul 14, 2018 7:26 pm, edited 1 time in total.
nesdoug.com -- blog/tutorial on programming for the NES
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: How to find RAM addresses/ How to make Game Genie Codes?

Post by tokumaru »

Spindaboy wrote:Can you explain how please?
He meant that MMC5 games have the ability to map RAM into the ROM area if they've been designed to do that. Modifying an existing game to do that would be a whole different thing, requiring an enormous hacking effort to completely reorganize the way the game engine works, way more work than it'd take to modify the game to implement just the cheat you wanted in the first place.
User avatar
Spindaboy
Posts: 9
Joined: Sat Jul 14, 2018 5:34 pm
Location: Kentucky
Contact:

Re: How to find RAM addresses/ How to make Game Genie Codes?

Post by Spindaboy »

dougeff wrote:Are you asking how the MMC5 mapper works (very few games had...Castlevania 3 was one)? Or how game genie works?

Actually, scratch that. I'm suddenly reminded that MMC5 is buggy with the game genie, and you can't even see the game genie code entry screen.
All I need to know is the best method for editing particular values. Step 1 would be finding the location of what I want to change (which I guess now would be a ROM address) and Step 2 would be at what point I need to activate my custom Game Genie code to change the located address (supposedly before starting a New Game)?
User avatar
dougeff
Posts: 3079
Joined: Fri May 08, 2015 7:17 pm

Re: How to find RAM addresses/ How to make Game Genie Codes?

Post by dougeff »

Ok.

First, have you tried any of the game specific tools over at Romhacking.net?

Such as...

https://www.romhacking.net/utilities/163/

Also, lots of info at the datacrystal database...

http://datacrystal.romhacking.net/wiki/ ... asy_Series

Click on the RAM MAP on each game.
nesdoug.com -- blog/tutorial on programming for the NES
User avatar
dougeff
Posts: 3079
Joined: Fri May 08, 2015 7:17 pm

Re: How to find RAM addresses/ How to make Game Genie Codes?

Post by dougeff »

But, to answer your question...
(I used to make game genie codes as a hobby.)

Basically, when the CPU reads a byte from a specific location in the ROM, instead of getting that byte, you can force it to see another byte.

like if the game code says...
Load the #5 and store it at the "lives left" RAM address, you can tell it to load a 6, or 7, or whatever.

So, step 1 is to figure out which RAM address you want to change, then to locate some code which modifies that RAM address. For me, I like to use a debugger, and set a breakpoint for writes to that address.

Then use a game genie encoder (FCEUX has one), and write a new value to be loaded to that address.

Other things you can do, are changing "conditional branches" to always skip some code, or always do some code.

You could change code to $ea to erase it. ea means NOP, no operation (ie, do nothing).

Lots of options.
Last edited by dougeff on Sat Jul 14, 2018 7:50 pm, edited 1 time in total.
nesdoug.com -- blog/tutorial on programming for the NES
User avatar
Spindaboy
Posts: 9
Joined: Sat Jul 14, 2018 5:34 pm
Location: Kentucky
Contact:

Re: How to find RAM addresses/ How to make Game Genie Codes?

Post by Spindaboy »

dougeff wrote:Ok.

First, have you tried any of the game specific tools over at Romhacking.net?

Such as...

https://www.romhacking.net/utilities/163/

Also, lots of info at the datacrystal database...

http://datacrystal.romhacking.net/wiki/ ... asy_Series

Click on the RAM MAP on each game.
I'm familiar with FF Hackster, but all the changes I want to make are going to be on real cartridges and only involve changing temporary things such as save file stats not actually overwriting any ROM data. The datacrystal information has what I need if I want to intercept the ROM values for FF I, however for FF II and FF III I still need to locate certain addresses which I don't know how to do.
Post Reply