u16 DSPLLE::DSP_WriteControlRegister(u16 _uFlag) { UDSPControl Temp(_uFlag); if (!m_InitMixer) { if (!Temp.DSPHalt) { InitMixer(); } } DSPInterpreter::WriteCR(_uFlag); // Check if the CPU has set an external interrupt (CR_EXTERNAL_INT) // and immediately process it, if it has. if (_uFlag & 2) { if (!m_bDSPThread) { DSPCore_CheckExternalInterrupt(); DSPCore_CheckExceptions(); } else { DSPCore_SetExternalInterrupt(true); } } return DSPInterpreter::ReadCR(); }
// Delegate to JIT or interpreter as appropriate. // Handle state changes and stepping. int DSPCore_RunCycles(int cycles) { if (dspjit) { if (g_dsp.external_interrupt_waiting) { DSPCore_CheckExternalInterrupt(); DSPCore_CheckExceptions(); DSPCore_SetExternalInterrupt(false); } cyclesLeft = cycles; DSPCompiledCode pExecAddr = (DSPCompiledCode)dspjit->enterDispatcher; pExecAddr(); if (g_dsp.reset_dspjit_codespace) dspjit->ClearIRAMandDSPJITCodespaceReset(); return cyclesLeft; } while (cycles > 0) { switch (core_state) { case DSPCORE_RUNNING: // Seems to slow things down #if defined(_DEBUG) || defined(DEBUGFAST) cycles = DSPInterpreter::RunCyclesDebug(cycles); #else cycles = DSPInterpreter::RunCycles(cycles); #endif break; case DSPCORE_STEPPING: step_event.Wait(); if (core_state != DSPCORE_STEPPING) continue; DSPInterpreter::Step(); cycles--; DSPHost::UpdateDebugger(); break; case DSPCORE_STOP: break; } } return cycles; }
// Used by thread mode. int RunCyclesThread(int cycles) { while (true) { if (g_dsp.cr & CR_HALT) return 0; if (g_dsp.external_interrupt_waiting) { DSPCore_CheckExternalInterrupt(); DSPCore_SetExternalInterrupt(false); } Step(); cycles--; if (cycles < 0) return 0; } }
u16 DSPLLE::DSP_WriteControlRegister(u16 _uFlag) { DSPInterpreter::WriteCR(_uFlag); if (_uFlag & 2) { if (!m_bDSPThread) { DSPCore_CheckExternalInterrupt(); DSPCore_CheckExceptions(); } else { // External interrupt pending: this is the zelda ucode. // Disable the DSP thread because there is no performance gain. requestDisableThread = true; DSPCore_SetExternalInterrupt(true); } } return DSPInterpreter::ReadCR(); }