diff --git a/configure.py b/configure.py index 8395768b..1b1853fb 100644 --- a/configure.py +++ b/configure.py @@ -420,7 +420,7 @@ config.libs = [ Object(Matching, "libultra/gu/scale.c"), Object(Matching, "libultra/sendmesg.c"), Object(Matching, "libultra/setthreadpri.c"), - Object(NonMatching, "libultra/settimer.c"), + Object(Matching, "libultra/settimer.c", extra_cflags=["-O0", "-opt schedule", "-opt peep"]), # no clue why this file has these flags, but they're necessary Object(Matching, "libultra/shutdown.c"), Object(Matching, "libultra/gu/sins.c"), Object(Matching, "libultra/startthread.c"), diff --git a/src/static/libultra/settimer.c b/src/static/libultra/settimer.c index 6911f5b6..64a86d7b 100644 --- a/src/static/libultra/settimer.c +++ b/src/static/libultra/settimer.c @@ -2,15 +2,14 @@ #include -static void timer_handler(OSAlarm* alarm, OSContext* context); - -static void timer_handler(OSAlarm* volatile alarm, OSContext* context) { - OSTimer* volatile timer = (OSTimer* volatile)alarm; +static void timer_handler(OSAlarm* alarm, OSContext* context) { + OSTimer* timer = (OSTimer*)alarm; BOOL enabled = OSDisableInterrupts(); if ((OSTime)timer->interval != 0) { OSSetAlarm(&timer->alarm, (OSTime)timer->interval, timer_handler); } else { + OSTimer* next = timer->next; timer->next->prev = timer->prev; timer->prev->next = timer->next; timer->next = NULL; @@ -21,11 +20,15 @@ static void timer_handler(OSAlarm* volatile alarm, OSContext* context) { OSRestoreInterrupts(enabled); } -extern int osSetTimer(OSTimer* timer, OSTime countdown, OSTime interval, OSMessageQueue* volatile mq, volatile OSMessage msg) { + +extern int osSetTimer(OSTimer* timer, OSTime countdown, OSTime interval, OSMessageQueue* mq, OSMessage msg) { BOOL enable = OSDisableInterrupts(); OSTimer* head; - countdown = countdown == 0 ? interval : countdown; + if (countdown == 0) { + countdown = interval; + } + OSCreateAlarm(&timer->alarm); timer->mq = (OSMessageQueue*)mq; timer->msg = msg;