How do GameShark codes work?

[BACK]
How do GameShark codes work?
Posted On: July 22, 2013

This has always boggled me. Obviously GameShark and Game Genie never got inside access to place their own cheats into every game. I don't think any developers gave them the source code to pour over for codes. And I don't think the original development process for these games included placing any of these codes themselves. So, what is a GameShark or Game Genie code, really?


Both of them usually take the form of a relatively short hexadecimal string (or multiple if that is the case) so my intuition tells me they use the same principle. But are they just memory addresses to flip a bit? Or lock it? Or XOR a series of bits with something? What is the code, and what does it do?


Question from user LoveAndCoding at gaming.stackexchange.com.


Answer:

How it works.


When GameShark (and other game enhancer products/homebrew) gets loaded by the console, the enhancer is what launches the actual game. In doing so, it leaves behind a Code Handler in the system RAM and "hooks" the game's programming.


Specific locations in a game's programming that get executed roughly every frame (like reading the controller data) are where "hooks" will be placed. (because SDKs are used, this makes finding hooks that work in all games for a system much easier).


What the hook actually does is redirect the flow of programming to the Code Handler the enhancer left behind. Once the Code Handler is finished executing, it returns the flow of programming back to the point of hijacking.


If you are familiar with GameShark's "Master Code", that is what sets the hook.


(other enhancers - like Gecko OS for Wii - don't need master codes because the enhancer itself has a handful of SDK-based hooks that it can "find" in the game while it loads.).


Structure of codes.


Now a code itself is separated into THREE parts:.


The CodeType (this is USUALLY the first byte of the code-- the first 2 Hex Characters). CodeTypes are specific to the enhancer.


The address in ram that the CodeType will use.


The value the codetype will use at the specified address.


The most common CodeTypes are:.


RAM Writes (typical options are 8bit, 16bit, or 32bit).


With RAM Write, the CodeHandler will take the value and place it at the address. (changing whatever was there, like setting your health to 100!).


Conditionals (typical options are >, <, =, !=).


With Conditionals, the CodeHander reads the value at the code's address and compares it to the value in the code. IF the comparison returns true, then the CodeHander will execute the next line in the code. (how many lines it executes is up to the enhancer and often is an option in the codetype itself!).


There is plenty more info we could dive into, but that should give you a good basis for understanding. =).


Source: Game hacker since 1999, founder of http://GeckoCodes.org.


Answer from user James0x57 at gaming.stackexchange.com.



[BACK]
How do GameShark codes work?
Posted On: July 22, 2013

This has always boggled me. Obviously GameShark and Game Genie never got inside access to place their own cheats into every game. I don't think any developers gave them the source code to pour over for codes. And I don't think the original development process for these games included placing any of these codes themselves. So, what is a GameShark or Game Genie code, really?


Both of them usually take the form of a relatively short hexadecimal string (or multiple if that is the case) so my intuition tells me they use the same principle. But are they just memory addresses to flip a bit? Or lock it? Or XOR a series of bits with something? What is the code, and what does it do?


Question from user LoveAndCoding at gaming.stackexchange.com.


Answer:

How it works.


When GameShark (and other game enhancer products/homebrew) gets loaded by the console, the enhancer is what launches the actual game. In doing so, it leaves behind a Code Handler in the system RAM and "hooks" the game's programming.


Specific locations in a game's programming that get executed roughly every frame (like reading the controller data) are where "hooks" will be placed. (because SDKs are used, this makes finding hooks that work in all games for a system much easier).


What the hook actually does is redirect the flow of programming to the Code Handler the enhancer left behind. Once the Code Handler is finished executing, it returns the flow of programming back to the point of hijacking.


If you are familiar with GameShark's "Master Code", that is what sets the hook.


(other enhancers - like Gecko OS for Wii - don't need master codes because the enhancer itself has a handful of SDK-based hooks that it can "find" in the game while it loads.).


Structure of codes.


Now a code itself is separated into THREE parts:.


The CodeType (this is USUALLY the first byte of the code-- the first 2 Hex Characters). CodeTypes are specific to the enhancer.


The address in ram that the CodeType will use.


The value the codetype will use at the specified address.


The most common CodeTypes are:.


RAM Writes (typical options are 8bit, 16bit, or 32bit).


With RAM Write, the CodeHandler will take the value and place it at the address. (changing whatever was there, like setting your health to 100!).


Conditionals (typical options are >, <, =, !=).


With Conditionals, the CodeHander reads the value at the code's address and compares it to the value in the code. IF the comparison returns true, then the CodeHander will execute the next line in the code. (how many lines it executes is up to the enhancer and often is an option in the codetype itself!).


There is plenty more info we could dive into, but that should give you a good basis for understanding. =).


Source: Game hacker since 1999, founder of http://GeckoCodes.org.


Answer from user James0x57 at gaming.stackexchange.com.



[BACK]

In Fallout New Vegas, I failed Render Unto Caesar. How can I recover and do the quest anyway? In Fallout New Vegas, I failed Render Unto Caesar. How can I recover and do the quest anyway?

Posted On: February 17, 2023
Shortly after I got the Mark Of Caesar at New Vegas and was told I was forgiven and the legion wouldn't attack me any more, a bunch of legion assassins appeared and attacked me. I shrugged and tho...[More]


Is there a way to play the campaign only and avoid a large download in Call of Duty: Modern Warfare Remastered? Is there a way to play the campaign only and avoid a large download in Call of Duty: Modern Warfare Remastered?

Posted On: April 23, 2024
So, today I got Call of Duty: Modern Warfare Remastered 50% off to play the campaign. Upon buying it, I get two things in my Steam library: MWR MP and MWR. Now, I started with just the MWR one because...[More]


Frequency of the Golden Bowser Train? Frequency of the Golden Bowser Train?

Posted On: January 28, 2023
Does anyone happen to know how often you can go to the Golden Bowser Train? For those that don't yet know, it is a level with nothing but coins, and is a great way to bolster your extra lives.Questio...[More]


N++ System Requirements on Mac N++ System Requirements on Mac

Posted On: March 17, 2024
I'm looking at N++ (https://store.steampowered.com/app/230270/N_NPLUSPLUS/) and it doesn't list the system requirements for a mac.This question is not about whether my specific computer can run N++, b...[More]


Is there any use for crystallized charges after energy cells are maxed in Zelda? Is there any use for crystallized charges after energy cells are maxed in Zelda?

Posted On: June 23, 2023
I've been focusing on upgrading my energy cells so I can keep creating larger Zonai devices and have them active for longer. I've been exchanging Zonaite for crystallized charges, but have als...[More]


Are there any special rewards for completing Adventure Mode multiple times? Are there any special rewards for completing Adventure Mode multiple times?

Posted On: August 2, 2023
I recently completed Adventure Mode in Plants vs. Zombies for the iPhone. Are there any special rewards for completing it multiple times? I noticed that when I started Adventure Mode again I had to...[More]


How does a heavy build work? How does a heavy build work?

Posted On: April 10, 2024
The first time I started the game I picked Wretch. I knew nothing about the game. I quickly started collecting the heaviest equipment available, thinking it must be best. I started grinding the Godric...[More]


What do you use Luxury gemstones for in Slipways? What do you use Luxury gemstones for in Slipways?

Posted On: June 24, 2023
Starting a new game, I got a Gemstone Asteroids modifier. I quickly found the a gemstone asteroid and managed to mine it. But I can't figure out what they are good for? Question from user DJ...[More]


Why do my short beards look like crap? Why do my short beards look like crap?

Posted On: December 18, 2024
Question from user court_of_owlets at BaldursGate3 at reddit.com.Answer:Reminds me of Team America :D.https: - - preview.redd.it - 84km4prjqm7e1.png?width=639&format=png&auto=webp&s=547e79da13e6e37970...[More]


Whats the air intake parts air drag in Kerbal Space Program past 1.0? Whats the air intake parts air drag in Kerbal Space Program past 1.0?

Posted On: April 3, 2023
I've been considering increasing efficiency of my early launch stages by adding jet engines. I found an old thread discussing the idea, and one post struck me as "make-or-break" of my id...[More]