Skip to content

Commit

Permalink
rework conflicting save data (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
bates64 authored May 26, 2024
2 parents f1c9438 + 85022d1 commit 6a33ff5
Show file tree
Hide file tree
Showing 47 changed files with 1,902 additions and 1,911 deletions.
75 changes: 6 additions & 69 deletions include/common_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -2049,56 +2049,6 @@ typedef struct PlayerStatus {
/* 0x281 */ char unk_281[7];
} PlayerStatus; // size = 0x288

typedef struct SaveGlobals {
/* 0x00 */ char magicString[16]; /* "Mario Story 006" string */
/* 0x10 */ s8 pad[32]; /* always zero */
/* 0x30 */ s32 crc1;
/* 0x34 */ s32 crc2;
/* 0x38 */ s32 useMonoSound;
/* 0x3C */ u32 lastFileSelected;
/* 0x40 */ s8 reserved[64]; // unused
} SaveGlobals; // size = 0x80

typedef struct FileDisplayData {
/* 0x00 */ s32 timePlayed;
/* 0x04 */ u8 spiritsRescued;
/* 0x05 */ char unk_05[1];
/* 0x06 */ s8 level;
/* 0x07 */ unsigned char filename[8];
/* 0x0F */ char unk_0F[9];
} FileDisplayData; // size = 0x18

typedef struct SaveData {
/* 0x0000 */ char magicString[16]; /* "Mario Story 006" string */
/* 0x0010 */ char modName[28]; /* always non-null for DX saves */
/* 0x002C */ s8 majorVersion;
/* 0x002D */ s8 minorVersion;
/* 0x002E */ s8 patchVersion;
/* 0x002F */ char reserved;
/* 0x0030 */ s32 crc1;
/* 0x0034 */ s32 crc2;
/* 0x0038 */ s32 saveSlot;
/* 0x003C */ s32 saveCount;
/* 0x0040 */ PlayerData player;
/* 0x0468 */ s16 areaID;
/* 0x046A */ s16 mapID;
/* 0x046C */ s16 entryID;
/* 0x046E */ char unk_46E[2];
/* 0x0470 */ s32 enemyDefeatFlags[60][12];
/* 0x0FB0 */ s32 globalFlags[64];
/* 0x10B0 */ s8 globalBytes[512];
/* 0x12B0 */ s32 areaFlags[8];
/* 0x12D0 */ s8 areaBytes[16];
/* 0x12E0 */ s8 debugEnemyContact;
/* 0x12E0 */ b8 debugUnused1;
/* 0x12E0 */ b8 debugUnused2;
/* 0x12E0 */ b8 musicEnabled;
/* 0x12E4 */ char unk_12E4[0x2];
/* 0x12E6 */ Vec3s savePos;
/* 0x12EC */ FileDisplayData metadata;
/* 0x1304 */ char unk_1304[0x7C];
} SaveData; // size = 0x1380

typedef struct Path {
/* 0x00 */ s32 numVectors;
/* 0x04 */ f32* lengths;
Expand Down Expand Up @@ -2132,7 +2082,7 @@ typedef struct MenuPanel {
/* 0x01 */ s8 col;
/* 0x02 */ s8 row;
/* 0x03 */ u8 selected; // usually set to the current value from gridData
/* 0x04 */ s8 page; // filemenu: 0 = select, 1 = delete, 3 = copy from, 4 = copy to, all else = save
/* 0x04 */ s8 state; // filemenu: 0 = select, 1 = delete, 3 = copy from, 4 = copy to, all else = save
/* 0x05 */ s8 numCols;
/* 0x06 */ s8 numRows;
/* 0x07 */ s8 numPages; // unsure
Expand Down Expand Up @@ -2320,24 +2270,8 @@ typedef struct VirtualEntity {

typedef VirtualEntity* VirtualEntityList[0x40];

typedef struct Message {
/* 0x00 */ b32 unk_00;
/* 0x04 */ s32 entityModelIndex;
/* 0x08 */ Vec3f accel;
/* 0x14 */ Vec3f vel;
/* 0x20 */ s32 appearTime;
/* 0x24 */ s32 unk_24;
/* 0x28 */ f32 rotZ;
/* 0x2C */ f32 rotVelZ;
/* 0x30 */ f32 rotY;
/* 0x34 */ f32 scale;
/* 0x38 */ Vec3f pos;
/* 0x44 */ s32 deleteTime;
/* 0x48 */ f32 unk_48;
} Message; // size = 0x4C

struct PopupMessage;
typedef void (*PopupMessageCallback)(void* popup);

typedef struct PopupMessage {
/* 0x00 */ s32 unk_00;
/* 0x04 */ PopupMessageCallback updateFunc;
Expand All @@ -2348,7 +2282,10 @@ typedef struct PopupMessage {
/* 0x14 */ s16 duration;
/* 0x16 */ s8 showMsgState;
/* 0x17 */ s8 needsInit;
/* 0x18 */ Message* message;
/* 0x18 */ union {
struct BonkData* bonk;
struct HudStatusIcon* icons;
} data;
} PopupMessage; // size = 0x1C

typedef struct HiddenPanelsData {
Expand Down
158 changes: 82 additions & 76 deletions include/enums.h
Original file line number Diff line number Diff line change
Expand Up @@ -5194,78 +5194,78 @@ enum DictionaryIndex {
DICTIONARY_SIZE,
};

enum WindowId {
WINDOW_ID_NONE = -1,
WINDOW_ID_0 = 0,
WINDOW_ID_1 = 1,
WINDOW_ID_2 = 2,
WINDOW_ID_3 = 3,
WINDOW_ID_4 = 4,
WINDOW_ID_5 = 5,
WINDOW_ID_6 = 6,
WINDOW_ID_7 = 7,
WINDOW_ID_8 = 8, // battle main?
WINDOW_ID_BATTLE_POPUP = 9,
WINDOW_ID_ITEM_INFO_NAME = 10,
WINDOW_ID_ITEM_INFO_DESC = 11,
WINDOW_ID_12 = 12,
WINDOW_ID_13 = 13,
WINDOW_ID_14 = 14,
WINDOW_ID_15 = 15,
WINDOW_ID_16 = 16,
WINDOW_ID_17 = 17, // brown box used for "Throw away an item" and certain popup titles
WINDOW_ID_18 = 18,
WINDOW_ID_19 = 19,
WINDOW_ID_CURRENCY_COUNTER = 20,
WINDOW_ID_21 = 21,
WINDOW_ID_PAUSE_MAIN = 22,
WINDOW_ID_PAUSE_DECRIPTION = 23,
WINDOW_ID_FILEMENU_CURSOR = 23, // same as previous
WINDOW_ID_PAUSE_TUTORIAL = 24,
WINDOW_ID_FILEMENU_COPYARROW = 24, // same as previous
WINDOW_ID_PAUSE_TAB_STATS = 25,
WINDOW_ID_PAUSE_TAB_BADGES = 26,
WINDOW_ID_PAUSE_TAB_ITEMS = 27,
WINDOW_ID_PAUSE_TAB_PARTY = 28,
WINDOW_ID_PAUSE_TAB_SPIRITS = 29,
WINDOW_ID_PAUSE_TAB_MAP = 30,
WINDOW_ID_PAUSE_STATS = 31,
WINDOW_ID_PAUSE_BADGES = 32,
WINDOW_ID_PAUSE_ITEMS = 33,
WINDOW_ID_PAUSE_PARTNERS = 34,
WINDOW_ID_PAUSE_PARTNERS_TITLE = 35,
WINDOW_ID_PAUSE_PARTNERS_MOVELIST = 36,
WINDOW_ID_PAUSE_PARTNERS_MOVELIST_TITLE = 37,
WINDOW_ID_PAUSE_PARTNERS_MOVELIST_FLOWER = 38,
WINDOW_ID_PAUSE_SPIRITS = 39,
WINDOW_ID_PAUSE_SPIRITS_TITLE = 40,
WINDOW_ID_PAUSE_MAP = 41,
WINDOW_ID_PAUSE_MAP_TITLE = 42,
WINDOW_ID_PAUSE_TAB_INVIS = 43,
WINDOW_ID_PAUSE_CURSOR = 44,
WINDOW_ID_FILEMENU_MAIN = 44, // same as previous
WINDOW_ID_FILEMENU_TITLE = 45,
WINDOW_ID_FILEMENU_YESNO_PROMPT = 46,
WINDOW_ID_FILEMENU_INFO = 47,
WINDOW_ID_FILEMENU_CREATEFILE_HEADER = 48,
WINDOW_ID_FILEMENU_KEYBOARD = 49,
WINDOW_ID_FILEMENU_YESNO_OPTIONS = 50,
WINDOW_ID_FILEMENU_STEREO = 51,
WINDOW_ID_FILEMENU_MONO = 52,
WINDOW_ID_FILEMENU_OPTION_LEFT = 53,
WINDOW_ID_FILEMENU_OPTION_CENTER = 54,
WINDOW_ID_FILEMENU_OPTION_RIGHT = 55,
WINDOW_ID_FILEMENU_FILE0_INFO = 56,
WINDOW_ID_FILEMENU_FILE1_INFO = 57,
WINDOW_ID_FILEMENU_FILE2_INFO = 58,
WINDOW_ID_FILEMENU_FILE3_INFO = 59,
WINDOW_ID_FILEMENU_FILE0_TITLE = 60,
WINDOW_ID_FILEMENU_FILE1_TITLE = 61,
WINDOW_ID_FILEMENU_FILE2_TITLE = 62,
WINDOW_ID_FILEMENU_FILE3_TITLE = 63,
};

enum SimpleWindowUpdateId {
enum WindowID {
WIN_NONE = -1,
WIN_UNUSED_0 = 0,
WIN_BTL_MOVES_MENU = 1,
WIN_BTL_MOVES_TITLE = 2,
WIN_BTL_MOVES_ICON = 3,
WIN_BTL_SPIRITS_TITLE = 4,
WIN_BTL_SPIRITS_ICON = 5,
WIN_BTL_STRATS_MENU = 6,
WIN_BTL_STRATS_TITLE = 7,
WIN_BTL_DESC_BOX = 8, // strats and level up menus
WIN_BTL_POPUP = 9,
WIN_SHOP_ITEM_NAME = 10,
WIN_SHOP_ITEM_DESC = 11,
WIN_PICKUP_HEADER = 12,
WIN_UNUSED_13 = 13, // unused
WIN_POPUP_CONTENT = 14,
WIN_POPUP_TITLE_A = 15,
WIN_POPUP_COST = 16,
WIN_POPUP_TITLE_B = 17, // brown box used for "Throw away an item" and certain popup titles
WIN_PARTNER_COST = 18,
WIN_POPUP_DESC = 19,
WIN_CURRENCY_COUNTER = 20,
WIN_POPUP_PROMPT = 21,
WIN_PAUSE_MAIN = 22,
WIN_PAUSE_DECRIPTION = 23,
WIN_FILES_CURSOR = 23, // same as previous
WIN_PAUSE_TUTORIAL = 24,
WIN_FILES_COPYARROW = 24, // same as previous
WIN_PAUSE_TAB_STATS = 25,
WIN_PAUSE_TAB_BADGES = 26,
WIN_PAUSE_TAB_ITEMS = 27,
WIN_PAUSE_TAB_PARTY = 28,
WIN_PAUSE_TAB_SPIRITS = 29,
WIN_PAUSE_TAB_MAP = 30,
WIN_PAUSE_STATS = 31,
WIN_PAUSE_BADGES = 32,
WIN_PAUSE_ITEMS = 33,
WIN_PAUSE_PARTNERS = 34,
WIN_PAUSE_PARTNERS_TITLE = 35,
WIN_PAUSE_PARTNERS_MOVELIST = 36,
WIN_PAUSE_PARTNERS_MOVELIST_TITLE = 37,
WIN_PAUSE_PARTNERS_MOVELIST_FLOWER = 38,
WIN_PAUSE_SPIRITS = 39,
WIN_PAUSE_SPIRITS_TITLE = 40,
WIN_PAUSE_MAP = 41,
WIN_PAUSE_MAP_TITLE = 42,
WIN_PAUSE_TAB_INVIS = 43,
WIN_PAUSE_CURSOR = 44,
WIN_FILES_MAIN = 44, // same as previous
WIN_FILES_TITLE = 45,
WIN_FILES_CONFIRM_PROMPT = 46,
WIN_FILES_MESSAGE = 47,
WIN_FILES_INPUT_FIELD = 48,
WIN_FILES_INPUT_KEYBOARD = 49,
WIN_FILES_CONFIRM_OPTIONS = 50,
WIN_FILES_STEREO = 51,
WIN_FILES_MONO = 52,
WIN_FILES_OPTION_LEFT = 53,
WIN_FILES_OPTION_CENTER = 54,
WIN_FILES_OPTION_RIGHT = 55,
WIN_FILES_SLOT0_BODY = 56,
WIN_FILES_SLOT1_BODY = 57,
WIN_FILES_SLOT2_BODY = 58,
WIN_FILES_SLOT3_BODY = 59,
WIN_FILES_SLOT0_TITLE = 60,
WIN_FILES_SLOT1_TITLE = 61,
WIN_FILES_SLOT2_TITLE = 62,
WIN_FILES_SLOT3_TITLE = 63,
};

enum SimpleWindowUpdateID {
WINDOW_UPDATE_SHOW = 1,
WINDOW_UPDATE_HIDE = 2,
WINDOW_UPDATE_HIER_UPDATE = 3,
Expand All @@ -5277,11 +5277,11 @@ enum SimpleWindowUpdateId {
WINDOW_UPDATE_9 = 9,
};

enum WindowGroupId {
enum WindowGroups {
WINDOW_GROUP_ALL = 0,
WINDOW_GROUP_1 = 1,
WINDOW_GROUP_PAUSE_MENU = 2,
WINDOW_GROUP_FILE_MENU = 3,
WINDOW_GROUP_BATTLE = 1,
WINDOW_GROUP_PAUSE = 2,
WINDOW_GROUP_FILES = 3,
};

enum RushFlags {
Expand Down Expand Up @@ -5991,6 +5991,12 @@ enum MsgChars {

MSG_CHAR_UNK_C3 = 0xC3,

MSG_CHAR_MENU_SPACE = 0xC6,
MSG_CHAR_MENU_USE_CHARSET_B = 0xC7,
MSG_CHAR_MENU_USE_CHARSET_A = 0xC8,
MSG_CHAR_MENU_BACK = 0xC9,
MSG_CHAR_MENU_END = 0xCA,

// special character codes used when reading from the source buffer
MSG_CHAR_READ_ENDL = 0xF0,
MSG_CHAR_READ_WAIT = 0xF1,
Expand Down
57 changes: 47 additions & 10 deletions include/filemenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,61 @@

#include "common.h"

#define CENTER_WINDOW_X(id) (((gWindows[id].parent != WIN_NONE) \
? (gWindows[gWindows[id].parent].width / 2) \
: (SCREEN_WIDTH / 2)) \
- (gWindows[id].width / 2))

#define CENTER_WINDOW_Y(id) (((gWindows[id].parent != WIN_NONE) \
? (gWindows[gWindows[id].parent].height / 2) \
: (SCREEN_HEIGHT / 2)) \
- (gWindows[id].height / 2))

enum {
PAGE_0,
PAGE_1,
#if !VERSION_PAL
PAGE_2,
#endif
PAGE_3,
PAGE_4,
FILE_MENU_MAIN = 0, // file selection
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_CONFIRM_DELETE = 0,
FM_CONFIRM_LANGUAGE = 1,
FM_CONFIRM_CREATE = 2,
FM_CONFIRM_COPY = 3, // unused
FM_CONFIRM_START = 4,
FM_MESSAGE_DELETED = 0,
#if !VERSION_PAL
FM_MESSAGE_LANGUAGE = 1,
#endif
FM_MESSAGE_COPIED,
FM_MESSAGE_CREATED,
FM_INPUT_CHARSET_A = 0,
FM_INPUT_CHARSET_B = 1,
};

enum {
FM_MAIN_OPT_DELETE = 4,
FM_MAIN_OPT_COPY = 5,
FM_MAIN_OPT_CANCEL = 6,
};

extern MenuPanel* filemenu_menus[];

extern s32 filemenu_iterFileIdx;
extern s32 filemenu_CopyToFileIdx;
extern s32 filemenu_pressedButtons;
extern s32 filemenu_cursorHudElem;
extern s32 filemenu_heldButtons;
extern s8 filemenu_filename_pos;
extern s32 filemenu_loadedFileIdx;
extern s32 filemenu_CopyFromFileIdx;
extern s8 filemenu_currentMenu;
extern s32 filemenu_8024C09C;
extern s32 filemenu_cursorHudElemID[1];
Expand Down Expand Up @@ -64,7 +101,7 @@ WINDOW_UPDATE_FUNC(filemenu_update_deselect_file);
WINDOW_UPDATE_FUNC(filemenu_update_show_name_confirm);
WINDOW_UPDATE_FUNC(filemenu_update_hidden_name_confirm);

WINDOW_UPDATE_FUNC(main_menu_window_update);
WINDOW_UPDATE_FUNC(unused_main_menu_window_darkening);

WINDOW_UPDATE_FUNC(filemenu_update_show_title);

Expand Down
2 changes: 1 addition & 1 deletion include/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
#define ITEM_MENU_PAGE(index) (&gPauseItemsPages[index])

#define MENU_PANEL_SELECTED_GRID_DATA(panel) \
(panel)->gridData[(panel)->page * (panel)->numCols * (panel)->numRows + \
(panel)->gridData[(panel)->state * (panel)->numCols * (panel)->numRows + \
(panel)->numCols * (panel)->row + \
(panel)->col]

Expand Down
2 changes: 0 additions & 2 deletions include/variables.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ extern f32 PlayerNormalPitch;
extern s32 NpcHitQueryColliderID;
extern Vec3s StandardActorHomePositions[];

extern SaveData gCurrentSaveFile;

extern s32 gEncounterSubState;
extern s32 timeFreezeMode;
extern s32 D_8009A678;
Expand Down
Loading

0 comments on commit 6a33ff5

Please sign in to comment.