m64p: attempt to add execute callback

no memory callback seems to be working yet though
This commit is contained in:
feos 2016-08-11 21:56:55 +03:00
parent 8eaba2e40f
commit 80c90e7acc
9 changed files with 68 additions and 12 deletions

View File

@ -564,7 +564,7 @@ namespace BizHawk.Client.EmuHawk
base.Dispose(disposing);
}
#endregion`
#endregion
#region Pause

View File

@ -531,6 +531,9 @@
<Compile Include="Consoles\Nintendo\N64\N64.IStatable.cs">
<DependentUpon>N64.cs</DependentUpon>
</Compile>
<Compile Include="Consoles\Nintendo\N64\N64.ITraceable.cs">
<DependentUpon>N64.cs</DependentUpon>
</Compile>
<Compile Include="Consoles\Nintendo\N64\N64Input.cs" />
<Compile Include="Consoles\Nintendo\N64\N64Settings.cs" />
<Compile Include="Consoles\Nintendo\N64\N64SyncSettings.Controller.cs" />
@ -899,15 +902,35 @@
<Compile Include="Consoles\Sega\Saturn\Yabause.IStatable.cs">
<DependentUpon>Yabause.cs</DependentUpon>
</Compile>
<Compile Include="Consoles\Sega\SMS\SMS.ICodeDataLogger.cs" />
<Compile Include="Consoles\Sega\SMS\SMS.IDebuggable.cs" />
<Compile Include="Consoles\Sega\SMS\SMS.IEmulator.cs" />
<Compile Include="Consoles\Sega\SMS\SMS.IInputPollable.cs" />
<Compile Include="Consoles\Sega\SMS\SMS.IMemoryDomains.cs" />
<Compile Include="Consoles\Sega\SMS\SMS.Input.cs" />
<Compile Include="Consoles\Sega\SMS\SMS.ISaveRam.cs" />
<Compile Include="Consoles\Sega\SMS\SMS.ISettable.cs" />
<Compile Include="Consoles\Sega\SMS\SMS.IStatable.cs" />
<Compile Include="Consoles\Sega\SMS\SMS.cs" />
<Compile Include="Consoles\Sega\SMS\SMS.ICodeDataLogger.cs">
<DependentUpon>SMS.cs</DependentUpon>
</Compile>
<Compile Include="Consoles\Sega\SMS\SMS.IDebuggable.cs">
<DependentUpon>SMS.cs</DependentUpon>
</Compile>
<Compile Include="Consoles\Sega\SMS\SMS.IEmulator.cs">
<DependentUpon>SMS.cs</DependentUpon>
</Compile>
<Compile Include="Consoles\Sega\SMS\SMS.IInputPollable.cs">
<DependentUpon>SMS.cs</DependentUpon>
</Compile>
<Compile Include="Consoles\Sega\SMS\SMS.IMemoryDomains.cs">
<DependentUpon>SMS.cs</DependentUpon>
</Compile>
<Compile Include="Consoles\Sega\SMS\SMS.Input.cs">
<DependentUpon>SMS.cs</DependentUpon>
</Compile>
<Compile Include="Consoles\Sega\SMS\SMS.ISaveRam.cs">
<DependentUpon>SMS.cs</DependentUpon>
</Compile>
<Compile Include="Consoles\Sega\SMS\SMS.ISettable.cs">
<DependentUpon>SMS.cs</DependentUpon>
</Compile>
<Compile Include="Consoles\Sega\SMS\SMS.IStatable.cs">
<DependentUpon>SMS.cs</DependentUpon>
</Compile>
<Compile Include="Consoles\Sega\SMS\VDP.cs" />
<Compile Include="Consoles\Sega\SMS\TerebiOekaki.cs" />
<Compile Include="Consoles\Sega\SMS\MemoryMap.Korea.cs" />
<Compile Include="Consoles\Sega\SMS\MemoryMap.ExtRam.cs" />
@ -1003,8 +1026,6 @@
<Compile Include="Consoles\Sega\Genesis\GenVDP.Render.cs" />
<Compile Include="Consoles\Sega\Genesis\MemoryMap.68000.cs" />
<Compile Include="Consoles\Sega\Genesis\MemoryMap.Z80.cs" />
<Compile Include="Consoles\Sega\SMS\SMS.cs" />
<Compile Include="Consoles\Sega\SMS\VDP.cs" />
<Compile Include="Sound\CDAudio.cs" />
<Compile Include="Sound\HuC6280PSG.cs" />
<Compile Include="Sound\MMC5Audio.cs" />

View File

@ -69,6 +69,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64
private mupen64plusApi.MemoryCallback _readcb;
private mupen64plusApi.MemoryCallback _writecb;
private mupen64plusApi.MemoryCallback _executecb;
private void RefreshMemoryCallbacks()
{
@ -93,8 +94,18 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64
_writecb = null;
}
if (mcs.HasExecutes)
{
_executecb = delegate(uint addr) { mcs.CallExecutes(addr); };
}
else
{
_executecb = null;
}
api.setReadCallback(_readcb);
api.setWriteCallback(_writecb);
api.setExecuteCallback(_executecb);
}
}
}

View File

@ -364,6 +364,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64.NativeApi
public delegate void SetWriteCallback(MemoryCallback callback);
SetWriteCallback m64pSetWriteCallback;
/// <summary>
/// Sets the memory execute callback
/// </summary>
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void SetExecuteCallback(MemoryCallback callback);
SetExecuteCallback m64pSetExecuteCallback;
/// <summary>
/// Gets the CPU registers
/// </summary>
@ -497,6 +504,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64.NativeApi
m64pSetReadCallback = (SetReadCallback)Marshal.GetDelegateForFunctionPointer(GetProcAddress(CoreDll, "SetReadCallback"), typeof(SetReadCallback));
m64pSetWriteCallback = (SetWriteCallback)Marshal.GetDelegateForFunctionPointer(GetProcAddress(CoreDll, "SetWriteCallback"), typeof(SetWriteCallback));
m64pSetExecuteCallback = (SetExecuteCallback)Marshal.GetDelegateForFunctionPointer(GetProcAddress(CoreDll, "SetExecuteCallback"), typeof(SetExecuteCallback));
m64pGetRegisters = (GetRegisters)Marshal.GetDelegateForFunctionPointer(GetProcAddress(CoreDll, "GetRegisters"), typeof(GetRegisters));
@ -647,6 +655,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64.NativeApi
m64pSetWriteCallback(callback);
}
public void setExecuteCallback(MemoryCallback callback)
{
m64pSetExecuteCallback(callback);
}
public void getRegisters(byte[] dest)
{
m64pGetRegisters(dest);

View File

@ -135,6 +135,7 @@ static int firstFrameBufferSetting;
void (*readCB)(unsigned int) = NULL;
void (*writeCB)(unsigned int) = NULL;
void (*executeCB)(unsigned int) = NULL;
// uncomment to output count of calls to write_rdram():
//#define COUNT_WRITE_RDRAM_CALLS 1
@ -4043,4 +4044,9 @@ EXPORT void CALL SetReadCallback(void (*CB)(unsigned int))
EXPORT void CALL SetWriteCallback(void (*CB)(unsigned int))
{
writeCB = CB;
}
EXPORT void CALL SetExecuteCallback(void (*CB)(unsigned int))
{
executeCB = CB;
}

View File

@ -26,6 +26,7 @@
#define READCB() if (readCB) readCB(address)
#define WRITECB() if (writeCB) writeCB(address)
#define EXECUTECB() if (executeCB) executeCB(PC->addr)
#define READCBADDR(addr) if (readCB) readCB(addr)
#define WRITECBADDR(addr) if (writeCB) writeCB(addr)
@ -54,6 +55,8 @@ extern unsigned char cpu_byte;
extern unsigned short hword;
extern unsigned long long dword, *rdword;
extern void (*executeCB)(unsigned int);
extern void (*readmem[0x10000])(void);
extern void (*readmemb[0x10000])(void);
extern void (*readmemh[0x10000])(void);

View File

@ -419,6 +419,7 @@ void pure_interpreter(void)
#ifdef DBG
if (g_DebuggerActive) update_debugger(PC->addr);
#endif
EXECUTECB();
PC->ops();
}
}

View File

@ -1068,6 +1068,7 @@ void r4300_execute(void (*startcb)(void))
#ifdef DBG
if (g_DebuggerActive) update_debugger(PC->addr);
#endif
EXECUTECB();
PC->ops();
}

Binary file not shown.