diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.ISettable.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.ISettable.cs index 0e57966b9b..855aa5c434 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.ISettable.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.ISettable.cs @@ -88,8 +88,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy public class GambatteSyncSettings { - [DisplayName("Enable BIOS: WARNING: File must exist!")] - [Description("Boots game using system BIOS. Should be used for TASing")] + [DisplayName("Enable official Nintendo BIOS")] + [Description("Boots game using system BIOS. You must have the bios file. Should be used for TASing.")] [DefaultValue(false)] public bool EnableBIOS { get; set; } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.cs index 562555a4cb..1ec9d15287 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.cs @@ -1,8 +1,9 @@ using System; - +using System.IO; using BizHawk.Common.BufferExtensions; using BizHawk.Emulation.Common; using BizHawk.Emulation.Cores.Consoles.Nintendo.Gameboy; +using BizHawk.Emulation.Cores.Properties; namespace BizHawk.Emulation.Cores.Nintendo.Gameboy { @@ -83,6 +84,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy throw new InvalidOperationException($"{nameof(LibGambatte.gambatte_load)}() returned non-zero (is this not a gb or gbc rom?)"); } + byte[] bios; string biosName; if ((flags & LibGambatte.LoadFlags.FORCE_DMG) == LibGambatte.LoadFlags.FORCE_DMG) { @@ -91,18 +93,40 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy } else { + // TODO: Fix AGB bios mode stuff + // biosName = _syncSettings.GBACGB ? "AGB" : "GBC"; biosName = "GBC"; IsCgb = true; } if (_syncSettings.EnableBIOS) { - byte[] Bios; - Bios = comm.CoreFileProvider.GetFirmware(biosName, "World", true, "BIOS Not Found, Cannot Load. Change SyncSettings to run without BIOS."); - if (LibGambatte.gambatte_loadbios(GambatteState, Bios, (uint)Bios.Length) != 0) + bios = comm.CoreFileProvider.GetFirmware(biosName, "World", true, "BIOS Not Found, Cannot Load. Change SyncSettings to run without BIOS."); + } + else + { + Lazy builtinBios; + switch (biosName) { - throw new InvalidOperationException($"{nameof(LibGambatte.gambatte_loadbios)}() returned non-zero (bios error)"); + case "GB": + builtinBios = Resources.SameboyDmgBoot; + break; + case "GBC": + builtinBios = Resources.SameboyCgbBoot; + break; + // TODO: This doesn't work; locks up before leaving the bios screen + // case "AGB": + // builtinBios = Resources.SameboyAgbBoot; + // break; + default: + throw new Exception("Internal GB Error (BIOS??)"); } + bios = BizHawk.Common.Util.DecompressGzipFile(new MemoryStream(builtinBios.Value, false)); + } + + if (LibGambatte.gambatte_loadbios(GambatteState, bios, (uint)bios.Length) != 0) + { + throw new InvalidOperationException($"{nameof(LibGambatte.gambatte_loadbios)}() returned non-zero (bios error)"); } // set real default colors (before anyone mucks with them at all) diff --git a/src/BizHawk.Emulation.Cores/Properties/Resources.cs b/src/BizHawk.Emulation.Cores/Properties/Resources.cs index 87dce02375..4bcb534912 100644 --- a/src/BizHawk.Emulation.Cores/Properties/Resources.cs +++ b/src/BizHawk.Emulation.Cores/Properties/Resources.cs @@ -16,6 +16,7 @@ namespace BizHawk.Emulation.Cores.Properties { internal static readonly Lazy CPC_OS_6128_ROM = new Lazy(() => ReadEmbeddedByteArray("CPC_OS_6128.ROM.gz")); internal static readonly Lazy OS_464_ROM = new Lazy(() => ReadEmbeddedByteArray("OS_464.ROM.gz")); internal static readonly Lazy SameboyCgbBoot = new Lazy(() => ReadEmbeddedByteArray("cgb_boot.rom.gz")); + internal static readonly Lazy SameboyAgbBoot = new Lazy(() => ReadEmbeddedByteArray("agb_boot.rom.gz")); internal static readonly Lazy SameboyDmgBoot = new Lazy(() => ReadEmbeddedByteArray("dmg_boot.rom.gz")); internal static readonly Lazy SgbCartPresent_SPC = new Lazy(() => ReadEmbeddedByteArray("sgb-cart-present.spc.gz")); internal static readonly Lazy ZX_128_ROM = new Lazy(() => ReadEmbeddedByteArray("128.ROM.gz")); diff --git a/src/BizHawk.Emulation.Cores/Resources/agb_boot.rom.gz b/src/BizHawk.Emulation.Cores/Resources/agb_boot.rom.gz new file mode 100644 index 0000000000..1a778e92d7 Binary files /dev/null and b/src/BizHawk.Emulation.Cores/Resources/agb_boot.rom.gz differ