public void patchForNationalDex() {
		log("--Patching for National Dex at Start of Game--");
		String nl = System.getProperty("line.separator");
		int fso = romEntry.getValue("FreeSpace");
		if (romEntry.romType == RomType_Ruby
				|| romEntry.romType == RomType_Sapp) {
			// Find the original pokedex script
			int pkDexOffset = find("326629010803");
			if (pkDexOffset < 0) {
				log("Patch unsuccessful." + nl);
				return;
			}
			int textPointer = readPointer(pkDexOffset - 4);
			int realScriptLocation = pkDexOffset - 8;
			int pointerLocToScript = find(pointerToHexString(realScriptLocation));
			if (pointerLocToScript < 0) {
				log("Patch unsuccessful." + nl);
				return;
			}
			// Find free space for our new routine
			int writeSpace = RomFunctions.freeSpaceFinder(rom, (byte) 0xFF, 44,
					fso);
			if (writeSpace < fso) {
				log("Patch unsuccessful." + nl);
				// Somehow this ROM is full
				return;
			}
			writePointer(pointerLocToScript, writeSpace);
			writeHexString("31720167", writeSpace);
			writePointer(writeSpace + 4, textPointer);
			writeHexString(
					"32662901082B00801102006B02021103016B020211DABE4E020211675A6A02022A008003",
					writeSpace + 8);

		} else if (romEntry.romType == RomType_FRLG) {
			// Find the original pokedex script
			int pkDexOffset = find("292908258101");
			if (pkDexOffset < 0) {
				log("Patch unsuccessful." + nl);
				return;
			}
			// Find free space for our new routine
			int writeSpace = RomFunctions.freeSpaceFinder(rom, (byte) 0xFF, 10,
					fso);
			if (writeSpace < fso) {
				// Somehow this ROM is full
				log("Patch unsuccessful." + nl);
				return;
			}
			rom[pkDexOffset] = 4;
			writePointer(pkDexOffset + 1, writeSpace);
			rom[pkDexOffset + 5] = 0; // NOP

			// Now write our new routine
			writeHexString("292908258101256F0103", writeSpace);

			// Fix people using the national dex flag
			List<Integer> ndexChecks = findMultiple("260D809301210D800100");
			for (int ndexCheckOffset : ndexChecks) {
				// change to a flag-check
				// 82C = "beaten e4/gary once"
				writeHexString("2B2C0800000000000000", ndexCheckOffset);
			}

			// Fix oak in his lab
			int oakLabCheckOffs = find("257D011604800000260D80D400");
			if (oakLabCheckOffs > 0) {
				// replace it
				writeHexString("257D011604800100", oakLabCheckOffs);
			}

			// Fix oak outside your house
			int oakHouseCheckOffs = find("1604800000260D80D4001908800580190980068083000880830109802109803C");
			if (oakHouseCheckOffs > 0) {
				// fix him to use ndex count
				writeHexString("1604800100", oakHouseCheckOffs);
			}
		} else {
			// Find the original pokedex script
			int pkDexOffset = find("3229610825F00129E40816CD40010003");
			if (pkDexOffset < 0) {
				log("Patch unsuccessful." + nl);
				return;
			}
			int textPointer = readPointer(pkDexOffset - 4);
			int realScriptLocation = pkDexOffset - 8;
			int pointerLocToScript = find(pointerToHexString(realScriptLocation));
			if (pointerLocToScript < 0) {
				log("Patch unsuccessful." + nl);
				return;
			}
			// Find free space for our new routine
			int writeSpace = RomFunctions.freeSpaceFinder(rom, (byte) 0xFF, 27,
					fso);
			if (writeSpace < fso) {
				// Somehow this ROM is full
				log("Patch unsuccessful." + nl);
				return;
			}
			writePointer(pointerLocToScript, writeSpace);
			writeHexString("31720167", writeSpace);
			writePointer(writeSpace + 4, textPointer);
			writeHexString("3229610825F00129E40825F30116CD40010003",
					writeSpace + 8);
		}
		log("Patch successful!" + nl);
	}