diff --git a/Assets/dll/bsnes.wbx.zst b/Assets/dll/bsnes.wbx.zst index a591d1faa6..8ea8ee6783 100644 Binary files a/Assets/dll/bsnes.wbx.zst and b/Assets/dll/bsnes.wbx.zst differ diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/BSNES/BsnesApi.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/BSNES/BsnesApi.cs index b8ee510958..7915d775f0 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/BSNES/BsnesApi.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/BSNES/BsnesApi.cs @@ -33,7 +33,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.BSNES [BizImport(CallingConvention.Cdecl)] public abstract BsnesApi.SNES_REGION snes_get_region(); [BizImport(CallingConvention.Cdecl)] - public abstract BsnesApi.SNES_MAPPER snes_get_mapper(); + public abstract IntPtr snes_get_board(); [BizImport(CallingConvention.Cdecl)] public abstract IntPtr snes_get_memory_region(int id, out int size, out int wordSize); [BizImport(CallingConvention.Cdecl)] diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/BSNES/BsnesApi_Enums.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/BSNES/BsnesApi_Enums.cs index 296c3864c7..0ac8300998 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/BSNES/BsnesApi_Enums.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/BSNES/BsnesApi_Enums.cs @@ -151,21 +151,6 @@ High } - public enum SNES_MAPPER : byte - { - LOROM = 0, - HIROM = 1, - EXLOROM = 2, - EXHIROM = 3, - SUPERFXROM = 4, - SA1ROM = 5, - SPC7110ROM = 6, - BSCLOROM = 7, - BSCHIROM = 8, - BSXROM = 9, - STROM = 10 - } - public enum SNES_REGION : uint { NTSC = 0, diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/BSNES/BsnesCore.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/BSNES/BsnesCore.cs index 1339c85ba0..2e2d6eb544 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/BSNES/BsnesCore.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/BSNES/BsnesCore.cs @@ -1,5 +1,6 @@ using System; using System.IO; +using System.Runtime.InteropServices; using BizHawk.Common; using BizHawk.Emulation.Common; using BizHawk.Emulation.Common.Base_Implementations; @@ -12,7 +13,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.BSNES { [PortedCore(CoreNames.Bsnes115, "bsnes team", "v115+", "https://github.com/bsnes-emu/bsnes")] [ServiceNotApplicable(new[] { typeof(IDriveLight) })] - public partial class BsnesCore : IEmulator, IDebuggable, IVideoProvider, ISaveRam, IStatable, IInputPollable, IRegionable, ISettable, IBSNESForGfxDebugger + public partial class BsnesCore : IEmulator, IDebuggable, IVideoProvider, ISaveRam, IStatable, IInputPollable, IRegionable, ISettable, IBSNESForGfxDebugger, IBoardInfo { [CoreConstructor(VSystemID.Raw.SGB)] [CoreConstructor(VSystemID.Raw.SNES)] @@ -85,8 +86,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.BSNES if (IsSGB) { - ser.Register(new SGBBoardInfo()); - Api.core.snes_load_cartridge_super_gameboy(sgbRomData, loadParameters.Roms[0].RomData, sgbRomData!.Length, loadParameters.Roms[0].RomData.Length); } @@ -95,6 +94,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.BSNES Api.core.snes_load_cartridge_normal(loadParameters.Roms[0].RomData, loadParameters.Roms[0].RomData.Length); } + using (Api.EnterExit()) this.BoardName = Marshal.PtrToStringAnsi(Api.core.snes_get_board()); _region = Api.core.snes_get_region(); if (_region == BsnesApi.SNES_REGION.NTSC) { @@ -130,11 +130,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.BSNES private bool _disposed; public bool IsSGB { get; } - - private class SGBBoardInfo : IBoardInfo - { - public string BoardName => "SGB"; - } + public string BoardName { get; } internal BsnesApi Api { get; } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/BSNES/SubBsnesCore.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/BSNES/SubBsnesCore.cs index a6ac4539af..bd7995550c 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/BSNES/SubBsnesCore.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/BSNES/SubBsnesCore.cs @@ -26,16 +26,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.BSNES ser.Register(_bsnesCore.ServiceProvider.GetService()); ser.Register(_bsnesCore.ServiceProvider.GetService()); ser.Register(_bsnesCore.ServiceProvider.GetService>()); + ser.Register(_bsnesCore.ServiceProvider.GetService()); + ser.Register(_bsnesCore.ServiceProvider.GetService()); ser.Register(_bsnesCore.ServiceProvider.GetService()); ser.Register(_bsnesCore.ServiceProvider.GetService()); ser.Register(_bsnesCore.ServiceProvider.GetService()); ser.Register(_bsnesCore.ServiceProvider.GetService()); - ser.Register(_bsnesCore.ServiceProvider.GetService()); - if (IsSGB) - { - // board info is only set in SGB mode - ser.Register(_bsnesCore.ServiceProvider.GetService()); - } ServiceProvider = ser; } @@ -50,45 +46,45 @@ namespace BizHawk.Emulation.Cores.Nintendo.BSNES public bool FrameAdvance(IController controller, bool render, bool renderSound = true) { using (_bsnesCore.Api.EnterExit()) - { - _bsnesCore.FrameAdvancePre(controller, render, renderSound); - - _bsnesCore.IsLagFrame = true; - bool framePassed = false; - - bool resetSignal = controller.IsPressed("Reset"); - bool powerSignal = controller.IsPressed("Power"); - - if (resetSignal || powerSignal) - { - int resetInstruction = controller.AxisValue("Reset Instruction"); - for (int i = 0; i < resetInstruction; i++) - { - framePassed = _bsnesCore.Api.core.snes_cpu_step(); - if (framePassed) break; - } - - if (resetSignal) - { - _bsnesCore.Api.core.snes_reset(); - } - - if (powerSignal) - { - _bsnesCore.Api.core.snes_power(); - } - } - else - { - // run the core for one (sub-)frame - bool subFrameRequested = controller.IsPressed("Subframe"); - framePassed = _bsnesCore.Api.core.snes_run(subFrameRequested); - } - - if (!framePassed) _bsnesCore.IsLagFrame = false; - _bsnesCore.FrameAdvancePost(); - - return true; + { + _bsnesCore.FrameAdvancePre(controller, render, renderSound); + + _bsnesCore.IsLagFrame = true; + bool framePassed = false; + + bool resetSignal = controller.IsPressed("Reset"); + bool powerSignal = controller.IsPressed("Power"); + + if (resetSignal || powerSignal) + { + int resetInstruction = controller.AxisValue("Reset Instruction"); + for (int i = 0; i < resetInstruction; i++) + { + framePassed = _bsnesCore.Api.core.snes_cpu_step(); + if (framePassed) break; + } + + if (resetSignal) + { + _bsnesCore.Api.core.snes_reset(); + } + + if (powerSignal) + { + _bsnesCore.Api.core.snes_power(); + } + } + else + { + // run the core for one (sub-)frame + bool subFrameRequested = controller.IsPressed("Subframe"); + framePassed = _bsnesCore.Api.core.snes_run(subFrameRequested); + } + + if (!framePassed) _bsnesCore.IsLagFrame = false; + _bsnesCore.FrameAdvancePost(); + + return true; } } diff --git a/waterbox/bsnescore/bsnes/target-bsnescore/bsnescore.cpp b/waterbox/bsnescore/bsnes/target-bsnescore/bsnescore.cpp index a0c0da34af..0b4644ebf5 100644 --- a/waterbox/bsnescore/bsnes/target-bsnescore/bsnescore.cpp +++ b/waterbox/bsnescore/bsnes/target-bsnescore/bsnescore.cpp @@ -312,22 +312,12 @@ EXPORT short* snes_get_audiobuffer_and_size(int& out_size) { return audioBuffer.data(); } -EXPORT char snes_get_mapper(void) { - string board = program->superFamicom.document["game/board"].text(); - string mapper = board.split('-', 1)[0]; - if (mapper == "LOROM") return 0; - if (mapper == "HIROM") return 1; - if (mapper == "EXLOROM") return 2; - if (mapper == "EXHIROM") return 3; - if (mapper == "SUPERFXROM") return 4; - if (mapper == "SA1ROM") return 5; - if (mapper == "SPC7110ROM") return 6; - if (mapper == "BSCLOROM") return 7; - if (mapper == "BSCHIROM") return 8; - if (mapper == "BSXROM") return 9; - if (mapper == "STROM") return 10; +const char* board; +EXPORT const char* snes_get_board(void) +{ + if (!board) board = program->superFamicom.document["game/board"].text().data(); - return -1; + return board; } EXPORT void* snes_get_memory_region(int id, int* size, int* word_size)