diff --git a/asm/easy_chat.s b/asm/easy_chat.s index f6f09a87e..7a46f12c5 100644 --- a/asm/easy_chat.s +++ b/asm/easy_chat.s @@ -9869,10 +9869,18 @@ _0811F8AE: .pool thumb_func_end InitializeEasyChatWordArray +@void sub_811F8BC() { +@ s16* v; +@ s16* ptr; +@ v = GetSaveBlock1Field3564(); +@ for (ptr = v + 3; ptr >= v; ptr--) { +@ *ptr = -1; +@ } +@} thumb_func_start sub_811F8BC sub_811F8BC: @ 811F8BC push {lr} - bl sub_801B058 + bl GetSaveBlock1Field3564 ldr r1, =0x0000ffff adds r2, r1, 0 adds r1, r0, 0x6 diff --git a/asm/rom_8011DC0.s b/asm/rom_8011DC0.s index ec5b7e8f5..fafedeeff 100644 --- a/asm/rom_8011DC0.s +++ b/asm/rom_8011DC0.s @@ -8315,6 +8315,11 @@ _0801AFC2: .pool thumb_func_end sub_801AC54 +@void sub_801AFD8() { +@ CpuFill32(0, &gSaveBlock1Ptr->field_322C, 219); +@ sub_801B180(); +@ sub_811F8BC(); +@} thumb_func_start sub_801AFD8 sub_801AFD8: @ 801AFD8 push {lr} @@ -8367,25 +8372,25 @@ sav1_get_mevent_buffer_2: @ 801B034 .pool thumb_func_end sav1_get_mevent_buffer_2 - thumb_func_start sub_801B044 -sub_801B044: @ 801B044 + thumb_func_start GetSaveBlock1Field356C +GetSaveBlock1Field356C: @ 801B044 ldr r0, =gSaveBlock1Ptr ldr r0, [r0] ldr r1, =0x0000356c adds r0, r1 bx lr .pool - thumb_func_end sub_801B044 + thumb_func_end GetSaveBlock1Field356C - thumb_func_start sub_801B058 -sub_801B058: @ 801B058 + thumb_func_start GetSaveBlock1Field3564 +GetSaveBlock1Field3564: @ 801B058 ldr r0, =gSaveBlock1Ptr ldr r0, [r0] ldr r1, =0x00003564 adds r0, r1 bx lr .pool - thumb_func_end sub_801B058 + thumb_func_end GetSaveBlock1Field3564 thumb_func_start sub_801B06C sub_801B06C: @ 801B06C @@ -8531,7 +8536,7 @@ sub_801B180: @ 801B180 sub sp, 0x4 movs r0, 0 str r0, [sp] - bl sub_801B044 + bl GetSaveBlock1Field356C adds r1, r0, 0 ldr r2, =0x05000001 mov r0, sp @@ -13795,7 +13800,7 @@ _0801DB60: sub_801DB68: @ 801DB68 push {r4,r5,lr} adds r4, r0, 0 - bl sub_801B044 + bl GetSaveBlock1Field356C adds r5, r0, 0 movs r0, 0x3 adds r1, r4, 0 @@ -13841,7 +13846,7 @@ _0801DBB8: thumb_func_start sub_801DBC0 sub_801DBC0: @ 801DBC0 push {lr} - bl sub_801B044 + bl GetSaveBlock1Field356C movs r1, 0 strb r1, [r0] strb r1, [r0, 0x1] @@ -13858,7 +13863,7 @@ sub_801DBDC: @ 801DBDC ldr r0, =0x0000402e bl GetVarPointer adds r4, r0, 0 - bl sub_801B044 + bl GetSaveBlock1Field356C adds r2, r0, 0 ldr r0, [r2] lsls r0, 24 @@ -13889,7 +13894,7 @@ _0801DC10: sub_801DC20: @ 801DC20 push {r4-r6,lr} ldr r6, =gSpecialVar_Result - bl sub_801B044 + bl GetSaveBlock1Field356C adds r4, r0, 0 bl IsMysteryEventEnabled cmp r0, 0 diff --git a/common_syms/pokedex.txt b/common_syms/pokedex.txt index c982c9d3a..9aa48a74d 100644 --- a/common_syms/pokedex.txt +++ b/common_syms/pokedex.txt @@ -1,2 +1,2 @@ -gUnknown_030060B0 +gUnusedPokedexU8 gUnknown_030060B4 diff --git a/data/event_scripts.s b/data/event_scripts.s index 7ee8e6cf2..1b8807ed7 100644 --- a/data/event_scripts.s +++ b/data/event_scripts.s @@ -940,7 +940,7 @@ EventScript_27149D:: @ 827149D setberrytree 82, 36, 5 return -EventScript_2715DE:: @ 82715DE +EventScript_ResetAllMapFlags:: @ 82715DE setflag FLAG_LINK_CONTEST_POKE_BALL setflag FLAG_HIDE_ROUTE_111_VICTORIA_WINSTRATE setflag FLAG_HIDE_ROUTE_111_VIVI_WINSTRATE diff --git a/include/field_specials.h b/include/field_specials.h index 981d65c0a..bff04a739 100644 --- a/include/field_specials.h +++ b/include/field_specials.h @@ -25,5 +25,7 @@ void UpdateFrontierManiac(u16 a0); void UpdateFrontierGambler(u16 a0); void ResetCyclingRoadChallengeData(void); bool8 warp0_in_pokecenter(void); +void ResetFanClub(void); + #endif // GUARD_FIELD_SPECIALS_H diff --git a/include/global.h b/include/global.h index 14a6387cd..cc308c3c9 100644 --- a/include/global.h +++ b/include/global.h @@ -376,7 +376,7 @@ struct BattleFrontier /*0xEBC*/ u32 battlesCount; /*0xEC0*/ u16 field_EC0[16]; /*0xEE0*/ u8 field_EE0; - /*0xEE1*/ u8 field_EE1[2][PLAYER_NAME_LENGTH + 1]; + /*0xEE1*/ u8 opponentName[2][PLAYER_NAME_LENGTH + 1]; /*0xEF1*/ u8 field_EF1[2][4]; /*0xEF9*/ u8 field_EF9_0:7; /*0xEF9*/ u8 field_EF9_1:1; @@ -446,7 +446,7 @@ struct SaveBlock2 /*0x90*/ u8 filler_90[0x8]; /*0x98*/ struct Time localTimeOffset; /*0xA0*/ struct Time lastBerryTreeUpdate; - /*0xA8*/ u32 field_A8; + /*0xA8*/ u32 field_A8; // Written to, but never read. /*0xAC*/ u32 encryptionKey; /*0xB0*/ struct PlayersApprentice playerApprentice; /*0xDC*/ struct Apprentice apprentices[4]; // From record mixing. @@ -787,7 +787,7 @@ struct WaldaPhrase bool8 patternUnlocked; }; -struct UnkSaveSubstruct_3b98 +struct TrainerNameRecord { u32 trainerId; u8 trainerName[PLAYER_NAME_LENGTH + 1]; @@ -891,7 +891,7 @@ struct SaveBlock1 /*0x3B14*/ struct RecordMixingGift recordMixingGift; /*0x3B24*/ u8 seen2[DEX_FLAGS_NO]; /*0x3B58*/ LilycoveLady lilycoveLady; - /*0x3B98*/ struct UnkSaveSubstruct_3b98 unk_3B98[20]; + /*0x3B98*/ struct TrainerNameRecord trainerNameRecords[20]; /*0x3C88*/ u8 filler_3C88[0xDC]; /*0x3D64*/ struct SaveTrainerHill trainerHill; /*0x3D70*/ struct WaldaPhrase waldaPhrase; diff --git a/include/item_menu.h b/include/item_menu.h index d972cdf83..2ca1af200 100644 --- a/include/item_menu.h +++ b/include/item_menu.h @@ -79,5 +79,7 @@ bool8 UseRegisteredKeyItemOnField(void); void CB2_GoToSellMenu(void); void GoToBagMenu(u8 bagMenuType, u8 pocketId, void ( *postExitMenuMainCallback2)()); void DoWallyTutorialBagMenu(void); +void ResetBagScrollPositions(void); + #endif //GUARD_item_menu_H diff --git a/include/link.h b/include/link.h index 52a631570..11eff5c28 100644 --- a/include/link.h +++ b/include/link.h @@ -305,7 +305,7 @@ void sub_8009FAC(void); bool8 sub_800A4D8(u8 a0); u8 sub_800A9D8(void); u8 sub_800A0C8(s32, s32); -u16 *sub_801B058(void); +u16 *GetSaveBlock1Field3564(void); u8 sub_800A9A8(void); void sub_800AD10(void); void sub_800AB18(void); diff --git a/include/link_rfu.h b/include/link_rfu.h index d468d6c49..c91f9f1d3 100644 --- a/include/link_rfu.h +++ b/include/link_rfu.h @@ -213,6 +213,7 @@ extern struct UnkRfuStruct_2 gUnknown_03005000; extern u8 gWirelessStatusIndicatorSpriteId; // Exported ROM declarations +void WipeTrainerNameRecords(void); u32 sub_800BEC0(void); void sub_800E700(void); void sub_800EDD4(void); @@ -263,7 +264,7 @@ void sub_800E084(void); void sub_801103C(void); void sub_8011C5C(void); void sub_80106D4(void); -void sub_800E3A8(void); +void RecordMixTrainerNames(void); void sub_800ED10(void); void sub_800ED28(void); void sub_8011090(u8 a0, u32 a1, u32 a2); diff --git a/include/main.h b/include/main.h index 2ed30307b..728064288 100644 --- a/include/main.h +++ b/include/main.h @@ -68,5 +68,7 @@ void ClearPokemonCrySongs(void); void RestoreSerialTimer3IntrHandlers(void); void StartTimer1(void); void SeedRngAndSetTrainerId(void); +extern u16 GetGeneratedTrainerIdLower(void); + #endif // GUARD_MAIN_H diff --git a/include/player_pc.h b/include/player_pc.h index 5a0b83683..53bb25c6b 100644 --- a/include/player_pc.h +++ b/include/player_pc.h @@ -85,5 +85,7 @@ extern const struct MenuAction gMailboxMailOptions[]; void ReshowPlayerPC(u8 taskId); void sub_816B31C(void); void Mailbox_ReturnToMailListAfterDeposit(void); +void NewGameInitPCItems(void); + #endif //GUARD_PLAYER_PC_H diff --git a/include/pokedex.h b/include/pokedex.h index 91e9e37d4..6136f7786 100644 --- a/include/pokedex.h +++ b/include/pokedex.h @@ -1,7 +1,7 @@ #ifndef GUARD_POKEDEX_H #define GUARD_POKEDEX_H -extern u8 gUnknown_030060B0; +extern u8 gUnusedPokedexU8; extern void (*gUnknown_030060B4)(void); #define HOENN_DEX_COUNT 202 @@ -42,5 +42,6 @@ u8 CreateDexDisplayMonDataTask(u16 dexNum, u32 trainerId, u32 personality); s8 GetSetPokedexFlag(u16 nationalNum, u8 caseId); u16 CreateMonSpriteFromNationalDexNumber(u16, s16, s16, u16); bool16 HasAllHoennMons(void); +void ResetPokedexScrollPositions(void); #endif // GUARD_POKEDEX_H diff --git a/include/secret_base.h b/include/secret_base.h index 57ad81fee..699158d0e 100644 --- a/include/secret_base.h +++ b/include/secret_base.h @@ -24,6 +24,7 @@ void sub_80EBB28(void); void WarpIntoSecretBase(const struct MapPosition *position, const struct MapEvents *events); bool8 sub_80E909C(void); void sub_80EB218(void); +void ResetSecretBases(void); // SetCurrentSecretBaseFromPosition void sub_80E9608(const struct MapPosition *position, const struct MapEvents *events); @@ -33,4 +34,5 @@ void sub_80E8BC8(void); void sub_80E8D4C(void); void EnableBothScriptContexts(void); + #endif //GUARD_SECRET_BASE_H diff --git a/include/tv.h b/include/tv.h index 760d87522..a7ef3daa8 100644 --- a/include/tv.h +++ b/include/tv.h @@ -61,5 +61,6 @@ void ContestLiveUpdates_BeforeInterview_2(u8 a0); void ContestLiveUpdates_BeforeInterview_3(u8 a0); void ContestLiveUpdates_BeforeInterview_4(u16 a0); void ContestLiveUpdates_BeforeInterview_5(u8 a0, u8 a1); +void ResetGabbyAndTy(void); #endif //GUARD_TV_H diff --git a/src/easy_chat.c b/src/easy_chat.c index c84895df5..7158253d1 100644 --- a/src/easy_chat.c +++ b/src/easy_chat.c @@ -359,7 +359,7 @@ void easy_chat_input_maybe(void) words = gSaveBlock2Ptr->apprentices[0].easyChatWords; break; case 20: - words = sub_801B058(); + words = GetSaveBlock1Field3564(); break; default: return; diff --git a/src/event_data.c b/src/event_data.c index a9da142e5..e75c37773 100644 --- a/src/event_data.c +++ b/src/event_data.c @@ -28,8 +28,6 @@ EWRAM_DATA static u8 gUnknown_020375FC[16] = {0}; extern u16 *const gSpecialVars[]; -extern void sub_80BB358(void); - void InitEventData(void) { memset(gSaveBlock1Ptr->flags, 0, sizeof(gSaveBlock1Ptr->flags)); @@ -69,7 +67,7 @@ void EnableNationalPokedex(void) FlagSet(FLAG_SYS_NATIONAL_DEX); gSaveBlock2Ptr->pokedex.mode = DEX_MODE_NATIONAL; gSaveBlock2Ptr->pokedex.order = 0; - sub_80BB358(); + ResetPokedexScrollPositions(); } bool32 IsNationalPokedexEnabled(void) diff --git a/src/frontier_util.c b/src/frontier_util.c index e6954c356..6fcbd4ffb 100644 --- a/src/frontier_util.c +++ b/src/frontier_util.c @@ -1528,7 +1528,7 @@ static void ShowLinkContestResultsWindow(void) static void sub_81A31FC(void) { - u8 text[32]; + u8 name[32]; s32 lvlMode = gSaveBlock2Ptr->frontier.lvlMode; s32 facility = VarGet(VAR_FRONTIER_FACILITY); s32 battleMode = VarGet(VAR_FRONTIER_BATTLE_MODE); @@ -1541,9 +1541,9 @@ static void sub_81A31FC(void) gSaveBlock2Ptr->frontier.towerRecordWinStreaks[battleMode][lvlMode] = gSaveBlock2Ptr->frontier.towerWinStreaks[battleMode][lvlMode]; if (battleMode == FRONTIER_MODE_LINK_MULTIS) { - StringCopy(text, gLinkPlayers[gBattleScripting.multiplayerId ^ 1].name); - StripExtCtrlCodes(text); - StringCopy(gSaveBlock2Ptr->frontier.field_EE1[lvlMode], text); + StringCopy(name, gLinkPlayers[gBattleScripting.multiplayerId ^ 1].name); + StripExtCtrlCodes(name); + StringCopy(gSaveBlock2Ptr->frontier.opponentName[lvlMode], name); SetTrainerId(gLinkPlayers[gBattleScripting.multiplayerId ^ 1].trainerId, gSaveBlock2Ptr->frontier.field_EF1[lvlMode]); } if (gSaveBlock2Ptr->frontier.towerWinStreaks[battleMode][lvlMode] > 1 @@ -2336,8 +2336,8 @@ static void PrintHallRecords(s32 hallFacilityId, s32 lvlMode) AddTextPrinterParameterized(gRecordsWindowId, 1, gLevelModeText[lvlMode], x, 1, TEXT_SPEED_FF, NULL); if (hallFacilityId == HALL_FACILITIES_COUNT) { - gSaveBlock2Ptr->frontier.field_EE1[0][PLAYER_NAME_LENGTH] = EOS; - gSaveBlock2Ptr->frontier.field_EE1[1][PLAYER_NAME_LENGTH] = EOS; + gSaveBlock2Ptr->frontier.opponentName[0][PLAYER_NAME_LENGTH] = EOS; + gSaveBlock2Ptr->frontier.opponentName[1][PLAYER_NAME_LENGTH] = EOS; Fill2PRecords(records2P, lvlMode); for (i = 0; i < 3; i++) Print2PRecord(i, 1, 4, &records2P[i]); diff --git a/src/link_rfu.c b/src/link_rfu.c index ebfc802e0..4ad2a5169 100644 --- a/src/link_rfu.c +++ b/src/link_rfu.c @@ -16,6 +16,7 @@ #include "task.h" #include "text.h" #include "constants/species.h" +#include "save.h" extern u16 gUnknown_03005DA8; extern void nullsub_89(u8 taskId); @@ -2347,17 +2348,17 @@ void sub_800E174(void) } } -void sub_800E378(struct UnkSaveSubstruct_3b98 *dest, u32 trainerId, const u8 *name) +void CopyTrainerRecord(struct TrainerNameRecord *dest, u32 trainerId, const u8 *name) { dest->trainerId = trainerId; StringCopy(dest->trainerName, name); } -bool32 sub_800E388(const u8 *name) +bool32 NameIsNotEmpty(const u8 *name) { s32 i; - for (i = 0; i < 8; i++) + for (i = 0; i < PLAYER_NAME_LENGTH + 1; i++) { if (name[i] != 0) { @@ -2367,52 +2368,64 @@ bool32 sub_800E388(const u8 *name) return FALSE; } -void sub_800E3A8(void) +// Save the currently connected players into the trainer records, shifting all previous records down. +void RecordMixTrainerNames(void) { if (gWirelessCommType != 0) { s32 i; s32 j; - s32 cnt; - s32 sp0[5]; - struct UnkSaveSubstruct_3b98 *sp14 = calloc(20, sizeof(struct UnkSaveSubstruct_3b98)); + s32 nextSpace; + s32 connectedTrainerRecordIndices[5]; + struct TrainerNameRecord *newRecords = calloc(20, sizeof(struct TrainerNameRecord)); + + // Check if we already have a record saved for connected trainers. for (i = 0; i < GetLinkPlayerCount(); i++) { - sp0[i] = -1; + connectedTrainerRecordIndices[i] = -1; for (j = 0; j < 20; j++) { - if ((u16)gLinkPlayers[i].trainerId == gSaveBlock1Ptr->unk_3B98[j].trainerId && StringCompare(gLinkPlayers[i].name, gSaveBlock1Ptr->unk_3B98[j].trainerName) == 0) + if ((u16)gLinkPlayers[i].trainerId == gSaveBlock1Ptr->trainerNameRecords[j].trainerId && StringCompare(gLinkPlayers[i].name, gSaveBlock1Ptr->trainerNameRecords[j].trainerName) == 0) { - sp0[i] = j; + connectedTrainerRecordIndices[i] = j; } } } - cnt = 0; + + // Save the connected trainers first, at the top of the list. + nextSpace = 0; for (i = 0; i < GetLinkPlayerCount(); i++) { if (i != GetMultiplayerId() && gLinkPlayers[i].language != LANGUAGE_JAPANESE) { - sub_800E378(&sp14[cnt], (u16)gLinkPlayers[i].trainerId, gLinkPlayers[i].name); - if (sp0[i] >= 0) + CopyTrainerRecord(&newRecords[nextSpace], (u16)gLinkPlayers[i].trainerId, gLinkPlayers[i].name); + + // If we already had a record for this trainer, wipe it so that the next step doesn't duplicate it. + if (connectedTrainerRecordIndices[i] >= 0) { - memset(gSaveBlock1Ptr->unk_3B98[sp0[i]].trainerName, 0, 8); + memset(gSaveBlock1Ptr->trainerNameRecords[connectedTrainerRecordIndices[i]].trainerName, 0, 8); } - cnt++; + nextSpace++; } } + + // Copy all non-empty records to the new list, in the order they appear on the old list. If the list is full, + // the last (oldest) records will be dropped. for (i = 0; i < 20; i++) { - if (sub_800E388(gSaveBlock1Ptr->unk_3B98[i].trainerName)) + if (NameIsNotEmpty(gSaveBlock1Ptr->trainerNameRecords[i].trainerName)) { - sub_800E378(&sp14[cnt], gSaveBlock1Ptr->unk_3B98[i].trainerId, gSaveBlock1Ptr->unk_3B98[i].trainerName); - if (++cnt >= 20) + CopyTrainerRecord(&newRecords[nextSpace], gSaveBlock1Ptr->trainerNameRecords[i].trainerId, gSaveBlock1Ptr->trainerNameRecords[i].trainerName); + if (++nextSpace >= 20) { break; } } } - memcpy(gSaveBlock1Ptr->unk_3B98, sp14, 20 * sizeof(struct UnkSaveSubstruct_3b98)); - free(sp14); + + // Finalize the new list, and clean up. + memcpy(gSaveBlock1Ptr->trainerNameRecords, newRecords, 20 * sizeof(struct TrainerNameRecord)); + free(newRecords); } } @@ -2422,11 +2435,11 @@ bool32 sub_800E540(u16 id, u8 *name) for (i = 0; i < 20; i++) { - if (StringCompare(gSaveBlock1Ptr->unk_3B98[i].trainerName, name) == 0 && gSaveBlock1Ptr->unk_3B98[i].trainerId == id) + if (StringCompare(gSaveBlock1Ptr->trainerNameRecords[i].trainerName, name) == 0 && gSaveBlock1Ptr->trainerNameRecords[i].trainerId == id) { return TRUE; } - if (!sub_800E388(gSaveBlock1Ptr->unk_3B98[i].trainerName)) + if (!NameIsNotEmpty(gSaveBlock1Ptr->trainerNameRecords[i].trainerName)) { return FALSE; } @@ -2434,14 +2447,14 @@ bool32 sub_800E540(u16 id, u8 *name) return FALSE; } -void sub_800E5AC(void) +void WipeTrainerNameRecords(void) { s32 i; for (i = 0; i < 20; i++) { - gSaveBlock1Ptr->unk_3B98[i].trainerId = 0; - CpuFill16(0, gSaveBlock1Ptr->unk_3B98[i].trainerName, 8); + gSaveBlock1Ptr->trainerNameRecords[i].trainerId = 0; + CpuFill16(0, gSaveBlock1Ptr->trainerNameRecords[i].trainerName, 8); } } diff --git a/src/new_game.c b/src/new_game.c index a4bf2951f..2e8930f7c 100644 --- a/src/new_game.c +++ b/src/new_game.c @@ -30,31 +30,25 @@ #include "apprentice.h" #include "frontier_util.h" #include "constants/maps.h" +#include "pokedex.h" +#include "save.h" +#include "link_rfu.h" +#include "main.h" +#include "contest.h" +#include "item_menu.h" +#include "pokemon_storage_system.h" +#include "decoration_inventory.h" +#include "secret_base.h" +#include "player_pc.h" +#include "field_specials.h" -extern u16 gSaveFileStatus; -extern u8 gUnknown_030060B0; -// TODO: replace those declarations with file headers -extern u16 GetGeneratedTrainerIdLower(void); -extern void ClearContestWinnerPicsInContestHall(void); -extern void sub_80BB358(void); -extern void ResetBagScrollPositions(void); -extern void ResetGabbyAndTy(void); -extern void ResetSecretBases(void); -extern void ResetLinkContestBoolean(void); -extern void sub_8052DA8(void); -extern void ResetPokemonStorageSystem(void); -extern void NewGameInitPCItems(void); -extern void ClearDecorationInventories(void); -extern void ResetFanClub(void); extern void copy_strings_to_sav1(void); extern void sub_801AFD8(void); -extern void sub_800E5AC(void); -extern void ResetContestLinkResults(void); extern void ResetPokeJumpResults(void); extern void SetBerryPowder(u32* powder, u32 newValue); -extern const u8 EventScript_2715DE[]; +extern const u8 EventScript_ResetAllMapFlags[]; // this file's functions static void ClearFrontierRecord(void); @@ -112,7 +106,7 @@ static void SetDefaultOptions(void) static void ClearPokedexFlags(void) { - gUnknown_030060B0 = 0; + gUnusedPokedexU8 = 0; memset(&gSaveBlock2Ptr->pokedex.owned, 0, sizeof(gSaveBlock2Ptr->pokedex.owned)); memset(&gSaveBlock2Ptr->pokedex.seen, 0, sizeof(gSaveBlock2Ptr->pokedex.seen)); } @@ -130,8 +124,8 @@ static void ClearFrontierRecord(void) { CpuFill32(0, &gSaveBlock2Ptr->frontier, sizeof(gSaveBlock2Ptr->frontier)); - gSaveBlock2Ptr->frontier.field_EE1[0][0] = EOS; - gSaveBlock2Ptr->frontier.field_EE1[1][0] = EOS; + gSaveBlock2Ptr->frontier.opponentName[0][0] = EOS; + gSaveBlock2Ptr->frontier.opponentName[1][0] = EOS; } static void WarpToTruck(void) @@ -149,7 +143,7 @@ void Sav2_ClearSetDefault(void) void ResetMenuAndMonGlobals(void) { gDifferentSaveFile = 0; - sub_80BB358(); + ResetPokedexScrollPositions(); ZeroPlayerPartyMons(); ZeroEnemyPartyMons(); ResetBagScrollPositions(); @@ -203,7 +197,7 @@ void NewGameInitData(void) ResetFanClub(); ResetLotteryCorner(); WarpToTruck(); - ScriptContext2_RunNewScript(EventScript_2715DE); + ScriptContext2_RunNewScript(EventScript_ResetAllMapFlags); ResetMiniGamesResults(); copy_strings_to_sav1(); SetLilycoveLady(); @@ -211,7 +205,7 @@ void NewGameInitData(void) ClearRankingHallRecords(); InitMatchCallCounters(); sub_801AFD8(); - sub_800E5AC(); + WipeTrainerNameRecords(); ResetTrainerHillResults(); ResetContestLinkResults(); } diff --git a/src/pokedex.c b/src/pokedex.c index 2ebc33622..805412c85 100644 --- a/src/pokedex.c +++ b/src/pokedex.c @@ -37,7 +37,8 @@ static EWRAM_DATA u8 gUnknown_02039B52 = 0; static EWRAM_DATA struct PokedexListItem *sPokedexListItem = NULL; // IWRAM common -u8 gUnknown_030060B0; +// This is written to, but never read. +u8 gUnusedPokedexU8; void (*gUnknown_030060B4)(void); struct PokedexOption @@ -1225,7 +1226,7 @@ void ResetPokedex(void) gUnknown_02039B50 = 0; gUnknown_02039B52 = 64; - gUnknown_030060B0 = 0; + gUnusedPokedexU8 = 0; gSaveBlock2Ptr->pokedex.mode = DEX_MODE_HOENN; gSaveBlock2Ptr->pokedex.order = 0; gSaveBlock2Ptr->pokedex.nationalMagic = 0; @@ -1243,7 +1244,7 @@ void ResetPokedex(void) } } -void sub_80BB358(void) +void ResetPokedexScrollPositions(void) { gUnknown_02039B50 = 0; gUnknown_02039B52 = 64; diff --git a/src/record_mixing.c b/src/record_mixing.c index 189033685..c0ca5f19c 100644 --- a/src/record_mixing.c +++ b/src/record_mixing.c @@ -1087,7 +1087,7 @@ void GetPlayerHallRecords(struct PlayerHallRecords *dst) CopyTrainerId(dst->twoPlayers[j].id1, gSaveBlock2Ptr->playerTrainerId); CopyTrainerId(dst->twoPlayers[j].id2, gSaveBlock2Ptr->frontier.field_EF1[j]); StringCopy(dst->twoPlayers[j].name1, gSaveBlock2Ptr->playerName); - StringCopy(dst->twoPlayers[j].name2, gSaveBlock2Ptr->frontier.field_EE1[j]); + StringCopy(dst->twoPlayers[j].name2, gSaveBlock2Ptr->frontier.opponentName[j]); } for (i = 0; i < 2; i++) diff --git a/src/rom_8011DC0.c b/src/rom_8011DC0.c index 9bdd86167..baed26cf8 100644 --- a/src/rom_8011DC0.c +++ b/src/rom_8011DC0.c @@ -1687,7 +1687,7 @@ void sub_801440C(u8 taskId) case 9 ... 11: case 13: case 15: - sub_800E3A8(); + RecordMixTrainerNames(); break; } @@ -1800,12 +1800,12 @@ void sub_8014790(u8 taskId) sendBuff[1] = GetMonData(&gPlayerParty[gSelectedOrderFromParty[1] - 1], MON_DATA_SPECIES, NULL); gMain.savedCallback = NULL; data[0] = 4; - sub_800E3A8(); + RecordMixTrainerNames(); ResetBlockReceivedFlags(); break; case 16: case 23 ... 27: - sub_800E3A8(); + RecordMixTrainerNames(); DestroyTask(taskId); default: EnableBothScriptContexts();