quicknes: add "System Bus". note that this System Bus will not resolve any MMIO stuff at all

This commit is contained in:
goyuken 2014-01-06 23:23:47 +00:00
parent 86024d2347
commit 45e5f4b286
5 changed files with 69 additions and 18 deletions

View File

@ -192,6 +192,22 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
/// <returns></returns>
[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);
/// <summary>
/// peek the system bus
/// </summary>
/// <param name="e">Context</param>
/// <param name="addr">0000:ffff, but non-ram/rom addresses won't work</param>
/// <returns></returns>
[DllImport(dllname, CallingConvention = CallingConvention.Cdecl)]
public static extern byte qn_peek_prgbus(IntPtr e, int addr);
/// <summary>
/// poke the system bus
/// </summary>
/// <param name="e">Context</param>
/// <param name="addr">0000:ffff, but non-ram/rom addresses won't work</param>
/// <param name="val"></param>
[DllImport(dllname, CallingConvention = CallingConvention.Cdecl)]
public static extern void qn_poke_prgbus(IntPtr e, int addr, byte val);
/// <summary>
/// handle "string error" as returned by some quicknes functions

View File

@ -308,9 +308,29 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
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);
}

Binary file not shown.

View File

@ -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);
}

View File

@ -198,6 +198,11 @@ public:
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<Nes_Cpu>(emu).get_code(addr); }
void poke_prg(nes_addr_t addr, byte value) { *static_cast<Nes_Cpu>(emu).get_code(addr) = value; }
// End of public interface
public:
blargg_err_t set_sample_rate( long rate, class Nes_Buffer* );