I wanted to start doing simplified tutorials for Game Genie to hex conversions. A mixture of GGCCC and Lazy Bastard's guides:
http://www.videogamesource.com/genie...andbk/p12.html
http://gamehacking.org/library/114
=================================================
NES 6 Characters
Code - SXIOPO
Run each character through this cipher:
A = 0000
P = 0001
Z = 0010
L = 0011
G = 0100
I = 0101
T = 0110
Y = 0111
E = 1000
O = 1001
X = 1010
U = 1011
K = 1100
S = 1101
V = 1110
N = 1111
Transposed - 110110100101100100011001
Rearrange the characters using this pattern:
9, 14-17, 22-24, 5, 10-13, 18-20, 1, 6-8, 21, 2-4
Was: 110110100101100100011001
Now: 000100011101100110101101
Take 1-16 and convert to hex for the address:
0001000111011001
11D9
Take 17-24 for the replace value:
10101101
AD
If the file size divided by 1024 has a remainder then add 10 for the header
If the file is bigger than 48 KB then repeat the patch every 2000
=================================================
NES 8 Characters
Code - SKSOPOVK
Run each character through this cipher:
A = 0000
P = 0001
Z = 0010
L = 0011
G = 0100
I = 0101
T = 0110
Y = 0111
E = 1000
O = 1001
X = 1010
U = 1011
K = 1100
S = 1101
V = 1110
N = 1111
Transposed - 11011100110110010001100111101100
Rearrange the characters using this pattern:
9, 14-17, 22-24, 5, 10-13, 18-20, 1, 6-8, 29, 2-4, 25, 30-32, 21, 26-28
Was: 11011100110110010001100111101100
Now: 10010001110110011100110111001110
Take 1-16 and convert to hex for the address:
1001000111011001
91D9
Take 17-24 for the compare value:
11001101
CD
Take 25-32 for the replace value:
11001110
CE
If the file size divided by 1024 has a remainder then add 10 for the header
If the file is smaller than 48 KB then subtract 4000
This allows smaller games like Excite Bike to work
If the file is larger than 48 KB then subtract C000
This allows codes for SMB3 to Zelda to seek earlier in the rom
Seek through the rom in intervals of 2000
When you find the compare value replace it
=================================================
SNES
Code - C9CF-CFBF
Run each character through this cipher:
D = 0
F = 1
4 = 2
7 = 3
0 = 4
9 = 5
1 = 6
5 = 7
6 = 8
B = 9
C = A
8 = B
A = C
2 = D
3 = E
E = F
Transposed - A5A1A191
The replace value is the first two characters (A5)
Make a binary number of what's left (A1A191)
101000011010000110010001
Rearrange the characters using this pattern:
11-14, 19-22, 1-4, 23-24, 9-10, 5-8, 15-18
Was: 101000011010000110010001
Now: 100001001010011000010110
Convert back to hex for the cpu address:
84A616
With replace value - 84A616:A5
If the file size divided by 1024 has a remainder then add 200 for the header
We now convert the cpu address to a rom address to know where to patch
Check for HiROM/LoROM rom in header:
Seek in the rom to FFD5 (101D5 if headered)
If the value is 21 or 31 then it's a HiROM
Otherwise we'll assume LoROM (most are)
For LoROM we take our binary value and shift bits again: (HiROM skips this)
0 + first 8 characters of binary + last 15 characters of binary
Was: 100001001010011000010110
Now: 010000100010011000010110
Converted back to hex:
422616
Run the address through this lovely uCON64 math to find the solution:
If the address is >= 400000 and <= 7FFFFF then subtract 400000
If the address is >= 800000 and <= BFFFFF then subtract 800000
If the address is >= C00000 and <= FFFFFF then subtract C00000
422616 - 400000 = 22616
Final address with replace value 22616:A5
=================================================
Genesis/Mega Drive
Code - GJ6A-CA7A
Run each character through this cipher:
A = 00000
B = 00001
C = 00010
D = 00011
E = 00100
F = 00101
G = 00110
H = 00111
J = 01000
K = 01001
L = 01010
M = 01011
N = 01100
P = 01101
R = 01110
S = 01111
T = 10000
V = 10001
W = 10010
X = 10011
Y = 10100
Z = 10101
0 = 10110
1 = 10111
2 = 11000
3 = 11001
4 = 11010
5 = 11011
6 = 11100
7 = 11101
8 = 11110
9 = 11111
Transposed - 0011001000111000000000010000001110100000
Rearrange the characters using this pattern:
17-24, 9-16, 33-40, 30-32, 25-29, 1-8
Was: 0011001000111000000000010000001110100000
Now: 0000000100111000101000000110000000110010
Take 1-24 and convert to hex for the address:
000000010011100010100000
138A0
Take 25-40 for the two replace values:
0110000000110010
6032
1-2 are is the first value and 3-4 is the second
At 138A0 write 60
At 138A1 write 32
=================================================
GB 6 Characters
Code - 21C-53E
The address is character 6 XOR with F, 3-5:
1C53
The replace value is 1-2:
21
=================================================
GB 9 Characters
Code - 18A-B1E-2AA
The address is character 6 XOR with F, 3-5:
1AB1
The replace value is 1-2:
18
For the compare value take 7, 9 (drop 8):
2A
Convert to binary:
101010
Left pad it to 8 characters:
00101010
Rearrange as 7-8, 1-6:
10001010
XOR with BA for the compare value:
30
Seek through the rom in intervals of 2000
When you find the compare value replace it
http://www.videogamesource.com/genie...andbk/p12.html
http://gamehacking.org/library/114
=================================================
NES 6 Characters
Code - SXIOPO
Run each character through this cipher:
A = 0000
P = 0001
Z = 0010
L = 0011
G = 0100
I = 0101
T = 0110
Y = 0111
E = 1000
O = 1001
X = 1010
U = 1011
K = 1100
S = 1101
V = 1110
N = 1111
Transposed - 110110100101100100011001
Rearrange the characters using this pattern:
9, 14-17, 22-24, 5, 10-13, 18-20, 1, 6-8, 21, 2-4
Was: 110110100101100100011001
Now: 000100011101100110101101
Take 1-16 and convert to hex for the address:
0001000111011001
11D9
Take 17-24 for the replace value:
10101101
AD
If the file size divided by 1024 has a remainder then add 10 for the header
If the file is bigger than 48 KB then repeat the patch every 2000
=================================================
NES 8 Characters
Code - SKSOPOVK
Run each character through this cipher:
A = 0000
P = 0001
Z = 0010
L = 0011
G = 0100
I = 0101
T = 0110
Y = 0111
E = 1000
O = 1001
X = 1010
U = 1011
K = 1100
S = 1101
V = 1110
N = 1111
Transposed - 11011100110110010001100111101100
Rearrange the characters using this pattern:
9, 14-17, 22-24, 5, 10-13, 18-20, 1, 6-8, 29, 2-4, 25, 30-32, 21, 26-28
Was: 11011100110110010001100111101100
Now: 10010001110110011100110111001110
Take 1-16 and convert to hex for the address:
1001000111011001
91D9
Take 17-24 for the compare value:
11001101
CD
Take 25-32 for the replace value:
11001110
CE
If the file size divided by 1024 has a remainder then add 10 for the header
If the file is smaller than 48 KB then subtract 4000
This allows smaller games like Excite Bike to work
If the file is larger than 48 KB then subtract C000
This allows codes for SMB3 to Zelda to seek earlier in the rom
Seek through the rom in intervals of 2000
When you find the compare value replace it
=================================================
SNES
Code - C9CF-CFBF
Run each character through this cipher:
D = 0
F = 1
4 = 2
7 = 3
0 = 4
9 = 5
1 = 6
5 = 7
6 = 8
B = 9
C = A
8 = B
A = C
2 = D
3 = E
E = F
Transposed - A5A1A191
The replace value is the first two characters (A5)
Make a binary number of what's left (A1A191)
101000011010000110010001
Rearrange the characters using this pattern:
11-14, 19-22, 1-4, 23-24, 9-10, 5-8, 15-18
Was: 101000011010000110010001
Now: 100001001010011000010110
Convert back to hex for the cpu address:
84A616
With replace value - 84A616:A5
If the file size divided by 1024 has a remainder then add 200 for the header
We now convert the cpu address to a rom address to know where to patch
Check for HiROM/LoROM rom in header:
Seek in the rom to FFD5 (101D5 if headered)
If the value is 21 or 31 then it's a HiROM
Otherwise we'll assume LoROM (most are)
For LoROM we take our binary value and shift bits again: (HiROM skips this)
0 + first 8 characters of binary + last 15 characters of binary
Was: 100001001010011000010110
Now: 010000100010011000010110
Converted back to hex:
422616
Run the address through this lovely uCON64 math to find the solution:
If the address is >= 400000 and <= 7FFFFF then subtract 400000
If the address is >= 800000 and <= BFFFFF then subtract 800000
If the address is >= C00000 and <= FFFFFF then subtract C00000
422616 - 400000 = 22616
Final address with replace value 22616:A5
=================================================
Genesis/Mega Drive
Code - GJ6A-CA7A
Run each character through this cipher:
A = 00000
B = 00001
C = 00010
D = 00011
E = 00100
F = 00101
G = 00110
H = 00111
J = 01000
K = 01001
L = 01010
M = 01011
N = 01100
P = 01101
R = 01110
S = 01111
T = 10000
V = 10001
W = 10010
X = 10011
Y = 10100
Z = 10101
0 = 10110
1 = 10111
2 = 11000
3 = 11001
4 = 11010
5 = 11011
6 = 11100
7 = 11101
8 = 11110
9 = 11111
Transposed - 0011001000111000000000010000001110100000
Rearrange the characters using this pattern:
17-24, 9-16, 33-40, 30-32, 25-29, 1-8
Was: 0011001000111000000000010000001110100000
Now: 0000000100111000101000000110000000110010
Take 1-24 and convert to hex for the address:
000000010011100010100000
138A0
Take 25-40 for the two replace values:
0110000000110010
6032
1-2 are is the first value and 3-4 is the second
At 138A0 write 60
At 138A1 write 32
=================================================
GB 6 Characters
Code - 21C-53E
The address is character 6 XOR with F, 3-5:
1C53
The replace value is 1-2:
21
=================================================
GB 9 Characters
Code - 18A-B1E-2AA
The address is character 6 XOR with F, 3-5:
1AB1
The replace value is 1-2:
18
For the compare value take 7, 9 (drop 8):
2A
Convert to binary:
101010
Left pad it to 8 characters:
00101010
Rearrange as 7-8, 1-6:
10001010
XOR with BA for the compare value:
30
Seek through the rom in intervals of 2000
When you find the compare value replace it
Comment