diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 2 | ||||
-rw-r--r-- | src/task.c | 26 |
2 files changed, 8 insertions, 20 deletions
diff --git a/src/main.c b/src/main.c index f0ad4ce94..992d23ead 100644 --- a/src/main.c +++ b/src/main.c @@ -298,7 +298,7 @@ void InitIntrHandlers(void) REG_IME = 1; - EnableInterrupts(0x1); + EnableInterrupts(INTR_FLAG_VBLANK); } void SetVBlankCallback(IntrCallback callback) diff --git a/src/task.c b/src/task.c index a97496009..3a3ddadfd 100644 --- a/src/task.c +++ b/src/task.c @@ -136,32 +136,20 @@ void TaskDummy(u8 taskId) { } -#define TASK_DATA_OP(taskId, offset, op) \ -{ \ - u32 tasksAddr = (u32)gTasks; \ - u32 addr = taskId * sizeof(struct Task) + offset; \ - u32 dataAddr = tasksAddr + offsetof(struct Task, data); \ - addr += dataAddr; \ - op; \ -} - void SetTaskFuncWithFollowupFunc(u8 taskId, TaskFunc func, TaskFunc followupFunc) { - TASK_DATA_OP(taskId, 28, *((u16 *)addr) = (u32)followupFunc) - TASK_DATA_OP(taskId, 30, *((u16 *)addr) = (u32)followupFunc >> 16) + u8 followupFuncIndex = NUM_TASK_DATA - 2; // Should be const. + + gTasks[taskId].data[followupFuncIndex] = (s16)((u32)followupFunc); + gTasks[taskId].data[followupFuncIndex + 1] = (s16)((u32)followupFunc >> 16); // Store followupFunc as two half-words in the data array. gTasks[taskId].func = func; } void SwitchTaskToFollowupFunc(u8 taskId) { - s32 func; - - gTasks[taskId].func = NULL; - - TASK_DATA_OP(taskId, 28, func = *((u16 *)addr)) - TASK_DATA_OP(taskId, 30, func |= *((s16 *)addr) << 16) + u8 followupFuncIndex = NUM_TASK_DATA - 2; // Should be const. - gTasks[taskId].func = (TaskFunc)func; + gTasks[taskId].func = (TaskFunc)((u16)(gTasks[taskId].data[followupFuncIndex]) | (gTasks[taskId].data[followupFuncIndex + 1] << 16)); } bool8 FuncIsActiveTask(TaskFunc func) @@ -183,7 +171,7 @@ u8 FindTaskIdByFunc(TaskFunc func) if (gTasks[i].isActive == TRUE && gTasks[i].func == func) return (u8)i; - return 0xFF; + return TAIL_SENTINEL; // No task was found. } u8 GetTaskCount(void) |