diff --git a/BizHawk.Emulation/Consoles/Nintendo/SNES/LibsnesCore.cs b/BizHawk.Emulation/Consoles/Nintendo/SNES/LibsnesCore.cs index d3704b6065..97445fb99e 100644 --- a/BizHawk.Emulation/Consoles/Nintendo/SNES/LibsnesCore.cs +++ b/BizHawk.Emulation/Consoles/Nintendo/SNES/LibsnesCore.cs @@ -1,5 +1,5 @@ //TODO -//libsnes needs to be modified to support multiple instances +//libsnes needs to be modified to support multiple instances - THIS IS NECESSARY - or else loading one game and then another breaks things //rename snes.dll so nobody thinks it's a stock snes.dll (we'll be editing it substantially at some point) //wrap dll code around some kind of library-accessing interface so that it doesnt malfunction if the dll is unavailable @@ -82,6 +82,12 @@ namespace BizHawk.Emulation.Consoles.Nintendo.SNES [return: MarshalAs(UnmanagedType.U1)] [DllImport("snes.dll", CallingConvention = CallingConvention.Cdecl)] public static extern bool snes_unserialize(IntPtr data, int size); + + [DllImport("snes.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void snes_set_layer_enable(int layer, int priority, + [MarshalAs(UnmanagedType.U1)] + bool enable + ); public enum SNES_MEMORY : uint { @@ -241,6 +247,19 @@ namespace BizHawk.Emulation.Consoles.Nintendo.SNES public void FrameAdvance(bool render) { + LibsnesDll.snes_set_layer_enable(0, 0, CoreInputComm.SNES_ShowBG1_0); + LibsnesDll.snes_set_layer_enable(0, 1, CoreInputComm.SNES_ShowBG1_1); + LibsnesDll.snes_set_layer_enable(1, 0, CoreInputComm.SNES_ShowBG2_0); + LibsnesDll.snes_set_layer_enable(1, 1, CoreInputComm.SNES_ShowBG2_1); + LibsnesDll.snes_set_layer_enable(2, 0, CoreInputComm.SNES_ShowBG3_0); + LibsnesDll.snes_set_layer_enable(2, 1, CoreInputComm.SNES_ShowBG3_1); + LibsnesDll.snes_set_layer_enable(3, 0, CoreInputComm.SNES_ShowBG4_0); + LibsnesDll.snes_set_layer_enable(3, 1, CoreInputComm.SNES_ShowBG4_1); + LibsnesDll.snes_set_layer_enable(4, 0, CoreInputComm.SNES_ShowOBJ_0); + LibsnesDll.snes_set_layer_enable(4, 1, CoreInputComm.SNES_ShowOBJ_1); + LibsnesDll.snes_set_layer_enable(4, 2, CoreInputComm.SNES_ShowOBJ_2); + LibsnesDll.snes_set_layer_enable(4, 3, CoreInputComm.SNES_ShowOBJ_3); + //apparently this is one frame? LibsnesDll.snes_run(); } @@ -351,9 +370,9 @@ namespace BizHawk.Emulation.Consoles.Nintendo.SNES } // Arbitrary extensible core comm mechanism - CoreInputComm IEmulator.CoreInputComm { get; set; } - CoreOutputComm IEmulator.CoreOutputComm { get { return CoreOutputComm; } } - CoreOutputComm CoreOutputComm = new CoreOutputComm(); + public CoreInputComm CoreInputComm { get; set; } + public CoreOutputComm CoreOutputComm { get { return _CoreOutputComm; } } + CoreOutputComm _CoreOutputComm = new CoreOutputComm(); // ----- Client Debugging API stuff ----- unsafe MemoryDomain MakeMemoryDomain(string name, LibsnesDll.SNES_MEMORY id, Endian endian) @@ -394,7 +413,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo.SNES { MemoryDomains = new List(); - var romDomain = new MemoryDomain("ROM", romData.Length, Endian.Little, + var romDomain = new MemoryDomain("CARTROM", romData.Length, Endian.Little, (addr) => romData[addr], (addr, value) => romData[addr] = value); diff --git a/BizHawk.Emulation/Interfaces/CoreComms.cs b/BizHawk.Emulation/Interfaces/CoreComms.cs index e857e0a4fc..63e7f062b7 100644 --- a/BizHawk.Emulation/Interfaces/CoreComms.cs +++ b/BizHawk.Emulation/Interfaces/CoreComms.cs @@ -7,6 +7,10 @@ public bool NES_ShowBG, NES_ShowOBJ; public bool PCE_ShowBG1, PCE_ShowOBJ1, PCE_ShowBG2, PCE_ShowOBJ2; public bool SMS_ShowBG, SMS_ShowOBJ; + + public bool SNES_ShowBG1_0, SNES_ShowBG2_0, SNES_ShowBG3_0, SNES_ShowBG4_0; + public bool SNES_ShowBG1_1, SNES_ShowBG2_1, SNES_ShowBG3_1, SNES_ShowBG4_1; + public bool SNES_ShowOBJ_0, SNES_ShowOBJ_1, SNES_ShowOBJ_2, SNES_ShowOBJ_3; } public class CoreOutputComm diff --git a/BizHawk.MultiClient/Config.cs b/BizHawk.MultiClient/Config.cs index b9db346611..bd517741a3 100644 --- a/BizHawk.MultiClient/Config.cs +++ b/BizHawk.MultiClient/Config.cs @@ -344,6 +344,23 @@ namespace BizHawk.MultiClient public int NESTopLine = 8; public int NESBottomLine = 231; + // SNES Graphics settings + //bsnes allows the layers to be enabled for each priority level. + //this may not be important for the bg (there are two priority levels) + //but it may be useful for OBJ, so we might want to control them separately + public bool SNES_ShowBG1_0 = true; + public bool SNES_ShowBG2_0 = true; + public bool SNES_ShowBG3_0 = true; + public bool SNES_ShowBG4_0 = true; + public bool SNES_ShowBG1_1 = true; + public bool SNES_ShowBG2_1 = true; + public bool SNES_ShowBG3_1 = true; + public bool SNES_ShowBG4_1 = true; + public bool SNES_ShowOBJ_0 = true; + public bool SNES_ShowOBJ_1 = true; + public bool SNES_ShowOBJ_2 = true; + public bool SNES_ShowOBJ_3 = true; + // PCE Graphics settings public bool PCEDispBG1 = true; public bool PCEDispOBJ1= true; diff --git a/BizHawk.MultiClient/MainForm.cs b/BizHawk.MultiClient/MainForm.cs index ff43657d84..69184d168b 100644 --- a/BizHawk.MultiClient/MainForm.cs +++ b/BizHawk.MultiClient/MainForm.cs @@ -341,6 +341,19 @@ namespace BizHawk.MultiClient Global.CoreInputComm.PCE_ShowOBJ2 = Global.Config.PCEDispOBJ2; Global.CoreInputComm.SMS_ShowBG = Global.Config.SMSDispBG; Global.CoreInputComm.SMS_ShowOBJ = Global.Config.SMSDispOBJ; + + Global.CoreInputComm.SNES_ShowBG1_0 = Global.Config.SNES_ShowBG1_0; + Global.CoreInputComm.SNES_ShowBG1_1 = Global.Config.SNES_ShowBG1_1; + Global.CoreInputComm.SNES_ShowBG2_0 = Global.Config.SNES_ShowBG2_0; + Global.CoreInputComm.SNES_ShowBG2_1 = Global.Config.SNES_ShowBG2_1; + Global.CoreInputComm.SNES_ShowBG3_0 = Global.Config.SNES_ShowBG3_0; + Global.CoreInputComm.SNES_ShowBG3_1 = Global.Config.SNES_ShowBG3_1; + Global.CoreInputComm.SNES_ShowBG4_0 = Global.Config.SNES_ShowBG4_0; + Global.CoreInputComm.SNES_ShowBG4_1 = Global.Config.SNES_ShowBG4_1; + Global.CoreInputComm.SNES_ShowOBJ_0 = Global.Config.SNES_ShowOBJ_0; + Global.CoreInputComm.SNES_ShowOBJ_1 = Global.Config.SNES_ShowOBJ_1; + Global.CoreInputComm.SNES_ShowOBJ_2 = Global.Config.SNES_ShowOBJ_2; + Global.CoreInputComm.SNES_ShowOBJ_3 = Global.Config.SNES_ShowOBJ_3; } void SyncPresentationMode() diff --git a/BizHawk.MultiClient/output/snes.dll b/BizHawk.MultiClient/output/snes.dll index ae399fe318..8f09969672 100644 Binary files a/BizHawk.MultiClient/output/snes.dll and b/BizHawk.MultiClient/output/snes.dll differ diff --git a/libsnes/bsnes/snes/system/system.cpp b/libsnes/bsnes/snes/system/system.cpp index 9b70bbf907..fddfc94df3 100644 --- a/libsnes/bsnes/snes/system/system.cpp +++ b/libsnes/bsnes/snes/system/system.cpp @@ -247,3 +247,10 @@ System::System() { } } + + +//zero 04-sep-2012 +extern "C" void snes_set_layer_enable(int layer, int priority, bool enable) +{ + SNES::ppu.layer_enable(layer, priority, enable); +} diff --git a/libsnes/bsnes/target-libsnes/libsnes.hpp b/libsnes/bsnes/target-libsnes/libsnes.hpp index f7e4d1bfea..bb83e19894 100644 --- a/libsnes/bsnes/target-libsnes/libsnes.hpp +++ b/libsnes/bsnes/target-libsnes/libsnes.hpp @@ -130,6 +130,7 @@ unsigned snes_get_memory_size(unsigned id); //zeromus additions bool snes_check_cartridge(const uint8_t *rom_data, unsigned rom_size); +void snes_set_layer_enable(int layer, int priority, bool enable); #ifdef __cplusplus }