diff --git a/cube/swiss/source/gcm.c b/cube/swiss/source/gcm.c index 83353219..7141d819 100644 --- a/cube/swiss/source/gcm.c +++ b/cube/swiss/source/gcm.c @@ -348,12 +348,13 @@ int patch_gcm(file_handle *file, ExecutableFile *filesToPatch, int numToPatch, i char patchDirName[256]; char patchBaseDirName[256]; - char gameID[8]; - memset(&gameID, 0, 8); + char gameID[16]; + memset(&gameID, 0, 16); memset(&patchDirName, 0, 256); memset(&patchBaseDirName, 0, 256); strncpy((char*)&gameID, (char*)&GCMDisk, 4); sprintf(&patchDirName[0],"%sswiss_patches/%s",devices[DEVICE_PATCHES]->initial->name, &gameID[0]); + memcpy((char*)&gameID, (char*)&GCMDisk, 12); sprintf(&patchBaseDirName[0],"%sswiss_patches",devices[DEVICE_PATCHES]->initial->name); print_gecko("Patch dir will be: %s if required\r\n", patchDirName); *(vu32*)VAR_EXECD_OFFSET = 0xFFFFFFFF; diff --git a/cube/swiss/source/patcher.c b/cube/swiss/source/patcher.c index 1b9b487f..fc3529d8 100644 --- a/cube/swiss/source/patcher.c +++ b/cube/swiss/source/patcher.c @@ -438,6 +438,56 @@ int PatchDetectLowMemUsage( u8 *dst, u32 Length, int dataType ) return LowMemPatched; } +// HACK: PSO 0x80001800 move to 0x817F1800 +u32 PatchPatchBuffer(char *dst) +{ + int i; + int patched = 0; + u32 LISReg = -1; + u32 LISOff = -1; + + for (i = 0;; i += 4) + { + u32 op = *(vu32*)(dst + i); + + if ((op & 0xFC1FFFFF) == 0x3C008000) // lis rX, 0x8000 + { + LISReg = (op & 0x3E00000) >> 21; + LISOff = (u32)dst + i; + } + + if ((op & 0xFC000000) == 0x38000000) // li rX, x + { + u32 src = (op >> 16) & 0x1F; + u32 dst = (op >> 21) & 0x1F; + if ((src != LISReg) && (dst == LISReg)) + { + LISReg = -1; + LISOff = (u32)dst + i; + } + } + + if ((op & 0xFC00FFFF) == 0x38001800) // addi rX, rY, 0x1800 (patch buffer) + { + u32 src = (op >> 16) & 0x1F; + if (src == LISReg) + { + *(vu32*)(LISOff) = (LISReg << 21) | 0x3C00817F; + print_gecko("Patch:[%08X] %08X: lis r%u, 0x817F\r\n", (u32)LISOff, *(u32*)LISOff, LISReg ); + LISReg = -1; + patched++; + } + u32 dst = (op >> 21) & 0x1F; + if (dst == LISReg) + LISReg = -1; + } + if (op == 0x4E800020) // blr + break; + } + return patched; +} + + u32 Patch_DVDLowLevelReadForWKF(void *addr, u32 length, int dataType) { int i = 0; @@ -1842,6 +1892,23 @@ int Patch_GameSpecific(void *addr, u32 length, const char* gameID, int dataType) addr_start += 4; } } + else if((*(u32*)&gameID[0] == 0x47504F45) + && (*(u32*)&gameID[4] == 0x38500002) + && (*(u32*)&gameID[8] == 0x01000000)) { + // Nasty PSO 1 & 2+ hack to redirect a lowmem buffer to highmem + void *addr_start = addr; + void *addr_end = addr+length; + while(addr_start 0) { top_of_main_ram = WIIRD_ENGINE; } + if((*(u32*)0x80000000 == 0x47504F45) + && (*(u32*)0x80000004 == 0x38500002) + && (*(u32*)0x80000008 == 0x01000000)) { + // Nasty PSO 1 & 2+ hack to redirect a lowmem buffer to highmem + top_of_main_ram = 0x817F1800; + print_gecko("PSO 1 & 2+ hack enabled\r\n"); + } print_gecko("Top of RAM simulated as: 0x%08X\r\n", top_of_main_ram);