Use `LoadOther` for GBS files, cleanup the code a little, update SameBoy version info

This commit is contained in:
CasualPokePlayer 2022-10-03 15:49:09 -07:00
parent 9528a2030f
commit c547a20f8e
2 changed files with 23 additions and 28 deletions

View File

@ -418,14 +418,13 @@ namespace BizHawk.Client.Common
rom = new RomGame(file);
// hacky for now
if (file.Extension == ".exe")
rom.GameInfo.System = file.Extension switch
{
rom.GameInfo.System = VSystemID.Raw.PSX;
}
else if (file.Extension == ".nsf")
{
rom.GameInfo.System = VSystemID.Raw.NES;
}
".exe" => VSystemID.Raw.PSX,
".nsf" => VSystemID.Raw.NES,
".gbs" => VSystemID.Raw.GB,
_ => rom.GameInfo.System,
};
Util.DebugWriteLine(rom.GameInfo.System);
@ -460,6 +459,18 @@ namespace BizHawk.Client.Common
{
case VSystemID.Raw.GB:
case VSystemID.Raw.GBC:
if (file.Extension == ".gbs")
{
nextEmulator = new Sameboy(
nextComm,
rom.GameInfo,
rom.FileData,
GetCoreSettings<Sameboy, Sameboy.SameboySettings>(),
GetCoreSyncSettings<Sameboy, Sameboy.SameboySyncSettings>()
);
return;
}
if (_config.GbAsSgb)
{
game.System = VSystemID.Raw.SGB;
@ -494,19 +505,6 @@ namespace BizHawk.Client.Common
nextEmulator = MakeCoreFromCoreInventory(cip, forcedCoreName);
}
private void LoadGBS(string path, CoreComm nextComm, HawkFile file, out IEmulator nextEmulator, out RomGame rom, out GameInfo game)
{
rom = new RomGame(file);
rom.GameInfo.System = VSystemID.Raw.GB;
game = rom.GameInfo;
nextEmulator = new Sameboy(
nextComm,
rom.FileData,
GetCoreSettings<Sameboy, Sameboy.SameboySettings>(),
GetCoreSyncSettings<Sameboy, Sameboy.SameboySyncSettings>()
);
}
private void LoadPSF(string path, CoreComm nextComm, HawkFile file, out IEmulator nextEmulator, out RomGame rom, out GameInfo game)
{
// TODO: Why does the PSF loader need CbDeflater provided? Surely this is a matter internal to it.
@ -693,9 +691,6 @@ namespace BizHawk.Client.Common
if (!LoadXML(path, nextComm, file, forcedCoreName, out nextEmulator, out rom, out game))
return false;
break;
case ".gbs":
LoadGBS(path, nextComm, file, out nextEmulator, out rom, out game);
break;
case ".psf":
case ".minipsf":
LoadPSF(path, nextComm, file, out nextEmulator, out rom, out game);
@ -875,7 +870,7 @@ namespace BizHawk.Client.Common
/// <remarks>TODO add and handle <see cref="FilesystemFilter.LuaScripts"/> (you can drag-and-drop scripts and there are already non-rom things in this list, so why not?)</remarks>
private static readonly FilesystemFilterSet RomFSFilterSet = new FilesystemFilterSet(
new FilesystemFilter("Music Files", Array.Empty<string>(), devBuildExtraExts: new[] { "psf", "minipsf", "sid", "nsf" }),
new FilesystemFilter("Music Files", Array.Empty<string>(), devBuildExtraExts: new[] { "psf", "minipsf", "sid", "nsf", "gbs" }),
new FilesystemFilter("Disc Images", new[] { "cue", "ccd", "mds", "m3u" }),
new FilesystemFilter("NES", RomFileExtensions.NES.Concat(new[] { "nsf" }).ToList(), addArchiveExts: true),
new FilesystemFilter("Super NES", RomFileExtensions.SNES, addArchiveExts: true),
@ -883,7 +878,7 @@ namespace BizHawk.Client.Common
new FilesystemFilter("PSX Executables (experimental)", Array.Empty<string>(), devBuildExtraExts: new[] { "exe" }),
new FilesystemFilter("PSF Playstation Sound File", new[] { "psf", "minipsf" }),
new FilesystemFilter("Nintendo 64", RomFileExtensions.N64),
new FilesystemFilter("Gameboy", RomFileExtensions.GB, addArchiveExts: true),
new FilesystemFilter("Gameboy", RomFileExtensions.GB.Concat(new[] { "gbs" }).ToList(), addArchiveExts: true),
new FilesystemFilter("Gameboy Advance", RomFileExtensions.GBA, addArchiveExts: true),
new FilesystemFilter("Nintendo DS", RomFileExtensions.NDS),
new FilesystemFilter("Master System", RomFileExtensions.SMS, addArchiveExts: true),

View File

@ -13,7 +13,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Sameboy
/// <summary>
/// a gameboy/gameboy color emulator wrapped around native C libsameboy
/// </summary>
[PortedCore(CoreNames.Sameboy, "LIJI32", "0.15.1", "https://github.com/LIJI32/SameBoy")]
[PortedCore(CoreNames.Sameboy, "LIJI32", "0.15.6", "https://github.com/LIJI32/SameBoy")]
[ServiceNotApplicable(new[] { typeof(IDriveLight) })]
public partial class Sameboy : ICycleTiming, IInputPollable, ILinkable, IRomInfo, IBoardInfo, IGameboyCommon
{
@ -44,8 +44,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.Sameboy
private readonly LibSameboy.RumbleCallback _rumblecb;
public Sameboy(CoreComm comm, byte[] gbs, SameboySettings settings, SameboySyncSettings syncSettings)
: this(comm, GameInfo.NullInstance, null, settings, syncSettings, false)
public Sameboy(CoreComm comm, GameInfo game, byte[] gbs, SameboySettings settings, SameboySyncSettings syncSettings)
: this(comm, game, null, settings, syncSettings, false)
{
var gbsInfo = new LibSameboy.GBSInfo
{