mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2025-01-13 15:13:42 +01:00
more overworld work
This commit is contained in:
parent
382442c4c8
commit
f22be4d010
@ -2156,7 +2156,7 @@ sub_80B360C: @ 80B360C
|
||||
negs r1, r1
|
||||
ands r0, r1
|
||||
str r0, [r2]
|
||||
bl call_ResetMapMusic
|
||||
bl Overworld_ResetMapMusic
|
||||
bl copy_player_party_from_sav1
|
||||
bl copy_bags_and_unk_data_to_save_blocks
|
||||
bl sub_813BF10
|
||||
|
@ -1884,8 +1884,8 @@ _080ABEF4:
|
||||
.pool
|
||||
thumb_func_end sub_80ABE18
|
||||
|
||||
thumb_func_start sub_80ABF00
|
||||
sub_80ABF00: @ 80ABF00
|
||||
thumb_func_start ApplyWeatherGammaShiftToPal
|
||||
ApplyWeatherGammaShiftToPal: @ 80ABF00
|
||||
push {lr}
|
||||
lsls r0, 24
|
||||
lsrs r0, 24
|
||||
@ -1900,7 +1900,7 @@ sub_80ABF00: @ 80ABF00
|
||||
pop {r0}
|
||||
bx r0
|
||||
.pool
|
||||
thumb_func_end sub_80ABF00
|
||||
thumb_func_end ApplyWeatherGammaShiftToPal
|
||||
|
||||
thumb_func_start sub_80ABF20
|
||||
sub_80ABF20: @ 80ABF20
|
||||
@ -10478,7 +10478,7 @@ sub_80B058C: @ 80B058C
|
||||
thumb_func_start sub_80B05B4
|
||||
sub_80B05B4: @ 80B05B4
|
||||
push {lr}
|
||||
bl sub_80859B0
|
||||
bl Overworld_FadeOutMapMusic
|
||||
ldr r0, =task50_0807F0C8
|
||||
movs r1, 0x50
|
||||
bl CreateTask
|
||||
|
@ -182,8 +182,8 @@ _0809D9EA:
|
||||
bx r0
|
||||
thumb_func_end ActivatePerStepCallback
|
||||
|
||||
thumb_func_start wild_encounter_reset_coro_args
|
||||
wild_encounter_reset_coro_args: @ 809D9F0
|
||||
thumb_func_start ResetFieldTasksArgs
|
||||
ResetFieldTasksArgs: @ 809D9F0
|
||||
push {lr}
|
||||
ldr r0, =task_per_step_callback_manager
|
||||
bl FindTaskIdByFunc
|
||||
@ -207,7 +207,7 @@ _0809DA1A:
|
||||
pop {r0}
|
||||
bx r0
|
||||
.pool
|
||||
thumb_func_end wild_encounter_reset_coro_args
|
||||
thumb_func_end ResetFieldTasksArgs
|
||||
|
||||
thumb_func_start nullsub_34
|
||||
nullsub_34: @ 809DA2C
|
||||
|
@ -9,14 +9,14 @@
|
||||
sub_80D47D4: @ 80D47D4
|
||||
push {lr}
|
||||
bl sub_80A0934
|
||||
bl AddMapNamePopUpWindowTask
|
||||
bl ShowMapNamePopup
|
||||
movs r0, 0x1
|
||||
pop {r1}
|
||||
bx r1
|
||||
thumb_func_end sub_80D47D4
|
||||
|
||||
thumb_func_start AddMapNamePopUpWindowTask
|
||||
AddMapNamePopUpWindowTask: @ 80D47E4
|
||||
thumb_func_start ShowMapNamePopup
|
||||
ShowMapNamePopup: @ 80D47E4
|
||||
push {r4,lr}
|
||||
movs r0, 0x80
|
||||
lsls r0, 7
|
||||
@ -83,7 +83,7 @@ _080D486C:
|
||||
pop {r0}
|
||||
bx r0
|
||||
.pool
|
||||
thumb_func_end AddMapNamePopUpWindowTask
|
||||
thumb_func_end ShowMapNamePopup
|
||||
|
||||
thumb_func_start Task_MapNamePopUpWindow
|
||||
Task_MapNamePopUpWindow: @ 80D487C
|
||||
|
1496
asm/overworld.s
1496
asm/overworld.s
File diff suppressed because it is too large
Load Diff
@ -483,7 +483,7 @@ gUnknown_0854FE64:: @ 854FE64
|
||||
.2byte 0x00c8, 0x0048, 0x0040, 0x0038, 0x0030, 0x0028, 0x0020, 0x0018, 0x0000, 0x0000
|
||||
|
||||
.align 2
|
||||
gUnknown_0854FE78:: @ 854FE78
|
||||
gMaxFlashLevel:: @ 854FE78
|
||||
.4byte 0x00000008
|
||||
|
||||
.align 2
|
||||
|
@ -28,7 +28,7 @@ BattleFrontier_BattlePyramidEmptySquare_EventScript_252A77:: @ 8252A77
|
||||
end
|
||||
|
||||
BattleFrontier_BattlePyramidEmptySquare_EventScript_252A8F:: @ 8252A8F
|
||||
special AddMapNamePopUpWindowTask
|
||||
special ShowMapNamePopup
|
||||
setvar VAR_0x400F, 0
|
||||
end
|
||||
|
||||
|
@ -64,7 +64,7 @@ BattleFrontier_BattlePyramidTop_EventScript_255180:: @ 8255180
|
||||
end
|
||||
|
||||
BattleFrontier_BattlePyramidTop_EventScript_25518A:: @ 825518A
|
||||
special AddMapNamePopUpWindowTask
|
||||
special ShowMapNamePopup
|
||||
setvar VAR_0x400F, 0
|
||||
end
|
||||
|
||||
|
@ -417,8 +417,8 @@ gSpecials:: @ 81DBA64
|
||||
def_special sub_813B880
|
||||
def_special sub_81A085C
|
||||
def_special ShouldTryGetTrainerScript
|
||||
def_special AddMapNamePopUpWindowTask
|
||||
def_special AddMapNamePopUpWindowTask
|
||||
def_special ShowMapNamePopup
|
||||
def_special ShowMapNamePopup
|
||||
def_special sub_81BE994
|
||||
def_special sub_81BE79C
|
||||
def_special sub_81BE7F4
|
||||
|
@ -184,7 +184,7 @@
|
||||
#define VAR_0x40B0 0x40B0
|
||||
#define VAR_0x40B1 0x40B1
|
||||
#define VAR_0x40B2 0x40B2
|
||||
#define VAR_0x40B3 0x40B3
|
||||
#define VAR_WEATHER_INSTITUTE_STATE 0x40B3
|
||||
#define VAR_PORTHOLE 0x40B4
|
||||
#define VAR_0x40B5 0x40B5
|
||||
#define VAR_0x40B6 0x40B6
|
||||
|
@ -620,10 +620,10 @@ struct SaveBlock1
|
||||
/*0x14*/ struct WarpData warp2;
|
||||
/*0x1C*/ struct WarpData lastHealLocation;
|
||||
/*0x24*/ struct WarpData warp4;
|
||||
/*0x2C*/ u16 battleMusic;
|
||||
/*0x2C*/ u16 savedMusic;
|
||||
/*0x2E*/ u8 weather;
|
||||
/*0x2F*/ u8 filler_2F;
|
||||
/*0x30*/ u8 flashUsed;
|
||||
/*0x30*/ u8 flashLevel;
|
||||
/*0x32*/ u16 mapDataId;
|
||||
/*0x34*/ u16 mapView[0x100];
|
||||
/*0x234*/ u8 playerPartyCount;
|
||||
|
@ -63,6 +63,14 @@ void sub_8084D5C(s16 a1, s16 a2);
|
||||
void sub_8084DD4(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y);
|
||||
|
||||
// to erase later
|
||||
bool32 Overworld_IsBikingAllowed(void);
|
||||
u8 sub_808532C(struct UnkPlayerStruct *playerStruct, u16 a2, u8 a3);
|
||||
u8 sub_808538C(struct UnkPlayerStruct *playerStruct, u8 a2, u16 a3, u8 a4);
|
||||
u16 cur_mapdata_block_role_at_screen_center_acc_to_sav1(void);
|
||||
bool8 Overworld_MapTypeIsIndoors(u8 mapType);
|
||||
void SetDefaultFlashLevel(void);
|
||||
void Overworld_ClearSavedMusic(void);
|
||||
void sub_8085810(void);
|
||||
u8 GetMapTypeByGroupAndId(s8 mapGroup, s8 mapNum);
|
||||
u8 Overworld_GetMapTypeOfSaveblockLocation(void);
|
||||
void Overworld_SetMapObjTemplateCoords(u8, s16, s16);
|
||||
|
@ -45,7 +45,7 @@ extern void ItemUseOutOfBattle_EvolutionStone(u8 b);
|
||||
extern void bag_menu_mail_related(void);
|
||||
extern void OpenPokeblockCase(u8 a, void(*b)(void));
|
||||
extern void overworld_free_bg_tilemaps(void);
|
||||
extern bool32 sav1_map_is_biking_allowed(void);
|
||||
extern bool32 Overworld_IsBikingAllowed(void);
|
||||
extern bool8 IsPlayerFacingSurfableFishableWater(void);
|
||||
extern bool8 sub_81221AC(void);
|
||||
extern u8 gText_ItemFinderNothing[];
|
||||
@ -236,7 +236,7 @@ void ItemUseOutOfBattle_Bike(u8 taskId)
|
||||
DisplayCannotDismountBikeMessage(taskId, data[3]);
|
||||
else
|
||||
{
|
||||
if (sav1_map_is_biking_allowed() == TRUE && IsBikingDisallowedByPlayer() == 0)
|
||||
if (Overworld_IsBikingAllowed() == TRUE && IsBikingDisallowedByPlayer() == 0)
|
||||
{
|
||||
gUnknown_0203A0F4 = ItemUseOnFieldCB_Bike;
|
||||
SetUpItemUseOnFieldCallback(taskId);
|
||||
|
575
src/overworld.c
575
src/overworld.c
@ -52,6 +52,7 @@
|
||||
#include "wild_encounter.h"
|
||||
#include "bg.h"
|
||||
#include "money.h"
|
||||
#include "save_location.h"
|
||||
|
||||
// event scripts
|
||||
extern const u8 EventScript_WhiteOut[];
|
||||
@ -60,7 +61,7 @@ extern const u8 EventScript_271862[];
|
||||
// vars
|
||||
extern struct MapData *const gMapAttributes[];
|
||||
extern struct MapHeader *const *const gMapGroups[];
|
||||
extern s32 gMaxFlashLevel;
|
||||
extern const s32 gMaxFlashLevel;
|
||||
|
||||
// functions
|
||||
extern void HealPlayerParty(void);
|
||||
@ -71,6 +72,22 @@ extern void copy_map_tileset1_tileset2_to_vram(struct MapData *);
|
||||
extern void apply_map_tileset1_tileset2_palette(struct MapData *);
|
||||
extern void ResetCyclingRoadChallengeData(void);
|
||||
extern void ApplyNewEncryptionKeyToWord(u32 *word, u32 newKey);
|
||||
extern void mapheader_run_script_with_tag_x5(void);
|
||||
extern void ResetFieldTasksArgs(void);
|
||||
extern void sub_80A0A2C(void);
|
||||
extern void not_trainer_hill_battle_pyramid(void);
|
||||
extern void apply_map_tileset2_palette(struct MapData *);
|
||||
extern void copy_map_tileset2_to_vram_2(struct MapData *);
|
||||
extern void prev_quest_postbuffer_cursor_backup_reset(void);
|
||||
extern void ShowMapNamePopup(void);
|
||||
extern bool32 InTrainerHill(void);
|
||||
extern void sub_81AA1D8(void);
|
||||
extern void sub_81D5DF8(void);
|
||||
extern void sub_80EB218(void);
|
||||
extern void trainer_hill_map_load_related(void);
|
||||
extern void battle_pyramid_map_load_related(u8);
|
||||
extern void UpdateTVScreensOnMap(u32, u32);
|
||||
extern void sub_80E9238(u8);
|
||||
|
||||
// this file's functions
|
||||
static void Overworld_ResetStateAfterWhiteOut(void);
|
||||
@ -85,15 +102,16 @@ IWRAM_DATA u8 gUnknown_03000E19;
|
||||
IWRAM_DATA void *rom4_c_unused_03000e1c;
|
||||
|
||||
// EWRAM vars
|
||||
EWRAM_DATA u8 gUnknown_020322D8 = 0;
|
||||
EWRAM_DATA struct WarpData gUnknown_020322DC = {0};
|
||||
EWRAM_DATA struct WarpData gWarpDestination = {0}; // new warp position
|
||||
EWRAM_DATA struct WarpData gUnknown_020322EC = {0};
|
||||
EWRAM_DATA struct WarpData gUnknown_020322F4 = {0};
|
||||
EWRAM_DATA u16 gLastMapSectionId = 0;
|
||||
// EWRAM_DATA struct UnkPlayerStruct gUnknown_02029810 = {0};
|
||||
// EWRAM_DATA u16 sAmbientCrySpecies = 0;
|
||||
// EWRAM_DATA bool8 sIsAmbientCryWaterMon = FALSE;
|
||||
// EWRAM_DATA struct LinkPlayerMapObject gLinkPlayerMapObjects[4] = {0};
|
||||
EWRAM_DATA struct UnkPlayerStruct gUnknown_02032300 = {0};
|
||||
EWRAM_DATA u16 sAmbientCrySpecies = 0;
|
||||
EWRAM_DATA bool8 sIsAmbientCryWaterMon = FALSE;
|
||||
EWRAM_DATA struct LinkPlayerMapObject gLinkPlayerMapObjects[4] = {0};
|
||||
|
||||
// const rom data
|
||||
const struct WarpData sDummyWarpData =
|
||||
@ -544,3 +562,550 @@ void sub_8084DD4(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y)
|
||||
{
|
||||
SetWarpData(&gSaveBlock1Ptr->warp4, mapGroup, mapNum, warpId, x, y);
|
||||
}
|
||||
|
||||
void sub_8084E14(void)
|
||||
{
|
||||
gWarpDestination = gSaveBlock1Ptr->warp4;
|
||||
}
|
||||
|
||||
void sub_8084E2C(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y)
|
||||
{
|
||||
SetWarpData(&gUnknown_020322EC, mapGroup, mapNum, warpId, x, y);
|
||||
}
|
||||
|
||||
void warp1_set_to_warp2(void)
|
||||
{
|
||||
gWarpDestination = gUnknown_020322EC;
|
||||
}
|
||||
|
||||
void sub_8084E80(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y)
|
||||
{
|
||||
SetWarpData(&gUnknown_020322F4, mapGroup, mapNum, warpId, x, y);
|
||||
}
|
||||
|
||||
void sub_8084EBC(s16 x, s16 y)
|
||||
{
|
||||
if (warp_data_is_not_neg_1(&gUnknown_020322F4) == TRUE)
|
||||
{
|
||||
gWarpDestination = gUnknown_020322DC;
|
||||
}
|
||||
else
|
||||
{
|
||||
Overworld_SetWarpDestination(gUnknown_020322F4.mapGroup, gUnknown_020322F4.mapNum, -1, x, y);
|
||||
}
|
||||
}
|
||||
|
||||
void warp1_set_to_sav1w(void)
|
||||
{
|
||||
gWarpDestination = gSaveBlock1Ptr->warp1;
|
||||
}
|
||||
|
||||
void sub_8084F2C(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y)
|
||||
{
|
||||
SetWarpData(&gSaveBlock1Ptr->warp1, mapGroup, mapNum, warpId, x, y);
|
||||
}
|
||||
|
||||
void sub_8084F6C(u8 a1)
|
||||
{
|
||||
const struct HealLocation *warp = GetHealLocationPointer(a1);
|
||||
if (warp)
|
||||
SetWarpData(&gSaveBlock1Ptr->warp1, warp->group, warp->map, -1, warp->x, warp->y);
|
||||
}
|
||||
|
||||
void sub_8084FAC(void)
|
||||
{
|
||||
gSaveBlock1Ptr->warp1 = gSaveBlock1Ptr->warp2;
|
||||
}
|
||||
|
||||
struct MapConnection *GetMapConnection(u8 dir)
|
||||
{
|
||||
s32 i;
|
||||
s32 count = gMapHeader.connections->count;
|
||||
struct MapConnection *connection = gMapHeader.connections->connections;
|
||||
|
||||
if (connection == NULL)
|
||||
return NULL;
|
||||
|
||||
for(i = 0; i < count; i++, connection++)
|
||||
if (connection->direction == dir)
|
||||
return connection;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool8 sub_8084FF8(u8 dir, u16 x, u16 y)
|
||||
{
|
||||
struct MapConnection *connection = GetMapConnection(dir);
|
||||
|
||||
if (connection != NULL)
|
||||
{
|
||||
Overworld_SetWarpDestination(connection->mapGroup, connection->mapNum, -1, x, y);
|
||||
}
|
||||
else
|
||||
{
|
||||
mapheader_run_script_with_tag_x6();
|
||||
if (warp_data_is_not_neg_1(&gUnknown_020322EC))
|
||||
return FALSE;
|
||||
warp1_set_to_warp2();
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool8 sub_8085058(u16 x, u16 y)
|
||||
{
|
||||
return sub_8084FF8(CONNECTION_EMERGE, x, y);
|
||||
}
|
||||
|
||||
bool8 sub_8085078(u16 x, u16 y)
|
||||
{
|
||||
return sub_8084FF8(CONNECTION_DIVE, x, y);
|
||||
}
|
||||
|
||||
void mliX_load_map(u8 mapGroup, u8 mapNum)
|
||||
{
|
||||
s32 paletteIndex;
|
||||
|
||||
Overworld_SetWarpDestination(mapGroup, mapNum, -1, -1, -1);
|
||||
if (gMapHeader.regionMapSectionId != 0x3A)
|
||||
sub_8085810();
|
||||
|
||||
ApplyCurrentWarp();
|
||||
set_current_map_header_from_sav1_save_old_name();
|
||||
LoadMapObjTemplatesFromHeader();
|
||||
TrySetMapSaveWarpStatus();
|
||||
ClearTempFieldEventData();
|
||||
ResetCyclingRoadChallengeData();
|
||||
prev_quest_postbuffer_cursor_backup_reset();
|
||||
TryUpdateRandomTrainerRematches(mapGroup, mapNum);
|
||||
DoTimeBasedEvents();
|
||||
SetSav1WeatherFromCurrMapHeader();
|
||||
ChooseAmbientCrySpecies();
|
||||
SetDefaultFlashLevel();
|
||||
Overworld_ClearSavedMusic();
|
||||
mapheader_run_script_with_tag_x3();
|
||||
not_trainer_hill_battle_pyramid();
|
||||
copy_map_tileset2_to_vram_2(gMapHeader.mapData);
|
||||
apply_map_tileset2_palette(gMapHeader.mapData);
|
||||
|
||||
for (paletteIndex = 6; paletteIndex < 13; paletteIndex++)
|
||||
ApplyWeatherGammaShiftToPal(paletteIndex);
|
||||
|
||||
sub_80A0A2C();
|
||||
UpdateLocationHistoryForRoamer();
|
||||
RoamerMove();
|
||||
DoCurrentWeather();
|
||||
ResetFieldTasksArgs();
|
||||
mapheader_run_script_with_tag_x5();
|
||||
|
||||
if (gMapHeader.regionMapSectionId != 0x3A || gMapHeader.regionMapSectionId != gLastMapSectionId)
|
||||
ShowMapNamePopup();
|
||||
}
|
||||
|
||||
void mli0_load_map(u32 a1)
|
||||
{
|
||||
bool8 v2;
|
||||
bool8 indoors;
|
||||
|
||||
set_current_map_header_from_sav1_save_old_name();
|
||||
if (!(gUnknown_020322D8 & 1))
|
||||
{
|
||||
if (gMapHeader.mapDataId == 0x169)
|
||||
sub_81AA1D8();
|
||||
else if (InTrainerHill())
|
||||
sub_81D5DF8();
|
||||
else
|
||||
LoadMapObjTemplatesFromHeader();
|
||||
}
|
||||
|
||||
v2 = is_light_level_1_2_3_5_or_6(gMapHeader.mapType);
|
||||
indoors = Overworld_MapTypeIsIndoors(gMapHeader.mapType);
|
||||
|
||||
sub_80EB218();
|
||||
TrySetMapSaveWarpStatus();
|
||||
ClearTempFieldEventData();
|
||||
ResetCyclingRoadChallengeData();
|
||||
prev_quest_postbuffer_cursor_backup_reset();
|
||||
TryUpdateRandomTrainerRematches(gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum);
|
||||
if (a1 != 1)
|
||||
DoTimeBasedEvents();
|
||||
SetSav1WeatherFromCurrMapHeader();
|
||||
ChooseAmbientCrySpecies();
|
||||
if (v2)
|
||||
FlagClear(FLAG_SYS_USE_FLASH);
|
||||
SetDefaultFlashLevel();
|
||||
Overworld_ClearSavedMusic();
|
||||
mapheader_run_script_with_tag_x3();
|
||||
UpdateLocationHistoryForRoamer();
|
||||
RoamerMoveToOtherLocationSet();
|
||||
if (gMapHeader.mapDataId == 0x169)
|
||||
battle_pyramid_map_load_related(0);
|
||||
else if (InTrainerHill())
|
||||
trainer_hill_map_load_related();
|
||||
else
|
||||
not_trainer_hill_battle_pyramid();
|
||||
|
||||
if (a1 != 1 && indoors)
|
||||
{
|
||||
UpdateTVScreensOnMap(gUnknown_03005DC0.width, gUnknown_03005DC0.height);
|
||||
sub_80E9238(1);
|
||||
}
|
||||
}
|
||||
|
||||
void player_avatar_init_params_reset(void)
|
||||
{
|
||||
gUnknown_02032300.player_field_1 = 1;
|
||||
gUnknown_02032300.player_field_0 = 1;
|
||||
}
|
||||
|
||||
void walkrun_find_lowest_active_bit_in_bitfield(void)
|
||||
{
|
||||
gUnknown_02032300.player_field_1 = player_get_direction_lower_nybble();
|
||||
|
||||
if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_MACH_BIKE))
|
||||
gUnknown_02032300.player_field_0 = 2;
|
||||
else if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_ACRO_BIKE))
|
||||
gUnknown_02032300.player_field_0 = 4;
|
||||
else if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_SURFING))
|
||||
gUnknown_02032300.player_field_0 = 8;
|
||||
else if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_4))
|
||||
gUnknown_02032300.player_field_0 = 16;
|
||||
else
|
||||
gUnknown_02032300.player_field_0 = 1;
|
||||
}
|
||||
|
||||
struct UnkPlayerStruct *sub_80852D4(void)
|
||||
{
|
||||
struct UnkPlayerStruct playerStruct;
|
||||
u8 mapType = Overworld_GetMapTypeOfSaveblockLocation();
|
||||
u16 v2 = cur_mapdata_block_role_at_screen_center_acc_to_sav1();
|
||||
u8 v4 = sub_808532C(&gUnknown_02032300, v2, mapType);
|
||||
playerStruct.player_field_0 = v4;
|
||||
playerStruct.player_field_1 = sub_808538C(&gUnknown_02032300, v4, v2, mapType);
|
||||
gUnknown_02032300 = playerStruct;
|
||||
return &gUnknown_02032300;
|
||||
}
|
||||
|
||||
u8 sub_808532C(struct UnkPlayerStruct *playerStruct, u16 a2, u8 a3)
|
||||
{
|
||||
if (a3 != 8 && FlagGet(FLAG_SYS_CRUISE_MODE))
|
||||
return 1;
|
||||
if (a3 == 5)
|
||||
return 16;
|
||||
if (MetatileBehavior_IsSurfableWaterOrUnderwater(a2) == 1)
|
||||
return 8;
|
||||
if (Overworld_IsBikingAllowed() != TRUE)
|
||||
return 1;
|
||||
if (playerStruct->player_field_0 == 2)
|
||||
return 2;
|
||||
if (playerStruct->player_field_0 != 4)
|
||||
return 1;
|
||||
return 4;
|
||||
}
|
||||
|
||||
u8 sub_808538C(struct UnkPlayerStruct *playerStruct, u8 a2, u16 a3, u8 a4)
|
||||
{
|
||||
if (FlagGet(FLAG_SYS_CRUISE_MODE) && a4 == 6)
|
||||
return 4;
|
||||
if (MetatileBehavior_IsDeepSouthWarp(a3) == TRUE)
|
||||
return 2;
|
||||
if (MetatileBehavior_IsNonAnimDoor(a3) == TRUE || MetatileBehavior_IsDoor(a3) == TRUE)
|
||||
return 1;
|
||||
if (MetatileBehavior_IsSouthArrowWarp(a3) == TRUE)
|
||||
return 2;
|
||||
if (MetatileBehavior_IsNorthArrowWarp(a3) == TRUE)
|
||||
return 1;
|
||||
if (MetatileBehavior_IsWestArrowWarp(a3) == TRUE)
|
||||
return 4;
|
||||
if (MetatileBehavior_IsEastArrowWarp(a3) == TRUE)
|
||||
return 3;
|
||||
if ((playerStruct->player_field_0 == 16 && a2 == 8)
|
||||
|| (playerStruct->player_field_0 == 8 && a2 == 16))
|
||||
return playerStruct->player_field_1;
|
||||
if (MetatileBehavior_IsLadder(a3) == TRUE)
|
||||
return playerStruct->player_field_1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
u16 cur_mapdata_block_role_at_screen_center_acc_to_sav1(void)
|
||||
{
|
||||
return MapGridGetMetatileBehaviorAt(gSaveBlock1Ptr->pos.x + 7, gSaveBlock1Ptr->pos.y + 7);
|
||||
}
|
||||
|
||||
bool32 Overworld_IsBikingAllowed(void)
|
||||
{
|
||||
if (!(gMapHeader.flags & 1))
|
||||
return FALSE;
|
||||
else
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void SetDefaultFlashLevel(void)
|
||||
{
|
||||
if (!gMapHeader.cave)
|
||||
gSaveBlock1Ptr->flashLevel = 0;
|
||||
else if (FlagGet(FLAG_SYS_USE_FLASH))
|
||||
gSaveBlock1Ptr->flashLevel = 1;
|
||||
else
|
||||
gSaveBlock1Ptr->flashLevel = gMaxFlashLevel - 1;
|
||||
}
|
||||
|
||||
void Overworld_SetFlashLevel(s32 flashLevel)
|
||||
{
|
||||
if (flashLevel < 0 || flashLevel > gMaxFlashLevel)
|
||||
flashLevel = 0;
|
||||
gSaveBlock1Ptr->flashLevel = flashLevel;
|
||||
}
|
||||
|
||||
u8 Overworld_GetFlashLevel(void)
|
||||
{
|
||||
return gSaveBlock1Ptr->flashLevel;
|
||||
}
|
||||
|
||||
void sub_8085524(u16 mapDataId)
|
||||
{
|
||||
gSaveBlock1Ptr->mapDataId = mapDataId;
|
||||
gMapHeader.mapData = get_mapdata_header();
|
||||
}
|
||||
|
||||
void sub_8085540(u8 var)
|
||||
{
|
||||
gUnknown_020322D8 = var;
|
||||
}
|
||||
|
||||
u8 sub_808554C(void)
|
||||
{
|
||||
return gUnknown_020322D8;
|
||||
}
|
||||
|
||||
bool16 ShouldLegendaryMusicPlayAtLocation(struct WarpData *warp)
|
||||
{
|
||||
if (!FlagGet(FLAG_SYS_WEATHER_CTRL))
|
||||
return FALSE;
|
||||
if (warp->mapGroup == 0)
|
||||
{
|
||||
switch (warp->mapNum)
|
||||
{
|
||||
case MAP_NUM(LILYCOVE_CITY):
|
||||
case MAP_NUM(MOSSDEEP_CITY):
|
||||
case MAP_NUM(SOOTOPOLIS_CITY):
|
||||
case MAP_NUM(EVER_GRANDE_CITY):
|
||||
case MAP_NUM(ROUTE124):
|
||||
case MAP_NUM(ROUTE125):
|
||||
case MAP_NUM(ROUTE126):
|
||||
case MAP_NUM(ROUTE127):
|
||||
case MAP_NUM(ROUTE128):
|
||||
return TRUE;
|
||||
default:
|
||||
if (VarGet(VAR_0x405E) < 4)
|
||||
return FALSE;
|
||||
switch (warp->mapNum)
|
||||
{
|
||||
case MAP_NUM(ROUTE129):
|
||||
case MAP_NUM(ROUTE130):
|
||||
case MAP_NUM(ROUTE131):
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool16 NoMusicInSotopolisWithLegendaries(struct WarpData *warp)
|
||||
{
|
||||
if (VarGet(VAR_0x40CA) != 1)
|
||||
return FALSE;
|
||||
if (warp->mapGroup != MAP_GROUP(SOOTOPOLIS_CITY))
|
||||
return FALSE;
|
||||
if (warp->mapNum == MAP_NUM(SOOTOPOLIS_CITY))
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool16 IsInfiltratedWeatherInstitute(struct WarpData *warp)
|
||||
{
|
||||
if (VarGet(VAR_WEATHER_INSTITUTE_STATE))
|
||||
return FALSE;
|
||||
if (warp->mapGroup != MAP_GROUP(ROUTE119_WEATHER_INSTITUTE_1F))
|
||||
return FALSE;
|
||||
if (warp->mapNum == MAP_NUM(ROUTE119_WEATHER_INSTITUTE_1F)
|
||||
|| warp->mapNum == MAP_NUM(ROUTE119_WEATHER_INSTITUTE_2F))
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool16 IsInflitratedSpaceCenter(struct WarpData *warp)
|
||||
{
|
||||
if (VarGet(VAR_0x405D) == 0)
|
||||
return FALSE;
|
||||
if (VarGet(VAR_0x405D) > 2)
|
||||
return FALSE;
|
||||
if (warp->mapGroup != MAP_GROUP(MOSSDEEP_CITY_SPACE_CENTER_1F))
|
||||
return FALSE;
|
||||
if (warp->mapNum == MAP_NUM(MOSSDEEP_CITY_SPACE_CENTER_1F)
|
||||
|| warp->mapNum == MAP_NUM(MOSSDEEP_CITY_SPACE_CENTER_2F))
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
u16 GetLocationMusic(struct WarpData *warp)
|
||||
{
|
||||
if (NoMusicInSotopolisWithLegendaries(warp) == TRUE)
|
||||
return 0xFFFF;
|
||||
else if (ShouldLegendaryMusicPlayAtLocation(warp) == TRUE)
|
||||
return MUS_OOAME;
|
||||
else if (IsInflitratedSpaceCenter(warp) == TRUE)
|
||||
return MUS_MGM0;
|
||||
else if (IsInfiltratedWeatherInstitute(warp) == TRUE)
|
||||
return MUS_TOZAN;
|
||||
else
|
||||
return Overworld_GetMapHeaderByGroupAndId(warp->mapGroup, warp->mapNum)->music;
|
||||
}
|
||||
|
||||
u16 GetCurrLocationDefaultMusic(void)
|
||||
{
|
||||
u16 music;
|
||||
|
||||
// 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)
|
||||
return MUS_ASHROAD;
|
||||
|
||||
music = GetLocationMusic(&gSaveBlock1Ptr->location);
|
||||
if (music != 0x7FFF)
|
||||
{
|
||||
return music;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (gSaveBlock1Ptr->pos.x < 24)
|
||||
return MUS_DOORO_X1;
|
||||
else
|
||||
return MUS_GRANROAD;
|
||||
}
|
||||
}
|
||||
|
||||
u16 GetWarpDestinationMusic(void)
|
||||
{
|
||||
u16 music = GetLocationMusic(&gWarpDestination);
|
||||
if (music != 0x7FFF)
|
||||
{
|
||||
return music;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(MAUVILLE_CITY)
|
||||
&& gSaveBlock1Ptr->location.mapNum == MAP_NUM(MAUVILLE_CITY))
|
||||
return MUS_DOORO_X1;
|
||||
else
|
||||
return MUS_GRANROAD;
|
||||
}
|
||||
}
|
||||
|
||||
void Overworld_ResetMapMusic(void)
|
||||
{
|
||||
ResetMapMusic();
|
||||
}
|
||||
|
||||
void Overworld_PlaySpecialMapMusic(void)
|
||||
{
|
||||
u16 music = GetCurrLocationDefaultMusic();
|
||||
|
||||
if (music != MUS_OOAME && music != 0xFFFF)
|
||||
{
|
||||
if (gSaveBlock1Ptr->savedMusic)
|
||||
music = gSaveBlock1Ptr->savedMusic;
|
||||
else if (Overworld_GetMapTypeOfSaveblockLocation() == MAP_TYPE_UNDERWATER)
|
||||
music = MUS_DEEPDEEP;
|
||||
else if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_SURFING))
|
||||
music = MUS_NAMINORI;
|
||||
}
|
||||
|
||||
if (music != GetCurrentMapMusic())
|
||||
PlayNewMapMusic(music);
|
||||
}
|
||||
|
||||
void Overworld_SetSavedMusic(u16 songNum)
|
||||
{
|
||||
gSaveBlock1Ptr->savedMusic = songNum;
|
||||
}
|
||||
|
||||
void Overworld_ClearSavedMusic(void)
|
||||
{
|
||||
gSaveBlock1Ptr->savedMusic = 0;
|
||||
}
|
||||
|
||||
void sub_8085810(void)
|
||||
{
|
||||
if (FlagGet(FLAG_SPECIAL_FLAG_0x4001) != TRUE)
|
||||
{
|
||||
u16 newMusic = GetWarpDestinationMusic();
|
||||
u16 currentMusic = GetCurrentMapMusic();
|
||||
if (newMusic != MUS_OOAME && newMusic != 0xFFFF)
|
||||
{
|
||||
if (currentMusic == MUS_DEEPDEEP || currentMusic == MUS_NAMINORI)
|
||||
return;
|
||||
if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_SURFING))
|
||||
newMusic = MUS_NAMINORI;
|
||||
}
|
||||
if (newMusic != currentMusic)
|
||||
{
|
||||
if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_MACH_BIKE | PLAYER_AVATAR_FLAG_ACRO_BIKE))
|
||||
FadeOutAndFadeInNewMapMusic(newMusic, 4, 4);
|
||||
else
|
||||
FadeOutAndPlayNewMapMusic(newMusic, 8);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Overworld_ChangeMusicToDefault(void)
|
||||
{
|
||||
u16 currentMusic = GetCurrentMapMusic();
|
||||
if (currentMusic != GetCurrLocationDefaultMusic())
|
||||
FadeOutAndPlayNewMapMusic(GetCurrLocationDefaultMusic(), 8);
|
||||
}
|
||||
|
||||
void Overworld_ChangeMusicTo(u16 newMusic)
|
||||
{
|
||||
u16 currentMusic = GetCurrentMapMusic();
|
||||
if (currentMusic != newMusic && currentMusic != MUS_OOAME)
|
||||
FadeOutAndPlayNewMapMusic(newMusic, 8);
|
||||
}
|
||||
|
||||
u8 GetMapMusicFadeoutSpeed(void)
|
||||
{
|
||||
struct MapHeader *mapHeader = warp1_get_mapheader();
|
||||
if (Overworld_MapTypeIsIndoors(mapHeader->mapType) == TRUE)
|
||||
return 2;
|
||||
else
|
||||
return 4;
|
||||
}
|
||||
|
||||
void music_something(void)
|
||||
{
|
||||
u16 currentMusic = GetCurrentMapMusic();
|
||||
u16 warpMusic = GetWarpDestinationMusic();
|
||||
if (FlagGet(FLAG_SPECIAL_FLAG_0x4001) != TRUE && warpMusic != GetCurrentMapMusic())
|
||||
{
|
||||
if (currentMusic == MUS_NAMINORI
|
||||
&& VarGet(VAR_0x40CA) == 2
|
||||
&& gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(SOOTOPOLIS_CITY)
|
||||
&& gSaveBlock1Ptr->location.mapNum == MAP_NUM(SOOTOPOLIS_CITY)
|
||||
&& gWarpDestination.mapGroup == MAP_GROUP(SOOTOPOLIS_CITY)
|
||||
&& gWarpDestination.mapNum == MAP_NUM(SOOTOPOLIS_CITY)
|
||||
&& gWarpDestination.x == 0x1D
|
||||
&& gWarpDestination.y == 0x35)
|
||||
return;
|
||||
FadeOutMapMusic(GetMapMusicFadeoutSpeed());
|
||||
}
|
||||
}
|
||||
|
||||
bool8 sub_80859A0(void)
|
||||
{
|
||||
return IsNotWaitingForBGMStop();
|
||||
}
|
||||
|
||||
void Overworld_FadeOutMapMusic(void)
|
||||
{
|
||||
FadeOutMapMusic(4);
|
||||
}
|
||||
|
@ -211,24 +211,8 @@ gDifferentSaveFile: @ 20322D4
|
||||
gUnknown_020322D5: @ 20322D5
|
||||
.space 0x3
|
||||
|
||||
gUnknown_020322D8: @ 20322D8
|
||||
.space 0x4
|
||||
|
||||
.include "src/overworld.o"
|
||||
|
||||
.align 2
|
||||
gUnknown_02032300: @ 2032300
|
||||
.space 0x4
|
||||
|
||||
gUnknown_02032304: @ 2032304
|
||||
.space 0x2
|
||||
|
||||
gUnknown_02032306: @ 2032306
|
||||
.space 0x2
|
||||
|
||||
gLinkPlayerMapObjects: @ 2032308
|
||||
.space 0x10
|
||||
|
||||
gUnknown_02032318: @ 2032318
|
||||
.space 0x5000
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user