diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/LibQuickNES.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/LibQuickNES.cs
index 6eab122a15..79d83b72b1 100644
--- a/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/LibQuickNES.cs
+++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/LibQuickNES.cs
@@ -192,6 +192,22 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
///
[DllImport(dllname, CallingConvention = CallingConvention.Cdecl)]
public static extern bool qn_get_memory_area(IntPtr e, int which, ref IntPtr data, ref int size, ref bool writable, ref IntPtr name);
+ ///
+ /// peek the system bus
+ ///
+ /// Context
+ /// 0000:ffff, but non-ram/rom addresses won't work
+ ///
+ [DllImport(dllname, CallingConvention = CallingConvention.Cdecl)]
+ public static extern byte qn_peek_prgbus(IntPtr e, int addr);
+ ///
+ /// poke the system bus
+ ///
+ /// Context
+ /// 0000:ffff, but non-ram/rom addresses won't work
+ ///
+ [DllImport(dllname, CallingConvention = CallingConvention.Cdecl)]
+ public static extern void qn_poke_prgbus(IntPtr e, int addr, byte val);
///
/// handle "string error" as returned by some quicknes functions
diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.cs
index d7377adce5..95fc4f827f 100644
--- a/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.cs
+++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.cs
@@ -292,25 +292,45 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
mm.Add(new MemoryDomain
(
- Marshal.PtrToStringAnsi(name),
- size,
- MemoryDomain.Endian.Unknown,
- delegate(int addr)
- {
- if (addr < 0 || addr >= size)
- throw new ArgumentOutOfRangeException();
- return p[addr];
- },
- delegate(int addr, byte val)
- {
- if (!writable)
- return;
- if (addr < 0 || addr >= size)
- throw new ArgumentOutOfRangeException();
- p[addr] = val;
- }));
+ Marshal.PtrToStringAnsi(name),
+ size,
+ MemoryDomain.Endian.Unknown,
+ delegate(int addr)
+ {
+ if (addr < 0 || addr >= size)
+ throw new ArgumentOutOfRangeException();
+ return p[addr];
+ },
+ delegate(int addr, byte val)
+ {
+ if (!writable)
+ return;
+ if (addr < 0 || addr >= size)
+ throw new ArgumentOutOfRangeException();
+ p[addr] = val;
+ }
+ ));
}
}
+ // add system bus
+ mm.Add(new MemoryDomain
+ (
+ "System Bus",
+ 0x10000,
+ MemoryDomain.Endian.Unknown,
+ delegate(int addr)
+ {
+ if (addr < 0 || addr >= 0x10000)
+ throw new ArgumentOutOfRangeException();
+ return LibQuickNES.qn_peek_prgbus(Context, addr);
+ },
+ delegate(int addr, byte val)
+ {
+ if (addr < 0 || addr >= 0x10000)
+ throw new ArgumentOutOfRangeException();
+ LibQuickNES.qn_poke_prgbus(Context, addr, val);
+ }
+ ));
MemoryDomains = new MemoryDomainList(mm, 0);
}
diff --git a/output/dll/libquicknes.dll b/output/dll/libquicknes.dll
index 8b713d283a..b1c2e2ff67 100644
Binary files a/output/dll/libquicknes.dll and b/output/dll/libquicknes.dll differ
diff --git a/quicknes/bizinterface.cpp b/quicknes/bizinterface.cpp
index c35d70e8b0..a8a29374d8 100644
--- a/quicknes/bizinterface.cpp
+++ b/quicknes/bizinterface.cpp
@@ -228,3 +228,13 @@ EXPORT int qn_get_memory_area(Nes_Emu *e, int which, const void **data, int *siz
return 1;
}
}
+
+EXPORT unsigned char qn_peek_prgbus(Nes_Emu *e, int addr)
+{
+ return e->peek_prg(addr & 0xffff);
+}
+
+EXPORT void qn_poke_prgbus(Nes_Emu *e, int addr, unsigned char val)
+{
+ e->poke_prg(addr & 0xffff, val);
+}
diff --git a/quicknes/nes_emu/Nes_Emu.h b/quicknes/nes_emu/Nes_Emu.h
index 81d47f154c..c3394e2154 100644
--- a/quicknes/nes_emu/Nes_Emu.h
+++ b/quicknes/nes_emu/Nes_Emu.h
@@ -197,7 +197,12 @@ public:
// Optional 8K memory
enum { high_mem_size = 0x2000 };
byte* high_mem() { return emu.impl->sram; }
-
+
+// Prg peek/poke for debuggin
+ byte peek_prg(nes_addr_t addr) const { return *static_cast(emu).get_code(addr); }
+ void poke_prg(nes_addr_t addr, byte value) { *static_cast(emu).get_code(addr) = value; }
+
+
// End of public interface
public:
blargg_err_t set_sample_rate( long rate, class Nes_Buffer* );