Wrap nonmatching functions and link ai.c

Former-commit-id: 4737d6c9d3
This commit is contained in:
Phillip Stephens 2022-12-09 17:51:32 -08:00
parent d4c1747688
commit 4de93b4f68
3 changed files with 61 additions and 2 deletions

View File

@ -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],
],
},
{

View File

@ -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; }

View File

@ -833,5 +833,6 @@ lbl_80387664:
mtlr r0
blr
}
/* clang-format on */
#pragma pop
#endif