diff --git a/BizHawk.Emulation/Consoles/Nintendo/N64/N64.cs b/BizHawk.Emulation/Consoles/Nintendo/N64/N64.cs index 38797a22c5..155cc7565b 100644 --- a/BizHawk.Emulation/Consoles/Nintendo/N64/N64.cs +++ b/BizHawk.Emulation/Consoles/Nintendo/N64/N64.cs @@ -360,22 +360,26 @@ namespace BizHawk.Emulation.Consoles.Nintendo.N64 VICallback m64pVICallback; public void FrameComplete() { - uint s = (uint)AudGetAudioRate(); - if (s != m64pSamplingRate) + if (resampler != null) { - m64pSamplingRate = s; - resampler.ChangeRate(s, 44100, s, 44100); - //Console.WriteLine("N64 ARate Change {0}", s); - } + // the way i've fubared up the core, a first framecomplete callback happens in init, before everything is set up + uint s = (uint)AudGetAudioRate(); + if (s != m64pSamplingRate) + { + m64pSamplingRate = s; + resampler.ChangeRate(s, 44100, s, 44100); + //Console.WriteLine("N64 ARate Change {0}", s); + } - int m64pAudioBufferSize = AudGetBufferSize(); - if (m64pAudioBuffer.Length < m64pAudioBufferSize) - m64pAudioBuffer = new short[m64pAudioBufferSize]; + int m64pAudioBufferSize = AudGetBufferSize(); + if (m64pAudioBuffer.Length < m64pAudioBufferSize) + m64pAudioBuffer = new short[m64pAudioBufferSize]; - if (m64pAudioBufferSize > 0) - { - AudReadAudioBuffer(m64pAudioBuffer); - resampler.EnqueueSamples(m64pAudioBuffer, m64pAudioBufferSize / 2); + if (m64pAudioBufferSize > 0) + { + AudReadAudioBuffer(m64pAudioBuffer); + resampler.EnqueueSamples(m64pAudioBuffer, m64pAudioBufferSize / 2); + } } m64pFrameComplete = true; } @@ -487,10 +491,14 @@ namespace BizHawk.Emulation.Consoles.Nintendo.N64 m64pEmulator.Start(); int state = -1; + /* do { m64pCoreDoCommandRefInt(m64p_command.M64CMD_CORE_STATE_QUERY, 1, ref state); } while (state != (int)m64p_emu_state.M64EMU_PAUSED); + */ + m64pFrameComplete = false; + while (!m64pFrameComplete) { } m64pSamplingRate = (uint)AudGetAudioRate(); diff --git a/BizHawk.MultiClient/output/dll/mupen64plus-audio-bkm.dll b/BizHawk.MultiClient/output/dll/mupen64plus-audio-bkm.dll index 57bd43f4b7..a35acc1b0c 100644 Binary files a/BizHawk.MultiClient/output/dll/mupen64plus-audio-bkm.dll and b/BizHawk.MultiClient/output/dll/mupen64plus-audio-bkm.dll differ diff --git a/BizHawk.MultiClient/output/dll/mupen64plus-input-bkm.dll b/BizHawk.MultiClient/output/dll/mupen64plus-input-bkm.dll index aaf48f355c..121c2c39d7 100644 Binary files a/BizHawk.MultiClient/output/dll/mupen64plus-input-bkm.dll and b/BizHawk.MultiClient/output/dll/mupen64plus-input-bkm.dll differ diff --git a/BizHawk.MultiClient/output/dll/mupen64plus-rsp-hle.dll b/BizHawk.MultiClient/output/dll/mupen64plus-rsp-hle.dll index 4f5363d6e7..c321ecc2f8 100644 Binary files a/BizHawk.MultiClient/output/dll/mupen64plus-rsp-hle.dll and b/BizHawk.MultiClient/output/dll/mupen64plus-rsp-hle.dll differ diff --git a/BizHawk.MultiClient/output/dll/mupen64plus-video-rice.dll b/BizHawk.MultiClient/output/dll/mupen64plus-video-rice.dll index 9062c9ff97..d3824cb967 100644 Binary files a/BizHawk.MultiClient/output/dll/mupen64plus-video-rice.dll and b/BizHawk.MultiClient/output/dll/mupen64plus-video-rice.dll differ diff --git a/BizHawk.MultiClient/output/dll/mupen64plus.dll b/BizHawk.MultiClient/output/dll/mupen64plus.dll index e682611170..fa48f4cf8b 100644 Binary files a/BizHawk.MultiClient/output/dll/mupen64plus.dll and b/BizHawk.MultiClient/output/dll/mupen64plus.dll differ diff --git a/libmupen64plus/mupen64plus-core/src/main/main.c b/libmupen64plus/mupen64plus-core/src/main/main.c index 2470eb0b25..643213d70a 100644 --- a/libmupen64plus/mupen64plus-core/src/main/main.c +++ b/libmupen64plus/mupen64plus-core/src/main/main.c @@ -289,11 +289,13 @@ static void main_set_speedlimiter(int enable) static int main_is_paused(void) { - return (g_EmulatorRunning && rompause); + return (g_EmulatorRunning);// && rompause); } void main_toggle_pause(void) { + MessageBox(NULL, "This wasn't supposed to happen!", "Call Spooky", 0); + /* if (!g_EmulatorRunning) return; @@ -321,12 +323,14 @@ void main_toggle_pause(void) rompause = !rompause; l_FrameAdvance = 0; + */ } void main_advance_one(void) { l_FrameAdvance = 1; - rompause = 0; + //rompause = 0; + ReleaseSemaphore(rompausesem, 1, NULL); StateChanged(M64CORE_EMU_STATE, M64EMU_RUNNING); } @@ -413,8 +417,8 @@ m64p_error main_core_state_query(m64p_core_param param, int *rval) case M64CORE_EMU_STATE: if (!g_EmulatorRunning) *rval = M64EMU_STOPPED; - else if (rompause) - *rval = M64EMU_PAUSED; + //else if (rompause) + // *rval = M64EMU_PAUSED; else *rval = M64EMU_RUNNING; break; @@ -667,14 +671,14 @@ void new_vi(void) double VILimitMilliseconds = 1000.0 / ROM_PARAMS.vilimit; double AdjustedLimit = VILimitMilliseconds * 100.0 / l_SpeedFactor; // adjust for selected emulator speed int time; - + start_section(IDLE_SECTION); VI_Counter++; #ifdef DBG if(g_DebuggerActive) DebuggerCallback(DEBUG_UI_VI, 0); #endif - + /* if(LastFPSTime == 0) { LastFPSTime = CounterTime = SDL_GetTicks(); @@ -703,12 +707,13 @@ void new_vi(void) } LastFPSTime = CurrentFPSTime ; + */ end_section(IDLE_SECTION); if (g_VICallback != NULL) (*g_VICallback)(); if (l_FrameAdvance) { - rompause = 1; + //rompause = 1; l_FrameAdvance = 0; StateChanged(M64CORE_EMU_STATE, M64EMU_PAUSED); } @@ -838,12 +843,13 @@ void main_stop(void) osd_delete_message(l_msgVol); l_msgVol = NULL; } - if (rompause) - { - rompause = 0; + stop = 1; + //if (rompause) + //{ + // rompause = 0; + ReleaseSemaphore(rompausesem, 1, NULL); StateChanged(M64CORE_EMU_STATE, M64EMU_RUNNING); - } - stop = 1; + //} #ifdef DBG if(g_DebuggerActive) { diff --git a/libmupen64plus/mupen64plus-core/src/r4300/interupt.c b/libmupen64plus/mupen64plus-core/src/r4300/interupt.c index f44da5b995..3223583d2e 100644 --- a/libmupen64plus/mupen64plus-core/src/r4300/interupt.c +++ b/libmupen64plus/mupen64plus-core/src/r4300/interupt.c @@ -388,21 +388,23 @@ void gen_interupt(void) refresh_stat(); // if paused, poll for input events - if(rompause) - { + //if(rompause) + //{ osd_render(); // draw Paused message in case gfx.updateScreen didn't do it VidExt_GL_SwapBuffers(); - while(rompause) - { - SDL_Delay(10); + // while(rompause) + // { + //SDL_Delay(10); + SDL_PumpEvents(); #ifdef WITH_LIRC lircCheckInput(); #endif //WITH_LIRC - } - } + // } + //} new_vi(); + WaitForSingleObject(rompausesem, INFINITE); if (vi_register.vi_v_sync == 0) vi_register.vi_delay = 500000; else vi_register.vi_delay = ((vi_register.vi_v_sync + 1)*1500); next_vi += vi_register.vi_delay; diff --git a/libmupen64plus/mupen64plus-core/src/r4300/r4300.c b/libmupen64plus/mupen64plus-core/src/r4300/r4300.c index 8753595da2..daa812873c 100644 --- a/libmupen64plus/mupen64plus-core/src/r4300/r4300.c +++ b/libmupen64plus/mupen64plus-core/src/r4300/r4300.c @@ -45,7 +45,8 @@ unsigned int r4300emu = 0; int no_compiled_jump = 0; -int llbit, rompause; +int llbit; //, rompause; +HANDLE rompausesem; #if NEW_DYNAREC != NEW_DYNAREC_ARM int stop; long long int reg[32], hi, lo; @@ -985,7 +986,8 @@ void r4300_execute(void) debug_count = 0; delay_slot=0; stop = 0; - rompause = 1; + //rompause = 1; + rompausesem = CreateSemaphore(NULL, 0, 1, NULL); /* clear instruction counters */ #if defined(COUNT_INSTR) diff --git a/libmupen64plus/mupen64plus-core/src/r4300/r4300.h b/libmupen64plus/mupen64plus-core/src/r4300/r4300.h index 399a9fbaa1..b06564b66e 100644 --- a/libmupen64plus/mupen64plus-core/src/r4300/r4300.h +++ b/libmupen64plus/mupen64plus-core/src/r4300/r4300.h @@ -22,6 +22,9 @@ #ifndef R4300_H #define R4300_H +#define WIN32_LEAN_AND_MEAN +#include + #include "recomp.h" #include "memory/tlb.h" @@ -29,7 +32,8 @@ extern precomp_instr *PC; extern precomp_block *blocks[0x100000], *actual; -extern int stop, llbit, rompause; +extern int stop, llbit; //, rompause; +extern HANDLE rompausesem; extern long long int reg[32], hi, lo; extern long long int local_rs; extern unsigned int reg_cop0[32];