Skip to content

Commit

Permalink
simplify game modes and remove language select
Browse files Browse the repository at this point in the history
  • Loading branch information
z64a committed May 30, 2024
1 parent 5f087ea commit 5522044
Show file tree
Hide file tree
Showing 22 changed files with 246 additions and 1,453 deletions.
2 changes: 1 addition & 1 deletion include/common_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -1425,7 +1425,7 @@ typedef struct GameStatus {
/* 0x098 */ Vec3f playerPos;
/* 0x0A4 */ f32 playerYaw;
/* 0x0A8 */ s8 introPart;
/* 0x0A9 */ s8 unk_A9; // selected language?
/* 0x0A9 */ s8 unk_A9;
/* 0x0AA */ s8 demoBattleFlags;
/* 0x0AB */ u8 soundOutputMode;
/* 0x0AC */ s8 startupState; // used for various startup states like logos, title screen, intro, and demo
Expand Down
26 changes: 7 additions & 19 deletions include/filemenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,20 @@ enum {
FILE_MENU_CONFIRM = 1, // confirmation prompt is open
FILE_MENU_MESSAGE = 2, // message is displayed, e.g. "File X has been deleted."
FILE_MENU_INPUT_NAME = 3, // "Enter a file name!" screen
FILE_MENU_LANGUAGES = 4,
};

enum {
FM_MAIN_SELECT_FILE = 0, // choose which file to load
FM_MAIN_SELECT_DELETE = 1, // choose which file to delete
#if !VERSION_PAL
FM_MAIN_SELECT_LANGUAGE = 2,
#endif
FM_MAIN_SELECT_COPY_FROM,
FM_MAIN_SELECT_COPY_TO,
FM_MAIN_SELECT_COPY_FROM = 2,
FM_MAIN_SELECT_COPY_TO = 3,
FM_CONFIRM_DELETE = 0,
FM_CONFIRM_LANGUAGE = 1,
FM_CONFIRM_CREATE = 2,
FM_CONFIRM_COPY = 3, // unused
FM_CONFIRM_START = 4,
FM_CONFIRM_CREATE = 1,
FM_CONFIRM_COPY = 2, // unused
FM_CONFIRM_START = 3,
FM_MESSAGE_DELETED = 0,
#if !VERSION_PAL
FM_MESSAGE_LANGUAGE = 1,
#endif
FM_MESSAGE_COPIED,
FM_MESSAGE_CREATED,
FM_MESSAGE_COPIED = 1,
FM_MESSAGE_CREATED = 2,
FM_INPUT_CHARSET_A = 0,
FM_INPUT_CHARSET_B = 1,
};
Expand Down Expand Up @@ -105,10 +97,6 @@ WINDOW_UPDATE_FUNC(unused_main_menu_window_darkening);

WINDOW_UPDATE_FUNC(filemenu_update_show_title);

#if VERSION_PAL
WINDOW_UPDATE_FUNC(filemenu_selectlanguage_80248018);
#endif

void filemenu_draw_file_name(u8*, s32, s32, s32, s32, s32, s32, s32);
void filemenu_draw_contents_title(MenuPanel*, s32, s32, s32, s32, s32, s32);
void filemenu_draw_contents_stereo(MenuPanel*, s32, s32, s32, s32, s32, s32);
Expand Down
8 changes: 0 additions & 8 deletions include/functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ void copy_matrix(Matrix4f src, Matrix4f dest);
Shadow* get_shadow_by_index(s32 index);
s32 get_time_freeze_mode(void);
void render_player_model(void);
s16 get_game_mode(void);
s32 is_picking_up_item(void);

f32 integrate_gravity(void);
Expand Down Expand Up @@ -731,12 +730,6 @@ void state_drawUI_pause(void);
void state_init_unpause(void);
void state_step_unpause(void);
void state_drawUI_unpause(void);
void state_init_language_select(void);
void state_step_language_select(void);
void state_drawUI_language_select(void);
void state_init_exit_language_select(void);
void state_step_exit_language_select(void);
void state_drawUI_exit_language_select(void);
void state_init_file_select(void);
void state_step_file_select(void);
void state_drawUI_file_select(void);
Expand Down Expand Up @@ -1094,7 +1087,6 @@ void btl_save_world_cameras(void);
void load_battle_section(void);
void btl_update(void);
void update_item_entities(void);
void iterate_models(void);
void restore_map_collision_data(void);
void mdl_load_all_textures(struct ModelNode* model, s32 romOffset, s32 size);
void mdl_calculate_model_sizes(void);
Expand Down
211 changes: 6 additions & 205 deletions src/filemenu/filemenu_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,13 @@ extern MenuPanel filemenu_main_menuBP;
extern MenuPanel filemenu_yesno_menuBP;
extern MenuPanel filemenu_info_menuBP;
extern MenuPanel filemenu_createfile_menuBP;
extern MenuPanel filemenu_selectlanguage_menuBP;

HudScript* filemenu_cursor_hudElemScripts[] = { &HES_AnimatedCursorHand };
MenuPanel* filemenu_menus[] = {
&filemenu_main_menuBP,
&filemenu_yesno_menuBP,
&filemenu_info_menuBP,
&filemenu_createfile_menuBP,
#if VERSION_PAL
&filemenu_selectlanguage_menuBP,
#endif
};
s32 filemenu_cursor_posX = SCREEN_WIDTH / 2;
s32 filemenu_cursor_posY = -SCREEN_HEIGHT / 2;
Expand All @@ -32,9 +28,6 @@ s32 filemenu_cursor_targetY = -SCREEN_HEIGHT / 2;
s32 filemenu_cursorGoalAlpha = 0;
s32 filemenu_cursorGoalAlpha2 = 0;
s32 D_80249BB0 = TRUE;
#if !VERSION_PAL
s32 D_80249BB4 = 0;
#endif
s32 D_80249BB8 = 0;
s16 D_80249BBC[16] = { 315, 303, 283, 260, 235, 210, 185, 160, 135, 110, 85, 60, 37, 17, 5, 0 };
s16 D_80249BDC[16] = { 315, 303, 283, 260, 235, 210, 185, 160, 135, 110, 85, 60, 37, 17, 5, 0 };
Expand All @@ -53,50 +46,6 @@ s16 D_80249D14[16] = { 0, 2, 9, 21, 34, 48, 62, 77, 91, 105, 120, 134, 148, 161,
s16 D_80249D34[10] = { 185, 160, 135, 110, 85, 60, 37, 17, 5, 0 };
s16 D_80249D48[10] = { 0, 5, 17, 37, 60, 85, 110, 135, 160, 185};

#if VERSION_PAL
s16 D_filemenu_8024EB5C[] = {
210,
182,
162,
145,
130,
117,
105,
92,
80,
67,
55,
42,
30,
18,
8,
2,
0,
};

s16 D_filemenu_8024EB80[] = {
-2,
-8,
-18,
-30,
-42,
-55,
-67,
-80,
-92,
-105,
-117,
-130,
-142,
-155,
-167,
-180,
-192,
-205,
};
#endif

s32 D_80249D4C = 0; // padding?
Vp D_80249D60 = {
.vp = {
.vscale = { 640, 480, 511, 0},
Expand Down Expand Up @@ -212,9 +161,7 @@ void filemenu_set_cursor_alpha(s32 alpha) {
void filemenu_set_cursor_goal_pos(s32 windowID, s32 posX, s32 posY) {
Window* window = &gWindows[windowID];

if (D_80249BB0
|| get_game_mode() == GAME_MODE_END_FILE_SELECT
|| get_game_mode() == GAME_MODE_END_LANGUAGE_SELECT) {
if (D_80249BB0 || get_game_mode() == GAME_MODE_END_FILE_SELECT) {
if (D_80249BB0) {
s32 i;

Expand Down Expand Up @@ -785,106 +732,6 @@ void filemenu_update_hidden_name_confirm(
}
}

#if VERSION_PAL
void filemenu_update_pal_80247f40(
s32 windowIndex,
s32* flags,
s32* posX, s32* posY, s32* posZ,
f32* scaleX, f32* scaleY,
f32* rotX, f32* rotY, f32* rotZ,
s32* darkening,
s32* opacity
) {
Window* window = &gWindows[windowIndex];
s32 var_a1 = window->updateCounter;
s32 var_a3 = 0;
s32 var_v1;

switch (windowIndex) {
case WIN_FILES_SLOT0_BODY:
var_a3 = 0;
break;
case WIN_FILES_SLOT1_BODY:
var_a3 = 1;
break;
case WIN_FILES_SLOT2_BODY:
var_a3 = 2;
break;
case WIN_FILES_SLOT3_BODY:
var_a3 = 3;
break;
}
var_v1 = gCurrentLanguage;
var_v1 -= var_a3;
var_v1 = abs(var_v1);

var_a1 -= (var_v1 * 3);
if (var_a1 < 0) {
var_a1 = 0;
}
if (var_a1 == 0) {
window->flags &= ~WINDOW_FLAG_HIDDEN;
}
if (var_a1 < ARRAY_COUNT(D_filemenu_8024EB5C)) {
*posX -= D_filemenu_8024EB5C[var_a1];
} else {
*posX -= D_filemenu_8024EB5C[ARRAY_COUNT(D_filemenu_8024EB5C) - 1];
window->flags &= ~WINDOW_FLAG_INITIAL_ANIMATION;
}
}

void filemenu_selectlanguage_80248018(
s32 windowIndex,
s32* flags,
s32* posX, s32* posY, s32* posZ,
f32* scaleX, f32* scaleY,
f32* rotX, f32* rotY, f32* rotZ,
s32* darkening,
s32* opacity
) {
Window* window = &gWindows[windowIndex];
s32 var_a1 = window->updateCounter;
s32 var_a3 = 0;
s32 var_v1;

switch (windowIndex) {
case WIN_FILES_SLOT0_BODY:
var_a3 = 0;
break;
case WIN_FILES_SLOT1_BODY:
var_a3 = 1;
break;
case WIN_FILES_SLOT2_BODY:
var_a3 = 2;
break;
case WIN_FILES_SLOT3_BODY:
var_a3 = 3;
break;
}
var_v1 = gCurrentLanguage;
var_v1 -= var_a3;
if (var_v1 < 0) {
var_v1 = -var_v1;
}
var_a1 -= (var_v1 * 3);
if (var_a1 < 0) {
var_a1 = 0;
}
if (var_a1 < ARRAY_COUNT(D_filemenu_8024EB80)) {
*posX -= D_filemenu_8024EB80[var_a1];
} else {
*posX -= D_filemenu_8024EB80[ARRAY_COUNT(D_filemenu_8024EB80) - 1];
window->flags &= ~WINDOW_FLAG_INITIAL_ANIMATION;
window->flags |= WINDOW_FLAG_HIDDEN;
}

// TODO: ARRAY_COUNT?
if (var_a1 >= 0x10) {
filemenu_cursor_alpha = 0;
}
}
#endif

void filemenu_draw_cursor(MenuPanel* menu, s32 baseX, s32 baseY, s32 width, s32 height, s32 opacity, s32 darkening) {
s32 temp_a1;

Expand Down Expand Up @@ -1047,53 +894,10 @@ void filemenu_init(s32 arg0) {
}
setup_pause_menu_tab(filemenu_common_windowBPs, ARRAY_COUNT(filemenu_common_windowBPs));

#if VERSION_PAL
if (arg0 != 2) {
filemenu_currentMenu = FILE_MENU_MAIN;
menu = filemenu_menus[FILE_MENU_MAIN];
menu->page = filemenu_currentMenu;
func_PAL_8002B574();

if (menu->page == 0) {
fio_load_globals();
if (gSaveGlobals.lastFileSelected >= 4) {
gSaveGlobals.lastFileSelected = 0;
}
gGameStatusPtr->saveSlot = gSaveGlobals.lastFileSelected;
}

filemenu_set_selected(menu, (gGameStatusPtr->saveSlot & 1) * 2, gGameStatusPtr->saveSlot >> 1);

panelIt = filemenu_menus;
for (i = 0; i < ARRAY_COUNT(filemenu_menus) - 1; i++, panelIt++) {
if ((*panelIt)->fpInit != NULL) {
(*panelIt)->fpInit((*panelIt));
}
}
update_window_hierarchy(WIN_PAUSE_DECRIPTION, 64);
} else {
filemenu_currentMenu = FILE_MENU_LANGUAGES;
filemenu_set_selected(filemenu_menus[FILE_MENU_LANGUAGES], 0, gCurrentLanguage);

panelIt = filemenu_menus;
for (i = 0; i < ARRAY_COUNT(filemenu_menus); i++, panelIt++) {
if (i == 4) {
if ((*panelIt)->fpInit != NULL) {
(*panelIt)->fpInit((*panelIt));
}
}
}
update_window_hierarchy(WIN_PAUSE_DECRIPTION, 64);
}
#else
filemenu_currentMenu = FILE_MENU_MAIN;
menu = filemenu_menus[FILE_MENU_MAIN];

if (arg0 == 0) {
menu->state = FM_MAIN_SELECT_FILE;
} else {
menu->state = FM_MAIN_SELECT_LANGUAGE;
}
menu->state = FM_MAIN_SELECT_FILE;

if (menu->state == FM_MAIN_SELECT_FILE) {
for (i = 0; i < ARRAY_COUNT(filemenu_menus); i++) {
Expand All @@ -1109,13 +913,11 @@ void filemenu_init(s32 arg0) {
}
}

if (menu->state == FM_MAIN_SELECT_FILE) { // always the case?
fio_load_globals();
if (gSaveGlobals.lastFileSelected >= 4) {
gSaveGlobals.lastFileSelected = 0;
}
gGameStatusPtr->saveSlot = gSaveGlobals.lastFileSelected;
fio_load_globals();
if (gSaveGlobals.lastFileSelected >= 4) {
gSaveGlobals.lastFileSelected = 0;
}
gGameStatusPtr->saveSlot = gSaveGlobals.lastFileSelected;
}

filemenu_set_selected(menu, (gGameStatusPtr->saveSlot & 1) * 2, gGameStatusPtr->saveSlot >> 1);
Expand All @@ -1127,7 +929,6 @@ void filemenu_init(s32 arg0) {
}
}
update_window_hierarchy(WIN_PAUSE_DECRIPTION, 64);
#endif
}

void filemenu_cleanup(void) {
Expand Down
13 changes: 0 additions & 13 deletions src/filemenu/filemenu_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,6 @@ void filemenu_info_draw_message_contents(
filemenu_draw_message(filemenu_get_menu_message(FILE_MESSAGE_PERIOD_34), baseX + 65, baseY + 18, 255, 0, 0);
#endif
break;
case FM_MESSAGE_LANGUAGE:
filemenu_draw_message(filemenu_get_menu_message(FILE_MESSAGE_28), baseX + 10, baseY + 4, 255, 0, 0);
break;
case FM_MESSAGE_CREATED:
filemenu_draw_message(filemenu_get_menu_message(FILE_MESSAGE_FILE_26), baseX + 10, baseY + 4, 255, 0, 0);
draw_number(filemenu_menus[FILE_MENU_MAIN]->selected + 1, baseX + CREATE_SUCCESS_NUMBER_X, baseY + 6 + NUMBER_OFFSET_Y, DRAW_NUMBER_CHARSET_NORMAL, MSG_PAL_WHITE, 255, DRAW_NUMBER_STYLE_MONOSPACE | DRAW_NUMBER_STYLE_ALIGN_RIGHT);
Expand Down Expand Up @@ -164,20 +161,10 @@ void filemenu_info_handle_input(MenuPanel* menu) {
set_window_update(WIN_FILES_OPTION_RIGHT, (s32)filemenu_update_show_options_bottom);
filemenu_set_selected(menu, 0, 2);
break;
case FILE_MENU_LANGUAGES:
menu->state = FILE_MENU_MAIN;
set_window_update(WIN_FILES_STEREO, (s32)filemenu_update_show_options_left);
set_window_update(WIN_FILES_MONO, (s32)filemenu_update_show_options_right);
set_window_update(WIN_FILES_OPTION_LEFT, (s32)filemenu_update_show_options_bottom);
set_window_update(WIN_FILES_OPTION_RIGHT, (s32)filemenu_update_show_options_bottom);
filemenu_set_selected(menu, 1, 2);
break;
#if !VERSION_PAL
case FILE_MENU_MESSAGE:
menu->state = FILE_MENU_MESSAGE;
filemenu_set_selected(menu, 1, 2);
break;
#endif
}
set_window_update(WIN_FILES_MESSAGE, WINDOW_UPDATE_HIDE);
}
Expand Down
Loading

0 comments on commit 5522044

Please sign in to comment.