diff --git a/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp b/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp index 741f470fd7..3a77f6d87b 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp @@ -2,6 +2,7 @@ #include "Emu/Memory/Memory.h" #include "Emu/System.h" #include "Emu/SysCalls/Modules.h" +#include "sysPrxForUser.h" //#include "Emu/RSX/GCM.h" //#include "Emu/SysCalls/lv2/sys_process.h" @@ -803,25 +804,26 @@ s32 cellGcmAddressToOffset(u64 address, mem32_t offset) { cellGcmSys->Log("cellGcmAddressToOffset(address=0x%x,offset_addr=0x%x)", address, offset.GetAddr()); - if (address >= 0xD0000000/*not on main memory or local*/) + // Address not on main memory or local memory + if (address >= 0xD0000000) { return CELL_GCM_ERROR_FAILURE; + } u32 result; - // If address is in range of local memory - if (Memory.RSXFBMem.IsInMyRange(address)) - { + // Address in local memory + if (Memory.RSXFBMem.IsInMyRange(address)) { result = address - Memory.RSXFBMem.GetStartAddr(); } - // else check if the adress (main memory) is mapped in IO + // Address in main memory else check else { u16 upper12Bits = Memory.Read16(offsetTable.ioAddress + sizeof(u16)*(address >> 20)); + // If the address is mapped in IO if (upper12Bits != 0xFFFF) { - result = (((u64)upper12Bits << 20) | (address & (0xFFFFF))); + result = ((u64)upper12Bits << 20) | (address & 0xFFFFF); } - // address is not mapped in IO else { return CELL_GCM_ERROR_FAILURE; } diff --git a/rpcs3/Emu/SysCalls/Modules/sysPrxForUser.h b/rpcs3/Emu/SysCalls/Modules/sysPrxForUser.h index 3dc3697ce9..527549f990 100644 --- a/rpcs3/Emu/SysCalls/Modules/sysPrxForUser.h +++ b/rpcs3/Emu/SysCalls/Modules/sysPrxForUser.h @@ -13,3 +13,6 @@ struct HeapInfo { } }; + +// SysCalls +u32 _sys_memset(u32 addr, s32 value, u32 size); diff --git a/rpcs3/Emu/SysCalls/SysCalls.cpp b/rpcs3/Emu/SysCalls/SysCalls.cpp index 54ce826b74..ec87d6c287 100644 --- a/rpcs3/Emu/SysCalls/SysCalls.cpp +++ b/rpcs3/Emu/SysCalls/SysCalls.cpp @@ -99,7 +99,7 @@ static func_caller* sc_table[kSyscallTableLength] = null_func,//bind_func(sys_ppu_thread_start), //53 (0x035) null_func,//bind_func(sys_ppu_...), //54 (0x036) ROOT null_func,//bind_func(sys_ppu_...), //55 (0x037) ROOT - null_func,//bind_func(sys_ppu_thread_rename), //56 (0x038) + bind_func(sys_ppu_thread_rename), //56 (0x038) null_func,//bind_func(sys_ppu_thread_recover_page_fault)//57 (0x039) null_func,//bind_func(sys_ppu_thread_get_page_fault_context),//58 (0x03A) null_func, //59 (0x03B) UNS diff --git a/rpcs3/Emu/SysCalls/lv2/sys_ppu_thread.cpp b/rpcs3/Emu/SysCalls/lv2/sys_ppu_thread.cpp index 7dfba3b29c..a05924df46 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_ppu_thread.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_ppu_thread.cpp @@ -210,10 +210,23 @@ void sys_ppu_thread_once(mem_ptr_t>> once_ctrl, u32 entry) } } -s32 sys_ppu_thread_get_id(const u32 id_addr) +s32 sys_ppu_thread_get_id(mem64_t thread_id) { - sys_ppu_thread.Log("sys_ppu_thread_get_id(id_addr=0x%x)", id_addr); + sys_ppu_thread.Log("sys_ppu_thread_get_id(thread_id_addr=0x%x)", thread_id.GetAddr()); - Memory.Write64(id_addr, GetCurrentPPUThread().GetId()); + thread_id = GetCurrentPPUThread().GetId(); + return CELL_OK; +} + +s32 sys_ppu_thread_rename(u64 thread_id, u32 name_addr) +{ + sys_ppu_thread.Log("sys_ppu_thread_rename(thread_id=%d, name_addr=0x%x)", thread_id, name_addr); + + CPUThread* thr = Emu.GetCPU().GetThread(thread_id); + if (!thr) { + return CELL_ESRCH; + } + + thr->SetThreadName(Memory.ReadString(name_addr)); return CELL_OK; } diff --git a/rpcs3/Emu/SysCalls/lv2/sys_ppu_thread.h b/rpcs3/Emu/SysCalls/lv2/sys_ppu_thread.h index 7918118e99..ef1be8cc49 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_ppu_thread.h +++ b/rpcs3/Emu/SysCalls/lv2/sys_ppu_thread.h @@ -26,4 +26,5 @@ s32 sys_ppu_thread_stop(u64 thread_id); s32 sys_ppu_thread_restart(u64 thread_id); s32 sys_ppu_thread_create(mem64_t thread_id, u32 entry, u64 arg, s32 prio, u32 stacksize, u64 flags, u32 threadname_addr); void sys_ppu_thread_once(mem_ptr_t>> once_ctrl, u32 entry); -s32 sys_ppu_thread_get_id(const u32 id_addr); +s32 sys_ppu_thread_get_id(mem64_t thread_id); +s32 sys_ppu_thread_rename(u64 thread_id, u32 name_addr); diff --git a/rpcs3/rpcs3.cpp b/rpcs3/rpcs3.cpp index 3b32d28c5c..f30e71289f 100644 --- a/rpcs3/rpcs3.cpp +++ b/rpcs3/rpcs3.cpp @@ -18,6 +18,7 @@ #endif #include "Gui/GLGSFrame.h" +#include #ifdef _WIN32 #include @@ -114,10 +115,13 @@ bool Rpcs3App::OnInit() SetAppName(_PRGNAME_); wxInitAllImageHandlers(); + // RPCS3 assumes the current working directory is the folder where it is contained, so we make sure this is true + const wxString executablePath = wxStandardPaths::Get().GetExecutablePath(); + wxSetWorkingDirectory(wxPathOnly(executablePath)); + main_thread = std::this_thread::get_id(); Ini.Load(); - m_MainFrame = new MainFrame(); SetTopWindow(m_MainFrame); Emu.Init();