update libsnes building for new output directory, and add support for exec/read/write/nmi/irq hooks
This commit is contained in:
parent
ed5cfe39a6
commit
7a260abb54
|
@ -46,7 +46,7 @@
|
|||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<UseVSHostingProcess>true</UseVSHostingProcess>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
|
|
|
@ -389,7 +389,18 @@ namespace BizHawk.Emulation.Consoles.Nintendo.SNES
|
|||
|
||||
eMessage_SetBuffer,
|
||||
eMessage_BeginBufferIO,
|
||||
eMessage_EndBufferIO
|
||||
eMessage_EndBufferIO,
|
||||
|
||||
eMessage_set_state_hook_exec,
|
||||
eMessage_set_state_hook_read,
|
||||
eMessage_set_state_hook_write,
|
||||
eMessage_set_state_hook_nmi,
|
||||
eMessage_set_state_hook_irq,
|
||||
eMessage_snes_cb_hook_exec,
|
||||
eMessage_snes_cb_hook_read,
|
||||
eMessage_snes_cb_hook_write,
|
||||
eMessage_snes_cb_hook_nmi,
|
||||
eMessage_snes_cb_hook_irq,
|
||||
};
|
||||
|
||||
static bool DryRun(string exePath)
|
||||
|
@ -635,6 +646,12 @@ namespace BizHawk.Emulation.Consoles.Nintendo.SNES
|
|||
public void snes_term() { WritePipeMessage(eMessage.eMessage_snes_term); }
|
||||
public void snes_unload_cartridge() { WritePipeMessage(eMessage.eMessage_snes_unload_cartridge); }
|
||||
|
||||
public void snes_set_state_hook_exec(bool state)
|
||||
{
|
||||
WritePipeMessage(eMessage.eMessage_set_state_hook_exec);
|
||||
bwPipe.Write(state);
|
||||
}
|
||||
|
||||
public bool snes_load_cartridge_super_game_boy(string rom_xml, byte[] rom_data, uint rom_size, string dmg_xml, byte[] dmg_data, uint dmg_size)
|
||||
{
|
||||
WritePipeMessage(eMessage.eMessage_snes_load_cartridge_super_game_boy);
|
||||
|
@ -932,6 +949,29 @@ namespace BizHawk.Emulation.Consoles.Nintendo.SNES
|
|||
SharedMemoryBlocks.Remove(name);
|
||||
break;
|
||||
}
|
||||
|
||||
case eMessage.eMessage_snes_cb_hook_exec:
|
||||
{
|
||||
var addr = brPipe.ReadInt32();
|
||||
//Console.WriteLine("received hook messages from libsnes\n");
|
||||
//not sure how to shuttle these out of an emu core yet. do we have mechanisms for that?
|
||||
break;
|
||||
}
|
||||
case eMessage.eMessage_snes_cb_hook_read:
|
||||
{
|
||||
var addr = brPipe.ReadInt32();
|
||||
break;
|
||||
}
|
||||
case eMessage.eMessage_snes_cb_hook_write:
|
||||
{
|
||||
var addr = brPipe.ReadInt32();
|
||||
var value = brPipe.ReadByte();
|
||||
break;
|
||||
}
|
||||
case eMessage.eMessage_snes_cb_hook_nmi:
|
||||
break;
|
||||
case eMessage.eMessage_snes_cb_hook_irq:
|
||||
break;
|
||||
}
|
||||
}
|
||||
} //WaitForCompletion()
|
||||
|
|
|
@ -259,6 +259,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo.SNES
|
|||
CoreComm.CpuTraceAvailable = true;
|
||||
|
||||
api.snes_power();
|
||||
api.snes_set_state_hook_exec(true);
|
||||
|
||||
SetupMemoryDomains(romData,sgbRomData);
|
||||
|
||||
|
|
|
@ -15,10 +15,10 @@ if [ "$1" == "32" ]; then
|
|||
fi
|
||||
|
||||
#debug:
|
||||
#export BIZWINCFLAGS="-I. -O0 -g -masm=intel -DLIBCO_IMPORT -DLIBCO_MSVC -static-libgcc -static-libstdc++"
|
||||
#export BIZWINCFLAGS="-I. -O0 -g -masm=intel -DHOOKS -DLIBCO_IMPORT -DLIBCO_MSVC -static-libgcc -static-libstdc++"
|
||||
|
||||
#not debug
|
||||
export BIZWINCFLAGS="-I. -O3 -masm=intel -static-libgcc -static-libstdc++ ${cflags64}"
|
||||
export BIZWINCFLAGS="-I. -O3 -masm=intel -DHOOKS -static-libgcc -static-libstdc++ ${cflags64}"
|
||||
|
||||
export TARGET_LIBSNES_LIBDEPS="-L ../libco_msvc_win32/release/ -static -static-libgcc -static-libstdc++ ${cflags64} ${cflags32} -mwindows"
|
||||
export profile=$2
|
||||
|
@ -28,7 +28,7 @@ platform=win target=libsnes make -e -j 4
|
|||
cd ..
|
||||
|
||||
filename=libsneshawk-${bits}-${profile}.exe
|
||||
targetdir=../BizHawk.MultiClient/output/dll
|
||||
targetdir=../output/dll
|
||||
targetpath=${targetdir}/${filename}
|
||||
cp bsnes/out/${filename} ${targetdir}
|
||||
if [ "$3" == "compress" ]; then
|
||||
|
|
|
@ -32,7 +32,7 @@ template<typename R, typename... P> struct hook<R (P...)> {
|
|||
function<R (P...)> callback;
|
||||
|
||||
R operator()(P... p) const {
|
||||
#if defined(DEBUGGER)
|
||||
#if defined(DEBUGGER) || defined(HOOKS)
|
||||
if(callback) return callback(std::forward<P>(p)...);
|
||||
#endif
|
||||
return R();
|
||||
|
|
|
@ -135,6 +135,7 @@ privileged:
|
|||
static void Enter();
|
||||
void op_step();
|
||||
|
||||
public:
|
||||
struct Debugger {
|
||||
hook<void (uint24)> op_exec;
|
||||
hook<void (uint24)> op_read;
|
||||
|
|
|
@ -169,7 +169,7 @@ HANDLE hPipe, hMapFile;
|
|||
void* hMapFilePtr;
|
||||
static bool running = false;
|
||||
|
||||
enum eMessage : int
|
||||
enum eMessage : int32
|
||||
{
|
||||
eMessage_Complete,
|
||||
|
||||
|
@ -228,7 +228,18 @@ enum eMessage : int
|
|||
|
||||
eMessage_SetBuffer,
|
||||
eMessage_BeginBufferIO,
|
||||
eMessage_EndBufferIO
|
||||
eMessage_EndBufferIO,
|
||||
|
||||
eMessage_set_state_hook_exec,
|
||||
eMessage_set_state_hook_read,
|
||||
eMessage_set_state_hook_write,
|
||||
eMessage_set_state_hook_nmi,
|
||||
eMessage_set_state_hook_irq,
|
||||
eMessage_snes_cb_hook_exec,
|
||||
eMessage_snes_cb_hook_read,
|
||||
eMessage_snes_cb_hook_write,
|
||||
eMessage_snes_cb_hook_nmi,
|
||||
eMessage_snes_cb_hook_irq,
|
||||
};
|
||||
|
||||
void ReadPipeBuffer(void* buf, int len)
|
||||
|
@ -474,6 +485,36 @@ void InitBsnes()
|
|||
snes_set_freeSharedMemory(snes_freeSharedMemory);
|
||||
}
|
||||
|
||||
|
||||
static void debug_op_exec(uint24 addr)
|
||||
{
|
||||
WritePipe(eMessage_snes_cb_hook_exec);
|
||||
WritePipe((uint32)addr);
|
||||
}
|
||||
|
||||
static void debug_op_read(uint24 addr)
|
||||
{
|
||||
WritePipe(eMessage_snes_cb_hook_read);
|
||||
WritePipe((uint32)addr);
|
||||
}
|
||||
|
||||
static void debug_op_write(uint24 addr, uint8 value)
|
||||
{
|
||||
WritePipe(eMessage_snes_cb_hook_write);
|
||||
WritePipe((uint32)addr);
|
||||
WritePipe(value);
|
||||
}
|
||||
|
||||
static void debug_op_nmi()
|
||||
{
|
||||
WritePipe(eMessage_snes_cb_hook_nmi);
|
||||
}
|
||||
|
||||
static void debug_op_irq()
|
||||
{
|
||||
WritePipe(eMessage_snes_cb_hook_irq);
|
||||
}
|
||||
|
||||
void RunMessageLoop()
|
||||
{
|
||||
for(;;)
|
||||
|
@ -689,6 +730,26 @@ void RunMessageLoop()
|
|||
bufio = false;
|
||||
break;
|
||||
|
||||
case eMessage_set_state_hook_exec:
|
||||
SNES::cpu.debugger.op_exec = ReadPipe<bool>() ? debug_op_exec : hook<void (uint24)>();
|
||||
break;
|
||||
|
||||
case eMessage_set_state_hook_read:
|
||||
SNES::cpu.debugger.op_read = ReadPipe<bool>() ? debug_op_read : hook<void (uint24)>();
|
||||
break;
|
||||
|
||||
case eMessage_set_state_hook_write:
|
||||
SNES::cpu.debugger.op_write = ReadPipe<bool>() ? debug_op_write : hook<void (uint24, uint8)>();
|
||||
break;
|
||||
|
||||
case eMessage_set_state_hook_nmi:
|
||||
SNES::cpu.debugger.op_nmi = ReadPipe<bool>() ? debug_op_nmi : hook<void ()>();
|
||||
break;
|
||||
|
||||
case eMessage_set_state_hook_irq:
|
||||
SNES::cpu.debugger.op_irq = ReadPipe<bool>() ? debug_op_irq : hook<void ()>();
|
||||
break;
|
||||
|
||||
} //switch(msg)
|
||||
}
|
||||
}
|
||||
|
@ -764,5 +825,6 @@ int CALLBACK WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine
|
|||
|
||||
void pwrap_init()
|
||||
{
|
||||
//bsnes's interface initialization calls into this after initializing itself, so we can get a chance to mod it for pwrap functionalities
|
||||
InitBsnes();
|
||||
}
|
Binary file not shown.
Loading…
Reference in New Issue