From 1435c96b41049da3a05ed97d9a07b355aacbac4f Mon Sep 17 00:00:00 2001 From: Slawter666 <38655737+Slawter666@users.noreply.github.com> Date: Wed, 17 Oct 2018 01:11:44 +0100 Subject: [PATCH] Further synchronisation --- asm/field_control_avatar.s | 10 ++--- asm/field_screen.s | 2 +- asm/fldeff_80F9BCC.s | 16 +++---- data/event_scripts.s | 2 +- data/specials.inc | 2 +- include/event_object_movement.h | 2 +- include/field_control_avatar.h | 2 +- include/field_effect.h | 4 +- include/field_poison.h | 4 +- include/fldeff_80F9BCC.h | 2 +- include/global.fieldmap.h | 16 +++---- include/overworld.h | 16 +++---- src/bike.c | 2 +- src/event_object_movement.c | 10 ++--- src/field_effect.c | 45 +++++++++---------- src/field_player_avatar.c | 2 +- src/field_poison.c | 65 ++++++++++++++-------------- src/field_specials.c | 4 +- src/fldeff_flash.c | 2 +- src/item_use.c | 6 +-- src/overworld.c | 76 ++++++++++++++++----------------- src/rom6.c | 21 ++++----- src/time_events.c | 2 +- 23 files changed, 158 insertions(+), 155 deletions(-) diff --git a/asm/field_control_avatar.s b/asm/field_control_avatar.s index c299d6633..65e8ed8b4 100644 --- a/asm/field_control_avatar.s +++ b/asm/field_control_avatar.s @@ -178,9 +178,9 @@ _0809C006: bx r0 thumb_func_end FieldGetPlayerInput - thumb_func_start sub_809C014 -@ int sub_809C014(overworld_input_data *input_data) -sub_809C014: @ 809C014 + thumb_func_start ProcessPlayerFieldInput +@ int ProcessPlayerFieldInput(overworld_input_data *input_data) +ProcessPlayerFieldInput: @ 809C014 push {r4-r6,lr} sub sp, 0x8 adds r5, r0, 0 @@ -348,7 +348,7 @@ _0809C172: pop {r4-r6} pop {r1} bx r1 - thumb_func_end sub_809C014 + thumb_func_end ProcessPlayerFieldInput thumb_func_start player_get_pos_to_and_height player_get_pos_to_and_height: @ 809C17C @@ -1560,7 +1560,7 @@ overworld_poison_step: @ 809CB94 strh r1, [r0] cmp r1, 0 bne _0809CBD4 - bl overworld_poison + bl DoPoisonFieldEffect cmp r0, 0x1 beq _0809CBD4 cmp r0, 0x1 diff --git a/asm/field_screen.s b/asm/field_screen.s index c11aef1b4..8a97644ac 100644 --- a/asm/field_screen.s +++ b/asm/field_screen.s @@ -7851,7 +7851,7 @@ palette_bg_faded_fill_black: @ 80AF020 thumb_func_start pal_fill_for_maplights pal_fill_for_maplights: @ 80AF040 push {r4,lr} - bl get_map_light_from_warp0 + bl GetLastUsedWarpMapType adds r4, r0, 0 lsls r4, 24 lsrs r4, 24 diff --git a/asm/fldeff_80F9BCC.s b/asm/fldeff_80F9BCC.s index 3cfbe215a..e31997849 100644 --- a/asm/fldeff_80F9BCC.s +++ b/asm/fldeff_80F9BCC.s @@ -2200,8 +2200,8 @@ _080FAE2A: .pool thumb_func_end sub_80FADE4 - thumb_func_start task50_overworld_poison_effect -task50_overworld_poison_effect: @ 80FAE38 + thumb_func_start task50_FldeffPoison_Start +task50_FldeffPoison_Start: @ 80FAE38 push {lr} lsls r0, 24 lsrs r2, r0, 24 @@ -2260,25 +2260,25 @@ _080FAE92: _080FAEA2: pop {r0} bx r0 - thumb_func_end task50_overworld_poison_effect + thumb_func_end task50_FldeffPoison_Start - thumb_func_start overworld_poison_effect -overworld_poison_effect: @ 80FAEA8 + thumb_func_start FldeffPoison_Start +FldeffPoison_Start: @ 80FAEA8 push {lr} movs r0, 0x4F bl PlaySE - ldr r0, =task50_overworld_poison_effect + ldr r0, =task50_FldeffPoison_Start movs r1, 0x50 bl CreateTask pop {r0} bx r0 .pool - thumb_func_end overworld_poison_effect + thumb_func_end FldeffPoison_Start thumb_func_start FieldPoisonEffectIsRunning FieldPoisonEffectIsRunning: @ 80FAEC0 push {lr} - ldr r0, =task50_overworld_poison_effect + ldr r0, =task50_FldeffPoison_Start bl FuncIsActiveTask lsls r0, 24 lsrs r0, 24 diff --git a/data/event_scripts.s b/data/event_scripts.s index dc308f8b1..30adafd35 100644 --- a/data/event_scripts.s +++ b/data/event_scripts.s @@ -3324,7 +3324,7 @@ EventScript_2736B3:: @ 82736B3 EventScript_2736BC:: @ 82736BC lockall - special sub_80F972C + special ExecuteWhiteOut waitstate compare VAR_RESULT, 1 goto_eq EventScript_2736D9 diff --git a/data/specials.inc b/data/specials.inc index 4d11cf304..ec378ae19 100644 --- a/data/specials.inc +++ b/data/specials.inc @@ -210,7 +210,7 @@ gSpecials:: @ 81DBA64 def_special ShowLinkBattleRecords def_special IsEnoughForCostInVar0x8005 def_special SubtractMoneyFromVar0x8005 - def_special sub_80F972C + def_special ExecuteWhiteOut def_special sp0C8_whiteout_maybe def_special RotatingGate_InitPuzzle def_special RotatingGate_InitPuzzleAndGraphics diff --git a/include/event_object_movement.h b/include/event_object_movement.h index ddccfe39b..8a66d140c 100644 --- a/include/event_object_movement.h +++ b/include/event_object_movement.h @@ -82,7 +82,7 @@ struct LockedAnimEventObjects extern const struct SpriteFrameImage gEventObjectPicTable_PechaBerryTree[]; extern const u8 gReflectionEffectPaletteMap[]; -void sub_808D438(void); +void ResetEventObjects(void); u8 GetMoveDirectionAnimNum(u8); u8 GetEventObjectIdByLocalIdAndMap(u8, u8, u8); bool8 TryGetEventObjectIdByLocalIdAndMap(u8, u8, u8, u8 *); diff --git a/include/field_control_avatar.h b/include/field_control_avatar.h index 0ff1834ca..14245a8a2 100644 --- a/include/field_control_avatar.h +++ b/include/field_control_avatar.h @@ -25,7 +25,7 @@ struct FieldInput void FieldClearPlayerInput(struct FieldInput *pStruct); void FieldGetPlayerInput(struct FieldInput *pStruct, u16 keys, u16 heldKeys); -int sub_809C014(struct FieldInput *pStruct); +int ProcessPlayerFieldInput(struct FieldInput *pStruct); u8 *sub_80682A8(struct MapPosition *, u8, u8); void overworld_poison_timer_set(void); void prev_quest_postbuffer_cursor_backup_reset(void); diff --git a/include/field_effect.h b/include/field_effect.h index e05ded621..f049d6966 100644 --- a/include/field_effect.h +++ b/include/field_effect.h @@ -179,8 +179,8 @@ bool8 sub_80B7B94(struct Task *, struct EventObject *, struct Sprite *); bool8 sub_80B7BCC(struct Task *, struct EventObject *, struct Sprite *); bool8 sub_80B7BF4(struct Task *, struct EventObject *, struct Sprite *); -void sub_80B7D14(struct Task *); -void sub_80B7D34(struct Task *); +static void EscapeRopeFieldEffect_Step0(struct Task *); +static void EscapeRopeFieldEffect_Step1(struct Task *); void sub_80B7EC4(struct Task *); void sub_80B7EE8(struct Task *); diff --git a/include/field_poison.h b/include/field_poison.h index d1a4c823b..90d017ac7 100644 --- a/include/field_poison.h +++ b/include/field_poison.h @@ -13,7 +13,7 @@ enum { FLDPSN_FNT }; -void sub_80F972C(void); -unsigned int overworld_poison(void); +void ExecuteWhiteOut(void); +u32 DoPoisonFieldEffect(void); #endif //GUARD_FIELD_POISON_H diff --git a/include/fldeff_80F9BCC.h b/include/fldeff_80F9BCC.h index ba775cd6d..67e0de85f 100644 --- a/include/fldeff_80F9BCC.h +++ b/include/fldeff_80F9BCC.h @@ -11,7 +11,7 @@ void sub_80FA5E4(s16 id, s16 x, s16 y); void sub_80FA794(s16 x, s16 y); void CreateRecordMixingSprite(void); void DestroyRecordMixingSprite(void); -void overworld_poison_effect(void); +void FldeffPoison_Start(void); bool8 sub_80FADE4(u16, u8); #endif //GUARD_FLDEFF_80F9BCC_H diff --git a/include/global.fieldmap.h b/include/global.fieldmap.h index 4bec8e0c7..3f0b61ea7 100644 --- a/include/global.fieldmap.h +++ b/include/global.fieldmap.h @@ -230,14 +230,14 @@ struct EventObjectGraphicsInfo /*0x20*/ const union AffineAnimCmd *const *affineAnims; }; -#define PLAYER_AVATAR_FLAG_ON_FOOT (1 << 0) -#define PLAYER_AVATAR_FLAG_MACH_BIKE (1 << 1) -#define PLAYER_AVATAR_FLAG_ACRO_BIKE (1 << 2) -#define PLAYER_AVATAR_FLAG_SURFING (1 << 3) -#define PLAYER_AVATAR_FLAG_4 (1 << 4) -#define PLAYER_AVATAR_FLAG_5 (1 << 5) -#define PLAYER_AVATAR_FLAG_6 (1 << 6) -#define PLAYER_AVATAR_FLAG_DASH (1 << 7) +#define PLAYER_AVATAR_FLAG_ON_FOOT (1 << 0) +#define PLAYER_AVATAR_FLAG_MACH_BIKE (1 << 1) +#define PLAYER_AVATAR_FLAG_ACRO_BIKE (1 << 2) +#define PLAYER_AVATAR_FLAG_SURFING (1 << 3) +#define PLAYER_AVATAR_FLAG_UNDERWATER (1 << 4) +#define PLAYER_AVATAR_FLAG_5 (1 << 5) +#define PLAYER_AVATAR_FLAG_6 (1 << 6) +#define PLAYER_AVATAR_FLAG_DASH (1 << 7) enum { diff --git a/include/overworld.h b/include/overworld.h index 3dce20ab2..6b38a8782 100644 --- a/include/overworld.h +++ b/include/overworld.h @@ -47,13 +47,13 @@ void Overworld_SetEventObjTemplateMovementType(u8 localId, u8 movementType); const struct MapLayout *GetMapLayout(void); void ApplyCurrentWarp(void); void set_warp2_warp3_to_neg_1(void); -void SetWarpData(struct WarpData *warp, s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y); -bool32 IsDummyWarp(struct WarpData *warp); +static void SetWarpData(struct WarpData *warp, s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y); +static bool32 IsDummyWarp(struct WarpData *warp); struct MapHeader const *const Overworld_GetMapHeaderByGroupAndId(u16 mapGroup, u16 mapNum); struct MapHeader const *const GetDestinationWarpMapHeader(void); -void LoadCurrentMapData(void); -void LoadSaveblockMapHeader(void); -void SetPlayerCoordsFromWarp(void); +static void LoadCurrentMapData(void); +static void LoadSaveblockMapHeader(void); +static void SetPlayerCoordsFromWarp(void); void WarpIntoMap(void); void Overworld_SetWarpDestination(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y); void warp1_set_2(s8 mapGroup, s8 mapNum, s8 warpId); @@ -67,7 +67,7 @@ void sub_8084D5C(s16 a1, s16 a2); void sub_8084DD4(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y); void sub_8084E14(void); void SetFixedDiveWarp(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y); -void SetFixedDiveWarpAsDestination(void); +static void SetFixedDiveWarpAsDestination(void); void SetFixedHoleWarp(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y); void SetFixedHoleWarpAsDestination(s16 x, s16 y); void warp1_set_to_sav1w(void); @@ -75,7 +75,7 @@ void sub_8084F2C(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y); void sub_8084F6C(u8 a1); void sub_8084FAC(void); const struct MapConnection *GetMapConnection(u8 dir); -bool8 SetDiveWarp(u8 dir, u16 x, u16 y); +static bool8 SetDiveWarp(u8 dir, u16 x, u16 y); bool8 SetDiveWarpEmerge(u16 x, u16 y); bool8 SetDiveWarpDive(u16 x, u16 y); void mliX_load_map(u8 mapGroup, u8 mapNum); @@ -105,7 +105,7 @@ void UpdateAmbientCry(s16 *state, u16 *delayCounter); u8 GetMapTypeByGroupAndId(s8 mapGroup, s8 mapNum); u8 GetMapTypeByWarpData(struct WarpData *warp); u8 Overworld_GetMapTypeOfSaveblockLocation(void); -u8 get_map_light_from_warp0(void); +u8 GetLastUsedWarpMapType(void); bool8 is_map_type_1_2_3_5_or_6(u8 mapType); bool8 Overworld_MapTypeAllowsTeleportAndFly(u8 mapType); bool8 Overworld_MapTypeIsIndoors(u8 mapType); diff --git a/src/bike.c b/src/bike.c index 6ffd479f7..1fa4eb301 100644 --- a/src/bike.c +++ b/src/bike.c @@ -968,7 +968,7 @@ bool8 IsBikingDisallowedByPlayer(void) s16 x, y; u8 tileBehavior; - if (!(gPlayerAvatar.flags & (PLAYER_AVATAR_FLAG_SURFING | PLAYER_AVATAR_FLAG_4))) + if (!(gPlayerAvatar.flags & (PLAYER_AVATAR_FLAG_SURFING | PLAYER_AVATAR_FLAG_UNDERWATER))) { PlayerGetDestCoords(&x, &y); tileBehavior = MapGridGetMetatileBehaviorAt(x, y); diff --git a/src/event_object_movement.c b/src/event_object_movement.c index 342944fcb..201f5ff08 100644 --- a/src/event_object_movement.c +++ b/src/event_object_movement.c @@ -74,7 +74,7 @@ static void sub_8097D68(struct Sprite*); static void ApplyLevitateMovement(u8); static bool8 MovementType_Disguise_Callback(struct EventObject *, struct Sprite *); static bool8 MovementType_Hidden_Callback(struct EventObject *, struct Sprite *); -static void sub_808D450(void); +static void CreateReflectionEffectSprites(void); static u8 GetEventObjectIdByLocalId(u8); static u8 GetEventObjectIdByLocalIdAndMapInternal(u8, u8, u8); static bool8 GetAvailableEventObjectId(u16, u8, u8, u8 *); @@ -1083,15 +1083,15 @@ static void ClearAllEventObjects(void) ClearEventObject(&gEventObjects[i]); } -void sub_808D438(void) +void ResetEventObjects(void) { ClearLinkPlayerEventObjects(); ClearAllEventObjects(); ClearPlayerAvatarInfo(); - sub_808D450(); + CreateReflectionEffectSprites(); } -static void sub_808D450(void) +static void CreateReflectionEffectSprites(void) { u8 spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[21], 0, 0, 31); gSprites[spriteId].oam.affineMode = 1; @@ -1809,7 +1809,7 @@ void sub_808E16C(s16 x, s16 y) sub_808E1B8(i, x, y); } } - sub_808D450(); + CreateReflectionEffectSprites(); } static void sub_808E1B8(u8 eventObjectId, s16 x, s16 y) diff --git a/src/field_effect.c b/src/field_effect.c index 5a5ccfc0a..5db9b9f36 100644 --- a/src/field_effect.c +++ b/src/field_effect.c @@ -1,10 +1,9 @@ #include "global.h" -#include "field_effect.h" -#include "trainer_pokemon_sprites.h" #include "decompress.h" -#include "field_camera.h" -#include "field_effect_helpers.h" #include "event_object_movement.h" +#include "field_camera.h" +#include "field_effect.h" +#include "field_effect_helpers.h" #include "field_player_avatar.h" #include "field_screen.h" #include "field_weather.h" @@ -22,8 +21,10 @@ #include "sound.h" #include "sprite.h" #include "task.h" +#include "trainer_pokemon_sprites.h" #include "trig.h" #include "util.h" +#include "constants/event_object_movement_constants.h" #include "constants/rgb.h" #include "constants/songs.h" @@ -322,9 +323,9 @@ bool8 (*const gUnknown_0855C460[])(struct Task *, struct EventObject *, struct S sub_80B7BF4, }; -void (*const gUnknown_0855C474[])(struct Task *) = { - sub_80B7D14, - sub_80B7D34, +void (*const gEscapeRopeFieldEffectFuncs[])(struct Task *) = { + EscapeRopeFieldEffect_Step0, + EscapeRopeFieldEffect_Step1, }; // .text @@ -1686,7 +1687,7 @@ bool8 sub_80B7478(struct Task *task, struct EventObject *eventObject) return FALSE; } -void Task_Dive(u8); +static void Task_Dive(u8); extern int dive_warp(struct MapPosition *, u16); bool8 FldEff_UseDive(void) @@ -1999,7 +2000,7 @@ bool8 sub_80B7BCC(struct Task *task, struct EventObject *eventObject, struct Spr return FALSE; } -void sub_80B7CE4(u8); +static void DoEscapeRopeFieldEffect(u8); void mapldr_080859D4(void); bool8 sub_80B7BF4(struct Task *task, struct EventObject *eventObject, struct Sprite *sprite) @@ -2032,29 +2033,29 @@ void sub_80B7CAC(struct Sprite *sprite) } } -void sub_80B7CC8(void) +void StartEscapeRopeFieldEffect(void) { ScriptContext2_Enable(); FreezeEventObjects(); - CreateTask(sub_80B7CE4, 0x50); + CreateTask(DoEscapeRopeFieldEffect, 0x50); } -void sub_80B7CE4(u8 taskId) +static void DoEscapeRopeFieldEffect(u8 taskId) { - gUnknown_0855C474[gTasks[taskId].data[0]](&gTasks[taskId]); + gEscapeRopeFieldEffectFuncs[gTasks[taskId].data[0]](&gTasks[taskId]); } -void sub_80B7D14(struct Task *task) +static void EscapeRopeFieldEffect_Step0(struct Task *task) { task->data[0]++; task->data[14] = 64; task->data[15] = GetPlayerFacingDirection(); } -void sub_80B7D34(struct Task *task) +static void EscapeRopeFieldEffect_Step1(struct Task *task) { struct EventObject *eventObject; - u8 spinDirections[5] = {1, 3, 4, 2, 1}; + u8 spinDirections[5] = {DIR_SOUTH, DIR_WEST, DIR_EAST, DIR_NORTH, DIR_SOUTH}; if (task->data[14] != 0 && (--task->data[14]) == 0) { music_something(); @@ -2070,7 +2071,7 @@ void sub_80B7D34(struct Task *task) WarpIntoMap(); gFieldCallback = mapldr_080859D4; SetMainCallback2(CB2_LoadMap); - DestroyTask(FindTaskIdByFunc(sub_80B7CE4)); + DestroyTask(FindTaskIdByFunc(DoEscapeRopeFieldEffect)); } else if (task->data[1] == 0 || (--task->data[1]) == 0) { EventObjectSetHeldMovement(eventObject, GetFaceDirectionMovementAction(spinDirections[eventObject->facingDirection])); @@ -2905,7 +2906,7 @@ void sub_80B8E14(struct Task *task) if (!EventObjectIsMovementOverridden(eventObject) || EventObjectClearHeldMovementIfFinished(eventObject)) { sub_808C114(); - EventObjectSetHeldMovement(eventObject, 0x39); + EventObjectSetHeldMovement(eventObject, MOVEMENT_ACTION_START_ANIM_IN_DIRECTION); task->data[0]++; } } @@ -3210,7 +3211,7 @@ void sub_80B9204(struct Task *task) gPlayerAvatar.preventStep = TRUE; SetPlayerAvatarStateMask(1); sub_808C114(); - EventObjectSetHeldMovement(eventObject, 0x39); + EventObjectSetHeldMovement(eventObject, MOVEMENT_ACTION_START_ANIM_IN_DIRECTION); task->data[0]++; } } @@ -3250,7 +3251,7 @@ void sub_80B92F8(struct Task *task) task->data[0]++; task->data[2] = 16; SetPlayerAvatarTransitionFlags(PLAYER_AVATAR_FLAG_ON_FOOT); - EventObjectSetHeldMovement(&gEventObjects[gPlayerAvatar.eventObjectId], 0x02); + EventObjectSetHeldMovement(&gEventObjects[gPlayerAvatar.eventObjectId], MOVEMENT_ACTION_FACE_LEFT); } } @@ -3275,7 +3276,7 @@ void sub_80B9390(struct Task *task) EventObjectSetGraphicsId(eventObject, GetPlayerAvatarGraphicsIdByStateId(0x03)); StartSpriteAnim(&gSprites[eventObject->spriteId], 0x16); eventObject->inanimate = 1; - EventObjectSetHeldMovement(eventObject, 0x48); + EventObjectSetHeldMovement(eventObject, MOVEMENT_ACTION_JUMP_IN_PLACE_LEFT); if (task->data[15] & 0x08) { DestroySprite(&gSprites[eventObject->fieldEffectSpriteId]); @@ -3585,7 +3586,7 @@ void sub_80B9978(struct Task *task) sprite->pos2.y = 0; sprite->coordOffsetEnabled = 1; sub_808C114(); - EventObjectSetHeldMovement(eventObject, 0x39); + EventObjectSetHeldMovement(eventObject, MOVEMENT_ACTION_START_ANIM_IN_DIRECTION); task->data[0]++; } } diff --git a/src/field_player_avatar.c b/src/field_player_avatar.c index e72b5b944..f5ddbcca4 100644 --- a/src/field_player_avatar.c +++ b/src/field_player_avatar.c @@ -624,7 +624,7 @@ static void PlayerNotOnBikeMoving(u8 direction, u16 heldKeys) return; } - if (!(gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_4) && (heldKeys & B_BUTTON) && FlagGet(FLAG_SYS_B_DASH) + if (!(gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_UNDERWATER) && (heldKeys & B_BUTTON) && FlagGet(FLAG_SYS_B_DASH) && IsRunningDisallowed(gEventObjects[gPlayerAvatar.eventObjectId].currentMetatileBehavior) == 0) { PlayerRun(direction); diff --git a/src/field_poison.c b/src/field_poison.c index 98819c450..a3b70323e 100644 --- a/src/field_poison.c +++ b/src/field_poison.c @@ -1,20 +1,20 @@ #include "global.h" -#include "string_util.h" -#include "party_menu.h" -#include "constants/species.h" -#include "task.h" -#include "field_message_box.h" -#include "strings.h" -#include "rom_818CFC8.h" -#include "battle_frontier_2.h" -#include "pokenav.h" -#include "event_data.h" -#include "script.h" #include "battle.h" -#include "fldeff_80F9BCC.h" +#include "battle_frontier_2.h" +#include "event_data.h" +#include "field_message_box.h" #include "field_poison.h" +#include "fldeff_80F9BCC.h" +#include "party_menu.h" +#include "pokenav.h" +#include "rom_818CFC8.h" +#include "script.h" +#include "string_util.h" +#include "strings.h" +#include "task.h" +#include "constants/species.h" -static bool32 sub_80F9568(struct Pokemon *pokemon) +static bool32 IsMonValidSpecies(struct Pokemon *pokemon) { u16 species = GetMonData(pokemon, MON_DATA_SPECIES2); if (species == SPECIES_NONE || species == SPECIES_EGG) @@ -24,14 +24,14 @@ static bool32 sub_80F9568(struct Pokemon *pokemon) return TRUE; } -static bool32 sub_80F958C(void) +static bool32 AllMonsFainted(void) { int i; - struct Pokemon *pokemon; + struct Pokemon *pokemon = gPlayerParty; - for (pokemon = gPlayerParty, i = 0; i < PARTY_SIZE; i++, pokemon++) + for (i = 0; i < PARTY_SIZE; i++, pokemon++) { - if (sub_80F9568(pokemon) && GetMonData(pokemon, MON_DATA_HP) != 0) + if (IsMonValidSpecies(pokemon) && GetMonData(pokemon, MON_DATA_HP) != 0) { return FALSE; } @@ -39,27 +39,28 @@ static bool32 sub_80F958C(void) return TRUE; } -static void sub_80F95C0(u8 partyIdx) +static void FaintFromFieldPoison(u8 partyIdx) { struct Pokemon *pokemon = gPlayerParty + partyIdx; - unsigned int status = STATUS1_NONE; + u32 status = STATUS1_NONE; + AdjustFriendship(pokemon, 0x07); SetMonData(pokemon, MON_DATA_STATUS, &status); GetMonData(pokemon, MON_DATA_NICKNAME, gStringVar1); StringGetEnd10(gStringVar1); } -static bool32 sub_80F960C(u8 partyIdx) +static bool32 MonFaintedFromPoison(u8 partyIdx) { struct Pokemon *pokemon = gPlayerParty + partyIdx; - if (sub_80F9568(pokemon) && GetMonData(pokemon, MON_DATA_HP) == 0 && pokemon_ailments_get_primary(GetMonData(pokemon, MON_DATA_STATUS)) == AILMENT_PSN) + if (IsMonValidSpecies(pokemon) && GetMonData(pokemon, MON_DATA_HP) == 0 && pokemon_ailments_get_primary(GetMonData(pokemon, MON_DATA_STATUS)) == AILMENT_PSN) { return TRUE; } return FALSE; } -static void sub_80F9654(u8 taskId) +static void Task_WhiteOut(u8 taskId) { s16 *data = gTasks[taskId].data; switch (data[0]) @@ -67,9 +68,9 @@ static void sub_80F9654(u8 taskId) case 0: for (; data[1] < PARTY_SIZE; data[1]++) { - if (sub_80F960C(data[1])) + if (MonFaintedFromPoison(data[1])) { - sub_80F95C0(data[1]); + FaintFromFieldPoison(data[1]); ShowFieldMessage(gText_PkmnFainted3); data[0]++; return; @@ -84,7 +85,7 @@ static void sub_80F9654(u8 taskId) } break; case 2: - if (sub_80F958C()) + if (AllMonsFainted()) { if (InBattlePyramid() | InBattlePike() || sub_81D5C18()) { @@ -105,19 +106,19 @@ static void sub_80F9654(u8 taskId) } } -void sub_80F972C(void) +void ExecuteWhiteOut(void) { - CreateTask(sub_80F9654, 80); + CreateTask(Task_WhiteOut, 80); ScriptContext1_Stop(); } -unsigned int overworld_poison(void) +u32 DoPoisonFieldEffect(void) { int i; - unsigned int hp; + u32 hp; struct Pokemon *pokemon = gPlayerParty; - unsigned int numPoisoned = 0; - unsigned int numFainted = 0; + u32 numPoisoned = 0; + u32 numFainted = 0; for (i = 0; i < PARTY_SIZE; i++) { if (GetMonData(pokemon, MON_DATA_SANITY_BIT2) && pokemon_ailments_get_primary(GetMonData(pokemon, MON_DATA_STATUS)) == AILMENT_PSN) @@ -134,7 +135,7 @@ unsigned int overworld_poison(void) } if (numFainted != 0 || numPoisoned != 0) { - overworld_poison_effect(); + FldeffPoison_Start(); } if (numFainted != 0) { diff --git a/src/field_specials.c b/src/field_specials.c index 113979375..a2bd567d0 100644 --- a/src/field_specials.c +++ b/src/field_specials.c @@ -1513,7 +1513,7 @@ bool8 FoundBlackGlasses(void) void SetRoute119Weather(void) { - if (is_map_type_1_2_3_5_or_6(get_map_light_from_warp0()) != TRUE) + if (is_map_type_1_2_3_5_or_6(GetLastUsedWarpMapType()) != TRUE) { SetSav1Weather(20); } @@ -1521,7 +1521,7 @@ void SetRoute119Weather(void) void SetRoute123Weather(void) { - if (is_map_type_1_2_3_5_or_6(get_map_light_from_warp0()) != TRUE) + if (is_map_type_1_2_3_5_or_6(GetLastUsedWarpMapType()) != TRUE) { SetSav1Weather(21); } diff --git a/src/fldeff_flash.c b/src/fldeff_flash.c index 654f02c23..d4d979239 100644 --- a/src/fldeff_flash.c +++ b/src/fldeff_flash.c @@ -156,7 +156,7 @@ void c2_change_map(void) static bool8 sub_8137304(void) { u8 i; - u8 v0 = get_map_light_from_warp0(); + u8 v0 = GetLastUsedWarpMapType(); u8 v1 = Overworld_GetMapTypeOfSaveblockLocation(); for (i = 0; gUnknown_085B27C8[i].unk0; i++) diff --git a/src/item_use.c b/src/item_use.c index 633d975a8..4ab9f6e23 100755 --- a/src/item_use.c +++ b/src/item_use.c @@ -58,7 +58,7 @@ extern void sub_81C5924(void); extern void sub_81C59BC(void); extern void sub_81AB9A8(u8); extern void sub_81ABA88(u8); -extern void sub_80B7CC8(void); +extern void StartEscapeRopeFieldEffect(void); extern u8* sub_806CF78(u16); extern void sub_81B89F0(void); extern u8 GetItemEffectType(u16); @@ -260,7 +260,7 @@ bool32 CanFish(void) if (MetatileBehavior_IsWaterfall(tileBehavior)) return FALSE; - if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_4)) + if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_UNDERWATER)) return FALSE; if (!TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_SURFING)) @@ -890,7 +890,7 @@ void ItemUseOutOfBattle_BlackWhiteFlute(u8 taskId) void task08_080A1C44(u8 taskId) { ResetInitialPlayerAvatarState(); - sub_80B7CC8(); + StartEscapeRopeFieldEffect(); DestroyTask(taskId); } diff --git a/src/overworld.c b/src/overworld.c index 61023af58..ef0220867 100644 --- a/src/overworld.c +++ b/src/overworld.c @@ -585,7 +585,7 @@ void set_warp2_warp3_to_neg_1(void) gFixedHoleWarp = sDummyWarpData; } -void SetWarpData(struct WarpData *warp, s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y) +static void SetWarpData(struct WarpData *warp, s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y) { warp->mapGroup = mapGroup; warp->mapNum = mapNum; @@ -594,7 +594,7 @@ void SetWarpData(struct WarpData *warp, s8 mapGroup, s8 mapNum, s8 warpId, s8 x, warp->y = y; } -bool32 IsDummyWarp(struct WarpData *warp) +static bool32 IsDummyWarp(struct WarpData *warp) { if (warp->mapGroup != -1) return FALSE; @@ -620,7 +620,7 @@ struct MapHeader const *const GetDestinationWarpMapHeader(void) return Overworld_GetMapHeaderByGroupAndId(sWarpDestination.mapGroup, sWarpDestination.mapNum); } -void LoadCurrentMapData(void) +static void LoadCurrentMapData(void) { sLastMapSectionId = gMapHeader.regionMapSectionId; gMapHeader = *Overworld_GetMapHeaderByGroupAndId(gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum); @@ -628,13 +628,13 @@ void LoadCurrentMapData(void) gMapHeader.mapLayout = GetMapLayout(); } -void LoadSaveblockMapHeader(void) +static void LoadSaveblockMapHeader(void) { gMapHeader = *Overworld_GetMapHeaderByGroupAndId(gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum); gMapHeader.mapLayout = GetMapLayout(); } -void SetPlayerCoordsFromWarp(void) +static void SetPlayerCoordsFromWarp(void) { if (gSaveBlock1Ptr->location.warpId >= 0 && gSaveBlock1Ptr->location.warpId < gMapHeader.events->warpCount) { @@ -729,7 +729,7 @@ void SetFixedDiveWarp(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y) SetWarpData(&gFixedDiveWarp, mapGroup, mapNum, warpId, x, y); } -void SetFixedDiveWarpAsDestination(void) +static void SetFixedDiveWarpAsDestination(void) { sWarpDestination = gFixedDiveWarp; } @@ -785,7 +785,7 @@ const struct MapConnection *GetMapConnection(u8 dir) return NULL; } -bool8 SetDiveWarp(u8 dir, u16 x, u16 y) +static bool8 SetDiveWarp(u8 dir, u16 x, u16 y) { const struct MapConnection *connection = GetMapConnection(dir); @@ -905,8 +905,8 @@ static void mli0_load_map(u32 a1) void ResetInitialPlayerAvatarState(void) { - gInitialPlayerAvatarState.direction = 1; - gInitialPlayerAvatarState.transitionFlags = 1; + gInitialPlayerAvatarState.direction = DIR_SOUTH; + gInitialPlayerAvatarState.transitionFlags = PLAYER_AVATAR_FLAG_ON_FOOT; } void StoreInitialPlayerAvatarState(void) @@ -914,15 +914,15 @@ void StoreInitialPlayerAvatarState(void) gInitialPlayerAvatarState.direction = GetPlayerFacingDirection(); if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_MACH_BIKE)) - gInitialPlayerAvatarState.transitionFlags = 2; + gInitialPlayerAvatarState.transitionFlags = PLAYER_AVATAR_FLAG_MACH_BIKE; else if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_ACRO_BIKE)) - gInitialPlayerAvatarState.transitionFlags = 4; + gInitialPlayerAvatarState.transitionFlags = PLAYER_AVATAR_FLAG_ACRO_BIKE; else if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_SURFING)) - gInitialPlayerAvatarState.transitionFlags = 8; - else if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_4)) - gInitialPlayerAvatarState.transitionFlags = 16; + gInitialPlayerAvatarState.transitionFlags = PLAYER_AVATAR_FLAG_SURFING; + else if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_UNDERWATER)) + gInitialPlayerAvatarState.transitionFlags = PLAYER_AVATAR_FLAG_UNDERWATER; else - gInitialPlayerAvatarState.transitionFlags = 1; + gInitialPlayerAvatarState.transitionFlags = PLAYER_AVATAR_FLAG_ON_FOOT; } static struct InitialPlayerAvatarState *GetInitialPlayerAvatarState(void) @@ -940,44 +940,44 @@ static struct InitialPlayerAvatarState *GetInitialPlayerAvatarState(void) static u8 GetAdjustedInitialTransitionFlags(struct InitialPlayerAvatarState *playerStruct, u16 metatileBehavior, u8 mapType) { if (mapType != MAP_TYPE_INDOOR && FlagGet(FLAG_SYS_CRUISE_MODE)) - return 1; + return PLAYER_AVATAR_FLAG_ON_FOOT; else if (mapType == MAP_TYPE_UNDERWATER) - return 16; + return PLAYER_AVATAR_FLAG_UNDERWATER; else if (MetatileBehavior_IsSurfableWaterOrUnderwater(metatileBehavior) == TRUE) - return 8; + return PLAYER_AVATAR_FLAG_SURFING; else if (Overworld_IsBikingAllowed() != TRUE) - return 1; - else if (playerStruct->transitionFlags == 2) - return 2; - else if (playerStruct->transitionFlags != 4) - return 1; + return PLAYER_AVATAR_FLAG_ON_FOOT; + else if (playerStruct->transitionFlags == PLAYER_AVATAR_FLAG_MACH_BIKE) + return PLAYER_AVATAR_FLAG_MACH_BIKE; + else if (playerStruct->transitionFlags != PLAYER_AVATAR_FLAG_ACRO_BIKE) + return PLAYER_AVATAR_FLAG_ON_FOOT; else - return 4; + return PLAYER_AVATAR_FLAG_ACRO_BIKE; } static u8 GetAdjustedInitialDirection(struct InitialPlayerAvatarState *playerStruct, u8 transitionFlags, u16 metatileBehavior, u8 mapType) { if (FlagGet(FLAG_SYS_CRUISE_MODE) && mapType == MAP_TYPE_6) - return 4; + return DIR_EAST; else if (MetatileBehavior_IsDeepSouthWarp(metatileBehavior) == TRUE) - return 2; + return DIR_NORTH; else if (MetatileBehavior_IsNonAnimDoor(metatileBehavior) == TRUE || MetatileBehavior_IsDoor(metatileBehavior) == TRUE) - return 1; + return DIR_SOUTH; else if (MetatileBehavior_IsSouthArrowWarp(metatileBehavior) == TRUE) - return 2; + return DIR_NORTH; else if (MetatileBehavior_IsNorthArrowWarp(metatileBehavior) == TRUE) - return 1; + return DIR_SOUTH; else if (MetatileBehavior_IsWestArrowWarp(metatileBehavior) == TRUE) - return 4; + return DIR_EAST; else if (MetatileBehavior_IsEastArrowWarp(metatileBehavior) == TRUE) - return 3; - else if ((playerStruct->transitionFlags == 16 && transitionFlags == 8) - || (playerStruct->transitionFlags == 8 && transitionFlags == 16)) + return DIR_WEST; + else if ((playerStruct->transitionFlags == PLAYER_AVATAR_FLAG_UNDERWATER && transitionFlags == PLAYER_AVATAR_FLAG_SURFING) + || (playerStruct->transitionFlags == PLAYER_AVATAR_FLAG_SURFING && transitionFlags == PLAYER_AVATAR_FLAG_UNDERWATER )) return playerStruct->direction; else if (MetatileBehavior_IsLadder(metatileBehavior) == TRUE) return playerStruct->direction; else - return 1; + return DIR_SOUTH; } static u16 GetCenterScreenMetatileBehavior(void) @@ -1357,7 +1357,7 @@ u8 Overworld_GetMapTypeOfSaveblockLocation(void) return GetMapTypeByWarpData(&gSaveBlock1Ptr->location); } -u8 get_map_light_from_warp0(void) +u8 GetLastUsedWarpMapType(void) { return GetMapTypeByWarpData(&gLastUsedWarp); } @@ -1458,7 +1458,7 @@ static void DoCB1_Overworld(u16 newKeys, u16 heldKeys) FieldGetPlayerInput(&inputStruct, newKeys, heldKeys); if (!ScriptContext2_IsEnabled()) { - if (sub_809C014(&inputStruct) == 1) + if (ProcessPlayerFieldInput(&inputStruct) == 1) { ScriptContext2_Enable(); HideMapNamePopUpWindow(); @@ -2168,7 +2168,7 @@ static void sub_80869DC(void) { gTotalCameraPixelOffsetX = 0; gTotalCameraPixelOffsetY = 0; - sub_808D438(); + ResetEventObjects(); TrySpawnEventObjects(0, 0); mapheader_run_first_tag4_script_list_match(); } @@ -2180,7 +2180,7 @@ static void mli4_mapscripts_and_other(void) gTotalCameraPixelOffsetX = 0; gTotalCameraPixelOffsetY = 0; - sub_808D438(); + ResetEventObjects(); sav1_camera_get_focus_coords(&x, &y); player = GetInitialPlayerAvatarState(); InitPlayerAvatar(x, y, player->direction, gSaveBlock2Ptr->playerGender); diff --git a/src/rom6.c b/src/rom6.c index cc146fc94..712ac76e0 100644 --- a/src/rom6.c +++ b/src/rom6.c @@ -1,21 +1,22 @@ #include "global.h" -#include "constants/event_objects.h" -#include "constants/songs.h" -#include "rom6.h" #include "braille_puzzles.h" #include "event_data.h" +#include "event_object_movement.h" #include "event_scripts.h" #include "field_effect.h" -#include "event_object_movement.h" #include "field_player_avatar.h" #include "item_use.h" -#include "party_menu.h" #include "overworld.h" +#include "party_menu.h" +#include "rom6.h" #include "script.h" #include "sound.h" #include "sprite.h" #include "task.h" +#include "constants/event_object_movement_constants.h" +#include "constants/event_objects.h" #include "constants/map_types.h" +#include "constants/songs.h" // static functions static void task08_080C9820(u8 taskId); @@ -31,14 +32,14 @@ static void sub_8135780(void); extern struct MapPosition gPlayerFacingPosition; // text -bool8 CheckObjectGraphicsInFrontOfPlayer(u8 a) +bool8 CheckObjectGraphicsInFrontOfPlayer(u8 graphicsId) { u8 eventObjId; GetXYCoordsOneStepInFrontOfPlayer(&gPlayerFacingPosition.x, &gPlayerFacingPosition.y); gPlayerFacingPosition.height = PlayerGetZCoord(); eventObjId = GetEventObjectIdByXYZ(gPlayerFacingPosition.x, gPlayerFacingPosition.y, gPlayerFacingPosition.height); - if (gEventObjects[eventObjId].graphicsId != a) + if (gEventObjects[eventObjId].graphicsId != graphicsId) { return FALSE; } @@ -73,7 +74,7 @@ static void task08_080C9820(u8 taskId) else { sub_808C114(); - EventObjectSetHeldMovement(&gEventObjects[eventObjId], 0x39); + EventObjectSetHeldMovement(&gEventObjects[eventObjId], MOVEMENT_ACTION_START_ANIM_IN_DIRECTION); gTasks[taskId].func = sub_813552C; } } @@ -90,7 +91,7 @@ static void sub_813552C(u8 taskId) static void sub_8135578(u8 taskId) { - if (!FieldEffectActiveListContains(6)) + if (!FieldEffectActiveListContains(FLDEFF_FIELD_MOVE_SHOW_MON)) { gFieldEffectArguments[1] = GetPlayerFacingDirection(); if (gFieldEffectArguments[1] == 1) @@ -189,7 +190,7 @@ bool8 FldEff_UseDig(void) gTasks[taskId].data[8] = (u32)sub_8135780 >> 16; gTasks[taskId].data[9] = (u32)sub_8135780; if (!ShouldDoBrailleDigEffect()) - SetPlayerAvatarTransitionFlags(1); + SetPlayerAvatarTransitionFlags(PLAYER_AVATAR_FLAG_ON_FOOT); return FALSE; } diff --git a/src/time_events.c b/src/time_events.c index 1f46e7705..9702d321f 100644 --- a/src/time_events.c +++ b/src/time_events.c @@ -81,7 +81,7 @@ void UpdateShoalTideFlag(void) 1, // 23 }; - if (is_map_type_1_2_3_5_or_6(get_map_light_from_warp0())) + if (is_map_type_1_2_3_5_or_6(GetLastUsedWarpMapType())) { RtcCalcLocalTime(); if (tide[gLocalTime.hours])