From 9d5b13839be78b77be4b14c9f6e0434b8cda4305 Mon Sep 17 00:00:00 2001 From: DH Date: Tue, 19 Nov 2013 23:10:23 +0200 Subject: [PATCH] - Fixed OpenGL renderer LoadVertexArray & DrawArray. - Improved SPU SCs. - Renamed mem_ptr_t -> mem_list_ptr_t, mem_struct_ptr_t -> mem_ptr_t. --- Utilities/BEType.h | 91 ++++++----- rpcs3/Emu/GS/GL/GLFragmentProgram.cpp | 5 +- rpcs3/Emu/GS/GL/GLGSRender.cpp | 15 +- rpcs3/Emu/GS/GL/GLGSRender.h | 1 - rpcs3/Emu/GS/RSXThread.cpp | 33 +++- rpcs3/Emu/GS/RSXThread.h | 2 + rpcs3/Emu/Io/PadHandler.h | 4 + rpcs3/Emu/Memory/Memory.h | 156 ++++++++++++++----- rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp | 51 +++---- rpcs3/Emu/SysCalls/Modules/cellGifDec.cpp | 12 +- rpcs3/Emu/SysCalls/Modules/cellJpgDec.cpp | 12 +- rpcs3/Emu/SysCalls/Modules/cellPngDec.cpp | 10 +- rpcs3/Emu/SysCalls/Modules/cellResc.cpp | 92 ++++++----- rpcs3/Emu/SysCalls/Modules/cellSysutil.cpp | 2 +- rpcs3/Emu/SysCalls/SC_FUNC.h | 15 +- rpcs3/Emu/SysCalls/SysCalls.cpp | 2 +- rpcs3/Emu/SysCalls/SysCalls.h | 24 +-- rpcs3/Emu/SysCalls/lv2/SC_FileSystem.cpp | 4 +- rpcs3/Emu/SysCalls/lv2/SC_Pad.cpp | 2 + rpcs3/Emu/SysCalls/lv2/SC_Rwlock.cpp | 2 +- rpcs3/Emu/SysCalls/lv2/SC_SPU_Thread.cpp | 170 +++++++++------------ rpcs3/Emu/SysCalls/lv2/SC_SPU_Thread.h | 32 ++++ rpcs3/Emu/SysCalls/lv2/SC_Timer.cpp | 4 +- rpcs3/rpcs3.h | 5 +- 24 files changed, 424 insertions(+), 322 deletions(-) create mode 100644 rpcs3/Emu/SysCalls/lv2/SC_SPU_Thread.h diff --git a/Utilities/BEType.h b/Utilities/BEType.h index 96fa3e6e6f..ac622de3bd 100644 --- a/Utilities/BEType.h +++ b/Utilities/BEType.h @@ -1,10 +1,48 @@ #pragma once -#pragma warning(disable: 4739) -template +template struct se_t; +template struct se_t { static __forceinline void func(T& dst, const T src) { (u8&)dst = (u8&)src; } }; +template struct se_t { static __forceinline void func(T& dst, const T src) { (u16&)dst = _byteswap_ushort((u16&)src); } }; +template struct se_t { static __forceinline void func(T& dst, const T src) { (u32&)dst = _byteswap_ulong((u32&)src); } }; +template struct se_t { static __forceinline void func(T& dst, const T src) { (u64&)dst = _byteswap_uint64((u64&)src); } }; + +template struct const_se_t;; +template struct const_se_t +{ + static const T value = (T)_value; +}; + +template struct const_se_t +{ + static const T value = ((_value >> 8) & 0xff) | ((_value << 8) & 0xff00); +}; + +template struct const_se_t +{ + static const T value = + ((_value >> 24) & 0x000000ff) | + ((_value >> 8) & 0x0000ff00) | + ((_value << 8) & 0x00ff0000) | + ((_value << 24) & 0xff000000); +}; + +template struct const_se_t +{ + static const T value = + ((_value >> 56) & 0x00000000000000ff) | + ((_value >> 40) & 0x000000000000ff00) | + ((_value >> 24) & 0x0000000000ff0000) | + ((_value >> 8) & 0x00000000ff000000) | + ((_value << 8) & 0x000000ff00000000) | + ((_value << 24) & 0x0000ff0000000000) | + ((_value << 40) & 0x00ff000000000000) | + ((_value << 56) & 0xff00000000000000); +}; + +template class be_t { - static_assert(sizeof(T) == 1 || sizeof(T) == 2 || sizeof(T) == 4 || sizeof(T) == 8, "Bad be_t type"); + static_assert(size == 1 || size == 2 || size == 4 || size == 8, "Bad be_t type"); T m_data; public: @@ -32,28 +70,7 @@ public: { T res; - switch(sizeof(T)) - { - case 1: - (u8&)res = (u8&)m_data; - break; - - case 2: - (u16&)res = _byteswap_ushort((u16&)m_data); - break; - - case 4: - (u32&)res = _byteswap_ulong((u32&)m_data); - break; - - case 8: - (u64&)res = _byteswap_uint64((u64&)m_data); - break; - - default: - assert(0); - break; - } + se_t::func(res, m_data); return res; } @@ -65,27 +82,7 @@ public: void FromLE(const T& value) { - switch(sizeof(T)) - { - case 1: - (u8&)m_data = (u8&)value; - return; - - case 2: - (u16&)m_data = _byteswap_ushort((u16&)value); - return; - - case 4: - (u32&)m_data = _byteswap_ulong((u32&)value); - return; - - case 8: - (u64&)m_data = _byteswap_uint64((u64&)value); - return; - } - - assert(0); - m_data = value; + se_t::func(m_data, value); } //template @@ -151,4 +148,4 @@ public: template bool operator < (const be_t& right) const { return (T1)ToLE() < right.ToLE(); } template bool operator >= (const be_t& right) const { return (T1)ToLE() >= right.ToLE(); } template bool operator <= (const be_t& right) const { return (T1)ToLE() <= right.ToLE(); } -}; \ No newline at end of file +}; diff --git a/rpcs3/Emu/GS/GL/GLFragmentProgram.cpp b/rpcs3/Emu/GS/GL/GLFragmentProgram.cpp index f0b25a2896..bdfca11ab7 100644 --- a/rpcs3/Emu/GS/GL/GLFragmentProgram.cpp +++ b/rpcs3/Emu/GS/GL/GLFragmentProgram.cpp @@ -106,8 +106,9 @@ wxString GLFragmentDecompilerThread::AddReg(u32 index, int fp16) */ //ConLog.Warning("%c%d: %d %d", (fp16 ? 'h' : 'r'), index, dst.tex_num, src2.use_index_reg); + return m_parr.AddParam(fp16 ? PARAM_NONE : PARAM_OUT, "vec4", - wxString::Format((fp16 ? "h%u" : "r%u"), index), fp16 ? -1 : index); + wxString::Format((fp16 ? "h%u" : "r%u"), index), fp16 ? -1 : (!index ? 0 : ((index >= 2 && index <= 4) ? (index - 1) : -1))); } bool GLFragmentDecompilerThread::HasReg(u32 index, int fp16) @@ -226,6 +227,7 @@ void GLFragmentDecompilerThread::Task() { mem32_ptr_t data(m_addr); m_size = 0; + m_location = 0; while(true) { @@ -320,6 +322,7 @@ void GLFragmentDecompilerThread::Task() m_shader = BuildCode(); main.Clear(); + m_parr.params.Clear(); } GLShaderProgram::GLShaderProgram() diff --git a/rpcs3/Emu/GS/GL/GLGSRender.cpp b/rpcs3/Emu/GS/GL/GLGSRender.cpp index 7dbc3e7d68..1b1d42a2fa 100644 --- a/rpcs3/Emu/GS/GL/GLGSRender.cpp +++ b/rpcs3/Emu/GS/GL/GLGSRender.cpp @@ -295,23 +295,12 @@ void GLGSRender::DisableVertexData() for(u32 i=0; i> 16; u8 v3 = v >> 24; + m_vertex_data[index].Reset(); m_vertex_data[index].size = 4; m_vertex_data[index].type = 4; m_vertex_data[index].data.AddCpy(v0); @@ -208,6 +211,7 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, mem32_ptr_t& args, const u3 float v0 = (float&)a0; float v1 = (float&)a1; + m_vertex_data[index].Reset(); m_vertex_data[index].type = 2; m_vertex_data[index].size = 2; m_vertex_data[index].data.SetCount(sizeof(float) * 2); @@ -230,6 +234,7 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, mem32_ptr_t& args, const u3 float v2 = (float&)a2; float v3 = (float&)a3; + m_vertex_data[index].Reset(); m_vertex_data[index].type = 2; m_vertex_data[index].size = 4; m_vertex_data[index].data.SetCount(sizeof(float) * 4); @@ -440,6 +445,17 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, mem32_ptr_t& args, const u3 m_front_polygon_mode = args[0]; break; + case NV4097_CLEAR_ZCULL_SURFACE: + { + u32 a0 = args[0]; + + if(a0 & 0x01) m_clear_surface_z = m_clear_z; + if(a0 & 0x02) m_clear_surface_s = m_clear_s; + + m_clear_surface_mask |= a0 & 0x3; + } + break; + case NV4097_CLEAR_SURFACE: { u32 a0 = args[0]; @@ -513,8 +529,11 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, mem32_ptr_t& args, const u3 const u32 first = ac & 0xffffff; const u32 _count = (ac >> 24) + 1; + //ConLog.Warning("NV4097_DRAW_ARRAYS: %d - %d", first, _count); + LoadVertexData(first, _count); + if(first < m_draw_array_first) m_draw_array_first = first; m_draw_array_count += _count; } } @@ -575,6 +594,8 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, mem32_ptr_t& args, const u3 { u32 a0 = args[0]; + //ConLog.Warning("NV4097_SET_BEGIN_END: %x", a0); + if(a0) { Begin(a0); @@ -1296,6 +1317,8 @@ void RSXThread::Begin(u32 draw_mode) { m_begin_end = 1; m_draw_mode = draw_mode; + m_draw_array_count = 0; + m_draw_array_first = ~0; if(Emu.GetCallbackManager().m_exit_callback.m_callbacks.GetCount()) { @@ -1312,11 +1335,6 @@ void RSXThread::End() //Emu.GetCallbackManager().m_exit_callback.Handle(0x0122, 0); } - for(uint i=0; i class mem_struct_ptr_t +template +class mem_base_t { - const u32 m_addr; +protected: + u32 m_addr; public: - mem_struct_ptr_t(u32 addr) : m_addr(addr) + mem_base_t(u32 addr) : m_addr(addr) { } - operator T&() - { - return (T&)Memory[m_addr]; - } + u32 GetAddr() const { return m_addr; } - operator const T&() const + bool IsGood() const + { + return Memory.IsGoodAddr(m_addr, sizeof(T)); + } +}; + +template +class mem_ptr_t : public mem_base_t +{ +public: + mem_ptr_t(u32 addr) : mem_base_t(addr) { - return (const T&)Memory[m_addr]; } T* operator -> () @@ -430,6 +438,64 @@ public: return (const T*)&Memory[m_addr]; } + mem_ptr_t operator++ (int) + { + mem_struct_ptr_t res(m_addr); + m_addr += sizeof(T); + return ret; + } + + mem_ptr_t& operator++ () + { + m_addr += sizeof(T); + return *this; + } + + mem_ptr_t operator-- (int) + { + mem_struct_ptr_t res(m_addr); + m_addr -= sizeof(T); + return ret; + } + + mem_ptr_t& operator-- () + { + m_addr -= sizeof(T); + return *this; + } + + mem_ptr_t& operator += (uint count) + { + m_addr += count * sizeof(T); + return *this; + } + + mem_ptr_t& operator -= (uint count) + { + m_addr -= count * sizeof(T); + return *this; + } + + mem_ptr_t operator + (uint count) const + { + return m_addr + count * sizeof(T); + } + + mem_ptr_t operator - (uint count) const + { + return m_addr - count * sizeof(T); + } + + T& operator *() + { + return (T&)Memory[m_addr]; + } + + const T& operator *() const + { + return (T&)Memory[m_addr]; + } + T& operator [](uint index) { return (T&)Memory[m_addr + sizeof(T) * index]; @@ -440,26 +506,34 @@ public: return (const T&)Memory[m_addr + sizeof(T) * index]; } - u32 GetAddr() const { return m_addr; } + operator bool() const { return m_addr == 0; } - bool IsGood() const - { - return Memory.IsGoodAddr(m_addr, sizeof(T)); - } + bool operator == (mem_ptr_t right) const { return m_addr == right.m_addr; } + bool operator != (mem_ptr_t right) const { return m_addr != right.m_addr; } + bool operator > (mem_ptr_t right) const { return m_addr > right.m_addr; } + bool operator < (mem_ptr_t right) const { return m_addr < right.m_addr; } + bool operator >= (mem_ptr_t right) const { return m_addr >= right.m_addr; } + bool operator <= (mem_ptr_t right) const { return m_addr <= right.m_addr; } - mem_struct_ptr_t& operator = (const T& right) - { - memcpy(&Memory[m_addr], &right, sizeof(T)); - return *this; - } + bool operator == (T* right) const { return (T*)&Memory[m_addr] == right; } + bool operator != (T* right) const { return (T*)&Memory[m_addr] != right; } + bool operator > (T* right) const { return (T*)&Memory[m_addr] > right; } + bool operator < (T* right) const { return (T*)&Memory[m_addr] < right; } + bool operator >= (T* right) const { return (T*)&Memory[m_addr] >= right; } + bool operator <= (T* right) const { return (T*)&Memory[m_addr] <= right; } }; -template class mem_t -{ - const u32 m_addr; +template static bool operator == (T* left, mem_ptr_t right) { return left == (T*)&Memory[right.GetAddr()]; } +template static bool operator != (T* left, mem_ptr_t right) { return left != (T*)&Memory[right.GetAddr()]; } +template static bool operator > (T* left, mem_ptr_t right) { return left > (T*)&Memory[right.GetAddr()]; } +template static bool operator < (T* left, mem_ptr_t right) { return left < (T*)&Memory[right.GetAddr()]; } +template static bool operator >= (T* left, mem_ptr_t right) { return left >= (T*)&Memory[right.GetAddr()]; } +template static bool operator <= (T* left, mem_ptr_t right) { return left <= (T*)&Memory[right.GetAddr()]; } +template class mem_t : public mem_base_t +{ public: - mem_t(u32 addr) : m_addr(addr) + mem_t(u32 addr) : mem_base_t(addr) { } @@ -485,21 +559,12 @@ public: mem_t& operator ^= (T right) { return *this = (*this) ^ right; } mem_t& operator <<= (T right) { return *this = (*this) << right; } mem_t& operator >>= (T right) { return *this = (*this) >> right; } - - u32 GetAddr() const { return m_addr; } - - bool IsGood() const - { - return Memory.IsGoodAddr(m_addr, sizeof(T)); - } }; -template class mem_ptr_t +template class mem_list_ptr_t : public mem_base_t { - u32 m_addr; - public: - mem_ptr_t(u32 addr) : m_addr(addr) + mem_list_ptr_t(u32 addr) : mem_base_t(addr) { } @@ -515,7 +580,6 @@ public: return m_addr; } - u32 GetAddr() const { return m_addr; } u32 Skip(const u32 offset) { return m_addr += offset; } operator be_t*() { return GetPtr(); } @@ -661,7 +725,7 @@ public: return GetAddr(); } - operator const mem_struct_ptr_t() const + operator const mem_ptr_t() const { return GetAddr(); } @@ -678,7 +742,19 @@ typedef mem_t mem16_t; typedef mem_t mem32_t; typedef mem_t mem64_t; -typedef mem_ptr_t mem8_ptr_t; -typedef mem_ptr_t mem16_ptr_t; -typedef mem_ptr_t mem32_ptr_t; -typedef mem_ptr_t mem64_ptr_t; \ No newline at end of file +/* +typedef mem_ptr_t> mem8_ptr_t; +typedef mem_ptr_t> mem16_ptr_t; +typedef mem_ptr_t> mem32_ptr_t; +typedef mem_ptr_t> mem64_ptr_t; + +typedef mem_list_ptr_t mem8_lptr_t; +typedef mem_list_ptr_t mem16_lptr_t; +typedef mem_list_ptr_t mem32_lptr_t; +typedef mem_list_ptr_t mem64_lptr_t; +*/ + +typedef mem_list_ptr_t mem8_ptr_t; +typedef mem_list_ptr_t mem16_ptr_t; +typedef mem_list_ptr_t mem32_ptr_t; +typedef mem_list_ptr_t mem64_ptr_t; \ No newline at end of file diff --git a/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp b/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp index 4691c0aaf3..fc498379db 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp @@ -26,18 +26,16 @@ struct gcm_offset u32 map_offset_addr = 0; u32 map_offset_pos = 0; -int cellGcmMapMainMemory(u32 address, u32 size, u32 offset_addr) +int cellGcmMapMainMemory(u32 address, u32 size, mem32_t offset) { - cellGcmSys.Warning("cellGcmMapMainMemory(address=0x%x,size=0x%x,offset_addr=0x%x)", address, size, offset_addr); - if(!Memory.IsGoodAddr(offset_addr, sizeof(u32))) return CELL_EFAULT; + cellGcmSys.Warning("cellGcmMapMainMemory(address=0x%x,size=0x%x,offset_addr=0x%x)", address, size, offset.GetAddr()); + if(!offset.IsGood()) return CELL_EFAULT; Emu.GetGSManager().GetRender().m_main_mem_addr = Emu.GetGSManager().GetRender().m_ioAddress; - u32 offset = address - Emu.GetGSManager().GetRender().m_main_mem_addr; + offset = address - Emu.GetGSManager().GetRender().m_main_mem_addr; Emu.GetGSManager().GetRender().m_main_mem_info.AddCpy(MemInfo(address, size)); - Memory.Write32(offset_addr, offset); - return CELL_OK; } @@ -92,20 +90,21 @@ int cellGcmInit(u32 context_addr, u32 cmdSize, u32 ioSize, u32 ioAddress) return CELL_OK; } -int cellGcmGetConfiguration(u32 config_addr) +int cellGcmGetConfiguration(mem_ptr_t config) { - cellGcmSys.Log("cellGcmGetConfiguration(config_addr=0x%x)", config_addr); + cellGcmSys.Log("cellGcmGetConfiguration(config_addr=0x%x)", config.GetAddr()); - if(!Memory.IsGoodAddr(config_addr, sizeof(CellGcmConfig))) return CELL_EFAULT; + if(!config.IsGood()) return CELL_EFAULT; + + *config = current_config; - Memory.WriteData(config_addr, current_config); return CELL_OK; } -int cellGcmAddressToOffset(u32 address, u32 offset_addr) +int cellGcmAddressToOffset(u32 address, mem32_t offset) { - cellGcmSys.Log("cellGcmAddressToOffset(address=0x%x,offset_addr=0x%x)", address, offset_addr); - if(!Memory.IsGoodAddr(offset_addr, sizeof(u32))) return CELL_EFAULT; + cellGcmSys.Log("cellGcmAddressToOffset(address=0x%x,offset_addr=0x%x)", address, offset.GetAddr()); + if(!offset.IsGood()) return CELL_EFAULT; if(!map_offset_addr) { @@ -144,13 +143,11 @@ int cellGcmAddressToOffset(u32 address, u32 offset_addr) //ConLog.Warning("cellGcmAddressToOffset: io memory: offset = 0x%x - 0x%x = 0x%x", address, sa, address - sa); } - u32 offset = address - sa; + offset = address - sa; //Memory.Write16(map_offset_addr + map_offset_pos + 0, ea); //Memory.Write16(map_offset_addr + map_offset_pos + 2, offset); //map_offset_pos += 4; - Memory.Write32(offset_addr, offset); - return CELL_OK; } @@ -188,9 +185,9 @@ u32 cellGcmGetControlRegister() return gcm_info.control_addr; } -int cellGcmSetPrepareFlip(u32 ctx, u32 id) +int cellGcmSetPrepareFlip(mem_ptr_t ctxt, u32 id) { - cellGcmSys.Log("cellGcmSetPrepareFlip(ctx=0x%x, id=0x%x)", ctx, id); + cellGcmSys.Log("cellGcmSetPrepareFlip(ctx=0x%x, id=0x%x)", ctxt.GetAddr(), id); if(id >= 8) { @@ -198,22 +195,22 @@ int cellGcmSetPrepareFlip(u32 ctx, u32 id) } GSLockCurrent gslock(GS_LOCK_WAIT_FLUSH); - CellGcmContextData& ctxt = (CellGcmContextData&)Memory[ctx]; - u32 current = re(ctxt.current); - u32 end = re(ctxt.end); + + u32 current = re(ctxt->current); + u32 end = re(ctxt->end); if(current + 8 >= end) { ConLog.Warning("bad flip!"); - cellGcmCallback(ctx, current + 8 - end); + cellGcmCallback(ctxt.GetAddr(), current + 8 - end); } - current = re(ctxt.current); + current = re(ctxt->current); Memory.Write32(current, 0x3fead | (1 << 18)); Memory.Write32(current + 4, id); - re(ctxt.current, current + 8); + re(ctxt->current, current + 8); - if(ctx == gcm_info.context_addr) + if(ctxt.GetAddr() == gcm_info.context_addr) { CellGcmControl& ctrl = (CellGcmControl&)Memory[gcm_info.control_addr]; re(ctrl.put, re(ctrl.put) + 8); @@ -331,13 +328,13 @@ u64 cellGcmGetTimeStamp(u32 index) int cellGcmSetFlipHandler(u32 handler_addr) { cellGcmSys.Warning("cellGcmSetFlipHandler(handler_addr=%d)", handler_addr); - if(!Memory.IsGoodAddr(handler_addr) && handler_addr != 0) + if(handler_addr != 0 && !Memory.IsGoodAddr(handler_addr)) { return CELL_EFAULT; } Emu.GetGSManager().GetRender().m_flip_handler.SetAddr(handler_addr); - return 0; + return CELL_OK; } s64 cellGcmFunc15() diff --git a/rpcs3/Emu/SysCalls/Modules/cellGifDec.cpp b/rpcs3/Emu/SysCalls/Modules/cellGifDec.cpp index 93ca74c373..09fab89512 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellGifDec.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellGifDec.cpp @@ -132,7 +132,7 @@ int cellGifDecExtCreate(u32 mainHandle, u32 threadInParam, u32 threadOutParam, u return CELL_OK; } -int cellGifDecOpen(u32 mainHandle, mem32_t subHandle, const mem_struct_ptr_t src, mem_struct_ptr_t openInfo) +int cellGifDecOpen(u32 mainHandle, mem32_t subHandle, const mem_ptr_t src, mem_ptr_t openInfo) { /* vfsStream* stream; @@ -182,7 +182,7 @@ int cellGifDecOpen(u32 mainHandle, mem32_t subHandle, const mem_struct_ptr_t info) +int cellGifDecReadHeader(u32 mainHandle, u32 subHandle, mem_ptr_t info) { ID sub_handle_id_data; if(!cellGifDec.CheckId(subHandle, sub_handle_id_data)) @@ -217,12 +217,12 @@ int cellGifDecReadHeader(u32 mainHandle, u32 subHandle, mem_struct_ptr_t inParam, mem_struct_ptr_t outParam) +int cellGifDecSetParameter(u32 mainHandle, u32 subHandle, const mem_ptr_t inParam, mem_ptr_t outParam) { ID sub_handle_id_data; if(!cellGifDec.CheckId(subHandle, sub_handle_id_data)) @@ -246,12 +246,12 @@ int cellGifDecSetParameter(u32 mainHandle, u32 subHandle, const mem_struct_ptr_t current_outParam.outputBitDepth = 0; // Unimplemented current_outParam.useMemorySpace = 0; // Unimplemented - outParam = current_outParam; + *outParam = current_outParam; return CELL_OK; } -int cellGifDecDecodeData(u32 mainHandle, u32 subHandle, mem8_ptr_t data, const mem_struct_ptr_t dataCtrlParam, mem_struct_ptr_t dataOutInfo) +int cellGifDecDecodeData(u32 mainHandle, u32 subHandle, mem8_ptr_t data, const mem_ptr_t dataCtrlParam, mem_ptr_t dataOutInfo) { dataOutInfo->status = CELL_GIFDEC_DEC_STATUS_STOP; diff --git a/rpcs3/Emu/SysCalls/Modules/cellJpgDec.cpp b/rpcs3/Emu/SysCalls/Modules/cellJpgDec.cpp index c112b1f80f..58dd6ec7f6 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellJpgDec.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellJpgDec.cpp @@ -126,7 +126,7 @@ int cellJpgDecDestroy(u32 mainHandle) return CELL_OK; } -int cellJpgDecOpen(u32 mainHandle, mem32_t subHandle, u32 src_addr, mem_struct_ptr_t openInfo) +int cellJpgDecOpen(u32 mainHandle, mem32_t subHandle, u32 src_addr, mem_ptr_t openInfo) { //u32 srcSelect = Memory.Read32(src_addr); u32 fileName = Memory.Read32(src_addr+4); @@ -170,7 +170,7 @@ int cellJpgDecClose(u32 mainHandle, u32 subHandle) return CELL_OK; } -int cellJpgDecReadHeader(u32 mainHandle, u32 subHandle, mem_struct_ptr_t info) +int cellJpgDecReadHeader(u32 mainHandle, u32 subHandle, mem_ptr_t info) { cellJpgDec.Log("cellJpgDecReadHeader(mainHandle=0x%x, subHandle=0x%x, info_addr=0x%llx)", mainHandle, subHandle, info.GetAddr()); ID sub_handle_id_data; @@ -224,12 +224,12 @@ int cellJpgDecReadHeader(u32 mainHandle, u32 subHandle, mem_struct_ptr_t dataCtrlParam, mem_struct_ptr_t dataOutInfo) +int cellJpgDecDecodeData(u32 mainHandle, u32 subHandle, mem8_ptr_t data, const mem_ptr_t dataCtrlParam, mem_ptr_t dataOutInfo) { dataOutInfo->status = CELL_JPGDEC_DEC_STATUS_STOP; ID sub_handle_id_data; @@ -295,7 +295,7 @@ int cellJpgDecDecodeData(u32 mainHandle, u32 subHandle, mem8_ptr_t data, const m return CELL_OK; } -int cellJpgDecSetParameter(u32 mainHandle, u32 subHandle, const mem_struct_ptr_t inParam, mem_struct_ptr_t outParam) +int cellJpgDecSetParameter(u32 mainHandle, u32 subHandle, const mem_ptr_t inParam, mem_ptr_t outParam) { ID sub_handle_id_data; if(!cellJpgDec.CheckId(subHandle, sub_handle_id_data)) @@ -332,7 +332,7 @@ int cellJpgDecSetParameter(u32 mainHandle, u32 subHandle, const mem_struct_ptr_t current_outParam.downScale = inParam->downScale; current_outParam.useMemorySpace = 0; // Unimplemented - outParam = current_outParam; + *outParam = current_outParam; return CELL_OK; } diff --git a/rpcs3/Emu/SysCalls/Modules/cellPngDec.cpp b/rpcs3/Emu/SysCalls/Modules/cellPngDec.cpp index 4f130f0a52..8bc72699e0 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellPngDec.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellPngDec.cpp @@ -160,7 +160,7 @@ int cellPngDecClose(u32 mainHandle, u32 subHandle) return CELL_OK; } -int cellPngDecReadHeader(u32 mainHandle, u32 subHandle, mem_struct_ptr_t info) +int cellPngDecReadHeader(u32 mainHandle, u32 subHandle, mem_ptr_t info) { cellPngDec.Log("cellPngDecReadHeader(mainHandle=0x%x, subHandle=0x%x, info_addr=0x%llx)", mainHandle, subHandle, info.GetAddr()); ID sub_handle_id_data; @@ -206,12 +206,12 @@ int cellPngDecReadHeader(u32 mainHandle, u32 subHandle, mem_struct_ptr_t()[28]; current_info.chunkInformation = 0; // Unimplemented - info = current_info; + *info = current_info; return CELL_OK; } -int cellPngDecDecodeData(u32 mainHandle, u32 subHandle, mem8_ptr_t data, const mem_struct_ptr_t dataCtrlParam, mem_struct_ptr_t dataOutInfo) +int cellPngDecDecodeData(u32 mainHandle, u32 subHandle, mem8_ptr_t data, const mem_ptr_t dataCtrlParam, mem_ptr_t dataOutInfo) { dataOutInfo->status = CELL_PNGDEC_DEC_STATUS_STOP; ID sub_handle_id_data; @@ -271,7 +271,7 @@ int cellPngDecDecodeData(u32 mainHandle, u32 subHandle, mem8_ptr_t data, const m return CELL_OK; } -int cellPngDecSetParameter(u32 mainHandle, u32 subHandle, const mem_struct_ptr_t inParam, mem_struct_ptr_t outParam) +int cellPngDecSetParameter(u32 mainHandle, u32 subHandle, const mem_ptr_t inParam, mem_ptr_t outParam) { ID sub_handle_id_data; if(!cellPngDec.CheckId(subHandle, sub_handle_id_data)) @@ -305,7 +305,7 @@ int cellPngDecSetParameter(u32 mainHandle, u32 subHandle, const mem_struct_ptr_t current_outParam.outputMode = inParam->outputMode; current_outParam.useMemorySpace = 0; // Unimplemented - outParam = current_outParam; + *outParam = current_outParam; return CELL_OK; } diff --git a/rpcs3/Emu/SysCalls/Modules/cellResc.cpp b/rpcs3/Emu/SysCalls/Modules/cellResc.cpp index 3c472fd52b..89da1da0c4 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellResc.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellResc.cpp @@ -76,9 +76,9 @@ CCellRescInternal* s_rescInternalInstance = new CCellRescInternal(); // Extern Functions extern int cellGcmSetFlipMode(u32 mode); extern int cellGcmSetFlipHandler(u32 handler_addr); -extern int cellGcmAddressToOffset(u32 address, u32 offset_addr); +extern int cellGcmAddressToOffset(u32 address, mem32_t offset); extern int cellGcmSetDisplayBuffer(u32 id, u32 offset, u32 pitch, u32 width, u32 height); -extern int cellGcmSetPrepareFlip(u32 ctx, u32 id); +extern int cellGcmSetPrepareFlip(mem_ptr_t ctx, u32 id); int cellRescGetNumColorBuffers(u32 dstMode, u32 palTemporalMode, u32 reserved); // Help Functions @@ -112,9 +112,7 @@ void BuildupVertexBufferNR() float U_PS0 = UV_CENTER - U_PS; float U_PS1 = UV_CENTER + U_PS; - mem_struct_ptr_t vv(s_rescInternalInstance->m_vertexArrayEA_addr); - - int i = 0; + mem_ptr_t vv(s_rescInternalInstance->m_vertexArrayEA_addr); if(s_rescInternalInstance->m_dstMode == CELL_RESC_720x480 || s_rescInternalInstance->m_dstMode == CELL_RESC_720x576){ switch(s_rescInternalInstance->m_initConfig.ratioMode){ @@ -127,26 +125,26 @@ void BuildupVertexBufferNR() } NR_FULLSCREEN: - vv[i].Px = -PX_FS; vv[i].Py = PY_FS; vv[i].u = U_FS0; vv[i].v = V_FS0; vv[i].u2 = 0.0f; vv[i].v2 = 0.0f; i++; - vv[i].Px = PX_FS; vv[i].Py = PY_FS; vv[i].u = U_FS1; vv[i].v = V_FS0; vv[i].u2 = 1.0f; vv[i].v2 = 0.0f; i++; - vv[i].Px = PX_FS; vv[i].Py = -PY_FS; vv[i].u = U_FS1; vv[i].v = V_FS1; vv[i].u2 = 1.0f; vv[i].v2 = 1.0f; i++; - vv[i].Px = -PX_FS; vv[i].Py = -PY_FS; vv[i].u = U_FS0; vv[i].v = V_FS1; vv[i].u2 = 0.0f; vv[i].v2 = 1.0f; i++; + vv->Px = -PX_FS; vv->Py = PY_FS; vv->u = U_FS0; vv->v = V_FS0; vv->u2 = 0.0f; vv->v2 = 0.0f; ++vv; + vv->Px = PX_FS; vv->Py = PY_FS; vv->u = U_FS1; vv->v = V_FS0; vv->u2 = 1.0f; vv->v2 = 0.0f; ++vv; + vv->Px = PX_FS; vv->Py = -PY_FS; vv->u = U_FS1; vv->v = V_FS1; vv->u2 = 1.0f; vv->v2 = 1.0f; ++vv; + vv->Px = -PX_FS; vv->Py = -PY_FS; vv->u = U_FS0; vv->v = V_FS1; vv->u2 = 0.0f; vv->v2 = 1.0f; ++vv; s_rescInternalInstance->m_nVertex = VERTEX_NUMBER_NORMAL; return; NR_LETTERBOX: - vv[i].Px = -PX_FS; vv[i].Py = PY_FS; vv[i].u = U_FS0; vv[i].v = V_LB0; vv[i].u2 = 0.0f; vv[i].v2 = 0.0f; i++; - vv[i].Px = PX_FS; vv[i].Py = PY_FS; vv[i].u = U_FS1; vv[i].v = V_LB0; vv[i].u2 = 1.0f; vv[i].v2 = 0.0f; i++; - vv[i].Px = PX_FS; vv[i].Py = -PY_FS; vv[i].u = U_FS1; vv[i].v = V_LB1; vv[i].u2 = 1.0f; vv[i].v2 = 1.0f; i++; - vv[i].Px = -PX_FS; vv[i].Py = -PY_FS; vv[i].u = U_FS0; vv[i].v = V_LB1; vv[i].u2 = 0.0f; vv[i].v2 = 1.0f; i++; + vv->Px = -PX_FS; vv->Py = PY_FS; vv->u = U_FS0; vv->v = V_LB0; vv->u2 = 0.0f; vv->v2 = 0.0f; ++vv; + vv->Px = PX_FS; vv->Py = PY_FS; vv->u = U_FS1; vv->v = V_LB0; vv->u2 = 1.0f; vv->v2 = 0.0f; ++vv; + vv->Px = PX_FS; vv->Py = -PY_FS; vv->u = U_FS1; vv->v = V_LB1; vv->u2 = 1.0f; vv->v2 = 1.0f; ++vv; + vv->Px = -PX_FS; vv->Py = -PY_FS; vv->u = U_FS0; vv->v = V_LB1; vv->u2 = 0.0f; vv->v2 = 1.0f; ++vv; s_rescInternalInstance->m_nVertex = VERTEX_NUMBER_NORMAL; return; NR_PANSCAN: - vv[i].Px = -PX_FS; vv[i].Py = PY_FS; vv[i].u = U_PS0; vv[i].v = V_FS0; vv[i].u2 = 0.0f; vv[i].v2 = 0.0f; i++; - vv[i].Px = PX_FS; vv[i].Py = PY_FS; vv[i].u = U_PS1; vv[i].v = V_FS0; vv[i].u2 = 1.0f; vv[i].v2 = 0.0f; i++; - vv[i].Px = PX_FS; vv[i].Py = -PY_FS; vv[i].u = U_PS1; vv[i].v = V_FS1; vv[i].u2 = 1.0f; vv[i].v2 = 1.0f; i++; - vv[i].Px = -PX_FS; vv[i].Py = -PY_FS; vv[i].u = U_PS0; vv[i].v = V_FS1; vv[i].u2 = 0.0f; vv[i].v2 = 1.0f; i++; + vv->Px = -PX_FS; vv->Py = PY_FS; vv->u = U_PS0; vv->v = V_FS0; vv->u2 = 0.0f; vv->v2 = 0.0f; ++vv; + vv->Px = PX_FS; vv->Py = PY_FS; vv->u = U_PS1; vv->v = V_FS0; vv->u2 = 1.0f; vv->v2 = 0.0f; ++vv; + vv->Px = PX_FS; vv->Py = -PY_FS; vv->u = U_PS1; vv->v = V_FS1; vv->u2 = 1.0f; vv->v2 = 1.0f; ++vv; + vv->Px = -PX_FS; vv->Py = -PY_FS; vv->u = U_PS0; vv->v = V_FS1; vv->u2 = 0.0f; vv->v2 = 1.0f; ++vv; s_rescInternalInstance->m_nVertex = VERTEX_NUMBER_NORMAL; return; } @@ -190,9 +188,7 @@ void BuildupVertexBufferUN(s32 srcIdx) float U2_FS1 = s_rescInternalInstance->m_dstWidth; float V2_FS1 = s_rescInternalInstance->m_dstHeight; - mem_struct_ptr_t vv(s_rescInternalInstance->m_vertexArrayEA_addr); - - int i = 0; + mem_ptr_t vv(s_rescInternalInstance->m_vertexArrayEA_addr); if(s_rescInternalInstance->m_dstMode == CELL_RESC_720x480 || s_rescInternalInstance->m_dstMode == CELL_RESC_720x576){ switch(s_rescInternalInstance->m_initConfig.ratioMode){ @@ -205,31 +201,31 @@ void BuildupVertexBufferUN(s32 srcIdx) } UN_FULLSCREEN: - vv[i].Px = -PX_FS; vv[i].Py = PY_FS; vv[i].u = U_FS0; vv[i].v = V_FS0; vv[i].u2 = U2_FS0; vv[i].v2 = V2_FS0; i++; - vv[i].Px = PX_FS; vv[i].Py = PY_FS; vv[i].u = U_FS1; vv[i].v = V_FS0; vv[i].u2 = U2_FS1; vv[i].v2 = V2_FS0; i++; - vv[i].Px = PX_FS; vv[i].Py = -PY_FS; vv[i].u = U_FS1; vv[i].v = V_FS1; vv[i].u2 = U2_FS1; vv[i].v2 = V2_FS1; i++; - vv[i].Px = -PX_FS; vv[i].Py = -PY_FS; vv[i].u = U_FS0; vv[i].v = V_FS1; vv[i].u2 = U2_FS0; vv[i].v2 = V2_FS1; i++; + vv->Px = -PX_FS; vv->Py = PY_FS; vv->u = U_FS0; vv->v = V_FS0; vv->u2 = U2_FS0; vv->v2 = V2_FS0; ++vv; + vv->Px = PX_FS; vv->Py = PY_FS; vv->u = U_FS1; vv->v = V_FS0; vv->u2 = U2_FS1; vv->v2 = V2_FS0; ++vv; + vv->Px = PX_FS; vv->Py = -PY_FS; vv->u = U_FS1; vv->v = V_FS1; vv->u2 = U2_FS1; vv->v2 = V2_FS1; ++vv; + vv->Px = -PX_FS; vv->Py = -PY_FS; vv->u = U_FS0; vv->v = V_FS1; vv->u2 = U2_FS0; vv->v2 = V2_FS1; ++vv; s_rescInternalInstance->m_nVertex = VERTEX_NUMBER_NORMAL; return; UN_LETTERBOX: - vv[i].Px = -PX_FS; vv[i].Py = PY_FS; vv[i].u = U_FS0; vv[i].v = V_LB0; vv[i].u2 = U2_FS0; vv[i].v2 = V2_FS0; i++; - vv[i].Px = PX_FS; vv[i].Py = PY_FS; vv[i].u = U_FS1; vv[i].v = V_LB0; vv[i].u2 = U2_FS1; vv[i].v2 = V2_FS0; i++; - vv[i].Px = PX_FS; vv[i].Py = -PY_FS; vv[i].u = U_FS1; vv[i].v = V_LB1; vv[i].u2 = U2_FS1; vv[i].v2 = V2_FS1; i++; - vv[i].Px = -PX_FS; vv[i].Py = -PY_FS; vv[i].u = U_FS0; vv[i].v = V_LB1; vv[i].u2 = U2_FS0; vv[i].v2 = V2_FS1; i++; + vv->Px = -PX_FS; vv->Py = PY_FS; vv->u = U_FS0; vv->v = V_LB0; vv->u2 = U2_FS0; vv->v2 = V2_FS0; ++vv; + vv->Px = PX_FS; vv->Py = PY_FS; vv->u = U_FS1; vv->v = V_LB0; vv->u2 = U2_FS1; vv->v2 = V2_FS0; ++vv; + vv->Px = PX_FS; vv->Py = -PY_FS; vv->u = U_FS1; vv->v = V_LB1; vv->u2 = U2_FS1; vv->v2 = V2_FS1; ++vv; + vv->Px = -PX_FS; vv->Py = -PY_FS; vv->u = U_FS0; vv->v = V_LB1; vv->u2 = U2_FS0; vv->v2 = V2_FS1; ++vv; s_rescInternalInstance->m_nVertex = VERTEX_NUMBER_NORMAL; return; UN_PANSCAN: - vv[i].Px = -PX_FS; vv[i].Py = PY_FS; vv[i].u = U_PS0; vv[i].v = V_FS0; vv[i].u2 = U2_FS0; vv[i].v2 = V2_FS0; i++; - vv[i].Px = PX_FS; vv[i].Py = PY_FS; vv[i].u = U_PS1; vv[i].v = V_FS0; vv[i].u2 = U2_FS1; vv[i].v2 = V2_FS0; i++; - vv[i].Px = PX_FS; vv[i].Py = -PY_FS; vv[i].u = U_PS1; vv[i].v = V_FS1; vv[i].u2 = U2_FS1; vv[i].v2 = V2_FS1; i++; - vv[i].Px = -PX_FS; vv[i].Py = -PY_FS; vv[i].u = U_PS0; vv[i].v = V_FS1; vv[i].u2 = U2_FS0; vv[i].v2 = V2_FS1; i++; + vv->Px = -PX_FS; vv->Py = PY_FS; vv->u = U_PS0; vv->v = V_FS0; vv->u2 = U2_FS0; vv->v2 = V2_FS0; ++vv; + vv->Px = PX_FS; vv->Py = PY_FS; vv->u = U_PS1; vv->v = V_FS0; vv->u2 = U2_FS1; vv->v2 = V2_FS0; ++vv; + vv->Px = PX_FS; vv->Py = -PY_FS; vv->u = U_PS1; vv->v = V_FS1; vv->u2 = U2_FS1; vv->v2 = V2_FS1; ++vv; + vv->Px = -PX_FS; vv->Py = -PY_FS; vv->u = U_PS0; vv->v = V_FS1; vv->u2 = U2_FS0; vv->v2 = V2_FS1; ++vv; s_rescInternalInstance->m_nVertex = VERTEX_NUMBER_NORMAL; return; } -inline int InternalVersion(mem_struct_ptr_t conf) +inline int InternalVersion(mem_ptr_t conf) { switch (conf->size) { @@ -335,7 +331,7 @@ int CalculateMaxColorBuffersSize() return maxBufSize; } -bool CheckInitConfig(mem_struct_ptr_t initConfig) +bool CheckInitConfig(mem_ptr_t initConfig) { if( (initConfig->resourcePolicy & ~((u32)0x3)) || (initConfig->supportModes & 0xF) == 0 || @@ -360,7 +356,7 @@ void InitMembers() { } -void InitContext(mem_struct_ptr_t& cntxt) +void InitContext(mem_ptr_t& cntxt) { //TODO: use cntxt GSLockCurrent lock(GS_LOCK_WAIT_FLUSH); @@ -406,7 +402,7 @@ void InitContext(mem_struct_ptr_t& cntxt) } } -void InitVertex(mem_struct_ptr_t& cntxt) +void InitVertex(mem_ptr_t& cntxt) { GSLockCurrent lock(GS_LOCK_WAIT_FLUSH); GSRender& r = Emu.GetGSManager().GetRender(); @@ -415,7 +411,7 @@ void InitVertex(mem_struct_ptr_t& cntxt) } // Module Functions -int cellRescInit(mem_struct_ptr_t initConfig) +int cellRescInit(mem_ptr_t initConfig) { cellResc.Warning("cellRescInit(initConfig_addr=0x%x)", initConfig.GetAddr()); @@ -425,7 +421,7 @@ int cellRescInit(mem_struct_ptr_t initConfig) return CELL_RESC_ERROR_BAD_ARGUMENT; InitMembers(); - s_rescInternalInstance->m_initConfig = initConfig; // TODO: This may be incompatible with older binaries + s_rescInternalInstance->m_initConfig = *initConfig; // TODO: This may be incompatible with older binaries s_rescInternalInstance->m_bInitialized = true; return CELL_OK; @@ -461,7 +457,7 @@ int cellRescVideoOutResolutionId2RescBufferMode(u32 resolutionId, mem32_t buffer return CELL_OK; } -int cellRescSetDsts(u32 dstsMode, mem_struct_ptr_t dsts) +int cellRescSetDsts(u32 dstsMode, mem_ptr_t dsts) { cellResc.Log("cellRescSetDsts(dstsMode=%d, CellRescDsts_addr=0x%x)", dstsMode, dsts.GetAddr()); @@ -474,7 +470,7 @@ int cellRescSetDsts(u32 dstsMode, mem_struct_ptr_t dsts) (dstsMode != CELL_RESC_1280x720) && (dstsMode != CELL_RESC_1920x1080)) return CELL_RESC_ERROR_BAD_ARGUMENT; - s_rescInternalInstance->m_rescDsts[GetRescDestsIndex(dstsMode)] = dsts; + s_rescInternalInstance->m_rescDsts[GetRescDestsIndex(dstsMode)] = *dsts; return CELL_OK; } @@ -636,7 +632,7 @@ int cellRescGetNumColorBuffers(u32 dstMode, u32 palTemporalMode, u32 reserved) : 2; } -int cellRescGcmSurface2RescSrc(mem_struct_ptr_t gcmSurface, mem_struct_ptr_t rescSrc) +int cellRescGcmSurface2RescSrc(mem_ptr_t gcmSurface, mem_ptr_t rescSrc) { cellResc.Log("cellRescGcmSurface2RescSrc(gcmSurface_addr=0x%x, rescSrc_addr=0x%x)", gcmSurface.GetAddr(), rescSrc.GetAddr()); @@ -664,7 +660,7 @@ int cellRescGcmSurface2RescSrc(mem_struct_ptr_t gcmSurface, mem_ return CELL_OK; } -int cellRescSetSrc(s32 idx, mem_struct_ptr_t src) +int cellRescSetSrc(s32 idx, mem_ptr_t src) { cellResc.Log("cellRescSetSrc(idx=0x%x, src_addr=0x%x)", idx, src.GetAddr()); @@ -683,14 +679,14 @@ int cellRescSetSrc(s32 idx, mem_struct_ptr_t src) //Emu.GetGSManager().GetRender().SetData(src.offset, 800, 600); //Emu.GetGSManager().GetRender().Draw(); - s_rescInternalInstance->m_rescSrc[idx] = src; + s_rescInternalInstance->m_rescSrc[idx] = *src; cellGcmSetDisplayBuffer(idx, src->offset, src->pitch, src->width, src->height); return 0; } -int cellRescSetConvertAndFlip(mem_struct_ptr_t cntxt, s32 idx) +int cellRescSetConvertAndFlip(mem_ptr_t cntxt, s32 idx) { cellResc.Log("cellRescSetConvertAndFlip(cntxt_addr=0x%x, indx=0x%x)", cntxt.GetAddr(), idx); @@ -707,7 +703,7 @@ int cellRescSetConvertAndFlip(mem_struct_ptr_t cntxt, s32 id //TODO: ? - cellGcmSetPrepareFlip(cntxt.GetAddr(), idx); + cellGcmSetPrepareFlip(cntxt, idx); return CELL_OK; } @@ -738,12 +734,12 @@ int cellRescSetBufferAddress(mem32_t colorBuffers, mem32_t vertexArray, mem32_t s_rescInternalInstance->m_vertexArrayEA_addr = vertexArray.GetAddr(); s_rescInternalInstance->m_fragmentUcodeEA_addr = fragmentShader.GetAddr(); - MemoryAllocator dstOffset; - cellGcmAddressToOffset(s_rescInternalInstance->m_colorBuffersEA_addr, dstOffset.GetAddr()); + MemoryAllocator> dstOffset; + cellGcmAddressToOffset(s_rescInternalInstance->m_colorBuffersEA_addr, dstOffset); for(int i=0; im_dstOffsets[i] = dstOffset + i * s_rescInternalInstance->m_dstBufInterval; + s_rescInternalInstance->m_dstOffsets[i] = dstOffset->ToLE() + i * s_rescInternalInstance->m_dstBufInterval; } for(int i=0; i info) +int cellVideoOutGetDeviceInfo(u32 videoOut, u32 deviceIndex, mem_ptr_t info) { cellSysutil.Error("Unimplemented function: cellVideoOutGetDeviceInfo(videoOut=%u, deviceIndex=%u, info_addr=0x%x)", videoOut, deviceIndex, info.GetAddr()); diff --git a/rpcs3/Emu/SysCalls/SC_FUNC.h b/rpcs3/Emu/SysCalls/SC_FUNC.h index 8f5ccb5bb3..88171718d5 100644 --- a/rpcs3/Emu/SysCalls/SC_FUNC.h +++ b/rpcs3/Emu/SysCalls/SC_FUNC.h @@ -2,10 +2,19 @@ #define RESULT(x) SC_ARGS_1 = (x) -template struct get_arg { static __forceinline T func(PPUThread& CPU, int i) { return (T&)CPU.GPR[i + 2]; } }; -template struct get_arg { static __forceinline T func(PPUThread& CPU, int i) { return CPU.FPR[i]; } }; +template +struct get_arg; -#define ARG(n) get_arg::value, T##n>::func(CPU, n) +template +struct get_arg { static __forceinline T func(PPUThread& CPU, int i) { return (T&)CPU.GPR[i + 2]; } }; + +template +struct get_arg { static __forceinline T func(PPUThread& CPU, int i) { return CPU.GPR[i + 2] ? (T)&Memory[CPU.GPR[i + 2]] : nullptr; } }; + +template +struct get_arg { static __forceinline T func(PPUThread& CPU, int i) { return CPU.FPR[i]; } }; + +#define ARG(n) get_arg::value, std::is_pointer::value, T##n>::func(CPU, n) template class binder_func_0 : public func_caller diff --git a/rpcs3/Emu/SysCalls/SysCalls.cpp b/rpcs3/Emu/SysCalls/SysCalls.cpp index 703181c264..b09d78954b 100644 --- a/rpcs3/Emu/SysCalls/SysCalls.cpp +++ b/rpcs3/Emu/SysCalls/SysCalls.cpp @@ -98,7 +98,7 @@ static func_caller* sc_table[1024] = null_func, null_func, null_func, null_func, null_func, //179 null_func, bind_func(sys_spu_thread_write_ls), bind_func(sys_spu_thread_read_ls), null_func, null_func, //184 null_func, null_func, null_func, null_func, null_func, //189 - bind_func(sys_spu_thread_write_spu_mb), null_func, null_func, null_func, null_func, //194 + bind_func(sys_spu_thread_write_spu_mb), bind_func(sys_spu_thread_connect_event), null_func, null_func, null_func, //194 null_func, null_func, null_func, null_func, null_func, //199 null_func, null_func, null_func, null_func, null_func, //204 null_func, null_func, null_func, null_func, null_func, //209 diff --git a/rpcs3/Emu/SysCalls/SysCalls.h b/rpcs3/Emu/SysCalls/SysCalls.h index 7107953d1f..b89954efcd 100644 --- a/rpcs3/Emu/SysCalls/SysCalls.h +++ b/rpcs3/Emu/SysCalls/SysCalls.h @@ -3,6 +3,7 @@ #include "lv2/SC_FileSystem.h" #include "lv2/SC_Timer.h" #include "lv2/SC_Rwlock.h" +#include "lv2/SC_SPU_Thread.h" //#define SYSCALLS_DEBUG #define declCPU PPUThread& CPU = GetCurrentPPUThread @@ -189,8 +190,8 @@ extern int cellFsClose(u32 fd); extern int cellFsOpendir(u32 path_addr, mem32_t fd); extern int cellFsReaddir(u32 fd, u32 dir_addr, mem64_t nread); extern int cellFsClosedir(u32 fd); -extern int cellFsStat(u32 path_addr, mem_struct_ptr_t sb); -extern int cellFsFstat(u32 fd, mem_struct_ptr_t sb); +extern int cellFsStat(u32 path_addr, mem_ptr_t sb); +extern int cellFsFstat(u32 fd, mem_ptr_t sb); extern int cellFsMkdir(u32 path_addr, u32 mode); extern int cellFsRename(u32 from_addr, u32 to_addr); extern int cellFsRmdir(u32 path_addr); @@ -257,16 +258,17 @@ extern int sys_heap_create_heap(const u32 heap_addr, const u32 start_addr, const extern int sys_heap_malloc(const u32 heap_addr, const u32 size); //sys_spu -extern int sys_spu_image_open(u32 img_addr, u32 path_addr); -extern int sys_spu_thread_initialize(u32 thread_addr, u32 group, u32 spu_num, u32 img_addr, u32 attr_addr, u32 arg_addr); -extern int sys_spu_thread_set_argument(u32 id, u32 arg_addr); +extern int sys_spu_image_open(mem_ptr_t img, u32 path_addr); +extern int sys_spu_thread_initialize(mem32_t thread, u32 group, u32 spu_num, mem_ptr_t img, mem_ptr_t attr, mem_ptr_t arg); +extern int sys_spu_thread_set_argument(u32 id, mem_ptr_t arg); extern int sys_spu_thread_group_start(u32 id); -extern int sys_spu_thread_group_create(u64 id_addr, u32 num, int prio, u64 attr_addr); -extern int sys_spu_thread_create(u64 thread_id_addr, u64 entry_addr, u64 arg, int prio, u32 stacksize, u64 flags, u64 threadname_addr); -extern int sys_raw_spu_create(u32 id_addr, u32 attr_addr); +extern int sys_spu_thread_group_create(mem32_t id, u32 num, int prio, mem_ptr_t attr); +extern int sys_spu_thread_create(mem32_t thread_id, mem32_t entry, u64 arg, int prio, u32 stacksize, u64 flags, u32 threadname_addr); +extern int sys_spu_thread_connect_event(u32 id, u32 eq, u32 et, u8 spup); +extern int sys_raw_spu_create(mem32_t id, u32 attr_addr); extern int sys_spu_initialize(u32 max_usable_spu, u32 max_raw_spu); extern int sys_spu_thread_write_ls(u32 id, u32 address, u64 value, u32 type); -extern int sys_spu_thread_read_ls(u32 id, u32 address, u32 value_addr, u32 type); +extern int sys_spu_thread_read_ls(u32 id, u32 address, mem64_t value, u32 type); extern int sys_spu_thread_write_spu_mb(u32 id, u32 value); //sys_time @@ -278,7 +280,7 @@ extern u64 sys_time_get_timebase_frequency(); //sys_timer extern int sys_timer_create(mem32_t timer_id); extern int sys_timer_destroy(u32 timer_id); -extern int sys_timer_get_information(u32 timer_id, mem_struct_ptr_t info); +extern int sys_timer_get_information(u32 timer_id, mem_ptr_t info); extern int sys_timer_start(u32 timer_id, s64 basetime, u64 period); extern int sys_timer_stop(u32 timer_id); extern int sys_timer_connect_event_queue(u32 timer_id, u32 queue_id, u64 name, u64 data1, u64 data2); @@ -299,7 +301,7 @@ extern int sys_trace_free_buffer(); extern int sys_trace_create2(); //sys_rwlock -extern int sys_rwlock_create(mem32_t rw_lock_id, mem_struct_ptr_t attr); +extern int sys_rwlock_create(mem32_t rw_lock_id, mem_ptr_t attr); extern int sys_rwlock_destroy(u32 rw_lock_id); extern int sys_rwlock_rlock(u32 rw_lock_id, u64 timeout); extern int sys_rwlock_tryrlock(u32 rw_lock_id); diff --git a/rpcs3/Emu/SysCalls/lv2/SC_FileSystem.cpp b/rpcs3/Emu/SysCalls/lv2/SC_FileSystem.cpp index 1fc163f281..dd2a6f6da8 100644 --- a/rpcs3/Emu/SysCalls/lv2/SC_FileSystem.cpp +++ b/rpcs3/Emu/SysCalls/lv2/SC_FileSystem.cpp @@ -174,7 +174,7 @@ int cellFsClosedir(u32 fd) return CELL_OK; } -int cellFsStat(const u32 path_addr, mem_struct_ptr_t sb) +int cellFsStat(const u32 path_addr, mem_ptr_t sb) { const wxString& path = Memory.ReadString(path_addr); sys_fs.Log("cellFsFstat(path: %s, sb_addr: 0x%x)", path, sb.GetAddr()); @@ -216,7 +216,7 @@ int cellFsStat(const u32 path_addr, mem_struct_ptr_t sb) return CELL_OK; } -int cellFsFstat(u32 fd, mem_struct_ptr_t sb) +int cellFsFstat(u32 fd, mem_ptr_t sb) { sys_fs.Log("cellFsFstat(fd: %d, sb_addr: 0x%x)", fd, sb.GetAddr()); ID id; diff --git a/rpcs3/Emu/SysCalls/lv2/SC_Pad.cpp b/rpcs3/Emu/SysCalls/lv2/SC_Pad.cpp index 15d9e7bb54..a052cd041b 100644 --- a/rpcs3/Emu/SysCalls/lv2/SC_Pad.cpp +++ b/rpcs3/Emu/SysCalls/lv2/SC_Pad.cpp @@ -77,6 +77,8 @@ int cellPadGetData(u32 port_no, u32 data_addr) u16 d2 = 0; const Array