From 21ccc60b87bbbaa3e0215880a7702b561bf497d0 Mon Sep 17 00:00:00 2001 From: Yn5an3 Date: Mon, 3 Dec 2012 23:37:14 +0100 Subject: [PATCH 1/3] Wrapped sceGe.cpp functions --- Core/HLE/sceGe.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Core/HLE/sceGe.cpp b/Core/HLE/sceGe.cpp index 3237373e03..d2c04260d2 100644 --- a/Core/HLE/sceGe.cpp +++ b/Core/HLE/sceGe.cpp @@ -121,9 +121,9 @@ void sceGeContinue() // no arguments } -void sceGeBreak() +void sceGeBreak(u32 mode) { - u32 mode = PARAM(0); //0 : current dlist 1: all drawing + //mode => 0 : current dlist 1: all drawing ERROR_LOG(HLE,"UNIMPL sceGeBreak(mode=%d)",mode); } @@ -198,14 +198,13 @@ void 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); static int EDRamWidth; int last = EDRamWidth; EDRamWidth = new_size; - RETURN(last); + return last; } const HLEFunction sceGe_user[] = @@ -216,12 +215,12 @@ const HLEFunction sceGe_user[] = {0xE0D68148,&WrapV_UU, "sceGeListUpdateStallAddr"}, {0x03444EB4,&WrapV_UU, "sceGeListSync"}, {0xB287BD61,&WrapU_U, "sceGeDrawSync"}, - {0xB448EC0D,sceGeBreak, "sceGeBreak"}, + {0xB448EC0D,&WrapV_U, "sceGeBreak"}, {0x4C06E472,sceGeContinue, "sceGeContinue"}, {0xA4FC06A4,&WrapU_U, "sceGeSetCallback"}, {0x05DB22CE,&WrapV_U, "sceGeUnsetCallback"}, {0x1F6752AD,&WrapU_V, "sceGeEdramGetSize"}, - {0xB77905EA,&sceGeEdramSetAddrTranslation,"sceGeEdramSetAddrTranslation"}, + {0xB77905EA,&WrapU_I,"sceGeEdramSetAddrTranslation"}, {0xDC93CFEF,0,"sceGeGetCmd"}, {0x57C8945B,&sceGeGetMtx,"sceGeGetMtx"}, {0x438A385A,&WrapU_U,"sceGeSaveContext"}, From 85177ebf09aaf6b44b9a71bf74495f09b946894e Mon Sep 17 00:00:00 2001 From: Yn5an3 Date: Wed, 5 Dec 2012 15:49:48 +0100 Subject: [PATCH 2/3] Wrapped funtions in sceIo.cpp --- Core/HLE/FunctionWrappers.h | 65 +++++- Core/HLE/sceIo.cpp | 421 ++++++++++++++++-------------------- 2 files changed, 246 insertions(+), 240 deletions(-) diff --git a/Core/HLE/FunctionWrappers.h b/Core/HLE/FunctionWrappers.h index 8cec9e7537..907fd7e7a8 100644 --- a/Core/HLE/FunctionWrappers.h +++ b/Core/HLE/FunctionWrappers.h @@ -29,6 +29,7 @@ template void WrapU64_V() { currentMIPS->r[3] = (retval >> 32) & 0xFFFFFFFF; } +//This seems to be wrong template void WrapI_UU64() { u64 param_one = currentMIPS->r[5]; param_one |= (u64)(currentMIPS->r[6])<< 32; @@ -43,6 +44,11 @@ template void WrapI_UUU64() { RETURN(retval); } +template void WrapU_II64I(){ + s64 param_one = ((s64)PARAM(2)) | ((s64)(PARAM(3))<<32); + u32 retval = func(PARAM(0), param_one, PARAM(4)); + RETURN(retval); +} //32bit wrappers template void WrapV_V() { @@ -53,6 +59,11 @@ template void WrapU_V() { RETURN(func()); } +template void WrapU_IVI(){ + u32 retval = func(PARAM(0), Memory::GetPointer(PARAM(1)), PARAM(2)); + RETURN(retval); +} + template void WrapF_V() { RETURNF(func()); } @@ -72,6 +83,11 @@ template void WrapI_U() { RETURN(retval); } +template void WrapU_IUI() { + u32 retval = func(PARAM(0), PARAM(1),PARAM(2)); + RETURN(retval); +} + template void WrapI_UU() { int retval = func(PARAM(0), PARAM(1)); RETURN(retval); @@ -156,6 +172,17 @@ template void WrapV_UI() { func(PARAM(0), PARAM(1)); } +template void WrapU_C(){ + u32 retval = func(Memory::GetCharPointer(PARAM(0))); + RETURN(retval); +} + +template void WrapU_CCCU(){ + u32 retval = func(Memory::GetCharPointer(PARAM(0)),Memory::GetCharPointer(PARAM(1)), + Memory::GetCharPointer(PARAM(2)), PARAM(3)); + RETURN(retval); +} + template void WrapI_CU() { int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1)); RETURN(retval); @@ -167,20 +194,30 @@ template void WrapI_CUUU() { } template void WrapU_CU() { - int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1)); + u32 retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1)); RETURN((u32)retval); } template void WrapU_UC() { - int retval = func(PARAM(0), Memory::GetCharPointer(PARAM(1))); + u32 retval = func(PARAM(0), Memory::GetCharPointer(PARAM(1))); RETURN(retval); } template void WrapU_CUU() { - int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2)); + u32 retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2)); RETURN((u32)retval); } +template void WrapU_III() { + u32 retval = func(PARAM(0), PARAM(1), PARAM(2)); + RETURN(retval); +} + +template void WrapU_IUU() { + u32 retval = func(PARAM(0), PARAM(1), PARAM(2)); + RETURN(retval); +} + template void WrapU_UUU() { u32 retval = func(PARAM(0), PARAM(1), PARAM(2)); RETURN(retval); @@ -251,11 +288,31 @@ template void WrapV_UUUUU() { func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)); } +template void WrapU_CC() { + int retval = func(Memory::GetCharPointer(PARAM(0)), Memory::GetCharPointer(PARAM(1))); + RETURN(retval); +} + +template void WrapV_CI() { + func(Memory::GetCharPointer(PARAM(0)), PARAM(1)); +} + +template void WrapU_CI() { + int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1)); + RETURN(retval); +} + template void WrapU_CIUIU() { int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2), PARAM(3), PARAM(4)); RETURN(retval); } +template void WrapU_CIUIUI() { + u32 retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2), PARAM(3), PARAM(4), + PARAM(5)); + RETURN(retval); +} + template void WrapU_UUUUUU() { u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4), PARAM(5)); RETURN(retval); @@ -269,4 +326,4 @@ template void WrapI_IUUU() { template void WrapI_IUU() { int retval = func(PARAM(0), PARAM(1), PARAM(2)); RETURN(retval); -} \ No newline at end of file +} diff --git a/Core/HLE/sceIo.cpp b/Core/HLE/sceIo.cpp index 6b5501cfe2..0bc69d5957 100644 --- a/Core/HLE/sceIo.cpp +++ b/Core/HLE/sceIo.cpp @@ -187,31 +187,27 @@ void __IoShutdown() } -void sceIoAssign() +u32 sceIoAssign(const char *aliasname, const char *physname, const char *devname, u32 flag) { - const char *aliasname = Memory::GetCharPointer(PARAM(0)); - const char *physname = Memory::GetCharPointer(PARAM(1)); - const char *devname = Memory::GetCharPointer(PARAM(2)); - u32 flag = PARAM(3); ERROR_LOG(HLE,"UNIMPL sceIoAssign(%s, %s, %s, %08x, ...)",aliasname,physname,devname,flag); - RETURN(0); + return 0; } -void sceKernelStdin() +u32 sceKernelStdin() { DEBUG_LOG(HLE,"3=sceKernelStdin()"); - RETURN(3); + return 3; } -void sceKernelStdout() +u32 sceKernelStdout() { DEBUG_LOG(HLE,"1=sceKernelStdout()"); - RETURN(1); + return 1; } -void sceKernelStderr() +u32 sceKernelStderr() { DEBUG_LOG(HLE,"2=sceKernelStderr()"); - RETURN(2); + return 2; } void __IoCompleteAsyncIO(SceUID id) @@ -245,11 +241,8 @@ void __IoGetStat(SceIoStat *stat, PSPFileInfo &info) } -void sceIoGetstat() +u32 sceIoGetstat(const char *filename, u32 addr) { - const char *filename = Memory::GetCharPointer(PARAM(0)); - u32 addr = PARAM(1); - SceIoStat stat; PSPFileInfo info = pspFileSystem.GetFileInfo(filename); __IoGetStat(&stat, info); @@ -257,87 +250,81 @@ void sceIoGetstat() DEBUG_LOG(HLE,"sceIoGetstat(%s, %08x) : sector = %08x",filename,addr,info.startSector); - RETURN(0); + return 0; } -void sceIoRead() //(int fd, void *data, int size); +//Not sure about wrapping it or not, since the log seems to take the address of the data var +u32 sceIoRead(int id, u32 data_addr, int size) //(int fd, void *data, int size); { - SceUID id = PARAM(0); if (id == 3) { DEBUG_LOG(HLE,"sceIoRead STDIN"); - RETURN(0); //stdin - return; + return 0; //stdin } u32 error; FileNode *f = kernelObjects.Get(id, error); if (f) { - if (PARAM(1)) + if (data_addr) { - u8 *data = (u8*)Memory::GetPointer(PARAM(1)); - int size = PARAM(2); - f->asyncResult = RETURN((u32)pspFileSystem.ReadFile(f->handle, data, size)); - DEBUG_LOG(HLE,"%i=sceIoRead(%d, %08x , %i)",f->asyncResult, id, PARAM(1), size); + u8 *data = (u8*)Memory::GetPointer(data_addr); + f->asyncResult = (u32)pspFileSystem.ReadFile(f->handle, data, size); + DEBUG_LOG(HLE,"%i=sceIoRead(%d, %08x , %i)",f->asyncResult, id, data_addr, size); + return f->asyncResult; } else { ERROR_LOG(HLE,"sceIoRead Reading into zero pointer"); - RETURN(-1); + return -1; } } else { ERROR_LOG(HLE,"sceIoRead ERROR: no file open"); - RETURN(error); + return error; } } -void sceIoWrite() //(int fd, void *data, int size); +u32 sceIoWrite(int id, void *data_ptr, int size) //(int fd, void *data, int size); { - SceUID id = PARAM(0); - int size = PARAM(2); - if (PARAM(0) == 2) + + if (id == 2) { - //stderr! - const char *str = Memory::GetCharPointer(PARAM(1)); + //stderr! + const char *str = (const char*)data_ptr; DEBUG_LOG(HLE,"stderr: %s", str); - RETURN(size); - return; + return size; } - if (PARAM(0) == 1) + if (id == 1) { //stdout! - char *str = (char *)Memory::GetPointer(PARAM(1)); + char *str = (char *)data_ptr; char temp = str[size]; str[size]=0; DEBUG_LOG(HLE,"stdout: %s", str); str[size]=temp; - RETURN(size); - return; + return size; } u32 error; FileNode *f = kernelObjects.Get(id, error); if (f) { - u8 *data = (u8*)Memory::GetPointer(PARAM(1)); - f->asyncResult = RETURN((u32)pspFileSystem.WriteFile(f->handle,data,size)); + u8 *data = (u8*)data_ptr; + f->asyncResult = (u32)pspFileSystem.WriteFile(f->handle,data,size); + return f->asyncResult; } else { ERROR_LOG(HLE,"sceIoWrite ERROR: no file open"); - RETURN(error); + return error; } } -void sceIoLseek() //(int fd, int64 offset, int whence); +u32 sceIoLseek(int id, s64 offset, int whence) //(int fd, int64 offset, int whence); { - SceUID id = PARAM(0); u32 error; FileNode *f = kernelObjects.Get(id, error); - s64 offset = ((s64)PARAM(2)) | ((s64)(PARAM(3))<<32); - int whence = PARAM(4); if (f) { FileMove seek = FILEMOVE_BEGIN; @@ -348,25 +335,23 @@ void sceIoLseek() //(int fd, int64 offset, int whence); case 2: seek=FILEMOVE_END;break; } - f->asyncResult = RETURN((u32)pspFileSystem.SeekFile(f->handle, (s32)offset, seek)); - DEBUG_LOG(HLE,"%i = sceIoLseek(%d,%i,%i)",f->asyncResult, id,(int)offset,whence); - } + f->asyncResult = (u32)pspFileSystem.SeekFile(f->handle, (s32)offset, seek); + DEBUG_LOG(HLE,"%i = sceIoLseek(%d,%i,%i)",f->asyncResult, id,(int)offset,whence); + return f->asyncResult; + } else { ERROR_LOG(HLE,"sceIoLseek(%d, %i, %i) - ERROR: invalid file", id, (int)offset, whence); - RETURN(error); + return error; } } -void sceIoLseek32() //(int fd, int offset, int whence); +u32 sceIoLseek32(int id, int offset, int whence) //(int fd, int offset, int whence); { - SceUID id = PARAM(0); u32 error; FileNode *f = kernelObjects.Get(id, error); if (f) { - s32 offset = (s32)PARAM(2); - int whence = PARAM(3); DEBUG_LOG(HLE,"sceIoLseek32(%d,%08x,%i)",id,(int)offset,whence); FileMove seek=FILEMOVE_BEGIN; @@ -377,21 +362,18 @@ void sceIoLseek32() //(int fd, int offset, int whence); case 2: seek=FILEMOVE_END;break; } - f->asyncResult = RETURN((u32)pspFileSystem.SeekFile(f->handle, (s32)offset, seek)); + f->asyncResult = (u32)pspFileSystem.SeekFile(f->handle, (s32)offset, seek); + return f->asyncResult; } else { ERROR_LOG(HLE,"sceIoLseek32 ERROR: no file open"); - RETURN(error); + return error; } } -// Try WrapI_CU -void sceIoOpen() //(const char* file, int mode); +u32 sceIoOpen(const char* filename, int mode) //(const char* file, int mode); { - const char *filename = Memory::GetCharPointer(PARAM(0)); - int mode = PARAM(1); - //memory stick filename int access=FILEACCESS_NONE; if (mode & O_RDONLY) access |= FILEACCESS_READ; @@ -403,8 +385,7 @@ void sceIoOpen() //(const char* file, int mode); if (h == 0) { ERROR_LOG(HLE,"ERROR_ERRNO_FILE_NOT_FOUND=sceIoOpen(%s, %08x) - file not found", filename, mode); - RETURN(ERROR_ERRNO_FILE_NOT_FOUND); - return; + return ERROR_ERRNO_FILE_NOT_FOUND; } FileNode *f = new FileNode(); @@ -413,45 +394,40 @@ void sceIoOpen() //(const char* file, int mode); f->fullpath = filename; f->asyncResult = id; DEBUG_LOG(HLE,"%i=sceIoOpen(%s, %08x)",id,filename,mode); - RETURN(id); + return id; } -void sceIoClose() //(int fd); +u32 sceIoClose(int id) //(int fd); { - SceUID f = PARAM(0); - DEBUG_LOG(HLE,"sceIoClose(%d)",f); - RETURN(kernelObjects.Destroy(f)); + DEBUG_LOG(HLE,"sceIoClose(%d)",id); + return kernelObjects.Destroy(id); } -void sceIoRemove() //(const char *file); +u32 sceIoRemove(const char *filename) //(const char *file); { - const char *filename = Memory::GetCharPointer(PARAM(0)); + DEBUG_LOG(HLE,"sceIoRemove(%s)", filename); if (pspFileSystem.DeleteFile(filename)) - RETURN(0); + return 0; else - RETURN(-1); - DEBUG_LOG(HLE,"sceIoRemove(%s)", filename); + return -1; } -void sceIoMkdir() //(const char *dir, int mode); +u32 sceIoMkdir(const char *dirname, int mode) //(const char *dir, int mode); { - const char *filename = Memory::GetCharPointer(PARAM(0)); - int mode = PARAM(1); - if (pspFileSystem.MkDir(filename)) - RETURN(0); + DEBUG_LOG(HLE,"sceIoMkdir(%s, %i)", dirname, mode); + if (pspFileSystem.MkDir(dirname)) + return 0; else - RETURN(-1); - DEBUG_LOG(HLE,"sceIoMkdir(%s, %i)", filename, mode); + return -1; } -void sceIoRmdir() //(const char *dir); +u32 sceIoRmdir(const char *dirname) { - const char *filename = Memory::GetCharPointer(PARAM(0)); - if (pspFileSystem.RmDir(filename)) - RETURN(0); + DEBUG_LOG(HLE,"sceIoRmdir(%s)", dirname); + if (pspFileSystem.RmDir(dirname)) + return 0; else - RETURN(-1); - DEBUG_LOG(HLE,"sceIoRmdir(%s)", filename); + return -1; } void sceIoSync() @@ -468,14 +444,9 @@ struct DeviceSize u32 freeClusters; }; -void sceIoDevctl() //(const char *name, int cmd, void *arg, size_t arglen, void *buf, size_t *buflen); +u32 sceIoDevctl(const char *name, int cmd, u32 argAddr, int argLen, + u32 outPtr, int outLen) //(const char *name, int cmd, void *arg, size_t arglen, void *buf, size_t *buflen); { - const char *name = Memory::GetCharPointer(PARAM(0)); - int cmd = PARAM(1); - u32 argAddr = PARAM(2); - int argLen = PARAM(3); - u32 outPtr = PARAM(4); - int outLen = PARAM(5); if (strcmp(name, "emulator:")) { DEBUG_LOG(HLE,"sceIoDevctl(\"%s\", %08x, %08x, %i, %08x, %i)", name, cmd,argAddr,argLen,outPtr,outLen); @@ -486,22 +457,21 @@ void sceIoDevctl() //(const char *name, int cmd, void *arg, size_t arglen, void case 0x01F20001: // Get Disc Type. if (Memory::IsValidAddress(outPtr)) { Memory::Write_U32(0x10, outPtr); // Game disc - RETURN(0); return; + return 0; } else { - RETURN(-1); return; + return -1; } break; case 0x01F20002: // Get current LBA. if (Memory::IsValidAddress(outPtr)) { Memory::Write_U32(0, outPtr); // Game disc - RETURN(0); return; + return 0; } else { - RETURN(-1); return; + return -1; } break; case 0x01F100A3: // Seek - RETURN(0); return; - break; + return 0; } // This should really send it on to a FileSystem implementation instead. @@ -517,11 +487,10 @@ void sceIoDevctl() //(const char *name, int cmd, void *arg, size_t arglen, void if (0 == __KernelRegisterCallback(THREAD_CALLBACK_MEMORYSTICK, cbId)) { DEBUG_LOG(HLE, "sceIoDevCtl: Memstick callback %i registered, notifying immediately.", cbId); __KernelNotifyCallbackType(THREAD_CALLBACK_MEMORYSTICK, cbId, MemoryStick_State()); - RETURN(0); + return 0; } else { - RETURN(ERROR_MEMSTICK_DEVCTL_BAD_PARAMS); + return ERROR_MEMSTICK_DEVCTL_BAD_PARAMS; } - return; } break; @@ -530,11 +499,10 @@ void sceIoDevctl() //(const char *name, int cmd, void *arg, size_t arglen, void u32 cbId = Memory::Read_U32(argAddr); if (0 == __KernelUnregisterCallback(THREAD_CALLBACK_MEMORYSTICK, cbId)) { DEBUG_LOG(HLE, "sceIoDevCtl: Unregistered memstick callback %i", cbId); - RETURN(0); + return 0; } else { - RETURN(ERROR_MEMSTICK_DEVCTL_BAD_PARAMS); + return ERROR_MEMSTICK_DEVCTL_BAD_PARAMS; } - return; } break; @@ -542,11 +510,10 @@ void sceIoDevctl() //(const char *name, int cmd, void *arg, size_t arglen, void case 0x02025801: // Memstick Driver status? if (Memory::IsValidAddress(outPtr)) { Memory::Write_U32(1, outPtr); - RETURN(0); + return 0; } else { - RETURN(ERROR_MEMSTICK_DEVCTL_BAD_PARAMS); + return ERROR_MEMSTICK_DEVCTL_BAD_PARAMS; } - return; case 0x02425818: // Get memstick size etc // Pretend we have a 2GB memory stick. @@ -562,11 +529,10 @@ void sceIoDevctl() //(const char *name, int cmd, void *arg, size_t arglen, void deviceSize.totalClusters = (u32)((totalSize * 95 / 100) / (deviceSize.sectorSize * deviceSize.sectorsPerCluster)); deviceSize.freeClusters = (u32)((freeSize * 95 / 100) / (deviceSize.sectorSize * deviceSize.sectorsPerCluster)); Memory::WriteStruct(pointer, &deviceSize); - RETURN(0); + return 0; } else { - RETURN(ERROR_MEMSTICK_DEVCTL_BAD_PARAMS); + return ERROR_MEMSTICK_DEVCTL_BAD_PARAMS; } - return; } } @@ -579,11 +545,10 @@ void sceIoDevctl() //(const char *name, int cmd, void *arg, size_t arglen, void if (0 == __KernelRegisterCallback(THREAD_CALLBACK_MEMORYSTICK_FAT, cbId)) { DEBUG_LOG(HLE, "sceIoDevCtl: Memstick FAT callback %i registered, notifying immediately.", cbId); __KernelNotifyCallbackType(THREAD_CALLBACK_MEMORYSTICK_FAT, cbId, MemoryStick_FatState()); - RETURN(0); + return 0; } else { - RETURN(-1); + return -1; } - return; } break; case 0x02415822: // MScmUnregisterMSInsertEjectCallback @@ -591,30 +556,29 @@ void sceIoDevctl() //(const char *name, int cmd, void *arg, size_t arglen, void u32 cbId = Memory::Read_U32(argAddr); if (0 == __KernelUnregisterCallback(THREAD_CALLBACK_MEMORYSTICK_FAT, cbId)) { DEBUG_LOG(HLE, "sceIoDevCtl: Unregistered memstick FAT callback %i", cbId); - RETURN(0); + return 0; } else { - RETURN(-1); + return -1; } - return; } case 0x02415823: // Set FAT as enabled if (Memory::IsValidAddress(argAddr) && argLen == 4) { MemoryStick_SetFatState((MemStickFatState)Memory::Read_U32(argAddr)); - RETURN(0); + return 0; } else { ERROR_LOG(HLE, "Failed 0x02415823 fat"); - RETURN(-1); + return -1; } break; case 0x02425823: // Check if FAT enabled if (Memory::IsValidAddress(outPtr) && outLen == 4) { Memory::Write_U32(MemoryStick_FatState(), outPtr); - RETURN(0); + return 0; } else { ERROR_LOG(HLE, "Failed 0x02425823 fat"); - RETURN(-1); + return -1; } break; @@ -633,11 +597,10 @@ void sceIoDevctl() //(const char *name, int cmd, void *arg, size_t arglen, void deviceSize.totalClusters = (u32)((totalSize * 95 / 100) / (deviceSize.sectorSize * deviceSize.sectorsPerCluster)); deviceSize.freeClusters = (u32)((freeSize * 95 / 100) / (deviceSize.sectorSize * deviceSize.sectorsPerCluster)); Memory::WriteStruct(pointer, &deviceSize); - RETURN(0); + return 0; } else { - RETURN(ERROR_MEMSTICK_DEVCTL_BAD_PARAMS); + return ERROR_MEMSTICK_DEVCTL_BAD_PARAMS; } - return; } } } @@ -651,8 +614,7 @@ void sceIoDevctl() //(const char *name, int cmd, void *arg, size_t arglen, void case 1: // EMULATOR_DEVCTL__GET_HAS_DISPLAY if (Memory::IsValidAddress(outPtr)) Memory::Write_U32(0, outPtr); // TODO: Make a headless mode for running tests! - RETURN(0); - return; + return 0; case 2: // EMULATOR_DEVCTL__SEND_OUTPUT { std::string data(Memory::GetCharPointer(argAddr), argLen); @@ -669,20 +631,17 @@ void sceIoDevctl() //(const char *name, int cmd, void *arg, size_t arglen, void { DEBUG_LOG(HLE, "%s", data.c_str()); } - RETURN(0); - return; + return 0; } case 3: // EMULATOR_DEVCTL__IS_EMULATOR if (Memory::IsValidAddress(outPtr)) Memory::Write_U32(1, outPtr); // TODO: Make a headless mode for running tests! - RETURN(0); - return; + return 0; } ERROR_LOG(HLE, "sceIoDevCtl: UNKNOWN PARAMETERS"); - RETURN(0); - return; + return 0; } //089c6d1c weird branch @@ -693,26 +652,23 @@ void sceIoDevctl() //(const char *name, int cmd, void *arg, size_t arglen, void 089c6c78 ]: HLE: sceIoDevctl("fatms0:", 02415821, 09ffb9c4, 4, 00000000, 0) (z_un_089c6bc4) 089c6cac ]: HLE: sceIoDevctl("mscmhc0:", 02025806, 00000000, 0, 09ffb9c8, 4) (z_un_089c6bc4) */ - RETURN(SCE_KERNEL_ERROR_UNSUP); + return SCE_KERNEL_ERROR_UNSUP; } -void sceIoRename() //(const char *oldname, const char *newname); +u32 sceIoRename(const char *from, const char *to) //(const char *oldname, const char *newname); { - const char *from = Memory::GetCharPointer(PARAM(0)); - const char *to = Memory::GetCharPointer(PARAM(1)); + DEBUG_LOG(HLE,"sceIoRename(%s, %s)", from, to); if (pspFileSystem.RenameFile(from, to)) - RETURN(0); + return 0; else - RETURN(-1); - DEBUG_LOG(HLE,"sceIoRename(%s, %s)", from, to); + return -1; } -void sceIoChdir() +u32 sceIoChdir(const char *dirname) { - const char *dir = Memory::GetCharPointer(PARAM(0)); - pspFileSystem.ChDir(dir); - DEBUG_LOG(HLE,"sceIoChdir(%s)",dir); - RETURN(1); + pspFileSystem.ChDir(dirname); + DEBUG_LOG(HLE,"sceIoChdir(%s)",dirname); + return 1; } typedef u32 (*DeferredAction)(SceUID id, int param); @@ -732,87 +688,85 @@ u32 __IoClose(SceUID id, int param) return kernelObjects.Destroy(id); } +//TODO Not really sure if this should be wrapped nor how void sceIoCloseAsync() { DEBUG_LOG(HLE,"sceIoCloseAsync(%d)",PARAM(0)); - //sceIoClose(); + //sceIoClose(); defAction = &__IoClose; - RETURN(0); + RETURN(0); } -void sceIoLseekAsync() +u32 sceIoLseekAsync(int id, s64 offset, int whence) { - sceIoLseek(); - __IoCompleteAsyncIO(PARAM(0)); - RETURN(0); + sceIoLseek(id,offset,whence); + __IoCompleteAsyncIO(id); + return 0; } -void sceIoSetAsyncCallback() +u32 sceIoSetAsyncCallback(int id, u32 clbckId, u32 clbckArg) { - DEBUG_LOG(HLE,"sceIoSetAsyncCallback(%d, %i, %08x)",PARAM(0), PARAM(1), PARAM(2)); + DEBUG_LOG(HLE,"sceIoSetAsyncCallback(%d, %i, %08x)", id, clbckId, clbckArg); - SceUID id = PARAM(0); - u32 error; + u32 error; FileNode *f = kernelObjects.Get(id, error); if (f) { - f->callbackID = PARAM(1); - f->callbackArg = PARAM(2); - RETURN(0); + f->callbackID = clbckId; + f->callbackArg = clbckArg; + return 0; } else { - RETURN(error); + return error; } } -void sceIoLseek32Async() +u32 sceIoLseek32Async(int id, int offset, int whence) { - DEBUG_LOG(HLE,"sceIoLseek32Async(%d) sorta implemented",PARAM(0)); - sceIoLseek32(); - __IoCompleteAsyncIO(PARAM(0)); - RETURN(0); + DEBUG_LOG(HLE,"sceIoLseek32Async(%d) sorta implemented", id); + sceIoLseek32(id, offset, whence); + __IoCompleteAsyncIO(id); + return 0; } -void sceIoOpenAsync() +void sceIoOpenAsync(const char *filename, int mode) { DEBUG_LOG(HLE,"sceIoOpenAsync() sorta implemented"); - sceIoOpen(); + sceIoOpen(filename, mode); // __IoCompleteAsyncIO(currentMIPS->r[2]); // The return value // We have to return a UID here, which may have been destroyed when we reach Wait if it failed. // Now that we're just faking it, we just don't RETURN(0) here. } -void sceIoReadAsync() +u32 sceIoReadAsync(int id, u32 data_addr, int size) { - DEBUG_LOG(HLE,"sceIoReadAsync(%d)",PARAM(0)); - sceIoRead(); - __IoCompleteAsyncIO(PARAM(0)); - RETURN(0); + DEBUG_LOG(HLE,"sceIoReadAsync(%d)",id); + sceIoRead(id, data_addr,size); + __IoCompleteAsyncIO(id); + return 0; } -void sceIoGetAsyncStat() +u32 sceIoGetAsyncStat(int id, u32 address, u32 uknwn) { - SceUID id = PARAM(0); u32 error; FileNode *f = kernelObjects.Get(id, error); if (f) { - Memory::Write_U64(f->asyncResult, PARAM(2)); - DEBUG_LOG(HLE,"%i = sceIoGetAsyncStat(%i, %i, %08x) (HACK)", (u32)f->asyncResult, id, PARAM(1), PARAM(2)); - RETURN(0); //completed + Memory::Write_U64(f->asyncResult, address); + DEBUG_LOG(HLE,"%i = sceIoGetAsyncStat(%i, %i, %08x) (HACK)", (u32)f->asyncResult, id, address, uknwn); + return 0; //completed } else { ERROR_LOG(HLE,"ERROR - sceIoGetAsyncStat with invalid id %i", id); - RETURN(-1); + return -1; } } -void sceIoWaitAsync() +u32 sceIoWaitAsync(int id, u32 address, u32 uknwn) { - SceUID id = PARAM(0); u32 error; FileNode *f = kernelObjects.Get(id, error); if (f) @@ -823,22 +777,21 @@ void sceIoWaitAsync() res = defAction(id, defParam); defAction = 0; } - Memory::Write_U64(res, PARAM(1)); - DEBUG_LOG(HLE,"%i = sceIoWaitAsync(%i, %08x) (HACK)", (u32)res, id, PARAM(1)); - RETURN(0); //completed + Memory::Write_U64(res, address); + DEBUG_LOG(HLE,"%i = sceIoWaitAsync(%i, %08x) (HACK)", (u32)res, id, uknwn); + return 0; //completed } else { ERROR_LOG(HLE,"ERROR - sceIoWaitAsync waiting for invalid id %i", id); - RETURN(-1); + return -1; } } -void sceIoWaitAsyncCB() +u32 sceIoWaitAsyncCB(int id, u32 address) { // Should process callbacks here - SceUID id = PARAM(0); u32 error; FileNode *f = kernelObjects.Get(id, error); if (f) @@ -849,9 +802,9 @@ void sceIoWaitAsyncCB() res = defAction(id, defParam); defAction = 0; } - Memory::Write_U64(res, PARAM(1)); - DEBUG_LOG(HLE,"%i = sceIoWaitAsyncCB(%i, %08x) (HACK)", (u32)res, id, PARAM(1)); - RETURN(0); //completed + Memory::Write_U64(res, address); + DEBUG_LOG(HLE,"%i = sceIoWaitAsyncCB(%i, %08x) (HACK)", (u32)res, id, address); + return 0; //completed } else { @@ -859,9 +812,8 @@ void sceIoWaitAsyncCB() } } -void sceIoPollAsync() +u32 sceIoPollAsync(int id, u32 address) { - SceUID id = PARAM(0); u32 error; FileNode *f = kernelObjects.Get(id, error); if (f) @@ -872,9 +824,9 @@ void sceIoPollAsync() res = defAction(id, defParam); defAction = 0; } - Memory::Write_U64(res, PARAM(1)); - DEBUG_LOG(HLE,"%i = sceIoPollAsync(%i, %08x) (HACK)", (u32)res, id, PARAM(1)); - RETURN(0); //completed + Memory::Write_U64(res, address); + DEBUG_LOG(HLE,"%i = sceIoPollAsync(%i, %08x) (HACK)", (u32)res, id, address); + return 0; //completed } else { @@ -895,9 +847,8 @@ public: int index; }; -void sceIoDopen() //(const char *path); +u32 sceIoDopen(const char *path ) //(const char *path); { - const char *path = Memory::GetCharPointer(PARAM(0)); DEBUG_LOG(HLE,"sceIoDopen(\"%s\")",path); DirListing *dir = new DirListing(); @@ -909,35 +860,34 @@ void sceIoDopen() //(const char *path); dir->index = 0; dir->name = std::string(path); - RETURN(id); + return id; } -void sceIoDread() +u32 sceIoDread(int id, u32 dirent_addr) { - SceUID id = PARAM(0); + u32 error; DirListing *dir = kernelObjects.Get(id, error); if (dir) { if (dir->index == (int)dir->listing.size()) { - DEBUG_LOG(HLE,"sceIoDread( %d %08x ) - end of the line", PARAM(0), PARAM(1)); - RETURN(0); - return; + DEBUG_LOG(HLE,"sceIoDread( %d %08x ) - end of the line", id, dirent_addr); + return 0; } PSPFileInfo &info = dir->listing[dir->index]; - SceIoDirEnt *entry = (SceIoDirEnt*)Memory::GetPointer(PARAM(1)); + SceIoDirEnt *entry = (SceIoDirEnt*)Memory::GetPointer(dirent_addr); __IoGetStat(&entry->d_stat, info); strncpy(entry->d_name, info.name.c_str(), 256); entry->d_private = 0xC0DEBABE; - DEBUG_LOG(HLE,"sceIoDread( %d %08x ) = %s", PARAM(0), PARAM(1), entry->d_name); + DEBUG_LOG(HLE,"sceIoDread( %d %08x ) = %s", id, dirent_addr, entry->d_name); dir->index++; - RETURN((u32)(dir->listing.size()-dir->index+1)); + return (u32)(dir->listing.size()-dir->index+1); } else { @@ -945,51 +895,50 @@ void sceIoDread() } } -void sceIoDclose() +u32 sceIoDclose(int id) { - u32 id = PARAM(0); DEBUG_LOG(HLE,"sceIoDclose(%d)",id); - RETURN(kernelObjects.Destroy(id)); + return kernelObjects.Destroy(id); } const HLEFunction IoFileMgrForUser[] = { - {0xb29ddf9c,sceIoDopen, "sceIoDopen"}, - {0xe3eb004c,sceIoDread, "sceIoDread"}, - {0xeb092469,sceIoDclose,"sceIoDclose"}, + {0xb29ddf9c,&WrapU_C, "sceIoDopen"}, + {0xe3eb004c,&WrapU_IU, "sceIoDread"}, + {0xeb092469,&WrapU_I,"sceIoDclose"}, {0xe95a012b,0,"sceIoIoctlAsync"}, {0x63632449,0,"sceIoIoctl"}, - {0xace946e8,sceIoGetstat,"sceIoGetstat"}, + {0xace946e8,&WrapU_CU,"sceIoGetstat"}, {0xb8a740f4,0,"sceIoChstat"}, - {0x55f4717d,sceIoChdir,"sceIoChdir"}, + {0x55f4717d,&WrapU_C,"sceIoChdir"}, {0x08bd7374,0,"sceIoGetDevType"}, - {0xB2A628C1,sceIoAssign,"sceIoAssign"}, + {0xB2A628C1,&WrapU_CCCU,"sceIoAssign"}, {0xe8bc6571,0,"sceIoCancel"}, {0xb293727f,sceIoChangeAsyncPriority,"sceIoChangeAsyncPriority"}, - {0x810C4BC3,sceIoClose, "sceIoClose"}, //(int fd); + {0x810C4BC3,&WrapU_I, "sceIoClose"}, //(int fd); {0xff5940b6,sceIoCloseAsync,"sceIoCloseAsync"}, - {0x54F5FB11,sceIoDevctl,"sceIoDevctl"}, //(const char *name int cmd, void *arg, size_t arglen, void *buf, size_t *buflen); - {0xcb05f8d6,sceIoGetAsyncStat,"sceIoGetAsyncStat"}, - {0x27EB27B8,sceIoLseek, "sceIoLseek"}, //(int fd, int offset, int whence); - {0x68963324,sceIoLseek32,"sceIoLseek32"}, - {0x1b385d8f,sceIoLseek32Async,"sceIoLseek32Async"}, - {0x71b19e77,sceIoLseekAsync,"sceIoLseekAsync"}, - {0x109F50BC,sceIoOpen, "sceIoOpen"}, //(const char* file, int mode); - {0x89AA9906,sceIoOpenAsync,"sceIoOpenAsync"}, - {0x06A70004,sceIoMkdir,"sceIoMkdir"}, //(const char *dir, int mode); - {0x3251ea56,sceIoPollAsync,"sceIoPollAsync"}, - {0x6A638D83,sceIoRead, "sceIoRead"}, //(int fd, void *data, int size); - {0xa0b5a7c2,sceIoReadAsync,"sceIoReadAsync"}, - {0xF27A9C51,sceIoRemove,"sceIoRemove"}, //(const char *file); - {0x779103A0,sceIoRename,"sceIoRename"}, //(const char *oldname, const char *newname); - {0x1117C65F,sceIoRmdir,"sceIoRmdir"}, //(const char *dir); - {0xA12A0514,sceIoSetAsyncCallback,"sceIoSetAsyncCallback"}, + {0x54F5FB11,&WrapU_CIUIUI,"sceIoDevctl"}, //(const char *name int cmd, void *arg, size_t arglen, void *buf, size_t *buflen); + {0xcb05f8d6,&WrapU_IUU,"sceIoGetAsyncStat"}, + {0x27EB27B8,&WrapU_II64I, "sceIoLseek"}, //(int fd, int offset, int whence); + {0x68963324,&WrapU_III,"sceIoLseek32"}, + {0x1b385d8f,&WrapU_III,"sceIoLseek32Async"}, + {0x71b19e77,&WrapU_II64I,"sceIoLseekAsync"}, + {0x109F50BC,&WrapU_CI, "sceIoOpen"}, //(const char* file, int mode); + {0x89AA9906,&WrapV_CI,"sceIoOpenAsync"}, + {0x06A70004,&WrapU_CI,"sceIoMkdir"}, //(const char *dir, int mode); + {0x3251ea56,&WrapU_IU,"sceIoPollAsync"}, + {0x6A638D83,&WrapU_IUI, "sceIoRead"}, //(int fd, void *data, int size); + {0xa0b5a7c2,&WrapU_IUI,"sceIoReadAsync"}, + {0xF27A9C51,&WrapU_C,"sceIoRemove"}, //(const char *file); + {0x779103A0,&WrapU_CC,"sceIoRename"}, //(const char *oldname, const char *newname); + {0x1117C65F,&WrapU_C,"sceIoRmdir"}, //(const char *dir); + {0xA12A0514,&WrapU_IUU,"sceIoSetAsyncCallback"}, {0xab96437f,sceIoSync,"sceIoSync"}, {0x6d08a871,0,"sceIoUnassign"}, - {0x42EC03AC,sceIoWrite, "sceIoWrite"}, //(int fd, void *data, int size); + {0x42EC03AC,&WrapU_IVI, "sceIoWrite"}, //(int fd, void *data, int size); {0x0facab19,0,"sceIoWriteAsync"}, - {0x35dbd746,sceIoWaitAsyncCB,"sceIoWaitAsyncCB"}, - {0xe23eec33,sceIoWaitAsync,"sceIoWaitAsync"}, + {0x35dbd746,&WrapU_IU,"sceIoWaitAsyncCB"}, + {0xe23eec33,&WrapU_IUU,"sceIoWaitAsync"}, }; void Register_IoFileMgrForUser() @@ -1000,9 +949,9 @@ void Register_IoFileMgrForUser() const HLEFunction StdioForUser[] = { - {0x172D316E,sceKernelStdin,"sceKernelStdin"}, - {0xA6BAB2E9,sceKernelStdout,"sceKernelStdout"}, - {0xF78BA90A,sceKernelStderr,"sceKernelStderr"}, + {0x172D316E,&WrapU_V,"sceKernelStdin"}, + {0xA6BAB2E9,&WrapU_V,"sceKernelStdout"}, + {0xF78BA90A,&WrapU_V,"sceKernelStderr"}, }; void Register_StdioForUser() From 8d5125ea8b9e0b3bcadb3f1a443195e5f70f0fd9 Mon Sep 17 00:00:00 2001 From: Yn5an3 Date: Wed, 5 Dec 2012 22:19:14 +0100 Subject: [PATCH 3/3] Cleaned identation, solved bug in WrapI_UU64(). Ammended sceIoWaitAsync and sceIoWaitAsyncCB since they can not be wrapped. --- Core/HLE/FunctionWrappers.h | 94 +++-- Core/HLE/sceGe.cpp | 87 ++-- Core/HLE/sceIo.cpp | 788 +++++++++++++++++++----------------- 3 files changed, 509 insertions(+), 460 deletions(-) diff --git a/Core/HLE/FunctionWrappers.h b/Core/HLE/FunctionWrappers.h index 907fd7e7a8..9f4d5447a9 100644 --- a/Core/HLE/FunctionWrappers.h +++ b/Core/HLE/FunctionWrappers.h @@ -29,25 +29,25 @@ template void WrapU64_V() { currentMIPS->r[3] = (retval >> 32) & 0xFFFFFFFF; } -//This seems to be wrong template 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 void WrapI_UUU64() { +template 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 void WrapU_II64I(){ - s64 param_one = ((s64)PARAM(2)) | ((s64)(PARAM(3))<<32); - u32 retval = func(PARAM(0), param_one, PARAM(4)); - RETURN(retval); +template 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 @@ -59,9 +59,9 @@ template void WrapU_V() { RETURN(func()); } -template void WrapU_IVI(){ - u32 retval = func(PARAM(0), Memory::GetPointer(PARAM(1)), PARAM(2)); - RETURN(retval); +template void WrapU_IVI() { + u32 retval = func(PARAM(0), Memory::GetPointer(PARAM(1)), PARAM(2)); + RETURN(retval); } template void WrapF_V() { @@ -84,8 +84,8 @@ template void WrapI_U() { } template void WrapU_IUI() { - u32 retval = func(PARAM(0), PARAM(1),PARAM(2)); - RETURN(retval); + u32 retval = func(PARAM(0), PARAM(1), PARAM(2)); + RETURN(retval); } template void WrapI_UU() { @@ -148,7 +148,6 @@ template void WrapI_UUI() { RETURN(retval); } - template void WrapI_II() { int retval = func(PARAM(0), PARAM(1)); RETURN(retval); @@ -172,15 +171,16 @@ template void WrapV_UI() { func(PARAM(0), PARAM(1)); } -template void WrapU_C(){ - u32 retval = func(Memory::GetCharPointer(PARAM(0))); - RETURN(retval); +template void WrapU_C() { + u32 retval = func(Memory::GetCharPointer(PARAM(0))); + RETURN(retval); } -template void WrapU_CCCU(){ - u32 retval = func(Memory::GetCharPointer(PARAM(0)),Memory::GetCharPointer(PARAM(1)), - Memory::GetCharPointer(PARAM(2)), PARAM(3)); - RETURN(retval); +template void WrapU_CCCU() { + u32 retval = func(Memory::GetCharPointer(PARAM(0)), + Memory::GetCharPointer(PARAM(1)), Memory::GetCharPointer(PARAM(2)), + PARAM(3)); + RETURN(retval); } template void WrapI_CU() { @@ -189,33 +189,34 @@ template void WrapI_CU() { } template 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 void WrapU_CU() { - u32 retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1)); - RETURN((u32)retval); + u32 retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1)); + RETURN((u32) retval); } template void WrapU_UC() { - u32 retval = func(PARAM(0), Memory::GetCharPointer(PARAM(1))); + u32 retval = func(PARAM(0), Memory::GetCharPointer(PARAM(1))); RETURN(retval); } template void WrapU_CUU() { - u32 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 void WrapU_III() { - u32 retval = func(PARAM(0), PARAM(1), PARAM(2)); - RETURN(retval); + u32 retval = func(PARAM(0), PARAM(1), PARAM(2)); + RETURN(retval); } template void WrapU_IUU() { - u32 retval = func(PARAM(0), PARAM(1), PARAM(2)); - RETURN(retval); + u32 retval = func(PARAM(0), PARAM(1), PARAM(2)); + RETURN(retval); } template void WrapU_UUU() { @@ -252,11 +253,13 @@ template void WrapV_CUIU() { } template 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 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 void WrapU_UUUU() { @@ -289,32 +292,35 @@ template void WrapV_UUUUU() { } template void WrapU_CC() { - int retval = func(Memory::GetCharPointer(PARAM(0)), Memory::GetCharPointer(PARAM(1))); - RETURN(retval); + int retval = func(Memory::GetCharPointer(PARAM(0)), + Memory::GetCharPointer(PARAM(1))); + RETURN(retval); } template void WrapV_CI() { - func(Memory::GetCharPointer(PARAM(0)), PARAM(1)); + func(Memory::GetCharPointer(PARAM(0)), PARAM(1)); } template void WrapU_CI() { - int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1)); - RETURN(retval); + int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1)); + RETURN(retval); } template 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 void WrapU_CIUIUI() { - u32 retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2), PARAM(3), PARAM(4), - PARAM(5)); - RETURN(retval); + u32 retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2), + PARAM(3), PARAM(4), PARAM(5)); + RETURN(retval); } template 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); } diff --git a/Core/HLE/sceGe.cpp b/Core/HLE/sceGe.cpp index d2c04260d2..793d09d19c 100644 --- a/Core/HLE/sceGe.cpp +++ b/Core/HLE/sceGe.cpp @@ -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(u32 mode) { - //mode => 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,16 +204,16 @@ u32 sceGeRestoreContext(u32 ctxAddr) void sceGeGetMtx() { - ERROR_LOG(HLE,"UNIMPL sceGeGetMtx()"); + ERROR_LOG(HLE, "UNIMPL sceGeGetMtx()"); } u32 sceGeEdramSetAddrTranslation(int new_size) { - 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[] = diff --git a/Core/HLE/sceIo.cpp b/Core/HLE/sceIo.cpp index 0bc69d5957..54b68ea56c 100644 --- a/Core/HLE/sceIo.cpp +++ b/Core/HLE/sceIo.cpp @@ -59,7 +59,7 @@ umd: - block access - umd irda?: - (?=0..9) block access - infra-red port (doesnt support seeking, maybe send/recieve data from port tho) mscm0: - block access - memstick cm?? umd00: block access - umd -umd01: block access - umd +umd01: block access - umd */ #define O_RDONLY 0x0001 @@ -87,13 +87,14 @@ const std::string &EmuDebugOutput() { #define SCE_STM_FLNK 0x4000 enum { - TYPE_DIR=0x10, - TYPE_FILE=0x20 + TYPE_DIR=0x10, + TYPE_FILE=0x20 }; -struct SceIoStat { +struct SceIoStat +{ SceMode st_mode; unsigned int st_attr; SceOff st_size; @@ -110,12 +111,13 @@ struct SceIoDirEnt u32 d_private; }; -struct dirent { - u32 unk0; - u32 type; - u32 size; - u32 unk[19]; - char name[0x108]; +struct dirent +{ + u32 unk0; + u32 type; + u32 size; + u32 unk[19]; + char name[0x108]; }; class FileNode : public KernelObject @@ -141,7 +143,7 @@ public: u32 callbackID; u32 callbackArg; - u32 asyncResult; + u32 asyncResult; bool pendingAsyncResult; bool sectorBlockMode; @@ -160,7 +162,7 @@ void __IoInit() char *winpos = strstr(path_buffer, "Windows"); if (winpos) - *winpos = 0; + *winpos = 0; strcat(path_buffer, "dummy.txt"); _splitpath_s(path_buffer, drive, dir, file, ext ); @@ -175,7 +177,7 @@ void __IoInit() DirectoryFileSystem *memstick; memstick = new DirectoryFileSystem(&pspFileSystem, mypath); - pspFileSystem.Mount("ms0:", memstick); + pspFileSystem.Mount("ms0:", memstick); pspFileSystem.Mount("fatms0:", memstick); pspFileSystem.Mount("fatms:", memstick); pspFileSystem.Mount("flash0:", new EmptyFileSystem()); @@ -187,33 +189,35 @@ void __IoShutdown() } -u32 sceIoAssign(const char *aliasname, const char *physname, const char *devname, u32 flag) +u32 sceIoAssign(const char *aliasname, const char *physname, + const char *devname, u32 flag) { - ERROR_LOG(HLE,"UNIMPL sceIoAssign(%s, %s, %s, %08x, ...)",aliasname,physname,devname,flag); - return 0; + ERROR_LOG(HLE, "UNIMPL sceIoAssign(%s, %s, %s, %08x, ...)", aliasname, + physname, devname, flag); + return 0; } u32 sceKernelStdin() { - DEBUG_LOG(HLE,"3=sceKernelStdin()"); - return 3; + DEBUG_LOG(HLE, "3=sceKernelStdin()"); + return 3; } u32 sceKernelStdout() { - DEBUG_LOG(HLE,"1=sceKernelStdout()"); - return 1; + DEBUG_LOG(HLE, "1=sceKernelStdout()"); + return 1; } u32 sceKernelStderr() { - DEBUG_LOG(HLE,"2=sceKernelStderr()"); - return 2; + DEBUG_LOG(HLE, "2=sceKernelStderr()"); + return 2; } void __IoCompleteAsyncIO(SceUID id) { u32 error; - FileNode *f = kernelObjects.Get(id, error); + FileNode *f = kernelObjects.Get < FileNode > (id, error); if (f) { if (f->callbackID) @@ -226,7 +230,7 @@ void __IoCompleteAsyncIO(SceUID id) void __IoGetStat(SceIoStat *stat, PSPFileInfo &info) { memset(stat, 0xfe, sizeof(SceIoStat)); - stat->st_size = (s64)info.size; + stat->st_size = (s64) info.size; int type, attr; if (info.type & FILETYPE_DIRECTORY) @@ -240,7 +244,6 @@ void __IoGetStat(SceIoStat *stat, PSPFileInfo &info) stat->st_private[0] = info.startSector; } - u32 sceIoGetstat(const char *filename, u32 addr) { SceIoStat stat; @@ -248,144 +251,167 @@ u32 sceIoGetstat(const char *filename, u32 addr) __IoGetStat(&stat, info); Memory::WriteStruct(addr, &stat); - DEBUG_LOG(HLE,"sceIoGetstat(%s, %08x) : sector = %08x",filename,addr,info.startSector); + DEBUG_LOG(HLE, "sceIoGetstat(%s, %08x) : sector = %08x", filename, addr, + info.startSector); - return 0; + return 0; } //Not sure about wrapping it or not, since the log seems to take the address of the data var -u32 sceIoRead(int id, u32 data_addr, int size) //(int fd, void *data, int size); +u32 sceIoRead(int id, u32 data_addr, int size) //(int fd, void *data, int size); { if (id == 3) { - DEBUG_LOG(HLE,"sceIoRead STDIN"); - return 0; //stdin + DEBUG_LOG(HLE, "sceIoRead STDIN"); + return 0; //stdin } u32 error; - FileNode *f = kernelObjects.Get(id, error); + FileNode *f = kernelObjects.Get < FileNode > (id, error); if (f) { - if (data_addr) + if (data_addr) { - u8 *data = (u8*)Memory::GetPointer(data_addr); - f->asyncResult = (u32)pspFileSystem.ReadFile(f->handle, data, size); - DEBUG_LOG(HLE,"%i=sceIoRead(%d, %08x , %i)",f->asyncResult, id, data_addr, size); - return f->asyncResult; + u8 *data = (u8*) Memory::GetPointer(data_addr); + f->asyncResult = (u32) pspFileSystem.ReadFile(f->handle, data, + size); + DEBUG_LOG(HLE, "%i=sceIoRead(%d, %08x , %i)", f->asyncResult, id, + data_addr, size); + return f->asyncResult; } else { - ERROR_LOG(HLE,"sceIoRead Reading into zero pointer"); - return -1; + ERROR_LOG(HLE, "sceIoRead Reading into zero pointer"); + return -1; } } else { - ERROR_LOG(HLE,"sceIoRead ERROR: no file open"); - return error; + ERROR_LOG(HLE, "sceIoRead ERROR: no file open"); + return error; } } -u32 sceIoWrite(int id, void *data_ptr, int size) //(int fd, void *data, int size); +u32 sceIoWrite(int id, void *data_ptr, int size) //(int fd, void *data, int size); { - if (id == 2) + if (id == 2) { - //stderr! - const char *str = (const char*)data_ptr; - DEBUG_LOG(HLE,"stderr: %s", str); - return size; + //stderr! + const char *str = (const char*) data_ptr; + DEBUG_LOG(HLE, "stderr: %s", str); + return size; } - if (id == 1) + if (id == 1) { //stdout! - char *str = (char *)data_ptr; + char *str = (char *) data_ptr; char temp = str[size]; - str[size]=0; - DEBUG_LOG(HLE,"stdout: %s", str); - str[size]=temp; - return size; + str[size] = 0; + DEBUG_LOG(HLE, "stdout: %s", str); + str[size] = temp; + return size; } u32 error; - FileNode *f = kernelObjects.Get(id, error); + FileNode *f = kernelObjects.Get < FileNode > (id, error); if (f) { - u8 *data = (u8*)data_ptr; - f->asyncResult = (u32)pspFileSystem.WriteFile(f->handle,data,size); - return f->asyncResult; + u8 *data = (u8*) data_ptr; + f->asyncResult = (u32) pspFileSystem.WriteFile(f->handle, data, size); + return f->asyncResult; } else { - ERROR_LOG(HLE,"sceIoWrite ERROR: no file open"); - return error; + ERROR_LOG(HLE, "sceIoWrite ERROR: no file open"); + return error; } } u32 sceIoLseek(int id, s64 offset, int whence) //(int fd, int64 offset, int whence); { u32 error; - FileNode *f = kernelObjects.Get(id, error); + FileNode *f = kernelObjects.Get < FileNode > (id, error); if (f) { FileMove seek = FILEMOVE_BEGIN; switch (whence) { - case 0: break; - case 1: seek=FILEMOVE_CURRENT;break; - case 2: seek=FILEMOVE_END;break; + case 0: + break; + case 1: + seek = FILEMOVE_CURRENT; + break; + case 2: + seek = FILEMOVE_END; + break; } - f->asyncResult = (u32)pspFileSystem.SeekFile(f->handle, (s32)offset, seek); - DEBUG_LOG(HLE,"%i = sceIoLseek(%d,%i,%i)",f->asyncResult, id,(int)offset,whence); - return f->asyncResult; - } + f->asyncResult = (u32) pspFileSystem.SeekFile(f->handle, (s32) offset, + seek); + DEBUG_LOG(HLE, "%i = sceIoLseek(%d,%i,%i)", f->asyncResult, id, + (int) offset, whence); + return f->asyncResult; + } else { - ERROR_LOG(HLE,"sceIoLseek(%d, %i, %i) - ERROR: invalid file", id, (int)offset, whence); - return error; + ERROR_LOG(HLE, "sceIoLseek(%d, %i, %i) - ERROR: invalid file", id, + (int) offset, whence); + return error; } } u32 sceIoLseek32(int id, int offset, int whence) //(int fd, int offset, int whence); { u32 error; - FileNode *f = kernelObjects.Get(id, error); + FileNode *f = kernelObjects.Get < FileNode > (id, error); if (f) { - DEBUG_LOG(HLE,"sceIoLseek32(%d,%08x,%i)",id,(int)offset,whence); + DEBUG_LOG(HLE, "sceIoLseek32(%d,%08x,%i)", id, (int) offset, whence); - FileMove seek=FILEMOVE_BEGIN; + FileMove seek = FILEMOVE_BEGIN; switch (whence) { - case 0: break; - case 1: seek=FILEMOVE_CURRENT;break; - case 2: seek=FILEMOVE_END;break; + case 0: + break; + case 1: + seek = FILEMOVE_CURRENT; + break; + case 2: + seek = FILEMOVE_END; + break; } - f->asyncResult = (u32)pspFileSystem.SeekFile(f->handle, (s32)offset, seek); - return f->asyncResult; + f->asyncResult = (u32) pspFileSystem.SeekFile(f->handle, (s32) offset, + seek); + return f->asyncResult; } else { - ERROR_LOG(HLE,"sceIoLseek32 ERROR: no file open"); - return error; + ERROR_LOG(HLE, "sceIoLseek32 ERROR: no file open"); + return error; } } -u32 sceIoOpen(const char* filename, int mode) //(const char* file, int mode); +u32 sceIoOpen(const char* filename, int mode) //(const char* file, int mode); { //memory stick filename - int access=FILEACCESS_NONE; - if (mode & O_RDONLY) access |= FILEACCESS_READ; - if (mode & O_WRONLY) access |= FILEACCESS_WRITE; - if (mode & O_APPEND) access |= FILEACCESS_APPEND; - if (mode & O_CREAT) access |= FILEACCESS_CREATE; + int access = FILEACCESS_NONE; + if (mode & O_RDONLY) + access |= FILEACCESS_READ; + if (mode & O_WRONLY) + access |= FILEACCESS_WRITE; + if (mode & O_APPEND) + access |= FILEACCESS_APPEND; + if (mode & O_CREAT) + access |= FILEACCESS_CREATE; - u32 h = pspFileSystem.OpenFile(filename, (FileAccess)access); + u32 h = pspFileSystem.OpenFile(filename, (FileAccess) access); if (h == 0) { - ERROR_LOG(HLE,"ERROR_ERRNO_FILE_NOT_FOUND=sceIoOpen(%s, %08x) - file not found", filename, mode); - return ERROR_ERRNO_FILE_NOT_FOUND; + ERROR_LOG(HLE, + "ERROR_ERRNO_FILE_NOT_FOUND=sceIoOpen(%s, %08x) - file not found", + filename, mode); + return ERROR_ERRNO_FILE_NOT_FOUND; } FileNode *f = new FileNode(); @@ -393,46 +419,46 @@ u32 sceIoOpen(const char* filename, int mode) //(const char* file, int mode); f->handle = h; f->fullpath = filename; f->asyncResult = id; - DEBUG_LOG(HLE,"%i=sceIoOpen(%s, %08x)",id,filename,mode); - return id; + DEBUG_LOG(HLE, "%i=sceIoOpen(%s, %08x)", id, filename, mode); + return id; } -u32 sceIoClose(int id) //(int fd); +u32 sceIoClose(int id) //(int fd); { - DEBUG_LOG(HLE,"sceIoClose(%d)",id); - return kernelObjects.Destroy(id); + DEBUG_LOG(HLE, "sceIoClose(%d)", id); + return kernelObjects.Destroy < FileNode > (id); } u32 sceIoRemove(const char *filename) //(const char *file); { - DEBUG_LOG(HLE,"sceIoRemove(%s)", filename); + DEBUG_LOG(HLE, "sceIoRemove(%s)", filename); if (pspFileSystem.DeleteFile(filename)) - return 0; + return 0; else - return -1; + return -1; } -u32 sceIoMkdir(const char *dirname, int mode) //(const char *dir, int mode); +u32 sceIoMkdir(const char *dirname, int mode) //(const char *dir, int mode); { - DEBUG_LOG(HLE,"sceIoMkdir(%s, %i)", dirname, mode); - if (pspFileSystem.MkDir(dirname)) - return 0; + DEBUG_LOG(HLE, "sceIoMkdir(%s, %i)", dirname, mode); + if (pspFileSystem.MkDir(dirname)) + return 0; else - return -1; + return -1; } u32 sceIoRmdir(const char *dirname) { - DEBUG_LOG(HLE,"sceIoRmdir(%s)", dirname); - if (pspFileSystem.RmDir(dirname)) - return 0; + DEBUG_LOG(HLE, "sceIoRmdir(%s)", dirname); + if (pspFileSystem.RmDir(dirname)) + return 0; else - return -1; + return -1; } void sceIoSync() { - DEBUG_LOG(HLE,"UNIMPL sceIoSync not implemented"); + DEBUG_LOG(HLE, "UNIMPL sceIoSync not implemented"); } struct DeviceSize @@ -441,234 +467,234 @@ struct DeviceSize u32 sectorSize; u32 sectorsPerCluster; u32 totalClusters; - u32 freeClusters; + u32 freeClusters; }; u32 sceIoDevctl(const char *name, int cmd, u32 argAddr, int argLen, u32 outPtr, int outLen) //(const char *name, int cmd, void *arg, size_t arglen, void *buf, size_t *buflen); { - if (strcmp(name, "emulator:")) { - DEBUG_LOG(HLE,"sceIoDevctl(\"%s\", %08x, %08x, %i, %08x, %i)", name, cmd,argAddr,argLen,outPtr,outLen); - } + if (strcmp(name, "emulator:")) { + DEBUG_LOG(HLE,"sceIoDevctl(\"%s\", %08x, %08x, %i, %08x, %i)", name, cmd,argAddr,argLen,outPtr,outLen); + } - // UMD checks - switch (cmd) { - case 0x01F20001: // Get Disc Type. - if (Memory::IsValidAddress(outPtr)) { - Memory::Write_U32(0x10, outPtr); // Game disc + // UMD checks + switch (cmd) { + case 0x01F20001: // Get Disc Type. + if (Memory::IsValidAddress(outPtr)) { + Memory::Write_U32(0x10, outPtr); // Game disc return 0; - } else { + } else { return -1; - } - break; - case 0x01F20002: // Get current LBA. - if (Memory::IsValidAddress(outPtr)) { - Memory::Write_U32(0, outPtr); // Game disc + } + break; + case 0x01F20002: // Get current LBA. + if (Memory::IsValidAddress(outPtr)) { + Memory::Write_U32(0, outPtr); // Game disc return 0; - } else { + } else { return -1; - } - break; - case 0x01F100A3: // Seek + } + break; + case 0x01F100A3: // Seek return 0; - } - - // This should really send it on to a FileSystem implementation instead. + } - if (!strcmp(name, "mscmhc0:") || !strcmp(name, "ms0:")) - { - switch (cmd) - { - // does one of these set a callback as well? (see coded arms) - case 0x02015804: // Register callback - if (Memory::IsValidAddress(argAddr) && argLen == 4) { - u32 cbId = Memory::Read_U32(argAddr); - if (0 == __KernelRegisterCallback(THREAD_CALLBACK_MEMORYSTICK, cbId)) { - DEBUG_LOG(HLE, "sceIoDevCtl: Memstick callback %i registered, notifying immediately.", cbId); - __KernelNotifyCallbackType(THREAD_CALLBACK_MEMORYSTICK, cbId, MemoryStick_State()); + // This should really send it on to a FileSystem implementation instead. + + if (!strcmp(name, "mscmhc0:") || !strcmp(name, "ms0:")) + { + switch (cmd) + { + // does one of these set a callback as well? (see coded arms) + case 0x02015804: // Register callback + if (Memory::IsValidAddress(argAddr) && argLen == 4) { + u32 cbId = Memory::Read_U32(argAddr); + if (0 == __KernelRegisterCallback(THREAD_CALLBACK_MEMORYSTICK, cbId)) { + DEBUG_LOG(HLE, "sceIoDevCtl: Memstick callback %i registered, notifying immediately.", cbId); + __KernelNotifyCallbackType(THREAD_CALLBACK_MEMORYSTICK, cbId, MemoryStick_State()); return 0; - } else { + } else { return ERROR_MEMSTICK_DEVCTL_BAD_PARAMS; - } - } - break; + } + } + break; - case 0x02025805: // Unregister callback - if (Memory::IsValidAddress(argAddr) && argLen == 4) { - u32 cbId = Memory::Read_U32(argAddr); - if (0 == __KernelUnregisterCallback(THREAD_CALLBACK_MEMORYSTICK, cbId)) { - DEBUG_LOG(HLE, "sceIoDevCtl: Unregistered memstick callback %i", cbId); + case 0x02025805: // Unregister callback + if (Memory::IsValidAddress(argAddr) && argLen == 4) { + u32 cbId = Memory::Read_U32(argAddr); + if (0 == __KernelUnregisterCallback(THREAD_CALLBACK_MEMORYSTICK, cbId)) { + DEBUG_LOG(HLE, "sceIoDevCtl: Unregistered memstick callback %i", cbId); return 0; - } else { + } else { return ERROR_MEMSTICK_DEVCTL_BAD_PARAMS; - } - } - break; + } + } + break; - case 0x02025806: // Memory stick inserted? - case 0x02025801: // Memstick Driver status? - if (Memory::IsValidAddress(outPtr)) { - Memory::Write_U32(1, outPtr); + case 0x02025806: // Memory stick inserted? + case 0x02025801: // Memstick Driver status? + if (Memory::IsValidAddress(outPtr)) { + Memory::Write_U32(1, outPtr); return 0; - } else { + } else { return ERROR_MEMSTICK_DEVCTL_BAD_PARAMS; - } + } - case 0x02425818: // Get memstick size etc - // Pretend we have a 2GB memory stick. - if (Memory::IsValidAddress(argAddr)) { // "Should" be outPtr but isn't - u32 pointer = Memory::Read_U32(argAddr); + case 0x02425818: // Get memstick size etc + // Pretend we have a 2GB memory stick. + if (Memory::IsValidAddress(argAddr)) { // "Should" be outPtr but isn't + u32 pointer = Memory::Read_U32(argAddr); - u64 totalSize = (u32)2 * 1024 * 1024 * 1024; - u64 freeSize = 1 * 1024 * 1024 * 1024; - DeviceSize deviceSize; - deviceSize.maxSectors = 512; - deviceSize.sectorSize = 0x200; - deviceSize.sectorsPerCluster = 0x08; - deviceSize.totalClusters = (u32)((totalSize * 95 / 100) / (deviceSize.sectorSize * deviceSize.sectorsPerCluster)); - deviceSize.freeClusters = (u32)((freeSize * 95 / 100) / (deviceSize.sectorSize * deviceSize.sectorsPerCluster)); - Memory::WriteStruct(pointer, &deviceSize); + u64 totalSize = (u32)2 * 1024 * 1024 * 1024; + u64 freeSize = 1 * 1024 * 1024 * 1024; + DeviceSize deviceSize; + deviceSize.maxSectors = 512; + deviceSize.sectorSize = 0x200; + deviceSize.sectorsPerCluster = 0x08; + deviceSize.totalClusters = (u32)((totalSize * 95 / 100) / (deviceSize.sectorSize * deviceSize.sectorsPerCluster)); + deviceSize.freeClusters = (u32)((freeSize * 95 / 100) / (deviceSize.sectorSize * deviceSize.sectorsPerCluster)); + Memory::WriteStruct(pointer, &deviceSize); return 0; - } else { + } else { return ERROR_MEMSTICK_DEVCTL_BAD_PARAMS; - } - } - } + } + } + } - if (!strcmp(name, "fatms0:")) - { - switch (cmd) { - case 0x02415821: // MScmRegisterMSInsertEjectCallback - { - u32 cbId = Memory::Read_U32(argAddr); - if (0 == __KernelRegisterCallback(THREAD_CALLBACK_MEMORYSTICK_FAT, cbId)) { - DEBUG_LOG(HLE, "sceIoDevCtl: Memstick FAT callback %i registered, notifying immediately.", cbId); - __KernelNotifyCallbackType(THREAD_CALLBACK_MEMORYSTICK_FAT, cbId, MemoryStick_FatState()); + if (!strcmp(name, "fatms0:")) + { + switch (cmd) { + case 0x02415821: // MScmRegisterMSInsertEjectCallback + { + u32 cbId = Memory::Read_U32(argAddr); + if (0 == __KernelRegisterCallback(THREAD_CALLBACK_MEMORYSTICK_FAT, cbId)) { + DEBUG_LOG(HLE, "sceIoDevCtl: Memstick FAT callback %i registered, notifying immediately.", cbId); + __KernelNotifyCallbackType(THREAD_CALLBACK_MEMORYSTICK_FAT, cbId, MemoryStick_FatState()); return 0; - } else { + } else { return -1; - } - } - break; - case 0x02415822: // MScmUnregisterMSInsertEjectCallback - { - u32 cbId = Memory::Read_U32(argAddr); - if (0 == __KernelUnregisterCallback(THREAD_CALLBACK_MEMORYSTICK_FAT, cbId)) { - DEBUG_LOG(HLE, "sceIoDevCtl: Unregistered memstick FAT callback %i", cbId); + } + } + break; + case 0x02415822: // MScmUnregisterMSInsertEjectCallback + { + u32 cbId = Memory::Read_U32(argAddr); + if (0 == __KernelUnregisterCallback(THREAD_CALLBACK_MEMORYSTICK_FAT, cbId)) { + DEBUG_LOG(HLE, "sceIoDevCtl: Unregistered memstick FAT callback %i", cbId); return 0; - } else { + } else { return -1; - } - } + } + } - case 0x02415823: // Set FAT as enabled - if (Memory::IsValidAddress(argAddr) && argLen == 4) { - MemoryStick_SetFatState((MemStickFatState)Memory::Read_U32(argAddr)); + case 0x02415823: // Set FAT as enabled + if (Memory::IsValidAddress(argAddr) && argLen == 4) { + MemoryStick_SetFatState((MemStickFatState)Memory::Read_U32(argAddr)); return 0; - } else { - ERROR_LOG(HLE, "Failed 0x02415823 fat"); + } else { + ERROR_LOG(HLE, "Failed 0x02415823 fat"); return -1; - } - break; + } + break; - case 0x02425823: // Check if FAT enabled - if (Memory::IsValidAddress(outPtr) && outLen == 4) { - Memory::Write_U32(MemoryStick_FatState(), outPtr); + case 0x02425823: // Check if FAT enabled + if (Memory::IsValidAddress(outPtr) && outLen == 4) { + Memory::Write_U32(MemoryStick_FatState(), outPtr); return 0; - } else { - ERROR_LOG(HLE, "Failed 0x02425823 fat"); + } else { + ERROR_LOG(HLE, "Failed 0x02425823 fat"); return -1; - } - break; + } + break; - case 0x02425818: // Get memstick size etc - // Pretend we have a 2GB memory stick. - { - if (Memory::IsValidAddress(argAddr)) { // "Should" be outPtr but isn't - u32 pointer = Memory::Read_U32(argAddr); + case 0x02425818: // Get memstick size etc + // Pretend we have a 2GB memory stick. + { + if (Memory::IsValidAddress(argAddr)) { // "Should" be outPtr but isn't + u32 pointer = Memory::Read_U32(argAddr); - u64 totalSize = (u32)2 * 1024 * 1024 * 1024; - u64 freeSize = 1 * 1024 * 1024 * 1024; - DeviceSize deviceSize; - deviceSize.maxSectors = 512; - deviceSize.sectorSize = 0x200; - deviceSize.sectorsPerCluster = 0x08; - deviceSize.totalClusters = (u32)((totalSize * 95 / 100) / (deviceSize.sectorSize * deviceSize.sectorsPerCluster)); - deviceSize.freeClusters = (u32)((freeSize * 95 / 100) / (deviceSize.sectorSize * deviceSize.sectorsPerCluster)); - Memory::WriteStruct(pointer, &deviceSize); + u64 totalSize = (u32)2 * 1024 * 1024 * 1024; + u64 freeSize = 1 * 1024 * 1024 * 1024; + DeviceSize deviceSize; + deviceSize.maxSectors = 512; + deviceSize.sectorSize = 0x200; + deviceSize.sectorsPerCluster = 0x08; + deviceSize.totalClusters = (u32)((totalSize * 95 / 100) / (deviceSize.sectorSize * deviceSize.sectorsPerCluster)); + deviceSize.freeClusters = (u32)((freeSize * 95 / 100) / (deviceSize.sectorSize * deviceSize.sectorsPerCluster)); + Memory::WriteStruct(pointer, &deviceSize); return 0; - } else { + } else { return ERROR_MEMSTICK_DEVCTL_BAD_PARAMS; - } - } - } - } + } + } + } + } - if (!strcmp(name, "kemulator:") || !strcmp(name, "emulator:")) - { - // Emulator special tricks! - switch (cmd) - { - case 1: // EMULATOR_DEVCTL__GET_HAS_DISPLAY - if (Memory::IsValidAddress(outPtr)) - Memory::Write_U32(0, outPtr); // TODO: Make a headless mode for running tests! + if (!strcmp(name, "kemulator:") || !strcmp(name, "emulator:")) + { + // Emulator special tricks! + switch (cmd) + { + case 1: // EMULATOR_DEVCTL__GET_HAS_DISPLAY + if (Memory::IsValidAddress(outPtr)) + Memory::Write_U32(0, outPtr); // TODO: Make a headless mode for running tests! return 0; - case 2: // EMULATOR_DEVCTL__SEND_OUTPUT - { - std::string data(Memory::GetCharPointer(argAddr), argLen); - if (PSP_CoreParameter().printfEmuLog) - { - printf("%s", data.c_str()); + case 2: // EMULATOR_DEVCTL__SEND_OUTPUT + { + std::string data(Memory::GetCharPointer(argAddr), argLen); + if (PSP_CoreParameter().printfEmuLog) + { + printf("%s", data.c_str()); #ifdef _WIN32 - OutputDebugString(data.c_str()); + OutputDebugString(data.c_str()); #endif - // Also collect the debug output - emuDebugOutput += data; - } - else - { - DEBUG_LOG(HLE, "%s", data.c_str()); - } + // Also collect the debug output + emuDebugOutput += data; + } + else + { + DEBUG_LOG(HLE, "%s", data.c_str()); + } return 0; - } - case 3: // EMULATOR_DEVCTL__IS_EMULATOR - if (Memory::IsValidAddress(outPtr)) - Memory::Write_U32(1, outPtr); // TODO: Make a headless mode for running tests! + } + case 3: // EMULATOR_DEVCTL__IS_EMULATOR + if (Memory::IsValidAddress(outPtr)) + Memory::Write_U32(1, outPtr); // TODO: Make a headless mode for running tests! return 0; - } + } + + ERROR_LOG(HLE, "sceIoDevCtl: UNKNOWN PARAMETERS"); - ERROR_LOG(HLE, "sceIoDevCtl: UNKNOWN PARAMETERS"); - return 0; - } + } - //089c6d1c weird branch - /* - 089c6bdc ]: HLE: sceKernelCreateCallback(name= MemoryStick Detection ,entry= 089c7484 ) (z_un_089c6bc4) - 089c6c18 ]: HLE: sceIoDevctl("mscmhc0:", 02015804, 09ffb9c0, 4, 00000000, 0) (z_un_089c6bc4) - 089c6c40 ]: HLE: sceKernelCreateCallback(name= MemoryStick Assignment ,entry= 089c7534 ) (z_un_089c6bc4) - 089c6c78 ]: HLE: sceIoDevctl("fatms0:", 02415821, 09ffb9c4, 4, 00000000, 0) (z_un_089c6bc4) - 089c6cac ]: HLE: sceIoDevctl("mscmhc0:", 02025806, 00000000, 0, 09ffb9c8, 4) (z_un_089c6bc4) - */ + //089c6d1c weird branch + /* + 089c6bdc ]: HLE: sceKernelCreateCallback(name= MemoryStick Detection ,entry= 089c7484 ) (z_un_089c6bc4) + 089c6c18 ]: HLE: sceIoDevctl("mscmhc0:", 02015804, 09ffb9c0, 4, 00000000, 0) (z_un_089c6bc4) + 089c6c40 ]: HLE: sceKernelCreateCallback(name= MemoryStick Assignment ,entry= 089c7534 ) (z_un_089c6bc4) + 089c6c78 ]: HLE: sceIoDevctl("fatms0:", 02415821, 09ffb9c4, 4, 00000000, 0) (z_un_089c6bc4) + 089c6cac ]: HLE: sceIoDevctl("mscmhc0:", 02025806, 00000000, 0, 09ffb9c8, 4) (z_un_089c6bc4) + */ return SCE_KERNEL_ERROR_UNSUP; } u32 sceIoRename(const char *from, const char *to) //(const char *oldname, const char *newname); { - DEBUG_LOG(HLE,"sceIoRename(%s, %s)", from, to); + DEBUG_LOG(HLE, "sceIoRename(%s, %s)", from, to); if (pspFileSystem.RenameFile(from, to)) - return 0; + return 0; else - return -1; + return -1; } u32 sceIoChdir(const char *dirname) { - pspFileSystem.ChDir(dirname); - DEBUG_LOG(HLE,"sceIoChdir(%s)",dirname); - return 1; + pspFileSystem.ChDir(dirname); + DEBUG_LOG(HLE, "sceIoChdir(%s)", dirname); + return 1; } typedef u32 (*DeferredAction)(SceUID id, int param); @@ -677,98 +703,99 @@ u32 defParam; void sceIoChangeAsyncPriority() { - ERROR_LOG(HLE,"UNIMPL sceIoChangeAsyncPriority(%d)", PARAM(0)); + ERROR_LOG(HLE, "UNIMPL sceIoChangeAsyncPriority(%d)", PARAM(0)); RETURN(0); } u32 __IoClose(SceUID id, int param) { - DEBUG_LOG(HLE,"Deferred IoClose(%d)",id); + DEBUG_LOG(HLE, "Deferred IoClose(%d)", id); __IoCompleteAsyncIO(id); - return kernelObjects.Destroy(id); + return kernelObjects.Destroy < FileNode > (id); } //TODO Not really sure if this should be wrapped nor how void sceIoCloseAsync() { - DEBUG_LOG(HLE,"sceIoCloseAsync(%d)",PARAM(0)); - //sceIoClose(); + DEBUG_LOG(HLE, "sceIoCloseAsync(%d)", PARAM(0)); + //sceIoClose(); defAction = &__IoClose; - RETURN(0); + RETURN(0); } u32 sceIoLseekAsync(int id, s64 offset, int whence) { - sceIoLseek(id,offset,whence); - __IoCompleteAsyncIO(id); - return 0; + sceIoLseek(id, offset, whence); + __IoCompleteAsyncIO(id); + return 0; } u32 sceIoSetAsyncCallback(int id, u32 clbckId, u32 clbckArg) { - DEBUG_LOG(HLE,"sceIoSetAsyncCallback(%d, %i, %08x)", id, clbckId, clbckArg); + DEBUG_LOG(HLE, "sceIoSetAsyncCallback(%d, %i, %08x)", id, clbckId, + clbckArg); - u32 error; - FileNode *f = kernelObjects.Get(id, error); + u32 error; + FileNode *f = kernelObjects.Get < FileNode > (id, error); if (f) { - f->callbackID = clbckId; - f->callbackArg = clbckArg; - return 0; + f->callbackID = clbckId; + f->callbackArg = clbckArg; + return 0; } else { - return error; + return error; } } u32 sceIoLseek32Async(int id, int offset, int whence) { - DEBUG_LOG(HLE,"sceIoLseek32Async(%d) sorta implemented", id); - sceIoLseek32(id, offset, whence); - __IoCompleteAsyncIO(id); - return 0; + DEBUG_LOG(HLE, "sceIoLseek32Async(%d) sorta implemented", id); + sceIoLseek32(id, offset, whence); + __IoCompleteAsyncIO(id); + return 0; } void sceIoOpenAsync(const char *filename, int mode) { - DEBUG_LOG(HLE,"sceIoOpenAsync() sorta implemented"); - sceIoOpen(filename, mode); + DEBUG_LOG(HLE, "sceIoOpenAsync() sorta implemented"); + sceIoOpen(filename, mode); // __IoCompleteAsyncIO(currentMIPS->r[2]); // The return value // We have to return a UID here, which may have been destroyed when we reach Wait if it failed. // Now that we're just faking it, we just don't RETURN(0) here. -} +} u32 sceIoReadAsync(int id, u32 data_addr, int size) { - DEBUG_LOG(HLE,"sceIoReadAsync(%d)",id); - sceIoRead(id, data_addr,size); - __IoCompleteAsyncIO(id); - return 0; + DEBUG_LOG(HLE, "sceIoReadAsync(%d)", id); + sceIoRead(id, data_addr, size); + __IoCompleteAsyncIO(id); + return 0; } u32 sceIoGetAsyncStat(int id, u32 address, u32 uknwn) { u32 error; - FileNode *f = kernelObjects.Get(id, error); + FileNode *f = kernelObjects.Get < FileNode > (id, error); if (f) { - Memory::Write_U64(f->asyncResult, address); - DEBUG_LOG(HLE,"%i = sceIoGetAsyncStat(%i, %i, %08x) (HACK)", (u32)f->asyncResult, id, address, uknwn); - return 0; //completed + Memory::Write_U64(f->asyncResult, address); + DEBUG_LOG(HLE, "%i = sceIoGetAsyncStat(%i, %i, %08x) (HACK)", + (u32) f->asyncResult, id, address, uknwn); + return 0; //completed } else { - ERROR_LOG(HLE,"ERROR - sceIoGetAsyncStat with invalid id %i", id); - return -1; + ERROR_LOG(HLE, "ERROR - sceIoGetAsyncStat with invalid id %i", id); + return -1; } } - -u32 sceIoWaitAsync(int id, u32 address, u32 uknwn) +void sceIoWaitAsync(int id, u32 address, u32 uknwn) { u32 error; - FileNode *f = kernelObjects.Get(id, error); + FileNode *f = kernelObjects.Get < FileNode > (id, error); if (f) { u64 res = f->asyncResult; @@ -777,23 +804,24 @@ u32 sceIoWaitAsync(int id, u32 address, u32 uknwn) res = defAction(id, defParam); defAction = 0; } - Memory::Write_U64(res, address); - DEBUG_LOG(HLE,"%i = sceIoWaitAsync(%i, %08x) (HACK)", (u32)res, id, uknwn); - return 0; //completed + Memory::Write_U64(res, address); + DEBUG_LOG(HLE, "%i = sceIoWaitAsync(%i, %08x) (HACK)", (u32) res, id, + uknwn); + RETURN(0); //completed } else { - ERROR_LOG(HLE,"ERROR - sceIoWaitAsync waiting for invalid id %i", id); - return -1; + ERROR_LOG(HLE, "ERROR - sceIoWaitAsync waiting for invalid id %i", id); + RETURN(-1); } } -u32 sceIoWaitAsyncCB(int id, u32 address) +void sceIoWaitAsyncCB(int id, u32 address) { // Should process callbacks here u32 error; - FileNode *f = kernelObjects.Get(id, error); + FileNode *f = kernelObjects.Get < FileNode > (id, error); if (f) { u64 res = f->asyncResult; @@ -802,20 +830,22 @@ u32 sceIoWaitAsyncCB(int id, u32 address) res = defAction(id, defParam); defAction = 0; } - Memory::Write_U64(res, address); - DEBUG_LOG(HLE,"%i = sceIoWaitAsyncCB(%i, %08x) (HACK)", (u32)res, id, address); - return 0; //completed + Memory::Write_U64(res, address); + DEBUG_LOG(HLE, "%i = sceIoWaitAsyncCB(%i, %08x) (HACK)", (u32) res, id, + address); + RETURN(0); //completed } else { - ERROR_LOG(HLE,"ERROR - sceIoWaitAsyncCB waiting for invalid id %i", id); + ERROR_LOG(HLE, "ERROR - sceIoWaitAsyncCB waiting for invalid id %i", + id); } } u32 sceIoPollAsync(int id, u32 address) { u32 error; - FileNode *f = kernelObjects.Get(id, error); + FileNode *f = kernelObjects.Get < FileNode > (id, error); if (f) { u64 res = f->asyncResult; @@ -824,13 +854,14 @@ u32 sceIoPollAsync(int id, u32 address) res = defAction(id, defParam); defAction = 0; } - Memory::Write_U64(res, address); - DEBUG_LOG(HLE,"%i = sceIoPollAsync(%i, %08x) (HACK)", (u32)res, id, address); - return 0; //completed + Memory::Write_U64(res, address); + DEBUG_LOG(HLE, "%i = sceIoPollAsync(%i, %08x) (HACK)", (u32) res, id, + address); + return 0; //completed } else { - ERROR_LOG(HLE,"ERROR - sceIoPollAsync waiting for invalid id %i", id); + ERROR_LOG(HLE, "ERROR - sceIoPollAsync waiting for invalid id %i", id); } } @@ -847,9 +878,9 @@ public: int index; }; -u32 sceIoDopen(const char *path ) //(const char *path); +u32 sceIoDopen(const char *path) //(const char *path); { - DEBUG_LOG(HLE,"sceIoDopen(\"%s\")",path); + DEBUG_LOG(HLE, "sceIoDopen(\"%s\")", path); DirListing *dir = new DirListing(); SceUID id = kernelObjects.Create(dir); @@ -860,85 +891,88 @@ u32 sceIoDopen(const char *path ) //(const char *path); dir->index = 0; dir->name = std::string(path); - return id; + return id; } u32 sceIoDread(int id, u32 dirent_addr) { u32 error; - DirListing *dir = kernelObjects.Get(id, error); + DirListing *dir = kernelObjects.Get < DirListing > (id, error); if (dir) { - if (dir->index == (int)dir->listing.size()) + if (dir->index == (int) dir->listing.size()) { - DEBUG_LOG(HLE,"sceIoDread( %d %08x ) - end of the line", id, dirent_addr); - return 0; + DEBUG_LOG(HLE, "sceIoDread( %d %08x ) - end of the line", id, + dirent_addr); + return 0; } PSPFileInfo &info = dir->listing[dir->index]; - SceIoDirEnt *entry = (SceIoDirEnt*)Memory::GetPointer(dirent_addr); + SceIoDirEnt *entry = (SceIoDirEnt*) Memory::GetPointer(dirent_addr); __IoGetStat(&entry->d_stat, info); strncpy(entry->d_name, info.name.c_str(), 256); entry->d_private = 0xC0DEBABE; - DEBUG_LOG(HLE,"sceIoDread( %d %08x ) = %s", id, dirent_addr, entry->d_name); + DEBUG_LOG(HLE, "sceIoDread( %d %08x ) = %s", id, dirent_addr, + entry->d_name); dir->index++; - return (u32)(dir->listing.size()-dir->index+1); + return (u32)(dir->listing.size() - dir->index + 1); } else { - DEBUG_LOG(HLE,"sceIoDread - invalid listing %i, error %08x", id, error); + DEBUG_LOG(HLE, "sceIoDread - invalid listing %i, error %08x", id, + error); } } u32 sceIoDclose(int id) { - DEBUG_LOG(HLE,"sceIoDclose(%d)",id); - return kernelObjects.Destroy(id); + DEBUG_LOG(HLE, "sceIoDclose(%d)", id); + return kernelObjects.Destroy < DirListing > (id); } const HLEFunction IoFileMgrForUser[] = { - {0xb29ddf9c,&WrapU_C, "sceIoDopen"}, - {0xe3eb004c,&WrapU_IU, "sceIoDread"}, - {0xeb092469,&WrapU_I,"sceIoDclose"}, - {0xe95a012b,0,"sceIoIoctlAsync"}, - {0x63632449,0,"sceIoIoctl"}, - {0xace946e8,&WrapU_CU,"sceIoGetstat"}, - {0xb8a740f4,0,"sceIoChstat"}, - {0x55f4717d,&WrapU_C,"sceIoChdir"}, - {0x08bd7374,0,"sceIoGetDevType"}, - {0xB2A628C1,&WrapU_CCCU,"sceIoAssign"}, - {0xe8bc6571,0,"sceIoCancel"}, - {0xb293727f,sceIoChangeAsyncPriority,"sceIoChangeAsyncPriority"}, - {0x810C4BC3,&WrapU_I, "sceIoClose"}, //(int fd); - {0xff5940b6,sceIoCloseAsync,"sceIoCloseAsync"}, - {0x54F5FB11,&WrapU_CIUIUI,"sceIoDevctl"}, //(const char *name int cmd, void *arg, size_t arglen, void *buf, size_t *buflen); - {0xcb05f8d6,&WrapU_IUU,"sceIoGetAsyncStat"}, - {0x27EB27B8,&WrapU_II64I, "sceIoLseek"}, //(int fd, int offset, int whence); - {0x68963324,&WrapU_III,"sceIoLseek32"}, - {0x1b385d8f,&WrapU_III,"sceIoLseek32Async"}, - {0x71b19e77,&WrapU_II64I,"sceIoLseekAsync"}, - {0x109F50BC,&WrapU_CI, "sceIoOpen"}, //(const char* file, int mode); - {0x89AA9906,&WrapV_CI,"sceIoOpenAsync"}, - {0x06A70004,&WrapU_CI,"sceIoMkdir"}, //(const char *dir, int mode); - {0x3251ea56,&WrapU_IU,"sceIoPollAsync"}, - {0x6A638D83,&WrapU_IUI, "sceIoRead"}, //(int fd, void *data, int size); - {0xa0b5a7c2,&WrapU_IUI,"sceIoReadAsync"}, - {0xF27A9C51,&WrapU_C,"sceIoRemove"}, //(const char *file); - {0x779103A0,&WrapU_CC,"sceIoRename"}, //(const char *oldname, const char *newname); - {0x1117C65F,&WrapU_C,"sceIoRmdir"}, //(const char *dir); - {0xA12A0514,&WrapU_IUU,"sceIoSetAsyncCallback"}, - {0xab96437f,sceIoSync,"sceIoSync"}, - {0x6d08a871,0,"sceIoUnassign"}, - {0x42EC03AC,&WrapU_IVI, "sceIoWrite"}, //(int fd, void *data, int size); - {0x0facab19,0,"sceIoWriteAsync"}, - {0x35dbd746,&WrapU_IU,"sceIoWaitAsyncCB"}, - {0xe23eec33,&WrapU_IUU,"sceIoWaitAsync"}, + { 0xb29ddf9c, &WrapU_C, "sceIoDopen" }, + { 0xe3eb004c, &WrapU_IU, "sceIoDread" }, + { 0xeb092469, &WrapU_I, "sceIoDclose" }, + { 0xe95a012b, 0, "sceIoIoctlAsync" }, + { 0x63632449, 0, "sceIoIoctl" }, + { 0xace946e8, &WrapU_CU, "sceIoGetstat" }, + { 0xb8a740f4, 0, "sceIoChstat" }, + { 0x55f4717d, &WrapU_C, "sceIoChdir" }, + { 0x08bd7374, 0, "sceIoGetDevType" }, + { 0xB2A628C1, &WrapU_CCCU, "sceIoAssign" }, + { 0xe8bc6571, 0, "sceIoCancel" }, + { 0xb293727f, sceIoChangeAsyncPriority, "sceIoChangeAsyncPriority" }, + { 0x810C4BC3, &WrapU_I, "sceIoClose" }, //(int fd); + { 0xff5940b6, sceIoCloseAsync, "sceIoCloseAsync" }, + { 0x54F5FB11, &WrapU_CIUIUI, "sceIoDevctl" }, //(const char *name int cmd, void *arg, size_t arglen, void *buf, size_t *buflen); + { 0xcb05f8d6, &WrapU_IUU, "sceIoGetAsyncStat" }, + { 0x27EB27B8, &WrapU_II64I, "sceIoLseek" }, //(int fd, int offset, int whence); + { 0x68963324, &WrapU_III, "sceIoLseek32" }, + { 0x1b385d8f, &WrapU_III, "sceIoLseek32Async" }, + { 0x71b19e77, &WrapU_II64I, "sceIoLseekAsync" }, + { 0x109F50BC, &WrapU_CI, "sceIoOpen" }, //(const char* file, int mode); + { 0x89AA9906, &WrapV_CI, "sceIoOpenAsync" }, + { 0x06A70004, &WrapU_CI, "sceIoMkdir" }, //(const char *dir, int mode); + { 0x3251ea56, &WrapU_IU, "sceIoPollAsync" }, + { 0x6A638D83, &WrapU_IUI, "sceIoRead" }, //(int fd, void *data, int size); + { 0xa0b5a7c2, &WrapU_IUI, "sceIoReadAsync" }, + { 0xF27A9C51, &WrapU_C, "sceIoRemove" }, //(const char *file); + { 0x779103A0, &WrapU_CC, "sceIoRename" }, //(const char *oldname, const char *newname); + { 0x1117C65F, &WrapU_C, "sceIoRmdir" }, //(const char *dir); + { 0xA12A0514, &WrapU_IUU, "sceIoSetAsyncCallback" }, + { 0xab96437f, sceIoSync, "sceIoSync" }, + { 0x6d08a871, 0, "sceIoUnassign" }, + { 0x42EC03AC, &WrapU_IVI, "sceIoWrite" }, //(int fd, void *data, int size); + { 0x0facab19, 0, "sceIoWriteAsync" }, + { 0x35dbd746, &WrapV_IU, "sceIoWaitAsyncCB" }, + { 0xe23eec33, &WrapV_IUU, "sceIoWaitAsync" }, }; void Register_IoFileMgrForUser() @@ -947,11 +981,11 @@ void Register_IoFileMgrForUser() } -const HLEFunction StdioForUser[] = +const HLEFunction StdioForUser[] = { - {0x172D316E,&WrapU_V,"sceKernelStdin"}, - {0xA6BAB2E9,&WrapU_V,"sceKernelStdout"}, - {0xF78BA90A,&WrapU_V,"sceKernelStderr"}, + { 0x172D316E, &WrapU_V, "sceKernelStdin" }, + { 0xA6BAB2E9, &WrapU_V, "sceKernelStdout" }, + { 0xF78BA90A, &WrapU_V, "sceKernelStderr" }, }; void Register_StdioForUser()