Clean up game_modes.c and game_states.c (#1115)

This commit is contained in:
JoshDuMan 2023-09-15 23:53:00 -04:00 committed by GitHub
parent ef440ff994
commit bde8f70e3f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
39 changed files with 431 additions and 220 deletions

View File

@ -2478,15 +2478,6 @@ typedef struct CreditsPairOffset {
/* 0x02 */ s16 offset;
} CreditsPairOffset; // size = 0x4
typedef struct GameMode {
/* 0x00 */ u16 flags;
/* 0x04 */ void (*init)(void);
/* 0x08 */ void (*step)(void);
/* 0x0C */ UNK_FUN_PTR(unk_0C);
/* 0x10 */ void (*render)(void);
/* 0x14 */ void (*renderAux)(void); ///< @see state_render_frontUI
} GameMode; // size = 0x18
typedef struct PartnerDMAData {
/* 0x00 */ u32 dmaStart;
/* 0x04 */ u32 dmaEnd;

View File

@ -3491,27 +3491,6 @@ enum EffectGfxDataFlags {
#include "move_enum.h"
enum GameModeIDs {
GAME_MODE_STARTUP = 0x00000000,
GAME_MODE_LOGOS = 0x00000001,
GAME_MODE_TITLE_SCREEN = 0x00000002,
GAME_MODE_ENTER_DEMO_WORLD = 0x00000003,
GAME_MODE_CHANGE_MAP = 0x00000004,
GAME_MODE_UNUSED = 0x00000005,
GAME_MODE_ENTER_WORLD = 0x00000006,
GAME_MODE_WORLD = 0x00000007,
GAME_MODE_BATTLE = 0x00000008,
GAME_MODE_END_BATTLE = 0x00000009,
GAME_MODE_PAUSE = 0x0000000A,
GAME_MODE_UNPAUSE = 0x0000000B,
GAME_MODE_LANGUAGE_SELECT = 0x0000000C,
GAME_MODE_END_LANGUAGE_SELECT = 0x0000000D,
GAME_MODE_FILE_SELECT = 0x0000000E,
GAME_MODE_END_FILE_SELECT = 0x0000000F,
GAME_MODE_INTRO = 0x00000010,
GAME_MODE_DEMO = 0x00000011,
};
enum DemoState {
DEMO_STATE_NONE = 0,
DEMO_STATE_ACTIVE = 1,

View File

@ -283,8 +283,6 @@ void mem_clear(void* data, s32 numBytes);
void intro_logos_set_fade_color(s16 color);
void intro_logos_set_fade_alpha(s16 alpha);
void set_game_mode(s16 idx);
f32 get_xz_dist_to_player(f32, f32);
void func_800E06C0(s32);
void close_status_bar(void);
@ -584,7 +582,6 @@ void update_workers(void);
void update_triggers(void);
void update_scripts(void);
void update_messages(void);
void step_current_game_mode(void);
void update_entities(void);
void func_80138198(void);
void bgm_update_music_settings(void);
@ -596,13 +593,11 @@ void func_802C3EE4(void);
void render_screen_overlay_backUI(void);
void render_workers_backUI(void);
void render_effects_UI(void);
void state_render_backUI(void);
void render_window_root(void);
void render_messages(void);
void render_workers_frontUI(void);
void render_screen_overlay_frontUI(void);
void render_curtains(void);
void state_render_frontUI(void);
void fio_init_flash(void);
void func_80028838(void);
void clear_screen_overlays(void);
@ -704,9 +699,9 @@ void state_step_enter_world(void);
void state_init_change_map(void);
void state_step_change_map(void);
void state_drawUI_change_map(void);
void func_80036430(void);
void func_8003646C(void);
void func_80036640(void);
void state_init_game_over(void);
void state_step_game_over(void);
void state_drawUI_game_over(void);
void state_init_enter_world(void);
void state_drawUI_enter_world(void);
void state_init_world(void);
@ -742,7 +737,6 @@ void state_drawUI_intro(void);
void state_init_demo(void);
void state_step_demo(void);
void state_drawUI_demo(void);
void game_mode_set_fpDrawAuxUI(s32 i, void (*fn)(void));
void btl_set_player_idle_anims(void);
@ -1073,7 +1067,6 @@ void clear_model_data(void);
void init_sprite_shading_data(void);
void clear_sprite_shading_data(void);
void clear_character_set(void);
void clear_game_modes(void);
void clear_trigger_data(void);
void clear_script_list(void);
void clear_entity_data(s32);

View File

@ -10,8 +10,6 @@
#define UNK_FUN_PTR(name) void(*name)(void)
#define UNK_ARGS
typedef void (*StateFunc)(void);
typedef char* (*PrintCallback)(void*, const char*, u32);
/// Linker symbol address, as in `ld_addrs.h`.

View File

@ -1,5 +1,6 @@
#include "common.h"
#include "nu/nusys.h"
#include "game_modes.h"
SHIFT_BSS s16 gMapTransitionAlpha;
SHIFT_BSS s16 gMapTransitionFadeRate;
@ -85,7 +86,7 @@ void state_step_enter_world(void) {
enable_player_input();
}
set_screen_overlay_params_front(OVERLAY_NONE, -1.0f);
set_game_mode(GAME_MODE_CHANGE_MAP);
set_game_mode(GAME_MODE_WORLD);
}
break;
}
@ -173,7 +174,7 @@ void state_step_change_map(void) {
enable_player_input();
}
set_screen_overlay_params_front(OVERLAY_NONE, -1.0f);
set_game_mode(GAME_MODE_CHANGE_MAP);
set_game_mode(GAME_MODE_WORLD);
}
break;
}
@ -185,14 +186,14 @@ void state_drawUI_change_map(void) {
}
}
void func_80036430(void) {
void state_init_game_over(void) {
gMapTransitionAlpha = 255;
gMapTransitionFadeRate = 20;
gMapTransitionState = 0x01;
gPlayerStatus.flags |= PS_FLAG_NO_STATIC_COLLISION;
}
void func_8003646C(void) {
void state_step_game_over(void) {
switch (gMapTransitionState) {
case 1:
gOverrideFlags |= GLOBAL_OVERRIDES_8;
@ -226,7 +227,7 @@ void func_8003646C(void) {
gMapTransitionAlpha = 0;
gMapTransitionState++;
set_screen_overlay_params_front(OVERLAY_NONE, -1.0f);
set_game_mode(GAME_MODE_CHANGE_MAP);
set_game_mode(GAME_MODE_WORLD);
}
update_npcs();
update_player();
@ -238,5 +239,5 @@ void func_8003646C(void) {
set_screen_overlay_params_front(OVERLAY_SCREEN_COLOR, gMapTransitionAlpha);
}
void func_80036640(void) {
void state_drawUI_game_over(void) {
}

View File

@ -5,6 +5,7 @@
#include "hud_element.h"
#include "battle/battle.h"
#include "model.h"
#include "game_modes.h"
extern StageListRow* gCurrentStagePtr;
@ -2144,7 +2145,7 @@ void btl_state_update_end_battle(void) {
gGameStatusPtr->areaID = areaID;
gGameStatusPtr->mapID = mapID;
gGameStatusPtr->entryID = gv_01_ENTRY_0;
set_game_mode(GAME_MODE_ENTER_WORLD);
set_game_mode(GAME_MODE_GAME_OVER);
} else {
btl_set_state(BATTLE_STATE_0);
gLastDrawBattleState = gBattleState;

View File

@ -4,6 +4,7 @@
#include "macros.h"
#include "common.h"
#include "sprite.h"
#include "game_modes.h"
#include "pause/pause_common.h"
#include "world/partners.h"
#include "world/partner/lakilester.h"

View File

@ -4,6 +4,7 @@
#include "battle_tables.h"
#include "hud_element.h"
#include "sprite.h"
#include "game_modes.h"
SHIFT_BSS s32 D_800DC060;
SHIFT_BSS StageListRow* gCurrentStagePtr;

View File

@ -5,6 +5,7 @@
#include "ui/no_controller.png.h"
#include "ld_addrs.h"
#include "nu/nusys.h"
#include "game_modes.h"
#include "theater/walls.png.inc.c"

View File

@ -1,4 +1,5 @@
#include "common.h"
#include "game_modes.h"
// args: start, end, duration, EasingType
ApiStatus MakeLerp(Evt* script, s32 isInitialCall) {

View File

@ -1,6 +1,7 @@
#include "common.h"
#include "model.h"
#include "evt.h"
#include "game_modes.h"
extern LavaReset* gLavaResetList;
extern s32 LastSafeFloor;
@ -721,7 +722,7 @@ void goto_map(Evt* script, s32 mode) {
}
set_map_transition_effect(mapTransitionEffect);
set_game_mode(GAME_MODE_UNUSED);
set_game_mode(GAME_MODE_CHANGE_MAP);
}
ApiStatus GotoMap(Evt* script, s32 isInitialCall) {

View File

@ -3,6 +3,7 @@
#include "hud_element.h"
#include "fio.h"
#include "ld_addrs.h"
#include "game_modes.h"
extern HudScript HES_AnimatedCursorHand;

View File

@ -3,6 +3,7 @@
#include "hud_element.h"
#include "audio/public.h"
#include "fio.h"
#include "game_modes.h"
extern HudScript HES_Spirit1;
extern HudScript HES_Spirit2;

View File

@ -3,6 +3,7 @@
#include "message_ids.h"
#include "hud_element.h"
#include "ld_addrs.h"
#include "game_modes.h"
extern HudScript HES_Spirit1;

View File

@ -1,6 +1,7 @@
#include "common.h"
#include "filemenu.h"
#include "fio.h"
#include "game_modes.h"
#if VERSION_IQUE
#define DELETE_FILE_DELETE_X 20

View File

@ -1,6 +1,4 @@
#include "common.h"
// TODO: decide whether to call these 'game modes' or 'states'
#include "game_modes.h"
s32 D_80077420[] = {
0x000000E4, 0x000000E1, 0x000000EB, 0x000000EF, 0x000000F6, 0x0000010A, 0x0000010C, 0x00000121, 0x00000122,
@ -25,82 +23,246 @@ s32 D_80077420[] = {
0x000000D4, 0x000000D5, 0x000000D6, 0x000000D7, 0x000000D8, 0x000000D9, 0x000000DA,
};
// These StateFunc[] should really be GameMode but they seem to sometimes only take up 0x14 bytes of data rather than 0x18 like they should if they were really a struct.
// These GameModeIncomplete are used as the struct GameMode. As GameModeIncomplete is 0x14 long and GameMode is 0x18 long, the last element
// and first element of the next struct are shared in data.
StateFunc gameModeBlueprints[] = { NULL, state_init_startup, state_step_startup, NULL, state_drawUI_startup };
typedef struct GameModeIncomplete {
/* 0x00 */ u16 flags;
/* 0x04 */ void (*init)(void);
/* 0x08 */ void (*step)(void);
/* 0x0C */ UNK_FUN_PTR(unusedFunc);
/* 0x10 */ void (*render)(void);
#ifdef AVOID_UB
/* 0x14 */ void (*renderAux)(void); ///< @see state_render_frontUI
#endif
} GameModeIncomplete; // size = 0x14
StateFunc D_800776FC[] = { NULL, state_init_logos, state_step_logos, NULL, state_drawUI_logos };
StateFunc D_80077710[] = { NULL, state_init_title_screen, state_step_title_screen, NULL, state_drawUI_title_screen };
StateFunc D_80077724[] = { NULL, state_init_enter_demo, state_step_enter_world, NULL, state_drawUI_enter_world };
StateFunc D_80077738[] = { NULL, state_init_change_map, state_step_change_map, NULL, state_drawUI_change_map };
StateFunc D_8007774C[] = { NULL, func_80036430, func_8003646C, NULL, func_80036640 };
StateFunc D_80077760[] = { NULL, state_init_enter_world, state_step_enter_world, NULL, state_drawUI_enter_world };
StateFunc D_80077774[] = { NULL, state_init_world, state_step_world, NULL, state_drawUI_world };
StateFunc D_80077788[] = { NULL, state_init_battle, state_step_battle, NULL, state_drawUI_battle };
StateFunc D_8007779C[] = { NULL, state_init_end_battle, state_step_end_battle, NULL, state_drawUI_end_battle };
StateFunc D_800777B0[] = { NULL, state_init_pause, state_step_pause, NULL, state_drawUI_pause };
StateFunc D_800777C4[] = { NULL, state_init_unpause, state_step_unpause, NULL, state_drawUI_unpause };
StateFunc D_800777D8[] = {
NULL, state_init_language_select, state_step_language_select, NULL, state_drawUI_language_select
GameModeIncomplete GameModeStartup = {
MODE_FLAG_NONE,
state_init_startup,
state_step_startup,
NULL,
state_drawUI_startup,
#ifdef AVOID_UB
NULL,
#endif
};
StateFunc D_800777EC[] = {
NULL, state_init_exit_language_select, state_step_exit_language_select, NULL, state_drawUI_exit_language_select
GameModeIncomplete GameModeLogos = {
MODE_FLAG_NONE,
state_init_logos,
state_step_logos,
NULL,
state_drawUI_logos,
#ifdef AVOID_UB
NULL,
#endif
};
StateFunc D_80077800[] = { NULL, state_init_file_select, state_step_file_select, NULL, state_drawUI_file_select };
StateFunc D_80077814[] = {
NULL, state_init_exit_file_select, state_step_exit_file_select, NULL, state_drawUI_exit_file_select
GameModeIncomplete GameModeTitleScreen = {
MODE_FLAG_NONE,
state_init_title_screen,
state_step_title_screen,
NULL,
state_drawUI_title_screen,
#ifdef AVOID_UB
NULL,
#endif
};
StateFunc D_80077828[] = { NULL, state_init_intro, state_step_intro, NULL, state_drawUI_intro };
GameModeIncomplete GameModeEnterDemoWorld = {
MODE_FLAG_NONE,
state_init_enter_demo,
state_step_enter_world,
NULL,
state_drawUI_enter_world,
#ifdef AVOID_UB
NULL,
#endif
};
StateFunc D_8007783C[] = { NULL, state_init_demo, state_step_demo, NULL, state_drawUI_demo };
GameModeIncomplete GameModeChangeMap = {
MODE_FLAG_NONE,
state_init_change_map,
state_step_change_map,
NULL,
state_drawUI_change_map,
#ifdef AVOID_UB
NULL,
#endif
};
GameModeIncomplete GameModeGameOver = {
MODE_FLAG_NONE,
state_init_game_over,
state_step_game_over,
NULL,
state_drawUI_game_over,
#ifdef AVOID_UB
NULL,
#endif
};
GameModeIncomplete GameModeEnterWorld = {
MODE_FLAG_NONE,
state_init_enter_world,
state_step_enter_world,
NULL,
state_drawUI_enter_world,
#ifdef AVOID_UB
NULL,
#endif
};
GameModeIncomplete GameModeWorld = {
MODE_FLAG_NONE,
state_init_world,
state_step_world,
NULL,
state_drawUI_world,
#ifdef AVOID_UB
NULL,
#endif
};
GameModeIncomplete GameModeBattle = {
MODE_FLAG_NONE,
state_init_battle,
state_step_battle,
NULL,
state_drawUI_battle,
#ifdef AVOID_UB
NULL,
#endif
};
GameModeIncomplete GameModeEndBattle = {
MODE_FLAG_NONE,
state_init_end_battle,
state_step_end_battle,
NULL,
state_drawUI_end_battle,
#ifdef AVOID_UB
NULL,
#endif
};
GameModeIncomplete GameModePause = {
MODE_FLAG_NONE,
state_init_pause,
state_step_pause,
NULL,
state_drawUI_pause,
#ifdef AVOID_UB
NULL,
#endif
};
GameModeIncomplete GameModeUnpause = {
MODE_FLAG_NONE,
state_init_unpause,
state_step_unpause,
NULL,
state_drawUI_unpause,
#ifdef AVOID_UB
NULL,
#endif
};
GameModeIncomplete GameModeLanguageSelect = {
MODE_FLAG_NONE,
state_init_language_select,
state_step_language_select,
NULL,
state_drawUI_language_select,
#ifdef AVOID_UB
NULL,
#endif
};
GameModeIncomplete GameModeEndLanguageSelect = {
MODE_FLAG_NONE,
state_init_exit_language_select,
state_step_exit_language_select,
NULL,
state_drawUI_exit_language_select,
#ifdef AVOID_UB
NULL,
#endif
};
GameModeIncomplete GameModeFileSelect = {
MODE_FLAG_NONE,
state_init_file_select,
state_step_file_select,
NULL,
state_drawUI_file_select,
#ifdef AVOID_UB
NULL,
#endif
};
GameModeIncomplete GameModeEndFileSelect = {
0,
state_init_exit_file_select,
state_step_exit_file_select,
NULL,
state_drawUI_exit_file_select,
#ifdef AVOID_UB
NULL,
#endif
};
GameModeIncomplete GameModeIntro = {
MODE_FLAG_NONE,
state_init_intro,
state_step_intro,
NULL,
state_drawUI_intro,
#ifdef AVOID_UB
NULL,
#endif
};
GameModeIncomplete GameModeDemo = {
MODE_FLAG_NONE,
state_init_demo,
state_step_demo,
NULL,
state_drawUI_demo,
#ifdef AVOID_UB
NULL,
#endif
};
GameMode* gameModeMap[] = {
(GameMode*) gameModeBlueprints,
(GameMode*) D_800776FC,
(GameMode*) D_80077710,
(GameMode*) D_80077724,
(GameMode*) D_80077774,
(GameMode*) D_80077738,
(GameMode*) D_8007774C,
(GameMode*) D_80077760,
(GameMode*) D_80077788,
(GameMode*) D_8007779C,
(GameMode*) D_800777B0,
(GameMode*) D_800777C4,
(GameMode*) D_800777D8,
(GameMode*) D_800777EC,
(GameMode*) D_80077800,
(GameMode*) D_80077814,
(GameMode*) D_80077828,
(GameMode*) D_8007783C,
NULL,
NULL,
(GameMode*) &GameModeStartup,
(GameMode*) &GameModeLogos,
(GameMode*) &GameModeTitleScreen,
(GameMode*) &GameModeEnterDemoWorld,
(GameMode*) &GameModeWorld,
(GameMode*) &GameModeChangeMap,
(GameMode*) &GameModeGameOver,
(GameMode*) &GameModeEnterWorld,
(GameMode*) &GameModeBattle,
(GameMode*) &GameModeEndBattle,
(GameMode*) &GameModePause,
(GameMode*) &GameModeUnpause,
(GameMode*) &GameModeLanguageSelect,
(GameMode*) &GameModeEndLanguageSelect,
(GameMode*) &GameModeFileSelect,
(GameMode*) &GameModeEndFileSelect,
(GameMode*) &GameModeIntro,
(GameMode*) &GameModeDemo,
};
SHIFT_BSS s16 gameMode;
GameMode* set_game_mode_slot(s32 i, GameMode* mode);
SHIFT_BSS s16 CurGameMode;
void set_game_mode(s16 mode) {
gameMode = mode;
CurGameMode = mode;
set_game_mode_slot(0, gameModeMap[mode]);
}
s16 get_game_mode(void) {
return gameMode;
return CurGameMode;
}

55
src/game_modes.h Normal file
View File

@ -0,0 +1,55 @@
#ifndef _GAME_MODES_H_
#define _GAME_MODES_H_
#include "common.h"
// These flags are mostly unused. Not enough context to discern their original purpose.
enum GameModeFlags {
MODE_FLAG_NONE = 0,
MODE_FLAG_INITIALIZED = (1 << 0), // Set when the mod is initialized
MODE_FLAG_STEP_NOT_DONE = (1 << 1), // Turned off after the first step is done
MODE_FLAG_4 = (1 << 2),
MODE_FLAG_8 = (1 << 3),
MODE_FLAG_10 = (1 << 4),
MODE_FLAG_RENDER_AUX_SET = (1 << 5), // Set when the renderAux function is set
};
enum GameModeIDs {
GAME_MODE_STARTUP = 0,
GAME_MODE_LOGOS = 1,
GAME_MODE_TITLE_SCREEN = 2,
GAME_MODE_ENTER_DEMO_WORLD = 3,
GAME_MODE_WORLD = 4,
GAME_MODE_CHANGE_MAP = 5,
GAME_MODE_GAME_OVER = 6,
GAME_MODE_ENTER_WORLD = 7,
GAME_MODE_BATTLE = 8,
GAME_MODE_END_BATTLE = 9,
GAME_MODE_PAUSE = 10,
GAME_MODE_UNPAUSE = 11,
GAME_MODE_LANGUAGE_SELECT = 12,
GAME_MODE_END_LANGUAGE_SELECT = 13,
GAME_MODE_FILE_SELECT = 14,
GAME_MODE_END_FILE_SELECT = 15,
GAME_MODE_INTRO = 16,
GAME_MODE_DEMO = 17,
};
typedef struct GameMode {
/* 0x00 */ u16 flags;
/* 0x04 */ void (*init)(void);
/* 0x08 */ void (*step)(void);
/* 0x0C */ UNK_FUN_PTR(unusedFunc);
/* 0x10 */ void (*render)(void);
/* 0x14 */ void (*renderAux)(void); ///< @see state_render_frontUI
} GameMode; // size = 0x18
void set_game_mode(s16 mode);
void clear_game_modes(void);
GameMode* set_game_mode_slot(s32 i, GameMode* mode);
void game_mode_set_fpDrawAuxUI(s32 i, void (*fn)(void));
void step_current_game_mode(void);
void state_render_backUI(void);
void state_render_frontUI(void);
#endif

View File

@ -1,116 +1,123 @@
#include "common.h"
#include "game_modes.h"
SHIFT_BSS GameMode gMainGameState[2]; // TODO rename
SHIFT_BSS GameMode gMainGameMode[2];
void state_delegate_NOP(void) {
void mode_default_nop(void) {
}
void clear_game_modes(void) {
GameMode* gameMode;
s32 i;
for (gameMode = gMainGameState, i = 0; i < ARRAY_COUNT(gMainGameState); i++, gameMode++) {
gameMode->flags = 0;
for (gameMode = gMainGameMode, i = 0; i < ARRAY_COUNT(gMainGameMode); i++, gameMode++) {
gameMode->flags = MODE_FLAG_NONE;
}
}
GameMode* set_next_game_mode(GameMode* arg0) {
// Function is unused.
GameMode* set_next_game_mode(GameMode* mode) {
GameMode* gameMode;
s32 i;
for (gameMode = gMainGameState, i = 0; i < ARRAY_COUNT(gMainGameState); i++, gameMode++) {
if (gameMode->flags == 0) {
for (gameMode = gMainGameMode, i = 0; i < ARRAY_COUNT(gMainGameMode); i++, gameMode++) {
if (gameMode->flags == MODE_FLAG_NONE) {
break;
}
}
ASSERT(i < ARRAY_COUNT(gMainGameState));
ASSERT(i < ARRAY_COUNT(gMainGameMode));
gameMode->flags = 1 | 2;
gameMode->init = arg0->init;
gameMode->step = arg0->step;
gameMode->render = arg0->render;
gameMode->unk_0C = NULL;
gameMode->flags = MODE_FLAG_INITIALIZED | MODE_FLAG_STEP_NOT_DONE;
gameMode->init = mode->init;
gameMode->step = mode->step;
gameMode->render = mode->render;
gameMode->unusedFunc = NULL;
if (gameMode->init == NULL) {
gameMode->init = state_delegate_NOP;
gameMode->init = mode_default_nop;
}
if (gameMode->step == NULL) {
gameMode->step = state_delegate_NOP;
gameMode->step = mode_default_nop;
}
if (gameMode->unk_0C == NULL) {
gameMode->unk_0C = state_delegate_NOP;
if (gameMode->unusedFunc == NULL) {
gameMode->unusedFunc = mode_default_nop;
}
if (gameMode->render == NULL) {
gameMode->render = state_delegate_NOP;
gameMode->render = mode_default_nop;
}
gameMode->renderAux = state_delegate_NOP;
gameMode->renderAux = mode_default_nop;
gameMode->init();
return gameMode;
}
GameMode* set_game_mode_slot(s32 i, GameMode* mode) {
GameMode* gameMode = &gMainGameState[i];
GameMode* gameMode = &gMainGameMode[i];
ASSERT(i < ARRAY_COUNT(gMainGameState));
ASSERT(i < ARRAY_COUNT(gMainGameMode));
gameMode->flags = 2 | 1;
gameMode->flags = MODE_FLAG_INITIALIZED | MODE_FLAG_STEP_NOT_DONE;
gameMode->init = mode->init;
gameMode->step = mode->step;
gameMode->render = mode->render;
gameMode->unk_0C = NULL;
if (gameMode->init == NULL) gameMode->init = state_delegate_NOP;
if (gameMode->step == NULL) gameMode->step = state_delegate_NOP;
if (gameMode->unk_0C == NULL) gameMode->unk_0C = state_delegate_NOP;
if (gameMode->render == NULL) gameMode->render = state_delegate_NOP;
gameMode->unusedFunc = NULL;
if (gameMode->init == NULL) gameMode->init = mode_default_nop;
if (gameMode->step == NULL) gameMode->step = mode_default_nop;
if (gameMode->unusedFunc == NULL) gameMode->unusedFunc = mode_default_nop;
if (gameMode->render == NULL) gameMode->render = mode_default_nop;
gameMode->renderAux = state_delegate_NOP;
gameMode->renderAux = mode_default_nop;
gameMode->init();
return gameMode;
}
void game_mode_set_fpDrawAuxUI(s32 i, void (*fn)(void)) {
GameMode* gameMode = &gMainGameState[i];
GameMode* gameMode = &gMainGameMode[i];
ASSERT(i < ARRAY_COUNT(gMainGameState));
ASSERT(i < ARRAY_COUNT(gMainGameMode));
gameMode->renderAux = fn;
gameMode->flags |= 0x20;
gameMode->flags |= MODE_FLAG_RENDER_AUX_SET;
if (fn == NULL) {
gameMode->renderAux = state_delegate_NOP;
gameMode->renderAux = mode_default_nop;
}
}
void func_80112DD4(s32 i) {
gMainGameState[i].flags |= 4;
// Unused
void set_game_mode_flag_4(s32 i) {
gMainGameMode[i].flags |= MODE_FLAG_4;
}
void func_80112DFC(s32 i) {
gMainGameState[i].flags |= 8;
// Unused
void set_game_mode_flag_8(s32 i) {
gMainGameMode[i].flags |= MODE_FLAG_8;
}
void func_80112E24(s32 i) {
gMainGameState[i].flags &= ~0x1C;
// Unused
void clear_game_mode_unk_flags(s32 i) {
gMainGameMode[i].flags &= ~(MODE_FLAG_4 | MODE_FLAG_8 | MODE_FLAG_10);
}
void func_80112E4C(s32 i) {
gMainGameState[i].flags &= ~0x0C;
gMainGameState[i].flags |= 0x10;
// Unused
void set_game_mode_flag_10(s32 i) {
gMainGameMode[i].flags &= ~(MODE_FLAG_4 | MODE_FLAG_8);
gMainGameMode[i].flags |= MODE_FLAG_10;
}
void step_current_game_mode(void) {
GameMode* gameMode = gMainGameState;
GameMode* gameMode = gMainGameMode;
s32 i;
for (i = 0; i < ARRAY_COUNT(gMainGameState); i++, gameMode++) {
if (gameMode->flags != 0) {
if (!(gameMode->flags & 4)) {
if (!(gameMode->flags & 8)) {
gameMode->flags &= ~2;
for (i = 0; i < ARRAY_COUNT(gMainGameMode); i++, gameMode++) {
if (gameMode->flags != MODE_FLAG_NONE) {
if (!(gameMode->flags & MODE_FLAG_4)) {
if (!(gameMode->flags & MODE_FLAG_8)) {
gameMode->flags &= ~MODE_FLAG_STEP_NOT_DONE;
gameMode->step();
}
}
@ -118,15 +125,16 @@ void step_current_game_mode(void) {
}
}
// Unused
void state_do_unk(void) {
GameMode* gameMode = gMainGameState;
GameMode* gameMode = gMainGameMode;
s32 i;
for (i = 0; i < ARRAY_COUNT(gMainGameState); i++, gameMode++) {
if (gameMode->flags != 0) {
if (!(gameMode->flags & 4)) {
if (!(gameMode->flags & 0x10)) {
gameMode->unk_0C();
for (i = 0; i < ARRAY_COUNT(gMainGameMode); i++, gameMode++) {
if (gameMode->flags != MODE_FLAG_NONE) {
if (!(gameMode->flags & MODE_FLAG_4)) {
if (!(gameMode->flags & MODE_FLAG_10)) {
gameMode->unusedFunc();
}
}
}
@ -134,13 +142,13 @@ void state_do_unk(void) {
}
void state_render_backUI(void) {
GameMode* gameMode = gMainGameState;
GameMode* gameMode = gMainGameMode;
s32 i;
for (i = 0; i < ARRAY_COUNT(gMainGameState); i++, gameMode++) {
if (gameMode->flags != 0) {
if (!(gameMode->flags & 4)) {
if (!(gameMode->flags & 0x10)) {
for (i = 0; i < ARRAY_COUNT(gMainGameMode); i++, gameMode++) {
if (gameMode->flags != MODE_FLAG_NONE) {
if (!(gameMode->flags & MODE_FLAG_4)) {
if (!(gameMode->flags & MODE_FLAG_10)) {
gameMode->render();
}
}
@ -149,14 +157,14 @@ void state_render_backUI(void) {
}
void state_render_frontUI(void) {
GameMode* gameMode = gMainGameState;
GameMode* gameMode = gMainGameMode;
s32 i;
for (i = 0; i < ARRAY_COUNT(gMainGameState); i++, gameMode++) {
if (gameMode->flags != 0) {
if (!(gameMode->flags & 4)) {
if (!(gameMode->flags & 2)) {
if (gameMode->flags & 0x20) {
for (i = 0; i < ARRAY_COUNT(gMainGameMode); i++, gameMode++) {
if (gameMode->flags != MODE_FLAG_NONE) {
if (!(gameMode->flags & MODE_FLAG_4)) {
if (!(gameMode->flags & MODE_FLAG_STEP_NOT_DONE)) {
if (gameMode->flags & MODE_FLAG_RENDER_AUX_SET) {
gameMode->renderAux();
}
}
@ -165,12 +173,12 @@ void state_render_frontUI(void) {
}
// re-initialization needed - evidence of inlining? or just copy/pasting?
gameMode = &gMainGameState[0];
for (i = 0; i < ARRAY_COUNT(gMainGameState); i++, gameMode++) {
if (gameMode->flags != 0) {
if (!(gameMode->flags & 4)) {
if (!(gameMode->flags & 2)) {
if (gameMode->flags & 0x10) {
gameMode = &gMainGameMode[0];
for (i = 0; i < ARRAY_COUNT(gMainGameMode); i++, gameMode++) {
if (gameMode->flags != MODE_FLAG_NONE) {
if (!(gameMode->flags & MODE_FLAG_4)) {
if (!(gameMode->flags & MODE_FLAG_STEP_NOT_DONE)) {
if (gameMode->flags & MODE_FLAG_10) {
gameMode->render();
}
}

View File

@ -4,6 +4,7 @@
#include "hud_element.h"
#include "sprite.h"
#include "overlay.h"
#include "game_modes.h"
SHIFT_BSS s32 gOverrideFlags;
SHIFT_BSS s32 timeFreezeMode;

View File

@ -2,6 +2,7 @@
#include "message_ids.h"
#include "sprite.h"
#include "pause_common.h"
#include "game_modes.h"
#include "sprite/npc/Goombaria.h"
#include "sprite/npc/WorldGoombario.h"
#include "sprite/npc/Goompa.h"

View File

@ -5,6 +5,7 @@
#include "sprite.h"
#include "battle/battle.h"
#include "model.h"
#include "game_modes.h"
extern u16 gFrameBuf0[];
extern u16 gFrameBuf1[];
@ -203,7 +204,7 @@ void state_step_end_battle(void) {
if (D_800A0908 != 0) {
set_time_freeze_mode(D_800A0908);
}
set_game_mode(GAME_MODE_CHANGE_MAP);
set_game_mode(GAME_MODE_WORLD);
}
}
}

View File

@ -2,6 +2,7 @@
#include "hud_element.h"
#include "battle/battle.h"
#include "sprite.h"
#include "game_modes.h"
typedef struct DemoSceneData {
/* 0x0 */ s16 sceneType;

View File

@ -5,6 +5,7 @@
#include "hud_element.h"
#include "sprite.h"
#include "model.h"
#include "game_modes.h"
#if VERSION_JP
// TODO: split the filemenu segment
@ -369,7 +370,7 @@ void state_step_exit_language_select(void) {
update_encounters();
update_effects();
enable_player_input();
set_game_mode(GAME_MODE_CHANGE_MAP);
set_game_mode(GAME_MODE_WORLD);
set_screen_overlay_params_front(OVERLAY_NONE, -1.0f);
break;
}
@ -432,7 +433,7 @@ void state_step_exit_file_select(void) {
}
break;
case 6:
set_game_mode(GAME_MODE_WORLD);
set_game_mode(GAME_MODE_ENTER_WORLD);
break;
}
}

View File

@ -1,6 +1,7 @@
#include "common.h"
#include "hud_element.h"
#include "sprite.h"
#include "game_modes.h"
SHIFT_BSS s32 D_800A0950;
SHIFT_BSS s16 D_800A0954;

View File

@ -4,6 +4,7 @@
#include "hud_element.h"
#include "sprite.h"
#include "nu/nusys.h"
#include "game_modes.h"
void appendGfx_intro_logos(void);

View File

@ -5,6 +5,7 @@
#include "hud_element.h"
#include "sprite.h"
#include "model.h"
#include "game_modes.h"
#if VERSION_JP
// TODO: split this segment
@ -249,7 +250,7 @@ void state_step_unpause(void) {
update_player();
update_effects();
enable_player_input();
set_game_mode(GAME_MODE_CHANGE_MAP);
set_game_mode(GAME_MODE_WORLD);
break;
}
}

View File

@ -2,6 +2,7 @@
#include "hud_element.h"
#include "fio.h"
#include "sprite.h"
#include "game_modes.h"
void state_init_startup(void) {
gOverrideFlags |= GLOBAL_OVERRIDES_8;

View File

@ -2,6 +2,7 @@
#include "nu/nusys.h"
#include "hud_element.h"
#include "sprite.h"
#include "game_modes.h"
#if VERSION_JP
#define TITLE_WIDTH 272

View File

@ -1,5 +1,6 @@
#include "functions.h"
#include "npc.h"
#include "game_modes.h"
void state_world_draw_aux_ui(void);

View File

@ -1,6 +1,7 @@
#include "gv_01.h"
#include "sprite.h"
#include "hud_element.h"
#include "game_modes.h"
#include "sprite/player.h"
#include "world/common/entity/Pipe.inc.c"

View File

@ -1,6 +1,7 @@
#include "kmr_02.h"
#include "effects.h"
#include "model.h"
#include "game_modes.h"
#include "sprite/player.h"
extern EvtScript N(EVS_NpcAI_Eldstar_02);

View File

@ -1,5 +1,6 @@
#include "kmr_24.h"
#include "fio.h"
#include "game_modes.h"
API_CALLABLE(N(ExitGame)) {
s16 progress;
@ -17,7 +18,7 @@ API_CALLABLE(N(ExitGame)) {
script->functionTemp[1] = progress;
return ApiStatus_BLOCK;
} else {
set_game_mode(0);
set_game_mode(GAME_MODE_STARTUP);
return ApiStatus_DONE2;
}
}

View File

@ -286,7 +286,7 @@ dlabel D_800A08E8
dlabel D_800A08EC
.space 4
dlabel gameMode
dlabel CurGameMode
.space 4
dlabel D_800A08F4

View File

@ -168,7 +168,7 @@ dlabel bEntityBlueprint
dlabel D_801516FC
.space 4
dlabel gMainGameState
dlabel gMainGameMode
.space 0x00000040
dlabel gCurrentTextureHeader

View File

@ -223,7 +223,7 @@ dlabel D_800A08E8
dlabel D_800A08EC
.space 4
dlabel gameMode
dlabel CurGameMode
.space 0x00000010
dlabel D_800A0900

View File

@ -170,7 +170,7 @@ dlabel bEntityBlueprint
dlabel D_801516FC
.space 4
dlabel gMainGameState
dlabel gMainGameMode
.space 0x00000040
dlabel gCurrentTextureHeader

View File

@ -280,7 +280,7 @@ dlabel D_800A08E8
dlabel D_800A08EC
.space 4
dlabel gameMode
dlabel CurGameMode
.space 4
dlabel D_800A08F4

View File

@ -170,7 +170,7 @@ dlabel bEntityBlueprint
dlabel D_801516FC
.space 4
dlabel gMainGameState
dlabel gMainGameMode
.space 0x00000040
dlabel gCurrentTextureHeader

View File

@ -220,9 +220,9 @@ state_drawUI_enter_world = 0x800360FC; // type:func rom:0x114FC
state_init_change_map = 0x80036130; // type:func rom:0x11530
state_step_change_map = 0x8003617C; // type:func rom:0x1157C
state_drawUI_change_map = 0x800363FC; // type:func rom:0x117FC
func_80036430 = 0x80036430; // type:func rom:0x11830
func_8003646C = 0x8003646C; // type:func rom:0x1186C
func_80036640 = 0x80036640; // type:func rom:0x11A40
state_init_game_over = 0x80036430; // type:func rom:0x11830
state_step_game_over = 0x8003646C; // type:func rom:0x1186C
state_drawUI_game_over = 0x80036640; // type:func rom:0x11A40
state_init_intro = 0x80036650; // type:func rom:0x11A50
state_step_intro = 0x80036854; // type:func rom:0x11C54
state_drawUI_intro = 0x80036DE0; // type:func rom:0x121E0
@ -1362,24 +1362,24 @@ beforeFlag = 0x800773FC; // rom:0x527FC
nuSiCallBackList = 0x80077400; // rom:0x52800
gCurrentCameraID = 0x80077410; // rom:0x52810
D_80077420 = 0x80077420; // rom:0x52820
gameModeBlueprints = 0x800776E8; // rom:0x52AE8
D_800776FC = 0x800776FC; // rom:0x52AFC
D_80077710 = 0x80077710; // rom:0x52B10
D_80077724 = 0x80077724; // rom:0x52B24
D_80077738 = 0x80077738; // rom:0x52B38
D_8007774C = 0x8007774C; // rom:0x52B4C
D_80077760 = 0x80077760; // rom:0x52B60
D_80077774 = 0x80077774; // rom:0x52B74
D_80077788 = 0x80077788; // rom:0x52B88
D_8007779C = 0x8007779C; // rom:0x52B9C
D_800777B0 = 0x800777B0; // rom:0x52BB0
D_800777C4 = 0x800777C4; // rom:0x52BC4
D_800777D8 = 0x800777D8; // rom:0x52BD8
D_800777EC = 0x800777EC; // rom:0x52BEC
D_80077800 = 0x80077800; // rom:0x52C00
D_80077814 = 0x80077814; // rom:0x52C14
D_80077828 = 0x80077828; // rom:0x52C28
D_8007783C = 0x8007783C; // rom:0x52C3C
GameModeStartup = 0x800776E8; // rom:0x52AE8
GameModeLogos = 0x800776FC; // rom:0x52AFC
GameModeTitleScreen = 0x80077710; // rom:0x52B10
GameModeEnterDemoWorld = 0x80077724; // rom:0x52B24
GameModeChangeMap = 0x80077738; // rom:0x52B38
GameModeGameOver = 0x8007774C; // rom:0x52B4C
GameModeEnterWorld = 0x80077760; // rom:0x52B60
GameModeWorld = 0x80077774; // rom:0x52B74
GameModeBattle = 0x80077788; // rom:0x52B88
GameModeEndBattle = 0x8007779C; // rom:0x52B9C
GameModePause = 0x800777B0; // rom:0x52BB0
GameModeUnpause = 0x800777C4; // rom:0x52BC4
GameModeLanguageSelect = 0x800777D8; // rom:0x52BD8
GameModeEndLanguageSelect = 0x800777EC; // rom:0x52BEC
GameModeFileSelect = 0x80077800; // rom:0x52C00
GameModeEndFileSelect = 0x80077814; // rom:0x52C14
GameModeIntro = 0x80077828; // rom:0x52C28
GameModeDemo = 0x8007783C; // rom:0x52C3C
gameModeMap = 0x80077850; // rom:0x52C50
bFrameBuffers = 0x800778A0; // rom:0x52CA0
D_800778AC = 0x800778AC; // rom:0x52CAC
@ -3947,15 +3947,15 @@ set_standard_shadow_scale = 0x8011285C; // type:func rom:0xA8F5C
set_npc_shadow_scale = 0x80112900; // type:func rom:0xA9000
set_peach_shadow_scale = 0x801129D4; // type:func rom:0xA90D4
is_block_on_ground = 0x80112B20; // type:func rom:0xA9220
state_delegate_NOP = 0x80112B90; // type:func rom:0xA9290
mode_default_nop = 0x80112B90; // type:func rom:0xA9290
clear_game_modes = 0x80112B98; // type:func rom:0xA9298
set_next_game_mode = 0x80112BBC; // type:func rom:0xA92BC
set_game_mode_slot = 0x80112CA8; // type:func rom:0xA93A8
game_mode_set_fpDrawAuxUI = 0x80112D84; // type:func rom:0xA9484
func_80112DD4 = 0x80112DD4; // type:func rom:0xA94D4
func_80112DFC = 0x80112DFC; // type:func rom:0xA94FC
func_80112E24 = 0x80112E24; // type:func rom:0xA9524
func_80112E4C = 0x80112E4C; // type:func rom:0xA954C
set_game_mode_flag_3 = 0x80112DD4; // type:func rom:0xA94D4
set_game_mode_flag_4 = 0x80112DFC; // type:func rom:0xA94FC
clear_game_mode_unk_flags = 0x80112E24; // type:func rom:0xA9524
set_game_mode_flag_5 = 0x80112E4C; // type:func rom:0xA954C
step_current_game_mode = 0x80112E78; // type:func rom:0xA9578
state_do_unk = 0x80112EEC; // type:func rom:0xA95EC
state_render_backUI = 0x80112F58; // type:func rom:0xA9658
@ -4819,7 +4819,7 @@ wEntityBlueprint = 0x80151668; // rom:0xE7D68
start_script = 0x802C33E0; // type:func rom:0xE7D90
bEntityBlueprint = 0x801516E8; // rom:0xE7DE8
D_801516FC = 0x801516FC; // rom:0xE7DFC
gMainGameState = 0x80151700; // rom:0xE7E00
gMainGameMode = 0x80151700; // rom:0xE7E00
gCurrentTileDescriptor = 0x80151740; // rom:0xE7E40
wModelList = 0x80151770; // rom:0xE7E70
start_script_in_group = 0x802C35D0; // type:func rom:0xE7F80