public void saveFileAs(string filename, ROM_Endian saveType) { if (saveType == ROM_Endian.MIXED) { swapMixedBig(); File.WriteAllBytes(filename, bytes); swapMixedBig(); endian = ROM_Endian.MIXED; } else if (saveType == ROM_Endian.LITTLE) { swapLittleBig(); File.WriteAllBytes(filename, bytes); swapLittleBig(); endian = ROM_Endian.LITTLE; } else // Save as big endian by default { File.WriteAllBytes(filename, bytes); endian = ROM_Endian.BIG; } Globals.needToSave = false; filepath = filename; Globals.pathToAutoLoadROM = filepath; SettingsFile.SaveGlobalSettings("default"); }
private void checkROM() { if (bytes[0] == 0x80 && bytes[1] == 0x37) { endian = ROM_Endian.BIG; } else if (bytes[0] == 0x37 && bytes[1] == 0x80) { endian = ROM_Endian.MIXED; } else if (bytes[0] == 0x40 && bytes[1] == 0x12) { endian = ROM_Endian.LITTLE; } if (endian == ROM_Endian.MIXED) { swapMixedBig(); } else if (endian == ROM_Endian.LITTLE) { swapLittleBig(); } if (bytes[0x3E] == 0x45) { region = ROM_Region.NORTH_AMERICA; } else if (bytes[0x3E] == 0x50) { region = ROM_Region.EUROPE; } else if (bytes[0x3E] == 0x4A) { if (bytes[0x3F] < 3) { region = ROM_Region.JAPAN; } else { region = ROM_Region.JAPAN_SHINDOU; } } // Setup segment 0x02 & segment 0x15 addresses if (region == ROM_Region.NORTH_AMERICA) { Globals.macro_preset_table = 0xEC7E0; Globals.special_preset_table = 0xED350; // Globals.seg02_location = new[] { (uint)0x108A40, (uint)0x114750 }; Globals.seg15_location = new[] { (uint)0x2ABCA0, (uint)0x2AC6B0 }; } else if (region == ROM_Region.EUROPE) { Globals.macro_preset_table = 0xBD590; Globals.special_preset_table = 0xBE100; // Globals.seg02_location = new[] { (uint)0xDE190, (uint)0xE49F0 }; Globals.seg15_location = new[] { (uint)0x28CEE0, (uint)0x28D8F0 }; } else if (region == ROM_Region.JAPAN) { Globals.macro_preset_table = 0xEB6D0; Globals.special_preset_table = 0xEC240; // Globals.seg02_location = new[] { (uint)0x1076D0, (uint)0x112B50 }; Globals.seg15_location = new[] { (uint)0x2AA240, (uint)0x2AAC50 }; } else if (region == ROM_Region.JAPAN_SHINDOU) { Globals.macro_preset_table = 0xC8D60; Globals.special_preset_table = 0xC98D0; //Globals.seg02_location = new[] { (uint)0xE42F0, (uint)0xEF770 }; Globals.seg15_location = new[] { (uint)0x286AC0, (uint)0x2874D0 }; } findAndSetSegment02(); Console.WriteLine("Segment2 location: 0x" + Globals.seg02_location[0].ToString("X8") + " to 0x" + Globals.seg02_location[1].ToString("X8")); if (bytes[Globals.seg15_location[0]] == 0x17) { type = ROM_Type.EXTENDED; } else { type = ROM_Type.VANILLA; } Console.WriteLine("ROM = " + filepath); Console.WriteLine("ROM Endian = " + endian); Console.WriteLine("ROM Region = " + region); Console.WriteLine("ROM Type = " + type); Console.WriteLine("-----------------------"); }