Remove firmware patching from Gambatte

This commit is contained in:
YoshiRulz 2021-09-17 23:54:48 +10:00 committed by James Groom
parent d513c5b2a0
commit 190e121a90
2 changed files with 8 additions and 35 deletions

View File

@ -106,11 +106,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
[DefaultValue(false)]
public bool EnableBIOS { get; set; }
[DisplayName("Patch Similar BootROMs")]
[Description("If true, BootROMs (or \"BIOSes\") are patched a similar other. GBC is patched to GBA. DMG is patched to MGB (and vice versa). Should not be used for unofficial BootROMs. Ignored (treated as false) when booting without a BIOS.")]
[DefaultValue(false)]
public bool PatchBIOS { get; set; }
public enum ConsoleModeType
{
Auto,

View File

@ -80,39 +80,17 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
flags |= LibGambatte.LoadFlags.MULTICART_COMPAT;
}
byte[] bios;
string biosSystemId;
string biosId;
IsCgb = (flags & LibGambatte.LoadFlags.CGB_MODE) == LibGambatte.LoadFlags.CGB_MODE;
biosSystemId = IsCgb ? "GBC" : "GB";
biosId = (_syncSettings.ConsoleMode == GambatteSyncSettings.ConsoleModeType.GBA) && !_syncSettings.PatchBIOS ? "AGB" : "World";
if (IsSgb)
{
biosId = "SGB2";
}
if (_syncSettings.EnableBIOS)
{
bios = comm.CoreFileProvider.GetFirmwareOrThrow(new(biosSystemId, biosId), "BIOS Not Found, Cannot Load. Change SyncSettings to run without BIOS.");
if (_syncSettings.PatchBIOS)
{
if (!IsCgb)
{
bios[0xFD] ^= 0xFE; // patch from dmg<->mgb, or sgb1<->sgb2
}
else if (_syncSettings.ConsoleMode == GambatteSyncSettings.ConsoleModeType.GBA)
{
// patch from cgb->agb re
bios[0xF3] ^= 0x03;
for (var i = 0xF5; i < 0xFB; i++)
{
bios[i] = bios[i + 1];
}
bios[0xFB] ^= 0x74;
}
}
FirmwareID fwid = new(
IsCgb ? "GBC" : "GB",
IsSgb
? "SGB2"
: _syncSettings.ConsoleMode is GambatteSyncSettings.ConsoleModeType.GBA
? "AGB"
: "World");
var bios = comm.CoreFileProvider.GetFirmwareOrThrow(fwid, "BIOS Not Found, Cannot Load. Change SyncSettings to run without BIOS."); // https://github.com/TASVideos/BizHawk/issues/2832 tho
if (LibGambatte.gambatte_loadbiosbuf(GambatteState, bios, (uint)bios.Length) != 0)
{
throw new InvalidOperationException($"{nameof(LibGambatte.gambatte_loadbiosbuf)}() returned non-zero (bios error)");