From 4ea6992172a53eb263d5f4342c5e08dfc3f8096a Mon Sep 17 00:00:00 2001 From: GriffinR Date: Wed, 24 Jun 2020 16:27:00 -0400 Subject: [PATCH] Continue documenting overworld/field effects --- asm/macros/trainer_hill.inc | 6 +- data/field_effect_scripts.s | 42 +- data/maps/TrainerHill_Entrance/scripts.inc | 4 +- data/scripts/trainer_hill.inc | 4 +- ...{lavaridge_gym_warp.png => ash_launch.png} | Bin .../{jump_out_of_ash.png => ash_puff.png} | Bin ...hop_big_splash.png => jump_big_splash.png} | Bin ...small_splash.png => jump_small_splash.png} | Bin ...hop_tall_grass.png => jump_tall_grass.png} | Bin graphics/field_effects/pics/unused_grass.png | Bin 344 -> 0 bytes .../field_effects/pics/unused_grass_2.png | Bin 389 -> 344 bytes .../field_effects/pics/unused_grass_3.png | Bin 0 -> 389 bytes .../{unknown_20.png => water_surfacing.png} | Bin .../deoxys_rock_fragment_bottom_left.png} | Bin .../deoxys_rock_fragment_bottom_right.png} | Bin .../deoxys_rock_fragment_top_left.png} | Bin .../deoxys_rock_fragment_top_right.png} | Bin ...ig_hof_monitor.png => hof_monitor_big.png} | Bin ..._hof_monitor.png => hof_monitor_small.png} | Bin .../trainer_hill_ereader.pal} | 0 include/constants/field_effects.h | 33 +- include/constants/trainer_hill.h | 2 +- include/event_object_movement.h | 18 +- include/field_effect.h | 4 +- include/field_effect_helpers.h | 10 +- include/field_player_avatar.h | 4 +- include/fieldmap.h | 8 +- include/trainer_hill.h | 4 +- include/tv.h | 2 +- spritesheet_rules.mk | 16 +- src/battle_transition.c | 10 +- .../field_effect_object_template_pointers.h | 16 +- src/data/field_effects/field_effect_objects.h | 790 ++++-- .../object_events/object_event_graphics.h | 16 +- src/event_object_movement.c | 112 +- src/field_effect.c | 2155 +++++++++-------- src/field_effect_helpers.c | 193 +- src/field_player_avatar.c | 14 +- src/field_screen_effect.c | 2 +- src/fieldmap.c | 15 +- src/fldeff_cut.c | 4 +- src/fldeff_misc.c | 18 +- src/item_use.c | 2 +- src/overworld.c | 76 +- src/trainer_hill.c | 25 +- src/trainer_see.c | 6 +- src/tv.c | 2 +- 47 files changed, 2045 insertions(+), 1568 deletions(-) rename graphics/field_effects/pics/{lavaridge_gym_warp.png => ash_launch.png} (100%) rename graphics/field_effects/pics/{jump_out_of_ash.png => ash_puff.png} (100%) rename graphics/field_effects/pics/{bike_hop_big_splash.png => jump_big_splash.png} (100%) rename graphics/field_effects/pics/{bike_hop_small_splash.png => jump_small_splash.png} (100%) rename graphics/field_effects/pics/{bike_hop_tall_grass.png => jump_tall_grass.png} (100%) delete mode 100644 graphics/field_effects/pics/unused_grass.png create mode 100644 graphics/field_effects/pics/unused_grass_3.png rename graphics/field_effects/pics/{unknown_20.png => water_surfacing.png} (100%) rename graphics/{unknown/unknown_55C1B0.png => misc/deoxys_rock_fragment_bottom_left.png} (100%) rename graphics/{unknown/unknown_55C1D0.png => misc/deoxys_rock_fragment_bottom_right.png} (100%) rename graphics/{unknown/unknown_55C170.png => misc/deoxys_rock_fragment_top_left.png} (100%) rename graphics/{unknown/unknown_55C190.png => misc/deoxys_rock_fragment_top_right.png} (100%) rename graphics/misc/{big_hof_monitor.png => hof_monitor_big.png} (100%) rename graphics/misc/{small_hof_monitor.png => hof_monitor_small.png} (100%) rename graphics/{pokenav/862A5D4.pal => misc/trainer_hill_ereader.pal} (100%) diff --git a/asm/macros/trainer_hill.inc b/asm/macros/trainer_hill.inc index d5c84fd02..65c8c6bef 100644 --- a/asm/macros/trainer_hill.inc +++ b/asm/macros/trainer_hill.inc @@ -52,9 +52,9 @@ special CallTrainerHillFunction .endm - @ Unknown, dummied. Only side effect is setting VAR_RESULT to 0. - .macro trainerhill_clearresult - setvar VAR_0x8004, TRAINER_HILL_FUNC_CLEAR_RESULT + @ Unknown, dummied. E-Reader association is assumed. Only side effect is setting VAR_RESULT to 0. + .macro trainerhill_getusingereader + setvar VAR_0x8004, TRAINER_HILL_FUNC_GET_IN_EREADER_MODE special CallTrainerHillFunction .endm diff --git a/data/field_effect_scripts.s b/data/field_effect_scripts.s index 2eddf3126..6850154d3 100644 --- a/data/field_effect_scripts.s +++ b/data/field_effect_scripts.s @@ -17,17 +17,17 @@ gFieldEffectScriptPointers:: @ 82DB9D4 .4byte gFieldEffectScript_UseSurf @ FLDEFF_USE_SURF .4byte gFieldEffectScript_GroundImpactDust @ FLDEFF_DUST .4byte gFieldEffectScript_UseSecretPowerCave @ FLDEFF_USE_SECRET_POWER_CAVE - .4byte gFieldEffectScript_BikeHopTallGrass @ FLDEFF_JUMP_TALL_GRASS + .4byte gFieldEffectScript_JumpTallGrass @ FLDEFF_JUMP_TALL_GRASS .4byte gFieldEffectScript_SandFootprints @ FLDEFF_SAND_FOOTPRINTS - .4byte gFieldEffectScript_BikeHopBigSplash @ FLDEFF_JUMP_BIG_SPLASH + .4byte gFieldEffectScript_JumpBigSplash @ FLDEFF_JUMP_BIG_SPLASH .4byte gFieldEffectScript_Splash @ FLDEFF_SPLASH - .4byte gFieldEffectScript_BikeHopSmallSplash @ FLDEFF_JUMP_SMALL_SPLASH + .4byte gFieldEffectScript_JumpSmallSplash @ FLDEFF_JUMP_SMALL_SPLASH .4byte gFieldEffectScript_LongGrass @ FLDEFF_LONG_GRASS .4byte gFieldEffectScript_JumpLongGrass @ FLDEFF_JUMP_LONG_GRASS .4byte gFieldEffectScript_Unknown19 @ FLDEFF_UNKNOWN_19 - .4byte gFieldEffectScript_UnusedGrass @ FLDEFF_UNUSED_GRASS + .4byte gFieldEffectScript_UnusedGrass2 @ FLDEFF_UNUSED_GRASS_2 .4byte gFieldEffectScript_Unknown21 @ FLDEFF_UNKNOWN_21 - .4byte gFieldEffectScript_Unknown22 @ FLDEFF_UNKNOWN_22 + .4byte gFieldEffectScript_WaterSurfacing @ FLDEFF_WATER_SURFACING .4byte gFieldEffectScript_BerryTreeGrowthSparkle @ FLDEFF_BERRY_TREE_GROWTH_SPARKLE .4byte gFieldEffectScript_DeepSandFootprints @ FLDEFF_DEEP_SAND_FOOTPRINTS .4byte gFieldEffectScript_PokeCenterHeal @ FLDEFF_POKECENTER_HEAL @@ -54,8 +54,8 @@ gFieldEffectScriptPointers:: @ 82DB9D4 .4byte gFieldEffectScript_HeartIcon @ FLDEFF_HEART_ICON .4byte gFieldEffectScript_Unknown47 @ FLDEFF_NOP_47 .4byte gFieldEffectScript_Unknown48 @ FLDEFF_NOP_48 - .4byte gFieldEffectScript_JumpOutOfAsh @ FLDEFF_POP_OUT_OF_ASH - .4byte gFieldEffectScript_LavaridgeGymWarp @ FLDEFF_LAVARIDGE_GYM_WARP + .4byte gFieldEffectScript_AshPuff @ FLDEFF_ASH_PUFF + .4byte gFieldEffectScript_AshLaunch @ FLDEFF_ASH_LAUNCH .4byte gFieldEffectScript_SweetScent @ FLDEFF_SWEET_SCENT .4byte gFieldEffectScript_SandPillar @ FLDEFF_SAND_PILLAR .4byte gFieldEffectScript_Bubbles @ FLDEFF_BUBBLES @@ -69,7 +69,7 @@ gFieldEffectScriptPointers:: @ 82DB9D4 .4byte gFieldEffectScript_SecretBaseBootPC @ FLDEFF_PCTURN_ON .4byte gFieldEffectScript_HallOfFameRecord @ FLDEFF_HALL_OF_FAME_RECORD .4byte gFieldEffectScript_UseTeleport @ FLDEFF_USE_TELEPORT - .4byte gFieldEffectScript_Rayquaza @ FLDEFF_RAYQUAZA + .4byte gFieldEffectScript_RayquazaSpotlight @ FLDEFF_RAYQUAZA_SPOTLIGHT .4byte gFieldEffectScript_DestroyDeoxysRock @ FLDEFF_DESTROY_DEOXYS_ROCK .4byte gFieldEffectScript_MoveDeoxysRock @ FLDEFF_MOVE_DEOXYS_ROCK @@ -121,7 +121,7 @@ gFieldEffectScript_UseSecretPowerCave:: @ 82DBB32 field_eff_callnative FldEff_UseSecretPowerCave field_eff_end -gFieldEffectScript_BikeHopTallGrass:: @ 82DBB38 +gFieldEffectScript_JumpTallGrass:: @ 82DBB38 field_eff_loadfadedpal_callnative gFieldEffectObjectPaletteInfo1, FldEff_JumpTallGrass field_eff_end @@ -129,7 +129,7 @@ gFieldEffectScript_SandFootprints:: @ 82DBB42 field_eff_loadfadedpal_callnative gFieldEffectObjectPaletteInfo0, FldEff_SandFootprints field_eff_end -gFieldEffectScript_BikeHopBigSplash:: @ 82DBB4C +gFieldEffectScript_JumpBigSplash:: @ 82DBB4C field_eff_loadfadedpal_callnative gFieldEffectObjectPaletteInfo0, FldEff_JumpBigSplash field_eff_end @@ -137,7 +137,7 @@ gFieldEffectScript_Splash:: @ 82DBB56 field_eff_loadfadedpal_callnative gFieldEffectObjectPaletteInfo0, FldEff_Splash field_eff_end -gFieldEffectScript_BikeHopSmallSplash:: @ 82DBB60 +gFieldEffectScript_JumpSmallSplash:: @ 82DBB60 field_eff_loadfadedpal_callnative gFieldEffectObjectPaletteInfo0, FldEff_JumpSmallSplash field_eff_end @@ -153,16 +153,16 @@ gFieldEffectScript_Unknown19:: @ 82DBB7E field_eff_loadfadedpal_callnative gFieldEffectObjectPaletteInfo1, FldEff_Unknown19 field_eff_end -gFieldEffectScript_UnusedGrass:: @ 82DBB88 - field_eff_loadfadedpal_callnative gFieldEffectObjectPaletteInfo1, FldEff_UnusedGrass +gFieldEffectScript_UnusedGrass2:: @ 82DBB88 + field_eff_loadfadedpal_callnative gFieldEffectObjectPaletteInfo1, FldEff_UnusedGrass2 field_eff_end gFieldEffectScript_Unknown21:: @ 82DBB92 field_eff_loadfadedpal_callnative gFieldEffectObjectPaletteInfo0, FldEff_Unknown21 field_eff_end -gFieldEffectScript_Unknown22:: @ 82DBB9C - field_eff_loadfadedpal_callnative gFieldEffectObjectPaletteInfo0, FldEff_Unknown22 +gFieldEffectScript_WaterSurfacing:: @ 82DBB9C + field_eff_loadfadedpal_callnative gFieldEffectObjectPaletteInfo0, FldEff_WaterSurfacing field_eff_end gFieldEffectScript_BerryTreeGrowthSparkle:: @ 82DBBA6 @@ -271,12 +271,12 @@ gFieldEffectScript_Unknown48:: @ 82DBC66 field_eff_callnative FldEff_NopA700 field_eff_end -gFieldEffectScript_JumpOutOfAsh:: @ 82DBC6C - field_eff_loadfadedpal_callnative gFieldEffectObjectPaletteInfo2, FldEff_PopOutOfAsh +gFieldEffectScript_AshPuff:: @ 82DBC6C + field_eff_loadfadedpal_callnative gFieldEffectObjectPaletteInfo2, FldEff_AshPuff field_eff_end -gFieldEffectScript_LavaridgeGymWarp:: @ 82DBC76 - field_eff_loadfadedpal_callnative gFieldEffectObjectPaletteInfo2, FldEff_LavaridgeGymWarp +gFieldEffectScript_AshLaunch:: @ 82DBC76 + field_eff_loadfadedpal_callnative gFieldEffectObjectPaletteInfo2, FldEff_AshLaunch field_eff_end gFieldEffectScript_SweetScent:: @ 82DBC80 @@ -332,8 +332,8 @@ gFieldEffectScript_UseTeleport:: @ 82DBCED field_eff_callnative FldEff_UseTeleport field_eff_end -gFieldEffectScript_Rayquaza:: @ 82DBCF3 - field_eff_callnative sub_80B8F98 +gFieldEffectScript_RayquazaSpotlight:: @ 82DBCF3 + field_eff_callnative FldEff_RayquazaSpotlight field_eff_end gFieldEffectScript_DestroyDeoxysRock:: @ 82DBCF9 diff --git a/data/maps/TrainerHill_Entrance/scripts.inc b/data/maps/TrainerHill_Entrance/scripts.inc index e1311b6d1..b3bec46b0 100644 --- a/data/maps/TrainerHill_Entrance/scripts.inc +++ b/data/maps/TrainerHill_Entrance/scripts.inc @@ -18,8 +18,8 @@ TrainerHill_Entrance_OnWarp: @ 82680CF TrainerHill_Entrance_OnResume: @ 82680D0 trainerhill_resumetimer setvar VAR_TEMP_0, 0 - trainerhill_clearresult - compare VAR_RESULT, 0 @ VAR_RESULT always 0 here + trainerhill_getusingereader + compare VAR_RESULT, FALSE @ VAR_RESULT always FALSE here goto_if_eq TrainerHill_Entrance_EventScript_TryFaceAttendant setobjectxy OBJ_EVENT_ID_PLAYER, 9, 6 applymovement OBJ_EVENT_ID_PLAYER, TrainerHill_Entrance_Movement_PlayerFaceAttendant diff --git a/data/scripts/trainer_hill.inc b/data/scripts/trainer_hill.inc index ca692e1ef..34d0462bb 100644 --- a/data/scripts/trainer_hill.inc +++ b/data/scripts/trainer_hill.inc @@ -32,8 +32,8 @@ EventScript_TrainerHillTimer:: @ 82C8393 TrainerHill_1F_EventScript_DummyWarpToEntranceCounter:: @ 82C83A6 setvar VAR_TEMP_2, 1 - trainerhill_clearresult - compare VAR_RESULT, 1 @ VAR_RESULT always 0 here + trainerhill_getusingereader + compare VAR_RESULT, TRUE @ VAR_RESULT always FALSE here goto_if_eq TrainerHill_1F_EventScript_WarpSilentToEntranceCounter end diff --git a/graphics/field_effects/pics/lavaridge_gym_warp.png b/graphics/field_effects/pics/ash_launch.png similarity index 100% rename from graphics/field_effects/pics/lavaridge_gym_warp.png rename to graphics/field_effects/pics/ash_launch.png diff --git a/graphics/field_effects/pics/jump_out_of_ash.png b/graphics/field_effects/pics/ash_puff.png similarity index 100% rename from graphics/field_effects/pics/jump_out_of_ash.png rename to graphics/field_effects/pics/ash_puff.png diff --git a/graphics/field_effects/pics/bike_hop_big_splash.png b/graphics/field_effects/pics/jump_big_splash.png similarity index 100% rename from graphics/field_effects/pics/bike_hop_big_splash.png rename to graphics/field_effects/pics/jump_big_splash.png diff --git a/graphics/field_effects/pics/bike_hop_small_splash.png b/graphics/field_effects/pics/jump_small_splash.png similarity index 100% rename from graphics/field_effects/pics/bike_hop_small_splash.png rename to graphics/field_effects/pics/jump_small_splash.png diff --git a/graphics/field_effects/pics/bike_hop_tall_grass.png b/graphics/field_effects/pics/jump_tall_grass.png similarity index 100% rename from graphics/field_effects/pics/bike_hop_tall_grass.png rename to graphics/field_effects/pics/jump_tall_grass.png diff --git a/graphics/field_effects/pics/unused_grass.png b/graphics/field_effects/pics/unused_grass.png deleted file mode 100644 index 65f4d97e29f9d738995b8e5e67053d3d0d99cd74..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 344 zcmV-e0jK_nP)%W`?qaOPi_P|w=Kqv~VzjK3q}9c9#iT*BgBYZ0)|W4J0002v zNklyiR;lE?ZvEWtaeaEh7>Yp#i3@awkjx2U|P7&dxZ qwRy^&G(+uS(C)MozC?BEcm4v??T4!bpiRC20000yiR;lE?ZvEWtaeaEh7>Yp#iUaJE)9r_=1fWg600000NkvXX Hu0mjfA|iaY delta 303 zcmV+~0nq-~0)+#RUw;7*NklqBOO3N`=9&Yf;Kro zMG`W_3_JU@#voIN(*F@7Zcz~X1N{!|6t+SHP!ezIr1Z(=mC>W+~=Oq;>EPAZgj1ejA@|^((Qi6$6&40)OEW0#zPTg1qEXlYu zFT}uNFm{f?DY^jWi}+(g4|5NmoF1NMh7Mg^qd|-XlT*vJSQS}(3lr0~zu248Ps_>n zJPR`YZ`;?Q-l$x0oNlua4)>eume;|lC;ysU;REh z!Sqx8Cz%W`?qaOPi_P|w=Kqv~VzjK3q}9c9#iT*BgBYZ0)|W4J0003H zNklqBOO3N`=9&Yf;KroMG`W_3_JU@#voIN(*F@7 zZcz~X1N{!|6t+SHP!ezIr1Z(=mC>W+~ z=Oq;>EPAZgj1ejA@|^((Qi6$6&By{QyEJxA-B<-I$+$Ex#K2-Oc8j_+vs3 za}S=J9-e204qaTML5u~HQ_Hnj66Vtc9*qhT&%gOdU3o`w0+t;Dqs9bTJZnF>$ z_nYgM*TJbL|Dc^^2K#XmTtz0QZ~~9heuBr#PfmAV{XROu^i%yOnfC>^`>Po`{Z!xK jB4$euanimPaused = FALSE; } -bool8 sub_8095B0C(struct ObjectEvent *objectEvent, struct Sprite *sprite) +bool8 DoFigure8Anim(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (sub_8097758(sprite)) + if (AnimateSpriteInFigure8(sprite)) { ShiftStillObjectEventCoords(objectEvent); objectEvent->triggerGroundEffectsOnStop = TRUE; @@ -6884,14 +6886,14 @@ bool8 sub_8095B0C(struct ObjectEvent *objectEvent, struct Sprite *sprite) bool8 MovementAction_Figure8_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8095AF0(objectEvent, sprite); + InitFigure8Anim(objectEvent, sprite); sprite->data[2] = 1; return MovementAction_Figure8_Step1(objectEvent, sprite); } bool8 MovementAction_Figure8_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (sub_8095B0C(objectEvent, sprite)) + if (DoFigure8Anim(objectEvent, sprite)) { sprite->data[2] = 2; return TRUE; @@ -8094,26 +8096,26 @@ void GroundEffect_Seaweed(struct ObjectEvent *objEvent, struct Sprite *sprite) } static void (*const sGroundEffectFuncs[])(struct ObjectEvent *objEvent, struct Sprite *sprite) = { - GroundEffect_SpawnOnTallGrass, - GroundEffect_StepOnTallGrass, - GroundEffect_SpawnOnLongGrass, - GroundEffect_StepOnLongGrass, - GroundEffect_WaterReflection, - GroundEffect_IceReflection, - GroundEffect_FlowingWater, - GroundEffect_SandTracks, - GroundEffect_DeepSandTracks, - GroundEffect_Ripple, - GroundEffect_StepOnPuddle, - GroundEffect_SandHeap, - GroundEffect_JumpOnTallGrass, - GroundEffect_JumpOnLongGrass, - GroundEffect_JumpOnShallowWater, - GroundEffect_JumpOnWater, - GroundEffect_JumpLandingDust, - GroundEffect_ShortGrass, - GroundEffect_HotSprings, - GroundEffect_Seaweed + GroundEffect_SpawnOnTallGrass, // GROUND_EFFECT_FLAG_TALL_GRASS_ON_SPAWN + GroundEffect_StepOnTallGrass, // GROUND_EFFECT_FLAG_TALL_GRASS_ON_MOVE + GroundEffect_SpawnOnLongGrass, // GROUND_EFFECT_FLAG_LONG_GRASS_ON_SPAWN + GroundEffect_StepOnLongGrass, // GROUND_EFFECT_FLAG_LONG_GRASS_ON_MOVE + GroundEffect_WaterReflection, // GROUND_EFFECT_FLAG_ICE_REFLECTION + GroundEffect_IceReflection, // GROUND_EFFECT_FLAG_REFLECTION + GroundEffect_FlowingWater, // GROUND_EFFECT_FLAG_SHALLOW_FLOWING_WATER + GroundEffect_SandTracks, // GROUND_EFFECT_FLAG_SAND + GroundEffect_DeepSandTracks, // GROUND_EFFECT_FLAG_DEEP_SAND + GroundEffect_Ripple, // GROUND_EFFECT_FLAG_RIPPLES + GroundEffect_StepOnPuddle, // GROUND_EFFECT_FLAG_PUDDLE + GroundEffect_SandHeap, // GROUND_EFFECT_FLAG_SAND_PILE + GroundEffect_JumpOnTallGrass, // GROUND_EFFECT_FLAG_LAND_IN_TALL_GRASS + GroundEffect_JumpOnLongGrass, // GROUND_EFFECT_FLAG_LAND_IN_LONG_GRASS + GroundEffect_JumpOnShallowWater, // GROUND_EFFECT_FLAG_LAND_IN_SHALLOW_WATER + GroundEffect_JumpOnWater, // GROUND_EFFECT_FLAG_LAND_IN_DEEP_WATER + GroundEffect_JumpLandingDust, // GROUND_EFFECT_FLAG_LAND_ON_NORMAL_GROUND + GroundEffect_ShortGrass, // GROUND_EFFECT_FLAG_SHORT_GRASS + GroundEffect_HotSprings, // GROUND_EFFECT_FLAG_HOT_SPRINGS + GroundEffect_Seaweed // GROUND_EFFECT_FLAG_SEAWEED }; static void DoFlaggedGroundEffects(struct ObjectEvent *objEvent, struct Sprite *sprite, u32 flags) @@ -8391,7 +8393,7 @@ bool8 sub_80976EC(struct Sprite *sprite) return FALSE; } -static const s8 gUnknown_0850E772[] = { +static const s8 sFigure8XOffsets[FIGURE_8_LENGTH] = { 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 1, 1, @@ -8403,7 +8405,7 @@ static const s8 gUnknown_0850E772[] = { 0, 1, 0, 0, 0, 0, 0, 0, }; -static const s8 gUnknown_0850E7BA[] = { +static const s8 sFigure8YOffsets[FIGURE_8_LENGTH] = { 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, @@ -8415,57 +8417,57 @@ static const s8 gUnknown_0850E7BA[] = { -1, -1, -1, -1, -1, -1, -1, -2, }; -s16 sub_8097728(s16 a1) +s16 GetFigure8YOffset(s16 idx) { - return gUnknown_0850E7BA[a1]; + return sFigure8YOffsets[idx]; } -s16 sub_809773C(s16 a1) +s16 GetFigure8XOffset(s16 idx) { - return gUnknown_0850E772[a1]; + return sFigure8XOffsets[idx]; } -void sub_8097750(struct Sprite *sprite) +static void InitSpriteForFigure8Anim(struct Sprite *sprite) { sprite->data[6] = 0; sprite->data[7] = 0; } -bool8 sub_8097758(struct Sprite *sprite) +static bool8 AnimateSpriteInFigure8(struct Sprite *sprite) { - bool8 result = FALSE; + bool8 finished = FALSE; switch(sprite->data[7]) { - case 0: - sprite->pos2.x += sub_809773C(sprite->data[6]); - sprite->pos2.y += sub_8097728(sprite->data[6]); - break; - case 1: - sprite->pos2.x -= sub_809773C(0x47 - sprite->data[6]); - sprite->pos2.y += sub_8097728(0x47 - sprite->data[6]); - break; - case 2: - sprite->pos2.x -= sub_809773C(sprite->data[6]); - sprite->pos2.y += sub_8097728(sprite->data[6]); - break; - case 3: - sprite->pos2.x += sub_809773C(0x47 - sprite->data[6]); - sprite->pos2.y += sub_8097728(0x47 - sprite->data[6]); - break; + case 0: + sprite->pos2.x += GetFigure8XOffset(sprite->data[6]); + sprite->pos2.y += GetFigure8YOffset(sprite->data[6]); + break; + case 1: + sprite->pos2.x -= GetFigure8XOffset((FIGURE_8_LENGTH - 1) - sprite->data[6]); + sprite->pos2.y += GetFigure8YOffset((FIGURE_8_LENGTH - 1) - sprite->data[6]); + break; + case 2: + sprite->pos2.x -= GetFigure8XOffset(sprite->data[6]); + sprite->pos2.y += GetFigure8YOffset(sprite->data[6]); + break; + case 3: + sprite->pos2.x += GetFigure8XOffset((FIGURE_8_LENGTH - 1) - sprite->data[6]); + sprite->pos2.y += GetFigure8YOffset((FIGURE_8_LENGTH - 1) - sprite->data[6]); + break; } - if(++sprite->data[6] == 0x48) + if (++sprite->data[6] == FIGURE_8_LENGTH) { sprite->data[6] = 0; sprite->data[7]++; } - if(sprite->data[7] == 0x4) + if (sprite->data[7] == 4) { sprite->pos2.y = 0; sprite->pos2.x = 0; - result = TRUE; + finished = TRUE; } - return result; + return finished; } static const s8 gUnknown_0850E802[] = { diff --git a/src/field_effect.c b/src/field_effect.c index 284d9b0e7..fbf6bd10c 100644 --- a/src/field_effect.c +++ b/src/field_effect.c @@ -39,30 +39,32 @@ EWRAM_DATA s32 gFieldEffectArguments[8] = {0}; // Static type declarations static void Task_PokecenterHeal(u8 taskId); -static void PokecenterHealEffect_0(struct Task *); -static void PokecenterHealEffect_1(struct Task *); -static void PokecenterHealEffect_2(struct Task *); -static void PokecenterHealEffect_3(struct Task *); +static void PokecenterHealEffect_Init(struct Task *); +static void PokecenterHealEffect_WaitForBallPlacement(struct Task *); +static void PokecenterHealEffect_WaitForBallFlashing(struct Task *); +static void PokecenterHealEffect_WaitForSoundAndEnd(struct Task *); +static u8 CreatePokecenterMonitorSprite(s16, s16); +static void SpriteCB_PokecenterMonitor(struct Sprite *); static void Task_HallOfFameRecord(u8 taskId); -static void HallOfFameRecordEffect_0(struct Task *); -static void HallOfFameRecordEffect_1(struct Task *); -static void HallOfFameRecordEffect_2(struct Task *); -static void HallOfFameRecordEffect_3(struct Task *); +static void HallOfFameRecordEffect_Init(struct Task *); +static void HallOfFameRecordEffect_WaitForBallPlacement(struct Task *); +static void HallOfFameRecordEffect_WaitForBallFlashing(struct Task *); +static void HallOfFameRecordEffect_WaitForSoundAndEnd(struct Task *); +static void CreateHofMonitorSprite(s16, s16, s16, bool8); +static void SpriteCB_HallOfFameMonitor(struct Sprite *); -static u8 CreatePokeballGlowSprite(s16, s16, s16, u16); +static u8 CreateGlowingPokeballsEffect(s16, s16, s16, bool16); static void SpriteCB_PokeballGlowEffect(struct Sprite *); -static void PokeballGlowEffect_0(struct Sprite *); -static void PokeballGlowEffect_1(struct Sprite *); -static void PokeballGlowEffect_2(struct Sprite *); -static void PokeballGlowEffect_3(struct Sprite *); -static void PokeballGlowEffect_4(struct Sprite *); -static void PokeballGlowEffect_5(struct Sprite *); -static void PokeballGlowEffect_6(struct Sprite *); -static void PokeballGlowEffect_7(struct Sprite *); - -static u8 PokecenterHealEffectHelper(s16, s16); -static void HallOfFameRecordEffectHelper(s16, s16, s16, u8); +static void PokeballGlowEffect_PlaceBalls(struct Sprite *); +static void PokeballGlowEffect_TryPlaySe(struct Sprite *); +static void PokeballGlowEffect_Flash1(struct Sprite *); +static void PokeballGlowEffect_Flash2(struct Sprite *); +static void PokeballGlowEffect_WaitAfterFlash(struct Sprite *); +static void PokeballGlowEffect_Dummy(struct Sprite *); +static void PokeballGlowEffect_WaitForSound(struct Sprite *); +static void PokeballGlowEffect_Idle(struct Sprite *); +static void SpriteCB_PokeballGlow(struct Sprite *); static void FieldCallback_UseFly(void); static void Task_UseFly(u8); @@ -70,169 +72,165 @@ static void FieldCallback_FlyIntoMap(void); static void Task_FlyIntoMap(u8); static void Task_FallWarpFieldEffect(u8); -static bool8 FallWarpEffect_0(struct Task *); -static bool8 FallWarpEffect_1(struct Task *); -static bool8 FallWarpEffect_2(struct Task *); -static bool8 FallWarpEffect_3(struct Task *); -static bool8 FallWarpEffect_4(struct Task *); -static bool8 FallWarpEffect_5(struct Task *); -static bool8 FallWarpEffect_6(struct Task *); +static bool8 FallWarpEffect_Init(struct Task *); +static bool8 FallWarpEffect_WaitWeather(struct Task *); +static bool8 FallWarpEffect_StartFall(struct Task *); +static bool8 FallWarpEffect_Fall(struct Task *); +static bool8 FallWarpEffect_Land(struct Task *); +static bool8 FallWarpEffect_CameraShake(struct Task *); +static bool8 FallWarpEffect_End(struct Task *); static void Task_EscalatorWarpOut(u8); -static bool8 EscalatorWarpOutEffect_0(struct Task *); -static bool8 EscalatorWarpOutEffect_1(struct Task *); -static bool8 EscalatorWarpOutEffect_2(struct Task *); -static bool8 EscalatorWarpOutEffect_3(struct Task *); -static bool8 EscalatorWarpOutEffect_4(struct Task *); -static bool8 EscalatorWarpOutEffect_5(struct Task *); - -static void sub_80B6FB8(struct Task *); -static void sub_80B7004(struct Task *); -static void sub_80B7050(void); -static void sub_80B7060(void); +static bool8 EscalatorWarpOut_Init(struct Task *); +static bool8 EscalatorWarpOut_WaitForPlayer(struct Task *); +static bool8 EscalatorWarpOut_Up_Ride(struct Task *); +static bool8 EscalatorWarpOut_Up_End(struct Task *); +static bool8 EscalatorWarpOut_Down_Ride(struct Task *); +static bool8 EscalatorWarpOut_Down_End(struct Task *); +static void RideUpEscalatorOut(struct Task *); +static void RideDownEscalatorOut(struct Task *); +static void FadeOutAtEndOfEscalator(void); +static void WarpAtEndOfEscalator(void); static void FieldCallback_EscalatorWarpIn(void); static void Task_EscalatorWarpIn(u8); -static bool8 EscalatorWarpInEffect_0(struct Task *); -static bool8 EscalatorWarpInEffect_1(struct Task *); -static bool8 EscalatorWarpInEffect_2(struct Task *); -static bool8 EscalatorWarpInEffect_3(struct Task *); -static bool8 EscalatorWarpInEffect_4(struct Task *); -static bool8 EscalatorWarpInEffect_5(struct Task *); -static bool8 EscalatorWarpInEffect_6(struct Task *); +static bool8 EscalatorWarpIn_Init(struct Task *); +static bool8 EscalatorWarpIn_Down_Init(struct Task *); +static bool8 EscalatorWarpIn_Down_Ride(struct Task *); +static bool8 EscalatorWarpIn_Up_Init(struct Task *); +static bool8 EscalatorWarpIn_Up_Ride(struct Task *); +static bool8 EscalatorWarpIn_WaitForMovement(struct Task *); +static bool8 EscalatorWarpIn_End(struct Task *); static void Task_UseWaterfall(u8); -static bool8 WaterfallFieldEffect_0(struct Task *, struct ObjectEvent *); -static bool8 WaterfallFieldEffect_1(struct Task *, struct ObjectEvent *); -static bool8 WaterfallFieldEffect_2(struct Task *, struct ObjectEvent *); -static bool8 WaterfallFieldEffect_3(struct Task *, struct ObjectEvent *); -static bool8 WaterfallFieldEffect_4(struct Task *, struct ObjectEvent *); +static bool8 WaterfallFieldEffect_Init(struct Task *, struct ObjectEvent *); +static bool8 WaterfallFieldEffect_ShowMon(struct Task *, struct ObjectEvent *); +static bool8 WaterfallFieldEffect_WaitForShowMon(struct Task *, struct ObjectEvent *); +static bool8 WaterfallFieldEffect_RideUp(struct Task *, struct ObjectEvent *); +static bool8 WaterfallFieldEffect_ContinueRideOrEnd(struct Task *, struct ObjectEvent *); static void Task_UseDive(u8); -static bool8 DiveFieldEffect_0(struct Task *); -static bool8 DiveFieldEffect_1(struct Task *); -static bool8 DiveFieldEffect_2(struct Task *); +static bool8 DiveFieldEffect_Init(struct Task *); +static bool8 DiveFieldEffect_ShowMon(struct Task *); +static bool8 DiveFieldEffect_TryWarp(struct Task *); static void Task_LavaridgeGymB1FWarp(u8); -static bool8 LavaridgeGymB1FWarpEffect_0(struct Task *, struct ObjectEvent *, struct Sprite *); -static bool8 LavaridgeGymB1FWarpEffect_1(struct Task *, struct ObjectEvent *, struct Sprite *); -static bool8 LavaridgeGymB1FWarpEffect_2(struct Task *, struct ObjectEvent *, struct Sprite *); -static bool8 LavaridgeGymB1FWarpEffect_3(struct Task *, struct ObjectEvent *, struct Sprite *); -static bool8 LavaridgeGymB1FWarpEffect_4(struct Task *, struct ObjectEvent *, struct Sprite *); -static bool8 LavaridgeGymB1FWarpEffect_5(struct Task *, struct ObjectEvent *, struct Sprite *); +static bool8 LavaridgeGymB1FWarpEffect_Init(struct Task *, struct ObjectEvent *, struct Sprite *); +static bool8 LavaridgeGymB1FWarpEffect_CameraShake(struct Task *, struct ObjectEvent *, struct Sprite *); +static bool8 LavaridgeGymB1FWarpEffect_Launch(struct Task *, struct ObjectEvent *, struct Sprite *); +static bool8 LavaridgeGymB1FWarpEffect_Rise(struct Task *, struct ObjectEvent *, struct Sprite *); +static bool8 LavaridgeGymB1FWarpEffect_FadeOut(struct Task *, struct ObjectEvent *, struct Sprite *); +static bool8 LavaridgeGymB1FWarpEffect_Warp(struct Task *, struct ObjectEvent *, struct Sprite *); static void FieldCB_LavaridgeGymB1FWarpExit(void); static void Task_LavaridgeGymB1FWarpExit(u8); -static bool8 LavaridgeGymB1FWarpExitEffect_0(struct Task *, struct ObjectEvent *, struct Sprite *); -static bool8 LavaridgeGymB1FWarpExitEffect_1(struct Task *, struct ObjectEvent *, struct Sprite *); -static bool8 LavaridgeGymB1FWarpExitEffect_2(struct Task *, struct ObjectEvent *, struct Sprite *); -static bool8 LavaridgeGymB1FWarpExitEffect_3(struct Task *, struct ObjectEvent *, struct Sprite *); +static bool8 LavaridgeGymB1FWarpExitEffect_Init(struct Task *, struct ObjectEvent *, struct Sprite *); +static bool8 LavaridgeGymB1FWarpExitEffect_StartPopOut(struct Task *, struct ObjectEvent *, struct Sprite *); +static bool8 LavaridgeGymB1FWarpExitEffect_PopOut(struct Task *, struct ObjectEvent *, struct Sprite *); +static bool8 LavaridgeGymB1FWarpExitEffect_End(struct Task *, struct ObjectEvent *, struct Sprite *); static void Task_LavaridgeGym1FWarp(u8); -static bool8 LavaridgeGym1FWarpEffect_0(struct Task *, struct ObjectEvent *, struct Sprite *); -static bool8 LavaridgeGym1FWarpEffect_1(struct Task *, struct ObjectEvent *, struct Sprite *); -static bool8 LavaridgeGym1FWarpEffect_2(struct Task *, struct ObjectEvent *, struct Sprite *); -static bool8 LavaridgeGym1FWarpEffect_3(struct Task *, struct ObjectEvent *, struct Sprite *); -static bool8 LavaridgeGym1FWarpEffect_4(struct Task *, struct ObjectEvent *, struct Sprite *); +static bool8 LavaridgeGym1FWarpEffect_Init(struct Task *, struct ObjectEvent *, struct Sprite *); +static bool8 LavaridgeGym1FWarpEffect_AshPuff(struct Task *, struct ObjectEvent *, struct Sprite *); +static bool8 LavaridgeGym1FWarpEffect_Disappear(struct Task *, struct ObjectEvent *, struct Sprite *); +static bool8 LavaridgeGym1FWarpEffect_FadeOut(struct Task *, struct ObjectEvent *, struct Sprite *); +static bool8 LavaridgeGym1FWarpEffect_Warp(struct Task *, struct ObjectEvent *, struct Sprite *); static void Task_EscapeRopeWarpOut(u8); -static void EscapeRopeWarpOutFieldEffect_0(struct Task *); -static void EscapeRopeWarpOutFieldEffect_1(struct Task *); +static void EscapeRopeWarpOutEffect_Init(struct Task *); +static void EscapeRopeWarpOutEffect_Spin(struct Task *); static void FieldCallback_EscapeRopeWarpIn(void); static void Task_EscapeRopeWarpIn(u8); -static void EscapeRopeWarpInFieldEffect_0(struct Task *); -static void EscapeRopeWarpInFieldEffect_1(struct Task *); +static void EscapeRopeWarpInEffect_Init(struct Task *); +static void EscapeRopeWarpInEffect_Spin(struct Task *); static void Task_TeleportWarpOut(u8); -static void TeleportWarpOutFieldEffect_0(struct Task*); -static void TeleportWarpOutFieldEffect_1(struct Task*); -static void TeleportWarpOutFieldEffect_2(struct Task*); -static void TeleportWarpOutFieldEffect_3(struct Task*); +static void TeleportWarpOutFieldEffect_Init(struct Task*); +static void TeleportWarpOutFieldEffect_SpinGround(struct Task*); +static void TeleportWarpOutFieldEffect_SpinExit(struct Task*); +static void TeleportWarpOutFieldEffect_End(struct Task*); static void FieldCallback_TeleportWarpIn(void); static void Task_TeleportWarpIn(u8); -static void TeleportWarpInFieldEffect_0(struct Task *); -static void TeleportWarpInFieldEffect_1(struct Task *); -static void TeleportWarpInFieldEffect_2(struct Task *); +static void TeleportWarpInFieldEffect_Init(struct Task *); +static void TeleportWarpInFieldEffect_SpinEnter(struct Task *); +static void TeleportWarpInFieldEffect_SpinGround(struct Task *); static void Task_FieldMoveShowMonOutdoors(u8); -static void FieldMoveShowMonOutdoorsEffect_0(struct Task *); -static void FieldMoveShowMonOutdoorsEffect_1(struct Task *); -static void FieldMoveShowMonOutdoorsEffect_2(struct Task *); -static void FieldMoveShowMonOutdoorsEffect_3(struct Task *); -static void FieldMoveShowMonOutdoorsEffect_4(struct Task *); -static void FieldMoveShowMonOutdoorsEffect_5(struct Task *); -static void FieldMoveShowMonOutdoorsEffect_6(struct Task *); - +static void FieldMoveShowMonOutdoorsEffect_Init(struct Task *); +static void FieldMoveShowMonOutdoorsEffect_LoadGfx(struct Task *); +static void FieldMoveShowMonOutdoorsEffect_CreateBanner(struct Task *); +static void FieldMoveShowMonOutdoorsEffect_WaitForMon(struct Task *); +static void FieldMoveShowMonOutdoorsEffect_ShrinkBanner(struct Task *); +static void FieldMoveShowMonOutdoorsEffect_RestoreBg(struct Task *); +static void FieldMoveShowMonOutdoorsEffect_End(struct Task *); static void VBlankCB_FieldMoveShowMonOutdoors(void); -static void sub_80B8874(u16); +static void LoadFieldMoveOutdoorStreaksTilemap(u16); static void Task_FieldMoveShowMonIndoors(u8); -static void FieldMoveShowMonIndoorsEffect_0(struct Task *); -static void FieldMoveShowMonIndoorsEffect_1(struct Task *); -static void FieldMoveShowMonIndoorsEffect_2(struct Task *); -static void FieldMoveShowMonIndoorsEffect_3(struct Task *); -static void FieldMoveShowMonIndoorsEffect_4(struct Task *); -static void FieldMoveShowMonIndoorsEffect_5(struct Task *); -static void FieldMoveShowMonIndoorsEffect_6(struct Task *); - +static void FieldMoveShowMonIndoorsEffect_Init(struct Task *); +static void FieldMoveShowMonIndoorsEffect_LoadGfx(struct Task *); +static void FieldMoveShowMonIndoorsEffect_SlideBannerOn(struct Task *); +static void FieldMoveShowMonIndoorsEffect_WaitForMon(struct Task *); +static void FieldMoveShowMonIndoorsEffect_RestoreBg(struct Task *); +static void FieldMoveShowMonIndoorsEffect_SlideBannerOff(struct Task *); +static void FieldMoveShowMonIndoorsEffect_End(struct Task *); static void VBlankCB_FieldMoveShowMonIndoors(void); -static void sub_80B8B28(struct Task *); -static bool8 sub_80B8B38(struct Task *); -static bool8 sub_80B8BF0(struct Task *); +static void AnimateIndoorShowMonBg(struct Task *); +static bool8 SlideIndoorBannerOnscreen(struct Task *); +static bool8 SlideIndoorBannerOffscreen(struct Task *); -static u8 sub_80B8C60(u32, u32, u32); -static void sub_80B8CC0(struct Sprite *); -static void sub_80B8D04(struct Sprite *); -static void sub_80B8D20(struct Sprite *); +static u8 InitFieldMoveMonSprite(u32, u32, u32); +static void SpriteCB_FieldMoveMonSlideOnscreen(struct Sprite *); +static void SpriteCB_FieldMoveMonWaitAfterCry(struct Sprite *); +static void SpriteCB_FieldMoveMonSlideOffscreen(struct Sprite *); static void Task_SurfFieldEffect(u8); -static void SurfFieldEffect_1(struct Task *); -static void SurfFieldEffect_2(struct Task *); -static void SurfFieldEffect_3(struct Task *); -static void SurfFieldEffect_4(struct Task *); -static void SurfFieldEffect_5(struct Task *); +static void SurfFieldEffect_Init(struct Task *); +static void SurfFieldEffect_FieldMovePose(struct Task *); +static void SurfFieldEffect_ShowMon(struct Task *); +static void SurfFieldEffect_JumpOnSurfBlob(struct Task *); +static void SurfFieldEffect_End(struct Task *); static void SpriteCB_NPCFlyOut(struct Sprite *); static void Task_FlyOut(u8); -static void FlyOutFieldEffect_0(struct Task *); -static void FlyOutFieldEffect_1(struct Task *); -static void FlyOutFieldEffect_2(struct Task *); -static void FlyOutFieldEffect_3(struct Task *); -static void FlyOutFieldEffect_4(struct Task *); -static void FlyOutFieldEffect_5(struct Task *); -static void FlyOutFieldEffect_6(struct Task *); -static void FlyOutFieldEffect_7(struct Task *); -static void FlyOutFieldEffect_8(struct Task *); +static void FlyOutFieldEffect_FieldMovePose(struct Task *); +static void FlyOutFieldEffect_ShowMon(struct Task *); +static void FlyOutFieldEffect_BirdLeaveBall(struct Task *); +static void FlyOutFieldEffect_WaitBirdLeave(struct Task *); +static void FlyOutFieldEffect_BirdSwoopDown(struct Task *); +static void FlyOutFieldEffect_JumpOnBird(struct Task *); +static void FlyOutFieldEffect_FlyOffWithBird(struct Task *); +static void FlyOutFieldEffect_WaitFlyOff(struct Task *); +static void FlyOutFieldEffect_End(struct Task *); -static u8 sub_80B94C4(void); -static u8 sub_80B9508(u8); -static void sub_80B9524(u8); -static void sub_80B9560(u8, u8); -static void sub_80B957C(struct Sprite *); -static void sub_80B963C(struct Sprite *); +static u8 CreateFlyBirdSprite(void); +static u8 GetFlyBirdAnimCompleted(u8); +static void StartFlyBirdSwoopDown(u8); +static void SetFlyBirdPlayerSpriteId(u8, u8); +static void SpriteCB_FlyBirdLeaveBall(struct Sprite *); +static void SpriteCB_FlyBirdSwoopDown(struct Sprite *); static void Task_FlyIn(u8); -static void FlyInFieldEffect_0(struct Task *); -static void FlyInFieldEffect_1(struct Task *); -static void FlyInFieldEffect_2(struct Task *); -static void FlyInFieldEffect_3(struct Task *); -static void FlyInFieldEffect_4(struct Task *); -static void FlyInFieldEffect_5(struct Task *); -static void FlyInFieldEffect_6(struct Task *); +static void FlyInFieldEffect_BirdSwoopDown(struct Task *); +static void FlyInFieldEffect_FlyInWithBird(struct Task *); +static void FlyInFieldEffect_JumpOffBird(struct Task *); +static void FlyInFieldEffect_FieldMovePose(struct Task *); +static void FlyInFieldEffect_BirdReturnToBall(struct Task *); +static void FlyInFieldEffect_WaitBirdReturn(struct Task *); +static void FlyInFieldEffect_End(struct Task *); static void Task_DestroyDeoxysRock(u8 taskId); -static void DestroyDeoxysRockFieldEffect_0(s16*, u8); -static void DestroyDeoxysRockFieldEffect_1(s16*, u8); -static void DestroyDeoxysRockFieldEffect_2(s16*, u8); +static void DestroyDeoxysRockEffect_CameraShake(s16*, u8); +static void DestroyDeoxysRockEffect_RockFragments(s16*, u8); +static void DestroyDeoxysRockEffect_WaitAndEnd(s16*, u8); +static void CreateDeoxysRockFragments(struct Sprite*); +static void SpriteCB_DeoxysRockFragment(struct Sprite* sprite); -static void sub_80B9DB8(struct Sprite* sprite); static void Task_MoveDeoxysRock(u8 taskId); -static void sub_80B9D24(struct Sprite*); - // Static RAM declarations static u8 sActiveList[32]; @@ -244,34 +242,33 @@ extern const struct CompressedSpriteSheet gTrainerFrontPicTable[]; extern u8 *gFieldEffectScriptPointers[]; extern const struct SpriteTemplate *const gFieldEffectObjectTemplatePointers[]; -// .rodata -const u32 gNewGameBirchPic[] = INCBIN_U32("graphics/birch_speech/birch.4bpp"); -const u32 gUnusedBirchBeauty[] = INCBIN_U32("graphics/unused/intro_birch_beauty.4bpp"); -const u16 gNewGameBirchPalette[16] = INCBIN_U16("graphics/birch_speech/birch.gbapal"); -const u32 gSpriteImage_855A970[] = INCBIN_U32("graphics/misc/pokeball_glow.4bpp"); -const u16 gFieldEffectObjectPalette4[16] = INCBIN_U16("graphics/field_effects/palettes/04.gbapal"); -const u32 gSpriteImage_855A9B0[] = INCBIN_U32("graphics/misc/pokecenter_monitor/0.4bpp"); -const u32 gSpriteImage_855AA70[] = INCBIN_U32("graphics/misc/pokecenter_monitor/1.4bpp"); -const u32 gSpriteImage_855AB30[] = INCBIN_U32("graphics/misc/big_hof_monitor.4bpp"); -const u8 gSpriteImage_855AD30[] = INCBIN_U8("graphics/misc/small_hof_monitor.4bpp"); -const u16 gFieldEffectObjectPalette5[16] = INCBIN_U16("graphics/field_effects/palettes/05.gbapal"); +static const u32 sNewGameBirch_Gfx[] = INCBIN_U32("graphics/birch_speech/birch.4bpp"); +static const u32 sUnusedBirchBeauty[] = INCBIN_U32("graphics/unused/intro_birch_beauty.4bpp"); +static const u16 sNewGameBirch_Pal[16] = INCBIN_U16("graphics/birch_speech/birch.gbapal"); +static const u32 sPokeballGlow_Gfx[] = INCBIN_U32("graphics/misc/pokeball_glow.4bpp"); +static const u16 sFieldEffectObjectPalette4[16] = INCBIN_U16("graphics/field_effects/palettes/04.gbapal"); +static const u32 sPokecenterMonitor0_Gfx[] = INCBIN_U32("graphics/misc/pokecenter_monitor/0.4bpp"); +static const u32 sPokecenterMonitor1_Gfx[] = INCBIN_U32("graphics/misc/pokecenter_monitor/1.4bpp"); +static const u32 sHofMonitorBig_Gfx[] = INCBIN_U32("graphics/misc/hof_monitor_big.4bpp"); +static const u8 sHofMonitorSmall_Gfx[] = INCBIN_U8("graphics/misc/hof_monitor_small.4bpp"); +static const u16 sFieldEffectObjectPalette5[16] = INCBIN_U16("graphics/field_effects/palettes/05.gbapal"); // Graphics for the lights streaking past your Pokemon when it uses a field move. -const u32 gFieldMoveStreaksTiles[] = INCBIN_U32("graphics/misc/field_move_streaks.4bpp"); -const u16 gFieldMoveStreaksPalette[16] = INCBIN_U16("graphics/misc/field_move_streaks.gbapal"); -const u16 gFieldMoveStreaksTilemap[] = INCBIN_U16("graphics/misc/field_move_streaks_map.bin"); +static const u32 sFieldMoveStreaksOutdoors_Gfx[] = INCBIN_U32("graphics/misc/field_move_streaks.4bpp"); +static const u16 sFieldMoveStreaksOutdoors_Pal[16] = INCBIN_U16("graphics/misc/field_move_streaks.gbapal"); +static const u16 sFieldMoveStreaksOutdoors_Tilemap[320] = INCBIN_U16("graphics/misc/field_move_streaks_map.bin"); -// The following light streaks effect is used when the map is dark (e.g. a cave). -const u32 gDarknessFieldMoveStreaksTiles[] = INCBIN_U32("graphics/misc/darkness_field_move_streaks.4bpp"); -const u16 gDarknessFieldMoveStreaksPalette[16] = INCBIN_U16("graphics/misc/darkness_field_move_streaks.gbapal"); -const u16 gDarknessFieldMoveStreaksTilemap[] = INCBIN_U16("graphics/misc/darkness_field_move_streaks_map.bin"); +// The following light streaks effect is used when the map is indoors +static const u32 sFieldMoveStreaksIndoors_Gfx[] = INCBIN_U32("graphics/misc/darkness_field_move_streaks.4bpp"); +static const u16 sFieldMoveStreaksIndoors_Pal[16] = INCBIN_U16("graphics/misc/darkness_field_move_streaks.gbapal"); +static const u16 sFieldMoveStreaksIndoors_Tilemap[320] = INCBIN_U16("graphics/misc/darkness_field_move_streaks_map.bin"); -const u16 gUnknown_0855B610[16] = INCBIN_U16("graphics/misc/spotlight.gbapal"); -const u8 gUnknown_0855B630[] = INCBIN_U8("graphics/misc/spotlight.4bpp"); -const u8 gUnknown_0855C170[] = INCBIN_U8("graphics/unknown/unknown_55C170.4bpp"); -const u8 gUnknown_0855C190[] = INCBIN_U8("graphics/unknown/unknown_55C190.4bpp"); -const u8 gUnknown_0855C1B0[] = INCBIN_U8("graphics/unknown/unknown_55C1B0.4bpp"); -const u8 gUnknown_0855C1D0[] = INCBIN_U8("graphics/unknown/unknown_55C1D0.4bpp"); +static const u16 sSpotlight_Pal[16] = INCBIN_U16("graphics/misc/spotlight.gbapal"); +static const u8 sSpotlight_Gfx[] = INCBIN_U8("graphics/misc/spotlight.4bpp"); +static const u8 sRockFragment_TopLeft[] = INCBIN_U8("graphics/misc/deoxys_rock_fragment_top_left.4bpp"); +static const u8 sRockFragment_TopRight[] = INCBIN_U8("graphics/misc/deoxys_rock_fragment_top_right.4bpp"); +static const u8 sRockFragment_BottomLeft[] = INCBIN_U8("graphics/misc/deoxys_rock_fragment_bottom_left.4bpp"); +static const u8 sRockFragment_BottomRight[] = INCBIN_U8("graphics/misc/deoxys_rock_fragment_bottom_right.4bpp"); bool8 (*const gFieldEffectScriptFuncs[])(u8 **, u32 *) = { @@ -285,7 +282,7 @@ bool8 (*const gFieldEffectScriptFuncs[])(u8 **, u32 *) = FieldEffectCmd_loadfadedpal_callnative, }; -const struct OamData gNewGameBirchOamAttributes = +static const struct OamData sOam_64x64 = { .y = 0, .affineMode = ST_OAM_AFFINE_OFF, @@ -299,7 +296,7 @@ const struct OamData gNewGameBirchOamAttributes = .paletteNum = 0, }; -const struct OamData gOamData_855C218 = +static const struct OamData sOam_8x8 = { .y = 0, .affineMode = ST_OAM_AFFINE_OFF, @@ -313,7 +310,7 @@ const struct OamData gOamData_855C218 = .paletteNum = 0, }; -const struct OamData gOamData_855C220 = +static const struct OamData sOam_16x16 = { .y = 0, .affineMode = ST_OAM_AFFINE_OFF, @@ -327,52 +324,52 @@ const struct OamData gOamData_855C220 = .paletteNum = 0, }; -const struct SpriteFrameImage gNewGameBirchPicTable[] = +static const struct SpriteFrameImage sPicTable_NewGameBirch[] = { - obj_frame_tiles(gNewGameBirchPic) + obj_frame_tiles(sNewGameBirch_Gfx) }; -const struct SpritePalette gNewGameBirchObjectPaletteInfo = +static const struct SpritePalette sSpritePalette_NewGameBirch = { - .data = gNewGameBirchPalette, - .tag = 0x1006 + .data = sNewGameBirch_Pal, + .tag = FLDEFF_PAL_TAG_6 }; -const union AnimCmd gNewGameBirchImageAnim[] = +static const union AnimCmd sAnim_NewGameBirch[] = { ANIMCMD_FRAME(.imageValue = 0, .duration = 1), ANIMCMD_END }; -const union AnimCmd *const gNewGameBirchImageAnimTable[] = +static const union AnimCmd *const sAnimTable_NewGameBirch[] = { - gNewGameBirchImageAnim + sAnim_NewGameBirch }; -const struct SpriteTemplate gNewGameBirchObjectTemplate = +static const struct SpriteTemplate sSpriteTemplate_NewGameBirch = { .tileTag = 0xFFFF, - .paletteTag = 4102, - .oam = &gNewGameBirchOamAttributes, - .anims = gNewGameBirchImageAnimTable, - .images = gNewGameBirchPicTable, + .paletteTag = FLDEFF_PAL_TAG_6, + .oam = &sOam_64x64, + .anims = sAnimTable_NewGameBirch, + .images = sPicTable_NewGameBirch, .affineAnims = gDummySpriteAffineAnimTable, .callback = SpriteCallbackDummy }; const struct SpritePalette gFieldEffectObjectPaletteInfo4 = { - .data = gFieldEffectObjectPalette4, - .tag = 0x1007 + .data = sFieldEffectObjectPalette4, + .tag = FLDEFF_PAL_TAG_7 }; const struct SpritePalette gFieldEffectObjectPaletteInfo5 = { - .data = gFieldEffectObjectPalette5, - .tag = 0x1010 + .data = sFieldEffectObjectPalette5, + .tag = FLDEFF_PAL_TAG_16 }; -const struct OamData gOamData_855C26C = +static const struct OamData sOam_32x16 = { .y = 0, .affineMode = ST_OAM_AFFINE_OFF, @@ -386,28 +383,28 @@ const struct OamData gOamData_855C26C = .paletteNum = 0, }; -const struct SpriteFrameImage gSpriteImageTable_855C274[] = +static const struct SpriteFrameImage sPicTable_PokeballGlow[] = { - obj_frame_tiles(gSpriteImage_855A970) + obj_frame_tiles(sPokeballGlow_Gfx) }; -const struct SpriteFrameImage gSpriteImageTable_855C27C[] = +static const struct SpriteFrameImage sPicTable_PokecenterMonitor[] = { - obj_frame_tiles(gSpriteImage_855A9B0), - obj_frame_tiles(gSpriteImage_855AA70) + obj_frame_tiles(sPokecenterMonitor0_Gfx), + obj_frame_tiles(sPokecenterMonitor1_Gfx) }; -const struct SpriteFrameImage gSpriteImageTable_855C28C[] = +static const struct SpriteFrameImage sPicTable_HofMonitorBig[] = { - obj_frame_tiles(gSpriteImage_855AB30) + obj_frame_tiles(sHofMonitorBig_Gfx) }; -const struct SpriteFrameImage gSpriteImageTable_855C294[] = +static const struct SpriteFrameImage sPicTable_HofMonitorSmall[] = { - {.data = gSpriteImage_855AD30, .size = 0x200} // the macro breaks down here + {.data = sHofMonitorSmall_Gfx, .size = 0x200} // the macro breaks down here }; -const struct Subsprite gSubspriteTable_855C29C[] = +static const struct Subsprite sSubsprites_PokecenterMonitor[] = { { .x = -12, @@ -443,9 +440,9 @@ const struct Subsprite gSubspriteTable_855C29C[] = } }; -const struct SubspriteTable gUnknown_0855C2AC = subsprite_table(gSubspriteTable_855C29C); +static const struct SubspriteTable sSubspriteTable_PokecenterMonitor = subsprite_table(sSubsprites_PokecenterMonitor); -const struct Subsprite gSubspriteTable_855C2B4[] = +static const struct Subsprite sSubsprites_HofMonitorBig[] = { { .x = -32, @@ -481,7 +478,7 @@ const struct Subsprite gSubspriteTable_855C2B4[] = } }; -const struct SubspriteTable gUnknown_0855C2C4 = subsprite_table(gSubspriteTable_855C2B4); +static const struct SubspriteTable sSubspriteTable_HofMonitorBig = subsprite_table(sSubsprites_HofMonitorBig); const union AnimCmd gSpriteAnim_855C2CC[] = { @@ -508,84 +505,84 @@ const union AnimCmd *const gSpriteAnimTable_855C2F8[] = gSpriteAnim_855C2D4 }; -const union AnimCmd *const gSpriteAnimTable_855C300[] = +static const union AnimCmd *const sAnimTable_HofMonitor[] = { gSpriteAnim_855C2CC }; -const struct SpriteTemplate gSpriteTemplate_855C304 = +static const struct SpriteTemplate sSpriteTemplate_PokeballGlow = { .tileTag = 0xFFFF, - .paletteTag = 4103, - .oam = &gOamData_855C218, + .paletteTag = FLDEFF_PAL_TAG_7, + .oam = &sOam_8x8, .anims = gSpriteAnimTable_855C2F8, - .images = gSpriteImageTable_855C274, + .images = sPicTable_PokeballGlow, .affineAnims = gDummySpriteAffineAnimTable, .callback = SpriteCB_PokeballGlow }; -const struct SpriteTemplate gSpriteTemplate_855C31C = +static const struct SpriteTemplate sSpriteTemplate_PokecenterMonitor = { .tileTag = 0xFFFF, - .paletteTag = 4100, - .oam = &gOamData_855C220, + .paletteTag = FLDEFF_PAL_TAG_4, + .oam = &sOam_16x16, .anims = gSpriteAnimTable_855C2F8, - .images = gSpriteImageTable_855C27C, + .images = sPicTable_PokecenterMonitor, .affineAnims = gDummySpriteAffineAnimTable, .callback = SpriteCB_PokecenterMonitor }; -const struct SpriteTemplate gSpriteTemplate_855C334 = +static const struct SpriteTemplate sSpriteTemplate_HofMonitorBig = { .tileTag = 0xFFFF, - .paletteTag = 4112, - .oam = &gOamData_855C220, - .anims = gSpriteAnimTable_855C300, - .images = gSpriteImageTable_855C28C, + .paletteTag = FLDEFF_PAL_TAG_16, + .oam = &sOam_16x16, + .anims = sAnimTable_HofMonitor, + .images = sPicTable_HofMonitorBig, .affineAnims = gDummySpriteAffineAnimTable, .callback = SpriteCB_HallOfFameMonitor }; -const struct SpriteTemplate gSpriteTemplate_855C34C = +static const struct SpriteTemplate sSpriteTemplate_HofMonitorSmall = { .tileTag = 0xFFFF, - .paletteTag = 4112, - .oam = &gOamData_855C26C, - .anims = gSpriteAnimTable_855C300, - .images = gSpriteImageTable_855C294, + .paletteTag = FLDEFF_PAL_TAG_16, + .oam = &sOam_32x16, + .anims = sAnimTable_HofMonitor, + .images = sPicTable_HofMonitorSmall, .affineAnims = gDummySpriteAffineAnimTable, .callback = SpriteCB_HallOfFameMonitor }; void (*const sPokecenterHealEffectFuncs[])(struct Task *) = { - PokecenterHealEffect_0, - PokecenterHealEffect_1, - PokecenterHealEffect_2, - PokecenterHealEffect_3 + PokecenterHealEffect_Init, + PokecenterHealEffect_WaitForBallPlacement, + PokecenterHealEffect_WaitForBallFlashing, + PokecenterHealEffect_WaitForSoundAndEnd }; void (*const sHallOfFameRecordEffectFuncs[])(struct Task *) = { - HallOfFameRecordEffect_0, - HallOfFameRecordEffect_1, - HallOfFameRecordEffect_2, - HallOfFameRecordEffect_3 + HallOfFameRecordEffect_Init, + HallOfFameRecordEffect_WaitForBallPlacement, + HallOfFameRecordEffect_WaitForBallFlashing, + HallOfFameRecordEffect_WaitForSoundAndEnd }; void (*const sPokeballGlowEffectFuncs[])(struct Sprite *) = { - PokeballGlowEffect_0, - PokeballGlowEffect_1, - PokeballGlowEffect_2, - PokeballGlowEffect_3, - PokeballGlowEffect_4, - PokeballGlowEffect_5, - PokeballGlowEffect_6, - PokeballGlowEffect_7 + PokeballGlowEffect_PlaceBalls, + PokeballGlowEffect_TryPlaySe, + PokeballGlowEffect_Flash1, + PokeballGlowEffect_Flash2, + PokeballGlowEffect_WaitAfterFlash, + PokeballGlowEffect_Dummy, + PokeballGlowEffect_WaitForSound, + PokeballGlowEffect_Idle }; -const struct Coords16 gUnknown_0855C3A4[] = +static const struct Coords16 sPokeballCoordOffsets[PARTY_SIZE] = { {.x = 0, .y = 0}, {.x = 6, .y = 0}, @@ -595,93 +592,91 @@ const struct Coords16 gUnknown_0855C3A4[] = {.x = 6, .y = 8} }; -const u8 gUnknown_0855C3BC[] = {16, 12, 8, 0}; -const u8 gUnknown_0855C3C0[] = {16, 12, 8, 0}; -const u8 gUnknown_0855C3C4[] = { 0, 0, 0, 0}; +static const u8 sPokeballGlowReds[] = {16, 12, 8, 0}; +static const u8 sPokeballGlowGreens[] = {16, 12, 8, 0}; +static const u8 sPokeballGlowBlues[] = { 0, 0, 0, 0}; bool8 (*const sFallWarpFieldEffectFuncs[])(struct Task *) = { - FallWarpEffect_0, - FallWarpEffect_1, - FallWarpEffect_2, - FallWarpEffect_3, - FallWarpEffect_4, - FallWarpEffect_5, - FallWarpEffect_6, + FallWarpEffect_Init, + FallWarpEffect_WaitWeather, + FallWarpEffect_StartFall, + FallWarpEffect_Fall, + FallWarpEffect_Land, + FallWarpEffect_CameraShake, + FallWarpEffect_End, }; bool8 (*const sEscalatorWarpOutFieldEffectFuncs[])(struct Task *) = { - EscalatorWarpOutEffect_0, - EscalatorWarpOutEffect_1, - EscalatorWarpOutEffect_2, - EscalatorWarpOutEffect_3, - EscalatorWarpOutEffect_4, - EscalatorWarpOutEffect_5, + EscalatorWarpOut_Init, + EscalatorWarpOut_WaitForPlayer, + EscalatorWarpOut_Up_Ride, + EscalatorWarpOut_Up_End, + EscalatorWarpOut_Down_Ride, + EscalatorWarpOut_Down_End, }; bool8 (*const sEscalatorWarpInFieldEffectFuncs[])(struct Task *) = { - EscalatorWarpInEffect_0, - EscalatorWarpInEffect_1, - EscalatorWarpInEffect_2, - EscalatorWarpInEffect_3, - EscalatorWarpInEffect_4, - EscalatorWarpInEffect_5, - EscalatorWarpInEffect_6, + EscalatorWarpIn_Init, + EscalatorWarpIn_Down_Init, + EscalatorWarpIn_Down_Ride, + EscalatorWarpIn_Up_Init, + EscalatorWarpIn_Up_Ride, + EscalatorWarpIn_WaitForMovement, + EscalatorWarpIn_End, }; bool8 (*const sWaterfallFieldEffectFuncs[])(struct Task *, struct ObjectEvent *) = { - WaterfallFieldEffect_0, - WaterfallFieldEffect_1, - WaterfallFieldEffect_2, - WaterfallFieldEffect_3, - WaterfallFieldEffect_4, + WaterfallFieldEffect_Init, + WaterfallFieldEffect_ShowMon, + WaterfallFieldEffect_WaitForShowMon, + WaterfallFieldEffect_RideUp, + WaterfallFieldEffect_ContinueRideOrEnd, }; bool8 (*const sDiveFieldEffectFuncs[])(struct Task *) = { - DiveFieldEffect_0, - DiveFieldEffect_1, - DiveFieldEffect_2, + DiveFieldEffect_Init, + DiveFieldEffect_ShowMon, + DiveFieldEffect_TryWarp, }; bool8 (*const sLavaridgeGymB1FWarpEffectFuncs[])(struct Task *, struct ObjectEvent *, struct Sprite *) = { - LavaridgeGymB1FWarpEffect_0, - LavaridgeGymB1FWarpEffect_1, - LavaridgeGymB1FWarpEffect_2, - LavaridgeGymB1FWarpEffect_3, - LavaridgeGymB1FWarpEffect_4, - LavaridgeGymB1FWarpEffect_5, + LavaridgeGymB1FWarpEffect_Init, + LavaridgeGymB1FWarpEffect_CameraShake, + LavaridgeGymB1FWarpEffect_Launch, + LavaridgeGymB1FWarpEffect_Rise, + LavaridgeGymB1FWarpEffect_FadeOut, + LavaridgeGymB1FWarpEffect_Warp, }; bool8 (*const sLavaridgeGymB1FWarpExitEffectFuncs[])(struct Task *, struct ObjectEvent *, struct Sprite *) = { - LavaridgeGymB1FWarpExitEffect_0, - LavaridgeGymB1FWarpExitEffect_1, - LavaridgeGymB1FWarpExitEffect_2, - LavaridgeGymB1FWarpExitEffect_3, + LavaridgeGymB1FWarpExitEffect_Init, + LavaridgeGymB1FWarpExitEffect_StartPopOut, + LavaridgeGymB1FWarpExitEffect_PopOut, + LavaridgeGymB1FWarpExitEffect_End, }; bool8 (*const sLavaridgeGym1FWarpEffectFuncs[])(struct Task *, struct ObjectEvent *, struct Sprite *) = { - LavaridgeGym1FWarpEffect_0, - LavaridgeGym1FWarpEffect_1, - LavaridgeGym1FWarpEffect_2, - LavaridgeGym1FWarpEffect_3, - LavaridgeGym1FWarpEffect_4, + LavaridgeGym1FWarpEffect_Init, + LavaridgeGym1FWarpEffect_AshPuff, + LavaridgeGym1FWarpEffect_Disappear, + LavaridgeGym1FWarpEffect_FadeOut, + LavaridgeGym1FWarpEffect_Warp, }; -void (*const sEscapeRopeWarpOutFieldEffectFuncs[])(struct Task *) = +void (*const sEscapeRopeWarpOutEffectFuncs[])(struct Task *) = { - EscapeRopeWarpOutFieldEffect_0, - EscapeRopeWarpOutFieldEffect_1, + EscapeRopeWarpOutEffect_Init, + EscapeRopeWarpOutEffect_Spin, }; -// .text - u32 FieldEffectStart(u8 id) { u8 *script; @@ -885,7 +880,7 @@ u8 CreateTrainerSprite(u8 trainerSpriteID, s16 x, s16 y, u8 subpriority, u8 *buf LoadCompressedSpriteSheetOverrideBuffer(&gTrainerFrontPicTable[trainerSpriteID], buffer); spriteTemplate.tileTag = gTrainerFrontPicTable[trainerSpriteID].tag; spriteTemplate.paletteTag = gTrainerFrontPicPaletteTable[trainerSpriteID].tag; - spriteTemplate.oam = &gNewGameBirchOamAttributes; + spriteTemplate.oam = &sOam_64x64; spriteTemplate.anims = gDummySpriteAnimTable; spriteTemplate.images = NULL; spriteTemplate.affineAnims = gDummySpriteAffineAnimTable; @@ -901,8 +896,8 @@ void LoadTrainerGfx_TrainerCard(u8 gender, u16 palOffset, u8 *dest) u8 AddNewGameBirchObject(s16 x, s16 y, u8 subpriority) { - LoadSpritePalette(&gNewGameBirchObjectPaletteInfo); - return CreateSprite(&gNewGameBirchObjectTemplate, x, y, subpriority); + LoadSpritePalette(&sSpritePalette_NewGameBirch); + return CreateSprite(&sSpriteTemplate_NewGameBirch, x, y, subpriority); } u8 CreateMonSprite_PicBox(u16 species, s16 x, s16 y, u8 subpriority) @@ -915,10 +910,10 @@ u8 CreateMonSprite_PicBox(u16 species, s16 x, s16 y, u8 subpriority) return spriteId; } -u8 CreateMonSprite_FieldMove(u16 species, u32 d, u32 g, s16 x, s16 y, u8 subpriority) +u8 CreateMonSprite_FieldMove(u16 species, u32 otId, u32 personality, s16 x, s16 y, u8 subpriority) { - const struct CompressedSpritePalette *spritePalette = GetMonSpritePalStructFromOtIdPersonality(species, d, g); - u16 spriteId = CreateMonPicSprite_HandleDeoxys(species, d, g, 1, x, y, 0, spritePalette->tag); + const struct CompressedSpritePalette *spritePalette = GetMonSpritePalStructFromOtIdPersonality(species, otId, personality); + u16 spriteId = CreateMonPicSprite_HandleDeoxys(species, otId, personality, 1, x, y, 0, spritePalette->tag); PreservePaletteInWeather(IndexOfSpritePaletteTag(spritePalette->tag) + 0x10); if (spriteId == 0xFFFF) return MAX_SPRITES; @@ -978,6 +973,28 @@ void MultiplyPaletteRGBComponents(u16 i, u8 r, u8 g, u8 b) gPlttBufferFaded[i] = outPal; } +// Task data for Task_PokecenterHeal and Task_HallOfFameRecord +#define tState data[0] +#define tNumMons data[1] +#define tFirstBallX data[2] +#define tFirstBallY data[3] +#define tMonitorX data[4] +#define tMonitorY data[5] +#define tBallSpriteId data[6] +#define tMonitorSpriteId data[7] +#define tStartHofFlash data[15] + +// Sprite data for SpriteCB_PokeballGlowEffect +#define sState data[0] +#define sTimer data[1] +#define sCounter data[2] +#define sPlayHealSe data[5] +#define sNumMons data[6] +#define sSpriteId data[7] + +// Sprite data for SpriteCB_PokeballGlow +#define sEffectSpriteId data[0] + bool8 FldEff_PokecenterHeal(void) { u8 nPokemon; @@ -985,11 +1002,11 @@ bool8 FldEff_PokecenterHeal(void) nPokemon = CalculatePlayerPartyCount(); task = &gTasks[CreateTask(Task_PokecenterHeal, 0xff)]; - task->data[1] = nPokemon; - task->data[2] = 0x5d; - task->data[3] = 0x24; - task->data[4] = 0x7c; - task->data[5] = 0x18; + task->tNumMons = nPokemon; + task->tFirstBallX = 93; + task->tFirstBallY = 36; + task->tMonitorX = 124; + task->tMonitorY = 24; return FALSE; } @@ -997,38 +1014,38 @@ static void Task_PokecenterHeal(u8 taskId) { struct Task *task; task = &gTasks[taskId]; - sPokecenterHealEffectFuncs[task->data[0]](task); + sPokecenterHealEffectFuncs[task->tState](task); } -static void PokecenterHealEffect_0(struct Task *task) +static void PokecenterHealEffect_Init(struct Task *task) { - task->data[0]++; - task->data[6] = CreatePokeballGlowSprite(task->data[1], task->data[2], task->data[3], 1); - task->data[7] = PokecenterHealEffectHelper(task->data[4], task->data[5]); + task->tState++; + task->tBallSpriteId = CreateGlowingPokeballsEffect(task->tNumMons, task->tFirstBallX, task->tFirstBallY, TRUE); + task->tMonitorSpriteId = CreatePokecenterMonitorSprite(task->tMonitorX, task->tMonitorY); } -static void PokecenterHealEffect_1(struct Task *task) +static void PokecenterHealEffect_WaitForBallPlacement(struct Task *task) { - if (gSprites[task->data[6]].data[0] > 1) + if (gSprites[task->tBallSpriteId].sState > 1) { - gSprites[task->data[7]].data[0]++; - task->data[0]++; + gSprites[task->tMonitorSpriteId].sState++; + task->tState++; } } -static void PokecenterHealEffect_2(struct Task *task) +static void PokecenterHealEffect_WaitForBallFlashing(struct Task *task) { - if (gSprites[task->data[6]].data[0] > 4) + if (gSprites[task->tBallSpriteId].sState > 4) { - task->data[0]++; + task->tState++; } } -static void PokecenterHealEffect_3(struct Task *task) +static void PokecenterHealEffect_WaitForSoundAndEnd(struct Task *task) { - if (gSprites[task->data[6]].data[0] > 6) + if (gSprites[task->tBallSpriteId].sState > 6) { - DestroySprite(&gSprites[task->data[6]]); + DestroySprite(&gSprites[task->tBallSpriteId]); FieldEffectActiveListRemove(FLDEFF_POKECENTER_HEAL); DestroyTask(FindTaskIdByFunc(Task_PokecenterHeal)); } @@ -1041,9 +1058,9 @@ bool8 FldEff_HallOfFameRecord(void) nPokemon = CalculatePlayerPartyCount(); task = &gTasks[CreateTask(Task_HallOfFameRecord, 0xff)]; - task->data[1] = nPokemon; - task->data[2] = 0x75; - task->data[3] = 0x34; + task->tNumMons = nPokemon; + task->tFirstBallX = 117; + task->tFirstBallY = 52; return FALSE; } @@ -1051,51 +1068,50 @@ static void Task_HallOfFameRecord(u8 taskId) { struct Task *task; task = &gTasks[taskId]; - sHallOfFameRecordEffectFuncs[task->data[0]](task); + sHallOfFameRecordEffectFuncs[task->tState](task); } -static void HallOfFameRecordEffect_0(struct Task *task) +static void HallOfFameRecordEffect_Init(struct Task *task) { u8 taskId; - task->data[0]++; - task->data[6] = CreatePokeballGlowSprite(task->data[1], task->data[2], task->data[3], 0); + task->tState++; + task->tBallSpriteId = CreateGlowingPokeballsEffect(task->tNumMons, task->tFirstBallX, task->tFirstBallY, FALSE); taskId = FindTaskIdByFunc(Task_HallOfFameRecord); - HallOfFameRecordEffectHelper(taskId, 0x78, 0x18, 0); - HallOfFameRecordEffectHelper(taskId, 0x28, 0x08, 1); - HallOfFameRecordEffectHelper(taskId, 0x48, 0x08, 1); - HallOfFameRecordEffectHelper(taskId, 0xa8, 0x08, 1); - HallOfFameRecordEffectHelper(taskId, 0xc8, 0x08, 1); + CreateHofMonitorSprite(taskId, 120, 24, FALSE); + CreateHofMonitorSprite(taskId, 40, 8, TRUE); + CreateHofMonitorSprite(taskId, 72, 8, TRUE); + CreateHofMonitorSprite(taskId, 168, 8, TRUE); + CreateHofMonitorSprite(taskId, 200, 8, TRUE); } -static void HallOfFameRecordEffect_1(struct Task *task) +static void HallOfFameRecordEffect_WaitForBallPlacement(struct Task *task) { - if (gSprites[task->data[6]].data[0] > 1) + if (gSprites[task->tBallSpriteId].sState > 1) { - task->data[15]++; // was this ever initialized? is this ever used? - task->data[0]++; + task->tStartHofFlash++; + task->tState++; } } -static void HallOfFameRecordEffect_2(struct Task *task) +static void HallOfFameRecordEffect_WaitForBallFlashing(struct Task *task) { - if (gSprites[task->data[6]].data[0] > 4) + if (gSprites[task->tBallSpriteId].sState > 4) { - task->data[0]++; + task->tState++; } } -static void HallOfFameRecordEffect_3(struct Task *task) +static void HallOfFameRecordEffect_WaitForSoundAndEnd(struct Task *task) { - if (gSprites[task->data[6]].data[0] > 6) + if (gSprites[task->tBallSpriteId].sState > 6) { - DestroySprite(&gSprites[task->data[6]]); + DestroySprite(&gSprites[task->tBallSpriteId]); FieldEffectActiveListRemove(FLDEFF_HALL_OF_FAME_RECORD); DestroyTask(FindTaskIdByFunc(Task_HallOfFameRecord)); } } - -static u8 CreatePokeballGlowSprite(s16 data6, s16 x, s16 y, u16 data5) +static u8 CreateGlowingPokeballsEffect(s16 numMons, s16 x, s16 y, bool16 playHealSe) { u8 spriteId; struct Sprite *sprite; @@ -1103,150 +1119,150 @@ static u8 CreatePokeballGlowSprite(s16 data6, s16 x, s16 y, u16 data5) sprite = &gSprites[spriteId]; sprite->pos2.x = x; sprite->pos2.y = y; - sprite->data[5] = data5; - sprite->data[6] = data6; - sprite->data[7] = spriteId; + sprite->sPlayHealSe = playHealSe; + sprite->sNumMons = numMons; + sprite->sSpriteId = spriteId; return spriteId; } static void SpriteCB_PokeballGlowEffect(struct Sprite *sprite) { - sPokeballGlowEffectFuncs[sprite->data[0]](sprite); + sPokeballGlowEffectFuncs[sprite->sState](sprite); } -static void PokeballGlowEffect_0(struct Sprite *sprite) +static void PokeballGlowEffect_PlaceBalls(struct Sprite *sprite) { - u8 endSpriteId; - if (sprite->data[1] == 0 || (--sprite->data[1]) == 0) + u8 spriteId; + if (sprite->sTimer == 0 || (--sprite->sTimer) == 0) { - sprite->data[1] = 25; - endSpriteId = CreateSpriteAtEnd(&gSpriteTemplate_855C304, gUnknown_0855C3A4[sprite->data[2]].x + sprite->pos2.x, gUnknown_0855C3A4[sprite->data[2]].y + sprite->pos2.y, 0); - gSprites[endSpriteId].oam.priority = 2; - gSprites[endSpriteId].data[0] = sprite->data[7]; - sprite->data[2]++; - sprite->data[6]--; + sprite->sTimer = 25; + spriteId = CreateSpriteAtEnd(&sSpriteTemplate_PokeballGlow, sPokeballCoordOffsets[sprite->sCounter].x + sprite->pos2.x, sPokeballCoordOffsets[sprite->sCounter].y + sprite->pos2.y, 0); + gSprites[spriteId].oam.priority = 2; + gSprites[spriteId].sEffectSpriteId = sprite->sSpriteId; + sprite->sCounter++; + sprite->sNumMons--; PlaySE(SE_BOWA); } - if (sprite->data[6] == 0) + if (sprite->sNumMons == 0) { - sprite->data[1] = 32; - sprite->data[0]++; + sprite->sTimer = 32; + sprite->sState++; } } -static void PokeballGlowEffect_1(struct Sprite *sprite) +static void PokeballGlowEffect_TryPlaySe(struct Sprite *sprite) { - if ((--sprite->data[1]) == 0) + if ((--sprite->sTimer) == 0) { - sprite->data[0]++; - sprite->data[1] = 8; - sprite->data[2] = 0; + sprite->sState++; + sprite->sTimer = 8; + sprite->sCounter = 0; sprite->data[3] = 0; - if (sprite->data[5]) + if (sprite->sPlayHealSe) { PlayFanfare(MUS_ME_ASA); } } } -static void PokeballGlowEffect_2(struct Sprite *sprite) +static void PokeballGlowEffect_Flash1(struct Sprite *sprite) { u8 phase; - if ((--sprite->data[1]) == 0) + if ((--sprite->sTimer) == 0) { - sprite->data[1] = 8; - sprite->data[2]++; - sprite->data[2] &= 3; - if (sprite->data[2] == 0) - { + sprite->sTimer = 8; + sprite->sCounter++; + sprite->sCounter &= 3; + + if (sprite->sCounter == 0) sprite->data[3]++; - } } - phase = (sprite->data[2] + 3) & 3; - MultiplyInvertedPaletteRGBComponents((IndexOfSpritePaletteTag(0x1007) << 4) + 0x108, gUnknown_0855C3BC[phase], gUnknown_0855C3C0[phase], gUnknown_0855C3C4[phase]); - phase = (sprite->data[2] + 2) & 3; - MultiplyInvertedPaletteRGBComponents((IndexOfSpritePaletteTag(0x1007) << 4) + 0x106, gUnknown_0855C3BC[phase], gUnknown_0855C3C0[phase], gUnknown_0855C3C4[phase]); - phase = (sprite->data[2] + 1) & 3; - MultiplyInvertedPaletteRGBComponents((IndexOfSpritePaletteTag(0x1007) << 4) + 0x102, gUnknown_0855C3BC[phase], gUnknown_0855C3C0[phase], gUnknown_0855C3C4[phase]); - phase = sprite->data[2]; - MultiplyInvertedPaletteRGBComponents((IndexOfSpritePaletteTag(0x1007) << 4) + 0x105, gUnknown_0855C3BC[phase], gUnknown_0855C3C0[phase], gUnknown_0855C3C4[phase]); - MultiplyInvertedPaletteRGBComponents((IndexOfSpritePaletteTag(0x1007) << 4) + 0x103, gUnknown_0855C3BC[phase], gUnknown_0855C3C0[phase], gUnknown_0855C3C4[phase]); + phase = (sprite->sCounter + 3) & 3; + MultiplyInvertedPaletteRGBComponents((IndexOfSpritePaletteTag(FLDEFF_PAL_TAG_7) << 4) + 0x108, sPokeballGlowReds[phase], sPokeballGlowGreens[phase], sPokeballGlowBlues[phase]); + phase = (sprite->sCounter + 2) & 3; + MultiplyInvertedPaletteRGBComponents((IndexOfSpritePaletteTag(FLDEFF_PAL_TAG_7) << 4) + 0x106, sPokeballGlowReds[phase], sPokeballGlowGreens[phase], sPokeballGlowBlues[phase]); + phase = (sprite->sCounter + 1) & 3; + MultiplyInvertedPaletteRGBComponents((IndexOfSpritePaletteTag(FLDEFF_PAL_TAG_7) << 4) + 0x102, sPokeballGlowReds[phase], sPokeballGlowGreens[phase], sPokeballGlowBlues[phase]); + phase = sprite->sCounter; + MultiplyInvertedPaletteRGBComponents((IndexOfSpritePaletteTag(FLDEFF_PAL_TAG_7) << 4) + 0x105, sPokeballGlowReds[phase], sPokeballGlowGreens[phase], sPokeballGlowBlues[phase]); + MultiplyInvertedPaletteRGBComponents((IndexOfSpritePaletteTag(FLDEFF_PAL_TAG_7) << 4) + 0x103, sPokeballGlowReds[phase], sPokeballGlowGreens[phase], sPokeballGlowBlues[phase]); if (sprite->data[3] > 2) { - sprite->data[0]++; - sprite->data[1] = 8; - sprite->data[2] = 0; + sprite->sState++; + sprite->sTimer = 8; + sprite->sCounter = 0; } } -static void PokeballGlowEffect_3(struct Sprite *sprite) +static void PokeballGlowEffect_Flash2(struct Sprite *sprite) { u8 phase; - if ((--sprite->data[1]) == 0) + if ((--sprite->sTimer) == 0) { - sprite->data[1] = 8; - sprite->data[2]++; - sprite->data[2] &= 3; - if (sprite->data[2] == 3) + sprite->sTimer = 8; + sprite->sCounter++; + sprite->sCounter &= 3; + if (sprite->sCounter == 3) { - sprite->data[0]++; - sprite->data[1] = 30; + sprite->sState++; + sprite->sTimer = 30; } } - phase = sprite->data[2]; - MultiplyInvertedPaletteRGBComponents((IndexOfSpritePaletteTag(0x1007) << 4) + 0x108, gUnknown_0855C3BC[phase], gUnknown_0855C3C0[phase], gUnknown_0855C3C4[phase]); - MultiplyInvertedPaletteRGBComponents((IndexOfSpritePaletteTag(0x1007) << 4) + 0x106, gUnknown_0855C3BC[phase], gUnknown_0855C3C0[phase], gUnknown_0855C3C4[phase]); - MultiplyInvertedPaletteRGBComponents((IndexOfSpritePaletteTag(0x1007) << 4) + 0x102, gUnknown_0855C3BC[phase], gUnknown_0855C3C0[phase], gUnknown_0855C3C4[phase]); - MultiplyInvertedPaletteRGBComponents((IndexOfSpritePaletteTag(0x1007) << 4) + 0x105, gUnknown_0855C3BC[phase], gUnknown_0855C3C0[phase], gUnknown_0855C3C4[phase]); - MultiplyInvertedPaletteRGBComponents((IndexOfSpritePaletteTag(0x1007) << 4) + 0x103, gUnknown_0855C3BC[phase], gUnknown_0855C3C0[phase], gUnknown_0855C3C4[phase]); + phase = sprite->sCounter; + MultiplyInvertedPaletteRGBComponents((IndexOfSpritePaletteTag(FLDEFF_PAL_TAG_7) << 4) + 0x108, sPokeballGlowReds[phase], sPokeballGlowGreens[phase], sPokeballGlowBlues[phase]); + MultiplyInvertedPaletteRGBComponents((IndexOfSpritePaletteTag(FLDEFF_PAL_TAG_7) << 4) + 0x106, sPokeballGlowReds[phase], sPokeballGlowGreens[phase], sPokeballGlowBlues[phase]); + MultiplyInvertedPaletteRGBComponents((IndexOfSpritePaletteTag(FLDEFF_PAL_TAG_7) << 4) + 0x102, sPokeballGlowReds[phase], sPokeballGlowGreens[phase], sPokeballGlowBlues[phase]); + MultiplyInvertedPaletteRGBComponents((IndexOfSpritePaletteTag(FLDEFF_PAL_TAG_7) << 4) + 0x105, sPokeballGlowReds[phase], sPokeballGlowGreens[phase], sPokeballGlowBlues[phase]); + MultiplyInvertedPaletteRGBComponents((IndexOfSpritePaletteTag(FLDEFF_PAL_TAG_7) << 4) + 0x103, sPokeballGlowReds[phase], sPokeballGlowGreens[phase], sPokeballGlowBlues[phase]); } -static void PokeballGlowEffect_4(struct Sprite *sprite) +static void PokeballGlowEffect_WaitAfterFlash(struct Sprite *sprite) { - if ((--sprite->data[1]) == 0) + if ((--sprite->sTimer) == 0) { - sprite->data[0]++; + sprite->sState++; } } -static void PokeballGlowEffect_5(struct Sprite *sprite) +static void PokeballGlowEffect_Dummy(struct Sprite *sprite) { - sprite->data[0]++; + sprite->sState++; } -static void PokeballGlowEffect_6(struct Sprite *sprite) +static void PokeballGlowEffect_WaitForSound(struct Sprite *sprite) { - if (sprite->data[5] == 0 || IsFanfareTaskInactive()) + if (sprite->sPlayHealSe == FALSE || IsFanfareTaskInactive()) { - sprite->data[0]++; + sprite->sState++; } } -static void PokeballGlowEffect_7(struct Sprite *sprite) +static void PokeballGlowEffect_Idle(struct Sprite *sprite) { + // Idle until destroyed } -void SpriteCB_PokeballGlow(struct Sprite *sprite) +static void SpriteCB_PokeballGlow(struct Sprite *sprite) { - if (gSprites[sprite->data[0]].data[0] > 4) + if (gSprites[sprite->sEffectSpriteId].sState > 4) { FieldEffectFreeGraphicsResources(sprite); } } -static u8 PokecenterHealEffectHelper(s16 x, s16 y) +static u8 CreatePokecenterMonitorSprite(s16 x, s16 y) { - u8 spriteIdAtEnd; + u8 spriteId; struct Sprite *sprite; - spriteIdAtEnd = CreateSpriteAtEnd(&gSpriteTemplate_855C31C, x, y, 0); - sprite = &gSprites[spriteIdAtEnd]; + spriteId = CreateSpriteAtEnd(&sSpriteTemplate_PokecenterMonitor, x, y, 0); + sprite = &gSprites[spriteId]; sprite->oam.priority = 2; sprite->invisible = TRUE; - SetSubspriteTables(sprite, &gUnknown_0855C2AC); - return spriteIdAtEnd; + SetSubspriteTables(sprite, &sSubspriteTable_PokecenterMonitor); + return spriteId; } -void SpriteCB_PokecenterMonitor(struct Sprite *sprite) +static void SpriteCB_PokecenterMonitor(struct Sprite *sprite) { if (sprite->data[0] != 0) { @@ -1260,24 +1276,24 @@ void SpriteCB_PokecenterMonitor(struct Sprite *sprite) } } -static void HallOfFameRecordEffectHelper(s16 a0, s16 a1, s16 a2, u8 a3) +static void CreateHofMonitorSprite(s16 taskId, s16 x, s16 y, bool8 isSmallMonitor) { - u8 spriteIdAtEnd; - if (!a3) + u8 spriteId; + if (!isSmallMonitor) { - spriteIdAtEnd = CreateSpriteAtEnd(&gSpriteTemplate_855C334, a1, a2, 0); - SetSubspriteTables(&gSprites[spriteIdAtEnd], &gUnknown_0855C2C4); + spriteId = CreateSpriteAtEnd(&sSpriteTemplate_HofMonitorBig, x, y, 0); + SetSubspriteTables(&gSprites[spriteId], &sSubspriteTable_HofMonitorBig); } else { - spriteIdAtEnd = CreateSpriteAtEnd(&gSpriteTemplate_855C34C, a1, a2, 0); + spriteId = CreateSpriteAtEnd(&sSpriteTemplate_HofMonitorSmall, x, y, 0); } - gSprites[spriteIdAtEnd].invisible = TRUE; - gSprites[spriteIdAtEnd].data[0] = a0; + gSprites[spriteId].invisible = TRUE; + gSprites[spriteId].data[0] = taskId; } -void SpriteCB_HallOfFameMonitor(struct Sprite *sprite) +static void SpriteCB_HallOfFameMonitor(struct Sprite *sprite) { - if (gTasks[sprite->data[0]].data[15]) + if (gTasks[sprite->data[0]].tStartHofFlash) { if (sprite->data[1] == 0 || (--sprite->data[1]) == 0) { @@ -1292,6 +1308,22 @@ void SpriteCB_HallOfFameMonitor(struct Sprite *sprite) } } +#undef tState +#undef tNumMons +#undef tFirstBallX +#undef tFirstBallY +#undef tMonitorX +#undef tMonitorY +#undef tBallSpriteId +#undef tMonitorSpriteId +#undef tStartHofFlash +#undef sState +#undef sTimer +#undef sCounter +#undef sPlayHealSe +#undef sNumMons +#undef sSpriteId +#undef sEffectSpriteId void ReturnToFieldFromFlyMapSelect(void) { @@ -1315,14 +1347,12 @@ static void Task_UseFly(u8 taskId) if (!task->data[0]) { if (!IsWeatherNotFadingIn()) - { return; - } + gFieldEffectArguments[0] = GetCursorSelectionMonId(); if ((int)gFieldEffectArguments[0] > PARTY_SIZE - 1) - { gFieldEffectArguments[0] = 0; - } + FieldEffectStart(FLDEFF_USE_FLY); task->data[0]++; } @@ -1372,6 +1402,15 @@ static void Task_FlyIntoMap(u8 taskId) } } +#define tState data[0] +#define tFallOffset data[1] +#define tTotalFall data[2] +#define tSetTrigger data[3] +#define tSubsprMode data[4] + +#define tVertShake data[1] // re-used +#define tNumShakes data[2] + void FieldCB_FallWarpExit(void) { Overworld_PlaySpecialMapMusic(); @@ -1386,10 +1425,10 @@ static void Task_FallWarpFieldEffect(u8 taskId) { struct Task *task; task = &gTasks[taskId]; - while (sFallWarpFieldEffectFuncs[task->data[0]](task)); // return code signifies whether to continue blocking here + while (sFallWarpFieldEffectFuncs[task->tState](task)); } -static bool8 FallWarpEffect_0(struct Task *task) +static bool8 FallWarpEffect_Init(struct Task *task) { struct ObjectEvent *playerObject; struct Sprite *playerSprite; @@ -1399,59 +1438,57 @@ static bool8 FallWarpEffect_0(struct Task *task) gObjectEvents[gPlayerAvatar.objectEventId].invisible = TRUE; gPlayerAvatar.preventStep = TRUE; ObjectEventSetHeldMovement(playerObject, GetFaceDirectionMovementAction(GetPlayerFacingDirection())); - task->data[4] = playerSprite->subspriteMode; + task->tSubsprMode = playerSprite->subspriteMode; playerObject->fixedPriority = 1; playerSprite->oam.priority = 1; playerSprite->subspriteMode = SUBSPRITES_IGNORE_PRIORITY; - task->data[0]++; + task->tState++; return TRUE; } -static bool8 FallWarpEffect_1(struct Task *task) +static bool8 FallWarpEffect_WaitWeather(struct Task *task) { if (IsWeatherNotFadingIn()) - { - task->data[0]++; - } + task->tState++; + return FALSE; } -static bool8 FallWarpEffect_2(struct Task *task) +static bool8 FallWarpEffect_StartFall(struct Task *task) { struct Sprite *sprite; s16 centerToCornerVecY; sprite = &gSprites[gPlayerAvatar.spriteId]; centerToCornerVecY = -(sprite->centerToCornerVecY << 1); sprite->pos2.y = -(sprite->pos1.y + sprite->centerToCornerVecY + gSpriteCoordOffsetY + centerToCornerVecY); - task->data[1] = 1; - task->data[2] = 0; + task->tFallOffset = 1; + task->tTotalFall = 0; gObjectEvents[gPlayerAvatar.objectEventId].invisible = FALSE; PlaySE(SE_RU_HYUU); - task->data[0]++; + task->tState++; return FALSE; } -static bool8 FallWarpEffect_3(struct Task *task) +static bool8 FallWarpEffect_Fall(struct Task *task) { struct ObjectEvent *objectEvent; struct Sprite *sprite; objectEvent = &gObjectEvents[gPlayerAvatar.objectEventId]; sprite = &gSprites[gPlayerAvatar.spriteId]; - sprite->pos2.y += task->data[1]; - if (task->data[1] < 8) + sprite->pos2.y += task->tFallOffset; + if (task->tFallOffset < 8) { - task->data[2] += task->data[1]; - if (task->data[2] & 0xf) - { - task->data[1] <<= 1; - } + task->tTotalFall += task->tFallOffset; + + if (task->tTotalFall & 0xf) + task->tFallOffset <<= 1; } - if (task->data[3] == 0 && sprite->pos2.y >= -16) + if (task->tSetTrigger == FALSE && sprite->pos2.y >= -16) { - task->data[3]++; + task->tSetTrigger++; objectEvent->fixedPriority = 0; - sprite->subspriteMode = task->data[4]; + sprite->subspriteMode = task->tSubsprMode; objectEvent->triggerGroundEffectsOnMove = 1; } if (sprite->pos2.y >= 0) @@ -1460,37 +1497,36 @@ static bool8 FallWarpEffect_3(struct Task *task) objectEvent->triggerGroundEffectsOnStop = 1; objectEvent->landingJump = 1; sprite->pos2.y = 0; - task->data[0]++; + task->tState++; } return FALSE; } -static bool8 FallWarpEffect_4(struct Task *task) +static bool8 FallWarpEffect_Land(struct Task *task) { - task->data[0]++; - task->data[1] = 4; - task->data[2] = 0; + task->tState++; + task->tVertShake = 4; + task->tNumShakes = 0; SetCameraPanningCallback(NULL); return TRUE; } -static bool8 FallWarpEffect_5(struct Task *task) +static bool8 FallWarpEffect_CameraShake(struct Task *task) { - SetCameraPanning(0, task->data[1]); - task->data[1] = -task->data[1]; - task->data[2]++; - if ((task->data[2] & 3) == 0) - { - task->data[1] >>= 1; - } - if (task->data[1] == 0) - { - task->data[0]++; - } + SetCameraPanning(0, task->tVertShake); + task->tVertShake = -task->tVertShake; + task->tNumShakes++; + + if ((task->tNumShakes & 3) == 0) + task->tVertShake >>= 1; + + if (task->tVertShake == 0) + task->tState++; + return FALSE; } -static bool8 FallWarpEffect_6(struct Task *task) +static bool8 FallWarpEffect_End(struct Task *task) { gPlayerAvatar.preventStep = FALSE; ScriptContext2_Disable(); @@ -1501,14 +1537,25 @@ static bool8 FallWarpEffect_6(struct Task *task) return FALSE; } +#undef tState +#undef tFallOffset +#undef tTotalFall +#undef tSetTrigger +#undef tSubsprMode +#undef tVertShake +#undef tNumShakes + +#define tState data[0] +#define tGoingUp data[1] + void StartEscalatorWarp(u8 metatileBehavior, u8 priority) { u8 taskId; taskId = CreateTask(Task_EscalatorWarpOut, priority); - gTasks[taskId].data[1] = FALSE; + gTasks[taskId].tGoingUp = FALSE; if (metatileBehavior == MB_UP_ESCALATOR) { - gTasks[taskId].data[1] = TRUE; + gTasks[taskId].tGoingUp = TRUE; } } @@ -1516,74 +1563,74 @@ static void Task_EscalatorWarpOut(u8 taskId) { struct Task *task; task = &gTasks[taskId]; - while (sEscalatorWarpOutFieldEffectFuncs[task->data[0]](task)); + while (sEscalatorWarpOutFieldEffectFuncs[task->tState](task)); } -static bool8 EscalatorWarpOutEffect_0(struct Task *task) +static bool8 EscalatorWarpOut_Init(struct Task *task) { FreezeObjectEvents(); CameraObjectReset2(); - StartEscalator(task->data[1]); - task->data[0]++; + StartEscalator(task->tGoingUp); + task->tState++; return FALSE; } -static bool8 EscalatorWarpOutEffect_1(struct Task *task) +static bool8 EscalatorWarpOut_WaitForPlayer(struct Task *task) { struct ObjectEvent *objectEvent; objectEvent = &gObjectEvents[gPlayerAvatar.objectEventId]; if (!ObjectEventIsMovementOverridden(objectEvent) || ObjectEventClearHeldMovementIfFinished(objectEvent)) { ObjectEventSetHeldMovement(objectEvent, GetFaceDirectionMovementAction(GetPlayerFacingDirection())); - task->data[0]++; + task->tState++; task->data[2] = 0; task->data[3] = 0; - if ((u8)task->data[1] == 0) + if ((u8)task->tGoingUp == FALSE) { - task->data[0] = 4; + task->tState = 4; // jump to EscalatorWarpOut_Down_Ride } PlaySE(SE_ESUKA); } return FALSE; } -static bool8 EscalatorWarpOutEffect_2(struct Task *task) +static bool8 EscalatorWarpOut_Up_Ride(struct Task *task) { - sub_80B6FB8(task); + RideUpEscalatorOut(task); if (task->data[2] > 3) { - sub_80B7050(); - task->data[0]++; + FadeOutAtEndOfEscalator(); + task->tState++; } return FALSE; } -static bool8 EscalatorWarpOutEffect_3(struct Task *task) +static bool8 EscalatorWarpOut_Up_End(struct Task *task) { - sub_80B6FB8(task); - sub_80B7060(); + RideUpEscalatorOut(task); + WarpAtEndOfEscalator(); return FALSE; } -static bool8 EscalatorWarpOutEffect_4(struct Task *task) +static bool8 EscalatorWarpOut_Down_Ride(struct Task *task) { - sub_80B7004(task); + RideDownEscalatorOut(task); if (task->data[2] > 3) { - sub_80B7050(); - task->data[0]++; + FadeOutAtEndOfEscalator(); + task->tState++; } return FALSE; } -static bool8 EscalatorWarpOutEffect_5(struct Task *task) +static bool8 EscalatorWarpOut_Down_End(struct Task *task) { - sub_80B7004(task); - sub_80B7060(); + RideDownEscalatorOut(task); + WarpAtEndOfEscalator(); return FALSE; } -static void sub_80B6FB8(struct Task *task) +static void RideUpEscalatorOut(struct Task *task) { struct Sprite *sprite; sprite = &gSprites[gPlayerAvatar.spriteId]; @@ -1596,7 +1643,7 @@ static void sub_80B6FB8(struct Task *task) } } -static void sub_80B7004(struct Task *task) +static void RideDownEscalatorOut(struct Task *task) { struct Sprite *sprite; sprite = &gSprites[gPlayerAvatar.spriteId]; @@ -1609,13 +1656,13 @@ static void sub_80B7004(struct Task *task) } } -static void sub_80B7050(void) +static void FadeOutAtEndOfEscalator(void) { TryFadeOutOldMapMusic(); WarpFadeOutScreen(); } -static void sub_80B7060(void) +static void WarpAtEndOfEscalator(void) { if (!gPaletteFade.active && BGMusicStopped() == TRUE) { @@ -1627,6 +1674,9 @@ static void sub_80B7060(void) } } +#undef tState +#undef tGoingUp + static void FieldCallback_EscalatorWarpIn(void) { Overworld_PlaySpecialMapMusic(); @@ -1636,14 +1686,16 @@ static void FieldCallback_EscalatorWarpIn(void) gFieldCallback = NULL; } +#define tState data[0] + static void Task_EscalatorWarpIn(u8 taskId) { struct Task *task; task = &gTasks[taskId]; - while (sEscalatorWarpInFieldEffectFuncs[task->data[0]](task)); + while (sEscalatorWarpInFieldEffectFuncs[task->tState](task)); } -static bool8 EscalatorWarpInEffect_0(struct Task *task) +static bool8 EscalatorWarpIn_Init(struct Task *task) { struct ObjectEvent *objectEvent; s16 x; @@ -1654,31 +1706,35 @@ static bool8 EscalatorWarpInEffect_0(struct Task *task) ObjectEventSetHeldMovement(objectEvent, GetFaceDirectionMovementAction(DIR_EAST)); PlayerGetDestCoords(&x, &y); behavior = MapGridGetMetatileBehaviorAt(x, y); - task->data[0]++; + task->tState++; task->data[1] = 16; + if (behavior == MB_DOWN_ESCALATOR) { + // If dest is down escalator tile, player is riding up behavior = TRUE; - task->data[0] = 3; - } else // MB_UP_ESCALATOR + task->tState = 3; // jump to EscalatorWarpIn_Up_Init + } + else // MB_UP_ESCALATOR { + // If dest is up escalator tile, player is riding down behavior = FALSE; } StartEscalator(behavior); return TRUE; } -static bool8 EscalatorWarpInEffect_1(struct Task *task) +static bool8 EscalatorWarpIn_Down_Init(struct Task *task) { struct Sprite *sprite; sprite = &gSprites[gPlayerAvatar.spriteId]; sprite->pos2.x = Cos(0x84, task->data[1]); sprite->pos2.y = Sin(0x94, task->data[1]); - task->data[0]++; + task->tState++; return FALSE; } -static bool8 EscalatorWarpInEffect_2(struct Task *task) +static bool8 EscalatorWarpIn_Down_Ride(struct Task *task) { struct Sprite *sprite; sprite = &gSprites[gPlayerAvatar.spriteId]; @@ -1693,22 +1749,22 @@ static bool8 EscalatorWarpInEffect_2(struct Task *task) { sprite->pos2.x = 0; sprite->pos2.y = 0; - task->data[0] = 5; + task->tState = 5; } return FALSE; } -static bool8 EscalatorWarpInEffect_3(struct Task *task) +static bool8 EscalatorWarpIn_Up_Init(struct Task *task) { struct Sprite *sprite; sprite = &gSprites[gPlayerAvatar.spriteId]; sprite->pos2.x = Cos(0x7c, task->data[1]); sprite->pos2.y = Sin(0x76, task->data[1]); - task->data[0]++; + task->tState++; return FALSE; } -static bool8 EscalatorWarpInEffect_4(struct Task *task) +static bool8 EscalatorWarpIn_Up_Ride(struct Task *task) { struct Sprite *sprite; sprite = &gSprites[gPlayerAvatar.spriteId]; @@ -1723,23 +1779,23 @@ static bool8 EscalatorWarpInEffect_4(struct Task *task) { sprite->pos2.x = 0; sprite->pos2.y = 0; - task->data[0]++; + task->tState++; } return FALSE; } -static bool8 EscalatorWarpInEffect_5(struct Task *task) +static bool8 EscalatorWarpIn_WaitForMovement(struct Task *task) { if (IsEscalatorMoving()) { return FALSE; } StopEscalator(); - task->data[0]++; + task->tState++; return TRUE; } -static bool8 EscalatorWarpInEffect_6(struct Task *task) +static bool8 EscalatorWarpIn_End(struct Task *task) { struct ObjectEvent *objectEvent; objectEvent = &gObjectEvents[gPlayerAvatar.objectEventId]; @@ -1753,70 +1809,75 @@ static bool8 EscalatorWarpInEffect_6(struct Task *task) return FALSE; } +#undef tState + +#define tState data[0] +#define tMonId data[1] + bool8 FldEff_UseWaterfall(void) { u8 taskId; taskId = CreateTask(Task_UseWaterfall, 0xff); - gTasks[taskId].data[1] = gFieldEffectArguments[0]; + gTasks[taskId].tMonId = gFieldEffectArguments[0]; Task_UseWaterfall(taskId); return FALSE; } static void Task_UseWaterfall(u8 taskId) { - while (sWaterfallFieldEffectFuncs[gTasks[taskId].data[0]](&gTasks[taskId], &gObjectEvents[gPlayerAvatar.objectEventId])); + while (sWaterfallFieldEffectFuncs[gTasks[taskId].tState](&gTasks[taskId], &gObjectEvents[gPlayerAvatar.objectEventId])); } -static bool8 WaterfallFieldEffect_0(struct Task *task, struct ObjectEvent *objectEvent) +static bool8 WaterfallFieldEffect_Init(struct Task *task, struct ObjectEvent *objectEvent) { ScriptContext2_Enable(); gPlayerAvatar.preventStep = TRUE; - task->data[0]++; + task->tState++; return FALSE; } -static bool8 WaterfallFieldEffect_1(struct Task *task, struct ObjectEvent *objectEvent) +static bool8 WaterfallFieldEffect_ShowMon(struct Task *task, struct ObjectEvent *objectEvent) { ScriptContext2_Enable(); if (!ObjectEventIsMovementOverridden(objectEvent)) { ObjectEventClearHeldMovementIfFinished(objectEvent); - gFieldEffectArguments[0] = task->data[1]; + gFieldEffectArguments[0] = task->tMonId; FieldEffectStart(FLDEFF_FIELD_MOVE_SHOW_MON_INIT); - task->data[0]++; + task->tState++; } return FALSE; } -static bool8 WaterfallFieldEffect_2(struct Task *task, struct ObjectEvent *objectEvent) +static bool8 WaterfallFieldEffect_WaitForShowMon(struct Task *task, struct ObjectEvent *objectEvent) { if (FieldEffectActiveListContains(FLDEFF_FIELD_MOVE_SHOW_MON)) { return FALSE; } - task->data[0]++; + task->tState++; return TRUE; } -static bool8 WaterfallFieldEffect_3(struct Task *task, struct ObjectEvent *objectEvent) +static bool8 WaterfallFieldEffect_RideUp(struct Task *task, struct ObjectEvent *objectEvent) { ObjectEventSetHeldMovement(objectEvent, GetWalkSlowMovementAction(DIR_NORTH)); - task->data[0]++; + task->tState++; return FALSE; } -static bool8 WaterfallFieldEffect_4(struct Task *task, struct ObjectEvent *objectEvent) +static bool8 WaterfallFieldEffect_ContinueRideOrEnd(struct Task *task, struct ObjectEvent *objectEvent) { if (!ObjectEventClearHeldMovementIfFinished(objectEvent)) - { return FALSE; - } + if (MetatileBehavior_IsWaterfall(objectEvent->currentMetatileBehavior)) { - // Still ascending waterfall - task->data[0] = 3; + // Still ascending waterfall, back to WaterfallFieldEffect_RideUp + task->tState = 3; return TRUE; } + ScriptContext2_Disable(); gPlayerAvatar.preventStep = FALSE; DestroyTask(FindTaskIdByFunc(Task_UseWaterfall)); @@ -1824,6 +1885,9 @@ static bool8 WaterfallFieldEffect_4(struct Task *task, struct ObjectEvent *objec return FALSE; } +#undef tState +#undef tMonId + bool8 FldEff_UseDive(void) { u8 taskId; @@ -1839,14 +1903,14 @@ void Task_UseDive(u8 taskId) while (sDiveFieldEffectFuncs[gTasks[taskId].data[0]](&gTasks[taskId])); } -static bool8 DiveFieldEffect_0(struct Task *task) +static bool8 DiveFieldEffect_Init(struct Task *task) { gPlayerAvatar.preventStep = TRUE; task->data[0]++; return FALSE; } -static bool8 DiveFieldEffect_1(struct Task *task) +static bool8 DiveFieldEffect_ShowMon(struct Task *task) { ScriptContext2_Enable(); gFieldEffectArguments[0] = task->data[15]; @@ -1855,10 +1919,12 @@ static bool8 DiveFieldEffect_1(struct Task *task) return FALSE; } -static bool8 DiveFieldEffect_2(struct Task *task) +static bool8 DiveFieldEffect_TryWarp(struct Task *task) { struct MapPosition mapPosition; PlayerGetDestCoords(&mapPosition.x, &mapPosition.y); + + // Wait for show mon first if (!FieldEffectActiveListContains(FLDEFF_FIELD_MOVE_SHOW_MON)) { TryDoDiveWarp(&mapPosition, gObjectEvents[gPlayerAvatar.objectEventId].currentMetatileBehavior); @@ -1878,7 +1944,7 @@ static void Task_LavaridgeGymB1FWarp(u8 taskId) while (sLavaridgeGymB1FWarpEffectFuncs[gTasks[taskId].data[0]](&gTasks[taskId], &gObjectEvents[gPlayerAvatar.objectEventId], &gSprites[gPlayerAvatar.spriteId])); } -static bool8 LavaridgeGymB1FWarpEffect_0(struct Task *task, struct ObjectEvent *objectEvent, struct Sprite *sprite) +static bool8 LavaridgeGymB1FWarpEffect_Init(struct Task *task, struct ObjectEvent *objectEvent, struct Sprite *sprite) { FreezeObjectEvents(); CameraObjectReset2(); @@ -1890,7 +1956,7 @@ static bool8 LavaridgeGymB1FWarpEffect_0(struct Task *task, struct ObjectEvent * return TRUE; } -static bool8 LavaridgeGymB1FWarpEffect_1(struct Task *task, struct ObjectEvent *objectEvent, struct Sprite *sprite) +static bool8 LavaridgeGymB1FWarpEffect_CameraShake(struct Task *task, struct ObjectEvent *objectEvent, struct Sprite *sprite) { SetCameraPanning(0, task->data[1]); task->data[1] = -task->data[1]; @@ -1903,7 +1969,7 @@ static bool8 LavaridgeGymB1FWarpEffect_1(struct Task *task, struct ObjectEvent * return FALSE; } -static bool8 LavaridgeGymB1FWarpEffect_2(struct Task *task, struct ObjectEvent *objectEvent, struct Sprite *sprite) +static bool8 LavaridgeGymB1FWarpEffect_Launch(struct Task *task, struct ObjectEvent *objectEvent, struct Sprite *sprite) { sprite->pos2.y = 0; task->data[3] = 1; @@ -1911,13 +1977,13 @@ static bool8 LavaridgeGymB1FWarpEffect_2(struct Task *task, struct ObjectEvent * gFieldEffectArguments[1] = objectEvent->currentCoords.y; gFieldEffectArguments[2] = sprite->subpriority - 1; gFieldEffectArguments[3] = sprite->oam.priority; - FieldEffectStart(FLDEFF_LAVARIDGE_GYM_WARP); + FieldEffectStart(FLDEFF_ASH_LAUNCH); PlaySE(SE_W153); task->data[0]++; return TRUE; } -static bool8 LavaridgeGymB1FWarpEffect_3(struct Task *task, struct ObjectEvent *objectEvent, struct Sprite *sprite) +static bool8 LavaridgeGymB1FWarpEffect_Rise(struct Task *task, struct ObjectEvent *objectEvent, struct Sprite *sprite) { s16 centerToCornerVecY; SetCameraPanning(0, task->data[1]); @@ -1960,7 +2026,7 @@ static bool8 LavaridgeGymB1FWarpEffect_3(struct Task *task, struct ObjectEvent * return FALSE; } -static bool8 LavaridgeGymB1FWarpEffect_4(struct Task *task, struct ObjectEvent *objectEvent, struct Sprite *sprite) +static bool8 LavaridgeGymB1FWarpEffect_FadeOut(struct Task *task, struct ObjectEvent *objectEvent, struct Sprite *sprite) { TryFadeOutOldMapMusic(); WarpFadeOutScreen(); @@ -1968,7 +2034,7 @@ static bool8 LavaridgeGymB1FWarpEffect_4(struct Task *task, struct ObjectEvent * return FALSE; } -static bool8 LavaridgeGymB1FWarpEffect_5(struct Task *task, struct ObjectEvent *objectEvent, struct Sprite *sprite) +static bool8 LavaridgeGymB1FWarpEffect_Warp(struct Task *task, struct ObjectEvent *objectEvent, struct Sprite *sprite) { if (!gPaletteFade.active && BGMusicStopped() == TRUE) { @@ -1994,7 +2060,7 @@ static void Task_LavaridgeGymB1FWarpExit(u8 taskId) while (sLavaridgeGymB1FWarpExitEffectFuncs[gTasks[taskId].data[0]](&gTasks[taskId], &gObjectEvents[gPlayerAvatar.objectEventId], &gSprites[gPlayerAvatar.spriteId])); } -static bool8 LavaridgeGymB1FWarpExitEffect_0(struct Task *task, struct ObjectEvent *objectEvent, struct Sprite *sprite) +static bool8 LavaridgeGymB1FWarpExitEffect_Init(struct Task *task, struct ObjectEvent *objectEvent, struct Sprite *sprite) { CameraObjectReset2(); FreezeObjectEvents(); @@ -2004,7 +2070,7 @@ static bool8 LavaridgeGymB1FWarpExitEffect_0(struct Task *task, struct ObjectEve return FALSE; } -static bool8 LavaridgeGymB1FWarpExitEffect_1(struct Task *task, struct ObjectEvent *objectEvent, struct Sprite *sprite) +static bool8 LavaridgeGymB1FWarpExitEffect_StartPopOut(struct Task *task, struct ObjectEvent *objectEvent, struct Sprite *sprite) { if (IsWeatherNotFadingIn()) { @@ -2012,13 +2078,13 @@ static bool8 LavaridgeGymB1FWarpExitEffect_1(struct Task *task, struct ObjectEve gFieldEffectArguments[1] = objectEvent->currentCoords.y; gFieldEffectArguments[2] = sprite->subpriority - 1; gFieldEffectArguments[3] = sprite->oam.priority; - task->data[1] = FieldEffectStart(FLDEFF_POP_OUT_OF_ASH); + task->data[1] = FieldEffectStart(FLDEFF_ASH_PUFF); task->data[0]++; } return FALSE; } -static bool8 LavaridgeGymB1FWarpExitEffect_2(struct Task *task, struct ObjectEvent *objectEvent, struct Sprite *sprite) +static bool8 LavaridgeGymB1FWarpExitEffect_PopOut(struct Task *task, struct ObjectEvent *objectEvent, struct Sprite *sprite) { sprite = &gSprites[task->data[1]]; if (sprite->animCmdIndex > 1) @@ -2032,7 +2098,7 @@ static bool8 LavaridgeGymB1FWarpExitEffect_2(struct Task *task, struct ObjectEve return FALSE; } -static bool8 LavaridgeGymB1FWarpExitEffect_3(struct Task *task, struct ObjectEvent *objectEvent, struct Sprite *sprite) +static bool8 LavaridgeGymB1FWarpExitEffect_End(struct Task *task, struct ObjectEvent *objectEvent, struct Sprite *sprite) { if (ObjectEventClearHeldMovementIfFinished(objectEvent)) { @@ -2044,23 +2110,21 @@ static bool8 LavaridgeGymB1FWarpExitEffect_3(struct Task *task, struct ObjectEve return FALSE; } -// For the ash puff effect when warping off the B1F ash tiles -u8 FldEff_LavaridgeGymWarp(void) +// For the ash effect when jumping off the Lavaridge Gym B1F warp tiles +u8 FldEff_AshLaunch(void) { u8 spriteId; sub_80930E0((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 8); - spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_LAVARIDGE_GYM_WARP], gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2]); + spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_ASH_LAUNCH], gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2]); gSprites[spriteId].oam.priority = gFieldEffectArguments[3]; gSprites[spriteId].coordOffsetEnabled = TRUE; return spriteId; } -void SpriteCB_LavaridgeGymWarp(struct Sprite *sprite) +void SpriteCB_AshLaunch(struct Sprite *sprite) { if (sprite->animEnded) - { - FieldEffectStop(sprite, FLDEFF_LAVARIDGE_GYM_WARP); - } + FieldEffectStop(sprite, FLDEFF_ASH_LAUNCH); } void StartLavaridgeGym1FWarp(u8 priority) @@ -2073,7 +2137,7 @@ static void Task_LavaridgeGym1FWarp(u8 taskId) while(sLavaridgeGym1FWarpEffectFuncs[gTasks[taskId].data[0]](&gTasks[taskId], &gObjectEvents[gPlayerAvatar.objectEventId], &gSprites[gPlayerAvatar.spriteId])); } -static bool8 LavaridgeGym1FWarpEffect_0(struct Task *task, struct ObjectEvent *objectEvent, struct Sprite *sprite) +static bool8 LavaridgeGym1FWarpEffect_Init(struct Task *task, struct ObjectEvent *objectEvent, struct Sprite *sprite) { FreezeObjectEvents(); CameraObjectReset2(); @@ -2083,7 +2147,7 @@ static bool8 LavaridgeGym1FWarpEffect_0(struct Task *task, struct ObjectEvent *o return FALSE; } -static bool8 LavaridgeGym1FWarpEffect_1(struct Task *task, struct ObjectEvent *objectEvent, struct Sprite *sprite) +static bool8 LavaridgeGym1FWarpEffect_AshPuff(struct Task *task, struct ObjectEvent *objectEvent, struct Sprite *sprite) { if (ObjectEventClearHeldMovementIfFinished(objectEvent)) { @@ -2093,7 +2157,7 @@ static bool8 LavaridgeGym1FWarpEffect_1(struct Task *task, struct ObjectEvent *o gFieldEffectArguments[1] = objectEvent->currentCoords.y; gFieldEffectArguments[2] = sprite->subpriority - 1; gFieldEffectArguments[3] = sprite->oam.priority; - task->data[1] = FieldEffectStart(FLDEFF_POP_OUT_OF_ASH); + task->data[1] = FieldEffectStart(FLDEFF_ASH_PUFF); task->data[0]++; } else { @@ -2105,7 +2169,7 @@ static bool8 LavaridgeGym1FWarpEffect_1(struct Task *task, struct ObjectEvent *o return FALSE; } -static bool8 LavaridgeGym1FWarpEffect_2(struct Task *task, struct ObjectEvent *objectEvent, struct Sprite *sprite) +static bool8 LavaridgeGym1FWarpEffect_Disappear(struct Task *task, struct ObjectEvent *objectEvent, struct Sprite *sprite) { if (gSprites[task->data[1]].animCmdIndex == 2) { @@ -2115,9 +2179,9 @@ static bool8 LavaridgeGym1FWarpEffect_2(struct Task *task, struct ObjectEvent *o return FALSE; } -static bool8 LavaridgeGym1FWarpEffect_3(struct Task *task, struct ObjectEvent *objectEvent, struct Sprite *sprite) +static bool8 LavaridgeGym1FWarpEffect_FadeOut(struct Task *task, struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (!FieldEffectActiveListContains(FLDEFF_POP_OUT_OF_ASH)) + if (!FieldEffectActiveListContains(FLDEFF_ASH_PUFF)) { TryFadeOutOldMapMusic(); WarpFadeOutScreen(); @@ -2126,7 +2190,7 @@ static bool8 LavaridgeGym1FWarpEffect_3(struct Task *task, struct ObjectEvent *o return FALSE; } -static bool8 LavaridgeGym1FWarpEffect_4(struct Task *task, struct ObjectEvent *objectEvent, struct Sprite *sprite) +static bool8 LavaridgeGym1FWarpEffect_Warp(struct Task *task, struct ObjectEvent *objectEvent, struct Sprite *sprite) { if (!gPaletteFade.active && BGMusicStopped() == TRUE) { @@ -2138,24 +2202,29 @@ static bool8 LavaridgeGym1FWarpEffect_4(struct Task *task, struct ObjectEvent *o return FALSE; } -u8 FldEff_PopOutOfAsh(void) +// For the ash effect when a trainer pops out of ash, or when the player enters/exits a warp in Lavaridge Gym 1F +u8 FldEff_AshPuff(void) { u8 spriteId; sub_80930E0((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 8); - spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_JUMP_OUT_OF_ASH], gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2]); + spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_ASH_PUFF], gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2]); gSprites[spriteId].oam.priority = gFieldEffectArguments[3]; gSprites[spriteId].coordOffsetEnabled = TRUE; return spriteId; } -void SpriteCB_PopOutOfAsh(struct Sprite *sprite) +void SpriteCB_AshPuff(struct Sprite *sprite) { if (sprite->animEnded) - { - FieldEffectStop(sprite, FLDEFF_POP_OUT_OF_ASH); - } + FieldEffectStop(sprite, FLDEFF_ASH_PUFF); } +#define tState data[0] +#define tSpinDelay data[1] +#define tNumTurns data[2] +#define tTimer data[14] +#define tStartDir data[15] + void StartEscapeRopeFieldEffect(void) { ScriptContext2_Enable(); @@ -2165,21 +2234,21 @@ void StartEscapeRopeFieldEffect(void) static void Task_EscapeRopeWarpOut(u8 taskId) { - sEscapeRopeWarpOutFieldEffectFuncs[gTasks[taskId].data[0]](&gTasks[taskId]); + sEscapeRopeWarpOutEffectFuncs[gTasks[taskId].tState](&gTasks[taskId]); } -static void EscapeRopeWarpOutFieldEffect_0(struct Task *task) +static void EscapeRopeWarpOutEffect_Init(struct Task *task) { - task->data[0]++; - task->data[14] = 64; - task->data[15] = GetPlayerFacingDirection(); + task->tState++; + task->tTimer = 64; + task->tStartDir = GetPlayerFacingDirection(); } -static void EscapeRopeWarpOutFieldEffect_1(struct Task *task) +static void EscapeRopeWarpOutEffect_Spin(struct Task *task) { struct ObjectEvent *objectEvent; u8 spinDirections[5] = {DIR_SOUTH, DIR_WEST, DIR_EAST, DIR_NORTH, DIR_SOUTH}; - if (task->data[14] != 0 && (--task->data[14]) == 0) + if (task->tTimer != 0 && (--task->tTimer) == 0) { TryFadeOutOldMapMusic(); WarpFadeOutScreen(); @@ -2187,29 +2256,28 @@ static void EscapeRopeWarpOutFieldEffect_1(struct Task *task) objectEvent = &gObjectEvents[gPlayerAvatar.objectEventId]; if (!ObjectEventIsMovementOverridden(objectEvent) || ObjectEventClearHeldMovementIfFinished(objectEvent)) { - if (task->data[14] == 0 && !gPaletteFade.active && BGMusicStopped() == TRUE) + if (task->tTimer == 0 && !gPaletteFade.active && BGMusicStopped() == TRUE) { - SetObjectEventDirection(objectEvent, task->data[15]); + SetObjectEventDirection(objectEvent, task->tStartDir); SetWarpDestinationToEscapeWarp(); WarpIntoMap(); gFieldCallback = FieldCallback_EscapeRopeWarpIn; SetMainCallback2(CB2_LoadMap); DestroyTask(FindTaskIdByFunc(Task_EscapeRopeWarpOut)); - } else if (task->data[1] == 0 || (--task->data[1]) == 0) + } + else if (task->tSpinDelay == 0 || (--task->tSpinDelay) == 0) { ObjectEventSetHeldMovement(objectEvent, GetFaceDirectionMovementAction(spinDirections[objectEvent->facingDirection])); - if (task->data[2] < 12) - { - task->data[2]++; - } - task->data[1] = 8 >> (task->data[2] >> 2); + if (task->tNumTurns < 12) + task->tNumTurns++; + task->tSpinDelay = 8 >> (task->tNumTurns >> 2); } } } -void (*const sEscapeRopeWarpInFieldEffectFuncs[])(struct Task *) = { - EscapeRopeWarpInFieldEffect_0, - EscapeRopeWarpInFieldEffect_1 +void (*const sEscapeRopeWarpInEffectFuncs[])(struct Task *) = { + EscapeRopeWarpInEffect_Init, + EscapeRopeWarpInEffect_Spin }; static void FieldCallback_EscapeRopeWarpIn(void) @@ -2225,29 +2293,29 @@ static void FieldCallback_EscapeRopeWarpIn(void) static void Task_EscapeRopeWarpIn(u8 taskId) { - sEscapeRopeWarpInFieldEffectFuncs[gTasks[taskId].data[0]](&gTasks[taskId]); + sEscapeRopeWarpInEffectFuncs[gTasks[taskId].tState](&gTasks[taskId]); } -static void EscapeRopeWarpInFieldEffect_0(struct Task *task) +static void EscapeRopeWarpInEffect_Init(struct Task *task) { if (IsWeatherNotFadingIn()) { - task->data[0]++; - task->data[15] = GetPlayerFacingDirection(); + task->tState++; + task->tStartDir = GetPlayerFacingDirection(); } } -static void EscapeRopeWarpInFieldEffect_1(struct Task *task) +static void EscapeRopeWarpInEffect_Spin(struct Task *task) { u8 spinDirections[5] = {DIR_SOUTH, DIR_WEST, DIR_EAST, DIR_NORTH, DIR_SOUTH}; struct ObjectEvent *objectEvent = &gObjectEvents[gPlayerAvatar.objectEventId]; - if (task->data[1] == 0 || (--task->data[1]) == 0) + if (task->tSpinDelay == 0 || (--task->tSpinDelay) == 0) { if (ObjectEventIsMovementOverridden(objectEvent) && !ObjectEventClearHeldMovementIfFinished(objectEvent)) { return; } - if (task->data[2] >= 32 && task->data[15] == GetPlayerFacingDirection()) + if (task->tNumTurns >= 32 && task->tStartDir == GetPlayerFacingDirection()) { objectEvent->invisible = FALSE; ScriptContext2_Disable(); @@ -2256,42 +2324,48 @@ static void EscapeRopeWarpInFieldEffect_1(struct Task *task) return; } ObjectEventSetHeldMovement(objectEvent, GetFaceDirectionMovementAction(spinDirections[objectEvent->facingDirection])); - if (task->data[2] < 32) - { - task->data[2]++; - } - task->data[1] = task->data[2] >> 2; + if (task->tNumTurns < 32) + task->tNumTurns++; + task->tSpinDelay = task->tNumTurns >> 2; } objectEvent->invisible ^= 1; } +#undef tState +#undef tSpinDelay +#undef tNumTurns +#undef tTimer +#undef tStartDir + +#define tState data[0] + void FldEff_TeleportWarpOut(void) { CreateTask(Task_TeleportWarpOut, 0); } static void (*const sTeleportWarpOutFieldEffectFuncs[])(struct Task *) = { - TeleportWarpOutFieldEffect_0, - TeleportWarpOutFieldEffect_1, - TeleportWarpOutFieldEffect_2, - TeleportWarpOutFieldEffect_3 + TeleportWarpOutFieldEffect_Init, + TeleportWarpOutFieldEffect_SpinGround, + TeleportWarpOutFieldEffect_SpinExit, + TeleportWarpOutFieldEffect_End }; static void Task_TeleportWarpOut(u8 taskId) { - sTeleportWarpOutFieldEffectFuncs[gTasks[taskId].data[0]](&gTasks[taskId]); + sTeleportWarpOutFieldEffectFuncs[gTasks[taskId].tState](&gTasks[taskId]); } -static void TeleportWarpOutFieldEffect_0(struct Task *task) +static void TeleportWarpOutFieldEffect_Init(struct Task *task) { ScriptContext2_Enable(); FreezeObjectEvents(); CameraObjectReset2(); task->data[15] = GetPlayerFacingDirection(); - task->data[0]++; + task->tState++; } -static void TeleportWarpOutFieldEffect_1(struct Task *task) +static void TeleportWarpOutFieldEffect_SpinGround(struct Task *task) { u8 spinDirections[5] = {DIR_SOUTH, DIR_WEST, DIR_EAST, DIR_NORTH, DIR_SOUTH}; struct ObjectEvent *objectEvent = &gObjectEvents[gPlayerAvatar.objectEventId]; @@ -2303,7 +2377,7 @@ static void TeleportWarpOutFieldEffect_1(struct Task *task) } if (task->data[2] > 7 && task->data[15] == objectEvent->facingDirection) { - task->data[0]++; + task->tState++; task->data[1] = 4; task->data[2] = 8; task->data[3] = 1; @@ -2311,7 +2385,7 @@ static void TeleportWarpOutFieldEffect_1(struct Task *task) } } -static void TeleportWarpOutFieldEffect_2(struct Task *task) +static void TeleportWarpOutFieldEffect_SpinExit(struct Task *task) { u8 spinDirections[5] = {DIR_SOUTH, DIR_WEST, DIR_EAST, DIR_NORTH, DIR_SOUTH}; struct ObjectEvent *objectEvent = &gObjectEvents[gPlayerAvatar.objectEventId]; @@ -2333,13 +2407,13 @@ static void TeleportWarpOutFieldEffect_2(struct Task *task) } if (task->data[4] >= 0xa8) { - task->data[0]++; + task->tState++; TryFadeOutOldMapMusic(); WarpFadeOutScreen(); } } -static void TeleportWarpOutFieldEffect_3(struct Task *task) +static void TeleportWarpOutFieldEffect_End(struct Task *task) { if (!gPaletteFade.active) { @@ -2373,9 +2447,9 @@ static void FieldCallback_TeleportWarpIn(void) } void (*const sTeleportWarpInFieldEffectFuncs[])(struct Task *) = { - TeleportWarpInFieldEffect_0, - TeleportWarpInFieldEffect_1, - TeleportWarpInFieldEffect_2 + TeleportWarpInFieldEffect_Init, + TeleportWarpInFieldEffect_SpinEnter, + TeleportWarpInFieldEffect_SpinGround }; static void Task_TeleportWarpIn(u8 taskId) @@ -2383,7 +2457,7 @@ static void Task_TeleportWarpIn(u8 taskId) sTeleportWarpInFieldEffectFuncs[gTasks[taskId].data[0]](&gTasks[taskId]); } -static void TeleportWarpInFieldEffect_0(struct Task *task) +static void TeleportWarpInFieldEffect_Init(struct Task *task) { struct Sprite *sprite; s16 centerToCornerVecY; @@ -2402,7 +2476,7 @@ static void TeleportWarpInFieldEffect_0(struct Task *task) } } -static void TeleportWarpInFieldEffect_1(struct Task *task) +static void TeleportWarpInFieldEffect_SpinEnter(struct Task *task) { u8 spinDirections[5] = {DIR_SOUTH, DIR_WEST, DIR_EAST, DIR_NORTH, DIR_SOUTH}; struct ObjectEvent *objectEvent = &gObjectEvents[gPlayerAvatar.objectEventId]; @@ -2441,7 +2515,7 @@ static void TeleportWarpInFieldEffect_1(struct Task *task) } } -static void TeleportWarpInFieldEffect_2(struct Task *task) +static void TeleportWarpInFieldEffect_SpinGround(struct Task *task) { u8 spinDirections[5] = {DIR_SOUTH, DIR_WEST, DIR_EAST, DIR_NORTH, DIR_SOUTH}; struct ObjectEvent *objectEvent = &gObjectEvents[gPlayerAvatar.objectEventId]; @@ -2459,17 +2533,34 @@ static void TeleportWarpInFieldEffect_2(struct Task *task) } } +// Task data for Task_FieldMoveShowMonOutDoors +#define tState data[0] +#define tWinHoriz data[1] +#define tWinVert data[2] +#define tWinIn data[3] +#define tWinOut data[4] +#define tBgHoriz data[5] +#define tBgVert data[6] +#define tMonSpriteId data[15] + +// Sprite data for field move mon sprite +#define sSpecies data[0] +#define sOnscreenTimer data[1] +#define sSlidOffscreen data[7] + +// There are two variants (outdoor/indoor) of the "show mon for a field move" effect +// Outdoor has a black background with thick white streaks and appears from the right by stretching vertically and horizontally +// Indoor has blue background with thin white streaks and appears from the left by stretching horizontally +// For both the background streaks move to the right, and the mon sprite enters from the right and exits left bool8 FldEff_FieldMoveShowMon(void) { u8 taskId; if (IsMapTypeOutdoors(GetCurrentMapType()) == TRUE) - { taskId = CreateTask(Task_FieldMoveShowMonOutdoors, 0xff); - } else - { + else taskId = CreateTask(Task_FieldMoveShowMonIndoors, 0xff); - } - gTasks[taskId].data[15] = sub_80B8C60(gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2]); + + gTasks[taskId].tMonSpriteId = InitFieldMoveMonSprite(gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2]); return FALSE; } @@ -2488,132 +2579,127 @@ bool8 FldEff_FieldMoveShowMonInit(void) } void (*const sFieldMoveShowMonOutdoorsEffectFuncs[])(struct Task *) = { - FieldMoveShowMonOutdoorsEffect_0, - FieldMoveShowMonOutdoorsEffect_1, - FieldMoveShowMonOutdoorsEffect_2, - FieldMoveShowMonOutdoorsEffect_3, - FieldMoveShowMonOutdoorsEffect_4, - FieldMoveShowMonOutdoorsEffect_5, - FieldMoveShowMonOutdoorsEffect_6, + FieldMoveShowMonOutdoorsEffect_Init, + FieldMoveShowMonOutdoorsEffect_LoadGfx, + FieldMoveShowMonOutdoorsEffect_CreateBanner, + FieldMoveShowMonOutdoorsEffect_WaitForMon, + FieldMoveShowMonOutdoorsEffect_ShrinkBanner, + FieldMoveShowMonOutdoorsEffect_RestoreBg, + FieldMoveShowMonOutdoorsEffect_End, }; static void Task_FieldMoveShowMonOutdoors(u8 taskId) { - sFieldMoveShowMonOutdoorsEffectFuncs[gTasks[taskId].data[0]](&gTasks[taskId]); + sFieldMoveShowMonOutdoorsEffectFuncs[gTasks[taskId].tState](&gTasks[taskId]); } -static void FieldMoveShowMonOutdoorsEffect_0(struct Task *task) +static void FieldMoveShowMonOutdoorsEffect_Init(struct Task *task) { task->data[11] = REG_WININ; task->data[12] = REG_WINOUT; StoreWordInTwoHalfwords(&task->data[13], (u32)gMain.vblankCallback); - task->data[1] = 0xf0f1; - task->data[2] = 0x5051; - task->data[3] = 0x3f; - task->data[4] = 0x3e; - SetGpuReg(REG_OFFSET_WIN0H, task->data[1]); - SetGpuReg(REG_OFFSET_WIN0V, task->data[2]); - SetGpuReg(REG_OFFSET_WININ, task->data[3]); - SetGpuReg(REG_OFFSET_WINOUT, task->data[4]); + task->tWinHoriz = WIN_RANGE(240, 241); + task->tWinVert = WIN_RANGE(80, 81); + task->tWinIn = WININ_WIN0_BG_ALL | WININ_WIN0_OBJ | WININ_WIN0_CLR; + task->tWinOut = WINOUT_WIN01_BG1 | WINOUT_WIN01_BG2 | WINOUT_WIN01_BG3 | WINOUT_WIN01_OBJ | WINOUT_WIN01_CLR; + SetGpuReg(REG_OFFSET_WIN0H, task->tWinHoriz); + SetGpuReg(REG_OFFSET_WIN0V, task->tWinVert); + SetGpuReg(REG_OFFSET_WININ, task->tWinIn); + SetGpuReg(REG_OFFSET_WINOUT, task->tWinOut); SetVBlankCallback(VBlankCB_FieldMoveShowMonOutdoors); - task->data[0]++; + task->tState++; } -static void FieldMoveShowMonOutdoorsEffect_1(struct Task *task) +static void FieldMoveShowMonOutdoorsEffect_LoadGfx(struct Task *task) { u16 offset = ((REG_BG0CNT >> 2) << 14); u16 delta = ((REG_BG0CNT >> 8) << 11); - CpuCopy16(gFieldMoveStreaksTiles, (void *)(VRAM + offset), 0x200); + CpuCopy16(sFieldMoveStreaksOutdoors_Gfx, (void *)(VRAM + offset), 0x200); CpuFill32(0, (void *)(VRAM + delta), 0x800); - LoadPalette(gFieldMoveStreaksPalette, 0xf0, 0x20); - sub_80B8874(delta); - task->data[0]++; + LoadPalette(sFieldMoveStreaksOutdoors_Pal, 0xf0, 0x20); + LoadFieldMoveOutdoorStreaksTilemap(delta); + task->tState++; } -static void FieldMoveShowMonOutdoorsEffect_2(struct Task *task) +static void FieldMoveShowMonOutdoorsEffect_CreateBanner(struct Task *task) { - s16 v0; - s16 v2; - s16 v3; - task->data[5] -= 16; - v0 = ((u16)task->data[1] >> 8); - v2 = ((u16)task->data[2] >> 8); - v3 = ((u16)task->data[2] & 0xff); - v0 -= 16; - v2 -= 2; - v3 += 2; - if (v0 < 0) + s16 horiz; + s16 vertHi; + s16 vertLo; + task->tBgHoriz -= 16; + horiz = ((u16)task->tWinHoriz >> 8); + vertHi = ((u16)task->tWinVert >> 8); + vertLo = ((u16)task->tWinVert & 0xff); + horiz -= 16; + vertHi -= 2; + vertLo += 2; + + if (horiz < 0) + horiz = 0; + + if (vertHi < 40) + vertHi = 40; + + if (vertLo > 120) + vertLo = 120; + + task->tWinHoriz = (horiz << 8) | (task->tWinHoriz & 0xff); + task->tWinVert = (vertHi << 8) | vertLo; + if (horiz == 0 && vertHi == 40 && vertLo == 120) { - v0 = 0; - } - if (v2 < 0x28) - { - v2 = 0x28; - } - if (v3 > 0x78) - { - v3 = 0x78; - } - task->data[1] = (v0 << 8) | (task->data[1] & 0xff); - task->data[2] = (v2 << 8) | v3; - if (v0 == 0 && v2 == 0x28 && v3 == 0x78) - { - gSprites[task->data[15]].callback = sub_80B8CC0; - task->data[0]++; + gSprites[task->tMonSpriteId].callback = SpriteCB_FieldMoveMonSlideOnscreen; + task->tState++; } } -static void FieldMoveShowMonOutdoorsEffect_3(struct Task *task) +static void FieldMoveShowMonOutdoorsEffect_WaitForMon(struct Task *task) { - task->data[5] -= 16; - if (gSprites[task->data[15]].data[7]) - { - task->data[0]++; - } + task->tBgHoriz -= 16; + + if (gSprites[task->tMonSpriteId].sSlidOffscreen) + task->tState++; } -static void FieldMoveShowMonOutdoorsEffect_4(struct Task *task) +static void FieldMoveShowMonOutdoorsEffect_ShrinkBanner(struct Task *task) { - s16 v2; - s16 v3; - task->data[5] -= 16; - v2 = (task->data[2] >> 8); - v3 = (task->data[2] & 0xff); - v2 += 6; - v3 -= 6; - if (v2 > 0x50) - { - v2 = 0x50; - } - if (v3 < 0x51) - { - v3 = 0x51; - } - task->data[2] = (v2 << 8) | v3; - if (v2 == 0x50 && v3 == 0x51) - { - task->data[0]++; - } + s16 vertHi; + s16 vertLo; + task->tBgHoriz -= 16; + vertHi = (task->tWinVert >> 8); + vertLo = (task->tWinVert & 0xFF); + vertHi += 6; + vertLo -= 6; + + if (vertHi > 80) + vertHi = 80; + + if (vertLo < 81) + vertLo = 81; + + task->tWinVert = (vertHi << 8) | vertLo; + + if (vertHi == 80 && vertLo == 81) + task->tState++; } -static void FieldMoveShowMonOutdoorsEffect_5(struct Task *task) +static void FieldMoveShowMonOutdoorsEffect_RestoreBg(struct Task *task) { u16 bg0cnt = (REG_BG0CNT >> 8) << 11; CpuFill32(0, (void *)VRAM + bg0cnt, 0x800); - task->data[1] = 0xf1; - task->data[2] = 0xa1; - task->data[3] = task->data[11]; - task->data[4] = task->data[12]; - task->data[0]++; + task->tWinHoriz = 241; + task->tWinVert = 161; + task->tWinIn = task->data[11]; + task->tWinOut = task->data[12]; + task->tState++; } -static void FieldMoveShowMonOutdoorsEffect_6(struct Task *task) +static void FieldMoveShowMonOutdoorsEffect_End(struct Task *task) { IntrCallback callback; LoadWordFromTwoHalfwords((u16 *)&task->data[13], (u32 *)&callback); SetVBlankCallback(callback); InitTextBoxGfxAndPrinters(); - FreeResourcesAndDestroySprite(&gSprites[task->data[15]], task->data[15]); + FreeResourcesAndDestroySprite(&gSprites[task->tMonSpriteId], task->tMonSpriteId); FieldEffectActiveListRemove(FLDEFF_FIELD_MOVE_SHOW_MON); DestroyTask(FindTaskIdByFunc(Task_FieldMoveShowMonOutdoors)); } @@ -2624,103 +2710,116 @@ static void VBlankCB_FieldMoveShowMonOutdoors(void) struct Task *task = &gTasks[FindTaskIdByFunc(Task_FieldMoveShowMonOutdoors)]; LoadWordFromTwoHalfwords((u16 *)&task->data[13], (u32 *)&callback); callback(); - SetGpuReg(REG_OFFSET_WIN0H, task->data[1]); - SetGpuReg(REG_OFFSET_WIN0V, task->data[2]); - SetGpuReg(REG_OFFSET_WININ, task->data[3]); - SetGpuReg(REG_OFFSET_WINOUT, task->data[4]); - SetGpuReg(REG_OFFSET_BG0HOFS, task->data[5]); - SetGpuReg(REG_OFFSET_BG0VOFS, task->data[6]); + SetGpuReg(REG_OFFSET_WIN0H, task->tWinHoriz); + SetGpuReg(REG_OFFSET_WIN0V, task->tWinVert); + SetGpuReg(REG_OFFSET_WININ, task->tWinIn); + SetGpuReg(REG_OFFSET_WINOUT, task->tWinOut); + SetGpuReg(REG_OFFSET_BG0HOFS, task->tBgHoriz); + SetGpuReg(REG_OFFSET_BG0VOFS, task->tBgVert); } -static void sub_80B8874(u16 offs) +static void LoadFieldMoveOutdoorStreaksTilemap(u16 offs) { u16 i; u16 *dest; - dest = (u16 *)(VRAM + 0x140 + offs); - for (i = 0; i < 0x140; i++, dest++) + dest = (u16 *)(VRAM + ARRAY_COUNT(sFieldMoveStreaksOutdoors_Tilemap) + offs); + for (i = 0; i < ARRAY_COUNT(sFieldMoveStreaksOutdoors_Tilemap); i++, dest++) { - *dest = gFieldMoveStreaksTilemap[i] | METATILE_ELEVATION_MASK; + *dest = sFieldMoveStreaksOutdoors_Tilemap[i] | 0xF000; } } +#undef tState +#undef tWinHoriz +#undef tWinVert +#undef tWinIn +#undef tWinOut +#undef tBgHoriz +#undef tBgVert +#undef tMonSpriteId + +// Task data for Task_FieldMoveShowMonIndoors +#define tState data[0] +#define tBgHoriz data[1] +#define tBgVert data[2] +#define tBgOffsetIdx data[3] +#define tBgOffset data[4] +#define tMonSpriteId data[15] + void (*const sFieldMoveShowMonIndoorsEffectFuncs[])(struct Task *) = { - FieldMoveShowMonIndoorsEffect_0, - FieldMoveShowMonIndoorsEffect_1, - FieldMoveShowMonIndoorsEffect_2, - FieldMoveShowMonIndoorsEffect_3, - FieldMoveShowMonIndoorsEffect_4, - FieldMoveShowMonIndoorsEffect_5, - FieldMoveShowMonIndoorsEffect_6, + FieldMoveShowMonIndoorsEffect_Init, + FieldMoveShowMonIndoorsEffect_LoadGfx, + FieldMoveShowMonIndoorsEffect_SlideBannerOn, + FieldMoveShowMonIndoorsEffect_WaitForMon, + FieldMoveShowMonIndoorsEffect_RestoreBg, + FieldMoveShowMonIndoorsEffect_SlideBannerOff, + FieldMoveShowMonIndoorsEffect_End, }; static void Task_FieldMoveShowMonIndoors(u8 taskId) { - sFieldMoveShowMonIndoorsEffectFuncs[gTasks[taskId].data[0]](&gTasks[taskId]); + sFieldMoveShowMonIndoorsEffectFuncs[gTasks[taskId].tState](&gTasks[taskId]); } -static void FieldMoveShowMonIndoorsEffect_0(struct Task *task) +static void FieldMoveShowMonIndoorsEffect_Init(struct Task *task) { - SetGpuReg(REG_OFFSET_BG0HOFS, task->data[1]); - SetGpuReg(REG_OFFSET_BG0VOFS, task->data[2]); + SetGpuReg(REG_OFFSET_BG0HOFS, task->tBgHoriz); + SetGpuReg(REG_OFFSET_BG0VOFS, task->tBgVert); StoreWordInTwoHalfwords((u16 *)&task->data[13], (u32)gMain.vblankCallback); SetVBlankCallback(VBlankCB_FieldMoveShowMonIndoors); - task->data[0]++; + task->tState++; } -static void FieldMoveShowMonIndoorsEffect_1(struct Task *task) +static void FieldMoveShowMonIndoorsEffect_LoadGfx(struct Task *task) { u16 offset; u16 delta; offset = ((REG_BG0CNT >> 2) << 14); delta = ((REG_BG0CNT >> 8) << 11); task->data[12] = delta; - CpuCopy16(gDarknessFieldMoveStreaksTiles, (void *)(VRAM + offset), 0x80); + CpuCopy16(sFieldMoveStreaksIndoors_Gfx, (void *)(VRAM + offset), 0x80); CpuFill32(0, (void *)(VRAM + delta), 0x800); - LoadPalette(gDarknessFieldMoveStreaksPalette, 0xf0, 0x20); - task->data[0]++; + LoadPalette(sFieldMoveStreaksIndoors_Pal, 0xf0, 0x20); + task->tState++; } -static void FieldMoveShowMonIndoorsEffect_2(struct Task *task) +static void FieldMoveShowMonIndoorsEffect_SlideBannerOn(struct Task *task) { - if (sub_80B8B38(task)) + if (SlideIndoorBannerOnscreen(task)) { SetGpuReg(REG_OFFSET_WIN1H, 0x00f0); SetGpuReg(REG_OFFSET_WIN1V, 0x2878); - gSprites[task->data[15]].callback = sub_80B8CC0; - task->data[0]++; + gSprites[task->tMonSpriteId].callback = SpriteCB_FieldMoveMonSlideOnscreen; + task->tState++; } - sub_80B8B28(task); + AnimateIndoorShowMonBg(task); } -static void FieldMoveShowMonIndoorsEffect_3(struct Task *task) +static void FieldMoveShowMonIndoorsEffect_WaitForMon(struct Task *task) { - sub_80B8B28(task); - if (gSprites[task->data[15]].data[7]) - { - task->data[0]++; - } + AnimateIndoorShowMonBg(task); + if (gSprites[task->tMonSpriteId].sSlidOffscreen) + task->tState++; } -static void FieldMoveShowMonIndoorsEffect_4(struct Task *task) +static void FieldMoveShowMonIndoorsEffect_RestoreBg(struct Task *task) { - sub_80B8B28(task); - task->data[3] = task->data[1] & 7; - task->data[4] = 0; + AnimateIndoorShowMonBg(task); + task->tBgOffsetIdx = task->tBgHoriz & 7; + task->tBgOffset = 0; SetGpuReg(REG_OFFSET_WIN1H, 0xffff); SetGpuReg(REG_OFFSET_WIN1V, 0xffff); - task->data[0]++; + task->tState++; } -static void FieldMoveShowMonIndoorsEffect_5(struct Task *task) +static void FieldMoveShowMonIndoorsEffect_SlideBannerOff(struct Task *task) { - sub_80B8B28(task); - if (sub_80B8BF0(task)) - { - task->data[0]++; - } + AnimateIndoorShowMonBg(task); + if (SlideIndoorBannerOffscreen(task)) + task->tState++; } -static void FieldMoveShowMonIndoorsEffect_6(struct Task *task) +static void FieldMoveShowMonIndoorsEffect_End(struct Task *task) { IntrCallback intrCallback; u16 bg0cnt; @@ -2729,7 +2828,7 @@ static void FieldMoveShowMonIndoorsEffect_6(struct Task *task) LoadWordFromTwoHalfwords((u16 *)&task->data[13], (u32 *)&intrCallback); SetVBlankCallback(intrCallback); InitTextBoxGfxAndPrinters(); - FreeResourcesAndDestroySprite(&gSprites[task->data[15]], task->data[15]); + FreeResourcesAndDestroySprite(&gSprites[task->tMonSpriteId], task->tMonSpriteId); FieldEffectActiveListRemove(FLDEFF_FIELD_MOVE_SHOW_MON); DestroyTask(FindTaskIdByFunc(Task_FieldMoveShowMonIndoors)); } @@ -2741,116 +2840,123 @@ static void VBlankCB_FieldMoveShowMonIndoors(void) task = &gTasks[FindTaskIdByFunc(Task_FieldMoveShowMonIndoors)]; LoadWordFromTwoHalfwords((u16 *)&task->data[13], (u32 *)&intrCallback); intrCallback(); - SetGpuReg(REG_OFFSET_BG0HOFS, task->data[1]); - SetGpuReg(REG_OFFSET_BG0VOFS, task->data[2]); + SetGpuReg(REG_OFFSET_BG0HOFS, task->tBgHoriz); + SetGpuReg(REG_OFFSET_BG0VOFS, task->tBgVert); } -static void sub_80B8B28(struct Task *task) +static void AnimateIndoorShowMonBg(struct Task *task) { - task->data[1] -= 16; - task->data[3] += 16; + task->tBgHoriz -= 16; + task->tBgOffsetIdx += 16; } -static bool8 sub_80B8B38(struct Task *task) +static bool8 SlideIndoorBannerOnscreen(struct Task *task) { u16 i; u16 srcOffs; u16 dstOffs; u16 *dest; - if (task->data[4] >= 32) - { + + if (task->tBgOffset >= 32) return TRUE; - } - dstOffs = (task->data[3] >> 3) & 0x1f; - if (dstOffs >= task->data[4]) + + dstOffs = (task->tBgOffsetIdx >> 3) & 0x1f; + if (dstOffs >= task->tBgOffset) { dstOffs = (32 - dstOffs) & 0x1f; - srcOffs = (32 - task->data[4]) & 0x1f; + srcOffs = (32 - task->tBgOffset) & 0x1f; dest = (u16 *)(VRAM + 0x140 + (u16)task->data[12]); for (i = 0; i < 10; i++) { - dest[dstOffs + i * 32] = gDarknessFieldMoveStreaksTilemap[srcOffs + i * 32]; + dest[dstOffs + i * 32] = sFieldMoveStreaksIndoors_Tilemap[srcOffs + i * 32]; dest[dstOffs + i * 32] |= 0xf000; - dest[((dstOffs + 1) & 0x1f) + i * 32] = gDarknessFieldMoveStreaksTilemap[((srcOffs + 1) & 0x1f) + i * 32] | 0xf000; + dest[((dstOffs + 1) & 0x1f) + i * 32] = sFieldMoveStreaksIndoors_Tilemap[((srcOffs + 1) & 0x1f) + i * 32] | 0xf000; dest[((dstOffs + 1) & 0x1f) + i * 32] |= 0xf000; } - task->data[4] += 2; + task->tBgOffset += 2; } return FALSE; } -static bool8 sub_80B8BF0(struct Task *task) +static bool8 SlideIndoorBannerOffscreen(struct Task *task) { u16 i; u16 dstOffs; u16 *dest; - if (task->data[4] >= 32) - { + + if (task->tBgOffset >= 32) return TRUE; - } - dstOffs = task->data[3] >> 3; - if (dstOffs >= task->data[4]) + + dstOffs = task->tBgOffsetIdx >> 3; + if (dstOffs >= task->tBgOffset) { - dstOffs = (task->data[1] >> 3) & 0x1f; + dstOffs = (task->tBgHoriz >> 3) & 0x1f; dest = (u16 *)(VRAM + 0x140 + (u16)task->data[12]); for (i = 0; i < 10; i++) { dest[dstOffs + i * 32] = 0xf000; dest[((dstOffs + 1) & 0x1f) + i * 32] = 0xf000; } - task->data[4] += 2; + task->tBgOffset += 2; } return FALSE; } -static u8 sub_80B8C60(u32 a0, u32 a1, u32 a2) +#undef tState +#undef tBgHoriz +#undef tBgVert +#undef tBgOffsetIdx +#undef tBgOffset +#undef tMonSpriteId + +static u8 InitFieldMoveMonSprite(u32 species, u32 otId, u32 personality) { u16 v0; u8 monSprite; struct Sprite *sprite; - v0 = (a0 & 0x80000000) >> 16; - a0 &= 0x7fffffff; - monSprite = CreateMonSprite_FieldMove(a0, a1, a2, 0x140, 0x50, 0); + v0 = (species & 0x80000000) >> 16; + species &= 0x7fffffff; + monSprite = CreateMonSprite_FieldMove(species, otId, personality, 0x140, 0x50, 0); sprite = &gSprites[monSprite]; sprite->callback = SpriteCallbackDummy; sprite->oam.priority = 0; - sprite->data[0] = a0; + sprite->sSpecies = species; sprite->data[6] = v0; return monSprite; } -static void sub_80B8CC0(struct Sprite *sprite) +static void SpriteCB_FieldMoveMonSlideOnscreen(struct Sprite *sprite) { - if ((sprite->pos1.x -= 20) <= 0x78) + if ((sprite->pos1.x -= 20) <= 120) { - sprite->pos1.x = 0x78; - sprite->data[1] = 30; - sprite->callback = sub_80B8D04; + sprite->pos1.x = 120; + sprite->sOnscreenTimer = 30; + sprite->callback = SpriteCB_FieldMoveMonWaitAfterCry; if (sprite->data[6]) { - PlayCry2(sprite->data[0], 0, 0x7d, 0xa); + PlayCry2(sprite->sSpecies, 0, 0x7d, 0xa); } else { - PlayCry1(sprite->data[0], 0); + PlayCry1(sprite->sSpecies, 0); } } } -static void sub_80B8D04(struct Sprite *sprite) +static void SpriteCB_FieldMoveMonWaitAfterCry(struct Sprite *sprite) { - if ((--sprite->data[1]) == 0) + if ((--sprite->sOnscreenTimer) == 0) { - sprite->callback = sub_80B8D20; + sprite->callback = SpriteCB_FieldMoveMonSlideOffscreen; } } -static void sub_80B8D20(struct Sprite *sprite) +static void SpriteCB_FieldMoveMonSlideOffscreen(struct Sprite *sprite) { - if (sprite->pos1.x < -0x40) + if (sprite->pos1.x < -64) { - sprite->data[7] = 1; + sprite->sSlidOffscreen = TRUE; } else { @@ -2858,40 +2964,51 @@ static void sub_80B8D20(struct Sprite *sprite) } } +#undef tState +#undef tMonSpriteId +#undef sSpecies +#undef sSlidOffscreen +#undef sOnscreenTimer + +#define tState data[0] +#define tDestX data[1] +#define tDestY data[2] +#define tMonId data[15] + u8 FldEff_UseSurf(void) { u8 taskId = CreateTask(Task_SurfFieldEffect, 0xff); - gTasks[taskId].data[15] = gFieldEffectArguments[0]; + gTasks[taskId].tMonId = gFieldEffectArguments[0]; Overworld_ClearSavedMusic(); Overworld_ChangeMusicTo(MUS_NAMINORI); return FALSE; } void (*const sSurfFieldEffectFuncs[])(struct Task *) = { - SurfFieldEffect_1, - SurfFieldEffect_2, - SurfFieldEffect_3, - SurfFieldEffect_4, - SurfFieldEffect_5, + SurfFieldEffect_Init, + SurfFieldEffect_FieldMovePose, + SurfFieldEffect_ShowMon, + SurfFieldEffect_JumpOnSurfBlob, + SurfFieldEffect_End, }; static void Task_SurfFieldEffect(u8 taskId) { - sSurfFieldEffectFuncs[gTasks[taskId].data[0]](&gTasks[taskId]); + sSurfFieldEffectFuncs[gTasks[taskId].tState](&gTasks[taskId]); } -static void SurfFieldEffect_1(struct Task *task) +static void SurfFieldEffect_Init(struct Task *task) { ScriptContext2_Enable(); FreezeObjectEvents(); gPlayerAvatar.preventStep = TRUE; SetPlayerAvatarStateMask(PLAYER_AVATAR_FLAG_SURFING); - PlayerGetDestCoords(&task->data[1], &task->data[2]); - MoveCoords(gObjectEvents[gPlayerAvatar.objectEventId].movementDirection, &task->data[1], &task->data[2]); - task->data[0]++; + PlayerGetDestCoords(&task->tDestX, &task->tDestY); + MoveCoords(gObjectEvents[gPlayerAvatar.objectEventId].movementDirection, &task->tDestX, &task->tDestY); + task->tState++; } -static void SurfFieldEffect_2(struct Task *task) +static void SurfFieldEffect_FieldMovePose(struct Task *task) { struct ObjectEvent *objectEvent; objectEvent = &gObjectEvents[gPlayerAvatar.objectEventId]; @@ -2899,23 +3016,23 @@ static void SurfFieldEffect_2(struct Task *task) { SetPlayerAvatarFieldMove(); ObjectEventSetHeldMovement(objectEvent, MOVEMENT_ACTION_START_ANIM_IN_DIRECTION); - task->data[0]++; + task->tState++; } } -static void SurfFieldEffect_3(struct Task *task) +static void SurfFieldEffect_ShowMon(struct Task *task) { struct ObjectEvent *objectEvent; objectEvent = &gObjectEvents[gPlayerAvatar.objectEventId]; if (ObjectEventCheckHeldMovementStatus(objectEvent)) { - gFieldEffectArguments[0] = task->data[15] | 0x80000000; + gFieldEffectArguments[0] = task->tMonId | 0x80000000; FieldEffectStart(FLDEFF_FIELD_MOVE_SHOW_MON_INIT); - task->data[0]++; + task->tState++; } } -static void SurfFieldEffect_4(struct Task *task) +static void SurfFieldEffect_JumpOnSurfBlob(struct Task *task) { struct ObjectEvent *objectEvent; if (!FieldEffectActiveListContains(FLDEFF_FIELD_MOVE_SHOW_MON)) @@ -2924,15 +3041,15 @@ static void SurfFieldEffect_4(struct Task *task) ObjectEventSetGraphicsId(objectEvent, GetPlayerAvatarGraphicsIdByStateId(PLAYER_AVATAR_STATE_SURFING)); ObjectEventClearHeldMovementIfFinished(objectEvent); ObjectEventSetHeldMovement(objectEvent, GetJumpSpecialMovementAction(objectEvent->movementDirection)); - gFieldEffectArguments[0] = task->data[1]; - gFieldEffectArguments[1] = task->data[2]; + gFieldEffectArguments[0] = task->tDestX; + gFieldEffectArguments[1] = task->tDestY; gFieldEffectArguments[2] = gPlayerAvatar.objectEventId; objectEvent->fieldEffectSpriteId = FieldEffectStart(FLDEFF_SURF_BLOB); - task->data[0]++; + task->tState++; } } -static void SurfFieldEffect_5(struct Task *task) +static void SurfFieldEffect_End(struct Task *task) { struct ObjectEvent *objectEvent; objectEvent = &gObjectEvents[gPlayerAvatar.objectEventId]; @@ -2941,7 +3058,7 @@ static void SurfFieldEffect_5(struct Task *task) gPlayerAvatar.preventStep = FALSE; gPlayerAvatar.flags &= ~PLAYER_AVATAR_FLAG_5; ObjectEventSetHeldMovement(objectEvent, GetFaceDirectionMovementAction(objectEvent->movementDirection)); - sub_81555AC(objectEvent->fieldEffectSpriteId, 1); + SetSurfBobState(objectEvent->fieldEffectSpriteId, 1); UnfreezeObjectEvents(); ScriptContext2_Disable(); FieldEffectActiveListRemove(FLDEFF_USE_SURF); @@ -2949,10 +3066,15 @@ static void SurfFieldEffect_5(struct Task *task) } } -u8 sub_80B8F98(void) +#undef tState +#undef tDestX +#undef tDestY +#undef tMonId + +u8 FldEff_RayquazaSpotlight(void) { u8 i, j, k; - u8 spriteId = CreateSprite(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_RAYQUAZA], 0x78, -0x18, 1); + u8 spriteId = CreateSprite(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_RAYQUAZA], 120, -24, 1); struct Sprite *sprite = &gSprites[spriteId]; sprite->oam.priority = 1; @@ -2966,7 +3088,7 @@ u8 sub_80B8F98(void) SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG0 | BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_BG1 | BLDCNT_TGT2_BG2 | BLDCNT_TGT2_BG3 | BLDCNT_TGT2_OBJ | BLDCNT_TGT2_BD); SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(14, 14)); SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG_ALL | WININ_WIN0_OBJ | WININ_WIN0_CLR | WININ_WIN1_BG_ALL | WININ_WIN1_OBJ | WININ_WIN1_CLR); - LoadPalette(gUnknown_0855B610, 0xC0, sizeof(gUnknown_0855B610)); + LoadPalette(sSpotlight_Pal, 0xC0, sizeof(sSpotlight_Pal)); SetGpuReg(REG_OFFSET_BG0VOFS, 120); for (i = 3; i < 15; i++) { @@ -2979,8 +3101,8 @@ u8 sub_80B8F98(void) { for (i = 0; i < 8; i++) { - *(u16*)(BG_CHAR_ADDR(2) + (k + 1) * 32 + i * 4) = (gUnknown_0855B630[k * 32 + i * 4 + 1] << 8) + gUnknown_0855B630[k * 32 + i * 4]; - *(u16*)(BG_CHAR_ADDR(2) + (k + 1) * 32 + i * 4 + 2) = (gUnknown_0855B630[k * 32 + i * 4 + 3] << 8) + gUnknown_0855B630[k * 32 + i * 4 + 2]; + *(u16*)(BG_CHAR_ADDR(2) + (k + 1) * 32 + i * 4) = (sSpotlight_Gfx[k * 32 + i * 4 + 1] << 8) + sSpotlight_Gfx[k * 32 + i * 4]; + *(u16*)(BG_CHAR_ADDR(2) + (k + 1) * 32 + i * 4 + 2) = (sSpotlight_Gfx[k * 32 + i * 4 + 3] << 8) + sSpotlight_Gfx[k * 32 + i * 4 + 2]; } } return spriteId; @@ -3015,39 +3137,47 @@ static void SpriteCB_NPCFlyOut(struct Sprite *sprite) npcSprite->pos2.x = 0; npcSprite->pos2.y = 0; } + if (sprite->data[2] >= 0x80) - { FieldEffectStop(sprite, FLDEFF_NPCFLY_OUT); - } } -#define tAvatarFlags data[15] +// Task data for Task_FlyOut/FlyIn +#define tState data[0] +#define tMonId data[1] +#define tBirdSpriteId data[1] //re-used +#define tTimer data[2] +#define tAvatarFlags data[15] + +// Sprite data for the fly bird +#define sPlayerSpriteId data[6] +#define sAnimCompleted data[7] u8 FldEff_UseFly(void) { u8 taskId = CreateTask(Task_FlyOut, 254); - gTasks[taskId].data[1] = gFieldEffectArguments[0]; + gTasks[taskId].tMonId = gFieldEffectArguments[0]; return 0; } void (*const sFlyOutFieldEffectFuncs[])(struct Task *) = { - FlyOutFieldEffect_0, - FlyOutFieldEffect_1, - FlyOutFieldEffect_2, - FlyOutFieldEffect_3, - FlyOutFieldEffect_4, - FlyOutFieldEffect_5, - FlyOutFieldEffect_6, - FlyOutFieldEffect_7, - FlyOutFieldEffect_8, + FlyOutFieldEffect_FieldMovePose, + FlyOutFieldEffect_ShowMon, + FlyOutFieldEffect_BirdLeaveBall, + FlyOutFieldEffect_WaitBirdLeave, + FlyOutFieldEffect_BirdSwoopDown, + FlyOutFieldEffect_JumpOnBird, + FlyOutFieldEffect_FlyOffWithBird, + FlyOutFieldEffect_WaitFlyOff, + FlyOutFieldEffect_End, }; static void Task_FlyOut(u8 taskId) { - sFlyOutFieldEffectFuncs[gTasks[taskId].data[0]](&gTasks[taskId]); + sFlyOutFieldEffectFuncs[gTasks[taskId].tState](&gTasks[taskId]); } -static void FlyOutFieldEffect_0(struct Task *task) +static void FlyOutFieldEffect_FieldMovePose(struct Task *task) { struct ObjectEvent *objectEvent = &gObjectEvents[gPlayerAvatar.objectEventId]; if (!ObjectEventIsMovementOverridden(objectEvent) || ObjectEventClearHeldMovementIfFinished(objectEvent)) @@ -3057,61 +3187,61 @@ static void FlyOutFieldEffect_0(struct Task *task) SetPlayerAvatarStateMask(PLAYER_AVATAR_FLAG_ON_FOOT); SetPlayerAvatarFieldMove(); ObjectEventSetHeldMovement(objectEvent, MOVEMENT_ACTION_START_ANIM_IN_DIRECTION); - task->data[0]++; + task->tState++; } } -static void FlyOutFieldEffect_1(struct Task *task) +static void FlyOutFieldEffect_ShowMon(struct Task *task) { struct ObjectEvent *objectEvent = &gObjectEvents[gPlayerAvatar.objectEventId]; if (ObjectEventClearHeldMovementIfFinished(objectEvent)) { - task->data[0]++; - gFieldEffectArguments[0] = task->data[1]; + task->tState++; + gFieldEffectArguments[0] = task->tMonId; FieldEffectStart(FLDEFF_FIELD_MOVE_SHOW_MON_INIT); } } -static void FlyOutFieldEffect_2(struct Task *task) +static void FlyOutFieldEffect_BirdLeaveBall(struct Task *task) { if (!FieldEffectActiveListContains(FLDEFF_FIELD_MOVE_SHOW_MON)) { struct ObjectEvent *objectEvent = &gObjectEvents[gPlayerAvatar.objectEventId]; if (task->tAvatarFlags & PLAYER_AVATAR_FLAG_SURFING) { - sub_81555AC(objectEvent->fieldEffectSpriteId, 2); - sub_81555D8(objectEvent->fieldEffectSpriteId, 0); + SetSurfBobState(objectEvent->fieldEffectSpriteId, 2); + SetSurfBobWhileFlyingOutState(objectEvent->fieldEffectSpriteId, 0); } - task->data[1] = sub_80B94C4(); - task->data[0]++; + task->tBirdSpriteId = CreateFlyBirdSprite(); // Does "leave ball" animation by default + task->tState++; } } -static void FlyOutFieldEffect_3(struct Task *task) +static void FlyOutFieldEffect_WaitBirdLeave(struct Task *task) { - if (sub_80B9508(task->data[1])) + if (GetFlyBirdAnimCompleted(task->tBirdSpriteId)) { - task->data[0]++; - task->data[2] = 16; + task->tState++; + task->tTimer = 16; SetPlayerAvatarTransitionFlags(PLAYER_AVATAR_FLAG_ON_FOOT); ObjectEventSetHeldMovement(&gObjectEvents[gPlayerAvatar.objectEventId], MOVEMENT_ACTION_FACE_LEFT); } } -static void FlyOutFieldEffect_4(struct Task *task) +static void FlyOutFieldEffect_BirdSwoopDown(struct Task *task) { struct ObjectEvent *objectEvent = &gObjectEvents[gPlayerAvatar.objectEventId]; - if ((task->data[2] == 0 || (--task->data[2]) == 0) && ObjectEventClearHeldMovementIfFinished(objectEvent)) + if ((task->tTimer == 0 || (--task->tTimer) == 0) && ObjectEventClearHeldMovementIfFinished(objectEvent)) { - task->data[0]++; + task->tState++; PlaySE(SE_W019); - sub_80B9524(task->data[1]); + StartFlyBirdSwoopDown(task->tBirdSpriteId); } } -static void FlyOutFieldEffect_5(struct Task *task) +static void FlyOutFieldEffect_JumpOnBird(struct Task *task) { - if ((++task->data[2]) >= 8) + if ((++task->tTimer) >= 8) { struct ObjectEvent *objectEvent = &gObjectEvents[gPlayerAvatar.objectEventId]; ObjectEventSetGraphicsId(objectEvent, GetPlayerAvatarGraphicsIdByStateId(PLAYER_AVATAR_STATE_SURFING)); @@ -3122,35 +3252,35 @@ static void FlyOutFieldEffect_5(struct Task *task) { DestroySprite(&gSprites[objectEvent->fieldEffectSpriteId]); } - task->data[0]++; - task->data[2] = 0; + task->tState++; + task->tTimer = 0; } } -static void FlyOutFieldEffect_6(struct Task *task) +static void FlyOutFieldEffect_FlyOffWithBird(struct Task *task) { - if ((++task->data[2]) >= 10) + if ((++task->tTimer) >= 10) { struct ObjectEvent *objectEvent = &gObjectEvents[gPlayerAvatar.objectEventId]; ObjectEventClearHeldMovementIfActive(objectEvent); objectEvent->inanimate = FALSE; objectEvent->hasShadow = FALSE; - sub_80B9560(task->data[1], objectEvent->spriteId); + SetFlyBirdPlayerSpriteId(task->tBirdSpriteId, objectEvent->spriteId); CameraObjectReset2(); - task->data[0]++; + task->tState++; } } -static void FlyOutFieldEffect_7(struct Task *task) +static void FlyOutFieldEffect_WaitFlyOff(struct Task *task) { - if (sub_80B9508(task->data[1])) + if (GetFlyBirdAnimCompleted(task->tBirdSpriteId)) { WarpFadeOutScreen(); - task->data[0]++; + task->tState++; } } -static void FlyOutFieldEffect_8(struct Task *task) +static void FlyOutFieldEffect_End(struct Task *task) { if (!gPaletteFade.active) { @@ -3159,7 +3289,7 @@ static void FlyOutFieldEffect_8(struct Task *task) } } -static u8 sub_80B94C4(void) +static u8 CreateFlyBirdSprite(void) { u8 spriteId; struct Sprite *sprite; @@ -3167,58 +3297,58 @@ static u8 sub_80B94C4(void) sprite = &gSprites[spriteId]; sprite->oam.paletteNum = 0; sprite->oam.priority = 1; - sprite->callback = sub_80B957C; + sprite->callback = SpriteCB_FlyBirdLeaveBall; return spriteId; } -static u8 sub_80B9508(u8 spriteId) +static u8 GetFlyBirdAnimCompleted(u8 spriteId) { - return gSprites[spriteId].data[7]; + return gSprites[spriteId].sAnimCompleted; } -static void sub_80B9524(u8 spriteId) +static void StartFlyBirdSwoopDown(u8 spriteId) { struct Sprite *sprite; sprite = &gSprites[spriteId]; - sprite->callback = sub_80B963C; - sprite->pos1.x = 0x78; - sprite->pos1.y = 0x00; + sprite->callback = SpriteCB_FlyBirdSwoopDown; + sprite->pos1.x = 120; + sprite->pos1.y = 0; sprite->pos2.x = 0; sprite->pos2.y = 0; memset(&sprite->data[0], 0, 8 * sizeof(u16) /* zero all data cells */); - sprite->data[6] = 0x40; + sprite->sPlayerSpriteId = MAX_SPRITES; } -static void sub_80B9560(u8 a0, u8 a1) +static void SetFlyBirdPlayerSpriteId(u8 birdSpriteId, u8 playerSpriteId) { - gSprites[a0].data[6] = a1; + gSprites[birdSpriteId].sPlayerSpriteId = playerSpriteId; } -const union AffineAnimCmd SpriteAffineAnim_855C518[] = { +static const union AffineAnimCmd sAffineAnim_FlyBirdLeaveBall[] = { AFFINEANIMCMD_FRAME(8, 8, -30, 0), AFFINEANIMCMD_FRAME(28, 28, 0, 30), AFFINEANIMCMD_END }; -const union AffineAnimCmd SpriteAffineAnim_855C530[] = { +static const union AffineAnimCmd sAffineAnim_FlyBirdReturnToBall[] = { AFFINEANIMCMD_FRAME(256, 256, 64, 0), AFFINEANIMCMD_FRAME(-10, -10, 0, 22), AFFINEANIMCMD_END }; -const union AffineAnimCmd *const gSpriteAffineAnimTable_0855C548[] = { - SpriteAffineAnim_855C518, - SpriteAffineAnim_855C530 +static const union AffineAnimCmd *const sAffineAnims_FlyBird[] = { + sAffineAnim_FlyBirdLeaveBall, + sAffineAnim_FlyBirdReturnToBall }; -static void sub_80B957C(struct Sprite *sprite) +static void SpriteCB_FlyBirdLeaveBall(struct Sprite *sprite) { - if (sprite->data[7] == 0) + if (sprite->sAnimCompleted == FALSE) { if (sprite->data[0] == 0) { sprite->oam.affineMode = ST_OAM_AFFINE_DOUBLE; - sprite->affineAnims = gSpriteAffineAnimTable_0855C548; + sprite->affineAnims = sAffineAnims_FlyBird; InitSpriteAffineAnim(sprite); StartSpriteAffineAnim(sprite, 0); sprite->pos1.x = 0x76; @@ -3236,7 +3366,7 @@ static void sub_80B957C(struct Sprite *sprite) } if (sprite->data[1] > 0x81) { - sprite->data[7]++; + sprite->sAnimCompleted++; sprite->oam.affineMode = ST_OAM_AFFINE_OFF; FreeOamMatrix(sprite->oam.matrixNum); CalcCenterToCornerVec(sprite, sprite->oam.shape, sprite->oam.size, ST_OAM_AFFINE_OFF); @@ -3244,14 +3374,14 @@ static void sub_80B957C(struct Sprite *sprite) } } -static void sub_80B963C(struct Sprite *sprite) +static void SpriteCB_FlyBirdSwoopDown(struct Sprite *sprite) { sprite->pos2.x = Cos(sprite->data[2], 0x8c); sprite->pos2.y = Sin(sprite->data[2], 0x48); sprite->data[2] = (sprite->data[2] + 4) & 0xff; - if (sprite->data[6] != MAX_SPRITES) + if (sprite->sPlayerSpriteId != MAX_SPRITES) { - struct Sprite *sprite1 = &gSprites[sprite->data[6]]; + struct Sprite *sprite1 = &gSprites[sprite->sPlayerSpriteId]; sprite1->coordOffsetEnabled = FALSE; sprite1->pos1.x = sprite->pos1.x + sprite->pos2.x; sprite1->pos1.y = sprite->pos1.y + sprite->pos2.y - 8; @@ -3260,18 +3390,18 @@ static void sub_80B963C(struct Sprite *sprite) } if (sprite->data[2] >= 0x80) { - sprite->data[7] = 1; + sprite->sAnimCompleted = TRUE; } } -void sub_80B96B0(struct Sprite *sprite) +static void SpriteCB_FlyBirdReturnToBall(struct Sprite *sprite) { - if (sprite->data[7] == 0) + if (sprite->sAnimCompleted == FALSE) { if (sprite->data[0] == 0) { sprite->oam.affineMode = ST_OAM_AFFINE_DOUBLE; - sprite->affineAnims = gSpriteAffineAnimTable_0855C548; + sprite->affineAnims = sAffineAnims_FlyBird; InitSpriteAffineAnim(sprite); StartSpriteAffineAnim(sprite, 1); sprite->pos1.x = 0x5e; @@ -3300,7 +3430,7 @@ void sub_80B96B0(struct Sprite *sprite) } if (sprite->data[3] >= 60) { - sprite->data[7]++; + sprite->sAnimCompleted++; sprite->oam.affineMode = ST_OAM_AFFINE_OFF; FreeOamMatrix(sprite->oam.matrixNum); sprite->invisible = TRUE; @@ -3308,78 +3438,78 @@ void sub_80B96B0(struct Sprite *sprite) } } -void sub_80B9794(u8 spriteId) +static void StartFlyBirdReturnToBall(u8 spriteId) { - sub_80B9524(spriteId); - gSprites[spriteId].callback = sub_80B96B0; + StartFlyBirdSwoopDown(spriteId); // Set up is the same, but overrwrites the callback below + gSprites[spriteId].callback = SpriteCB_FlyBirdReturnToBall; } u8 FldEff_FlyIn(void) { - CreateTask(Task_FlyIn, 0xfe); + CreateTask(Task_FlyIn, 254); return 0; } void (*const sFlyInFieldEffectFuncs[])(struct Task *) = { - FlyInFieldEffect_0, - FlyInFieldEffect_1, - FlyInFieldEffect_2, - FlyInFieldEffect_3, - FlyInFieldEffect_4, - FlyInFieldEffect_5, - FlyInFieldEffect_6, + FlyInFieldEffect_BirdSwoopDown, + FlyInFieldEffect_FlyInWithBird, + FlyInFieldEffect_JumpOffBird, + FlyInFieldEffect_FieldMovePose, + FlyInFieldEffect_BirdReturnToBall, + FlyInFieldEffect_WaitBirdReturn, + FlyInFieldEffect_End, }; static void Task_FlyIn(u8 taskId) { - sFlyInFieldEffectFuncs[gTasks[taskId].data[0]](&gTasks[taskId]); + sFlyInFieldEffectFuncs[gTasks[taskId].tState](&gTasks[taskId]); } -static void FlyInFieldEffect_0(struct Task *task) +static void FlyInFieldEffect_BirdSwoopDown(struct Task *task) { struct ObjectEvent *objectEvent; objectEvent = &gObjectEvents[gPlayerAvatar.objectEventId]; if (!ObjectEventIsMovementOverridden(objectEvent) || ObjectEventClearHeldMovementIfFinished(objectEvent)) { - task->data[0]++; - task->data[2] = 17; + task->tState++; + task->tTimer = 17; task->tAvatarFlags = gPlayerAvatar.flags; gPlayerAvatar.preventStep = TRUE; SetPlayerAvatarStateMask(PLAYER_AVATAR_FLAG_ON_FOOT); if (task->tAvatarFlags & PLAYER_AVATAR_FLAG_SURFING) { - sub_81555AC(objectEvent->fieldEffectSpriteId, 0); + SetSurfBobState(objectEvent->fieldEffectSpriteId, 0); } ObjectEventSetGraphicsId(objectEvent, GetPlayerAvatarGraphicsIdByStateId(PLAYER_AVATAR_STATE_SURFING)); CameraObjectReset2(); ObjectEventTurn(objectEvent, DIR_WEST); StartSpriteAnim(&gSprites[objectEvent->spriteId], 0x16); objectEvent->invisible = FALSE; - task->data[1] = sub_80B94C4(); - sub_80B9524(task->data[1]); - sub_80B9560(task->data[1], objectEvent->spriteId); + task->tBirdSpriteId = CreateFlyBirdSprite(); + StartFlyBirdSwoopDown(task->tBirdSpriteId); + SetFlyBirdPlayerSpriteId(task->tBirdSpriteId, objectEvent->spriteId); } } -static void FlyInFieldEffect_1(struct Task *task) +static void FlyInFieldEffect_FlyInWithBird(struct Task *task) { struct ObjectEvent *objectEvent; struct Sprite *sprite; - if (task->data[2] == 0 || (--task->data[2]) == 0) + if (task->tTimer == 0 || (--task->tTimer) == 0) { objectEvent = &gObjectEvents[gPlayerAvatar.objectEventId]; sprite = &gSprites[objectEvent->spriteId]; - sub_80B9560(task->data[1], 0x40); + SetFlyBirdPlayerSpriteId(task->tBirdSpriteId, MAX_SPRITES); sprite->pos1.x += sprite->pos2.x; sprite->pos1.y += sprite->pos2.y; sprite->pos2.x = 0; sprite->pos2.y = 0; - task->data[0]++; - task->data[2] = 0; + task->tState++; + task->tTimer = 0; } } -static void FlyInFieldEffect_2(struct Task *task) +static void FlyInFieldEffect_JumpOffBird(struct Task *task) { s16 sYPositions[18] = { -2, @@ -3402,18 +3532,17 @@ static void FlyInFieldEffect_2(struct Task *task) 8 }; struct Sprite *sprite = &gSprites[gPlayerAvatar.spriteId]; - sprite->pos2.y = sYPositions[task->data[2]]; - if ((++task->data[2]) >= (int)ARRAY_COUNT(sYPositions)) - { - task->data[0]++; - } + sprite->pos2.y = sYPositions[task->tTimer]; + + if ((++task->tTimer) >= (int)ARRAY_COUNT(sYPositions)) + task->tState++; } -static void FlyInFieldEffect_3(struct Task *task) +static void FlyInFieldEffect_FieldMovePose(struct Task *task) { struct ObjectEvent *objectEvent; struct Sprite *sprite; - if (sub_80B9508(task->data[1])) + if (GetFlyBirdAnimCompleted(task->tBirdSpriteId)) { objectEvent = &gObjectEvents[gPlayerAvatar.objectEventId]; sprite = &gSprites[objectEvent->spriteId]; @@ -3424,30 +3553,30 @@ static void FlyInFieldEffect_3(struct Task *task) sprite->coordOffsetEnabled = TRUE; SetPlayerAvatarFieldMove(); ObjectEventSetHeldMovement(objectEvent, MOVEMENT_ACTION_START_ANIM_IN_DIRECTION); - task->data[0]++; + task->tState++; } } -static void FlyInFieldEffect_4(struct Task *task) +static void FlyInFieldEffect_BirdReturnToBall(struct Task *task) { if (ObjectEventClearHeldMovementIfFinished(&gObjectEvents[gPlayerAvatar.objectEventId])) { - task->data[0]++; - sub_80B9794(task->data[1]); + task->tState++; + StartFlyBirdReturnToBall(task->tBirdSpriteId); } } -static void FlyInFieldEffect_5(struct Task *task) +static void FlyInFieldEffect_WaitBirdReturn(struct Task *task) { - if (sub_80B9508(task->data[1])) + if (GetFlyBirdAnimCompleted(task->tBirdSpriteId)) { - DestroySprite(&gSprites[task->data[1]]); - task->data[0]++; - task->data[1] = 0x10; + DestroySprite(&gSprites[task->tBirdSpriteId]); + task->tState++; + task->data[1] = 16; } } -static void FlyInFieldEffect_6(struct Task *task) +static void FlyInFieldEffect_End(struct Task *task) { u8 state; struct ObjectEvent *objectEvent; @@ -3458,7 +3587,7 @@ static void FlyInFieldEffect_6(struct Task *task) if (task->tAvatarFlags & PLAYER_AVATAR_FLAG_SURFING) { state = PLAYER_AVATAR_STATE_SURFING; - sub_81555AC(objectEvent->fieldEffectSpriteId, 1); + SetSurfBobState(objectEvent->fieldEffectSpriteId, 1); } ObjectEventSetGraphicsId(objectEvent, GetPlayerAvatarGraphicsIdByStateId(state)); ObjectEventTurn(objectEvent, DIR_SOUTH); @@ -3469,17 +3598,33 @@ static void FlyInFieldEffect_6(struct Task *task) } } +#undef tState +#undef tMonId +#undef tBirdSpriteId +#undef tTimer +#undef tAvatarFlags +#undef sPlayerSpriteId +#undef sAnimCompleted + +#define tState data[1] +#define tObjectEventId data[2] +#define tTimer data[3] +#define tCameraTaskId data[5] +#define tLocalId data[6] +#define tMapNum data[7] +#define tMapGroup data[8] + bool8 FldEff_DestroyDeoxysRock(void) { u8 taskId; - u8 objectEventIdBuffer; - if (!TryGetObjectEventIdByLocalIdAndMap(gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2], &objectEventIdBuffer)) + u8 objectEventId; + if (!TryGetObjectEventIdByLocalIdAndMap(gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2], &objectEventId)) { - taskId = CreateTask(Task_DestroyDeoxysRock, 0x50); - gTasks[taskId].data[2] = objectEventIdBuffer; - gTasks[taskId].data[6] = gFieldEffectArguments[0]; - gTasks[taskId].data[7] = gFieldEffectArguments[1]; - gTasks[taskId].data[8] = gFieldEffectArguments[2]; + taskId = CreateTask(Task_DestroyDeoxysRock, 80); + gTasks[taskId].tObjectEventId = objectEventId; + gTasks[taskId].tLocalId = gFieldEffectArguments[0]; + gTasks[taskId].tMapNum = gFieldEffectArguments[1]; + gTasks[taskId].tMapGroup = gFieldEffectArguments[2]; } else { @@ -3488,49 +3633,58 @@ bool8 FldEff_DestroyDeoxysRock(void) return FALSE; } -static void Task_PanCameraForDestroyingDeoxysRock(u8 taskId) +#define tShakeDelay data[0] +#define tShakeUp data[1] +#define tShake data[5] +#define tEndDelay data[6] +#define tEnding data[7] + +static void Task_DeoxysRockCameraShake(u8 taskId) { s16 *data = gTasks[taskId].data; - if (data[7] != 0) + if (tEnding) { - if (++data[6] > 20) + if (++tEndDelay > 20) { - data[6] = 0; - if (data[5] != 0) - data[5]--; + tEndDelay = 0; + if (tShake != 0) + tShake--; } } else { - data[5] = 4; + tShake = 4; } - if (++data[0] > 1) + if (++tShakeDelay > 1) { - data[0] = 0; - if (++data[1] & 1) - { - SetCameraPanning(0, -data[5]); - } + tShakeDelay = 0; + + if (++tShakeUp & 1) + SetCameraPanning(0, -tShake); else - { - SetCameraPanning(0, data[5]); - } + SetCameraPanning(0, tShake); } UpdateCameraPanning(); - if (data[5] == 0) + if (tShake == 0) DestroyTask(taskId); } -void sub_80B9BD0(u8 taskId) +static void StartEndingDeoxysRockCameraShake(u8 taskId) { - gTasks[taskId].data[7] = 1; + gTasks[taskId].tEnding = TRUE; } -void (*const sDestroyDeoxysRockFieldEffectFuncs[])(s16*, u8) = { - DestroyDeoxysRockFieldEffect_0, - DestroyDeoxysRockFieldEffect_1, - DestroyDeoxysRockFieldEffect_2, +#undef tShakeDelay +#undef tShakeUp +#undef tShake +#undef tEndDelay +#undef tEnding + +void (*const sDestroyDeoxysRockEffectFuncs[])(s16*, u8) = { + DestroyDeoxysRockEffect_CameraShake, + DestroyDeoxysRockEffect_RockFragments, + DestroyDeoxysRockEffect_WaitAndEnd, }; static void Task_DestroyDeoxysRock(u8 taskId) @@ -3538,89 +3692,97 @@ static void Task_DestroyDeoxysRock(u8 taskId) s16 *data = gTasks[taskId].data; InstallCameraPanAheadCallback(); SetCameraPanningCallback(0); - sDestroyDeoxysRockFieldEffectFuncs[data[1]](data, taskId); + sDestroyDeoxysRockEffectFuncs[tState](data, taskId); } -static void DestroyDeoxysRockFieldEffect_0(s16* data, u8 taskId) +static void DestroyDeoxysRockEffect_CameraShake(s16* data, u8 taskId) { - u8 newTaskId = CreateTask(Task_PanCameraForDestroyingDeoxysRock, 0x5A); + u8 newTaskId = CreateTask(Task_DeoxysRockCameraShake, 90); PlaySE(SE_T_KAMI2); - data[5] = newTaskId; - data[1]++; + tCameraTaskId = newTaskId; + tState++; } -static void DestroyDeoxysRockFieldEffect_1(s16* data, u8 taskId) +static void DestroyDeoxysRockEffect_RockFragments(s16* data, u8 taskId) { - if (++data[3] > 0x78) + if (++tTimer > 120) { - struct Sprite *sprite = &gSprites[gObjectEvents[data[2]].spriteId]; - gObjectEvents[data[2]].invisible = TRUE; + struct Sprite *sprite = &gSprites[gObjectEvents[tObjectEventId].spriteId]; + gObjectEvents[tObjectEventId].invisible = TRUE; BlendPalettes(0x0000FFFF, 0x10, RGB_WHITE); BeginNormalPaletteFade(0x0000FFFF, 0, 0x10, 0, RGB_WHITE); - sub_80B9D24(sprite); + CreateDeoxysRockFragments(sprite); PlaySE(SE_T_KAMI); - sub_80B9BD0(data[5]); - data[3] = 0; - data[1]++; + StartEndingDeoxysRockCameraShake(tCameraTaskId); + tTimer = 0; + tState++; } } -static void DestroyDeoxysRockFieldEffect_2(s16* a0, u8 taskId) +static void DestroyDeoxysRockEffect_WaitAndEnd(s16* data, u8 taskId) { - if (!gPaletteFade.active && !FuncIsActiveTask(Task_PanCameraForDestroyingDeoxysRock)) + if (!gPaletteFade.active && !FuncIsActiveTask(Task_DeoxysRockCameraShake)) { InstallCameraPanAheadCallback(); - RemoveObjectEventByLocalIdAndMap(a0[6], a0[7], a0[8]); + RemoveObjectEventByLocalIdAndMap(tLocalId, tMapNum, tMapGroup); FieldEffectActiveListRemove(FLDEFF_DESTROY_DEOXYS_ROCK); DestroyTask(taskId); } } -const struct SpriteFrameImage gSpriteImageTable_855C59C[] = { - obj_frame_tiles(gUnknown_0855C170), - obj_frame_tiles(gUnknown_0855C190), - obj_frame_tiles(gUnknown_0855C1B0), - obj_frame_tiles(gUnknown_0855C1D0), +#undef tState +#undef tObjectEventId +#undef tTimer +#undef tCameraTaskId +#undef tLocalId +#undef tMapNum +#undef tMapGroup + +static const struct SpriteFrameImage sImages_DeoxysRockFragment[] = { + obj_frame_tiles(sRockFragment_TopLeft), + obj_frame_tiles(sRockFragment_TopRight), + obj_frame_tiles(sRockFragment_BottomLeft), + obj_frame_tiles(sRockFragment_BottomRight), }; -const union AnimCmd gSpriteAnim_855C5BC[] = { +static const union AnimCmd sAnim_RockFragment_TopLeft[] = { ANIMCMD_FRAME(.imageValue = 0), ANIMCMD_END }; -const union AnimCmd gSpriteAnim_855C5C4[] = { +static const union AnimCmd sAnim_RockFragment_TopRight[] = { ANIMCMD_FRAME(.imageValue = 1), ANIMCMD_END }; -const union AnimCmd gSpriteAnim_855C5CC[] = { +static const union AnimCmd sAnim_RockFragment_BottomLeft[] = { ANIMCMD_FRAME(.imageValue = 2), ANIMCMD_END }; -const union AnimCmd gSpriteAnim_855C5D4[] = { +static const union AnimCmd sAnim_RockFragment_BottomRight[] = { ANIMCMD_FRAME(.imageValue = 3), ANIMCMD_END }; -const union AnimCmd *const gSpriteAnimTable_855C5DC[] = { - gSpriteAnim_855C5BC, - gSpriteAnim_855C5C4, - gSpriteAnim_855C5CC, - gSpriteAnim_855C5D4, +static const union AnimCmd *const sAnims_DeoxysRockFragment[] = { + sAnim_RockFragment_TopLeft, + sAnim_RockFragment_TopRight, + sAnim_RockFragment_BottomLeft, + sAnim_RockFragment_BottomRight, }; -const struct SpriteTemplate gUnknown_0855C5EC = { +static const struct SpriteTemplate sSpriteTemplate_DeoxysRockFragment = { .tileTag = 0xFFFF, .paletteTag = 4378, - .oam = &gOamData_855C218, - .anims = gSpriteAnimTable_855C5DC, - .images = gSpriteImageTable_855C59C, + .oam = &sOam_8x8, + .anims = sAnims_DeoxysRockFragment, + .images = sImages_DeoxysRockFragment, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_80B9DB8 + .callback = SpriteCB_DeoxysRockFragment }; -static void sub_80B9D24(struct Sprite* sprite) +static void CreateDeoxysRockFragments(struct Sprite* sprite) { int i; int xPos = (s16)gTotalCameraPixelOffsetX + sprite->pos1.x + sprite->pos2.x; @@ -3628,7 +3790,7 @@ static void sub_80B9D24(struct Sprite* sprite) for (i = 0; i < 4; i++) { - u8 spriteId = CreateSprite(&gUnknown_0855C5EC, xPos, yPos, 0); + u8 spriteId = CreateSprite(&sSpriteTemplate_DeoxysRockFragment, xPos, yPos, 0); if (spriteId != MAX_SPRITES) { StartSpriteAnim(&gSprites[spriteId], i); @@ -3638,8 +3800,9 @@ static void sub_80B9D24(struct Sprite* sprite) } } -static void sub_80B9DB8(struct Sprite* sprite) +static void SpriteCB_DeoxysRockFragment(struct Sprite* sprite) { + // 1 case for each fragment, fly off in 4 different directions switch (sprite->data[0]) { case 0: @@ -3659,7 +3822,7 @@ static void sub_80B9DB8(struct Sprite* sprite) sprite->pos1.y += 12; break; } - if ((u16)(sprite->pos1.x + 4) > 0xF8 || sprite->pos1.y < -4 || sprite->pos1.y > 0xA4) + if ((u16)(sprite->pos1.x + 4) > 248 || sprite->pos1.y < -4 || sprite->pos1.y > 164) DestroySprite(sprite); } diff --git a/src/field_effect_helpers.c b/src/field_effect_helpers.c index d6bffd206..e3ca54f16 100755 --- a/src/field_effect_helpers.c +++ b/src/field_effect_helpers.c @@ -817,19 +817,19 @@ u32 FldEff_Unknown19(void) return 0; } -u32 FldEff_UnusedGrass(void) +u32 FldEff_UnusedGrass2(void) { u8 spriteId; struct Sprite *sprite; sub_80930E0((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 8); - spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_UNUSED_GRASS], gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2]); + spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_UNUSED_GRASS_2], gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2]); if (spriteId != MAX_SPRITES) { sprite = &gSprites[spriteId]; sprite->coordOffsetEnabled = TRUE; sprite->oam.priority = gFieldEffectArguments[3]; - sprite->data[0] = FLDEFF_UNUSED_GRASS; + sprite->data[0] = FLDEFF_UNUSED_GRASS_2; } return 0; } @@ -851,19 +851,19 @@ u32 FldEff_Unknown21(void) return 0; } -u32 FldEff_Unknown22(void) +u32 FldEff_WaterSurfacing(void) { u8 spriteId; struct Sprite *sprite; sub_80930E0((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 8); - spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_20], gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2]); + spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_WATER_SURFACING], gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2]); if (spriteId != MAX_SPRITES) { sprite = &gSprites[spriteId]; sprite->coordOffsetEnabled = TRUE; sprite->oam.priority = gFieldEffectArguments[3]; - sprite->data[0] = FLDEFF_UNKNOWN_22; + sprite->data[0] = FLDEFF_WATER_SURFACING; } return 0; } @@ -960,33 +960,34 @@ u32 FldEff_SurfBlob(void) return spriteId; } -void sub_81555AC(u8 spriteId, u8 value) +// States for bobbing up and down while surfing +void SetSurfBobState(u8 spriteId, u8 value) { gSprites[spriteId].data[0] = (gSprites[spriteId].data[0] & ~0xF) | (value & 0xF); } -void sub_81555D8(u8 spriteId, u8 value) +void SetSurfBobWhileFlyingOutState(u8 spriteId, u8 value) { gSprites[spriteId].data[0] = (gSprites[spriteId].data[0] & ~0xF0) | ((value & 0xF) << 4); } -void sub_8155604(u8 spriteId, u8 value, s16 data1) +void SetSurfBobWhileFishingState(u8 spriteId, u8 value, s16 data1) { gSprites[spriteId].data[0] = (gSprites[spriteId].data[0] & ~0xF00) | ((value & 0xF) << 8); gSprites[spriteId].data[1] = data1; } -static u8 sub_8155638(struct Sprite *sprite) +static u8 GetSurfBobState(struct Sprite *sprite) { return sprite->data[0] & 0xF; } -static u8 sub_8155640(struct Sprite *sprite) +static u8 GetSurfBobWhileFlyingOutState(struct Sprite *sprite) { return (sprite->data[0] & 0xF0) >> 4; } -static u8 sub_815564C(struct Sprite *sprite) +static u8 GetSurfBobWhileFishingState(struct Sprite *sprite) { return (sprite->data[0] & 0xF00) >> 8; } @@ -1018,7 +1019,7 @@ static void SynchroniseSurfAnim(struct ObjectEvent *objectEvent, struct Sprite * [DIR_NORTHEAST] = 1, }; - if (sub_8155640(sprite) == 0) + if (GetSurfBobWhileFlyingOutState(sprite) == 0) StartSpriteAnimIfDifferent(sprite, surfBlobDirectionAnims[objectEvent->movementDirection]); } @@ -1049,8 +1050,8 @@ void sub_81556E8(struct ObjectEvent *objectEvent, struct Sprite *sprite) static void CreateBobbingEffect(struct ObjectEvent *objectEvent, struct Sprite *linkedSprite, struct Sprite *sprite) { u16 unk_085CDC6A[] = {3, 7}; - u8 v0 = sub_8155638(sprite); - if (v0 != 0) + u8 bobState = GetSurfBobState(sprite); + if (bobState != 0) { if (((u16)(++ sprite->data[4]) & unk_085CDC6A[sprite->data[5]]) == 0) { @@ -1060,9 +1061,9 @@ static void CreateBobbingEffect(struct ObjectEvent *objectEvent, struct Sprite * { sprite->data[3] = -sprite->data[3]; } - if (v0 != 2) + if (bobState != 2) { - if (sub_815564C(sprite) == 0) + if (GetSurfBobWhileFishingState(sprite) == 0) linkedSprite->pos2.y = sprite->pos2.y; else linkedSprite->pos2.y = sprite->data[1] + sprite->pos2.y; @@ -1358,61 +1359,72 @@ void UpdateSparkleFieldEffect(struct Sprite *sprite) FieldEffectStop(sprite, FLDEFF_SPARKLE); } -void sub_8155EA0(struct Sprite *sprite) +#define sTimer data[0] +#define sState data[2] +#define sStartY data[4] +#define sCounter data[5] +#define sAnimCounter data[6] +#define sAnimState data[7] + +// Same as InitSpriteForFigure8Anim +static void InitRayquazaForFigure8Anim(struct Sprite *sprite) { - sprite->data[6] = 0; - sprite->data[7] = 0; + sprite->sAnimCounter = 0; + sprite->sAnimState = 0; } -bool8 sub_8155EA8(struct Sprite *sprite) +// Only different from AnimateSpriteInFigure8 by the addition of SetGpuReg to move the spotlight +static bool8 AnimateRayquazaInFigure8(struct Sprite *sprite) { - bool8 returnBool = FALSE; + bool8 finished = FALSE; - switch (sprite->data[7]) + switch (sprite->sAnimState) { - case 0: - sprite->pos2.x += sub_809773C(sprite->data[6]); - sprite->pos2.y += sub_8097728(sprite->data[6]); - break; - case 1: - sprite->pos2.x -= sub_809773C(0x47 - sprite->data[6]); - sprite->pos2.y += sub_8097728(0x47 - sprite->data[6]); - break; - case 2: - sprite->pos2.x -= sub_809773C(sprite->data[6]); - sprite->pos2.y += sub_8097728(sprite->data[6]); - break; - case 3: - sprite->pos2.x += sub_809773C(0x47 - sprite->data[6]); - sprite->pos2.y += sub_8097728(0x47 - sprite->data[6]); - break; + case 0: + sprite->pos2.x += GetFigure8XOffset(sprite->sAnimCounter); + sprite->pos2.y += GetFigure8YOffset(sprite->sAnimCounter); + break; + case 1: + sprite->pos2.x -= GetFigure8XOffset((FIGURE_8_LENGTH - 1) - sprite->sAnimCounter); + sprite->pos2.y += GetFigure8YOffset((FIGURE_8_LENGTH - 1) - sprite->sAnimCounter); + break; + case 2: + sprite->pos2.x -= GetFigure8XOffset(sprite->sAnimCounter); + sprite->pos2.y += GetFigure8YOffset(sprite->sAnimCounter); + break; + case 3: + sprite->pos2.x += GetFigure8XOffset((FIGURE_8_LENGTH - 1) - sprite->sAnimCounter); + sprite->pos2.y += GetFigure8YOffset((FIGURE_8_LENGTH - 1) - sprite->sAnimCounter); + break; } + // Update spotlight to sweep left and right with Rayquaza SetGpuReg(REG_OFFSET_BG0HOFS, -sprite->pos2.x); - if (++sprite->data[6] == 72) + + if (++sprite->sAnimCounter == FIGURE_8_LENGTH) { - sprite->data[6] = 0; - sprite->data[7]++; + sprite->sAnimCounter = 0; + sprite->sAnimState++; } - if (sprite->data[7] == 4) + if (sprite->sAnimState == 4) { sprite->pos2.y = 0; sprite->pos2.x = 0; - returnBool = TRUE; + finished = TRUE; } - return returnBool; + return finished; } -void sub_8155F80(struct Sprite *sprite) +void UpdateRayquazaSpotlightEffect(struct Sprite *sprite) { u8 i, j; - switch (sprite->data[2]) + switch (sprite->sState) { case 0: - SetGpuReg(REG_OFFSET_BG0VOFS, 0x78 - (sprite->data[0] / 3)); - if (sprite->data[0] == 0x60) + SetGpuReg(REG_OFFSET_BG0VOFS, 120 - (sprite->sTimer / 3)); + if (sprite->sTimer == 96) { for (i = 0; i < 3; i++) { @@ -1422,42 +1434,42 @@ void sub_8155F80(struct Sprite *sprite) } } } - if (sprite->data[0] > 0x137) + if (sprite->sTimer > 311) { - sprite->data[2] = 1; - sprite->data[0] = 0; + sprite->sState = 1; + sprite->sTimer = 0; } break; case 1: - sprite->pos1.y = (gSineTable[sprite->data[0] / 3] >> 2) + sprite->data[4]; - if (sprite->data[0] == 0xBD) + sprite->pos1.y = (gSineTable[sprite->sTimer / 3] >> 2) + sprite->sStartY; + if (sprite->sTimer == 189) { - sprite->data[2] = 2; - sprite->data[5] = 0; - sprite->data[0] = 0; + sprite->sState = 2; + sprite->sCounter = 0; + sprite->sTimer = 0; } break; case 2: - if (sprite->data[0] == 0x3C) + if (sprite->sTimer == 60) { - sprite->data[5]++; - sprite->data[0] = 0; + sprite->sCounter++; + sprite->sTimer = 0; } - if (sprite->data[5] == 7) + if (sprite->sCounter == 7) { - sprite->data[5] = 0; - sprite->data[2] = 3; + sprite->sCounter = 0; + sprite->sState = 3; } break; case 3: if (sprite->pos2.y == 0) { - sprite->data[0] = 0; - sprite->data[2]++; + sprite->sTimer = 0; + sprite->sState++; } - if (sprite->data[0] == 5) + if (sprite->sTimer == 5) { - sprite->data[0] = 0; + sprite->sTimer = 0; if (sprite->pos2.y > 0) sprite->pos2.y--; else @@ -1465,38 +1477,38 @@ void sub_8155F80(struct Sprite *sprite) } break; case 4: - if (sprite->data[0] == 0x3C) + if (sprite->sTimer == 60) { - sprite->data[2] = 5; - sprite->data[0] = 0; - sprite->data[5] = 0; + sprite->sState = 5; + sprite->sTimer = 0; + sprite->sCounter = 0; } break; case 5: - sub_8155EA0(sprite); - sprite->data[2] = 6; - sprite->data[0] = 0; + InitRayquazaForFigure8Anim(sprite); + sprite->sState = 6; + sprite->sTimer = 0; break; case 6: - if (sub_8155EA8(sprite)) + if (AnimateRayquazaInFigure8(sprite)) { - sprite->data[0] = 0; - if (++sprite->data[5] <= 2) + sprite->sTimer = 0; + if (++sprite->sCounter <= 2) { - sub_8155EA0(sprite); + InitRayquazaForFigure8Anim(sprite); } else { - sprite->data[5] = 0; - sprite->data[2] = 7; + sprite->sCounter = 0; + sprite->sState = 7; } } break; case 7: - if (sprite->data[0] == 0x1E) + if (sprite->sTimer == 30) { - sprite->data[2] = 8; - sprite->data[0] = 0; + sprite->sState = 8; + sprite->sTimer = 0; } break; case 8: @@ -1508,11 +1520,11 @@ void sub_8155F80(struct Sprite *sprite) } } SetGpuReg(REG_OFFSET_BG0VOFS, 0); - FieldEffectStop(sprite, FLDEFF_RAYQUAZA); + FieldEffectStop(sprite, FLDEFF_RAYQUAZA_SPOTLIGHT); break; } - if (sprite->data[2] == 1) + if (sprite->sState == 1) { if ((sprite->data[1] & 7) == 0) sprite->pos2.y += sprite->data[3]; @@ -1521,10 +1533,17 @@ void sub_8155F80(struct Sprite *sprite) sprite->data[1]++; } - sprite->data[0]++; + sprite->sTimer++; } -void sub_8156194(struct Sprite *sprite) +#undef sTimer +#undef sState +#undef sStartY +#undef sCounter +#undef sAnimCounter +#undef sAnimState + +void UpdateJumpImpactEffect(struct Sprite *sprite) { if (sprite->animEnded) { diff --git a/src/field_player_avatar.c b/src/field_player_avatar.c index c482f39d6..41ddfc17d 100644 --- a/src/field_player_avatar.c +++ b/src/field_player_avatar.c @@ -320,7 +320,7 @@ static u8 ObjectEventCB2_NoMovement2(void) return 0; } -void player_step(u8 direction, u16 newKeys, u16 heldKeys) +void PlayerStep(u8 direction, u16 newKeys, u16 heldKeys) { struct ObjectEvent *playerObjEvent = &gObjectEvents[gPlayerAvatar.objectEventId]; @@ -869,7 +869,7 @@ static void PlayerAvatarTransition_Surfing(struct ObjectEvent *objEvent) gFieldEffectArguments[2] = gPlayerAvatar.objectEventId; spriteId = FieldEffectStart(FLDEFF_SURF_BLOB); objEvent->fieldEffectSpriteId = spriteId; - sub_81555AC(spriteId, 1); + SetSurfBobState(spriteId, 1); } static void PlayerAvatarTransition_Underwater(struct ObjectEvent *objEvent) @@ -885,7 +885,7 @@ static void PlayerAvatarTransition_ReturnToField(struct ObjectEvent *objEvent) gPlayerAvatar.flags |= PLAYER_AVATAR_FLAG_5; } -void sub_808B578(void) +void UpdatePlayerAvatarTransitionState(void) { gPlayerAvatar.tileTransitionState = T_NOT_MOVING; if (PlayerIsAnimActive()) @@ -1650,7 +1650,7 @@ static void Task_StopSurfingInit(u8 taskId) if (!ObjectEventClearHeldMovementIfFinished(playerObjEvent)) return; } - sub_81555AC(playerObjEvent->fieldEffectSpriteId, 2); + SetSurfBobState(playerObjEvent->fieldEffectSpriteId, 2); ObjectEventSetHeldMovement(playerObjEvent, GetJumpSpecialMovementAction((u8)gTasks[taskId].data[0])); gTasks[taskId].func = Task_WaitStopSurfing; } @@ -1934,7 +1934,7 @@ static bool8 Fishing11(struct Task *task) ObjectEventSetGraphicsId(playerObjEvent, task->tPlayerGfxId); ObjectEventTurn(playerObjEvent, playerObjEvent->movementDirection); if (gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_SURFING) - sub_8155604(gObjectEvents[gPlayerAvatar.objectEventId].fieldEffectSpriteId, 0, 0); + SetSurfBobWhileFishingState(gObjectEvents[gPlayerAvatar.objectEventId].fieldEffectSpriteId, 0, 0); gSprites[gPlayerAvatar.spriteId].pos2.x = 0; gSprites[gPlayerAvatar.spriteId].pos2.y = 0; ClearDialogWindowAndFrame(0, TRUE); @@ -1994,7 +1994,7 @@ static bool8 Fishing15(struct Task *task) ObjectEventSetGraphicsId(playerObjEvent, task->tPlayerGfxId); ObjectEventTurn(playerObjEvent, playerObjEvent->movementDirection); if (gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_SURFING) - sub_8155604(gObjectEvents[gPlayerAvatar.objectEventId].fieldEffectSpriteId, 0, 0); + SetSurfBobWhileFishingState(gObjectEvents[gPlayerAvatar.objectEventId].fieldEffectSpriteId, 0, 0); gSprites[gPlayerAvatar.spriteId].pos2.x = 0; gSprites[gPlayerAvatar.spriteId].pos2.y = 0; task->tStep++; @@ -2053,7 +2053,7 @@ static void AlignFishingAnimationFrames(void) if (animType == 10 || animType == 11) playerSprite->pos2.y = 8; if (gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_SURFING) - sub_8155604(gObjectEvents[gPlayerAvatar.objectEventId].fieldEffectSpriteId, 1, playerSprite->pos2.y); + SetSurfBobWhileFishingState(gObjectEvents[gPlayerAvatar.objectEventId].fieldEffectSpriteId, 1, playerSprite->pos2.y); } void sub_808D074(u8 a0) diff --git a/src/field_screen_effect.c b/src/field_screen_effect.c index 971e58cf4..57dc27ed9 100644 --- a/src/field_screen_effect.c +++ b/src/field_screen_effect.c @@ -290,7 +290,7 @@ void FieldCB_WarpExitFadeFromWhite(void) void FieldCB_WarpExitFadeFromBlack(void) { - if (!sub_81D6534()) // sub_81D6534 always returns false + if (!OnTrainerHillEReaderChallengeFloor()) // always false Overworld_PlaySpecialMapMusic(); FadeInFromBlack(); SetUpWarpExitTask(); diff --git a/src/fieldmap.c b/src/fieldmap.c index a046bf4fa..5eb00ad27 100644 --- a/src/fieldmap.c +++ b/src/fieldmap.c @@ -44,7 +44,7 @@ static void InitBackupMapLayoutConnections(struct MapHeader *mapHeader); static void LoadSavedMapView(void); static bool8 SkipCopyingMetatileFromSavedMap(u16* mapMetatilePtr, u16 mapWidth, u8 yMode); -struct MapHeader const *const mapconnection_get_mapheader(struct MapConnection *connection) +struct MapHeader const *const GetMapHeaderFromConnection(struct MapConnection *connection) { return Overworld_GetMapHeaderByGroupAndId(connection->mapGroup, connection->mapNum); } @@ -124,7 +124,7 @@ static void InitBackupMapLayoutConnections(struct MapHeader *mapHeader) gMapConnectionFlags = sDummyConnectionFlags; for (i = 0; i < count; i++, connection++) { - struct MapHeader const *cMap = mapconnection_get_mapheader(connection); + struct MapHeader const *cMap = GetMapHeaderFromConnection(connection); u32 offset = connection->offset; switch (connection->direction) { @@ -734,7 +734,7 @@ int CanCameraMoveInDirection(int direction) void sub_80887F8(struct MapConnection *connection, int direction, int x, int y) { struct MapHeader const *mapHeader; - mapHeader = mapconnection_get_mapheader(connection); + mapHeader = GetMapHeaderFromConnection(connection); switch (direction) { case CONNECTION_EAST: @@ -805,7 +805,7 @@ struct MapConnection *sub_8088950(u8 direction, int x, int y) bool8 sub_80889A8(u8 direction, int x, int y, struct MapConnection *connection) { struct MapHeader const *mapHeader; - mapHeader = mapconnection_get_mapheader(connection); + mapHeader = GetMapHeaderFromConnection(connection); switch (direction) { case CONNECTION_SOUTH: @@ -846,7 +846,7 @@ int sub_8088A38(int x, int width) int sub_8088A4C(struct MapConnection *connection, int x, int y) { struct MapHeader const *mapHeader; - mapHeader = mapconnection_get_mapheader(connection); + mapHeader = GetMapHeaderFromConnection(connection); switch (connection->direction) { case CONNECTION_SOUTH: @@ -893,7 +893,7 @@ struct MapConnection *GetConnectionAtCoords(s16 x, s16 y) return NULL; } -void sub_8088B3C(u16 x, u16 y) +void SetCameraFocusCoords(u16 x, u16 y) { gSaveBlock1Ptr->pos.x = x - 7; gSaveBlock1Ptr->pos.y = y - 7; @@ -905,7 +905,8 @@ void GetCameraFocusCoords(u16 *x, u16 *y) *y = gSaveBlock1Ptr->pos.y + 7; } -void SetPlayerCoords(u16 x, u16 y) +// Unused +static void SetCameraCoords(u16 x, u16 y) { gSaveBlock1Ptr->pos.x = x; gSaveBlock1Ptr->pos.y = y; diff --git a/src/fldeff_cut.c b/src/fldeff_cut.c index f5e06e8f6..2c9151598 100644 --- a/src/fldeff_cut.c +++ b/src/fldeff_cut.c @@ -122,12 +122,12 @@ static const struct SpriteFrameImage sSpriteImageTable_CutGrass[] = {gFieldEffectPic_CutGrass, 0x20}, }; -const struct SpritePalette gFieldEffectObjectPaletteInfo6 = {gFieldEffectObjectPalette6, 0x1000}; +const struct SpritePalette gFieldEffectObjectPaletteInfo6 = {gFieldEffectObjectPalette6, FLDEFF_PAL_TAG_0}; static const struct SpriteTemplate sSpriteTemplate_CutGrass = { .tileTag = 0xFFFF, - .paletteTag = 0x1000, + .paletteTag = FLDEFF_PAL_TAG_0, .oam = &sOamData_CutGrass, .anims = sSpriteAnimTable_CutGrass, .images = sSpriteImageTable_CutGrass, diff --git a/src/fldeff_misc.c b/src/fldeff_misc.c index f197b7b33..bb5bd65d7 100644 --- a/src/fldeff_misc.c +++ b/src/fldeff_misc.c @@ -209,7 +209,7 @@ static const struct SpriteFrameImage gUnknown_858E5D8[] = static const struct SpriteTemplate gUnknown_0858E600 = { .tileTag = 0xFFFF, - .paletteTag = 0x1003, + .paletteTag = FLDEFF_PAL_TAG_3, .oam = &gOamData_858E4D8, .anims = gSpriteAnimTable_858E570, .images = gUnknown_858E588, @@ -220,7 +220,7 @@ static const struct SpriteTemplate gUnknown_0858E600 = static const struct SpriteTemplate gUnknown_0858E618 = { .tileTag = 0xFFFF, - .paletteTag = 0x1008, + .paletteTag = FLDEFF_PAL_TAG_8, .oam = &gOamData_858E4D8, .anims = gSpriteAnimTable_858E574, .images = gUnknown_858E5B0, @@ -231,7 +231,7 @@ static const struct SpriteTemplate gUnknown_0858E618 = static const struct SpriteTemplate gUnknown_0858E630 = { .tileTag = 0xFFFF, - .paletteTag = 0x1008, + .paletteTag = FLDEFF_PAL_TAG_8, .oam = &gOamData_858E4D8, .anims = gSpriteAnimTable_858E584, .images = gUnknown_858E5D8, @@ -239,8 +239,8 @@ static const struct SpriteTemplate gUnknown_0858E630 = .callback = ShrubEntranceSpriteCallback1, }; -const struct SpritePalette gFieldEffectObjectPaletteInfo7 = {gFieldEffectObjectPalette7, 0x1003}; -const struct SpritePalette gFieldEffectObjectPaletteInfo8 = {gFieldEffectObjectPalette8, 0x1008}; +const struct SpritePalette gFieldEffectObjectPaletteInfo7 = {gFieldEffectObjectPalette7, FLDEFF_PAL_TAG_3}; +const struct SpritePalette gFieldEffectObjectPaletteInfo8 = {gFieldEffectObjectPalette8, FLDEFF_PAL_TAG_8}; static const struct OamData gOamData_858E658 = { @@ -277,7 +277,7 @@ static const struct SpriteFrameImage gUnknown_0858E674[] = static const struct SpriteTemplate gUnknown_0858E68C = { .tileTag = 0xFFFF, - .paletteTag = 0x100E, + .paletteTag = FLDEFF_PAL_TAG_14, .oam = &gOamData_858E658, .anims = gSpriteAnimTable_858E670, .images = gUnknown_0858E674, @@ -286,7 +286,7 @@ static const struct SpriteTemplate gUnknown_0858E68C = }; // This uses one of the secret base palettes, so there is no "graphics/field_effects/palettes/09.pal" file. -const struct SpritePalette gFieldEffectObjectPaletteInfo9 = {gTilesetPalettes_SecretBase[5], 0x100E}; +const struct SpritePalette gFieldEffectObjectPaletteInfo9 = {gTilesetPalettes_SecretBase[5], FLDEFF_PAL_TAG_14}; static const u8 gSpriteImage_858E6AC[] = INCBIN_U8("graphics/unknown/858E84C/0.4bpp"); static const u8 gSpriteImage_858E72C[] = INCBIN_U8("graphics/unknown/858E84C/1.4bpp"); @@ -300,7 +300,7 @@ static const struct SpriteFrameImage gUnknown_0858E84C[] = {gSpriteImage_858E7AC, sizeof(gSpriteImage_858E7AC)}, }; -static const struct SpritePalette gUnknown_0858E864 = {gUnknown_0858E82C, 0x1000}; +static const struct SpritePalette gUnknown_0858E864 = {gUnknown_0858E82C, FLDEFF_PAL_TAG_0}; static const union AnimCmd gSpriteAnim_858E86C[] = { @@ -318,7 +318,7 @@ static const union AnimCmd *const gSpriteAnimTable_858E87C[] = static const struct SpriteTemplate gUnknown_0858E880 = { .tileTag = 0xFFFF, - .paletteTag = 0x1000, + .paletteTag = FLDEFF_PAL_TAG_0, .oam = &gObjectEventBaseOam_32x8, .anims = gSpriteAnimTable_858E87C, .images = gUnknown_0858E84C, diff --git a/src/item_use.c b/src/item_use.c index ff689a19a..a90321a3b 100755 --- a/src/item_use.c +++ b/src/item_use.c @@ -399,7 +399,7 @@ static bool8 IsHiddenItemPresentInConnection(struct MapConnection *connection, i u32 localOffset; s32 localLength; - struct MapHeader const *const mapHeader = mapconnection_get_mapheader(connection); + struct MapHeader const *const mapHeader = GetMapHeaderFromConnection(connection); switch (connection->direction) { diff --git a/src/overworld.c b/src/overworld.c index 530699f83..bfe692988 100644 --- a/src/overworld.c +++ b/src/overworld.c @@ -96,24 +96,24 @@ static void VBlankCB_Field(void); static void SpriteCB_LinkPlayer(struct Sprite *sprite); static void ChooseAmbientCrySpecies(void); static void DoMapLoadLoop(u8 *state); +static bool32 LoadMapInStepsLocal(u8 *state, bool32); static bool32 LoadMapInStepsLink(u8 *state); static bool32 ReturnToFieldLocal(u8 *state); -static bool32 LoadMapInStepsLocal(u8 *state, bool32); static bool32 ReturnToFieldLink(u8 *state); -static void mli4_mapscripts_and_other(void); +static void InitObjectEventsLink(void); +static void InitObjectEventsLocal(void); static void InitOverworldGraphicsRegisters(void); static u8 GetSpriteForLinkedPlayer(u8); static u16 KeyInterCB_SendNothing(u32 a1); -static void sub_80867C8(void); +static void ResetMirageTowerAndSaveBlockPtrs(void); static void sub_80867D8(void); -static void sub_8086AE4(void); -static void sub_80869DC(void); -static void sub_8086B14(void); +static void OffsetCameraFocusByLinkPlayerId(void); +static void SpawnLinkPlayers(void); static void SetCameraToTrackGuestPlayer(void); -static void sub_8086988(bool32 arg0); +static void ResumeMap(bool32 arg0); static void SetCameraToTrackPlayer(void); static void sub_8086A68(void); -static void sub_8086860(void); +static void InitViewGraphics(void); static void SetCameraToTrackGuestPlayer_2(void); static void CreateLinkPlayerSprites(void); static void ClearAllPlayerKeys(void); @@ -520,7 +520,7 @@ void Overworld_SetObjEventTemplateMovementType(u8 localId, u8 movementType) } } -static void mapdata_load_assets_to_gpu_and_full_redraw(void) +static void InitMapView(void) { ResetFieldCamera(); CopyMapTilesetsToVram(gMapHeader.mapLayout); @@ -939,7 +939,7 @@ static u8 GetAdjustedInitialDirection(struct InitialPlayerAvatarState *playerStr else if (MetatileBehavior_IsEastArrowWarp(metatileBehavior) == TRUE) 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 )) + || (playerStruct->transitionFlags == PLAYER_AVATAR_FLAG_SURFING && transitionFlags == PLAYER_AVATAR_FLAG_UNDERWATER)) return playerStruct->direction; else if (MetatileBehavior_IsLadder(metatileBehavior) == TRUE) return playerStruct->direction; @@ -1421,7 +1421,7 @@ static void DoCB1_Overworld(u16 newKeys, u16 heldKeys) { struct FieldInput inputStruct; - sub_808B578(); + UpdatePlayerAvatarTransitionState(); FieldClearPlayerInput(&inputStruct); FieldGetPlayerInput(&inputStruct, newKeys, heldKeys); if (!ScriptContext2_IsEnabled()) @@ -1433,7 +1433,7 @@ static void DoCB1_Overworld(u16 newKeys, u16 heldKeys) } else { - player_step(inputStruct.dpadDirection, newKeys, heldKeys); + PlayerStep(inputStruct.dpadDirection, newKeys, heldKeys); } } } @@ -1723,12 +1723,12 @@ void CB2_ContinueSavedGame(void) ClearContinueGameWarpStatus(); SetWarpDestinationToContinueGameWarp(); WarpIntoMap(); - sub_80EDB44(); + TryPutTodaysRivalTrainerOnAir(); SetMainCallback2(CB2_LoadMap); } else { - sub_80EDB44(); + TryPutTodaysRivalTrainerOnAir(); gFieldCallback = sub_8086204; SetMainCallback1(CB1_Overworld); CB2_ReturnToField(); @@ -1797,7 +1797,7 @@ static bool32 LoadMapInStepsLink(u8 *state) InitOverworldBgs(); ScriptContext1_Init(); ScriptContext2_Disable(); - sub_80867C8(); + ResetMirageTowerAndSaveBlockPtrs(); sub_80867D8(); (*state)++; break; @@ -1806,13 +1806,13 @@ static bool32 LoadMapInStepsLink(u8 *state) (*state)++; break; case 2: - sub_8086988(TRUE); + ResumeMap(TRUE); (*state)++; break; case 3: - sub_8086AE4(); - sub_80869DC(); - sub_8086B14(); + OffsetCameraFocusByLinkPlayerId(); + InitObjectEventsLink(); + SpawnLinkPlayers(); SetCameraToTrackGuestPlayer(); (*state)++; break; @@ -1878,16 +1878,16 @@ static bool32 LoadMapInStepsLocal(u8 *state, bool32 a2) (*state)++; break; case 1: - sub_80867C8(); + ResetMirageTowerAndSaveBlockPtrs(); sub_80867D8(); (*state)++; break; case 2: - sub_8086988(a2); + ResumeMap(a2); (*state)++; break; case 3: - mli4_mapscripts_and_other(); + InitObjectEventsLocal(); SetCameraToTrackPlayer(); (*state)++; break; @@ -1945,16 +1945,16 @@ static bool32 ReturnToFieldLocal(u8 *state) switch (*state) { case 0: - sub_80867C8(); + ResetMirageTowerAndSaveBlockPtrs(); sub_80867D8(); - sub_8086988(FALSE); + ResumeMap(FALSE); sub_8086A68(); SetCameraToTrackPlayer(); (*state)++; break; case 1: - sub_8086860(); - sub_81D64C0(); + InitViewGraphics(); + TryLoadTrainerHillEReaderPalette(); (*state)++; break; case 2: @@ -1974,12 +1974,12 @@ static bool32 ReturnToFieldLink(u8 *state) { case 0: FieldClearVBlankHBlankCallbacks(); - sub_80867C8(); + ResetMirageTowerAndSaveBlockPtrs(); sub_80867D8(); (*state)++; break; case 1: - sub_8086988(TRUE); + ResumeMap(TRUE); (*state)++; break; case 2: @@ -2050,7 +2050,7 @@ static void DoMapLoadLoop(u8 *state) while (!LoadMapInStepsLocal(state, FALSE)); } -static void sub_80867C8(void) +static void ResetMirageTowerAndSaveBlockPtrs(void) { ClearMirageTowerPulseBlend(); MoveSaveBlocks_ResetHeap(); @@ -2067,12 +2067,12 @@ static void sub_80867D8(void) LoadOam(); } -static void sub_8086860(void) +static void InitViewGraphics(void) { InitCurrentFlashLevelScanlineEffect(); InitOverworldGraphicsRegisters(); InitTextBoxGfxAndPrinters(); - mapdata_load_assets_to_gpu_and_full_redraw(); + InitMapView(); } static void InitOverworldGraphicsRegisters(void) @@ -2110,7 +2110,7 @@ static void InitOverworldGraphicsRegisters(void) InitFieldMessageBox(); } -static void sub_8086988(bool32 a1) +static void ResumeMap(bool32 a1) { ResetTasks(); ResetSpriteData(); @@ -2133,7 +2133,7 @@ static void sub_8086988(bool32 a1) TryStartMirageTowerPulseBlendEffect(); } -static void sub_80869DC(void) +static void InitObjectEventsLink(void) { gTotalCameraPixelOffsetX = 0; gTotalCameraPixelOffsetY = 0; @@ -2142,7 +2142,7 @@ static void sub_80869DC(void) TryRunOnWarpIntoMapScript(); } -static void mli4_mapscripts_and_other(void) +static void InitObjectEventsLocal(void) { s16 x, y; struct InitialPlayerAvatarState *player; @@ -2183,17 +2183,17 @@ static void SetCameraToTrackGuestPlayer_2(void) InitCameraUpdateCallback(GetSpriteForLinkedPlayer(gLocalLinkPlayerId)); } -static void sub_8086AE4(void) +static void OffsetCameraFocusByLinkPlayerId(void) { u16 x, y; GetCameraFocusCoords(&x, &y); - // This is a hack of some kind; it's undone in sub_8086B14, which is called + // This is a hack of some kind; it's undone in SpawnLinkPlayers, which is called // soon after this function. - sub_8088B3C(x + gLocalLinkPlayerId, y); + SetCameraFocusCoords(x + gLocalLinkPlayerId, y); } -static void sub_8086B14(void) +static void SpawnLinkPlayers(void) { u16 i; u16 x, y; diff --git a/src/trainer_hill.c b/src/trainer_hill.c index d6cb49837..c5aea14d9 100644 --- a/src/trainer_hill.c +++ b/src/trainer_hill.c @@ -64,7 +64,7 @@ static void TrainerHillSetPlayerLost(void); static void TrainerHillGetChallengeStatus(void); static void BufferChallengeTime(void); static void GetAllFloorsUsed(void); -static void ClearVarResult(void); +static void GetInEReaderMode(void); static void IsTrainerHillChallengeActive(void); static void ShowTrainerHillPostBattleText(void); static void SetAllTrainerFlags(void); @@ -202,7 +202,7 @@ static const u16 *const *const sPrizeListSets[] = sPrizeLists2 }; -static const u16 sUnknown_0862A5D4[] = INCBIN_U16("graphics/pokenav/862A5D4.gbapal"); +static const u16 sEReader_Pal[] = INCBIN_U16("graphics/misc/trainer_hill_ereader.gbapal"); static const u8 sRecordWinColors[] = {TEXT_COLOR_TRANSPARENT, TEXT_COLOR_DARK_GREY, TEXT_COLOR_LIGHT_GREY}; static const struct TrHillTag *const sDataPerTag[] = @@ -233,7 +233,7 @@ static void (* const sHillFunctions[])(void) = [TRAINER_HILL_FUNC_GET_CHALLENGE_STATUS] = TrainerHillGetChallengeStatus, [TRAINER_HILL_FUNC_GET_CHALLENGE_TIME] = BufferChallengeTime, [TRAINER_HILL_FUNC_GET_ALL_FLOORS_USED] = GetAllFloorsUsed, - [TRAINER_HILL_FUNC_CLEAR_RESULT] = ClearVarResult, + [TRAINER_HILL_FUNC_GET_IN_EREADER_MODE] = GetInEReaderMode, [TRAINER_HILL_FUNC_IN_CHALLENGE] = IsTrainerHillChallengeActive, [TRAINER_HILL_FUNC_POST_BATTLE_TEXT] = ShowTrainerHillPostBattleText, [TRAINER_HILL_FUNC_SET_ALL_TRAINER_FLAGS] = SetAllTrainerFlags, @@ -546,10 +546,11 @@ static void GetAllFloorsUsed(void) } // May have been dummied. Every time this is called a conditional for var result occurs afterwards -static void ClearVarResult(void) +// Relation to E-Reader is an assumption, most dummied Trainer Hill code seems to be JP E-Reader mode related +static void GetInEReaderMode(void) { SetUpDataStruct(); - gSpecialVar_Result = 0; + gSpecialVar_Result = FALSE; FreeDataStruct(); } @@ -997,11 +998,11 @@ static void SetAllTrainerFlags(void) gSaveBlock2Ptr->frontier.trainerFlags = 0xFF; } -// Palette never loaded, sub_81D6534 always FALSE -void sub_81D64C0(void) +// Palette never loaded, OnTrainerHillEReaderChallengeFloor always FALSE +void TryLoadTrainerHillEReaderPalette(void) { - if (sub_81D6534() == TRUE) - LoadPalette(sUnknown_0862A5D4, 0x70, 0x20); + if (OnTrainerHillEReaderChallengeFloor() == TRUE) + LoadPalette(sEReader_Pal, 0x70, 0x20); } static void GetGameSaved(void) @@ -1020,13 +1021,13 @@ static void ClearGameSaved(void) } // Always FALSE -bool32 sub_81D6534(void) +bool32 OnTrainerHillEReaderChallengeFloor(void) { if (!InTrainerHillChallenge() || GetCurrentTrainerHillMapId() == TRAINER_HILL_ENTRANCE) return FALSE; - ClearVarResult(); - if (gSpecialVar_Result == 0) + GetInEReaderMode(); + if (gSpecialVar_Result == FALSE) return FALSE; else return TRUE; diff --git a/src/trainer_see.c b/src/trainer_see.c index 68a16e208..4f4aaea08 100644 --- a/src/trainer_see.c +++ b/src/trainer_see.c @@ -559,7 +559,7 @@ static bool8 PopOutOfAshHiddenTrainer(u8 taskId, struct Task *task, struct Objec gFieldEffectArguments[1] = trainerObj->currentCoords.y; gFieldEffectArguments[2] = gSprites[trainerObj->spriteId].subpriority - 1; gFieldEffectArguments[3] = 2; - task->tOutOfAshSpriteId = FieldEffectStart(FLDEFF_POP_OUT_OF_ASH); + task->tOutOfAshSpriteId = FieldEffectStart(FLDEFF_ASH_PUFF); task->tFuncId++; } return FALSE; @@ -586,7 +586,7 @@ static bool8 JumpInPlaceHiddenTrainer(u8 taskId, struct Task *task, struct Objec static bool8 WaitRevealHiddenTrainer(u8 taskId, struct Task *task, struct ObjectEvent *trainerObj) { - if (!FieldEffectActiveListContains(FLDEFF_POP_OUT_OF_ASH)) + if (!FieldEffectActiveListContains(FLDEFF_ASH_PUFF)) task->tFuncId = 3; return FALSE; @@ -610,7 +610,7 @@ static void sub_80B44C8(u8 taskId) task->data[7]++; } sTrainerSeeFuncList2[task->data[0]](taskId, task, objEvent); - if (task->data[0] == 3 && !FieldEffectActiveListContains(FLDEFF_POP_OUT_OF_ASH)) + if (task->data[0] == 3 && !FieldEffectActiveListContains(FLDEFF_ASH_PUFF)) { SetTrainerMovementType(objEvent, GetTrainerFacingDirectionMovementType(objEvent->facingDirection)); TryOverrideTemplateCoordsForObjectEvent(objEvent, GetTrainerFacingDirectionMovementType(objEvent->facingDirection)); diff --git a/src/tv.c b/src/tv.c index eaf30f82b..17a02be6b 100644 --- a/src/tv.c +++ b/src/tv.c @@ -1930,7 +1930,7 @@ void sub_80EDA80(void) } } -void sub_80EDB44(void) +void TryPutTodaysRivalTrainerOnAir(void) { TVShow *show; u32 i;