papermario/src/code_25f00_len_940.c

92 lines
2.1 KiB
C
Raw Normal View History

2020-08-04 08:49:11 +02:00
#include "common.h"
2020-12-09 23:53:35 +01:00
#include "nu/nusys.h"
#include "nu/nualsgi.h"
2020-08-04 08:49:11 +02:00
2020-12-10 07:39:32 +01:00
extern NUDMAState nuAuDmaState;
extern s32 nuAuDmaNext;
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_25f00_len_940", func_8004AB00);
2020-08-04 08:49:11 +02:00
2020-12-09 23:53:35 +01:00
void nuAuPreNMIFuncSet(NUAuPreNMIFunc func) {
OSIntMask mask = osSetIntMask(OS_IM_NONE);
2020-12-08 11:50:14 +01:00
2020-12-09 23:53:35 +01:00
nuAuPreNMIFunc = func;
osSetIntMask(mask);
2020-12-08 11:50:14 +01:00
}
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_25f00_len_940", func_8004AE08);
2020-08-04 08:49:11 +02:00
2020-10-15 06:43:07 +02:00
INCLUDE_ASM(s32, "code_25f00_len_940", nuAuDmaCallBack);
2020-12-10 07:39:32 +01:00
ALDMAproc nuAuDmaNew(NUDMAState **state) {
if (!nuAuDmaState.initialized) {
nuAuDmaState.firstFree = &nuAuDmaBuf;
nuAuDmaState.firstUsed = NULL;
nuAuDmaState.initialized = TRUE;
}
nuAuDmaNext = 0;
*state = &nuAuDmaState;
return nuAuDmaCallBack;
}
2020-08-04 08:49:11 +02:00
2020-12-10 14:24:28 +01:00
// Some weird symbol loading shenanigans (addiu vs lw)
#ifdef NON_MATCHING
void nuAuCleanDMABuffers(void) {
NUDMABuffer* dmaPtr = nuAuDmaState.firstUsed;
NUDMABuffer* nextPtr;
while (dmaPtr != NULL) {
nextPtr = dmaPtr->node.next;
if (&nuAuDmaState) {
}
if (dmaPtr->frameCnt + 1 < nuAuFrameCounter) {
if (nuAuDmaState.firstUsed == dmaPtr) {
nuAuDmaState.firstUsed = nextPtr;
}
alUnlink(dmaPtr);
if (nuAuDmaState.firstFree != NULL) {
alLink(dmaPtr, nuAuDmaState.firstFree);
} else {
nuAuDmaState.firstFree = dmaPtr;
dmaPtr->node.next = NULL;
dmaPtr->node.prev = NULL;
}
}
dmaPtr = nextPtr;
}
nuAuDmaNext = 0;
nuAuFrameCounter += 1;
}
#else
2020-12-09 23:53:35 +01:00
INCLUDE_ASM(void, "code_25f00_len_940", nuAuCleanDMABuffers);
2020-12-10 14:24:28 +01:00
#endif
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_25f00_len_940", func_8004B328);
2020-09-24 05:16:13 +02:00
2020-11-06 01:37:31 +01:00
void alLink(ALLink* element, ALLink* after) {
2020-11-06 01:30:17 +01:00
element->next = after->next;
element->prev = after;
if (after->next != NULL) {
after->next->prev = element;
}
after->next = element;
}
2020-11-06 01:37:31 +01:00
void alUnlink(ALLink* element) {
2020-11-06 01:30:17 +01:00
if (element->next != NULL) {
element->next->prev = element->prev;
}
if (element->prev != NULL) {
element->prev->next = element->next;
}
}