Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
game_modes.c
Go to the documentation of this file.
1#include "game_modes.h"
2
5 MODE_FLAG_INITIALIZED = (1 << 0), // Set when the mode is initialized
6 MODE_FLAG_NEEDS_STEP = (1 << 1), // Turned off after the first step is done
7 MODE_FLAG_HAS_FRONT_UI = (1 << 2), // renderFrontUI function has been assigned
8};
9
10typedef struct GameModeData {
11 /* 0x00 */ u16 flags;
12 /* 0x04 */ void (*init)(void);
13 /* 0x08 */ void (*step)(void);
14 /* 0x0C */ void (*renderBackUI)(void);
15 /* 0x10 */ void (*renderFrontUI)(void);
16} GameModeData; // size = 0x14
17
21 .step = state_step_startup,
22 .renderBackUI = state_drawUI_startup,
23 .renderFrontUI = NULL,
24 },
26 .init = state_init_logos,
27 .step = state_step_logos,
28 .renderBackUI = state_drawUI_logos,
29 .renderFrontUI = NULL,
30 },
34 .renderBackUI = state_drawUI_title_screen,
35 .renderFrontUI = NULL,
36 },
40 .renderBackUI = state_drawUI_enter_world,
41 .renderFrontUI = NULL,
42 },
46 .renderBackUI = state_drawUI_enter_world,
47 .renderFrontUI = NULL,
48 },
50 .init = state_init_world,
51 .step = state_step_world,
52 .renderBackUI = state_drawUI_world,
53 .renderFrontUI = NULL,
54 },
58 .renderBackUI = state_drawUI_change_map,
59 .renderFrontUI = NULL,
60 },
64 .renderBackUI = state_drawUI_game_over,
65 .renderFrontUI = NULL,
66 },
68 .init = state_init_battle,
69 .step = state_step_battle,
70 .renderBackUI = state_drawUI_battle,
71 .renderFrontUI = NULL,
72 },
76 .renderBackUI = state_drawUI_end_battle,
77 .renderFrontUI = NULL,
78 },
80 .init = state_init_pause,
81 .step = state_step_pause,
82 .renderBackUI = state_drawUI_pause,
83 .renderFrontUI = NULL,
84 },
86 .init = state_init_unpause,
87 .step = state_step_unpause,
88 .renderBackUI = state_drawUI_unpause,
89 .renderFrontUI = NULL,
90 },
94 .renderBackUI = state_drawUI_file_select,
95 .renderFrontUI = NULL,
96 },
100 .renderBackUI = state_drawUI_exit_file_select,
101 .renderFrontUI = NULL,
102 },
104 .init = state_init_intro,
105 .step = state_step_intro,
106 .renderBackUI = state_drawUI_intro,
107 .renderFrontUI = NULL,
108 },
110 .init = state_init_demo,
111 .step = state_step_demo,
112 .renderBackUI = state_drawUI_demo,
113 .renderFrontUI = NULL,
114 },
115};
116
119
120void game_mode_nop(void) {
121}
122
123s32 get_game_mode(void) {
124 return CurGameModeID;
125}
126
127void set_game_mode(s32 modeID) {
128 GameModeData const* template = &GameModeTemplates[modeID];
129 CurGameModeID = modeID;
130
132 CurGameMode.init = template->init;
133 CurGameMode.step = template->step;
134 CurGameMode.renderBackUI = template->renderBackUI;
135
136 if (CurGameMode.init == NULL) {
138 }
139 if (CurGameMode.step == NULL) {
141 }
142 if (CurGameMode.renderBackUI == NULL) {
144 }
145
148}
149
153
154void set_game_mode_render_frontUI(void (*fn)(void)) {
157
158 if (fn == NULL) {
160 }
161}
162
163void step_game_mode(void) {
165 return;
166 }
167
168 CurGameMode.flags &= ~MODE_FLAG_NEEDS_STEP;
170}
171
174 return;
175 }
176
178}
179
182 return;
183 }
184
186 return;
187 }
188
191 }
192}
void state_init_startup(void)
void state_init_file_select(void)
void state_step_end_battle(void)
void state_step_exit_file_select(void)
void state_drawUI_enter_world(void)
void state_init_change_map(void)
void state_drawUI_unpause(void)
void state_step_unpause(void)
void state_step_logos(void)
void state_init_pause(void)
Definition state_pause.c:51
void state_init_enter_demo(void)
void state_step_change_map(void)
void state_step_file_select(void)
void state_step_world(void)
Definition state_world.c:20
void state_step_pause(void)
Definition state_pause.c:61
void state_drawUI_exit_file_select(void)
void state_drawUI_title_screen(void)
void state_step_title_screen(void)
void state_init_intro(void)
Definition state_intro.c:26
void state_init_battle(void)
void state_step_startup(void)
void state_init_unpause(void)
void state_init_logos(void)
Definition state_logos.c:66
void state_step_enter_world(void)
void state_drawUI_end_battle(void)
void state_drawUI_startup(void)
void state_step_intro(void)
Definition state_intro.c:92
void state_step_demo(void)
Definition state_demo.c:161
void state_init_game_over(void)
void state_drawUI_change_map(void)
void state_step_game_over(void)
void state_init_exit_file_select(void)
void state_drawUI_game_over(void)
void state_drawUI_world(void)
Definition state_world.c:35
void state_drawUI_demo(void)
Definition state_demo.c:274
void state_drawUI_battle(void)
void state_init_demo(void)
Definition state_demo.c:144
void state_init_title_screen(void)
void state_init_enter_world(void)
void state_init_end_battle(void)
void state_drawUI_logos(void)
void state_init_world(void)
Definition state_world.c:10
void state_drawUI_pause(void)
void state_step_battle(void)
void state_drawUI_file_select(void)
void state_drawUI_intro(void)
void render_game_mode_backUI(void)
Definition game_modes.c:172
BSS s32 CurGameModeID
Definition game_modes.c:117
void clear_game_mode(void)
Definition game_modes.c:150
s32 get_game_mode(void)
Definition game_modes.c:123
void game_mode_nop(void)
Definition game_modes.c:120
BSS GameModeData CurGameMode
Definition game_modes.c:118
void set_game_mode_render_frontUI(void(*fn)(void))
Definition game_modes.c:154
const GameModeData GameModeTemplates[]
Definition game_modes.c:18
void set_game_mode(s32 modeID)
Definition game_modes.c:127
GameModeFlags
Definition game_modes.c:3
@ MODE_FLAG_NEEDS_STEP
Definition game_modes.c:6
@ MODE_FLAG_NONE
Definition game_modes.c:4
@ MODE_FLAG_INITIALIZED
Definition game_modes.c:5
@ MODE_FLAG_HAS_FRONT_UI
Definition game_modes.c:7
void step_game_mode(void)
Definition game_modes.c:163
void render_game_mode_frontUI(void)
Definition game_modes.c:180
@ GAME_MODE_PAUSE
Definition game_modes.h:17
@ GAME_MODE_END_BATTLE
Definition game_modes.h:16
@ GAME_MODE_LOGOS
Definition game_modes.h:8
@ GAME_MODE_UNPAUSE
Definition game_modes.h:18
@ GAME_MODE_DEMO
Definition game_modes.h:22
@ GAME_MODE_ENTER_WORLD
Definition game_modes.h:11
@ GAME_MODE_GAME_OVER
Definition game_modes.h:14
@ GAME_MODE_BATTLE
Definition game_modes.h:15
@ GAME_MODE_WORLD
Definition game_modes.h:12
@ GAME_MODE_END_FILE_SELECT
Definition game_modes.h:20
@ GAME_MODE_FILE_SELECT
Definition game_modes.h:19
@ GAME_MODE_ENTER_DEMO_WORLD
Definition game_modes.h:10
@ GAME_MODE_CHANGE_MAP
Definition game_modes.h:13
@ GAME_MODE_TITLE_SCREEN
Definition game_modes.h:9
@ GAME_MODE_INTRO
Definition game_modes.h:21
@ GAME_MODE_STARTUP
Definition game_modes.h:7
#define BSS
Definition macros.h:7
void(* renderFrontUI)(void)
Definition game_modes.c:15
void(* init)(void)
Definition game_modes.c:12
void(* renderBackUI)(void)
Definition game_modes.c:14
void(* step)(void)
Definition game_modes.c:13