From 7a27d2fdc1e8e52449577b607b477ec7bc583034 Mon Sep 17 00:00:00 2001 From: Crementif <26669564+Crementif@users.noreply.github.com> Date: Thu, 23 Dec 2021 16:49:35 +0100 Subject: [PATCH] [Color Splash] Add Improve Performance Pack Made by Exzap --- .../patch_taskmgr.asm | 80 +++++++++++++++++++ Mods/ColorSplash_ImprovePerformance/rules.txt | 6 ++ 2 files changed, 86 insertions(+) create mode 100644 Mods/ColorSplash_ImprovePerformance/patch_taskmgr.asm create mode 100644 Mods/ColorSplash_ImprovePerformance/rules.txt diff --git a/Mods/ColorSplash_ImprovePerformance/patch_taskmgr.asm b/Mods/ColorSplash_ImprovePerformance/patch_taskmgr.asm new file mode 100644 index 00000000..2090037b --- /dev/null +++ b/Mods/ColorSplash_ImprovePerformance/patch_taskmgr.asm @@ -0,0 +1,80 @@ +[SharedConstants] +moduleMatches = 0xca6b9a52, 0x7467d6cf + +TASK_MGR_OBJ_SIZE = 0x3878 ; sys::task::Manager unmodified base size. +OS_SEMAPHORE_SIZE = 0x20 +NEW_TASK_MGR_OBJ_SIZE = TASK_MGR_OBJ_SIZE + OS_SEMAPHORE_SIZE + +[SharedCode] +moduleMatches = 0xca6b9a52, 0x7467d6cf + +.origin = codecave + +; Init hook +; We initialize the semaphore we append at the end of the class +_TaskManagerInitHook: + mflr r30 + li r4, 0 ; initial count for semaphore + mr r3, r31 + addi r3, r3, TASK_MGR_OBJ_SIZE + bl import.coreinit.OSInitSemaphore ; OSInitSemaphore(&taskMgr->ourSemaphore, 0) + mtlr r30 + li r9, 0 ; our hook replaces an instruction that sets r9 = 0 +blr + + +; Submit hook +; We signal the semaphore +_TaskManagerSubmitHook: + mflr r29 + mr r3, r31 + addi r3, r3, TASK_MGR_OBJ_SIZE + bl import.coreinit.OSSignalSemaphore ; OSSignalSemaphore(&taskMgr->ourSemaphore) + mtlr r29 + lwz r3, 0x10(r1) ; replaced instruction +blr + +; RunQueuedTask hook +; We wait for the semaphore before checking if work is available +_TaskManagerRunQueuedTask: + mr r31, r3 ; replaced instruction + + mflr r29 + mr r3, r31 + addi r3, r3, TASK_MGR_OBJ_SIZE + bl import.coreinit.OSWaitSemaphore ; OSWaitSemaphore(&taskMgr->ourSemaphore) + + mtlr r29 +blr + + +; Todo - Signal semaphore on TaskManager shutdown request + + +[ColorSplashEUv0] +moduleMatches = 0xca6b9a52 + +; increase allocated size of sys::task::Manager to fit our appended OSSemaphore +0x025E249C = li r3, NEW_TASK_MGR_OBJ_SIZE +0x0233D068 = li r3, NEW_TASK_MGR_OBJ_SIZE +0x0233D098 = li r3, NEW_TASK_MGR_OBJ_SIZE +0x0243C284 = li r3, NEW_TASK_MGR_OBJ_SIZE + +0x025E2588 = bla _TaskManagerInitHook +0x025E2AA8 = bla _TaskManagerSubmitHook +0x025E1F14 = bla _TaskManagerRunQueuedTask + + +[ColorSplashUSv0] +moduleMatches = 0x7467d6cf + +; subtract 0xDC from EU offsets to get US offsets + +0x025E23C0 = li r3, NEW_TASK_MGR_OBJ_SIZE +0x0233CF8C = li r3, NEW_TASK_MGR_OBJ_SIZE +0x0233CFBC = li r3, NEW_TASK_MGR_OBJ_SIZE +0x0243C1A8 = li r3, NEW_TASK_MGR_OBJ_SIZE + +0x025E24AC = bla _TaskManagerInitHook +0x025E29CC = bla _TaskManagerSubmitHook +0x025E1E38 = bla _TaskManagerRunQueuedTask \ No newline at end of file diff --git a/Mods/ColorSplash_ImprovePerformance/rules.txt b/Mods/ColorSplash_ImprovePerformance/rules.txt new file mode 100644 index 00000000..727dcf86 --- /dev/null +++ b/Mods/ColorSplash_ImprovePerformance/rules.txt @@ -0,0 +1,6 @@ +[Definition] +titleIds = 000500001F600900,000500001F600A00,000500001F600B00 +name = Improve Performance +path = "Paper Mario: Color Splash/Mods/Improve Performance" +description = Substantially lowers CPU requirements of the game.|Can improve performance on some systems.||Needs to be enabled before (and can't be disabled after) running the game, otherwise it'll crash. +version = 7 \ No newline at end of file