private static void PostProcess(Data data) { Pad(data); var snesApi = data.GetSnesApi(); Debug.Assert(snesApi != null); // inject the game name into the bytes // This is a UTF8 string that needs to be converted to ShiftJIS (Ascii w/some japanese chars) encoding. snesApi.SetCartridgeTitle(GetSampleUtf8CartridgeTitle()); // initialize some SNES header stuff (this is not complete, feel free to add things that are useful) Debug.Assert(snesApi.RomMapMode == RomMapMode.LoRom); Debug.Assert(snesApi.RomSpeed == RomSpeed.FastRom); var romSettingsOffset = RomUtil.GetRomSettingOffset(RomMapMode.LoRom); const int loromAndFastRom = 0x30; data.RomBytes[romSettingsOffset].Rom = loromAndFastRom; // do this LAST after all modifications to the ROM bytes have been completed snesApi.FixChecksum(); // NORMALLY when a project is loaded, we have to open the ROM file on disk and read the bytes on disk into RomBytes // for this sample data, there is no ROM on disk, so we tell Diz we already took care of it data.RomBytesLoaded = true; }
public static void TestTitleRead() { var fakeRom = Enumerable .Range(0, 0x7FC0) .Select(_ => (byte)0x00) .Concat(RawRomBytes) .ToArray(); RomUtil .GetCartridgeTitleFromRom( fakeRom, RomUtil.GetRomSettingOffset(RomMapMode.LoRom) ).Should().Be(ExpectedTitleStr); }