From 3058a926cfca089c65701b2902273b0e37467ca1 Mon Sep 17 00:00:00 2001 From: anusko Date: Sun, 29 Aug 2010 17:53:55 +0000 Subject: [PATCH] Implemented missing lswx and stswx instructions. Tested with Wii PES 2008 (PAL), which now works (OpenGL devs please take a look at this game). Changed the scope of some variables introduced in my previous commit (r6132). git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6147 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Core/Src/Core.cpp | 8 +-- .../Src/PowerPC/Interpreter/Interpreter.cpp | 6 +- .../Interpreter/Interpreter_LoadStore.cpp | 59 ++++++++++++++++--- .../Interpreter/Interpreter_Tables.cpp | 3 +- .../Core/Src/PowerPC/Jit64/Jit64_Tables.cpp | 3 +- .../Core/Src/PowerPC/Jit64IL/JitIL_Tables.cpp | 3 +- 6 files changed, 60 insertions(+), 22 deletions(-) diff --git a/Source/Core/Core/Src/Core.cpp b/Source/Core/Core/Src/Core.cpp index bb7245489e..3dba513079 100644 --- a/Source/Core/Core/Src/Core.cpp +++ b/Source/Core/Core/Src/Core.cpp @@ -630,13 +630,7 @@ void VideoThrottle() u32 Speed = VPS * 100 / VideoInterface::TargetRefreshRate; // Settings are shown the same for both extended and summary info - std::string SSettings = StringFromFormat("%s %s", - #ifdef _M_IX86 - _CoreParameter.iCPUCore ? jit->GetName() : "Int32", - #else - _CoreParameter.iCPUCore ? jit->GetName() : "Int64", - #endif - _CoreParameter.bCPUThread ? "DC" : "SC"); + std::string SSettings = StringFromFormat("%s %s", cpu_core_base->GetName(), _CoreParameter.bCPUThread ? "DC" : "SC"); // Use extended or summary information. The summary information does not print the ticks data, // that's more of a debugging interest, it can always be optional of course if someone is interested. diff --git a/Source/Core/Core/Src/PowerPC/Interpreter/Interpreter.cpp b/Source/Core/Core/Src/PowerPC/Interpreter/Interpreter.cpp index 12103fc701..a2f05a4b82 100644 --- a/Source/Core/Core/Src/PowerPC/Interpreter/Interpreter.cpp +++ b/Source/Core/Core/Src/PowerPC/Interpreter/Interpreter.cpp @@ -261,7 +261,11 @@ void Interpreter::ClearCache() const char *Interpreter::GetName() { - return "Interpreter"; +#ifdef _M_X64 + return "Interpreter64"; +#else + return "Interpreter32"; +#endif } Interpreter *Interpreter::getInstance() diff --git a/Source/Core/Core/Src/PowerPC/Interpreter/Interpreter_LoadStore.cpp b/Source/Core/Core/Src/PowerPC/Interpreter/Interpreter_LoadStore.cpp index eb0d012b2f..9e1346a8ad 100644 --- a/Source/Core/Core/Src/PowerPC/Interpreter/Interpreter_LoadStore.cpp +++ b/Source/Core/Core/Src/PowerPC/Interpreter/Interpreter_LoadStore.cpp @@ -521,12 +521,40 @@ void Interpreter::lhzx(UGeckoInstruction _inst) } } +// TODO: is this right? +// FIXME: Should rollback if a DSI occurs void Interpreter::lswx(UGeckoInstruction _inst) { - static bool bFirst = true; - if (bFirst) - PanicAlert("lswx - Instruction unimplemented"); - bFirst = false; + u32 EA = Helper_Get_EA_X(_inst); + u32 n = rSPR(SPR_XER) & 0x7F; + int r = _inst.RD; + int i = 0; + + if (n > 0) + { + m_GPR[r] = 0; + do + { + u32 TempValue = Memory::Read_U8(EA) << (24 - i); + if (PowerPC::ppcState.Exceptions & EXCEPTION_DSI) + { + PanicAlert("DSI exception in lswx."); + NOTICE_LOG(POWERPC, "DSI exception in lswx"); + return; + } + m_GPR[r] |= TempValue; + + EA++; + n--; + i += 8; + if (i == 32) + { + i = 0; + r = (r + 1) & 31; + m_GPR[r] = 0; + } + } while (n > 0); + } } void Interpreter::lwbrx(UGeckoInstruction _inst) @@ -722,12 +750,27 @@ void Interpreter::stswi(UGeckoInstruction _inst) } } +// TODO: is this right? is it DSI interruptible? void Interpreter::stswx(UGeckoInstruction _inst) { - static bool bFirst = true; - if (bFirst) - PanicAlert("stswx - Instruction unimplemented"); - bFirst = false; + u32 EA = Helper_Get_EA_X(_inst); + u32 n = rSPR(SPR_XER) & 0x7F; + int r = _inst.RS; + int i = 0; + + while (n > 0) + { + Memory::Write_U8((m_GPR[r] >> (24 - i)) & 0xFF, EA); + + EA++; + n--; + i += 8; + if (i == 32) + { + i = 0; + r++; + } + } } void Interpreter::stwbrx(UGeckoInstruction _inst) diff --git a/Source/Core/Core/Src/PowerPC/Interpreter/Interpreter_Tables.cpp b/Source/Core/Core/Src/PowerPC/Interpreter/Interpreter_Tables.cpp index 9ea755cdef..498ac69af8 100644 --- a/Source/Core/Core/Src/PowerPC/Interpreter/Interpreter_Tables.cpp +++ b/Source/Core/Core/Src/PowerPC/Interpreter/Interpreter_Tables.cpp @@ -362,11 +362,10 @@ static GekkoOPTemplate table63_2[] = namespace InterpreterTables { -bool initialized = false; - void InitTables() { // once initialized, tables are read-only + static bool initialized = false; if (initialized) return; diff --git a/Source/Core/Core/Src/PowerPC/Jit64/Jit64_Tables.cpp b/Source/Core/Core/Src/PowerPC/Jit64/Jit64_Tables.cpp index cebff3a80b..f3bf4c8648 100644 --- a/Source/Core/Core/Src/PowerPC/Jit64/Jit64_Tables.cpp +++ b/Source/Core/Core/Src/PowerPC/Jit64/Jit64_Tables.cpp @@ -392,11 +392,10 @@ void CompileInstruction(PPCAnalyst::CodeOp & op) } } -bool initialized = false; - void InitTables() { // once initialized, tables are read-only + static bool initialized = false; if (initialized) return; diff --git a/Source/Core/Core/Src/PowerPC/Jit64IL/JitIL_Tables.cpp b/Source/Core/Core/Src/PowerPC/Jit64IL/JitIL_Tables.cpp index 29e7573296..7272cc265a 100644 --- a/Source/Core/Core/Src/PowerPC/Jit64IL/JitIL_Tables.cpp +++ b/Source/Core/Core/Src/PowerPC/Jit64IL/JitIL_Tables.cpp @@ -395,11 +395,10 @@ void CompileInstruction(PPCAnalyst::CodeOp & op) } } -bool initialized = false; - void InitTables() { // once initialized, tables are read-only + static bool initialized = false; if (initialized) return;