Esempio n. 1
0
 public void saveFileAs(string filename, RomEndian saveType)
 {
     if (saveType == RomEndian.Mixed)
     {
         swapMixedBig();
         File.WriteAllBytes(filename, bytes);
         swapMixedBig();
         endian = RomEndian.Mixed;
     }
     else if (saveType == RomEndian.Little)
     {
         swapLittleBig();
         File.WriteAllBytes(filename, bytes);
         swapLittleBig();
         endian = RomEndian.Little;
     }
     else             // Save as big endian by default
     {
         File.WriteAllBytes(filename, bytes);
         endian = RomEndian.Big;
     }
     Globals.needToSave        = false;
     filepath                  = filename;
     Globals.pathToAutoLoadROM = filepath;
     SettingsFile.SaveGlobalSettings("default");
 }
Esempio n. 2
0
        private void checkROM()
        {
            if (bytes[0] == 0x80 && bytes[1] == 0x37)
            {
                endian = RomEndian.Big;
            }
            else if (bytes[0] == 0x37 && bytes[1] == 0x80)
            {
                endian = RomEndian.Mixed;
            }
            else if (bytes[0] == 0x40 && bytes[1] == 0x12)
            {
                endian = RomEndian.Little;
            }

            if (endian == RomEndian.Mixed)
            {
                swapMixedBig();
            }
            else if (endian == RomEndian.Little)
            {
                swapLittleBig();
            }

            if (bytes[0x3E] == 0x45)
            {
                region = RomRegion.NorthAmerica;
            }
            else if (bytes[0x3E] == 0x50)
            {
                region = RomRegion.Europe;
            }
            else if (bytes[0x3E] == 0x4A)
            {
                if (bytes[0x3F] < 3)
                {
                    region = RomRegion.Japan;
                }
                else
                {
                    region = RomRegion.JapanShindou;
                }
            }

            // Setup segment 0x02 & segment 0x15 addresses
            if (region == RomRegion.NorthAmerica)
            {
                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 == RomRegion.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 == RomRegion.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 == RomRegion.JapanShindou)
            {
                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 = RomType.Extended;
            }
            else
            {
                type = RomType.Vanilla;
            }


            Console.WriteLine("ROM = " + filepath);
            Console.WriteLine("ROM Endian = " + endian);
            Console.WriteLine("ROM Region = " + region);
            Console.WriteLine("ROM Type = " + type);
            Console.WriteLine("-----------------------");
        }