summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGriffinR <griffin.g.richards@gmail.com>2021-10-25 10:42:08 -0400
committerGriffinR <griffin.g.richards@gmail.com>2021-10-26 01:39:28 -0400
commit1056209d8e62770bac18cb6a4bc34ce96db30f12 (patch)
treee9e62438afbba5230d9c97e725a182f857b36e25 /src
parenta612c27f2ded23f713b2199764b65c6b8b4aaf9d (diff)
Start battle_transition documenting
Diffstat (limited to 'src')
-rw-r--r--src/battle_setup.c39
-rw-r--r--src/battle_transition.c2327
2 files changed, 1201 insertions, 1165 deletions
diff --git a/src/battle_setup.c b/src/battle_setup.c
index 2a716e08c..6a4afe746 100644
--- a/src/battle_setup.c
+++ b/src/battle_setup.c
@@ -47,8 +47,14 @@
#include "constants/trainers.h"
#include "constants/trainer_hill.h"
-enum
-{
+enum {
+ TRANSITION_TYPE_NORMAL,
+ TRANSITION_TYPE_CAVE,
+ TRANSITION_TYPE_FLASH,
+ TRANSITION_TYPE_WATER,
+};
+
+enum {
TRAINER_PARAM_LOAD_VAL_8BIT,
TRAINER_PARAM_LOAD_VAL_16BIT,
TRAINER_PARAM_LOAD_VAL_32BIT,
@@ -85,7 +91,6 @@ static void HandleRematchVarsOnBattleEnd(void);
static const u8 *GetIntroSpeechOfApproachingTrainer(void);
static const u8 *GetTrainerCantBattleSpeech(void);
-// ewram vars
EWRAM_DATA static u16 sTrainerBattleMode = 0;
EWRAM_DATA u16 gTrainerBattleOpponent_A = 0;
EWRAM_DATA u16 gTrainerBattleOpponent_B = 0;
@@ -103,24 +108,22 @@ EWRAM_DATA static u8 *sTrainerBBattleScriptRetAddr = NULL;
EWRAM_DATA static bool8 sShouldCheckTrainerBScript = FALSE;
EWRAM_DATA static u8 sNoOfPossibleTrainerRetScripts = 0;
-// const rom data
-
// The first transition is used if the enemy pokemon are lower level than our pokemon.
// Otherwise, the second transition is used.
static const u8 sBattleTransitionTable_Wild[][2] =
{
- {B_TRANSITION_SLICE, B_TRANSITION_WHITEFADE}, // Normal
- {B_TRANSITION_CLOCKWISE_BLACKFADE, B_TRANSITION_GRID_SQUARES}, // Cave
- {B_TRANSITION_BLUR, B_TRANSITION_GRID_SQUARES}, // Cave with flash used
- {B_TRANSITION_WAVE, B_TRANSITION_RIPPLE}, // Water
+ [TRANSITION_TYPE_NORMAL] = {B_TRANSITION_SLICE, B_TRANSITION_WHITEFADE},
+ [TRANSITION_TYPE_CAVE] = {B_TRANSITION_CLOCKWISE_BLACKFADE, B_TRANSITION_GRID_SQUARES},
+ [TRANSITION_TYPE_FLASH] = {B_TRANSITION_BLUR, B_TRANSITION_GRID_SQUARES},
+ [TRANSITION_TYPE_WATER] = {B_TRANSITION_WAVE, B_TRANSITION_RIPPLE},
};
static const u8 sBattleTransitionTable_Trainer[][2] =
{
- {B_TRANSITION_POKEBALLS_TRAIL, B_TRANSITION_SHARDS}, // Normal
- {B_TRANSITION_SHUFFLE, B_TRANSITION_BIG_POKEBALL}, // Cave
- {B_TRANSITION_BLUR, B_TRANSITION_GRID_SQUARES}, // Cave with flash used
- {B_TRANSITION_SWIRL, B_TRANSITION_RIPPLE}, // Water
+ [TRANSITION_TYPE_NORMAL] = {B_TRANSITION_POKEBALLS_TRAIL, B_TRANSITION_SHARDS},
+ [TRANSITION_TYPE_CAVE] = {B_TRANSITION_SHUFFLE, B_TRANSITION_BIG_POKEBALL},
+ [TRANSITION_TYPE_FLASH] = {B_TRANSITION_BLUR, B_TRANSITION_GRID_SQUARES},
+ [TRANSITION_TYPE_WATER] = {B_TRANSITION_SWIRL, B_TRANSITION_RIPPLE},
};
// Battle Frontier (excluding Pyramid and Dome, which have their own tables below)
@@ -697,20 +700,20 @@ static u8 GetBattleTransitionTypeByMap(void)
PlayerGetDestCoords(&x, &y);
tileBehavior = MapGridGetMetatileBehaviorAt(x, y);
if (Overworld_GetFlashLevel())
- return B_TRANSITION_SHUFFLE;
+ return TRANSITION_TYPE_FLASH;
if (!MetatileBehavior_IsSurfableWaterOrUnderwater(tileBehavior))
{
switch (gMapHeader.mapType)
{
case MAP_TYPE_UNDERGROUND:
- return B_TRANSITION_SWIRL;
+ return TRANSITION_TYPE_CAVE;
case MAP_TYPE_UNDERWATER:
- return B_TRANSITION_BIG_POKEBALL;
+ return TRANSITION_TYPE_WATER;
default:
- return B_TRANSITION_BLUR;
+ return TRANSITION_TYPE_NORMAL;
}
}
- return B_TRANSITION_BIG_POKEBALL;
+ return TRANSITION_TYPE_WATER;
}
static u16 GetSumOfPlayerPartyLevel(u8 numMons)
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], &REG_BG0HOFS, 0xA2400001);
+ DmaSet(0, gScanlineEffectRegBuffers[1], &REG_BG0HOFS, B_TRANS_DMA_FLAGS);
}
static void VBlankCB1_BigPokeball(void)
{
Transition_BigPokeball_Vblank();
- DmaSet(0, gScanlineEffectRegBuffers[1], &REG_WIN0H, 0xA2400001);
+ DmaSet(0, gScanlineEffectRegBuffers[1], &REG_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], &REG_WIN0H, 0xA2400001);
+ DmaSet(0, gScanlineEffectRegBuffers[1], &REG_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], &REG_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], &REG_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], &REG_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], &REG_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], &REG_BLDY, 0xA2400001);
+ if (sTransitionData->VBlank_DMA != 0)
+ DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], DISPLAY_HEIGHT * 2);
+ REG_BLDCNT = sTransitionData->BLDCNT;
+ DmaSet(0, gScanlineEffectRegBuffers[1], &REG_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], &REG_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], &REG_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, &REG_BG0VOFS, 0xA2400001);
+ DmaSet(0, dmaSrc, &REG_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], &REG_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], &REG_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], &REG_WIN0H, 0xA2400001);
+ DmaSet(0, gScanlineEffectRegBuffers[1], &REG_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