mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-01-30 21:32:50 +00:00
memory-wip branch merged
This commit is contained in:
commit
367b8e7129
@ -825,6 +825,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
template<typename T>
|
||||
class MemoryAllocator
|
||||
{
|
||||
@ -934,6 +935,7 @@ public:
|
||||
return (NT*)(m_ptr + offset);
|
||||
}
|
||||
};
|
||||
*/
|
||||
|
||||
typedef mem_t<u8, u32> mem8_t;
|
||||
typedef mem_t<u16, u32> mem16_t;
|
||||
@ -957,3 +959,5 @@ typedef mem_list_ptr_t<u16, u32> mem16_ptr_t;
|
||||
typedef mem_list_ptr_t<u32, u32> mem32_ptr_t;
|
||||
typedef mem_list_ptr_t<u64, u32> mem64_ptr_t;
|
||||
|
||||
#include "vm.h"
|
||||
|
||||
|
44
rpcs3/Emu/Memory/vm.cpp
Normal file
44
rpcs3/Emu/Memory/vm.cpp
Normal file
@ -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;
|
||||
}
|
||||
}
|
31
rpcs3/Emu/Memory/vm.h
Normal file
31
rpcs3/Emu/Memory/vm.h
Normal file
@ -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<typename T>
|
||||
T* get_ptr(u32 addr)
|
||||
{
|
||||
return (T*)&Memory[addr];
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
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"
|
386
rpcs3/Emu/Memory/vm_ptr.h
Normal file
386
rpcs3/Emu/Memory/vm_ptr.h
Normal file
@ -0,0 +1,386 @@
|
||||
#pragma once
|
||||
|
||||
namespace vm
|
||||
{
|
||||
template<typename T, int lvl = 1, typename AT = u32>
|
||||
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<T, lvl - 1, AT>& operator *()
|
||||
{
|
||||
return get_ref<ptr<T, lvl - 1, AT>>(m_addr);
|
||||
}
|
||||
|
||||
__forceinline const ptr<T, lvl - 1, AT>& operator *() const
|
||||
{
|
||||
return get_ref<const ptr<T, lvl - 1, AT>>(m_addr);
|
||||
}
|
||||
|
||||
__forceinline ptr<T, lvl - 1, AT>& operator [](int index)
|
||||
{
|
||||
return get_ref<ptr<T, lvl - 1, AT>>(m_addr + sizeof(AT) * index);
|
||||
}
|
||||
|
||||
__forceinline const ptr<T, lvl - 1, AT>& operator [](int index) const
|
||||
{
|
||||
return get_ref<const ptr<T, lvl - 1, AT>>(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<typename T, typename AT>
|
||||
class ptr<T, 1, AT>
|
||||
{
|
||||
AT m_addr;
|
||||
|
||||
public:
|
||||
__forceinline T* operator -> ()
|
||||
{
|
||||
return get_ptr<T>(m_addr);
|
||||
}
|
||||
|
||||
__forceinline const T* operator -> () const
|
||||
{
|
||||
return get_ptr<const T>(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<T>(m_addr);
|
||||
}
|
||||
|
||||
__forceinline const T& operator *() const
|
||||
{
|
||||
return get_ref<T>(m_addr);
|
||||
}
|
||||
|
||||
__forceinline T& operator [](int index)
|
||||
{
|
||||
return get_ref<T>(m_addr + sizeof(T) * index);
|
||||
}
|
||||
|
||||
__forceinline const T& operator [](int index) const
|
||||
{
|
||||
return get_ref<const T>(m_addr + sizeof(T) * index);
|
||||
}
|
||||
|
||||
/*
|
||||
operator ref<T>()
|
||||
{
|
||||
return { m_addr };
|
||||
}
|
||||
|
||||
operator const ref<T>() 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<T>(m_addr);
|
||||
}
|
||||
|
||||
bool check() const
|
||||
{
|
||||
return Memory.IsGoodAddr(m_addr, sizeof(T));
|
||||
}
|
||||
|
||||
static ptr make(u32 addr)
|
||||
{
|
||||
return (ptr&)addr;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename AT>
|
||||
class ptr<void, 1, AT>
|
||||
{
|
||||
AT m_addr;
|
||||
|
||||
public:
|
||||
AT addr() const
|
||||
{
|
||||
return m_addr;
|
||||
}
|
||||
|
||||
void* get_ptr() const
|
||||
{
|
||||
return vm::get_ptr<void>(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<typename RT, typename AT>
|
||||
class ptr<RT(*)(), 1, AT>
|
||||
{
|
||||
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<void*>(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<typename AT, typename RT, typename ...T>
|
||||
class ptr<RT(*)(T...), 1, AT>
|
||||
{
|
||||
AT m_addr;
|
||||
|
||||
__forceinline RT call_func(bool is_async, T... args) const
|
||||
{
|
||||
template<typename T>
|
||||
struct _func_arg
|
||||
{
|
||||
__forceinline static u64 get_value(const T& arg)
|
||||
{
|
||||
return arg;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T, typename AT>
|
||||
struct _func_arg<ptr<T, AT>>
|
||||
{
|
||||
__forceinline static u64 get_value(const ptr<T, AT> arg)
|
||||
{
|
||||
return arg.addr();
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T, typename AT>
|
||||
struct _func_arg<ref<T, AT>>
|
||||
{
|
||||
__forceinline static u64 get_value(const ref<T, AT> arg)
|
||||
{
|
||||
return arg.addr();
|
||||
}
|
||||
};
|
||||
|
||||
Callback cb;
|
||||
cb.SetAddr(m_addr);
|
||||
cb.Handle(_func_arg<T>::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<void*>(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<typename T, int lvl = 1, typename AT = u32>
|
||||
class beptr : public ptr<T, lvl, be_t<AT>> {};
|
||||
}
|
63
rpcs3/Emu/Memory/vm_ref.h
Normal file
63
rpcs3/Emu/Memory/vm_ref.h
Normal file
@ -0,0 +1,63 @@
|
||||
#pragma once
|
||||
|
||||
namespace vm
|
||||
{
|
||||
template<typename T, typename AT = u32>
|
||||
class _ref_base
|
||||
{
|
||||
AT m_addr;
|
||||
|
||||
public:
|
||||
operator T&()
|
||||
{
|
||||
return get_ref<T>(m_addr);
|
||||
}
|
||||
|
||||
operator const T&() const
|
||||
{
|
||||
return get_ref<const T>(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<typename T, typename AT = u32> class brefl : public _ref_base<T, be_t<AT>> {};
|
||||
|
||||
//BE reference to BE data
|
||||
template<typename T, typename AT = u32> class brefb : public _ref_base<be_t<T>, be_t<AT>> {};
|
||||
|
||||
//LE reference to BE data
|
||||
template<typename T, typename AT = u32> class lrefb : public _ref_base<be_t<T>, AT> {};
|
||||
|
||||
//LE reference to LE data
|
||||
template<typename T, typename AT = u32> class lrefl : public _ref_base<T, AT> {};
|
||||
|
||||
namespace ps3
|
||||
{
|
||||
//default reference for HLE functions (LE reference to BE data)
|
||||
template<typename T, typename AT = u32> class ref : public lrefb {};
|
||||
|
||||
//default reference for HLE structures (BE reference to BE data)
|
||||
template<typename T, typename AT = u32> class bref : public brefb {};
|
||||
}
|
||||
|
||||
namespace psv
|
||||
{
|
||||
//default reference for HLE functions & structures (LE reference to LE data)
|
||||
template<typename T, typename AT = u32> class ref : public lrefl {};
|
||||
}
|
||||
}
|
503
rpcs3/Emu/Memory/vm_var.h
Normal file
503
rpcs3/Emu/Memory/vm_var.h
Normal file
@ -0,0 +1,503 @@
|
||||
#pragma once
|
||||
|
||||
namespace vm
|
||||
{
|
||||
template<typename T>
|
||||
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<T>(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<T>(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<T>() const
|
||||
{
|
||||
return addr();
|
||||
}
|
||||
*/
|
||||
|
||||
operator T&()
|
||||
{
|
||||
return *m_ptr;
|
||||
}
|
||||
|
||||
operator const T&() const
|
||||
{
|
||||
return *m_ptr;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class var<T[]>
|
||||
{
|
||||
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<T>(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<T>(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<typename T1>
|
||||
operator const T1() const
|
||||
{
|
||||
return T1(*m_ptr);
|
||||
}
|
||||
|
||||
template<typename T1>
|
||||
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<T>() const
|
||||
{
|
||||
return addr();
|
||||
}
|
||||
*/
|
||||
template<typename NT>
|
||||
NT* To(uint offset = 0)
|
||||
{
|
||||
return (NT*)(m_ptr + offset);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T, int _count>
|
||||
class var<T[_count]>
|
||||
{
|
||||
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<T>(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<typename T1>
|
||||
operator const T1() const
|
||||
{
|
||||
return T1(*m_ptr);
|
||||
}
|
||||
|
||||
template<typename T1>
|
||||
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<T>() const
|
||||
{
|
||||
return addr();
|
||||
}
|
||||
*/
|
||||
template<typename NT>
|
||||
NT* To(uint offset = 0)
|
||||
{
|
||||
return (NT*)(m_ptr + offset);
|
||||
}
|
||||
};
|
||||
}
|
@ -44,8 +44,9 @@ int cellFontInit(mem_ptr_t<CellFontConfig> config)
|
||||
{
|
||||
cellFont->Log("cellFontInit(config=0x%x)", config.GetAddr());
|
||||
|
||||
MemoryAllocator<u64> revisionFlags = 0;
|
||||
cellFontGetRevisionFlags(revisionFlags.GetAddr());
|
||||
vm::var<u64> revisionFlags;
|
||||
revisionFlags.value() = 0;
|
||||
cellFontGetRevisionFlags(revisionFlags.addr());
|
||||
return cellFontInitializeWithRevision(revisionFlags, config.GetAddr());
|
||||
}
|
||||
|
||||
|
@ -236,11 +236,11 @@ int cellGameDataCheckCreate2(u32 version, const mem_list_ptr_t<u8> dirName, u32
|
||||
}
|
||||
|
||||
// TODO: use memory container
|
||||
MemoryAllocator<CellGameDataCBResult> cbResult;
|
||||
MemoryAllocator<CellGameDataStatGet> cbGet;
|
||||
MemoryAllocator<CellGameDataStatSet> cbSet;
|
||||
vm::var<CellGameDataCBResult> cbResult;
|
||||
vm::var<CellGameDataStatGet> cbGet;
|
||||
vm::var<CellGameDataStatSet> 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<u8> 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())
|
||||
{
|
||||
|
@ -40,14 +40,14 @@ int cellGifDecOpen(u32 mainHandle, mem32_t subHandle, const mem_ptr_t<CellGifDec
|
||||
|
||||
case se32(CELL_GIFDEC_FILE):
|
||||
// Get file descriptor
|
||||
MemoryAllocator<be_t<u32>> fd;
|
||||
int ret = cellFsOpen(src->fileName, 0, fd.GetAddr(), 0, 0);
|
||||
vm::var<be_t<u32>> 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<CellFsStat> sb; // Alloc a CellFsStat struct
|
||||
ret = cellFsFstat(current_subHandle->fd, sb.GetAddr());
|
||||
vm::var<CellFsStat> 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_t<CellGifDecInfo
|
||||
CellGifDecInfo& current_info = subHandle_data->info;
|
||||
|
||||
//Write the header to buffer
|
||||
MemoryAllocator<u8> buffer(13); // Alloc buffer for GIF header
|
||||
MemoryAllocator<be_t<u64>> pos, nread;
|
||||
vm::var<u8[13]> buffer; // Alloc buffer for GIF header
|
||||
vm::var<be_t<u64>> 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<unsigned char> gif((u32)fileSize);
|
||||
MemoryAllocator<u64> pos, nread;
|
||||
vm::var<unsigned char[]> gif((u32)fileSize);
|
||||
vm::var<u64> 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<unsigned char,decltype(&::free)>
|
||||
(
|
||||
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
|
||||
);
|
||||
|
||||
|
@ -46,14 +46,14 @@ int cellJpgDecOpen(u32 mainHandle, mem32_t subHandle, mem_ptr_t<CellJpgDecSrc> s
|
||||
|
||||
case se32(CELL_JPGDEC_FILE):
|
||||
// Get file descriptor
|
||||
MemoryAllocator<be_t<u32>> fd;
|
||||
int ret = cellFsOpen(src->fileName, 0, fd.GetAddr(), 0, 0);
|
||||
vm::var<be_t<u32>> 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<CellFsStat> sb; // Alloc a CellFsStat struct
|
||||
ret = cellFsFstat(current_subHandle->fd, sb.GetAddr());
|
||||
vm::var<CellFsStat> 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_t<CellJpgDecInfo
|
||||
CellJpgDecInfo& current_info = subHandle_data->info;
|
||||
|
||||
//Write the header to buffer
|
||||
MemoryAllocator<u8> buffer((u32)fileSize);
|
||||
MemoryAllocator<be_t<u64>> pos, nread;
|
||||
vm::var<u8[]> buffer((u32)fileSize);
|
||||
vm::var<be_t<u64>> 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<unsigned char> jpg((u32)fileSize);
|
||||
MemoryAllocator<u64> pos, nread;
|
||||
vm::var<unsigned char[]> jpg((u32)fileSize);
|
||||
vm::var<u64> 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<unsigned char,decltype(&::free)>
|
||||
(
|
||||
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
|
||||
);
|
||||
|
||||
|
@ -15,7 +15,7 @@ static std::map<u32, CellPngDecMainHandle *> 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<CellPngDecSrc> s
|
||||
|
||||
case se32(CELL_PNGDEC_FILE):
|
||||
// Get file descriptor
|
||||
MemoryAllocator<be_t<u32>> fd;
|
||||
int ret = cellFsOpen(src->fileName_addr, 0, fd.GetAddr(), 0, 0);
|
||||
vm::var<be_t<u32>> 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<CellFsStat> sb; // Alloc a CellFsStat struct
|
||||
ret = cellFsFstat(current_subHandle->fd, sb.GetAddr());
|
||||
vm::var<CellFsStat> 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_t<CellPngDecSrc
|
||||
|
||||
cellPngDec->Warning("*** cbCtrlStrm->cbCtrlStrmFunc_addr=0x%x", cbCtrlStrm->cbCtrlStrmFunc.GetAddr());
|
||||
|
||||
MemoryAllocator<CellPngDecStrmInfo> streamInfo;
|
||||
MemoryAllocator<CellPngDecStrmParam> streamParam;
|
||||
vm::var<CellPngDecStrmInfo> streamInfo;
|
||||
vm::var<CellPngDecStrmParam> 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<CellPngDecInfo
|
||||
if(fileSize < 29) return CELL_PNGDEC_ERROR_HEADER; // Error: The file is smaller than the length of a PNG header
|
||||
|
||||
//Write the header to buffer
|
||||
MemoryAllocator<be_t<u32>> buffer(34); // Alloc buffer for PNG header
|
||||
MemoryAllocator<be_t<u64>> pos, nread;
|
||||
vm::var<u8[34]> buffer; // Alloc buffer for PNG header
|
||||
auto buffer_32 = buffer.To<be_t<u32>>();
|
||||
vm::var<be_t<u64>> 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<u8>()[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<CellPngDecInfo
|
||||
default: return CELL_PNGDEC_ERROR_HEADER; // Not supported color type
|
||||
}
|
||||
|
||||
current_info.imageWidth = buffer[4];
|
||||
current_info.imageHeight = buffer[5];
|
||||
current_info.bitDepth = buffer.To<u8>()[24];
|
||||
current_info.interlaceMethod = buffer.To<u8>()[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<unsigned char> png((u32)fileSize);
|
||||
MemoryAllocator<u64> pos, nread;
|
||||
vm::var<unsigned char[]> png((u32)fileSize);
|
||||
vm::var<u64> 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<unsigned char,decltype(&::free)>
|
||||
(
|
||||
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;
|
||||
|
@ -726,13 +726,13 @@ int cellRescSetDisplayMode(u32 displayMode)
|
||||
else m_pCFragmentShader = m_pCFragmentShaderArray[RESC_SHADER_DEFAULT_BILINEAR];
|
||||
}*/
|
||||
|
||||
MemoryAllocator<CellVideoOutConfiguration> videocfg;
|
||||
vm::var<CellVideoOutConfiguration> 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<be_t<u32>> dstOffset;
|
||||
cellGcmAddressToOffset(s_rescInternalInstance->m_colorBuffersEA, dstOffset.GetAddr());
|
||||
vm::var<be_t<u32>> dstOffset;
|
||||
cellGcmAddressToOffset(s_rescInternalInstance->m_colorBuffersEA, dstOffset.addr());
|
||||
|
||||
for (int i=0; i<GetNumColorBuffers(); i++)
|
||||
{
|
||||
|
@ -681,10 +681,10 @@ int cellHddGameCheck(u32 version, u32 dirName_addr, u32 errDialog, mem_func_ptr_
|
||||
if (dirName.size() != 9)
|
||||
return CELL_HDDGAME_ERROR_PARAM;
|
||||
|
||||
MemoryAllocator<CellHddGameSystemFileParam> param;
|
||||
MemoryAllocator<CellHddGameCBResult> result;
|
||||
MemoryAllocator<CellHddGameStatGet> get;
|
||||
MemoryAllocator<CellHddGameStatSet> set;
|
||||
vm::var<CellHddGameSystemFileParam> param;
|
||||
vm::var<CellHddGameCBResult> result;
|
||||
vm::var<CellHddGameStatGet> get;
|
||||
vm::var<CellHddGameStatSet> 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;
|
||||
|
@ -216,8 +216,8 @@ void getSaveDataStat(SaveDataEntry entry, mem_ptr_t<CellSaveDataStatGet> statGet
|
||||
|
||||
s32 modifySaveDataFiles(mem_func_ptr_t<CellSaveDataFileCallback>& funcFile, mem_ptr_t<CellSaveDataCBResult> result, const std::string& saveDataDir)
|
||||
{
|
||||
MemoryAllocator<CellSaveDataFileGet> fileGet;
|
||||
MemoryAllocator<CellSaveDataFileSet> fileSet;
|
||||
vm::var<CellSaveDataFileGet> fileGet;
|
||||
vm::var<CellSaveDataFileSet> fileSet;
|
||||
|
||||
if (!Emu.GetVFS().ExistsDir(saveDataDir))
|
||||
Emu.GetVFS().CreateDir(saveDataDir);
|
||||
@ -225,7 +225,7 @@ s32 modifySaveDataFiles(mem_func_ptr_t<CellSaveDataFileCallback>& 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<CellSaveDataSetList> 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<CellSaveDataCBResult> result;
|
||||
MemoryAllocator<CellSaveDataListGet> listGet;
|
||||
MemoryAllocator<CellSaveDataListSet> listSet;
|
||||
MemoryAllocator<CellSaveDataStatGet> statGet;
|
||||
MemoryAllocator<CellSaveDataStatSet> statSet;
|
||||
vm::var<CellSaveDataCBResult> result;
|
||||
vm::var<CellSaveDataListGet> listGet;
|
||||
vm::var<CellSaveDataListSet> listSet;
|
||||
vm::var<CellSaveDataStatGet> statGet;
|
||||
vm::var<CellSaveDataStatSet> 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<CellSaveDataSetList> 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<CellSaveDataSetList> 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<CellSaveDataSetList> 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<CellSaveDataSetList> 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<CellSaveDataCBResult> result;
|
||||
MemoryAllocator<CellSaveDataListGet> listGet;
|
||||
MemoryAllocator<CellSaveDataListSet> listSet;
|
||||
MemoryAllocator<CellSaveDataStatGet> statGet;
|
||||
MemoryAllocator<CellSaveDataStatSet> statSet;
|
||||
|
||||
vm::var<CellSaveDataCBResult> result;
|
||||
vm::var<CellSaveDataListGet> listGet;
|
||||
vm::var<CellSaveDataListSet> listSet;
|
||||
vm::var<CellSaveDataStatGet> statGet;
|
||||
vm::var<CellSaveDataStatSet> 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<CellSaveDataSetList> 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<CellSaveDataSetList> 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<CellSaveDataSetList> 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<CellSaveDataSetList> 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<CellSaveDataCBResult> result;
|
||||
MemoryAllocator<CellSaveDataListGet> listGet;
|
||||
MemoryAllocator<CellSaveDataFixedSet> fixedSet;
|
||||
MemoryAllocator<CellSaveDataStatGet> statGet;
|
||||
MemoryAllocator<CellSaveDataStatSet> statSet;
|
||||
vm::var<CellSaveDataCBResult> result;
|
||||
vm::var<CellSaveDataListGet> listGet;
|
||||
vm::var<CellSaveDataFixedSet> fixedSet;
|
||||
vm::var<CellSaveDataStatGet> statGet;
|
||||
vm::var<CellSaveDataStatSet> 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<CellSaveDataSetList> 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<CellSaveDataSetList> 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<CellSaveDataSetList> 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<CellSaveDataCBResult> result;
|
||||
MemoryAllocator<CellSaveDataListGet> listGet;
|
||||
MemoryAllocator<CellSaveDataFixedSet> fixedSet;
|
||||
MemoryAllocator<CellSaveDataStatGet> statGet;
|
||||
MemoryAllocator<CellSaveDataStatSet> statSet;
|
||||
vm::var<CellSaveDataCBResult> result;
|
||||
vm::var<CellSaveDataListGet> listGet;
|
||||
vm::var<CellSaveDataFixedSet> fixedSet;
|
||||
vm::var<CellSaveDataStatGet> statGet;
|
||||
vm::var<CellSaveDataStatSet> 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<CellSaveDataSetList> 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<CellSaveDataSetList> 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<CellSaveDataCBResult> result;
|
||||
MemoryAllocator<CellSaveDataStatGet> statGet;
|
||||
MemoryAllocator<CellSaveDataStatSet> statSet;
|
||||
vm::var<CellSaveDataCBResult> result;
|
||||
vm::var<CellSaveDataStatGet> statGet;
|
||||
vm::var<CellSaveDataStatSet> 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<CellSaveDataCBResult> result;
|
||||
MemoryAllocator<CellSaveDataStatGet> statGet;
|
||||
MemoryAllocator<CellSaveDataStatSet> statSet;
|
||||
vm::var<CellSaveDataCBResult> result;
|
||||
vm::var<CellSaveDataStatGet> statGet;
|
||||
vm::var<CellSaveDataStatSet> 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_t<CellSaveDataS
|
||||
cellSysutil->Warning("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<CellSaveDataCBResult> result;
|
||||
MemoryAllocator<CellSaveDataListGet> listGet;
|
||||
MemoryAllocator<CellSaveDataListSet> listSet;
|
||||
MemoryAllocator<CellSaveDataStatGet> statGet;
|
||||
MemoryAllocator<CellSaveDataStatSet> statSet;
|
||||
vm::var<CellSaveDataCBResult> result;
|
||||
vm::var<CellSaveDataListGet> listGet;
|
||||
vm::var<CellSaveDataListSet> listSet;
|
||||
vm::var<CellSaveDataStatGet> statGet;
|
||||
vm::var<CellSaveDataStatSet> 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_t<CellSaveDataS
|
||||
memcpy(dirList[i].listParam, saveEntries[i].listParam.c_str(), CELL_SAVEDATA_SYSP_LPARAM_SIZE);
|
||||
}
|
||||
|
||||
funcFixed(result.GetAddr(), listGet.GetAddr(), listSet.GetAddr());
|
||||
funcFixed(result.addr(), listGet.addr(), listSet.addr());
|
||||
|
||||
if (result->result < 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_t<CellSaveDataS
|
||||
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("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_t<CellSaveDataS
|
||||
*/
|
||||
|
||||
// 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;
|
||||
}
|
||||
@ -787,11 +787,11 @@ int cellSaveDataListAutoLoad(u32 version, u32 errDialog, mem_ptr_t<CellSaveDataS
|
||||
cellSysutil->Warning("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<CellSaveDataCBResult> result;
|
||||
MemoryAllocator<CellSaveDataListGet> listGet;
|
||||
MemoryAllocator<CellSaveDataListSet> listSet;
|
||||
MemoryAllocator<CellSaveDataStatGet> statGet;
|
||||
MemoryAllocator<CellSaveDataStatSet> statSet;
|
||||
vm::var<CellSaveDataCBResult> result;
|
||||
vm::var<CellSaveDataListGet> listGet;
|
||||
vm::var<CellSaveDataListSet> listSet;
|
||||
vm::var<CellSaveDataStatGet> statGet;
|
||||
vm::var<CellSaveDataStatSet> 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_t<CellSaveDataS
|
||||
memcpy(dirList[i].listParam, saveEntries[i].listParam.c_str(), CELL_SAVEDATA_SYSP_LPARAM_SIZE);
|
||||
}
|
||||
|
||||
funcFixed(result.GetAddr(), listGet.GetAddr(), listSet.GetAddr());
|
||||
funcFixed(result.addr(), listGet.addr(), listSet.addr());
|
||||
|
||||
if (result->result < 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_t<CellSaveDataS
|
||||
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) {
|
||||
@ -861,7 +861,7 @@ int cellSaveDataListAutoLoad(u32 version, u32 errDialog, mem_ptr_t<CellSaveDataS
|
||||
*/
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
@ -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<be_t<u64>> oldPos, newPos;
|
||||
ret = cellFsLseek(fd, 0, CELL_SEEK_CUR, oldPos.GetAddr()); // Save the current position
|
||||
vm::var<be_t<u64>> 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;
|
||||
|
@ -96,6 +96,7 @@
|
||||
<ClCompile Include="Emu\RSX\GSRender.cpp" />
|
||||
<ClCompile Include="Emu\RSX\RSXTexture.cpp" />
|
||||
<ClCompile Include="Emu\RSX\RSXThread.cpp" />
|
||||
<ClCompile Include="Emu\Memory\vm.cpp" />
|
||||
<ClCompile Include="Emu\SysCalls\Callback.cpp" />
|
||||
<ClCompile Include="Emu\SysCalls\FuncList.cpp" />
|
||||
<ClCompile Include="Emu\SysCalls\LogBase.cpp" />
|
||||
@ -328,6 +329,10 @@
|
||||
<ClInclude Include="Emu\RSX\RSXThread.h" />
|
||||
<ClInclude Include="Emu\RSX\RSXVertexProgram.h" />
|
||||
<ClInclude Include="Emu\RSX\sysutil_video.h" />
|
||||
<ClInclude Include="Emu\Memory\vm.h" />
|
||||
<ClInclude Include="Emu\Memory\vm_ptr.h" />
|
||||
<ClInclude Include="Emu\Memory\vm_ref.h" />
|
||||
<ClInclude Include="Emu\Memory\vm_var.h" />
|
||||
<ClInclude Include="Emu\SysCalls\Callback.h" />
|
||||
<ClInclude Include="Emu\SysCalls\ErrorCodes.h" />
|
||||
<ClInclude Include="Emu\SysCalls\LogBase.h" />
|
||||
@ -546,7 +551,7 @@
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug - MemLeak|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<WarningLevel>Level2</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>false</SDLCheck>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
|
@ -620,6 +620,9 @@
|
||||
<ClCompile Include="..\Utilities\rXml.cpp">
|
||||
<Filter>Utilities</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Emu\Memory\vm.cpp">
|
||||
<Filter>Emu\Memory</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Crypto\aes.h">
|
||||
@ -1189,5 +1192,17 @@
|
||||
<ClInclude Include="Loader\TRP.h">
|
||||
<Filter>Loader</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Emu\Memory\vm.h">
|
||||
<Filter>Emu\Memory</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Emu\Memory\vm_ptr.h">
|
||||
<Filter>Emu\Memory</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Emu\Memory\vm_ref.h">
|
||||
<Filter>Emu\Memory</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Emu\Memory\vm_var.h">
|
||||
<Filter>Emu\Memory</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
Loading…
x
Reference in New Issue
Block a user