News: 11 March 2016 - Forum Rules
Current Moderators - DarkSol, KingMike, MathOnNapkins, Azkadellia, Danke

Author Topic: How to convert Game Genie, PAR, Pro Action Replay, to C++ byte array  (Read 3798 times)

Daniel_F

  • Jr. Member
  • **
  • Posts: 6
    • View Profile
Hi, friends! greetings!

I tried to research, but, I think because of my English which is not efficient, I didn't get a return that would help me.

  I'm trying to research something. I'm a 40 year old man, finishing college in computing and I want to try to do a project.


   First of all, I apologize if my question seems stupid, or if I was too lazy to research. I am a limited person and I'm still trying to understand some issues in computing.
 
    Would any programmer know how to convert a Game Genie code, or Pro Action Replay, or PAR, to a byte array (with raw hex codes) in C ++?

    For example:

Super Mario World.
Starting with 99 lives, the Game Genie code is: 14B4-6F07

How would it look in C ++?
byte codeSMW []: {?????????? };

    Thank you all.


KingMike

  • Forum Moderator
  • Hero Member
  • *****
  • Posts: 7037
  • *sigh* A changed avatar. Big deal.
    • View Profile
Re: How to convert Game Genie, PAR, Pro Action Replay, to C++ byte array
« Reply #1 on: September 05, 2020, 10:19:29 am »
Game Genie codes are encrypted.
Information on decoding them is easily found by Google.

But once decoded, they decode to simple one byte address/data pair, where the data byte replaces the original value at the specified address.
(That is true for SNES. Genesis will decode to a two-byte value, but is otherwise the same.
NES/GB/GG will additionally contain a "compare" value. The data will only be replaced if the original data being replaced matches the compare value. That is because on those consoles, most games will utilize ROM banking, and the CPU itself cannot tell the difference between the 16 or more possible effective ROM addresses that could be affected.
"My watch says 30 chickens" Google, 2018


FAST6191

  • Hero Member
  • *****
  • Posts: 2962
    • View Profile
Re: How to convert Game Genie, PAR, Pro Action Replay, to C++ byte array
« Reply #3 on: September 05, 2020, 11:03:57 am »
+1 to the others thus far. After decryption then destination, check for those systems where different data might be there, and the payload for the thing you want. Sticking various things in an array should then be a matter of expanding them out (shifts, blanking/boolean fun) and giving each aspect their own thing within it. In most cases it should be a few set lengths (if not just one) so that is nice. Whether you condense addresses listed one after the other (I did not check to see if anything in the game genie world has a slide code option either) then being up to you but I would probably skip that one unless you have a good reason to do it.

If we are sharing links though

https://gamehacking.org/wiki/EnHacklopedia
https://gamehacking.org/wiki/Hacking_NES#Game_Genie
https://gamehacking.org/wiki/Hacking_SNES#Game_Genie
https://gamehacking.org/wiki/Hacking_Genesis
https://gamehacking.org/wiki/Hacking_Game_Boy#Game_Genie
... I can't be bothered to go through the whole of EnHacklopedia pulling specific links so hopefully you get the idea.
http://problemkaputt.de/gbatek.htm#gbacheatdevices
http://problemkaputt.de/psx-spx.htm#cheatdevices
http://problemkaputt.de/ 's emulators usually have reference grade hardware docs, which will usually include at least a bit on the all the weird and wonderful peripherals available and this includes cheat devices.


Do note the game genie name got sold off at points so while for most of the 8-16 bit stuff it did mean ROM patching codes then later it might have been save, RAM or something else entirely. Equally some later devices dropped binaries in RAM so you can more readily port codes across there, and while most ROM codes on later devices (think GBA) were limited to one or two codes to bypass anti piracy, hook things or otherwise get things in place then there are still options for it.

Depending upon what you are doing there are some hardpatching tools for GG codes on older systems. CCCGP, Game Genie Code Patcher, Game Genie Guy... I am not sure if any are open source offhand (or can be easily decompiled -- I think CCCGP was done in visual basic so tends to have something).

slidelljohn

  • Sr. Member
  • ****
  • Posts: 326
    • View Profile
Re: How to convert Game Genie, PAR, Pro Action Replay, to C++ byte array
« Reply #4 on: September 05, 2020, 11:18:41 am »
Convert game genie to hex decoder.

GG   HEX
--   ---
D    0h
F    1h
4    2h
7    3h 
0    4h 
9    5h 
1    6h 
5    7h   
6    8h   
B    9h 
C    Ah   
8    Bh
A    Ch
2    Dh 
3    Eh   
E    Fh     

14B4-6F07 turns into 6292-8143

remove 62

turns into 928143

convert 928143 to binary

Code: [Select]
10010010 10000001 01000011
ijklqrst opabcduv wxefghmn

switch binary around to this pattern

Code: [Select]
00000000 10011110 00100101
abcdefgh ijklmnop qrstuvwx

convert to hex

009e25
That is your address in rom.



62 = 98 in decimal

Change 04(5 lives) to (62) 99 lives

Exact details are in those pages 11 and 12

Lol my 1st time learning this :woot!:

@Daniel_F
Hope you stick around and share your c++ code after you create it.
« Last Edit: September 05, 2020, 12:05:46 pm by slidelljohn »

Daniel_F

  • Jr. Member
  • **
  • Posts: 6
    • View Profile
Re: How to convert Game Genie, PAR, Pro Action Replay, to C++ byte array
« Reply #5 on: September 05, 2020, 03:04:58 pm »
Convert game genie to hex decoder.

GG   HEX
--   ---
D    0h
F    1h
4    2h
7    3h 
0    4h 
9    5h 
1    6h 
5    7h   
6    8h   
B    9h 
C    Ah   
8    Bh
A    Ch
2    Dh 
3    Eh   
E    Fh     
[...]

Your help was amazing! the table at the beginning, plus the example given, helped me a lot.

    I visited the suggested pages. The content is excellent!

Dear Sir. SlidellJohn, I'm trying to create a "Cheater" with an Arduino, so that I can send these bytes through the data input on the super nintendo controller.

  However, I realized that it is not that simple.

It will be a very complicated research for a person not very developed as I am.

    The data pin on the SNES console appears to be in a low state. The Arduino serial port seems to be high. My goal is to use the TX output of the Arduino, to transmit the bytes through the controller data port.

       I think my idea is kind of meaningless.

Daniel_F

  • Jr. Member
  • **
  • Posts: 6
    • View Profile
Re: How to convert Game Genie, PAR, Pro Action Replay, to C++ byte array
« Reply #6 on: September 05, 2020, 03:41:59 pm »
+1 to the others thus far. After decryption then destination, check for those systems where different data might be there, and the payload for the thing you want. Sticking various things in an array should then be a matter of expanding them out (shifts, blanking/boolean fun) and giving each aspect their own thing within it. In most cases it should be a few set lengths (if not just one) so that is nice. Whether you condense addresses listed one after the other (I did not check to see if anything in the game genie world has a slide code option either) then being up to you but I would probably skip that one unless you have a good reason to do it.

If we are sharing links though

https://gamehacking.org/wiki/EnHacklopedia
https://gamehacking.org/wiki/Hacking_NES#Game_Genie
https://gamehacking.org/wiki/Hacking_SNES#Game_Genie
https://gamehacking.org/wiki/Hacking_Genesis
https://gamehacking.org/wiki/Hacking_Game_Boy#Game_Genie
... I can't be bothered to go through the whole of EnHacklopedia pulling specific links so hopefully you get the idea.
http://problemkaputt.de/gbatek.htm#gbacheatdevices
http://problemkaputt.de/psx-spx.htm#cheatdevices
http://problemkaputt.de/ 's emulators usually have reference grade hardware docs, which will usually include at least a bit on the all the weird and wonderful peripherals available and this includes cheat devices[...]

thank you, Sir. I really appreciate this content.

Cyneprepou4uk

  • Hero Member
  • *****
  • Posts: 530
  • I am the baldest romhacker
    • View Profile
Re: How to convert Game Genie, PAR, Pro Action Replay, to C++ byte array
« Reply #7 on: September 06, 2020, 07:12:08 am »
FCEUX emulator is written in C++ and has GG encode/decode tool in it. I think its code is here
https://github.com/TASVideos/fceux/blob/master/src/drivers/win/cheat.cpp
iromhacker.ru - NES ROM hacking tutorials for beginners. Please use Google Translate browser extension

slidelljohn

  • Sr. Member
  • ****
  • Posts: 326
    • View Profile
Re: How to convert Game Genie, PAR, Pro Action Replay, to C++ byte array
« Reply #8 on: September 06, 2020, 08:09:37 am »
Your help was amazing! the table at the beginning, plus the example given, helped me a lot.

    I visited the suggested pages. The content is excellent!

Dear Sir. SlidellJohn, I'm trying to create a "Cheater" with an Arduino, so that I can send these bytes through the data input on the super nintendo controller.

  However, I realized that it is not that simple.

It will be a very complicated research for a person not very developed as I am.

    The data pin on the SNES console appears to be in a low state. The Arduino serial port seems to be high. My goal is to use the TX output of the Arduino, to transmit the bytes through the controller data port.

       I think my idea is kind of meaningless.
Glad I could help!

Sorry my friend but unfortunately I don't have much knowledge on the hardware so I don't
think I will be able to help with that. It does sound interesting and hopefully you figure
out a way to do what you are trying to do.

Daniel_F

  • Jr. Member
  • **
  • Posts: 6
    • View Profile
Re: How to convert Game Genie, PAR, Pro Action Replay, to C++ byte array
« Reply #9 on: September 06, 2020, 10:47:19 pm »
FCEUX emulator is written in C++ and has GG encode/decode tool in it. I think its code is here
https://github.com/TASVideos/fceux/blob/master/src/drivers/win/cheat.cpp
It's a great emulator.  And really great decode tool.  Thank you very much, Sir.   

FAST6191

  • Hero Member
  • *****
  • Posts: 2962
    • View Profile
Re: How to convert Game Genie, PAR, Pro Action Replay, to C++ byte array
« Reply #10 on: September 07, 2020, 09:12:30 am »
Your help was amazing! the table at the beginning, plus the example given, helped me a lot.

    I visited the suggested pages. The content is excellent!

Dear Sir. SlidellJohn, I'm trying to create a "Cheater" with an Arduino, so that I can send these bytes through the data input on the super nintendo controller.

  However, I realized that it is not that simple.

It will be a very complicated research for a person not very developed as I am.

    The data pin on the SNES console appears to be in a low state. The Arduino serial port seems to be high. My goal is to use the TX output of the Arduino, to transmit the bytes through the controller data port.

       I think my idea is kind of meaningless.

Can you send such things through a controller in the first place?
Most controllers are just packets of data (assuming they are serial, parallel options tending to have many wires to many pins conveying a simple state which is even worse) and do little more than that. Some later ones might have memory card slots or USB built in but that is not the SNES.

You then have two options there from what I see

1) I am sure most here have seen the things where through a series of several hundred very specific button presses and inventory/scoreboard/some user data manipulation cause a crash and play a little demo.
https://www.youtube.com/watch?v=p5T81yHkHtI for an example.
That is very game specific and I am not sure all games are even likely to be amenable to it. If you have a particular game in mind though then that is fair enough.


2) This is basically a way to not have to press up and down several hundred times on a hardware cheat device to input a series of user codes, possibly before realising you typed one in wrong and because 16 bit era UI you then get to redo a whole bunch of things to put it right.

As for high and low (or positive edge/negative edge switching) inputs I have not checked to see what goes here but will assume it is the case.
a) You can set arduinos to do other things if memory serves.
b) A logic inverter aka NOT gate is arguably the most basic component in digital electronics and while everything is transistors in the end then building one from transistors is a common test question for schoolboy electronics exams if you did decide a NOT gate (or more likely an array on a chip with a few dozen of the things, useful if you have multiple buttons to handle) was not a viable thing to add to your build) https://reviseomatic.org/help/s-advanced-logic/Logic%20Gate%20Arrays.php

Edit.
Or do you mean you want to have an arduino act as a game genie itself (don't know if it is an option here as the arduinos are usually pretty slow to the point where I might worry about signals taking too long to come back from the cart and into the SNES again) but I suppose we have seen dumpers so maybe, and also adapt a controller or something to take codes? I would ask why though if the arduino itself could just have a USB out or something on it and take a new sketch with all the codes you might want in there.


KingMike

  • Forum Moderator
  • Hero Member
  • *****
  • Posts: 7037
  • *sigh* A changed avatar. Big deal.
    • View Profile
Re: How to convert Game Genie, PAR, Pro Action Replay, to C++ byte array
« Reply #11 on: September 07, 2020, 09:36:10 am »
Do note the game genie name got sold off at points so while for most of the 8-16 bit stuff it did mean ROM patching codes then later it might have been save, RAM or something else entirely. Equally some later devices dropped binaries in RAM so you can more readily port codes across there, and while most ROM codes on later devices (think GBA) were limited to one or two codes to bypass anti piracy, hook things or otherwise get things in place then there are still options for it.
I don't think Game Genie was sold, I think it just died when the US distributor, toy company Galoob, got bought out by Hasbro and they didn't really care to do anything with it. (though developed by UK company CodeMasters, I can't recall hearing if they released it in Europe. I imagine yes, though if it was, I'm surprised there doesn't seem to have a SMS version of the GG. The market would've still be high enough there for one. Not so in the US, especially after Nintendo delayed its release with a lawsuit.)
Now, the other device Action Replay got sold under different names.
"My watch says 30 chickens" Google, 2018

slidelljohn

  • Sr. Member
  • ****
  • Posts: 326
    • View Profile
Re: How to convert Game Genie, PAR, Pro Action Replay, to C++ byte array
« Reply #12 on: September 07, 2020, 09:46:44 am »
Can you send such things through a controller in the first place?

Possibly:
https://forums.bannister.org/ubbthreads.php?ubb=showflat&Number=77760&page=all&PHPSESSID=e4cf52657bca866089eaeb930a3c038b

I have no idea how he did it but its very impressive.

With the knowledge of near(byuu), the knowledge of I believe it was Cydrak but I'm not sure, and the help from
qwertymodo I was able to create my super v-power modchip for the snes. Their knowledge on the snes was very
helpful. I actually have a newer and better design for the modchip that I would like to finish building sometime
in the beginning of next year.

For those who don't know or have forgot about it here is the last design of my modchip:
« Last Edit: September 07, 2020, 10:47:42 am by slidelljohn »

Raeven0

  • Jr. Member
  • **
  • Posts: 35
    • View Profile
Re: How to convert Game Genie, PAR, Pro Action Replay, to C++ byte array
« Reply #13 on: September 07, 2020, 11:01:12 am »
Possibly:
https://forums.bannister.org/ubbthreads.php?ubb=showflat&Number=77760&page=all&PHPSESSID=e4cf52657bca866089eaeb930a3c038b
I have no idea how he did it but its very impressive.
The SNES controller port has two write-only, two read-only, and one RW line, each 1 bit wide, which are memory-mapped and always live. The controller can write whatever it wants, and the active ROM can interpret those inputs however it wants.

I don't know how this is useful without a custom ROM (or an ACE exploit), though.

slidelljohn

  • Sr. Member
  • ****
  • Posts: 326
    • View Profile
Re: How to convert Game Genie, PAR, Pro Action Replay, to C++ byte array
« Reply #14 on: September 07, 2020, 11:47:24 am »
I don't know how this is useful without a custom ROM (or an ACE exploit), though.
Could the custom rom be in between the cart and the console like a game genie?

September 07, 2020, 04:09:56 pm - (Auto Merged - Double Posts are not allowed before 7 days.)
Am I the only one that noticed what just happened?
Seems like a bot was all in this page with those reads jump then stop so quick. Very strange  :o
« Last Edit: September 07, 2020, 04:09:56 pm by slidelljohn »

Daniel_F

  • Jr. Member
  • **
  • Posts: 6
    • View Profile
Re: How to convert Game Genie, PAR, Pro Action Replay, to C++ byte array
« Reply #15 on: September 07, 2020, 02:41:39 pm »
Can you send such things through a controller in the first place?
Most controllers are just packets of data (assuming they are serial, parallel options tending to have many wires to many pins conveying a simple state which is even worse) and do little more than that. Some later ones might have memory card slots or USB built in but that is not the SNES.

You then have two options there from what I see

1) I am sure most here have seen the things where through a series of several hundred very specific button presses and inventory/scoreboard/some user data manipulation cause a crash and play a little demo.
https://www.youtube.com/watch?v=p5T81yHkHtI for an example.
That is very game specific and I am not sure all games are even likely to be amenable to it. If you have a particular game in mind though then that is fair enough.
[...]

Sir @FAST6191  I want to thank you. Your notes led me to an important analysis.

  In my not very smart mind, I deduced the following: unlike the communication protocol of Sega's consoles, the Super Nintendo and Nes, send the controller bytes directly over a data channel to the processor. It is not like, for example, the Sega Master System, which needs a tiny dead-short on each pin of the controller connector and each pin, when in High or Low state, sends a predetermined byte to the processor. I thought that the NES or Super Nintendo data port could communicate more directly with the processor. But I realize that I am completely wrong.

    Since creating this topic, I have made an Arduino connection to SNES. I made a tiny Sketch using Processing and tested it on my Super Mario World. Reading the bits surprised me. I sent bytes like 0x9D and nothing unusual happened. These bytes, just sent commands like Jump and Pause simultaneously.

   The complexity of this subject is incredible. Writing data in the memory addresses of a video game is a very complex task. I am not ready for a project of this size. Another graduation may be necessary.

     You helped me a lot.

Daniel_F

  • Jr. Member
  • **
  • Posts: 6
    • View Profile
Re: How to convert Game Genie, PAR, Pro Action Replay, to C++ byte array
« Reply #16 on: September 07, 2020, 02:48:08 pm »
Possibly:
https://forums.bannister.org/ubbthreads.php?ubb=showflat&Number=77760&page=all&PHPSESSID=e4cf52657bca866089eaeb930a3c038b

I have no idea how he did it but its very impressive.

With the knowledge of near(byuu), the knowledge of I believe it was Cydrak but I'm not sure, and the help from
qwertymodo I was able to create my super v-power modchip for the snes. Their knowledge on the snes was very
helpful. I actually have a newer and better design for the modchip that I would like to finish building sometime
in the beginning of next year. [...]

Sir @slidelljohn. Thank you for posting information about this project, the ST-0018. It is something very incredible. I was interested in your Modchip project. I hope I can see the final modification you intend to make.

FAST6191

  • Hero Member
  • *****
  • Posts: 2962
    • View Profile
Re: How to convert Game Genie, PAR, Pro Action Replay, to C++ byte array
« Reply #17 on: September 08, 2020, 09:52:45 am »
I don't think Game Genie was sold, I think it just died when the US distributor, toy company Galoob, got bought out by Hasbro and they didn't really care to do anything with it. (though developed by UK company CodeMasters, I can't recall hearing if they released it in Europe. I imagine yes, though if it was, I'm surprised there doesn't seem to have a SMS version of the GG. The market would've still be high enough there for one. Not so in the US, especially after Nintendo delayed its release with a lawsuit.)
Now, the other device Action Replay got sold under different names.
There were things later, and today things calling themselves game genie as well.  https://www.gamerevolution.com/review/351109-game-genie-review-bringing-modern-controller-xbox-one-ps4-switch
http://thegamegenie.com/nintendo-ds/
Certainly the other brands had a far more storied history in the times post 16 bit era but game genie, official or otherwise, was not static either.

Equally it was not really Nintendo that delayed it -- Galoob filed for a declaratory judgement before release. Granted one could quite justifiably say given how well known Nintendo's heavy handedness in such matters was that it made that a smart move despite similar things existing on far older devices (such a mindset persists to this day https://www.gdcvault.com/play/1023470/-It-s-Just-Emulation , and might as well have the follow up while linking things https://www.gdcvault.com/play/1025782/It-s-Still-Emulation-Saving ).

Could the custom rom be in between the cart and the console like a game genie?

September 07, 2020, 04:09:56 pm - (Auto Merged - Double Posts are not allowed before 7 days.)
Am I the only one that noticed what just happened?
Seems like a bot was all in this page with those reads jump then stop so quick. Very strange  :o
I don't know if views are updated in real time. Quite often forum software, blogs and the like will run an update once every hour or so and adjust numbers accordingly rather than hammering the server all the time for what is not so fundamental aspects of forum running (replies matter, PMs matter, up to the millisecond view counts less so).

As far as custom rom being between the cart and console... yeah you are basically recreating a flash cart there, one with a ROM dumper attached. Some of the region adapters for the N64 did something maybe kind of like that (took mine apart once and it had a very fast, for the time at least, CPLD I think it was and presumably read the correct CIC from the donor cart on the back and then put it to the front). That are you are recreating the game genie concept which is almost a proto flash cart (indeed I might even make one in the modern world where it dumps the ROM to a RAM chip, not like SNES games are huge in size relative to modern RAM chips, and operate everything from there if I was going to make such a device today).

I could see some programmable chip being able to intercept all data reads, determine if one is in the proper range and then returning that particular mod for that particular read, otherwise passing all commands through as per usual. Whether an arduino in basic sketches would be it I am rather more dubious about -- the delays as it calculates things in basic sketches make all sorts of trouble even for LED displays that humans watch, doing that for something as quick fire and latency sensitive as cart reads... I am wary.


As far as writing memory to games. That is basic cheat making really and while the extremes get quite far advanced it is otherwise generally many people's first real introduction to ROM hacking related subjects as far as doing them (many will encounter trainers, translations and whatnot but that is using rather than doing). For things like the DS where the binary is loaded into RAM, as are files in general but that gets more tricky, you can alter the binary and do things as potent as a game genie in classical times*. Doing that from a controller would be a real feat but the general principle is nothing too drastic.

*more for others reading along at home. Action replay/gameshark/goldfinger/codebreaker/... are generally variations on the theme of RAM cheats. Good for making infinite items, adding things to inventories and such things that fall directly from data in RAM. Game genies in classical sense however alter what the ROM appears as. This can then alter fundamental aspects of how the game works (you don't just have infinite lives, you don't even react to being hit sort of thing). They are however far harder to make hence there being fewer of them out in the world. Being alterations to the ROM they are also more easily patched in directly where RAM codes are harder and tend to be reserved for individual hacks by skilled people or later devices that are either simpler or have more space and ability to have code added in (GBA and DS having such things, though the N64 kind of has something now).

KingMike

  • Forum Moderator
  • Hero Member
  • *****
  • Posts: 7037
  • *sigh* A changed avatar. Big deal.
    • View Profile
Re: How to convert Game Genie, PAR, Pro Action Replay, to C++ byte array
« Reply #18 on: September 11, 2020, 10:13:57 am »
What was funny is that reportedly Codemasters themselves had to use their Game Genie tech to hard-patch a fix for a single bit programming error in Micro Machines for the NES, after they already had the final ROMs produced and didn't want the costly expensive of ordering a corrected reprint.

Although that sounds a little similar to when Capcom probably learned its lesson about how SNES mirroring works after they had to had to bodge-wire probably thousands of retail Rockman X (1.0) carts to make its copy-protection work how it was intended to (I'm guessing it was something different between development and consumer PCBs.)
But not quite the same as the Codemasters issue was an exact coding hotfix whereas Capcom needed to fix a certain memory region.
Though MMX antipiracy sounds complicated enough I'm not exactly sure which versions that affected.
"My watch says 30 chickens" Google, 2018

Anime_World

  • RHDN Patreon Supporter!
  • Jr. Member
  • *****
  • Posts: 32
    • View Profile