diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/battle_pyramid.c | 2 | ||||
-rw-r--r-- | src/field_control_avatar.c | 2 | ||||
-rw-r--r-- | src/fieldmap.c | 6 | ||||
-rw-r--r-- | src/overworld.c | 18 | ||||
-rw-r--r-- | src/script.c | 43 | ||||
-rw-r--r-- | src/trainer_hill.c | 2 |
6 files changed, 37 insertions, 36 deletions
diff --git a/src/battle_pyramid.c b/src/battle_pyramid.c index a2fa4120f..340c17c59 100644 --- a/src/battle_pyramid.c +++ b/src/battle_pyramid.c @@ -1590,7 +1590,7 @@ void GenerateBattlePyramidFloorLayout(u16 *backupMapData, bool8 setPlayerPositio layoutMap += mapLayout->width; } } - mapheader_run_script_with_tag_x1(); + RunOnLoadMapScript(); free(floorLayoutOffsets); } diff --git a/src/field_control_avatar.c b/src/field_control_avatar.c index 00dce4c7d..cffafaf9f 100644 --- a/src/field_control_avatar.c +++ b/src/field_control_avatar.c @@ -147,7 +147,7 @@ int ProcessPlayerFieldInput(struct FieldInput *input) if (CheckForTrainersWantingBattle() == TRUE) return TRUE; - if (mapheader_run_first_tag2_script_list_match() == 1) + if (TryRunOnFrameMapScript() == TRUE) return TRUE; if (input->pressedBButton && TrySetupDiveEmergeScript() == TRUE) diff --git a/src/fieldmap.c b/src/fieldmap.c index 7d9d079fc..cf5f0356e 100644 --- a/src/fieldmap.c +++ b/src/fieldmap.c @@ -53,7 +53,7 @@ void InitMap(void) { InitMapLayoutData(&gMapHeader); sub_80E8EE0(gMapHeader.events); - mapheader_run_script_with_tag_x1(); + RunOnLoadMapScript(); } void InitMapFromSavedGame(void) @@ -62,7 +62,7 @@ void InitMapFromSavedGame(void) sub_80E9238(0); sub_80E8EE0(gMapHeader.events); LoadSavedMapView(); - mapheader_run_script_with_tag_x1(); + RunOnLoadMapScript(); UpdateTVScreensOnMap(gBackupMapLayout.width, gBackupMapLayout.height); } @@ -775,7 +775,7 @@ bool8 CameraMove(int x, int y) old_y = gSaveBlock1Ptr->pos.y; connection = sub_8088950(direction, gSaveBlock1Ptr->pos.x, gSaveBlock1Ptr->pos.y); sub_80887F8(connection, direction, x, y); - mliX_load_map(connection->mapGroup, connection->mapNum); + LoadMapFromCameraTransition(connection->mapGroup, connection->mapNum); gCamera.active = TRUE; gCamera.x = old_x - gSaveBlock1Ptr->pos.x; gCamera.y = old_y - gSaveBlock1Ptr->pos.y; diff --git a/src/overworld.c b/src/overworld.c index 08fd94c1b..d5584efc3 100644 --- a/src/overworld.c +++ b/src/overworld.c @@ -761,7 +761,7 @@ static bool8 SetDiveWarp(u8 dir, u16 x, u16 y) } else { - mapheader_run_script_with_tag_x6(); + RunOnDiveWarpMapScript(); if (IsDummyWarp(&gFixedDiveWarp)) return FALSE; SetWarpDestinationToDiveWarp(); @@ -779,7 +779,7 @@ bool8 SetDiveWarpDive(u16 x, u16 y) return SetDiveWarp(CONNECTION_DIVE, x, y); } -void mliX_load_map(u8 mapGroup, u8 mapNum) +void LoadMapFromCameraTransition(u8 mapGroup, u8 mapNum) { s32 paletteIndex; @@ -800,7 +800,7 @@ void mliX_load_map(u8 mapGroup, u8 mapNum) ChooseAmbientCrySpecies(); SetDefaultFlashLevel(); Overworld_ClearSavedMusic(); - mapheader_run_script_with_tag_x3(); + RunOnTransitionMapScript(); InitMap(); copy_map_tileset2_to_vram_2(gMapHeader.mapLayout); apply_map_tileset2_palette(gMapHeader.mapLayout); @@ -813,7 +813,7 @@ void mliX_load_map(u8 mapGroup, u8 mapNum) RoamerMove(); DoCurrentWeather(); ResetFieldTasksArgs(); - mapheader_run_script_with_tag_x5(); + RunOnResumeMapScript(); if (gMapHeader.regionMapSectionId != MAPSEC_BATTLE_FRONTIER || gMapHeader.regionMapSectionId != sLastMapSectionId) ShowMapNamePopup(); @@ -852,7 +852,7 @@ static void mli0_load_map(u32 a1) FlagClear(FLAG_SYS_USE_FLASH); SetDefaultFlashLevel(); Overworld_ClearSavedMusic(); - mapheader_run_script_with_tag_x3(); + RunOnTransitionMapScript(); UpdateLocationHistoryForRoamer(); RoamerMoveToOtherLocationSet(); if (gMapHeader.mapLayoutId == LAYOUT_BATTLE_FRONTIER_BATTLE_PYRAMID_EMPTY_SQUARE) @@ -2126,7 +2126,7 @@ static void sub_8086988(u32 a1) sub_80AEE84(); if (!a1) SetUpFieldTasks(); - mapheader_run_script_with_tag_x5(); + RunOnResumeMapScript(); TryStartMirageTowerPulseBlendEffect(); } @@ -2136,7 +2136,7 @@ static void sub_80869DC(void) gTotalCameraPixelOffsetY = 0; ResetEventObjects(); TrySpawnEventObjects(0, 0); - mapheader_run_first_tag4_script_list_match(); + TryRunOnWarpIntoMapScript(); } static void mli4_mapscripts_and_other(void) @@ -2153,14 +2153,14 @@ static void mli4_mapscripts_and_other(void) SetPlayerAvatarTransitionFlags(player->transitionFlags); ResetInitialPlayerAvatarState(); TrySpawnEventObjects(0, 0); - mapheader_run_first_tag4_script_list_match(); + TryRunOnWarpIntoMapScript(); } static void sub_8086A68(void) { sub_808E16C(0, 0); RotatingGate_InitPuzzleAndGraphics(); - mapheader_run_script_with_tag_x7(); + RunOnReturnToFieldMapScript(); } static void sub_8086A80(void) diff --git a/src/script.c b/src/script.c index c61ae7183..c95a1141f 100644 --- a/src/script.c +++ b/src/script.c @@ -2,6 +2,7 @@ #include "script.h" #include "event_data.h" #include "util.h" +#include "constants/map_scripts.h" #define RAM_SCRIPT_MAGIC 51 @@ -241,7 +242,7 @@ void ScriptContext2_RunNewScript(const u8 *ptr) while (RunScriptCommand(&sScriptContext2) == TRUE); } -u8 *mapheader_get_tagged_pointer(u8 tag) +u8 *MapHeaderGetScriptTable(u8 tag) { const u8 *mapScripts = gMapHeader.mapScripts; @@ -261,16 +262,16 @@ u8 *mapheader_get_tagged_pointer(u8 tag) } } -void mapheader_run_script_by_tag(u8 tag) +void MapHeaderRunScriptType(u8 tag) { - u8 *ptr = mapheader_get_tagged_pointer(tag); + u8 *ptr = MapHeaderGetScriptTable(tag); if (ptr) ScriptContext2_RunNewScript(ptr); } -u8 *mapheader_get_first_match_from_tagged_ptr_list(u8 tag) +u8 *MapHeaderCheckScriptTable(u8 tag) { - u8 *ptr = mapheader_get_tagged_pointer(tag); + u8 *ptr = MapHeaderGetScriptTable(tag); if (!ptr) return NULL; @@ -291,45 +292,45 @@ u8 *mapheader_get_first_match_from_tagged_ptr_list(u8 tag) } } -void mapheader_run_script_with_tag_x1(void) +void RunOnLoadMapScript(void) { - mapheader_run_script_by_tag(1); + MapHeaderRunScriptType(MAP_SCRIPT_ON_LOAD); } -void mapheader_run_script_with_tag_x3(void) +void RunOnTransitionMapScript(void) { - mapheader_run_script_by_tag(3); + MapHeaderRunScriptType(MAP_SCRIPT_ON_TRANSITION); } -void mapheader_run_script_with_tag_x5(void) +void RunOnResumeMapScript(void) { - mapheader_run_script_by_tag(5); + MapHeaderRunScriptType(MAP_SCRIPT_ON_RESUME); } -void mapheader_run_script_with_tag_x7(void) +void RunOnReturnToFieldMapScript(void) { - mapheader_run_script_by_tag(7); + MapHeaderRunScriptType(MAP_SCRIPT_ON_RETURN_TO_FIELD); } -void mapheader_run_script_with_tag_x6(void) +void RunOnDiveWarpMapScript(void) { - mapheader_run_script_by_tag(6); + MapHeaderRunScriptType(MAP_SCRIPT_ON_DIVE_WARP); } -bool8 mapheader_run_first_tag2_script_list_match(void) +bool8 TryRunOnFrameMapScript(void) { - u8 *ptr = mapheader_get_first_match_from_tagged_ptr_list(2); + u8 *ptr = MapHeaderCheckScriptTable(MAP_SCRIPT_ON_FRAME_TABLE); if (!ptr) - return 0; + return FALSE; ScriptContext1_SetupScript(ptr); - return 1; + return TRUE; } -void mapheader_run_first_tag4_script_list_match(void) +void TryRunOnWarpIntoMapScript(void) { - u8 *ptr = mapheader_get_first_match_from_tagged_ptr_list(4); + u8 *ptr = MapHeaderCheckScriptTable(MAP_SCRIPT_ON_WARP_INTO_MAP_TABLE); if (ptr) ScriptContext2_RunNewScript(ptr); } diff --git a/src/trainer_hill.c b/src/trainer_hill.c index efe11b0c7..42b196abd 100644 --- a/src/trainer_hill.c +++ b/src/trainer_hill.c @@ -796,7 +796,7 @@ void sub_81D5FB4(u16 *mapArg) dst += 31; } - mapheader_run_script_with_tag_x1(); + RunOnLoadMapScript(); FreeDataStruct(); } |