diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesApi_BRK.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesApi_BRK.cs index c0f9c1271e..e312640397 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesApi_BRK.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesApi_BRK.cs @@ -32,10 +32,20 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES WriteHook((uint)addr, value); break; } + + //not supported yet case eMessage.eMessage_BRK_hook_nmi: break; case eMessage.eMessage_BRK_hook_irq: break; + + case eMessage.eMessage_BRK_scanlineStart: + int line = brPipe.ReadInt32(); + if (scanlineStart != null) + scanlineStart(line); + SPECIAL_Resume(); + break; + } //switch(msg) return true; } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesApi_Enums.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesApi_Enums.cs index affb989217..02acdcd22c 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesApi_Enums.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesApi_Enums.cs @@ -61,7 +61,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES eMessage_SIG_input_state, eMessage_SIG_input_notify, eMessage_SIG_audio_flush, - eMessage_SIG_scanlineStart, eMessage_SIG_path_request, eMessage_SIG_trace_callback, eMessage_SIG_allocSharedMemory, //? @@ -73,6 +72,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES eMessage_BRK_hook_write, eMessage_BRK_hook_nmi, eMessage_BRK_hook_irq, + eMessage_BRK_scanlineStart, }; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesApi_SIG.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesApi_SIG.cs index ffae4c7275..15f3a602dc 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesApi_SIG.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesApi_SIG.cs @@ -70,17 +70,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES brPipe.ReadInt32(); //dummy synchronization break; } - case eMessage.eMessage_SIG_scanlineStart: - { - int line = brPipe.ReadInt32(); - if (scanlineStart != null) - scanlineStart(line); - - //we have to notify the unmanaged process that we're done peeking thruogh its memory and whatnot so it can proceed with emulation - //HUM??????????? BRK_COMPLETE???? SCANLINE CB NEEDS RE-EVALUATING - WritePipeMessage(eMessage.eMessage_BRK_Complete); - break; - } case eMessage.eMessage_SIG_path_request: { int slot = brPipe.ReadInt32(); diff --git a/libsnes/bsnes/target-libsnes/libsnes_pwrap.cpp b/libsnes/bsnes/target-libsnes/libsnes_pwrap.cpp index 9ff8c34e27..ddb22c5d0b 100644 --- a/libsnes/bsnes/target-libsnes/libsnes_pwrap.cpp +++ b/libsnes/bsnes/target-libsnes/libsnes_pwrap.cpp @@ -95,7 +95,6 @@ enum eMessage : int32 eMessage_SIG_input_state, eMessage_SIG_input_notify, eMessage_SIG_audio_flush, - eMessage_SIG_scanlineStart, eMessage_SIG_path_request, eMessage_SIG_trace_callback, eMessage_SIG_allocSharedMemory, //? @@ -107,6 +106,7 @@ enum eMessage : int32 eMessage_BRK_hook_write, eMessage_BRK_hook_nmi, eMessage_BRK_hook_irq, + eMessage_BRK_scanlineStart, //implemented as a BRK because that's really what it is, its just a graphical event and not a CPU event }; @@ -122,6 +122,7 @@ enum eEmulationCallback { eEmulationCallback_snes_video_refresh, eEmulationCallback_snes_audio_flush, + eEmulationCallback_snes_scanline, eEmulationCallback_snes_input_poll, eEmulationCallback_snes_input_state, eEmulationCallback_snes_input_notify, @@ -162,6 +163,10 @@ struct EmulationControl unsigned height; } cb_video_refresh_params; struct + { + int32_t scanline; + } cb_scanline_params; + struct { unsigned port, device, index, id; int16_t result; @@ -552,14 +557,10 @@ const char* snes_path_request(int slot, const char* hint) void RunControlMessageLoop(); void snes_scanlineStart(int line) { - //TODO - //WritePipe(eMessage_snes_cb_scanlineStart); - //WritePipe(line); - - ////we've got to wait for the frontend to finish processing. - ////in theory we could let emulation proceed after snagging the vram and registers, and do decoding and stuff on another thread... - ////but its too hard for now. - //RunMessageLoop(); + s_EmulationControl.exitReason = eEmulationExitReason_BRK; + s_EmulationControl.hookExitType = eMessage_BRK_scanlineStart; + s_EmulationControl.cb_scanline_params.scanline = line; + SETCONTROL; } class SharedMemoryBlock @@ -979,9 +980,10 @@ TOP: char* buf = (char*)hMapFilePtr + destOfs; int bufsize = 512 * 480 * 4; memcpy(buf,s_EmulationControl.cb_video_refresh_params.data,bufsize); - WritePipe((char)0); //dummy synchronization + WritePipe((char)0); //dummy synchronization (alert frontend we're done with buffer) break; } + case eEmulationCallback_snes_audio_flush: Handle_SIG_audio_flush(); break; @@ -1029,6 +1031,10 @@ TOP: s_EmulationControl.exitReason = eEmulationExitReason_NotSet; switch(s_EmulationControl.hookExitType) { + case eMessage_BRK_scanlineStart: + WritePipe(eMessage_BRK_scanlineStart); + WritePipe((uint32)s_EmulationControl.hookAddr); + break; case eMessage_BRK_hook_exec: WritePipe(eMessage_BRK_hook_exec); WritePipe((uint32)s_EmulationControl.hookAddr); diff --git a/output/dll/libsneshawk-32-compatibility.dll b/output/dll/libsneshawk-32-compatibility.dll index b8e06af9bd..fea764ec23 100644 Binary files a/output/dll/libsneshawk-32-compatibility.dll and b/output/dll/libsneshawk-32-compatibility.dll differ diff --git a/output/dll/libsneshawk-32-performance.dll b/output/dll/libsneshawk-32-performance.dll index 559da54ce0..1d1e77fbf5 100644 Binary files a/output/dll/libsneshawk-32-performance.dll and b/output/dll/libsneshawk-32-performance.dll differ