Alchemy
Loading...
Searching...
No Matches

callback_scheduler.h

Go to the documentation of this file.
1#ifndef ALCHEMY_CALLBACK_SCHEDULER_H
2#define ALCHEMY_CALLBACK_SCHEDULER_H
3
4/// @file
5/// The task scheduler: tasks, their order and the scheduler's state.
6
7#include "edition.h"
8#include "types.h"
9#include "static_assert.h"
10
14};
15
16typedef void (*SchedulerCallback)(void);
17
18/// A scheduled task: its routine's address, its order (see SCHEDULER_KEY_) and
19/// its flags, where bit 0 keeps it running while overlay tasks are suspended.
25};
26
27STATIC_ASSERT(sizeof(struct SchedulerTask) == 8);
30
31/// A task's order: the high byte picks the pass that runs it, the low byte
32/// ranks it within the pass (higher runs first). An odd high byte means the
33/// task is suspended, so no pass matches it.
34#define SCHEDULER_KEY_VBLANK 0x480
35#define SCHEDULER_KEY_MAIN_LOOP 0xc80
36
37#define TASK_STATE_HIGH(task) (((u8 *)&(task)->state)[1])
38
39/* FAKEMATCH: volatile makes every access to this cell a load or store of its
40 * own; without it Scheduler_AddOrUpdateCallback: differ 14 in tbs-en, 59
41 * instructions for 61. */
42extern volatile u8 gSchedulerStatus;
43extern u8 gSchedulerReady; ///< 1 once the task table is set up
45
47
51
52#endif
s32 Scheduler_CountCallbacksByKey(s32 key)
struct SchedulerTask gSchedulerTaskTable[]
void Scheduler_RunCallbacksBeforeBoundary(s32 key)
void Scheduler_RunCallbacksByKey(s32 key)
u8 gSchedulerReady
1 once the task table is set up
volatile u8 gSchedulerStatus
void(*) SchedulerCallback(void)
SchedulerTaskLimits
@ SCHEDULER_TLA_TASK_COUNT
@ SCHEDULER_TBS_TASK_COUNT
The edition's language, for C to compare (LANGUAGE == LANGUAGE_GERMAN).
void Runtime_CallWorkEntryWithArgs(struct SoundPlayer *player, struct SoundTrack *track)
Finishes a track through the base command table entry.
Definition engine.c:1070
STATIC_ASSERT, a compile-time check that emits nothing.
#define STATIC_ASSERT(condition)
C89 permits repeated extern declarations of the same array.
#define offsetof(type, member)
Definition stddef.h:19
A scheduled task: its routine's address, its order (see SCHEDULER_KEY_) and its flags,...
The integer types, TRUE, UNUSED and the fixed-address macros.
signed int s32
Definition types.h:14
unsigned int u32
Definition types.h:15
unsigned short u16
Definition types.h:13
unsigned char u8
Definition types.h:11