From dbfd07f11e87668963dd053369556ec2094edf7f Mon Sep 17 00:00:00 2001 From: David Kiarie Date: Tue, 15 Jul 2014 18:04:37 +0300 Subject: [PATCH 01/18] fix broken commit (2267c84d6a6ff071fea59bebd68135523d979e78) --- rpcs3/Gui/VFSManager.cpp | 10 +++++----- rpcs3/Gui/VFSManager.h | 4 ++-- rpcs3/Gui/VHDDManager.cpp | 4 ++-- rpcs3/Gui/VHDDManager.h | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/rpcs3/Gui/VFSManager.cpp b/rpcs3/Gui/VFSManager.cpp index d1ba3365e4..af4fe3d1ed 100644 --- a/rpcs3/Gui/VFSManager.cpp +++ b/rpcs3/Gui/VFSManager.cpp @@ -139,10 +139,10 @@ VFSManagerDialog::VFSManagerDialog(wxWindow* parent) m_list->Bind(wxEVT_LIST_ITEM_ACTIVATED, &VFSManagerDialog::OnEntryConfig, this); m_list->Bind(wxEVT_RIGHT_DOWN, &VFSManagerDialog::OnRightClick, this); - Bind(wxEVT_MENU, &VFSManagerDialog::OnAdd, this, id_add); - Bind(wxEVT_MENU, &VFSManagerDialog::OnRemove, this, id_remove); - Bind(wxEVT_MENU, &VFSManagerDialog::OnEntryConfig, this, id_config); - Bind(wxEVT_CLOSE_WINDOW, &VFSManagerDialog::OnClose, this, wxID_OK); + Bind(wxEVT_MENU, &VFSManagerDialog::OnAdd, this, id_add); + Bind(wxEVT_MENU, &VFSManagerDialog::OnRemove, this, id_remove); + Bind(wxEVT_MENU, &VFSManagerDialog::OnEntryConfig, this, id_config); + Bind(wxEVT_BUTTON, &VFSManagerDialog::OnClose, this, wxID_OK); LoadEntries(); UpdateList(); @@ -214,7 +214,7 @@ void VFSManagerDialog::OnRemove(wxCommandEvent& event) UpdateList(); } -void VFSManagerDialog::OnClose(wxCloseEvent& event) +void VFSManagerDialog::OnClose(wxCommandEvent& event) { SaveEntries(); event.Skip(); diff --git a/rpcs3/Gui/VFSManager.h b/rpcs3/Gui/VFSManager.h index 309f9882e1..7f3e14d445 100644 --- a/rpcs3/Gui/VFSManager.h +++ b/rpcs3/Gui/VFSManager.h @@ -33,7 +33,7 @@ public: void OnAdd(wxCommandEvent& event); void OnRemove(wxCommandEvent& event); - void OnClose(wxCloseEvent& event); + void OnClose(wxCommandEvent& event); void LoadEntries(); void SaveEntries(); -}; \ No newline at end of file +}; diff --git a/rpcs3/Gui/VHDDManager.cpp b/rpcs3/Gui/VHDDManager.cpp index 27b4327ec1..7aa6ceb950 100644 --- a/rpcs3/Gui/VHDDManager.cpp +++ b/rpcs3/Gui/VHDDManager.cpp @@ -406,7 +406,7 @@ VHDDManagerDialog::VHDDManagerDialog(wxWindow* parent) Bind(wxEVT_MENU, &VHDDManagerDialog::OnOpen, this, id_open); Bind(wxEVT_MENU, &VHDDManagerDialog::OnRemove, this, id_remove); Bind(wxEVT_MENU, &VHDDManagerDialog::OnCreateHDD, this, id_create_hdd); - Bind(wxEVT_CLOSE_WINDOW, &VHDDManagerDialog::OnClose, this, wxID_OK); + Bind(wxEVT_BUTTON, &VHDDManagerDialog::OnClose, this, wxID_OK); LoadPaths(); UpdateList(); } @@ -521,7 +521,7 @@ void VHDDManagerDialog::OnCreateHDD(wxCommandEvent& event) } } -void VHDDManagerDialog::OnClose(wxCloseEvent& event) +void VHDDManagerDialog::OnClose(wxCommandEvent& event) { SavePaths(); event.Skip(); diff --git a/rpcs3/Gui/VHDDManager.h b/rpcs3/Gui/VHDDManager.h index aec9f55fc4..044b1bd341 100644 --- a/rpcs3/Gui/VHDDManager.h +++ b/rpcs3/Gui/VHDDManager.h @@ -82,7 +82,7 @@ public: void OnRemove(wxCommandEvent& event); void OnCreateHDD(wxCommandEvent& event); - void OnClose(wxCloseEvent& event); + void OnClose(wxCommandEvent& event); void LoadPaths(); void SavePaths(); }; From 78aef474a5a802b328ba82ba200cd234bab59b00 Mon Sep 17 00:00:00 2001 From: David Kiarie Date: Tue, 15 Jul 2014 18:29:48 +0300 Subject: [PATCH 02/18] rename some functions as per their function --- rpcs3/Gui/VFSManager.cpp | 4 ++-- rpcs3/Gui/VFSManager.h | 2 +- rpcs3/Gui/VHDDManager.cpp | 4 ++-- rpcs3/Gui/VHDDManager.h | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/rpcs3/Gui/VFSManager.cpp b/rpcs3/Gui/VFSManager.cpp index af4fe3d1ed..9df763384f 100644 --- a/rpcs3/Gui/VFSManager.cpp +++ b/rpcs3/Gui/VFSManager.cpp @@ -142,7 +142,7 @@ VFSManagerDialog::VFSManagerDialog(wxWindow* parent) Bind(wxEVT_MENU, &VFSManagerDialog::OnAdd, this, id_add); Bind(wxEVT_MENU, &VFSManagerDialog::OnRemove, this, id_remove); Bind(wxEVT_MENU, &VFSManagerDialog::OnEntryConfig, this, id_config); - Bind(wxEVT_BUTTON, &VFSManagerDialog::OnClose, this, wxID_OK); + Bind(wxEVT_BUTTON, &VFSManagerDialog::OnOK, this, wxID_OK); LoadEntries(); UpdateList(); @@ -214,7 +214,7 @@ void VFSManagerDialog::OnRemove(wxCommandEvent& event) UpdateList(); } -void VFSManagerDialog::OnClose(wxCommandEvent& event) +void VFSManagerDialog::OnOK(wxCommandEvent& event) { SaveEntries(); event.Skip(); diff --git a/rpcs3/Gui/VFSManager.h b/rpcs3/Gui/VFSManager.h index 7f3e14d445..63260b3e6c 100644 --- a/rpcs3/Gui/VFSManager.h +++ b/rpcs3/Gui/VFSManager.h @@ -33,7 +33,7 @@ public: void OnAdd(wxCommandEvent& event); void OnRemove(wxCommandEvent& event); - void OnClose(wxCommandEvent& event); + void OnOK(wxCommandEvent& event); void LoadEntries(); void SaveEntries(); }; diff --git a/rpcs3/Gui/VHDDManager.cpp b/rpcs3/Gui/VHDDManager.cpp index 7aa6ceb950..5808848259 100644 --- a/rpcs3/Gui/VHDDManager.cpp +++ b/rpcs3/Gui/VHDDManager.cpp @@ -406,7 +406,7 @@ VHDDManagerDialog::VHDDManagerDialog(wxWindow* parent) Bind(wxEVT_MENU, &VHDDManagerDialog::OnOpen, this, id_open); Bind(wxEVT_MENU, &VHDDManagerDialog::OnRemove, this, id_remove); Bind(wxEVT_MENU, &VHDDManagerDialog::OnCreateHDD, this, id_create_hdd); - Bind(wxEVT_BUTTON, &VHDDManagerDialog::OnClose, this, wxID_OK); + Bind(wxEVT_BUTTON, &VHDDManagerDialog::OnOk, this, wxID_OK); LoadPaths(); UpdateList(); } @@ -521,7 +521,7 @@ void VHDDManagerDialog::OnCreateHDD(wxCommandEvent& event) } } -void VHDDManagerDialog::OnClose(wxCommandEvent& event) +void VHDDManagerDialog::OnOk(wxCommandEvent& event) { SavePaths(); event.Skip(); diff --git a/rpcs3/Gui/VHDDManager.h b/rpcs3/Gui/VHDDManager.h index 044b1bd341..b3b8ad9a49 100644 --- a/rpcs3/Gui/VHDDManager.h +++ b/rpcs3/Gui/VHDDManager.h @@ -82,7 +82,7 @@ public: void OnRemove(wxCommandEvent& event); void OnCreateHDD(wxCommandEvent& event); - void OnClose(wxCommandEvent& event); + void OnOk(wxCommandEvent& event); void LoadPaths(); void SavePaths(); }; From 8e19af530b7424d073540aa40766e9117a15e01d Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Wed, 16 Jul 2014 16:03:54 +0400 Subject: [PATCH 03/18] .gitignore fix --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 43afefc806..84200d4e1b 100644 --- a/.gitignore +++ b/.gitignore @@ -61,7 +61,7 @@ rpcs3/git-version.h !/bin/dev_hdd0/game/TEST12345/ # Ignore other system generated files -bin/dev_hdd0/log.txt +bin/dev_hdd0/*.txt x64/Debug/emucore.lib x64/Release/emucore.lib From b487dcee277681e0765f7bb48d5407e554373fc7 Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Wed, 16 Jul 2014 16:06:58 +0400 Subject: [PATCH 04/18] RawSPU initialization fix --- rpcs3/Emu/CPU/CPUThreadManager.cpp | 26 ++++++++++++++++++++------ rpcs3/Emu/CPU/CPUThreadManager.h | 1 - rpcs3/Emu/Cell/RawSPUThread.cpp | 7 +++---- rpcs3/Emu/Cell/RawSPUThread.h | 2 +- 4 files changed, 24 insertions(+), 12 deletions(-) diff --git a/rpcs3/Emu/CPU/CPUThreadManager.cpp b/rpcs3/Emu/CPU/CPUThreadManager.cpp index 01ba798add..d162bc493b 100644 --- a/rpcs3/Emu/CPU/CPUThreadManager.cpp +++ b/rpcs3/Emu/CPU/CPUThreadManager.cpp @@ -11,7 +11,6 @@ #include "Emu/ARMv7/ARMv7Thread.h" CPUThreadManager::CPUThreadManager() - : m_raw_spu_num(0) { } @@ -22,7 +21,6 @@ CPUThreadManager::~CPUThreadManager() void CPUThreadManager::Close() { - m_raw_spu_num = 0; while(m_threads.size()) RemoveThread(m_threads[0]->GetId()); } @@ -34,10 +32,26 @@ CPUThread& CPUThreadManager::AddThread(CPUThreadType type) switch(type) { - case CPU_THREAD_PPU: new_thread = new PPUThread(); break; - case CPU_THREAD_SPU: new_thread = new SPUThread(); break; - case CPU_THREAD_RAW_SPU: new_thread = new RawSPUThread(m_raw_spu_num++); break; - case CPU_THREAD_ARMv7: new_thread = new ARMv7Thread(); break; + case CPU_THREAD_PPU: + { + new_thread = new PPUThread(); + break; + } + case CPU_THREAD_SPU: + { + new_thread = new SPUThread(); + break; + } + case CPU_THREAD_RAW_SPU: + { + new_thread = new RawSPUThread(); + break; + } + case CPU_THREAD_ARMv7: + { + new_thread = new ARMv7Thread(); + break; + } default: assert(0); } diff --git a/rpcs3/Emu/CPU/CPUThreadManager.h b/rpcs3/Emu/CPU/CPUThreadManager.h index ba71cb78b9..ad312108d7 100644 --- a/rpcs3/Emu/CPU/CPUThreadManager.h +++ b/rpcs3/Emu/CPU/CPUThreadManager.h @@ -7,7 +7,6 @@ class CPUThreadManager { std::vector m_threads; std::mutex m_mtx_thread; - u32 m_raw_spu_num; public: CPUThreadManager(); diff --git a/rpcs3/Emu/Cell/RawSPUThread.cpp b/rpcs3/Emu/Cell/RawSPUThread.cpp index 4f81ccf513..7255e31952 100644 --- a/rpcs3/Emu/Cell/RawSPUThread.cpp +++ b/rpcs3/Emu/Cell/RawSPUThread.cpp @@ -7,12 +7,11 @@ #include "Emu/Cell/RawSPUThread.h" -RawSPUThread::RawSPUThread(u32 index, CPUThreadType type) +RawSPUThread::RawSPUThread(CPUThreadType type) : SPUThread(type) , MemoryBlock() - , m_index(index) { - Memory.InitRawSPU(SetRange(RAW_SPU_BASE_ADDR + RAW_SPU_OFFSET * index, RAW_SPU_PROB_OFFSET), m_index); + m_index = Memory.InitRawSPU(this); Reset(); } @@ -344,7 +343,7 @@ void RawSPUThread::Task() { PC = SPU.NPC.GetValue(); - CPUThread::Task(); + SPUThread::Task(); SPU.NPC.SetValue(PC); } diff --git a/rpcs3/Emu/Cell/RawSPUThread.h b/rpcs3/Emu/Cell/RawSPUThread.h index d8765a3b25..c7b3479f98 100644 --- a/rpcs3/Emu/Cell/RawSPUThread.h +++ b/rpcs3/Emu/Cell/RawSPUThread.h @@ -19,7 +19,7 @@ class RawSPUThread u32 m_index; public: - RawSPUThread(u32 index, CPUThreadType type = CPU_THREAD_RAW_SPU); + RawSPUThread(CPUThreadType type = CPU_THREAD_RAW_SPU); virtual ~RawSPUThread(); virtual bool Read32(const u64 addr, u32* value) override; From e1a9f08a91f55aedf836ee6a6e0b6c6f08d91ee4 Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Wed, 16 Jul 2014 16:07:38 +0400 Subject: [PATCH 05/18] sys_raw_spu_destroy implemented --- rpcs3/Emu/SysCalls/lv2/sys_spu.cpp | 72 +++++++++++++----------------- 1 file changed, 31 insertions(+), 41 deletions(-) diff --git a/rpcs3/Emu/SysCalls/lv2/sys_spu.cpp b/rpcs3/Emu/SysCalls/lv2/sys_spu.cpp index 4a88fb9c48..68303a28a4 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_spu.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_spu.cpp @@ -18,46 +18,12 @@ u32 LoadSpuImage(vfsStream& stream, u32& spu_ep) { ELFLoader l(stream); l.LoadInfo(); - const u32 alloc_size = 256 * 1024 /*0x1000000 - stream.GetSize()*/; + const u32 alloc_size = 256 * 1024; u32 spu_offset = Memory.MainMem.AllocAlign(alloc_size); l.LoadData(spu_offset); spu_ep = l.GetEntry(); return spu_offset; } -/*u64 g_last_spu_offset = 0; -static const u64 g_spu_alloc_size = 0x1000000; - -u32 LoadSpuImage(vfsStream& stream, u64 address) -{ - ELFLoader l(stream); - l.LoadInfo(); - l.LoadData(address); - - return address + l.GetEntry(); -} - -u32 LoadSpuImage(vfsStream& stream) -{ - g_last_spu_offset = Memory.MainMem.Alloc(g_spu_alloc_size); - return LoadSpuImage(stream, g_last_spu_offset); -}*/ - -/*u32 _max_usable_spu = 0; -u32 _max_raw_spu = 0; - -s32 sys_spu_initialize(u32 max_usable_spu, u32 max_raw_spu) -{ - sc_spu.Log("sys_spu_initialize(max_usable_spu=%d, max_raw_spu=%d)", max_usable_spu, max_raw_spu); - _max_usable_spu = max_usable_spu; - _max_raw_spu = max_raw_spu; - return CELL_OK; -} - -s32 sys_raw_spu_create(u32 id_addr, u32 attr_addr) -{ - Memory.Write32(id_addr, Emu.GetIdManager().GetNewID("raw_spu")); - return CELL_OK; -}*/ //156 s32 sys_spu_image_open(mem_ptr_t img, u32 path_addr) @@ -349,13 +315,23 @@ s32 sys_spu_thread_group_join(u32 id, mem32_t cause, mem32_t status) return CELL_ESRCH; } + if (cause.GetAddr() && !cause.IsGood()) + { + return CELL_EFAULT; + } + + if (status.GetAddr() && !status.IsGood()) + { + return CELL_EFAULT; + } + if (group_info->lock.exchange(1)) // acquire lock { return CELL_EBUSY; } - cause = SYS_SPU_THREAD_GROUP_JOIN_ALL_THREADS_EXIT; - status = 0; //unspecified because of ALL_THREADS_EXIT + if (cause.GetAddr()) cause = SYS_SPU_THREAD_GROUP_JOIN_ALL_THREADS_EXIT; + if (status.GetAddr()) status = 0; //unspecified because of ALL_THREADS_EXIT for (u32 i = 0; i < group_info->list.size(); i++) { @@ -796,24 +772,38 @@ s32 sys_raw_spu_create(mem32_t id, u32 attr_addr) { sc_spu.Warning("sys_raw_spu_create(id_addr=0x%x, attr_addr=0x%x)", id.GetAddr(), attr_addr); - //Emu.GetIdManager().GetNewID("sys_raw_spu", new u32(attr_addr)); CPUThread& new_thread = Emu.GetCPU().AddThread(CPU_THREAD_RAW_SPU); + if (((RawSPUThread&)new_thread).GetIndex() >= 5) + { + Emu.GetCPU().RemoveThread(new_thread.GetId()); + return CELL_EAGAIN; + } + id = ((RawSPUThread&)new_thread).GetIndex(); new_thread.Run(); - return CELL_OK; } s32 sys_raw_spu_destroy(u32 id) { - sc_spu.Error("sys_raw_spu_destroy(id=%d)", id); + sc_spu.Warning("sys_raw_spu_destroy(id=%d)", id); + RawSPUThread* t = Emu.GetCPU().GetRawSPUThread(id); + + if (!t) + { + return CELL_ESRCH; + } + + // TODO: check if busy + + Emu.GetCPU().RemoveThread(t->GetId()); return CELL_OK; } s32 sys_raw_spu_create_interrupt_tag(u32 id, u32 class_id, u32 hwthread, mem32_t intrtag) { - sc_spu.Error("sys_raw_spu_create_interrupt_tag(id=%d, class_id=%d, hwthread=0x%x, intrtag_addr=0x%x)", id, class_id, hwthread, intrtag.GetAddr()); + sc_spu.Warning("sys_raw_spu_create_interrupt_tag(id=%d, class_id=%d, hwthread=0x%x, intrtag_addr=0x%x)", id, class_id, hwthread, intrtag.GetAddr()); RawSPUThread* t = Emu.GetCPU().GetRawSPUThread(id); From d94ce7094e857f11baac31f70addb5f9041771ea Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Wed, 16 Jul 2014 16:09:20 +0400 Subject: [PATCH 06/18] Rounding mode set --- rpcs3/Emu/Cell/SPUThread.cpp | 15 +++++++++++++++ rpcs3/Emu/Cell/SPUThread.h | 1 + 2 files changed, 16 insertions(+) diff --git a/rpcs3/Emu/Cell/SPUThread.cpp b/rpcs3/Emu/Cell/SPUThread.cpp index a8355bc296..9c020cb219 100644 --- a/rpcs3/Emu/Cell/SPUThread.cpp +++ b/rpcs3/Emu/Cell/SPUThread.cpp @@ -10,6 +10,8 @@ #include "Emu/Cell/SPUDisAsm.h" #include "Emu/Cell/SPURecompiler.h" +#include + SPUThread& GetCurrentSPUThread() { PPCThread* thread = GetCurrentPPCThread(); @@ -35,6 +37,19 @@ SPUThread::~SPUThread() { } +void SPUThread::Task() +{ + const int round = std::fegetround(); + std::fesetround(FE_TOWARDZERO); + + CPUThread::Task(); + if (std::fegetround() != FE_TOWARDZERO) + { + LOG_ERROR(Log::SPU, "Rounding mode has changed(%d)", std::fegetround()); + } + std::fesetround(round); +} + void SPUThread::DoReset() { PPCThread::DoReset(); diff --git a/rpcs3/Emu/Cell/SPUThread.h b/rpcs3/Emu/Cell/SPUThread.h index a56751bbe8..5f38235859 100644 --- a/rpcs3/Emu/Cell/SPUThread.h +++ b/rpcs3/Emu/Cell/SPUThread.h @@ -1444,6 +1444,7 @@ public: public: virtual void InitRegs(); virtual u64 GetFreeStackSize() const; + virtual void Task(); protected: virtual void DoReset(); From 3d9c76a80d7fe0d74932b3afb20452dccf380fc0 Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Wed, 16 Jul 2014 16:09:43 +0400 Subject: [PATCH 07/18] RawSPU initialization fix --- rpcs3/Emu/Memory/Memory.h | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/rpcs3/Emu/Memory/Memory.h b/rpcs3/Emu/Memory/Memory.h index 6430e27d80..88cc1dea6d 100644 --- a/rpcs3/Emu/Memory/Memory.h +++ b/rpcs3/Emu/Memory/Memory.h @@ -214,12 +214,22 @@ public: } } - void InitRawSPU(MemoryBlock* raw_spu, const u32 num) + u32 InitRawSPU(MemoryBlock* raw_spu) { std::lock_guard lock(m_mutex); - MemoryBlocks.push_back(raw_spu); - if (num < sizeof(RawSPUMem) / sizeof(RawSPUMem[0])) RawSPUMem[num] = raw_spu; + u32 index; + for (index = 0; index < sizeof(RawSPUMem) / sizeof(RawSPUMem[0]); index++) + { + if (!RawSPUMem[index]) + { + RawSPUMem[index] = raw_spu; + break; + } + } + + MemoryBlocks.push_back(raw_spu->SetRange(RAW_SPU_BASE_ADDR + RAW_SPU_OFFSET * index, RAW_SPU_PROB_OFFSET)); + return index; } void CloseRawSPU(MemoryBlock* raw_spu, const u32 num) From 3d0983e7d021ccc24ea2f462c9f2cc1bfcecf225 Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Wed, 16 Jul 2014 16:13:11 +0400 Subject: [PATCH 08/18] SPU Interpreter fix (these bugs weren't in SPURecompiler) --- rpcs3/Emu/Cell/SPUInterpreter.h | 156 +++++++++++++++++++++----------- 1 file changed, 102 insertions(+), 54 deletions(-) diff --git a/rpcs3/Emu/Cell/SPUInterpreter.h b/rpcs3/Emu/Cell/SPUInterpreter.h index 32fa60e91c..b340677966 100644 --- a/rpcs3/Emu/Cell/SPUInterpreter.h +++ b/rpcs3/Emu/Cell/SPUInterpreter.h @@ -503,29 +503,50 @@ private: void ROTQBI(u32 rt, u32 ra, u32 rb) { const int t = CPU.GPR[rb]._u32[3] & 0x7; - const SPU_GPR_hdr temp = CPU.GPR[ra]; - CPU.GPR[rt]._u32[0] = (temp._u32[0] << t) | (temp._u32[3] >> (32 - t)); - CPU.GPR[rt]._u32[1] = (temp._u32[1] << t) | (temp._u32[0] >> (32 - t)); - CPU.GPR[rt]._u32[2] = (temp._u32[2] << t) | (temp._u32[1] >> (32 - t)); - CPU.GPR[rt]._u32[3] = (temp._u32[3] << t) | (temp._u32[2] >> (32 - t)); + if (t) // not an optimization, it fixes shifts + { + const SPU_GPR_hdr temp = CPU.GPR[ra]; + CPU.GPR[rt]._u32[0] = (temp._u32[0] << t) | (temp._u32[3] >> (32 - t)); + CPU.GPR[rt]._u32[1] = (temp._u32[1] << t) | (temp._u32[0] >> (32 - t)); + CPU.GPR[rt]._u32[2] = (temp._u32[2] << t) | (temp._u32[1] >> (32 - t)); + CPU.GPR[rt]._u32[3] = (temp._u32[3] << t) | (temp._u32[2] >> (32 - t)); + } + else + { + CPU.GPR[rt] = CPU.GPR[ra]; + } } void ROTQMBI(u32 rt, u32 ra, u32 rb) { const int t = (0 - CPU.GPR[rb]._u32[3]) & 0x7; - const SPU_GPR_hdr temp = CPU.GPR[ra]; - CPU.GPR[rt]._u32[0] = (temp._u32[0] >> t) | (temp._u32[1] << (32 - t)); - CPU.GPR[rt]._u32[1] = (temp._u32[1] >> t) | (temp._u32[2] << (32 - t)); - CPU.GPR[rt]._u32[2] = (temp._u32[2] >> t) | (temp._u32[3] << (32 - t)); - CPU.GPR[rt]._u32[3] = (temp._u32[3] >> t); + if (t) // not an optimization, it fixes shifts + { + const SPU_GPR_hdr temp = CPU.GPR[ra]; + CPU.GPR[rt]._u32[0] = (temp._u32[0] >> t) | (temp._u32[1] << (32 - t)); + CPU.GPR[rt]._u32[1] = (temp._u32[1] >> t) | (temp._u32[2] << (32 - t)); + CPU.GPR[rt]._u32[2] = (temp._u32[2] >> t) | (temp._u32[3] << (32 - t)); + CPU.GPR[rt]._u32[3] = (temp._u32[3] >> t); + } + else + { + CPU.GPR[rt] = CPU.GPR[ra]; + } } void SHLQBI(u32 rt, u32 ra, u32 rb) { const int t = CPU.GPR[rb]._u32[3] & 0x7; - const SPU_GPR_hdr temp = CPU.GPR[ra]; - CPU.GPR[rt]._u32[0] = (temp._u32[0] << t); - CPU.GPR[rt]._u32[1] = (temp._u32[1] << t) | (temp._u32[0] >> (32 - t)); - CPU.GPR[rt]._u32[2] = (temp._u32[2] << t) | (temp._u32[1] >> (32 - t)); - CPU.GPR[rt]._u32[3] = (temp._u32[3] << t) | (temp._u32[2] >> (32 - t)); + if (t) // not an optimization, it fixes shifts + { + const SPU_GPR_hdr temp = CPU.GPR[ra]; + CPU.GPR[rt]._u32[0] = (temp._u32[0] << t); + CPU.GPR[rt]._u32[1] = (temp._u32[1] << t) | (temp._u32[0] >> (32 - t)); + CPU.GPR[rt]._u32[2] = (temp._u32[2] << t) | (temp._u32[1] >> (32 - t)); + CPU.GPR[rt]._u32[3] = (temp._u32[3] << t) | (temp._u32[2] >> (32 - t)); + } + else + { + CPU.GPR[rt] = CPU.GPR[ra]; + } } void ROTQBY(u32 rt, u32 ra, u32 rb) { @@ -591,29 +612,50 @@ private: void ROTQBII(u32 rt, u32 ra, s32 i7) { const int s = i7 & 0x7; - const SPU_GPR_hdr temp = CPU.GPR[ra]; - CPU.GPR[rt]._u32[0] = (temp._u32[0] << s) | (temp._u32[3] >> (32 - s)); - CPU.GPR[rt]._u32[1] = (temp._u32[1] << s) | (temp._u32[0] >> (32 - s)); - CPU.GPR[rt]._u32[2] = (temp._u32[2] << s) | (temp._u32[1] >> (32 - s)); - CPU.GPR[rt]._u32[3] = (temp._u32[3] << s) | (temp._u32[2] >> (32 - s)); + if (s) // not an optimization, it fixes shifts + { + const SPU_GPR_hdr temp = CPU.GPR[ra]; + CPU.GPR[rt]._u32[0] = (temp._u32[0] << s) | (temp._u32[3] >> (32 - s)); + CPU.GPR[rt]._u32[1] = (temp._u32[1] << s) | (temp._u32[0] >> (32 - s)); + CPU.GPR[rt]._u32[2] = (temp._u32[2] << s) | (temp._u32[1] >> (32 - s)); + CPU.GPR[rt]._u32[3] = (temp._u32[3] << s) | (temp._u32[2] >> (32 - s)); + } + else + { + CPU.GPR[rt] = CPU.GPR[ra]; + } } void ROTQMBII(u32 rt, u32 ra, s32 i7) { const int s = (0 - i7) & 0x7; - const SPU_GPR_hdr temp = CPU.GPR[ra]; - CPU.GPR[rt]._u32[0] = (temp._u32[0] >> s) | (temp._u32[1] << (32 - s)); - CPU.GPR[rt]._u32[1] = (temp._u32[1] >> s) | (temp._u32[2] << (32 - s)); - CPU.GPR[rt]._u32[2] = (temp._u32[2] >> s) | (temp._u32[3] << (32 - s)); - CPU.GPR[rt]._u32[3] = (temp._u32[3] >> s); + if (s) // not an optimization, it fixes shifts + { + const SPU_GPR_hdr temp = CPU.GPR[ra]; + CPU.GPR[rt]._u32[0] = (temp._u32[0] >> s) | (temp._u32[1] << (32 - s)); + CPU.GPR[rt]._u32[1] = (temp._u32[1] >> s) | (temp._u32[2] << (32 - s)); + CPU.GPR[rt]._u32[2] = (temp._u32[2] >> s) | (temp._u32[3] << (32 - s)); + CPU.GPR[rt]._u32[3] = (temp._u32[3] >> s); + } + else + { + CPU.GPR[rt] = CPU.GPR[ra]; + } } void SHLQBII(u32 rt, u32 ra, s32 i7) { const int s = i7 & 0x7; - const SPU_GPR_hdr temp = CPU.GPR[ra]; - CPU.GPR[rt]._u32[0] = (temp._u32[0] << s); - CPU.GPR[rt]._u32[1] = (temp._u32[1] << s) | (temp._u32[0] >> (32 - s)); - CPU.GPR[rt]._u32[2] = (temp._u32[2] << s) | (temp._u32[1] >> (32 - s)); - CPU.GPR[rt]._u32[3] = (temp._u32[3] << s) | (temp._u32[2] >> (32 - s)); + if (s) // not an optimization, it fixes shifts + { + const SPU_GPR_hdr temp = CPU.GPR[ra]; + CPU.GPR[rt]._u32[0] = (temp._u32[0] << s); + CPU.GPR[rt]._u32[1] = (temp._u32[1] << s) | (temp._u32[0] >> (32 - s)); + CPU.GPR[rt]._u32[2] = (temp._u32[2] << s) | (temp._u32[1] >> (32 - s)); + CPU.GPR[rt]._u32[3] = (temp._u32[3] << s) | (temp._u32[2] >> (32 - s)); + } + else + { + CPU.GPR[rt] = CPU.GPR[ra]; + } } void ROTQBYI(u32 rt, u32 ra, s32 i7) { @@ -747,24 +789,27 @@ private: } void FA(u32 rt, u32 ra, u32 rb) { - CPU.GPR[rt]._f[0] = CPU.GPR[ra]._f[0] + CPU.GPR[rb]._f[0]; - CPU.GPR[rt]._f[1] = CPU.GPR[ra]._f[1] + CPU.GPR[rb]._f[1]; - CPU.GPR[rt]._f[2] = CPU.GPR[ra]._f[2] + CPU.GPR[rb]._f[2]; - CPU.GPR[rt]._f[3] = CPU.GPR[ra]._f[3] + CPU.GPR[rb]._f[3]; + for (int w = 0; w < 4; w++) + { + CPU.GPR[rt]._f[w] = CPU.GPR[ra]._f[w] + CPU.GPR[rb]._f[w]; + //if (CPU.GPR[rt]._f[w] == -0.0f) CPU.GPR[rt]._f[w] = 0.0f; + } } void FS(u32 rt, u32 ra, u32 rb) { - CPU.GPR[rt]._f[0] = CPU.GPR[ra]._f[0] - CPU.GPR[rb]._f[0]; - CPU.GPR[rt]._f[1] = CPU.GPR[ra]._f[1] - CPU.GPR[rb]._f[1]; - CPU.GPR[rt]._f[2] = CPU.GPR[ra]._f[2] - CPU.GPR[rb]._f[2]; - CPU.GPR[rt]._f[3] = CPU.GPR[ra]._f[3] - CPU.GPR[rb]._f[3]; + for (int w = 0; w < 4; w++) + { + CPU.GPR[rt]._f[w] = CPU.GPR[ra]._f[w] - CPU.GPR[rb]._f[w]; + //if (CPU.GPR[rt]._f[w] == -0.0f) CPU.GPR[rt]._f[w] = 0.0f; + } } void FM(u32 rt, u32 ra, u32 rb) { - CPU.GPR[rt]._f[0] = CPU.GPR[ra]._f[0] * CPU.GPR[rb]._f[0]; - CPU.GPR[rt]._f[1] = CPU.GPR[ra]._f[1] * CPU.GPR[rb]._f[1]; - CPU.GPR[rt]._f[2] = CPU.GPR[ra]._f[2] * CPU.GPR[rb]._f[2]; - CPU.GPR[rt]._f[3] = CPU.GPR[ra]._f[3] * CPU.GPR[rb]._f[3]; + for (int w = 0; w < 4; w++) + { + CPU.GPR[rt]._f[w] = CPU.GPR[ra]._f[w] * CPU.GPR[rb]._f[w]; + //if (CPU.GPR[rt]._f[w] == -0.0f) CPU.GPR[rt]._f[w] = 0.0f; + } } void CLGTH(u32 rt, u32 ra, u32 rb) { @@ -1513,24 +1558,27 @@ private: } void FNMS(u32 rt, u32 ra, u32 rb, u32 rc) { - CPU.GPR[rt]._f[0] = CPU.GPR[rc]._f[0] - CPU.GPR[ra]._f[0] * CPU.GPR[rb]._f[0]; - CPU.GPR[rt]._f[1] = CPU.GPR[rc]._f[1] - CPU.GPR[ra]._f[1] * CPU.GPR[rb]._f[1]; - CPU.GPR[rt]._f[2] = CPU.GPR[rc]._f[2] - CPU.GPR[ra]._f[2] * CPU.GPR[rb]._f[2]; - CPU.GPR[rt]._f[3] = CPU.GPR[rc]._f[3] - CPU.GPR[ra]._f[3] * CPU.GPR[rb]._f[3]; + for (int w = 0; w < 4; w++) + { + CPU.GPR[rt]._f[w] = CPU.GPR[rc]._f[w] - CPU.GPR[ra]._f[w] * CPU.GPR[rb]._f[w]; + //if (CPU.GPR[rt]._f[w] == -0.0f) CPU.GPR[rt]._f[w] = 0.0f; + } } void FMA(u32 rt, u32 ra, u32 rb, u32 rc) { - CPU.GPR[rt]._f[0] = CPU.GPR[ra]._f[0] * CPU.GPR[rb]._f[0] + CPU.GPR[rc]._f[0]; - CPU.GPR[rt]._f[1] = CPU.GPR[ra]._f[1] * CPU.GPR[rb]._f[1] + CPU.GPR[rc]._f[1]; - CPU.GPR[rt]._f[2] = CPU.GPR[ra]._f[2] * CPU.GPR[rb]._f[2] + CPU.GPR[rc]._f[2]; - CPU.GPR[rt]._f[3] = CPU.GPR[ra]._f[3] * CPU.GPR[rb]._f[3] + CPU.GPR[rc]._f[3]; + for (int w = 0; w < 4; w++) + { + CPU.GPR[rt]._f[w] = CPU.GPR[rc]._f[w] + CPU.GPR[ra]._f[w] * CPU.GPR[rb]._f[w]; + //if (CPU.GPR[rt]._f[w] == -0.0f) CPU.GPR[rt]._f[w] = 0.0f; + } } void FMS(u32 rt, u32 ra, u32 rb, u32 rc) { - CPU.GPR[rt]._f[0] = CPU.GPR[ra]._f[0] * CPU.GPR[rb]._f[0] - CPU.GPR[rc]._f[0]; - CPU.GPR[rt]._f[1] = CPU.GPR[ra]._f[1] * CPU.GPR[rb]._f[1] - CPU.GPR[rc]._f[1]; - CPU.GPR[rt]._f[2] = CPU.GPR[ra]._f[2] * CPU.GPR[rb]._f[2] - CPU.GPR[rc]._f[2]; - CPU.GPR[rt]._f[3] = CPU.GPR[ra]._f[3] * CPU.GPR[rb]._f[3] - CPU.GPR[rc]._f[3]; + for (int w = 0; w < 4; w++) + { + CPU.GPR[rt]._f[w] = CPU.GPR[ra]._f[w] * CPU.GPR[rb]._f[w] - CPU.GPR[rc]._f[w]; + //if (CPU.GPR[rt]._f[w] == -0.0f) CPU.GPR[rt]._f[w] = 0.0f; + } } void UNK(u32 code, u32 opcode, u32 gcode) From 694a2b774ed3eb415df26bf92d46b5affef84296 Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Wed, 16 Jul 2014 16:15:20 +0400 Subject: [PATCH 09/18] SPU Recompiler fix --- rpcs3/Emu/Cell/SPURecompiler.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rpcs3/Emu/Cell/SPURecompiler.h b/rpcs3/Emu/Cell/SPURecompiler.h index 7b019ac5ca..0851c70a3e 100644 --- a/rpcs3/Emu/Cell/SPURecompiler.h +++ b/rpcs3/Emu/Cell/SPURecompiler.h @@ -1485,8 +1485,8 @@ private: c.movdqa(vr.get(), XmmConst(_mm_set_epi32(0x10111213, 0x14151617, 0x18191a1b, 0x1c1d1e1f))); XmmFinalize(vr, rt); XmmInvalidate(rt); - c.mov(dword_ptr(*cpu_var, *addr, 0, offsetof(SPUThread, GPR[rt]._u32[0])), 0x00010203); - c.mov(dword_ptr(*cpu_var, *addr, 0, offsetof(SPUThread, GPR[rt]._u32[1])), 0x04050607); + c.mov(dword_ptr(*cpu_var, *addr, 0, offsetof(SPUThread, GPR[rt]._u32[0])), 0x04050607); + c.mov(dword_ptr(*cpu_var, *addr, 0, offsetof(SPUThread, GPR[rt]._u32[1])), 0x00010203); LOG_OPCODE(); } void ROTQBI(u32 rt, u32 ra, u32 rb) @@ -1628,8 +1628,8 @@ private: c.movdqa(vr.get(), XmmConst(_mm_set_epi32(0x10111213, 0x14151617, 0x18191a1b, 0x1c1d1e1f))); XmmFinalize(vr, rt); XmmInvalidate(rt); - c.mov(dword_ptr(*cpu_var, *addr, 0, offsetof(SPUThread, GPR[rt]._u32[0])), 0x00010203); - c.mov(dword_ptr(*cpu_var, *addr, 0, offsetof(SPUThread, GPR[rt]._u32[1])), 0x04050607); + c.mov(dword_ptr(*cpu_var, *addr, 0, offsetof(SPUThread, GPR[rt]._u32[0])), 0x04050607); + c.mov(dword_ptr(*cpu_var, *addr, 0, offsetof(SPUThread, GPR[rt]._u32[1])), 0x00010203); LOG_OPCODE(); } void ROTQBII(u32 rt, u32 ra, s32 i7) From ecbc9d1b080494342f5682937e93881f1590b49e Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Wed, 16 Jul 2014 20:10:18 +0400 Subject: [PATCH 10/18] RawSPU cleanup --- rpcs3/Emu/Cell/RawSPUThread.cpp | 183 ++++---------------------------- rpcs3/Emu/Cell/SPUThread.cpp | 6 +- rpcs3/Emu/Cell/SPUThread.h | 49 ++++----- rpcs3/Emu/Memory/Memory.h | 10 +- 4 files changed, 54 insertions(+), 194 deletions(-) diff --git a/rpcs3/Emu/Cell/RawSPUThread.cpp b/rpcs3/Emu/Cell/RawSPUThread.cpp index 7255e31952..2337f6d0e1 100644 --- a/rpcs3/Emu/Cell/RawSPUThread.cpp +++ b/rpcs3/Emu/Cell/RawSPUThread.cpp @@ -22,75 +22,20 @@ RawSPUThread::~RawSPUThread() bool RawSPUThread::Read32(const u64 addr, u32* value) { - if(addr < GetStartAddr() + RAW_SPU_PROB_OFFSET) - { - return MemoryBlock::Read32(addr, value); - } + const u64 offset = addr - GetStartAddr() - RAW_SPU_PROB_OFFSET; - const u32 offset = addr - GetStartAddr() - RAW_SPU_PROB_OFFSET; - - switch(offset) + switch (offset) { - case MFC_LSA_offs: - { - LOG_ERROR(Log::SPU, "RawSPUThread[%d]: Read32(MFC_LSA)", m_index); - *value = MFC2.LSA.GetValue(); - break; - } - - case MFC_EAH_offs: - { - LOG_ERROR(Log::SPU, "RawSPUThread[%d]: Read32(MFC_EAH)", m_index); - *value = MFC2.EAH.GetValue(); - break; - } - - case MFC_EAL_offs: - { - LOG_ERROR(Log::SPU, "RawSPUThread[%d]: Read32(MFC_EAL)", m_index); - *value = MFC2.EAL.GetValue(); - break; - } - - case MFC_Size_Tag_offs: - { - LOG_ERROR(Log::SPU, "RawSPUThread[%d]: Read32(MFC_Size_Tag)", m_index); - *value = MFC2.Size_Tag.GetValue(); - break; - } - case MFC_CMDStatus_offs: { - LOG_ERROR(Log::SPU, "RawSPUThread[%d]: Read32(MFC_CMDStatus)", m_index); *value = MFC2.CMDStatus.GetValue(); break; } case MFC_QStatus_offs: { - LOG_WARNING(Log::SPU, "RawSPUThread[%d]: Read32(MFC_QStatus)", m_index); - *value = MFC2.QStatus.GetValue(); - break; - } - - case Prxy_QueryType_offs: - { - LOG_WARNING(Log::SPU, "RawSPUThread[%d]: Read32(Prxy_QueryType)", m_index); - *value = Prxy.QueryType.GetValue(); - break; - } - - case Prxy_QueryMask_offs: - { - LOG_WARNING(Log::SPU, "RawSPUThread[%d]: Read32(Prxy_QueryMask)", m_index); - *value = Prxy.QueryMask.GetValue(); - break; - } - - case Prxy_TagStatus_offs: - { - LOG_WARNING(Log::SPU, "RawSPUThread[%d]: Read32(Prxy_TagStatus)", m_index); - *value = Prxy.TagStatus.GetValue(); + // TagStatus is not used: mask is written directly + *value = MFC2.QueryMask.GetValue(); break; } @@ -100,62 +45,23 @@ bool RawSPUThread::Read32(const u64 addr, u32* value) SPU.Out_MBox.PopUncond(*value); break; } - - case SPU_In_MBox_offs: - { - LOG_ERROR(Log::SPU, "RawSPUThread[%d]: Read32(SPU_In_MBox)", m_index); - while (!SPU.In_MBox.Pop(*value) && !Emu.IsStopped()) - std::this_thread::sleep_for(std::chrono::milliseconds(1)); - break; - } case SPU_MBox_Status_offs: { - //LOG_WARNING(Log::SPU, "RawSPUThread[%d]: Read32(SPU_MBox_Status)", m_index); - //SPU.MBox_Status.SetValue(SPU.Out_MBox.GetCount() ? SPU.MBox_Status.GetValue() | 1 : SPU.MBox_Status.GetValue() & ~1); - SPU.MBox_Status.SetValue((SPU.Out_MBox.GetCount() & 0xff) | (SPU.In_MBox.GetFreeCount() << 8)); - *value = SPU.MBox_Status.GetValue(); + *value = (SPU.Out_MBox.GetCount() & 0xff) | (SPU.In_MBox.GetFreeCount() << 8); break; } - case SPU_RunCntl_offs: - { - LOG_ERROR(Log::SPU, "RawSPUThread[%d]: Read32(SPU_RunCntl)", m_index); - *value = (u32)IsRunning(); - break; - } - case SPU_Status_offs: { *value = SPU.Status.GetValue(); break; } - - case SPU_NPC_offs: - { - LOG_ERROR(Log::SPU, "RawSPUThread[%d]: Read32(SPU_NPC)", m_index); - *value = SPU.NPC.GetValue(); - break; - } - - case SPU_RdSigNotify1_offs: - { - LOG_ERROR(Log::SPU, "RawSPUThread[%d]: Read32(SPU_RdSigNotify1)", m_index); - *value = SPU.SNR[0].GetValue(); - break; - } - - case SPU_RdSigNotify2_offs: - { - LOG_ERROR(Log::SPU, "RawSPUThread[%d]: Read32(SPU_RdSigNotify2)", m_index); - *value = SPU.SNR[1].GetValue(); - break; - } default: { - LOG_ERROR(Log::SPU, "RawSPUThread[%d]: Read32(0x%x)", m_index, offset); - Emu.Pause(); + // TODO: read value from LS if necessary (not important) + LOG_ERROR(Log::SPU, "RawSPUThread[%d]: Read32(0x%llx)", m_index, offset); return false; } } @@ -165,14 +71,9 @@ bool RawSPUThread::Read32(const u64 addr, u32* value) bool RawSPUThread::Write32(const u64 addr, const u32 value) { - if(addr < GetStartAddr() + RAW_SPU_PROB_OFFSET) - { - return MemoryBlock::Write32(addr, value); - } + const u64 offset = addr - GetStartAddr() - RAW_SPU_PROB_OFFSET; - const u32 offset = addr - GetStartAddr() - RAW_SPU_PROB_OFFSET; - - switch(offset) + switch (offset) { case MFC_LSA_offs: { @@ -205,53 +106,26 @@ bool RawSPUThread::Write32(const u64 addr, const u32 value) break; } - case MFC_QStatus_offs: - { - LOG_ERROR(Log::SPU, "RawSPUThread[%d]: Write32(MFC_QStatus, 0x%x)", m_index, value); - //MFC2.QStatus.SetValue(value); - break; - } - case Prxy_QueryType_offs: { - LOG_WARNING(Log::SPU, "RawSPUThread[%d]: Write32(Prxy_QueryType, 0x%x)", m_index, value); - Prxy.QueryType.SetValue(value); - switch(value) { - case 2: - LOG_WARNING(Log::SPU, "RawSPUThread[%d]: Prxy Query Immediate.", m_index); - break; + case 2: break; default: + { LOG_ERROR(Log::SPU, "RawSPUThread[%d]: Unknown Prxy Query Type. (prxy_query=0x%x)", m_index, value); - break; + return false; + } } - Prxy.QueryType.SetValue(0); - MFC2.QStatus.SetValue(Prxy.QueryMask.GetValue()); + MFC2.QueryType.SetValue(value); // not used break; } case Prxy_QueryMask_offs: { - LOG_WARNING(Log::SPU, "RawSPUThread[%d]: Write32(Prxy_QueryMask, 0x%x)", m_index, value); - Prxy.QueryMask.SetValue(value); - break; - } - - case Prxy_TagStatus_offs: - { - LOG_WARNING(Log::SPU, "RawSPUThread[%d]: Write32(Prxy_TagStatus, 0x%x)", m_index, value); - Prxy.TagStatus.SetValue(value); - break; - } - - case SPU_Out_MBox_offs: - { - LOG_WARNING(Log::SPU, "RawSPUThread[%d]: Write32(SPU_Out_MBox, 0x%x)", m_index, value); - while (!SPU.Out_MBox.Push(value) && !Emu.IsStopped()) - std::this_thread::sleep_for(std::chrono::milliseconds(1)); + MFC2.QueryMask.SetValue(value); // TagStatus is not used break; } @@ -261,13 +135,6 @@ bool RawSPUThread::Write32(const u64 addr, const u32 value) SPU.In_MBox.PushUncond(value); break; } - - case SPU_MBox_Status_offs: - { - LOG_WARNING(Log::SPU, "RawSPUThread[%d]: Write32(SPU_MBox_Status, 0x%x)", m_index, value); - SPU.MBox_Status.SetValue(value); - break; - } case SPU_RunCntl_offs: { @@ -289,39 +156,29 @@ bool RawSPUThread::Write32(const u64 addr, const u32 value) break; } - case SPU_Status_offs: - { - LOG_WARNING(Log::SPU, "RawSPUThread[%d]: Write32(SPU_Status, 0x%x)", m_index, value); - SPU.Status.SetValue(value); - break; - } - case SPU_NPC_offs: { - LOG_WARNING(Log::SPU, "RawSPUThread[%d]: Write32(SPU_NPC, 0x%x)", m_index, value); SPU.NPC.SetValue(value); break; } case SPU_RdSigNotify1_offs: { - LOG_WARNING(Log::SPU, "RawSPUThread[%d]: Write32(SPU_RdSigNotify1, 0x%x)", m_index, value); - SPU.SNR[0].SetValue(value); + WriteSNR(0, value); break; } case SPU_RdSigNotify2_offs: { - LOG_WARNING(Log::SPU, "RawSPUThread[%d]: Write32(SPU_RdSigNotify2, 0x%x)", m_index, value); - SPU.SNR[1].SetValue(value); + WriteSNR(1, value); break; } default: { - LOG_ERROR(Log::SPU, "RawSPUThread[%d]: Write32(0x%x, 0x%x)", m_index, offset, value); - Emu.Pause(); - break; + // TODO: write value to LS if necessary (not important) + LOG_ERROR(Log::SPU, "RawSPUThread[%d]: Write32(0x%llx, 0x%x)", m_index, offset, value); + return false; } } diff --git a/rpcs3/Emu/Cell/SPUThread.cpp b/rpcs3/Emu/Cell/SPUThread.cpp index 9c020cb219..235b73700c 100644 --- a/rpcs3/Emu/Cell/SPUThread.cpp +++ b/rpcs3/Emu/Cell/SPUThread.cpp @@ -75,9 +75,13 @@ void SPUThread::InitRegs() dmac.queue_lock = 0;*/ SPU.Status.SetValue(SPU_STATUS_STOPPED); - Prxy.QueryType.SetValue(0); + + // TODO: check initialization if necessary + MFC2.QueryType.SetValue(0); // prxy MFC1.CMDStatus.SetValue(0); MFC2.CMDStatus.SetValue(0); + MFC1.TagStatus.SetValue(0); + MFC2.TagStatus.SetValue(0); //PC = SPU.NPC.GetValue(); } diff --git a/rpcs3/Emu/Cell/SPUThread.h b/rpcs3/Emu/Cell/SPUThread.h index 5f38235859..abc187e9c2 100644 --- a/rpcs3/Emu/Cell/SPUThread.h +++ b/rpcs3/Emu/Cell/SPUThread.h @@ -523,16 +523,11 @@ public: Channel<1> EAL; Channel<1> Size_Tag; Channel<1> CMDStatus; - Channel<1> QStatus; - } MFC1, MFC2; - - struct - { - Channel<1> QueryType; + Channel<1> QueryType; // only for prxy Channel<1> QueryMask; Channel<1> TagStatus; Channel<1> AtomicStat; - } Prxy; + } MFC1, MFC2; struct StalledList { @@ -555,7 +550,6 @@ public: Channel<1> Out_MBox; Channel<1> Out_IntrMBox; Channel<4> In_MBox; - Channel<1> MBox_Status; Channel<1> Status; Channel<1> NPC; Channel<1> SNR[2]; @@ -831,7 +825,7 @@ public: reservation.data[i] = *(u128*)&Memory[(u32)ea + i * 16]; *(u128*)&Memory[dmac.ls_offset + lsa + i * 16] = reservation.data[i]; } - Prxy.AtomicStat.PushUncond(MFC_GETLLAR_SUCCESS); + MFCArgs.AtomicStat.PushUncond(MFC_GETLLAR_SUCCESS); } else if (op == MFC_PUTLLC_CMD) // store conditional { @@ -854,7 +848,7 @@ public: } if (changed == 0) // nothing changed? { - Prxy.AtomicStat.PushUncond(MFC_PUTLLC_SUCCESS); + MFCArgs.AtomicStat.PushUncond(MFC_PUTLLC_SUCCESS); } else if (changed == 1) { @@ -862,7 +856,7 @@ public: { LOG_ERROR(Log::SPU, "MFC_PUTLLC_CMD: TODO: 128bit compare and swap"); Emu.Pause(); - Prxy.AtomicStat.PushUncond(MFC_PUTLLC_SUCCESS); + MFCArgs.AtomicStat.PushUncond(MFC_PUTLLC_SUCCESS); } else { @@ -871,11 +865,11 @@ public: if (InterlockedCompareExchange64((volatile long long*)(Memory + (u32)ea + last * 16 + last_q * 8), buf[last]._u64[last_q], reservation.data[last]._u64[last_q]) == reservation.data[last]._u64[last_q]) { - Prxy.AtomicStat.PushUncond(MFC_PUTLLC_SUCCESS); + MFCArgs.AtomicStat.PushUncond(MFC_PUTLLC_SUCCESS); } else { - Prxy.AtomicStat.PushUncond(MFC_PUTLLC_FAILURE); + MFCArgs.AtomicStat.PushUncond(MFC_PUTLLC_FAILURE); } /*u32 last_d = last_q * 2; if (buf[last]._u32[last_d] == reservation.data[last]._u32[last_d] && buf[last]._u32[last_d+1] != reservation.data[last]._u32[last_d+1]) @@ -890,7 +884,7 @@ public: { LOG_ERROR(Log::SPU, "MFC_PUTLLC_CMD: TODO: 64bit compare and swap"); Emu.Pause(); - Prxy.AtomicStat.PushUncond(MFC_PUTLLC_SUCCESS); + MFCArgs.AtomicStat.PushUncond(MFC_PUTLLC_SUCCESS); }*/ } } @@ -900,18 +894,18 @@ public: LOG_ERROR(Log::SPU, "MFC_PUTLLC_CMD: Reservation Error: impossibru (~ 16x%d (mask=0x%x)) (opcode=0x%x, cmd=0x%x, lsa = 0x%x, ea = 0x%llx, tag = 0x%x, size = 0x%x)", changed, mask, op, cmd, lsa, ea, tag, size); Emu.Pause(); - Prxy.AtomicStat.PushUncond(MFC_PUTLLC_SUCCESS); + MFCArgs.AtomicStat.PushUncond(MFC_PUTLLC_SUCCESS); } } else { - Prxy.AtomicStat.PushUncond(MFC_PUTLLC_FAILURE); + MFCArgs.AtomicStat.PushUncond(MFC_PUTLLC_FAILURE); } reservation.clear(); } else // failed { - Prxy.AtomicStat.PushUncond(MFC_PUTLLC_FAILURE); + MFCArgs.AtomicStat.PushUncond(MFC_PUTLLC_FAILURE); } } else // store unconditional @@ -920,7 +914,7 @@ public: ProcessCmd(MFC_PUT_CMD, tag, lsa, ea, 128); if (op == MFC_PUTLLUC_CMD) { - Prxy.AtomicStat.PushUncond(MFC_PUTLLUC_SUCCESS); + MFCArgs.AtomicStat.PushUncond(MFC_PUTLLUC_SUCCESS); } if ((reservation.addr + reservation.size > ea && reservation.addr <= ea + size) || (ea + size > reservation.addr && ea <= reservation.addr + reservation.size)) @@ -944,12 +938,12 @@ public: { case SPU_WrOutMbox: return SPU.Out_MBox.GetFreeCount(); case SPU_RdInMbox: return SPU.In_MBox.GetCount(); - case MFC_RdTagStat: return Prxy.TagStatus.GetCount(); + case MFC_RdTagStat: return MFC1.TagStatus.GetCount(); case MFC_RdListStallStat: return StallStat.GetCount(); - case MFC_WrTagUpdate: return Prxy.TagStatus.GetCount(); // hack + case MFC_WrTagUpdate: return MFC1.TagStatus.GetCount(); // hack case SPU_RdSigNotify1: return SPU.SNR[0].GetCount(); case SPU_RdSigNotify2: return SPU.SNR[1].GetCount(); - case MFC_RdAtomicStat: return Prxy.AtomicStat.GetCount(); + case MFC_RdAtomicStat: return MFC1.AtomicStat.GetCount(); default: { @@ -1115,14 +1109,14 @@ public: case MFC_WrTagMask: { //ConLog.Warning("%s: %s = 0x%x", __FUNCTION__, spu_ch_name[ch], v); - Prxy.QueryMask.SetValue(v); + MFC1.QueryMask.SetValue(v); break; } case MFC_WrTagUpdate: { //ConLog.Warning("%s: %s = 0x%x", __FUNCTION__, spu_ch_name[ch], v); - Prxy.TagStatus.PushUncond(Prxy.QueryMask.GetValue()); + MFC1.TagStatus.PushUncond(MFC1.QueryMask.GetValue()); break; } @@ -1184,7 +1178,7 @@ public: case SPU_WrDec: { - m_dec_start = get_system_time(); + m_dec_start = get_time(); m_dec_value = v; break; } @@ -1215,7 +1209,7 @@ public: case MFC_RdTagStat: { - while (!Prxy.TagStatus.Pop(v) && !Emu.IsStopped()) std::this_thread::sleep_for(std::chrono::milliseconds(1)); + while (!MFC1.TagStatus.Pop(v) && !Emu.IsStopped()) std::this_thread::sleep_for(std::chrono::milliseconds(1)); //ConLog.Warning("%s: 0x%x = %s", __FUNCTION__, v, spu_ch_name[ch]); break; } @@ -1236,7 +1230,7 @@ public: case MFC_RdAtomicStat: { - while (!Prxy.AtomicStat.Pop(v) && !Emu.IsStopped()) std::this_thread::sleep_for(std::chrono::milliseconds(1)); + while (!MFC1.AtomicStat.Pop(v) && !Emu.IsStopped()) std::this_thread::sleep_for(std::chrono::milliseconds(1)); break; } @@ -1248,8 +1242,7 @@ public: case SPU_RdDec: { - // decrementer freq is probably 80 MHz - v = m_dec_value - (u32)(get_system_time() - m_dec_start) * 80; + v = m_dec_value - (u32)(get_time() - m_dec_start); break; } diff --git a/rpcs3/Emu/Memory/Memory.h b/rpcs3/Emu/Memory/Memory.h index 88cc1dea6d..c552fe2f7b 100644 --- a/rpcs3/Emu/Memory/Memory.h +++ b/rpcs3/Emu/Memory/Memory.h @@ -401,7 +401,10 @@ public: } else { - RawSPUMem[(addr - RAW_SPU_BASE_ADDR) / RAW_SPU_OFFSET]->Write32(addr, data); + if (!RawSPUMem[(addr - RAW_SPU_BASE_ADDR) / RAW_SPU_OFFSET]->Write32(addr, data)) + { + *(u32*)((u8*)GetBaseAddr() + addr) = re32(data); + } } } else @@ -474,7 +477,10 @@ public: else { u32 res; - RawSPUMem[(addr - RAW_SPU_BASE_ADDR) / RAW_SPU_OFFSET]->Read32(addr, &res); + if (!RawSPUMem[(addr - RAW_SPU_BASE_ADDR) / RAW_SPU_OFFSET]->Read32(addr, &res)) + { + res = re32(*(u32*)((u8*)GetBaseAddr() + addr)); + } return res; } } From c3e06694351b6ee153b2253502818aa9cdf1fb24 Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Wed, 16 Jul 2014 20:21:09 +0400 Subject: [PATCH 11/18] Time functions fixed --- rpcs3/Emu/SysCalls/lv2/sys_time.cpp | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/rpcs3/Emu/SysCalls/lv2/sys_time.cpp b/rpcs3/Emu/SysCalls/lv2/sys_time.cpp index 0a5ded0ce9..df4d2b109a 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_time.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_time.cpp @@ -14,22 +14,32 @@ SysCallBase sys_time("sys_time"); -//static const u64 timebase_frequency = 79800000; +static const u64 timebase_frequency = /*79800000*/ 80000000; // 80 Mhz extern int cellSysutilGetSystemParamInt(int id, mem32_t value); // Auxiliary functions u64 get_time() { #ifdef _WIN32 + static struct PerformanceFreqHolder + { + u64 value; + + PerformanceFreqHolder() + { + LARGE_INTEGER freq; + QueryPerformanceFrequency(&freq); + value = freq.QuadPart; + } + } freq; + LARGE_INTEGER cycle; - LARGE_INTEGER freq; QueryPerformanceCounter(&cycle); - QueryPerformanceFrequency(&freq); - return cycle.QuadPart * 10000000 / freq.QuadPart; + return cycle.QuadPart * timebase_frequency / freq.value; #else struct timespec ts; if (!clock_gettime(CLOCK_MONOTONIC, &ts)) - return ts.tv_sec * (s64)10000000 + (s64)ts.tv_nsec / (s64)100; + return ts.tv_sec * (s64)timebase_frequency + (s64)ts.tv_nsec * (s64)timebase_frequency / 1000000000; // Should never occur. assert(0); @@ -40,7 +50,7 @@ u64 get_time() // Returns some relative time in microseconds, don't change this fact u64 get_system_time() { - return get_time() / 10; + return get_time() / (timebase_frequency / 1000000); } @@ -61,8 +71,8 @@ s32 sys_time_get_current_time(u32 sec_addr, u32 nsec_addr) u64 time = get_time(); - Memory.Write64(sec_addr, time / 10000000); - Memory.Write64(nsec_addr, (time % 10000000) * 100); + Memory.Write64(sec_addr, time / timebase_frequency); + Memory.Write64(nsec_addr, (time % timebase_frequency) * 1000000000 / (s64)(timebase_frequency)); return CELL_OK; } @@ -76,5 +86,5 @@ s64 sys_time_get_system_time() u64 sys_time_get_timebase_frequency() { sys_time.Log("sys_time_get_timebase_frequency()"); - return 10000000; + return timebase_frequency; } From 7816843dfbe9ca5767267ef359270e063acacde8 Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Wed, 16 Jul 2014 22:29:26 +0400 Subject: [PATCH 12/18] Little fix --- rpcs3/Emu/SysCalls/lv2/sys_time.cpp | 5 +++-- rpcs3/Emu/SysCalls/lv2/sys_time.h | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/rpcs3/Emu/SysCalls/lv2/sys_time.cpp b/rpcs3/Emu/SysCalls/lv2/sys_time.cpp index df4d2b109a..aada49f665 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_time.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_time.cpp @@ -35,7 +35,8 @@ u64 get_time() LARGE_INTEGER cycle; QueryPerformanceCounter(&cycle); - return cycle.QuadPart * timebase_frequency / freq.value; + u64 sec = cycle.QuadPart / freq.value; + return sec * timebase_frequency + (cycle.QuadPart % freq.value) * timebase_frequency / freq.value; #else struct timespec ts; if (!clock_gettime(CLOCK_MONOTONIC, &ts)) @@ -50,7 +51,7 @@ u64 get_time() // Returns some relative time in microseconds, don't change this fact u64 get_system_time() { - return get_time() / (timebase_frequency / 1000000); + return get_time() / (timebase_frequency / MHZ); } diff --git a/rpcs3/Emu/SysCalls/lv2/sys_time.h b/rpcs3/Emu/SysCalls/lv2/sys_time.h index 921504cb42..3ebdefb7da 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_time.h +++ b/rpcs3/Emu/SysCalls/lv2/sys_time.h @@ -1,5 +1,7 @@ #pragma once +#define MHZ (10000000) + // Auxiliary functions u64 get_time(); u64 get_system_time(); From f729f21e6cf32f8f39c3e38c2d368c3291e79d7e Mon Sep 17 00:00:00 2001 From: raven02 Date: Fri, 18 Jul 2014 04:05:15 +0800 Subject: [PATCH 13/18] Fix compiler warning --- rpcs3/Emu/GS/GL/GLFragmentProgram.h | 12 ++-- rpcs3/Emu/GS/GL/GLVertexProgram.h | 98 ++++++++++++++--------------- rpcs3/Emu/GS/RSXThread.cpp | 12 ++-- rpcs3/Emu/GS/RSXThread.h | 12 ++-- 4 files changed, 67 insertions(+), 67 deletions(-) diff --git a/rpcs3/Emu/GS/GL/GLFragmentProgram.h b/rpcs3/Emu/GS/GL/GLFragmentProgram.h index b903fd927b..0ff5af0d4f 100644 --- a/rpcs3/Emu/GS/GL/GLFragmentProgram.h +++ b/rpcs3/Emu/GS/GL/GLFragmentProgram.h @@ -79,16 +79,16 @@ struct GLFragmentDecompilerThread : public ThreadBase struct { u32 else_offset : 31; - u32 : 1; + u32 : 1; }; struct { - u32 : 2; - u32 rep1 : 8; - u32 rep2 : 8; - u32 : 1; - u32 rep3 : 8; + u32 : 2; + u32 rep1 : 8; + u32 rep2 : 8; + u32 : 1; + u32 rep3 : 8; }; } src1; diff --git a/rpcs3/Emu/GS/GL/GLVertexProgram.h b/rpcs3/Emu/GS/GL/GLVertexProgram.h index 1a0c41c922..ffa19e8238 100644 --- a/rpcs3/Emu/GS/GL/GLVertexProgram.h +++ b/rpcs3/Emu/GS/GL/GLVertexProgram.h @@ -10,26 +10,26 @@ struct GLVertexDecompilerThread : public ThreadBase struct { - u32 addr_swz : 2; - u32 mask_w : 2; - u32 mask_z : 2; - u32 mask_y : 2; - u32 mask_x : 2; - u32 cond : 3; - u32 cond_test_enable : 1; - u32 cond_update_enable_0 : 1; - u32 dst_tmp : 6; - u32 src0_abs : 1; - u32 src1_abs : 1; - u32 src2_abs : 1; - u32 addr_reg_sel_1 : 1; - u32 cond_reg_sel_1 : 1; - u32 staturate : 1; - u32 index_input : 1; - u32 : 1; - u32 cond_update_enable_1 : 1; - u32 vec_result : 1; - u32 : 1; + u32 addr_swz : 2; + u32 mask_w : 2; + u32 mask_z : 2; + u32 mask_y : 2; + u32 mask_x : 2; + u32 cond : 3; + u32 cond_test_enable : 1; + u32 cond_update_enable_0 : 1; + u32 dst_tmp : 6; + u32 src0_abs : 1; + u32 src1_abs : 1; + u32 src2_abs : 1; + u32 addr_reg_sel_1 : 1; + u32 cond_reg_sel_1 : 1; + u32 staturate : 1; + u32 index_input : 1; + u32 : 1; + u32 cond_update_enable_1 : 1; + u32 vec_result : 1; + u32 : 1; }; } d0; @@ -39,11 +39,11 @@ struct GLVertexDecompilerThread : public ThreadBase struct { - u32 src0h : 8; - u32 input_src : 4; - u32 const_src : 10; - u32 vec_opcode : 5; - u32 sca_opcode : 5; + u32 src0h : 8; + u32 input_src : 4; + u32 const_src : 10; + u32 vec_opcode : 5; + u32 sca_opcode : 5; }; } d1; @@ -53,14 +53,14 @@ struct GLVertexDecompilerThread : public ThreadBase struct { - u32 src2h : 6; - u32 src1 : 17; - u32 src0l : 9; + u32 src2h : 6; + u32 src1 : 17; + u32 src0l : 9; }; struct { - u32 iaddrh : 6; - u32 : 26; + u32 iaddrh : 6; + u32 : 26; }; } d2; @@ -70,10 +70,10 @@ struct GLVertexDecompilerThread : public ThreadBase struct { - u32 end : 1; - u32 index_const : 1; - u32 dst : 5; - u32 sca_dst_tmp : 6; + u32 end : 1; + u32 index_const : 1; + u32 dst : 5; + u32 sca_dst_tmp : 6; u32 vec_writemask_w : 1; u32 vec_writemask_z : 1; u32 vec_writemask_y : 1; @@ -82,12 +82,12 @@ struct GLVertexDecompilerThread : public ThreadBase u32 sca_writemask_z : 1; u32 sca_writemask_y : 1; u32 sca_writemask_x : 1; - u32 src2l : 11; + u32 src2l : 11; }; struct { - u32 : 29; - u32 iaddrl : 3; + u32 : 29; + u32 iaddrl : 3; }; } d3; @@ -99,31 +99,31 @@ struct GLVertexDecompilerThread : public ThreadBase struct { - u32 src0l : 9; - u32 src0h : 8; + u32 src0l : 9; + u32 src0h : 8; }; struct { - u32 src1 : 17; + u32 src1 : 17; }; struct { - u32 src2l : 11; - u32 src2h : 6; + u32 src2l : 11; + u32 src2h : 6; }; }; struct { - u32 reg_type : 2; - u32 tmp_src : 6; - u32 swz_w : 2; - u32 swz_z : 2; - u32 swz_y : 2; - u32 swz_x : 2; - u32 neg : 1; + u32 reg_type : 2; + u32 tmp_src : 6; + u32 swz_w : 2; + u32 swz_z : 2; + u32 swz_y : 2; + u32 swz_x : 2; + u32 neg : 1; }; } src[3]; diff --git a/rpcs3/Emu/GS/RSXThread.cpp b/rpcs3/Emu/GS/RSXThread.cpp index 60a464f342..c0bb2b1127 100644 --- a/rpcs3/Emu/GS/RSXThread.cpp +++ b/rpcs3/Emu/GS/RSXThread.cpp @@ -1677,12 +1677,12 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, mem32_ptr_t args, const u32 { const u32 a0 = ARGS(0); m_set_clip_plane = true; - m_clip_plane_0 = a0 & 0xf; - m_clip_plane_1 = (a0 >> 4) & 0xf; - m_clip_plane_2 = (a0 >> 8) & 0xf; - m_clip_plane_3 = (a0 >> 12) & 0xf; - m_clip_plane_4 = (a0 >> 16) & 0xf; - m_clip_plane_5 = a0 >> 20; + m_clip_plane_0 = (a0 & 0xf) ? true : false; + m_clip_plane_1 = ((a0 >> 4)) & 0xf ? true : false; + m_clip_plane_2 = ((a0 >> 8)) & 0xf ? true : false; + m_clip_plane_3 = ((a0 >> 12)) & 0xf ? true : false; + m_clip_plane_4 = ((a0 >> 16)) & 0xf ? true : false; + m_clip_plane_5 = (a0 >> 20) ? true : false; } break; diff --git a/rpcs3/Emu/GS/RSXThread.h b/rpcs3/Emu/GS/RSXThread.h index 623a1a433c..42a0c7695e 100644 --- a/rpcs3/Emu/GS/RSXThread.h +++ b/rpcs3/Emu/GS/RSXThread.h @@ -348,12 +348,12 @@ public: // Clip plane bool m_set_clip_plane; - u32 m_clip_plane_0; - u32 m_clip_plane_1; - u32 m_clip_plane_2; - u32 m_clip_plane_3; - u32 m_clip_plane_4; - u32 m_clip_plane_5; + bool m_clip_plane_0; + bool m_clip_plane_1; + bool m_clip_plane_2; + bool m_clip_plane_3; + bool m_clip_plane_4; + bool m_clip_plane_5; // Surface bool m_set_surface_format; From 4856066a81d4d363681e87b240b7bff1d6a49df0 Mon Sep 17 00:00:00 2001 From: raven02 Date: Fri, 18 Jul 2014 23:03:39 +0800 Subject: [PATCH 14/18] Regression fix #1 --- rpcs3/Emu/GS/GL/GLFragmentProgram.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/rpcs3/Emu/GS/GL/GLFragmentProgram.cpp b/rpcs3/Emu/GS/GL/GLFragmentProgram.cpp index 2b33a7fdf0..2f3f18cb78 100644 --- a/rpcs3/Emu/GS/GL/GLFragmentProgram.cpp +++ b/rpcs3/Emu/GS/GL/GLFragmentProgram.cpp @@ -251,10 +251,10 @@ std::string GLFragmentDecompilerThread::BuildCode() static const std::pair table[] = { { "ocol0", m_ctrl & 0x40 ? "r0" : "h0" }, - { "ocol1", m_ctrl & 0x40 ? "r1" : "h2" }, - { "ocol2", m_ctrl & 0x40 ? "r2" : "h4" }, - { "ocol3", m_ctrl & 0x40 ? "r3" : "h6" }, - { "ocol4", m_ctrl & 0x40 ? "r4" : "h8" }, + { "ocol1", m_ctrl & 0x40 ? "r2" : "h2" }, + { "ocol2", m_ctrl & 0x40 ? "r3" : "h4" }, + { "ocol3", m_ctrl & 0x40 ? "r4" : "h6" }, + { "ocol4", m_ctrl & 0x40 ? "r5" : "h8" }, }; for (int i = 0; i < sizeof(table) / sizeof(*table); ++i) @@ -263,19 +263,19 @@ std::string GLFragmentDecompilerThread::BuildCode() AddCode(m_parr.AddParam(PARAM_OUT, "vec4", table[i].first, i) + " = " + table[i].second + ";"); } - if(m_ctrl & 0xe) main += "\tgl_FragDepth = r1.z;\n"; + if (m_ctrl & 0xe) main += "\tgl_FragDepth = r1.z;\n"; std::string p; - for(u32 i=0; i Date: Fri, 18 Jul 2014 20:55:26 +0400 Subject: [PATCH 15/18] be_t<> constructor elimination --- Utilities/BEType.h | 31 ++++++-------- Utilities/SMutex.cpp | 2 +- Utilities/SMutex.h | 42 +++++++++---------- rpcs3/Crypto/unpkg.cpp | 5 ++- rpcs3/Emu/GS/sysutil_video.h | 18 ++++---- rpcs3/Emu/Memory/Memory.h | 26 ++++++------ rpcs3/Emu/Memory/MemoryBlock.h | 19 --------- rpcs3/Emu/SysCalls/Modules/SC_Pad.cpp | 2 + .../SysCalls/Modules/cellSysutil_SaveData.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/libmixer.cpp | 2 +- rpcs3/Emu/SysCalls/lv2/sys_lwcond.cpp | 4 +- rpcs3/Emu/SysCalls/lv2/sys_lwmutex.cpp | 8 ++-- rpcs3/Emu/SysCalls/lv2/sys_ppu_thread.cpp | 4 +- rpcs3/Emu/SysCalls/lv2/sys_spinlock.cpp | 4 +- rpcs3/Loader/TROPUSR.cpp | 13 ++++-- 15 files changed, 81 insertions(+), 103 deletions(-) diff --git a/Utilities/BEType.h b/Utilities/BEType.h index 65fe524f89..4477ead2ce 100644 --- a/Utilities/BEType.h +++ b/Utilities/BEType.h @@ -63,24 +63,6 @@ class be_t public: typedef T type; - -#ifdef _WIN32 - be_t(){} -#else - be_t() noexcept = default; -#endif - - be_t(const be_t& value) = default; - be_t(const T& value) - { - FromLE(value); - } - - template - explicit be_t(const be_t& value) - { - FromBE(value.ToBE()); - } const T& ToBE() const { @@ -130,7 +112,18 @@ public: operator const be_t() const { be_t res; - res.FromBE(ToBE()); + if (sizeof(T1) < sizeof(T)) + { + res.FromBE(ToBE() >> ((sizeof(T)-sizeof(T1)) * 8)); + } + else if (sizeof(T1) > sizeof(T)) + { + res.FromBE((T1)ToBE() << ((sizeof(T1)-sizeof(T)) * 8)); + } + else + { + res.FromBE(ToBE()); + } return res; } diff --git a/Utilities/SMutex.cpp b/Utilities/SMutex.cpp index 80c8798941..fe853c191e 100644 --- a/Utilities/SMutex.cpp +++ b/Utilities/SMutex.cpp @@ -36,5 +36,5 @@ __forceinline u32 SM_GetCurrentCPUThreadId() __forceinline be_t SM_GetCurrentCPUThreadIdBE() { - return SM_GetCurrentCPUThreadId(); + return be_t::MakeFromLE(SM_GetCurrentCPUThreadId()); } diff --git a/Utilities/SMutex.h b/Utilities/SMutex.h index a769fe5469..beeb5a8920 100644 --- a/Utilities/SMutex.h +++ b/Utilities/SMutex.h @@ -22,8 +22,8 @@ enum SMutexResult template < typename T, - u64 free_value = 0, - u64 dead_value = 0xffffffff, + const u64 free_value = 0, + const u64 dead_value = 0xffffffffffffffffull, void (*wait)() = SM_Sleep > class SMutexBase @@ -32,20 +32,26 @@ class SMutexBase std::atomic owner; public: - SMutexBase() - : owner((T)free_value) + static const T GetFreeValue() { + static const u64 value = free_value; + return (const T&)value; + } + + static const T GetDeadValue() + { + static const u64 value = dead_value; + return (const T&)value; } void initialize() { - (T&)owner = free_value; + owner = GetFreeValue(); } - ~SMutexBase() + void finalize() { - lock((T)dead_value); - owner = (T)dead_value; + owner = GetDeadValue(); } __forceinline T GetOwner() const @@ -53,23 +59,13 @@ public: return (T&)owner; } - __forceinline T GetFreeValue() const - { - return (T)free_value; - } - - __forceinline T GetDeadValue() const - { - return (T)dead_value; - } - SMutexResult trylock(T tid) { if (Emu.IsStopped()) { return SMR_ABORT; } - T old = (T)free_value; + T old = GetFreeValue(); if (!owner.compare_exchange_strong(old, tid)) { @@ -77,7 +73,7 @@ public: { return SMR_DEADLOCK; } - if (old == (T)dead_value) + if (old == GetDeadValue()) { return SMR_DESTROYED; } @@ -87,7 +83,7 @@ public: return SMR_OK; } - SMutexResult unlock(T tid, T to = (T)free_value) + SMutexResult unlock(T tid, T to = GetFreeValue()) { if (Emu.IsStopped()) { @@ -97,11 +93,11 @@ public: if (!owner.compare_exchange_strong(old, to)) { - if (old == (T)free_value) + if (old == GetFreeValue()) { return SMR_FAILED; } - if (old == (T)dead_value) + if (old == GetDeadValue()) { return SMR_DESTROYED; } diff --git a/rpcs3/Crypto/unpkg.cpp b/rpcs3/Crypto/unpkg.cpp index 1b499ce61c..3d26e9178d 100644 --- a/rpcs3/Crypto/unpkg.cpp +++ b/rpcs3/Crypto/unpkg.cpp @@ -113,8 +113,9 @@ int Decrypt(rFile& pkg_f, rFile& dec_pkg_f, PKGHeader* m_header) { aes_crypt_ecb(&c, AES_ENCRYPT, iv, ctr+j*HASH_LEN); - be_t hi = *(be_t*)&iv[0]; - be_t lo = *(be_t*)&iv[8] + 1; + be_t hi = be_t::MakeFromBE(*(u64*)&iv[0]); + be_t lo = be_t::MakeFromBE(*(u64*)&iv[8]); + lo++; if (lo == 0) hi += 1; diff --git a/rpcs3/Emu/GS/sysutil_video.h b/rpcs3/Emu/GS/sysutil_video.h index b0d03c6323..c0d2a89370 100644 --- a/rpcs3/Emu/GS/sysutil_video.h +++ b/rpcs3/Emu/GS/sysutil_video.h @@ -223,15 +223,15 @@ enum CellVideoOutRGBOutputRange static const CellVideoOutResolution ResolutionTable[] = { - {(u16)-1, (u16)-1}, //0 - 0 - {1920, 1080}, //1 - 1 - {1280, 720}, //2 - 2 - {720, 480}, //4 - 3 - {720, 576}, //5 - 4 - {1600, 1080}, //10 - 5 - {1440, 1080}, //11 - 6 - {1280, 1080}, //12 - 7 - {960, 1080}, //13 - 8 + { be_t::MakeFromBE(se16(0xffff)), be_t::MakeFromBE(se16(0xffff)) }, //0 - 0 + { be_t::MakeFromBE(se16(1920)), be_t::MakeFromBE(se16(1080)) }, //1 - 1 + { be_t::MakeFromBE(se16(1280)), be_t::MakeFromBE(se16(720)) }, //2 - 2 + { be_t::MakeFromBE(se16(720)), be_t::MakeFromBE(se16(480)) }, //4 - 3 + { be_t::MakeFromBE(se16(720)), be_t::MakeFromBE(se16(576)) }, //5 - 4 + { be_t::MakeFromBE(se16(1600)), be_t::MakeFromBE(se16(1080)) }, //10 - 5 + { be_t::MakeFromBE(se16(1440)), be_t::MakeFromBE(se16(1080)) }, //11 - 6 + { be_t::MakeFromBE(se16(1280)), be_t::MakeFromBE(se16(1080)) }, //12 - 7 + { be_t::MakeFromBE(se16(960)), be_t::MakeFromBE(se16(1080)) }, //13 - 8 }; inline static u32 ResolutionIdToNum(u32 id) diff --git a/rpcs3/Emu/Memory/Memory.h b/rpcs3/Emu/Memory/Memory.h index c552fe2f7b..114fdff049 100644 --- a/rpcs3/Emu/Memory/Memory.h +++ b/rpcs3/Emu/Memory/Memory.h @@ -517,29 +517,29 @@ public: } } - bool CopyToReal(void* real, u64 from, u32 count) + template bool CopyToReal(void* real, T from, u32 count) { - if (!IsGoodAddr(from, count)) return false; + if (!IsGoodAddr(from, count)) return false; - memcpy(real, GetMemFromAddr(from), count); + memcpy(real, GetMemFromAddr(from), count); return true; } - bool CopyFromReal(u64 to, const void* real, u32 count) + template bool CopyFromReal(T to, const void* real, u32 count) { - if (!IsGoodAddr(to, count)) return false; + if (!IsGoodAddr(to, count)) return false; - memcpy(GetMemFromAddr(to), real, count); + memcpy(GetMemFromAddr(to), real, count); return true; } - bool Copy(u64 to, u64 from, u32 count) + template bool Copy(T1 to, T2 from, u32 count) { - if (!IsGoodAddr(to, count) || !IsGoodAddr(from, count)) return false; + if (!IsGoodAddr(to, count) || !IsGoodAddr(from, count)) return false; - memmove(GetMemFromAddr(to), GetMemFromAddr(from), count); + memmove(GetMemFromAddr(to), GetMemFromAddr(from), count); return true; } @@ -564,14 +564,14 @@ public: for (u32 i = 0; i < size; ++i) Write8(addr + (size - 1 - i), src[i]); } - template void WriteData(const u64 addr, const T* data) + template void WriteData(const T addr, const Td* data) { - memcpy(GetMemFromAddr(addr), data, sizeof(T)); + memcpy(GetMemFromAddr(addr), data, sizeof(Td)); } - template void WriteData(const u64 addr, const T data) + template void WriteData(const T addr, const Td data) { - *(T*)GetMemFromAddr(addr) = data; + *(Td*)GetMemFromAddr(addr) = data; } std::string ReadString(const u64 addr, const u64 len) diff --git a/rpcs3/Emu/Memory/MemoryBlock.h b/rpcs3/Emu/Memory/MemoryBlock.h index c4a3d70632..1873d009dc 100644 --- a/rpcs3/Emu/Memory/MemoryBlock.h +++ b/rpcs3/Emu/Memory/MemoryBlock.h @@ -366,25 +366,6 @@ public: } }; -class NullMemoryBlock : public MemoryBlock -{ -public: - virtual bool IsNULL() { return true; } - virtual bool IsMyAddress(const u64 addr) { return true; } - - virtual bool Read8(const u64 addr, u8* value); - virtual bool Read16(const u64 addr, u16* value); - virtual bool Read32(const u64 addr, u32* value); - virtual bool Read64(const u64 addr, u64* value); - virtual bool Read128(const u64 addr, u128* value); - - virtual bool Write8(const u64 addr, const u8 value); - virtual bool Write16(const u64 addr, const u16 value); - virtual bool Write32(const u64 addr, const u32 value); - virtual bool Write64(const u64 addr, const u64 value); - virtual bool Write128(const u64 addr, const u128 value); -}; - template class DynamicMemoryBlockBase : public PT { diff --git a/rpcs3/Emu/SysCalls/Modules/SC_Pad.cpp b/rpcs3/Emu/SysCalls/Modules/SC_Pad.cpp index fc0989e528..b91e990c89 100644 --- a/rpcs3/Emu/SysCalls/Modules/SC_Pad.cpp +++ b/rpcs3/Emu/SysCalls/Modules/SC_Pad.cpp @@ -332,6 +332,8 @@ int cellPadGetInfo2(u32 info_addr) if(!Emu.GetPadManager().IsInited()) return CELL_PAD_ERROR_UNINITIALIZED; CellPadInfo2 info = {}; + //sys_io->Warning("*** info{}: max_connect=0x%x, now_connect=0x%x, system_info=0x%x, port_status[0]=0x%x, port_setting[0]=0x%x", + // (u32)info.max_connect, (u32)info.now_connect, (u32)info.system_info, (u32)info.port_status[0], (u32)info.port_setting[0]); const PadInfo& rinfo = Emu.GetPadManager().GetInfo(); info.max_connect = rinfo.max_connect; diff --git a/rpcs3/Emu/SysCalls/Modules/cellSysutil_SaveData.cpp b/rpcs3/Emu/SysCalls/Modules/cellSysutil_SaveData.cpp index 2393b0c2ff..b3c3cb2d27 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSysutil_SaveData.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSysutil_SaveData.cpp @@ -178,7 +178,7 @@ void getSaveDataStat(SaveDataEntry entry, mem_ptr_t statGet memcpy(statGet->getParam.listParam, entry.listParam.c_str(), CELL_SAVEDATA_SYSP_LPARAM_SIZE); statGet->fileNum = 0; - statGet->fileList.SetAddr(0); + statGet->fileList.SetAddr(be_t::MakeFromBE(0)); statGet->fileListNum = 0; std::string saveDir = "/dev_hdd0/home/00000001/savedata/" + entry.dirName; // TODO: Get the path of the current user vfsDir dir(saveDir); @@ -210,7 +210,7 @@ void getSaveDataStat(SaveDataEntry entry, mem_ptr_t statGet } } - statGet->fileList.SetAddr(Memory.Alloc(sizeof(CellSaveDataFileStat) * fileEntries.size(), sizeof(CellSaveDataFileStat))); + statGet->fileList.SetAddr(be_t::MakeFromLE(Memory.Alloc(sizeof(CellSaveDataFileStat)* fileEntries.size(), sizeof(CellSaveDataFileStat)))); for (u32 i=0; ifileList[i], &fileEntries[i], sizeof(CellSaveDataFileStat)); } diff --git a/rpcs3/Emu/SysCalls/Modules/libmixer.cpp b/rpcs3/Emu/SysCalls/Modules/libmixer.cpp index 147e37c812..00204a718b 100644 --- a/rpcs3/Emu/SysCalls/Modules/libmixer.cpp +++ b/rpcs3/Emu/SysCalls/Modules/libmixer.cpp @@ -213,7 +213,7 @@ int cellSSPlayerSetWave(u32 handle, mem_ptr_t waveInfo, m ssp[handle].m_addr = waveInfo->addr; ssp[handle].m_samples = waveInfo->samples; ssp[handle].m_loop_start = waveInfo->loopStartOffset - 1; - ssp[handle].m_loop_mode = commonInfo.GetAddr() ? commonInfo->loopMode : CELL_SSPLAYER_ONESHOT; + ssp[handle].m_loop_mode = commonInfo.GetAddr() ? (u32)commonInfo->loopMode : CELL_SSPLAYER_ONESHOT; ssp[handle].m_position = waveInfo->startOffset - 1; return CELL_OK; diff --git a/rpcs3/Emu/SysCalls/lv2/sys_lwcond.cpp b/rpcs3/Emu/SysCalls/lv2/sys_lwcond.cpp index ee44e1601b..9ebbcafb5d 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_lwcond.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_lwcond.cpp @@ -189,7 +189,7 @@ s32 sys_lwcond_wait(mem_ptr_t lwcond, u64 timeout) mem_ptr_t mutex(lwcond->lwmutex); u32 tid_le = GetCurrentPPUThread().GetId(); - be_t tid = tid_le; + be_t tid = be_t::MakeFromLE(tid_le); SleepQueue* sq = nullptr; Emu.GetIdManager().GetIDData((u32)mutex->sleep_queue, sq); @@ -211,7 +211,7 @@ s32 sys_lwcond_wait(mem_ptr_t lwcond, u64 timeout) if (sq) { - mutex->mutex.unlock(tid, mutex->attribute.ToBE() == se32(SYS_SYNC_PRIORITY) ? sq->pop_prio() : sq->pop()); + mutex->mutex.unlock(tid, be_t::MakeFromLE(mutex->attribute.ToBE() == se32(SYS_SYNC_PRIORITY) ? sq->pop_prio() : sq->pop())); } else if (mutex->attribute.ToBE() == se32(SYS_SYNC_RETRY)) { diff --git a/rpcs3/Emu/SysCalls/lv2/sys_lwmutex.cpp b/rpcs3/Emu/SysCalls/lv2/sys_lwmutex.cpp index 969c39e680..ce1e049286 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_lwmutex.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_lwmutex.cpp @@ -77,7 +77,7 @@ s32 sys_lwmutex_lock(mem_ptr_t lwmutex, u64 timeout) //ConLog.Write("*** lock mutex (addr=0x%x, attr=0x%x, Nrec=%d, owner=%d, waiter=%d)", //lwmutex.GetAddr(), (u32)lwmutex->attribute, (u32)lwmutex->recursive_count, lwmutex->vars.parts.owner.GetOwner(), (u32)lwmutex->waiter); - return lwmutex->lock(GetCurrentPPUThread().GetId(), timeout ? ((timeout < 1000) ? 1 : (timeout / 1000)) : 0); + return lwmutex->lock(be_t::MakeFromLE(GetCurrentPPUThread().GetId()), timeout ? ((timeout < 1000) ? 1 : (timeout / 1000)) : 0); } s32 sys_lwmutex_trylock(mem_ptr_t lwmutex) @@ -86,7 +86,7 @@ s32 sys_lwmutex_trylock(mem_ptr_t lwmutex) if (!lwmutex.IsGood()) return CELL_EFAULT; - return lwmutex->trylock(GetCurrentPPUThread().GetId()); + return lwmutex->trylock(be_t::MakeFromLE(GetCurrentPPUThread().GetId())); } s32 sys_lwmutex_unlock(mem_ptr_t lwmutex) @@ -98,7 +98,7 @@ s32 sys_lwmutex_unlock(mem_ptr_t lwmutex) //ConLog.Write("*** unlocking mutex (addr=0x%x, attr=0x%x, Nrec=%d, owner=%d, waiter=%d)", //lwmutex.GetAddr(), (u32)lwmutex->attribute, (u32)lwmutex->recursive_count, (u32)lwmutex->vars.parts.owner.GetOwner(), (u32)lwmutex->waiter); - return lwmutex->unlock(GetCurrentPPUThread().GetId()); + return lwmutex->unlock(be_t::MakeFromLE(GetCurrentPPUThread().GetId())); } void SleepQueue::push(u32 tid) @@ -294,7 +294,7 @@ int sys_lwmutex_t::unlock(be_t tid) recursive_count -= 1; if (!recursive_count.ToBE()) { - be_t target = 0; + be_t target = be_t::MakeFromBE(se32(0)); switch (attribute.ToBE() & se32(SYS_SYNC_ATTR_PROTOCOL_MASK)) { case se32(SYS_SYNC_FIFO): diff --git a/rpcs3/Emu/SysCalls/lv2/sys_ppu_thread.cpp b/rpcs3/Emu/SysCalls/lv2/sys_ppu_thread.cpp index ad51e004a0..f60e144710 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_ppu_thread.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_ppu_thread.cpp @@ -209,8 +209,8 @@ void sys_ppu_thread_once(mem_ptr_t>> once_ctrl, u32 entry) { sysPrxForUser->Warning("sys_ppu_thread_once(once_ctrl_addr=0x%x, entry=0x%x)", once_ctrl.GetAddr(), entry); - be_t old = SYS_PPU_THREAD_ONCE_INIT; - if (once_ctrl->compare_exchange_weak(old, SYS_PPU_THREAD_DONE_INIT)) + be_t old = be_t::MakeFromBE(se32(SYS_PPU_THREAD_ONCE_INIT)); + if (once_ctrl->compare_exchange_weak(old, be_t::MakeFromBE(se32(SYS_PPU_THREAD_DONE_INIT)))) { CPUThread& new_thread = Emu.GetCPU().AddThread(CPU_THREAD_PPU); new_thread.SetEntry(entry); diff --git a/rpcs3/Emu/SysCalls/lv2/sys_spinlock.cpp b/rpcs3/Emu/SysCalls/lv2/sys_spinlock.cpp index 23a618ad48..9d70571088 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_spinlock.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_spinlock.cpp @@ -19,7 +19,7 @@ void sys_spinlock_lock(mem_ptr_t lock) { sys_spinlock.Log("sys_spinlock_lock(lock_addr=0x%x)", lock.GetAddr()); - be_t tid = GetCurrentPPUThread().GetId(); + be_t tid = be_t::MakeFromLE(GetCurrentPPUThread().GetId()); switch (lock->mutex.lock(tid)) { case SMR_ABORT: LOG_WARNING(HLE, "sys_spinlock_lock(0x%x) aborted", lock.GetAddr()); break; @@ -32,7 +32,7 @@ s32 sys_spinlock_trylock(mem_ptr_t lock) { sys_spinlock.Log("sys_spinlock_trylock(lock_addr=0x%x)", lock.GetAddr()); - be_t tid = GetCurrentPPUThread().GetId(); + be_t tid = be_t::MakeFromLE(GetCurrentPPUThread().GetId()); switch (lock->mutex.trylock(tid)) { case SMR_FAILED: return CELL_EBUSY; diff --git a/rpcs3/Loader/TROPUSR.cpp b/rpcs3/Loader/TROPUSR.cpp index 118bf182ae..b19f0016d7 100644 --- a/rpcs3/Loader/TROPUSR.cpp +++ b/rpcs3/Loader/TROPUSR.cpp @@ -143,8 +143,11 @@ bool TROPUSRLoader::Generate(const std::string& filepath, const std::string& con default: trophy_grade = 0; } - TROPUSREntry4 entry4 = {4, sizeof(TROPUSREntry4)-0x10, m_table4.size(), 0, trophy_id, trophy_grade, 0xFFFFFFFF}; - TROPUSREntry6 entry6 = {6, sizeof(TROPUSREntry6)-0x10, m_table6.size(), 0, trophy_id, 0, 0, 0, 0, 0}; + TROPUSREntry4 entry4 = { be_t::MakeFromBE(se32(4)), be_t::MakeFromBE(se32(sizeof(TROPUSREntry4) - 0x10)), + be_t::MakeFromLE(m_table4.size()), be_t::MakeFromBE(se32(0)), be_t::MakeFromLE(trophy_id), + be_t::MakeFromLE(trophy_grade), be_t::MakeFromBE(se32(0xFFFFFFFF)) }; + TROPUSREntry6 entry6 = { be_t::MakeFromBE(se32(6)), be_t::MakeFromBE(se32(sizeof(TROPUSREntry6) - 0x10)), + be_t::MakeFromLE(m_table6.size()), be_t::MakeFromBE(0), be_t::MakeFromLE(trophy_id) }; m_table4.push_back(entry4); m_table6.push_back(entry6); @@ -152,9 +155,11 @@ bool TROPUSRLoader::Generate(const std::string& filepath, const std::string& con } u64 offset = sizeof(TROPUSRHeader) + 2 * sizeof(TROPUSRTableHeader); - TROPUSRTableHeader table4header = {4, sizeof(TROPUSREntry4)-0x10, 1, m_table4.size(), offset, 0}; + TROPUSRTableHeader table4header = { be_t::MakeFromBE(se32(4)), be_t::MakeFromBE(se32(sizeof(TROPUSREntry4)-0x10)), + be_t::MakeFromBE(se32(1)), be_t::MakeFromLE(m_table4.size()), be_t::MakeFromLE(offset) }; offset += m_table4.size() * sizeof(TROPUSREntry4); - TROPUSRTableHeader table6header = {6, sizeof(TROPUSREntry6)-0x10, 1, m_table6.size(), offset, 0}; + TROPUSRTableHeader table6header = { be_t::MakeFromBE(se32(6)), be_t::MakeFromBE(se32(sizeof(TROPUSREntry6)-0x10)), + be_t::MakeFromBE(se32(1)), be_t::MakeFromLE(m_table6.size()), be_t::MakeFromLE(offset) }; offset += m_table6.size() * sizeof(TROPUSREntry6); m_tableHeaders.clear(); From f69337be6540fea6a7e9744b505352ac6332029b Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Fri, 18 Jul 2014 21:04:12 +0400 Subject: [PATCH 16/18] Little fix --- Utilities/BEType.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Utilities/BEType.h b/Utilities/BEType.h index 4477ead2ce..8c2880c71b 100644 --- a/Utilities/BEType.h +++ b/Utilities/BEType.h @@ -118,7 +118,7 @@ public: } else if (sizeof(T1) > sizeof(T)) { - res.FromBE((T1)ToBE() << ((sizeof(T1)-sizeof(T)) * 8)); + res.FromLE(ToLE()); } else { From 5f55afda0f9cf444cf209d51340038a278a877c4 Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Fri, 18 Jul 2014 21:30:22 +0400 Subject: [PATCH 17/18] Little fix 2 --- Utilities/SMutex.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Utilities/SMutex.h b/Utilities/SMutex.h index beeb5a8920..c67578d7b2 100644 --- a/Utilities/SMutex.h +++ b/Utilities/SMutex.h @@ -49,6 +49,11 @@ public: owner = GetFreeValue(); } + SMutexBase() + { + initialize(); + } + void finalize() { owner = GetDeadValue(); From d058ef769cbea6baefea11645d327a56a5c6e12b Mon Sep 17 00:00:00 2001 From: raven02 Date: Sat, 19 Jul 2014 01:47:58 +0800 Subject: [PATCH 18/18] Fix a dst_reg typo for tc9 --- rpcs3/Emu/GS/GL/GLVertexProgram.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rpcs3/Emu/GS/GL/GLVertexProgram.cpp b/rpcs3/Emu/GS/GL/GLVertexProgram.cpp index 665f564c24..dc82212f7e 100644 --- a/rpcs3/Emu/GS/GL/GLVertexProgram.cpp +++ b/rpcs3/Emu/GS/GL/GLVertexProgram.cpp @@ -353,7 +353,7 @@ std::string GLVertexDecompilerThread::BuildCode() { "tc6", true, "dst_reg13", "", false }, { "tc7", true, "dst_reg14", "", false }, { "tc8", true, "dst_reg15", "", false }, - { "tc9", true, "dst_reg6", "", false } + { "tc9", true, "dst_reg16", "", false } }; std::string f;