mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-23 13:30:02 +00:00
Consistently use MIPS_REG_V0 for return values.
This way all instances are a lot easier to search for (was trying to find where we were writing an incorrect value to v0, turns out to be callback related of course.)
This commit is contained in:
parent
446418d783
commit
641064f0bc
@ -23,103 +23,76 @@
|
||||
// For easy parameter parsing and return value processing.
|
||||
|
||||
// 64bit wrappers
|
||||
// 64bit values are always "aligned" in regs (never start on an odd reg.)
|
||||
|
||||
template<u64 func()> void WrapU64_V() {
|
||||
u64 retval = func();
|
||||
currentMIPS->r[2] = retval & 0xFFFFFFFF;
|
||||
currentMIPS->r[3] = (retval >> 32) & 0xFFFFFFFF;
|
||||
RETURN64(retval);
|
||||
}
|
||||
|
||||
template<u64 func(u32)> void WrapU64_U() {
|
||||
u64 retval = func(PARAM(0));
|
||||
currentMIPS->r[2] = retval & 0xFFFFFFFF;
|
||||
currentMIPS->r[3] = (retval >> 32) & 0xFFFFFFFF;
|
||||
RETURN64(retval);
|
||||
}
|
||||
|
||||
template<u64 func(int)> void WrapU64_I() {
|
||||
u64 retval = func(PARAM(0));
|
||||
currentMIPS->r[2] = retval & 0xFFFFFFFF;
|
||||
currentMIPS->r[3] = (retval >> 32) & 0xFFFFFFFF;
|
||||
RETURN64(retval);
|
||||
}
|
||||
|
||||
template<u64 func(u32, u64)> void WrapU64_UU64() {
|
||||
u64 param_one = currentMIPS->r[6];
|
||||
param_one |= (u64)(currentMIPS->r[7]) << 32;
|
||||
u64 retval = func(PARAM(0), param_one);
|
||||
currentMIPS->r[2] = retval & 0xFFFFFFFF;
|
||||
currentMIPS->r[3] = (retval >> 32) & 0xFFFFFFFF;
|
||||
u64 retval = func(PARAM(0), PARAM64(2));
|
||||
RETURN64(retval);
|
||||
}
|
||||
|
||||
template<u64 func(int, u64)> void WrapU64_IU64() {
|
||||
u64 param_one = currentMIPS->r[6];
|
||||
param_one |= (u64)(currentMIPS->r[7]) << 32;
|
||||
u64 retval = func(PARAM(0), param_one);
|
||||
currentMIPS->r[2] = retval & 0xFFFFFFFF;
|
||||
currentMIPS->r[3] = (retval >> 32) & 0xFFFFFFFF;
|
||||
u64 retval = func(PARAM(0), PARAM64(2));
|
||||
RETURN64(retval);
|
||||
}
|
||||
|
||||
template<int func(int, u64)> void WrapI_IU64() {
|
||||
u64 param_one = currentMIPS->r[6];
|
||||
param_one |= (u64)(currentMIPS->r[7]) << 32;
|
||||
int retval = func(PARAM(0), param_one);
|
||||
int retval = func(PARAM(0), PARAM64(2));
|
||||
RETURN(retval);
|
||||
}
|
||||
|
||||
template<int func(u32, u64)> void WrapI_UU64() {
|
||||
u64 param_one = currentMIPS->r[6];
|
||||
param_one |= (u64)(currentMIPS->r[7]) << 32;
|
||||
int retval = func(PARAM(0), param_one);
|
||||
int retval = func(PARAM(0), PARAM64(2));
|
||||
RETURN(retval);
|
||||
}
|
||||
|
||||
template<u32 func(u32, u64)> void WrapU_UU64() {
|
||||
u64 param_one = currentMIPS->r[6];
|
||||
param_one |= (u64)(currentMIPS->r[7]) << 32;
|
||||
u32 retval = func(PARAM(0), param_one);
|
||||
u32 retval = func(PARAM(0), PARAM64(2));
|
||||
RETURN(retval);
|
||||
}
|
||||
|
||||
template<int func(u32, u32, u64)> void WrapI_UUU64() {
|
||||
u64 param_two = currentMIPS->r[6];
|
||||
param_two |= (u64)(currentMIPS->r[7]) << 32;
|
||||
int retval = func(PARAM(0), PARAM(1), param_two);
|
||||
int retval = func(PARAM(0), PARAM(1), PARAM64(2));
|
||||
RETURN(retval);
|
||||
}
|
||||
|
||||
template<u32 func(int, s64, int)> void WrapU_II64I() {
|
||||
s64 param_one = currentMIPS->r[6];
|
||||
param_one |= (s64)(currentMIPS->r[7]) << 32;
|
||||
u32 retval = func(PARAM(0), param_one, PARAM(4));
|
||||
u32 retval = func(PARAM(0), PARAM64(2), PARAM(4));
|
||||
RETURN(retval);
|
||||
}
|
||||
|
||||
template<u32 func(u32, u64, u32, u32)> void WrapU_UU64UU() {
|
||||
u64 param_one = currentMIPS->r[6];
|
||||
param_one |= (u64)(currentMIPS->r[7]) << 32;
|
||||
u32 retval = func(PARAM(0), param_one, PARAM(4), PARAM(5));
|
||||
u32 retval = func(PARAM(0), PARAM64(2), PARAM(4), PARAM(5));
|
||||
RETURN(retval);
|
||||
}
|
||||
|
||||
template<u32 func(int, u64, u32, u32)> void WrapU_IU64UU() {
|
||||
u64 param_one = currentMIPS->r[6];
|
||||
param_one |= (u64)(currentMIPS->r[7]) << 32;
|
||||
u32 retval = func(PARAM(0), param_one, PARAM(4), PARAM(5));
|
||||
u32 retval = func(PARAM(0), PARAM64(2), PARAM(4), PARAM(5));
|
||||
RETURN(retval);
|
||||
}
|
||||
|
||||
template<int func(int, int, const char*, u64)> void WrapI_IICU64() {
|
||||
u64 param_three = currentMIPS->r[8];
|
||||
param_three |= (u64)(currentMIPS->r[9]) << 32;
|
||||
int retval = func(PARAM(0), PARAM(1), Memory::GetCharPointer(PARAM(2)), param_three);
|
||||
int retval = func(PARAM(0), PARAM(1), Memory::GetCharPointer(PARAM(2)), PARAM64(4));
|
||||
RETURN(retval);
|
||||
}
|
||||
|
||||
template<s64 func(int, s64, int)> void WrapI64_II64I() {
|
||||
s64 param_one = currentMIPS->r[6];
|
||||
param_one |= (s64)(currentMIPS->r[7]) << 32;
|
||||
s64 retval = func(PARAM(0), param_one, PARAM(4));
|
||||
currentMIPS->r[2] = (retval >> 0) & 0xFFFFFFFF;
|
||||
currentMIPS->r[3] = (retval >> 32) & 0xFFFFFFFF;
|
||||
s64 retval = func(PARAM(0), PARAM64(2), PARAM(4));
|
||||
RETURN64(retval);
|
||||
}
|
||||
|
||||
//32bit wrappers
|
||||
@ -223,7 +196,7 @@ template<int func(u32, u32)> void WrapI_UU() {
|
||||
|
||||
template<int func(u32, float, float)> void WrapI_UFF() {
|
||||
// Not sure about the float arguments.
|
||||
int retval = func(PARAM(0), currentMIPS->f[12], currentMIPS->f[13]);
|
||||
int retval = func(PARAM(0), PARAMF(0), PARAMF(1));
|
||||
RETURN(retval);
|
||||
}
|
||||
|
||||
|
@ -57,10 +57,12 @@ struct Syscall
|
||||
u32 nid;
|
||||
};
|
||||
|
||||
#define PARAM(n) currentMIPS->r[4+n]
|
||||
#define PARAMF(n) currentMIPS->f[12+n]
|
||||
#define RETURN(n) currentMIPS->r[2]=n
|
||||
#define RETURNF(fl) currentMIPS->f[0]=fl
|
||||
#define PARAM(n) currentMIPS->r[MIPS_REG_A0 + n]
|
||||
#define PARAM64(n) (currentMIPS->r[MIPS_REG_A0 + n] | ((u64)currentMIPS->r[MIPS_REG_A0 + n + 1] << 32))
|
||||
#define PARAMF(n) currentMIPS->f[12 + n]
|
||||
#define RETURN(n) currentMIPS->r[MIPS_REG_V0] = n
|
||||
#define RETURN64(n) {u64 RETURN64_tmp = n; currentMIPS->r[MIPS_REG_V0] = RETURN64_tmp & 0xFFFFFFFF; currentMIPS->r[MIPS_REG_V1] = RETURN64_tmp >> 32;}
|
||||
#define RETURNF(fl) currentMIPS->f[0] = fl
|
||||
|
||||
#ifndef ARRAY_SIZE
|
||||
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
|
||||
|
@ -381,7 +381,7 @@ public:
|
||||
};
|
||||
|
||||
void AfterModuleEntryCall::run(MipsCall &call) {
|
||||
Memory::Write_U32(retValAddr, currentMIPS->r[2]);
|
||||
Memory::Write_U32(retValAddr, currentMIPS->r[MIPS_REG_V0]);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
@ -3111,21 +3111,21 @@ void ActionAfterMipsCall::run(MipsCall &call) {
|
||||
|
||||
void Thread::setReturnValue(u32 retval)
|
||||
{
|
||||
if (this->GetUID() == currentThread) {
|
||||
currentMIPS->r[2] = retval;
|
||||
if (GetUID() == currentThread) {
|
||||
currentMIPS->r[MIPS_REG_V0] = retval;
|
||||
} else {
|
||||
context.r[2] = retval;
|
||||
context.r[MIPS_REG_V0] = retval;
|
||||
}
|
||||
}
|
||||
|
||||
void Thread::setReturnValue(u64 retval)
|
||||
{
|
||||
if (this->GetUID() == currentThread) {
|
||||
currentMIPS->r[2] = retval & 0xFFFFFFFF;
|
||||
currentMIPS->r[3] = (retval >> 32) & 0xFFFFFFFF;
|
||||
if (GetUID() == currentThread) {
|
||||
currentMIPS->r[MIPS_REG_V0] = retval & 0xFFFFFFFF;
|
||||
currentMIPS->r[MIPS_REG_V1] = (retval >> 32) & 0xFFFFFFFF;
|
||||
} else {
|
||||
context.r[2] = retval & 0xFFFFFFFF;
|
||||
context.r[3] = (retval >> 32) & 0xFFFFFFFF;
|
||||
context.r[MIPS_REG_V0] = retval & 0xFFFFFFFF;
|
||||
context.r[MIPS_REG_V1] = (retval >> 32) & 0xFFFFFFFF;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -988,7 +988,7 @@ void PostPutAction::run(MipsCall &call) {
|
||||
|
||||
MpegContext *ctx = getMpegCtx(ringbuffer->mpeg);
|
||||
|
||||
int packetsAdded = currentMIPS->r[2];
|
||||
int packetsAdded = currentMIPS->r[MIPS_REG_V0];
|
||||
if (ringbuffer->packetsRead == 0 && ctx->mediaengine && packetsAdded > 0) {
|
||||
// init mediaEngine
|
||||
AnalyzeMpeg(ctx->mpegheader, ctx);
|
||||
|
Loading…
Reference in New Issue
Block a user