diff --git a/Core/Core.h b/Core/Core.h index 564701ef5..66a0a19be 100644 --- a/Core/Core.h +++ b/Core/Core.h @@ -38,7 +38,8 @@ enum CoreState CORE_RUNNING, CORE_STEPPING, CORE_POWERDOWN, - CORE_ERROR + CORE_ERROR, + CORE_NEXTFRAME, }; diff --git a/Core/HLE/sceDisplay.cpp b/Core/HLE/sceDisplay.cpp index 70832e8b7..267303cd6 100644 --- a/Core/HLE/sceDisplay.cpp +++ b/Core/HLE/sceDisplay.cpp @@ -25,6 +25,7 @@ #include "sceAudio.h" #include "../Host.h" #include "../Config.h" +#include "../Core/Core.h" #include "sceDisplay.h" #include "sceKernel.h" #include "sceKernelThread.h" @@ -61,7 +62,6 @@ static int hCountTotal = 0; //unused static int vCount = 0; static int isVblank = 0; -static bool frameDone; // STATE END // The vblank period is 731.5 us (0.7315 ms) @@ -87,7 +87,6 @@ void hleLeaveVblank(u64 userdata, int cyclesLate); void __DisplayInit() { framebufIsLatched = false; - frameDone = false; framebuf.topaddr = 0x04000000; framebuf.pspframebuf = Memory::GetPointer(0x04000000); framebuf.pspFramebufFormat = PSP_DISPLAY_PIXEL_FORMAT_8888; @@ -108,14 +107,6 @@ void __DisplayShutdown() ShutdownGfxState(); } -// will return true once after every end-of-frame. -bool __DisplayFrameDone() -{ - bool retVal = frameDone; - frameDone = false; - return retVal; -} - void hleEnterVblank(u64 userdata, int cyclesLate) { int vbCount = userdata; @@ -133,7 +124,7 @@ void hleEnterVblank(u64 userdata, int cyclesLate) CoreTiming::ScheduleEvent(msToCycles(vblankMs) - cyclesLate, leaveVblankEvent, vbCount+1); // TODO: Should this be done here or in hleLeaveVblank? - if (framebufIsLatched) + if (framebufIsLatched) { DEBUG_LOG(HLE, "Setting latched framebuffer %08x (prev: %08x)", latchedFramebuf.topaddr, framebuf.topaddr); framebuf = latchedFramebuf; @@ -141,7 +132,7 @@ void hleEnterVblank(u64 userdata, int cyclesLate) } // Draw screen overlays before blitting. Saves and restores the Ge context. - + /* if (g_Config.bShowGPUStats) { @@ -172,7 +163,10 @@ void hleEnterVblank(u64 userdata, int cyclesLate) } // Tell the emu core that it's time to stop emulating - frameDone = true; + // Win32 doesn't need this. +#ifndef _WIN32 + coreState = CORE_NEXTFRAME; +#endif } diff --git a/Core/MIPS/MIPS.cpp b/Core/MIPS/MIPS.cpp index 3cc2c9544..4237c8760 100644 --- a/Core/MIPS/MIPS.cpp +++ b/Core/MIPS/MIPS.cpp @@ -109,13 +109,7 @@ void MIPSState::SingleStep() // returns 1 if reached ticks limit int MIPSState::RunLoopUntil(u64 globalTicks) { - // Don't subvert this by setting useJIT to true - other places also check the coreparameter - bool useJIT = PSP_CoreParameter().cpuCore == CPU_JIT; -#if defined(ANDROID) || defined(BLACKBERRY) - useJIT = false; -#endif - - if (useJIT) + if (PSP_CoreParameter().cpuCore == CPU_JIT) { MIPSComp::jit->RunLoopUntil(globalTicks); } @@ -194,12 +188,6 @@ int MIPSState::RunLoopUntil(u64 globalTicks) // DEBUG_LOG(CPU, "Hit the max ticks, bailing 1 : %llu, %llu", globalTicks, CoreTiming::GetTicks()); return 1; } -#ifndef _WIN32 // Windows simply keeps running and control the refresh from sceDisplay - if (__DisplayFrameDone()) { - // End of frame! Need to quit the CPU loop temporarily. - return 0; - } -#endif } CoreTiming::Advance(); diff --git a/android/jni/EmuScreen.cpp b/android/jni/EmuScreen.cpp index 9afdb7028..47ba7f662 100644 --- a/android/jni/EmuScreen.cpp +++ b/android/jni/EmuScreen.cpp @@ -47,7 +47,11 @@ EmuScreen::EmuScreen(const std::string &filename) : invalid_(true) INFO_LOG(BOOT, "Starting up hardware."); CoreParameter coreParam; +#if defined(ANDROID) || defined(BLACKBERRY) coreParam.cpuCore = CPU_INTERPRETER; +#else + coreParam.cpuCore = g_Config.bJIT ? CPU_JIT : CPU_INTERPRETER; +#endif coreParam.gpuCore = GPU_GLES; coreParam.enableSound = g_Config.bEnableSound; coreParam.fileToStart = fileToStart; @@ -150,11 +154,15 @@ void EmuScreen::render() // Let's do 120 "blocks" per second just to try it int blockTicks = usToCycles(1000000 / 120); - while (retval == 1) { + // Run until CORE_NEXTFRAME + while (coreState == CORE_RUNNING) { u64 nowTicks = CoreTiming::GetTicks(); retval = mipsr4k.RunLoopUntil(nowTicks + blockTicks); - // If exited because of cycles, try again. - // If exited because of end of frame, great! + } + // Hopefully coreState is now CORE_NEXTFRAME + if (coreState == CORE_NEXTFRAME) { + // set back to running for the next frame + coreState = CORE_RUNNING; } //if (hasRendered)