News: 11 March 2016 - Forum Rules

Author Topic: How to patch Pro Action Replay and Raw cheat codes into a ROM?  (Read 1138 times)

nanashi89

  • Jr. Member
  • **
  • Posts: 50
    • View Profile
Anything like Game Genie Guy?

Jorpho

  • Hero Member
  • *****
  • Posts: 5051
  • The cat screams with the voice of a man.
    • View Profile
This signature is an illusion and is a trap devised by Satan. Go ahead dauntlessly! Make rapid progres!

FAST6191

  • Hero Member
  • *****
  • Posts: 3345
    • View Profile
Re: How to patch Pro Action Replay and Raw cheat codes into a ROM?
« Reply #2 on: June 18, 2021, 09:53:33 am »
PAR/AR/gameshark/raw/codebreaker/goldfinger... cheats are all typically memory cheats. Classically the game genie codes are ROM cheats, which is to say "this area of the ROM, make it this instead" which is why they are usually trivial to patch into the ROM once you understand the compression and encrytptions used.
Enhacklopedia, wherever it happens to be this week, usually carries a nice list of code descriptions for older consoles https://doc.kodewerx.org/index.html and newer stuff is usually documented in places as well.

It is possible to patch in memory cheats to games, though most place the limit at doing it easily on anything post 16 bit, and even then I don't have any particularly good choices compared to the GBA and DS (see GBAATM, Gabsharky, GBA-ATM rebirth and DSATM) for the PS1 and N64 (though some are doing some things here that people are working on).
I already went in one of the links above but for the sake of a relatively complete reply here.
1) You find say a vblank routine (a section of code that the console runs ever frame, and devs/hackers/cheaters stick code into to run) and chuck in a little "write this to this area of memory" (maybe with a check to see if something else happened) such that every frame the game itself overwrites your health/ammo/mana/items/double jump count/... which is also what your average cheat device does.
2) You find the routine dealing with the item in question and edit that to nerf it, change a sub to an add or similar. If you have a cheat you by design know where it lands in memory and can either set a simple break on write to it to have an emulator tell you what instruction changed it, and instead change the code to do something else. Sometimes you don't even need that and can look at the raw disassembly and find an instruction writing to it. Bonus with this sort of thing is you can also then do things like make codes that work when values live on the stack, and dodge say instant death damage (I usually use invincibility cheats on goldeneye here -- a rocket to the face might do so much damage that the damage calculator sees no health and triggers the death routine before the next frame happens and the cheat device fills you back up, if the damage calculator however never takes it off in the first place... and you might also avoid knockback).

If you make code style 2) above then you also have most of what you need to turn it into a game genie code as well. Speaking of which there is also the secondary thing where many modern systems copy code into memory to run*, as opposed to older cartridge based things that operated from the ROM chips themselves. At this point patching something in memory might well be equivalent to patching a part of the ROM itself and thus can be translated across, give or take any fun with compression.

*anything based on CD/optical or floppy disc being this, and I guess more old school with tapes. The GBA technically had this in some instances (though most times it used its incredibly fast ROM read options to run from the cart, also why GBA emulation can be tricky on limited systems and GBA flash carts still need pricey chips) but the DS was when it properly happened.