From a612c27f2ded23f713b2199764b65c6b8b4aaf9d Mon Sep 17 00:00:00 2001 From: GriffinR Date: Mon, 25 Oct 2021 10:20:48 -0400 Subject: Drop battle transition 'phase' terminology --- src/battle_transition.c | 1367 +++++++++++++++++++++++------------------------ 1 file changed, 683 insertions(+), 684 deletions(-) (limited to 'src/battle_transition.c') diff --git a/src/battle_transition.c b/src/battle_transition.c index 2fc4c6854..983a50217 100644 --- a/src/battle_transition.c +++ b/src/battle_transition.c @@ -60,186 +60,186 @@ struct StructRectangularSpiral typedef bool8 (*TransitionStateFunc)(struct Task *task); typedef bool8 (*TransitionSpriteCallback)(struct Sprite *sprite); -// this file's functions +static bool8 Transition_StartIntro(struct Task *task); +static bool8 Transition_WaitForIntro(struct Task *task); +static bool8 Transition_StartMain(struct Task *task); +static bool8 Transition_WaitForMain(struct Task *task); + static void LaunchBattleTransitionTask(u8 transitionId); -static void Task_BattleTransitionMain(u8 taskId); -static void Phase1Task_TransitionAll(u8 taskId); -static void Phase2Task_Blur(u8 taskId); -static void Phase2Task_Swirl(u8 taskId); -static void Phase2Task_Shuffle(u8 taskId); -static void Phase2Task_BigPokeball(u8 taskId); -static void Phase2Task_PokeballsTrail(u8 taskId); -static void Phase2Task_Clockwise_BlackFade(u8 taskId); -static void Phase2Task_Ripple(u8 taskId); -static void Phase2Task_Wave(u8 taskId); -static void Phase2Task_Slice(u8 taskId); -static void Phase2Task_WhiteFade(u8 taskId); -static void Phase2Task_GridSquares(u8 taskId); -static void Phase2Task_Shards(u8 taskId); -static void Phase2Task_Sidney(u8 taskId); -static void Phase2Task_Phoebe(u8 taskId); -static void Phase2Task_Glacia(u8 taskId); -static void Phase2Task_Drake(u8 taskId); -static void Phase2Task_Champion(u8 taskId); -static void Phase2Task_Aqua(u8 taskId); -static void Phase2Task_Magma(u8 taskId); -static void Phase2Task_Regice(u8 taskId); -static void Phase2Task_Registeel(u8 taskId); -static void Phase2Task_Regirock(u8 taskId); -static void Phase2Task_Kyogre(u8 taskId); -static void Phase2Task_Groudon(u8 taskId); -static void Phase2Task_Rayquaza(u8 taskId); -static void Phase2Task_ShredSplit(u8 taskId); -static void Phase2Task_Blackhole1(u8 taskId); -static void Phase2Task_Blackhole2(u8 taskId); -static void Phase2Task_RectangularSpiral(u8 taskId); -static void Phase2Task_FrontierLogoWiggle(u8 taskId); -static void Phase2Task_FrontierLogoWave(u8 taskId); -static void Phase2Task_FrontierSquares(u8 taskId); -static void Phase2Task_FrontierSquaresScroll(u8 taskId); -static void Phase2Task_FrontierSquaresSpiral(u8 taskId); +static void Task_BattleTransition(u8 taskId); +static void Task_Intro(u8 taskId); +static void Task_Blur(u8 taskId); +static void Task_Swirl(u8 taskId); +static void Task_Shuffle(u8 taskId); +static void Task_BigPokeball(u8 taskId); +static void Task_PokeballsTrail(u8 taskId); +static void Task_Clockwise_BlackFade(u8 taskId); +static void Task_Ripple(u8 taskId); +static void Task_Wave(u8 taskId); +static void Task_Slice(u8 taskId); +static void Task_WhiteFade(u8 taskId); +static void Task_GridSquares(u8 taskId); +static void Task_Shards(u8 taskId); +static void Task_Sidney(u8 taskId); +static void Task_Phoebe(u8 taskId); +static void Task_Glacia(u8 taskId); +static void Task_Drake(u8 taskId); +static void Task_Champion(u8 taskId); +static void Task_Aqua(u8 taskId); +static void Task_Magma(u8 taskId); +static void Task_Regice(u8 taskId); +static void Task_Registeel(u8 taskId); +static void Task_Regirock(u8 taskId); +static void Task_Kyogre(u8 taskId); +static void Task_Groudon(u8 taskId); +static void Task_Rayquaza(u8 taskId); +static void Task_ShredSplit(u8 taskId); +static void Task_Blackhole1(u8 taskId); +static void Task_Blackhole2(u8 taskId); +static void Task_RectangularSpiral(u8 taskId); +static void Task_FrontierLogoWiggle(u8 taskId); +static void Task_FrontierLogoWave(u8 taskId); +static void Task_FrontierSquares(u8 taskId); +static void Task_FrontierSquaresScroll(u8 taskId); +static void Task_FrontierSquaresSpiral(u8 taskId); static void VBlankCB_BattleTransition(void); -static void VBlankCB_Phase2_Swirl(void); -static void HBlankCB_Phase2_Swirl(void); -static void VBlankCB_Phase2_Shuffle(void); -static void HBlankCB_Phase2_Shuffle(void); -static void VBlankCB0_Phase2_BigPokeball(void); -static void VBlankCB1_Phase2_BigPokeball(void); -static void VBlankCB_Phase2_Clockwise_BlackFade(void); -static void VBlankCB_Phase2_Ripple(void); -static void HBlankCB_Phase2_Ripple(void); -static void VBlankCB_Phase2_30(void); -static void HBlankCB_Phase2_30(void); -static void VBlankCB_Phase2_Wave(void); -static void VBlankCB_Phase2_Slice(void); -static void HBlankCB_Phase2_Slice(void); -static void VBlankCB0_Phase2_WhiteFade(void); -static void VBlankCB1_Phase2_WhiteFade(void); -static void HBlankCB_Phase2_WhiteFade(void); -static void VBlankCB_Phase2_Shards(void); -static void VBlankCB_Phase2_Rayquaza(void); -static bool8 Phase2_Blur_Func1(struct Task *task); -static bool8 Phase2_Blur_Func2(struct Task *task); -static bool8 Phase2_Blur_Func3(struct Task *task); -static bool8 Phase2_Swirl_Func1(struct Task *task); -static bool8 Phase2_Swirl_Func2(struct Task *task); -static bool8 Phase2_Shuffle_Func1(struct Task *task); -static bool8 Phase2_Shuffle_Func2(struct Task *task); -static bool8 Phase2_Aqua_Func1(struct Task *task); -static bool8 Phase2_Aqua_Func2(struct Task *task); -static bool8 Phase2_Magma_Func1(struct Task *task); -static bool8 Phase2_Magma_Func2(struct Task *task); -static bool8 Phase2_FramesCountdown(struct Task *task); -static bool8 Phase2_Regi_Func1(struct Task *task); -static bool8 Phase2_Regice_Func2(struct Task *task); -static bool8 Phase2_Registeel_Func2(struct Task *task); -static bool8 Phase2_Regirock_Func2(struct Task *task); -static bool8 Phase2_WeatherTrio_Func1(struct Task *task); -static bool8 Phase2_WaitPaletteFade(struct Task *task); -static bool8 Phase2_Kyogre_Func3(struct Task *task); -static bool8 Phase2_Kyogre_Func4(struct Task *task); -static bool8 Phase2_Kyogre_Func5(struct Task *task); -static bool8 Phase2_Groudon_Func3(struct Task *task); -static bool8 Phase2_Groudon_Func4(struct Task *task); -static bool8 Phase2_Groudon_Func5(struct Task *task); -static bool8 Phase2_WeatherDuo_Func6(struct Task *task); -static bool8 Phase2_WeatherDuo_Func7(struct Task *task); -static bool8 Phase2_BigPokeball_Func1(struct Task *task); -static bool8 Phase2_BigPokeball_Func2(struct Task *task); -static bool8 Phase2_BigPokeball_Func3(struct Task *task); -static bool8 Phase2_BigPokeball_Func4(struct Task *task); -static bool8 Phase2_BigPokeball_Func5(struct Task *task); -static bool8 Phase2_BigPokeball_Func6(struct Task *task); -static bool8 Phase2_PokeballsTrail_Func1(struct Task *task); -static bool8 Phase2_PokeballsTrail_Func2(struct Task *task); -static bool8 Phase2_PokeballsTrail_Func3(struct Task *task); -static bool8 Phase2_Clockwise_BlackFade_Func1(struct Task *task); -static bool8 Phase2_Clockwise_BlackFade_Func2(struct Task *task); -static bool8 Phase2_Clockwise_BlackFade_Func3(struct Task *task); -static bool8 Phase2_Clockwise_BlackFade_Func4(struct Task *task); -static bool8 Phase2_Clockwise_BlackFade_Func5(struct Task *task); -static bool8 Phase2_Clockwise_BlackFade_Func6(struct Task *task); -static bool8 Phase2_Clockwise_BlackFade_Func7(struct Task *task); -static bool8 Phase2_Ripple_Func1(struct Task *task); -static bool8 Phase2_Ripple_Func2(struct Task *task); -static bool8 Phase2_Wave_Func1(struct Task *task); -static bool8 Phase2_Wave_Func2(struct Task *task); -static bool8 Phase2_Wave_Func3(struct Task *task); -static bool8 Phase2_Slice_Func1(struct Task *task); -static bool8 Phase2_Slice_Func2(struct Task *task); -static bool8 Phase2_Slice_Func3(struct Task *task); -static bool8 Phase2_WhiteFade_Func1(struct Task *task); -static bool8 Phase2_WhiteFade_Func2(struct Task *task); -static bool8 Phase2_WhiteFade_Func3(struct Task *task); -static bool8 Phase2_WhiteFade_Func4(struct Task *task); -static bool8 Phase2_WhiteFade_Func5(struct Task *task); -static bool8 Phase2_GridSquares_Func1(struct Task *task); -static bool8 Phase2_GridSquares_Func2(struct Task *task); -static bool8 Phase2_GridSquares_Func3(struct Task *task); -static bool8 Phase2_Shards_Func1(struct Task *task); -static bool8 Phase2_Shards_Func2(struct Task *task); -static bool8 Phase2_Shards_Func3(struct Task *task); -static bool8 Phase2_Shards_Func4(struct Task *task); -static bool8 Phase2_Shards_Func5(struct Task *task); -static bool8 Phase2_ShredSplit_Func1(struct Task *task); -static bool8 Phase2_ShredSplit_Func2(struct Task *task); -static bool8 Phase2_ShredSplit_Func3(struct Task *task); -static bool8 Phase2_ShredSplit_Func4(struct Task *task); -static bool8 Phase2_Blackhole_Func1(struct Task *task); -static bool8 Phase2_Blackhole1_Func2(struct Task *task); -static bool8 Phase2_Blackhole1_Func3(struct Task *task); -static bool8 Phase2_Blackhole2_Func2(struct Task *task); -static bool8 Phase2_RectangularSpiral_Func1(struct Task *task); -static bool8 Phase2_RectangularSpiral_Func2(struct Task *task); -static bool8 Phase2_RectangularSpiral_Func3(struct Task *task); -static bool8 Phase2_FrontierLogoWiggle_Func1(struct Task *task); -static bool8 Phase2_FrontierLogoWiggle_Func2(struct Task *task); -static bool8 Phase2_FrontierLogoWave_Func1(struct Task *task); -static bool8 Phase2_FrontierLogoWave_Func2(struct Task *task); -static bool8 Phase2_FrontierLogoWave_Func3(struct Task *task); -static bool8 Phase2_FrontierLogoWave_Func4(struct Task *task); -static bool8 Phase2_Rayquaza_Func3(struct Task *task); -static bool8 Phase2_Rayquaza_Func4(struct Task *task); -static bool8 Phase2_Rayquaza_Func5(struct Task *task); -static bool8 Phase2_Rayquaza_Func6(struct Task *task); -static bool8 Phase2_Rayquaza_Func7(struct Task *task); -static bool8 Phase2_Rayquaza_Func8(struct Task *task); -static bool8 Phase2_Rayquaza_Func9(struct Task *task); -static bool8 Phase2_FrontierSquares_Func1(struct Task *task); -static bool8 Phase2_FrontierSquares_Func2(struct Task *task); -static bool8 Phase2_FrontierSquares_Func3(struct Task *task); -static bool8 Phase2_FrontierSquares_End(struct Task *task); -static bool8 Phase2_FrontierSquaresSpiral_Func1(struct Task *task); -static bool8 Phase2_FrontierSquaresSpiral_Func2(struct Task *task); -static bool8 Phase2_FrontierSquaresSpiral_Func3(struct Task *task); -static bool8 Phase2_FrontierSquaresSpiral_Func4(struct Task *task); -static bool8 Phase2_FrontierSquaresScroll_Func1(struct Task *task); -static bool8 Phase2_FrontierSquaresScroll_Func2(struct Task *task); -static bool8 Phase2_FrontierSquaresScroll_Func3(struct Task *task); -static bool8 Phase2_FrontierSquaresScroll_Func4(struct Task *task); -static bool8 Phase2_FrontierSquaresScroll_Func5(struct Task *task); -static bool8 Phase2_Mugshot_Func1(struct Task *task); -static bool8 Phase2_Mugshot_Func2(struct Task *task); -static bool8 Phase2_Mugshot_Func3(struct Task *task); -static bool8 Phase2_Mugshot_Func4(struct Task *task); -static bool8 Phase2_Mugshot_Func5(struct Task *task); -static bool8 Phase2_Mugshot_Func6(struct Task *task); -static bool8 Phase2_Mugshot_Func7(struct Task *task); -static bool8 Phase2_Mugshot_Func8(struct Task *task); -static bool8 Phase2_Mugshot_Func9(struct Task *task); -static bool8 Phase2_Mugshot_Func10(struct Task *task); -static void Phase2Task_MugShotTransition(u8 taskId); +static void VBlankCB_Swirl(void); +static void HBlankCB_Swirl(void); +static void VBlankCB_Shuffle(void); +static void HBlankCB_Shuffle(void); +static void VBlankCB0_BigPokeball(void); +static void VBlankCB1_BigPokeball(void); +static void VBlankCB_Clockwise_BlackFade(void); +static void VBlankCB_Ripple(void); +static void HBlankCB_Ripple(void); +static void VBlankCB_30(void); +static void HBlankCB_30(void); +static void VBlankCB_Wave(void); +static void VBlankCB_Slice(void); +static void HBlankCB_Slice(void); +static void VBlankCB0_WhiteFade(void); +static void VBlankCB1_WhiteFade(void); +static void HBlankCB_WhiteFade(void); +static void VBlankCB_Shards(void); +static void VBlankCB_Rayquaza(void); +static bool8 Blur_Func1(struct Task *task); +static bool8 Blur_Func2(struct Task *task); +static bool8 Blur_Func3(struct Task *task); +static bool8 Swirl_Func1(struct Task *task); +static bool8 Swirl_Func2(struct Task *task); +static bool8 Shuffle_Func1(struct Task *task); +static bool8 Shuffle_Func2(struct Task *task); +static bool8 Aqua_Func1(struct Task *task); +static bool8 Aqua_Func2(struct Task *task); +static bool8 Magma_Func1(struct Task *task); +static bool8 Magma_Func2(struct Task *task); +static bool8 FramesCountdown(struct Task *task); +static bool8 Regi_Func1(struct Task *task); +static bool8 Regice_Func2(struct Task *task); +static bool8 Registeel_Func2(struct Task *task); +static bool8 Regirock_Func2(struct Task *task); +static bool8 WeatherTrio_Func1(struct Task *task); +static bool8 WaitPaletteFade(struct Task *task); +static bool8 Kyogre_Func3(struct Task *task); +static bool8 Kyogre_Func4(struct Task *task); +static bool8 Kyogre_Func5(struct Task *task); +static bool8 Groudon_Func3(struct Task *task); +static bool8 Groudon_Func4(struct Task *task); +static bool8 Groudon_Func5(struct Task *task); +static bool8 WeatherDuo_Func6(struct Task *task); +static bool8 WeatherDuo_Func7(struct Task *task); +static bool8 BigPokeball_Func1(struct Task *task); +static bool8 BigPokeball_Func2(struct Task *task); +static bool8 BigPokeball_Func3(struct Task *task); +static bool8 BigPokeball_Func4(struct Task *task); +static bool8 BigPokeball_Func5(struct Task *task); +static bool8 BigPokeball_Func6(struct Task *task); +static bool8 PokeballsTrail_Func1(struct Task *task); +static bool8 PokeballsTrail_Func2(struct Task *task); +static bool8 PokeballsTrail_Func3(struct Task *task); +static bool8 Clockwise_BlackFade_Func1(struct Task *task); +static bool8 Clockwise_BlackFade_Func2(struct Task *task); +static bool8 Clockwise_BlackFade_Func3(struct Task *task); +static bool8 Clockwise_BlackFade_Func4(struct Task *task); +static bool8 Clockwise_BlackFade_Func5(struct Task *task); +static bool8 Clockwise_BlackFade_Func6(struct Task *task); +static bool8 Clockwise_BlackFade_Func7(struct Task *task); +static bool8 Ripple_Func1(struct Task *task); +static bool8 Ripple_Func2(struct Task *task); +static bool8 Wave_Func1(struct Task *task); +static bool8 Wave_Func2(struct Task *task); +static bool8 Wave_Func3(struct Task *task); +static bool8 Slice_Func1(struct Task *task); +static bool8 Slice_Func2(struct Task *task); +static bool8 Slice_Func3(struct Task *task); +static bool8 WhiteFade_Func1(struct Task *task); +static bool8 WhiteFade_Func2(struct Task *task); +static bool8 WhiteFade_Func3(struct Task *task); +static bool8 WhiteFade_Func4(struct Task *task); +static bool8 WhiteFade_Func5(struct Task *task); +static bool8 GridSquares_Func1(struct Task *task); +static bool8 GridSquares_Func2(struct Task *task); +static bool8 GridSquares_Func3(struct Task *task); +static bool8 Shards_Func1(struct Task *task); +static bool8 Shards_Func2(struct Task *task); +static bool8 Shards_Func3(struct Task *task); +static bool8 Shards_Func4(struct Task *task); +static bool8 Shards_Func5(struct Task *task); +static bool8 ShredSplit_Func1(struct Task *task); +static bool8 ShredSplit_Func2(struct Task *task); +static bool8 ShredSplit_Func3(struct Task *task); +static bool8 ShredSplit_Func4(struct Task *task); +static bool8 Blackhole_Func1(struct Task *task); +static bool8 Blackhole1_Func2(struct Task *task); +static bool8 Blackhole1_Func3(struct Task *task); +static bool8 Blackhole2_Func2(struct Task *task); +static bool8 RectangularSpiral_Func1(struct Task *task); +static bool8 RectangularSpiral_Func2(struct Task *task); +static bool8 RectangularSpiral_Func3(struct Task *task); +static bool8 FrontierLogoWiggle_Func1(struct Task *task); +static bool8 FrontierLogoWiggle_Func2(struct Task *task); +static bool8 FrontierLogoWave_Func1(struct Task *task); +static bool8 FrontierLogoWave_Func2(struct Task *task); +static bool8 FrontierLogoWave_Func3(struct Task *task); +static bool8 FrontierLogoWave_Func4(struct Task *task); +static bool8 Rayquaza_Func3(struct Task *task); +static bool8 Rayquaza_Func4(struct Task *task); +static bool8 Rayquaza_Func5(struct Task *task); +static bool8 Rayquaza_Func6(struct Task *task); +static bool8 Rayquaza_Func7(struct Task *task); +static bool8 Rayquaza_Func8(struct Task *task); +static bool8 Rayquaza_Func9(struct Task *task); +static bool8 FrontierSquares_Func1(struct Task *task); +static bool8 FrontierSquares_Func2(struct Task *task); +static bool8 FrontierSquares_Func3(struct Task *task); +static bool8 FrontierSquares_End(struct Task *task); +static bool8 FrontierSquaresSpiral_Func1(struct Task *task); +static bool8 FrontierSquaresSpiral_Func2(struct Task *task); +static bool8 FrontierSquaresSpiral_Func3(struct Task *task); +static bool8 FrontierSquaresSpiral_Func4(struct Task *task); +static bool8 FrontierSquaresScroll_Func1(struct Task *task); +static bool8 FrontierSquaresScroll_Func2(struct Task *task); +static bool8 FrontierSquaresScroll_Func3(struct Task *task); +static bool8 FrontierSquaresScroll_Func4(struct Task *task); +static bool8 FrontierSquaresScroll_Func5(struct Task *task); +static bool8 Mugshot_Func1(struct Task *task); +static bool8 Mugshot_Func2(struct Task *task); +static bool8 Mugshot_Func3(struct Task *task); +static bool8 Mugshot_Func4(struct Task *task); +static bool8 Mugshot_Func5(struct Task *task); +static bool8 Mugshot_Func6(struct Task *task); +static bool8 Mugshot_Func7(struct Task *task); +static bool8 Mugshot_Func8(struct Task *task); +static bool8 Mugshot_Func9(struct Task *task); +static bool8 Mugshot_Func10(struct Task *task); +static void Task_MugShotTransition(u8 taskId); static void Mugshots_CreateOpponentPlayerSprites(struct Task *task); -static void VBlankCB0_Phase2_Mugshots(void); -static void VBlankCB1_Phase2_Mugshots(void); -static void HBlankCB_Phase2_Mugshots(void); -static bool8 Transition_Phase1(struct Task *task); -static bool8 Transition_WaitForPhase1(struct Task *task); -static bool8 Transition_Phase2(struct Task *task); -static bool8 Transition_WaitForPhase2(struct Task *task); +static void VBlankCB0_Mugshots(void); +static void VBlankCB1_Mugshots(void); +static void HBlankCB_Mugshots(void); static void InitTransitionStructVars(void); static void FadeScreenBlack(void); -static void CreatePhase1Task(s16 a0, s16 a1, s16 a2, s16 a3, s16 a4); +static void CreateIntroTask(s16 a0, s16 a1, s16 a2, s16 a3, s16 a4); static void sub_814A014(u16 *a0, s16 a1, s16 a2, s16 a3); static void sub_8149F98(s16 *array, s16 sinAdd, s16 index, s16 indexIncrementer, s16 amplitude, s16 arrSize); static void GetBg0TilemapDst(u16 **tileset); @@ -248,9 +248,9 @@ static bool8 sub_814A228(s16 *a0, bool8 a1, bool8 a2); static void SetTrainerPicSlideTable(s16 spriteId, s16 arrId); static void IncrementTrainerPicState(s16 spriteId); static s16 IsTrainerPicSlideDone(s16 spriteId); -static bool8 Phase1_TransitionAll_Func1(struct Task *task); -static bool8 Phase1_TransitionAll_Func2(struct Task *task); -static bool8 IsPhase1Done(void); +static bool8 Transition_Intro_1(struct Task *task); +static bool8 Transition_Intro_2(struct Task *task); +static bool8 IsIntroTaskDone(void); static bool16 sub_8149048(const s16 * const *arg0, struct StructRectangularSpiral *arg1); static void sub_814713C(struct Sprite *sprite); static void SpriteCb_TrainerPic(struct Sprite *sprite); @@ -261,16 +261,13 @@ static bool8 TrainerPicCb_Slide1(struct Sprite *sprite); static bool8 TrainerPicCb_Slide2(struct Sprite *sprite); static bool8 TrainerPicCb_Slide3(struct Sprite *sprite); -// iwram bss vars static s16 sUnusedRectangularSpiralVar; static u8 sTestingTransitionId; static u8 sTestingTransitionState; static struct StructRectangularSpiral sRectangularSpiralTransition[4]; -// ewram vars EWRAM_DATA static struct TransitionData *sTransitionStructPtr = NULL; -// const rom data static const u32 sBigPokeball_Tileset[] = INCBIN_U32("graphics/battle_transitions/big_pokeball.4bpp"); static const u32 sPokeballTrail_Tileset[] = INCBIN_U32("graphics/battle_transitions/pokeball_trail.4bpp"); static const u8 sPokeball_Gfx[] = INCBIN_U8("graphics/battle_transitions/pokeball.4bpp"); @@ -312,205 +309,207 @@ static const u32 sFrontierSquares_Shrink1_Tileset[] = INCBIN_U32("graphics/battl static const u32 sFrontierSquares_Shrink2_Tileset[] = INCBIN_U32("graphics/battle_transitions/frontier_square_4.4bpp.lz"); static const u32 sFrontierSquares_Tilemap[] = INCBIN_U32("graphics/battle_transitions/frontier_squares.bin"); -static const TaskFunc sPhase1_Tasks[B_TRANSITION_COUNT] = +// All battle transitions use the same intro +static const TaskFunc sTasks_Intro[B_TRANSITION_COUNT] = { - [0 ... B_TRANSITION_COUNT - 1] = &Phase1Task_TransitionAll + [0 ... B_TRANSITION_COUNT - 1] = &Task_Intro }; -static const TaskFunc sPhase2_Tasks[B_TRANSITION_COUNT] = -{ - [B_TRANSITION_BLUR] = Phase2Task_Blur, - [B_TRANSITION_SWIRL] = Phase2Task_Swirl, - [B_TRANSITION_SHUFFLE] = Phase2Task_Shuffle, - [B_TRANSITION_BIG_POKEBALL] = Phase2Task_BigPokeball, - [B_TRANSITION_POKEBALLS_TRAIL] = Phase2Task_PokeballsTrail, - [B_TRANSITION_CLOCKWISE_BLACKFADE] = Phase2Task_Clockwise_BlackFade, - [B_TRANSITION_RIPPLE] = Phase2Task_Ripple, - [B_TRANSITION_WAVE] = Phase2Task_Wave, - [B_TRANSITION_SLICE] = Phase2Task_Slice, - [B_TRANSITION_WHITEFADE] = Phase2Task_WhiteFade, - [B_TRANSITION_GRID_SQUARES] = Phase2Task_GridSquares, - [B_TRANSITION_SHARDS] = Phase2Task_Shards, - [B_TRANSITION_SIDNEY] = Phase2Task_Sidney, - [B_TRANSITION_PHOEBE] = Phase2Task_Phoebe, - [B_TRANSITION_GLACIA] = Phase2Task_Glacia, - [B_TRANSITION_DRAKE] = Phase2Task_Drake, - [B_TRANSITION_CHAMPION] = Phase2Task_Champion, - [B_TRANSITION_AQUA] = Phase2Task_Aqua, - [B_TRANSITION_MAGMA] = Phase2Task_Magma, - [B_TRANSITION_REGICE] = Phase2Task_Regice, - [B_TRANSITION_REGISTEEL] = Phase2Task_Registeel, - [B_TRANSITION_REGIROCK] = Phase2Task_Regirock, - [B_TRANSITION_KYOGRE] = Phase2Task_Kyogre, - [B_TRANSITION_GROUDON] = Phase2Task_Groudon, - [B_TRANSITION_RAYQUAZA] = Phase2Task_Rayquaza, - [B_TRANSITION_SHRED_SPLIT] = Phase2Task_ShredSplit, - [B_TRANSITION_BLACKHOLE1] = Phase2Task_Blackhole1, - [B_TRANSITION_BLACKHOLE2] = Phase2Task_Blackhole2, - [B_TRANSITION_RECTANGULAR_SPIRAL] = Phase2Task_RectangularSpiral, - [B_TRANSITION_FRONTIER_LOGO_WIGGLE] = Phase2Task_FrontierLogoWiggle, - [B_TRANSITION_FRONTIER_LOGO_WAVE] = Phase2Task_FrontierLogoWave, - [B_TRANSITION_FRONTIER_SQUARES] = Phase2Task_FrontierSquares, - [B_TRANSITION_FRONTIER_SQUARES_SCROLL] = Phase2Task_FrontierSquaresScroll, - [B_TRANSITION_FRONTIER_SQUARES_SPIRAL] = Phase2Task_FrontierSquaresSpiral, - [B_TRANSITION_FRONTIER_CIRCLES_MEET] = Phase2Task_FrontierCirclesMeet, - [B_TRANSITION_FRONTIER_CIRCLES_CROSS] = Phase2Task_FrontierCirclesCross, - [B_TRANSITION_FRONTIER_CIRCLES_ASYMMETRIC_SPIRAL] = Phase2Task_FrontierCirclesAsymmetricSpiral, - [B_TRANSITION_FRONTIER_CIRCLES_SYMMETRIC_SPIRAL] = Phase2Task_FrontierCirclesSymmetricSpiral, - [B_TRANSITION_FRONTIER_CIRCLES_MEET_IN_SEQ] = Phase2Task_FrontierCirclesMeetInSeq, - [B_TRANSITION_FRONTIER_CIRCLES_CROSS_IN_SEQ] = Phase2Task_FrontierCirclesCrossInSeq, - [B_TRANSITION_FRONTIER_CIRCLES_ASYMMETRIC_SPIRAL_IN_SEQ] = Phase2Task_FrontierCirclesAsymmetricSpiralInSeq, - [B_TRANSITION_FRONTIER_CIRCLES_SYMMETRIC_SPIRAL_IN_SEQ] = Phase2Task_FrontierCirclesSymmetricSpiralInSeq, +// After the intro each transition has a unique main task +static const TaskFunc sTasks_Main[B_TRANSITION_COUNT] = +{ + [B_TRANSITION_BLUR] = Task_Blur, + [B_TRANSITION_SWIRL] = Task_Swirl, + [B_TRANSITION_SHUFFLE] = Task_Shuffle, + [B_TRANSITION_BIG_POKEBALL] = Task_BigPokeball, + [B_TRANSITION_POKEBALLS_TRAIL] = Task_PokeballsTrail, + [B_TRANSITION_CLOCKWISE_BLACKFADE] = Task_Clockwise_BlackFade, + [B_TRANSITION_RIPPLE] = Task_Ripple, + [B_TRANSITION_WAVE] = Task_Wave, + [B_TRANSITION_SLICE] = Task_Slice, + [B_TRANSITION_WHITEFADE] = Task_WhiteFade, + [B_TRANSITION_GRID_SQUARES] = Task_GridSquares, + [B_TRANSITION_SHARDS] = Task_Shards, + [B_TRANSITION_SIDNEY] = Task_Sidney, + [B_TRANSITION_PHOEBE] = Task_Phoebe, + [B_TRANSITION_GLACIA] = Task_Glacia, + [B_TRANSITION_DRAKE] = Task_Drake, + [B_TRANSITION_CHAMPION] = Task_Champion, + [B_TRANSITION_AQUA] = Task_Aqua, + [B_TRANSITION_MAGMA] = Task_Magma, + [B_TRANSITION_REGICE] = Task_Regice, + [B_TRANSITION_REGISTEEL] = Task_Registeel, + [B_TRANSITION_REGIROCK] = Task_Regirock, + [B_TRANSITION_KYOGRE] = Task_Kyogre, + [B_TRANSITION_GROUDON] = Task_Groudon, + [B_TRANSITION_RAYQUAZA] = Task_Rayquaza, + [B_TRANSITION_SHRED_SPLIT] = Task_ShredSplit, + [B_TRANSITION_BLACKHOLE1] = Task_Blackhole1, + [B_TRANSITION_BLACKHOLE2] = Task_Blackhole2, + [B_TRANSITION_RECTANGULAR_SPIRAL] = Task_RectangularSpiral, + [B_TRANSITION_FRONTIER_LOGO_WIGGLE] = Task_FrontierLogoWiggle, + [B_TRANSITION_FRONTIER_LOGO_WAVE] = Task_FrontierLogoWave, + [B_TRANSITION_FRONTIER_SQUARES] = Task_FrontierSquares, + [B_TRANSITION_FRONTIER_SQUARES_SCROLL] = Task_FrontierSquaresScroll, + [B_TRANSITION_FRONTIER_SQUARES_SPIRAL] = Task_FrontierSquaresSpiral, + [B_TRANSITION_FRONTIER_CIRCLES_MEET] = Task_FrontierCirclesMeet, + [B_TRANSITION_FRONTIER_CIRCLES_CROSS] = Task_FrontierCirclesCross, + [B_TRANSITION_FRONTIER_CIRCLES_ASYMMETRIC_SPIRAL] = Task_FrontierCirclesAsymmetricSpiral, + [B_TRANSITION_FRONTIER_CIRCLES_SYMMETRIC_SPIRAL] = Task_FrontierCirclesSymmetricSpiral, + [B_TRANSITION_FRONTIER_CIRCLES_MEET_IN_SEQ] = Task_FrontierCirclesMeetInSeq, + [B_TRANSITION_FRONTIER_CIRCLES_CROSS_IN_SEQ] = Task_FrontierCirclesCrossInSeq, + [B_TRANSITION_FRONTIER_CIRCLES_ASYMMETRIC_SPIRAL_IN_SEQ] = Task_FrontierCirclesAsymmetricSpiralInSeq, + [B_TRANSITION_FRONTIER_CIRCLES_SYMMETRIC_SPIRAL_IN_SEQ] = Task_FrontierCirclesSymmetricSpiralInSeq, }; -static const TransitionStateFunc sMainTransitionPhases[] = +static const TransitionStateFunc sTaskHandlers[] = { - &Transition_Phase1, - &Transition_WaitForPhase1, - &Transition_Phase2, - &Transition_WaitForPhase2 + &Transition_StartIntro, + &Transition_WaitForIntro, + &Transition_StartMain, + &Transition_WaitForMain }; -static const TransitionStateFunc sPhase2_Blur_Funcs[] = +static const TransitionStateFunc sBlur_Funcs[] = { - Phase2_Blur_Func1, - Phase2_Blur_Func2, - Phase2_Blur_Func3 + Blur_Func1, + Blur_Func2, + Blur_Func3 }; -static const TransitionStateFunc sPhase2_Swirl_Funcs[] = +static const TransitionStateFunc sSwirl_Funcs[] = { - Phase2_Swirl_Func1, - Phase2_Swirl_Func2, + Swirl_Func1, + Swirl_Func2, }; -static const TransitionStateFunc sPhase2_Shuffle_Funcs[] = +static const TransitionStateFunc sShuffle_Funcs[] = { - Phase2_Shuffle_Func1, - Phase2_Shuffle_Func2, + Shuffle_Func1, + Shuffle_Func2, }; -static const TransitionStateFunc sPhase2_Aqua_Funcs[] = +static const TransitionStateFunc sAqua_Funcs[] = { - Phase2_Aqua_Func1, - Phase2_Aqua_Func2, - Phase2_BigPokeball_Func3, - Phase2_BigPokeball_Func4, - Phase2_BigPokeball_Func5, - Phase2_FramesCountdown, - Phase2_BigPokeball_Func6 + Aqua_Func1, + Aqua_Func2, + BigPokeball_Func3, + BigPokeball_Func4, + BigPokeball_Func5, + FramesCountdown, + BigPokeball_Func6 }; -static const TransitionStateFunc sPhase2_Magma_Funcs[] = +static const TransitionStateFunc sMagma_Funcs[] = { - Phase2_Magma_Func1, - Phase2_Magma_Func2, - Phase2_BigPokeball_Func3, - Phase2_BigPokeball_Func4, - Phase2_BigPokeball_Func5, - Phase2_FramesCountdown, - Phase2_BigPokeball_Func6 + Magma_Func1, + Magma_Func2, + BigPokeball_Func3, + BigPokeball_Func4, + BigPokeball_Func5, + FramesCountdown, + BigPokeball_Func6 }; -static const TransitionStateFunc sPhase2_BigPokeball_Funcs[] = +static const TransitionStateFunc sBigPokeball_Funcs[] = { - Phase2_BigPokeball_Func1, - Phase2_BigPokeball_Func2, - Phase2_BigPokeball_Func3, - Phase2_BigPokeball_Func4, - Phase2_BigPokeball_Func5, - Phase2_BigPokeball_Func6 + BigPokeball_Func1, + BigPokeball_Func2, + BigPokeball_Func3, + BigPokeball_Func4, + BigPokeball_Func5, + BigPokeball_Func6 }; -static const TransitionStateFunc sPhase2_Regice_Funcs[] = +static const TransitionStateFunc sRegice_Funcs[] = { - Phase2_Regi_Func1, - Phase2_Regice_Func2, - Phase2_BigPokeball_Func3, - Phase2_BigPokeball_Func4, - Phase2_BigPokeball_Func5, - Phase2_BigPokeball_Func6 + Regi_Func1, + Regice_Func2, + BigPokeball_Func3, + BigPokeball_Func4, + BigPokeball_Func5, + BigPokeball_Func6 }; -static const TransitionStateFunc sPhase2_Registeel_Funcs[] = +static const TransitionStateFunc sRegisteel_Funcs[] = { - Phase2_Regi_Func1, - Phase2_Registeel_Func2, - Phase2_BigPokeball_Func3, - Phase2_BigPokeball_Func4, - Phase2_BigPokeball_Func5, - Phase2_BigPokeball_Func6 + Regi_Func1, + Registeel_Func2, + BigPokeball_Func3, + BigPokeball_Func4, + BigPokeball_Func5, + BigPokeball_Func6 }; -static const TransitionStateFunc sPhase2_Regirock_Funcs[] = +static const TransitionStateFunc sRegirock_Funcs[] = { - Phase2_Regi_Func1, - Phase2_Regirock_Func2, - Phase2_BigPokeball_Func3, - Phase2_BigPokeball_Func4, - Phase2_BigPokeball_Func5, - Phase2_BigPokeball_Func6 + Regi_Func1, + Regirock_Func2, + BigPokeball_Func3, + BigPokeball_Func4, + BigPokeball_Func5, + BigPokeball_Func6 }; -static const TransitionStateFunc sPhase2_Kyogre_Funcs[] = +static const TransitionStateFunc sKyogre_Funcs[] = { - Phase2_WeatherTrio_Func1, - Phase2_WaitPaletteFade, - Phase2_Kyogre_Func3, - Phase2_Kyogre_Func4, - Phase2_Kyogre_Func5, - Phase2_FramesCountdown, - Phase2_WeatherDuo_Func6, - Phase2_WeatherDuo_Func7 + WeatherTrio_Func1, + WaitPaletteFade, + Kyogre_Func3, + Kyogre_Func4, + Kyogre_Func5, + FramesCountdown, + WeatherDuo_Func6, + WeatherDuo_Func7 }; -static const TransitionStateFunc sPhase2_PokeballsTrail_Funcs[] = +static const TransitionStateFunc sPokeballsTrail_Funcs[] = { - Phase2_PokeballsTrail_Func1, - Phase2_PokeballsTrail_Func2, - Phase2_PokeballsTrail_Func3 + PokeballsTrail_Func1, + PokeballsTrail_Func2, + PokeballsTrail_Func3 }; static const s16 sUnknown_085C8B88[2] = {-16, 256}; static const s16 sUnknown_085C8B8C[5] = {0, 32, 64, 18, 48}; static const s16 sUnknown_085C8B96[2] = {8, -8}; -static const TransitionStateFunc sPhase2_Clockwise_BlackFade_Funcs[] = +static const TransitionStateFunc sClockwise_BlackFade_Funcs[] = { - Phase2_Clockwise_BlackFade_Func1, - Phase2_Clockwise_BlackFade_Func2, - Phase2_Clockwise_BlackFade_Func3, - Phase2_Clockwise_BlackFade_Func4, - Phase2_Clockwise_BlackFade_Func5, - Phase2_Clockwise_BlackFade_Func6, - Phase2_Clockwise_BlackFade_Func7 + Clockwise_BlackFade_Func1, + Clockwise_BlackFade_Func2, + Clockwise_BlackFade_Func3, + Clockwise_BlackFade_Func4, + Clockwise_BlackFade_Func5, + Clockwise_BlackFade_Func6, + Clockwise_BlackFade_Func7 }; -static const TransitionStateFunc sPhase2_Ripple_Funcs[] = +static const TransitionStateFunc sRipple_Funcs[] = { - Phase2_Ripple_Func1, - Phase2_Ripple_Func2 + Ripple_Func1, + Ripple_Func2 }; -static const TransitionStateFunc sPhase2_Wave_Funcs[] = +static const TransitionStateFunc sWave_Funcs[] = { - Phase2_Wave_Func1, - Phase2_Wave_Func2, - Phase2_Wave_Func3 + Wave_Func1, + Wave_Func2, + Wave_Func3 }; -static const TransitionStateFunc sPhase2_Mugshot_Funcs[] = -{ - Phase2_Mugshot_Func1, - Phase2_Mugshot_Func2, - Phase2_Mugshot_Func3, - Phase2_Mugshot_Func4, - Phase2_Mugshot_Func5, - Phase2_Mugshot_Func6, - Phase2_Mugshot_Func7, - Phase2_Mugshot_Func8, - Phase2_Mugshot_Func9, - Phase2_Mugshot_Func10 +static const TransitionStateFunc sMugshot_Funcs[] = +{ + Mugshot_Func1, + Mugshot_Func2, + Mugshot_Func3, + Mugshot_Func4, + Mugshot_Func5, + Mugshot_Func6, + Mugshot_Func7, + Mugshot_Func8, + Mugshot_Func9, + Mugshot_Func10 }; static const u8 sMugshotsTrainerPicIDsTable[MUGSHOTS_COUNT] = @@ -552,44 +551,44 @@ static const TransitionSpriteCallback sTrainerPicSpriteCbs[] = static const s16 sTrainerPicSlideOffsets1[2] = {12, -12}; static const s16 sTrainerPicSlideOffsets2[2] = {-1, 1}; -static const TransitionStateFunc sPhase2_Slice_Funcs[] = +static const TransitionStateFunc sSlice_Funcs[] = { - Phase2_Slice_Func1, - Phase2_Slice_Func2, - Phase2_Slice_Func3 + Slice_Func1, + Slice_Func2, + Slice_Func3 }; -static const TransitionStateFunc sPhase2_ShredSplit_Funcs[] = +static const TransitionStateFunc sShredSplit_Funcs[] = { - Phase2_ShredSplit_Func1, - Phase2_ShredSplit_Func2, - Phase2_ShredSplit_Func3, - Phase2_ShredSplit_Func4 + ShredSplit_Func1, + ShredSplit_Func2, + ShredSplit_Func3, + ShredSplit_Func4 }; static const u8 gUnknown_085C8C64[] = {39, 119}; static const s16 gUnknown_085C8C66[] = {1, -1}; -static const TransitionStateFunc sPhase2_Blackhole1_Funcs[] = +static const TransitionStateFunc sBlackhole1_Funcs[] = { - Phase2_Blackhole_Func1, - Phase2_Blackhole1_Func2, - Phase2_Blackhole1_Func3 + Blackhole_Func1, + Blackhole1_Func2, + Blackhole1_Func3 }; -static const TransitionStateFunc sPhase2_Blackhole2_Funcs[] = +static const TransitionStateFunc sBlackhole2_Funcs[] = { - Phase2_Blackhole_Func1, - Phase2_Blackhole2_Func2 + Blackhole_Func1, + Blackhole2_Func2 }; static const s16 gUnknown_085C8C80[] = {-6, 4}; -static const TransitionStateFunc sPhase2_RectangularSpiral_Funcs[] = +static const TransitionStateFunc sRectangularSpiral_Funcs[] = { - Phase2_RectangularSpiral_Func1, - Phase2_RectangularSpiral_Func2, - Phase2_RectangularSpiral_Func3 + RectangularSpiral_Func1, + RectangularSpiral_Func2, + RectangularSpiral_Func3 }; static const s16 gUnknown_085C8C90[] = {1, 27, 275, -1}; @@ -639,58 +638,58 @@ static const s16 *const *const gUnknown_085C8D38[] = gUnknown_085C8D18 }; -static const TransitionStateFunc sPhase2_Groudon_Funcs[] = +static const TransitionStateFunc sGroudon_Funcs[] = { - Phase2_WeatherTrio_Func1, - Phase2_WaitPaletteFade, - Phase2_Groudon_Func3, - Phase2_Groudon_Func4, - Phase2_Groudon_Func5, - Phase2_FramesCountdown, - Phase2_WeatherDuo_Func6, - Phase2_WeatherDuo_Func7 + WeatherTrio_Func1, + WaitPaletteFade, + Groudon_Func3, + Groudon_Func4, + Groudon_Func5, + FramesCountdown, + WeatherDuo_Func6, + WeatherDuo_Func7 }; -static const TransitionStateFunc sPhase2_Rayquaza_Funcs[] = -{ - Phase2_WeatherTrio_Func1, - Phase2_WaitPaletteFade, - Phase2_Rayquaza_Func3, - Phase2_Rayquaza_Func4, - Phase2_Rayquaza_Func5, - Phase2_Rayquaza_Func6, - Phase2_Rayquaza_Func7, - Phase2_Rayquaza_Func8, - Phase2_Rayquaza_Func9, - Phase2_Blackhole1_Func2, - Phase2_Blackhole1_Func3 +static const TransitionStateFunc sRayquaza_Funcs[] = +{ + WeatherTrio_Func1, + WaitPaletteFade, + Rayquaza_Func3, + Rayquaza_Func4, + Rayquaza_Func5, + Rayquaza_Func6, + Rayquaza_Func7, + Rayquaza_Func8, + Rayquaza_Func9, + Blackhole1_Func2, + Blackhole1_Func3 }; -static const TransitionStateFunc sPhase2_WhiteFade_Funcs[] = +static const TransitionStateFunc sWhiteFade_Funcs[] = { - Phase2_WhiteFade_Func1, - Phase2_WhiteFade_Func2, - Phase2_WhiteFade_Func3, - Phase2_WhiteFade_Func4, - Phase2_WhiteFade_Func5 + WhiteFade_Func1, + WhiteFade_Func2, + WhiteFade_Func3, + WhiteFade_Func4, + WhiteFade_Func5 }; static const s16 sUnknown_085C8DA0[] = {0, 20, 15, 40, 10, 25, 35, 5}; -static const TransitionStateFunc sPhase2_GridSquares_Funcs[] = +static const TransitionStateFunc sGridSquares_Funcs[] = { - Phase2_GridSquares_Func1, - Phase2_GridSquares_Func2, - Phase2_GridSquares_Func3 + GridSquares_Func1, + GridSquares_Func2, + GridSquares_Func3 }; -static const TransitionStateFunc sPhase2_Shards_Funcs[] = +static const TransitionStateFunc sShards_Funcs[] = { - Phase2_Shards_Func1, - Phase2_Shards_Func2, - Phase2_Shards_Func3, - Phase2_Shards_Func4, - Phase2_Shards_Func5 + Shards_Func1, + Shards_Func2, + Shards_Func3, + Shards_Func4, + Shards_Func5 }; static const s16 sUnknown_085C8DD0[][5] = @@ -706,10 +705,10 @@ static const s16 sUnknown_085C8DD0[][5] = static const s16 sUnknown_085C8E16[] = {8, 4, 2, 1, 1, 1, 0}; -static const TransitionStateFunc sPhase1_TransitionAll_Funcs[] = +static const TransitionStateFunc sTransitionIntroFuncs[] = { - Phase1_TransitionAll_Func1, - Phase1_TransitionAll_Func2 + Transition_Intro_1, + Transition_Intro_2 }; static const struct SpriteFrameImage sSpriteImage_Pokeball[] = @@ -850,54 +849,53 @@ static const struct SpritePalette sSpritePalette_UnusedTrainer = {sUnusedTrainer static const u16 sBigPokeball_Tilemap[] = INCBIN_U16("graphics/battle_transitions/big_pokeball_map.bin"); static const u16 sMugshotsTilemap[] = INCBIN_U16("graphics/battle_transitions/elite_four_bg_map.bin"); -static const TransitionStateFunc sPhase2_FrontierLogoWiggle_Funcs[] = +static const TransitionStateFunc sFrontierLogoWiggle_Funcs[] = { - Phase2_FrontierLogoWiggle_Func1, - Phase2_FrontierLogoWiggle_Func2, - Phase2_BigPokeball_Func3, - Phase2_BigPokeball_Func4, - Phase2_BigPokeball_Func5, - Phase2_BigPokeball_Func6 + FrontierLogoWiggle_Func1, + FrontierLogoWiggle_Func2, + BigPokeball_Func3, + BigPokeball_Func4, + BigPokeball_Func5, + BigPokeball_Func6 }; -static const TransitionStateFunc sPhase2_FrontierLogoWave_Funcs[] = +static const TransitionStateFunc sFrontierLogoWave_Funcs[] = { - Phase2_FrontierLogoWave_Func1, - Phase2_FrontierLogoWave_Func2, - Phase2_FrontierLogoWave_Func3, - Phase2_FrontierLogoWave_Func4 + FrontierLogoWave_Func1, + FrontierLogoWave_Func2, + FrontierLogoWave_Func3, + FrontierLogoWave_Func4 }; -static const TransitionStateFunc sPhase2_FrontierSquares_Funcs[] = +static const TransitionStateFunc sFrontierSquares_Funcs[] = { - Phase2_FrontierSquares_Func1, - Phase2_FrontierSquares_Func2, - Phase2_FrontierSquares_Func3, - Phase2_FrontierSquares_End + FrontierSquares_Func1, + FrontierSquares_Func2, + FrontierSquares_Func3, + FrontierSquares_End }; -static const TransitionStateFunc sPhase2_FrontierSquaresSpiral_Funcs[] = +static const TransitionStateFunc sFrontierSquaresSpiral_Funcs[] = { - Phase2_FrontierSquaresSpiral_Func1, - Phase2_FrontierSquaresSpiral_Func2, - Phase2_FrontierSquaresSpiral_Func3, - Phase2_FrontierSquaresSpiral_Func4, - Phase2_FrontierSquares_End + FrontierSquaresSpiral_Func1, + FrontierSquaresSpiral_Func2, + FrontierSquaresSpiral_Func3, + FrontierSquaresSpiral_Func4, + FrontierSquares_End }; -static const TransitionStateFunc sPhase2_FrontierSquaresScroll_Funcs[] = +static const TransitionStateFunc sFrontierSquaresScroll_Funcs[] = { - Phase2_FrontierSquaresScroll_Func1, - Phase2_FrontierSquaresScroll_Func2, - Phase2_FrontierSquaresScroll_Func3, - Phase2_FrontierSquaresScroll_Func4, - Phase2_FrontierSquaresScroll_Func5 + FrontierSquaresScroll_Func1, + FrontierSquaresScroll_Func2, + FrontierSquaresScroll_Func3, + FrontierSquaresScroll_Func4, + FrontierSquaresScroll_Func5 }; static const u8 gUnknown_085C9A30[] = {0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x1b, 0x14, 0x0d, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x07, 0x0e, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x13, 0x0c, 0x0b, 0x0a, 0x09, 0x08, 0x0f, 0x10, 0x11, 0x12}; static const u8 gUnknown_085C9A53[] = {0x00, 0x10, 0x29, 0x16, 0x2c, 0x02, 0x2b, 0x15, 0x2e, 0x1b, 0x09, 0x30, 0x26, 0x05, 0x39, 0x3b, 0x0c, 0x3f, 0x23, 0x1c, 0x0a, 0x35, 0x07, 0x31, 0x27, 0x17, 0x37, 0x01, 0x3e, 0x11, 0x3d, 0x1e, 0x06, 0x22, 0x0f, 0x33, 0x20, 0x3a, 0x0d, 0x2d, 0x25, 0x34, 0x0b, 0x18, 0x3c, 0x13, 0x38, 0x21, 0x1d, 0x32, 0x28, 0x36, 0x0e, 0x03, 0x2f, 0x14, 0x12, 0x19, 0x04, 0x24, 0x1a, 0x2a, 0x1f, 0x08, 0x00}; -// code static void CB2_TestBattleTransition(void) { switch (sTestingTransitionState) @@ -921,7 +919,8 @@ static void CB2_TestBattleTransition(void) UpdatePaletteFade(); } -void TestBattleTransition(u8 transitionId) +// Unused +static void TestBattleTransition(u8 transitionId) { sTestingTransitionId = transitionId; SetMainCallback2(CB2_TestBattleTransition); @@ -947,7 +946,7 @@ void BattleTransition_Start(u8 transitionId) bool8 IsBattleTransitionDone(void) { - u8 taskId = FindTaskIdByFunc(Task_BattleTransitionMain); + u8 taskId = FindTaskIdByFunc(Task_BattleTransition); if (gTasks[taskId].tTransitionDone) { DestroyTask(taskId); @@ -962,23 +961,23 @@ bool8 IsBattleTransitionDone(void) static void LaunchBattleTransitionTask(u8 transitionId) { - u8 taskId = CreateTask(Task_BattleTransitionMain, 2); + u8 taskId = CreateTask(Task_BattleTransition, 2); gTasks[taskId].tTransitionId = transitionId; sTransitionStructPtr = AllocZeroed(sizeof(*sTransitionStructPtr)); } -static void Task_BattleTransitionMain(u8 taskId) +static void Task_BattleTransition(u8 taskId) { - while (sMainTransitionPhases[gTasks[taskId].tState](&gTasks[taskId])); + while (sTaskHandlers[gTasks[taskId].tState](&gTasks[taskId])); } -static bool8 Transition_Phase1(struct Task *task) +static bool8 Transition_StartIntro(struct Task *task) { SetWeatherScreenFadeOut(); CpuCopy32(gPlttBufferFaded, gPlttBufferUnfaded, 0x400); - if (sPhase1_Tasks[task->tTransitionId] != NULL) + if (sTasks_Intro[task->tTransitionId] != NULL) { - CreateTask(sPhase1_Tasks[task->tTransitionId], 4); + CreateTask(sTasks_Intro[task->tTransitionId], 4); task->tState++; return FALSE; } @@ -989,9 +988,9 @@ static bool8 Transition_Phase1(struct Task *task) } } -static bool8 Transition_WaitForPhase1(struct Task *task) +static bool8 Transition_WaitForIntro(struct Task *task) { - if (FindTaskIdByFunc(sPhase1_Tasks[task->tTransitionId]) == TASK_NONE) + if (FindTaskIdByFunc(sTasks_Intro[task->tTransitionId]) == TASK_NONE) { task->tState++; return TRUE; @@ -1002,17 +1001,17 @@ static bool8 Transition_WaitForPhase1(struct Task *task) } } -static bool8 Transition_Phase2(struct Task *task) +static bool8 Transition_StartMain(struct Task *task) { - CreateTask(sPhase2_Tasks[task->tTransitionId], 0); + CreateTask(sTasks_Main[task->tTransitionId], 0); task->tState++; return FALSE; } -static bool8 Transition_WaitForPhase2(struct Task *task) +static bool8 Transition_WaitForMain(struct Task *task) { task->tTransitionDone = FALSE; - if (FindTaskIdByFunc(sPhase2_Tasks[task->tTransitionId]) == TASK_NONE) + if (FindTaskIdByFunc(sTasks_Main[task->tTransitionId]) == TASK_NONE) task->tTransitionDone = TRUE; return FALSE; } @@ -1020,14 +1019,14 @@ static bool8 Transition_WaitForPhase2(struct Task *task) #undef tTransitionId #undef tTransitionDone -static void Phase1Task_TransitionAll(u8 taskId) +static void Task_Intro(u8 taskId) { if (gTasks[taskId].tState == 0) { gTasks[taskId].tState++; - CreatePhase1Task(0, 0, 3, 2, 2); // creates a sub-task for this sub-task + CreateIntroTask(0, 0, 3, 2, 2); } - else if (IsPhase1Done()) + else if (IsIntroTaskDone()) { DestroyTask(taskId); } @@ -1046,12 +1045,12 @@ static void Phase1Task_TransitionAll(u8 taskId) #define tPlayerSpriteId data[14] #define tMugshotId data[15] -static void Phase2Task_Blur(u8 taskId) +static void Task_Blur(u8 taskId) { - while (sPhase2_Blur_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sBlur_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static bool8 Phase2_Blur_Func1(struct Task *task) +static bool8 Blur_Func1(struct Task *task) { SetGpuReg(REG_OFFSET_MOSAIC, 0); SetGpuRegBits(REG_OFFSET_BG1CNT, BGCNT_MOSAIC); @@ -1061,7 +1060,7 @@ static bool8 Phase2_Blur_Func1(struct Task *task) return TRUE; } -static bool8 Phase2_Blur_Func2(struct Task *task) +static bool8 Blur_Func2(struct Task *task) { if (task->tData1 != 0) { @@ -1079,30 +1078,30 @@ static bool8 Phase2_Blur_Func2(struct Task *task) return FALSE; } -static bool8 Phase2_Blur_Func3(struct Task *task) +static bool8 Blur_Func3(struct Task *task) { if (!gPaletteFade.active) { - u8 taskId = FindTaskIdByFunc(Phase2Task_Blur); + u8 taskId = FindTaskIdByFunc(Task_Blur); DestroyTask(taskId); } return FALSE; } -static void Phase2Task_Swirl(u8 taskId) +static void Task_Swirl(u8 taskId) { - while (sPhase2_Swirl_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sSwirl_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static bool8 Phase2_Swirl_Func1(struct Task *task) +static bool8 Swirl_Func1(struct Task *task) { InitTransitionStructVars(); ScanlineEffect_Clear(); BeginNormalPaletteFade(PALETTES_ALL, 4, 0, 0x10, RGB_BLACK); sub_8149F98(gScanlineEffectRegBuffers[1], sTransitionStructPtr->field_14, 0, 2, 0, 160); - SetVBlankCallback(VBlankCB_Phase2_Swirl); - SetHBlankCallback(HBlankCB_Phase2_Swirl); + SetVBlankCallback(VBlankCB_Swirl); + SetHBlankCallback(HBlankCB_Swirl); EnableInterrupts(INTR_FLAG_VBLANK | INTR_FLAG_HBLANK); @@ -1110,7 +1109,7 @@ static bool8 Phase2_Swirl_Func1(struct Task *task) return FALSE; } -static bool8 Phase2_Swirl_Func2(struct Task *task) +static bool8 Swirl_Func2(struct Task *task) { sTransitionStructPtr->VBlank_DMA = FALSE; task->tData1 += 4; @@ -1120,7 +1119,7 @@ static bool8 Phase2_Swirl_Func2(struct Task *task) if (!gPaletteFade.active) { - u8 taskId = FindTaskIdByFunc(Phase2Task_Swirl); + u8 taskId = FindTaskIdByFunc(Task_Swirl); DestroyTask(taskId); } @@ -1128,14 +1127,14 @@ static bool8 Phase2_Swirl_Func2(struct Task *task) return FALSE; } -static void VBlankCB_Phase2_Swirl(void) +static void VBlankCB_Swirl(void) { VBlankCB_BattleTransition(); if (sTransitionStructPtr->VBlank_DMA) DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], 320); } -static void HBlankCB_Phase2_Swirl(void) +static void HBlankCB_Swirl(void) { u16 var = gScanlineEffectRegBuffers[1][REG_VCOUNT]; REG_BG1HOFS = var; @@ -1143,12 +1142,12 @@ static void HBlankCB_Phase2_Swirl(void) REG_BG3HOFS = var; } -static void Phase2Task_Shuffle(u8 taskId) +static void Task_Shuffle(u8 taskId) { - while (sPhase2_Shuffle_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sShuffle_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static bool8 Phase2_Shuffle_Func1(struct Task *task) +static bool8 Shuffle_Func1(struct Task *task) { InitTransitionStructVars(); ScanlineEffect_Clear(); @@ -1156,8 +1155,8 @@ static bool8 Phase2_Shuffle_Func1(struct Task *task) BeginNormalPaletteFade(PALETTES_ALL, 4, 0, 0x10, RGB_BLACK); memset(gScanlineEffectRegBuffers[1], sTransitionStructPtr->field_16, 0x140); - SetVBlankCallback(VBlankCB_Phase2_Shuffle); - SetHBlankCallback(HBlankCB_Phase2_Shuffle); + SetVBlankCallback(VBlankCB_Shuffle); + SetHBlankCallback(HBlankCB_Shuffle); EnableInterrupts(INTR_FLAG_VBLANK | INTR_FLAG_HBLANK); @@ -1165,7 +1164,7 @@ static bool8 Phase2_Shuffle_Func1(struct Task *task) return FALSE; } -static bool8 Phase2_Shuffle_Func2(struct Task *task) +static bool8 Shuffle_Func2(struct Task *task) { u8 i; u16 r3, r4; @@ -1183,20 +1182,20 @@ static bool8 Phase2_Shuffle_Func2(struct Task *task) } if (!gPaletteFade.active) - DestroyTask(FindTaskIdByFunc(Phase2Task_Shuffle)); + DestroyTask(FindTaskIdByFunc(Task_Shuffle)); sTransitionStructPtr->VBlank_DMA++; return FALSE; } -static void VBlankCB_Phase2_Shuffle(void) +static void VBlankCB_Shuffle(void) { VBlankCB_BattleTransition(); if (sTransitionStructPtr->VBlank_DMA) DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], 320); } -static void HBlankCB_Phase2_Shuffle(void) +static void HBlankCB_Shuffle(void) { u16 var = gScanlineEffectRegBuffers[1][REG_VCOUNT]; REG_BG1VOFS = var; @@ -1204,39 +1203,39 @@ static void HBlankCB_Phase2_Shuffle(void) REG_BG3VOFS = var; } -static void Phase2Task_BigPokeball(u8 taskId) +static void Task_BigPokeball(u8 taskId) { - while (sPhase2_BigPokeball_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sBigPokeball_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static void Phase2Task_Aqua(u8 taskId) +static void Task_Aqua(u8 taskId) { - while (sPhase2_Aqua_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sAqua_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static void Phase2Task_Magma(u8 taskId) +static void Task_Magma(u8 taskId) { - while (sPhase2_Magma_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sMagma_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static void Phase2Task_Regice(u8 taskId) +static void Task_Regice(u8 taskId) { - while (sPhase2_Regice_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sRegice_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static void Phase2Task_Registeel(u8 taskId) +static void Task_Registeel(u8 taskId) { - while (sPhase2_Registeel_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sRegisteel_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static void Phase2Task_Regirock(u8 taskId) +static void Task_Regirock(u8 taskId) { - while (sPhase2_Regirock_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sRegirock_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static void Phase2Task_Kyogre(u8 taskId) +static void Task_Kyogre(u8 taskId) { - while (sPhase2_Kyogre_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sKyogre_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } static void sub_814669C(struct Task *task) @@ -1262,10 +1261,10 @@ static void sub_814669C(struct Task *task) gScanlineEffectRegBuffers[1][i] = 240; } - SetVBlankCallback(VBlankCB0_Phase2_BigPokeball); + SetVBlankCallback(VBlankCB0_BigPokeball); } -static bool8 Phase2_Aqua_Func1(struct Task *task) +static bool8 Aqua_Func1(struct Task *task) { u16 *tilemap, *tileset; @@ -1280,7 +1279,7 @@ static bool8 Phase2_Aqua_Func1(struct Task *task) return FALSE; } -static bool8 Phase2_Magma_Func1(struct Task *task) +static bool8 Magma_Func1(struct Task *task) { u16 *tilemap, *tileset; @@ -1295,7 +1294,7 @@ static bool8 Phase2_Magma_Func1(struct Task *task) return FALSE; } -static bool8 Phase2_Regi_Func1(struct Task *task) +static bool8 Regi_Func1(struct Task *task) { u16 *tilemap, *tileset; @@ -1309,7 +1308,7 @@ static bool8 Phase2_Regi_Func1(struct Task *task) return FALSE; } -static bool8 Phase2_BigPokeball_Func1(struct Task *task) +static bool8 BigPokeball_Func1(struct Task *task) { u16 *tilemap, *tileset; @@ -1329,7 +1328,7 @@ static bool8 Phase2_BigPokeball_Func1(struct Task *task) ptr[index] = toStore; \ } -static bool8 Phase2_BigPokeball_Func2(struct Task *task) +static bool8 BigPokeball_Func2(struct Task *task) { s16 i, j; u16 *tilemap, *tileset; @@ -1350,7 +1349,7 @@ static bool8 Phase2_BigPokeball_Func2(struct Task *task) return TRUE; } -static bool8 Phase2_Aqua_Func2(struct Task *task) +static bool8 Aqua_Func2(struct Task *task) { u16 *tilemap, *tileset; @@ -1362,7 +1361,7 @@ static bool8 Phase2_Aqua_Func2(struct Task *task) return FALSE; } -static bool8 Phase2_Magma_Func2(struct Task *task) +static bool8 Magma_Func2(struct Task *task) { u16 *tilemap, *tileset; @@ -1374,7 +1373,7 @@ static bool8 Phase2_Magma_Func2(struct Task *task) return FALSE; } -static bool8 Phase2_Regice_Func2(struct Task *task) +static bool8 Regice_Func2(struct Task *task) { u16 *tilemap, *tileset; @@ -1387,7 +1386,7 @@ static bool8 Phase2_Regice_Func2(struct Task *task) return FALSE; } -static bool8 Phase2_Registeel_Func2(struct Task *task) +static bool8 Registeel_Func2(struct Task *task) { u16 *tilemap, *tileset; @@ -1400,7 +1399,7 @@ static bool8 Phase2_Registeel_Func2(struct Task *task) return FALSE; } -static bool8 Phase2_Regirock_Func2(struct Task *task) +static bool8 Regirock_Func2(struct Task *task) { u16 *tilemap, *tileset; @@ -1413,7 +1412,7 @@ static bool8 Phase2_Regirock_Func2(struct Task *task) return FALSE; } -static bool8 Phase2_Kyogre_Func3(struct Task *task) +static bool8 Kyogre_Func3(struct Task *task) { u16 *tilemap, *tileset; @@ -1426,7 +1425,7 @@ static bool8 Phase2_Kyogre_Func3(struct Task *task) return FALSE; } -static bool8 Phase2_Kyogre_Func4(struct Task *task) +static bool8 Kyogre_Func4(struct Task *task) { if (task->tData1 % 3 == 0) { @@ -1443,7 +1442,7 @@ static bool8 Phase2_Kyogre_Func4(struct Task *task) return FALSE; } -static bool8 Phase2_Kyogre_Func5(struct Task *task) +static bool8 Kyogre_Func5(struct Task *task) { if (task->tData1 % 5 == 0) { @@ -1460,14 +1459,14 @@ static bool8 Phase2_Kyogre_Func5(struct Task *task) return FALSE; } -static bool8 Phase2_WeatherDuo_Func6(struct Task *task) +static bool8 WeatherDuo_Func6(struct Task *task) { BeginNormalPaletteFade(PALETTES_OBJECTS | 0x8000, 1, 0, 0x10, RGB_BLACK); task->tState++; return FALSE; } -static bool8 Phase2_WeatherDuo_Func7(struct Task *task) +static bool8 WeatherDuo_Func7(struct Task *task) { if (!gPaletteFade.active) { @@ -1478,7 +1477,7 @@ static bool8 Phase2_WeatherDuo_Func7(struct Task *task) return FALSE; } -static bool8 Phase2_BigPokeball_Func3(struct Task *task) +static bool8 BigPokeball_Func3(struct Task *task) { sTransitionStructPtr->VBlank_DMA = FALSE; if (task->tData3 == 0 || --task->tData3 == 0) @@ -1498,7 +1497,7 @@ static bool8 Phase2_BigPokeball_Func3(struct Task *task) return FALSE; } -static bool8 Phase2_BigPokeball_Func4(struct Task *task) +static bool8 BigPokeball_Func4(struct Task *task) { sTransitionStructPtr->VBlank_DMA = FALSE; if (task->tData3 == 0 || --task->tData3 == 0) @@ -1518,7 +1517,7 @@ static bool8 Phase2_BigPokeball_Func4(struct Task *task) return FALSE; } -static bool8 Phase2_BigPokeball_Func5(struct Task *task) +static bool8 BigPokeball_Func5(struct Task *task) { sTransitionStructPtr->VBlank_DMA = FALSE; task->tData4 += 8; @@ -1538,28 +1537,28 @@ static bool8 Phase2_BigPokeball_Func5(struct Task *task) return FALSE; } -static bool8 Phase2_FramesCountdown(struct Task *task) +static bool8 FramesCountdown(struct Task *task) { if (--task->tFrames == 0) task->tState++; return FALSE; } -static bool8 Phase2_WeatherTrio_Func1(struct Task *task) +static bool8 WeatherTrio_Func1(struct Task *task) { BeginNormalPaletteFade(PALETTES_BG, 1, 0, 0x10, RGB_BLACK); task->tState++; return FALSE; } -static bool8 Phase2_WaitPaletteFade(struct Task *task) +static bool8 WaitPaletteFade(struct Task *task) { if (!gPaletteFade.active) task->tState++; return FALSE; } -static bool8 Phase2_BigPokeball_Func6(struct Task *task) +static bool8 BigPokeball_Func6(struct Task *task) { sTransitionStructPtr->VBlank_DMA = FALSE; if (task->tData2 < 1024) @@ -1583,7 +1582,7 @@ static bool8 Phase2_BigPokeball_Func6(struct Task *task) if (task->tData3 == 0) { task->tData3++; - SetVBlankCallback(VBlankCB1_Phase2_BigPokeball); + SetVBlankCallback(VBlankCB1_BigPokeball); } sTransitionStructPtr->VBlank_DMA++; @@ -1605,24 +1604,24 @@ static void Transition_BigPokeball_Vblank(void) REG_BLDALPHA = sTransitionStructPtr->BLDALPHA; } -static void VBlankCB0_Phase2_BigPokeball(void) +static void VBlankCB0_BigPokeball(void) { Transition_BigPokeball_Vblank(); DmaSet(0, gScanlineEffectRegBuffers[1], ®_BG0HOFS, 0xA2400001); } -static void VBlankCB1_Phase2_BigPokeball(void) +static void VBlankCB1_BigPokeball(void) { Transition_BigPokeball_Vblank(); DmaSet(0, gScanlineEffectRegBuffers[1], ®_WIN0H, 0xA2400001); } -static void Phase2Task_PokeballsTrail(u8 taskId) +static void Task_PokeballsTrail(u8 taskId) { - while (sPhase2_PokeballsTrail_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sPokeballsTrail_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static bool8 Phase2_PokeballsTrail_Func1(struct Task *task) +static bool8 PokeballsTrail_Func1(struct Task *task) { u16 *tilemap, *tileset; @@ -1635,7 +1634,7 @@ static bool8 Phase2_PokeballsTrail_Func1(struct Task *task) return FALSE; } -static bool8 Phase2_PokeballsTrail_Func2(struct Task *task) +static bool8 PokeballsTrail_Func2(struct Task *task) { s16 i; s16 rand; @@ -1658,12 +1657,12 @@ static bool8 Phase2_PokeballsTrail_Func2(struct Task *task) return FALSE; } -static bool8 Phase2_PokeballsTrail_Func3(struct Task *task) +static bool8 PokeballsTrail_Func3(struct Task *task) { if (!FieldEffectActiveListContains(FLDEFF_POKEBALL)) { FadeScreenBlack(); - DestroyTask(FindTaskIdByFunc(Phase2Task_PokeballsTrail)); + DestroyTask(FindTaskIdByFunc(Task_PokeballsTrail)); } return FALSE; } @@ -1718,12 +1717,12 @@ static void sub_814713C(struct Sprite *sprite) } } -static void Phase2Task_Clockwise_BlackFade(u8 taskId) +static void Task_Clockwise_BlackFade(u8 taskId) { - while (sPhase2_Clockwise_BlackFade_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sClockwise_BlackFade_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static bool8 Phase2_Clockwise_BlackFade_Func1(struct Task *task) +static bool8 Clockwise_BlackFade_Func1(struct Task *task) { u16 i; @@ -1740,14 +1739,14 @@ static bool8 Phase2_Clockwise_BlackFade_Func1(struct Task *task) gScanlineEffectRegBuffers[1][i] = 0xF3F4; } - SetVBlankCallback(VBlankCB_Phase2_Clockwise_BlackFade); + SetVBlankCallback(VBlankCB_Clockwise_BlackFade); sTransitionStructPtr->data[4] = 120; task->tState++; return TRUE; } -static bool8 Phase2_Clockwise_BlackFade_Func2(struct Task *task) +static bool8 Clockwise_BlackFade_Func2(struct Task *task) { sTransitionStructPtr->VBlank_DMA = FALSE; @@ -1768,7 +1767,7 @@ static bool8 Phase2_Clockwise_BlackFade_Func2(struct Task *task) return FALSE; } -static bool8 Phase2_Clockwise_BlackFade_Func3(struct Task *task) +static bool8 Clockwise_BlackFade_Func3(struct Task *task) { s16 r1, r3; vu8 var = 0; @@ -1806,7 +1805,7 @@ static bool8 Phase2_Clockwise_BlackFade_Func3(struct Task *task) return FALSE; } -static bool8 Phase2_Clockwise_BlackFade_Func4(struct Task *task) +static bool8 Clockwise_BlackFade_Func4(struct Task *task) { sTransitionStructPtr->VBlank_DMA = FALSE; @@ -1827,7 +1826,7 @@ static bool8 Phase2_Clockwise_BlackFade_Func4(struct Task *task) return FALSE; } -static bool8 Phase2_Clockwise_BlackFade_Func5(struct Task *task) +static bool8 Clockwise_BlackFade_Func5(struct Task *task) { s16 r1, r2, var4; vu8 var = 0; @@ -1867,7 +1866,7 @@ static bool8 Phase2_Clockwise_BlackFade_Func5(struct Task *task) return FALSE; } -static bool8 Phase2_Clockwise_BlackFade_Func6(struct Task *task) +static bool8 Clockwise_BlackFade_Func6(struct Task *task) { sTransitionStructPtr->VBlank_DMA = FALSE; @@ -1891,15 +1890,15 @@ static bool8 Phase2_Clockwise_BlackFade_Func6(struct Task *task) return FALSE; } -static bool8 Phase2_Clockwise_BlackFade_Func7(struct Task *task) +static bool8 Clockwise_BlackFade_Func7(struct Task *task) { DmaStop(0); FadeScreenBlack(); - DestroyTask(FindTaskIdByFunc(Phase2Task_Clockwise_BlackFade)); + DestroyTask(FindTaskIdByFunc(Task_Clockwise_BlackFade)); return FALSE; } -static void VBlankCB_Phase2_Clockwise_BlackFade(void) +static void VBlankCB_Clockwise_BlackFade(void) { DmaStop(0); VBlankCB_BattleTransition(); @@ -1912,12 +1911,12 @@ static void VBlankCB_Phase2_Clockwise_BlackFade(void) DmaSet(0, gScanlineEffectRegBuffers[1], ®_WIN0H, 0xA2400001); } -static void Phase2Task_Ripple(u8 taskId) +static void Task_Ripple(u8 taskId) { - while (sPhase2_Ripple_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sRipple_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static bool8 Phase2_Ripple_Func1(struct Task *task) +static bool8 Ripple_Func1(struct Task *task) { u8 i; @@ -1929,8 +1928,8 @@ static bool8 Phase2_Ripple_Func1(struct Task *task) gScanlineEffectRegBuffers[1][i] = sTransitionStructPtr->field_16; } - SetVBlankCallback(VBlankCB_Phase2_Ripple); - SetHBlankCallback(HBlankCB_Phase2_Ripple); + SetVBlankCallback(VBlankCB_Ripple); + SetHBlankCallback(HBlankCB_Ripple); EnableInterrupts(INTR_FLAG_HBLANK); @@ -1938,7 +1937,7 @@ static bool8 Phase2_Ripple_Func1(struct Task *task) return TRUE; } -static bool8 Phase2_Ripple_Func2(struct Task *task) +static bool8 Ripple_Func2(struct Task *task) { u8 i; s16 r3; @@ -1966,20 +1965,20 @@ static bool8 Phase2_Ripple_Func2(struct Task *task) } if (task->tData4 != 0 && !gPaletteFade.active) - DestroyTask(FindTaskIdByFunc(Phase2Task_Ripple)); + DestroyTask(FindTaskIdByFunc(Task_Ripple)); sTransitionStructPtr->VBlank_DMA++; return FALSE; } -static void VBlankCB_Phase2_Ripple(void) +static void VBlankCB_Ripple(void) { VBlankCB_BattleTransition(); if (sTransitionStructPtr->VBlank_DMA) DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], 320); } -static void HBlankCB_Phase2_Ripple(void) +static void HBlankCB_Ripple(void) { u16 var = gScanlineEffectRegBuffers[1][REG_VCOUNT]; REG_BG1VOFS = var; @@ -1987,12 +1986,12 @@ static void HBlankCB_Phase2_Ripple(void) REG_BG3VOFS = var; } -static void Phase2Task_Wave(u8 taskId) +static void Task_Wave(u8 taskId) { - while (sPhase2_Wave_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sWave_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static bool8 Phase2_Wave_Func1(struct Task *task) +static bool8 Wave_Func1(struct Task *task) { u8 i; @@ -2009,13 +2008,13 @@ static bool8 Phase2_Wave_Func1(struct Task *task) gScanlineEffectRegBuffers[1][i] = 242; } - SetVBlankCallback(VBlankCB_Phase2_Wave); + SetVBlankCallback(VBlankCB_Wave); task->tState++; return TRUE; } -static bool8 Phase2_Wave_Func2(struct Task *task) +static bool8 Wave_Func2(struct Task *task) { u8 i, r5; u16* toStore; @@ -2045,15 +2044,15 @@ static bool8 Phase2_Wave_Func2(struct Task *task) return FALSE; } -static bool8 Phase2_Wave_Func3(struct Task *task) +static bool8 Wave_Func3(struct Task *task) { DmaStop(0); FadeScreenBlack(); - DestroyTask(FindTaskIdByFunc(Phase2Task_Wave)); + DestroyTask(FindTaskIdByFunc(Task_Wave)); return FALSE; } -static void VBlankCB_Phase2_Wave(void) +static void VBlankCB_Wave(void) { DmaStop(0); VBlankCB_BattleTransition(); @@ -2065,42 +2064,42 @@ static void VBlankCB_Phase2_Wave(void) DmaSet(0, gScanlineEffectRegBuffers[1], ®_WIN0H, 0xA2400001); } -static void Phase2Task_Sidney(u8 taskId) +static void Task_Sidney(u8 taskId) { gTasks[taskId].tMugshotId = MUGSHOT_SIDNEY; - Phase2Task_MugShotTransition(taskId); + Task_MugShotTransition(taskId); } -static void Phase2Task_Phoebe(u8 taskId) +static void Task_Phoebe(u8 taskId) { gTasks[taskId].tMugshotId = MUGSHOT_PHOEBE; - Phase2Task_MugShotTransition(taskId); + Task_MugShotTransition(taskId); } -static void Phase2Task_Glacia(u8 taskId) +static void Task_Glacia(u8 taskId) { gTasks[taskId].tMugshotId = MUGSHOT_GLACIA; - Phase2Task_MugShotTransition(taskId); + Task_MugShotTransition(taskId); } -static void Phase2Task_Drake(u8 taskId) +static void Task_Drake(u8 taskId) { gTasks[taskId].tMugshotId = MUGSHOT_DRAKE; - Phase2Task_MugShotTransition(taskId); + Task_MugShotTransition(taskId); } -static void Phase2Task_Champion(u8 taskId) +static void Task_Champion(u8 taskId) { gTasks[taskId].tMugshotId = MUGSHOT_CHAMPION; - Phase2Task_MugShotTransition(taskId); + Task_MugShotTransition(taskId); } -static void Phase2Task_MugShotTransition(u8 taskId) +static void Task_MugShotTransition(u8 taskId) { - while (sPhase2_Mugshot_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sMugshot_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static bool8 Phase2_Mugshot_Func1(struct Task *task) +static bool8 Mugshot_Func1(struct Task *task) { u8 i; @@ -2120,13 +2119,13 @@ static bool8 Phase2_Mugshot_Func1(struct Task *task) gScanlineEffectRegBuffers[1][i] = 0xF0F1; } - SetVBlankCallback(VBlankCB0_Phase2_Mugshots); + SetVBlankCallback(VBlankCB0_Mugshots); task->tState++; return FALSE; } -static bool8 Phase2_Mugshot_Func2(struct Task *task) +static bool8 Mugshot_Func2(struct Task *task) { s16 i, j; u16 *tilemap, *tileset; @@ -2148,12 +2147,12 @@ static bool8 Phase2_Mugshot_Func2(struct Task *task) EnableInterrupts(INTR_FLAG_HBLANK); - SetHBlankCallback(HBlankCB_Phase2_Mugshots); + SetHBlankCallback(HBlankCB_Mugshots); task->tState++; return FALSE; } -static bool8 Phase2_Mugshot_Func3(struct Task *task) +static bool8 Mugshot_Func3(struct Task *task) { u8 i, r5; u16* toStore; @@ -2201,7 +2200,7 @@ static bool8 Phase2_Mugshot_Func3(struct Task *task) return FALSE; } -static bool8 Phase2_Mugshot_Func4(struct Task *task) +static bool8 Mugshot_Func4(struct Task *task) { u8 i; u16* toStore; @@ -2230,7 +2229,7 @@ static bool8 Phase2_Mugshot_Func4(struct Task *task) return FALSE; } -static bool8 Phase2_Mugshot_Func5(struct Task *task) +static bool8 Mugshot_Func5(struct Task *task) { sTransitionStructPtr->BG0HOFS_1 -= 8; sTransitionStructPtr->BG0HOFS_2 += 8; @@ -2242,7 +2241,7 @@ static bool8 Phase2_Mugshot_Func5(struct Task *task) return FALSE; } -static bool8 Phase2_Mugshot_Func6(struct Task *task) +static bool8 Mugshot_Func6(struct Task *task) { sTransitionStructPtr->BG0HOFS_1 -= 8; sTransitionStructPtr->BG0HOFS_2 += 8; @@ -2259,12 +2258,12 @@ static bool8 Phase2_Mugshot_Func6(struct Task *task) task->tData3 = 0; task->tData4 = 0; sTransitionStructPtr->BLDCNT = BLDCNT_TGT1_ALL | BLDCNT_EFFECT_LIGHTEN; - SetVBlankCallback(VBlankCB1_Phase2_Mugshots); + SetVBlankCallback(VBlankCB1_Mugshots); } return FALSE; } -static bool8 Phase2_Mugshot_Func7(struct Task *task) +static bool8 Mugshot_Func7(struct Task *task) { bool32 r6; @@ -2305,7 +2304,7 @@ static bool8 Phase2_Mugshot_Func7(struct Task *task) return FALSE; } -static bool8 Phase2_Mugshot_Func8(struct Task *task) +static bool8 Mugshot_Func8(struct Task *task) { sTransitionStructPtr->VBlank_DMA = FALSE; BlendPalettes(PALETTES_ALL, 0x10, RGB_WHITE); @@ -2316,7 +2315,7 @@ static bool8 Phase2_Mugshot_Func8(struct Task *task) return TRUE; } -static bool8 Phase2_Mugshot_Func9(struct Task *task) +static bool8 Mugshot_Func9(struct Task *task) { sTransitionStructPtr->VBlank_DMA = FALSE; @@ -2329,7 +2328,7 @@ static bool8 Phase2_Mugshot_Func9(struct Task *task) return FALSE; } -static bool8 Phase2_Mugshot_Func10(struct Task *task) +static bool8 Mugshot_Func10(struct Task *task) { DmaStop(0); FadeScreenBlack(); @@ -2337,7 +2336,7 @@ static bool8 Phase2_Mugshot_Func10(struct Task *task) return FALSE; } -static void VBlankCB0_Phase2_Mugshots(void) +static void VBlankCB0_Mugshots(void) { DmaStop(0); VBlankCB_BattleTransition(); @@ -2350,7 +2349,7 @@ static void VBlankCB0_Phase2_Mugshots(void) DmaSet(0, gScanlineEffectRegBuffers[1], ®_WIN0H, 0xA2400001); } -static void VBlankCB1_Phase2_Mugshots(void) +static void VBlankCB1_Mugshots(void) { DmaStop(0); VBlankCB_BattleTransition(); @@ -2360,7 +2359,7 @@ static void VBlankCB1_Phase2_Mugshots(void) DmaSet(0, gScanlineEffectRegBuffers[1], ®_BLDY, 0xA2400001); } -static void HBlankCB_Phase2_Mugshots(void) +static void HBlankCB_Mugshots(void) { if (REG_VCOUNT < 80) REG_BG0HOFS = sTransitionStructPtr->BG0HOFS_1; @@ -2491,12 +2490,12 @@ static s16 IsTrainerPicSlideDone(s16 spriteId) #undef sDone #undef sSlideTableId -static void Phase2Task_Slice(u8 taskId) +static void Task_Slice(u8 taskId) { - while (sPhase2_Slice_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sSlice_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static bool8 Phase2_Slice_Func1(struct Task *task) +static bool8 Slice_Func1(struct Task *task) { u16 i; @@ -2519,14 +2518,14 @@ static bool8 Phase2_Slice_Func1(struct Task *task) EnableInterrupts(INTR_FLAG_HBLANK); SetGpuRegBits(REG_OFFSET_DISPSTAT, DISPSTAT_HBLANK_INTR); - SetVBlankCallback(VBlankCB_Phase2_Slice); - SetHBlankCallback(HBlankCB_Phase2_Slice); + SetVBlankCallback(VBlankCB_Slice); + SetHBlankCallback(HBlankCB_Slice); task->tState++; return TRUE; } -static bool8 Phase2_Slice_Func2(struct Task *task) +static bool8 Slice_Func2(struct Task *task) { u16 i; @@ -2563,15 +2562,15 @@ static bool8 Phase2_Slice_Func2(struct Task *task) return FALSE; } -static bool8 Phase2_Slice_Func3(struct Task *task) +static bool8 Slice_Func3(struct Task *task) { DmaStop(0); FadeScreenBlack(); - DestroyTask(FindTaskIdByFunc(Phase2Task_Slice)); + DestroyTask(FindTaskIdByFunc(Task_Slice)); return FALSE; } -static void VBlankCB_Phase2_Slice(void) +static void VBlankCB_Slice(void) { DmaStop(0); VBlankCB_BattleTransition(); @@ -2583,7 +2582,7 @@ static void VBlankCB_Phase2_Slice(void) DmaSet(0, &gScanlineEffectRegBuffers[1][160], ®_WIN0H, 0xA2400001); } -static void HBlankCB_Phase2_Slice(void) +static void HBlankCB_Slice(void) { if (REG_VCOUNT < 160) { @@ -2594,12 +2593,12 @@ static void HBlankCB_Phase2_Slice(void) } } -static void Phase2Task_ShredSplit(u8 taskId) +static void Task_ShredSplit(u8 taskId) { - while (sPhase2_ShredSplit_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sShredSplit_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static bool8 Phase2_ShredSplit_Func1(struct Task *task) +static bool8 ShredSplit_Func1(struct Task *task) { u16 i; @@ -2627,14 +2626,14 @@ static bool8 Phase2_ShredSplit_Func1(struct Task *task) EnableInterrupts(INTR_FLAG_HBLANK); - SetVBlankCallback(VBlankCB_Phase2_Slice); - SetHBlankCallback(HBlankCB_Phase2_Slice); + SetVBlankCallback(VBlankCB_Slice); + SetHBlankCallback(HBlankCB_Slice); task->tState++; return TRUE; } -static bool8 Phase2_ShredSplit_Func2(struct Task *task) +static bool8 ShredSplit_Func2(struct Task *task) { u16 i, j, k; u8 arr1[ARRAY_COUNT(gUnknown_085C8C64)]; @@ -2735,7 +2734,7 @@ static bool8 Phase2_ShredSplit_Func2(struct Task *task) // is always false, resulting in the game being stuck in an infinite loop. // It's possible this transition is only partially // done and the second part was left out. -static bool8 Phase2_ShredSplit_Func3(struct Task *task) +static bool8 ShredSplit_Func3(struct Task *task) { u16 i; bool32 done = TRUE; @@ -2753,25 +2752,25 @@ static bool8 Phase2_ShredSplit_Func3(struct Task *task) return FALSE; } -static bool8 Phase2_ShredSplit_Func4(struct Task *task) +static bool8 ShredSplit_Func4(struct Task *task) { DmaStop(0); FadeScreenBlack(); - DestroyTask(FindTaskIdByFunc(Phase2Task_ShredSplit)); + DestroyTask(FindTaskIdByFunc(Task_ShredSplit)); return FALSE; } -static void Phase2Task_Blackhole1(u8 taskId) +static void Task_Blackhole1(u8 taskId) { - while (sPhase2_Blackhole1_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sBlackhole1_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static void Phase2Task_Blackhole2(u8 taskId) +static void Task_Blackhole2(u8 taskId) { - while (sPhase2_Blackhole2_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sBlackhole2_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static bool8 Phase2_Blackhole_Func1(struct Task *task) +static bool8 Blackhole_Func1(struct Task *task) { s32 i; @@ -2788,7 +2787,7 @@ static bool8 Phase2_Blackhole_Func1(struct Task *task) gScanlineEffectRegBuffers[1][i] = 0; } - SetVBlankCallback(VBlankCB1_Phase2_BigPokeball); + SetVBlankCallback(VBlankCB1_BigPokeball); task->tState++; task->tData1 = 1; @@ -2798,7 +2797,7 @@ static bool8 Phase2_Blackhole_Func1(struct Task *task) return FALSE; } -static bool8 Phase2_Blackhole1_Func3(struct Task *task) +static bool8 Blackhole1_Func3(struct Task *task) { if (task->tFuncState == 1) { @@ -2830,7 +2829,7 @@ static bool8 Phase2_Blackhole1_Func3(struct Task *task) return FALSE; } -static bool8 Phase2_Blackhole1_Func2(struct Task *task) +static bool8 Blackhole1_Func2(struct Task *task) { sTransitionStructPtr->VBlank_DMA = FALSE; if (task->tFuncState == 0) @@ -2852,7 +2851,7 @@ static bool8 Phase2_Blackhole1_Func2(struct Task *task) return FALSE; } -static bool8 Phase2_Blackhole2_Func2(struct Task *task) +static bool8 Blackhole2_Func2(struct Task *task) { u16 index; // should be s16 I think s16 amplitude; @@ -2897,12 +2896,12 @@ static bool8 Phase2_Blackhole2_Func2(struct Task *task) return FALSE; } -static void Phase2Task_RectangularSpiral(u8 taskId) +static void Task_RectangularSpiral(u8 taskId) { - while (sPhase2_RectangularSpiral_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sRectangularSpiral_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static bool8 Phase2_RectangularSpiral_Func1(struct Task *task) +static bool8 RectangularSpiral_Func1(struct Task *task) { u16 *tilemap, *tileset; @@ -2942,7 +2941,7 @@ static bool8 Phase2_RectangularSpiral_Func1(struct Task *task) return FALSE; } -static bool8 Phase2_RectangularSpiral_Func2(struct Task *task) +static bool8 RectangularSpiral_Func2(struct Task *task) { u16 *tilemap, *tileset; u8 i; @@ -2978,7 +2977,7 @@ static bool8 Phase2_RectangularSpiral_Func2(struct Task *task) return FALSE; } -static bool8 Phase2_RectangularSpiral_Func3(struct Task *task) +static bool8 RectangularSpiral_Func3(struct Task *task) { DmaStop(0); FadeScreenBlack(); @@ -3049,12 +3048,12 @@ static bool16 sub_8149048(const s16 * const *arg0, struct StructRectangularSpira return TRUE; } -static void Phase2Task_Groudon(u8 taskId) +static void Task_Groudon(u8 taskId) { - while (sPhase2_Groudon_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sGroudon_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static bool8 Phase2_Groudon_Func3(struct Task *task) +static bool8 Groudon_Func3(struct Task *task) { u16 *tilemap, *tileset; @@ -3068,7 +3067,7 @@ static bool8 Phase2_Groudon_Func3(struct Task *task) return FALSE; } -static bool8 Phase2_Groudon_Func4(struct Task *task) +static bool8 Groudon_Func4(struct Task *task) { if (task->tData1 % 3 == 0) { @@ -3084,7 +3083,7 @@ static bool8 Phase2_Groudon_Func4(struct Task *task) return FALSE; } -static bool8 Phase2_Groudon_Func5(struct Task *task) +static bool8 Groudon_Func5(struct Task *task) { if (task->tData1 % 5 == 0) { @@ -3101,12 +3100,12 @@ static bool8 Phase2_Groudon_Func5(struct Task *task) return FALSE; } -static void Phase2Task_Rayquaza(u8 taskId) +static void Task_Rayquaza(u8 taskId) { - while (sPhase2_Rayquaza_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sRayquaza_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static bool8 Phase2_Rayquaza_Func3(struct Task *task) +static bool8 Rayquaza_Func3(struct Task *task) { u16 *tilemap, *tileset; u16 i; @@ -3129,11 +3128,11 @@ static bool8 Phase2_Rayquaza_Func3(struct Task *task) gScanlineEffectRegBuffers[1][i] = 0x100; } - SetVBlankCallback(VBlankCB_Phase2_Rayquaza); + SetVBlankCallback(VBlankCB_Rayquaza); return FALSE; } -static bool8 Phase2_Rayquaza_Func4(struct Task *task) +static bool8 Rayquaza_Func4(struct Task *task) { u16 *tilemap, *tileset; @@ -3143,7 +3142,7 @@ static bool8 Phase2_Rayquaza_Func4(struct Task *task) return FALSE; } -static bool8 Phase2_Rayquaza_Func5(struct Task *task) +static bool8 Rayquaza_Func5(struct Task *task) { if ((task->tData1 % 4) == 0) { @@ -3160,7 +3159,7 @@ static bool8 Phase2_Rayquaza_Func5(struct Task *task) return FALSE; } -static bool8 Phase2_Rayquaza_Func6(struct Task *task) +static bool8 Rayquaza_Func6(struct Task *task) { if (++task->tData1 > 20) { @@ -3172,7 +3171,7 @@ static bool8 Phase2_Rayquaza_Func6(struct Task *task) return FALSE; } -static bool8 Phase2_Rayquaza_Func7(struct Task *task) +static bool8 Rayquaza_Func7(struct Task *task) { if (!gPaletteFade.active) { @@ -3183,7 +3182,7 @@ static bool8 Phase2_Rayquaza_Func7(struct Task *task) return FALSE; } -static bool8 Phase2_Rayquaza_Func8(struct Task *task) +static bool8 Rayquaza_Func8(struct Task *task) { BlendPalettes(PALETTES_BG & ~(0x8000), 8, 0); BlendPalettes(PALETTES_OBJECTS | 0x8000, 0, 0); @@ -3192,7 +3191,7 @@ static bool8 Phase2_Rayquaza_Func8(struct Task *task) return FALSE; } -static bool8 Phase2_Rayquaza_Func9(struct Task *task) +static bool8 Rayquaza_Func9(struct Task *task) { if ((task->tData1 % 3) == 0) { @@ -3214,7 +3213,7 @@ static bool8 Phase2_Rayquaza_Func9(struct Task *task) gScanlineEffectRegBuffers[1][i] = 0; } - SetVBlankCallback(VBlankCB1_Phase2_BigPokeball); + SetVBlankCallback(VBlankCB1_BigPokeball); task->tState++; task->tData2 = 0x100; task->tFuncState = 0; @@ -3224,7 +3223,7 @@ static bool8 Phase2_Rayquaza_Func9(struct Task *task) return FALSE; } -static void VBlankCB_Phase2_Rayquaza(void) +static void VBlankCB_Rayquaza(void) { void *dmaSrc; @@ -3241,12 +3240,12 @@ static void VBlankCB_Phase2_Rayquaza(void) DmaSet(0, dmaSrc, ®_BG0VOFS, 0xA2400001); } -static void Phase2Task_WhiteFade(u8 taskId) +static void Task_WhiteFade(u8 taskId) { - while (sPhase2_WhiteFade_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sWhiteFade_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static bool8 Phase2_WhiteFade_Func1(struct Task *task) +static bool8 WhiteFade_Func1(struct Task *task) { u16 i; @@ -3266,14 +3265,14 @@ static bool8 Phase2_WhiteFade_Func1(struct Task *task) } EnableInterrupts(INTR_FLAG_HBLANK); - SetHBlankCallback(HBlankCB_Phase2_WhiteFade); - SetVBlankCallback(VBlankCB0_Phase2_WhiteFade); + SetHBlankCallback(HBlankCB_WhiteFade); + SetVBlankCallback(VBlankCB0_WhiteFade); task->tState++; return FALSE; } -static bool8 Phase2_WhiteFade_Func2(struct Task *task) +static bool8 WhiteFade_Func2(struct Task *task) { s16 i, posY; s16 arr1[ARRAY_COUNT(sUnknown_085C8DA0)]; @@ -3293,7 +3292,7 @@ static bool8 Phase2_WhiteFade_Func2(struct Task *task) return FALSE; } -static bool8 Phase2_WhiteFade_Func3(struct Task *task) +static bool8 WhiteFade_Func3(struct Task *task) { sTransitionStructPtr->VBlank_DMA = 0; if (sTransitionStructPtr->field_20 > 7) @@ -3304,7 +3303,7 @@ static bool8 Phase2_WhiteFade_Func3(struct Task *task) return FALSE; } -static bool8 Phase2_WhiteFade_Func4(struct Task *task) +static bool8 WhiteFade_Func4(struct Task *task) { sTransitionStructPtr->VBlank_DMA = 0; @@ -3317,23 +3316,23 @@ static bool8 Phase2_WhiteFade_Func4(struct Task *task) sTransitionStructPtr->BLDCNT = 0xFF; sTransitionStructPtr->WININ = WININ_WIN0_ALL; - SetVBlankCallback(VBlankCB1_Phase2_WhiteFade); + SetVBlankCallback(VBlankCB1_WhiteFade); task->tState++; return FALSE; } -static bool8 Phase2_WhiteFade_Func5(struct Task *task) +static bool8 WhiteFade_Func5(struct Task *task) { if (++sTransitionStructPtr->BLDY > 16) { FadeScreenBlack(); - DestroyTask(FindTaskIdByFunc(Phase2Task_WhiteFade)); + DestroyTask(FindTaskIdByFunc(Task_WhiteFade)); } return FALSE; } -static void VBlankCB0_Phase2_WhiteFade(void) +static void VBlankCB0_WhiteFade(void) { DmaStop(0); VBlankCB_BattleTransition(); @@ -3346,7 +3345,7 @@ static void VBlankCB0_Phase2_WhiteFade(void) DmaSet(0, &gScanlineEffectRegBuffers[1][160], ®_WIN0H, 0xA2400001); } -static void VBlankCB1_Phase2_WhiteFade(void) +static void VBlankCB1_WhiteFade(void) { VBlankCB_BattleTransition(); REG_BLDY = sTransitionStructPtr->BLDY; @@ -3357,7 +3356,7 @@ static void VBlankCB1_Phase2_WhiteFade(void) REG_WIN0V = sTransitionStructPtr->WIN0V; } -static void HBlankCB_Phase2_WhiteFade(void) +static void HBlankCB_WhiteFade(void) { REG_BLDY = gScanlineEffectRegBuffers[1][REG_VCOUNT]; } @@ -3405,12 +3404,12 @@ static void sub_8149864(struct Sprite *sprite) } } -static void Phase2Task_GridSquares(u8 taskId) +static void Task_GridSquares(u8 taskId) { - while (sPhase2_GridSquares_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sGridSquares_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static bool8 Phase2_GridSquares_Func1(struct Task *task) +static bool8 GridSquares_Func1(struct Task *task) { u16 *tilemap, *tileset; @@ -3423,7 +3422,7 @@ static bool8 Phase2_GridSquares_Func1(struct Task *task) return FALSE; } -static bool8 Phase2_GridSquares_Func2(struct Task *task) +static bool8 GridSquares_Func2(struct Task *task) { u16* tileset; @@ -3444,22 +3443,22 @@ static bool8 Phase2_GridSquares_Func2(struct Task *task) return FALSE; } -static bool8 Phase2_GridSquares_Func3(struct Task *task) +static bool8 GridSquares_Func3(struct Task *task) { if (--task->tData1 == 0) { FadeScreenBlack(); - DestroyTask(FindTaskIdByFunc(Phase2Task_GridSquares)); + DestroyTask(FindTaskIdByFunc(Task_GridSquares)); } return FALSE; } -static void Phase2Task_Shards(u8 taskId) +static void Task_Shards(u8 taskId) { - while (sPhase2_Shards_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sShards_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static bool8 Phase2_Shards_Func1(struct Task *task) +static bool8 Shards_Func1(struct Task *task) { u16 i; @@ -3476,13 +3475,13 @@ static bool8 Phase2_Shards_Func1(struct Task *task) } CpuSet(gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], 0xA0); - SetVBlankCallback(VBlankCB_Phase2_Shards); + SetVBlankCallback(VBlankCB_Shards); task->tState++; return TRUE; } -static bool8 Phase2_Shards_Func2(struct Task *task) +static bool8 Shards_Func2(struct Task *task) { sub_814A1AC(sTransitionStructPtr->data, sUnknown_085C8DD0[task->tData1][0], @@ -3495,7 +3494,7 @@ static bool8 Phase2_Shards_Func2(struct Task *task) return TRUE; } -static bool8 Phase2_Shards_Func3(struct Task *task) +static bool8 Shards_Func3(struct Task *task) { s16 i; bool8 nextFunc; @@ -3534,7 +3533,7 @@ static bool8 Phase2_Shards_Func3(struct Task *task) return FALSE; } -static bool8 Phase2_Shards_Func4(struct Task *task) +static bool8 Shards_Func4(struct Task *task) { if (++task->tData1 < 7) { @@ -3546,12 +3545,12 @@ static bool8 Phase2_Shards_Func4(struct Task *task) { DmaStop(0); FadeScreenBlack(); - DestroyTask(FindTaskIdByFunc(Phase2Task_Shards)); + DestroyTask(FindTaskIdByFunc(Task_Shards)); return FALSE; } } -static bool8 Phase2_Shards_Func5(struct Task *task) +static bool8 Shards_Func5(struct Task *task) { if (--task->tData3 == 0) { @@ -3562,7 +3561,7 @@ static bool8 Phase2_Shards_Func5(struct Task *task) return FALSE; } -static void VBlankCB_Phase2_Shards(void) +static void VBlankCB_Shards(void) { DmaStop(0); VBlankCB_BattleTransition(); @@ -3597,9 +3596,9 @@ static void VBlankCB_Phase2_Shards(void) #define tData6 data[6] #define tData7 data[7] -static void CreatePhase1Task(s16 a0, s16 a1, s16 a2, s16 a3, s16 a4) +static void CreateIntroTask(s16 a0, s16 a1, s16 a2, s16 a3, s16 a4) { - u8 taskId = CreateTask(TransitionPhase1_Task_RunFuncs, 3); + u8 taskId = CreateTask(Task_BattleTransition_Intro, 3); gTasks[taskId].tData1 = a0; gTasks[taskId].tData2 = a1; gTasks[taskId].tData3 = a2; @@ -3608,20 +3607,20 @@ static void CreatePhase1Task(s16 a0, s16 a1, s16 a2, s16 a3, s16 a4) gTasks[taskId].tData6 = a0; } -static bool8 IsPhase1Done(void) +static bool8 IsIntroTaskDone(void) { - if (FindTaskIdByFunc(TransitionPhase1_Task_RunFuncs) == TASK_NONE) + if (FindTaskIdByFunc(Task_BattleTransition_Intro) == TASK_NONE) return TRUE; else return FALSE; } -void TransitionPhase1_Task_RunFuncs(u8 taskId) +void Task_BattleTransition_Intro(u8 taskId) { - while (sPhase1_TransitionAll_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sTransitionIntroFuncs[gTasks[taskId].tState](&gTasks[taskId])); } -static bool8 Phase1_TransitionAll_Func1(struct Task *task) +static bool8 Transition_Intro_1(struct Task *task) { if (task->tData6 == 0 || --task->tData6 == 0) { @@ -3639,7 +3638,7 @@ static bool8 Phase1_TransitionAll_Func1(struct Task *task) return FALSE; } -static bool8 Phase1_TransitionAll_Func2(struct Task *task) +static bool8 Transition_Intro_2(struct Task *task) { if (task->tData6 == 0 || --task->tData6 == 0) { @@ -3652,7 +3651,7 @@ static bool8 Phase1_TransitionAll_Func2(struct Task *task) if (task->tData7 == 0) { if (--task->tData3 == 0) - DestroyTask(FindTaskIdByFunc(TransitionPhase1_Task_RunFuncs)); + DestroyTask(FindTaskIdByFunc(Task_BattleTransition_Intro)); else { task->tData6 = task->tData1; @@ -3845,7 +3844,7 @@ static bool8 sub_814A228(s16 *data, bool8 a1, bool8 a2) #define tData6 data[6] #define tData7 data[7] -static bool8 Phase2_FrontierLogoWiggle_Func1(struct Task *task) +static bool8 FrontierLogoWiggle_Func1(struct Task *task) { u16 *tilemap, *tileset; @@ -3859,7 +3858,7 @@ static bool8 Phase2_FrontierLogoWiggle_Func1(struct Task *task) return FALSE; } -static bool8 Phase2_FrontierLogoWiggle_Func2(struct Task *task) +static bool8 FrontierLogoWiggle_Func2(struct Task *task) { u16 *tilemap, *tileset; @@ -3871,17 +3870,17 @@ static bool8 Phase2_FrontierLogoWiggle_Func2(struct Task *task) return TRUE; } -static void Phase2Task_FrontierLogoWiggle(u8 taskId) +static void Task_FrontierLogoWiggle(u8 taskId) { - while (sPhase2_FrontierLogoWiggle_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sFrontierLogoWiggle_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static void Phase2Task_FrontierLogoWave(u8 taskId) +static void Task_FrontierLogoWave(u8 taskId) { - while (sPhase2_FrontierLogoWave_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sFrontierLogoWave_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static bool8 Phase2_FrontierLogoWave_Func1(struct Task *task) +static bool8 FrontierLogoWave_Func1(struct Task *task) { u16 *tilemap, *tileset; @@ -3907,7 +3906,7 @@ static bool8 Phase2_FrontierLogoWave_Func1(struct Task *task) return FALSE; } -static bool8 Phase2_FrontierLogoWave_Func2(struct Task *task) +static bool8 FrontierLogoWave_Func2(struct Task *task) { u16 *tilemap, *tileset; @@ -3918,7 +3917,7 @@ static bool8 Phase2_FrontierLogoWave_Func2(struct Task *task) return TRUE; } -static bool8 Phase2_FrontierLogoWave_Func3(struct Task *task) +static bool8 FrontierLogoWave_Func3(struct Task *task) { u8 i; @@ -3927,15 +3926,15 @@ static bool8 Phase2_FrontierLogoWave_Func3(struct Task *task) gScanlineEffectRegBuffers[1][i] = sTransitionStructPtr->field_16; } - SetVBlankCallback(VBlankCB_Phase2_30); - SetHBlankCallback(HBlankCB_Phase2_30); + SetVBlankCallback(VBlankCB_30); + SetHBlankCallback(HBlankCB_30); EnableInterrupts(INTR_FLAG_HBLANK); task->tState++; return TRUE; } -static bool8 Phase2_FrontierLogoWave_Func4(struct Task *task) +static bool8 FrontierLogoWave_Func4(struct Task *task) { u8 i; u16 var6, amplitude, var8; @@ -3979,14 +3978,14 @@ static bool8 Phase2_FrontierLogoWave_Func4(struct Task *task) } if (task->tData4 != 0 && !gPaletteFade.active) - DestroyTask(FindTaskIdByFunc(Phase2Task_FrontierLogoWave)); + DestroyTask(FindTaskIdByFunc(Task_FrontierLogoWave)); task->tData7 -= 17; sTransitionStructPtr->VBlank_DMA++; return FALSE; } -static void VBlankCB_Phase2_30(void) +static void VBlankCB_30(void) { VBlankCB_BattleTransition(); REG_BLDCNT = sTransitionStructPtr->BLDCNT; @@ -3996,28 +3995,28 @@ static void VBlankCB_Phase2_30(void) DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], 320); } -static void HBlankCB_Phase2_30(void) +static void HBlankCB_30(void) { u16 var = gScanlineEffectRegBuffers[1][REG_VCOUNT]; REG_BG0VOFS = var; } -static void Phase2Task_FrontierSquares(u8 taskId) +static void Task_FrontierSquares(u8 taskId) { - while (sPhase2_FrontierSquares_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sFrontierSquares_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static void Phase2Task_FrontierSquaresSpiral(u8 taskId) +static void Task_FrontierSquaresSpiral(u8 taskId) { - while (sPhase2_FrontierSquaresSpiral_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sFrontierSquaresSpiral_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static void Phase2Task_FrontierSquaresScroll(u8 taskId) +static void Task_FrontierSquaresScroll(u8 taskId) { - while (sPhase2_FrontierSquaresScroll_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sFrontierSquaresScroll_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static bool8 Phase2_FrontierSquares_Func1(struct Task *task) +static bool8 FrontierSquares_Func1(struct Task *task) { u16 *tilemap, *tileset; @@ -4039,7 +4038,7 @@ static bool8 Phase2_FrontierSquares_Func1(struct Task *task) return FALSE; } -static bool8 Phase2_FrontierSquares_Func2(struct Task *task) +static bool8 FrontierSquares_Func2(struct Task *task) { CopyRectToBgTilemapBufferRect(0, sFrontierSquares_Tilemap, 0, 0, 4, 4, task->tData2, task->tData3, 4, 4, 0xF, 0, 0); CopyBgTilemapBufferToVram(0); @@ -4057,7 +4056,7 @@ static bool8 Phase2_FrontierSquares_Func2(struct Task *task) return FALSE; } -static bool8 Phase2_FrontierSquares_Func3(struct Task *task) +static bool8 FrontierSquares_Func3(struct Task *task) { u8 i; u16 *tilemap, *tileset; @@ -4098,7 +4097,7 @@ static bool8 Phase2_FrontierSquares_Func3(struct Task *task) return FALSE; } -static bool8 Phase2_FrontierSquaresSpiral_Func1(struct Task *task) +static bool8 FrontierSquaresSpiral_Func1(struct Task *task) { u16 *tilemap, *tileset; @@ -4120,7 +4119,7 @@ static bool8 Phase2_FrontierSquaresSpiral_Func1(struct Task *task) return FALSE; } -static bool8 Phase2_FrontierSquaresSpiral_Func2(struct Task *task) +static bool8 FrontierSquaresSpiral_Func2(struct Task *task) { u8 var = gUnknown_085C9A30[task->tData2]; u8 varMod = var % 7; @@ -4133,7 +4132,7 @@ static bool8 Phase2_FrontierSquaresSpiral_Func2(struct Task *task) return FALSE; } -static bool8 Phase2_FrontierSquaresSpiral_Func3(struct Task *task) +static bool8 FrontierSquaresSpiral_Func3(struct Task *task) { BlendPalette(0xE0, 0x10, 3, 0); BlendPalettes(PALETTES_ALL & ~(0x8000 | 0x4000), 0x10, 0); @@ -4145,7 +4144,7 @@ static bool8 Phase2_FrontierSquaresSpiral_Func3(struct Task *task) return FALSE; } -static bool8 Phase2_FrontierSquaresSpiral_Func4(struct Task *task) +static bool8 FrontierSquaresSpiral_Func4(struct Task *task) { if ((task->tData3 ^= 1)) { @@ -4188,7 +4187,7 @@ static bool8 Phase2_FrontierSquaresSpiral_Func4(struct Task *task) return FALSE; } -static bool8 Phase2_FrontierSquares_End(struct Task *task) +static bool8 FrontierSquares_End(struct Task *task) { FillBgTilemapBufferRect_Palette0(0, 1, 0, 0, 0x20, 0x20); CopyBgTilemapBufferToVram(0); @@ -4213,7 +4212,7 @@ static void sub_814ABE4(u8 taskId) } } -static bool8 Phase2_FrontierSquaresScroll_Func1(struct Task *task) +static bool8 FrontierSquaresScroll_Func1(struct Task *task) { u8 taskId = 0; u16 *tilemap, *tileset; @@ -4255,7 +4254,7 @@ static bool8 Phase2_FrontierSquaresScroll_Func1(struct Task *task) return FALSE; } -static bool8 Phase2_FrontierSquaresScroll_Func2(struct Task *task) +static bool8 FrontierSquaresScroll_Func2(struct Task *task) { u8 var = gUnknown_085C9A53[task->tData2]; u8 varDiv = var / 8; @@ -4282,7 +4281,7 @@ static bool8 Phase2_FrontierSquaresScroll_Func2(struct Task *task) return 0; } -static bool8 Phase2_FrontierSquaresScroll_Func3(struct Task *task) +static bool8 FrontierSquaresScroll_Func3(struct Task *task) { BlendPalettes(PALETTES_ALL & ~(0x8000), 0x10, 0); @@ -4292,7 +4291,7 @@ static bool8 Phase2_FrontierSquaresScroll_Func3(struct Task *task) return FALSE; } -static bool8 Phase2_FrontierSquaresScroll_Func4(struct Task *task) +static bool8 FrontierSquaresScroll_Func4(struct Task *task) { u8 var = gUnknown_085C9A53[task->tData2]; u8 varDiv = var / 8; @@ -4314,7 +4313,7 @@ static bool8 Phase2_FrontierSquaresScroll_Func4(struct Task *task) #undef tSub32_Y_delta #undef tSub32_Bool -static bool8 Phase2_FrontierSquaresScroll_Func5(struct Task *task) +static bool8 FrontierSquaresScroll_Func5(struct Task *task) { gBattle_BG0_X = 0; gBattle_BG0_Y = 0; -- cgit v1.2.3 From 1056209d8e62770bac18cb6a4bc34ce96db30f12 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Mon, 25 Oct 2021 10:42:08 -0400 Subject: Start battle_transition documenting --- src/battle_transition.c | 2327 ++++++++++++++++++++++++----------------------- 1 file changed, 1180 insertions(+), 1147 deletions(-) (limited to 'src/battle_transition.c') diff --git a/src/battle_transition.c b/src/battle_transition.c index 983a50217..72edf92d5 100644 --- a/src/battle_transition.c +++ b/src/battle_transition.c @@ -25,6 +25,16 @@ #include "constants/trainers.h" #include "constants/rgb.h" +#define PALTAG_UNUSED_MUGSHOT 0x100A + +#define B_TRANS_DMA_FLAGS (1 | ((DMA_SRC_INC | DMA_DEST_FIXED | DMA_REPEAT | DMA_16BIT | DMA_START_HBLANK | DMA_ENABLE) << 16)) + +#define SET_TILEMAP_TILE(ptr, posY, posX, toStore) \ +{ \ + u32 index = (posY) * 32 + posX; \ + ptr[index] = toStore; \ +} + struct TransitionData { vu8 VBlank_DMA; @@ -32,19 +42,19 @@ struct TransitionData u16 WINOUT; u16 WIN0H; u16 WIN0V; - u16 field_A; // unused - u16 field_C; // unused + u16 unused1; + u16 unused2; u16 BLDCNT; u16 BLDALPHA; u16 BLDY; - s16 field_14; - s16 field_16; - s16 BG0HOFS_1; - s16 BG0HOFS_2; + s16 cameraX; + s16 cameraY; + s16 BG0HOFS_Lower; + s16 BG0HOFS_Upper; s16 BG0VOFS; // used but not set - s16 field_1E; // unused + s16 unused3; s16 field_20; - s16 field_22; // unused + s16 unused4; s16 data[11]; }; @@ -107,13 +117,13 @@ static void VBlankCB_Swirl(void); static void HBlankCB_Swirl(void); static void VBlankCB_Shuffle(void); static void HBlankCB_Shuffle(void); -static void VBlankCB0_BigPokeball(void); +static void VBlankCB_PatternWeave(void); static void VBlankCB1_BigPokeball(void); static void VBlankCB_Clockwise_BlackFade(void); static void VBlankCB_Ripple(void); static void HBlankCB_Ripple(void); -static void VBlankCB_30(void); -static void HBlankCB_30(void); +static void VBlankCB_FrontierLogoWave(void); +static void HBlankCB_FrontierLogoWave(void); static void VBlankCB_Wave(void); static void VBlankCB_Slice(void); static void HBlankCB_Slice(void); @@ -122,84 +132,84 @@ static void VBlankCB1_WhiteFade(void); static void HBlankCB_WhiteFade(void); static void VBlankCB_Shards(void); static void VBlankCB_Rayquaza(void); -static bool8 Blur_Func1(struct Task *task); -static bool8 Blur_Func2(struct Task *task); -static bool8 Blur_Func3(struct Task *task); -static bool8 Swirl_Func1(struct Task *task); -static bool8 Swirl_Func2(struct Task *task); -static bool8 Shuffle_Func1(struct Task *task); -static bool8 Shuffle_Func2(struct Task *task); -static bool8 Aqua_Func1(struct Task *task); -static bool8 Aqua_Func2(struct Task *task); -static bool8 Magma_Func1(struct Task *task); -static bool8 Magma_Func2(struct Task *task); +static bool8 Blur_Init(struct Task *task); +static bool8 Blur_Main(struct Task *task); +static bool8 Blur_End(struct Task *task); +static bool8 Swirl_Init(struct Task *task); +static bool8 Swirl_End(struct Task *task); +static bool8 Shuffle_Init(struct Task *task); +static bool8 Shuffle_End(struct Task *task); +static bool8 Aqua_Init(struct Task *task); +static bool8 Aqua_SetGfx(struct Task *task); +static bool8 Magma_Init(struct Task *task); +static bool8 Magma_SetGfx(struct Task *task); static bool8 FramesCountdown(struct Task *task); -static bool8 Regi_Func1(struct Task *task); -static bool8 Regice_Func2(struct Task *task); -static bool8 Registeel_Func2(struct Task *task); -static bool8 Regirock_Func2(struct Task *task); -static bool8 WeatherTrio_Func1(struct Task *task); -static bool8 WaitPaletteFade(struct Task *task); -static bool8 Kyogre_Func3(struct Task *task); -static bool8 Kyogre_Func4(struct Task *task); -static bool8 Kyogre_Func5(struct Task *task); -static bool8 Groudon_Func3(struct Task *task); -static bool8 Groudon_Func4(struct Task *task); -static bool8 Groudon_Func5(struct Task *task); -static bool8 WeatherDuo_Func6(struct Task *task); -static bool8 WeatherDuo_Func7(struct Task *task); -static bool8 BigPokeball_Func1(struct Task *task); -static bool8 BigPokeball_Func2(struct Task *task); -static bool8 BigPokeball_Func3(struct Task *task); -static bool8 BigPokeball_Func4(struct Task *task); -static bool8 BigPokeball_Func5(struct Task *task); -static bool8 BigPokeball_Func6(struct Task *task); -static bool8 PokeballsTrail_Func1(struct Task *task); -static bool8 PokeballsTrail_Func2(struct Task *task); -static bool8 PokeballsTrail_Func3(struct Task *task); -static bool8 Clockwise_BlackFade_Func1(struct Task *task); +static bool8 Regi_Init(struct Task *task); +static bool8 Regice_SetGfx(struct Task *task); +static bool8 Registeel_SetGfx(struct Task *task); +static bool8 Regirock_SetGfx(struct Task *task); +static bool8 WeatherTrio_BgFadeBlack(struct Task *task); +static bool8 WeatherTrio_WaitFade(struct Task *task); +static bool8 Kyogre_Init(struct Task *task); +static bool8 Kyogre_PalettePulsate(struct Task *task); +static bool8 Kyogre_PaletteBrighten(struct Task *task); +static bool8 Groudon_Init(struct Task *task); +static bool8 Groudon_PalettePulsate(struct Task *task); +static bool8 Groudon_PaletteBrighten(struct Task *task); +static bool8 WeatherDuo_FadeOut(struct Task *task); +static bool8 WeatherDuo_End(struct Task *task); +static bool8 BigPokeball_Init(struct Task *task); +static bool8 BigPokeball_SetGfx(struct Task *task); +static bool8 PatternWeave_1(struct Task *task); +static bool8 PatternWeave_2(struct Task *task); +static bool8 PatternWeave_3(struct Task *task); +static bool8 PatternWeave_End(struct Task *task); +static bool8 PokeballsTrail_Init(struct Task *task); +static bool8 PokeballsTrail_Main(struct Task *task); +static bool8 PokeballsTrail_End(struct Task *task); +static bool8 Clockwise_BlackFade_Init(struct Task *task); static bool8 Clockwise_BlackFade_Func2(struct Task *task); static bool8 Clockwise_BlackFade_Func3(struct Task *task); static bool8 Clockwise_BlackFade_Func4(struct Task *task); static bool8 Clockwise_BlackFade_Func5(struct Task *task); static bool8 Clockwise_BlackFade_Func6(struct Task *task); -static bool8 Clockwise_BlackFade_Func7(struct Task *task); -static bool8 Ripple_Func1(struct Task *task); +static bool8 Clockwise_BlackFade_End(struct Task *task); +static bool8 Ripple_Init(struct Task *task); static bool8 Ripple_Func2(struct Task *task); -static bool8 Wave_Func1(struct Task *task); +static bool8 Wave_Init(struct Task *task); static bool8 Wave_Func2(struct Task *task); -static bool8 Wave_Func3(struct Task *task); -static bool8 Slice_Func1(struct Task *task); +static bool8 Wave_End(struct Task *task); +static bool8 Slice_Init(struct Task *task); static bool8 Slice_Func2(struct Task *task); -static bool8 Slice_Func3(struct Task *task); -static bool8 WhiteFade_Func1(struct Task *task); +static bool8 Slice_End(struct Task *task); +static bool8 WhiteFade_Init(struct Task *task); static bool8 WhiteFade_Func2(struct Task *task); static bool8 WhiteFade_Func3(struct Task *task); static bool8 WhiteFade_Func4(struct Task *task); -static bool8 WhiteFade_Func5(struct Task *task); -static bool8 GridSquares_Func1(struct Task *task); +static bool8 WhiteFade_End(struct Task *task); +static bool8 GridSquares_Init(struct Task *task); static bool8 GridSquares_Func2(struct Task *task); -static bool8 GridSquares_Func3(struct Task *task); -static bool8 Shards_Func1(struct Task *task); +static bool8 GridSquares_End(struct Task *task); +static bool8 Shards_Init(struct Task *task); static bool8 Shards_Func2(struct Task *task); static bool8 Shards_Func3(struct Task *task); static bool8 Shards_Func4(struct Task *task); static bool8 Shards_Func5(struct Task *task); -static bool8 ShredSplit_Func1(struct Task *task); +static bool8 ShredSplit_Init(struct Task *task); static bool8 ShredSplit_Func2(struct Task *task); static bool8 ShredSplit_Func3(struct Task *task); -static bool8 ShredSplit_Func4(struct Task *task); -static bool8 Blackhole_Func1(struct Task *task); +static bool8 ShredSplit_End(struct Task *task); +static bool8 Blackhole_Init(struct Task *task); static bool8 Blackhole1_Func2(struct Task *task); static bool8 Blackhole1_Func3(struct Task *task); static bool8 Blackhole2_Func2(struct Task *task); -static bool8 RectangularSpiral_Func1(struct Task *task); +static bool8 RectangularSpiral_Init(struct Task *task); static bool8 RectangularSpiral_Func2(struct Task *task); -static bool8 RectangularSpiral_Func3(struct Task *task); -static bool8 FrontierLogoWiggle_Func1(struct Task *task); -static bool8 FrontierLogoWiggle_Func2(struct Task *task); -static bool8 FrontierLogoWave_Func1(struct Task *task); -static bool8 FrontierLogoWave_Func2(struct Task *task); +static bool8 RectangularSpiral_End(struct Task *task); +static bool8 FrontierLogoWiggle_Init(struct Task *task); +static bool8 FrontierLogoWiggle_SetGfx(struct Task *task); +static bool8 FrontierLogoWave_Init(struct Task *task); +static bool8 FrontierLogoWave_SetGfx(struct Task *task); static bool8 FrontierLogoWave_Func3(struct Task *task); static bool8 FrontierLogoWave_Func4(struct Task *task); static bool8 Rayquaza_Func3(struct Task *task); @@ -209,39 +219,39 @@ static bool8 Rayquaza_Func6(struct Task *task); static bool8 Rayquaza_Func7(struct Task *task); static bool8 Rayquaza_Func8(struct Task *task); static bool8 Rayquaza_Func9(struct Task *task); -static bool8 FrontierSquares_Func1(struct Task *task); +static bool8 FrontierSquares_Init(struct Task *task); static bool8 FrontierSquares_Func2(struct Task *task); static bool8 FrontierSquares_Func3(struct Task *task); static bool8 FrontierSquares_End(struct Task *task); -static bool8 FrontierSquaresSpiral_Func1(struct Task *task); +static bool8 FrontierSquaresSpiral_Init(struct Task *task); static bool8 FrontierSquaresSpiral_Func2(struct Task *task); static bool8 FrontierSquaresSpiral_Func3(struct Task *task); static bool8 FrontierSquaresSpiral_Func4(struct Task *task); -static bool8 FrontierSquaresScroll_Func1(struct Task *task); +static bool8 FrontierSquaresScroll_Init(struct Task *task); static bool8 FrontierSquaresScroll_Func2(struct Task *task); static bool8 FrontierSquaresScroll_Func3(struct Task *task); static bool8 FrontierSquaresScroll_Func4(struct Task *task); -static bool8 FrontierSquaresScroll_Func5(struct Task *task); -static bool8 Mugshot_Func1(struct Task *task); -static bool8 Mugshot_Func2(struct Task *task); -static bool8 Mugshot_Func3(struct Task *task); -static bool8 Mugshot_Func4(struct Task *task); -static bool8 Mugshot_Func5(struct Task *task); -static bool8 Mugshot_Func6(struct Task *task); -static bool8 Mugshot_Func7(struct Task *task); -static bool8 Mugshot_Func8(struct Task *task); -static bool8 Mugshot_Func9(struct Task *task); -static bool8 Mugshot_Func10(struct Task *task); -static void Task_MugShotTransition(u8 taskId); -static void Mugshots_CreateOpponentPlayerSprites(struct Task *task); +static bool8 FrontierSquaresScroll_End(struct Task *task); +static bool8 Mugshot_Init(struct Task *task); +static bool8 Mugshot_SetGfx(struct Task *task); +static bool8 Mugshot_ShowBanner(struct Task *task); +static bool8 Mugshot_StartOpponentSlide(struct Task *task); +static bool8 Mugshot_WaitStartPlayerSlide(struct Task *task); +static bool8 Mugshot_WaitPlayerSlide(struct Task *task); +static bool8 Mugshot_GradualWhiteFade(struct Task *task); +static bool8 Mugshot_InitFadeWhiteToBlack(struct Task *task); +static bool8 Mugshot_FadeToBlack(struct Task *task); +static bool8 Mugshot_End(struct Task *task); +static void DoMugshotTransition(u8 taskId); +static void Mugshots_CreateTrainerPics(struct Task *task); static void VBlankCB0_Mugshots(void); static void VBlankCB1_Mugshots(void); static void HBlankCB_Mugshots(void); -static void InitTransitionStructVars(void); +static void InitTransitionData(void); static void FadeScreenBlack(void); static void CreateIntroTask(s16 a0, s16 a1, s16 a2, s16 a3, s16 a4); static void sub_814A014(u16 *a0, s16 a1, s16 a2, s16 a3); -static void sub_8149F98(s16 *array, s16 sinAdd, s16 index, s16 indexIncrementer, s16 amplitude, s16 arrSize); +static void SetSinWave(s16 *array, s16 sinAdd, s16 index, s16 indexIncrementer, s16 amplitude, s16 arrSize); static void GetBg0TilemapDst(u16 **tileset); static void sub_814A1AC(s16 *a0, s16 a1, s16 a2, s16 a3, s16 a4, s16 a5, s16 a6); static bool8 sub_814A228(s16 *a0, bool8 a1, bool8 a2); @@ -252,21 +262,21 @@ static bool8 Transition_Intro_1(struct Task *task); static bool8 Transition_Intro_2(struct Task *task); static bool8 IsIntroTaskDone(void); static bool16 sub_8149048(const s16 * const *arg0, struct StructRectangularSpiral *arg1); -static void sub_814713C(struct Sprite *sprite); -static void SpriteCb_TrainerPic(struct Sprite *sprite); +static void SpriteCB_FldEffPokeball(struct Sprite *sprite); +static void SpriteCB_MugshotTrainerPic(struct Sprite *sprite); static void sub_8149864(struct Sprite *sprite); -static bool8 TrainerPicCb_Nothing(struct Sprite *sprite); -static bool8 TrainerPicCb_SetSlideOffsets(struct Sprite *sprite); -static bool8 TrainerPicCb_Slide1(struct Sprite *sprite); -static bool8 TrainerPicCb_Slide2(struct Sprite *sprite); -static bool8 TrainerPicCb_Slide3(struct Sprite *sprite); +static bool8 MugshotTrainerPic_Nothing(struct Sprite *sprite); +static bool8 MugshotTrainerPic_SetSlideOffsets(struct Sprite *sprite); +static bool8 MugshotTrainerPic_Slide1(struct Sprite *sprite); +static bool8 MugshotTrainerPic_Slide2(struct Sprite *sprite); +static bool8 MugshotTrainerPic_Slide3(struct Sprite *sprite); static s16 sUnusedRectangularSpiralVar; static u8 sTestingTransitionId; static u8 sTestingTransitionState; static struct StructRectangularSpiral sRectangularSpiralTransition[4]; -EWRAM_DATA static struct TransitionData *sTransitionStructPtr = NULL; +EWRAM_DATA static struct TransitionData *sTransitionData = NULL; static const u32 sBigPokeball_Tileset[] = INCBIN_U32("graphics/battle_transitions/big_pokeball.4bpp"); static const u32 sPokeballTrail_Tileset[] = INCBIN_U32("graphics/battle_transitions/pokeball_trail.4bpp"); @@ -315,7 +325,8 @@ static const TaskFunc sTasks_Intro[B_TRANSITION_COUNT] = [0 ... B_TRANSITION_COUNT - 1] = &Task_Intro }; -// After the intro each transition has a unique main task +// After the intro each transition has a unique main task. +// This task will call the functions that do the transition effects. static const TaskFunc sTasks_Main[B_TRANSITION_COUNT] = { [B_TRANSITION_BLUR] = Task_Blur, @@ -372,102 +383,102 @@ static const TransitionStateFunc sTaskHandlers[] = static const TransitionStateFunc sBlur_Funcs[] = { - Blur_Func1, - Blur_Func2, - Blur_Func3 + Blur_Init, + Blur_Main, + Blur_End }; static const TransitionStateFunc sSwirl_Funcs[] = { - Swirl_Func1, - Swirl_Func2, + Swirl_Init, + Swirl_End, }; static const TransitionStateFunc sShuffle_Funcs[] = { - Shuffle_Func1, - Shuffle_Func2, + Shuffle_Init, + Shuffle_End, }; static const TransitionStateFunc sAqua_Funcs[] = { - Aqua_Func1, - Aqua_Func2, - BigPokeball_Func3, - BigPokeball_Func4, - BigPokeball_Func5, + Aqua_Init, + Aqua_SetGfx, + PatternWeave_1, + PatternWeave_2, + PatternWeave_3, FramesCountdown, - BigPokeball_Func6 + PatternWeave_End }; static const TransitionStateFunc sMagma_Funcs[] = { - Magma_Func1, - Magma_Func2, - BigPokeball_Func3, - BigPokeball_Func4, - BigPokeball_Func5, + Magma_Init, + Magma_SetGfx, + PatternWeave_1, + PatternWeave_2, + PatternWeave_3, FramesCountdown, - BigPokeball_Func6 + PatternWeave_End }; static const TransitionStateFunc sBigPokeball_Funcs[] = { - BigPokeball_Func1, - BigPokeball_Func2, - BigPokeball_Func3, - BigPokeball_Func4, - BigPokeball_Func5, - BigPokeball_Func6 + BigPokeball_Init, + BigPokeball_SetGfx, + PatternWeave_1, + PatternWeave_2, + PatternWeave_3, + PatternWeave_End }; static const TransitionStateFunc sRegice_Funcs[] = { - Regi_Func1, - Regice_Func2, - BigPokeball_Func3, - BigPokeball_Func4, - BigPokeball_Func5, - BigPokeball_Func6 + Regi_Init, + Regice_SetGfx, + PatternWeave_1, + PatternWeave_2, + PatternWeave_3, + PatternWeave_End }; static const TransitionStateFunc sRegisteel_Funcs[] = { - Regi_Func1, - Registeel_Func2, - BigPokeball_Func3, - BigPokeball_Func4, - BigPokeball_Func5, - BigPokeball_Func6 + Regi_Init, + Registeel_SetGfx, + PatternWeave_1, + PatternWeave_2, + PatternWeave_3, + PatternWeave_End }; static const TransitionStateFunc sRegirock_Funcs[] = { - Regi_Func1, - Regirock_Func2, - BigPokeball_Func3, - BigPokeball_Func4, - BigPokeball_Func5, - BigPokeball_Func6 + Regi_Init, + Regirock_SetGfx, + PatternWeave_1, + PatternWeave_2, + PatternWeave_3, + PatternWeave_End }; static const TransitionStateFunc sKyogre_Funcs[] = { - WeatherTrio_Func1, - WaitPaletteFade, - Kyogre_Func3, - Kyogre_Func4, - Kyogre_Func5, + WeatherTrio_BgFadeBlack, + WeatherTrio_WaitFade, + Kyogre_Init, + Kyogre_PalettePulsate, + Kyogre_PaletteBrighten, FramesCountdown, - WeatherDuo_Func6, - WeatherDuo_Func7 + WeatherDuo_FadeOut, + WeatherDuo_End }; static const TransitionStateFunc sPokeballsTrail_Funcs[] = { - PokeballsTrail_Func1, - PokeballsTrail_Func2, - PokeballsTrail_Func3 + PokeballsTrail_Init, + PokeballsTrail_Main, + PokeballsTrail_End }; static const s16 sUnknown_085C8B88[2] = {-16, 256}; @@ -476,48 +487,48 @@ static const s16 sUnknown_085C8B96[2] = {8, -8}; static const TransitionStateFunc sClockwise_BlackFade_Funcs[] = { - Clockwise_BlackFade_Func1, + Clockwise_BlackFade_Init, Clockwise_BlackFade_Func2, Clockwise_BlackFade_Func3, Clockwise_BlackFade_Func4, Clockwise_BlackFade_Func5, Clockwise_BlackFade_Func6, - Clockwise_BlackFade_Func7 + Clockwise_BlackFade_End }; static const TransitionStateFunc sRipple_Funcs[] = { - Ripple_Func1, + Ripple_Init, Ripple_Func2 }; static const TransitionStateFunc sWave_Funcs[] = { - Wave_Func1, + Wave_Init, Wave_Func2, - Wave_Func3 + Wave_End }; static const TransitionStateFunc sMugshot_Funcs[] = { - Mugshot_Func1, - Mugshot_Func2, - Mugshot_Func3, - Mugshot_Func4, - Mugshot_Func5, - Mugshot_Func6, - Mugshot_Func7, - Mugshot_Func8, - Mugshot_Func9, - Mugshot_Func10 + Mugshot_Init, + Mugshot_SetGfx, + Mugshot_ShowBanner, + Mugshot_StartOpponentSlide, + Mugshot_WaitStartPlayerSlide, + Mugshot_WaitPlayerSlide, + Mugshot_GradualWhiteFade, + Mugshot_InitFadeWhiteToBlack, + Mugshot_FadeToBlack, + Mugshot_End }; static const u8 sMugshotsTrainerPicIDsTable[MUGSHOTS_COUNT] = { - [MUGSHOT_SIDNEY] = TRAINER_PIC_ELITE_FOUR_SIDNEY, - [MUGSHOT_PHOEBE] = TRAINER_PIC_ELITE_FOUR_PHOEBE, - [MUGSHOT_GLACIA] = TRAINER_PIC_ELITE_FOUR_GLACIA, - [MUGSHOT_DRAKE] = TRAINER_PIC_ELITE_FOUR_DRAKE, + [MUGSHOT_SIDNEY] = TRAINER_PIC_ELITE_FOUR_SIDNEY, + [MUGSHOT_PHOEBE] = TRAINER_PIC_ELITE_FOUR_PHOEBE, + [MUGSHOT_GLACIA] = TRAINER_PIC_ELITE_FOUR_GLACIA, + [MUGSHOT_DRAKE] = TRAINER_PIC_ELITE_FOUR_DRAKE, [MUGSHOT_CHAMPION] = TRAINER_PIC_CHAMPION_WALLACE, }; static const s16 sMugshotsOpponentRotationScales[MUGSHOTS_COUNT][2] = @@ -530,40 +541,40 @@ static const s16 sMugshotsOpponentRotationScales[MUGSHOTS_COUNT][2] = }; static const s16 sMugshotsOpponentCoords[MUGSHOTS_COUNT][2] = { - [MUGSHOT_SIDNEY] = {0, 0}, - [MUGSHOT_PHOEBE] = {0, 0}, - [MUGSHOT_GLACIA] = {-4, 4}, - [MUGSHOT_DRAKE] = {0, 5}, - [MUGSHOT_CHAMPION] = {-8, 7}, + [MUGSHOT_SIDNEY] = { 0, 0}, + [MUGSHOT_PHOEBE] = { 0, 0}, + [MUGSHOT_GLACIA] = {-4, 4}, + [MUGSHOT_DRAKE] = { 0, 5}, + [MUGSHOT_CHAMPION] = {-8, 7}, }; -static const TransitionSpriteCallback sTrainerPicSpriteCbs[] = +static const TransitionSpriteCallback sMugshotTrainerPicFuncs[] = { - TrainerPicCb_Nothing, - TrainerPicCb_SetSlideOffsets, - TrainerPicCb_Slide1, - TrainerPicCb_Slide2, - TrainerPicCb_Nothing, - TrainerPicCb_Slide3, - TrainerPicCb_Nothing + MugshotTrainerPic_Nothing, + MugshotTrainerPic_SetSlideOffsets, + MugshotTrainerPic_Slide1, + MugshotTrainerPic_Slide2, + MugshotTrainerPic_Nothing, + MugshotTrainerPic_Slide3, + MugshotTrainerPic_Nothing }; static const s16 sTrainerPicSlideOffsets1[2] = {12, -12}; -static const s16 sTrainerPicSlideOffsets2[2] = {-1, 1}; +static const s16 sTrainerPicSlideOffsets2[2] = {-1, 1}; static const TransitionStateFunc sSlice_Funcs[] = { - Slice_Func1, + Slice_Init, Slice_Func2, - Slice_Func3 + Slice_End }; static const TransitionStateFunc sShredSplit_Funcs[] = { - ShredSplit_Func1, + ShredSplit_Init, ShredSplit_Func2, ShredSplit_Func3, - ShredSplit_Func4 + ShredSplit_End }; static const u8 gUnknown_085C8C64[] = {39, 119}; @@ -571,14 +582,14 @@ static const s16 gUnknown_085C8C66[] = {1, -1}; static const TransitionStateFunc sBlackhole1_Funcs[] = { - Blackhole_Func1, + Blackhole_Init, Blackhole1_Func2, Blackhole1_Func3 }; static const TransitionStateFunc sBlackhole2_Funcs[] = { - Blackhole_Func1, + Blackhole_Init, Blackhole2_Func2 }; @@ -586,9 +597,9 @@ static const s16 gUnknown_085C8C80[] = {-6, 4}; static const TransitionStateFunc sRectangularSpiral_Funcs[] = { - RectangularSpiral_Func1, + RectangularSpiral_Init, RectangularSpiral_Func2, - RectangularSpiral_Func3 + RectangularSpiral_End }; static const s16 gUnknown_085C8C90[] = {1, 27, 275, -1}; @@ -640,20 +651,20 @@ static const s16 *const *const gUnknown_085C8D38[] = static const TransitionStateFunc sGroudon_Funcs[] = { - WeatherTrio_Func1, - WaitPaletteFade, - Groudon_Func3, - Groudon_Func4, - Groudon_Func5, + WeatherTrio_BgFadeBlack, + WeatherTrio_WaitFade, + Groudon_Init, + Groudon_PalettePulsate, + Groudon_PaletteBrighten, FramesCountdown, - WeatherDuo_Func6, - WeatherDuo_Func7 + WeatherDuo_FadeOut, + WeatherDuo_End }; static const TransitionStateFunc sRayquaza_Funcs[] = { - WeatherTrio_Func1, - WaitPaletteFade, + WeatherTrio_BgFadeBlack, + WeatherTrio_WaitFade, Rayquaza_Func3, Rayquaza_Func4, Rayquaza_Func5, @@ -667,25 +678,25 @@ static const TransitionStateFunc sRayquaza_Funcs[] = static const TransitionStateFunc sWhiteFade_Funcs[] = { - WhiteFade_Func1, + WhiteFade_Init, WhiteFade_Func2, WhiteFade_Func3, WhiteFade_Func4, - WhiteFade_Func5 + WhiteFade_End }; static const s16 sUnknown_085C8DA0[] = {0, 20, 15, 40, 10, 25, 35, 5}; static const TransitionStateFunc sGridSquares_Funcs[] = { - GridSquares_Func1, + GridSquares_Init, GridSquares_Func2, - GridSquares_Func3 + GridSquares_End }; static const TransitionStateFunc sShards_Funcs[] = { - Shards_Func1, + Shards_Init, Shards_Func2, Shards_Func3, Shards_Func4, @@ -753,7 +764,7 @@ static const struct SpriteTemplate sSpriteTemplate_Pokeball = .anims = sSpriteAnimTable_Pokeball, .images = sSpriteImage_Pokeball, .affineAnims = sSpriteAffineAnimTable_Pokeball, - .callback = sub_814713C + .callback = SpriteCB_FldEffPokeball }; static const struct OamData sOam_UnusedBrendanLass = @@ -797,23 +808,23 @@ static const union AnimCmd *const sSpriteAnimTable_UnusedBrendanLass[] = static const struct SpriteTemplate sSpriteTemplate_UnusedBrendan = { .tileTag = TAG_NONE, - .paletteTag = 0x100A, + .paletteTag = PALTAG_UNUSED_MUGSHOT, .oam = &sOam_UnusedBrendanLass, .anims = sSpriteAnimTable_UnusedBrendanLass, .images = sImageTable_UnusedBrendan, .affineAnims = gDummySpriteAffineAnimTable, - .callback = SpriteCb_TrainerPic + .callback = SpriteCB_MugshotTrainerPic }; static const struct SpriteTemplate sSpriteTemplate_UnusedLass = { .tileTag = TAG_NONE, - .paletteTag = 0x100A, + .paletteTag = PALTAG_UNUSED_MUGSHOT, .oam = &sOam_UnusedBrendanLass, .anims = sSpriteAnimTable_UnusedBrendanLass, .images = sImageTable_UnusedLass, .affineAnims = gDummySpriteAffineAnimTable, - .callback = SpriteCb_TrainerPic + .callback = SpriteCB_MugshotTrainerPic }; static const u16 sFieldEffectPal_Pokeball[] = INCBIN_U16("graphics/field_effects/palettes/pokeball.gbapal"); @@ -844,32 +855,32 @@ static const u16 *const sPlayerMugshotsPals[GENDER_COUNT] = }; static const u16 sUnusedTrainerPalette[] = INCBIN_U16("graphics/battle_transitions/unused_trainer.gbapal"); -static const struct SpritePalette sSpritePalette_UnusedTrainer = {sUnusedTrainerPalette, 0x100A}; +static const struct SpritePalette sSpritePalette_UnusedTrainer = {sUnusedTrainerPalette, PALTAG_UNUSED_MUGSHOT}; static const u16 sBigPokeball_Tilemap[] = INCBIN_U16("graphics/battle_transitions/big_pokeball_map.bin"); static const u16 sMugshotsTilemap[] = INCBIN_U16("graphics/battle_transitions/elite_four_bg_map.bin"); static const TransitionStateFunc sFrontierLogoWiggle_Funcs[] = { - FrontierLogoWiggle_Func1, - FrontierLogoWiggle_Func2, - BigPokeball_Func3, - BigPokeball_Func4, - BigPokeball_Func5, - BigPokeball_Func6 + FrontierLogoWiggle_Init, + FrontierLogoWiggle_SetGfx, + PatternWeave_1, + PatternWeave_2, + PatternWeave_3, + PatternWeave_End }; static const TransitionStateFunc sFrontierLogoWave_Funcs[] = { - FrontierLogoWave_Func1, - FrontierLogoWave_Func2, + FrontierLogoWave_Init, + FrontierLogoWave_SetGfx, FrontierLogoWave_Func3, FrontierLogoWave_Func4 }; static const TransitionStateFunc sFrontierSquares_Funcs[] = { - FrontierSquares_Func1, + FrontierSquares_Init, FrontierSquares_Func2, FrontierSquares_Func3, FrontierSquares_End @@ -877,7 +888,7 @@ static const TransitionStateFunc sFrontierSquares_Funcs[] = static const TransitionStateFunc sFrontierSquaresSpiral_Funcs[] = { - FrontierSquaresSpiral_Func1, + FrontierSquaresSpiral_Init, FrontierSquaresSpiral_Func2, FrontierSquaresSpiral_Func3, FrontierSquaresSpiral_Func4, @@ -886,15 +897,35 @@ static const TransitionStateFunc sFrontierSquaresSpiral_Funcs[] = static const TransitionStateFunc sFrontierSquaresScroll_Funcs[] = { - FrontierSquaresScroll_Func1, + FrontierSquaresScroll_Init, FrontierSquaresScroll_Func2, FrontierSquaresScroll_Func3, FrontierSquaresScroll_Func4, - FrontierSquaresScroll_Func5 + FrontierSquaresScroll_End }; -static const u8 gUnknown_085C9A30[] = {0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x1b, 0x14, 0x0d, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x07, 0x0e, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x13, 0x0c, 0x0b, 0x0a, 0x09, 0x08, 0x0f, 0x10, 0x11, 0x12}; -static const u8 gUnknown_085C9A53[] = {0x00, 0x10, 0x29, 0x16, 0x2c, 0x02, 0x2b, 0x15, 0x2e, 0x1b, 0x09, 0x30, 0x26, 0x05, 0x39, 0x3b, 0x0c, 0x3f, 0x23, 0x1c, 0x0a, 0x35, 0x07, 0x31, 0x27, 0x17, 0x37, 0x01, 0x3e, 0x11, 0x3d, 0x1e, 0x06, 0x22, 0x0f, 0x33, 0x20, 0x3a, 0x0d, 0x2d, 0x25, 0x34, 0x0b, 0x18, 0x3c, 0x13, 0x38, 0x21, 0x1d, 0x32, 0x28, 0x36, 0x0e, 0x03, 0x2f, 0x14, 0x12, 0x19, 0x04, 0x24, 0x1a, 0x2a, 0x1f, 0x08, 0x00}; +static const u8 gUnknown_085C9A30[] = { + 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, + 0x1b, 0x14, 0x0d, 0x06, 0x05, 0x04, 0x03, + 0x02, 0x01, 0x00, 0x07, 0x0e, 0x15, 0x16, + 0x17, 0x18, 0x19, 0x1a, 0x13, 0x0c, 0x0b, + 0x0a, 0x09, 0x08, 0x0f, 0x10, 0x11, 0x12 +}; + +static const u8 gUnknown_085C9A53[] = { + 0x00, 0x10, 0x29, 0x16, 0x2c, 0x02, 0x2b, 0x15, + 0x2e, 0x1b, 0x09, 0x30, 0x26, 0x05, 0x39, 0x3b, + 0x0c, 0x3f, 0x23, 0x1c, 0x0a, 0x35, 0x07, 0x31, + 0x27, 0x17, 0x37, 0x01, 0x3e, 0x11, 0x3d, 0x1e, + 0x06, 0x22, 0x0f, 0x33, 0x20, 0x3a, 0x0d, 0x2d, + 0x25, 0x34, 0x0b, 0x18, 0x3c, 0x13, 0x38, 0x21, + 0x1d, 0x32, 0x28, 0x36, 0x0e, 0x03, 0x2f, 0x14, + 0x12, 0x19, 0x04, 0x24, 0x1a, 0x2a, 0x1f, 0x08 +}; + +//--------------------------- +// Main transition functions +//--------------------------- static void CB2_TestBattleTransition(void) { @@ -950,7 +981,7 @@ bool8 IsBattleTransitionDone(void) if (gTasks[taskId].tTransitionDone) { DestroyTask(taskId); - FREE_AND_SET_NULL(sTransitionStructPtr); + FREE_AND_SET_NULL(sTransitionData); return TRUE; } else @@ -963,7 +994,7 @@ static void LaunchBattleTransitionTask(u8 transitionId) { u8 taskId = CreateTask(Task_BattleTransition, 2); gTasks[taskId].tTransitionId = transitionId; - sTransitionStructPtr = AllocZeroed(sizeof(*sTransitionStructPtr)); + sTransitionData = AllocZeroed(sizeof(*sTransitionData)); } static void Task_BattleTransition(u8 taskId) @@ -1032,25 +1063,24 @@ static void Task_Intro(u8 taskId) } } -// sub-task for phase2 -#define tData1 data[1] -#define tData2 data[2] -#define tData3 data[3] -#define tData4 data[4] -#define tData5 data[5] -#define tData6 data[6] #define tFuncState data[7] -#define tFrames data[8] #define tOpponentSpriteId data[13] #define tPlayerSpriteId data[14] #define tMugshotId data[15] +//-------------------- +// B_TRANSITION_BLUR +//-------------------- + +#define tDelay data[1] +#define tCounter data[2] + static void Task_Blur(u8 taskId) { while (sBlur_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static bool8 Blur_Func1(struct Task *task) +static bool8 Blur_Init(struct Task *task) { SetGpuReg(REG_OFFSET_MOSAIC, 0); SetGpuRegBits(REG_OFFSET_BG1CNT, BGCNT_MOSAIC); @@ -1060,25 +1090,25 @@ static bool8 Blur_Func1(struct Task *task) return TRUE; } -static bool8 Blur_Func2(struct Task *task) +static bool8 Blur_Main(struct Task *task) { - if (task->tData1 != 0) + if (task->tDelay != 0) { - task->tData1--; + task->tDelay--; } else { - task->tData1 = 4; - if (++task->tData2 == 10) - BeginNormalPaletteFade(PALETTES_ALL, -1, 0, 0x10, RGB_BLACK); - SetGpuReg(REG_OFFSET_MOSAIC, (task->tData2 & 15) * 17); - if (task->tData2 > 14) + task->tDelay = 4; + if (++task->tCounter == 10) + BeginNormalPaletteFade(PALETTES_ALL, -1, 0, 16, RGB_BLACK); + SetGpuReg(REG_OFFSET_MOSAIC, (task->tCounter & 15) * 17); + if (task->tCounter > 14) task->tState++; } return FALSE; } -static bool8 Blur_Func3(struct Task *task) +static bool8 Blur_End(struct Task *task) { if (!gPaletteFade.active) { @@ -1088,17 +1118,27 @@ static bool8 Blur_Func3(struct Task *task) return FALSE; } +#undef tDelay +#undef tCounter + +//-------------------- +// B_TRANSITION_SWIRL +//-------------------- + +#define tSinIndex data[1] +#define tAmplitude data[2] + static void Task_Swirl(u8 taskId) { while (sSwirl_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static bool8 Swirl_Func1(struct Task *task) +static bool8 Swirl_Init(struct Task *task) { - InitTransitionStructVars(); + InitTransitionData(); ScanlineEffect_Clear(); - BeginNormalPaletteFade(PALETTES_ALL, 4, 0, 0x10, RGB_BLACK); - sub_8149F98(gScanlineEffectRegBuffers[1], sTransitionStructPtr->field_14, 0, 2, 0, 160); + BeginNormalPaletteFade(PALETTES_ALL, 4, 0, 16, RGB_BLACK); + SetSinWave(gScanlineEffectRegBuffers[1], sTransitionData->cameraX, 0, 2, 0, DISPLAY_HEIGHT); SetVBlankCallback(VBlankCB_Swirl); SetHBlankCallback(HBlankCB_Swirl); @@ -1109,13 +1149,13 @@ static bool8 Swirl_Func1(struct Task *task) return FALSE; } -static bool8 Swirl_Func2(struct Task *task) +static bool8 Swirl_End(struct Task *task) { - sTransitionStructPtr->VBlank_DMA = FALSE; - task->tData1 += 4; - task->tData2 += 8; + sTransitionData->VBlank_DMA = FALSE; + task->tSinIndex += 4; + task->tAmplitude += 8; - sub_8149F98(gScanlineEffectRegBuffers[0], sTransitionStructPtr->field_14, task->tData1, 2, task->tData2, 160); + SetSinWave(gScanlineEffectRegBuffers[0], sTransitionData->cameraX, task->tSinIndex, 2, task->tAmplitude, DISPLAY_HEIGHT); if (!gPaletteFade.active) { @@ -1123,15 +1163,15 @@ static bool8 Swirl_Func2(struct Task *task) DestroyTask(taskId); } - sTransitionStructPtr->VBlank_DMA++; + sTransitionData->VBlank_DMA++; return FALSE; } static void VBlankCB_Swirl(void) { VBlankCB_BattleTransition(); - if (sTransitionStructPtr->VBlank_DMA) - DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], 320); + if (sTransitionData->VBlank_DMA) + DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], DISPLAY_HEIGHT * 2); } static void HBlankCB_Swirl(void) @@ -1142,18 +1182,28 @@ static void HBlankCB_Swirl(void) REG_BG3HOFS = var; } +#undef tSinIndex +#undef tAmplitude + +//---------------------- +// B_TRANSITION_SHUFFLE +//---------------------- + +#define tSinVal data[1] +#define tAmplitude data[2] + static void Task_Shuffle(u8 taskId) { while (sShuffle_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static bool8 Shuffle_Func1(struct Task *task) +static bool8 Shuffle_Init(struct Task *task) { - InitTransitionStructVars(); + InitTransitionData(); ScanlineEffect_Clear(); - BeginNormalPaletteFade(PALETTES_ALL, 4, 0, 0x10, RGB_BLACK); - memset(gScanlineEffectRegBuffers[1], sTransitionStructPtr->field_16, 0x140); + BeginNormalPaletteFade(PALETTES_ALL, 4, 0, 16, RGB_BLACK); + memset(gScanlineEffectRegBuffers[1], sTransitionData->cameraY, DISPLAY_HEIGHT * 2); SetVBlankCallback(VBlankCB_Shuffle); SetHBlankCallback(HBlankCB_Shuffle); @@ -1164,35 +1214,35 @@ static bool8 Shuffle_Func1(struct Task *task) return FALSE; } -static bool8 Shuffle_Func2(struct Task *task) +static bool8 Shuffle_End(struct Task *task) { u8 i; - u16 r3, r4; + u16 amplitude, sinVal; - sTransitionStructPtr->VBlank_DMA = FALSE; - r4 = task->tData1; - r3 = task->tData2 >> 8; - task->tData1 += 4224; - task->tData2 += 384; + sTransitionData->VBlank_DMA = FALSE; + sinVal = task->tSinVal; + amplitude = task->tAmplitude >> 8; + task->tSinVal += 4224; + task->tAmplitude += 384; - for (i = 0; i < 160; i++, r4 += 4224) + for (i = 0; i < DISPLAY_HEIGHT; i++, sinVal += 4224) { - u16 var = r4 / 256; - gScanlineEffectRegBuffers[0][i] = sTransitionStructPtr->field_16 + Sin(var, r3); + u16 sinIndex = sinVal / 256; + gScanlineEffectRegBuffers[0][i] = sTransitionData->cameraY + Sin(sinIndex, amplitude); } if (!gPaletteFade.active) DestroyTask(FindTaskIdByFunc(Task_Shuffle)); - sTransitionStructPtr->VBlank_DMA++; + sTransitionData->VBlank_DMA++; return FALSE; } static void VBlankCB_Shuffle(void) { VBlankCB_BattleTransition(); - if (sTransitionStructPtr->VBlank_DMA) - DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], 320); + if (sTransitionData->VBlank_DMA) + DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], DISPLAY_HEIGHT * 2); } static void HBlankCB_Shuffle(void) @@ -1203,6 +1253,32 @@ static void HBlankCB_Shuffle(void) REG_BG3VOFS = var; } +#undef tSinVal +#undef tAmplitude + +//------------------------------------------------------------------------ +// B_TRANSITION_BIG_POKEBALL, B_TRANSITION_AQUA, B_TRANSITION_MAGMA, +// B_TRANSITION_REGICE, B_TRANSITION_REGISTEEL, B_TRANSITION_REGIROCK +// and B_TRANSITION_KYOGRE. +// +// With the exception of B_TRANSITION_KYOGRE, all of the above transitions +// use the same weave effect (see the PatternWeave functions). +// Unclear why Kyogre's was grouped here and not with Groudon/Rayquaza's. +//------------------------------------------------------------------------ + +#define tBlendTarget1 data[1] +#define tBlendTarget2 data[2] +#define tBlendDelay data[3] + +// Data 1-3 change purpose for PatternWeave_End +#define tEndAmplitude data[1] +#define tEndAmplitudeDelta data[2] +#define tVBlankSet data[3] + +#define tSinIndex data[4] +#define tAmplitude data[5] +#define tEndDelay data[8] + static void Task_BigPokeball(u8 taskId) { while (sBigPokeball_Funcs[gTasks[taskId].tState](&gTasks[taskId])); @@ -1238,186 +1314,179 @@ static void Task_Kyogre(u8 taskId) while (sKyogre_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static void sub_814669C(struct Task *task) +static void InitPatternWeaveTransition(struct Task *task) { s32 i; - InitTransitionStructVars(); + InitTransitionData(); ScanlineEffect_Clear(); - task->tData1 = 16; - task->tData2 = 0; - task->tData4 = 0; - task->tData5 = 0x4000; - sTransitionStructPtr->WININ = WININ_WIN0_ALL; - sTransitionStructPtr->WINOUT = 0; - sTransitionStructPtr->WIN0H = DISPLAY_WIDTH; - sTransitionStructPtr->WIN0V = DISPLAY_HEIGHT; - sTransitionStructPtr->BLDCNT = BLDCNT_TGT1_BG0 | BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_ALL; - sTransitionStructPtr->BLDALPHA = BLDALPHA_BLEND(task->tData2, task->tData1); - - for (i = 0; i < 160; i++) - { - gScanlineEffectRegBuffers[1][i] = 240; - } + task->tBlendTarget1 = 16; + task->tBlendTarget2 = 0; + task->tSinIndex = 0; + task->tAmplitude = 0x4000; + sTransitionData->WININ = WININ_WIN0_ALL; + sTransitionData->WINOUT = 0; + sTransitionData->WIN0H = DISPLAY_WIDTH; + sTransitionData->WIN0V = DISPLAY_HEIGHT; + sTransitionData->BLDCNT = BLDCNT_TGT1_BG0 | BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_ALL; + sTransitionData->BLDALPHA = BLDALPHA_BLEND(task->tBlendTarget2, task->tBlendTarget1); + + for (i = 0; i < DISPLAY_HEIGHT; i++) + gScanlineEffectRegBuffers[1][i] = DISPLAY_WIDTH; - SetVBlankCallback(VBlankCB0_BigPokeball); + SetVBlankCallback(VBlankCB_PatternWeave); } -static bool8 Aqua_Func1(struct Task *task) +static bool8 Aqua_Init(struct Task *task) { u16 *tilemap, *tileset; - task->tFrames = 60; - sub_814669C(task); + task->tEndDelay = 60; + InitPatternWeaveTransition(task); GetBg0TilesDst(&tilemap, &tileset); - CpuFill16(0, tilemap, 0x800); + CpuFill16(0, tilemap, BG_SCREEN_SIZE); LZ77UnCompVram(sTeamAqua_Tileset, tileset); - LoadPalette(sEvilTeam_Palette, 0xF0, 0x20); + LoadPalette(sEvilTeam_Palette, 0xF0, sizeof(sEvilTeam_Palette)); task->tState++; return FALSE; } -static bool8 Magma_Func1(struct Task *task) +static bool8 Magma_Init(struct Task *task) { u16 *tilemap, *tileset; - task->tFrames = 60; - sub_814669C(task); + task->tEndDelay = 60; + InitPatternWeaveTransition(task); GetBg0TilesDst(&tilemap, &tileset); - CpuFill16(0, tilemap, 0x800); + CpuFill16(0, tilemap, BG_SCREEN_SIZE); LZ77UnCompVram(sTeamMagma_Tileset, tileset); - LoadPalette(sEvilTeam_Palette, 0xF0, 0x20); + LoadPalette(sEvilTeam_Palette, 0xF0, sizeof(sEvilTeam_Palette)); task->tState++; return FALSE; } -static bool8 Regi_Func1(struct Task *task) +static bool8 Regi_Init(struct Task *task) { u16 *tilemap, *tileset; - task->tFrames = 60; - sub_814669C(task); + task->tEndDelay = 60; + InitPatternWeaveTransition(task); GetBg0TilesDst(&tilemap, &tileset); - CpuFill16(0, tilemap, 0x800); + CpuFill16(0, tilemap, BG_SCREEN_SIZE); CpuCopy16(sRegis_Tileset, tileset, 0x2000); task->tState++; return FALSE; } -static bool8 BigPokeball_Func1(struct Task *task) +static bool8 BigPokeball_Init(struct Task *task) { u16 *tilemap, *tileset; - sub_814669C(task); + InitPatternWeaveTransition(task); GetBg0TilesDst(&tilemap, &tileset); - CpuFill16(0, tilemap, 0x800); - CpuCopy16(sBigPokeball_Tileset, tileset, 0x580); - LoadPalette(sFieldEffectPal_Pokeball, 0xF0, 0x20); + CpuFill16(0, tilemap, BG_SCREEN_SIZE); + CpuCopy16(sBigPokeball_Tileset, tileset, sizeof(sBigPokeball_Tileset)); + LoadPalette(sFieldEffectPal_Pokeball, 0xF0, sizeof(sFieldEffectPal_Pokeball)); task->tState++; return FALSE; } -#define SOME_VRAM_STORE(ptr, posY, posX, toStore) \ -{ \ - u32 index = (posY) * 32 + posX; \ - ptr[index] = toStore; \ -} - -static bool8 BigPokeball_Func2(struct Task *task) +static bool8 BigPokeball_SetGfx(struct Task *task) { s16 i, j; u16 *tilemap, *tileset; - const u16 *BigPokeballMap; + const u16 *bigPokeballMap; GetBg0TilesDst(&tilemap, &tileset); - BigPokeballMap = sBigPokeball_Tilemap; + bigPokeballMap = sBigPokeball_Tilemap; for (i = 0; i < 20; i++) { - for (j = 0; j < 30; j++, BigPokeballMap++) - { - SOME_VRAM_STORE(tilemap, i, j, *BigPokeballMap | 0xF000); - } + for (j = 0; j < 30; j++, bigPokeballMap++) + SET_TILEMAP_TILE(tilemap, i, j, *bigPokeballMap | 0xF000); } - sub_8149F98(gScanlineEffectRegBuffers[0], 0, task->tData4, 132, task->tData5, 160); + + SetSinWave(gScanlineEffectRegBuffers[0], 0, task->tSinIndex, 132, task->tAmplitude, DISPLAY_HEIGHT); task->tState++; return TRUE; } -static bool8 Aqua_Func2(struct Task *task) +static bool8 Aqua_SetGfx(struct Task *task) { u16 *tilemap, *tileset; GetBg0TilesDst(&tilemap, &tileset); LZ77UnCompVram(sTeamAqua_Tilemap, tilemap); - sub_8149F98(gScanlineEffectRegBuffers[0], 0, task->tData4, 132, task->tData5, 160); + SetSinWave(gScanlineEffectRegBuffers[0], 0, task->tSinIndex, 132, task->tAmplitude, DISPLAY_HEIGHT); task->tState++; return FALSE; } -static bool8 Magma_Func2(struct Task *task) +static bool8 Magma_SetGfx(struct Task *task) { u16 *tilemap, *tileset; GetBg0TilesDst(&tilemap, &tileset); LZ77UnCompVram(sTeamMagma_Tilemap, tilemap); - sub_8149F98(gScanlineEffectRegBuffers[0], 0, task->tData4, 132, task->tData5, 160); + SetSinWave(gScanlineEffectRegBuffers[0], 0, task->tSinIndex, 132, task->tAmplitude, DISPLAY_HEIGHT); task->tState++; return FALSE; } -static bool8 Regice_Func2(struct Task *task) +static bool8 Regice_SetGfx(struct Task *task) { u16 *tilemap, *tileset; GetBg0TilesDst(&tilemap, &tileset); - LoadPalette(sRegice_Palette, 0xF0, 0x20); + LoadPalette(sRegice_Palette, 0xF0, sizeof(sRegice_Palette)); CpuCopy16(sRegice_Tilemap, tilemap, 0x500); - sub_8149F98(gScanlineEffectRegBuffers[0], 0, task->tData4, 132, task->tData5, 160); + SetSinWave(gScanlineEffectRegBuffers[0], 0, task->tSinIndex, 132, task->tAmplitude, DISPLAY_HEIGHT); task->tState++; return FALSE; } -static bool8 Registeel_Func2(struct Task *task) +static bool8 Registeel_SetGfx(struct Task *task) { u16 *tilemap, *tileset; GetBg0TilesDst(&tilemap, &tileset); - LoadPalette(sRegisteel_Palette, 0xF0, 0x20); + LoadPalette(sRegisteel_Palette, 0xF0, sizeof(sRegisteel_Palette)); CpuCopy16(sRegisteel_Tilemap, tilemap, 0x500); - sub_8149F98(gScanlineEffectRegBuffers[0], 0, task->tData4, 132, task->tData5, 160); + SetSinWave(gScanlineEffectRegBuffers[0], 0, task->tSinIndex, 132, task->tAmplitude, DISPLAY_HEIGHT); task->tState++; return FALSE; } -static bool8 Regirock_Func2(struct Task *task) +static bool8 Regirock_SetGfx(struct Task *task) { u16 *tilemap, *tileset; GetBg0TilesDst(&tilemap, &tileset); - LoadPalette(sRegirock_Palette, 0xF0, 0x20); + LoadPalette(sRegirock_Palette, 0xF0, sizeof(sRegirock_Palette)); CpuCopy16(sRegirock_Tilemap, tilemap, 0x500); - sub_8149F98(gScanlineEffectRegBuffers[0], 0, task->tData4, 132, task->tData5, 160); + SetSinWave(gScanlineEffectRegBuffers[0], 0, task->tSinIndex, 132, task->tAmplitude, DISPLAY_HEIGHT); task->tState++; return FALSE; } -static bool8 Kyogre_Func3(struct Task *task) +#define tTimer data[1] + +static bool8 Kyogre_Init(struct Task *task) { u16 *tilemap, *tileset; GetBg0TilesDst(&tilemap, &tileset); - CpuFill16(0, tilemap, 0x800); + CpuFill16(0, tilemap, BG_SCREEN_SIZE); LZ77UnCompVram(sKyogre_Tileset, tileset); LZ77UnCompVram(sKyogre_Tilemap, tilemap); @@ -1425,48 +1494,48 @@ static bool8 Kyogre_Func3(struct Task *task) return FALSE; } -static bool8 Kyogre_Func4(struct Task *task) +static bool8 Kyogre_PalettePulsate(struct Task *task) { - if (task->tData1 % 3 == 0) + if (task->tTimer % 3 == 0) { - u16 var = task->tData1 % 30; + u16 var = task->tTimer % 30; var /= 3; LoadPalette(sKyogre1_Palette + (var * 16), 0xF0, 0x20); } - if (++task->tData1 > 58) + if (++task->tTimer > 58) { task->tState++; - task->tData1 = 0; + task->tTimer = 0; } return FALSE; } -static bool8 Kyogre_Func5(struct Task *task) +static bool8 Kyogre_PaletteBrighten(struct Task *task) { - if (task->tData1 % 5 == 0) + if (task->tTimer % 5 == 0) { - s16 var = task->tData1 / 5; + s16 var = task->tTimer / 5; LoadPalette(sKyogre2_Palette + (var * 16), 0xF0, 0x20); } - if (++task->tData1 > 68) + if (++task->tTimer > 68) { task->tState++; - task->tData1 = 0; - task->tFrames = 30; + task->tTimer = 0; + task->tEndDelay = 30; } return FALSE; } -static bool8 WeatherDuo_Func6(struct Task *task) +static bool8 WeatherDuo_FadeOut(struct Task *task) { - BeginNormalPaletteFade(PALETTES_OBJECTS | 0x8000, 1, 0, 0x10, RGB_BLACK); + BeginNormalPaletteFade(PALETTES_OBJECTS | (1 << 15), 1, 0, 16, RGB_BLACK); task->tState++; return FALSE; } -static bool8 WeatherDuo_Func7(struct Task *task) +static bool8 WeatherDuo_End(struct Task *task) { if (!gPaletteFade.active) { @@ -1477,100 +1546,105 @@ static bool8 WeatherDuo_Func7(struct Task *task) return FALSE; } -static bool8 BigPokeball_Func3(struct Task *task) +#undef tTimer + +// The PatternWeave_ functions are used by several different transitions. +// They create an effect where a pattern/image (such as the Magma emblem) is +// formed by a shimmering weave effect. +static bool8 PatternWeave_1(struct Task *task) { - sTransitionStructPtr->VBlank_DMA = FALSE; - if (task->tData3 == 0 || --task->tData3 == 0) + sTransitionData->VBlank_DMA = FALSE; + if (task->tBlendDelay == 0 || --task->tBlendDelay == 0) { - task->tData2++; - task->tData3 = 2; + task->tBlendTarget2++; + task->tBlendDelay = 2; } - sTransitionStructPtr->BLDALPHA = BLDALPHA_BLEND(task->tData2, task->tData1); - if (task->tData2 > 15) + sTransitionData->BLDALPHA = BLDALPHA_BLEND(task->tBlendTarget2, task->tBlendTarget1); + if (task->tBlendTarget2 > 15) task->tState++; - task->tData4 += 8; - task->tData5 -= 256; + task->tSinIndex += 8; + task->tAmplitude -= 256; - sub_8149F98(gScanlineEffectRegBuffers[0], 0, task->tData4, 132, task->tData5 >> 8, 160); + SetSinWave(gScanlineEffectRegBuffers[0], 0, task->tSinIndex, 132, task->tAmplitude >> 8, DISPLAY_HEIGHT); - sTransitionStructPtr->VBlank_DMA++; + sTransitionData->VBlank_DMA++; return FALSE; } -static bool8 BigPokeball_Func4(struct Task *task) +static bool8 PatternWeave_2(struct Task *task) { - sTransitionStructPtr->VBlank_DMA = FALSE; - if (task->tData3 == 0 || --task->tData3 == 0) + sTransitionData->VBlank_DMA = FALSE; + if (task->tBlendDelay == 0 || --task->tBlendDelay == 0) { - task->tData1--; - task->tData3 = 2; + task->tBlendTarget1--; + task->tBlendDelay = 2; } - sTransitionStructPtr->BLDALPHA = BLDALPHA_BLEND(task->tData2, task->tData1); - if (task->tData1 == 0) + sTransitionData->BLDALPHA = BLDALPHA_BLEND(task->tBlendTarget2, task->tBlendTarget1); + if (task->tBlendTarget1 == 0) task->tState++; - task->tData4 += 8; - task->tData5 -= 256; + task->tSinIndex += 8; + task->tAmplitude -= 256; - sub_8149F98(gScanlineEffectRegBuffers[0], 0, task->tData4, 132, task->tData5 >> 8, 160); + SetSinWave(gScanlineEffectRegBuffers[0], 0, task->tSinIndex, 132, task->tAmplitude >> 8, DISPLAY_HEIGHT); - sTransitionStructPtr->VBlank_DMA++; + sTransitionData->VBlank_DMA++; return FALSE; } -static bool8 BigPokeball_Func5(struct Task *task) +static bool8 PatternWeave_3(struct Task *task) { - sTransitionStructPtr->VBlank_DMA = FALSE; - task->tData4 += 8; - task->tData5 -= 256; + sTransitionData->VBlank_DMA = FALSE; + task->tSinIndex += 8; + task->tAmplitude -= 256; - sub_8149F98(gScanlineEffectRegBuffers[0], 0, task->tData4, 132, task->tData5 >> 8, 160); + SetSinWave(gScanlineEffectRegBuffers[0], 0, task->tSinIndex, 132, task->tAmplitude >> 8, DISPLAY_HEIGHT); - if (task->tData5 <= 0) + if (task->tAmplitude <= 0) { task->tState++; - task->tData1 = 160; - task->tData2 = 256; - task->tData3 = 0; + task->tEndAmplitude = 160; + task->tEndAmplitudeDelta = 256; + task->tVBlankSet = FALSE; } - sTransitionStructPtr->VBlank_DMA++; + sTransitionData->VBlank_DMA++; return FALSE; } static bool8 FramesCountdown(struct Task *task) { - if (--task->tFrames == 0) + if (--task->tEndDelay == 0) task->tState++; return FALSE; } -static bool8 WeatherTrio_Func1(struct Task *task) +static bool8 WeatherTrio_BgFadeBlack(struct Task *task) { - BeginNormalPaletteFade(PALETTES_BG, 1, 0, 0x10, RGB_BLACK); + BeginNormalPaletteFade(PALETTES_BG, 1, 0, 16, RGB_BLACK); task->tState++; return FALSE; } -static bool8 WaitPaletteFade(struct Task *task) +static bool8 WeatherTrio_WaitFade(struct Task *task) { if (!gPaletteFade.active) task->tState++; return FALSE; } -static bool8 BigPokeball_Func6(struct Task *task) +static bool8 PatternWeave_End(struct Task *task) { - sTransitionStructPtr->VBlank_DMA = FALSE; - if (task->tData2 < 1024) - task->tData2 += 128; - if (task->tData1 != 0) + sTransitionData->VBlank_DMA = FALSE; + if (task->tEndAmplitudeDelta < 1024) + task->tEndAmplitudeDelta += 128; + if (task->tEndAmplitude != 0) { - task->tData1 -= (task->tData2 >> 8); - if (task->tData1 < 0) - task->tData1 = 0; + task->tEndAmplitude -= task->tEndAmplitudeDelta >> 8; + if (task->tEndAmplitude < 0) + task->tEndAmplitude = 0; } - sub_814A014(gScanlineEffectRegBuffers[0], 120, 80, task->tData1); - if (task->tData1 == 0) + sub_814A014(gScanlineEffectRegBuffers[0], 120, 80, task->tEndAmplitude); + if (task->tEndAmplitude == 0) { SetVBlankCallback(NULL); DmaStop(0); @@ -1579,13 +1653,13 @@ static bool8 BigPokeball_Func6(struct Task *task) } else { - if (task->tData3 == 0) + if (!task->tVBlankSet) { - task->tData3++; + task->tVBlankSet++; SetVBlankCallback(VBlankCB1_BigPokeball); } - sTransitionStructPtr->VBlank_DMA++; + sTransitionData->VBlank_DMA++; } return FALSE; @@ -1595,58 +1669,65 @@ static void Transition_BigPokeball_Vblank(void) { DmaStop(0); VBlankCB_BattleTransition(); - if (sTransitionStructPtr->VBlank_DMA) - DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], 320); - REG_WININ = sTransitionStructPtr->WININ; - REG_WINOUT = sTransitionStructPtr->WINOUT; - REG_WIN0V = sTransitionStructPtr->WIN0V; - REG_BLDCNT = sTransitionStructPtr->BLDCNT; - REG_BLDALPHA = sTransitionStructPtr->BLDALPHA; + if (sTransitionData->VBlank_DMA) + DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], DISPLAY_HEIGHT * 2); + REG_WININ = sTransitionData->WININ; + REG_WINOUT = sTransitionData->WINOUT; + REG_WIN0V = sTransitionData->WIN0V; + REG_BLDCNT = sTransitionData->BLDCNT; + REG_BLDALPHA = sTransitionData->BLDALPHA; } -static void VBlankCB0_BigPokeball(void) +static void VBlankCB_PatternWeave(void) { Transition_BigPokeball_Vblank(); - DmaSet(0, gScanlineEffectRegBuffers[1], ®_BG0HOFS, 0xA2400001); + DmaSet(0, gScanlineEffectRegBuffers[1], ®_BG0HOFS, B_TRANS_DMA_FLAGS); } static void VBlankCB1_BigPokeball(void) { Transition_BigPokeball_Vblank(); - DmaSet(0, gScanlineEffectRegBuffers[1], ®_WIN0H, 0xA2400001); + DmaSet(0, gScanlineEffectRegBuffers[1], ®_WIN0H, B_TRANS_DMA_FLAGS); } +#undef tAmplitude +#undef tSinIndex +#undef tBlendTarget1 +#undef tBlendTarget2 +#undef tEndAmplitude +#undef tVBlankSet + static void Task_PokeballsTrail(u8 taskId) { while (sPokeballsTrail_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static bool8 PokeballsTrail_Func1(struct Task *task) +static bool8 PokeballsTrail_Init(struct Task *task) { u16 *tilemap, *tileset; GetBg0TilesDst(&tilemap, &tileset); CpuSet(sPokeballTrail_Tileset, tileset, 0x20); - CpuFill32(0, tilemap, 0x800); - LoadPalette(sFieldEffectPal_Pokeball, 0xF0, 0x20); + CpuFill32(0, tilemap, BG_SCREEN_SIZE); + LoadPalette(sFieldEffectPal_Pokeball, 0xF0, sizeof(sFieldEffectPal_Pokeball)); task->tState++; return FALSE; } -static bool8 PokeballsTrail_Func2(struct Task *task) +static bool8 PokeballsTrail_Main(struct Task *task) { s16 i; s16 rand; - s16 arr0[ARRAY_COUNT(sUnknown_085C8B88)]; + s16 xCoords[ARRAY_COUNT(sUnknown_085C8B88)]; s16 arr1[ARRAY_COUNT(sUnknown_085C8B8C)]; - memcpy(arr0, sUnknown_085C8B88, sizeof(sUnknown_085C8B88)); + memcpy(xCoords, sUnknown_085C8B88, sizeof(sUnknown_085C8B88)); memcpy(arr1, sUnknown_085C8B8C, sizeof(sUnknown_085C8B8C)); rand = Random() & 1; for (i = 0; i <= 4; i++, rand ^= 1) { - gFieldEffectArguments[0] = arr0[rand]; // x + gFieldEffectArguments[0] = xCoords[rand]; // x gFieldEffectArguments[1] = (i * 32) + 16; // y gFieldEffectArguments[2] = rand; gFieldEffectArguments[3] = arr1[i]; @@ -1657,7 +1738,7 @@ static bool8 PokeballsTrail_Func2(struct Task *task) return FALSE; } -static bool8 PokeballsTrail_Func3(struct Task *task) +static bool8 PokeballsTrail_End(struct Task *task) { if (!FieldEffectActiveListContains(FLDEFF_POKEBALL)) { @@ -1667,27 +1748,31 @@ static bool8 PokeballsTrail_Func3(struct Task *task) return FALSE; } +#define sData0 data[0] +#define sData1 data[1] +#define sData2 data[2] + bool8 FldEff_Pokeball(void) { u8 spriteId = CreateSpriteAtEnd(&sSpriteTemplate_Pokeball, gFieldEffectArguments[0], gFieldEffectArguments[1], 0); gSprites[spriteId].oam.priority = 0; gSprites[spriteId].oam.affineMode = ST_OAM_AFFINE_NORMAL; - gSprites[spriteId].data[0] = gFieldEffectArguments[2]; - gSprites[spriteId].data[1] = gFieldEffectArguments[3]; - gSprites[spriteId].data[2] = -1; + gSprites[spriteId].sData0 = gFieldEffectArguments[2]; + gSprites[spriteId].sData1 = gFieldEffectArguments[3]; + gSprites[spriteId].sData2 = -1; InitSpriteAffineAnim(&gSprites[spriteId]); StartSpriteAffineAnim(&gSprites[spriteId], gFieldEffectArguments[2]); return FALSE; } -static void sub_814713C(struct Sprite *sprite) +static void SpriteCB_FldEffPokeball(struct Sprite *sprite) { s16 arr0[ARRAY_COUNT(sUnknown_085C8B96)]; memcpy(arr0, sUnknown_085C8B96, sizeof(sUnknown_085C8B96)); - if (sprite->data[1] != 0) + if (sprite->sData1 != 0) { - sprite->data[1]--; + sprite->sData1--; } else { @@ -1696,51 +1781,53 @@ static void sub_814713C(struct Sprite *sprite) s16 posX = sprite->x >> 3; s16 posY = sprite->y >> 3; - if (posX != sprite->data[2]) + if (posX != sprite->sData2) { u32 var; u16 *ptr; - sprite->data[2] = posX; + sprite->sData2 = posX; var = (((REG_BG0CNT >> 8) & 0x1F) << 11); ptr = (u16 *)(VRAM + var); - SOME_VRAM_STORE(ptr, posY - 2, posX, 0xF001); - SOME_VRAM_STORE(ptr, posY - 1, posX, 0xF001); - SOME_VRAM_STORE(ptr, posY - 0, posX, 0xF001); - SOME_VRAM_STORE(ptr, posY + 1, posX, 0xF001); + SET_TILEMAP_TILE(ptr, posY - 2, posX, 0xF001); + SET_TILEMAP_TILE(ptr, posY - 1, posX, 0xF001); + SET_TILEMAP_TILE(ptr, posY - 0, posX, 0xF001); + SET_TILEMAP_TILE(ptr, posY + 1, posX, 0xF001); } } - sprite->x += arr0[sprite->data[0]]; - if (sprite->x < -15 || sprite->x > 255) + sprite->x += arr0[sprite->sData0]; + if (sprite->x < -15 || sprite->x > DISPLAY_WIDTH + 15) FieldEffectStop(sprite, FLDEFF_POKEBALL); } } +#undef sData0 +#undef sData1 +#undef sData2 + static void Task_Clockwise_BlackFade(u8 taskId) { while (sClockwise_BlackFade_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static bool8 Clockwise_BlackFade_Func1(struct Task *task) +static bool8 Clockwise_BlackFade_Init(struct Task *task) { u16 i; - InitTransitionStructVars(); + InitTransitionData(); ScanlineEffect_Clear(); - sTransitionStructPtr->WININ = 0; - sTransitionStructPtr->WINOUT = WINOUT_WIN01_ALL; - sTransitionStructPtr->WIN0H = -3855; - sTransitionStructPtr->WIN0V = DISPLAY_HEIGHT; + sTransitionData->WININ = 0; + sTransitionData->WINOUT = WINOUT_WIN01_ALL; + sTransitionData->WIN0H = WIN_RANGE(DISPLAY_WIDTH, DISPLAY_WIDTH + 1); + sTransitionData->WIN0V = DISPLAY_HEIGHT; - for (i = 0; i < 160; i++) - { - gScanlineEffectRegBuffers[1][i] = 0xF3F4; - } + for (i = 0; i < DISPLAY_HEIGHT; i++) + gScanlineEffectRegBuffers[1][i] = WIN_RANGE(DISPLAY_WIDTH + 3, DISPLAY_WIDTH + 4); SetVBlankCallback(VBlankCB_Clockwise_BlackFade); - sTransitionStructPtr->data[4] = 120; + sTransitionData->data[4] = 120; task->tState++; return TRUE; @@ -1748,22 +1835,22 @@ static bool8 Clockwise_BlackFade_Func1(struct Task *task) static bool8 Clockwise_BlackFade_Func2(struct Task *task) { - sTransitionStructPtr->VBlank_DMA = FALSE; + sTransitionData->VBlank_DMA = FALSE; - sub_814A1AC(sTransitionStructPtr->data, 120, 80, sTransitionStructPtr->data[4], -1, 1, 1); + sub_814A1AC(sTransitionData->data, 120, 80, sTransitionData->data[4], -1, 1, 1); do { - gScanlineEffectRegBuffers[0][sTransitionStructPtr->data[3]] = (sTransitionStructPtr->data[2] + 1) | 0x7800; - } while (!sub_814A228(sTransitionStructPtr->data, 1, 1)); + gScanlineEffectRegBuffers[0][sTransitionData->data[3]] = (sTransitionData->data[2] + 1) | 0x7800; + } while (!sub_814A228(sTransitionData->data, 1, 1)); - sTransitionStructPtr->data[4] += 16; - if (sTransitionStructPtr->data[4] >= 240) + sTransitionData->data[4] += 16; + if (sTransitionData->data[4] >= DISPLAY_WIDTH) { - sTransitionStructPtr->data[5] = 0; + sTransitionData->data[5] = 0; task->tState++; } - sTransitionStructPtr->VBlank_DMA++; + sTransitionData->VBlank_DMA++; return FALSE; } @@ -1772,57 +1859,55 @@ static bool8 Clockwise_BlackFade_Func3(struct Task *task) s16 r1, r3; vu8 var = 0; - sTransitionStructPtr->VBlank_DMA = FALSE; + sTransitionData->VBlank_DMA = FALSE; - sub_814A1AC(sTransitionStructPtr->data, 120, 80, 240, sTransitionStructPtr->data[5], 1, 1); + sub_814A1AC(sTransitionData->data, 120, 80, 240, sTransitionData->data[5], 1, 1); while (1) { - r1 = 120, r3 = sTransitionStructPtr->data[2] + 1; - if (sTransitionStructPtr->data[5] >= 80) - r1 = sTransitionStructPtr->data[2], r3 = 240; - gScanlineEffectRegBuffers[0][sTransitionStructPtr->data[3]] = (r3) | (r1 << 8); + r1 = 120, r3 = sTransitionData->data[2] + 1; + if (sTransitionData->data[5] >= DISPLAY_HEIGHT / 2) + r1 = sTransitionData->data[2], r3 = DISPLAY_WIDTH; + gScanlineEffectRegBuffers[0][sTransitionData->data[3]] = (r3) | (r1 << 8); if (var != 0) break; - var = sub_814A228(sTransitionStructPtr->data, 1, 1); + var = sub_814A228(sTransitionData->data, 1, 1); } - sTransitionStructPtr->data[5] += 8; - if (sTransitionStructPtr->data[5] >= 160) + sTransitionData->data[5] += 8; + if (sTransitionData->data[5] >= DISPLAY_HEIGHT) { - sTransitionStructPtr->data[4] = 240; + sTransitionData->data[4] = DISPLAY_WIDTH; task->tState++; } else { - while (sTransitionStructPtr->data[3] < sTransitionStructPtr->data[5]) - { - gScanlineEffectRegBuffers[0][++sTransitionStructPtr->data[3]] = (r3) | (r1 << 8); - } + while (sTransitionData->data[3] < sTransitionData->data[5]) + gScanlineEffectRegBuffers[0][++sTransitionData->data[3]] = (r3) | (r1 << 8); } - sTransitionStructPtr->VBlank_DMA++; + sTransitionData->VBlank_DMA++; return FALSE; } static bool8 Clockwise_BlackFade_Func4(struct Task *task) { - sTransitionStructPtr->VBlank_DMA = FALSE; + sTransitionData->VBlank_DMA = FALSE; - sub_814A1AC(sTransitionStructPtr->data, 120, 80, sTransitionStructPtr->data[4], 160, 1, 1); + sub_814A1AC(sTransitionData->data, 120, 80, sTransitionData->data[4], 160, 1, 1); do { - gScanlineEffectRegBuffers[0][sTransitionStructPtr->data[3]] = (sTransitionStructPtr->data[2] << 8) | 0xF0; - } while (!sub_814A228(sTransitionStructPtr->data, 1, 1)); + gScanlineEffectRegBuffers[0][sTransitionData->data[3]] = (sTransitionData->data[2] << 8) | 0xF0; + } while (!sub_814A228(sTransitionData->data, 1, 1)); - sTransitionStructPtr->data[4] -= 16; - if (sTransitionStructPtr->data[4] <= 0) + sTransitionData->data[4] -= 16; + if (sTransitionData->data[4] <= 0) { - sTransitionStructPtr->data[5] = 160; + sTransitionData->data[5] = DISPLAY_HEIGHT; task->tState++; } - sTransitionStructPtr->VBlank_DMA++; + sTransitionData->VBlank_DMA++; return FALSE; } @@ -1831,66 +1916,66 @@ static bool8 Clockwise_BlackFade_Func5(struct Task *task) s16 r1, r2, var4; vu8 var = 0; - sTransitionStructPtr->VBlank_DMA = FALSE; + sTransitionData->VBlank_DMA = FALSE; - sub_814A1AC(sTransitionStructPtr->data, 120, 80, 0, sTransitionStructPtr->data[5], 1, 1); + sub_814A1AC(sTransitionData->data, 120, 80, 0, sTransitionData->data[5], 1, 1); while (1) { - r1 = (gScanlineEffectRegBuffers[0][sTransitionStructPtr->data[3]]) & 0xFF; - r2 = sTransitionStructPtr->data[2]; - if (sTransitionStructPtr->data[5] <= 80) - r2 = 120, r1 = sTransitionStructPtr->data[2]; + r1 = (gScanlineEffectRegBuffers[0][sTransitionData->data[3]]) & 0xFF; + r2 = sTransitionData->data[2]; + if (sTransitionData->data[5] <= DISPLAY_HEIGHT / 2) + r2 = 120, r1 = sTransitionData->data[2]; var4 = (r1) | (r2 << 8); - gScanlineEffectRegBuffers[0][sTransitionStructPtr->data[3]] = var4; + gScanlineEffectRegBuffers[0][sTransitionData->data[3]] = var4; if (var != 0) break; - var = sub_814A228(sTransitionStructPtr->data, 1, 1); + var = sub_814A228(sTransitionData->data, 1, 1); } - sTransitionStructPtr->data[5] -= 8; - if (sTransitionStructPtr->data[5] <= 0) + sTransitionData->data[5] -= 8; + if (sTransitionData->data[5] <= 0) { - sTransitionStructPtr->data[4] = 0; + sTransitionData->data[4] = 0; task->tState++; } else { - while (sTransitionStructPtr->data[3] > sTransitionStructPtr->data[5]) + while (sTransitionData->data[3] > sTransitionData->data[5]) { - gScanlineEffectRegBuffers[0][--sTransitionStructPtr->data[3]] = (r1) | (r2 << 8); + gScanlineEffectRegBuffers[0][--sTransitionData->data[3]] = (r1) | (r2 << 8); } } - sTransitionStructPtr->VBlank_DMA++; + sTransitionData->VBlank_DMA++; return FALSE; } static bool8 Clockwise_BlackFade_Func6(struct Task *task) { - sTransitionStructPtr->VBlank_DMA = FALSE; + sTransitionData->VBlank_DMA = FALSE; - sub_814A1AC(sTransitionStructPtr->data, 120, 80, sTransitionStructPtr->data[4], 0, 1, 1); + sub_814A1AC(sTransitionData->data, 120, 80, sTransitionData->data[4], 0, 1, 1); do { s16 r2, r3; - r2 = 120, r3 = sTransitionStructPtr->data[2]; - if (sTransitionStructPtr->data[2] >= 120) - r2 = 0, r3 = 240; - gScanlineEffectRegBuffers[0][sTransitionStructPtr->data[3]] = (r3) | (r2 << 8); + r2 = 120, r3 = sTransitionData->data[2]; + if (sTransitionData->data[2] >= 120) + r2 = 0, r3 = DISPLAY_WIDTH; + gScanlineEffectRegBuffers[0][sTransitionData->data[3]] = (r3) | (r2 << 8); - } while (!sub_814A228(sTransitionStructPtr->data, 1, 1)); + } while (!sub_814A228(sTransitionData->data, 1, 1)); - sTransitionStructPtr->data[4] += 16; - if (sTransitionStructPtr->data[2] > 120) + sTransitionData->data[4] += 16; + if (sTransitionData->data[2] > 120) task->tState++; - sTransitionStructPtr->VBlank_DMA++; + sTransitionData->VBlank_DMA++; return FALSE; } -static bool8 Clockwise_BlackFade_Func7(struct Task *task) +static bool8 Clockwise_BlackFade_End(struct Task *task) { DmaStop(0); FadeScreenBlack(); @@ -1902,13 +1987,13 @@ static void VBlankCB_Clockwise_BlackFade(void) { DmaStop(0); VBlankCB_BattleTransition(); - if (sTransitionStructPtr->VBlank_DMA != 0) - DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], 320); - REG_WININ = sTransitionStructPtr->WININ; - REG_WINOUT = sTransitionStructPtr->WINOUT; - REG_WIN0V = sTransitionStructPtr->WIN0V; + if (sTransitionData->VBlank_DMA != 0) + DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], DISPLAY_HEIGHT * 2); + REG_WININ = sTransitionData->WININ; + REG_WINOUT = sTransitionData->WINOUT; + REG_WIN0V = sTransitionData->WIN0V; REG_WIN0H = gScanlineEffectRegBuffers[1][0]; - DmaSet(0, gScanlineEffectRegBuffers[1], ®_WIN0H, 0xA2400001); + DmaSet(0, gScanlineEffectRegBuffers[1], ®_WIN0H, B_TRANS_DMA_FLAGS); } static void Task_Ripple(u8 taskId) @@ -1916,17 +2001,15 @@ static void Task_Ripple(u8 taskId) while (sRipple_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static bool8 Ripple_Func1(struct Task *task) +static bool8 Ripple_Init(struct Task *task) { u8 i; - InitTransitionStructVars(); + InitTransitionData(); ScanlineEffect_Clear(); - for (i = 0; i < 160; i++) - { - gScanlineEffectRegBuffers[1][i] = sTransitionStructPtr->field_16; - } + for (i = 0; i < DISPLAY_HEIGHT; i++) + gScanlineEffectRegBuffers[1][i] = sTransitionData->cameraY; SetVBlankCallback(VBlankCB_Ripple); SetHBlankCallback(HBlankCB_Ripple); @@ -1943,39 +2026,39 @@ static bool8 Ripple_Func2(struct Task *task) s16 r3; u16 r4, r8; - sTransitionStructPtr->VBlank_DMA = FALSE; + sTransitionData->VBlank_DMA = FALSE; - r3 = task->tData2 >> 8; - r4 = task->tData1; + r3 = task->data[2] >> 8; + r4 = task->data[1]; r8 = 384; - task->tData1 += 0x400; - if (task->tData2 <= 0x1FFF) - task->tData2 += 0x180; + task->data[1] += 0x400; + if (task->data[2] <= 0x1FFF) + task->data[2] += 0x180; - for (i = 0; i < 160; i++, r4 += r8) + for (i = 0; i < DISPLAY_HEIGHT; i++, r4 += r8) { s16 var = r4 >> 8; - gScanlineEffectRegBuffers[0][i] = sTransitionStructPtr->field_16 + Sin(var & 0xffff, r3); + gScanlineEffectRegBuffers[0][i] = sTransitionData->cameraY + Sin(var & 0xffff, r3); } - if (++task->tData3 == 81) + if (++task->data[3] == 81) { - task->tData4++; - BeginNormalPaletteFade(PALETTES_ALL, -2, 0, 0x10, RGB_BLACK); + task->data[4]++; + BeginNormalPaletteFade(PALETTES_ALL, -2, 0, 16, RGB_BLACK); } - if (task->tData4 != 0 && !gPaletteFade.active) + if (task->data[4] != 0 && !gPaletteFade.active) DestroyTask(FindTaskIdByFunc(Task_Ripple)); - sTransitionStructPtr->VBlank_DMA++; + sTransitionData->VBlank_DMA++; return FALSE; } static void VBlankCB_Ripple(void) { VBlankCB_BattleTransition(); - if (sTransitionStructPtr->VBlank_DMA) - DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], 320); + if (sTransitionData->VBlank_DMA) + DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], DISPLAY_HEIGHT * 2); } static void HBlankCB_Ripple(void) @@ -1986,27 +2069,26 @@ static void HBlankCB_Ripple(void) REG_BG3VOFS = var; } +// B_TRANSITION_WAVE static void Task_Wave(u8 taskId) { while (sWave_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static bool8 Wave_Func1(struct Task *task) +static bool8 Wave_Init(struct Task *task) { u8 i; - InitTransitionStructVars(); + InitTransitionData(); ScanlineEffect_Clear(); - sTransitionStructPtr->WININ = WININ_WIN0_ALL; - sTransitionStructPtr->WINOUT = 0; - sTransitionStructPtr->WIN0H = DISPLAY_WIDTH; - sTransitionStructPtr->WIN0V = DISPLAY_HEIGHT; + sTransitionData->WININ = WININ_WIN0_ALL; + sTransitionData->WINOUT = 0; + sTransitionData->WIN0H = DISPLAY_WIDTH; + sTransitionData->WIN0V = DISPLAY_HEIGHT; - for (i = 0; i < 160; i++) - { - gScanlineEffectRegBuffers[1][i] = 242; - } + for (i = 0; i < DISPLAY_HEIGHT; i++) + gScanlineEffectRegBuffers[1][i] = DISPLAY_WIDTH + 2; SetVBlankCallback(VBlankCB_Wave); @@ -2020,31 +2102,31 @@ static bool8 Wave_Func2(struct Task *task) u16* toStore; bool8 nextFunc; - sTransitionStructPtr->VBlank_DMA = FALSE; + sTransitionData->VBlank_DMA = FALSE; toStore = gScanlineEffectRegBuffers[0]; - r5 = task->tData2; - task->tData2 += 16; - task->tData1 += 8; + r5 = task->data[2]; + task->data[2] += 16; + task->data[1] += 8; - for (i = 0, nextFunc = TRUE; i < 160; i++, r5 += 4, toStore++) + for (i = 0, nextFunc = TRUE; i < DISPLAY_HEIGHT; i++, r5 += 4, toStore++) { - s16 value = task->tData1 + Sin(r5, 40); + s16 value = task->data[1] + Sin(r5, 40); if (value < 0) value = 0; - if (value > 240) - value = 240; - *toStore = (value << 8) | (0xF1); - if (value < 240) + if (value > DISPLAY_WIDTH) + value = DISPLAY_WIDTH; + *toStore = (value << 8) | (DISPLAY_WIDTH + 1); + if (value < DISPLAY_WIDTH) nextFunc = FALSE; } if (nextFunc) task->tState++; - sTransitionStructPtr->VBlank_DMA++; + sTransitionData->VBlank_DMA++; return FALSE; } -static bool8 Wave_Func3(struct Task *task) +static bool8 Wave_End(struct Task *task) { DmaStop(0); FadeScreenBlack(); @@ -2056,68 +2138,66 @@ static void VBlankCB_Wave(void) { DmaStop(0); VBlankCB_BattleTransition(); - if (sTransitionStructPtr->VBlank_DMA != 0) - DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], 320); - REG_WININ = sTransitionStructPtr->WININ; - REG_WINOUT = sTransitionStructPtr->WINOUT; - REG_WIN0V = sTransitionStructPtr->WIN0V; - DmaSet(0, gScanlineEffectRegBuffers[1], ®_WIN0H, 0xA2400001); + if (sTransitionData->VBlank_DMA != 0) + DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], DISPLAY_HEIGHT * 2); + REG_WININ = sTransitionData->WININ; + REG_WINOUT = sTransitionData->WINOUT; + REG_WIN0V = sTransitionData->WIN0V; + DmaSet(0, gScanlineEffectRegBuffers[1], ®_WIN0H, B_TRANS_DMA_FLAGS); } static void Task_Sidney(u8 taskId) { gTasks[taskId].tMugshotId = MUGSHOT_SIDNEY; - Task_MugShotTransition(taskId); + DoMugshotTransition(taskId); } static void Task_Phoebe(u8 taskId) { gTasks[taskId].tMugshotId = MUGSHOT_PHOEBE; - Task_MugShotTransition(taskId); + DoMugshotTransition(taskId); } static void Task_Glacia(u8 taskId) { gTasks[taskId].tMugshotId = MUGSHOT_GLACIA; - Task_MugShotTransition(taskId); + DoMugshotTransition(taskId); } static void Task_Drake(u8 taskId) { gTasks[taskId].tMugshotId = MUGSHOT_DRAKE; - Task_MugShotTransition(taskId); + DoMugshotTransition(taskId); } static void Task_Champion(u8 taskId) { gTasks[taskId].tMugshotId = MUGSHOT_CHAMPION; - Task_MugShotTransition(taskId); + DoMugshotTransition(taskId); } -static void Task_MugShotTransition(u8 taskId) +static void DoMugshotTransition(u8 taskId) { while (sMugshot_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static bool8 Mugshot_Func1(struct Task *task) +static bool8 Mugshot_Init(struct Task *task) { u8 i; - InitTransitionStructVars(); + InitTransitionData(); ScanlineEffect_Clear(); - Mugshots_CreateOpponentPlayerSprites(task); + Mugshots_CreateTrainerPics(task); - task->tData1 = 0; - task->tData2 = 1; - task->tData3 = 239; - sTransitionStructPtr->WININ = WININ_WIN0_ALL; - sTransitionStructPtr->WINOUT = WINOUT_WIN01_BG1 | WINOUT_WIN01_BG2 | WINOUT_WIN01_BG3 | WINOUT_WIN01_OBJ | WINOUT_WIN01_CLR; - sTransitionStructPtr->WIN0V = DISPLAY_HEIGHT; + task->data[1] = 0; + task->data[2] = 1; + task->data[3] = DISPLAY_WIDTH - 1; + sTransitionData->WININ = WININ_WIN0_ALL; + sTransitionData->WINOUT = WINOUT_WIN01_BG1 | WINOUT_WIN01_BG2 | WINOUT_WIN01_BG3 | WINOUT_WIN01_OBJ | WINOUT_WIN01_CLR; + sTransitionData->WIN0V = DISPLAY_HEIGHT; - for (i = 0; i < 160; i++) - { + for (i = 0; i < DISPLAY_HEIGHT; i++) gScanlineEffectRegBuffers[1][i] = 0xF0F1; - } SetVBlankCallback(VBlankCB0_Mugshots); @@ -2125,7 +2205,7 @@ static bool8 Mugshot_Func1(struct Task *task) return FALSE; } -static bool8 Mugshot_Func2(struct Task *task) +static bool8 Mugshot_SetGfx(struct Task *task) { s16 i, j; u16 *tilemap, *tileset; @@ -2140,9 +2220,7 @@ static bool8 Mugshot_Func2(struct Task *task) for (i = 0; i < 20; i++) { for (j = 0; j < 32; j++, mugshotsMap++) - { - SOME_VRAM_STORE(tilemap, i, j, *mugshotsMap | 0xF000); - } + SET_TILEMAP_TILE(tilemap, i, j, *mugshotsMap | 0xF000); } EnableInterrupts(INTR_FLAG_HBLANK); @@ -2152,72 +2230,71 @@ static bool8 Mugshot_Func2(struct Task *task) return FALSE; } -static bool8 Mugshot_Func3(struct Task *task) +static bool8 Mugshot_ShowBanner(struct Task *task) { u8 i, r5; u16* toStore; s16 value; s32 mergedValue; - sTransitionStructPtr->VBlank_DMA = FALSE; + sTransitionData->VBlank_DMA = FALSE; toStore = gScanlineEffectRegBuffers[0]; - r5 = task->tData1; - task->tData1 += 0x10; + r5 = task->data[1]; + task->data[1] += 16; - for (i = 0; i < 80; i++, toStore++, r5 += 0x10) + for (i = 0; i < DISPLAY_HEIGHT / 2; i++, toStore++, r5 += 16) { - value = task->tData2 + Sin(r5, 0x10); + value = task->data[2] + Sin(r5, 16); if (value < 0) value = 1; - if (value > 0xF0) - value = 0xF0; + if (value > DISPLAY_WIDTH) + value = DISPLAY_WIDTH; *toStore = value; } - for (; i < 160; i++, toStore++, r5 += 0x10) + for (; i < DISPLAY_HEIGHT; i++, toStore++, r5 += 16) { - value = task->tData3 - Sin(r5, 0x10); + value = task->data[3] - Sin(r5, 16); if (value < 0) value = 0; - if (value > 0xEF) - value = 0xEF; - *toStore = (value << 8) | (0xF0); + if (value > DISPLAY_WIDTH - 1) + value = DISPLAY_WIDTH - 1; + *toStore = (value << 8) | (DISPLAY_WIDTH); } - task->tData2 += 8; - task->tData3 -= 8; - if (task->tData2 > 0xF0) - task->tData2 = 0xF0; - if (task->tData3 < 0) - task->tData3 = 0; - mergedValue = *(s32*)(&task->tData2); - if (mergedValue == 0xF0) + task->data[2] += 8; + task->data[3] -= 8; + if (task->data[2] > DISPLAY_WIDTH) + task->data[2] = DISPLAY_WIDTH; + if (task->data[3] < 0) + task->data[3] = 0; + mergedValue = *(s32*)(&task->data[2]); + if (mergedValue == DISPLAY_WIDTH) task->tState++; - sTransitionStructPtr->BG0HOFS_1 -= 8; - sTransitionStructPtr->BG0HOFS_2 += 8; - sTransitionStructPtr->VBlank_DMA++; + sTransitionData->BG0HOFS_Lower -= 8; + sTransitionData->BG0HOFS_Upper += 8; + sTransitionData->VBlank_DMA++; return FALSE; } -static bool8 Mugshot_Func4(struct Task *task) +static bool8 Mugshot_StartOpponentSlide(struct Task *task) { u8 i; u16* toStore; - sTransitionStructPtr->VBlank_DMA = FALSE; + sTransitionData->VBlank_DMA = FALSE; - for (i = 0, toStore = gScanlineEffectRegBuffers[0]; i < 160; i++, toStore++) - { - *toStore = 0xF0; - } + for (i = 0, toStore = gScanlineEffectRegBuffers[0]; i < DISPLAY_HEIGHT; i++, toStore++) + *toStore = DISPLAY_WIDTH; task->tState++; - task->tData1 = 0; - task->tData2 = 0; - task->tData3 = 0; - sTransitionStructPtr->BG0HOFS_1 -= 8; - sTransitionStructPtr->BG0HOFS_2 += 8; + task->data[1] = 0; + task->data[2] = 0; + task->data[3] = 0; + + sTransitionData->BG0HOFS_Lower -= 8; + sTransitionData->BG0HOFS_Upper += 8; SetTrainerPicSlideTable(task->tOpponentSpriteId, 0); SetTrainerPicSlideTable(task->tPlayerSpriteId, 1); @@ -2225,14 +2302,16 @@ static bool8 Mugshot_Func4(struct Task *task) PlaySE(SE_MUGSHOT); - sTransitionStructPtr->VBlank_DMA++; + sTransitionData->VBlank_DMA++; return FALSE; } -static bool8 Mugshot_Func5(struct Task *task) +static bool8 Mugshot_WaitStartPlayerSlide(struct Task *task) { - sTransitionStructPtr->BG0HOFS_1 -= 8; - sTransitionStructPtr->BG0HOFS_2 += 8; + sTransitionData->BG0HOFS_Lower -= 8; + sTransitionData->BG0HOFS_Upper += 8; + + // Start player's pic slide in once the opponent is finished if (IsTrainerPicSlideDone(task->tOpponentSpriteId)) { task->tState++; @@ -2241,94 +2320,95 @@ static bool8 Mugshot_Func5(struct Task *task) return FALSE; } -static bool8 Mugshot_Func6(struct Task *task) +static bool8 Mugshot_WaitPlayerSlide(struct Task *task) { - sTransitionStructPtr->BG0HOFS_1 -= 8; - sTransitionStructPtr->BG0HOFS_2 += 8; + sTransitionData->BG0HOFS_Lower -= 8; + sTransitionData->BG0HOFS_Upper += 8; + if (IsTrainerPicSlideDone(task->tPlayerSpriteId)) { - sTransitionStructPtr->VBlank_DMA = FALSE; + sTransitionData->VBlank_DMA = FALSE; SetVBlankCallback(NULL); DmaStop(0); - memset(gScanlineEffectRegBuffers[0], 0, 0x140); - memset(gScanlineEffectRegBuffers[1], 0, 0x140); + memset(gScanlineEffectRegBuffers[0], 0, DISPLAY_HEIGHT * 2); + memset(gScanlineEffectRegBuffers[1], 0, DISPLAY_HEIGHT * 2); SetGpuReg(REG_OFFSET_WIN0H, DISPLAY_WIDTH); SetGpuReg(REG_OFFSET_BLDY, 0); task->tState++; - task->tData3 = 0; - task->tData4 = 0; - sTransitionStructPtr->BLDCNT = BLDCNT_TGT1_ALL | BLDCNT_EFFECT_LIGHTEN; + task->data[3] = 0; + task->data[4] = 0; + sTransitionData->BLDCNT = BLDCNT_TGT1_ALL | BLDCNT_EFFECT_LIGHTEN; SetVBlankCallback(VBlankCB1_Mugshots); } return FALSE; } -static bool8 Mugshot_Func7(struct Task *task) +static bool8 Mugshot_GradualWhiteFade(struct Task *task) { - bool32 r6; + bool32 active; - sTransitionStructPtr->VBlank_DMA = FALSE; - r6 = TRUE; - sTransitionStructPtr->BG0HOFS_1 -= 8; - sTransitionStructPtr->BG0HOFS_2 += 8; + sTransitionData->VBlank_DMA = FALSE; + active = TRUE; + sTransitionData->BG0HOFS_Lower -= 8; + sTransitionData->BG0HOFS_Upper += 8; - if (task->tData4 < 0x50) - task->tData4 += 2; - if (task->tData4 > 0x50) - task->tData4 = 0x50; + if (task->data[4] < DISPLAY_HEIGHT / 2) + task->data[4] += 2; + if (task->data[4] > DISPLAY_HEIGHT / 2) + task->data[4] = DISPLAY_HEIGHT / 2; - if (++task->tData3 & 1) + if (++task->data[3] & 1) { s16 i; - for (i = 0, r6 = FALSE; i <= task->tData4; i++) + for (i = 0, active = FALSE; i <= task->data[4]; i++) { - s16 index1 = 0x50 - i; - s16 index2 = 0x50 + i; + s16 index1 = DISPLAY_HEIGHT / 2 - i; + s16 index2 = DISPLAY_HEIGHT / 2 + i; if (gScanlineEffectRegBuffers[0][index1] <= 15) { - r6 = TRUE; + active = TRUE; gScanlineEffectRegBuffers[0][index1]++; } if (gScanlineEffectRegBuffers[0][index2] <= 15) { - r6 = TRUE; + active = TRUE; gScanlineEffectRegBuffers[0][index2]++; } } } - if (task->tData4 == 0x50 && !r6) + if (task->data[4] == DISPLAY_HEIGHT / 2 && !active) task->tState++; - sTransitionStructPtr->VBlank_DMA++; + sTransitionData->VBlank_DMA++; return FALSE; } -static bool8 Mugshot_Func8(struct Task *task) +static bool8 Mugshot_InitFadeWhiteToBlack(struct Task *task) { - sTransitionStructPtr->VBlank_DMA = FALSE; - BlendPalettes(PALETTES_ALL, 0x10, RGB_WHITE); - sTransitionStructPtr->BLDCNT = 0xFF; - task->tData3 = 0; + sTransitionData->VBlank_DMA = FALSE; + BlendPalettes(PALETTES_ALL, 16, RGB_WHITE); + sTransitionData->BLDCNT = 0xFF; + task->data[3] = 0; task->tState++; return TRUE; } -static bool8 Mugshot_Func9(struct Task *task) +static bool8 Mugshot_FadeToBlack(struct Task *task) { - sTransitionStructPtr->VBlank_DMA = FALSE; + sTransitionData->VBlank_DMA = FALSE; - task->tData3++; - memset(gScanlineEffectRegBuffers[0], task->tData3, 0x140); - if (task->tData3 > 15) + task->data[3]++; + memset(gScanlineEffectRegBuffers[0], task->data[3], DISPLAY_HEIGHT * 2); + if (task->data[3] > 15) task->tState++; - sTransitionStructPtr->VBlank_DMA++; + sTransitionData->VBlank_DMA++; return FALSE; } -static bool8 Mugshot_Func10(struct Task *task) +static bool8 Mugshot_End(struct Task *task) { DmaStop(0); FadeScreenBlack(); @@ -2340,31 +2420,31 @@ static void VBlankCB0_Mugshots(void) { DmaStop(0); VBlankCB_BattleTransition(); - if (sTransitionStructPtr->VBlank_DMA != 0) - DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], 320); - REG_BG0VOFS = sTransitionStructPtr->BG0VOFS; - REG_WININ = sTransitionStructPtr->WININ; - REG_WINOUT = sTransitionStructPtr->WINOUT; - REG_WIN0V = sTransitionStructPtr->WIN0V; - DmaSet(0, gScanlineEffectRegBuffers[1], ®_WIN0H, 0xA2400001); + if (sTransitionData->VBlank_DMA != 0) + DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], DISPLAY_HEIGHT * 2); + REG_BG0VOFS = sTransitionData->BG0VOFS; + REG_WININ = sTransitionData->WININ; + REG_WINOUT = sTransitionData->WINOUT; + REG_WIN0V = sTransitionData->WIN0V; + DmaSet(0, gScanlineEffectRegBuffers[1], ®_WIN0H, B_TRANS_DMA_FLAGS); } static void VBlankCB1_Mugshots(void) { DmaStop(0); VBlankCB_BattleTransition(); - if (sTransitionStructPtr->VBlank_DMA != 0) - DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], 320); - REG_BLDCNT = sTransitionStructPtr->BLDCNT; - DmaSet(0, gScanlineEffectRegBuffers[1], ®_BLDY, 0xA2400001); + if (sTransitionData->VBlank_DMA != 0) + DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], DISPLAY_HEIGHT * 2); + REG_BLDCNT = sTransitionData->BLDCNT; + DmaSet(0, gScanlineEffectRegBuffers[1], ®_BLDY, B_TRANS_DMA_FLAGS); } static void HBlankCB_Mugshots(void) { - if (REG_VCOUNT < 80) - REG_BG0HOFS = sTransitionStructPtr->BG0HOFS_1; + if (REG_VCOUNT < DISPLAY_HEIGHT / 2) + REG_BG0HOFS = sTransitionData->BG0HOFS_Lower; else - REG_BG0HOFS = sTransitionStructPtr->BG0HOFS_2; + REG_BG0HOFS = sTransitionData->BG0HOFS_Upper; } // data fields for player/opponent sprites in mugshots @@ -2374,7 +2454,7 @@ static void HBlankCB_Mugshots(void) #define sDone data[6] #define sSlideTableId data[7] -static void Mugshots_CreateOpponentPlayerSprites(struct Task *task) +static void Mugshots_CreateTrainerPics(struct Task *task) { struct Sprite *opponentSprite, *playerSprite; @@ -2383,13 +2463,16 @@ static void Mugshots_CreateOpponentPlayerSprites(struct Task *task) sMugshotsOpponentCoords[mugshotId][0] - 32, sMugshotsOpponentCoords[mugshotId][1] + 42, 0, gDecompressionBuffer); - task->tPlayerSpriteId = CreateTrainerSprite(PlayerGenderToFrontTrainerPicId(gSaveBlock2Ptr->playerGender), DISPLAY_WIDTH + 32, 106, 0, gDecompressionBuffer); + task->tPlayerSpriteId = CreateTrainerSprite(PlayerGenderToFrontTrainerPicId(gSaveBlock2Ptr->playerGender), + DISPLAY_WIDTH + 32, + 106, + 0, gDecompressionBuffer); opponentSprite = &gSprites[task->tOpponentSpriteId]; playerSprite = &gSprites[task->tPlayerSpriteId]; - opponentSprite->callback = SpriteCb_TrainerPic; - playerSprite->callback = SpriteCb_TrainerPic; + opponentSprite->callback = SpriteCB_MugshotTrainerPic; + playerSprite->callback = SpriteCB_MugshotTrainerPic; opponentSprite->oam.affineMode = ST_OAM_AFFINE_DOUBLE; playerSprite->oam.affineMode = ST_OAM_AFFINE_DOUBLE; @@ -2410,32 +2493,32 @@ static void Mugshots_CreateOpponentPlayerSprites(struct Task *task) SetOamMatrixRotationScaling(playerSprite->oam.matrixNum, -512, 512, 0); } -static void SpriteCb_TrainerPic(struct Sprite *sprite) +static void SpriteCB_MugshotTrainerPic(struct Sprite *sprite) { - while (sTrainerPicSpriteCbs[sprite->sState](sprite)); + while (sMugshotTrainerPicFuncs[sprite->sState](sprite)); } -static bool8 TrainerPicCb_Nothing(struct Sprite *sprite) +static bool8 MugshotTrainerPic_Nothing(struct Sprite *sprite) { return FALSE; } -static bool8 TrainerPicCb_SetSlideOffsets(struct Sprite *sprite) +static bool8 MugshotTrainerPic_SetSlideOffsets(struct Sprite *sprite) { - s16 offfsets1[ARRAY_COUNT(sTrainerPicSlideOffsets1)]; - s16 offfsets2[ARRAY_COUNT(sTrainerPicSlideOffsets2)]; + s16 offsets1[ARRAY_COUNT(sTrainerPicSlideOffsets1)]; + s16 offsets2[ARRAY_COUNT(sTrainerPicSlideOffsets2)]; - memcpy(offfsets1, sTrainerPicSlideOffsets1, sizeof(sTrainerPicSlideOffsets1)); - memcpy(offfsets2, sTrainerPicSlideOffsets2, sizeof(sTrainerPicSlideOffsets2)); + memcpy(offsets1, sTrainerPicSlideOffsets1, sizeof(sTrainerPicSlideOffsets1)); + memcpy(offsets2, sTrainerPicSlideOffsets2, sizeof(sTrainerPicSlideOffsets2)); sprite->sState++; - sprite->sOffsetX = offfsets1[sprite->sSlideTableId]; - sprite->sOffsetX2 = offfsets2[sprite->sSlideTableId]; + sprite->sOffsetX = offsets1[sprite->sSlideTableId]; + sprite->sOffsetX2 = offsets2[sprite->sSlideTableId]; return TRUE; } // fast slide to around middle screen -static bool8 TrainerPicCb_Slide1(struct Sprite *sprite) +static bool8 MugshotTrainerPic_Slide1(struct Sprite *sprite) { sprite->x += sprite->sOffsetX; if (sprite->sSlideTableId && sprite->x < 133) @@ -2446,7 +2529,7 @@ static bool8 TrainerPicCb_Slide1(struct Sprite *sprite) } // slower but accelerating slide -static bool8 TrainerPicCb_Slide2(struct Sprite *sprite) +static bool8 MugshotTrainerPic_Slide2(struct Sprite *sprite) { sprite->sOffsetX += sprite->sOffsetX2; sprite->x += sprite->sOffsetX; @@ -2460,11 +2543,11 @@ static bool8 TrainerPicCb_Slide2(struct Sprite *sprite) } // Has no practical effect -static bool8 TrainerPicCb_Slide3(struct Sprite *sprite) +static bool8 MugshotTrainerPic_Slide3(struct Sprite *sprite) { sprite->sOffsetX += sprite->sOffsetX2; sprite->x += sprite->sOffsetX; - if (sprite->x < -31 || sprite->x > 271) + if (sprite->x < -31 || sprite->x > DISPLAY_WIDTH + 31) sprite->sState++; return FALSE; } @@ -2495,24 +2578,24 @@ static void Task_Slice(u8 taskId) while (sSlice_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static bool8 Slice_Func1(struct Task *task) +static bool8 Slice_Init(struct Task *task) { u16 i; - InitTransitionStructVars(); + InitTransitionData(); ScanlineEffect_Clear(); - task->tData2 = 256; - task->tData3 = 1; - sTransitionStructPtr->WININ = WININ_WIN0_ALL; - sTransitionStructPtr->WINOUT = 0; - sTransitionStructPtr->WIN0V = DISPLAY_HEIGHT; - sTransitionStructPtr->VBlank_DMA = FALSE; + task->data[2] = 256; + task->data[3] = 1; + sTransitionData->WININ = WININ_WIN0_ALL; + sTransitionData->WINOUT = 0; + sTransitionData->WIN0V = DISPLAY_HEIGHT; + sTransitionData->VBlank_DMA = FALSE; - for (i = 0; i < 160; i++) + for (i = 0; i < DISPLAY_HEIGHT; i++) { - gScanlineEffectRegBuffers[1][i] = sTransitionStructPtr->field_14; - gScanlineEffectRegBuffers[1][160 + i] = 0xF0; + gScanlineEffectRegBuffers[1][i] = sTransitionData->cameraX; + gScanlineEffectRegBuffers[1][DISPLAY_HEIGHT + i] = DISPLAY_WIDTH; } EnableInterrupts(INTR_FLAG_HBLANK); @@ -2529,40 +2612,40 @@ static bool8 Slice_Func2(struct Task *task) { u16 i; - sTransitionStructPtr->VBlank_DMA = FALSE; + sTransitionData->VBlank_DMA = FALSE; - task->tData1 += (task->tData2 >> 8); - if (task->tData1 > 0xF0) - task->tData1 = 0xF0; - if (task->tData2 <= 0xFFF) - task->tData2 += task->tData3; - if (task->tData3 < 128) - task->tData3 <<= 1; // multiplying by two + task->data[1] += (task->data[2] >> 8); + if (task->data[1] > DISPLAY_WIDTH) + task->data[1] = DISPLAY_WIDTH; + if (task->data[2] <= 0xFFF) + task->data[2] += task->data[3]; + if (task->data[3] < 128) + task->data[3] <<= 1; // multiplying by two - for (i = 0; i < 160; i++) + for (i = 0; i < DISPLAY_HEIGHT; i++) { u16 *storeLoc1 = &gScanlineEffectRegBuffers[0][i]; - u16 *storeLoc2 = &gScanlineEffectRegBuffers[0][i + 160]; + u16 *storeLoc2 = &gScanlineEffectRegBuffers[0][i + DISPLAY_HEIGHT]; if (i & 1) { - *storeLoc1 = sTransitionStructPtr->field_14 + task->tData1; - *storeLoc2 = 0xF0 - task->tData1; + *storeLoc1 = sTransitionData->cameraX + task->data[1]; + *storeLoc2 = DISPLAY_WIDTH - task->data[1]; } else { - *storeLoc1 = sTransitionStructPtr->field_14 - task->tData1; - *storeLoc2 = (task->tData1 << 8) | (0xF1); + *storeLoc1 = sTransitionData->cameraX - task->data[1]; + *storeLoc2 = (task->data[1] << 8) | (DISPLAY_WIDTH + 1); } } - if (task->tData1 > 0xEF) + if (task->data[1] >= DISPLAY_WIDTH) task->tState++; - sTransitionStructPtr->VBlank_DMA++; + sTransitionData->VBlank_DMA++; return FALSE; } -static bool8 Slice_Func3(struct Task *task) +static bool8 Slice_End(struct Task *task) { DmaStop(0); FadeScreenBlack(); @@ -2574,17 +2657,17 @@ static void VBlankCB_Slice(void) { DmaStop(0); VBlankCB_BattleTransition(); - REG_WININ = sTransitionStructPtr->WININ; - REG_WINOUT = sTransitionStructPtr->WINOUT; - REG_WIN0V = sTransitionStructPtr->WIN0V; - if (sTransitionStructPtr->VBlank_DMA) - DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], 640); - DmaSet(0, &gScanlineEffectRegBuffers[1][160], ®_WIN0H, 0xA2400001); + REG_WININ = sTransitionData->WININ; + REG_WINOUT = sTransitionData->WINOUT; + REG_WIN0V = sTransitionData->WIN0V; + if (sTransitionData->VBlank_DMA) + DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], DISPLAY_HEIGHT * 4); + DmaSet(0, &gScanlineEffectRegBuffers[1][DISPLAY_HEIGHT], ®_WIN0H, B_TRANS_DMA_FLAGS); } static void HBlankCB_Slice(void) { - if (REG_VCOUNT < 160) + if (REG_VCOUNT < DISPLAY_HEIGHT) { u16 var = gScanlineEffectRegBuffers[1][REG_VCOUNT]; REG_BG1HOFS = var; @@ -2598,31 +2681,31 @@ static void Task_ShredSplit(u8 taskId) while (sShredSplit_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static bool8 ShredSplit_Func1(struct Task *task) +static bool8 ShredSplit_Init(struct Task *task) { u16 i; - InitTransitionStructVars(); + InitTransitionData(); ScanlineEffect_Clear(); - sTransitionStructPtr->WININ = WININ_WIN0_ALL; - sTransitionStructPtr->WINOUT = 0; - sTransitionStructPtr->WIN0V = DISPLAY_HEIGHT; + sTransitionData->WININ = WININ_WIN0_ALL; + sTransitionData->WINOUT = 0; + sTransitionData->WIN0V = DISPLAY_HEIGHT; - for (i = 0; i < 0xA0; i++) + for (i = 0; i < DISPLAY_HEIGHT; i++) { - gScanlineEffectRegBuffers[1][i] = sTransitionStructPtr->field_14; - gScanlineEffectRegBuffers[1][0xA0 + i] = 0xF0; - gScanlineEffectRegBuffers[0][i] = sTransitionStructPtr->field_14; - gScanlineEffectRegBuffers[0][0xA0 + i] = 0xF0; - gScanlineEffectRegBuffers[0][0x140 + i] = 0; - gScanlineEffectRegBuffers[0][0x1E0 + i] = 0x100; - gScanlineEffectRegBuffers[0][0x280 + i] = 1; + gScanlineEffectRegBuffers[1][i] = sTransitionData->cameraX; + gScanlineEffectRegBuffers[1][DISPLAY_HEIGHT + i] = DISPLAY_WIDTH; + gScanlineEffectRegBuffers[0][i] = sTransitionData->cameraX; + gScanlineEffectRegBuffers[0][DISPLAY_HEIGHT + i] = DISPLAY_WIDTH; + gScanlineEffectRegBuffers[0][DISPLAY_HEIGHT * 2 + i] = 0; + gScanlineEffectRegBuffers[0][DISPLAY_HEIGHT * 3 + i] = 256; + gScanlineEffectRegBuffers[0][DISPLAY_HEIGHT * 4 + i] = 1; } - task->tData4 = 0; - task->tData5 = 0; - task->tData6 = 7; + task->data[4] = 0; + task->data[5] = 0; + task->data[6] = 7; EnableInterrupts(INTR_FLAG_HBLANK); @@ -2645,10 +2728,10 @@ static bool8 ShredSplit_Func2(struct Task *task) memcpy(arr1, gUnknown_085C8C64, sizeof(arr1)); memcpy(arr2, gUnknown_085C8C66, sizeof(arr2)); - sTransitionStructPtr->VBlank_DMA = FALSE; + sTransitionData->VBlank_DMA = FALSE; var = 0; - for (i = 0; i <= task->tData5; i++) + for (i = 0; i <= task->data[5]; i++) { for (j = 0; j < 2; j++) { @@ -2657,12 +2740,12 @@ static bool8 ShredSplit_Func2(struct Task *task) unkVar = (arr1[j]) + (arr2[k] * -(i) * 2); if (unkVar >= 0 && (unkVar != 79 || j != 1)) { - ptr4 = &gScanlineEffectRegBuffers[0][unkVar + 320]; - ptr3 = &gScanlineEffectRegBuffers[0][unkVar + 480]; - ptr1 = &gScanlineEffectRegBuffers[0][unkVar + 640]; - if (*ptr4 > 0xEF) + ptr4 = &gScanlineEffectRegBuffers[0][unkVar + DISPLAY_HEIGHT * 2]; + ptr3 = &gScanlineEffectRegBuffers[0][unkVar + DISPLAY_HEIGHT * 3]; + ptr1 = &gScanlineEffectRegBuffers[0][unkVar + DISPLAY_HEIGHT * 4]; + if (*ptr4 >= DISPLAY_WIDTH) { - *ptr4 = 0xF0; + *ptr4 = DISPLAY_WIDTH; var++; } else @@ -2674,9 +2757,9 @@ static bool8 ShredSplit_Func2(struct Task *task) *ptr3 += *ptr1; } ptr2 = &gScanlineEffectRegBuffers[0][unkVar]; - ptr3 = &gScanlineEffectRegBuffers[0][unkVar + 160]; - *ptr2 = sTransitionStructPtr->field_14 + *ptr4; - *ptr3 = 0xF0 - *ptr4; + ptr3 = &gScanlineEffectRegBuffers[0][unkVar + DISPLAY_HEIGHT]; + *ptr2 = sTransitionData->cameraX + *ptr4; + *ptr3 = DISPLAY_WIDTH - *ptr4; if (i == 0) break; @@ -2689,14 +2772,14 @@ static bool8 ShredSplit_Func2(struct Task *task) for (k = 0; k < 2; k++) { unkVar = (arr1[j] + 1) + (arr2[k] * -(i) * 2); - if (unkVar <= 160 && (unkVar != 80 || j != 1)) + if (unkVar <= DISPLAY_HEIGHT && (unkVar != DISPLAY_HEIGHT / 2 || j != 1)) { - ptr4 = &gScanlineEffectRegBuffers[0][unkVar + 320]; - ptr3 = &gScanlineEffectRegBuffers[0][unkVar + 480]; - ptr1 = &gScanlineEffectRegBuffers[0][unkVar + 640]; - if (*ptr4 > 0xEF) + ptr4 = &gScanlineEffectRegBuffers[0][unkVar + DISPLAY_HEIGHT * 2]; + ptr3 = &gScanlineEffectRegBuffers[0][unkVar + DISPLAY_HEIGHT * 3]; + ptr1 = &gScanlineEffectRegBuffers[0][unkVar + DISPLAY_HEIGHT * 4]; + if (*ptr4 >= DISPLAY_WIDTH) { - *ptr4 = 0xF0; + *ptr4 = DISPLAY_WIDTH; var++; } else @@ -2708,9 +2791,9 @@ static bool8 ShredSplit_Func2(struct Task *task) *ptr3 += *ptr1; } ptr2 = &gScanlineEffectRegBuffers[0][unkVar]; - ptr3 = &gScanlineEffectRegBuffers[0][unkVar + 160]; - *ptr2 = sTransitionStructPtr->field_14 - *ptr4; - *ptr3 = (*ptr4 << 8) | (0xF1); + ptr3 = &gScanlineEffectRegBuffers[0][unkVar + DISPLAY_HEIGHT]; + *ptr2 = sTransitionData->cameraX - *ptr4; + *ptr3 = (*ptr4 << 8) | (DISPLAY_WIDTH + 1); if (i == 0) break; @@ -2719,14 +2802,14 @@ static bool8 ShredSplit_Func2(struct Task *task) } } - if (--task->tData4 < 0) - task->tData4 = 0; - if (task->tData4 <= 0 && task->tData5 + 1 <= 20) - task->tData4 = task->tData6, task->tData5++; - if (var > 0x9F) + if (--task->data[4] < 0) + task->data[4] = 0; + if (task->data[4] <= 0 && task->data[5] + 1 <= 20) + task->data[4] = task->data[6], task->data[5]++; + if (var >= DISPLAY_HEIGHT) task->tState++; - sTransitionStructPtr->VBlank_DMA++; + sTransitionData->VBlank_DMA++; return FALSE; } @@ -2740,9 +2823,9 @@ static bool8 ShredSplit_Func3(struct Task *task) bool32 done = TRUE; u16 checkVar2 = 0xFF10; - for (i = 0; i < 0xA0; i++) + for (i = 0; i < DISPLAY_HEIGHT; i++) { - if (gScanlineEffectRegBuffers[1][i] != 0xF0 && gScanlineEffectRegBuffers[1][i] != checkVar2) + if (gScanlineEffectRegBuffers[1][i] != DISPLAY_WIDTH && gScanlineEffectRegBuffers[1][i] != checkVar2) done = FALSE; // a break statement should be put here } @@ -2752,7 +2835,7 @@ static bool8 ShredSplit_Func3(struct Task *task) return FALSE; } -static bool8 ShredSplit_Func4(struct Task *task) +static bool8 ShredSplit_End(struct Task *task) { DmaStop(0); FadeScreenBlack(); @@ -2770,28 +2853,26 @@ static void Task_Blackhole2(u8 taskId) while (sBlackhole2_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static bool8 Blackhole_Func1(struct Task *task) +static bool8 Blackhole_Init(struct Task *task) { s32 i; - InitTransitionStructVars(); + InitTransitionData(); ScanlineEffect_Clear(); - sTransitionStructPtr->WININ = 0; - sTransitionStructPtr->WINOUT = WINOUT_WIN01_ALL; - sTransitionStructPtr->WIN0H = DISPLAY_WIDTH; - sTransitionStructPtr->WIN0V = DISPLAY_HEIGHT; + sTransitionData->WININ = 0; + sTransitionData->WINOUT = WINOUT_WIN01_ALL; + sTransitionData->WIN0H = DISPLAY_WIDTH; + sTransitionData->WIN0V = DISPLAY_HEIGHT; - for (i = 0; i < 0xA0; i++) - { + for (i = 0; i < DISPLAY_HEIGHT; i++) gScanlineEffectRegBuffers[1][i] = 0; - } SetVBlankCallback(VBlankCB1_BigPokeball); task->tState++; - task->tData1 = 1; - task->tData2 = 0x100; + task->data[1] = 1; + task->data[2] = 0x100; task->tFuncState = 0; return FALSE; @@ -2807,22 +2888,22 @@ static bool8 Blackhole1_Func3(struct Task *task) } else { - sTransitionStructPtr->VBlank_DMA = FALSE; - if (task->tData2 < 0x400) - task->tData2 += 0x80; - if (task->tData1 < 0xA0) - task->tData1 += (task->tData2 >> 8); - if (task->tData1 > 0xA0) - task->tData1 = 0xA0; - sub_814A014(gScanlineEffectRegBuffers[0], 0x78, 0x50, task->tData1); - if (task->tData1 == 0xA0) + sTransitionData->VBlank_DMA = FALSE; + if (task->data[2] < 1024) + task->data[2] += 128; + if (task->data[1] < DISPLAY_HEIGHT) + task->data[1] += (task->data[2] >> 8); + if (task->data[1] > DISPLAY_HEIGHT) + task->data[1] = DISPLAY_HEIGHT; + sub_814A014(gScanlineEffectRegBuffers[0], 120, 80, task->data[1]); + if (task->data[1] == DISPLAY_HEIGHT) { task->tFuncState = 1; FadeScreenBlack(); } else { - sTransitionStructPtr->VBlank_DMA++; + sTransitionData->VBlank_DMA++; } } @@ -2831,23 +2912,23 @@ static bool8 Blackhole1_Func3(struct Task *task) static bool8 Blackhole1_Func2(struct Task *task) { - sTransitionStructPtr->VBlank_DMA = FALSE; + sTransitionData->VBlank_DMA = FALSE; if (task->tFuncState == 0) { task->tFuncState++; - task->tData1 = 0x30; - task->tData6 = 0; + task->data[1] = 0x30; + task->data[6] = 0; } - task->tData1 += gUnknown_085C8C80[task->tData6]; - task->tData6 = (task->tData6 + 1) % 2; - sub_814A014(gScanlineEffectRegBuffers[0], 0x78, 0x50, task->tData1); - if (task->tData1 < 9) + task->data[1] += gUnknown_085C8C80[task->data[6]]; + task->data[6] = (task->data[6] + 1) % 2; + sub_814A014(gScanlineEffectRegBuffers[0], 120, 80, task->data[1]); + if (task->data[1] < 9) { task->tState++; task->tFuncState = 0; } - sTransitionStructPtr->VBlank_DMA++; + sTransitionData->VBlank_DMA++; return FALSE; } @@ -2856,43 +2937,43 @@ static bool8 Blackhole2_Func2(struct Task *task) u16 index; // should be s16 I think s16 amplitude; - sTransitionStructPtr->VBlank_DMA = FALSE; + sTransitionData->VBlank_DMA = FALSE; if (task->tFuncState == 0) { task->tFuncState++; - task->tData5 = 2; - task->tData6 = 2; + task->data[5] = 2; + task->data[6] = 2; } - if (task->tData1 > 0xA0) - task->tData1 = 0xA0; + if (task->data[1] > DISPLAY_HEIGHT) + task->data[1] = DISPLAY_HEIGHT; - sub_814A014(gScanlineEffectRegBuffers[0], 0x78, 0x50, task->tData1); - if (task->tData1 == 0xA0) + sub_814A014(gScanlineEffectRegBuffers[0], 120, 80, task->data[1]); + if (task->data[1] == DISPLAY_HEIGHT) { DmaStop(0); FadeScreenBlack(); DestroyTask(FindTaskIdByFunc(task->func)); } - index = task->tData5; - if ((task->tData5 & 0xFF) <= 128) + index = task->data[5]; + if ((task->data[5] & 0xFF) <= 128) { - amplitude = task->tData6; - task->tData5 += 8; + amplitude = task->data[6]; + task->data[5] += 8; } else { - amplitude = task->tData6 - 1; - task->tData5 += 16; + amplitude = task->data[6] - 1; + task->data[5] += 16; } - task->tData1 += Sin(index & 0xFF, amplitude); + task->data[1] += Sin(index & 0xFF, amplitude); - if (task->tData1 <= 0) - task->tData1 = 1; - if (task->tData5 > 0xFE) - task->tData5 >>= 8, task->tData6++; + if (task->data[1] <= 0) + task->data[1] = 1; + if (task->data[5] > 0xFE) + task->data[5] >>= 8, task->data[6]++; - sTransitionStructPtr->VBlank_DMA++; + sTransitionData->VBlank_DMA++; return FALSE; } @@ -2901,17 +2982,17 @@ static void Task_RectangularSpiral(u8 taskId) while (sRectangularSpiral_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static bool8 RectangularSpiral_Func1(struct Task *task) +static bool8 RectangularSpiral_Init(struct Task *task) { u16 *tilemap, *tileset; GetBg0TilesDst(&tilemap, &tileset); CpuCopy16(sShrinkingBoxTileset, tileset, 0x20); CpuCopy16(sShrinkingBoxTileset + 0x70, tileset + 0x20, 0x20); - CpuFill16(0xF000, tilemap, 0x800); - LoadPalette(sFieldEffectPal_Pokeball, 0xF0, 0x20); + CpuFill16(0xF000, tilemap, BG_SCREEN_SIZE); + LoadPalette(sFieldEffectPal_Pokeball, 0xF0, sizeof(sFieldEffectPal_Pokeball)); - task->tData3 = 1; + task->data[3] = 1; task->tState++; sRectangularSpiralTransition[0].field_0 = 0; @@ -2967,7 +3048,7 @@ static bool8 RectangularSpiral_Func2(struct Task *task) var2 = var % 32; var3 = var / 32; - SOME_VRAM_STORE(tilemap, var3, var2, 0xF002); + SET_TILEMAP_TILE(tilemap, var3, var2, 0xF002); } } } @@ -2977,7 +3058,7 @@ static bool8 RectangularSpiral_Func2(struct Task *task) return FALSE; } -static bool8 RectangularSpiral_Func3(struct Task *task) +static bool8 RectangularSpiral_End(struct Task *task) { DmaStop(0); FadeScreenBlack(); @@ -3053,53 +3134,55 @@ static void Task_Groudon(u8 taskId) while (sGroudon_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static bool8 Groudon_Func3(struct Task *task) +static bool8 Groudon_Init(struct Task *task) { u16 *tilemap, *tileset; GetBg0TilesDst(&tilemap, &tileset); - CpuFill16(0, tilemap, 0x800); + CpuFill16(0, tilemap, BG_SCREEN_SIZE); LZ77UnCompVram(sGroudon_Tileset, tileset); LZ77UnCompVram(sGroudon_Tilemap, tilemap); task->tState++; - task->tData1 = 0; + task->data[1] = 0; return FALSE; } -static bool8 Groudon_Func4(struct Task *task) +static bool8 Groudon_PalettePulsate(struct Task *task) { - if (task->tData1 % 3 == 0) + if (task->data[1] % 3 == 0) { - u16 var = (task->tData1 % 30) / 3; + u16 var = (task->data[1] % 30) / 3; LoadPalette(sGroudon1_Palette + (var * 16), 0xF0, 0x20); } - if (++task->tData1 > 58) + if (++task->data[1] > 58) { task->tState++; - task->tData1 = 0; + task->data[1] = 0; } return FALSE; } -static bool8 Groudon_Func5(struct Task *task) +static bool8 Groudon_PaletteBrighten(struct Task *task) { - if (task->tData1 % 5 == 0) + if (task->data[1] % 5 == 0) { - s16 var = task->tData1 / 5; + s16 var = task->data[1] / 5; LoadPalette(sGroudon2_Palette + (var * 16), 0xF0, 0x20); } - if (++task->tData1 > 68) + if (++task->data[1] > 68) { task->tState++; - task->tData1 = 0; - task->tFrames = 30; + task->data[1] = 0; + task->tEndDelay = 30; } return FALSE; } +#undef tEndDelay + static void Task_Rayquaza(u8 taskId) { while (sRayquaza_Funcs[gTasks[taskId].tState](&gTasks[taskId])); @@ -3110,19 +3193,19 @@ static bool8 Rayquaza_Func3(struct Task *task) u16 *tilemap, *tileset; u16 i; - InitTransitionStructVars(); + InitTransitionData(); ScanlineEffect_Clear(); SetGpuReg(REG_OFFSET_BG0CNT, BGCNT_CHARBASE(2) | BGCNT_SCREENBASE(26) | BGCNT_TXT256x512); GetBg0TilesDst(&tilemap, &tileset); - CpuFill16(0, tilemap, 0x800); + CpuFill16(0, tilemap, BG_SCREEN_SIZE); CpuCopy16(sRayquaza_Tileset, tileset, 0x2000); - sTransitionStructPtr->field_20 = 0; + sTransitionData->field_20 = 0; task->tState++; LoadPalette(sRayquaza_Palette + 0x50, 0xF0, 0x20); - for (i = 0; i < 160; i++) + for (i = 0; i < DISPLAY_HEIGHT; i++) { gScanlineEffectRegBuffers[0][i] = 0; gScanlineEffectRegBuffers[1][i] = 0x100; @@ -3137,23 +3220,23 @@ static bool8 Rayquaza_Func4(struct Task *task) u16 *tilemap, *tileset; GetBg0TilesDst(&tilemap, &tileset); - CpuCopy16(sRayquaza_Tilemap, tilemap, 0x1000); + CpuCopy16(sRayquaza_Tilemap, tilemap, sizeof(sRayquaza_Tilemap)); task->tState++; return FALSE; } static bool8 Rayquaza_Func5(struct Task *task) { - if ((task->tData1 % 4) == 0) + if ((task->data[1] % 4) == 0) { - u16 value = task->tData1 / 4; + u16 value = task->data[1] / 4; const u16 *palPtr = &sRayquaza_Palette[(value + 5) * 16]; LoadPalette(palPtr, 0xF0, 0x20); } - if (++task->tData1 > 40) + if (++task->data[1] > 40) { task->tState++; - task->tData1 = 0; + task->data[1] = 0; } return FALSE; @@ -3161,11 +3244,11 @@ static bool8 Rayquaza_Func5(struct Task *task) static bool8 Rayquaza_Func6(struct Task *task) { - if (++task->tData1 > 20) + if (++task->data[1] > 20) { task->tState++; - task->tData1 = 0; - BeginNormalPaletteFade(PALETTES_OBJECTS | 0x8000, 2, 0, 0x10, RGB_BLACK); + task->data[1] = 0; + BeginNormalPaletteFade(PALETTES_OBJECTS | (1 << 15), 2, 0, 16, RGB_BLACK); } return FALSE; @@ -3175,7 +3258,7 @@ static bool8 Rayquaza_Func7(struct Task *task) { if (!gPaletteFade.active) { - sTransitionStructPtr->field_20 = 1; + sTransitionData->field_20 = 1; task->tState++; } @@ -3184,8 +3267,8 @@ static bool8 Rayquaza_Func7(struct Task *task) static bool8 Rayquaza_Func8(struct Task *task) { - BlendPalettes(PALETTES_BG & ~(0x8000), 8, 0); - BlendPalettes(PALETTES_OBJECTS | 0x8000, 0, 0); + BlendPalettes(PALETTES_BG & ~(1 << 15), 8, RGB_BLACK); + BlendPalettes(PALETTES_OBJECTS | (1 << 15), 0, RGB_BLACK); task->tState++; return FALSE; @@ -3193,29 +3276,27 @@ static bool8 Rayquaza_Func8(struct Task *task) static bool8 Rayquaza_Func9(struct Task *task) { - if ((task->tData1 % 3) == 0) + if ((task->data[1] % 3) == 0) { - u16 value = task->tData1 / 3; + u16 value = task->data[1] / 3; const u16 *palPtr = &sRayquaza_Palette[(value + 0) * 16]; LoadPalette(palPtr, 0xF0, 0x20); } - if (++task->tData1 >= 40) + if (++task->data[1] >= 40) { u16 i; - sTransitionStructPtr->WININ = 0; - sTransitionStructPtr->WINOUT = WINOUT_WIN01_ALL; - sTransitionStructPtr->WIN0H = DISPLAY_WIDTH; - sTransitionStructPtr->WIN0V = DISPLAY_HEIGHT; + sTransitionData->WININ = 0; + sTransitionData->WINOUT = WINOUT_WIN01_ALL; + sTransitionData->WIN0H = DISPLAY_WIDTH; + sTransitionData->WIN0V = DISPLAY_HEIGHT; - for (i = 0; i < 160; i++) - { + for (i = 0; i < DISPLAY_HEIGHT; i++) gScanlineEffectRegBuffers[1][i] = 0; - } SetVBlankCallback(VBlankCB1_BigPokeball); task->tState++; - task->tData2 = 0x100; + task->data[2] = 0x100; task->tFuncState = 0; ClearGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_BG0_ON); } @@ -3230,14 +3311,14 @@ static void VBlankCB_Rayquaza(void) DmaStop(0); VBlankCB_BattleTransition(); - if (sTransitionStructPtr->field_20 == 0) + if (sTransitionData->field_20 == 0) dmaSrc = gScanlineEffectRegBuffers[0]; - else if (sTransitionStructPtr->field_20 == 1) + else if (sTransitionData->field_20 == 1) dmaSrc = gScanlineEffectRegBuffers[1]; else dmaSrc = gScanlineEffectRegBuffers[0]; - DmaSet(0, dmaSrc, ®_BG0VOFS, 0xA2400001); + DmaSet(0, dmaSrc, ®_BG0VOFS, B_TRANS_DMA_FLAGS); } static void Task_WhiteFade(u8 taskId) @@ -3245,23 +3326,23 @@ static void Task_WhiteFade(u8 taskId) while (sWhiteFade_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static bool8 WhiteFade_Func1(struct Task *task) +static bool8 WhiteFade_Init(struct Task *task) { u16 i; - InitTransitionStructVars(); + InitTransitionData(); ScanlineEffect_Clear(); - sTransitionStructPtr->BLDCNT = BLDCNT_TGT1_ALL | BLDCNT_EFFECT_LIGHTEN; - sTransitionStructPtr->BLDY = 0; - sTransitionStructPtr->WININ = WININ_WIN0_BG1 | WININ_WIN0_BG2 | WININ_WIN0_BG3 | WININ_WIN0_OBJ; - sTransitionStructPtr->WINOUT = WINOUT_WIN01_ALL; - sTransitionStructPtr->WIN0V = DISPLAY_HEIGHT; + sTransitionData->BLDCNT = BLDCNT_TGT1_ALL | BLDCNT_EFFECT_LIGHTEN; + sTransitionData->BLDY = 0; + sTransitionData->WININ = WININ_WIN0_BG1 | WININ_WIN0_BG2 | WININ_WIN0_BG3 | WININ_WIN0_OBJ; + sTransitionData->WINOUT = WINOUT_WIN01_ALL; + sTransitionData->WIN0V = DISPLAY_HEIGHT; - for (i = 0; i < 160; i++) + for (i = 0; i < DISPLAY_HEIGHT; i++) { gScanlineEffectRegBuffers[1][i] = 0; - gScanlineEffectRegBuffers[1][i + 160] = 0xF0; + gScanlineEffectRegBuffers[1][i + DISPLAY_HEIGHT] = DISPLAY_WIDTH; } EnableInterrupts(INTR_FLAG_HBLANK); @@ -3279,10 +3360,10 @@ static bool8 WhiteFade_Func2(struct Task *task) struct Sprite *sprite; memcpy(arr1, sUnknown_085C8DA0, sizeof(sUnknown_085C8DA0)); - for (i = 0, posY = 0; i < 8; i++, posY += 0x14) + for (i = 0, posY = 0; i < 8; i++, posY += 20) { sprite = &gSprites[CreateInvisibleSprite(sub_8149864)]; - sprite->x = 0xF0; + sprite->x = DISPLAY_WIDTH; sprite->y = posY; sprite->data[5] = arr1[i]; } @@ -3294,10 +3375,10 @@ static bool8 WhiteFade_Func2(struct Task *task) static bool8 WhiteFade_Func3(struct Task *task) { - sTransitionStructPtr->VBlank_DMA = 0; - if (sTransitionStructPtr->field_20 > 7) + sTransitionData->VBlank_DMA = 0; + if (sTransitionData->field_20 > 7) { - BlendPalettes(PALETTES_ALL, 0x10, 0x7FFF); + BlendPalettes(PALETTES_ALL, 16, RGB_WHITE); task->tState++; } return FALSE; @@ -3305,16 +3386,16 @@ static bool8 WhiteFade_Func3(struct Task *task) static bool8 WhiteFade_Func4(struct Task *task) { - sTransitionStructPtr->VBlank_DMA = 0; + sTransitionData->VBlank_DMA = 0; DmaStop(0); SetVBlankCallback(0); SetHBlankCallback(0); - sTransitionStructPtr->WIN0H = DISPLAY_WIDTH; - sTransitionStructPtr->BLDY = 0; - sTransitionStructPtr->BLDCNT = 0xFF; - sTransitionStructPtr->WININ = WININ_WIN0_ALL; + sTransitionData->WIN0H = DISPLAY_WIDTH; + sTransitionData->BLDY = 0; + sTransitionData->BLDCNT = 0xFF; + sTransitionData->WININ = WININ_WIN0_ALL; SetVBlankCallback(VBlankCB1_WhiteFade); @@ -3322,9 +3403,9 @@ static bool8 WhiteFade_Func4(struct Task *task) return FALSE; } -static bool8 WhiteFade_Func5(struct Task *task) +static bool8 WhiteFade_End(struct Task *task) { - if (++sTransitionStructPtr->BLDY > 16) + if (++sTransitionData->BLDY > 16) { FadeScreenBlack(); DestroyTask(FindTaskIdByFunc(Task_WhiteFade)); @@ -3336,24 +3417,24 @@ static void VBlankCB0_WhiteFade(void) { DmaStop(0); VBlankCB_BattleTransition(); - REG_BLDCNT = sTransitionStructPtr->BLDCNT; - REG_WININ = sTransitionStructPtr->WININ; - REG_WINOUT = sTransitionStructPtr->WINOUT; - REG_WIN0V = sTransitionStructPtr->WIN0V; - if (sTransitionStructPtr->VBlank_DMA) - DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], 640); - DmaSet(0, &gScanlineEffectRegBuffers[1][160], ®_WIN0H, 0xA2400001); + REG_BLDCNT = sTransitionData->BLDCNT; + REG_WININ = sTransitionData->WININ; + REG_WINOUT = sTransitionData->WINOUT; + REG_WIN0V = sTransitionData->WIN0V; + if (sTransitionData->VBlank_DMA) + DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], DISPLAY_HEIGHT * 4); + DmaSet(0, &gScanlineEffectRegBuffers[1][DISPLAY_HEIGHT], ®_WIN0H, B_TRANS_DMA_FLAGS); } static void VBlankCB1_WhiteFade(void) { VBlankCB_BattleTransition(); - REG_BLDY = sTransitionStructPtr->BLDY; - REG_BLDCNT = sTransitionStructPtr->BLDCNT; - REG_WININ = sTransitionStructPtr->WININ; - REG_WINOUT = sTransitionStructPtr->WINOUT; - REG_WIN0H = sTransitionStructPtr->WIN0H; - REG_WIN0V = sTransitionStructPtr->WIN0V; + REG_BLDY = sTransitionData->BLDY; + REG_BLDCNT = sTransitionData->BLDCNT; + REG_WININ = sTransitionData->WININ; + REG_WINOUT = sTransitionData->WINOUT; + REG_WIN0H = sTransitionData->WIN0H; + REG_WIN0V = sTransitionData->WIN0V; } static void HBlankCB_WhiteFade(void) @@ -3367,13 +3448,13 @@ static void sub_8149864(struct Sprite *sprite) { sprite->data[5]--; if (sprite->data[6]) - sTransitionStructPtr->VBlank_DMA = 1; + sTransitionData->VBlank_DMA = 1; } else { u16 i; u16* ptr1 = &gScanlineEffectRegBuffers[0][sprite->y]; - u16* ptr2 = &gScanlineEffectRegBuffers[0][sprite->y + 160]; + u16* ptr2 = &gScanlineEffectRegBuffers[0][sprite->y + DISPLAY_HEIGHT]; for (i = 0; i < 20; i++) { ptr1[i] = sprite->data[0] >> 8; @@ -3391,13 +3472,13 @@ static void sub_8149864(struct Sprite *sprite) sprite->data[0] = 0x1000; if (sprite->data[6]) - sTransitionStructPtr->VBlank_DMA = 1; + sTransitionData->VBlank_DMA = 1; if (sprite->data[1]) { - if (sprite->data[6] == 0 || (sTransitionStructPtr->field_20 > 6 && sprite->data[2]++ > 7)) + if (sprite->data[6] == 0 || (sTransitionData->field_20 > 6 && sprite->data[2]++ > 7)) { - sTransitionStructPtr->field_20++; + sTransitionData->field_20++; DestroySprite(sprite); } } @@ -3409,14 +3490,14 @@ static void Task_GridSquares(u8 taskId) while (sGridSquares_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static bool8 GridSquares_Func1(struct Task *task) +static bool8 GridSquares_Init(struct Task *task) { u16 *tilemap, *tileset; GetBg0TilesDst(&tilemap, &tileset); - CpuSet(sShrinkingBoxTileset, tileset, 0x10); - CpuFill16(0xF000, tilemap, 0x800); - LoadPalette(sFieldEffectPal_Pokeball, 0xF0, 0x20); + CpuSet(sShrinkingBoxTileset, tileset, 16); + CpuFill16(0xF000, tilemap, BG_SCREEN_SIZE); + LoadPalette(sFieldEffectPal_Pokeball, 0xF0, sizeof(sFieldEffectPal_Pokeball)); task->tState++; return FALSE; @@ -3426,26 +3507,26 @@ static bool8 GridSquares_Func2(struct Task *task) { u16* tileset; - if (task->tData1 == 0) + if (task->data[1] == 0) { GetBg0TilemapDst(&tileset); - task->tData1 = 3; - task->tData2++; - CpuSet(sShrinkingBoxTileset + (task->tData2 * 8), tileset, 0x10); - if (task->tData2 > 0xD) + task->data[1] = 3; + task->data[2]++; + CpuSet(sShrinkingBoxTileset + (task->data[2] * 8), tileset, 16); + if (task->data[2] > 13) { task->tState++; - task->tData1 = 16; + task->data[1] = 16; } } - task->tData1--; + task->data[1]--; return FALSE; } -static bool8 GridSquares_Func3(struct Task *task) +static bool8 GridSquares_End(struct Task *task) { - if (--task->tData1 == 0) + if (--task->data[1] == 0) { FadeScreenBlack(); DestroyTask(FindTaskIdByFunc(Task_GridSquares)); @@ -3458,23 +3539,21 @@ static void Task_Shards(u8 taskId) while (sShards_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static bool8 Shards_Func1(struct Task *task) +static bool8 Shards_Init(struct Task *task) { u16 i; - InitTransitionStructVars(); + InitTransitionData(); ScanlineEffect_Clear(); - sTransitionStructPtr->WININ = WININ_WIN0_ALL; - sTransitionStructPtr->WINOUT = 0; - sTransitionStructPtr->WIN0V = DISPLAY_HEIGHT; + sTransitionData->WININ = WININ_WIN0_ALL; + sTransitionData->WINOUT = 0; + sTransitionData->WIN0V = DISPLAY_HEIGHT; - for (i = 0; i < 160; i++) - { - gScanlineEffectRegBuffers[0][i] = 0xF0; - } + for (i = 0; i < DISPLAY_HEIGHT; i++) + gScanlineEffectRegBuffers[0][i] = DISPLAY_WIDTH; - CpuSet(gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], 0xA0); + CpuSet(gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], DISPLAY_HEIGHT); SetVBlankCallback(VBlankCB_Shards); task->tState++; @@ -3483,13 +3562,13 @@ static bool8 Shards_Func1(struct Task *task) static bool8 Shards_Func2(struct Task *task) { - sub_814A1AC(sTransitionStructPtr->data, - sUnknown_085C8DD0[task->tData1][0], - sUnknown_085C8DD0[task->tData1][1], - sUnknown_085C8DD0[task->tData1][2], - sUnknown_085C8DD0[task->tData1][3], + sub_814A1AC(sTransitionData->data, + sUnknown_085C8DD0[task->data[1]][0], + sUnknown_085C8DD0[task->data[1]][1], + sUnknown_085C8DD0[task->data[1]][2], + sUnknown_085C8DD0[task->data[1]][3], 1, 1); - task->tData2 = sUnknown_085C8DD0[task->tData1][4]; + task->data[2] = sUnknown_085C8DD0[task->data[1]][4]; task->tState++; return TRUE; } @@ -3499,46 +3578,46 @@ static bool8 Shards_Func3(struct Task *task) s16 i; bool8 nextFunc; - sTransitionStructPtr->VBlank_DMA = 0; + sTransitionData->VBlank_DMA = 0; for (i = 0, nextFunc = FALSE; i < 16; i++) { - s16 r3 = gScanlineEffectRegBuffers[0][sTransitionStructPtr->data[3]] >> 8; - s16 r4 = gScanlineEffectRegBuffers[0][sTransitionStructPtr->data[3]] & 0xFF; - if (task->tData2 == 0) + s16 r3 = gScanlineEffectRegBuffers[0][sTransitionData->data[3]] >> 8; + s16 r4 = gScanlineEffectRegBuffers[0][sTransitionData->data[3]] & 0xFF; + if (task->data[2] == 0) { - if (r3 < sTransitionStructPtr->data[2]) - r3 = sTransitionStructPtr->data[2]; + if (r3 < sTransitionData->data[2]) + r3 = sTransitionData->data[2]; if (r3 > r4) r3 = r4; } else { - if (r4 > sTransitionStructPtr->data[2]) - r4 = sTransitionStructPtr->data[2]; + if (r4 > sTransitionData->data[2]) + r4 = sTransitionData->data[2]; if (r4 <= r3) r4 = r3; } - gScanlineEffectRegBuffers[0][sTransitionStructPtr->data[3]] = (r4) | (r3 << 8); + gScanlineEffectRegBuffers[0][sTransitionData->data[3]] = (r4) | (r3 << 8); if (nextFunc) { task->tState++; break; } else - nextFunc = sub_814A228(sTransitionStructPtr->data, 1, 1); + nextFunc = sub_814A228(sTransitionData->data, 1, 1); } - sTransitionStructPtr->VBlank_DMA++; + sTransitionData->VBlank_DMA++; return FALSE; } static bool8 Shards_Func4(struct Task *task) { - if (++task->tData1 < 7) + if (++task->data[1] < 7) { task->tState++; - task->tData3 = sUnknown_085C8E16[task->tData1 - 1]; + task->data[3] = sUnknown_085C8E16[task->data[1] - 1]; return TRUE; } else @@ -3552,7 +3631,7 @@ static bool8 Shards_Func4(struct Task *task) static bool8 Shards_Func5(struct Task *task) { - if (--task->tData3 == 0) + if (--task->data[3] == 0) { task->tState = 1; return TRUE; @@ -3565,46 +3644,29 @@ static void VBlankCB_Shards(void) { DmaStop(0); VBlankCB_BattleTransition(); - if (sTransitionStructPtr->VBlank_DMA) - DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], 320); - REG_WININ = sTransitionStructPtr->WININ; - REG_WINOUT = sTransitionStructPtr->WINOUT; - REG_WIN0V = sTransitionStructPtr->WIN0V; + if (sTransitionData->VBlank_DMA) + DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], DISPLAY_HEIGHT * 2); + REG_WININ = sTransitionData->WININ; + REG_WINOUT = sTransitionData->WINOUT; + REG_WIN0V = sTransitionData->WIN0V; REG_WIN0H = gScanlineEffectRegBuffers[1][0]; - DmaSet(0, gScanlineEffectRegBuffers[1], ®_WIN0H, 0xA2400001); + DmaSet(0, gScanlineEffectRegBuffers[1], ®_WIN0H, B_TRANS_DMA_FLAGS); } -// sub-task for phase2 -#undef tData1 -#undef tData2 -#undef tData3 -#undef tData4 -#undef tData5 -#undef tData6 #undef tFuncState -#undef tFrames #undef tOpponentSpriteId #undef tPlayerSpriteId #undef tMugshotId -// sub-task for sub-task phase -#define tData1 data[1] -#define tData2 data[2] -#define tData3 data[3] -#define tData4 data[4] -#define tData5 data[5] -#define tData6 data[6] -#define tData7 data[7] - static void CreateIntroTask(s16 a0, s16 a1, s16 a2, s16 a3, s16 a4) { u8 taskId = CreateTask(Task_BattleTransition_Intro, 3); - gTasks[taskId].tData1 = a0; - gTasks[taskId].tData2 = a1; - gTasks[taskId].tData3 = a2; - gTasks[taskId].tData4 = a3; - gTasks[taskId].tData5 = a4; - gTasks[taskId].tData6 = a0; + gTasks[taskId].data[1] = a0; + gTasks[taskId].data[2] = a1; + gTasks[taskId].data[3] = a2; + gTasks[taskId].data[4] = a3; + gTasks[taskId].data[5] = a4; + gTasks[taskId].data[6] = a0; } static bool8 IsIntroTaskDone(void) @@ -3622,57 +3684,49 @@ void Task_BattleTransition_Intro(u8 taskId) static bool8 Transition_Intro_1(struct Task *task) { - if (task->tData6 == 0 || --task->tData6 == 0) + if (task->data[6] == 0 || --task->data[6] == 0) { - task->tData6 = task->tData1; - task->tData7 += task->tData4; - if (task->tData7 > 16) - task->tData7 = 16; - BlendPalettes(PALETTES_ALL, task->tData7, 0x2D6B); + task->data[6] = task->data[1]; + task->data[7] += task->data[4]; + if (task->data[7] > 16) + task->data[7] = 16; + BlendPalettes(PALETTES_ALL, task->data[7], RGB(11, 11, 11)); } - if (task->tData7 > 15) + if (task->data[7] > 15) { task->tState++; - task->tData6 = task->tData2; + task->data[6] = task->data[2]; } return FALSE; } static bool8 Transition_Intro_2(struct Task *task) { - if (task->tData6 == 0 || --task->tData6 == 0) + if (task->data[6] == 0 || --task->data[6] == 0) { - task->tData6 = task->tData2; - task->tData7 -= task->tData5; - if (task->tData7 < 0) - task->tData7 = 0; - BlendPalettes(PALETTES_ALL, task->tData7, 0x2D6B); + task->data[6] = task->data[2]; + task->data[7] -= task->data[5]; + if (task->data[7] < 0) + task->data[7] = 0; + BlendPalettes(PALETTES_ALL, task->data[7], RGB(11, 11, 11)); } - if (task->tData7 == 0) + if (task->data[7] == 0) { - if (--task->tData3 == 0) + if (--task->data[3] == 0) DestroyTask(FindTaskIdByFunc(Task_BattleTransition_Intro)); else { - task->tData6 = task->tData1; + task->data[6] = task->data[1]; task->tState = 0; } } return FALSE; } -#undef tData1 -#undef tData2 -#undef tData3 -#undef tData4 -#undef tData5 -#undef tData6 -#undef tData7 - -static void InitTransitionStructVars(void) +static void InitTransitionData(void) { - memset(sTransitionStructPtr, 0, sizeof(*sTransitionStructPtr)); - GetCameraOffsetWithPan(&sTransitionStructPtr->field_14, &sTransitionStructPtr->field_16); + memset(sTransitionData, 0, sizeof(*sTransitionData)); + GetCameraOffsetWithPan(&sTransitionData->cameraX, &sTransitionData->cameraY); } static void VBlankCB_BattleTransition(void) @@ -3685,7 +3739,7 @@ static void VBlankCB_BattleTransition(void) static void GetBg0TilemapDst(u16 **tileset) { u16 charBase = REG_BG0CNT >> 2; - charBase <<= 0xE; + charBase <<= 14; *tileset = (u16*)(VRAM + charBase); } @@ -3694,8 +3748,8 @@ void GetBg0TilesDst(u16 **tilemap, u16 **tileset) u16 screenBase = REG_BG0CNT >> 8; u16 charBase = REG_BG0CNT >> 2; - screenBase <<= 0xB; - charBase <<= 0xE; + screenBase <<= 11; + charBase <<= 14; *tilemap = (u16*)(VRAM + screenBase); *tileset = (u16*)(VRAM + charBase); @@ -3706,54 +3760,52 @@ static void FadeScreenBlack(void) BlendPalettes(PALETTES_ALL, 16, RGB_BLACK); } -static void sub_8149F98(s16 *array, s16 sinAdd, s16 index, s16 indexIncrementer, s16 amplitude, s16 arrSize) +static void SetSinWave(s16 *array, s16 sinAdd, s16 index, s16 indexIncrementer, s16 amplitude, s16 arrSize) { u8 i; for (i = 0; arrSize > 0; arrSize--, i++, index += indexIncrementer) - { - array[i] = sinAdd + Sin(0xFF & index, amplitude); - } + array[i] = sinAdd + Sin(index & 0xFF, amplitude); } -static void sub_814A014(u16 *array, s16 a1, s16 a2, s16 a3) +static void sub_814A014(u16 *array, s16 x, s16 y, s16 amplitude) { s16 i; - memset(array, 0xA, 160 * sizeof(s16)); + memset(array, 10, DISPLAY_HEIGHT * sizeof(s16)); for (i = 0; i < 64; i++) { s16 sinResult, cosResult; s16 toStoreOrr, r2, r3, toStore, r7, r8; - sinResult = Sin(i, a3); - cosResult = Cos(i, a3); + sinResult = Sin(i, amplitude); + cosResult = Cos(i, amplitude); - toStoreOrr = a1 - sinResult; - toStore = a1 + sinResult; - r7 = a2 - cosResult; - r8 = a2 + cosResult; + toStoreOrr = x - sinResult; + toStore = x + sinResult; + r7 = y - cosResult; + r8 = y + cosResult; if (toStoreOrr < 0) toStoreOrr = 0; - if (toStore > 0xF0) - toStore = 0xF0; + if (toStore > DISPLAY_WIDTH) + toStore = DISPLAY_WIDTH; if (r7 < 0) r7 = 0; - if (r8 > 0x9F) - r8 = 0x9F; + if (r8 > DISPLAY_HEIGHT - 1) + r8 = DISPLAY_HEIGHT - 1; toStore |= (toStoreOrr << 8); array[r7] = toStore; array[r8] = toStore; - cosResult = Cos(i + 1, a3); - r3 = a2 - cosResult; - r2 = a2 + cosResult; + cosResult = Cos(i + 1, amplitude); + r3 = y - cosResult; + r2 = y + cosResult; if (r3 < 0) r3 = 0; - if (r2 > 0x9F) - r2 = 0x9F; + if (r2 > DISPLAY_HEIGHT - 1) + r2 = DISPLAY_HEIGHT - 1; while (r7 > r3) array[--r7] = toStore; @@ -3835,36 +3887,27 @@ static bool8 sub_814A228(s16 *data, bool8 a1, bool8 a2) return FALSE; } -// sub-task for phase2 of a couple of new transitions -#define tData1 data[1] -#define tData2 data[2] -#define tData3 data[3] -#define tData4 data[4] -#define tData5 data[5] -#define tData6 data[6] -#define tData7 data[7] - -static bool8 FrontierLogoWiggle_Func1(struct Task *task) +static bool8 FrontierLogoWiggle_Init(struct Task *task) { u16 *tilemap, *tileset; - sub_814669C(task); + InitPatternWeaveTransition(task); GetBg0TilesDst(&tilemap, &tileset); - CpuFill16(0, tilemap, 0x800); + CpuFill16(0, tilemap, BG_SCREEN_SIZE); LZ77UnCompVram(sFrontierLogo_Tileset, tileset); - LoadPalette(sFrontierLogo_Palette, 0xF0, 0x20); + LoadPalette(sFrontierLogo_Palette, 0xF0, sizeof(sFrontierLogo_Palette)); task->tState++; return FALSE; } -static bool8 FrontierLogoWiggle_Func2(struct Task *task) +static bool8 FrontierLogoWiggle_SetGfx(struct Task *task) { u16 *tilemap, *tileset; GetBg0TilesDst(&tilemap, &tileset); LZ77UnCompVram(sFrontierLogo_Tilemap, tilemap); - sub_8149F98(gScanlineEffectRegBuffers[0], 0, task->tData4, 0x84, task->tData5, 160); + SetSinWave(gScanlineEffectRegBuffers[0], 0, task->data[4], 0x84, task->data[5], DISPLAY_HEIGHT); task->tState++; return TRUE; @@ -3880,33 +3923,33 @@ static void Task_FrontierLogoWave(u8 taskId) while (sFrontierLogoWave_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static bool8 FrontierLogoWave_Func1(struct Task *task) +static bool8 FrontierLogoWave_Init(struct Task *task) { u16 *tilemap, *tileset; - InitTransitionStructVars(); + InitTransitionData(); ScanlineEffect_Clear(); ClearGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON | DISPCNT_WIN1_ON); - task->tData2 = 0x2000; - task->tData1 = 0x7FFF; - task->tData5 = 0; - task->tData6 = 16; - task->tData7 = 2560; - sTransitionStructPtr->BLDCNT = BLDCNT_TGT1_BG0 | BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_ALL; - sTransitionStructPtr->BLDALPHA = BLDALPHA_BLEND(task->tData5, task->tData6); - REG_BLDCNT = sTransitionStructPtr->BLDCNT; - REG_BLDALPHA = sTransitionStructPtr->BLDALPHA; + task->data[2] = 0x2000; + task->data[1] = 0x7FFF; + task->data[5] = 0; + task->data[6] = 16; + task->data[7] = 2560; + sTransitionData->BLDCNT = BLDCNT_TGT1_BG0 | BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_ALL; + sTransitionData->BLDALPHA = BLDALPHA_BLEND(task->data[5], task->data[6]); + REG_BLDCNT = sTransitionData->BLDCNT; + REG_BLDALPHA = sTransitionData->BLDALPHA; GetBg0TilesDst(&tilemap, &tileset); - CpuFill16(0, tilemap, 0x800); + CpuFill16(0, tilemap, BG_SCREEN_SIZE); LZ77UnCompVram(sFrontierLogo_Tileset, tileset); - LoadPalette(sFrontierLogo_Palette, 0xF0, 0x20); - sTransitionStructPtr->field_16 = 0; + LoadPalette(sFrontierLogo_Palette, 0xF0, sizeof(sFrontierLogo_Palette)); + sTransitionData->cameraY = 0; task->tState++; return FALSE; } -static bool8 FrontierLogoWave_Func2(struct Task *task) +static bool8 FrontierLogoWave_SetGfx(struct Task *task) { u16 *tilemap, *tileset; @@ -3921,13 +3964,11 @@ static bool8 FrontierLogoWave_Func3(struct Task *task) { u8 i; - for (i = 0; i < 160; i++) - { - gScanlineEffectRegBuffers[1][i] = sTransitionStructPtr->field_16; - } + for (i = 0; i < DISPLAY_HEIGHT; i++) + gScanlineEffectRegBuffers[1][i] = sTransitionData->cameraY; - SetVBlankCallback(VBlankCB_30); - SetHBlankCallback(HBlankCB_30); + SetVBlankCallback(VBlankCB_FrontierLogoWave); + SetHBlankCallback(HBlankCB_FrontierLogoWave); EnableInterrupts(INTR_FLAG_HBLANK); task->tState++; @@ -3939,63 +3980,63 @@ static bool8 FrontierLogoWave_Func4(struct Task *task) u8 i; u16 var6, amplitude, var8; - sTransitionStructPtr->VBlank_DMA = FALSE; + sTransitionData->VBlank_DMA = FALSE; - amplitude = task->tData2 >> 8; - var6 = task->tData1; + amplitude = task->data[2] >> 8; + var6 = task->data[1]; var8 = 384; - task->tData1 = var6 - task->tData7; + task->data[1] = var6 - task->data[7]; - if (task->tData3 >= 70) + if (task->data[3] >= 70) { - if (task->tData2 - 384 >= 0) - task->tData2 -= 384; + if (task->data[2] - 384 >= 0) + task->data[2] -= 384; else - task->tData2 = 0; + task->data[2] = 0; } - if (task->tData3 >= 0 && task->tData3 % 3 == 0) + if (task->data[3] >= 0 && task->data[3] % 3 == 0) { - if (task->tData5 < 16) - task->tData5++; - else if (task->tData6 > 0) - task->tData6--; + if (task->data[5] < 16) + task->data[5]++; + else if (task->data[6] > 0) + task->data[6]--; - sTransitionStructPtr->BLDALPHA = BLDALPHA_BLEND(task->tData5, task->tData6); + sTransitionData->BLDALPHA = BLDALPHA_BLEND(task->data[5], task->data[6]); } - for (i = 0; i < 160; i++, var6 += var8) + for (i = 0; i < DISPLAY_HEIGHT; i++, var6 += var8) { s16 index = var6 / 256; - gScanlineEffectRegBuffers[0][i] = sTransitionStructPtr->field_16 + Sin(index & 0xff, amplitude); + gScanlineEffectRegBuffers[0][i] = sTransitionData->cameraY + Sin(index & 0xff, amplitude); } - if (++task->tData3 == 101) + if (++task->data[3] == 101) { - task->tData4++; - BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 0x10, RGB_BLACK); + task->data[4]++; + BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 16, RGB_BLACK); } - if (task->tData4 != 0 && !gPaletteFade.active) + if (task->data[4] != 0 && !gPaletteFade.active) DestroyTask(FindTaskIdByFunc(Task_FrontierLogoWave)); - task->tData7 -= 17; - sTransitionStructPtr->VBlank_DMA++; + task->data[7] -= 17; + sTransitionData->VBlank_DMA++; return FALSE; } -static void VBlankCB_30(void) +static void VBlankCB_FrontierLogoWave(void) { VBlankCB_BattleTransition(); - REG_BLDCNT = sTransitionStructPtr->BLDCNT; - REG_BLDALPHA = sTransitionStructPtr->BLDALPHA; + REG_BLDCNT = sTransitionData->BLDCNT; + REG_BLDALPHA = sTransitionData->BLDALPHA; - if (sTransitionStructPtr->VBlank_DMA) - DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], 320); + if (sTransitionData->VBlank_DMA) + DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], DISPLAY_HEIGHT * 2); } -static void HBlankCB_30(void) +static void HBlankCB_FrontierLogoWave(void) { u16 var = gScanlineEffectRegBuffers[1][REG_VCOUNT]; REG_BG0VOFS = var; @@ -4016,7 +4057,7 @@ static void Task_FrontierSquaresScroll(u8 taskId) while (sFrontierSquaresScroll_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static bool8 FrontierSquares_Func1(struct Task *task) +static bool8 FrontierSquares_Init(struct Task *task) { u16 *tilemap, *tileset; @@ -4027,12 +4068,12 @@ static bool8 FrontierSquares_Func1(struct Task *task) FillBgTilemapBufferRect(0, 1, 0, 0, 1, 0x20, 0xF); FillBgTilemapBufferRect(0, 1, 0x1D, 0, 1, 0x20, 0xF); CopyBgTilemapBufferToVram(0); - LoadPalette(sFrontierSquares_Palette, 0xF0, 0x20); + LoadPalette(sFrontierSquares_Palette, 0xF0, sizeof(sFrontierSquares_Palette)); - task->tData2 = 1; - task->tData3 = 0; - task->tData4 = 0; - task->tData7 = 10; + task->data[2] = 1; + task->data[3] = 0; + task->data[4] = 0; + task->data[7] = 10; task->tState++; return FALSE; @@ -4040,16 +4081,16 @@ static bool8 FrontierSquares_Func1(struct Task *task) static bool8 FrontierSquares_Func2(struct Task *task) { - CopyRectToBgTilemapBufferRect(0, sFrontierSquares_Tilemap, 0, 0, 4, 4, task->tData2, task->tData3, 4, 4, 0xF, 0, 0); + CopyRectToBgTilemapBufferRect(0, sFrontierSquares_Tilemap, 0, 0, 4, 4, task->data[2], task->data[3], 4, 4, 0xF, 0, 0); CopyBgTilemapBufferToVram(0); - task->tData2 += 4; - if (++task->tData4 == 7) + task->data[2] += 4; + if (++task->data[4] == 7) { - task->tData2 = 1; - task->tData3 += 4; - task->tData4 = 0; - if (task->tData3 > 19) + task->data[2] = 1; + task->data[3] += 4; + task->data[4] = 0; + if (task->data[3] > 19) task->tState++; } @@ -4062,9 +4103,9 @@ static bool8 FrontierSquares_Func3(struct Task *task) u16 *tilemap, *tileset; GetBg0TilesDst(&tilemap, &tileset); - if (task->tData6++ >= task->tData7) + if (task->data[6]++ >= task->data[7]) { - switch (task->tData5) + switch (task->data[5]) { case 0: for (i = 250; i < 255; i++) @@ -4074,7 +4115,7 @@ static bool8 FrontierSquares_Func3(struct Task *task) } break; case 1: - BlendPalettes(PALETTES_ALL & ~(0x8000), 0x10, 0); + BlendPalettes(PALETTES_ALL & ~(1 << 15), 16, RGB_BLACK); LZ77UnCompVram(sFrontierSquares_EmptyBg_Tileset, tileset); break; case 2: @@ -4090,14 +4131,14 @@ static bool8 FrontierSquares_Func3(struct Task *task) return FALSE; } - task->tData6 = 0; - task->tData5++; + task->data[6] = 0; + task->data[5]++; } return FALSE; } -static bool8 FrontierSquaresSpiral_Func1(struct Task *task) +static bool8 FrontierSquaresSpiral_Init(struct Task *task) { u16 *tilemap, *tileset; @@ -4108,12 +4149,12 @@ static bool8 FrontierSquaresSpiral_Func1(struct Task *task) FillBgTilemapBufferRect(0, 1, 0, 0, 1, 0x20, 0xF); FillBgTilemapBufferRect(0, 1, 0x1D, 0, 1, 0x20, 0xF); CopyBgTilemapBufferToVram(0); - LoadPalette(sFrontierSquares_Palette, 0xE0, 0x20); - LoadPalette(sFrontierSquares_Palette, 0xF0, 0x20); - BlendPalette(0xE0, 0x10, 8, 0); + LoadPalette(sFrontierSquares_Palette, 0xE0, sizeof(sFrontierSquares_Palette)); + LoadPalette(sFrontierSquares_Palette, 0xF0, sizeof(sFrontierSquares_Palette)); + BlendPalette(0xE0, 16, 8, 0); - task->tData2 = 34; - task->tData3 = 0; + task->data[2] = 34; + task->data[3] = 0; task->tState++; return FALSE; @@ -4121,24 +4162,24 @@ static bool8 FrontierSquaresSpiral_Func1(struct Task *task) static bool8 FrontierSquaresSpiral_Func2(struct Task *task) { - u8 var = gUnknown_085C9A30[task->tData2]; + u8 var = gUnknown_085C9A30[task->data[2]]; u8 varMod = var % 7; u8 varDiv = var / 7; CopyRectToBgTilemapBufferRect(0, &sFrontierSquares_Tilemap, 0, 0, 4, 4, 4 * varMod + 1, 4 * varDiv, 4, 4, 0xF, 0, 0); CopyBgTilemapBufferToVram(0); - if (--task->tData2 < 0) + if (--task->data[2] < 0) task->tState++; return FALSE; } static bool8 FrontierSquaresSpiral_Func3(struct Task *task) { - BlendPalette(0xE0, 0x10, 3, 0); - BlendPalettes(PALETTES_ALL & ~(0x8000 | 0x4000), 0x10, 0); + BlendPalette(0xE0, 16, 3, 0); + BlendPalettes(PALETTES_ALL & ~(1 << 15 | 1 << 14), 16, RGB_BLACK); - task->tData2 = 0; - task->tData3 = 0; + task->data[2] = 0; + task->data[3] = 0; task->tState++; return FALSE; @@ -4146,7 +4187,7 @@ static bool8 FrontierSquaresSpiral_Func3(struct Task *task) static bool8 FrontierSquaresSpiral_Func4(struct Task *task) { - if ((task->tData3 ^= 1)) + if ((task->data[3] ^= 1)) { CopyRectToBgTilemapBufferRect( 0, @@ -4155,8 +4196,8 @@ static bool8 FrontierSquaresSpiral_Func4(struct Task *task) 0, 4, 4, - 4 * (gUnknown_085C9A30[task->tData2] % 7) + 1, - 4 * (gUnknown_085C9A30[task->tData2] / 7), + 4 * (gUnknown_085C9A30[task->data[2]] % 7) + 1, + 4 * (gUnknown_085C9A30[task->data[2]] / 7), 4, 4, 0xE, @@ -4165,22 +4206,22 @@ static bool8 FrontierSquaresSpiral_Func4(struct Task *task) } else { - if (task->tData2 > 0) + if (task->data[2] > 0) { FillBgTilemapBufferRect( 0, 1, - 4 * (gUnknown_085C9A30[task->tData2 - 1] % 7) + 1, - 4 * (gUnknown_085C9A30[task->tData2 - 1] / 7), + 4 * (gUnknown_085C9A30[task->data[2] - 1] % 7) + 1, + 4 * (gUnknown_085C9A30[task->data[2] - 1] / 7), 4, 4, 0xF); } - task->tData2++; + task->data[2]++; } - if (task->tData2 > 34) + if (task->data[2] > 34) task->tState++; CopyBgTilemapBufferToVram(0); @@ -4191,7 +4232,7 @@ static bool8 FrontierSquares_End(struct Task *task) { FillBgTilemapBufferRect_Palette0(0, 1, 0, 0, 0x20, 0x20); CopyBgTilemapBufferToVram(0); - BlendPalettes(PALETTES_ALL, 0x10, 0); + BlendPalettes(PALETTES_ALL, 16, RGB_BLACK); DestroyTask(FindTaskIdByFunc(task->func)); return FALSE; } @@ -4212,7 +4253,7 @@ static void sub_814ABE4(u8 taskId) } } -static bool8 FrontierSquaresScroll_Func1(struct Task *task) +static bool8 FrontierSquaresScroll_Init(struct Task *task) { u8 taskId = 0; u16 *tilemap, *tileset; @@ -4221,14 +4262,14 @@ static bool8 FrontierSquaresScroll_Func1(struct Task *task) LZ77UnCompVram(sFrontierSquares_FilledBg_Tileset, tileset); FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 0x20, 0x20); CopyBgTilemapBufferToVram(0); - LoadPalette(sFrontierSquares_Palette, 0xF0, 0x20); + LoadPalette(sFrontierSquares_Palette, 0xF0, sizeof(sFrontierSquares_Palette)); gBattle_BG0_X = 0; gBattle_BG0_Y = 0; SetGpuReg(REG_OFFSET_BG0VOFS, gBattle_BG0_X); SetGpuReg(REG_OFFSET_BG0HOFS, gBattle_BG0_Y); - task->tData2 = 0; + task->data[2] = 0; taskId = CreateTask(sub_814ABE4, 1); switch (Random() % 4) { @@ -4256,7 +4297,7 @@ static bool8 FrontierSquaresScroll_Func1(struct Task *task) static bool8 FrontierSquaresScroll_Func2(struct Task *task) { - u8 var = gUnknown_085C9A53[task->tData2]; + u8 var = gUnknown_085C9A53[task->data[2]]; u8 varDiv = var / 8; u8 varAnd = var & 7; @@ -4276,16 +4317,16 @@ static bool8 FrontierSquaresScroll_Func2(struct Task *task) 0); CopyBgTilemapBufferToVram(0); - if (++task->tData2 > 63) + if (++task->data[2] > 63) task->tState++; return 0; } static bool8 FrontierSquaresScroll_Func3(struct Task *task) { - BlendPalettes(PALETTES_ALL & ~(0x8000), 0x10, 0); + BlendPalettes(PALETTES_ALL & ~(1 << 15), 16, RGB_BLACK); - task->tData2 = 0; + task->data[2] = 0; task->tState++; return FALSE; @@ -4293,14 +4334,14 @@ static bool8 FrontierSquaresScroll_Func3(struct Task *task) static bool8 FrontierSquaresScroll_Func4(struct Task *task) { - u8 var = gUnknown_085C9A53[task->tData2]; + u8 var = gUnknown_085C9A53[task->data[2]]; u8 varDiv = var / 8; - u8 varAnd = var & 7; + u8 varAnd = var % 8; FillBgTilemapBufferRect(0, 1, 4 * varDiv + 1, 4 * varAnd, 4, 4, 0xF); CopyBgTilemapBufferToVram(0); - if (++task->tData2 > 63) + if (++task->data[2] > 63) { DestroyTask(FindTaskIdByFunc(sub_814ABE4)); task->tState++; @@ -4313,7 +4354,7 @@ static bool8 FrontierSquaresScroll_Func4(struct Task *task) #undef tSub32_Y_delta #undef tSub32_Bool -static bool8 FrontierSquaresScroll_Func5(struct Task *task) +static bool8 FrontierSquaresScroll_End(struct Task *task) { gBattle_BG0_X = 0; gBattle_BG0_Y = 0; @@ -4322,7 +4363,7 @@ static bool8 FrontierSquaresScroll_Func5(struct Task *task) FillBgTilemapBufferRect_Palette0(0, 1, 0, 0, 0x20, 0x20); CopyBgTilemapBufferToVram(0); - BlendPalettes(PALETTES_ALL, 0x10, 0); + BlendPalettes(PALETTES_ALL, 16, RGB_BLACK); DestroyTask(FindTaskIdByFunc(task->func)); @@ -4331,11 +4372,3 @@ static bool8 FrontierSquaresScroll_Func5(struct Task *task) #endif return FALSE; } - -#undef tData1 -#undef tData2 -#undef tData3 -#undef tData4 -#undef tData5 -#undef tData6 -#undef tData7 -- cgit v1.2.3 From 07bf225f9416b3d75fb69101d1d5ec87a19031b6 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Wed, 27 Oct 2021 16:17:27 -0400 Subject: Continue battle_transition documenting --- src/battle_transition.c | 2211 +++++++++++++++++++++++++++-------------------- 1 file changed, 1280 insertions(+), 931 deletions(-) (limited to 'src/battle_transition.c') diff --git a/src/battle_transition.c b/src/battle_transition.c index 72edf92d5..88194db27 100644 --- a/src/battle_transition.c +++ b/src/battle_transition.c @@ -29,10 +29,27 @@ #define B_TRANS_DMA_FLAGS (1 | ((DMA_SRC_INC | DMA_DEST_FIXED | DMA_REPEAT | DMA_16BIT | DMA_START_HBLANK | DMA_ENABLE) << 16)) -#define SET_TILEMAP_TILE(ptr, posY, posX, toStore) \ -{ \ - u32 index = (posY) * 32 + posX; \ - ptr[index] = toStore; \ +// Used by each transition task to determine which of its functions to call +#define tState data[0] + +// Below are data defines for InitBlackWipe and UpdateBlackWipe, for the TransitionData data array. +// These will be re-used by any transitions that use these functions. +#define tWipeStartX data[0] +#define tWipeStartY data[1] +#define tWipeCurrX data[2] +#define tWipeCurrY data[3] +#define tWipeEndX data[4] +#define tWipeEndY data[5] +#define tWipeXMove data[6] +#define tWipeYMove data[7] +#define tWipeXDist data[8] +#define tWipeYDist data[9] +#define tWipeTemp data[10] + +#define SET_TILE(ptr, posY, posX, tile) \ +{ \ + u32 index = (posY) * 32 + posX; \ + ptr[index] = tile | (0xF0 << 8); \ } struct TransitionData @@ -53,17 +70,17 @@ struct TransitionData s16 BG0HOFS_Upper; s16 BG0VOFS; // used but not set s16 unused3; - s16 field_20; + s16 counter; s16 unused4; s16 data[11]; }; -struct StructRectangularSpiral +struct RectangularSpiralLine { - u8 field_0; - s16 field_2; - u8 field_4; - s16 field_6; + u8 state; + s16 position; + u8 moveIdx; + s16 skipPosition; u8 field_8; }; @@ -83,13 +100,13 @@ static void Task_Swirl(u8 taskId); static void Task_Shuffle(u8 taskId); static void Task_BigPokeball(u8 taskId); static void Task_PokeballsTrail(u8 taskId); -static void Task_Clockwise_BlackFade(u8 taskId); +static void Task_ClockwiseWipe(u8 taskId); static void Task_Ripple(u8 taskId); static void Task_Wave(u8 taskId); static void Task_Slice(u8 taskId); -static void Task_WhiteFade(u8 taskId); +static void Task_WhiteBarsFade(u8 taskId); static void Task_GridSquares(u8 taskId); -static void Task_Shards(u8 taskId); +static void Task_AngledWipes(u8 taskId); static void Task_Sidney(u8 taskId); static void Task_Phoebe(u8 taskId); static void Task_Glacia(u8 taskId); @@ -104,8 +121,8 @@ static void Task_Kyogre(u8 taskId); static void Task_Groudon(u8 taskId); static void Task_Rayquaza(u8 taskId); static void Task_ShredSplit(u8 taskId); -static void Task_Blackhole1(u8 taskId); -static void Task_Blackhole2(u8 taskId); +static void Task_Blackhole(u8 taskId); +static void Task_BlackholePulsate(u8 taskId); static void Task_RectangularSpiral(u8 taskId); static void Task_FrontierLogoWiggle(u8 taskId); static void Task_FrontierLogoWave(u8 taskId); @@ -118,8 +135,8 @@ static void HBlankCB_Swirl(void); static void VBlankCB_Shuffle(void); static void HBlankCB_Shuffle(void); static void VBlankCB_PatternWeave(void); -static void VBlankCB1_BigPokeball(void); -static void VBlankCB_Clockwise_BlackFade(void); +static void VBlankCB_CircularMask(void); +static void VBlankCB_ClockwiseWipe(void); static void VBlankCB_Ripple(void); static void HBlankCB_Ripple(void); static void VBlankCB_FrontierLogoWave(void); @@ -127,10 +144,10 @@ static void HBlankCB_FrontierLogoWave(void); static void VBlankCB_Wave(void); static void VBlankCB_Slice(void); static void HBlankCB_Slice(void); -static void VBlankCB0_WhiteFade(void); -static void VBlankCB1_WhiteFade(void); -static void HBlankCB_WhiteFade(void); -static void VBlankCB_Shards(void); +static void VBlankCB_WhiteBarsFade(void); +static void VBlankCB_WhiteBarsFade_Blend(void); +static void HBlankCB_WhiteBarsFade(void); +static void VBlankCB_AngledWipes(void); static void VBlankCB_Rayquaza(void); static bool8 Blur_Init(struct Task *task); static bool8 Blur_Main(struct Task *task); @@ -151,60 +168,60 @@ static bool8 Regirock_SetGfx(struct Task *task); static bool8 WeatherTrio_BgFadeBlack(struct Task *task); static bool8 WeatherTrio_WaitFade(struct Task *task); static bool8 Kyogre_Init(struct Task *task); -static bool8 Kyogre_PalettePulsate(struct Task *task); +static bool8 Kyogre_PaletteFlash(struct Task *task); static bool8 Kyogre_PaletteBrighten(struct Task *task); static bool8 Groudon_Init(struct Task *task); -static bool8 Groudon_PalettePulsate(struct Task *task); +static bool8 Groudon_PaletteFlash(struct Task *task); static bool8 Groudon_PaletteBrighten(struct Task *task); static bool8 WeatherDuo_FadeOut(struct Task *task); static bool8 WeatherDuo_End(struct Task *task); static bool8 BigPokeball_Init(struct Task *task); static bool8 BigPokeball_SetGfx(struct Task *task); -static bool8 PatternWeave_1(struct Task *task); -static bool8 PatternWeave_2(struct Task *task); -static bool8 PatternWeave_3(struct Task *task); -static bool8 PatternWeave_End(struct Task *task); +static bool8 PatternWeave_Blend1(struct Task *task); +static bool8 PatternWeave_Blend2(struct Task *task); +static bool8 PatternWeave_FinishAppear(struct Task *task); +static bool8 PatternWeave_CircularMask(struct Task *task); static bool8 PokeballsTrail_Init(struct Task *task); static bool8 PokeballsTrail_Main(struct Task *task); static bool8 PokeballsTrail_End(struct Task *task); -static bool8 Clockwise_BlackFade_Init(struct Task *task); -static bool8 Clockwise_BlackFade_Func2(struct Task *task); -static bool8 Clockwise_BlackFade_Func3(struct Task *task); -static bool8 Clockwise_BlackFade_Func4(struct Task *task); -static bool8 Clockwise_BlackFade_Func5(struct Task *task); -static bool8 Clockwise_BlackFade_Func6(struct Task *task); -static bool8 Clockwise_BlackFade_End(struct Task *task); +static bool8 ClockwiseWipe_Init(struct Task *task); +static bool8 ClockwiseWipe_TopRight(struct Task *task); +static bool8 ClockwiseWipe_Right(struct Task *task); +static bool8 ClockwiseWipe_Bottom(struct Task *task); +static bool8 ClockwiseWipe_Left(struct Task *task); +static bool8 ClockwiseWipe_TopLeft(struct Task *task); +static bool8 ClockwiseWipe_End(struct Task *task); static bool8 Ripple_Init(struct Task *task); -static bool8 Ripple_Func2(struct Task *task); +static bool8 Ripple_Main(struct Task *task); static bool8 Wave_Init(struct Task *task); -static bool8 Wave_Func2(struct Task *task); +static bool8 Wave_Main(struct Task *task); static bool8 Wave_End(struct Task *task); static bool8 Slice_Init(struct Task *task); -static bool8 Slice_Func2(struct Task *task); +static bool8 Slice_Main(struct Task *task); static bool8 Slice_End(struct Task *task); -static bool8 WhiteFade_Init(struct Task *task); -static bool8 WhiteFade_Func2(struct Task *task); -static bool8 WhiteFade_Func3(struct Task *task); -static bool8 WhiteFade_Func4(struct Task *task); -static bool8 WhiteFade_End(struct Task *task); +static bool8 WhiteBarsFade_Init(struct Task *task); +static bool8 WhiteBarsFade_StartBars(struct Task *task); +static bool8 WhiteBarsFade_WaitBars(struct Task *task); +static bool8 WhiteBarsFade_BlendToBlack(struct Task *task); +static bool8 WhiteBarsFade_End(struct Task *task); static bool8 GridSquares_Init(struct Task *task); -static bool8 GridSquares_Func2(struct Task *task); +static bool8 GridSquares_Main(struct Task *task); static bool8 GridSquares_End(struct Task *task); -static bool8 Shards_Init(struct Task *task); -static bool8 Shards_Func2(struct Task *task); -static bool8 Shards_Func3(struct Task *task); -static bool8 Shards_Func4(struct Task *task); -static bool8 Shards_Func5(struct Task *task); +static bool8 AngledWipes_Init(struct Task *task); +static bool8 AngledWipes_SetWipeData(struct Task *task); +static bool8 AngledWipes_DoWipe(struct Task *task); +static bool8 AngledWipes_TryEnd(struct Task *task); +static bool8 AngledWipes_StartNext(struct Task *task); static bool8 ShredSplit_Init(struct Task *task); -static bool8 ShredSplit_Func2(struct Task *task); -static bool8 ShredSplit_Func3(struct Task *task); +static bool8 ShredSplit_Main(struct Task *task); +static bool8 ShredSplit_BrokenCheck(struct Task *task); static bool8 ShredSplit_End(struct Task *task); static bool8 Blackhole_Init(struct Task *task); -static bool8 Blackhole1_Func2(struct Task *task); -static bool8 Blackhole1_Func3(struct Task *task); -static bool8 Blackhole2_Func2(struct Task *task); +static bool8 Blackhole_Vibrate(struct Task *task); +static bool8 Blackhole_GrowEnd(struct Task *task); +static bool8 BlackholePulsate_Main(struct Task *task); static bool8 RectangularSpiral_Init(struct Task *task); -static bool8 RectangularSpiral_Func2(struct Task *task); +static bool8 RectangularSpiral_Main(struct Task *task); static bool8 RectangularSpiral_End(struct Task *task); static bool8 FrontierLogoWiggle_Init(struct Task *task); static bool8 FrontierLogoWiggle_SetGfx(struct Task *task); @@ -212,16 +229,16 @@ static bool8 FrontierLogoWave_Init(struct Task *task); static bool8 FrontierLogoWave_SetGfx(struct Task *task); static bool8 FrontierLogoWave_Func3(struct Task *task); static bool8 FrontierLogoWave_Func4(struct Task *task); -static bool8 Rayquaza_Func3(struct Task *task); -static bool8 Rayquaza_Func4(struct Task *task); -static bool8 Rayquaza_Func5(struct Task *task); -static bool8 Rayquaza_Func6(struct Task *task); -static bool8 Rayquaza_Func7(struct Task *task); -static bool8 Rayquaza_Func8(struct Task *task); -static bool8 Rayquaza_Func9(struct Task *task); +static bool8 Rayquaza_Init(struct Task *task); +static bool8 Rayquaza_SetGfx(struct Task *task); +static bool8 Rayquaza_PaletteFlash(struct Task *task); +static bool8 Rayquaza_FadeToBlack(struct Task *task); +static bool8 Rayquaza_WaitFade(struct Task *task); +static bool8 Rayquaza_SetBlack(struct Task *task); +static bool8 Rayquaza_TriRing(struct Task *task); static bool8 FrontierSquares_Init(struct Task *task); -static bool8 FrontierSquares_Func2(struct Task *task); -static bool8 FrontierSquares_Func3(struct Task *task); +static bool8 FrontierSquares_Draw(struct Task *task); +static bool8 FrontierSquares_Shrink(struct Task *task); static bool8 FrontierSquares_End(struct Task *task); static bool8 FrontierSquaresSpiral_Init(struct Task *task); static bool8 FrontierSquaresSpiral_Func2(struct Task *task); @@ -244,37 +261,37 @@ static bool8 Mugshot_FadeToBlack(struct Task *task); static bool8 Mugshot_End(struct Task *task); static void DoMugshotTransition(u8 taskId); static void Mugshots_CreateTrainerPics(struct Task *task); -static void VBlankCB0_Mugshots(void); -static void VBlankCB1_Mugshots(void); +static void VBlankCB_Mugshots(void); +static void VBlankCB_MugshotsFadeOut(void); static void HBlankCB_Mugshots(void); static void InitTransitionData(void); static void FadeScreenBlack(void); static void CreateIntroTask(s16 a0, s16 a1, s16 a2, s16 a3, s16 a4); -static void sub_814A014(u16 *a0, s16 a1, s16 a2, s16 a3); +static void SetCircularMask(u16 *a0, s16 a1, s16 a2, s16 a3); static void SetSinWave(s16 *array, s16 sinAdd, s16 index, s16 indexIncrementer, s16 amplitude, s16 arrSize); static void GetBg0TilemapDst(u16 **tileset); -static void sub_814A1AC(s16 *a0, s16 a1, s16 a2, s16 a3, s16 a4, s16 a5, s16 a6); -static bool8 sub_814A228(s16 *a0, bool8 a1, bool8 a2); -static void SetTrainerPicSlideTable(s16 spriteId, s16 arrId); +static void InitBlackWipe(s16 *a0, s16 a1, s16 a2, s16 a3, s16 a4, s16 a5, s16 a6); +static bool8 UpdateBlackWipe(s16 *a0, bool8 a1, bool8 a2); +static void SetTrainerPicSlideDirection(s16 spriteId, s16 arrId); static void IncrementTrainerPicState(s16 spriteId); static s16 IsTrainerPicSlideDone(s16 spriteId); -static bool8 Transition_Intro_1(struct Task *task); -static bool8 Transition_Intro_2(struct Task *task); +static bool8 TransitionIntro_FadeToGray(struct Task *task); +static bool8 TransitionIntro_FadeFromGray(struct Task *task); static bool8 IsIntroTaskDone(void); -static bool16 sub_8149048(const s16 * const *arg0, struct StructRectangularSpiral *arg1); -static void SpriteCB_FldEffPokeball(struct Sprite *sprite); +static bool16 UpdateRectangularSpiralLine(const s16 * const *arg0, struct RectangularSpiralLine *arg1); +static void SpriteCB_FldEffPokeballTrail(struct Sprite *sprite); static void SpriteCB_MugshotTrainerPic(struct Sprite *sprite); -static void sub_8149864(struct Sprite *sprite); -static bool8 MugshotTrainerPic_Nothing(struct Sprite *sprite); -static bool8 MugshotTrainerPic_SetSlideOffsets(struct Sprite *sprite); -static bool8 MugshotTrainerPic_Slide1(struct Sprite *sprite); -static bool8 MugshotTrainerPic_Slide2(struct Sprite *sprite); -static bool8 MugshotTrainerPic_Slide3(struct Sprite *sprite); - -static s16 sUnusedRectangularSpiralVar; +static void SpriteCB_WhiteBarFade(struct Sprite *sprite); +static bool8 MugshotTrainerPic_Pause(struct Sprite *sprite); +static bool8 MugshotTrainerPic_Init(struct Sprite *sprite); +static bool8 MugshotTrainerPic_Slide(struct Sprite *sprite); +static bool8 MugshotTrainerPic_SlideSlow(struct Sprite *sprite); +static bool8 MugshotTrainerPic_SlideOffscreen(struct Sprite *sprite); + +static s16 sDebug_RectangularSpiralData; static u8 sTestingTransitionId; static u8 sTestingTransitionState; -static struct StructRectangularSpiral sRectangularSpiralTransition[4]; +static struct RectangularSpiralLine sRectangularSpiralLines[4]; EWRAM_DATA static struct TransitionData *sTransitionData = NULL; @@ -297,7 +314,7 @@ static const u16 sRegirock_Palette[] = INCBIN_U16("graphics/battle_transitions/r static const u32 sRegice_Tilemap[] = INCBIN_U32("graphics/battle_transitions/regice.bin"); static const u32 sRegisteel_Tilemap[] = INCBIN_U32("graphics/battle_transitions/registeel.bin"); static const u32 sRegirock_Tilemap[] = INCBIN_U32("graphics/battle_transitions/regirock.bin"); -static const u16 gUnknown_085BDB14[] = INCBIN_U16("graphics/battle_transitions/85BDB14.gbapal"); +static const u16 sUnused_Palette[] = INCBIN_U16("graphics/battle_transitions/unused.gbapal"); static const u32 sKyogre_Tileset[] = INCBIN_U32("graphics/battle_transitions/kyogre.4bpp.lz"); static const u32 sKyogre_Tilemap[] = INCBIN_U32("graphics/battle_transitions/kyogre.bin.lz"); static const u32 sGroudon_Tileset[] = INCBIN_U32("graphics/battle_transitions/groudon.4bpp.lz"); @@ -334,13 +351,13 @@ static const TaskFunc sTasks_Main[B_TRANSITION_COUNT] = [B_TRANSITION_SHUFFLE] = Task_Shuffle, [B_TRANSITION_BIG_POKEBALL] = Task_BigPokeball, [B_TRANSITION_POKEBALLS_TRAIL] = Task_PokeballsTrail, - [B_TRANSITION_CLOCKWISE_BLACKFADE] = Task_Clockwise_BlackFade, + [B_TRANSITION_CLOCKWISE_WIPE] = Task_ClockwiseWipe, [B_TRANSITION_RIPPLE] = Task_Ripple, [B_TRANSITION_WAVE] = Task_Wave, [B_TRANSITION_SLICE] = Task_Slice, - [B_TRANSITION_WHITEFADE] = Task_WhiteFade, + [B_TRANSITION_WHITE_BARS_FADE] = Task_WhiteBarsFade, [B_TRANSITION_GRID_SQUARES] = Task_GridSquares, - [B_TRANSITION_SHARDS] = Task_Shards, + [B_TRANSITION_ANGLED_WIPES] = Task_AngledWipes, [B_TRANSITION_SIDNEY] = Task_Sidney, [B_TRANSITION_PHOEBE] = Task_Phoebe, [B_TRANSITION_GLACIA] = Task_Glacia, @@ -355,8 +372,8 @@ static const TaskFunc sTasks_Main[B_TRANSITION_COUNT] = [B_TRANSITION_GROUDON] = Task_Groudon, [B_TRANSITION_RAYQUAZA] = Task_Rayquaza, [B_TRANSITION_SHRED_SPLIT] = Task_ShredSplit, - [B_TRANSITION_BLACKHOLE1] = Task_Blackhole1, - [B_TRANSITION_BLACKHOLE2] = Task_Blackhole2, + [B_TRANSITION_BLACKHOLE] = Task_Blackhole, + [B_TRANSITION_BLACKHOLE_PULSATE] = Task_BlackholePulsate, [B_TRANSITION_RECTANGULAR_SPIRAL] = Task_RectangularSpiral, [B_TRANSITION_FRONTIER_LOGO_WIGGLE] = Task_FrontierLogoWiggle, [B_TRANSITION_FRONTIER_LOGO_WAVE] = Task_FrontierLogoWave, @@ -404,62 +421,62 @@ static const TransitionStateFunc sAqua_Funcs[] = { Aqua_Init, Aqua_SetGfx, - PatternWeave_1, - PatternWeave_2, - PatternWeave_3, + PatternWeave_Blend1, + PatternWeave_Blend2, + PatternWeave_FinishAppear, FramesCountdown, - PatternWeave_End + PatternWeave_CircularMask }; static const TransitionStateFunc sMagma_Funcs[] = { Magma_Init, Magma_SetGfx, - PatternWeave_1, - PatternWeave_2, - PatternWeave_3, + PatternWeave_Blend1, + PatternWeave_Blend2, + PatternWeave_FinishAppear, FramesCountdown, - PatternWeave_End + PatternWeave_CircularMask }; static const TransitionStateFunc sBigPokeball_Funcs[] = { BigPokeball_Init, BigPokeball_SetGfx, - PatternWeave_1, - PatternWeave_2, - PatternWeave_3, - PatternWeave_End + PatternWeave_Blend1, + PatternWeave_Blend2, + PatternWeave_FinishAppear, + PatternWeave_CircularMask }; static const TransitionStateFunc sRegice_Funcs[] = { Regi_Init, Regice_SetGfx, - PatternWeave_1, - PatternWeave_2, - PatternWeave_3, - PatternWeave_End + PatternWeave_Blend1, + PatternWeave_Blend2, + PatternWeave_FinishAppear, + PatternWeave_CircularMask }; static const TransitionStateFunc sRegisteel_Funcs[] = { Regi_Init, Registeel_SetGfx, - PatternWeave_1, - PatternWeave_2, - PatternWeave_3, - PatternWeave_End + PatternWeave_Blend1, + PatternWeave_Blend2, + PatternWeave_FinishAppear, + PatternWeave_CircularMask }; static const TransitionStateFunc sRegirock_Funcs[] = { Regi_Init, Regirock_SetGfx, - PatternWeave_1, - PatternWeave_2, - PatternWeave_3, - PatternWeave_End + PatternWeave_Blend1, + PatternWeave_Blend2, + PatternWeave_FinishAppear, + PatternWeave_CircularMask }; static const TransitionStateFunc sKyogre_Funcs[] = @@ -467,7 +484,7 @@ static const TransitionStateFunc sKyogre_Funcs[] = WeatherTrio_BgFadeBlack, WeatherTrio_WaitFade, Kyogre_Init, - Kyogre_PalettePulsate, + Kyogre_PaletteFlash, Kyogre_PaletteBrighten, FramesCountdown, WeatherDuo_FadeOut, @@ -481,31 +498,32 @@ static const TransitionStateFunc sPokeballsTrail_Funcs[] = PokeballsTrail_End }; -static const s16 sUnknown_085C8B88[2] = {-16, 256}; -static const s16 sUnknown_085C8B8C[5] = {0, 32, 64, 18, 48}; -static const s16 sUnknown_085C8B96[2] = {8, -8}; +#define NUM_POKEBALL_TRAILS 5 +static const s16 sPokeballsTrail_StartXCoords[2] = { -16, DISPLAY_WIDTH + 16 }; +static const s16 sPokeballsTrail_Delays[NUM_POKEBALL_TRAILS] = {0, 32, 64, 18, 48}; +static const s16 sPokeballsTrail_Speeds[2] = {8, -8}; -static const TransitionStateFunc sClockwise_BlackFade_Funcs[] = +static const TransitionStateFunc sClockwiseWipe_Funcs[] = { - Clockwise_BlackFade_Init, - Clockwise_BlackFade_Func2, - Clockwise_BlackFade_Func3, - Clockwise_BlackFade_Func4, - Clockwise_BlackFade_Func5, - Clockwise_BlackFade_Func6, - Clockwise_BlackFade_End + ClockwiseWipe_Init, + ClockwiseWipe_TopRight, + ClockwiseWipe_Right, + ClockwiseWipe_Bottom, + ClockwiseWipe_Left, + ClockwiseWipe_TopLeft, + ClockwiseWipe_End }; static const TransitionStateFunc sRipple_Funcs[] = { Ripple_Init, - Ripple_Func2 + Ripple_Main }; static const TransitionStateFunc sWave_Funcs[] = { Wave_Init, - Wave_Func2, + Wave_Main, Wave_End }; @@ -550,76 +568,87 @@ static const s16 sMugshotsOpponentCoords[MUGSHOTS_COUNT][2] = static const TransitionSpriteCallback sMugshotTrainerPicFuncs[] = { - MugshotTrainerPic_Nothing, - MugshotTrainerPic_SetSlideOffsets, - MugshotTrainerPic_Slide1, - MugshotTrainerPic_Slide2, - MugshotTrainerPic_Nothing, - MugshotTrainerPic_Slide3, - MugshotTrainerPic_Nothing + MugshotTrainerPic_Pause, + MugshotTrainerPic_Init, + MugshotTrainerPic_Slide, + MugshotTrainerPic_SlideSlow, + MugshotTrainerPic_Pause, + MugshotTrainerPic_SlideOffscreen, + MugshotTrainerPic_Pause }; -static const s16 sTrainerPicSlideOffsets1[2] = {12, -12}; -static const s16 sTrainerPicSlideOffsets2[2] = {-1, 1}; +// One element per slide direction. +// Sign of acceleration is opposite speed, so slide decelerates. +static const s16 sTrainerPicSlideSpeeds[2] = {12, -12}; +static const s16 sTrainerPicSlideAccels[2] = {-1, 1}; static const TransitionStateFunc sSlice_Funcs[] = { Slice_Init, - Slice_Func2, + Slice_Main, Slice_End }; static const TransitionStateFunc sShredSplit_Funcs[] = { ShredSplit_Init, - ShredSplit_Func2, - ShredSplit_Func3, + ShredSplit_Main, + ShredSplit_BrokenCheck, ShredSplit_End }; -static const u8 gUnknown_085C8C64[] = {39, 119}; -static const s16 gUnknown_085C8C66[] = {1, -1}; +static const u8 sShredSplit_SectionYCoords[] = {39, DISPLAY_HEIGHT - 41}; +static const s16 sShredSplit_SectionMoveDirs[] = {1, -1}; -static const TransitionStateFunc sBlackhole1_Funcs[] = +static const TransitionStateFunc sBlackhole_Funcs[] = { Blackhole_Init, - Blackhole1_Func2, - Blackhole1_Func3 + Blackhole_Vibrate, + Blackhole_GrowEnd }; -static const TransitionStateFunc sBlackhole2_Funcs[] = +static const TransitionStateFunc sBlackholePulsate_Funcs[] = { Blackhole_Init, - Blackhole2_Func2 + BlackholePulsate_Main }; -static const s16 gUnknown_085C8C80[] = {-6, 4}; +// Blackhole rapidly alternates adding these values to the radius, +// resulting in a vibrating shrink/grow effect. +static const s16 sBlackhole_Vibrations[] = {-6, 4}; static const TransitionStateFunc sRectangularSpiral_Funcs[] = { RectangularSpiral_Init, - RectangularSpiral_Func2, + RectangularSpiral_Main, RectangularSpiral_End }; -static const s16 gUnknown_085C8C90[] = {1, 27, 275, -1}; -static const s16 gUnknown_085C8C98[] = {2, 486, -1}; -static const s16 gUnknown_085C8C9E[] = {3, 262, -1}; -static const s16 gUnknown_085C8CA4[] = {4, 507, -2}; -static const s16 gUnknown_085C8CAA[] = {1, 213, -1}; -static const s16 gUnknown_085C8CB0[] = {2, 548, -2}; -static const s16 gUnknown_085C8CB6[] = {3, 196, -1}; -static const s16 gUnknown_085C8CBC[] = {4, 573, 309, -1}; -static const s16 gUnknown_085C8CC4[] = {1, 474, -1}; -static const s16 gUnknown_085C8CCA[] = {2, 295, 32, -1}; -static const s16 gUnknown_085C8CD2[] = {3, 58, -1}; -static const s16 gUnknown_085C8CD8[] = {4, 455, -1}; -static const s16 gUnknown_085C8CDE[] = {1, 540, -1}; -static const s16 gUnknown_085C8CE4[] = {2, 229, -1}; -static const s16 gUnknown_085C8CEA[] = {3, 244, 28, -1}; -static const s16 gUnknown_085C8CF2[] = {4, 517, -1}; - -static const s16 *const gUnknown_085C8CF8[] = +#define SPIRAL_END (-1) +#define SPIRAL_SKIP (-2) + +static const s16 gUnknown_085C8C90[] = {1, 27, 275, SPIRAL_END}; +static const s16 gUnknown_085C8C98[] = {2, 486, SPIRAL_END}; +static const s16 gUnknown_085C8C9E[] = {3, 262, SPIRAL_END}; +static const s16 gUnknown_085C8CA4[] = {4, 507, SPIRAL_SKIP}; + +static const s16 gUnknown_085C8CAA[] = {1, 213, SPIRAL_END}; +static const s16 gUnknown_085C8CB0[] = {2, 548, SPIRAL_SKIP}; +static const s16 gUnknown_085C8CB6[] = {3, 196, SPIRAL_END}; +static const s16 gUnknown_085C8CBC[] = {4, 573, 309, SPIRAL_END}; + +static const s16 gUnknown_085C8CC4[] = {1, 474, SPIRAL_END}; +static const s16 gUnknown_085C8CCA[] = {2, 295, 32, SPIRAL_END}; +static const s16 gUnknown_085C8CD2[] = {3, 58, SPIRAL_END}; +static const s16 gUnknown_085C8CD8[] = {4, 455, SPIRAL_END}; + +static const s16 gUnknown_085C8CDE[] = {1, 540, SPIRAL_END}; +static const s16 gUnknown_085C8CE4[] = {2, 229, SPIRAL_END}; +static const s16 gUnknown_085C8CEA[] = {3, 244, 28, SPIRAL_END}; +static const s16 gUnknown_085C8CF2[] = {4, 517, SPIRAL_END}; + +// Move data for spiral lines starting in the top left / bottom right +static const s16 *const sRectangularSpiral_MoveDataTable_MajorDiagonal[] = { gUnknown_085C8C90, gUnknown_085C8CA4, @@ -631,7 +660,8 @@ static const s16 *const gUnknown_085C8CF8[] = gUnknown_085C8CDE }; -static const s16 *const gUnknown_085C8D18[] = +// Move data for spiral lines starting in the top right / bottom left +static const s16 *const sRectangularSpiral_MoveDataTable_MinorDiagonal[] = { gUnknown_085C8CBC, gUnknown_085C8CB0, @@ -643,10 +673,10 @@ static const s16 *const gUnknown_085C8D18[] = gUnknown_085C8CD2 }; -static const s16 *const *const gUnknown_085C8D38[] = +static const s16 *const *const sRectangularSpiral_MoveDataTables[] = { - gUnknown_085C8CF8, - gUnknown_085C8D18 + sRectangularSpiral_MoveDataTable_MajorDiagonal, + sRectangularSpiral_MoveDataTable_MinorDiagonal }; static const TransitionStateFunc sGroudon_Funcs[] = @@ -654,7 +684,7 @@ static const TransitionStateFunc sGroudon_Funcs[] = WeatherTrio_BgFadeBlack, WeatherTrio_WaitFade, Groudon_Init, - Groudon_PalettePulsate, + Groudon_PaletteFlash, Groudon_PaletteBrighten, FramesCountdown, WeatherDuo_FadeOut, @@ -665,61 +695,65 @@ static const TransitionStateFunc sRayquaza_Funcs[] = { WeatherTrio_BgFadeBlack, WeatherTrio_WaitFade, - Rayquaza_Func3, - Rayquaza_Func4, - Rayquaza_Func5, - Rayquaza_Func6, - Rayquaza_Func7, - Rayquaza_Func8, - Rayquaza_Func9, - Blackhole1_Func2, - Blackhole1_Func3 + Rayquaza_Init, + Rayquaza_SetGfx, + Rayquaza_PaletteFlash, + Rayquaza_FadeToBlack, + Rayquaza_WaitFade, + Rayquaza_SetBlack, + Rayquaza_TriRing, + Blackhole_Vibrate, + Blackhole_GrowEnd }; -static const TransitionStateFunc sWhiteFade_Funcs[] = +static const TransitionStateFunc sWhiteBarsFade_Funcs[] = { - WhiteFade_Init, - WhiteFade_Func2, - WhiteFade_Func3, - WhiteFade_Func4, - WhiteFade_End + WhiteBarsFade_Init, + WhiteBarsFade_StartBars, + WhiteBarsFade_WaitBars, + WhiteBarsFade_BlendToBlack, + WhiteBarsFade_End }; -static const s16 sUnknown_085C8DA0[] = {0, 20, 15, 40, 10, 25, 35, 5}; +#define NUM_WHITE_BARS 8 +static const s16 sWhiteBarsFade_StartDelays[NUM_WHITE_BARS] = {0, 20, 15, 40, 10, 25, 35, 5}; static const TransitionStateFunc sGridSquares_Funcs[] = { GridSquares_Init, - GridSquares_Func2, + GridSquares_Main, GridSquares_End }; -static const TransitionStateFunc sShards_Funcs[] = +static const TransitionStateFunc sAngledWipes_Funcs[] = { - Shards_Init, - Shards_Func2, - Shards_Func3, - Shards_Func4, - Shards_Func5 + AngledWipes_Init, + AngledWipes_SetWipeData, + AngledWipes_DoWipe, + AngledWipes_TryEnd, + AngledWipes_StartNext }; -static const s16 sUnknown_085C8DD0[][5] = +#define NUM_ANGLED_WIPES 7 + +static const s16 sAngledWipes_MoveData[NUM_ANGLED_WIPES][5] = { - {56, 0, 0, 160, 0}, - {104, 160, 240, 88, 1}, - {240, 72, 56, 0, 1}, - {0, 32, 144, 160, 0}, - {144, 160, 184, 0, 1}, - {56, 0, 168, 160, 0}, - {168, 160, 48, 0, 1}, +// startX startY endX endY yDirection + {56, 0, 0, DISPLAY_HEIGHT, 0}, + {104, DISPLAY_HEIGHT, DISPLAY_WIDTH, 88, 1}, + {DISPLAY_WIDTH, 72, 56, 0, 1}, + {0, 32, 144, DISPLAY_HEIGHT, 0}, + {144, DISPLAY_HEIGHT, 184, 0, 1}, + {56, 0, 168, DISPLAY_HEIGHT, 0}, + {168, DISPLAY_HEIGHT, 48, 0, 1}, }; -static const s16 sUnknown_085C8E16[] = {8, 4, 2, 1, 1, 1, 0}; +static const s16 sAngledWipes_EndDelays[NUM_ANGLED_WIPES] = {8, 4, 2, 1, 1, 1, 0}; static const TransitionStateFunc sTransitionIntroFuncs[] = { - Transition_Intro_1, - Transition_Intro_2 + TransitionIntro_FadeToGray, + TransitionIntro_FadeFromGray }; static const struct SpriteFrameImage sSpriteImage_Pokeball[] = @@ -759,12 +793,12 @@ static const union AffineAnimCmd *const sSpriteAffineAnimTable_Pokeball[] = static const struct SpriteTemplate sSpriteTemplate_Pokeball = { .tileTag = TAG_NONE, - .paletteTag = FLDEFF_PAL_TAG_POKEBALL, + .paletteTag = FLDEFF_PAL_TAG_POKEBALL_TRAIL, .oam = &gObjectEventBaseOam_32x32, .anims = sSpriteAnimTable_Pokeball, .images = sSpriteImage_Pokeball, .affineAnims = sSpriteAffineAnimTable_Pokeball, - .callback = SpriteCB_FldEffPokeball + .callback = SpriteCB_FldEffPokeballTrail }; static const struct OamData sOam_UnusedBrendanLass = @@ -829,7 +863,7 @@ static const struct SpriteTemplate sSpriteTemplate_UnusedLass = static const u16 sFieldEffectPal_Pokeball[] = INCBIN_U16("graphics/field_effects/palettes/pokeball.gbapal"); -const struct SpritePalette gSpritePalette_Pokeball = {sFieldEffectPal_Pokeball, FLDEFF_PAL_TAG_POKEBALL}; +const struct SpritePalette gSpritePalette_Pokeball = {sFieldEffectPal_Pokeball, FLDEFF_PAL_TAG_POKEBALL_TRAIL}; static const u16 sMugshotPal_Sidney[] = INCBIN_U16("graphics/battle_transitions/sidney_bg.gbapal"); static const u16 sMugshotPal_Phoebe[] = INCBIN_U16("graphics/battle_transitions/phoebe_bg.gbapal"); @@ -864,10 +898,10 @@ static const TransitionStateFunc sFrontierLogoWiggle_Funcs[] = { FrontierLogoWiggle_Init, FrontierLogoWiggle_SetGfx, - PatternWeave_1, - PatternWeave_2, - PatternWeave_3, - PatternWeave_End + PatternWeave_Blend1, + PatternWeave_Blend2, + PatternWeave_FinishAppear, + PatternWeave_CircularMask }; static const TransitionStateFunc sFrontierLogoWave_Funcs[] = @@ -881,8 +915,8 @@ static const TransitionStateFunc sFrontierLogoWave_Funcs[] = static const TransitionStateFunc sFrontierSquares_Funcs[] = { FrontierSquares_Init, - FrontierSquares_Func2, - FrontierSquares_Func3, + FrontierSquares_Draw, + FrontierSquares_Shrink, FrontierSquares_End }; @@ -968,9 +1002,6 @@ void BattleTransition_Start(u8 transitionId) LaunchBattleTransitionTask(transitionId); } -// in all tasks data[0] is reserved for the state -#define tState data[0] - // main task that launches sub-tasks for phase1 and phase2 #define tTransitionId data[1] #define tTransitionDone data[15] @@ -1063,11 +1094,6 @@ static void Task_Intro(u8 taskId) } } -#define tFuncState data[7] -#define tOpponentSpriteId data[13] -#define tPlayerSpriteId data[14] -#define tMugshotId data[15] - //-------------------- // B_TRANSITION_BLUR //-------------------- @@ -1270,10 +1296,10 @@ static void HBlankCB_Shuffle(void) #define tBlendTarget2 data[2] #define tBlendDelay data[3] -// Data 1-3 change purpose for PatternWeave_End -#define tEndAmplitude data[1] -#define tEndAmplitudeDelta data[2] -#define tVBlankSet data[3] +// Data 1-3 change purpose for PatternWeave_CircularMask +#define tRadius data[1] +#define tRadiusDelta data[2] +#define tVBlankSet data[3] #define tSinIndex data[4] #define tAmplitude data[5] @@ -1407,7 +1433,7 @@ static bool8 BigPokeball_SetGfx(struct Task *task) for (i = 0; i < 20; i++) { for (j = 0; j < 30; j++, bigPokeballMap++) - SET_TILEMAP_TILE(tilemap, i, j, *bigPokeballMap | 0xF000); + SET_TILE(tilemap, i, j, *bigPokeballMap); } SetSinWave(gScanlineEffectRegBuffers[0], 0, task->tSinIndex, 132, task->tAmplitude, DISPLAY_HEIGHT); @@ -1494,13 +1520,13 @@ static bool8 Kyogre_Init(struct Task *task) return FALSE; } -static bool8 Kyogre_PalettePulsate(struct Task *task) +static bool8 Kyogre_PaletteFlash(struct Task *task) { if (task->tTimer % 3 == 0) { - u16 var = task->tTimer % 30; - var /= 3; - LoadPalette(sKyogre1_Palette + (var * 16), 0xF0, 0x20); + u16 offset = task->tTimer % 30; + offset /= 3; + LoadPalette(&sKyogre1_Palette[offset * 16], 0xF0, 0x20); } if (++task->tTimer > 58) { @@ -1515,8 +1541,8 @@ static bool8 Kyogre_PaletteBrighten(struct Task *task) { if (task->tTimer % 5 == 0) { - s16 var = task->tTimer / 5; - LoadPalette(sKyogre2_Palette + (var * 16), 0xF0, 0x20); + s16 offset = task->tTimer / 5; + LoadPalette(&sKyogre2_Palette[offset * 16], 0xF0, 0x20); } if (++task->tTimer > 68) { @@ -1551,7 +1577,7 @@ static bool8 WeatherDuo_End(struct Task *task) // The PatternWeave_ functions are used by several different transitions. // They create an effect where a pattern/image (such as the Magma emblem) is // formed by a shimmering weave effect. -static bool8 PatternWeave_1(struct Task *task) +static bool8 PatternWeave_Blend1(struct Task *task) { sTransitionData->VBlank_DMA = FALSE; if (task->tBlendDelay == 0 || --task->tBlendDelay == 0) @@ -1571,7 +1597,7 @@ static bool8 PatternWeave_1(struct Task *task) return FALSE; } -static bool8 PatternWeave_2(struct Task *task) +static bool8 PatternWeave_Blend2(struct Task *task) { sTransitionData->VBlank_DMA = FALSE; if (task->tBlendDelay == 0 || --task->tBlendDelay == 0) @@ -1591,7 +1617,7 @@ static bool8 PatternWeave_2(struct Task *task) return FALSE; } -static bool8 PatternWeave_3(struct Task *task) +static bool8 PatternWeave_FinishAppear(struct Task *task) { sTransitionData->VBlank_DMA = FALSE; task->tSinIndex += 8; @@ -1602,8 +1628,8 @@ static bool8 PatternWeave_3(struct Task *task) if (task->tAmplitude <= 0) { task->tState++; - task->tEndAmplitude = 160; - task->tEndAmplitudeDelta = 256; + task->tRadius = DISPLAY_HEIGHT; + task->tRadiusDelta = 1 << 8; task->tVBlankSet = FALSE; } @@ -1632,19 +1658,20 @@ static bool8 WeatherTrio_WaitFade(struct Task *task) return FALSE; } -static bool8 PatternWeave_End(struct Task *task) +// Do a shrinking circular mask to go to a black screen after the pattern appears. +static bool8 PatternWeave_CircularMask(struct Task *task) { sTransitionData->VBlank_DMA = FALSE; - if (task->tEndAmplitudeDelta < 1024) - task->tEndAmplitudeDelta += 128; - if (task->tEndAmplitude != 0) + if (task->tRadiusDelta < (4 << 8)) + task->tRadiusDelta += 128; // 256 is 1 unit of speed. Speed up every other frame (128 / 256) + if (task->tRadius != 0) { - task->tEndAmplitude -= task->tEndAmplitudeDelta >> 8; - if (task->tEndAmplitude < 0) - task->tEndAmplitude = 0; + task->tRadius -= task->tRadiusDelta >> 8; + if (task->tRadius < 0) + task->tRadius = 0; } - sub_814A014(gScanlineEffectRegBuffers[0], 120, 80, task->tEndAmplitude); - if (task->tEndAmplitude == 0) + SetCircularMask(gScanlineEffectRegBuffers[0], DISPLAY_WIDTH / 2, DISPLAY_HEIGHT / 2, task->tRadius); + if (task->tRadius == 0) { SetVBlankCallback(NULL); DmaStop(0); @@ -1656,16 +1683,14 @@ static bool8 PatternWeave_End(struct Task *task) if (!task->tVBlankSet) { task->tVBlankSet++; - SetVBlankCallback(VBlankCB1_BigPokeball); + SetVBlankCallback(VBlankCB_CircularMask); } - sTransitionData->VBlank_DMA++; } - return FALSE; } -static void Transition_BigPokeball_Vblank(void) +static void VBlankCB_SetWinAndBlend(void) { DmaStop(0); VBlankCB_BattleTransition(); @@ -1680,13 +1705,13 @@ static void Transition_BigPokeball_Vblank(void) static void VBlankCB_PatternWeave(void) { - Transition_BigPokeball_Vblank(); + VBlankCB_SetWinAndBlend(); DmaSet(0, gScanlineEffectRegBuffers[1], ®_BG0HOFS, B_TRANS_DMA_FLAGS); } -static void VBlankCB1_BigPokeball(void) +static void VBlankCB_CircularMask(void) { - Transition_BigPokeball_Vblank(); + VBlankCB_SetWinAndBlend(); DmaSet(0, gScanlineEffectRegBuffers[1], ®_WIN0H, B_TRANS_DMA_FLAGS); } @@ -1694,9 +1719,18 @@ static void VBlankCB1_BigPokeball(void) #undef tSinIndex #undef tBlendTarget1 #undef tBlendTarget2 -#undef tEndAmplitude +#undef tRadius +#undef tRadiusDelta #undef tVBlankSet +//------------------------------ +// B_TRANSITION_POKEBALLS_TRAIL +//------------------------------ + +#define sSide data[0] +#define sDelay data[1] +#define sPrevX data[2] + static void Task_PokeballsTrail(u8 taskId) { while (sPokeballsTrail_Funcs[gTasks[taskId].tState](&gTasks[taskId])); @@ -1718,20 +1752,22 @@ static bool8 PokeballsTrail_Init(struct Task *task) static bool8 PokeballsTrail_Main(struct Task *task) { s16 i; - s16 rand; - s16 xCoords[ARRAY_COUNT(sUnknown_085C8B88)]; - s16 arr1[ARRAY_COUNT(sUnknown_085C8B8C)]; - - memcpy(xCoords, sUnknown_085C8B88, sizeof(sUnknown_085C8B88)); - memcpy(arr1, sUnknown_085C8B8C, sizeof(sUnknown_085C8B8C)); - rand = Random() & 1; - for (i = 0; i <= 4; i++, rand ^= 1) + s16 side; + s16 startX[ARRAY_COUNT(sPokeballsTrail_StartXCoords)]; + s16 delays[ARRAY_COUNT(sPokeballsTrail_Delays)]; + memcpy(startX, sPokeballsTrail_StartXCoords, sizeof(sPokeballsTrail_StartXCoords)); + memcpy(delays, sPokeballsTrail_Delays, sizeof(sPokeballsTrail_Delays)); + + // Randomly pick which side the first ball should start on. + // The side is then flipped for each subsequent ball. + side = Random() & 1; + for (i = 0; i < NUM_POKEBALL_TRAILS; i++, side ^= 1) { - gFieldEffectArguments[0] = xCoords[rand]; // x - gFieldEffectArguments[1] = (i * 32) + 16; // y - gFieldEffectArguments[2] = rand; - gFieldEffectArguments[3] = arr1[i]; - FieldEffectStart(FLDEFF_POKEBALL); + gFieldEffectArguments[0] = startX[side]; // x + gFieldEffectArguments[1] = (i * 32) + 16; // y + gFieldEffectArguments[2] = side; + gFieldEffectArguments[3] = delays[i]; + FieldEffectStart(FLDEFF_POKEBALL_TRAIL); } task->tState++; @@ -1740,7 +1776,7 @@ static bool8 PokeballsTrail_Main(struct Task *task) static bool8 PokeballsTrail_End(struct Task *task) { - if (!FieldEffectActiveListContains(FLDEFF_POKEBALL)) + if (!FieldEffectActiveListContains(FLDEFF_POKEBALL_TRAIL)) { FadeScreenBlack(); DestroyTask(FindTaskIdByFunc(Task_PokeballsTrail)); @@ -1748,70 +1784,72 @@ static bool8 PokeballsTrail_End(struct Task *task) return FALSE; } -#define sData0 data[0] -#define sData1 data[1] -#define sData2 data[2] - -bool8 FldEff_Pokeball(void) +bool8 FldEff_PokeballTrail(void) { u8 spriteId = CreateSpriteAtEnd(&sSpriteTemplate_Pokeball, gFieldEffectArguments[0], gFieldEffectArguments[1], 0); gSprites[spriteId].oam.priority = 0; gSprites[spriteId].oam.affineMode = ST_OAM_AFFINE_NORMAL; - gSprites[spriteId].sData0 = gFieldEffectArguments[2]; - gSprites[spriteId].sData1 = gFieldEffectArguments[3]; - gSprites[spriteId].sData2 = -1; + gSprites[spriteId].sSide = gFieldEffectArguments[2]; + gSprites[spriteId].sDelay = gFieldEffectArguments[3]; + gSprites[spriteId].sPrevX = -1; InitSpriteAffineAnim(&gSprites[spriteId]); StartSpriteAffineAnim(&gSprites[spriteId], gFieldEffectArguments[2]); return FALSE; } -static void SpriteCB_FldEffPokeball(struct Sprite *sprite) +static void SpriteCB_FldEffPokeballTrail(struct Sprite *sprite) { - s16 arr0[ARRAY_COUNT(sUnknown_085C8B96)]; + s16 speeds[ARRAY_COUNT(sPokeballsTrail_Speeds)]; + memcpy(speeds, sPokeballsTrail_Speeds, sizeof(sPokeballsTrail_Speeds)); - memcpy(arr0, sUnknown_085C8B96, sizeof(sUnknown_085C8B96)); - if (sprite->sData1 != 0) + if (sprite->sDelay != 0) { - sprite->sData1--; + sprite->sDelay--; } else { if (sprite->x >= 0 && sprite->x <= DISPLAY_WIDTH) { + // Set Pokéball position s16 posX = sprite->x >> 3; s16 posY = sprite->y >> 3; - if (posX != sprite->sData2) + // If Pokéball moved forward clear trail behind it + if (posX != sprite->sPrevX) { u32 var; u16 *ptr; - sprite->sData2 = posX; - var = (((REG_BG0CNT >> 8) & 0x1F) << 11); - ptr = (u16 *)(VRAM + var); + sprite->sPrevX = posX; + var = ((REG_BG0CNT >> 8) & 0x1F) << 11; + ptr = (u16 *)(BG_VRAM + var); - SET_TILEMAP_TILE(ptr, posY - 2, posX, 0xF001); - SET_TILEMAP_TILE(ptr, posY - 1, posX, 0xF001); - SET_TILEMAP_TILE(ptr, posY - 0, posX, 0xF001); - SET_TILEMAP_TILE(ptr, posY + 1, posX, 0xF001); + SET_TILE(ptr, posY - 2, posX, 1); + SET_TILE(ptr, posY - 1, posX, 1); + SET_TILE(ptr, posY - 0, posX, 1); + SET_TILE(ptr, posY + 1, posX, 1); } } - sprite->x += arr0[sprite->sData0]; + sprite->x += speeds[sprite->sSide]; if (sprite->x < -15 || sprite->x > DISPLAY_WIDTH + 15) - FieldEffectStop(sprite, FLDEFF_POKEBALL); + FieldEffectStop(sprite, FLDEFF_POKEBALL_TRAIL); } } -#undef sData0 -#undef sData1 -#undef sData2 +#undef sSide +#undef sDelay +#undef sPrevX + +//----------------------------- +// B_TRANSITION_CLOCKWISE_WIPE +//----------------------------- -static void Task_Clockwise_BlackFade(u8 taskId) +static void Task_ClockwiseWipe(u8 taskId) { - while (sClockwise_BlackFade_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sClockwiseWipe_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static bool8 Clockwise_BlackFade_Init(struct Task *task) +static bool8 ClockwiseWipe_Init(struct Task *task) { u16 i; @@ -1824,29 +1862,29 @@ static bool8 Clockwise_BlackFade_Init(struct Task *task) sTransitionData->WIN0V = DISPLAY_HEIGHT; for (i = 0; i < DISPLAY_HEIGHT; i++) - gScanlineEffectRegBuffers[1][i] = WIN_RANGE(DISPLAY_WIDTH + 3, DISPLAY_WIDTH + 4); + gScanlineEffectRegBuffers[1][i] = ((DISPLAY_WIDTH + 3) << 8) | (DISPLAY_WIDTH + 4); - SetVBlankCallback(VBlankCB_Clockwise_BlackFade); - sTransitionData->data[4] = 120; + SetVBlankCallback(VBlankCB_ClockwiseWipe); + sTransitionData->tWipeEndX = DISPLAY_WIDTH / 2; task->tState++; return TRUE; } -static bool8 Clockwise_BlackFade_Func2(struct Task *task) +static bool8 ClockwiseWipe_TopRight(struct Task *task) { sTransitionData->VBlank_DMA = FALSE; - sub_814A1AC(sTransitionData->data, 120, 80, sTransitionData->data[4], -1, 1, 1); + InitBlackWipe(sTransitionData->data, DISPLAY_WIDTH / 2, DISPLAY_HEIGHT / 2, sTransitionData->tWipeEndX, -1, 1, 1); do { - gScanlineEffectRegBuffers[0][sTransitionData->data[3]] = (sTransitionData->data[2] + 1) | 0x7800; - } while (!sub_814A228(sTransitionData->data, 1, 1)); + gScanlineEffectRegBuffers[0][sTransitionData->tWipeCurrY] = (sTransitionData->tWipeCurrX + 1) | ((DISPLAY_WIDTH / 2) << 8); + } while (!UpdateBlackWipe(sTransitionData->data, TRUE, TRUE)); - sTransitionData->data[4] += 16; - if (sTransitionData->data[4] >= DISPLAY_WIDTH) + sTransitionData->tWipeEndX += 16; + if (sTransitionData->tWipeEndX >= DISPLAY_WIDTH) { - sTransitionData->data[5] = 0; + sTransitionData->tWipeEndY = 0; task->tState++; } @@ -1854,56 +1892,56 @@ static bool8 Clockwise_BlackFade_Func2(struct Task *task) return FALSE; } -static bool8 Clockwise_BlackFade_Func3(struct Task *task) +static bool8 ClockwiseWipe_Right(struct Task *task) { - s16 r1, r3; - vu8 var = 0; + s16 start, end; + vu8 finished = FALSE; sTransitionData->VBlank_DMA = FALSE; - sub_814A1AC(sTransitionData->data, 120, 80, 240, sTransitionData->data[5], 1, 1); + InitBlackWipe(sTransitionData->data, DISPLAY_WIDTH / 2, DISPLAY_HEIGHT / 2, DISPLAY_WIDTH, sTransitionData->tWipeEndY, 1, 1); while (1) { - r1 = 120, r3 = sTransitionData->data[2] + 1; - if (sTransitionData->data[5] >= DISPLAY_HEIGHT / 2) - r1 = sTransitionData->data[2], r3 = DISPLAY_WIDTH; - gScanlineEffectRegBuffers[0][sTransitionData->data[3]] = (r3) | (r1 << 8); - if (var != 0) + start = DISPLAY_WIDTH / 2, end = sTransitionData->tWipeCurrX + 1; + if (sTransitionData->tWipeEndY >= DISPLAY_HEIGHT / 2) + start = sTransitionData->tWipeCurrX, end = DISPLAY_WIDTH; + gScanlineEffectRegBuffers[0][sTransitionData->tWipeCurrY] = end | (start << 8); + if (finished) break; - var = sub_814A228(sTransitionData->data, 1, 1); + finished = UpdateBlackWipe(sTransitionData->data, TRUE, TRUE); } - sTransitionData->data[5] += 8; - if (sTransitionData->data[5] >= DISPLAY_HEIGHT) + sTransitionData->tWipeEndY += 8; + if (sTransitionData->tWipeEndY >= DISPLAY_HEIGHT) { - sTransitionData->data[4] = DISPLAY_WIDTH; + sTransitionData->tWipeEndX = DISPLAY_WIDTH; task->tState++; } else { - while (sTransitionData->data[3] < sTransitionData->data[5]) - gScanlineEffectRegBuffers[0][++sTransitionData->data[3]] = (r3) | (r1 << 8); + while (sTransitionData->tWipeCurrY < sTransitionData->tWipeEndY) + gScanlineEffectRegBuffers[0][++sTransitionData->tWipeCurrY] = end | (start << 8); } sTransitionData->VBlank_DMA++; return FALSE; } -static bool8 Clockwise_BlackFade_Func4(struct Task *task) +static bool8 ClockwiseWipe_Bottom(struct Task *task) { sTransitionData->VBlank_DMA = FALSE; - sub_814A1AC(sTransitionData->data, 120, 80, sTransitionData->data[4], 160, 1, 1); + InitBlackWipe(sTransitionData->data, DISPLAY_WIDTH / 2, DISPLAY_HEIGHT / 2, sTransitionData->tWipeEndX, DISPLAY_HEIGHT, 1, 1); do { - gScanlineEffectRegBuffers[0][sTransitionData->data[3]] = (sTransitionData->data[2] << 8) | 0xF0; - } while (!sub_814A228(sTransitionData->data, 1, 1)); + gScanlineEffectRegBuffers[0][sTransitionData->tWipeCurrY] = (sTransitionData->tWipeCurrX << 8) | DISPLAY_WIDTH; + } while (!UpdateBlackWipe(sTransitionData->data, TRUE, TRUE)); - sTransitionData->data[4] -= 16; - if (sTransitionData->data[4] <= 0) + sTransitionData->tWipeEndX -= 16; + if (sTransitionData->tWipeEndX <= 0) { - sTransitionData->data[5] = DISPLAY_HEIGHT; + sTransitionData->tWipeEndY = DISPLAY_HEIGHT; task->tState++; } @@ -1911,79 +1949,75 @@ static bool8 Clockwise_BlackFade_Func4(struct Task *task) return FALSE; } -static bool8 Clockwise_BlackFade_Func5(struct Task *task) +static bool8 ClockwiseWipe_Left(struct Task *task) { - s16 r1, r2, var4; - vu8 var = 0; + s16 end, start, temp; + vu8 finished = FALSE; sTransitionData->VBlank_DMA = FALSE; - sub_814A1AC(sTransitionData->data, 120, 80, 0, sTransitionData->data[5], 1, 1); + InitBlackWipe(sTransitionData->data, DISPLAY_WIDTH / 2, DISPLAY_HEIGHT / 2, 0, sTransitionData->tWipeEndY, 1, 1); while (1) { - r1 = (gScanlineEffectRegBuffers[0][sTransitionData->data[3]]) & 0xFF; - r2 = sTransitionData->data[2]; - if (sTransitionData->data[5] <= DISPLAY_HEIGHT / 2) - r2 = 120, r1 = sTransitionData->data[2]; - var4 = (r1) | (r2 << 8); - gScanlineEffectRegBuffers[0][sTransitionData->data[3]] = var4; - if (var != 0) + end = (gScanlineEffectRegBuffers[0][sTransitionData->tWipeCurrY]) & 0xFF; + start = sTransitionData->tWipeCurrX; + if (sTransitionData->tWipeEndY <= DISPLAY_HEIGHT / 2) + start = DISPLAY_WIDTH / 2, end = sTransitionData->tWipeCurrX; + temp = end | (start << 8); + gScanlineEffectRegBuffers[0][sTransitionData->tWipeCurrY] = temp; + if (finished) break; - var = sub_814A228(sTransitionData->data, 1, 1); + finished = UpdateBlackWipe(sTransitionData->data, TRUE, TRUE); } - sTransitionData->data[5] -= 8; - if (sTransitionData->data[5] <= 0) + sTransitionData->tWipeEndY -= 8; + if (sTransitionData->tWipeEndY <= 0) { - sTransitionData->data[4] = 0; + sTransitionData->tWipeEndX = 0; task->tState++; } else { - while (sTransitionData->data[3] > sTransitionData->data[5]) - { - gScanlineEffectRegBuffers[0][--sTransitionData->data[3]] = (r1) | (r2 << 8); - } + while (sTransitionData->tWipeCurrY > sTransitionData->tWipeEndY) + gScanlineEffectRegBuffers[0][--sTransitionData->tWipeCurrY] = end | (start << 8); } sTransitionData->VBlank_DMA++; return FALSE; } -static bool8 Clockwise_BlackFade_Func6(struct Task *task) +static bool8 ClockwiseWipe_TopLeft(struct Task *task) { sTransitionData->VBlank_DMA = FALSE; - sub_814A1AC(sTransitionData->data, 120, 80, sTransitionData->data[4], 0, 1, 1); + InitBlackWipe(sTransitionData->data, DISPLAY_WIDTH / 2, DISPLAY_HEIGHT / 2, sTransitionData->tWipeEndX, 0, 1, 1); do { - s16 r2, r3; - - r2 = 120, r3 = sTransitionData->data[2]; - if (sTransitionData->data[2] >= 120) - r2 = 0, r3 = DISPLAY_WIDTH; - gScanlineEffectRegBuffers[0][sTransitionData->data[3]] = (r3) | (r2 << 8); - - } while (!sub_814A228(sTransitionData->data, 1, 1)); - - sTransitionData->data[4] += 16; - if (sTransitionData->data[2] > 120) + s16 start, end; + start = DISPLAY_WIDTH / 2, end = sTransitionData->tWipeCurrX; + if (sTransitionData->tWipeCurrX >= DISPLAY_WIDTH / 2) + start = 0, end = DISPLAY_WIDTH; + gScanlineEffectRegBuffers[0][sTransitionData->tWipeCurrY] = end | (start << 8); + } while (!UpdateBlackWipe(sTransitionData->data, TRUE, TRUE)); + + sTransitionData->tWipeEndX += 16; + if (sTransitionData->tWipeCurrX > DISPLAY_WIDTH / 2) task->tState++; sTransitionData->VBlank_DMA++; return FALSE; } -static bool8 Clockwise_BlackFade_End(struct Task *task) +static bool8 ClockwiseWipe_End(struct Task *task) { DmaStop(0); FadeScreenBlack(); - DestroyTask(FindTaskIdByFunc(Task_Clockwise_BlackFade)); + DestroyTask(FindTaskIdByFunc(Task_ClockwiseWipe)); return FALSE; } -static void VBlankCB_Clockwise_BlackFade(void) +static void VBlankCB_ClockwiseWipe(void) { DmaStop(0); VBlankCB_BattleTransition(); @@ -1996,6 +2030,15 @@ static void VBlankCB_Clockwise_BlackFade(void) DmaSet(0, gScanlineEffectRegBuffers[1], ®_WIN0H, B_TRANS_DMA_FLAGS); } +//--------------------- +// B_TRANSITION_RIPPLE +//--------------------- + +#define tSinVal data[1] +#define tAmplitudeVal data[2] +#define tTimer data[3] +#define tFadeStarted data[4] + static void Task_Ripple(u8 taskId) { while (sRipple_Funcs[gTasks[taskId].tState](&gTasks[taskId])); @@ -2020,34 +2063,34 @@ static bool8 Ripple_Init(struct Task *task) return TRUE; } -static bool8 Ripple_Func2(struct Task *task) +static bool8 Ripple_Main(struct Task *task) { u8 i; - s16 r3; - u16 r4, r8; + s16 amplitude; + u16 sinVal, speed; sTransitionData->VBlank_DMA = FALSE; - r3 = task->data[2] >> 8; - r4 = task->data[1]; - r8 = 384; - task->data[1] += 0x400; - if (task->data[2] <= 0x1FFF) - task->data[2] += 0x180; + amplitude = task->tAmplitudeVal >> 8; + sinVal = task->tSinVal; + speed = 0x180; + task->tSinVal += 0x400; + if (task->tAmplitudeVal <= 0x1FFF) + task->tAmplitudeVal += 0x180; - for (i = 0; i < DISPLAY_HEIGHT; i++, r4 += r8) + for (i = 0; i < DISPLAY_HEIGHT; i++, sinVal += speed) { - s16 var = r4 >> 8; - gScanlineEffectRegBuffers[0][i] = sTransitionData->cameraY + Sin(var & 0xffff, r3); + s16 sinIndex = sinVal >> 8; + gScanlineEffectRegBuffers[0][i] = sTransitionData->cameraY + Sin(sinIndex & 0xffff, amplitude); } - if (++task->data[3] == 81) + if (++task->tTimer == 81) { - task->data[4]++; + task->tFadeStarted++; BeginNormalPaletteFade(PALETTES_ALL, -2, 0, 16, RGB_BLACK); } - if (task->data[4] != 0 && !gPaletteFade.active) + if (task->tFadeStarted && !gPaletteFade.active) DestroyTask(FindTaskIdByFunc(Task_Ripple)); sTransitionData->VBlank_DMA++; @@ -2069,7 +2112,18 @@ static void HBlankCB_Ripple(void) REG_BG3VOFS = var; } +#undef tSinVal +#undef tAmplitudeVal +#undef tTimer +#undef tFadeStarted + +//------------------- // B_TRANSITION_WAVE +//------------------- + +#define tX data[1] +#define tSinIndex data[2] + static void Task_Wave(u8 taskId) { while (sWave_Funcs[gTasks[taskId].tState](&gTasks[taskId])); @@ -2096,30 +2150,30 @@ static bool8 Wave_Init(struct Task *task) return TRUE; } -static bool8 Wave_Func2(struct Task *task) +static bool8 Wave_Main(struct Task *task) { - u8 i, r5; + u8 i, sinIndex; u16* toStore; - bool8 nextFunc; + bool8 finished; sTransitionData->VBlank_DMA = FALSE; toStore = gScanlineEffectRegBuffers[0]; - r5 = task->data[2]; - task->data[2] += 16; - task->data[1] += 8; + sinIndex = task->tSinIndex; + task->tSinIndex += 16; + task->tX += 8; - for (i = 0, nextFunc = TRUE; i < DISPLAY_HEIGHT; i++, r5 += 4, toStore++) + for (i = 0, finished = TRUE; i < DISPLAY_HEIGHT; i++, sinIndex += 4, toStore++) { - s16 value = task->data[1] + Sin(r5, 40); - if (value < 0) - value = 0; - if (value > DISPLAY_WIDTH) - value = DISPLAY_WIDTH; - *toStore = (value << 8) | (DISPLAY_WIDTH + 1); - if (value < DISPLAY_WIDTH) - nextFunc = FALSE; + s16 x = task->tX + Sin(sinIndex, 40); + if (x < 0) + x = 0; + if (x > DISPLAY_WIDTH) + x = DISPLAY_WIDTH; + *toStore = (x << 8) | (DISPLAY_WIDTH + 1); + if (x < DISPLAY_WIDTH) + finished = FALSE; } - if (nextFunc) + if (finished) task->tState++; sTransitionData->VBlank_DMA++; @@ -2146,6 +2200,33 @@ static void VBlankCB_Wave(void) DmaSet(0, gScanlineEffectRegBuffers[1], ®_WIN0H, B_TRANS_DMA_FLAGS); } +#undef tX +#undef tSinIndex + +//---------------------------------------------------------------- +// B_TRANSITION_SIDNEY, B_TRANSITION_PHOEBE, B_TRANSITION_GLACIA, +// B_TRANSITION_DRAKE, and B_TRANSITION_CHAMPION +// +// These are all the "mugshot" transitions, where a banner shows +// the trainer pic of the player and their opponent. +//---------------------------------------------------------------- + +#define tSinIndex data[1] +#define tTopBannerX data[2] +#define tBottomBannerX data[3] +#define tTimer data[3] // Re-used +#define tFadeSpread data[4] +#define tOpponentSpriteId data[13] +#define tPlayerSpriteId data[14] +#define tMugshotId data[15] + +// Sprite data for trainer sprites in mugshots +#define sState data[0] +#define sSlideSpeed data[1] +#define sSlideAccel data[2] +#define sDone data[6] +#define sSlideDir data[7] + static void Task_Sidney(u8 taskId) { gTasks[taskId].tMugshotId = MUGSHOT_SIDNEY; @@ -2189,17 +2270,17 @@ static bool8 Mugshot_Init(struct Task *task) ScanlineEffect_Clear(); Mugshots_CreateTrainerPics(task); - task->data[1] = 0; - task->data[2] = 1; - task->data[3] = DISPLAY_WIDTH - 1; + task->tSinIndex = 0; + task->tTopBannerX = 1; + task->tBottomBannerX = DISPLAY_WIDTH - 1; sTransitionData->WININ = WININ_WIN0_ALL; sTransitionData->WINOUT = WINOUT_WIN01_BG1 | WINOUT_WIN01_BG2 | WINOUT_WIN01_BG3 | WINOUT_WIN01_OBJ | WINOUT_WIN01_CLR; sTransitionData->WIN0V = DISPLAY_HEIGHT; for (i = 0; i < DISPLAY_HEIGHT; i++) - gScanlineEffectRegBuffers[1][i] = 0xF0F1; + gScanlineEffectRegBuffers[1][i] = (DISPLAY_WIDTH << 8) | (DISPLAY_WIDTH + 1); - SetVBlankCallback(VBlankCB0_Mugshots); + SetVBlankCallback(VBlankCB_Mugshots); task->tState++; return FALSE; @@ -2220,7 +2301,7 @@ static bool8 Mugshot_SetGfx(struct Task *task) for (i = 0; i < 20; i++) { for (j = 0; j < 32; j++, mugshotsMap++) - SET_TILEMAP_TILE(tilemap, i, j, *mugshotsMap | 0xF000); + SET_TILE(tilemap, i, j, *mugshotsMap); } EnableInterrupts(INTR_FLAG_HBLANK); @@ -2232,43 +2313,49 @@ static bool8 Mugshot_SetGfx(struct Task *task) static bool8 Mugshot_ShowBanner(struct Task *task) { - u8 i, r5; + u8 i, sinIndex; u16* toStore; - s16 value; + s16 x; s32 mergedValue; sTransitionData->VBlank_DMA = FALSE; toStore = gScanlineEffectRegBuffers[0]; - r5 = task->data[1]; - task->data[1] += 16; + sinIndex = task->tSinIndex; + task->tSinIndex += 16; - for (i = 0; i < DISPLAY_HEIGHT / 2; i++, toStore++, r5 += 16) + // Update top banner + for (i = 0; i < DISPLAY_HEIGHT / 2; i++, toStore++, sinIndex += 16) { - value = task->data[2] + Sin(r5, 16); - if (value < 0) - value = 1; - if (value > DISPLAY_WIDTH) - value = DISPLAY_WIDTH; - *toStore = value; + x = task->tTopBannerX + Sin(sinIndex, 16); + if (x < 0) + x = 1; + if (x > DISPLAY_WIDTH) + x = DISPLAY_WIDTH; + *toStore = x; } - for (; i < DISPLAY_HEIGHT; i++, toStore++, r5 += 16) + + // Update bottom banner + for (; i < DISPLAY_HEIGHT; i++, toStore++, sinIndex += 16) { - value = task->data[3] - Sin(r5, 16); - if (value < 0) - value = 0; - if (value > DISPLAY_WIDTH - 1) - value = DISPLAY_WIDTH - 1; - *toStore = (value << 8) | (DISPLAY_WIDTH); + x = task->tBottomBannerX - Sin(sinIndex, 16); + if (x < 0) + x = 0; + if (x > DISPLAY_WIDTH - 1) + x = DISPLAY_WIDTH - 1; + *toStore = (x << 8) | DISPLAY_WIDTH; } - task->data[2] += 8; - task->data[3] -= 8; - if (task->data[2] > DISPLAY_WIDTH) - task->data[2] = DISPLAY_WIDTH; - if (task->data[3] < 0) - task->data[3] = 0; - mergedValue = *(s32*)(&task->data[2]); + // Slide banners across screen + task->tTopBannerX += 8; + task->tBottomBannerX -= 8; + + if (task->tTopBannerX > DISPLAY_WIDTH) + task->tTopBannerX = DISPLAY_WIDTH; + if (task->tBottomBannerX < 0) + task->tBottomBannerX = 0; + + mergedValue = *(s32*)(&task->tTopBannerX); if (mergedValue == DISPLAY_WIDTH) task->tState++; @@ -2289,15 +2376,19 @@ static bool8 Mugshot_StartOpponentSlide(struct Task *task) *toStore = DISPLAY_WIDTH; task->tState++; - task->data[1] = 0; - task->data[2] = 0; - task->data[3] = 0; + + // Clear old data + task->tSinIndex = 0; + task->tTopBannerX = 0; + task->tBottomBannerX = 0; sTransitionData->BG0HOFS_Lower -= 8; sTransitionData->BG0HOFS_Upper += 8; - SetTrainerPicSlideTable(task->tOpponentSpriteId, 0); - SetTrainerPicSlideTable(task->tPlayerSpriteId, 1); + SetTrainerPicSlideDirection(task->tOpponentSpriteId, 0); + SetTrainerPicSlideDirection(task->tPlayerSpriteId, 1); + + // Start opponent slide IncrementTrainerPicState(task->tOpponentSpriteId); PlaySE(SE_MUGSHOT); @@ -2311,7 +2402,7 @@ static bool8 Mugshot_WaitStartPlayerSlide(struct Task *task) sTransitionData->BG0HOFS_Lower -= 8; sTransitionData->BG0HOFS_Upper += 8; - // Start player's pic slide in once the opponent is finished + // Start player's slide in once the opponent is finished if (IsTrainerPicSlideDone(task->tOpponentSpriteId)) { task->tState++; @@ -2335,10 +2426,10 @@ static bool8 Mugshot_WaitPlayerSlide(struct Task *task) SetGpuReg(REG_OFFSET_WIN0H, DISPLAY_WIDTH); SetGpuReg(REG_OFFSET_BLDY, 0); task->tState++; - task->data[3] = 0; - task->data[4] = 0; + task->tTimer = 0; + task->tFadeSpread = 0; sTransitionData->BLDCNT = BLDCNT_TGT1_ALL | BLDCNT_EFFECT_LIGHTEN; - SetVBlankCallback(VBlankCB1_Mugshots); + SetVBlankCallback(VBlankCB_MugshotsFadeOut); } return FALSE; } @@ -2352,16 +2443,18 @@ static bool8 Mugshot_GradualWhiteFade(struct Task *task) sTransitionData->BG0HOFS_Lower -= 8; sTransitionData->BG0HOFS_Upper += 8; - if (task->data[4] < DISPLAY_HEIGHT / 2) - task->data[4] += 2; - if (task->data[4] > DISPLAY_HEIGHT / 2) - task->data[4] = DISPLAY_HEIGHT / 2; + if (task->tFadeSpread < DISPLAY_HEIGHT / 2) + task->tFadeSpread += 2; + if (task->tFadeSpread > DISPLAY_HEIGHT / 2) + task->tFadeSpread = DISPLAY_HEIGHT / 2; - if (++task->data[3] & 1) + if (++task->tTimer & 1) { s16 i; - for (i = 0, active = FALSE; i <= task->data[4]; i++) + for (i = 0, active = FALSE; i <= task->tFadeSpread; i++) { + // Fade starts in middle of screen and + // spreads outwards in both directions. s16 index1 = DISPLAY_HEIGHT / 2 - i; s16 index2 = DISPLAY_HEIGHT / 2 + i; if (gScanlineEffectRegBuffers[0][index1] <= 15) @@ -2377,19 +2470,21 @@ static bool8 Mugshot_GradualWhiteFade(struct Task *task) } } - if (task->data[4] == DISPLAY_HEIGHT / 2 && !active) + if (task->tFadeSpread == DISPLAY_HEIGHT / 2 && !active) task->tState++; sTransitionData->VBlank_DMA++; return FALSE; } +// Set palette to white to replace the scanline white fade +// before the screen fades to black. static bool8 Mugshot_InitFadeWhiteToBlack(struct Task *task) { sTransitionData->VBlank_DMA = FALSE; BlendPalettes(PALETTES_ALL, 16, RGB_WHITE); sTransitionData->BLDCNT = 0xFF; - task->data[3] = 0; + task->tTimer = 0; task->tState++; return TRUE; @@ -2399,9 +2494,9 @@ static bool8 Mugshot_FadeToBlack(struct Task *task) { sTransitionData->VBlank_DMA = FALSE; - task->data[3]++; - memset(gScanlineEffectRegBuffers[0], task->data[3], DISPLAY_HEIGHT * 2); - if (task->data[3] > 15) + task->tTimer++; + memset(gScanlineEffectRegBuffers[0], task->tTimer, DISPLAY_HEIGHT * 2); + if (task->tTimer > 15) task->tState++; sTransitionData->VBlank_DMA++; @@ -2416,7 +2511,7 @@ static bool8 Mugshot_End(struct Task *task) return FALSE; } -static void VBlankCB0_Mugshots(void) +static void VBlankCB_Mugshots(void) { DmaStop(0); VBlankCB_BattleTransition(); @@ -2429,7 +2524,7 @@ static void VBlankCB0_Mugshots(void) DmaSet(0, gScanlineEffectRegBuffers[1], ®_WIN0H, B_TRANS_DMA_FLAGS); } -static void VBlankCB1_Mugshots(void) +static void VBlankCB_MugshotsFadeOut(void) { DmaStop(0); VBlankCB_BattleTransition(); @@ -2447,26 +2542,19 @@ static void HBlankCB_Mugshots(void) REG_BG0HOFS = sTransitionData->BG0HOFS_Upper; } -// data fields for player/opponent sprites in mugshots -#define sState data[0] -#define sOffsetX data[1] -#define sOffsetX2 data[2] -#define sDone data[6] -#define sSlideTableId data[7] - static void Mugshots_CreateTrainerPics(struct Task *task) { struct Sprite *opponentSprite, *playerSprite; s16 mugshotId = task->tMugshotId; task->tOpponentSpriteId = CreateTrainerSprite(sMugshotsTrainerPicIDsTable[mugshotId], - sMugshotsOpponentCoords[mugshotId][0] - 32, - sMugshotsOpponentCoords[mugshotId][1] + 42, - 0, gDecompressionBuffer); + sMugshotsOpponentCoords[mugshotId][0] - 32, + sMugshotsOpponentCoords[mugshotId][1] + 42, + 0, gDecompressionBuffer); task->tPlayerSpriteId = CreateTrainerSprite(PlayerGenderToFrontTrainerPicId(gSaveBlock2Ptr->playerGender), - DISPLAY_WIDTH + 32, - 106, - 0, gDecompressionBuffer); + DISPLAY_WIDTH + 32, + 106, + 0, gDecompressionBuffer); opponentSprite = &gSprites[task->tOpponentSpriteId]; playerSprite = &gSprites[task->tPlayerSpriteId]; @@ -2498,63 +2586,70 @@ static void SpriteCB_MugshotTrainerPic(struct Sprite *sprite) while (sMugshotTrainerPicFuncs[sprite->sState](sprite)); } -static bool8 MugshotTrainerPic_Nothing(struct Sprite *sprite) +// Wait until IncrementTrainerPicState is called +static bool8 MugshotTrainerPic_Pause(struct Sprite *sprite) { return FALSE; } -static bool8 MugshotTrainerPic_SetSlideOffsets(struct Sprite *sprite) +static bool8 MugshotTrainerPic_Init(struct Sprite *sprite) { - s16 offsets1[ARRAY_COUNT(sTrainerPicSlideOffsets1)]; - s16 offsets2[ARRAY_COUNT(sTrainerPicSlideOffsets2)]; + s16 speeds[ARRAY_COUNT(sTrainerPicSlideSpeeds)]; + s16 accels[ARRAY_COUNT(sTrainerPicSlideAccels)]; - memcpy(offsets1, sTrainerPicSlideOffsets1, sizeof(sTrainerPicSlideOffsets1)); - memcpy(offsets2, sTrainerPicSlideOffsets2, sizeof(sTrainerPicSlideOffsets2)); + memcpy(speeds, sTrainerPicSlideSpeeds, sizeof(sTrainerPicSlideSpeeds)); + memcpy(accels, sTrainerPicSlideAccels, sizeof(sTrainerPicSlideAccels)); sprite->sState++; - sprite->sOffsetX = offsets1[sprite->sSlideTableId]; - sprite->sOffsetX2 = offsets2[sprite->sSlideTableId]; + sprite->sSlideSpeed = speeds[sprite->sSlideDir]; + sprite->sSlideAccel = accels[sprite->sSlideDir]; return TRUE; } -// fast slide to around middle screen -static bool8 MugshotTrainerPic_Slide1(struct Sprite *sprite) +static bool8 MugshotTrainerPic_Slide(struct Sprite *sprite) { - sprite->x += sprite->sOffsetX; - if (sprite->sSlideTableId && sprite->x < 133) + sprite->x += sprite->sSlideSpeed; + + // Advance state when pic passes ~40% of screen + if (sprite->sSlideDir && sprite->x < DISPLAY_WIDTH - 107) sprite->sState++; - else if (!sprite->sSlideTableId && sprite->x > 103) + else if (!sprite->sSlideDir && sprite->x > 103) sprite->sState++; return FALSE; } -// slower but accelerating slide -static bool8 MugshotTrainerPic_Slide2(struct Sprite *sprite) +static bool8 MugshotTrainerPic_SlideSlow(struct Sprite *sprite) { - sprite->sOffsetX += sprite->sOffsetX2; - sprite->x += sprite->sOffsetX; - if (sprite->sOffsetX == 0) + // Add acceleration value to speed, then add speed. + // For both sides acceleration is opposite speed, so slide slows down. + sprite->sSlideSpeed += sprite->sSlideAccel; + sprite->x += sprite->sSlideSpeed; + + // Advance state when slide comes to a stop + if (sprite->sSlideSpeed == 0) { sprite->sState++; - sprite->sOffsetX2 = -sprite->sOffsetX2; + sprite->sSlideAccel = -sprite->sSlideAccel; sprite->sDone = TRUE; } return FALSE; } -// Has no practical effect -static bool8 MugshotTrainerPic_Slide3(struct Sprite *sprite) +// Slides trainer pic offscreen. This is never reached, because it's preceded +// by a second MugshotTrainerPic_Pause, and IncrementTrainerPicState is +// only called once per trainer pic. +static bool8 MugshotTrainerPic_SlideOffscreen(struct Sprite *sprite) { - sprite->sOffsetX += sprite->sOffsetX2; - sprite->x += sprite->sOffsetX; + sprite->sSlideSpeed += sprite->sSlideAccel; + sprite->x += sprite->sSlideSpeed; if (sprite->x < -31 || sprite->x > DISPLAY_WIDTH + 31) sprite->sState++; return FALSE; } -static void SetTrainerPicSlideTable(s16 spriteId, s16 arrId) +static void SetTrainerPicSlideDirection(s16 spriteId, s16 dirId) { - gSprites[spriteId].sSlideTableId = arrId; + gSprites[spriteId].sSlideDir = dirId; } static void IncrementTrainerPicState(s16 spriteId) @@ -2568,10 +2663,26 @@ static s16 IsTrainerPicSlideDone(s16 spriteId) } #undef sState -#undef sOffsetX -#undef sOffsetX2 +#undef sSlideSpeed +#undef sSlideAccel #undef sDone -#undef sSlideTableId +#undef sSlideDir +#undef tSinIndex +#undef tTopBannerX +#undef tBottomBannerX +#undef tTimer +#undef tFadeSpread +#undef tOpponentSpriteId +#undef tPlayerSpriteId +#undef tMugshotId + +//-------------------- +// B_TRANSITION_SLICE +//-------------------- + +#define tEffectX data[1] +#define tSpeed data[2] +#define tAccel data[3] static void Task_Slice(u8 taskId) { @@ -2585,8 +2696,8 @@ static bool8 Slice_Init(struct Task *task) InitTransitionData(); ScanlineEffect_Clear(); - task->data[2] = 256; - task->data[3] = 1; + task->tSpeed = 1 << 8; + task->tAccel = 1; sTransitionData->WININ = WININ_WIN0_ALL; sTransitionData->WINOUT = 0; sTransitionData->WIN0V = DISPLAY_HEIGHT; @@ -2608,37 +2719,39 @@ static bool8 Slice_Init(struct Task *task) return TRUE; } -static bool8 Slice_Func2(struct Task *task) +static bool8 Slice_Main(struct Task *task) { u16 i; sTransitionData->VBlank_DMA = FALSE; - task->data[1] += (task->data[2] >> 8); - if (task->data[1] > DISPLAY_WIDTH) - task->data[1] = DISPLAY_WIDTH; - if (task->data[2] <= 0xFFF) - task->data[2] += task->data[3]; - if (task->data[3] < 128) - task->data[3] <<= 1; // multiplying by two + task->tEffectX += (task->tSpeed >> 8); + if (task->tEffectX > DISPLAY_WIDTH) + task->tEffectX = DISPLAY_WIDTH; + if (task->tSpeed <= 0xFFF) + task->tSpeed += task->tAccel; + if (task->tAccel < 128) + task->tAccel <<= 1; // multiplying by two for (i = 0; i < DISPLAY_HEIGHT; i++) { u16 *storeLoc1 = &gScanlineEffectRegBuffers[0][i]; u16 *storeLoc2 = &gScanlineEffectRegBuffers[0][i + DISPLAY_HEIGHT]; - if (i & 1) + + // Alternate rows + if (i % 2) { - *storeLoc1 = sTransitionData->cameraX + task->data[1]; - *storeLoc2 = DISPLAY_WIDTH - task->data[1]; + *storeLoc1 = sTransitionData->cameraX + task->tEffectX; + *storeLoc2 = DISPLAY_WIDTH - task->tEffectX; } else { - *storeLoc1 = sTransitionData->cameraX - task->data[1]; - *storeLoc2 = (task->data[1] << 8) | (DISPLAY_WIDTH + 1); + *storeLoc1 = sTransitionData->cameraX - task->tEffectX; + *storeLoc2 = (task->tEffectX << 8) | (DISPLAY_WIDTH + 1); } } - if (task->data[1] >= DISPLAY_WIDTH) + if (task->tEffectX >= DISPLAY_WIDTH) task->tState++; sTransitionData->VBlank_DMA++; @@ -2676,6 +2789,20 @@ static void HBlankCB_Slice(void) } } +#undef tEffectX +#undef tSpeed +#undef tAccel + +//-------------------------- +// B_TRANSITION_SHRED_SPLIT +//-------------------------- + +// Data starts at 4. Possible it shared data +// with Slice above, which ends at 3. +#define tDelayTimer data[4] +#define tExtent data[5] +#define tDelay data[6] + static void Task_ShredSplit(u8 taskId) { while (sShredSplit_Funcs[gTasks[taskId].tState](&gTasks[taskId])); @@ -2703,9 +2830,9 @@ static bool8 ShredSplit_Init(struct Task *task) gScanlineEffectRegBuffers[0][DISPLAY_HEIGHT * 4 + i] = 1; } - task->data[4] = 0; - task->data[5] = 0; - task->data[6] = 7; + task->tDelayTimer = 0; + task->tExtent = 0; + task->tDelay = 7; EnableInterrupts(INTR_FLAG_HBLANK); @@ -2716,37 +2843,38 @@ static bool8 ShredSplit_Init(struct Task *task) return TRUE; } -static bool8 ShredSplit_Func2(struct Task *task) +static bool8 ShredSplit_Main(struct Task *task) { u16 i, j, k; - u8 arr1[ARRAY_COUNT(gUnknown_085C8C64)]; - s16 arr2[ARRAY_COUNT(gUnknown_085C8C66)]; - u8 var; + u8 baseY[ARRAY_COUNT(sShredSplit_SectionYCoords)]; + s16 moveDirs[ARRAY_COUNT(sShredSplit_SectionMoveDirs)]; + u8 linesFinished; u16 *ptr4, *ptr3, *ptr1, *ptr2; - s16 unkVar; + s16 y; - memcpy(arr1, gUnknown_085C8C64, sizeof(arr1)); - memcpy(arr2, gUnknown_085C8C66, sizeof(arr2)); + memcpy(baseY, sShredSplit_SectionYCoords, sizeof(baseY)); + memcpy(moveDirs, sShredSplit_SectionMoveDirs, sizeof(moveDirs)); sTransitionData->VBlank_DMA = FALSE; - var = 0; + linesFinished = 0; - for (i = 0; i <= task->data[5]; i++) + for (i = 0; i <= task->tExtent; i++) { + // Slide half of the pixel rows (alternating) right for (j = 0; j < 2; j++) { for (k = 0; k < 2; k++) { - unkVar = (arr1[j]) + (arr2[k] * -(i) * 2); - if (unkVar >= 0 && (unkVar != 79 || j != 1)) + y = baseY[j] + (moveDirs[k] * -i * 2); + if (y >= 0 && (y != DISPLAY_HEIGHT / 2 - 1 || j != 1)) { - ptr4 = &gScanlineEffectRegBuffers[0][unkVar + DISPLAY_HEIGHT * 2]; - ptr3 = &gScanlineEffectRegBuffers[0][unkVar + DISPLAY_HEIGHT * 3]; - ptr1 = &gScanlineEffectRegBuffers[0][unkVar + DISPLAY_HEIGHT * 4]; + ptr4 = &gScanlineEffectRegBuffers[0][y + DISPLAY_HEIGHT * 2]; + ptr3 = &gScanlineEffectRegBuffers[0][y + DISPLAY_HEIGHT * 3]; + ptr1 = &gScanlineEffectRegBuffers[0][y + DISPLAY_HEIGHT * 4]; if (*ptr4 >= DISPLAY_WIDTH) { *ptr4 = DISPLAY_WIDTH; - var++; + linesFinished++; } else { @@ -2756,8 +2884,8 @@ static bool8 ShredSplit_Func2(struct Task *task) if (*ptr3 <= 0xFFF) *ptr3 += *ptr1; } - ptr2 = &gScanlineEffectRegBuffers[0][unkVar]; - ptr3 = &gScanlineEffectRegBuffers[0][unkVar + DISPLAY_HEIGHT]; + ptr2 = &gScanlineEffectRegBuffers[0][y]; + ptr3 = &gScanlineEffectRegBuffers[0][y + DISPLAY_HEIGHT]; *ptr2 = sTransitionData->cameraX + *ptr4; *ptr3 = DISPLAY_WIDTH - *ptr4; @@ -2767,20 +2895,21 @@ static bool8 ShredSplit_Func2(struct Task *task) } } + // Slide the other half of the rows left for (j = 0; j < 2; j++) { for (k = 0; k < 2; k++) { - unkVar = (arr1[j] + 1) + (arr2[k] * -(i) * 2); - if (unkVar <= DISPLAY_HEIGHT && (unkVar != DISPLAY_HEIGHT / 2 || j != 1)) + y = baseY[j] + 1 + (moveDirs[k] * -i * 2); + if (y <= DISPLAY_HEIGHT && (y != DISPLAY_HEIGHT / 2 || j != 1)) { - ptr4 = &gScanlineEffectRegBuffers[0][unkVar + DISPLAY_HEIGHT * 2]; - ptr3 = &gScanlineEffectRegBuffers[0][unkVar + DISPLAY_HEIGHT * 3]; - ptr1 = &gScanlineEffectRegBuffers[0][unkVar + DISPLAY_HEIGHT * 4]; + ptr4 = &gScanlineEffectRegBuffers[0][y + DISPLAY_HEIGHT * 2]; + ptr3 = &gScanlineEffectRegBuffers[0][y + DISPLAY_HEIGHT * 3]; + ptr1 = &gScanlineEffectRegBuffers[0][y + DISPLAY_HEIGHT * 4]; if (*ptr4 >= DISPLAY_WIDTH) { *ptr4 = DISPLAY_WIDTH; - var++; + linesFinished++; } else { @@ -2790,8 +2919,8 @@ static bool8 ShredSplit_Func2(struct Task *task) if (*ptr3 <= 0xFFF) *ptr3 += *ptr1; } - ptr2 = &gScanlineEffectRegBuffers[0][unkVar]; - ptr3 = &gScanlineEffectRegBuffers[0][unkVar + DISPLAY_HEIGHT]; + ptr2 = &gScanlineEffectRegBuffers[0][y]; + ptr3 = &gScanlineEffectRegBuffers[0][y + DISPLAY_HEIGHT]; *ptr2 = sTransitionData->cameraX - *ptr4; *ptr3 = (*ptr4 << 8) | (DISPLAY_WIDTH + 1); @@ -2802,11 +2931,19 @@ static bool8 ShredSplit_Func2(struct Task *task) } } - if (--task->data[4] < 0) - task->data[4] = 0; - if (task->data[4] <= 0 && task->data[5] + 1 <= 20) - task->data[4] = task->data[6], task->data[5]++; - if (var >= DISPLAY_HEIGHT) + // Count down to next move + if (--task->tDelayTimer < 0) + task->tDelayTimer = 0; + + // Try increase effect's extent + if (task->tDelayTimer <= 0 && task->tExtent + 1 <= DISPLAY_HEIGHT / 8) + { + task->tDelayTimer = task->tDelay; + task->tExtent++; + } + + // All lines have reached screen width, move on. + if (linesFinished >= DISPLAY_HEIGHT) task->tState++; sTransitionData->VBlank_DMA++; @@ -2817,7 +2954,8 @@ static bool8 ShredSplit_Func2(struct Task *task) // is always false, resulting in the game being stuck in an infinite loop. // It's possible this transition is only partially // done and the second part was left out. -static bool8 ShredSplit_Func3(struct Task *task) +// In any case removing or bypassing this state allows the transition to finish. +static bool8 ShredSplit_BrokenCheck(struct Task *task) { u16 i; bool32 done = TRUE; @@ -2826,7 +2964,7 @@ static bool8 ShredSplit_Func3(struct Task *task) for (i = 0; i < DISPLAY_HEIGHT; i++) { if (gScanlineEffectRegBuffers[1][i] != DISPLAY_WIDTH && gScanlineEffectRegBuffers[1][i] != checkVar2) - done = FALSE; // a break statement should be put here + done = FALSE; } if (done == TRUE) @@ -2843,16 +2981,32 @@ static bool8 ShredSplit_End(struct Task *task) return FALSE; } -static void Task_Blackhole1(u8 taskId) +#undef tDelayTimer +#undef tExtent +#undef tDelay + +//----------------------------------------------------------- +// B_TRANSITION_BLACKHOLE and B_TRANSITION_BLACKHOLE_PULSATE +//----------------------------------------------------------- + +#define tRadius data[1] +#define tGrowSpeed data[2] +#define tSinIndex data[5] +#define tVibrateId data[6] +#define tAmplitude data[6] // Used differently by the two transitions +#define tFlag data[7] // Used generally to indicate an action has taken place. + +static void Task_Blackhole(u8 taskId) { - while (sBlackhole1_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sBlackhole_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static void Task_Blackhole2(u8 taskId) +static void Task_BlackholePulsate(u8 taskId) { - while (sBlackhole2_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sBlackholePulsate_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } +// Init is shared by both transitions static bool8 Blackhole_Init(struct Task *task) { s32 i; @@ -2868,19 +3022,19 @@ static bool8 Blackhole_Init(struct Task *task) for (i = 0; i < DISPLAY_HEIGHT; i++) gScanlineEffectRegBuffers[1][i] = 0; - SetVBlankCallback(VBlankCB1_BigPokeball); + SetVBlankCallback(VBlankCB_CircularMask); task->tState++; - task->data[1] = 1; - task->data[2] = 0x100; - task->tFuncState = 0; + task->tRadius = 1; + task->tGrowSpeed = 1 << 8; + task->tFlag = FALSE; return FALSE; } -static bool8 Blackhole1_Func3(struct Task *task) +static bool8 Blackhole_GrowEnd(struct Task *task) { - if (task->tFuncState == 1) + if (task->tFlag == TRUE) { DmaStop(0); SetVBlankCallback(NULL); @@ -2889,16 +3043,16 @@ static bool8 Blackhole1_Func3(struct Task *task) else { sTransitionData->VBlank_DMA = FALSE; - if (task->data[2] < 1024) - task->data[2] += 128; - if (task->data[1] < DISPLAY_HEIGHT) - task->data[1] += (task->data[2] >> 8); - if (task->data[1] > DISPLAY_HEIGHT) - task->data[1] = DISPLAY_HEIGHT; - sub_814A014(gScanlineEffectRegBuffers[0], 120, 80, task->data[1]); - if (task->data[1] == DISPLAY_HEIGHT) + if (task->tGrowSpeed < 1024) + task->tGrowSpeed += 128; + if (task->tRadius < DISPLAY_HEIGHT) + task->tRadius += task->tGrowSpeed >> 8; + if (task->tRadius > DISPLAY_HEIGHT) + task->tRadius = DISPLAY_HEIGHT; + SetCircularMask(gScanlineEffectRegBuffers[0], DISPLAY_WIDTH / 2, DISPLAY_HEIGHT / 2, task->tRadius); + if (task->tRadius == DISPLAY_HEIGHT) { - task->tFuncState = 1; + task->tFlag = TRUE; FadeScreenBlack(); } else @@ -2910,73 +3064,89 @@ static bool8 Blackhole1_Func3(struct Task *task) return FALSE; } -static bool8 Blackhole1_Func2(struct Task *task) +static bool8 Blackhole_Vibrate(struct Task *task) { sTransitionData->VBlank_DMA = FALSE; - if (task->tFuncState == 0) + if (task->tFlag == FALSE) { - task->tFuncState++; - task->data[1] = 0x30; - task->data[6] = 0; + task->tFlag++; + task->tRadius = 48; + task->tVibrateId = 0; } - task->data[1] += gUnknown_085C8C80[task->data[6]]; - task->data[6] = (task->data[6] + 1) % 2; - sub_814A014(gScanlineEffectRegBuffers[0], 120, 80, task->data[1]); - if (task->data[1] < 9) + task->tRadius += sBlackhole_Vibrations[task->tVibrateId]; + task->tVibrateId = (task->tVibrateId + 1) % (int)ARRAY_COUNT(sBlackhole_Vibrations); + SetCircularMask(gScanlineEffectRegBuffers[0], DISPLAY_WIDTH / 2, DISPLAY_HEIGHT / 2, task->tRadius); + if (task->tRadius < 9) { task->tState++; - task->tFuncState = 0; + task->tFlag = FALSE; } sTransitionData->VBlank_DMA++; return FALSE; } -static bool8 Blackhole2_Func2(struct Task *task) +static bool8 BlackholePulsate_Main(struct Task *task) { u16 index; // should be s16 I think s16 amplitude; sTransitionData->VBlank_DMA = FALSE; - if (task->tFuncState == 0) + if (task->tFlag == FALSE) { - task->tFuncState++; - task->data[5] = 2; - task->data[6] = 2; + task->tFlag++; + task->tSinIndex = 2; + task->tAmplitude = 2; } - if (task->data[1] > DISPLAY_HEIGHT) - task->data[1] = DISPLAY_HEIGHT; - sub_814A014(gScanlineEffectRegBuffers[0], 120, 80, task->data[1]); - if (task->data[1] == DISPLAY_HEIGHT) + if (task->tRadius > DISPLAY_HEIGHT) + task->tRadius = DISPLAY_HEIGHT; + + SetCircularMask(gScanlineEffectRegBuffers[0], DISPLAY_WIDTH / 2, DISPLAY_HEIGHT / 2, task->tRadius); + if (task->tRadius == DISPLAY_HEIGHT) { DmaStop(0); FadeScreenBlack(); DestroyTask(FindTaskIdByFunc(task->func)); } - index = task->data[5]; - if ((task->data[5] & 0xFF) <= 128) + index = task->tSinIndex; + if ((task->tSinIndex & 0xFF) <= 128) { - amplitude = task->data[6]; - task->data[5] += 8; + amplitude = task->tAmplitude; + task->tSinIndex += 8; } else { - amplitude = task->data[6] - 1; - task->data[5] += 16; + amplitude = task->tAmplitude - 1; + task->tSinIndex += 16; } - task->data[1] += Sin(index & 0xFF, amplitude); + task->tRadius += Sin(index & 0xFF, amplitude); + + if (task->tRadius <= 0) + task->tRadius = 1; - if (task->data[1] <= 0) - task->data[1] = 1; - if (task->data[5] > 0xFE) - task->data[5] >>= 8, task->data[6]++; + if (task->tSinIndex >= 0xFF) + { + task->tSinIndex >>= 8; + task->tAmplitude++; + } sTransitionData->VBlank_DMA++; return FALSE; } +#undef tRadius +#undef tGrowSpeed +#undef tSinIndex +#undef tVibrateId +#undef tAmplitude +#undef tFlag + +//--------------------------------- +// B_TRANSITION_RECTANGULAR_SPIRAL +//--------------------------------- + static void Task_RectangularSpiral(u8 taskId) { while (sRectangularSpiral_Funcs[gTasks[taskId].tState](&gTasks[taskId])); @@ -2989,40 +3159,44 @@ static bool8 RectangularSpiral_Init(struct Task *task) GetBg0TilesDst(&tilemap, &tileset); CpuCopy16(sShrinkingBoxTileset, tileset, 0x20); CpuCopy16(sShrinkingBoxTileset + 0x70, tileset + 0x20, 0x20); - CpuFill16(0xF000, tilemap, BG_SCREEN_SIZE); + CpuFill16(0xF0 << 8, tilemap, BG_SCREEN_SIZE); LoadPalette(sFieldEffectPal_Pokeball, 0xF0, sizeof(sFieldEffectPal_Pokeball)); task->data[3] = 1; task->tState++; - sRectangularSpiralTransition[0].field_0 = 0; - sRectangularSpiralTransition[0].field_2 = -1; - sRectangularSpiralTransition[0].field_4 = 1; - sRectangularSpiralTransition[0].field_6 = 308; - sRectangularSpiralTransition[0].field_8 = 0; - - sRectangularSpiralTransition[1].field_0 = 0; - sRectangularSpiralTransition[1].field_2 = -1; - sRectangularSpiralTransition[1].field_4 = 1; - sRectangularSpiralTransition[1].field_6 = 308; - sRectangularSpiralTransition[1].field_8 = 0; - - sRectangularSpiralTransition[2].field_0 = 0; - sRectangularSpiralTransition[2].field_2 = -3; - sRectangularSpiralTransition[2].field_4 = 1; - sRectangularSpiralTransition[2].field_6 = 307; - sRectangularSpiralTransition[2].field_8 = 0; - - sRectangularSpiralTransition[3].field_0 = 0; - sRectangularSpiralTransition[3].field_2 = -3; - sRectangularSpiralTransition[3].field_4 = 1; - sRectangularSpiralTransition[3].field_6 = 307; - sRectangularSpiralTransition[3].field_8 = 0; + // Top left + sRectangularSpiralLines[0].state = 0; + sRectangularSpiralLines[0].position = -1; + sRectangularSpiralLines[0].moveIdx = 1; + sRectangularSpiralLines[0].skipPosition = 308; + sRectangularSpiralLines[0].field_8 = 0; + + // Bottom right + sRectangularSpiralLines[1].state = 0; + sRectangularSpiralLines[1].position = -1; + sRectangularSpiralLines[1].moveIdx = 1; + sRectangularSpiralLines[1].skipPosition = 308; + sRectangularSpiralLines[1].field_8 = 0; + + // Top right + sRectangularSpiralLines[2].state = 0; + sRectangularSpiralLines[2].position = -3; + sRectangularSpiralLines[2].moveIdx = 1; + sRectangularSpiralLines[2].skipPosition = 307; + sRectangularSpiralLines[2].field_8 = 0; + + // Bottom left + sRectangularSpiralLines[3].state = 0; + sRectangularSpiralLines[3].position = -3; + sRectangularSpiralLines[3].moveIdx = 1; + sRectangularSpiralLines[3].skipPosition = 307; + sRectangularSpiralLines[3].field_8 = 0; return FALSE; } -static bool8 RectangularSpiral_Func2(struct Task *task) +static bool8 RectangularSpiral_Main(struct Task *task) { u16 *tilemap, *tileset; u8 i; @@ -3031,24 +3205,28 @@ static bool8 RectangularSpiral_Func2(struct Task *task) GetBg0TilesDst(&tilemap, &tileset); + // Draw 2 tiles at a time for each spiral line for (i = 0; i < 2; i++) { - for (j = 0; j < ARRAY_COUNT(sRectangularSpiralTransition); j++) + for (j = 0; j < ARRAY_COUNT(sRectangularSpiralLines); j++) { - s16 var = 0, var2 = 0; - s32 var3 = 0; + s16 position = 0; + s16 x = 0, y = 0; - if (sub_8149048(gUnknown_085C8D38[j / 2], &sRectangularSpiralTransition[j])) + if (UpdateRectangularSpiralLine(sRectangularSpiral_MoveDataTables[j / 2], &sRectangularSpiralLines[j])) { + // The line moved to a new position, draw the tile. done = FALSE; - var = sRectangularSpiralTransition[j].field_2; + position = sRectangularSpiralLines[j].position; + + // Invert position for the two bottom lines if ((j % 2) == 1) - var = 0x27D - var; + position = 637 - position; - var2 = var % 32; - var3 = var / 32; + x = position % 32; + y = position / 32; - SET_TILEMAP_TILE(tilemap, var3, var2, 0xF002); + SET_TILE(tilemap, y, x, 2); } } } @@ -3066,69 +3244,77 @@ static bool8 RectangularSpiral_End(struct Task *task) return FALSE; } -static bool16 sub_8149048(const s16 * const *arg0, struct StructRectangularSpiral *arg1) +// Returns TRUE if a tile should be drawn, FALSE otherwise +static bool16 UpdateRectangularSpiralLine(const s16 * const *moveDataTable, struct RectangularSpiralLine *line) { - const s16 *array = arg0[arg1->field_0]; - if (array[arg1->field_4] == -1) + const s16 *moveData = moveDataTable[line->state]; + if (moveData[line->moveIdx] == SPIRAL_END) return FALSE; - // ?? - sUnusedRectangularSpiralVar = array[0]; - sUnusedRectangularSpiralVar = array[1]; - sUnusedRectangularSpiralVar = array[2]; - sUnusedRectangularSpiralVar = array[3]; + // Presumably saving data for debug. + sDebug_RectangularSpiralData = moveData[0]; + sDebug_RectangularSpiralData = moveData[1]; + sDebug_RectangularSpiralData = moveData[2]; + sDebug_RectangularSpiralData = moveData[3]; - switch (array[0]) + switch (moveData[0]) { case 1: - arg1->field_2 += 0x1; + line->position += 1; break; case 2: - arg1->field_2 -= 0x1; + line->position -= 1; break; case 3: - arg1->field_2 -= 0x20; + line->position -= 32; break; case 4: - arg1->field_2 += 0x20; + line->position += 32; break; } - if (arg1->field_2 > 0x27F || array[arg1->field_4] == -1) + // Below check is never true. + // SPIRAL_END was already checked, and position is never >= 640 + if (line->position >= 640 || moveData[line->moveIdx] == SPIRAL_END) return FALSE; - if (arg1->field_8 == 0 && array[arg1->field_4] == -2) + if (line->field_8 == 0 && moveData[line->moveIdx] == SPIRAL_SKIP) { - arg1->field_8 = 1; - arg1->field_4 = 1; - arg1->field_2 = arg1->field_6; - arg1->field_0 = 4; + line->field_8 = 1; + line->moveIdx = 1; + line->position = line->skipPosition; + line->state = 4; } - if (arg1->field_2 == array[arg1->field_4]) + if (line->position == moveData[line->moveIdx]) { - (arg1->field_0)++; - if (arg1->field_8 == 1) + line->state++; + if (line->field_8 == 1) { - if (arg1->field_0 > 7) + if (line->state > 7) { - (arg1->field_4)++; - (arg1->field_0) = 4; + line->moveIdx++; + line->state = 4; } } else { - if (arg1->field_0 > 3) + if (line->state > 3) { - (arg1->field_4)++; - (arg1->field_0) = 0; + line->moveIdx++; + line->state = 0; } } } - return TRUE; } +//---------------------- +// B_TRANSITION_GROUDON +//---------------------- + +#define tTimer data[1] + static void Task_Groudon(u8 taskId) { while (sGroudon_Funcs[gTasks[taskId].tState](&gTasks[taskId])); @@ -3144,21 +3330,21 @@ static bool8 Groudon_Init(struct Task *task) LZ77UnCompVram(sGroudon_Tilemap, tilemap); task->tState++; - task->data[1] = 0; + task->tTimer = 0; return FALSE; } -static bool8 Groudon_PalettePulsate(struct Task *task) +static bool8 Groudon_PaletteFlash(struct Task *task) { - if (task->data[1] % 3 == 0) + if (task->tTimer % 3 == 0) { - u16 var = (task->data[1] % 30) / 3; - LoadPalette(sGroudon1_Palette + (var * 16), 0xF0, 0x20); + u16 offset = (task->tTimer % 30) / 3; + LoadPalette(&sGroudon1_Palette[offset * 16], 0xF0, 0x20); } - if (++task->data[1] > 58) + if (++task->tTimer > 58) { task->tState++; - task->data[1] = 0; + task->tTimer = 0; } return FALSE; @@ -3166,29 +3352,38 @@ static bool8 Groudon_PalettePulsate(struct Task *task) static bool8 Groudon_PaletteBrighten(struct Task *task) { - if (task->data[1] % 5 == 0) + if (task->tTimer % 5 == 0) { - s16 var = task->data[1] / 5; - LoadPalette(sGroudon2_Palette + (var * 16), 0xF0, 0x20); + s16 offset = task->tTimer / 5; + LoadPalette(&sGroudon2_Palette[offset * 16], 0xF0, 0x20); } - if (++task->data[1] > 68) + if (++task->tTimer > 68) { task->tState++; - task->data[1] = 0; + task->tTimer = 0; task->tEndDelay = 30; } return FALSE; } +#undef tTimer #undef tEndDelay +//----------------------- +// B_TRANSITION_RAYQUAZA +//----------------------- + +#define tTimer data[1] +#define tGrowSpeed data[2] // Shared from B_TRANSITION_BLACKHOLE +#define tFlag data[7] // Shared from B_TRANSITION_BLACKHOLE + static void Task_Rayquaza(u8 taskId) { while (sRayquaza_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static bool8 Rayquaza_Func3(struct Task *task) +static bool8 Rayquaza_Init(struct Task *task) { u16 *tilemap, *tileset; u16 i; @@ -3201,9 +3396,9 @@ static bool8 Rayquaza_Func3(struct Task *task) CpuFill16(0, tilemap, BG_SCREEN_SIZE); CpuCopy16(sRayquaza_Tileset, tileset, 0x2000); - sTransitionData->field_20 = 0; + sTransitionData->counter = 0; task->tState++; - LoadPalette(sRayquaza_Palette + 0x50, 0xF0, 0x20); + LoadPalette(&sRayquaza_Palette[0x50], 0xF0, 0x20); for (i = 0; i < DISPLAY_HEIGHT; i++) { @@ -3215,7 +3410,7 @@ static bool8 Rayquaza_Func3(struct Task *task) return FALSE; } -static bool8 Rayquaza_Func4(struct Task *task) +static bool8 Rayquaza_SetGfx(struct Task *task) { u16 *tilemap, *tileset; @@ -3225,47 +3420,46 @@ static bool8 Rayquaza_Func4(struct Task *task) return FALSE; } -static bool8 Rayquaza_Func5(struct Task *task) +static bool8 Rayquaza_PaletteFlash(struct Task *task) { - if ((task->data[1] % 4) == 0) + if ((task->tTimer % 4) == 0) { - u16 value = task->data[1] / 4; + u16 value = task->tTimer / 4; const u16 *palPtr = &sRayquaza_Palette[(value + 5) * 16]; LoadPalette(palPtr, 0xF0, 0x20); } - if (++task->data[1] > 40) + if (++task->tTimer > 40) { task->tState++; - task->data[1] = 0; + task->tTimer = 0; } return FALSE; } -static bool8 Rayquaza_Func6(struct Task *task) +static bool8 Rayquaza_FadeToBlack(struct Task *task) { - if (++task->data[1] > 20) + if (++task->tTimer > 20) { task->tState++; - task->data[1] = 0; + task->tTimer = 0; BeginNormalPaletteFade(PALETTES_OBJECTS | (1 << 15), 2, 0, 16, RGB_BLACK); } return FALSE; } -static bool8 Rayquaza_Func7(struct Task *task) +static bool8 Rayquaza_WaitFade(struct Task *task) { if (!gPaletteFade.active) { - sTransitionData->field_20 = 1; + sTransitionData->counter = 1; task->tState++; } - return FALSE; } -static bool8 Rayquaza_Func8(struct Task *task) +static bool8 Rayquaza_SetBlack(struct Task *task) { BlendPalettes(PALETTES_BG & ~(1 << 15), 8, RGB_BLACK); BlendPalettes(PALETTES_OBJECTS | (1 << 15), 0, RGB_BLACK); @@ -3274,15 +3468,15 @@ static bool8 Rayquaza_Func8(struct Task *task) return FALSE; } -static bool8 Rayquaza_Func9(struct Task *task) +static bool8 Rayquaza_TriRing(struct Task *task) { - if ((task->data[1] % 3) == 0) + if ((task->tTimer % 3) == 0) { - u16 value = task->data[1] / 3; + u16 value = task->tTimer / 3; const u16 *palPtr = &sRayquaza_Palette[(value + 0) * 16]; LoadPalette(palPtr, 0xF0, 0x20); } - if (++task->data[1] >= 40) + if (++task->tTimer >= 40) { u16 i; @@ -3294,10 +3488,10 @@ static bool8 Rayquaza_Func9(struct Task *task) for (i = 0; i < DISPLAY_HEIGHT; i++) gScanlineEffectRegBuffers[1][i] = 0; - SetVBlankCallback(VBlankCB1_BigPokeball); + SetVBlankCallback(VBlankCB_CircularMask); task->tState++; - task->data[2] = 0x100; - task->tFuncState = 0; + task->tGrowSpeed = 1 << 8; + task->tFlag = FALSE; ClearGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_BG0_ON); } @@ -3311,9 +3505,9 @@ static void VBlankCB_Rayquaza(void) DmaStop(0); VBlankCB_BattleTransition(); - if (sTransitionData->field_20 == 0) + if (sTransitionData->counter == 0) dmaSrc = gScanlineEffectRegBuffers[0]; - else if (sTransitionData->field_20 == 1) + else if (sTransitionData->counter == 1) dmaSrc = gScanlineEffectRegBuffers[1]; else dmaSrc = gScanlineEffectRegBuffers[0]; @@ -3321,12 +3515,28 @@ static void VBlankCB_Rayquaza(void) DmaSet(0, dmaSrc, ®_BG0VOFS, B_TRANS_DMA_FLAGS); } -static void Task_WhiteFade(u8 taskId) +#undef tTimer +#undef tGrowSpeed +#undef tFlag + +//------------------------------ +// B_TRANSITION_WHITE_BARS_FADE +//------------------------------ + +#define sFade data[0] +#define sFinished data[1] +#define sDestroyAttempts data[2] +#define sDelay data[5] +#define sIsMainSprite data[6] + +#define FADE_TARGET (16 << 8) + +static void Task_WhiteBarsFade(u8 taskId) { - while (sWhiteFade_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sWhiteBarsFade_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static bool8 WhiteFade_Init(struct Task *task) +static bool8 WhiteBarsFade_Init(struct Task *task) { u16 i; @@ -3346,37 +3556,40 @@ static bool8 WhiteFade_Init(struct Task *task) } EnableInterrupts(INTR_FLAG_HBLANK); - SetHBlankCallback(HBlankCB_WhiteFade); - SetVBlankCallback(VBlankCB0_WhiteFade); + SetHBlankCallback(HBlankCB_WhiteBarsFade); + SetVBlankCallback(VBlankCB_WhiteBarsFade); task->tState++; return FALSE; } -static bool8 WhiteFade_Func2(struct Task *task) +static bool8 WhiteBarsFade_StartBars(struct Task *task) { s16 i, posY; - s16 arr1[ARRAY_COUNT(sUnknown_085C8DA0)]; + s16 delays[ARRAY_COUNT(sWhiteBarsFade_StartDelays)]; struct Sprite *sprite; + memcpy(delays, sWhiteBarsFade_StartDelays, sizeof(sWhiteBarsFade_StartDelays)); - memcpy(arr1, sUnknown_085C8DA0, sizeof(sUnknown_085C8DA0)); - for (i = 0, posY = 0; i < 8; i++, posY += 20) + for (i = 0, posY = 0; i < NUM_WHITE_BARS; i++, posY += DISPLAY_HEIGHT / NUM_WHITE_BARS) { - sprite = &gSprites[CreateInvisibleSprite(sub_8149864)]; + sprite = &gSprites[CreateInvisibleSprite(SpriteCB_WhiteBarFade)]; sprite->x = DISPLAY_WIDTH; sprite->y = posY; - sprite->data[5] = arr1[i]; + sprite->sDelay = delays[i]; } - sprite->data[6]++; + + // Set on one sprite only. This one will enable the DMA + // copy in VBlank and wait for the others to destroy. + sprite->sIsMainSprite++; task->tState++; return FALSE; } -static bool8 WhiteFade_Func3(struct Task *task) +static bool8 WhiteBarsFade_WaitBars(struct Task *task) { sTransitionData->VBlank_DMA = 0; - if (sTransitionData->field_20 > 7) + if (sTransitionData->counter >= NUM_WHITE_BARS) { BlendPalettes(PALETTES_ALL, 16, RGB_WHITE); task->tState++; @@ -3384,7 +3597,7 @@ static bool8 WhiteFade_Func3(struct Task *task) return FALSE; } -static bool8 WhiteFade_Func4(struct Task *task) +static bool8 WhiteBarsFade_BlendToBlack(struct Task *task) { sTransitionData->VBlank_DMA = 0; @@ -3397,23 +3610,23 @@ static bool8 WhiteFade_Func4(struct Task *task) sTransitionData->BLDCNT = 0xFF; sTransitionData->WININ = WININ_WIN0_ALL; - SetVBlankCallback(VBlankCB1_WhiteFade); + SetVBlankCallback(VBlankCB_WhiteBarsFade_Blend); task->tState++; return FALSE; } -static bool8 WhiteFade_End(struct Task *task) +static bool8 WhiteBarsFade_End(struct Task *task) { if (++sTransitionData->BLDY > 16) { FadeScreenBlack(); - DestroyTask(FindTaskIdByFunc(Task_WhiteFade)); + DestroyTask(FindTaskIdByFunc(Task_WhiteBarsFade)); } return FALSE; } -static void VBlankCB0_WhiteFade(void) +static void VBlankCB_WhiteBarsFade(void) { DmaStop(0); VBlankCB_BattleTransition(); @@ -3426,7 +3639,7 @@ static void VBlankCB0_WhiteFade(void) DmaSet(0, &gScanlineEffectRegBuffers[1][DISPLAY_HEIGHT], ®_WIN0H, B_TRANS_DMA_FLAGS); } -static void VBlankCB1_WhiteFade(void) +static void VBlankCB_WhiteBarsFade_Blend(void) { VBlankCB_BattleTransition(); REG_BLDY = sTransitionData->BLDY; @@ -3437,17 +3650,17 @@ static void VBlankCB1_WhiteFade(void) REG_WIN0V = sTransitionData->WIN0V; } -static void HBlankCB_WhiteFade(void) +static void HBlankCB_WhiteBarsFade(void) { REG_BLDY = gScanlineEffectRegBuffers[1][REG_VCOUNT]; } -static void sub_8149864(struct Sprite *sprite) +static void SpriteCB_WhiteBarFade(struct Sprite *sprite) { - if (sprite->data[5]) + if (sprite->sDelay) { - sprite->data[5]--; - if (sprite->data[6]) + sprite->sDelay--; + if (sprite->sIsMainSprite) sTransitionData->VBlank_DMA = 1; } else @@ -3455,36 +3668,51 @@ static void sub_8149864(struct Sprite *sprite) u16 i; u16* ptr1 = &gScanlineEffectRegBuffers[0][sprite->y]; u16* ptr2 = &gScanlineEffectRegBuffers[0][sprite->y + DISPLAY_HEIGHT]; - for (i = 0; i < 20; i++) + for (i = 0; i < DISPLAY_HEIGHT / NUM_WHITE_BARS; i++) { - ptr1[i] = sprite->data[0] >> 8; - ptr2[i] = (u8)(sprite->x); + ptr1[i] = sprite->sFade >> 8; + ptr2[i] = (u8)sprite->x; } - if (sprite->x == 0 && sprite->data[0] == 0x1000) - sprite->data[1] = 1; + if (sprite->x == 0 && sprite->sFade == FADE_TARGET) + sprite->sFinished = TRUE; sprite->x -= 16; - sprite->data[0] += 0x80; + sprite->sFade += FADE_TARGET / 32; if (sprite->x < 0) sprite->x = 0; - if (sprite->data[0] > 0x1000) - sprite->data[0] = 0x1000; + if (sprite->sFade > FADE_TARGET) + sprite->sFade = FADE_TARGET; - if (sprite->data[6]) + if (sprite->sIsMainSprite) sTransitionData->VBlank_DMA = 1; - if (sprite->data[1]) + if (sprite->sFinished) { - if (sprite->data[6] == 0 || (sTransitionData->field_20 > 6 && sprite->data[2]++ > 7)) + // If not the main sprite, destroy self. Otherwise, wait until the + // others have destroyed themselves, or until enough time has elapsed. + if (!sprite->sIsMainSprite || (sTransitionData->counter >= NUM_WHITE_BARS - 1 && sprite->sDestroyAttempts++ > 7)) { - sTransitionData->field_20++; + sTransitionData->counter++; DestroySprite(sprite); } } } } +#undef sFade +#undef sFinished +#undef sDestroyAttempts +#undef sDelay +#undef sIsMainSprite + +//--------------------------- +// B_TRANSITION_GRID_SQUARES +//--------------------------- + +#define tDelay data[1] +#define tShrinkStage data[2] + static void Task_GridSquares(u8 taskId) { while (sGridSquares_Funcs[gTasks[taskId].tState](&gTasks[taskId])); @@ -3496,37 +3724,37 @@ static bool8 GridSquares_Init(struct Task *task) GetBg0TilesDst(&tilemap, &tileset); CpuSet(sShrinkingBoxTileset, tileset, 16); - CpuFill16(0xF000, tilemap, BG_SCREEN_SIZE); + CpuFill16(0xF0 << 8, tilemap, BG_SCREEN_SIZE); LoadPalette(sFieldEffectPal_Pokeball, 0xF0, sizeof(sFieldEffectPal_Pokeball)); task->tState++; return FALSE; } -static bool8 GridSquares_Func2(struct Task *task) +static bool8 GridSquares_Main(struct Task *task) { u16* tileset; - if (task->data[1] == 0) + if (task->tDelay == 0) { GetBg0TilemapDst(&tileset); - task->data[1] = 3; - task->data[2]++; - CpuSet(sShrinkingBoxTileset + (task->data[2] * 8), tileset, 16); - if (task->data[2] > 13) + task->tDelay = 3; + task->tShrinkStage++; + CpuSet(&sShrinkingBoxTileset[task->tShrinkStage * 8], tileset, 16); + if (task->tShrinkStage > 13) { task->tState++; - task->data[1] = 16; + task->tDelay = 16; } } - task->data[1]--; + task->tDelay--; return FALSE; } static bool8 GridSquares_End(struct Task *task) { - if (--task->data[1] == 0) + if (--task->tDelay == 0) { FadeScreenBlack(); DestroyTask(FindTaskIdByFunc(Task_GridSquares)); @@ -3534,12 +3762,23 @@ static bool8 GridSquares_End(struct Task *task) return FALSE; } -static void Task_Shards(u8 taskId) +#undef tDelay +#undef tShrinkStage + +//--------------------------- +// B_TRANSITION_ANGLED_WIPES +//--------------------------- + +#define tWipeId data[1] +#define tDir data[2] +#define tDelay data[3] + +static void Task_AngledWipes(u8 taskId) { - while (sShards_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sAngledWipes_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static bool8 Shards_Init(struct Task *task) +static bool8 AngledWipes_Init(struct Task *task) { u16 i; @@ -3554,85 +3793,89 @@ static bool8 Shards_Init(struct Task *task) gScanlineEffectRegBuffers[0][i] = DISPLAY_WIDTH; CpuSet(gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], DISPLAY_HEIGHT); - SetVBlankCallback(VBlankCB_Shards); + SetVBlankCallback(VBlankCB_AngledWipes); task->tState++; return TRUE; } -static bool8 Shards_Func2(struct Task *task) +static bool8 AngledWipes_SetWipeData(struct Task *task) { - sub_814A1AC(sTransitionData->data, - sUnknown_085C8DD0[task->data[1]][0], - sUnknown_085C8DD0[task->data[1]][1], - sUnknown_085C8DD0[task->data[1]][2], - sUnknown_085C8DD0[task->data[1]][3], - 1, 1); - task->data[2] = sUnknown_085C8DD0[task->data[1]][4]; + InitBlackWipe(sTransitionData->data, + sAngledWipes_MoveData[task->tWipeId][0], + sAngledWipes_MoveData[task->tWipeId][1], + sAngledWipes_MoveData[task->tWipeId][2], + sAngledWipes_MoveData[task->tWipeId][3], + 1, 1); + task->tDir = sAngledWipes_MoveData[task->tWipeId][4]; task->tState++; return TRUE; } -static bool8 Shards_Func3(struct Task *task) +static bool8 AngledWipes_DoWipe(struct Task *task) { s16 i; - bool8 nextFunc; + bool8 finished; sTransitionData->VBlank_DMA = 0; - for (i = 0, nextFunc = FALSE; i < 16; i++) + for (i = 0, finished = FALSE; i < 16; i++) { - s16 r3 = gScanlineEffectRegBuffers[0][sTransitionData->data[3]] >> 8; - s16 r4 = gScanlineEffectRegBuffers[0][sTransitionData->data[3]] & 0xFF; - if (task->data[2] == 0) + s16 r3 = gScanlineEffectRegBuffers[0][sTransitionData->tWipeCurrY] >> 8; + s16 r4 = gScanlineEffectRegBuffers[0][sTransitionData->tWipeCurrY] & 0xFF; + if (task->tDir == 0) { - if (r3 < sTransitionData->data[2]) - r3 = sTransitionData->data[2]; + // Moving down + if (r3 < sTransitionData->tWipeCurrX) + r3 = sTransitionData->tWipeCurrX; if (r3 > r4) r3 = r4; } else { - if (r4 > sTransitionData->data[2]) - r4 = sTransitionData->data[2]; + // Moving up + if (r4 > sTransitionData->tWipeCurrX) + r4 = sTransitionData->tWipeCurrX; if (r4 <= r3) r4 = r3; } - gScanlineEffectRegBuffers[0][sTransitionData->data[3]] = (r4) | (r3 << 8); - if (nextFunc) + gScanlineEffectRegBuffers[0][sTransitionData->tWipeCurrY] = (r4) | (r3 << 8); + if (finished) { task->tState++; break; } - else - nextFunc = sub_814A228(sTransitionData->data, 1, 1); + finished = UpdateBlackWipe(sTransitionData->data, TRUE, TRUE); } sTransitionData->VBlank_DMA++; return FALSE; } -static bool8 Shards_Func4(struct Task *task) +static bool8 AngledWipes_TryEnd(struct Task *task) { - if (++task->data[1] < 7) + if (++task->tWipeId < NUM_ANGLED_WIPES) { + // Continue with next wipe task->tState++; - task->data[3] = sUnknown_085C8E16[task->data[1] - 1]; + task->tDelay = sAngledWipes_EndDelays[task->tWipeId - 1]; return TRUE; } else { + // End transition DmaStop(0); FadeScreenBlack(); - DestroyTask(FindTaskIdByFunc(Task_Shards)); + DestroyTask(FindTaskIdByFunc(Task_AngledWipes)); return FALSE; } } -static bool8 Shards_Func5(struct Task *task) +static bool8 AngledWipes_StartNext(struct Task *task) { - if (--task->data[3] == 0) + if (--task->tDelay == 0) { + // Return to AngledWipes_SetWipeData task->tState = 1; return TRUE; } @@ -3640,7 +3883,7 @@ static bool8 Shards_Func5(struct Task *task) return FALSE; } -static void VBlankCB_Shards(void) +static void VBlankCB_AngledWipes(void) { DmaStop(0); VBlankCB_BattleTransition(); @@ -3653,20 +3896,31 @@ static void VBlankCB_Shards(void) DmaSet(0, gScanlineEffectRegBuffers[1], ®_WIN0H, B_TRANS_DMA_FLAGS); } -#undef tFuncState -#undef tOpponentSpriteId -#undef tPlayerSpriteId -#undef tMugshotId +#undef tWipeId +#undef tDir +#undef tDelay + +//----------------------------------- +// Transition intro +//----------------------------------- -static void CreateIntroTask(s16 a0, s16 a1, s16 a2, s16 a3, s16 a4) +#define tFadeToGrayDelay data[1] +#define tFadeFromGrayDelay data[2] +#define tNumFades data[3] +#define tFadeToGrayIncrement data[4] +#define tFadeFromGrayIncrement data[5] +#define tDelayTimer data[6] +#define tBlend data[7] + +static void CreateIntroTask(s16 fadeToGrayDelay, s16 fadeFromGrayDelay, s16 numFades, s16 fadeToGrayIncrement, s16 fadeFromGrayIncrement) { u8 taskId = CreateTask(Task_BattleTransition_Intro, 3); - gTasks[taskId].data[1] = a0; - gTasks[taskId].data[2] = a1; - gTasks[taskId].data[3] = a2; - gTasks[taskId].data[4] = a3; - gTasks[taskId].data[5] = a4; - gTasks[taskId].data[6] = a0; + gTasks[taskId].tFadeToGrayDelay = fadeToGrayDelay; + gTasks[taskId].tFadeFromGrayDelay = fadeFromGrayDelay; + gTasks[taskId].tNumFades = numFades; + gTasks[taskId].tFadeToGrayIncrement = fadeToGrayIncrement; + gTasks[taskId].tFadeFromGrayIncrement = fadeFromGrayIncrement; + gTasks[taskId].tDelayTimer = fadeToGrayDelay; } static bool8 IsIntroTaskDone(void) @@ -3682,47 +3936,64 @@ void Task_BattleTransition_Intro(u8 taskId) while (sTransitionIntroFuncs[gTasks[taskId].tState](&gTasks[taskId])); } -static bool8 Transition_Intro_1(struct Task *task) +static bool8 TransitionIntro_FadeToGray(struct Task *task) { - if (task->data[6] == 0 || --task->data[6] == 0) + if (task->tDelayTimer == 0 || --task->tDelayTimer == 0) { - task->data[6] = task->data[1]; - task->data[7] += task->data[4]; - if (task->data[7] > 16) - task->data[7] = 16; - BlendPalettes(PALETTES_ALL, task->data[7], RGB(11, 11, 11)); + task->tDelayTimer = task->tFadeToGrayDelay; + task->tBlend += task->tFadeToGrayIncrement; + if (task->tBlend > 16) + task->tBlend = 16; + BlendPalettes(PALETTES_ALL, task->tBlend, RGB(11, 11, 11)); } - if (task->data[7] > 15) + if (task->tBlend >= 16) { + // Fade to gray complete, start fade back task->tState++; - task->data[6] = task->data[2]; + task->tDelayTimer = task->tFadeFromGrayDelay; } return FALSE; } -static bool8 Transition_Intro_2(struct Task *task) +static bool8 TransitionIntro_FadeFromGray(struct Task *task) { - if (task->data[6] == 0 || --task->data[6] == 0) + if (task->tDelayTimer == 0 || --task->tDelayTimer == 0) { - task->data[6] = task->data[2]; - task->data[7] -= task->data[5]; - if (task->data[7] < 0) - task->data[7] = 0; - BlendPalettes(PALETTES_ALL, task->data[7], RGB(11, 11, 11)); + task->tDelayTimer = task->tFadeFromGrayDelay; + task->tBlend -= task->tFadeFromGrayIncrement; + if (task->tBlend < 0) + task->tBlend = 0; + BlendPalettes(PALETTES_ALL, task->tBlend, RGB(11, 11, 11)); } - if (task->data[7] == 0) + if (task->tBlend == 0) { - if (--task->data[3] == 0) + if (--task->tNumFades == 0) + { + // All fades done, end intro DestroyTask(FindTaskIdByFunc(Task_BattleTransition_Intro)); + } else { - task->data[6] = task->data[1]; + // Fade from gray complete, start new fade + task->tDelayTimer = task->tFadeToGrayDelay; task->tState = 0; } } return FALSE; } +#undef tFadeToGrayDelay +#undef tFadeFromGrayDelay +#undef tNumFades +#undef tFadeToGrayIncrement +#undef tFadeFromGrayIncrement +#undef tDelayTimer +#undef tBlend + +//----------------------------------- +// General transition functions +//----------------------------------- + static void InitTransitionData(void) { memset(sTransitionData, 0, sizeof(*sTransitionData)); @@ -3740,7 +4011,7 @@ static void GetBg0TilemapDst(u16 **tileset) { u16 charBase = REG_BG0CNT >> 2; charBase <<= 14; - *tileset = (u16*)(VRAM + charBase); + *tileset = (u16*)(BG_VRAM + charBase); } void GetBg0TilesDst(u16 **tilemap, u16 **tileset) @@ -3751,8 +4022,8 @@ void GetBg0TilesDst(u16 **tilemap, u16 **tileset) screenBase <<= 11; charBase <<= 14; - *tilemap = (u16*)(VRAM + screenBase); - *tileset = (u16*)(VRAM + charBase); + *tilemap = (u16*)(BG_VRAM + screenBase); + *tileset = (u16*)(BG_VRAM + charBase); } static void FadeScreenBlack(void) @@ -3767,126 +4038,151 @@ static void SetSinWave(s16 *array, s16 sinAdd, s16 index, s16 indexIncrementer, array[i] = sinAdd + Sin(index & 0xFF, amplitude); } -static void sub_814A014(u16 *array, s16 x, s16 y, s16 amplitude) +static void SetCircularMask(u16 *buffer, s16 centerX, s16 centerY, s16 radius) { s16 i; - memset(array, 10, DISPLAY_HEIGHT * sizeof(s16)); + memset(buffer, 10, DISPLAY_HEIGHT * sizeof(u16)); for (i = 0; i < 64; i++) { s16 sinResult, cosResult; - s16 toStoreOrr, r2, r3, toStore, r7, r8; - - sinResult = Sin(i, amplitude); - cosResult = Cos(i, amplitude); - - toStoreOrr = x - sinResult; - toStore = x + sinResult; - r7 = y - cosResult; - r8 = y + cosResult; - - if (toStoreOrr < 0) - toStoreOrr = 0; - if (toStore > DISPLAY_WIDTH) - toStore = DISPLAY_WIDTH; - if (r7 < 0) - r7 = 0; - if (r8 > DISPLAY_HEIGHT - 1) - r8 = DISPLAY_HEIGHT - 1; - - toStore |= (toStoreOrr << 8); - array[r7] = toStore; - array[r8] = toStore; - - cosResult = Cos(i + 1, amplitude); - r3 = y - cosResult; - r2 = y + cosResult; - - if (r3 < 0) - r3 = 0; - if (r2 > DISPLAY_HEIGHT - 1) - r2 = DISPLAY_HEIGHT - 1; - - while (r7 > r3) - array[--r7] = toStore; - while (r7 < r3) - array[++r7] = toStore; - - while (r8 > r2) - array[--r8] = toStore; - while (r8 < r2) - array[++r8] = toStore; + s16 drawXLeft, drawYBottNext, drawYTopNext, drawX, drawYTop, drawYBott; + + sinResult = Sin(i, radius); + cosResult = Cos(i, radius); + + drawXLeft = centerX - sinResult; + drawX = centerX + sinResult; + drawYTop = centerY - cosResult; + drawYBott = centerY + cosResult; + + if (drawXLeft < 0) + drawXLeft = 0; + if (drawX > DISPLAY_WIDTH) + drawX = DISPLAY_WIDTH; + if (drawYTop < 0) + drawYTop = 0; + if (drawYBott > DISPLAY_HEIGHT - 1) + drawYBott = DISPLAY_HEIGHT - 1; + + drawX |= (drawXLeft << 8); + buffer[drawYTop] = drawX; + buffer[drawYBott] = drawX; + + cosResult = Cos(i + 1, radius); + drawYTopNext = centerY - cosResult; + drawYBottNext = centerY + cosResult; + + if (drawYTopNext < 0) + drawYTopNext = 0; + if (drawYBottNext > DISPLAY_HEIGHT - 1) + drawYBottNext = DISPLAY_HEIGHT - 1; + + while (drawYTop > drawYTopNext) + buffer[--drawYTop] = drawX; + while (drawYTop < drawYTopNext) + buffer[++drawYTop] = drawX; + + while (drawYBott > drawYBottNext) + buffer[--drawYBott] = drawX; + while (drawYBott < drawYBottNext) + buffer[++drawYBott] = drawX; } } -static void sub_814A1AC(s16 *data, s16 a1, s16 a2, s16 a3, s16 a4, s16 a5, s16 a6) +static void InitBlackWipe(s16 *data, s16 startX, s16 startY, s16 endX, s16 endY, s16 xMove, s16 yMove) { - data[0] = a1; - data[1] = a2; - data[2] = a1; - data[3] = a2; - data[4] = a3; - data[5] = a4; - data[6] = a5; - data[7] = a6; - data[8] = a3 - a1; - if (data[8] < 0) + tWipeStartX = startX; + tWipeStartY = startY; + tWipeCurrX = startX; + tWipeCurrY = startY; + tWipeEndX = endX; + tWipeEndY = endY; + tWipeXMove = xMove; + tWipeYMove = yMove; + tWipeXDist = endX - startX; + if (tWipeXDist < 0) { - data[8] = -data[8]; - data[6] = -a5; + // If end was less than start, reverse direction + tWipeXDist = -tWipeXDist; + tWipeXMove = -xMove; } - data[9] = a4 - a2; - if (data[9] < 0) + tWipeYDist = endY - startY; + if (tWipeYDist < 0) { - data[9] = -data[9]; - data[7] = -a6; + // If end was less than start, reverse direction + tWipeYDist = -tWipeYDist; + tWipeYMove = -yMove; } - data[10] = 0; + tWipeTemp = 0; } -static bool8 sub_814A228(s16 *data, bool8 a1, bool8 a2) +static bool8 UpdateBlackWipe(s16 *data, bool8 xExact, bool8 yExact) { - u8 var; - if (data[8] > data[9]) + u8 numFinished; + + if (tWipeXDist > tWipeYDist) { - data[2] += data[6]; - data[10] += data[9]; - if (data[10] > data[8]) + // X has further to move, move it first + tWipeCurrX += tWipeXMove; + + // If it has been far enough since Y's + // last move then move it too + tWipeTemp += tWipeYDist; + if (tWipeTemp > tWipeXDist) { - data[3] += data[7]; - data[10] -= data[8]; + tWipeCurrY += tWipeYMove; + tWipeTemp -= tWipeXDist; } } else { - data[3] += data[7]; - data[10] += data[8]; - if (data[10] > data[9]) + // Y has further to move, move it first + tWipeCurrY += tWipeYMove; + + // If it has been far enough since X's + // last move then move it too + tWipeTemp += tWipeXDist; + if (tWipeTemp > tWipeYDist) { - data[2] += data[6]; - data[10] -= data[9]; + tWipeCurrX += tWipeXMove; + tWipeTemp -= tWipeYDist; } } - var = 0; - if ((data[6] > 0 && data[2] >= data[4]) || (data[6] < 0 && data[2] <= data[4])) + + numFinished = 0; + + // Has X coord reached end? + if ((tWipeXMove > 0 && tWipeCurrX >= tWipeEndX) + || (tWipeXMove < 0 && tWipeCurrX <= tWipeEndX)) { - var++; - if (a1) - data[2] = data[4]; + numFinished++; + if (xExact) + tWipeCurrX = tWipeEndX; } - if ((data[7] > 0 && data[3] >= data[5]) || (data[7] < 0 && data[3] <= data[5])) + + // Has Y coord reached end? + if ((tWipeYMove > 0 && tWipeCurrY >= tWipeEndY) + || (tWipeYMove < 0 && tWipeCurrY <= tWipeEndY)) { - var++; - if (a2) - data[3] = data[5]; + numFinished++; + if (yExact) + tWipeCurrY = tWipeEndY; } - if (var == 2) + // Return TRUE if both coords have reached end + if (numFinished == 2) return TRUE; else return FALSE; } +//----------------------------------- +// B_TRANSITION_FRONTIER_LOGO_WIGGLE +//----------------------------------- + +#define tAmplitude data[5] + static bool8 FrontierLogoWiggle_Init(struct Task *task) { u16 *tilemap, *tileset; @@ -3907,7 +4203,7 @@ static bool8 FrontierLogoWiggle_SetGfx(struct Task *task) GetBg0TilesDst(&tilemap, &tileset); LZ77UnCompVram(sFrontierLogo_Tilemap, tilemap); - SetSinWave(gScanlineEffectRegBuffers[0], 0, task->data[4], 0x84, task->data[5], DISPLAY_HEIGHT); + SetSinWave(gScanlineEffectRegBuffers[0], 0, task->data[4], 0x84, task->tAmplitude, DISPLAY_HEIGHT); task->tState++; return TRUE; @@ -3918,6 +4214,20 @@ static void Task_FrontierLogoWiggle(u8 taskId) while (sFrontierLogoWiggle_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } +#undef tAmplitude + +//--------------------------------- +// B_TRANSITION_FRONTIER_LOGO_WAVE +//--------------------------------- + +#define tSinVal data[1] +#define tAmplitudeVal data[2] +#define tTimer data[3] +#define tStartedFade data[4] +#define tBlendTarget2 data[5] +#define tBlendTarget1 data[6] +#define tSinDecrement data[7] + static void Task_FrontierLogoWave(u8 taskId) { while (sFrontierLogoWave_Funcs[gTasks[taskId].tState](&gTasks[taskId])); @@ -3930,13 +4240,13 @@ static bool8 FrontierLogoWave_Init(struct Task *task) InitTransitionData(); ScanlineEffect_Clear(); ClearGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON | DISPCNT_WIN1_ON); - task->data[2] = 0x2000; - task->data[1] = 0x7FFF; - task->data[5] = 0; - task->data[6] = 16; - task->data[7] = 2560; + task->tAmplitudeVal = 32 << 8; + task->tSinVal = 0x7FFF; + task->tBlendTarget2 = 0; + task->tBlendTarget1 = 16; + task->tSinDecrement = 2560; sTransitionData->BLDCNT = BLDCNT_TGT1_BG0 | BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_ALL; - sTransitionData->BLDALPHA = BLDALPHA_BLEND(task->data[5], task->data[6]); + sTransitionData->BLDALPHA = BLDALPHA_BLEND(task->tBlendTarget2, task->tBlendTarget1); REG_BLDCNT = sTransitionData->BLDCNT; REG_BLDALPHA = sTransitionData->BLDALPHA; GetBg0TilesDst(&tilemap, &tileset); @@ -3978,50 +4288,54 @@ static bool8 FrontierLogoWave_Func3(struct Task *task) static bool8 FrontierLogoWave_Func4(struct Task *task) { u8 i; - u16 var6, amplitude, var8; + u16 sinVal, amplitude, sinSpread; sTransitionData->VBlank_DMA = FALSE; - amplitude = task->data[2] >> 8; - var6 = task->data[1]; - var8 = 384; + amplitude = task->tAmplitudeVal >> 8; + sinVal = task->tSinVal; + sinSpread = 384; - task->data[1] = var6 - task->data[7]; + task->tSinVal -= task->tSinDecrement; - if (task->data[3] >= 70) + if (task->tTimer >= 70) { - if (task->data[2] - 384 >= 0) - task->data[2] -= 384; + // Decrease amount logo moves up and down + // until it rests in the middle of the screen. + if (task->tAmplitudeVal - 384 >= 0) + task->tAmplitudeVal -= 384; else - task->data[2] = 0; + task->tAmplitudeVal = 0; } - if (task->data[3] >= 0 && task->data[3] % 3 == 0) + if (task->tTimer >= 0 && task->tTimer % 3 == 0) { - if (task->data[5] < 16) - task->data[5]++; - else if (task->data[6] > 0) - task->data[6]--; + // Blend logo into view + if (task->tBlendTarget2 < 16) + task->tBlendTarget2++; + else if (task->tBlendTarget1 > 0) + task->tBlendTarget1--; - sTransitionData->BLDALPHA = BLDALPHA_BLEND(task->data[5], task->data[6]); + sTransitionData->BLDALPHA = BLDALPHA_BLEND(task->tBlendTarget2, task->tBlendTarget1); } - for (i = 0; i < DISPLAY_HEIGHT; i++, var6 += var8) + // Move logo up and down + for (i = 0; i < DISPLAY_HEIGHT; i++, sinVal += sinSpread) { - s16 index = var6 / 256; + s16 index = sinVal / 256; gScanlineEffectRegBuffers[0][i] = sTransitionData->cameraY + Sin(index & 0xff, amplitude); } - if (++task->data[3] == 101) + if (++task->tTimer == 101) { - task->data[4]++; + task->tStartedFade++; BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 16, RGB_BLACK); } - if (task->data[4] != 0 && !gPaletteFade.active) + if (task->tStartedFade && !gPaletteFade.active) DestroyTask(FindTaskIdByFunc(Task_FrontierLogoWave)); - task->data[7] -= 17; + task->tSinDecrement -= 17; sTransitionData->VBlank_DMA++; return FALSE; } @@ -4042,6 +4356,30 @@ static void HBlankCB_FrontierLogoWave(void) REG_BG0VOFS = var; } +#undef tSinVal +#undef tAmplitudeVal +#undef tTimer +#undef tStartedFade +#undef tBlendTarget2 +#undef tBlendTarget1 +#undef tSinDecrement + +//---------------------------------------------------------------------- +// B_TRANSITION_FRONTIER_SQUARES, B_TRANSITION_FRONTIER_SQUARES_SCROLL, +// and B_TRANSITION_FRONTIER_SQUARES_SPIRAL +//---------------------------------------------------------------------- + +#define NUM_SQUARES_PER_ROW 7 +#define NUM_SQUARES_PER_COL 5 +#define SQUARE_SIZE 4 + +#define tPosX data[2] +#define tPosY data[3] +#define tRowPos data[4] +#define tShrinkState data[5] +#define tShrinkDelayTimer data[6] +#define tShrinkDelay data[7] + static void Task_FrontierSquares(u8 taskId) { while (sFrontierSquares_Funcs[gTasks[taskId].tState](&gTasks[taskId])); @@ -4070,42 +4408,46 @@ static bool8 FrontierSquares_Init(struct Task *task) CopyBgTilemapBufferToVram(0); LoadPalette(sFrontierSquares_Palette, 0xF0, sizeof(sFrontierSquares_Palette)); - task->data[2] = 1; - task->data[3] = 0; - task->data[4] = 0; - task->data[7] = 10; + task->tPosX = 1; + task->tPosY = 0; + task->tRowPos = 0; + task->tShrinkDelay = 10; task->tState++; return FALSE; } -static bool8 FrontierSquares_Func2(struct Task *task) +static bool8 FrontierSquares_Draw(struct Task *task) { - CopyRectToBgTilemapBufferRect(0, sFrontierSquares_Tilemap, 0, 0, 4, 4, task->data[2], task->data[3], 4, 4, 0xF, 0, 0); + CopyRectToBgTilemapBufferRect(0, sFrontierSquares_Tilemap, 0, 0, + SQUARE_SIZE, SQUARE_SIZE, + task->tPosX, task->tPosY, + SQUARE_SIZE, SQUARE_SIZE, + 15, 0, 0); CopyBgTilemapBufferToVram(0); - task->data[2] += 4; - if (++task->data[4] == 7) + task->tPosX += SQUARE_SIZE; + if (++task->tRowPos == NUM_SQUARES_PER_ROW) { - task->data[2] = 1; - task->data[3] += 4; - task->data[4] = 0; - if (task->data[3] > 19) + task->tPosX = 1; + task->tPosY += SQUARE_SIZE; + task->tRowPos = 0; + if (task->tPosY >= NUM_SQUARES_PER_COL * SQUARE_SIZE) task->tState++; } return FALSE; } -static bool8 FrontierSquares_Func3(struct Task *task) +static bool8 FrontierSquares_Shrink(struct Task *task) { u8 i; u16 *tilemap, *tileset; GetBg0TilesDst(&tilemap, &tileset); - if (task->data[6]++ >= task->data[7]) + if (task->tShrinkDelayTimer++ >= task->tShrinkDelay) { - switch (task->data[5]) + switch (task->tShrinkState) { case 0: for (i = 250; i < 255; i++) @@ -4131,13 +4473,20 @@ static bool8 FrontierSquares_Func3(struct Task *task) return FALSE; } - task->data[6] = 0; - task->data[5]++; + task->tShrinkDelayTimer = 0; + task->tShrinkState++; } return FALSE; } +#undef tPosX +#undef tPosY +#undef tRowPos +#undef tShrinkState +#undef tShrinkDelayTimer +#undef tShrinkDelay + static bool8 FrontierSquaresSpiral_Init(struct Task *task) { u16 *tilemap, *tileset; -- cgit v1.2.3 From f51247615e5734f1b9d61e22156b90ab1f1b489f Mon Sep 17 00:00:00 2001 From: GriffinR Date: Fri, 29 Oct 2021 11:56:06 -0400 Subject: Finish documenting battle_transition --- src/battle_transition.c | 496 +++++++++++++++++++++++++++--------------------- 1 file changed, 276 insertions(+), 220 deletions(-) (limited to 'src/battle_transition.c') diff --git a/src/battle_transition.c b/src/battle_transition.c index 88194db27..6aa388302 100644 --- a/src/battle_transition.c +++ b/src/battle_transition.c @@ -80,8 +80,8 @@ struct RectangularSpiralLine u8 state; s16 position; u8 moveIdx; - s16 skipPosition; - u8 field_8; + s16 reboundPosition; + bool8 outward; }; typedef bool8 (*TransitionStateFunc)(struct Task *task); @@ -227,8 +227,8 @@ static bool8 FrontierLogoWiggle_Init(struct Task *task); static bool8 FrontierLogoWiggle_SetGfx(struct Task *task); static bool8 FrontierLogoWave_Init(struct Task *task); static bool8 FrontierLogoWave_SetGfx(struct Task *task); -static bool8 FrontierLogoWave_Func3(struct Task *task); -static bool8 FrontierLogoWave_Func4(struct Task *task); +static bool8 FrontierLogoWave_InitScanline(struct Task *task); +static bool8 FrontierLogoWave_Main(struct Task *task); static bool8 Rayquaza_Init(struct Task *task); static bool8 Rayquaza_SetGfx(struct Task *task); static bool8 Rayquaza_PaletteFlash(struct Task *task); @@ -241,13 +241,13 @@ static bool8 FrontierSquares_Draw(struct Task *task); static bool8 FrontierSquares_Shrink(struct Task *task); static bool8 FrontierSquares_End(struct Task *task); static bool8 FrontierSquaresSpiral_Init(struct Task *task); -static bool8 FrontierSquaresSpiral_Func2(struct Task *task); -static bool8 FrontierSquaresSpiral_Func3(struct Task *task); -static bool8 FrontierSquaresSpiral_Func4(struct Task *task); +static bool8 FrontierSquaresSpiral_Outward(struct Task *task); +static bool8 FrontierSquaresSpiral_SetBlack(struct Task *task); +static bool8 FrontierSquaresSpiral_Inward(struct Task *task); static bool8 FrontierSquaresScroll_Init(struct Task *task); -static bool8 FrontierSquaresScroll_Func2(struct Task *task); -static bool8 FrontierSquaresScroll_Func3(struct Task *task); -static bool8 FrontierSquaresScroll_Func4(struct Task *task); +static bool8 FrontierSquaresScroll_Draw(struct Task *task); +static bool8 FrontierSquaresScroll_SetBlack(struct Task *task); +static bool8 FrontierSquaresScroll_Erase(struct Task *task); static bool8 FrontierSquaresScroll_End(struct Task *task); static bool8 Mugshot_Init(struct Task *task); static bool8 Mugshot_SetGfx(struct Task *task); @@ -625,52 +625,73 @@ static const TransitionStateFunc sRectangularSpiral_Funcs[] = }; #define SPIRAL_END (-1) -#define SPIRAL_SKIP (-2) +#define SPIRAL_REBOUND (-2) + +// Note that the directions are inverted for the lines originating at the bottom. +// i.e. MOVE_RIGHT is a right move for the top lines and a left move for the inverted bottom lines. +enum { + MOVE_RIGHT = 1, + MOVE_LEFT, + MOVE_UP, + MOVE_DOWN, +}; + +// Offsets of the movement data for spiraling in either direction. +#define SPIRAL_INWARD_START 0 +#define SPIRAL_INWARD_END 3 +#define SPIRAL_OUTWARD_START 4 +#define SPIRAL_OUTWARD_END 7 -static const s16 gUnknown_085C8C90[] = {1, 27, 275, SPIRAL_END}; -static const s16 gUnknown_085C8C98[] = {2, 486, SPIRAL_END}; -static const s16 gUnknown_085C8C9E[] = {3, 262, SPIRAL_END}; -static const s16 gUnknown_085C8CA4[] = {4, 507, SPIRAL_SKIP}; +static const s16 sRectangularSpiral_Major_InwardRight[] = {MOVE_RIGHT, 27, 275, SPIRAL_END}; +static const s16 sRectangularSpiral_Major_InwardLeft[] = {MOVE_LEFT, 486, SPIRAL_END}; +static const s16 sRectangularSpiral_Major_InwardUp[] = {MOVE_UP, 262, SPIRAL_END}; +static const s16 sRectangularSpiral_Major_InwardDown[] = {MOVE_DOWN, 507, SPIRAL_REBOUND}; -static const s16 gUnknown_085C8CAA[] = {1, 213, SPIRAL_END}; -static const s16 gUnknown_085C8CB0[] = {2, 548, SPIRAL_SKIP}; -static const s16 gUnknown_085C8CB6[] = {3, 196, SPIRAL_END}; -static const s16 gUnknown_085C8CBC[] = {4, 573, 309, SPIRAL_END}; +static const s16 sRectangularSpiral_Minor_InwardRight[] = {MOVE_RIGHT, 213, SPIRAL_END}; +static const s16 sRectangularSpiral_Minor_InwardLeft[] = {MOVE_LEFT, 548, SPIRAL_REBOUND}; +static const s16 sRectangularSpiral_Minor_InwardUp[] = {MOVE_UP, 196, SPIRAL_END}; +static const s16 sRectangularSpiral_Minor_InwardDown[] = {MOVE_DOWN, 573, 309, SPIRAL_END}; -static const s16 gUnknown_085C8CC4[] = {1, 474, SPIRAL_END}; -static const s16 gUnknown_085C8CCA[] = {2, 295, 32, SPIRAL_END}; -static const s16 gUnknown_085C8CD2[] = {3, 58, SPIRAL_END}; -static const s16 gUnknown_085C8CD8[] = {4, 455, SPIRAL_END}; +static const s16 sRectangularSpiral_Minor_OutwardRight[] = {MOVE_RIGHT, 474, SPIRAL_END}; +static const s16 sRectangularSpiral_Minor_OutwardLeft[] = {MOVE_LEFT, 295, 32, SPIRAL_END}; +static const s16 sRectangularSpiral_Minor_OutwardUp[] = {MOVE_UP, 58, SPIRAL_END}; +static const s16 sRectangularSpiral_Minor_OutwardDown[] = {MOVE_DOWN, 455, SPIRAL_END}; -static const s16 gUnknown_085C8CDE[] = {1, 540, SPIRAL_END}; -static const s16 gUnknown_085C8CE4[] = {2, 229, SPIRAL_END}; -static const s16 gUnknown_085C8CEA[] = {3, 244, 28, SPIRAL_END}; -static const s16 gUnknown_085C8CF2[] = {4, 517, SPIRAL_END}; +static const s16 sRectangularSpiral_Major_OutwardRight[] = {MOVE_RIGHT, 540, SPIRAL_END}; +static const s16 sRectangularSpiral_Major_OutwardLeft[] = {MOVE_LEFT, 229, SPIRAL_END}; +static const s16 sRectangularSpiral_Major_OutwardUp[] = {MOVE_UP, 244, 28, SPIRAL_END}; +static const s16 sRectangularSpiral_Major_OutwardDown[] = {MOVE_DOWN, 517, SPIRAL_END}; // Move data for spiral lines starting in the top left / bottom right static const s16 *const sRectangularSpiral_MoveDataTable_MajorDiagonal[] = { - gUnknown_085C8C90, - gUnknown_085C8CA4, - gUnknown_085C8C98, - gUnknown_085C8C9E, - gUnknown_085C8CEA, - gUnknown_085C8CE4, - gUnknown_085C8CF2, - gUnknown_085C8CDE + [SPIRAL_INWARD_START] = + sRectangularSpiral_Major_InwardRight, + sRectangularSpiral_Major_InwardDown, + sRectangularSpiral_Major_InwardLeft, + sRectangularSpiral_Major_InwardUp, + + [SPIRAL_OUTWARD_START] = + sRectangularSpiral_Major_OutwardUp, + sRectangularSpiral_Major_OutwardLeft, + sRectangularSpiral_Major_OutwardDown, + sRectangularSpiral_Major_OutwardRight }; // Move data for spiral lines starting in the top right / bottom left static const s16 *const sRectangularSpiral_MoveDataTable_MinorDiagonal[] = { - gUnknown_085C8CBC, - gUnknown_085C8CB0, - gUnknown_085C8CB6, - gUnknown_085C8CAA, - gUnknown_085C8CCA, - gUnknown_085C8CD8, - gUnknown_085C8CC4, - gUnknown_085C8CD2 + [SPIRAL_INWARD_START] = + sRectangularSpiral_Minor_InwardDown, + sRectangularSpiral_Minor_InwardLeft, + sRectangularSpiral_Minor_InwardUp, + sRectangularSpiral_Minor_InwardRight, + + [SPIRAL_OUTWARD_START] = + sRectangularSpiral_Minor_OutwardLeft, + sRectangularSpiral_Minor_OutwardDown, + sRectangularSpiral_Minor_OutwardRight, + sRectangularSpiral_Minor_OutwardUp }; static const s16 *const *const sRectangularSpiral_MoveDataTables[] = @@ -738,7 +759,7 @@ static const TransitionStateFunc sAngledWipes_Funcs[] = static const s16 sAngledWipes_MoveData[NUM_ANGLED_WIPES][5] = { -// startX startY endX endY yDirection +// startX startY endX endY yDirection {56, 0, 0, DISPLAY_HEIGHT, 0}, {104, DISPLAY_HEIGHT, DISPLAY_WIDTH, 88, 1}, {DISPLAY_WIDTH, 72, 56, 0, 1}, @@ -908,8 +929,8 @@ static const TransitionStateFunc sFrontierLogoWave_Funcs[] = { FrontierLogoWave_Init, FrontierLogoWave_SetGfx, - FrontierLogoWave_Func3, - FrontierLogoWave_Func4 + FrontierLogoWave_InitScanline, + FrontierLogoWave_Main }; static const TransitionStateFunc sFrontierSquares_Funcs[] = @@ -923,38 +944,54 @@ static const TransitionStateFunc sFrontierSquares_Funcs[] = static const TransitionStateFunc sFrontierSquaresSpiral_Funcs[] = { FrontierSquaresSpiral_Init, - FrontierSquaresSpiral_Func2, - FrontierSquaresSpiral_Func3, - FrontierSquaresSpiral_Func4, + FrontierSquaresSpiral_Outward, + FrontierSquaresSpiral_SetBlack, + FrontierSquaresSpiral_Inward, FrontierSquares_End }; static const TransitionStateFunc sFrontierSquaresScroll_Funcs[] = { FrontierSquaresScroll_Init, - FrontierSquaresScroll_Func2, - FrontierSquaresScroll_Func3, - FrontierSquaresScroll_Func4, + FrontierSquaresScroll_Draw, + FrontierSquaresScroll_SetBlack, + FrontierSquaresScroll_Erase, FrontierSquaresScroll_End }; -static const u8 gUnknown_085C9A30[] = { - 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, - 0x1b, 0x14, 0x0d, 0x06, 0x05, 0x04, 0x03, - 0x02, 0x01, 0x00, 0x07, 0x0e, 0x15, 0x16, - 0x17, 0x18, 0x19, 0x1a, 0x13, 0x0c, 0x0b, - 0x0a, 0x09, 0x08, 0x0f, 0x10, 0x11, 0x12 +// Dimensions for the 2 non-scrolling frontier square transitions. +// SQUARE_SIZE is the same in the scrolling version but it uses +// more because it needs to show more than can be shown at a single +// time n-screen. +#define SQUARE_SIZE 4 +#define MARGIN_SIZE 1 // Squares do not fit evenly across the width, so there is a margin on either side. +#define NUM_SQUARES_PER_ROW ((DISPLAY_WIDTH - (MARGIN_SIZE * 8 * 2)) / (SQUARE_SIZE * 8)) +#define NUM_SQUARES_PER_COL (DISPLAY_HEIGHT / (SQUARE_SIZE * 8)) +#define NUM_SQUARES (NUM_SQUARES_PER_ROW * NUM_SQUARES_PER_COL) + +// The order in which the squares should appear/disappear to create +// the spiral effect. Spiraling inward starts with the first element, +// and spiraling outward starts with the last. The positions are the +// squares numbered left-to-right top-to-bottom. +static const u8 sFrontierSquaresSpiral_Positions[NUM_SQUARES] = { + 28, 29, 30, 31, 32, 33, 34, + 27, 20, 13, 6, 5, 4, 3, + 2, 1, 0, 7, 14, 21, 22, + 23, 24, 25, 26, 19, 12, 11, + 10, 9, 8, 15, 16, 17, 18 }; -static const u8 gUnknown_085C9A53[] = { - 0x00, 0x10, 0x29, 0x16, 0x2c, 0x02, 0x2b, 0x15, - 0x2e, 0x1b, 0x09, 0x30, 0x26, 0x05, 0x39, 0x3b, - 0x0c, 0x3f, 0x23, 0x1c, 0x0a, 0x35, 0x07, 0x31, - 0x27, 0x17, 0x37, 0x01, 0x3e, 0x11, 0x3d, 0x1e, - 0x06, 0x22, 0x0f, 0x33, 0x20, 0x3a, 0x0d, 0x2d, - 0x25, 0x34, 0x0b, 0x18, 0x3c, 0x13, 0x38, 0x21, - 0x1d, 0x32, 0x28, 0x36, 0x0e, 0x03, 0x2f, 0x14, - 0x12, 0x19, 0x04, 0x24, 0x1a, 0x2a, 0x1f, 0x08 +// In the scrolling version the squares appear/disappear in a "random" order +// dictated by the list below. +static const u8 sFrontierSquaresScroll_Positions[] = { + 0, 16, 41, 22, 44, 2, 43, 21, + 46, 27, 9, 48, 38, 5, 57, 59, + 12, 63, 35, 28, 10, 53, 7, 49, + 39, 23, 55, 1, 62, 17, 61, 30, + 6, 34, 15, 51, 32, 58, 13, 45, + 37, 52, 11, 24, 60, 19, 56, 33, + 29, 50, 40, 54, 14, 3, 47, 20, + 18, 25, 4, 36, 26, 42, 31, 8 }; //--------------------------- @@ -1036,7 +1073,7 @@ static void Task_BattleTransition(u8 taskId) static bool8 Transition_StartIntro(struct Task *task) { SetWeatherScreenFadeOut(); - CpuCopy32(gPlttBufferFaded, gPlttBufferUnfaded, 0x400); + CpuCopy32(gPlttBufferFaded, gPlttBufferUnfaded, sizeof(gPlttBufferUnfaded)); if (sTasks_Intro[task->tTransitionId] != NULL) { CreateTask(sTasks_Intro[task->tTransitionId], 4); @@ -3158,40 +3195,40 @@ static bool8 RectangularSpiral_Init(struct Task *task) GetBg0TilesDst(&tilemap, &tileset); CpuCopy16(sShrinkingBoxTileset, tileset, 0x20); - CpuCopy16(sShrinkingBoxTileset + 0x70, tileset + 0x20, 0x20); + CpuCopy16(&sShrinkingBoxTileset[0x70], &tileset[0x20], 0x20); CpuFill16(0xF0 << 8, tilemap, BG_SCREEN_SIZE); LoadPalette(sFieldEffectPal_Pokeball, 0xF0, sizeof(sFieldEffectPal_Pokeball)); task->data[3] = 1; task->tState++; - // Top left - sRectangularSpiralLines[0].state = 0; + // Line starting in top left + sRectangularSpiralLines[0].state = SPIRAL_INWARD_START; sRectangularSpiralLines[0].position = -1; sRectangularSpiralLines[0].moveIdx = 1; - sRectangularSpiralLines[0].skipPosition = 308; - sRectangularSpiralLines[0].field_8 = 0; + sRectangularSpiralLines[0].reboundPosition = 308; + sRectangularSpiralLines[0].outward = FALSE; - // Bottom right - sRectangularSpiralLines[1].state = 0; + // Line starting in bottom right + sRectangularSpiralLines[1].state = SPIRAL_INWARD_START; sRectangularSpiralLines[1].position = -1; sRectangularSpiralLines[1].moveIdx = 1; - sRectangularSpiralLines[1].skipPosition = 308; - sRectangularSpiralLines[1].field_8 = 0; + sRectangularSpiralLines[1].reboundPosition = 308; + sRectangularSpiralLines[1].outward = FALSE; - // Top right - sRectangularSpiralLines[2].state = 0; + // Line starting in top right + sRectangularSpiralLines[2].state = SPIRAL_INWARD_START; sRectangularSpiralLines[2].position = -3; sRectangularSpiralLines[2].moveIdx = 1; - sRectangularSpiralLines[2].skipPosition = 307; - sRectangularSpiralLines[2].field_8 = 0; + sRectangularSpiralLines[2].reboundPosition = 307; + sRectangularSpiralLines[2].outward = FALSE; - // Bottom left - sRectangularSpiralLines[3].state = 0; + // Line starting in bottom left + sRectangularSpiralLines[3].state = SPIRAL_INWARD_START; sRectangularSpiralLines[3].position = -3; sRectangularSpiralLines[3].moveIdx = 1; - sRectangularSpiralLines[3].skipPosition = 307; - sRectangularSpiralLines[3].field_8 = 0; + sRectangularSpiralLines[3].reboundPosition = 307; + sRectangularSpiralLines[3].outward = FALSE; return FALSE; } @@ -3219,7 +3256,7 @@ static bool8 RectangularSpiral_Main(struct Task *task) done = FALSE; position = sRectangularSpiralLines[j].position; - // Invert position for the two bottom lines + // Invert position for the two lines that start at the bottom. if ((j % 2) == 1) position = 637 - position; @@ -3248,6 +3285,10 @@ static bool8 RectangularSpiral_End(struct Task *task) static bool16 UpdateRectangularSpiralLine(const s16 * const *moveDataTable, struct RectangularSpiralLine *line) { const s16 *moveData = moveDataTable[line->state]; + + // Has spiral finished? + // Note that most move data arrays endsin SPIRAL_END but it is + // only ever reached on the final array of spiraling outward. if (moveData[line->moveIdx] == SPIRAL_END) return FALSE; @@ -3257,18 +3298,22 @@ static bool16 UpdateRectangularSpiralLine(const s16 * const *moveDataTable, stru sDebug_RectangularSpiralData = moveData[2]; sDebug_RectangularSpiralData = moveData[3]; + // Note that for the two lines originating at the bottom the + // position is inverted, so the directions are flipped. + // i.e. position += 1 is right for the top lines and left + // for their inverted partners on the bottom. switch (moveData[0]) { - case 1: + case MOVE_RIGHT: line->position += 1; break; - case 2: + case MOVE_LEFT: line->position -= 1; break; - case 3: + case MOVE_UP: line->position -= 32; break; - case 4: + case MOVE_DOWN: line->position += 32; break; } @@ -3278,31 +3323,40 @@ static bool16 UpdateRectangularSpiralLine(const s16 * const *moveDataTable, stru if (line->position >= 640 || moveData[line->moveIdx] == SPIRAL_END) return FALSE; - if (line->field_8 == 0 && moveData[line->moveIdx] == SPIRAL_SKIP) + if (!line->outward && moveData[line->moveIdx] == SPIRAL_REBOUND) { - line->field_8 = 1; + // Line has reached the final point of spiraling inward. + // Time to flip and start spiraling outward. + line->outward = TRUE; line->moveIdx = 1; - line->position = line->skipPosition; - line->state = 4; + line->position = line->reboundPosition; + line->state = SPIRAL_OUTWARD_START; } + // Reached move target, advance to next movement. if (line->position == moveData[line->moveIdx]) { line->state++; - if (line->field_8 == 1) + if (line->outward == TRUE) { - if (line->state > 7) + if (line->state > SPIRAL_OUTWARD_END) { + // Still spiraling outward, loop back to the first state + // but use the second set of move targets. + // For example, the 28 in sRectangularSpiral_Major_OutwardUp line->moveIdx++; - line->state = 4; + line->state = SPIRAL_OUTWARD_START; } } else { - if (line->state > 3) + if (line->state > SPIRAL_INWARD_END) { + // Still spiraling inward, loop back to the first state + // but use the second set of move targets. + // For example, the 275 in sRectangularSpiral_Major_InwardRight line->moveIdx++; - line->state = 0; + line->state = SPIRAL_INWARD_START; } } } @@ -4181,6 +4235,7 @@ static bool8 UpdateBlackWipe(s16 *data, bool8 xExact, bool8 yExact) // B_TRANSITION_FRONTIER_LOGO_WIGGLE //----------------------------------- +#define tSinIndex data[4] #define tAmplitude data[5] static bool8 FrontierLogoWiggle_Init(struct Task *task) @@ -4203,7 +4258,7 @@ static bool8 FrontierLogoWiggle_SetGfx(struct Task *task) GetBg0TilesDst(&tilemap, &tileset); LZ77UnCompVram(sFrontierLogo_Tilemap, tilemap); - SetSinWave(gScanlineEffectRegBuffers[0], 0, task->data[4], 0x84, task->tAmplitude, DISPLAY_HEIGHT); + SetSinWave(gScanlineEffectRegBuffers[0], 0, task->tSinIndex, 132, task->tAmplitude, DISPLAY_HEIGHT); task->tState++; return TRUE; @@ -4214,6 +4269,7 @@ static void Task_FrontierLogoWiggle(u8 taskId) while (sFrontierLogoWiggle_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } +#undef tSinIndex #undef tAmplitude //--------------------------------- @@ -4270,7 +4326,7 @@ static bool8 FrontierLogoWave_SetGfx(struct Task *task) return TRUE; } -static bool8 FrontierLogoWave_Func3(struct Task *task) +static bool8 FrontierLogoWave_InitScanline(struct Task *task) { u8 i; @@ -4285,7 +4341,7 @@ static bool8 FrontierLogoWave_Func3(struct Task *task) return TRUE; } -static bool8 FrontierLogoWave_Func4(struct Task *task) +static bool8 FrontierLogoWave_Main(struct Task *task) { u8 i; u16 sinVal, amplitude, sinSpread; @@ -4300,8 +4356,8 @@ static bool8 FrontierLogoWave_Func4(struct Task *task) if (task->tTimer >= 70) { - // Decrease amount logo moves up and down - // until it rests in the middle of the screen. + // Decrease amount of logo movement and distortion + // until it rests normally in the middle of the screen. if (task->tAmplitudeVal - 384 >= 0) task->tAmplitudeVal -= 384; else @@ -4319,7 +4375,7 @@ static bool8 FrontierLogoWave_Func4(struct Task *task) sTransitionData->BLDALPHA = BLDALPHA_BLEND(task->tBlendTarget2, task->tBlendTarget1); } - // Move logo up and down + // Move logo up and down and distort it for (i = 0; i < DISPLAY_HEIGHT; i++, sinVal += sinSpread) { s16 index = sinVal / 256; @@ -4369,10 +4425,6 @@ static void HBlankCB_FrontierLogoWave(void) // and B_TRANSITION_FRONTIER_SQUARES_SPIRAL //---------------------------------------------------------------------- -#define NUM_SQUARES_PER_ROW 7 -#define NUM_SQUARES_PER_COL 5 -#define SQUARE_SIZE 4 - #define tPosX data[2] #define tPosY data[3] #define tRowPos data[4] @@ -4402,13 +4454,13 @@ static bool8 FrontierSquares_Init(struct Task *task) GetBg0TilesDst(&tilemap, &tileset); LZ77UnCompVram(sFrontierSquares_FilledBg_Tileset, tileset); - FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 0x20, 0x20); - FillBgTilemapBufferRect(0, 1, 0, 0, 1, 0x20, 0xF); - FillBgTilemapBufferRect(0, 1, 0x1D, 0, 1, 0x20, 0xF); + FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 32, 32); + FillBgTilemapBufferRect(0, 1, 0, 0, MARGIN_SIZE, 32, 15); + FillBgTilemapBufferRect(0, 1, 30 - MARGIN_SIZE, 0, MARGIN_SIZE, 32, 15); CopyBgTilemapBufferToVram(0); LoadPalette(sFrontierSquares_Palette, 0xF0, sizeof(sFrontierSquares_Palette)); - task->tPosX = 1; + task->tPosX = MARGIN_SIZE; task->tPosY = 0; task->tRowPos = 0; task->tShrinkDelay = 10; @@ -4429,7 +4481,7 @@ static bool8 FrontierSquares_Draw(struct Task *task) task->tPosX += SQUARE_SIZE; if (++task->tRowPos == NUM_SQUARES_PER_ROW) { - task->tPosX = 1; + task->tPosX = MARGIN_SIZE; task->tPosY += SQUARE_SIZE; task->tRowPos = 0; if (task->tPosY >= NUM_SQUARES_PER_COL * SQUARE_SIZE) @@ -4452,8 +4504,8 @@ static bool8 FrontierSquares_Shrink(struct Task *task) case 0: for (i = 250; i < 255; i++) { - gPlttBufferUnfaded[i] = 0; - gPlttBufferFaded[i] = 0; + gPlttBufferUnfaded[i] = RGB_BLACK; + gPlttBufferFaded[i] = RGB_BLACK; } break; case 1: @@ -4467,7 +4519,7 @@ static bool8 FrontierSquares_Shrink(struct Task *task) LZ77UnCompVram(sFrontierSquares_Shrink2_Tileset, tileset); break; default: - FillBgTilemapBufferRect_Palette0(0, 1, 0, 0, 0x20, 0x20); + FillBgTilemapBufferRect_Palette0(0, 1, 0, 0, 32, 32); CopyBgTilemapBufferToVram(0); task->tState++; return FALSE; @@ -4487,6 +4539,9 @@ static bool8 FrontierSquares_Shrink(struct Task *task) #undef tShrinkDelayTimer #undef tShrinkDelay +#define tSquareNum data[2] +#define tFadeFlag data[3] + static bool8 FrontierSquaresSpiral_Init(struct Task *task) { u16 *tilemap, *tileset; @@ -4494,83 +4549,81 @@ static bool8 FrontierSquaresSpiral_Init(struct Task *task) GetBg0TilesDst(&tilemap, &tileset); LZ77UnCompVram(sFrontierSquares_FilledBg_Tileset, tileset); - FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 0x20, 0x20); - FillBgTilemapBufferRect(0, 1, 0, 0, 1, 0x20, 0xF); - FillBgTilemapBufferRect(0, 1, 0x1D, 0, 1, 0x20, 0xF); + FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 32, 32); + FillBgTilemapBufferRect(0, 1, 0, 0, MARGIN_SIZE, 32, 15); + FillBgTilemapBufferRect(0, 1, 30 - MARGIN_SIZE, 0, MARGIN_SIZE, 32, 15); CopyBgTilemapBufferToVram(0); LoadPalette(sFrontierSquares_Palette, 0xE0, sizeof(sFrontierSquares_Palette)); LoadPalette(sFrontierSquares_Palette, 0xF0, sizeof(sFrontierSquares_Palette)); - BlendPalette(0xE0, 16, 8, 0); + BlendPalette(0xE0, 16, 8, RGB_BLACK); - task->data[2] = 34; - task->data[3] = 0; + task->tSquareNum = NUM_SQUARES - 1; + task->tFadeFlag = 0; task->tState++; return FALSE; } -static bool8 FrontierSquaresSpiral_Func2(struct Task *task) +static bool8 FrontierSquaresSpiral_Outward(struct Task *task) { - u8 var = gUnknown_085C9A30[task->data[2]]; - u8 varMod = var % 7; - u8 varDiv = var / 7; - CopyRectToBgTilemapBufferRect(0, &sFrontierSquares_Tilemap, 0, 0, 4, 4, 4 * varMod + 1, 4 * varDiv, 4, 4, 0xF, 0, 0); + u8 pos = sFrontierSquaresSpiral_Positions[task->tSquareNum]; + u8 x = pos % NUM_SQUARES_PER_ROW; + u8 y = pos / NUM_SQUARES_PER_ROW; + CopyRectToBgTilemapBufferRect(0, sFrontierSquares_Tilemap, 0, 0, + SQUARE_SIZE, SQUARE_SIZE, + SQUARE_SIZE * x + MARGIN_SIZE, SQUARE_SIZE * y, + SQUARE_SIZE, SQUARE_SIZE, + 15, 0, 0); CopyBgTilemapBufferToVram(0); - if (--task->data[2] < 0) + if (--task->tSquareNum < 0) task->tState++; return FALSE; } -static bool8 FrontierSquaresSpiral_Func3(struct Task *task) +// Now that the overworld is completely covered by the squares, +// set it to black so it's not revealed when the squares are removed. +static bool8 FrontierSquaresSpiral_SetBlack(struct Task *task) { - BlendPalette(0xE0, 16, 3, 0); + BlendPalette(0xE0, 16, 3, RGB_BLACK); BlendPalettes(PALETTES_ALL & ~(1 << 15 | 1 << 14), 16, RGB_BLACK); - task->data[2] = 0; - task->data[3] = 0; + task->tSquareNum = 0; + task->tFadeFlag = 0; task->tState++; return FALSE; } -static bool8 FrontierSquaresSpiral_Func4(struct Task *task) +// Spiral inward erasing the squares +static bool8 FrontierSquaresSpiral_Inward(struct Task *task) { - if ((task->data[3] ^= 1)) + // Each square is faded first, then the one that was faded last move is erased. + if (task->tFadeFlag ^= 1) { - CopyRectToBgTilemapBufferRect( - 0, - sFrontierSquares_Tilemap, - 0, - 0, - 4, - 4, - 4 * (gUnknown_085C9A30[task->data[2]] % 7) + 1, - 4 * (gUnknown_085C9A30[task->data[2]] / 7), - 4, - 4, - 0xE, - 0, - 0); + // Shade square + CopyRectToBgTilemapBufferRect(0, sFrontierSquares_Tilemap, 0, 0, + SQUARE_SIZE, SQUARE_SIZE, + SQUARE_SIZE * (sFrontierSquaresSpiral_Positions[task->tSquareNum] % NUM_SQUARES_PER_ROW) + MARGIN_SIZE, + SQUARE_SIZE * (sFrontierSquaresSpiral_Positions[task->tSquareNum] / NUM_SQUARES_PER_ROW), + SQUARE_SIZE, SQUARE_SIZE, + 14, 0, 0); } else { - if (task->data[2] > 0) + if (task->tSquareNum > 0) { - FillBgTilemapBufferRect( - 0, - 1, - 4 * (gUnknown_085C9A30[task->data[2] - 1] % 7) + 1, - 4 * (gUnknown_085C9A30[task->data[2] - 1] / 7), - 4, - 4, - 0xF); + // Erase square + FillBgTilemapBufferRect(0, 1, + SQUARE_SIZE * (sFrontierSquaresSpiral_Positions[task->tSquareNum - 1] % NUM_SQUARES_PER_ROW) + MARGIN_SIZE, + SQUARE_SIZE * (sFrontierSquaresSpiral_Positions[task->tSquareNum - 1] / NUM_SQUARES_PER_ROW), + SQUARE_SIZE, SQUARE_SIZE, + 15); } - - task->data[2]++; + task->tSquareNum++; } - if (task->data[2] > 34) + if (task->tSquareNum >= NUM_SQUARES) task->tState++; CopyBgTilemapBufferToVram(0); @@ -4579,26 +4632,30 @@ static bool8 FrontierSquaresSpiral_Func4(struct Task *task) static bool8 FrontierSquares_End(struct Task *task) { - FillBgTilemapBufferRect_Palette0(0, 1, 0, 0, 0x20, 0x20); + FillBgTilemapBufferRect_Palette0(0, 1, 0, 0, 32, 32); CopyBgTilemapBufferToVram(0); BlendPalettes(PALETTES_ALL, 16, RGB_BLACK); DestroyTask(FindTaskIdByFunc(task->func)); return FALSE; } -// sub task for phase2 32 -#define tSub32_X_delta data[0] -#define tSub32_Y_delta data[1] -#define tSub32_Bool data[2] +#undef tSquareNum +#undef tFadeFlag + +#define tScrollXDir data[0] +#define tScrollYDir data[1] +#define tScrollUpdateFlag data[2] -static void sub_814ABE4(u8 taskId) +#define tSquareNum data[2] + +static void Task_ScrollBg(u8 taskId) { - if (!(gTasks[taskId].tSub32_Bool ^= 1)) + if (!(gTasks[taskId].tScrollUpdateFlag ^= 1)) { SetGpuReg(REG_OFFSET_BG0VOFS, gBattle_BG0_X); SetGpuReg(REG_OFFSET_BG0HOFS, gBattle_BG0_Y); - gBattle_BG0_X += gTasks[taskId].tSub32_X_delta; - gBattle_BG0_Y += gTasks[taskId].tSub32_Y_delta; + gBattle_BG0_X += gTasks[taskId].tScrollXDir; + gBattle_BG0_Y += gTasks[taskId].tScrollYDir; } } @@ -4609,7 +4666,7 @@ static bool8 FrontierSquaresScroll_Init(struct Task *task) GetBg0TilesDst(&tilemap, &tileset); LZ77UnCompVram(sFrontierSquares_FilledBg_Tileset, tileset); - FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 0x20, 0x20); + FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 32, 32); CopyBgTilemapBufferToVram(0); LoadPalette(sFrontierSquares_Palette, 0xF0, sizeof(sFrontierSquares_Palette)); @@ -4618,25 +4675,27 @@ static bool8 FrontierSquaresScroll_Init(struct Task *task) SetGpuReg(REG_OFFSET_BG0VOFS, gBattle_BG0_X); SetGpuReg(REG_OFFSET_BG0HOFS, gBattle_BG0_Y); - task->data[2] = 0; - taskId = CreateTask(sub_814ABE4, 1); + task->tSquareNum = 0; + + // Start scrolling bg in a random direction. + taskId = CreateTask(Task_ScrollBg, 1); switch (Random() % 4) { - case 0: - gTasks[taskId].tSub32_X_delta = 1; - gTasks[taskId].tSub32_Y_delta = 1; + case 0: // Down/right + gTasks[taskId].tScrollXDir = 1; + gTasks[taskId].tScrollYDir = 1; break; - case 1: - gTasks[taskId].tSub32_X_delta = -1; - gTasks[taskId].tSub32_Y_delta = -1; + case 1: // Up/left + gTasks[taskId].tScrollXDir = -1; + gTasks[taskId].tScrollYDir = -1; break; - case 2: - gTasks[taskId].tSub32_X_delta = 1; - gTasks[taskId].tSub32_Y_delta = -1; + case 2: // Up/right + gTasks[taskId].tScrollXDir = 1; + gTasks[taskId].tScrollYDir = -1; break; - default: - gTasks[taskId].tSub32_X_delta = -1; - gTasks[taskId].tSub32_Y_delta = 1; + default: // Down/left + gTasks[taskId].tScrollXDir = -1; + gTasks[taskId].tScrollYDir = 1; break; } @@ -4644,65 +4703,57 @@ static bool8 FrontierSquaresScroll_Init(struct Task *task) return FALSE; } -static bool8 FrontierSquaresScroll_Func2(struct Task *task) -{ - u8 var = gUnknown_085C9A53[task->data[2]]; - u8 varDiv = var / 8; - u8 varAnd = var & 7; - - CopyRectToBgTilemapBufferRect( - 0, - &sFrontierSquares_Tilemap, - 0, - 0, - 4, - 4, - 4 * varDiv + 1, - 4 * varAnd, - 4, - 4, - 0xF, - 0, - 0); +static bool8 FrontierSquaresScroll_Draw(struct Task *task) +{ + u8 pos = sFrontierSquaresScroll_Positions[task->tSquareNum]; + u8 x = pos / (NUM_SQUARES_PER_ROW + 1); // +1 because during scroll an additional column covers the margin. + u8 y = pos % (NUM_SQUARES_PER_ROW + 1); + + CopyRectToBgTilemapBufferRect(0, &sFrontierSquares_Tilemap, 0, 0, + SQUARE_SIZE, SQUARE_SIZE, + SQUARE_SIZE * x + MARGIN_SIZE, SQUARE_SIZE * y, + SQUARE_SIZE, SQUARE_SIZE, + 15, 0, 0); CopyBgTilemapBufferToVram(0); - if (++task->data[2] > 63) + if (++task->tSquareNum >= (int)ARRAY_COUNT(sFrontierSquaresScroll_Positions)) task->tState++; return 0; } -static bool8 FrontierSquaresScroll_Func3(struct Task *task) +// Now that the overworld is completely covered by the squares, +// set it to black so it's not revealed when the squares are removed. +static bool8 FrontierSquaresScroll_SetBlack(struct Task *task) { BlendPalettes(PALETTES_ALL & ~(1 << 15), 16, RGB_BLACK); - task->data[2] = 0; + task->tSquareNum = 0; task->tState++; return FALSE; } -static bool8 FrontierSquaresScroll_Func4(struct Task *task) +static bool8 FrontierSquaresScroll_Erase(struct Task *task) { - u8 var = gUnknown_085C9A53[task->data[2]]; - u8 varDiv = var / 8; - u8 varAnd = var % 8; + u8 pos = sFrontierSquaresScroll_Positions[task->tSquareNum]; + u8 x = pos / (NUM_SQUARES_PER_ROW + 1); + u8 y = pos % (NUM_SQUARES_PER_ROW + 1); - FillBgTilemapBufferRect(0, 1, 4 * varDiv + 1, 4 * varAnd, 4, 4, 0xF); + FillBgTilemapBufferRect(0, 1, + SQUARE_SIZE * x + MARGIN_SIZE, SQUARE_SIZE * y, + SQUARE_SIZE, SQUARE_SIZE, + 15); CopyBgTilemapBufferToVram(0); - if (++task->data[2] > 63) + if (++task->tSquareNum >= (int)ARRAY_COUNT(sFrontierSquaresScroll_Positions)) { - DestroyTask(FindTaskIdByFunc(sub_814ABE4)); + DestroyTask(FindTaskIdByFunc(Task_ScrollBg)); task->tState++; } return FALSE; } -#undef tSub32_X_delta -#undef tSub32_Y_delta -#undef tSub32_Bool - static bool8 FrontierSquaresScroll_End(struct Task *task) { gBattle_BG0_X = 0; @@ -4710,7 +4761,7 @@ static bool8 FrontierSquaresScroll_End(struct Task *task) SetGpuReg(REG_OFFSET_BG0VOFS, 0); SetGpuReg(REG_OFFSET_BG0HOFS, gBattle_BG0_Y); - FillBgTilemapBufferRect_Palette0(0, 1, 0, 0, 0x20, 0x20); + FillBgTilemapBufferRect_Palette0(0, 1, 0, 0, 32, 32); CopyBgTilemapBufferToVram(0); BlendPalettes(PALETTES_ALL, 16, RGB_BLACK); @@ -4721,3 +4772,8 @@ static bool8 FrontierSquaresScroll_End(struct Task *task) #endif return FALSE; } + +#undef tScrollXDir +#undef tScrollYDir +#undef tScrollUpdateFlag +#undef tSquareNum -- cgit v1.2.3 From 886551f655ee0651b47ad81e55404059f3e2673b Mon Sep 17 00:00:00 2001 From: GriffinR Date: Fri, 29 Oct 2021 18:43:27 -0400 Subject: Clean up battle transition doc --- src/battle_transition.c | 352 ++++++++++++++++++++++++------------------------ 1 file changed, 174 insertions(+), 178 deletions(-) (limited to 'src/battle_transition.c') diff --git a/src/battle_transition.c b/src/battle_transition.c index 6aa388302..1e421b5e4 100644 --- a/src/battle_transition.c +++ b/src/battle_transition.c @@ -87,48 +87,48 @@ struct RectangularSpiralLine typedef bool8 (*TransitionStateFunc)(struct Task *task); typedef bool8 (*TransitionSpriteCallback)(struct Sprite *sprite); -static bool8 Transition_StartIntro(struct Task *task); -static bool8 Transition_WaitForIntro(struct Task *task); -static bool8 Transition_StartMain(struct Task *task); -static bool8 Transition_WaitForMain(struct Task *task); - -static void LaunchBattleTransitionTask(u8 transitionId); -static void Task_BattleTransition(u8 taskId); -static void Task_Intro(u8 taskId); -static void Task_Blur(u8 taskId); -static void Task_Swirl(u8 taskId); -static void Task_Shuffle(u8 taskId); -static void Task_BigPokeball(u8 taskId); -static void Task_PokeballsTrail(u8 taskId); -static void Task_ClockwiseWipe(u8 taskId); -static void Task_Ripple(u8 taskId); -static void Task_Wave(u8 taskId); -static void Task_Slice(u8 taskId); -static void Task_WhiteBarsFade(u8 taskId); -static void Task_GridSquares(u8 taskId); -static void Task_AngledWipes(u8 taskId); -static void Task_Sidney(u8 taskId); -static void Task_Phoebe(u8 taskId); -static void Task_Glacia(u8 taskId); -static void Task_Drake(u8 taskId); -static void Task_Champion(u8 taskId); -static void Task_Aqua(u8 taskId); -static void Task_Magma(u8 taskId); -static void Task_Regice(u8 taskId); -static void Task_Registeel(u8 taskId); -static void Task_Regirock(u8 taskId); -static void Task_Kyogre(u8 taskId); -static void Task_Groudon(u8 taskId); -static void Task_Rayquaza(u8 taskId); -static void Task_ShredSplit(u8 taskId); -static void Task_Blackhole(u8 taskId); -static void Task_BlackholePulsate(u8 taskId); -static void Task_RectangularSpiral(u8 taskId); -static void Task_FrontierLogoWiggle(u8 taskId); -static void Task_FrontierLogoWave(u8 taskId); -static void Task_FrontierSquares(u8 taskId); -static void Task_FrontierSquaresScroll(u8 taskId); -static void Task_FrontierSquaresSpiral(u8 taskId); +static bool8 Transition_StartIntro(struct Task *); +static bool8 Transition_WaitForIntro(struct Task *); +static bool8 Transition_StartMain(struct Task *); +static bool8 Transition_WaitForMain(struct Task *); + +static void LaunchBattleTransitionTask(u8); +static void Task_BattleTransition(u8); +static void Task_Intro(u8); +static void Task_Blur(u8); +static void Task_Swirl(u8); +static void Task_Shuffle(u8); +static void Task_BigPokeball(u8); +static void Task_PokeballsTrail(u8); +static void Task_ClockwiseWipe(u8); +static void Task_Ripple(u8); +static void Task_Wave(u8); +static void Task_Slice(u8); +static void Task_WhiteBarsFade(u8); +static void Task_GridSquares(u8); +static void Task_AngledWipes(u8); +static void Task_Sidney(u8); +static void Task_Phoebe(u8); +static void Task_Glacia(u8); +static void Task_Drake(u8); +static void Task_Champion(u8); +static void Task_Aqua(u8); +static void Task_Magma(u8); +static void Task_Regice(u8); +static void Task_Registeel(u8); +static void Task_Regirock(u8); +static void Task_Kyogre(u8); +static void Task_Groudon(u8); +static void Task_Rayquaza(u8); +static void Task_ShredSplit(u8); +static void Task_Blackhole(u8); +static void Task_BlackholePulsate(u8); +static void Task_RectangularSpiral(u8); +static void Task_FrontierLogoWiggle(u8); +static void Task_FrontierLogoWave(u8); +static void Task_FrontierSquares(u8); +static void Task_FrontierSquaresScroll(u8); +static void Task_FrontierSquaresSpiral(u8); static void VBlankCB_BattleTransition(void); static void VBlankCB_Swirl(void); static void HBlankCB_Swirl(void); @@ -149,144 +149,144 @@ static void VBlankCB_WhiteBarsFade_Blend(void); static void HBlankCB_WhiteBarsFade(void); static void VBlankCB_AngledWipes(void); static void VBlankCB_Rayquaza(void); -static bool8 Blur_Init(struct Task *task); -static bool8 Blur_Main(struct Task *task); -static bool8 Blur_End(struct Task *task); -static bool8 Swirl_Init(struct Task *task); -static bool8 Swirl_End(struct Task *task); -static bool8 Shuffle_Init(struct Task *task); -static bool8 Shuffle_End(struct Task *task); -static bool8 Aqua_Init(struct Task *task); -static bool8 Aqua_SetGfx(struct Task *task); -static bool8 Magma_Init(struct Task *task); -static bool8 Magma_SetGfx(struct Task *task); -static bool8 FramesCountdown(struct Task *task); -static bool8 Regi_Init(struct Task *task); -static bool8 Regice_SetGfx(struct Task *task); -static bool8 Registeel_SetGfx(struct Task *task); -static bool8 Regirock_SetGfx(struct Task *task); -static bool8 WeatherTrio_BgFadeBlack(struct Task *task); -static bool8 WeatherTrio_WaitFade(struct Task *task); -static bool8 Kyogre_Init(struct Task *task); -static bool8 Kyogre_PaletteFlash(struct Task *task); -static bool8 Kyogre_PaletteBrighten(struct Task *task); -static bool8 Groudon_Init(struct Task *task); -static bool8 Groudon_PaletteFlash(struct Task *task); -static bool8 Groudon_PaletteBrighten(struct Task *task); -static bool8 WeatherDuo_FadeOut(struct Task *task); -static bool8 WeatherDuo_End(struct Task *task); -static bool8 BigPokeball_Init(struct Task *task); -static bool8 BigPokeball_SetGfx(struct Task *task); -static bool8 PatternWeave_Blend1(struct Task *task); -static bool8 PatternWeave_Blend2(struct Task *task); -static bool8 PatternWeave_FinishAppear(struct Task *task); -static bool8 PatternWeave_CircularMask(struct Task *task); -static bool8 PokeballsTrail_Init(struct Task *task); -static bool8 PokeballsTrail_Main(struct Task *task); -static bool8 PokeballsTrail_End(struct Task *task); -static bool8 ClockwiseWipe_Init(struct Task *task); -static bool8 ClockwiseWipe_TopRight(struct Task *task); -static bool8 ClockwiseWipe_Right(struct Task *task); -static bool8 ClockwiseWipe_Bottom(struct Task *task); -static bool8 ClockwiseWipe_Left(struct Task *task); -static bool8 ClockwiseWipe_TopLeft(struct Task *task); -static bool8 ClockwiseWipe_End(struct Task *task); -static bool8 Ripple_Init(struct Task *task); -static bool8 Ripple_Main(struct Task *task); -static bool8 Wave_Init(struct Task *task); -static bool8 Wave_Main(struct Task *task); -static bool8 Wave_End(struct Task *task); -static bool8 Slice_Init(struct Task *task); -static bool8 Slice_Main(struct Task *task); -static bool8 Slice_End(struct Task *task); -static bool8 WhiteBarsFade_Init(struct Task *task); -static bool8 WhiteBarsFade_StartBars(struct Task *task); -static bool8 WhiteBarsFade_WaitBars(struct Task *task); -static bool8 WhiteBarsFade_BlendToBlack(struct Task *task); -static bool8 WhiteBarsFade_End(struct Task *task); -static bool8 GridSquares_Init(struct Task *task); -static bool8 GridSquares_Main(struct Task *task); -static bool8 GridSquares_End(struct Task *task); -static bool8 AngledWipes_Init(struct Task *task); -static bool8 AngledWipes_SetWipeData(struct Task *task); -static bool8 AngledWipes_DoWipe(struct Task *task); -static bool8 AngledWipes_TryEnd(struct Task *task); -static bool8 AngledWipes_StartNext(struct Task *task); -static bool8 ShredSplit_Init(struct Task *task); -static bool8 ShredSplit_Main(struct Task *task); -static bool8 ShredSplit_BrokenCheck(struct Task *task); -static bool8 ShredSplit_End(struct Task *task); -static bool8 Blackhole_Init(struct Task *task); -static bool8 Blackhole_Vibrate(struct Task *task); -static bool8 Blackhole_GrowEnd(struct Task *task); -static bool8 BlackholePulsate_Main(struct Task *task); -static bool8 RectangularSpiral_Init(struct Task *task); -static bool8 RectangularSpiral_Main(struct Task *task); -static bool8 RectangularSpiral_End(struct Task *task); -static bool8 FrontierLogoWiggle_Init(struct Task *task); -static bool8 FrontierLogoWiggle_SetGfx(struct Task *task); -static bool8 FrontierLogoWave_Init(struct Task *task); -static bool8 FrontierLogoWave_SetGfx(struct Task *task); -static bool8 FrontierLogoWave_InitScanline(struct Task *task); -static bool8 FrontierLogoWave_Main(struct Task *task); -static bool8 Rayquaza_Init(struct Task *task); -static bool8 Rayquaza_SetGfx(struct Task *task); -static bool8 Rayquaza_PaletteFlash(struct Task *task); -static bool8 Rayquaza_FadeToBlack(struct Task *task); -static bool8 Rayquaza_WaitFade(struct Task *task); -static bool8 Rayquaza_SetBlack(struct Task *task); -static bool8 Rayquaza_TriRing(struct Task *task); -static bool8 FrontierSquares_Init(struct Task *task); -static bool8 FrontierSquares_Draw(struct Task *task); -static bool8 FrontierSquares_Shrink(struct Task *task); -static bool8 FrontierSquares_End(struct Task *task); -static bool8 FrontierSquaresSpiral_Init(struct Task *task); -static bool8 FrontierSquaresSpiral_Outward(struct Task *task); -static bool8 FrontierSquaresSpiral_SetBlack(struct Task *task); -static bool8 FrontierSquaresSpiral_Inward(struct Task *task); -static bool8 FrontierSquaresScroll_Init(struct Task *task); -static bool8 FrontierSquaresScroll_Draw(struct Task *task); -static bool8 FrontierSquaresScroll_SetBlack(struct Task *task); -static bool8 FrontierSquaresScroll_Erase(struct Task *task); -static bool8 FrontierSquaresScroll_End(struct Task *task); -static bool8 Mugshot_Init(struct Task *task); -static bool8 Mugshot_SetGfx(struct Task *task); -static bool8 Mugshot_ShowBanner(struct Task *task); -static bool8 Mugshot_StartOpponentSlide(struct Task *task); -static bool8 Mugshot_WaitStartPlayerSlide(struct Task *task); -static bool8 Mugshot_WaitPlayerSlide(struct Task *task); -static bool8 Mugshot_GradualWhiteFade(struct Task *task); -static bool8 Mugshot_InitFadeWhiteToBlack(struct Task *task); -static bool8 Mugshot_FadeToBlack(struct Task *task); -static bool8 Mugshot_End(struct Task *task); -static void DoMugshotTransition(u8 taskId); -static void Mugshots_CreateTrainerPics(struct Task *task); +static bool8 Blur_Init(struct Task *); +static bool8 Blur_Main(struct Task *); +static bool8 Blur_End(struct Task *); +static bool8 Swirl_Init(struct Task *); +static bool8 Swirl_End(struct Task *); +static bool8 Shuffle_Init(struct Task *); +static bool8 Shuffle_End(struct Task *); +static bool8 Aqua_Init(struct Task *); +static bool8 Aqua_SetGfx(struct Task *); +static bool8 Magma_Init(struct Task *); +static bool8 Magma_SetGfx(struct Task *); +static bool8 FramesCountdown(struct Task *); +static bool8 Regi_Init(struct Task *); +static bool8 Regice_SetGfx(struct Task *); +static bool8 Registeel_SetGfx(struct Task *); +static bool8 Regirock_SetGfx(struct Task *); +static bool8 WeatherTrio_BgFadeBlack(struct Task *); +static bool8 WeatherTrio_WaitFade(struct Task *); +static bool8 Kyogre_Init(struct Task *); +static bool8 Kyogre_PaletteFlash(struct Task *); +static bool8 Kyogre_PaletteBrighten(struct Task *); +static bool8 Groudon_Init(struct Task *); +static bool8 Groudon_PaletteFlash(struct Task *); +static bool8 Groudon_PaletteBrighten(struct Task *); +static bool8 WeatherDuo_FadeOut(struct Task *); +static bool8 WeatherDuo_End(struct Task *); +static bool8 BigPokeball_Init(struct Task *); +static bool8 BigPokeball_SetGfx(struct Task *); +static bool8 PatternWeave_Blend1(struct Task *); +static bool8 PatternWeave_Blend2(struct Task *); +static bool8 PatternWeave_FinishAppear(struct Task *); +static bool8 PatternWeave_CircularMask(struct Task *); +static bool8 PokeballsTrail_Init(struct Task *); +static bool8 PokeballsTrail_Main(struct Task *); +static bool8 PokeballsTrail_End(struct Task *); +static bool8 ClockwiseWipe_Init(struct Task *); +static bool8 ClockwiseWipe_TopRight(struct Task *); +static bool8 ClockwiseWipe_Right(struct Task *); +static bool8 ClockwiseWipe_Bottom(struct Task *); +static bool8 ClockwiseWipe_Left(struct Task *); +static bool8 ClockwiseWipe_TopLeft(struct Task *); +static bool8 ClockwiseWipe_End(struct Task *); +static bool8 Ripple_Init(struct Task *); +static bool8 Ripple_Main(struct Task *); +static bool8 Wave_Init(struct Task *); +static bool8 Wave_Main(struct Task *); +static bool8 Wave_End(struct Task *); +static bool8 Slice_Init(struct Task *); +static bool8 Slice_Main(struct Task *); +static bool8 Slice_End(struct Task *); +static bool8 WhiteBarsFade_Init(struct Task *); +static bool8 WhiteBarsFade_StartBars(struct Task *); +static bool8 WhiteBarsFade_WaitBars(struct Task *); +static bool8 WhiteBarsFade_BlendToBlack(struct Task *); +static bool8 WhiteBarsFade_End(struct Task *); +static bool8 GridSquares_Init(struct Task *); +static bool8 GridSquares_Main(struct Task *); +static bool8 GridSquares_End(struct Task *); +static bool8 AngledWipes_Init(struct Task *); +static bool8 AngledWipes_SetWipeData(struct Task *); +static bool8 AngledWipes_DoWipe(struct Task *); +static bool8 AngledWipes_TryEnd(struct Task *); +static bool8 AngledWipes_StartNext(struct Task *); +static bool8 ShredSplit_Init(struct Task *); +static bool8 ShredSplit_Main(struct Task *); +static bool8 ShredSplit_BrokenCheck(struct Task *); +static bool8 ShredSplit_End(struct Task *); +static bool8 Blackhole_Init(struct Task *); +static bool8 Blackhole_Vibrate(struct Task *); +static bool8 Blackhole_GrowEnd(struct Task *); +static bool8 BlackholePulsate_Main(struct Task *); +static bool8 RectangularSpiral_Init(struct Task *); +static bool8 RectangularSpiral_Main(struct Task *); +static bool8 RectangularSpiral_End(struct Task *); +static bool8 FrontierLogoWiggle_Init(struct Task *); +static bool8 FrontierLogoWiggle_SetGfx(struct Task *); +static bool8 FrontierLogoWave_Init(struct Task *); +static bool8 FrontierLogoWave_SetGfx(struct Task *); +static bool8 FrontierLogoWave_InitScanline(struct Task *); +static bool8 FrontierLogoWave_Main(struct Task *); +static bool8 Rayquaza_Init(struct Task *); +static bool8 Rayquaza_SetGfx(struct Task *); +static bool8 Rayquaza_PaletteFlash(struct Task *); +static bool8 Rayquaza_FadeToBlack(struct Task *); +static bool8 Rayquaza_WaitFade(struct Task *); +static bool8 Rayquaza_SetBlack(struct Task *); +static bool8 Rayquaza_TriRing(struct Task *); +static bool8 FrontierSquares_Init(struct Task *); +static bool8 FrontierSquares_Draw(struct Task *); +static bool8 FrontierSquares_Shrink(struct Task *); +static bool8 FrontierSquares_End(struct Task *); +static bool8 FrontierSquaresSpiral_Init(struct Task *); +static bool8 FrontierSquaresSpiral_Outward(struct Task *); +static bool8 FrontierSquaresSpiral_SetBlack(struct Task *); +static bool8 FrontierSquaresSpiral_Inward(struct Task *); +static bool8 FrontierSquaresScroll_Init(struct Task *); +static bool8 FrontierSquaresScroll_Draw(struct Task *); +static bool8 FrontierSquaresScroll_SetBlack(struct Task *); +static bool8 FrontierSquaresScroll_Erase(struct Task *); +static bool8 FrontierSquaresScroll_End(struct Task *); +static bool8 Mugshot_Init(struct Task *); +static bool8 Mugshot_SetGfx(struct Task *); +static bool8 Mugshot_ShowBanner(struct Task *); +static bool8 Mugshot_StartOpponentSlide(struct Task *); +static bool8 Mugshot_WaitStartPlayerSlide(struct Task *); +static bool8 Mugshot_WaitPlayerSlide(struct Task *); +static bool8 Mugshot_GradualWhiteFade(struct Task *); +static bool8 Mugshot_InitFadeWhiteToBlack(struct Task *); +static bool8 Mugshot_FadeToBlack(struct Task *); +static bool8 Mugshot_End(struct Task *); +static void DoMugshotTransition(u8); +static void Mugshots_CreateTrainerPics(struct Task *); static void VBlankCB_Mugshots(void); static void VBlankCB_MugshotsFadeOut(void); static void HBlankCB_Mugshots(void); static void InitTransitionData(void); static void FadeScreenBlack(void); -static void CreateIntroTask(s16 a0, s16 a1, s16 a2, s16 a3, s16 a4); -static void SetCircularMask(u16 *a0, s16 a1, s16 a2, s16 a3); -static void SetSinWave(s16 *array, s16 sinAdd, s16 index, s16 indexIncrementer, s16 amplitude, s16 arrSize); -static void GetBg0TilemapDst(u16 **tileset); -static void InitBlackWipe(s16 *a0, s16 a1, s16 a2, s16 a3, s16 a4, s16 a5, s16 a6); -static bool8 UpdateBlackWipe(s16 *a0, bool8 a1, bool8 a2); -static void SetTrainerPicSlideDirection(s16 spriteId, s16 arrId); -static void IncrementTrainerPicState(s16 spriteId); -static s16 IsTrainerPicSlideDone(s16 spriteId); -static bool8 TransitionIntro_FadeToGray(struct Task *task); -static bool8 TransitionIntro_FadeFromGray(struct Task *task); +static void CreateIntroTask(s16, s16, s16, s16, s16); +static void SetCircularMask(u16 *, s16, s16, s16); +static void SetSinWave(s16 *, s16, s16, s16, s16, s16); +static void GetBg0TilemapDst(u16 **); +static void InitBlackWipe(s16 *, s16, s16, s16, s16, s16, s16); +static bool8 UpdateBlackWipe(s16 *, bool8, bool8); +static void SetTrainerPicSlideDirection(s16, s16); +static void IncrementTrainerPicState(s16); +static s16 IsTrainerPicSlideDone(s16); +static bool8 TransitionIntro_FadeToGray(struct Task *); +static bool8 TransitionIntro_FadeFromGray(struct Task *); static bool8 IsIntroTaskDone(void); -static bool16 UpdateRectangularSpiralLine(const s16 * const *arg0, struct RectangularSpiralLine *arg1); -static void SpriteCB_FldEffPokeballTrail(struct Sprite *sprite); -static void SpriteCB_MugshotTrainerPic(struct Sprite *sprite); -static void SpriteCB_WhiteBarFade(struct Sprite *sprite); -static bool8 MugshotTrainerPic_Pause(struct Sprite *sprite); -static bool8 MugshotTrainerPic_Init(struct Sprite *sprite); -static bool8 MugshotTrainerPic_Slide(struct Sprite *sprite); -static bool8 MugshotTrainerPic_SlideSlow(struct Sprite *sprite); -static bool8 MugshotTrainerPic_SlideOffscreen(struct Sprite *sprite); +static bool16 UpdateRectangularSpiralLine(const s16 * const *, struct RectangularSpiralLine *); +static void SpriteCB_FldEffPokeballTrail(struct Sprite *); +static void SpriteCB_MugshotTrainerPic(struct Sprite *); +static void SpriteCB_WhiteBarFade(struct Sprite *); +static bool8 MugshotTrainerPic_Pause(struct Sprite *); +static bool8 MugshotTrainerPic_Init(struct Sprite *); +static bool8 MugshotTrainerPic_Slide(struct Sprite *); +static bool8 MugshotTrainerPic_SlideSlow(struct Sprite *); +static bool8 MugshotTrainerPic_SlideOffscreen(struct Sprite *); static s16 sDebug_RectangularSpiralData; static u8 sTestingTransitionId; @@ -959,10 +959,6 @@ static const TransitionStateFunc sFrontierSquaresScroll_Funcs[] = FrontierSquaresScroll_End }; -// Dimensions for the 2 non-scrolling frontier square transitions. -// SQUARE_SIZE is the same in the scrolling version but it uses -// more because it needs to show more than can be shown at a single -// time n-screen. #define SQUARE_SIZE 4 #define MARGIN_SIZE 1 // Squares do not fit evenly across the width, so there is a margin on either side. #define NUM_SQUARES_PER_ROW ((DISPLAY_WIDTH - (MARGIN_SIZE * 8 * 2)) / (SQUARE_SIZE * 8)) -- cgit v1.2.3