GameGenie Patching


  GameGenie was a device created by codemasters and galoob that let you make cheats for games. It was plugged in the console like a normal cartridge, and in its top the desired cartridge was plugged. These cheats are possible because what GameGenie do is edit the RAM that stores values used by the ROMs, setting these values to a constant that can be, for example, the number of lifes you have!

  Genecyst was the first Genesis emulator to have support for GameGenie then, with Kgen98, Steve Snake started to use this neat feature in his great emulator. No ROM image of a GameGenie is necessary, as some may imagine, to use them with console emulators, these programs themselves have a built-in feature that acts like a GameGenie, writing the codes in the emulated RAM.

  The GameGenie code consists of a eight-bytes long string, and the valid characters are A, B, C, D, E, F, G, H, J, K, L, M, N, P, R, S, T, V, W, X, Y, Z, 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9, all in uppercase. Each character have a binary repressentation, which is 5-bits long.

Char Value
A00000
B00001
C00010
D00011
E00100
F00101
G00110
H00111
J01000
K01001
L01010
Char Value
M01011
N01100
P01101
R01110
S01111
T10000
V10001
W10010
X10011
Y10100
Z10101
Char Value
010110
110111
211000
311001
411010
511011
611100
711101
811110
911111

  The cheat code should be firstly converted directly using the table above, and then the bits should be reordered. For example, the GameGenie code SCRA-BJX0 is translated to:

Code:
Bits:
Id:
SCRA
01111000100111000000
ijklmnopIJKLMNOPABCD
-
-
-
BJX0
00001010001001110110
EFGHdefghabcQRSTUVWX

  Then rearrange (using the id) as...

Bits:
Id:
000000001001110001110110
ABCDEFGHIJKLMNOPQRSTUVWX
:
:
01010100 01111000
abcdefghijklmnop

  Which give us, in hexa, 009C76:5478. This means that H5478 will be written at H009C76 memory offset.