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]

Whats the software used in Megaman X speedruns? Whats the software used in Megaman X speedruns?

Posted On: March 1, 2024
I'm starting out with my personal journey toward a 100% speedrun of Megaman X and I noticed that pretty much every speedrunner on YouTube are using a software that keeps track of time for each level: ...[More]


Where can I farm hearty fruits or other food that gives yellow hearts in Breath of the Wild? Where can I farm hearty fruits or other food that gives yellow hearts in Breath of the Wild?

Posted On: April 4, 2023
My basic approach to hard battles etc. is to stock up on meals that add extra heart containers (and to close my eyes at the scary parts). Up until recently, I've had a solid back stock of Duria...[More]


Wii controllers keep losing connection. What can I do? Wii controllers keep losing connection. What can I do?

Posted On: January 15, 2024
I have a Wii and two controllers. In the last few months the controllers lose the connection to the Wii rather often. It's bad enough that we cannot play Mario Kart any more (because one player ge...[More]


Is Abdel Adrian just book canon or is he also canon to BG3? Is Abdel Adrian just book canon or is he also canon to BG3?

Posted On: July 31, 2025
I was going to play BG3 after I finished another game that’s taking up most of the storage on my SSD but I reached a slow point in that game so I was thinking of trying BG1 and BG2 first.So I saw th...[More]


I have just discovered the devs gave Scratch his own tent I have just discovered the devs gave Scratch his own tent

Posted On: April 28, 2024
Question from user SmartTransformingAce at BaldursGate3 at reddit.com.Answer:I have well over 1000 hours in this game - and have only just discovered this.Answer from user SmartTransformingAce at Bald...[More]


Will they add romance to Hogwarts legacy? Will they add romance to Hogwarts legacy?

Posted On: July 22, 2023
The material is there, quest lines and body movements and such but they never actually do date. It is weird how they’re like 16-17 and NOT romancing. Plus it’s clear Poppy has a thing for ...[More]


Combat Spells in Hogwarts Legacy Combat Spells in Hogwarts Legacy

Posted On: July 26, 2023
What are everyone's favourite combat spells and what do you all group with each other? . I have bombarda, glacius, diffindo, flipendo as my 1st 4. . Expelliarmus and the 3 unforgivable curse...[More]


Does Fallout 4 have a color filter like Fallout 3 and Fallout: New Vegas? Does Fallout 4 have a color filter like Fallout 3 and Fallout: New Vegas?

Posted On: April 22, 2024
Previous 3D Fallout games, Fallout 3 (green) and Fallout: New Vegas (orange), both have a color filter (filter enabled on the left, disabled on the right):.Fallout 3:.New Vegas:.By looking at Fallout ...[More]


Why Do All the Allies Disapprove of Helping Yugir Why Do All the Allies Disapprove of Helping Yugir

Posted On: November 15, 2023
I'm not sure why almost all of my allies disapprove whenever I choose to help Yugir. I feel like this is a morally right choice, so why does Will and Shadowheart disapprove? Question from user ...[More]


No reward for vault entrance completion in Hogwarts Legacy? No reward for vault entrance completion in Hogwarts Legacy?

Posted On: July 11, 2023
Some of those puzzles were somewhat difficult, I feel like you should get XP for completion and not just janky gear.  Question from user Pandy_45 at HogwartsLegacyGaming at reddit. Answer: ...[More]