Patch Raw Cheat Codes to NES Game

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
Zoldark
Posts: 72
Joined: Sat Oct 28, 2017 10:18 am
Contact:

Patch Raw Cheat Codes to NES Game

Post by Zoldark »

I have a raw Cheat Code and I want to make it permanent for my game, but I searched everywhere and tried everything I could think of and can't find a way to Patch my game with it.

the code is
0402:0A

This is not a game genie code I know they claim a program Called CCCGP works with Raw codes but all it does for the Nes is patch Game Genie Codes into a game not Raw Codes. I do know how to apply game genie codes manually by hand with a hex editor, and I tried the same method with this Raw Code but can't find the area "Hex Value that it effects" in the game where I can make a permanent change.

Can Raw Codes even be applied to a NES Game? Or are they only for emulators?
Don't buy FamicomNes games WillyNilly Check the Mapper first
https://www.nesdev.org/wiki/Mapper
https://nescartdb.com/
I feel like I said something wrong even if I didn't I don't know for sure and I always feel bad about it.
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Patch Raw Cheat Codes to NES Game

Post by tepples »

It's more common on NES to make ROM codes (which affect $8000-$FFFF) than RAM codes (which affect $0000-$07FF or $6000-$7FFF). ROM codes can be turned into Game Genie codes.
User avatar
dougeff
Posts: 3079
Joined: Fri May 08, 2015 7:17 pm

Re: Patch Raw Cheat Codes to NES Game

Post by dougeff »

A skilled person could patch it into the game. It's far more complicated than you think.

402 isn't the 0x402nd byte in the ROM. It's a RAM address that might be written to by hundreds of places in the ROM...or only 1 or 2. Depending on the game.

It's much much easier to do it an emulator, and use a cheat tool to freeze that RAM address at $0a.

It's possible(unlikely), that the game explicitly sets this RAM value during initialization, and setting it once would do what you want. In which patching it would be replacing only 1 byte. But it takes a lot to know which 1 byte.
nesdoug.com -- blog/tutorial on programming for the NES
Zoldark
Posts: 72
Joined: Sat Oct 28, 2017 10:18 am
Contact:

Re: Patch Raw Cheat Codes to NES Game

Post by Zoldark »

dougeff wrote:A skilled person could patch it into the game. It's far more complicated than you think.

402 isn't the 0x402nd byte in the ROM. It's a RAM address that might be written to by hundreds of places in the ROM...or only 1 or 2. Depending on the game.

It's much much easier to do it an emulator, and use a cheat tool to freeze that RAM address at $0a.

It's possible(unlikely), that the game explicitly sets this RAM value during initialization, and setting it once would do what you want. In which patching it would be replacing only 1 byte. But it takes a lot to know which 1 byte.
tepples wrote:It's more common on NES to make ROM codes (which affect $8000-$FFFF) than RAM codes (which affect $0000-$07FF or $6000-$7FFF). ROM codes can be turned into Game Genie codes.
Thank you..

I guess I was on the right track I just hadn't narrowed down the right 1 byte in the game, and I don't have the Ram Address.

I'll just have to try finding it with FCEUX, is a long Process I had to chose a large game. I had thought it only Effected 1 Byte, right now I'm running a comparison on another game that is a Hack of it as it uses a Similar effect as what the code does only is slightly different is a Japan only Pirate version, and am writing down all the area's were it changed by only 1 byte. There are a lot of them though..
Don't buy FamicomNes games WillyNilly Check the Mapper first
https://www.nesdev.org/wiki/Mapper
https://nescartdb.com/
I feel like I said something wrong even if I didn't I don't know for sure and I always feel bad about it.
User avatar
nesrocks
Posts: 563
Joined: Thu Aug 13, 2015 4:40 pm
Location: Rio de Janeiro - Brazil
Contact:

Re: Patch Raw Cheat Codes to NES Game

Post by nesrocks »

Set a breakpoint on the debugger for writes to that address, do a hard reset and start playing the game. If you're really lucky it's simply set a few times (new game, etc), and you can change the value in the ROM. If you're not lucky it may take a bit more time until you understand what exactly changes it.

For example, if there is a code that decreases the value, and you never want it decreased, you can replace the decrease instruction with NOP instructions ($EA).
https://twitter.com/bitinkstudios <- Follow me on twitter! Thanks!
https://www.patreon.com/bitinkstudios <- Support me on Patreon!
Zoldark
Posts: 72
Joined: Sat Oct 28, 2017 10:18 am
Contact:

Re: Patch Raw Cheat Codes to NES Game

Post by Zoldark »

Thanks for the Info, I tried everything I could but still couldn't locate the Ram Address that it effected.
I found that an effect I wanted existed as a game genie code and was able to Patch my game with it.. After having racked my brain for a day and a half.

I did find this helpful doc on cheating with FCUEX http://www.fceux.com/web/help/fceux.htm ... alues.html I'll look over it more carefully later and maybe find away to work with RAM codes after some further study..

I tried the debugger but as far as that goes I don't know much about using it yet. It did show that the Value the code changes is x00, but there are just too many x00 Bytes in the game. The area that the code effects seems as far as I can tell to be between $0000-$07FF but there are a lot single bytes in that range that are 00.. after about 40 or so I gave up.. I wrote down the values FCEUX claimed the code effected and tried those but yielded no result and I even tried adding 10 to them but still nothing.. It was really a frustrating ordeal.

I made a new Game Genie code after modifying the existing one I found online, and well it gives an Effect that is like what I wanted.
So my problem is mostly solved. Thanks Again.

Note: I just realized I should added 16, not 10.. Later..
Don't buy FamicomNes games WillyNilly Check the Mapper first
https://www.nesdev.org/wiki/Mapper
https://nescartdb.com/
I feel like I said something wrong even if I didn't I don't know for sure and I always feel bad about it.
User avatar
Memblers
Site Admin
Posts: 4044
Joined: Mon Sep 20, 2004 6:04 am
Location: Indianapolis
Contact:

Re: Patch Raw Cheat Codes to NES Game

Post by Memblers »

There are some generic ways to freeze RAM, though it probably won't work in every case (most cases would be fine though). You could find some free space in ROM (needs maybe 10 bytes?). Change the NMI vector to point to that free space, then insert some code there that does this:

Code: Select all

 PHA
 LDA #$0A
 STA $0402
 PLA
 JMP original_NMI
User avatar
dougeff
Posts: 3079
Joined: Fri May 08, 2015 7:17 pm

Re: Patch Raw Cheat Codes to NES Game

Post by dougeff »

the code is
0402:0A
I could but still couldn't locate the Ram Address that it effected.
The RAM address is 402 (hexadecimal). The cheat code forces it to be 0a.
show that the Value the code changes is x00
Probably an initial code to zero the RAM. You should have kept playing until some other code wrote to 402.
nesdoug.com -- blog/tutorial on programming for the NES
User avatar
rainwarrior
Posts: 8732
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Patch Raw Cheat Codes to NES Game

Post by rainwarrior »

Is there a reason you haven't named the game in question, or described what this code is supposed to do in it?

We can't share ROMs here, but there's no problem with talking about them, and I'm not volunteering anybody but there's a good chance someone here could figure out whatever it is in a matter of minutes.
Zoldark
Posts: 72
Joined: Sat Oct 28, 2017 10:18 am
Contact:

Re: Patch Raw Cheat Codes to NES Game

Post by Zoldark »

rainwarrior wrote:Is there a reason you haven't named the game in question, or described what this code is supposed to do in it?

We can't share ROMs here, but there's no problem with talking about them, and I'm not volunteering anybody but there's a good chance someone here could figure out whatever it is in a matter of minutes.

I'm sorry it took me awhile to get back on. I had some difficulty with my computer.

I found a Game Genie code and altered it to get an effect I wanted.. Problem solved..

I'm sorry the BSFree website was down, and I thought the guy who made the codes had gotten mad and removed his codes, but it turns out I just hadn't clicked the right button for weapon codes on Gamehacking.org after running a fresh install of windows 7 on my computer, I don't even have an emulator at the moment.. I took down their names this time so if I do use their codes or a modification of them I can give them proper credit.. I'm making a full hack the game not just adding a cheat code I've already got a New Title Screen and Replace two Huge Blocks of Text, and I plan on changing the full Palette, and all text of the game as well as making some graphical changes.

The Code is for 1943 - The Battle of Midway (USA) and changes the default Special Weapon, which is what appears to have been done in the Game 1944 that came out in Japan as a Pirate original or hacked version of 1943 Japan.. But 1944 probably used a different code, and that was the game I was comparing 1943 with trying to find what was used for it.

The Game Genie code LEEPXLAE does the same thing except it enables the Normal Weapon to act as the Special Weapon.
Don't buy FamicomNes games WillyNilly Check the Mapper first
https://www.nesdev.org/wiki/Mapper
https://nescartdb.com/
I feel like I said something wrong even if I didn't I don't know for sure and I always feel bad about it.
User avatar
LucianoTheWindowsFan
Posts: 62
Joined: Mon Jun 22, 2020 9:39 am

Re: Patch Raw Cheat Codes to NES Game

Post by LucianoTheWindowsFan »

I know this thread is almost 3 years old, but I have an FCEUX cheat (0087?00:17) that fixed the triangle channel bug in Ufouria. I just wanted to fix it in the ROM.
The SNES is my favorite console, not only because it is an upgrade to the NES, but because it had some quality games as well (e.g. EarthBound and Kirby's Dream Land 3).
Post Reply