From ce6e8ed798007545a42aaf36099176355d070003 Mon Sep 17 00:00:00 2001 From: nakeee Date: Mon, 6 Jul 2009 19:19:03 +0000 Subject: [PATCH] DSPLLE: More minor clean up, some log mistake fixes and revert the +1 loop (it seems to got zelda ucode stuck for some weird reason) git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3694 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/DSPCore/Src/DSPCore.cpp | 12 +++++----- Source/Core/DSPCore/Src/DSPHWInterface.cpp | 4 ++-- Source/Core/DSPCore/Src/DSPIntUtil.h | 1 + Source/Core/DSPCore/Src/DSPInterpreter.cpp | 28 ---------------------- Source/Core/DSPCore/Src/DSPInterpreter.h | 3 +++ Source/Core/DSPCore/Src/DspIntBranch.cpp | 27 +++++++++++++++++++++ Source/Core/DSPCore/Src/SConscript | 4 ++-- 7 files changed, 41 insertions(+), 38 deletions(-) diff --git a/Source/Core/DSPCore/Src/DSPCore.cpp b/Source/Core/DSPCore/Src/DSPCore.cpp index 21f99b2a18..713c3f9111 100644 --- a/Source/Core/DSPCore/Src/DSPCore.cpp +++ b/Source/Core/DSPCore/Src/DSPCore.cpp @@ -170,7 +170,7 @@ void DSPCore_CheckExternalInterrupt() g_dsp.cr &= ~CR_EXTERNAL_INT; } else { #ifdef DEBUG_EXP - ERROR_LOG(DSPLLE, "External interupt firing failed"); + ERROR_LOG(DSPLLE, "External interrupt firing failed"); #endif } @@ -189,8 +189,8 @@ void DSPCore_CheckExceptions() // check exceptions should it be 0..7 or 7..0? for (int i = 0; i < 8; i++) { // Seems exp int is not masked by sr_int_enable - if (dsp_SR_is_flag_set(SR_INT_ENABLE) || i == EXP_INT) { - if (g_dsp.exceptions & (1 << i)) { + if (g_dsp.exceptions & (1 << i)) { + if (dsp_SR_is_flag_set(SR_INT_ENABLE) || i == EXP_INT) { _assert_msg_(MASTER_LOG, !g_dsp.exception_in_progress_hack, "assert while exception"); // store pc and sr until RTI @@ -201,11 +201,11 @@ void DSPCore_CheckExceptions() g_dsp.exceptions &= ~(1 << i); g_dsp.exception_in_progress_hack = true; break; - } - } else { + } else { #ifdef DEBUG_EXP - ERROR_LOG(DSPLLE, "Firing exception %d failed"); + ERROR_LOG(DSPLLE, "Firing exception %d failed"); #endif + } } } } diff --git a/Source/Core/DSPCore/Src/DSPHWInterface.cpp b/Source/Core/DSPCore/Src/DSPHWInterface.cpp index 34089cb1c9..e87314bdb0 100644 --- a/Source/Core/DSPCore/Src/DSPHWInterface.cpp +++ b/Source/Core/DSPCore/Src/DSPHWInterface.cpp @@ -92,7 +92,7 @@ void gdsp_mbox_write_l(u8 mbx, u16 val) { NOTICE_LOG(DSPLLE, "DSP(WM) B:%i M:0x%08x (pc=0x%04x)", mbx, gdsp_mbox_peek(GDSP_MBOX_DSP), g_dsp.pc); } else { - NOTICE_LOG(DSPLLE, "CPU(WM) B:%i M:0x%08x (pc=0x%04x)", mbx, gdsp_mbox_peek(GDSP_MBOX_DSP), g_dsp.pc); + NOTICE_LOG(DSPLLE, "CPU(WM) B:%i M:0x%08x (pc=0x%04x)", mbx, gdsp_mbox_peek(GDSP_MBOX_CPU), g_dsp.pc); } #endif } @@ -121,7 +121,7 @@ u16 gdsp_mbox_read_l(u8 mbx) { NOTICE_LOG(DSPLLE, "DSP(RM) B:%i M:0x%08x (pc=0x%04x)", mbx, gdsp_mbox_peek(GDSP_MBOX_DSP), g_dsp.pc); } else { - NOTICE_LOG(DSPLLE, "CPU(RM) B:%i M:0x%08x (pc=0x%04x)", mbx, gdsp_mbox_peek(GDSP_MBOX_DSP), g_dsp.pc); + NOTICE_LOG(DSPLLE, "CPU(RM) B:%i M:0x%08x (pc=0x%04x)", mbx, gdsp_mbox_peek(GDSP_MBOX_CPU), g_dsp.pc); } #endif diff --git a/Source/Core/DSPCore/Src/DSPIntUtil.h b/Source/Core/DSPCore/Src/DSPIntUtil.h index a4ef54f3b4..0d87136afe 100644 --- a/Source/Core/DSPCore/Src/DSPIntUtil.h +++ b/Source/Core/DSPCore/Src/DSPIntUtil.h @@ -33,6 +33,7 @@ #include "DSPMemoryMap.h" #include "DSPStacks.h" + // --------------------------------------------------------------------------------------- // --- SR // --------------------------------------------------------------------------------------- diff --git a/Source/Core/DSPCore/Src/DSPInterpreter.cpp b/Source/Core/DSPCore/Src/DSPInterpreter.cpp index 1417a2ad89..aa4d2905eb 100644 --- a/Source/Core/DSPCore/Src/DSPInterpreter.cpp +++ b/Source/Core/DSPCore/Src/DSPInterpreter.cpp @@ -71,34 +71,6 @@ u16 ReadCR() return g_dsp.cr; } -void HandleLoop() -{ - // Handle looping hardware. - u16& rLoopCounter = g_dsp.r[DSP_REG_ST3]; - if (rLoopCounter > 0) - { - const u16 rCallAddress = g_dsp.r[DSP_REG_ST0]; - const u16 rLoopAddress = g_dsp.r[DSP_REG_ST2]; - - - if (g_dsp.pc == (rLoopAddress + opSize[rLoopAddress])) - { - rLoopCounter--; - if (rLoopCounter > 0) - { - g_dsp.pc = rCallAddress; - } - else - { - // end of loop - dsp_reg_load_stack(0); - dsp_reg_load_stack(2); - dsp_reg_load_stack(3); - } - } - } -} - void Step() { DSPCore_CheckExceptions(); diff --git a/Source/Core/DSPCore/Src/DSPInterpreter.h b/Source/Core/DSPCore/Src/DSPInterpreter.h index fe5f1afcc9..3bad4ec4f0 100644 --- a/Source/Core/DSPCore/Src/DSPInterpreter.h +++ b/Source/Core/DSPCore/Src/DSPInterpreter.h @@ -27,6 +27,9 @@ namespace DSPInterpreter { void Step(); void Run(); +// See: DspIntBranch.cpp +void HandleLoop(); + // If these simply return the same number of cycles as was passed into them, // chances are that the DSP is halted. // The difference between them is that the debug one obeys breakpoints. diff --git a/Source/Core/DSPCore/Src/DspIntBranch.cpp b/Source/Core/DSPCore/Src/DspIntBranch.cpp index 721428d8f0..7afa5d9585 100644 --- a/Source/Core/DSPCore/Src/DspIntBranch.cpp +++ b/Source/Core/DSPCore/Src/DspIntBranch.cpp @@ -145,6 +145,33 @@ void halt(const UDSPInstruction& opc) // then PC is modified with calue from call stack $st0. Otherwise values from // callstack $st0 and both loop stacks $st2 and $st3 are poped and execution // continues at next opcode. +void HandleLoop() +{ + // Handle looping hardware. + u16& rLoopCounter = g_dsp.r[DSP_REG_ST3]; + if (rLoopCounter > 0) + { + const u16 rCallAddress = g_dsp.r[DSP_REG_ST0]; + const u16 rLoopAddress = g_dsp.r[DSP_REG_ST2]; + + + if (g_dsp.pc == (rLoopAddress + 1)) //opSize[rLoopAddress])) + { + rLoopCounter--; + if (rLoopCounter > 0) + { + g_dsp.pc = rCallAddress; + } + else + { + // end of loop + dsp_reg_load_stack(0); + dsp_reg_load_stack(2); + dsp_reg_load_stack(3); + } + } + } +} // LOOP $R diff --git a/Source/Core/DSPCore/Src/SConscript b/Source/Core/DSPCore/Src/SConscript index 17d08b29cb..3bcf48a462 100644 --- a/Source/Core/DSPCore/Src/SConscript +++ b/Source/Core/DSPCore/Src/SConscript @@ -6,11 +6,10 @@ files = [ "assemble.cpp", "disassemble.cpp", "DSPAccelerator.cpp", - "DSPBreakpoints.cpp", + "DSPBreakpoints.cpp", "DSPIntCCUtil.cpp", "DSPIntExtOps.cpp", "DSPHWInterface.cpp", - "DSPInterpreter.cpp", "DSPMemoryMap.cpp", "DSPStacks.cpp", "DSPAnalyzer.cpp", @@ -22,6 +21,7 @@ files = [ "DSPJit.cpp", "DSPCodeUtil.cpp", "LabelMap.cpp", + "DSPInterpreter.cpp", "DSPCore.cpp", "DSPTables.cpp", ]