diff --git a/BizHawk.Emulation/Consoles/Nintendo/SNES/LibsnesCore.cs b/BizHawk.Emulation/Consoles/Nintendo/SNES/LibsnesCore.cs index 1e020944f7..a4036e65f5 100644 --- a/BizHawk.Emulation/Consoles/Nintendo/SNES/LibsnesCore.cs +++ b/BizHawk.Emulation/Consoles/Nintendo/SNES/LibsnesCore.cs @@ -110,6 +110,11 @@ namespace BizHawk.Emulation.Consoles.Nintendo.SNES [DllImport("libsneshawk.dll", CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr snes_get_memory_data(SNES_MEMORY id); + [DllImport("libsneshawk.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern byte bus_read(uint addr); + [DllImport("libsneshawk.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void bus_write(uint addr, byte val); + [DllImport("libsneshawk.dll", CallingConvention = CallingConvention.Cdecl)] public static extern int snes_serialize_size(); @@ -835,6 +840,10 @@ namespace BizHawk.Emulation.Consoles.Nintendo.SNES MakeMemoryDomain("OAM", LibsnesDll.SNES_MEMORY.OAM, Endian.Little); MakeMemoryDomain("CGRAM", LibsnesDll.SNES_MEMORY.CGRAM, Endian.Little); MakeMemoryDomain("APURAM", LibsnesDll.SNES_MEMORY.APURAM, Endian.Little); + + MemoryDomains.Add(new MemoryDomain("BUS", 0x1000000, Endian.Little, + (addr) => LibsnesDll.bus_read((uint)addr), + (addr, val) => LibsnesDll.bus_write((uint)addr, val))); } public IList MemoryDomains { get; private set; } public MemoryDomain MainMemory { get; private set; } diff --git a/BizHawk.MultiClient/output/libsneshawk.dll b/BizHawk.MultiClient/output/libsneshawk.dll index 3b528cf370..4aa906d822 100644 Binary files a/BizHawk.MultiClient/output/libsneshawk.dll and b/BizHawk.MultiClient/output/libsneshawk.dll differ diff --git a/libsnes/bsnes/target-libsnes/libsnes.cpp b/libsnes/bsnes/target-libsnes/libsnes.cpp index eb8270f2c9..af1f8dc193 100644 --- a/libsnes/bsnes/target-libsnes/libsnes.cpp +++ b/libsnes/bsnes/target-libsnes/libsnes.cpp @@ -529,6 +529,13 @@ unsigned snes_get_memory_size(unsigned id) { return size; } +uint8_t bus_read(unsigned addr) { + return SNES::bus.read(addr); +} +void bus_write(unsigned addr, uint8_t val) { + SNES::bus.write(addr, val); +} + int snes_poll_message() { if(interface.messages.size() == 0) return -1; diff --git a/libsnes/bsnes/target-libsnes/libsnes.hpp b/libsnes/bsnes/target-libsnes/libsnes.hpp index 264d8c9169..39fdf993ed 100644 --- a/libsnes/bsnes/target-libsnes/libsnes.hpp +++ b/libsnes/bsnes/target-libsnes/libsnes.hpp @@ -142,6 +142,10 @@ void snes_dequeue_message(char* buffer); typedef const char* (*snes_path_request_t)(int slot, const char* hint); void snes_set_path_request(snes_path_request_t path_request); +// system bus implementation +uint8_t bus_read(unsigned addr); +void bus_write(unsigned addr, uint8_t val); + //$2105 #define SNES_REG_BG_MODE 0 #define SNES_REG_BG3_PRIORITY 1