diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/LibQuickNES.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/LibQuickNES.cs index b73a41009e..8a24442114 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/LibQuickNES.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/LibQuickNES.cs @@ -45,22 +45,6 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES [DllImport(dllname, CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr qn_set_sample_rate(IntPtr e, int rate); /// - /// get required min dimensions of output video buffer (8bpp) - /// - /// context - /// width - /// height - //[DllImport(dllname, CallingConvention = CallingConvention.Cdecl)] - //public static extern void qn_get_image_dimensions(IntPtr e, ref int width, ref int height); - /// - /// set output video buffer that will be used for all subsequent renders until replaced - /// - /// context - /// 8bpp, at least as big as qn_get_image_dimensions() - /// byte pitch - //[DllImport(dllname, CallingConvention = CallingConvention.Cdecl)] - //public static extern void qn_set_pixels(IntPtr e, IntPtr dest, int pitch); - /// /// emulate a single frame /// /// context @@ -216,6 +200,13 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES [DllImport(dllname, CallingConvention = CallingConvention.Cdecl)] public static extern void qn_poke_prgbus(IntPtr e, int addr, byte val); /// + /// get internal registers + /// + /// Context + /// a, x, y, sp, pc, p + [DllImport(dllname, CallingConvention = CallingConvention.Cdecl)] + public static extern void qn_get_cpuregs(IntPtr e, [Out] int[] dest); + /// /// get the mapper that's loaded /// /// Context diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.cs index cf9dcf793e..69701f0ebc 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.cs @@ -361,7 +361,16 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES public Dictionary GetCpuFlagsAndRegisters() { - throw new NotImplementedException(); + int[] regs = new int[6]; + var ret = new Dictionary(); + LibQuickNES.qn_get_cpuregs(Context, regs); + ret["A"] = regs[0]; + ret["X"] = regs[1]; + ret["Y"] = regs[2]; + ret["SP"] = regs[3]; + ret["PC"] = regs[4]; + ret["P"] = regs[5]; + return ret; } #endregion @@ -494,11 +503,6 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES LibQuickNES.qn_delete(Context); Context = IntPtr.Zero; } - //if (VideoInput != null) - //{ - // VideoInputH.Free(); - // VideoInput = null; - //} if (VideoOutput != null) { VideoOutputH.Free(); @@ -509,8 +513,6 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES #region VideoProvider int[] VideoOutput; - //byte[] VideoInput; - //GCHandle VideoInputH; GCHandle VideoOutputH; int cropleft = 0; @@ -528,11 +530,6 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES void InitVideo() { - //int w = 0, h = 0; - //LibQuickNES.qn_get_image_dimensions(Context, ref w, ref h); - //VideoInput = new byte[w * h]; - //VideoInputH = GCHandle.Alloc(VideoInput, GCHandleType.Pinned); - //LibQuickNES.qn_set_pixels(Context, VideoInputH.AddrOfPinnedObject(), w); VideoOutput = new int[256 * 240]; VideoOutputH = GCHandle.Alloc(VideoOutput, GCHandleType.Pinned); } @@ -569,7 +566,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES NumSamples = LibQuickNES.qn_read_audio(Context, MonoBuff, MonoBuff.Length); unsafe { - fixed (short *_src = &MonoBuff[0], _dst = &StereoBuff[0]) + fixed (short* _src = &MonoBuff[0], _dst = &StereoBuff[0]) { short* src = _src; short* dst = _dst; @@ -579,7 +576,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES *dst++ = *src++; } } - } + } } short[] MonoBuff = new short[1024]; diff --git a/output/dll/libquicknes.dll b/output/dll/libquicknes.dll index 3c7a9a64a8..cb306a69f3 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 fd8018d939..764c0a033b 100644 --- a/quicknes/bizinterface.cpp +++ b/quicknes/bizinterface.cpp @@ -49,19 +49,6 @@ EXPORT const char *qn_set_sample_rate(Nes_Emu *e, int rate) return ret; } -//EXPORT void qn_get_image_dimensions(Nes_Emu *e, int *width, int *height) -//{ -// if (width) -// *width = e->buffer_width; -// if (height) -// *height = e->buffer_height(); -//} - -//EXPORT void qn_set_pixels(Nes_Emu *e, void *dest, int pitch) -//{ -// e->set_pixels(dest, pitch); -//} - EXPORT const char *qn_emulate_frame(Nes_Emu *e, int pad1, int pad2) { return e->emulate_frame(pad1, pad2); @@ -260,6 +247,11 @@ EXPORT void qn_poke_prgbus(Nes_Emu *e, int addr, unsigned char val) e->poke_prg(addr & 0xffff, val); } +EXPORT void qn_get_cpuregs(Nes_Emu *e, unsigned int *dest) +{ + e->get_regs(dest); +} + EXPORT const char *qn_get_mapper(Nes_Emu *e, int *number) { int m = e->cart()->mapper_code(); diff --git a/quicknes/nes_emu/Nes_Emu.cpp b/quicknes/nes_emu/Nes_Emu.cpp index a14cae5306..98edee5baa 100644 --- a/quicknes/nes_emu/Nes_Emu.cpp +++ b/quicknes/nes_emu/Nes_Emu.cpp @@ -495,3 +495,12 @@ Nes_Emu::rgb_t const Nes_Emu::nes_colors [color_table_size] = {136,190,197},{184,184,184},{ 0, 0, 0},{ 0, 0, 0} }; +void Nes_Emu::get_regs(unsigned int *dest) const +{ + dest[0] = emu.r.a; + dest[1] = emu.r.x; + dest[2] = emu.r.y; + dest[3] = emu.r.sp; + dest[4] = emu.r.pc; + dest[5] = emu.r.status; +} diff --git a/quicknes/nes_emu/Nes_Emu.h b/quicknes/nes_emu/Nes_Emu.h index cbd53be84f..e0fee4298f 100644 --- a/quicknes/nes_emu/Nes_Emu.h +++ b/quicknes/nes_emu/Nes_Emu.h @@ -204,6 +204,7 @@ public: 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; } + void get_regs(unsigned int *dest) const; // End of public interface public: @@ -271,4 +272,3 @@ inline long Nes_Emu::chr_size() const } #endif -