Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
worker.c File Reference

Go to the source code of this file.

Functions

void worker_delegate_do_nothing (void)
 
void clear_worker_list (void)
 
void init_worker_list (void)
 
s32 create_worker_world (void(*updateFunc)(void), void(*drawFunc)(void))
 
s32 create_worker_frontUI (void(*updateFunc)(void), void(*drawFunc)(void))
 
s32 create_worker_backUI (void(*updateFunc)(void), void(*drawFunc)(void))
 
void update_workers (void)
 
void render_workers_world (void)
 
void render_workers_frontUI (void)
 
void render_workers_backUI (void)
 
void free_worker (s32 idx)
 
Workerget_worker (s32 idx)
 

Variables

BSS WorkerList gWorldWorkerList
 
BSS WorkerList gBattleWorkerList
 
BSS WorkerListgCurrentWorkerListPtr
 

Function Documentation

◆ worker_delegate_do_nothing()

void worker_delegate_do_nothing ( void )

Definition at line 7 of file worker.c.

7 {
8}

Referenced by create_worker_backUI(), create_worker_frontUI(), and create_worker_world().

◆ clear_worker_list()

void clear_worker_list ( void )

Definition at line 10 of file worker.c.

10 {
11 s32 i;
12
15 } else {
17 }
18
19 for (i = 0; i < MAX_WORKERS; i++) {
20 (*gCurrentWorkerListPtr)[i] = NULL;
21 }
22}
@ CONTEXT_WORLD
Definition enums.h:3529
#define MAX_WORKERS
Definition macros.h:95
GameStatus * gGameStatusPtr
Definition main_loop.c:32
BSS WorkerList gWorldWorkerList
Definition worker.c:3
BSS WorkerList * gCurrentWorkerListPtr
Definition worker.c:5
BSS WorkerList gBattleWorkerList
Definition worker.c:4

Referenced by load_demo_battle(), load_engine_data(), load_map_by_IDs(), state_init_logos(), state_init_title_screen(), state_step_battle(), state_step_demo(), state_step_intro(), state_step_pause(), and state_step_startup().

◆ init_worker_list()

void init_worker_list ( void )

Definition at line 24 of file worker.c.

Referenced by state_step_end_battle(), and state_step_unpause().

◆ create_worker_world()

s32 create_worker_world ( void(*)(void) updateFunc,
void(*)(void) drawFunc )

Definition at line 32 of file worker.c.

32 {
33 Worker* worker;
34 s32 i;
35
36 for (i = 0; i < MAX_WORKERS; i++) {
37 Worker* lastWorker = (*gCurrentWorkerListPtr)[i];
38 if (lastWorker == NULL) {
39 break;
40 }
41 }
43
44 (*gCurrentWorkerListPtr)[i] = worker = heap_malloc(sizeof(*worker));
45 ASSERT(worker != NULL);
46
48 worker->update = updateFunc;
49 if (updateFunc == NULL) {
51 }
52 worker->draw = drawFunc;
53 if (drawFunc == NULL) {
55 }
56
59 }
60 return i;
61}
#define ASSERT(condition)
@ WORKER_FLAG_1
Definition enums.h:2770
@ WORKER_FLAG_SKIP_DRAW_UNTIL_UPDATE
Definition enums.h:2771
void * heap_malloc(s32 size)
Definition heap.c:34
#define BATTLE_ENTITY_ID_BIT
Definition macros.h:146
void(* draw)(void)
void(* update)(void)
void worker_delegate_do_nothing(void)
Definition worker.c:7

◆ create_worker_frontUI()

s32 create_worker_frontUI ( void(*)(void) updateFunc,
void(*)(void) drawFunc )

Definition at line 63 of file worker.c.

63 {
64 Worker* worker;
65 s32 i;
66
67 for (i = 0; i < MAX_WORKERS; i++) {
68 Worker* lastWorker = (*gCurrentWorkerListPtr)[i];
69 if (lastWorker == NULL) {
70 break;
71 }
72 }
74
75 (*gCurrentWorkerListPtr)[i] = worker = heap_malloc(sizeof(*worker));
76 ASSERT(worker != NULL);
77
79 worker->update = updateFunc;
80 if (updateFunc == NULL) {
82 }
83 worker->draw = drawFunc;
84 if (drawFunc == NULL) {
86 }
87
90 }
91 return i;
92}
@ WORKER_FLAG_FRONT_UI
Definition enums.h:2772

Referenced by clear_item_entity_data(), create_battle_popup_menu(), create_shop_popup_menu(), create_standard_popup_menu(), func_80268E88(), and partner_reset_data().

◆ create_worker_backUI()

s32 create_worker_backUI ( void(*)(void) updateFunc,
void(*)(void) drawFunc )

Definition at line 94 of file worker.c.

94 {
95 Worker* worker;
96 s32 i;
97
98 for (i = 0; i < MAX_WORKERS; i++) {
99 Worker* lastWorker = (*gCurrentWorkerListPtr)[i];
100 if (lastWorker == NULL) {
101 break;
102 }
103 }
104 ASSERT(i < MAX_WORKERS);
105
106 (*gCurrentWorkerListPtr)[i] = worker = heap_malloc(sizeof(*worker));
107 ASSERT(worker != NULL);
108
110 worker->update = updateFunc;
111 if (updateFunc == NULL) {
113 }
114 worker->draw = drawFunc;
115 if (drawFunc == NULL) {
117 }
118
121 }
122 return i;
123}
@ WORKER_FLAG_BACK_UI
Definition enums.h:2773

Referenced by clear_virtual_entity_list().

◆ update_workers()

void update_workers ( void )

Definition at line 125 of file worker.c.

125 {
126 s32 i;
127
128 for (i = 0; i < MAX_WORKERS; i++) {
129 Worker* worker = (*gCurrentWorkerListPtr)[i];
130 if (worker != NULL) {
131 worker->flags &= ~WORKER_FLAG_SKIP_DRAW_UNTIL_UPDATE;
132 worker->update();
133 }
134 }
135}

Referenced by step_game_loop().

◆ render_workers_world()

void render_workers_world ( void )

Definition at line 137 of file worker.c.

137 {
138 s32 i;
139
140 for (i = 0; i < MAX_WORKERS; i++) {
141 Worker* worker = (*gCurrentWorkerListPtr)[i];
142 if (worker != NULL && !(worker->flags & WORKER_FLAG_SKIP_DRAW_UNTIL_UPDATE)) {
143 if (!(worker->flags & WORKER_FLAG_FRONT_UI)) {
144 worker->draw();
145 }
146 }
147 }
148}

Referenced by render_frame().

◆ render_workers_frontUI()

void render_workers_frontUI ( void )

Definition at line 150 of file worker.c.

150 {
151 s32 i;
152
153 for (i = 0; i < MAX_WORKERS; i++) {
154 Worker* worker = (*gCurrentWorkerListPtr)[i];
155 if (worker != NULL && !(worker->flags & WORKER_FLAG_SKIP_DRAW_UNTIL_UPDATE)) {
156 if (worker->flags & WORKER_FLAG_FRONT_UI) {
157 worker->draw();
158 }
159 }
160 }
161}

Referenced by gfx_draw_frame().

◆ render_workers_backUI()

void render_workers_backUI ( void )

Definition at line 163 of file worker.c.

163 {
164 s32 i;
165
166 for (i = 0; i < MAX_WORKERS; i++) {
167 Worker* worker = (*gCurrentWorkerListPtr)[i];
168 if (worker != NULL && !(worker->flags & WORKER_FLAG_SKIP_DRAW_UNTIL_UPDATE)) {
169 if (worker->flags & WORKER_FLAG_BACK_UI) {
170 worker->draw();
171 }
172 }
173 }
174}

Referenced by gfx_draw_frame().

◆ free_worker()

void free_worker ( s32 idx)

Definition at line 176 of file worker.c.

176 {
178 idx &= ~BATTLE_ENTITY_ID_BIT;
179 if ((*gCurrentWorkerListPtr)[idx] != NULL) {
181 (*gCurrentWorkerListPtr)[idx] = NULL;
182 }
183 }
184}
s32 heap_free(void *ptr)
Definition heap.c:42

Referenced by popup_menu_update().

◆ get_worker()

Worker * get_worker ( s32 idx)

Definition at line 186 of file worker.c.

186 {
187 return (*gCurrentWorkerListPtr)[idx & ~BATTLE_ENTITY_ID_BIT];
188}

Referenced by partner_reset_data().

Variable Documentation

◆ gWorldWorkerList

BSS WorkerList gWorldWorkerList

Definition at line 3 of file worker.c.

Referenced by clear_worker_list(), and init_worker_list().

◆ gBattleWorkerList

BSS WorkerList gBattleWorkerList

Definition at line 4 of file worker.c.

Referenced by clear_worker_list(), and init_worker_list().

◆ gCurrentWorkerListPtr

BSS WorkerList* gCurrentWorkerListPtr

Definition at line 5 of file worker.c.

Referenced by clear_worker_list(), free_worker(), get_worker(), and init_worker_list().