diff --git a/include/berry_data.h b/include/berry_data.h index 2fd189da76..bef6bbc212 100644 --- a/include/berry_data.h +++ b/include/berry_data.h @@ -1,87 +1,51 @@ #ifndef POKEPLATINUM_BERRY_DATA_H #define POKEPLATINUM_BERRY_DATA_H -#include "struct_decls/struct_berry_data_decl.h" - #include "narc.h" #include "strbuf.h" +// These must be #defines for csv2bin #define FIRMNESS_VERY_SOFT 1 #define FIRMNESS_SOFT 2 #define FIRMNESS_HARD 3 #define FIRMNESS_VERY_HARD 4 #define FIRMNESS_SUPER_HARD 5 -/* - * Constructs a new NARC which contains an open FSFile to the berry data archive. - * - * @param heapID: ID of the heap to alloc from - * - * @returns: Pointer to the newly-allocated NARC - */ -NARC *BerryData_NARC_ctor(u32 heapID); - -BerryData *sub_020973A8(NARC *param0, u32 param1, u32 param2); +enum BerryAttribute { + BERRYATTR_SIZE = 0, + BERRYATTR_FIRMNESS, + BERRYATTR_YIELD_CATEGORY, + BERRYATTR_STAGE_DURATION, + BERRYATTR_MOISTURE_DRAIN_RATE, + BERRYATTR_SPICINESS, + BERRYATTR_DRYNESS, + BERRYATTR_SWEETNESS, + BERRYATTR_BITTERNESS, + BERRYATTR_SOURNESS, + BERRYATTR_SMOOTHNESS, +}; + +typedef struct BerryData { + u16 size; + u8 firmness; + u8 yieldCategory; + u8 stageDuration; + u8 moistureDrainRate; + u8 spiciness; + u8 dryness; + u8 sweetness; + u8 bitterness; + u8 sourness; + u8 smoothness; +} BerryData; -/* - * Closes the wrapped FSFile and returns the NARC allocation to the heap from whence it came. - * - * @param narc: Pointer to the NARC - */ +NARC *BerryData_NARC_ctor(u32 heapID); +BerryData *BerryData_LoadFromOpenNARC(NARC *narc, u32 memberIdx, u32 heapID); void BerryData_NARC_dtor(NARC *narc); - -/* - * Creates a new buffer large enough to hold the data of the specified - * NARC member in 'nuts_data.narc', then reads the data. - * - * @param index: Index of the NARC member within 'nuts_data.narc' which contains the berry's data - * @param heapID: ID of the heap to alloc from - * - * @returns: Pointer to the allocated buffer which contains the data that was read. - */ -BerryData *BerryData_LoadDataByNarcMemberIndex(u32 index, u32 heapID); - -/* - * Creates a new buffer large enough to hold the data of the - * specified berry, then reads the data from nuts_data.narc - * - * @param itemID: Item ID of the berry for which to read the data - * @param heapID: ID of the heap to alloc from - * - * @returns: Pointer to the allocated buffer which contains the data that was read. - */ +BerryData *BerryData_Load(u32 memberIdx, u32 heapID); BerryData *BerryData_LoadDataByItemID(u32 itemID, u32 heapID); - -/* - * Retrieves the value of the specified attribute from a BerryData buffer - * - * @param berryData: Pointer to the buffer holding the berry data - * @param attributeID: ID of the attribute to retrieve the value for - * - * @returns: The value of the specified attribute - */ u32 BerryData_GetAttribute(BerryData *berryData, u32 attributeID); - -/* - * Creates a new string buffer large enough to hold the - * name of the specified berry, then reads the string. - * - * @param index: Index of the NARC member within 'nuts_data.narc' which contains the berry's data - * @param heapID: ID of the heap to alloc from - * - * @returns: Pointer to the allocated buffer which contains the string that was read. - */ -Strbuf *BerryData_AllocAndGetName(u16 index, u32 heapID); - -/* - * Creates a new string buffer large enough to hold the - * description of the specified berry, then reads the string. - * - * @param index: Index of the NARC member within 'nuts_data.narc' which contains the berry's data - * @param heapID: ID of the heap to alloc from - * - * @returns: Pointer to the allocated buffer which contains the string that was read. - */ -Strbuf *BerryData_AllocAndGetDescription(u16 index, u16 heapID); +Strbuf *BerryData_AllocAndGetName(u16 memberIdx, u32 heapID); +Strbuf *BerryData_AllocAndGetDescription(u16 memberIdx, u16 heapID); #endif // POKEPLATINUM_BERRY_DATA_H diff --git a/include/berry_patches.h b/include/berry_patches.h new file mode 100644 index 0000000000..8503c2ff36 --- /dev/null +++ b/include/berry_patches.h @@ -0,0 +1,67 @@ +#ifndef POKEPLATINUM_BERRY_PATCHES_H +#define POKEPLATINUM_BERRY_PATCHES_H + +#include "constants/heap.h" + +#define MAX_BERRY_PATCHES 128 + +enum BerryGrowthStage { + BERRY_GROWTH_STAGE_NONE = 0, + BERRY_GROWTH_STAGE_PLANTED, + BERRY_GROWTH_STAGE_SPROUTED, + BERRY_GROWTH_STAGE_GROWING, + BERRY_GROWTH_STAGE_BLOOMING, + BERRY_GROWTH_STAGE_FRUIT, +}; + +enum MulchType { + MULCH_TYPE_NONE = 0, + MULCH_TYPE_GROWTH, + MULCH_TYPE_DAMP, + MULCH_TYPE_STABLE, + MULCH_TYPE_GOOEY, +}; + +enum SoilMoisture { + SOIL_VERY_DRY = 0, + SOIL_DRY, + SOIL_MOIST, +}; + +typedef struct BerryPatch { + u8 berryID; + u8 growthStage; + u16 stageMinutesRemaining; + u16 moistureMinutesRemaining; + u8 replantCount; + u16 yield; + u8 moistureRating; + u8 yieldRating; + u8 mulchType; + u8 isGrowing; +} BerryPatch; + +typedef struct BerryGrowthData { + u8 stageDuration; + u8 moistureDrainRate; + u8 yieldCategory; +} BerryGrowthData; + +void BerryPatches_Clear(BerryPatch *patches); +void BerryPatches_Init(BerryPatch *patches, enum HeapId heapID, const u16 *initPatches, int initSize); +BerryGrowthData *BerryGrowthData_Init(enum HeapId heapID); +enum BerryGrowthStage BerryPatches_GetPatchGrowthStage(const BerryPatch *patches, int patchID); +int BerryPatches_GetPatchBerryID(const BerryPatch *patches, int patchID); +enum SoilMoisture BerryPatches_GetPatchMoisture(const BerryPatch *patches, int patchID); +int BerryPatches_GetPatchYieldRating(const BerryPatch *patches, int patchID); +void BerryPatches_PlantInPatch(BerryPatch *patches, int patchID, const BerryGrowthData *growthData, int berryID); +void BerryPatches_ResetPatchMoisture(BerryPatch *patches, int patchID); +BOOL BerryPatches_IsPatchGrowing(const BerryPatch *patches, int patchID); +void BerryPatches_SetIsPatchGrowing(BerryPatch *patches, int patchID, BOOL isGrowing); +enum MulchType BerryPatches_GetPatchMulchType(const BerryPatch *patches, int patchID); +void BerryPatches_SetPatchMulchType(BerryPatch *patches, int patchID, enum MulchType mulchType); +int BerryPatches_GetPatchYield(const BerryPatch *patches, int patchID); +int BerryPatches_HarvestPatch(BerryPatch *patches, int patchID); +void BerryPatches_ElapseMinutes(BerryPatch *patches, const BerryGrowthData *growthData, int minutesPassed); + +#endif // POKEPLATINUM_BERRY_PATCHES_H diff --git a/include/constants/field/map_load.h b/include/constants/field/map_load.h index 483bc7ffe3..2335fb183b 100644 --- a/include/constants/field/map_load.h +++ b/include/constants/field/map_load.h @@ -1,7 +1,7 @@ #ifndef POKEPLATINUM_CONSTANTS_FIELD_MAP_LOAD_H #define POKEPLATINUM_CONSTANTS_FIELD_MAP_LOAD_H -enum { +enum MapLoadType { MAP_LOAD_TYPE_OVERWORLD = 0, MAP_LOAD_TYPE_UNDERGROUND, MAP_LOAD_TYPE_UNION, diff --git a/include/constants/heap.h b/include/constants/heap.h index 6d5d52400f..030b2a0fcd 100644 --- a/include/constants/heap.h +++ b/include/constants/heap.h @@ -12,6 +12,8 @@ enum HeapId { HEAP_ID_POKETCH_MAIN = 7, HEAP_ID_POKETCH_APP, + HEAP_ID_FIELDMAP = 11, + HEAP_ID_COMMUNICATION = 15, HEAP_ID_DISTORTION_WORLD_WARP = 30, @@ -20,6 +22,8 @@ enum HeapId { HEAP_ID_CHOOSE_STARTER_APP = 47, + HEAP_ID_GAME_START = 77, + HEAP_ID_LIBRARY_TV = 120, }; @@ -27,9 +31,12 @@ enum HeapSize { HEAP_SIZE_POKETCH_MAIN = 0xc000, HEAP_SIZE_POKETCH_APP = 0xc000, + HEAP_SIZE_FIELDMAP = 0x1C000, + HEAP_SIZE_CHOOSE_STARTER_APP = 0x40000, HEAP_SIZE_LIBRARY_TV = 0x40000, HEAP_SIZE_DISTORTION_WORLD_WARP = 0x50000, + HEAP_SIZE_GAME_START = 0x20000, }; #endif // POKEPLATINUM_CONSTANTS_HEAP_H diff --git a/include/constants/savedata/save_table.h b/include/constants/savedata/save_table.h index 6605be2724..e0bec4973b 100644 --- a/include/constants/savedata/save_table.h +++ b/include/constants/savedata/save_table.h @@ -26,7 +26,7 @@ enum SaveTableEntryID { SAVE_TABLE_ENTRY_IMAGE_CLIPS, SAVE_TABLE_ENTRY_MAIL, SAVE_TABLE_ENTRY_POFFINS, - SAVE_TABLE_ENTRY_RANDOM_GROUP, + SAVE_TABLE_ENTRY_RECORD_MIXED_RNG, SAVE_TABLE_ENTRY_JOURNAL, SAVE_TABLE_ENTRY_TRAINER_CARD, SAVE_TABLE_ENTRY_GAME_RECORDS, diff --git a/include/constants/string.h b/include/constants/string.h index ac69b64d60..6decfb7489 100644 --- a/include/constants/string.h +++ b/include/constants/string.h @@ -1,9 +1,10 @@ #ifndef POKEPLATINUM_CONSTANTS_STRING_H #define POKEPLATINUM_CONSTANTS_STRING_H -#define MON_NAME_LEN 10 -#define TRAINER_NAME_LEN 7 -#define TABLET_NAME_LEN 10 -#define MOVE_NAME_LEN 16 +#define MON_NAME_LEN 10 +#define TRAINER_NAME_LEN 7 +#define TABLET_NAME_LEN 10 +#define MOVE_NAME_LEN 16 +#define UNION_GROUP_NAME_LEN 7 #endif diff --git a/include/core_sys.h b/include/core_sys.h index 32ed51146f..68823ff51a 100644 --- a/include/core_sys.h +++ b/include/core_sys.h @@ -29,10 +29,10 @@ typedef struct CoreSys { SysTaskManager *mainTaskMgr; SysTaskManager *vBlankTaskMgr; SysTaskManager *postVBlankTaskMgr; - SysTaskManager *unk_24; + SysTaskManager *printTaskMgr; u32 *unk_28; + u32 vblankCounter; u32 frameCounter; - u32 unk_30; enum ButtonMode buttonMode; u32 heldKeysRaw; u32 pressedKeysRaw; diff --git a/include/data/berry_init.h b/include/data/berry_init.h index 48df50b3b8..b5eeb83326 100644 --- a/include/data/berry_init.h +++ b/include/data/berry_init.h @@ -1,249 +1,127 @@ #include "constants/items.h" -/** - * @brief Table of initial berry states for the various mulch-beds across the - * overworld. - * - * This table is used to initialize the state of the mulch-beds at the time a - * new game is started. Entries in the table should be read in pairs; the first - * element is the berry planted in that particular mulch-bed, and the second is - * the number of that berry that can be harvested from the resulting tree. - */ -static const u16 sBerryInitTable[] = { - ITEM_ORAN_BERRY, - 1, - ITEM_CHERI_BERRY, - 1, - ITEM_CHESTO_BERRY, - 1, - ITEM_PECHA_BERRY, - 1, - ITEM_ORAN_BERRY, - 1, - ITEM_PECHA_BERRY, - 1, - ITEM_RAZZ_BERRY, - 2, - ITEM_BLUK_BERRY, - 2, - ITEM_CHERI_BERRY, - 1, - ITEM_ORAN_BERRY, - 2, - ITEM_SITRUS_BERRY, - 1, - ITEM_WEPEAR_BERRY, - 2, - ITEM_WEPEAR_BERRY, - 2, - ITEM_KELPSY_BERRY, - 1, - ITEM_CHERI_BERRY, - 1, - ITEM_PECHA_BERRY, - 1, - ITEM_ORAN_BERRY, - 1, - ITEM_ORAN_BERRY, - 1, - ITEM_RAWST_BERRY, - 1, - ITEM_RAWST_BERRY, - 1, - ITEM_RAZZ_BERRY, - 1, - ITEM_RAZZ_BERRY, - 1, - ITEM_CHERI_BERRY, - 1, - ITEM_ORAN_BERRY, - 1, - ITEM_ORAN_BERRY, - 1, - ITEM_BLUK_BERRY, - 1, - ITEM_NANAB_BERRY, - 2, - ITEM_RAZZ_BERRY, - 2, - ITEM_BLUK_BERRY, - 2, - ITEM_PINAP_BERRY, - 2, - ITEM_LEPPA_BERRY, - 1, - ITEM_CHESTO_BERRY, - 1, - ITEM_RAZZ_BERRY, - 1, - ITEM_RAZZ_BERRY, - 1, - ITEM_PERSIM_BERRY, - 1, - ITEM_NANAB_BERRY, - 1, - ITEM_NANAB_BERRY, - 1, - ITEM_FIGY_BERRY, - 1, - ITEM_ASPEAR_BERRY, - 1, - ITEM_ASPEAR_BERRY, - 1, - ITEM_RAZZ_BERRY, - 1, - ITEM_PINAP_BERRY, - 1, - ITEM_SITRUS_BERRY, - 1, - ITEM_CHESTO_BERRY, - 1, - ITEM_WIKI_BERRY, - 1, - ITEM_AGUAV_BERRY, - 1, - ITEM_PECHA_BERRY, - 1, - ITEM_ASPEAR_BERRY, - 1, - ITEM_IAPAPA_BERRY, - 1, - ITEM_GREPA_BERRY, - 1, - ITEM_SITRUS_BERRY, - 1, - ITEM_ASPEAR_BERRY, - 1, - ITEM_TAMATO_BERRY, - 1, - ITEM_LUM_BERRY, - 1, - ITEM_PECHA_BERRY, - 1, - ITEM_PINAP_BERRY, - 1, - ITEM_PINAP_BERRY, - 1, - ITEM_PINAP_BERRY, - 1, - ITEM_PERSIM_BERRY, - 1, - ITEM_PERSIM_BERRY, - 1, - ITEM_NANAB_BERRY, - 1, - ITEM_NANAB_BERRY, - 1, - ITEM_AGUAV_BERRY, - 1, - ITEM_IAPAPA_BERRY, - 1, - ITEM_RAWST_BERRY, - 1, - ITEM_RAWST_BERRY, - 1, - ITEM_CHERI_BERRY, - 1, - ITEM_SITRUS_BERRY, - 1, - ITEM_CHESTO_BERRY, - 1, - ITEM_POMEG_BERRY, - 1, - ITEM_PECHA_BERRY, - 2, - ITEM_BLUK_BERRY, - 2, - ITEM_WIKI_BERRY, - 1, - ITEM_MAGO_BERRY, - 1, - ITEM_RAWST_BERRY, - 1, - ITEM_PERSIM_BERRY, - 1, - ITEM_FIGY_BERRY, - 1, - ITEM_PINAP_BERRY, - 2, - ITEM_LEPPA_BERRY, - 1, - ITEM_PECHA_BERRY, - 1, - ITEM_MAGO_BERRY, - 1, - ITEM_HONDEW_BERRY, - 1, - ITEM_WIKI_BERRY, - 2, - ITEM_MAGO_BERRY, - 2, - ITEM_AGUAV_BERRY, - 2, - ITEM_QUALOT_BERRY, - 1, - ITEM_SITRUS_BERRY, - 2, - ITEM_BLUK_BERRY, - 3, - ITEM_NANAB_BERRY, - 3, - ITEM_WEPEAR_BERRY, - 3, - ITEM_POMEG_BERRY, - 1, - ITEM_POMEG_BERRY, - 1, - ITEM_HONDEW_BERRY, - 2, - ITEM_HONDEW_BERRY, - 2, - ITEM_KELPSY_BERRY, - 1, - ITEM_KELPSY_BERRY, - 1, - ITEM_TAMATO_BERRY, - 1, - ITEM_TAMATO_BERRY, - 1, - ITEM_QUALOT_BERRY, - 1, - ITEM_QUALOT_BERRY, - 1, - ITEM_POMEG_BERRY, - 1, - ITEM_POMEG_BERRY, - 1, - ITEM_HONDEW_BERRY, - 1, - ITEM_HONDEW_BERRY, - 1, - ITEM_TAMATO_BERRY, - 1, - ITEM_TAMATO_BERRY, - 1, - ITEM_GREPA_BERRY, - 1, - ITEM_GREPA_BERRY, - 1, - ITEM_QUALOT_BERRY, - 1, - ITEM_QUALOT_BERRY, - 1, - ITEM_LUM_BERRY, - 1, - ITEM_LEPPA_BERRY, - 1, - ITEM_QUALOT_BERRY, - 2, - ITEM_GREPA_BERRY, - 2, - ITEM_KELPSY_BERRY, - 2, - ITEM_KELPSY_BERRY, - 2, - ITEM_GREPA_BERRY, - 1, - ITEM_GREPA_BERRY, - 1, +typedef struct BerryPatchInit { + u16 berryItemID; + u16 yield; +} BerryPatchInit; + +static const BerryPatchInit sBerryInitTable[] = { + { .berryItemID = ITEM_ORAN_BERRY, .yield = 1 }, + { .berryItemID = ITEM_CHERI_BERRY, .yield = 1 }, + { .berryItemID = ITEM_CHESTO_BERRY, .yield = 1 }, + { .berryItemID = ITEM_PECHA_BERRY, .yield = 1 }, + { .berryItemID = ITEM_ORAN_BERRY, .yield = 1 }, + { .berryItemID = ITEM_PECHA_BERRY, .yield = 1 }, + { .berryItemID = ITEM_RAZZ_BERRY, .yield = 2 }, + { .berryItemID = ITEM_BLUK_BERRY, .yield = 2 }, + { .berryItemID = ITEM_CHERI_BERRY, .yield = 1 }, + { .berryItemID = ITEM_ORAN_BERRY, .yield = 2 }, + { .berryItemID = ITEM_SITRUS_BERRY, .yield = 1 }, + { .berryItemID = ITEM_WEPEAR_BERRY, .yield = 2 }, + { .berryItemID = ITEM_WEPEAR_BERRY, .yield = 2 }, + { .berryItemID = ITEM_KELPSY_BERRY, .yield = 1 }, + { .berryItemID = ITEM_CHERI_BERRY, .yield = 1 }, + { .berryItemID = ITEM_PECHA_BERRY, .yield = 1 }, + { .berryItemID = ITEM_ORAN_BERRY, .yield = 1 }, + { .berryItemID = ITEM_ORAN_BERRY, .yield = 1 }, + { .berryItemID = ITEM_RAWST_BERRY, .yield = 1 }, + { .berryItemID = ITEM_RAWST_BERRY, .yield = 1 }, + { .berryItemID = ITEM_RAZZ_BERRY, .yield = 1 }, + { .berryItemID = ITEM_RAZZ_BERRY, .yield = 1 }, + { .berryItemID = ITEM_CHERI_BERRY, .yield = 1 }, + { .berryItemID = ITEM_ORAN_BERRY, .yield = 1 }, + { .berryItemID = ITEM_ORAN_BERRY, .yield = 1 }, + { .berryItemID = ITEM_BLUK_BERRY, .yield = 1 }, + { .berryItemID = ITEM_NANAB_BERRY, .yield = 2 }, + { .berryItemID = ITEM_RAZZ_BERRY, .yield = 2 }, + { .berryItemID = ITEM_BLUK_BERRY, .yield = 2 }, + { .berryItemID = ITEM_PINAP_BERRY, .yield = 2 }, + { .berryItemID = ITEM_LEPPA_BERRY, .yield = 1 }, + { .berryItemID = ITEM_CHESTO_BERRY, .yield = 1 }, + { .berryItemID = ITEM_RAZZ_BERRY, .yield = 1 }, + { .berryItemID = ITEM_RAZZ_BERRY, .yield = 1 }, + { .berryItemID = ITEM_PERSIM_BERRY, .yield = 1 }, + { .berryItemID = ITEM_NANAB_BERRY, .yield = 1 }, + { .berryItemID = ITEM_NANAB_BERRY, .yield = 1 }, + { .berryItemID = ITEM_FIGY_BERRY, .yield = 1 }, + { .berryItemID = ITEM_ASPEAR_BERRY, .yield = 1 }, + { .berryItemID = ITEM_ASPEAR_BERRY, .yield = 1 }, + { .berryItemID = ITEM_RAZZ_BERRY, .yield = 1 }, + { .berryItemID = ITEM_PINAP_BERRY, .yield = 1 }, + { .berryItemID = ITEM_SITRUS_BERRY, .yield = 1 }, + { .berryItemID = ITEM_CHESTO_BERRY, .yield = 1 }, + { .berryItemID = ITEM_WIKI_BERRY, .yield = 1 }, + { .berryItemID = ITEM_AGUAV_BERRY, .yield = 1 }, + { .berryItemID = ITEM_PECHA_BERRY, .yield = 1 }, + { .berryItemID = ITEM_ASPEAR_BERRY, .yield = 1 }, + { .berryItemID = ITEM_IAPAPA_BERRY, .yield = 1 }, + { .berryItemID = ITEM_GREPA_BERRY, .yield = 1 }, + { .berryItemID = ITEM_SITRUS_BERRY, .yield = 1 }, + { .berryItemID = ITEM_ASPEAR_BERRY, .yield = 1 }, + { .berryItemID = ITEM_TAMATO_BERRY, .yield = 1 }, + { .berryItemID = ITEM_LUM_BERRY, .yield = 1 }, + { .berryItemID = ITEM_PECHA_BERRY, .yield = 1 }, + { .berryItemID = ITEM_PINAP_BERRY, .yield = 1 }, + { .berryItemID = ITEM_PINAP_BERRY, .yield = 1 }, + { .berryItemID = ITEM_PINAP_BERRY, .yield = 1 }, + { .berryItemID = ITEM_PERSIM_BERRY, .yield = 1 }, + { .berryItemID = ITEM_PERSIM_BERRY, .yield = 1 }, + { .berryItemID = ITEM_NANAB_BERRY, .yield = 1 }, + { .berryItemID = ITEM_NANAB_BERRY, .yield = 1 }, + { .berryItemID = ITEM_AGUAV_BERRY, .yield = 1 }, + { .berryItemID = ITEM_IAPAPA_BERRY, .yield = 1 }, + { .berryItemID = ITEM_RAWST_BERRY, .yield = 1 }, + { .berryItemID = ITEM_RAWST_BERRY, .yield = 1 }, + { .berryItemID = ITEM_CHERI_BERRY, .yield = 1 }, + { .berryItemID = ITEM_SITRUS_BERRY, .yield = 1 }, + { .berryItemID = ITEM_CHESTO_BERRY, .yield = 1 }, + { .berryItemID = ITEM_POMEG_BERRY, .yield = 1 }, + { .berryItemID = ITEM_PECHA_BERRY, .yield = 2 }, + { .berryItemID = ITEM_BLUK_BERRY, .yield = 2 }, + { .berryItemID = ITEM_WIKI_BERRY, .yield = 1 }, + { .berryItemID = ITEM_MAGO_BERRY, .yield = 1 }, + { .berryItemID = ITEM_RAWST_BERRY, .yield = 1 }, + { .berryItemID = ITEM_PERSIM_BERRY, .yield = 1 }, + { .berryItemID = ITEM_FIGY_BERRY, .yield = 1 }, + { .berryItemID = ITEM_PINAP_BERRY, .yield = 2 }, + { .berryItemID = ITEM_LEPPA_BERRY, .yield = 1 }, + { .berryItemID = ITEM_PECHA_BERRY, .yield = 1 }, + { .berryItemID = ITEM_MAGO_BERRY, .yield = 1 }, + { .berryItemID = ITEM_HONDEW_BERRY, .yield = 1 }, + { .berryItemID = ITEM_WIKI_BERRY, .yield = 2 }, + { .berryItemID = ITEM_MAGO_BERRY, .yield = 2 }, + { .berryItemID = ITEM_AGUAV_BERRY, .yield = 2 }, + { .berryItemID = ITEM_QUALOT_BERRY, .yield = 1 }, + { .berryItemID = ITEM_SITRUS_BERRY, .yield = 2 }, + { .berryItemID = ITEM_BLUK_BERRY, .yield = 3 }, + { .berryItemID = ITEM_NANAB_BERRY, .yield = 3 }, + { .berryItemID = ITEM_WEPEAR_BERRY, .yield = 3 }, + { .berryItemID = ITEM_POMEG_BERRY, .yield = 1 }, + { .berryItemID = ITEM_POMEG_BERRY, .yield = 1 }, + { .berryItemID = ITEM_HONDEW_BERRY, .yield = 2 }, + { .berryItemID = ITEM_HONDEW_BERRY, .yield = 2 }, + { .berryItemID = ITEM_KELPSY_BERRY, .yield = 1 }, + { .berryItemID = ITEM_KELPSY_BERRY, .yield = 1 }, + { .berryItemID = ITEM_TAMATO_BERRY, .yield = 1 }, + { .berryItemID = ITEM_TAMATO_BERRY, .yield = 1 }, + { .berryItemID = ITEM_QUALOT_BERRY, .yield = 1 }, + { .berryItemID = ITEM_QUALOT_BERRY, .yield = 1 }, + { .berryItemID = ITEM_POMEG_BERRY, .yield = 1 }, + { .berryItemID = ITEM_POMEG_BERRY, .yield = 1 }, + { .berryItemID = ITEM_HONDEW_BERRY, .yield = 1 }, + { .berryItemID = ITEM_HONDEW_BERRY, .yield = 1 }, + { .berryItemID = ITEM_TAMATO_BERRY, .yield = 1 }, + { .berryItemID = ITEM_TAMATO_BERRY, .yield = 1 }, + { .berryItemID = ITEM_GREPA_BERRY, .yield = 1 }, + { .berryItemID = ITEM_GREPA_BERRY, .yield = 1 }, + { .berryItemID = ITEM_QUALOT_BERRY, .yield = 1 }, + { .berryItemID = ITEM_QUALOT_BERRY, .yield = 1 }, + { .berryItemID = ITEM_LUM_BERRY, .yield = 1 }, + { .berryItemID = ITEM_LEPPA_BERRY, .yield = 1 }, + { .berryItemID = ITEM_QUALOT_BERRY, .yield = 2 }, + { .berryItemID = ITEM_GREPA_BERRY, .yield = 2 }, + { .berryItemID = ITEM_KELPSY_BERRY, .yield = 2 }, + { .berryItemID = ITEM_KELPSY_BERRY, .yield = 2 }, + { .berryItemID = ITEM_GREPA_BERRY, .yield = 1 }, + { .berryItemID = ITEM_GREPA_BERRY, .yield = 1 }, }; diff --git a/include/field/field_system.h b/include/field/field_system.h index 6bc02f79aa..7d0fa3c9c3 100644 --- a/include/field/field_system.h +++ b/include/field/field_system.h @@ -13,11 +13,9 @@ #include "struct_decls/terrain_collision_manager_decl.h" #include "struct_defs/map_load_mode.h" #include "struct_defs/struct_0202610C.h" -#include "struct_defs/struct_02049FA8.h" #include "struct_defs/struct_0204AFC4.h" #include "struct_defs/struct_0209C370.h" -#include "field/field_system_sub1_decl.h" #include "field/field_system_sub2_decl.h" #include "field/field_system_sub3.h" #include "overlay005/struct_ov5_021D1A68_decl.h" @@ -42,12 +40,21 @@ #include "bg_window.h" #include "camera.h" #include "journal.h" +#include "location.h" #include "map_header_data.h" +#include "overlay_manager.h" #include "pokeradar.h" #include "savedata.h" +typedef struct FieldProcessManager { + OverlayManager *parent; + OverlayManager *child; + BOOL pause; + BOOL kill; +} FieldProcessManager; + typedef struct FieldSystem_t { - FieldSystem_sub1 *unk_00; + FieldProcessManager *processManager; FieldSystem_sub2 *unk_04; BgConfig *bgConfig; SaveData *saveData; @@ -73,7 +80,7 @@ typedef struct FieldSystem_t { const TerrainCollisionManager *terrainCollisionMan; int unk_60; UnkStruct_ov5_021E1B20 *unk_64; - BOOL unk_68; + BOOL runningFieldMap; UnkStruct_ov23_0224942C *unk_6C; int mapLoadType; const MapLoadMode *mapLoadMode; diff --git a/include/field/field_system_sub1_decl.h b/include/field/field_system_sub1_decl.h deleted file mode 100644 index 3539a26635..0000000000 --- a/include/field/field_system_sub1_decl.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef POKEPLATINUM_FIELD_SYSTEM_SUB1_DECL_H -#define POKEPLATINUM_FIELD_SYSTEM_SUB1_DECL_H - -typedef struct FieldSystem_sub1_t FieldSystem_sub1; - -#endif // POKEPLATINUM_FIELD_SYSTEM_SUB1_DECL_H diff --git a/include/field_map_change.h b/include/field_map_change.h index 2fdde807de..25285f5283 100644 --- a/include/field_map_change.h +++ b/include/field_map_change.h @@ -2,11 +2,12 @@ #define POKEPLATINUM_FIELD_MAP_CHANGE_H #include "struct_decls/struct_020508D4_decl.h" -#include "struct_defs/struct_02049FA8.h" #include "field/field_system_decl.h" #include "functypes/funcptr_02050904.h" +#include "location.h" + void FieldMapChange_Set3DDisplay(FieldSystem *fieldSystem); void FieldMapChange_UpdateGameData(FieldSystem *fieldSystem, BOOL param1); void FieldMapChange_UpdateGameDataDistortionWorld(FieldSystem *fieldSystem, BOOL param1); diff --git a/include/field_overworld_state.h b/include/field_overworld_state.h index d6ba5ebaab..1697751b56 100644 --- a/include/field_overworld_state.h +++ b/include/field_overworld_state.h @@ -3,19 +3,19 @@ #include "struct_decls/struct_0203A790_decl.h" #include "struct_decls/struct_0203A79C_decl.h" -#include "struct_defs/struct_02049FA8.h" #include "struct_defs/struct_020556C4.h" #include "struct_defs/struct_0205EC34.h" #include "field/field_system_decl.h" +#include "location.h" #include "savedata.h" int FieldOverworldState_Size(void); int FieldOverworldSave_Size(void); void FieldOverworldSave_Init(FieldOverworldSave *param0); void FieldOverworldState_Init(FieldOverworldState *param0); -Location *sub_0203A720(FieldOverworldState *param0); +Location *FieldOverworldState_GetPlayerLocation(FieldOverworldState *param0); Location *FieldOverworldState_GetEntranceLocation(FieldOverworldState *param0); Location *FieldOverworldState_GetPrevLocation(FieldOverworldState *param0); Location *sub_0203A72C(FieldOverworldState *param0); diff --git a/include/field_system.h b/include/field_system.h index cad0ffc940..30c7f58d15 100644 --- a/include/field_system.h +++ b/include/field_system.h @@ -8,16 +8,16 @@ #include "overlay_manager.h" #include "savedata.h" -void sub_0203CD00(FieldSystem *fieldSystem); -void sub_0203CD44(FieldSystem *fieldSystem); -BOOL sub_0203CD4C(FieldSystem *fieldSystem); -BOOL sub_0203CD5C(FieldSystem *fieldSystem); -BOOL sub_0203CD74(FieldSystem *fieldSystem); -void sub_0203CD84(FieldSystem *fieldSystem, const OverlayManagerTemplate *param1, void *param2); -void sub_0203D128(void); -void sub_0203D140(void); +void FieldSystem_StartFieldMap(FieldSystem *fieldSystem); +void FieldSystem_FlagNotRunningFieldMap(FieldSystem *fieldSystem); +BOOL FieldSystem_HasParentProcess(FieldSystem *fieldSystem); +BOOL FieldSystem_IsRunningFieldMap(FieldSystem *fieldSystem); +BOOL FieldSystem_HasChildProcess(FieldSystem *fieldSystem); +void FieldSystem_StartChildProcess(FieldSystem *fieldSystem, const OverlayManagerTemplate *overlayTemplate, void *overlayArgs); +void FieldSystem_PauseProcessing(void); +void FieldSystem_ResumeProcessing(void); PoketchSystem *FieldSystem_GetPoketchSystem(void); -BgConfig *sub_0203D170(void *param0); -SaveData *FieldSystem_SaveData(void *param0); +BgConfig *FieldSystem_GetBgConfig(void *fieldSystem); +SaveData *FieldSystem_GetSaveData(void *fieldSystem); #endif // POKEPLATINUM_UNK_0203CC84_H diff --git a/include/game_overlay.h b/include/game_overlay.h index a869c3972e..e9acf3f5cd 100644 --- a/include/game_overlay.h +++ b/include/game_overlay.h @@ -3,15 +3,15 @@ #include -typedef enum PMOverlayLoadType { +typedef enum OverlayLoadType { OVERLAY_LOAD_NORMAL, OVERLAY_LOAD_NOINIT, OVERLAY_LOAD_ASYNC -} PMOverlayLoadType; +} OverlayLoadType; -void Overlay_UnloadByID(const FSOverlayID param0); -int Overlay_GetLoadDestination(const FSOverlayID param0); -BOOL Overlay_LoadByID(const FSOverlayID param0, int param1); +void Overlay_UnloadByID(const FSOverlayID overlayID); +int Overlay_GetLoadDestination(const FSOverlayID overlayID); +BOOL Overlay_LoadByID(const FSOverlayID overlayID, enum OverlayLoadType loadType); #ifdef GDB_DEBUGGING // describes a single overlay entry, which GDB can inspect to determine which overlays are loaded. diff --git a/include/game_start.h b/include/game_start.h new file mode 100644 index 0000000000..2a63f76486 --- /dev/null +++ b/include/game_start.h @@ -0,0 +1,10 @@ +#ifndef POKEPLATINUM_GAME_START_H +#define POKEPLATINUM_GAME_START_H + +#include "overlay_manager.h" + +extern const OverlayManagerTemplate gGameStartLoadSaveOverlayTemplate; +extern const OverlayManagerTemplate gGameStartNewSaveOverlayTemplate; +extern const OverlayManagerTemplate gGameStartRowanIntroOverlayTemplate; + +#endif // POKEPLATINUM_GAME_START_H diff --git a/include/inlines.h b/include/inlines.h index 79f6abaae2..1682719ad0 100644 --- a/include/inlines.h +++ b/include/inlines.h @@ -4,7 +4,6 @@ #include #include "struct_decls/struct_0203A790_decl.h" -#include "struct_defs/struct_02049FA8.h" #include "field/field_system.h" #include "overlay061/struct_ov61_0222C3B0.h" @@ -14,6 +13,7 @@ #include "field_script_context.h" #include "graphics.h" #include "heap.h" +#include "location.h" #include "map_header.h" #include "narc.h" #include "palette.h" @@ -150,15 +150,6 @@ static inline void inline_ov47_0225621C(FieldSystem *fieldSystem, int *param1, i *param2 /= 32; } -static inline void Location_Set(Location *location, int mapId, int param2, int param3, int param4, int param5) -{ - location->mapId = mapId; - location->unk_04 = param2; - location->x = param3; - location->z = param4; - location->unk_10 = param5; -} - static inline u16 *ScriptContext_GetVarPointer(ScriptContext *ctx) { return FieldSystem_GetVarPointer(ctx->fieldSystem, ScriptContext_ReadHalfWord(ctx)); diff --git a/include/location.h b/include/location.h new file mode 100644 index 0000000000..44d076bd1e --- /dev/null +++ b/include/location.h @@ -0,0 +1,36 @@ +#ifndef POKEPLATINUM_LOCATION_H +#define POKEPLATINUM_LOCATION_H + +#include "savedata.h" + +#define WARP_ID_NONE -1 + +enum FaceDirection { + FACE_UP = 0, + FACE_DOWN, + FACE_LEFT, + FACE_RIGHT, +}; + +typedef struct Location { + int mapId; + int warpId; + int x; + int z; + int faceDirection; +} Location; + +static inline void Location_Set(Location *location, int mapId, int warpId, int x, int z, int faceDirection) +{ + location->mapId = mapId; + location->warpId = warpId; + location->x = x; + location->z = z; + location->faceDirection = faceDirection; +} + +void SetPlayerStartLocation(Location *outLocation); +void SetPlayerFirstRespawnLocation(Location *outLocation); +void InitPlayerStartLocation(SaveData *saveData); + +#endif // POKEPLATINUM_LOCATION_H diff --git a/include/main.h b/include/main.h new file mode 100644 index 0000000000..0135d015cc --- /dev/null +++ b/include/main.h @@ -0,0 +1,24 @@ +#ifndef POKEPLATINUM_MAIN_H +#define POKEPLATINUM_MAIN_H + +#include + +#include "overlay_manager.h" +#include "savedata.h" + +enum OSResetParameter { + RESET_CLEAN = 0, + RESET_ERROR, +}; + +typedef struct ApplicationArgs { + int unk_00; + BOOL error; + SaveData *saveData; +} ApplicationArgs; + +void EnqueueApplication(FSOverlayID overlayID, const OverlayManagerTemplate *template); +void InitRNG(void); +void HandleConsoleFold(void); + +#endif // POKEPLATINUM_MAIN_H diff --git a/include/overlay005/const_ov5_021F89B0.h b/include/overlay005/const_ov5_021F89B0.h deleted file mode 100644 index 0ebd94efed..0000000000 --- a/include/overlay005/const_ov5_021F89B0.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef POKEPLATINUM_CONST_OV5_021F89B0_H -#define POKEPLATINUM_CONST_OV5_021F89B0_H - -#include "overlay_manager.h" - -extern const OverlayManagerTemplate gFieldMapTemplate; - -#endif // POKEPLATINUM_CONST_OV5_021F89B0_H diff --git a/include/overlay005/ov5_021D0D80.h b/include/overlay005/fieldmap.h similarity index 84% rename from include/overlay005/ov5_021D0D80.h rename to include/overlay005/fieldmap.h index 0fd3afbba8..c11a886820 100644 --- a/include/overlay005/ov5_021D0D80.h +++ b/include/overlay005/fieldmap.h @@ -4,6 +4,9 @@ #include "field/field_system_decl.h" #include "bg_window.h" +#include "overlay_manager.h" + +extern const OverlayManagerTemplate gFieldMapTemplate; void ov5_021D12D0(FieldSystem *fieldSystem, u32 param1); void ov5_021D1434(BgConfig *param0); diff --git a/include/overlay006/ov6_02242984.h b/include/overlay006/ov6_02242984.h index 66a35f4419..851afd642b 100644 --- a/include/overlay006/ov6_02242984.h +++ b/include/overlay006/ov6_02242984.h @@ -1,11 +1,11 @@ #ifndef POKEPLATINUM_OV6_02242984_H #define POKEPLATINUM_OV6_02242984_H -#include "struct_defs/struct_02049FA8.h" - #include "field/field_system_decl.h" #include "overlay006/struct_ov6_02242A8C_decl.h" +#include "location.h" + int ov6_02242984(FieldSystem *fieldSystem); UnkStruct_ov6_02242A8C *ov6_02242A10(const int param0, FieldSystem *fieldSystem); void ov6_02242A8C(UnkStruct_ov6_02242A8C *param0); diff --git a/include/overlay057/const_ov57_021D0F70.h b/include/overlay057/const_ov57_021D0F70.h deleted file mode 100644 index 3cac6c7f77..0000000000 --- a/include/overlay057/const_ov57_021D0F70.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef POKEPLATINUM_CONST_OV57_021D0F70_H -#define POKEPLATINUM_CONST_OV57_021D0F70_H - -#include "overlay_manager.h" - -extern const OverlayManagerTemplate Unk_ov57_021D0F70; - -#endif // POKEPLATINUM_CONST_OV57_021D0F70_H diff --git a/include/overlay057/const_ov57_021D0F80.h b/include/overlay057/const_ov57_021D0F80.h deleted file mode 100644 index 71017f446b..0000000000 --- a/include/overlay057/const_ov57_021D0F80.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef POKEPLATINUM_CONST_OV57_021D0F80_H -#define POKEPLATINUM_CONST_OV57_021D0F80_H - -#include "overlay_manager.h" - -extern const OverlayManagerTemplate Unk_ov57_021D0F80; - -#endif // POKEPLATINUM_CONST_OV57_021D0F80_H diff --git a/include/overlay057/const_ov57_021D0F90.h b/include/overlay057/const_ov57_021D0F90.h deleted file mode 100644 index ba4644b095..0000000000 --- a/include/overlay057/const_ov57_021D0F90.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef POKEPLATINUM_CONST_OV57_021D0F90_H -#define POKEPLATINUM_CONST_OV57_021D0F90_H - -#include "overlay_manager.h" - -extern const OverlayManagerTemplate Unk_ov57_021D0F90; - -#endif // POKEPLATINUM_CONST_OV57_021D0F90_H diff --git a/include/overlay057/ov57_021D0F30.h b/include/overlay057/ov57_021D0F30.h deleted file mode 100644 index f626a9c610..0000000000 --- a/include/overlay057/ov57_021D0F30.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef POKEPLATINUM_OV57_021D0F30_H -#define POKEPLATINUM_OV57_021D0F30_H - -#include "savedata.h" - -void ov57_021D0F30(int param0, SaveData *param1); -void ov57_021D0F44(int param0, SaveData *param1); - -#endif // POKEPLATINUM_OV57_021D0F30_H diff --git a/include/overlay059/ov59_021D2A2C.h b/include/overlay059/ov59_021D2A2C.h index ab468470ef..1028cc2744 100644 --- a/include/overlay059/ov59_021D2A2C.h +++ b/include/overlay059/ov59_021D2A2C.h @@ -1,10 +1,10 @@ #ifndef POKEPLATINUM_OV59_021D2A2C_H #define POKEPLATINUM_OV59_021D2A2C_H -#include "struct_decls/struct_0202B4A0_decl.h" +#include "record_mixed_rng.h" -u32 ov59_021D2A2C(UnkStruct_0202B4A0 *param0); -void *ov59_021D2A30(UnkStruct_0202B4A0 *param0); -void ov59_021D2AC4(int param0, int param1, UnkStruct_0202B4A0 *param2, const void **param3); +u32 ov59_021D2A2C(RecordMixedRNG *param0); +void *ov59_021D2A30(RecordMixedRNG *param0); +void ov59_021D2AC4(int param0, int param1, RecordMixedRNG *param2, const void **param3); #endif // POKEPLATINUM_OV59_021D2A2C_H diff --git a/include/overlay077/const_ov77_021D742C.h b/include/overlay077/const_ov77_021D742C.h index 48e5e7075c..e5e9ffe0f8 100644 --- a/include/overlay077/const_ov77_021D742C.h +++ b/include/overlay077/const_ov77_021D742C.h @@ -3,6 +3,6 @@ #include "overlay_manager.h" -extern const OverlayManagerTemplate Unk_ov77_021D742C; +extern const OverlayManagerTemplate gTitleScreenOverlayTemplate; #endif // POKEPLATINUM_CONST_OV77_021D742C_H diff --git a/include/record_mixed_rng.h b/include/record_mixed_rng.h new file mode 100644 index 0000000000..35c0d3b8fb --- /dev/null +++ b/include/record_mixed_rng.h @@ -0,0 +1,57 @@ +#ifndef POKEPLATINUM_RECORD_MIXED_RNG_H +#define POKEPLATINUM_RECORD_MIXED_RNG_H + +#include "constants/string.h" + +#include "charcode.h" +#include "savedata.h" +#include "strbuf.h" + +enum RecordMixedRNGEntry { + RECORD_MIXED_RNG_PLAYER_ORIGINAL, + RECORD_MIXED_RNG_PLAYER_OVERRIDE, + RECORD_MIXED_RNG_QUEUE_0, + RECORD_MIXED_RNG_QUEUE_1, + RECORD_MIXED_RNG_QUEUE_2, + RECORD_MIXED_RNG_QUEUE_3, + + RECORD_MIXED_RNG_MAX, +}; + +enum RecordMixedRNGName { + RECORD_MIXED_RNG_GROUP_NAME, + RECORD_MIXED_RNG_PLAYER_NAME, +}; + +typedef struct RecordMixedRNG { + charcode_t groupName[UNION_GROUP_NAME_LEN + 1]; + charcode_t playerName[TRAINER_NAME_LEN + 1]; + u8 gender; + u8 countryCode; + u16 dummy; + u32 seed; + u32 rand; +} RecordMixedRNG; + +int RecordMixedRNG_SaveSize(); +RecordMixedRNG *SaveData_GetRecordMixedRNG(SaveData *saveData); + +void RecordMixedRNG_CopyEntry(RecordMixedRNG *rngCollection, enum RecordMixedRNGEntry srcEntry, enum RecordMixedRNGEntry destEntry); +void RecordMixedRNG_Init(RecordMixedRNG *rngCollection); +void RecordMixedRNG_AdvanceEntries(RecordMixedRNG *rngCollection, u32 stepCount); +u32 RecordMixedRNG_GetEntrySeed(RecordMixedRNG *rngCollection, enum RecordMixedRNGEntry entry); +void RecordMixedRNG_SetEntrySeed(RecordMixedRNG *rngCollection, enum RecordMixedRNGEntry entry, u32 seed); +u32 RecordMixedRNG_GetRand(RecordMixedRNG *rngCollection); +const charcode_t *RecordMixedRNG_GetEntryName(const RecordMixedRNG *rngCollection, enum RecordMixedRNGEntry entry, enum RecordMixedRNGName nameChoice); +void RecordMixedRNG_GetEntryNameAsStrbuf(RecordMixedRNG *rngCollection, enum RecordMixedRNGEntry entry, enum RecordMixedRNGName nameChoice, Strbuf *outStrbuf); +void RecordMixedRNG_SetEntryGender(RecordMixedRNG *rngCollection, enum RecordMixedRNGEntry entry, int gender); +int RecordMixedRNG_GetEntryGender(const RecordMixedRNG *rngCollection, enum RecordMixedRNGEntry entry); +int RecordMixedRNG_GetEntryCountryCode(const RecordMixedRNG *rngCollection, enum RecordMixedRNGEntry entry); +void RecordMixedRNG_SetEntryCountryCode(RecordMixedRNG *rngCollection, enum RecordMixedRNGEntry entry, int countryCode); +BOOL RecordMixedRNG_IsEntryValid(const RecordMixedRNG *rngCollection, enum RecordMixedRNGEntry entry); +BOOL RecordMixedRNG_IsEntryEqualToOverride(const RecordMixedRNG *rngCollection, enum RecordMixedRNGEntry entry); +BOOL RecordMixedRNG_DoesCollectionContainGroup(const RecordMixedRNG *rngCollection, const charcode_t *groupName); +BOOL RecordMixedRNG_IsEntryEmpty(const RecordMixedRNG *entry); +BOOL RecordMixedRNG_AreEntriesEqual(const RecordMixedRNG *entry1, const RecordMixedRNG *entry2); + +#endif // POKEPLATINUM_RECORD_MIXED_RNG_H diff --git a/include/savedata_misc.h b/include/savedata_misc.h index 96dcde809d..0c6ce8f73f 100644 --- a/include/savedata_misc.h +++ b/include/savedata_misc.h @@ -4,12 +4,11 @@ #include "constants/savedata/save_table.h" #include "constants/string.h" -#include "struct_decls/struct_02027854_decl.h" #include "struct_decls/struct_02027860_decl.h" #include "struct_defs/sentence.h" -#include "struct_defs/struct_02027854.h" #include "struct_defs/struct_02027860.h" +#include "berry_patches.h" #include "savedata.h" #include "strbuf.h" @@ -21,7 +20,7 @@ typedef struct ExtraSaveKey { } ExtraSaveKey; typedef struct MiscSaveBlock { - UnkStruct_02027854 unk_00[128]; + BerryPatch berryPatches[MAX_BERRY_PATCHES]; UnkStruct_02027860 unk_680; u16 rivalName[TRAINER_NAME_LEN + 1]; u16 tabletName[TABLET_NAME_LEN + 1]; // used in shaymin event @@ -40,7 +39,7 @@ int MiscSaveBlock_SaveSize(void); void MiscSaveBlock_Init(MiscSaveBlock *miscSave); MiscSaveBlock *SaveData_MiscSaveBlock(SaveData *saveData); const MiscSaveBlock *SaveData_MiscSaveBlockConst(const SaveData *saveData); -UnkStruct_02027854 *sub_02027854(SaveData *saveData); +BerryPatch *MiscSaveBlock_GetBerryPatches(SaveData *saveData); UnkStruct_02027860 *sub_02027860(SaveData *saveData); const u16 *MiscSaveBlock_RivalName(const MiscSaveBlock *miscSave); void MiscSaveBlock_SetRivalName(MiscSaveBlock *miscSave, Strbuf *name); diff --git a/include/struct_decls/struct_02025CCC_decl.h b/include/struct_decls/struct_02025CCC_decl.h deleted file mode 100644 index 1ca8ee9b35..0000000000 --- a/include/struct_decls/struct_02025CCC_decl.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef POKEPLATINUM_STRUCT_02025CCC_DECL_H -#define POKEPLATINUM_STRUCT_02025CCC_DECL_H - -typedef struct UnkStruct_02025CCC_t UnkStruct_02025CCC; - -#endif // POKEPLATINUM_STRUCT_02025CCC_DECL_H diff --git a/include/struct_decls/struct_02027854_decl.h b/include/struct_decls/struct_02027854_decl.h deleted file mode 100644 index c1435845f7..0000000000 --- a/include/struct_decls/struct_02027854_decl.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef POKEPLATINUM_STRUCT_02027854_DECL_H -#define POKEPLATINUM_STRUCT_02027854_DECL_H - -typedef struct UnkStruct_02027854_t UnkStruct_02027854; - -#endif // POKEPLATINUM_STRUCT_02027854_DECL_H diff --git a/include/struct_decls/struct_0202B4A0_decl.h b/include/struct_decls/struct_0202B4A0_decl.h deleted file mode 100644 index d1f8b7ac5e..0000000000 --- a/include/struct_decls/struct_0202B4A0_decl.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef POKEPLATINUM_STRUCT_0202B4A0_DECL_H -#define POKEPLATINUM_STRUCT_0202B4A0_DECL_H - -typedef struct UnkStruct_0202B4A0_t UnkStruct_0202B4A0; - -#endif // POKEPLATINUM_STRUCT_0202B4A0_DECL_H diff --git a/include/struct_decls/struct_berry_data_decl.h b/include/struct_decls/struct_berry_data_decl.h deleted file mode 100644 index 582449a2b9..0000000000 --- a/include/struct_decls/struct_berry_data_decl.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef POKEPLATINUM_STRUCT_BERRY_DATA_DECL_H -#define POKEPLATINUM_STRUCT_BERRY_DATA_DECL_H - -typedef struct BerryData BerryData; - -#endif // POKEPLATINUM_STRUCT_BERRY_DATA_DECL_H diff --git a/include/struct_defs/struct_02027854.h b/include/struct_defs/struct_02027854.h deleted file mode 100644 index 5307da788b..0000000000 --- a/include/struct_defs/struct_02027854.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef POKEPLATINUM_STRUCT_02027854_H -#define POKEPLATINUM_STRUCT_02027854_H - -typedef struct UnkStruct_02027854_t { - u8 unk_00; - u8 unk_01; - u16 unk_02; - u16 unk_04; - u8 unk_06; - u16 unk_08; - u8 unk_0A; - u8 unk_0B; - u8 unk_0C; - u8 unk_0D; -} UnkStruct_02027854; - -#endif // POKEPLATINUM_STRUCT_02027854_H diff --git a/include/struct_defs/struct_02027BF4.h b/include/struct_defs/struct_02027BF4.h deleted file mode 100644 index c41e97e43e..0000000000 --- a/include/struct_defs/struct_02027BF4.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef POKEPLATINUM_STRUCT_02027BF4_H -#define POKEPLATINUM_STRUCT_02027BF4_H - -typedef struct { - u8 unk_00; - u8 unk_01; - u8 unk_02; -} UnkStruct_02027BF4; - -#endif // POKEPLATINUM_STRUCT_02027BF4_H diff --git a/include/struct_defs/struct_0202B4A0.h b/include/struct_defs/struct_0202B4A0.h deleted file mode 100644 index 1b25e710bc..0000000000 --- a/include/struct_defs/struct_0202B4A0.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef POKEPLATINUM_STRUCT_0202B4A0_H -#define POKEPLATINUM_STRUCT_0202B4A0_H - -#include "struct_defs/struct_0202B510.h" - -typedef struct UnkStruct_0202B4A0_t { - UnkStruct_0202B510 unk_00[6]; -} UnkStruct_0202B4A0; - -#endif // POKEPLATINUM_STRUCT_0202B4A0_H diff --git a/include/struct_defs/struct_0202B510.h b/include/struct_defs/struct_0202B510.h deleted file mode 100644 index a9ef846df4..0000000000 --- a/include/struct_defs/struct_0202B510.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef POKEPLATINUM_STRUCT_0202B510_H -#define POKEPLATINUM_STRUCT_0202B510_H - -typedef struct { - u16 unk_00[8]; - u16 unk_10[8]; - u8 unk_20; - u8 unk_21; - u16 unk_22; - u32 unk_24; - u32 unk_28; -} UnkStruct_0202B510; - -#endif // POKEPLATINUM_STRUCT_0202B510_H diff --git a/include/struct_defs/struct_0203CC84.h b/include/struct_defs/struct_0203CC84.h index 51effb6652..71417d6ce7 100644 --- a/include/struct_defs/struct_0203CC84.h +++ b/include/struct_defs/struct_0203CC84.h @@ -3,10 +3,4 @@ #include "savedata.h" -typedef struct { - int unk_00; - BOOL unk_04; - SaveData *unk_08; -} UnkStruct_0203CC84; - #endif // POKEPLATINUM_STRUCT_0203CC84_H diff --git a/include/struct_defs/struct_0203E0FC.h b/include/struct_defs/struct_0203E0FC.h index c6c7771c22..c60d96fef9 100644 --- a/include/struct_defs/struct_0203E0FC.h +++ b/include/struct_defs/struct_0203E0FC.h @@ -2,7 +2,6 @@ #define POKEPLATINUM_STRUCT_0203E0FC_H #include "struct_decls/pokedexdata_decl.h" -#include "struct_decls/struct_02025CCC_decl.h" #include "struct_decls/struct_0202B370_decl.h" #include "struct_decls/struct_0202C878_decl.h" #include "struct_decls/struct_0202DA40_decl.h" @@ -14,11 +13,12 @@ #include "game_records.h" #include "journal.h" #include "savedata.h" +#include "system_data.h" #include "trainer_info.h" typedef struct { UnkStruct_0202DA40 *unk_00; - UnkStruct_02025CCC *unk_04; + SystemData *unk_04; Party *unk_08; PCBoxes *unk_0C; PokedexData *unk_10; diff --git a/include/struct_defs/struct_02049FA8.h b/include/struct_defs/struct_02049FA8.h index a5a59465c2..911c9f7f36 100644 --- a/include/struct_defs/struct_02049FA8.h +++ b/include/struct_defs/struct_02049FA8.h @@ -1,12 +1,4 @@ #ifndef POKEPLATINUM_STRUCT_02049FA8_H #define POKEPLATINUM_STRUCT_02049FA8_H -typedef struct { - int mapId; - int unk_04; - int x; - int z; - int unk_10; -} Location; - #endif // POKEPLATINUM_STRUCT_02049FA8_H diff --git a/include/struct_defs/struct_0204AFC4.h b/include/struct_defs/struct_0204AFC4.h index 9f039a6e98..bf1340cc6e 100644 --- a/include/struct_defs/struct_0204AFC4.h +++ b/include/struct_defs/struct_0204AFC4.h @@ -3,11 +3,12 @@ #include "struct_decls/struct_0202D060_decl.h" #include "struct_decls/struct_0202D750_decl.h" -#include "struct_defs/struct_02049FA8.h" #include "struct_defs/struct_0204B404.h" #include "overlay104/struct_ov104_0223A348.h" +#include "location.h" + typedef struct UnkStruct_0204AFC4_t { int unk_00; int unk_04; diff --git a/include/struct_defs/struct_02055BA8.h b/include/struct_defs/struct_02055BA8.h deleted file mode 100644 index 947417d097..0000000000 --- a/include/struct_defs/struct_02055BA8.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef POKEPLATINUM_STRUCT_02055BA8_H -#define POKEPLATINUM_STRUCT_02055BA8_H - -#include - -typedef struct { - BOOL unk_00; - RTCDate unk_04; - RTCTime unk_14; - u32 unk_20; - s64 unk_24; - s64 unk_2C; - u32 unk_34; -} UnkStruct_02055BA8; - -#endif // POKEPLATINUM_STRUCT_02055BA8_H diff --git a/include/struct_defs/struct_0206BC70.h b/include/struct_defs/struct_0206BC70.h index e477171911..48d24f9308 100644 --- a/include/struct_defs/struct_0206BC70.h +++ b/include/struct_defs/struct_0206BC70.h @@ -3,17 +3,17 @@ #include -#include "struct_decls/struct_02025CCC_decl.h" #include "struct_decls/struct_0202D750_decl.h" #include "struct_decls/struct_0202D764_decl.h" #include "game_options.h" #include "savedata.h" +#include "system_data.h" typedef struct { UnkStruct_0202D750 *unk_00; UnkStruct_0202D764 *unk_04; - UnkStruct_02025CCC *unk_08; + SystemData *unk_08; SaveData *unk_0C; Options *unk_10; DWCUserData *unk_14; diff --git a/include/system_data.h b/include/system_data.h new file mode 100644 index 0000000000..97aa0fa801 --- /dev/null +++ b/include/system_data.h @@ -0,0 +1,48 @@ +#ifndef POKEPLATINUM_SYSTEM_DATA_H +#define POKEPLATINUM_SYSTEM_DATA_H + +#include + +#include "savedata.h" + +typedef struct GameTime { + BOOL canary; + RTCDate date; + RTCTime time; + u32 day; + s64 startTimestamp; + s64 playTimestamp; + u32 penaltyInMinutes; +} GameTime; + +typedef struct SystemData { + s64 rtcOffset; + u8 macAddress[6]; + u8 ownerBirthMonth; + u8 ownerBirthDayOfMonth; + GameTime gameTime; + u8 unk_48; + u8 unk_49; + s32 unk_4C; + u32 unk_50[3]; +} SystemData; + +int SystemData_SaveSize(void); +void SystemData_Clear(SystemData *systemData); +SystemData *SaveData_GetSystemData(SaveData *systemData); +GameTime *SaveData_GetGameTime(SaveData *saveData); +void SystemData_Init(SystemData *systemData); +BOOL SystemData_MatchesCurrentSystem(const SystemData *systemData); +BOOL SystemData_MatchesCurrentRTCOffset(const SystemData *systemData); +u8 SystemData_GetOwnerBirthMonth(const SystemData *systemData); +u8 SystemData_GetOwnerBirthDayOfMonth(const SystemData *systemData); +BOOL sub_02025D64(const SystemData *param0); +void sub_02025D6C(SystemData *param0, BOOL param1); +s32 sub_02025D74(const SystemData *param0); +void sub_02025D78(SystemData *param0, s32 param1); +void GameTime_Clear(GameTime *gameTime); +BOOL GameTime_HasPenalty(const GameTime *gameTime); +void GameTime_DecrementPenalty(GameTime *gameTime, int val); +void GameTime_StartPenalty(GameTime *gameTime); + +#endif // POKEPLATINUM_SYSTEM_DATA_H diff --git a/include/unk_02000C88.h b/include/unk_02000C88.h deleted file mode 100644 index f46f1abf70..0000000000 --- a/include/unk_02000C88.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef POKEPLATINUM_UNK_02000C88_H -#define POKEPLATINUM_UNK_02000C88_H - -#include - -#include "overlay_manager.h" - -void sub_02000EC4(FSOverlayID param0, const OverlayManagerTemplate *param1); -void InitRNG(void); -void HandleConsoleFold(void); - -#endif // POKEPLATINUM_UNK_02000C88_H diff --git a/include/unk_02017428.h b/include/unk_02017428.h index ac92092911..24d357f2e2 100644 --- a/include/unk_02017428.h +++ b/include/unk_02017428.h @@ -3,8 +3,8 @@ #include "play_time.h" -void sub_02017428(void); -void sub_02017434(PlayTime *playTime); +void PlayTime_FlagNotStarted(void); +void PlayTime_Start(PlayTime *playTime); void sub_02017458(void); #endif // POKEPLATINUM_UNK_02017428_H diff --git a/include/unk_02025CB0.h b/include/unk_02025CB0.h deleted file mode 100644 index 0fb3dd2955..0000000000 --- a/include/unk_02025CB0.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef POKEPLATINUM_UNK_02025CB0_H -#define POKEPLATINUM_UNK_02025CB0_H - -#include "struct_decls/struct_02025CCC_decl.h" -#include "struct_defs/struct_02055BA8.h" - -#include "savedata.h" - -int SystemData_SaveSize(void); -void SystemData_Init(UnkStruct_02025CCC *param0); -UnkStruct_02025CCC *sub_02025CCC(SaveData *param0); -UnkStruct_02055BA8 *sub_02025CD8(SaveData *param0); -void sub_02025CE4(UnkStruct_02025CCC *param0); -BOOL sub_02025D10(const UnkStruct_02025CCC *param0); -BOOL sub_02025D40(const UnkStruct_02025CCC *param0); -u8 sub_02025D5C(const UnkStruct_02025CCC *param0); -u8 sub_02025D60(const UnkStruct_02025CCC *param0); -BOOL sub_02025D64(const UnkStruct_02025CCC *param0); -void sub_02025D6C(UnkStruct_02025CCC *param0, BOOL param1); -s32 sub_02025D74(const UnkStruct_02025CCC *param0); -void sub_02025D78(UnkStruct_02025CCC *param0, s32 param1); -void sub_02025D84(UnkStruct_02055BA8 *param0); -BOOL sub_02025DB8(const UnkStruct_02055BA8 *param0); -void sub_02025DC8(UnkStruct_02055BA8 *param0, int param1); -void sub_02025DE8(UnkStruct_02055BA8 *param0); - -#endif // POKEPLATINUM_UNK_02025CB0_H diff --git a/include/unk_02027B70.h b/include/unk_02027B70.h deleted file mode 100644 index 4359636497..0000000000 --- a/include/unk_02027B70.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef POKEPLATINUM_UNK_02027B70_H -#define POKEPLATINUM_UNK_02027B70_H - -#include "struct_decls/struct_02027854_decl.h" -#include "struct_defs/struct_02027BF4.h" - -void sub_02027B70(UnkStruct_02027854 *param0); -void sub_02027B90(UnkStruct_02027854 *param0, int param1, const u16 *param2, int param3); -UnkStruct_02027BF4 *sub_02027BF4(int param0); -int sub_02027D04(const UnkStruct_02027854 *param0, int param1); -int sub_02027D10(const UnkStruct_02027854 *param0, int param1); -int sub_02027D18(const UnkStruct_02027854 *param0, int param1); -int sub_02027D34(const UnkStruct_02027854 *param0, int param1); -void sub_02027D40(UnkStruct_02027854 *param0, int param1, const UnkStruct_02027BF4 *param2, int param3); -void sub_02027D78(UnkStruct_02027854 *param0, int param1); -BOOL sub_02027D84(const UnkStruct_02027854 *param0, int param1); -void sub_02027D90(UnkStruct_02027854 *param0, int param1, BOOL param2); -int sub_02027D9C(const UnkStruct_02027854 *param0, int param1); -void sub_02027DA8(UnkStruct_02027854 *param0, int param1, int param2); -int sub_02027DB4(const UnkStruct_02027854 *param0, int param1); -int sub_02027DC0(UnkStruct_02027854 *param0, int param1); -void sub_02027EAC(UnkStruct_02027854 *param0, const UnkStruct_02027BF4 *param1, int param2); - -#endif // POKEPLATINUM_UNK_02027B70_H diff --git a/include/unk_0202B37C.h b/include/unk_0202B37C.h deleted file mode 100644 index 81fbc9375a..0000000000 --- a/include/unk_0202B37C.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef POKEPLATINUM_UNK_0202B37C_H -#define POKEPLATINUM_UNK_0202B37C_H - -#include "struct_decls/struct_0202B4A0_decl.h" -#include "struct_defs/struct_0202B510.h" - -#include "savedata.h" -#include "strbuf.h" - -int RandomGroup_SaveSize(void); -void sub_0202B384(UnkStruct_0202B4A0 *param0, int param1, int param2); -void RandomGroup_Init(UnkStruct_0202B4A0 *param0); -void sub_0202B3D8(UnkStruct_0202B4A0 *param0, u32 param1); -u32 sub_0202B400(UnkStruct_0202B4A0 *param0, int param1); -void sub_0202B40C(UnkStruct_0202B4A0 *param0, int param1, u32 param2); -u32 sub_0202B428(UnkStruct_0202B4A0 *param0); -const u16 *sub_0202B42C(const UnkStruct_0202B4A0 *param0, int param1, int param2); -void sub_0202B444(UnkStruct_0202B4A0 *param0, int param1, int param2, Strbuf *param3); -void sub_0202B470(UnkStruct_0202B4A0 *param0, int param1, int param2); -int sub_0202B47C(const UnkStruct_0202B4A0 *param0, int param1); -int sub_0202B488(const UnkStruct_0202B4A0 *param0, int param1); -void sub_0202B494(UnkStruct_0202B4A0 *param0, int param1, int param2); -UnkStruct_0202B4A0 *sub_0202B4A0(SaveData *param0); -BOOL sub_0202B4AC(const UnkStruct_0202B4A0 *param0, int param1); -BOOL sub_0202B4C4(const UnkStruct_0202B4A0 *param0, int param1); -BOOL sub_0202B4D8(const UnkStruct_0202B4A0 *param0, const u16 *param1); -BOOL sub_0202B510(const UnkStruct_0202B510 *param0); -BOOL sub_0202B530(const UnkStruct_0202B510 *param0, const UnkStruct_0202B510 *param1); - -#endif // POKEPLATINUM_UNK_0202B37C_H diff --git a/include/unk_0203A7D8.h b/include/unk_0203A7D8.h index 8bad84e8d7..1fae3ab486 100644 --- a/include/unk_0203A7D8.h +++ b/include/unk_0203A7D8.h @@ -1,10 +1,10 @@ #ifndef POKEPLATINUM_UNK_0203A7D8_H #define POKEPLATINUM_UNK_0203A7D8_H -#include "struct_defs/struct_02049FA8.h" - #include "field/field_system_decl.h" +#include "location.h" + int sub_0203A7EC(void); void sub_0203A7F0(int param0, Location *param1); void sub_0203A824(int param0, Location *param1); diff --git a/include/unk_0203D178.h b/include/unk_0203D178.h deleted file mode 100644 index ed8c699ee5..0000000000 --- a/include/unk_0203D178.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef POKEPLATINUM_UNK_0203D178_H -#define POKEPLATINUM_UNK_0203D178_H - -#include "struct_defs/struct_02049FA8.h" - -#include "savedata.h" - -void sub_0203D178(Location *param0); -void sub_0203D190(Location *param0); -void sub_0203D1A8(SaveData *param0); - -#endif // POKEPLATINUM_UNK_0203D178_H diff --git a/include/unk_0206A8DC.h b/include/unk_0206A8DC.h index 1a3a51997b..b103b5e456 100644 --- a/include/unk_0206A8DC.h +++ b/include/unk_0206A8DC.h @@ -3,7 +3,7 @@ #include "vars_flags.h" -void sub_0206A92C(VarsFlags *param0); +void VarsFlags_SetBagAvailable(VarsFlags *param0); BOOL sub_0206A938(VarsFlags *param0); void sub_0206A944(VarsFlags *param0); BOOL sub_0206A954(VarsFlags *param0); diff --git a/platinum.us/main.lsf b/platinum.us/main.lsf index c5555713e3..a8590307f8 100644 --- a/platinum.us/main.lsf +++ b/platinum.us/main.lsf @@ -103,7 +103,7 @@ Static main Object main.nef.p/src_unk_02024358.c.o Object main.nef.p/src_savedata_save_table.c.o Object main.nef.p/src_savedata.c.o - Object main.nef.p/src_unk_02025CB0.c.o + Object main.nef.p/src_system_data.c.o Object main.nef.p/src_save_player.c.o Object main.nef.p/src_trainer_info.c.o Object main.nef.p/src_unk_0202602C.c.o @@ -112,7 +112,7 @@ Static main Object main.nef.p/src_unk_0202631C.c.o Object main.nef.p/src_savedata_misc.c.o Object main.nef.p/src_game_options.c.o - Object main.nef.p/src_unk_02027B70.c.o + Object main.nef.p/src_berry_patches.c.o Object main.nef.p/src_unk_02027F50.c.o Object main.nef.p/src_unk_02027F84.c.o Object main.nef.p/src_unk_02028124.c.o @@ -120,7 +120,7 @@ Static main Object main.nef.p/src_unk_020298BC.c.o Object main.nef.p/src_poffin.c.o Object main.nef.p/src_unk_0202ACE0.c.o - Object main.nef.p/src_unk_0202B37C.c.o + Object main.nef.p/src_record_mixed_rng.c.o Object main.nef.p/src_coins.c.o Object main.nef.p/src_journal.c.o Object main.nef.p/src_unk_0202C7FC.c.o @@ -177,7 +177,7 @@ Static main Object main.nef.p/src_field_menu.c.o Object main.nef.p/src_unk_0203C954.c.o Object main.nef.p/src_field_system.c.o - Object main.nef.p/src_unk_0203D178.c.o + Object main.nef.p/src_location.c.o Object main.nef.p/src_unk_0203D1B8.c.o Object main.nef.p/src_field_script_context.c.o Object main.nef.p/src_script_manager.c.o @@ -1096,11 +1096,10 @@ Overlay overlay56 Object main.nef.p/src_overlay056_ov56_022561C0.c.o } -Overlay overlay57 +Overlay game_start { After main - Object main.nef.p/src_overlay057_ov57_021D0D80.c.o - Object main.nef.p/src_overlay057_ov57_021D0F30.c.o + Object main.nef.p/src_game_start.c.o } Overlay overlay58 diff --git a/platinum.us/sbins.sha1 b/platinum.us/sbins.sha1 index ab809f1012..c17c8d3b7a 100644 --- a/platinum.us/sbins.sha1 +++ b/platinum.us/sbins.sha1 @@ -56,7 +56,7 @@ b38da9fe733a6a1213ff217f4e2788e3ae2011a4 *overlay47.sbin 395bbb8597227e687f61cea574c2219c7c77d1d1 *overlay54.sbin ea68f11d110d5929d18eeaad9cf3f1792986ab7f *overlay55.sbin 1b89fbbf7576f21608df1334606ed2e77f5e21ea *overlay56.sbin -88b06ba661770c8feef9ec96bcee6942819fbda4 *overlay57.sbin +88b06ba661770c8feef9ec96bcee6942819fbda4 *game_start.sbin 9b7c8c69b165a8a4f1da4ff4fc73bdc0af52def8 *overlay58.sbin 43b9d869fc580cb7e6af6ef95cbbc015b5542d50 *overlay59.sbin 0a0cfedfb93a08ff8fd187d6e62a5c9a1e3056cc *overlay60.sbin diff --git a/res/text/meson.build b/res/text/meson.build index cf2af63274..8ee52c4390 100644 --- a/res/text/meson.build +++ b/res/text/meson.build @@ -420,8 +420,8 @@ message_bank_files = files( 'message_bank_unk_0420.gmm', 'message_bank_unk_0421.gmm', 'message_bank_unk_0422.gmm', - 'message_bank_unk_0423.gmm', - 'message_bank_unk_0424.gmm', + 'message_bank_berry_descriptions.gmm', + 'message_bank_berry_names.gmm', 'message_bank_unk_0425.gmm', 'message_bank_unk_0426.gmm', 'message_bank_unk_0427.gmm', diff --git a/res/text/message_bank_unk_0423.gmm b/res/text/message_bank_berry_descriptions.gmm similarity index 100% rename from res/text/message_bank_unk_0423.gmm rename to res/text/message_bank_berry_descriptions.gmm diff --git a/res/text/message_bank_unk_0424.gmm b/res/text/message_bank_berry_names.gmm similarity index 100% rename from res/text/message_bank_unk_0424.gmm rename to res/text/message_bank_berry_names.gmm diff --git a/res/text/message_banks.order b/res/text/message_banks.order index 5864cf81f9..de8eadabab 100644 --- a/res/text/message_banks.order +++ b/res/text/message_banks.order @@ -421,8 +421,8 @@ message_bank_unk_0419 message_bank_unk_0420 message_bank_unk_0421 message_bank_unk_0422 -message_bank_unk_0423 -message_bank_unk_0424 +message_bank_berry_descriptions +message_bank_berry_names message_bank_unk_0425 message_bank_unk_0426 message_bank_unk_0427 diff --git a/src/berry_data.c b/src/berry_data.c index 6c6268a0c6..bad480019b 100644 --- a/src/berry_data.c +++ b/src/berry_data.c @@ -1,34 +1,22 @@ #include "berry_data.h" -#include -#include +#include "constants/items.h" +#include "constants/narc.h" + +#include "text/pl_msg.naix" #include "message.h" #include "narc.h" #include "strbuf.h" -typedef struct BerryData { - u16 size; - u8 firmness; - u8 yieldCategory; - u8 stageDuration; - u8 moistureDrainRate; - u8 spiciness; - u8 dryness; - u8 sweetness; - u8 bitterness; - u8 sourness; - u8 smoothness; -} BerryData; - NARC *BerryData_NARC_ctor(u32 heapID) { return NARC_ctor(NARC_INDEX_ITEMTOOL__ITEMDATA__NUTS_DATA, heapID); } -BerryData *sub_020973A8(NARC *param0, u32 param1, u32 param2) +BerryData *BerryData_LoadFromOpenNARC(NARC *narc, u32 memberIdx, u32 heapID) { - return NARC_AllocAndReadWholeMember(param0, 0 + param1, param2); + return NARC_AllocAndReadWholeMember(narc, memberIdx, heapID); } void BerryData_NARC_dtor(NARC *narc) @@ -36,66 +24,58 @@ void BerryData_NARC_dtor(NARC *narc) NARC_dtor(narc); } -BerryData *BerryData_LoadDataByNarcMemberIndex(u32 index, u32 heapID) +BerryData *BerryData_Load(u32 memberIdx, u32 heapID) { - return NARC_AllocAndReadWholeMemberByIndexPair(NARC_INDEX_ITEMTOOL__ITEMDATA__NUTS_DATA, 0 + index, heapID); + return NARC_AllocAndReadWholeMemberByIndexPair(NARC_INDEX_ITEMTOOL__ITEMDATA__NUTS_DATA, memberIdx, heapID); } BerryData *BerryData_LoadDataByItemID(u32 itemID, u32 heapID) { - return BerryData_LoadDataByNarcMemberIndex(itemID - 149, heapID); + return BerryData_Load(itemID - FIRST_BERRY_IDX, heapID); } u32 BerryData_GetAttribute(BerryData *berryData, u32 attributeID) { switch (attributeID) { - case 0: + case BERRYATTR_SIZE: return berryData->size; - case 1: + case BERRYATTR_FIRMNESS: return berryData->firmness; - case 2: + case BERRYATTR_YIELD_CATEGORY: return berryData->yieldCategory; - case 3: + case BERRYATTR_STAGE_DURATION: return berryData->stageDuration; - case 4: + case BERRYATTR_MOISTURE_DRAIN_RATE: return berryData->moistureDrainRate; - case 5: + case BERRYATTR_SPICINESS: return berryData->spiciness; - case 6: + case BERRYATTR_DRYNESS: return berryData->dryness; - case 7: + case BERRYATTR_SWEETNESS: return berryData->sweetness; - case 8: + case BERRYATTR_BITTERNESS: return berryData->bitterness; - case 9: + case BERRYATTR_SOURNESS: return berryData->sourness; - case 10: + case BERRYATTR_SMOOTHNESS: return berryData->smoothness; } return 0; } -Strbuf *BerryData_AllocAndGetName(u16 index, u32 heapID) +Strbuf *BerryData_AllocAndGetName(u16 memberIdx, u32 heapID) { - MessageLoader *v0; - Strbuf *v1; - - v0 = MessageLoader_Init(1, 26, 424, heapID); - v1 = MessageLoader_GetNewStrbuf(v0, index); - - MessageLoader_Free(v0); - return v1; + MessageLoader *loader = MessageLoader_Init(MESSAGE_LOADER_NARC_HANDLE, NARC_INDEX_MSGDATA__PL_MSG, message_bank_berry_names, heapID); + Strbuf *name = MessageLoader_GetNewStrbuf(loader, memberIdx); + MessageLoader_Free(loader); + return name; } -Strbuf *BerryData_AllocAndGetDescription(u16 index, u16 heapID) +Strbuf *BerryData_AllocAndGetDescription(u16 memberIdx, u16 heapID) { - MessageLoader *v0; - Strbuf *v1; - - v0 = MessageLoader_Init(1, 26, 423, heapID); - v1 = MessageLoader_GetNewStrbuf(v0, index); - - MessageLoader_Free(v0); - return v1; + MessageLoader *loader = MessageLoader_Init(MESSAGE_LOADER_NARC_HANDLE, NARC_INDEX_MSGDATA__PL_MSG, message_bank_berry_descriptions, heapID); + Strbuf *desc = MessageLoader_GetNewStrbuf(loader, memberIdx); + MessageLoader_Free(loader); + return desc; } diff --git a/src/berry_patches.c b/src/berry_patches.c new file mode 100644 index 0000000000..c625c9d39a --- /dev/null +++ b/src/berry_patches.c @@ -0,0 +1,329 @@ +#include "berry_patches.h" + +#include "constants/heap.h" +#include "constants/items.h" + +#include "berry_data.h" +#include "heap.h" +#include "narc.h" + +#define BASE_HARVEST_STAGES 4 +#define BASE_MAX_REPLANT_COUNT 10 +#define MAX_MOISTURE_RATING 100 +#define MAX_YIELD_RATING 5 + +static void ZeroBerryPatch(BerryPatch *berryPatch); +static int CalcBerryYield(BerryPatch *berryPatch, const BerryGrowthData *growthData); +static int CalcMinutesRemainingInStage(const BerryGrowthData *growthData, int berryID, enum MulchType mulchType); +static int CalcMoistureDrainRate(const BerryGrowthData *growthData, int berryID, enum MulchType mulchType); +static int GetHarvestTimeWithMulch(const BerryPatch *berryPatch); +static int GetTotalReplantCountWithMulch(const BerryPatch *berryPatch); +static int CalcTotalStageCount(BerryPatch *berryPatch); +static void AdvancePatchGrowth(BerryPatch *berryPatch, const BerryGrowthData *growthData); +static void DrainPatchMoisture(BerryPatch *berryPatch, const BerryGrowthData *growthData, int minutesPassed); + +void BerryPatches_Clear(BerryPatch *patches) +{ + MI_CpuClear8(patches, sizeof(BerryPatch) * MAX_BERRY_PATCHES); + for (int i = 0; i < MAX_BERRY_PATCHES; i++) { + patches[i].growthStage = BERRY_GROWTH_STAGE_NONE; + patches[i].berryID = 0; + } +} + +void BerryPatches_Init(BerryPatch *patches, enum HeapId heapID, const u16 *initPatches, int initSize) +{ + BerryGrowthData *growthData = BerryGrowthData_Init(heapID); + + for (int i = 0; i < MAX_BERRY_PATCHES || i < initSize; i++) { + ZeroBerryPatch(&patches[i]); + + patches[i].berryID = initPatches[i * 2] - FIRST_BERRY_IDX + 1; + patches[i].growthStage = BERRY_GROWTH_STAGE_FRUIT; + patches[i].stageMinutesRemaining = CalcMinutesRemainingInStage(growthData, patches[i].berryID, patches[i].mulchType) * 4; + patches[i].yield = initPatches[i * 2 + 1]; + patches[i].moistureRating = MAX_MOISTURE_RATING; + patches[i].yieldRating = 3; + } + + Heap_FreeToHeap(growthData); +} + +BerryGrowthData *BerryGrowthData_Init(enum HeapId heapID) +{ + BerryGrowthData *growthData; + BerryData *berryData; + NARC *narc; + + narc = BerryData_NARC_ctor(heapID); + growthData = Heap_AllocFromHeap(heapID, sizeof(BerryGrowthData) * NUM_BERRIES); + + for (int i = 0; i < NUM_BERRIES; i++) { + berryData = BerryData_LoadFromOpenNARC(narc, i, heapID); + + growthData[i].stageDuration = BerryData_GetAttribute(berryData, BERRYATTR_STAGE_DURATION); + growthData[i].moistureDrainRate = BerryData_GetAttribute(berryData, BERRYATTR_MOISTURE_DRAIN_RATE); + growthData[i].yieldCategory = BerryData_GetAttribute(berryData, BERRYATTR_YIELD_CATEGORY); + + Heap_FreeToHeap(berryData); + } + + BerryData_NARC_dtor(narc); + return growthData; +} + +static void ZeroBerryPatch(BerryPatch *berryPatch) +{ + berryPatch->berryID = 0; + berryPatch->growthStage = BERRY_GROWTH_STAGE_NONE; + berryPatch->stageMinutesRemaining = 0; + berryPatch->moistureMinutesRemaining = 0; + berryPatch->replantCount = 0; + berryPatch->yield = 0; + berryPatch->moistureRating = 0; + berryPatch->yieldRating = 0; + berryPatch->mulchType = 0; + berryPatch->isGrowing = FALSE; +} + +static int CalcBerryYield(BerryPatch *berryPatch, const BerryGrowthData *growthData) +{ + return growthData[berryPatch->berryID - 1].yieldCategory * berryPatch->yieldRating; +} + +static int CalcMinutesRemainingInStage(const BerryGrowthData *growthData, int berryID, enum MulchType mulchType) +{ + int minutesRemaining = growthData[berryID - 1].stageDuration * 60; + + if (mulchType == MULCH_TYPE_GROWTH) { + minutesRemaining = (minutesRemaining * 3) / 4; + } else if (mulchType == MULCH_TYPE_DAMP) { + minutesRemaining = minutesRemaining + (minutesRemaining / 2); + } + + return minutesRemaining; +} + +static int CalcMoistureDrainRate(const BerryGrowthData *growthData, int berryID, enum MulchType mulchType) +{ + int drainRate = growthData[berryID - 1].moistureDrainRate; + + if (mulchType == MULCH_TYPE_DAMP) { + return drainRate / 2; + } else if (mulchType == MULCH_TYPE_GROWTH) { + return drainRate + drainRate / 2; + } else { + return drainRate; + } +} + +static int GetHarvestTimeWithMulch(const BerryPatch *berryPatch) +{ + if (berryPatch->mulchType == MULCH_TYPE_STABLE) { + return BASE_HARVEST_STAGES + (BASE_HARVEST_STAGES / 2); + } else { + return BASE_HARVEST_STAGES; + } +} + +static int GetTotalReplantCountWithMulch(const BerryPatch *berryPatch) +{ + if (berryPatch->mulchType == MULCH_TYPE_GOOEY) { + return BASE_MAX_REPLANT_COUNT + (BASE_MAX_REPLANT_COUNT / 2); + } else { + return BASE_MAX_REPLANT_COUNT; + } +} + +static int CalcTotalStageCount(BerryPatch *berryPatch) +{ + return 1 + (3 + GetHarvestTimeWithMulch(berryPatch)) * GetTotalReplantCountWithMulch(berryPatch); +} + +enum BerryGrowthStage BerryPatches_GetPatchGrowthStage(const BerryPatch *patches, int patchID) +{ + return patches[patchID].growthStage; +} + +int BerryPatches_GetPatchBerryID(const BerryPatch *patches, int patchID) +{ + return patches[patchID].berryID; +} + +enum SoilMoisture BerryPatches_GetPatchMoisture(const BerryPatch *patches, int patchID) +{ + int moistureRating = patches[patchID].moistureRating; + if (moistureRating == 0) { + return SOIL_VERY_DRY; + } else if (moistureRating <= 50) { + return SOIL_DRY; + } else { + return SOIL_MOIST; + } +} + +int BerryPatches_GetPatchYieldRating(const BerryPatch *patches, int patchID) +{ + return patches[patchID].yieldRating; +} + +void BerryPatches_PlantInPatch(BerryPatch *patches, int patchID, const BerryGrowthData *growthData, int berryID) +{ + patches[patchID].berryID = berryID; + patches[patchID].growthStage = BERRY_GROWTH_STAGE_PLANTED; + patches[patchID].stageMinutesRemaining = CalcMinutesRemainingInStage(growthData, berryID, patches[patchID].mulchType); + patches[patchID].moistureMinutesRemaining = 0; + patches[patchID].replantCount = 0; + patches[patchID].yield = 0; + patches[patchID].moistureRating = MAX_MOISTURE_RATING; + patches[patchID].yieldRating = MAX_YIELD_RATING; + patches[patchID].isGrowing = TRUE; +} + +void BerryPatches_ResetPatchMoisture(BerryPatch *patches, int patchID) +{ + patches[patchID].moistureRating = MAX_MOISTURE_RATING; +} + +BOOL BerryPatches_IsPatchGrowing(const BerryPatch *patches, int patchID) +{ + return patches[patchID].isGrowing; +} + +void BerryPatches_SetIsPatchGrowing(BerryPatch *patches, int patchID, BOOL isGrowing) +{ + patches[patchID].isGrowing = isGrowing; +} + +enum MulchType BerryPatches_GetPatchMulchType(const BerryPatch *patches, int patchID) +{ + return patches[patchID].mulchType; +} + +void BerryPatches_SetPatchMulchType(BerryPatch *patches, int patchID, enum MulchType mulchType) +{ + patches[patchID].mulchType = mulchType; +} + +int BerryPatches_GetPatchYield(const BerryPatch *patches, int patchID) +{ + return patches[patchID].yield; +} + +int BerryPatches_HarvestPatch(BerryPatch *patches, int patchID) +{ + int yield = patches[patchID].yield; + ZeroBerryPatch(&patches[patchID]); + return yield; +} + +static void AdvancePatchGrowth(BerryPatch *berryPatch, const BerryGrowthData *growthData) +{ + switch (berryPatch->growthStage) { + case BERRY_GROWTH_STAGE_NONE: + GF_ASSERT(FALSE); + break; + + case BERRY_GROWTH_STAGE_PLANTED: + case BERRY_GROWTH_STAGE_SPROUTED: + case BERRY_GROWTH_STAGE_GROWING: + berryPatch->growthStage++; + break; + + case BERRY_GROWTH_STAGE_BLOOMING: + berryPatch->yield = CalcBerryYield(berryPatch, growthData); + if (berryPatch->yield < 2) { + berryPatch->yield = 2; + } + + berryPatch->growthStage++; + + break; + + case BERRY_GROWTH_STAGE_FRUIT: + berryPatch->yield = 0; + berryPatch->growthStage = BERRY_GROWTH_STAGE_SPROUTED; + berryPatch->yieldRating = MAX_YIELD_RATING; + berryPatch->replantCount++; + if (berryPatch->replantCount == GetTotalReplantCountWithMulch(berryPatch)) { + ZeroBerryPatch(berryPatch); + } + + break; + } +} + +static void DrainPatchMoisture(BerryPatch *berryPatch, const BerryGrowthData *growthData, int minutesPassed) +{ + if (berryPatch->growthStage == BERRY_GROWTH_STAGE_FRUIT) { + return; + } + + int drainageRate = CalcMoistureDrainRate(growthData, berryPatch->berryID, berryPatch->mulchType); + minutesPassed += berryPatch->moistureMinutesRemaining; + + int hoursPassed = minutesPassed / 60; + berryPatch->moistureMinutesRemaining = minutesPassed % 60; + + if (hoursPassed == 0) { + return; + } + + if (berryPatch->moistureRating >= drainageRate * hoursPassed) { + berryPatch->moistureRating -= drainageRate * hoursPassed; + return; + } + + if (berryPatch->moistureRating > 0) { + int hoursUntilPenalty = (berryPatch->moistureRating + (drainageRate - 1)) / drainageRate; + hoursPassed -= hoursUntilPenalty; + berryPatch->moistureRating = 0; + } + + if (berryPatch->yieldRating > hoursPassed) { + berryPatch->yieldRating -= hoursPassed; + } else { + berryPatch->yieldRating = 0; + } +} + +void BerryPatches_ElapseMinutes(BerryPatch *patches, const BerryGrowthData *growthData, int minutesPassed) +{ + int i; + s32 totalMinutes; + BerryPatch *patch; + + for (i = 0; i < MAX_BERRY_PATCHES; i++) { + patch = &patches[i]; + + if (patch->berryID == 0 || patch->growthStage == BERRY_GROWTH_STAGE_NONE || patch->isGrowing == FALSE) { + continue; + } + + int maxPatchLifetime = CalcMinutesRemainingInStage(growthData, patch->berryID, patch->mulchType) * CalcTotalStageCount(patch); + if (minutesPassed >= maxPatchLifetime) { + ZeroBerryPatch(patch); + continue; + } + + totalMinutes = minutesPassed; + while (patch->growthStage != BERRY_GROWTH_STAGE_NONE && totalMinutes != 0) { + if (patch->stageMinutesRemaining > totalMinutes) { + DrainPatchMoisture(patch, growthData, totalMinutes); + patch->stageMinutesRemaining -= totalMinutes; + totalMinutes = 0; + break; + } else { + DrainPatchMoisture(patch, growthData, patch->stageMinutesRemaining); + AdvancePatchGrowth(patch, growthData); + + totalMinutes -= patch->stageMinutesRemaining; + patch->stageMinutesRemaining = CalcMinutesRemainingInStage(growthData, patch->berryID, patch->mulchType); + + if (patch->growthStage == BERRY_GROWTH_STAGE_FRUIT) { + patch->stageMinutesRemaining *= GetHarvestTimeWithMulch(patch); + } + } + } + } +} diff --git a/src/comm_player_manager.c b/src/comm_player_manager.c index 89c01380c1..e149394c87 100644 --- a/src/comm_player_manager.c +++ b/src/comm_player_manager.c @@ -922,8 +922,8 @@ void CommPlayer_RecvLocationAndInit(int netId, int size, void *src, void *unused static void sub_02058644(int netId) { - UndergroundData *underground = sub_020298B0(FieldSystem_SaveData(sCommPlayerManager->fieldSystem)); - SaveData_SecretBaseRecord(FieldSystem_SaveData(sCommPlayerManager->fieldSystem)); + UndergroundData *underground = sub_020298B0(FieldSystem_GetSaveData(sCommPlayerManager->fieldSystem)); + SaveData_SecretBaseRecord(FieldSystem_GetSaveData(sCommPlayerManager->fieldSystem)); if (sCommPlayerManager->isUnderground) { if (netId == CommSys_CurNetId()) { @@ -1683,7 +1683,7 @@ void sub_02059464(int param0) sCommPlayerManager->unk_00 |= param0; } - sub_0203D128(); + FieldSystem_PauseProcessing(); sCommPlayerManager->unk_2BC = 0; } @@ -1700,10 +1700,10 @@ void sub_0205948C(int param0) if (sCommPlayerManager->unk_00 == 0) { if (0x10 != param0) { - sub_0203D140(); + FieldSystem_ResumeProcessing(); sub_02057FC4(1); } else { - sub_0203D140(); + FieldSystem_ResumeProcessing(); sCommPlayerManager->unk_2BC = 1; } } @@ -1716,13 +1716,13 @@ void sub_020594EC(void) void sub_020594FC(void) { - sub_0203D128(); + FieldSystem_PauseProcessing(); sCommPlayerManager->unk_2BC = 0; } void sub_02059514(void) { - sub_0203D140(); + FieldSystem_ResumeProcessing(); sub_02057FC4(1); } diff --git a/src/communication_information.c b/src/communication_information.c index b890b36214..009a3786fb 100644 --- a/src/communication_information.c +++ b/src/communication_information.c @@ -7,19 +7,18 @@ #include "constants/heap.h" #include "struct_decls/struct_0202B370_decl.h" -#include "struct_decls/struct_0202B4A0_decl.h" #include "struct_decls/struct_0202C878_decl.h" #include "struct_defs/struct_0202610C.h" #include "communication_system.h" #include "heap.h" +#include "record_mixed_rng.h" #include "save_player.h" #include "savedata.h" #include "trainer_info.h" #include "unk_0202602C.h" #include "unk_0202854C.h" #include "unk_0202ACE0.h" -#include "unk_0202B37C.h" #include "unk_0202C858.h" #include "unk_02033200.h" #include "unk_0203909C.h" @@ -118,7 +117,7 @@ void CommInfo_SendBattleRegulation(void) u16 netId = CommSys_CurNetId(); TrainerInfo *trainerInfo; const u16 *v2; - UnkStruct_0202B4A0 *v3 = sub_0202B4A0(sCommInfo->saveData); + RecordMixedRNG *v3 = SaveData_GetRecordMixedRNG(sCommInfo->saveData); UnkStruct_0202B370 *v4 = sub_0202B370(sCommInfo->saveData); UnkStruct_0202C878 *v5 = sub_0202C878(sCommInfo->saveData); @@ -131,7 +130,7 @@ void CommInfo_SendBattleRegulation(void) TrainerInfo_Copy(trainerInfo, sCommInfo->trainerInfo[netId]); OS_GetMacAddress(&sCommInfo->playerInfo[netId].macAddress[0]); - v2 = sub_0202B42C(v3, 1, 0); + v2 = RecordMixedRNG_GetEntryName(v3, 1, 0); MI_CpuCopy8(v2, sCommInfo->playerInfo[netId].unk_4C, sizeof(sCommInfo->playerInfo[netId].unk_4C)); diff --git a/src/communication_system.c b/src/communication_system.c index 40d3aad594..d03ad2dd01 100644 --- a/src/communication_system.c +++ b/src/communication_system.c @@ -1873,7 +1873,7 @@ void CommSys_Seed(MATHRandContext32 *rand) RTCTime time; GetCurrentDateTime(&date, &time); - seed = (((((((u64)date.year * 16ULL + date.month) * 32ULL) + date.day) * 32ULL + time.hour) * 64ULL + time.minute) * 64ULL + (time.second + gCoreSys.frameCounter)); + seed = (((((((u64)date.year * 16ULL + date.month) * 32ULL) + date.day) * 32ULL + time.hour) * 64ULL + time.minute) * 64ULL + (time.second + gCoreSys.vblankCounter)); MATH_InitRand32(rand, seed); } diff --git a/src/error_message_reset.c b/src/error_message_reset.c index 4fa8084444..349fdbfd7c 100644 --- a/src/error_message_reset.c +++ b/src/error_message_reset.c @@ -12,11 +12,11 @@ #include "font.h" #include "gx_layers.h" #include "heap.h" +#include "main.h" #include "message.h" #include "render_window.h" #include "strbuf.h" #include "text.h" -#include "unk_02000C88.h" #include "unk_0200A9DC.h" #include "unk_0200F174.h" #include "unk_02017728.h" diff --git a/src/field_comm_manager.c b/src/field_comm_manager.c index f49411d10e..316bcbade8 100644 --- a/src/field_comm_manager.c +++ b/src/field_comm_manager.c @@ -125,7 +125,7 @@ void FieldCommMan_StartBattleServer(FieldSystem *fieldSystem, int param1, int pa return; } - CommMan_StartBattleServer(FieldSystem_SaveData(fieldSystem), param1, param2, fieldSystem->unk_B0, 0); + CommMan_StartBattleServer(FieldSystem_GetSaveData(fieldSystem), param1, param2, fieldSystem->unk_B0, 0); FieldCommMan_Init(fieldSystem); FieldCommMan_SetTask(Task_StartBattleServer, 0); } @@ -136,7 +136,7 @@ void FieldCommMan_StartBattleClient(FieldSystem *fieldSystem, int param1, int pa return; } - CommMan_StartBattleClient(FieldSystem_SaveData(fieldSystem), param1, param2, fieldSystem->unk_B0, 0); + CommMan_StartBattleClient(FieldSystem_GetSaveData(fieldSystem), param1, param2, fieldSystem->unk_B0, 0); FieldCommMan_Init(fieldSystem); FieldCommMan_SetTask(Task_StartBattleClient, 0); } diff --git a/src/field_map_change.c b/src/field_map_change.c index 7bcc3ef022..ef6904b753 100644 --- a/src/field_map_change.c +++ b/src/field_map_change.c @@ -10,7 +10,6 @@ #include "struct_decls/struct_0203A790_decl.h" #include "struct_decls/struct_020508D4_decl.h" #include "struct_defs/map_load_mode.h" -#include "struct_defs/struct_02049FA8.h" #include "struct_defs/struct_0205EC34.h" #include "field/field_system.h" @@ -34,6 +33,7 @@ #include "heap.h" #include "inlines.h" #include "journal.h" +#include "location.h" #include "map_header.h" #include "map_header_data.h" #include "map_object.h" @@ -214,8 +214,8 @@ static void FieldMapChange_SetNewLocation(FieldSystem *fieldSystem, const Locati MapHeaderData_Load(fieldSystem, fieldSystem->location->mapId); - if (fieldSystem->location->unk_04 != -1) { - const WarpEvent *warpEvent = MapHeaderData_GetWarpEventByIndex(fieldSystem, fieldSystem->location->unk_04); + if (fieldSystem->location->warpId != WARP_ID_NONE) { + const WarpEvent *warpEvent = MapHeaderData_GetWarpEventByIndex(fieldSystem, fieldSystem->location->warpId); fieldSystem->location->x = warpEvent->x; fieldSystem->location->z = warpEvent->z; @@ -340,7 +340,7 @@ static void FieldMapChange_CreateObjects(FieldSystem *fieldSystem) fieldState = SaveData_GetFieldOverworldState(fieldSystem->saveData); playerData = FieldOverworldState_GetPlayerData(fieldState); - fieldSystem->playerAvatar = PlayerAvatar_Init(fieldSystem->mapObjMan, fieldSystem->location->x, fieldSystem->location->z, fieldSystem->location->unk_10, playerData->unk_04, gender, 0, playerData); + fieldSystem->playerAvatar = PlayerAvatar_Init(fieldSystem->mapObjMan, fieldSystem->location->x, fieldSystem->location->z, fieldSystem->location->faceDirection, playerData->unk_04, gender, 0, playerData); sub_0203A418(fieldSystem); MapObjectMan_StopAllMovement(fieldSystem->mapObjMan); @@ -687,7 +687,7 @@ void FieldTask_ChangeMapByLocation(TaskManager *taskMan, const Location *nextLoc FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); MapChangeSubData *mapChangeSub = Heap_AllocFromHeapAtEnd(11, sizeof(MapChangeSubData)); - if (sub_0203CD4C(fieldSystem)) { + if (FieldSystem_HasParentProcess(fieldSystem)) { GF_ASSERT(FALSE); return; } @@ -868,7 +868,7 @@ static void FieldTask_FadeInFly(TaskManager *taskMan) FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); MapChangeFlyData *mapChangeData = TaskManager_Environment(taskMan); - if (!sub_0203CD4C(fieldSystem)) { + if (!FieldSystem_HasParentProcess(fieldSystem)) { GF_ASSERT(FALSE); return; } @@ -999,7 +999,7 @@ static void sub_02053E5C(TaskManager *taskMan) FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); MapChangeDigData *mapChangeData = TaskManager_Environment(taskMan); - if (!sub_0203CD4C(fieldSystem)) { + if (!FieldSystem_HasParentProcess(fieldSystem)) { GF_ASSERT(FALSE); return; } @@ -1375,7 +1375,7 @@ void sub_020544F0(TaskManager *taskMan, const Location *nextLocation) FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); MapChangeSubData *mapChangeData = Heap_AllocFromHeapAtEnd(11, sizeof(MapChangeSubData)); - if (sub_0203CD4C(fieldSystem)) { + if (FieldSystem_HasParentProcess(fieldSystem)) { GF_ASSERT(FALSE); return; } diff --git a/src/field_menu.c b/src/field_menu.c index f27b3aa99d..f3a7fe87d3 100644 --- a/src/field_menu.c +++ b/src/field_menu.c @@ -28,7 +28,7 @@ #include "functypes/funcptr_0203BC5C.h" #include "functypes/funcptr_02050904.h" #include "gmm/message_bank_unk_0367.h" -#include "overlay005/ov5_021D0D80.h" +#include "overlay005/fieldmap.h" #include "overlay005/ov5_021D2F14.h" #include "overlay005/save_info_window.h" #include "overlay021/struct_ov21_021D0D80.h" @@ -370,7 +370,7 @@ static u32 sub_0203ABD0(FieldSystem *fieldSystem) v0 |= 0x2; } - if (sub_0206A938(SaveData_GetVarsFlags(fieldSystem->saveData)) == 0) { + if (VarsFlags_CheckBagAvailable(SaveData_GetVarsFlags(fieldSystem->saveData)) == 0) { v0 |= 0x4; } @@ -1308,7 +1308,7 @@ static BOOL sub_0203BC5C(TaskManager *taskMan) v6->unk_24 = sub_0207CB94(v2); v6->unk_1C = fieldSystem; - sub_0203CD84(fieldSystem, &Unk_020F1E88, v6); + FieldSystem_StartChildProcess(fieldSystem, &Unk_020F1E88, v6); menu->unk_25C = v6; sub_0203B674(menu, sub_0203B7C0); } break; @@ -1355,7 +1355,7 @@ static BOOL sub_0203BC5C(TaskManager *taskMan) v13->unk_20 = 10; } - sub_0203CD84(fieldSystem, &Unk_020F1E88, v13); + FieldSystem_StartChildProcess(fieldSystem, &Unk_020F1E88, v13); menu->unk_25C = v13; sub_0203B674(menu, sub_0203B7C0); } @@ -1647,7 +1647,7 @@ static BOOL sub_0203C1C8(TaskManager *taskMan) v3->unk_26 = v2->move; v3->unk_28 = v2->selectedSlot; - sub_0203CD84(fieldSystem, &Unk_020F1E88, v3); + FieldSystem_StartChildProcess(fieldSystem, &Unk_020F1E88, v3); Heap_FreeToHeap(menu->unk_260); menu->unk_25C = v3; sub_0203B674(menu, sub_0203B7C0); @@ -1862,7 +1862,7 @@ static void sub_0203C668(FieldSystem *fieldSystem, FieldMenu *param1, u8 param2) sub_02097750(param1->unk_25C, Party_GetPokemonBySlotIndex(partyMan->unk_00, v0->unk_02)); sub_02097770(param1->unk_25C); - sub_0203CD84(fieldSystem, &Unk_020F1E88, partyMan); + FieldSystem_StartChildProcess(fieldSystem, &Unk_020F1E88, partyMan); param1->unk_25C = partyMan; sub_0203B674(param1, sub_0203B7C0); diff --git a/src/field_overworld_state.c b/src/field_overworld_state.c index 57df128f70..b45449dd5c 100644 --- a/src/field_overworld_state.c +++ b/src/field_overworld_state.c @@ -3,13 +3,13 @@ #include #include -#include "struct_defs/struct_02049FA8.h" #include "struct_defs/struct_020556C4.h" #include "struct_defs/struct_0205EC34.h" #include "struct_defs/struct_02061D3C.h" #include "field/field_system.h" +#include "location.h" #include "map_object.h" #include "player_avatar.h" #include "savedata.h" @@ -17,7 +17,7 @@ #include "unk_020556C4.h" typedef struct UnkStruct_0203A790_t { - Location unk_00; + Location player; Location entrance; Location previous; Location special; @@ -64,9 +64,9 @@ void FieldOverworldState_Init(FieldOverworldState *fieldState) fieldState->warpId = sub_0203A7EC(); } -Location *sub_0203A720(FieldOverworldState *fieldState) +Location *FieldOverworldState_GetPlayerLocation(FieldOverworldState *fieldState) { - return &fieldState->unk_00; + return &fieldState->player; } Location *FieldOverworldState_GetEntranceLocation(FieldOverworldState *fieldState) diff --git a/src/field_system.c b/src/field_system.c index d202bac7a6..1a2b39b8f5 100644 --- a/src/field_system.c +++ b/src/field_system.c @@ -4,13 +4,12 @@ #include #include "constants/field/map_load.h" +#include "constants/heap.h" +#include "consts/map.h" -#include "struct_defs/struct_0203CC84.h" - -#include "field/field_system_sub1_decl.h" #include "field/field_system_sub2_t.h" -#include "overlay005/const_ov5_021F89B0.h" #include "overlay005/field_control.h" +#include "overlay005/fieldmap.h" #include "overlay005/ov5_021DD6FC.h" #include "overlay005/ov5_021DFB54.h" #include "overlay005/ov5_021E1B08.h" @@ -28,11 +27,11 @@ #include "field_system.h" #include "game_overlay.h" #include "heap.h" +#include "main.h" #include "map_header_data.h" #include "overlay_manager.h" #include "pokeradar.h" #include "savedata.h" -#include "unk_02000C88.h" #include "unk_02039C80.h" #include "unk_020508D4.h" #include "unk_0205F180.h" @@ -42,158 +41,143 @@ FS_EXTERN_OVERLAY(overlay5); FS_EXTERN_OVERLAY(overlay77); -typedef struct FieldSystem_sub1_t { - OverlayManager *unk_00; - OverlayManager *unk_04; - BOOL unk_08; - BOOL unk_0C; -}; - -static FieldSystem *FieldSystem_Init(OverlayManager *param0); -static BOOL FieldSystem_Run(FieldSystem *fieldSystem); -static void sub_0203CE6C(OverlayManager *param0); -static void FieldSystem_Control(FieldSystem *fieldSystem); +static BOOL InitFieldSystemContinue(OverlayManager *ovyManager, int *state); +static BOOL InitFieldSystemNewGame(OverlayManager *ovyManager, int *state); +static BOOL ExecuteFieldProcesses(OverlayManager *ovyManager, int *state); +static BOOL ReturnToTitleScreen(OverlayManager *ovyManager, int *state); +static FieldSystem *InitFieldSystem(OverlayManager *ovyManager); +static void TeardownFieldSystem(OverlayManager *ovyManager); +static void ExecuteAndCleanupIfDone(OverlayManager **ovyManagerPtr); +static BOOL HandleInputsEventsAndProcesses(FieldSystem *fieldSystem); +static void HandleFieldInput(FieldSystem *fieldSystem); static FieldSystem *sFieldSystem; -static int FieldSystem_InitContinue(OverlayManager *overlayMan, int *param1) +static BOOL InitFieldSystemContinue(OverlayManager *ovyManager, int *state) { - UnkStruct_0203CC84 *v0 = OverlayManager_Args(overlayMan); - - sFieldSystem = FieldSystem_Init(overlayMan); + ApplicationArgs *argv = OverlayManager_Args(ovyManager); + sFieldSystem = InitFieldSystem(ovyManager); - if (v0->unk_04) { + if (argv->error) { FieldSystem_StartLoadMapFromErrorTask(sFieldSystem); } else { FieldSystem_SetLoadSavedGameMapTask(sFieldSystem); } - v0->unk_04 = 0; - return 1; + argv->error = FALSE; + return TRUE; } -static int FieldSystem_InitNewGame(OverlayManager *overlayMan, int *param1) +static BOOL InitFieldSystemNewGame(OverlayManager *ovyManager, int *state) { - sFieldSystem = FieldSystem_Init(overlayMan); + sFieldSystem = InitFieldSystem(ovyManager); FieldSystem_SetLoadNewGameSpawnTask(sFieldSystem); - return 1; + return TRUE; } -static int FieldSystem_Main(OverlayManager *overlayMan, int *param1) +static BOOL ExecuteFieldProcesses(OverlayManager *ovyManager, int *state) { - FieldSystem *fieldSystem = OverlayManager_Data(overlayMan); - - if (FieldSystem_Run(fieldSystem)) { - return 1; + if (HandleInputsEventsAndProcesses(OverlayManager_Data(ovyManager))) { + return TRUE; } else { - return 0; + return FALSE; } } -static int FieldSystem_Exit(OverlayManager *overlayMan, int *param1) +static BOOL ReturnToTitleScreen(OverlayManager *ovyManager, int *state) { - sub_0203CE6C(overlayMan); - sub_02000EC4(FS_OVERLAY_ID(overlay77), &Unk_ov77_021D742C); - return 1; + TeardownFieldSystem(ovyManager); + EnqueueApplication(FS_OVERLAY_ID(overlay77), &gTitleScreenOverlayTemplate); + return TRUE; } const OverlayManagerTemplate gFieldSystemNewGameTemplate = { - FieldSystem_InitNewGame, - FieldSystem_Main, - FieldSystem_Exit, - 0xffffffff + .init = InitFieldSystemNewGame, + .main = ExecuteFieldProcesses, + .exit = ReturnToTitleScreen, + .overlayID = FS_OVERLAY_ID_NONE, }; const OverlayManagerTemplate gFieldSystemContinueTemplate = { - FieldSystem_InitContinue, - FieldSystem_Main, - FieldSystem_Exit, - 0xffffffff + .init = InitFieldSystemContinue, + .main = ExecuteFieldProcesses, + .exit = ReturnToTitleScreen, + .overlayID = FS_OVERLAY_ID_NONE, }; -void sub_0203CD00(FieldSystem *fieldSystem) +void FieldSystem_StartFieldMap(FieldSystem *fieldSystem) { - GF_ASSERT(fieldSystem->unk_00->unk_04 == NULL); - GF_ASSERT(fieldSystem->unk_00->unk_00 == NULL); - Overlay_LoadByID(FS_OVERLAY_ID(overlay5), 2); + GF_ASSERT(fieldSystem->processManager->child == NULL); + GF_ASSERT(fieldSystem->processManager->parent == NULL); + Overlay_LoadByID(FS_OVERLAY_ID(overlay5), OVERLAY_LOAD_ASYNC); - fieldSystem->unk_68 = 0; - fieldSystem->unk_00->unk_08 = 0; - fieldSystem->unk_00->unk_00 = OverlayManager_New(&gFieldMapTemplate, fieldSystem, 11); + fieldSystem->runningFieldMap = FALSE; + fieldSystem->processManager->pause = FALSE; + fieldSystem->processManager->parent = OverlayManager_New(&gFieldMapTemplate, fieldSystem, HEAP_ID_FIELDMAP); } -void sub_0203CD44(FieldSystem *fieldSystem) +void FieldSystem_FlagNotRunningFieldMap(FieldSystem *fieldSystem) { - fieldSystem->unk_68 = 0; + fieldSystem->runningFieldMap = FALSE; } -BOOL sub_0203CD4C(FieldSystem *fieldSystem) +BOOL FieldSystem_HasParentProcess(FieldSystem *fieldSystem) { - return fieldSystem->unk_00->unk_00 != NULL; + return fieldSystem->processManager->parent != NULL; } -BOOL sub_0203CD5C(FieldSystem *fieldSystem) +BOOL FieldSystem_IsRunningFieldMap(FieldSystem *fieldSystem) { - if ((fieldSystem->unk_00->unk_00 != NULL) && fieldSystem->unk_68) { - return 1; - } else { - return 0; - } + return fieldSystem->processManager->parent != NULL && fieldSystem->runningFieldMap; } -BOOL sub_0203CD74(FieldSystem *fieldSystem) +BOOL FieldSystem_HasChildProcess(FieldSystem *fieldSystem) { - return fieldSystem->unk_00->unk_04 != NULL; + return fieldSystem->processManager->child != NULL; } -void sub_0203CD84(FieldSystem *fieldSystem, const OverlayManagerTemplate *param1, void *param2) +void FieldSystem_StartChildProcess(FieldSystem *fieldSystem, const OverlayManagerTemplate *overlayTemplate, void *overlayArgs) { - GF_ASSERT(fieldSystem->unk_00->unk_04 == NULL); - sub_0203CD44(fieldSystem); - fieldSystem->unk_00->unk_04 = OverlayManager_New(param1, param2, 11); + GF_ASSERT(fieldSystem->processManager->child == NULL); + FieldSystem_FlagNotRunningFieldMap(fieldSystem); + fieldSystem->processManager->child = OverlayManager_New(overlayTemplate, overlayArgs, HEAP_ID_FIELDMAP); } -static FieldSystem *FieldSystem_Init(OverlayManager *overlayMan) +static FieldSystem *InitFieldSystem(OverlayManager *ovyManager) { - UnkStruct_0203CC84 *v0; - FieldSystem *fieldSystem; - - Heap_Create(3, 11, 0x1c000); - Heap_Create(3, 32, 0x4000); - Heap_Create(0, 91, 0x300); + Heap_Create(HEAP_ID_APPLICATION, HEAP_ID_FIELDMAP, HEAP_SIZE_FIELDMAP); + Heap_Create(HEAP_ID_APPLICATION, 32, 0x4000); + Heap_Create(HEAP_ID_SYSTEM, 91, 0x300); - fieldSystem = OverlayManager_NewData(overlayMan, sizeof(FieldSystem), 11); + FieldSystem *fieldSystem = OverlayManager_NewData(ovyManager, sizeof(FieldSystem), HEAP_ID_FIELDMAP); MI_CpuClear8(fieldSystem, sizeof(FieldSystem)); - fieldSystem->unk_00 = Heap_AllocFromHeap(11, sizeof(FieldSystem_sub1)); - fieldSystem->unk_00->unk_00 = NULL; - fieldSystem->unk_00->unk_04 = NULL; - fieldSystem->unk_00->unk_08 = 0; - fieldSystem->unk_00->unk_0C = 0; - - v0 = OverlayManager_Args(overlayMan); - - fieldSystem->saveData = v0->unk_08; + fieldSystem->processManager = Heap_AllocFromHeap(HEAP_ID_FIELDMAP, sizeof(FieldProcessManager)); + fieldSystem->processManager->parent = NULL; + fieldSystem->processManager->child = NULL; + fieldSystem->processManager->pause = FALSE; + fieldSystem->processManager->kill = FALSE; + fieldSystem->saveData = ((ApplicationArgs *)OverlayManager_Args(ovyManager))->saveData; fieldSystem->taskManager = NULL; - fieldSystem->location = sub_0203A720(SaveData_GetFieldOverworldState(fieldSystem->saveData)); + fieldSystem->location = FieldOverworldState_GetPlayerLocation(SaveData_GetFieldOverworldState(fieldSystem->saveData)); fieldSystem->unk_2C = sub_02039D6C(); - MapHeaderData_Init(fieldSystem, 11); + MapHeaderData_Init(fieldSystem, HEAP_ID_FIELDMAP); - fieldSystem->unk_98 = sub_0207D99C(11); - fieldSystem->chain = RadarChain_Init(11); + fieldSystem->unk_98 = sub_0207D99C(HEAP_ID_FIELDMAP); + fieldSystem->chain = RadarChain_Init(HEAP_ID_FIELDMAP); RadarChain_Clear(fieldSystem->chain); - fieldSystem->unk_B4 = sub_0209ACBC(11); - fieldSystem->unk_BC = sub_0209C370(11); + fieldSystem->unk_B4 = sub_0209ACBC(HEAP_ID_FIELDMAP); + fieldSystem->unk_BC = sub_0209C370(HEAP_ID_FIELDMAP); return fieldSystem; } -static void sub_0203CE6C(OverlayManager *overlayMan) +static void TeardownFieldSystem(OverlayManager *ovyManager) { - FieldSystem *fieldSystem = OverlayManager_Data(overlayMan); + FieldSystem *fieldSystem = OverlayManager_Data(ovyManager); sub_02039DE4(fieldSystem->unk_2C); MapHeaderData_Free(fieldSystem); @@ -202,108 +186,101 @@ static void sub_0203CE6C(OverlayManager *overlayMan) sub_0209ACDC(fieldSystem->unk_B4); sub_0209C388(fieldSystem->unk_BC); - Heap_FreeToHeap(fieldSystem->unk_00); - OverlayManager_FreeData(overlayMan); + Heap_FreeToHeap(fieldSystem->processManager); + OverlayManager_FreeData(ovyManager); Heap_Destroy(91); - Heap_Destroy(11); + Heap_Destroy(HEAP_ID_FIELDMAP); Heap_Destroy(32); } -static void sub_0203CECC(OverlayManager **overlayMan) +static void ExecuteAndCleanupIfDone(OverlayManager **ovyManagerPtr) { - if (*overlayMan) { - if (OverlayManager_Exec(*overlayMan)) { - OverlayManager_Free(*overlayMan); - *overlayMan = NULL; - } + if (*ovyManagerPtr && OverlayManager_Exec(*ovyManagerPtr)) { + OverlayManager_Free(*ovyManagerPtr); + *ovyManagerPtr = NULL; } } -BOOL FieldSystem_Run(FieldSystem *fieldSystem) +static BOOL HandleInputsEventsAndProcesses(FieldSystem *fieldSystem) { - BOOL v0; - - FieldSystem_Control(fieldSystem); - v0 = sub_02050958(fieldSystem); - - if ((v0 == 1) && (fieldSystem->unk_04 != NULL)) { - ov5_021EA714(fieldSystem, 0, 0); + HandleFieldInput(fieldSystem); + if (sub_02050958(fieldSystem) == TRUE && fieldSystem->unk_04 != NULL) { + ov5_021EA714(fieldSystem, POKETCH_EVENT_SLEEP, 0); } - if (fieldSystem->unk_00->unk_00) { - sub_0203CECC(&fieldSystem->unk_00->unk_00); + if (fieldSystem->processManager->parent) { + ExecuteAndCleanupIfDone(&fieldSystem->processManager->parent); - if (fieldSystem->unk_00->unk_00 == NULL) { + if (fieldSystem->processManager->parent == NULL) { Overlay_UnloadByID(FS_OVERLAY_ID(overlay5)); } - } else if (fieldSystem->unk_00->unk_04) { - sub_0203CECC(&fieldSystem->unk_00->unk_04); + } else if (fieldSystem->processManager->child) { + ExecuteAndCleanupIfDone(&fieldSystem->processManager->child); } - if (fieldSystem->unk_00->unk_0C && !fieldSystem->taskManager && !fieldSystem->unk_00->unk_00 && !fieldSystem->unk_00->unk_04) { - return 1; + // Does not match with return (expression) + if (fieldSystem->processManager->kill + && !fieldSystem->taskManager + && !fieldSystem->processManager->parent + && !fieldSystem->processManager->child) { + return TRUE; } - return 0; + return FALSE; } -void FieldSystem_Control(FieldSystem *fieldSystem) +static void HandleFieldInput(FieldSystem *fieldSystem) { - int loadType; - FieldInput v1; - BOOL v2 = 0; - - if (!fieldSystem->unk_00->unk_08 && fieldSystem->unk_68 && (sub_020509A4(fieldSystem) == 0)) { - v2 = 1; + BOOL processInput = FALSE; + if (!fieldSystem->processManager->pause && fieldSystem->runningFieldMap && sub_020509A4(fieldSystem) == FALSE) { + processInput = TRUE; } - if (v2) { + FieldInput fieldInput; + if (processInput) { sub_0205F490(fieldSystem->playerAvatar); - FieldInput_Update(&v1, fieldSystem, gCoreSys.pressedKeys, gCoreSys.heldKeys); + FieldInput_Update(&fieldInput, fieldSystem, gCoreSys.pressedKeys, gCoreSys.heldKeys); } - loadType = fieldSystem->mapLoadType; - - if (fieldSystem->location->mapId == 326) { + enum MapLoadType loadType = fieldSystem->mapLoadType; + if (fieldSystem->location->mapId == MAP_HEADER_BATTLE_TOWER) { loadType = MAP_LOAD_TYPE_OVERWORLD; } switch (loadType) { case MAP_LOAD_TYPE_UNDERGROUND: - if (v2) { - if (sub_02058C40()) { - if (FieldInput_Process_Underground(&v1, fieldSystem) == 1) { - } - } + if (processInput && sub_02058C40()) { + FieldInput_Process_Underground(&fieldInput, fieldSystem); } - sub_0205805C(fieldSystem, v2); + sub_0205805C(fieldSystem, processInput); break; + case MAP_LOAD_TYPE_COLOSSEUM: - if (v2) { + if (processInput) { if (sub_02058C40()) { - if (FieldInput_Process_Colosseum(&v1, fieldSystem) == 1) { - v2 = 0; + if (FieldInput_Process_Colosseum(&fieldInput, fieldSystem) == TRUE) { + processInput = FALSE; } } else { - v2 = 0; + processInput = FALSE; } } - sub_0205805C(fieldSystem, v2); + sub_0205805C(fieldSystem, processInput); break; - case MAP_LOAD_TYPE_UNION: - if (v2) { - if (FieldInput_Process_UnionRoom(&v1, fieldSystem) == 1) { - } else { - PlayerAvatar_MoveControl(fieldSystem->playerAvatar, fieldSystem->unk_28, -1, v1.pressedKeys, v1.heldKeys, 0); + case MAP_LOAD_TYPE_UNION: + if (processInput) { + if (FieldInput_Process_UnionRoom(&fieldInput, fieldSystem) != TRUE) { + PlayerAvatar_MoveControl(fieldSystem->playerAvatar, fieldSystem->unk_28, -1, fieldInput.pressedKeys, fieldInput.heldKeys, 0); } } break; + case MAP_LOAD_TYPE_BATTLE_TOWER: - if (v2) { - if (FieldInput_Process_BattleTower(&v1, fieldSystem) == 1) { + if (processInput) { + if (FieldInput_Process_BattleTower(&fieldInput, fieldSystem) == TRUE) { ov5_021DDA78(fieldSystem->unk_04->unk_08); ov5_021E1BCC(fieldSystem, 4); ov5_021E0EEC(fieldSystem->playerAvatar); @@ -313,22 +290,20 @@ void FieldSystem_Control(FieldSystem *fieldSystem) ov5_021DDA78(fieldSystem->unk_04->unk_08); } - { - BOOL v3 = 0; - PoketchSystem *poketchSys = FieldSystem_GetPoketchSystem(); - - if (poketchSys != NULL) { - v3 = PoketchSystem_IsTapped(poketchSys); - } - - PlayerAvatar_MoveControl(fieldSystem->playerAvatar, fieldSystem->unk_28, -1, v1.pressedKeys, v1.heldKeys, v3); + BOOL tappedPoketch = FALSE; + PoketchSystem *poketchSys = FieldSystem_GetPoketchSystem(); + if (poketchSys != NULL) { + tappedPoketch = PoketchSystem_IsTapped(poketchSys); } + + PlayerAvatar_MoveControl(fieldSystem->playerAvatar, fieldSystem->unk_28, -1, fieldInput.pressedKeys, fieldInput.heldKeys, tappedPoketch); } } break; + default: - if (v2) { - if (FieldInput_Process(&v1, fieldSystem) == 1) { + if (processInput) { + if (FieldInput_Process(&fieldInput, fieldSystem) == TRUE) { ov5_021DDA78(fieldSystem->unk_04->unk_08); ov5_021E1BCC(fieldSystem, 4); sub_0205F56C(fieldSystem->playerAvatar); @@ -339,31 +314,28 @@ void FieldSystem_Control(FieldSystem *fieldSystem) ov5_021DDA78(fieldSystem->unk_04->unk_08); } - { - BOOL v5 = 0; - PoketchSystem *poketchSys = FieldSystem_GetPoketchSystem(); - - if (poketchSys != NULL) { - v5 = PoketchSystem_IsTapped(poketchSys); - } - - PlayerAvatar_MoveControl(fieldSystem->playerAvatar, fieldSystem->unk_28, -1, v1.pressedKeys, v1.heldKeys, v5); + BOOL tappedPoketch = 0; + PoketchSystem *poketchSys = FieldSystem_GetPoketchSystem(); + if (poketchSys != NULL) { + tappedPoketch = PoketchSystem_IsTapped(poketchSys); } + + PlayerAvatar_MoveControl(fieldSystem->playerAvatar, fieldSystem->unk_28, -1, fieldInput.pressedKeys, fieldInput.heldKeys, tappedPoketch); } } break; } } -void sub_0203D128(void) +void FieldSystem_PauseProcessing(void) { - sFieldSystem->unk_00->unk_08 = 1; + sFieldSystem->processManager->pause = TRUE; CommSys_DisableSendMovementData(); } -void sub_0203D140(void) +void FieldSystem_ResumeProcessing(void) { - sFieldSystem->unk_00->unk_08 = 0; + sFieldSystem->processManager->pause = FALSE; CommSys_EnableSendMovementData(); } @@ -376,13 +348,12 @@ struct PoketchSystem *FieldSystem_GetPoketchSystem(void) return sFieldSystem->unk_04->poketchSys; } -BgConfig *sub_0203D170(void *param0) +BgConfig *FieldSystem_GetBgConfig(void *fieldSystem) { - FieldSystem *fieldSystem = (FieldSystem *)param0; - return fieldSystem->bgConfig; + return ((FieldSystem *)fieldSystem)->bgConfig; } -SaveData *FieldSystem_SaveData(void *param0) +SaveData *FieldSystem_GetSaveData(void *fieldSystem) { - return ((FieldSystem *)param0)->saveData; + return ((FieldSystem *)fieldSystem)->saveData; } diff --git a/src/game_overlay.c b/src/game_overlay.c index 11aa6620bb..5dc07207e2 100644 --- a/src/game_overlay.c +++ b/src/game_overlay.c @@ -28,9 +28,6 @@ static BOOL GetOverlayRamBounds(const FSOverlayID param0, u32 *param1, u32 *para static BOOL LoadOverlayNormal(MIProcessor param0, FSOverlayID param1); static BOOL LoadOverlayNoInit(MIProcessor param0, FSOverlayID param1); static BOOL LoadOverlayNoInitAsync(MIProcessor param0, FSOverlayID param1); -void Overlay_UnloadByID(const FSOverlayID param0); -int Overlay_GetLoadDestination(const FSOverlayID param0); -BOOL Overlay_LoadByID(const FSOverlayID param0, int param1); static UnkStruct_021BF370 Unk_021BF370; @@ -118,7 +115,7 @@ int Overlay_GetLoadDestination(const FSOverlayID overlayID) return OVERLAY_REGION_MAIN; } -BOOL Overlay_LoadByID(const FSOverlayID overlayID, int loadType) +BOOL Overlay_LoadByID(const FSOverlayID overlayID, enum OverlayLoadType loadType) { BOOL result; u32 dmaBak = FS_DMA_NOT_USE; @@ -143,11 +140,11 @@ BOOL Overlay_LoadByID(const FSOverlayID overlayID, int loadType) } if (i >= 8) { - GF_ASSERT(0); + GF_ASSERT(FALSE); return FALSE; } - if ((overlayRegion == 1) || (overlayRegion == 2)) { + if (overlayRegion == OVERLAY_REGION_ITCM || overlayRegion == OVERLAY_REGION_DTCM) { dmaBak = FS_SetDefaultDMA(FS_DMA_NOT_USE); } @@ -166,16 +163,16 @@ BOOL Overlay_LoadByID(const FSOverlayID overlayID, int loadType) return 0; } - if ((overlayRegion == 1) || (overlayRegion == 2)) { + if (overlayRegion == OVERLAY_REGION_ITCM || overlayRegion == OVERLAY_REGION_DTCM) { FS_SetDefaultDMA(dmaBak); } - if (result == 0) { - GF_ASSERT(0); - return 0; + if (result == FALSE) { + GF_ASSERT(FALSE); + return FALSE; } - return 1; + return TRUE; } static BOOL CanOverlayBeLoaded(const FSOverlayID param0) diff --git a/src/game_start.c b/src/game_start.c new file mode 100644 index 0000000000..5bbd92b9de --- /dev/null +++ b/src/game_start.c @@ -0,0 +1,186 @@ +#include "game_start.h" + +#include "constants/game_options.h" +#include "constants/heap.h" + +#include "berry_patches.h" +#include "game_options.h" +#include "heap.h" +#include "location.h" +#include "main.h" +#include "overlay_manager.h" +#include "party.h" +#include "pokemon.h" +#include "record_mixed_rng.h" +#include "save_player.h" +#include "savedata.h" +#include "savedata_misc.h" +#include "system_data.h" +#include "trainer_info.h" +#include "unk_02017428.h" +#include "unk_0201D15C.h" +#include "unk_0205C980.h" +#include "unk_0206A8DC.h" +#include "unk_0206B9D8.h" +#include "vars_flags.h" + +#include "constdata/const_020EA10C.h" +#include "constdata/const_020EA11C.h" +#include "constdata/const_020F6824.h" + +static int GameStartRowanIntro_Init(OverlayManager *ovyManager, int *state); +static int GameStartRowanIntro_Main(OverlayManager *ovyManager, int *state); +static int GameStartRowanIntro_Exit(OverlayManager *ovyManager, int *state); +static int GameStartNewSave_Init(OverlayManager *ovyManager, int *state); +static int GameStartNewSave_Main(OverlayManager *ovyManager, int *state); +static int GameStartNewSave_Exit(OverlayManager *ovyManager, int *state); +static int GameStartLoadSave_Init(OverlayManager *ovyManager, int *state); +static int GameStartLoadSave_Main(OverlayManager *ovyManager, int *state); +static int GameStartLoadSave_Exit(OverlayManager *ovyManager, int *state); + +static void InitializeNewSave(enum HeapId heapID, SaveData *saveData, BOOL setTrainerID); +static void TryLoadingSave(int unused, SaveData *saveData); +static void StartNewSave(int unused, SaveData *saveData); + +const OverlayManagerTemplate gGameStartRowanIntroOverlayTemplate = { + .init = GameStartRowanIntro_Init, + .main = GameStartRowanIntro_Main, + .exit = GameStartRowanIntro_Exit, + .overlayID = FS_OVERLAY_ID_NONE, +}; + +const OverlayManagerTemplate gGameStartNewSaveOverlayTemplate = { + .init = GameStartNewSave_Init, + .main = GameStartNewSave_Main, + .exit = GameStartNewSave_Exit, + .overlayID = FS_OVERLAY_ID_NONE, +}; + +const OverlayManagerTemplate gGameStartLoadSaveOverlayTemplate = { + .init = GameStartLoadSave_Init, + .main = GameStartLoadSave_Main, + .exit = GameStartLoadSave_Exit, + .overlayID = FS_OVERLAY_ID_NONE, +}; + +static BOOL GameStartRowanIntro_Init(OverlayManager *ovyManager, int *state) +{ + Heap_Create(HEAP_ID_APPLICATION, HEAP_ID_GAME_START, HEAP_SIZE_GAME_START); + InitRNG(); + return TRUE; +} + +static BOOL GameStartRowanIntro_Main(OverlayManager *ovyManager, int *state) +{ + SaveData *saveData = ((ApplicationArgs *)OverlayManager_Args(ovyManager))->saveData; + StartNewSave(HEAP_ID_GAME_START, saveData); + return TRUE; +} + +static int GameStartRowanIntro_Exit(OverlayManager *ovyManager, int *state) +{ + Heap_Destroy(HEAP_ID_GAME_START); + EnqueueApplication(FS_OVERLAY_ID_NONE, &Unk_020F6824); + return TRUE; +} + +static int GameStartNewSave_Init(OverlayManager *ovyManager, int *state) +{ + Heap_Create(HEAP_ID_APPLICATION, HEAP_ID_GAME_START, HEAP_SIZE_GAME_START); + InitRNG(); + return TRUE; +} + +static int GameStartNewSave_Main(OverlayManager *ovyManager, int *state) +{ + SaveData *saveData = ((ApplicationArgs *)OverlayManager_Args(ovyManager))->saveData; + InitializeNewSave(HEAP_ID_GAME_START, saveData, 1); + PlayTime_Start(SaveData_GetPlayTime(saveData)); + return TRUE; +} + +static int GameStartNewSave_Exit(OverlayManager *ovyManager, int *state) +{ + Heap_Destroy(HEAP_ID_GAME_START); + EnqueueApplication(FS_OVERLAY_ID_NONE, &gFieldSystemNewGameTemplate); + return TRUE; +} + +static int GameStartLoadSave_Init(OverlayManager *ovyManager, int *state) +{ + Heap_Create(HEAP_ID_APPLICATION, HEAP_ID_GAME_START, HEAP_SIZE_GAME_START); + InitRNG(); + return TRUE; +} + +static int GameStartLoadSave_Main(OverlayManager *ovyManager, int *state) +{ + SaveData *saveData = ((ApplicationArgs *)OverlayManager_Args(ovyManager))->saveData; + SystemData *systemData = SaveData_GetSystemData(saveData); + + TryLoadingSave(HEAP_ID_GAME_START, saveData); + Options_SetSystemButtonMode(saveData, OPTIONS_BUTTON_MODE_NORMAL); + + if (!SystemData_MatchesCurrentSystem(systemData) || !SystemData_MatchesCurrentRTCOffset(systemData)) { + GameTime_StartPenalty(SaveData_GetGameTime(saveData)); + SystemData_Init(systemData); + Party_SetShayminLandForm(Party_GetFromSavedata(saveData)); + } + + PlayTime_Start(SaveData_GetPlayTime(saveData)); + return TRUE; +} + +static int GameStartLoadSave_Exit(OverlayManager *ovyManager, int *state) +{ + Heap_Destroy(HEAP_ID_GAME_START); + EnqueueApplication(FS_OVERLAY_ID_NONE, &gFieldSystemContinueTemplate); + return TRUE; +} + +#include "data/berry_init.h" + +static void InitializeNewSave(enum HeapId heapID, SaveData *saveData, BOOL setTrainerID) +{ + u32 rnd; + BerryPatch *berryPatches; + TrainerInfo *trainerInfo; + GameTime *gameTime; + RecordMixedRNG *rngCollection; + + SystemData_Init(SaveData_GetSystemData(saveData)); + + gameTime = SaveData_GetGameTime(saveData); + GameTime_Clear(gameTime); + + rngCollection = SaveData_GetRecordMixedRNG(saveData); + RecordMixedRNG_SetEntrySeed(rngCollection, RECORD_MIXED_RNG_PLAYER_OVERRIDE, MTRNG_Next()); + sub_0206C008(saveData); + + trainerInfo = SaveData_GetTrainerInfo(saveData); + rnd = MTRNG_Next(); + + if (setTrainerID) { + TrainerInfo_SetID(trainerInfo, rnd); + } + + TrainerInfo_SetAppearance(trainerInfo, sub_0205C9BC(rnd, TrainerInfo_Gender(trainerInfo), 0)); + + berryPatches = MiscSaveBlock_GetBerryPatches(saveData); + BerryPatches_Init(berryPatches, heapID, (const u16 *)sBerryInitTable, NELEMS(sBerryInitTable)); +} + +static void TryLoadingSave(int unused, SaveData *saveData) +{ + if (!SaveData_Load(saveData)) { + OS_ResetSystem(RESET_CLEAN); + } +} + +static void StartNewSave(int unused, SaveData *saveData) +{ + SaveData_Clear(saveData); + InitPlayerStartLocation(saveData); + TrainerInfo_SetMoney(SaveData_GetTrainerInfo(saveData), 3000); + VarsFlags_SetBagAvailable(SaveData_GetVarsFlags(saveData)); +} diff --git a/src/library_tv/library_tv.c b/src/library_tv/library_tv.c index f1bd62e682..0a9c2740c7 100644 --- a/src/library_tv/library_tv.c +++ b/src/library_tv/library_tv.c @@ -30,7 +30,7 @@ typedef struct LibraryTV { int waitTiming; } LibraryTV; -extern void sub_02000EC4(FSOverlayID param0, const OverlayManagerTemplate *param1); +extern void EnqueueApplication(FSOverlayID param0, const OverlayManagerTemplate *param1); static void LibraryTV_VBlank(void *data); static void LibraryTV_SetVramBank(LibraryTV *ltv); static void LibraryTV_ReleaseVramBank(LibraryTV *ltv); diff --git a/src/location.c b/src/location.c new file mode 100644 index 0000000000..bccbbc9c51 --- /dev/null +++ b/src/location.c @@ -0,0 +1,37 @@ +#include "location.h" + +#include "consts/map.h" + +#include "field_overworld_state.h" +#include "savedata.h" + +static const Location sPlayerStartLocation = { + .mapId = MAP_HEADER_TWINLEAF_TOWN_PLAYER_HOUSE_2F, + .warpId = WARP_ID_NONE, + .x = 4, + .z = 6, + .faceDirection = FACE_UP, +}; + +static const Location sPlayerFirstRespawnLocation = { + .mapId = MAP_HEADER_TWINLEAF_TOWN, + .warpId = WARP_ID_NONE, + .x = 116, + .z = 886, + .faceDirection = FACE_DOWN, +}; + +void SetPlayerStartLocation(Location *outLocation) +{ + *outLocation = sPlayerStartLocation; +} + +void SetPlayerFirstRespawnLocation(Location *outLocation) +{ + *outLocation = sPlayerFirstRespawnLocation; +} + +void InitPlayerStartLocation(SaveData *saveData) +{ + SetPlayerStartLocation(FieldOverworldState_GetPlayerLocation(SaveData_GetFieldOverworldState(saveData))); +} diff --git a/src/main.c b/src/main.c index 741186614b..0bc473a821 100644 --- a/src/main.c +++ b/src/main.c @@ -1,25 +1,26 @@ +#include "main.h" + #include #include #include #include "constants/heap.h" -#include "struct_defs/struct_0203CC84.h" - -#include "overlay057/const_ov57_021D0F70.h" #include "overlay077/const_ov77_021D742C.h" #include "assert.h" +#include "bg_window.h" #include "communication_system.h" #include "core_sys.h" #include "font.h" #include "game_overlay.h" +#include "game_start.h" +#include "main.h" #include "overlay_manager.h" #include "rtc.h" #include "save_player.h" #include "savedata.h" #include "sys_task_manager.h" -#include "unk_02000C88.h" #include "unk_02003B60.h" #include "unk_0200A9DC.h" #include "unk_0200F174.h" @@ -38,31 +39,31 @@ #define RESET_COMBO (PAD_BUTTON_START | PAD_BUTTON_SELECT | PAD_BUTTON_L | PAD_BUTTON_R) -FS_EXTERN_OVERLAY(overlay57); +FS_EXTERN_OVERLAY(game_start); FS_EXTERN_OVERLAY(overlay77); -typedef struct { - FSOverlayID unk_00; - OverlayManager *unk_04; - FSOverlayID unk_08; - const OverlayManagerTemplate *unk_0C; - UnkStruct_0203CC84 unk_10; -} UnkStruct_02101D28; +typedef struct Application { + FSOverlayID currOverlayID; + OverlayManager *currOverlay; + FSOverlayID nextOverlayID; + const OverlayManagerTemplate *nextOverlay; + ApplicationArgs args; +} Application; -static void sub_02000E3C(void); -static void sub_02000E54(void); +static void InitApplication(void); +static void RunApplication(void); static void WaitFrame(void); -static void sub_02000F10(int param0); -static void SoftReset(int param0); +static void TrySystemReset(enum OSResetParameter resetParam); +static void SoftReset(enum OSResetParameter resetParam); static void HeapCanaryFailed(int param0, int param1); static void CheckHeapCanary(void); -static UnkStruct_02101D28 Unk_02101D28; +static Application sApplication; // This variable doesn't really makes sense. If it's set to off, the game will // repeatedly try to restore the backlight to its saved state. static PMBackLightSwitch sSavedBacklightState; BOOL gIgnoreCartridgeForWake; -extern const OverlayManagerTemplate Unk_ov77_021D788C; +extern const OverlayManagerTemplate gOpeningCutsceneOverlayTemplate; void NitroMain(void) { @@ -74,48 +75,50 @@ void NitroMain(void) PM_GetBackLight(&sSavedBacklightState, NULL); sub_0202419C(); InitRTC(); - sub_02000E3C(); + InitApplication(); Fonts_Init(); Font_InitManager(FONT_SYSTEM, HEAP_ID_APPLICATION); Font_InitManager(FONT_MESSAGE, HEAP_ID_APPLICATION); Font_InitManager(FONT_UNOWN, HEAP_ID_APPLICATION); - Unk_02101D28.unk_10.unk_00 = -1; - Unk_02101D28.unk_10.unk_08 = SaveData_Init(); + sApplication.args.unk_00 = -1; + sApplication.args.saveData = SaveData_Init(); - sub_02003B60(GetChatotCryDataFromSave(Unk_02101D28.unk_10.unk_08), SaveData_Options(Unk_02101D28.unk_10.unk_08)); + sub_02003B60(GetChatotCryDataFromSave(sApplication.args.saveData), SaveData_Options(sApplication.args.saveData)); sub_02022844(); if (sub_02038FFC(3) == DWC_INIT_RESULT_DESTROY_OTHER_SETTING) { sub_02039A64(3, 0); } - if (SaveData_BackupExists(Unk_02101D28.unk_10.unk_08) == 0) { + if (SaveData_BackupExists(sApplication.args.saveData) == 0) { sub_0209A74C(0); } else { switch (OS_GetResetParameter()) { - case 0: - Unk_02101D28.unk_10.unk_04 = 0; - sub_02000EC4(FS_OVERLAY_ID(overlay77), &Unk_ov77_021D788C); + case RESET_CLEAN: + sApplication.args.error = FALSE; + EnqueueApplication(FS_OVERLAY_ID(overlay77), &gOpeningCutsceneOverlayTemplate); break; - case 1: + + case RESET_ERROR: sub_0200F344(0, 0x0); sub_0200F344(1, 0x0); - Unk_02101D28.unk_10.unk_04 = 1; - sub_02000EC4(FS_OVERLAY_ID(overlay57), &Unk_ov57_021D0F70); + sApplication.args.error = TRUE; + EnqueueApplication(FS_OVERLAY_ID(game_start), &gGameStartLoadSaveOverlayTemplate); break; + default: - GF_ASSERT(0); + GF_ASSERT(FALSE); } } gCoreSys.unk_6C = 1; - gCoreSys.unk_30 = 0; + gCoreSys.frameCounter = 0; InitRNG(); sub_0200AB84(); - sub_02017428(); + PlayTime_FlagNotStarted(); gIgnoreCartridgeForWake = FALSE; @@ -124,33 +127,31 @@ void NitroMain(void) HandleConsoleFold(); ReadKeypadAndTouchpad(); - if ((gCoreSys.heldKeysRaw & RESET_COMBO) == RESET_COMBO) { - if (gCoreSys.inhibitReset == 0) { - SoftReset(0); - } + if ((gCoreSys.heldKeysRaw & RESET_COMBO) == RESET_COMBO && !gCoreSys.inhibitReset) { + SoftReset(RESET_CLEAN); } if (CommSys_Update()) { CheckHeapCanary(); - sub_02000E54(); + RunApplication(); SysTaskManager_ExecuteTasks(gCoreSys.mainTaskMgr); - SysTaskManager_ExecuteTasks(gCoreSys.unk_24); + SysTaskManager_ExecuteTasks(gCoreSys.printTaskMgr); - if (!gCoreSys.unk_30) { - OS_WaitIrq(1, OS_IE_V_BLANK); - gCoreSys.frameCounter++; + if (!gCoreSys.frameCounter) { + OS_WaitIrq(TRUE, OS_IE_V_BLANK); + gCoreSys.vblankCounter++; } } UpdateRTC(); sub_02017458(); sub_020241CC(); - SysTaskManager_ExecuteTasks(gCoreSys.unk_24); + SysTaskManager_ExecuteTasks(gCoreSys.printTaskMgr); - OS_WaitIrq(1, OS_IE_V_BLANK); + OS_WaitIrq(TRUE, OS_IE_V_BLANK); - gCoreSys.frameCounter++; - gCoreSys.unk_30 = 0; + gCoreSys.vblankCounter++; + gCoreSys.frameCounter = 0; sub_0200ABF0(); sub_0200F27C(); @@ -164,72 +165,68 @@ void NitroMain(void) } } -static void sub_02000E3C(void) +static void InitApplication() { - Unk_02101D28.unk_00 = 0xffffffff; - Unk_02101D28.unk_04 = NULL; - Unk_02101D28.unk_08 = 0xffffffff; - Unk_02101D28.unk_0C = NULL; + sApplication.currOverlayID = FS_OVERLAY_ID_NONE; + sApplication.currOverlay = NULL; + sApplication.nextOverlayID = FS_OVERLAY_ID_NONE; + sApplication.nextOverlay = NULL; } -static void sub_02000E54(void) +static void RunApplication(void) { - BOOL v0; - - if (Unk_02101D28.unk_04 == NULL) { - if (Unk_02101D28.unk_0C == NULL) { + if (sApplication.currOverlay == NULL) { + if (sApplication.nextOverlay == NULL) { return; } - if (Unk_02101D28.unk_08 != 0xffffffff) { - Overlay_LoadByID(Unk_02101D28.unk_08, 0); + if (sApplication.nextOverlayID != FS_OVERLAY_ID_NONE) { + Overlay_LoadByID(sApplication.nextOverlayID, OVERLAY_LOAD_NORMAL); } - Unk_02101D28.unk_00 = Unk_02101D28.unk_08; - Unk_02101D28.unk_04 = OverlayManager_New(Unk_02101D28.unk_0C, &Unk_02101D28.unk_10, 0); - Unk_02101D28.unk_08 = 0xffffffff; - Unk_02101D28.unk_0C = NULL; + sApplication.currOverlayID = sApplication.nextOverlayID; + sApplication.currOverlay = OverlayManager_New(sApplication.nextOverlay, &sApplication.args, HEAP_ID_SYSTEM); + sApplication.nextOverlayID = FS_OVERLAY_ID_NONE; + sApplication.nextOverlay = NULL; } - v0 = OverlayManager_Exec(Unk_02101D28.unk_04); + if (OverlayManager_Exec(sApplication.currOverlay)) { + OverlayManager_Free(sApplication.currOverlay); + sApplication.currOverlay = NULL; - if (v0) { - OverlayManager_Free(Unk_02101D28.unk_04); - Unk_02101D28.unk_04 = NULL; - - if (Unk_02101D28.unk_00 != 0xffffffff) { - Overlay_UnloadByID(Unk_02101D28.unk_00); + if (sApplication.currOverlayID != FS_OVERLAY_ID_NONE) { + Overlay_UnloadByID(sApplication.currOverlayID); } } } -void sub_02000EC4(FSOverlayID param0, const OverlayManagerTemplate *param1) +void EnqueueApplication(FSOverlayID overlayID, const OverlayManagerTemplate *template) { - GF_ASSERT(Unk_02101D28.unk_0C == NULL); + GF_ASSERT(sApplication.nextOverlay == NULL); - Unk_02101D28.unk_08 = param0; - Unk_02101D28.unk_0C = param1; + sApplication.nextOverlayID = overlayID; + sApplication.nextOverlay = template; } static void WaitFrame(void) { CommSys_Update(); - OS_WaitIrq(1, OS_IE_V_BLANK); + OS_WaitIrq(TRUE, OS_IE_V_BLANK); - gCoreSys.frameCounter++; - gCoreSys.unk_30 = 0; + gCoreSys.vblankCounter++; + gCoreSys.frameCounter = 0; if (gCoreSys.mainCallback != NULL) { gCoreSys.mainCallback(gCoreSys.mainCallbackData); } } -static void sub_02000F10(int param0) +static void TrySystemReset(enum OSResetParameter resetParam) { if (sub_02038AB8()) { if (CARD_TryWaitBackupAsync() == TRUE) { - OS_ResetSystem(param0); + OS_ResetSystem(resetParam); } } @@ -253,10 +250,10 @@ static void CheckHeapCanary(void) } } -static void SoftReset(int param0) +static void SoftReset(enum OSResetParameter resetParam) { - sub_0200F344(0, 0x7fff); - sub_0200F344(1, 0x7fff); + sub_0200F344(DS_SCREEN_MAIN, 0x7fff); + sub_0200F344(DS_SCREEN_SUB, 0x7fff); if (sub_02037DB0()) { SaveData_SaveStateCancel(SaveData_Ptr()); @@ -264,18 +261,17 @@ static void SoftReset(int param0) while (TRUE) { HandleConsoleFold(); - sub_02000F10(param0); + TrySystemReset(resetParam); } } -static void HeapCanaryFailed(int param0, int param1) +static void HeapCanaryFailed(int resetParam, int param1) { int elapsed; - BOOL v1; if (param1 == 3) { sub_02039834(0, 3, 0); - } else if (0 == param0) { + } else if (0 == resetParam) { if (sub_020389B8() == TRUE) { sub_02039834(0, 6, 0); } else { @@ -312,21 +308,19 @@ static void HeapCanaryFailed(int param0, int param1) } } - SoftReset(param0); + SoftReset(resetParam); } void InitRNG(void) { - RTCDate v0; - RTCTime v1; - u32 v2; - - GetCurrentDateTime(&v0, &v1); + RTCDate date; + RTCTime time; + GetCurrentDateTime(&date, &time); - v2 = v0.year + v0.month * 0x100 * v0.day * 0x10000 + v1.hour * 0x10000 + (v1.minute + v1.second) * 0x1000000 + gCoreSys.frameCounter; + u32 seed = date.year + date.month * 0x100 * date.day * 0x10000 + time.hour * 0x10000 + (time.minute + time.second) * 0x1000000 + gCoreSys.vblankCounter; - MTRNG_SetSeed(v2); - LCRNG_SetSeed(v2); + MTRNG_SetSeed(seed); + LCRNG_SetSeed(seed); } void HandleConsoleFold(void) diff --git a/src/meson.build b/src/meson.build index 9deee9db38..df40c166d0 100644 --- a/src/meson.build +++ b/src/meson.build @@ -95,7 +95,7 @@ pokeplatinum_c = files( 'unk_02024358.c', 'savedata/save_table.c', 'savedata.c', - 'unk_02025CB0.c', + 'system_data.c', 'save_player.c', 'trainer_info.c', 'unk_0202602C.c', @@ -104,14 +104,14 @@ pokeplatinum_c = files( 'unk_0202631C.c', 'savedata_misc.c', 'game_options.c', - 'unk_02027B70.c', + 'berry_patches.c', 'unk_02027F50.c', 'unk_02027F84.c', 'unk_02028124.c', 'unk_0202854C.c', 'unk_020298BC.c', 'unk_0202ACE0.c', - 'unk_0202B37C.c', + 'record_mixed_rng.c', 'journal.c', 'unk_0202C7FC.c', 'unk_0202C858.c', @@ -166,7 +166,7 @@ pokeplatinum_c = files( 'field_menu.c', 'unk_0203C954.c', 'field_system.c', - 'unk_0203D178.c', + 'location.c', 'unk_0203D1B8.c', 'field_script_context.c', 'script_manager.c', @@ -730,8 +730,7 @@ pokeplatinum_c = files( 'overlay055/ov55_022561C0.c', 'overlay055/ov55_0225632C.c', 'overlay056/ov56_022561C0.c', - 'overlay057/ov57_021D0D80.c', - 'overlay057/ov57_021D0F30.c', + 'game_start.c', 'overlay058/ov58_021D0D80.c', 'overlay059/ov59_021D0D80.c', 'overlay059/ov59_021D2A2C.c', diff --git a/src/overlay005/encounter_effect.c b/src/overlay005/encounter_effect.c index 606c59128d..d4073e8d94 100644 --- a/src/overlay005/encounter_effect.c +++ b/src/overlay005/encounter_effect.c @@ -14,10 +14,10 @@ #include "field/field_system_sub2_t.h" #include "overlay005/encounter_effect.h" #include "overlay005/encounter_effect_core.h" +#include "overlay005/fieldmap.h" #include "overlay005/hblank_system.h" #include "overlay005/linear_interpolation_task_fx32.h" #include "overlay005/linear_interpolation_task_s32.h" -#include "overlay005/ov5_021D0D80.h" #include "overlay005/quadratic_interpolation_task_fx32.h" #include "overlay005/struct_ov5_021DDF24.h" #include "overlay005/struct_ov5_021DE47C.h" diff --git a/src/overlay005/field_control.c b/src/overlay005/field_control.c index f1159c6418..81dbf0a55f 100644 --- a/src/overlay005/field_control.c +++ b/src/overlay005/field_control.c @@ -11,7 +11,6 @@ #include "struct_decls/struct_0203A790_decl.h" #include "struct_decls/struct_02061AB4_decl.h" #include "struct_decls/struct_party_decl.h" -#include "struct_defs/struct_02049FA8.h" #include "field/field_system.h" #include "field/field_system_sub2_t.h" @@ -40,6 +39,7 @@ #include "field_overworld_state.h" #include "game_records.h" #include "inlines.h" +#include "location.h" #include "map_header.h" #include "map_header_data.h" #include "map_object.h" @@ -589,7 +589,7 @@ static BOOL Field_CheckMapTransition(FieldSystem *fieldSystem, const FieldInput ov8_0224C62C(fieldSystem, playerX, playerZ, &v6); } - sub_02056BDC(fieldSystem, nextMap.mapId, nextMap.unk_04, 0, 0, v6, 1); + sub_02056BDC(fieldSystem, nextMap.mapId, nextMap.warpId, 0, 0, v6, 1); return TRUE; } @@ -636,14 +636,14 @@ static BOOL Field_CheckMapTransition(FieldSystem *fieldSystem, const FieldInput } else if (sub_0205DAF8(tileBehavior) || sub_0205DB28(tileBehavior) || sub_0205DB04(tileBehavior) || sub_0205DB34(tileBehavior) || sub_0205DB1C(tileBehavior) || sub_0205DB4C(tileBehavior)) { - sub_02056C18(fieldSystem, nextMap.mapId, nextMap.unk_04, 0, 0, input->transitionDir); + sub_02056C18(fieldSystem, nextMap.mapId, nextMap.warpId, 0, 0, input->transitionDir); return TRUE; } else { return FALSE; } // these statements are unreachable, but required for matching - sub_02056BDC(fieldSystem, nextMap.mapId, nextMap.unk_04, 0, 0, input->transitionDir, transitionType); + sub_02056BDC(fieldSystem, nextMap.mapId, nextMap.warpId, 0, 0, input->transitionDir, transitionType); return TRUE; } @@ -797,7 +797,7 @@ static BOOL Field_CheckTransition(FieldSystem *fieldSystem, const int playerX, c return FALSE; } - sub_02056BDC(fieldSystem, nextMap.mapId, nextMap.unk_04, 0, 0, playerDir, 2); + sub_02056BDC(fieldSystem, nextMap.mapId, nextMap.warpId, 0, 0, playerDir, 2); return TRUE; } else if (TileBehavior_IsEscalator(curTileBehavior) == TRUE) { int playerDir = PlayerAvatar_GetDir(fieldSystem->playerAvatar); @@ -807,17 +807,17 @@ static BOOL Field_CheckTransition(FieldSystem *fieldSystem, const int playerX, c return FALSE; } - sub_02056BDC(fieldSystem, nextMap.mapId, nextMap.unk_04, 0, 0, playerDir, 2); + sub_02056BDC(fieldSystem, nextMap.mapId, nextMap.warpId, 0, 0, playerDir, 2); return TRUE; } if (sub_0205DB10(curTileBehavior) || sub_0205DB40(curTileBehavior)) { - sub_02056C18(fieldSystem, nextMap.mapId, nextMap.unk_04, 0, 0, 0); + sub_02056C18(fieldSystem, nextMap.mapId, nextMap.warpId, 0, 0, 0); return TRUE; } if (TileBehavior_IsWarp(curTileBehavior)) { - FieldSystem_StartMapChangeWarpTask(fieldSystem, nextMap.mapId, nextMap.unk_04); + FieldSystem_StartMapChangeWarpTask(fieldSystem, nextMap.mapId, nextMap.warpId); return TRUE; } @@ -1029,7 +1029,7 @@ static void Field_SetMapConnection(FieldSystem *fieldSystem, const int playerX, Location *nextMap = sub_0203A72C(v0); (*nextMap) = *(fieldSystem->location); - nextMap->unk_10 = playerDir; + nextMap->faceDirection = playerDir; nextMap->x = playerX; nextMap->z = playerZ; @@ -1038,7 +1038,7 @@ static void Field_SetMapConnection(FieldSystem *fieldSystem, const int playerX, } nextMap->mapId = fieldSystem->location->mapId; - nextMap->unk_04 = -1; + nextMap->warpId = WARP_ID_NONE; } static void Field_TrySetMapConnection(FieldSystem *fieldSystem) diff --git a/src/overlay005/fieldmap.c b/src/overlay005/fieldmap.c index fe68e63205..5c0f7ab5d8 100644 --- a/src/overlay005/fieldmap.c +++ b/src/overlay005/fieldmap.c @@ -1,3 +1,5 @@ +#include "overlay005/fieldmap.h" + #include #include @@ -12,12 +14,10 @@ #include "field/field_system.h" #include "field/field_system_sub2_decl.h" #include "field/field_system_sub2_t.h" -#include "overlay005/const_ov5_021F89B0.h" #include "overlay005/const_ov5_021FF6B8.h" #include "overlay005/const_ov5_021FF744.h" #include "overlay005/const_ov5_021FF7D0.h" #include "overlay005/hblank_system.h" -#include "overlay005/ov5_021D0D80.h" #include "overlay005/ov5_021D1A94.h" #include "overlay005/ov5_021D37AC.h" #include "overlay005/ov5_021D521C.h" @@ -117,7 +117,7 @@ static BOOL FieldMap_Exit(OverlayManager *overlayMan, int *param1); static BOOL FieldMap_ChangeZone(FieldSystem *fieldSystem); static void ov5_021D134C(FieldSystem *fieldSystem, u8 param1); static BOOL ov5_021D119C(FieldSystem *fieldSystem); -static void ov5_021D0D80(void *param0); +static void fieldmap(void *param0); static void ov5_021D13B4(FieldSystem *fieldSystem); static int ov5_021D1178(FieldSystem *fieldSystem); static BOOL FieldMap_InDistortionWorld(FieldSystem *fieldSystem); @@ -126,7 +126,7 @@ static const int *ov5_021D1A68(const UnkStruct_ov5_021D1A68 *param0); static const int ov5_021D1A6C(const UnkStruct_ov5_021D1A68 *param0); static void ov5_021D1A70(UnkStruct_ov5_021D1A68 *param0); -static inline void inline_ov5_021D0D80(FieldSystem *fieldSystem) +static inline void inline_fieldmap(FieldSystem *fieldSystem) { UnkStruct_ov5_021ED0A4 *v0 = sub_0206285C(fieldSystem->mapObjMan); UnkStruct_02020C44 *v1 = ov5_021EDC8C(v0); @@ -134,7 +134,7 @@ static inline void inline_ov5_021D0D80(FieldSystem *fieldSystem) sub_02020D68(v1); } -static void ov5_021D0D80(void *param0) +static void fieldmap(void *param0) { FieldSystem *fieldSystem = param0; @@ -142,7 +142,7 @@ static void ov5_021D0D80(void *param0) sub_0201DCAC(); sub_0200A858(); - inline_ov5_021D0D80(fieldSystem); + inline_fieldmap(fieldSystem); } static BOOL FieldMap_Init(OverlayManager *overlayMan, int *param1) @@ -231,7 +231,7 @@ static BOOL FieldMap_Init(OverlayManager *overlayMan, int *param1) break; case 3: if (ov5_021D5BF4(fieldSystem)) { - fieldSystem->unk_68 = 1; + fieldSystem->runningFieldMap = TRUE; ret = TRUE; } break; @@ -255,7 +255,7 @@ static BOOL FieldMap_Main(OverlayManager *overlayMan, int *param1) ov5_021D134C(fieldSystem, fieldSystem->unk_C0); - if (fieldSystem->unk_68) { + if (fieldSystem->runningFieldMap) { return FALSE; } else { return TRUE; @@ -274,7 +274,7 @@ static BOOL FieldMap_Exit(OverlayManager *overlayMan, int *param1) fieldSystem->location->x = Player_GetXPos(fieldSystem->playerAvatar); fieldSystem->location->z = Player_GetZPos(fieldSystem->playerAvatar); - fieldSystem->location->unk_10 = PlayerAvatar_GetDir(fieldSystem->playerAvatar); + fieldSystem->location->faceDirection = PlayerAvatar_GetDir(fieldSystem->playerAvatar); ov5_021EF300(fieldSystem->unk_A0); @@ -367,7 +367,7 @@ const OverlayManagerTemplate gFieldMapTemplate = { static int ov5_021D1178(FieldSystem *fieldSystem) { - UnkStruct_02027860 *v0 = sub_02027860(FieldSystem_SaveData(fieldSystem)); + UnkStruct_02027860 *v0 = sub_02027860(FieldSystem_GetSaveData(fieldSystem)); int v1 = sub_02027F80(v0); if (v1 == 0) { @@ -887,7 +887,7 @@ static void ov5_021D1878(FieldSystem *fieldSystem) FieldEffect_InitRenderObject(fieldSystem->unk_40); { - UnkStruct_02027860 *v3 = sub_02027860(FieldSystem_SaveData(fieldSystem)); + UnkStruct_02027860 *v3 = sub_02027860(FieldSystem_GetSaveData(fieldSystem)); int v4 = sub_02027F80(v3); PlayerAvatar_InitDraw(fieldSystem->playerAvatar, v4); @@ -929,7 +929,7 @@ static void ov5_021D1968(FieldSystem *fieldSystem) ov5_021D5CE4(fieldSystem->unk_04->unk_10, ov5_021EFA8C(fieldSystem->unk_30)); sub_02068344(fieldSystem); ov5_021EE7C0(fieldSystem); - SetMainCallback(ov5_021D0D80, fieldSystem); + SetMainCallback(fieldmap, fieldSystem); } static UnkStruct_ov5_021D1A68 *ov5_021D1A14(int fieldSystem, int param1) @@ -975,7 +975,7 @@ static void ov5_021D1A70(UnkStruct_ov5_021D1A68 *param0) static BOOL FieldMap_InDistortionWorld(FieldSystem *fieldSystem) { - UnkStruct_02027860 *v0 = sub_02027860(FieldSystem_SaveData(fieldSystem)); + UnkStruct_02027860 *v0 = sub_02027860(FieldSystem_GetSaveData(fieldSystem)); int v1 = sub_02027F80(v0); if (v1 == 9) { diff --git a/src/overlay005/ov5_021D1A94.c b/src/overlay005/ov5_021D1A94.c index f85b0e324c..c842570526 100644 --- a/src/overlay005/ov5_021D1A94.c +++ b/src/overlay005/ov5_021D1A94.c @@ -74,7 +74,7 @@ static void ov5_021D1B24(SysTask *param0, void *param1) { UnkStruct_ov5_021D1BEC *v0 = param1; - if (sub_0203CD5C(v0->unk_00->fieldSystem)) { + if (FieldSystem_IsRunningFieldMap(v0->unk_00->fieldSystem)) { if (v0->unk_0C->unk_10) { v0->unk_0C->unk_10(v0, v0->unk_00->fieldSystem, v0->unk_10); } @@ -85,7 +85,7 @@ static void ov5_021D1B48(SysTask *param0, void *param1) { UnkStruct_ov5_021D1BEC *v0 = param1; - if (sub_0203CD5C(v0->unk_00->fieldSystem)) { + if (FieldSystem_IsRunningFieldMap(v0->unk_00->fieldSystem)) { if (v0->unk_0C->unk_14) { v0->unk_0C->unk_14(v0, v0->unk_00->fieldSystem, v0->unk_10); } diff --git a/src/overlay005/ov5_021D431C.c b/src/overlay005/ov5_021D431C.c index f8f5eb3afe..b733ea5673 100644 --- a/src/overlay005/ov5_021D431C.c +++ b/src/overlay005/ov5_021D431C.c @@ -8,7 +8,7 @@ #include "struct_defs/struct_02055130.h" #include "field/field_system.h" -#include "overlay005/ov5_021D0D80.h" +#include "overlay005/fieldmap.h" #include "overlay005/ov5_021D37AC.h" #include "overlay005/ov5_021E15F4.h" #include "overlay005/ov5_021EF75C.h" diff --git a/src/overlay005/ov5_021EA874.c b/src/overlay005/ov5_021EA874.c index 46dbcd4fb5..37796a5465 100644 --- a/src/overlay005/ov5_021EA874.c +++ b/src/overlay005/ov5_021EA874.c @@ -420,7 +420,7 @@ static BOOL ov5_021EADB4(TaskManager *param0) case 12: ov5_021EAF1C(v0); Heap_FreeToHeap(v0); - sub_0203D140(); + FieldSystem_ResumeProcessing(); return 1; } diff --git a/src/overlay005/ov5_021F8370.c b/src/overlay005/ov5_021F8370.c index 1be5e5e2b8..6e97349a8b 100644 --- a/src/overlay005/ov5_021F8370.c +++ b/src/overlay005/ov5_021F8370.c @@ -67,7 +67,7 @@ void ov5_021F8370(FieldSystem *fieldSystem) UnkStruct_02071C34 *v2; UnkStruct_ov5_021F8480 *v3; - v1 = sub_02027860(FieldSystem_SaveData(fieldSystem)); + v1 = sub_02027860(FieldSystem_GetSaveData(fieldSystem)); v2 = sub_02027F6C(v1, 10); v3 = Heap_AllocFromHeap(4, sizeof(UnkStruct_ov5_021F8480)); @@ -116,7 +116,7 @@ BOOL ov5_021F83D4(FieldSystem *fieldSystem, const int param1, const int param2, BOOL ov5_021F8410(FieldSystem *fieldSystem, const int param1, const int param2, const int param3) { - UnkStruct_02027860 *v0 = sub_02027860(FieldSystem_SaveData(fieldSystem)); + UnkStruct_02027860 *v0 = sub_02027860(FieldSystem_GetSaveData(fieldSystem)); if (sub_02027F80(v0) == 10) { int v1; diff --git a/src/overlay005/save_info_window.c b/src/overlay005/save_info_window.c index 48cb357d11..5fe0abdb22 100644 --- a/src/overlay005/save_info_window.c +++ b/src/overlay005/save_info_window.c @@ -8,7 +8,6 @@ #include "consts/map.h" #include "struct_decls/pokedexdata_decl.h" -#include "struct_defs/struct_02049FA8.h" #include "overlay005/ov5_021EA714.h" #include "overlay005/save_info_window.h" @@ -18,6 +17,7 @@ #include "bg_window.h" #include "field_overworld_state.h" #include "font.h" +#include "location.h" #include "map_header.h" #include "message_util.h" #include "player_avatar.h" @@ -50,7 +50,7 @@ static const int sSaveInfoValues[] = { static void SaveInfo_SetValues(SaveInfo *saveInfo, const FieldSystem *fieldSystem) { SaveData *saveData = fieldSystem->saveData; - Location *curLocation = sub_0203A720(SaveData_GetFieldOverworldState(saveData)); + Location *curLocation = FieldOverworldState_GetPlayerLocation(SaveData_GetFieldOverworldState(saveData)); PokedexData *pokedex = SaveData_Pokedex(saveData); saveInfo->mapLabelTextID = MapHeader_GetMapLabelTextID(curLocation->mapId); @@ -201,8 +201,8 @@ static void FieldSystem_SaveObjectsAndLocation(FieldSystem *fieldSystem) fieldSystem->location->x = Player_GetXPos(fieldSystem->playerAvatar); fieldSystem->location->z = Player_GetZPos(fieldSystem->playerAvatar); - fieldSystem->location->unk_04 = -1; - fieldSystem->location->unk_10 = PlayerAvatar_GetDir(fieldSystem->playerAvatar); + fieldSystem->location->warpId = WARP_ID_NONE; + fieldSystem->location->faceDirection = PlayerAvatar_GetDir(fieldSystem->playerAvatar); } void FieldSystem_SaveStateIfCommunicationOff(FieldSystem *fieldSystem) diff --git a/src/overlay006/ov6_0223E140.c b/src/overlay006/ov6_0223E140.c index 41422753f1..1e287da073 100644 --- a/src/overlay006/ov6_0223E140.c +++ b/src/overlay006/ov6_0223E140.c @@ -10,8 +10,8 @@ #include "field/field_system.h" #include "field/field_system_sub2_t.h" +#include "overlay005/fieldmap.h" #include "overlay005/motion_blur.h" -#include "overlay005/ov5_021D0D80.h" #include "overlay005/ov5_021D1A94.h" #include "overlay005/ov5_021D521C.h" #include "overlay005/struct_ov5_021D1BEC_decl.h" @@ -2058,7 +2058,7 @@ UnkStruct_ov6_022401B8 *ov6_02240104(u32 param0, FieldSystem *fieldSystem) ov6_02240260(&v0->unk_34, v0->unk_11C, &v0->unk_10C); { - BgConfig *v1 = sub_0203D170(v0->fieldSystem); + BgConfig *v1 = FieldSystem_GetBgConfig(v0->fieldSystem); Graphics_LoadTilesToBgLayer(172, 74, v1, 2, 0, 0, 0, param0); Graphics_LoadTilemapToBgLayer(172, 76, v1, 2, 0, 0, 0, param0); diff --git a/src/overlay006/ov6_02240C9C.c b/src/overlay006/ov6_02240C9C.c index b4da5ebd75..cc064acc3b 100644 --- a/src/overlay006/ov6_02240C9C.c +++ b/src/overlay006/ov6_02240C9C.c @@ -326,7 +326,7 @@ BOOL ov6_02240D5C(FieldSystem *fieldSystem) v13[i].minLevel = encounterData->grassEncounters.encounters[i].level; } - BOOL nationalDexObtained = Pokedex_IsNationalDexObtained(SaveData_Pokedex(FieldSystem_SaveData(fieldSystem))); + BOOL nationalDexObtained = Pokedex_IsNationalDexObtained(SaveData_Pokedex(FieldSystem_GetSaveData(fieldSystem))); WildEncounters_ReplaceTimedEncounters(encounterData, &v13[2].species, &v13[3].species); WildEncounters_ReplaceRadarEncounters(fieldSystem, encounterData, &v13[0].species, &v13[1].species); @@ -514,7 +514,7 @@ BOOL ov6_022411C8(FieldSystem *fieldSystem, TaskManager *param1) v12[i].minLevel = encounterData->grassEncounters.encounters[i].level; } - BOOL nationalDexObtained = Pokedex_IsNationalDexObtained(SaveData_Pokedex(FieldSystem_SaveData(fieldSystem))); + BOOL nationalDexObtained = Pokedex_IsNationalDexObtained(SaveData_Pokedex(FieldSystem_GetSaveData(fieldSystem))); WildEncounters_ReplaceTimedEncounters(encounterData, &v12[2].species, &v12[3].species); WildEncounters_ReplaceRadarEncounters(fieldSystem, encounterData, &v12[0].species, &v12[1].species); @@ -643,7 +643,7 @@ BOOL ov6_022413E4(FieldSystem *fieldSystem, BattleParams **battleParams) v12[i].minLevel = encounterData->grassEncounters.encounters[i].level; } - BOOL nationalDexObtained = Pokedex_IsNationalDexObtained(SaveData_Pokedex(FieldSystem_SaveData(fieldSystem))); + BOOL nationalDexObtained = Pokedex_IsNationalDexObtained(SaveData_Pokedex(FieldSystem_GetSaveData(fieldSystem))); WildEncounters_ReplaceTimedEncounters(encounterData, &v12[2].species, &v12[3].species); WildEncounters_ReplaceRadarEncounters(fieldSystem, encounterData, &v12[0].species, &v12[1].species); @@ -700,7 +700,7 @@ static BOOL ov6_02241674(FieldSystem *fieldSystem, Pokemon *firstPartyMon, Battl GetRadarMon(fieldSystem->chain, &species, &level); if (param6->unk_04 == 1) { - TrainerInfo *v3 = SaveData_GetTrainerInfo(FieldSystem_SaveData(fieldSystem)); + TrainerInfo *v3 = SaveData_GetTrainerInfo(FieldSystem_GetSaveData(fieldSystem)); v0 = ov6_02241F2C(species, level, 1, param6->unk_08, TrainerInfo_ID(v3), encounterFieldParams, firstPartyMon, battleParams); } else { v0 = ov6_02241F7C(fieldSystem, firstPartyMon, encounterFieldParams, param4, 1, battleParams, species, level); diff --git a/src/overlay006/ov6_02242984.c b/src/overlay006/ov6_02242984.c index fbd655101e..862a366753 100644 --- a/src/overlay006/ov6_02242984.c +++ b/src/overlay006/ov6_02242984.c @@ -3,8 +3,6 @@ #include #include -#include "struct_defs/struct_02049FA8.h" - #include "field/field_system.h" #include "overlay006/ov6_02240C9C.h" #include "overlay006/ov6_02242F74.h" @@ -14,6 +12,7 @@ #include "field_system.h" #include "heap.h" #include "inlines.h" +#include "location.h" #include "map_header_data.h" #include "narc.h" #include "player_avatar.h" @@ -43,7 +42,7 @@ int ov6_02242984(FieldSystem *fieldSystem) v2[i] = encounterData->grassEncounters.encounters[i].species; } - BOOL v1 = Pokedex_IsNationalDexObtained(SaveData_Pokedex(FieldSystem_SaveData(fieldSystem))); + BOOL v1 = Pokedex_IsNationalDexObtained(SaveData_Pokedex(FieldSystem_GetSaveData(fieldSystem))); ov6_02242F74(sub_0202D814(sub_0202D834(fieldSystem->saveData), 1), v1, fieldSystem->location->mapId, &v2[6], &v2[7]); WildEncounters_ReplaceTimedEncounters(encounterData, &v2[2], &v2[3]); diff --git a/src/overlay006/ov6_02242AF0.c b/src/overlay006/ov6_02242AF0.c index 3df02ab1da..6e48f09317 100644 --- a/src/overlay006/ov6_02242AF0.c +++ b/src/overlay006/ov6_02242AF0.c @@ -88,7 +88,7 @@ void ov6_02242AF0(FieldSystem *fieldSystem) UnkStruct_ov6_02242AF0 *v1; VecFx32 v2; - v0 = sub_02027860(FieldSystem_SaveData(fieldSystem)); + v0 = sub_02027860(FieldSystem_GetSaveData(fieldSystem)); v1 = (UnkStruct_ov6_02242AF0 *)sub_02027F6C(v0, 6); v2.x = ((FX32_ONE * 16) * (32 * 2 + 2)); @@ -115,7 +115,7 @@ void ov6_02242B58(FieldSystem *fieldSystem, const u16 param1, const u16 param2) UnkStruct_ov6_02242AF0 *v1; UnkStruct_ov6_02242B58 *v2; - v0 = sub_02027860(FieldSystem_SaveData(fieldSystem)); + v0 = sub_02027860(FieldSystem_GetSaveData(fieldSystem)); v1 = (UnkStruct_ov6_02242AF0 *)sub_02027F6C(v0, 6); v2 = Heap_AllocFromHeapAtEnd(4, sizeof(UnkStruct_ov6_02242B58)); @@ -184,7 +184,7 @@ u32 ov6_02242C3C(FieldSystem *fieldSystem, const u16 param1) UnkStruct_02027860 *v0; UnkStruct_ov6_02242AF0 *v1; - v0 = sub_02027860(FieldSystem_SaveData(fieldSystem)); + v0 = sub_02027860(FieldSystem_GetSaveData(fieldSystem)); v1 = (UnkStruct_ov6_02242AF0 *)sub_02027F6C(v0, 6); if (v1->unk_00 == param1) { diff --git a/src/overlay006/ov6_02247100.c b/src/overlay006/ov6_02247100.c index ebe3e39c4c..29b17622c5 100644 --- a/src/overlay006/ov6_02247100.c +++ b/src/overlay006/ov6_02247100.c @@ -6,7 +6,6 @@ #include "struct_decls/struct_0203A790_decl.h" #include "struct_decls/struct_020508D4_decl.h" #include "struct_decls/struct_02061AB4_decl.h" -#include "struct_defs/struct_02049FA8.h" #include "field/field_system.h" #include "overlay005/map_object_anim_cmd.h" @@ -17,6 +16,7 @@ #include "field_overworld_state.h" #include "heap.h" #include "journal.h" +#include "location.h" #include "player_avatar.h" #include "pokemon.h" #include "sys_task_manager.h" diff --git a/src/overlay006/ov6_02247660.c b/src/overlay006/ov6_02247660.c index b3c929419a..adea7c2a7e 100644 --- a/src/overlay006/ov6_02247660.c +++ b/src/overlay006/ov6_02247660.c @@ -8,7 +8,7 @@ #include "heap.h" #include "inlines.h" #include "narc.h" -#include "unk_0202B37C.h" +#include "record_mixed_rng.h" #include "unk_02039C80.h" #include "unk_0205F180.h" @@ -35,7 +35,7 @@ BOOL ov6_02247660(FieldSystem *fieldSystem) return 0; } - v13 = sub_0202B428(sub_0202B4A0(fieldSystem->saveData)); + v13 = RecordMixedRNG_GetRand(SaveData_GetRecordMixedRNG(fieldSystem->saveData)); sub_020615AC(fieldSystem->playerAvatar, &v15, &v16); diff --git a/src/overlay006/ov6_02247A0C.c b/src/overlay006/ov6_02247A0C.c index 76005dd066..067ee187b2 100644 --- a/src/overlay006/ov6_02247A0C.c +++ b/src/overlay006/ov6_02247A0C.c @@ -132,8 +132,8 @@ void *ov6_02247A90(void *param0) int v4, v5, v6, v7; SaveData *v8; - v1 = sub_0203D170(param0); - v8 = FieldSystem_SaveData(param0); + v1 = FieldSystem_GetBgConfig(param0); + v8 = FieldSystem_GetSaveData(param0); v0 = Heap_AllocFromHeap(11, sizeof(UnkStruct_ov6_02247A90)); MI_CpuClear8(v0, sizeof(UnkStruct_ov6_02247A90)); diff --git a/src/overlay007/communication_club.c b/src/overlay007/communication_club.c index 35c0d5705c..5402ce3828 100644 --- a/src/overlay007/communication_club.c +++ b/src/overlay007/communication_club.c @@ -220,7 +220,7 @@ static void CommClubMan_Init(FieldSystem *fieldSystem) sCommClubMan->fieldSystem = fieldSystem; sCommClubMan->unk_97 = 0; sCommClubMan->msgLoader = MessageLoader_Init(1, 26, 353, 4); - sCommClubMan->trainerInfoPersonal = SaveData_GetTrainerInfo(FieldSystem_SaveData(sCommClubMan->fieldSystem)); + sCommClubMan->trainerInfoPersonal = SaveData_GetTrainerInfo(FieldSystem_GetSaveData(sCommClubMan->fieldSystem)); sCommClubMan->unk_7C = TrainerInfo_New(4); Window_Init(&sCommClubMan->unk_20); diff --git a/src/overlay007/ov7_0224CD28.c b/src/overlay007/ov7_0224CD28.c index f083f78305..4903036a0c 100644 --- a/src/overlay007/ov7_0224CD28.c +++ b/src/overlay007/ov7_0224CD28.c @@ -8,7 +8,7 @@ #include "struct_decls/struct_020508D4_decl.h" #include "field/field_system.h" -#include "overlay005/ov5_021D0D80.h" +#include "overlay005/fieldmap.h" #include "overlay005/ov5_021D2F14.h" #include "overlay007/struct_ov7_0224D008.h" #include "overlay007/struct_ov7_0224F2EC.h" diff --git a/src/overlay008/ov8_02249960.c b/src/overlay008/ov8_02249960.c index 92eaf2212a..55c8972f08 100644 --- a/src/overlay008/ov8_02249960.c +++ b/src/overlay008/ov8_02249960.c @@ -360,7 +360,7 @@ void ov8_0224997C(FieldSystem *fieldSystem) UnkStruct_02027860 *v7; UnkStruct_02071B10 *v8; - v7 = sub_02027860(FieldSystem_SaveData(fieldSystem)); + v7 = sub_02027860(FieldSystem_GetSaveData(fieldSystem)); v8 = (UnkStruct_02071B10 *)sub_02027F6C(v7, 1); v6 = Heap_AllocFromHeapAtEnd(11, sizeof(UnkStruct_ov8_0224997C)); @@ -608,7 +608,7 @@ void ov8_02249DBC(FieldSystem *fieldSystem) UnkStruct_02027860 *v7; UnkStruct_02071B10 *v8; - v7 = sub_02027860(FieldSystem_SaveData(fieldSystem)); + v7 = sub_02027860(FieldSystem_GetSaveData(fieldSystem)); v8 = (UnkStruct_02071B10 *)sub_02027F6C(v7, 1); { @@ -756,7 +756,7 @@ void ov8_02249FB8(FieldSystem *fieldSystem) UnkStruct_02027860 *v2; UnkStruct_ov8_02249FB8 *v3; - v2 = sub_02027860(FieldSystem_SaveData(fieldSystem)); + v2 = sub_02027860(FieldSystem_GetSaveData(fieldSystem)); v3 = (UnkStruct_ov8_02249FB8 *)sub_02027F6C(v2, 2); PlayerAvatar_PosVectorOut(fieldSystem->playerAvatar, &v1); @@ -1244,7 +1244,7 @@ static void ov8_0224A254(UnkStruct_ov8_0224A1E4 *param0, const u8 param1) UnkStruct_02027860 *v3; UnkStruct_02071B30 *v4; - v3 = sub_02027860(FieldSystem_SaveData(param0->fieldSystem)); + v3 = sub_02027860(FieldSystem_GetSaveData(param0->fieldSystem)); v4 = (UnkStruct_02071B30 *)sub_02027F6C(v3, 3); v2 = Heap_AllocFromHeapAtEnd(11, sizeof(UnkStruct_ov8_0224997C)); @@ -1572,7 +1572,7 @@ void ov8_0224A8C8(FieldSystem *fieldSystem) UnkStruct_02027860 *v1; UnkStruct_02071B30 *v2; - v1 = sub_02027860(FieldSystem_SaveData(fieldSystem)); + v1 = sub_02027860(FieldSystem_GetSaveData(fieldSystem)); v2 = (UnkStruct_02071B30 *)sub_02027F6C(v1, 3); fieldSystem->unk_04->unk_24 = Heap_AllocFromHeap(4, sizeof(UnkStruct_ov8_0224A1E4)); @@ -1655,7 +1655,7 @@ BOOL ov8_0224AAA8(FieldSystem *fieldSystem) int v2; UnkStruct_02027860 *v3; - v3 = sub_02027860(FieldSystem_SaveData(fieldSystem)); + v3 = sub_02027860(FieldSystem_GetSaveData(fieldSystem)); v2 = sub_02027F80(v3); if (v2 != 3) { @@ -2081,7 +2081,7 @@ void ov8_0224ABD4(FieldSystem *fieldSystem) UnkStruct_02027860 *v1; UnkStruct_02071B6C *v2; - v1 = sub_02027860(FieldSystem_SaveData(fieldSystem)); + v1 = sub_02027860(FieldSystem_GetSaveData(fieldSystem)); v2 = (UnkStruct_02071B6C *)sub_02027F6C(v1, 5); fieldSystem->unk_04->unk_24 = Heap_AllocFromHeap(4, sizeof(UnkStruct_ov8_0224ABD4)); @@ -2170,7 +2170,7 @@ void ov8_0224AD34(FieldSystem *fieldSystem, const u8 param1) UnkStruct_02027860 *v2; UnkStruct_02071B6C *v3; - v2 = sub_02027860(FieldSystem_SaveData(fieldSystem)); + v2 = sub_02027860(FieldSystem_GetSaveData(fieldSystem)); v3 = (UnkStruct_02071B6C *)sub_02027F6C(v2, 5); v1 = (UnkStruct_ov8_0224ABD4 *)fieldSystem->unk_04->unk_24; v0 = Heap_AllocFromHeapAtEnd(11, sizeof(UnkStruct_ov8_0224997C)); @@ -2432,7 +2432,7 @@ void ov8_0224B020(FieldSystem *fieldSystem) UnkStruct_02071BD0 *v1; UnkStruct_ov8_0224AF00 *v2; - v0 = sub_02027860(FieldSystem_SaveData(fieldSystem)); + v0 = sub_02027860(FieldSystem_GetSaveData(fieldSystem)); v1 = sub_02027F6C(v0, 8); v2 = Heap_AllocFromHeap(4, sizeof(UnkStruct_ov8_0224AF00)); @@ -2495,7 +2495,7 @@ BOOL ov8_0224B110(FieldSystem *fieldSystem, const int param1, const int param2, UnkStruct_02027860 *v4; UnkStruct_02071BD0 *v5; - v4 = sub_02027860(FieldSystem_SaveData(fieldSystem)); + v4 = sub_02027860(FieldSystem_GetSaveData(fieldSystem)); v5 = sub_02027F6C(v4, 8); v1 = v5->unk_00; v0 = 0; @@ -2879,7 +2879,7 @@ BOOL ov8_0224B67C(FieldSystem *fieldSystem, Window *param1, MessageLoader *param UnkStruct_02027860 *v0; UnkStruct_02071BD0 *v1; - v0 = sub_02027860(FieldSystem_SaveData(fieldSystem)); + v0 = sub_02027860(FieldSystem_GetSaveData(fieldSystem)); v1 = sub_02027F6C(v0, 8); if (v1->unk_00 >= 4) { @@ -2918,7 +2918,7 @@ BOOL ov8_0224B714(FieldSystem *fieldSystem, int param1, int param2, int param3) UnkStruct_02071BD0 *v1; const UnkStruct_ov8_0224C7F0 *v2; - v0 = sub_02027860(FieldSystem_SaveData(fieldSystem)); + v0 = sub_02027860(FieldSystem_GetSaveData(fieldSystem)); v1 = sub_02027F6C(v0, 8); v2 = &Unk_ov8_0224C7F0[v1->unk_00]; @@ -2976,7 +2976,7 @@ void ov8_0224B764(FieldSystem *fieldSystem) UnkStruct_02071BF8 *v1; UnkStruct_ov8_0224B8D0 *v2; - v0 = sub_02027860(FieldSystem_SaveData(fieldSystem)); + v0 = sub_02027860(FieldSystem_GetSaveData(fieldSystem)); v1 = sub_02027F6C(v0, 4); v2 = Heap_AllocFromHeap(4, sizeof(UnkStruct_ov8_0224B8D0)); @@ -3524,7 +3524,7 @@ BOOL ov8_0224BF4C(FieldSystem *fieldSystem) { UnkStruct_02027860 *v0; - v0 = sub_02027860(FieldSystem_SaveData(fieldSystem)); + v0 = sub_02027860(FieldSystem_GetSaveData(fieldSystem)); if (sub_02027F80(v0) != 4) { return 0; @@ -3729,7 +3729,7 @@ void ov8_0224C198(FieldSystem *fieldSystem) UnkStruct_02071C18 *v1; UnkStruct_ov8_0224C444 *v2; - v0 = sub_02027860(FieldSystem_SaveData(fieldSystem)); + v0 = sub_02027860(FieldSystem_GetSaveData(fieldSystem)); v1 = sub_02027F6C(v0, 2); v2 = Heap_AllocFromHeap(4, sizeof(UnkStruct_ov8_0224C444)); @@ -3928,7 +3928,7 @@ BOOL ov8_0224C51C(FieldSystem *fieldSystem) MapObject *v7; MapObject *v8; - v4 = sub_02027860(FieldSystem_SaveData(fieldSystem)); + v4 = sub_02027860(FieldSystem_GetSaveData(fieldSystem)); if (sub_02027F80(v4) != 2) { return 0; @@ -3963,7 +3963,7 @@ BOOL ov8_0224C5DC(FieldSystem *fieldSystem, void *param1) { UnkStruct_02027860 *v0; - v0 = sub_02027860(FieldSystem_SaveData(fieldSystem)); + v0 = sub_02027860(FieldSystem_GetSaveData(fieldSystem)); if (sub_02027F80(v0) != 2) { return 0; @@ -3993,7 +3993,7 @@ BOOL ov8_0224C62C(FieldSystem *fieldSystem, int param1, int param2, int *param3) { UnkStruct_02027860 *v0; - v0 = sub_02027860(FieldSystem_SaveData(fieldSystem)); + v0 = sub_02027860(FieldSystem_GetSaveData(fieldSystem)); if (sub_02027F80(v0) != 2) { return 0; diff --git a/src/overlay009/ov9_02249960.c b/src/overlay009/ov9_02249960.c index c3d45aae83..9b42dbd7cd 100644 --- a/src/overlay009/ov9_02249960.c +++ b/src/overlay009/ov9_02249960.c @@ -18,8 +18,8 @@ #include "field/field_system.h" #include "field/field_system_sub2_t.h" +#include "overlay005/fieldmap.h" #include "overlay005/map_object_anim_cmd.h" -#include "overlay005/ov5_021D0D80.h" #include "overlay005/ov5_021D57BC.h" #include "overlay005/ov5_021DF440.h" #include "overlay005/ov5_021E779C.h" @@ -1172,7 +1172,7 @@ void ov9_02249960(FieldSystem *fieldSystem) UnkStruct_02071C5C *v1; UnkStruct_ov9_02249B04 *v2; - v0 = sub_02027860(FieldSystem_SaveData(fieldSystem)); + v0 = sub_02027860(FieldSystem_GetSaveData(fieldSystem)); v1 = sub_02027F6C(v0, 9); v2 = Heap_AllocFromHeap(4, sizeof(UnkStruct_ov9_02249B04)); @@ -1604,7 +1604,7 @@ void ov9_02249FD0(FieldSystem *fieldSystem) GF_ASSERT(fieldSystem != NULL); - v0 = sub_02027860(FieldSystem_SaveData(fieldSystem)); + v0 = sub_02027860(FieldSystem_GetSaveData(fieldSystem)); v1 = sub_02027F6C(v0, 9); v1->unk_04 = 0; @@ -2045,7 +2045,7 @@ BOOL ov9_0224A59C(FieldSystem *fieldSystem, int param1) { UnkStruct_02027860 *v0; - v0 = sub_02027860(FieldSystem_SaveData(fieldSystem)); + v0 = sub_02027860(FieldSystem_GetSaveData(fieldSystem)); if (sub_02027F80(v0) == 9) { int v1, v2, v3, v4; @@ -2129,7 +2129,7 @@ BOOL ov9_0224A71C(FieldSystem *fieldSystem) { UnkStruct_02027860 *v0; - v0 = sub_02027860(FieldSystem_SaveData(fieldSystem)); + v0 = sub_02027860(FieldSystem_GetSaveData(fieldSystem)); if (sub_02027F80(v0) != 9) { return 0; @@ -9486,7 +9486,7 @@ BOOL ov9_02250F74(FieldSystem *fieldSystem) { UnkStruct_02027860 *v0; - v0 = sub_02027860(FieldSystem_SaveData(fieldSystem)); + v0 = sub_02027860(FieldSystem_GetSaveData(fieldSystem)); if (sub_02027F80(v0) != 9) { return 0; @@ -9554,7 +9554,7 @@ BOOL ov9_02251044(FieldSystem *fieldSystem, int param1, int param2, int param3, { UnkStruct_02027860 *v0; - v0 = sub_02027860(FieldSystem_SaveData(fieldSystem)); + v0 = sub_02027860(FieldSystem_GetSaveData(fieldSystem)); if (sub_02027F80(v0) != 9) { GF_ASSERT(0); diff --git a/src/overlay023/ov23_0223E140.c b/src/overlay023/ov23_0223E140.c index a3eb750c16..11fa515090 100644 --- a/src/overlay023/ov23_0223E140.c +++ b/src/overlay023/ov23_0223E140.c @@ -1422,13 +1422,13 @@ static void ov23_0223F118(SysTask *param0, void *param1) case 2: if (IsScreenTransitionDone()) { if (fieldSystem->unk_6C == NULL) { - sub_0203CD44(fieldSystem); + FieldSystem_FlagNotRunningFieldMap(fieldSystem); (v0->unk_00)++; } } break; case 3: - if (!sub_0203CD4C(fieldSystem)) { + if (!FieldSystem_HasParentProcess(fieldSystem)) { sub_02039794(); (v0->unk_00)++; } @@ -1474,7 +1474,7 @@ static void ov23_0223F118(SysTask *param0, void *param1) v0->unk_08++; if (v0->unk_08 > 80) { - UndergroundData *v2 = sub_020298B0(FieldSystem_SaveData(Unk_ov23_02257740->fieldSystem)); + UndergroundData *v2 = sub_020298B0(FieldSystem_GetSaveData(Unk_ov23_02257740->fieldSystem)); ov23_02254044(ov23_0224219C()); @@ -1777,7 +1777,7 @@ static BOOL ov23_0223F838(int param0, int param1, int param2) static int ov23_0223F970(UnkStruct_ov23_02256EB0 *param0) { - SaveData *v0 = FieldSystem_SaveData(Unk_ov23_02257740->fieldSystem); + SaveData *v0 = FieldSystem_GetSaveData(Unk_ov23_02257740->fieldSystem); UndergroundData *v1 = sub_020298B0(v0); BOOL v2 = TrainerInfo_ID(SaveData_GetTrainerInfo(v0)) % 2; BOOL v3 = Pokedex_IsNationalDexObtained(SaveData_Pokedex(v0)); @@ -1850,7 +1850,7 @@ static int ov23_0223FA20(void) static void ov23_0223FA3C(BgConfig *param0, int param1, UnkStruct_ov23_0223EE80 *param2) { - UndergroundData *v0 = sub_020298B0(FieldSystem_SaveData(Unk_ov23_02257740->fieldSystem)); + UndergroundData *v0 = sub_020298B0(FieldSystem_GetSaveData(Unk_ov23_02257740->fieldSystem)); int v1, v2, v3 = ov23_0223F9C8(); int v4, v5, v6, v7, v8 = 0, v9, v10; int v11 = ov23_0223FA20(); @@ -2497,8 +2497,8 @@ static int ov23_0224080C(int param0) static void ov23_022408A0(int param0, int param1) { int v0 = param0; - SecretBaseRecord *v1 = SaveData_SecretBaseRecord(FieldSystem_SaveData(Unk_ov23_02257740->fieldSystem)); - UndergroundData *v2 = sub_020298B0(FieldSystem_SaveData(Unk_ov23_02257740->fieldSystem)); + SecretBaseRecord *v1 = SaveData_SecretBaseRecord(FieldSystem_GetSaveData(Unk_ov23_02257740->fieldSystem)); + UndergroundData *v2 = sub_020298B0(FieldSystem_GetSaveData(Unk_ov23_02257740->fieldSystem)); if (ov23_02241CF4(v0)) { ov23_0224F6E0(v0, param1); @@ -2510,7 +2510,7 @@ static void ov23_022408A0(int param0, int param1) static BOOL ov23_022408EC(int param0) { - UndergroundData *v0 = sub_020298B0(FieldSystem_SaveData(Unk_ov23_02257740->fieldSystem)); + UndergroundData *v0 = sub_020298B0(FieldSystem_GetSaveData(Unk_ov23_02257740->fieldSystem)); if (ov23_02241CF4(param0)) { if (40 == sub_02028C3C(v0)) { @@ -2683,7 +2683,7 @@ static BOOL ov23_02240CFC(UnkStruct_ov23_0223EE80 *param0) { u8 v0[2]; int v1; - UndergroundData *v2 = sub_020298B0(FieldSystem_SaveData(Unk_ov23_02257740->fieldSystem)); + UndergroundData *v2 = sub_020298B0(FieldSystem_GetSaveData(Unk_ov23_02257740->fieldSystem)); if (Unk_ov23_02257740->unk_A29 == 1) { Unk_ov23_02257740->unk_A29 = 0; diff --git a/src/overlay023/ov23_022416A8.c b/src/overlay023/ov23_022416A8.c index c51ba204a0..57398ae1eb 100644 --- a/src/overlay023/ov23_022416A8.c +++ b/src/overlay023/ov23_022416A8.c @@ -97,7 +97,7 @@ void ov23_022416E0(void *param0, FieldSystem *fieldSystem) MI_CpuFill8(Unk_ov23_02257744, 0, sizeof(UnkStruct_ov23_02257744)); Unk_ov23_02257744->fieldSystem = fieldSystem; - v1 = sub_020298B0(FieldSystem_SaveData(fieldSystem)); + v1 = sub_020298B0(FieldSystem_GetSaveData(fieldSystem)); for (v0 = 0; v0 < 100; v0++) { Unk_ov23_02257744->unk_00[v0].unk_06 = sub_020290DC(v1, v0); @@ -114,7 +114,7 @@ void ov23_022416E0(void *param0, FieldSystem *fieldSystem) static void ov23_02241778(void) { - UndergroundData *v0 = sub_020298B0(FieldSystem_SaveData(Unk_ov23_02257744->fieldSystem)); + UndergroundData *v0 = sub_020298B0(FieldSystem_GetSaveData(Unk_ov23_02257744->fieldSystem)); int v1; for (v1 = 0; v1 < 100; v1++) { @@ -527,7 +527,7 @@ BOOL ov23_02241D58(Strbuf *param0) int ov23_02241DF8(MATHRandContext16 *param0) { - UndergroundData *v0 = sub_020298B0(FieldSystem_SaveData(Unk_ov23_02257744->fieldSystem)); + UndergroundData *v0 = sub_020298B0(FieldSystem_GetSaveData(Unk_ov23_02257744->fieldSystem)); int v1, v2, v3; for (v3 = 0; v3 < 100; v3++) { diff --git a/src/overlay023/ov23_02241F74.c b/src/overlay023/ov23_02241F74.c index c81421c58c..88c8266985 100644 --- a/src/overlay023/ov23_02241F74.c +++ b/src/overlay023/ov23_02241F74.c @@ -789,8 +789,8 @@ void ov23_02242BC0(FieldSystem *fieldSystem) ov23_0223E1E4(v0, fieldSystem); v0 = Heap_AllocFromHeap(15, ov23_02253608()); - ov23_02253598(v0, SaveData_SecretBaseRecord(FieldSystem_SaveData(fieldSystem)), FieldSystem_SaveData(fieldSystem)); - ov23_0224F588(sub_020298B0(FieldSystem_SaveData(fieldSystem))); + ov23_02253598(v0, SaveData_SecretBaseRecord(FieldSystem_GetSaveData(fieldSystem)), FieldSystem_GetSaveData(fieldSystem)); + ov23_0224F588(sub_020298B0(FieldSystem_GetSaveData(fieldSystem))); } } diff --git a/src/overlay023/ov23_0224340C.c b/src/overlay023/ov23_0224340C.c index 3fd8bf7bff..0eb753464e 100644 --- a/src/overlay023/ov23_0224340C.c +++ b/src/overlay023/ov23_0224340C.c @@ -617,7 +617,7 @@ static const UnkFuncPtr_ov23_022564CC Unk_ov23_022565E4[] = { static void ov23_0224340C(void) { int v0; - UndergroundData *v1 = sub_020298B0(FieldSystem_SaveData(Unk_ov23_02257764->fieldSystem)); + UndergroundData *v1 = sub_020298B0(FieldSystem_GetSaveData(Unk_ov23_02257764->fieldSystem)); for (v0 = 0; v0 < 16; v0++) { Unk_ov23_02257764->unk_308[v0].unk_04 = sub_02029030(v1, v0); @@ -646,7 +646,7 @@ void ov23_022434BC(void *param0, FieldSystem *fieldSystem) MI_CpuFill8(Unk_ov23_02257764, 0, sizeof(UnkStruct_ov23_02257764)); Unk_ov23_02257764->fieldSystem = fieldSystem; - v1 = sub_020298B0(FieldSystem_SaveData(fieldSystem)); + v1 = sub_020298B0(FieldSystem_GetSaveData(fieldSystem)); Unk_ov23_02257764->unk_2F0 = NULL; @@ -1151,7 +1151,7 @@ void ov23_02243CE8(void) static void ov23_02243D50(void) { - UndergroundData *v0 = sub_020298B0(FieldSystem_SaveData(Unk_ov23_02257764->fieldSystem)); + UndergroundData *v0 = sub_020298B0(FieldSystem_GetSaveData(Unk_ov23_02257764->fieldSystem)); int v1; for (v1 = 0; v1 < 16; v1++) { @@ -1325,7 +1325,7 @@ BOOL ov23_02244080(int param0, UnkStruct_ov23_0224271C *param1, u8 param2) u8 v2 = param0; UnkStruct_ov23_02243DA8 *v3; UnkStruct_ov23_02244140 v4; - UndergroundData *v5 = sub_020298B0(FieldSystem_SaveData(Unk_ov23_02257764->fieldSystem)); + UndergroundData *v5 = sub_020298B0(FieldSystem_GetSaveData(Unk_ov23_02257764->fieldSystem)); v0 = CommPlayer_AddXServer(param0); v1 = CommPlayer_AddZServer(param0); @@ -1549,7 +1549,7 @@ void ov23_0224448C(int param0, int param1, void *param2, void *param3) return; } - v1 = SaveData_SecretBaseRecord(FieldSystem_SaveData(Unk_ov23_02257764->fieldSystem)); + v1 = SaveData_SecretBaseRecord(FieldSystem_GetSaveData(Unk_ov23_02257764->fieldSystem)); Sound_PlayEffect(1570); MI_CpuCopy8(v0, &Unk_ov23_02257764->unk_B28[v0->unk_07_0], sizeof(UnkStruct_ov23_02244140)); @@ -2547,7 +2547,7 @@ void ov23_02245560(int param0, int param1) void ov23_022455B4(int param0, int param1, void *param2, void *param3) { UnkStruct_ov23_02245560 *v0 = param2; - SecretBaseRecord *v1 = SaveData_SecretBaseRecord(FieldSystem_SaveData(Unk_ov23_02257764->fieldSystem)); + SecretBaseRecord *v1 = SaveData_SecretBaseRecord(FieldSystem_GetSaveData(Unk_ov23_02257764->fieldSystem)); ov23_0224B024(v0->unk_01); diff --git a/src/overlay023/ov23_022499E4.c b/src/overlay023/ov23_022499E4.c index de9218e351..43e59fa1b7 100644 --- a/src/overlay023/ov23_022499E4.c +++ b/src/overlay023/ov23_022499E4.c @@ -75,7 +75,7 @@ void ov23_022499E8(FieldSystem *fieldSystem) return; } - sub_02036794(FieldSystem_SaveData(fieldSystem)); + sub_02036794(FieldSystem_GetSaveData(fieldSystem)); FieldCommMan_Init(fieldSystem); v0 = FieldCommMan_Get(); diff --git a/src/overlay023/ov23_0224A1D0.c b/src/overlay023/ov23_0224A1D0.c index cf8515039b..bd90cc1df7 100644 --- a/src/overlay023/ov23_0224A1D0.c +++ b/src/overlay023/ov23_0224A1D0.c @@ -93,7 +93,7 @@ static void ov23_0224A204(int param0) } commPlayerMan->unk_27C[0] = commPlayerMan->unk_290[param0]; - sub_02028830(sub_020298B0(FieldSystem_SaveData(commPlayerMan->fieldSystem)), commPlayerMan->unk_290[param0]); + sub_02028830(sub_020298B0(FieldSystem_GetSaveData(commPlayerMan->fieldSystem)), commPlayerMan->unk_290[param0]); commPlayerMan->unk_290[param0] = NULL; commPlayerMan->unk_14A[param0].unk_20 = 0xff; @@ -227,7 +227,7 @@ void ov23_0224A410(int param0, int param1, void *param2, void *param3) commPlayerMan->unk_58.unk_00_9 = 0; if (commPlayerMan->unk_5A[v1->unk_02] == 0) { - sub_020294F4(SaveData_SecretBaseRecord(FieldSystem_SaveData(commPlayerMan->fieldSystem)), v1->unk_02); + sub_020294F4(SaveData_SecretBaseRecord(FieldSystem_GetSaveData(commPlayerMan->fieldSystem)), v1->unk_02); sub_0206B364(v2, sub_0206B354(v2) + 1); sub_0206B384(v2, sub_0206B374(v2) + 1); @@ -395,7 +395,7 @@ void ov23_0224A77C(int param0, int param1, void *param2, void *param3) UnkStruct_ov23_0224A570 *v1 = param2; BOOL v2; int v3 = 0; - SecretBaseRecord *v4 = SaveData_SecretBaseRecord(FieldSystem_SaveData(commPlayerMan->fieldSystem)); + SecretBaseRecord *v4 = SaveData_SecretBaseRecord(FieldSystem_GetSaveData(commPlayerMan->fieldSystem)); switch (v1->unk_00) { case 0: @@ -469,7 +469,7 @@ void ov23_0224A77C(int param0, int param1, void *param2, void *param3) ov23_0224B040(v1->unk_01); if (v1->unk_01 == CommSys_CurNetId()) { - SecretBaseRecord *v5 = SaveData_SecretBaseRecord(FieldSystem_SaveData(commPlayerMan->fieldSystem)); + SecretBaseRecord *v5 = SaveData_SecretBaseRecord(FieldSystem_GetSaveData(commPlayerMan->fieldSystem)); u8 v6 = sub_0202958C(v5); sub_020295C0(v5); diff --git a/src/overlay023/ov23_0224B05C.c b/src/overlay023/ov23_0224B05C.c index 075e5ad291..6088d3e265 100644 --- a/src/overlay023/ov23_0224B05C.c +++ b/src/overlay023/ov23_0224B05C.c @@ -9,7 +9,6 @@ #include "struct_decls/struct_02029894_decl.h" #include "struct_decls/struct_020298B0_decl.h" #include "struct_decls/struct_020508D4_decl.h" -#include "struct_defs/struct_02049FA8.h" #include "field/field_system.h" #include "overlay005/ov5_021E15F4.h" @@ -40,6 +39,7 @@ #include "graphics.h" #include "heap.h" #include "journal.h" +#include "location.h" #include "map_object_move.h" #include "menu.h" #include "message.h" @@ -378,7 +378,7 @@ void ov23_0224B2C8(FieldSystem *fieldSystem) UnkStruct_02029894 *v0; SecretBaseRecord *v1; - v0 = sub_02029894(FieldSystem_SaveData(fieldSystem)); + v0 = sub_02029894(FieldSystem_GetSaveData(fieldSystem)); v1 = sub_020298AC(v0); sub_020294D4(v1, GameRecords_GetTrainerScore(SaveData_GetGameRecordsPtr(fieldSystem->saveData))); @@ -1529,11 +1529,11 @@ static BOOL ov23_0224C708(TaskManager *param0) switch (v1->unk_10) { case 0: - sub_0203CD44(fieldSystem); + FieldSystem_FlagNotRunningFieldMap(fieldSystem); (v1->unk_10)++; break; case 1: - if (!sub_0203CD4C(fieldSystem)) { + if (!FieldSystem_HasParentProcess(fieldSystem)) { v1->unk_10 = 0; return 1; } @@ -1550,7 +1550,7 @@ static BOOL ov23_0224C74C(TaskManager *param0) switch (v1->unk_10) { case 0: - sub_0203CD00(fieldSystem); + FieldSystem_StartFieldMap(fieldSystem); (v1->unk_10)++; break; case 1: @@ -1606,10 +1606,10 @@ static BOOL ov23_0224C790(TaskManager *param0) break; case 4: v2.mapId = v1->unk_14; - v2.unk_04 = v1->unk_18; + v2.warpId = v1->unk_18; v2.x = v1->unk_1C; v2.z = v1->unk_20; - v2.unk_10 = v1->unk_24; + v2.faceDirection = v1->unk_24; sub_020544F0(param0, &v2); (v1->unk_0C)++; break; @@ -1982,7 +1982,7 @@ static void ov23_0224CEC8(void) void ov23_0224CF18(int param0, int param1, void *param2, void *param3) { UnkStruct_ov23_0224CF18 *v0 = param2; - SecretBaseRecord *v1 = SaveData_SecretBaseRecord(FieldSystem_SaveData(Unk_ov23_022577AC->fieldSystem)); + SecretBaseRecord *v1 = SaveData_SecretBaseRecord(FieldSystem_GetSaveData(Unk_ov23_022577AC->fieldSystem)); if (v0->unk_00 != CommSys_CurNetId()) { return; @@ -2152,8 +2152,8 @@ BOOL ov23_0224D1A0(int param0, int param1) static void ov23_0224D238(void) { - UnkStruct_02029894 *v0 = sub_02029894(FieldSystem_SaveData(Unk_ov23_022577AC->fieldSystem)); - UndergroundData *v1 = sub_020298B0(FieldSystem_SaveData(Unk_ov23_022577AC->fieldSystem)); + UnkStruct_02029894 *v0 = sub_02029894(FieldSystem_GetSaveData(Unk_ov23_022577AC->fieldSystem)); + UndergroundData *v1 = sub_020298B0(FieldSystem_GetSaveData(Unk_ov23_022577AC->fieldSystem)); int v2 = CommPlayer_AddXServer(0); int v3 = CommPlayer_AddZServer(0); int v4 = CommPlayer_DirServer(0); diff --git a/src/overlay023/ov23_0224DC40.c b/src/overlay023/ov23_0224DC40.c index 621010fd5d..636e2b7633 100644 --- a/src/overlay023/ov23_0224DC40.c +++ b/src/overlay023/ov23_0224DC40.c @@ -459,7 +459,7 @@ static void ov23_0224E124(UnkStruct_ov23_0224E280 *param0) ov23_022540F4(ov23_0224219C(), param0->unk_28.unk_02); ov23_02253F40(ov23_0224219C(), 14, 0, NULL); - sub_0202952C(SaveData_SecretBaseRecord(FieldSystem_SaveData(param0->fieldSystem))); + sub_0202952C(SaveData_SecretBaseRecord(FieldSystem_GetSaveData(param0->fieldSystem))); ov23_0224F634(param0->unk_28.unk_02); Sound_PlayEffect(1507); } @@ -902,7 +902,7 @@ static void ov23_0224E93C(SysTask *param0, UnkStruct_ov23_022577B0 *param1) if (v0 == 0) { if (ov23_0224F744(param1->unk_24.unk_02)) { - sub_0202977C(SaveData_SecretBaseRecord(FieldSystem_SaveData(param1->fieldSystem))); + sub_0202977C(SaveData_SecretBaseRecord(FieldSystem_GetSaveData(param1->fieldSystem))); Sound_PlayEffect(1507); ov23_0224DC40(param1, 22); diff --git a/src/overlay023/ov23_0224F294.c b/src/overlay023/ov23_0224F294.c index a87fbaef3c..c09788795f 100644 --- a/src/overlay023/ov23_0224F294.c +++ b/src/overlay023/ov23_0224F294.c @@ -293,7 +293,7 @@ void ov23_0224F5B8(void) static int ov23_0224F5C8(void *param0) { UnkStruct_ov23_02250CD4 *v0 = param0; - UndergroundData *v1 = sub_020298B0(FieldSystem_SaveData(v0->fieldSystem)); + UndergroundData *v1 = sub_020298B0(FieldSystem_GetSaveData(v0->fieldSystem)); return sub_02028E28(v1); } @@ -301,7 +301,7 @@ static int ov23_0224F5C8(void *param0) static int ov23_0224F5DC(void *param0) { UnkStruct_ov23_02250CD4 *v0 = param0; - UndergroundData *v1 = sub_020298B0(FieldSystem_SaveData(v0->fieldSystem)); + UndergroundData *v1 = sub_020298B0(FieldSystem_GetSaveData(v0->fieldSystem)); return sub_020289A0(v1); } @@ -309,7 +309,7 @@ static int ov23_0224F5DC(void *param0) int ov23_0224F5F0(int param0, void *param1) { UnkStruct_ov23_02250CD4 *v0 = param1; - UndergroundData *v1 = sub_020298B0(FieldSystem_SaveData(v0->fieldSystem)); + UndergroundData *v1 = sub_020298B0(FieldSystem_GetSaveData(v0->fieldSystem)); return sub_020289B8(v1, param0); } @@ -317,7 +317,7 @@ int ov23_0224F5F0(int param0, void *param1) static int ov23_0224F608(void *param0) { UnkStruct_ov23_02250CD4 *v0 = param0; - UndergroundData *v1 = sub_020298B0(FieldSystem_SaveData(v0->fieldSystem)); + UndergroundData *v1 = sub_020298B0(FieldSystem_GetSaveData(v0->fieldSystem)); return sub_02028B70(v1); } @@ -325,7 +325,7 @@ static int ov23_0224F608(void *param0) int ov23_0224F61C(int param0, void *param1) { UnkStruct_ov23_02250CD4 *v0 = param1; - UndergroundData *v1 = sub_020298B0(FieldSystem_SaveData(v0->fieldSystem)); + UndergroundData *v1 = sub_020298B0(FieldSystem_GetSaveData(v0->fieldSystem)); return sub_02028B88(v1, param0); } @@ -339,7 +339,7 @@ void ov23_0224F634(int param0) static int ov23_0224F658(void *param0) { UnkStruct_ov23_02250CD4 *v0 = param0; - UndergroundData *v1 = sub_020298B0(FieldSystem_SaveData(v0->fieldSystem)); + UndergroundData *v1 = sub_020298B0(FieldSystem_GetSaveData(v0->fieldSystem)); return sub_02028C3C(v1); } @@ -347,7 +347,7 @@ static int ov23_0224F658(void *param0) int ov23_0224F66C(int param0, void *param1) { UnkStruct_ov23_02250CD4 *v0 = param1; - UndergroundData *v1 = sub_020298B0(FieldSystem_SaveData(v0->fieldSystem)); + UndergroundData *v1 = sub_020298B0(FieldSystem_GetSaveData(v0->fieldSystem)); return sub_02028E44(v1, param0); } @@ -355,7 +355,7 @@ int ov23_0224F66C(int param0, void *param1) int ov23_0224F684(int param0, void *param1) { UnkStruct_ov23_02250CD4 *v0 = param1; - UndergroundData *v1 = sub_020298B0(FieldSystem_SaveData(v0->fieldSystem)); + UndergroundData *v1 = sub_020298B0(FieldSystem_GetSaveData(v0->fieldSystem)); return sub_02028C54(v1, param0); } @@ -363,7 +363,7 @@ int ov23_0224F684(int param0, void *param1) int ov23_0224F69C(int param0, void *param1) { UnkStruct_ov23_02250CD4 *v0 = param1; - UndergroundData *v1 = sub_020298B0(FieldSystem_SaveData(v0->fieldSystem)); + UndergroundData *v1 = sub_020298B0(FieldSystem_GetSaveData(v0->fieldSystem)); return sub_02028C60(v1, param0); } @@ -371,7 +371,7 @@ int ov23_0224F69C(int param0, void *param1) static int ov23_0224F6B4(void *param0) { UnkStruct_ov23_02250CD4 *v0 = param0; - UndergroundData *v1 = sub_020298B0(FieldSystem_SaveData(v0->fieldSystem)); + UndergroundData *v1 = sub_020298B0(FieldSystem_GetSaveData(v0->fieldSystem)); return sub_02028D58(v1); } @@ -379,7 +379,7 @@ static int ov23_0224F6B4(void *param0) int ov23_0224F6C8(int param0, void *param1) { UnkStruct_ov23_02250CD4 *v0 = param1; - UndergroundData *v1 = sub_020298B0(FieldSystem_SaveData(v0->fieldSystem)); + UndergroundData *v1 = sub_020298B0(FieldSystem_GetSaveData(v0->fieldSystem)); return sub_02028D74(v1, param0); } @@ -489,7 +489,7 @@ static void ov23_0224F7F4(UnkStruct_ov23_02250CD4 *param0) for (v4 = 0; v4 < NELEMS(Unk_ov23_02256924); v4++) { if (v4 == v1) { - const TrainerInfo *v5 = SaveData_GetTrainerInfo(FieldSystem_SaveData(param0->fieldSystem)); + const TrainerInfo *v5 = SaveData_GetTrainerInfo(FieldSystem_GetSaveData(param0->fieldSystem)); Strbuf *v6 = TrainerInfo_NameNewStrbuf(v5, 4); StringList_AddFromStrbuf(param0->unk_40, v6, Unk_ov23_02256924[v4].unk_04); @@ -1409,7 +1409,7 @@ static void ov23_02250A14(UnkStruct_ov23_02250CD4 *param0) { ov23_0224FB7C(param0); ov23_02253968(); - ov23_02253834(param0->fieldSystem->bgConfig, SaveData_GetTrainerInfo(FieldSystem_SaveData(param0->fieldSystem)), ov23_02250A0C, param0, 1); + ov23_02253834(param0->fieldSystem->bgConfig, SaveData_GetTrainerInfo(FieldSystem_GetSaveData(param0->fieldSystem)), ov23_02250A0C, param0, 1); param0->unk_2AA = 10; } @@ -1551,7 +1551,7 @@ static void ov23_02250C74(ListMenu *param0, u32 param1, u8 param2) { UnkStruct_ov23_02250CD4 *v0 = (UnkStruct_ov23_02250CD4 *)ListMenu_GetAttribute(param0, 19); int v1 = param1; - UndergroundData *v2 = sub_020298B0(FieldSystem_SaveData(v0->fieldSystem)); + UndergroundData *v2 = sub_020298B0(FieldSystem_GetSaveData(v0->fieldSystem)); if (!sub_02028AFC(v2, v1)) { ListMenu_SetAltTextColors(param0, 1, 15, 2); diff --git a/src/overlay023/ov23_0225128C.c b/src/overlay023/ov23_0225128C.c index c8940b340c..6837eaf285 100644 --- a/src/overlay023/ov23_0225128C.c +++ b/src/overlay023/ov23_0225128C.c @@ -5,7 +5,6 @@ #include "struct_decls/struct_020298B0_decl.h" #include "struct_decls/struct_020508D4_decl.h" -#include "struct_defs/struct_02049FA8.h" #include "field/field_system.h" #include "overlay023/funcptr_ov23_022515D8.h" @@ -33,6 +32,7 @@ #include "field_system.h" #include "heap.h" #include "list_menu.h" +#include "location.h" #include "menu.h" #include "message.h" #include "player_avatar.h" @@ -228,7 +228,7 @@ int ov23_02251414(void) static BOOL ov23_02251418(int param0, UnkStruct_ov23_02250CD4 *param1) { - UndergroundData *v0 = sub_020298B0(FieldSystem_SaveData(param1->fieldSystem)); + UndergroundData *v0 = sub_020298B0(FieldSystem_GetSaveData(param1->fieldSystem)); int v1; v1 = sub_02028B88(v0, param0); @@ -243,7 +243,7 @@ static BOOL ov23_02251418(int param0, UnkStruct_ov23_02250CD4 *param1) static int ov23_0225144C(int param0, UnkStruct_ov23_02250CD4 *param1) { - UndergroundData *v0 = sub_020298B0(FieldSystem_SaveData(param1->fieldSystem)); + UndergroundData *v0 = sub_020298B0(FieldSystem_GetSaveData(param1->fieldSystem)); int v1; if (sub_02028AFC(v0, param0)) { @@ -702,7 +702,7 @@ static void ov23_02251C04(SysTask *param0, void *param1) case 6: ov23_0224FB7C(param1); ov23_02254044(ov23_022421BC()); - v0->unk_270 = ov23_02253C64(v0->fieldSystem->bgConfig, SaveData_GetTrainerInfo(FieldSystem_SaveData(v0->fieldSystem)), sub_020298B0(FieldSystem_SaveData(v0->fieldSystem)), NULL, NULL); + v0->unk_270 = ov23_02253C64(v0->fieldSystem->bgConfig, SaveData_GetTrainerInfo(FieldSystem_GetSaveData(v0->fieldSystem)), sub_020298B0(FieldSystem_GetSaveData(v0->fieldSystem)), NULL, NULL); v0->unk_2AA = 7; break; case 7: diff --git a/src/overlay023/ov23_022521F0.c b/src/overlay023/ov23_022521F0.c index 44bcfae77e..6d3fce9a29 100644 --- a/src/overlay023/ov23_022521F0.c +++ b/src/overlay023/ov23_022521F0.c @@ -86,7 +86,7 @@ static void ov23_022521F0(UnkStruct_ov23_02250CD4 *param0, int param1) { MATHRandContext16 v0; int v1, v2, v3, v4, v5; - UndergroundData *v6 = sub_020298B0(FieldSystem_SaveData(param0->fieldSystem)); + UndergroundData *v6 = sub_020298B0(FieldSystem_GetSaveData(param0->fieldSystem)); MATH_InitRand16(&v0, sub_02028930(v6) + param1); @@ -131,7 +131,7 @@ static void ov23_022522F0(UnkStruct_ov23_02250CD4 *param0, int param1) { MATHRandContext16 v0; int v1, v2, v3, v4, v5; - SaveData *v6 = FieldSystem_SaveData(param0->fieldSystem); + SaveData *v6 = FieldSystem_GetSaveData(param0->fieldSystem); UndergroundData *v7 = sub_020298B0(v6); BOOL v8 = Pokedex_IsNationalDexObtained(SaveData_Pokedex(v6)); @@ -176,7 +176,7 @@ static void ov23_022522F0(UnkStruct_ov23_02250CD4 *param0, int param1) static int ov23_02252404(UnkStruct_ov23_02250CD4 *param0, int param1, int param2) { BOOL v0 = 0; - UndergroundData *v1 = sub_020298B0(FieldSystem_SaveData(param0->fieldSystem)); + UndergroundData *v1 = sub_020298B0(FieldSystem_GetSaveData(param0->fieldSystem)); if (param0->unk_279[param1] != ov23_0224F684(param2, param0)) { return 0xfffd; @@ -299,7 +299,7 @@ static void ov23_02252754(ListMenu *param0, u32 param1, u8 param2) { MATHRandContext16 v0; UnkStruct_ov23_02250CD4 *v1 = (UnkStruct_ov23_02250CD4 *)ListMenu_GetAttribute(param0, 19); - UndergroundData *v2 = sub_020298B0(FieldSystem_SaveData(v1->fieldSystem)); + UndergroundData *v2 = sub_020298B0(FieldSystem_GetSaveData(v1->fieldSystem)); int v3 = param1, v4, v5; int v6, v7 = 0, v8; @@ -474,7 +474,7 @@ static void ov23_02252BB8(int param0, UnkStruct_ov23_02250CD4 *param1) static u32 ov23_02252C08(UnkStruct_ov23_02250CD4 *param0) { - UndergroundData *v0 = sub_020298B0(FieldSystem_SaveData(param0->fieldSystem)); + UndergroundData *v0 = sub_020298B0(FieldSystem_GetSaveData(param0->fieldSystem)); if (ov23_0224F6E0(param0->unk_279[0], param0->unk_27E[0])) { if (param0->unk_2AC == 1) { diff --git a/src/overlay048/ov48_022561C0.c b/src/overlay048/ov48_022561C0.c index b3c08dca98..193dfe27e2 100644 --- a/src/overlay048/ov48_022561C0.c +++ b/src/overlay048/ov48_022561C0.c @@ -2,20 +2,18 @@ #include #include -#include "struct_decls/struct_02027854_decl.h" - #include "overlay025/poketch_system.h" #include "overlay048/ov48_0225650C.h" #include "overlay048/struct_ov48_0225650C_1.h" #include "overlay048/struct_ov48_0225650C_decl.h" +#include "berry_patches.h" #include "bg_window.h" #include "heap.h" #include "inlines.h" #include "savedata_misc.h" #include "sys_task.h" #include "sys_task_manager.h" -#include "unk_02027B70.h" #include "unk_0206AFE0.h" #include "vars_flags.h" @@ -311,11 +309,11 @@ static BOOL ov48_022563D0(UnkStruct_ov48_0225621C *param0) static int ov48_02256408(UnkStruct_ov48_0225621C *param0) { - UnkStruct_02027854 *v0 = sub_02027854(PoketchSystem_GetSaveData(param0->poketchSys)); + BerryPatch *v0 = MiscSaveBlock_GetBerryPatches(PoketchSystem_GetSaveData(param0->poketchSys)); int v1, v2; for (v1 = 0, v2 = 0; v1 < (NELEMS(Unk_ov48_02256A38)); v1++) { - if ((sub_02027D84(v0, v1) == 1) && (sub_02027D04(v0, v1) == 5)) { + if ((BerryPatches_IsPatchGrowing(v0, v1) == 1) && (BerryPatches_GetPatchGrowthStage(v0, v1) == 5)) { param0->unk_04.unk_0C[v2].unk_00 = Unk_ov48_02256A38[v1].unk_00; param0->unk_04.unk_0C[v2].unk_01 = Unk_ov48_02256A38[v1].unk_01; diff --git a/src/overlay057/ov57_021D0D80.c b/src/overlay057/ov57_021D0D80.c deleted file mode 100644 index 8591a11ea8..0000000000 --- a/src/overlay057/ov57_021D0D80.c +++ /dev/null @@ -1,183 +0,0 @@ -#include -#include - -#include "constants/game_options.h" - -#include "struct_decls/struct_02025CCC_decl.h" -#include "struct_decls/struct_02027854_decl.h" -#include "struct_decls/struct_0202B4A0_decl.h" -#include "struct_defs/struct_0203CC84.h" -#include "struct_defs/struct_02055BA8.h" - -#include "overlay057/const_ov57_021D0F70.h" -#include "overlay057/const_ov57_021D0F80.h" -#include "overlay057/const_ov57_021D0F90.h" -#include "overlay057/ov57_021D0F30.h" - -#include "game_options.h" -#include "heap.h" -#include "overlay_manager.h" -#include "party.h" -#include "pokemon.h" -#include "save_player.h" -#include "savedata.h" -#include "savedata_misc.h" -#include "trainer_info.h" -#include "unk_02000C88.h" -#include "unk_02017428.h" -#include "unk_0201D15C.h" -#include "unk_02025CB0.h" -#include "unk_02027B70.h" -#include "unk_0202B37C.h" -#include "unk_0205C980.h" -#include "unk_0206B9D8.h" - -#include "constdata/const_020EA10C.h" -#include "constdata/const_020EA11C.h" -#include "constdata/const_020F6824.h" - -static int ov57_021D0D80(OverlayManager *param0, int *param1); -static int ov57_021D0D98(OverlayManager *param0, int *param1); -static int ov57_021D0DAC(OverlayManager *param0, int *param1); -static int ov57_021D0DC8(OverlayManager *param0, int *param1); -static int ov57_021D0DE0(OverlayManager *param0, int *param1); -static int ov57_021D0E00(OverlayManager *param0, int *param1); -static int ov57_021D0E1C(OverlayManager *param0, int *param1); -static int ov57_021D0E34(OverlayManager *param0, int *param1); -static int ov57_021D0E90(OverlayManager *param0, int *param1); -static void ov57_021D0EAC(int param0, SaveData *param1, BOOL param2); - -const OverlayManagerTemplate Unk_ov57_021D0F90 = { - ov57_021D0D80, - ov57_021D0D98, - ov57_021D0DAC, - 0xffffffff -}; - -const OverlayManagerTemplate Unk_ov57_021D0F80 = { - ov57_021D0DC8, - ov57_021D0DE0, - ov57_021D0E00, - 0xffffffff -}; - -const OverlayManagerTemplate Unk_ov57_021D0F70 = { - ov57_021D0E1C, - ov57_021D0E34, - ov57_021D0E90, - 0xffffffff -}; - -static int ov57_021D0D80(OverlayManager *param0, int *param1) -{ - Heap_Create(3, 77, 131072); - InitRNG(); - - return 1; -} - -static int ov57_021D0D98(OverlayManager *param0, int *param1) -{ - SaveData *v0 = ((UnkStruct_0203CC84 *)OverlayManager_Args(param0))->unk_08; - - ov57_021D0F44(77, v0); - return 1; -} - -static int ov57_021D0DAC(OverlayManager *param0, int *param1) -{ - Heap_Destroy(77); - sub_02000EC4(0xffffffff, &Unk_020F6824); - - return 1; -} - -static int ov57_021D0DC8(OverlayManager *param0, int *param1) -{ - Heap_Create(3, 77, 131072); - InitRNG(); - - return 1; -} - -static int ov57_021D0DE0(OverlayManager *param0, int *param1) -{ - SaveData *v0 = ((UnkStruct_0203CC84 *)OverlayManager_Args(param0))->unk_08; - - ov57_021D0EAC(77, v0, 1); - sub_02017434(SaveData_GetPlayTime(v0)); - - return 1; -} - -static int ov57_021D0E00(OverlayManager *param0, int *param1) -{ - Heap_Destroy(77); - sub_02000EC4(0xffffffff, &gFieldSystemNewGameTemplate); - return 1; -} - -static int ov57_021D0E1C(OverlayManager *param0, int *param1) -{ - Heap_Create(3, 77, 131072); - InitRNG(); - - return 1; -} - -static int ov57_021D0E34(OverlayManager *param0, int *param1) -{ - SaveData *v0 = ((UnkStruct_0203CC84 *)OverlayManager_Args(param0))->unk_08; - UnkStruct_02025CCC *v1 = sub_02025CCC(v0); - - ov57_021D0F30(77, v0); - Options_SetSystemButtonMode(v0, OPTIONS_BUTTON_MODE_NORMAL); - - if (!sub_02025D10(v1) || !sub_02025D40(v1)) { - sub_02025DE8(sub_02025CD8(v0)); - sub_02025CE4(v1); - Party_SetShayminLandForm(Party_GetFromSavedata(v0)); - } - - sub_02017434(SaveData_GetPlayTime(v0)); - return 1; -} - -static int ov57_021D0E90(OverlayManager *param0, int *param1) -{ - Heap_Destroy(77); - sub_02000EC4(0xffffffff, &gFieldSystemContinueTemplate); - return 1; -} - -#include "data/berry_init.h" - -static void ov57_021D0EAC(int param0, SaveData *param1, BOOL param2) -{ - u32 v0; - UnkStruct_02027854 *v1; - TrainerInfo *v2; - UnkStruct_02055BA8 *v3; - UnkStruct_0202B4A0 *v4; - - sub_02025CE4(sub_02025CCC(param1)); - - v3 = sub_02025CD8(param1); - sub_02025D84(v3); - - v4 = sub_0202B4A0(param1); - sub_0202B40C(v4, 1, MTRNG_Next()); - sub_0206C008(param1); - - v2 = SaveData_GetTrainerInfo(param1); - v0 = MTRNG_Next(); - - if (param2) { - TrainerInfo_SetID(v2, v0); - } - - TrainerInfo_SetAppearance(v2, sub_0205C9BC(v0, TrainerInfo_Gender(v2), 0)); - - v1 = sub_02027854(param1); - sub_02027B90(v1, param0, sBerryInitTable, NELEMS(sBerryInitTable) / 2); -} diff --git a/src/overlay057/ov57_021D0F30.c b/src/overlay057/ov57_021D0F30.c deleted file mode 100644 index 3d0411b607..0000000000 --- a/src/overlay057/ov57_021D0F30.c +++ /dev/null @@ -1,30 +0,0 @@ -#include "overlay057/ov57_021D0F30.h" - -#include -#include - -#include "save_player.h" -#include "savedata.h" -#include "trainer_info.h" -#include "unk_0203D178.h" -#include "unk_0206A8DC.h" -#include "vars_flags.h" - -void ov57_021D0F30(int param0, SaveData *param1) -{ - if (!SaveData_Load(param1)) { - OS_ResetSystem(0); - } -} - -void ov57_021D0F44(int param0, SaveData *param1) -{ - TrainerInfo *v0; - - SaveData_Clear(param1); - sub_0203D1A8(param1); - - v0 = SaveData_GetTrainerInfo(param1); - TrainerInfo_SetMoney(v0, 3000); - sub_0206A92C(SaveData_GetVarsFlags(param1)); -} diff --git a/src/overlay059/ov59_021D2A2C.c b/src/overlay059/ov59_021D2A2C.c index a099f466c6..058606d2d0 100644 --- a/src/overlay059/ov59_021D2A2C.c +++ b/src/overlay059/ov59_021D2A2C.c @@ -3,59 +3,56 @@ #include #include -#include "struct_defs/struct_0202B4A0.h" -#include "struct_defs/struct_0202B510.h" +#include "record_mixed_rng.h" -#include "unk_0202B37C.h" +static void ov59_021D2A78(RecordMixedRNG *param0, int param1); +static void ov59_021D2A34(RecordMixedRNG *param0, const RecordMixedRNG *param1); -static void ov59_021D2A78(UnkStruct_0202B4A0 *param0, int param1); -static void ov59_021D2A34(UnkStruct_0202B4A0 *param0, const UnkStruct_0202B510 *param1); - -u32 ov59_021D2A2C(UnkStruct_0202B4A0 *param0) +u32 ov59_021D2A2C(RecordMixedRNG *param0) { - return sizeof(UnkStruct_0202B510); + return sizeof(RecordMixedRNG); } -void *ov59_021D2A30(UnkStruct_0202B4A0 *param0) +void *ov59_021D2A30(RecordMixedRNG *param0) { - return ¶m0->unk_00[1]; + return ¶m0[1]; } -static void ov59_021D2A34(UnkStruct_0202B4A0 *param0, const UnkStruct_0202B510 *param1) +static void ov59_021D2A34(RecordMixedRNG *param0, const RecordMixedRNG *param1) { int v0; for (v0 = 5; v0 > 2; v0--) { - param0->unk_00[v0] = param0->unk_00[v0 - 1]; + param0[v0] = param0[v0 - 1]; } - param0->unk_00[2] = *param1; + param0[2] = *param1; } -static void ov59_021D2A78(UnkStruct_0202B4A0 *param0, int param1) +static void ov59_021D2A78(RecordMixedRNG *param0, int param1) { int v0; - UnkStruct_0202B510 *v1; + RecordMixedRNG *v1; GF_ASSERT(2 <= param1 && param1 <= 5); for (v0 = param1 + 1; v0 <= 5; v0++) { - param0->unk_00[v0 - 1] = param0->unk_00[v0]; + param0[v0 - 1] = param0[v0]; } - v1 = ¶m0->unk_00[5]; + v1 = ¶m0[5]; - v1->unk_00[0] = 0xffff; - v1->unk_10[0] = 0xffff; + v1->groupName[0] = 0xffff; + v1->playerName[0] = 0xffff; } -void ov59_021D2AC4(int param0, int param1, UnkStruct_0202B4A0 *param2, const void **param3) +void ov59_021D2AC4(int param0, int param1, RecordMixedRNG *param2, const void **param3) { int v0, v1; - UnkStruct_0202B510 *v2; + RecordMixedRNG *v2; for (v0 = 0; v0 < param0; v0++) { - v2 = (UnkStruct_0202B510 *)param3[v0]; + v2 = (RecordMixedRNG *)param3[v0]; if (v0 == param1) { continue; @@ -65,16 +62,16 @@ void ov59_021D2AC4(int param0, int param1, UnkStruct_0202B4A0 *param2, const voi continue; } - if (sub_0202B510(v2) == 1) { + if (RecordMixedRNG_IsEntryEmpty(v2) == 1) { continue; } - if (sub_0202B530(v2, ¶m2->unk_00[0])) { + if (RecordMixedRNG_AreEntriesEqual(v2, ¶m2[0])) { continue; } for (v1 = 0; v1 < 4; v1++) { - if (sub_0202B530(v2, ¶m2->unk_00[2 + v1])) { + if (RecordMixedRNG_AreEntriesEqual(v2, ¶m2[2 + v1])) { ov59_021D2A78(param2, 2 + v1); } } diff --git a/src/overlay059/ov59_021D2F88.c b/src/overlay059/ov59_021D2F88.c index 3ec7769404..4e3c26d735 100644 --- a/src/overlay059/ov59_021D2F88.c +++ b/src/overlay059/ov59_021D2F88.c @@ -6,7 +6,6 @@ #include "struct_decls/struct_0202440C_decl.h" #include "struct_decls/struct_02029C68_decl.h" #include "struct_decls/struct_0202A750_decl.h" -#include "struct_decls/struct_0202B4A0_decl.h" #include "struct_decls/struct_0202E8C0_decl.h" #include "overlay059/ov59_021D2A2C.h" @@ -18,9 +17,9 @@ #include "communication_information.h" #include "communication_system.h" #include "heap.h" +#include "record_mixed_rng.h" #include "savedata.h" #include "unk_020298BC.h" -#include "unk_0202B37C.h" #include "unk_0202D05C.h" #include "unk_0202E2CC.h" #include "unk_0202E840.h" @@ -47,13 +46,13 @@ typedef struct { static u32 ov59_021D2F88(SaveData *param0) { - UnkStruct_0202B4A0 *v0 = sub_0202B4A0(param0); + RecordMixedRNG *v0 = SaveData_GetRecordMixedRNG(param0); return ov59_021D2A2C(v0); } static void *ov59_021D2F94(SaveData *param0, int param1, u32 param2) { - UnkStruct_0202B4A0 *v0 = sub_0202B4A0(param0); + RecordMixedRNG *v0 = SaveData_GetRecordMixedRNG(param0); void *v1 = Heap_AllocFromHeapAtEnd(param1, param2); MI_CpuCopyFast(ov59_021D2A30(v0), v1, param2); @@ -63,7 +62,7 @@ static void *ov59_021D2F94(SaveData *param0, int param1, u32 param2) static void ov59_021D2FBC(const UnkStruct_ov59_021D2FBC *param0) { - UnkStruct_0202B4A0 *v0 = sub_0202B4A0(param0->unk_04); + RecordMixedRNG *v0 = SaveData_GetRecordMixedRNG(param0->unk_04); ov59_021D2AC4(param0->unk_08, param0->unk_0C, v0, param0->unk_10); } diff --git a/src/overlay061/ov61_0222BF44.c b/src/overlay061/ov61_0222BF44.c index 868615c329..bdb6629bea 100644 --- a/src/overlay061/ov61_0222BF44.c +++ b/src/overlay061/ov61_0222BF44.c @@ -4,7 +4,6 @@ #include #include -#include "struct_decls/struct_02025CCC_decl.h" #include "struct_decls/struct_0202B370_decl.h" #include "struct_defs/struct_02017498.h" #include "struct_defs/struct_02099F80.h" @@ -31,13 +30,13 @@ #include "strbuf.h" #include "string_list.h" #include "string_template.h" +#include "system_data.h" #include "text.h" #include "unk_0200A784.h" #include "unk_0200F174.h" #include "unk_02017728.h" #include "unk_0201DBEC.h" #include "unk_0201E3D8.h" -#include "unk_02025CB0.h" #include "unk_0202ACE0.h" #include "unk_020366A0.h" #include "unk_02038FFC.h" @@ -801,11 +800,11 @@ static int ov61_0222CBF0(UnkStruct_ov61_0222C664 *param0) { DWCUserData *v0; s32 v1; - UnkStruct_02025CCC *v2; + SystemData *v2; UnkStruct_0202B370 *v3; v3 = sub_0202B370(param0->unk_00->unk_00->unk_04); - v2 = sub_02025CCC(param0->unk_00->unk_00->unk_04); + v2 = SaveData_GetSystemData(param0->unk_00->unk_00->unk_04); v0 = sub_0202AD28(v3); v1 = sub_02025D74(v2); diff --git a/src/overlay062/ov62_0224112C.c b/src/overlay062/ov62_0224112C.c index b9c22087b6..ec7f973ff3 100644 --- a/src/overlay062/ov62_0224112C.c +++ b/src/overlay062/ov62_0224112C.c @@ -15,7 +15,7 @@ #include "overlay062/struct_ov62_02241130.h" #include "inlines.h" -#include "unk_02025CB0.h" +#include "system_data.h" static inline BOOL inline_ov62_022411B8(UnkStruct_0208C06C *param0); @@ -33,7 +33,7 @@ void ov62_02241130(UnkStruct_0208C06C *param0) { UnkStruct_ov62_02241130 v0; - v0.unk_00 = sub_02025D74(sub_02025CCC(param0->unk_830)); + v0.unk_00 = sub_02025D74(SaveData_GetSystemData(param0->unk_830)); v0.unk_04 = 102; v0.unk_08 = param0->unk_830; v0.unk_0C.unk_00 = param0; diff --git a/src/overlay066/ov66_0222DDF0.c b/src/overlay066/ov66_0222DDF0.c index 0e2a15ff4e..b6babeab91 100644 --- a/src/overlay066/ov66_0222DDF0.c +++ b/src/overlay066/ov66_0222DDF0.c @@ -14,7 +14,6 @@ #include "struct_decls/struct_02030EC4_decl.h" #include "struct_decls/struct_0207E060_decl.h" #include "struct_decls/struct_party_decl.h" -#include "struct_defs/struct_02055BA8.h" #include "overlay066/ov66_02231428.h" #include "overlay066/ov66_0223177C.h" @@ -54,12 +53,12 @@ #include "save_player.h" #include "savedata.h" #include "strbuf.h" +#include "system_data.h" #include "trainer_info.h" #include "unk_020041CC.h" #include "unk_02005474.h" #include "unk_02014D38.h" #include "unk_0201D15C.h" -#include "unk_02025CB0.h" #include "unk_0202631C.h" #include "unk_0202C858.h" #include "unk_02030EA4.h" @@ -2312,14 +2311,14 @@ static void ov66_0222F7C8(UnkStruct_ov66_0222F6C4 *param0, SaveData *param1, u32 Party *v1; UnkStruct_0202C878 *v2; PokedexData *v3; - UnkStruct_02055BA8 *v4; + GameTime *v4; { v0 = SaveData_GetTrainerInfo(param1); v1 = Party_GetFromSavedata(param1); v3 = SaveData_Pokedex(param1); v2 = sub_0202C878(param1); - v4 = sub_02025CD8(param1); + v4 = SaveData_GetGameTime(param1); } { @@ -2365,7 +2364,7 @@ static void ov66_0222F7C8(UnkStruct_ov66_0222F6C4 *param0, SaveData *param1, u32 param0->unk_20.unk_41 = 0xff; param0->unk_20.unk_43 = 0; param0->unk_20.unk_42 = GAME_VERSION; - param0->unk_20.unk_44 = v4->unk_24; + param0->unk_20.unk_44 = v4->startTimestamp; { int v9; diff --git a/src/overlay073/ov73_021D0D80.c b/src/overlay073/ov73_021D0D80.c index 5016ea3754..67b7e4d3db 100644 --- a/src/overlay073/ov73_021D0D80.c +++ b/src/overlay073/ov73_021D0D80.c @@ -4,20 +4,19 @@ #include "struct_decls/struct_02015920_decl.h" #include "struct_defs/archived_sprite.h" #include "struct_defs/struct_02015958.h" -#include "struct_defs/struct_0203CC84.h" #include "struct_defs/struct_0208737C.h" #include "struct_defs/struct_02099F80.h" -#include "overlay057/const_ov57_021D0F80.h" - #include "bg_window.h" #include "core_sys.h" #include "font.h" #include "game_options.h" +#include "game_start.h" #include "graphics.h" #include "gx_layers.h" #include "heap.h" #include "list_menu.h" +#include "main.h" #include "message.h" #include "overlay_manager.h" #include "palette.h" @@ -33,7 +32,6 @@ #include "sys_task_manager.h" #include "text.h" #include "trainer_info.h" -#include "unk_02000C88.h" #include "unk_020041CC.h" #include "unk_02005474.h" #include "unk_0200A9DC.h" @@ -46,7 +44,7 @@ #include "constdata/const_020F2DAC.h" -FS_EXTERN_OVERLAY(overlay57); +FS_EXTERN_OVERLAY(game_start); typedef struct { int unk_00; @@ -91,7 +89,7 @@ typedef struct { u16 *unk_BC; } UnkStruct_ov73_021D1058; -void sub_02000EC4(FSOverlayID param0, const OverlayManagerTemplate *param1); +void EnqueueApplication(FSOverlayID param0, const OverlayManagerTemplate *param1); int ov73_021D0D80(OverlayManager *param0, int *param1); int ov73_021D0E20(OverlayManager *param0, int *param1); int ov73_021D0F7C(OverlayManager *param0, int *param1); @@ -137,7 +135,7 @@ int ov73_021D0D80(OverlayManager *param0, int *param1) memset(v0, 0, sizeof(UnkStruct_ov73_021D1058)); v0->unk_00 = v1; - v0->unk_04 = ((UnkStruct_0203CC84 *)OverlayManager_Args(param0))->unk_08; + v0->unk_04 = ((ApplicationArgs *)OverlayManager_Args(param0))->saveData; v0->unk_08 = SaveData_Options(v0->unk_04); v0->unk_0C = 0; v0->unk_10 = 0; @@ -250,7 +248,7 @@ int ov73_021D0F7C(OverlayManager *param0, int *param1) sub_0208716C(v0->unk_74); OverlayManager_FreeData(param0); Heap_Destroy(v1); - sub_02000EC4(FS_OVERLAY_ID(overlay57), &Unk_ov57_021D0F80); + EnqueueApplication(FS_OVERLAY_ID(game_start), &gGameStartNewSaveOverlayTemplate); return 1; } diff --git a/src/overlay073/ov73_021D3250.c b/src/overlay073/ov73_021D3250.c index caa8db7b30..ea7f080d50 100644 --- a/src/overlay073/ov73_021D3250.c +++ b/src/overlay073/ov73_021D3250.c @@ -29,7 +29,7 @@ typedef struct { int unk_24; } UnkStruct_ov73_021D342C; -void sub_02000EC4(FSOverlayID param0, const OverlayManagerTemplate * param1); +void EnqueueApplication(FSOverlayID param0, const OverlayManagerTemplate *param1); int ov73_021D3250(OverlayManager * param0, int * param1); int ov73_021D3280(OverlayManager * param0, int * param1); int ov73_021D3404(OverlayManager * param0, int * param1); diff --git a/src/overlay077/ov77_021D0D80.c b/src/overlay077/ov77_021D0D80.c index 151e52f8ba..6910fe48e7 100644 --- a/src/overlay077/ov77_021D0D80.c +++ b/src/overlay077/ov77_021D0D80.c @@ -16,12 +16,12 @@ #include "graphics.h" #include "gx_layers.h" #include "heap.h" +#include "main.h" #include "message.h" #include "narc.h" #include "overlay_manager.h" #include "strbuf.h" #include "text.h" -#include "unk_02000C88.h" #include "unk_020041CC.h" #include "unk_02005474.h" #include "unk_0200A9DC.h" @@ -115,10 +115,10 @@ typedef struct { extern const OverlayManagerTemplate Unk_020F8A48; extern const OverlayManagerTemplate Unk_020F8AB4; -extern const OverlayManagerTemplate Unk_ov77_021D788C; +extern const OverlayManagerTemplate gOpeningCutsceneOverlayTemplate; static void ov77_021D1D48(BgConfig *param0, int param1); -void sub_02000EC4(FSOverlayID param0, const OverlayManagerTemplate *param1); +void EnqueueApplication(FSOverlayID param0, const OverlayManagerTemplate *param1); static int ov77_021D0D80(OverlayManager *param0, int *param1); static int ov77_021D0E3C(OverlayManager *param0, int *param1); static int ov77_021D10FC(OverlayManager *param0, int *param1); @@ -146,7 +146,7 @@ static void ov77_021D2428(BgConfig *param0, int param1, UnkStruct_ov77_021D1568 static void ov77_021D24C8(UnkStruct_ov77_021D1568 *param0); static void ov77_021D2438(UnkStruct_ov77_021D1568 *param0); -const OverlayManagerTemplate Unk_ov77_021D742C = { +const OverlayManagerTemplate gTitleScreenOverlayTemplate = { ov77_021D0D80, ov77_021D0E3C, ov77_021D10FC, @@ -331,14 +331,14 @@ static int ov77_021D10FC(OverlayManager *param0, int *param1) switch (v2) { default: case 1: - sub_02000EC4(0xffffffff, &Unk_020F8AB4); + EnqueueApplication(0xffffffff, &Unk_020F8AB4); break; case 2: - sub_02000EC4(0xffffffff, &Unk_020F8A48); + EnqueueApplication(0xffffffff, &Unk_020F8A48); break; case 3: sub_02004234(0); - sub_02000EC4(FS_OVERLAY_ID(overlay77), &Unk_ov77_021D788C); + EnqueueApplication(FS_OVERLAY_ID(overlay77), &gOpeningCutsceneOverlayTemplate); break; } diff --git a/src/overlay077/ov77_021D25B0.c b/src/overlay077/ov77_021D25B0.c index 86552f2f19..0367060a46 100644 --- a/src/overlay077/ov77_021D25B0.c +++ b/src/overlay077/ov77_021D25B0.c @@ -21,11 +21,11 @@ #include "graphics.h" #include "gx_layers.h" #include "heap.h" +#include "main.h" #include "narc.h" #include "overlay_manager.h" #include "sys_task.h" #include "sys_task_manager.h" -#include "unk_02000C88.h" #include "unk_020041CC.h" #include "unk_0200A784.h" #include "unk_0200A9DC.h" @@ -136,7 +136,7 @@ typedef struct { u8 unk_2A8; } UnkStruct_ov77_021D2E9C; -void sub_02000EC4(FSOverlayID param0, const OverlayManagerTemplate *param1); +void EnqueueApplication(FSOverlayID param0, const OverlayManagerTemplate *param1); static int ov77_021D2D08(OverlayManager *param0, int *param1); static int ov77_021D2D94(OverlayManager *param0, int *param1); static int ov77_021D2E60(OverlayManager *param0, int *param1); @@ -178,9 +178,9 @@ static void ov77_021D5308(UnkStruct_ov77_021D5308 *param0); static BOOL ov77_021D5390(UnkStruct_ov77_021D5308 *param0, const int param1); static void ov77_021D5478(UnkStruct_ov77_021D2E9C *param0); -extern const OverlayManagerTemplate Unk_ov77_021D742C; +extern const OverlayManagerTemplate gTitleScreenOverlayTemplate; -const OverlayManagerTemplate Unk_ov77_021D788C = { +const OverlayManagerTemplate gOpeningCutsceneOverlayTemplate = { ov77_021D2D08, ov77_021D2D94, ov77_021D2E60, @@ -1017,7 +1017,7 @@ static int ov77_021D2E60(OverlayManager *param0, int *param1) LCRNG_SetSeed(v0->unk_14); OverlayManager_FreeData(param0); Heap_Destroy(76); - sub_02000EC4(FS_OVERLAY_ID(overlay77), &Unk_ov77_021D742C); + EnqueueApplication(FS_OVERLAY_ID(overlay77), &gTitleScreenOverlayTemplate); return 1; } diff --git a/src/overlay083/ov83_0223F7F4.c b/src/overlay083/ov83_0223F7F4.c index 1112f98f23..26a6509536 100644 --- a/src/overlay083/ov83_0223F7F4.c +++ b/src/overlay083/ov83_0223F7F4.c @@ -3,7 +3,6 @@ #include #include -#include "struct_decls/struct_berry_data_decl.h" #include "struct_defs/struct_0202A93C.h" #include "overlay083/struct_ov83_0223DB4C_sub1.h" diff --git a/src/overlay085/ov85_02241440.c b/src/overlay085/ov85_02241440.c index 0bde7a5341..f981e0aa2b 100644 --- a/src/overlay085/ov85_02241440.c +++ b/src/overlay085/ov85_02241440.c @@ -4,7 +4,6 @@ #include #include "struct_decls/struct_0200C440_decl.h" -#include "struct_decls/struct_berry_data_decl.h" #include "struct_defs/struct_020972FC.h" #include "struct_defs/struct_02099F80.h" @@ -223,7 +222,7 @@ int ov85_02241440(OverlayManager *param0, int *param1) memset(v0, 0, sizeof(UnkStruct_ov85_022417E4)); v0->unk_1F8 = OverlayManager_Args(param0); v0->unk_00 = BgConfig_New(36); - v0->unk_1FC = BerryData_LoadDataByNarcMemberIndex(v0->unk_1F8->unk_08, 36); + v0->unk_1FC = BerryData_Load(v0->unk_1F8->unk_08, 36); sub_0208C120(0, 36); @@ -854,7 +853,7 @@ static void ov85_02241F0C(UnkStruct_ov85_022417E4 *param0) NARC *v0; Heap_FreeToHeap(param0->unk_1FC); - param0->unk_1FC = BerryData_LoadDataByNarcMemberIndex(param0->unk_1F8->unk_08, 36); + param0->unk_1FC = BerryData_Load(param0->unk_1F8->unk_08, 36); ov85_02241CD0(param0); v0 = NARC_ctor(NARC_INDEX_GRAPHIC__NTAG_GRA, 36); diff --git a/src/overlay094/ov94_02244950.c b/src/overlay094/ov94_02244950.c index 159992a56b..ba76749334 100644 --- a/src/overlay094/ov94_02244950.c +++ b/src/overlay094/ov94_02244950.c @@ -22,9 +22,9 @@ #include "render_window.h" #include "strbuf.h" #include "string_template.h" +#include "system_data.h" #include "text.h" #include "unk_0200F174.h" -#include "unk_02025CB0.h" #include "unk_0202ACE0.h" #include "unk_02030CE8.h" #include "unk_020366A0.h" diff --git a/src/overlay096/ov96_0223BCE0.c b/src/overlay096/ov96_0223BCE0.c index 0e64533a32..e25408f7ff 100644 --- a/src/overlay096/ov96_0223BCE0.c +++ b/src/overlay096/ov96_0223BCE0.c @@ -30,10 +30,10 @@ #include "savedata.h" #include "strbuf.h" #include "string_template.h" +#include "system_data.h" #include "text.h" #include "unk_02005474.h" #include "unk_0200F174.h" -#include "unk_02025CB0.h" #include "unk_0202D05C.h" #include "unk_02030CE8.h" #include "unk_020366A0.h" diff --git a/src/overlay097/ov97_0222AE60.c b/src/overlay097/ov97_0222AE60.c index cb19ca63f4..a11125d4e0 100644 --- a/src/overlay097/ov97_0222AE60.c +++ b/src/overlay097/ov97_0222AE60.c @@ -3,11 +3,8 @@ #include "struct_decls/pokedexdata_decl.h" #include "struct_decls/struct_0202442C_decl.h" -#include "struct_defs/struct_0203CC84.h" #include "struct_defs/struct_02099F80.h" -#include "overlay057/const_ov57_021D0F70.h" -#include "overlay057/const_ov57_021D0F90.h" #include "overlay077/const_ov77_021D742C.h" #include "overlay097/const_ov97_0223D674.h" #include "overlay097/ov97_02235D18.h" @@ -20,9 +17,11 @@ #include "cell_actor.h" #include "core_sys.h" #include "font.h" +#include "game_start.h" #include "graphics.h" #include "gx_layers.h" #include "heap.h" +#include "main.h" #include "message.h" #include "message_util.h" #include "overlay_manager.h" @@ -32,9 +31,9 @@ #include "savedata.h" #include "strbuf.h" #include "string_template.h" +#include "system_data.h" #include "text.h" #include "trainer_info.h" -#include "unk_02000C88.h" #include "unk_020041CC.h" #include "unk_02005474.h" #include "unk_0200A784.h" @@ -42,13 +41,12 @@ #include "unk_02017728.h" #include "unk_0201DBEC.h" #include "unk_02024358.h" -#include "unk_02025CB0.h" #include "unk_0202631C.h" #include "unk_0202DAB4.h" #include "unk_020366A0.h" #include "unk_0209A74C.h" -FS_EXTERN_OVERLAY(overlay57); +FS_EXTERN_OVERLAY(game_start); FS_EXTERN_OVERLAY(overlay77); FS_EXTERN_OVERLAY(overlay97); FS_EXTERN_OVERLAY(overlay98); @@ -658,7 +656,7 @@ static BOOL ov97_0222B7DC(void *param0, int param1, UnkStruct_ov97_02237808 *par v0->unk_34 = 1; } - if (sub_02025D64(sub_02025CCC(v0->unk_04)) == 1) { + if (sub_02025D64(SaveData_GetSystemData(v0->unk_04)) == 1) { v0->unk_34 = 1; } @@ -984,7 +982,7 @@ static int ov97_0222BD70(OverlayManager *param0, int *param1) sub_0200F344(0, 0x0); sub_0200F344(1, 0x0); - v0->unk_04 = ((UnkStruct_0203CC84 *)OverlayManager_Args(param0))->unk_08; + v0->unk_04 = ((ApplicationArgs *)OverlayManager_Args(param0))->saveData; v0->unk_14 = SaveData_MysteryGift(v0->unk_04); v0->unk_11C = FX32_ONE * 0; v0->unk_120 = FX32_ONE * 0; @@ -1165,33 +1163,33 @@ static void ov97_0222C094(UnkStruct_0222AE60 *param0) { switch (param0->unk_58) { case 1: - sub_02000EC4(FS_OVERLAY_ID(overlay57), &Unk_ov57_021D0F70); + EnqueueApplication(FS_OVERLAY_ID(game_start), &gGameStartLoadSaveOverlayTemplate); break; case 2: - sub_02000EC4(FS_OVERLAY_ID(overlay57), &Unk_ov57_021D0F90); + EnqueueApplication(FS_OVERLAY_ID(game_start), &gGameStartRowanIntroOverlayTemplate); break; case 3: - sub_02000EC4(FS_OVERLAY_ID(overlay97), &Unk_ov97_0223D71C); + EnqueueApplication(FS_OVERLAY_ID(overlay97), &Unk_ov97_0223D71C); break; case 5: - sub_02000EC4(FS_OVERLAY_ID(overlay97), &Unk_ov97_0223D864); + EnqueueApplication(FS_OVERLAY_ID(overlay97), &Unk_ov97_0223D864); break; case 4: - sub_02000EC4(FS_OVERLAY_ID(overlay97), &Unk_ov97_0223D6BC); + EnqueueApplication(FS_OVERLAY_ID(overlay97), &Unk_ov97_0223D6BC); break; case 6: sub_020243E0("data/eoo.dat"); break; case 7: sub_0200569C(); - sub_02000EC4(0xffffffff, &Unk_020F6DF0); + EnqueueApplication(0xffffffff, &Unk_020F6DF0); break; case 8: sub_0200569C(); - sub_02000EC4(FS_OVERLAY_ID(overlay98), &Unk_ov98_02249BAC); + EnqueueApplication(FS_OVERLAY_ID(overlay98), &Unk_ov98_02249BAC); break; case 0: - sub_02000EC4(FS_OVERLAY_ID(overlay77), &Unk_ov77_021D742C); + EnqueueApplication(FS_OVERLAY_ID(overlay77), &gTitleScreenOverlayTemplate); break; } } diff --git a/src/overlay097/ov97_0222C174.c b/src/overlay097/ov97_0222C174.c index 8ca64811e2..2e7f12dd03 100644 --- a/src/overlay097/ov97_0222C174.c +++ b/src/overlay097/ov97_0222C174.c @@ -5,7 +5,6 @@ #include "struct_decls/struct_0202442C_decl.h" #include "struct_defs/struct_0202DBAC.h" #include "struct_defs/struct_0202DF40.h" -#include "struct_defs/struct_0203CC84.h" #include "struct_defs/struct_02099F80.h" #include "overlay077/const_ov77_021D742C.h" @@ -26,6 +25,7 @@ #include "graphics.h" #include "gx_layers.h" #include "heap.h" +#include "main.h" #include "message.h" #include "message_util.h" #include "overlay_manager.h" @@ -37,7 +37,6 @@ #include "string_template.h" #include "text.h" #include "trainer_info.h" -#include "unk_02000C88.h" #include "unk_020041CC.h" #include "unk_02005474.h" #include "unk_0202631C.h" @@ -680,7 +679,7 @@ static int ov97_0222C6F8(OverlayManager *param0, int *param1) v0->unk_00 = 85; v0->unk_04 = BgConfig_New(v0->unk_00); - v0->unk_08 = ((UnkStruct_0203CC84 *)OverlayManager_Args(param0))->unk_08; + v0->unk_08 = ((ApplicationArgs *)OverlayManager_Args(param0))->saveData; v0->unk_10 = SaveData_GetTrainerInfo(v0->unk_08); v0->unk_0C = SaveData_Pokedex(v0->unk_08); v0->unk_14 = SaveData_Options(v0->unk_08); @@ -784,7 +783,7 @@ static int ov97_0222C78C(OverlayManager *param0, int *param1) static int ov97_0222C948(OverlayManager *param0, int *param1) { Heap_Destroy(91); - sub_02000EC4(FS_OVERLAY_ID(overlay77), &Unk_ov77_021D742C); + EnqueueApplication(FS_OVERLAY_ID(overlay77), &gTitleScreenOverlayTemplate); OverlayManager_FreeData(param0); Heap_Destroy(85); diff --git a/src/overlay097/ov97_0222D04C.c b/src/overlay097/ov97_0222D04C.c index 3ee9406f80..f469ef3298 100644 --- a/src/overlay097/ov97_0222D04C.c +++ b/src/overlay097/ov97_0222D04C.c @@ -3,8 +3,6 @@ #include #include -#include "struct_defs/struct_0203CC84.h" - #include "overlay097/ov97_0222D2F8.h" #include "overlay097/ov97_0222D30C.h" #include "overlay097/struct_ov97_0222D04C.h" @@ -14,6 +12,7 @@ #include "communication_information.h" #include "communication_system.h" #include "heap.h" +#include "main.h" #include "overlay_manager.h" #include "savedata.h" #include "sys_task.h" @@ -186,7 +185,7 @@ void ov97_0222D200(UnkStruct_ov97_0222D04C *param0, int param1) return; } - v0 = ((UnkStruct_0203CC84 *)OverlayManager_Args(ov97_022301A4()))->unk_08; + v0 = ((ApplicationArgs *)OverlayManager_Args(ov97_022301A4()))->saveData; sub_02036C1C(v0, param1); ov97_0222D04C(param0); diff --git a/src/overlay097/ov97_0222D30C.c b/src/overlay097/ov97_0222D30C.c index 1b473351c8..8490d6da2e 100644 --- a/src/overlay097/ov97_0222D30C.c +++ b/src/overlay097/ov97_0222D30C.c @@ -4,9 +4,7 @@ #include #include "struct_decls/struct_0202442C_decl.h" -#include "struct_decls/struct_02025CCC_decl.h" #include "struct_defs/struct_0202DF40.h" -#include "struct_defs/struct_0203CC84.h" #include "overlay077/const_ov77_021D742C.h" #include "overlay097/ov97_0222D04C.h" @@ -32,6 +30,7 @@ #include "gx_layers.h" #include "heap.h" #include "list_menu.h" +#include "main.h" #include "message.h" #include "message_util.h" #include "overlay_manager.h" @@ -46,8 +45,8 @@ #include "string_template.h" #include "sys_task.h" #include "sys_task_manager.h" +#include "system_data.h" #include "text.h" -#include "unk_02000C88.h" #include "unk_020041CC.h" #include "unk_02005474.h" #include "unk_020093B4.h" @@ -429,7 +428,7 @@ static void ov97_0222D658(OverlayManager *param0) UnkStruct_ov97_0222D04C *v2 = OverlayManager_Data(param0); UnkStruct_ov97_0222D250 *v3 = &v2->unk_8C.unk_00; UnkUnion_ov97_0222D2B0 *v4 = &v2->unk_8C.unk_50; - SaveData *v5 = ((UnkStruct_0203CC84 *)OverlayManager_Args(param0))->unk_08; + SaveData *v5 = ((ApplicationArgs *)OverlayManager_Args(param0))->saveData; MysteryGift *v6; if (v3->unk_4E_2 == 0) { @@ -664,7 +663,7 @@ static int ov97_0222DA64(OverlayManager *param0) static int ov97_0222DA84(OverlayManager *param0) { Window *v0; - UnkStruct_02025CCC *v1; + SystemData *v1; UnkStruct_ov97_0222D04C *v2 = OverlayManager_Data(param0); MysteryGift *v3 = SaveData_MysteryGift(v2->unk_04); @@ -1102,7 +1101,7 @@ static int ov97_0222E2DC(OverlayManager *param0, int *param1) } v0->unk_62C = 29; - v0->unk_04 = ((UnkStruct_0203CC84 *)OverlayManager_Args(param0))->unk_08; + v0->unk_04 = ((ApplicationArgs *)OverlayManager_Args(param0))->saveData; v0->unk_08 = SaveData_Options(v0->unk_04); v0->unk_68 = 0xff; @@ -2436,9 +2435,9 @@ static int ov97_022301BC(OverlayManager *param0, int *param1) UnkStruct_ov97_0222D04C *v0 = OverlayManager_Data(param0); if (v0->unk_440 == 0) { - sub_02000EC4(FS_OVERLAY_ID(overlay77), &Unk_ov77_021D742C); + EnqueueApplication(FS_OVERLAY_ID(overlay77), &gTitleScreenOverlayTemplate); } else if (v0->unk_440 == 1) { - sub_02000EC4(FS_OVERLAY_ID(overlay97), &Unk_ov97_0223D7AC); + EnqueueApplication(FS_OVERLAY_ID(overlay97), &Unk_ov97_0223D7AC); } Heap_Destroy(91); diff --git a/src/overlay097/ov97_02230410.c b/src/overlay097/ov97_02230410.c index bcc8f134fc..669e1db27a 100644 --- a/src/overlay097/ov97_02230410.c +++ b/src/overlay097/ov97_02230410.c @@ -4,7 +4,6 @@ #include "struct_decls/struct_0202442C_decl.h" #include "struct_defs/struct_0200C738.h" #include "struct_defs/struct_0202DBAC.h" -#include "struct_defs/struct_0203CC84.h" #include "overlay097/ov97_0222D04C.h" #include "overlay097/ov97_02232054.h" @@ -26,6 +25,7 @@ #include "gx_layers.h" #include "heap.h" #include "list_menu.h" +#include "main.h" #include "message.h" #include "message_util.h" #include "overlay_manager.h" @@ -41,7 +41,6 @@ #include "sys_task_manager.h" #include "text.h" #include "trainer_info.h" -#include "unk_02000C88.h" #include "unk_02005474.h" #include "unk_0200F174.h" #include "unk_0202DAB4.h" @@ -1033,7 +1032,7 @@ static int ov97_0223161C(OverlayManager *param0, int *param1) switch (*param1) { case 0: - v4->unk_2C04 = ((UnkStruct_0203CC84 *)OverlayManager_Args(param0))->unk_08; + v4->unk_2C04 = ((ApplicationArgs *)OverlayManager_Args(param0))->saveData; v4->unk_2C00 = SaveData_MysteryGift(v4->unk_2C04); v4->unk_2C08 = SaveData_Options(v4->unk_2C04); v4->unk_2C0C = Options_Frame(v4->unk_2C08); @@ -1462,7 +1461,7 @@ static int ov97_02231F38(OverlayManager *param0, int *param1) Bg_FreeTilemapBuffer(v1->unk_2A5C, 2); Bg_FreeTilemapBuffer(v1->unk_2A5C, 3); Heap_FreeToHeap(v1->unk_2A5C); - sub_02000EC4(FS_OVERLAY_ID(overlay97), &Unk_ov97_0223D71C); + EnqueueApplication(FS_OVERLAY_ID(overlay97), &Unk_ov97_0223D71C); Heap_Destroy(91); OverlayManager_FreeData(param0); Heap_Destroy(87); diff --git a/src/overlay097/ov97_02233B18.c b/src/overlay097/ov97_02233B18.c index de938f5d8f..1e6114eab4 100644 --- a/src/overlay097/ov97_02233B18.c +++ b/src/overlay097/ov97_02233B18.c @@ -8,7 +8,6 @@ #include "struct_decls/struct_02024440_decl.h" #include "struct_defs/struct_0200C738.h" #include "struct_defs/struct_02015958.h" -#include "struct_defs/struct_0203CC84.h" #include "struct_defs/struct_02099F80.h" #include "overlay022/struct_ov22_022559F8.h" @@ -31,6 +30,7 @@ #include "gx_layers.h" #include "heap.h" #include "item.h" +#include "main.h" #include "message.h" #include "narc.h" #include "overlay_manager.h" @@ -46,7 +46,6 @@ #include "text.h" #include "touch_screen.h" #include "trainer_info.h" -#include "unk_02000C88.h" #include "unk_020041CC.h" #include "unk_02005474.h" #include "unk_020093B4.h" @@ -1780,7 +1779,7 @@ static int ov97_02235624(OverlayManager *param0, int *param1) sub_0200F344(0, 0x0); sub_0200F344(1, 0x0); - v0->unk_10 = ((UnkStruct_0203CC84 *)OverlayManager_Args(param0))->unk_08; + v0->unk_10 = ((ApplicationArgs *)OverlayManager_Args(param0))->saveData; v0->unk_14 = SaveData_GetTrainerInfo(v0->unk_10); v0->unk_18 = SaveData_Options(v0->unk_10); v0->unk_1C = Options_Frame(v0->unk_18); @@ -2139,7 +2138,7 @@ static int ov97_02235CC8(OverlayManager *param0, int *param1) Strbuf_Free(v0->unk_12668); Strbuf_Free(v0->unk_1266C); Heap_FreeToHeap(v0->unk_20); - sub_02000EC4(FS_OVERLAY_ID(overlay77), &Unk_ov77_021D742C); + EnqueueApplication(FS_OVERLAY_ID(overlay77), &gTitleScreenOverlayTemplate); OverlayManager_FreeData(param0); Heap_Destroy(78); diff --git a/src/overlay098/ov98_02246C20.c b/src/overlay098/ov98_02246C20.c index b234e4acf2..0f891c1d44 100644 --- a/src/overlay098/ov98_02246C20.c +++ b/src/overlay098/ov98_02246C20.c @@ -4,7 +4,6 @@ #include #include -#include "struct_defs/struct_0203CC84.h" #include "struct_defs/struct_02089438.h" #include "overlay065/ov65_0222DCE0.h" @@ -18,10 +17,10 @@ #include "error_handling.h" #include "game_overlay.h" #include "heap.h" +#include "main.h" #include "overlay_manager.h" #include "save_player.h" #include "strbuf.h" -#include "unk_02000C88.h" #include "unk_020041CC.h" #include "unk_02017728.h" #include "unk_02030CE8.h" @@ -104,7 +103,7 @@ int ov98_02246C20(OverlayManager *param0, int *param1) v0 = OverlayManager_NewData(param0, sizeof(UnkStruct_ov98_02246E88), 108); MI_CpuClear8(v0, sizeof(UnkStruct_ov98_02246E88)); - v0->unk_04 = ((UnkStruct_0203CC84 *)OverlayManager_Args(param0))->unk_08; + v0->unk_04 = ((ApplicationArgs *)OverlayManager_Args(param0))->saveData; v0->unk_08 = SaveData_Options(v0->unk_04); v0->unk_114 = Strbuf_Init(100, 108); v0->unk_118 = Strbuf_Init(100, 108); @@ -181,7 +180,7 @@ int ov98_02246DC0(OverlayManager *param0, int *param1) OverlayManager_FreeData(param0); Heap_Destroy(108); Heap_Destroy(91); - sub_02000EC4(FS_OVERLAY_ID(overlay77), &Unk_ov77_021D742C); + EnqueueApplication(FS_OVERLAY_ID(overlay77), &gTitleScreenOverlayTemplate); return 1; } diff --git a/src/overlay098/ov98_022471C8.c b/src/overlay098/ov98_022471C8.c index e32c908299..0733b1bbbf 100644 --- a/src/overlay098/ov98_022471C8.c +++ b/src/overlay098/ov98_022471C8.c @@ -4,7 +4,6 @@ #include #include -#include "struct_decls/struct_02025CCC_decl.h" #include "struct_decls/struct_0202B370_decl.h" #include "struct_defs/struct_02099F80.h" @@ -36,6 +35,7 @@ #include "strbuf.h" #include "string_list.h" #include "string_template.h" +#include "system_data.h" #include "text.h" #include "unk_02005474.h" #include "unk_0200A784.h" @@ -43,7 +43,6 @@ #include "unk_02017728.h" #include "unk_0201DBEC.h" #include "unk_0201E3D8.h" -#include "unk_02025CB0.h" #include "unk_0202ACE0.h" #include "unk_02030CE8.h" #include "unk_020366A0.h" @@ -1726,11 +1725,11 @@ static int ov98_02248BFC (UnkStruct_ov98_02247704 * param0) { DWCUserData * v0; s32 v1; - UnkStruct_02025CCC * v2; + SystemData *v2; UnkStruct_0202B370 * v3; v3 = sub_0202B370(param0->unk_00->unk_04); - v2 = sub_02025CCC(param0->unk_00->unk_04); + v2 = SaveData_GetSystemData(param0->unk_00->unk_04); v0 = sub_0202AD28(v3); v1 = sub_02025D74(v2); diff --git a/src/overlay102/ov102_021D0D80.c b/src/overlay102/ov102_021D0D80.c index d08703eb10..e096e311e1 100644 --- a/src/overlay102/ov102_021D0D80.c +++ b/src/overlay102/ov102_021D0D80.c @@ -37,7 +37,7 @@ typedef struct { int unk_40; } UnkStruct_ov102_021D0F8C; -void sub_02000EC4(FSOverlayID param0, const OverlayManagerTemplate *param1); +void EnqueueApplication(FSOverlayID param0, const OverlayManagerTemplate *param1); int ov102_021D0D80(OverlayManager *param0, int *param1); int ov102_021D0E2C(OverlayManager *param0, int *param1); int ov102_021D0F50(OverlayManager *param0, int *param1); diff --git a/src/overlay118/ov118_021D0D80.c b/src/overlay118/ov118_021D0D80.c index cbb9c90e00..de8e9c051a 100644 --- a/src/overlay118/ov118_021D0D80.c +++ b/src/overlay118/ov118_021D0D80.c @@ -93,7 +93,7 @@ int ov118_021D0DBC(GameWindowLayout *param0) break; } - sub_0202736C(SaveData_Pokedex(FieldSystem_SaveData(param0->unk_5A4->unk_1C)), v1); + sub_0202736C(SaveData_Pokedex(FieldSystem_GetSaveData(param0->unk_5A4->unk_1C)), v1); } v0->unk_00++; break; diff --git a/src/record_mixed_rng.c b/src/record_mixed_rng.c new file mode 100644 index 0000000000..254c4183e0 --- /dev/null +++ b/src/record_mixed_rng.c @@ -0,0 +1,169 @@ +#include "record_mixed_rng.h" + +#include "constants/charcode.h" +#include "constants/savedata/save_table.h" +#include "constants/string.h" + +#include "charcode.h" +#include "charcode_util.h" +#include "savedata.h" +#include "strbuf.h" +#include "unk_0201D15C.h" + +RecordMixedRNG *sRNGCollection; + +int RecordMixedRNG_SaveSize() +{ + return sizeof(RecordMixedRNG) * RECORD_MIXED_RNG_MAX; +} + +void RecordMixedRNG_CopyEntry(RecordMixedRNG *rngCollection, enum RecordMixedRNGEntry srcEntry, enum RecordMixedRNGEntry destEntry) +{ + rngCollection[destEntry] = rngCollection[srcEntry]; +} + +void RecordMixedRNG_Init(RecordMixedRNG *rngCollection) +{ + MI_CpuClearFast(rngCollection, sizeof(RecordMixedRNG) * RECORD_MIXED_RNG_MAX); + + for (int entry = 0; entry < RECORD_MIXED_RNG_MAX; entry++) { + rngCollection[entry].groupName[0] = CHAR_EOS; + rngCollection[entry].playerName[0] = CHAR_EOS; + } + + sRNGCollection = rngCollection; +} + +void RecordMixedRNG_AdvanceEntries(RecordMixedRNG *rngCollection, u32 stepCount) +{ + for (u32 i = 0; i < RECORD_MIXED_RNG_MAX; i++) { + for (u32 j = 0; j < stepCount; j++) { + rngCollection[i].rand = ARNG_Next(rngCollection[i].rand); + } + } +} + +u32 RecordMixedRNG_GetEntrySeed(RecordMixedRNG *rngCollection, enum RecordMixedRNGEntry entry) +{ + return rngCollection[entry].seed; +} + +void RecordMixedRNG_SetEntrySeed(RecordMixedRNG *rngCollection, enum RecordMixedRNGEntry entry, u32 seed) +{ + rngCollection[entry].seed = seed; + rngCollection[entry].rand = ARNG_Next(seed); +} + +u32 RecordMixedRNG_GetRand(RecordMixedRNG *rngCollection) +{ + return rngCollection[RECORD_MIXED_RNG_PLAYER_OVERRIDE].rand; +} + +const charcode_t *RecordMixedRNG_GetEntryName(const RecordMixedRNG *rngCollection, enum RecordMixedRNGEntry entry, enum RecordMixedRNGName nameChoice) +{ + if (nameChoice == RECORD_MIXED_RNG_GROUP_NAME) { + return rngCollection[entry].groupName; + } + + return rngCollection[entry].playerName; +} + +void RecordMixedRNG_GetEntryNameAsStrbuf(RecordMixedRNG *rngCollection, enum RecordMixedRNGEntry entry, enum RecordMixedRNGName nameChoice, Strbuf *outStrbuf) +{ + charcode_t *name; + if (nameChoice == RECORD_MIXED_RNG_GROUP_NAME) { + name = rngCollection[entry].groupName; + Strbuf_ToChars(outStrbuf, name, UNION_GROUP_NAME_LEN + 1); + } else { + name = rngCollection[entry].playerName; + Strbuf_ToChars(outStrbuf, name, TRAINER_NAME_LEN + 1); + } +} + +void RecordMixedRNG_SetEntryGender(RecordMixedRNG *rngCollection, enum RecordMixedRNGEntry entry, int gender) +{ + rngCollection[entry].gender = gender; +} + +int RecordMixedRNG_GetEntryGender(const RecordMixedRNG *rngCollection, enum RecordMixedRNGEntry entry) +{ + return rngCollection[entry].gender; +} + +int RecordMixedRNG_GetEntryCountryCode(const RecordMixedRNG *rngCollection, enum RecordMixedRNGEntry entry) +{ + return rngCollection[entry].countryCode; +} + +void RecordMixedRNG_SetEntryCountryCode(RecordMixedRNG *rngCollection, enum RecordMixedRNGEntry entry, int countryCode) +{ + rngCollection[entry].countryCode = countryCode; +} + +RecordMixedRNG *SaveData_GetRecordMixedRNG(SaveData *saveData) +{ + return SaveData_SaveTable(saveData, SAVE_TABLE_ENTRY_RECORD_MIXED_RNG); +} + +BOOL RecordMixedRNG_IsEntryValid(const RecordMixedRNG *rngCollection, enum RecordMixedRNGEntry entry) +{ + return !RecordMixedRNG_IsEntryEmpty(&rngCollection[entry]); +} + +BOOL RecordMixedRNG_IsEntryEqualToOverride(const RecordMixedRNG *rngCollection, enum RecordMixedRNGEntry entry) +{ + return RecordMixedRNG_AreEntriesEqual(&rngCollection[RECORD_MIXED_RNG_PLAYER_OVERRIDE], &rngCollection[entry]); +} + +BOOL RecordMixedRNG_DoesCollectionContainGroup(const RecordMixedRNG *rngCollection, const charcode_t *groupName) +{ + if (*groupName == CHAR_EOS) { + return FALSE; + } + + for (int entry = 0; entry < RECORD_MIXED_RNG_MAX; entry++) { + if (!CharCode_CompareNumChars(groupName, rngCollection[entry].groupName, UNION_GROUP_NAME_LEN + 1)) { + return TRUE; + } + } + + return FALSE; +} + +BOOL RecordMixedRNG_IsEntryEmpty(const RecordMixedRNG *entry) +{ + if (entry->groupName[0] == CHAR_EOS) { + return TRUE; + } + + if (entry->playerName[0] == CHAR_EOS) { + return TRUE; + } + + return FALSE; +} + +BOOL RecordMixedRNG_AreEntriesEqual(const RecordMixedRNG *entry1, const RecordMixedRNG *entry2) +{ + if (CharCode_CompareNumChars(entry1->playerName, entry2->playerName, TRAINER_NAME_LEN + 1)) { + return FALSE; + } + + if (CharCode_CompareNumChars(entry1->groupName, entry2->groupName, UNION_GROUP_NAME_LEN + 1)) { + return FALSE; + } + + if (entry1->gender != entry2->gender) { + return FALSE; + } + + if (entry1->countryCode != entry2->countryCode) { + return FALSE; + } + + if (entry1->seed != entry2->seed) { + return FALSE; + } + + return TRUE; +} diff --git a/src/savedata/save_table.c b/src/savedata/save_table.c index fe53aaf5c0..654f702180 100644 --- a/src/savedata/save_table.c +++ b/src/savedata/save_table.c @@ -10,11 +10,12 @@ #include "party.h" #include "poffin.h" #include "poketch_data.h" +#include "record_mixed_rng.h" #include "save_player.h" #include "savedata.h" #include "savedata_misc.h" +#include "system_data.h" #include "unk_02014D38.h" -#include "unk_02025CB0.h" #include "unk_0202602C.h" #include "unk_020261E4.h" #include "unk_0202631C.h" @@ -23,7 +24,6 @@ #include "unk_0202854C.h" #include "unk_020298BC.h" #include "unk_0202ACE0.h" -#include "unk_0202B37C.h" #include "unk_0202C7FC.h" #include "unk_0202C858.h" #include "unk_0202C9F4.h" @@ -46,7 +46,7 @@ #include "vars_flags.h" const SaveTableEntry gSaveTable[] = { - { SAVE_TABLE_ENTRY_SYSTEM, SAVE_BLOCK_ID_NORMAL, (SaveEntrySizeFunc)SystemData_SaveSize, (SaveEntryInitFunc)SystemData_Init }, + { SAVE_TABLE_ENTRY_SYSTEM, SAVE_BLOCK_ID_NORMAL, (SaveEntrySizeFunc)SystemData_SaveSize, (SaveEntryInitFunc)SystemData_Clear }, { SAVE_TABLE_ENTRY_PLAYER, SAVE_BLOCK_ID_NORMAL, (SaveEntrySizeFunc)Player_SaveSize, (SaveEntryInitFunc)Player_Init }, { SAVE_TABLE_ENTRY_PARTY, SAVE_BLOCK_ID_NORMAL, (SaveEntrySizeFunc)Party_SaveSize, (SaveEntryInitFunc)Party_Init }, { SAVE_TABLE_ENTRY_BAG, SAVE_BLOCK_ID_NORMAL, (SaveEntrySizeFunc)Bag_SaveSize, (SaveEntryInitFunc)Bag_Init }, @@ -63,7 +63,7 @@ const SaveTableEntry gSaveTable[] = { { SAVE_TABLE_ENTRY_IMAGE_CLIPS, SAVE_BLOCK_ID_NORMAL, (SaveEntrySizeFunc)ImageClip_SaveSize, (SaveEntryInitFunc)ImageClip_Init }, { SAVE_TABLE_ENTRY_MAIL, SAVE_BLOCK_ID_NORMAL, (SaveEntrySizeFunc)Mail_SaveSize, (SaveEntryInitFunc)Mail_Init }, { SAVE_TABLE_ENTRY_POFFINS, SAVE_BLOCK_ID_NORMAL, (SaveEntrySizeFunc)Poffin_SaveSize, (SaveEntryInitFunc)Poffin_Init }, - { SAVE_TABLE_ENTRY_RANDOM_GROUP, SAVE_BLOCK_ID_NORMAL, (SaveEntrySizeFunc)RandomGroup_SaveSize, (SaveEntryInitFunc)RandomGroup_Init }, + { SAVE_TABLE_ENTRY_RECORD_MIXED_RNG, SAVE_BLOCK_ID_NORMAL, (SaveEntrySizeFunc)RecordMixedRNG_SaveSize, (SaveEntryInitFunc)RecordMixedRNG_Init }, { SAVE_TABLE_ENTRY_JOURNAL, SAVE_BLOCK_ID_NORMAL, (SaveEntrySizeFunc)Journal_SaveSize, (SaveEntryInitFunc)Journal_Init10 }, { SAVE_TABLE_ENTRY_TRAINER_CARD, SAVE_BLOCK_ID_NORMAL, (SaveEntrySizeFunc)TrainerCard_SaveSize, (SaveEntryInitFunc)TrainerCard_Init }, { SAVE_TABLE_ENTRY_GAME_RECORDS, SAVE_BLOCK_ID_NORMAL, (SaveEntrySizeFunc)GameRecords_SaveSize, (SaveEntryInitFunc)GameRecords_Init }, diff --git a/src/savedata_misc.c b/src/savedata_misc.c index 78b4aff04e..8aabdbb90d 100644 --- a/src/savedata_misc.c +++ b/src/savedata_misc.c @@ -7,9 +7,9 @@ #include "struct_defs/sentence.h" +#include "berry_patches.h" #include "unk_02014A84.h" #include "unk_02014D38.h" -#include "unk_02027B70.h" #include "unk_02027F50.h" int MiscSaveBlock_SaveSize(void) @@ -21,7 +21,7 @@ void MiscSaveBlock_Init(MiscSaveBlock *miscSave) { MI_CpuClearFast(miscSave, sizeof(MiscSaveBlock)); - sub_02027B70(miscSave->unk_00); + BerryPatches_Clear(miscSave->berryPatches); sub_02027F50(&miscSave->unk_680); MI_CpuFill16(miscSave->rivalName, CHAR_EOS, TRAINER_NAME_LEN + 1); @@ -49,10 +49,10 @@ const MiscSaveBlock *SaveData_MiscSaveBlockConst(const SaveData *saveData) return SaveData_SaveTableConst(saveData, SAVE_TABLE_ENTRY_MISC); } -UnkStruct_02027854 *sub_02027854(SaveData *saveData) +BerryPatch *MiscSaveBlock_GetBerryPatches(SaveData *saveData) { MiscSaveBlock *miscSave = SaveData_SaveTable(saveData, SAVE_TABLE_ENTRY_MISC); - return miscSave->unk_00; + return miscSave->berryPatches; } UnkStruct_02027860 *sub_02027860(SaveData *saveData) diff --git a/src/scrcmd.c b/src/scrcmd.c index b84f4d4dee..30692d735a 100644 --- a/src/scrcmd.c +++ b/src/scrcmd.c @@ -11,7 +11,6 @@ #include "struct_decls/pokedexdata_decl.h" #include "struct_decls/struct_02014EC4_decl.h" #include "struct_decls/struct_0202440C_decl.h" -#include "struct_decls/struct_02025CCC_decl.h" #include "struct_decls/struct_02026218_decl.h" #include "struct_decls/struct_02026310_decl.h" #include "struct_decls/struct_02028430_decl.h" @@ -39,7 +38,6 @@ #include "struct_defs/struct_0203E608.h" #include "struct_defs/struct_02041DC8.h" #include "struct_defs/struct_02042434.h" -#include "struct_defs/struct_02049FA8.h" #include "struct_defs/struct_0204AFC4.h" #include "struct_defs/struct_02098C44.h" @@ -106,6 +104,7 @@ #include "heap.h" #include "inlines.h" #include "journal.h" +#include "location.h" #include "map_header_data.h" #include "map_object.h" #include "map_object_move.h" @@ -128,6 +127,7 @@ #include "string_template.h" #include "sys_task.h" #include "sys_task_manager.h" +#include "system_data.h" #include "text.h" #include "trainer_data.h" #include "trainer_info.h" @@ -135,7 +135,6 @@ #include "unk_0200F174.h" #include "unk_02014D38.h" #include "unk_0201D15C.h" -#include "unk_02025CB0.h" #include "unk_020261E4.h" #include "unk_0202631C.h" #include "unk_02028124.h" @@ -4945,10 +4944,10 @@ static BOOL ScrCmd_11B(ScriptContext *ctx) Location location; location.mapId = ScriptContext_GetVar(ctx); - location.unk_04 = ScriptContext_GetVar(ctx); + location.warpId = ScriptContext_GetVar(ctx); location.x = ScriptContext_GetVar(ctx); location.z = ScriptContext_GetVar(ctx); - location.unk_10 = ScriptContext_GetVar(ctx); + location.faceDirection = ScriptContext_GetVar(ctx); FieldOverworldState_SetSpecialLocation(SaveData_GetFieldOverworldState(ctx->fieldSystem->saveData), &location); return 0; @@ -5287,8 +5286,8 @@ static BOOL ScrCmd_13C(ScriptContext *ctx) MapObject **v0 = FieldSystem_GetScriptMemberPtr(ctx->fieldSystem, SCRIPT_MANAGER_TARGET_OBJECT); StringTemplate **v1 = FieldSystem_GetScriptMemberPtr(ctx->fieldSystem, SCRIPT_MANAGER_STR_TEMPLATE); u16 v2 = ScriptContext_ReadHalfWord(ctx); - TrainerInfo *v3 = SaveData_GetTrainerInfo(FieldSystem_SaveData(ctx->fieldSystem)); - UnkStruct_02014EC4 *v4 = sub_02014EC4(FieldSystem_SaveData(ctx->fieldSystem)); + TrainerInfo *v3 = SaveData_GetTrainerInfo(FieldSystem_GetSaveData(ctx->fieldSystem)); + UnkStruct_02014EC4 *v4 = sub_02014EC4(FieldSystem_GetSaveData(ctx->fieldSystem)); u16 v5; if (v2 == 0) { @@ -5497,7 +5496,7 @@ static BOOL ScrCmd_153(ScriptContext *ctx) static BOOL ScrCmd_154(ScriptContext *ctx) { - TrainerInfo *v0 = SaveData_GetTrainerInfo(FieldSystem_SaveData(ctx->fieldSystem)); + TrainerInfo *v0 = SaveData_GetTrainerInfo(FieldSystem_GetSaveData(ctx->fieldSystem)); StringTemplate **v1 = FieldSystem_GetScriptMemberPtr(ctx->fieldSystem, SCRIPT_MANAGER_STR_TEMPLATE); sub_0205C980(TrainerInfo_ID(v0), TrainerInfo_Gender(v0), *v1); @@ -5506,7 +5505,7 @@ static BOOL ScrCmd_154(ScriptContext *ctx) static BOOL ScrCmd_155(ScriptContext *ctx) { - TrainerInfo *v0 = SaveData_GetTrainerInfo(FieldSystem_SaveData(ctx->fieldSystem)); + TrainerInfo *v0 = SaveData_GetTrainerInfo(FieldSystem_GetSaveData(ctx->fieldSystem)); u16 v1 = ScriptContext_GetVar(ctx); u16 *v2 = ScriptContext_GetVarPointer(ctx); @@ -5518,7 +5517,7 @@ static BOOL ScrCmd_155(ScriptContext *ctx) static BOOL ScrCmd_29C(ScriptContext *ctx) { - TrainerInfo *v0 = SaveData_GetTrainerInfo(FieldSystem_SaveData(ctx->fieldSystem)); + TrainerInfo *v0 = SaveData_GetTrainerInfo(FieldSystem_GetSaveData(ctx->fieldSystem)); u16 v1 = ScriptContext_GetVar(ctx); u16 *v2 = ScriptContext_GetVarPointer(ctx); @@ -5529,7 +5528,7 @@ static BOOL ScrCmd_29C(ScriptContext *ctx) static BOOL ScrCmd_156(ScriptContext *ctx) { - TrainerInfo *v0 = SaveData_GetTrainerInfo(FieldSystem_SaveData(ctx->fieldSystem)); + TrainerInfo *v0 = SaveData_GetTrainerInfo(FieldSystem_GetSaveData(ctx->fieldSystem)); u16 v1 = ScriptContext_GetVar(ctx); TrainerInfo_SetAppearance(v0, v1); @@ -5553,7 +5552,7 @@ static BOOL ScrCmd_14C(ScriptContext *ctx) static BOOL ScrCmd_GetPlayerGender(ScriptContext *ctx) { - TrainerInfo *trainerInfo = SaveData_GetTrainerInfo(FieldSystem_SaveData(ctx->fieldSystem)); + TrainerInfo *trainerInfo = SaveData_GetTrainerInfo(FieldSystem_GetSaveData(ctx->fieldSystem)); u16 *destVar = ScriptContext_GetVarPointer(ctx); *destVar = TrainerInfo_Gender(trainerInfo); @@ -6700,7 +6699,7 @@ static BOOL ScrCmd_246(ScriptContext *ctx) static BOOL ScrCmd_249(ScriptContext *ctx) { FieldSystem *fieldSystem = ctx->fieldSystem; - TrainerInfo *v1 = SaveData_GetTrainerInfo(FieldSystem_SaveData(ctx->fieldSystem)); + TrainerInfo *v1 = SaveData_GetTrainerInfo(FieldSystem_GetSaveData(ctx->fieldSystem)); u16 *v2 = ScriptContext_GetVarPointer(ctx); PCBoxes *v3 = SaveData_PCBoxes(fieldSystem->saveData); u16 v4 = ScriptContext_GetVar(ctx); @@ -7237,11 +7236,11 @@ static BOOL ScrCmd_282(ScriptContext *ctx) { u16 *v0 = ScriptContext_GetVarPointer(ctx); FieldSystem *fieldSystem = ctx->fieldSystem; - UnkStruct_02025CCC *v2; + SystemData *v2; - v2 = sub_02025CCC(ctx->fieldSystem->saveData); + v2 = SaveData_GetSystemData(ctx->fieldSystem->saveData); - if ((sub_02025D5C(v2) == sub_02055BB8(fieldSystem)) && (sub_02025D60(v2) == sub_02055BC4(fieldSystem))) { + if ((SystemData_GetOwnerBirthMonth(v2) == sub_02055BB8(fieldSystem)) && (SystemData_GetOwnerBirthDayOfMonth(v2) == sub_02055BC4(fieldSystem))) { *v0 = 1; } else { *v0 = 0; @@ -7663,9 +7662,9 @@ static BOOL ScrCmd_2AA(ScriptContext *ctx) static BOOL ScrCmd_2AC(ScriptContext *ctx) { FieldSystem *fieldSystem = ctx->fieldSystem; - UnkStruct_02025CCC *v1; + SystemData *v1; - v1 = sub_02025CCC(ctx->fieldSystem->saveData); + v1 = SaveData_GetSystemData(ctx->fieldSystem->saveData); sub_02025D6C(v1, 1); return 0; @@ -7710,8 +7709,8 @@ static BOOL ScrCmd_2B5(ScriptContext *ctx) location->mapId = mapId; location->x = v1; location->z = v2; - location->unk_04 = -1; - location->unk_10 = 1; + location->warpId = WARP_ID_NONE; + location->faceDirection = FACE_DOWN; return 0; } diff --git a/src/string_template.c b/src/string_template.c index 6785e426a3..6904080935 100644 --- a/src/string_template.c +++ b/src/string_template.c @@ -11,7 +11,6 @@ #include "consts/gender.h" #include "consts/moves.h" -#include "struct_decls/struct_0202B4A0_decl.h" #include "struct_decls/struct_020797DC_decl.h" #include "struct_defs/trainer_data.h" @@ -26,6 +25,7 @@ #include "heap.h" #include "message.h" #include "pokemon.h" +#include "record_mixed_rng.h" #include "save_player.h" #include "savedata.h" #include "savedata_misc.h" @@ -33,7 +33,6 @@ #include "trainer_info.h" #include "unk_02014D38.h" #include "unk_02017038.h" -#include "unk_0202B37C.h" #include "unk_020797C8.h" #include "unk_020996D0.h" @@ -526,13 +525,13 @@ void StringTemplate_SetUnionGroupName(StringTemplate *template, SaveData *save, { int gender, countryCode; Strbuf *groupName; - UnkStruct_0202B4A0 *group = sub_0202B4A0(save); + RecordMixedRNG *group = SaveData_GetRecordMixedRNG(save); - gender = sub_0202B47C(group, groupID); - countryCode = sub_0202B488(group, groupID); + gender = RecordMixedRNG_GetEntryGender(group, groupID); + countryCode = RecordMixedRNG_GetEntryCountryCode(group, groupID); groupName = Strbuf_Init(64, HEAP_ID_FIELD); - Strbuf_CopyChars(groupName, sub_0202B42C(group, groupID, nameType)); + Strbuf_CopyChars(groupName, RecordMixedRNG_GetEntryName(group, groupID, nameType)); StringTemplate_SetStrbuf(template, idx, groupName, gender, 1, countryCode); Strbuf_Free(groupName); } diff --git a/src/sys_task.c b/src/sys_task.c index 81c283b4c9..26a74cbc2d 100644 --- a/src/sys_task.c +++ b/src/sys_task.c @@ -18,7 +18,7 @@ SysTask *SysTask_ExecuteOnVBlank(SysTaskFunc callback, void *param, u32 priority SysTask *SysTask_CreateOnPrintQueue(SysTaskFunc callback, void *param, u32 priority) { - return SysTaskManager_AddTask(gCoreSys.unk_24, callback, param, priority); + return SysTaskManager_AddTask(gCoreSys.printTaskMgr, callback, param, priority); } SysTask *SysTask_ExecuteAfterVBlank(SysTaskFunc callback, void *param, u32 priority) diff --git a/src/system_data.c b/src/system_data.c new file mode 100644 index 0000000000..44d82e6b47 --- /dev/null +++ b/src/system_data.c @@ -0,0 +1,125 @@ +#include "system_data.h" + +#include "constants/savedata/save_table.h" + +#include "rtc.h" +#include "savedata.h" + +int SystemData_SaveSize() +{ + return sizeof(SystemData); +} + +void SystemData_Clear(SystemData *systemData) +{ + MI_CpuClearFast(systemData, sizeof(SystemData)); + GameTime_Clear(&systemData->gameTime); +} + +SystemData *SaveData_GetSystemData(SaveData *systemData) +{ + return SaveData_SaveTable(systemData, SAVE_TABLE_ENTRY_SYSTEM); +} + +GameTime *SaveData_GetGameTime(SaveData *saveData) +{ + return &SaveData_GetSystemData(saveData)->gameTime; +} + +void SystemData_Init(SystemData *systemData) +{ + OSOwnerInfo ownerInfo; + + systemData->rtcOffset = OS_GetOwnerRtcOffset(); + OS_GetMacAddress(systemData->macAddress); + + OS_GetOwnerInfo(&ownerInfo); + systemData->ownerBirthMonth = ownerInfo.birthday.month; + systemData->ownerBirthDayOfMonth = ownerInfo.birthday.day; +} + +BOOL SystemData_MatchesCurrentSystem(const SystemData *systemData) +{ + u8 currMacAddress[6]; + OS_GetMacAddress(currMacAddress); + + for (int i = 0; i < 6; i++) { + if (systemData->macAddress[i] != currMacAddress[i]) { + return FALSE; + } + } + + return TRUE; +} + +BOOL SystemData_MatchesCurrentRTCOffset(const SystemData *systemData) +{ + return OS_GetOwnerRtcOffset() == systemData->rtcOffset; +} + +u8 SystemData_GetOwnerBirthMonth(const SystemData *systemData) +{ + return systemData->ownerBirthMonth; +} + +u8 SystemData_GetOwnerBirthDayOfMonth(const SystemData *systemData) +{ + return systemData->ownerBirthDayOfMonth; +} + +BOOL sub_02025D64(const SystemData *param0) +{ + return param0->unk_48; +} + +void sub_02025D6C(SystemData *param0, BOOL param1) +{ + param0->unk_48 = param1; +} + +s32 sub_02025D74(const SystemData *param0) +{ + return param0->unk_4C; +} + +void sub_02025D78(SystemData *param0, s32 param1) +{ + if (param0->unk_4C == 0) { + param0->unk_4C = param1; + } +} + +void GameTime_Clear(GameTime *gameTime) +{ + gameTime->canary = TRUE; + GetCurrentDateTime(&gameTime->date, &gameTime->time); + gameTime->day = RTC_ConvertDateToDay(&gameTime->date); + gameTime->startTimestamp = RTC_ConvertDateTimeToSecond(&gameTime->date, &gameTime->time); + gameTime->playTimestamp = 0; + gameTime->penaltyInMinutes = 0; +} + +BOOL GameTime_HasPenalty(const GameTime *gameTime) +{ + return gameTime->penaltyInMinutes != 0; +} + +void GameTime_DecrementPenalty(GameTime *gameTime, int val) +{ + if (gameTime->penaltyInMinutes > 24 * 60) { + gameTime->penaltyInMinutes = 24 * 60; + } + + if (gameTime->penaltyInMinutes < val) { + gameTime->penaltyInMinutes = 0; + } else { + gameTime->penaltyInMinutes -= val; + } +} + +void GameTime_StartPenalty(GameTime *gameTime) +{ + gameTime->penaltyInMinutes = 60 * 24; + GetCurrentDateTime(&gameTime->date, &gameTime->time); + gameTime->day = RTC_ConvertDateToDay(&gameTime->date); +} diff --git a/src/unk_02017428.c b/src/unk_02017428.c index 9c1f8b9715..187683be7b 100644 --- a/src/unk_02017428.c +++ b/src/unk_02017428.c @@ -6,20 +6,20 @@ #include "play_time.h" #include "unk_02022844.h" -static BOOL Unk_021BF658 = 0; +static BOOL sStarted = FALSE; static u64 Unk_021BF668 = 0; static u64 Unk_021BF660 = 0; static u64 Unk_021BF670 = 0; static PlayTime *sPlayTime = NULL; -void sub_02017428(void) +void PlayTime_FlagNotStarted() { - Unk_021BF658 = 0; + sStarted = FALSE; } -void sub_02017434(PlayTime *playTime) +void PlayTime_Start(PlayTime *playTime) { - Unk_021BF658 = 1; + sStarted = TRUE; Unk_021BF668 = 0; Unk_021BF660 = 0; sPlayTime = playTime; @@ -28,7 +28,7 @@ void sub_02017434(PlayTime *playTime) void sub_02017458(void) { - if (Unk_021BF658) { + if (sStarted) { u64 v0 = sub_0202295C(sub_0202293C() - Unk_021BF670); if (v0 > Unk_021BF660) { diff --git a/src/unk_02017728.c b/src/unk_02017728.c index a82201a923..210c96ce30 100644 --- a/src/unk_02017728.c +++ b/src/unk_02017728.c @@ -29,7 +29,7 @@ void sub_02017728(void) MI_WaitDma(GX_DEFAULT_DMAID); SysTaskManager_ExecuteTasks(gCoreSys.vBlankTaskMgr); - gCoreSys.unk_30++; + gCoreSys.frameCounter++; } static void sub_0201775C(void) @@ -149,7 +149,7 @@ void sub_0201789C(void) gCoreSys.mainTaskMgr = SysTaskManager_Init(160, OS_AllocFromMainArenaLo(SysTaskManager_GetRequiredSize(160), 4)); gCoreSys.vBlankTaskMgr = SysTaskManager_Init(32, OS_AllocFromMainArenaLo(SysTaskManager_GetRequiredSize(32), 4)); gCoreSys.postVBlankTaskMgr = SysTaskManager_Init(32, OS_AllocFromMainArenaLo(SysTaskManager_GetRequiredSize(32), 4)); - gCoreSys.unk_24 = SysTaskManager_Init(4, OS_AllocFromMainArenaLo(SysTaskManager_GetRequiredSize(4), 4)); + gCoreSys.printTaskMgr = SysTaskManager_Init(4, OS_AllocFromMainArenaLo(SysTaskManager_GetRequiredSize(4), 4)); GX_DispOff(); GXS_DispOff(); @@ -178,7 +178,7 @@ void sub_0201789C(void) gCoreSys.unk_10 = NULL; gCoreSys.unk_14 = NULL; gCoreSys.heapCanary = NULL; - gCoreSys.frameCounter = 0; + gCoreSys.vblankCounter = 0; gCoreSys.unk_65 = 0; CARD_SetCacheFlushThreshold(0x500, 0x2400); diff --git a/src/unk_02025CB0.c b/src/unk_02025CB0.c deleted file mode 100644 index 7f1b2af8bb..0000000000 --- a/src/unk_02025CB0.c +++ /dev/null @@ -1,150 +0,0 @@ -#include "unk_02025CB0.h" - -#include -#include - -#include "struct_defs/struct_02055BA8.h" - -#include "rtc.h" -#include "savedata.h" - -typedef struct UnkStruct_02025CCC_t { - s64 unk_00; - u8 unk_08[6]; - u8 unk_0E; - u8 unk_0F; - UnkStruct_02055BA8 unk_10; - u8 unk_48; - u8 unk_49; - s32 unk_4C; - u32 unk_50[3]; -} UnkStruct_02025CCC; - -int SystemData_SaveSize(void) -{ - return sizeof(UnkStruct_02025CCC); -} - -void SystemData_Init(UnkStruct_02025CCC *param0) -{ - MI_CpuClearFast(param0, sizeof(UnkStruct_02025CCC)); - sub_02025D84(¶m0->unk_10); -} - -UnkStruct_02025CCC *sub_02025CCC(SaveData *param0) -{ - return SaveData_SaveTable(param0, 0); -} - -UnkStruct_02055BA8 *sub_02025CD8(SaveData *param0) -{ - UnkStruct_02025CCC *v0; - - v0 = sub_02025CCC(param0); - return &v0->unk_10; -} - -void sub_02025CE4(UnkStruct_02025CCC *param0) -{ - OSOwnerInfo v0; - - param0->unk_00 = OS_GetOwnerRtcOffset(); - - OS_GetMacAddress(param0->unk_08); - OS_GetOwnerInfo(&v0); - - param0->unk_0E = v0.birthday.month; - param0->unk_0F = v0.birthday.day; -} - -BOOL sub_02025D10(const UnkStruct_02025CCC *param0) -{ - int v0; - u8 v1[6]; - - OS_GetMacAddress(v1); - - for (v0 = 0; v0 < 6; v0++) { - if (param0->unk_08[v0] != v1[v0]) { - return 0; - } - } - - return 1; -} - -BOOL sub_02025D40(const UnkStruct_02025CCC *param0) -{ - return OS_GetOwnerRtcOffset() == param0->unk_00; -} - -u8 sub_02025D5C(const UnkStruct_02025CCC *param0) -{ - return param0->unk_0E; -} - -u8 sub_02025D60(const UnkStruct_02025CCC *param0) -{ - return param0->unk_0F; -} - -BOOL sub_02025D64(const UnkStruct_02025CCC *param0) -{ - return param0->unk_48; -} - -void sub_02025D6C(UnkStruct_02025CCC *param0, BOOL param1) -{ - param0->unk_48 = param1; -} - -s32 sub_02025D74(const UnkStruct_02025CCC *param0) -{ - return param0->unk_4C; -} - -void sub_02025D78(UnkStruct_02025CCC *param0, s32 param1) -{ - if (param0->unk_4C == 0) { - param0->unk_4C = param1; - } -} - -void sub_02025D84(UnkStruct_02055BA8 *param0) -{ - param0->unk_00 = 1; - GetCurrentDateTime(¶m0->unk_04, ¶m0->unk_14); - param0->unk_20 = RTC_ConvertDateToDay(¶m0->unk_04); - param0->unk_24 = RTC_ConvertDateTimeToSecond(¶m0->unk_04, ¶m0->unk_14); - param0->unk_2C = 0; - param0->unk_34 = 0; -} - -BOOL sub_02025DB8(const UnkStruct_02055BA8 *param0) -{ - if (param0->unk_34 != 0) { - return 1; - } else { - return 0; - } -} - -void sub_02025DC8(UnkStruct_02055BA8 *param0, int param1) -{ - if (param0->unk_34 > 24 * 60) { - param0->unk_34 = 24 * 60; - } - - if (param0->unk_34 < param1) { - param0->unk_34 = 0; - } else { - param0->unk_34 -= param1; - } -} - -void sub_02025DE8(UnkStruct_02055BA8 *param0) -{ - param0->unk_34 = 60 * 24; - GetCurrentDateTime(¶m0->unk_04, ¶m0->unk_14); - param0->unk_20 = RTC_ConvertDateToDay(¶m0->unk_04); -} diff --git a/src/unk_02027B70.c b/src/unk_02027B70.c deleted file mode 100644 index 6aee557f83..0000000000 --- a/src/unk_02027B70.c +++ /dev/null @@ -1,334 +0,0 @@ -#include "unk_02027B70.h" - -#include -#include - -#include "struct_decls/struct_berry_data_decl.h" -#include "struct_defs/struct_02027854.h" -#include "struct_defs/struct_02027BF4.h" - -#include "berry_data.h" -#include "heap.h" -#include "narc.h" - -static void sub_02027C50(UnkStruct_02027854 *param0); -static int sub_02027C7C(const UnkStruct_02027BF4 *param0, int param1, int param2); - -void sub_02027B70(UnkStruct_02027854 *param0) -{ - int v0; - - MI_CpuClear8(param0, sizeof(UnkStruct_02027854) * 128); - - for (v0 = 0; v0 < 128; v0++) { - param0[v0].unk_01 = 0; - param0[v0].unk_00 = 0; - } -} - -void sub_02027B90(UnkStruct_02027854 *param0, int param1, const u16 *param2, int param3) -{ - int v0; - UnkStruct_02027BF4 *v1 = sub_02027BF4(param1); - - for (v0 = 0; v0 < 128 || v0 < param3; v0++) { - sub_02027C50(¶m0[v0]); - param0[v0].unk_00 = param2[v0 * 2] - 149 + 1; - param0[v0].unk_01 = 5; - param0[v0].unk_02 = sub_02027C7C(v1, param0[v0].unk_00, param0[v0].unk_0C) * 4; - param0[v0].unk_08 = param2[v0 * 2 + 1]; - param0[v0].unk_0A = 100; - param0[v0].unk_0B = 3; - } - - Heap_FreeToHeap(v1); -} - -UnkStruct_02027BF4 *sub_02027BF4(int param0) -{ - int v0; - UnkStruct_02027BF4 *v1; - BerryData *v2; - NARC *v3; - - v3 = BerryData_NARC_ctor(param0); - v1 = Heap_AllocFromHeap(param0, sizeof(UnkStruct_02027BF4) * 64); - - for (v0 = 0; v0 < 64; v0++) { - v2 = sub_020973A8(v3, v0, param0); - - v1[v0].unk_00 = BerryData_GetAttribute(v2, 3); - v1[v0].unk_01 = BerryData_GetAttribute(v2, 4); - v1[v0].unk_02 = BerryData_GetAttribute(v2, 2); - - Heap_FreeToHeap(v2); - } - - BerryData_NARC_dtor(v3); - return v1; -} - -static void sub_02027C50(UnkStruct_02027854 *param0) -{ - param0->unk_00 = 0; - param0->unk_01 = 0; - param0->unk_02 = 0; - param0->unk_04 = 0; - param0->unk_06 = 0; - param0->unk_08 = 0; - param0->unk_0A = 0; - param0->unk_0B = 0; - param0->unk_0C = 0; - param0->unk_0D = 0; -} - -static int sub_02027C68(UnkStruct_02027854 *param0, const UnkStruct_02027BF4 *param1) -{ - return param1[param0->unk_00 - 1].unk_02 * param0->unk_0B; -} - -static int sub_02027C7C(const UnkStruct_02027BF4 *param0, int param1, int param2) -{ - int v0; - - v0 = param0[param1 - 1].unk_00 * 60; - - if (param2 == 1) { - v0 = (v0 * 3) / 4; - } else if (param2 == 2) { - v0 = v0 + (v0 / 2); - } - - return v0; -} - -static int sub_02027CA8(const UnkStruct_02027BF4 *param0, int param1, int param2) -{ - int v0 = param0[param1 - 1].unk_01; - - if (param2 == 2) { - return v0 / 2; - } else if (param2 == 1) { - return v0 + v0 / 2; - } else { - return v0; - } -} - -static int sub_02027CCC(const UnkStruct_02027854 *param0) -{ - if (param0->unk_0C == 3) { - return 4 + 2; - } else { - return 4; - } -} - -static int sub_02027CDC(const UnkStruct_02027854 *param0) -{ - if (param0->unk_0C == 4) { - return 10 + 5; - } else { - return 10; - } -} - -static int sub_02027CEC(UnkStruct_02027854 *param0) -{ - return 1 + (1 + 1 + 1 + sub_02027CCC(param0)) * sub_02027CDC(param0); -} - -int sub_02027D04(const UnkStruct_02027854 *param0, int param1) -{ - return param0[param1].unk_01; -} - -int sub_02027D10(const UnkStruct_02027854 *param0, int param1) -{ - return param0[param1].unk_00; -} - -int sub_02027D18(const UnkStruct_02027854 *param0, int param1) -{ - int v0; - - v0 = param0[param1].unk_0A; - - if (v0 == 0) { - return 0; - } else if (v0 <= 50) { - return 1; - } else { - return 2; - } -} - -int sub_02027D34(const UnkStruct_02027854 *param0, int param1) -{ - return param0[param1].unk_0B; -} - -void sub_02027D40(UnkStruct_02027854 *param0, int param1, const UnkStruct_02027BF4 *param2, int param3) -{ - param0[param1].unk_00 = param3; - param0[param1].unk_01 = 1; - param0[param1].unk_02 = sub_02027C7C(param2, param3, param0[param1].unk_0C); - param0[param1].unk_04 = 0; - param0[param1].unk_06 = 0; - param0[param1].unk_08 = 0; - param0[param1].unk_0A = 100; - param0[param1].unk_0B = 5; - param0[param1].unk_0D = 1; -} - -void sub_02027D78(UnkStruct_02027854 *param0, int param1) -{ - param0[param1].unk_0A = 100; -} - -BOOL sub_02027D84(const UnkStruct_02027854 *param0, int param1) -{ - return param0[param1].unk_0D; -} - -void sub_02027D90(UnkStruct_02027854 *param0, int param1, BOOL param2) -{ - param0[param1].unk_0D = param2; -} - -int sub_02027D9C(const UnkStruct_02027854 *param0, int param1) -{ - return param0[param1].unk_0C; -} - -void sub_02027DA8(UnkStruct_02027854 *param0, int param1, int param2) -{ - param0[param1].unk_0C = param2; -} - -int sub_02027DB4(const UnkStruct_02027854 *param0, int param1) -{ - return param0[param1].unk_08; -} - -int sub_02027DC0(UnkStruct_02027854 *param0, int param1) -{ - int v0; - - v0 = param0[param1].unk_08; - sub_02027C50(¶m0[param1]); - - return v0; -} - -static void sub_02027DD4(UnkStruct_02027854 *param0, const UnkStruct_02027BF4 *param1) -{ - switch (param0->unk_01) { - case 0: - GF_ASSERT(0); - break; - case 1: - case 2: - case 3: - param0->unk_01++; - break; - case 4: - param0->unk_08 = sub_02027C68(param0, param1); - - if (param0->unk_08 < 2) { - param0->unk_08 = 2; - } - - param0->unk_01++; - break; - case 5: - param0->unk_08 = 0; - param0->unk_01 = 2; - param0->unk_0B = 5; - param0->unk_06++; - - if (param0->unk_06 == sub_02027CDC(param0)) { - sub_02027C50(param0); - } - break; - } -} - -static void sub_02027E40(UnkStruct_02027854 *param0, const UnkStruct_02027BF4 *param1, int param2) -{ - int v0; - int v1; - int v2; - - if (param0->unk_01 == 5) { - return; - } - - v1 = sub_02027CA8(param1, param0->unk_00, param0->unk_0C); - param2 += param0->unk_04; - - v0 = param2 / 60; - param0->unk_04 = param2 % 60; - - if (v0 == 0) { - return; - } - - if (param0->unk_0A >= v1 * v0) { - param0->unk_0A -= v1 * v0; - return; - } - - if (param0->unk_0A > 0) { - v2 = (param0->unk_0A + (v1 - 1)) / v1; - v0 -= v2; - param0->unk_0A = 0; - } - - if (param0->unk_0B > v0) { - param0->unk_0B -= v0; - } else { - param0->unk_0B = 0; - } -} - -void sub_02027EAC(UnkStruct_02027854 *param0, const UnkStruct_02027BF4 *param1, int param2) -{ - int v0; - s32 v1; - UnkStruct_02027854 *v2; - - for (v0 = 0; v0 < 128; v0++) { - v2 = ¶m0[v0]; - - if ((v2->unk_00 == 0) || (v2->unk_01 == 0) || (v2->unk_0D == 0)) { - continue; - } - - if (param2 >= sub_02027C7C(param1, v2->unk_00, v2->unk_0C) * sub_02027CEC(v2)) { - sub_02027C50(v2); - continue; - } - - v1 = param2; - - while (v2->unk_01 != 0 && v1 != 0) { - if (v2->unk_02 > v1) { - sub_02027E40(v2, param1, v1); - v2->unk_02 -= v1; - v1 = 0; - break; - } else { - sub_02027E40(v2, param1, v2->unk_02); - sub_02027DD4(v2, param1); - - v1 -= v2->unk_02; - v2->unk_02 = sub_02027C7C(param1, v2->unk_00, v2->unk_0C); - - if (v2->unk_01 == 5) { - v2->unk_02 *= sub_02027CCC(v2); - } - } - } - } -} diff --git a/src/unk_0202854C.c b/src/unk_0202854C.c index 002a73fd16..f3cc2ece4a 100644 --- a/src/unk_0202854C.c +++ b/src/unk_0202854C.c @@ -101,7 +101,7 @@ void Underground_Init(UndergroundData *param0) RTCTime v2; GetCurrentDateTime(&v1, &v2); - v0 = (((((((u32)v1.year * 32ULL + v1.month) * 32ULL) + v1.day) * 32ULL + v2.hour) * 32ULL + v2.minute) * 32ULL + (v2.second + gCoreSys.frameCounter)); + v0 = (((((((u32)v1.year * 32ULL + v1.month) * 32ULL) + v1.day) * 32ULL + v2.hour) * 32ULL + v2.minute) * 32ULL + (v2.second + gCoreSys.vblankCounter)); MI_CpuFill8(param0, 0, sizeof(UndergroundData)); diff --git a/src/unk_0202B37C.c b/src/unk_0202B37C.c deleted file mode 100644 index c5242cb1ee..0000000000 --- a/src/unk_0202B37C.c +++ /dev/null @@ -1,188 +0,0 @@ -#include "unk_0202B37C.h" - -#include -#include - -#include "struct_defs/struct_0202B4A0.h" -#include "struct_defs/struct_0202B510.h" - -#include "charcode_util.h" -#include "savedata.h" -#include "strbuf.h" -#include "unk_0201D15C.h" - -UnkStruct_0202B4A0 *Unk_021C079C; - -int RandomGroup_SaveSize(void) -{ - return sizeof(UnkStruct_0202B4A0); -} - -void sub_0202B384(UnkStruct_0202B4A0 *param0, int param1, int param2) -{ - param0->unk_00[param2] = param0->unk_00[param1]; -} - -void RandomGroup_Init(UnkStruct_0202B4A0 *param0) -{ - int v0; - - MI_CpuClearFast(param0, sizeof(UnkStruct_0202B4A0)); - - for (v0 = 0; v0 < 6; v0++) { - param0->unk_00[v0].unk_00[0] = 0xffff; - param0->unk_00[v0].unk_10[0] = 0xffff; - } - - Unk_021C079C = param0; -} - -void sub_0202B3D8(UnkStruct_0202B4A0 *param0, u32 param1) -{ - u32 v0, v1; - - for (v0 = 0; v0 < 6; v0++) { - for (v1 = 0; v1 < param1; v1++) { - param0->unk_00[v0].unk_28 = ARNG_Next(param0->unk_00[v0].unk_28); - } - } -} - -u32 sub_0202B400(UnkStruct_0202B4A0 *param0, int param1) -{ - return param0->unk_00[param1].unk_24; -} - -void sub_0202B40C(UnkStruct_0202B4A0 *param0, int param1, u32 param2) -{ - param0->unk_00[param1].unk_24 = param2; - param0->unk_00[param1].unk_28 = ARNG_Next(param2); -} - -u32 sub_0202B428(UnkStruct_0202B4A0 *param0) -{ - return param0->unk_00[1].unk_28; -} - -const u16 *sub_0202B42C(const UnkStruct_0202B4A0 *param0, int param1, int param2) -{ - if (param2 == 0) { - return param0->unk_00[param1].unk_00; - } - - return param0->unk_00[param1].unk_10; -} - -void sub_0202B444(UnkStruct_0202B4A0 *param0, int param1, int param2, Strbuf *param3) -{ - u16 *v0; - - if (param2 == 0) { - v0 = param0->unk_00[param1].unk_00; - Strbuf_ToChars(param3, v0, 7 + 1); - } else { - v0 = param0->unk_00[param1].unk_10; - Strbuf_ToChars(param3, v0, 7 + 1); - } -} - -void sub_0202B470(UnkStruct_0202B4A0 *param0, int param1, int param2) -{ - param0->unk_00[param1].unk_20 = param2; -} - -int sub_0202B47C(const UnkStruct_0202B4A0 *param0, int param1) -{ - return param0->unk_00[param1].unk_20; -} - -int sub_0202B488(const UnkStruct_0202B4A0 *param0, int param1) -{ - return param0->unk_00[param1].unk_21; -} - -void sub_0202B494(UnkStruct_0202B4A0 *param0, int param1, int param2) -{ - param0->unk_00[param1].unk_21 = param2; -} - -UnkStruct_0202B4A0 *sub_0202B4A0(SaveData *param0) -{ - return (UnkStruct_0202B4A0 *)SaveData_SaveTable(param0, 17); -} - -BOOL sub_0202B4AC(const UnkStruct_0202B4A0 *param0, int param1) -{ - const UnkStruct_0202B510 *v0 = ¶m0->unk_00[param1]; - return !(sub_0202B510(v0)); -} - -BOOL sub_0202B4C4(const UnkStruct_0202B4A0 *param0, int param1) -{ - const UnkStruct_0202B510 *v0, *v1; - - v0 = ¶m0->unk_00[1]; - v1 = ¶m0->unk_00[param1]; - - return sub_0202B530(v0, v1); -} - -BOOL sub_0202B4D8(const UnkStruct_0202B4A0 *param0, const u16 *param1) -{ - int v0; - const UnkStruct_0202B510 *v1; - - if (*param1 == 0xffff) { - return 0; - } - - for (v0 = 0; v0 < 6; v0++) { - v1 = ¶m0->unk_00[v0]; - - if (!CharCode_CompareNumChars(param1, v1->unk_00, 7 + 1)) { - return 1; - } - } - - return 0; -} - -BOOL sub_0202B510(const UnkStruct_0202B510 *param0) -{ - if (param0->unk_00[0] == 0xffff) { - return 1; - } - - if (param0->unk_10[0] == 0xffff) { - return 1; - } - - return 0; -} - -BOOL sub_0202B530(const UnkStruct_0202B510 *param0, const UnkStruct_0202B510 *param1) -{ - int v0; - - if (CharCode_CompareNumChars(param0->unk_10, param1->unk_10, 7 + 1)) { - return 0; - } - - if (CharCode_CompareNumChars(param0->unk_00, param1->unk_00, 7 + 1)) { - return 0; - } - - if (param0->unk_20 != param1->unk_20) { - return 0; - } - - if (param0->unk_21 != param1->unk_21) { - return 0; - } - - if (param0->unk_24 != param1->unk_24) { - return 0; - } - - return 1; -} diff --git a/src/unk_0202E840.c b/src/unk_0202E840.c index 790f42a264..f03485f318 100644 --- a/src/unk_0202E840.c +++ b/src/unk_0202E840.c @@ -15,11 +15,11 @@ #include "charcode_util.h" #include "game_records.h" #include "heap.h" +#include "record_mixed_rng.h" #include "save_player.h" #include "savedata.h" #include "strbuf.h" #include "trainer_info.h" -#include "unk_0202B37C.h" #include "unk_0203061C.h" typedef struct { @@ -195,7 +195,7 @@ void *sub_0202E9FC(SaveData *param0, int param1) v3 = Heap_AllocFromHeapAtEnd(param1, sizeof(UnkStruct_0202E91C)); MI_CpuClear8(v3, sizeof(UnkStruct_0202E91C)); - v1 = sub_0202B400(sub_0202B4A0(param0), 1); + v1 = RecordMixedRNG_GetEntrySeed(SaveData_GetRecordMixedRNG(param0), 1); v4 = TrainerInfo_NameNewStrbuf(v5, param1); v6 = sub_0202E924(param0, param1); @@ -357,7 +357,7 @@ void sub_0202ED0C(SaveData *param0, int param1, u8 param2, const void **param3, UnkStruct_0202EE10 *v5; v4 = sub_0202E8C0(param0); - v2 = sub_0202B400(sub_0202B4A0(param0), 1); + v2 = RecordMixedRNG_GetEntrySeed(SaveData_GetRecordMixedRNG(param0), 1); v1 = 0; for (v0 = 0; v0 < param2; v0++) { @@ -398,7 +398,7 @@ UnkStruct_0202EE10 *sub_0202ED8C(SaveData *param0, int param1, int param2) MI_CpuClear8(v3, sizeof(UnkStruct_0202EE10)); - v2 = sub_0202B400(sub_0202B4A0(param0), 1); + v2 = RecordMixedRNG_GetEntrySeed(SaveData_GetRecordMixedRNG(param0), 1); v4 = sub_0202E924(param0, param2); v3->unk_00 = sub_0202E840(param1); v1 = sub_0202E84C(param1); diff --git a/src/unk_02030A80.c b/src/unk_02030A80.c index 54e8fd909a..46e676b178 100644 --- a/src/unk_02030A80.c +++ b/src/unk_02030A80.c @@ -3,7 +3,6 @@ #include #include -#include "struct_decls/struct_02025CCC_decl.h" #include "struct_decls/struct_0202C878_decl.h" #include "struct_defs/sentence.h" #include "struct_defs/struct_0202F298_sub1.h" @@ -16,10 +15,10 @@ #include "savedata.h" #include "savedata_misc.h" #include "strbuf.h" +#include "system_data.h" #include "trainer_info.h" #include "unk_02014A84.h" #include "unk_02014D38.h" -#include "unk_02025CB0.h" #include "unk_0202C858.h" #include "unk_0205C980.h" #include "unk_020996D0.h" @@ -43,7 +42,7 @@ void sub_02030AA0(UnkStruct_02030A80 *param0, SaveData *param1) { TrainerInfo *v0 = SaveData_GetTrainerInfo(param1); UnkStruct_0202C878 *v1 = sub_0202C878(param1); - UnkStruct_02025CCC *v2 = sub_02025CCC(param1); + SystemData *v2 = SaveData_GetSystemData(param1); const MiscSaveBlock *v3 = SaveData_MiscSaveBlockConst(param1); int v4, v5, v6; int v7; diff --git a/src/unk_02039A64.c b/src/unk_02039A64.c index c2203744e3..b442c9e2d6 100644 --- a/src/unk_02039A64.c +++ b/src/unk_02039A64.c @@ -8,11 +8,11 @@ #include "font.h" #include "gx_layers.h" #include "heap.h" +#include "main.h" #include "message.h" #include "render_window.h" #include "strbuf.h" #include "text.h" -#include "unk_02000C88.h" #include "unk_0200A9DC.h" #include "unk_0200F174.h" #include "unk_02017728.h" diff --git a/src/unk_0203A7D8.c b/src/unk_0203A7D8.c index f37e1b7d3b..e0127822e4 100644 --- a/src/unk_0203A7D8.c +++ b/src/unk_0203A7D8.c @@ -3,11 +3,10 @@ #include #include -#include "struct_defs/struct_02049FA8.h" - #include "field/field_system.h" #include "inlines.h" +#include "location.h" #include "vars_flags.h" typedef struct { @@ -66,10 +65,10 @@ void sub_0203A7F0(int param0, Location *location) param0 = sub_0203A7D8(param0); location->mapId = Unk_020E97B4[param0].unk_06; - location->unk_04 = -1; + location->warpId = WARP_ID_NONE; location->x = Unk_020E97B4[param0].unk_08; location->z = Unk_020E97B4[param0].unk_0A; - location->unk_10 = 1; + location->faceDirection = FACE_DOWN; } void sub_0203A824(int param0, Location *location) @@ -77,10 +76,10 @@ void sub_0203A824(int param0, Location *location) param0 = sub_0203A7D8(param0); location->mapId = Unk_020E97B4[param0].unk_00; - location->unk_04 = -1; + location->warpId = WARP_ID_NONE; location->x = Unk_020E97B4[param0].unk_02; location->z = Unk_020E97B4[param0].unk_04; - location->unk_10 = 0; + location->faceDirection = FACE_UP; } int sub_0203A858(int param0) diff --git a/src/unk_0203A944.c b/src/unk_0203A944.c index 9a44bef20d..81e4010c66 100644 --- a/src/unk_0203A944.c +++ b/src/unk_0203A944.c @@ -5,14 +5,12 @@ #include "constants/overworld_weather.h" -#include "struct_defs/struct_02055BA8.h" - #include "field/field_system.h" #include "inlines.h" #include "map_header.h" #include "rtc.h" -#include "unk_02025CB0.h" +#include "system_data.h" #include "unk_020559DC.h" static const u8 Unk_020E98F4[] = { @@ -1860,12 +1858,12 @@ int FieldSystem_GetWeather(FieldSystem *fieldSystem, int param1) { int v1; - UnkStruct_02055BA8 *v2 = sub_02025CD8(fieldSystem->saveData); + GameTime *v2 = SaveData_GetGameTime(fieldSystem->saveData); - v1 = DayNumberForDate(&v2->unk_04) - 1; + v1 = DayNumberForDate(&v2->date) - 1; GF_ASSERT(v1 >= 0 && v1 < 366); - if ((v2->unk_04.month > 2) && !inline_0203A944(v2->unk_04.year)) { + if ((v2->date.month > 2) && !inline_0203A944(v2->date.year)) { v1++; } diff --git a/src/unk_0203D178.c b/src/unk_0203D178.c deleted file mode 100644 index 811d33cd6d..0000000000 --- a/src/unk_0203D178.c +++ /dev/null @@ -1,36 +0,0 @@ -#include "unk_0203D178.h" - -#include -#include - -#include "struct_decls/struct_0203A790_decl.h" -#include "struct_defs/struct_02049FA8.h" - -#include "field_overworld_state.h" -#include "savedata.h" - -void sub_0203D178(Location *param0) -{ - static const Location v0 = { - 415, -1, 4, 6, 0 - }; - - *param0 = v0; -} - -void sub_0203D190(Location *param0) -{ - static const Location v0 = { - 411, -1, 116, 886, 1 - }; - - *param0 = v0; -} - -void sub_0203D1A8(SaveData *param0) -{ - FieldOverworldState *v0 = SaveData_GetFieldOverworldState(param0); - Location *v1 = sub_0203A720(v0); - - sub_0203D178(v1); -} diff --git a/src/unk_0203D1B8.c b/src/unk_0203D1B8.c index 0625bdcbc1..a376f11f3e 100644 --- a/src/unk_0203D1B8.c +++ b/src/unk_0203D1B8.c @@ -8,7 +8,6 @@ #include "struct_decls/struct_02029C68_decl.h" #include "struct_decls/struct_02029D04_decl.h" #include "struct_decls/struct_0202A750_decl.h" -#include "struct_decls/struct_0202B4A0_decl.h" #include "struct_decls/struct_0202C834_decl.h" #include "struct_decls/struct_020508D4_decl.h" #include "struct_decls/struct_0207AE68_decl.h" @@ -101,20 +100,20 @@ #include "pokemon.h" #include "pokemon_summary_app.h" #include "poketch_data.h" +#include "record_mixed_rng.h" #include "rtc.h" #include "save_player.h" #include "savedata.h" #include "savedata_misc.h" #include "strbuf.h" +#include "system_data.h" #include "trainer_info.h" #include "unk_02017498.h" #include "unk_0201D15C.h" -#include "unk_02025CB0.h" #include "unk_0202631C.h" #include "unk_02028124.h" #include "unk_020298BC.h" #include "unk_0202ACE0.h" -#include "unk_0202B37C.h" #include "unk_0202C7FC.h" #include "unk_0202C858.h" #include "unk_0202D05C.h" @@ -259,7 +258,7 @@ const OverlayManagerTemplate gBattleOverlayTemplate = { void sub_0203D1D4(FieldSystem *fieldSystem, BattleParams *param1) { - sub_0203CD84(fieldSystem, &gBattleOverlayTemplate, param1); + FieldSystem_StartChildProcess(fieldSystem, &gBattleOverlayTemplate, param1); } static const u8 Unk_020EA164[] = { @@ -285,7 +284,7 @@ void sub_0203D1E4(FieldSystem *fieldSystem, void *param1) FS_OVERLAY_ID(overlay84) }; - sub_0203CD84(fieldSystem, &Unk_ov84_02241130, param1); + FieldSystem_StartChildProcess(fieldSystem, &Unk_ov84_02241130, param1); } void *sub_0203D20C(FieldSystem *fieldSystem, UnkStruct_020684D0 *param1) @@ -360,7 +359,7 @@ void sub_0203D2E4(FieldSystem *fieldSystem, void *param1) FS_OVERLAY_ID(overlay85) }; - sub_0203CD84(fieldSystem, &v0, param1); + FieldSystem_StartChildProcess(fieldSystem, &v0, param1); } void sub_0203D30C(FieldSystem *fieldSystem, void *param1) @@ -374,12 +373,12 @@ void sub_0203D30C(FieldSystem *fieldSystem, void *param1) FS_OVERLAY_ID(overlay81) }; - sub_0203CD84(fieldSystem, &v0, fieldSystem->saveData); + FieldSystem_StartChildProcess(fieldSystem, &v0, fieldSystem->saveData); } void sub_0203D334(FieldSystem *fieldSystem, void *param1) { - sub_0203CD84(fieldSystem, &Unk_020F410C, param1); + FieldSystem_StartChildProcess(fieldSystem, &Unk_020F410C, param1); } static PartyManagementData *sub_0203D344(int param0, FieldSystem *fieldSystem, int param2, int param3) @@ -406,7 +405,7 @@ void *sub_0203D390(FieldSystem *fieldSystem, UnkStruct_02070950 *param1, u8 para v0->unk_18 = param1; v0->unk_22 = param2; - sub_0203CD84(fieldSystem, &Unk_020F1E88, v0); + FieldSystem_StartChildProcess(fieldSystem, &Unk_020F1E88, v0); return v0; } @@ -415,7 +414,7 @@ void *sub_0203D3C0(int param0, FieldSystem *fieldSystem) { PartyManagementData *v0 = sub_0203D344(11, fieldSystem, 0, 3); - sub_0203CD84(fieldSystem, &Unk_020F1E88, v0); + FieldSystem_StartChildProcess(fieldSystem, &Unk_020F1E88, v0); return v0; } @@ -423,7 +422,7 @@ void *sub_0203D3E4(int param0, FieldSystem *fieldSystem) { PartyManagementData *v0 = sub_0203D344(11, fieldSystem, 0, 19); - sub_0203CD84(fieldSystem, &Unk_020F1E88, v0); + FieldSystem_StartChildProcess(fieldSystem, &Unk_020F1E88, v0); return v0; } @@ -438,7 +437,7 @@ void *sub_0203D410(int param0, FieldSystem *fieldSystem, int param2) PartyManagementData *v0 = sub_0203D344(11, fieldSystem, 0, 18); v0->unk_22 = param2; - sub_0203CD84(fieldSystem, &Unk_020F1E88, v0); + FieldSystem_StartChildProcess(fieldSystem, &Unk_020F1E88, v0); return v0; } @@ -467,7 +466,7 @@ static BOOL sub_0203D444(TaskManager *param0) switch (*v2) { case 0: - sub_0203CD84(fieldSystem, &Unk_020F1E88, v1->unk_04); + FieldSystem_StartChildProcess(fieldSystem, &Unk_020F1E88, v1->unk_04); *v2 = 1; break; case 1: @@ -540,7 +539,7 @@ void *sub_0203D578(int param0, FieldSystem *fieldSystem, int param2, int param3, v0->unk_2B = 0; } - sub_0203CD84(fieldSystem, &Unk_020F1E88, v0); + FieldSystem_StartChildProcess(fieldSystem, &Unk_020F1E88, v0); return v0; } @@ -563,7 +562,7 @@ void *sub_0203D5C8(int param0, FieldSystem *fieldSystem, int param2) PokemonSummary_FlagVisiblePages(v0, Unk_020EA02C); PokemonSummary_SetPlayerProfile(v0, SaveData_GetTrainerInfo(fieldSystem->saveData)); - sub_0203CD84(fieldSystem, &Unk_020F410C, v0); + FieldSystem_StartChildProcess(fieldSystem, &Unk_020F410C, v0); return v0; } @@ -573,7 +572,7 @@ void *sub_0203D644(FieldSystem *fieldSystem, int param1) PartyManagementData *v0 = sub_0203D344(11, fieldSystem, 0, 21); v0->unk_22 = param1; - sub_0203CD84(fieldSystem, &Unk_020F1E88, v0); + FieldSystem_StartChildProcess(fieldSystem, &Unk_020F1E88, v0); return v0; } @@ -654,7 +653,7 @@ void sub_0203D754(FieldSystem *fieldSystem, UnkStruct_02042434 *param1) FS_OVERLAY_ID(overlay19) }; - sub_0203CD84(fieldSystem, &v0, param1); + FieldSystem_StartChildProcess(fieldSystem, &v0, param1); } static BOOL sub_0203D764(TaskManager *taskMan) @@ -731,7 +730,7 @@ void sub_0203D874(FieldSystem *fieldSystem, UnkStruct_0209747C *param1) FS_OVERLAY_ID(overlay20) }; - sub_0203CD84(fieldSystem, &v0, param1); + FieldSystem_StartChildProcess(fieldSystem, &v0, param1); } void sub_0203D884(FieldSystem *fieldSystem, UnkStruct_0203D8AC *param1) @@ -745,7 +744,7 @@ void sub_0203D884(FieldSystem *fieldSystem, UnkStruct_0203D8AC *param1) FS_OVERLAY_ID(overlay80) }; - sub_0203CD84(fieldSystem, &v0, param1); + FieldSystem_StartChildProcess(fieldSystem, &v0, param1); } void *sub_0203D8AC(FieldSystem *fieldSystem) @@ -774,13 +773,13 @@ static void OpenOptionsMenu(FieldSystem *fieldSystem, Options *options) FS_OVERLAY_ID(options_menu) }; - sub_0203CD84(fieldSystem, &template, options); + FieldSystem_StartChildProcess(fieldSystem, &template, options); } void *FieldSystem_OpenOptionsMenu(FieldSystem *fieldSystem) { OptionsMenu *optionsMenu = Heap_AllocFromHeapAtEnd(11, sizeof(OptionsMenu)); - Options *options = SaveData_Options(FieldSystem_SaveData(fieldSystem)); + Options *options = SaveData_Options(FieldSystem_GetSaveData(fieldSystem)); OpenOptionsMenu(fieldSystem, options); return optionsMenu; @@ -790,14 +789,14 @@ extern const OverlayManagerTemplate Unk_020F64B0; static void sub_0203D910(FieldSystem *fieldSystem, UnkStruct_02097728 *param1) { - sub_0203CD84(fieldSystem, &Unk_020F64B0, param1); + FieldSystem_StartChildProcess(fieldSystem, &Unk_020F64B0, param1); } UnkStruct_02097728 *sub_0203D920(FieldSystem *fieldSystem, int param1, u8 param2, u8 param3, int param4) { UnkStruct_02097728 *v0; - v0 = sub_02097624(FieldSystem_SaveData(fieldSystem), param1, param2, param3, 11); + v0 = sub_02097624(FieldSystem_GetSaveData(fieldSystem), param1, param2, param3, 11); sub_0203D910(fieldSystem, v0); return v0; @@ -808,9 +807,9 @@ UnkStruct_02097728 *sub_0203D94C(FieldSystem *fieldSystem, int param1, u8 param2 UnkStruct_02097728 *v0; if (param1 == 3) { - v0 = sub_020976F4(FieldSystem_SaveData(fieldSystem), param2, param3); + v0 = sub_020976F4(FieldSystem_GetSaveData(fieldSystem), param2, param3); } else { - v0 = sub_0209767C(FieldSystem_SaveData(fieldSystem), param1, param2, param3); + v0 = sub_0209767C(FieldSystem_GetSaveData(fieldSystem), param1, param2, param3); } sub_0203D910(fieldSystem, v0); @@ -822,7 +821,7 @@ UnkStruct_02097728 *sub_0203D984(FieldSystem *fieldSystem, Pokemon *param1, int { UnkStruct_02097728 *v0; - v0 = sub_020976BC(FieldSystem_SaveData(fieldSystem), param1, param2); + v0 = sub_020976BC(FieldSystem_GetSaveData(fieldSystem), param1, param2); sub_0203D910(fieldSystem, v0); return v0; @@ -830,14 +829,14 @@ UnkStruct_02097728 *sub_0203D984(FieldSystem *fieldSystem, Pokemon *param1, int static void sub_0203D9A8(FieldSystem *fieldSystem, UnkStruct_0203D9B8 *param1) { - sub_0203CD84(fieldSystem, &Unk_020F6890, param1); + FieldSystem_StartChildProcess(fieldSystem, &Unk_020F6890, param1); } UnkStruct_0203D9B8 *sub_0203D9B8(FieldSystem *fieldSystem, int param1) { UnkStruct_0203D9B8 *v0; - v0 = sub_020989DC(FieldSystem_SaveData(fieldSystem), param1); + v0 = sub_020989DC(FieldSystem_GetSaveData(fieldSystem), param1); sub_0203D9A8(fieldSystem, v0); return v0; @@ -854,7 +853,7 @@ void sub_0203D9D8(FieldSystem *fieldSystem, UnkStruct_ov90_021D0D80 *param1) FS_OVERLAY_ID(overlay90) }; - sub_0203CD84(fieldSystem, &v0, param1); + FieldSystem_StartChildProcess(fieldSystem, &v0, param1); } static UnkStruct_0203DA00 *sub_0203DA00(int param0, SaveData *param1, int param2, BOOL *param3, BOOL param4) @@ -940,7 +939,7 @@ BOOL sub_0203DB10(FieldSystem *fieldSystem, void *param1) FS_OVERLAY_ID(overlay22) }; - sub_0203CD84(fieldSystem, &v0, param1); + FieldSystem_StartChildProcess(fieldSystem, &v0, param1); return 1; } @@ -956,7 +955,7 @@ BOOL sub_0203DB24(FieldSystem *fieldSystem, void *param1) FS_OVERLAY_ID(overlay22) }; - sub_0203CD84(fieldSystem, &v0, param1); + FieldSystem_StartChildProcess(fieldSystem, &v0, param1); return 1; } @@ -1140,7 +1139,7 @@ void sub_0203DDFC(FieldSystem *fieldSystem) v0->unk_04 = fieldSystem->journal; v0->unk_08 = SaveData_Options(fieldSystem->saveData); - sub_0203CD84(fieldSystem, &Unk_020EA258, v0); + FieldSystem_StartChildProcess(fieldSystem, &Unk_020EA258, v0); } void *sub_0203DE34(FieldSystem *fieldSystem) @@ -1153,7 +1152,7 @@ void *sub_0203DE34(FieldSystem *fieldSystem) v0->records = SaveData_GetGameRecordsPtr(fieldSystem->saveData); v0->unk_10 = fieldSystem->journal; - sub_0203CD84(fieldSystem, &Unk_020EA248, v0); + FieldSystem_StartChildProcess(fieldSystem, &Unk_020EA248, v0); return v0; } @@ -1167,12 +1166,12 @@ const OverlayManagerTemplate Unk_020EA238 = { void sub_0203DE78(FieldSystem *fieldSystem, SaveData *param1) { - sub_0203CD84(fieldSystem, &Unk_020EA238, param1); + FieldSystem_StartChildProcess(fieldSystem, &Unk_020EA238, param1); } void sub_0203DE88(FieldSystem *fieldSystem, SaveData *param1) { - sub_0203CD84(fieldSystem, &Unk_020F2FCC, fieldSystem); + FieldSystem_StartChildProcess(fieldSystem, &Unk_020F2FCC, fieldSystem); } static BOOL sub_0203DE98(TaskManager *param0) @@ -1201,9 +1200,9 @@ static BOOL sub_0203DE98(TaskManager *param0) } } else if (v2->unk_0C->unk_00 == 5) { const u16 *v3 = Strbuf_GetData(v2->unk_0C->unk_18); - UnkStruct_0202B4A0 *v4 = sub_0202B4A0(fieldSystem->saveData); + RecordMixedRNG *v4 = SaveData_GetRecordMixedRNG(fieldSystem->saveData); - if (sub_0202B4D8(v4, v3)) { + if (RecordMixedRNG_DoesCollectionContainGroup(v4, v3)) { v2->unk_0C->unk_14 = 2; } } @@ -1244,8 +1243,8 @@ static void sub_0203DF68(TaskManager *param0) Pokemon_SetValue(v3, MON_DATA_NICKNAME_AND_FLAG, (u8 *)&v1->unk_0C->unk_1C); } break; case 5: { - UnkStruct_0202B4A0 *v5 = sub_0202B4A0(fieldSystem->saveData); - sub_0202B444(v5, 0, 0, v1->unk_0C->unk_18); + RecordMixedRNG *v5 = SaveData_GetRecordMixedRNG(fieldSystem->saveData); + RecordMixedRNG_GetEntryNameAsStrbuf(v5, 0, 0, v1->unk_0C->unk_18); } break; case 6: { MiscSaveBlock *v6 = SaveData_MiscSaveBlock(fieldSystem->saveData); @@ -1302,7 +1301,7 @@ void sub_0203E09C(FieldSystem *fieldSystem, TrainerCard *param1) FS_OVERLAY_ID(overlay71) }; - sub_0203CD84(fieldSystem, &v0, param1); + FieldSystem_StartChildProcess(fieldSystem, &v0, param1); } BOOL sub_0203E0AC(FieldSystem *fieldSystem, void *param1) @@ -1316,7 +1315,7 @@ BOOL sub_0203E0AC(FieldSystem *fieldSystem, void *param1) FS_OVERLAY_ID(overlay21) }; - sub_0203CD84(fieldSystem, &v0, param1); + FieldSystem_StartChildProcess(fieldSystem, &v0, param1); return 1; } @@ -1331,7 +1330,7 @@ void sub_0203E0C0(FieldSystem *fieldSystem, ChooseStarterData *param1) FS_OVERLAY_ID(choose_starter) }; - sub_0203CD84(fieldSystem, &template, param1); + FieldSystem_StartChildProcess(fieldSystem, &template, param1); } void sub_0203E0D0(FieldSystem *fieldSystem) @@ -1347,7 +1346,7 @@ void sub_0203E0D0(FieldSystem *fieldSystem) FS_OVERLAY_ID(overlay72) }; - sub_0203CD84(fieldSystem, &v1, fieldSystem->saveData); + FieldSystem_StartChildProcess(fieldSystem, &v1, fieldSystem->saveData); } void sub_0203E0FC(FieldSystem *fieldSystem, int param1) @@ -1366,7 +1365,7 @@ void sub_0203E0FC(FieldSystem *fieldSystem, int param1) v0 = Heap_AllocFromHeapAtEnd(11, sizeof(UnkStruct_0203E0FC)); v0->unk_00 = sub_0202DA40(fieldSystem->saveData); - v0->unk_04 = sub_02025CCC(fieldSystem->saveData); + v0->unk_04 = SaveData_GetSystemData(fieldSystem->saveData); v0->unk_08 = SaveData_SaveTable(fieldSystem->saveData, 2); v0->unk_0C = SaveData_PCBoxes(fieldSystem->saveData); v0->unk_10 = SaveData_Pokedex(fieldSystem->saveData); @@ -1383,7 +1382,7 @@ void sub_0203E0FC(FieldSystem *fieldSystem, int param1) v0->unk_30 = SaveData_GetBag(fieldSystem->saveData); v0->unk_40 = param1; - sub_0203CD84(fieldSystem, &v1, v0); + FieldSystem_StartChildProcess(fieldSystem, &v1, v0); } void *sub_0203E1AC(FieldSystem *fieldSystem, int param1, int param2) @@ -1403,7 +1402,7 @@ void *sub_0203E1AC(FieldSystem *fieldSystem, int param1, int param2) v0->unk_00 = sub_0202D750(fieldSystem->saveData); v0->unk_04 = sub_0202D764(fieldSystem->saveData); - v0->unk_08 = sub_02025CCC(fieldSystem->saveData); + v0->unk_08 = SaveData_GetSystemData(fieldSystem->saveData); v0->unk_10 = SaveData_Options(fieldSystem->saveData); v0->unk_14 = sub_0202AD28(sub_0202B370(fieldSystem->saveData)); v0->unk_0C = fieldSystem->saveData; @@ -1412,7 +1411,7 @@ void *sub_0203E1AC(FieldSystem *fieldSystem, int param1, int param2) v0->unk_24 = param2; v0->unk_20 = 1; - sub_0203CD84(fieldSystem, &v1, v0); + FieldSystem_StartChildProcess(fieldSystem, &v1, v0); return (void *)v0; } @@ -1426,7 +1425,7 @@ static const OverlayManagerTemplate Unk_020EA328 = { void sub_0203E224(FieldSystem *fieldSystem) { - sub_0203CD84(fieldSystem, &Unk_020EA328, fieldSystem->saveData); + FieldSystem_StartChildProcess(fieldSystem, &Unk_020EA328, fieldSystem->saveData); } void sub_0203E234(FieldSystem *fieldSystem, UnkStruct_0203E234 *param1) @@ -1440,7 +1439,7 @@ void sub_0203E234(FieldSystem *fieldSystem, UnkStruct_0203E234 *param1) FS_OVERLAY_ID(overlay86) }; - sub_0203CD84(fieldSystem, &v0, param1); + FieldSystem_StartChildProcess(fieldSystem, &v0, param1); } void *sub_0203E244(FieldSystem *fieldSystem) @@ -1460,7 +1459,7 @@ void *sub_0203E244(FieldSystem *fieldSystem) Heap_FreeToHeap(v1); return NULL; } else { - sub_0203CD84(fieldSystem, &v0, v1); + FieldSystem_StartChildProcess(fieldSystem, &v0, v1); return v1; } } @@ -1476,7 +1475,7 @@ void sub_0203E274(FieldSystem *fieldSystem, UnkStruct_0203E274 *param1) FS_OVERLAY_ID(overlay99) }; - sub_0203CD84(fieldSystem, &v0, param1); + FieldSystem_StartChildProcess(fieldSystem, &v0, param1); } void sub_0203E284(FieldSystem *fieldSystem, UnkStruct_020997B8 *param1) @@ -1490,7 +1489,7 @@ void sub_0203E284(FieldSystem *fieldSystem, UnkStruct_020997B8 *param1) FS_OVERLAY_ID(overlay91) }; - sub_0203CD84(fieldSystem, &v0, param1); + FieldSystem_StartChildProcess(fieldSystem, &v0, param1); } void sub_0203E2AC(FieldSystem *fieldSystem, void *param1) @@ -1504,7 +1503,7 @@ void sub_0203E2AC(FieldSystem *fieldSystem, void *param1) FS_OVERLAY_ID(overlay93) }; - sub_0203CD84(fieldSystem, &v0, param1); + FieldSystem_StartChildProcess(fieldSystem, &v0, param1); } void sub_0203E2D4(FieldSystem *fieldSystem, void *param1) @@ -1515,7 +1514,7 @@ void sub_0203E2D4(FieldSystem *fieldSystem, void *param1) ov93_021D111C, ov93_021D120C, ov93_021D12F0, FS_OVERLAY_ID(overlay93) }; - sub_0203CD84(fieldSystem, &v0, param1); + FieldSystem_StartChildProcess(fieldSystem, &v0, param1); } void sub_0203E2FC(FieldSystem *fieldSystem) @@ -1546,7 +1545,7 @@ BOOL sub_0203E348(FieldSystem *fieldSystem, UnkStruct_0203E348 *param1) FS_OVERLAY_ID(overlay101) }; - sub_0203CD84(fieldSystem, &v0, param1); + FieldSystem_StartChildProcess(fieldSystem, &v0, param1); return 1; } @@ -1620,14 +1619,14 @@ static u8 sub_0203E484(SaveData *param0, u8 param1) 3, 3, }; - UnkStruct_0202B4A0 *v1 = sub_0202B4A0(param0); + RecordMixedRNG *v1 = SaveData_GetRecordMixedRNG(param0); u32 v2; u8 v3[12]; u8 v4, v5, v6, v7; v2 = LCRNG_GetSeed(); - LCRNG_SetSeed(sub_0202B428(v1)); + LCRNG_SetSeed(RecordMixedRNG_GetRand(v1)); MI_CpuCopy8(v0, v3, sizeof(v3)); for (v4 = 0; v4 < 12; v4++) { @@ -1680,7 +1679,7 @@ void *sub_0203E53C(FieldSystem *fieldSystem, int param1, int param2) v1->unk_00 = fieldSystem->saveData; } - sub_0203CD84(fieldSystem, &v0, v1); + FieldSystem_StartChildProcess(fieldSystem, &v0, v1); return v1; } @@ -1705,7 +1704,7 @@ void *sub_0203E564(FieldSystem *fieldSystem, u8 param1, u8 param2, u16 param3, i v0->unk_06 = param3; v0->unk_00 = fieldSystem->saveData; - sub_0203CD84(fieldSystem, &v1, v0); + FieldSystem_StartChildProcess(fieldSystem, &v1, v0); return v0; } @@ -1729,7 +1728,7 @@ PartyManagementData *sub_0203E598(FieldSystem *fieldSystem, int param1, int para v0->unk_22 = 0; v0->unk_1C = fieldSystem; - sub_0203CD84(fieldSystem, &Unk_020F1E88, v0); + FieldSystem_StartChildProcess(fieldSystem, &Unk_020F1E88, v0); return v0; } @@ -1751,7 +1750,7 @@ void *sub_0203E608(FieldSystem *fieldSystem, int param1) memset(v0, 0, sizeof(UnkStruct_0203E608)); v0->unk_00 = fieldSystem->saveData; - sub_0203CD84(fieldSystem, &v1, v0); + FieldSystem_StartChildProcess(fieldSystem, &v1, v0); return v0; } @@ -1782,7 +1781,7 @@ void *sub_0203E63C(int param0, FieldSystem *fieldSystem, u16 param2, u16 param3) PokemonSummary_FlagVisiblePages(v0, Unk_020EA15C); PokemonSummary_SetPlayerProfile(v0, SaveData_GetTrainerInfo(fieldSystem->saveData)); - sub_0203CD84(fieldSystem, &Unk_020F410C, v0); + FieldSystem_StartChildProcess(fieldSystem, &Unk_020F410C, v0); return v0; } @@ -1808,7 +1807,7 @@ void sub_0203E6C0(FieldSystem *fieldSystem, int param1, int param2) v0->unk_08 = param1; v0->unk_0C = param2; - sub_0203CD84(fieldSystem, &v1, v0); + FieldSystem_StartChildProcess(fieldSystem, &v1, v0); } FS_EXTERN_OVERLAY(library_tv); @@ -1822,7 +1821,7 @@ static const OverlayManagerTemplate LibraryTV_template = { void sub_0203E704(FieldSystem *fieldSystem) { - sub_0203CD84(fieldSystem, &LibraryTV_template, fieldSystem->saveData); + FieldSystem_StartChildProcess(fieldSystem, &LibraryTV_template, fieldSystem->saveData); } static const OverlayManagerTemplate Unk_020EA368 = { @@ -1834,5 +1833,5 @@ static const OverlayManagerTemplate Unk_020EA368 = { void sub_0203E714(FieldSystem *fieldSystem) { - sub_0203CD84(fieldSystem, &Unk_020EA368, fieldSystem->saveData); + FieldSystem_StartChildProcess(fieldSystem, &Unk_020EA368, fieldSystem->saveData); } diff --git a/src/unk_02046C7C.c b/src/unk_02046C7C.c index 51753e3e97..1e35deaabe 100644 --- a/src/unk_02046C7C.c +++ b/src/unk_02046C7C.c @@ -93,7 +93,7 @@ BOOL ScrCmd_0FA(ScriptContext *param0) Strbuf *v0; Pokemon *v1; void **v2 = FieldSystem_GetScriptMemberPtr(param0->fieldSystem, SCRIPT_MANAGER_DATA_PTR); - TrainerInfo *v3 = SaveData_GetTrainerInfo(FieldSystem_SaveData(param0->fieldSystem)); + TrainerInfo *v3 = SaveData_GetTrainerInfo(FieldSystem_GetSaveData(param0->fieldSystem)); u16 v4 = ScriptContext_GetVar(param0); u16 v5 = ScriptContext_GetVar(param0); u16 v6 = ScriptContext_GetVar(param0); diff --git a/src/unk_020474B8.c b/src/unk_020474B8.c index 49c684e5e3..b781440e24 100644 --- a/src/unk_020474B8.c +++ b/src/unk_020474B8.c @@ -50,7 +50,7 @@ BOOL ScrCmd_BufferPlayerName(ScriptContext *ctx) StringTemplate **strTemplate = FieldSystem_GetScriptMemberPtr(fieldSystem, SCRIPT_MANAGER_STR_TEMPLATE); u8 templateArg = ScriptContext_ReadByte(ctx); - StringTemplate_SetPlayerName(*strTemplate, templateArg, SaveData_GetTrainerInfo(FieldSystem_SaveData(fieldSystem))); + StringTemplate_SetPlayerName(*strTemplate, templateArg, SaveData_GetTrainerInfo(FieldSystem_GetSaveData(fieldSystem))); return FALSE; } @@ -244,7 +244,7 @@ BOOL ScrCmd_0D9(ScriptContext *param0) { int v0; FieldSystem *fieldSystem = param0->fieldSystem; - TrainerInfo *v2 = SaveData_GetTrainerInfo(FieldSystem_SaveData(param0->fieldSystem)); + TrainerInfo *v2 = SaveData_GetTrainerInfo(FieldSystem_GetSaveData(param0->fieldSystem)); StringTemplate **v3 = FieldSystem_GetScriptMemberPtr(fieldSystem, SCRIPT_MANAGER_STR_TEMPLATE); u8 v4 = ScriptContext_ReadByte(param0); diff --git a/src/unk_02048BD0.c b/src/unk_02048BD0.c index eea5fc0f1e..246416bf82 100644 --- a/src/unk_02048BD0.c +++ b/src/unk_02048BD0.c @@ -3,10 +3,9 @@ #include #include -#include "struct_decls/struct_0202B4A0_decl.h" - #include "field_script_context.h" #include "inlines.h" +#include "record_mixed_rng.h" #include "save_player.h" #include "savedata.h" #include "script_manager.h" @@ -14,14 +13,13 @@ #include "string_template.h" #include "trainer_info.h" #include "unk_0201D15C.h" -#include "unk_0202B37C.h" #include "unk_0203D1B8.h" #include "unk_0206CCB0.h" BOOL ScrCmd_21D(ScriptContext *param0) { StringTemplate **v0 = FieldSystem_GetScriptMemberPtr(param0->fieldSystem, SCRIPT_MANAGER_STR_TEMPLATE); - UnkStruct_0202B4A0 *v1 = sub_0202B4A0(param0->fieldSystem->saveData); + RecordMixedRNG *v1 = SaveData_GetRecordMixedRNG(param0->fieldSystem->saveData); SaveData *v2 = param0->fieldSystem->saveData; switch (ScriptContext_ReadHalfWord(param0)) { @@ -31,7 +29,7 @@ BOOL ScrCmd_21D(ScriptContext *param0) v3 = ScriptContext_GetVar(param0); v4 = ScriptContext_GetVarPointer(param0); - *v4 = sub_0202B4AC(v1, v3); + *v4 = RecordMixedRNG_IsEntryValid(v1, v3); return 0; } break; @@ -41,7 +39,7 @@ BOOL ScrCmd_21D(ScriptContext *param0) v5 = ScriptContext_GetVar(param0); v6 = ScriptContext_GetVarPointer(param0); - *v6 = sub_0202B4C4(v1, v5); + *v6 = RecordMixedRNG_IsEntryEqualToOverride(v1, v5); return 0; } break; @@ -64,15 +62,15 @@ BOOL ScrCmd_21D(ScriptContext *param0) case 4: { const u16 *v11; - v11 = sub_0202B42C(v1, 0, 0); + v11 = RecordMixedRNG_GetEntryName(v1, 0, 0); sub_0203DFE8(param0->taskManager, 5, 0, 7, 0, v11, ScriptContext_GetVarPointer(param0)); } return 1; case 5: { u16 v12 = ScriptContext_GetVar(param0); - BOOL v13 = sub_0202B4AC(v1, 1); + BOOL v13 = RecordMixedRNG_IsEntryValid(v1, 1); - sub_0202B384(v1, v12, 1); + RecordMixedRNG_CopyEntry(v1, v12, 1); if (v13) { sub_0206D430(param0->fieldSystem); @@ -84,12 +82,12 @@ BOOL ScrCmd_21D(ScriptContext *param0) TrainerInfo *v15 = SaveData_GetTrainerInfo(param0->fieldSystem->saveData); TrainerInfo_NameStrbuf(v15, v14); - sub_0202B444(v1, 0, 1, v14); - sub_0202B470(v1, 0, TrainerInfo_Gender(v15)); - sub_0202B494(v1, 0, GAME_LANGUAGE); - sub_0202B40C(v1, 0, MTRNG_Next()); + RecordMixedRNG_GetEntryNameAsStrbuf(v1, 0, 1, v14); + RecordMixedRNG_SetEntryGender(v1, 0, TrainerInfo_Gender(v15)); + RecordMixedRNG_SetEntryCountryCode(v1, 0, GAME_LANGUAGE); + RecordMixedRNG_SetEntrySeed(v1, 0, MTRNG_Next()); Strbuf_Free(v14); - sub_0202B384(v1, 0, 1); + RecordMixedRNG_CopyEntry(v1, 0, 1); sub_0206D424(param0->fieldSystem); } break; } diff --git a/src/unk_020494DC.c b/src/unk_020494DC.c index 07ccf96d4a..655171c988 100644 --- a/src/unk_020494DC.c +++ b/src/unk_020494DC.c @@ -37,7 +37,7 @@ BOOL ScrCmd_1DB(ScriptContext *param0) v0 = ScriptContext_ReadHalfWord(param0); v1 = ScriptContext_ReadHalfWord(param0); - param0->fieldSystem->unk_AC = sub_0204A124(FieldSystem_SaveData(param0->fieldSystem), v0, v1); + param0->fieldSystem->unk_AC = sub_0204A124(FieldSystem_GetSaveData(param0->fieldSystem), v0, v1); return 0; } diff --git a/src/unk_02049D08.c b/src/unk_02049D08.c index cc2901cb73..be3885eb9d 100644 --- a/src/unk_02049D08.c +++ b/src/unk_02049D08.c @@ -12,7 +12,6 @@ #include "struct_decls/struct_0203068C_decl.h" #include "struct_decls/struct_020508D4_decl.h" #include "struct_decls/struct_party_decl.h" -#include "struct_defs/struct_02049FA8.h" #include "struct_defs/struct_0204AFC4.h" #include "struct_defs/struct_02098C44.h" @@ -25,6 +24,7 @@ #include "heap.h" #include "inlines.h" #include "journal.h" +#include "location.h" #include "party.h" #include "player_avatar.h" #include "pokemon.h" diff --git a/src/unk_0204C6C8.c b/src/unk_0204C6C8.c index 3577776605..a1c7ade9d4 100644 --- a/src/unk_0204C6C8.c +++ b/src/unk_0204C6C8.c @@ -104,7 +104,7 @@ BOOL ScrCmd_2A8(ScriptContext *param0) BOOL ScrCmd_274(ScriptContext *param0) { FieldSystem *fieldSystem = param0->fieldSystem; - TrainerInfo *v1 = SaveData_GetTrainerInfo(FieldSystem_SaveData(param0->fieldSystem)); + TrainerInfo *v1 = SaveData_GetTrainerInfo(FieldSystem_GetSaveData(param0->fieldSystem)); SaveData *v2 = fieldSystem->saveData; u16 *v3 = SaveData_GetCoins(v2); u32 v4, v5; @@ -125,7 +125,7 @@ BOOL ScrCmd_274(ScriptContext *param0) BOOL ScrCmd_2A9(ScriptContext *param0) { FieldSystem *fieldSystem = param0->fieldSystem; - TrainerInfo *v1 = SaveData_GetTrainerInfo(FieldSystem_SaveData(param0->fieldSystem)); + TrainerInfo *v1 = SaveData_GetTrainerInfo(FieldSystem_GetSaveData(param0->fieldSystem)); SaveData *v2 = fieldSystem->saveData; u16 *v3 = SaveData_GetCoins(v2); u16 *v4 = ScriptContext_GetVarPointer(param0); diff --git a/src/unk_0204C8F0.c b/src/unk_0204C8F0.c index d98708a882..beda719339 100644 --- a/src/unk_0204C8F0.c +++ b/src/unk_0204C8F0.c @@ -16,7 +16,7 @@ BOOL ScrCmd_06F(ScriptContext *param0) { - TrainerInfo *v0 = SaveData_GetTrainerInfo(FieldSystem_SaveData(param0->fieldSystem)); + TrainerInfo *v0 = SaveData_GetTrainerInfo(FieldSystem_GetSaveData(param0->fieldSystem)); u32 v1; v1 = ScriptContext_ReadWord(param0); @@ -27,7 +27,7 @@ BOOL ScrCmd_06F(ScriptContext *param0) BOOL ScrCmd_070(ScriptContext *param0) { - TrainerInfo *v0 = SaveData_GetTrainerInfo(FieldSystem_SaveData(param0->fieldSystem)); + TrainerInfo *v0 = SaveData_GetTrainerInfo(FieldSystem_GetSaveData(param0->fieldSystem)); u32 v1; v1 = ScriptContext_ReadWord(param0); @@ -38,7 +38,7 @@ BOOL ScrCmd_070(ScriptContext *param0) BOOL ScrCmd_1A3(ScriptContext *param0) { - TrainerInfo *v0 = SaveData_GetTrainerInfo(FieldSystem_SaveData(param0->fieldSystem)); + TrainerInfo *v0 = SaveData_GetTrainerInfo(FieldSystem_GetSaveData(param0->fieldSystem)); u32 v1; v1 = ScriptContext_GetVar(param0); @@ -49,7 +49,7 @@ BOOL ScrCmd_1A3(ScriptContext *param0) BOOL ScrCmd_071(ScriptContext *param0) { - TrainerInfo *v0 = SaveData_GetTrainerInfo(FieldSystem_SaveData(param0->fieldSystem)); + TrainerInfo *v0 = SaveData_GetTrainerInfo(FieldSystem_GetSaveData(param0->fieldSystem)); u16 *v1; u32 v2, v3; @@ -68,7 +68,7 @@ BOOL ScrCmd_071(ScriptContext *param0) BOOL ScrCmd_1AB(ScriptContext *param0) { - TrainerInfo *v0 = SaveData_GetTrainerInfo(FieldSystem_SaveData(param0->fieldSystem)); + TrainerInfo *v0 = SaveData_GetTrainerInfo(FieldSystem_GetSaveData(param0->fieldSystem)); u16 *v1; u32 v2, v3; diff --git a/src/unk_0204CA84.c b/src/unk_0204CA84.c index 5383b7566b..6c9df5ba01 100644 --- a/src/unk_0204CA84.c +++ b/src/unk_0204CA84.c @@ -62,7 +62,7 @@ BOOL ScrCmd_1A9(ScriptContext *param0) SaveData *v1 = fieldSystem->saveData; UnkStruct_02026310 *v2 = (UnkStruct_02026310 *)(SaveData_SaveTable(v1, 8)); Party *v3 = Party_GetFromSavedata(fieldSystem->saveData); - TrainerInfo *v4 = SaveData_GetTrainerInfo(FieldSystem_SaveData(param0->fieldSystem)); + TrainerInfo *v4 = SaveData_GetTrainerInfo(FieldSystem_GetSaveData(param0->fieldSystem)); ov5_021E6EA8(v2, v3, v4); return 0; diff --git a/src/unk_0204CFFC.c b/src/unk_0204CFFC.c index 4df2a36406..5878e2793c 100644 --- a/src/unk_0204CFFC.c +++ b/src/unk_0204CFFC.c @@ -66,7 +66,7 @@ BOOL ScrCmd_199(ScriptContext *param0) { FieldSystem *fieldSystem = param0->fieldSystem; Pokemon *v1; - TrainerInfo *v2 = SaveData_GetTrainerInfo(FieldSystem_SaveData(param0->fieldSystem)); + TrainerInfo *v2 = SaveData_GetTrainerInfo(FieldSystem_GetSaveData(param0->fieldSystem)); u16 *v3 = ScriptContext_GetVarPointer(param0); u16 *v4 = ScriptContext_GetVarPointer(param0); u16 v5, v6; diff --git a/src/unk_0204E3CC.c b/src/unk_0204E3CC.c index b29b38a390..ffc669bacb 100644 --- a/src/unk_0204E3CC.c +++ b/src/unk_0204E3CC.c @@ -87,7 +87,7 @@ BOOL ScrCmd_15E(ScriptContext *param0) { u16 *v0 = ScriptContext_GetVarPointer(param0); - *v0 = sub_0206A938(SaveData_GetVarsFlags(param0->fieldSystem->saveData)); + *v0 = VarsFlags_CheckBagAvailable(SaveData_GetVarsFlags(param0->fieldSystem->saveData)); return 0; } @@ -119,7 +119,7 @@ BOOL ScrCmd_15D(ScriptContext *param0) BOOL ScrCmd_15F(ScriptContext *param0) { - sub_0206A92C(SaveData_GetVarsFlags(param0->fieldSystem->saveData)); + VarsFlags_SetBagAvailable(SaveData_GetVarsFlags(param0->fieldSystem->saveData)); return 0; } diff --git a/src/unk_0204EDA4.c b/src/unk_0204EDA4.c index 14a0e0a97a..9be5ae86c0 100644 --- a/src/unk_0204EDA4.c +++ b/src/unk_0204EDA4.c @@ -80,7 +80,7 @@ static void sub_0204EE90(ScriptContext *param0, u16 param1, Pokemon *param2, u16 *v0 = v1; v1->unk_00 = param2; - v1->unk_04 = SaveData_GetTrainerInfo(FieldSystem_SaveData(param0->fieldSystem)); + v1->unk_04 = SaveData_GetTrainerInfo(FieldSystem_GetSaveData(param0->fieldSystem)); v1->unk_08 = SaveData_Options(param0->fieldSystem->saveData); v1->unk_0C = param3; v1->unk_15 = param1; diff --git a/src/unk_0204F13C.c b/src/unk_0204F13C.c index 0c1e6f3c87..7b8ff301a4 100644 --- a/src/unk_0204F13C.c +++ b/src/unk_0204F13C.c @@ -363,7 +363,7 @@ static int sub_0204F50C(UnkStruct_0204F470 *param0, FieldSystem *fieldSystem, in v1->unk_32_4 = 2; } - sub_0203CD84(fieldSystem, &Unk_020F1E88, v1); + FieldSystem_StartChildProcess(fieldSystem, &Unk_020F1E88, v1); *(param0->unk_08) = v1; @@ -437,7 +437,7 @@ static int sub_0204F628(UnkStruct_0204F470 *param0, FieldSystem *fieldSystem, in PokemonSummary_FlagVisiblePages(v0, v2); PokemonSummary_SetPlayerProfile(v0, SaveData_GetTrainerInfo(v1)); - sub_0203CD84(fieldSystem, &Unk_020F410C, v0); + FieldSystem_StartChildProcess(fieldSystem, &Unk_020F410C, v0); *(param0->unk_08) = v0; return UnkEnum_0204F13C_4; diff --git a/src/unk_0204FAB4.c b/src/unk_0204FAB4.c index a2a8d158ab..3462cdf507 100644 --- a/src/unk_0204FAB4.c +++ b/src/unk_0204FAB4.c @@ -281,7 +281,7 @@ static int sub_0204FE50(UnkStruct_0204FE50 *param0, FieldSystem *fieldSystem, in v1->unk_32_4 = 2; } - sub_0203CD84(fieldSystem, &Unk_020F1E88, v1); + FieldSystem_StartChildProcess(fieldSystem, &Unk_020F1E88, v1); *(param0->unk_0C) = v1; @@ -342,7 +342,7 @@ static int sub_0204FF6C(UnkStruct_0204FE50 *param0, FieldSystem *fieldSystem, in PokemonSummary_FlagVisiblePages(v0, v2); PokemonSummary_SetPlayerProfile(v0, SaveData_GetTrainerInfo(v1)); - sub_0203CD84(fieldSystem, &Unk_020F410C, v0); + FieldSystem_StartChildProcess(fieldSystem, &Unk_020F410C, v0); *(param0->unk_0C) = v0; return 3; diff --git a/src/unk_0205003C.c b/src/unk_0205003C.c index 391813feab..e1d483235d 100644 --- a/src/unk_0205003C.c +++ b/src/unk_0205003C.c @@ -270,7 +270,7 @@ static int sub_0205037C(UnkStruct_0205037C *param0, FieldSystem *fieldSystem, in v1->unk_32_4 = 2; } - sub_0203CD84(fieldSystem, &Unk_020F1E88, v1); + FieldSystem_StartChildProcess(fieldSystem, &Unk_020F1E88, v1); *(param0->unk_0C) = v1; return 1; @@ -330,7 +330,7 @@ static int sub_02050498(UnkStruct_0205037C *param0, FieldSystem *fieldSystem, in PokemonSummary_FlagVisiblePages(v0, v2); PokemonSummary_SetPlayerProfile(v0, SaveData_GetTrainerInfo(v1)); - sub_0203CD84(fieldSystem, &Unk_020F410C, v0); + FieldSystem_StartChildProcess(fieldSystem, &Unk_020F410C, v0); *(param0->unk_0C) = v0; return 3; diff --git a/src/unk_02050568.c b/src/unk_02050568.c index 36689165ef..8e56ab622b 100644 --- a/src/unk_02050568.c +++ b/src/unk_02050568.c @@ -7,7 +7,6 @@ #include "struct_decls/struct_020508D4_decl.h" #include "struct_decls/struct_0205E884_decl.h" #include "struct_decls/struct_02061AB4_decl.h" -#include "struct_defs/struct_02049FA8.h" #include "field/field_system.h" #include "field/field_system_sub2_t.h" @@ -18,6 +17,7 @@ #include "field_map_change.h" #include "heap.h" #include "inlines.h" +#include "location.h" #include "map_object.h" #include "player_avatar.h" #include "unk_02005474.h" diff --git a/src/unk_020508D4.c b/src/unk_020508D4.c index 2adf083eae..d7ca31ed43 100644 --- a/src/unk_020508D4.c +++ b/src/unk_020508D4.c @@ -116,7 +116,7 @@ BOOL sub_020509A4(FieldSystem *fieldSystem) BOOL sub_020509B4(FieldSystem *fieldSystem) { - if (sub_0203CD4C(fieldSystem) || sub_0203CD74(fieldSystem)) { + if (FieldSystem_HasParentProcess(fieldSystem) || FieldSystem_HasChildProcess(fieldSystem)) { return 1; } else { return 0; @@ -125,12 +125,12 @@ BOOL sub_020509B4(FieldSystem *fieldSystem) void sub_020509D4(FieldSystem *fieldSystem) { - sub_0203CD00(fieldSystem); + FieldSystem_StartFieldMap(fieldSystem); } BOOL sub_020509DC(FieldSystem *fieldSystem) { - if (sub_0203CD5C(fieldSystem)) { + if (FieldSystem_IsRunningFieldMap(fieldSystem)) { return 1; } else { return 0; @@ -144,7 +144,7 @@ static BOOL sub_020509F0(TaskManager *param0) switch (v1->unk_00) { case 0: - sub_0203CD84(fieldSystem, v1->unk_04, v1->unk_08); + FieldSystem_StartChildProcess(fieldSystem, v1->unk_04, v1->unk_08); v1->unk_00++; break; case 1: diff --git a/src/unk_02050A74.c b/src/unk_02050A74.c index dfb3888cfa..aea173c69f 100644 --- a/src/unk_02050A74.c +++ b/src/unk_02050A74.c @@ -12,7 +12,6 @@ #include "struct_decls/struct_party_decl.h" #include "struct_defs/struct_0202610C.h" #include "struct_defs/struct_0202BE38.h" -#include "struct_defs/struct_02049FA8.h" #include "field/field_system.h" #include "overlay006/battle_params.h" @@ -29,6 +28,7 @@ #include "game_records.h" #include "heap.h" #include "journal.h" +#include "location.h" #include "map_object.h" #include "party.h" #include "pokemon.h" diff --git a/src/unk_02051D8C.c b/src/unk_02051D8C.c index c251947a3b..fe4cd1be95 100644 --- a/src/unk_02051D8C.c +++ b/src/unk_02051D8C.c @@ -12,7 +12,6 @@ #include "struct_decls/struct_party_decl.h" #include "struct_defs/chatot_cry.h" #include "struct_defs/struct_0202610C.h" -#include "struct_defs/struct_02055BA8.h" #include "struct_defs/struct_0205EC34.h" #include "struct_defs/struct_0209C370.h" #include "struct_defs/trainer_data.h" @@ -41,8 +40,8 @@ #include "save_player.h" #include "savedata.h" #include "strbuf.h" +#include "system_data.h" #include "trainer_info.h" -#include "unk_02025CB0.h" #include "unk_0202602C.h" #include "unk_0202631C.h" #include "unk_02027F84.h" @@ -117,7 +116,7 @@ BattleParams *sub_02051D8C(int param0, u32 param1) RTCTime v3; GetCurrentDateTime(&v2, &v3); - v1->unk_174 = v2.year + v2.month * 0x100 * v2.day * 0x10000 + v3.hour * 0x10000 + (v3.minute + v3.second) * 0x1000000 + gCoreSys.frameCounter; + v1->unk_174 = v2.year + v2.month * 0x100 * v2.day * 0x10000 + v3.hour * 0x10000 + (v3.minute + v3.second) * 0x1000000 + gCoreSys.vblankCounter; } if (CommSys_IsInitialized() == 1) { @@ -264,9 +263,9 @@ void sub_020521B8(BattleParams *param0, const FieldSystem *fieldSystem, SaveData param0->unk_128 = MapHeader_GetBattleBG(param3); param0->unk_12C = 9; { - UnkStruct_02055BA8 *v7 = sub_02025CD8(param2); + GameTime *v7 = SaveData_GetGameTime(param2); - param0->unk_138 = TimeOfDayForHour(v7->unk_14.hour); + param0->unk_138 = TimeOfDayForHour(v7->time.hour); } } diff --git a/src/unk_020528D0.c b/src/unk_020528D0.c index ba3cec0bc7..cdfa7fcfc8 100644 --- a/src/unk_020528D0.c +++ b/src/unk_020528D0.c @@ -5,7 +5,6 @@ #include "struct_decls/struct_0203A790_decl.h" #include "struct_decls/struct_020508D4_decl.h" -#include "struct_defs/struct_02049FA8.h" #include "struct_defs/struct_02099F80.h" #include "field/field_system.h" @@ -19,6 +18,7 @@ #include "graphics.h" #include "gx_layers.h" #include "heap.h" +#include "location.h" #include "message.h" #include "party.h" #include "pokemon.h" @@ -124,7 +124,7 @@ static void sub_02052914(FieldSystem *fieldSystem, TaskManager *param1) v0->unk_20 = StringTemplate_Default(11); Window_AddFromTemplate(v0->unk_08, &v0->unk_0C, &Unk_020EC2F0); - StringTemplate_SetPlayerName(v0->unk_20, 0, SaveData_GetTrainerInfo(FieldSystem_SaveData(fieldSystem))); + StringTemplate_SetPlayerName(v0->unk_20, 0, SaveData_GetTrainerInfo(FieldSystem_GetSaveData(fieldSystem))); if (fieldSystem->location->mapId == 414) { sub_02052AA4(v0, 4, 0, 0); diff --git a/src/unk_02052C6C.c b/src/unk_02052C6C.c index 1e2076b952..480b946b64 100644 --- a/src/unk_02052C6C.c +++ b/src/unk_02052C6C.c @@ -10,7 +10,6 @@ #include "struct_defs/struct_0202DF8C.h" #include "struct_defs/struct_0203E234.h" #include "struct_defs/struct_0203E274.h" -#include "struct_defs/struct_02049FA8.h" #include "struct_defs/struct_02099F80.h" #include "field/field_system.h" @@ -22,6 +21,7 @@ #include "game_records.h" #include "gx_layers.h" #include "heap.h" +#include "location.h" #include "message.h" #include "message_util.h" #include "party.h" @@ -36,7 +36,6 @@ #include "unk_0200F174.h" #include "unk_0202631C.h" #include "unk_0202DF8C.h" -#include "unk_0203D178.h" #include "unk_0203D1B8.h" #include "unk_020508D4.h" #include "unk_02054884.h" @@ -203,8 +202,8 @@ void sub_02052E58(TaskManager *param0) v7 = Party_GetFromSavedata(fieldSystem->saveData); Party_GiveChampionRibbons(v7); - sub_0203D178(v1); - sub_0203D190(v2); + SetPlayerStartLocation(v1); + SetPlayerFirstRespawnLocation(v2); sub_0206AD9C(v3); sub_0206A944(v3); TrainerInfo_SetMainStoryCleared(v4); diff --git a/src/unk_020553DC.c b/src/unk_020553DC.c index 6ba8b25465..8f3cfb52f3 100644 --- a/src/unk_020553DC.c +++ b/src/unk_020553DC.c @@ -5,11 +5,11 @@ #include "struct_decls/struct_0203A790_decl.h" #include "struct_decls/struct_0205E884_decl.h" -#include "struct_defs/struct_02049FA8.h" #include "field/field_system.h" #include "field_overworld_state.h" +#include "location.h" #include "map_header.h" #include "player_avatar.h" #include "pokeradar.h" diff --git a/src/unk_02055808.c b/src/unk_02055808.c index 5ae0fb00cb..61f6c4fffe 100644 --- a/src/unk_02055808.c +++ b/src/unk_02055808.c @@ -16,7 +16,7 @@ static BOOL sub_02055808(TaskManager *param0) { FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); - if (!sub_0203CD4C(fieldSystem)) { + if (!FieldSystem_HasParentProcess(fieldSystem)) { return 1; } @@ -27,12 +27,12 @@ void FieldTask_FinishFieldMap(TaskManager *param0) { FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); - if (!sub_0203CD4C(fieldSystem)) { + if (!FieldSystem_HasParentProcess(fieldSystem)) { GF_ASSERT(FALSE); return; } - sub_0203CD44(fieldSystem); + FieldSystem_FlagNotRunningFieldMap(fieldSystem); FieldTask_Start(param0, sub_02055808, NULL); } @@ -51,7 +51,7 @@ void FieldTask_StartFieldMap(TaskManager *param0) { FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); - if (sub_0203CD4C(fieldSystem)) { + if (FieldSystem_HasParentProcess(fieldSystem)) { GF_ASSERT(FALSE); return; } @@ -73,7 +73,7 @@ void sub_020558AC(TaskManager *param0) { FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); - if (!sub_0203CD4C(fieldSystem)) { + if (!FieldSystem_HasParentProcess(fieldSystem)) { GF_ASSERT(FALSE); return; } @@ -88,7 +88,7 @@ void sub_020558F0(TaskManager *param0) { FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); - if (!sub_0203CD4C(fieldSystem)) { + if (!FieldSystem_HasParentProcess(fieldSystem)) { GF_ASSERT(FALSE); return; } diff --git a/src/unk_020559DC.c b/src/unk_020559DC.c index 2c4175b376..4975186df0 100644 --- a/src/unk_020559DC.c +++ b/src/unk_020559DC.c @@ -5,7 +5,6 @@ #include "struct_decls/struct_0202440C_decl.h" #include "struct_decls/struct_party_decl.h" -#include "struct_defs/struct_02055BA8.h" #include "field/field_system.h" #include "savedata/save_table.h" @@ -14,11 +13,11 @@ #include "inlines.h" #include "party.h" #include "pokemon.h" +#include "record_mixed_rng.h" #include "rtc.h" #include "script_manager.h" -#include "unk_02025CB0.h" +#include "system_data.h" #include "unk_0202854C.h" -#include "unk_0202B37C.h" #include "unk_0202C858.h" #include "unk_0202D7A8.h" #include "unk_0202E2CC.h" @@ -31,16 +30,16 @@ static void sub_02055AC0(FieldSystem *fieldSystem, s32 param1); static void sub_02055B64(FieldSystem *fieldSystem, s32 param1, const RTCTime *param2); -static void sub_02055A14(FieldSystem *fieldSystem, UnkStruct_02055BA8 *param1, const RTCDate *param2); -static void inline_020559DC(FieldSystem *fieldSystem, UnkStruct_02055BA8 *param1, const RTCDate *param2, const RTCTime *param3); +static void sub_02055A14(FieldSystem *fieldSystem, GameTime *param1, const RTCDate *param2); +static void inline_020559DC(FieldSystem *fieldSystem, GameTime *param1, const RTCDate *param2, const RTCTime *param3); void sub_020559DC(FieldSystem *fieldSystem) { RTCDate v0; RTCTime v1; - UnkStruct_02055BA8 *v2 = sub_02025CD8(fieldSystem->saveData); + GameTime *v2 = SaveData_GetGameTime(fieldSystem->saveData); - if (v2->unk_00 == 0) { + if (v2->canary == FALSE) { return; } @@ -50,51 +49,51 @@ void sub_020559DC(FieldSystem *fieldSystem) inline_020559DC(fieldSystem, v2, &v0, &v1); } -static void sub_02055A14(FieldSystem *fieldSystem, UnkStruct_02055BA8 *param1, const RTCDate *param2) +static void sub_02055A14(FieldSystem *fieldSystem, GameTime *param1, const RTCDate *param2) { s32 v0; v0 = RTC_ConvertDateToDay(param2); - if (v0 < param1->unk_20) { - param1->unk_20 = v0; - } else if (v0 > param1->unk_20) { - sub_02055AC0(fieldSystem, v0 - param1->unk_20); - param1->unk_20 = v0; + if (v0 < param1->day) { + param1->day = v0; + } else if (v0 > param1->day) { + sub_02055AC0(fieldSystem, v0 - param1->day); + param1->day = v0; } } -static void inline_020559DC(FieldSystem *fieldSystem, UnkStruct_02055BA8 *param1, const RTCDate *param2, const RTCTime *param3) +static void inline_020559DC(FieldSystem *fieldSystem, GameTime *param1, const RTCDate *param2, const RTCTime *param3) { s64 v0, v1; s32 v2; v0 = RTC_ConvertDateTimeToSecond(param2, param3); - v1 = RTC_ConvertDateTimeToSecond(¶m1->unk_04, ¶m1->unk_14); + v1 = RTC_ConvertDateTimeToSecond(¶m1->date, ¶m1->time); if (v0 < v1) { - param1->unk_04 = *param2; - param1->unk_14 = *param3; + param1->date = *param2; + param1->time = *param3; } else { v2 = (v0 - v1) / 60; if (v2 > 0) { - sub_02025DC8(param1, v2); + GameTime_DecrementPenalty(param1, v2); sub_02055B64(fieldSystem, v2, param3); - param1->unk_04 = *param2; - param1->unk_14 = *param3; + param1->date = *param2; + param1->time = *param3; } } } static void sub_02055AC0(FieldSystem *fieldSystem, s32 param1) { - sub_02028658(FieldSystem_SaveData(fieldSystem), param1); + sub_02028658(FieldSystem_GetSaveData(fieldSystem), param1); sub_0203F1FC(fieldSystem); sub_0206C2D0(fieldSystem->saveData, param1); - sub_0202B3D8(sub_0202B4A0(fieldSystem->saveData), param1); - sub_0202D80C(sub_0202D834(fieldSystem->saveData), sub_0202B428(sub_0202B4A0(fieldSystem->saveData))); + RecordMixedRNG_AdvanceEntries(SaveData_GetRecordMixedRNG(fieldSystem->saveData), param1); + sub_0202D80C(sub_0202D834(fieldSystem->saveData), RecordMixedRNG_GetRand(SaveData_GetRecordMixedRNG(fieldSystem->saveData))); { Party *v0; @@ -152,61 +151,61 @@ static void sub_02055B64(FieldSystem *fieldSystem, s32 param1, const RTCTime *pa int sub_02055BA8(const FieldSystem *fieldSystem) { - UnkStruct_02055BA8 *v0 = sub_02025CD8(fieldSystem->saveData); - return TimeOfDayForHour(v0->unk_14.hour); + GameTime *v0 = SaveData_GetGameTime(fieldSystem->saveData); + return TimeOfDayForHour(v0->time.hour); } int sub_02055BB8(const FieldSystem *fieldSystem) { - UnkStruct_02055BA8 *v0 = sub_02025CD8(fieldSystem->saveData); - return v0->unk_04.month; + GameTime *v0 = SaveData_GetGameTime(fieldSystem->saveData); + return v0->date.month; } int sub_02055BC4(const FieldSystem *fieldSystem) { - UnkStruct_02055BA8 *v0 = sub_02025CD8(fieldSystem->saveData); - return v0->unk_04.day; + GameTime *v0 = SaveData_GetGameTime(fieldSystem->saveData); + return v0->date.day; } int sub_02055BD0(const FieldSystem *fieldSystem) { - UnkStruct_02055BA8 *v0 = sub_02025CD8(fieldSystem->saveData); - return v0->unk_04.week; + GameTime *v0 = SaveData_GetGameTime(fieldSystem->saveData); + return v0->date.week; } int sub_02055BDC(const FieldSystem *fieldSystem) { - UnkStruct_02055BA8 *v0 = sub_02025CD8(fieldSystem->saveData); - return v0->unk_14.hour; + GameTime *v0 = SaveData_GetGameTime(fieldSystem->saveData); + return v0->time.hour; } int sub_02055BE8(const FieldSystem *fieldSystem) { - UnkStruct_02055BA8 *v0 = sub_02025CD8(fieldSystem->saveData); - return v0->unk_14.minute; + GameTime *v0 = SaveData_GetGameTime(fieldSystem->saveData); + return v0->time.minute; } void sub_02055BF4(const FieldSystem *fieldSystem, RTCDate *param1, RTCTime *param2) { - UnkStruct_02055BA8 *v0 = sub_02025CD8(fieldSystem->saveData); - RTC_ConvertSecondToDateTime(param1, param2, v0->unk_24); + GameTime *v0 = SaveData_GetGameTime(fieldSystem->saveData); + RTC_ConvertSecondToDateTime(param1, param2, v0->startTimestamp); } void sub_02055C10(const FieldSystem *fieldSystem, RTCDate *param1, RTCTime *param2) { - UnkStruct_02055BA8 *v0 = sub_02025CD8(fieldSystem->saveData); - RTC_ConvertSecondToDateTime(param1, param2, v0->unk_2C); + GameTime *v0 = SaveData_GetGameTime(fieldSystem->saveData); + RTC_ConvertSecondToDateTime(param1, param2, v0->playTimestamp); } void sub_02055C2C(const FieldSystem *fieldSystem) { - UnkStruct_02055BA8 *v0 = sub_02025CD8(fieldSystem->saveData); + GameTime *v0 = SaveData_GetGameTime(fieldSystem->saveData); - v0->unk_2C = GetTimestamp(); + v0->playTimestamp = GetTimestamp(); } BOOL sub_02055C40(FieldSystem *fieldSystem) { - UnkStruct_02055BA8 *v0 = sub_02025CD8(fieldSystem->saveData); - return sub_02025DB8(v0); + GameTime *v0 = SaveData_GetGameTime(fieldSystem->saveData); + return GameTime_HasPenalty(v0); } diff --git a/src/unk_02055C50.c b/src/unk_02055C50.c index 6480fc8c7d..ad3e9b59c1 100644 --- a/src/unk_02055C50.c +++ b/src/unk_02055C50.c @@ -3,11 +3,9 @@ #include #include -#include "struct_decls/struct_02027854_decl.h" #include "struct_decls/struct_020508D4_decl.h" #include "struct_decls/struct_02055CBC_decl.h" #include "struct_decls/struct_02061AB4_decl.h" -#include "struct_defs/struct_02027BF4.h" #include "field/field_system.h" #include "field/field_system_sub2_t.h" @@ -17,6 +15,7 @@ #include "overlay005/struct_ov5_021DF47C_decl.h" #include "bag.h" +#include "berry_patches.h" #include "core_sys.h" #include "easy3d.h" #include "heap.h" @@ -25,7 +24,6 @@ #include "savedata_misc.h" #include "sys_task_manager.h" #include "unk_0201CED8.h" -#include "unk_02027B70.h" #include "unk_020508D4.h" #include "unk_02054D00.h" #include "unk_020655F4.h" @@ -34,7 +32,7 @@ struct UnkStruct_02055CBC_t { int unk_00; - UnkStruct_02027BF4 *unk_04; + BerryGrowthData *unk_04; NNSG3dRenderObj unk_08; NNSG3dResMdl *unk_5C; NNSG3dResFileHeader *unk_60; @@ -94,7 +92,7 @@ UnkStruct_02055CBC *sub_02055C8C(FieldSystem *fieldSystem, int param1) MI_CpuClear8(v0, sizeof(UnkStruct_02055CBC)); v0->unk_00 = param1; - v0->unk_04 = sub_02027BF4(param1); + v0->unk_04 = BerryGrowthData_Init(param1); sub_02055D14(fieldSystem, v0); return v0; @@ -109,18 +107,18 @@ void sub_02055CBC(UnkStruct_02055CBC *param0) void sub_02055CD4(FieldSystem *fieldSystem, int param1) { - UnkStruct_02027854 *v0; - UnkStruct_02027BF4 *v1; + BerryPatch *v0; + BerryGrowthData *v1; if (fieldSystem->unk_04 == NULL) { - v1 = sub_02027BF4(11); - v0 = sub_02027854(fieldSystem->saveData); - sub_02027EAC(v0, v1, param1); + v1 = BerryGrowthData_Init(11); + v0 = MiscSaveBlock_GetBerryPatches(fieldSystem->saveData); + BerryPatches_ElapseMinutes(v0, v1, param1); Heap_FreeToHeap(v1); } else { v1 = fieldSystem->unk_04->unk_18->unk_04; - v0 = sub_02027854(fieldSystem->saveData); - sub_02027EAC(v0, v1, param1); + v0 = MiscSaveBlock_GetBerryPatches(fieldSystem->saveData); + BerryPatches_ElapseMinutes(v0, v1, param1); } } @@ -158,13 +156,13 @@ void sub_02055D94(FieldSystem *fieldSystem) { int v0 = 0; MapObject *v1; - UnkStruct_02027854 *v2 = sub_02027854(fieldSystem->saveData); + BerryPatch *v2 = MiscSaveBlock_GetBerryPatches(fieldSystem->saveData); while (sub_020625B0(fieldSystem->mapObjMan, &v1, &v0, (1 << 0)) == 1) { if (sub_020677F4(sub_02062920(v1)) == 1) { if (sub_02055D54(fieldSystem, MapObject_PosVector(v1))) { int v3 = sub_020629D8(v1, 0); - sub_02027D90(v2, v3, 1); + BerryPatches_SetIsPatchGrowing(v2, v3, 1); } } } @@ -173,14 +171,14 @@ void sub_02055D94(FieldSystem *fieldSystem) BOOL sub_02055E00(FieldSystem *fieldSystem, MapObject *param1) { int v0, v1, v2; - UnkStruct_02027854 *v3 = sub_02027854(fieldSystem->saveData); + BerryPatch *v3 = MiscSaveBlock_GetBerryPatches(fieldSystem->saveData); v0 = sub_020629D8(param1, 0); - v2 = sub_02027D10(v3, v0); - v1 = sub_02027DB4(v3, v0); + v2 = BerryPatches_GetPatchBerryID(v3, v0); + v1 = BerryPatches_GetPatchYield(v3, v0); - sub_0206D914(fieldSystem, sub_02055C50(v2), sub_02027D34(v3, v0), v1); - sub_02027DC0(v3, v0); + sub_0206D914(fieldSystem, sub_02055C50(v2), BerryPatches_GetPatchYieldRating(v3, v0), v1); + BerryPatches_HarvestPatch(v3, v0); sub_02067834(param1); return Bag_TryAddItem(SaveData_GetBag(fieldSystem->saveData), sub_02055C50(v2), v1, 4); @@ -189,82 +187,82 @@ BOOL sub_02055E00(FieldSystem *fieldSystem, MapObject *param1) void sub_02055E80(FieldSystem *fieldSystem, MapObject *param1, u16 param2) { int v0; - UnkStruct_02027854 *v1 = sub_02027854(fieldSystem->saveData); + BerryPatch *v1 = MiscSaveBlock_GetBerryPatches(fieldSystem->saveData); v0 = sub_020629D8(param1, 0); - sub_02027DA8(v1, v0, sub_02055C80(param2)); + BerryPatches_SetPatchMulchType(v1, v0, sub_02055C80(param2)); } void sub_02055EAC(FieldSystem *fieldSystem, MapObject *param1, u16 param2) { int v0; - UnkStruct_02027854 *v1 = sub_02027854(fieldSystem->saveData); + BerryPatch *v1 = MiscSaveBlock_GetBerryPatches(fieldSystem->saveData); v0 = sub_020629D8(param1, 0); - sub_02027D40(v1, v0, fieldSystem->unk_04->unk_18->unk_04, sub_02055C60(param2)); + BerryPatches_PlantInPatch(v1, v0, fieldSystem->unk_04->unk_18->unk_04, sub_02055C60(param2)); } void sub_02055EE0(FieldSystem *fieldSystem, MapObject *param1) { int v0; - UnkStruct_02027854 *v1 = sub_02027854(fieldSystem->saveData); + BerryPatch *v1 = MiscSaveBlock_GetBerryPatches(fieldSystem->saveData); v0 = sub_020629D8(param1, 0); - sub_02027D78(v1, v0); + BerryPatches_ResetPatchMoisture(v1, v0); } int sub_02055F00(const FieldSystem *fieldSystem, const MapObject *param1) { int v0; - UnkStruct_02027854 *v1 = sub_02027854(fieldSystem->saveData); + BerryPatch *v1 = MiscSaveBlock_GetBerryPatches(fieldSystem->saveData); v0 = sub_020629D8(param1, 0); - return sub_02027D04(v1, v0); + return BerryPatches_GetPatchGrowthStage(v1, v0); } int sub_02055F20(const FieldSystem *fieldSystem, const MapObject *param1) { int v0; - UnkStruct_02027854 *v1 = sub_02027854(fieldSystem->saveData); + BerryPatch *v1 = MiscSaveBlock_GetBerryPatches(fieldSystem->saveData); v0 = sub_020629D8(param1, 0); - return sub_02027D10(v1, v0); + return BerryPatches_GetPatchBerryID(v1, v0); } u16 sub_02055F40(const FieldSystem *fieldSystem, const MapObject *param1) { int v0; - UnkStruct_02027854 *v1 = sub_02027854(fieldSystem->saveData); + BerryPatch *v1 = MiscSaveBlock_GetBerryPatches(fieldSystem->saveData); v0 = sub_020629D8(param1, 0); - return sub_02055C50(sub_02027D10(v1, v0)); + return sub_02055C50(BerryPatches_GetPatchBerryID(v1, v0)); } u16 sub_02055F64(const FieldSystem *fieldSystem, const MapObject *param1) { int v0; - UnkStruct_02027854 *v1 = sub_02027854(fieldSystem->saveData); + BerryPatch *v1 = MiscSaveBlock_GetBerryPatches(fieldSystem->saveData); v0 = sub_020629D8(param1, 0); - return sub_02055C70(sub_02027D9C(v1, v0)); + return sub_02055C70(BerryPatches_GetPatchMulchType(v1, v0)); } int sub_02055F88(const FieldSystem *fieldSystem, const MapObject *param1) { int v0; - UnkStruct_02027854 *v1 = sub_02027854(fieldSystem->saveData); + BerryPatch *v1 = MiscSaveBlock_GetBerryPatches(fieldSystem->saveData); v0 = sub_020629D8(param1, 0); - return sub_02027D18(v1, v0); + return BerryPatches_GetPatchMoisture(v1, v0); } int sub_02055FA8(const FieldSystem *fieldSystem, const MapObject *param1) { int v0; - UnkStruct_02027854 *v1 = sub_02027854(fieldSystem->saveData); + BerryPatch *v1 = MiscSaveBlock_GetBerryPatches(fieldSystem->saveData); v0 = sub_020629D8(param1, 0); - return sub_02027DB4(v1, v0); + return BerryPatches_GetPatchYield(v1, v0); } u32 sub_02055FC8(const FieldSystem *fieldSystem, const MapObject *param1) diff --git a/src/unk_02056B30.c b/src/unk_02056B30.c index cd3d5be2cf..0804be2c92 100644 --- a/src/unk_02056B30.c +++ b/src/unk_02056B30.c @@ -5,14 +5,13 @@ #include "struct_decls/struct_020508D4_decl.h" #include "struct_decls/struct_02061AB4_decl.h" -#include "struct_defs/struct_02049FA8.h" #include "field/field_system.h" #include "field/field_system_sub2_t.h" #include "functypes/funcptr_020EC560.h" #include "functypes/funcptr_020EC57C.h" +#include "overlay005/fieldmap.h" #include "overlay005/hblank_system.h" -#include "overlay005/ov5_021D0D80.h" #include "overlay005/ov5_021D431C.h" #include "overlay005/ov5_021DD6FC.h" #include "overlay005/struct_ov5_021D432C_decl.h" @@ -22,6 +21,7 @@ #include "field_map_change.h" #include "heap.h" #include "inlines.h" +#include "location.h" #include "map_header.h" #include "map_object.h" #include "player_avatar.h" diff --git a/src/unk_0205A0D8.c b/src/unk_0205A0D8.c index 94e5d5e98d..bc3f95b8ed 100644 --- a/src/unk_0205A0D8.c +++ b/src/unk_0205A0D8.c @@ -11,7 +11,7 @@ #include "field/field_system.h" #include "functypes/funcptr_0205AB10.h" -#include "overlay005/ov5_021D0D80.h" +#include "overlay005/fieldmap.h" #include "bag.h" #include "bg_window.h" @@ -144,7 +144,7 @@ static void sub_0205A0D8(UnkStruct_0205A0D8 *param0, FieldSystem *fieldSystem, P v0->ribbons = sub_0202D79C(v1); PokemonSummary_FlagVisiblePages(v0, v2); - sub_0203CD84(fieldSystem, &Unk_020F410C, v0); + FieldSystem_StartChildProcess(fieldSystem, &Unk_020F410C, v0); param0->unk_00 = v0; } @@ -178,7 +178,7 @@ static void sub_0205A164(UnkStruct_0205A0D8 *param0, int param1) v1->unk_2C[v0] = param0->unk_3D[v0]; } - sub_0203CD84(param0->fieldSystem, &Unk_020F1E88, v1); + FieldSystem_StartChildProcess(param0->fieldSystem, &Unk_020F1E88, v1); param0->unk_04 = v1; } @@ -1095,7 +1095,7 @@ void sub_0205B2D4(FieldSystem *fieldSystem) v4->unk_28 = 0; FieldTask_Set(fieldSystem, sub_0205B140, v4); - sub_0203D128(); + FieldSystem_PauseProcessing(); break; } } diff --git a/src/unk_0205B33C.c b/src/unk_0205B33C.c index cf6c3b48fb..b3dacd9d1d 100644 --- a/src/unk_0205B33C.c +++ b/src/unk_0205B33C.c @@ -150,7 +150,7 @@ static UnkStruct_0205B43C *sub_0205B3A0(FieldSystem *fieldSystem) return NULL; } - v1 = FieldSystem_SaveData(fieldSystem); + v1 = FieldSystem_GetSaveData(fieldSystem); sub_020369EC(v1); v2 = (UnkStruct_0205B43C *)Heap_AllocFromHeap(31, sizeof(UnkStruct_0205B43C)); diff --git a/src/unk_02068344.c b/src/unk_02068344.c index df9287974b..9f4d4c25e7 100644 --- a/src/unk_02068344.c +++ b/src/unk_02068344.c @@ -66,7 +66,7 @@ void sub_02068344(FieldSystem *fieldSystem) int v0; UnkStruct_02027860 *v1; - v1 = sub_02027860(FieldSystem_SaveData(fieldSystem)); + v1 = sub_02027860(FieldSystem_GetSaveData(fieldSystem)); v0 = sub_02027F80(v1); if (v0 == 0) { @@ -81,7 +81,7 @@ void sub_02068368(FieldSystem *fieldSystem) int v0; UnkStruct_02027860 *v1; - v1 = sub_02027860(FieldSystem_SaveData(fieldSystem)); + v1 = sub_02027860(FieldSystem_GetSaveData(fieldSystem)); v0 = sub_02027F80(v1); if (v0 == 0) { @@ -98,7 +98,7 @@ BOOL sub_02068390(FieldSystem *fieldSystem, const int param1, const int param2, int v0; UnkStruct_02027860 *v1; - v1 = sub_02027860(FieldSystem_SaveData(fieldSystem)); + v1 = sub_02027860(FieldSystem_GetSaveData(fieldSystem)); v0 = sub_02027F80(v1); if (v0 == 0) { diff --git a/src/unk_020683F4.c b/src/unk_020683F4.c index edc2b71924..21b02046dc 100644 --- a/src/unk_020683F4.c +++ b/src/unk_020683F4.c @@ -15,7 +15,7 @@ #include "field/field_system.h" #include "functypes/funcptr_0203BC5C.h" #include "functypes/funcptr_02069238.h" -#include "overlay005/ov5_021D0D80.h" +#include "overlay005/fieldmap.h" #include "overlay005/ov5_021DFB54.h" #include "overlay005/ov5_021F007C.h" #include "overlay005/ov5_021F08CC.h" @@ -351,7 +351,7 @@ static void sub_02068630(UnkStruct_02068630 *param0, const UnkStruct_020684D0 *p v2->unk_24 = param0->unk_04; v2->unk_22 = param0->unk_06; - sub_0203CD84(fieldSystem, &Unk_020F1E88, v2); + FieldSystem_StartChildProcess(fieldSystem, &Unk_020F1E88, v2); v1->unk_25C = v2; sub_0203B674(v1, sub_0203B7C0); } @@ -604,7 +604,7 @@ static void sub_02068A34(UnkStruct_02068630 *param0, const UnkStruct_020684D0 *p v2->unk_22 = param0->unk_06; v2->unk_26 = Item_MoveForTMHM(param0->unk_04); - sub_0203CD84(fieldSystem, &Unk_020F1E88, v2); + FieldSystem_StartChildProcess(fieldSystem, &Unk_020F1E88, v2); v1->unk_25C = v2; sub_0203B674(v1, sub_0203B7C0); } @@ -1003,7 +1003,7 @@ static void sub_02068FEC(UnkStruct_02068630 *param0, const UnkStruct_020684D0 *p v2->unk_24 = param0->unk_04; v2->unk_22 = param0->unk_06; - sub_0203CD84(fieldSystem, &Unk_020F1E88, v2); + FieldSystem_StartChildProcess(fieldSystem, &Unk_020F1E88, v2); v1->unk_25C = v2; sub_0203B674(v1, sub_0203B7C0); } diff --git a/src/unk_0206A8DC.c b/src/unk_0206A8DC.c index 4e3ed5e3ca..95d3c3653f 100644 --- a/src/unk_0206A8DC.c +++ b/src/unk_0206A8DC.c @@ -46,13 +46,13 @@ static BOOL sub_0206A8F4(VarsFlags *param0, int param1, u32 param2) return 0; } -void sub_0206A92C(VarsFlags *param0) +void VarsFlags_SetBagAvailable(VarsFlags *param0) { sub_0206A8DC(param0, (2400 + 0)); return; } -BOOL sub_0206A938(VarsFlags *param0) +BOOL VarsFlags_CheckBagAvailable(VarsFlags *param0) { return sub_0206A8EC(param0, (2400 + 0)); } diff --git a/src/unk_0206AFE0.c b/src/unk_0206AFE0.c index e5ca7462c2..f255f4352b 100644 --- a/src/unk_0206AFE0.c +++ b/src/unk_0206AFE0.c @@ -4,12 +4,12 @@ #include #include "struct_decls/struct_0203A790_decl.h" -#include "struct_defs/struct_02049FA8.h" #include "field_overworld_state.h" +#include "location.h" +#include "record_mixed_rng.h" #include "savedata.h" #include "unk_0201D15C.h" -#include "unk_0202B37C.h" #include "unk_0206A8DC.h" #include "vars_flags.h" @@ -268,7 +268,7 @@ void sub_0206B2E4(SaveData *param0, u16 param1) VarsFlags *v0 = SaveData_GetVarsFlags(param0); u32 v1; - v1 = sub_0202B428(sub_0202B4A0(param0)); + v1 = RecordMixedRNG_GetRand(SaveData_GetRecordMixedRNG(param0)); v1 = v1 * 1103515245L + 12345; sub_0206B280(v0, v1); @@ -455,7 +455,7 @@ void sub_0206B514(SaveData *param0) u32 v0; VarsFlags *v1 = SaveData_GetVarsFlags(param0); FieldOverworldState *v2 = SaveData_GetFieldOverworldState(param0); - Location *location = sub_0203A720(v2); + Location *location = FieldOverworldState_GetPlayerLocation(v2); if ((location->mapId != 457) && (location->mapId != 464)) { sub_0206AF90(v1); diff --git a/src/unk_0206B70C.c b/src/unk_0206B70C.c index da6ce11bb8..c92848ab5b 100644 --- a/src/unk_0206B70C.c +++ b/src/unk_0206B70C.c @@ -5,7 +5,6 @@ #include "struct_decls/struct_0203A790_decl.h" #include "struct_defs/struct_0203D8AC.h" -#include "struct_defs/struct_02049FA8.h" #include "struct_defs/struct_020556C4.h" #include "struct_defs/union_0206B878.h" @@ -15,6 +14,7 @@ #include "field_system.h" #include "heap.h" #include "inlines.h" +#include "location.h" #include "map_header.h" #include "player_avatar.h" #include "save_player.h" @@ -85,7 +85,7 @@ void sub_0206B70C(FieldSystem *fieldSystem, UnkStruct_0203D8AC *param1, int para z = Player_GetZPos(fieldSystem->playerAvatar); int v11 = 10 - 1; - Location *location = sub_0203A720(v9); + Location *location = FieldOverworldState_GetPlayerLocation(v9); v6 = location->mapId; @@ -109,7 +109,7 @@ void sub_0206B70C(FieldSystem *fieldSystem, UnkStruct_0203D8AC *param1, int para param1->unk_04 = v10->z; } - v0 = SaveData_GetTrainerInfo(FieldSystem_SaveData(fieldSystem)); + v0 = SaveData_GetTrainerInfo(FieldSystem_GetSaveData(fieldSystem)); param1->unk_0C = TrainerInfo_Gender(v0); v7 = sub_0203A76C(SaveData_GetFieldOverworldState(fieldSystem->saveData)); v2 = (v7->unk_00 - 2 + 6) % 6; diff --git a/src/unk_0206B9D8.c b/src/unk_0206B9D8.c index 57bb3012af..073014a71e 100644 --- a/src/unk_0206B9D8.c +++ b/src/unk_0206B9D8.c @@ -22,11 +22,11 @@ #include "heap.h" #include "party.h" #include "pokemon_summary_app.h" +#include "record_mixed_rng.h" #include "save_player.h" #include "savedata.h" #include "script_manager.h" #include "unk_0202854C.h" -#include "unk_0202B37C.h" #include "unk_0202D05C.h" #include "unk_0202D778.h" #include "unk_0203061C.h" @@ -91,7 +91,7 @@ static int sub_0206B9D8(UnkStruct_0206B9D8 *param0, FieldSystem *fieldSystem, in v2->unk_2C[v0] = param0->unk_0E[v0]; } - sub_0203CD84(fieldSystem, &Unk_020F1E88, v2); + FieldSystem_StartChildProcess(fieldSystem, &Unk_020F1E88, v2); *(param0->unk_14) = v2; return 1; @@ -152,7 +152,7 @@ static int sub_0206BAE0(UnkStruct_0206B9D8 *param0, FieldSystem *fieldSystem, in PokemonSummary_FlagVisiblePages(v0, v2); PokemonSummary_SetPlayerProfile(v0, SaveData_GetTrainerInfo(v1)); - sub_0203CD84(fieldSystem, &Unk_020F410C, v0); + FieldSystem_StartChildProcess(fieldSystem, &Unk_020F410C, v0); *(param0->unk_14) = v0; return 3; @@ -476,7 +476,7 @@ u32 sub_0206C008(SaveData *param0) { u32 v0; - v0 = sub_0202B428(sub_0202B4A0(param0)); + v0 = RecordMixedRNG_GetRand(SaveData_GetRecordMixedRNG(param0)); v0 = sub_0206BFFC(v0); sub_0202D470(sub_0202D750(param0), v0); diff --git a/src/unk_0206C0E8.c b/src/unk_0206C0E8.c index fdde946c84..889f37f23f 100644 --- a/src/unk_0206C0E8.c +++ b/src/unk_0206C0E8.c @@ -5,7 +5,6 @@ #include "struct_decls/struct_020508D4_decl.h" #include "struct_decls/struct_02061AB4_decl.h" -#include "struct_defs/struct_02049FA8.h" #include "field/field_system.h" #include "field/field_system_sub2_t.h" @@ -17,6 +16,7 @@ #include "core_sys.h" #include "field_map_change.h" #include "heap.h" +#include "location.h" #include "map_object.h" #include "player_avatar.h" #include "unk_02005474.h" diff --git a/src/unk_0206CCB0.c b/src/unk_0206CCB0.c index e9d442e02a..12fb90045a 100644 --- a/src/unk_0206CCB0.c +++ b/src/unk_0206CCB0.c @@ -8,10 +8,8 @@ #include "struct_decls/pokedexdata_decl.h" #include "struct_decls/struct_0202440C_decl.h" -#include "struct_decls/struct_02027854_decl.h" #include "struct_decls/struct_02029C68_decl.h" #include "struct_decls/struct_0202A750_decl.h" -#include "struct_decls/struct_0202B4A0_decl.h" #include "struct_decls/struct_party_decl.h" #include "struct_defs/struct_0202D7B0.h" #include "struct_defs/struct_0202E7D8.h" @@ -34,6 +32,7 @@ #include "savedata/save_table.h" #include "bag.h" +#include "berry_patches.h" #include "charcode_util.h" #include "field_system.h" #include "heap.h" @@ -42,6 +41,7 @@ #include "message.h" #include "party.h" #include "pokemon.h" +#include "record_mixed_rng.h" #include "roaming_pokemon.h" #include "save_player.h" #include "savedata.h" @@ -51,9 +51,7 @@ #include "trainer_info.h" #include "unk_0201D15C.h" #include "unk_0202631C.h" -#include "unk_02027B70.h" #include "unk_020298BC.h" -#include "unk_0202B37C.h" #include "unk_0202D7A8.h" #include "unk_0202E2CC.h" #include "unk_0203A944.h" @@ -822,12 +820,12 @@ static void sub_0206D3E4(FieldSystem *fieldSystem, int param1) { UnkUnion_0206D1B8 v0; UnkStruct_0206D43C *v1 = &v0.val4; - UnkStruct_0202B4A0 *v2 = sub_0202B4A0(fieldSystem->saveData); + RecordMixedRNG *v2 = SaveData_GetRecordMixedRNG(fieldSystem->saveData); GF_ASSERT(sizeof(UnkUnion_0206D1B8) == 40); MI_CpuClearFast(&v0, 40); - CharCode_CopyNumChars(v1->unk_00, sub_0202B42C(v2, 1, 0), 10 + 1); + CharCode_CopyNumChars(v1->unk_00, RecordMixedRNG_GetEntryName(v2, 1, 0), 10 + 1); sub_0206CD70(fieldSystem, 2, param1, v1); } @@ -2044,12 +2042,12 @@ static const u8 Unk_020EFD34[] = { 0x5 }; -static int sub_0206E848(UnkStruct_0202B4A0 *param0) +static int sub_0206E848(RecordMixedRNG *param0) { int v0, v1; for (v0 = 0, v1 = 0; v0 < NELEMS(Unk_020EFD34); v0++) { - if (sub_0202B4AC(param0, Unk_020EFD34[v0])) { + if (RecordMixedRNG_IsEntryValid(param0, Unk_020EFD34[v0])) { v1++; } } @@ -2061,7 +2059,7 @@ static int sub_0206E870(FieldSystem *fieldSystem, StringTemplate *param1, UnkStr { int v0, v1, v2; int v3; - UnkStruct_0202B4A0 *v4 = sub_0202B4A0(fieldSystem->saveData); + RecordMixedRNG *v4 = SaveData_GetRecordMixedRNG(fieldSystem->saveData); v1 = sub_0206E848(v4); GF_ASSERT(v1 > 0); @@ -2073,7 +2071,7 @@ static int sub_0206E870(FieldSystem *fieldSystem, StringTemplate *param1, UnkStr } for (v0 = 0; v0 < NELEMS(Unk_020EFD34); v0++) { - if (sub_0202B4AC(v4, Unk_020EFD34[v0])) { + if (RecordMixedRNG_IsEntryValid(v4, Unk_020EFD34[v0])) { if (v1 == 0) { v2 = Unk_020EFD34[v0]; break; @@ -2100,7 +2098,7 @@ static int sub_0206E870(FieldSystem *fieldSystem, StringTemplate *param1, UnkStr static BOOL sub_0206E928(FieldSystem *fieldSystem, UnkStruct_ov6_022465F4 *param1) { - UnkStruct_0202B4A0 *v0 = sub_0202B4A0(fieldSystem->saveData); + RecordMixedRNG *v0 = SaveData_GetRecordMixedRNG(fieldSystem->saveData); if (sub_0206E848(v0) != 0) { return 1; @@ -2167,7 +2165,7 @@ static BOOL sub_0206EA0C(FieldSystem *fieldSystem, UnkStruct_ov6_022465F4 *param static int sub_0206EA10(FieldSystem *fieldSystem, StringTemplate *param1, UnkStruct_ov6_022465F4 *param2) { - TrainerInfo *v0 = SaveData_GetTrainerInfo(FieldSystem_SaveData(fieldSystem)); + TrainerInfo *v0 = SaveData_GetTrainerInfo(FieldSystem_GetSaveData(fieldSystem)); int v1 = fieldSystem->location->mapId; if ((v1 == 411) || ((v1 >= 412) && (v1 <= 417))) { @@ -2541,14 +2539,14 @@ static int sub_0206EBE8(FieldSystem *fieldSystem) static int sub_0206EC90(FieldSystem *fieldSystem, StringTemplate *param1, UnkStruct_ov6_022465F4 *param2) { - UnkStruct_02027854 *v0 = sub_02027854(fieldSystem->saveData); + BerryPatch *v0 = MiscSaveBlock_GetBerryPatches(fieldSystem->saveData); int v1, v2; v1 = sub_0206EBE8(fieldSystem); v2 = Unk_020F0074[v1 * 2 + 1]; StringTemplate_SetLocationName(param1, 0, MapHeader_GetMapLabelTextID(v2)); - switch (sub_02027D04(v0, v1)) { + switch (BerryPatches_GetPatchGrowthStage(v0, v1)) { case 5: return 36; case 4: @@ -2624,7 +2622,7 @@ static int sub_0206EDAC(FieldSystem *fieldSystem, StringTemplate *param1, UnkStr u16 v2, v3; u32 v4, v5; Strbuf *v6 = Strbuf_Init(22, 4); - TrainerInfo *v7 = SaveData_GetTrainerInfo(FieldSystem_SaveData(fieldSystem)); + TrainerInfo *v7 = SaveData_GetTrainerInfo(FieldSystem_GetSaveData(fieldSystem)); v1 = sub_0202D834(fieldSystem->saveData); v2 = (LCRNG_Next() % 29); diff --git a/src/unk_02070428.c b/src/unk_02070428.c index c8fe7f479a..3f880a6701 100644 --- a/src/unk_02070428.c +++ b/src/unk_02070428.c @@ -4,7 +4,6 @@ #include #include "struct_defs/struct_0202D7B0.h" -#include "struct_defs/struct_02049FA8.h" #include "struct_defs/struct_020556C4.h" #include "struct_defs/struct_0205EC34.h" @@ -13,6 +12,7 @@ #include "field_overworld_state.h" #include "inlines.h" #include "journal.h" +#include "location.h" #include "map_header.h" #include "roaming_pokemon.h" #include "save_player.h" diff --git a/src/unk_0207064C.c b/src/unk_0207064C.c index d673b32446..f7d2138782 100644 --- a/src/unk_0207064C.c +++ b/src/unk_0207064C.c @@ -4,13 +4,13 @@ #include #include "struct_decls/struct_020508D4_decl.h" -#include "struct_defs/struct_02049FA8.h" #include "field/field_system.h" #include "overlay006/ov6_02243258.h" #include "field_map_change.h" #include "heap.h" +#include "location.h" #include "player_avatar.h" #include "pokemon.h" #include "sys_task_manager.h" diff --git a/src/unk_0207160C.c b/src/unk_0207160C.c index fabed38615..fa2dbd3555 100644 --- a/src/unk_0207160C.c +++ b/src/unk_0207160C.c @@ -123,7 +123,7 @@ void sub_0207160C(FieldSystem *fieldSystem) const UnkStruct_020F03F4 *v4; fx32 v5; - v2 = sub_02027860(FieldSystem_SaveData(fieldSystem)); + v2 = sub_02027860(FieldSystem_GetSaveData(fieldSystem)); v3 = (UnkStruct_020716D4 *)sub_02027F6C(v2, 7); v4 = &Unk_020F03F4[v3->unk_02]; v5 = v4->unk_00[v3->unk_00]; @@ -162,7 +162,7 @@ void sub_020716D4(FieldSystem *fieldSystem) UnkStruct_02027860 *v0; UnkStruct_020716D4 *v1; - v0 = sub_02027860(FieldSystem_SaveData(fieldSystem)); + v0 = sub_02027860(FieldSystem_GetSaveData(fieldSystem)); sub_02027F5C(v0, 7); v1 = (UnkStruct_020716D4 *)sub_02027F6C(v0, 7); @@ -274,7 +274,7 @@ u8 sub_02071818(FieldSystem *fieldSystem) UnkStruct_02027860 *v0; UnkStruct_020716D4 *v1; - v0 = sub_02027860(FieldSystem_SaveData(fieldSystem)); + v0 = sub_02027860(FieldSystem_GetSaveData(fieldSystem)); v1 = (UnkStruct_020716D4 *)sub_02027F6C(v0, 7); if (v1->unk_04) { @@ -290,7 +290,7 @@ void sub_0207183C(FieldSystem *fieldSystem) UnkStruct_020716D4 *v1; UnkStruct_020718D8 *v2; - v0 = sub_02027860(FieldSystem_SaveData(fieldSystem)); + v0 = sub_02027860(FieldSystem_GetSaveData(fieldSystem)); v1 = (UnkStruct_020716D4 *)sub_02027F6C(v0, 7); if ((Unk_020F03F4[v1->unk_02].unk_10) && (v1->unk_00 == 1)) { diff --git a/src/unk_02071B10.c b/src/unk_02071B10.c index 6775510863..591af75dc1 100644 --- a/src/unk_02071B10.c +++ b/src/unk_02071B10.c @@ -54,7 +54,7 @@ void sub_02071B10(FieldSystem *fieldSystem) UnkStruct_02027860 *v0; UnkStruct_02071B10 *v1; - v0 = sub_02027860(FieldSystem_SaveData(fieldSystem)); + v0 = sub_02027860(FieldSystem_GetSaveData(fieldSystem)); sub_02027F5C(v0, 1); v1 = (UnkStruct_02071B10 *)sub_02027F6C(v0, 1); @@ -66,7 +66,7 @@ void sub_02071B30(FieldSystem *fieldSystem) UnkStruct_02027860 *v0; UnkStruct_02071B30 *v1; - v0 = sub_02027860(FieldSystem_SaveData(fieldSystem)); + v0 = sub_02027860(FieldSystem_GetSaveData(fieldSystem)); sub_02027F5C(v0, 3); v1 = (UnkStruct_02071B30 *)sub_02027F6C(v0, 3); @@ -88,7 +88,7 @@ void sub_02071B6C(FieldSystem *fieldSystem, const u8 param1) GF_ASSERT(param1 < 3); - v0 = sub_02027860(FieldSystem_SaveData(fieldSystem)); + v0 = sub_02027860(FieldSystem_GetSaveData(fieldSystem)); sub_02027F5C(v0, 5); v1 = (UnkStruct_02071B6C *)sub_02027F6C(v0, 5); @@ -121,7 +121,7 @@ void sub_02071BD0(FieldSystem *fieldSystem) UnkStruct_02027860 *v0; UnkStruct_02071BD0 *v1; - v0 = sub_02027860(FieldSystem_SaveData(fieldSystem)); + v0 = sub_02027860(FieldSystem_GetSaveData(fieldSystem)); sub_02027F5C(v0, 8); v1 = sub_02027F6C(v0, 8); @@ -133,7 +133,7 @@ void sub_02071BF8(FieldSystem *fieldSystem) UnkStruct_02027860 *v0; UnkStruct_02071BF8 *v1; - v0 = sub_02027860(FieldSystem_SaveData(fieldSystem)); + v0 = sub_02027860(FieldSystem_GetSaveData(fieldSystem)); sub_02027F5C(v0, 4); v1 = (UnkStruct_02071BF8 *)sub_02027F6C(v0, 4); @@ -145,7 +145,7 @@ void sub_02071C18(FieldSystem *fieldSystem) UnkStruct_02027860 *v0; UnkStruct_02071C18 *v1; - v0 = sub_02027860(FieldSystem_SaveData(fieldSystem)); + v0 = sub_02027860(FieldSystem_GetSaveData(fieldSystem)); sub_02027F5C(v0, 2); v1 = (UnkStruct_02071C18 *)sub_02027F6C(v0, 2); } @@ -155,7 +155,7 @@ void sub_02071C34(FieldSystem *fieldSystem) UnkStruct_02027860 *v0; UnkStruct_02071C34 *v1; - v0 = sub_02027860(FieldSystem_SaveData(fieldSystem)); + v0 = sub_02027860(FieldSystem_GetSaveData(fieldSystem)); sub_02027F5C(v0, 10); v1 = sub_02027F6C(v0, 10); @@ -167,7 +167,7 @@ void sub_02071C5C(FieldSystem *fieldSystem) UnkStruct_02027860 *v0; UnkStruct_02071C5C *v1; - v0 = sub_02027860(FieldSystem_SaveData(fieldSystem)); + v0 = sub_02027860(FieldSystem_GetSaveData(fieldSystem)); sub_02027F5C(v0, 9); v1 = sub_02027F6C(v0, 9); @@ -191,7 +191,7 @@ BOOL sub_02071CB4(FieldSystem *fieldSystem, int param1) { UnkStruct_02027860 *v0; - v0 = sub_02027860(FieldSystem_SaveData(fieldSystem)); + v0 = sub_02027860(FieldSystem_GetSaveData(fieldSystem)); if (param1 == sub_02027F80(v0)) { return 1; diff --git a/src/unk_02071CD0.c b/src/unk_02071CD0.c index 337b2ec48a..81f640a374 100644 --- a/src/unk_02071CD0.c +++ b/src/unk_02071CD0.c @@ -18,7 +18,7 @@ void sub_02071CD0(FieldSystem *fieldSystem) UnkStruct_02027860 *v1; UnkStruct_ov6_02242AF0 *v2; - v1 = sub_02027860(FieldSystem_SaveData(fieldSystem)); + v1 = sub_02027860(FieldSystem_GetSaveData(fieldSystem)); v0 = sub_02027F80(v1); if (v0 != 6) { diff --git a/src/unk_02071D40.c b/src/unk_02071D40.c index 7a2d151218..5191b6dd4b 100644 --- a/src/unk_02071D40.c +++ b/src/unk_02071D40.c @@ -51,7 +51,7 @@ void sub_02071D40(const u8 param0, const u8 param1, const u8 param2, const u8 pa GameRecords *v1; SaveData *v2; - v2 = FieldSystem_SaveData(fieldSystem); + v2 = FieldSystem_GetSaveData(fieldSystem); v0 = SaveData_GetTrainerInfo(v2); v1 = SaveData_GetGameRecordsPtr(v2); @@ -130,7 +130,7 @@ u8 sub_02071F28(FieldSystem *fieldSystem) SecretBaseRecord *v4; UnkStruct_0203068C *v5; - v1 = FieldSystem_SaveData(fieldSystem); + v1 = FieldSystem_GetSaveData(fieldSystem); v2 = SaveData_GetGameRecordsPtr(v1); v3 = SaveData_GetVarsFlags(v1); v4 = SaveData_SecretBaseRecord(v1); diff --git a/src/unk_020722AC.c b/src/unk_020722AC.c index e752500c50..5cf0b63254 100644 --- a/src/unk_020722AC.c +++ b/src/unk_020722AC.c @@ -203,7 +203,7 @@ void sub_020722AC(void *param0, int *param1) MI_CpuClear8(v0, sizeof(UnkStruct_02072334)); v0->unk_04 = param1; - v1 = FieldSystem_SaveData(param0); + v1 = FieldSystem_GetSaveData(param0); v0->fieldSystem = (FieldSystem *)param0; v0->unk_00 = 43; @@ -997,7 +997,7 @@ static void sub_020730B8(UnkStruct_02072334 *param0, u8 param1, BOOL param2) return; } - v1 = Party_GetFromSavedata(FieldSystem_SaveData(param0->fieldSystem)); + v1 = Party_GetFromSavedata(FieldSystem_GetSaveData(param0->fieldSystem)); v2 = Party_GetPokemonBySlotIndex(v1, param1); sub_020977E4(param0->unk_1AC, param0->unk_18, v2, param0->unk_00); @@ -1046,7 +1046,7 @@ static void sub_020731A4(UnkStruct_02072334 *param0) static void sub_020731F4(UnkStruct_02072334 *param0) { - param0->unk_170 = sub_0203D170(param0->fieldSystem); + param0->unk_170 = FieldSystem_GetBgConfig(param0->fieldSystem); LoadMessageBoxGraphics(param0->unk_170, 3, (1024 - (18 + 12)), 10, param0->unk_14, param0->unk_00); LoadStandardWindowGraphics(param0->unk_170, 3, (1024 - (18 + 12) - 9), 11, 0, param0->unk_00); @@ -1210,9 +1210,9 @@ static int sub_02073524(UnkStruct_02072334 *param0, int param1) v0 = Heap_AllocFromHeap(param0->unk_00, sizeof(PartyManagementData)); MI_CpuClear8(v0, sizeof(PartyManagementData)); - v0->unk_00 = Party_GetFromSavedata(FieldSystem_SaveData(param0->fieldSystem)); - v0->unk_04 = SaveData_GetBag(FieldSystem_SaveData(param0->fieldSystem)); - v0->unk_0C = SaveData_Options(FieldSystem_SaveData(param0->fieldSystem)); + v0->unk_00 = Party_GetFromSavedata(FieldSystem_GetSaveData(param0->fieldSystem)); + v0->unk_04 = SaveData_GetBag(FieldSystem_GetSaveData(param0->fieldSystem)); + v0->unk_0C = SaveData_Options(FieldSystem_GetSaveData(param0->fieldSystem)); v0->unk_08 = sub_02028430(param0->fieldSystem->saveData); v0->unk_21 = 0; v0->unk_20 = param1; @@ -1222,7 +1222,7 @@ static int sub_02073524(UnkStruct_02072334 *param0, int param1) v0->unk_22 = param0->unk_17; } - sub_0203CD84(param0->fieldSystem, &Unk_020F1E88, v0); + FieldSystem_StartChildProcess(param0->fieldSystem, &Unk_020F1E88, v0); param0->unk_1B4 = v0; param0->unk_12++; break; diff --git a/src/unk_0207DA28.c b/src/unk_0207DA28.c index 5ac14671d7..23e751ce8a 100644 --- a/src/unk_0207DA28.c +++ b/src/unk_0207DA28.c @@ -341,7 +341,7 @@ static void sub_0207DE04(UnkStruct_0207DE40 *param0, FieldSystem *fieldSystem, u param0->unk_10 = v0; - sub_0203CD84(fieldSystem, &Unk_020F1B88, v0); + FieldSystem_StartChildProcess(fieldSystem, &Unk_020F1B88, v0); } static u32 sub_0207DE40(UnkStruct_0207DE40 *param0) @@ -396,7 +396,7 @@ static UnkStruct_ov115_02260440 *sub_0207DE90(FieldSystem *fieldSystem, u32 para v0->unk_34 = fieldSystem->saveData; Overlay_LoadByID(FS_OVERLAY_ID(overlay114), 2); - sub_0203CD84(fieldSystem, &v1, v0); + FieldSystem_StartChildProcess(fieldSystem, &v1, v0); } return v0; } @@ -430,7 +430,7 @@ static UnkStruct_ov66_02231134 *sub_0207DEEC(FieldSystem *fieldSystem, u32 param v0->unk_34 = fieldSystem->saveData; Overlay_LoadByID(FS_OVERLAY_ID(overlay114), 2); - sub_0203CD84(fieldSystem, &v1, v0); + FieldSystem_StartChildProcess(fieldSystem, &v1, v0); } return v0; } @@ -466,7 +466,7 @@ static UnkStruct_ov117_02260440 *sub_0207DF40(FieldSystem *fieldSystem, u32 para v0->unk_34 = fieldSystem->saveData; Overlay_LoadByID(FS_OVERLAY_ID(overlay114), 2); - sub_0203CD84(fieldSystem, &v1, v0); + FieldSystem_StartChildProcess(fieldSystem, &v1, v0); } return v0; diff --git a/src/unk_02098218.c b/src/unk_02098218.c index 8621959f34..03f1624907 100644 --- a/src/unk_02098218.c +++ b/src/unk_02098218.c @@ -214,7 +214,7 @@ static BOOL sub_0209843C(TaskManager *param0) { Pokemon *v2 = v0->unk_0C.unk_00; - TrainerInfo *v3 = SaveData_GetTrainerInfo(FieldSystem_SaveData(fieldSystem)); + TrainerInfo *v3 = SaveData_GetTrainerInfo(FieldSystem_GetSaveData(fieldSystem)); int v4 = 6; int v5 = MapHeader_GetMapLabelTextID(fieldSystem->location->mapId); int v6 = 11; @@ -226,7 +226,7 @@ static BOOL sub_0209843C(TaskManager *param0) } { - sub_0202F180(FieldSystem_SaveData(fieldSystem), v0->unk_0C.unk_00); + sub_0202F180(FieldSystem_GetSaveData(fieldSystem), v0->unk_0C.unk_00); } if (v0->unk_04 == 1) { @@ -241,7 +241,7 @@ static BOOL sub_0209843C(TaskManager *param0) v9 = Pokemon_GetValue(v0->unk_0C.unk_00, MON_DATA_SPECIES, 0); - v0->unk_08 = sub_0208712C(11, 1, v9, 10, SaveData_Options(FieldSystem_SaveData(fieldSystem))); + v0->unk_08 = sub_0208712C(11, 1, v9, 10, SaveData_Options(FieldSystem_GetSaveData(fieldSystem))); v0->unk_08->unk_10 = Pokemon_GetValue(v0->unk_0C.unk_00, MON_DATA_GENDER, NULL); v0->unk_08->unk_08 = Pokemon_GetValue(v0->unk_0C.unk_00, MON_DATA_FORM, NULL); sub_02050A38(param0, &Unk_020F2DAC, v0->unk_08); @@ -253,7 +253,7 @@ static BOOL sub_0209843C(TaskManager *param0) { FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); - GameRecords *v11 = SaveData_GetGameRecordsPtr(FieldSystem_SaveData(fieldSystem)); + GameRecords *v11 = SaveData_GetGameRecordsPtr(FieldSystem_GetSaveData(fieldSystem)); GameRecords_IncrementRecordValue(v11, RECORD_UNK_049); } diff --git a/src/unk_020985E4.c b/src/unk_020985E4.c index 3a8f8815b7..ea069de5c6 100644 --- a/src/unk_020985E4.c +++ b/src/unk_020985E4.c @@ -8,7 +8,7 @@ #include "struct_defs/struct_0209862C.h" #include "field/field_system.h" -#include "overlay005/ov5_021D0D80.h" +#include "overlay005/fieldmap.h" #include "overlay100/ov100_021D0D80.h" #include "field_system.h" @@ -64,7 +64,7 @@ BOOL sub_0209862C(TaskManager *param0) FS_OVERLAY_ID(overlay100) }; - sub_0203CD84(fieldSystem, &v2, v1->unk_04); + FieldSystem_StartChildProcess(fieldSystem, &v2, v1->unk_04); v1->unk_00++; } break; diff --git a/src/unk_02099550.c b/src/unk_02099550.c index 7b0c291268..ecfe30817e 100644 --- a/src/unk_02099550.c +++ b/src/unk_02099550.c @@ -3,12 +3,11 @@ #include #include -#include "struct_defs/struct_0203CC84.h" - #include "overlay018/ov18_0221F800.h" #include "game_overlay.h" #include "heap.h" +#include "main.h" #include "overlay_manager.h" #include "savedata.h" @@ -63,7 +62,7 @@ void sub_020995C4(void) static int sub_020995D4(OverlayManager *param0, int *param1) { Heap_Create(3, 49, 0x41000); - sub_02099590(((UnkStruct_0203CC84 *)OverlayManager_Args(param0))->unk_08, 49); + sub_02099590(((ApplicationArgs *)OverlayManager_Args(param0))->saveData, 49); Heap_Destroy(49); OS_ResetSystem(0); diff --git a/src/unk_02099604.c b/src/unk_02099604.c index acb9868097..a4bf41133a 100644 --- a/src/unk_02099604.c +++ b/src/unk_02099604.c @@ -50,7 +50,7 @@ static void sub_0209964C(FieldSystem *fieldSystem, UnkStruct_ov82_0223B164 *para FS_OVERLAY_ID(overlay82) }; - sub_0203CD84(fieldSystem, &v0, param1); + FieldSystem_StartChildProcess(fieldSystem, &v0, param1); } } @@ -58,7 +58,7 @@ UnkStruct_ov82_0223B164 *sub_02099674(FieldSystem *fieldSystem, int param1, int { UnkStruct_ov82_0223B164 *v0; - v0 = sub_02099604(param1, FieldSystem_SaveData(fieldSystem), param2, fieldSystem->journal); + v0 = sub_02099604(param1, FieldSystem_GetSaveData(fieldSystem), param2, fieldSystem->journal); sub_0209964C(fieldSystem, v0); return v0; @@ -68,7 +68,7 @@ UnkStruct_ov82_0223B164 *sub_020996A0(FieldSystem *fieldSystem, int param1, BOOL { UnkStruct_ov82_0223B164 *v0; - v0 = sub_02099604(1, FieldSystem_SaveData(fieldSystem), param1, fieldSystem->journal); + v0 = sub_02099604(1, FieldSystem_GetSaveData(fieldSystem), param1, fieldSystem->journal); v0->unk_20 = 1; v0->unk_24 = param2; diff --git a/src/unk_02099DFC.c b/src/unk_02099DFC.c index 9d76a1f604..4d62cbf792 100644 --- a/src/unk_02099DFC.c +++ b/src/unk_02099DFC.c @@ -1,7 +1,6 @@ #include #include -#include "struct_defs/struct_0203CC84.h" #include "struct_defs/struct_02099F80.h" #include "bg_window.h" @@ -9,6 +8,7 @@ #include "font.h" #include "gx_layers.h" #include "heap.h" +#include "main.h" #include "menu.h" #include "message.h" #include "overlay_manager.h" @@ -16,7 +16,6 @@ #include "savedata.h" #include "strbuf.h" #include "text.h" -#include "unk_02000C88.h" #include "unk_020041CC.h" #include "unk_02005474.h" #include "unk_0200F174.h" @@ -38,7 +37,7 @@ typedef struct { void *unk_34; } UnkStruct_02099DFC; -void sub_02000EC4(FSOverlayID param0, const OverlayManagerTemplate *param1); +void EnqueueApplication(FSOverlayID param0, const OverlayManagerTemplate *param1); int sub_02099DFC(OverlayManager *param0, int *param1); int sub_02099E38(OverlayManager *param0, int *param1); int sub_02099F54(OverlayManager *param0, int *param1); @@ -50,7 +49,7 @@ static void sub_0209A0E0(UnkStruct_02099DFC *param0); static BOOL sub_0209A0F4(UnkStruct_02099DFC *param0); static BOOL sub_0209A200(UnkStruct_02099DFC *param0, u32 param1, int param2, int param3); -extern const OverlayManagerTemplate Unk_ov77_021D742C; +extern const OverlayManagerTemplate gTitleScreenOverlayTemplate; const OverlayManagerTemplate Unk_020F8A48 = { sub_02099DFC, @@ -91,7 +90,7 @@ int sub_02099DFC(OverlayManager *param0, int *param1) v0->unk_00 = v1; v0->unk_04 = 0; - v0->unk_30 = ((UnkStruct_0203CC84 *)OverlayManager_Args(param0))->unk_08; + v0->unk_30 = ((ApplicationArgs *)OverlayManager_Args(param0))->saveData; return 1; } diff --git a/src/unk_0209A2C4.c b/src/unk_0209A2C4.c index 44ce14f72d..d667c84f9e 100644 --- a/src/unk_0209A2C4.c +++ b/src/unk_0209A2C4.c @@ -1,7 +1,6 @@ #include #include -#include "struct_defs/struct_0203CC84.h" #include "struct_defs/struct_02099F80.h" #include "bg_window.h" @@ -9,6 +8,7 @@ #include "font.h" #include "gx_layers.h" #include "heap.h" +#include "main.h" #include "menu.h" #include "message.h" #include "overlay_manager.h" @@ -16,7 +16,6 @@ #include "savedata.h" #include "strbuf.h" #include "text.h" -#include "unk_02000C88.h" #include "unk_0200F174.h" #include "unk_02017728.h" @@ -38,7 +37,6 @@ typedef struct { u32 unk_3C; } UnkStruct_0209A3D0; -void sub_02000EC4(FSOverlayID param0, const OverlayManagerTemplate *param1); int sub_0209A2C4(OverlayManager *param0, int *param1); int sub_0209A300(OverlayManager *param0, int *param1); int sub_0209A3A4(OverlayManager *param0, int *param1); @@ -80,7 +78,7 @@ int sub_0209A2C4(OverlayManager *param0, int *param1) v0->unk_00 = v1; v0->unk_04 = 0; - v0->unk_34 = ((UnkStruct_0203CC84 *)OverlayManager_Args(param0))->unk_08; + v0->unk_34 = ((ApplicationArgs *)OverlayManager_Args(param0))->saveData; return 1; } @@ -129,7 +127,7 @@ int sub_0209A3A4(OverlayManager *param0, int *param1) OverlayManager_FreeData(param0); Heap_Destroy(v1); - sub_02000EC4(FS_OVERLAY_ID(overlay97), &Unk_ov97_0223D674); + EnqueueApplication(FS_OVERLAY_ID(overlay97), &Unk_ov97_0223D674); return 1; } diff --git a/src/unk_0209A74C.c b/src/unk_0209A74C.c index a949bb49d6..24c72cb6c7 100644 --- a/src/unk_0209A74C.c +++ b/src/unk_0209A74C.c @@ -10,11 +10,11 @@ #include "font.h" #include "gx_layers.h" #include "heap.h" +#include "main.h" #include "message.h" #include "render_window.h" #include "strbuf.h" #include "text.h" -#include "unk_02000C88.h" #include "unk_0200A9DC.h" #include "unk_0200F174.h" #include "unk_02017728.h" diff --git a/src/unk_0209AA74.c b/src/unk_0209AA74.c index 757f4bd158..bd248b2fcf 100644 --- a/src/unk_0209AA74.c +++ b/src/unk_0209AA74.c @@ -10,11 +10,11 @@ #include "font.h" #include "gx_layers.h" #include "heap.h" +#include "main.h" #include "message.h" #include "render_window.h" #include "strbuf.h" #include "text.h" -#include "unk_02000C88.h" #include "unk_0200A9DC.h" #include "unk_0200F174.h" #include "unk_02017728.h" diff --git a/src/unk_0209AC14.c b/src/unk_0209AC14.c index dbf38b8cf5..ff88d50ed8 100644 --- a/src/unk_0209AC14.c +++ b/src/unk_0209AC14.c @@ -6,7 +6,7 @@ #include "struct_decls/struct_020508D4_decl.h" #include "field/field_system.h" -#include "overlay005/ov5_021D0D80.h" +#include "overlay005/fieldmap.h" #include "overlay007/ov7_0224CD28.h" #include "overlay007/struct_ov7_0224D008.h" diff --git a/src/unk_0209ACF4.c b/src/unk_0209ACF4.c index 97446c8da7..c4402c05ce 100644 --- a/src/unk_0209ACF4.c +++ b/src/unk_0209ACF4.c @@ -8,7 +8,7 @@ #include "struct_defs/sentence.h" #include "field/field_system.h" -#include "overlay005/ov5_021D0D80.h" +#include "overlay005/fieldmap.h" #include "bg_window.h" #include "colored_arrow.h" diff --git a/src/unk_0209B344.c b/src/unk_0209B344.c index 0a169720b4..6445c247dc 100644 --- a/src/unk_0209B344.c +++ b/src/unk_0209B344.c @@ -8,7 +8,7 @@ #include "struct_defs/sentence.h" #include "field/field_system.h" -#include "overlay005/ov5_021D0D80.h" +#include "overlay005/fieldmap.h" #include "heap.h" #include "savedata_misc.h" diff --git a/src/unk_0209BA18.c b/src/unk_0209BA18.c index 5825a41cf7..222f5d1cc5 100644 --- a/src/unk_0209BA18.c +++ b/src/unk_0209BA18.c @@ -39,7 +39,7 @@ UnkStruct_ov104_02230BE4 *sub_0209BA18(FieldSystem *fieldSystem, void *param1) v0->unk_24 = (((((((((((0 + 1) + 1) + 1) + 1) + 1) + 3) + 1) + 1) + 1) + 2) + 1); v0->fieldSystem = fieldSystem; - sub_0203CD84(fieldSystem, &Unk_020F8BE0, v0); + FieldSystem_StartChildProcess(fieldSystem, &Unk_020F8BE0, v0); return v0; } diff --git a/src/unk_0209C194.c b/src/unk_0209C194.c index 192449c0ef..7b037aa474 100644 --- a/src/unk_0209C194.c +++ b/src/unk_0209C194.c @@ -98,7 +98,7 @@ static BOOL sub_0209C25C(UnkStruct_0209C1EC *param0) { param0->unk_28 = sub_0209C194(¶m0->unk_08, 11); param0->unk_00 = 1; - sub_0203CD84(param0->fieldSystem, &Unk_020F94FC, param0->unk_28); + FieldSystem_StartChildProcess(param0->fieldSystem, &Unk_020F94FC, param0->unk_28); return 0; } @@ -134,7 +134,7 @@ static BOOL sub_0209C2C0(UnkStruct_0209C1EC *param0) param0->unk_00 = 3; } else { param0->unk_28->unk_04 = v0; - sub_0203CD84(param0->fieldSystem, &Unk_020F950C, param0->unk_28); + FieldSystem_StartChildProcess(param0->fieldSystem, &Unk_020F950C, param0->unk_28); param0->unk_28->unk_00 = 3; param0->unk_00 = 4; }