summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSlawter666 <38655737+Slawter666@users.noreply.github.com>2018-09-04 23:31:37 +0100
committerSlawter666 <38655737+Slawter666@users.noreply.github.com>2018-09-04 23:31:37 +0100
commit4c54212b1f559a110fc7f6fffebe3a54748f3fec (patch)
tree9a15ec95345fdc22fd5d48580f0492695b8c036f /src
parent5c66b8a7eff886b72bb98e22b5b34421d1a601d2 (diff)
Bring labels for overworld.c over from pokeruby
Diffstat (limited to 'src')
-rw-r--r--src/decoration.c2
-rw-r--r--src/event_object_movement.c38
-rw-r--r--src/field_effect.c24
-rw-r--r--src/field_specials.c4
-rw-r--r--src/fieldmap.c4
-rwxr-xr-xsrc/item_use.c2
-rw-r--r--src/new_game.c2
-rw-r--r--src/overworld.c267
-rw-r--r--src/rom_8011DC0.c4
-rw-r--r--src/safari_zone.c4
-rw-r--r--src/scrcmd.c22
-rw-r--r--src/secret_base.c6
12 files changed, 189 insertions, 190 deletions
diff --git a/src/decoration.c b/src/decoration.c
index 4f9ad298d..e1def6d38 100644
--- a/src/decoration.c
+++ b/src/decoration.c
@@ -1132,7 +1132,7 @@ void sub_8127B04(u8 taskId)
{
DrawWholeMapView();
Overworld_SetWarpDestination(gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1, gTasks[taskId].data[3], gTasks[taskId].data[4]);
- warp_in();
+ WarpIntoMap();
}
u16 sub_8127B54(u8 decor, u8 a1)
diff --git a/src/event_object_movement.c b/src/event_object_movement.c
index b54936db4..9a1e711c3 100644
--- a/src/event_object_movement.c
+++ b/src/event_object_movement.c
@@ -798,7 +798,7 @@ bool8 (*const gDirectionBlockedMetatileFuncs[])(u8) = {
MetatileBehavior_IsWestBlocked
};
-const struct Coords16 gDirectionToVectors[] = {
+static const struct Coords16 sDirectionToVectors[] = {
{ 0, 0},
{ 0, 1},
{ 0, -1},
@@ -4957,14 +4957,14 @@ void sub_8092EF0(u8 localId, u8 mapNum, u8 mapGroup)
void MoveCoords(u8 direction, s16 *x, s16 *y)
{
- *x += gDirectionToVectors[direction].x;
- *y += gDirectionToVectors[direction].y;
+ *x += sDirectionToVectors[direction].x;
+ *y += sDirectionToVectors[direction].y;
}
void sub_8092F60(u8 direction, s16 *x, s16 *y)
{
- *x += gDirectionToVectors[direction].x << 4;
- *y += gDirectionToVectors[direction].y << 4;
+ *x += sDirectionToVectors[direction].x << 4;
+ *y += sDirectionToVectors[direction].y << 4;
}
static void MoveCoordsInDirection(u32 dir, s16 *x, s16 *y, s16 deltaX, s16 deltaY)
@@ -4972,13 +4972,13 @@ static void MoveCoordsInDirection(u32 dir, s16 *x, s16 *y, s16 deltaX, s16 delta
u8 direction = dir;
s16 dx2 = (u16)deltaX;
s16 dy2 = (u16)deltaY;
- if (gDirectionToVectors[direction].x > 0)
+ if (sDirectionToVectors[direction].x > 0)
*x += dx2;
- if (gDirectionToVectors[direction].x < 0)
+ if (sDirectionToVectors[direction].x < 0)
*x -= dx2;
- if (gDirectionToVectors[direction].y > 0)
+ if (sDirectionToVectors[direction].y > 0)
*y += dy2;
- if (gDirectionToVectors[direction].y < 0)
+ if (sDirectionToVectors[direction].y < 0)
*y -= dy2;
}
@@ -8389,32 +8389,32 @@ void UnfreezeEventObjects(void)
void Step1(struct Sprite *sprite, u8 dir)
{
- sprite->pos1.x += gDirectionToVectors[dir].x;
- sprite->pos1.y += gDirectionToVectors[dir].y;
+ sprite->pos1.x += sDirectionToVectors[dir].x;
+ sprite->pos1.y += sDirectionToVectors[dir].y;
}
void Step2(struct Sprite *sprite, u8 dir)
{
- sprite->pos1.x += 2 * (u16) gDirectionToVectors[dir].x;
- sprite->pos1.y += 2 * (u16) gDirectionToVectors[dir].y;
+ sprite->pos1.x += 2 * (u16) sDirectionToVectors[dir].x;
+ sprite->pos1.y += 2 * (u16) sDirectionToVectors[dir].y;
}
void Step3(struct Sprite *sprite, u8 dir)
{
- sprite->pos1.x += 2 * (u16) gDirectionToVectors[dir].x + (u16) gDirectionToVectors[dir].x;
- sprite->pos1.y += 2 * (u16) gDirectionToVectors[dir].y + (u16) gDirectionToVectors[dir].y;
+ sprite->pos1.x += 2 * (u16) sDirectionToVectors[dir].x + (u16) sDirectionToVectors[dir].x;
+ sprite->pos1.y += 2 * (u16) sDirectionToVectors[dir].y + (u16) sDirectionToVectors[dir].y;
}
void Step4(struct Sprite *sprite, u8 dir)
{
- sprite->pos1.x += 4 * (u16) gDirectionToVectors[dir].x;
- sprite->pos1.y += 4 * (u16) gDirectionToVectors[dir].y;
+ sprite->pos1.x += 4 * (u16) sDirectionToVectors[dir].x;
+ sprite->pos1.y += 4 * (u16) sDirectionToVectors[dir].y;
}
void Step8(struct Sprite *sprite, u8 dir)
{
- sprite->pos1.x += 8 * (u16) gDirectionToVectors[dir].x;
- sprite->pos1.y += 8 * (u16) gDirectionToVectors[dir].y;
+ sprite->pos1.x += 8 * (u16) sDirectionToVectors[dir].x;
+ sprite->pos1.y += 8 * (u16) sDirectionToVectors[dir].y;
}
void oamt_npc_ministep_reset(struct Sprite *sprite, u8 a2, u8 a3)
diff --git a/src/field_effect.c b/src/field_effect.c
index 13de58aa4..ecda8578b 100644
--- a/src/field_effect.c
+++ b/src/field_effect.c
@@ -1170,7 +1170,7 @@ void task00_8084310(u8 taskId)
if (!FieldEffectActiveListContains(FLDEFF_USE_FLY))
{
Overworld_ResetStateAfterFly();
- warp_in();
+ WarpIntoMap();
SetMainCallback2(CB2_LoadMap);
gFieldCallback = mapldr_08084390;
DestroyTask(taskId);
@@ -1355,7 +1355,7 @@ void sub_80B6FB8(struct Task *);
void sub_80B7004(struct Task *);
void sub_80B7050(void);
void sub_80B7060(void);
-bool8 sub_80859A0(void);
+bool8 BGMusicStopped(void);
void sub_80B70B4(void);
void sub_80E1570(void);
void sub_80B70DC(u8);
@@ -1476,10 +1476,10 @@ void sub_80B7050(void)
void sub_80B7060(void)
{
- if (!gPaletteFade.active && sub_80859A0() == TRUE)
+ if (!gPaletteFade.active && BGMusicStopped() == TRUE)
{
sub_80E1570();
- warp_in();
+ WarpIntoMap();
gFieldCallback = sub_80B70B4;
SetMainCallback2(CB2_LoadMap);
DestroyTask(FindTaskIdByFunc(sub_80B6E88));
@@ -1838,9 +1838,9 @@ bool8 sub_80B77F8(struct Task *task, struct EventObject *eventObject, struct Spr
bool8 sub_80B7814(struct Task *task, struct EventObject *eventObject, struct Sprite *sprite)
{
- if (!gPaletteFade.active && sub_80859A0() == TRUE)
+ if (!gPaletteFade.active && BGMusicStopped() == TRUE)
{
- warp_in();
+ WarpIntoMap();
gFieldCallback = mapldr_080851BC;
SetMainCallback2(CB2_LoadMap);
DestroyTask(FindTaskIdByFunc(sub_80B75F0));
@@ -2004,9 +2004,9 @@ void mapldr_080859D4(void);
bool8 sub_80B7BF4(struct Task *task, struct EventObject *eventObject, struct Sprite *sprite)
{
- if (!gPaletteFade.active && sub_80859A0() == TRUE)
+ if (!gPaletteFade.active && BGMusicStopped() == TRUE)
{
- warp_in();
+ WarpIntoMap();
gFieldCallback = sub_80B6B68;
SetMainCallback2(CB2_LoadMap);
DestroyTask(FindTaskIdByFunc(sub_80B7A8C));
@@ -2063,11 +2063,11 @@ void sub_80B7D34(struct Task *task)
eventObject = &gEventObjects[gPlayerAvatar.eventObjectId];
if (!EventObjectIsMovementOverridden(eventObject) || EventObjectClearHeldMovementIfFinished(eventObject))
{
- if (task->data[14] == 0 && !gPaletteFade.active && sub_80859A0() == TRUE)
+ if (task->data[14] == 0 && !gPaletteFade.active && BGMusicStopped() == TRUE)
{
SetEventObjectDirection(eventObject, task->data[15]);
sub_8084E14();
- warp_in();
+ WarpIntoMap();
gFieldCallback = mapldr_080859D4;
SetMainCallback2(CB2_LoadMap);
DestroyTask(FindTaskIdByFunc(sub_80B7CE4));
@@ -2234,10 +2234,10 @@ static void TeleportFieldEffectTask4(struct Task *task)
task->data[5] = TRUE;
}
- if (sub_80859A0() == TRUE)
+ if (BGMusicStopped() == TRUE)
{
Overworld_SetWarpDestToLastHealLoc();
- warp_in();
+ WarpIntoMap();
SetMainCallback2(CB2_LoadMap);
gFieldCallback = mapldr_08085D88;
DestroyTask(FindTaskIdByFunc(ExecuteTeleportFieldEffectTask));
diff --git a/src/field_specials.c b/src/field_specials.c
index 84852e6b5..14f99b426 100644
--- a/src/field_specials.c
+++ b/src/field_specials.c
@@ -269,7 +269,7 @@ u16 GetRecordedCyclingRoadResults(void) {
}
void UpdateCyclingRoadState(void) {
- if (gUnknown_020322DC.mapNum == MAP_NUM(ROUTE110_SEASIDE_CYCLING_ROAD_SOUTH_ENTRANCE) && gUnknown_020322DC.mapGroup == MAP_GROUP(ROUTE110_SEASIDE_CYCLING_ROAD_SOUTH_ENTRANCE))
+ if (gLastUsedWarp.mapNum == MAP_NUM(ROUTE110_SEASIDE_CYCLING_ROAD_SOUTH_ENTRANCE) && gLastUsedWarp.mapGroup == MAP_GROUP(ROUTE110_SEASIDE_CYCLING_ROAD_SOUTH_ENTRANCE))
{
return;
}
@@ -2094,7 +2094,7 @@ bool32 warp0_in_pokecenter(void)
static const u16 gUnknown_085B2C2A[] = { 0x0202, 0x0301, 0x0405, 0x0504, 0x0604, 0x0700, 0x0804, 0x090b, 0x0a05, 0x0b05, 0x0c02, 0x0d06, 0x0e03, 0x0f02, 0x100c, 0x100a, 0x1a35, 0x193c, 0xffff };
int i;
- u16 map = (gUnknown_020322DC.mapGroup << 8) + gUnknown_020322DC.mapNum;
+ u16 map = (gLastUsedWarp.mapGroup << 8) + gLastUsedWarp.mapNum;
for (i = 0; gUnknown_085B2C2A[i] != 0xFFFF; i++)
{
diff --git a/src/fieldmap.c b/src/fieldmap.c
index 8d1988686..019db9d0d 100644
--- a/src/fieldmap.c
+++ b/src/fieldmap.c
@@ -712,8 +712,8 @@ int GetPostCameraMoveMapBorderId(int x, int y)
int CanCameraMoveInDirection(int direction)
{
int x, y;
- x = gSaveBlock1Ptr->pos.x + 7 + gUnknown_08339D64[direction].x;
- y = gSaveBlock1Ptr->pos.y + 7 + gUnknown_08339D64[direction].y;
+ x = gSaveBlock1Ptr->pos.x + 7 + gDirectionToVectors[direction].x;
+ y = gSaveBlock1Ptr->pos.y + 7 + gDirectionToVectors[direction].y;
if (GetMapBorderIdAt(x, y) == -1)
{
return 0;
diff --git a/src/item_use.c b/src/item_use.c
index bf7c2a386..ea8206502 100755
--- a/src/item_use.c
+++ b/src/item_use.c
@@ -878,7 +878,7 @@ void ItemUseOutOfBattle_BlackWhiteFlute(u8 taskId)
void task08_080A1C44(u8 taskId)
{
- player_avatar_init_params_reset();
+ ResetInitialPlayerAvatarState();
sub_80B7CC8();
DestroyTask(taskId);
}
diff --git a/src/new_game.c b/src/new_game.c
index da5e91229..36c028ce8 100644
--- a/src/new_game.c
+++ b/src/new_game.c
@@ -133,7 +133,7 @@ static void ClearFrontierRecord(void)
static void WarpToTruck(void)
{
Overworld_SetWarpDestination(25, 40, -1, -1, -1); // inside of truck
- warp_in();
+ WarpIntoMap();
}
void Sav2_ClearSetDefault(void)
diff --git a/src/overworld.c b/src/overworld.c
index d4425effc..683679218 100644
--- a/src/overworld.c
+++ b/src/overworld.c
@@ -1,8 +1,8 @@
#include "global.h"
#include "overworld.h"
-#include "main.h"
#include "battle_setup.h"
#include "berry.h"
+#include "bg.h"
// #include "cable_club.h"
#include "clock.h"
#include "event_data.h"
@@ -20,15 +20,18 @@
#include "field_weather.h"
#include "fieldmap.h"
// #include "fldeff_flash.h"
+#include "gpu_regs.h"
#include "heal_location.h"
#include "link.h"
+#include "link_rfu.h"
#include "load_save.h"
#include "main.h"
+#include "malloc.h"
#include "m4a.h"
-#include "constants/maps.h"
#include "map_name_popup.h"
#include "menu.h"
#include "metatile_behavior.h"
+#include "money.h"
#include "new_game.h"
#include "palette.h"
#include "play_time.h"
@@ -37,12 +40,11 @@
// #include "rotating_gate.h"
#include "safari_zone.h"
#include "save.h"
+#include "save_location.h"
#include "script.h"
// #include "script_pokemon_80C4.h"
#include "secret_base.h"
-#include "constants/songs.h"
#include "sound.h"
-#include "constants/species.h"
#include "start_menu.h"
#include "task.h"
// #include "tileset_anim.h"
@@ -50,14 +52,11 @@
#include "tv.h"
#include "scanline_effect.h"
#include "wild_encounter.h"
-#include "bg.h"
-#include "money.h"
-#include "save_location.h"
#include "constants/abilities.h"
-#include "malloc.h"
-#include "gpu_regs.h"
-#include "link_rfu.h"
#include "constants/map_types.h"
+#include "constants/maps.h"
+#include "constants/songs.h"
+#include "constants/species.h"
// event scripts
extern const u8 EventScript_WhiteOut[];
@@ -184,7 +183,7 @@ static bool32 sub_8086638(u8 *state);
static bool32 load_map_stuff(u8 *state, u32);
static bool32 map_loading_iteration_2_link(u8 *state);
static void mli4_mapscripts_and_other(void);
-static void map_loading_lcd_reset(void);
+static void InitOverworldGraphicsRegisters(void);
static u8 sub_8087858(u8);
static u16 sub_80871C0(u32 a1);
static void sub_80867C8(void);
@@ -245,9 +244,9 @@ static void c1_link_related_func_set(u16 (*func)(u32));
static void SetFieldVBlankCallback(void);
static void FieldClearVBlankHBlankCallbacks(void);
static void sub_8085810(void);
-static u8 sub_808532C(struct UnkPlayerStruct *playerStruct, u16 a2, u8 a3);
-static u8 sub_808538C(struct UnkPlayerStruct *playerStruct, u8 a2, u16 a3, u8 a4);
-static u16 cur_mapdata_block_role_at_screen_center_acc_to_sav1(void);
+static u8 GetAdjustedInitialTransitionFlags(struct InitialPlayerAvatarState *playerStruct, u16 a2, u8 a3);
+static u8 GetAdjustedInitialDirection(struct InitialPlayerAvatarState *playerStruct, u8 a2, u16 a3, u8 a4);
+static u16 GetCenterScreenMetatileBehavior(void);
// IWRAM bss vars
IWRAM_DATA static void *sUnknown_03000E0C;
@@ -259,12 +258,12 @@ IWRAM_DATA static u32 sUnusedVar;
// EWRAM vars
EWRAM_DATA static u8 sUnknown_020322D8 = 0;
-EWRAM_DATA struct WarpData gUnknown_020322DC = {0};
+EWRAM_DATA struct WarpData gLastUsedWarp = {0};
EWRAM_DATA static struct WarpData sWarpDestination = {0}; // new warp position
-EWRAM_DATA static struct WarpData sUnknown_020322EC = {0};
-EWRAM_DATA static struct WarpData sUnknown_020322F4 = {0};
+EWRAM_DATA static struct WarpData gFixedDiveWarp = {0};
+EWRAM_DATA static struct WarpData gFixedHoleWarp = {0};
EWRAM_DATA static u16 sLastMapSectionId = 0;
-EWRAM_DATA static struct UnkPlayerStruct sUnknown_02032300 = {0};
+EWRAM_DATA static struct InitialPlayerAvatarState gInitialPlayerAvatarState = {0};
EWRAM_DATA static u16 sAmbientCrySpecies = 0;
EWRAM_DATA static bool8 sIsAmbientCryWaterMon = FALSE;
EWRAM_DATA struct LinkPlayerEventObject gLinkPlayerEventObjects[4] = {0};
@@ -291,17 +290,17 @@ static const u8 sUnusedData[] =
0x2C, 0x00, 0x00, 0x00,
};
-const struct UCoords32 gUnknown_08339D64[] =
-{
- { 0, 0},
- { 0, 1},
- { 0, -1},
- {-1, 0},
- { 1, 0},
- {-1, 1},
- { 1, 1},
- {-1, -1},
- { 1, -1},
+const struct UCoords32 gDirectionToVectors[] =
+{
+ { 0, 0}, // DIR_NONE
+ { 0, 1}, // DIR_SOUTH
+ { 0, -1}, // DIR_NORTH
+ {-1, 0}, // DIR_WEST
+ { 1, 0}, // DIR_EAST
+ {-1, 1}, // DIR_SOUTHWEST
+ { 1, 1}, // DIR_SOUTHEAST
+ {-1, -1}, // DIR_NORTHWEST
+ { 1, -1}, // DIR_NORTHEAST
};
static const struct BgTemplate gUnknown_08339DAC[] =
@@ -344,7 +343,7 @@ static const struct BgTemplate gUnknown_08339DAC[] =
}
};
-static const struct ScanlineEffectParams gUnknown_08339DBC =
+static const struct ScanlineEffectParams sFlashEffectParams =
{
(void *)REG_ADDR_WIN0H,
((DMA_ENABLE | DMA_START_HBLANK | DMA_REPEAT | DMA_DEST_RELOAD) << 16) | 1,
@@ -399,12 +398,12 @@ void DoWhiteOut(void)
HealPlayerParty();
Overworld_ResetStateAfterWhiteOut();
Overworld_SetWarpDestToLastHealLoc();
- warp_in();
+ WarpIntoMap();
}
void Overworld_ResetStateAfterFly(void)
{
- player_avatar_init_params_reset();
+ ResetInitialPlayerAvatarState();
FlagClear(FLAG_SYS_CYCLING_ROAD);
FlagClear(FLAG_SYS_CRUISE_MODE);
FlagClear(FLAG_SYS_SAFARI_MODE);
@@ -414,7 +413,7 @@ void Overworld_ResetStateAfterFly(void)
void Overworld_ResetStateAfterTeleport(void)
{
- player_avatar_init_params_reset();
+ ResetInitialPlayerAvatarState();
FlagClear(FLAG_SYS_CYCLING_ROAD);
FlagClear(FLAG_SYS_CRUISE_MODE);
FlagClear(FLAG_SYS_SAFARI_MODE);
@@ -425,7 +424,7 @@ void Overworld_ResetStateAfterTeleport(void)
void Overworld_ResetStateAfterDigEscRope(void)
{
- player_avatar_init_params_reset();
+ ResetInitialPlayerAvatarState();
FlagClear(FLAG_SYS_CYCLING_ROAD);
FlagClear(FLAG_SYS_CRUISE_MODE);
FlagClear(FLAG_SYS_SAFARI_MODE);
@@ -435,7 +434,7 @@ void Overworld_ResetStateAfterDigEscRope(void)
static void Overworld_ResetStateAfterWhiteOut(void)
{
- player_avatar_init_params_reset();
+ ResetInitialPlayerAvatarState();
FlagClear(FLAG_SYS_CYCLING_ROAD);
FlagClear(FLAG_SYS_CRUISE_MODE);
FlagClear(FLAG_SYS_SAFARI_MODE);
@@ -574,16 +573,16 @@ const struct MapLayout *GetMapLayout(void)
void ApplyCurrentWarp(void)
{
- gUnknown_020322DC = gSaveBlock1Ptr->location;
+ gLastUsedWarp = gSaveBlock1Ptr->location;
gSaveBlock1Ptr->location = sWarpDestination;
- sUnknown_020322EC = sDummyWarpData;
- sUnknown_020322F4 = sDummyWarpData;
+ gFixedDiveWarp = sDummyWarpData;
+ gFixedHoleWarp = sDummyWarpData;
}
void set_warp2_warp3_to_neg_1(void)
{
- sUnknown_020322EC = sDummyWarpData;
- sUnknown_020322F4 = sDummyWarpData;
+ gFixedDiveWarp = sDummyWarpData;
+ gFixedHoleWarp = sDummyWarpData;
}
void SetWarpData(struct WarpData *warp, s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y)
@@ -595,7 +594,7 @@ void SetWarpData(struct WarpData *warp, s8 mapGroup, s8 mapNum, s8 warpId, s8 x,
warp->y = y;
}
-bool32 warp_data_is_not_neg_1(struct WarpData *warp)
+bool32 IsDummyWarp(struct WarpData *warp)
{
if (warp->mapGroup != -1)
return FALSE;
@@ -616,12 +615,12 @@ struct MapHeader const *const Overworld_GetMapHeaderByGroupAndId(u16 mapGroup, u
return gMapGroups[mapGroup][mapNum];
}
-struct MapHeader const *const warp1_get_mapheader(void)
+struct MapHeader const *const GetDestinationWarpMapHeader(void)
{
return Overworld_GetMapHeaderByGroupAndId(sWarpDestination.mapGroup, sWarpDestination.mapNum);
}
-void set_current_map_header_from_sav1_save_old_name(void)
+void LoadCurrentMapData(void)
{
sLastMapSectionId = gMapHeader.regionMapSectionId;
gMapHeader = *Overworld_GetMapHeaderByGroupAndId(gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum);
@@ -635,7 +634,7 @@ void LoadSaveblockMapHeader(void)
gMapHeader.mapLayout = GetMapLayout();
}
-void update_camera_pos_from_warpid(void)
+void SetPlayerCoordsFromWarp(void)
{
if (gSaveBlock1Ptr->location.warpId >= 0 && gSaveBlock1Ptr->location.warpId < gMapHeader.events->warpCount)
{
@@ -654,11 +653,11 @@ void update_camera_pos_from_warpid(void)
}
}
-void warp_in(void)
+void WarpIntoMap(void)
{
ApplyCurrentWarp();
- set_current_map_header_from_sav1_save_old_name();
- update_camera_pos_from_warpid();
+ LoadCurrentMapData();
+ SetPlayerCoordsFromWarp();
}
void Overworld_SetWarpDestination(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y)
@@ -725,27 +724,27 @@ void sub_8084E14(void)
sWarpDestination = gSaveBlock1Ptr->warp4;
}
-void sub_8084E2C(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y)
+void SetFixedDiveWarp(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y)
{
- SetWarpData(&sUnknown_020322EC, mapGroup, mapNum, warpId, x, y);
+ SetWarpData(&gFixedDiveWarp, mapGroup, mapNum, warpId, x, y);
}
-void warp1_set_to_warp2(void)
+void SetFixedDiveWarpAsDestination(void)
{
- sWarpDestination = sUnknown_020322EC;
+ sWarpDestination = gFixedDiveWarp;
}
-void sub_8084E80(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y)
+void SetFixedHoleWarp(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y)
{
- SetWarpData(&sUnknown_020322F4, mapGroup, mapNum, warpId, x, y);
+ SetWarpData(&gFixedHoleWarp, mapGroup, mapNum, warpId, x, y);
}
-void sub_8084EBC(s16 x, s16 y)
+void SetFixedHoleWarpAsDestination(s16 x, s16 y)
{
- if (warp_data_is_not_neg_1(&sUnknown_020322F4) == TRUE)
- sWarpDestination = gUnknown_020322DC;
+ if (IsDummyWarp(&gFixedHoleWarp) == TRUE)
+ sWarpDestination = gLastUsedWarp;
else
- Overworld_SetWarpDestination(sUnknown_020322F4.mapGroup, sUnknown_020322F4.mapNum, -1, x, y);
+ Overworld_SetWarpDestination(gFixedHoleWarp.mapGroup, gFixedHoleWarp.mapNum, -1, x, y);
}
void warp1_set_to_sav1w(void)
@@ -786,7 +785,7 @@ const struct MapConnection *GetMapConnection(u8 dir)
return NULL;
}
-bool8 sub_8084FF8(u8 dir, u16 x, u16 y)
+bool8 SetDiveWarp(u8 dir, u16 x, u16 y)
{
const struct MapConnection *connection = GetMapConnection(dir);
@@ -797,21 +796,21 @@ bool8 sub_8084FF8(u8 dir, u16 x, u16 y)
else
{
mapheader_run_script_with_tag_x6();
- if (warp_data_is_not_neg_1(&sUnknown_020322EC))
+ if (IsDummyWarp(&gFixedDiveWarp))
return FALSE;
- warp1_set_to_warp2();
+ SetFixedDiveWarpAsDestination();
}
return TRUE;
}
-bool8 sub_8085058(u16 x, u16 y)
+bool8 SetDiveWarpEmerge(u16 x, u16 y)
{
- return sub_8084FF8(CONNECTION_EMERGE, x, y);
+ return SetDiveWarp(CONNECTION_EMERGE, x, y);
}
-bool8 sub_8085078(u16 x, u16 y)
+bool8 SetDiveWarpDive(u16 x, u16 y)
{
- return sub_8084FF8(CONNECTION_DIVE, x, y);
+ return SetDiveWarp(CONNECTION_DIVE, x, y);
}
void mliX_load_map(u8 mapGroup, u8 mapNum)
@@ -823,7 +822,7 @@ void mliX_load_map(u8 mapGroup, u8 mapNum)
sub_8085810();
ApplyCurrentWarp();
- set_current_map_header_from_sav1_save_old_name();
+ LoadCurrentMapData();
LoadEventObjTemplatesFromHeader();
TrySetMapSaveWarpStatus();
ClearTempFieldEventData();
@@ -859,7 +858,7 @@ static void mli0_load_map(u32 a1)
bool8 v2;
bool8 indoors;
- set_current_map_header_from_sav1_save_old_name();
+ LoadCurrentMapData();
if (!(sUnknown_020322D8 & 1))
{
if (gMapHeader.mapLayoutId == 0x169)
@@ -904,84 +903,84 @@ static void mli0_load_map(u32 a1)
}
}
-void player_avatar_init_params_reset(void)
+void ResetInitialPlayerAvatarState(void)
{
- sUnknown_02032300.player_field_1 = 1;
- sUnknown_02032300.player_field_0 = 1;
+ gInitialPlayerAvatarState.direction = 1;
+ gInitialPlayerAvatarState.transitionFlags = 1;
}
-void walkrun_find_lowest_active_bit_in_bitfield(void)
+void StoreInitialPlayerAvatarState(void)
{
- sUnknown_02032300.player_field_1 = GetPlayerFacingDirection();
+ gInitialPlayerAvatarState.direction = GetPlayerFacingDirection();
if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_MACH_BIKE))
- sUnknown_02032300.player_field_0 = 2;
+ gInitialPlayerAvatarState.transitionFlags = 2;
else if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_ACRO_BIKE))
- sUnknown_02032300.player_field_0 = 4;
+ gInitialPlayerAvatarState.transitionFlags = 4;
else if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_SURFING))
- sUnknown_02032300.player_field_0 = 8;
+ gInitialPlayerAvatarState.transitionFlags = 8;
else if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_4))
- sUnknown_02032300.player_field_0 = 16;
+ gInitialPlayerAvatarState.transitionFlags = 16;
else
- sUnknown_02032300.player_field_0 = 1;
+ gInitialPlayerAvatarState.transitionFlags = 1;
}
-static struct UnkPlayerStruct *sub_80852D4(void)
+static struct InitialPlayerAvatarState *GetInitialPlayerAvatarState(void)
{
- struct UnkPlayerStruct playerStruct;
+ struct InitialPlayerAvatarState playerStruct;
u8 mapType = Overworld_GetMapTypeOfSaveblockLocation();
- u16 v2 = cur_mapdata_block_role_at_screen_center_acc_to_sav1();
- u8 v4 = sub_808532C(&sUnknown_02032300, v2, mapType);
- playerStruct.player_field_0 = v4;
- playerStruct.player_field_1 = sub_808538C(&sUnknown_02032300, v4, v2, mapType);
- sUnknown_02032300 = playerStruct;
- return &sUnknown_02032300;
+ u16 metatileBehavior = GetCenterScreenMetatileBehavior();
+ u8 transitionFlags = GetAdjustedInitialTransitionFlags(&gInitialPlayerAvatarState, metatileBehavior, mapType);
+ playerStruct.transitionFlags = transitionFlags;
+ playerStruct.direction = GetAdjustedInitialDirection(&gInitialPlayerAvatarState, transitionFlags, metatileBehavior, mapType);
+ gInitialPlayerAvatarState = playerStruct;
+ return &gInitialPlayerAvatarState;
}
-static u8 sub_808532C(struct UnkPlayerStruct *playerStruct, u16 a2, u8 a3)
+static u8 GetAdjustedInitialTransitionFlags(struct InitialPlayerAvatarState *playerStruct, u16 metatileBehavior, u8 mapType)
{
- if (a3 != 8 && FlagGet(FLAG_SYS_CRUISE_MODE))
+ if (mapType != MAP_TYPE_INDOOR && FlagGet(FLAG_SYS_CRUISE_MODE))
return 1;
- else if (a3 == 5)
+ else if (mapType == MAP_TYPE_UNDERWATER)
return 16;
- else if (MetatileBehavior_IsSurfableWaterOrUnderwater(a2) == 1)
+ else if (MetatileBehavior_IsSurfableWaterOrUnderwater(metatileBehavior) == TRUE)
return 8;
else if (Overworld_IsBikingAllowed() != TRUE)
return 1;
- else if (playerStruct->player_field_0 == 2)
+ else if (playerStruct->transitionFlags == 2)
return 2;
- else if (playerStruct->player_field_0 != 4)
+ else if (playerStruct->transitionFlags != 4)
return 1;
else
return 4;
}
-static u8 sub_808538C(struct UnkPlayerStruct *playerStruct, u8 a2, u16 a3, u8 a4)
+static u8 GetAdjustedInitialDirection(struct InitialPlayerAvatarState *playerStruct, u8 transitionFlags, u16 metatileBehavior, u8 mapType)
{
- if (FlagGet(FLAG_SYS_CRUISE_MODE) && a4 == 6)
+ if (FlagGet(FLAG_SYS_CRUISE_MODE) && mapType == MAP_TYPE_6)
return 4;
- else if (MetatileBehavior_IsDeepSouthWarp(a3) == TRUE)
+ else if (MetatileBehavior_IsDeepSouthWarp(metatileBehavior) == TRUE)
return 2;
- else if (MetatileBehavior_IsNonAnimDoor(a3) == TRUE || MetatileBehavior_IsDoor(a3) == TRUE)
+ else if (MetatileBehavior_IsNonAnimDoor(metatileBehavior) == TRUE || MetatileBehavior_IsDoor(metatileBehavior) == TRUE)
return 1;
- else if (MetatileBehavior_IsSouthArrowWarp(a3) == TRUE)
+ else if (MetatileBehavior_IsSouthArrowWarp(metatileBehavior) == TRUE)
return 2;
- else if (MetatileBehavior_IsNorthArrowWarp(a3) == TRUE)
+ else if (MetatileBehavior_IsNorthArrowWarp(metatileBehavior) == TRUE)
return 1;
- else if (MetatileBehavior_IsWestArrowWarp(a3) == TRUE)
+ else if (MetatileBehavior_IsWestArrowWarp(metatileBehavior) == TRUE)
return 4;
- else if (MetatileBehavior_IsEastArrowWarp(a3) == TRUE)
+ else if (MetatileBehavior_IsEastArrowWarp(metatileBehavior) == TRUE)
return 3;
- else if ((playerStruct->player_field_0 == 16 && a2 == 8)
- || (playerStruct->player_field_0 == 8 && a2 == 16))
- return playerStruct->player_field_1;
- else if (MetatileBehavior_IsLadder(a3) == TRUE)
- return playerStruct->player_field_1;
+ else if ((playerStruct->transitionFlags == 16 && transitionFlags == 8)
+ || (playerStruct->transitionFlags == 8 && transitionFlags == 16))
+ return playerStruct->direction;
+ else if (MetatileBehavior_IsLadder(metatileBehavior) == TRUE)
+ return playerStruct->direction;
else
return 1;
}
-static u16 cur_mapdata_block_role_at_screen_center_acc_to_sav1(void)
+static u16 GetCenterScreenMetatileBehavior(void)
{
return MapGridGetMetatileBehaviorAt(gSaveBlock1Ptr->pos.x + 7, gSaveBlock1Ptr->pos.y + 7);
}
@@ -1231,7 +1230,7 @@ void Overworld_ChangeMusicTo(u16 newMusic)
u8 GetMapMusicFadeoutSpeed(void)
{
- const struct MapHeader *mapHeader = warp1_get_mapheader();
+ const struct MapHeader *mapHeader = GetDestinationWarpMapHeader();
if (Overworld_MapTypeIsIndoors(mapHeader->mapType) == TRUE)
return 2;
else
@@ -1257,7 +1256,7 @@ void music_something(void)
}
}
-bool8 sub_80859A0(void)
+bool8 BGMusicStopped(void)
{
return IsNotWaitingForBGMStop();
}
@@ -1360,7 +1359,7 @@ u8 Overworld_GetMapTypeOfSaveblockLocation(void)
u8 get_map_light_from_warp0(void)
{
- return GetMapTypeByWarpData(&gUnknown_020322DC);
+ return GetMapTypeByWarpData(&gLastUsedWarp);
}
bool8 is_map_type_1_2_3_5_or_6(u8 mapType)
@@ -1549,7 +1548,7 @@ void CB2_NewGame(void)
StopMapMusic();
ResetSafariZoneFlag_();
NewGameInitData();
- player_avatar_init_params_reset();
+ ResetInitialPlayerAvatarState();
PlayTimeCounter_Start();
ScriptContext1_Init();
ScriptContext2_Disable();
@@ -1571,7 +1570,7 @@ void CB2_WhiteOut(void)
StopMapMusic();
ResetSafariZoneFlag_();
DoWhiteOut();
- player_avatar_init_params_reset();
+ ResetInitialPlayerAvatarState();
ScriptContext1_Init();
ScriptContext2_Disable();
gFieldCallback = sub_80AF3C8;
@@ -1754,7 +1753,7 @@ void CB2_ContinueSavedGame(void)
{
ClearSecretBase2Field_9();
warp1_set_to_sav1w();
- warp_in();
+ WarpIntoMap();
sub_80EDB44();
SetMainCallback2(CB2_LoadMap);
}
@@ -1805,19 +1804,19 @@ static void VBlankCB_Field(void)
TransferTilesetAnimsBuffer();
}
-static void sub_80863B0(void)
+static void InitCurrentFlashLevelScanlineEffect(void)
{
- u8 val;
+ u8 flashLevel;
if (sub_81A9E6C())
{
door_upload_tiles();
- ScanlineEffect_SetParams(gUnknown_08339DBC);
+ ScanlineEffect_SetParams(sFlashEffectParams);
}
- else if ((val = Overworld_GetFlashLevel()))
+ else if ((flashLevel = Overworld_GetFlashLevel()))
{
- sub_80B00E8(val);
- ScanlineEffect_SetParams(gUnknown_08339DBC);
+ sub_80B00E8(flashLevel);
+ ScanlineEffect_SetParams(sFlashEffectParams);
}
}
@@ -1849,8 +1848,8 @@ static bool32 map_loading_iteration_3(u8 *state)
(*state)++;
break;
case 4:
- sub_80863B0();
- map_loading_lcd_reset();
+ InitCurrentFlashLevelScanlineEffect();
+ InitOverworldGraphicsRegisters();
sub_8197200();
(*state)++;
break;
@@ -1924,8 +1923,8 @@ static bool32 load_map_stuff(u8 *state, u32 a2)
(*state)++;
break;
case 4:
- sub_80863B0();
- map_loading_lcd_reset();
+ InitCurrentFlashLevelScanlineEffect();
+ InitOverworldGraphicsRegisters();
sub_8197200();
(*state)++;
break;
@@ -2021,8 +2020,8 @@ static bool32 map_loading_iteration_2_link(u8 *state)
(*state)++;
break;
case 3:
- sub_80863B0();
- map_loading_lcd_reset();
+ InitCurrentFlashLevelScanlineEffect();
+ InitOverworldGraphicsRegisters();
sub_8197200();
(*state)++;
break;
@@ -2101,13 +2100,13 @@ static void sub_80867D8(void)
static void sub_8086860(void)
{
- sub_80863B0();
- map_loading_lcd_reset();
+ InitCurrentFlashLevelScanlineEffect();
+ InitOverworldGraphicsRegisters();
sub_8197200();
mapdata_load_assets_to_gpu_and_full_redraw();
}
-static void map_loading_lcd_reset(void)
+static void InitOverworldGraphicsRegisters(void)
{
clear_scheduled_bg_copies_to_vram();
reset_temp_tile_data_buffers();
@@ -2177,16 +2176,16 @@ static void sub_80869DC(void)
static void mli4_mapscripts_and_other(void)
{
s16 x, y;
- struct UnkPlayerStruct *player;
+ struct InitialPlayerAvatarState *player;
gUnknown_03005DEC = 0;
gUnknown_03005DE8 = 0;
sub_808D438();
sav1_camera_get_focus_coords(&x, &y);
- player = sub_80852D4();
- InitPlayerAvatar(x, y, player->player_field_1, gSaveBlock2Ptr->playerGender);
- SetPlayerAvatarTransitionFlags(player->player_field_0);
- player_avatar_init_params_reset();
+ player = GetInitialPlayerAvatarState();
+ InitPlayerAvatar(x, y, player->direction, gSaveBlock2Ptr->playerGender);
+ SetPlayerAvatarTransitionFlags(player->transitionFlags);
+ ResetInitialPlayerAvatarState();
TrySpawnEventObjects(0, 0);
mapheader_run_first_tag4_script_list_match();
}
@@ -2731,8 +2730,8 @@ static const u8 *sub_80873B4(struct UnkStruct_8054FF8 *a1)
return 0;
unkStruct = a1->sub;
- unkStruct.x += gUnknown_08339D64[a1->d].x;
- unkStruct.y += gUnknown_08339D64[a1->d].y;
+ unkStruct.x += gDirectionToVectors[a1->d].x;
+ unkStruct.y += gDirectionToVectors[a1->d].y;
unkStruct.height = 0;
linkPlayerId = GetLinkPlayerIdAt(unkStruct.x, unkStruct.y);
@@ -3165,12 +3164,12 @@ static void SpriteCB_LinkPlayer(struct Sprite *sprite)
SetObjectSubpriorityByZCoord(eventObj->previousElevation, sprite, 1);
sprite->oam.priority = ZCoordToPriority(eventObj->previousElevation);
- if (!linkPlayerEventObj->mode)
+ if (!linkPlayerEventObj->mode)
StartSpriteAnim(sprite, GetFaceDirectionAnimNum(eventObj->range.as_byte));
else
StartSpriteAnimIfDifferent(sprite, GetMoveDirectionAnimNum(eventObj->range.as_byte));
- UpdateEventObjectSpriteVisibility(sprite, 0);
+ UpdateEventObjectSpriteVisibility(sprite, 0);
if (eventObj->triggerGroundEffectsOnMove)
{
sprite->invisible = ((sprite->data[7] & 4) >> 2);
diff --git a/src/rom_8011DC0.c b/src/rom_8011DC0.c
index b2bd2eb78..56c31f89f 100644
--- a/src/rom_8011DC0.c
+++ b/src/rom_8011DC0.c
@@ -1637,7 +1637,7 @@ 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);
- warp_in();
+ WarpIntoMap();
}
void sub_8014304(s8 mapGroup, s8 mapNum, s32 x, s32 y, u16 arg4)
@@ -1648,7 +1648,7 @@ void sub_8014304(s8 mapGroup, s8 mapNum, s32 x, s32 y, u16 arg4)
gUnknown_03005DB4 = GetMultiplayerId();
sub_809D2BC();
Overworld_SetWarpDestination(mapGroup, mapNum, -1, x, y);
- warp_in();
+ WarpIntoMap();
}
void sub_8014384(void)
diff --git a/src/safari_zone.c b/src/safari_zone.c
index 01d72fa13..427a5ceb8 100644
--- a/src/safari_zone.c
+++ b/src/safari_zone.c
@@ -35,7 +35,7 @@ extern void CB2_ReturnToFieldContinueScriptPlayMapMusic(void);
extern void CB2_LoadMap(void);
extern void sub_80AF6F0(void);
extern void ScriptContext1_Stop(void);
-extern void warp_in(void);
+extern void WarpIntoMap(void);
extern void GetXYCoordsOneStepInFrontOfPlayer(s16* x, s16* y);
extern void PlayerGetDestCoords(s16* x, s16* y);
@@ -117,7 +117,7 @@ void CB2_EndSafariBattle(void)
else if (gBattleOutcome == B_OUTCOME_NO_SAFARI_BALLS)
{
ScriptContext2_RunNewScript(EventScript_2A4B4C);
- warp_in();
+ WarpIntoMap();
gFieldCallback = sub_80AF6F0;
SetMainCallback2(CB2_LoadMap);
}
diff --git a/src/scrcmd.c b/src/scrcmd.c
index 01d04704a..31a4ed35a 100644
--- a/src/scrcmd.c
+++ b/src/scrcmd.c
@@ -750,7 +750,7 @@ bool8 ScrCmd_warp(struct ScriptContext *ctx)
Overworld_SetWarpDestination(mapGroup, mapNum, warpId, x, y);
sub_80AF734();
- player_avatar_init_params_reset();
+ ResetInitialPlayerAvatarState();
return TRUE;
}
@@ -764,7 +764,7 @@ bool8 ScrCmd_warpsilent(struct ScriptContext *ctx)
Overworld_SetWarpDestination(mapGroup, mapNum, warpId, x, y);
sp13E_warp_to_last_warp();
- player_avatar_init_params_reset();
+ ResetInitialPlayerAvatarState();
return TRUE;
}
@@ -778,7 +778,7 @@ bool8 ScrCmd_warpdoor(struct ScriptContext *ctx)
Overworld_SetWarpDestination(mapGroup, mapNum, warpId, x, y);
sub_80AF7D0();
- player_avatar_init_params_reset();
+ ResetInitialPlayerAvatarState();
return TRUE;
}
@@ -791,11 +791,11 @@ bool8 ScrCmd_warphole(struct ScriptContext *ctx)
PlayerGetDestCoords(&x, &y);
if (mapGroup == 0xFF && mapNum == 0xFF)
- sub_8084EBC(x - 7, y - 7);
+ SetFixedHoleWarpAsDestination(x - 7, y - 7);
else
Overworld_SetWarpDestination(mapGroup, mapNum, -1, x - 7, y - 7);
sp13F_fall_to_last_warp();
- player_avatar_init_params_reset();
+ ResetInitialPlayerAvatarState();
return TRUE;
}
@@ -809,7 +809,7 @@ bool8 ScrCmd_warpteleport(struct ScriptContext *ctx)
Overworld_SetWarpDestination(mapGroup, mapNum, warpId, x, y);
sub_80AF848();
- player_avatar_init_params_reset();
+ ResetInitialPlayerAvatarState();
return TRUE;
}
@@ -823,7 +823,7 @@ bool8 ScrCmd_warpD7(struct ScriptContext *ctx)
Overworld_SetWarpDestination(mapGroup, mapNum, warpId, x, y);
sub_80AF87C();
- player_avatar_init_params_reset();
+ ResetInitialPlayerAvatarState();
return TRUE;
}
@@ -859,7 +859,7 @@ bool8 ScrCmd_setdivewarp(struct ScriptContext *ctx)
u16 x = VarGet(ScriptReadHalfword(ctx));
u16 y = VarGet(ScriptReadHalfword(ctx));
- sub_8084E2C(mapGroup, mapNum, warpId, x, y);
+ SetFixedDiveWarp(mapGroup, mapNum, warpId, x, y);
return FALSE;
}
@@ -871,7 +871,7 @@ bool8 ScrCmd_setholewarp(struct ScriptContext *ctx)
u16 x = VarGet(ScriptReadHalfword(ctx));
u16 y = VarGet(ScriptReadHalfword(ctx));
- sub_8084E80(mapGroup, mapNum, warpId, x, y);
+ SetFixedHoleWarp(mapGroup, mapNum, warpId, x, y);
return FALSE;
}
@@ -2240,7 +2240,7 @@ bool8 ScrCmd_warpD1(struct ScriptContext *ctx)
Overworld_SetWarpDestination(mapGroup, mapNum, warpId, x, y);
sub_808D074(GetPlayerFacingDirection());
sub_80B0244();
- player_avatar_init_params_reset();
+ ResetInitialPlayerAvatarState();
return TRUE;
}
@@ -2293,6 +2293,6 @@ bool8 ScrCmd_warpE0(struct ScriptContext *ctx)
Overworld_SetWarpDestination(mapGroup, mapNum, warpId, x, y);
sub_80AF79C();
- player_avatar_init_params_reset();
+ ResetInitialPlayerAvatarState();
return TRUE;
}
diff --git a/src/secret_base.c b/src/secret_base.c
index d357261fe..7fae50a81 100644
--- a/src/secret_base.c
+++ b/src/secret_base.c
@@ -388,7 +388,7 @@ void sub_80E8FD0(u8 taskId)
gSaveBlock1Ptr->secretBases[secretBaseRecordId].sbr_field_10 ++;
}
sub_80E8F9C();
- warp_in();
+ WarpIntoMap();
gFieldCallback = sub_80AF168;
SetMainCallback2(CB2_LoadMap);
DestroyTask(taskId);
@@ -446,7 +446,7 @@ void sub_80E916C(u8 taskId)
{
idx = sCurSecretBaseId / 10 * 4;
Overworld_SetWarpDestination(gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1, gUnknown_0858CFE8[idx + 2], gUnknown_0858CFE8[idx + 3]);
- warp_in();
+ WarpIntoMap();
gFieldCallback = sub_80E9108;
SetMainCallback2(CB2_LoadMap);
DestroyTask(taskId);
@@ -644,7 +644,7 @@ void sub_80E96A4(u8 taskId)
break;
case 2:
copy_saved_warp2_bank_and_enter_x_to_warp1(0x7e);
- warp_in();
+ WarpIntoMap();
gFieldCallback = mapldr_default;
SetMainCallback2(CB2_LoadMap);
ScriptContext2_Disable();