Bring labels for overworld.c over from pokeruby

This commit is contained in:
Slawter666 2018-09-04 23:31:37 +01:00
parent 5c66b8a7ef
commit 4c54212b1f
16 changed files with 231 additions and 232 deletions

View File

@ -774,7 +774,7 @@ _08150340:
orrs r3, r0 orrs r3, r0
str r3, [r2, 0x8] str r3, [r2, 0x8]
ldr r0, [r2, 0x8] ldr r0, [r2, 0x8]
bl warp_in bl WarpIntoMap
ldr r0, =gFieldCallback ldr r0, =gFieldCallback
str r4, [r0] str r4, [r0]
ldr r0, =CB2_LoadMap ldr r0, =CB2_LoadMap

View File

@ -530,7 +530,7 @@ sub_809C2C8: @ 809C2C8
ldrh r1, [r4, 0x2] ldrh r1, [r4, 0x2]
b _0809C30E b _0809C30E
_0809C2F0: _0809C2F0:
ldr r1, =gUnknown_08339D64 ldr r1, =gDirectionToVectors
lsls r2, r6, 3 lsls r2, r6, 3
adds r0, r2, r1 adds r0, r2, r1
ldr r3, [r0] ldr r3, [r0]
@ -631,7 +631,7 @@ _0809C3B4:
lsrs r0, 24 lsrs r0, 24
cmp r0, 0x1 cmp r0, 0x1
bne _0809C400 bne _0809C400
ldr r1, =gUnknown_08339D64 ldr r1, =gDirectionToVectors
lsls r2, r7, 3 lsls r2, r7, 3
adds r0, r2, r1 adds r0, r2, r1
ldr r3, [r0] ldr r3, [r0]
@ -1658,7 +1658,7 @@ mapheader_run_first_tag2_script_list_match_conditionally: @ 809CC38
negs r0, r0 negs r0, r0
cmp r4, r0 cmp r4, r0
beq _0809CC90 beq _0809CC90
bl walkrun_find_lowest_active_bit_in_bitfield bl StoreInitialPlayerAvatarState
mov r0, r8 mov r0, r8
adds r1, r4, 0 adds r1, r4, 0
adds r2, r7, 0 adds r2, r7, 0
@ -1699,7 +1699,7 @@ sub_809CC9C: @ 809CC9C
lsrs r0, 24 lsrs r0, 24
cmp r0, 0x1 cmp r0, 0x1
bne _0809CD8A bne _0809CD8A
bl walkrun_find_lowest_active_bit_in_bitfield bl StoreInitialPlayerAvatarState
adds r0, r7, 0 adds r0, r7, 0
adds r1, r4, 0 adds r1, r4, 0
adds r2, r6, 0 adds r2, r6, 0
@ -2083,7 +2083,7 @@ _0809CFB0:
lsrs r0, 24 lsrs r0, 24
cmp r0, 0x1 cmp r0, 0x1
bne _0809CFFC bne _0809CFFC
bl walkrun_find_lowest_active_bit_in_bitfield bl StoreInitialPlayerAvatarState
adds r0, r6, 0 adds r0, r6, 0
adds r1, r4, 0 adds r1, r4, 0
adds r2, r5, 0 adds r2, r5, 0
@ -2334,7 +2334,7 @@ dive_warp: @ 809D16C
subs r1, 0x7 subs r1, 0x7
lsls r1, 16 lsls r1, 16
lsrs r1, 16 lsrs r1, 16
bl sub_8085058 bl SetDiveWarpEmerge
b _0809D1C8 b _0809D1C8
.pool .pool
_0809D1A4: _0809D1A4:
@ -2353,12 +2353,12 @@ _0809D1A4:
subs r1, 0x7 subs r1, 0x7
lsls r1, 16 lsls r1, 16
lsrs r1, 16 lsrs r1, 16
bl sub_8085078 bl SetDiveWarpDive
_0809D1C8: _0809D1C8:
lsls r0, 24 lsls r0, 24
cmp r0, 0 cmp r0, 0
beq _0809D1E0 beq _0809D1E0
bl walkrun_find_lowest_active_bit_in_bitfield bl StoreInitialPlayerAvatarState
bl sp13E_warp_to_last_warp bl sp13E_warp_to_last_warp
movs r0, 0xE9 movs r0, 0xE9
bl PlaySE bl PlaySE
@ -2407,7 +2407,7 @@ sub_809D1E8: @ 809D1E8
subs r1, 0x7 subs r1, 0x7
lsls r1, 16 lsls r1, 16
lsrs r1, 16 lsrs r1, 16
bl sub_8085058 bl SetDiveWarpEmerge
lsls r0, 24 lsls r0, 24
lsrs r0, 24 lsrs r0, 24
cmp r0, 0x1 cmp r0, 0x1
@ -2431,7 +2431,7 @@ _0809D244:
subs r1, 0x7 subs r1, 0x7
lsls r1, 16 lsls r1, 16
lsrs r1, 16 lsrs r1, 16
bl sub_8085078 bl SetDiveWarpDive
lsls r0, 24 lsls r0, 24
lsrs r0, 24 lsrs r0, 24
cmp r0, 0x1 cmp r0, 0x1

View File

@ -7914,7 +7914,7 @@ sub_80AF0B4: @ 80AF0B4
adds r4, r0, 0 adds r4, r0, 0
lsls r4, 24 lsls r4, 24
lsrs r4, 24 lsrs r4, 24
bl warp1_get_mapheader bl GetDestinationWarpMapHeader
ldrb r1, [r0, 0x17] ldrb r1, [r0, 0x17]
adds r0, r4, 0 adds r0, r4, 0
bl sub_8137360 bl sub_8137360
@ -8924,7 +8924,7 @@ _080AF914:
bl sub_80AF710 bl sub_80AF710
cmp r0, 0 cmp r0, 0
bne _080AF93E bne _080AF93E
bl sub_80859A0 bl BGMusicStopped
lsls r0, 24 lsls r0, 24
cmp r0, 0 cmp r0, 0
beq _080AF93E beq _080AF93E
@ -8934,7 +8934,7 @@ _080AF926:
strh r0, [r4, 0x8] strh r0, [r4, 0x8]
b _080AF93E b _080AF93E
_080AF92E: _080AF92E:
bl warp_in bl WarpIntoMap
ldr r0, =sub_8086074 ldr r0, =sub_8086074
bl SetMainCallback2 bl SetMainCallback2
adds r0, r5, 0 adds r0, r5, 0
@ -8999,7 +8999,7 @@ _080AF9B2:
bl sub_80AF710 bl sub_80AF710
cmp r0, 0 cmp r0, 0
bne _080AF9E8 bne _080AF9E8
bl sub_80859A0 bl BGMusicStopped
lsls r0, 24 lsls r0, 24
cmp r0, 0 cmp r0, 0
beq _080AF9E8 beq _080AF9E8
@ -9014,7 +9014,7 @@ _080AF9D0:
ldrb r0, [r0] ldrb r0, [r0]
cmp r0, 0 cmp r0, 0
bne _080AF9E8 bne _080AF9E8
bl warp_in bl WarpIntoMap
ldr r0, =CB2_LoadMap ldr r0, =CB2_LoadMap
bl SetMainCallback2 bl SetMainCallback2
adds r0, r5, 0 adds r0, r5, 0
@ -9076,7 +9076,7 @@ _080AFA44:
bl sub_81BE72C bl sub_81BE72C
strh r5, [r4, 0xA] strh r5, [r4, 0xA]
_080AFA5A: _080AFA5A:
bl sub_80859A0 bl BGMusicStopped
lsls r0, 24 lsls r0, 24
cmp r0, 0 cmp r0, 0
beq _080AFA7C beq _080AFA7C
@ -9086,7 +9086,7 @@ _080AFA64:
strh r0, [r4, 0x8] strh r0, [r4, 0x8]
b _080AFA7C b _080AFA7C
_080AFA6C: _080AFA6C:
bl warp_in bl WarpIntoMap
ldr r0, =CB2_LoadMap ldr r0, =CB2_LoadMap
bl SetMainCallback2 bl SetMainCallback2
adds r0, r6, 0 adds r0, r6, 0
@ -9297,7 +9297,7 @@ _080AFC2C:
bl sub_80AF710 bl sub_80AF710
cmp r0, 0 cmp r0, 0
bne _080AFC56 bne _080AFC56
bl sub_80859A0 bl BGMusicStopped
lsls r0, 24 lsls r0, 24
cmp r0, 0 cmp r0, 0
beq _080AFC56 beq _080AFC56
@ -9307,7 +9307,7 @@ _080AFC3E:
strh r0, [r4, 0x8] strh r0, [r4, 0x8]
b _080AFC56 b _080AFC56
_080AFC46: _080AFC46:
bl warp_in bl WarpIntoMap
ldr r0, =sub_8086024 ldr r0, =sub_8086024
bl SetMainCallback2 bl SetMainCallback2
adds r0, r5, 0 adds r0, r5, 0
@ -10049,7 +10049,7 @@ _080B0210:
bl sub_80AF710 bl sub_80AF710
cmp r0, 0 cmp r0, 0
bne _080B023A bne _080B023A
bl sub_80859A0 bl BGMusicStopped
lsls r0, 24 lsls r0, 24
cmp r0, 0 cmp r0, 0
beq _080B023A beq _080B023A
@ -10059,7 +10059,7 @@ _080B0222:
strh r0, [r4, 0x8] strh r0, [r4, 0x8]
b _080B023A b _080B023A
_080B022A: _080B022A:
bl warp_in bl WarpIntoMap
ldr r0, =CB2_LoadMap ldr r0, =CB2_LoadMap
bl SetMainCallback2 bl SetMainCallback2
adds r0, r5, 0 adds r0, r5, 0
@ -10492,7 +10492,7 @@ task50_0807F0C8: @ 80B05CC
push {r4,lr} push {r4,lr}
lsls r0, 24 lsls r0, 24
lsrs r4, r0, 24 lsrs r4, r0, 24
bl sub_80859A0 bl BGMusicStopped
lsls r0, 24 lsls r0, 24
lsrs r0, 24 lsrs r0, 24
cmp r0, 0x1 cmp r0, 0x1

View File

@ -1,10 +1,10 @@
#ifndef GUARD_OVERWORLD_H #ifndef GUARD_OVERWORLD_H
#define GUARD_OVERWORLD_H #define GUARD_OVERWORLD_H
struct UnkPlayerStruct struct InitialPlayerAvatarState
{ {
u8 player_field_0; u8 transitionFlags;
u8 player_field_1; u8 direction;
}; };
struct LinkPlayerEventObject struct LinkPlayerEventObject
@ -16,7 +16,7 @@ struct LinkPlayerEventObject
}; };
// Exported RAM declarations // Exported RAM declarations
extern struct WarpData gUnknown_020322DC; extern struct WarpData gLastUsedWarp;
extern struct LinkPlayerEventObject gLinkPlayerEventObjects[4]; extern struct LinkPlayerEventObject gLinkPlayerEventObjects[4];
extern u16 *gBGTilemapBuffers1; extern u16 *gBGTilemapBuffers1;
@ -26,7 +26,7 @@ extern u16 *gBGTilemapBuffers3;
extern void (*gFieldCallback)(void); extern void (*gFieldCallback)(void);
// Exported ROM declarations // Exported ROM declarations
extern const struct UCoords32 gUnknown_08339D64[]; extern const struct UCoords32 gDirectionToVectors[];
void DoWhiteOut(void); void DoWhiteOut(void);
void Overworld_ResetStateAfterFly(void); void Overworld_ResetStateAfterFly(void);
@ -45,13 +45,13 @@ const struct MapLayout *GetMapLayout(void);
void ApplyCurrentWarp(void); void ApplyCurrentWarp(void);
void set_warp2_warp3_to_neg_1(void); void set_warp2_warp3_to_neg_1(void);
void SetWarpData(struct WarpData *warp, s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y); void SetWarpData(struct WarpData *warp, s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y);
bool32 warp_data_is_not_neg_1(struct WarpData *warp); bool32 IsDummyWarp(struct WarpData *warp);
struct MapHeader const *const Overworld_GetMapHeaderByGroupAndId(u16 mapGroup, u16 mapNum); struct MapHeader const *const Overworld_GetMapHeaderByGroupAndId(u16 mapGroup, u16 mapNum);
struct MapHeader const *const warp1_get_mapheader(void); struct MapHeader const *const GetDestinationWarpMapHeader(void);
void set_current_map_header_from_sav1_save_old_name(void); void LoadCurrentMapData(void);
void LoadSaveblockMapHeader(void); void LoadSaveblockMapHeader(void);
void update_camera_pos_from_warpid(void); void SetPlayerCoordsFromWarp(void);
void warp_in(void); void WarpIntoMap(void);
void Overworld_SetWarpDestination(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y); void Overworld_SetWarpDestination(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y);
void warp1_set_2(s8 mapGroup, s8 mapNum, s8 warpId); 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(s32 unused, s8 mapGroup, s8 mapNum, s8 warpId);
@ -63,21 +63,21 @@ void Overworld_SetHealLocationWarp(u8 healLocationId);
void sub_8084D5C(s16 a1, s16 a2); void sub_8084D5C(s16 a1, s16 a2);
void sub_8084DD4(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y); void sub_8084DD4(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y);
void sub_8084E14(void); void sub_8084E14(void);
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);
void warp1_set_to_warp2(void); void SetFixedDiveWarpAsDestination(void);
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);
void sub_8084EBC(s16 x, s16 y); void SetFixedHoleWarpAsDestination(s16 x, s16 y);
void warp1_set_to_sav1w(void); void warp1_set_to_sav1w(void);
void sub_8084F2C(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y); void sub_8084F2C(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y);
void sub_8084F6C(u8 a1); void sub_8084F6C(u8 a1);
void sub_8084FAC(void); void sub_8084FAC(void);
const struct MapConnection *GetMapConnection(u8 dir); const struct MapConnection *GetMapConnection(u8 dir);
bool8 sub_8084FF8(u8 dir, u16 x, u16 y); bool8 SetDiveWarp(u8 dir, u16 x, u16 y);
bool8 sub_8085058(u16 x, u16 y); bool8 SetDiveWarpEmerge(u16 x, u16 y);
bool8 sub_8085078(u16 x, u16 y); bool8 SetDiveWarpDive(u16 x, u16 y);
void mliX_load_map(u8 mapGroup, u8 mapNum); void mliX_load_map(u8 mapGroup, u8 mapNum);
void player_avatar_init_params_reset(void); void ResetInitialPlayerAvatarState(void);
void walkrun_find_lowest_active_bit_in_bitfield(void); void StoreInitialPlayerAvatarState(void);
bool32 Overworld_IsBikingAllowed(void); bool32 Overworld_IsBikingAllowed(void);
void SetDefaultFlashLevel(void); void SetDefaultFlashLevel(void);
void Overworld_SetFlashLevel(s32 flashLevel); void Overworld_SetFlashLevel(s32 flashLevel);
@ -96,7 +96,7 @@ void Overworld_ChangeMusicToDefault(void);
void Overworld_ChangeMusicTo(u16 newMusic); void Overworld_ChangeMusicTo(u16 newMusic);
u8 GetMapMusicFadeoutSpeed(void); u8 GetMapMusicFadeoutSpeed(void);
void music_something(void); void music_something(void);
bool8 sub_80859A0(void); bool8 BGMusicStopped(void);
void Overworld_FadeOutMapMusic(void); void Overworld_FadeOutMapMusic(void);
void UpdateAmbientCry(s16 *state, u16 *delayCounter); void UpdateAmbientCry(s16 *state, u16 *delayCounter);
u8 GetMapTypeByGroupAndId(s8 mapGroup, s8 mapNum); u8 GetMapTypeByGroupAndId(s8 mapGroup, s8 mapNum);

View File

@ -1132,7 +1132,7 @@ void sub_8127B04(u8 taskId)
{ {
DrawWholeMapView(); DrawWholeMapView();
Overworld_SetWarpDestination(gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1, gTasks[taskId].data[3], gTasks[taskId].data[4]); 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) u16 sub_8127B54(u8 decor, u8 a1)

View File

@ -798,7 +798,7 @@ bool8 (*const gDirectionBlockedMetatileFuncs[])(u8) = {
MetatileBehavior_IsWestBlocked MetatileBehavior_IsWestBlocked
}; };
const struct Coords16 gDirectionToVectors[] = { static const struct Coords16 sDirectionToVectors[] = {
{ 0, 0}, { 0, 0},
{ 0, 1}, { 0, 1},
{ 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) void MoveCoords(u8 direction, s16 *x, s16 *y)
{ {
*x += gDirectionToVectors[direction].x; *x += sDirectionToVectors[direction].x;
*y += gDirectionToVectors[direction].y; *y += sDirectionToVectors[direction].y;
} }
void sub_8092F60(u8 direction, s16 *x, s16 *y) void sub_8092F60(u8 direction, s16 *x, s16 *y)
{ {
*x += gDirectionToVectors[direction].x << 4; *x += sDirectionToVectors[direction].x << 4;
*y += gDirectionToVectors[direction].y << 4; *y += sDirectionToVectors[direction].y << 4;
} }
static void MoveCoordsInDirection(u32 dir, s16 *x, s16 *y, s16 deltaX, s16 deltaY) 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; u8 direction = dir;
s16 dx2 = (u16)deltaX; s16 dx2 = (u16)deltaX;
s16 dy2 = (u16)deltaY; s16 dy2 = (u16)deltaY;
if (gDirectionToVectors[direction].x > 0) if (sDirectionToVectors[direction].x > 0)
*x += dx2; *x += dx2;
if (gDirectionToVectors[direction].x < 0) if (sDirectionToVectors[direction].x < 0)
*x -= dx2; *x -= dx2;
if (gDirectionToVectors[direction].y > 0) if (sDirectionToVectors[direction].y > 0)
*y += dy2; *y += dy2;
if (gDirectionToVectors[direction].y < 0) if (sDirectionToVectors[direction].y < 0)
*y -= dy2; *y -= dy2;
} }
@ -8389,32 +8389,32 @@ void UnfreezeEventObjects(void)
void Step1(struct Sprite *sprite, u8 dir) void Step1(struct Sprite *sprite, u8 dir)
{ {
sprite->pos1.x += gDirectionToVectors[dir].x; sprite->pos1.x += sDirectionToVectors[dir].x;
sprite->pos1.y += gDirectionToVectors[dir].y; sprite->pos1.y += sDirectionToVectors[dir].y;
} }
void Step2(struct Sprite *sprite, u8 dir) void Step2(struct Sprite *sprite, u8 dir)
{ {
sprite->pos1.x += 2 * (u16) gDirectionToVectors[dir].x; sprite->pos1.x += 2 * (u16) sDirectionToVectors[dir].x;
sprite->pos1.y += 2 * (u16) gDirectionToVectors[dir].y; sprite->pos1.y += 2 * (u16) sDirectionToVectors[dir].y;
} }
void Step3(struct Sprite *sprite, u8 dir) void Step3(struct Sprite *sprite, u8 dir)
{ {
sprite->pos1.x += 2 * (u16) gDirectionToVectors[dir].x + (u16) gDirectionToVectors[dir].x; sprite->pos1.x += 2 * (u16) sDirectionToVectors[dir].x + (u16) sDirectionToVectors[dir].x;
sprite->pos1.y += 2 * (u16) gDirectionToVectors[dir].y + (u16) gDirectionToVectors[dir].y; sprite->pos1.y += 2 * (u16) sDirectionToVectors[dir].y + (u16) sDirectionToVectors[dir].y;
} }
void Step4(struct Sprite *sprite, u8 dir) void Step4(struct Sprite *sprite, u8 dir)
{ {
sprite->pos1.x += 4 * (u16) gDirectionToVectors[dir].x; sprite->pos1.x += 4 * (u16) sDirectionToVectors[dir].x;
sprite->pos1.y += 4 * (u16) gDirectionToVectors[dir].y; sprite->pos1.y += 4 * (u16) sDirectionToVectors[dir].y;
} }
void Step8(struct Sprite *sprite, u8 dir) void Step8(struct Sprite *sprite, u8 dir)
{ {
sprite->pos1.x += 8 * (u16) gDirectionToVectors[dir].x; sprite->pos1.x += 8 * (u16) sDirectionToVectors[dir].x;
sprite->pos1.y += 8 * (u16) gDirectionToVectors[dir].y; sprite->pos1.y += 8 * (u16) sDirectionToVectors[dir].y;
} }
void oamt_npc_ministep_reset(struct Sprite *sprite, u8 a2, u8 a3) void oamt_npc_ministep_reset(struct Sprite *sprite, u8 a2, u8 a3)

View File

@ -1170,7 +1170,7 @@ void task00_8084310(u8 taskId)
if (!FieldEffectActiveListContains(FLDEFF_USE_FLY)) if (!FieldEffectActiveListContains(FLDEFF_USE_FLY))
{ {
Overworld_ResetStateAfterFly(); Overworld_ResetStateAfterFly();
warp_in(); WarpIntoMap();
SetMainCallback2(CB2_LoadMap); SetMainCallback2(CB2_LoadMap);
gFieldCallback = mapldr_08084390; gFieldCallback = mapldr_08084390;
DestroyTask(taskId); DestroyTask(taskId);
@ -1355,7 +1355,7 @@ void sub_80B6FB8(struct Task *);
void sub_80B7004(struct Task *); void sub_80B7004(struct Task *);
void sub_80B7050(void); void sub_80B7050(void);
void sub_80B7060(void); void sub_80B7060(void);
bool8 sub_80859A0(void); bool8 BGMusicStopped(void);
void sub_80B70B4(void); void sub_80B70B4(void);
void sub_80E1570(void); void sub_80E1570(void);
void sub_80B70DC(u8); void sub_80B70DC(u8);
@ -1476,10 +1476,10 @@ void sub_80B7050(void)
void sub_80B7060(void) void sub_80B7060(void)
{ {
if (!gPaletteFade.active && sub_80859A0() == TRUE) if (!gPaletteFade.active && BGMusicStopped() == TRUE)
{ {
sub_80E1570(); sub_80E1570();
warp_in(); WarpIntoMap();
gFieldCallback = sub_80B70B4; gFieldCallback = sub_80B70B4;
SetMainCallback2(CB2_LoadMap); SetMainCallback2(CB2_LoadMap);
DestroyTask(FindTaskIdByFunc(sub_80B6E88)); 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) 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; gFieldCallback = mapldr_080851BC;
SetMainCallback2(CB2_LoadMap); SetMainCallback2(CB2_LoadMap);
DestroyTask(FindTaskIdByFunc(sub_80B75F0)); DestroyTask(FindTaskIdByFunc(sub_80B75F0));
@ -2004,9 +2004,9 @@ void mapldr_080859D4(void);
bool8 sub_80B7BF4(struct Task *task, struct EventObject *eventObject, struct Sprite *sprite) 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; gFieldCallback = sub_80B6B68;
SetMainCallback2(CB2_LoadMap); SetMainCallback2(CB2_LoadMap);
DestroyTask(FindTaskIdByFunc(sub_80B7A8C)); DestroyTask(FindTaskIdByFunc(sub_80B7A8C));
@ -2063,11 +2063,11 @@ void sub_80B7D34(struct Task *task)
eventObject = &gEventObjects[gPlayerAvatar.eventObjectId]; eventObject = &gEventObjects[gPlayerAvatar.eventObjectId];
if (!EventObjectIsMovementOverridden(eventObject) || EventObjectClearHeldMovementIfFinished(eventObject)) 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]); SetEventObjectDirection(eventObject, task->data[15]);
sub_8084E14(); sub_8084E14();
warp_in(); WarpIntoMap();
gFieldCallback = mapldr_080859D4; gFieldCallback = mapldr_080859D4;
SetMainCallback2(CB2_LoadMap); SetMainCallback2(CB2_LoadMap);
DestroyTask(FindTaskIdByFunc(sub_80B7CE4)); DestroyTask(FindTaskIdByFunc(sub_80B7CE4));
@ -2234,10 +2234,10 @@ static void TeleportFieldEffectTask4(struct Task *task)
task->data[5] = TRUE; task->data[5] = TRUE;
} }
if (sub_80859A0() == TRUE) if (BGMusicStopped() == TRUE)
{ {
Overworld_SetWarpDestToLastHealLoc(); Overworld_SetWarpDestToLastHealLoc();
warp_in(); WarpIntoMap();
SetMainCallback2(CB2_LoadMap); SetMainCallback2(CB2_LoadMap);
gFieldCallback = mapldr_08085D88; gFieldCallback = mapldr_08085D88;
DestroyTask(FindTaskIdByFunc(ExecuteTeleportFieldEffectTask)); DestroyTask(FindTaskIdByFunc(ExecuteTeleportFieldEffectTask));

View File

@ -269,7 +269,7 @@ u16 GetRecordedCyclingRoadResults(void) {
} }
void UpdateCyclingRoadState(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; 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 }; 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; 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++) for (i = 0; gUnknown_085B2C2A[i] != 0xFFFF; i++)
{ {

View File

@ -712,8 +712,8 @@ int GetPostCameraMoveMapBorderId(int x, int y)
int CanCameraMoveInDirection(int direction) int CanCameraMoveInDirection(int direction)
{ {
int x, y; int x, y;
x = gSaveBlock1Ptr->pos.x + 7 + gUnknown_08339D64[direction].x; x = gSaveBlock1Ptr->pos.x + 7 + gDirectionToVectors[direction].x;
y = gSaveBlock1Ptr->pos.y + 7 + gUnknown_08339D64[direction].y; y = gSaveBlock1Ptr->pos.y + 7 + gDirectionToVectors[direction].y;
if (GetMapBorderIdAt(x, y) == -1) if (GetMapBorderIdAt(x, y) == -1)
{ {
return 0; return 0;

View File

@ -878,7 +878,7 @@ void ItemUseOutOfBattle_BlackWhiteFlute(u8 taskId)
void task08_080A1C44(u8 taskId) void task08_080A1C44(u8 taskId)
{ {
player_avatar_init_params_reset(); ResetInitialPlayerAvatarState();
sub_80B7CC8(); sub_80B7CC8();
DestroyTask(taskId); DestroyTask(taskId);
} }

View File

@ -133,7 +133,7 @@ static void ClearFrontierRecord(void)
static void WarpToTruck(void) static void WarpToTruck(void)
{ {
Overworld_SetWarpDestination(25, 40, -1, -1, -1); // inside of truck Overworld_SetWarpDestination(25, 40, -1, -1, -1); // inside of truck
warp_in(); WarpIntoMap();
} }
void Sav2_ClearSetDefault(void) void Sav2_ClearSetDefault(void)

View File

@ -1,8 +1,8 @@
#include "global.h" #include "global.h"
#include "overworld.h" #include "overworld.h"
#include "main.h"
#include "battle_setup.h" #include "battle_setup.h"
#include "berry.h" #include "berry.h"
#include "bg.h"
// #include "cable_club.h" // #include "cable_club.h"
#include "clock.h" #include "clock.h"
#include "event_data.h" #include "event_data.h"
@ -20,15 +20,18 @@
#include "field_weather.h" #include "field_weather.h"
#include "fieldmap.h" #include "fieldmap.h"
// #include "fldeff_flash.h" // #include "fldeff_flash.h"
#include "gpu_regs.h"
#include "heal_location.h" #include "heal_location.h"
#include "link.h" #include "link.h"
#include "link_rfu.h"
#include "load_save.h" #include "load_save.h"
#include "main.h" #include "main.h"
#include "malloc.h"
#include "m4a.h" #include "m4a.h"
#include "constants/maps.h"
#include "map_name_popup.h" #include "map_name_popup.h"
#include "menu.h" #include "menu.h"
#include "metatile_behavior.h" #include "metatile_behavior.h"
#include "money.h"
#include "new_game.h" #include "new_game.h"
#include "palette.h" #include "palette.h"
#include "play_time.h" #include "play_time.h"
@ -37,12 +40,11 @@
// #include "rotating_gate.h" // #include "rotating_gate.h"
#include "safari_zone.h" #include "safari_zone.h"
#include "save.h" #include "save.h"
#include "save_location.h"
#include "script.h" #include "script.h"
// #include "script_pokemon_80C4.h" // #include "script_pokemon_80C4.h"
#include "secret_base.h" #include "secret_base.h"
#include "constants/songs.h"
#include "sound.h" #include "sound.h"
#include "constants/species.h"
#include "start_menu.h" #include "start_menu.h"
#include "task.h" #include "task.h"
// #include "tileset_anim.h" // #include "tileset_anim.h"
@ -50,14 +52,11 @@
#include "tv.h" #include "tv.h"
#include "scanline_effect.h" #include "scanline_effect.h"
#include "wild_encounter.h" #include "wild_encounter.h"
#include "bg.h"
#include "money.h"
#include "save_location.h"
#include "constants/abilities.h" #include "constants/abilities.h"
#include "malloc.h"
#include "gpu_regs.h"
#include "link_rfu.h"
#include "constants/map_types.h" #include "constants/map_types.h"
#include "constants/maps.h"
#include "constants/songs.h"
#include "constants/species.h"
// event scripts // event scripts
extern const u8 EventScript_WhiteOut[]; 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 load_map_stuff(u8 *state, u32);
static bool32 map_loading_iteration_2_link(u8 *state); static bool32 map_loading_iteration_2_link(u8 *state);
static void mli4_mapscripts_and_other(void); static void mli4_mapscripts_and_other(void);
static void map_loading_lcd_reset(void); static void InitOverworldGraphicsRegisters(void);
static u8 sub_8087858(u8); static u8 sub_8087858(u8);
static u16 sub_80871C0(u32 a1); static u16 sub_80871C0(u32 a1);
static void sub_80867C8(void); 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 SetFieldVBlankCallback(void);
static void FieldClearVBlankHBlankCallbacks(void); static void FieldClearVBlankHBlankCallbacks(void);
static void sub_8085810(void); static void sub_8085810(void);
static u8 sub_808532C(struct UnkPlayerStruct *playerStruct, u16 a2, u8 a3); static u8 GetAdjustedInitialTransitionFlags(struct InitialPlayerAvatarState *playerStruct, u16 a2, u8 a3);
static u8 sub_808538C(struct UnkPlayerStruct *playerStruct, u8 a2, u16 a3, u8 a4); static u8 GetAdjustedInitialDirection(struct InitialPlayerAvatarState *playerStruct, u8 a2, u16 a3, u8 a4);
static u16 cur_mapdata_block_role_at_screen_center_acc_to_sav1(void); static u16 GetCenterScreenMetatileBehavior(void);
// IWRAM bss vars // IWRAM bss vars
IWRAM_DATA static void *sUnknown_03000E0C; IWRAM_DATA static void *sUnknown_03000E0C;
@ -259,12 +258,12 @@ IWRAM_DATA static u32 sUnusedVar;
// EWRAM vars // EWRAM vars
EWRAM_DATA static u8 sUnknown_020322D8 = 0; 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 sWarpDestination = {0}; // new warp position
EWRAM_DATA static struct WarpData sUnknown_020322EC = {0}; EWRAM_DATA static struct WarpData gFixedDiveWarp = {0};
EWRAM_DATA static struct WarpData sUnknown_020322F4 = {0}; EWRAM_DATA static struct WarpData gFixedHoleWarp = {0};
EWRAM_DATA static u16 sLastMapSectionId = 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 u16 sAmbientCrySpecies = 0;
EWRAM_DATA static bool8 sIsAmbientCryWaterMon = FALSE; EWRAM_DATA static bool8 sIsAmbientCryWaterMon = FALSE;
EWRAM_DATA struct LinkPlayerEventObject gLinkPlayerEventObjects[4] = {0}; EWRAM_DATA struct LinkPlayerEventObject gLinkPlayerEventObjects[4] = {0};
@ -291,17 +290,17 @@ static const u8 sUnusedData[] =
0x2C, 0x00, 0x00, 0x00, 0x2C, 0x00, 0x00, 0x00,
}; };
const struct UCoords32 gUnknown_08339D64[] = const struct UCoords32 gDirectionToVectors[] =
{ {
{ 0, 0}, { 0, 0}, // DIR_NONE
{ 0, 1}, { 0, 1}, // DIR_SOUTH
{ 0, -1}, { 0, -1}, // DIR_NORTH
{-1, 0}, {-1, 0}, // DIR_WEST
{ 1, 0}, { 1, 0}, // DIR_EAST
{-1, 1}, {-1, 1}, // DIR_SOUTHWEST
{ 1, 1}, { 1, 1}, // DIR_SOUTHEAST
{-1, -1}, {-1, -1}, // DIR_NORTHWEST
{ 1, -1}, { 1, -1}, // DIR_NORTHEAST
}; };
static const struct BgTemplate gUnknown_08339DAC[] = 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, (void *)REG_ADDR_WIN0H,
((DMA_ENABLE | DMA_START_HBLANK | DMA_REPEAT | DMA_DEST_RELOAD) << 16) | 1, ((DMA_ENABLE | DMA_START_HBLANK | DMA_REPEAT | DMA_DEST_RELOAD) << 16) | 1,
@ -399,12 +398,12 @@ void DoWhiteOut(void)
HealPlayerParty(); HealPlayerParty();
Overworld_ResetStateAfterWhiteOut(); Overworld_ResetStateAfterWhiteOut();
Overworld_SetWarpDestToLastHealLoc(); Overworld_SetWarpDestToLastHealLoc();
warp_in(); WarpIntoMap();
} }
void Overworld_ResetStateAfterFly(void) void Overworld_ResetStateAfterFly(void)
{ {
player_avatar_init_params_reset(); ResetInitialPlayerAvatarState();
FlagClear(FLAG_SYS_CYCLING_ROAD); FlagClear(FLAG_SYS_CYCLING_ROAD);
FlagClear(FLAG_SYS_CRUISE_MODE); FlagClear(FLAG_SYS_CRUISE_MODE);
FlagClear(FLAG_SYS_SAFARI_MODE); FlagClear(FLAG_SYS_SAFARI_MODE);
@ -414,7 +413,7 @@ void Overworld_ResetStateAfterFly(void)
void Overworld_ResetStateAfterTeleport(void) void Overworld_ResetStateAfterTeleport(void)
{ {
player_avatar_init_params_reset(); ResetInitialPlayerAvatarState();
FlagClear(FLAG_SYS_CYCLING_ROAD); FlagClear(FLAG_SYS_CYCLING_ROAD);
FlagClear(FLAG_SYS_CRUISE_MODE); FlagClear(FLAG_SYS_CRUISE_MODE);
FlagClear(FLAG_SYS_SAFARI_MODE); FlagClear(FLAG_SYS_SAFARI_MODE);
@ -425,7 +424,7 @@ void Overworld_ResetStateAfterTeleport(void)
void Overworld_ResetStateAfterDigEscRope(void) void Overworld_ResetStateAfterDigEscRope(void)
{ {
player_avatar_init_params_reset(); ResetInitialPlayerAvatarState();
FlagClear(FLAG_SYS_CYCLING_ROAD); FlagClear(FLAG_SYS_CYCLING_ROAD);
FlagClear(FLAG_SYS_CRUISE_MODE); FlagClear(FLAG_SYS_CRUISE_MODE);
FlagClear(FLAG_SYS_SAFARI_MODE); FlagClear(FLAG_SYS_SAFARI_MODE);
@ -435,7 +434,7 @@ void Overworld_ResetStateAfterDigEscRope(void)
static void Overworld_ResetStateAfterWhiteOut(void) static void Overworld_ResetStateAfterWhiteOut(void)
{ {
player_avatar_init_params_reset(); ResetInitialPlayerAvatarState();
FlagClear(FLAG_SYS_CYCLING_ROAD); FlagClear(FLAG_SYS_CYCLING_ROAD);
FlagClear(FLAG_SYS_CRUISE_MODE); FlagClear(FLAG_SYS_CRUISE_MODE);
FlagClear(FLAG_SYS_SAFARI_MODE); FlagClear(FLAG_SYS_SAFARI_MODE);
@ -574,16 +573,16 @@ const struct MapLayout *GetMapLayout(void)
void ApplyCurrentWarp(void) void ApplyCurrentWarp(void)
{ {
gUnknown_020322DC = gSaveBlock1Ptr->location; gLastUsedWarp = gSaveBlock1Ptr->location;
gSaveBlock1Ptr->location = sWarpDestination; gSaveBlock1Ptr->location = sWarpDestination;
sUnknown_020322EC = sDummyWarpData; gFixedDiveWarp = sDummyWarpData;
sUnknown_020322F4 = sDummyWarpData; gFixedHoleWarp = sDummyWarpData;
} }
void set_warp2_warp3_to_neg_1(void) void set_warp2_warp3_to_neg_1(void)
{ {
sUnknown_020322EC = sDummyWarpData; gFixedDiveWarp = sDummyWarpData;
sUnknown_020322F4 = sDummyWarpData; gFixedHoleWarp = sDummyWarpData;
} }
void SetWarpData(struct WarpData *warp, s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y) 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; warp->y = y;
} }
bool32 warp_data_is_not_neg_1(struct WarpData *warp) bool32 IsDummyWarp(struct WarpData *warp)
{ {
if (warp->mapGroup != -1) if (warp->mapGroup != -1)
return FALSE; return FALSE;
@ -616,12 +615,12 @@ struct MapHeader const *const Overworld_GetMapHeaderByGroupAndId(u16 mapGroup, u
return gMapGroups[mapGroup][mapNum]; 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); return Overworld_GetMapHeaderByGroupAndId(sWarpDestination.mapGroup, sWarpDestination.mapNum);
} }
void set_current_map_header_from_sav1_save_old_name(void) void LoadCurrentMapData(void)
{ {
sLastMapSectionId = gMapHeader.regionMapSectionId; sLastMapSectionId = gMapHeader.regionMapSectionId;
gMapHeader = *Overworld_GetMapHeaderByGroupAndId(gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum); gMapHeader = *Overworld_GetMapHeaderByGroupAndId(gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum);
@ -635,7 +634,7 @@ void LoadSaveblockMapHeader(void)
gMapHeader.mapLayout = GetMapLayout(); gMapHeader.mapLayout = GetMapLayout();
} }
void update_camera_pos_from_warpid(void) void SetPlayerCoordsFromWarp(void)
{ {
if (gSaveBlock1Ptr->location.warpId >= 0 && gSaveBlock1Ptr->location.warpId < gMapHeader.events->warpCount) 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(); ApplyCurrentWarp();
set_current_map_header_from_sav1_save_old_name(); LoadCurrentMapData();
update_camera_pos_from_warpid(); SetPlayerCoordsFromWarp();
} }
void Overworld_SetWarpDestination(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y) void Overworld_SetWarpDestination(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y)
@ -725,27 +724,27 @@ void sub_8084E14(void)
sWarpDestination = gSaveBlock1Ptr->warp4; 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) if (IsDummyWarp(&gFixedHoleWarp) == TRUE)
sWarpDestination = gUnknown_020322DC; sWarpDestination = gLastUsedWarp;
else 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) void warp1_set_to_sav1w(void)
@ -786,7 +785,7 @@ const struct MapConnection *GetMapConnection(u8 dir)
return NULL; 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); const struct MapConnection *connection = GetMapConnection(dir);
@ -797,21 +796,21 @@ bool8 sub_8084FF8(u8 dir, u16 x, u16 y)
else else
{ {
mapheader_run_script_with_tag_x6(); mapheader_run_script_with_tag_x6();
if (warp_data_is_not_neg_1(&sUnknown_020322EC)) if (IsDummyWarp(&gFixedDiveWarp))
return FALSE; return FALSE;
warp1_set_to_warp2(); SetFixedDiveWarpAsDestination();
} }
return TRUE; 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) void mliX_load_map(u8 mapGroup, u8 mapNum)
@ -823,7 +822,7 @@ void mliX_load_map(u8 mapGroup, u8 mapNum)
sub_8085810(); sub_8085810();
ApplyCurrentWarp(); ApplyCurrentWarp();
set_current_map_header_from_sav1_save_old_name(); LoadCurrentMapData();
LoadEventObjTemplatesFromHeader(); LoadEventObjTemplatesFromHeader();
TrySetMapSaveWarpStatus(); TrySetMapSaveWarpStatus();
ClearTempFieldEventData(); ClearTempFieldEventData();
@ -859,7 +858,7 @@ static void mli0_load_map(u32 a1)
bool8 v2; bool8 v2;
bool8 indoors; bool8 indoors;
set_current_map_header_from_sav1_save_old_name(); LoadCurrentMapData();
if (!(sUnknown_020322D8 & 1)) if (!(sUnknown_020322D8 & 1))
{ {
if (gMapHeader.mapLayoutId == 0x169) 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; gInitialPlayerAvatarState.direction = 1;
sUnknown_02032300.player_field_0 = 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)) if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_MACH_BIKE))
sUnknown_02032300.player_field_0 = 2; gInitialPlayerAvatarState.transitionFlags = 2;
else if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_ACRO_BIKE)) else if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_ACRO_BIKE))
sUnknown_02032300.player_field_0 = 4; gInitialPlayerAvatarState.transitionFlags = 4;
else if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_SURFING)) else if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_SURFING))
sUnknown_02032300.player_field_0 = 8; gInitialPlayerAvatarState.transitionFlags = 8;
else if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_4)) else if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_4))
sUnknown_02032300.player_field_0 = 16; gInitialPlayerAvatarState.transitionFlags = 16;
else 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(); u8 mapType = Overworld_GetMapTypeOfSaveblockLocation();
u16 v2 = cur_mapdata_block_role_at_screen_center_acc_to_sav1(); u16 metatileBehavior = GetCenterScreenMetatileBehavior();
u8 v4 = sub_808532C(&sUnknown_02032300, v2, mapType); u8 transitionFlags = GetAdjustedInitialTransitionFlags(&gInitialPlayerAvatarState, metatileBehavior, mapType);
playerStruct.player_field_0 = v4; playerStruct.transitionFlags = transitionFlags;
playerStruct.player_field_1 = sub_808538C(&sUnknown_02032300, v4, v2, mapType); playerStruct.direction = GetAdjustedInitialDirection(&gInitialPlayerAvatarState, transitionFlags, metatileBehavior, mapType);
sUnknown_02032300 = playerStruct; gInitialPlayerAvatarState = playerStruct;
return &sUnknown_02032300; 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; return 1;
else if (a3 == 5) else if (mapType == MAP_TYPE_UNDERWATER)
return 16; return 16;
else if (MetatileBehavior_IsSurfableWaterOrUnderwater(a2) == 1) else if (MetatileBehavior_IsSurfableWaterOrUnderwater(metatileBehavior) == TRUE)
return 8; return 8;
else if (Overworld_IsBikingAllowed() != TRUE) else if (Overworld_IsBikingAllowed() != TRUE)
return 1; return 1;
else if (playerStruct->player_field_0 == 2) else if (playerStruct->transitionFlags == 2)
return 2; return 2;
else if (playerStruct->player_field_0 != 4) else if (playerStruct->transitionFlags != 4)
return 1; return 1;
else else
return 4; 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; return 4;
else if (MetatileBehavior_IsDeepSouthWarp(a3) == TRUE) else if (MetatileBehavior_IsDeepSouthWarp(metatileBehavior) == TRUE)
return 2; return 2;
else if (MetatileBehavior_IsNonAnimDoor(a3) == TRUE || MetatileBehavior_IsDoor(a3) == TRUE) else if (MetatileBehavior_IsNonAnimDoor(metatileBehavior) == TRUE || MetatileBehavior_IsDoor(metatileBehavior) == TRUE)
return 1; return 1;
else if (MetatileBehavior_IsSouthArrowWarp(a3) == TRUE) else if (MetatileBehavior_IsSouthArrowWarp(metatileBehavior) == TRUE)
return 2; return 2;
else if (MetatileBehavior_IsNorthArrowWarp(a3) == TRUE) else if (MetatileBehavior_IsNorthArrowWarp(metatileBehavior) == TRUE)
return 1; return 1;
else if (MetatileBehavior_IsWestArrowWarp(a3) == TRUE) else if (MetatileBehavior_IsWestArrowWarp(metatileBehavior) == TRUE)
return 4; return 4;
else if (MetatileBehavior_IsEastArrowWarp(a3) == TRUE) else if (MetatileBehavior_IsEastArrowWarp(metatileBehavior) == TRUE)
return 3; return 3;
else if ((playerStruct->player_field_0 == 16 && a2 == 8) else if ((playerStruct->transitionFlags == 16 && transitionFlags == 8)
|| (playerStruct->player_field_0 == 8 && a2 == 16)) || (playerStruct->transitionFlags == 8 && transitionFlags == 16))
return playerStruct->player_field_1; return playerStruct->direction;
else if (MetatileBehavior_IsLadder(a3) == TRUE) else if (MetatileBehavior_IsLadder(metatileBehavior) == TRUE)
return playerStruct->player_field_1; return playerStruct->direction;
else else
return 1; 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); return MapGridGetMetatileBehaviorAt(gSaveBlock1Ptr->pos.x + 7, gSaveBlock1Ptr->pos.y + 7);
} }
@ -1231,7 +1230,7 @@ void Overworld_ChangeMusicTo(u16 newMusic)
u8 GetMapMusicFadeoutSpeed(void) u8 GetMapMusicFadeoutSpeed(void)
{ {
const struct MapHeader *mapHeader = warp1_get_mapheader(); const struct MapHeader *mapHeader = GetDestinationWarpMapHeader();
if (Overworld_MapTypeIsIndoors(mapHeader->mapType) == TRUE) if (Overworld_MapTypeIsIndoors(mapHeader->mapType) == TRUE)
return 2; return 2;
else else
@ -1257,7 +1256,7 @@ void music_something(void)
} }
} }
bool8 sub_80859A0(void) bool8 BGMusicStopped(void)
{ {
return IsNotWaitingForBGMStop(); return IsNotWaitingForBGMStop();
} }
@ -1360,7 +1359,7 @@ u8 Overworld_GetMapTypeOfSaveblockLocation(void)
u8 get_map_light_from_warp0(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) bool8 is_map_type_1_2_3_5_or_6(u8 mapType)
@ -1549,7 +1548,7 @@ void CB2_NewGame(void)
StopMapMusic(); StopMapMusic();
ResetSafariZoneFlag_(); ResetSafariZoneFlag_();
NewGameInitData(); NewGameInitData();
player_avatar_init_params_reset(); ResetInitialPlayerAvatarState();
PlayTimeCounter_Start(); PlayTimeCounter_Start();
ScriptContext1_Init(); ScriptContext1_Init();
ScriptContext2_Disable(); ScriptContext2_Disable();
@ -1571,7 +1570,7 @@ void CB2_WhiteOut(void)
StopMapMusic(); StopMapMusic();
ResetSafariZoneFlag_(); ResetSafariZoneFlag_();
DoWhiteOut(); DoWhiteOut();
player_avatar_init_params_reset(); ResetInitialPlayerAvatarState();
ScriptContext1_Init(); ScriptContext1_Init();
ScriptContext2_Disable(); ScriptContext2_Disable();
gFieldCallback = sub_80AF3C8; gFieldCallback = sub_80AF3C8;
@ -1754,7 +1753,7 @@ void CB2_ContinueSavedGame(void)
{ {
ClearSecretBase2Field_9(); ClearSecretBase2Field_9();
warp1_set_to_sav1w(); warp1_set_to_sav1w();
warp_in(); WarpIntoMap();
sub_80EDB44(); sub_80EDB44();
SetMainCallback2(CB2_LoadMap); SetMainCallback2(CB2_LoadMap);
} }
@ -1805,19 +1804,19 @@ static void VBlankCB_Field(void)
TransferTilesetAnimsBuffer(); TransferTilesetAnimsBuffer();
} }
static void sub_80863B0(void) static void InitCurrentFlashLevelScanlineEffect(void)
{ {
u8 val; u8 flashLevel;
if (sub_81A9E6C()) if (sub_81A9E6C())
{ {
door_upload_tiles(); door_upload_tiles();
ScanlineEffect_SetParams(gUnknown_08339DBC); ScanlineEffect_SetParams(sFlashEffectParams);
} }
else if ((val = Overworld_GetFlashLevel())) else if ((flashLevel = Overworld_GetFlashLevel()))
{ {
sub_80B00E8(val); sub_80B00E8(flashLevel);
ScanlineEffect_SetParams(gUnknown_08339DBC); ScanlineEffect_SetParams(sFlashEffectParams);
} }
} }
@ -1849,8 +1848,8 @@ static bool32 map_loading_iteration_3(u8 *state)
(*state)++; (*state)++;
break; break;
case 4: case 4:
sub_80863B0(); InitCurrentFlashLevelScanlineEffect();
map_loading_lcd_reset(); InitOverworldGraphicsRegisters();
sub_8197200(); sub_8197200();
(*state)++; (*state)++;
break; break;
@ -1924,8 +1923,8 @@ static bool32 load_map_stuff(u8 *state, u32 a2)
(*state)++; (*state)++;
break; break;
case 4: case 4:
sub_80863B0(); InitCurrentFlashLevelScanlineEffect();
map_loading_lcd_reset(); InitOverworldGraphicsRegisters();
sub_8197200(); sub_8197200();
(*state)++; (*state)++;
break; break;
@ -2021,8 +2020,8 @@ static bool32 map_loading_iteration_2_link(u8 *state)
(*state)++; (*state)++;
break; break;
case 3: case 3:
sub_80863B0(); InitCurrentFlashLevelScanlineEffect();
map_loading_lcd_reset(); InitOverworldGraphicsRegisters();
sub_8197200(); sub_8197200();
(*state)++; (*state)++;
break; break;
@ -2101,13 +2100,13 @@ static void sub_80867D8(void)
static void sub_8086860(void) static void sub_8086860(void)
{ {
sub_80863B0(); InitCurrentFlashLevelScanlineEffect();
map_loading_lcd_reset(); InitOverworldGraphicsRegisters();
sub_8197200(); sub_8197200();
mapdata_load_assets_to_gpu_and_full_redraw(); 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(); clear_scheduled_bg_copies_to_vram();
reset_temp_tile_data_buffers(); reset_temp_tile_data_buffers();
@ -2177,16 +2176,16 @@ static void sub_80869DC(void)
static void mli4_mapscripts_and_other(void) static void mli4_mapscripts_and_other(void)
{ {
s16 x, y; s16 x, y;
struct UnkPlayerStruct *player; struct InitialPlayerAvatarState *player;
gUnknown_03005DEC = 0; gUnknown_03005DEC = 0;
gUnknown_03005DE8 = 0; gUnknown_03005DE8 = 0;
sub_808D438(); sub_808D438();
sav1_camera_get_focus_coords(&x, &y); sav1_camera_get_focus_coords(&x, &y);
player = sub_80852D4(); player = GetInitialPlayerAvatarState();
InitPlayerAvatar(x, y, player->player_field_1, gSaveBlock2Ptr->playerGender); InitPlayerAvatar(x, y, player->direction, gSaveBlock2Ptr->playerGender);
SetPlayerAvatarTransitionFlags(player->player_field_0); SetPlayerAvatarTransitionFlags(player->transitionFlags);
player_avatar_init_params_reset(); ResetInitialPlayerAvatarState();
TrySpawnEventObjects(0, 0); TrySpawnEventObjects(0, 0);
mapheader_run_first_tag4_script_list_match(); mapheader_run_first_tag4_script_list_match();
} }
@ -2731,8 +2730,8 @@ static const u8 *sub_80873B4(struct UnkStruct_8054FF8 *a1)
return 0; return 0;
unkStruct = a1->sub; unkStruct = a1->sub;
unkStruct.x += gUnknown_08339D64[a1->d].x; unkStruct.x += gDirectionToVectors[a1->d].x;
unkStruct.y += gUnknown_08339D64[a1->d].y; unkStruct.y += gDirectionToVectors[a1->d].y;
unkStruct.height = 0; unkStruct.height = 0;
linkPlayerId = GetLinkPlayerIdAt(unkStruct.x, unkStruct.y); linkPlayerId = GetLinkPlayerIdAt(unkStruct.x, unkStruct.y);
@ -3165,12 +3164,12 @@ static void SpriteCB_LinkPlayer(struct Sprite *sprite)
SetObjectSubpriorityByZCoord(eventObj->previousElevation, sprite, 1); SetObjectSubpriorityByZCoord(eventObj->previousElevation, sprite, 1);
sprite->oam.priority = ZCoordToPriority(eventObj->previousElevation); sprite->oam.priority = ZCoordToPriority(eventObj->previousElevation);
if (!linkPlayerEventObj->mode) if (!linkPlayerEventObj->mode)
StartSpriteAnim(sprite, GetFaceDirectionAnimNum(eventObj->range.as_byte)); StartSpriteAnim(sprite, GetFaceDirectionAnimNum(eventObj->range.as_byte));
else else
StartSpriteAnimIfDifferent(sprite, GetMoveDirectionAnimNum(eventObj->range.as_byte)); StartSpriteAnimIfDifferent(sprite, GetMoveDirectionAnimNum(eventObj->range.as_byte));
UpdateEventObjectSpriteVisibility(sprite, 0); UpdateEventObjectSpriteVisibility(sprite, 0);
if (eventObj->triggerGroundEffectsOnMove) if (eventObj->triggerGroundEffectsOnMove)
{ {
sprite->invisible = ((sprite->data[7] & 4) >> 2); sprite->invisible = ((sprite->data[7] & 4) >> 2);

View File

@ -1637,7 +1637,7 @@ void sub_8014290(u16 arg0, u16 x, u16 y)
VarSet(VAR_0x4087, arg0); VarSet(VAR_0x4087, arg0);
Overworld_SetWarpDestination(gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1, x, y); 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); 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) 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(); gUnknown_03005DB4 = GetMultiplayerId();
sub_809D2BC(); sub_809D2BC();
Overworld_SetWarpDestination(mapGroup, mapNum, -1, x, y); Overworld_SetWarpDestination(mapGroup, mapNum, -1, x, y);
warp_in(); WarpIntoMap();
} }
void sub_8014384(void) void sub_8014384(void)

View File

@ -35,7 +35,7 @@ extern void CB2_ReturnToFieldContinueScriptPlayMapMusic(void);
extern void CB2_LoadMap(void); extern void CB2_LoadMap(void);
extern void sub_80AF6F0(void); extern void sub_80AF6F0(void);
extern void ScriptContext1_Stop(void); extern void ScriptContext1_Stop(void);
extern void warp_in(void); extern void WarpIntoMap(void);
extern void GetXYCoordsOneStepInFrontOfPlayer(s16* x, s16* y); extern void GetXYCoordsOneStepInFrontOfPlayer(s16* x, s16* y);
extern void PlayerGetDestCoords(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) else if (gBattleOutcome == B_OUTCOME_NO_SAFARI_BALLS)
{ {
ScriptContext2_RunNewScript(EventScript_2A4B4C); ScriptContext2_RunNewScript(EventScript_2A4B4C);
warp_in(); WarpIntoMap();
gFieldCallback = sub_80AF6F0; gFieldCallback = sub_80AF6F0;
SetMainCallback2(CB2_LoadMap); SetMainCallback2(CB2_LoadMap);
} }

View File

@ -750,7 +750,7 @@ bool8 ScrCmd_warp(struct ScriptContext *ctx)
Overworld_SetWarpDestination(mapGroup, mapNum, warpId, x, y); Overworld_SetWarpDestination(mapGroup, mapNum, warpId, x, y);
sub_80AF734(); sub_80AF734();
player_avatar_init_params_reset(); ResetInitialPlayerAvatarState();
return TRUE; return TRUE;
} }
@ -764,7 +764,7 @@ bool8 ScrCmd_warpsilent(struct ScriptContext *ctx)
Overworld_SetWarpDestination(mapGroup, mapNum, warpId, x, y); Overworld_SetWarpDestination(mapGroup, mapNum, warpId, x, y);
sp13E_warp_to_last_warp(); sp13E_warp_to_last_warp();
player_avatar_init_params_reset(); ResetInitialPlayerAvatarState();
return TRUE; return TRUE;
} }
@ -778,7 +778,7 @@ bool8 ScrCmd_warpdoor(struct ScriptContext *ctx)
Overworld_SetWarpDestination(mapGroup, mapNum, warpId, x, y); Overworld_SetWarpDestination(mapGroup, mapNum, warpId, x, y);
sub_80AF7D0(); sub_80AF7D0();
player_avatar_init_params_reset(); ResetInitialPlayerAvatarState();
return TRUE; return TRUE;
} }
@ -791,11 +791,11 @@ bool8 ScrCmd_warphole(struct ScriptContext *ctx)
PlayerGetDestCoords(&x, &y); PlayerGetDestCoords(&x, &y);
if (mapGroup == 0xFF && mapNum == 0xFF) if (mapGroup == 0xFF && mapNum == 0xFF)
sub_8084EBC(x - 7, y - 7); SetFixedHoleWarpAsDestination(x - 7, y - 7);
else else
Overworld_SetWarpDestination(mapGroup, mapNum, -1, x - 7, y - 7); Overworld_SetWarpDestination(mapGroup, mapNum, -1, x - 7, y - 7);
sp13F_fall_to_last_warp(); sp13F_fall_to_last_warp();
player_avatar_init_params_reset(); ResetInitialPlayerAvatarState();
return TRUE; return TRUE;
} }
@ -809,7 +809,7 @@ bool8 ScrCmd_warpteleport(struct ScriptContext *ctx)
Overworld_SetWarpDestination(mapGroup, mapNum, warpId, x, y); Overworld_SetWarpDestination(mapGroup, mapNum, warpId, x, y);
sub_80AF848(); sub_80AF848();
player_avatar_init_params_reset(); ResetInitialPlayerAvatarState();
return TRUE; return TRUE;
} }
@ -823,7 +823,7 @@ bool8 ScrCmd_warpD7(struct ScriptContext *ctx)
Overworld_SetWarpDestination(mapGroup, mapNum, warpId, x, y); Overworld_SetWarpDestination(mapGroup, mapNum, warpId, x, y);
sub_80AF87C(); sub_80AF87C();
player_avatar_init_params_reset(); ResetInitialPlayerAvatarState();
return TRUE; return TRUE;
} }
@ -859,7 +859,7 @@ bool8 ScrCmd_setdivewarp(struct ScriptContext *ctx)
u16 x = VarGet(ScriptReadHalfword(ctx)); u16 x = VarGet(ScriptReadHalfword(ctx));
u16 y = VarGet(ScriptReadHalfword(ctx)); u16 y = VarGet(ScriptReadHalfword(ctx));
sub_8084E2C(mapGroup, mapNum, warpId, x, y); SetFixedDiveWarp(mapGroup, mapNum, warpId, x, y);
return FALSE; return FALSE;
} }
@ -871,7 +871,7 @@ bool8 ScrCmd_setholewarp(struct ScriptContext *ctx)
u16 x = VarGet(ScriptReadHalfword(ctx)); u16 x = VarGet(ScriptReadHalfword(ctx));
u16 y = VarGet(ScriptReadHalfword(ctx)); u16 y = VarGet(ScriptReadHalfword(ctx));
sub_8084E80(mapGroup, mapNum, warpId, x, y); SetFixedHoleWarp(mapGroup, mapNum, warpId, x, y);
return FALSE; return FALSE;
} }
@ -2240,7 +2240,7 @@ bool8 ScrCmd_warpD1(struct ScriptContext *ctx)
Overworld_SetWarpDestination(mapGroup, mapNum, warpId, x, y); Overworld_SetWarpDestination(mapGroup, mapNum, warpId, x, y);
sub_808D074(GetPlayerFacingDirection()); sub_808D074(GetPlayerFacingDirection());
sub_80B0244(); sub_80B0244();
player_avatar_init_params_reset(); ResetInitialPlayerAvatarState();
return TRUE; return TRUE;
} }
@ -2293,6 +2293,6 @@ bool8 ScrCmd_warpE0(struct ScriptContext *ctx)
Overworld_SetWarpDestination(mapGroup, mapNum, warpId, x, y); Overworld_SetWarpDestination(mapGroup, mapNum, warpId, x, y);
sub_80AF79C(); sub_80AF79C();
player_avatar_init_params_reset(); ResetInitialPlayerAvatarState();
return TRUE; return TRUE;
} }

View File

@ -388,7 +388,7 @@ void sub_80E8FD0(u8 taskId)
gSaveBlock1Ptr->secretBases[secretBaseRecordId].sbr_field_10 ++; gSaveBlock1Ptr->secretBases[secretBaseRecordId].sbr_field_10 ++;
} }
sub_80E8F9C(); sub_80E8F9C();
warp_in(); WarpIntoMap();
gFieldCallback = sub_80AF168; gFieldCallback = sub_80AF168;
SetMainCallback2(CB2_LoadMap); SetMainCallback2(CB2_LoadMap);
DestroyTask(taskId); DestroyTask(taskId);
@ -446,7 +446,7 @@ void sub_80E916C(u8 taskId)
{ {
idx = sCurSecretBaseId / 10 * 4; idx = sCurSecretBaseId / 10 * 4;
Overworld_SetWarpDestination(gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1, gUnknown_0858CFE8[idx + 2], gUnknown_0858CFE8[idx + 3]); Overworld_SetWarpDestination(gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1, gUnknown_0858CFE8[idx + 2], gUnknown_0858CFE8[idx + 3]);
warp_in(); WarpIntoMap();
gFieldCallback = sub_80E9108; gFieldCallback = sub_80E9108;
SetMainCallback2(CB2_LoadMap); SetMainCallback2(CB2_LoadMap);
DestroyTask(taskId); DestroyTask(taskId);
@ -644,7 +644,7 @@ void sub_80E96A4(u8 taskId)
break; break;
case 2: case 2:
copy_saved_warp2_bank_and_enter_x_to_warp1(0x7e); copy_saved_warp2_bank_and_enter_x_to_warp1(0x7e);
warp_in(); WarpIntoMap();
gFieldCallback = mapldr_default; gFieldCallback = mapldr_default;
SetMainCallback2(CB2_LoadMap); SetMainCallback2(CB2_LoadMap);
ScriptContext2_Disable(); ScriptContext2_Disable();