From 4de93b4f687d159ce7cc25f6fa6b8b8836c9e71c Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Fri, 9 Dec 2022 17:51:32 -0800 Subject: [PATCH] Wrap nonmatching functions and link ai.c Former-commit-id: 4737d6c9d32ce9c7f2303a4369bcba41c5cab5fc --- configure.py | 4 +-- src/Dolphin/ai.c | 58 +++++++++++++++++++++++++++++++++++++++++++ src/Dolphin/pad/pad.c | 1 + 3 files changed, 61 insertions(+), 2 deletions(-) diff --git a/configure.py b/configure.py index 27e265f9..e1a87be6 100755 --- a/configure.py +++ b/configure.py @@ -699,11 +699,11 @@ LIBS = [ }, { "lib": "ai", - "mwcc_version": "1.2.5", + "mwcc_version": "1.2.5e", "cflags": "$cflags_base", "host": False, "objects": [ - ["Dolphin/ai", False], + ["Dolphin/ai", True], ], }, { diff --git a/src/Dolphin/ai.c b/src/Dolphin/ai.c index 9d65b1ec..62e350a2 100644 --- a/src/Dolphin/ai.c +++ b/src/Dolphin/ai.c @@ -22,6 +22,7 @@ void __AIDHandler(s16 interrupt, OSContext* context); void __AICallbackStackSwitch(register AIDCallback cb); void __AI_SRC_INIT(void); +#if NONMATCHING AIDCallback AIRegisterDMACallback(AIDCallback callback) { s32 oldInts; AIDCallback ret; @@ -32,6 +33,34 @@ AIDCallback AIRegisterDMACallback(AIDCallback callback) { OSRestoreInterrupts(oldInts); return ret; } +#else +/* clang-format off */ +#pragma push +#pragma optimization_level 0 +#pragma optimizewithasm off +asm AIDCallback AIRegisterDMACallback(AIDCallback callback) { + nofralloc + mflr r0 + stw r0, 4(r1) + stwu r1, -0x18(r1) + stw r31, 0x14(r1) + stw r30, 0x10(r1) + mr r30, r3 + lwz r31, __AID_Callback + bl OSDisableInterrupts + stw r30, __AID_Callback + bl OSRestoreInterrupts + mr r3, r31 + lwz r0, 0x1c(r1) + lwz r31, 0x14(r1) + lwz r30, 0x10(r1) + addi r1, r1, 0x18 + mtlr r0 + blr +} +#pragma pop +/* clang-format on */ +#endif void AIInitDMA(u32 addr, u32 length) { s32 oldInts; @@ -50,6 +79,7 @@ u32 AIGetDMAStartAddr(void) { return (u32)((__DSPRegs[24] & 0x03ff) << 16) | (__DSPRegs[25] & 0xffe0); } +#if NONMATCHING AISCallback AIRegisterStreamCallback(AISCallback callback) { AISCallback ret; s32 oldInts; @@ -60,6 +90,34 @@ AISCallback AIRegisterStreamCallback(AISCallback callback) { OSRestoreInterrupts(oldInts); return ret; } +#else +/* clang-format off */ +#pragma push +#pragma optimization_level 0 +#pragma optimizewithasm off +asm AISCallback AIRegisterStreamCallback(AISCallback callback) { + nofralloc + mflr r0 + stw r0, 4(r1) + stwu r1, -0x18(r1) + stw r31, 0x14(r1) + stw r30, 0x10(r1) + mr r30, r3 + lwz r31, __AIS_Callback + bl OSDisableInterrupts + stw r30, __AIS_Callback + bl OSRestoreInterrupts + mr r3, r31 + lwz r0, 0x1c(r1) + lwz r31, 0x14(r1) + lwz r30, 0x10(r1) + addi r1, r1, 0x18 + mtlr r0 + blr +} +#pragma pop +/* clang-format on */ +#endif void AIResetStreamSampleCount(void) { __AIRegs[0] = (__AIRegs[0] & ~0x20) | 0x20; } diff --git a/src/Dolphin/pad/pad.c b/src/Dolphin/pad/pad.c index 98c21a50..4cbabe4d 100644 --- a/src/Dolphin/pad/pad.c +++ b/src/Dolphin/pad/pad.c @@ -833,5 +833,6 @@ lbl_80387664: mtlr r0 blr } +/* clang-format on */ #pragma pop #endif