From d4c174768854ea6084e0b51275672adfa46682b9 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Fri, 9 Dec 2022 17:25:20 -0800 Subject: [PATCH] Wrap nonmatching functions in pad.c and link Former-commit-id: 219f534bfd78b976aba75173f0df2c439fb0e160 --- configure.py | 2 +- src/Dolphin/pad/pad.c | 83 +++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 82 insertions(+), 3 deletions(-) diff --git a/configure.py b/configure.py index 07b97fa9..27e265f9 100755 --- a/configure.py +++ b/configure.py @@ -834,7 +834,7 @@ LIBS = [ "host": False, "objects": [ ["Dolphin/pad/PadClamp", True], - ["Dolphin/pad/pad", False], + ["Dolphin/pad/pad", True], ], }, { diff --git a/src/Dolphin/pad/pad.c b/src/Dolphin/pad/pad.c index 287dde18..98c21a50 100644 --- a/src/Dolphin/pad/pad.c +++ b/src/Dolphin/pad/pad.c @@ -42,8 +42,8 @@ static void (*MakeStatus)(s32, PADStatus*, u32[2]) = SPEC2_MakeStatus; static u32 Type[SI_MAX_CHAN]; static PADStatus Origin[SI_MAX_CHAN]; -static u32 CmdReadOrigin = 41 << 24; -static u32 CmdCalibrate = 42 << 24; +static u32 CmdReadOrigin = 0x41 << 24; +static u32 CmdCalibrate = 0x42 << 24; static u32 CmdProbeDevice[SI_MAX_CHAN]; static BOOL OnReset(BOOL final); @@ -730,6 +730,7 @@ static void SamplingHandler(__OSInterrupt interrupt, OSContext* context) { } } +#if NONMATCHING PADSamplingCallback PADSetSamplingCallback(PADSamplingCallback callback) { PADSamplingCallback prev; @@ -742,7 +743,41 @@ PADSamplingCallback PADSetSamplingCallback(PADSamplingCallback callback) { } return prev; } +#else +/* clang-format off */ +#pragma push +#pragma optimization_level 0 +#pragma optimizewithasm off +asm PADSamplingCallback PADSetSamplingCallback(PADSamplingCallback callback) { + nofralloc + mflr r0 + cmplwi r3, 0 + stw r0, 4(r1) + stwu r1, -0x18(r1) + stw r31, 0x14(r1) + lwz r31, SamplingCallback + stw r3, SamplingCallback + beq lbl_803875E4 + lis r3, SamplingHandler@ha + addi r3, r3, SamplingHandler@l + bl SIRegisterPollingHandler + b lbl_803875F0 +lbl_803875E4: + lis r3, SamplingHandler@ha + addi r3, r3, SamplingHandler@l + bl SIUnregisterPollingHandler +lbl_803875F0: + mr r3, r31 + lwz r0, 0x1c(r1) + lwz r31, 0x14(r1) + addi r1, r1, 0x18 + mtlr r0 + blr +} +#pragma pop +#endif +#if NONMATCHING BOOL __PADDisableRecalibration(BOOL disable) { BOOL enabled; BOOL prev; @@ -756,3 +791,47 @@ BOOL __PADDisableRecalibration(BOOL disable) { OSRestoreInterrupts(enabled); return prev; } +#else +/* clang-format off */ +#pragma push +#pragma optimization_level 0 +#pragma optimizewithasm off +asm BOOL __PADDisableRecalibration(BOOL disable) { + nofralloc + mflr r0 + stw r0, 4(r1) + stwu r1, -0x18(r1) + stw r31, 0x14(r1) + stw r30, 0x10(r1) + mr r30, r3 + bl OSDisableInterrupts + lis r4, UnkVal@ha + lbz r0, UnkVal@l(r4) + rlwinm. r0, r0, 0, 0x19, 0x19 + beq lbl_8038763C + li r31, 1 + b lbl_80387640 +lbl_8038763C: + li r31, 0 +lbl_80387640: + lis r4, UnkVal@ha + lbz r0, UnkVal@l(r4) + andi. r0, r0, 0xbf + cmpwi r30, 0 + stb r0, UnkVal@l(r4) + beq lbl_80387664 + lbz r0, UnkVal@l(r4) + ori r0, r0, 0x40 + stb r0, UnkVal@l(r4) +lbl_80387664: + 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 +#endif