Copy Link
Add to Bookmark
Report
Converting between Game Genie's SNES codes and hex codes
The instructions for converting SNES and Genesis codes by the "brute force" method come from rec.games.video.misc, in a file named "GAMES3.TXT." I've since lost the specifics. Sorry. Anyway, this is quoted directly from that file:
Game Genie SNES decoding
(This is from hexadecimal to Genie, to reverse just run it backwards)
Data - D7 down to D0
Address - A23 down to A0. Bit 15 is always a 1; if you use a 0, the Game
Genie will just change it to a 1 anyway.
DDDD DDDD AAAA AAAA AAAA AAAA AAAA AAAA (Genie Code)
7654 3210 1111 7654 9822 2232 1011 1111 (True address, rearranged)
5432 32 10 98 7610
Example - Force AD at 80C7AA
Data = 1010 1101
Address = 1000 0000 1100 0111 1010 1010
Take the data in order, and then take bit 15, 14, 13, 12, 7, 6, etc. of the
address, to get:
1010 1101 1100 1010 1110 0010 1000 0001 = ADCAE281
The Game Genie hex is encoded from normal hexadecimal, so at this
point you must translate with the following table:
HEX: 0 1 2 3 4 5 6 7 8 9 A B C D E F
GENIE: D F 4 7 0 9 1 5 6 B C 8 A 2 3 E
Translates to C2AC-346F
As with NES codes, I'll also put up the VC++ stuff that worked for me.
static CString SGGtoHx(CString scode)
{
CString hresult=" ";
char tchar[2]="";
unsigned int mval=0;
for (mval=0;mval<=7;mval++) //Error checking
{
if (GetVal(scode[(int) mval])== -1) //GetVal turns GG hex into real hex
return "--------"; //(hand-written, not shown)
}
//The first 4 characters are okay, but the last 4 are
//mass rotated. There's no mass rotate command, so you have
//to OR everything together and rotate... Or fake rotate.
//There's only 16 bits, but it still wants to use a 32 bit
//space, so you have to fake it. (I forget why short int
//didn't work.) Anyway, then you AND everything
//back off and store it away.
_itoa(GetVal(scode[0]),tchar,16); //_itoa puts the number into a string
hresult.SetAt(6,tchar[0]); //SetAt stores it in the result
_itoa(GetVal(scode[1]),tchar,16);
hresult.SetAt(7,tchar[0]);
_itoa(GetVal(scode[2]),tchar,16);
hresult.SetAt(2,tchar[0]);
_itoa(GetVal(scode[3]),tchar,16);
hresult.SetAt(4,tchar[0]);
mval = GetVal(scode[7]);
mval |= (GetVal(scode[6])<<4);
mval |= (GetVal(scode[5])<<8);
mval |= (GetVal(scode[4])<<12);
mval <<= 2;
mval |= (GetVal(scode[4])&12)>>2;
mval &= 65535; //2 bits get away because of the fake rotate
_itoa((mval&61440)>>12,tchar,16);
hresult.SetAt(0,tchar[0]);
_itoa((mval&3840)>>8,tchar,16);
hresult.SetAt(5,tchar[0]);
_itoa((mval&240)>>4,tchar,16);
hresult.SetAt(1,tchar[0]);
_itoa(mval&15,tchar,16);
hresult.SetAt(3,tchar[0]);
return hresult;
}
static CString SHxtoGG(CString scode)
{
CString gresult=" ";
unsigned int mval=0;
for (mval=0;mval<=7;mval++) //More error checking
{
if (AtoH(scode[(int) mval])== -1) //AtoH turns hex strings into numbers
return "--------"; //(recycled from NES section)
}
//GetChar turns real hex into GG hex (hand-written, not shown)
gresult.SetAt(0,GetChar(AtoH(scode[6])));
gresult.SetAt(1,GetChar(AtoH(scode[7])));
gresult.SetAt(2,GetChar(AtoH(scode[2])));
gresult.SetAt(3,GetChar(AtoH(scode[4])));
mval = AtoH(scode[3]);
mval |= (AtoH(scode[1])<<4);
mval |= (AtoH(scode[5])<<8);
mval |= (AtoH(scode[0])<<12);
mval >>= 2;
mval |= (AtoH(scode[3])&3)<<14;
gresult.SetAt(4,GetChar((mval&61440)>>12));
gresult.SetAt(5,GetChar((mval&3840)>>8));
gresult.SetAt(6,GetChar((mval&240)>>4));
gresult.SetAt(7,GetChar(mval&15));
return gresult;
}