marioparty4/src/TRK_MINNOW_DOLPHIN/mainloop.c
dbalatoni13 cdb1d1fc37
Import gx, PadClamp, rest of mtx, TRK 2.6 and MSL (#525)
* Match mtx and Padclamp.c

* Match the rest of GX

* Import TRK 2.6

* Import MSL headers and files

* Merge some MSL headers into ours
2025-01-12 08:11:23 -06:00

70 lines
1.4 KiB
C

#include "TRK_MINNOW_DOLPHIN/MetroTRK/Portable/serpoll.h"
#include "TRK_MINNOW_DOLPHIN/MetroTRK/Portable/msgbuf.h"
#include "TRK_MINNOW_DOLPHIN/MetroTRK/Portable/dispatch.h"
#include "TRK_MINNOW_DOLPHIN/Os/dolphin/targcont.h"
#include "TRK_MINNOW_DOLPHIN/ppc/Generic/targimpl.h"
void TRKHandleRequestEvent(TRKEvent* event)
{
TRKBuffer* buffer = TRKGetBuffer(event->msgBufID);
TRKDispatchMessage(buffer);
}
void TRKHandleSupportEvent(TRKEvent* event) { TRKTargetSupportRequest(); }
void TRKIdle()
{
if (TRKTargetStopped() == FALSE) {
TRKTargetContinue();
}
}
void TRKNubMainLoop(void)
{
void* msg;
TRKEvent event;
BOOL isShutdownRequested;
BOOL isNewInput;
isShutdownRequested = FALSE;
isNewInput = FALSE;
while (isShutdownRequested == FALSE) {
if (TRKGetNextEvent(&event) != FALSE) {
isNewInput = FALSE;
switch (event.eventType) {
case NUBEVENT_Null:
break;
case NUBEVENT_Request:
TRKHandleRequestEvent(&event);
break;
case NUBEVENT_Shutdown:
isShutdownRequested = TRUE;
break;
case NUBEVENT_Breakpoint:
case NUBEVENT_Exception:
TRKTargetInterrupt(&event);
break;
case NUBEVENT_Support:
TRKHandleSupportEvent(&event);
break;
}
TRKDestructEvent(&event);
continue;
}
if ((isNewInput == FALSE) || (*(u8*)gTRKInputPendingPtr != '\0')) {
isNewInput = TRUE;
TRKGetInput();
continue;
}
TRKIdle();
isNewInput = FALSE;
}
}