From 5b34700cb2d1f845fb8b451a795e031a44cc9428 Mon Sep 17 00:00:00 2001 From: jdflyer Date: Mon, 2 Jan 2023 19:44:52 -0700 Subject: [PATCH] Add frank.py --- Makefile | 1 + include/dolphin/ai/ai.h | 2 +- libs/dolphin/ai/Makefile | 2 + libs/dolphin/ai/ai.c | 62 +--------- libs/dolphin/ar/Makefile | 2 + libs/dolphin/ar/ar.c | 12 -- libs/dolphin/base/Makefile | 2 + libs/dolphin/card/CARDBios.c | 132 -------------------- libs/dolphin/card/CARDBlock.c | 12 -- libs/dolphin/card/CARDCheck.c | 12 -- libs/dolphin/card/CARDDir.c | 12 -- libs/dolphin/card/CARDFormat.c | 12 -- libs/dolphin/card/CARDMount.c | 24 ---- libs/dolphin/card/CARDRdwr.c | 12 -- libs/dolphin/card/CARDRead.c | 12 -- libs/dolphin/card/Makefile | 2 + libs/dolphin/db/Makefile | 2 + libs/dolphin/dsp/Makefile | 2 + libs/dolphin/dsp/dsp_task.c | 58 --------- libs/dolphin/dvd/Makefile | 2 + libs/dolphin/dvd/dvd.c | 60 +-------- libs/dolphin/dvd/dvdidutils.c | 12 -- libs/dolphin/dvd/fstload.c | 49 -------- libs/dolphin/exi/EXIBios.c | 2 +- libs/dolphin/exi/Makefile | 2 + libs/dolphin/gd/Makefile | 2 + libs/dolphin/gx/Makefile | 2 + libs/dolphin/mtx/Makefile | 2 + libs/dolphin/os/Makefile | 2 + libs/dolphin/os/OSAlarm.c | 24 ---- libs/dolphin/os/OSAudioSystem.c | 11 -- libs/dolphin/os/OSCache.c | 12 -- libs/dolphin/os/OSInterrupt.c | 24 ---- libs/dolphin/os/OSMessage.c | 24 ---- libs/dolphin/os/OSRtc.c | 36 ------ libs/dolphin/os/OSTime.c | 24 ---- libs/dolphin/pad/Makefile | 2 + libs/dolphin/pad/Pad.c | 36 ------ libs/dolphin/pad/Padclamp.c | 26 +--- libs/dolphin/si/Makefile | 2 + libs/dolphin/si/SIBios.c | 42 +------ libs/dolphin/vi/Makefile | 2 + tools/frank.py | 213 ++++++++++++++++++++++++++++++++ 43 files changed, 253 insertions(+), 735 deletions(-) create mode 100644 tools/frank.py diff --git a/Makefile b/Makefile index 12d2e013714..64d37dddd6d 100644 --- a/Makefile +++ b/Makefile @@ -77,6 +77,7 @@ PYTHON := python3 ICONV := iconv DOXYGEN := doxygen MAKEREL := tools/makerel.py +FRANK := tools/frank.py IMAGENAME := gz2e01.iso # Options diff --git a/include/dolphin/ai/ai.h b/include/dolphin/ai/ai.h index 0130971aea9..0de6e2d9ccc 100644 --- a/include/dolphin/ai/ai.h +++ b/include/dolphin/ai/ai.h @@ -15,7 +15,7 @@ void AIInitDMA(u32 addr, u32 length); void AIStartDMA(void); void AIStopDMA(void); void AISetStreamPlayState(u32 state); -u32 AIGetStreamPlayState(void); +inline u32 AIGetStreamPlayState(void); void AISetDSPSampleRate(u32 rate); u32 AIGetDSPSampleRate(void); void __AI_set_stream_sample_rate(u32 rate); diff --git a/libs/dolphin/ai/Makefile b/libs/dolphin/ai/Makefile index 895608cf4a2..b4a68b263eb 100644 --- a/libs/dolphin/ai/Makefile +++ b/libs/dolphin/ai/Makefile @@ -36,3 +36,5 @@ $(BUILD_DIR)/libs/dolphin/ai/%.o: libs/dolphin/ai/%.c @echo building... $< @$(ICONV) -f UTF-8 -t CP932 < $< > $(basename $@).c @$(WINE) tools/mwcc_compiler/1.2.5/mwcceppc.exe $(LIBAI_A_CFLAGS) -c -o $@ $(basename $@).c + @echo Frank is fixing $@ + @$(PYTHON) $(FRANK) $@ $@ $@ diff --git a/libs/dolphin/ai/ai.c b/libs/dolphin/ai/ai.c index 44071660dda..c305f120850 100644 --- a/libs/dolphin/ai/ai.c +++ b/libs/dolphin/ai/ai.c @@ -32,8 +32,6 @@ asm AIDCallback AIRegisterDMACallback(AIDCallback callback) { #pragma pop /* 8034FCB4-8034FD3C 34A5F4 0088+00 0/0 2/2 0/0 .text AIInitDMA */ -// need compiler epilogue patch -#ifdef NONMATCHING void AIInitDMA(u32 addr, u32 length) { s32 oldInts; oldInts = OSDisableInterrupts(); @@ -42,16 +40,6 @@ void AIInitDMA(u32 addr, u32 length) { __DSPRegs[27] = (u16)((__DSPRegs[27] & ~0x7FFF) | (u16)((length >> 5) & 0xFFFF)); OSRestoreInterrupts(oldInts); } -#else -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void AIInitDMA(u32 addr, u32 length) { - nofralloc -#include "asm/dolphin/ai/ai/AIInitDMA.s" -} -#pragma pop -#endif /* 8034FD3C-8034FD54 34A67C 0018+00 0/0 1/1 0/0 .text AIStartDMA */ void AIStartDMA(void) { @@ -65,8 +53,6 @@ void AIStopDMA(void) { } /* 8034FD6C-8034FE44 34A6AC 00D8+00 1/1 1/1 0/0 .text AISetStreamPlayState */ -// need compiler epilogue patch -#ifdef NONMATCHING void AISetStreamPlayState(u32 state) { s32 oldInts; u8 volRight; @@ -92,25 +78,13 @@ void AISetStreamPlayState(u32 state) { __AIRegs[0] = (__AIRegs[0] & ~1) | state; } } -#else -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void AISetStreamPlayState(u32 state) { - nofralloc -#include "asm/dolphin/ai/ai/AISetStreamPlayState.s" -} -#pragma pop -#endif /* 8034FE44-8034FE54 34A784 0010+00 1/1 0/0 0/0 .text AIGetStreamPlayState */ -u32 AIGetStreamPlayState(void) { +inline u32 AIGetStreamPlayState(void) { return __AIRegs[0] & 1; } /* 8034FE54-8034FF34 34A794 00E0+00 1/1 1/1 0/0 .text AISetDSPSampleRate */ -// need compiler epilogue patch -#ifdef NONMATCHING void AISetDSPSampleRate(u32 rate) { u32 state; s32 oldInts; @@ -141,16 +115,6 @@ void AISetDSPSampleRate(u32 rate) { AISetStreamVolRight(right); } } -#else -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void AISetDSPSampleRate(u32 rate) { - nofralloc -#include "asm/dolphin/ai/ai/AISetDSPSampleRate.s" -} -#pragma pop -#endif /* 8034FF34-8034FF48 34A874 0014+00 1/1 0/0 1/1 .text AIGetDSPSampleRate */ u32 AIGetDSPSampleRate(void) { @@ -158,8 +122,6 @@ u32 AIGetDSPSampleRate(void) { } /* 8034FF48-8035001C 34A888 00D4+00 1/1 0/1 0/0 .text __AI_set_stream_sample_rate */ -// need compiler epilogue patch -#ifdef NONMATCHING void __AI_set_stream_sample_rate(u32 rate) { s32 oldInts; s32 state; @@ -188,16 +150,6 @@ void __AI_set_stream_sample_rate(u32 rate) { AISetStreamVolLeft(left); AISetStreamVolRight(right); } -#else -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void __AI_set_stream_sample_rate(u32 rate) { - nofralloc -#include "asm/dolphin/ai/ai/__AI_set_stream_sample_rate.s" -} -#pragma pop -#endif /* 8035001C-8035002C 34A95C 0010+00 3/3 0/0 0/0 .text AIGetStreamSampleRate */ u32 AIGetStreamSampleRate(void) { @@ -271,8 +223,6 @@ asm void AIInit(u8* stack) { #pragma pop /* 803501F0-8035026C 34AB30 007C+00 1/1 0/0 0/0 .text __AISHandler */ -// need compiler epilogue patch -#ifdef NONMATCHING void __AISHandler(s16 interrupt, OSContext* context) { OSContext tmpContext; __AIRegs[0] |= 8; @@ -286,16 +236,6 @@ void __AISHandler(s16 interrupt, OSContext* context) { OSClearContext(&tmpContext); OSSetCurrentContext(context); } -#else -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void __AISHandler(s16 interrupt, OSContext* context) { - nofralloc -#include "asm/dolphin/ai/ai/__AISHandler.s" -} -#pragma pop -#endif /* 8035026C-80350318 34ABAC 00AC+00 1/1 0/0 0/0 .text __AIDHandler */ void __AIDHandler(s16 interrupt, OSContext* context) { diff --git a/libs/dolphin/ar/Makefile b/libs/dolphin/ar/Makefile index dcf2513caa3..0d2c1d0264c 100644 --- a/libs/dolphin/ar/Makefile +++ b/libs/dolphin/ar/Makefile @@ -38,4 +38,6 @@ $(BUILD_DIR)/libs/dolphin/ar/%.o: libs/dolphin/ar/%.c @echo building... $< @$(ICONV) -f UTF-8 -t CP932 < $< > $(basename $@).c @$(WINE) tools/mwcc_compiler/1.2.5/mwcceppc.exe $(LIBAR_A_CFLAGS) -c -o $@ $(basename $@).c + @echo Frank is fixing $@ + @$(PYTHON) $(FRANK) $@ $@ $@ diff --git a/libs/dolphin/ar/ar.c b/libs/dolphin/ar/ar.c index 77ea7f42714..71a085cce92 100644 --- a/libs/dolphin/ar/ar.c +++ b/libs/dolphin/ar/ar.c @@ -65,8 +65,6 @@ asm u32 ARGetDMAStatus(void) { #endif /* 803505D4-803506C4 34AF14 00F0+00 0/0 5/5 0/0 .text ARStartDMA */ -// needs compiler epilogue patch -#ifdef NONMATCHING void ARStartDMA(u32 type, u32 mainmem_addr, u32 aram_addr, u32 length) { BOOL enabled; @@ -81,16 +79,6 @@ void ARStartDMA(u32 type, u32 mainmem_addr, u32 aram_addr, u32 length) { __DSPRegs[21] = (u16)(__DSPRegs[21] & ~0xffe0) | (u16)(length & 0xffff); OSRestoreInterrupts(enabled); } -#else -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void ARStartDMA(u32 type, u32 mainmem_addr, u32 aram_addr, u32 length) { - nofralloc -#include "asm/dolphin/ar/ar/ARStartDMA.s" -} -#pragma pop -#endif /* ############################################################################################## */ /* 804518BC-804518C0 000DBC 0004+00 2/1 0/0 0/0 .sbss __AR_Size */ diff --git a/libs/dolphin/base/Makefile b/libs/dolphin/base/Makefile index a165ad6da08..91baf15200d 100644 --- a/libs/dolphin/base/Makefile +++ b/libs/dolphin/base/Makefile @@ -28,4 +28,6 @@ $(BUILD_DIR)/libs/dolphin/base/%.o: libs/dolphin/base/%.c @echo building... $< @$(ICONV) -f UTF-8 -t CP932 < $< > $(basename $@).c @$(WINE) tools/mwcc_compiler/1.2.5/mwcceppc.exe $(CFLAGS) $(LIBBASE_A_CFLAGS) -c -o $@ $(basename $@).c + @echo Frank is fixing $@ + @$(PYTHON) $(FRANK) $@ $@ $@ diff --git a/libs/dolphin/card/CARDBios.c b/libs/dolphin/card/CARDBios.c index 88d3da301bf..47217f41be2 100644 --- a/libs/dolphin/card/CARDBios.c +++ b/libs/dolphin/card/CARDBios.c @@ -46,8 +46,6 @@ void __CARDSyncCallback(s32 chan, s32 result) { } /* 80352A68-80352B40 34D3A8 00D8+00 0/0 1/1 0/0 .text __CARDExtHandler */ -// needs compiler epilogue patch -#ifdef NONMATCHING void __CARDExtHandler(s32 chan, OSContext* context) { CARDControl* card; CARDCallback callback; @@ -75,20 +73,8 @@ void __CARDExtHandler(s32 chan, OSContext* context) { } } } -#else -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void __CARDExtHandler(s32 chan, OSContext* context) { - nofralloc -#include "asm/dolphin/card/CARDBios/__CARDExtHandler.s" -} -#pragma pop -#endif /* 80352B40-80352C58 34D480 0118+00 0/0 1/1 0/0 .text __CARDExiHandler */ -// needs compiler epilogue patch -#ifdef NONMATCHING void __CARDExiHandler(s32 chan, OSContext* context) { CARDControl* card; CARDCallback callback; @@ -132,16 +118,6 @@ fatal: callback(chan, result); } } -#else -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void __CARDExiHandler(s32 chan, OSContext* context) { - nofralloc -#include "asm/dolphin/card/CARDBios/__CARDExiHandler.s" -} -#pragma pop -#endif /* 80352C58-80352D00 34D598 00A8+00 3/3 0/0 0/0 .text __CARDTxHandler */ void __CARDTxHandler(s32 chan, OSContext* context) { @@ -161,8 +137,6 @@ void __CARDTxHandler(s32 chan, OSContext* context) { } /* 80352D00-80352D84 34D640 0084+00 2/2 2/2 0/0 .text __CARDUnlockedHandler */ -// needs compiler epilogue patch -#ifdef NONMATCHING void __CARDUnlockedHandler(s32 chan, OSContext* context) { CARDControl* card; CARDCallback callback; @@ -174,20 +148,8 @@ void __CARDUnlockedHandler(s32 chan, OSContext* context) { callback(chan, EXIProbe(chan) ? CARD_RESULT_UNLOCKED : CARD_RESULT_NOCARD); } } -#else -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void __CARDUnlockedHandler(s32 chan, OSContext* context) { - nofralloc -#include "asm/dolphin/card/CARDBios/__CARDUnlockedHandler.s" -} -#pragma pop -#endif /* 80352D84-80352E44 34D6C4 00C0+00 0/0 1/1 0/0 .text __CARDEnableInterrupt */ -// needs compiler epilogue patch -#ifdef NONMATCHING s32 __CARDEnableInterrupt(s32 chan, BOOL enable) { BOOL err; u32 cmd; @@ -203,20 +165,8 @@ s32 __CARDEnableInterrupt(s32 chan, BOOL enable) { err |= !EXIDeselect(chan); return err ? CARD_RESULT_NOCARD : CARD_RESULT_READY; } -#else -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm s32 __CARDEnableInterrupt(s32 chan, BOOL enable) { - nofralloc -#include "asm/dolphin/card/CARDBios/__CARDEnableInterrupt.s" -} -#pragma pop -#endif /* 80352E44-80352F34 34D784 00F0+00 1/1 2/2 0/0 .text __CARDReadStatus */ -// needs compiler epilogue patch -#ifdef NONMATCHING s32 __CARDReadStatus(s32 chan, u8* status) { BOOL err; u32 cmd; @@ -234,16 +184,6 @@ s32 __CARDReadStatus(s32 chan, u8* status) { err |= !EXIDeselect(chan); return err ? CARD_RESULT_NOCARD : CARD_RESULT_READY; } -#else -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm s32 __CARDReadStatus(s32 chan, u8* status) { - nofralloc -#include "asm/dolphin/card/CARDBios/__CARDReadStatus.s" -} -#pragma pop -#endif /* 80352F34-80353024 34D874 00F0+00 0/0 1/1 0/0 .text __CARDReadVendorID */ #pragma push @@ -256,8 +196,6 @@ asm void __CARDReadVendorID() { #pragma pop /* 80353024-803530D0 34D964 00AC+00 1/1 1/1 0/0 .text __CARDClearStatus */ -// needs compiler epilogue patch -#ifdef NONMATCHING s32 __CARDClearStatus(s32 chan) { BOOL err; u32 cmd; @@ -274,20 +212,8 @@ s32 __CARDClearStatus(s32 chan) { return err ? CARD_RESULT_NOCARD : CARD_RESULT_READY; } -#else -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm s32 __CARDClearStatus(s32 chan) { - nofralloc -#include "asm/dolphin/card/CARDBios/__CARDClearStatus.s" -} -#pragma pop -#endif /* 803530D0-80353174 34DA10 00A4+00 2/2 0/0 0/0 .text TimeoutHandler */ -// needs compiler epilogue patch -#ifdef NONMATCHING static void TimeoutHandler(OSAlarm* alarm, OSContext* context) { s32 chan; CARDControl* card; @@ -310,16 +236,6 @@ static void TimeoutHandler(OSAlarm* alarm, OSContext* context) { callback(chan, CARD_RESULT_IOERROR); } } -#else -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -static asm void TimeoutHandler(OSAlarm* alarm, OSContext* context) { - nofralloc -#include "asm/dolphin/card/CARDBios/TimeoutHandler.s" -} -#pragma pop -#endif /* 80353174-80353414 34DAB4 02A0+00 2/2 0/0 0/0 .text Retry */ #pragma push @@ -332,8 +248,6 @@ static asm s32 Retry(s32 chan) { #pragma pop /* 80353414-80353524 34DD54 0110+00 1/1 0/0 0/0 .text UnlockedCallback */ -// needs compiler epilogue patch -#ifdef NONMATCHING static void UnlockedCallback(s32 chan, s32 result) { CARDCallback callback; CARDControl* card; @@ -371,16 +285,6 @@ static void UnlockedCallback(s32 chan, s32 result) { } } } -#else -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -static asm void UnlockedCallback(s32 chan, s32 result) { - nofralloc -#include "asm/dolphin/card/CARDBios/UnlockedCallback.s" -} -#pragma pop -#endif /* 80353524-80353748 34DE64 0224+00 3/3 0/0 0/0 .text __CARDStart */ #pragma push @@ -399,8 +303,6 @@ asm s32 __CARDStart(s32 chan, CARDCallback txCallback, CARDCallback exiCallback) #define BA(x) ((u8)((x)&0x7f)) /* 80353748-8035387C 34E088 0134+00 0/0 2/2 0/0 .text __CARDReadSegment */ -// needs compiler epilogue patch -#ifdef NONMATCHING s32 __CARDReadSegment(s32 chan, CARDCallback callback) { CARDControl* card; s32 result; @@ -433,16 +335,6 @@ s32 __CARDReadSegment(s32 chan, CARDCallback callback) { } return result; } -#else -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm s32 __CARDReadSegment(s32 chan, CARDCallback callback) { - nofralloc -#include "asm/dolphin/card/CARDBios/__CARDReadSegment.s" -} -#pragma pop -#endif /* 8035387C-803539B8 34E1BC 013C+00 0/0 2/2 0/0 .text __CARDWritePage */ // needs compiler epilogue patch @@ -522,8 +414,6 @@ static u16 __CARDEncode; static u16 __CARDFastMode; /* 80353AC8-80353B74 34E408 00AC+00 0/0 1/1 0/0 .text CARDInit */ -// needs compiler epilogue patch -#ifdef NONMATCHING void CARDInit(void) { int chan; @@ -549,16 +439,6 @@ void CARDInit(void) { OSRegisterResetFunction(&ResetFunctionInfo); } -#else -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void CARDInit(void) { - nofralloc -#include "asm/dolphin/card/CARDBios/CARDInit.s" -} -#pragma pop -#endif /* 80353B74-80353B7C 34E4B4 0008+00 0/0 2/2 0/0 .text __CARDGetFontEncode */ u16 __CARDGetFontEncode(void) { @@ -572,8 +452,6 @@ void __CARDSetDiskID(const DVDDiskID* id) { } /* 80353BB4-80353C6C 34E4F4 00B8+00 1/1 10/10 0/0 .text __CARDGetControlBlock */ -// needs compiler epilogue patch -#ifdef NONMATCHING s32 __CARDGetControlBlock(s32 chan, CARDControl** pcard) { BOOL enabled; s32 result; @@ -598,16 +476,6 @@ s32 __CARDGetControlBlock(s32 chan, CARDControl** pcard) { OSRestoreInterrupts(enabled); return result; } -#else -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm s32 __CARDGetControlBlock(s32 chan, CARDControl** pcard) { - nofralloc -#include "asm/dolphin/card/CARDBios/__CARDGetControlBlock.s" -} -#pragma pop -#endif /* 80353C6C-80353CD0 34E5AC 0064+00 0/0 24/24 0/0 .text __CARDPutControlBlock */ #pragma push diff --git a/libs/dolphin/card/CARDBlock.c b/libs/dolphin/card/CARDBlock.c index b733a54c2d8..a1cab5be6aa 100644 --- a/libs/dolphin/card/CARDBlock.c +++ b/libs/dolphin/card/CARDBlock.c @@ -29,8 +29,6 @@ u16* __CARDGetFatBlock(CARDControl* card) { } /* 8035541C-803554F0 34FD5C 00D4+00 1/1 0/0 0/0 .text WriteCallback */ -// needs compiler epilogue patch -#ifdef NONMATCHING static void WriteCallback(s32 chan, s32 result) { CARDControl* card; CARDCallback callback; @@ -62,16 +60,6 @@ static void WriteCallback(s32 chan, s32 result) { callback(chan, result); } } -#else -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -static asm void WriteCallback(s32 chan, s32 result) { - nofralloc -#include "asm/dolphin/card/CARDBlock/WriteCallback.s" -} -#pragma pop -#endif /* 803554F0-803555B8 34FE30 00C8+00 1/1 0/0 0/0 .text EraseCallback */ #pragma push diff --git a/libs/dolphin/card/CARDCheck.c b/libs/dolphin/card/CARDCheck.c index 43cbd129af5..d1fea3f8da6 100644 --- a/libs/dolphin/card/CARDCheck.c +++ b/libs/dolphin/card/CARDCheck.c @@ -83,8 +83,6 @@ static asm s32 VerifyFAT(CARDControl* card, int* outCurrent) { #pragma pop /* 803562D8-80356364 350C18 008C+00 0/0 1/1 0/0 .text __CARDVerify */ -// needs compiler epilogue patch -#ifdef NONMATCHING s32 __CARDVerify(CARDControl* card) { s32 result; int errors; @@ -105,16 +103,6 @@ s32 __CARDVerify(CARDControl* card) { return CARD_RESULT_BROKEN; } } -#else -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm s32 __CARDVerify(CARDControl* card) { - nofralloc -#include "asm/dolphin/card/CARDCheck/__CARDVerify.s" -} -#pragma pop -#endif /* 80356364-803568F4 350CA4 0590+00 1/1 0/0 0/0 .text CARDCheckExAsync */ #ifdef NONMATCHING diff --git a/libs/dolphin/card/CARDDir.c b/libs/dolphin/card/CARDDir.c index 94277558ef7..adbdffaf4ff 100644 --- a/libs/dolphin/card/CARDDir.c +++ b/libs/dolphin/card/CARDDir.c @@ -25,8 +25,6 @@ CARDDir* __CARDGetDirBlock(CARDControl* card) { } /* 80355784-80355854 3500C4 00D0+00 1/1 0/0 0/0 .text WriteCallback */ -// needs compiler epilogue patch -#ifdef NONMATCHING static void WriteCallback(s32 chan, s32 result) { CARDControl* card; CARDCallback callback; @@ -55,16 +53,6 @@ error: callback(chan, result); } } -#else -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -static asm void WriteCallback(s32 chan, s32 result) { - nofralloc -#include "asm/dolphin/card/CARDDir/WriteCallback.s" -} -#pragma pop -#endif /* 80355854-8035591C 350194 00C8+00 1/1 0/0 0/0 .text EraseCallback */ // needs compiler epilogue patch diff --git a/libs/dolphin/card/CARDFormat.c b/libs/dolphin/card/CARDFormat.c index dacd4b1b1f2..00d5923bfa8 100644 --- a/libs/dolphin/card/CARDFormat.c +++ b/libs/dolphin/card/CARDFormat.c @@ -29,8 +29,6 @@ void __shr2i(); // /* 80357484-803575C8 351DC4 0144+00 1/1 0/0 0/0 .text FormatCallback */ -// needs compiler epilogue patch -#ifdef NONMATCHING static void FormatCallback(s32 chan, s32 result) { CARDControl* card; CARDCallback callback; @@ -68,16 +66,6 @@ error: __CARDPutControlBlock(card, result); callback(chan, result); } -#else -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -static asm void FormatCallback(s32 chan, s32 result) { - nofralloc -#include "asm/dolphin/card/CARDFormat/FormatCallback.s" -} -#pragma pop -#endif /* 803575C8-80357C20 351F08 0658+00 1/1 0/0 0/0 .text __CARDFormatRegionAsync */ #pragma push diff --git a/libs/dolphin/card/CARDMount.c b/libs/dolphin/card/CARDMount.c index 18ed0344e5f..77c04418076 100644 --- a/libs/dolphin/card/CARDMount.c +++ b/libs/dolphin/card/CARDMount.c @@ -156,8 +156,6 @@ static asm s32 DoMount(s32 chan) { #pragma pop /* 8035701C-80357154 35195C 0138+00 2/2 1/1 0/0 .text __CARDMountCallback */ -// needs compiler epilogue patch -#ifdef NONMATCHING void __CARDMountCallback(s32 chan, s32 result) { CARDControl* card; CARDCallback callback; @@ -198,16 +196,6 @@ void __CARDMountCallback(s32 chan, s32 result) { __CARDPutControlBlock(card, result); callback(chan, result); } -#else -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void __CARDMountCallback(s32 chan, s32 result) { - nofralloc -#include "asm/dolphin/card/CARDMount/__CARDMountCallback.s" -} -#pragma pop -#endif /* 80357154-803572F4 351A94 01A0+00 1/1 0/0 0/0 .text CARDMountAsync */ s32 CARDMountAsync(s32 chan, void* workArea, CARDCallback detachCallback, @@ -278,8 +266,6 @@ s32 CARDMount(s32 chan, void* workArea, CARDCallback attachCb) { } /* 8035733C-803573D8 351C7C 009C+00 2/2 0/0 0/0 .text DoUnmount */ -// needs compiler epilogue patch -#ifdef NONMATCHING static void DoUnmount(s32 chan, s32 result) { CARDControl* card; BOOL enabled; @@ -296,16 +282,6 @@ static void DoUnmount(s32 chan, s32 result) { } OSRestoreInterrupts(enabled); } -#else -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -static asm void DoUnmount(s32 chan, s32 result) { - nofralloc -#include "asm/dolphin/card/CARDMount/DoUnmount.s" -} -#pragma pop -#endif /* 803573D8-80357484 351D18 00AC+00 0/0 2/2 0/0 .text CARDUnmount */ #pragma push diff --git a/libs/dolphin/card/CARDRdwr.c b/libs/dolphin/card/CARDRdwr.c index af9cb5f078a..6e244cdecdf 100644 --- a/libs/dolphin/card/CARDRdwr.c +++ b/libs/dolphin/card/CARDRdwr.c @@ -23,8 +23,6 @@ static void BlockWriteCallback(s32 chan, s32 result); // /* 80355184-80355260 34FAC4 00DC+00 1/1 0/0 0/0 .text BlockReadCallback */ -// needs compiler epilogue patch -#ifdef NONMATCHING static void BlockReadCallback(s32 chan, s32 result) { CARDControl* card; CARDCallback callback; @@ -58,16 +56,6 @@ error: callback(chan, result); } } -#else -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -static asm void BlockReadCallback(s32 chan, s32 result) { - nofralloc -#include "asm/dolphin/card/CARDRdwr/BlockReadCallback.s" -} -#pragma pop -#endif /* 80355260-803552C4 34FBA0 0064+00 0/0 3/3 0/0 .text __CARDRead */ s32 __CARDRead(s32 chan, u32 addr, s32 length, void* dst, CARDCallback callback) { diff --git a/libs/dolphin/card/CARDRead.c b/libs/dolphin/card/CARDRead.c index 0d8f13b2e80..f48f104f6eb 100644 --- a/libs/dolphin/card/CARDRead.c +++ b/libs/dolphin/card/CARDRead.c @@ -22,8 +22,6 @@ static void ReadCallback(s32 chan, s32 result); // /* 803584A0-80358658 352DE0 01B8+00 1/1 1/1 0/0 .text __CARDSeek */ -// needs compiler epilogue patch -#ifdef NONMATCHING s32 __CARDSeek(CARDFileInfo* fileInfo, s32 length, s32 offset, CARDControl** pcard) { CARDControl* card; CARDDir* dir; @@ -71,16 +69,6 @@ s32 __CARDSeek(CARDFileInfo* fileInfo, s32 length, s32 offset, CARDControl** pca *pcard = card; return CARD_RESULT_READY; } -#else -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm s32 __CARDSeek(CARDFileInfo* fileInfo, s32 length, s32 offset, CARDControl** pcard) { - nofralloc -#include "asm/dolphin/card/CARDRead/__CARDSeek.s" -} -#pragma pop -#endif /* 80358658-80358788 352F98 0130+00 1/1 0/0 0/0 .text ReadCallback */ static void ReadCallback(s32 chan, s32 result) { diff --git a/libs/dolphin/card/Makefile b/libs/dolphin/card/Makefile index f33f44d5800..1ff4e5596cb 100644 --- a/libs/dolphin/card/Makefile +++ b/libs/dolphin/card/Makefile @@ -62,4 +62,6 @@ $(BUILD_DIR)/libs/dolphin/card/%.o: libs/dolphin/card/%.c @echo building... $< @$(ICONV) -f UTF-8 -t CP932 < $< > $(basename $@).c @$(WINE) tools/mwcc_compiler/1.2.5/mwcceppc.exe $(LIBCARD_A_CFLAGS) -c -o $@ $(basename $@).c + @echo Frank is fixing $@ + @$(PYTHON) $(FRANK) $@ $@ $@ diff --git a/libs/dolphin/db/Makefile b/libs/dolphin/db/Makefile index cb448e6ccae..6f6e3b5d726 100644 --- a/libs/dolphin/db/Makefile +++ b/libs/dolphin/db/Makefile @@ -36,4 +36,6 @@ $(BUILD_DIR)/libs/dolphin/db/%.o: libs/dolphin/db/%.c @echo building... $< @$(ICONV) -f UTF-8 -t CP932 < $< > $(basename $@).c @$(WINE) tools/mwcc_compiler/1.2.5/mwcceppc.exe $(LIBDB_A_CFLAGS) -c -o $@ $(basename $@).c + @echo Frank is fixing $@ + @$(PYTHON) $(FRANK) $@ $@ $@ diff --git a/libs/dolphin/dsp/Makefile b/libs/dolphin/dsp/Makefile index ee6ca8279c8..6cb9ad4e5bc 100644 --- a/libs/dolphin/dsp/Makefile +++ b/libs/dolphin/dsp/Makefile @@ -40,4 +40,6 @@ $(BUILD_DIR)/libs/dolphin/dsp/%.o: libs/dolphin/dsp/%.c @echo building... $< @$(ICONV) -f UTF-8 -t CP932 < $< > $(basename $@).c @$(WINE) tools/mwcc_compiler/1.2.5/mwcceppc.exe $(LIBDSP_A_CFLAGS) -c -o $@ $(basename $@).c + @echo Frank is fixing $@ + @$(PYTHON) $(FRANK) $@ $@ $@ diff --git a/libs/dolphin/dsp/dsp_task.c b/libs/dolphin/dsp/dsp_task.c index 0e1c1ceb502..9d3a19f3233 100644 --- a/libs/dolphin/dsp/dsp_task.c +++ b/libs/dolphin/dsp/dsp_task.c @@ -34,8 +34,6 @@ void __DSP_remove_task(); // /* 803525D0-80352770 34CF10 01A0+00 0/0 1/1 0/0 .text __DSP_exec_task */ -// needs compiler epilogue patch -#ifdef NONMATCHING void __DSP_exec_task(DSPTaskInfo* curr, DSPTaskInfo* next) { if (curr) { DSPSendMailToDSP((u32)(curr->dram_mmem_addr)); @@ -99,56 +97,10 @@ void __DSP_exec_task(DSPTaskInfo* curr, DSPTaskInfo* next) { ; } } -#else -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void __DSP_exec_task(DSPTaskInfo* curr, DSPTaskInfo* next) { - nofralloc -#include "asm/dolphin/dsp/dsp_task/__DSP_exec_task.s" -} -#pragma pop -#endif - -/* ############################################################################################## */ -/* 803D1CF8-803D1D18 02EE18 001D+03 1/1 0/0 0/0 .data @266 */ -SECTION_DATA static char lit_266[] = "DSP is booting task: 0x%08X\n"; - -/* 803D1D18-803D1D48 02EE38 002D+03 0/1 0/0 0/0 .data @267 */ -#pragma push -#pragma force_active on -SECTION_DATA static char lit_267[] = "__DSP_boot_task() : IRAM MMEM ADDR: 0x%08X\n"; -#pragma pop - -/* 803D1D48-803D1D78 02EE68 002D+03 0/1 0/0 0/0 .data @268 */ -#pragma push -#pragma force_active on -SECTION_DATA static char lit_268[] = "__DSP_boot_task() : IRAM DSP ADDR : 0x%08X\n"; -#pragma pop - -/* 803D1D78-803D1DA8 02EE98 002D+03 0/1 0/0 0/0 .data @269 */ -#pragma push -#pragma force_active on -SECTION_DATA static char lit_269[] = "__DSP_boot_task() : IRAM LENGTH : 0x%08X\n"; -#pragma pop - -/* 803D1DA8-803D1DD8 02EEC8 002D+03 0/1 0/0 0/0 .data @270 */ -#pragma push -#pragma force_active on -SECTION_DATA static char lit_270[] = "__DSP_boot_task() : DRAM MMEM ADDR: 0x%08X\n"; -#pragma pop - -/* 803D1DD8-803D1E08 02EEF8 002D+03 0/1 0/0 0/0 .data @271 */ -#pragma push -#pragma force_active on -SECTION_DATA static char lit_271[] = "__DSP_boot_task() : Start Vector : 0x%08X\n"; -#pragma pop #define MSG_BASE 0x80F30000 /* 80352770-803528FC 34D0B0 018C+00 0/0 1/1 0/0 .text __DSP_boot_task */ -// needs compiler epilogue patch -#ifdef NONMATCHING void __DSP_boot_task(DSPTaskInfo* task) { volatile u32 mail; @@ -201,16 +153,6 @@ void __DSP_boot_task(DSPTaskInfo* task) { __DSP_debug_printf("__DSP_boot_task() : Start Vector : 0x%08X\n", (u32)(task->dsp_init_vector)); } -#else -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void __DSP_boot_task(DSPTaskInfo* task) { - nofralloc -#include "asm/dolphin/dsp/dsp_task/__DSP_boot_task.s" -} -#pragma pop -#endif /* 803528FC-8035299C 34D23C 00A0+00 0/0 1/1 0/0 .text __DSP_insert_task */ void __DSP_insert_task(DSPTaskInfo* task) { diff --git a/libs/dolphin/dvd/Makefile b/libs/dolphin/dvd/Makefile index 7137466f6cc..fdbbf629972 100644 --- a/libs/dolphin/dvd/Makefile +++ b/libs/dolphin/dvd/Makefile @@ -50,4 +50,6 @@ $(BUILD_DIR)/libs/dolphin/dvd/%.o: libs/dolphin/dvd/%.c @echo building... $< @$(ICONV) -f UTF-8 -t CP932 < $< > $(basename $@).c @$(WINE) tools/mwcc_compiler/1.2.5/mwcceppc.exe $(LIBDVD_A_CFLAGS) -c -o $@ $(basename $@).c + @echo Frank is fixing $@ + @$(PYTHON) $(FRANK) $@ $@ $@ diff --git a/libs/dolphin/dvd/dvd.c b/libs/dolphin/dvd/dvd.c index 7f15fe80a62..ee2f9879add 100644 --- a/libs/dolphin/dvd/dvd.c +++ b/libs/dolphin/dvd/dvd.c @@ -85,16 +85,8 @@ extern OSThreadQueue __DVDThreadQueue; /* 803490EC-803490F0 343A2C 0004+00 1/0 0/0 0/0 .text defaultOptionalCommandChecker */ static void defaultOptionalCommandChecker() {} -/* ############################################################################################## */ -/* 803D1520-803D1568 02E640 0045+03 1/0 0/0 0/0 .data @1 */ -SECTION_DATA static char lit_1[] = - "<< Dolphin SDK - DVD\trelease build: Apr 5 2004 04:14:51 (0x2301) >>"; - /* 804509E8-804509EC -00001 0004+00 1/1 0/0 0/0 .sdata __DVDVersion */ -SECTION_SDATA static char* __DVDVersion = lit_1; - -/* 803D1568-803D1574 02E688 000A+02 1/1 0/0 0/0 .data @18 */ -SECTION_DATA static char lit_18[] = "load fst\n"; +SECTION_SDATA static char* __DVDVersion = "<< Dolphin SDK - DVD\trelease build: Apr 5 2004 04:14:51 (0x2301) >>"; /* 80451778-8045177C 000C78 0004+00 24/24 0/0 0/0 .sbss executing */ static DVDCommandBlock* executing; @@ -151,8 +143,6 @@ static u32 MotorState; static BOOL DVDInitialized; /* 803490F0-803491C8 343A30 00D8+00 0/0 3/3 0/0 .text DVDInit */ -// needs compiler epilogue patch -#ifdef NONMATCHING void DVDInit(void) { if (DVDInitialized) { return; @@ -181,16 +171,6 @@ void DVDInit(void) { FirstTimeInBootrom = TRUE; } } -#else -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void DVDInit(void) { - nofralloc -#include "asm/dolphin/dvd/dvd/DVDInit.s" -} -#pragma pop -#endif /* ############################################################################################## */ /* 803D1574-803D15A8 02E694 0034+00 2/2 0/0 0/0 .data @24 */ @@ -350,8 +330,6 @@ inline static BOOL CheckCancel(u32 resume) { } /* 80349498-803496FC 343DD8 0264+00 6/6 0/0 0/0 .text cbForStateGettingError */ -// needs compiler epilogue patch -#ifdef NONMATCHING static void cbForStateGettingError(u32 intType) { u32 error; u32 status; @@ -431,16 +409,6 @@ static void cbForStateGettingError(u32 intType) { return; } } -#else -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -static asm void cbForStateGettingError(u32 intType) { - nofralloc -#include "asm/dolphin/dvd/dvd/cbForStateGettingError.s" -} -#pragma pop -#endif /* 803496FC-80349758 34403C 005C+00 1/1 0/0 0/0 .text cbForUnrecoveredError */ static void cbForUnrecoveredError(u32 intType) { @@ -638,7 +606,7 @@ static void AlarmHandler(OSAlarm* alarm, OSContext* context) { static OSAlarm ResetAlarm; /* 80349E30-80349F04 344770 00D4+00 1/1 0/0 0/0 .text stateCoverClosed */ -static void stateCoverClosed(void) { +static inline void stateCoverClosed(void) { DVDCommandBlock* finished; switch (CurrCommand) { @@ -692,23 +660,11 @@ static void stateMotorStopped(void) { } /* 80349FC0-8034A0AC 344900 00EC+00 4/4 0/0 0/0 .text cbForStateMotorStopped */ -// needs stateCoverClosed converted to static inline -#ifdef NONMATCHING static void cbForStateMotorStopped(u32 intType) { __DIRegs[1] = 0; executing->state = 3; stateCoverClosed(); } -#else -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -static asm void cbForStateMotorStopped(u32 intType) { - nofralloc -#include "asm/dolphin/dvd/dvd/cbForStateMotorStopped.s" -} -#pragma pop -#endif /* 8034A0AC-8034A394 3449EC 02E8+00 18/18 0/0 0/0 .text stateReady */ #ifdef NONMATCHING @@ -1187,8 +1143,6 @@ static asm BOOL DVDCancelAsync(DVDCommandBlock* block, DVDCBCallback callback) { #endif /* 8034B550-8034B5FC 345E90 00AC+00 0/0 1/1 1/1 .text DVDCancel */ -// needs compiler epilogue patch -#ifdef NONMATCHING s32 DVDCancel(DVDCommandBlock* block) { BOOL result; s32 state; @@ -1224,16 +1178,6 @@ s32 DVDCancel(DVDCommandBlock* block) { OSRestoreInterrupts(enabled); return 0; } -#else -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm s32 DVDCancel(DVDCommandBlock* block) { - nofralloc -#include "asm/dolphin/dvd/dvd/DVDCancel.s" -} -#pragma pop -#endif /* 8034B5FC-8034B620 345F3C 0024+00 1/1 0/0 0/0 .text cbForCancelSync */ static void cbForCancelSync(s32 result, DVDCommandBlock* block) { diff --git a/libs/dolphin/dvd/dvdidutils.c b/libs/dolphin/dvd/dvdidutils.c index 8e5cd49734d..de95f3e4815 100644 --- a/libs/dolphin/dvd/dvdidutils.c +++ b/libs/dolphin/dvd/dvdidutils.c @@ -3,8 +3,6 @@ #include "dolphin/dvd/dvd.h" /* 8034BC04-8034BCFC 346544 00F8+00 0/0 1/1 0/0 .text DVDCompareDiskID */ -// needs compiler epilogue patch -#ifdef NONMATCHING BOOL DVDCompareDiskID(DVDDiskID* id1, DVDDiskID* id2) { if (id1->game_name[0] && id2->game_name[0] && strncmp(&id1->game_name[0], &id2->game_name[0], 4)) { @@ -27,13 +25,3 @@ BOOL DVDCompareDiskID(DVDDiskID* id1, DVDDiskID* id2) { return TRUE; } -#else -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm BOOL DVDCompareDiskID(DVDDiskID* id1, DVDDiskID* id2) { - nofralloc -#include "asm/dolphin/dvd/dvdidutils/DVDCompareDiskID.s" -} -#pragma pop -#endif diff --git a/libs/dolphin/dvd/fstload.c b/libs/dolphin/dvd/fstload.c index e207c4deafe..d39425eae65 100644 --- a/libs/dolphin/dvd/fstload.c +++ b/libs/dolphin/dvd/fstload.c @@ -51,52 +51,13 @@ static void cb(s32 result, DVDCommandBlock* block) { } } -/* ############################################################################################## */ -/* 803D16F0-803D170C 02E810 001A+02 1/1 0/0 0/0 .data @38 */ -SECTION_DATA static char lit_38[] = " Game Name ... %c%c%c%c\n"; - -/* 803D170C-803D1724 02E82C 0016+02 0/1 0/0 0/0 .data @39 */ -#pragma push -#pragma force_active on -SECTION_DATA static char lit_39[] = " Company ..... %c%c\n"; -#pragma pop - -/* 803D1724-803D1738 02E844 0014+00 0/1 0/0 0/0 .data @40 */ -#pragma push -#pragma force_active on -SECTION_DATA static char lit_40[] = " Disk # ...... %d\n"; -#pragma pop - -/* 803D1738-803D174C 02E858 0014+00 0/1 0/0 0/0 .data @41 */ -#pragma push -#pragma force_active on -SECTION_DATA static char lit_41[] = " Game ver .... %d\n"; -#pragma pop - -/* 803D174C-803D1760 02E86C 0014+00 0/1 0/0 0/0 .data @44 */ -#pragma push -#pragma force_active on -SECTION_DATA static char lit_44[] = " Streaming ... %s\n"; -#pragma pop - /* 8044C9B8-8044C9F8 0796D8 003F+01 1/1 0/0 0/0 .bss bb2Buf */ static u8 bb2Buf[OSRoundUp32B(sizeof(DVDBB2)) + 31]; /* 8044C9F8-8044CA28 079718 0030+00 1/1 0/0 0/0 .bss block$18 */ static u8 block[48]; -/* 80450A00-80450A04 000480 0002+02 1/1 0/0 0/0 .sdata @37 */ -SECTION_SDATA static char lit_37[] = "\n"; - -/* 80450A04-80450A08 000484 0004+00 1/1 0/0 0/0 .sdata @42 */ -SECTION_SDATA static char lit_42[] = "OFF"; - -/* 80450A08-80450A10 000488 0003+05 1/1 0/0 0/0 .sdata @43 */ -SECTION_SDATA static char lit_43[] = "ON"; - /* 8034BE04-8034BF6C 346744 0168+00 0/0 1/1 0/0 .text __fstLoad */ -// needs compiler epilogue patch -#ifdef NONMATCHING void __fstLoad(void) { OSBootInfo* bootInfo; DVDDiskID* id; @@ -131,13 +92,3 @@ void __fstLoad(void) { OSReport("\n"); OSSetArenaHi(bb2->FSTAddress); } -#else -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void __fstLoad(void) { - nofralloc -#include "asm/dolphin/dvd/fstload/__fstLoad.s" -} -#pragma pop -#endif diff --git a/libs/dolphin/exi/EXIBios.c b/libs/dolphin/exi/EXIBios.c index 2b872e18ee0..a2534b240e9 100644 --- a/libs/dolphin/exi/EXIBios.c +++ b/libs/dolphin/exi/EXIBios.c @@ -136,7 +136,7 @@ asm s32 EXIImm(s32 chan, void* buf, s32 len, u32 type, EXICallback callback) { /* 80342F5C-80342FFC 33D89C 00A0+00 0/0 7/7 0/0 .text EXIImmEx */ // needs compiler lmw/lwz order patch #ifdef NONMATCHING -BOOL EXIImmEx(s32 chan, void* buf, s32 len, u32 mode) { +s32 EXIImmEx(s32 chan, void* buf, s32 len, u32 mode) { s32 xLen; while (len) { diff --git a/libs/dolphin/exi/Makefile b/libs/dolphin/exi/Makefile index b41c1824947..ebed15640c5 100644 --- a/libs/dolphin/exi/Makefile +++ b/libs/dolphin/exi/Makefile @@ -38,4 +38,6 @@ $(BUILD_DIR)/libs/dolphin/exi/%.o: libs/dolphin/exi/%.c @echo building... $< @$(ICONV) -f UTF-8 -t CP932 < $< > $(basename $@).c @$(WINE) tools/mwcc_compiler/1.2.5/mwcceppc.exe $(LIBEXI_A_CFLAGS) -c -o $@ $(basename $@).c + @echo Frank is fixing $@ + @$(PYTHON) $(FRANK) $@ $@ $@ diff --git a/libs/dolphin/gd/Makefile b/libs/dolphin/gd/Makefile index d82b1e7c291..83c2cfe71cc 100644 --- a/libs/dolphin/gd/Makefile +++ b/libs/dolphin/gd/Makefile @@ -38,4 +38,6 @@ $(BUILD_DIR)/libs/dolphin/gd/%.o: libs/dolphin/gd/%.c @echo building... $< @$(ICONV) -f UTF-8 -t CP932 < $< > $(basename $@).c @$(WINE) tools/mwcc_compiler/1.2.5/mwcceppc.exe $(LIBGD_A_CFLAGS) -c -o $@ $(basename $@).c + @echo Frank is fixing $@ + @$(PYTHON) $(FRANK) $@ $@ $@ diff --git a/libs/dolphin/gx/Makefile b/libs/dolphin/gx/Makefile index 0f00f994e33..3278a71f3d0 100644 --- a/libs/dolphin/gx/Makefile +++ b/libs/dolphin/gx/Makefile @@ -54,4 +54,6 @@ $(BUILD_DIR)/libs/dolphin/gx/%.o: libs/dolphin/gx/%.c @echo building... $< @$(ICONV) -f UTF-8 -t CP932 < $< > $(basename $@).c @$(WINE) tools/mwcc_compiler/1.2.5/mwcceppc.exe $(CFLAGS) $(LIBGX_A_CFLAGS) -c -o $@ $(basename $@).c + @echo Frank is fixing $@ + @$(PYTHON) $(FRANK) $@ $@ $@ diff --git a/libs/dolphin/mtx/Makefile b/libs/dolphin/mtx/Makefile index 65c6ad64d1e..3262e3e80d0 100644 --- a/libs/dolphin/mtx/Makefile +++ b/libs/dolphin/mtx/Makefile @@ -36,4 +36,6 @@ $(BUILD_DIR)/libs/dolphin/mtx/%.o: libs/dolphin/mtx/%.c @echo building... $< @$(ICONV) -f UTF-8 -t CP932 < $< > $(basename $@).c @$(WINE) tools/mwcc_compiler/1.2.5/mwcceppc.exe $(CFLAGS) $(LIBMTX_A_CFLAGS) -c -o $@ $(basename $@).c + @echo Frank is fixing $@ + @$(PYTHON) $(FRANK) $@ $@ $@ diff --git a/libs/dolphin/os/Makefile b/libs/dolphin/os/Makefile index 7341c22bc03..b757133808a 100644 --- a/libs/dolphin/os/Makefile +++ b/libs/dolphin/os/Makefile @@ -80,4 +80,6 @@ $(BUILD_DIR)/libs/dolphin/os/%.o: libs/dolphin/os/%.c @echo building... $< @$(ICONV) -f UTF-8 -t CP932 < $< > $(basename $@).c @$(WINE) tools/mwcc_compiler/1.2.5/mwcceppc.exe $(LIBOS_A_CFLAGS) -c -o $@ $(basename $@).c + @echo Frank is fixing $@ + @$(PYTHON) $(FRANK) $@ $@ $@ diff --git a/libs/dolphin/os/OSAlarm.c b/libs/dolphin/os/OSAlarm.c index ff0cf845299..5a43e591644 100644 --- a/libs/dolphin/os/OSAlarm.c +++ b/libs/dolphin/os/OSAlarm.c @@ -130,8 +130,6 @@ void OSSetPeriodicAlarm(OSAlarm* alarm, OSTime start, OSTime period, OSAlarmHand } /* 8033AC3C-8033AD58 33557C 011C+00 1/1 11/11 0/0 .text OSCancelAlarm */ -// need compiler epilogue patch -#ifdef NONMATCHING void OSCancelAlarm(OSAlarm* alarm) { OSAlarm* next; BOOL enabled; @@ -161,20 +159,8 @@ void OSCancelAlarm(OSAlarm* alarm) { OSRestoreInterrupts(enabled); } -#else -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void OSCancelAlarm(OSAlarm* alarm) { - nofralloc -#include "asm/dolphin/os/OSAlarm/OSCancelAlarm.s" -} -#pragma pop -#endif /* 8033AD58-8033AF88 335698 0230+00 1/1 0/0 0/0 .text DecrementerExceptionCallback */ -// need compiler epilogue patch -#ifdef NONMATCHING static void DecrementerExceptionCallback(register __OSException exception, register OSContext* context) { OSAlarm* alarm; @@ -221,16 +207,6 @@ static void DecrementerExceptionCallback(register __OSException exception, __OSReschedule(); OSLoadContext(context); } -#else -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -static asm void DecrementerExceptionCallback(__OSException exception, OSContext* context) { - nofralloc -#include "asm/dolphin/os/OSAlarm/DecrementerExceptionCallback.s" -} -#pragma pop -#endif /* 8033AF88-8033AFD8 3358C8 0050+00 1/1 0/0 0/0 .text DecrementerExceptionHandler */ static asm void DecrementerExceptionHandler(register __OSException exception, diff --git a/libs/dolphin/os/OSAudioSystem.c b/libs/dolphin/os/OSAudioSystem.c index 37ebe8a59f2..e431a1327a9 100644 --- a/libs/dolphin/os/OSAudioSystem.c +++ b/libs/dolphin/os/OSAudioSystem.c @@ -96,7 +96,6 @@ void __OSInitAudioSystem(void) { } /* 8033B494-8033B56C 335DD4 00D8+00 0/0 1/1 0/0 .text __OSStopAudioSystem */ -#ifdef NONMATCHING void __OSStopAudioSystem(void) { u32 r28; @@ -124,13 +123,3 @@ void __OSStopAudioSystem(void) { #undef waitUntil } -#else -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void __OSStopAudioSystem(void) { - nofralloc -#include "asm/dolphin/os/OSAudioSystem/__OSStopAudioSystem.s" -} -#pragma pop -#endif diff --git a/libs/dolphin/os/OSCache.c b/libs/dolphin/os/OSCache.c index 8b7b018f4cf..35290c9ac4c 100644 --- a/libs/dolphin/os/OSCache.c +++ b/libs/dolphin/os/OSCache.c @@ -351,8 +351,6 @@ static asm void LCStoreBlocks(register void* destAddr, register void* srcAddr, // clang-format on } /* 8033B838-8033B8E4 336178 00AC+00 0/0 0/0 3/3 .text LCStoreData */ -// matches with mwcc 1.2.5e -#ifdef NONMATCHING u32 LCStoreData(void* destAddr, void* srcAddr, u32 nBytes) { u32 blocks = (nBytes + 31) / 32; u32 ret = (blocks + 127) / 128; @@ -372,16 +370,6 @@ u32 LCStoreData(void* destAddr, void* srcAddr, u32 nBytes) { return ret; } -#else -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm u32 LCStoreData(void* destAddr, void* srcAddr, u32 nBytes) { - nofralloc -#include "asm/dolphin/os/OSCache/LCStoreData.s" -} -#pragma pop -#endif /* 8033B8E4-8033B8F8 336224 0014+00 0/0 0/0 3/3 .text LCQueueWait */ asm void LCQueueWait(register u32 len){ diff --git a/libs/dolphin/os/OSInterrupt.c b/libs/dolphin/os/OSInterrupt.c index 10d1d807e68..e86ded77fae 100644 --- a/libs/dolphin/os/OSInterrupt.c +++ b/libs/dolphin/os/OSInterrupt.c @@ -256,8 +256,6 @@ u32 SetInterruptMask(OSInterruptMask mask, OSInterruptMask current) { } /* 8033DABC-8033DB44 3383FC 0088+00 1/1 15/15 0/0 .text __OSMaskInterrupts */ -// need compiler epilogue patch -#ifdef NONMATCHING OSInterruptMask __OSMaskInterrupts(OSInterruptMask global) { BOOL enabled; OSInterruptMask prev; @@ -276,20 +274,8 @@ OSInterruptMask __OSMaskInterrupts(OSInterruptMask global) { OSRestoreInterrupts(enabled); return prev; } -#else -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm OSInterruptMask __OSMaskInterrupts(OSInterruptMask mask) { - nofralloc -#include "asm/dolphin/os/OSInterrupt/__OSMaskInterrupts.s" -} -#pragma pop -#endif /* 8033DB44-8033DBCC 338484 0088+00 0/0 18/18 0/0 .text __OSUnmaskInterrupts */ -// need compiler epilogue patch -#ifdef NONMATCHING OSInterruptMask __OSUnmaskInterrupts(OSInterruptMask global) { BOOL enabled; OSInterruptMask prev; @@ -308,16 +294,6 @@ OSInterruptMask __OSUnmaskInterrupts(OSInterruptMask global) { OSRestoreInterrupts(enabled); return prev; } -#else -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm OSInterruptMask __OSUnmaskInterrupts(OSInterruptMask mask) { - nofralloc -#include "asm/dolphin/os/OSInterrupt/__OSUnmaskInterrupts.s" -} -#pragma pop -#endif /* ############################################################################################## */ /* 803D0758-803D0788 02D878 002C+04 1/1 0/0 0/0 .data InterruptPrioTable */ diff --git a/libs/dolphin/os/OSMessage.c b/libs/dolphin/os/OSMessage.c index 0759648ac58..620eebb01e1 100644 --- a/libs/dolphin/os/OSMessage.c +++ b/libs/dolphin/os/OSMessage.c @@ -22,8 +22,6 @@ void OSInitMessageQueue(OSMessageQueue* mq, OSMessage* msgArray, s32 msgCount) { } /* 8033E9F4-8033EABC 339334 00C8+00 0/0 21/21 9/9 .text OSSendMessage */ -// needs compiler epilogue patch -#ifdef NONMATCHING BOOL OSSendMessage(OSMessageQueue* mq, OSMessage msg, s32 flags) { BOOL enabled; s32 lastIndex; @@ -48,20 +46,8 @@ BOOL OSSendMessage(OSMessageQueue* mq, OSMessage msg, s32 flags) { OSRestoreInterrupts(enabled); return TRUE; } -#else -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm BOOL OSSendMessage(OSMessageQueue* queue, OSMessage msg, s32 flags) { - nofralloc -#include "asm/dolphin/os/OSMessage/OSSendMessage.s" -} -#pragma pop -#endif /* 8033EABC-8033EB98 3393FC 00DC+00 0/0 15/15 9/9 .text OSReceiveMessage */ -// needs compiler epilogue patch -#ifdef NONMATCHING BOOL OSReceiveMessage(OSMessageQueue* mq, OSMessage* msg, s32 flags) { BOOL enabled; @@ -87,16 +73,6 @@ BOOL OSReceiveMessage(OSMessageQueue* mq, OSMessage* msg, s32 flags) { OSRestoreInterrupts(enabled); return TRUE; } -#else -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm BOOL OSReceiveMessage(OSMessageQueue* queue, OSMessage* msg, s32 flags) { - nofralloc -#include "asm/dolphin/os/OSMessage/OSReceiveMessage.s" -} -#pragma pop -#endif /* 8033EB98-8033EC6C 3394D8 00D4+00 0/0 1/1 0/0 .text OSJamMessage */ #pragma push diff --git a/libs/dolphin/os/OSRtc.c b/libs/dolphin/os/OSRtc.c index 9e10d56335f..6e2195bd55a 100644 --- a/libs/dolphin/os/OSRtc.c +++ b/libs/dolphin/os/OSRtc.c @@ -21,24 +21,12 @@ static BOOL UnlockSram(BOOL commit, u32 offset); static SramControlBlock Scb ALIGN_DECL(32); /* 8033FE90-8033FEF0 33A7D0 0060+00 2/2 0/0 0/0 .text WriteSramCallback */ -// needs compiler epilogue patch -#ifdef NONMATCHING static void WriteSramCallback(s32 chan, OSContext* context) { Scb.sync = WriteSram(Scb.sram + Scb.offset, Scb.offset, RTC_SRAM_SIZE - Scb.offset); if (Scb.sync) { Scb.offset = RTC_SRAM_SIZE; } } -#else -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -static asm void WriteSramCallback(s32 chan, OSContext* context) { - nofralloc -#include "asm/dolphin/os/OSRtc/WriteSramCallback.s" -} -#pragma pop -#endif static inline BOOL ReadSram(void* buffer) { BOOL err; @@ -67,8 +55,6 @@ static inline BOOL ReadSram(void* buffer) { } /* 8033FEF0-80340008 33A830 0118+00 1/1 0/0 0/0 .text WriteSram */ -// needs compiler epilogue patch -#ifdef NONMATCHING BOOL WriteSram(void* buffer, u32 offset, u32 size) { BOOL err; u32 cmd; @@ -92,36 +78,14 @@ BOOL WriteSram(void* buffer, u32 offset, u32 size) { return !err; } -#else -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -static asm BOOL WriteSram(void* buffer, u32 offset, u32 size) { - nofralloc -#include "asm/dolphin/os/OSRtc/WriteSram.s" -} -#pragma pop -#endif /* 80340008-80340144 33A948 013C+00 0/0 1/1 0/0 .text __OSInitSram */ -// needs compiler epilogue patch -#ifdef NONMATCHING void __OSInitSram(void) { Scb.locked = Scb.enabled = FALSE; Scb.sync = ReadSram(Scb.sram); Scb.offset = RTC_SRAM_SIZE; OSSetGbsMode(OSGetGbsMode()); } -#else -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void __OSInitSram(void) { - nofralloc -#include "asm/dolphin/os/OSRtc/__OSInitSram.s" -} -#pragma pop -#endif /* 80340144-803401A0 33AA84 005C+00 0/0 3/3 0/0 .text __OSLockSram */ #pragma push diff --git a/libs/dolphin/os/OSTime.c b/libs/dolphin/os/OSTime.c index 3193a01a7f9..3e2abdf929e 100644 --- a/libs/dolphin/os/OSTime.c +++ b/libs/dolphin/os/OSTime.c @@ -52,8 +52,6 @@ asm OSTick OSGetTick(void) { #define OS_SYSTEMTIME_BASE 0x30D8 /* 8034271C-80342780 33D05C 0064+00 0/0 16/16 0/0 .text __OSGetSystemTime */ -// needs compiler epilogue patch -#ifdef NONMATCHING OSTime __OSGetSystemTime(void) { BOOL enabled; OSTime* timeAdjustAddr = (OSTime*)(OS_BASE_CACHED + OS_SYSTEMTIME_BASE); @@ -65,20 +63,8 @@ OSTime __OSGetSystemTime(void) { return result; } -#else -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm OSTime __OSGetSystemTime(void) { - nofralloc -#include "asm/dolphin/os/OSTime/__OSGetSystemTime.s" -} -#pragma pop -#endif /* 80342780-803427D8 33D0C0 0058+00 0/0 1/1 0/0 .text __OSTimeToSystemTime */ -// needs compiler epilogue patch -#ifdef NONMATCHING OSTime __OSTimeToSystemTime(OSTime time) { BOOL enabled; OSTime* timeAdjustAddr = (OSTime*)(OS_BASE_CACHED + OS_SYSTEMTIME_BASE); @@ -90,16 +76,6 @@ OSTime __OSTimeToSystemTime(OSTime time) { return result; } -#else -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm OSTime __OSTimeToSystemTime(OSTime time) { - nofralloc -#include "asm/dolphin/os/OSTime/__OSTimeToSystemTime.s" -} -#pragma pop -#endif /* ############################################################################################## */ /* 803D1048-803D1078 02E168 0030+00 1/1 0/0 0/0 .data YearDays */ diff --git a/libs/dolphin/pad/Makefile b/libs/dolphin/pad/Makefile index 35c76f5386b..27f49a6db12 100644 --- a/libs/dolphin/pad/Makefile +++ b/libs/dolphin/pad/Makefile @@ -38,4 +38,6 @@ $(BUILD_DIR)/libs/dolphin/pad/%.o: libs/dolphin/pad/%.c @echo building... $< @$(ICONV) -f UTF-8 -t CP932 < $< > $(basename $@).c @$(WINE) tools/mwcc_compiler/1.2.5/mwcceppc.exe $(LIBPAD_A_CFLAGS) -c -o $@ $(basename $@).c + @echo Frank is fixing $@ + @$(PYTHON) $(FRANK) $@ $@ $@ diff --git a/libs/dolphin/pad/Pad.c b/libs/dolphin/pad/Pad.c index fce1c3f0507..535eba9da4f 100644 --- a/libs/dolphin/pad/Pad.c +++ b/libs/dolphin/pad/Pad.c @@ -184,8 +184,6 @@ inline void PADDisable(s32 chan) { } /* 8034E51C-8034E5E8 348E5C 00CC+00 2/2 0/0 0/0 .text PADOriginUpdateCallback */ -// needs compiler epilogue patch -#ifdef NONMATCHING static void PADOriginUpdateCallback(s32 chan, u32 error, OSContext* context) { if (!(EnabledBits & ((u32)PAD_CHAN0_BIT >> chan))) { return; @@ -200,20 +198,8 @@ static void PADOriginUpdateCallback(s32 chan, u32 error, OSContext* context) { PADDisable(chan); } } -#else -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -static asm void PADOriginUpdateCallback(s32 chan, u32 error, OSContext* context) { - nofralloc -#include "asm/dolphin/pad/Pad/PADOriginUpdateCallback.s" -} -#pragma pop -#endif /* 8034E5E8-8034E6C0 348F28 00D8+00 1/1 0/0 0/0 .text PADProbeCallback */ -// needs compiler epilogue patch -#ifdef NONMATCHING static void PADProbeCallback(s32 chan, u32 error, OSContext* context) { if (!(error & (SI_ERROR_UNDER_RUN | SI_ERROR_OVER_RUN | SI_ERROR_NO_RESPONSE | SI_ERROR_COLLISION))) { @@ -222,16 +208,6 @@ static void PADProbeCallback(s32 chan, u32 error, OSContext* context) { } DoReset(); } -#else -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -static asm void PADProbeCallback(s32 chan, u32 error, OSContext* context) { - nofralloc -#include "asm/dolphin/pad/Pad/PADProbeCallback.s" -} -#pragma pop -#endif /* ############################################################################################## */ /* 80450A30-80450A34 0004B0 0004+00 4/4 0/0 0/0 .sdata Spec */ @@ -253,8 +229,6 @@ static u32 CmdProbeDevice[4]; #pragma pop /* 8034E6C0-8034E9EC 349000 032C+00 4/4 0/0 0/0 .text PADTypeAndStatusCallback */ -// needs compiler epilogue patch -#ifdef NONMATCHING static void PADTypeAndStatusCallback(s32 chan, u32 type) { u32 chanBit; u32 recalibrate; @@ -310,16 +284,6 @@ static void PADTypeAndStatusCallback(s32 chan, u32 type) { return; } } -#else -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -static asm void PADTypeAndStatusCallback(s32 chan, u32 type) { - nofralloc -#include "asm/dolphin/pad/Pad/PADTypeAndStatusCallback.s" -} -#pragma pop -#endif /* 8034E9EC-8034EB2C 34932C 0140+00 1/1 0/0 0/0 .text PADReceiveCheckCallback */ #pragma push diff --git a/libs/dolphin/pad/Padclamp.c b/libs/dolphin/pad/Padclamp.c index 656f1dc8f45..a2051d8b6b5 100644 --- a/libs/dolphin/pad/Padclamp.c +++ b/libs/dolphin/pad/Padclamp.c @@ -135,8 +135,6 @@ inline void ClampTrigger(u8* trigger, u8 min, u8 max) { } /* 8034E094-8034E1A8 3489D4 0114+00 0/0 1/1 0/0 .text PADClamp */ -// needs compiler epilogue patch -#ifdef NONMATCHING void PADClamp(PADStatus* status) { int i; for (i = 0; i < 4; i++, status++) { @@ -152,22 +150,10 @@ void PADClamp(PADStatus* status) { ClampTrigger(&status->trigger_right, ClampRegion.minTrigger, ClampRegion.maxTrigger); } } -#else -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void PADClamp(PADStatus* status) { - nofralloc -#include "asm/dolphin/pad/Padclamp/PADClamp.s" -} -#pragma pop -#endif /* 8034E1A8-8034E2B4 348AE8 010C+00 0/0 1/1 0/0 .text PADClampCircle */ -// needs compiler epilogue patch -#ifdef NONMATCHING void PADClampCircle(PADStatus* status) { - u32 i; + int i; for (i = 0; i < 4; ++i, status++) { if (status->error != PAD_ERR_NONE) { continue; @@ -180,13 +166,3 @@ void PADClampCircle(PADStatus* status) { ClampTrigger(&status->trigger_right, ClampRegion.minTrigger, ClampRegion.maxTrigger); } } -#else -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void PADClampCircle(PADStatus* status) { - nofralloc -#include "asm/dolphin/pad/Padclamp/PADClampCircle.s" -} -#pragma pop -#endif diff --git a/libs/dolphin/si/Makefile b/libs/dolphin/si/Makefile index b67c0170578..31460266071 100644 --- a/libs/dolphin/si/Makefile +++ b/libs/dolphin/si/Makefile @@ -38,4 +38,6 @@ $(BUILD_DIR)/libs/dolphin/si/%.o: libs/dolphin/si/%.c @echo building... $< @$(ICONV) -f UTF-8 -t CP932 < $< > $(basename $@).c @$(WINE) tools/mwcc_compiler/1.2.5/mwcceppc.exe $(LIBSI_A_CFLAGS) -c -o $@ $(basename $@).c + @echo Frank is fixing $@ + @$(PYTHON) $(FRANK) $@ $@ $@ diff --git a/libs/dolphin/si/SIBios.c b/libs/dolphin/si/SIBios.c index 0267d771c27..af28da30bbc 100644 --- a/libs/dolphin/si/SIBios.c +++ b/libs/dolphin/si/SIBios.c @@ -83,8 +83,6 @@ static inline void SIClearTCInterrupt() { } /* 80344BFC-80344EF8 33F53C 02FC+00 1/1 0/0 0/0 .text CompleteTransfer */ -// needs compiler epilogue patch -#ifdef NONMATCHING static u32 CompleteTransfer() { u32 sr; u32 i; @@ -133,16 +131,6 @@ static u32 CompleteTransfer() { } return sr; } -#else -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -static asm u32 CompleteTransfer(void) { - nofralloc -#include "asm/dolphin/si/SIBios/CompleteTransfer.s" -} -#pragma pop -#endif /* ############################################################################################## */ /* 8044C790-8044C7D0 0794B0 0040+00 1/1 0/0 0/0 .bss TypeCallback */ @@ -271,7 +259,7 @@ static asm void SIInterruptHandler(OSInterrupt interrupt, OSContext* context) { #endif /* 8034523C-803452D4 33FB7C 0098+00 2/2 0/0 0/0 .text SIEnablePollingInterrupt */ -// needs compiler epilogue patch +// lwz and mr swapped #ifdef NONMATCHING static BOOL SIEnablePollingInterrupt(BOOL enable) { BOOL enabled; @@ -307,9 +295,7 @@ static asm BOOL SIEnablePollingInterrupt(BOOL enable) { #endif /* 803452D4-803453A0 33FC14 00CC+00 0/0 1/1 0/0 .text SIRegisterPollingHandler */ -// needs compiler epilogue patch -#ifdef NONMATCHING -BOOL SIRegisterPollingHandler(__OSInterruptHandler handler) { +BOOL SIRegisterPollingHandler(OSInterruptHandler handler) { BOOL enabled; int i; @@ -331,20 +317,8 @@ BOOL SIRegisterPollingHandler(__OSInterruptHandler handler) { OSRestoreInterrupts(enabled); return FALSE; } -#else -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm BOOL SIRegisterPollingHandler(OSInterruptHandler handler) { - nofralloc -#include "asm/dolphin/si/SIBios/SIRegisterPollingHandler.s" -} -#pragma pop -#endif /* 803453A0-80345494 33FCE0 00F4+00 0/0 1/1 0/0 .text SIUnregisterPollingHandler */ -// needs compiler epilogue patch -#ifdef NONMATCHING BOOL SIUnregisterPollingHandler(OSInterruptHandler handler) { BOOL enabled; int i; @@ -369,16 +343,6 @@ BOOL SIUnregisterPollingHandler(OSInterruptHandler handler) { OSRestoreInterrupts(enabled); return FALSE; } -#else -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm BOOL SIUnregisterPollingHandler(OSInterruptHandler handler) { - nofralloc -#include "asm/dolphin/si/SIBios/SIUnregisterPollingHandler.s" -} -#pragma pop -#endif /* 80345494-80345548 33FDD4 00B4+00 0/0 1/1 0/0 .text SIInit */ void SIInit(void) { @@ -449,7 +413,7 @@ static BOOL __SITransfer(s32 chan, void* output, u32 outputBytes, void* input, u } /* 80345754-803457D0 340094 007C+00 1/1 1/1 0/0 .text SIGetStatus */ -// needs compiler epilogue patch +// lwz and mr swap #ifdef NONMATCHING u32 SIGetStatus(s32 chan) { BOOL enabled; diff --git a/libs/dolphin/vi/Makefile b/libs/dolphin/vi/Makefile index a196a51ffaf..b59f0351ac9 100644 --- a/libs/dolphin/vi/Makefile +++ b/libs/dolphin/vi/Makefile @@ -36,4 +36,6 @@ $(BUILD_DIR)/libs/dolphin/vi/%.o: libs/dolphin/vi/%.c @echo building... $< @$(ICONV) -f UTF-8 -t CP932 < $< > $(basename $@).c @$(WINE) tools/mwcc_compiler/1.2.5/mwcceppc.exe $(LIBVI_A_CFLAGS) -c -o $@ $(basename $@).c + @echo Frank is fixing $@ + @$(PYTHON) $(FRANK) $@ $@ $@ diff --git a/tools/frank.py b/tools/frank.py new file mode 100644 index 00000000000..2165b0b6658 --- /dev/null +++ b/tools/frank.py @@ -0,0 +1,213 @@ +#! /usr/bin/env python3 + +# Written by Ethan Roseman (ethteck) +# MIT License +# Copyright 2021 + +# Modified by EpochFlame + +import argparse +import sys + +# Byte sequence that marks code size +CODESIZE_MAGIC = b"\x00\x00\x00\x06\x00\x00\x00\x00\x00\x00\x00\x34" +BLR_BYTE_SEQ = b"\x4E\x80\x00\x20" +MTLR_BYTE_SEQ = b"\x7C\x08\x03\xA6" +PROFILE_EXTRA_BYTES = b"\x48\x00\x00\x01\x60\x00\x00\x00" + +LWZ_BYTE = b"\x80" + +# Byte sequence array for branches to link register +BLR_BYTE_SEQ_ARRAY = [BLR_BYTE_SEQ, +b"\x4D\x80\x00\x20", b"\x4D\x80\x00\x21", b"\x4C\x81\x00\x20", b"\x4C\x81\x00\x21", +b"\x4D\x82\x00\x20", b"\x4D\x82\x00\x21", b"\x4C\x80\x00\x20", b"\x4C\x80\x00\x21", +b"\x4D\x81\x00\x20", b"\x4D\x81\x00\x21", b"\x4C\x80\x00\x20", b"\x4C\x80\x00\x21", +b"\x4C\x82\x00\x20", b"\x4C\x82\x00\x21", b"\x4C\x81\x00\x20", b"\x4C\x81\x00\x21", +b"\x4D\x83\x00\x20", b"\x4D\x83\x00\x21", b"\x4C\x83\x00\x20", b"\x4C\x83\x00\x21", +b"\x4D\x83\x00\x20", b"\x4D\x83\x00\x21", b"\x4C\x83\x00\x20", b"\x4C\x83\x00\x21"] + +# Example invocation: ./frank.py vanilla.o profile.o output.o +parser = argparse.ArgumentParser() +parser.add_argument("vanilla", help="Path to the vanilla object", type=argparse.FileType('rb')) +parser.add_argument("profile", help="Path to the profile object", type=argparse.FileType('rb')) +parser.add_argument("target", help="Path to the target object (to write)") + +args = parser.parse_args() + +# Read contents into bytearrays and close files +vanilla_bytes = args.vanilla.read() +args.vanilla.close() + +# If the file contains no code, the codesize magic will not be found. +# The vanilla object requires no modification. +code_size_magic_idx = vanilla_bytes.find(CODESIZE_MAGIC) +if code_size_magic_idx == -1: + with open(args.target, "wb") as f: + f.write(vanilla_bytes) + sys.exit(0) + +profile_bytes = args.profile.read() +args.profile.close() + +# Peephole rescheduling +# +# This is the pattern we will detect: +# (A) lwz <--. .--> (A) li +# (B) li <---\-' bl +# \ nop +# '---> (B) lwz +# +# If the profiled schedule swaps the +# instructions around the bl/nop, we +# instead use the vanilla schedule. +# +idx = 8 +shift = 0 # difference between vanilla and profile code, due to bl/nops +while idx < len(profile_bytes) - 16: + # Find next epilogue + epi_pos = profile_bytes.find(PROFILE_EXTRA_BYTES, idx) + if epi_pos == -1: + break # break while loop when no targets remain + if epi_pos % 4 != 0: # check 4-byte alignment + idx += 4 + continue + + v_pos = epi_pos - shift + shift += 8 + + vanilla_inst_a = vanilla_bytes[v_pos-4:v_pos] + vanilla_inst_b = vanilla_bytes[v_pos:v_pos+4] + vanilla_inst_c = vanilla_bytes[v_pos+4:v_pos+8] + profile_inst_a = profile_bytes[epi_pos-4:epi_pos] + profile_inst_b = profile_bytes[epi_pos+8:epi_pos+12] + profile_inst_c = profile_bytes[epi_pos+12:epi_pos+16] + + opcode_a = vanilla_inst_a[0] >> 2 + opcode_b = vanilla_inst_b[0] >> 2 + opcode_c = vanilla_inst_c[0] >> 2 + + LWZ = 0x80 >> 2 + LFS = 0xC0 >> 2 + ADDI = 0x38 >> 2 + LI = ADDI # an LI instruction is just an ADDI with RA=0 + LMW = 0xB8 >> 2 + + if opcode_a == LWZ and \ + opcode_b in [LI, LFS] and \ + vanilla_inst_a == profile_inst_b and \ + vanilla_inst_b == profile_inst_a and \ + vanilla_inst_c == profile_inst_c and \ + opcode_c != ADDI: # <- don't reorder if at the very end of the epilogue + + # Swap instructions (A) and (B) + profile_bytes = profile_bytes[:epi_pos-4] \ + + vanilla_inst_a \ + + PROFILE_EXTRA_BYTES \ + + vanilla_inst_b \ + + profile_bytes[epi_pos+12:] + + # Similar reordering for lwz/lmw, except both insns follow the bl/nop + elif opcode_b == LWZ and \ + opcode_c == LMW and \ + vanilla_inst_b == profile_inst_c and \ + vanilla_inst_c == profile_inst_b: + + profile_bytes = profile_bytes[:epi_pos+8] \ + + vanilla_inst_b \ + + vanilla_inst_c \ + + profile_bytes[epi_pos+16:] + + idx = epi_pos + 8 + +# Remove byte sequence +stripped_bytes = profile_bytes.replace(PROFILE_EXTRA_BYTES, b"") + +# Find end of code sections in vanilla and stripped bytes +code_size_offset = code_size_magic_idx + len(CODESIZE_MAGIC) +code_size_bytes = vanilla_bytes[code_size_offset:code_size_offset+4] +code_size = int.from_bytes(code_size_bytes, byteorder='big') + +eoc_offset = 0x34 + code_size + +# Break if the eoc is not found +assert(eoc_offset != len(vanilla_bytes)) + +# Replace 0x34 - eoc in vanilla with bytes from stripped +final_bytes = vanilla_bytes[:0x34] + stripped_bytes[0x34:eoc_offset] + vanilla_bytes[eoc_offset:] + +# Fix branches to link register +for seq in BLR_BYTE_SEQ_ARRAY: + idx = 0 + + while idx < len(vanilla_bytes): + found_pos = vanilla_bytes.find(seq, idx) + if found_pos == -1: + break # break while loop when no targets remain + if found_pos % 4 != 0: # check 4-byte alignment + idx += 4 + continue + final_bytes = final_bytes[:found_pos] + vanilla_bytes[found_pos:found_pos+4] + final_bytes[found_pos+4:] + idx = found_pos + len(seq) + +# Reunify mtlr/blr instructions, shifting intermediary instructions up +idx = 0 + +while idx < len(final_bytes): + # Find mtlr position + mtlr_found_pos = final_bytes.find(MTLR_BYTE_SEQ, idx) + if mtlr_found_pos == -1: + break # break while loop when no targets remain + if mtlr_found_pos % 4 != 0: # check 4-byte alignment + idx += 4 + continue + # Find paired blr position + blr_found_pos = final_bytes.find(BLR_BYTE_SEQ, mtlr_found_pos) + if blr_found_pos == -1: + break # break while loop when no targets remain + if blr_found_pos % 4 != 0: # check 4-byte alignment + idx += 4 + continue + if mtlr_found_pos + 4 == blr_found_pos: + idx += 4 + continue # continue if mtlr is followed directly by blr + + final_bytes = final_bytes[:mtlr_found_pos] + final_bytes[mtlr_found_pos+4:blr_found_pos] + final_bytes[mtlr_found_pos:mtlr_found_pos+4] + final_bytes[blr_found_pos:] + idx = mtlr_found_pos + len(MTLR_BYTE_SEQ) + +# Reorder lmw/lwz/lfd instructions, if needed (@Altafen) +# Specifically, if this sequence shows up in the stripped profiler code: "LMW, LWZ, LFD*" +# And this sequence shows up in the vanilla code: "LWZ, LFD*, LMW" +# (LFD* = any number of LFDs, including zero) +# If all bytes match between the two (except for the reordering), then use the vanilla ordering. +# This could be written to anchor around the "BL, NOP" instructions in unstripped profiler code, +# or to check for the presence of "ADDI, MTLR, BLR" soon after. +# This also could be written to decode the operands of each instruction to make sure the reorder is harmless. +# Neither of these safeguards are necessary at the moment. +LWZ = 32 +LMW = 46 +LFD = 50 +idx = 0 +while idx+4 < len(final_bytes): + if final_bytes[idx] >> 2 == LMW and final_bytes[idx+4] >> 2 == LWZ and vanilla_bytes[idx] >> 2 == LWZ: + start_idx = idx + lmw_bytes = final_bytes[idx:idx+4] + lwz_bytes = final_bytes[idx+4:idx+8] + if vanilla_bytes[idx:idx+4] != lwz_bytes: + idx += 4 + continue + lfd_bytes = b"" + idx += 4 + while vanilla_bytes[idx] >> 2 == LFD: + lfd_bytes += vanilla_bytes[idx:idx+4] + idx += 4 + if vanilla_bytes[idx:idx+4] != lmw_bytes: + continue + if final_bytes[start_idx+8:start_idx+8+len(lfd_bytes)] != lfd_bytes: + continue + idx += 4 + final_bytes = final_bytes[:start_idx] + lwz_bytes + lfd_bytes + lmw_bytes + final_bytes[idx:] + continue + idx += 4 + +with open(args.target, "wb") as f: + f.write(final_bytes) \ No newline at end of file