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]

Does every shrine in Tears of the Kingdom have a treasure chest? Does every shrine in Tears of the Kingdom have a treasure chest?

Posted On: May 14, 2023
Do all of the shrines in The Legend of Zelda: Tears of the Kingdom have at least one treasure chest? Question from user ahsteele at gaming.stackexchange.com. Answer: Yes. Tears of the Kingdom...[More]


Can I replay levels in Hi-Fi Rush? Can I replay levels in Hi-Fi Rush?

Posted On: February 19, 2023
I missed some collectables in a stage and want to go back to get them. Is there a way to replay a stage? Question from user Stevoisiak at gaming.stackexchange.com. Answer: Yes, you can replay...[More]


What's the most visually satisfying effect or ability? What's the most visually satisfying effect or ability?

Posted On: October 16, 2023
What abilities or effects are the most appealing visually for you? My top contenders divine smite and fireball. Smite especially when it's an unexpected smite on a crit. Not knowing it's co...[More]


Where does The Darkness II keeps its save files? Where does The Darkness II keeps its save files?

Posted On: May 11, 2023
Say I wanted to back up or delete my saves on the PC version (via Steam). Where are they located? Question from user a cat at gaming.stackexchange.com. Answer: Using X to represent the gam...[More]


How Did My Terraria Silver Pickaxe Got Damaged? How Did My Terraria Silver Pickaxe Got Damaged?

Posted On: May 12, 2023
I crafted my first silver pickaxe in Terraria 1.1. I did not examine its stats until some time later. The name color is grey with -14% damage. I have no problem mining with it but killing monsters ...[More]


Why dont I have permission to use WorldEdit? Why dont I have permission to use WorldEdit?

Posted On: February 13, 2023
I'm trying to install WorldEdit, and I've done the following:. Gotten the craftbukkit JAR, run it, stopped it, replaced world with my save from single, run again, stopped again, ...[More]


Can I increase the speed of combat in XCOM? Can I increase the speed of combat in XCOM?

Posted On: June 20, 2023
XCOM Enemy Unknown is a beautiful game, but you can only see every 5 second animation so many times before it becomes repetitive and self-indulgent. Is there a way to make the animations go faster or ...[More]


For Hogwarts Legacy Should I Use PS4 or Switch? For Hogwarts Legacy Should I Use PS4 or Switch?

Posted On: April 15, 2023
So I've been waiting for this game for ages, and I really want to play it. I have a PS4 and a Switch, and I was thinking of getting the Switch version once it comes out, because honestly it's ...[More]


Honkai Star Rail What is Effect Hit Rate? Honkai Star Rail What is Effect Hit Rate?

Posted On: May 15, 2023
Some relics have an 'Effect Hit Rate' stat. What effect is being referred to here and at what point is the hit/no-hit RNG evaluated? Question from user LT_ at gaming.stackexchange.com. A...[More]


Which is your favorite season at Hogwarts? Which is your favorite season at Hogwarts?

Posted On: September 19, 2023
Question from user gift_of_the-gab at HogwartsLegacyGaming at reddit. Answer: Late Summer - Autumn. Once it gets to Halloween it’s gone too far because it’s too themed. I feel lik...[More]