diff --git a/rpcs3/Emu/Memory/Memory.h b/rpcs3/Emu/Memory/Memory.h index b339a1c500..8d7bdc6762 100644 --- a/rpcs3/Emu/Memory/Memory.h +++ b/rpcs3/Emu/Memory/Memory.h @@ -825,6 +825,7 @@ public: } }; +/* template class MemoryAllocator { @@ -934,6 +935,7 @@ public: return (NT*)(m_ptr + offset); } }; +*/ typedef mem_t mem8_t; typedef mem_t mem16_t; @@ -957,3 +959,5 @@ typedef mem_list_ptr_t mem16_ptr_t; typedef mem_list_ptr_t mem32_ptr_t; typedef mem_list_ptr_t mem64_ptr_t; +#include "vm.h" + diff --git a/rpcs3/Emu/Memory/vm.cpp b/rpcs3/Emu/Memory/vm.cpp new file mode 100644 index 0000000000..a475b85eb7 --- /dev/null +++ b/rpcs3/Emu/Memory/vm.cpp @@ -0,0 +1,44 @@ +#include "stdafx.h" + +namespace vm +{ + //TODO + bool check_addr(u32 addr) + { + return false; + } + + bool map(u32 addr, u32 size, u32 flags) + { + return false; + } + + bool unmap(u32 addr, u32 size, u32 flags) + { + return false; + } + + u32 alloc(u32 size) + { + return 0; + } + + void unalloc(u32 addr) + { + } + + u32 read32(u32 addr) + { + return 0; + } + + bool read32(u32 addr, u32& value) + { + return false; + } + + bool write32(u32 addr, u32 value) + { + return false; + } +} \ No newline at end of file diff --git a/rpcs3/Emu/Memory/vm.h b/rpcs3/Emu/Memory/vm.h new file mode 100644 index 0000000000..97a43cb78a --- /dev/null +++ b/rpcs3/Emu/Memory/vm.h @@ -0,0 +1,31 @@ +#pragma once + +namespace vm +{ + bool check_addr(u32 addr); + bool map(u32 addr, u32 size, u32 flags); + bool unmap(u32 addr, u32 size = 0, u32 flags = 0); + u32 alloc(u32 size); + void unalloc(u32 addr); + + template + T* get_ptr(u32 addr) + { + return (T*)&Memory[addr]; + } + + template + T& get_ref(u32 addr) + { + return (T&)Memory[addr]; + } + + //TODO + u32 read32(u32 addr); + bool read32(u32 addr, u32& value); + bool write32(u32 addr, u32 value); +} + +#include "vm_ptr.h" +#include "vm_ref.h" +#include "vm_var.h" \ No newline at end of file diff --git a/rpcs3/Emu/Memory/vm_ptr.h b/rpcs3/Emu/Memory/vm_ptr.h new file mode 100644 index 0000000000..3003f11e66 --- /dev/null +++ b/rpcs3/Emu/Memory/vm_ptr.h @@ -0,0 +1,386 @@ +#pragma once + +namespace vm +{ + template + class ptr + { + AT m_addr; + + public: + ptr operator++ (int) + { + AT result = m_addr; + m_addr += sizeof(AT); + return { result }; + } + + ptr& operator++ () + { + m_addr += sizeof(AT); + return *this; + } + + ptr operator-- (int) + { + AT result = m_addr; + m_addr -= sizeof(AT); + return { result }; + } + + ptr& operator-- () + { + m_addr -= sizeof(AT); + return *this; + } + + ptr& operator += (int count) + { + m_addr += count * sizeof(AT); + return *this; + } + + ptr& operator -= (int count) + { + m_addr -= count * sizeof(AT); + return *this; + } + + ptr operator + (int count) const + { + return { m_addr + count * sizeof(AT) }; + } + + ptr operator - (int count) const + { + return { m_addr - count * sizeof(AT) }; + } + + __forceinline ptr& operator *() + { + return get_ref>(m_addr); + } + + __forceinline const ptr& operator *() const + { + return get_ref>(m_addr); + } + + __forceinline ptr& operator [](int index) + { + return get_ref>(m_addr + sizeof(AT) * index); + } + + __forceinline const ptr& operator [](int index) const + { + return get_ref>(m_addr + sizeof(AT) * index); + } + + operator bool() const + { + return m_addr != 0; + } + + AT addr() const + { + return m_addr; + } + + bool check() const + { + return Memory.IsGoodAddr(m_addr, sizeof(AT)); + } + + static ptr make(u32 addr) + { + return (ptr&)addr; + } + }; + + template + class ptr + { + AT m_addr; + + public: + __forceinline T* operator -> () + { + return get_ptr(m_addr); + } + + __forceinline const T* operator -> () const + { + return get_ptr(m_addr); + } + + ptr operator++ (int) + { + AT result = m_addr; + m_addr += sizeof(T); + return { result }; + } + + ptr& operator++ () + { + m_addr += sizeof(T); + return *this; + } + + ptr operator-- (int) + { + AT result = m_addr; + m_addr -= sizeof(T); + return { result }; + } + + ptr& operator-- () + { + m_addr -= sizeof(T); + return *this; + } + + ptr& operator += (int count) + { + m_addr += count * sizeof(T); + return *this; + } + + ptr& operator -= (int count) + { + m_addr -= count * sizeof(T); + return *this; + } + + ptr operator + (int count) const + { + return { m_addr + count * sizeof(T) }; + } + + ptr operator - (int count) const + { + return { m_addr - count * sizeof(T) }; + } + + __forceinline T& operator *() + { + return get_ref(m_addr); + } + + __forceinline const T& operator *() const + { + return get_ref(m_addr); + } + + __forceinline T& operator [](int index) + { + return get_ref(m_addr + sizeof(T) * index); + } + + __forceinline const T& operator [](int index) const + { + return get_ref(m_addr + sizeof(T) * index); + } + + /* + operator ref() + { + return { m_addr }; + } + + operator const ref() const + { + return { m_addr }; + } + */ + + AT addr() const + { + return m_addr; + } + + operator bool() const + { + return m_addr != 0; + } + + T* get_ptr() const + { + return vm::get_ptr(m_addr); + } + + bool check() const + { + return Memory.IsGoodAddr(m_addr, sizeof(T)); + } + + static ptr make(u32 addr) + { + return (ptr&)addr; + } + }; + + template + class ptr + { + AT m_addr; + + public: + AT addr() const + { + return m_addr; + } + + void* get_ptr() const + { + return vm::get_ptr(m_addr); + } + + bool check() const + { + return Memory.IsGoodAddr(m_addr); + } + + operator bool() const + { + return m_addr != 0; + } + + static ptr make(u32 addr) + { + return (ptr&)addr; + } + }; + + template + class ptr + { + AT m_addr; + + __forceinline RT call_func(bool is_async) const + { + Callback cb; + cb.SetAddr(m_addr); + return (RT)cb.Branch(!is_async); + } + + public: + typedef RT(*type)(); + + __forceinline RT operator()() const + { + return call_func(false); + } + + __forceinline void async() const + { + call_func(true); + } + + AT addr() const + { + return m_addr; + } + + type get_ptr() const + { + return *((type*)vm::get_ptr(m_addr)); + } + + bool check() const + { + return Memory.IsGoodAddr(m_addr); + } + + operator bool() const + { + return m_addr != 0; + } + + static ptr make(u32 addr) + { + return (ptr&)addr; + } + }; + + template + class ptr + { + AT m_addr; + + __forceinline RT call_func(bool is_async, T... args) const + { + template + struct _func_arg + { + __forceinline static u64 get_value(const T& arg) + { + return arg; + } + }; + + template + struct _func_arg> + { + __forceinline static u64 get_value(const ptr arg) + { + return arg.addr(); + } + }; + + template + struct _func_arg> + { + __forceinline static u64 get_value(const ref arg) + { + return arg.addr(); + } + }; + + Callback cb; + cb.SetAddr(m_addr); + cb.Handle(_func_arg::get_value(args)...); + return (RT)cb.Branch(!is_async); + } + + public: + typedef RT(*type)(T...); + + __forceinline RT operator()(T... args) const + { + return call_func(false, args...); + } + + __forceinline void async(T... args) const + { + call_func(true, args...); + } + + AT addr() const + { + return m_addr; + } + + type get_ptr() const + { + return *((type*)vm::get_ptr(m_addr)); + } + + bool check() const + { + return Memory.IsGoodAddr(m_addr); + } + + operator bool() const + { + return m_addr != 0; + } + + static ptr make(u32 addr) + { + return (ptr&)addr; + } + }; + + template + class beptr : public ptr> {}; +} \ No newline at end of file diff --git a/rpcs3/Emu/Memory/vm_ref.h b/rpcs3/Emu/Memory/vm_ref.h new file mode 100644 index 0000000000..797c6da784 --- /dev/null +++ b/rpcs3/Emu/Memory/vm_ref.h @@ -0,0 +1,63 @@ +#pragma once + +namespace vm +{ + template + class _ref_base + { + AT m_addr; + + public: + operator T&() + { + return get_ref(m_addr); + } + + operator const T&() const + { + return get_ref(m_addr); + } + + AT addr() const + { + return m_addr; + } + + bool check() const + { + return Memory.IsGoodAddr(m_addr, sizeof(T)); + } + + static ref make(u32 addr) + { + return (ref&)addr; + } + }; + + //BE reference to LE data + template class brefl : public _ref_base> {}; + + //BE reference to BE data + template class brefb : public _ref_base, be_t> {}; + + //LE reference to BE data + template class lrefb : public _ref_base, AT> {}; + + //LE reference to LE data + template class lrefl : public _ref_base {}; + + namespace ps3 + { + //default reference for HLE functions (LE reference to BE data) + template class ref : public lrefb {}; + + //default reference for HLE structures (BE reference to BE data) + template class bref : public brefb {}; + } + + namespace psv + { + //default reference for HLE functions & structures (LE reference to LE data) + template class ref : public lrefl {}; + } +} \ No newline at end of file diff --git a/rpcs3/Emu/Memory/vm_var.h b/rpcs3/Emu/Memory/vm_var.h new file mode 100644 index 0000000000..adb4338c0d --- /dev/null +++ b/rpcs3/Emu/Memory/vm_var.h @@ -0,0 +1,503 @@ +#pragma once + +namespace vm +{ + template + class var + { + u32 m_addr; + u32 m_size; + u32 m_align; + T* m_ptr; + + public: + var(u32 size = sizeof(T), u32 align = sizeof(T)) + : m_size(size) + , m_align(align) + { + alloc(); + } + + var(const var& r) + : m_size(r.m_size) + , m_align(r.m_align) + { + alloc(); + *m_ptr = *r.m_ptr; + } + + ~var() + { + dealloc(); + } + + void alloc() + { + m_addr = Memory.Alloc(size(), m_align); + m_ptr = Memory.IsGoodAddr(m_addr, size()) ? get_ptr(m_addr) : nullptr; + } + + void dealloc() + { + if (check()) + { + Memory.Free(m_addr); + m_addr = 0; + m_ptr = nullptr; + } + } + + static var make(u32 addr, u32 size = sizeof(T), u32 align = sizeof(T)) + { + var res; + + res.m_addr = addr; + res.m_size = size; + res.m_align = align; + res.m_ptr = Memory.IsGoodAddr(addr, size) ? get_ptr(addr) : nullptr; + + return res; + } + + T* operator -> () + { + return m_ptr; + } + + const T* operator -> () const + { + return m_ptr; + } + + T* get_ptr() + { + return m_ptr; + } + + const T* get_ptr() const + { + return m_ptr; + } + + T& value() + { + return *m_ptr; + } + + const T& value() const + { + return *m_ptr; + } + + u32 addr() const + { + return m_addr; + } + + u32 size() const + { + return m_size; + } + + bool check() const + { + return m_ptr != nullptr; + } + + /* + operator const ref() const + { + return addr(); + } + */ + + operator T&() + { + return *m_ptr; + } + + operator const T&() const + { + return *m_ptr; + } + }; + + template + class var + { + u32 m_addr; + u32 m_count; + u32 m_size; + u32 m_align; + T* m_ptr; + + public: + var(u32 count, u32 size = sizeof(T), u32 align = sizeof(T)) + : m_count(count) + , m_size(size) + , m_align(align) + { + alloc(); + } + + ~var() + { + dealloc(); + } + + var(const var& r) + : m_size(r.m_size) + , m_align(r.m_align) + { + alloc(); + memcpy(m_ptr, r.m_ptr, size()); + } + + void alloc() + { + m_addr = Memory.Alloc(size(), m_align); + m_ptr = Memory.IsGoodAddr(m_addr, size()) ? get_ptr(m_addr) : nullptr; + } + + void dealloc() + { + if (check()) + { + Memory.Free(m_addr); + m_addr = 0; + m_ptr = nullptr; + } + } + + static var make(u32 addr, u32 count, u32 size = sizeof(T), u32 align = sizeof(T)) + { + var res; + + res.m_addr = addr; + res.m_count = count; + res.m_size = size; + res.m_align = align; + res.m_ptr = Memory.IsGoodAddr(addr, size * count) ? get_ptr(addr) : nullptr; + + return res; + } + + T* begin() + { + return m_ptr; + } + + const T* begin() const + { + return m_ptr; + } + + T* end() + { + return m_ptr + count(); + } + + const T* end() const + { + return m_ptr + count(); + } + + T* operator -> () + { + return m_ptr; + } + + T& get() + { + return m_ptr; + } + + const T& get() const + { + return m_ptr; + } + + const T* operator -> () const + { + return m_ptr; + } + + uint addr() const + { + return m_addr; + } + + uint size() const + { + return m_count * m_size; + } + + uint count() const + { + return m_count; + } + + bool check() const + { + return Memory.IsGoodAddr(m_addr, size()); + } + + template + operator const T1() const + { + return T1(*m_ptr); + } + + template + operator T1() + { + return T1(*m_ptr); + } + + operator const T&() const + { + return *m_ptr; + } + + operator T&() + { + return *m_ptr; + } + + operator const T*() const + { + return m_ptr; + } + + operator T*() + { + return m_ptr; + } + + T& operator [](int index) + { + return *(T*)((u8*)m_ptr + (m_size < m_align ? m_align : m_size) * index); + } + + const T& operator [](int index) const + { + return *(T*)((u8*)m_ptr + (m_size < m_align ? m_align : m_size) * index); + } + + T& at(uint index) + { + if (index >= count()) + throw std::out_of_range(std::to_string(index) + " >= " + count()); + + return *(T*)((u8*)m_ptr + (m_size < m_align ? m_align : m_size) * index); + } + + const T& at(uint index) const + { + if (index >= count()) + throw std::out_of_range(std::to_string(index) + " >= " + count()); + + return *(T*)((u8*)m_ptr + (m_size < m_align ? m_align : m_size) * index); + } + + T* ptr() + { + return m_ptr; + } + + const T* ptr() const + { + return m_ptr; + } + + /* + operator const ptr() const + { + return addr(); + } + */ + template + NT* To(uint offset = 0) + { + return (NT*)(m_ptr + offset); + } + }; + + template + class var + { + u32 m_addr; + u32 m_size; + u32 m_align; + T* m_ptr; + + public: + var(u32 size = sizeof(T), u32 align = sizeof(T)) + : m_size(size) + , m_align(align) + { + alloc(); + } + + ~var() + { + dealloc(); + } + + var(const var& r) + : m_size(r.m_size) + , m_align(r.m_align) + { + alloc(); + memcpy(m_ptr, r.m_ptr, size()); + } + + void alloc() + { + m_addr = Memory.Alloc(size(), m_align); + m_ptr = Memory.IsGoodAddr(m_addr, size()) ? get_ptr(m_addr) : nullptr; + } + + void dealloc() + { + if (check()) + { + Memory.Free(m_addr); + m_addr = 0; + m_ptr = nullptr; + } + } + + T* operator -> () + { + return m_ptr; + } + + T* begin() + { + return m_ptr; + } + + const T* begin() const + { + return m_ptr; + } + + T* end() + { + return m_ptr + count(); + } + + const T* end() const + { + return m_ptr + count(); + } + + T& get() + { + return m_ptr; + } + + const T& get() const + { + return m_ptr; + } + + const T* operator -> () const + { + return m_ptr; + } + + uint addr() const + { + return m_addr; + } + + __forceinline uint count() const + { + return _count; + } + + uint size() const + { + return _count * m_size; + } + + bool check() const + { + return m_ptr != nullptr; + } + + template + operator const T1() const + { + return T1(*m_ptr); + } + + template + operator T1() + { + return T1(*m_ptr); + } + + operator const T&() const + { + return *m_ptr; + } + + operator T&() + { + return *m_ptr; + } + + operator const T*() const + { + return m_ptr; + } + + operator T*() + { + return m_ptr; + } + + T& operator [](uint index) + { + assert(index < count()); + return *(T*)((u8*)m_ptr + (m_size < m_align ? m_align : m_size) * index); + } + + const T& operator [](uint index) const + { + assert(index < count()); + return *(T*)((u8*)m_ptr + (m_size < m_align ? m_align : m_size) * index); + } + + T& at(uint index) + { + if (index >= count()) + throw std::out_of_range(std::to_string(index) + " >= " + count()); + + return *(T*)((u8*)m_ptr + (m_size < m_align ? m_align : m_size) * index); + } + + const T& at(uint index) const + { + if (index >= count()) + throw std::out_of_range(std::to_string(index) + " >= " + count()); + + return *(T*)((u8*)m_ptr + (m_size < m_align ? m_align : m_size) * index); + } + + /* + operator const ptr() const + { + return addr(); + } + */ + template + NT* To(uint offset = 0) + { + return (NT*)(m_ptr + offset); + } + }; +} \ No newline at end of file diff --git a/rpcs3/Emu/SysCalls/Modules/cellFont.cpp b/rpcs3/Emu/SysCalls/Modules/cellFont.cpp index 7eb1c130cf..fdd0d4a457 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellFont.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellFont.cpp @@ -44,8 +44,9 @@ int cellFontInit(mem_ptr_t config) { cellFont->Log("cellFontInit(config=0x%x)", config.GetAddr()); - MemoryAllocator revisionFlags = 0; - cellFontGetRevisionFlags(revisionFlags.GetAddr()); + vm::var revisionFlags; + revisionFlags.value() = 0; + cellFontGetRevisionFlags(revisionFlags.addr()); return cellFontInitializeWithRevision(revisionFlags, config.GetAddr()); } diff --git a/rpcs3/Emu/SysCalls/Modules/cellGame.cpp b/rpcs3/Emu/SysCalls/Modules/cellGame.cpp index f18acfeb64..b93748ceb5 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellGame.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellGame.cpp @@ -236,11 +236,11 @@ int cellGameDataCheckCreate2(u32 version, const mem_list_ptr_t dirName, u32 } // TODO: use memory container - MemoryAllocator cbResult; - MemoryAllocator cbGet; - MemoryAllocator cbSet; + vm::var cbResult; + vm::var cbGet; + vm::var cbSet; - memset(cbGet.GetPtr(), 0, sizeof(CellGameDataStatGet)); + cbGet.value() = {}; // TODO: Use the free space of the computer's HDD where RPCS3 is being run. cbGet->hddFreeSizeKB = 40000000; //40 GB @@ -265,7 +265,7 @@ int cellGameDataCheckCreate2(u32 version, const mem_list_ptr_t dirName, u32 strcpy_trunc(cbGet->getParam.title, psf.GetString("TITLE")); // TODO: write lang titles - funcStat(cbResult.GetAddr(), cbGet.GetAddr(), cbSet.GetAddr()); + funcStat(cbResult.addr(), cbGet.addr(), cbSet.addr()); if (cbSet->setParam.GetAddr()) { diff --git a/rpcs3/Emu/SysCalls/Modules/cellGifDec.cpp b/rpcs3/Emu/SysCalls/Modules/cellGifDec.cpp index b3aa0c793b..dc9bbbafbf 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellGifDec.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellGifDec.cpp @@ -40,14 +40,14 @@ int cellGifDecOpen(u32 mainHandle, mem32_t subHandle, const mem_ptr_t> fd; - int ret = cellFsOpen(src->fileName, 0, fd.GetAddr(), 0, 0); + vm::var> fd; + int ret = cellFsOpen(src->fileName, 0, fd.addr(), 0, 0); current_subHandle->fd = fd->ToLE(); if (ret != CELL_OK) return CELL_GIFDEC_ERROR_OPEN_FILE; // Get size of file - MemoryAllocator sb; // Alloc a CellFsStat struct - ret = cellFsFstat(current_subHandle->fd, sb.GetAddr()); + vm::var sb; // Alloc a CellFsStat struct + ret = cellFsFstat(current_subHandle->fd, sb.addr()); if (ret != CELL_OK) return ret; current_subHandle->fileSize = sb->st_size; // Get CellFsStat.st_size break; @@ -73,18 +73,18 @@ int cellGifDecReadHeader(u32 mainHandle, u32 subHandle, mem_ptr_tinfo; //Write the header to buffer - MemoryAllocator buffer(13); // Alloc buffer for GIF header - MemoryAllocator> pos, nread; + vm::var buffer; // Alloc buffer for GIF header + vm::var> pos, nread; switch(subHandle_data->src.srcSelect.ToBE()) { case se32(CELL_GIFDEC_BUFFER): - memmove(Memory + buffer.GetAddr(), Memory + subHandle_data->src.streamPtr.ToLE(), buffer.GetSize()); + memmove(Memory + buffer.addr(), Memory + subHandle_data->src.streamPtr.ToLE(), buffer.size()); break; case se32(CELL_GIFDEC_FILE): - cellFsLseek(fd, 0, CELL_SEEK_SET, pos.GetAddr()); - cellFsRead(fd, buffer.GetAddr(), buffer.GetSize(), nread.GetAddr()); + cellFsLseek(fd, 0, CELL_SEEK_SET, pos.addr()); + cellFsRead(fd, buffer.addr(), buffer.size(), nread.addr()); break; } @@ -155,18 +155,18 @@ int cellGifDecDecodeData(u32 mainHandle, u32 subHandle, mem8_ptr_t data, const m const CellGifDecOutParam& current_outParam = subHandle_data->outParam; //Copy the GIF file to a buffer - MemoryAllocator gif((u32)fileSize); - MemoryAllocator pos, nread; + vm::var gif((u32)fileSize); + vm::var pos, nread; switch(subHandle_data->src.srcSelect.ToBE()) { case se32(CELL_GIFDEC_BUFFER): - memmove(Memory + gif.GetAddr(), Memory + subHandle_data->src.streamPtr.ToLE(), gif.GetSize()); + memmove(Memory + gif.addr(), Memory + subHandle_data->src.streamPtr.ToLE(), gif.size()); break; case se32(CELL_GIFDEC_FILE): - cellFsLseek(fd, 0, CELL_SEEK_SET, pos.GetAddr()); - cellFsRead(fd, gif.GetAddr(), gif.GetSize(), nread.GetAddr()); + cellFsLseek(fd, 0, CELL_SEEK_SET, pos.addr()); + cellFsRead(fd, gif.addr(), gif.size(), nread.addr()); break; } @@ -174,7 +174,7 @@ int cellGifDecDecodeData(u32 mainHandle, u32 subHandle, mem8_ptr_t data, const m int width, height, actual_components; auto image = std::unique_ptr ( - stbi_load_from_memory(gif.GetPtr(), (s32)fileSize, &width, &height, &actual_components, 4), + stbi_load_from_memory(gif.ptr(), (s32)fileSize, &width, &height, &actual_components, 4), &::free ); diff --git a/rpcs3/Emu/SysCalls/Modules/cellJpgDec.cpp b/rpcs3/Emu/SysCalls/Modules/cellJpgDec.cpp index 71afb2d8e6..3040029fb3 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellJpgDec.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellJpgDec.cpp @@ -46,14 +46,14 @@ int cellJpgDecOpen(u32 mainHandle, mem32_t subHandle, mem_ptr_t s case se32(CELL_JPGDEC_FILE): // Get file descriptor - MemoryAllocator> fd; - int ret = cellFsOpen(src->fileName, 0, fd.GetAddr(), 0, 0); + vm::var> fd; + int ret = cellFsOpen(src->fileName, 0, fd.addr(), 0, 0); current_subHandle->fd = fd->ToLE(); if (ret != CELL_OK) return CELL_JPGDEC_ERROR_OPEN_FILE; // Get size of file - MemoryAllocator sb; // Alloc a CellFsStat struct - ret = cellFsFstat(current_subHandle->fd, sb.GetAddr()); + vm::var sb; // Alloc a CellFsStat struct + ret = cellFsFstat(current_subHandle->fd, sb.addr()); if (ret != CELL_OK) return ret; current_subHandle->fileSize = sb->st_size; // Get CellFsStat.st_size break; @@ -93,18 +93,18 @@ int cellJpgDecReadHeader(u32 mainHandle, u32 subHandle, mem_ptr_tinfo; //Write the header to buffer - MemoryAllocator buffer((u32)fileSize); - MemoryAllocator> pos, nread; + vm::var buffer((u32)fileSize); + vm::var> pos, nread; switch(subHandle_data->src.srcSelect.ToBE()) { case se32(CELL_JPGDEC_BUFFER): - memmove(Memory + buffer.GetAddr(), Memory + subHandle_data->src.streamPtr.ToLE(), buffer.GetSize()); + memmove(Memory + buffer.addr(), Memory + subHandle_data->src.streamPtr.ToLE(), buffer.size()); break; case se32(CELL_JPGDEC_FILE): - cellFsLseek(fd, 0, CELL_SEEK_SET, pos.GetAddr()); - cellFsRead(fd, buffer.GetAddr(), buffer.GetSize(), nread.GetAddr()); + cellFsLseek(fd, 0, CELL_SEEK_SET, pos.addr()); + cellFsRead(fd, buffer.addr(), buffer.size(), nread.addr()); break; } @@ -162,18 +162,18 @@ int cellJpgDecDecodeData(u32 mainHandle, u32 subHandle, mem8_ptr_t data, const m const CellJpgDecOutParam& current_outParam = subHandle_data->outParam; //Copy the JPG file to a buffer - MemoryAllocator jpg((u32)fileSize); - MemoryAllocator pos, nread; + vm::var jpg((u32)fileSize); + vm::var pos, nread; switch(subHandle_data->src.srcSelect.ToBE()) { case se32(CELL_JPGDEC_BUFFER): - memmove(Memory + jpg.GetAddr(), Memory + subHandle_data->src.streamPtr.ToLE(), jpg.GetSize()); + memmove(Memory + jpg.addr(), Memory + subHandle_data->src.streamPtr.ToLE(), jpg.size()); break; case se32(CELL_JPGDEC_FILE): - cellFsLseek(fd, 0, CELL_SEEK_SET, pos.GetAddr()); - cellFsRead(fd, jpg.GetAddr(), jpg.GetSize(), nread.GetAddr()); + cellFsLseek(fd, 0, CELL_SEEK_SET, pos.addr()); + cellFsRead(fd, jpg.addr(), jpg.size(), nread.addr()); break; } @@ -181,7 +181,7 @@ int cellJpgDecDecodeData(u32 mainHandle, u32 subHandle, mem8_ptr_t data, const m int width, height, actual_components; auto image = std::unique_ptr ( - stbi_load_from_memory(jpg.GetPtr(), (s32)fileSize, &width, &height, &actual_components, 4), + stbi_load_from_memory(jpg.ptr(), (s32)fileSize, &width, &height, &actual_components, 4), &::free ); diff --git a/rpcs3/Emu/SysCalls/Modules/cellPngDec.cpp b/rpcs3/Emu/SysCalls/Modules/cellPngDec.cpp index 0d444d9803..9a419e02e4 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellPngDec.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellPngDec.cpp @@ -15,7 +15,7 @@ static std::map cellPngDecMap; CellPngDecMainHandle *getCellPngDecCtx(u32 mainHandle) { if (cellPngDecMap.find(mainHandle) == cellPngDecMap.end()) - return NULL; + return nullptr; return cellPngDecMap[mainHandle]; } @@ -68,14 +68,14 @@ int cellPngDecOpen(u32 mainHandle, mem32_t subHandle, mem_ptr_t s case se32(CELL_PNGDEC_FILE): // Get file descriptor - MemoryAllocator> fd; - int ret = cellFsOpen(src->fileName_addr, 0, fd.GetAddr(), 0, 0); + vm::var> fd; + int ret = cellFsOpen(src->fileName_addr, 0, fd.addr(), 0, 0); current_subHandle->fd = fd->ToLE(); if(ret != CELL_OK) return CELL_PNGDEC_ERROR_OPEN_FILE; // Get size of file - MemoryAllocator sb; // Alloc a CellFsStat struct - ret = cellFsFstat(current_subHandle->fd, sb.GetAddr()); + vm::var sb; // Alloc a CellFsStat struct + ret = cellFsFstat(current_subHandle->fd, sb.addr()); if(ret != CELL_OK) return ret; current_subHandle->fileSize = sb->st_size; // Get CellFsStat.st_size break; @@ -94,12 +94,12 @@ int cellPngDecExtOpen(u32 mainHandle, mem32_t subHandle, mem_ptr_tWarning("*** cbCtrlStrm->cbCtrlStrmFunc_addr=0x%x", cbCtrlStrm->cbCtrlStrmFunc.GetAddr()); - MemoryAllocator streamInfo; - MemoryAllocator streamParam; + vm::var streamInfo; + vm::var streamParam; int res = cellPngDecOpen(mainHandle, subHandle, src, openInfo); - if (!res) cbCtrlStrm->cbCtrlStrmFunc(streamInfo.GetAddr(), streamParam.GetAddr(), cbCtrlStrm->cbCtrlStrmArg); + if (!res) cbCtrlStrm->cbCtrlStrmFunc(streamInfo.addr(), streamParam.addr(), cbCtrlStrm->cbCtrlStrmArg); return res; } @@ -133,28 +133,29 @@ int cellPngDecReadHeader(u32 mainHandle, u32 subHandle, mem_ptr_t> buffer(34); // Alloc buffer for PNG header - MemoryAllocator> pos, nread; + vm::var buffer; // Alloc buffer for PNG header + auto buffer_32 = buffer.To>(); + vm::var> pos, nread; switch(subHandle_data->src.srcSelect.ToBE()) { case se32(CELL_PNGDEC_BUFFER): - memmove(Memory + buffer.GetAddr(), Memory + subHandle_data->src.streamPtr.ToLE(), buffer.GetSize()); + memmove(Memory + buffer.addr(), Memory + subHandle_data->src.streamPtr.ToLE(), buffer.size()); break; case se32(CELL_PNGDEC_FILE): - cellFsLseek(fd, 0, CELL_SEEK_SET, pos.GetAddr()); - cellFsRead(fd, buffer.GetAddr(), buffer.GetSize(), nread.GetAddr()); + cellFsLseek(fd, 0, CELL_SEEK_SET, pos.addr()); + cellFsRead(fd, buffer.addr(), buffer.size(), nread.addr()); break; } - if (buffer[0] != 0x89504E47 || - buffer[1] != 0x0D0A1A0A || // Error: The first 8 bytes are not a valid PNG signature - buffer[3] != 0x49484452) // Error: The PNG file does not start with an IHDR chunk + if (buffer_32[0].ToBE() != se32(0x89504E47) || + buffer_32[1].ToBE() != se32(0x0D0A1A0A) || // Error: The first 8 bytes are not a valid PNG signature + buffer_32[3].ToBE() != se32(0x49484452)) // Error: The PNG file does not start with an IHDR chunk { return CELL_PNGDEC_ERROR_HEADER; } - switch (buffer.To()[25]) + switch (buffer[25]) { case 0: current_info.colorSpace = CELL_PNGDEC_GRAYSCALE; current_info.numComponents = 1; break; case 2: current_info.colorSpace = CELL_PNGDEC_RGB; current_info.numComponents = 3; break; @@ -164,10 +165,10 @@ int cellPngDecReadHeader(u32 mainHandle, u32 subHandle, mem_ptr_t()[24]; - current_info.interlaceMethod = buffer.To()[28]; + current_info.imageWidth = buffer_32[4]; + current_info.imageHeight = buffer_32[5]; + current_info.bitDepth = buffer[24]; + current_info.interlaceMethod = buffer[28]; current_info.chunkInformation = 0; // Unimplemented *info = current_info; @@ -198,18 +199,18 @@ int cellPngDecDecodeData(u32 mainHandle, u32 subHandle, mem8_ptr_t data, const m const CellPngDecOutParam& current_outParam = subHandle_data->outParam; //Copy the PNG file to a buffer - MemoryAllocator png((u32)fileSize); - MemoryAllocator pos, nread; + vm::var png((u32)fileSize); + vm::var pos, nread; switch(subHandle_data->src.srcSelect.ToBE()) { case se32(CELL_PNGDEC_BUFFER): - memmove(Memory + png.GetAddr(), Memory + subHandle_data->src.streamPtr.ToLE(), png.GetSize()); + memmove(Memory + png.addr(), Memory + subHandle_data->src.streamPtr.ToLE(), png.size()); break; case se32(CELL_PNGDEC_FILE): - cellFsLseek(fd, 0, CELL_SEEK_SET, pos.GetAddr()); - cellFsRead(fd, png.GetAddr(), png.GetSize(), nread.GetAddr()); + cellFsLseek(fd, 0, CELL_SEEK_SET, pos.addr()); + cellFsRead(fd, png.addr(), png.size(), nread.addr()); break; } @@ -217,7 +218,7 @@ int cellPngDecDecodeData(u32 mainHandle, u32 subHandle, mem8_ptr_t data, const m int width, height, actual_components; auto image = std::unique_ptr ( - stbi_load_from_memory(png.GetPtr(), (s32)fileSize, &width, &height, &actual_components, 4), + stbi_load_from_memory(png.ptr(), (s32)fileSize, &width, &height, &actual_components, 4), &::free ); if (!image) return CELL_PNGDEC_ERROR_STREAM_FORMAT; diff --git a/rpcs3/Emu/SysCalls/Modules/cellResc.cpp b/rpcs3/Emu/SysCalls/Modules/cellResc.cpp index bbd3797131..4003352d0f 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellResc.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellResc.cpp @@ -726,13 +726,13 @@ int cellRescSetDisplayMode(u32 displayMode) else m_pCFragmentShader = m_pCFragmentShaderArray[RESC_SHADER_DEFAULT_BILINEAR]; }*/ - MemoryAllocator videocfg; + vm::var videocfg; videocfg->resolutionId = RescBufferMode2SysutilResolutionId(s_rescInternalInstance->m_dstMode); videocfg->format = RescDstFormat2SysutilFormat(s_rescInternalInstance->m_pRescDsts->format ); videocfg->aspect = CELL_VIDEO_OUT_ASPECT_AUTO; videocfg->pitch = s_rescInternalInstance->m_dstPitch; - cellVideoOutConfigure(CELL_VIDEO_OUT_PRIMARY, videocfg.GetAddr(), 0, 0); + cellVideoOutConfigure(CELL_VIDEO_OUT_PRIMARY, videocfg.addr(), 0, 0); if (IsPalInterpolate()) { @@ -1016,8 +1016,8 @@ int cellRescSetBufferAddress(mem32_t colorBuffers, mem32_t vertexArray, mem32_t s_rescInternalInstance->m_vertexArrayEA = vertexArray.GetAddr(); s_rescInternalInstance->m_fragmentUcodeEA = fragmentShader.GetAddr(); - MemoryAllocator> dstOffset; - cellGcmAddressToOffset(s_rescInternalInstance->m_colorBuffersEA, dstOffset.GetAddr()); + vm::var> dstOffset; + cellGcmAddressToOffset(s_rescInternalInstance->m_colorBuffersEA, dstOffset.addr()); for (int i=0; i param; - MemoryAllocator result; - MemoryAllocator get; - MemoryAllocator set; + vm::var param; + vm::var result; + vm::var get; + vm::var set; get->hddFreeSizeKB = 40 * 1024 * 1024; // 40 GB, TODO: Use the free space of the computer's HDD where RPCS3 is being run. get->isNewData = CELL_HDDGAME_ISNEWDATA_EXIST; @@ -730,7 +730,7 @@ int cellHddGameCheck(u32 version, u32 dirName_addr, u32 errDialog, mem_func_ptr_ // TODO ? - funcStat(result.GetAddr(), get.GetAddr(), set.GetAddr()); + funcStat(result.addr(), get.addr(), set.addr()); if (result->result != CELL_HDDGAME_CBRESULT_OK && result->result != CELL_HDDGAME_CBRESULT_OK_CANCEL) return CELL_HDDGAME_ERROR_CBRESULT; diff --git a/rpcs3/Emu/SysCalls/Modules/cellSysutil_SaveData.cpp b/rpcs3/Emu/SysCalls/Modules/cellSysutil_SaveData.cpp index 3b17cb5fb7..da5dce0882 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSysutil_SaveData.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSysutil_SaveData.cpp @@ -216,8 +216,8 @@ void getSaveDataStat(SaveDataEntry entry, mem_ptr_t statGet s32 modifySaveDataFiles(mem_func_ptr_t& funcFile, mem_ptr_t result, const std::string& saveDataDir) { - MemoryAllocator fileGet; - MemoryAllocator fileSet; + vm::var fileGet; + vm::var fileSet; if (!Emu.GetVFS().ExistsDir(saveDataDir)) Emu.GetVFS().CreateDir(saveDataDir); @@ -225,7 +225,7 @@ s32 modifySaveDataFiles(mem_func_ptr_t& funcFile, mem_ fileGet->excSize = 0; while (true) { - funcFile(result.GetAddr(), fileGet.GetAddr(), fileSet.GetAddr()); + funcFile(result.GetAddr(), fileGet.addr(), fileSet.addr()); if (result->result < 0) { cellSysutil->Error("modifySaveDataFiles: CellSaveDataFileCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message. return CELL_SAVEDATA_ERROR_CBRESULT; @@ -294,11 +294,11 @@ int cellSaveDataListSave2(u32 version, mem_ptr_t setList, m cellSysutil->Warning("cellSaveDataListSave2(version=%d, setList_addr=0x%x, setBuf_addr=0x%x, funcList_addr=0x%x, funcStat_addr=0x%x, funcFile_addr=0x%x, container=0x%x, userdata_addr=0x%x)", version, setList.GetAddr(), setBuf.GetAddr(), funcList.GetAddr(), funcStat.GetAddr(), funcFile.GetAddr(), container, userdata_addr); - MemoryAllocator result; - MemoryAllocator listGet; - MemoryAllocator listSet; - MemoryAllocator statGet; - MemoryAllocator statSet; + vm::var result; + vm::var listGet; + vm::var listSet; + vm::var statGet; + vm::var statSet; std::string saveBaseDir = "/dev_hdd0/home/00000001/savedata/"; // TODO: Get the path of the current user vfsDir dir(saveBaseDir); @@ -333,7 +333,7 @@ int cellSaveDataListSave2(u32 version, mem_ptr_t setList, m memcpy(dirList[i].listParam, saveEntries[i].listParam.c_str(), CELL_SAVEDATA_SYSP_LPARAM_SIZE); } - funcList(result.GetAddr(), listGet.GetAddr(), listSet.GetAddr()); + funcList(result.addr(), listGet.addr(), listSet.addr()); if (result->result < 0) { cellSysutil->Error("cellSaveDataListSave2: CellSaveDataListCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message. @@ -351,10 +351,10 @@ int cellSaveDataListSave2(u32 version, mem_ptr_t setList, m u32 focusIndex = focusSaveDataEntry(saveEntries, listSet->focusPosition); // TODO: Display the dialog here u32 selectedIndex = focusIndex; // TODO: Until the dialog is implemented, select always the focused entry - getSaveDataStat(saveEntries[selectedIndex], statGet.GetAddr()); + getSaveDataStat(saveEntries[selectedIndex], statGet.addr()); result->userdata_addr = userdata_addr; - funcStat(result.GetAddr(), statGet.GetAddr(), statSet.GetAddr()); + funcStat(result.addr(), statGet.addr(), statSet.addr()); Memory.Free(statGet->fileList.GetAddr()); if (result->result < 0) { cellSysutil->Error("cellSaveDataListLoad2: CellSaveDataStatCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message. @@ -366,7 +366,7 @@ int cellSaveDataListSave2(u32 version, mem_ptr_t setList, m */ // Enter the loop where the save files are read/created/deleted. - s32 ret = modifySaveDataFiles(funcFile, result.GetAddr(), saveBaseDir + (char*)statGet->dir.dirName); + s32 ret = modifySaveDataFiles(funcFile, result.addr(), saveBaseDir + (char*)statGet->dir.dirName); return ret; } @@ -377,12 +377,12 @@ int cellSaveDataListLoad2(u32 version, mem_ptr_t setList, m { cellSysutil->Warning("cellSaveDataListLoad2(version=%d, setList_addr=0x%x, setBuf_addr=0x%x, funcList_addr=0x%x, funcStat_addr=0x%x, funcFile_addr=0x%x, container=0x%x, userdata_addr=0x%x)", version, setList.GetAddr(), setBuf.GetAddr(), funcList.GetAddr(), funcStat.GetAddr(), funcFile.GetAddr(), container, userdata_addr); - - MemoryAllocator result; - MemoryAllocator listGet; - MemoryAllocator listSet; - MemoryAllocator statGet; - MemoryAllocator statSet; + + vm::var result; + vm::var listGet; + vm::var listSet; + vm::var statGet; + vm::var statSet; std::string saveBaseDir = "/dev_hdd0/home/00000001/savedata/"; // TODO: Get the path of the current user vfsDir dir(saveBaseDir); @@ -418,7 +418,7 @@ int cellSaveDataListLoad2(u32 version, mem_ptr_t setList, m memcpy(dirList[i].listParam, saveEntries[i].listParam.c_str(), CELL_SAVEDATA_SYSP_LPARAM_SIZE); } - funcList(result.GetAddr(), listGet.GetAddr(), listSet.GetAddr()); + funcList(result.addr(), listGet.addr(), listSet.addr()); if (result->result < 0) { cellSysutil->Error("cellSaveDataListLoad2: CellSaveDataListCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message. @@ -436,10 +436,10 @@ int cellSaveDataListLoad2(u32 version, mem_ptr_t setList, m u32 focusIndex = focusSaveDataEntry(saveEntries, listSet->focusPosition); // TODO: Display the dialog here u32 selectedIndex = focusIndex; // TODO: Until the dialog is implemented, select always the focused entry - getSaveDataStat(saveEntries[selectedIndex], statGet.GetAddr()); + getSaveDataStat(saveEntries[selectedIndex], statGet.addr()); result->userdata_addr = userdata_addr; - funcStat(result.GetAddr(), statGet.GetAddr(), statSet.GetAddr()); + funcStat(result.addr(), statGet.addr(), statSet.addr()); Memory.Free(statGet->fileList.GetAddr()); if (result->result < 0) { cellSysutil->Error("cellSaveDataListLoad2: CellSaveDataStatCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message. @@ -451,7 +451,7 @@ int cellSaveDataListLoad2(u32 version, mem_ptr_t setList, m */ // Enter the loop where the save files are read/created/deleted. - s32 ret = modifySaveDataFiles(funcFile, result.GetAddr(), saveBaseDir + (char*)statGet->dir.dirName); + s32 ret = modifySaveDataFiles(funcFile, result.addr(), saveBaseDir + (char*)statGet->dir.dirName); return ret; } @@ -463,11 +463,11 @@ int cellSaveDataFixedSave2(u32 version, mem_ptr_t setList, cellSysutil->Warning("cellSaveDataFixedSave2(version=%d, setList_addr=0x%x, setBuf_addr=0x%x, funcFixed_addr=0x%x, funcStat_addr=0x%x, funcFile_addr=0x%x, container=0x%x, userdata_addr=0x%x)", version, setList.GetAddr(), setBuf.GetAddr(), funcFixed.GetAddr(), funcStat.GetAddr(), funcFile.GetAddr(), container, userdata_addr); - MemoryAllocator result; - MemoryAllocator listGet; - MemoryAllocator fixedSet; - MemoryAllocator statGet; - MemoryAllocator statSet; + vm::var result; + vm::var listGet; + vm::var fixedSet; + vm::var statGet; + vm::var statSet; std::string saveBaseDir = "/dev_hdd0/home/00000001/savedata/"; // TODO: Get the path of the current user vfsDir dir(saveBaseDir); @@ -499,17 +499,17 @@ int cellSaveDataFixedSave2(u32 version, mem_ptr_t setList, memcpy(dirList[i].dirName, saveEntries[i].dirName.c_str(), CELL_SAVEDATA_DIRNAME_SIZE); memcpy(dirList[i].listParam, saveEntries[i].listParam.c_str(), CELL_SAVEDATA_SYSP_LPARAM_SIZE); } - funcFixed(result.GetAddr(), listGet.GetAddr(), fixedSet.GetAddr()); + funcFixed(result.addr(), listGet.addr(), fixedSet.addr()); if (result->result < 0) { cellSysutil->Error("cellSaveDataFixedSave2: CellSaveDataFixedCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message. return CELL_SAVEDATA_ERROR_CBRESULT; } - setSaveDataFixed(saveEntries, fixedSet.GetAddr()); - getSaveDataStat(saveEntries[0], statGet.GetAddr()); // There should be only one element in this list + setSaveDataFixed(saveEntries, fixedSet.addr()); + getSaveDataStat(saveEntries[0], statGet.addr()); // There should be only one element in this list // TODO: Display the Yes|No dialog here result->userdata_addr = userdata_addr; - funcStat(result.GetAddr(), statGet.GetAddr(), statSet.GetAddr()); + funcStat(result.addr(), statGet.addr(), statSet.addr()); Memory.Free(statGet->fileList.GetAddr()); if (result->result < 0) { cellSysutil->Error("cellSaveDataFixedSave2: CellSaveDataStatCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message. @@ -520,7 +520,7 @@ int cellSaveDataFixedSave2(u32 version, mem_ptr_t setList, */ // Enter the loop where the save files are read/created/deleted. - s32 ret = modifySaveDataFiles(funcFile, result.GetAddr(), saveBaseDir + (char*)statGet->dir.dirName); + s32 ret = modifySaveDataFiles(funcFile, result.addr(), saveBaseDir + (char*)statGet->dir.dirName); return ret; } @@ -532,11 +532,11 @@ int cellSaveDataFixedLoad2(u32 version, mem_ptr_t setList, cellSysutil->Warning("cellSaveDataFixedLoad2(version=%d, setList_addr=0x%x, setBuf=0x%x, funcList=0x%x, funcStat=0x%x, funcFile=0x%x, container=0x%x, userdata_addr=0x%x)", version, setList.GetAddr(), setBuf.GetAddr(), funcFixed.GetAddr(), funcStat.GetAddr(), funcFile.GetAddr(), container, userdata_addr); - MemoryAllocator result; - MemoryAllocator listGet; - MemoryAllocator fixedSet; - MemoryAllocator statGet; - MemoryAllocator statSet; + vm::var result; + vm::var listGet; + vm::var fixedSet; + vm::var statGet; + vm::var statSet; std::string saveBaseDir = "/dev_hdd0/home/00000001/savedata/"; // TODO: Get the path of the current user vfsDir dir(saveBaseDir); @@ -568,17 +568,17 @@ int cellSaveDataFixedLoad2(u32 version, mem_ptr_t setList, memcpy(dirList[i].dirName, saveEntries[i].dirName.c_str(), CELL_SAVEDATA_DIRNAME_SIZE); memcpy(dirList[i].listParam, saveEntries[i].listParam.c_str(), CELL_SAVEDATA_SYSP_LPARAM_SIZE); } - funcFixed(result.GetAddr(), listGet.GetAddr(), fixedSet.GetAddr()); + funcFixed(result.addr(), listGet.addr(), fixedSet.addr()); if (result->result < 0) { cellSysutil->Error("cellSaveDataFixedLoad2: CellSaveDataFixedCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message. return CELL_SAVEDATA_ERROR_CBRESULT; } - setSaveDataFixed(saveEntries, fixedSet.GetAddr()); - getSaveDataStat(saveEntries[0], statGet.GetAddr()); // There should be only one element in this list + setSaveDataFixed(saveEntries, fixedSet.addr()); + getSaveDataStat(saveEntries[0], statGet.addr()); // There should be only one element in this list // TODO: Display the Yes|No dialog here result->userdata_addr = userdata_addr; - funcStat(result.GetAddr(), statGet.GetAddr(), statSet.GetAddr()); + funcStat(result.addr(), statGet.addr(), statSet.addr()); Memory.Free(statGet->fileList.GetAddr()); if (result->result < 0) { cellSysutil->Error("cellSaveDataFixedLoad2: CellSaveDataStatCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message. @@ -589,7 +589,7 @@ int cellSaveDataFixedLoad2(u32 version, mem_ptr_t setList, */ // Enter the loop where the save files are read/created/deleted. - s32 ret = modifySaveDataFiles(funcFile, result.GetAddr(), saveBaseDir + (char*)statGet->dir.dirName); + s32 ret = modifySaveDataFiles(funcFile, result.addr(), saveBaseDir + (char*)statGet->dir.dirName); return ret; } @@ -601,9 +601,9 @@ int cellSaveDataAutoSave2(u32 version, u32 dirName_addr, u32 errDialog, mem_ptr_ cellSysutil->Warning("cellSaveDataAutoSave2(version=%d, dirName_addr=0x%x, errDialog=%d, setBuf=0x%x, funcList=0x%x, funcStat=0x%x, funcFile=0x%x, container=0x%x, userdata_addr=0x%x)", version, dirName_addr, errDialog, setBuf.GetAddr(), funcStat.GetAddr(), funcFile.GetAddr(), container, userdata_addr); - MemoryAllocator result; - MemoryAllocator statGet; - MemoryAllocator statSet; + vm::var result; + vm::var statGet; + vm::var statSet; std::string saveBaseDir = "/dev_hdd0/home/00000001/savedata/"; // TODO: Get the path of the current user vfsDir dir(saveBaseDir); @@ -628,9 +628,9 @@ int cellSaveDataAutoSave2(u32 version, u32 dirName_addr, u32 errDialog, mem_ptr_ saveEntries.push_back(entry); } - getSaveDataStat(saveEntries[0], statGet.GetAddr()); // There should be only one element in this list + getSaveDataStat(saveEntries[0], statGet.addr()); // There should be only one element in this list result->userdata_addr = userdata_addr; - funcStat(result.GetAddr(), statGet.GetAddr(), statSet.GetAddr()); + funcStat(result.addr(), statGet.addr(), statSet.addr()); Memory.Free(statGet->fileList.GetAddr()); if (result->result < 0) { @@ -642,7 +642,7 @@ int cellSaveDataAutoSave2(u32 version, u32 dirName_addr, u32 errDialog, mem_ptr_ */ // Enter the loop where the save files are read/created/deleted. - s32 ret = modifySaveDataFiles(funcFile, result.GetAddr(), saveBaseDir + (char*)statGet->dir.dirName); + s32 ret = modifySaveDataFiles(funcFile, result.addr(), saveBaseDir + (char*)statGet->dir.dirName); return CELL_SAVEDATA_RET_OK; } @@ -654,9 +654,9 @@ int cellSaveDataAutoLoad2(u32 version, u32 dirName_addr, u32 errDialog, mem_ptr_ cellSysutil->Warning("cellSaveDataAutoLoad2(version=%d, dirName_addr=0x%x, errDialog=%d, setBuf=0x%x, funcList=0x%x, funcStat=0x%x, funcFile=0x%x, container=0x%x, userdata_addr=0x%x)", version, dirName_addr, errDialog, setBuf.GetAddr(), funcStat.GetAddr(), funcFile.GetAddr(), container, userdata_addr); - MemoryAllocator result; - MemoryAllocator statGet; - MemoryAllocator statSet; + vm::var result; + vm::var statGet; + vm::var statSet; std::string saveBaseDir = "/dev_hdd0/home/00000001/savedata/"; // TODO: Get the path of the current user vfsDir dir(saveBaseDir); @@ -678,9 +678,9 @@ int cellSaveDataAutoLoad2(u32 version, u32 dirName_addr, u32 errDialog, mem_ptr_ return CELL_OK; // TODO: Can anyone check the actual behaviour of a PS3 when saves are not found? } - getSaveDataStat(saveEntries[0], statGet.GetAddr()); // There should be only one element in this list + getSaveDataStat(saveEntries[0], statGet.addr()); // There should be only one element in this list result->userdata_addr = userdata_addr; - funcStat(result.GetAddr(), statGet.GetAddr(), statSet.GetAddr()); + funcStat(result.addr(), statGet.addr(), statSet.addr()); Memory.Free(statGet->fileList.GetAddr()); if (result->result < 0) { @@ -692,7 +692,7 @@ int cellSaveDataAutoLoad2(u32 version, u32 dirName_addr, u32 errDialog, mem_ptr_ */ // Enter the loop where the save files are read/created/deleted. - s32 ret = modifySaveDataFiles(funcFile, result.GetAddr(), saveBaseDir + (char*)statGet->dir.dirName); + s32 ret = modifySaveDataFiles(funcFile, result.addr(), saveBaseDir + (char*)statGet->dir.dirName); return CELL_SAVEDATA_RET_OK; } @@ -703,11 +703,11 @@ int cellSaveDataListAutoSave(u32 version, u32 errDialog, mem_ptr_tWarning("cellSaveDataListAutoSave(version=%d, errDialog=%d, setBuf=0x%x, funcFixed=0x%x, funcStat=0x%x, funcFile=0x%x, container=0x%x, userdata_addr=0x%x)", version, errDialog, setList.GetAddr(), setBuf.GetAddr(), funcFixed.GetAddr(), funcStat.GetAddr(), funcFile.GetAddr(), container, userdata_addr); - MemoryAllocator result; - MemoryAllocator listGet; - MemoryAllocator listSet; - MemoryAllocator statGet; - MemoryAllocator statSet; + vm::var result; + vm::var listGet; + vm::var listSet; + vm::var statGet; + vm::var statSet; std::string saveBaseDir = "/dev_hdd0/home/00000001/savedata/"; // TODO: Get the path of the current user vfsDir dir(saveBaseDir); @@ -743,7 +743,7 @@ int cellSaveDataListAutoSave(u32 version, u32 errDialog, mem_ptr_tresult < 0) { cellSysutil->Error("cellSaveDataListAutoSave: CellSaveDataListCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message. @@ -761,10 +761,10 @@ int cellSaveDataListAutoSave(u32 version, u32 errDialog, mem_ptr_tfocusPosition); // TODO: Display the dialog here u32 selectedIndex = focusIndex; // TODO: Until the dialog is implemented, select always the focused entry - getSaveDataStat(saveEntries[selectedIndex], statGet.GetAddr()); + getSaveDataStat(saveEntries[selectedIndex], statGet.addr()); result->userdata_addr = userdata_addr; - funcStat(result.GetAddr(), statGet.GetAddr(), statSet.GetAddr()); + funcStat(result.addr(), statGet.addr(), statSet.addr()); Memory.Free(statGet->fileList.GetAddr()); if (result->result < 0) { cellSysutil->Error("cellSaveDataListAutoSave: CellSaveDataStatCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message. @@ -776,7 +776,7 @@ int cellSaveDataListAutoSave(u32 version, u32 errDialog, mem_ptr_tdir.dirName); + s32 ret = modifySaveDataFiles(funcFile, result.addr(), saveBaseDir + (char*)statGet->dir.dirName); return CELL_SAVEDATA_RET_OK; } @@ -787,11 +787,11 @@ int cellSaveDataListAutoLoad(u32 version, u32 errDialog, mem_ptr_tWarning("cellSaveDataListAutoLoad(version=%d, errDialog=%d, setBuf=0x%x, funcFixed=0x%x, funcStat=0x%x, funcFile=0x%x, container=0x%x, userdata_addr=0x%x)", version, errDialog, setList.GetAddr(), setBuf.GetAddr(), funcFixed.GetAddr(), funcStat.GetAddr(), funcFile.GetAddr(), container, userdata_addr); - MemoryAllocator result; - MemoryAllocator listGet; - MemoryAllocator listSet; - MemoryAllocator statGet; - MemoryAllocator statSet; + vm::var result; + vm::var listGet; + vm::var listSet; + vm::var statGet; + vm::var statSet; std::string saveBaseDir = "/dev_hdd0/home/00000001/savedata/"; // TODO: Get the path of the current user vfsDir dir(saveBaseDir); @@ -827,7 +827,7 @@ int cellSaveDataListAutoLoad(u32 version, u32 errDialog, mem_ptr_tresult < 0) { cellSysutil->Error("cellSaveDataListAutoLoad: CellSaveDataListCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message. @@ -845,10 +845,10 @@ int cellSaveDataListAutoLoad(u32 version, u32 errDialog, mem_ptr_tfocusPosition); // TODO: Display the dialog here u32 selectedIndex = focusIndex; // TODO: Until the dialog is implemented, select always the focused entry - getSaveDataStat(saveEntries[selectedIndex], statGet.GetAddr()); + getSaveDataStat(saveEntries[selectedIndex], statGet.addr()); result->userdata_addr = userdata_addr; - funcStat(result.GetAddr(), statGet.GetAddr(), statSet.GetAddr()); + funcStat(result.addr(), statGet.addr(), statSet.addr()); Memory.Free(statGet->fileList.GetAddr()); if (result->result < 0) { @@ -861,7 +861,7 @@ int cellSaveDataListAutoLoad(u32 version, u32 errDialog, mem_ptr_tdir.dirName); + s32 ret = modifySaveDataFiles(funcFile, result.addr(), saveBaseDir + (char*)statGet->dir.dirName); return CELL_SAVEDATA_RET_OK; } diff --git a/rpcs3/Emu/SysCalls/Modules/sys_fs.cpp b/rpcs3/Emu/SysCalls/Modules/sys_fs.cpp index c403278ba2..e6be52a0c8 100644 --- a/rpcs3/Emu/SysCalls/Modules/sys_fs.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sys_fs.cpp @@ -258,14 +258,14 @@ int cellFsReadWithOffset(u32 fd, u64 offset, u32 buf_addr, u64 buffer_size, mem6 fd, offset, buf_addr, buffer_size, nread.GetAddr()); int ret; - MemoryAllocator> oldPos, newPos; - ret = cellFsLseek(fd, 0, CELL_SEEK_CUR, oldPos.GetAddr()); // Save the current position + vm::var> oldPos, newPos; + ret = cellFsLseek(fd, 0, CELL_SEEK_CUR, oldPos.addr()); // Save the current position if (ret) return ret; - ret = cellFsLseek(fd, offset, CELL_SEEK_SET, newPos.GetAddr()); // Move to the specified offset + ret = cellFsLseek(fd, offset, CELL_SEEK_SET, newPos.addr()); // Move to the specified offset if (ret) return ret; ret = cellFsRead(fd, buf_addr, buffer_size, nread.GetAddr()); // Read the file if (ret) return ret; - ret = cellFsLseek(fd, Memory.Read64(oldPos.GetAddr()), CELL_SEEK_SET, newPos.GetAddr()); // Return to the old position + ret = cellFsLseek(fd, oldPos.value(), CELL_SEEK_SET, newPos.addr()); // Return to the old position if (ret) return ret; return CELL_OK; diff --git a/rpcs3/emucore.vcxproj b/rpcs3/emucore.vcxproj index b1ffe18464..0c2cb666b4 100644 --- a/rpcs3/emucore.vcxproj +++ b/rpcs3/emucore.vcxproj @@ -96,6 +96,7 @@ + @@ -328,6 +329,10 @@ + + + + @@ -546,7 +551,7 @@ - Level3 + Level2 Disabled false Use diff --git a/rpcs3/emucore.vcxproj.filters b/rpcs3/emucore.vcxproj.filters index b1500a5f15..c5041ec25d 100644 --- a/rpcs3/emucore.vcxproj.filters +++ b/rpcs3/emucore.vcxproj.filters @@ -620,6 +620,9 @@ Utilities + + Emu\Memory + @@ -1189,5 +1192,17 @@ Loader + + Emu\Memory + + + Emu\Memory + + + Emu\Memory + + + Emu\Memory + \ No newline at end of file