diff --git a/asm/contest_link_80F57C4.s b/asm/contest_link_80F57C4.s index b869adf1ba..ec962c71d9 100644 --- a/asm/contest_link_80F57C4.s +++ b/asm/contest_link_80F57C4.s @@ -578,10 +578,10 @@ _080F5D58: adds r0, r5, 0 movs r1, 0 bl VarSet - bl sub_8076D5C + bl SetContinueGameWarpStatusToDynamicWarp movs r0, 0x1 bl TrySavingData - bl sav2_gender2_inplace_and_xFE + bl ClearContinueGameWarpStatus2 adds r0, r5, 0 adds r1, r4, 0 bl VarSet @@ -5598,7 +5598,7 @@ _080F874C: movs r3, 0x1 negs r3, r3 movs r0, 0 - bl saved_warp2_set + bl SetDynamicWarp bl ScriptContext2_Disable bl EnableBothScriptContexts _080F877E: diff --git a/asm/rom_8011DC0.s b/asm/rom_8011DC0.s index b90c9701eb..e6751247bf 100644 --- a/asm/rom_8011DC0.s +++ b/asm/rom_8011DC0.s @@ -15686,7 +15686,7 @@ _0801EB04: lsls r0, 24 cmp r0, 0 bne _0801EBC2 - bl sub_8076D5C + bl SetContinueGameWarpStatusToDynamicWarp movs r0, 0 bl TrySavingData ldr r0, =gUnknown_02022C84 @@ -15713,7 +15713,7 @@ _0801EB40: bne _0801EBC2 movs r0, 0x37 bl PlaySE - bl sav2_gender2_inplace_and_xFE + bl ClearContinueGameWarpStatus2 ldr r0, =gUnknown_02022C84 ldr r1, [r0] movs r0, 0xA @@ -20568,7 +20568,7 @@ _080211EC: beq _080211F8 b _08021302 _080211F8: - bl sub_81971D0 + bl InitStandardTextBoxWindows bl sub_8197200 adds r0, r5, 0 bl sub_8022588 @@ -39128,7 +39128,7 @@ _0802A7CE: movs r1, 0 movs r2, 0 bl ChangeBgY - bl sub_81971D0 + bl InitStandardTextBoxWindows bl sub_8197200 movs r1, 0x82 lsls r1, 5 diff --git a/asm/trade.s b/asm/trade.s index e8ce288104..eb2d22b066 100644 --- a/asm/trade.s +++ b/asm/trade.s @@ -13851,7 +13851,7 @@ _0807EDCE: movs r0, 0x2 bl sub_801B990 _0807EDF6: - bl sub_8076D5C + bl SetContinueGameWarpStatusToDynamicWarp bl sub_8153380 ldr r1, =gMain movs r2, 0x87 @@ -13884,7 +13884,7 @@ _0807EE38: lsrs r1, r0, 24 cmp r1, 0 beq _0807EE5C - bl sav2_gender2_inplace_and_xFE + bl ClearContinueGameWarpStatus2 ldr r0, =gMain movs r1, 0x87 lsls r1, 3 diff --git a/asm/trainer_card.s b/asm/trainer_card.s index 10e4d6d8fe..d0f26e0e15 100644 --- a/asm/trainer_card.s +++ b/asm/trainer_card.s @@ -4971,7 +4971,7 @@ _080C5204: b _080C52C8 _080C5214: str r4, [r0] - bl sav1_map_get_name + bl GetCurrentRegionMapSectionId lsls r0, 24 lsrs r4, r0, 24 cmp r4, 0x3A @@ -7780,7 +7780,7 @@ sub_80C6974: @ 80C6974 adds r1, r6 ldrb r1, [r1, 0xC] bl StartSpriteAnim - bl sav1_map_get_name + bl GetCurrentRegionMapSectionId lsls r0, 24 lsrs r5, r0, 24 cmp r5, 0x3A diff --git a/include/constants/songs.h b/include/constants/songs.h index 58a8e725cd..a459edd241 100644 --- a/include/constants/songs.h +++ b/include/constants/songs.h @@ -536,6 +536,6 @@ #define PH_NURSE_HELD 608 #define PH_NURSE_SOLO 609 -#define MUS_ROUTE_118 0x7FFF // What is this for? +#define MUS_ROUTE_118 0x7FFF // map is split into 2 music sections. controlled by GetCurrLocationDefaultMusic(). #endif // GUARD_CONSTANTS_SONGS_H diff --git a/include/global.h b/include/global.h index 090ba7ce46..4656f3968f 100644 --- a/include/global.h +++ b/include/global.h @@ -521,7 +521,7 @@ struct SaveBlock2 { /*0x00*/ u8 playerName[PLAYER_NAME_LENGTH + 1]; /*0x08*/ u8 playerGender; // MALE, FEMALE - /*0x09*/ u8 specialSaveWarp; + /*0x09*/ u8 specialSaveWarpFlags; /*0x0A*/ u8 playerTrainerId[4]; /*0x0E*/ u16 playTimeHours; /*0x10*/ u8 playTimeMinutes; @@ -889,10 +889,10 @@ struct SaveBlock1 { /*0x00*/ struct Coords16 pos; /*0x04*/ struct WarpData location; - /*0x0C*/ struct WarpData warp1; - /*0x14*/ struct WarpData warp2; - /*0x1C*/ struct WarpData lastHealLocation; - /*0x24*/ struct WarpData warp4; + /*0x0C*/ struct WarpData continueGameWarp; + /*0x14*/ struct WarpData dynamicWarp; + /*0x1C*/ struct WarpData lastHealLocation; // used by white-out and teleport + /*0x24*/ struct WarpData escapeWarp; // used by Dig and Escape Rope /*0x2C*/ u16 savedMusic; /*0x2E*/ u8 weather; /*0x2F*/ u8 weatherCycleStage; diff --git a/include/load_save.h b/include/load_save.h index c64a1179ba..bf50bffd75 100644 --- a/include/load_save.h +++ b/include/load_save.h @@ -15,11 +15,11 @@ void ClearSav2(void); void ClearSav1(void); void SetSaveBlocksPointers(u16 offset); void MoveSaveBlocks_ResetHeap(void); -u32 GetSecretBase2Field_9(void); -void ClearSecretBase2Field_9(void); -void SetSecretBase2Field_9(void); -void sub_8076D5C(void); -void sav2_gender2_inplace_and_xFE(void); +u32 UseContinueGameWarp(void); +void ClearContinueGameWarpStatus(void); +void SetContinueGameWarpStatus(void); +void SetContinueGameWarpStatusToDynamicWarp(void); +void ClearContinueGameWarpStatus2(void); void SavePlayerParty(void); void LoadPlayerParty(void); void SaveEventObjects(void); diff --git a/include/menu.h b/include/menu.h index 9b2341e583..aca4624687 100644 --- a/include/menu.h +++ b/include/menu.h @@ -20,7 +20,8 @@ struct MenuAction extern const u16 gUnknown_0860F074[]; -void sub_81971D0(void); +void FreeAllOverworldWindowBuffers(void); +void InitStandardTextBoxWindows(void); void sub_8197200(void); u16 RunTextPrintersAndIsPrinter0Active(void); void sub_81973A4(void); diff --git a/include/overworld.h b/include/overworld.h index 1f53662b37..f62a5136da 100644 --- a/include/overworld.h +++ b/include/overworld.h @@ -46,28 +46,25 @@ void Overworld_SetEventObjTemplateCoords(u8 localId, s16 x, s16 y); void Overworld_SetEventObjTemplateMovementType(u8 localId, u8 movementType); const struct MapLayout *GetMapLayout(void); void ApplyCurrentWarp(void); -void set_warp2_warp3_to_neg_1(void); struct MapHeader const *const Overworld_GetMapHeaderByGroupAndId(u16 mapGroup, u16 mapNum); struct MapHeader const *const GetDestinationWarpMapHeader(void); void WarpIntoMap(void); -void Overworld_SetWarpDestination(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y); -void warp1_set_2(s8 mapGroup, s8 mapNum, s8 warpId); -void saved_warp2_set(s32 unused, s8 mapGroup, s8 mapNum, s8 warpId); -void saved_warp2_set_2(s32 unused, s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y); -void copy_saved_warp2_bank_and_enter_x_to_warp1(u8 unused); -void sub_8084CCC(u8 a1); -void Overworld_SetWarpDestToLastHealLoc(void); -void Overworld_SetHealLocationWarp(u8 healLocationId); -void sub_8084D5C(s16 a1, s16 a2); -void sub_8084DD4(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y); -void sub_8084E14(void); +void SetWarpDestination(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y); +void SetWarpDestinationToMapWarp(s8 mapGroup, s8 mapNum, s8 warpId); +void SetDynamicWarp(s32 unused, s8 mapGroup, s8 mapNum, s8 warpId); +void SetDynamicWarpWithCoords(s32 unused, s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y); +void SetWarpDestinationToDynamicWarp(u8 unused); +void SetWarpDestinationToHealLocation(u8 a1); +void SetWarpDestinationToLastHealLocation(void); +void SetLastHealLocationWarp(u8 healLocationId); +void sub_8084D5C(s16 x, s16 y); +void SetEscapeWarp(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y); +void SetWarpDestinationToEscapeWarp(void); void SetFixedDiveWarp(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y); void SetFixedHoleWarp(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y); -void SetFixedHoleWarpAsDestination(s16 x, s16 y); -void warp1_set_to_sav1w(void); -void sub_8084F2C(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y); -void sub_8084F6C(u8 a1); -void sub_8084FAC(int unused); +void SetWarpDestinationToFixedHoleWarp(s16 x, s16 y); +void SetContinueGameWarpToHealLocation(u8 a1); +void SetContinueGameWarpToDynamicWarp(int unused); const struct MapConnection *GetMapConnection(u8 dir); bool8 SetDiveWarpEmerge(u16 x, u16 y); bool8 SetDiveWarpDive(u16 x, u16 y); @@ -78,7 +75,7 @@ bool32 Overworld_IsBikingAllowed(void); void SetDefaultFlashLevel(void); void Overworld_SetFlashLevel(s32 flashLevel); u8 Overworld_GetFlashLevel(void); -void sub_8085524(u16 mapLayoutId); +void SetCurrentMapLayout(u16 mapLayoutId); void sub_8085540(u8 var); u8 sub_808554C(void); u16 GetLocationMusic(struct WarpData *warp); @@ -97,15 +94,15 @@ void Overworld_FadeOutMapMusic(void); void UpdateAmbientCry(s16 *state, u16 *delayCounter); u8 GetMapTypeByGroupAndId(s8 mapGroup, s8 mapNum); u8 GetMapTypeByWarpData(struct WarpData *warp); -u8 Overworld_GetMapTypeOfSaveblockLocation(void); +u8 GetCurrentMapType(void); u8 GetLastUsedWarpMapType(void); bool8 is_map_type_1_2_3_5_or_6(u8 mapType); bool8 Overworld_MapTypeAllowsTeleportAndFly(u8 mapType); bool8 Overworld_MapTypeIsIndoors(u8 mapType); -u8 sav1_saved_warp2_map_get_name(void); -u8 sav1_map_get_name(void); +u8 GetSavedWarpRegionMapSectionId(void); +u8 GetCurrentRegionMapSectionId(void); u8 GetCurrentMapBattleScene(void); -void overworld_free_bg_tilemaps(void); +void CleanupOverworldWindowsAndTilemaps(void); bool32 is_c1_link_related_active(void); void CB1_Overworld(void); void CB2_OverworldBasic(void); diff --git a/include/save_location.h b/include/save_location.h index 71dbd3fd85..c330124ad6 100644 --- a/include/save_location.h +++ b/include/save_location.h @@ -1,6 +1,12 @@ #ifndef GUARD_SAVE_LOCATION_H #define GUARD_SAVE_LOCATION_H +// specialSaveWarp flags +#define CONTINUE_GAME_WARP (1 << 0) +#define POKECENTER_SAVEWARP (1 << 1) +#define LOBBY_SAVEWARP (1 << 2) +#define UNK_SPECIAL_SAVE_WARP_FLAG_3 (1 << 3) + void TrySetMapSaveWarpStatus(void); void sub_81AFDA0(void); void sub_81AFDD0(void); diff --git a/src/battle_arena.c b/src/battle_arena.c index 14f86c8829..fb95e64d49 100644 --- a/src/battle_arena.c +++ b/src/battle_arena.c @@ -784,7 +784,7 @@ static void sub_81A58B4(void) if (!isCurrent) gSaveBlock2Ptr->frontier.arenaWinStreaks[lvlMode] = 0; - saved_warp2_set(0, gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1); + SetDynamicWarp(0, gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1); gTrainerBattleOpponent_A = 0; } diff --git a/src/battle_dome.c b/src/battle_dome.c index 8645eb76b1..00ae84d096 100644 --- a/src/battle_dome.c +++ b/src/battle_dome.c @@ -2388,7 +2388,7 @@ static void sub_818E9CC(void) if (!(gSaveBlock2Ptr->frontier.field_CDC & gUnknown_0860D0EC[battleMode][lvlMode])) gSaveBlock2Ptr->frontier.domeWinStreaks[battleMode][lvlMode] = 0; - saved_warp2_set(0, gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1); + SetDynamicWarp(0, gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1); gTrainerBattleOpponent_A = 0; } diff --git a/src/battle_factory.c b/src/battle_factory.c index 4194086955..0445d5deaf 100644 --- a/src/battle_factory.c +++ b/src/battle_factory.c @@ -202,7 +202,7 @@ static void sub_81A5E94(void) for (i = 0; i < 3; i++) gUnknown_03006298[i] |= 0xFFFF; - saved_warp2_set(0, gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1); + SetDynamicWarp(0, gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1); gTrainerBattleOpponent_A = 0; } diff --git a/src/battle_palace.c b/src/battle_palace.c index 4033712b62..fb8cc0729a 100644 --- a/src/battle_palace.c +++ b/src/battle_palace.c @@ -69,7 +69,7 @@ static void sub_8195980(void) if (!(gSaveBlock2Ptr->frontier.field_CDC & gUnknown_0860DE98[battleMode][lvlMode])) gSaveBlock2Ptr->frontier.palaceWinStreaks[battleMode][lvlMode] = 0; - saved_warp2_set(0, gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1); + SetDynamicWarp(0, gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1); gTrainerBattleOpponent_A = 0; } diff --git a/src/battle_pyramid_bag.c b/src/battle_pyramid_bag.c index 12f631155f..50baf48fd2 100644 --- a/src/battle_pyramid_bag.c +++ b/src/battle_pyramid_bag.c @@ -365,7 +365,7 @@ static void sub_81C4F44(u8 taskId) { if (!gPaletteFade.active) { - overworld_free_bg_tilemaps(); + CleanupOverworldWindowsAndTilemaps(); gFieldCallback2 = hm_add_c3_without_phase_2; sub_81C4F98(3, CB2_ReturnToField); DestroyTask(taskId); diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 67e9a0b1a1..2490d6e136 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -10138,7 +10138,7 @@ static void atkEF_handleballthrow(void) ballMultiplier = 10; break; case ITEM_DIVE_BALL: - if (Overworld_GetMapTypeOfSaveblockLocation() == MAP_TYPE_UNDERWATER) + if (GetCurrentMapType() == MAP_TYPE_UNDERWATER) ballMultiplier = 35; else ballMultiplier = 10; diff --git a/src/battle_setup.c b/src/battle_setup.c index 55ee331cd8..21386016ff 100644 --- a/src/battle_setup.c +++ b/src/battle_setup.c @@ -349,7 +349,7 @@ static void Task_BattleStart(u8 taskId) case 1: if (IsBattleTransitionDone() == TRUE) { - overworld_free_bg_tilemaps(); + CleanupOverworldWindowsAndTilemaps(); SetMainCallback2(CB2_InitBattle); RestartWildEncounterImmunitySteps(); ClearPoisonStepCounter(); diff --git a/src/battle_tent.c b/src/battle_tent.c index c358deaa57..de4d9d374a 100644 --- a/src/battle_tent.c +++ b/src/battle_tent.c @@ -100,7 +100,7 @@ static void sub_81B99D4(void) gSaveBlock2Ptr->frontier.field_CA8 = 0; gSaveBlock2Ptr->frontier.curChallengeBattleNum = 0; gSaveBlock2Ptr->frontier.field_CA9_a = FALSE; - saved_warp2_set(0, gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1); + SetDynamicWarp(0, gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1); } static void sub_81B9A28(void) @@ -162,7 +162,7 @@ static void sub_81B9BA0(void) gSaveBlock2Ptr->frontier.field_CA8 = 0; gSaveBlock2Ptr->frontier.curChallengeBattleNum = 0; gSaveBlock2Ptr->frontier.field_CA9_a = FALSE; - saved_warp2_set(0, gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1); + SetDynamicWarp(0, gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1); } static void sub_81B9BF4(void) @@ -217,7 +217,7 @@ static void sub_81B9D28(void) gSaveBlock2Ptr->frontier.field_CA8 = 0; gSaveBlock2Ptr->frontier.curChallengeBattleNum = 0; gSaveBlock2Ptr->frontier.field_CA9_a = FALSE; - saved_warp2_set(0, gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1); + SetDynamicWarp(0, gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1); } static void sub_81B9D7C(void) diff --git a/src/battle_tower.c b/src/battle_tower.c index 12fde44f7f..2bb0352a8b 100644 --- a/src/battle_tower.c +++ b/src/battle_tower.c @@ -1163,7 +1163,7 @@ static void sub_8161F94(void) gSaveBlock2Ptr->frontier.towerWinStreaks[battleMode][lvlMode] = 0; ValidateBattleTowerRecordChecksums(); - saved_warp2_set(0, gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1); + SetDynamicWarp(0, gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1); gTrainerBattleOpponent_A = 0; } diff --git a/src/cable_club.c b/src/cable_club.c index 56154d5bfe..372329c14b 100644 --- a/src/cable_club.c +++ b/src/cable_club.c @@ -845,7 +845,7 @@ static void sub_80B32B4(u8 taskId) PlayMapChosenOrBattleBGM(MUS_BATTLE20); sub_80B3260(gSpecialVar_0x8004); - overworld_free_bg_tilemaps(); + CleanupOverworldWindowsAndTilemaps(); gTrainerBattleOpponent_A = 0x800; SetMainCallback2(CB2_InitBattle); gMain.savedCallback = sub_80B360C; @@ -911,7 +911,7 @@ static void sub_80B33BC(u8 taskId) gLinkPlayers[0].linkType = 0x2211; sub_80B3260(gSpecialVar_0x8004); - overworld_free_bg_tilemaps(); + CleanupOverworldWindowsAndTilemaps(); gTrainerBattleOpponent_A = 0x800; SetMainCallback2(CB2_InitBattle); gMain.savedCallback = sub_80B360C; @@ -1008,7 +1008,7 @@ void sub_80B36EC(void) LoadPlayerParty(); SavePlayerBag(); } - copy_saved_warp2_bank_and_enter_x_to_warp1(0x7F); + SetWarpDestinationToDynamicWarp(0x7F); } void sub_80B371C(void) diff --git a/src/decoration.c b/src/decoration.c index addca69540..438f2cbd1a 100644 --- a/src/decoration.c +++ b/src/decoration.c @@ -1131,7 +1131,7 @@ void sub_8127ACC(u8 taskId) void sub_8127B04(u8 taskId) { DrawWholeMapView(); - Overworld_SetWarpDestination(gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1, gTasks[taskId].data[3], gTasks[taskId].data[4]); + SetWarpDestination(gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1, gTasks[taskId].data[3], gTasks[taskId].data[4]); WarpIntoMap(); } diff --git a/src/easy_chat.c b/src/easy_chat.c index c4bc02e422..c84895df51 100644 --- a/src/easy_chat.c +++ b/src/easy_chat.c @@ -364,7 +364,7 @@ void easy_chat_input_maybe(void) default: return; } - overworld_free_bg_tilemaps(); + CleanupOverworldWindowsAndTilemaps(); sub_811A20C(gSpecialVar_0x8004, words, CB2_ReturnToFieldContinueScript, sizeParam); } @@ -383,7 +383,7 @@ static void sub_811A7E4(void) { lilycoveLady = &gSaveBlock1Ptr->lilycoveLady; lilycoveLady->quiz.unk_016 = -1; - overworld_free_bg_tilemaps(); + CleanupOverworldWindowsAndTilemaps(); sub_811A8F0(); } return; diff --git a/src/egg_hatch.c b/src/egg_hatch.c index a7b3e30b04..c2e57f8b51 100644 --- a/src/egg_hatch.c +++ b/src/egg_hatch.c @@ -379,7 +379,7 @@ static void AddHatchedMonToParty(u8 id) caughtLvl = 0; SetMonData(mon, MON_DATA_MET_LEVEL, &caughtLvl); - mapNameID = sav1_map_get_name(); + mapNameID = GetCurrentRegionMapSectionId(); SetMonData(mon, MON_DATA_MET_LOCATION, &mapNameID); MonRestorePP(mon); @@ -471,7 +471,7 @@ static void Task_EggHatch(u8 taskID) { if (!gPaletteFade.active) { - overworld_free_bg_tilemaps(); + CleanupOverworldWindowsAndTilemaps(); SetMainCallback2(CB2_EggHatch_0); gFieldCallback = sub_80AF168; DestroyTask(taskID); diff --git a/src/field_control_avatar.c b/src/field_control_avatar.c index 3774ef2b30..bac0417dca 100644 --- a/src/field_control_avatar.c +++ b/src/field_control_avatar.c @@ -28,6 +28,7 @@ #include "wild_encounter.h" #include "constants/bg_event_constants.h" #include "constants/map_types.h" +#include "constants/maps.h" #include "constants/songs.h" extern bool32 sub_8196034(void); @@ -818,19 +819,19 @@ static void sub_809CEB0(struct MapHeader *unused, s8 warpEventId, struct MapPosi warpEvent = &gMapHeader.events->warps[warpEventId]; } - if (warpEvent->mapNum == 0x7F) + if (warpEvent->mapNum == MAP_NUM(NONE)) { - copy_saved_warp2_bank_and_enter_x_to_warp1(warpEvent->warpId); + SetWarpDestinationToDynamicWarp(warpEvent->warpId); } else { const struct MapHeader *mapHeader; - warp1_set_2(warpEvent->mapGroup, warpEvent->mapNum, warpEvent->warpId); + SetWarpDestinationToMapWarp(warpEvent->mapGroup, warpEvent->mapNum, warpEvent->warpId); sub_8084D5C(position->x, position->y); mapHeader = Overworld_GetMapHeaderByGroupAndId(warpEvent->mapGroup, warpEvent->mapNum); - if (mapHeader->events->warps[warpEvent->warpId].mapNum == 0x7F) - saved_warp2_set(mapHeader->events->warps[warpEventId].warpId, gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, warpEventId); + if (mapHeader->events->warps[warpEvent->warpId].mapNum == MAP_NUM(NONE)) + SetDynamicWarp(mapHeader->events->warps[warpEventId].warpId, gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, warpEventId); } } diff --git a/src/field_effect.c b/src/field_effect.c index 9a65a444bd..75104d426e 100644 --- a/src/field_effect.c +++ b/src/field_effect.c @@ -2171,7 +2171,7 @@ static void EscapeRopeFieldEffect_Step1(struct Task *task) if (task->data[14] == 0 && !gPaletteFade.active && BGMusicStopped() == TRUE) { SetEventObjectDirection(eventObject, task->data[15]); - sub_8084E14(); + SetWarpDestinationToEscapeWarp(); WarpIntoMap(); gFieldCallback = mapldr_080859D4; SetMainCallback2(CB2_LoadMap); @@ -2332,7 +2332,7 @@ static void TeleportFieldEffectTask4(struct Task *task) if (BGMusicStopped() == TRUE) { - Overworld_SetWarpDestToLastHealLoc(); + SetWarpDestinationToLastHealLocation(); WarpIntoMap(); SetMainCallback2(CB2_LoadMap); gFieldCallback = mapldr_08085D88; @@ -2443,7 +2443,7 @@ static void sub_80B8410(struct Task *task) bool8 FldEff_FieldMoveShowMon(void) { u8 taskId; - if (is_map_type_1_2_3_5_or_6(Overworld_GetMapTypeOfSaveblockLocation()) == TRUE) + if (is_map_type_1_2_3_5_or_6(GetCurrentMapType()) == TRUE) { taskId = CreateTask(sub_80B8554, 0xff); } else diff --git a/src/field_message_box.c b/src/field_message_box.c index 46da9e9e51..5e23b5f6bd 100755 --- a/src/field_message_box.c +++ b/src/field_message_box.c @@ -8,21 +8,21 @@ extern bool32 sub_8196094(void); extern void sub_8196080(u8*); -EWRAM_DATA u8 gUnknown_020375BC = 0; +static EWRAM_DATA u8 sFieldMessageBoxMode = 0; -void textbox_fdecode_auto_and_task_add(u8*, int); -void textbox_auto_and_task_add(void); +static void textbox_fdecode_auto_and_task_add(u8*, bool32); +static void textbox_auto_and_task_add(void); -void sub_8098128(void) +void InitFieldMessageBox(void) { - gUnknown_020375BC = 0; + sFieldMessageBoxMode = 0; gTextFlags.canABSpeedUpPrint = 0; gTextFlags.useAlternateDownArrow = 0; gTextFlags.autoScroll = 0; gTextFlags.forceMidTextSpeed = 0; } -void sub_8098154(u8 taskId) +static void sub_8098154(u8 taskId) { struct Task *task = &gTasks[taskId]; @@ -39,18 +39,18 @@ void sub_8098154(u8 taskId) case 2: if (RunTextPrintersAndIsPrinter0Active() != 1) { - gUnknown_020375BC = 0; + sFieldMessageBoxMode = 0; DestroyTask(taskId); } } } -void task_add_textbox(void) +static void task_add_textbox(void) { CreateTask(sub_8098154, 0x50); } -void task_del_textbox(void) +static void task_del_textbox(void) { u8 taskId = FindTaskIdByFunc(sub_8098154); if (taskId != 0xFF) @@ -59,10 +59,10 @@ void task_del_textbox(void) bool8 ShowFieldMessage(u8 *str) { - if (gUnknown_020375BC != 0) + if (sFieldMessageBoxMode != 0) return FALSE; textbox_fdecode_auto_and_task_add(str, 1); - gUnknown_020375BC = 2; + sFieldMessageBoxMode = 2; return TRUE; } @@ -70,57 +70,57 @@ void sub_8098214(u8 taskId) { if (!sub_8196094()) { - gUnknown_020375BC = 0; + sFieldMessageBoxMode = 0; DestroyTask(taskId); } } bool8 sub_8098238(u8 *str) { - if (gUnknown_020375BC != 0) + if (sFieldMessageBoxMode != 0) return FALSE; StringExpandPlaceholders(gStringVar4, str); CreateTask(sub_8098214, 0); sub_8196080(str); - gUnknown_020375BC = 2; + sFieldMessageBoxMode = 2; return TRUE; } bool8 ShowFieldAutoScrollMessage(u8 *str) { - if (gUnknown_020375BC != 0) + if (sFieldMessageBoxMode != 0) return FALSE; - gUnknown_020375BC = 3; + sFieldMessageBoxMode = 3; textbox_fdecode_auto_and_task_add(str, 0); return TRUE; } bool8 sub_80982A0(u8 *str) { - gUnknown_020375BC = 3; + sFieldMessageBoxMode = 3; textbox_fdecode_auto_and_task_add(str, 1); return TRUE; } bool8 sub_80982B8(void) { - if (gUnknown_020375BC != 0) + if (sFieldMessageBoxMode != 0) return FALSE; - gUnknown_020375BC = 2; + sFieldMessageBoxMode = 2; textbox_auto_and_task_add(); return TRUE; } -void textbox_fdecode_auto_and_task_add(u8* str, int a) +static void textbox_fdecode_auto_and_task_add(u8* str, bool32 allowSkippingDelayWithButtonPress) { StringExpandPlaceholders(gStringVar4, str); - AddTextPrinterForMessage(a); + AddTextPrinterForMessage(allowSkippingDelayWithButtonPress); task_add_textbox(); } -void textbox_auto_and_task_add(void) +static void textbox_auto_and_task_add(void) { - AddTextPrinterForMessage(1); + AddTextPrinterForMessage(TRUE); task_add_textbox(); } @@ -128,17 +128,17 @@ void HideFieldMessageBox(void) { task_del_textbox(); sub_8197434(0, 1); - gUnknown_020375BC = 0; + sFieldMessageBoxMode = 0; } u8 GetFieldMessageBoxMode(void) { - return gUnknown_020375BC; + return sFieldMessageBoxMode; } bool8 IsFieldMessageBoxHidden(void) { - if (gUnknown_020375BC == 0) + if (sFieldMessageBoxMode == 0) return TRUE; return FALSE; } @@ -147,11 +147,11 @@ void sub_8098358(void) { task_del_textbox(); NewMenuHelpers_DrawStdWindowFrame(0, 1); - gUnknown_020375BC = 0; + sFieldMessageBoxMode = 0; } void sub_8098374(void) { task_del_textbox(); - gUnknown_020375BC = 0; + sFieldMessageBoxMode = 0; } diff --git a/src/field_screen_effect.c b/src/field_screen_effect.c index a6b7e7c248..62a3d0335a 100644 --- a/src/field_screen_effect.c +++ b/src/field_screen_effect.c @@ -89,7 +89,7 @@ static void palette_bg_faded_fill_black(void) void pal_fill_for_maplights(void) { u8 previousMapType = GetLastUsedWarpMapType(); - switch (GetMapPairFadeFromType(previousMapType, Overworld_GetMapTypeOfSaveblockLocation())) + switch (GetMapPairFadeFromType(previousMapType, GetCurrentMapType())) { case 0: palette_bg_faded_fill_black(); @@ -115,7 +115,7 @@ void pal_fill_black(void) void WarpFadeScreen(void) { - u8 currentMapType = Overworld_GetMapTypeOfSaveblockLocation(); + u8 currentMapType = GetCurrentMapType(); switch (GetMapPairFadeToType(currentMapType, GetDestinationWarpMapHeader()->mapType)) { case 0: diff --git a/src/field_special_scene.c b/src/field_special_scene.c index 1cabf63d69..3675cf0d89 100644 --- a/src/field_special_scene.c +++ b/src/field_special_scene.c @@ -1,7 +1,12 @@ #include "global.h" #include "event_data.h" #include "event_object_movement.h" +#include "field_camera.h" +#include "field_screen_effect.h" +#include "field_specials.h" +#include "fieldmap.h" #include "main.h" +#include "overworld.h" #include "palette.h" #include "script.h" #include "script_movement.h" @@ -13,14 +18,6 @@ #define SECONDS(value) ((signed) (60.0 * value + 0.5)) -extern u8 GetSSTidalLocation(s8 *, s8 *, s16 *, s16 *); // should be in field_specials.h -extern void Overworld_SetWarpDestination(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y); -extern bool32 CountSSTidalStep(u16); -extern void copy_saved_warp2_bank_and_enter_x_to_warp1(u8 unused); -extern void sp13E_warp_to_last_warp(void); -extern void saved_warp2_set(int unused, s8 mapGroup, s8 mapNum, s8 warpId); -extern void sub_80AF8B8(void); - // porthole states enum { @@ -30,20 +27,13 @@ enum EXIT_PORTHOLE, }; -extern void SetCameraPanning(s16 x, s16 y); -extern void SetCameraPanningCallback(void ( *callback)()); -extern void InstallCameraPanAheadCallback(); -extern void pal_fill_black(void); -extern void MapGridSetMetatileIdAt(s32 x, s32 y, u16 metatileId); -extern void DrawWholeMapView(); - //. rodata static const s8 gTruckCamera_HorizontalTable[] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 2, 2, 2, 2, 2, -1, -1, -1, 0}; const u8 gUnknown_0858E8AB[] = {0x18, 0xFE}; const u8 gUnknown_0858E8AD[] = {0x17, 0xFE}; // .text -void Task_Truck3(u8); +static void Task_Truck3(u8); s16 GetTruckCameraBobbingY(int a1) { @@ -121,7 +111,7 @@ void Task_Truck2(u8 taskId) } } -void Task_Truck3(u8 taskId) +static void Task_Truck3(u8 taskId) { s16 *data = gTasks[taskId].data; s16 cameraXpan; @@ -256,7 +246,7 @@ bool8 sub_80FB59C(void) } else { - Overworld_SetWarpDestination(mapGroup, mapNum, -1, x, y); + SetWarpDestination(mapGroup, mapNum, -1, x, y); return TRUE; } } @@ -312,7 +302,7 @@ void Task_HandlePorthole(u8 taskId) case EXIT_PORTHOLE: // exit porthole. FlagClear(0x4001); FlagClear(0x4000); - copy_saved_warp2_bank_and_enter_x_to_warp1(0); + SetWarpDestinationToDynamicWarp(0); sp13E_warp_to_last_warp(); DestroyTask(taskId); break; @@ -349,7 +339,7 @@ void sub_80FB7A4(void) FlagSet(FLAG_SYS_CRUISE_MODE); FlagSet(0x4001); FlagSet(0x4000); - saved_warp2_set(0, gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1); + SetDynamicWarp(0, gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1); sub_80FB59C(); sub_80AF8B8(); } diff --git a/src/field_specials.c b/src/field_specials.c index 5e1c86dfe2..4e9a5c0f75 100644 --- a/src/field_specials.c +++ b/src/field_specials.c @@ -945,11 +945,11 @@ void CableCarWarp(void) { if (gSpecialVar_0x8004 != 0) { - Overworld_SetWarpDestination(MAP_GROUP(ROUTE112_CABLE_CAR_STATION), MAP_NUM(ROUTE112_CABLE_CAR_STATION), -1, 6, 4); + SetWarpDestination(MAP_GROUP(ROUTE112_CABLE_CAR_STATION), MAP_NUM(ROUTE112_CABLE_CAR_STATION), -1, 6, 4); } else { - Overworld_SetWarpDestination(MAP_GROUP(MT_CHIMNEY_CABLE_CAR_STATION), MAP_NUM(MT_CHIMNEY_CABLE_CAR_STATION), -1, 6, 4); + SetWarpDestination(MAP_GROUP(MT_CHIMNEY_CABLE_CAR_STATION), MAP_NUM(MT_CHIMNEY_CABLE_CAR_STATION), -1, 6, 4); } } @@ -1725,7 +1725,7 @@ const u16 gUnknown_085B2C06[][3] = void SetDepartmentStoreFloorVar(void) { u8 deptStoreFloor; - switch (gSaveBlock1Ptr->warp2.mapNum) + switch (gSaveBlock1Ptr->dynamicWarp.mapNum) { case MAP_NUM(LILYCOVE_CITY_DEPARTMENT_STORE_1F): deptStoreFloor = 4; @@ -1757,9 +1757,9 @@ u16 sub_81399F4(void) gUnknown_0203AB60 = 0; gUnknown_0203AB62 = 0; - if (gSaveBlock1Ptr->warp2.mapGroup == 13) + if (gSaveBlock1Ptr->dynamicWarp.mapGroup == MAP_GROUP(LILYCOVE_CITY_DEPARTMENT_STORE_1F)) { - switch (gSaveBlock1Ptr->warp2.mapNum) + switch (gSaveBlock1Ptr->dynamicWarp.mapNum) { case MAP_NUM(LILYCOVE_CITY_DEPARTMENT_STORE_5F): gUnknown_0203AB60 = 0; @@ -3813,7 +3813,7 @@ void sub_813B9A0(void) { if (gSaveBlock1Ptr->lastHealLocation.mapGroup == MAP_GROUP(DEWFORD_TOWN) && gSaveBlock1Ptr->lastHealLocation.mapNum == MAP_NUM(DEWFORD_TOWN)) { - Overworld_SetHealLocationWarp(3); + SetLastHealLocationWarp(3); } } diff --git a/src/fldeff_flash.c b/src/fldeff_flash.c index 69d198c842..f3bd76cbf6 100644 --- a/src/fldeff_flash.c +++ b/src/fldeff_flash.c @@ -156,7 +156,7 @@ static bool8 sub_8137304(void) { u8 i; u8 v0 = GetLastUsedWarpMapType(); - u8 v1 = Overworld_GetMapTypeOfSaveblockLocation(); + u8 v1 = GetCurrentMapType(); for (i = 0; gUnknown_085B27C8[i].unk0; i++) { diff --git a/src/frontier_util.c b/src/frontier_util.c index c722230cd6..40b1edbe33 100644 --- a/src/frontier_util.c +++ b/src/frontier_util.c @@ -2407,9 +2407,9 @@ void sub_81A4C30(void) i = gPlayerPartyCount; LoadPlayerParty(); - sub_8076D5C(); + SetContinueGameWarpStatusToDynamicWarp(); TrySavingData(SAVE_LINK); - sav2_gender2_inplace_and_xFE(); + ClearContinueGameWarpStatus2(); gPlayerPartyCount = i; for (i = 0; i < PARTY_SIZE; i++) diff --git a/src/hall_of_fame.c b/src/hall_of_fame.c index 34d62149a1..3f217b7828 100644 --- a/src/hall_of_fame.c +++ b/src/hall_of_fame.c @@ -1299,7 +1299,7 @@ static bool8 sub_8175024(void) CopyBgTilemapBufferToVram(3); break; case 3: - sub_81971D0(); + InitStandardTextBoxWindows(); sub_8197200(); break; case 4: diff --git a/src/item_use.c b/src/item_use.c index f82071a17e..7592673454 100755 --- a/src/item_use.c +++ b/src/item_use.c @@ -627,7 +627,7 @@ void sub_80FDC00(u8 taskId) { if (!gPaletteFade.active) { - overworld_free_bg_tilemaps(); + CleanupOverworldWindowsAndTilemaps(); OpenPokeblockCase(0, CB2_ReturnToField); DestroyTask(taskId); } diff --git a/src/load_save.c b/src/load_save.c index 9636264287..a7593d007e 100644 --- a/src/load_save.c +++ b/src/load_save.c @@ -1,13 +1,14 @@ #include "global.h" -#include "gba/flash_internal.h" +#include "alloc.h" +#include "item.h" #include "load_save.h" #include "main.h" +#include "overworld.h" #include "pokemon.h" #include "pokemon_storage_system.h" #include "random.h" -#include "alloc.h" -#include "item.h" -#include "overworld.h" +#include "save_location.h" +#include "gba/flash_internal.h" #include "decoration_inventory.h" static void ApplyNewEncryptionKeyToAllEncryptedData(u32 encryptionKey); @@ -136,30 +137,30 @@ void MoveSaveBlocks_ResetHeap(void) gSaveBlock2Ptr->encryptionKey = encryptionKey; } -u32 GetSecretBase2Field_9(void) +u32 UseContinueGameWarp(void) { - return gSaveBlock2Ptr->specialSaveWarp & 1; + return gSaveBlock2Ptr->specialSaveWarpFlags & CONTINUE_GAME_WARP; } -void ClearSecretBase2Field_9(void) +void ClearContinueGameWarpStatus(void) { - gSaveBlock2Ptr->specialSaveWarp &= ~1; + gSaveBlock2Ptr->specialSaveWarpFlags &= ~CONTINUE_GAME_WARP; } -void SetSecretBase2Field_9(void) +void SetContinueGameWarpStatus(void) { - gSaveBlock2Ptr->specialSaveWarp |= 1; + gSaveBlock2Ptr->specialSaveWarpFlags |= CONTINUE_GAME_WARP; } -void sub_8076D5C(void) +void SetContinueGameWarpStatusToDynamicWarp(void) { - sub_8084FAC(0); - gSaveBlock2Ptr->specialSaveWarp |= 1; + SetContinueGameWarpToDynamicWarp(0); + gSaveBlock2Ptr->specialSaveWarpFlags |= CONTINUE_GAME_WARP; } -void sav2_gender2_inplace_and_xFE(void) +void ClearContinueGameWarpStatus2(void) { - gSaveBlock2Ptr->specialSaveWarp &= ~1; + gSaveBlock2Ptr->specialSaveWarpFlags &= ~CONTINUE_GAME_WARP; } void SavePlayerParty(void) diff --git a/src/menu.c b/src/menu.c index 8c3c61ea76..f1b35b42e7 100644 --- a/src/menu.c +++ b/src/menu.c @@ -48,8 +48,8 @@ struct Menu bool8 APressMuted; }; -static EWRAM_DATA u8 gStartMenuWindowId = 0; -static EWRAM_DATA u8 gUnknown_0203CD8D = 0; +static EWRAM_DATA u8 sStartMenuWindowId = 0; +static EWRAM_DATA u8 sMapNamePopupWindowId = 0; static EWRAM_DATA struct Menu gUnknown_0203CD90 = {0}; static EWRAM_DATA u16 gUnknown_0203CD9C = 0; static EWRAM_DATA u8 gUnknown_0203CD9E = 0; @@ -63,7 +63,7 @@ static EWRAM_DATA void *gUnknown_0203CDAC[0x20] = {NULL}; const u16 gUnknown_0860F074[] = INCBIN_U16("graphics/interface/860F074.gbapal"); static const u8 gUnknown_0860F094[] = { 8, 4, 1 }; -static const struct WindowTemplate gUnknown_0860F098[] = +static const struct WindowTemplate sStandardTextBox_WindowTemplates[] = { { .bg = 0, @@ -77,7 +77,7 @@ static const struct WindowTemplate gUnknown_0860F098[] = DUMMY_WIN_TEMPLATE }; -static const struct WindowTemplate gUnknown_0860F0A8 = +static const struct WindowTemplate sYesNo_WindowTemplates = { .bg = 0, .tilemapLeft = 21, @@ -137,14 +137,14 @@ extern u8 sub_8199134(s8, s8); extern void sub_8198C78(void); extern void task_free_buf_after_copying_tile_data_to_vram(u8 taskId); -void sub_81971D0(void) +void InitStandardTextBoxWindows(void) { - InitWindows(gUnknown_0860F098); - gStartMenuWindowId = 0xFF; - gUnknown_0203CD8D = 0xFF; + InitWindows(sStandardTextBox_WindowTemplates); + sStartMenuWindowId = 0xFF; + sMapNamePopupWindowId = 0xFF; } -void sub_81971F4(void) +void FreeAllOverworldWindowBuffers(void) { FreeAllWindowBuffers(); } @@ -460,12 +460,12 @@ void DisplayItemMessageOnField(u8 taskId, const u8 *string, TaskFunc callback) void DisplayYesNoMenu(void) { - CreateYesNoMenu(&gUnknown_0860F0A8, STD_WINDOW_BASE_TILE_NUM, STD_WINDOW_PALETTE_NUM, 0); + CreateYesNoMenu(&sYesNo_WindowTemplates, STD_WINDOW_BASE_TILE_NUM, STD_WINDOW_PALETTE_NUM, 0); } void sub_8197948(u8 initialCursorPos) { - CreateYesNoMenu(&gUnknown_0860F0A8, STD_WINDOW_BASE_TILE_NUM, STD_WINDOW_PALETTE_NUM, initialCursorPos); + CreateYesNoMenu(&sYesNo_WindowTemplates, STD_WINDOW_BASE_TILE_NUM, STD_WINDOW_PALETTE_NUM, initialCursorPos); } u32 GetPlayerTextSpeed(void) @@ -486,22 +486,22 @@ u8 GetPlayerTextSpeedDelay(void) u8 sub_81979C4(u8 a1) { - if (gStartMenuWindowId == 0xFF) - gStartMenuWindowId = sub_8198AA4(0, 0x16, 1, 7, (a1 * 2) + 2, 0xF, 0x139); - return gStartMenuWindowId; + if (sStartMenuWindowId == 0xFF) + sStartMenuWindowId = sub_8198AA4(0, 0x16, 1, 7, (a1 * 2) + 2, 0xF, 0x139); + return sStartMenuWindowId; } u8 GetStartMenuWindowId(void) { - return gStartMenuWindowId; + return sStartMenuWindowId; } void RemoveStartMenuWindow(void) { - if (gStartMenuWindowId != 0xFF) + if (sStartMenuWindowId != 0xFF) { - RemoveWindow(gStartMenuWindowId); - gStartMenuWindowId = 0xFF; + RemoveWindow(sStartMenuWindowId); + sStartMenuWindowId = 0xFF; } } @@ -517,22 +517,22 @@ u16 sub_8197A38(void) u8 AddMapNamePopUpWindow(void) { - if (gUnknown_0203CD8D == 0xFF) - gUnknown_0203CD8D = sub_8198AA4(0, 1, 1, 10, 3, 14, 0x107); - return gUnknown_0203CD8D; + if (sMapNamePopupWindowId == 0xFF) + sMapNamePopupWindowId = sub_8198AA4(0, 1, 1, 10, 3, 14, 0x107); + return sMapNamePopupWindowId; } u8 GetMapNamePopUpWindowId(void) { - return gUnknown_0203CD8D; + return sMapNamePopupWindowId; } void RemoveMapNamePopUpWindow(void) { - if (gUnknown_0203CD8D != 0xFF) + if (sMapNamePopupWindowId != 0xFF) { - RemoveWindow(gUnknown_0203CD8D); - gUnknown_0203CD8D = 0xFF; + RemoveWindow(sMapNamePopupWindowId); + sMapNamePopupWindowId = 0xFF; } } diff --git a/src/mirage_tower.c b/src/mirage_tower.c index bfaea4c5e7..a8dd5d9de8 100644 --- a/src/mirage_tower.c +++ b/src/mirage_tower.c @@ -625,7 +625,7 @@ static void DoMirageTowerDisintegration(u8 taskId) SetGpuRegBits(REG_OFFSET_BG2CNT, BGCNT_PRIORITY(2)); SetGpuRegBits(REG_OFFSET_BG0CNT, BGCNT_PRIORITY(0)); SetBgAttribute(0, BG_ATTR_PRIORITY, 0); - sub_81971D0(); + InitStandardTextBoxWindows(); break; case 7: ShowBg(0); diff --git a/src/naming_screen.c b/src/naming_screen.c index e6d146b853..c310ceb9fb 100644 --- a/src/naming_screen.c +++ b/src/naming_screen.c @@ -362,7 +362,7 @@ static void NamingScreen_InitBGs(void) ChangeBgX(3, 0, 0); ChangeBgY(3, 0, 0); - sub_81971D0(); + InitStandardTextBoxWindows(); sub_8197200(); for (i = 0; i < 5; i++) diff --git a/src/new_game.c b/src/new_game.c index 82e8c2c960..8ecd48bc7a 100644 --- a/src/new_game.c +++ b/src/new_game.c @@ -136,7 +136,7 @@ static void ClearFrontierRecord(void) static void WarpToTruck(void) { - Overworld_SetWarpDestination(MAP_GROUP(INSIDE_OF_TRUCK), MAP_NUM(INSIDE_OF_TRUCK), -1, -1, -1); + SetWarpDestination(MAP_GROUP(INSIDE_OF_TRUCK), MAP_NUM(INSIDE_OF_TRUCK), -1, -1, -1); WarpIntoMap(); } @@ -169,7 +169,7 @@ void NewGameInitData(void) ClearFrontierRecord(); ClearSav1(); ClearMailData(); - gSaveBlock2Ptr->specialSaveWarp = 0; + gSaveBlock2Ptr->specialSaveWarpFlags = 0; gSaveBlock2Ptr->field_A8 = 0; InitPlayerTrainerId(); PlayTimeCounter_Reset(); diff --git a/src/overworld.c b/src/overworld.c index 2aad688615..217b4c27e0 100644 --- a/src/overworld.c +++ b/src/overworld.c @@ -57,8 +57,10 @@ #include "constants/abilities.h" #include "constants/map_types.h" #include "constants/maps.h" +#include "constants/region_map_sections.h" #include "constants/songs.h" #include "constants/species.h" +#include "constants/weather.h" // event scripts extern const u8 EventScript_WhiteOut[]; @@ -114,7 +116,6 @@ extern void c2_change_map(void); extern void sub_81D5DF8(void); extern void sub_80EB218(void); extern void sub_80AF3C8(void); -extern void sub_81971F4(void); extern void sub_808B578(void); extern void sub_80AF314(void); extern void sub_80AF214(void); @@ -134,7 +135,7 @@ extern void sub_81AA2F8(void); extern void sub_8195E10(void); extern void sub_80EDB44(void); extern void sub_81D64C0(void); -extern void sub_8098128(void); +extern void InitFieldMessageBox(void); extern void copy_map_tileset1_to_vram(const struct MapLayout *); extern void copy_map_tileset2_to_vram(const struct MapLayout *); extern void FieldUpdateBgTilemapScroll(void); @@ -339,7 +340,7 @@ const struct UCoords32 gDirectionToVectors[] = }, }; -static const struct BgTemplate gUnknown_08339DAC[] = +static const struct BgTemplate sOverworldBgTemplates[] = { { .bg = 0, @@ -433,7 +434,7 @@ void DoWhiteOut(void) SetMoney(&gSaveBlock1Ptr->money, GetMoney(&gSaveBlock1Ptr->money) / 2); HealPlayerParty(); Overworld_ResetStateAfterWhiteOut(); - Overworld_SetWarpDestToLastHealLoc(); + SetWarpDestinationToLastHealLocation(); WarpIntoMap(); } @@ -615,7 +616,7 @@ void ApplyCurrentWarp(void) gFixedHoleWarp = sDummyWarpData; } -void set_warp2_warp3_to_neg_1(void) +static void ClearDiveAndHoleWarps(void) { gFixedDiveWarp = sDummyWarpData; gFixedHoleWarp = sDummyWarpData; @@ -696,68 +697,66 @@ void WarpIntoMap(void) SetPlayerCoordsFromWarp(); } -void Overworld_SetWarpDestination(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y) +void SetWarpDestination(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y) { SetWarpData(&sWarpDestination, mapGroup, mapNum, warpId, x, y); } -void warp1_set_2(s8 mapGroup, s8 mapNum, s8 warpId) +void SetWarpDestinationToMapWarp(s8 mapGroup, s8 mapNum, s8 warpId) { - Overworld_SetWarpDestination(mapGroup, mapNum, warpId, -1, -1); + SetWarpDestination(mapGroup, mapNum, warpId, -1, -1); } -void saved_warp2_set(s32 unused, s8 mapGroup, s8 mapNum, s8 warpId) +void SetDynamicWarp(s32 unused, s8 mapGroup, s8 mapNum, s8 warpId) { - SetWarpData(&gSaveBlock1Ptr->warp2, mapGroup, mapNum, warpId, gSaveBlock1Ptr->pos.x, gSaveBlock1Ptr->pos.y); + SetWarpData(&gSaveBlock1Ptr->dynamicWarp, mapGroup, mapNum, warpId, gSaveBlock1Ptr->pos.x, gSaveBlock1Ptr->pos.y); } -void saved_warp2_set_2(s32 unused, s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y) +void SetDynamicWarpWithCoords(s32 unused, s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y) { - SetWarpData(&gSaveBlock1Ptr->warp2, mapGroup, mapNum, warpId, x, y); + SetWarpData(&gSaveBlock1Ptr->dynamicWarp, mapGroup, mapNum, warpId, x, y); } -void copy_saved_warp2_bank_and_enter_x_to_warp1(u8 unused) +void SetWarpDestinationToDynamicWarp(u8 unusedWarpId) { - sWarpDestination = gSaveBlock1Ptr->warp2; + sWarpDestination = gSaveBlock1Ptr->dynamicWarp; } -void sub_8084CCC(u8 a1) +void SetWarpDestinationToHealLocation(u8 healLocationId) { - const struct HealLocation *warp = GetHealLocation(a1); - + const struct HealLocation *warp = GetHealLocation(healLocationId); if (warp) - Overworld_SetWarpDestination(warp->group, warp->map, -1, warp->x, warp->y); + SetWarpDestination(warp->group, warp->map, -1, warp->x, warp->y); } -void Overworld_SetWarpDestToLastHealLoc(void) +void SetWarpDestinationToLastHealLocation(void) { sWarpDestination = gSaveBlock1Ptr->lastHealLocation; } -void Overworld_SetHealLocationWarp(u8 healLocationId) +void SetLastHealLocationWarp(u8 healLocationId) { const struct HealLocation *healLocation = GetHealLocation(healLocationId); - - if (healLocation != NULL) + if (healLocation) SetWarpData(&gSaveBlock1Ptr->lastHealLocation, healLocation->group, healLocation->map, -1, healLocation->x, healLocation->y); } -void sub_8084D5C(s16 a1, s16 a2) +void sub_8084D5C(s16 x, s16 y) { - u8 currMapType = Overworld_GetMapTypeOfSaveblockLocation(); + u8 currMapType = GetCurrentMapType(); u8 destMapType = GetMapTypeByGroupAndId(sWarpDestination.mapGroup, sWarpDestination.mapNum); if (is_map_type_1_2_3_5_or_6(currMapType) && is_map_type_1_2_3_5_or_6(destMapType) != TRUE) - sub_8084DD4(gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1, a1 - 7, a2 - 6); + SetEscapeWarp(gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1, x - 7, y - 6); } -void sub_8084DD4(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y) +void SetEscapeWarp(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y) { - SetWarpData(&gSaveBlock1Ptr->warp4, mapGroup, mapNum, warpId, x, y); + SetWarpData(&gSaveBlock1Ptr->escapeWarp, mapGroup, mapNum, warpId, x, y); } -void sub_8084E14(void) +void SetWarpDestinationToEscapeWarp(void) { - sWarpDestination = gSaveBlock1Ptr->warp4; + sWarpDestination = gSaveBlock1Ptr->escapeWarp; } void SetFixedDiveWarp(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y) @@ -765,7 +764,7 @@ void SetFixedDiveWarp(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y) SetWarpData(&gFixedDiveWarp, mapGroup, mapNum, warpId, x, y); } -static void SetFixedDiveWarpAsDestination(void) +static void SetWarpDestinationToDiveWarp(void) { sWarpDestination = gFixedDiveWarp; } @@ -775,34 +774,34 @@ void SetFixedHoleWarp(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y) SetWarpData(&gFixedHoleWarp, mapGroup, mapNum, warpId, x, y); } -void SetFixedHoleWarpAsDestination(s16 x, s16 y) +void SetWarpDestinationToFixedHoleWarp(s16 x, s16 y) { if (IsDummyWarp(&gFixedHoleWarp) == TRUE) sWarpDestination = gLastUsedWarp; else - Overworld_SetWarpDestination(gFixedHoleWarp.mapGroup, gFixedHoleWarp.mapNum, -1, x, y); + SetWarpDestination(gFixedHoleWarp.mapGroup, gFixedHoleWarp.mapNum, -1, x, y); } -void warp1_set_to_sav1w(void) +static void SetWarpDestinationToContinueGameWarp(void) { - sWarpDestination = gSaveBlock1Ptr->warp1; + sWarpDestination = gSaveBlock1Ptr->continueGameWarp; } -void sub_8084F2C(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y) +void SetContinueGameWarp(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y) { - SetWarpData(&gSaveBlock1Ptr->warp1, mapGroup, mapNum, warpId, x, y); + SetWarpData(&gSaveBlock1Ptr->continueGameWarp, mapGroup, mapNum, warpId, x, y); } -void sub_8084F6C(u8 a1) +void SetContinueGameWarpToHealLocation(u8 healLocationId) { - const struct HealLocation *warp = GetHealLocation(a1); + const struct HealLocation *warp = GetHealLocation(healLocationId); if (warp) - SetWarpData(&gSaveBlock1Ptr->warp1, warp->group, warp->map, -1, warp->x, warp->y); + SetWarpData(&gSaveBlock1Ptr->continueGameWarp, warp->group, warp->map, -1, warp->x, warp->y); } -void sub_8084FAC(int unused) +void SetContinueGameWarpToDynamicWarp(int unused) { - gSaveBlock1Ptr->warp1 = gSaveBlock1Ptr->warp2; + gSaveBlock1Ptr->continueGameWarp = gSaveBlock1Ptr->dynamicWarp; } const struct MapConnection *GetMapConnection(u8 dir) @@ -827,14 +826,14 @@ static bool8 SetDiveWarp(u8 dir, u16 x, u16 y) if (connection != NULL) { - Overworld_SetWarpDestination(connection->mapGroup, connection->mapNum, -1, x, y); + SetWarpDestination(connection->mapGroup, connection->mapNum, -1, x, y); } else { mapheader_run_script_with_tag_x6(); if (IsDummyWarp(&gFixedDiveWarp)) return FALSE; - SetFixedDiveWarpAsDestination(); + SetWarpDestinationToDiveWarp(); } return TRUE; } @@ -853,7 +852,7 @@ void mliX_load_map(u8 mapGroup, u8 mapNum) { s32 paletteIndex; - Overworld_SetWarpDestination(mapGroup, mapNum, -1, -1, -1); + SetWarpDestination(mapGroup, mapNum, -1, -1, -1); if (gMapHeader.regionMapSectionId != 0x3A) sub_8085810(); @@ -885,7 +884,7 @@ void mliX_load_map(u8 mapGroup, u8 mapNum) ResetFieldTasksArgs(); mapheader_run_script_with_tag_x5(); - if (gMapHeader.regionMapSectionId != 0x3A || gMapHeader.regionMapSectionId != sLastMapSectionId) + if (gMapHeader.regionMapSectionId != MAPSEC_BATTLE_FRONTIER || gMapHeader.regionMapSectionId != sLastMapSectionId) ShowMapNamePopup(); } @@ -964,7 +963,7 @@ void StoreInitialPlayerAvatarState(void) static struct InitialPlayerAvatarState *GetInitialPlayerAvatarState(void) { struct InitialPlayerAvatarState playerStruct; - u8 mapType = Overworld_GetMapTypeOfSaveblockLocation(); + u8 mapType = GetCurrentMapType(); u16 metatileBehavior = GetCenterScreenMetatileBehavior(); u8 transitionFlags = GetAdjustedInitialTransitionFlags(&gInitialPlayerAvatarState, metatileBehavior, mapType); playerStruct.transitionFlags = transitionFlags; @@ -1051,7 +1050,7 @@ u8 Overworld_GetFlashLevel(void) return gSaveBlock1Ptr->flashLevel; } -void sub_8085524(u16 mapLayoutId) +void SetCurrentMapLayout(u16 mapLayoutId) { gSaveBlock1Ptr->mapLayoutId = mapLayoutId; gMapHeader.mapLayout = GetMapLayout(); @@ -1160,11 +1159,11 @@ u16 GetCurrLocationDefaultMusic(void) // Play the desert music only when the sandstorm is active on Route 111. if (gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(ROUTE111) && gSaveBlock1Ptr->location.mapNum == MAP_NUM(ROUTE111) - && GetSav1Weather() == 8) + && GetSav1Weather() == WEATHER_SANDSTORM) return MUS_ASHROAD; music = GetLocationMusic(&gSaveBlock1Ptr->location); - if (music != 0x7FFF) + if (music != MUS_ROUTE_118) { return music; } @@ -1180,7 +1179,7 @@ u16 GetCurrLocationDefaultMusic(void) u16 GetWarpDestinationMusic(void) { u16 music = GetLocationMusic(&sWarpDestination); - if (music != 0x7FFF) + if (music != MUS_ROUTE_118) { return music; } @@ -1207,7 +1206,7 @@ void Overworld_PlaySpecialMapMusic(void) { if (gSaveBlock1Ptr->savedMusic) music = gSaveBlock1Ptr->savedMusic; - else if (Overworld_GetMapTypeOfSaveblockLocation() == MAP_TYPE_UNDERWATER) + else if (GetCurrentMapType() == MAP_TYPE_UNDERWATER) music = MUS_DEEPDEEP; else if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_SURFING)) music = MUS_NAMINORI; @@ -1285,8 +1284,8 @@ void TryFadeOutOldMapMusic(void) && gSaveBlock1Ptr->location.mapNum == MAP_NUM(SOOTOPOLIS_CITY) && sWarpDestination.mapGroup == MAP_GROUP(SOOTOPOLIS_CITY) && sWarpDestination.mapNum == MAP_NUM(SOOTOPOLIS_CITY) - && sWarpDestination.x == 0x1D - && sWarpDestination.y == 0x35) + && sWarpDestination.x == 29 + && sWarpDestination.y == 53) return; FadeOutMapMusic(GetMapMusicFadeoutSpeed()); } @@ -1388,7 +1387,7 @@ u8 GetMapTypeByWarpData(struct WarpData *warp) return GetMapTypeByGroupAndId(warp->mapGroup, warp->mapNum); } -u8 Overworld_GetMapTypeOfSaveblockLocation(void) +u8 GetCurrentMapType(void) { return GetMapTypeByWarpData(&gSaveBlock1Ptr->location); } @@ -1430,12 +1429,12 @@ bool8 Overworld_MapTypeIsIndoors(u8 mapType) return FALSE; } -u8 sav1_saved_warp2_map_get_name(void) +u8 GetSavedWarpRegionMapSectionId(void) { - return Overworld_GetMapHeaderByGroupAndId(gSaveBlock1Ptr->warp2.mapGroup, gSaveBlock1Ptr->warp2.mapNum)->regionMapSectionId; + return Overworld_GetMapHeaderByGroupAndId(gSaveBlock1Ptr->dynamicWarp.mapGroup, gSaveBlock1Ptr->dynamicWarp.mapNum)->regionMapSectionId; } -u8 sav1_map_get_name(void) +u8 GetCurrentRegionMapSectionId(void) { return Overworld_GetMapHeaderByGroupAndId(gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum)->regionMapSectionId; } @@ -1445,30 +1444,30 @@ u8 GetCurrentMapBattleScene(void) return Overworld_GetMapHeaderByGroupAndId(gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum)->battleType; } -static void overworld_bg_setup(void) +static void InitOverworldBgs(void) { - InitBgsFromTemplates(0, gUnknown_08339DAC, ARRAY_COUNT(gUnknown_08339DAC)); + InitBgsFromTemplates(0, sOverworldBgTemplates, ARRAY_COUNT(sOverworldBgTemplates)); SetBgAttribute(1, BG_ATTR_MOSAIC, 1); SetBgAttribute(2, BG_ATTR_MOSAIC, 1); SetBgAttribute(3, BG_ATTR_MOSAIC, 1); - gBGTilemapBuffers2 = AllocZeroed(0x800); - gBGTilemapBuffers1 = AllocZeroed(0x800); - gBGTilemapBuffers3 = AllocZeroed(0x800); + gBGTilemapBuffers2 = AllocZeroed(BG_SCREEN_SIZE); + gBGTilemapBuffers1 = AllocZeroed(BG_SCREEN_SIZE); + gBGTilemapBuffers3 = AllocZeroed(BG_SCREEN_SIZE); SetBgTilemapBuffer(1, gBGTilemapBuffers2); SetBgTilemapBuffer(2, gBGTilemapBuffers1); SetBgTilemapBuffer(3, gBGTilemapBuffers3); - sub_81971D0(); + InitStandardTextBoxWindows(); } -void overworld_free_bg_tilemaps(void) +void CleanupOverworldWindowsAndTilemaps(void) { ClearMirageTowerPulseBlendEffect(); - sub_81971F4(); - if (gBGTilemapBuffers3 != NULL) + FreeAllOverworldWindowBuffers(); + if (gBGTilemapBuffers3) FREE_AND_SET_NULL(gBGTilemapBuffers3); - if (gBGTilemapBuffers1 != NULL) + if (gBGTilemapBuffers1) FREE_AND_SET_NULL(gBGTilemapBuffers1); - if (gBGTilemapBuffers2 != NULL) + if (gBGTilemapBuffers2) FREE_AND_SET_NULL(gBGTilemapBuffers2); } @@ -1762,7 +1761,7 @@ void CB2_ContinueSavedGame(void) sub_81A3908(); LoadSaveblockMapHeader(); - set_warp2_warp3_to_neg_1(); + ClearDiveAndHoleWarps(); trainerHillMapId = GetCurrentTrainerHillMapId(); if (gMapHeader.mapLayoutId == 0x169) sub_81AA2F8(); @@ -1785,10 +1784,10 @@ void CB2_ContinueSavedGame(void) ScriptContext1_Init(); ScriptContext2_Disable(); sub_8195E10(); - if (GetSecretBase2Field_9() == 1) + if (UseContinueGameWarp() == TRUE) { - ClearSecretBase2Field_9(); - warp1_set_to_sav1w(); + ClearContinueGameWarpStatus(); + SetWarpDestinationToContinueGameWarp(); WarpIntoMap(); sub_80EDB44(); SetMainCallback2(CB2_LoadMap); @@ -1861,7 +1860,7 @@ static bool32 map_loading_iteration_3(u8 *state) switch (*state) { case 0: - overworld_bg_setup(); + InitOverworldBgs(); ScriptContext1_Init(); ScriptContext2_Disable(); sub_80867C8(); @@ -2147,8 +2146,8 @@ static void InitOverworldGraphicsRegisters(void) clear_scheduled_bg_copies_to_vram(); reset_temp_tile_data_buffers(); SetGpuReg(REG_OFFSET_MOSAIC, 0); - SetGpuReg(REG_OFFSET_WININ, 0x1F1F); - SetGpuReg(REG_OFFSET_WINOUT, 0x101); + SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG_ALL | WININ_WIN0_OBJ | WININ_WIN1_BG_ALL | WININ_WIN1_OBJ); + SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WIN01_BG0 | WINOUT_WINOBJ_BG0); SetGpuReg(REG_OFFSET_WIN0H, 0xFF); SetGpuReg(REG_OFFSET_WIN0V, 0xFF); SetGpuReg(REG_OFFSET_WIN1H, 0xFFFF); @@ -2156,7 +2155,7 @@ static void InitOverworldGraphicsRegisters(void) SetGpuReg(REG_OFFSET_BLDCNT, gUnknown_82EC7C4[1] | gUnknown_82EC7C4[2] | gUnknown_82EC7C4[3] | BLDCNT_TGT2_OBJ | BLDCNT_EFFECT_BLEND); SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(13, 7)); - overworld_bg_setup(); + InitOverworldBgs(); schedule_bg_copy_tilemap_to_vram(1); schedule_bg_copy_tilemap_to_vram(2); schedule_bg_copy_tilemap_to_vram(3); @@ -2174,7 +2173,7 @@ static void InitOverworldGraphicsRegisters(void) ShowBg(1); ShowBg(2); ShowBg(3); - sub_8098128(); + InitFieldMessageBox(); } static void sub_8086988(u32 a1) diff --git a/src/party_menu.c b/src/party_menu.c index ac26caa5d5..9b992fb990 100755 --- a/src/party_menu.c +++ b/src/party_menu.c @@ -4721,7 +4721,7 @@ static void CursorCb_FieldMove(u8 taskId) gUnknown_0203CEC4->data[0] = fieldMove; break; case FIELD_MOVE_DIG: - mapHeader = Overworld_GetMapHeaderByGroupAndId(gSaveBlock1Ptr->warp4.mapGroup, gSaveBlock1Ptr->warp4.mapNum); + mapHeader = Overworld_GetMapHeaderByGroupAndId(gSaveBlock1Ptr->escapeWarp.mapGroup, gSaveBlock1Ptr->escapeWarp.mapNum); sub_81245DC(gStringVar1, mapHeader->regionMapSectionId); StringExpandPlaceholders(gStringVar4, gText_EscapeFromHere); sub_81B5674(taskId); @@ -7249,7 +7249,7 @@ static void sub_81B9424(u8 taskId) { if (!gPaletteFade.active) { - overworld_free_bg_tilemaps(); + CleanupOverworldWindowsAndTilemaps(); InitPartyMenu(2, 0, 11, 0, 0, sub_81B1370, sub_81B9470); DestroyTask(taskId); } @@ -7276,7 +7276,7 @@ static void sub_81B94D0(u8 taskId) { if (!gPaletteFade.active) { - overworld_free_bg_tilemaps(); + CleanupOverworldWindowsAndTilemaps(); InitPartyMenu(3, 0, 11, 0, 0, sub_81B1370, sub_81B9390); DestroyTask(taskId); } @@ -7293,7 +7293,7 @@ static void sub_81B953C(u8 taskId) { if (!gPaletteFade.active) { - overworld_free_bg_tilemaps(); + CleanupOverworldWindowsAndTilemaps(); InitPartyMenu(7, 0, 11, 0, 0, sub_81B1370, sub_81B9588); DestroyTask(taskId); } @@ -7336,7 +7336,7 @@ static void sub_81B9640(u8 taskId) { if (!gPaletteFade.active) { - overworld_free_bg_tilemaps(); + CleanupOverworldWindowsAndTilemaps(); InitPartyMenu(12, 0, 0, 0, 0, sub_81B1370, sub_81B9390); DestroyTask(taskId); } diff --git a/src/player_pc.c b/src/player_pc.c index b7380cee3d..474cecaf53 100644 --- a/src/player_pc.c +++ b/src/player_pc.c @@ -491,7 +491,7 @@ static void Task_ItemStorage_Deposit(u8 taskId) { if (!gPaletteFade.active) { - overworld_free_bg_tilemaps(); + CleanupOverworldWindowsAndTilemaps(); sub_81AAC14(); DestroyTask(taskId); } @@ -723,7 +723,7 @@ static void Mailbox_FadeAndReadMail(u8 taskId) if (!gPaletteFade.active) { sub_81D1EC0(); - overworld_free_bg_tilemaps(); + CleanupOverworldWindowsAndTilemaps(); ReadMail(&(gSaveBlock1Ptr->mail[playerPCItemPageInfo.itemsAbove + 6 + playerPCItemPageInfo.cursorPos]), Mailbox_ReturnToFieldFromReadMail, TRUE); DestroyTask(taskId); } @@ -823,7 +823,7 @@ static void Mailbox_DoGiveMailPokeMenu(u8 taskId) if (!gPaletteFade.active) { sub_81D1EC0(); - overworld_free_bg_tilemaps(); + CleanupOverworldWindowsAndTilemaps(); sub_81B8448(); DestroyTask(taskId); } diff --git a/src/pokemon.c b/src/pokemon.c index 96f564a199..8da42cd855 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -2588,7 +2588,7 @@ void CreateBoxMon(struct BoxPokemon *boxMon, u16 species, u8 level, u8 fixedIV, SetBoxMonData(boxMon, MON_DATA_SPECIES, &species); SetBoxMonData(boxMon, MON_DATA_EXP, &gExperienceTables[gBaseStats[species].growthRate][level]); SetBoxMonData(boxMon, MON_DATA_FRIENDSHIP, &gBaseStats[species].friendship); - value = sav1_map_get_name(); + value = GetCurrentRegionMapSectionId(); SetBoxMonData(boxMon, MON_DATA_MET_LOCATION, &value); SetBoxMonData(boxMon, MON_DATA_MET_LEVEL, &level); SetBoxMonData(boxMon, MON_DATA_MET_GAME, &gGameVersion); @@ -5457,7 +5457,7 @@ bool8 PokemonUseItemEffects(struct Pokemon *mon, u16 item, u8 partyIndex, u8 mov { if (GetMonData(mon, MON_DATA_POKEBALL, NULL) == 11) friendship++; - if (GetMonData(mon, MON_DATA_MET_LOCATION, NULL) == sav1_map_get_name()) + if (GetMonData(mon, MON_DATA_MET_LOCATION, NULL) == GetCurrentRegionMapSectionId()) friendship++; } if (friendship < 0) @@ -5483,7 +5483,7 @@ bool8 PokemonUseItemEffects(struct Pokemon *mon, u16 item, u8 partyIndex, u8 mov { if (GetMonData(mon, MON_DATA_POKEBALL, NULL) == 11) friendship++; - if (GetMonData(mon, MON_DATA_MET_LOCATION, NULL) == sav1_map_get_name()) + if (GetMonData(mon, MON_DATA_MET_LOCATION, NULL) == GetCurrentRegionMapSectionId()) friendship++; } if (friendship < 0) @@ -5508,7 +5508,7 @@ bool8 PokemonUseItemEffects(struct Pokemon *mon, u16 item, u8 partyIndex, u8 mov { if (GetMonData(mon, MON_DATA_POKEBALL, NULL) == 11) friendship++; - if (GetMonData(mon, MON_DATA_MET_LOCATION, NULL) == sav1_map_get_name()) + if (GetMonData(mon, MON_DATA_MET_LOCATION, NULL) == GetCurrentRegionMapSectionId()) friendship++; } if (friendship < 0) @@ -6156,7 +6156,7 @@ void AdjustFriendship(struct Pokemon *mon, u8 event) { if (GetMonData(mon, MON_DATA_POKEBALL, 0) == ITEM_LUXURY_BALL) friendship++; - if (GetMonData(mon, MON_DATA_MET_LOCATION, 0) == sav1_map_get_name()) + if (GetMonData(mon, MON_DATA_MET_LOCATION, 0) == GetCurrentRegionMapSectionId()) friendship++; } if (friendship < 0) diff --git a/src/pokemon_storage_system.c b/src/pokemon_storage_system.c index 91a1a5fd03..36ed78a546 100644 --- a/src/pokemon_storage_system.c +++ b/src/pokemon_storage_system.c @@ -1759,7 +1759,7 @@ static void Task_PokemonStorageSystemPC(u8 taskId) case 4: if (!gPaletteFade.active) { - overworld_free_bg_tilemaps(); + CleanupOverworldWindowsAndTilemaps(); Cb2_EnterPSS(task->data[2]); RemoveWindow(task->data[15]); DestroyTask(taskId); diff --git a/src/post_battle_event_funcs.c b/src/post_battle_event_funcs.c index fe5e1089e5..3cbf6ecd29 100644 --- a/src/post_battle_event_funcs.c +++ b/src/post_battle_event_funcs.c @@ -34,12 +34,12 @@ int GameClear(void) if (GetGameStat(GAME_STAT_FIRST_HOF_PLAY_TIME) == 0) SetGameStat(GAME_STAT_FIRST_HOF_PLAY_TIME, (gSaveBlock2Ptr->playTimeHours << 16) | (gSaveBlock2Ptr->playTimeMinutes << 8) | gSaveBlock2Ptr->playTimeSeconds); - SetSecretBase2Field_9(); + SetContinueGameWarpStatus(); if (gSaveBlock2Ptr->playerGender == MALE) - sub_8084F6C(HEAL_LOCATION_LITTLEROOT_TOWN_BRENDANS_HOUSE_2F); + SetContinueGameWarpToHealLocation(HEAL_LOCATION_LITTLEROOT_TOWN_BRENDANS_HOUSE_2F); else - sub_8084F6C(HEAL_LOCATION_LITTLEROOT_TOWN_MAYS_HOUSE_2F); + SetContinueGameWarpToHealLocation(HEAL_LOCATION_LITTLEROOT_TOWN_MAYS_HOUSE_2F); ribbonGet = FALSE; diff --git a/src/record_mixing.c b/src/record_mixing.c index 2b497c82b8..e3764c4906 100644 --- a/src/record_mixing.c +++ b/src/record_mixing.c @@ -1481,14 +1481,14 @@ static void sub_80E7FF8(u8 taskId) task->data[0] = 6; break; case 2: - sub_8076D5C(); + SetContinueGameWarpStatusToDynamicWarp(); sub_8153430(); task->data[0] ++; break; case 3: if (sub_8153474()) { - sav2_gender2_inplace_and_xFE(); + ClearContinueGameWarpStatus2(); task->data[0] = 4; task->data[1] = 0; } diff --git a/src/region_map.c b/src/region_map.c index 4752d96f05..ff0c191673 100644 --- a/src/region_map.c +++ b/src/region_map.c @@ -25,6 +25,7 @@ #include "constants/region_map_sections.h" #include "heal_location.h" #include "constants/heal_locations.h" +#include "constants/map_types.h" #define MAP_WIDTH 28 #define MAP_HEIGHT 15 @@ -864,7 +865,7 @@ static void RegionMap_InitializeStateBasedOnPlayerLocation(void) u16 y; u16 dimensionScale; u16 xOnMap; - struct WarpData *storedWarp; + struct WarpData *warp; if (gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(SS_TIDAL_CORRIDOR) && (gSaveBlock1Ptr->location.mapNum == MAP_NUM(SS_TIDAL_CORRIDOR) @@ -878,11 +879,11 @@ static void RegionMap_InitializeStateBasedOnPlayerLocation(void) switch (GetMapTypeByGroupAndId(gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum)) { default: - case 1: - case 2: - case 3: - case 5: - case 6: + case MAP_TYPE_TOWN: + case MAP_TYPE_CITY: + case MAP_TYPE_ROUTE: + case MAP_TYPE_UNDERWATER: + case MAP_TYPE_6: gRegionMap->mapSecId = gMapHeader.regionMapSectionId; gRegionMap->playerIsInCave = FALSE; mapWidth = gMapHeader.mapLayout->width; @@ -894,17 +895,17 @@ static void RegionMap_InitializeStateBasedOnPlayerLocation(void) gRegionMap->playerIsInCave = TRUE; } break; - case 4: - case 7: + case MAP_TYPE_UNDERGROUND: + case MAP_TYPE_7: if (gMapHeader.flags & 0x02) { - mapHeader = Overworld_GetMapHeaderByGroupAndId(gSaveBlock1Ptr->warp4.mapGroup, gSaveBlock1Ptr->warp4.mapNum); + mapHeader = Overworld_GetMapHeaderByGroupAndId(gSaveBlock1Ptr->escapeWarp.mapGroup, gSaveBlock1Ptr->escapeWarp.mapNum); gRegionMap->mapSecId = mapHeader->regionMapSectionId; gRegionMap->playerIsInCave = TRUE; mapWidth = mapHeader->mapLayout->width; mapHeight = mapHeader->mapLayout->height; - x = gSaveBlock1Ptr->warp4.x; - y = gSaveBlock1Ptr->warp4.y; + x = gSaveBlock1Ptr->escapeWarp.x; + y = gSaveBlock1Ptr->escapeWarp.y; } else { @@ -916,27 +917,26 @@ static void RegionMap_InitializeStateBasedOnPlayerLocation(void) y = 1; } break; - case 9: - mapHeader = Overworld_GetMapHeaderByGroupAndId((u16)gSaveBlock1Ptr->warp2.mapGroup, (u16)gSaveBlock1Ptr->warp2.mapNum); + case MAP_TYPE_SECRET_BASE: + mapHeader = Overworld_GetMapHeaderByGroupAndId((u16)gSaveBlock1Ptr->dynamicWarp.mapGroup, (u16)gSaveBlock1Ptr->dynamicWarp.mapNum); gRegionMap->mapSecId = mapHeader->regionMapSectionId; gRegionMap->playerIsInCave = TRUE; mapWidth = mapHeader->mapLayout->width; mapHeight = mapHeader->mapLayout->height; - x = gSaveBlock1Ptr->warp2.x; - y = gSaveBlock1Ptr->warp2.y; + x = gSaveBlock1Ptr->dynamicWarp.x; + y = gSaveBlock1Ptr->dynamicWarp.y; break; - case 8: - + case MAP_TYPE_INDOOR: gRegionMap->mapSecId = gMapHeader.regionMapSectionId; if (gRegionMap->mapSecId != MAPSEC_DYNAMIC) { - storedWarp = &gSaveBlock1Ptr->warp4; - mapHeader = Overworld_GetMapHeaderByGroupAndId(storedWarp->mapGroup, storedWarp->mapNum); + warp = &gSaveBlock1Ptr->escapeWarp; + mapHeader = Overworld_GetMapHeaderByGroupAndId(warp->mapGroup, warp->mapNum); } else { - storedWarp = &gSaveBlock1Ptr->warp2; - mapHeader = Overworld_GetMapHeaderByGroupAndId(storedWarp->mapGroup, storedWarp->mapNum); + warp = &gSaveBlock1Ptr->dynamicWarp; + mapHeader = Overworld_GetMapHeaderByGroupAndId(warp->mapGroup, warp->mapNum); gRegionMap->mapSecId = mapHeader->regionMapSectionId; } if (RegionMap_IsPlayerInCave(gRegionMap->mapSecId)) @@ -949,8 +949,8 @@ static void RegionMap_InitializeStateBasedOnPlayerLocation(void) } mapWidth = mapHeader->mapLayout->width; mapHeight = mapHeader->mapLayout->height; - x = storedWarp->x; - y = storedWarp->y; + x = warp->x; + y = warp->y; break; } @@ -1902,25 +1902,25 @@ static void sub_8124E0C(void) switch (sFlyMap->regionMap.mapSecId) { case MAPSEC_SOUTHERN_ISLAND: - sub_8084CCC(HEAL_LOCATION_SOUTHERN_ISLAND_EXTERIOR); + SetWarpDestinationToHealLocation(HEAL_LOCATION_SOUTHERN_ISLAND_EXTERIOR); break; case MAPSEC_BATTLE_FRONTIER: - sub_8084CCC(HEAL_LOCATION_BATTLE_FRONTIER_OUTSIDE_EAST); + SetWarpDestinationToHealLocation(HEAL_LOCATION_BATTLE_FRONTIER_OUTSIDE_EAST); break; case MAPSEC_LITTLEROOT_TOWN: - sub_8084CCC(gSaveBlock2Ptr->playerGender == MALE ? HEAL_LOCATION_LITTLEROOT_TOWN_1 : HEAL_LOCATION_LITTLEROOT_TOWN_2); + SetWarpDestinationToHealLocation(gSaveBlock2Ptr->playerGender == MALE ? HEAL_LOCATION_LITTLEROOT_TOWN_1 : HEAL_LOCATION_LITTLEROOT_TOWN_2); break; case MAPSEC_EVER_GRANDE_CITY: - sub_8084CCC(FlagGet(FLAG_LANDMARK_POKEMON_LEAGUE) && sFlyMap->regionMap.posWithinMapSec == 0 ? HEAL_LOCATION_EVER_GRANDE_CITY_2 : HEAL_LOCATION_EVER_GRANDE_CITY_1); + SetWarpDestinationToHealLocation(FlagGet(FLAG_LANDMARK_POKEMON_LEAGUE) && sFlyMap->regionMap.posWithinMapSec == 0 ? HEAL_LOCATION_EVER_GRANDE_CITY_2 : HEAL_LOCATION_EVER_GRANDE_CITY_1); break; default: if (sMapHealLocations[sFlyMap->regionMap.mapSecId][2] != 0) { - sub_8084CCC(sMapHealLocations[sFlyMap->regionMap.mapSecId][2]); + SetWarpDestinationToHealLocation(sMapHealLocations[sFlyMap->regionMap.mapSecId][2]); } else { - warp1_set_2(sMapHealLocations[sFlyMap->regionMap.mapSecId][0], sMapHealLocations[sFlyMap->regionMap.mapSecId][1], -1); + SetWarpDestinationToMapWarp(sMapHealLocations[sFlyMap->regionMap.mapSecId][0], sMapHealLocations[sFlyMap->regionMap.mapSecId][1], -1); } break; } diff --git a/src/rom_8011DC0.c b/src/rom_8011DC0.c index 066f7695c7..d3c6ec6d1d 100644 --- a/src/rom_8011DC0.c +++ b/src/rom_8011DC0.c @@ -1315,7 +1315,7 @@ u32 sub_8013B8C(struct UnkStruct_Group *arg0, s32 id) if (gUnknown_02022C2C == 4 && structPtr->unk.field_0.unk_00.unk_01_2 != 3) { - if (!(gSaveBlock2Ptr->specialSaveWarp & 0x80)) + if (!(gSaveBlock2Ptr->specialSaveWarpFlags & 0x80)) return 1; else if (structPtr->unk.field_0.unk_00.unk_00_7) return 0; @@ -1633,8 +1633,8 @@ void sub_8014210(u16 battleFlags) void sub_8014290(u16 arg0, u16 x, u16 y) { VarSet(VAR_0x4087, arg0); - Overworld_SetWarpDestination(gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1, x, y); - saved_warp2_set_2(0, gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1, x, y); + SetWarpDestination(gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1, x, y); + SetDynamicWarpWithCoords(0, gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1, x, y); WarpIntoMap(); } @@ -1645,7 +1645,7 @@ void sub_8014304(s8 mapGroup, s8 mapNum, s32 x, s32 y, u16 arg4) gFieldLinkPlayerCount = GetLinkPlayerCount(); gUnknown_03005DB4 = GetMultiplayerId(); SetCableClubWarp(); - Overworld_SetWarpDestination(mapGroup, mapNum, -1, x, y); + SetWarpDestination(mapGroup, mapNum, -1, x, y); WarpIntoMap(); } @@ -1697,12 +1697,12 @@ void sub_801440C(u8 taskId) { case 65: case 81: - overworld_free_bg_tilemaps(); + CleanupOverworldWindowsAndTilemaps(); gMain.savedCallback = sub_801AC54; sub_81B8518(3); break; case 1: - overworld_free_bg_tilemaps(); + CleanupOverworldWindowsAndTilemaps(); sub_80143E4(gBlockSendBuffer, TRUE); HealPlayerParty(); SavePlayerParty(); @@ -1711,7 +1711,7 @@ void sub_801440C(u8 taskId) SetMainCallback2(sub_8014384); break; case 2: - overworld_free_bg_tilemaps(); + CleanupOverworldWindowsAndTilemaps(); HealPlayerParty(); SavePlayerParty(); LoadPlayerBag(); @@ -1720,7 +1720,7 @@ void sub_801440C(u8 taskId) SetMainCallback2(sub_8014384); break; case 3: - overworld_free_bg_tilemaps(); + CleanupOverworldWindowsAndTilemaps(); HealPlayerParty(); SavePlayerParty(); LoadPlayerBag(); @@ -1730,18 +1730,18 @@ void sub_801440C(u8 taskId) break; case 4: sub_80143E4(gBlockSendBuffer, TRUE); - overworld_free_bg_tilemaps(); + CleanupOverworldWindowsAndTilemaps(); sub_8014304(MAP_GROUP(TRADE_CENTER), MAP_NUM(TRADE_CENTER), 5, 8, 3); SetMainCallback2(sub_8014384); break; case 15: sub_80143E4(gBlockSendBuffer, TRUE); - overworld_free_bg_tilemaps(); + CleanupOverworldWindowsAndTilemaps(); sub_8014304(MAP_GROUP(RECORD_CORNER), MAP_NUM(RECORD_CORNER), 8, 9, 4); SetMainCallback2(sub_8014384); break; case 68: - overworld_free_bg_tilemaps(); + CleanupOverworldWindowsAndTilemaps(); CreateTask(sub_8013F90, 0); break; case 5: diff --git a/src/save.c b/src/save.c index 905f075fb2..b234c230d3 100644 --- a/src/save.c +++ b/src/save.c @@ -923,7 +923,7 @@ void sub_8153688(u8 taskId) break; case 3: if (taskData[2] == 0) - sub_8076D5C(); + SetContinueGameWarpStatusToDynamicWarp(); sub_8153380(); taskData[0] = 4; break; @@ -946,7 +946,7 @@ void sub_8153688(u8 taskId) break; case 7: if (taskData[2] == 0) - sav2_gender2_inplace_and_xFE(); + ClearContinueGameWarpStatus2(); sub_800ADF8(); taskData[0] = 8; break; diff --git a/src/save_location.c b/src/save_location.c index d49afa7369..2443b3161b 100644 --- a/src/save_location.c +++ b/src/save_location.c @@ -2,11 +2,6 @@ #include "save_location.h" #include "constants/maps.h" -// specialSaveWarp flags -#define POKECENTER_SAVEWARP (1 << 1) -#define LOBBY_SAVEWARP (1 << 2) -#define UNK_SPECIAL_SAVE_WARP_FLAG_3 (1 << 3) - static bool32 IsCurMapInLocationList(const u16 *list) { s32 i; @@ -94,26 +89,26 @@ static bool32 sub_81AFCEC(void) static void TrySetPokeCenterWarpStatus(void) { if (IsCurMapPokeCenter() == FALSE) - gSaveBlock2Ptr->specialSaveWarp &= ~(POKECENTER_SAVEWARP); + gSaveBlock2Ptr->specialSaveWarpFlags &= ~(POKECENTER_SAVEWARP); else - gSaveBlock2Ptr->specialSaveWarp |= POKECENTER_SAVEWARP; + gSaveBlock2Ptr->specialSaveWarpFlags |= POKECENTER_SAVEWARP; } static void TrySetReloadWarpStatus(void) { if (!IsCurMapReloadLocation()) - gSaveBlock2Ptr->specialSaveWarp &= ~(LOBBY_SAVEWARP); + gSaveBlock2Ptr->specialSaveWarpFlags &= ~(LOBBY_SAVEWARP); else - gSaveBlock2Ptr->specialSaveWarp |= LOBBY_SAVEWARP; + gSaveBlock2Ptr->specialSaveWarpFlags |= LOBBY_SAVEWARP; } // this function definitely sets a warp status, but because the list is empty, it's unknown what this does yet. static void sub_81AFD5C(void) { if (!sub_81AFCEC()) - gSaveBlock2Ptr->specialSaveWarp &= ~(UNK_SPECIAL_SAVE_WARP_FLAG_3); + gSaveBlock2Ptr->specialSaveWarpFlags &= ~(UNK_SPECIAL_SAVE_WARP_FLAG_3); else - gSaveBlock2Ptr->specialSaveWarp |= UNK_SPECIAL_SAVE_WARP_FLAG_3; + gSaveBlock2Ptr->specialSaveWarpFlags |= UNK_SPECIAL_SAVE_WARP_FLAG_3; } void TrySetMapSaveWarpStatus(void) @@ -136,5 +131,5 @@ void sub_81AFDA0(void) void sub_81AFDD0(void) { - gSaveBlock2Ptr->specialSaveWarp |= 0x80; + gSaveBlock2Ptr->specialSaveWarpFlags |= 0x80; } diff --git a/src/scrcmd.c b/src/scrcmd.c index ab3af019d8..39df1117d8 100644 --- a/src/scrcmd.c +++ b/src/scrcmd.c @@ -735,7 +735,7 @@ bool8 ScrCmd_setmaplayoutindex(struct ScriptContext *ctx) { u16 value = VarGet(ScriptReadHalfword(ctx)); - sub_8085524(value); + SetCurrentMapLayout(value); return FALSE; } @@ -747,7 +747,7 @@ bool8 ScrCmd_warp(struct ScriptContext *ctx) u16 x = VarGet(ScriptReadHalfword(ctx)); u16 y = VarGet(ScriptReadHalfword(ctx)); - Overworld_SetWarpDestination(mapGroup, mapNum, warpId, x, y); + SetWarpDestination(mapGroup, mapNum, warpId, x, y); sub_80AF734(); ResetInitialPlayerAvatarState(); return TRUE; @@ -761,7 +761,7 @@ bool8 ScrCmd_warpsilent(struct ScriptContext *ctx) u16 x = VarGet(ScriptReadHalfword(ctx)); u16 y = VarGet(ScriptReadHalfword(ctx)); - Overworld_SetWarpDestination(mapGroup, mapNum, warpId, x, y); + SetWarpDestination(mapGroup, mapNum, warpId, x, y); sp13E_warp_to_last_warp(); ResetInitialPlayerAvatarState(); return TRUE; @@ -775,7 +775,7 @@ bool8 ScrCmd_warpdoor(struct ScriptContext *ctx) u16 x = VarGet(ScriptReadHalfword(ctx)); u16 y = VarGet(ScriptReadHalfword(ctx)); - Overworld_SetWarpDestination(mapGroup, mapNum, warpId, x, y); + SetWarpDestination(mapGroup, mapNum, warpId, x, y); sub_80AF7D0(); ResetInitialPlayerAvatarState(); return TRUE; @@ -790,9 +790,9 @@ bool8 ScrCmd_warphole(struct ScriptContext *ctx) PlayerGetDestCoords(&x, &y); if (mapGroup == 0xFF && mapNum == 0xFF) - SetFixedHoleWarpAsDestination(x - 7, y - 7); + SetWarpDestinationToFixedHoleWarp(x - 7, y - 7); else - Overworld_SetWarpDestination(mapGroup, mapNum, -1, x - 7, y - 7); + SetWarpDestination(mapGroup, mapNum, -1, x - 7, y - 7); sp13F_fall_to_last_warp(); ResetInitialPlayerAvatarState(); return TRUE; @@ -806,7 +806,7 @@ bool8 ScrCmd_warpteleport(struct ScriptContext *ctx) u16 x = VarGet(ScriptReadHalfword(ctx)); u16 y = VarGet(ScriptReadHalfword(ctx)); - Overworld_SetWarpDestination(mapGroup, mapNum, warpId, x, y); + SetWarpDestination(mapGroup, mapNum, warpId, x, y); sub_80AF848(); ResetInitialPlayerAvatarState(); return TRUE; @@ -820,7 +820,7 @@ bool8 ScrCmd_warpD7(struct ScriptContext *ctx) u16 x = VarGet(ScriptReadHalfword(ctx)); u16 y = VarGet(ScriptReadHalfword(ctx)); - Overworld_SetWarpDestination(mapGroup, mapNum, warpId, x, y); + SetWarpDestination(mapGroup, mapNum, warpId, x, y); sub_80AF87C(); ResetInitialPlayerAvatarState(); return TRUE; @@ -834,7 +834,7 @@ bool8 ScrCmd_setwarp(struct ScriptContext *ctx) u16 x = VarGet(ScriptReadHalfword(ctx)); u16 y = VarGet(ScriptReadHalfword(ctx)); - Overworld_SetWarpDestination(mapGroup, mapNum, warpId, x, y); + SetWarpDestination(mapGroup, mapNum, warpId, x, y); return FALSE; } @@ -846,7 +846,7 @@ bool8 ScrCmd_setdynamicwarp(struct ScriptContext *ctx) u16 x = VarGet(ScriptReadHalfword(ctx)); u16 y = VarGet(ScriptReadHalfword(ctx)); - saved_warp2_set_2(0, mapGroup, mapNum, warpId, x, y); + SetDynamicWarpWithCoords(0, mapGroup, mapNum, warpId, x, y); return FALSE; } @@ -882,7 +882,7 @@ bool8 ScrCmd_setescapewarp(struct ScriptContext *ctx) u16 x = VarGet(ScriptReadHalfword(ctx)); u16 y = VarGet(ScriptReadHalfword(ctx)); - sub_8084DD4(mapGroup, mapNum, warpId, x, y); + SetEscapeWarp(mapGroup, mapNum, warpId, x, y); return FALSE; } @@ -1998,7 +1998,7 @@ bool8 ScrCmd_setrespawn(struct ScriptContext *ctx) { u16 healLocationId = VarGet(ScriptReadHalfword(ctx)); - Overworld_SetHealLocationWarp(healLocationId); + SetLastHealLocationWarp(healLocationId); return FALSE; } @@ -2235,7 +2235,7 @@ bool8 ScrCmd_warpD1(struct ScriptContext *ctx) u16 x = VarGet(ScriptReadHalfword(ctx)); u16 y = VarGet(ScriptReadHalfword(ctx)); - Overworld_SetWarpDestination(mapGroup, mapNum, warpId, x, y); + SetWarpDestination(mapGroup, mapNum, warpId, x, y); sub_808D074(GetPlayerFacingDirection()); sub_80B0244(); ResetInitialPlayerAvatarState(); @@ -2289,7 +2289,7 @@ bool8 ScrCmd_warpE0(struct ScriptContext *ctx) u16 x = VarGet(ScriptReadHalfword(ctx)); u16 y = VarGet(ScriptReadHalfword(ctx)); - Overworld_SetWarpDestination(mapGroup, mapNum, warpId, x, y); + SetWarpDestination(mapGroup, mapNum, warpId, x, y); sub_80AF79C(); ResetInitialPlayerAvatarState(); return TRUE; diff --git a/src/secret_base.c b/src/secret_base.c index 7e7b10a9a8..15d6d17803 100644 --- a/src/secret_base.c +++ b/src/secret_base.c @@ -366,7 +366,7 @@ void sub_80E8F9C(void) s8 idx; idx = sCurSecretBaseId / 10 * 4; - warp1_set_2(MAP_GROUP(SECRET_BASE_RED_CAVE1), gUnknown_0858CFE8[idx], gUnknown_0858CFE8[idx + 1]); + SetWarpDestinationToMapWarp(MAP_GROUP(SECRET_BASE_RED_CAVE1), gUnknown_0858CFE8[idx], gUnknown_0858CFE8[idx + 1]); } void sub_80E8FD0(u8 taskId) @@ -400,7 +400,7 @@ void sub_80E9068(void) { CreateTask(sub_80E8FD0, 0); FadeScreen(1, 0); - saved_warp2_set(0, gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1); + SetDynamicWarp(0, gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1); } bool8 sub_80E909C(void) @@ -445,7 +445,7 @@ void sub_80E916C(u8 taskId) if (!gPaletteFade.active) { idx = sCurSecretBaseId / 10 * 4; - Overworld_SetWarpDestination(gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1, gUnknown_0858CFE8[idx + 2], gUnknown_0858CFE8[idx + 3]); + SetWarpDestination(gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1, gUnknown_0858CFE8[idx + 2], gUnknown_0858CFE8[idx + 3]); WarpIntoMap(); gFieldCallback = sub_80E9108; SetMainCallback2(CB2_LoadMap); @@ -643,7 +643,7 @@ void sub_80E96A4(u8 taskId) } break; case 2: - copy_saved_warp2_bank_and_enter_x_to_warp1(0x7e); + SetWarpDestinationToDynamicWarp(0x7e); WarpIntoMap(); gFieldCallback = mapldr_default; SetMainCallback2(CB2_LoadMap); diff --git a/src/start_menu.c b/src/start_menu.c index ad7b4b6ccc..0f608b1d20 100644 --- a/src/start_menu.c +++ b/src/start_menu.c @@ -623,7 +623,7 @@ static bool8 StartMenuPokedexCallback(void) IncrementGameStat(GAME_STAT_CHECKED_POKEDEX); PlayRainSoundEffect(); RemoveExtraStartMenuWindows(); - overworld_free_bg_tilemaps(); + CleanupOverworldWindowsAndTilemaps(); SetMainCallback2(CB2_Pokedex); return TRUE; @@ -638,7 +638,7 @@ static bool8 StartMenuPokemonCallback(void) { PlayRainSoundEffect(); RemoveExtraStartMenuWindows(); - overworld_free_bg_tilemaps(); + CleanupOverworldWindowsAndTilemaps(); SetMainCallback2(CB2_PartyMenuFromStartMenu); // Display party menu return TRUE; @@ -653,7 +653,7 @@ static bool8 StartMenuBagCallback(void) { PlayRainSoundEffect(); RemoveExtraStartMenuWindows(); - overworld_free_bg_tilemaps(); + CleanupOverworldWindowsAndTilemaps(); SetMainCallback2(CB2_BagMenuFromStartMenu); // Display bag menu return TRUE; @@ -668,7 +668,7 @@ static bool8 StartMenuPokeNavCallback(void) { PlayRainSoundEffect(); RemoveExtraStartMenuWindows(); - overworld_free_bg_tilemaps(); + CleanupOverworldWindowsAndTilemaps(); SetMainCallback2(CB2_PokeNav); // Display PokeNav return TRUE; @@ -683,7 +683,7 @@ static bool8 StartMenuPlayerNameCallback(void) { PlayRainSoundEffect(); RemoveExtraStartMenuWindows(); - overworld_free_bg_tilemaps(); + CleanupOverworldWindowsAndTilemaps(); if (is_c1_link_related_active() || InUnionRoom()) { @@ -722,7 +722,7 @@ static bool8 StartMenuOptionCallback(void) { PlayRainSoundEffect(); RemoveExtraStartMenuWindows(); - overworld_free_bg_tilemaps(); + CleanupOverworldWindowsAndTilemaps(); SetMainCallback2(CB2_InitOptionMenu); // Display option menu gMain.savedCallback = CB2_ReturnToFieldWithOpenMenu; @@ -754,7 +754,7 @@ static bool8 StartMenuLinkModePlayerNameCallback(void) if (!gPaletteFade.active) { PlayRainSoundEffect(); - overworld_free_bg_tilemaps(); + CleanupOverworldWindowsAndTilemaps(); TrainerCard_ShowLinkCard(gUnknown_03005DB4, CB2_ReturnToFieldWithOpenMenu); return TRUE; @@ -784,7 +784,7 @@ static bool8 StartMenuBattlePyramidBagCallback(void) { PlayRainSoundEffect(); RemoveExtraStartMenuWindows(); - overworld_free_bg_tilemaps(); + CleanupOverworldWindowsAndTilemaps(); SetMainCallback2(CB2_PyramidBagMenuFromStartMenu); return TRUE; @@ -1285,14 +1285,14 @@ static void sub_80A0550(u8 taskId) } break; case 1: - sub_8076D5C(); + SetContinueGameWarpStatusToDynamicWarp(); sub_8153430(); *step = 2; break; case 2: if (sub_8153474()) { - sav2_gender2_inplace_and_xFE(); + ClearContinueGameWarpStatus2(); *step = 3; gSoftResetDisabled = 0; }