quicknes: support getcpuflagsandregisters
This commit is contained in:
parent
e68e691e3c
commit
ab74f31d41
|
@ -45,22 +45,6 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
|
||||||
[DllImport(dllname, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(dllname, CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern IntPtr qn_set_sample_rate(IntPtr e, int rate);
|
public static extern IntPtr qn_set_sample_rate(IntPtr e, int rate);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// get required min dimensions of output video buffer (8bpp)
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="e">context</param>
|
|
||||||
/// <param name="width">width</param>
|
|
||||||
/// <param name="height">height</param>
|
|
||||||
//[DllImport(dllname, CallingConvention = CallingConvention.Cdecl)]
|
|
||||||
//public static extern void qn_get_image_dimensions(IntPtr e, ref int width, ref int height);
|
|
||||||
/// <summary>
|
|
||||||
/// set output video buffer that will be used for all subsequent renders until replaced
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="e">context</param>
|
|
||||||
/// <param name="dest">8bpp, at least as big as qn_get_image_dimensions()</param>
|
|
||||||
/// <param name="pitch">byte pitch</param>
|
|
||||||
//[DllImport(dllname, CallingConvention = CallingConvention.Cdecl)]
|
|
||||||
//public static extern void qn_set_pixels(IntPtr e, IntPtr dest, int pitch);
|
|
||||||
/// <summary>
|
|
||||||
/// emulate a single frame
|
/// emulate a single frame
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="e">context</param>
|
/// <param name="e">context</param>
|
||||||
|
@ -216,6 +200,13 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
|
||||||
[DllImport(dllname, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(dllname, CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern void qn_poke_prgbus(IntPtr e, int addr, byte val);
|
public static extern void qn_poke_prgbus(IntPtr e, int addr, byte val);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// get internal registers
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="e">Context</param>
|
||||||
|
/// <param name="dest">a, x, y, sp, pc, p</param>
|
||||||
|
[DllImport(dllname, CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
public static extern void qn_get_cpuregs(IntPtr e, [Out] int[] dest);
|
||||||
|
/// <summary>
|
||||||
/// get the mapper that's loaded
|
/// get the mapper that's loaded
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="e">Context</param>
|
/// <param name="e">Context</param>
|
||||||
|
|
|
@ -361,7 +361,16 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
|
||||||
|
|
||||||
public Dictionary<string, int> GetCpuFlagsAndRegisters()
|
public Dictionary<string, int> GetCpuFlagsAndRegisters()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
int[] regs = new int[6];
|
||||||
|
var ret = new Dictionary<string, int>();
|
||||||
|
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
|
#endregion
|
||||||
|
@ -494,11 +503,6 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
|
||||||
LibQuickNES.qn_delete(Context);
|
LibQuickNES.qn_delete(Context);
|
||||||
Context = IntPtr.Zero;
|
Context = IntPtr.Zero;
|
||||||
}
|
}
|
||||||
//if (VideoInput != null)
|
|
||||||
//{
|
|
||||||
// VideoInputH.Free();
|
|
||||||
// VideoInput = null;
|
|
||||||
//}
|
|
||||||
if (VideoOutput != null)
|
if (VideoOutput != null)
|
||||||
{
|
{
|
||||||
VideoOutputH.Free();
|
VideoOutputH.Free();
|
||||||
|
@ -509,8 +513,6 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
|
||||||
#region VideoProvider
|
#region VideoProvider
|
||||||
|
|
||||||
int[] VideoOutput;
|
int[] VideoOutput;
|
||||||
//byte[] VideoInput;
|
|
||||||
//GCHandle VideoInputH;
|
|
||||||
GCHandle VideoOutputH;
|
GCHandle VideoOutputH;
|
||||||
|
|
||||||
int cropleft = 0;
|
int cropleft = 0;
|
||||||
|
@ -528,11 +530,6 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
|
||||||
|
|
||||||
void InitVideo()
|
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];
|
VideoOutput = new int[256 * 240];
|
||||||
VideoOutputH = GCHandle.Alloc(VideoOutput, GCHandleType.Pinned);
|
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);
|
NumSamples = LibQuickNES.qn_read_audio(Context, MonoBuff, MonoBuff.Length);
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
fixed (short *_src = &MonoBuff[0], _dst = &StereoBuff[0])
|
fixed (short* _src = &MonoBuff[0], _dst = &StereoBuff[0])
|
||||||
{
|
{
|
||||||
short* src = _src;
|
short* src = _src;
|
||||||
short* dst = _dst;
|
short* dst = _dst;
|
||||||
|
@ -579,7 +576,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
|
||||||
*dst++ = *src++;
|
*dst++ = *src++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
short[] MonoBuff = new short[1024];
|
short[] MonoBuff = new short[1024];
|
||||||
|
|
Binary file not shown.
|
@ -49,19 +49,6 @@ EXPORT const char *qn_set_sample_rate(Nes_Emu *e, int rate)
|
||||||
return ret;
|
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)
|
EXPORT const char *qn_emulate_frame(Nes_Emu *e, int pad1, int pad2)
|
||||||
{
|
{
|
||||||
return e->emulate_frame(pad1, 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);
|
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)
|
EXPORT const char *qn_get_mapper(Nes_Emu *e, int *number)
|
||||||
{
|
{
|
||||||
int m = e->cart()->mapper_code();
|
int m = e->cart()->mapper_code();
|
||||||
|
|
|
@ -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}
|
{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;
|
||||||
|
}
|
||||||
|
|
|
@ -204,6 +204,7 @@ public:
|
||||||
byte peek_prg(nes_addr_t addr) const { return *static_cast<Nes_Cpu>(emu).get_code(addr); }
|
byte peek_prg(nes_addr_t addr) const { return *static_cast<Nes_Cpu>(emu).get_code(addr); }
|
||||||
void poke_prg(nes_addr_t addr, byte value) { *static_cast<Nes_Cpu>(emu).get_code(addr) = value; }
|
void poke_prg(nes_addr_t addr, byte value) { *static_cast<Nes_Cpu>(emu).get_code(addr) = value; }
|
||||||
|
|
||||||
|
void get_regs(unsigned int *dest) const;
|
||||||
|
|
||||||
// End of public interface
|
// End of public interface
|
||||||
public:
|
public:
|
||||||
|
@ -271,4 +272,3 @@ inline long Nes_Emu::chr_size() const
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue