/*	Game Genie SNES decoding
 *
 *	Stol^H^H^H^HBorrowed from the rec.games.video FAQ by Ken Arromdee:
 *
 *	(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
 *
 *	So, AD:80C7AA translates to C2AC-346F
 *
 * 
 *	In Make8Struct:
 *	Either -g or -x is necessary.  It'll complain otherwise.
 *
 *
 *	In Make9Struct:
 *	What must be done:  Turn the input into a form identical
 *	to that which Make8Struct gives, stripping any punctuation
 *	along the way.  '-' in the fifth place means game genie.
 *	':' in the third means a hex code.  'X' in the sixth
 *	means you're looking at I Ching, not this program...
 *	We'll do quite a bit of typo checking here, too.
 *	NOTE:  -g or -x OVERRIDES any '-' or ':' in the code.
 *
 * In ConvertCode:
 * 	What we have now is known:  a 4-byte-long hex number; and whether that
 *	number is a game genie code waiting to be turned into a hex code, or
 *	vice versa.  Now, since it *is* hex, strtoul() is used to convert the
 *	mother into an unsigned long int, to get ready for bitwise stuff.  The
 *	messiness of the code is due to the fact that:
 *	GG to hex == translation of bytes, bit-swapping, and rehexing;
 *	hex to GG ==  hexification, bit-swapping, then retranslation.
 *	Simple, really.
 *
 *
 * To compile a shorter version in Linux:
 *	(1)  Use a.out (if you still have the libraries!); 
 *	(2)  Optimize (The -O2 flag; -O3 overoptimizes);
 *	(3a) Use the -N linker flag to inhibit mapping to page boundaries;
 *	(3b) If using 2.7.x, include "-Wl,-Bdynamic" to tell the linker
 *	     not to link statically.  *Make sure* you're using a.out
 *	     when doing this.  It'll segfault in ELF when used with -N;
 *	(4)  strip the executable to squeeze out the last few bytes.
 *
 *
 *	From GGCCC:
 *
 *
 *	CONVERSION CHART
 *	----------------
 *
 *	Convert the third byte of the code using this table:
 *
 *	D <------> 6         0 <------> A
 *	F <------> B         9 <------> 2
 *	4 <------> C         1 <------> 3
 *	7 <------> 8         5 <------> E
 *
 *    e.g., 1234-5678 to 1214-5678
 *
 *
 *
 */

int main() { printf("Hey, this is a doc file, not a program!"); return(1); }
