diff options
Diffstat (limited to 'arm9/lib')
-rw-r--r-- | arm9/lib/include/OS_init.h | 1 | ||||
-rw-r--r-- | arm9/lib/include/OS_interrupt.h | 1 | ||||
-rw-r--r-- | arm9/lib/include/OS_valarm.h | 25 | ||||
-rw-r--r-- | arm9/lib/include/registers.h | 1 | ||||
-rw-r--r-- | arm9/lib/src/OS_init.c | 1 | ||||
-rw-r--r-- | arm9/lib/src/OS_valarm.c | 30 |
6 files changed, 58 insertions, 1 deletions
diff --git a/arm9/lib/include/OS_init.h b/arm9/lib/include/OS_init.h index ea1fa66b..7427fed8 100644 --- a/arm9/lib/include/OS_init.h +++ b/arm9/lib/include/OS_init.h @@ -25,6 +25,7 @@ #include "OS_reset.h" #include "OS_exception.h" #include "OS_message.h" +#include "OS_valarm.h" void OS_Init(void); diff --git a/arm9/lib/include/OS_interrupt.h b/arm9/lib/include/OS_interrupt.h index d84cae00..893e6d65 100644 --- a/arm9/lib/include/OS_interrupt.h +++ b/arm9/lib/include/OS_interrupt.h @@ -4,6 +4,7 @@ #include "consts.h" #include "nitro/OS_interrupt_shared.h" +#define OS_IE_V_COUNT (1UL << REG_OS_IE_VE_SHIFT) #define OS_IE_TIMER0 (1UL << REG_OS_IE_T0_SHIFT) #define OS_IE_TIMER1 (1UL << REG_OS_IE_T1_SHIFT) diff --git a/arm9/lib/include/OS_valarm.h b/arm9/lib/include/OS_valarm.h new file mode 100644 index 00000000..b4850f9d --- /dev/null +++ b/arm9/lib/include/OS_valarm.h @@ -0,0 +1,25 @@ +#ifndef POKEDIAMOND_OS_VALARM_H +#define POKEDIAMOND_OS_VALARM_H + +#include "nitro/types.h" +#include "OS_alarm.h" + +typedef struct OSiVAlarm OSVAlarm; +struct OSiVAlarm +{ + OSAlarmHandler handler; + void *arg; + u32 tag; + u32 frame; + s16 fire; + s16 delay; + OSVAlarm *prev; + OSVAlarm *next; + BOOL period; + BOOL finish; + BOOL canceled; +}; + +void OS_InitVAlarm(void); + +#endif //POKEDIAMOND_OS_VALARM_H diff --git a/arm9/lib/include/registers.h b/arm9/lib/include/registers.h index 6bfb52ac..b2915f8c 100644 --- a/arm9/lib/include/registers.h +++ b/arm9/lib/include/registers.h @@ -345,6 +345,7 @@ #define reg_MI_MCD1 (*(REGType32v *)0x4100010) #define reg_CARD_DATA (*(REGType32v *)0x4100010) //? +#define REG_OS_IE_VE_SHIFT 2 #define REG_OS_IE_T0_SHIFT 3 #define REG_OS_IE_T1_SHIFT 4 diff --git a/arm9/lib/src/OS_init.c b/arm9/lib/src/OS_init.c index c93b1584..152a5534 100644 --- a/arm9/lib/src/OS_init.c +++ b/arm9/lib/src/OS_init.c @@ -3,7 +3,6 @@ extern void PXI_Init(void); extern void MI_Init(void); -extern void OS_InitVAlarm(void); extern void OSi_InitVramExclusive(void); extern void CTRDG_Init(void); extern void CARD_Init(void); diff --git a/arm9/lib/src/OS_valarm.c b/arm9/lib/src/OS_valarm.c new file mode 100644 index 00000000..37329147 --- /dev/null +++ b/arm9/lib/src/OS_valarm.c @@ -0,0 +1,30 @@ +#include "OS_valarm.h" +#include "function_target.h" +#include "OS_interrupt.h" + +static struct OSiVAlarmQueue +{ + OSVAlarm *head; + OSVAlarm *tail; +} OSi_VAlarmQueue; + +static u16 OSi_UseVAlarm = FALSE; + +static s32 OSi_VFrameCount; +static s32 OSi_PreviousVCount; + +ARM_FUNC void OS_InitVAlarm(void) +{ + if (!OSi_UseVAlarm) + { + OSi_UseVAlarm = TRUE; + + OSi_VAlarmQueue.head = NULL; + OSi_VAlarmQueue.tail = NULL; + + (void)OS_DisableIrqMask(OS_IE_V_COUNT); + + OSi_VFrameCount = 0; + OSi_PreviousVCount = 0; + } +} |