Merge pull request #785 from Nekotekina/master

vm:: global replacement
This commit is contained in:
B1ackDaemon 2014-09-02 16:03:07 +03:00
commit 505dacf152
150 changed files with 3749 additions and 3206 deletions

1
.gitignore vendored
View file

@ -69,3 +69,4 @@ x64/Release/emucore.lib
rpcs3/x64/*
.DS_Store
rpcs3/Emu/SysCalls/Modules/prx_*.h

View file

@ -47,10 +47,10 @@ template<typename T, s64 _value> struct const_se_t<T, _value, 8>
((_value << 56) & 0xff00000000000000);
};
template<typename T, int size=sizeof(T)>
template<typename T, typename T2 = T>
class be_t
{
static_assert(size == 1 || size == 2 || size == 4 || size == 8, "Bad be_t type");
static_assert(sizeof(T2) == 1 || sizeof(T2) == 2 || sizeof(T2) == 4 || sizeof(T2) == 8, "Bad be_t type");
T m_data;
public:
@ -65,7 +65,7 @@ public:
{
T res;
se_t<T>::func(res, m_data);
se_t<T, sizeof(T2)>::func(res, m_data);
return res;
}
@ -77,7 +77,7 @@ public:
void FromLE(const T& value)
{
se_t<T>::func(m_data, value);
se_t<T, sizeof(T2)>::func(m_data, value);
}
static be_t MakeFromLE(const T value)
@ -125,7 +125,7 @@ public:
return *this;
}
be_t<T,size>& operator = (const be_t<T,size>& right) = default;
be_t& operator = (const be_t& right) = default;
template<typename T1> be_t& operator += (T1 right) { return *this = T(*this) + right; }
template<typename T1> be_t& operator -= (T1 right) { return *this = T(*this) - right; }
@ -171,6 +171,69 @@ public:
be_t& operator-- () { *this -= 1; return *this; }
};
template<typename T, typename T2 = T>
struct is_be_t : public std::integral_constant<bool, false> {};
template<typename T, typename T2>
struct is_be_t<be_t<T, T2>, T2> : public std::integral_constant<bool, true> {};
template<typename T, typename T2 = T>
struct remove_be_t
{
typedef T type;
};
template<typename T, typename T2>
struct remove_be_t<be_t<T, T2>>
{
typedef T type;
};
template<typename T, typename T2 = T>
class to_be_t
{
template<typename TT, typename TT2, bool is_need_swap>
struct _be_type_selector
{
typedef TT type;
};
template<typename TT, typename TT2>
struct _be_type_selector<TT, TT2, true>
{
typedef be_t<TT, TT2> type;
};
public:
//true if need swap endianes for be
static const bool value = (sizeof(T2) > 1) && std::is_arithmetic<T>::value;
//be_t<T, size> if need swap endianes, T otherwise
typedef typename _be_type_selector< T, T2, value >::type type;
};
template<typename T>
class to_be_t<T, void>
{
public:
//true if need swap endianes for be
static const bool value = false;
//be_t<T, size> if need swap endianes, T otherwise
typedef void type;
};
template<typename T>
class to_be_t<T, const void>
{
public:
//true if need swap endianes for be
static const bool value = false;
//be_t<T, size> if need swap endianes, T otherwise
typedef const void type;
};
template<typename T, typename T1, T1 value> struct _se : public const_se_t<T, value> {};
template<typename T, typename T1, T1 value> struct _se<be_t<T>, T1, value> : public const_se_t<T, value> {};

View file

@ -14,7 +14,7 @@ LogManager *gLogManager = nullptr;
u32 LogMessage::size()
{
//1 byte for NULL terminator
return sizeof(LogMessage::size_type) + sizeof(LogType) + sizeof(LogSeverity) + sizeof(std::string::value_type)*mText.size() + 1;
return (u32)(sizeof(LogMessage::size_type) + sizeof(LogType) + sizeof(LogSeverity) + sizeof(std::string::value_type) * mText.size() + 1);
}
void LogMessage::serialize(char *output)

View file

@ -2,13 +2,6 @@
static std::thread::id main_thread;
struct rThread
{
static bool IsMain() { std::this_thread::get_id() == main_thread; }
};
class ThreadExec;
class NamedThreadBase
{
std::string m_name;

2
asmjit

@ -1 +1 @@
Subproject commit 3363e4138b003be36dfb63cf8c63cf360f04276f
Subproject commit d7fc62d9e905859579f5965eee6f7f99b65c2246

View file

@ -21,8 +21,8 @@ public:
virtual u8 DecodeMemory(const u64 address)
{
using namespace ARMv7_opcodes;
const u16 code0 = Memory.PSV.Read16(address);
const u16 code1 = Memory.PSV.Read16(address + 2);
const u16 code0 = Memory.PSV.Read16((u32)address);
const u16 code1 = Memory.PSV.Read16((u32)address + 2);
switch(code0 >> 12) //15 - 12
{

View file

@ -22,7 +22,7 @@ public:
protected:
virtual u32 DisAsmBranchTarget(const s32 imm)
{
return dump_pc + imm;
return (u32)dump_pc + imm;
}
std::string GetRegsListString(u16 regs_list)

View file

@ -310,7 +310,7 @@ protected:
void BL(u32 imm, u8 intstr_size)
{
CPU.LR = (CPU.PC + intstr_size) | 1;
CPU.LR = ((u32)CPU.PC + intstr_size) | 1;
CPU.SetBranch(CPU.PC + intstr_size + imm);
}

View file

@ -18,7 +18,7 @@ void ARMv7Thread::InitRegs()
memset(GPR, 0, sizeof(GPR[0]) * 15);
APSR.APSR = 0;
IPSR.IPSR = 0;
SP = m_stack_point;
SP = (u32)m_stack_point;
}
void ARMv7Thread::InitStack()

View file

@ -51,7 +51,7 @@ public:
u32 IPSR;
} IPSR;
void write_gpr(u8 n, u32 value)
void write_gpr(u32 n, u32 value)
{
assert(n < 16);
@ -65,7 +65,7 @@ public:
}
}
u32 read_gpr(u8 n)
u32 read_gpr(u32 n)
{
assert(n < 16);
@ -74,7 +74,7 @@ public:
return GPR[n];
}
return PC;
return (u32)PC;
}
public:

View file

@ -34,8 +34,8 @@ size_t AudioDumper::WriteData(const void* buffer, size_t size)
if (!do_save) return size; // ignore empty data
#endif
size_t ret = m_output.Write(buffer, size);
m_header.Size += ret;
m_header.RIFF.Size += ret;
m_header.Size += (u32)ret;
m_header.RIFF.Size += (u32)ret;
return ret;
}

View file

@ -67,5 +67,5 @@ public:
void WriteHeader();
size_t WriteData(const void* buffer, size_t size);
void Finalize();
const u8 GetCh() const { return m_header.FMT.NumChannels; }
const u8 GetCh() const { return (u8)m_header.FMT.NumChannels; }
};

View file

@ -287,7 +287,7 @@ void _se_translator(unsigned int u, EXCEPTION_POINTERS* pExp)
{
// TODO: allow recovering from a page fault
throw fmt::Format("Access violation: addr = 0x%x (last_syscall=0x%llx (%s))",
(u32)addr, (u64)GetCurrentCPUThread()->m_last_syscall, SysCalls::GetHLEFuncName((u64)GetCurrentCPUThread()->m_last_syscall).c_str());
(u32)addr, (u64)GetCurrentCPUThread()->m_last_syscall, SysCalls::GetHLEFuncName((u32)GetCurrentCPUThread()->m_last_syscall).c_str());
}
else
{

View file

@ -37,7 +37,7 @@ protected:
bool m_is_step;
u64 m_stack_addr;
u64 m_stack_size;
u32 m_stack_size;
u64 m_stack_point;
u64 m_exit_status;
@ -51,11 +51,11 @@ public:
virtual void CloseStack();
u64 GetStackAddr() const { return m_stack_addr; }
u64 GetStackSize() const { return m_stack_size; }
u32 GetStackSize() const { return m_stack_size; }
virtual u64 GetFreeStackSize() const=0;
void SetStackAddr(u64 stack_addr) { m_stack_addr = stack_addr; }
void SetStackSize(u64 stack_size) { m_stack_size = stack_size; }
void SetStackSize(u32 stack_size) { m_stack_size = stack_size; }
virtual void SetArg(const uint pos, const u64 arg) = 0;

View file

@ -68,12 +68,12 @@ private:
const u64 old_sc = CPU.m_last_syscall;
CPU.m_last_syscall = sc;
SysCalls::DoSyscall(sc);
SysCalls::DoSyscall((u32)sc);
if(Ini.HLELogging.GetValue())
{
LOG_WARNING(PPU, "SysCall[0x%llx ('%s')] done with code [0x%llx]! #pc: 0x%llx",
sc, SysCalls::GetHLEFuncName(sc).c_str(), CPU.GPR[3], CPU.PC);
sc, SysCalls::GetHLEFuncName((u32)sc).c_str(), CPU.GPR[3], CPU.PC);
}
#ifdef HLE_CALL_DEBUG
LOG_NOTICE(PPU, "SysCall[%lld] done with code [0x%llx]! #pc: 0x%llx", sc, CPU.GPR[3], CPU.PC);
@ -155,7 +155,7 @@ private:
void TWI(u32 to, u32 ra, s32 simm16)
{
s32 a = CPU.GPR[ra];
s32 a = (s32)CPU.GPR[ra];
if( (a < simm16 && (to & 0x10)) ||
(a > simm16 && (to & 0x8)) ||
@ -208,7 +208,7 @@ private:
CPU.VSCR.SAT = 1;
}
else
CPU.VPR[vd]._s8[b] = result;
CPU.VPR[vd]._s8[b] = (s8)result;
}
}
void VADDSHS(u32 vd, u32 va, u32 vb)
@ -248,7 +248,7 @@ private:
CPU.VSCR.SAT = 1;
}
else
CPU.VPR[vd]._s32[w] = result;
CPU.VPR[vd]._s32[w] = (s32)result;
}
}
void VADDUBM(u32 vd, u32 va, u32 vb)
@ -270,7 +270,7 @@ private:
CPU.VSCR.SAT = 1;
}
else
CPU.VPR[vd]._u8[b] = result;
CPU.VPR[vd]._u8[b] = (u8)result;
}
}
void VADDUHM(u32 vd, u32 va, u32 vb)
@ -314,7 +314,7 @@ private:
CPU.VSCR.SAT = 1;
}
else
CPU.VPR[vd]._u32[w] = result;
CPU.VPR[vd]._u32[w] = (u32)result;
}
}
void VAND(u32 vd, u32 va, u32 vb)
@ -1256,7 +1256,7 @@ private:
CPU.VSCR.SAT = 1;
}
CPU.VPR[vd]._s8[b+8] = result;
CPU.VPR[vd]._s8[b+8] = (s8)result;
result = CPU.VPR[vb]._s16[b];
@ -1271,7 +1271,7 @@ private:
CPU.VSCR.SAT = 1;
}
CPU.VPR[vd]._s8[b] = result;
CPU.VPR[vd]._s8[b] = (s8)result;
}
}
void VPKSHUS(u32 vd, u32 va, u32 vb)
@ -1291,7 +1291,7 @@ private:
CPU.VSCR.SAT = 1;
}
CPU.VPR[vd]._u8[b+8] = result;
CPU.VPR[vd]._u8[b+8] = (u8)result;
result = CPU.VPR[vb]._s16[b];
@ -1306,7 +1306,7 @@ private:
CPU.VSCR.SAT = 1;
}
CPU.VPR[vd]._u8[b] = result;
CPU.VPR[vd]._u8[b] = (u8)result;
}
}
void VPKSWSS(u32 vd, u32 va, u32 vb)
@ -1399,7 +1399,7 @@ private:
CPU.VSCR.SAT = 1;
}
CPU.VPR[vd]._u8[b+8] = result;
CPU.VPR[vd]._u8[b+8] = (u8)result;
result = CPU.VPR[vb]._u16[b];
@ -1409,7 +1409,7 @@ private:
CPU.VSCR.SAT = 1;
}
CPU.VPR[vd]._u8[b] = result;
CPU.VPR[vd]._u8[b] = (u8)result;
}
}
void VPKUWUM(u32 vd, u32 va, u32 vb)
@ -1502,7 +1502,7 @@ private:
{
for (uint w = 0; w < 4; w++)
{
CPU.VPR[vd]._u32[w] = rotl32(CPU.VPR[va]._u32[w], CPU.VPR[vb]._u8[w*4] & 0x1f);
CPU.VPR[vd]._u32[w] = (u32)rotl32(CPU.VPR[va]._u32[w], CPU.VPR[vb]._u8[w*4] & 0x1f);
}
}
void VRSQRTEFP(u32 vd, u32 vb)
@ -2093,7 +2093,7 @@ private:
case 0x1: UNK(fmt::Format("HyperCall %d", CPU.GPR[0])); break;
case 0x2: SysCall(); break;
case 0x3:
Emu.GetSFuncManager().StaticExecute(CPU.GPR[11]);
Emu.GetSFuncManager().StaticExecute((u32)CPU.GPR[11]);
if (Ini.HLELogging.GetValue())
{
LOG_NOTICE(PPU, "'%s' done with code[0x%llx]! #pc: 0x%llx",
@ -2244,11 +2244,11 @@ private:
{
if (is_r) // rldcr
{
RLDICR(ra, rs, CPU.GPR[rb], m_eb, rc);
RLDICR(ra, rs, (u32)CPU.GPR[rb], m_eb, rc);
}
else // rldcl
{
RLDICL(ra, rs, CPU.GPR[rb], m_eb, rc);
RLDICL(ra, rs, (u32)CPU.GPR[rb], m_eb, rc);
}
}
void CMP(u32 crfd, u32 l, u32 ra, u32 rb)
@ -2257,8 +2257,8 @@ private:
}
void TW(u32 to, u32 ra, u32 rb)
{
s32 a = CPU.GPR[ra];
s32 b = CPU.GPR[rb];
s32 a = (s32)CPU.GPR[ra];
s32 b = (s32)CPU.GPR[rb];
if( (a < b && (to & 0x10)) ||
(a > b && (to & 0x8)) ||
@ -2328,8 +2328,8 @@ private:
}
void MULHWU(u32 rd, u32 ra, u32 rb, bool rc)
{
u32 a = CPU.GPR[ra];
u32 b = CPU.GPR[rb];
u32 a = (u32)CPU.GPR[ra];
u32 b = (u32)CPU.GPR[rb];
CPU.GPR[rd] = ((u64)a * (u64)b) >> 32;
if(rc) CPU.UpdateCR0<s64>(CPU.GPR[rd]);
}
@ -2380,8 +2380,8 @@ private:
void SLW(u32 ra, u32 rs, u32 rb, bool rc)
{
u32 n = CPU.GPR[rb] & 0x1f;
u32 r = rotl32((u32)CPU.GPR[rs], n);
u32 m = (CPU.GPR[rb] & 0x20) ? 0 : rotate_mask[32][63 - n];
u32 r = (u32)rotl32((u32)CPU.GPR[rs], n);
u32 m = ((u32)CPU.GPR[rb] & 0x20) ? 0 : (u32)rotate_mask[32][63 - n];
CPU.GPR[ra] = r & m;
@ -2509,8 +2509,8 @@ private:
}
void MULHW(u32 rd, u32 ra, u32 rb, bool rc)
{
s32 a = CPU.GPR[ra];
s32 b = CPU.GPR[rb];
s32 a = (s32)CPU.GPR[ra];
s32 b = (s32)CPU.GPR[rb];
CPU.GPR[rd] = ((s64)a * (s64)b) >> 32;
if(rc) CPU.UpdateCR0<s64>(CPU.GPR[rd]);
}
@ -2644,7 +2644,7 @@ private:
}
void STWX(u32 rs, u32 ra, u32 rb)
{
Memory.Write32((ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb]), CPU.GPR[rs]);
Memory.Write32(ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb], (u32)CPU.GPR[rs]);
}
void STVEHX(u32 vs, u32 ra, u32 rb)
{
@ -2661,7 +2661,7 @@ private:
void STWUX(u32 rs, u32 ra, u32 rb)
{
const u64 addr = CPU.GPR[ra] + CPU.GPR[rb];
Memory.Write32(addr, CPU.GPR[rs]);
Memory.Write32(addr, (u32)CPU.GPR[rs]);
CPU.GPR[ra] = addr;
}
void STVEWX(u32 vs, u32 ra, u32 rb)
@ -2701,7 +2701,7 @@ private:
}
void STBX(u32 rs, u32 ra, u32 rb)
{
Memory.Write8((ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb]), CPU.GPR[rs]);
Memory.Write8((ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb]), (u8)CPU.GPR[rs]);
}
void STVX(u32 vs, u32 ra, u32 rb)
{
@ -2744,7 +2744,7 @@ private:
void STBUX(u32 rs, u32 ra, u32 rb)
{
const u64 addr = CPU.GPR[ra] + CPU.GPR[rb];
Memory.Write8(addr, CPU.GPR[rs]);
Memory.Write8(addr, (u8)CPU.GPR[rs]);
CPU.GPR[ra] = addr;
}
void ADD(u32 rd, u32 ra, u32 rb, u32 oe, bool rc)
@ -2834,7 +2834,7 @@ private:
}
void STHX(u32 rs, u32 ra, u32 rb)
{
Memory.Write16(ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb], CPU.GPR[rs]);
Memory.Write16(ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb], (u16)CPU.GPR[rs]);
}
void ORC(u32 ra, u32 rs, u32 rb, bool rc)
{
@ -2844,12 +2844,12 @@ private:
void ECOWX(u32 rs, u32 ra, u32 rb)
{
//HACK!
Memory.Write32((ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb]), CPU.GPR[rs]);
Memory.Write32((ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb]), (u32)CPU.GPR[rs]);
}
void STHUX(u32 rs, u32 ra, u32 rb)
{
const u64 addr = CPU.GPR[ra] + CPU.GPR[rb];
Memory.Write16(addr, CPU.GPR[rs]);
Memory.Write16(addr, (u16)CPU.GPR[rs]);
CPU.GPR[ra] = addr;
}
void OR(u32 ra, u32 rs, u32 rb, bool rc)
@ -2876,8 +2876,8 @@ private:
}
void DIVWU(u32 rd, u32 ra, u32 rb, u32 oe, bool rc)
{
const u32 RA = CPU.GPR[ra];
const u32 RB = CPU.GPR[rb];
const u32 RA = (u32)CPU.GPR[ra];
const u32 RB = (u32)CPU.GPR[rb];
if(RB == 0)
{
@ -2925,8 +2925,8 @@ private:
}
void DIVW(u32 rd, u32 ra, u32 rb, u32 oe, bool rc)
{
const s32 RA = CPU.GPR[ra];
const s32 RB = CPU.GPR[rb];
const s32 RA = (s32)CPU.GPR[ra];
const s32 RB = (s32)CPU.GPR[rb];
if (RB == 0 || ((u32)RA == (1 << 31) && RB == -1))
{
@ -2967,8 +2967,8 @@ private:
void SRW(u32 ra, u32 rs, u32 rb, bool rc)
{
u32 n = CPU.GPR[rb] & 0x1f;
u32 r = rotl32((u32)CPU.GPR[rs], 64 - n);
u32 m = (CPU.GPR[rb] & 0x20) ? 0 : rotate_mask[32 + n][63];
u32 r = (u32)rotl32((u32)CPU.GPR[rs], 64 - n);
u32 m = ((u32)CPU.GPR[rb] & 0x20) ? 0 : (u32)rotate_mask[32 + n][63];
CPU.GPR[ra] = r & m;
if(rc) CPU.UpdateCR0<s64>(CPU.GPR[ra]);
@ -2993,7 +2993,7 @@ private:
{
u64 EA = ra ? CPU.GPR[ra] : 0;
u64 N = nb ? nb : 32;
u8 reg = CPU.GPR[rd];
u8 reg = (u8)CPU.GPR[rd];
while (N > 0)
{
@ -3051,7 +3051,7 @@ private:
}
void STWBRX(u32 rs, u32 ra, u32 rb)
{
(u32&)Memory[ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb]] = CPU.GPR[rs];
(u32&)Memory[ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb]] = (u32)CPU.GPR[rs];
}
void STFSX(u32 frs, u32 ra, u32 rb)
{
@ -3072,31 +3072,31 @@ private:
}
void STSWI(u32 rd, u32 ra, u32 nb)
{
u64 EA = ra ? CPU.GPR[ra] : 0;
u64 N = nb ? nb : 32;
u8 reg = CPU.GPR[rd];
u64 EA = ra ? CPU.GPR[ra] : 0;
u64 N = nb ? nb : 32;
u8 reg = (u8)CPU.GPR[rd];
while (N > 0)
while (N > 0)
{
if (N > 3)
{
if (N > 3)
{
Memory.Write32(EA, CPU.GPR[reg]);
EA += 4;
N -= 4;
}
else
{
u32 buf = CPU.GPR[reg];
while (N > 0)
{
N = N - 1;
Memory.Write8(EA, (0xFF000000 & buf) >> 24);
buf <<= 8;
EA = EA + 1;
}
}
reg = (reg + 1) % 32;
Memory.Write32(EA, (u32)CPU.GPR[reg]);
EA += 4;
N -= 4;
}
else
{
u32 buf = (u32)CPU.GPR[reg];
while (N > 0)
{
N = N - 1;
Memory.Write8(EA, (0xFF000000 & buf) >> 24);
buf <<= 8;
EA = EA + 1;
}
}
reg = (reg + 1) % 32;
}
}
void STFDX(u32 frs, u32 ra, u32 rb)
{
@ -3121,7 +3121,7 @@ private:
}
void SRAW(u32 ra, u32 rs, u32 rb, bool rc)
{
s32 RS = CPU.GPR[rs];
s32 RS = (s32)CPU.GPR[rs];
u8 shift = CPU.GPR[rb] & 63;
if (shift > 31)
{
@ -3197,7 +3197,7 @@ private:
}
void STHBRX(u32 rs, u32 ra, u32 rb)
{
(u16&)Memory[ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb]] = CPU.GPR[rs];
(u16&)Memory[ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb]] = (u16)CPU.GPR[rs];
}
void EXTSH(u32 ra, u32 rs, bool rc)
{
@ -3259,22 +3259,22 @@ private:
}
void STW(u32 rs, u32 ra, s32 d)
{
Memory.Write32(ra ? CPU.GPR[ra] + d : d, CPU.GPR[rs]);
Memory.Write32(ra ? CPU.GPR[ra] + d : d, (u32)CPU.GPR[rs]);
}
void STWU(u32 rs, u32 ra, s32 d)
{
const u64 addr = CPU.GPR[ra] + d;
Memory.Write32(addr, CPU.GPR[rs]);
Memory.Write32(addr, (u32)CPU.GPR[rs]);
CPU.GPR[ra] = addr;
}
void STB(u32 rs, u32 ra, s32 d)
{
Memory.Write8(ra ? CPU.GPR[ra] + d : d, CPU.GPR[rs]);
Memory.Write8(ra ? CPU.GPR[ra] + d : d, (u8)CPU.GPR[rs]);
}
void STBU(u32 rs, u32 ra, s32 d)
{
const u64 addr = CPU.GPR[ra] + d;
Memory.Write8(addr, CPU.GPR[rs]);
Memory.Write8(addr, (u8)CPU.GPR[rs]);
CPU.GPR[ra] = addr;
}
void LHZ(u32 rd, u32 ra, s32 d)
@ -3299,12 +3299,12 @@ private:
}
void STH(u32 rs, u32 ra, s32 d)
{
Memory.Write16(ra ? CPU.GPR[ra] + d : d, CPU.GPR[rs]);
Memory.Write16(ra ? CPU.GPR[ra] + d : d, (u16)CPU.GPR[rs]);
}
void STHU(u32 rs, u32 ra, s32 d)
{
const u64 addr = CPU.GPR[ra] + d;
Memory.Write16(addr, CPU.GPR[rs]);
Memory.Write16(addr, (u16)CPU.GPR[rs]);
CPU.GPR[ra] = addr;
}
void LMW(u32 rd, u32 ra, s32 d)
@ -3320,7 +3320,7 @@ private:
u64 addr = ra ? CPU.GPR[ra] + d : d;
for(u32 i=rs; i<32; ++i, addr += 4)
{
Memory.Write32(addr, CPU.GPR[i]);
Memory.Write32(addr, (u32)CPU.GPR[i]);
}
}
void LFS(u32 frd, u32 ra, s32 d)
@ -3891,7 +3891,7 @@ private:
break;
}
r = (u64)i;
double di = i;
double di = (double)i;
if (di == b)
{
CPU.SetFPSCR_FI(0);
@ -3930,7 +3930,7 @@ private:
else
{
s64 i = (s64)b;
double di = i;
double di = (double)i;
if (di == b)
{
CPU.SetFPSCR_FI(0);

View file

@ -108,8 +108,8 @@ void PPUThread::InitRegs()
m_stack_point -= 0xc + 4 * argc;
u64 argv = m_stack_point;
mem64_ptr_t argv_list(argv);
for(int i=0; i<argc; ++i) argv_list += m_argv_addr[i];
auto argv_list = vm::ptr<be_t<u64>>::make((u32)argv);
for(int i=0; i<argc; ++i) argv_list[i] = m_argv_addr[i];
GPR[3] = argc;
GPR[4] = argv;

View file

@ -389,7 +389,7 @@ struct PPCdouble
u32 To32() const
{
float res = _double;
float res = (float)_double;
return (u32&)res;
}
@ -686,7 +686,7 @@ public:
}
else
{
UpdateCRn<u32>(n, a, b);
UpdateCRn<u32>(n, (u32)a, (u32)b);
}
}
@ -694,11 +694,11 @@ public:
{
if(l)
{
UpdateCRn<s64>(n, a, b);
UpdateCRn<s64>(n, (s64)a, (s64)b);
}
else
{
UpdateCRn<s32>(n, a, b);
UpdateCRn<s32>(n, (s32)a, (s32)b);
}
}
@ -822,7 +822,7 @@ public:
}
if (reg == "CR" || reg == "FPSCR")
{
unsigned long reg_value;
unsigned long long reg_value;
reg_value = std::stoull(value.substr(24, 31), 0, 16);
if (reg == "CR") CR.CR = (u32)reg_value;
if (reg == "FPSCR") FPSCR.FPSCR = (u32)reg_value;

View file

@ -155,6 +155,12 @@ bool RawSPUThread::Write32(const u64 addr, const u32 value)
case SPU_NPC_offs:
{
if (value & 3)
{
// least significant bit contains some interrupt flag
LOG_ERROR(Log::SPU, "RawSPUThread[%d]: Write32(SPU_NPC_offs, 0x%x): lowest bits set", m_index, value);
return false;
}
SPU.NPC.SetValue(value);
break;
}
@ -199,5 +205,5 @@ void RawSPUThread::Task()
SPUThread::Task();
SPU.NPC.SetValue(PC);
SPU.NPC.SetValue((u32)PC);
}

View file

@ -16,9 +16,9 @@ public:
RawSPUThread(CPUThreadType type = CPU_THREAD_RAW_SPU);
virtual ~RawSPUThread();
virtual bool Read32(const u64 addr, u32* value) override;
bool Read32(const u64 addr, u32* value);
virtual bool Write32(const u64 addr, const u32 value) override;
bool Write32(const u64 addr, const u32 value);
public:
virtual void InitRegs();

View file

@ -357,7 +357,7 @@ private:
u64 target = branchTarget(CPU.GPR[ra]._u32[3], 0);
CPU.GPR[rt].Reset();
CPU.GPR[rt]._u32[3] = CPU.PC + 4;
CPU.GPR[rt]._u32[3] = (u32)CPU.PC + 4;
LOG5_OPCODE("branch (0x%llx)", target);
CPU.SetBranch(target);
}
@ -1063,7 +1063,7 @@ private:
if (CPU.GPR[rt]._f[i] > 0xffffffff) //if big, result = max
CPU.GPR[rt]._u32[i] = 0xffffffff;
else
CPU.GPR[rt]._u32[i] = floor(CPU.GPR[rt]._f[i]);
CPU.GPR[rt]._u32[i] = (u32)floor(CPU.GPR[rt]._f[i]);
}
}
}
@ -1072,7 +1072,7 @@ private:
const u32 scale = 155 - (i8 & 0xff); //unsigned immediate
for (int i = 0; i < 4; i++)
{
CPU.GPR[rt]._f[i] = (s32)CPU.GPR[ra]._i32[i];
CPU.GPR[rt]._f[i] = (float)CPU.GPR[ra]._i32[i];
u32 exp = ((CPU.GPR[rt]._u32[i] >> 23) & 0xff) - scale;
@ -1178,7 +1178,7 @@ private:
{
u64 target = branchTarget(0, i16);
CPU.GPR[rt].Reset();
CPU.GPR[rt]._u32[3] = CPU.PC + 4;
CPU.GPR[rt]._u32[3] = (u32)CPU.PC + 4;
LOG5_OPCODE("branch (0x%llx)", target);
CPU.SetBranch(target);
}
@ -1208,7 +1208,7 @@ private:
{
u64 target = branchTarget(CPU.PC, i16);
CPU.GPR[rt].Reset();
CPU.GPR[rt]._u32[3] = CPU.PC + 4;
CPU.GPR[rt]._u32[3] = (u32)CPU.PC + 4;
LOG5_OPCODE("branch (0x%llx)", target);
CPU.SetBranch(target);
}

View file

@ -40,7 +40,7 @@ SPURSManagerEventFlag::SPURSManagerEventFlag(u32 flagClearMode, u32 flagDirectio
this->flagDirection = flagDirection;
}
SPURSManagerTasksetAttribute::SPURSManagerTasksetAttribute(u64 args, mem8_t priority, u32 maxContention)
SPURSManagerTasksetAttribute::SPURSManagerTasksetAttribute(u64 args, vm::ptr<const u8> priority, u32 maxContention)
{
this->args = args;
this->maxContention = maxContention;
@ -56,7 +56,7 @@ void SPURSManager::Finalize()
delete this->attr;
}
void SPURSManager::AttachLv2EventQueue(u32 queue, mem8_t port, int isDynamic)
void SPURSManager::AttachLv2EventQueue(u32 queue, vm::ptr<u8> port, int isDynamic)
{
//TODO:
}

View file

@ -47,7 +47,7 @@ protected:
class SPURSManagerTasksetAttribute
{
public:
SPURSManagerTasksetAttribute(u64 args, mem8_t priority, u32 maxContention);
SPURSManagerTasksetAttribute(u64 args, vm::ptr<const u8> priority, u32 maxContention);
protected:
be_t<u64> args;
@ -71,7 +71,7 @@ public:
SPURSManager(SPURSManagerAttribute *attr);
void Finalize();
void AttachLv2EventQueue(u32 queue, mem8_t port, int isDynamic);
void AttachLv2EventQueue(u32 queue, vm::ptr<u8> port, int isDynamic);
void DetachLv2EventQueue(u8 port);
protected:

View file

@ -85,6 +85,9 @@ public:
u16 count; // count of instructions compiled from current point (and to be checked)
u32 valid; // copy of valid opcode for validation
void* pointer; // pointer to executable memory object
#ifdef _WIN32
//_IMAGE_RUNTIME_FUNCTION_ENTRY info;
#endif
};
SPURecEntry entry[0x10000];
@ -105,14 +108,14 @@ public:
#define c (*compiler)
#ifdef _WIN32
#define cpu_xmm(x) oword_ptr(*cpu_var, (sizeof((*(SPUThread*)nullptr).x) == 16) ? offsetof(SPUThread, x) : throw "sizeof("#x") != 16")
#define cpu_qword(x) qword_ptr(*cpu_var, (sizeof((*(SPUThread*)nullptr).x) == 8) ? offsetof(SPUThread, x) : throw "sizeof("#x") != 8")
#define cpu_dword(x) dword_ptr(*cpu_var, (sizeof((*(SPUThread*)nullptr).x) == 4) ? offsetof(SPUThread, x) : throw "sizeof("#x") != 4")
#define cpu_word(x) word_ptr(*cpu_var, (sizeof((*(SPUThread*)nullptr).x) == 2) ? offsetof(SPUThread, x) : throw "sizeof("#x") != 2")
#define cpu_byte(x) byte_ptr(*cpu_var, (sizeof((*(SPUThread*)nullptr).x) == 1) ? offsetof(SPUThread, x) : throw "sizeof("#x") != 1")
#define cpu_xmm(x) oword_ptr(*cpu_var, (sizeof((*(SPUThread*)nullptr).x) == 16) ? (s32)offsetof(SPUThread, x) : throw "sizeof("#x") != 16")
#define cpu_qword(x) qword_ptr(*cpu_var, (sizeof((*(SPUThread*)nullptr).x) == 8) ? (s32)offsetof(SPUThread, x) : throw "sizeof("#x") != 8")
#define cpu_dword(x) dword_ptr(*cpu_var, (sizeof((*(SPUThread*)nullptr).x) == 4) ? (s32)offsetof(SPUThread, x) : throw "sizeof("#x") != 4")
#define cpu_word(x) word_ptr(*cpu_var, (sizeof((*(SPUThread*)nullptr).x) == 2) ? (s32)offsetof(SPUThread, x) : throw "sizeof("#x") != 2")
#define cpu_byte(x) byte_ptr(*cpu_var, (sizeof((*(SPUThread*)nullptr).x) == 1) ? (s32)offsetof(SPUThread, x) : throw "sizeof("#x") != 1")
#define g_imm_xmm(x) oword_ptr(*g_imm_var, offsetof(g_imm_table_struct, x))
#define g_imm2_xmm(x, y) oword_ptr(*g_imm_var, y, 0, offsetof(g_imm_table_struct, x))
#define g_imm_xmm(x) oword_ptr(*g_imm_var, (s32)offsetof(g_imm_table_struct, x))
#define g_imm2_xmm(x, y) oword_ptr(*g_imm_var, y, 0, (s32)offsetof(g_imm_table_struct, x))
#else
#define cpu_xmm(x) oword_ptr(*cpu_var, reinterpret_cast<uintptr_t>(&(((SPUThread*)0)->x)) )
#define cpu_qword(x) qword_ptr(*cpu_var, reinterpret_cast<uintptr_t>(&(((SPUThread*)0)->x)) )
@ -415,9 +418,9 @@ public:
return oword_ptr(*imm_var, i * sizeof(__m128i));
}
}
const int shift = rec.imm_table.size() * sizeof(__m128i);
const size_t shift = rec.imm_table.size() * sizeof(__m128i);
rec.imm_table.push_back(data);
return oword_ptr(*imm_var, shift);
return oword_ptr(*imm_var, (s32)shift);
}
Mem XmmConst(const __m128& data)
@ -1436,7 +1439,7 @@ private:
c.movdqa(vr.get(), XmmConst(_mm_set_epi32(0x10111213, 0x14151617, 0x18191a1b, 0x1c1d1e1f)));
XmmFinalize(vr, rt);
XmmInvalidate(rt);
c.mov(byte_ptr(*cpu_var, *addr, 0, offsetof(SPUThread, GPR[rt]._u8[0])), 0x03);
c.mov(byte_ptr(*cpu_var, *addr, 0, (s32)offsetof(SPUThread, GPR[rt]._u8[0])), 0x03);
LOG_OPCODE();
}
void CHX(u32 rt, u32 ra, u32 rb)
@ -1457,7 +1460,7 @@ private:
c.movdqa(vr.get(), XmmConst(_mm_set_epi32(0x10111213, 0x14151617, 0x18191a1b, 0x1c1d1e1f)));
XmmFinalize(vr, rt);
XmmInvalidate(rt);
c.mov(word_ptr(*cpu_var, *addr, 0, offsetof(SPUThread, GPR[rt]._u16[0])), 0x0203);
c.mov(word_ptr(*cpu_var, *addr, 0, (s32)offsetof(SPUThread, GPR[rt]._u16[0])), 0x0203);
LOG_OPCODE();
}
void CWX(u32 rt, u32 ra, u32 rb)
@ -1478,7 +1481,7 @@ private:
c.movdqa(vr.get(), XmmConst(_mm_set_epi32(0x10111213, 0x14151617, 0x18191a1b, 0x1c1d1e1f)));
XmmFinalize(vr, rt);
XmmInvalidate(rt);
c.mov(dword_ptr(*cpu_var, *addr, 0, offsetof(SPUThread, GPR[rt]._u32[0])), 0x00010203);
c.mov(dword_ptr(*cpu_var, *addr, 0, (s32)offsetof(SPUThread, GPR[rt]._u32[0])), 0x00010203);
LOG_OPCODE();
}
void CDX(u32 rt, u32 ra, u32 rb)
@ -1499,8 +1502,8 @@ private:
c.movdqa(vr.get(), XmmConst(_mm_set_epi32(0x10111213, 0x14151617, 0x18191a1b, 0x1c1d1e1f)));
XmmFinalize(vr, rt);
XmmInvalidate(rt);
c.mov(dword_ptr(*cpu_var, *addr, 0, offsetof(SPUThread, GPR[rt]._u32[0])), 0x04050607);
c.mov(dword_ptr(*cpu_var, *addr, 0, offsetof(SPUThread, GPR[rt]._u32[1])), 0x00010203);
c.mov(dword_ptr(*cpu_var, *addr, 0, (s32)offsetof(SPUThread, GPR[rt]._u32[0])), 0x04050607);
c.mov(dword_ptr(*cpu_var, *addr, 0, (s32)offsetof(SPUThread, GPR[rt]._u32[1])), 0x00010203);
LOG_OPCODE();
}
void ROTQBI(u32 rt, u32 ra, u32 rb)
@ -1600,7 +1603,7 @@ private:
c.movdqa(vr.get(), XmmConst(_mm_set_epi32(0x10111213, 0x14151617, 0x18191a1b, 0x1c1d1e1f)));
XmmFinalize(vr, rt);
XmmInvalidate(rt);
c.mov(byte_ptr(*cpu_var, *addr, 0, offsetof(SPUThread, GPR[rt]._u8[0])), 0x03);
c.mov(byte_ptr(*cpu_var, *addr, 0, (s32)offsetof(SPUThread, GPR[rt]._u8[0])), 0x03);
LOG_OPCODE();
}
void CHD(u32 rt, u32 ra, s32 i7)
@ -1614,7 +1617,7 @@ private:
c.movdqa(vr.get(), XmmConst(_mm_set_epi32(0x10111213, 0x14151617, 0x18191a1b, 0x1c1d1e1f)));
XmmFinalize(vr, rt);
XmmInvalidate(rt);
c.mov(word_ptr(*cpu_var, *addr, 0, offsetof(SPUThread, GPR[rt]._u16[0])), 0x0203);
c.mov(word_ptr(*cpu_var, *addr, 0, (s32)offsetof(SPUThread, GPR[rt]._u16[0])), 0x0203);
LOG_OPCODE();
}
void CWD(u32 rt, u32 ra, s32 i7)
@ -1628,7 +1631,7 @@ private:
c.movdqa(vr.get(), XmmConst(_mm_set_epi32(0x10111213, 0x14151617, 0x18191a1b, 0x1c1d1e1f)));
XmmFinalize(vr, rt);
XmmInvalidate(rt);
c.mov(dword_ptr(*cpu_var, *addr, 0, offsetof(SPUThread, GPR[rt]._u32[0])), 0x00010203);
c.mov(dword_ptr(*cpu_var, *addr, 0, (s32)offsetof(SPUThread, GPR[rt]._u32[0])), 0x00010203);
LOG_OPCODE();
}
void CDD(u32 rt, u32 ra, s32 i7)
@ -1642,8 +1645,8 @@ private:
c.movdqa(vr.get(), XmmConst(_mm_set_epi32(0x10111213, 0x14151617, 0x18191a1b, 0x1c1d1e1f)));
XmmFinalize(vr, rt);
XmmInvalidate(rt);
c.mov(dword_ptr(*cpu_var, *addr, 0, offsetof(SPUThread, GPR[rt]._u32[0])), 0x04050607);
c.mov(dword_ptr(*cpu_var, *addr, 0, offsetof(SPUThread, GPR[rt]._u32[1])), 0x00010203);
c.mov(dword_ptr(*cpu_var, *addr, 0, (s32)offsetof(SPUThread, GPR[rt]._u32[0])), 0x04050607);
c.mov(dword_ptr(*cpu_var, *addr, 0, (s32)offsetof(SPUThread, GPR[rt]._u32[1])), 0x00010203);
LOG_OPCODE();
}
void ROTQBII(u32 rt, u32 ra, s32 i7)
@ -1958,7 +1961,7 @@ private:
for (u32 i = 0; i < 4; i++)
{
c.bsr(*addr, cpu_dword(GPR[ra]._u32[i]));
c.cmovz(*addr, dword_ptr(*g_imm_var, offsetof(g_imm_table_struct, fsmb_table[0xffff]))); // load 0xffffffff
c.cmovz(*addr, dword_ptr(*g_imm_var, (s32)offsetof(g_imm_table_struct, fsmb_table[0xffff]))); // load 0xffffffff
c.neg(*addr);
c.add(*addr, 31);
c.mov(cpu_dword(GPR[rt]._u32[i]), *addr);
@ -1988,7 +1991,7 @@ private:
for (u32 i = 0; i < 8; i++)
{
c.movzx(*addr, cpu_word(GPR[ra]._u16[i]));
c.movzx(*addr, word_ptr(*g_imm_var, *addr, 1, offsetof(g_imm_table_struct, cntb_table[0])));
c.movzx(*addr, word_ptr(*g_imm_var, *addr, 1, (s32)offsetof(g_imm_table_struct, cntb_table[0])));
c.mov(cpu_word(GPR[rt]._u16[i]), addr->r16());
}*/
const XmmLink& va = XmmGet(ra, rt);
@ -2674,9 +2677,9 @@ private:
const XmmLink& va = XmmGet(ra, rt);
if (i8 != 173)
{
c.mulps(va.get(), XmmConst(_mm_set1_ps(pow(2, 173 - (i8 & 0xff))))); // scale
c.mulps(va.get(), XmmConst(_mm_set1_ps((float)pow(2, 173 - (i8 & 0xff))))); // scale
}
c.maxps(va.get(), XmmConst(_mm_set1_ps(-pow(2, 31)))); // saturate
c.maxps(va.get(), XmmConst(_mm_set1_ps((float)-pow(2, 31)))); // saturate
c.minps(va.get(), XmmConst(_mm_set1_ps((float)0x7fffffff)));
c.cvttps2dq(va.get(), va.get()); // convert to ints with truncation
XmmFinalize(va, rt);
@ -2687,13 +2690,13 @@ private:
const XmmLink& va = XmmGet(ra, rt);
if (i8 != 173)
{
c.mulps(va.get(), XmmConst(_mm_set1_ps(pow(2, 173 - (i8 & 0xff))))); // scale
c.mulps(va.get(), XmmConst(_mm_set1_ps((float)pow(2, 173 - (i8 & 0xff))))); // scale
}
c.maxps(va.get(), XmmConst(_mm_set1_ps(0.0f))); // saturate
c.minps(va.get(), XmmConst(_mm_set1_ps((float)0xffffffff)));
const XmmLink& v1 = XmmCopy(va);
c.cmpps(v1.get(), XmmConst(_mm_set1_ps(pow(2, 31))), 5); // generate mask of big values
c.andps(v1.get(), XmmConst(_mm_set1_ps(pow(2, 32)))); // generate correction component
c.cmpps(v1.get(), XmmConst(_mm_set1_ps((float)pow(2, 31))), 5); // generate mask of big values
c.andps(v1.get(), XmmConst(_mm_set1_ps((float)pow(2, 32)))); // generate correction component
c.subps(va.get(), v1.get()); // subtract correction component
c.cvttps2dq(va.get(), va.get()); // convert to ints with truncation
XmmFinalize(va, rt);
@ -2706,7 +2709,7 @@ private:
c.cvtdq2ps(va.get(), va.get()); // convert to floats
if (i8 != 155)
{
c.mulps(va.get(), XmmConst(_mm_set1_ps(pow(2, (i8 & 0xff) - 155)))); // scale
c.mulps(va.get(), XmmConst(_mm_set1_ps((float)pow(2, (i8 & 0xff) - 155)))); // scale
}
XmmFinalize(va, rt);
LOG_OPCODE();
@ -2717,11 +2720,11 @@ private:
const XmmLink& v1 = XmmCopy(va);
c.cvtdq2ps(va.get(), va.get()); // convert to floats
c.psrad(v1.get(), 32); // generate mask from sign bit
c.andps(v1.get(), XmmConst(_mm_set1_ps(pow(2, 32)))); // generate correction component
c.andps(v1.get(), XmmConst(_mm_set1_ps((float)pow(2, 32)))); // generate correction component
c.addps(va.get(), v1.get()); // add correction component
if (i8 != 155)
{
c.mulps(va.get(), XmmConst(_mm_set1_ps(pow(2, (i8 & 0xff) - 155)))); // scale
c.mulps(va.get(), XmmConst(_mm_set1_ps((float)pow(2, (i8 & 0xff) - 155)))); // scale
}
XmmFinalize(va, rt);
XmmFinalize(v1);

View file

@ -157,8 +157,23 @@ void SPURecompilerCore::Compile(u16 pos)
log.Open(fmt::Format("SPUjit_%d.log", GetCurrentSPUThread().GetId()), first ? rFile::write : rFile::write_append);
log.Write(fmt::Format("========== START POSITION 0x%x ==========\n\n", start * 4));
log.Write(std::string(stringLogger.getString()));
log.Write(fmt::Format("========== COMPILED %d (excess %d), time: [start=%lld (decoding=%lld), finalize=%lld]\n\n",
entry[start].count, excess, stamp1 - stamp0, time0, get_system_time() - stamp1));
if (!entry[start].pointer)
{
LOG_ERROR(Log::SPU, "SPURecompilerCore::Compile(pos=0x%x) failed", start * sizeof(u32));
log.Write("========== FAILED ============\n\n");
Emu.Pause();
}
else
{
log.Write(fmt::Format("========== COMPILED %d (excess %d), time: [start=%lld (decoding=%lld), finalize=%lld]\n\n",
entry[start].count, excess, stamp1 - stamp0, time0, get_system_time() - stamp1));
#ifdef _WIN32
//if (!RtlAddFunctionTable(&info, 1, (u64)entry[start].pointer))
//{
// LOG_ERROR(Log::SPU, "RtlAddFunctionTable() failed");
//}
#endif
}
log.Close();
m_enc->compiler = nullptr;
first = false;
@ -168,7 +183,7 @@ u8 SPURecompilerCore::DecodeMemory(const u64 address)
{
assert(CPU.dmac.ls_offset == address - CPU.PC);
const u64 m_offset = CPU.dmac.ls_offset;
const u16 pos = (CPU.PC >> 2);
const u16 pos = (u16)(CPU.PC >> 2);
//ConLog.Write("DecodeMemory: pos=%d", pos);
u32* ls = (u32*)&Memory[m_offset];
@ -195,6 +210,9 @@ u8 SPURecompilerCore::DecodeMemory(const u64 address)
i < (u32)pos + (u32)entry[pos].count)
{
runtime.release(entry[i].pointer);
#ifdef _WIN32
//RtlDeleteFunctionTable(&entry[i].info);
#endif
entry[i].pointer = nullptr;
}
}
@ -215,12 +233,7 @@ u8 SPURecompilerCore::DecodeMemory(const u64 address)
}
}
if (!entry[pos].pointer)
{
LOG_ERROR(Log::SPU, "SPURecompilerCore::DecodeMemory(ls_addr=0x%x): compilation failed", pos * sizeof(u32));
Emu.Pause();
return 0;
}
if (!entry[pos].pointer) return 0;
typedef u32(*Func)(const void* _cpu, const void* _ls, const void* _imm, const void* _g_imm);

View file

@ -155,11 +155,11 @@ void SPUThread::WriteSNR(bool number, u32 value)
{
if (cfg.value & ((u64)1 << (u64)number))
{
SPU.SNR[number].PushUncond_OR(value); // logical OR
SPU.SNR[number ? 1 : 0].PushUncond_OR(value); // logical OR
}
else
{
SPU.SNR[number].PushUncond(value); // overwrite
SPU.SNR[number ? 1 : 0].PushUncond(value); // overwrite
}
}
@ -282,7 +282,7 @@ void SPUThread::ListCmd(u32 lsa, u64 ea, u16 tag, u16 size, u32 cmd, MFCReg& MFC
for (u32 i = 0; i < list_size; i++)
{
mem_ptr_t<list_element> rec(dmac.ls_offset + list_addr + i * 8);
auto rec = vm::ptr<list_element>::make((u32)dmac.ls_offset + list_addr + i * 8);
u32 size = rec->ts;
if (size < 16 && size != 1 && size != 2 && size != 4 && size != 8)
@ -446,7 +446,7 @@ void SPUThread::EnqMfcCmd(MFCReg& MFCArgs)
changed, mask, op, cmd, lsa, ea, tag, size);
SPUDisAsm dis_asm(CPUDisAsm_InterpreterMode);
for (s32 i = PC; i < PC + 4 * 7; i += 4)
for (s32 i = (s32)PC; i < (s32)PC + 4 * 7; i += 4)
{
dis_asm.dump_pc = i;
dis_asm.offset = Memory.GetMemFromAddr(dmac.ls_offset);
@ -1013,9 +1013,9 @@ void SPUThread::StopAndSignal(u32 code)
eq->events.pop(event);
eq->owner.unlock(tid);
SPU.In_MBox.PushUncond(CELL_OK);
SPU.In_MBox.PushUncond(event.data1);
SPU.In_MBox.PushUncond(event.data2);
SPU.In_MBox.PushUncond(event.data3);
SPU.In_MBox.PushUncond((u32)event.data1);
SPU.In_MBox.PushUncond((u32)event.data2);
SPU.In_MBox.PushUncond((u32)event.data3);
return;
}
case SMR_FAILED: break;

View file

@ -522,17 +522,17 @@ public:
void StopAndSignal(u32 code);
virtual u8 ReadLS8 (const u32 lsa) const { return Memory.Read8 (lsa + m_offset); }
virtual u16 ReadLS16 (const u32 lsa) const { return Memory.Read16 (lsa + m_offset); }
virtual u32 ReadLS32 (const u32 lsa) const { return Memory.Read32 (lsa + m_offset); }
virtual u64 ReadLS64 (const u32 lsa) const { return Memory.Read64 (lsa + m_offset); }
virtual u128 ReadLS128(const u32 lsa) const { return Memory.Read128(lsa + m_offset); }
u8 ReadLS8 (const u32 lsa) const { return Memory.Read8 (lsa + m_offset); }
u16 ReadLS16 (const u32 lsa) const { return Memory.Read16 (lsa + m_offset); }
u32 ReadLS32 (const u32 lsa) const { return Memory.Read32 (lsa + m_offset); }
u64 ReadLS64 (const u32 lsa) const { return Memory.Read64 (lsa + m_offset); }
u128 ReadLS128(const u32 lsa) const { return Memory.Read128(lsa + m_offset); }
virtual void WriteLS8 (const u32 lsa, const u8& data) const { Memory.Write8 (lsa + m_offset, data); }
virtual void WriteLS16 (const u32 lsa, const u16& data) const { Memory.Write16 (lsa + m_offset, data); }
virtual void WriteLS32 (const u32 lsa, const u32& data) const { Memory.Write32 (lsa + m_offset, data); }
virtual void WriteLS64 (const u32 lsa, const u64& data) const { Memory.Write64 (lsa + m_offset, data); }
virtual void WriteLS128(const u32 lsa, const u128& data) const { Memory.Write128(lsa + m_offset, data); }
void WriteLS8 (const u32 lsa, const u8& data) const { Memory.Write8 (lsa + m_offset, data); }
void WriteLS16 (const u32 lsa, const u16& data) const { Memory.Write16 (lsa + m_offset, data); }
void WriteLS32 (const u32 lsa, const u32& data) const { Memory.Write32 (lsa + m_offset, data); }
void WriteLS64 (const u32 lsa, const u64& data) const { Memory.Write64 (lsa + m_offset, data); }
void WriteLS128(const u32 lsa, const u128& data) const { Memory.Write128(lsa + m_offset, data); }
public:
SPUThread(CPUThreadType type = CPU_THREAD_SPU);

View file

@ -328,8 +328,8 @@ void VFS::SaveLoadDevices(std::vector<VFSManagerEntry>& res, bool is_load)
}
else
{
count = res.size();
entries_count.SaveValue(res.size());
count = (int)res.size();
entries_count.SaveValue(count);
}
for(int i=0; i<count; ++i)

View file

@ -26,7 +26,7 @@ void vfsDevice::SetPath(const std::string& ps3_path, const std::string& local_pa
u32 vfsDevice::CmpPs3Path(const std::string& ps3_path)
{
const u32 lim = std::min(m_ps3_path.length(), ps3_path.length());
const u32 lim = (u32)std::min(m_ps3_path.length(), ps3_path.length());
u32 ret = 0;
for(u32 i=0; i<lim; ++i, ++ret)
@ -58,10 +58,10 @@ u32 vfsDevice::CmpLocalPath(const std::string& local_path)
std::vector<std::string> arr0 = fmt::rSplit(path0.GetFullPath(), DL);
std::vector<std::string> arr1 = fmt::rSplit(local_path, DL);
const u32 lim = std::min(arr0.size(), arr1.size());
const u32 lim = (u32)std::min(arr0.size(), arr1.size());
u32 ret = 0;
for(u32 i=0; i<lim; ret += arr0[i++].size() + 1)
for(u32 i=0; i<lim; ret += (u32)arr0[i++].size() + 1)
{
if(fmt::CmpNoCase(arr0[i],arr1[i]) != 0)
{
@ -75,7 +75,7 @@ u32 vfsDevice::CmpLocalPath(const std::string& local_path)
std::string vfsDevice::ErasePath(const std::string& path, u32 start_dir_count, u32 end_dir_count)
{
u32 from = 0;
u32 to = path.length() - 1;
u32 to = (u32)path.length() - 1;
for(uint i = 0, dir = 0; i < path.length(); ++i)
{
@ -89,7 +89,7 @@ std::string vfsDevice::ErasePath(const std::string& path, u32 start_dir_count, u
}
}
for(int i = path.length() - 1, dir = 0; i >= 0; --i)
for(int i = (int)path.length() - 1, dir = 0; i >= 0; --i)
{
if(path[i] == '\\' || path[i] == '/' || i == 0)
{
@ -109,9 +109,9 @@ std::string vfsDevice::GetRoot(const std::string& path)
//return fmt::ToUTF8(wxFileName(fmt::FromUTF8(path), wxPATH_UNIX).GetPath());
if(path.empty()) return "";
u32 first_dir = path.length() - 1;
u32 first_dir = (u32)path.length() - 1;
for(int i = path.length() - 1, dir = 0, li = path.length() - 1; i >= 0 && dir < 2; --i)
for(int i = (int)path.length() - 1, dir = 0, li = (int)path.length() - 1; i >= 0 && dir < 2; --i)
{
if(path[i] == '\\' || path[i] == '/' || i == 0)
{
@ -139,9 +139,9 @@ std::string vfsDevice::GetRootPs3(const std::string& path)
static const std::string home = "/dev_hdd0/game/";
u32 last_dir = 0;
u32 first_dir = path.length() - 1;
u32 first_dir = (u32)path.length() - 1;
for(int i = path.length() - 1, dir = 0; i >= 0; --i)
for(int i = (int)path.length() - 1, dir = 0; i >= 0; --i)
{
if(path[i] == '\\' || path[i] == '/' || i == 0)
{

View file

@ -177,7 +177,7 @@ public:
return true;
}
bool HasID(const s64 id)
bool HasID(const u32 id)
{
{
std::lock_guard<std::mutex> lock(m_mtx_main);
@ -211,7 +211,7 @@ public:
u32 GetTypeCount(IDType type)
{
if (type < TYPE_OTHER) {
return m_types[type].size();
return (u32)m_types[type].size();
}
return 1;
}

View file

@ -107,7 +107,7 @@ public:
void Button(u8 button, bool pressed)
{
for(u64 p=0; p < m_mice.size(); ++p)
for(u32 p=0; p < (u32)m_mice.size(); ++p)
{
if (m_info.status[p] == CELL_MOUSE_STATUS_CONNECTED)
{
@ -121,7 +121,7 @@ public:
void Scroll(const s8 rotation)
{
for(u64 p=0; p < m_mice.size(); ++p)
for(u32 p=0; p < (u32)m_mice.size(); ++p)
{
if (m_info.status[p] == CELL_MOUSE_STATUS_CONNECTED)
{
@ -134,7 +134,7 @@ public:
void Move(const s16 x_pos_new, const s16 y_pos_new)
{
for(u64 p=0; p< m_mice.size(); ++p)
for(u32 p=0; p < (u32)m_mice.size(); ++p)
{
if (m_info.status[p] == CELL_MOUSE_STATUS_CONNECTED)
{

View file

@ -2,17 +2,18 @@
#include "Utilities/Log.h"
#include "Emu/System.h"
#include "Memory.h"
#include "Emu/Cell/RawSPUThread.h"
#ifndef _WIN32
#include <sys/mman.h>
#else
#include <Windows.h>
#endif
/* OS X uses MAP_ANON instead of MAP_ANONYMOUS */
#ifndef MAP_ANONYMOUS
#define MAP_ANONYMOUS MAP_ANON
#endif
#else
#include <Windows.h>
#endif
MemoryBase Memory;
@ -107,14 +108,11 @@ void MemoryBase::Init(MemoryType type)
memset(RawSPUMem, 0, sizeof(RawSPUMem));
#ifdef _WIN32
m_base_addr = VirtualAlloc(nullptr, 0x100000000, MEM_RESERVE, PAGE_NOACCESS);
if (!m_base_addr)
#else
m_base_addr = ::mmap(nullptr, 0x100000000, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
if (m_base_addr == (void*)-1)
if ((s64)m_base_addr == (s64)-1)
#endif
{
m_base_addr = nullptr;
LOG_ERROR(MEMORY, "Initializing memory failed");
assert(0);
return;
@ -138,7 +136,6 @@ void MemoryBase::Init(MemoryType type)
case Memory_PSV:
MemoryBlocks.push_back(PSV.RAM.SetRange(0x81000000, 0x10000000));
MemoryBlocks.push_back(UserMemory = PSV.Userspace.SetRange(0x91000000, 0x10000000));
PSV.Init(GetBaseAddr());
break;
case Memory_PSP:
@ -147,7 +144,6 @@ void MemoryBase::Init(MemoryType type)
MemoryBlocks.push_back(PSP.RAM.SetRange(0x08000000, 0x02000000));
MemoryBlocks.push_back(PSP.Kernel.SetRange(0x88000000, 0x00800000));
MemoryBlocks.push_back(UserMemory = PSP.Userspace.SetRange(0x08800000, 0x01800000));
PSP.Init(GetBaseAddr());
break;
}
@ -172,17 +168,17 @@ void MemoryBase::Close()
MemoryBlocks.clear();
#ifdef _WIN32
if (!VirtualFree(m_base_addr, 0, MEM_RELEASE))
{
LOG_ERROR(MEMORY, "VirtualFree(0x%llx) failed", (u64)m_base_addr);
}
#else
if (::munmap(m_base_addr, 0x100000000))
{
LOG_ERROR(MEMORY, "::munmap(0x%llx) failed", (u64)m_base_addr);
}
#endif
//#ifdef _WIN32
// if (!VirtualFree(m_base_addr, 0, MEM_RELEASE))
// {
// LOG_ERROR(MEMORY, "VirtualFree(0x%llx) failed", (u64)m_base_addr);
// }
//#else
// if (::munmap(m_base_addr, 0x100000000))
// {
// LOG_ERROR(MEMORY, "::munmap(0x%llx) failed", (u64)m_base_addr);
// }
//#endif
}
void MemoryBase::WriteMMIO32(u32 addr, const u32 data)
@ -191,7 +187,7 @@ void MemoryBase::WriteMMIO32(u32 addr, const u32 data)
std::lock_guard<std::recursive_mutex> lock(m_mutex);
if (RawSPUMem[(addr - RAW_SPU_BASE_ADDR) / RAW_SPU_OFFSET] &&
RawSPUMem[(addr - RAW_SPU_BASE_ADDR) / RAW_SPU_OFFSET]->Write32(addr, data))
((RawSPUThread*)RawSPUMem[(addr - RAW_SPU_BASE_ADDR) / RAW_SPU_OFFSET])->Write32(addr, data))
{
return;
}
@ -207,7 +203,7 @@ u32 MemoryBase::ReadMMIO32(u32 addr)
std::lock_guard<std::recursive_mutex> lock(m_mutex);
if (RawSPUMem[(addr - RAW_SPU_BASE_ADDR) / RAW_SPU_OFFSET] &&
RawSPUMem[(addr - RAW_SPU_BASE_ADDR) / RAW_SPU_OFFSET]->Read32(addr, &res))
((RawSPUThread*)RawSPUMem[(addr - RAW_SPU_BASE_ADDR) / RAW_SPU_OFFSET])->Read32(addr, &res))
{
return res;
}
@ -365,218 +361,6 @@ bool MemoryBlock::IsMyAddress(const u64 addr)
return mem && addr >= GetStartAddr() && addr < GetEndAddr();
}
template <typename T>
__forceinline const T MemoryBlock::FastRead(const u64 addr) const
{
volatile const T data = *(const T *)GetMem(addr);
return re(data);
}
template <>
__forceinline const u128 MemoryBlock::FastRead<u128>(const u64 addr) const
{
volatile const u128 data = *(const u128 *)GetMem(addr);
u128 ret;
ret.lo = re(data.hi);
ret.hi = re(data.lo);
return ret;
}
bool MemoryBlock::Read8(const u64 addr, u8* value)
{
if(!IsMyAddress(addr))
{
*value = 0;
return false;
}
*value = FastRead<u8>(FixAddr(addr));
return true;
}
bool MemoryBlock::Read16(const u64 addr, u16* value)
{
if(!IsMyAddress(addr))
{
*value = 0;
return false;
}
*value = FastRead<u16>(FixAddr(addr));
return true;
}
bool MemoryBlock::Read32(const u64 addr, u32* value)
{
if(!IsMyAddress(addr))
{
*value = 0;
return false;
}
*value = FastRead<u32>(FixAddr(addr));
return true;
}
bool MemoryBlock::Read64(const u64 addr, u64* value)
{
if(!IsMyAddress(addr))
{
*value = 0;
return false;
}
*value = FastRead<u64>(FixAddr(addr));
return true;
}
bool MemoryBlock::Read128(const u64 addr, u128* value)
{
if(!IsMyAddress(addr))
{
*value = u128::From32(0);
return false;
}
*value = FastRead<u128>(FixAddr(addr));
return true;
}
template <typename T>
__forceinline void MemoryBlock::FastWrite(const u64 addr, const T value)
{
*(T *)GetMem(addr) = re(value);
}
template <>
__forceinline void MemoryBlock::FastWrite<u128>(const u64 addr, const u128 value)
{
u128 res;
res.lo = re(value.hi);
res.hi = re(value.lo);
*(u128*)GetMem(addr) = res;
}
bool MemoryBlock::Write8(const u64 addr, const u8 value)
{
if(!IsMyAddress(addr) || IsLocked(addr)) return false;
FastWrite<u8>(FixAddr(addr), value);
return true;
}
bool MemoryBlock::Write16(const u64 addr, const u16 value)
{
if(!IsMyAddress(addr) || IsLocked(addr)) return false;
FastWrite<u16>(FixAddr(addr), value);
return true;
}
bool MemoryBlock::Write32(const u64 addr, const u32 value)
{
if(!IsMyAddress(addr) || IsLocked(addr)) return false;
FastWrite<u32>(FixAddr(addr), value);
return true;
}
bool MemoryBlock::Write64(const u64 addr, const u64 value)
{
if(!IsMyAddress(addr) || IsLocked(addr)) return false;
FastWrite<u64>(FixAddr(addr), value);
return true;
}
bool MemoryBlock::Write128(const u64 addr, const u128 value)
{
if(!IsMyAddress(addr) || IsLocked(addr)) return false;
FastWrite<u128>(FixAddr(addr), value);
return true;
}
bool MemoryBlockLE::Read8(const u64 addr, u8* value)
{
if(!IsMyAddress(addr)) return false;
*value = *(u8*)GetMem(FixAddr(addr));
return true;
}
bool MemoryBlockLE::Read16(const u64 addr, u16* value)
{
if(!IsMyAddress(addr)) return false;
*value = *(u16*)GetMem(FixAddr(addr));
return true;
}
bool MemoryBlockLE::Read32(const u64 addr, u32* value)
{
if(!IsMyAddress(addr)) return false;
*value = *(u32*)GetMem(FixAddr(addr));
return true;
}
bool MemoryBlockLE::Read64(const u64 addr, u64* value)
{
if(!IsMyAddress(addr)) return false;
*value = *(u64*)GetMem(FixAddr(addr));
return true;
}
bool MemoryBlockLE::Read128(const u64 addr, u128* value)
{
if(!IsMyAddress(addr)) return false;
*value = *(u128*)GetMem(FixAddr(addr));
return true;
}
bool MemoryBlockLE::Write8(const u64 addr, const u8 value)
{
if(!IsMyAddress(addr)) return false;
*(u8*)GetMem(FixAddr(addr)) = value;
return true;
}
bool MemoryBlockLE::Write16(const u64 addr, const u16 value)
{
if(!IsMyAddress(addr)) return false;
*(u16*)GetMem(FixAddr(addr)) = value;
return true;
}
bool MemoryBlockLE::Write32(const u64 addr, const u32 value)
{
if(!IsMyAddress(addr)) return false;
*(u32*)GetMem(FixAddr(addr)) = value;
return true;
}
bool MemoryBlockLE::Write64(const u64 addr, const u64 value)
{
if(!IsMyAddress(addr)) return false;
*(u64*)GetMem(FixAddr(addr)) = value;
return true;
}
bool MemoryBlockLE::Write128(const u64 addr, const u128 value)
{
if(!IsMyAddress(addr)) return false;
*(u128*)GetMem(FixAddr(addr)) = value;
return true;
}
VirtualMemoryBlock::VirtualMemoryBlock() : MemoryBlock(), m_reserve_size(0)
{
}

View file

@ -8,6 +8,8 @@ using std::nullptr_t;
#define safe_delete(x) do {delete (x);(x)=nullptr;} while(0)
#define safe_free(x) do {free(x);(x)=nullptr;} while(0)
extern void* const m_base_addr;
enum MemoryType
{
Memory_PS3,
@ -25,7 +27,6 @@ enum : u64
class MemoryBase
{
void* m_base_addr;
std::vector<MemoryBlock*> MemoryBlocks;
u32 m_pages[0x100000000 / 4096]; // information about every page
std::recursive_mutex m_mutex;
@ -44,12 +45,6 @@ public:
struct Wrapper32LE
{
private:
void* m_base_addr;
public:
Wrapper32LE() : m_base_addr(nullptr) {}
void Write8(const u32 addr, const u8 data) { *(u8*)((u8*)m_base_addr + addr) = data; }
void Write16(const u32 addr, const u16 data) { *(u16*)((u8*)m_base_addr + addr) = data; }
void Write32(const u32 addr, const u32 data) { *(u32*)((u8*)m_base_addr + addr) = data; }
@ -61,8 +56,6 @@ public:
u32 Read32(const u32 addr) { return *(u32*)((u8*)m_base_addr + addr); }
u64 Read64(const u32 addr) { return *(u64*)((u8*)m_base_addr + addr); }
u128 Read128(const u32 addr) { return *(u128*)((u8*)m_base_addr + addr); }
void Init(void* real_addr) { m_base_addr = real_addr; }
};
struct : Wrapper32LE
@ -92,7 +85,7 @@ public:
Close();
}
void* GetBaseAddr() const
static void* const GetBaseAddr()
{
return m_base_addr;
}
@ -125,9 +118,9 @@ public:
{
const u64 res = (u64)addr - (u64)GetBaseAddr();
if (res < 0x100000000)
if ((u32)res == res)
{
return res;
return (u32)res;
}
else
{
@ -162,7 +155,7 @@ public:
}
else
{
for (u32 i = addr / 4096; i <= (addr + size - 1) / 4096; i++)
for (u32 i = (u32)addr / 4096; i <= ((u32)addr + size - 1) / 4096; i++)
{
if (!m_pages[i]) return false; // TODO: define page parameters
}
@ -211,7 +204,7 @@ public:
}
else
{
WriteMMIO32(addr, data);
WriteMMIO32((u32)addr, data);
}
}
else
@ -285,7 +278,7 @@ public:
}
else
{
return ReadMMIO32(addr);
return ReadMMIO32((u32)addr);
}
}
else
@ -365,7 +358,7 @@ public:
template<typename T> void WriteString(const T addr, const std::string& str)
{
memcpy(GetMemFromAddr<T>(addr), str.c_str(), str.size());
strcpy((char*)GetMemFromAddr<T>(addr), str.c_str());
}
u32 GetUserMemTotalSize()
@ -415,545 +408,5 @@ public:
extern MemoryBase Memory;
template<typename T, typename AT = u32>
class mem_base_t
{
protected:
AT m_addr;
public:
mem_base_t(AT addr) : m_addr(addr)
{
}
__forceinline AT GetAddr() const { return m_addr; }
__forceinline void SetAddr(AT addr) { m_addr = addr; }
__forceinline bool IsGood() const
{
return Memory.IsGoodAddr(m_addr, sizeof(T));
}
__forceinline operator bool() const
{
return m_addr != 0;
}
__forceinline bool operator != (nullptr_t) const
{
return m_addr != 0;
}
__forceinline bool operator == (nullptr_t) const
{
return m_addr == 0;
}
bool operator == (const mem_base_t& right) const { return m_addr == right.m_addr; }
bool operator != (const mem_base_t& right) const { return m_addr != right.m_addr; }
bool operator > (const mem_base_t& right) const { return m_addr > right.m_addr; }
bool operator < (const mem_base_t& right) const { return m_addr < right.m_addr; }
bool operator >= (const mem_base_t& right) const { return m_addr >= right.m_addr; }
bool operator <= (const mem_base_t& right) const { return m_addr <= right.m_addr; }
bool operator == (T* right) const { return (T*)&Memory[m_addr] == right; }
bool operator != (T* right) const { return (T*)&Memory[m_addr] != right; }
bool operator > (T* right) const { return (T*)&Memory[m_addr] > right; }
bool operator < (T* right) const { return (T*)&Memory[m_addr] < right; }
bool operator >= (T* right) const { return (T*)&Memory[m_addr] >= right; }
bool operator <= (T* right) const { return (T*)&Memory[m_addr] <= right; }
};
template<typename T, int lvl = 1, typename AT = u32>
class mem_ptr_t : public mem_base_t<AT, AT>
{
public:
mem_ptr_t(AT addr) : mem_base_t<AT, AT>(addr)
{
}
template<typename NT> operator mem_ptr_t<NT, lvl, AT>&() { return (mem_ptr_t<NT, lvl, AT>&)*this; }
template<typename NT> operator const mem_ptr_t<NT, lvl, AT>&() const { return (const mem_ptr_t<NT, lvl, AT>&)*this; }
mem_ptr_t operator++ (int)
{
mem_ptr_t ret(this->m_addr);
this->m_addr += sizeof(AT);
return ret;
}
mem_ptr_t& operator++ ()
{
this->m_addr += sizeof(AT);
return *this;
}
mem_ptr_t operator-- (int)
{
mem_ptr_t ret(this->m_addr);
this->m_addr -= sizeof(AT);
return ret;
}
mem_ptr_t& operator-- ()
{
this->m_addr -= sizeof(AT);
return *this;
}
mem_ptr_t& operator += (uint count)
{
this->m_addr += count * sizeof(AT);
return *this;
}
mem_ptr_t& operator -= (uint count)
{
this->m_addr -= count * sizeof(AT);
return *this;
}
mem_ptr_t operator + (uint count) const
{
return this->m_addr + count * sizeof(AT);
}
mem_ptr_t operator - (uint count) const
{
return this->m_addr - count * sizeof(AT);
}
__forceinline mem_ptr_t<T, lvl - 1, AT>& operator *()
{
return (mem_ptr_t<T, lvl - 1, AT>&)Memory[this->m_addr];
}
__forceinline const mem_ptr_t<T, lvl - 1, AT>& operator *() const
{
return (const mem_ptr_t<T, lvl - 1, AT>&)Memory[this->m_addr];
}
__forceinline mem_ptr_t<T, lvl - 1, AT>& operator [](uint index)
{
return (mem_ptr_t<T, lvl - 1, AT>&)Memory[this->m_addr + sizeof(AT) * index];
}
__forceinline const mem_ptr_t<T, lvl - 1, AT>& operator [](uint index) const
{
return (const mem_ptr_t<T, lvl - 1, AT>&)Memory[this->m_addr + sizeof(AT) * index];
}
bool IsGood() const
{
return (*this)->IsGood() && mem_base_t<T, AT>::IsGood();
}
__forceinline bool IsGoodAddr() const
{
return mem_base_t<T, AT>::IsGood();
}
};
template<typename T, typename AT>
class mem_ptr_t<T, 1, AT> : public mem_base_t<T, AT>
{
public:
mem_ptr_t(AT addr) : mem_base_t<T, AT>(addr)
{
}
template<typename NT> operator mem_ptr_t<NT, 1, AT>&() { return (mem_ptr_t<NT, 1, AT>&)*this; }
template<typename NT> operator const mem_ptr_t<NT, 1, AT>&() const { return (const mem_ptr_t<NT, 1, AT>&)*this; }
__forceinline T* operator -> ()
{
return (T*)&Memory[this->m_addr];
}
__forceinline const T* operator -> () const
{
return (const T*)&Memory[this->m_addr];
}
mem_ptr_t operator++ (int)
{
mem_ptr_t ret(this->m_addr);
this->m_addr += sizeof(T);
return ret;
}
mem_ptr_t& operator++ ()
{
this->m_addr += sizeof(T);
return *this;
}
mem_ptr_t operator-- (int)
{
mem_ptr_t ret(this->m_addr);
this->m_addr -= sizeof(T);
return ret;
}
mem_ptr_t& operator-- ()
{
this->m_addr -= sizeof(T);
return *this;
}
mem_ptr_t& operator += (uint count)
{
this->m_addr += count * sizeof(T);
return *this;
}
mem_ptr_t& operator -= (uint count)
{
this->m_addr -= count * sizeof(T);
return *this;
}
mem_ptr_t operator + (uint count) const
{
return this->m_addr + count * sizeof(T);
}
mem_ptr_t operator - (uint count) const
{
return this->m_addr - count * sizeof(T);
}
__forceinline T& operator *()
{
return (T&)Memory[this->m_addr];
}
__forceinline const T& operator *() const
{
return (T&)Memory[this->m_addr];
}
__forceinline T& operator [](uint index)
{
return (T&)Memory[this->m_addr + sizeof(T) * index];
}
__forceinline const T& operator [](uint index) const
{
return (const T&)Memory[this->m_addr + sizeof(T) * index];
}
};
template<typename AT>
class mem_ptr_t<void, 1, AT> : public mem_base_t<u8, AT>
{
public:
mem_ptr_t(AT addr) : mem_base_t<u8, AT>(addr)
{
}
template<typename NT> operator mem_ptr_t<NT, 1, AT>&() { return (mem_ptr_t<NT, 1, AT>&)*this; }
template<typename NT> operator const mem_ptr_t<NT, 1, AT>&() const { return (const mem_ptr_t<NT, 1, AT>&)*this; }
};
template<typename T, int lvl = 1, typename AT = u32>
class mem_beptr_t : public mem_ptr_t<T, lvl, be_t<AT>> {};
template<typename T, typename AT = u32> class mem_t : public mem_base_t<T, AT>
{
public:
mem_t(AT addr) : mem_base_t<T, AT>(addr)
{
}
mem_t& operator = (T right)
{
(be_t<T>&)Memory[this->m_addr] = right;
return *this;
}
__forceinline T GetValue()
{
return (be_t<T>&)Memory[this->m_addr];
}
operator const T() const
{
return (be_t<T>&)Memory[this->m_addr];
}
mem_t& operator += (T right) { return *this = (*this) + right; }
mem_t& operator -= (T right) { return *this = (*this) - right; }
mem_t& operator *= (T right) { return *this = (*this) * right; }
mem_t& operator /= (T right) { return *this = (*this) / right; }
mem_t& operator %= (T right) { return *this = (*this) % right; }
mem_t& operator &= (T right) { return *this = (*this) & right; }
mem_t& operator |= (T right) { return *this = (*this) | right; }
mem_t& operator ^= (T right) { return *this = (*this) ^ right; }
mem_t& operator <<= (T right) { return *this = (*this) << right; }
mem_t& operator >>= (T right) { return *this = (*this) >> right; }
};
template<typename T, typename AT = u32> class mem_list_ptr_t : public mem_base_t<T, AT>
{
public:
mem_list_ptr_t(u32 addr) : mem_base_t<T>(addr)
{
}
void operator = (T right)
{
(be_t<T>&)Memory[this->m_addr] = right;
}
u32 operator += (T right)
{
*this = right;
this->m_addr += sizeof(T);
return this->m_addr;
}
u32 AppendRawBytes(const u8 *bytes, size_t count)
{
memmove(Memory + this->m_addr, bytes, count);
this->m_addr += count;
return this->m_addr;
}
u32 Skip(const u32 offset) { return this->m_addr += offset; }
operator be_t<T>*() { return GetPtr(); }
operator void*() { return GetPtr(); }
operator be_t<T>*() const { return GetPtr(); }
operator void*() const { return GetPtr(); }
const char* GetString() const
{
return (const char*)&Memory[this->m_addr];
}
be_t<T>* GetPtr()
{
return (be_t<T>*)&Memory[this->m_addr];
}
const be_t<T>* GetPtr() const
{
return (const be_t<T>*)&Memory[this->m_addr];
}
};
template<typename T>
struct _func_arg
{
__forceinline static u64 get_value(const T& arg)
{
return arg;
}
};
template<typename T>
struct _func_arg<mem_base_t<T, u32>>
{
__forceinline static u64 get_value(const mem_base_t<T, u32> arg)
{
return arg.GetAddr();
}
};
template<typename T, int lvl> struct _func_arg<mem_ptr_t<T, lvl, u32>> : public _func_arg<mem_base_t<T, u32>> {};
template<int lvl> struct _func_arg<mem_ptr_t<void, lvl, u32>> : public _func_arg<mem_base_t<u8, u32>>{};
template<typename T> struct _func_arg<mem_list_ptr_t<T, u32>> : public _func_arg<mem_base_t<T, u32>> {};
template<typename T> struct _func_arg<mem_t<T, u32>> : public _func_arg<mem_base_t<T, u32>> {};
template<typename T>
struct _func_arg<be_t<T>>
{
__forceinline static u64 get_value(const be_t<T>& arg)
{
return arg.ToLE();
}
};
template<typename T, typename AT = u32> class mem_func_ptr_t;
template<typename T, typename AT = u32> class mem_func_beptr_t : public mem_func_ptr_t<T, be_t<AT>> {};
template<typename RT, typename AT>
class mem_func_ptr_t<RT (*)(), AT> : public mem_base_t<u64, AT>
{
__forceinline RT call_func(bool is_async) const
{
Callback cb;
cb.SetAddr(this->m_addr);
return (RT)cb.Branch(!is_async);
}
public:
__forceinline RT operator()() const
{
return call_func(false);
}
__forceinline void async() const
{
call_func(true);
}
};
template<typename AT, typename RT, typename ...T>
class mem_func_ptr_t<RT(*)(T...), AT> : public mem_base_t<u64, AT>
{
__forceinline RT call_func(bool is_async, T... args) const
{
Callback cb;
cb.SetAddr(this->m_addr);
cb.Handle(_func_arg<T>::get_value(args)...);
return (RT)cb.Branch(!is_async);
}
public:
__forceinline RT operator()(T... args) const
{
return call_func(false, args...);
}
__forceinline void async(T... args) const
{
call_func(true, args...);
}
};
template<typename T>
class MemoryAllocator
{
u32 m_addr;
u32 m_size;
T* m_ptr;
public:
MemoryAllocator(u32 size = sizeof(T), u32 align = 1)
: m_size(size)
, m_addr(Memory.Alloc(size, align))
, m_ptr((T*)&Memory[m_addr])
{
}
~MemoryAllocator()
{
Memory.Free(m_addr);
}
T* operator -> ()
{
return m_ptr;
}
T* GetPtr()
{
return m_ptr;
}
const T* GetPtr() const
{
return m_ptr;
}
const T* operator -> () const
{
return m_ptr;
}
u32 GetAddr() const
{
return m_addr;
}
u32 GetSize() const
{
return m_size;
}
bool IsGood() const
{
return Memory.IsGoodAddr(m_addr, sizeof(T));
}
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 *(m_ptr + index);
}
template<typename T1>
operator const mem_t<T1>() const
{
return GetAddr();
}
operator const mem_ptr_t<T>() const
{
return GetAddr();
}
template<typename NT>
NT* To(uint offset = 0)
{
return (NT*)(m_ptr + offset);
}
};
typedef mem_t<u8, u32> mem8_t;
typedef mem_t<u16, u32> mem16_t;
typedef mem_t<u32, u32> mem32_t;
typedef mem_t<u64, u32> mem64_t;
/*
typedef mem_ptr_t<be_t<u8>> mem8_ptr_t;
typedef mem_ptr_t<be_t<u16>> mem16_ptr_t;
typedef mem_ptr_t<be_t<u32>> mem32_ptr_t;
typedef mem_ptr_t<be_t<u64>> mem64_ptr_t;
typedef mem_list_ptr_t<u8> mem8_lptr_t;
typedef mem_list_ptr_t<u16> mem16_lptr_t;
typedef mem_list_ptr_t<u32> mem32_lptr_t;
typedef mem_list_ptr_t<u64> mem64_lptr_t;
*/
typedef mem_list_ptr_t<u8, u32> mem8_ptr_t;
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"

View file

@ -78,7 +78,7 @@ class MemoryBlock
protected:
u8* mem;
u64 range_start;
u64 range_size;
u32 range_size;
public:
MemoryBlock();
@ -102,24 +102,6 @@ public:
virtual bool IsMyAddress(const u64 addr);
virtual bool IsLocked(const u64 addr) { return false; }
template <typename T>
__forceinline const T FastRead(const u64 addr) const;
virtual bool Read8(const u64 addr, u8* value);
virtual bool Read16(const u64 addr, u16* value);
virtual bool Read32(const u64 addr, u32* value);
virtual bool Read64(const u64 addr, u64* value);
virtual bool Read128(const u64 addr, u128* value);
template <typename T>
__forceinline void FastWrite(const u64 addr, const T value);
virtual bool Write8(const u64 addr, const u8 value);
virtual bool Write16(const u64 addr, const u16 value);
virtual bool Write32(const u64 addr, const u32 value);
virtual bool Write64(const u64 addr, const u64 value);
virtual bool Write128(const u64 addr, const u128 value);
const u64 GetStartAddr() const { return range_start; }
const u64 GetEndAddr() const { return GetStartAddr() + GetSize() - 1; }
virtual const u32 GetSize() const { return range_size; }
@ -137,18 +119,7 @@ public:
class MemoryBlockLE : public MemoryBlock
{
public:
virtual bool Read8(const u64 addr, u8* value) override;
virtual bool Read16(const u64 addr, u16* value) override;
virtual bool Read32(const u64 addr, u32* value) override;
virtual bool Read64(const u64 addr, u64* value) override;
virtual bool Read128(const u64 addr, u128* value) override;
virtual bool Write8(const u64 addr, const u8 value) override;
virtual bool Write16(const u64 addr, const u16 value) override;
virtual bool Write32(const u64 addr, const u32 value) override;
virtual bool Write64(const u64 addr, const u64 value) override;
virtual bool Write128(const u64 addr, const u128 value) override;
};
class MemoryMirror : public MemoryBlock
@ -244,17 +215,17 @@ public:
// Return the total amount of reserved memory
virtual u32 GetReservedAmount();
virtual bool Read8(const u64 addr, u8* value);
virtual bool Read16(const u64 addr, u16* value);
virtual bool Read32(const u64 addr, u32* value);
virtual bool Read64(const u64 addr, u64* value);
virtual bool Read128(const u64 addr, u128* value);
bool Read8(const u64 addr, u8* value);
bool Read16(const u64 addr, u16* value);
bool Read32(const u64 addr, u32* value);
bool Read64(const u64 addr, u64* value);
bool Read128(const u64 addr, u128* value);
virtual bool Write8(const u64 addr, const u8 value);
virtual bool Write16(const u64 addr, const u16 value);
virtual bool Write32(const u64 addr, const u32 value);
virtual bool Write64(const u64 addr, const u64 value);
virtual bool Write128(const u64 addr, const u128 value);
bool Write8(const u64 addr, const u8 value);
bool Write16(const u64 addr, const u16 value);
bool Write32(const u64 addr, const u32 value);
bool Write64(const u64 addr, const u64 value);
bool Write128(const u64 addr, const u128 value);
// try to get the real address given a mapped address
// return true for success

47
rpcs3/Emu/Memory/vm.cpp Normal file
View file

@ -0,0 +1,47 @@
#include "stdafx.h"
#include "Memory.h"
#ifdef _WIN32
#include <Windows.h>
void* const m_base_addr = VirtualAlloc(nullptr, 0x100000000, MEM_RESERVE, PAGE_NOACCESS);
#else
#include <sys/mman.h>
/* OS X uses MAP_ANON instead of MAP_ANONYMOUS */
#ifndef MAP_ANONYMOUS
#define MAP_ANONYMOUS MAP_ANON
#endif
void* const m_base_addr = ::mmap(nullptr, 0x100000000, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
#endif
namespace vm
{
bool check_addr(u32 addr)
{
// Checking address before using it is unsafe.
// The only safe way to check it is to protect both actions (checking and using) with mutex that is used for mapping/allocation.
return false;
}
//TODO
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)
{
}
}

135
rpcs3/Emu/Memory/vm.h Normal file
View file

@ -0,0 +1,135 @@
#pragma once
namespace vm
{
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* const get_ptr(u32 addr)
{
return (T*)((u8*)m_base_addr + addr);
}
template<typename T>
T& get_ref(u32 addr)
{
return *(T*)((u8*)m_base_addr + addr);
}
static u8 read8(u32 addr)
{
return *((u8*)m_base_addr + addr);
}
static void write8(u32 addr, u8 value)
{
*((u8*)m_base_addr + addr) = value;
}
namespace ps3
{
static u16 read16(u32 addr)
{
return re16(*(u16*)((u8*)m_base_addr + addr));
}
static void write16(u32 addr, u16 value)
{
*(u16*)((u8*)m_base_addr + addr) = re16(value);
}
static u32 read32(u32 addr)
{
if (addr < RAW_SPU_BASE_ADDR || (addr % RAW_SPU_OFFSET) < RAW_SPU_PROB_OFFSET)
{
return re32(*(u32*)((u8*)m_base_addr + addr));
}
else
{
return Memory.ReadMMIO32((u32)addr);
}
}
static void write32(u32 addr, u32 value)
{
if (addr < RAW_SPU_BASE_ADDR || (addr % RAW_SPU_OFFSET) < RAW_SPU_PROB_OFFSET)
{
*(u32*)((u8*)m_base_addr + addr) = re32(value);
}
else
{
Memory.WriteMMIO32((u32)addr, value);
}
}
static u64 read64(u32 addr)
{
return re64(*(u64*)((u8*)m_base_addr + addr));
}
static void write64(u32 addr, u64 value)
{
*(u64*)((u8*)m_base_addr + addr) = re64(value);
}
static u128 read128(u32 addr)
{
return re128(*(u128*)((u8*)m_base_addr + addr));
}
static void write128(u32 addr, u128 value)
{
*(u128*)((u8*)m_base_addr + addr) = re128(value);
}
}
namespace psv
{
static u16 read16(u32 addr)
{
return *(u16*)((u8*)m_base_addr + addr);
}
static void write16(u32 addr, u16 value)
{
*(u16*)((u8*)m_base_addr + addr) = value;
}
static u32 read32(u32 addr)
{
return *(u32*)((u8*)m_base_addr + addr);
}
static void write32(u32 addr, u32 value)
{
*(u32*)((u8*)m_base_addr + addr) = value;
}
static u64 read64(u32 addr)
{
return *(u64*)((u8*)m_base_addr + addr);
}
static void write64(u32 addr, u64 value)
{
*(u64*)((u8*)m_base_addr + addr) = value;
}
static u128 read128(u32 addr)
{
return *(u128*)((u8*)m_base_addr + addr);
}
static void write128(u32 addr, u128 value)
{
*(u128*)((u8*)m_base_addr + addr) = value;
}
}
}
#include "vm_ref.h"
#include "vm_ptr.h"
#include "vm_var.h"

471
rpcs3/Emu/Memory/vm_ptr.h Normal file
View file

@ -0,0 +1,471 @@
#pragma once
namespace vm
{
template<typename T, int lvl = 1, typename AT = u32>
class _ptr_base
{
AT m_addr;
public:
typedef T type;
_ptr_base operator++ (int)
{
AT result = m_addr;
m_addr += sizeof(AT);
return make(result);
}
_ptr_base& operator++ ()
{
m_addr += sizeof(AT);
return *this;
}
_ptr_base operator-- (int)
{
AT result = m_addr;
m_addr -= sizeof(AT);
return make(result);
}
_ptr_base& operator-- ()
{
m_addr -= sizeof(AT);
return *this;
}
_ptr_base& operator += (int count)
{
m_addr += count * sizeof(AT);
return *this;
}
_ptr_base& operator -= (int count)
{
m_addr -= count * sizeof(AT);
return *this;
}
_ptr_base operator + (int count) const
{
return make(m_addr + count * sizeof(AT));
}
_ptr_base operator - (int count) const
{
return make(m_addr - count * sizeof(AT));
}
__forceinline _ptr_base<T, lvl - 1, AT>& operator *()
{
return vm::get_ref<_ptr_base<T, lvl - 1, AT>>(m_addr);
}
__forceinline const _ptr_base<T, lvl - 1, AT>& operator *() const
{
return vm::get_ref<const _ptr_base<T, lvl - 1, AT>>(m_addr);
}
__forceinline _ptr_base<T, lvl - 1, AT>& operator [](int index)
{
return vm::get_ref<_ptr_base<T, lvl - 1, AT>>(m_addr + sizeof(AT) * index);
}
__forceinline const _ptr_base<T, lvl - 1, AT>& operator [](int index) const
{
return vm::get_ref<const _ptr_base<T, lvl - 1, AT>>(m_addr + sizeof(AT) * index);
}
operator bool() const
{
return m_addr != 0;
}
AT addr() const
{
return m_addr;
}
static _ptr_base make(AT addr)
{
return (_ptr_base&)addr;
}
};
template<typename T, typename AT>
class _ptr_base<T, 1, AT>
{
AT m_addr;
public:
__forceinline T* const operator -> ()
{
return vm::get_ptr<T>(m_addr);
}
__forceinline const T* const operator -> () const
{
return vm::get_ptr<const T>(m_addr);
}
_ptr_base operator++ (int)
{
AT result = m_addr;
m_addr += sizeof(T);
return make(result);
}
_ptr_base& operator++ ()
{
m_addr += sizeof(T);
return *this;
}
_ptr_base operator-- (int)
{
AT result = m_addr;
m_addr -= sizeof(T);
return make(result);
}
_ptr_base& operator-- ()
{
m_addr -= sizeof(T);
return *this;
}
_ptr_base& operator += (int count)
{
m_addr += count * sizeof(T);
return *this;
}
_ptr_base& operator -= (int count)
{
m_addr -= count * sizeof(T);
return *this;
}
_ptr_base operator + (int count) const
{
return make(m_addr + count * sizeof(T));
}
_ptr_base operator - (int count) const
{
return make(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_base<T, AT>()
{
return _ref_base<T, AT>::make(m_addr);
}
operator const _ref_base<T, AT>() const
{
return _ref_base<T, AT>::make(m_addr);
}
*/
AT addr() const
{
return m_addr;
}
operator bool() const
{
return m_addr != 0;
}
T* const get_ptr() const
{
return vm::get_ptr<T>(m_addr);
}
static _ptr_base make(AT addr)
{
return (_ptr_base&)addr;
}
};
template<typename AT>
class _ptr_base<void, 1, AT>
{
AT m_addr;
public:
AT addr() const
{
return m_addr;
}
void* const get_ptr() const
{
return vm::get_ptr<void>(m_addr);
}
operator bool() const
{
return m_addr != 0;
}
static _ptr_base make(AT addr)
{
return (_ptr_base&)addr;
}
};
template<typename AT>
class _ptr_base<const void, 1, AT>
{
AT m_addr;
public:
AT addr() const
{
return m_addr;
}
const void* const get_ptr() const
{
return vm::get_ptr<const void>(m_addr);
}
operator bool() const
{
return m_addr != 0;
}
static _ptr_base make(AT addr)
{
return (_ptr_base&)addr;
}
};
template<typename RT, typename AT>
class _ptr_base<RT(*)(), 1, AT>
{
AT m_addr;
static_assert(!std::is_floating_point<RT>::value, "TODO: Unsupported callback result type (floating point)");
static_assert(!std::is_pointer<RT>::value, "Invalid callback result type (pointer)");
__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;
}
operator bool() const
{
return m_addr != 0;
}
static _ptr_base make(AT addr)
{
return (_ptr_base&)addr;
}
operator std::function<RT()>() const
{
const AT addr = m_addr;
return [addr]() -> RT { return make(addr)(); };
}
};
template<typename AT, typename RT, typename ...T>
class _ptr_base<RT(*)(T...), 1, AT>
{
AT m_addr;
static_assert(!std::is_floating_point<RT>::value, "TODO: Unsupported callback result type (floating point)");
static_assert(!std::is_pointer<RT>::value, "Invalid callback result type (pointer)");
template<typename TT>
struct _func_arg
{
static_assert(!std::is_floating_point<TT>::value, "TODO: Unsupported callback argument type (floating point)");
static_assert(!std::is_pointer<TT>::value, "Invalid callback argument type (pointer)");
__forceinline static u64 get_value(const TT& arg)
{
u64 res = 0;
(TT&)res = arg;
return res;
}
};
__forceinline RT call_func(bool is_async, T... args) const
{
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;
}
operator bool() const
{
return m_addr != 0;
}
static _ptr_base make(AT addr)
{
return (_ptr_base&)addr;
}
operator std::function<RT(T...)>() const
{
const AT addr = m_addr;
return [addr](T... args) -> RT { return make(addr)(args...); };
}
};
//BE pointer to LE data
template<typename T, int lvl = 1, typename AT = u32> struct bptrl : public _ptr_base<T, lvl, typename to_be_t<AT>::type>
{
static bptrl make(AT addr)
{
return (bptrl&)addr;
}
using _ptr_base<T, lvl, typename to_be_t<AT>::type>::operator=;
};
//BE pointer to BE data
template<typename T, int lvl = 1, typename AT = u32> struct bptrb : public _ptr_base<typename to_be_t<T>::type, lvl, typename to_be_t<AT>::type>
{
static bptrb make(AT addr)
{
return (bptrb&)addr;
}
using _ptr_base<typename to_be_t<T>::type, lvl, typename to_be_t<AT>::type>::operator=;
};
//LE pointer to BE data
template<typename T, int lvl = 1, typename AT = u32> struct lptrb : public _ptr_base<typename to_be_t<T>::type, lvl, AT>
{
static lptrb make(AT addr)
{
return (lptrb&)addr;
}
using _ptr_base<typename to_be_t<T>::type, lvl, AT>::operator=;
};
//LE pointer to LE data
template<typename T, int lvl = 1, typename AT = u32> struct lptrl : public _ptr_base<T, lvl, AT>
{
static lptrl make(AT addr)
{
return (lptrl&)addr;
}
using _ptr_base<T, lvl, AT>::operator=;
};
namespace ps3
{
//default pointer for HLE functions (LE ptrerence to BE data)
template<typename T, int lvl = 1, typename AT = u32> struct ptr : public lptrb<T, lvl, AT>
{
static ptr make(AT addr)
{
return (ptr&)addr;
}
using lptrb<T, lvl, AT>::operator=;
};
//default pointer for HLE structures (BE ptrerence to BE data)
template<typename T, int lvl = 1, typename AT = u32> struct bptr : public bptrb<T, lvl, AT>
{
static bptr make(AT addr)
{
return (bptr&)addr;
}
using bptrb<T, lvl, AT>::operator=;
};
}
namespace psv
{
//default pointer for HLE functions & structures (LE ptrerence to LE data)
template<typename T, int lvl = 1, typename AT = u32> struct ptr : public lptrl<T, lvl, AT>
{
static ptr make(AT addr)
{
return (ptr&)addr;
}
using lptrl<T, lvl, AT>::operator=;
};
}
//PS3 emulation is main now, so lets it be as default
using namespace ps3;
}

111
rpcs3/Emu/Memory/vm_ref.h Normal file
View file

@ -0,0 +1,111 @@
#pragma once
namespace vm
{
template<typename T, typename AT = u32>
class _ref_base
{
protected:
AT m_addr;
public:
typedef T type;
typedef typename remove_be_t<T>::type le_type;
typedef typename to_be_t<T>::type be_type;
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;
}
static _ref_base make(AT addr)
{
return (_ref_base&)addr;
}
_ref_base& operator = (le_type right)
{
get_ref<T>(m_addr) = right;
return *this;
}
const _ref_base& operator = (le_type right) const
{
get_ref<T>(m_addr) = right;
return *this;
}
_ref_base& operator = (be_type right)
{
get_ref<T>(m_addr) = right;
return *this;
}
const _ref_base& operator = (be_type right) const
{
get_ref<T>(m_addr) = right;
return *this;
}
};
//BE reference to LE data
template<typename T, typename AT = u32> struct brefl : public _ref_base<T, typename to_be_t<AT>::type>
{
using _ref_base<T, typename to_be_t<AT>::type>::operator=;
};
//BE reference to BE data
template<typename T, typename AT = u32> struct brefb : public _ref_base<typename to_be_t<T>::type, typename to_be_t<AT>::type>
{
using _ref_base<typename to_be_t<T>::type, typename to_be_t<AT>::type>::operator=;
};
//LE reference to BE data
template<typename T, typename AT = u32> struct lrefb : public _ref_base<typename to_be_t<T>::type, AT>
{
using _ref_base<typename to_be_t<T>::type, AT>::operator=;
};
//LE reference to LE data
template<typename T, typename AT = u32> struct lrefl : public _ref_base<T, AT>
{
using _ref_base<T, AT>::operator=;
};
namespace ps3
{
//default reference for HLE functions (LE reference to BE data)
template<typename T, typename AT = u32> struct ref : public lrefb<T, AT>
{
using lrefb<T, AT>::operator=;
};
//default reference for HLE structures (BE reference to BE data)
template<typename T, typename AT = u32> struct bref : public brefb<T, AT>
{
using brefb<T, AT>::operator=;
};
}
namespace psv
{
//default reference for HLE functions & structures (LE reference to LE data)
template<typename T, typename AT = u32> struct ref : public lrefl<T, AT>
{
using lrefl<T, AT>::operator=;
};
}
//PS3 emulation is main now, so lets it be as default
using namespace ps3;
}

493
rpcs3/Emu/Memory/vm_var.h Normal file
View file

@ -0,0 +1,493 @@
#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 = (u32)Memory.Alloc(size(), m_align);
m_ptr = vm::get_ptr<T>(m_addr);
}
void dealloc()
{
if (m_addr)
{
Memory.Free(m_addr);
m_addr = 0;
m_ptr = vm::get_ptr<T>(0);
}
}
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 = vm::get_ptr<T>(addr);
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;
}
/*
operator const ref<T>() const
{
return addr();
}
*/
template<typename AT> operator ps3::ptr<T, 1, AT>() const
{
return ps3::ptr<T, 1, AT>::make(m_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 = (u32)Memory.Alloc(size(), m_align);
m_ptr = vm::get_ptr<T>(m_addr);
}
void dealloc()
{
if (m_addr)
{
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 = vm::get_ptr<T>(addr);
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;
}
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 = (u32)Memory.Alloc(size(), m_align);
m_ptr = vm::get_ptr<T>(m_addr);
}
void dealloc()
{
if (m_addr)
{
Memory.Free(m_addr);
m_addr = 0;
m_ptr = vm::get_ptr<T>(0);
}
}
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;
}
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);
}
};
}

View file

@ -90,7 +90,7 @@ std::string GLFragmentDecompilerThread::AddConst()
return name;
}
mem32_ptr_t data(m_addr + m_size + m_offset);
auto data = vm::ptr<be_t<u32>>::make(m_addr + m_size + m_offset);
m_offset += 4 * 4;
u32 x = GetData(data[0]);
@ -279,7 +279,7 @@ std::string GLFragmentDecompilerThread::BuildCode()
void GLFragmentDecompilerThread::Task()
{
mem32_ptr_t data(m_addr);
auto data = vm::ptr<be_t<u32>>::make(m_addr);
m_size = 0;
m_location = 0;
m_loop_count = 0;
@ -314,7 +314,7 @@ void GLFragmentDecompilerThread::Task()
src1.HEX = GetData(data[2]);
src2.HEX = GetData(data[3]);
m_offset = 4 * 4;
m_offset = 4 * sizeof(u32);
const u32 opcode = dst.opcode | (src1.opcode_is_branch << 6);
@ -439,7 +439,8 @@ void GLFragmentDecompilerThread::Task()
if(dst.end) break;
data.Skip(m_offset);
assert(m_offset % sizeof(u32) == 0);
data += m_offset / sizeof(u32);
}
// flush m_code_level

View file

@ -6,7 +6,7 @@
#include "RSXThread.h"
#include "Emu/SysCalls/lv2/sys_time.h"
#define ARGS(x) (x >= count ? OutOfArgsCount(x, cmd, count, args.GetAddr()) : args[x].ToLE())
#define ARGS(x) (x >= count ? OutOfArgsCount(x, cmd, count, args.addr()) : args[x].ToLE())
u32 methodRegisters[0xffff];
@ -45,8 +45,8 @@ u32 GetAddress(u32 offset, u8 location)
{
switch(location)
{
case CELL_GCM_LOCATION_LOCAL: return Memory.RSXFBMem.GetStartAddr() + offset;
case CELL_GCM_LOCATION_MAIN: return Memory.RSXIOMem.RealAddr(Memory.RSXIOMem.GetStartAddr() + offset); // TODO: Error Check?
case CELL_GCM_LOCATION_LOCAL: return (u32)Memory.RSXFBMem.GetStartAddr() + offset;
case CELL_GCM_LOCATION_MAIN: return (u32)Memory.RSXIOMem.RealAddr(Memory.RSXIOMem.GetStartAddr() + offset); // TODO: Error Check?
}
LOG_ERROR(RSX, "GetAddress(offset=0x%x, location=0x%x)", location);
@ -142,7 +142,7 @@ u32 RSXVertexData::GetTypeSize()
u32 RSXThread::OutOfArgsCount(const uint x, const u32 cmd, const u32 count, const u32 args_addr)
{
mem32_ptr_t args(args_addr);
auto args = vm::ptr<be_t<u32>>::make(args_addr);
std::string debug = GetMethodName(cmd);
debug += "(";
for(u32 i=0; i<count; ++i) debug += (i ? ", " : "") + fmt::Format("0x%x", ARGS(i));
@ -209,7 +209,7 @@ u32 RSXThread::OutOfArgsCount(const uint x, const u32 cmd, const u32 count, cons
void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, const u32 args_addr, const u32 count)
{
mem32_ptr_t args(args_addr);
auto args = vm::ptr<be_t<u32>>::make(args_addr);
#if CMD_DEBUG
std::string debug = GetMethodName(cmd);
@ -881,7 +881,7 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, const u32 args_addr, const
{
case 0:
{
int pos = m_indexed_array.m_data.size();
int pos = (int)m_indexed_array.m_data.size();
m_indexed_array.m_data.resize(m_indexed_array.m_data.size() + 4);
index = Memory.Read32(m_indexed_array.m_addr + i * 4);
*(u32*)&m_indexed_array.m_data[pos] = index;
@ -891,7 +891,7 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, const u32 args_addr, const
case 1:
{
int pos = m_indexed_array.m_data.size();
int pos = (int)m_indexed_array.m_data.size();
m_indexed_array.m_data.resize(m_indexed_array.m_data.size() + 2);
index = Memory.Read16(m_indexed_array.m_addr + i * 2);
//LOG_WARNING(RSX, "index 2: %d", index);
@ -1568,7 +1568,7 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, const u32 args_addr, const
case NV4097_SET_POLYGON_STIPPLE_PATTERN:
{
for (size_t i = 0; i < 32; i++)
for (u32 i = 0; i < 32; i++)
{
m_polygon_stipple_pattern[i] = ARGS(i);
}
@ -2234,14 +2234,14 @@ void RSXThread::Task()
continue;
}
mem32_ptr_t args((u32)Memory.RSXIOMem.RealAddr(Memory.RSXIOMem.GetStartAddr() + get + 4));
auto args = vm::ptr<be_t<u32>>::make((u32)Memory.RSXIOMem.RealAddr(Memory.RSXIOMem.GetStartAddr() + get + 4));
for(u32 i=0; i<count; i++)
{
methodRegisters[(cmd & 0xffff) + (i*4*inc)] = ARGS(i);
}
DoCmd(cmd, cmd & 0x3ffff, args.GetAddr(), count);
DoCmd(cmd, cmd & 0x3ffff, args.addr(), count);
m_ctrl->get = get + (count + 1) * 4;
//memset(Memory.GetMemFromAddr(p.m_ioAddress + get), 0, (count + 1) * 4);

View file

@ -153,7 +153,7 @@ __forceinline void Module::AddFuncSub(const char group[8], const u64 ops[], cons
{
SFuncOp op;
op.mask = ops[i] >> 32;
op.crc = ops[i];
op.crc = (u32)ops[i];
if (op.mask) op.crc &= op.mask;
op.mask = re(op.mask);
op.crc = re(op.crc);

View file

@ -85,9 +85,9 @@ u16 cellKbCnvRawCode(u32 arrange, u32 mkey, u32 led, u16 rawcode)
return 0x0000;
}
int cellKbGetInfo(mem_ptr_t<CellKbInfo> info)
int cellKbGetInfo(vm::ptr<CellKbInfo> info)
{
sys_io->Log("cellKbGetInfo(info_addr=0x%x)", info.GetAddr());
sys_io->Log("cellKbGetInfo(info_addr=0x%x)", info.addr());
if(!Emu.GetKeyboardManager().IsInited()) return CELL_KB_ERROR_UNINITIALIZED;
const KbInfo& current_info = Emu.GetKeyboardManager().GetInfo();
@ -102,9 +102,9 @@ int cellKbGetInfo(mem_ptr_t<CellKbInfo> info)
return CELL_OK;
}
int cellKbRead(u32 port_no, mem_ptr_t<CellKbData> data)
int cellKbRead(u32 port_no, vm::ptr<CellKbData> data)
{
sys_io->Log("cellKbRead(port_no=%d,info_addr=0x%x)", port_no, data.GetAddr());
sys_io->Log("cellKbRead(port_no=%d,info_addr=0x%x)", port_no, data.addr());
const std::vector<Keyboard>& keyboards = Emu.GetKeyboardManager().GetKeyboards();
if(!Emu.GetKeyboardManager().IsInited()) return CELL_KB_ERROR_UNINITIALIZED;
@ -151,9 +151,9 @@ int cellKbSetReadMode(u32 port_no, u32 rmode)
return CELL_OK;
}
int cellKbGetConfiguration(u32 port_no, mem_ptr_t<CellKbConfig> config)
int cellKbGetConfiguration(u32 port_no, vm::ptr<CellKbConfig> config)
{
sys_io->Log("cellKbGetConfiguration(port_no=%d,config_addr=0x%x)", port_no, config.GetAddr());
sys_io->Log("cellKbGetConfiguration(port_no=%d,config_addr=0x%x)", port_no, config.addr());
if(!Emu.GetKeyboardManager().IsInited()) return CELL_KB_ERROR_UNINITIALIZED;
const KbConfig& current_config = Emu.GetKeyboardManager().GetConfig(port_no);

View file

@ -43,9 +43,9 @@ int cellKbInit(u32 max_connect);
int cellKbEnd();
int cellKbClearBuf(u32 port_no);
u16 cellKbCnvRawCode(u32 arrange, u32 mkey, u32 led, u16 rawcode);
int cellKbGetInfo(mem_ptr_t<CellKbInfo> info);
int cellKbRead(u32 port_no, mem_ptr_t<CellKbData> data);
int cellKbGetInfo(vm::ptr<CellKbInfo> info);
int cellKbRead(u32 port_no, vm::ptr<CellKbData> data);
int cellKbSetCodeType(u32 port_no, u32 type);
int cellKbSetLEDStatus(u32 port_no, u8 led);
int cellKbSetReadMode(u32 port_no, u32 rmode);
int cellKbGetConfiguration(u32 port_no, mem_ptr_t<CellKbConfig> config);
int cellKbGetConfiguration(u32 port_no, vm::ptr<CellKbConfig> config);

View file

@ -38,9 +38,9 @@ int cellMouseEnd()
return CELL_OK;
}
int cellMouseGetInfo(mem_ptr_t<CellMouseInfo> info)
int cellMouseGetInfo(vm::ptr<CellMouseInfo> info)
{
sys_io->Log("cellMouseGetInfo(info_addr=0x%x)", info.GetAddr());
sys_io->Log("cellMouseGetInfo(info_addr=0x%x)", info.addr());
if(!Emu.GetMouseManager().IsInited()) return CELL_MOUSE_ERROR_UNINITIALIZED;
const MouseInfo& current_info = Emu.GetMouseManager().GetInfo();
@ -54,9 +54,9 @@ int cellMouseGetInfo(mem_ptr_t<CellMouseInfo> info)
return CELL_OK;
}
int cellMouseInfoTabletMode(u32 port_no, mem_ptr_t<CellMouseInfoTablet> info)
int cellMouseInfoTabletMode(u32 port_no, vm::ptr<CellMouseInfoTablet> info)
{
sys_io->Log("cellMouseInfoTabletMode(port_no=%d,info_addr=0x%x)", port_no, info.GetAddr());
sys_io->Log("cellMouseInfoTabletMode(port_no=%d,info_addr=0x%x)", port_no, info.addr());
if(!Emu.GetMouseManager().IsInited()) return CELL_MOUSE_ERROR_UNINITIALIZED;
if(port_no >= Emu.GetMouseManager().GetMice().size()) return CELL_MOUSE_ERROR_INVALID_PARAMETER;
@ -66,9 +66,9 @@ int cellMouseInfoTabletMode(u32 port_no, mem_ptr_t<CellMouseInfoTablet> info)
return CELL_OK;
}
int cellMouseGetData(u32 port_no, mem_ptr_t<CellMouseData> data)
int cellMouseGetData(u32 port_no, vm::ptr<CellMouseData> data)
{
sys_io->Log("cellMouseGetData(port_no=%d,data_addr=0x%x)", port_no, data.GetAddr());
sys_io->Log("cellMouseGetData(port_no=%d,data_addr=0x%x)", port_no, data.addr());
if(!Emu.GetMouseManager().IsInited()) return CELL_MOUSE_ERROR_UNINITIALIZED;
if(port_no >= Emu.GetMouseManager().GetMice().size()) return CELL_MOUSE_ERROR_NO_DEVICE;
@ -88,7 +88,7 @@ int cellMouseGetData(u32 port_no, mem_ptr_t<CellMouseData> data)
return CELL_OK;
}
int cellMouseGetDataList(u32 port_no, mem_ptr_t<CellMouseDataList> data)
int cellMouseGetDataList(u32 port_no, vm::ptr<CellMouseDataList> data)
{
UNIMPLEMENTED_FUNC(sys_io);
@ -113,7 +113,7 @@ int cellMouseGetRawData(u32 port_no, u32 data_addr)
{
UNIMPLEMENTED_FUNC(sys_io);
/*sys_io->Log("cellMouseGetRawData(port_no=%d,data_addr=0x%x)", port_no, data.GetAddr());
/*sys_io->Log("cellMouseGetRawData(port_no=%d,data_addr=0x%x)", port_no, data.addr());
if(!Emu.GetMouseManager().IsInited()) return CELL_MOUSE_ERROR_UNINITIALIZED;
if(port_no >= Emu.GetMouseManager().GetMice().size()) return CELL_MOUSE_ERROR_NO_DEVICE;

View file

@ -53,10 +53,10 @@ static const u32 CELL_MOUSE_MAX_CODES = 64;
int cellMouseInit(u32 max_connect);
int cellMouseClearBuf(u32 port_no);
int cellMouseEnd();
int cellMouseGetInfo(mem_ptr_t<CellMouseInfo> info);
int cellMouseInfoTabletMode(u32 port_no, mem_ptr_t<CellMouseInfoTablet> info);
int cellMouseGetData(u32 port_no, mem_ptr_t<CellMouseData> data);
int cellMouseGetDataList(u32 port_no, mem_ptr_t<CellMouseDataList> data);
int cellMouseGetInfo(vm::ptr<CellMouseInfo> info);
int cellMouseInfoTabletMode(u32 port_no, vm::ptr<CellMouseInfoTablet> info);
int cellMouseGetData(u32 port_no, vm::ptr<CellMouseData> data);
int cellMouseGetDataList(u32 port_no, vm::ptr<CellMouseDataList> data);
int cellMouseSetTabletMode(u32 port_no, u32 mode);
int cellMouseGetTabletDataList(u32 port_no, u32 data_addr);
int cellMouseGetRawData(u32 port_no, u32 data_addr);

View file

@ -359,9 +359,9 @@ int cellPadGetInfo2(u32 info_addr)
return CELL_OK;
}
int cellPadGetCapabilityInfo(u32 port_no, mem32_t info_addr)
int cellPadGetCapabilityInfo(u32 port_no, vm::ptr<be_t<u32>> info_addr)
{
sys_io->Log("cellPadGetCapabilityInfo[port_no: %d, data_addr: 0x%x]", port_no, info_addr.GetAddr());
sys_io->Log("cellPadGetCapabilityInfo[port_no: %d, data_addr: 0x%x]", port_no, info_addr.addr());
if (!Emu.GetPadManager().IsInited()) return CELL_PAD_ERROR_UNINITIALIZED;
const PadInfo& rinfo = Emu.GetPadManager().GetInfo();
if (port_no >= rinfo.max_connect) return CELL_PAD_ERROR_INVALID_PARAMETER;
@ -374,7 +374,7 @@ int cellPadGetCapabilityInfo(u32 port_no, mem32_t info_addr)
//Should return the same as device capability mask, psl1ght has it backwards in pad.h
data.info[0] = pads[port_no].m_device_capability;
Memory.WriteData(info_addr.GetAddr(), data);
Memory.WriteData(info_addr.addr(), data);
return CELL_OK;
}

View file

@ -600,9 +600,9 @@ bool adecCheckType(AudioCodecType type)
return true;
}
int cellAdecQueryAttr(mem_ptr_t<CellAdecType> type, mem_ptr_t<CellAdecAttr> attr)
int cellAdecQueryAttr(vm::ptr<CellAdecType> type, vm::ptr<CellAdecAttr> attr)
{
cellAdec->Warning("cellAdecQueryAttr(type_addr=0x%x, attr_addr=0x%x)", type.GetAddr(), attr.GetAddr());
cellAdec->Warning("cellAdecQueryAttr(type_addr=0x%x, attr_addr=0x%x)", type.addr(), attr.addr());
if (!adecCheckType(type->audioCodecType)) return CELL_ADEC_ERROR_ARG;
@ -614,26 +614,26 @@ int cellAdecQueryAttr(mem_ptr_t<CellAdecType> type, mem_ptr_t<CellAdecAttr> attr
return CELL_OK;
}
int cellAdecOpen(mem_ptr_t<CellAdecType> type, mem_ptr_t<CellAdecResource> res, mem_ptr_t<CellAdecCb> cb, mem32_t handle)
int cellAdecOpen(vm::ptr<CellAdecType> type, vm::ptr<CellAdecResource> res, vm::ptr<CellAdecCb> cb, vm::ptr<be_t<u32>> handle)
{
cellAdec->Warning("cellAdecOpen(type_addr=0x%x, res_addr=0x%x, cb_addr=0x%x, handle_addr=0x%x)",
type.GetAddr(), res.GetAddr(), cb.GetAddr(), handle.GetAddr());
type.addr(), res.addr(), cb.addr(), handle.addr());
if (!adecCheckType(type->audioCodecType)) return CELL_ADEC_ERROR_ARG;
handle = adecOpen(new AudioDecoder(type->audioCodecType, res->startAddr, res->totalMemSize, cb->cbFunc, cb->cbArg));
*handle = adecOpen(new AudioDecoder(type->audioCodecType, res->startAddr, res->totalMemSize, cb->cbFunc, cb->cbArg));
return CELL_OK;
}
int cellAdecOpenEx(mem_ptr_t<CellAdecType> type, mem_ptr_t<CellAdecResourceEx> res, mem_ptr_t<CellAdecCb> cb, mem32_t handle)
int cellAdecOpenEx(vm::ptr<CellAdecType> type, vm::ptr<CellAdecResourceEx> res, vm::ptr<CellAdecCb> cb, vm::ptr<be_t<u32>> handle)
{
cellAdec->Warning("cellAdecOpenEx(type_addr=0x%x, res_addr=0x%x, cb_addr=0x%x, handle_addr=0x%x)",
type.GetAddr(), res.GetAddr(), cb.GetAddr(), handle.GetAddr());
type.addr(), res.addr(), cb.addr(), handle.addr());
if (!adecCheckType(type->audioCodecType)) return CELL_ADEC_ERROR_ARG;
handle = adecOpen(new AudioDecoder(type->audioCodecType, res->startAddr, res->totalMemSize, cb->cbFunc, cb->cbArg));
*handle = adecOpen(new AudioDecoder(type->audioCodecType, res->startAddr, res->totalMemSize, cb->cbFunc, cb->cbArg));
return CELL_OK;
}
@ -703,9 +703,9 @@ int cellAdecEndSeq(u32 handle)
return CELL_OK;
}
int cellAdecDecodeAu(u32 handle, mem_ptr_t<CellAdecAuInfo> auInfo)
int cellAdecDecodeAu(u32 handle, vm::ptr<CellAdecAuInfo> auInfo)
{
cellAdec->Log("cellAdecDecodeAu(handle=%d, auInfo_addr=0x%x)", handle, auInfo.GetAddr());
cellAdec->Log("cellAdecDecodeAu(handle=%d, auInfo_addr=0x%x)", handle, auInfo.addr());
AudioDecoder* adec;
if (!Emu.GetIdManager().GetIDData(handle, adec))
@ -714,7 +714,7 @@ int cellAdecDecodeAu(u32 handle, mem_ptr_t<CellAdecAuInfo> auInfo)
}
AdecTask task(adecDecodeAu);
task.au.auInfo_addr = auInfo.GetAddr();
task.au.auInfo_addr = auInfo.addr();
task.au.addr = auInfo->startAddr;
task.au.size = auInfo->size;
task.au.pts = ((u64)auInfo->pts.upper << 32) | (u64)auInfo->pts.lower;
@ -767,9 +767,9 @@ int cellAdecGetPcm(u32 handle, u32 outBuffer_addr)
return CELL_OK;
}
int cellAdecGetPcmItem(u32 handle, mem32_t pcmItem_ptr)
int cellAdecGetPcmItem(u32 handle, vm::ptr<be_t<u32>> pcmItem_ptr)
{
cellAdec->Log("cellAdecGetPcmItem(handle=%d, pcmItem_ptr_addr=0x%x)", handle, pcmItem_ptr.GetAddr());
cellAdec->Log("cellAdecGetPcmItem(handle=%d, pcmItem_ptr_addr=0x%x)", handle, pcmItem_ptr.addr());
AudioDecoder* adec;
if (!Emu.GetIdManager().GetIDData(handle, adec))
@ -787,7 +787,7 @@ int cellAdecGetPcmItem(u32 handle, mem32_t pcmItem_ptr)
AVFrame* frame = af.data;
mem_ptr_t<CellAdecPcmItem> pcm(adec->memAddr + adec->memBias);
auto pcm = vm::ptr<CellAdecPcmItem>::make(adec->memAddr + adec->memBias);
adec->memBias += 512;
if (adec->memBias + 512 > adec->memSize)
@ -796,22 +796,22 @@ int cellAdecGetPcmItem(u32 handle, mem32_t pcmItem_ptr)
}
pcm->pcmHandle = 0; // ???
pcm->pcmAttr.bsiInfo_addr = pcm.GetAddr() + sizeof(CellAdecPcmItem);
pcm->pcmAttr.bsiInfo_addr = pcm.addr() + sizeof(CellAdecPcmItem);
pcm->startAddr = 0x00000312; // invalid address (no output)
pcm->size = af.size;
pcm->status = CELL_OK;
pcm->auInfo.pts.lower = af.pts;
pcm->auInfo.pts.lower = (u32)af.pts;
pcm->auInfo.pts.upper = af.pts >> 32;
pcm->auInfo.size = af.auSize;
pcm->auInfo.startAddr = af.auAddr;
pcm->auInfo.userData = af.userdata;
mem_ptr_t<CellAdecAtracXInfo> atx(pcm.GetAddr() + sizeof(CellAdecPcmItem));
auto atx = vm::ptr<CellAdecAtracXInfo>::make(pcm.addr() + sizeof(CellAdecPcmItem));
atx->samplingFreq = frame->sample_rate; // ???
atx->nbytes = frame->nb_samples * frame->channels * sizeof(float); // ???
atx->channelConfigIndex = CELL_ADEC_CH_STEREO; // ???
pcmItem_ptr = pcm.GetAddr();
*pcmItem_ptr = pcm.addr();
return CELL_OK;
}

View file

@ -360,7 +360,7 @@ enum CellAdecMsgType
CELL_ADEC_MSG_TYPE_SEQDONE,
};
typedef mem_func_ptr_t<int (*)(u32 handle, CellAdecMsgType msgType, int msgData, u32 cbArg)> CellAdecCbMsg;
typedef s32(*CellAdecCbMsg)(u32 handle, CellAdecMsgType msgType, int msgData, u32 cbArg);
struct CellAdecCb
{

View file

@ -6,179 +6,179 @@ Module *cellAtrac = nullptr;
#include "cellAtrac.h"
int cellAtracSetDataAndGetMemSize(mem_ptr_t<CellAtracHandle> pHandle, u32 pucBufferAddr, u32 uiReadByte, u32 uiBufferByte, mem32_t puiWorkMemByte)
int cellAtracSetDataAndGetMemSize(vm::ptr<CellAtracHandle> pHandle, u32 pucBufferAddr, u32 uiReadByte, u32 uiBufferByte, vm::ptr<be_t<u32>> puiWorkMemByte)
{
cellAtrac->Todo("cellAtracSetDataAndGetMemSize(pHandle=0x%x, pucBufferAddr=0x%x, uiReadByte=0x%x, uiBufferByte=0x%x, puiWorkMemByte_addr=0x%x)",
pHandle.GetAddr(), pucBufferAddr, uiReadByte, uiBufferByte, puiWorkMemByte.GetAddr());
pHandle.addr(), pucBufferAddr, uiReadByte, uiBufferByte, puiWorkMemByte.addr());
puiWorkMemByte = 0x1000; // unproved
*puiWorkMemByte = 0x1000; // unproved
return CELL_OK;
}
int cellAtracCreateDecoder(mem_ptr_t<CellAtracHandle> pHandle, u32 pucWorkMem_addr, u32 uiPpuThreadPriority, u32 uiSpuThreadPriority)
int cellAtracCreateDecoder(vm::ptr<CellAtracHandle> pHandle, u32 pucWorkMem_addr, u32 uiPpuThreadPriority, u32 uiSpuThreadPriority)
{
cellAtrac->Todo("cellAtracCreateDecoder(pHandle=0x%x, pucWorkMem_addr=0x%x, uiPpuThreadPriority=%d, uiSpuThreadPriority=%d)",
pHandle.GetAddr(), pucWorkMem_addr, uiPpuThreadPriority, uiSpuThreadPriority);
pHandle.addr(), pucWorkMem_addr, uiPpuThreadPriority, uiSpuThreadPriority);
pHandle->data.pucWorkMem_addr = pucWorkMem_addr;
return CELL_OK;
}
int cellAtracCreateDecoderExt(mem_ptr_t<CellAtracHandle> pHandle, u32 pucWorkMem_addr, u32 uiPpuThreadPriority, mem_ptr_t<CellAtracExtRes> pExtRes)
int cellAtracCreateDecoderExt(vm::ptr<CellAtracHandle> pHandle, u32 pucWorkMem_addr, u32 uiPpuThreadPriority, vm::ptr<CellAtracExtRes> pExtRes)
{
cellAtrac->Todo("cellAtracCreateDecoderExt(pHandle=0x%x, pucWorkMem_addr=0x%x, uiPpuThreadPriority=%d, pExtRes_addr=0x%x)",
pHandle.GetAddr(), pucWorkMem_addr, uiPpuThreadPriority, pExtRes.GetAddr());
pHandle.addr(), pucWorkMem_addr, uiPpuThreadPriority, pExtRes.addr());
pHandle->data.pucWorkMem_addr = pucWorkMem_addr;
return CELL_OK;
}
int cellAtracDeleteDecoder(mem_ptr_t<CellAtracHandle> pHandle)
int cellAtracDeleteDecoder(vm::ptr<CellAtracHandle> pHandle)
{
cellAtrac->Todo("cellAtracDeleteDecoder(pHandle=0x%x)", pHandle.GetAddr());
cellAtrac->Todo("cellAtracDeleteDecoder(pHandle=0x%x)", pHandle.addr());
return CELL_OK;
}
int cellAtracDecode(mem_ptr_t<CellAtracHandle> pHandle, u32 pfOutAddr, mem32_t puiSamples, mem32_t puiFinishflag, mem32_t piRemainFrame)
int cellAtracDecode(vm::ptr<CellAtracHandle> pHandle, u32 pfOutAddr, vm::ptr<be_t<u32>> puiSamples, vm::ptr<be_t<u32>> puiFinishflag, vm::ptr<be_t<u32>> piRemainFrame)
{
cellAtrac->Todo("cellAtracDecode(pHandle=0x%x, pfOutAddr=0x%x, puiSamples_addr=0x%x, puiFinishFlag_addr=0x%x, piRemainFrame_addr=0x%x)",
pHandle.GetAddr(), pfOutAddr, puiSamples.GetAddr(), puiFinishflag.GetAddr(), piRemainFrame.GetAddr());
pHandle.addr(), pfOutAddr, puiSamples.addr(), puiFinishflag.addr(), piRemainFrame.addr());
puiSamples = 0;
puiFinishflag = 1;
piRemainFrame = CELL_ATRAC_ALLDATA_IS_ON_MEMORY;
*puiSamples = 0;
*puiFinishflag = 1;
*piRemainFrame = CELL_ATRAC_ALLDATA_IS_ON_MEMORY;
return CELL_OK;
}
int cellAtracGetStreamDataInfo(mem_ptr_t<CellAtracHandle> pHandle, mem32_t ppucWritePointer, mem32_t puiWritableByte, mem32_t puiReadPosition)
int cellAtracGetStreamDataInfo(vm::ptr<CellAtracHandle> pHandle, vm::ptr<be_t<u32>> ppucWritePointer, vm::ptr<be_t<u32>> puiWritableByte, vm::ptr<be_t<u32>> puiReadPosition)
{
cellAtrac->Todo("cellAtracGetStreamDataInfo(pHandle=0x%x, ppucWritePointer_addr=0x%x, puiWritableByte_addr=0x%x, puiReadPosition_addr=0x%x)",
pHandle.GetAddr(), ppucWritePointer.GetAddr(), puiWritableByte.GetAddr(), puiReadPosition.GetAddr());
pHandle.addr(), ppucWritePointer.addr(), puiWritableByte.addr(), puiReadPosition.addr());
ppucWritePointer = pHandle->data.pucWorkMem_addr;
puiWritableByte = 0x1000;
puiReadPosition = 0;
*ppucWritePointer = pHandle->data.pucWorkMem_addr;
*puiWritableByte = 0x1000;
*puiReadPosition = 0;
return CELL_OK;
}
int cellAtracAddStreamData(mem_ptr_t<CellAtracHandle> pHandle, u32 uiAddByte)
int cellAtracAddStreamData(vm::ptr<CellAtracHandle> pHandle, u32 uiAddByte)
{
cellAtrac->Todo("cellAtracAddStreamData(pHandle=0x%x, uiAddByte=0x%x)", pHandle.GetAddr(), uiAddByte);
cellAtrac->Todo("cellAtracAddStreamData(pHandle=0x%x, uiAddByte=0x%x)", pHandle.addr(), uiAddByte);
return CELL_OK;
}
int cellAtracGetRemainFrame(mem_ptr_t<CellAtracHandle> pHandle, mem32_t piRemainFrame)
int cellAtracGetRemainFrame(vm::ptr<CellAtracHandle> pHandle, vm::ptr<be_t<u32>> piRemainFrame)
{
cellAtrac->Todo("cellAtracGetRemainFrame(pHandle=0x%x, piRemainFrame_addr=0x%x)", pHandle.GetAddr(), piRemainFrame.GetAddr());
cellAtrac->Todo("cellAtracGetRemainFrame(pHandle=0x%x, piRemainFrame_addr=0x%x)", pHandle.addr(), piRemainFrame.addr());
piRemainFrame = CELL_ATRAC_ALLDATA_IS_ON_MEMORY;
*piRemainFrame = CELL_ATRAC_ALLDATA_IS_ON_MEMORY;
return CELL_OK;
}
int cellAtracGetVacantSize(mem_ptr_t<CellAtracHandle> pHandle, mem32_t puiVacantSize)
int cellAtracGetVacantSize(vm::ptr<CellAtracHandle> pHandle, vm::ptr<be_t<u32>> puiVacantSize)
{
cellAtrac->Todo("cellAtracGetVacantSize(pHandle=0x%x, puiVacantSize_addr=0x%x)", pHandle.GetAddr(), puiVacantSize.GetAddr());
cellAtrac->Todo("cellAtracGetVacantSize(pHandle=0x%x, puiVacantSize_addr=0x%x)", pHandle.addr(), puiVacantSize.addr());
puiVacantSize = 0x1000;
*puiVacantSize = 0x1000;
return CELL_OK;
}
int cellAtracIsSecondBufferNeeded(mem_ptr_t<CellAtracHandle> pHandle)
int cellAtracIsSecondBufferNeeded(vm::ptr<CellAtracHandle> pHandle)
{
cellAtrac->Todo("cellAtracIsSecondBufferNeeded(pHandle=0x%x)", pHandle.GetAddr());
cellAtrac->Todo("cellAtracIsSecondBufferNeeded(pHandle=0x%x)", pHandle.addr());
return CELL_OK;
}
int cellAtracGetSecondBufferInfo(mem_ptr_t<CellAtracHandle> pHandle, mem32_t puiReadPosition, mem32_t puiDataByte)
int cellAtracGetSecondBufferInfo(vm::ptr<CellAtracHandle> pHandle, vm::ptr<be_t<u32>> puiReadPosition, vm::ptr<be_t<u32>> puiDataByte)
{
cellAtrac->Todo("cellAtracGetSecondBufferInfo(pHandle=0x%x, puiReadPosition_addr=0x%x, puiDataByte_addr=0x%x)",
pHandle.GetAddr(), puiReadPosition.GetAddr(), puiDataByte.GetAddr());
pHandle.addr(), puiReadPosition.addr(), puiDataByte.addr());
puiReadPosition = 0;
puiDataByte = 0; // write to null block will occur
*puiReadPosition = 0;
*puiDataByte = 0; // write to null block will occur
return CELL_OK;
}
int cellAtracSetSecondBuffer(mem_ptr_t<CellAtracHandle> pHandle, u32 pucSecondBufferAddr, u32 uiSecondBufferByte)
int cellAtracSetSecondBuffer(vm::ptr<CellAtracHandle> pHandle, u32 pucSecondBufferAddr, u32 uiSecondBufferByte)
{
cellAtrac->Todo("cellAtracSetSecondBuffer(pHandle=0x%x, pucSecondBufferAddr=0x%x, uiSecondBufferByte=0x%x)",
pHandle.GetAddr(), pucSecondBufferAddr, uiSecondBufferByte);
pHandle.addr(), pucSecondBufferAddr, uiSecondBufferByte);
return CELL_OK;
}
int cellAtracGetChannel(mem_ptr_t<CellAtracHandle> pHandle, mem32_t puiChannel)
int cellAtracGetChannel(vm::ptr<CellAtracHandle> pHandle, vm::ptr<be_t<u32>> puiChannel)
{
cellAtrac->Todo("cellAtracGetChannel(pHandle=0x%x, puiChannel_addr=0x%x)", pHandle.GetAddr(), puiChannel.GetAddr());
cellAtrac->Todo("cellAtracGetChannel(pHandle=0x%x, puiChannel_addr=0x%x)", pHandle.addr(), puiChannel.addr());
puiChannel = 2;
*puiChannel = 2;
return CELL_OK;
}
int cellAtracGetMaxSample(mem_ptr_t<CellAtracHandle> pHandle, mem32_t puiMaxSample)
int cellAtracGetMaxSample(vm::ptr<CellAtracHandle> pHandle, vm::ptr<be_t<u32>> puiMaxSample)
{
cellAtrac->Todo("cellAtracGetMaxSample(pHandle=0x%x, puiMaxSample_addr=0x%x)", pHandle.GetAddr(), puiMaxSample.GetAddr());
cellAtrac->Todo("cellAtracGetMaxSample(pHandle=0x%x, puiMaxSample_addr=0x%x)", pHandle.addr(), puiMaxSample.addr());
puiMaxSample = 512;
*puiMaxSample = 512;
return CELL_OK;
}
int cellAtracGetNextSample(mem_ptr_t<CellAtracHandle> pHandle, mem32_t puiNextSample)
int cellAtracGetNextSample(vm::ptr<CellAtracHandle> pHandle, vm::ptr<be_t<u32>> puiNextSample)
{
cellAtrac->Todo("cellAtracGetNextSample(pHandle=0x%x, puiNextSample_addr=0x%x)", pHandle.GetAddr(), puiNextSample.GetAddr());
cellAtrac->Todo("cellAtracGetNextSample(pHandle=0x%x, puiNextSample_addr=0x%x)", pHandle.addr(), puiNextSample.addr());
puiNextSample = 0;
*puiNextSample = 0;
return CELL_OK;
}
int cellAtracGetSoundInfo(mem_ptr_t<CellAtracHandle> pHandle, mem32_t piEndSample, mem32_t piLoopStartSample, mem32_t piLoopEndSample)
int cellAtracGetSoundInfo(vm::ptr<CellAtracHandle> pHandle, vm::ptr<be_t<u32>> piEndSample, vm::ptr<be_t<u32>> piLoopStartSample, vm::ptr<be_t<u32>> piLoopEndSample)
{
cellAtrac->Todo("cellAtracGetSoundInfo(pHandle=0x%x, piEndSample_addr=0x%x, piLoopStartSample_addr=0x%x, piLoopEndSample_addr=0x%x)",
pHandle.GetAddr(), piEndSample.GetAddr(), piLoopStartSample.GetAddr(), piLoopEndSample.GetAddr());
pHandle.addr(), piEndSample.addr(), piLoopStartSample.addr(), piLoopEndSample.addr());
piEndSample = 0;
piLoopStartSample = 0;
piLoopEndSample = 0;
*piEndSample = 0;
*piLoopStartSample = 0;
*piLoopEndSample = 0;
return CELL_OK;
}
int cellAtracGetNextDecodePosition(mem_ptr_t<CellAtracHandle> pHandle, mem32_t puiSamplePosition)
int cellAtracGetNextDecodePosition(vm::ptr<CellAtracHandle> pHandle, vm::ptr<be_t<u32>> puiSamplePosition)
{
cellAtrac->Todo("cellAtracGetNextDecodePosition(pHandle=0x%x, puiSamplePosition_addr=0x%x)",
pHandle.GetAddr(), puiSamplePosition.GetAddr());
pHandle.addr(), puiSamplePosition.addr());
puiSamplePosition = 0;
*puiSamplePosition = 0;
return CELL_ATRAC_ERROR_ALLDATA_WAS_DECODED;
}
int cellAtracGetBitrate(mem_ptr_t<CellAtracHandle> pHandle, mem32_t puiBitrate)
int cellAtracGetBitrate(vm::ptr<CellAtracHandle> pHandle, vm::ptr<be_t<u32>> puiBitrate)
{
cellAtrac->Todo("cellAtracGetBitrate(pHandle=0x%x, puiBitrate_addr=0x%x)",
pHandle.GetAddr(), puiBitrate.GetAddr());
pHandle.addr(), puiBitrate.addr());
puiBitrate = 128;
*puiBitrate = 128;
return CELL_OK;
}
int cellAtracGetLoopInfo(mem_ptr_t<CellAtracHandle> pHandle, mem32_t piLoopNum, mem32_t puiLoopStatus)
int cellAtracGetLoopInfo(vm::ptr<CellAtracHandle> pHandle, vm::ptr<be_t<u32>> piLoopNum, vm::ptr<be_t<u32>> puiLoopStatus)
{
cellAtrac->Todo("cellAtracGetLoopInfo(pHandle=0x%x, piLoopNum_addr=0x%x, puiLoopStatus_addr=0x%x)",
pHandle.GetAddr(), piLoopNum.GetAddr(), puiLoopStatus.GetAddr());
pHandle.addr(), piLoopNum.addr(), puiLoopStatus.addr());
piLoopNum = 0;
puiLoopStatus = 0;
*piLoopNum = 0;
*puiLoopStatus = 0;
return CELL_OK;
}
int cellAtracSetLoopNum(mem_ptr_t<CellAtracHandle> pHandle, int iLoopNum)
int cellAtracSetLoopNum(vm::ptr<CellAtracHandle> pHandle, int iLoopNum)
{
cellAtrac->Todo("cellAtracSetLoopNum(pHandle=0x%x, iLoopNum=0x%x)", pHandle.GetAddr(), iLoopNum);
cellAtrac->Todo("cellAtracSetLoopNum(pHandle=0x%x, iLoopNum=0x%x)", pHandle.addr(), iLoopNum);
return CELL_OK;
}
int cellAtracGetBufferInfoForResetting(mem_ptr_t<CellAtracHandle> pHandle, u32 uiSample, mem_ptr_t<CellAtracBufferInfo> pBufferInfo)
int cellAtracGetBufferInfoForResetting(vm::ptr<CellAtracHandle> pHandle, u32 uiSample, vm::ptr<CellAtracBufferInfo> pBufferInfo)
{
cellAtrac->Todo("cellAtracGetBufferInfoForResetting(pHandle=0x%x, uiSample=0x%x, pBufferInfo_addr=0x%x)",
pHandle.GetAddr(), uiSample, pBufferInfo.GetAddr());
pHandle.addr(), uiSample, pBufferInfo.addr());
pBufferInfo->pucWriteAddr = pHandle->data.pucWorkMem_addr;
pBufferInfo->uiWritableByte = 0x1000;
@ -187,19 +187,19 @@ int cellAtracGetBufferInfoForResetting(mem_ptr_t<CellAtracHandle> pHandle, u32 u
return CELL_OK;
}
int cellAtracResetPlayPosition(mem_ptr_t<CellAtracHandle> pHandle, u32 uiSample, u32 uiWriteByte)
int cellAtracResetPlayPosition(vm::ptr<CellAtracHandle> pHandle, u32 uiSample, u32 uiWriteByte)
{
cellAtrac->Todo("cellAtracResetPlayPosition(pHandle=0x%x, uiSample=0x%x, uiWriteByte=0x%x)",
pHandle.GetAddr(), uiSample, uiWriteByte);
pHandle.addr(), uiSample, uiWriteByte);
return CELL_OK;
}
int cellAtracGetInternalErrorInfo(mem_ptr_t<CellAtracHandle> pHandle, mem32_t piResult)
int cellAtracGetInternalErrorInfo(vm::ptr<CellAtracHandle> pHandle, vm::ptr<be_t<u32>> piResult)
{
cellAtrac->Todo("cellAtracGetInternalErrorInfo(pHandle=0x%x, piResult_addr=0x%x)",
pHandle.GetAddr(), piResult.GetAddr());
pHandle.addr(), piResult.addr());
piResult = 0;
*piResult = 0;
return CELL_OK;
}

View file

@ -39,9 +39,9 @@ int cellAudioInit()
m_config.counter = 0;
// alloc memory
m_config.m_buffer = Memory.Alloc(128 * 1024 * m_config.AUDIO_PORT_COUNT, 1024);
m_config.m_buffer = (u32)Memory.Alloc(128 * 1024 * m_config.AUDIO_PORT_COUNT, 1024);
memset(Memory + m_config.m_buffer, 0, 128 * 1024 * m_config.AUDIO_PORT_COUNT);
m_config.m_indexes = Memory.Alloc(sizeof(u64) * m_config.AUDIO_PORT_COUNT, 16);
m_config.m_indexes = (u32)Memory.Alloc(sizeof(u64) * m_config.AUDIO_PORT_COUNT, 16);
memset(Memory + m_config.m_indexes, 0, sizeof(u64) * m_config.AUDIO_PORT_COUNT);
thread t("Audio Thread", []()
@ -387,17 +387,17 @@ int cellAudioInit()
{
std::lock_guard<std::mutex> lock(audioMutex);
// update indexes:
auto indexes = vm::ptr<be_t<u64>>::make(m_config.m_indexes);
for (u32 i = 0; i < m_config.AUDIO_PORT_COUNT; i++)
{
if (!m_config.m_ports[i].m_is_audio_port_started) continue;
AudioPortConfig& port = m_config.m_ports[i];
mem64_t index(m_config.m_indexes + i * sizeof(u64));
u32 position = port.tag % port.block; // old value
port.counter = m_config.counter;
port.tag++; // absolute index of block that will be read
index = (position + 1) % port.block; // write new value
indexes[i] = (position + 1) % port.block; // write new value
}
// load keys:
keys.resize(m_config.m_keys.size());
@ -507,9 +507,9 @@ int cellAudioQuit()
return CELL_OK;
}
int cellAudioPortOpen(mem_ptr_t<CellAudioPortParam> audioParam, mem32_t portNum)
int cellAudioPortOpen(vm::ptr<CellAudioPortParam> audioParam, vm::ptr<be_t<u32>> portNum)
{
cellAudio->Warning("cellAudioPortOpen(audioParam_addr=0x%x, portNum_addr=0x%x)", audioParam.GetAddr(), portNum.GetAddr());
cellAudio->Warning("cellAudioPortOpen(audioParam_addr=0x%x, portNum_addr=0x%x)", audioParam.addr(), portNum.addr());
if (audioParam->nChannel > 8 || audioParam->nBlock > 16)
{
@ -527,8 +527,8 @@ int cellAudioPortOpen(mem_ptr_t<CellAudioPortParam> audioParam, mem32_t portNum)
{
AudioPortConfig& port = m_config.m_ports[i];
port.channel = audioParam->nChannel;
port.block = audioParam->nBlock;
port.channel = (u8)audioParam->nChannel;
port.block = (u8)audioParam->nBlock;
port.attr = audioParam->attr;
if (port.attr & CELL_AUDIO_PORTATTR_INITLEVEL)
{
@ -539,7 +539,7 @@ int cellAudioPortOpen(mem_ptr_t<CellAudioPortParam> audioParam, mem32_t portNum)
port.level = 1.0f;
}
portNum = i;
*portNum = i;
cellAudio->Warning("*** audio port opened(nChannel=%d, nBlock=%d, attr=0x%llx, level=%f): port = %d",
port.channel, port.block, port.attr, port.level, i);
@ -555,9 +555,9 @@ int cellAudioPortOpen(mem_ptr_t<CellAudioPortParam> audioParam, mem32_t portNum)
return CELL_AUDIO_ERROR_PORT_FULL;
}
int cellAudioGetPortConfig(u32 portNum, mem_ptr_t<CellAudioPortConfig> portConfig)
int cellAudioGetPortConfig(u32 portNum, vm::ptr<CellAudioPortConfig> portConfig)
{
cellAudio->Warning("cellAudioGetPortConfig(portNum=0x%x, portConfig_addr=0x%x)", portNum, portConfig.GetAddr());
cellAudio->Warning("cellAudioGetPortConfig(portNum=0x%x, portConfig_addr=0x%x)", portNum, portConfig.addr());
if (portNum >= m_config.AUDIO_PORT_COUNT)
{
@ -659,9 +659,9 @@ int cellAudioPortStop(u32 portNum)
return CELL_OK;
}
int cellAudioGetPortTimestamp(u32 portNum, u64 tag, mem64_t stamp)
int cellAudioGetPortTimestamp(u32 portNum, u64 tag, vm::ptr<be_t<u64>> stamp)
{
cellAudio->Log("cellAudioGetPortTimestamp(portNum=0x%x, tag=0x%llx, stamp_addr=0x%x)", portNum, tag, stamp.GetAddr());
cellAudio->Log("cellAudioGetPortTimestamp(portNum=0x%x, tag=0x%llx, stamp_addr=0x%x)", portNum, tag, stamp.addr());
if (portNum >= m_config.AUDIO_PORT_COUNT)
{
@ -682,14 +682,14 @@ int cellAudioGetPortTimestamp(u32 portNum, u64 tag, mem64_t stamp)
std::lock_guard<std::mutex> lock(audioMutex);
stamp = m_config.start_time + (port.counter + (tag - port.tag)) * 256000000 / 48000;
*stamp = m_config.start_time + (port.counter + (tag - port.tag)) * 256000000 / 48000;
return CELL_OK;
}
int cellAudioGetPortBlockTag(u32 portNum, u64 blockNo, mem64_t tag)
int cellAudioGetPortBlockTag(u32 portNum, u64 blockNo, vm::ptr<be_t<u64>> tag)
{
cellAudio->Log("cellAudioGetPortBlockTag(portNum=0x%x, blockNo=0x%llx, tag_addr=0x%x)", portNum, blockNo, tag.GetAddr());
cellAudio->Log("cellAudioGetPortBlockTag(portNum=0x%x, blockNo=0x%llx, tag_addr=0x%x)", portNum, blockNo, tag.addr());
if (portNum >= m_config.AUDIO_PORT_COUNT)
{
@ -726,7 +726,7 @@ int cellAudioGetPortBlockTag(u32 portNum, u64 blockNo, mem64_t tag)
{
tag_base &= ~(port.block-1);
}
tag = tag_base + blockNo;
*tag = tag_base + blockNo;
return CELL_OK;
}
@ -738,9 +738,9 @@ int cellAudioSetPortLevel(u32 portNum, float level)
}
// Utility Functions
int cellAudioCreateNotifyEventQueue(mem32_t id, mem64_t key)
int cellAudioCreateNotifyEventQueue(vm::ptr<be_t<u32>> id, vm::ptr<be_t<u64>> key)
{
cellAudio->Warning("cellAudioCreateNotifyEventQueue(id_addr=0x%x, key_addr=0x%x)", id.GetAddr(), key.GetAddr());
cellAudio->Warning("cellAudioCreateNotifyEventQueue(id_addr=0x%x, key_addr=0x%x)", id.addr(), key.addr());
std::lock_guard<std::mutex> lock(audioMutex);
@ -760,15 +760,15 @@ int cellAudioCreateNotifyEventQueue(mem32_t id, mem64_t key)
return CELL_AUDIO_ERROR_EVENT_QUEUE;
}
id = cellAudio->GetNewId(eq);
key = event_key;
*id = cellAudio->GetNewId(eq);
*key = event_key;
return CELL_OK;
}
int cellAudioCreateNotifyEventQueueEx(mem32_t id, mem64_t key, u32 iFlags)
int cellAudioCreateNotifyEventQueueEx(vm::ptr<be_t<u32>> id, vm::ptr<be_t<u64>> key, u32 iFlags)
{
cellAudio->Todo("cellAudioCreateNotifyEventQueueEx(id_addr=0x%x, key_addr=0x%x, iFlags=0x%x)", id.GetAddr(), key.GetAddr(), iFlags);
cellAudio->Todo("cellAudioCreateNotifyEventQueueEx(id_addr=0x%x, key_addr=0x%x, iFlags=0x%x)", id.addr(), key.addr(), iFlags);
return CELL_OK;
}
@ -844,21 +844,21 @@ int cellAudioRemoveNotifyEventQueueEx(u64 key, u32 iFlags)
return CELL_OK;
}
int cellAudioAddData(u32 portNum, mem32_t src, u32 samples, float volume)
int cellAudioAddData(u32 portNum, vm::ptr<be_t<float>> src, u32 samples, float volume)
{
cellAudio->Todo("cellAudioAddData(portNum=0x%x, src_addr=0x%x, samples=%d, volume=%f)", portNum, src.GetAddr(), samples, volume);
cellAudio->Todo("cellAudioAddData(portNum=0x%x, src_addr=0x%x, samples=%d, volume=%f)", portNum, src.addr(), samples, volume);
return CELL_OK;
}
int cellAudioAdd2chData(u32 portNum, mem32_t src, u32 samples, float volume)
int cellAudioAdd2chData(u32 portNum, vm::ptr<be_t<float>> src, u32 samples, float volume)
{
cellAudio->Todo("cellAudioAdd2chData(portNum=0x%x, src_addr=0x%x, samples=%d, volume=%f)", portNum, src.GetAddr(), samples, volume);
cellAudio->Todo("cellAudioAdd2chData(portNum=0x%x, src_addr=0x%x, samples=%d, volume=%f)", portNum, src.addr(), samples, volume);
return CELL_OK;
}
int cellAudioAdd6chData(u32 portNum, mem32_t src, float volume)
int cellAudioAdd6chData(u32 portNum, vm::ptr<be_t<float>> src, float volume)
{
cellAudio->Todo("cellAudioAdd6chData(portNum=0x%x, src_addr=0x%x, volume=%f)", portNum, src.GetAddr(), volume);
cellAudio->Todo("cellAudioAdd6chData(portNum=0x%x, src_addr=0x%x, volume=%f)", portNum, src.addr(), volume);
return CELL_OK;
}

View file

@ -114,7 +114,7 @@ bool ElementaryStream::isfull()
return is_full();
}
void ElementaryStream::finish(DemuxerStream& stream) // not multithread-safe
void ElementaryStream::finish(DemuxerStream& stream) // not multithread-safe (or safe?)
{
u32 addr;
{
@ -122,16 +122,8 @@ void ElementaryStream::finish(DemuxerStream& stream) // not multithread-safe
//if (fidMajor != 0xbd) LOG_NOTICE(HLE, ">>> es::finish(): peek=0x%x, first=0x%x, put=0x%x, size=0x%x", peek, first, put, size);
addr = put;
/*if (!first)
{
first = put;
}
if (!peek)
{
peek = put;
}*/
mem_ptr_t<CellDmuxAuInfo> info(put);
auto info = vm::ptr<CellDmuxAuInfo>::make(put);
//if (fidMajor != 0xbd) LOG_WARNING(HLE, "es::finish(): (%s) size = 0x%x, info_addr=0x%x, pts = 0x%x",
//wxString(fidMajor == 0xbd ? "ATRAC3P Audio" : "Video AVC").wx_str(),
//(u32)info->auSize, put, (u32)info->ptsLower);
@ -167,7 +159,7 @@ void ElementaryStream::push(DemuxerStream& stream, u32 sz, PesHeader& pes)
memcpy(Memory + data_addr, Memory + stream.addr, sz);
stream.skip(sz);
mem_ptr_t<CellDmuxAuInfoEx> info(put);
auto info = vm::ptr<CellDmuxAuInfoEx>::make(put);
info->auAddr = put + 128;
info->auSize = size;
if (pes.new_au)
@ -181,10 +173,10 @@ void ElementaryStream::push(DemuxerStream& stream, u32 sz, PesHeader& pes)
info->userData = stream.userdata;
}
mem_ptr_t<CellDmuxPamfAuSpecificInfoAvc> tail(put + sizeof(CellDmuxAuInfoEx));
auto tail = vm::ptr<CellDmuxPamfAuSpecificInfoAvc>::make(put + sizeof(CellDmuxAuInfoEx));
tail->reserved1 = 0;
mem_ptr_t<CellDmuxAuInfo> inf(put + 64);
auto inf = vm::ptr<CellDmuxAuInfo>::make(put + 64);
inf->auAddr = put + 128;
inf->auSize = size;
if (pes.new_au)
@ -210,7 +202,7 @@ bool ElementaryStream::release()
u32 addr = entries.Peek();
mem_ptr_t<CellDmuxAuInfo> info(addr);
auto info = vm::ptr<CellDmuxAuInfo>::make(addr);
//if (fidMajor != 0xbd) LOG_WARNING(HLE, "es::release(): (%s) size = 0x%x, info = 0x%x, pts = 0x%x",
//wxString(fidMajor == 0xbd ? "ATRAC3P Audio" : "Video AVC").wx_str(), (u32)info->auSize, first, (u32)info->ptsLower);
@ -220,21 +212,6 @@ bool ElementaryStream::release()
return false;
}
/*u32 new_addr = a128(info.GetAddr() + 128 + info->auSize);
if (new_addr == put)
{
first = 0;
}
else if ((new_addr + GetMaxAU()) > (memAddr + memSize))
{
first = memAddr;
}
else
{
first = new_addr;
}*/
released++;
if (!entries.Pop(addr))
{
@ -260,7 +237,7 @@ bool ElementaryStream::peek(u32& out_data, bool no_ex, u32& out_spec, bool updat
}
u32 addr = entries.Peek(peek_count - released);
mem_ptr_t<CellDmuxAuInfo> info(addr);
auto info = vm::ptr<CellDmuxAuInfo>::make(addr);
//if (fidMajor != 0xbd) LOG_WARNING(HLE, "es::peek(%sAu(Ex)): (%s) size = 0x%x, info = 0x%x, pts = 0x%x",
//wxString(update_index ? "Get" : "Peek").wx_str(),
//wxString(fidMajor == 0xbd ? "ATRAC3P Audio" : "Video AVC").wx_str(), (u32)info->auSize, peek, (u32)info->ptsLower);
@ -271,19 +248,6 @@ bool ElementaryStream::peek(u32& out_data, bool no_ex, u32& out_spec, bool updat
if (update_index)
{
/*u32 new_addr = a128(peek + 128 + info->auSize);
if (new_addr == put)
{
peek = 0;
}
else if ((new_addr + GetMaxAU()) > (memAddr + memSize))
{
peek = memAddr;
}
else
{
peek = new_addr;
}*/
peek_count++;
}
@ -305,15 +269,15 @@ void ElementaryStream::reset()
peek_count = 0;
}
void dmuxQueryAttr(u32 info_addr /* may be 0 */, mem_ptr_t<CellDmuxAttr> attr)
void dmuxQueryAttr(u32 info_addr /* may be 0 */, vm::ptr<CellDmuxAttr> attr)
{
attr->demuxerVerLower = 0x280000; // TODO: check values
attr->demuxerVerUpper = 0x260000;
attr->memSize = 0x10000; // 0x3e8e6 from ps3
}
void dmuxQueryEsAttr(u32 info_addr /* may be 0 */, const mem_ptr_t<CellCodecEsFilterId> esFilterId,
const u32 esSpecificInfo_addr, mem_ptr_t<CellDmuxEsAttr> attr)
void dmuxQueryEsAttr(u32 info_addr /* may be 0 */, const vm::ptr<CellCodecEsFilterId> esFilterId,
const u32 esSpecificInfo_addr, vm::ptr<CellDmuxEsAttr> attr)
{
if (esFilterId->filterIdMajor >= 0xe0)
attr->memSize = 0x500000; // 0x45fa49 from ps3
@ -373,14 +337,14 @@ u32 dmuxOpen(Demuxer* data)
{
dmux.is_running = false;
// demuxing finished
mem_ptr_t<CellDmuxMsg> dmuxMsg(a128(dmux.memAddr) + (cb_add ^= 16));
auto dmuxMsg = vm::ptr<CellDmuxMsg>::make(a128(dmux.memAddr) + (cb_add ^= 16));
dmuxMsg->msgType = CELL_DMUX_MSG_TYPE_DEMUX_DONE;
dmuxMsg->supplementalInfo = stream.userdata;
/*Callback cb;
cb.SetAddr(dmux.cbFunc);
cb.Handle(dmux.id, dmuxMsg.GetAddr(), dmux.cbArg);
cb.Handle(dmux.id, dmuxMsg.addr(), dmux.cbArg);
cb.Branch(task.type == dmuxResetStreamAndWaitDone);*/
dmux.dmuxCb->ExecAsCallback(dmux.cbFunc, true, dmux.id, dmuxMsg.GetAddr(), dmux.cbArg);
dmux.dmuxCb->ExecAsCallback(dmux.cbFunc, true, dmux.id, dmuxMsg.addr(), dmux.cbArg);
updates_signaled++;
}
else switch (code.ToLE())
@ -457,14 +421,14 @@ u32 dmuxOpen(Demuxer* data)
es.finish(stream);
//LOG_NOTICE(HLE, "*** AT3+ AU sent (len=0x%x, pts=0x%llx)", len - pes.size - 3, pes.pts);
mem_ptr_t<CellDmuxEsMsg> esMsg(a128(dmux.memAddr) + (cb_add ^= 16));
auto esMsg = vm::ptr<CellDmuxEsMsg>::make(a128(dmux.memAddr) + (cb_add ^= 16));
esMsg->msgType = CELL_DMUX_ES_MSG_TYPE_AU_FOUND;
esMsg->supplementalInfo = stream.userdata;
/*Callback cb;
cb.SetAddr(es.cbFunc);
cb.Handle(dmux.id, es.id, esMsg.GetAddr(), es.cbArg);
cb.Handle(dmux.id, es.id, esMsg.addr(), es.cbArg);
cb.Branch(false);*/
dmux.dmuxCb->ExecAsCallback(es.cbFunc, false, dmux.id, es.id, esMsg.GetAddr(), es.cbArg);
dmux.dmuxCb->ExecAsCallback(es.cbFunc, false, dmux.id, es.id, esMsg.addr(), es.cbArg);
}
else
{
@ -510,14 +474,14 @@ u32 dmuxOpen(Demuxer* data)
}*/
es.finish(stream);
// callback
mem_ptr_t<CellDmuxEsMsg> esMsg(a128(dmux.memAddr) + (cb_add ^= 16));
auto esMsg = vm::ptr<CellDmuxEsMsg>::make(a128(dmux.memAddr) + (cb_add ^= 16));
esMsg->msgType = CELL_DMUX_ES_MSG_TYPE_AU_FOUND;
esMsg->supplementalInfo = stream.userdata;
/*Callback cb;
cb.SetAddr(es.cbFunc);
cb.Handle(dmux.id, es.id, esMsg.GetAddr(), es.cbArg);
cb.Handle(dmux.id, es.id, esMsg.addr(), es.cbArg);
cb.Branch(false);*/
dmux.dmuxCb->ExecAsCallback(es.cbFunc, false, dmux.id, es.id, esMsg.GetAddr(), es.cbArg);
dmux.dmuxCb->ExecAsCallback(es.cbFunc, false, dmux.id, es.id, esMsg.addr(), es.cbArg);
}
if (pes.new_au)
@ -622,15 +586,15 @@ u32 dmuxOpen(Demuxer* data)
case dmuxResetStream:
case dmuxResetStreamAndWaitDone:
{
mem_ptr_t<CellDmuxMsg> dmuxMsg(a128(dmux.memAddr) + (cb_add ^= 16));
auto dmuxMsg = vm::ptr<CellDmuxMsg>::make(a128(dmux.memAddr) + (cb_add ^= 16));
dmuxMsg->msgType = CELL_DMUX_MSG_TYPE_DEMUX_DONE;
dmuxMsg->supplementalInfo = stream.userdata;
/*Callback cb;
cb.SetAddr(dmux.cbFunc);
cb.Handle(dmux.id, dmuxMsg.GetAddr(), dmux.cbArg);
cb.Handle(dmux.id, dmuxMsg.addr(), dmux.cbArg);
cb.Branch(task.type == dmuxResetStreamAndWaitDone);*/
dmux.dmuxCb->ExecAsCallback(dmux.cbFunc, task.type == dmuxResetStreamAndWaitDone,
dmux.id, dmuxMsg.GetAddr(), dmux.cbArg);
dmux.id, dmuxMsg.addr(), dmux.cbArg);
updates_signaled++;
dmux.is_running = false;
@ -708,25 +672,25 @@ u32 dmuxOpen(Demuxer* data)
{
es.finish(stream);
// callback
mem_ptr_t<CellDmuxEsMsg> esMsg(a128(dmux.memAddr) + (cb_add ^= 16));
auto esMsg = vm::ptr<CellDmuxEsMsg>::make(a128(dmux.memAddr) + (cb_add ^= 16));
esMsg->msgType = CELL_DMUX_ES_MSG_TYPE_AU_FOUND;
esMsg->supplementalInfo = stream.userdata;
/*Callback cb;
cb.SetAddr(es.cbFunc);
cb.Handle(dmux.id, es.id, esMsg.GetAddr(), es.cbArg);
cb.Handle(dmux.id, es.id, esMsg.addr(), es.cbArg);
cb.Branch(false);*/
dmux.dmuxCb->ExecAsCallback(es.cbFunc, false, dmux.id, es.id, esMsg.GetAddr(), es.cbArg);
dmux.dmuxCb->ExecAsCallback(es.cbFunc, false, dmux.id, es.id, esMsg.addr(), es.cbArg);
}
// callback
mem_ptr_t<CellDmuxEsMsg> esMsg(a128(dmux.memAddr) + (cb_add ^= 16));
auto esMsg = vm::ptr<CellDmuxEsMsg>::make(a128(dmux.memAddr) + (cb_add ^= 16));
esMsg->msgType = CELL_DMUX_ES_MSG_TYPE_FLUSH_DONE;
esMsg->supplementalInfo = stream.userdata;
/*Callback cb;
cb.SetAddr(es.cbFunc);
cb.Handle(dmux.id, es.id, esMsg.GetAddr(), es.cbArg);
cb.Handle(dmux.id, es.id, esMsg.addr(), es.cbArg);
cb.Branch(false);*/
dmux.dmuxCb->ExecAsCallback(es.cbFunc, false, dmux.id, es.id, esMsg.GetAddr(), es.cbArg);
dmux.dmuxCb->ExecAsCallback(es.cbFunc, false, dmux.id, es.id, esMsg.addr(), es.cbArg);
}
break;
@ -749,9 +713,9 @@ u32 dmuxOpen(Demuxer* data)
return dmux_id;
}
int cellDmuxQueryAttr(const mem_ptr_t<CellDmuxType> demuxerType, mem_ptr_t<CellDmuxAttr> demuxerAttr)
int cellDmuxQueryAttr(const vm::ptr<CellDmuxType> demuxerType, vm::ptr<CellDmuxAttr> demuxerAttr)
{
cellDmux->Warning("cellDmuxQueryAttr(demuxerType_addr=0x%x, demuxerAttr_addr=0x%x)", demuxerType.GetAddr(), demuxerAttr.GetAddr());
cellDmux->Warning("cellDmuxQueryAttr(demuxerType_addr=0x%x, demuxerAttr_addr=0x%x)", demuxerType.addr(), demuxerAttr.addr());
if (demuxerType->streamType != CELL_DMUX_STREAM_TYPE_PAMF)
{
@ -762,9 +726,9 @@ int cellDmuxQueryAttr(const mem_ptr_t<CellDmuxType> demuxerType, mem_ptr_t<CellD
return CELL_OK;
}
int cellDmuxQueryAttr2(const mem_ptr_t<CellDmuxType2> demuxerType2, mem_ptr_t<CellDmuxAttr> demuxerAttr)
int cellDmuxQueryAttr2(const vm::ptr<CellDmuxType2> demuxerType2, vm::ptr<CellDmuxAttr> demuxerAttr)
{
cellDmux->Warning("cellDmuxQueryAttr2(demuxerType2_addr=0x%x, demuxerAttr_addr=0x%x)", demuxerType2.GetAddr(), demuxerAttr.GetAddr());
cellDmux->Warning("cellDmuxQueryAttr2(demuxerType2_addr=0x%x, demuxerAttr_addr=0x%x)", demuxerType2.addr(), demuxerAttr.addr());
if (demuxerType2->streamType != CELL_DMUX_STREAM_TYPE_PAMF)
{
@ -775,11 +739,11 @@ int cellDmuxQueryAttr2(const mem_ptr_t<CellDmuxType2> demuxerType2, mem_ptr_t<Ce
return CELL_OK;
}
int cellDmuxOpen(const mem_ptr_t<CellDmuxType> demuxerType, const mem_ptr_t<CellDmuxResource> demuxerResource,
const mem_ptr_t<CellDmuxCb> demuxerCb, mem32_t demuxerHandle)
int cellDmuxOpen(const vm::ptr<CellDmuxType> demuxerType, const vm::ptr<CellDmuxResource> demuxerResource,
const vm::ptr<CellDmuxCb> demuxerCb, vm::ptr<be_t<u32>> demuxerHandle)
{
cellDmux->Warning("cellDmuxOpen(demuxerType_addr=0x%x, demuxerResource_addr=0x%x, demuxerCb_addr=0x%x, demuxerHandle_addr=0x%x)",
demuxerType.GetAddr(), demuxerResource.GetAddr(), demuxerCb.GetAddr(), demuxerHandle.GetAddr());
demuxerType.addr(), demuxerResource.addr(), demuxerCb.addr(), demuxerHandle.addr());
if (demuxerType->streamType != CELL_DMUX_STREAM_TYPE_PAMF)
{
@ -788,16 +752,16 @@ int cellDmuxOpen(const mem_ptr_t<CellDmuxType> demuxerType, const mem_ptr_t<Cell
// TODO: check demuxerResource and demuxerCb arguments
demuxerHandle = dmuxOpen(new Demuxer(demuxerResource->memAddr, demuxerResource->memSize, demuxerCb->cbMsgFunc, demuxerCb->cbArg_addr));
*demuxerHandle = dmuxOpen(new Demuxer(demuxerResource->memAddr, demuxerResource->memSize, demuxerCb->cbMsgFunc, demuxerCb->cbArg_addr));
return CELL_OK;
}
int cellDmuxOpenEx(const mem_ptr_t<CellDmuxType> demuxerType, const mem_ptr_t<CellDmuxResourceEx> demuxerResourceEx,
const mem_ptr_t<CellDmuxCb> demuxerCb, mem32_t demuxerHandle)
int cellDmuxOpenEx(const vm::ptr<CellDmuxType> demuxerType, const vm::ptr<CellDmuxResourceEx> demuxerResourceEx,
const vm::ptr<CellDmuxCb> demuxerCb, vm::ptr<be_t<u32>> demuxerHandle)
{
cellDmux->Warning("cellDmuxOpenEx(demuxerType_addr=0x%x, demuxerResourceEx_addr=0x%x, demuxerCb_addr=0x%x, demuxerHandle_addr=0x%x)",
demuxerType.GetAddr(), demuxerResourceEx.GetAddr(), demuxerCb.GetAddr(), demuxerHandle.GetAddr());
demuxerType.addr(), demuxerResourceEx.addr(), demuxerCb.addr(), demuxerHandle.addr());
if (demuxerType->streamType != CELL_DMUX_STREAM_TYPE_PAMF)
{
@ -806,16 +770,16 @@ int cellDmuxOpenEx(const mem_ptr_t<CellDmuxType> demuxerType, const mem_ptr_t<Ce
// TODO: check demuxerResourceEx and demuxerCb arguments
demuxerHandle = dmuxOpen(new Demuxer(demuxerResourceEx->memAddr, demuxerResourceEx->memSize, demuxerCb->cbMsgFunc, demuxerCb->cbArg_addr));
*demuxerHandle = dmuxOpen(new Demuxer(demuxerResourceEx->memAddr, demuxerResourceEx->memSize, demuxerCb->cbMsgFunc, demuxerCb->cbArg_addr));
return CELL_OK;
}
int cellDmuxOpen2(const mem_ptr_t<CellDmuxType2> demuxerType2, const mem_ptr_t<CellDmuxResource2> demuxerResource2,
const mem_ptr_t<CellDmuxCb> demuxerCb, mem32_t demuxerHandle)
int cellDmuxOpen2(const vm::ptr<CellDmuxType2> demuxerType2, const vm::ptr<CellDmuxResource2> demuxerResource2,
const vm::ptr<CellDmuxCb> demuxerCb, vm::ptr<be_t<u32>> demuxerHandle)
{
cellDmux->Warning("cellDmuxOpen2(demuxerType2_addr=0x%x, demuxerResource2_addr=0x%x, demuxerCb_addr=0x%x, demuxerHandle_addr=0x%x)",
demuxerType2.GetAddr(), demuxerResource2.GetAddr(), demuxerCb.GetAddr(), demuxerHandle.GetAddr());
demuxerType2.addr(), demuxerResource2.addr(), demuxerCb.addr(), demuxerHandle.addr());
if (demuxerType2->streamType != CELL_DMUX_STREAM_TYPE_PAMF)
{
@ -824,7 +788,7 @@ int cellDmuxOpen2(const mem_ptr_t<CellDmuxType2> demuxerType2, const mem_ptr_t<C
// TODO: check demuxerType2, demuxerResource2 and demuxerCb arguments
demuxerHandle = dmuxOpen(new Demuxer(demuxerResource2->memAddr, demuxerResource2->memSize, demuxerCb->cbMsgFunc, demuxerCb->cbArg_addr));
*demuxerHandle = dmuxOpen(new Demuxer(demuxerResource2->memAddr, demuxerResource2->memSize, demuxerCb->cbMsgFunc, demuxerCb->cbArg_addr));
return CELL_OK;
}
@ -943,11 +907,11 @@ int cellDmuxResetStreamAndWaitDone(u32 demuxerHandle)
return CELL_OK;
}
int cellDmuxQueryEsAttr(const mem_ptr_t<CellDmuxType> demuxerType, const mem_ptr_t<CellCodecEsFilterId> esFilterId,
const u32 esSpecificInfo_addr, mem_ptr_t<CellDmuxEsAttr> esAttr)
int cellDmuxQueryEsAttr(const vm::ptr<CellDmuxType> demuxerType, const vm::ptr<CellCodecEsFilterId> esFilterId,
const u32 esSpecificInfo_addr, vm::ptr<CellDmuxEsAttr> esAttr)
{
cellDmux->Warning("cellDmuxQueryEsAttr(demuxerType_addr=0x%x, esFilterId_addr=0x%x, esSpecificInfo_addr=0x%x, esAttr_addr=0x%x)",
demuxerType.GetAddr(), esFilterId.GetAddr(), esSpecificInfo_addr, esAttr.GetAddr());
demuxerType.addr(), esFilterId.addr(), esSpecificInfo_addr, esAttr.addr());
if (demuxerType->streamType != CELL_DMUX_STREAM_TYPE_PAMF)
{
@ -960,11 +924,11 @@ int cellDmuxQueryEsAttr(const mem_ptr_t<CellDmuxType> demuxerType, const mem_ptr
return CELL_OK;
}
int cellDmuxQueryEsAttr2(const mem_ptr_t<CellDmuxType2> demuxerType2, const mem_ptr_t<CellCodecEsFilterId> esFilterId,
const u32 esSpecificInfo_addr, mem_ptr_t<CellDmuxEsAttr> esAttr)
int cellDmuxQueryEsAttr2(const vm::ptr<CellDmuxType2> demuxerType2, const vm::ptr<CellCodecEsFilterId> esFilterId,
const u32 esSpecificInfo_addr, vm::ptr<CellDmuxEsAttr> esAttr)
{
cellDmux->Warning("cellDmuxQueryEsAttr2(demuxerType2_addr=0x%x, esFilterId_addr=0x%x, esSpecificInfo_addr=0x%x, esAttr_addr=0x%x)",
demuxerType2.GetAddr(), esFilterId.GetAddr(), esSpecificInfo_addr, esAttr.GetAddr());
demuxerType2.addr(), esFilterId.addr(), esSpecificInfo_addr, esAttr.addr());
if (demuxerType2->streamType != CELL_DMUX_STREAM_TYPE_PAMF)
{
@ -977,13 +941,13 @@ int cellDmuxQueryEsAttr2(const mem_ptr_t<CellDmuxType2> demuxerType2, const mem_
return CELL_OK;
}
int cellDmuxEnableEs(u32 demuxerHandle, const mem_ptr_t<CellCodecEsFilterId> esFilterId,
const mem_ptr_t<CellDmuxEsResource> esResourceInfo, const mem_ptr_t<CellDmuxEsCb> esCb,
const u32 esSpecificInfo_addr, mem32_t esHandle)
int cellDmuxEnableEs(u32 demuxerHandle, const vm::ptr<CellCodecEsFilterId> esFilterId,
const vm::ptr<CellDmuxEsResource> esResourceInfo, const vm::ptr<CellDmuxEsCb> esCb,
const u32 esSpecificInfo_addr, vm::ptr<be_t<u32>> esHandle)
{
cellDmux->Warning("cellDmuxEnableEs(demuxerHandle=%d, esFilterId_addr=0x%x, esResourceInfo_addr=0x%x, esCb_addr=0x%x, "
"esSpecificInfo_addr=0x%x, esHandle_addr=0x%x)", demuxerHandle, esFilterId.GetAddr(), esResourceInfo.GetAddr(),
esCb.GetAddr(), esSpecificInfo_addr, esHandle.GetAddr());
"esSpecificInfo_addr=0x%x, esHandle_addr=0x%x)", demuxerHandle, esFilterId.addr(), esResourceInfo.addr(),
esCb.addr(), esSpecificInfo_addr, esHandle.addr());
Demuxer* dmux;
if (!Emu.GetIdManager().GetIDData(demuxerHandle, dmux))
@ -999,7 +963,7 @@ int cellDmuxEnableEs(u32 demuxerHandle, const mem_ptr_t<CellCodecEsFilterId> esF
u32 id = cellDmux->GetNewId(es);
es->id = id;
esHandle = id;
*esHandle = id;
cellDmux->Warning("*** New ES(dmux=%d, addr=0x%x, size=0x%x, filter(0x%x, 0x%x, 0x%x, 0x%x), cb=0x%x(arg=0x%x), spec=0x%x): id = %d",
demuxerHandle, es->memAddr, es->memSize, es->fidMajor, es->fidMinor, es->sup1, es->sup2, (u32)esCb->cbEsMsgFunc, es->cbArg, es->spec, id);
@ -1048,10 +1012,10 @@ int cellDmuxResetEs(u32 esHandle)
return CELL_OK;
}
int cellDmuxGetAu(u32 esHandle, mem32_t auInfo_ptr, mem32_t auSpecificInfo_ptr)
int cellDmuxGetAu(u32 esHandle, vm::ptr<be_t<u32>> auInfo_ptr, vm::ptr<be_t<u32>> auSpecificInfo_ptr)
{
cellDmux->Log("cellDmuxGetAu(esHandle=0x%x, auInfo_ptr_addr=0x%x, auSpecificInfo_ptr_addr=0x%x)",
esHandle, auInfo_ptr.GetAddr(), auSpecificInfo_ptr.GetAddr());
esHandle, auInfo_ptr.addr(), auSpecificInfo_ptr.addr());
ElementaryStream* es;
if (!Emu.GetIdManager().GetIDData(esHandle, es))
@ -1066,15 +1030,15 @@ int cellDmuxGetAu(u32 esHandle, mem32_t auInfo_ptr, mem32_t auSpecificInfo_ptr)
return CELL_DMUX_ERROR_EMPTY;
}
auInfo_ptr = info;
auSpecificInfo_ptr = spec;
*auInfo_ptr = info;
*auSpecificInfo_ptr = spec;
return CELL_OK;
}
int cellDmuxPeekAu(u32 esHandle, mem32_t auInfo_ptr, mem32_t auSpecificInfo_ptr)
int cellDmuxPeekAu(u32 esHandle, vm::ptr<be_t<u32>> auInfo_ptr, vm::ptr<be_t<u32>> auSpecificInfo_ptr)
{
cellDmux->Log("cellDmuxPeekAu(esHandle=0x%x, auInfo_ptr_addr=0x%x, auSpecificInfo_ptr_addr=0x%x)",
esHandle, auInfo_ptr.GetAddr(), auSpecificInfo_ptr.GetAddr());
esHandle, auInfo_ptr.addr(), auSpecificInfo_ptr.addr());
ElementaryStream* es;
if (!Emu.GetIdManager().GetIDData(esHandle, es))
@ -1089,15 +1053,15 @@ int cellDmuxPeekAu(u32 esHandle, mem32_t auInfo_ptr, mem32_t auSpecificInfo_ptr)
return CELL_DMUX_ERROR_EMPTY;
}
auInfo_ptr = info;
auSpecificInfo_ptr = spec;
*auInfo_ptr = info;
*auSpecificInfo_ptr = spec;
return CELL_OK;
}
int cellDmuxGetAuEx(u32 esHandle, mem32_t auInfoEx_ptr, mem32_t auSpecificInfo_ptr)
int cellDmuxGetAuEx(u32 esHandle, vm::ptr<be_t<u32>> auInfoEx_ptr, vm::ptr<be_t<u32>> auSpecificInfo_ptr)
{
cellDmux->Log("cellDmuxGetAuEx(esHandle=0x%x, auInfoEx_ptr_addr=0x%x, auSpecificInfo_ptr_addr=0x%x)",
esHandle, auInfoEx_ptr.GetAddr(), auSpecificInfo_ptr.GetAddr());
esHandle, auInfoEx_ptr.addr(), auSpecificInfo_ptr.addr());
ElementaryStream* es;
if (!Emu.GetIdManager().GetIDData(esHandle, es))
@ -1112,15 +1076,15 @@ int cellDmuxGetAuEx(u32 esHandle, mem32_t auInfoEx_ptr, mem32_t auSpecificInfo_p
return CELL_DMUX_ERROR_EMPTY;
}
auInfoEx_ptr = info;
auSpecificInfo_ptr = spec;
*auInfoEx_ptr = info;
*auSpecificInfo_ptr = spec;
return CELL_OK;
}
int cellDmuxPeekAuEx(u32 esHandle, mem32_t auInfoEx_ptr, mem32_t auSpecificInfo_ptr)
int cellDmuxPeekAuEx(u32 esHandle, vm::ptr<be_t<u32>> auInfoEx_ptr, vm::ptr<be_t<u32>> auSpecificInfo_ptr)
{
cellDmux->Log("cellDmuxPeekAuEx(esHandle=0x%x, auInfoEx_ptr_addr=0x%x, auSpecificInfo_ptr_addr=0x%x)",
esHandle, auInfoEx_ptr.GetAddr(), auSpecificInfo_ptr.GetAddr());
esHandle, auInfoEx_ptr.addr(), auSpecificInfo_ptr.addr());
ElementaryStream* es;
if (!Emu.GetIdManager().GetIDData(esHandle, es))
@ -1135,8 +1099,8 @@ int cellDmuxPeekAuEx(u32 esHandle, mem32_t auInfoEx_ptr, mem32_t auSpecificInfo_
return CELL_DMUX_ERROR_EMPTY;
}
auInfoEx_ptr = info;
auSpecificInfo_ptr = spec;
*auInfoEx_ptr = info;
*auSpecificInfo_ptr = spec;
return CELL_OK;
}

View file

@ -222,7 +222,7 @@ struct CellDmuxResource2
be_t<u32> shit[4];
};
typedef mem_func_ptr_t<void (*)(u32 demuxerHandle, mem_ptr_t<CellDmuxMsg> demuxerMsg, u32 cbArg_addr)> CellDmuxCbMsg;
typedef u32(*CellDmuxCbMsg)(u32 demuxerHandle, vm::ptr<CellDmuxMsg> demuxerMsg, u32 cbArg_addr);
struct CellDmuxCb
{
@ -231,7 +231,7 @@ struct CellDmuxCb
be_t<u32> cbArg_addr;
};
typedef mem_func_ptr_t<void (*)(u32 demuxerHandle, u32 esHandle, mem_ptr_t<CellDmuxEsMsg> esMsg, u32 cbArg_addr)> CellDmuxCbEsMsg;
typedef u32(*CellDmuxCbEsMsg)(u32 demuxerHandle, u32 esHandle, vm::ptr<CellDmuxEsMsg> esMsg, u32 cbArg_addr);
struct CellDmuxEsCb
{

View file

@ -81,12 +81,12 @@ int cellFiberPpuJoinFiber()
return CELL_OK;
}
u32 cellFiberPpuSelf()
vm::ptr<void> cellFiberPpuSelf()
{
cellFiber->Log("cellFiberPpuSelf() -> nullptr"); // TODO
// returns fiber structure (zero for simple PPU thread)
return 0;
return vm::ptr<void>::make(0);
}
int cellFiberPpuSendSignal()

View file

@ -15,9 +15,9 @@ Module *cellFont = nullptr;
CCellFontInternal* s_fontInternalInstance = nullptr;
// Functions
int cellFontInitializeWithRevision(u64 revisionFlags, mem_ptr_t<CellFontConfig> config)
int cellFontInitializeWithRevision(u64 revisionFlags, vm::ptr<CellFontConfig> config)
{
cellFont->Warning("cellFontInitializeWithRevision(revisionFlags=0x%llx, config=0x%x)", revisionFlags, config.GetAddr());
cellFont->Warning("cellFontInitializeWithRevision(revisionFlags=0x%llx, config=0x%x)", revisionFlags, config.addr());
if (s_fontInternalInstance->m_bInitialized)
return CELL_FONT_ERROR_ALREADY_INITIALIZED;
@ -34,19 +34,20 @@ int cellFontInitializeWithRevision(u64 revisionFlags, mem_ptr_t<CellFontConfig>
return CELL_FONT_OK;
}
int cellFontGetRevisionFlags(mem64_t revisionFlags)
int cellFontGetRevisionFlags(vm::ptr<be_t<u64>> revisionFlags)
{
UNIMPLEMENTED_FUNC(cellFont);
return CELL_FONT_OK;
}
int cellFontInit(mem_ptr_t<CellFontConfig> config)
int cellFontInit(vm::ptr<CellFontConfig> config)
{
cellFont->Log("cellFontInit(config=0x%x)", config.GetAddr());
cellFont->Log("cellFontInit(config=0x%x)", config.addr());
MemoryAllocator<u64> revisionFlags = 0;
cellFontGetRevisionFlags(revisionFlags.GetAddr());
return cellFontInitializeWithRevision(revisionFlags, config.GetAddr());
vm::var<be_t<u64>> revisionFlags;
revisionFlags.value() = 0;
cellFontGetRevisionFlags(revisionFlags);
return cellFontInitializeWithRevision(revisionFlags.value(), config);
}
int cellFontEnd()
@ -67,10 +68,10 @@ s32 cellFontSetFontsetOpenMode(u32 openMode)
return CELL_FONT_OK;
}
int cellFontOpenFontMemory(mem_ptr_t<CellFontLibrary> library, u32 fontAddr, u32 fontSize, u32 subNum, u32 uniqueId, mem_ptr_t<CellFont> font)
int cellFontOpenFontMemory(vm::ptr<CellFontLibrary> library, u32 fontAddr, u32 fontSize, u32 subNum, u32 uniqueId, vm::ptr<CellFont> font)
{
cellFont->Warning("cellFontOpenFontMemory(library_addr=0x%x, fontAddr=0x%x, fontSize=%d, subNum=%d, uniqueId=%d, font_addr=0x%x)",
library.GetAddr(), fontAddr, fontSize, subNum, uniqueId, font.GetAddr());
library.addr(), fontAddr, fontSize, subNum, uniqueId, font.addr());
if (!s_fontInternalInstance->m_bInitialized)
return CELL_FONT_ERROR_UNINITIALIZED;
@ -86,28 +87,28 @@ int cellFontOpenFontMemory(mem_ptr_t<CellFontLibrary> library, u32 fontAddr, u32
return CELL_FONT_OK;
}
int cellFontOpenFontFile(mem_ptr_t<CellFontLibrary> library, mem8_ptr_t fontPath, u32 subNum, s32 uniqueId, mem_ptr_t<CellFont> font)
int cellFontOpenFontFile(vm::ptr<CellFontLibrary> library, vm::ptr<const char> fontPath, u32 subNum, s32 uniqueId, vm::ptr<CellFont> font)
{
std::string fp(fontPath.GetString());
std::string fp(fontPath.get_ptr());
cellFont->Warning("cellFontOpenFontFile(library_addr=0x%x, fontPath=\"%s\", subNum=%d, uniqueId=%d, font_addr=0x%x)",
library.GetAddr(), fp.c_str(), subNum, uniqueId, font.GetAddr());
library.addr(), fp.c_str(), subNum, uniqueId, font.addr());
vfsFile f(fp);
if (!f.IsOpened())
return CELL_FONT_ERROR_FONT_OPEN_FAILED;
u32 fileSize = f.GetSize();
u32 bufferAddr = Memory.Alloc(fileSize, 1); // Freed in cellFontCloseFont
u32 fileSize = (u32)f.GetSize();
u32 bufferAddr = (u32)Memory.Alloc(fileSize, 1); // Freed in cellFontCloseFont
f.Read(Memory.VirtualToRealAddr(bufferAddr), fileSize);
int ret = cellFontOpenFontMemory(library.GetAddr(), bufferAddr, fileSize, subNum, uniqueId, font.GetAddr());
int ret = cellFontOpenFontMemory(library, bufferAddr, fileSize, subNum, uniqueId, font);
font->origin = CELL_FONT_OPEN_FONT_FILE;
return ret;
}
int cellFontOpenFontset(mem_ptr_t<CellFontLibrary> library, mem_ptr_t<CellFontType> fontType, mem_ptr_t<CellFont> font)
int cellFontOpenFontset(vm::ptr<CellFontLibrary> library, vm::ptr<CellFontType> fontType, vm::ptr<CellFont> font)
{
cellFont->Log("cellFontOpenFontset(library_addr=0x%x, fontType_addr=0x%x, font_addr=0x%x)",
library.GetAddr(), fontType.GetAddr(), font.GetAddr());
library.addr(), fontType.addr(), font.addr());
if (!s_fontInternalInstance->m_bInitialized)
return CELL_FONT_ERROR_UNINITIALIZED;
@ -180,17 +181,16 @@ int cellFontOpenFontset(mem_ptr_t<CellFontLibrary> library, mem_ptr_t<CellFontTy
return CELL_FONT_ERROR_NO_SUPPORT_FONTSET;
}
u32 file_addr = Memory.Alloc(file.length()+1, 1);
Memory.WriteString(file_addr, file);
int ret = cellFontOpenFontFile(library.GetAddr(), file_addr, 0, 0, font.GetAddr()); //TODO: Find the correct values of subNum, uniqueId
vm::var<const char> f((u32)file.length() + 1, 1);
Memory.WriteString(f.addr(), file);
int ret = cellFontOpenFontFile(library, f, 0, 0, font); //TODO: Find the correct values of subNum, uniqueId
font->origin = CELL_FONT_OPEN_FONTSET;
Memory.Free(file_addr);
return ret;
}
int cellFontOpenFontInstance(mem_ptr_t<CellFont> openedFont, mem_ptr_t<CellFont> font)
int cellFontOpenFontInstance(vm::ptr<CellFont> openedFont, vm::ptr<CellFont> font)
{
cellFont->Warning("cellFontOpenFontInstance(openedFont=0x%x, font=0x%x)", openedFont.GetAddr(), font.GetAddr());
cellFont->Warning("cellFontOpenFontInstance(openedFont=0x%x, font=0x%x)", openedFont.addr(), font.addr());
font->renderer_addr = openedFont->renderer_addr;
font->scale_x = openedFont->scale_x;
@ -209,10 +209,10 @@ s32 cellFontSetFontOpenMode(u32 openMode)
return CELL_FONT_OK;
}
int cellFontCreateRenderer(mem_ptr_t<CellFontLibrary> library, mem_ptr_t<CellFontRendererConfig> config, mem_ptr_t<CellFontRenderer> Renderer)
int cellFontCreateRenderer(vm::ptr<CellFontLibrary> library, vm::ptr<CellFontRendererConfig> config, vm::ptr<CellFontRenderer> Renderer)
{
cellFont->Warning("cellFontCreateRenderer(library_addr=0x%x, config_addr=0x%x, Renderer_addr=0x%x)",
library.GetAddr(), config.GetAddr(), Renderer.GetAddr());
library.addr(), config.addr(), Renderer.addr());
if (!s_fontInternalInstance->m_bInitialized)
return CELL_FONT_ERROR_UNINITIALIZED;
@ -222,10 +222,10 @@ int cellFontCreateRenderer(mem_ptr_t<CellFontLibrary> library, mem_ptr_t<CellFon
return CELL_FONT_OK;
}
void cellFontRenderSurfaceInit(mem_ptr_t<CellFontRenderSurface> surface, u32 buffer_addr, s32 bufferWidthByte, s32 pixelSizeByte, s32 w, s32 h)
void cellFontRenderSurfaceInit(vm::ptr<CellFontRenderSurface> surface, u32 buffer_addr, s32 bufferWidthByte, s32 pixelSizeByte, s32 w, s32 h)
{
cellFont->Warning("cellFontRenderSurfaceInit(surface_addr=0x%x, buffer_addr=0x%x, bufferWidthByte=%d, pixelSizeByte=%d, w=%d, h=%d)",
surface.GetAddr(), buffer_addr, bufferWidthByte, pixelSizeByte, w, h);
surface.addr(), buffer_addr, bufferWidthByte, pixelSizeByte, w, h);
surface->buffer_addr = buffer_addr;
surface->widthByte = bufferWidthByte;
@ -234,13 +234,13 @@ void cellFontRenderSurfaceInit(mem_ptr_t<CellFontRenderSurface> surface, u32 buf
surface->height = h;
if (!buffer_addr)
surface->buffer_addr = Memory.Alloc(bufferWidthByte * h, 1); // TODO: Huge memory leak
surface->buffer_addr = (u32)Memory.Alloc(bufferWidthByte * h, 1); // TODO: Huge memory leak
}
void cellFontRenderSurfaceSetScissor(mem_ptr_t<CellFontRenderSurface> surface, s32 x0, s32 y0, s32 w, s32 h)
void cellFontRenderSurfaceSetScissor(vm::ptr<CellFontRenderSurface> surface, s32 x0, s32 y0, s32 w, s32 h)
{
cellFont->Warning("cellFontRenderSurfaceSetScissor(surface_addr=0x%x, x0=%d, y0=%d, w=%d, h=%d)",
surface.GetAddr(), x0, y0, w, h);
surface.addr(), x0, y0, w, h);
surface->Scissor.x0 = x0;
surface->Scissor.y0 = y0;
@ -248,21 +248,19 @@ void cellFontRenderSurfaceSetScissor(mem_ptr_t<CellFontRenderSurface> surface, s
surface->Scissor.y1 = h;
}
int cellFontSetScalePixel(mem_ptr_t<CellFont> font, float w, float h)
int cellFontSetScalePixel(vm::ptr<CellFont> font, float w, float h)
{
w = GetCurrentPPUThread().FPR[1]; // TODO: Something is wrong with the float arguments
h = GetCurrentPPUThread().FPR[2]; // TODO: Something is wrong with the float arguments
cellFont->Log("cellFontSetScalePixel(font_addr=0x%x, w=%f, h=%f)", font.GetAddr(), w, h);
cellFont->Log("cellFontSetScalePixel(font_addr=0x%x, w=%f, h=%f)", font.addr(), w, h);
font->scale_x = w;
font->scale_y = h;
return CELL_FONT_OK;
}
int cellFontGetHorizontalLayout(mem_ptr_t<CellFont> font, mem_ptr_t<CellFontHorizontalLayout> layout)
int cellFontGetHorizontalLayout(vm::ptr<CellFont> font, vm::ptr<CellFontHorizontalLayout> layout)
{
cellFont->Log("cellFontGetHorizontalLayout(font_addr=0x%x, layout_addr=0x%x)",
font.GetAddr(), layout.GetAddr());
font.addr(), layout.addr());
int ascent, descent, lineGap;
float scale = stbtt_ScaleForPixelHeight(font->stbfont, font->scale_y);
@ -274,21 +272,21 @@ int cellFontGetHorizontalLayout(mem_ptr_t<CellFont> font, mem_ptr_t<CellFontHori
return CELL_FONT_OK;
}
int cellFontBindRenderer(mem_ptr_t<CellFont> font, mem_ptr_t<CellFontRenderer> renderer)
int cellFontBindRenderer(vm::ptr<CellFont> font, vm::ptr<CellFontRenderer> renderer)
{
cellFont->Warning("cellFontBindRenderer(font_addr=0x%x, renderer_addr=0x%x)",
font.GetAddr(), renderer.GetAddr());
font.addr(), renderer.addr());
if (font->renderer_addr)
return CELL_FONT_ERROR_RENDERER_ALREADY_BIND;
font->renderer_addr = renderer.GetAddr();
font->renderer_addr = renderer.addr();
return CELL_FONT_OK;
}
int cellFontUnbindRenderer(mem_ptr_t<CellFont> font)
int cellFontUnbindRenderer(vm::ptr<CellFont> font)
{
cellFont->Warning("cellFontBindRenderer(font_addr=0x%x)", font.GetAddr());
cellFont->Warning("cellFontBindRenderer(font_addr=0x%x)", font.addr());
if (!font->renderer_addr)
return CELL_FONT_ERROR_RENDERER_UNBIND;
@ -303,11 +301,9 @@ int cellFontDestroyRenderer()
return CELL_FONT_OK;
}
int cellFontSetupRenderScalePixel(mem_ptr_t<CellFont> font, float w, float h)
int cellFontSetupRenderScalePixel(vm::ptr<CellFont> font, float w, float h)
{
w = GetCurrentPPUThread().FPR[1]; // TODO: Something is wrong with the float arguments
h = GetCurrentPPUThread().FPR[2]; // TODO: Something is wrong with the float arguments
cellFont->Log("cellFontSetupRenderScalePixel(font_addr=0x%x, w=%f, h=%f)", font.GetAddr(), w, h);
cellFont->Log("cellFontSetupRenderScalePixel(font_addr=0x%x, w=%f, h=%f)", font.addr(), w, h);
if (!font->renderer_addr)
return CELL_FONT_ERROR_RENDERER_UNBIND;
@ -316,10 +312,10 @@ int cellFontSetupRenderScalePixel(mem_ptr_t<CellFont> font, float w, float h)
return CELL_FONT_OK;
}
int cellFontGetRenderCharGlyphMetrics(mem_ptr_t<CellFont> font, u32 code, mem_ptr_t<CellFontGlyphMetrics> metrics)
int cellFontGetRenderCharGlyphMetrics(vm::ptr<CellFont> font, u32 code, vm::ptr<CellFontGlyphMetrics> metrics)
{
cellFont->Log("cellFontGetRenderCharGlyphMetrics(font_addr=0x%x, code=0x%x, metrics_addr=0x%x)",
font.GetAddr(), code, metrics.GetAddr());
font.addr(), code, metrics.addr());
if (!font->renderer_addr)
return CELL_FONT_ERROR_RENDERER_UNBIND;
@ -328,12 +324,10 @@ int cellFontGetRenderCharGlyphMetrics(mem_ptr_t<CellFont> font, u32 code, mem_pt
return CELL_FONT_OK;
}
int cellFontRenderCharGlyphImage(mem_ptr_t<CellFont> font, u32 code, mem_ptr_t<CellFontRenderSurface> surface, float x, float y, mem_ptr_t<CellFontGlyphMetrics> metrics, mem_ptr_t<CellFontImageTransInfo> transInfo)
int cellFontRenderCharGlyphImage(vm::ptr<CellFont> font, u32 code, vm::ptr<CellFontRenderSurface> surface, float x, float y, vm::ptr<CellFontGlyphMetrics> metrics, vm::ptr<CellFontImageTransInfo> transInfo)
{
x = GetCurrentPPUThread().FPR[1]; // TODO: Something is wrong with the float arguments
y = GetCurrentPPUThread().FPR[2]; // TODO: Something is wrong with the float arguments
cellFont->Log("cellFontRenderCharGlyphImage(font_addr=0x%x, code=0x%x, surface_addr=0x%x, x=%f, y=%f, metrics_addr=0x%x, trans_addr=0x%x)",
font.GetAddr(), code, surface.GetAddr(), x, y, metrics.GetAddr(), transInfo.GetAddr());
font.addr(), code, surface.addr(), x, y, metrics.addr(), transInfo.addr());
if (!font->renderer_addr)
return CELL_FONT_ERROR_RENDERER_UNBIND;
@ -348,7 +342,7 @@ int cellFontRenderCharGlyphImage(mem_ptr_t<CellFont> font, u32 code, mem_ptr_t<C
int baseLineY;
int ascent, descent, lineGap;
stbtt_GetFontVMetrics(font->stbfont, &ascent, &descent, &lineGap);
baseLineY = ascent * scale;
baseLineY = (int)((float)ascent * scale); // ???
// Move the rendered character to the surface
unsigned char* buffer = (unsigned char*)Memory.VirtualToRealAddr(surface->buffer_addr);
@ -374,10 +368,9 @@ int cellFontEndLibrary()
return CELL_FONT_OK;
}
int cellFontSetEffectSlant(mem_ptr_t<CellFont> font, float slantParam)
int cellFontSetEffectSlant(vm::ptr<CellFont> font, float slantParam)
{
slantParam = GetCurrentPPUThread().FPR[1]; // TODO: Something is wrong with the float arguments
cellFont->Log("cellFontSetEffectSlant(font_addr=0x%x, slantParam=%f)", font.GetAddr(), slantParam);
cellFont->Log("cellFontSetEffectSlant(font_addr=0x%x, slantParam=%f)", font.addr(), slantParam);
if (slantParam < -1.0 || slantParam > 1.0)
return CELL_FONT_ERROR_INVALID_PARAMETER;
@ -386,26 +379,26 @@ int cellFontSetEffectSlant(mem_ptr_t<CellFont> font, float slantParam)
return CELL_FONT_OK;
}
int cellFontGetEffectSlant(mem_ptr_t<CellFont> font, mem32_t slantParam)
int cellFontGetEffectSlant(vm::ptr<CellFont> font, vm::ptr<be_t<float>> slantParam)
{
cellFont->Warning("cellFontSetEffectSlant(font_addr=0x%x, slantParam_addr=0x%x)", font.GetAddr(), slantParam.GetAddr());
cellFont->Warning("cellFontSetEffectSlant(font_addr=0x%x, slantParam_addr=0x%x)", font.addr(), slantParam.addr());
slantParam = font->slant; //Does this conversion from be_t<float> to *mem32_t work?
*slantParam = font->slant;
return CELL_FONT_OK;
}
int cellFontGetFontIdCode(mem_ptr_t<CellFont> font, u32 code, mem32_t fontId, mem32_t fontCode)
int cellFontGetFontIdCode(vm::ptr<CellFont> font, u32 code, vm::ptr<be_t<u32>> fontId, vm::ptr<be_t<u32>> fontCode)
{
cellFont->Todo("cellFontGetFontIdCode(font_addr=0x%x, code=0x%x, fontId_addr=0x%x, fontCode_addr=0x%x",
font.GetAddr(), code, fontId.GetAddr(), fontCode.GetAddr());
font.addr(), code, fontId.addr(), fontCode.addr());
// TODO: ?
return CELL_FONT_OK;
}
int cellFontCloseFont(mem_ptr_t<CellFont> font)
int cellFontCloseFont(vm::ptr<CellFont> font)
{
cellFont->Warning("cellFontCloseFont(font_addr=0x%x)", font.GetAddr());
cellFont->Warning("cellFontCloseFont(font_addr=0x%x)", font.addr());
if (font->origin == CELL_FONT_OPEN_FONTSET ||
font->origin == CELL_FONT_OPEN_FONT_FILE ||
@ -415,10 +408,10 @@ int cellFontCloseFont(mem_ptr_t<CellFont> font)
return CELL_FONT_OK;
}
int cellFontGetCharGlyphMetrics(mem_ptr_t<CellFont> font, u32 code, mem_ptr_t<CellFontGlyphMetrics> metrics)
int cellFontGetCharGlyphMetrics(vm::ptr<CellFont> font, u32 code, vm::ptr<CellFontGlyphMetrics> metrics)
{
cellFont->Log("cellFontGetCharGlyphMetrics(font_addr=0x%x, code=0x%x, metrics_addr=0x%x",
font.GetAddr(), code, metrics.GetAddr());
font.addr(), code, metrics.addr());
int x0, y0, x1, y1;
int advanceWidth, leftSideBearing;

View file

@ -13,15 +13,15 @@ Module *cellFontFT = nullptr;
CCellFontFTInternal* s_fontFtInternalInstance = nullptr;
int cellFontInitLibraryFreeTypeWithRevision(u64 revisionFlags, mem_ptr_t<CellFontLibraryConfigFT> config, u32 lib_addr_addr)
int cellFontInitLibraryFreeTypeWithRevision(u64 revisionFlags, vm::ptr<CellFontLibraryConfigFT> config, u32 lib_addr_addr)
{
cellFontFT->Warning("cellFontInitLibraryFreeTypeWithRevision(revisionFlags=0x%llx, config_addr=0x%x, lib_addr_addr=0x%x",
revisionFlags, config.GetAddr(), lib_addr_addr);
revisionFlags, config.addr(), lib_addr_addr);
//if (s_fontInternalInstance->m_bInitialized)
//return CELL_FONT_ERROR_UNINITIALIZED;
Memory.Write32(lib_addr_addr, Memory.Alloc(sizeof(CellFontLibrary), 1));
Memory.Write32(lib_addr_addr, (u32)Memory.Alloc(sizeof(CellFontLibrary), 1));
return CELL_OK;
}

View file

@ -16,10 +16,10 @@ Module *cellGame = nullptr;
std::string contentInfo = "";
std::string usrdir = "";
int cellGameBootCheck(mem32_t type, mem32_t attributes, mem_ptr_t<CellGameContentSize> size, mem_list_ptr_t<u8> dirName)
int cellGameBootCheck(vm::ptr<be_t<u32>> type, vm::ptr<be_t<u32>> attributes, vm::ptr<CellGameContentSize> size, vm::ptr<char> dirName)
{
cellGame->Warning("cellGameBootCheck(type_addr=0x%x, attributes_addr=0x%x, size_addr=0x%x, dirName_addr=0x%x)",
type.GetAddr(), attributes.GetAddr(), size.GetAddr(), dirName.GetAddr());
type.addr(), attributes.addr(), size.addr(), dirName.addr());
if (size)
{
@ -48,27 +48,27 @@ int cellGameBootCheck(mem32_t type, mem32_t attributes, mem_ptr_t<CellGameConten
std::string category = psf.GetString("CATEGORY");
if (category.substr(0, 2) == "DG")
{
type = CELL_GAME_GAMETYPE_DISC;
attributes = 0; // TODO
if (dirName.GetAddr()) Memory.WriteString(dirName.GetAddr(), ""); // ???
*type = CELL_GAME_GAMETYPE_DISC;
*attributes = 0; // TODO
if (dirName) Memory.WriteString(dirName.addr(), ""); // ???
contentInfo = "/dev_bdvd/PS3_GAME";
usrdir = "/dev_bdvd/PS3_GAME/USRDIR";
}
else if (category.substr(0, 2) == "HG")
{
std::string titleId = psf.GetString("TITLE_ID");
type = CELL_GAME_GAMETYPE_HDD;
attributes = 0; // TODO
if (dirName.GetAddr()) Memory.WriteString(dirName.GetAddr(), titleId);
*type = CELL_GAME_GAMETYPE_HDD;
*attributes = 0; // TODO
if (dirName) Memory.WriteString(dirName.addr(), titleId);
contentInfo = "/dev_hdd0/game/" + titleId;
usrdir = "/dev_hdd0/game/" + titleId + "/USRDIR";
}
else if (category.substr(0, 2) == "GD")
{
std::string titleId = psf.GetString("TITLE_ID");
type = CELL_GAME_GAMETYPE_DISC;
attributes = CELL_GAME_ATTRIBUTE_PATCH; // TODO
if (dirName.GetAddr()) Memory.WriteString(dirName.GetAddr(), titleId); // ???
*type = CELL_GAME_GAMETYPE_DISC;
*attributes = CELL_GAME_ATTRIBUTE_PATCH; // TODO
if (dirName) Memory.WriteString(dirName.addr(), titleId); // ???
contentInfo = "/dev_bdvd/PS3_GAME";
usrdir = "/dev_bdvd/PS3_GAME/USRDIR";
}
@ -81,9 +81,9 @@ int cellGameBootCheck(mem32_t type, mem32_t attributes, mem_ptr_t<CellGameConten
return CELL_GAME_RET_OK;
}
int cellGamePatchCheck(mem_ptr_t<CellGameContentSize> size, u32 reserved_addr)
int cellGamePatchCheck(vm::ptr<CellGameContentSize> size, u32 reserved_addr)
{
cellGame->Warning("cellGamePatchCheck(size_addr=0x%x, reserved_addr=0x%x)", size.GetAddr(), reserved_addr);
cellGame->Warning("cellGamePatchCheck(size_addr=0x%x, reserved_addr=0x%x)", size.addr(), reserved_addr);
if (reserved_addr != 0)
{
@ -129,9 +129,9 @@ int cellGamePatchCheck(mem_ptr_t<CellGameContentSize> size, u32 reserved_addr)
return CELL_GAME_RET_OK;
}
int cellGameDataCheck(u32 type, const mem_list_ptr_t<u8> dirName, mem_ptr_t<CellGameContentSize> size)
int cellGameDataCheck(u32 type, vm::ptr<const char> dirName, vm::ptr<CellGameContentSize> size)
{
cellGame->Warning("cellGameDataCheck(type=0x%x, dirName_addr=0x%x, size_addr=0x%x)", type, dirName.GetAddr(), size.GetAddr());
cellGame->Warning("cellGameDataCheck(type=0x%x, dirName_addr=0x%x, size_addr=0x%x)", type, dirName.addr(), size.addr());
if ((type - 1) >= 3)
{
@ -163,7 +163,7 @@ int cellGameDataCheck(u32 type, const mem_list_ptr_t<u8> dirName, mem_ptr_t<Cell
}
else
{
std::string dir = "/dev_hdd0/game/" + std::string(dirName.GetString());
const std::string dir = std::string("/dev_hdd0/game/") + dirName.get_ptr();
if (!Emu.GetVFS().ExistsDir(dir))
{
@ -177,10 +177,10 @@ int cellGameDataCheck(u32 type, const mem_list_ptr_t<u8> dirName, mem_ptr_t<Cell
return CELL_GAME_RET_OK;
}
int cellGameContentPermit(mem_list_ptr_t<u8> contentInfoPath, mem_list_ptr_t<u8> usrdirPath)
int cellGameContentPermit(vm::ptr<char> contentInfoPath, vm::ptr<char> usrdirPath)
{
cellGame->Warning("cellGameContentPermit(contentInfoPath_addr=0x%x, usrdirPath_addr=0x%x)",
contentInfoPath.GetAddr(), usrdirPath.GetAddr());
contentInfoPath.addr(), usrdirPath.addr());
if (contentInfo == "" && usrdir == "")
{
@ -189,8 +189,8 @@ int cellGameContentPermit(mem_list_ptr_t<u8> contentInfoPath, mem_list_ptr_t<u8>
}
// TODO: make it better
Memory.WriteString(contentInfoPath.GetAddr(), contentInfo);
Memory.WriteString(usrdirPath.GetAddr(), usrdir);
Memory.WriteString(contentInfoPath.addr(), contentInfo);
Memory.WriteString(usrdirPath.addr(), usrdir);
contentInfo = "";
usrdir = "";
@ -198,11 +198,11 @@ int cellGameContentPermit(mem_list_ptr_t<u8> contentInfoPath, mem_list_ptr_t<u8>
return CELL_GAME_RET_OK;
}
int cellGameDataCheckCreate2(u32 version, const mem_list_ptr_t<u8> dirName, u32 errDialog,
mem_func_ptr_t<void(*)(mem_ptr_t<CellGameDataCBResult> cbResult, mem_ptr_t<CellGameDataStatGet> get, mem_ptr_t<CellGameDataStatSet> set)> funcStat, u32 container)
int cellGameDataCheckCreate2(u32 version, vm::ptr<const char> dirName, u32 errDialog,
vm::ptr<void(*)(vm::ptr<CellGameDataCBResult> cbResult, vm::ptr<CellGameDataStatGet> get, vm::ptr<CellGameDataStatSet> set)> funcStat, u32 container)
{
cellGame->Warning("cellGameDataCheckCreate2(version=0x%x, dirName_addr=0x%x, errDialog=0x%x, funcStat_addr=0x%x, container=%d)",
version, dirName.GetAddr(), errDialog, funcStat.GetAddr(), container);
version, dirName.addr(), errDialog, funcStat.addr(), container);
if (version != CELL_GAMEDATA_VERSION_CURRENT || errDialog > 1)
{
@ -212,7 +212,7 @@ int cellGameDataCheckCreate2(u32 version, const mem_list_ptr_t<u8> dirName, u32
// TODO: output errors (errDialog)
const std::string dir = "/dev_hdd0/game/" + std::string(dirName.GetString());
const std::string dir = std::string("/dev_hdd0/game/") + dirName.get_ptr();
if (!Emu.GetVFS().ExistsDir(dir))
{
@ -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,12 +265,12 @@ 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, cbGet, cbSet);
if (cbSet->setParam.GetAddr())
if (cbSet->setParam)
{
// TODO: write PARAM.SFO from cbSet
cellGame->Todo("cellGameDataCheckCreate2(): writing PARAM.SFO parameters (addr=0x%x)", cbSet->setParam.GetAddr());
cellGame->Todo("cellGameDataCheckCreate2(): writing PARAM.SFO parameters (addr=0x%x)", cbSet->setParam.addr());
}
switch ((s32)cbResult->result)
@ -304,17 +304,17 @@ int cellGameDataCheckCreate2(u32 version, const mem_list_ptr_t<u8> dirName, u32
}
}
int cellGameDataCheckCreate(u32 version, const mem_list_ptr_t<u8> dirName, u32 errDialog,
mem_func_ptr_t<void(*)(mem_ptr_t<CellGameDataCBResult> cbResult, mem_ptr_t<CellGameDataStatGet> get, mem_ptr_t<CellGameDataStatSet> set)> funcStat, u32 container)
int cellGameDataCheckCreate(u32 version, vm::ptr<const char> dirName, u32 errDialog,
vm::ptr<void(*)(vm::ptr<CellGameDataCBResult> cbResult, vm::ptr<CellGameDataStatGet> get, vm::ptr<CellGameDataStatSet> set)> funcStat, u32 container)
{
// TODO: almost identical, the only difference is that this function will always calculate the size of game data
return cellGameDataCheckCreate2(version, dirName, errDialog, funcStat, container);
}
int cellGameCreateGameData(mem_ptr_t<CellGameSetInitParams> init, mem_list_ptr_t<u8> tmp_contentInfoPath, mem_list_ptr_t<u8> tmp_usrdirPath)
int cellGameCreateGameData(vm::ptr<CellGameSetInitParams> init, vm::ptr<char> tmp_contentInfoPath, vm::ptr<char> tmp_usrdirPath)
{
cellGame->Todo("cellGameCreateGameData(init_addr=0x%x, tmp_contentInfoPath_addr=0x%x, tmp_usrdirPath_addr=0x%x)",
init.GetAddr(), tmp_contentInfoPath.GetAddr(), tmp_usrdirPath.GetAddr());
init.addr(), tmp_contentInfoPath.addr(), tmp_usrdirPath.addr());
// TODO: create temporary game directory, set initial PARAM.SFO parameters
// cellGameContentPermit should then move files in non-temporary location and return their non-temporary displacement
@ -327,9 +327,9 @@ int cellGameDeleteGameData()
return CELL_OK;
}
int cellGameGetParamInt(u32 id, mem32_t value)
int cellGameGetParamInt(u32 id, vm::ptr<be_t<u32>> value)
{
cellGame->Warning("cellGameGetParamInt(id=%d, value_addr=0x%x)", id, value.GetAddr());
cellGame->Warning("cellGameGetParamInt(id=%d, value_addr=0x%x)", id, value.addr());
// TODO: Access through cellGame***Check functions
vfsFile f("/app_home/PARAM.SFO");
@ -339,9 +339,9 @@ int cellGameGetParamInt(u32 id, mem32_t value)
switch(id)
{
case CELL_GAME_PARAMID_PARENTAL_LEVEL: value = psf.GetInteger("PARENTAL_LEVEL"); break;
case CELL_GAME_PARAMID_RESOLUTION: value = psf.GetInteger("RESOLUTION"); break;
case CELL_GAME_PARAMID_SOUND_FORMAT: value = psf.GetInteger("SOUND_FORMAT"); break;
case CELL_GAME_PARAMID_PARENTAL_LEVEL: *value = psf.GetInteger("PARENTAL_LEVEL"); break;
case CELL_GAME_PARAMID_RESOLUTION: *value = psf.GetInteger("RESOLUTION"); break;
case CELL_GAME_PARAMID_SOUND_FORMAT: *value = psf.GetInteger("SOUND_FORMAT"); break;
default:
return CELL_GAME_ERROR_INVALID_ID;

View file

@ -197,6 +197,6 @@ struct CellGameDataStatGet
struct CellGameDataStatSet
{
mem_beptr_t<CellGameDataSystemFileParam> setParam;
vm::bptr<CellGameDataSystemFileParam> setParam;
be_t<u32> reserved;
};

View file

@ -29,7 +29,7 @@ const u32 tiled_pitches[] = {
u32 local_size = 0;
u32 local_addr = 0;
u32 system_mode = 0;
u64 system_mode = 0;
CellGcmConfig current_config;
CellGcmContextData current_context;
@ -65,8 +65,8 @@ CellGcmOffsetTable offsetTable;
void InitOffsetTable()
{
offsetTable.ioAddress = Memory.Alloc(3072 * sizeof(u16), 1);
offsetTable.eaAddress = Memory.Alloc(512 * sizeof(u16), 1);
offsetTable.ioAddress = (u32)Memory.Alloc(3072 * sizeof(u16), 1);
offsetTable.eaAddress = (u32)Memory.Alloc(512 * sizeof(u16), 1);
_sys_memset(offsetTable.ioAddress, 0xFF, 3072 * sizeof(u16));
_sys_memset(offsetTable.eaAddress, 0xFF, 512 * sizeof(u16));
@ -79,32 +79,32 @@ void InitOffsetTable()
u32 cellGcmGetLabelAddress(u8 index)
{
cellGcmSys->Log("cellGcmGetLabelAddress(index=%d)", index);
return Memory.RSXCMDMem.GetStartAddr() + 0x10 * index;
return (u32)Memory.RSXCMDMem.GetStartAddr() + 0x10 * index;
}
u32 cellGcmGetReportDataAddressLocation(u32 index, u32 location)
vm::ptr<CellGcmReportData> cellGcmGetReportDataAddressLocation(u32 index, u32 location)
{
cellGcmSys->Warning("cellGcmGetReportDataAddressLocation(index=%d, location=%d)", index, location);
if (location == CELL_GCM_LOCATION_LOCAL) {
if (index >= 2048) {
cellGcmSys->Error("cellGcmGetReportDataAddressLocation: Wrong local index (%d)", index);
return 0;
return vm::ptr<CellGcmReportData>::make(0);
}
return Memory.RSXFBMem.GetStartAddr() + index * 0x10;
return vm::ptr<CellGcmReportData>::make((u32)Memory.RSXFBMem.GetStartAddr() + index * 0x10);
}
if (location == CELL_GCM_LOCATION_MAIN) {
if (index >= 1024*1024) {
cellGcmSys->Error("cellGcmGetReportDataAddressLocation: Wrong main index (%d)", index);
return 0;
return vm::ptr<CellGcmReportData>::make(0);
}
// TODO: It seems m_report_main_addr is not initialized
return Emu.GetGSManager().GetRender().m_report_main_addr + index * 0x10;
return vm::ptr<CellGcmReportData>::make(Emu.GetGSManager().GetRender().m_report_main_addr + index * 0x10);
}
cellGcmSys->Error("cellGcmGetReportDataAddressLocation: Wrong location (%d)", location);
return 0;
return vm::ptr<CellGcmReportData>::make(0);
}
u64 cellGcmGetTimeStamp(u32 index)
@ -129,11 +129,11 @@ u32 cellGcmGetNotifyDataAddress(u32 index)
cellGcmSys->Warning("cellGcmGetNotifyDataAddress(index=%d)", index);
// Get address of 'IO table' and 'EA table'
MemoryAllocator<CellGcmOffsetTable> table;
cellGcmGetOffsetTable(table.GetAddr());
vm::var<CellGcmOffsetTable> table;
cellGcmGetOffsetTable(table);
// If entry not in use, return NULL
u16 entry = mem_ptr_t<u16>(table->eaAddress)[241];
u16 entry = Memory.Read16(table->eaAddress + 241 * sizeof(u16));
if (entry == 0xFFFF) {
return 0;
}
@ -144,9 +144,9 @@ u32 cellGcmGetNotifyDataAddress(u32 index)
/*
* Get base address of local report data area
*/
u32 _cellGcmFunc12()
vm::ptr<CellGcmReportData> _cellGcmFunc12()
{
return Memory.RSXFBMem.GetStartAddr(); // TODO
return vm::ptr<CellGcmReportData>::make(Memory.RSXFBMem.GetStartAddr()); // TODO
}
u32 cellGcmGetReport(u32 type, u32 index)
@ -162,7 +162,7 @@ u32 cellGcmGetReport(u32 type, u32 index)
return -1;
}
mem_ptr_t<CellGcmReportData> local_reports = _cellGcmFunc12();
vm::ptr<CellGcmReportData> local_reports = _cellGcmFunc12();
return local_reports[index].value;
}
@ -174,14 +174,14 @@ u32 cellGcmGetReportDataAddress(u32 index)
cellGcmSys->Error("cellGcmGetReportDataAddress: Wrong local index (%d)", index);
return 0;
}
return Memory.RSXFBMem.GetStartAddr() + index * 0x10;
return (u32)Memory.RSXFBMem.GetStartAddr() + index * 0x10;
}
u32 cellGcmGetReportDataLocation(u32 index, u32 location)
{
cellGcmSys->Warning("cellGcmGetReportDataLocation(index=%d, location=%d)", index, location);
mem_ptr_t<CellGcmReportData> report = cellGcmGetReportDataAddressLocation(index, location);
vm::ptr<CellGcmReportData> report = cellGcmGetReportDataAddressLocation(index, location);
return report->value;
}
@ -281,9 +281,9 @@ int cellGcmBindZcull(u8 index)
return CELL_OK;
}
int cellGcmGetConfiguration(mem_ptr_t<CellGcmConfig> config)
int cellGcmGetConfiguration(vm::ptr<CellGcmConfig> config)
{
cellGcmSys->Log("cellGcmGetConfiguration(config_addr=0x%x)", config.GetAddr());
cellGcmSys->Log("cellGcmGetConfiguration(config_addr=0x%x)", config.addr());
*config = current_config;
@ -315,16 +315,16 @@ void _cellGcmFunc1()
return;
}
void _cellGcmFunc15(mem_ptr_t<CellGcmContextData> context)
void _cellGcmFunc15(vm::ptr<CellGcmContextData> context)
{
cellGcmSys->Todo("_cellGcmFunc15(context_addr=0x%x)", context.GetAddr());
cellGcmSys->Todo("_cellGcmFunc15(context_addr=0x%x)", context.addr());
return;
}
// Called by cellGcmInit
s32 _cellGcmInitBody(mem_ptr_t<CellGcmContextData> context, u32 cmdSize, u32 ioSize, u32 ioAddress)
s32 _cellGcmInitBody(vm::ptr<CellGcmContextData> context, u32 cmdSize, u32 ioSize, u32 ioAddress)
{
cellGcmSys->Warning("_cellGcmInitBody(context_addr=0x%x, cmdSize=0x%x, ioSize=0x%x, ioAddress=0x%x)", context.GetAddr(), cmdSize, ioSize, ioAddress);
cellGcmSys->Warning("_cellGcmInitBody(context_addr=0x%x, cmdSize=0x%x, ioSize=0x%x, ioAddress=0x%x)", context.addr(), cmdSize, ioSize, ioAddress);
if(!cellGcmSys->IsLoaded())
cellGcmSys->Load();
@ -332,7 +332,7 @@ s32 _cellGcmInitBody(mem_ptr_t<CellGcmContextData> context, u32 cmdSize, u32 ioS
if(!local_size && !local_addr)
{
local_size = 0xf900000; // TODO: Get sdk_version in _cellGcmFunc15 and pass it to gcmGetLocalMemorySize
local_addr = Memory.RSXFBMem.GetStartAddr();
local_addr = (u32)Memory.RSXFBMem.GetStartAddr();
Memory.RSXFBMem.AllocAlign(local_size);
}
@ -374,11 +374,11 @@ s32 _cellGcmInitBody(mem_ptr_t<CellGcmContextData> context, u32 cmdSize, u32 ioS
current_context.current = current_context.begin;
current_context.callback = Emu.GetRSXCallback() - 4;
gcm_info.context_addr = Memory.MainMem.AllocAlign(0x1000);
gcm_info.context_addr = (u32)Memory.MainMem.AllocAlign(0x1000);
gcm_info.control_addr = gcm_info.context_addr + 0x40;
Memory.WriteData(gcm_info.context_addr, current_context);
Memory.Write32(context.GetAddr(), gcm_info.context_addr);
Memory.Write32(context.addr(), gcm_info.context_addr);
CellGcmControl& ctrl = (CellGcmControl&)Memory[gcm_info.control_addr];
ctrl.put = 0;
@ -386,10 +386,10 @@ s32 _cellGcmInitBody(mem_ptr_t<CellGcmContextData> context, u32 cmdSize, u32 ioS
ctrl.ref = -1;
auto& render = Emu.GetGSManager().GetRender();
render.m_ctxt_addr = context.GetAddr();
render.m_gcm_buffers_addr = Memory.Alloc(sizeof(CellGcmDisplayInfo) * 8, sizeof(CellGcmDisplayInfo));
render.m_zculls_addr = Memory.Alloc(sizeof(CellGcmZcullInfo) * 8, sizeof(CellGcmZcullInfo));
render.m_tiles_addr = Memory.Alloc(sizeof(CellGcmTileInfo) * 15, sizeof(CellGcmTileInfo));
render.m_ctxt_addr = context.addr();
render.m_gcm_buffers_addr = (u32)Memory.Alloc(sizeof(CellGcmDisplayInfo) * 8, sizeof(CellGcmDisplayInfo));
render.m_zculls_addr = (u32)Memory.Alloc(sizeof(CellGcmZcullInfo) * 8, sizeof(CellGcmZcullInfo));
render.m_tiles_addr = (u32)Memory.Alloc(sizeof(CellGcmTileInfo) * 15, sizeof(CellGcmTileInfo));
render.m_gcm_buffers_count = 0;
render.m_gcm_current_buffer = 0;
render.m_main_mem_addr = 0;
@ -448,9 +448,9 @@ int cellGcmSetDisplayBuffer(u32 id, u32 offset, u32 pitch, u32 width, u32 height
return CELL_OK;
}
int cellGcmSetFlip(mem_ptr_t<CellGcmContextData> ctxt, u32 id)
int cellGcmSetFlip(vm::ptr<CellGcmContextData> ctxt, u32 id)
{
cellGcmSys->Log("cellGcmSetFlip(ctx=0x%x, id=0x%x)", ctxt.GetAddr(), id);
cellGcmSys->Log("cellGcmSetFlip(ctx=0x%x, id=0x%x)", ctxt.addr(), id);
int res = cellGcmSetPrepareFlip(ctxt, id);
return res < 0 ? CELL_GCM_ERROR_FAILURE : CELL_OK;
@ -489,9 +489,9 @@ void cellGcmSetFlipStatus()
Emu.GetGSManager().GetRender().m_flip_status = 0;
}
s32 cellGcmSetPrepareFlip(mem_ptr_t<CellGcmContextData> ctxt, u32 id)
s32 cellGcmSetPrepareFlip(vm::ptr<CellGcmContextData> ctxt, u32 id)
{
cellGcmSys->Log("cellGcmSetPrepareFlip(ctx=0x%x, id=0x%x)", ctxt.GetAddr(), id);
cellGcmSys->Log("cellGcmSetPrepareFlip(ctx=0x%x, id=0x%x)", ctxt.addr(), id);
if(id > 7)
{
@ -507,7 +507,7 @@ s32 cellGcmSetPrepareFlip(mem_ptr_t<CellGcmContextData> ctxt, u32 id)
if(current + 8 >= end)
{
cellGcmSys->Error("bad flip!");
//cellGcmCallback(ctxt.GetAddr(), current + 8 - end);
//cellGcmCallback(ctxt.addr(), current + 8 - end);
//copied:
CellGcmControl& ctrl = (CellGcmControl&)Memory[gcm_info.control_addr];
@ -528,7 +528,7 @@ s32 cellGcmSetPrepareFlip(mem_ptr_t<CellGcmContextData> ctxt, u32 id)
Memory.Write32(current + 4, id);
ctxt->current += 8;
if(ctxt.GetAddr() == gcm_info.context_addr)
if(ctxt.addr() == gcm_info.context_addr)
{
CellGcmControl& ctrl = (CellGcmControl&)Memory[gcm_info.control_addr];
ctrl.put += 8;
@ -610,9 +610,9 @@ void cellGcmSetVBlankHandler(u32 handler_addr)
Emu.GetGSManager().GetRender().m_vblank_handler.SetAddr(handler_addr);
}
int cellGcmSetWaitFlip(mem_ptr_t<CellGcmContextData> ctxt)
int cellGcmSetWaitFlip(vm::ptr<CellGcmContextData> ctxt)
{
cellGcmSys->Log("cellGcmSetWaitFlip(ctx=0x%x)", ctxt.GetAddr());
cellGcmSys->Log("cellGcmSetWaitFlip(ctx=0x%x)", ctxt.addr());
GSLockCurrent lock(GS_LOCK_WAIT_FLIP);
return CELL_OK;
@ -801,9 +801,9 @@ int cellGcmSortRemapEaIoAddress()
//----------------------------------------------------------------------------
// Memory Mapping
//----------------------------------------------------------------------------
s32 cellGcmAddressToOffset(u64 address, mem32_t offset)
s32 cellGcmAddressToOffset(u64 address, vm::ptr<be_t<u32>> offset)
{
cellGcmSys->Log("cellGcmAddressToOffset(address=0x%x,offset_addr=0x%x)", address, offset.GetAddr());
cellGcmSys->Log("cellGcmAddressToOffset(address=0x%x,offset_addr=0x%x)", address, offset.addr());
// Address not on main memory or local memory
if (address >= 0xD0000000) {
@ -814,7 +814,7 @@ s32 cellGcmAddressToOffset(u64 address, mem32_t offset)
// Address in local memory
if (Memory.RSXFBMem.IsInMyRange(address)) {
result = address - Memory.RSXFBMem.GetStartAddr();
result = (u32)(address - Memory.RSXFBMem.GetStartAddr());
}
// Address in main memory else check
else
@ -830,7 +830,7 @@ s32 cellGcmAddressToOffset(u64 address, mem32_t offset)
}
}
offset = result;
*offset = result;
return CELL_OK;
}
@ -838,12 +838,12 @@ u32 cellGcmGetMaxIoMapSize()
{
cellGcmSys->Log("cellGcmGetMaxIoMapSize()");
return Memory.RSXIOMem.GetEndAddr() - Memory.RSXIOMem.GetStartAddr() - Memory.RSXIOMem.GetReservedAmount();
return (u32)(Memory.RSXIOMem.GetEndAddr() - Memory.RSXIOMem.GetStartAddr() - Memory.RSXIOMem.GetReservedAmount());
}
void cellGcmGetOffsetTable(mem_ptr_t<CellGcmOffsetTable> table)
void cellGcmGetOffsetTable(vm::ptr<CellGcmOffsetTable> table)
{
cellGcmSys->Log("cellGcmGetOffsetTable(table_addr=0x%x)", table.GetAddr());
cellGcmSys->Log("cellGcmGetOffsetTable(table_addr=0x%x)", table.addr());
table->ioAddress = offsetTable.ioAddress;
table->eaAddress = offsetTable.eaAddress;
@ -901,7 +901,7 @@ s32 cellGcmMapLocalMemory(u64 address, u64 size)
if (!local_size && !local_addr)
{
local_size = 0xf900000; //TODO
local_addr = Memory.RSXFBMem.GetStartAddr();
local_addr = (u32)Memory.RSXFBMem.GetStartAddr();
Memory.RSXFBMem.AllocAlign(local_size);
Memory.Write32(address, local_addr);
Memory.Write32(size, local_size);
@ -915,28 +915,28 @@ s32 cellGcmMapLocalMemory(u64 address, u64 size)
return CELL_OK;
}
s32 cellGcmMapMainMemory(u64 ea, u32 size, mem32_t offset)
s32 cellGcmMapMainMemory(u32 ea, u32 size, vm::ptr<be_t<u32>> offset)
{
cellGcmSys->Warning("cellGcmMapMainMemory(ea=0x%x,size=0x%x,offset_addr=0x%x)", ea, size, offset.GetAddr());
cellGcmSys->Warning("cellGcmMapMainMemory(ea=0x%x,size=0x%x,offset_addr=0x%x)", ea, size, offset.addr());
u64 io;
u32 io;
if ((ea & 0xFFFFF) || (size & 0xFFFFF)) return CELL_GCM_ERROR_FAILURE;
//check if the mapping was successfull
if (io = Memory.RSXIOMem.Map(ea, size, 0))
if (io = (u32)Memory.RSXIOMem.Map(ea, size, 0))
{
// convert to offset
io = io - Memory.RSXIOMem.GetStartAddr();
io = io - (u32)Memory.RSXIOMem.GetStartAddr();
//fill the offset table
for (u32 i = 0; i<(size >> 20); i++)
{
Memory.Write16(offsetTable.ioAddress + ((ea >> 20) + i)*sizeof(u16), (io >> 20) + i);
Memory.Write16(offsetTable.eaAddress + ((io >> 20) + i)*sizeof(u16), (ea >> 20) + i);
Memory.Write16(offsetTable.ioAddress + ((ea >> 20) + i) * sizeof(u16), (u16)(io >> 20) + i);
Memory.Write16(offsetTable.eaAddress + ((io >> 20) + i) * sizeof(u16), (u16)(ea >> 20) + i);
}
offset = io;
*offset = io;
}
else
{
@ -1095,17 +1095,17 @@ void cellGcmSetDefaultCommandBuffer()
// Other
//------------------------------------------------------------------------
int cellGcmSetFlipCommand(u32 ctx, u32 id)
int cellGcmSetFlipCommand(vm::ptr<CellGcmContextData> ctx, u32 id)
{
cellGcmSys->Log("cellGcmSetFlipCommand(ctx=0x%x, id=0x%x)", ctx, id);
cellGcmSys->Log("cellGcmSetFlipCommand(ctx_addr=0x%x, id=0x%x)", ctx.addr(), id);
return cellGcmSetPrepareFlip(ctx, id);
}
int cellGcmSetFlipCommandWithWaitLabel(u32 ctx, u32 id, u32 label_index, u32 label_value)
int cellGcmSetFlipCommandWithWaitLabel(vm::ptr<CellGcmContextData> ctx, u32 id, u32 label_index, u32 label_value)
{
cellGcmSys->Log("cellGcmSetFlipCommandWithWaitLabel(ctx=0x%x, id=0x%x, label_index=0x%x, label_value=0x%x)",
ctx, id, label_index, label_value);
cellGcmSys->Log("cellGcmSetFlipCommandWithWaitLabel(ctx_addr=0x%x, id=0x%x, label_index=0x%x, label_value=0x%x)",
ctx.addr(), id, label_index, label_value);
int res = cellGcmSetPrepareFlip(ctx, id);
Memory.Write32(Memory.RSXCMDMem.GetStartAddr() + 0x10 * label_index, label_value);

View file

@ -22,15 +22,15 @@ u32 gcmGetLocalMemorySize();
// SysCalls
s32 cellGcmSetPrepareFlip(mem_ptr_t<CellGcmContextData> ctxt, u32 id);
s32 cellGcmSetPrepareFlip(vm::ptr<CellGcmContextData> ctxt, u32 id);
s32 cellGcmAddressToOffset(u64 address, mem32_t offset);
s32 cellGcmAddressToOffset(u64 address, vm::ptr<be_t<u32>> offset);
u32 cellGcmGetMaxIoMapSize();
void cellGcmGetOffsetTable(mem_ptr_t<CellGcmOffsetTable> table);
void cellGcmGetOffsetTable(vm::ptr<CellGcmOffsetTable> table);
s32 cellGcmIoOffsetToAddress(u32 ioOffset, u64 address);
s32 cellGcmMapEaIoAddress(u32 ea, u32 io, u32 size);
s32 cellGcmMapEaIoAddressWithFlags(u32 ea, u32 io, u32 size, u32 flags);
s32 cellGcmMapMainMemory(u64 ea, u32 size, mem32_t offset);
s32 cellGcmMapMainMemory(u32 ea, u32 size, vm::ptr<be_t<u32>> offset);
s32 cellGcmReserveIoMapSize(u32 size);
s32 cellGcmUnmapEaIoAddress(u64 ea);
s32 cellGcmUnmapIoAddress(u64 io);

View file

@ -23,10 +23,10 @@ int cellGifDecExtCreate(u32 mainHandle, u32 threadInParam, u32 threadOutParam, u
return CELL_OK;
}
int cellGifDecOpen(u32 mainHandle, mem32_t subHandle, const mem_ptr_t<CellGifDecSrc> src, mem_ptr_t<CellGifDecOpnInfo> openInfo)
int cellGifDecOpen(u32 mainHandle, vm::ptr<be_t<u32>> subHandle, const vm::ptr<CellGifDecSrc> src, vm::ptr<CellGifDecOpnInfo> openInfo)
{
cellGifDec->Warning("cellGifDecOpen(mainHandle=0x%x, subHandle_addr=0x%x, src_addr=0x%x, openInfo_addr=0x%x)",
mainHandle, subHandle.GetAddr(), src.GetAddr(), openInfo.GetAddr());
mainHandle, subHandle.addr(), src.addr(), openInfo.addr());
CellGifDecSubHandle *current_subHandle = new CellGifDecSubHandle;
current_subHandle->fd = 0;
@ -40,29 +40,29 @@ 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, vm::ptr<be_t<u32>>::make(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);
if (ret != CELL_OK) return ret;
current_subHandle->fileSize = sb->st_size; // Get CellFsStat.st_size
break;
}
// From now, every u32 subHandle argument is a pointer to a CellGifDecSubHandle struct.
subHandle = cellGifDec->GetNewId(current_subHandle);
*subHandle = cellGifDec->GetNewId(current_subHandle);
return CELL_OK;
}
int cellGifDecReadHeader(u32 mainHandle, u32 subHandle, mem_ptr_t<CellGifDecInfo> info)
int cellGifDecReadHeader(u32 mainHandle, u32 subHandle, vm::ptr<CellGifDecInfo> info)
{
cellGifDec->Warning("cellGifDecReadHeader(mainHandle=0x%x, subHandle=0x%x, info_addr=0x%x)",
mainHandle, subHandle, info.GetAddr());
mainHandle, subHandle, info.addr());
CellGifDecSubHandle* subHandle_data;
if(!cellGifDec->CheckId(subHandle, subHandle_data))
@ -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);
cellFsLseek(fd, 0, CELL_SEEK_SET, pos);
cellFsRead(fd, buffer.addr(), buffer.size(), nread);
break;
}
@ -109,10 +109,10 @@ int cellGifDecReadHeader(u32 mainHandle, u32 subHandle, mem_ptr_t<CellGifDecInfo
return CELL_OK;
}
int cellGifDecSetParameter(u32 mainHandle, u32 subHandle, const mem_ptr_t<CellGifDecInParam> inParam, mem_ptr_t<CellGifDecOutParam> outParam)
int cellGifDecSetParameter(u32 mainHandle, u32 subHandle, const vm::ptr<CellGifDecInParam> inParam, vm::ptr<CellGifDecOutParam> outParam)
{
cellGifDec->Warning("cellGifDecSetParameter(mainHandle=0x%x, subHandle=0x%x, inParam_addr=0x%x, outParam_addr=0x%x)",
mainHandle, subHandle, inParam.GetAddr(), outParam.GetAddr());
mainHandle, subHandle, inParam.addr(), outParam.addr());
CellGifDecSubHandle* subHandle_data;
if(!cellGifDec->CheckId(subHandle, subHandle_data))
@ -139,10 +139,10 @@ int cellGifDecSetParameter(u32 mainHandle, u32 subHandle, const mem_ptr_t<CellGi
return CELL_OK;
}
int cellGifDecDecodeData(u32 mainHandle, u32 subHandle, mem8_ptr_t data, const mem_ptr_t<CellGifDecDataCtrlParam> dataCtrlParam, mem_ptr_t<CellGifDecDataOutInfo> dataOutInfo)
int cellGifDecDecodeData(u32 mainHandle, u32 subHandle, vm::ptr<u8> data, const vm::ptr<CellGifDecDataCtrlParam> dataCtrlParam, vm::ptr<CellGifDecDataOutInfo> dataOutInfo)
{
cellGifDec->Warning("cellGifDecDecodeData(mainHandle=0x%x, subHandle=0x%x, data_addr=0x%x, dataCtrlParam_addr=0x%x, dataOutInfo_addr=0x%x)",
mainHandle, subHandle, data.GetAddr(), dataCtrlParam.GetAddr(), dataOutInfo.GetAddr());
mainHandle, subHandle, data.addr(), dataCtrlParam.addr(), dataOutInfo.addr());
dataOutInfo->status = CELL_GIFDEC_DEC_STATUS_STOP;
@ -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(fileSize);
MemoryAllocator<u64> pos, nread;
vm::var<unsigned char[]> gif((u32)fileSize);
vm::var<be_t<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);
cellFsLseek(fd, 0, CELL_SEEK_SET, pos);
cellFsRead(fd, gif.addr(), gif.size(), nread);
break;
}
@ -174,14 +174,14 @@ 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(), fileSize, &width, &height, &actual_components, 4),
stbi_load_from_memory(gif.ptr(), (s32)fileSize, &width, &height, &actual_components, 4),
&::free
);
if (!image)
return CELL_GIFDEC_ERROR_STREAM_FORMAT;
const int bytesPerLine = dataCtrlParam->outputBytesPerLine;
const int bytesPerLine = (u32)dataCtrlParam->outputBytesPerLine;
const char nComponents = 4;
uint image_size = width * height * nComponents;
@ -196,12 +196,12 @@ int cellGifDecDecodeData(u32 mainHandle, u32 subHandle, mem8_ptr_t data, const m
{
const int dstOffset = i * bytesPerLine;
const int srcOffset = width * nComponents * i;
memcpy(Memory + (data.GetAddr() + dstOffset), &image.get()[srcOffset], linesize);
memcpy(Memory + (data.addr() + dstOffset), &image.get()[srcOffset], linesize);
}
}
else
{
memcpy(Memory + data.GetAddr(), image.get(), image_size);
memcpy(Memory + data.addr(), image.get(), image_size);
}
}
break;
@ -224,15 +224,15 @@ int cellGifDecDecodeData(u32 mainHandle, u32 subHandle, mem8_ptr_t data, const m
output[j + 2] = image.get()[srcOffset + j + 1];
output[j + 3] = image.get()[srcOffset + j + 2];
}
memcpy(Memory + (data.GetAddr() + dstOffset), output, linesize);
memcpy(Memory + (data.addr() + dstOffset), output, linesize);
}
free(output);
}
else
{
uint* dest = (uint*)new char[image_size];
uint* img = (uint*)new char[image_size];
uint* source_current = (uint*)&(image.get()[0]);
uint* dest_current = dest;
uint* dest_current = img;
for (uint i = 0; i < image_size / nComponents; i++)
{
uint val = *source_current;
@ -240,9 +240,8 @@ int cellGifDecDecodeData(u32 mainHandle, u32 subHandle, mem8_ptr_t data, const m
source_current++;
dest_current++;
}
// NOTE: AppendRawBytes has diff side-effect vs Memory.CopyFromReal
data.AppendRawBytes((u8*)dest, image_size);
delete[] dest;
memcpy(data.get_ptr(), img, image_size);
delete[] img;
}
}
break;

View file

@ -28,10 +28,10 @@ int cellJpgDecDestroy(u32 mainHandle)
return CELL_OK;
}
int cellJpgDecOpen(u32 mainHandle, mem32_t subHandle, mem_ptr_t<CellJpgDecSrc> src, mem_ptr_t<CellJpgDecOpnInfo> openInfo)
int cellJpgDecOpen(u32 mainHandle, vm::ptr<be_t<u32>> subHandle, vm::ptr<CellJpgDecSrc> src, vm::ptr<CellJpgDecOpnInfo> openInfo)
{
cellJpgDec->Warning("cellJpgDecOpen(mainHandle=0x%x, subHandle_addr=0x%x, src_addr=0x%x, openInfo_addr=0x%x)",
mainHandle, subHandle.GetAddr(), src.GetAddr(), openInfo.GetAddr());
mainHandle, subHandle.addr(), src.addr(), openInfo.addr());
CellJpgDecSubHandle *current_subHandle = new CellJpgDecSubHandle;
@ -46,21 +46,21 @@ 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, vm::ptr<be_t<u32>>::make(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);
if (ret != CELL_OK) return ret;
current_subHandle->fileSize = sb->st_size; // Get CellFsStat.st_size
break;
}
// From now, every u32 subHandle argument is a pointer to a CellJpgDecSubHandle struct.
subHandle = cellJpgDec->GetNewId(current_subHandle);
*subHandle = cellJpgDec->GetNewId(current_subHandle);
return CELL_OK;
}
@ -80,9 +80,9 @@ int cellJpgDecClose(u32 mainHandle, u32 subHandle)
return CELL_OK;
}
int cellJpgDecReadHeader(u32 mainHandle, u32 subHandle, mem_ptr_t<CellJpgDecInfo> info)
int cellJpgDecReadHeader(u32 mainHandle, u32 subHandle, vm::ptr<CellJpgDecInfo> info)
{
cellJpgDec->Log("cellJpgDecReadHeader(mainHandle=0x%x, subHandle=0x%x, info_addr=0x%x)", mainHandle, subHandle, info.GetAddr());
cellJpgDec->Log("cellJpgDecReadHeader(mainHandle=0x%x, subHandle=0x%x, info_addr=0x%x)", mainHandle, subHandle, info.addr());
CellJpgDecSubHandle* subHandle_data;
if(!cellJpgDec->CheckId(subHandle, subHandle_data))
@ -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(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);
cellFsLseek(fd, 0, CELL_SEEK_SET, pos);
cellFsRead(fd, buffer.addr(), buffer.size(), nread);
break;
}
@ -147,10 +147,10 @@ int cellJpgDecReadHeader(u32 mainHandle, u32 subHandle, mem_ptr_t<CellJpgDecInfo
return CELL_OK;
}
int cellJpgDecDecodeData(u32 mainHandle, u32 subHandle, mem8_ptr_t data, const mem_ptr_t<CellJpgDecDataCtrlParam> dataCtrlParam, mem_ptr_t<CellJpgDecDataOutInfo> dataOutInfo)
int cellJpgDecDecodeData(u32 mainHandle, u32 subHandle, vm::ptr<u8> data, const vm::ptr<CellJpgDecDataCtrlParam> dataCtrlParam, vm::ptr<CellJpgDecDataOutInfo> dataOutInfo)
{
cellJpgDec->Log("cellJpgDecDecodeData(mainHandle=0x%x, subHandle=0x%x, data_addr=0x%x, dataCtrlParam_addr=0x%x, dataOutInfo_addr=0x%x)",
mainHandle, subHandle, data.GetAddr(), dataCtrlParam.GetAddr(), dataOutInfo.GetAddr());
mainHandle, subHandle, data.addr(), dataCtrlParam.addr(), dataOutInfo.addr());
dataOutInfo->status = CELL_JPGDEC_DEC_STATUS_STOP;
CellJpgDecSubHandle* subHandle_data;
@ -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(fileSize);
MemoryAllocator<u64> pos, nread;
vm::var<unsigned char[]> jpg((u32)fileSize);
vm::var<be_t<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);
cellFsLseek(fd, 0, CELL_SEEK_SET, pos);
cellFsRead(fd, jpg.addr(), jpg.size(), nread);
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(), fileSize, &width, &height, &actual_components, 4),
stbi_load_from_memory(jpg.ptr(), (s32)fileSize, &width, &height, &actual_components, 4),
&::free
);
@ -189,7 +189,7 @@ int cellJpgDecDecodeData(u32 mainHandle, u32 subHandle, mem8_ptr_t data, const m
return CELL_JPGDEC_ERROR_STREAM_FORMAT;
const bool flip = current_outParam.outputMode == CELL_JPGDEC_BOTTOM_TO_TOP;
const int bytesPerLine = dataCtrlParam->outputBytesPerLine;
const int bytesPerLine = (u32)dataCtrlParam->outputBytesPerLine;
size_t image_size = width * height;
switch((u32)current_outParam.outputColorSpace)
@ -206,12 +206,12 @@ int cellJpgDecDecodeData(u32 mainHandle, u32 subHandle, mem8_ptr_t data, const m
{
const int dstOffset = i * bytesPerLine;
const int srcOffset = width * nComponents * (flip ? height - i - 1 : i);
memcpy(Memory + (data.GetAddr() + dstOffset), &image.get()[srcOffset], linesize);
memcpy(Memory + (data.addr() + dstOffset), &image.get()[srcOffset], linesize);
}
}
else
{
memcpy(Memory + data.GetAddr(), image.get(), image_size);
memcpy(Memory + data.addr(), image.get(), image_size);
}
}
break;
@ -236,15 +236,15 @@ int cellJpgDecDecodeData(u32 mainHandle, u32 subHandle, mem8_ptr_t data, const m
output[j + 2] = image.get()[srcOffset + j + 1];
output[j + 3] = image.get()[srcOffset + j + 2];
}
memcpy(Memory + (data.GetAddr() + dstOffset), output, linesize);
memcpy(Memory + (data.addr() + dstOffset), output, linesize);
}
free(output);
}
else
{
uint* dest = (uint*)new char[image_size];
uint* img = (uint*)new char[image_size];
uint* source_current = (uint*)&(image.get()[0]);
uint* dest_current = dest;
uint* dest_current = img;
for (uint i = 0; i < image_size / nComponents; i++)
{
uint val = *source_current;
@ -252,9 +252,8 @@ int cellJpgDecDecodeData(u32 mainHandle, u32 subHandle, mem8_ptr_t data, const m
source_current++;
dest_current++;
}
// NOTE: AppendRawBytes has diff side-effect vs Memory.CopyFromReal
data.AppendRawBytes((u8*)dest, image_size);
delete[] dest;
memcpy(data.get_ptr(), img, image_size);
delete[] img;
}
}
break;
@ -274,15 +273,15 @@ int cellJpgDecDecodeData(u32 mainHandle, u32 subHandle, mem8_ptr_t data, const m
dataOutInfo->status = CELL_JPGDEC_DEC_STATUS_FINISH;
if(dataCtrlParam->outputBytesPerLine)
dataOutInfo->outputLines = image_size / dataCtrlParam->outputBytesPerLine;
dataOutInfo->outputLines = (u32)(image_size / dataCtrlParam->outputBytesPerLine);
return CELL_OK;
}
int cellJpgDecSetParameter(u32 mainHandle, u32 subHandle, const mem_ptr_t<CellJpgDecInParam> inParam, mem_ptr_t<CellJpgDecOutParam> outParam)
int cellJpgDecSetParameter(u32 mainHandle, u32 subHandle, const vm::ptr<CellJpgDecInParam> inParam, vm::ptr<CellJpgDecOutParam> outParam)
{
cellJpgDec->Log("cellJpgDecSetParameter(mainHandle=0x%x, subHandle=0x%x, inParam_addr=0x%x, outParam_addr=0x%x)",
mainHandle, subHandle, inParam.GetAddr(), outParam.GetAddr());
mainHandle, subHandle, inParam.addr(), outParam.addr());
CellJpgDecSubHandle* subHandle_data;
if(!cellJpgDec->CheckId(subHandle, subHandle_data))

View file

@ -18,32 +18,32 @@
//Module cellL10n(0x001e, cellL10n_init);
Module *cellL10n = nullptr;
int UTF16stoUTF8s(mem16_ptr_t utf16, mem64_t utf16_len, mem8_ptr_t utf8, mem64_t utf8_len)
int UTF16stoUTF8s(vm::lptrl<const char16_t> utf16, vm::ptr<be_t<u32>> utf16_len, vm::ptr<char> utf8, vm::ptr<be_t<u32>> utf8_len)
{
cellL10n->Warning("UTF16stoUTF8s(utf16_addr=0x%x, utf16_len_addr=0x%x, utf8_addr=0x%x, utf8_len_addr=0x%x)",
utf16.GetAddr(), utf16_len.GetAddr(), utf8.GetAddr(), utf8_len.GetAddr());
utf16.addr(), utf16_len.addr(), utf8.addr(), utf8_len.addr());
std::u16string wstr =(char16_t*)Memory.VirtualToRealAddr(utf16.GetAddr());
wstr.resize(utf16_len.GetValue()); // TODO: Is this really the role of utf16_len in this function?
std::u16string wstr = utf16.get_ptr(); // ???
wstr.resize(*utf16_len); // TODO: Is this really the role of utf16_len in this function?
#ifdef _MSC_VER
std::wstring_convert<std::codecvt_utf8_utf16<char16_t>,char16_t> convert;
std::string str = convert.to_bytes(wstr);
if (utf8_len.GetValue() < str.size())
if (*utf8_len < str.size())
{
utf8_len = str.size();
*utf8_len = str.size();
return DSTExhausted;
}
utf8_len = str.size();
Memory.WriteString(utf8, str.c_str());
*utf8_len = str.size();
Memory.WriteString(utf8.addr(), str);
#endif
return ConversionOK;
}
int jstrchk(mem8_ptr_t jstr)
int jstrchk(vm::ptr<const char> jstr)
{
cellL10n->Warning("jstrchk(jstr_addr=0x%x) -> utf8", jstr.GetAddr());
cellL10n->Warning("jstrchk(jstr_addr=0x%x) -> utf8", jstr.addr());
return L10N_STR_UTF8;
}
@ -240,14 +240,14 @@ int _L10nConvertStr(int src_code, const void *src, size_t * src_len, int dst_cod
return ConverterUnknown;
if (strnlen_s((char*)src, *src_len) != *src_len) return SRCIllegal;
//std::string wrapped_source = (char*)Memory.VirtualToRealAddr(src.GetAddr());
//std::string wrapped_source = (char*)Memory.VirtualToRealAddr(src.addr());
std::string wrapped_source((char*)src);
//if (wrapped_source.length != src_len.GetValue()) return SRCIllegal;
std::string target = _OemToOem(srcCode, dstCode, wrapped_source);
if (target.length() > *dst_len) return DSTExhausted;
Memory.WriteString(dst, target.c_str());
Memory.WriteString(dst.addr(), target);
return ConversionOK;
}
@ -260,8 +260,8 @@ int _L10nConvertStr(int src_code, const void* src, size_t * src_len, int dst_cod
if ((_L10nCodeParse(src_code, srcCode)) && (_L10nCodeParse(dst_code, dstCode)))
{
iconv_t ict = iconv_open(srcCode.c_str(), dstCode.c_str());
//char *srcBuf = (char*)Memory.VirtualToRealAddr(src.GetAddr());
//char *dstBuf = (char*)Memory.VirtualToRealAddr(dst.GetAddr());
//char *srcBuf = (char*)Memory.VirtualToRealAddr(src.addr());
//char *dstBuf = (char*)Memory.VirtualToRealAddr(dst.addr());
char *srcBuf = (char*)src, *dstBuf = (char*)dst;
size_t srcLen = *src_len, dstLen = *dst_len;
size_t ictd = iconv(ict, &srcBuf, &srcLen, &dstBuf, &dstLen);
@ -283,11 +283,11 @@ int _L10nConvertStr(int src_code, const void* src, size_t * src_len, int dst_cod
#endif
//TODO: Check the code in emulation. If support for UTF8/UTF16/UTF32/UCS2/UCS4 should use wider chars.. awful.
int L10nConvertStr(int src_code, mem8_ptr_t src, mem64_t src_len, int dst_code, mem8_ptr_t dst, mem64_t dst_len)
int L10nConvertStr(int src_code, vm::ptr<const void> src, vm::ptr<be_t<u32>> src_len, int dst_code, vm::ptr<void> dst, vm::ptr<be_t<u32>> dst_len)
{
cellL10n->Todo("L10nConvertStr(src_code=%d,src=0x%x,src_len=%ld,dst_code=%d,dst=0x%x,dst_len=%ld)",
src_code, src.GetAddr(), src_len.GetValue(), dst_code, dst.GetAddr(), dst_len.GetValue());
cellL10n->Todo("L10nConvertStr: 1st char at dst: %x(Hex)", *((char*)Memory.VirtualToRealAddr(src.GetAddr())));
src_code, src.addr(), src_len.addr(), dst_code, dst.addr(), dst_len.addr());
cellL10n->Todo("L10nConvertStr: 1st char at dst: %x(Hex)", *((char*)src.get_ptr()));
#ifdef _MSC_VER
unsigned int srcCode = 0, dstCode = 0; //OEM code pages
bool src_page_converted = _L10nCodeParse(src_code, srcCode); //Check if code is in list.
@ -298,14 +298,14 @@ int L10nConvertStr(int src_code, mem8_ptr_t src, mem64_t src_len, int dst_code,
return ConverterUnknown;
//if (strnlen_s((char*)src, *src_len) != *src_len) return SRCIllegal;
std::string wrapped_source = (char*)Memory.VirtualToRealAddr(src.GetAddr());
std::string wrapped_source = (char*)src.get_ptr();
//std::string wrapped_source((char*)src);
if (wrapped_source.length() != src_len.GetValue()) return SRCIllegal;
if (wrapped_source.length() != *src_len) return SRCIllegal;
std::string target = _OemToOem(srcCode, dstCode, wrapped_source);
if (target.length() > dst_len.GetValue()) return DSTExhausted;
if (target.length() > *dst_len) return DSTExhausted;
Memory.WriteString(dst, target.c_str());
Memory.WriteString(dst.addr(), target);
return ConversionOK;
#else
@ -314,13 +314,13 @@ int L10nConvertStr(int src_code, mem8_ptr_t src, mem64_t src_len, int dst_code,
if ((_L10nCodeParse(src_code, srcCode)) && (_L10nCodeParse(dst_code, dstCode)))
{
iconv_t ict = iconv_open(srcCode.c_str(), dstCode.c_str());
char *srcBuf = (char*)Memory.VirtualToRealAddr(src.GetAddr());
char *dstBuf = (char*)Memory.VirtualToRealAddr(dst.GetAddr());
char *srcBuf = (char*)src.get_ptr();
char *dstBuf = (char*)dst.get_ptr();
//char *srcBuf = (char*)src, *dstBuf = (char*)dst;
//size_t srcLen = *src_len, dstLen = *dst_len;
size_t srcLen = src_len.GetValue(), dstLen = dst_len.GetValue();
size_t srcLen = *src_len, dstLen = *dst_len;
size_t ictd = iconv(ict, &srcBuf, &srcLen, &dstBuf, &dstLen);
if (ictd != src_len.GetValue())//if (ictd != *src_len)
if (ictd != *src_len)//if (ictd != *src_len)
{
if (errno == EILSEQ)
retValue = SRCIllegal; //Invalid multi-byte sequence

View file

@ -3,6 +3,7 @@
#include "Emu/System.h"
#include "Emu/SysCalls/Modules.h"
#include "Utilities/Log.h"
#include "Utilities/rMsgBox.h"
#include "Emu/SysCalls/lv2/sys_time.h"
#include "cellSysutil.h"
@ -59,10 +60,10 @@ void MsgDialogClose()
g_msg_dialog_wait_until = get_system_time();
}
int cellMsgDialogOpen2(u32 type, mem_list_ptr_t<u8> msgString, mem_func_ptr_t<CellMsgDialogCallback> callback, u32 userData, u32 extParam)
int cellMsgDialogOpen2(u32 type, vm::ptr<const char> msgString, vm::ptr<CellMsgDialogCallback> callback, u32 userData, u32 extParam)
{
cellSysutil->Warning("cellMsgDialogOpen2(type=0x%x, msgString_addr=0x%x, callback_addr=0x%x, userData=0x%x, extParam=0x%x)",
type, msgString.GetAddr(), callback.GetAddr(), userData, extParam);
type, msgString.addr(), callback.addr(), userData, extParam);
//type |= CELL_MSGDIALOG_TYPE_PROGRESSBAR_SINGLE | CELL_MSGDIALOG_TYPE_BG_INVISIBLE;
//type |= CELL_MSGDIALOG_TYPE_BUTTON_TYPE_YESNO | CELL_MSGDIALOG_TYPE_DEFAULT_CURSOR_NO;
@ -82,12 +83,14 @@ int cellMsgDialogOpen2(u32 type, mem_list_ptr_t<u8> msgString, mem_func_ptr_t<Ce
default: g_msg_dialog_progress_bar_count = 0; break; // ???
}
thread t("MsgDialog thread", [=]()
std::string msg = msgString.get_ptr();
thread t("MsgDialog thread", [type, msg, callback, userData, extParam]()
{
switch (type & CELL_MSGDIALOG_TYPE_SE_TYPE)
{
case CELL_MSGDIALOG_TYPE_SE_TYPE_NORMAL: cellSysutil->Warning("Message: \n%s", msgString.GetString()); break;
case CELL_MSGDIALOG_TYPE_SE_TYPE_ERROR: cellSysutil->Error("Message: \n%s", msgString.GetString()); break;
case CELL_MSGDIALOG_TYPE_SE_TYPE_NORMAL: LOG_WARNING(TTY, "%s", msg.c_str()); break;
case CELL_MSGDIALOG_TYPE_SE_TYPE_ERROR: LOG_ERROR(TTY, "%s", msg.c_str()); break;
}
switch (type & CELL_MSGDIALOG_TYPE_SE_MUTE) // TODO
@ -99,9 +102,9 @@ int cellMsgDialogOpen2(u32 type, mem_list_ptr_t<u8> msgString, mem_func_ptr_t<Ce
u64 status = CELL_MSGDIALOG_BUTTON_NONE;
volatile bool m_signal = false;
CallAfter([&]()
CallAfter([type, msg, &status, &m_signal]()
{
MsgDialogCreate(type, (char*)msgString.GetPtr(), status);
MsgDialogCreate(type, msg.c_str(), status);
m_signal = true;
});
@ -122,13 +125,20 @@ int cellMsgDialogOpen2(u32 type, mem_list_ptr_t<u8> msgString, mem_func_ptr_t<Ce
}
if (callback && (g_msg_dialog_state != msgDialogAbort))
callback.async(status, userData);
callback.async((s32)status, userData); // TODO: this callback should be registered
CallAfter([&]()
CallAfter([&m_signal]()
{
MsgDialogDestroy();
m_signal = false;
});
while (m_signal)
{
std::this_thread::sleep_for(std::chrono::milliseconds(1));
}
g_msg_dialog_state = msgDialogNone;
});
t.detach();
@ -136,10 +146,10 @@ int cellMsgDialogOpen2(u32 type, mem_list_ptr_t<u8> msgString, mem_func_ptr_t<Ce
return CELL_OK;
}
int cellMsgDialogOpenErrorCode(u32 errorCode, mem_func_ptr_t<CellMsgDialogCallback> callback, mem_ptr_t<void> userData, u32 extParam)
int cellMsgDialogOpenErrorCode(u32 errorCode, vm::ptr<CellMsgDialogCallback> callback, u32 userData, u32 extParam)
{
cellSysutil->Warning("cellMsgDialogOpenErrorCode(errorCode=0x%x, callback_addr=0x%x, userData=%d, extParam=%d)",
errorCode, callback.GetAddr(), userData, extParam);
cellSysutil->Warning("cellMsgDialogOpenErrorCode(errorCode=0x%x, callback_addr=0x%x, userData=0x%x, extParam=%d)",
errorCode, callback.addr(), userData, extParam);
std::string errorMessage;
switch (errorCode)
@ -230,7 +240,7 @@ int cellMsgDialogOpenErrorCode(u32 errorCode, mem_func_ptr_t<CellMsgDialogCallba
}
if (callback)
callback(status, userData);
callback((s32)status, userData);
return CELL_OK;
}
@ -278,10 +288,10 @@ int cellMsgDialogAbort()
return CELL_OK;
}
int cellMsgDialogProgressBarSetMsg(u32 progressBarIndex, mem_list_ptr_t<u8> msgString)
int cellMsgDialogProgressBarSetMsg(u32 progressBarIndex, vm::ptr<const char> msgString)
{
cellSysutil->Warning("cellMsgDialogProgressBarSetMsg(progressBarIndex=%d, msgString_addr=0x%x): '%s'",
progressBarIndex, msgString.GetAddr(), msgString.GetString());
cellSysutil->Warning("cellMsgDialogProgressBarSetMsg(progressBarIndex=%d, msgString_addr=0x%x ['%s'])",
progressBarIndex, msgString.addr(), msgString.get_ptr());
if (g_msg_dialog_state != msgDialogOpen)
{
@ -293,7 +303,7 @@ int cellMsgDialogProgressBarSetMsg(u32 progressBarIndex, mem_list_ptr_t<u8> msgS
return CELL_MSGDIALOG_ERROR_PARAM;
}
std::string text(msgString.GetString());
std::string text = msgString.get_ptr();
CallAfter([text, progressBarIndex]()
{

View file

@ -81,10 +81,10 @@ enum
typedef void(*CellMsgDialogCallback)(int buttonType, u32 userData);
int cellMsgDialogOpen2(u32 type, mem_list_ptr_t<u8> msgString, mem_func_ptr_t<CellMsgDialogCallback> callback, u32 userData, u32 extParam);
int cellMsgDialogOpenErrorCode(u32 errorCode, mem_func_ptr_t<CellMsgDialogCallback> callback, mem_ptr_t<void> userData, u32 extParam);
int cellMsgDialogOpen2(u32 type, vm::ptr<const char> msgString, vm::ptr<CellMsgDialogCallback> callback, u32 userData, u32 extParam);
int cellMsgDialogOpenErrorCode(u32 errorCode, vm::ptr<CellMsgDialogCallback> callback, u32 userData, u32 extParam);
int cellMsgDialogProgressBarSetMsg(u32 progressBarIndex, mem_list_ptr_t<u8> msgString);
int cellMsgDialogProgressBarSetMsg(u32 progressBarIndex, vm::ptr<const char> msgString);
int cellMsgDialogProgressBarReset(u32 progressBarIndex);
int cellMsgDialogProgressBarInc(u32 progressBarIndex, u32 delta);
int cellMsgDialogClose(float delay);

View file

@ -1,7 +1,7 @@
#include "stdafx.h"
#include "Emu/Memory/Memory.h"
#include "Emu/SysCalls/Modules.h"
#include "Emu/System.h"
#include "Emu/SysCalls/Modules.h"
#include "cellNetCtl.h"
@ -21,18 +21,18 @@ int cellNetCtlTerm()
return CELL_OK;
}
int cellNetCtlGetState(mem32_t state)
int cellNetCtlGetState(vm::ptr<be_t<u32>> state)
{
cellNetCtl->Log("cellNetCtlGetState(state_addr=0x%x)", state.GetAddr());
cellNetCtl->Log("cellNetCtlGetState(state_addr=0x%x)", state.addr());
state = CELL_NET_CTL_STATE_Disconnected; // TODO: Allow other states
*state = CELL_NET_CTL_STATE_Disconnected; // TODO: Allow other states
return CELL_OK;
}
int cellNetCtlAddHandler(mem_func_ptr_t<cellNetCtlHandler> handler, mem32_t arg, s32 hid)
int cellNetCtlAddHandler(vm::ptr<cellNetCtlHandler> handler, vm::ptr<be_t<u32>> arg, s32 hid)
{
cellNetCtl->Todo("cellNetCtlAddHandler(handler_addr=0x%x, arg_addr=0x%x, hid=%x)", handler.GetAddr(), arg.GetAddr(), hid);
cellNetCtl->Todo("cellNetCtlAddHandler(handler_addr=0x%x, arg_addr=0x%x, hid=%x)", handler.addr(), arg.addr(), hid);
return CELL_OK;
}
@ -44,20 +44,19 @@ int cellNetCtlDelHandler(s32 hid)
return CELL_OK;
}
int cellNetCtlGetInfo(s32 code, mem_ptr_t<CellNetCtlInfo> info)
int cellNetCtlGetInfo(s32 code, vm::ptr<CellNetCtlInfo> info)
{
cellNetCtl->Todo("cellNetCtlGetInfo(code=%x, info_addr=0x%x)", code, info.GetAddr());
cellNetCtl->Todo("cellNetCtlGetInfo(code=%x, info_addr=0x%x)", code, info.addr());
return CELL_OK;
}
int cellNetCtlNetStartDialogLoadAsync(mem_ptr_t<CellNetCtlNetStartDialogParam> param)
int cellNetCtlNetStartDialogLoadAsync(vm::ptr<CellNetCtlNetStartDialogParam> param)
{
cellNetCtl->Warning("cellNetCtlNetStartDialogLoadAsync(param_addr=0x%x)", param.GetAddr());
cellNetCtl->Warning("cellNetCtlNetStartDialogLoadAsync(param_addr=0x%x)", param.addr());
// TODO: Actually sign into PSN
Emu.GetCallbackManager().m_exit_callback.Handle(CELL_SYSUTIL_NET_CTL_NETSTART_FINISHED, 0);
return CELL_OK;
}
@ -68,18 +67,17 @@ int cellNetCtlNetStartDialogAbortAsync()
return CELL_OK;
}
int cellNetCtlNetStartDialogUnloadAsync(mem_ptr_t<CellNetCtlNetStartDialogResult> result)
int cellNetCtlNetStartDialogUnloadAsync(vm::ptr<CellNetCtlNetStartDialogResult> result)
{
cellNetCtl->Warning("cellNetCtlNetStartDialogUnloadAsync(result_addr=0x%x)", result.GetAddr());
cellNetCtl->Warning("cellNetCtlNetStartDialogUnloadAsync(result_addr=0x%x)", result.addr());
Emu.GetCallbackManager().m_exit_callback.Handle(CELL_SYSUTIL_NET_CTL_NETSTART_UNLOADED, 0);
return CELL_OK;
}
int cellNetCtlGetNatInfo(mem_ptr_t<CellNetCtlNatInfo> natInfo)
int cellNetCtlGetNatInfo(vm::ptr<CellNetCtlNatInfo> natInfo)
{
cellNetCtl->Todo("cellNetCtlGetNatInfo(natInfo_addr=0x%x)", natInfo.GetAddr());
cellNetCtl->Todo("cellNetCtlGetNatInfo(natInfo_addr=0x%x)", natInfo.addr());
if (natInfo->size == 0)
{

View file

@ -257,4 +257,4 @@ struct CellNetCtlNatInfo
be_t<u32> mapped_addr;
};
typedef void(*cellNetCtlHandler)(s32 prev_state, s32 new_state, s32 event, s32 error_code, mem32_t arg);
typedef void(*cellNetCtlHandler)(s32 prev_state, s32 new_state, s32 event, s32 error_code, vm::ptr<be_t<u32>> arg);

View file

@ -6,7 +6,7 @@
Module *cellPamf = nullptr;
int pamfStreamTypeToEsFilterId(u8 type, u8 ch, mem_ptr_t<CellCodecEsFilterId> pEsFilterId)
int pamfStreamTypeToEsFilterId(u8 type, u8 ch, vm::ptr<CellCodecEsFilterId> pEsFilterId)
{
//TODO: convert type and ch to EsFilterId
pEsFilterId->filterIdMajor = 0;
@ -74,10 +74,10 @@ int pamfStreamTypeToEsFilterId(u8 type, u8 ch, mem_ptr_t<CellCodecEsFilterId> pE
return CELL_OK;
}
u8 pamfGetStreamType(mem_ptr_t<CellPamfReader> pSelf, u8 stream)
u8 pamfGetStreamType(vm::ptr<CellPamfReader> pSelf, u8 stream)
{
//TODO: get stream type correctly
const mem_ptr_t<PamfHeader> pAddr(pSelf->pAddr);
const vm::ptr<PamfHeader> pAddr(pSelf->pAddr);
switch (pAddr->stream_headers[stream].type)
{
@ -91,10 +91,10 @@ u8 pamfGetStreamType(mem_ptr_t<CellPamfReader> pSelf, u8 stream)
}
}
u8 pamfGetStreamChannel(mem_ptr_t<CellPamfReader> pSelf, u8 stream)
u8 pamfGetStreamChannel(vm::ptr<CellPamfReader> pSelf, u8 stream)
{
//TODO: get stream channel correctly
const mem_ptr_t<PamfHeader> pAddr(pSelf->pAddr);
const vm::ptr<PamfHeader> pAddr(pSelf->pAddr);
switch (pAddr->stream_headers[stream].type)
{
@ -124,54 +124,54 @@ u8 pamfGetStreamChannel(mem_ptr_t<CellPamfReader> pSelf, u8 stream)
}
int cellPamfGetHeaderSize(mem_ptr_t<PamfHeader> pAddr, u64 fileSize, mem64_t pSize)
int cellPamfGetHeaderSize(vm::ptr<PamfHeader> pAddr, u64 fileSize, vm::ptr<be_t<u64>> pSize)
{
cellPamf->Warning("cellPamfGetHeaderSize(pAddr=0x%x, fileSize=%d, pSize_addr=0x%x)", pAddr.GetAddr(), fileSize, pSize.GetAddr());
cellPamf->Warning("cellPamfGetHeaderSize(pAddr=0x%x, fileSize=%d, pSize_addr=0x%x)", pAddr.addr(), fileSize, pSize.addr());
//if ((u32)pAddr->magic != 0x464d4150)
//return CELL_PAMF_ERROR_UNKNOWN_TYPE;
const u64 offset = (u64)pAddr->data_offset << 11;
pSize = offset;
*pSize = offset;
return CELL_OK;
}
int cellPamfGetHeaderSize2(mem_ptr_t<PamfHeader> pAddr, u64 fileSize, u32 attribute, mem64_t pSize)
int cellPamfGetHeaderSize2(vm::ptr<PamfHeader> pAddr, u64 fileSize, u32 attribute, vm::ptr<be_t<u64>> pSize)
{
cellPamf->Warning("cellPamfGetHeaderSize2(pAddr=0x%x, fileSize=%d, attribute=0x%x, pSize_addr=0x%x)", pAddr.GetAddr(), fileSize, attribute, pSize.GetAddr());
cellPamf->Warning("cellPamfGetHeaderSize2(pAddr=0x%x, fileSize=%d, attribute=0x%x, pSize_addr=0x%x)", pAddr.addr(), fileSize, attribute, pSize.addr());
//if ((u32)pAddr->magic != 0x464d4150)
//return CELL_PAMF_ERROR_UNKNOWN_TYPE;
const u64 offset = (u64)pAddr->data_offset << 11;
pSize = offset;
*pSize = offset;
return CELL_OK;
}
int cellPamfGetStreamOffsetAndSize(mem_ptr_t<PamfHeader> pAddr, u64 fileSize, mem64_t pOffset, mem64_t pSize)
int cellPamfGetStreamOffsetAndSize(vm::ptr<PamfHeader> pAddr, u64 fileSize, vm::ptr<be_t<u64>> pOffset, vm::ptr<be_t<u64>> pSize)
{
cellPamf->Warning("cellPamfGetStreamOffsetAndSize(pAddr=0x%x, fileSize=%d, pOffset_addr=0x%x, pSize_addr=0x%x)", pAddr.GetAddr(), fileSize, pOffset.GetAddr(), pSize.GetAddr());
cellPamf->Warning("cellPamfGetStreamOffsetAndSize(pAddr=0x%x, fileSize=%d, pOffset_addr=0x%x, pSize_addr=0x%x)", pAddr.addr(), fileSize, pOffset.addr(), pSize.addr());
//if ((u32)pAddr->magic != 0x464d4150)
//return CELL_PAMF_ERROR_UNKNOWN_TYPE;
const u64 offset = (u64)pAddr->data_offset << 11;
pOffset = offset;
*pOffset = offset;
const u64 size = (u64)pAddr->data_size << 11;
pSize = size;
*pSize = size;
return CELL_OK;
}
int cellPamfVerify(mem_ptr_t<PamfHeader> pAddr, u64 fileSize)
int cellPamfVerify(vm::ptr<PamfHeader> pAddr, u64 fileSize)
{
cellPamf->Warning("cellPamfVerify(pAddr=0x%x, fileSize=%d)", pAddr.GetAddr(), fileSize);
cellPamf->Warning("cellPamfVerify(pAddr=0x%x, fileSize=%d)", pAddr.addr(), fileSize);
return CELL_OK;
}
int cellPamfReaderInitialize(mem_ptr_t<CellPamfReader> pSelf, mem_ptr_t<PamfHeader> pAddr, u64 fileSize, u32 attribute)
int cellPamfReaderInitialize(vm::ptr<CellPamfReader> pSelf, vm::ptr<PamfHeader> pAddr, u64 fileSize, u32 attribute)
{
cellPamf->Warning("cellPamfReaderInitialize(pSelf=0x%x, pAddr=0x%x, fileSize=%d, attribute=0x%x)", pSelf.GetAddr(), pAddr.GetAddr(), fileSize, attribute);
cellPamf->Warning("cellPamfReaderInitialize(pSelf=0x%x, pAddr=0x%x, fileSize=%d, attribute=0x%x)", pSelf.addr(), pAddr.addr(), fileSize, attribute);
if (fileSize)
{
@ -181,7 +181,7 @@ int cellPamfReaderInitialize(mem_ptr_t<CellPamfReader> pSelf, mem_ptr_t<PamfHead
{
pSelf->fileSize = ((u64)pAddr->data_offset << 11) + ((u64)pAddr->data_size << 11);
}
pSelf->pAddr = pAddr.GetAddr();
pSelf->pAddr = vm::ptr<PamfHeader>::make(pAddr.addr());
if (attribute & CELL_PAMF_ATTRIBUTE_VERIFY_ON)
{
@ -192,49 +192,49 @@ int cellPamfReaderInitialize(mem_ptr_t<CellPamfReader> pSelf, mem_ptr_t<PamfHead
return CELL_OK;
}
int cellPamfReaderGetPresentationStartTime(mem_ptr_t<CellPamfReader> pSelf, mem_ptr_t<CellCodecTimeStamp> pTimeStamp)
int cellPamfReaderGetPresentationStartTime(vm::ptr<CellPamfReader> pSelf, vm::ptr<CellCodecTimeStamp> pTimeStamp)
{
cellPamf->Warning("cellPamfReaderGetPresentationStartTime(pSelf=0x%x, pTimeStamp_addr=0x%x)", pSelf.GetAddr(), pTimeStamp.GetAddr());
cellPamf->Warning("cellPamfReaderGetPresentationStartTime(pSelf=0x%x, pTimeStamp_addr=0x%x)", pSelf.addr(), pTimeStamp.addr());
const mem_ptr_t<PamfHeader> pAddr(pSelf->pAddr);
const vm::ptr<PamfHeader> pAddr(pSelf->pAddr);
const u32 upper = (u16)pAddr->start_pts_high;
pTimeStamp->upper = upper;
pTimeStamp->lower = pAddr->start_pts_low;
return CELL_OK;
}
int cellPamfReaderGetPresentationEndTime(mem_ptr_t<CellPamfReader> pSelf, mem_ptr_t<CellCodecTimeStamp> pTimeStamp)
int cellPamfReaderGetPresentationEndTime(vm::ptr<CellPamfReader> pSelf, vm::ptr<CellCodecTimeStamp> pTimeStamp)
{
cellPamf->Warning("cellPamfReaderGetPresentationEndTime(pSelf=0x%x, pTimeStamp_addr=0x%x)", pSelf.GetAddr(), pTimeStamp.GetAddr());
cellPamf->Warning("cellPamfReaderGetPresentationEndTime(pSelf=0x%x, pTimeStamp_addr=0x%x)", pSelf.addr(), pTimeStamp.addr());
const mem_ptr_t<PamfHeader> pAddr(pSelf->pAddr);
const vm::ptr<PamfHeader> pAddr(pSelf->pAddr);
const u32 upper = (u16)pAddr->end_pts_high;
pTimeStamp->upper = upper;
pTimeStamp->lower = pAddr->end_pts_low;
return CELL_OK;
}
int cellPamfReaderGetMuxRateBound(mem_ptr_t<CellPamfReader> pSelf)
int cellPamfReaderGetMuxRateBound(vm::ptr<CellPamfReader> pSelf)
{
cellPamf->Warning("cellPamfReaderGetMuxRateBound(pSelf=0x%x)", pSelf.GetAddr());
cellPamf->Warning("cellPamfReaderGetMuxRateBound(pSelf=0x%x)", pSelf.addr());
const mem_ptr_t<PamfHeader> pAddr(pSelf->pAddr);
const vm::ptr<PamfHeader> pAddr(pSelf->pAddr);
return pAddr->mux_rate_max;
}
int cellPamfReaderGetNumberOfStreams(mem_ptr_t<CellPamfReader> pSelf)
int cellPamfReaderGetNumberOfStreams(vm::ptr<CellPamfReader> pSelf)
{
cellPamf->Warning("cellPamfReaderGetNumberOfStreams(pSelf=0x%x)", pSelf.GetAddr());
cellPamf->Warning("cellPamfReaderGetNumberOfStreams(pSelf=0x%x)", pSelf.addr());
const mem_ptr_t<PamfHeader> pAddr(pSelf->pAddr);
const vm::ptr<PamfHeader> pAddr(pSelf->pAddr);
return pAddr->stream_count;
}
int cellPamfReaderGetNumberOfSpecificStreams(mem_ptr_t<CellPamfReader> pSelf, u8 streamType)
int cellPamfReaderGetNumberOfSpecificStreams(vm::ptr<CellPamfReader> pSelf, u8 streamType)
{
cellPamf->Warning("cellPamfReaderGetNumberOfSpecificStreams(pSelf=0x%x, streamType=%d)", pSelf.GetAddr(), streamType);
cellPamf->Warning("cellPamfReaderGetNumberOfSpecificStreams(pSelf=0x%x, streamType=%d)", pSelf.addr(), streamType);
const mem_ptr_t<PamfHeader> pAddr(pSelf->pAddr);
const vm::ptr<PamfHeader> pAddr(pSelf->pAddr);
int counts[6] = {0, 0, 0, 0, 0, 0};
@ -261,11 +261,11 @@ int cellPamfReaderGetNumberOfSpecificStreams(mem_ptr_t<CellPamfReader> pSelf, u8
}
}
int cellPamfReaderSetStreamWithIndex(mem_ptr_t<CellPamfReader> pSelf, u8 streamIndex)
int cellPamfReaderSetStreamWithIndex(vm::ptr<CellPamfReader> pSelf, u8 streamIndex)
{
cellPamf->Warning("cellPamfReaderSetStreamWithIndex(pSelf=0x%x, streamIndex=%d)", pSelf.GetAddr(), streamIndex);
cellPamf->Warning("cellPamfReaderSetStreamWithIndex(pSelf=0x%x, streamIndex=%d)", pSelf.addr(), streamIndex);
const mem_ptr_t<PamfHeader> pAddr(pSelf->pAddr);
const vm::ptr<PamfHeader> pAddr(pSelf->pAddr);
if (streamIndex < pAddr->stream_count)
{
@ -279,11 +279,11 @@ int cellPamfReaderSetStreamWithIndex(mem_ptr_t<CellPamfReader> pSelf, u8 streamI
}
}
int cellPamfReaderSetStreamWithTypeAndChannel(mem_ptr_t<CellPamfReader> pSelf, u8 streamType, u8 ch)
int cellPamfReaderSetStreamWithTypeAndChannel(vm::ptr<CellPamfReader> pSelf, u8 streamType, u8 ch)
{
cellPamf->Warning("cellPamfReaderSetStreamWithTypeAndChannel(pSelf=0x%x, streamType=%d, ch=%d)", pSelf.GetAddr(), streamType, ch);
cellPamf->Warning("cellPamfReaderSetStreamWithTypeAndChannel(pSelf=0x%x, streamType=%d, ch=%d)", pSelf.addr(), streamType, ch);
const mem_ptr_t<PamfHeader> pAddr(pSelf->pAddr);
const vm::ptr<PamfHeader> pAddr(pSelf->pAddr);
if (streamType > 5)
{
@ -307,11 +307,11 @@ int cellPamfReaderSetStreamWithTypeAndChannel(mem_ptr_t<CellPamfReader> pSelf, u
return CELL_PAMF_ERROR_STREAM_NOT_FOUND;
}
int cellPamfReaderSetStreamWithTypeAndIndex(mem_ptr_t<CellPamfReader> pSelf, u8 streamType, u8 streamIndex)
int cellPamfReaderSetStreamWithTypeAndIndex(vm::ptr<CellPamfReader> pSelf, u8 streamType, u8 streamIndex)
{
cellPamf->Warning("cellPamfReaderSetStreamWithTypeAndIndex(pSelf=0x%x, streamType=%d, streamIndex=%d)", pSelf.GetAddr(), streamType, streamIndex);
cellPamf->Warning("cellPamfReaderSetStreamWithTypeAndIndex(pSelf=0x%x, streamType=%d, streamIndex=%d)", pSelf.addr(), streamType, streamIndex);
const mem_ptr_t<PamfHeader> pAddr(pSelf->pAddr);
const vm::ptr<PamfHeader> pAddr(pSelf->pAddr);
u32 found = 0;
@ -354,42 +354,43 @@ int cellPamfReaderSetStreamWithTypeAndIndex(mem_ptr_t<CellPamfReader> pSelf, u8
return CELL_PAMF_ERROR_STREAM_NOT_FOUND;
}
int cellPamfStreamTypeToEsFilterId(u8 type, u8 ch, mem_ptr_t<CellCodecEsFilterId> pEsFilterId)
int cellPamfStreamTypeToEsFilterId(u8 type, u8 ch, vm::ptr<CellCodecEsFilterId> pEsFilterId)
{
cellPamf->Warning("cellPamfStreamTypeToEsFilterId(type=%d, ch=%d, pEsFilterId_addr=0x%x)", type, ch, pEsFilterId.GetAddr());
cellPamf->Warning("cellPamfStreamTypeToEsFilterId(type=%d, ch=%d, pEsFilterId_addr=0x%x)", type, ch, pEsFilterId.addr());
return pamfStreamTypeToEsFilterId(type, ch, pEsFilterId);
}
int cellPamfReaderGetStreamIndex(mem_ptr_t<CellPamfReader> pSelf)
int cellPamfReaderGetStreamIndex(vm::ptr<CellPamfReader> pSelf)
{
cellPamf->Log("cellPamfReaderGetStreamIndex(pSelf=0x%x)", pSelf.GetAddr());
cellPamf->Log("cellPamfReaderGetStreamIndex(pSelf=0x%x)", pSelf.addr());
return pSelf->stream;
}
int cellPamfReaderGetStreamTypeAndChannel(mem_ptr_t<CellPamfReader> pSelf, mem8_t pType, mem8_t pCh)
int cellPamfReaderGetStreamTypeAndChannel(vm::ptr<CellPamfReader> pSelf, vm::ptr<u8> pType, vm::ptr<u8> pCh)
{
cellPamf->Warning("cellPamfReaderGetStreamTypeAndChannel(pSelf=0x%x (stream=%d), pType_addr=0x%x, pCh_addr=0x%x", pSelf.GetAddr(), pSelf->stream, pType.GetAddr(), pCh.GetAddr());
cellPamf->Warning("cellPamfReaderGetStreamTypeAndChannel(pSelf=0x%x (stream=%d), pType_addr=0x%x, pCh_addr=0x%x",
pSelf.addr(), pSelf->stream, pType.addr(), pCh.addr());
pType = pamfGetStreamType(pSelf, pSelf->stream);
pCh = pamfGetStreamChannel(pSelf, pSelf->stream);
*pType = pamfGetStreamType(pSelf, pSelf->stream);
*pCh = pamfGetStreamChannel(pSelf, pSelf->stream);
return CELL_OK;
}
int cellPamfReaderGetEsFilterId(mem_ptr_t<CellPamfReader> pSelf, mem_ptr_t<CellCodecEsFilterId> pEsFilterId)
int cellPamfReaderGetEsFilterId(vm::ptr<CellPamfReader> pSelf, vm::ptr<CellCodecEsFilterId> pEsFilterId)
{
cellPamf->Warning("cellPamfReaderGetEsFilterId(pSelf=0x%x (stream=%d), pEsFilterId_addr=0x%x)", pSelf.GetAddr(), pSelf->stream, pEsFilterId.GetAddr());
cellPamf->Warning("cellPamfReaderGetEsFilterId(pSelf=0x%x (stream=%d), pEsFilterId_addr=0x%x)", pSelf.addr(), pSelf->stream, pEsFilterId.addr());
return pamfStreamTypeToEsFilterId(pamfGetStreamType(pSelf, pSelf->stream),
pamfGetStreamChannel(pSelf, pSelf->stream), pEsFilterId);
}
int cellPamfReaderGetStreamInfo(mem_ptr_t<CellPamfReader> pSelf, u32 pInfo_addr, u32 size)
int cellPamfReaderGetStreamInfo(vm::ptr<CellPamfReader> pSelf, u32 pInfo_addr, u32 size)
{
cellPamf->Warning("cellPamfReaderGetStreamInfo(pSelf=0x%x, stream=%d, pInfo_addr=0x%x, size=%d)", pSelf.GetAddr(), pSelf->stream, pInfo_addr, size);
cellPamf->Warning("cellPamfReaderGetStreamInfo(pSelf=0x%x, stream=%d, pInfo_addr=0x%x, size=%d)", pSelf.addr(), pSelf->stream, pInfo_addr, size);
const mem_ptr_t<PamfHeader> pAddr(pSelf->pAddr);
const vm::ptr<PamfHeader> pAddr(pSelf->pAddr);
memset(Memory + pInfo_addr, 0, size);
@ -397,8 +398,8 @@ int cellPamfReaderGetStreamInfo(mem_ptr_t<CellPamfReader> pSelf, u32 pInfo_addr,
{
case CELL_PAMF_STREAM_TYPE_AVC:
{
mem_ptr_t<CellPamfAvcInfo> pInfo(pInfo_addr);
mem_ptr_t<PamfStreamHeader_AVC> pAVC(pSelf->pAddr + 0x98 + pSelf->stream * 0x30);
auto pInfo = vm::ptr<CellPamfAvcInfo>::make(pInfo_addr);
auto pAVC = vm::ptr<PamfStreamHeader_AVC>::make(pSelf->pAddr.addr() + 0x98 + pSelf->stream * 0x30);
if (size != sizeof(CellPamfAvcInfo))
{
@ -433,8 +434,8 @@ int cellPamfReaderGetStreamInfo(mem_ptr_t<CellPamfReader> pSelf, u32 pInfo_addr,
break;
case CELL_PAMF_STREAM_TYPE_ATRAC3PLUS:
{
mem_ptr_t<CellPamfAtrac3plusInfo> pInfo(pInfo_addr);
mem_ptr_t<PamfStreamHeader_Audio> pAudio(pSelf->pAddr + 0x98 + pSelf->stream * 0x30);
auto pInfo = vm::ptr<CellPamfAtrac3plusInfo>::make(pInfo_addr);
auto pAudio = vm::ptr<PamfStreamHeader_Audio>::make(pSelf->pAddr.addr() + 0x98 + pSelf->stream * 0x30);
if (size != sizeof(CellPamfAtrac3plusInfo))
{
@ -448,8 +449,8 @@ int cellPamfReaderGetStreamInfo(mem_ptr_t<CellPamfReader> pSelf, u32 pInfo_addr,
break;
case CELL_PAMF_STREAM_TYPE_AC3:
{
mem_ptr_t<CellPamfAc3Info> pInfo(pInfo_addr);
mem_ptr_t<PamfStreamHeader_Audio> pAudio(pSelf->pAddr + 0x98 + pSelf->stream * 0x30);
auto pInfo = vm::ptr<CellPamfAc3Info>::make(pInfo_addr);
auto pAudio = vm::ptr<PamfStreamHeader_Audio>::make(pSelf->pAddr + 0x98 + pSelf->stream * 0x30);
if (size != sizeof(CellPamfAc3Info))
{
@ -463,8 +464,8 @@ int cellPamfReaderGetStreamInfo(mem_ptr_t<CellPamfReader> pSelf, u32 pInfo_addr,
break;
case CELL_PAMF_STREAM_TYPE_PAMF_LPCM:
{
mem_ptr_t<CellPamfLpcmInfo> pInfo(pInfo_addr);
mem_ptr_t<PamfStreamHeader_Audio> pAudio(pSelf->pAddr + 0x98 + pSelf->stream * 0x30);
auto pInfo = vm::ptr<CellPamfLpcmInfo>::make(pInfo_addr);
auto pAudio = vm::ptr<PamfStreamHeader_Audio>::make(pSelf->pAddr + 0x98 + pSelf->stream * 0x30);
if (size != sizeof(CellPamfLpcmInfo))
{
@ -492,46 +493,46 @@ int cellPamfReaderGetStreamInfo(mem_ptr_t<CellPamfReader> pSelf, u32 pInfo_addr,
return CELL_OK;
}
int cellPamfReaderGetNumberOfEp(mem_ptr_t<CellPamfReader> pSelf)
int cellPamfReaderGetNumberOfEp(vm::ptr<CellPamfReader> pSelf)
{
cellPamf->Warning("cellPamfReaderGetNumberOfEp(pSelf=0x%x, stream=%d)", pSelf.GetAddr(), pSelf->stream);
cellPamf->Warning("cellPamfReaderGetNumberOfEp(pSelf=0x%x, stream=%d)", pSelf.addr(), pSelf->stream);
const mem_ptr_t<PamfHeader> pAddr(pSelf->pAddr);
const vm::ptr<PamfHeader> pAddr(pSelf->pAddr);
return pAddr->stream_headers[pSelf->stream].ep_num;
}
int cellPamfReaderGetEpIteratorWithIndex(mem_ptr_t<CellPamfReader> pSelf, u32 epIndex, mem_ptr_t<CellPamfEpIterator> pIt)
int cellPamfReaderGetEpIteratorWithIndex(vm::ptr<CellPamfReader> pSelf, u32 epIndex, vm::ptr<CellPamfEpIterator> pIt)
{
cellPamf->Todo("cellPamfReaderGetEpIteratorWithIndex(pSelf=0x%x, stream=%d, epIndex=%d, pIt_addr=0x%x)", pSelf.GetAddr(), pSelf->stream, epIndex, pIt.GetAddr());
cellPamf->Todo("cellPamfReaderGetEpIteratorWithIndex(pSelf=0x%x, stream=%d, epIndex=%d, pIt_addr=0x%x)", pSelf.addr(), pSelf->stream, epIndex, pIt.addr());
const mem_ptr_t<PamfHeader> pAddr(pSelf->pAddr);
const vm::ptr<PamfHeader> pAddr(pSelf->pAddr);
//TODO:
return CELL_OK;
}
int cellPamfReaderGetEpIteratorWithTimeStamp(mem_ptr_t<CellPamfReader> pSelf, mem_ptr_t<CellCodecTimeStamp> pTimeStamp, mem_ptr_t<CellPamfEpIterator> pIt)
int cellPamfReaderGetEpIteratorWithTimeStamp(vm::ptr<CellPamfReader> pSelf, vm::ptr<CellCodecTimeStamp> pTimeStamp, vm::ptr<CellPamfEpIterator> pIt)
{
cellPamf->Todo("cellPamfReaderGetEpIteratorWithTimeStamp(pSelf=0x%x, pTimeStamp_addr=0x%x, pIt_addr=0x%x)", pSelf.GetAddr(), pTimeStamp.GetAddr(), pIt.GetAddr());
cellPamf->Todo("cellPamfReaderGetEpIteratorWithTimeStamp(pSelf=0x%x, pTimeStamp_addr=0x%x, pIt_addr=0x%x)", pSelf.addr(), pTimeStamp.addr(), pIt.addr());
const mem_ptr_t<PamfHeader> pAddr(pSelf->pAddr);
const vm::ptr<PamfHeader> pAddr(pSelf->pAddr);
//TODO:
return CELL_OK;
}
int cellPamfEpIteratorGetEp(mem_ptr_t<CellPamfEpIterator> pIt, mem_ptr_t<CellPamfEp> pEp)
int cellPamfEpIteratorGetEp(vm::ptr<CellPamfEpIterator> pIt, vm::ptr<CellPamfEp> pEp)
{
cellPamf->Todo("cellPamfEpIteratorGetEp(pIt_addr=0x%x, pEp_addr=0x%x)", pIt.GetAddr(), pEp.GetAddr());
cellPamf->Todo("cellPamfEpIteratorGetEp(pIt_addr=0x%x, pEp_addr=0x%x)", pIt.addr(), pEp.addr());
//TODO:
return CELL_OK;
}
int cellPamfEpIteratorMove(mem_ptr_t<CellPamfEpIterator> pIt, s32 steps, mem_ptr_t<CellPamfEp> pEp)
int cellPamfEpIteratorMove(vm::ptr<CellPamfEpIterator> pIt, s32 steps, vm::ptr<CellPamfEp> pEp)
{
cellPamf->Todo("cellPamfEpIteratorMove(pIt_addr=0x%x, steps=%d, pEp_addr=0x%x)", pIt.GetAddr(), steps, pEp.GetAddr());
cellPamf->Todo("cellPamfEpIteratorMove(pIt_addr=0x%x, steps=%d, pEp_addr=0x%x)", pIt.addr(), steps, pEp.addr());
//TODO:

View file

@ -330,7 +330,7 @@ struct CellPamfReader
{
//this struct can be used in any way, if it is not accessed directly by virtual CPU
//be_t<u64> internalData[16];
u32 pAddr;
vm::ptr<PamfHeader> pAddr;
int stream;
u64 fileSize;
u32 internalData[28];

View file

@ -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];
}
@ -51,10 +51,10 @@ int cellPngDecDestroy(u32 mainHandle)
return CELL_OK;
}
int cellPngDecOpen(u32 mainHandle, mem32_t subHandle, mem_ptr_t<CellPngDecSrc> src, u32 openInfo)
int cellPngDecOpen(u32 mainHandle, vm::ptr<be_t<u32>> subHandle, vm::ptr<CellPngDecSrc> src, u32 openInfo)
{
cellPngDec->Warning("cellPngDecOpen(mainHandle=0x%x, subHandle=0x%x, src_addr=0x%x, openInfo=0x%x)",
mainHandle, subHandle.GetAddr(), src.GetAddr(), openInfo);
mainHandle, subHandle.addr(), src.addr(), openInfo);
CellPngDecSubHandle *current_subHandle = new CellPngDecSubHandle;
current_subHandle->fd = 0;
@ -68,38 +68,38 @@ 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, vm::ptr<be_t<u32>>::make(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);
if(ret != CELL_OK) return ret;
current_subHandle->fileSize = sb->st_size; // Get CellFsStat.st_size
break;
}
// From now, every u32 subHandle argument is a pointer to a CellPngDecSubHandle struct.
subHandle = cellPngDec->GetNewId(current_subHandle);
*subHandle = cellPngDec->GetNewId(current_subHandle);
return CELL_OK;
}
int cellPngDecExtOpen(u32 mainHandle, mem32_t subHandle, mem_ptr_t<CellPngDecSrc> src, u32 openInfo, mem_ptr_t<CellPngDecCbCtrlStrm> cbCtrlStrm, mem_ptr_t<CellPngDecOpnParam> opnParam)
int cellPngDecExtOpen(u32 mainHandle, vm::ptr<be_t<u32>> subHandle, vm::ptr<CellPngDecSrc> src, u32 openInfo, vm::ptr<CellPngDecCbCtrlStrm> cbCtrlStrm, vm::ptr<CellPngDecOpnParam> opnParam)
{
cellPngDec->Warning("cellPngDecExtOpen(mainHandle=0x%x, subHandle=0x%x, src_addr=0x%x, openInfo=0x%x, cbCtrlStrm_addr=0x%x, opnParam=0x%x)",
mainHandle, subHandle.GetAddr(), src.GetAddr(), openInfo, cbCtrlStrm.GetAddr(), opnParam.GetAddr());
mainHandle, subHandle.addr(), src.addr(), openInfo, cbCtrlStrm.addr(), opnParam.addr());
cellPngDec->Warning("*** cbCtrlStrm->cbCtrlStrmFunc_addr=0x%x", cbCtrlStrm->cbCtrlStrmFunc.GetAddr());
cellPngDec->Warning("*** cbCtrlStrm->cbCtrlStrmFunc_addr=0x%x", cbCtrlStrm->cbCtrlStrmFunc.addr());
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, streamParam, cbCtrlStrm->cbCtrlStrmArg);
return res;
}
@ -118,9 +118,9 @@ int cellPngDecClose(u32 mainHandle, u32 subHandle)
return CELL_OK;
}
int cellPngDecReadHeader(u32 mainHandle, u32 subHandle, mem_ptr_t<CellPngDecInfo> info)
int cellPngDecReadHeader(u32 mainHandle, u32 subHandle, vm::ptr<CellPngDecInfo> info)
{
cellPngDec->Warning("cellPngDecReadHeader(mainHandle=0x%x, subHandle=0x%x, info_addr=0x%x)", mainHandle, subHandle, info.GetAddr());
cellPngDec->Warning("cellPngDecReadHeader(mainHandle=0x%x, subHandle=0x%x, info_addr=0x%x)", mainHandle, subHandle, info.addr());
CellPngDecSubHandle* subHandle_data;
if(!cellPngDec->CheckId(subHandle, subHandle_data))
return CELL_PNGDEC_ERROR_FATAL;
@ -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);
cellFsRead(fd, buffer.addr(), buffer.size(), nread);
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;
@ -175,18 +176,18 @@ int cellPngDecReadHeader(u32 mainHandle, u32 subHandle, mem_ptr_t<CellPngDecInfo
return CELL_OK;
}
int cellPngDecExtReadHeader(u32 mainHandle, u32 subHandle, mem_ptr_t<CellPngDecInfo> info, mem_ptr_t<CellPngDecExtInfo> extInfo)
int cellPngDecExtReadHeader(u32 mainHandle, u32 subHandle, vm::ptr<CellPngDecInfo> info, vm::ptr<CellPngDecExtInfo> extInfo)
{
cellPngDec->Warning("cellPngDecExtReadHeader(mainHandle=0x%x, subHandle=0x%x, info_addr=0x%x, extInfo_addr=0x%x)",
mainHandle, subHandle, info.GetAddr(), extInfo.GetAddr());
mainHandle, subHandle, info.addr(), extInfo.addr());
return cellPngDecReadHeader(mainHandle, subHandle, info);
}
int cellPngDecDecodeData(u32 mainHandle, u32 subHandle, mem8_ptr_t data, const mem_ptr_t<CellPngDecDataCtrlParam> dataCtrlParam, mem_ptr_t<CellPngDecDataOutInfo> dataOutInfo)
int cellPngDecDecodeData(u32 mainHandle, u32 subHandle, vm::ptr<u8> data, const vm::ptr<CellPngDecDataCtrlParam> dataCtrlParam, vm::ptr<CellPngDecDataOutInfo> dataOutInfo)
{
cellPngDec->Warning("cellPngDecDecodeData(mainHandle=0x%x, subHandle=0x%x, data_addr=0x%x, dataCtrlParam_addr=0x%x, dataOutInfo_addr=0x%x)",
mainHandle, subHandle, data.GetAddr(), dataCtrlParam.GetAddr(), dataOutInfo.GetAddr());
mainHandle, subHandle, data.addr(), dataCtrlParam.addr(), dataOutInfo.addr());
dataOutInfo->status = CELL_PNGDEC_DEC_STATUS_STOP;
CellPngDecSubHandle* subHandle_data;
@ -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(fileSize);
MemoryAllocator<u64> pos, nread;
vm::var<unsigned char[]> png((u32)fileSize);
vm::var<be_t<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);
cellFsRead(fd, png.addr(), png.size(), nread);
break;
}
@ -217,13 +218,13 @@ 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(), 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;
const bool flip = current_outParam.outputMode == CELL_PNGDEC_BOTTOM_TO_TOP;
const int bytesPerLine = dataCtrlParam->outputBytesPerLine;
const int bytesPerLine = (u32)dataCtrlParam->outputBytesPerLine;
uint image_size = width * height;
switch((u32)current_outParam.outputColorSpace)
@ -240,12 +241,12 @@ int cellPngDecDecodeData(u32 mainHandle, u32 subHandle, mem8_ptr_t data, const m
{
const int dstOffset = i * bytesPerLine;
const int srcOffset = width * nComponents * (flip ? height - i - 1 : i);
memcpy(Memory + (data.GetAddr() + dstOffset), &image.get()[srcOffset], linesize);
memcpy(Memory + (data.addr() + dstOffset), &image.get()[srcOffset], linesize);
}
}
else
{
memcpy(Memory + data.GetAddr(), image.get(), image_size);
memcpy(Memory + data.addr(), image.get(), image_size);
}
}
break;
@ -270,15 +271,15 @@ int cellPngDecDecodeData(u32 mainHandle, u32 subHandle, mem8_ptr_t data, const m
output[j + 2] = image.get()[srcOffset + j + 1];
output[j + 3] = image.get()[srcOffset + j + 2];
}
memcpy(Memory + (data.GetAddr() + dstOffset), output, linesize);
memcpy(Memory + (data.addr() + dstOffset), output, linesize);
}
free(output);
}
else
{
uint* dest = (uint*)new char[image_size];
uint* img = (uint*)new char[image_size];
uint* source_current = (uint*)&(image.get()[0]);
uint* dest_current = dest;
uint* dest_current = img;
for (uint i = 0; i < image_size / nComponents; i++)
{
uint val = *source_current;
@ -286,9 +287,8 @@ int cellPngDecDecodeData(u32 mainHandle, u32 subHandle, mem8_ptr_t data, const m
source_current++;
dest_current++;
}
// NOTE: AppendRawBytes has diff side-effect vs Memory.CopyFromReal
data.AppendRawBytes((u8*)dest, image_size);
delete[] dest;
memcpy(data.get_ptr(), img, image_size);
delete[] img;
}
}
break;
@ -308,21 +308,21 @@ int cellPngDecDecodeData(u32 mainHandle, u32 subHandle, mem8_ptr_t data, const m
return CELL_OK;
}
int cellPngDecExtDecodeData(u32 mainHandle, u32 subHandle, mem8_ptr_t data, const mem_ptr_t<CellPngDecDataCtrlParam> dataCtrlParam,
mem_ptr_t<CellPngDecDataOutInfo> dataOutInfo, mem_ptr_t<CellPngDecCbCtrlDisp> cbCtrlDisp, mem_ptr_t<CellPngDecDispParam> dispParam)
int cellPngDecExtDecodeData(u32 mainHandle, u32 subHandle, vm::ptr<u8> data, const vm::ptr<CellPngDecDataCtrlParam> dataCtrlParam,
vm::ptr<CellPngDecDataOutInfo> dataOutInfo, vm::ptr<CellPngDecCbCtrlDisp> cbCtrlDisp, vm::ptr<CellPngDecDispParam> dispParam)
{
cellPngDec->Warning("cellPngDecExtDecodeData(mainHandle=0x%x, subHandle=0x%x, data_addr=0x%x, dataCtrlParam_addr=0x%x, dataOutInfo_addr=0x%x, cbCtrlDisp_addr=0x%x, dispParam=0x%x)",
mainHandle, subHandle, data.GetAddr(), dataCtrlParam.GetAddr(), dataOutInfo.GetAddr(), cbCtrlDisp.GetAddr(), dispParam.GetAddr());
mainHandle, subHandle, data.addr(), dataCtrlParam.addr(), dataOutInfo.addr(), cbCtrlDisp.addr(), dispParam.addr());
if (cbCtrlDisp.GetAddr()) cellPngDec->Warning("*** cbCtrlDisp->cbCtrlDispFunc_addr=0x%x", (u32)cbCtrlDisp->cbCtrlDispFunc_addr);
if (cbCtrlDisp) cellPngDec->Warning("*** cbCtrlDisp->cbCtrlDispFunc_addr=0x%x", (u32)cbCtrlDisp->cbCtrlDispFunc_addr);
return cellPngDecDecodeData(mainHandle, subHandle, data, dataCtrlParam, dataOutInfo);
}
int cellPngDecSetParameter(u32 mainHandle, u32 subHandle, const mem_ptr_t<CellPngDecInParam> inParam, mem_ptr_t<CellPngDecOutParam> outParam)
int cellPngDecSetParameter(u32 mainHandle, u32 subHandle, const vm::ptr<CellPngDecInParam> inParam, vm::ptr<CellPngDecOutParam> outParam)
{
cellPngDec->Warning("cellPngDecSetParameter(mainHandle=0x%x, subHandle=0x%x, inParam_addr=0x%x, outParam_addr=0x%x)",
mainHandle, subHandle, inParam.GetAddr(), outParam.GetAddr());
mainHandle, subHandle, inParam.addr(), outParam.addr());
CellPngDecSubHandle* subHandle_data;
if(!cellPngDec->CheckId(subHandle, subHandle_data))
@ -360,11 +360,11 @@ int cellPngDecSetParameter(u32 mainHandle, u32 subHandle, const mem_ptr_t<CellPn
return CELL_OK;
}
int cellPngDecExtSetParameter(u32 mainHandle, u32 subHandle, const mem_ptr_t<CellPngDecInParam> inParam, mem_ptr_t<CellPngDecOutParam> outParam,
mem_ptr_t<CellPngDecExtInParam> extInParam, mem_ptr_t<CellPngDecExtOutParam> extOutParam)
int cellPngDecExtSetParameter(u32 mainHandle, u32 subHandle, const vm::ptr<CellPngDecInParam> inParam, vm::ptr<CellPngDecOutParam> outParam,
vm::ptr<CellPngDecExtInParam> extInParam, vm::ptr<CellPngDecExtOutParam> extOutParam)
{
cellPngDec->Warning("cellPngDecExtSetParameter(mainHandle=0x%x, subHandle=0x%x, inParam_addr=0x%x, outParam_addr=0x%x, extInParam=0x%x, extOutParam=0x%x",
mainHandle, subHandle, inParam.GetAddr(), outParam.GetAddr(), extInParam.GetAddr(), extOutParam.GetAddr());
mainHandle, subHandle, inParam.addr(), outParam.addr(), extInParam.addr(), extOutParam.addr());
return cellPngDecSetParameter(mainHandle, subHandle, inParam, outParam);
}

View file

@ -122,7 +122,7 @@ struct CellPngDecStrmParam
struct CellPngDecCbCtrlStrm
{
mem_func_beptr_t<void(*)(mem_ptr_t<CellPngDecStrmInfo> strmInfo, mem_ptr_t<CellPngDecStrmParam> strmParam, u32 cbCtrlStrmArg)> cbCtrlStrmFunc;
vm::bptr<void(*)(vm::ptr<CellPngDecStrmInfo> strmInfo, vm::ptr<CellPngDecStrmParam> strmParam, u32 cbCtrlStrmArg)> cbCtrlStrmFunc;
be_t<u32> cbCtrlStrmArg;
};

View file

@ -15,7 +15,7 @@ PICTURE_SIZE = (1.0f),
UV_DELTA_PS = (1.f / 8.f),
UV_DELTA_LB = (1.f / 6.f),
XY_DELTA_LB = (1.f / 8.f),
PI = 3.1415926535897932384626433832795;
PI = 3.141592741f;
void BuildupVertexBufferNR()
{
@ -37,7 +37,7 @@ void BuildupVertexBufferNR()
float U_PS0 = UV_CENTER - U_PS;
float U_PS1 = UV_CENTER + U_PS;
mem_ptr_t<RescVertex_t> vv(s_rescInternalInstance->m_vertexArrayEA);
auto vv = vm::ptr<RescVertex_t>::make(s_rescInternalInstance->m_vertexArrayEA);
if (s_rescInternalInstance->m_dstMode == CELL_RESC_720x480 || s_rescInternalInstance->m_dstMode == CELL_RESC_720x576)
{
@ -124,10 +124,10 @@ void BuildupVertexBufferUN(s32 srcIdx)
float U_PS1 = U_CENTER + U_PS;
float U2_FS0 = 0.0f;
float V2_FS0 = 0.0f;
float U2_FS1 = s_rescInternalInstance->m_dstWidth;
float V2_FS1 = s_rescInternalInstance->m_dstHeight;
float U2_FS1 = (float)s_rescInternalInstance->m_dstWidth;
float V2_FS1 = (float)s_rescInternalInstance->m_dstHeight;
mem_ptr_t<RescVertex_t> vv(s_rescInternalInstance->m_vertexArrayEA);
auto vv = vm::ptr<RescVertex_t>::make(s_rescInternalInstance->m_vertexArrayEA);
if (s_rescInternalInstance->m_dstMode == CELL_RESC_720x480 || s_rescInternalInstance->m_dstMode == CELL_RESC_720x576)
{
@ -171,7 +171,7 @@ UN_PANSCAN:
return;
}
inline int InternalVersion(mem_ptr_t<CellRescInitConfig> conf)
inline int InternalVersion(vm::ptr<CellRescInitConfig> conf)
{
switch ((u32)conf->size)
{
@ -323,7 +323,7 @@ int CalculateMaxColorBuffersSize()
return maxBufSize;
}
bool CheckInitConfig(mem_ptr_t<CellRescInitConfig> initConfig)
bool CheckInitConfig(vm::ptr<CellRescInitConfig> initConfig)
{
if ((initConfig->resourcePolicy & ~((u32)0x3)) || (initConfig->supportModes & 0xF) == 0 || (initConfig->ratioMode > 2) || (initConfig->palTemporalMode > 5))
{
@ -426,7 +426,7 @@ void InitMembers()
}
}
void SetupRsxRenderingStates(mem_ptr_t<CellGcmContextData>& cntxt)
void SetupRsxRenderingStates(vm::ptr<CellGcmContextData>& cntxt)
{
//TODO: use cntxt
GSLockCurrent lock(GS_LOCK_WAIT_FLUSH);
@ -473,7 +473,7 @@ void SetupRsxRenderingStates(mem_ptr_t<CellGcmContextData>& cntxt)
}
}
void SetupVertexArrays(mem_ptr_t<CellGcmContextData>& cntxt)
void SetupVertexArrays(vm::ptr<CellGcmContextData>& cntxt)
{
GSLockCurrent lock(GS_LOCK_WAIT_FLUSH);
GSRender& r = Emu.GetGSManager().GetRender();
@ -481,7 +481,7 @@ void SetupVertexArrays(mem_ptr_t<CellGcmContextData>& cntxt)
//TODO
}
void SetupSurfaces(mem_ptr_t<CellGcmContextData>& cntxt)
void SetupSurfaces(vm::ptr<CellGcmContextData>& cntxt)
{
bool isMrt;
u32 dstOffset0, dstOffset1;
@ -529,9 +529,9 @@ void SetupSurfaces(mem_ptr_t<CellGcmContextData>& cntxt)
}
// Module Functions
int cellRescInit(mem_ptr_t<CellRescInitConfig> initConfig)
int cellRescInit(vm::ptr<CellRescInitConfig> initConfig)
{
cellResc->Warning("cellRescInit(initConfig_addr=0x%x)", initConfig.GetAddr());
cellResc->Warning("cellRescInit(initConfig_addr=0x%x)", initConfig.addr());
if (s_rescInternalInstance->m_bInitialized)
{
@ -539,7 +539,7 @@ int cellRescInit(mem_ptr_t<CellRescInitConfig> initConfig)
return CELL_RESC_ERROR_REINITIALIZED;
}
if (InternalVersion(initConfig.GetAddr()) == -1 || !CheckInitConfig(initConfig))
if (InternalVersion(initConfig) == -1 || !CheckInitConfig(initConfig))
{
cellResc->Error("cellRescInit : CELL_RESC_ERROR_BAD_ARGUMENT");
return CELL_RESC_ERROR_BAD_ARGUMENT;
@ -582,23 +582,23 @@ void cellRescExit()
s_rescInternalInstance->m_bInitialized = false;
}
int cellRescVideoOutResolutionId2RescBufferMode(u32 resolutionId, mem32_t bufferMode)
int cellRescVideoOutResolutionId2RescBufferMode(u32 resolutionId, vm::ptr<be_t<u32>> bufferMode)
{
cellResc->Log("cellRescVideoOutResolutionId2RescBufferMode(resolutionId=%d, bufferMode_addr=0x%x)", resolutionId, bufferMode.GetAddr());
cellResc->Log("cellRescVideoOutResolutionId2RescBufferMode(resolutionId=%d, bufferMode_addr=0x%x)", resolutionId, bufferMode.addr());
switch (resolutionId)
{
case CELL_VIDEO_OUT_RESOLUTION_1080:
bufferMode = CELL_RESC_1920x1080;
*bufferMode = CELL_RESC_1920x1080;
break;
case CELL_VIDEO_OUT_RESOLUTION_720:
bufferMode = CELL_RESC_1280x720;
*bufferMode = CELL_RESC_1280x720;
break;
case CELL_VIDEO_OUT_RESOLUTION_480:
bufferMode = CELL_RESC_720x480;
*bufferMode = CELL_RESC_720x480;
break;
case CELL_VIDEO_OUT_RESOLUTION_576:
bufferMode = CELL_RESC_720x576;
*bufferMode = CELL_RESC_720x576;
break;
default:
cellResc->Error("cellRescVideoOutResolutionId2RescBufferMod : CELL_RESC_ERROR_BAD_ARGUMENT");
@ -608,9 +608,9 @@ int cellRescVideoOutResolutionId2RescBufferMode(u32 resolutionId, mem32_t buffer
return CELL_OK;
}
int cellRescSetDsts(u32 dstsMode, mem_ptr_t<CellRescDsts> dsts)
int cellRescSetDsts(u32 dstsMode, vm::ptr<CellRescDsts> dsts)
{
cellResc->Log("cellRescSetDsts(dstsMode=%d, CellRescDsts_addr=0x%x)", dstsMode, dsts.GetAddr());
cellResc->Log("cellRescSetDsts(dstsMode=%d, CellRescDsts_addr=0x%x)", dstsMode, dsts.addr());
if (!s_rescInternalInstance->m_bInitialized)
{
@ -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())
{
@ -820,9 +820,10 @@ int cellRescSetPalInterpolateDropFlexRatio(float ratio)
return CELL_OK;
}
int cellRescGetBufferSize(mem32_t colorBuffers, mem32_t vertexArray, mem32_t fragmentShader)
int cellRescGetBufferSize(vm::ptr<be_t<u32>> colorBuffers, vm::ptr<be_t<u32>> vertexArray, vm::ptr<be_t<u32>> fragmentShader)
{
cellResc->Warning("cellRescGetBufferSize(colorBuffers_addr=0x%x, vertexArray_addr=0x%x, fragmentShader_addr=0x%x)", colorBuffers.GetAddr(), vertexArray.GetAddr(), fragmentShader.GetAddr());
cellResc->Warning("cellRescGetBufferSize(colorBuffers_addr=0x%x, vertexArray_addr=0x%x, fragmentShader_addr=0x%x)",
colorBuffers.addr(), vertexArray.addr(), fragmentShader.addr());
if (!s_rescInternalInstance->m_bInitialized)
{
@ -845,19 +846,19 @@ int cellRescGetBufferSize(mem32_t colorBuffers, mem32_t vertexArray, mem32_t fra
fragmentUcodeSize = 0x300;
}
if (colorBuffers.GetAddr())
if (colorBuffers)
{
colorBuffers = colorBuffersSize;
*colorBuffers = colorBuffersSize;
}
if (vertexArray.GetAddr())
if (vertexArray)
{
vertexArray = vertexArraySize;
*vertexArray = vertexArraySize;
}
if (fragmentShader.GetAddr())
if (fragmentShader)
{
fragmentShader = fragmentUcodeSize;
*fragmentShader = fragmentUcodeSize;
}
return CELL_OK;
@ -884,9 +885,9 @@ int cellRescGetNumColorBuffers(u32 dstMode, u32 palTemporalMode, u32 reserved)
: 2;
}
int cellRescGcmSurface2RescSrc(mem_ptr_t<CellGcmSurface> gcmSurface, mem_ptr_t<CellRescSrc> rescSrc)
int cellRescGcmSurface2RescSrc(vm::ptr<CellGcmSurface> gcmSurface, vm::ptr<CellRescSrc> rescSrc)
{
cellResc->Log("cellRescGcmSurface2RescSrc(gcmSurface_addr=0x%x, rescSrc_addr=0x%x)", gcmSurface.GetAddr(), rescSrc.GetAddr());
cellResc->Log("cellRescGcmSurface2RescSrc(gcmSurface_addr=0x%x, rescSrc_addr=0x%x)", gcmSurface.addr(), rescSrc.addr());
u8 textureFormat = GcmSurfaceFormat2GcmTextureFormat(gcmSurface->colorFormat, gcmSurface->type);
s32 xW = 1, xH = 1;
@ -915,9 +916,9 @@ int cellRescGcmSurface2RescSrc(mem_ptr_t<CellGcmSurface> gcmSurface, mem_ptr_t<C
return CELL_OK;
}
int cellRescSetSrc(s32 idx, mem_ptr_t<CellRescSrc> src)
int cellRescSetSrc(s32 idx, vm::ptr<CellRescSrc> src)
{
cellResc->Log("cellRescSetSrc(idx=0x%x, src_addr=0x%x)", idx, src.GetAddr());
cellResc->Log("cellRescSetSrc(idx=0x%x, src_addr=0x%x)", idx, src.addr());
if(!s_rescInternalInstance->m_bInitialized)
{
@ -944,9 +945,9 @@ int cellRescSetSrc(s32 idx, mem_ptr_t<CellRescSrc> src)
return 0;
}
int cellRescSetConvertAndFlip(mem_ptr_t<CellGcmContextData> cntxt, s32 idx)
int cellRescSetConvertAndFlip(vm::ptr<CellGcmContextData> cntxt, s32 idx)
{
cellResc->Log("cellRescSetConvertAndFlip(cntxt_addr=0x%x, indx=0x%x)", cntxt.GetAddr(), idx);
cellResc->Log("cellRescSetConvertAndFlip(cntxt_addr=0x%x, indx=0x%x)", cntxt.addr(), idx);
if(!s_rescInternalInstance->m_bInitialized)
{
@ -990,9 +991,9 @@ int cellRescSetWaitFlip()
return CELL_OK;
}
int cellRescSetBufferAddress(mem32_t colorBuffers, mem32_t vertexArray, mem32_t fragmentShader)
int cellRescSetBufferAddress(vm::ptr<be_t<u32>> colorBuffers, vm::ptr<be_t<u32>> vertexArray, vm::ptr<be_t<u32>> fragmentShader)
{
cellResc->Warning("cellRescSetBufferAddress(colorBuffers_addr=0x%x, vertexArray_addr=0x%x, fragmentShader_addr=0x%x)", colorBuffers.GetAddr(), vertexArray.GetAddr(), fragmentShader.GetAddr());
cellResc->Warning("cellRescSetBufferAddress(colorBuffers_addr=0x%x, vertexArray_addr=0x%x, fragmentShader_addr=0x%x)", colorBuffers.addr(), vertexArray.addr(), fragmentShader.addr());
if(!s_rescInternalInstance->m_bInitialized)
{
@ -1000,18 +1001,18 @@ int cellRescSetBufferAddress(mem32_t colorBuffers, mem32_t vertexArray, mem32_t
return CELL_RESC_ERROR_NOT_INITIALIZED;
}
if(colorBuffers.GetAddr() % COLOR_BUFFER_ALIGNMENT || vertexArray.GetAddr() % VERTEX_BUFFER_ALIGNMENT || fragmentShader.GetAddr() % FRAGMENT_SHADER_ALIGNMENT)
if(colorBuffers.addr() % COLOR_BUFFER_ALIGNMENT || vertexArray.addr() % VERTEX_BUFFER_ALIGNMENT || fragmentShader.addr() % FRAGMENT_SHADER_ALIGNMENT)
{
cellResc->Error("cellRescSetBufferAddress : CELL_RESC_ERROR_BAD_ALIGNMENT");
return CELL_RESC_ERROR_BAD_ALIGNMENT;
}
s_rescInternalInstance->m_colorBuffersEA = colorBuffers.GetAddr();
s_rescInternalInstance->m_vertexArrayEA = vertexArray.GetAddr();
s_rescInternalInstance->m_fragmentUcodeEA = fragmentShader.GetAddr();
s_rescInternalInstance->m_colorBuffersEA = colorBuffers.addr();
s_rescInternalInstance->m_vertexArrayEA = vertexArray.addr();
s_rescInternalInstance->m_fragmentUcodeEA = fragmentShader.addr();
MemoryAllocator<be_t<u32>> dstOffset;
cellGcmAddressToOffset(s_rescInternalInstance->m_colorBuffersEA, dstOffset.GetAddr());
vm::var<be_t<u32>> dstOffset;
cellGcmAddressToOffset(s_rescInternalInstance->m_colorBuffersEA, dstOffset);
for (int i=0; i<GetNumColorBuffers(); i++)
{
@ -1130,8 +1131,8 @@ int CreateInterlaceTable(u32 ea_addr, float srcH, float dstH, CellRescTableEleme
float bandwidth = 0.5f / (srcH / dstH);
float phi_b = 2.f * PI * bandwidth;
float window[4];
mem16_ptr_t buf16(ea_addr);
mem32_ptr_t buf32(ea_addr);
auto buf16 = vm::ptr<be_t<u16>>::make(ea_addr);
auto buf32 = vm::ptr<be_t<float>>::make(ea_addr);
blackman(window);
@ -1159,7 +1160,8 @@ int CreateInterlaceTable(u32 ea_addr, float srcH, float dstH, CellRescTableEleme
buf16[3] = FloatToHalf(transient[3] / total4);
buf16 += 4;
}
else {
else
{
buf32[0] = transient[0] / total4;
buf32[1] = transient[1] / total4;
buf32[2] = transient[2] / total4;

View file

@ -153,9 +153,9 @@ CCellRescInternal* s_rescInternalInstance = nullptr;
extern int cellGcmSetFlipMode(u32 mode);
extern void cellGcmSetFlipHandler(u32 handler_addr);
extern void cellGcmSetVBlankHandler(u32 handler_addr);
extern int cellGcmAddressToOffset(u64 address, mem32_t offset);
extern int cellGcmAddressToOffset(u64 address, vm::ptr<be_t<u32>> offset);
extern int cellGcmSetDisplayBuffer(u32 id, u32 offset, u32 pitch, u32 width, u32 height);
extern int cellGcmSetPrepareFlip(mem_ptr_t<CellGcmContextData> ctx, u32 id);
extern int cellGcmSetPrepareFlip(vm::ptr<CellGcmContextData> ctx, u32 id);
extern int cellGcmSetSecondVFrequency(u32 freq);
extern u32 cellGcmGetLabelAddress(u8 index);
extern u32 cellGcmGetTiledPitchSize(u32 size);

View file

@ -9,31 +9,33 @@
//Module cellRtc(0x0009, cellRtc_init);
Module *cellRtc = nullptr;
long convertToUNIXTime(u16 seconds, u16 minutes, u16 hours, u16 days, int years)
s64 convertToUNIXTime(u16 seconds, u16 minutes, u16 hours, u16 days, int years)
{
return (seconds + minutes*60 + hours*3600 + days*86400 + (years-70)*31536000 + ((years-69)/4)*86400 - ((years-1)/100)*86400 + ((years+299)/400)*86400);
return (s64)seconds + (s64)minutes * 60 + (s64)hours * 3600 + (s64)days * 86400 +
(s64)(years - 70) * 31536000 + (s64)((years - 69) / 4) * 86400 -
(s64)((years - 1) / 100) * 86400 + (s64)((years + 299) / 400) * 86400;
}
u64 convertToWin32FILETIME(u16 seconds, u16 minutes, u16 hours, u16 days, int years)
{
long unixtime = convertToUNIXTime(seconds, minutes, hours, days, years);
s64 unixtime = convertToUNIXTime(seconds, minutes, hours, days, years);
u64 win32time = u64(unixtime) * u64(10000000) + u64(116444736000000000);
u64 win32filetime = win32time | win32time >> 32;
return win32filetime;
}
int cellRtcGetCurrentTick(mem_ptr_t<CellRtcTick> pTick)
int cellRtcGetCurrentTick(vm::ptr<CellRtcTick> pTick)
{
cellRtc->Log("cellRtcGetCurrentTick(pTick=0x%x)", pTick.GetAddr());
cellRtc->Log("cellRtcGetCurrentTick(pTick=0x%x)", pTick.addr());
rDateTime unow = rDateTime::UNow();
pTick->tick = unow.GetTicks();
return CELL_OK;
}
int cellRtcGetCurrentClock(mem_ptr_t<CellRtcDateTime> pClock, s32 iTimeZone)
int cellRtcGetCurrentClock(vm::ptr<CellRtcDateTime> pClock, s32 iTimeZone)
{
cellRtc->Log("cellRtcGetCurrentClock(pClock=0x%x, time_zone=%d)", pClock.GetAddr(), iTimeZone);
cellRtc->Log("cellRtcGetCurrentClock(pClock=0x%x, time_zone=%d)", pClock.addr(), iTimeZone);
rDateTime unow = rDateTime::UNow();
@ -52,9 +54,9 @@ int cellRtcGetCurrentClock(mem_ptr_t<CellRtcDateTime> pClock, s32 iTimeZone)
return CELL_OK;
}
int cellRtcGetCurrentClockLocalTime(mem_ptr_t<CellRtcDateTime> pClock)
int cellRtcGetCurrentClockLocalTime(vm::ptr<CellRtcDateTime> pClock)
{
cellRtc->Log("cellRtcGetCurrentClockLocalTime(pClock=0x%x)", pClock.GetAddr());
cellRtc->Log("cellRtcGetCurrentClockLocalTime(pClock=0x%x)", pClock.addr());
rDateTime unow = rDateTime::UNow();
@ -69,9 +71,9 @@ int cellRtcGetCurrentClockLocalTime(mem_ptr_t<CellRtcDateTime> pClock)
return CELL_OK;
}
int cellRtcFormatRfc2822(u32 pszDateTime_addr, mem_ptr_t<CellRtcTick> pUtc, s32 iTimeZone)
int cellRtcFormatRfc2822(u32 pszDateTime_addr, vm::ptr<CellRtcTick> pUtc, s32 iTimeZone)
{
cellRtc->Log("cellRtcFormatRfc2822(pszDateTime_addr=0x%x, pUtc=0x%x, time_zone=%d)", pszDateTime_addr, pUtc.GetAddr(), iTimeZone);
cellRtc->Log("cellRtcFormatRfc2822(pszDateTime_addr=0x%x, pUtc=0x%x, time_zone=%d)", pszDateTime_addr, pUtc.addr(), iTimeZone);
// Add time_zone as offset in minutes.
rTimeSpan tz = rTimeSpan(0, (long) iTimeZone, 0, 0);
@ -87,9 +89,9 @@ int cellRtcFormatRfc2822(u32 pszDateTime_addr, mem_ptr_t<CellRtcTick> pUtc, s32
return CELL_OK;
}
int cellRtcFormatRfc2822LocalTime(u32 pszDateTime_addr, mem_ptr_t<CellRtcTick> pUtc)
int cellRtcFormatRfc2822LocalTime(u32 pszDateTime_addr, vm::ptr<CellRtcTick> pUtc)
{
cellRtc->Log("cellRtcFormatRfc2822LocalTime(pszDateTime_addr=0x%x, pUtc=0x%x)", pszDateTime_addr, pUtc.GetAddr());
cellRtc->Log("cellRtcFormatRfc2822LocalTime(pszDateTime_addr=0x%x, pUtc=0x%x)", pszDateTime_addr, pUtc.addr());
// Get date from ticks.
rDateTime date = rDateTime((time_t)pUtc->tick);
@ -101,9 +103,9 @@ int cellRtcFormatRfc2822LocalTime(u32 pszDateTime_addr, mem_ptr_t<CellRtcTick> p
return CELL_OK;
}
int cellRtcFormatRfc3339(u32 pszDateTime_addr, mem_ptr_t<CellRtcTick> pUtc, s32 iTimeZone)
int cellRtcFormatRfc3339(u32 pszDateTime_addr, vm::ptr<CellRtcTick> pUtc, s32 iTimeZone)
{
cellRtc->Log("cellRtcFormatRfc3339(pszDateTime_addr=0x%x, pUtc=0x%x, iTimeZone=%d)", pszDateTime_addr, pUtc.GetAddr(), iTimeZone);
cellRtc->Log("cellRtcFormatRfc3339(pszDateTime_addr=0x%x, pUtc=0x%x, iTimeZone=%d)", pszDateTime_addr, pUtc.addr(), iTimeZone);
// Add time_zone as offset in minutes.
rTimeSpan tz = rTimeSpan(0, (long) iTimeZone, 0, 0);
@ -119,9 +121,9 @@ int cellRtcFormatRfc3339(u32 pszDateTime_addr, mem_ptr_t<CellRtcTick> pUtc, s32
return CELL_OK;
}
int cellRtcFormatRfc3339LocalTime(u32 pszDateTime_addr, mem_ptr_t<CellRtcTick> pUtc)
int cellRtcFormatRfc3339LocalTime(u32 pszDateTime_addr, vm::ptr<CellRtcTick> pUtc)
{
cellRtc->Log("cellRtcFormatRfc3339LocalTime(pszDateTime_addr=0x%x, pUtc=0x%x)", pszDateTime_addr, pUtc.GetAddr());
cellRtc->Log("cellRtcFormatRfc3339LocalTime(pszDateTime_addr=0x%x, pUtc=0x%x)", pszDateTime_addr, pUtc.addr());
// Get date from ticks.
rDateTime date = rDateTime((time_t) pUtc->tick);
@ -133,9 +135,9 @@ int cellRtcFormatRfc3339LocalTime(u32 pszDateTime_addr, mem_ptr_t<CellRtcTick> p
return CELL_OK;
}
int cellRtcParseDateTime(mem_ptr_t<CellRtcTick> pUtc, u32 pszDateTime_addr)
int cellRtcParseDateTime(vm::ptr<CellRtcTick> pUtc, u32 pszDateTime_addr)
{
cellRtc->Log("cellRtcParseDateTime(pUtc=0x%x, pszDateTime_addr=0x%x)", pUtc.GetAddr(), pszDateTime_addr);
cellRtc->Log("cellRtcParseDateTime(pUtc=0x%x, pszDateTime_addr=0x%x)", pUtc.addr(), pszDateTime_addr);
// Get date from formatted string.
rDateTime date;
@ -147,9 +149,9 @@ int cellRtcParseDateTime(mem_ptr_t<CellRtcTick> pUtc, u32 pszDateTime_addr)
return CELL_OK;
}
int cellRtcParseRfc3339(mem_ptr_t<CellRtcTick> pUtc, u32 pszDateTime_addr)
int cellRtcParseRfc3339(vm::ptr<CellRtcTick> pUtc, u32 pszDateTime_addr)
{
cellRtc->Log("cellRtcParseRfc3339(pUtc=0x%x, pszDateTime_addr=0x%x)", pUtc.GetAddr(), pszDateTime_addr);
cellRtc->Log("cellRtcParseRfc3339(pUtc=0x%x, pszDateTime_addr=0x%x)", pUtc.addr(), pszDateTime_addr);
// Get date from RFC3339 formatted string.
rDateTime date;
@ -161,9 +163,9 @@ int cellRtcParseRfc3339(mem_ptr_t<CellRtcTick> pUtc, u32 pszDateTime_addr)
return CELL_OK;
}
int cellRtcGetTick(mem_ptr_t<CellRtcDateTime> pTime, mem_ptr_t<CellRtcTick> pTick)
int cellRtcGetTick(vm::ptr<CellRtcDateTime> pTime, vm::ptr<CellRtcTick> pTick)
{
cellRtc->Log("cellRtcGetTick(pTime=0x%x, pTick=0x%x)", pTime.GetAddr(), pTick.GetAddr());
cellRtc->Log("cellRtcGetTick(pTime=0x%x, pTick=0x%x)", pTime.addr(), pTick.addr());
rDateTime datetime = rDateTime(pTime->day, (rDateTime::Month)pTime->month.ToLE(), pTime->year, pTime->hour, pTime->minute, pTime->second, (pTime->microsecond / 1000));
pTick->tick = datetime.GetTicks();
@ -171,9 +173,9 @@ int cellRtcGetTick(mem_ptr_t<CellRtcDateTime> pTime, mem_ptr_t<CellRtcTick> pTic
return CELL_OK;
}
int cellRtcSetTick(mem_ptr_t<CellRtcDateTime> pTime, mem_ptr_t<CellRtcTick> pTick)
int cellRtcSetTick(vm::ptr<CellRtcDateTime> pTime, vm::ptr<CellRtcTick> pTick)
{
cellRtc->Log("cellRtcSetTick(pTime=0x%x, pTick=0x%x)", pTime.GetAddr(), pTick.GetAddr());
cellRtc->Log("cellRtcSetTick(pTime=0x%x, pTick=0x%x)", pTime.addr(), pTick.addr());
rDateTime date = rDateTime((time_t)pTick->tick);
@ -188,17 +190,17 @@ int cellRtcSetTick(mem_ptr_t<CellRtcDateTime> pTime, mem_ptr_t<CellRtcTick> pTic
return CELL_OK;
}
int cellRtcTickAddTicks(mem_ptr_t<CellRtcTick> pTick0, mem_ptr_t<CellRtcTick> pTick1, s64 lAdd)
int cellRtcTickAddTicks(vm::ptr<CellRtcTick> pTick0, vm::ptr<CellRtcTick> pTick1, s64 lAdd)
{
cellRtc->Log("cellRtcTickAddTicks(pTick0=0x%x, pTick1=0x%x, lAdd=%lld)", pTick0.GetAddr(), pTick1.GetAddr(), lAdd);
cellRtc->Log("cellRtcTickAddTicks(pTick0=0x%x, pTick1=0x%x, lAdd=%lld)", pTick0.addr(), pTick1.addr(), lAdd);
pTick0->tick = pTick1->tick + lAdd;
return CELL_OK;
}
int cellRtcTickAddMicroseconds(mem_ptr_t<CellRtcTick> pTick0, mem_ptr_t<CellRtcTick> pTick1, s64 lAdd)
int cellRtcTickAddMicroseconds(vm::ptr<CellRtcTick> pTick0, vm::ptr<CellRtcTick> pTick1, s64 lAdd)
{
cellRtc->Log("cellRtcTickAddMicroseconds(pTick0=0x%x, pTick1=0x%x, lAdd=%lld)", pTick0.GetAddr(), pTick1.GetAddr(), lAdd);
cellRtc->Log("cellRtcTickAddMicroseconds(pTick0=0x%x, pTick1=0x%x, lAdd=%lld)", pTick0.addr(), pTick1.addr(), lAdd);
rDateTime date = rDateTime((time_t)pTick1->tick);
rTimeSpan microseconds = rTimeSpan(0, 0, 0, lAdd / 1000);
@ -208,9 +210,9 @@ int cellRtcTickAddMicroseconds(mem_ptr_t<CellRtcTick> pTick0, mem_ptr_t<CellRtcT
return CELL_OK;
}
int cellRtcTickAddSeconds(mem_ptr_t<CellRtcTick> pTick0, mem_ptr_t<CellRtcTick> pTick1, s64 lAdd)
int cellRtcTickAddSeconds(vm::ptr<CellRtcTick> pTick0, vm::ptr<CellRtcTick> pTick1, s64 lAdd)
{
cellRtc->Log("cellRtcTickAddSeconds(pTick0=0x%x, pTick1=0x%x, lAdd=%lld)", pTick0.GetAddr(), pTick1.GetAddr(), lAdd);
cellRtc->Log("cellRtcTickAddSeconds(pTick0=0x%x, pTick1=0x%x, lAdd=%lld)", pTick0.addr(), pTick1.addr(), lAdd);
rDateTime date = rDateTime((time_t)pTick1->tick);
rTimeSpan seconds = rTimeSpan(0, 0, lAdd, 0);
@ -220,45 +222,45 @@ int cellRtcTickAddSeconds(mem_ptr_t<CellRtcTick> pTick0, mem_ptr_t<CellRtcTick>
return CELL_OK;
}
int cellRtcTickAddMinutes(mem_ptr_t<CellRtcTick> pTick0, mem_ptr_t<CellRtcTick> pTick1, s64 lAdd)
int cellRtcTickAddMinutes(vm::ptr<CellRtcTick> pTick0, vm::ptr<CellRtcTick> pTick1, s64 lAdd)
{
cellRtc->Log("cellRtcTickAddMinutes(pTick0=0x%x, pTick1=0x%x, lAdd=%lld)", pTick0.GetAddr(), pTick1.GetAddr(), lAdd);
cellRtc->Log("cellRtcTickAddMinutes(pTick0=0x%x, pTick1=0x%x, lAdd=%lld)", pTick0.addr(), pTick1.addr(), lAdd);
rDateTime date = rDateTime((time_t)pTick1->tick);
rTimeSpan minutes = rTimeSpan(0, lAdd, 0, 0);
rTimeSpan minutes = rTimeSpan(0, lAdd, 0, 0); // ???
date.Add(minutes);
pTick0->tick = date.GetTicks();
return CELL_OK;
}
int cellRtcTickAddHours(mem_ptr_t<CellRtcTick> pTick0, mem_ptr_t<CellRtcTick> pTick1, s32 iAdd)
int cellRtcTickAddHours(vm::ptr<CellRtcTick> pTick0, vm::ptr<CellRtcTick> pTick1, s32 iAdd)
{
cellRtc->Log("cellRtcTickAddHours(pTick0=0x%x, pTick1=0x%x, iAdd=%d)", pTick0.GetAddr(), pTick1.GetAddr(), iAdd);
cellRtc->Log("cellRtcTickAddHours(pTick0=0x%x, pTick1=0x%x, iAdd=%d)", pTick0.addr(), pTick1.addr(), iAdd);
rDateTime date = rDateTime((time_t)pTick1->tick);
rTimeSpan hours = rTimeSpan(iAdd, 0, 0, 0);
rTimeSpan hours = rTimeSpan(iAdd, 0, 0, 0); // ???
date.Add(hours);
pTick0->tick = date.GetTicks();
return CELL_OK;
}
int cellRtcTickAddDays(mem_ptr_t<CellRtcTick> pTick0, mem_ptr_t<CellRtcTick> pTick1, s32 iAdd)
int cellRtcTickAddDays(vm::ptr<CellRtcTick> pTick0, vm::ptr<CellRtcTick> pTick1, s32 iAdd)
{
cellRtc->Log("cellRtcTickAddDays(pTick0=0x%x, pTick1=0x%x, iAdd=%d)", pTick0.GetAddr(), pTick1.GetAddr(), iAdd);
cellRtc->Log("cellRtcTickAddDays(pTick0=0x%x, pTick1=0x%x, iAdd=%d)", pTick0.addr(), pTick1.addr(), iAdd);
rDateTime date = rDateTime((time_t)pTick1->tick);
rDateSpan days = rDateSpan(0, 0, 0, iAdd);
rDateSpan days = rDateSpan(0, 0, 0, iAdd); // ???
date.Add(days);
pTick0->tick = date.GetTicks();
return CELL_OK;
}
int cellRtcTickAddWeeks(mem_ptr_t<CellRtcTick> pTick0, mem_ptr_t<CellRtcTick> pTick1, s32 iAdd)
int cellRtcTickAddWeeks(vm::ptr<CellRtcTick> pTick0, vm::ptr<CellRtcTick> pTick1, s32 iAdd)
{
cellRtc->Log("cellRtcTickAddWeeks(pTick0=0x%x, pTick1=0x%x, iAdd=%d)", pTick0.GetAddr(), pTick1.GetAddr(), iAdd);
cellRtc->Log("cellRtcTickAddWeeks(pTick0=0x%x, pTick1=0x%x, iAdd=%d)", pTick0.addr(), pTick1.addr(), iAdd);
rDateTime date = rDateTime((time_t)pTick1->tick);
rDateSpan weeks = rDateSpan(0, 0, iAdd, 0);
@ -268,9 +270,9 @@ int cellRtcTickAddWeeks(mem_ptr_t<CellRtcTick> pTick0, mem_ptr_t<CellRtcTick> pT
return CELL_OK;
}
int cellRtcTickAddMonths(mem_ptr_t<CellRtcTick> pTick0, mem_ptr_t<CellRtcTick> pTick1, s32 iAdd)
int cellRtcTickAddMonths(vm::ptr<CellRtcTick> pTick0, vm::ptr<CellRtcTick> pTick1, s32 iAdd)
{
cellRtc->Log("cellRtcTickAddMonths(pTick0=0x%x, pTick1=0x%x, iAdd=%d)", pTick0.GetAddr(), pTick1.GetAddr(), iAdd);
cellRtc->Log("cellRtcTickAddMonths(pTick0=0x%x, pTick1=0x%x, iAdd=%d)", pTick0.addr(), pTick1.addr(), iAdd);
rDateTime date = rDateTime((time_t)pTick1->tick);
rDateSpan months = rDateSpan(0, iAdd, 0, 0);
@ -280,9 +282,9 @@ int cellRtcTickAddMonths(mem_ptr_t<CellRtcTick> pTick0, mem_ptr_t<CellRtcTick> p
return CELL_OK;
}
int cellRtcTickAddYears(mem_ptr_t<CellRtcTick> pTick0, mem_ptr_t<CellRtcTick> pTick1, s32 iAdd)
int cellRtcTickAddYears(vm::ptr<CellRtcTick> pTick0, vm::ptr<CellRtcTick> pTick1, s32 iAdd)
{
cellRtc->Log("cellRtcTickAddYears(pTick0=0x%x, pTick1=0x%x, iAdd=%d)", pTick0.GetAddr(), pTick1.GetAddr(), iAdd);
cellRtc->Log("cellRtcTickAddYears(pTick0=0x%x, pTick1=0x%x, iAdd=%d)", pTick0.addr(), pTick1.addr(), iAdd);
rDateTime date = rDateTime((time_t)pTick1->tick);
rDateSpan years = rDateSpan(iAdd, 0, 0, 0);
@ -292,9 +294,9 @@ int cellRtcTickAddYears(mem_ptr_t<CellRtcTick> pTick0, mem_ptr_t<CellRtcTick> pT
return CELL_OK;
}
int cellRtcConvertUtcToLocalTime(mem_ptr_t<CellRtcTick> pUtc, mem_ptr_t<CellRtcTick> pLocalTime)
int cellRtcConvertUtcToLocalTime(vm::ptr<CellRtcTick> pUtc, vm::ptr<CellRtcTick> pLocalTime)
{
cellRtc->Log("cellRtcConvertUtcToLocalTime(pUtc=0x%x, pLocalTime=0x%x)", pUtc.GetAddr(), pLocalTime.GetAddr());
cellRtc->Log("cellRtcConvertUtcToLocalTime(pUtc=0x%x, pLocalTime=0x%x)", pUtc.addr(), pLocalTime.addr());
rDateTime time = rDateTime((time_t)pUtc->tick);
rDateTime local_time = time.FromUTC(false);
@ -302,9 +304,9 @@ int cellRtcConvertUtcToLocalTime(mem_ptr_t<CellRtcTick> pUtc, mem_ptr_t<CellRtcT
return CELL_OK;
}
int cellRtcConvertLocalTimeToUtc(mem_ptr_t<CellRtcTick> pLocalTime, mem_ptr_t<CellRtcTick> pUtc)
int cellRtcConvertLocalTimeToUtc(vm::ptr<CellRtcTick> pLocalTime, vm::ptr<CellRtcTick> pUtc)
{
cellRtc->Log("cellRtcConvertLocalTimeToUtc(pLocalTime=0x%x, pUtc=0x%x)", pLocalTime.GetAddr(), pUtc.GetAddr());
cellRtc->Log("cellRtcConvertLocalTimeToUtc(pLocalTime=0x%x, pUtc=0x%x)", pLocalTime.addr(), pUtc.addr());
rDateTime time = rDateTime((time_t)pLocalTime->tick);
rDateTime utc_time = time.ToUTC(false);
@ -312,44 +314,44 @@ int cellRtcConvertLocalTimeToUtc(mem_ptr_t<CellRtcTick> pLocalTime, mem_ptr_t<Ce
return CELL_OK;
}
int cellRtcGetDosTime(mem_ptr_t<CellRtcDateTime> pDateTime, mem32_t puiDosTime)
int cellRtcGetDosTime(vm::ptr<CellRtcDateTime> pDateTime, vm::ptr<be_t<u32>> puiDosTime)
{
cellRtc->Log("cellRtcGetDosTime(pDateTime=0x%x, puiDosTime=0x%x)", pDateTime.GetAddr(), puiDosTime.GetAddr());
cellRtc->Log("cellRtcGetDosTime(pDateTime=0x%x, puiDosTime=0x%x)", pDateTime.addr(), puiDosTime.addr());
// Convert to DOS time.
rDateTime date_time = rDateTime(pDateTime->day, (rDateTime::Month)pDateTime->month.ToLE(), pDateTime->year, pDateTime->hour, pDateTime->minute, pDateTime->second, (pDateTime->microsecond / 1000));
puiDosTime = date_time.GetAsDOS();
*puiDosTime = date_time.GetAsDOS();
return CELL_OK;
}
int cellRtcGetTime_t(mem_ptr_t<CellRtcDateTime> pDateTime, mem64_t piTime)
int cellRtcGetTime_t(vm::ptr<CellRtcDateTime> pDateTime, vm::ptr<be_t<s64>> piTime)
{
cellRtc->Log("cellRtcGetTime_t(pDateTime=0x%x, piTime=0x%x)", pDateTime.GetAddr(), piTime.GetAddr());
cellRtc->Log("cellRtcGetTime_t(pDateTime=0x%x, piTime=0x%x)", pDateTime.addr(), piTime.addr());
// Convert to POSIX time_t.
rDateTime date_time = rDateTime(pDateTime->day, (rDateTime::Month)pDateTime->month.ToLE(), pDateTime->year, pDateTime->hour, pDateTime->minute, pDateTime->second, (pDateTime->microsecond / 1000));
piTime = convertToUNIXTime(date_time.GetSecond(rDateTime::TZ::UTC), date_time.GetMinute(rDateTime::TZ::UTC),
*piTime = convertToUNIXTime(date_time.GetSecond(rDateTime::TZ::UTC), date_time.GetMinute(rDateTime::TZ::UTC),
date_time.GetHour(rDateTime::TZ::UTC), date_time.GetDay(rDateTime::TZ::UTC), date_time.GetYear(rDateTime::TZ::UTC));
return CELL_OK;
}
int cellRtcGetWin32FileTime(mem_ptr_t<CellRtcDateTime> pDateTime, mem64_t pulWin32FileTime)
int cellRtcGetWin32FileTime(vm::ptr<CellRtcDateTime> pDateTime, vm::ptr<be_t<u64>> pulWin32FileTime)
{
cellRtc->Log("cellRtcGetWin32FileTime(pDateTime=0x%x, pulWin32FileTime=0x%x)", pDateTime.GetAddr(), pulWin32FileTime.GetAddr());
cellRtc->Log("cellRtcGetWin32FileTime(pDateTime=0x%x, pulWin32FileTime=0x%x)", pDateTime.addr(), pulWin32FileTime.addr());
// Convert to WIN32 FILETIME.
rDateTime date_time = rDateTime(pDateTime->day, (rDateTime::Month)pDateTime->month.ToLE(), pDateTime->year, pDateTime->hour, pDateTime->minute, pDateTime->second, (pDateTime->microsecond / 1000));
pulWin32FileTime = convertToWin32FILETIME(date_time.GetSecond(rDateTime::TZ::UTC), date_time.GetMinute(rDateTime::TZ::UTC),
*pulWin32FileTime = convertToWin32FILETIME(date_time.GetSecond(rDateTime::TZ::UTC), date_time.GetMinute(rDateTime::TZ::UTC),
date_time.GetHour(rDateTime::TZ::UTC), date_time.GetDay(rDateTime::TZ::UTC), date_time.GetYear(rDateTime::TZ::UTC));
return CELL_OK;
}
int cellRtcSetDosTime(mem_ptr_t<CellRtcDateTime> pDateTime, u32 uiDosTime)
int cellRtcSetDosTime(vm::ptr<CellRtcDateTime> pDateTime, u32 uiDosTime)
{
cellRtc->Log("cellRtcSetDosTime(pDateTime=0x%x, uiDosTime=0x%x)", pDateTime.GetAddr(), uiDosTime);
cellRtc->Log("cellRtcSetDosTime(pDateTime=0x%x, uiDosTime=0x%x)", pDateTime.addr(), uiDosTime);
rDateTime date_time;
rDateTime dos_time = date_time.SetFromDOS(uiDosTime);
@ -365,9 +367,9 @@ int cellRtcSetDosTime(mem_ptr_t<CellRtcDateTime> pDateTime, u32 uiDosTime)
return CELL_OK;
}
int cellRtcSetTime_t(mem_ptr_t<CellRtcDateTime> pDateTime, u64 iTime)
int cellRtcSetTime_t(vm::ptr<CellRtcDateTime> pDateTime, u64 iTime)
{
cellRtc->Log("cellRtcSetTime_t(pDateTime=0x%x, iTime=0x%llx)", pDateTime.GetAddr(), iTime);
cellRtc->Log("cellRtcSetTime_t(pDateTime=0x%x, iTime=0x%llx)", pDateTime.addr(), iTime);
rDateTime date_time = rDateTime((time_t)iTime);
@ -382,7 +384,7 @@ int cellRtcSetTime_t(mem_ptr_t<CellRtcDateTime> pDateTime, u64 iTime)
return CELL_OK;
}
int cellRtcSetWin32FileTime(mem_ptr_t<CellRtcDateTime> pDateTime, u64 ulWin32FileTime)
int cellRtcSetWin32FileTime(vm::ptr<CellRtcDateTime> pDateTime, u64 ulWin32FileTime)
{
cellRtc->Log("cellRtcSetWin32FileTime(pDateTime=0x%x, ulWin32FileTime=0x%llx)", pDateTime, ulWin32FileTime);
@ -424,9 +426,9 @@ int cellRtcGetDayOfWeek(s32 year, s32 month, s32 day)
return datetime.GetWeekDay();
}
int cellRtcCheckValid(mem_ptr_t<CellRtcDateTime> pTime)
int cellRtcCheckValid(vm::ptr<CellRtcDateTime> pTime)
{
cellRtc->Log("cellRtcCheckValid(pTime=0x%x)", pTime.GetAddr());
cellRtc->Log("cellRtcCheckValid(pTime=0x%x)", pTime.addr());
if ((pTime->year < 1) || (pTime->year > 9999)) return CELL_RTC_ERROR_INVALID_YEAR;
else if ((pTime->month < 1) || (pTime->month > 12)) return CELL_RTC_ERROR_INVALID_MONTH;
@ -438,9 +440,9 @@ int cellRtcCheckValid(mem_ptr_t<CellRtcDateTime> pTime)
else return CELL_OK;
}
int cellRtcCompareTick(mem_ptr_t<CellRtcTick> pTick0, mem_ptr_t<CellRtcTick> pTick1)
int cellRtcCompareTick(vm::ptr<CellRtcTick> pTick0, vm::ptr<CellRtcTick> pTick1)
{
cellRtc->Log("cellRtcCompareTick(pTick0=0x%x, pTick1=0x%x)", pTick0.GetAddr(), pTick1.GetAddr());
cellRtc->Log("cellRtcCompareTick(pTick0=0x%x, pTick1=0x%x)", pTick0.addr(), pTick1.addr());
if (pTick0->tick < pTick1->tick) return -1;
else if (pTick0->tick > pTick1->tick) return 1;

View file

@ -110,28 +110,28 @@ typedef void(*CellSailMemAllocatorFuncFree)(u32 pArg, u32 boundary, u32 pMemory)
typedef int(*CellSailSoundAdapterFuncMakeup)(u32 pArg);
typedef int(*CellSailSoundAdapterFuncCleanup)(u32 pArg);
typedef void(*CellSailSoundAdapterFuncFormatChanged)(u32 pArg, mem_ptr_t<CellSailAudioFormat> pFormat, u32 sessionId);
typedef void(*CellSailSoundAdapterFuncFormatChanged)(u32 pArg, vm::ptr<CellSailAudioFormat> pFormat, u32 sessionId);
typedef int(*CellSailGraphicsAdapterFuncMakeup)(u32 pArg);
typedef int(*CellSailGraphicsAdapterFuncCleanup)(u32 pArg);
typedef void(*CellSailGraphicsAdapterFuncFormatChanged)(u32 pArg, mem_ptr_t<CellSailVideoFormat> pFormat, u32 sessionId);
typedef void(*CellSailGraphicsAdapterFuncFormatChanged)(u32 pArg, vm::ptr<CellSailVideoFormat> pFormat, u32 sessionId);
typedef int(*CellSailGraphicsAdapterFuncAllocFrame)(u32 pArg, u32 size, s32 num, u8 ppFrame);
typedef int(*CellSailGraphicsAdapterFuncFreeFrame)(u32 pArg, s32 num, u8 ppFrame);
typedef int(*CellSailSourceFuncMakeup)(u32 pArg, s8 pProtocolNames);
typedef int(*CellSailSourceFuncCleanup)(u32 pArg);
typedef void(*CellSailSourceFuncOpen)(u32 pArg, s32 streamType, u32 pMediaInfo, s8 pUri, mem_ptr_t<CellSailSourceStreamingProfile> pProfile);
typedef void(*CellSailSourceFuncOpen)(u32 pArg, s32 streamType, u32 pMediaInfo, s8 pUri, vm::ptr<CellSailSourceStreamingProfile> pProfile);
typedef void(*CellSailSourceFuncClose)(u32 pArg);
typedef void(*CellSailSourceFuncStart)(u32 pArg, mem_ptr_t<CellSailSourceStartCommand> pCommand, u32 sessionId);
typedef void(*CellSailSourceFuncStart)(u32 pArg, vm::ptr<CellSailSourceStartCommand> pCommand, u32 sessionId);
typedef void(*CellSailSourceFuncStop)(u32 pArg);
typedef void(*CellSailSourceFuncCancel)(u32 pArg);
typedef int(*CellSailSourceFuncCheckout)(u32 pArg, mem_ptr_t<CellSailSourceBufferItem> ppItem);
typedef int(*CellSailSourceFuncCheckin)(u32 pArg, mem_ptr_t<CellSailSourceBufferItem> pItem);
typedef int(*CellSailSourceFuncCheckout)(u32 pArg, vm::ptr<CellSailSourceBufferItem> ppItem);
typedef int(*CellSailSourceFuncCheckin)(u32 pArg, vm::ptr<CellSailSourceBufferItem> pItem);
typedef int(*CellSailSourceFuncClear)(u32 pArg);
typedef int(*CellSailSourceFuncRead)(u32 pArg, s32 streamType, u32 pMediaInfo, s8 pUri, u64 offset, u8 pBuf, u32 size, u64 pTotalSize);
typedef int(*CellSailSourceFuncReadSync)(u32 pArg, s32 streamType, u32 pMediaInfo, s8 pUri, u64 offset, u8 pBuf, u32 size, u64 pTotalSize);
typedef int(*CellSailSourceFuncGetCapabilities)(u32 pArg, s32 streamType, u32 pMediaInfo, s8 pUri, u64 pCapabilities);
typedef int(*CellSailSourceFuncInquireCapability)(u32 pArg, s32 streamType, u32 pMediaInfo, s8 pUri, mem_ptr_t<CellSailSourceStartCommand> pCommand);
typedef int(*CellSailSourceFuncInquireCapability)(u32 pArg, s32 streamType, u32 pMediaInfo, s8 pUri, vm::ptr<CellSailSourceStartCommand> pCommand);
typedef void(*CellSailSourceCheckFuncError)(u32 pArg, s8 pMsg, s32 line);
typedef int(*CellSailFsFuncOpen)(s8 pPath, s32 flag, s32 pFd, u32 pArg, u64 size);
@ -144,25 +144,25 @@ typedef int(*CellSailFsFuncCancel)(s32 fd);
typedef int(*CellSailRendererAudioFuncMakeup)(u32 pArg);
typedef int(*CellSailRendererAudioFuncCleanup)(u32 pArg);
typedef void(*CellSailRendererAudioFuncOpen)(u32 pArg, mem_ptr_t<CellSailAudioFormat> pInfo, u32 frameNum);
typedef void(*CellSailRendererAudioFuncOpen)(u32 pArg, vm::ptr<CellSailAudioFormat> pInfo, u32 frameNum);
typedef void(*CellSailRendererAudioFuncClose)(u32 pArg);
typedef void(*CellSailRendererAudioFuncStart)(u32 pArg, bool buffering);
typedef void(*CellSailRendererAudioFuncStop)(u32 pArg, bool flush);
typedef void(*CellSailRendererAudioFuncCancel)(u32 pArg);
typedef int(*CellSailRendererAudioFuncCheckout)(u32 pArg, mem_ptr_t<CellSailAudioFrameInfo> ppInfo);
typedef int(*CellSailRendererAudioFuncCheckin)(u32 pArg, mem_ptr_t<CellSailAudioFrameInfo> pInfo);
typedef int(*CellSailRendererAudioFuncCheckout)(u32 pArg, vm::ptr<CellSailAudioFrameInfo> ppInfo);
typedef int(*CellSailRendererAudioFuncCheckin)(u32 pArg, vm::ptr<CellSailAudioFrameInfo> pInfo);
typedef int(*CellSailRendererVideoFuncMakeup)(u32 pArg);
typedef int(*CellSailRendererVideoFuncCleanup)(u32 pArg);
typedef void(*CellSailRendererVideoFuncOpen)(u32 pArg, mem_ptr_t<CellSailVideoFormat> pInfo, u32 frameNum, u32 minFrameNum);
typedef void(*CellSailRendererVideoFuncOpen)(u32 pArg, vm::ptr<CellSailVideoFormat> pInfo, u32 frameNum, u32 minFrameNum);
typedef void(*CellSailRendererVideoFuncClose)(u32 pArg);
typedef void(*CellSailRendererVideoFuncStart)(u32 pArg, bool buffering);
typedef void(*CellSailRendererVideoFuncStop)(u32 pArg, bool flush, bool keepRendering);
typedef void(*CellSailRendererVideoFuncCancel)(u32 pArg);
typedef int(*CellSailRendererVideoFuncCheckout)(u32 pArg, mem_ptr_t<CellSailVideoFrameInfo> ppInfo);
typedef int(*CellSailRendererVideoFuncCheckin)(u32 pArg, mem_ptr_t<CellSailVideoFrameInfo> pInfo);
typedef int(*CellSailRendererVideoFuncCheckout)(u32 pArg, vm::ptr<CellSailVideoFrameInfo> ppInfo);
typedef int(*CellSailRendererVideoFuncCheckin)(u32 pArg, vm::ptr<CellSailVideoFrameInfo> pInfo);
typedef void(*CellSailPlayerFuncNotified)(u32 pArg, mem_ptr_t<CellSailEvent> event, u64 arg0, u64 arg1);
typedef void(*CellSailPlayerFuncNotified)(u32 pArg, vm::ptr<CellSailEvent> event, u64 arg0, u64 arg1);
struct CellSailMemAllocatorFuncs
{

File diff suppressed because it is too large Load diff

View file

@ -194,11 +194,11 @@ struct CellSpursTracePacket
};
// Exception handlers.
//typedef void (*CellSpursGlobalExceptionEventHandler)(mem_ptr_t<CellSpurs> spurs, const mem_ptr_t<CellSpursExceptionInfo> info,
// u32 id, mem_ptr_t<void> arg);
//typedef void (*CellSpursGlobalExceptionEventHandler)(vm::ptr<CellSpurs> spurs, const vm::ptr<CellSpursExceptionInfo> info,
// u32 id, vm::ptr<void> arg);
//
//typedef void (*CellSpursTasksetExceptionEventHandler)(mem_ptr_t<CellSpurs> spurs, mem_ptr_t<CellSpursTaskset> taskset,
// u32 idTask, const mem_ptr_t<CellSpursExceptionInfo> info, mem_ptr_t<void> arg);
//typedef void (*CellSpursTasksetExceptionEventHandler)(vm::ptr<CellSpurs> spurs, vm::ptr<CellSpursTaskset> taskset,
// u32 idTask, const vm::ptr<CellSpursExceptionInfo> info, vm::ptr<void> arg);
struct CellSpursTasksetInfo
{

View file

@ -764,7 +764,7 @@ void cellSpursJq_init()
#ifdef PRX_DEBUG
CallAfter([]()
{
libspurs_jq = Memory.PRXMem.AllocAlign(sizeof(libspurs_jq_data), 4096);
libspurs_jq = (u32)Memory.PRXMem.AllocAlign(sizeof(libspurs_jq_data), 4096);
memcpy(Memory + libspurs_jq, libspurs_jq_data, sizeof(libspurs_jq_data));
libspurs_jq_rtoc = libspurs_jq + 0x17E80;

File diff suppressed because it is too large Load diff

View file

@ -155,22 +155,22 @@ struct CellSyncLFQueue
static_assert(sizeof(CellSyncLFQueue) == 128, "CellSyncLFQueue: wrong size");
s32 syncMutexInitialize(mem_ptr_t<CellSyncMutex> mutex);
s32 syncMutexInitialize(vm::ptr<CellSyncMutex> mutex);
s32 syncBarrierInitialize(mem_ptr_t<CellSyncBarrier> barrier, u16 total_count);
s32 syncBarrierInitialize(vm::ptr<CellSyncBarrier> barrier, u16 total_count);
s32 syncRwmInitialize(mem_ptr_t<CellSyncRwm> rwm, u32 buffer_addr, u32 buffer_size);
s32 syncRwmInitialize(vm::ptr<CellSyncRwm> rwm, u32 buffer_addr, u32 buffer_size);
s32 syncQueueInitialize(mem_ptr_t<CellSyncQueue> queue, u32 buffer_addr, u32 size, u32 depth);
s32 syncQueueInitialize(vm::ptr<CellSyncQueue> queue, u32 buffer_addr, u32 size, u32 depth);
s32 syncLFQueueInitialize(mem_ptr_t<CellSyncLFQueue> queue, u32 buffer_addr, u32 size, u32 depth, CellSyncQueueDirection direction, u32 eaSignal_addr);
s32 syncLFQueueGetPushPointer(mem_ptr_t<CellSyncLFQueue> queue, s32& pointer, u32 isBlocking, u32 useEventQueue);
s32 syncLFQueueGetPushPointer2(mem_ptr_t<CellSyncLFQueue> queue, s32& pointer, u32 isBlocking, u32 useEventQueue);
s32 syncLFQueueCompletePushPointer(mem_ptr_t<CellSyncLFQueue> queue, s32 pointer, const std::function<s32(u32 addr, u32 arg)> fpSendSignal);
s32 syncLFQueueCompletePushPointer2(mem_ptr_t<CellSyncLFQueue> queue, s32 pointer, const std::function<s32(u32 addr, u32 arg)> fpSendSignal);
s32 syncLFQueueGetPopPointer(mem_ptr_t<CellSyncLFQueue> queue, s32& pointer, u32 isBlocking, u32, u32 useEventQueue);
s32 syncLFQueueGetPopPointer2(mem_ptr_t<CellSyncLFQueue> queue, s32& pointer, u32 isBlocking, u32 useEventQueue);
s32 syncLFQueueCompletePopPointer(mem_ptr_t<CellSyncLFQueue> queue, s32 pointer, const std::function<s32(u32 addr, u32 arg)> fpSendSignal, u32 noQueueFull);
s32 syncLFQueueCompletePopPointer2(mem_ptr_t<CellSyncLFQueue> queue, s32 pointer, const std::function<s32(u32 addr, u32 arg)> fpSendSignal, u32 noQueueFull);
s32 syncLFQueueAttachLv2EventQueue(mem32_ptr_t spus, u32 num, mem_ptr_t<CellSyncLFQueue> queue);
s32 syncLFQueueDetachLv2EventQueue(mem32_ptr_t spus, u32 num, mem_ptr_t<CellSyncLFQueue> queue);
s32 syncLFQueueInitialize(vm::ptr<CellSyncLFQueue> queue, u32 buffer_addr, u32 size, u32 depth, CellSyncQueueDirection direction, u32 eaSignal_addr);
s32 syncLFQueueGetPushPointer(vm::ptr<CellSyncLFQueue> queue, s32& pointer, u32 isBlocking, u32 useEventQueue);
s32 syncLFQueueGetPushPointer2(vm::ptr<CellSyncLFQueue> queue, s32& pointer, u32 isBlocking, u32 useEventQueue);
s32 syncLFQueueCompletePushPointer(vm::ptr<CellSyncLFQueue> queue, s32 pointer, const std::function<s32(u32 addr, u32 arg)> fpSendSignal);
s32 syncLFQueueCompletePushPointer2(vm::ptr<CellSyncLFQueue> queue, s32 pointer, const std::function<s32(u32 addr, u32 arg)> fpSendSignal);
s32 syncLFQueueGetPopPointer(vm::ptr<CellSyncLFQueue> queue, s32& pointer, u32 isBlocking, u32, u32 useEventQueue);
s32 syncLFQueueGetPopPointer2(vm::ptr<CellSyncLFQueue> queue, s32& pointer, u32 isBlocking, u32 useEventQueue);
s32 syncLFQueueCompletePopPointer(vm::ptr<CellSyncLFQueue> queue, s32 pointer, const std::function<s32(u32 addr, u32 arg)> fpSendSignal, u32 noQueueFull);
s32 syncLFQueueCompletePopPointer2(vm::ptr<CellSyncLFQueue> queue, s32 pointer, const std::function<s32(u32 addr, u32 arg)> fpSendSignal, u32 noQueueFull);
s32 syncLFQueueAttachLv2EventQueue(vm::ptr<be_t<u32>> spus, u32 num, vm::ptr<CellSyncLFQueue> queue);
s32 syncLFQueueDetachLv2EventQueue(vm::ptr<be_t<u32>> spus, u32 num, vm::ptr<CellSyncLFQueue> queue);

View file

@ -15,7 +15,7 @@ u32 libsync2;
u32 libsync2_rtoc;
#endif
int _cellSync2MutexAttributeInitialize()
s64 _cellSync2MutexAttributeInitialize()
{
#ifdef PRX_DEBUG
cellSync2->Warning("%s()", __FUNCTION__);
@ -26,7 +26,7 @@ int _cellSync2MutexAttributeInitialize()
#endif
}
int cellSync2MutexEstimateBufferSize()
s64 cellSync2MutexEstimateBufferSize()
{
#ifdef PRX_DEBUG
cellSync2->Warning("%s()", __FUNCTION__);
@ -37,7 +37,7 @@ int cellSync2MutexEstimateBufferSize()
#endif
}
int cellSync2MutexInitialize()
s64 cellSync2MutexInitialize()
{
#ifdef PRX_DEBUG
cellSync2->Warning("%s()", __FUNCTION__);
@ -48,7 +48,7 @@ int cellSync2MutexInitialize()
#endif
}
int cellSync2MutexFinalize()
s64 cellSync2MutexFinalize()
{
#ifdef PRX_DEBUG
cellSync2->Warning("%s()", __FUNCTION__);
@ -59,7 +59,7 @@ int cellSync2MutexFinalize()
#endif
}
int cellSync2MutexLock()
s64 cellSync2MutexLock()
{
#ifdef PRX_DEBUG
cellSync2->Warning("%s()", __FUNCTION__);
@ -70,7 +70,7 @@ int cellSync2MutexLock()
#endif
}
int cellSync2MutexTryLock()
s64 cellSync2MutexTryLock()
{
#ifdef PRX_DEBUG
cellSync2->Warning("%s()", __FUNCTION__);
@ -81,7 +81,7 @@ int cellSync2MutexTryLock()
#endif
}
int cellSync2MutexUnlock()
s64 cellSync2MutexUnlock()
{
#ifdef PRX_DEBUG
cellSync2->Warning("%s()", __FUNCTION__);
@ -92,7 +92,7 @@ int cellSync2MutexUnlock()
#endif
}
int _cellSync2CondAttributeInitialize()
s64 _cellSync2CondAttributeInitialize()
{
#ifdef PRX_DEBUG
cellSync2->Warning("%s()", __FUNCTION__);
@ -103,7 +103,7 @@ int _cellSync2CondAttributeInitialize()
#endif
}
int cellSync2CondEstimateBufferSize()
s64 cellSync2CondEstimateBufferSize()
{
#ifdef PRX_DEBUG
cellSync2->Warning("%s()", __FUNCTION__);
@ -114,7 +114,7 @@ int cellSync2CondEstimateBufferSize()
#endif
}
int cellSync2CondInitialize()
s64 cellSync2CondInitialize()
{
#ifdef PRX_DEBUG
cellSync2->Warning("%s()", __FUNCTION__);
@ -125,7 +125,7 @@ int cellSync2CondInitialize()
#endif
}
int cellSync2CondFinalize()
s64 cellSync2CondFinalize()
{
#ifdef PRX_DEBUG
cellSync2->Warning("%s()", __FUNCTION__);
@ -136,7 +136,7 @@ int cellSync2CondFinalize()
#endif
}
int cellSync2CondWait()
s64 cellSync2CondWait()
{
#ifdef PRX_DEBUG
cellSync2->Warning("%s()", __FUNCTION__);
@ -147,7 +147,7 @@ int cellSync2CondWait()
#endif
}
int cellSync2CondSignal()
s64 cellSync2CondSignal()
{
#ifdef PRX_DEBUG
cellSync2->Warning("%s()", __FUNCTION__);
@ -158,7 +158,7 @@ int cellSync2CondSignal()
#endif
}
int cellSync2CondSignalAll()
s64 cellSync2CondSignalAll()
{
#ifdef PRX_DEBUG
cellSync2->Warning("%s()", __FUNCTION__);
@ -169,7 +169,7 @@ int cellSync2CondSignalAll()
#endif
}
int _cellSync2SemaphoreAttributeInitialize()
s64 _cellSync2SemaphoreAttributeInitialize()
{
#ifdef PRX_DEBUG
cellSync2->Warning("%s()", __FUNCTION__);
@ -180,7 +180,7 @@ int _cellSync2SemaphoreAttributeInitialize()
#endif
}
int cellSync2SemaphoreEstimateBufferSize()
s64 cellSync2SemaphoreEstimateBufferSize()
{
#ifdef PRX_DEBUG
cellSync2->Warning("%s()", __FUNCTION__);
@ -191,7 +191,7 @@ int cellSync2SemaphoreEstimateBufferSize()
#endif
}
int cellSync2SemaphoreInitialize()
s64 cellSync2SemaphoreInitialize()
{
#ifdef PRX_DEBUG
cellSync2->Warning("%s()", __FUNCTION__);
@ -202,7 +202,7 @@ int cellSync2SemaphoreInitialize()
#endif
}
int cellSync2SemaphoreFinalize()
s64 cellSync2SemaphoreFinalize()
{
#ifdef PRX_DEBUG
cellSync2->Warning("%s()", __FUNCTION__);
@ -213,7 +213,7 @@ int cellSync2SemaphoreFinalize()
#endif
}
int cellSync2SemaphoreAcquire()
s64 cellSync2SemaphoreAcquire()
{
#ifdef PRX_DEBUG
cellSync2->Warning("%s()", __FUNCTION__);
@ -224,7 +224,7 @@ int cellSync2SemaphoreAcquire()
#endif
}
int cellSync2SemaphoreTryAcquire()
s64 cellSync2SemaphoreTryAcquire()
{
#ifdef PRX_DEBUG
cellSync2->Warning("%s()", __FUNCTION__);
@ -235,7 +235,7 @@ int cellSync2SemaphoreTryAcquire()
#endif
}
int cellSync2SemaphoreRelease()
s64 cellSync2SemaphoreRelease()
{
#ifdef PRX_DEBUG
cellSync2->Warning("%s()", __FUNCTION__);
@ -246,7 +246,7 @@ int cellSync2SemaphoreRelease()
#endif
}
int cellSync2SemaphoreGetCount()
s64 cellSync2SemaphoreGetCount()
{
#ifdef PRX_DEBUG
cellSync2->Warning("%s()", __FUNCTION__);
@ -257,7 +257,7 @@ int cellSync2SemaphoreGetCount()
#endif
}
int _cellSync2QueueAttributeInitialize()
s64 _cellSync2QueueAttributeInitialize()
{
#ifdef PRX_DEBUG
cellSync2->Warning("%s()", __FUNCTION__);
@ -268,7 +268,7 @@ int _cellSync2QueueAttributeInitialize()
#endif
}
int cellSync2QueueEstimateBufferSize()
s64 cellSync2QueueEstimateBufferSize()
{
#ifdef PRX_DEBUG
cellSync2->Warning("%s()", __FUNCTION__);
@ -279,7 +279,7 @@ int cellSync2QueueEstimateBufferSize()
#endif
}
int cellSync2QueueInitialize()
s64 cellSync2QueueInitialize()
{
#ifdef PRX_DEBUG
cellSync2->Warning("%s()", __FUNCTION__);
@ -290,7 +290,7 @@ int cellSync2QueueInitialize()
#endif
}
int cellSync2QueueFinalize()
s64 cellSync2QueueFinalize()
{
#ifdef PRX_DEBUG
cellSync2->Warning("%s()", __FUNCTION__);
@ -301,7 +301,7 @@ int cellSync2QueueFinalize()
#endif
}
int cellSync2QueuePush()
s64 cellSync2QueuePush()
{
#ifdef PRX_DEBUG
cellSync2->Warning("%s()", __FUNCTION__);
@ -312,7 +312,7 @@ int cellSync2QueuePush()
#endif
}
int cellSync2QueueTryPush()
s64 cellSync2QueueTryPush()
{
#ifdef PRX_DEBUG
cellSync2->Warning("%s()", __FUNCTION__);
@ -323,7 +323,7 @@ int cellSync2QueueTryPush()
#endif
}
int cellSync2QueuePop()
s64 cellSync2QueuePop()
{
#ifdef PRX_DEBUG
cellSync2->Warning("%s()", __FUNCTION__);
@ -334,7 +334,7 @@ int cellSync2QueuePop()
#endif
}
int cellSync2QueueTryPop()
s64 cellSync2QueueTryPop()
{
#ifdef PRX_DEBUG
cellSync2->Warning("%s()", __FUNCTION__);
@ -345,7 +345,7 @@ int cellSync2QueueTryPop()
#endif
}
int cellSync2QueueGetSize()
s64 cellSync2QueueGetSize()
{
#ifdef PRX_DEBUG
cellSync2->Warning("%s()", __FUNCTION__);
@ -356,7 +356,7 @@ int cellSync2QueueGetSize()
#endif
}
int cellSync2QueueGetDepth()
s64 cellSync2QueueGetDepth()
{
#ifdef PRX_DEBUG
cellSync2->Warning("%s()", __FUNCTION__);
@ -408,7 +408,7 @@ void cellSync2_init()
#ifdef PRX_DEBUG
CallAfter([]()
{
libsync2 = Memory.PRXMem.AllocAlign(sizeof(libsync2_data), 4096);
libsync2 = (u32)Memory.PRXMem.AllocAlign(sizeof(libsync2_data), 4096);
memcpy(Memory + libsync2, libsync2_data, sizeof(libsync2_data));
libsync2_rtoc = libsync2 + 0xF280;

View file

@ -17,92 +17,92 @@
#include "cellSysutil.h"
#include "cellSysutil_SaveData.h"
typedef void (*CellHddGameStatCallback)(mem_ptr_t<CellHddGameCBResult> cbResult, mem_ptr_t<CellHddGameStatGet> get, mem_ptr_t<CellHddGameStatSet> set);
typedef void (*CellHddGameStatCallback)(vm::ptr<CellHddGameCBResult> cbResult, vm::ptr<CellHddGameStatGet> get, vm::ptr<CellHddGameStatSet> set);
//void cellSysutil_init();
//Module cellSysutil(0x0015, cellSysutil_init);
Module *cellSysutil = nullptr;
int cellSysutilGetSystemParamInt(int id, mem32_t value)
int cellSysutilGetSystemParamInt(int id, vm::ptr<be_t<u32>> value)
{
cellSysutil->Log("cellSysutilGetSystemParamInt(id=0x%x, value_addr=0x%x)", id, value.GetAddr());
cellSysutil->Log("cellSysutilGetSystemParamInt(id=0x%x, value_addr=0x%x)", id, value.addr());
switch(id)
{
case CELL_SYSUTIL_SYSTEMPARAM_ID_LANG:
cellSysutil->Warning("cellSysutilGetSystemParamInt: CELL_SYSUTIL_SYSTEMPARAM_ID_LANG");
value = Ini.SysLanguage.GetValue();
*value = Ini.SysLanguage.GetValue();
break;
case CELL_SYSUTIL_SYSTEMPARAM_ID_ENTER_BUTTON_ASSIGN:
cellSysutil->Warning("cellSysutilGetSystemParamInt: CELL_SYSUTIL_SYSTEMPARAM_ID_ENTER_BUTTON_ASSIGN");
value = CELL_SYSUTIL_ENTER_BUTTON_ASSIGN_CROSS;
*value = CELL_SYSUTIL_ENTER_BUTTON_ASSIGN_CROSS;
break;
case CELL_SYSUTIL_SYSTEMPARAM_ID_DATE_FORMAT:
cellSysutil->Warning("cellSysutilGetSystemParamInt: CELL_SYSUTIL_SYSTEMPARAM_ID_DATE_FORMAT");
value = CELL_SYSUTIL_DATE_FMT_DDMMYYYY;
*value = CELL_SYSUTIL_DATE_FMT_DDMMYYYY;
break;
case CELL_SYSUTIL_SYSTEMPARAM_ID_TIME_FORMAT:
cellSysutil->Warning("cellSysutilGetSystemParamInt: CELL_SYSUTIL_SYSTEMPARAM_ID_TIME_FORMAT");
value = CELL_SYSUTIL_TIME_FMT_CLOCK24;
*value = CELL_SYSUTIL_TIME_FMT_CLOCK24;
break;
case CELL_SYSUTIL_SYSTEMPARAM_ID_TIMEZONE:
cellSysutil->Warning("cellSysutilGetSystemParamInt: CELL_SYSUTIL_SYSTEMPARAM_ID_TIMEZONE");
value = 3;
*value = 3;
break;
case CELL_SYSUTIL_SYSTEMPARAM_ID_SUMMERTIME:
cellSysutil->Warning("cellSysutilGetSystemParamInt: CELL_SYSUTIL_SYSTEMPARAM_ID_SUMMERTIME");
value = 1;
*value = 1;
break;
case CELL_SYSUTIL_SYSTEMPARAM_ID_GAME_PARENTAL_LEVEL:
cellSysutil->Warning("cellSysutilGetSystemParamInt: CELL_SYSUTIL_SYSTEMPARAM_ID_GAME_PARENTAL_LEVEL");
value = CELL_SYSUTIL_GAME_PARENTAL_OFF;
*value = CELL_SYSUTIL_GAME_PARENTAL_OFF;
break;
case CELL_SYSUTIL_SYSTEMPARAM_ID_GAME_PARENTAL_LEVEL0_RESTRICT:
cellSysutil->Warning("cellSysutilGetSystemParamInt: CELL_SYSUTIL_SYSTEMPARAM_ID_GAME_PARENTAL_LEVEL0_RESTRICT");
value = CELL_SYSUTIL_GAME_PARENTAL_LEVEL0_RESTRICT_OFF;
*value = CELL_SYSUTIL_GAME_PARENTAL_LEVEL0_RESTRICT_OFF;
break;
case CELL_SYSUTIL_SYSTEMPARAM_ID_CURRENT_USER_HAS_NP_ACCOUNT:
cellSysutil->Warning("cellSysutilGetSystemParamInt: CELL_SYSUTIL_SYSTEMPARAM_ID_CURRENT_USER_HAS_NP_ACCOUNT");
value = 0;
*value = 0;
break;
case CELL_SYSUTIL_SYSTEMPARAM_ID_CAMERA_PLFREQ:
cellSysutil->Warning("cellSysutilGetSystemParamInt: CELL_SYSUTIL_SYSTEMPARAM_ID_CAMERA_PLFREQ");
value = CELL_SYSUTIL_CAMERA_PLFREQ_DISABLED;
*value = CELL_SYSUTIL_CAMERA_PLFREQ_DISABLED;
break;
case CELL_SYSUTIL_SYSTEMPARAM_ID_PAD_RUMBLE:
cellSysutil->Warning("cellSysutilGetSystemParamInt: CELL_SYSUTIL_SYSTEMPARAM_ID_PAD_RUMBLE");
value = CELL_SYSUTIL_PAD_RUMBLE_OFF;
*value = CELL_SYSUTIL_PAD_RUMBLE_OFF;
break;
case CELL_SYSUTIL_SYSTEMPARAM_ID_KEYBOARD_TYPE:
cellSysutil->Warning("cellSysutilGetSystemParamInt: CELL_SYSUTIL_SYSTEMPARAM_ID_KEYBOARD_TYPE");
value = 0;
*value = 0;
break;
case CELL_SYSUTIL_SYSTEMPARAM_ID_JAPANESE_KEYBOARD_ENTRY_METHOD:
cellSysutil->Warning("cellSysutilGetSystemParamInt: CELL_SYSUTIL_SYSTEMPARAM_ID_JAPANESE_KEYBOARD_ENTRY_METHOD");
value = 0;
*value = 0;
break;
case CELL_SYSUTIL_SYSTEMPARAM_ID_CHINESE_KEYBOARD_ENTRY_METHOD:
cellSysutil->Warning("cellSysutilGetSystemParamInt: CELL_SYSUTIL_SYSTEMPARAM_ID_CHINESE_KEYBOARD_ENTRY_METHOD");
value = 0;
*value = 0;
break;
case CELL_SYSUTIL_SYSTEMPARAM_ID_PAD_AUTOOFF:
cellSysutil->Warning("cellSysutilGetSystemParamInt: CELL_SYSUTIL_SYSTEMPARAM_ID_PAD_AUTOOFF");
value = 0;
*value = 0;
break;
default:
@ -112,22 +112,22 @@ int cellSysutilGetSystemParamInt(int id, mem32_t value)
return CELL_OK;
}
int cellSysutilGetSystemParamString(s32 id, mem_list_ptr_t<u8> buf, u32 bufsize)
int cellSysutilGetSystemParamString(s32 id, vm::ptr<char> buf, u32 bufsize)
{
cellSysutil->Log("cellSysutilGetSystemParamString(id=%d, buf_addr=0x%x, bufsize=%d)", id, buf.GetAddr(), bufsize);
cellSysutil->Log("cellSysutilGetSystemParamString(id=%d, buf_addr=0x%x, bufsize=%d)", id, buf.addr(), bufsize);
memset(buf, 0, bufsize);
memset(buf.get_ptr(), 0, bufsize);
switch(id)
{
case CELL_SYSUTIL_SYSTEMPARAM_ID_NICKNAME:
cellSysutil->Warning("cellSysutilGetSystemParamString: CELL_SYSUTIL_SYSTEMPARAM_ID_NICKNAME");
memcpy(buf, "Unknown", 8); //for example
memcpy(buf.get_ptr(), "Unknown", 8); // for example
break;
case CELL_SYSUTIL_SYSTEMPARAM_ID_CURRENT_USERNAME:
cellSysutil->Warning("cellSysutilGetSystemParamString: CELL_SYSUTIL_SYSTEMPARAM_ID_CURRENT_USERNAME");
memcpy(buf, "Unknown", 8);
memcpy(buf.get_ptr(), "Unknown", 8);
break;
default:
@ -174,10 +174,10 @@ int cellVideoOutGetState(u32 videoOut, u32 deviceIndex, u32 state_addr)
return CELL_VIDEO_OUT_ERROR_UNSUPPORTED_VIDEO_OUT;
}
int cellVideoOutGetResolution(u32 resolutionId, mem_ptr_t<CellVideoOutResolution> resolution)
int cellVideoOutGetResolution(u32 resolutionId, vm::ptr<CellVideoOutResolution> resolution)
{
cellSysutil->Log("cellVideoOutGetResolution(resolutionId=%d, resolution_addr=0x%x)",
resolutionId, resolution.GetAddr());
resolutionId, resolution.addr());
u32 num = ResolutionIdToNum(resolutionId);
if(!num)
@ -253,10 +253,10 @@ int cellVideoOutGetConfiguration(u32 videoOut, u32 config_addr, u32 option_addr)
return CELL_VIDEO_OUT_ERROR_UNSUPPORTED_VIDEO_OUT;
}
int cellVideoOutGetDeviceInfo(u32 videoOut, u32 deviceIndex, mem_ptr_t<CellVideoOutDeviceInfo> info)
int cellVideoOutGetDeviceInfo(u32 videoOut, u32 deviceIndex, vm::ptr<CellVideoOutDeviceInfo> info)
{
cellSysutil->Warning("cellVideoOutGetDeviceInfo(videoOut=%u, deviceIndex=%u, info_addr=0x%x)",
videoOut, deviceIndex, info.GetAddr());
videoOut, deviceIndex, info.addr());
if(deviceIndex) return CELL_VIDEO_OUT_ERROR_DEVICE_NOT_FOUND;
@ -482,10 +482,10 @@ int cellAudioOutGetState(u32 audioOut, u32 deviceIndex, u32 state_addr)
return CELL_AUDIO_OUT_ERROR_UNSUPPORTED_AUDIO_OUT;
}
int cellAudioOutConfigure(u32 audioOut, mem_ptr_t<CellAudioOutConfiguration> config, mem_ptr_t<CellAudioOutOption> option, u32 waitForEvent)
int cellAudioOutConfigure(u32 audioOut, vm::ptr<CellAudioOutConfiguration> config, vm::ptr<CellAudioOutOption> option, u32 waitForEvent)
{
cellSysutil->Warning("cellAudioOutConfigure(audioOut=%d, config_addr=0x%x, option_addr=0x%x, (!)waitForEvent=%d)",
audioOut, config.GetAddr(), option.GetAddr(), waitForEvent);
audioOut, config.addr(), option.addr(), waitForEvent);
switch(audioOut)
{
@ -551,10 +551,10 @@ int cellAudioOutGetNumberOfDevice(u32 audioOut)
return CELL_AUDIO_OUT_ERROR_UNSUPPORTED_AUDIO_OUT;
}
int cellAudioOutGetDeviceInfo(u32 audioOut, u32 deviceIndex, mem_ptr_t<CellAudioOutDeviceInfo> info)
int cellAudioOutGetDeviceInfo(u32 audioOut, u32 deviceIndex, vm::ptr<CellAudioOutDeviceInfo> info)
{
cellSysutil->Todo("cellAudioOutGetDeviceInfo(audioOut=%u, deviceIndex=%u, info_addr=0x%x)",
audioOut, deviceIndex, info.GetAddr());
audioOut, deviceIndex, info.addr());
if(deviceIndex) return CELL_AUDIO_OUT_ERROR_DEVICE_NOT_FOUND;
@ -602,7 +602,7 @@ int cellAudioOutSetCopyControl(u32 audioOut, u32 control)
typedef struct{
char cacheId[CELL_SYSCACHE_ID_SIZE];
char getCachePath[CELL_SYSCACHE_PATH_MAX];
mem_ptr_t<void> reserved;
vm::ptr<void> reserved;
} CellSysCacheParam;
@ -658,9 +658,9 @@ int cellSysCacheClear(void)
return CELL_SYSCACHE_RET_OK_CLEARED;
}
int cellSysCacheMount(mem_ptr_t<CellSysCacheParam> param)
int cellSysCacheMount(vm::ptr<CellSysCacheParam> param)
{
cellSysutil->Warning("cellSysCacheMount(param_addr=0x%x)", param.GetAddr());
cellSysutil->Warning("cellSysCacheMount(param_addr=0x%x)", param.addr());
//TODO: implement
char id[CELL_SYSCACHE_ID_SIZE];
@ -672,19 +672,19 @@ int cellSysCacheMount(mem_ptr_t<CellSysCacheParam> param)
return CELL_SYSCACHE_RET_OK_RELAYED;
}
int cellHddGameCheck(u32 version, u32 dirName_addr, u32 errDialog, mem_func_ptr_t<CellHddGameStatCallback> funcStat, u32 container)
int cellHddGameCheck(u32 version, u32 dirName_addr, u32 errDialog, vm::ptr<CellHddGameStatCallback> funcStat, u32 container)
{
cellSysutil->Warning("cellHddGameCheck(version=%d, dirName_addr=0x%xx, errDialog=%d, funcStat_addr=0x%x, container=%d)",
version, dirName_addr, errDialog, funcStat, container);
version, dirName_addr, errDialog, funcStat.addr(), container);
std::string dirName = Memory.ReadString(dirName_addr);
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, get, set);
if (result->result != CELL_HDDGAME_CBRESULT_OK &&
result->result != CELL_HDDGAME_CBRESULT_OK_CANCEL)
return CELL_HDDGAME_ERROR_CBRESULT;
@ -752,9 +752,9 @@ int cellSysutilEnableBgmPlayback()
return CELL_OK;
}
int cellSysutilEnableBgmPlaybackEx(mem_ptr_t<CellSysutilBgmPlaybackExtraParam> param)
int cellSysutilEnableBgmPlaybackEx(vm::ptr<CellSysutilBgmPlaybackExtraParam> param)
{
cellSysutil->Warning("cellSysutilEnableBgmPlaybackEx(param_addr=0x%x)", param.GetAddr());
cellSysutil->Warning("cellSysutilEnableBgmPlaybackEx(param_addr=0x%x)", param.addr());
// TODO
bgm_playback_enabled = true;
@ -772,9 +772,9 @@ int cellSysutilDisableBgmPlayback()
return CELL_OK;
}
int cellSysutilDisableBgmPlaybackEx(mem_ptr_t<CellSysutilBgmPlaybackExtraParam> param)
int cellSysutilDisableBgmPlaybackEx(vm::ptr<CellSysutilBgmPlaybackExtraParam> param)
{
cellSysutil->Warning("cellSysutilDisableBgmPlaybackEx(param_addr=0x%x)", param.GetAddr());
cellSysutil->Warning("cellSysutilDisableBgmPlaybackEx(param_addr=0x%x)", param.addr());
// TODO
bgm_playback_enabled = false;
@ -782,9 +782,9 @@ int cellSysutilDisableBgmPlaybackEx(mem_ptr_t<CellSysutilBgmPlaybackExtraParam>
return CELL_OK;
}
int cellSysutilGetBgmPlaybackStatus(mem_ptr_t<CellSysutilBgmPlaybackStatus> status)
int cellSysutilGetBgmPlaybackStatus(vm::ptr<CellSysutilBgmPlaybackStatus> status)
{
cellSysutil->Log("cellSysutilGetBgmPlaybackStatus(status_addr=0x%x)", status.GetAddr());
cellSysutil->Log("cellSysutilGetBgmPlaybackStatus(status_addr=0x%x)", status.addr());
// TODO
status->playerState = CELL_SYSUTIL_BGMPLAYBACK_STATUS_STOP;
@ -796,9 +796,9 @@ int cellSysutilGetBgmPlaybackStatus(mem_ptr_t<CellSysutilBgmPlaybackStatus> stat
return CELL_OK;
}
int cellSysutilGetBgmPlaybackStatus2(mem_ptr_t<CellSysutilBgmPlaybackStatus2> status2)
int cellSysutilGetBgmPlaybackStatus2(vm::ptr<CellSysutilBgmPlaybackStatus2> status2)
{
cellSysutil->Log("cellSysutilGetBgmPlaybackStatus2(status2_addr=0x%x)", status2.GetAddr());
cellSysutil->Log("cellSysutilGetBgmPlaybackStatus2(status2_addr=0x%x)", status2.addr());
// TODO
status2->playerState = CELL_SYSUTIL_BGMPLAYBACK_STATUS_STOP;
@ -807,9 +807,9 @@ int cellSysutilGetBgmPlaybackStatus2(mem_ptr_t<CellSysutilBgmPlaybackStatus2> st
return CELL_OK;
}
int cellWebBrowserEstimate2(mem8_ptr_t _config, mem32_ptr_t memSize)
int cellWebBrowserEstimate2(const vm::ptr<const u8> _config, vm::ptr<be_t<u32>> memSize)
{
cellSysutil->Warning("cellWebBrowserEstimate2(config_addr=0x%x, memSize_addr=0x%x)", _config.GetAddr(), memSize.GetAddr());
cellSysutil->Warning("cellWebBrowserEstimate2(config_addr=0x%x, memSize_addr=0x%x)", _config.addr(), memSize.addr());
// TODO: When cellWebBrowser stuff is implemented, change this to some real
// needed memory buffer size.
@ -817,11 +817,11 @@ int cellWebBrowserEstimate2(mem8_ptr_t _config, mem32_ptr_t memSize)
return CELL_OK;
}
extern int cellGameDataCheckCreate2(u32 version, const mem_list_ptr_t<u8> dirName, u32 errDialog,
mem_func_ptr_t<void(*)(mem_ptr_t<CellGameDataCBResult> cbResult, mem_ptr_t<CellGameDataStatGet> get, mem_ptr_t<CellGameDataStatSet> set)> funcStat, u32 container);
extern int cellGameDataCheckCreate2(u32 version, vm::ptr<const char> dirName, u32 errDialog,
vm::ptr<void(*)(vm::ptr<CellGameDataCBResult> cbResult, vm::ptr<CellGameDataStatGet> get, vm::ptr<CellGameDataStatSet> set)> funcStat, u32 container);
extern int cellGameDataCheckCreate(u32 version, const mem_list_ptr_t<u8> dirName, u32 errDialog,
mem_func_ptr_t<void(*)(mem_ptr_t<CellGameDataCBResult> cbResult, mem_ptr_t<CellGameDataStatGet> get, mem_ptr_t<CellGameDataStatSet> set)> funcStat, u32 container);
extern int cellGameDataCheckCreate(u32 version, vm::ptr<const char> dirName, u32 errDialog,
vm::ptr<void(*)(vm::ptr<CellGameDataCBResult> cbResult, vm::ptr<CellGameDataStatGet> get, vm::ptr<CellGameDataStatSet> set)> funcStat, u32 container);
void cellSysutil_init()
{

View file

@ -202,7 +202,7 @@ struct CellHddGameStatGet
struct CellHddGameStatSet
{
mem_beptr_t<CellHddGameSystemFileParam> setParam;
vm::bptr<CellHddGameSystemFileParam> setParam;
be_t<u32> reserved_addr; // void*
};

View file

@ -74,7 +74,7 @@ void addSaveDataEntry(std::vector<SaveDataEntry>& saveEntries, const std::string
saveEntry.title = psf.GetString("TITLE");
saveEntry.subtitle = psf.GetString("SUB_TITLE");
saveEntry.details = psf.GetString("DETAIL");
saveEntry.sizeKB = getSaveDataSize(saveDir)/1024;
saveEntry.sizeKB = (u32)(getSaveDataSize(saveDir) / 1024);
saveEntry.st_atime_ = 0; // TODO
saveEntry.st_mtime_ = 0; // TODO
saveEntry.st_ctime_ = 0; // TODO
@ -85,7 +85,7 @@ void addSaveDataEntry(std::vector<SaveDataEntry>& saveEntries, const std::string
saveEntries.push_back(saveEntry);
}
void addNewSaveDataEntry(std::vector<SaveDataEntry>& saveEntries, mem_ptr_t<CellSaveDataListNewData> newData)
void addNewSaveDataEntry(std::vector<SaveDataEntry>& saveEntries, vm::ptr<CellSaveDataListNewData> newData)
{
SaveDataEntry saveEntry;
saveEntry.dirName = (char*)Memory.VirtualToRealAddr(newData->dirName_addr);
@ -105,7 +105,7 @@ u32 focusSaveDataEntry(const std::vector<SaveDataEntry>& saveEntries, u32 focusP
return 0;
}
void setSaveDataList(std::vector<SaveDataEntry>& saveEntries, mem_ptr_t<CellSaveDataDirList> fixedList, u32 fixedListNum)
void setSaveDataList(std::vector<SaveDataEntry>& saveEntries, vm::ptr<CellSaveDataDirList> fixedList, u32 fixedListNum)
{
std::vector<SaveDataEntry>::iterator entry = saveEntries.begin();
while (entry != saveEntries.end())
@ -126,7 +126,7 @@ void setSaveDataList(std::vector<SaveDataEntry>& saveEntries, mem_ptr_t<CellSave
}
}
void setSaveDataFixed(std::vector<SaveDataEntry>& saveEntries, mem_ptr_t<CellSaveDataFixedSet> fixedSet)
void setSaveDataFixed(std::vector<SaveDataEntry>& saveEntries, vm::ptr<CellSaveDataFixedSet> fixedSet)
{
std::vector<SaveDataEntry>::iterator entry = saveEntries.begin();
while (entry != saveEntries.end())
@ -145,7 +145,7 @@ void setSaveDataFixed(std::vector<SaveDataEntry>& saveEntries, mem_ptr_t<CellSav
saveEntries.push_back(entry);
}
if (fixedSet->newIcon.GetAddr())
if (fixedSet->newIcon)
{
saveEntries[0].iconBuf = Memory.VirtualToRealAddr(fixedSet->newIcon->iconBuf_addr);
saveEntries[0].iconBufSize = fixedSet->newIcon->iconBufSize;
@ -154,7 +154,7 @@ void setSaveDataFixed(std::vector<SaveDataEntry>& saveEntries, mem_ptr_t<CellSav
}
}
void getSaveDataStat(SaveDataEntry entry, mem_ptr_t<CellSaveDataStatGet> statGet)
void getSaveDataStat(SaveDataEntry entry, vm::ptr<CellSaveDataStatGet> statGet)
{
if (entry.isNew)
statGet->isNewData = CELL_SAVEDATA_ISNEWDATA_YES;
@ -177,7 +177,7 @@ void getSaveDataStat(SaveDataEntry entry, mem_ptr_t<CellSaveDataStatGet> statGet
memcpy(statGet->getParam.listParam, entry.listParam.c_str(), CELL_SAVEDATA_SYSP_LPARAM_SIZE);
statGet->fileNum = 0;
statGet->fileList.SetAddr(be_t<u32>::MakeFromBE(0));
statGet->fileList = vm::bptr<CellSaveDataFileStat>::make(0);
statGet->fileListNum = 0;
std::string saveDir = "/dev_hdd0/home/00000001/savedata/" + entry.dirName; // TODO: Get the path of the current user
vfsDir dir(saveDir);
@ -209,15 +209,15 @@ void getSaveDataStat(SaveDataEntry entry, mem_ptr_t<CellSaveDataStatGet> statGet
}
}
statGet->fileList.SetAddr(be_t<u32>::MakeFromLE(Memory.Alloc(sizeof(CellSaveDataFileStat)* fileEntries.size(), sizeof(CellSaveDataFileStat))));
statGet->fileList = vm::bptr<CellSaveDataFileStat>::make(be_t<u32>::MakeFromLE((u32)Memory.Alloc(sizeof(CellSaveDataFileStat) * (u32)fileEntries.size(), sizeof(CellSaveDataFileStat))));
for (u32 i=0; i<fileEntries.size(); i++)
memcpy(&statGet->fileList[i], &fileEntries[i], sizeof(CellSaveDataFileStat));
}
s32 modifySaveDataFiles(mem_func_ptr_t<CellSaveDataFileCallback>& funcFile, mem_ptr_t<CellSaveDataCBResult> result, const std::string& saveDataDir)
s32 modifySaveDataFiles(vm::ptr<CellSaveDataFileCallback> funcFile, vm::ptr<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, fileGet, fileSet);
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;
@ -256,13 +256,13 @@ s32 modifySaveDataFiles(mem_func_ptr_t<CellSaveDataFileCallback>& funcFile, mem_
{
case CELL_SAVEDATA_FILEOP_READ:
file = Emu.GetVFS().OpenFile(filepath, vfsRead);
fileGet->excSize = file->Read(buf, std::min(fileSet->fileSize, fileSet->fileBufSize)); // TODO: This may fail for big files because of the dest pointer.
fileGet->excSize = (u32)file->Read(buf, (u32)std::min(fileSet->fileSize, fileSet->fileBufSize)); // TODO: This may fail for big files because of the dest pointer.
break;
case CELL_SAVEDATA_FILEOP_WRITE:
Emu.GetVFS().CreateFile(filepath);
file = Emu.GetVFS().OpenFile(filepath, vfsWrite);
fileGet->excSize = file->Write(buf, std::min(fileSet->fileSize, fileSet->fileBufSize)); // TODO: This may fail for big files because of the dest pointer.
fileGet->excSize = (u32)file->Write(buf, (u32)std::min(fileSet->fileSize, fileSet->fileBufSize)); // TODO: This may fail for big files because of the dest pointer.
break;
case CELL_SAVEDATA_FILEOP_DELETE:
@ -287,18 +287,18 @@ s32 modifySaveDataFiles(mem_func_ptr_t<CellSaveDataFileCallback>& funcFile, mem_
// Functions
int cellSaveDataListSave2(u32 version, mem_ptr_t<CellSaveDataSetList> setList, mem_ptr_t<CellSaveDataSetBuf> setBuf,
mem_func_ptr_t<CellSaveDataListCallback> funcList, mem_func_ptr_t<CellSaveDataStatCallback> funcStat, mem_func_ptr_t<CellSaveDataFileCallback> funcFile,
int cellSaveDataListSave2(u32 version, vm::ptr<CellSaveDataSetList> setList, vm::ptr<CellSaveDataSetBuf> setBuf,
vm::ptr<CellSaveDataListCallback> funcList, vm::ptr<CellSaveDataStatCallback> funcStat, vm::ptr<CellSaveDataFileCallback> funcFile,
u32 container, u32 userdata_addr)
{
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);
version, setList.addr(), setBuf.addr(), funcList.addr(), funcStat.addr(), funcFile.addr(), 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);
@ -325,24 +325,24 @@ int cellSaveDataListSave2(u32 version, mem_ptr_t<CellSaveDataSetList> setList, m
// Sort the entries and fill the listGet->dirList array
std::sort(saveEntries.begin(), saveEntries.end(), sortSaveDataEntry(setList->sortType, setList->sortOrder));
listGet->dirList.SetAddr(setBuf->buf_addr);
CellSaveDataDirList* dirList = (CellSaveDataDirList*)Memory.VirtualToRealAddr(listGet->dirList.GetAddr());
listGet->dirList = vm::bptr<CellSaveDataDirList>::make(setBuf->buf_addr);
CellSaveDataDirList* dirList = (CellSaveDataDirList*)Memory.VirtualToRealAddr(listGet->dirList.addr());
for (u32 i=0; i<saveEntries.size(); i++) {
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);
}
funcList(result.GetAddr(), listGet.GetAddr(), listSet.GetAddr());
funcList(result, listGet, listSet);
if (result->result < 0) {
cellSysutil->Error("cellSaveDataListSave2: CellSaveDataListCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message.
return CELL_SAVEDATA_ERROR_CBRESULT;
}
setSaveDataList(saveEntries, (u32)listSet->fixedList.GetAddr(), listSet->fixedListNum);
if (listSet->newData.GetAddr())
addNewSaveDataEntry(saveEntries, (u32)listSet->newData.GetAddr());
setSaveDataList(saveEntries, vm::ptr<CellSaveDataDirList>::make(listSet->fixedList.addr()), listSet->fixedListNum);
if (listSet->newData)
addNewSaveDataEntry(saveEntries, vm::ptr<CellSaveDataListNewData>::make(listSet->newData.addr()));
if (saveEntries.size() == 0) {
cellSysutil->Warning("cellSaveDataListSave2: No save entries found!"); // TODO: Find a better way to handle this error
return CELL_SAVEDATA_RET_OK;
@ -351,38 +351,38 @@ 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);
result->userdata_addr = userdata_addr;
funcStat(result.GetAddr(), statGet.GetAddr(), statSet.GetAddr());
Memory.Free(statGet->fileList.GetAddr());
funcStat(result, statGet, statSet);
Memory.Free(statGet->fileList.addr());
if (result->result < 0) {
cellSysutil->Error("cellSaveDataListLoad2: CellSaveDataStatCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message.
return CELL_SAVEDATA_ERROR_CBRESULT;
}
/*if (statSet->setParam.GetAddr())
addNewSaveDataEntry(saveEntries, (u32)listSet->newData.GetAddr()); // TODO: This *is* wrong
/*if (statSet->setParam)
addNewSaveDataEntry(saveEntries, (u32)listSet->newData.addr()); // TODO: This *is* wrong
*/
// 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, saveBaseDir + (char*)statGet->dir.dirName);
return ret;
}
int cellSaveDataListLoad2(u32 version, mem_ptr_t<CellSaveDataSetList> setList, mem_ptr_t<CellSaveDataSetBuf> setBuf,
mem_func_ptr_t<CellSaveDataListCallback> funcList, mem_func_ptr_t<CellSaveDataStatCallback> funcStat, mem_func_ptr_t<CellSaveDataFileCallback> funcFile,
int cellSaveDataListLoad2(u32 version, vm::ptr<CellSaveDataSetList> setList, vm::ptr<CellSaveDataSetBuf> setBuf,
vm::ptr<CellSaveDataListCallback> funcList, vm::ptr<CellSaveDataStatCallback> funcStat, vm::ptr<CellSaveDataFileCallback> funcFile,
u32 container, u32 userdata_addr)
{
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;
version, setList.addr(), setBuf.addr(), funcList.addr(), funcStat.addr(), funcFile.addr(), container, userdata_addr);
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);
@ -410,24 +410,24 @@ int cellSaveDataListLoad2(u32 version, mem_ptr_t<CellSaveDataSetList> setList, m
// Sort the entries and fill the listGet->dirList array
std::sort(saveEntries.begin(), saveEntries.end(), sortSaveDataEntry(setList->sortType, setList->sortOrder));
listGet->dirList.SetAddr(setBuf->buf_addr);
CellSaveDataDirList* dirList = (CellSaveDataDirList*)Memory.VirtualToRealAddr(listGet->dirList.GetAddr());
listGet->dirList = vm::bptr<CellSaveDataDirList>::make(setBuf->buf_addr);
CellSaveDataDirList* dirList = (CellSaveDataDirList*)Memory.VirtualToRealAddr(listGet->dirList.addr());
for (u32 i=0; i<saveEntries.size(); i++) {
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);
}
funcList(result.GetAddr(), listGet.GetAddr(), listSet.GetAddr());
funcList(result, listGet, listSet);
if (result->result < 0) {
cellSysutil->Error("cellSaveDataListLoad2: CellSaveDataListCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message.
return CELL_SAVEDATA_ERROR_CBRESULT;
}
setSaveDataList(saveEntries, (u32)listSet->fixedList.GetAddr(), listSet->fixedListNum);
if (listSet->newData.GetAddr())
addNewSaveDataEntry(saveEntries, (u32)listSet->newData.GetAddr());
setSaveDataList(saveEntries, vm::ptr<CellSaveDataDirList>::make(listSet->fixedList.addr()), listSet->fixedListNum);
if (listSet->newData)
addNewSaveDataEntry(saveEntries, vm::ptr<CellSaveDataListNewData>::make(listSet->newData.addr()));
if (saveEntries.size() == 0) {
cellSysutil->Warning("cellSaveDataListLoad2: No save entries found!"); // TODO: Find a better way to handle this error
return CELL_SAVEDATA_RET_OK;
@ -436,38 +436,38 @@ 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);
result->userdata_addr = userdata_addr;
funcStat(result.GetAddr(), statGet.GetAddr(), statSet.GetAddr());
Memory.Free(statGet->fileList.GetAddr());
funcStat(result, statGet, statSet);
Memory.Free(statGet->fileList.addr());
if (result->result < 0) {
cellSysutil->Error("cellSaveDataListLoad2: CellSaveDataStatCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message.
return CELL_SAVEDATA_ERROR_CBRESULT;
}
/*if (statSet->setParam.GetAddr())
/*if (statSet->setParam)
// TODO: Write PARAM.SFO file
*/
// 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, saveBaseDir + (char*)statGet->dir.dirName);
return ret;
}
int cellSaveDataFixedSave2(u32 version, mem_ptr_t<CellSaveDataSetList> setList, mem_ptr_t<CellSaveDataSetBuf> setBuf,
mem_func_ptr_t<CellSaveDataFixedCallback> funcFixed, mem_func_ptr_t<CellSaveDataStatCallback> funcStat, mem_func_ptr_t<CellSaveDataFileCallback> funcFile,
int cellSaveDataFixedSave2(u32 version, vm::ptr<CellSaveDataSetList> setList, vm::ptr<CellSaveDataSetBuf> setBuf,
vm::ptr<CellSaveDataFixedCallback> funcFixed, vm::ptr<CellSaveDataStatCallback> funcStat, vm::ptr<CellSaveDataFileCallback> funcFile,
u32 container, u32 userdata_addr)
{
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);
version, setList.addr(), setBuf.addr(), funcFixed.addr(), funcStat.addr(), funcFile.addr(), 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);
@ -493,50 +493,50 @@ int cellSaveDataFixedSave2(u32 version, mem_ptr_t<CellSaveDataSetList> setList,
// Sort the entries and fill the listGet->dirList array
std::sort(saveEntries.begin(), saveEntries.end(), sortSaveDataEntry(setList->sortType, setList->sortOrder));
listGet->dirList.SetAddr(setBuf->buf_addr);
CellSaveDataDirList* dirList = (CellSaveDataDirList*)Memory.VirtualToRealAddr(listGet->dirList.GetAddr());
listGet->dirList = vm::bptr<CellSaveDataDirList>::make(setBuf->buf_addr);
CellSaveDataDirList* dirList = (CellSaveDataDirList*)Memory.VirtualToRealAddr(listGet->dirList.addr());
for (u32 i = 0; i<saveEntries.size(); i++) {
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, listGet, fixedSet);
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);
getSaveDataStat(saveEntries[0], statGet); // 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());
Memory.Free(statGet->fileList.GetAddr());
funcStat(result, statGet, statSet);
Memory.Free(statGet->fileList.addr());
if (result->result < 0) {
cellSysutil->Error("cellSaveDataFixedSave2: CellSaveDataStatCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message.
return CELL_SAVEDATA_ERROR_CBRESULT;
}
/*if (statSet->setParam.GetAddr())
/*if (statSet->setParam)
// TODO: Write PARAM.SFO file
*/
// 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, saveBaseDir + (char*)statGet->dir.dirName);
return ret;
}
int cellSaveDataFixedLoad2(u32 version, mem_ptr_t<CellSaveDataSetList> setList, mem_ptr_t<CellSaveDataSetBuf> setBuf,
mem_func_ptr_t<CellSaveDataFixedCallback> funcFixed, mem_func_ptr_t<CellSaveDataStatCallback> funcStat, mem_func_ptr_t<CellSaveDataFileCallback> funcFile,
int cellSaveDataFixedLoad2(u32 version, vm::ptr<CellSaveDataSetList> setList, vm::ptr<CellSaveDataSetBuf> setBuf,
vm::ptr<CellSaveDataFixedCallback> funcFixed, vm::ptr<CellSaveDataStatCallback> funcStat, vm::ptr<CellSaveDataFileCallback> funcFile,
u32 container, u32 userdata_addr)
{
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);
version, setList.addr(), setBuf.addr(), funcFixed.addr(), funcStat.addr(), funcFile.addr(), 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);
@ -562,48 +562,48 @@ int cellSaveDataFixedLoad2(u32 version, mem_ptr_t<CellSaveDataSetList> setList,
// Sort the entries and fill the listGet->dirList array
std::sort(saveEntries.begin(), saveEntries.end(), sortSaveDataEntry(setList->sortType, setList->sortOrder));
listGet->dirList.SetAddr(setBuf->buf_addr);
CellSaveDataDirList* dirList = (CellSaveDataDirList*)Memory.VirtualToRealAddr(listGet->dirList.GetAddr());
listGet->dirList = vm::bptr<CellSaveDataDirList>::make(setBuf->buf_addr);
CellSaveDataDirList* dirList = (CellSaveDataDirList*)Memory.VirtualToRealAddr(listGet->dirList.addr());
for (u32 i = 0; i<saveEntries.size(); i++) {
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, listGet, fixedSet);
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);
getSaveDataStat(saveEntries[0], statGet); // 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());
Memory.Free(statGet->fileList.GetAddr());
funcStat(result, statGet, statSet);
Memory.Free(statGet->fileList.addr());
if (result->result < 0) {
cellSysutil->Error("cellSaveDataFixedLoad2: CellSaveDataStatCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message.
return CELL_SAVEDATA_ERROR_CBRESULT;
}
/*if (statSet->setParam.GetAddr())
/*if (statSet->setParam)
// TODO: Write PARAM.SFO file
*/
// 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, saveBaseDir + (char*)statGet->dir.dirName);
return ret;
}
int cellSaveDataAutoSave2(u32 version, u32 dirName_addr, u32 errDialog, mem_ptr_t<CellSaveDataSetBuf> setBuf,
mem_func_ptr_t<CellSaveDataStatCallback> funcStat, mem_func_ptr_t<CellSaveDataFileCallback> funcFile,
int cellSaveDataAutoSave2(u32 version, u32 dirName_addr, u32 errDialog, vm::ptr<CellSaveDataSetBuf> setBuf,
vm::ptr<CellSaveDataStatCallback> funcStat, vm::ptr<CellSaveDataFileCallback> funcFile,
u32 container, u32 userdata_addr)
{
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);
version, dirName_addr, errDialog, setBuf.addr(), funcStat.addr(), funcFile.addr(), 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,35 +628,35 @@ 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); // There should be only one element in this list
result->userdata_addr = userdata_addr;
funcStat(result.GetAddr(), statGet.GetAddr(), statSet.GetAddr());
funcStat(result, statGet, statSet);
Memory.Free(statGet->fileList.GetAddr());
Memory.Free(statGet->fileList.addr());
if (result->result < 0) {
cellSysutil->Error("cellSaveDataAutoSave2: CellSaveDataStatCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message.
return CELL_SAVEDATA_ERROR_CBRESULT;
}
/*if (statSet->setParam.GetAddr())
/*if (statSet->setParam)
// TODO: Write PARAM.SFO file
*/
// 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, saveBaseDir + (char*)statGet->dir.dirName);
return CELL_SAVEDATA_RET_OK;
}
int cellSaveDataAutoLoad2(u32 version, u32 dirName_addr, u32 errDialog, mem_ptr_t<CellSaveDataSetBuf> setBuf,
mem_func_ptr_t<CellSaveDataStatCallback> funcStat, mem_func_ptr_t<CellSaveDataFileCallback> funcFile,
int cellSaveDataAutoLoad2(u32 version, u32 dirName_addr, u32 errDialog, vm::ptr<CellSaveDataSetBuf> setBuf,
vm::ptr<CellSaveDataStatCallback> funcStat, vm::ptr<CellSaveDataFileCallback> funcFile,
u32 container, u32 userdata_addr)
{
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);
version, dirName_addr, errDialog, setBuf.addr(), funcStat.addr(), funcFile.addr(), 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,36 +678,36 @@ 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); // There should be only one element in this list
result->userdata_addr = userdata_addr;
funcStat(result.GetAddr(), statGet.GetAddr(), statSet.GetAddr());
funcStat(result, statGet, statSet);
Memory.Free(statGet->fileList.GetAddr());
Memory.Free(statGet->fileList.addr());
if (result->result < 0) {
cellSysutil->Error("cellSaveDataAutoLoad2: CellSaveDataStatCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message.
return CELL_SAVEDATA_ERROR_CBRESULT;
}
/*if (statSet->setParam.GetAddr())
/*if (statSet->setParam)
// TODO: Write PARAM.SFO file
*/
// 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, saveBaseDir + (char*)statGet->dir.dirName);
return CELL_SAVEDATA_RET_OK;
}
int cellSaveDataListAutoSave(u32 version, u32 errDialog, mem_ptr_t<CellSaveDataSetList> setList, mem_ptr_t<CellSaveDataSetBuf> setBuf, mem_func_ptr_t<CellSaveDataFixedCallback> funcFixed,
mem_func_ptr_t<CellSaveDataStatCallback> funcStat, mem_func_ptr_t<CellSaveDataFileCallback> funcFile, u32 container, u32 userdata_addr)
int cellSaveDataListAutoSave(u32 version, u32 errDialog, vm::ptr<CellSaveDataSetList> setList, vm::ptr<CellSaveDataSetBuf> setBuf, vm::ptr<CellSaveDataFixedCallback> funcFixed,
vm::ptr<CellSaveDataStatCallback> funcStat, vm::ptr<CellSaveDataFileCallback> funcFile, u32 container, u32 userdata_addr)
{
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);
version, errDialog, setList.addr(), setBuf.addr(), funcFixed.addr(), funcStat.addr(), funcFile.addr(), 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<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);
@ -735,24 +735,25 @@ int cellSaveDataListAutoSave(u32 version, u32 errDialog, mem_ptr_t<CellSaveDataS
// Sort the entries and fill the listGet->dirList array
std::sort(saveEntries.begin(), saveEntries.end(), sortSaveDataEntry(setList->sortType, setList->sortOrder));
listGet->dirList.SetAddr(setBuf->buf_addr);
CellSaveDataDirList* dirList = (CellSaveDataDirList*)Memory.VirtualToRealAddr(listGet->dirList.GetAddr());
listGet->dirList = vm::bptr<CellSaveDataDirList>::make(setBuf->buf_addr);
CellSaveDataDirList* dirList = (CellSaveDataDirList*)Memory.VirtualToRealAddr(listGet->dirList.addr());
for (u32 i = 0; i<saveEntries.size(); i++) {
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(), listSet.GetAddr());
throw fmt::Format("%s(): implementation broken", __FUNCTION__);
funcFixed(result, listGet, fixedSet);
if (result->result < 0) {
cellSysutil->Error("cellSaveDataListAutoSave: CellSaveDataListCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message.
return CELL_SAVEDATA_ERROR_CBRESULT;
}
setSaveDataList(saveEntries, (u32)listSet->fixedList.GetAddr(), listSet->fixedListNum);
if (listSet->newData.GetAddr())
addNewSaveDataEntry(saveEntries, (u32)listSet->newData.GetAddr());
/*setSaveDataList(saveEntries, (u32)listSet->fixedList.addr(), listSet->fixedListNum);
if (listSet->newData)
addNewSaveDataEntry(saveEntries, (u32)listSet->newData.addr());
if (saveEntries.size() == 0) {
cellSysutil->Warning("cellSaveDataListAutoSave: No save entries found!"); // TODO: Find a better way to handle this error
return CELL_SAVEDATA_RET_OK;
@ -761,37 +762,37 @@ 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());
Memory.Free(statGet->fileList.GetAddr());
funcStat(result, statGet, statSet);
Memory.Free(statGet->fileList.addr());
if (result->result < 0) {
cellSysutil->Error("cellSaveDataListAutoSave: CellSaveDataStatCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message.
return CELL_SAVEDATA_ERROR_CBRESULT;
}
}*/
/*if (statSet->setParam.GetAddr())
addNewSaveDataEntry(saveEntries, (u32)listSet->newData.GetAddr()); // TODO: This *is* wrong
/*if (statSet->setParam)
addNewSaveDataEntry(saveEntries, (u32)listSet->newData.addr()); // TODO: This *is* wrong
*/
// 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, saveBaseDir + (char*)statGet->dir.dirName);
return CELL_SAVEDATA_RET_OK;
}
int cellSaveDataListAutoLoad(u32 version, u32 errDialog, mem_ptr_t<CellSaveDataSetList> setList, mem_ptr_t<CellSaveDataSetBuf> setBuf, mem_func_ptr_t<CellSaveDataFixedCallback> funcFixed,
mem_func_ptr_t<CellSaveDataStatCallback> funcStat, mem_func_ptr_t<CellSaveDataFileCallback> funcFile, u32 container, u32 userdata_addr)
int cellSaveDataListAutoLoad(u32 version, u32 errDialog, vm::ptr<CellSaveDataSetList> setList, vm::ptr<CellSaveDataSetBuf> setBuf, vm::ptr<CellSaveDataFixedCallback> funcFixed,
vm::ptr<CellSaveDataStatCallback> funcStat, vm::ptr<CellSaveDataFileCallback> funcFile, u32 container, u32 userdata_addr)
{
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);
version, errDialog, setList.addr(), setBuf.addr(), funcFixed.addr(), funcStat.addr(), funcFile.addr(), 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<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);
@ -819,24 +820,25 @@ int cellSaveDataListAutoLoad(u32 version, u32 errDialog, mem_ptr_t<CellSaveDataS
// Sort the entries and fill the listGet->dirList array
std::sort(saveEntries.begin(), saveEntries.end(), sortSaveDataEntry(setList->sortType, setList->sortOrder));
listGet->dirList.SetAddr(setBuf->buf_addr);
CellSaveDataDirList* dirList = (CellSaveDataDirList*)Memory.VirtualToRealAddr(listGet->dirList.GetAddr());
listGet->dirList = vm::bptr<CellSaveDataDirList>::make(setBuf->buf_addr);
CellSaveDataDirList* dirList = (CellSaveDataDirList*)Memory.VirtualToRealAddr(listGet->dirList.addr());
for (u32 i = 0; i<saveEntries.size(); i++) {
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(), listSet.GetAddr());
throw fmt::Format("%s(): implementation broken", __FUNCTION__);
funcFixed(result, listGet, fixedSet);
if (result->result < 0) {
cellSysutil->Error("cellSaveDataListAutoLoad: CellSaveDataListCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message.
return CELL_SAVEDATA_ERROR_CBRESULT;
}
setSaveDataList(saveEntries, (u32)listSet->fixedList.GetAddr(), listSet->fixedListNum);
if (listSet->newData.GetAddr())
addNewSaveDataEntry(saveEntries, (u32)listSet->newData.GetAddr());
/*setSaveDataList(saveEntries, (u32)listSet->fixedList.addr(), listSet->fixedListNum);
if (listSet->newData)
addNewSaveDataEntry(saveEntries, (u32)listSet->newData.addr());
if (saveEntries.size() == 0) {
cellSysutil->Warning("cellSaveDataListAutoLoad: No save entries found!"); // TODO: Find a better way to handle this error
return CELL_SAVEDATA_RET_OK;
@ -845,23 +847,23 @@ 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());
Memory.Free(statGet->fileList.GetAddr());
funcStat(result.addr(), statGet.addr(), statSet.addr());
Memory.Free(statGet->fileList.addr());
if (result->result < 0) {
cellSysutil->Error("cellSaveDataListAutoLoad: CellSaveDataStatCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message.
return CELL_SAVEDATA_ERROR_CBRESULT;
}
}*/
/*if (statSet->setParam.GetAddr())
/*if (statSet->setParam)
// TODO: Write PARAM.SFO file
*/
// 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, saveBaseDir + (char*)statGet->dir.dirName);
return CELL_SAVEDATA_RET_OK;
}
@ -966,7 +968,7 @@ int cellSaveDataFixedExport() //const char *dirName, u32 maxSizeKB, CellSaveData
return CELL_SAVEDATA_RET_OK;
}
int cellSaveDataGetListItem() //const char *dirName, CellSaveDataDirStat *dir, CellSaveDataSystemFileParam *sysFileParam, mem32_t bind, mem32_t sizeKB
int cellSaveDataGetListItem() //const char *dirName, CellSaveDataDirStat *dir, CellSaveDataSystemFileParam *sysFileParam, vm::ptr<be_t<u32>> bind, vm::ptr<be_t<u32>> sizeKB
{
UNIMPLEMENTED_FUNC(cellSysutil);
return CELL_SAVEDATA_RET_OK;
@ -1002,7 +1004,7 @@ int cellSaveDataUserFixedExport() //CellSysutilUserId userId, const char *dirNam
return CELL_SAVEDATA_RET_OK;
}
int cellSaveDataUserGetListItem() //CellSysutilUserId userId, const char *dirName, CellSaveDataDirStat *dir, CellSaveDataSystemFileParam *sysFileParam, mem32_t bind, mem32_t sizeKB
int cellSaveDataUserGetListItem() //CellSysutilUserId userId, const char *dirName, CellSaveDataDirStat *dir, CellSaveDataSystemFileParam *sysFileParam, vm::ptr<be_t<u32>> bind, vm::ptr<be_t<u32>> sizeKB
{
UNIMPLEMENTED_FUNC(cellSysutil);
return CELL_SAVEDATA_RET_OK;

View file

@ -116,7 +116,7 @@ struct CellSaveDataListNewData
{
be_t<u32> iconPosition;
be_t<u32> dirName_addr; // char*
mem_beptr_t<CellSaveDataNewDataIcon> icon;
vm::bptr<CellSaveDataNewDataIcon> icon;
};
struct CellSaveDataDirList
@ -129,7 +129,7 @@ struct CellSaveDataListGet
{
be_t<u32> dirNum;
be_t<u32> dirListNum;
mem_beptr_t<CellSaveDataDirList> dirList;
vm::bptr<CellSaveDataDirList> dirList;
};
struct CellSaveDataListSet
@ -137,15 +137,15 @@ struct CellSaveDataListSet
be_t<u32> focusPosition;
be_t<u32> focusDirName_addr; // char*
be_t<u32> fixedListNum;
mem_beptr_t<CellSaveDataDirList> fixedList;
mem_beptr_t<CellSaveDataListNewData> newData;
vm::bptr<CellSaveDataDirList> fixedList;
vm::bptr<CellSaveDataListNewData> newData;
be_t<u32> reserved_addr; // void*
};
struct CellSaveDataFixedSet
{
be_t<u32> dirName_addr; // char*
mem_beptr_t<CellSaveDataNewDataIcon> newIcon;
vm::bptr<CellSaveDataNewDataIcon> newIcon;
be_t<u32> option;
};
@ -191,7 +191,7 @@ struct CellSaveDataStatGet
be_t<s32> sysSizeKB;
be_t<u32> fileNum;
be_t<u32> fileListNum;
mem_beptr_t<CellSaveDataFileStat> fileList;
vm::bptr<CellSaveDataFileStat> fileList;
};
struct CellSaveDataAutoIndicator
@ -205,9 +205,9 @@ struct CellSaveDataAutoIndicator
struct CellSaveDataStatSet
{
mem_beptr_t<CellSaveDataSystemFileParam> setParam;
vm::bptr<CellSaveDataSystemFileParam> setParam;
be_t<u32> reCreateMode;
mem_beptr_t<CellSaveDataAutoIndicator> indicator;
vm::bptr<CellSaveDataAutoIndicator> indicator;
};
struct CellSaveDataFileGet
@ -247,11 +247,11 @@ struct CellSaveDataDoneGet
// Callback Functions
typedef void (*CellSaveDataFixedCallback)(mem_ptr_t<CellSaveDataCBResult> cbResult, mem_ptr_t<CellSaveDataListGet> get, mem_ptr_t<CellSaveDataFixedSet> set);
typedef void (*CellSaveDataListCallback) (mem_ptr_t<CellSaveDataCBResult> cbResult, mem_ptr_t<CellSaveDataListGet> get, mem_ptr_t<CellSaveDataListSet> set);
typedef void (*CellSaveDataStatCallback) (mem_ptr_t<CellSaveDataCBResult> cbResult, mem_ptr_t<CellSaveDataStatGet> get, mem_ptr_t<CellSaveDataStatSet> set);
typedef void (*CellSaveDataFileCallback) (mem_ptr_t<CellSaveDataCBResult> cbResult, mem_ptr_t<CellSaveDataFileGet> get, mem_ptr_t<CellSaveDataFileSet> set);
typedef void (*CellSaveDataDoneCallback) (mem_ptr_t<CellSaveDataCBResult> cbResult, mem_ptr_t<CellSaveDataDoneGet> get);
typedef void(*CellSaveDataFixedCallback)(vm::ptr<CellSaveDataCBResult> cbResult, vm::ptr<CellSaveDataListGet> get, vm::ptr<CellSaveDataFixedSet> set);
typedef void(*CellSaveDataListCallback) (vm::ptr<CellSaveDataCBResult> cbResult, vm::ptr<CellSaveDataListGet> get, vm::ptr<CellSaveDataListSet> set);
typedef void(*CellSaveDataStatCallback) (vm::ptr<CellSaveDataCBResult> cbResult, vm::ptr<CellSaveDataStatGet> get, vm::ptr<CellSaveDataStatSet> set);
typedef void(*CellSaveDataFileCallback) (vm::ptr<CellSaveDataCBResult> cbResult, vm::ptr<CellSaveDataFileGet> get, vm::ptr<CellSaveDataFileSet> set);
typedef void(*CellSaveDataDoneCallback) (vm::ptr<CellSaveDataCBResult> cbResult, vm::ptr<CellSaveDataDoneGet> get);
// Auxiliary Structs
@ -273,32 +273,32 @@ struct SaveDataEntry
// Function declarations
int cellSaveDataListSave2(u32 version, mem_ptr_t<CellSaveDataSetList> setList, mem_ptr_t<CellSaveDataSetBuf> setBuf,
mem_func_ptr_t<CellSaveDataListCallback> funcList, mem_func_ptr_t<CellSaveDataStatCallback> funcStat, mem_func_ptr_t<CellSaveDataFileCallback> funcFile,
int cellSaveDataListSave2(u32 version, vm::ptr<CellSaveDataSetList> setList, vm::ptr<CellSaveDataSetBuf> setBuf,
vm::ptr<CellSaveDataListCallback> funcList, vm::ptr<CellSaveDataStatCallback> funcStat, vm::ptr<CellSaveDataFileCallback> funcFile,
u32 container, u32 userdata_addr);
int cellSaveDataListLoad2(u32 version, mem_ptr_t<CellSaveDataSetList> setList, mem_ptr_t<CellSaveDataSetBuf> setBuf,
mem_func_ptr_t<CellSaveDataListCallback> funcList, mem_func_ptr_t<CellSaveDataStatCallback> funcStat, mem_func_ptr_t<CellSaveDataFileCallback> funcFile,
int cellSaveDataListLoad2(u32 version, vm::ptr<CellSaveDataSetList> setList, vm::ptr<CellSaveDataSetBuf> setBuf,
vm::ptr<CellSaveDataListCallback> funcList, vm::ptr<CellSaveDataStatCallback> funcStat, vm::ptr<CellSaveDataFileCallback> funcFile,
u32 container, u32 userdata_addr);
int cellSaveDataFixedSave2(u32 version, mem_ptr_t<CellSaveDataSetList> setList, mem_ptr_t<CellSaveDataSetBuf> setBuf,
mem_func_ptr_t<CellSaveDataFixedCallback> funcFixed, mem_func_ptr_t<CellSaveDataStatCallback> funcStat, mem_func_ptr_t<CellSaveDataFileCallback> funcFile,
int cellSaveDataFixedSave2(u32 version, vm::ptr<CellSaveDataSetList> setList, vm::ptr<CellSaveDataSetBuf> setBuf,
vm::ptr<CellSaveDataFixedCallback> funcFixed, vm::ptr<CellSaveDataStatCallback> funcStat, vm::ptr<CellSaveDataFileCallback> funcFile,
u32 container, u32 userdata_addr);
int cellSaveDataFixedLoad2(u32 version, mem_ptr_t<CellSaveDataSetList> setList, mem_ptr_t<CellSaveDataSetBuf> setBuf,
mem_func_ptr_t<CellSaveDataFixedCallback> funcFixed, mem_func_ptr_t<CellSaveDataStatCallback> funcStat, mem_func_ptr_t<CellSaveDataFileCallback> funcFile,
int cellSaveDataFixedLoad2(u32 version, vm::ptr<CellSaveDataSetList> setList, vm::ptr<CellSaveDataSetBuf> setBuf,
vm::ptr<CellSaveDataFixedCallback> funcFixed, vm::ptr<CellSaveDataStatCallback> funcStat, vm::ptr<CellSaveDataFileCallback> funcFile,
u32 container, u32 userdata_addr);
int cellSaveDataAutoSave2(u32 version, u32 dirName_addr, u32 errDialog, mem_ptr_t<CellSaveDataSetBuf> setBuf,
mem_func_ptr_t<CellSaveDataStatCallback> funcStat, mem_func_ptr_t<CellSaveDataFileCallback> funcFile,
int cellSaveDataAutoSave2(u32 version, u32 dirName_addr, u32 errDialog, vm::ptr<CellSaveDataSetBuf> setBuf,
vm::ptr<CellSaveDataStatCallback> funcStat, vm::ptr<CellSaveDataFileCallback> funcFile,
u32 container, u32 userdata_addr);
int cellSaveDataAutoLoad2(u32 version, u32 dirName_addr, u32 errDialog, mem_ptr_t<CellSaveDataSetBuf> setBuf,
mem_func_ptr_t<CellSaveDataStatCallback> funcStat, mem_func_ptr_t<CellSaveDataFileCallback> funcFile,
int cellSaveDataAutoLoad2(u32 version, u32 dirName_addr, u32 errDialog, vm::ptr<CellSaveDataSetBuf> setBuf,
vm::ptr<CellSaveDataStatCallback> funcStat, vm::ptr<CellSaveDataFileCallback> funcFile,
u32 container, u32 userdata_addr);
int cellSaveDataListAutoSave(u32 version, u32 errDialog, mem_ptr_t<CellSaveDataSetList> setList, mem_ptr_t<CellSaveDataSetBuf> setBuf, mem_func_ptr_t<CellSaveDataFixedCallback> funcFixed,
mem_func_ptr_t<CellSaveDataStatCallback> funcStat, mem_func_ptr_t<CellSaveDataFileCallback> funcFile, u32 container, u32 userdata_addr);
int cellSaveDataListAutoSave(u32 version, u32 errDialog, vm::ptr<CellSaveDataSetList> setList, vm::ptr<CellSaveDataSetBuf> setBuf, vm::ptr<CellSaveDataFixedCallback> funcFixed,
vm::ptr<CellSaveDataStatCallback> funcStat, vm::ptr<CellSaveDataFileCallback> funcFile, u32 container, u32 userdata_addr);
int cellSaveDataListAutoLoad(u32 version, u32 errDialog, mem_ptr_t<CellSaveDataSetList> setList, mem_ptr_t<CellSaveDataSetBuf> setBuf, mem_func_ptr_t<CellSaveDataFixedCallback> funcFixed,
mem_func_ptr_t<CellSaveDataStatCallback> funcStat, mem_func_ptr_t<CellSaveDataFileCallback> funcFile, u32 container, u32 userdata_addr);
int cellSaveDataListAutoLoad(u32 version, u32 errDialog, vm::ptr<CellSaveDataSetList> setList, vm::ptr<CellSaveDataSetBuf> setBuf, vm::ptr<CellSaveDataFixedCallback> funcFixed,
vm::ptr<CellSaveDataStatCallback> funcStat, vm::ptr<CellSaveDataFileCallback> funcFile, u32 container, u32 userdata_addr);

View file

@ -11,9 +11,9 @@
//Module cellUserInfo(0x0032, cellUserInfo_init);
Module *cellUserInfo = nullptr;
int cellUserInfoGetStat(u32 id, mem_ptr_t<CellUserInfoUserStat> stat)
int cellUserInfoGetStat(u32 id, vm::ptr<CellUserInfoUserStat> stat)
{
cellUserInfo->Warning("cellUserInfoGetStat(id=%d, stat_addr=0x%x)", id, stat.GetAddr());
cellUserInfo->Warning("cellUserInfoGetStat(id=%d, stat_addr=0x%x)", id, stat.addr());
if (id > CELL_USERINFO_USER_MAX)
return CELL_USERINFO_ERROR_NOUSER;
@ -57,21 +57,21 @@ int cellUserInfoEnableOverlay()
return CELL_OK;
}
int cellUserInfoGetList(mem32_t listNum, mem_ptr_t<CellUserInfoUserList> listBuf, mem32_t currentUserId)
int cellUserInfoGetList(vm::ptr<be_t<u32>> listNum, vm::ptr<CellUserInfoUserList> listBuf, vm::ptr<be_t<u32>> currentUserId)
{
cellUserInfo->Warning("cellUserInfoGetList(listNum_addr=0x%x, listBuf_addr=0x%x, currentUserId_addr=0x%x)",
listNum.GetAddr(), listBuf.GetAddr(), currentUserId.GetAddr());
listNum.addr(), listBuf.addr(), currentUserId.addr());
// If only listNum is NULL, an error will be returned
if (listBuf.GetAddr() && !listNum.GetAddr())
if (listBuf && !listNum)
return CELL_USERINFO_ERROR_PARAM;
if (listNum.GetAddr())
listNum = 1;
if (listBuf.GetAddr())
if (listNum)
*listNum = 1;
if (listBuf)
listBuf->userId[0] = 1;
if (currentUserId.GetAddr())
currentUserId = 1;
if (currentUserId)
*currentUserId = 1;
return CELL_OK;
}

View file

@ -42,7 +42,7 @@ struct CellUserInfoListSet
be_t<u32> title_addr; // (char*)
be_t<u32> focus;
be_t<u32> fixedListNum;
mem_ptr_t<CellUserInfoUserList> fixedList;
vm::ptr<CellUserInfoUserList> fixedList;
be_t<u32> reserved_addr; // (void*)
};

View file

@ -161,7 +161,7 @@ next:
}
}
u32 vdecQueryAttr(CellVdecCodecType type, u32 profile, u32 spec_addr /* may be 0 */, mem_ptr_t<CellVdecAttr> attr)
u32 vdecQueryAttr(CellVdecCodecType type, u32 profile, u32 spec_addr /* may be 0 */, vm::ptr<CellVdecAttr> attr)
{
switch (type) // TODO: check profile levels
{
@ -482,36 +482,36 @@ u32 vdecOpen(VideoDecoder* data)
return vdec_id;
}
int cellVdecQueryAttr(const mem_ptr_t<CellVdecType> type, mem_ptr_t<CellVdecAttr> attr)
int cellVdecQueryAttr(const vm::ptr<CellVdecType> type, vm::ptr<CellVdecAttr> attr)
{
cellVdec->Warning("cellVdecQueryAttr(type_addr=0x%x, attr_addr=0x%x)", type.GetAddr(), attr.GetAddr());
cellVdec->Warning("cellVdecQueryAttr(type_addr=0x%x, attr_addr=0x%x)", type.addr(), attr.addr());
return vdecQueryAttr(type->codecType, type->profileLevel, 0, attr);
}
int cellVdecQueryAttrEx(const mem_ptr_t<CellVdecTypeEx> type, mem_ptr_t<CellVdecAttr> attr)
int cellVdecQueryAttrEx(const vm::ptr<CellVdecTypeEx> type, vm::ptr<CellVdecAttr> attr)
{
cellVdec->Warning("cellVdecQueryAttrEx(type_addr=0x%x, attr_addr=0x%x)", type.GetAddr(), attr.GetAddr());
cellVdec->Warning("cellVdecQueryAttrEx(type_addr=0x%x, attr_addr=0x%x)", type.addr(), attr.addr());
return vdecQueryAttr(type->codecType, type->profileLevel, type->codecSpecificInfo_addr, attr);
}
int cellVdecOpen(const mem_ptr_t<CellVdecType> type, const mem_ptr_t<CellVdecResource> res, const mem_ptr_t<CellVdecCb> cb, mem32_t handle)
int cellVdecOpen(const vm::ptr<CellVdecType> type, const vm::ptr<CellVdecResource> res, const vm::ptr<CellVdecCb> cb, vm::ptr<be_t<u32>> handle)
{
cellVdec->Warning("cellVdecOpen(type_addr=0x%x, res_addr=0x%x, cb_addr=0x%x, handle_addr=0x%x)",
type.GetAddr(), res.GetAddr(), cb.GetAddr(), handle.GetAddr());
type.addr(), res.addr(), cb.addr(), handle.addr());
handle = vdecOpen(new VideoDecoder(type->codecType, type->profileLevel, res->memAddr, res->memSize, cb->cbFunc, cb->cbArg));
*handle = vdecOpen(new VideoDecoder(type->codecType, type->profileLevel, res->memAddr, res->memSize, cb->cbFunc, cb->cbArg));
return CELL_OK;
}
int cellVdecOpenEx(const mem_ptr_t<CellVdecTypeEx> type, const mem_ptr_t<CellVdecResourceEx> res, const mem_ptr_t<CellVdecCb> cb, mem32_t handle)
int cellVdecOpenEx(const vm::ptr<CellVdecTypeEx> type, const vm::ptr<CellVdecResourceEx> res, const vm::ptr<CellVdecCb> cb, vm::ptr<be_t<u32>> handle)
{
cellVdec->Warning("cellVdecOpenEx(type_addr=0x%x, res_addr=0x%x, cb_addr=0x%x, handle_addr=0x%x)",
type.GetAddr(), res.GetAddr(), cb.GetAddr(), handle.GetAddr());
type.addr(), res.addr(), cb.addr(), handle.addr());
handle = vdecOpen(new VideoDecoder(type->codecType, type->profileLevel, res->memAddr, res->memSize, cb->cbFunc, cb->cbArg));
*handle = vdecOpen(new VideoDecoder(type->codecType, type->profileLevel, res->memAddr, res->memSize, cb->cbFunc, cb->cbArg));
return CELL_OK;
}
@ -593,9 +593,9 @@ int cellVdecEndSeq(u32 handle)
return CELL_OK;
}
int cellVdecDecodeAu(u32 handle, CellVdecDecodeMode mode, const mem_ptr_t<CellVdecAuInfo> auInfo)
int cellVdecDecodeAu(u32 handle, CellVdecDecodeMode mode, const vm::ptr<CellVdecAuInfo> auInfo)
{
cellVdec->Log("cellVdecDecodeAu(handle=%d, mode=0x%x, auInfo_addr=0x%x)", handle, mode, auInfo.GetAddr());
cellVdec->Log("cellVdecDecodeAu(handle=%d, mode=0x%x, auInfo_addr=0x%x)", handle, mode, auInfo.addr());
VideoDecoder* vdec;
if (!Emu.GetIdManager().GetIDData(handle, vdec))
@ -617,9 +617,9 @@ int cellVdecDecodeAu(u32 handle, CellVdecDecodeMode mode, const mem_ptr_t<CellVd
return CELL_OK;
}
int cellVdecGetPicture(u32 handle, const mem_ptr_t<CellVdecPicFormat> format, u32 out_addr)
int cellVdecGetPicture(u32 handle, const vm::ptr<CellVdecPicFormat> format, u32 out_addr)
{
cellVdec->Log("cellVdecGetPicture(handle=%d, format_addr=0x%x, out_addr=0x%x)", handle, format.GetAddr(), out_addr);
cellVdec->Log("cellVdecGetPicture(handle=%d, format_addr=0x%x, out_addr=0x%x)", handle, format.addr(), out_addr);
VideoDecoder* vdec;
if (!Emu.GetIdManager().GetIDData(handle, vdec))
@ -670,9 +670,9 @@ int cellVdecGetPicture(u32 handle, const mem_ptr_t<CellVdecPicFormat> format, u3
return CELL_OK;
}
int cellVdecGetPicItem(u32 handle, mem32_t picItem_ptr)
int cellVdecGetPicItem(u32 handle, vm::ptr<be_t<u32>> picItem_ptr)
{
cellVdec->Log("cellVdecGetPicItem(handle=%d, picItem_ptr_addr=0x%x)", handle, picItem_ptr.GetAddr());
cellVdec->Log("cellVdecGetPicItem(handle=%d, picItem_ptr_addr=0x%x)", handle, picItem_ptr.addr());
VideoDecoder* vdec;
if (!Emu.GetIdManager().GetIDData(handle, vdec))
@ -690,7 +690,7 @@ int cellVdecGetPicItem(u32 handle, mem32_t picItem_ptr)
AVFrame& frame = *vf.data;
mem_ptr_t<CellVdecPicItem> info(vdec->memAddr + vdec->memBias);
auto info = vm::ptr<CellVdecPicItem>::make(vdec->memAddr + vdec->memBias);
vdec->memBias += 512;
if (vdec->memBias + 512 > vdec->memSize)
@ -702,11 +702,11 @@ int cellVdecGetPicItem(u32 handle, mem32_t picItem_ptr)
info->startAddr = 0x00000123; // invalid value (no address for picture)
info->size = a128(av_image_get_buffer_size(vdec->ctx->pix_fmt, vdec->ctx->width, vdec->ctx->height, 1));
info->auNum = 1;
info->auPts[0].lower = vf.pts;
info->auPts[0].lower = (u32)vf.pts;
info->auPts[0].upper = vf.pts >> 32;
info->auPts[1].lower = 0xffffffff;
info->auPts[1].upper = 0xffffffff;
info->auDts[0].lower = vf.dts;
info->auDts[0].lower = (u32)vf.dts;
info->auDts[0].upper = vf.dts >> 32;
info->auDts[1].lower = 0xffffffff;
info->auDts[1].upper = 0xffffffff;
@ -714,9 +714,9 @@ int cellVdecGetPicItem(u32 handle, mem32_t picItem_ptr)
info->auUserData[1] = 0;
info->status = CELL_OK;
info->attr = CELL_VDEC_PICITEM_ATTR_NORMAL;
info->picInfo_addr = info.GetAddr() + sizeof(CellVdecPicItem);
info->picInfo_addr = info.addr() + sizeof(CellVdecPicItem);
mem_ptr_t<CellVdecAvcInfo> avc(info.GetAddr() + sizeof(CellVdecPicItem));
auto avc = vm::ptr<CellVdecAvcInfo>::make(info.addr() + sizeof(CellVdecPicItem));
avc->horizontalSize = frame.width;
avc->verticalSize = frame.height;
@ -775,7 +775,7 @@ int cellVdecGetPicItem(u32 handle, mem32_t picItem_ptr)
avc->reserved[0] = 0;
avc->reserved[1] = 0;
picItem_ptr = info.GetAddr();
*picItem_ptr = info.addr();
return CELL_OK;
}

View file

@ -167,7 +167,7 @@ struct CellVdecPicFormat
u8 alpha;
};
typedef mem_func_ptr_t<void (*)(u32 handle_addr, CellVdecMsgType msgType, int msgData, u32 cbArg_addr)> CellVdecCbMsg;
typedef void(*CellVdecCbMsg)(u32 handle_addr, CellVdecMsgType msgType, int msgData, u32 cbArg_addr);
// Callback Function Information
struct CellVdecCb

View file

@ -14,9 +14,9 @@ extern "C"
//Module cellVpost(0x0008, cellVpost_init);
Module *cellVpost = nullptr;
int cellVpostQueryAttr(const mem_ptr_t<CellVpostCfgParam> cfgParam, mem_ptr_t<CellVpostAttr> attr)
int cellVpostQueryAttr(const vm::ptr<CellVpostCfgParam> cfgParam, vm::ptr<CellVpostAttr> attr)
{
cellVpost->Warning("cellVpostQueryAttr(cfgParam_addr=0x%x, attr_addr=0x%x)", cfgParam.GetAddr(), attr.GetAddr());
cellVpost->Warning("cellVpostQueryAttr(cfgParam_addr=0x%x, attr_addr=0x%x)", cfgParam.addr(), attr.addr());
// TODO: check cfgParam and output values
@ -37,23 +37,23 @@ u32 vpostOpen(VpostInstance* data)
return id;
}
int cellVpostOpen(const mem_ptr_t<CellVpostCfgParam> cfgParam, const mem_ptr_t<CellVpostResource> resource, mem32_t handle)
int cellVpostOpen(const vm::ptr<CellVpostCfgParam> cfgParam, const vm::ptr<CellVpostResource> resource, vm::ptr<be_t<u32>> handle)
{
cellVpost->Warning("cellVpostOpen(cfgParam_addr=0x%x, resource_addr=0x%x, handle_addr=0x%x)",
cfgParam.GetAddr(), resource.GetAddr(), handle.GetAddr());
cfgParam.addr(), resource.addr(), handle.addr());
// TODO: check values
handle = vpostOpen(new VpostInstance(cfgParam->outPicFmt == CELL_VPOST_PIC_FMT_OUT_RGBA_ILV));
*handle = vpostOpen(new VpostInstance(cfgParam->outPicFmt == CELL_VPOST_PIC_FMT_OUT_RGBA_ILV));
return CELL_OK;
}
int cellVpostOpenEx(const mem_ptr_t<CellVpostCfgParam> cfgParam, const mem_ptr_t<CellVpostResourceEx> resource, mem32_t handle)
int cellVpostOpenEx(const vm::ptr<CellVpostCfgParam> cfgParam, const vm::ptr<CellVpostResourceEx> resource, vm::ptr<be_t<u32>> handle)
{
cellVpost->Warning("cellVpostOpenEx(cfgParam_addr=0x%x, resource_addr=0x%x, handle_addr=0x%x)",
cfgParam.GetAddr(), resource.GetAddr(), handle.GetAddr());
cfgParam.addr(), resource.addr(), handle.addr());
// TODO: check values
handle = vpostOpen(new VpostInstance(cfgParam->outPicFmt == CELL_VPOST_PIC_FMT_OUT_RGBA_ILV));
*handle = vpostOpen(new VpostInstance(cfgParam->outPicFmt == CELL_VPOST_PIC_FMT_OUT_RGBA_ILV));
return CELL_OK;
}
@ -71,11 +71,11 @@ int cellVpostClose(u32 handle)
return CELL_OK;
}
int cellVpostExec(u32 handle, const u32 inPicBuff_addr, const mem_ptr_t<CellVpostCtrlParam> ctrlParam,
u32 outPicBuff_addr, mem_ptr_t<CellVpostPictureInfo> picInfo)
int cellVpostExec(u32 handle, const u32 inPicBuff_addr, const vm::ptr<CellVpostCtrlParam> ctrlParam,
u32 outPicBuff_addr, vm::ptr<CellVpostPictureInfo> picInfo)
{
cellVpost->Log("cellVpostExec(handle=0x%x, inPicBuff_addr=0x%x, ctrlParam_addr=0x%x, outPicBuff_addr=0x%x, picInfo_addr=0x%x)",
handle, inPicBuff_addr, ctrlParam.GetAddr(), outPicBuff_addr, picInfo.GetAddr());
handle, inPicBuff_addr, ctrlParam.addr(), outPicBuff_addr, picInfo.addr());
VpostInstance* vpost;
if (!Emu.GetIdManager().GetIDData(handle, vpost))

View file

@ -141,10 +141,10 @@ int cellAANDisconnect(u32 receive, u32 receivePortNo, u32 source, u32 sourcePort
return CELL_OK;
}
int cellSSPlayerCreate(mem32_t handle, mem_ptr_t<CellSSPlayerConfig> config)
int cellSSPlayerCreate(vm::ptr<be_t<u32>> handle, vm::ptr<CellSSPlayerConfig> config)
{
libmixer->Warning("cellSSPlayerCreate(handle_addr=0x%x, config_addr=0x%x)",
handle.GetAddr(), config.GetAddr());
handle.addr(), config.addr());
if (config->outputMode != 0 || config->channels - 1 >= 2)
{
@ -162,7 +162,7 @@ int cellSSPlayerCreate(mem32_t handle, mem_ptr_t<CellSSPlayerConfig> config)
p.m_channels = config->channels;
ssp.push_back(p);
handle = ssp.size() - 1;
*handle = (u32)ssp.size() - 1;
return CELL_OK;
}
@ -185,10 +185,10 @@ int cellSSPlayerRemove(u32 handle)
return CELL_OK;
}
int cellSSPlayerSetWave(u32 handle, mem_ptr_t<CellSSPlayerWaveParam> waveInfo, mem_ptr_t<CellSSPlayerCommonParam> commonInfo)
int cellSSPlayerSetWave(u32 handle, vm::ptr<CellSSPlayerWaveParam> waveInfo, vm::ptr<CellSSPlayerCommonParam> commonInfo)
{
libmixer->Warning("cellSSPlayerSetWave(handle=%d, waveInfo_addr=0x%x, commonInfo_addr=0x%x)",
handle, waveInfo.GetAddr(), commonInfo.GetAddr());
handle, waveInfo.addr(), commonInfo.addr());
std::lock_guard<std::mutex> lock(mixer_mutex);
@ -203,15 +203,15 @@ int cellSSPlayerSetWave(u32 handle, mem_ptr_t<CellSSPlayerWaveParam> waveInfo, m
ssp[handle].m_addr = waveInfo->addr;
ssp[handle].m_samples = waveInfo->samples;
ssp[handle].m_loop_start = waveInfo->loopStartOffset - 1;
ssp[handle].m_loop_mode = commonInfo.GetAddr() ? (u32)commonInfo->loopMode : CELL_SSPLAYER_ONESHOT;
ssp[handle].m_loop_mode = commonInfo ? (u32)commonInfo->loopMode : CELL_SSPLAYER_ONESHOT;
ssp[handle].m_position = waveInfo->startOffset - 1;
return CELL_OK;
}
int cellSSPlayerPlay(u32 handle, mem_ptr_t<CellSSPlayerRuntimeInfo> info)
int cellSSPlayerPlay(u32 handle, vm::ptr<CellSSPlayerRuntimeInfo> info)
{
libmixer->Warning("cellSSPlayerPlay(handle=%d, info_addr=0x%x)", handle, info.GetAddr());
libmixer->Warning("cellSSPlayerPlay(handle=%d, info_addr=0x%x)", handle, info.addr());
std::lock_guard<std::mutex> lock(mixer_mutex);
@ -252,9 +252,9 @@ int cellSSPlayerStop(u32 handle, u32 mode)
return CELL_OK;
}
int cellSSPlayerSetParam(u32 handle, mem_ptr_t<CellSSPlayerRuntimeInfo> info)
int cellSSPlayerSetParam(u32 handle, vm::ptr<CellSSPlayerRuntimeInfo> info)
{
libmixer->Warning("cellSSPlayerSetParam(handle=%d, info_addr=0x%x)", handle, info.GetAddr());
libmixer->Warning("cellSSPlayerSetParam(handle=%d, info_addr=0x%x)", handle, info.addr());
std::lock_guard<std::mutex> lock(mixer_mutex);
@ -295,9 +295,9 @@ int cellSSPlayerGetState(u32 handle)
return CELL_SSPLAYER_STATE_OFF;
}
int cellSurMixerCreate(const mem_ptr_t<CellSurMixerConfig> config)
int cellSurMixerCreate(const vm::ptr<CellSurMixerConfig> config)
{
libmixer->Warning("cellSurMixerCreate(config_addr=0x%x)", config.GetAddr());
libmixer->Warning("cellSurMixerCreate(config_addr=0x%x)", config.addr());
surMixer = *config;
@ -361,6 +361,7 @@ int cellSurMixerCreate(const mem_ptr_t<CellSurMixerConfig> config)
for (auto& p : ssp) if (p.m_active && p.m_created)
{
auto v = vm::lptrl<s16>::make(p.m_addr); // 16-bit LE audio data
float left = 0.0f;
float right = 0.0f;
float speed = fabs(p.m_speed);
@ -398,15 +399,12 @@ int cellSurMixerCreate(const mem_ptr_t<CellSurMixerConfig> config)
p.m_position += (u32)pos_inc;
if (p.m_channels == 1) // get mono data
{
mem16_t v(p.m_addr + pos * sizeof(u16));
left = right = (float)(s16)re16(v.GetValue()) / 0x8000 * p.m_level;
left = right = (float)v[pos] / 0x8000 * p.m_level;
}
else if (p.m_channels == 2) // get stereo data
{
mem16_t v1(p.m_addr + (pos * 2 + 0) * sizeof(u16));
mem16_t v2(p.m_addr + (pos * 2 + 1) * sizeof(u16));
left = (float)(s16)re16(v1.GetValue()) / 0x8000 * p.m_level;
right = (float)(s16)re16(v2.GetValue()) / 0x8000 * p.m_level;
left = (float)v[pos * 2 + 0] / 0x8000 * p.m_level;
right = (float)v[pos * 2 + 1] / 0x8000 * p.m_level;
}
if (p.m_connected) // mix
{
@ -465,17 +463,17 @@ int cellSurMixerCreate(const mem_ptr_t<CellSurMixerConfig> config)
return CELL_OK;
}
int cellSurMixerGetAANHandle(mem32_t handle)
int cellSurMixerGetAANHandle(vm::ptr<be_t<u32>> handle)
{
libmixer->Warning("cellSurMixerGetAANHandle(handle_addr=0x%x) -> %d", handle.GetAddr(), 0x11111111);
handle = 0x11111111;
libmixer->Warning("cellSurMixerGetAANHandle(handle_addr=0x%x) -> %d", handle.addr(), 0x11111111);
*handle = 0x11111111;
return CELL_OK;
}
int cellSurMixerChStripGetAANPortNo(mem32_t port, u32 type, u32 index)
int cellSurMixerChStripGetAANPortNo(vm::ptr<be_t<u32>> port, u32 type, u32 index)
{
libmixer->Warning("cellSurMixerChStripGetAANPortNo(port_addr=0x%x, type=0x%x, index=0x%x) -> 0x%x", port.GetAddr(), type, index, (type << 16) | index);
port = (type << 16) | index;
libmixer->Warning("cellSurMixerChStripGetAANPortNo(port_addr=0x%x, type=0x%x, index=0x%x) -> 0x%x", port.addr(), type, index, (type << 16) | index);
*port = (type << 16) | index;
return CELL_OK;
}
@ -556,9 +554,9 @@ int cellSurMixerSurBusAddData(u32 busNo, u32 offset, u32 addr, u32 samples)
return CELL_OK;
}
int cellSurMixerChStripSetParameter(u32 type, u32 index, mem_ptr_t<CellSurMixerChStripParam> param)
int cellSurMixerChStripSetParameter(u32 type, u32 index, vm::ptr<CellSurMixerChStripParam> param)
{
libmixer->Todo("cellSurMixerChStripSetParameter(type=%d, index=%d, param_addr=0x%x)", type, index, param.GetAddr());
libmixer->Todo("cellSurMixerChStripSetParameter(type=%d, index=%d, param_addr=0x%x)", type, index, param.addr());
return CELL_OK;
}
@ -576,19 +574,19 @@ int cellSurMixerPause(u32 type)
return CELL_OK;
}
int cellSurMixerGetCurrentBlockTag(mem64_t tag)
int cellSurMixerGetCurrentBlockTag(vm::ptr<be_t<u64>> tag)
{
libmixer->Log("cellSurMixerGetCurrentBlockTag(tag_addr=0x%x)", tag.GetAddr());
libmixer->Log("cellSurMixerGetCurrentBlockTag(tag_addr=0x%x)", tag.addr());
tag = mixcount;
*tag = mixcount;
return CELL_OK;
}
int cellSurMixerGetTimestamp(u64 tag, mem64_t stamp)
int cellSurMixerGetTimestamp(u64 tag, vm::ptr<be_t<u64>> stamp)
{
libmixer->Log("cellSurMixerGetTimestamp(tag=0x%llx, stamp_addr=0x%x)", tag, stamp.GetAddr());
libmixer->Log("cellSurMixerGetTimestamp(tag=0x%llx, stamp_addr=0x%x)", tag, stamp.addr());
stamp = m_config.start_time + (tag) * 256000000 / 48000; // ???
*stamp = m_config.start_time + (tag) * 256000000 / 48000; // ???
return CELL_OK;
}

View file

@ -58,15 +58,15 @@ u32 cellSoundSynth2GetAddr(u16 reg)
return 0;
}
int cellSoundSynth2SetEffectAttr(s16 bus, mem_ptr_t<CellSoundSynth2EffectAttr> attr)
int cellSoundSynth2SetEffectAttr(s16 bus, vm::ptr<CellSoundSynth2EffectAttr> attr)
{
libsynth2.Todo("cellSoundSynth2SetEffectAttr(bus=%d, attr_addr=0x%x)", bus, attr.GetAddr());
libsynth2.Todo("cellSoundSynth2SetEffectAttr(bus=%d, attr_addr=0x%x)", bus, attr.addr());
return CELL_OK;
}
int cellSoundSynth2SetEffectMode(s16 bus, mem_ptr_t<CellSoundSynth2EffectAttr> attr)
int cellSoundSynth2SetEffectMode(s16 bus, vm::ptr<CellSoundSynth2EffectAttr> attr)
{
libsynth2.Todo("cellSoundSynth2SetEffectMode(bus=%d, attr_addr=0x%x)", bus, attr.GetAddr());
libsynth2.Todo("cellSoundSynth2SetEffectMode(bus=%d, attr_addr=0x%x)", bus, attr.addr());
return CELL_OK;
}

View file

@ -177,20 +177,20 @@ int sceNpDrmExecuteGamePurchase()
return CELL_OK;
}
int sceNpDrmGetTimelimit(u32 drm_path_addr, mem64_t time_remain_usec)
int sceNpDrmGetTimelimit(u32 drm_path_addr, vm::ptr<be_t<u64>> time_remain_usec)
{
UNIMPLEMENTED_FUNC(sceNp);
return CELL_OK;
}
int sceNpManagerGetStatus(mem32_t status)
int sceNpManagerGetStatus(vm::ptr<be_t<u32>> status)
{
sceNp->Log("sceNpManagerGetStatus(status_addr=0x%x)", status.GetAddr());
sceNp->Log("sceNpManagerGetStatus(status_addr=0x%x)", status.addr());
// TODO: Check if sceNpInit() was called, if not return SCE_NP_ERROR_NOT_INITIALIZED
// TODO: Support different statuses
status = SCE_NP_MANAGER_STATUS_OFFLINE;
*status = SCE_NP_MANAGER_STATUS_OFFLINE;
return CELL_OK;
}

View file

@ -85,10 +85,10 @@ int sceNpTrophyInit(u32 pool_addr, u32 poolSize, u32 containerId, u64 options)
return CELL_OK;
}
int sceNpTrophyCreateContext(mem32_t context, mem_ptr_t<SceNpCommunicationId> commID, mem_ptr_t<SceNpCommunicationSignature> commSign, u64 options)
int sceNpTrophyCreateContext(vm::ptr<be_t<u32>> context, vm::ptr<SceNpCommunicationId> commID, vm::ptr<SceNpCommunicationSignature> commSign, u64 options)
{
sceNpTrophy->Warning("sceNpTrophyCreateContext(context_addr=0x%x, commID_addr=0x%x, commSign_addr=0x%x, options=0x%llx)",
context.GetAddr(), commID.GetAddr(), commSign.GetAddr(), options);
context.addr(), commID.addr(), commSign.addr(), options);
if (!s_npTrophyInstance.m_bInitialized)
return SCE_NP_TROPHY_ERROR_NOT_INITIALIZED;
@ -123,9 +123,9 @@ int sceNpTrophyCreateContext(mem32_t context, mem_ptr_t<SceNpCommunicationId> co
return SCE_NP_TROPHY_ERROR_CONF_DOES_NOT_EXIST;
}
int sceNpTrophyCreateHandle(mem32_t handle)
int sceNpTrophyCreateHandle(vm::ptr<be_t<u32>> handle)
{
sceNpTrophy->Warning("sceNpTrophyCreateHandle(handle_addr=0x%x)", handle.GetAddr());
sceNpTrophy->Warning("sceNpTrophyCreateHandle(handle_addr=0x%x)", handle.addr());
if (!s_npTrophyInstance.m_bInitialized)
return SCE_NP_TROPHY_ERROR_NOT_INITIALIZED;
@ -136,10 +136,10 @@ int sceNpTrophyCreateHandle(mem32_t handle)
return CELL_OK;
}
int sceNpTrophyRegisterContext(u32 context, u32 handle, mem_func_ptr_t<SceNpTrophyStatusCallback> statusCb, u32 arg_addr, u64 options)
int sceNpTrophyRegisterContext(u32 context, u32 handle, vm::ptr<SceNpTrophyStatusCallback> statusCb, u32 arg_addr, u64 options)
{
sceNpTrophy->Warning("sceNpTrophyRegisterContext(context=%d, handle=%d, statusCb_addr=0x%x, arg_addr=0x%x, options=0x%llx)",
context, handle, statusCb.GetAddr(), arg_addr, options);
context, handle, statusCb.addr(), arg_addr, options);
if (!(s_npTrophyInstance.m_bInitialized))
return SCE_NP_TROPHY_ERROR_NOT_INITIALIZED;
@ -213,10 +213,10 @@ int sceNpTrophySetSoundLevel()
return CELL_OK;
}
int sceNpTrophyGetRequiredDiskSpace(u32 context, u32 handle, mem64_t reqspace, u64 options)
int sceNpTrophyGetRequiredDiskSpace(u32 context, u32 handle, vm::ptr<be_t<u64>> reqspace, u64 options)
{
sceNpTrophy->Warning("sceNpTrophyGetRequiredDiskSpace(context=%d, handle=%d, reqspace_addr=0x%x, options=0x%llx)",
context, handle, reqspace.GetAddr(), options);
context, handle, reqspace.addr(), options);
if (!s_npTrophyInstance.m_bInitialized)
return SCE_NP_TROPHY_ERROR_NOT_INITIALIZED;
@ -228,7 +228,7 @@ int sceNpTrophyGetRequiredDiskSpace(u32 context, u32 handle, mem64_t reqspace, u
if (!ctxt.trp_stream)
return SCE_NP_TROPHY_ERROR_CONF_DOES_NOT_EXIST;
reqspace = ctxt.trp_stream->GetSize(); // TODO: This is not accurate. It's just an approximation of the real value
*reqspace = ctxt.trp_stream->GetSize(); // TODO: This is not accurate. It's just an approximation of the real value
return CELL_OK;
}
@ -244,10 +244,10 @@ int sceNpTrophyAbortHandle()
return CELL_OK;
}
int sceNpTrophyGetGameInfo(u32 context, u32 handle, mem_ptr_t<SceNpTrophyGameDetails> details, mem_ptr_t<SceNpTrophyGameData> data)
int sceNpTrophyGetGameInfo(u32 context, u32 handle, vm::ptr<SceNpTrophyGameDetails> details, vm::ptr<SceNpTrophyGameData> data)
{
sceNpTrophy->Warning("sceNpTrophyGetGameInfo(context=%d, handle=%d, details_addr=0x%x, data_addr=0x%x)",
context, handle, details.GetAddr(), data.GetAddr());
context, handle, details.addr(), data.addr());
if (!s_npTrophyInstance.m_bInitialized)
return SCE_NP_TROPHY_ERROR_NOT_INITIALIZED;
@ -302,10 +302,10 @@ int sceNpTrophyDestroyHandle()
return CELL_OK;
}
int sceNpTrophyUnlockTrophy(u32 context, u32 handle, s32 trophyId, mem32_t platinumId)
int sceNpTrophyUnlockTrophy(u32 context, u32 handle, s32 trophyId, vm::ptr<be_t<u32>> platinumId)
{
sceNpTrophy->Warning("sceNpTrophyUnlockTrophy(context=%d, handle=%d, trophyId=%d, platinumId_addr=0x%x)",
context, handle, trophyId, platinumId.GetAddr());
context, handle, trophyId, platinumId.addr());
if (!s_npTrophyInstance.m_bInitialized)
return SCE_NP_TROPHY_ERROR_NOT_INITIALIZED;
@ -323,7 +323,7 @@ int sceNpTrophyUnlockTrophy(u32 context, u32 handle, s32 trophyId, mem32_t plati
std::string trophyPath = "/dev_hdd0/home/00000001/trophy/" + ctxt.trp_name + "/TROPUSR.DAT";
ctxt.tropusr->Save(trophyPath);
platinumId = SCE_NP_TROPHY_INVALID_TROPHY_ID; // TODO
*platinumId = SCE_NP_TROPHY_INVALID_TROPHY_ID; // TODO
return CELL_OK;
}
@ -333,22 +333,22 @@ int sceNpTrophyTerm()
return CELL_OK;
}
int sceNpTrophyGetTrophyUnlockState(u32 context, u32 handle, mem_ptr_t<SceNpTrophyFlagArray> flags, mem32_t count)
int sceNpTrophyGetTrophyUnlockState(u32 context, u32 handle, vm::ptr<SceNpTrophyFlagArray> flags, vm::ptr<be_t<u32>> count)
{
sceNpTrophy->Warning("sceNpTrophyGetTrophyUnlockState(context=%d, handle=%d, flags_addr=0x%x, count_addr=0x%x)",
context, handle, flags.GetAddr(), count.GetAddr());
context, handle, flags.addr(), count.addr());
if (!s_npTrophyInstance.m_bInitialized)
return SCE_NP_TROPHY_ERROR_NOT_INITIALIZED;
// TODO: There are other possible errors
sceNpTrophyInternalContext& ctxt = s_npTrophyInstance.contexts[context];
count = ctxt.tropusr->GetTrophiesCount();
if (count.GetValue() > 128)
*count = ctxt.tropusr->GetTrophiesCount();
if (*count > 128)
sceNpTrophy->Warning("sceNpTrophyGetTrophyUnlockState: More than 128 trophies detected!");
// Pack up to 128 bools in u32 flag_bits[4]
for (u32 id=0; id<count.GetValue(); id++)
for (u32 id=0; id<*count; id++)
{
if (ctxt.tropusr->GetTrophyUnlockState(id))
flags->flag_bits[id/32] |= 1<<(id%32);
@ -365,10 +365,10 @@ int sceNpTrophyGetTrophyIcon()
return CELL_OK;
}
int sceNpTrophyGetTrophyInfo(u32 context, u32 handle, s32 trophyId, mem_ptr_t<SceNpTrophyDetails> details, mem_ptr_t<SceNpTrophyData> data)
int sceNpTrophyGetTrophyInfo(u32 context, u32 handle, s32 trophyId, vm::ptr<SceNpTrophyDetails> details, vm::ptr<SceNpTrophyData> data)
{
sceNpTrophy->Warning("sceNpTrophyGetTrophyInfo(context=%u, handle=%u, trophyId=%d, details_addr=0x%x, data_addr=0x%x)",
context, handle, trophyId, details.GetAddr(), data.GetAddr());
context, handle, trophyId, details.addr(), data.addr());
if (!s_npTrophyInstance.m_bInitialized)
return SCE_NP_TROPHY_ERROR_NOT_INITIALIZED;
@ -404,7 +404,7 @@ int sceNpTrophyGetTrophyInfo(u32 context, u32 handle, s32 trophyId, mem_ptr_t<Sc
}
data->trophyId = trophyId;
data->unlocked = ctxt.tropusr->GetTrophyUnlockState(trophyId);
data->unlocked = ctxt.tropusr->GetTrophyUnlockState(trophyId) ? true : false; // ???
data->timestamp.tick = ctxt.tropusr->GetTrophyTimestamp(trophyId);
}
}

View file

@ -32,24 +32,24 @@ int _sys_heap_create_heap(const u32 heap_addr, const u32 align, const u32 size)
return heap_id;
}
int _sys_heap_malloc(const u32 heap_id, const u32 size)
u32 _sys_heap_malloc(const u32 heap_id, const u32 size)
{
sysPrxForUser->Warning("_sys_heap_malloc(heap_id=%d, size=0x%x)", heap_id, size);
HeapInfo* heap;
if(!sysPrxForUser->CheckId(heap_id, heap)) return CELL_ESRCH;
return Memory.Alloc(size, 1);
return (u32)Memory.Alloc(size, 1);
}
int _sys_heap_memalign(u32 heap_id, u32 align, u32 size)
u32 _sys_heap_memalign(u32 heap_id, u32 align, u32 size)
{
sysPrxForUser->Warning("_sys_heap_memalign(heap_id=%d, align=0x%x, size=0x%x)", heap_id, align, size);
HeapInfo* heap;
if(!sysPrxForUser->CheckId(heap_id, heap)) return CELL_ESRCH;
return Memory.Alloc(size, align);
return (u32)Memory.Alloc(size, align);
}
void sys_initialize_tls()
@ -83,21 +83,21 @@ s64 sys_prx_exitspawn_with_level()
return CELL_OK;
}
int sys_spu_elf_get_information(u32 elf_img, mem32_t entry, mem32_t nseg)
int sys_spu_elf_get_information(u32 elf_img, vm::ptr<be_t<u32>> entry, vm::ptr<be_t<u32>> nseg)
{
sysPrxForUser->Warning("sys_spu_elf_get_information(elf_img=0x%x, entry_addr=0x%x, nseg_addr=0x%x", elf_img, entry.GetAddr(), nseg.GetAddr());
sysPrxForUser->Todo("sys_spu_elf_get_information(elf_img=0x%x, entry_addr=0x%x, nseg_addr=0x%x", elf_img, entry.addr(), nseg.addr());
return CELL_OK;
}
int sys_spu_elf_get_segments(u32 elf_img, mem_ptr_t<sys_spu_segment> segments, int nseg)
int sys_spu_elf_get_segments(u32 elf_img, vm::ptr<sys_spu_segment> segments, int nseg)
{
sysPrxForUser->Warning("sys_spu_elf_get_segments(elf_img=0x%x, segments_addr=0x%x, nseg=0x%x)", elf_img, segments.GetAddr(), nseg);
sysPrxForUser->Todo("sys_spu_elf_get_segments(elf_img=0x%x, segments_addr=0x%x, nseg=0x%x)", elf_img, segments.addr(), nseg);
return CELL_OK;
}
int sys_spu_image_import(mem_ptr_t<sys_spu_image> img, u32 src, u32 type)
int sys_spu_image_import(vm::ptr<sys_spu_image> img, u32 src, u32 type)
{
sysPrxForUser->Warning("sys_spu_image_import(img=0x%x, src=0x%x, type=0x%x)", img.GetAddr(), src, type);
sysPrxForUser->Warning("sys_spu_image_import(img=0x%x, src=0x%x, type=0x%x)", img.addr(), src, type);
vfsStreamMemory f(src);
u32 entry;
@ -111,17 +111,17 @@ int sys_spu_image_import(mem_ptr_t<sys_spu_image> img, u32 src, u32 type)
return CELL_OK;
}
int sys_spu_image_close(mem_ptr_t<sys_spu_image> img)
int sys_spu_image_close(vm::ptr<sys_spu_image> img)
{
sysPrxForUser->Warning("sys_spu_image_close(img=0x%x)", img.GetAddr());
sysPrxForUser->Warning("sys_spu_image_close(img=0x%x)", img.addr());
return CELL_OK;
}
int sys_raw_spu_load(int id, u32 path_addr, mem32_t entry)
int sys_raw_spu_load(int id, u32 path_addr, vm::ptr<be_t<u32>> entry)
{
const std::string path = Memory.ReadString(path_addr);
sysPrxForUser->Warning("sys_raw_spu_load(id=0x%x, path=0x%x [%s], entry_addr=0x%x)",
id, path_addr, path.c_str(), entry.GetAddr());
id, path_addr, path.c_str(), entry.addr());
vfsFile f(path);
if(!f.IsOpened())
@ -134,14 +134,14 @@ int sys_raw_spu_load(int id, u32 path_addr, mem32_t entry)
l.LoadInfo();
l.LoadData(RAW_SPU_BASE_ADDR + RAW_SPU_OFFSET * id);
entry = l.GetEntry();
*entry = l.GetEntry();
return CELL_OK;
}
int sys_raw_spu_image_load(int id, mem_ptr_t<sys_spu_image> img)
int sys_raw_spu_image_load(int id, vm::ptr<sys_spu_image> img)
{
sysPrxForUser->Warning("sys_raw_spu_image_load(id=0x%x, img_addr=0x%x)", id, img.GetAddr());
sysPrxForUser->Warning("sys_raw_spu_image_load(id=0x%x, img_addr=0x%x)", id, img.addr());
memcpy(Memory + (RAW_SPU_BASE_ADDR + RAW_SPU_OFFSET * id), Memory + (u32)img->segs_addr, 256 * 1024);
Memory.Write32(RAW_SPU_BASE_ADDR + RAW_SPU_OFFSET * id + RAW_SPU_PROB_OFFSET + SPU_NPC_offs, (u32)img->entry_point);
@ -172,7 +172,7 @@ s32 _sys_memcmp(u32 addr1, u32 addr2, u32 size)
return memcmp(Memory + addr1, Memory + addr2, size);
}
s32 _sys_strlen(u32 addr)
s64 _sys_strlen(u32 addr)
{
sysPrxForUser->Log("_sys_strlen(addr=0x%x)", addr);
@ -251,7 +251,7 @@ s32 _sys_spu_printf_finalize()
return CELL_OK;
}
s32 _sys_spu_printf_attach_group(u32 arg)
s64 _sys_spu_printf_attach_group(u32 arg)
{
sysPrxForUser->Warning("_sys_spu_printf_attach_group(arg=0x%x)", arg);
@ -263,7 +263,7 @@ s32 _sys_spu_printf_attach_group(u32 arg)
return GetCurrentPPUThread().FastCall(Memory.Read32(spu_printf_agcb), Memory.Read32(spu_printf_agcb + 4), arg);
}
s32 _sys_spu_printf_detach_group(u32 arg)
s64 _sys_spu_printf_detach_group(u32 arg)
{
sysPrxForUser->Warning("_sys_spu_printf_detach_group(arg=0x%x)", arg);
@ -275,7 +275,7 @@ s32 _sys_spu_printf_detach_group(u32 arg)
return GetCurrentPPUThread().FastCall(Memory.Read32(spu_printf_dgcb), Memory.Read32(spu_printf_dgcb + 4), arg);
}
s32 _sys_spu_printf_attach_thread(u32 arg)
s64 _sys_spu_printf_attach_thread(u32 arg)
{
sysPrxForUser->Warning("_sys_spu_printf_attach_thread(arg=0x%x)", arg);
@ -287,7 +287,7 @@ s32 _sys_spu_printf_attach_thread(u32 arg)
return GetCurrentPPUThread().FastCall(Memory.Read32(spu_printf_atcb), Memory.Read32(spu_printf_atcb + 4), arg);
}
s32 _sys_spu_printf_detach_thread(u32 arg)
s64 _sys_spu_printf_detach_thread(u32 arg)
{
sysPrxForUser->Warning("_sys_spu_printf_detach_thread(arg=0x%x)", arg);

View file

@ -66,7 +66,7 @@ int sdata_unpack(const std::string& packed_file, const std::string& unpacked_fil
u32 blockSize = re32(*(u32*)&buffer[0x84]);
u64 filesizeOutput = re64(*(u64*)&buffer[0x88]);
u64 filesizeInput = packed_stream->GetSize();
u32 blockCount = (filesizeOutput + blockSize-1) / blockSize;
u32 blockCount = (u32)((filesizeOutput + blockSize - 1) / blockSize);
// SDATA file is compressed
if (flags & 0x1)
@ -99,7 +99,7 @@ int sdata_unpack(const std::string& packed_file, const std::string& unpacked_fil
packed_stream->Seek(packed_stream->Tell() + t1);
if (!(blockCount-i-1))
blockSize = filesizeOutput-i*blockSize;
blockSize = (u32)(filesizeOutput - i * blockSize);
packed_stream->Read(buffer+256, blockSize);
unpacked_stream->Write(buffer+256, blockSize);
@ -110,11 +110,11 @@ int sdata_unpack(const std::string& packed_file, const std::string& unpacked_fil
}
int cellFsSdataOpen(u32 path_addr, int flags, mem32_t fd, mem32_t arg, u64 size)
int cellFsSdataOpen(u32 path_addr, int flags, vm::ptr<be_t<u32>> fd, vm::ptr<be_t<u32>> arg, u64 size)
{
const std::string& path = Memory.ReadString(path_addr);
sys_fs->Warning("cellFsSdataOpen(path=\"%s\", flags=0x%x, fd_addr=0x%x, arg_addr=0x%x, size=0x%llx) -> cellFsOpen()",
path.c_str(), flags, fd.GetAddr(), arg.GetAddr(), size);
path.c_str(), flags, fd.addr(), arg.addr(), size);
/*if (flags != CELL_O_RDONLY)
return CELL_EINVAL;
@ -136,9 +136,10 @@ int cellFsSdataOpen(u32 path_addr, int flags, mem32_t fd, mem32_t arg, u64 size)
return cellFsOpen(path_addr, flags, fd, arg, size);
}
int cellFsSdataOpenByFd(int mself_fd, int flags, mem32_t sdata_fd, u64 offset, mem32_t arg, u64 size)
int cellFsSdataOpenByFd(int mself_fd, int flags, vm::ptr<be_t<u32>> sdata_fd, u64 offset, vm::ptr<be_t<u32>> arg, u64 size)
{
sys_fs->Todo("cellFsSdataOpenByFd(mself_fd=0x%x, flags=0x%x, sdata_fd_addr=0x%x, offset=0x%llx, arg_addr=0x%x, size=0x%llx) -> cellFsOpen()", mself_fd, flags, sdata_fd.GetAddr(), offset, arg.GetAddr(), size);
sys_fs->Todo("cellFsSdataOpenByFd(mself_fd=0x%x, flags=0x%x, sdata_fd_addr=0x%x, offset=0x%llx, arg_addr=0x%x, size=0x%llx) -> cellFsOpen()",
mself_fd, flags, sdata_fd.addr(), offset, arg.addr(), size);
// TODO:
@ -149,7 +150,7 @@ std::atomic<u32> g_FsAioReadID( 0 );
std::atomic<u32> g_FsAioReadCur( 0 );
bool aio_init = false;
void fsAioRead(u32 fd, mem_ptr_t<CellFsAio> aio, int xid, mem_func_ptr_t<void (*)(mem_ptr_t<CellFsAio> xaio, int error, int xid, u64 size)> func)
void fsAioRead(u32 fd, vm::ptr<CellFsAio> aio, int xid, vm::ptr<void (*)(vm::ptr<CellFsAio> xaio, int error, int xid, u64 size)> func)
{
while (g_FsAioReadCur != xid)
{
@ -198,9 +199,9 @@ void fsAioRead(u32 fd, mem_ptr_t<CellFsAio> aio, int xid, mem_func_ptr_t<void (*
g_FsAioReadCur++;
}
int cellFsAioRead(mem_ptr_t<CellFsAio> aio, mem32_t aio_id, mem_func_ptr_t<void (*)(mem_ptr_t<CellFsAio> xaio, int error, int xid, u64 size)> func)
int cellFsAioRead(vm::ptr<CellFsAio> aio, vm::ptr<be_t<u32>> aio_id, vm::ptr<void(*)(vm::ptr<CellFsAio> xaio, int error, int xid, u64 size)> func)
{
sys_fs->Warning("cellFsAioRead(aio_addr=0x%x, id_addr=0x%x, func_addr=0x%x)", aio.GetAddr(), aio_id.GetAddr(), func.GetAddr());
sys_fs->Warning("cellFsAioRead(aio_addr=0x%x, id_addr=0x%x, func_addr=0x%x)", aio.addr(), aio_id.addr(), func.addr());
if (!aio_init)
{
@ -217,7 +218,7 @@ int cellFsAioRead(mem_ptr_t<CellFsAio> aio, mem32_t aio_id, mem_func_ptr_t<void
//get a unique id for the callback (may be used by cellFsAioCancel)
const u32 xid = g_FsAioReadID++;
aio_id = xid;
*aio_id = xid;
{
thread t("fsAioRead", std::bind(fsAioRead, fd, aio, xid, func));
@ -227,45 +228,43 @@ int cellFsAioRead(mem_ptr_t<CellFsAio> aio, mem32_t aio_id, mem_func_ptr_t<void
return CELL_OK;
}
int cellFsAioWrite(mem_ptr_t<CellFsAio> aio, mem32_t aio_id, mem_func_ptr_t<void(*)(mem_ptr_t<CellFsAio> xaio, int error, int xid, u64 size)> func)
int cellFsAioWrite(vm::ptr<CellFsAio> aio, vm::ptr<be_t<u32>> aio_id, vm::ptr<void(*)(vm::ptr<CellFsAio> xaio, int error, int xid, u64 size)> func)
{
sys_fs->Todo("cellFsAioWrite(aio_addr=0x%x, id_addr=0x%x, func_addr=0x%x)", aio.GetAddr(), aio_id.GetAddr(), func.GetAddr());
sys_fs->Todo("cellFsAioWrite(aio_addr=0x%x, id_addr=0x%x, func_addr=0x%x)", aio.addr(), aio_id.addr(), func.addr());
// TODO:
return CELL_OK;
}
int cellFsAioInit(mem8_ptr_t mount_point)
int cellFsAioInit(vm::ptr<const char> mount_point)
{
std::string mp = Memory.ReadString(mount_point.GetAddr());
sys_fs->Warning("cellFsAioInit(mount_point_addr=0x%x (%s))", mount_point.GetAddr(), mp.c_str());
sys_fs->Warning("cellFsAioInit(mount_point_addr=0x%x (%s))", mount_point.addr(), mount_point.get_ptr());
aio_init = true;
return CELL_OK;
}
int cellFsAioFinish(mem8_ptr_t mount_point)
int cellFsAioFinish(vm::ptr<const char> mount_point)
{
std::string mp = Memory.ReadString(mount_point.GetAddr());
sys_fs->Warning("cellFsAioFinish(mount_point_addr=0x%x (%s))", mount_point.GetAddr(), mp.c_str());
sys_fs->Warning("cellFsAioFinish(mount_point_addr=0x%x (%s))", mount_point.addr(), mount_point.get_ptr());
aio_init = false;
return CELL_OK;
}
int cellFsReadWithOffset(u32 fd, u64 offset, u32 buf_addr, u64 buffer_size, mem64_t nread)
int cellFsReadWithOffset(u32 fd, u64 offset, u32 buf_addr, u64 buffer_size, vm::ptr<be_t<u64>> nread)
{
sys_fs->Warning("cellFsReadWithOffset(fd=%d, offset=0x%llx, buf_addr=0x%x, buffer_size=%lld nread=0x%llx)",
fd, offset, buf_addr, buffer_size, nread.GetAddr());
fd, offset, buf_addr, buffer_size, nread.addr());
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); // 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); // Move to the specified offset
if (ret) return ret;
ret = cellFsRead(fd, buf_addr, buffer_size, nread.GetAddr()); // Read the file
ret = cellFsRead(fd, buf_addr, buffer_size, nread); // 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); // Return to the old position
if (ret) return ret;
return CELL_OK;

View file

@ -23,7 +23,7 @@ extern int cellPadInfoPressMode(u32 port_no);
extern int cellPadInfoSensorMode(u32 port_no);
extern int cellPadSetPressMode(u32 port_no, u32 mode);
extern int cellPadSetSensorMode(u32 port_no, u32 mode);
extern int cellPadGetCapabilityInfo(u32 port_no, mem32_t info_addr);
extern int cellPadGetCapabilityInfo(u32 port_no, vm::ptr<be_t<u32>> info_addr);
void sys_io_init()
{

View file

@ -21,7 +21,7 @@ extern "C"
//Module sys_net((u16)0x0000, sys_net_init);
Module *sys_net = nullptr;
mem32_t g_lastError(0);
vm::ptr<be_t<s32>> g_lastError = vm::ptr<be_t<s32>>::make(0);
// Auxiliary Functions
@ -94,48 +94,48 @@ using pck_len_t = u32;
#endif
// Functions
int sys_net_accept(s32 s, mem_ptr_t<sys_net_sockaddr> addr, mem32_t paddrlen)
int sys_net_accept(s32 s, vm::ptr<sys_net_sockaddr> addr, vm::ptr<be_t<u32>> paddrlen)
{
sys_net->Warning("accept(s=%d, family_addr=0x%x, paddrlen=0x%x)", s, addr.GetAddr(), paddrlen.GetAddr());
if (addr.GetAddr() == 0) {
sys_net->Warning("accept(s=%d, family_addr=0x%x, paddrlen=0x%x)", s, addr.addr(), paddrlen.addr());
if (!addr) {
int ret = accept(s, NULL, NULL);
g_lastError = getLastError();
*g_lastError = getLastError();
return ret;
}
else {
sockaddr _addr;
memcpy(&_addr, Memory.VirtualToRealAddr(addr.GetAddr()), sizeof(sockaddr));
memcpy(&_addr, addr.get_ptr(), sizeof(sockaddr));
_addr.sa_family = addr->sa_family;
pck_len_t *_paddrlen = (pck_len_t *)Memory.VirtualToRealAddr(paddrlen.GetAddr());
pck_len_t *_paddrlen = (pck_len_t *)Memory.VirtualToRealAddr(paddrlen.addr());
int ret = accept(s, &_addr, _paddrlen);
g_lastError = getLastError();
*g_lastError = getLastError();
return ret;
}
}
int sys_net_bind(s32 s, mem_ptr_t<sys_net_sockaddr_in> addr, u32 addrlen)
int sys_net_bind(s32 s, vm::ptr<sys_net_sockaddr_in> addr, u32 addrlen)
{
sys_net->Warning("bind(s=%d, family_addr=0x%x, addrlen=%u)", s, addr.GetAddr(), addrlen);
sys_net->Warning("bind(s=%d, family_addr=0x%x, addrlen=%u)", s, addr.addr(), addrlen);
sockaddr_in saddr;
memcpy(&saddr, Memory.VirtualToRealAddr(addr.GetAddr()), sizeof(sockaddr_in));
memcpy(&saddr, addr.get_ptr(), sizeof(sockaddr_in));
saddr.sin_family = addr->sin_family;
const char *ipaddr = inet_ntoa(saddr.sin_addr);
sys_net->Warning("binding on %s to port %d", ipaddr, ntohs(saddr.sin_port));
int ret = bind(s, (const sockaddr *)&saddr, addrlen);
g_lastError = getLastError();
*g_lastError = getLastError();
return ret;
}
int sys_net_connect(s32 s, mem_ptr_t<sys_net_sockaddr_in> addr, u32 addrlen)
int sys_net_connect(s32 s, vm::ptr<sys_net_sockaddr_in> addr, u32 addrlen)
{
sys_net->Warning("connect(s=%d, family_addr=0x%x, addrlen=%u)", s, addr.GetAddr(), addrlen);
sys_net->Warning("connect(s=%d, family_addr=0x%x, addrlen=%u)", s, addr.addr(), addrlen);
sockaddr_in saddr;
memcpy(&saddr, Memory.VirtualToRealAddr(addr.GetAddr()), sizeof(sockaddr_in));
memcpy(&saddr, addr.get_ptr(), sizeof(sockaddr_in));
saddr.sin_family = addr->sin_family;
const char *ipaddr = inet_ntoa(saddr.sin_addr);
sys_net->Warning("connecting on %s to port %d", ipaddr, ntohs(saddr.sin_port));
int ret = connect(s, (const sockaddr *) &saddr, addrlen);
g_lastError = getLastError();
*g_lastError = getLastError();
return ret;
}
@ -169,11 +169,10 @@ int getsockopt()
return CELL_OK;
}
int sys_net_inet_addr(mem8_ptr_t cp)
int sys_net_inet_addr(vm::ptr<const char> cp)
{
std::string cp_ = Memory.ReadString(cp.GetAddr());
sys_net->Warning("inet_addr(cp=\"%s\")", cp_.c_str());
return htonl(inet_addr(cp_.c_str())); // return a big-endian IP address
sys_net->Warning("inet_addr(cp_addr=0x%x['%s'])", cp.addr(), cp.get_ptr());
return htonl(inet_addr(cp.get_ptr())); // return a big-endian IP address
}
int inet_aton()
@ -230,7 +229,7 @@ int sys_net_listen(s32 s, s32 backlog)
{
sys_net->Warning("listen(s=%d, backlog=%d)", s, backlog);
int ret = listen(s, backlog);
g_lastError = getLastError();
*g_lastError = getLastError();
return ret;
}
@ -239,22 +238,22 @@ int sys_net_recv(s32 s, u32 buf_addr, u32 len, s32 flags)
sys_net->Warning("recv(s=%d, buf_addr=0x%x, len=%d, flags=0x%x)", s, buf_addr, len, flags);
char *buf = (char *)Memory.VirtualToRealAddr(buf_addr);
int ret = recv(s, buf, len, flags);
g_lastError = getLastError();
*g_lastError = getLastError();
return ret;
}
int sys_net_recvfrom(s32 s, u32 buf_addr, u32 len, s32 flags, mem_ptr_t<sys_net_sockaddr> addr, mem32_t paddrlen)
int sys_net_recvfrom(s32 s, u32 buf_addr, u32 len, s32 flags, vm::ptr<sys_net_sockaddr> addr, vm::ptr<be_t<u32>> paddrlen)
{
sys_net->Warning("recvfrom(s=%d, buf_addr=0x%x, len=%u, flags=0x%x, addr_addr=0x%x, paddrlen=0x%x)",
s, buf_addr, len, flags, addr.GetAddr(), paddrlen.GetAddr());
s, buf_addr, len, flags, addr.addr(), paddrlen.addr());
char *_buf_addr = (char *)Memory.VirtualToRealAddr(buf_addr);
sockaddr _addr;
memcpy(&_addr, Memory.VirtualToRealAddr(addr.GetAddr()), sizeof(sockaddr));
memcpy(&_addr, addr.get_ptr(), sizeof(sockaddr));
_addr.sa_family = addr->sa_family;
pck_len_t *_paddrlen = (pck_len_t *) Memory.VirtualToRealAddr(paddrlen.GetAddr());
pck_len_t *_paddrlen = (pck_len_t *) Memory.VirtualToRealAddr(paddrlen.addr());
int ret = recvfrom(s, _buf_addr, len, flags, &_addr, _paddrlen);
g_lastError = getLastError();
*g_lastError = getLastError();
return ret;
}
@ -269,7 +268,7 @@ int sys_net_send(s32 s, u32 buf_addr, u32 len, s32 flags)
sys_net->Warning("send(s=%d, buf_addr=0x%x, len=%d, flags=0x%x)", s, buf_addr, len, flags);
char *buf = (char *)Memory.VirtualToRealAddr(buf_addr);
int ret = send(s, buf, len, flags);
g_lastError = getLastError();
*g_lastError = getLastError();
return ret;
}
@ -279,17 +278,17 @@ int sendmsg()
return CELL_OK;
}
int sys_net_sendto(s32 s, u32 buf_addr, u32 len, s32 flags, mem_ptr_t<sys_net_sockaddr> addr, u32 addrlen)
int sys_net_sendto(s32 s, u32 buf_addr, u32 len, s32 flags, vm::ptr<sys_net_sockaddr> addr, u32 addrlen)
{
sys_net->Warning("sendto(s=%d, buf_addr=0x%x, len=%u, flags=0x%x, addr=0x%x, addrlen=%u)",
s, buf_addr, len, flags, addr.GetAddr(), addrlen);
s, buf_addr, len, flags, addr.addr(), addrlen);
char *_buf_addr = (char *)Memory.VirtualToRealAddr(buf_addr);
sockaddr _addr;
memcpy(&_addr, Memory.VirtualToRealAddr(addr.GetAddr()), sizeof(sockaddr));
memcpy(&_addr, addr.get_ptr(), sizeof(sockaddr));
_addr.sa_family = addr->sa_family;
int ret = sendto(s, _buf_addr, len, flags, &_addr, addrlen);
g_lastError = getLastError();
*g_lastError = getLastError();
return ret;
}
@ -298,7 +297,7 @@ int sys_net_setsockopt(s32 s, s32 level, s32 optname, u32 optval_addr, u32 optle
sys_net->Warning("socket(s=%d, level=%d, optname=%d, optval_addr=0x%x, optlen=%u)", s, level, optname, optval_addr, optlen);
char *_optval_addr = (char *)Memory.VirtualToRealAddr(optval_addr);
int ret = setsockopt(s, level, optname, _optval_addr, optlen);
g_lastError = getLastError();
*g_lastError = getLastError();
return ret;
}
@ -306,7 +305,7 @@ int sys_net_shutdown(s32 s, s32 how)
{
sys_net->Warning("shutdown(s=%d, how=%d)", s, how);
int ret = shutdown(s, how);
g_lastError = getLastError();
*g_lastError = getLastError();
return ret;
}
@ -314,7 +313,7 @@ int sys_net_socket(s32 family, s32 type, s32 protocol)
{
sys_net->Warning("socket(family=%d, type=%d, protocol=%d)", family, type, protocol);
int ret = socket(family, type, protocol);
g_lastError = getLastError();
*g_lastError = getLastError();
return ret;
}
@ -326,7 +325,7 @@ int sys_net_socketclose(s32 s)
#else
int ret = close(s);
#endif
g_lastError = getLastError();
*g_lastError = getLastError();
return ret;
}
@ -342,10 +341,10 @@ int socketselect()
return CELL_OK;
}
int sys_net_initialize_network_ex(mem_ptr_t<sys_net_initialize_parameter> param)
int sys_net_initialize_network_ex(vm::ptr<sys_net_initialize_parameter> param)
{
sys_net->Warning("sys_net_initialize_network_ex(param_addr=0x%x)", param.GetAddr());
g_lastError.SetAddr(Memory.Alloc(4, 1));
sys_net->Warning("sys_net_initialize_network_ex(param_addr=0x%x)", param.addr());
g_lastError = vm::ptr<be_t<s32>>::make((u32)Memory.Alloc(4, 1));
#ifdef _WIN32
WSADATA wsaData;
WORD wVersionRequested = MAKEWORD(1,1);
@ -408,10 +407,10 @@ int sys_net_show_nameserver()
return CELL_OK;
}
s32 _sys_net_errno_loc()
u32 _sys_net_errno_loc()
{
sys_net->Warning("_sys_net_errno_loc()");
return g_lastError.GetAddr();
return g_lastError.addr();
}
int sys_net_set_resolver_configurations()
@ -477,8 +476,8 @@ int sys_net_show_ifconfig()
int sys_net_finalize_network()
{
sys_net->Warning("sys_net_initialize_network_ex()");
Memory.Free(g_lastError.GetAddr());
g_lastError.SetAddr(0);
Memory.Free(g_lastError.addr());
g_lastError = vm::ptr<be_t<s32>>::make(0);
#ifdef _WIN32
WSACleanup();
#endif

View file

@ -5,6 +5,7 @@ class func_caller
{
public:
virtual void operator()() = 0;
virtual ~func_caller(){};
};
namespace detail
@ -38,7 +39,7 @@ namespace detail
static __forceinline T func(PPUThread& CPU)
{
return (T&)CPU.FPR[f_count];
return (T)CPU.FPR[f_count];
}
};
@ -73,7 +74,7 @@ namespace detail
static_assert(!std::is_pointer<T>::value, "Invalid function result type: pointer");
if (std::is_floating_point<T>::value)
{
(T&)CPU.FPR[1] = value;
CPU.FPR[1] = (double)value;
}
else
{

View file

@ -916,7 +916,7 @@ struct SyscallTableCleaner_t
void default_syscall()
{
declCPU();
u32 code = CPU.GPR[11];
u32 code = (u32)CPU.GPR[11];
//TODO: remove this
switch(code)
{

View file

@ -30,11 +30,11 @@ struct FsRingBufferConfig
} fs_config;
s32 cellFsOpen(u32 path_addr, s32 flags, mem32_t fd, mem32_t arg, u64 size)
s32 cellFsOpen(u32 path_addr, s32 flags, vm::ptr<be_t<u32>> fd, vm::ptr<be_t<u32>> arg, u64 size)
{
const std::string& path = Memory.ReadString(path_addr);
sys_fs->Log("cellFsOpen(path=\"%s\", flags=0x%x, fd_addr=0x%x, arg_addr=0x%x, size=0x%llx)",
path.c_str(), flags, fd.GetAddr(), arg.GetAddr(), size);
path.c_str(), flags, fd.addr(), arg.addr(), size);
const std::string& ppath = path;
//ConLog.Warning("path: %s [%s]", ppath.c_str(), path.c_str());
@ -109,16 +109,17 @@ s32 cellFsOpen(u32 path_addr, s32 flags, mem32_t fd, mem32_t arg, u64 size)
return CELL_ENOENT;
}
fd = sys_fs->GetNewId(stream, TYPE_FS_FILE);
sys_fs->Notice("\"%s\" opened: fd = %d", path.c_str(), fd.GetValue());
u32 id = sys_fs->GetNewId(stream, TYPE_FS_FILE);
*fd = id;
sys_fs->Notice("\"%s\" opened: fd = %d", path.c_str(), id);
return CELL_OK;
}
s32 cellFsRead(u32 fd, u32 buf_addr, u64 nbytes, mem64_t nread)
s32 cellFsRead(u32 fd, u32 buf_addr, u64 nbytes, vm::ptr<be_t<u64>> nread)
{
sys_fs->Log("cellFsRead(fd=%d, buf_addr=0x%x, nbytes=0x%llx, nread_addr=0x%x)",
fd, buf_addr, nbytes, nread.GetAddr());
fd, buf_addr, nbytes, nread.addr());
vfsStream* file;
if(!sys_fs->CheckId(fd, file)) return CELL_ESRCH;
@ -128,15 +129,15 @@ s32 cellFsRead(u32 fd, u32 buf_addr, u64 nbytes, mem64_t nread)
const u64 res = nbytes ? file->Read(Memory.GetMemFromAddr(buf_addr), nbytes) : 0;
if (nread.GetAddr()) nread = res; // write value if not NULL
if (nread) *nread = res;
return CELL_OK;
}
s32 cellFsWrite(u32 fd, u32 buf_addr, u64 nbytes, mem64_t nwrite)
s32 cellFsWrite(u32 fd, u32 buf_addr, u64 nbytes, vm::ptr<be_t<u64>> nwrite)
{
sys_fs->Log("cellFsWrite(fd=%d, buf_addr=0x%x, nbytes=0x%llx, nwrite_addr=0x%x)",
fd, buf_addr, nbytes, nwrite.GetAddr());
fd, buf_addr, nbytes, nwrite.addr());
vfsStream* file;
if(!sys_fs->CheckId(fd, file)) return CELL_ESRCH;
@ -146,7 +147,7 @@ s32 cellFsWrite(u32 fd, u32 buf_addr, u64 nbytes, mem64_t nwrite)
const u64 res = nbytes ? file->Write(Memory.GetMemFromAddr(buf_addr), nbytes) : 0;
if (nwrite.GetAddr()) nwrite = res; // write value if not NULL
if (nwrite) *nwrite = res;
return CELL_OK;
}
@ -161,10 +162,10 @@ s32 cellFsClose(u32 fd)
return CELL_OK;
}
s32 cellFsOpendir(u32 path_addr, mem32_t fd)
s32 cellFsOpendir(u32 path_addr, vm::ptr<be_t<u32>> fd)
{
const std::string& path = Memory.ReadString(path_addr);
sys_fs->Warning("cellFsOpendir(path=\"%s\", fd_addr=0x%x)", path.c_str(), fd.GetAddr());
sys_fs->Warning("cellFsOpendir(path=\"%s\", fd_addr=0x%x)", path.c_str(), fd.addr());
vfsDirBase* dir = Emu.GetVFS().OpenDir(path);
if(!dir || !dir->IsOpened())
@ -173,13 +174,13 @@ s32 cellFsOpendir(u32 path_addr, mem32_t fd)
return CELL_ENOENT;
}
fd = sys_fs->GetNewId(dir, TYPE_FS_DIR);
*fd = sys_fs->GetNewId(dir, TYPE_FS_DIR);
return CELL_OK;
}
s32 cellFsReaddir(u32 fd, mem_ptr_t<CellFsDirent> dir, mem64_t nread)
s32 cellFsReaddir(u32 fd, vm::ptr<CellFsDirent> dir, vm::ptr<be_t<u64>> nread)
{
sys_fs->Log("cellFsReaddir(fd=%d, dir_addr=0x%x, nread_addr=0x%x)", fd, dir.GetAddr(), nread.GetAddr());
sys_fs->Log("cellFsReaddir(fd=%d, dir_addr=0x%x, nread_addr=0x%x)", fd, dir.addr(), nread.addr());
vfsDirBase* directory;
if(!sys_fs->CheckId(fd, directory))
@ -188,14 +189,14 @@ s32 cellFsReaddir(u32 fd, mem_ptr_t<CellFsDirent> dir, mem64_t nread)
const DirEntryInfo* info = directory->Read();
if(info)
{
nread = 1;
Memory.WriteString(dir.GetAddr()+2, info->name);
*nread = 1;
Memory.WriteString(dir.addr() + 2, info->name);
dir->d_namlen = info->name.length();
dir->d_type = (info->flags & DirEntry_TypeFile) ? CELL_FS_TYPE_REGULAR : CELL_FS_TYPE_DIRECTORY;
}
else
{
nread = 0;
*nread = 0;
}
return CELL_OK;
@ -211,10 +212,10 @@ s32 cellFsClosedir(u32 fd)
return CELL_OK;
}
s32 cellFsStat(const u32 path_addr, mem_ptr_t<CellFsStat> sb)
s32 cellFsStat(const u32 path_addr, vm::ptr<CellFsStat> sb)
{
const std::string& path = Memory.ReadString(path_addr);
sys_fs->Warning("cellFsStat(path=\"%s\", sb_addr: 0x%x)", path.c_str(), sb.GetAddr());
sys_fs->Warning("cellFsStat(path=\"%s\", sb_addr: 0x%x)", path.c_str(), sb.addr());
sb->st_mode =
CELL_FS_S_IRUSR | CELL_FS_S_IWUSR | CELL_FS_S_IXUSR |
@ -251,9 +252,9 @@ s32 cellFsStat(const u32 path_addr, mem_ptr_t<CellFsStat> sb)
return CELL_ENOENT;
}
s32 cellFsFstat(u32 fd, mem_ptr_t<CellFsStat> sb)
s32 cellFsFstat(u32 fd, vm::ptr<CellFsStat> sb)
{
sys_fs->Log("cellFsFstat(fd=%d, sb_addr: 0x%x)", fd, sb.GetAddr());
sys_fs->Log("cellFsFstat(fd=%d, sb_addr: 0x%x)", fd, sb.addr());
IDType type;
vfsStream* file;
@ -378,10 +379,10 @@ s32 cellFsUnlink(u32 path_addr)
return CELL_OK;
}
s32 cellFsLseek(u32 fd, s64 offset, u32 whence, mem64_t pos)
s32 cellFsLseek(u32 fd, s64 offset, u32 whence, vm::ptr<be_t<u64>> pos)
{
vfsSeekMode seek_mode;
sys_fs->Log("cellFsLseek(fd=%d, offset=0x%llx, whence=0x%x, pos_addr=0x%x)", fd, offset, whence, pos.GetAddr());
sys_fs->Log("cellFsLseek(fd=%d, offset=0x%llx, whence=0x%x, pos_addr=0x%x)", fd, offset, whence, pos.addr());
switch(whence)
{
case CELL_SEEK_SET: seek_mode = vfsSeekSet; break;
@ -397,7 +398,7 @@ s32 cellFsLseek(u32 fd, s64 offset, u32 whence, mem64_t pos)
if (!sys_fs->CheckId(fd, file, type) || type != TYPE_FS_FILE) {
return CELL_ESRCH;
}
pos = file->Seek(offset, seek_mode);
*pos = file->Seek(offset, seek_mode);
return CELL_OK;
}
@ -461,48 +462,51 @@ s32 cellFsTruncate(u32 path_addr, u64 size)
return CELL_OK;
}
s32 cellFsFGetBlockSize(u32 fd, mem64_t sector_size, mem64_t block_size)
s32 cellFsFGetBlockSize(u32 fd, vm::ptr<be_t<u64>> sector_size, vm::ptr<be_t<u64>> block_size)
{
sys_fs->Log("cellFsFGetBlockSize(fd=%d, sector_size_addr: 0x%x, block_size_addr: 0x%x)", fd, sector_size.GetAddr(), block_size.GetAddr());
sys_fs->Log("cellFsFGetBlockSize(fd=%d, sector_size_addr: 0x%x, block_size_addr: 0x%x)",
fd, sector_size.addr(), block_size.addr());
vfsStream* file;
if(!sys_fs->CheckId(fd, file)) return CELL_ESRCH;
sector_size = 4096; // ?
block_size = 4096; // ?
*sector_size = 4096; // ?
*block_size = 4096; // ?
return CELL_OK;
}
s32 cellFsGetBlockSize(u32 path_addr, mem64_t sector_size, mem64_t block_size)
s32 cellFsGetBlockSize(u32 path_addr, vm::ptr<be_t<u64>> sector_size, vm::ptr<be_t<u64>> block_size)
{
sys_fs->Log("cellFsGetBlockSize(file: %s, sector_size_addr: 0x%x, block_size_addr: 0x%x)", Memory.ReadString(path_addr).c_str(), sector_size.GetAddr(), block_size.GetAddr());
sys_fs->Log("cellFsGetBlockSize(file: %s, sector_size_addr: 0x%x, block_size_addr: 0x%x)",
Memory.ReadString(path_addr).c_str(), sector_size.addr(), block_size.addr());
sector_size = 4096; // ?
block_size = 4096; // ?
*sector_size = 4096; // ?
*block_size = 4096; // ?
return CELL_OK;
}
s32 cellFsGetFreeSize(u32 path_addr, mem32_t block_size, mem64_t block_count)
s32 cellFsGetFreeSize(u32 path_addr, vm::ptr<be_t<u32>> block_size, vm::ptr<be_t<u64>> block_count)
{
const std::string& ps3_path = Memory.ReadString(path_addr);
sys_fs->Warning("cellFsGetFreeSize(path=\"%s\", block_size_addr=0x%x, block_count_addr=0x%x)",
ps3_path.c_str(), block_size.GetAddr(), block_count.GetAddr());
ps3_path.c_str(), block_size.addr(), block_count.addr());
if (ps3_path.empty())
return CELL_EINVAL;
// TODO: Get real values. Currently, it always returns 40 GB of free space divided in 4 KB blocks
block_size = 4096; // ?
block_count = 10485760; // ?
*block_size = 4096; // ?
*block_count = 10485760; // ?
return CELL_OK;
}
s32 cellFsGetDirectoryEntries(u32 fd, mem_ptr_t<CellFsDirectoryEntry> entries, u32 entries_size, mem32_t data_count)
s32 cellFsGetDirectoryEntries(u32 fd, vm::ptr<CellFsDirectoryEntry> entries, u32 entries_size, vm::ptr<be_t<u32>> data_count)
{
sys_fs->Log("cellFsGetDirectoryEntries(fd=%d, entries_addr=0x%x, entries_size = 0x%x, data_count_addr=0x%x)", fd, entries.GetAddr(), entries_size, data_count.GetAddr());
sys_fs->Log("cellFsGetDirectoryEntries(fd=%d, entries_addr=0x%x, entries_size = 0x%x, data_count_addr=0x%x)",
fd, entries.addr(), entries_size, data_count.addr());
vfsDirBase* directory;
if(!sys_fs->CheckId(fd, directory))
@ -511,8 +515,8 @@ s32 cellFsGetDirectoryEntries(u32 fd, mem_ptr_t<CellFsDirectoryEntry> entries, u
const DirEntryInfo* info = directory->Read();
if(info)
{
data_count = 1;
Memory.WriteString(entries.GetAddr()+2, info->name);
*data_count = 1;
Memory.WriteString(entries.addr()+2, info->name);
entries->entry_name.d_namlen = info->name.length();
entries->entry_name.d_type = (info->flags & DirEntry_TypeFile) ? CELL_FS_TYPE_REGULAR : CELL_FS_TYPE_DIRECTORY;
@ -530,15 +534,15 @@ s32 cellFsGetDirectoryEntries(u32 fd, mem_ptr_t<CellFsDirectoryEntry> entries, u
}
else
{
data_count = 0;
*data_count = 0;
}
return CELL_OK;
}
s32 cellFsStReadInit(u32 fd, mem_ptr_t<CellFsRingBuffer> ringbuf)
s32 cellFsStReadInit(u32 fd, vm::ptr<CellFsRingBuffer> ringbuf)
{
sys_fs->Warning("cellFsStReadInit(fd=%d, ringbuf_addr=0x%x)", fd, ringbuf.GetAddr());
sys_fs->Warning("cellFsStReadInit(fd=%d, ringbuf_addr=0x%x)", fd, ringbuf.addr());
vfsStream* file;
if(!sys_fs->CheckId(fd, file)) return CELL_ESRCH;
@ -546,11 +550,11 @@ s32 cellFsStReadInit(u32 fd, mem_ptr_t<CellFsRingBuffer> ringbuf)
fs_config.m_ring_buffer = *ringbuf;
if(ringbuf->ringbuf_size < 0x40000000) // If the size is less than 1MB
fs_config.m_alloc_mem_size = ((ringbuf->ringbuf_size + 64 * 1024 - 1) / (64 * 1024)) * (64 * 1024);
fs_config.m_alloc_mem_size = ((ringbuf->ringbuf_size + 1024 * 1024 - 1) / (1024 * 1024)) * (1024 * 1024);
fs_config.m_alloc_mem_size = (((u32)ringbuf->ringbuf_size + 64 * 1024 - 1) / (64 * 1024)) * (64 * 1024);
fs_config.m_alloc_mem_size = (((u32)ringbuf->ringbuf_size + 1024 * 1024 - 1) / (1024 * 1024)) * (1024 * 1024);
// alloc memory
fs_config.m_buffer = Memory.Alloc(fs_config.m_alloc_mem_size, 1024);
fs_config.m_buffer = (u32)Memory.Alloc(fs_config.m_alloc_mem_size, 1024);
memset(Memory + fs_config.m_buffer, 0, fs_config.m_alloc_mem_size);
fs_config.m_fs_status = CELL_FS_ST_INITIALIZED;
@ -571,9 +575,9 @@ s32 cellFsStReadFinish(u32 fd)
return CELL_OK;
}
s32 cellFsStReadGetRingBuf(u32 fd, mem_ptr_t<CellFsRingBuffer> ringbuf)
s32 cellFsStReadGetRingBuf(u32 fd, vm::ptr<CellFsRingBuffer> ringbuf)
{
sys_fs->Warning("cellFsStReadGetRingBuf(fd=%d, ringbuf_addr=0x%x)", fd, ringbuf.GetAddr());
sys_fs->Warning("cellFsStReadGetRingBuf(fd=%d, ringbuf_addr=0x%x)", fd, ringbuf.addr());
vfsStream* file;
if(!sys_fs->CheckId(fd, file)) return CELL_ESRCH;
@ -585,26 +589,26 @@ s32 cellFsStReadGetRingBuf(u32 fd, mem_ptr_t<CellFsRingBuffer> ringbuf)
return CELL_OK;
}
s32 cellFsStReadGetStatus(u32 fd, mem64_t status)
s32 cellFsStReadGetStatus(u32 fd, vm::ptr<be_t<u64>> status)
{
sys_fs->Warning("cellFsStReadGetRingBuf(fd=%d, status_addr=0x%x)", fd, status.GetAddr());
sys_fs->Warning("cellFsStReadGetRingBuf(fd=%d, status_addr=0x%x)", fd, status.addr());
vfsStream* file;
if(!sys_fs->CheckId(fd, file)) return CELL_ESRCH;
status = fs_config.m_fs_status;
*status = fs_config.m_fs_status;
return CELL_OK;
}
s32 cellFsStReadGetRegid(u32 fd, mem64_t regid)
s32 cellFsStReadGetRegid(u32 fd, vm::ptr<be_t<u64>> regid)
{
sys_fs->Warning("cellFsStReadGetRingBuf(fd=%d, regid_addr=0x%x)", fd, regid.GetAddr());
sys_fs->Warning("cellFsStReadGetRingBuf(fd=%d, regid_addr=0x%x)", fd, regid.addr());
vfsStream* file;
if(!sys_fs->CheckId(fd, file)) return CELL_ESRCH;
regid = fs_config.m_regid;
*regid = fs_config.m_regid;
return CELL_OK;
}
@ -634,22 +638,22 @@ s32 cellFsStReadStop(u32 fd)
return CELL_OK;
}
s32 cellFsStRead(u32 fd, u32 buf_addr, u64 size, mem64_t rsize)
s32 cellFsStRead(u32 fd, u32 buf_addr, u64 size, vm::ptr<be_t<u64>> rsize)
{
sys_fs->Todo("cellFsStRead(fd=%d, buf_addr=0x%x, size=0x%llx, rsize_addr = 0x%x)", fd, buf_addr, size, rsize.GetAddr());
sys_fs->Todo("cellFsStRead(fd=%d, buf_addr=0x%x, size=0x%llx, rsize_addr = 0x%x)", fd, buf_addr, size, rsize.addr());
vfsStream* file;
if(!sys_fs->CheckId(fd, file)) return CELL_ESRCH;
fs_config.m_regid += size;
rsize = fs_config.m_regid;
*rsize = fs_config.m_regid;
return CELL_OK;
}
s32 cellFsStReadGetCurrentAddr(u32 fd, mem32_t addr_addr, mem64_t size)
s32 cellFsStReadGetCurrentAddr(u32 fd, vm::ptr<be_t<u32>> addr, vm::ptr<be_t<u64>> size)
{
sys_fs->Todo("cellFsStReadGetCurrentAddr(fd=%d, addr_addr=0x%x, size_addr = 0x%x)", fd, addr_addr.GetAddr(), size.GetAddr());
sys_fs->Todo("cellFsStReadGetCurrentAddr(fd=%d, addr_addr=0x%x, size_addr = 0x%x)", fd, addr.addr(), size.addr());
vfsStream* file;
if(!sys_fs->CheckId(fd, file)) return CELL_ESRCH;
@ -677,9 +681,9 @@ s32 cellFsStReadWait(u32 fd, u64 size)
return CELL_OK;
}
s32 cellFsStReadWaitCallback(u32 fd, u64 size, mem_func_ptr_t<void (*)(int xfd, u64 xsize)> func)
s32 cellFsStReadWaitCallback(u32 fd, u64 size, vm::ptr<void (*)(int xfd, u64 xsize)> func)
{
sys_fs->Todo("cellFsStReadWaitCallback(fd=%d, size = 0x%llx, func_addr = 0x%x)", fd, size, func.GetAddr());
sys_fs->Todo("cellFsStReadWaitCallback(fd=%d, size = 0x%llx, func_addr = 0x%x)", fd, size, func.addr());
vfsStream* file;
if(!sys_fs->CheckId(fd, file)) return CELL_ESRCH;

Some files were not shown because too many files have changed in this diff Show more