Merge pull request #1308 from PokeCodec/pain

Get rid of Task_data_OP macro
This commit is contained in:
luckytyphlosion 2021-01-26 15:22:13 -05:00 committed by GitHub
commit ff8952a3f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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;
u8 followupFuncIndex = NUM_TASK_DATA - 2; // Should be const.
gTasks[taskId].func = NULL;
TASK_DATA_OP(taskId, 28, func = *((u16 *)addr))
TASK_DATA_OP(taskId, 30, func |= *((s16 *)addr) << 16)
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)