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); rom = new RomGame(file);
// hacky for now // hacky for now
if (file.Extension == ".exe") rom.GameInfo.System = file.Extension switch
{ {
rom.GameInfo.System = VSystemID.Raw.PSX; ".exe" => VSystemID.Raw.PSX,
} ".nsf" => VSystemID.Raw.NES,
else if (file.Extension == ".nsf") ".gbs" => VSystemID.Raw.GB,
{ _ => rom.GameInfo.System,
rom.GameInfo.System = VSystemID.Raw.NES; };
}
Util.DebugWriteLine(rom.GameInfo.System); Util.DebugWriteLine(rom.GameInfo.System);
@ -460,6 +459,18 @@ namespace BizHawk.Client.Common
{ {
case VSystemID.Raw.GB: case VSystemID.Raw.GB:
case VSystemID.Raw.GBC: 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) if (_config.GbAsSgb)
{ {
game.System = VSystemID.Raw.SGB; game.System = VSystemID.Raw.SGB;
@ -494,19 +505,6 @@ namespace BizHawk.Client.Common
nextEmulator = MakeCoreFromCoreInventory(cip, forcedCoreName); 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) 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. // 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)) if (!LoadXML(path, nextComm, file, forcedCoreName, out nextEmulator, out rom, out game))
return false; return false;
break; break;
case ".gbs":
LoadGBS(path, nextComm, file, out nextEmulator, out rom, out game);
break;
case ".psf": case ".psf":
case ".minipsf": case ".minipsf":
LoadPSF(path, nextComm, file, out nextEmulator, out rom, out game); 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> /// <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( 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("Disc Images", new[] { "cue", "ccd", "mds", "m3u" }),
new FilesystemFilter("NES", RomFileExtensions.NES.Concat(new[] { "nsf" }).ToList(), addArchiveExts: true), new FilesystemFilter("NES", RomFileExtensions.NES.Concat(new[] { "nsf" }).ToList(), addArchiveExts: true),
new FilesystemFilter("Super NES", RomFileExtensions.SNES, 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("PSX Executables (experimental)", Array.Empty<string>(), devBuildExtraExts: new[] { "exe" }),
new FilesystemFilter("PSF Playstation Sound File", new[] { "psf", "minipsf" }), new FilesystemFilter("PSF Playstation Sound File", new[] { "psf", "minipsf" }),
new FilesystemFilter("Nintendo 64", RomFileExtensions.N64), 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("Gameboy Advance", RomFileExtensions.GBA, addArchiveExts: true),
new FilesystemFilter("Nintendo DS", RomFileExtensions.NDS), new FilesystemFilter("Nintendo DS", RomFileExtensions.NDS),
new FilesystemFilter("Master System", RomFileExtensions.SMS, addArchiveExts: true), new FilesystemFilter("Master System", RomFileExtensions.SMS, addArchiveExts: true),

View File

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