Merge pull request #129 from Yn5an3/master

Wrapped sceGe and sceIo functions
This commit is contained in:
Henrik Rydgård 2012-12-05 15:31:27 -08:00
commit d06dfc36e0
3 changed files with 589 additions and 535 deletions

View file

@ -30,19 +30,25 @@ template<u64 func()> void WrapU64_V() {
}
template<int func(u32, u64)> void WrapI_UU64() {
u64 param_one = currentMIPS->r[5];
param_one |= (u64)(currentMIPS->r[6])<< 32;
u64 param_one = currentMIPS->r[6];
param_one |= (u64)(currentMIPS->r[7]) << 32;
int retval = func(PARAM(0), param_one);
RETURN(retval);
}
template<int func(u32,u32,u64)> void WrapI_UUU64() {
template<int func(u32, u32, u64)> void WrapI_UUU64() {
u64 param_two = currentMIPS->r[6];
param_two |= (u64)(currentMIPS->r[7])<< 32;
param_two |= (u64)(currentMIPS->r[7]) << 32;
int retval = func(PARAM(0), PARAM(1), param_two);
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));
RETURN(retval);
}
//32bit wrappers
template<void func()> void WrapV_V() {
@ -53,6 +59,11 @@ template<u32 func()> void WrapU_V() {
RETURN(func());
}
template<u32 func(int, void *, int)> void WrapU_IVI() {
u32 retval = func(PARAM(0), Memory::GetPointer(PARAM(1)), PARAM(2));
RETURN(retval);
}
template<float func()> void WrapF_V() {
RETURNF(func());
}
@ -72,6 +83,11 @@ template<int func(u32)> void WrapI_U() {
RETURN(retval);
}
template<u32 func(int, u32, int)> void WrapU_IUI() {
u32 retval = func(PARAM(0), PARAM(1), PARAM(2));
RETURN(retval);
}
template<int func(u32, u32)> void WrapI_UU() {
int retval = func(PARAM(0), PARAM(1));
RETURN(retval);
@ -137,7 +153,6 @@ template<int func(u32, u32, int)> void WrapI_UUI() {
RETURN(retval);
}
template<int func(int, int)> void WrapI_II() {
int retval = func(PARAM(0), PARAM(1));
RETURN(retval);
@ -161,29 +176,52 @@ template<void func(u32, int)> void WrapV_UI() {
func(PARAM(0), PARAM(1));
}
template<u32 func(const char *)> void WrapU_C() {
u32 retval = func(Memory::GetCharPointer(PARAM(0)));
RETURN(retval);
}
template<u32 func(const char *, const char *, const char *, u32)> void WrapU_CCCU() {
u32 retval = func(Memory::GetCharPointer(PARAM(0)),
Memory::GetCharPointer(PARAM(1)), Memory::GetCharPointer(PARAM(2)),
PARAM(3));
RETURN(retval);
}
template<int func(const char *, u32)> void WrapI_CU() {
int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1));
RETURN(retval);
}
template<int func(const char *, u32, u32, u32)> void WrapI_CUUU() {
int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2), PARAM(3));
int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2),
PARAM(3));
RETURN(retval);
}
template<u32 func(const char *, u32)> void WrapU_CU() {
int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1));
RETURN((u32)retval);
u32 retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1));
RETURN((u32) retval);
}
template<u32 func(u32, const char *)> void WrapU_UC() {
int retval = func(PARAM(0), Memory::GetCharPointer(PARAM(1)));
u32 retval = func(PARAM(0), Memory::GetCharPointer(PARAM(1)));
RETURN(retval);
}
template<u32 func(const char *, u32, u32)> void WrapU_CUU() {
int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2));
RETURN((u32)retval);
u32 retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2));
RETURN((u32) retval);
}
template<u32 func(int, int, int)> void WrapU_III() {
u32 retval = func(PARAM(0), PARAM(1), PARAM(2));
RETURN(retval);
}
template<u32 func(int, u32, u32)> void WrapU_IUU() {
u32 retval = func(PARAM(0), PARAM(1), PARAM(2));
RETURN(retval);
}
template<u32 func(u32, u32, u32)> void WrapU_UUU() {
@ -220,11 +258,13 @@ template<void func(const char *, u32, int, u32)> void WrapV_CUIU() {
}
template<void func(u32, const char *, u32, int, u32)> void WrapV_UCUIU() {
func(PARAM(0), Memory::GetCharPointer(PARAM(1)), PARAM(2), PARAM(3), PARAM(4));
func(PARAM(0), Memory::GetCharPointer(PARAM(1)), PARAM(2), PARAM(3),
PARAM(4));
}
template<void func(const char *, u32, int, int, u32)> void WrapV_CUIIU() {
func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2), PARAM(3), PARAM(4));
func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2), PARAM(3),
PARAM(4));
}
template<u32 func(u32, u32, u32, u32)> void WrapU_UUUU() {
@ -256,13 +296,36 @@ template<void func(u32, u32, u32, u32, u32)> void WrapV_UUUUU() {
func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4));
}
template<u32 func(const char *, const char *)> void WrapU_CC() {
int retval = func(Memory::GetCharPointer(PARAM(0)),
Memory::GetCharPointer(PARAM(1)));
RETURN(retval);
}
template<void func(const char *, int)> void WrapV_CI() {
func(Memory::GetCharPointer(PARAM(0)), PARAM(1));
}
template<u32 func(const char *, int)> void WrapU_CI() {
int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1));
RETURN(retval);
}
template<int func(const char *, int, u32, int, u32)> void WrapU_CIUIU() {
int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2), PARAM(3), PARAM(4));
int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2),
PARAM(3), PARAM(4));
RETURN(retval);
}
template<u32 func(const char *, int, u32, int, u32, int)> void WrapU_CIUIUI() {
u32 retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2),
PARAM(3), PARAM(4), PARAM(5));
RETURN(retval);
}
template<u32 func(u32, u32, u32, u32, u32, u32)> void WrapU_UUUUUU() {
u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4), PARAM(5));
u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4),
PARAM(5));
RETURN(retval);
}
@ -274,4 +337,4 @@ template<int func(int, u32, u32, u32)> void WrapI_IUUU() {
template<int func(int, u32, u32)> void WrapI_IUU() {
int retval = func(PARAM(0), PARAM(1), PARAM(2));
RETURN(retval);
}
}

View file

@ -28,7 +28,6 @@
// TODO: This doesn't really belong here
static int state;
void __GeInit()
{
state = 0;
@ -42,26 +41,26 @@ void __GeShutdown()
// The GE is implemented wrong - it should be parallel to the CPU execution instead of
// synchronous.
u32 sceGeEdramGetAddr()
{
u32 retVal = 0x04000000;
DEBUG_LOG(HLE,"%08x = sceGeEdramGetAddr",retVal);
DEBUG_LOG(HLE, "%08x = sceGeEdramGetAddr", retVal);
return retVal;
}
u32 sceGeEdramGetSize()
{
u32 retVal = 0x00200000;
DEBUG_LOG(HLE,"%08x = sceGeEdramGetSize()",retVal);
DEBUG_LOG(HLE, "%08x = sceGeEdramGetSize()", retVal);
return retVal;
}
u32 sceGeListEnQueue(u32 listAddress, u32 stallAddress, u32 callbackId, u32 optParamAddr)
u32 sceGeListEnQueue(u32 listAddress, u32 stallAddress, u32 callbackId,
u32 optParamAddr)
{
DEBUG_LOG(HLE,"sceGeListEnQueue(addr=%08x, stall=%08x, cbid=%08x, param=%08x)",
listAddress,stallAddress,callbackId,optParamAddr);
DEBUG_LOG(HLE,
"sceGeListEnQueue(addr=%08x, stall=%08x, cbid=%08x, param=%08x)",
listAddress, stallAddress, callbackId, optParamAddr);
//if (!stallAddress)
// stallAddress = listAddress;
u32 listID = gpu->EnqueueList(listAddress, stallAddress);
@ -71,76 +70,83 @@ u32 sceGeListEnQueue(u32 listAddress, u32 stallAddress, u32 callbackId, u32 optP
else
state = SCE_GE_LIST_COMPLETED;
DEBUG_LOG(HLE,"List %i enqueued.", listID);
DEBUG_LOG(HLE, "List %i enqueued.", listID);
//return display list ID
return listID;
}
u32 sceGeListEnQueueHead(u32 listAddress, u32 stallAddress, u32 callbackId, u32 optParamAddr)
u32 sceGeListEnQueueHead(u32 listAddress, u32 stallAddress, u32 callbackId,
u32 optParamAddr)
{
DEBUG_LOG(HLE,"sceGeListEnQueueHead(addr=%08x, stall=%08x, cbid=%08x, param=%08x)",
listAddress,stallAddress,callbackId,optParamAddr);
DEBUG_LOG(HLE,
"sceGeListEnQueueHead(addr=%08x, stall=%08x, cbid=%08x, param=%08x)",
listAddress, stallAddress, callbackId, optParamAddr);
//if (!stallAddress)
// stallAddress = listAddress;
u32 listID = gpu->EnqueueList(listAddress,stallAddress);
u32 listID = gpu->EnqueueList(listAddress, stallAddress);
// HACKY
if (listID)
state = SCE_GE_LIST_STALLING;
else
state = SCE_GE_LIST_COMPLETED;
DEBUG_LOG(HLE,"List %i enqueued.", listID);
DEBUG_LOG(HLE, "List %i enqueued.", listID);
//return display list ID
return listID;
}
void sceGeListUpdateStallAddr(u32 displayListID, u32 stallAddress)
void sceGeListUpdateStallAddr(u32 displayListID, u32 stallAddress)
{
DEBUG_LOG(HLE,"sceGeListUpdateStallAddr(dlid=%i,stalladdr=%08x)",
displayListID,stallAddress);
DEBUG_LOG(HLE, "sceGeListUpdateStallAddr(dlid=%i,stalladdr=%08x)",
displayListID, stallAddress);
gpu->UpdateStall(displayListID, stallAddress);
}
void sceGeListSync(u32 displayListID, u32 mode) //0 : wait for completion 1:check and return
{
DEBUG_LOG(HLE,"sceGeListSync(dlid=%08x, mode=%08x)", displayListID,mode);
DEBUG_LOG(HLE, "sceGeListSync(dlid=%08x, mode=%08x)", displayListID, mode);
}
u32 sceGeDrawSync(u32 mode)
{
//wait/check entire drawing state
DEBUG_LOG(HLE,"FAKE sceGeDrawSync(mode=%d) (0=wait for completion)",mode);
DEBUG_LOG(HLE, "FAKE sceGeDrawSync(mode=%d) (0=wait for completion)",
mode);
gpu->DrawSync(mode);
return 0;
}
void sceGeContinue()
{
ERROR_LOG(HLE,"UNIMPL sceGeContinue");
ERROR_LOG(HLE, "UNIMPL sceGeContinue");
// no arguments
}
void sceGeBreak()
void sceGeBreak(u32 mode)
{
u32 mode = PARAM(0); //0 : current dlist 1: all drawing
ERROR_LOG(HLE,"UNIMPL sceGeBreak(mode=%d)",mode);
//mode => 0 : current dlist 1: all drawing
ERROR_LOG(HLE, "UNIMPL sceGeBreak(mode=%d)", mode);
}
u32 sceGeSetCallback(u32 structAddr)
{
DEBUG_LOG(HLE,"sceGeSetCallback(struct=%08x)", structAddr);
DEBUG_LOG(HLE, "sceGeSetCallback(struct=%08x)", structAddr);
PspGeCallbackData ge_callback_data;
Memory::ReadStruct(structAddr, &ge_callback_data);
if (ge_callback_data.finish_func) {
sceKernelRegisterSubIntrHandler(PSP_GE_INTR, PSP_GE_SUBINTR_FINISH, ge_callback_data.finish_func, ge_callback_data.finish_arg);
if (ge_callback_data.finish_func)
{
sceKernelRegisterSubIntrHandler(PSP_GE_INTR, PSP_GE_SUBINTR_FINISH,
ge_callback_data.finish_func, ge_callback_data.finish_arg);
sceKernelEnableSubIntr(PSP_GE_INTR, PSP_GE_SUBINTR_FINISH);
}
if (ge_callback_data.signal_func) {
sceKernelRegisterSubIntrHandler(PSP_GE_INTR, PSP_GE_SUBINTR_SIGNAL, ge_callback_data.signal_func, ge_callback_data.signal_arg);
if (ge_callback_data.signal_func)
{
sceKernelRegisterSubIntrHandler(PSP_GE_INTR, PSP_GE_SUBINTR_SIGNAL,
ge_callback_data.signal_func, ge_callback_data.signal_arg);
sceKernelEnableSubIntr(PSP_GE_INTR, PSP_GE_SUBINTR_SIGNAL);
}
@ -148,9 +154,8 @@ u32 sceGeSetCallback(u32 structAddr)
return 0;
}
void sceGeUnsetCallback(u32 cbID)
{
DEBUG_LOG(HLE,"sceGeUnsetCallback(cbid=%08x)", cbID);
void sceGeUnsetCallback(u32 cbID) {
DEBUG_LOG(HLE, "sceGeUnsetCallback(cbid=%08x)", cbID);
sceKernelReleaseSubIntrHandler(PSP_GE_INTR, PSP_GE_SUBINTR_FINISH);
sceKernelReleaseSubIntrHandler(PSP_GE_INTR, PSP_GE_SUBINTR_SIGNAL);
}
@ -159,15 +164,17 @@ void sceGeUnsetCallback(u32 cbID)
// unless some insane game pokes it and relies on it...
u32 sceGeSaveContext(u32 ctxAddr)
{
DEBUG_LOG(HLE,"sceGeSaveContext(%08x)", ctxAddr);
DEBUG_LOG(HLE, "sceGeSaveContext(%08x)", ctxAddr);
if (sizeof(gstate) > 512 * 4) {
if (sizeof(gstate) > 512 * 4)
{
ERROR_LOG(HLE, "AARGH! sizeof(gstate) has grown too large!");
return 0;
}
// Let's just dump gstate.
if (Memory::IsValidAddress(ctxAddr)) {
if (Memory::IsValidAddress(ctxAddr))
{
Memory::WriteStruct(ctxAddr, &gstate);
}
@ -178,14 +185,16 @@ u32 sceGeSaveContext(u32 ctxAddr)
u32 sceGeRestoreContext(u32 ctxAddr)
{
DEBUG_LOG(HLE,"sceGeRestoreContext(%08x)", ctxAddr);
DEBUG_LOG(HLE, "sceGeRestoreContext(%08x)", ctxAddr);
if (sizeof(gstate) > 512 * 4) {
if (sizeof(gstate) > 512 * 4)
{
ERROR_LOG(HLE, "AARGH! sizeof(gstate) has grown too large!");
return 0;
}
if (Memory::IsValidAddress(ctxAddr)) {
if (Memory::IsValidAddress(ctxAddr))
{
Memory::ReadStruct(ctxAddr, &gstate);
}
ReapplyGfxState();
@ -195,17 +204,16 @@ u32 sceGeRestoreContext(u32 ctxAddr)
void sceGeGetMtx()
{
ERROR_LOG(HLE,"UNIMPL sceGeGetMtx()");
ERROR_LOG(HLE, "UNIMPL sceGeGetMtx()");
}
void sceGeEdramSetAddrTranslation()
u32 sceGeEdramSetAddrTranslation(int new_size)
{
int new_size = PARAM(0);
INFO_LOG(HLE,"sceGeEdramSetAddrTranslation(%i)", new_size);
INFO_LOG(HLE, "sceGeEdramSetAddrTranslation(%i)", new_size);
static int EDRamWidth;
int last = EDRamWidth;
EDRamWidth = new_size;
RETURN(last);
return last;
}
const HLEFunction sceGe_user[] =
@ -216,12 +224,12 @@ const HLEFunction sceGe_user[] =
{0xE0D68148,&WrapV_UU<sceGeListUpdateStallAddr>, "sceGeListUpdateStallAddr"},
{0x03444EB4,&WrapV_UU<sceGeListSync>, "sceGeListSync"},
{0xB287BD61,&WrapU_U<sceGeDrawSync>, "sceGeDrawSync"},
{0xB448EC0D,sceGeBreak, "sceGeBreak"},
{0xB448EC0D,&WrapV_U<sceGeBreak>, "sceGeBreak"},
{0x4C06E472,sceGeContinue, "sceGeContinue"},
{0xA4FC06A4,&WrapU_U<sceGeSetCallback>, "sceGeSetCallback"},
{0x05DB22CE,&WrapV_U<sceGeUnsetCallback>, "sceGeUnsetCallback"},
{0x1F6752AD,&WrapU_V<sceGeEdramGetSize>, "sceGeEdramGetSize"},
{0xB77905EA,&sceGeEdramSetAddrTranslation,"sceGeEdramSetAddrTranslation"},
{0xB77905EA,&WrapU_I<sceGeEdramSetAddrTranslation>,"sceGeEdramSetAddrTranslation"},
{0xDC93CFEF,0,"sceGeGetCmd"},
{0x57C8945B,&sceGeGetMtx,"sceGeGetMtx"},
{0x438A385A,&WrapU_U<sceGeSaveContext>,"sceGeSaveContext"},

File diff suppressed because it is too large Load diff