diff --git a/rpcs3/Emu/Cell/PPCDecoder.h b/rpcs3/Emu/Cell/PPCDecoder.h index 81e24087dd..68e7d6da72 100644 --- a/rpcs3/Emu/Cell/PPCDecoder.h +++ b/rpcs3/Emu/Cell/PPCDecoder.h @@ -1,6 +1,6 @@ #pragma once #include "PPCInstrTable.h" -#pragma warning( disable : 4800 4554 ) +#pragma warning( disable : 4800 ) template class InstrCaller @@ -485,21 +485,21 @@ static InstrList* connect_list(InstrList* parent, InstrL } template -static InstrList<1 << (to - from + 1), TO>* new_list(const CodeField& func, InstrCaller* error_func = nullptr) +static InstrList<1 << CodeField::size, TO>* new_list(const CodeField& func, InstrCaller* error_func = nullptr) { - return new InstrList<1 << (to - from + 1), TO>(func, error_func); + return new InstrList<1 << CodeField::size, TO>(func, error_func); } template -static InstrList<1 << (to - from + 1), TO>* new_list(InstrList* parent, int opcode, const CodeField& func, InstrCaller* error_func = nullptr) +static InstrList<1 << CodeField::size, TO>* new_list(InstrList* parent, int opcode, const CodeField& func, InstrCaller* error_func = nullptr) { - return connect_list(parent, new InstrList<1 << (to - from + 1), TO>(func, error_func), opcode); + return connect_list(parent, new InstrList<1 << CodeField::size, TO>(func, error_func), opcode); } template -static InstrList<1 << (to - from + 1), TO>* new_list(InstrList* parent, const CodeField& func, InstrCaller* error_func = nullptr) +static InstrList<1 << CodeField::size, TO>* new_list(InstrList* parent, const CodeField& func, InstrCaller* error_func = nullptr) { - return connect_list(parent, new InstrList<1 << (to - from + 1), TO>(func, error_func)); + return connect_list(parent, new InstrList<1 << CodeField::size, TO>(func, error_func)); } template diff --git a/rpcs3/Emu/Cell/PPCInstrTable.h b/rpcs3/Emu/Cell/PPCInstrTable.h index 76328a8b36..97f701b02d 100644 --- a/rpcs3/Emu/Cell/PPCInstrTable.h +++ b/rpcs3/Emu/Cell/PPCInstrTable.h @@ -1,10 +1,12 @@ #pragma once -template __forceinline static T sign(const T value) +template __forceinline static T sign(const T value) { - if(value & (1 << (size - 1))) + static_assert(size > 0 && size < sizeof(T) * 8, "Bad size"); + static const T sub_value = T(1) << size; + if(value & (T(1) << (size - 1))) { - return value - (1 << size); + return value - sub_value; } return value; @@ -52,6 +54,7 @@ public: { } + static const u32 size = to - from + 1; static const u32 shift = 31 - to; static const u32 mask = ((1ULL << ((to - from) + 1)) - 1) << shift; diff --git a/rpcs3/Emu/Cell/PPCThread.cpp b/rpcs3/Emu/Cell/PPCThread.cpp index 54e5c4ef28..4f63d6832b 100644 --- a/rpcs3/Emu/Cell/PPCThread.cpp +++ b/rpcs3/Emu/Cell/PPCThread.cpp @@ -10,8 +10,8 @@ PPCThread* GetCurrentPPCThread() PPCThread::PPCThread(PPCThreadType type) : ThreadBase(true, "PPCThread") , m_type(type) - , DisAsmFrame(NULL) - , m_dec(NULL) + , DisAsmFrame(nullptr) + , m_dec(nullptr) , stack_size(0) , stack_addr(0) , m_prio(0) @@ -28,12 +28,13 @@ PPCThread::~PPCThread() void PPCThread::Close() { - Stop(); if(DisAsmFrame) { DisAsmFrame->Close(); DisAsmFrame = nullptr; } + + Stop(); } void PPCThread::Reset() @@ -260,12 +261,11 @@ void PPCThread::Stop() wxGetApp().SendDbgCommand(DID_STOP_THREAD, this); m_status = Stopped; + ThreadBase::Stop(); Reset(); DoStop(); Emu.CheckStatus(); - ThreadBase::Stop(); - wxGetApp().SendDbgCommand(DID_STOPED_THREAD, this); } diff --git a/rpcs3/Emu/Cell/PPCThreadManager.cpp b/rpcs3/Emu/Cell/PPCThreadManager.cpp index eba18e18bb..d94375e3ed 100644 --- a/rpcs3/Emu/Cell/PPCThreadManager.cpp +++ b/rpcs3/Emu/Cell/PPCThreadManager.cpp @@ -50,10 +50,11 @@ void PPCThreadManager::RemoveThread(const u32 id) if(m_threads[i].GetId() != id) continue; - wxGetApp().SendDbgCommand(DID_REMOVE_THREAD, &m_threads[i]); - m_threads[i].Close(); - delete &m_threads[i]; + PPCThread* thr = &m_threads[i]; m_threads.RemoveFAt(i); + wxGetApp().SendDbgCommand(DID_REMOVE_THREAD, thr); + thr->Close(); + delete thr; i--; } diff --git a/rpcs3/Emu/Cell/PPUInstrTable.h b/rpcs3/Emu/Cell/PPUInstrTable.h index 08e110c6f4..45c2081de3 100644 --- a/rpcs3/Emu/Cell/PPUInstrTable.h +++ b/rpcs3/Emu/Cell/PPUInstrTable.h @@ -541,7 +541,9 @@ namespace PPU_instr /*0x33a*/bind_instr(g1f_list, SRADI1, RA, RS, sh, RC); /*0x33b*/bind_instr(g1f_list, SRADI2, RA, RS, sh, RC); /*0x356*/bind_instr(g1f_list, EIEIO); + /*0x387*/bind_instr(g1f_list, STVLXL, VS, RA, RB); /*0x39a*/bind_instr(g1f_list, EXTSH, RA, RS, RC); + /*0x387*/bind_instr(g1f_list, STVRXL, VS, RA, RB); /*0x3ba*/bind_instr(g1f_list, EXTSB, RA, RS, RC); /*0x3d7*/bind_instr(g1f_list, STFIWX, FRS, RA, RB); /*0x3da*/bind_instr(g1f_list, EXTSW, RA, RS, RC); diff --git a/rpcs3/Emu/Cell/PPUOpcodes.h b/rpcs3/Emu/Cell/PPUOpcodes.h index 52806e9241..d7d3a086be 100644 --- a/rpcs3/Emu/Cell/PPUOpcodes.h +++ b/rpcs3/Emu/Cell/PPUOpcodes.h @@ -739,7 +739,7 @@ public: virtual void SRADI1(u32 ra, u32 rs, u32 sh, bool rc) = 0; virtual void SRADI2(u32 ra, u32 rs, u32 sh, bool rc) = 0; virtual void EIEIO() = 0; - virtual void STVLXL(u32 sd, u32 ra, u32 rb) = 0; + virtual void STVLXL(u32 vs, u32 ra, u32 rb) = 0; virtual void EXTSH(u32 ra, u32 rs, bool rc) = 0; virtual void STVRXL(u32 sd, u32 ra, u32 rb) = 0; virtual void EXTSB(u32 ra, u32 rs, bool rc) = 0; diff --git a/rpcs3/Emu/Cell/PPUThread.cpp b/rpcs3/Emu/Cell/PPUThread.cpp index 54717b8fd6..618966d7c5 100644 --- a/rpcs3/Emu/Cell/PPUThread.cpp +++ b/rpcs3/Emu/Cell/PPUThread.cpp @@ -178,6 +178,7 @@ bool dump_enable = false; void PPUThread::DoCode(const s32 code) { +#ifdef _DEBUG static bool is_last_enabled = false; if(dump_enable) @@ -208,6 +209,7 @@ void PPUThread::DoCode(const s32 code) cycle = 0; TB++; } +#endif m_dec->Decode(code); } diff --git a/rpcs3/Emu/GS/GL/GLGSRender.cpp b/rpcs3/Emu/GS/GL/GLGSRender.cpp index d6adabd82e..60215814a4 100644 --- a/rpcs3/Emu/GS/GL/GLGSRender.cpp +++ b/rpcs3/Emu/GS/GL/GLGSRender.cpp @@ -3,7 +3,7 @@ #include "Emu/Cell/PPCInstrTable.h" #define CMD_DEBUG 0 -#define DUMP_VERTEX_DATA 1 +#define DUMP_VERTEX_DATA 0 #if CMD_DEBUG #define CMD_LOG ConLog.Write @@ -199,7 +199,6 @@ void GLRSXThread::Task() { u32 addr = cmd & ~(CELL_GCM_METHOD_FLAG_JUMP | CELL_GCM_METHOD_FLAG_NON_INCREMENT); addr &= ~0x1000; - //0x30101000 + 0x80bf000 = 0x80be000 ConLog.Warning("rsx jump(0x%x) #addr=0x%x, cmd=0x%x, get=0x%x, put=0x%x", addr, p.m_ioAddress + get, cmd, get, put); re(p.m_ctrl->get, addr); continue; @@ -1337,7 +1336,7 @@ void GLGSRender::ExecCMD() m_program.SetTex(i); tex.Init(); checkForGlError("tex.Init"); - tex.Save(); + //tex.Save(); } if(m_indexed_array.m_count) diff --git a/rpcs3/Emu/SysCalls/Modules.cpp b/rpcs3/Emu/SysCalls/Modules.cpp index 9e3c98bb2f..e8a5021980 100644 --- a/rpcs3/Emu/SysCalls/Modules.cpp +++ b/rpcs3/Emu/SysCalls/Modules.cpp @@ -140,19 +140,13 @@ bool IsLoadedFunc(u32 id) return false; } -bool CallFunc(u32 id) +bool CallFunc(u32 num) { - for(u32 i=0; i= g_modules_funcs_list.GetCount()) + return false; - return true; - } - } - - return false; + (*g_modules_funcs_list[num - 1024].func)(); + return true; } bool UnloadFunc(u32 id) @@ -170,6 +164,19 @@ bool UnloadFunc(u32 id) return false; } +u32 GetFuncNumById(u32 id) +{ + for(u32 i=0; iSetLabel("Pause"); break; + + case DID_EXIT_THR_SYSCALL: + Emu.GetCPU().RemoveThread(((PPCThread*)event.GetClientData())->GetId()); + break; } UpdateUI(); - event.Skip(); } }; diff --git a/rpcs3/Gui/InterpreterDisAsm.cpp b/rpcs3/Gui/InterpreterDisAsm.cpp index d137359a70..fd61e070ac 100644 --- a/rpcs3/Gui/InterpreterDisAsm.cpp +++ b/rpcs3/Gui/InterpreterDisAsm.cpp @@ -278,9 +278,17 @@ void InterpreterDisAsmFrame::ShowAddr(const u64 addr) void InterpreterDisAsmFrame::WriteRegs() { + if(!CPU) + { + m_regs->Clear(); + return; + } + + const wxString data = CPU->RegsToString(); + m_regs->Freeze(); m_regs->Clear(); - if(CPU) m_regs->WriteText(CPU->RegsToString()); + m_regs->WriteText(data); m_regs->Thaw(); } @@ -293,9 +301,9 @@ void InterpreterDisAsmFrame::HandleCommand(wxCommandEvent& event) { switch(event.GetId()) { - case DID_STOP_EMU: - case DID_PAUSE_EMU: - DoUpdate(); + case DID_STOPED_EMU: + case DID_PAUSED_EMU: + //DoUpdate(); break; } } @@ -304,12 +312,16 @@ void InterpreterDisAsmFrame::HandleCommand(wxCommandEvent& event) switch(event.GetId()) { case DID_PAUSE_THREAD: + m_btn_run->Disable(); + m_btn_step->Disable(); + m_btn_pause->Disable(); + break; + + case DID_PAUSED_THREAD: m_btn_run->Enable(); m_btn_step->Enable(); m_btn_pause->Disable(); - - case DID_CREATE_THREAD: - DoUpdate(); + //DoUpdate(); break; case DID_START_THREAD: @@ -318,11 +330,6 @@ void InterpreterDisAsmFrame::HandleCommand(wxCommandEvent& event) m_btn_run->Disable(); m_btn_step->Disable(); m_btn_pause->Enable(); - - if(event.GetId() == DID_START_THREAD) - { - DoUpdate(); - } break; case DID_REMOVE_THREAD: @@ -333,15 +340,14 @@ void InterpreterDisAsmFrame::HandleCommand(wxCommandEvent& event) if(event.GetId() == DID_REMOVE_THREAD) { - m_choice_units->SetSelection(-1); - wxCommandEvent event; - event.SetInt(-1); + //m_choice_units->SetSelection(-1); + //wxCommandEvent event; + //event.SetInt(-1); //event.SetClientData(nullptr); - OnSelectUnit(event); + //OnSelectUnit(event); UpdateUnitList(); + //DoUpdate(); } - - DoUpdate(); break; } } @@ -353,14 +359,17 @@ void InterpreterDisAsmFrame::HandleCommand(wxCommandEvent& event) UpdateUnitList(); if(m_choice_units->GetSelection() == -1) { - m_choice_units->SetSelection(0); - wxCommandEvent event; - event.SetInt(0); - event.SetClientData(&Emu.GetCPU().GetThreads()[0]); - OnSelectUnit(event); - DoUpdate(); + //m_choice_units->SetSelection(0); + //wxCommandEvent event; + //event.SetInt(0); + //event.SetClientData(&Emu.GetCPU().GetThreads()[0]); + //OnSelectUnit(event); } break; + + case DID_REMOVED_THREAD: + UpdateUnitList(); + break; } } } @@ -421,6 +430,7 @@ void InterpreterDisAsmFrame::DoRun(wxCommandEvent& WXUNUSED(event)) void InterpreterDisAsmFrame::DoPause(wxCommandEvent& WXUNUSED(event)) { + //DoUpdate(); if(CPU) CPU->Pause(); } diff --git a/rpcs3/Loader/ELF64.cpp b/rpcs3/Loader/ELF64.cpp index 70f89523aa..f6ff6d3b8a 100644 --- a/rpcs3/Loader/ELF64.cpp +++ b/rpcs3/Loader/ELF64.cpp @@ -382,7 +382,7 @@ bool ELF64Loader::LoadPhdrData(u64 offset) mem32_t out_tbl(tbl + i*8); out_tbl += dst + i*section; - out_tbl += nid; + out_tbl += GetFuncNumById(nid); mem32_t out_dst(dst + i*section); out_dst += OR(11, 2, 2, 0); diff --git a/rpcs3/rpcs3.h b/rpcs3/rpcs3.h index 533118cb92..6d1ff5911a 100644 --- a/rpcs3/rpcs3.h +++ b/rpcs3/rpcs3.h @@ -47,6 +47,7 @@ enum DbgCommand DID_EXEC_THREAD, DID_REGISTRED_CALLBACK, DID_UNREGISTRED_CALLBACK, + DID_EXIT_THR_SYSCALL, DID_LAST_COMMAND, };