diff options
author | Evan <eroelke@gmail.com> | 2019-12-02 15:49:22 -0700 |
---|---|---|
committer | Evan <eroelke@gmail.com> | 2019-12-02 15:49:22 -0700 |
commit | f475600b4c058236fac6790446b98a4d1d6d6fb2 (patch) | |
tree | 366beaba617ffdc915787b6b12446e5859a39f2f /src | |
parent | 4454ef35e861cf18ce6e43033f551538366bfb51 (diff) |
init battle_anim_special
Diffstat (limited to 'src')
-rw-r--r-- | src/battle_anim_effects_3.c | 282 | ||||
-rw-r--r-- | src/battle_anim_special.c | 2296 |
2 files changed, 2440 insertions, 138 deletions
diff --git a/src/battle_anim_effects_3.c b/src/battle_anim_effects_3.c index 89f66139f..4fd6ada0b 100644 --- a/src/battle_anim_effects_3.c +++ b/src/battle_anim_effects_3.c @@ -120,7 +120,9 @@ static void MoveOdorSleuthClone(struct Sprite *); static void AnimTask_TeeterDanceMovementStep(u8); static void AnimRecycleStep(struct Sprite *); static void AnimTask_SlackOffSquishStep(u8); -const union AnimCmd gScratchAnimCmds[] = + +// Data +const union AnimCmd gScratchAnimCmds[] = //83FEDE4 { ANIMCMD_FRAME(0, 4), ANIMCMD_FRAME(16, 4), @@ -130,12 +132,12 @@ const union AnimCmd gScratchAnimCmds[] = ANIMCMD_END, }; -const union AnimCmd *const gScratchAnimTable[] = +const union AnimCmd *const gScratchAnimTable[] = //83FEDFC { gScratchAnimCmds, }; -const struct SpriteTemplate gScratchSpriteTemplate = +const struct SpriteTemplate gScratchSpriteTemplate = //83FEE00 { .tileTag = ANIM_TAG_SCRATCH, .paletteTag = ANIM_TAG_SCRATCH, @@ -146,7 +148,7 @@ const struct SpriteTemplate gScratchSpriteTemplate = .callback = AnimSpriteOnMonPos, }; -const struct SpriteTemplate gBlackSmokeSpriteTemplate = +const struct SpriteTemplate gBlackSmokeSpriteTemplate = //83FEE18 { .tileTag = ANIM_TAG_BLACK_SMOKE, .paletteTag = ANIM_TAG_BLACK_SMOKE, @@ -157,7 +159,7 @@ const struct SpriteTemplate gBlackSmokeSpriteTemplate = .callback = AnimBlackSmoke, }; -const struct SpriteTemplate gBlackBallSpriteTemplate = +const struct SpriteTemplate gBlackBallSpriteTemplate = //83FEE30 { .tileTag = ANIM_TAG_BLACK_BALL, .paletteTag = ANIM_TAG_BLACK_BALL, @@ -168,7 +170,7 @@ const struct SpriteTemplate gBlackBallSpriteTemplate = .callback = AnimThrowProjectile, }; -const union AnimCmd gOpeningEyeAnimCmds[] = +const union AnimCmd gOpeningEyeAnimCmds[] = //83FEE48 { ANIMCMD_FRAME(0, 40), ANIMCMD_FRAME(16, 8), @@ -176,12 +178,12 @@ const union AnimCmd gOpeningEyeAnimCmds[] = ANIMCMD_END, }; -const union AnimCmd *const gOpeningEyeAnimTable[] = +const union AnimCmd *const gOpeningEyeAnimTable[] = //83FEE58 { gOpeningEyeAnimCmds, }; -const struct SpriteTemplate gOpeningEyeSpriteTemplate = +const struct SpriteTemplate gOpeningEyeSpriteTemplate = //83FEE5C { .tileTag = ANIM_TAG_OPENING_EYE, .paletteTag = ANIM_TAG_OPENING_EYE, @@ -192,7 +194,7 @@ const struct SpriteTemplate gOpeningEyeSpriteTemplate = .callback = AnimSpriteOnMonPos, }; -const struct SpriteTemplate gWhiteHaloSpriteTemplate = +const struct SpriteTemplate gWhiteHaloSpriteTemplate = //83FEE74 { .tileTag = ANIM_TAG_ROUND_WHITE_HALO, .paletteTag = ANIM_TAG_ROUND_WHITE_HALO, @@ -203,7 +205,7 @@ const struct SpriteTemplate gWhiteHaloSpriteTemplate = .callback = AnimWhiteHalo, }; -const struct SpriteTemplate gTealAlertSpriteTemplate = +const struct SpriteTemplate gTealAlertSpriteTemplate = //83FEE8C { .tileTag = ANIM_TAG_TEAL_ALERT, .paletteTag = ANIM_TAG_TEAL_ALERT, @@ -214,7 +216,7 @@ const struct SpriteTemplate gTealAlertSpriteTemplate = .callback = AnimTealAlert, }; -const union AffineAnimCmd gMeanLookEyeAffineAnimCmds1[] = +const union AffineAnimCmd gMeanLookEyeAffineAnimCmds1[] = //83FEEA4 { AFFINEANIMCMD_FRAME(0x180, 0x180, 0, 0), AFFINEANIMCMD_FRAME(-0x20, 0x18, 0, 5), @@ -222,20 +224,20 @@ const union AffineAnimCmd gMeanLookEyeAffineAnimCmds1[] = AFFINEANIMCMD_JUMP(1), }; -const union AffineAnimCmd gMeanLookEyeAffineAnimCmds2[] = +const union AffineAnimCmd gMeanLookEyeAffineAnimCmds2[] = //83FEEC4 { AFFINEANIMCMD_FRAME(0x30, 0x30, 0, 0), AFFINEANIMCMD_FRAME(0x20, 0x20, 0, 6), AFFINEANIMCMD_END, }; -const union AffineAnimCmd *const gMeanLookEyeAffineAnimTable[] = +const union AffineAnimCmd *const gMeanLookEyeAffineAnimTable[] = //83FEEDC { gMeanLookEyeAffineAnimCmds1, gMeanLookEyeAffineAnimCmds2, }; -const struct SpriteTemplate gMeanLookEyeSpriteTemplate = +const struct SpriteTemplate gMeanLookEyeSpriteTemplate = //83FEEE4 { .tileTag = ANIM_TAG_EYE, .paletteTag = ANIM_TAG_EYE, @@ -246,7 +248,7 @@ const struct SpriteTemplate gMeanLookEyeSpriteTemplate = .callback = AnimMeanLookEye, }; -const struct SpriteTemplate gSpikesSpriteTemplate = +const struct SpriteTemplate gSpikesSpriteTemplate = //83FEEFC { .tileTag = ANIM_TAG_SPIKES, .paletteTag = ANIM_TAG_SPIKES, @@ -257,7 +259,7 @@ const struct SpriteTemplate gSpikesSpriteTemplate = .callback = AnimSpikes, }; -const union AnimCmd gLeerAnimCmds[] = +const union AnimCmd gLeerAnimCmds[] = //83FEF14 { ANIMCMD_FRAME(0, 3), ANIMCMD_FRAME(16, 3), @@ -267,12 +269,12 @@ const union AnimCmd gLeerAnimCmds[] = ANIMCMD_END, }; -const union AnimCmd *const gLeerAnimTable[] = +const union AnimCmd *const gLeerAnimTable[] = //83FEF2C { gLeerAnimCmds, }; -const struct SpriteTemplate gLeerSpriteTemplate = +const struct SpriteTemplate gLeerSpriteTemplate = //83FEF30 { .tileTag = ANIM_TAG_LEER, .paletteTag = ANIM_TAG_LEER, @@ -283,30 +285,30 @@ const struct SpriteTemplate gLeerSpriteTemplate = .callback = AnimLeer, }; -const union AnimCmd gLetterZAnimCmds[] = +const union AnimCmd gLetterZAnimCmds[] = //83FEF48 { ANIMCMD_FRAME(0, 3), ANIMCMD_END, }; -const union AnimCmd *const gLetterZAnimTable[] = +const union AnimCmd *const gLetterZAnimTable[] = //83FEF50 { gLetterZAnimCmds, }; -const union AffineAnimCmd gLetterZAffineAnimCmds[] = +const union AffineAnimCmd gLetterZAffineAnimCmds[] = //83FEF54 { AFFINEANIMCMD_FRAME(-7, -7, -3, 16), AFFINEANIMCMD_FRAME(7, 7, 3, 16), AFFINEANIMCMD_JUMP(0), }; -const union AffineAnimCmd *const gLetterZAffineAnimTable[] = +const union AffineAnimCmd *const gLetterZAffineAnimTable[] = //83FEF6C { gLetterZAffineAnimCmds, }; -const struct SpriteTemplate gLetterZSpriteTemplate = +const struct SpriteTemplate gLetterZSpriteTemplate = //83FEF70 { .tileTag = ANIM_TAG_LETTER_Z, .paletteTag = ANIM_TAG_LETTER_Z, @@ -317,7 +319,7 @@ const struct SpriteTemplate gLetterZSpriteTemplate = .callback = AnimLetterZ, }; -const union AnimCmd gFangAnimCmds[] = +const union AnimCmd gFangAnimCmds[] = //83FEF88 { ANIMCMD_FRAME(0, 8), ANIMCMD_FRAME(16, 16), @@ -326,24 +328,24 @@ const union AnimCmd gFangAnimCmds[] = ANIMCMD_END, }; -const union AnimCmd *const gFangAnimTable[] = +const union AnimCmd *const gFangAnimTable[] = //83FEF9C { gFangAnimCmds, }; -const union AffineAnimCmd gFangAffineAnimCmds[] = +const union AffineAnimCmd gFangAffineAnimCmds[] = //83FEFA0 { AFFINEANIMCMD_FRAME(0x200, 0x200, 0, 0), AFFINEANIMCMD_FRAME(-0x20, -0x20, 0, 8), AFFINEANIMCMD_END, }; -const union AffineAnimCmd *const gFangAffineAnimTable[] = +const union AffineAnimCmd *const gFangAffineAnimTable[] = //83FEFB8 { gFangAffineAnimCmds, }; -const struct SpriteTemplate gFangSpriteTemplate = +const struct SpriteTemplate gFangSpriteTemplate = //83FEFBC { .tileTag = ANIM_TAG_FANG_ATTACK, .paletteTag = ANIM_TAG_FANG_ATTACK, @@ -354,27 +356,27 @@ const struct SpriteTemplate gFangSpriteTemplate = .callback = AnimFang, }; -const union AffineAnimCmd gSpotlightAffineAnimCmds1[] = +const union AffineAnimCmd gSpotlightAffineAnimCmds1[] = //83FEFD4 { AFFINEANIMCMD_FRAME(0x0, 0x180, 0, 0), AFFINEANIMCMD_FRAME(0x10, 0x0, 0, 20), AFFINEANIMCMD_END, }; -const union AffineAnimCmd gSpotlightAffineAnimCmds2[] = +const union AffineAnimCmd gSpotlightAffineAnimCmds2[] = //83FEFEC { AFFINEANIMCMD_FRAME(0x140, 0x180, 0, 0), AFFINEANIMCMD_FRAME(-0x10, 0x0, 0, 19), AFFINEANIMCMD_END, }; -const union AffineAnimCmd *const gSpotlightAffineAnimTable[] = +const union AffineAnimCmd *const gSpotlightAffineAnimTable[] = //83FF004 { gSpotlightAffineAnimCmds1, gSpotlightAffineAnimCmds2, }; -const struct SpriteTemplate gSpotlightSpriteTemplate = +const struct SpriteTemplate gSpotlightSpriteTemplate = //83FF00C { .tileTag = ANIM_TAG_SPOTLIGHT, .paletteTag = ANIM_TAG_SPOTLIGHT, @@ -385,7 +387,7 @@ const struct SpriteTemplate gSpotlightSpriteTemplate = .callback = AnimSpotlight, }; -const struct SpriteTemplate gClappingHandSpriteTemplate = +const struct SpriteTemplate gClappingHandSpriteTemplate = //83FF024 { .tileTag = ANIM_TAG_TAG_HAND, .paletteTag = ANIM_TAG_TAG_HAND, @@ -396,7 +398,7 @@ const struct SpriteTemplate gClappingHandSpriteTemplate = .callback = AnimClappingHand, }; -const struct SpriteTemplate gClappingHand2SpriteTemplate = +const struct SpriteTemplate gClappingHand2SpriteTemplate = //83FF03C { .tileTag = ANIM_TAG_TAG_HAND, .paletteTag = ANIM_TAG_TAG_HAND, @@ -407,7 +409,7 @@ const struct SpriteTemplate gClappingHand2SpriteTemplate = .callback = AnimClappingHand2, }; -const union AnimCmd gRapidSpinAnimCmds[] = +const union AnimCmd gRapidSpinAnimCmds[] = //83FF054 { ANIMCMD_FRAME(0, 2), ANIMCMD_FRAME(8, 2), @@ -415,12 +417,12 @@ const union AnimCmd gRapidSpinAnimCmds[] = ANIMCMD_JUMP(0), }; -const union AnimCmd *const gRapidSpinAnimTable[] = +const union AnimCmd *const gRapidSpinAnimTable[] = //83FF064 { gRapidSpinAnimCmds, }; -const struct SpriteTemplate gRapidSpinSpriteTemplate = +const struct SpriteTemplate gRapidSpinSpriteTemplate = //83FF068 { .tileTag = ANIM_TAG_RAPID_SPIN, .paletteTag = ANIM_TAG_RAPID_SPIN, @@ -431,7 +433,7 @@ const struct SpriteTemplate gRapidSpinSpriteTemplate = .callback = AnimRapidSpin, }; -const union AffineAnimCmd gUnknown_085CE2A0[] = +const union AffineAnimCmd gUnknown_83FF080[] = //83FF080 { AFFINEANIMCMD_FRAME(-12, 8, 0, 4), AFFINEANIMCMD_FRAME(20, -20, 0, 4), @@ -439,18 +441,18 @@ const union AffineAnimCmd gUnknown_085CE2A0[] = AFFINEANIMCMD_END, }; -const union AnimCmd gTriAttackTriangleAnimCmds[] = +const union AnimCmd gTriAttackTriangleAnimCmds[] = //83FF0A0 { ANIMCMD_FRAME(0, 8), ANIMCMD_END, }; -const union AnimCmd *const gTriAttackTriangleAnimTable[] = +const union AnimCmd *const gTriAttackTriangleAnimTable[] = //83FF0A8 { gTriAttackTriangleAnimCmds, }; -const union AffineAnimCmd gTriAttackTriangleAffineAnimCmds[] = +const union AffineAnimCmd gTriAttackTriangleAffineAnimCmds[] = //83FF0AC { AFFINEANIMCMD_FRAME(0, 0, 5, 40), AFFINEANIMCMD_FRAME(0, 0, 10, 10), @@ -459,12 +461,12 @@ const union AffineAnimCmd gTriAttackTriangleAffineAnimCmds[] = AFFINEANIMCMD_JUMP(0), }; -const union AffineAnimCmd *const gTriAttackTriangleAffineAnimTable[] = +const union AffineAnimCmd *const gTriAttackTriangleAffineAnimTable[] = //83FF0D4 { gTriAttackTriangleAffineAnimCmds, }; -const struct SpriteTemplate gTriAttackTriangleSpriteTemplate = +const struct SpriteTemplate gTriAttackTriangleSpriteTemplate = //83FF0D8 { .tileTag = ANIM_TAG_TRI_ATTACK_TRIANGLE, .paletteTag = ANIM_TAG_TRI_ATTACK_TRIANGLE, @@ -475,7 +477,7 @@ const struct SpriteTemplate gTriAttackTriangleSpriteTemplate = .callback = AnimTriAttackTriangle, }; -const union AnimCmd gEclipsingOrbAnimCmds[] = +const union AnimCmd gEclipsingOrbAnimCmds[] = //83FF0F0 { ANIMCMD_FRAME(0, 3), ANIMCMD_FRAME(16, 3), @@ -488,12 +490,12 @@ const union AnimCmd gEclipsingOrbAnimCmds[] = ANIMCMD_END, }; -const union AnimCmd *const gEclipsingOrbAnimTable[] = +const union AnimCmd *const gEclipsingOrbAnimTable[] = //83FF114 { gEclipsingOrbAnimCmds, }; -const struct SpriteTemplate gEclipsingOrbSpriteTemplate = +const struct SpriteTemplate gEclipsingOrbSpriteTemplate = //83FF118 { .tileTag = ANIM_TAG_ECLIPSING_ORB, .paletteTag = ANIM_TAG_ECLIPSING_ORB, @@ -504,7 +506,7 @@ const struct SpriteTemplate gEclipsingOrbSpriteTemplate = .callback = AnimSpriteOnMonPos, }; -const union AffineAnimCmd DefenseCurlDeformMonAffineAnimCmds[] = +const union AffineAnimCmd DefenseCurlDeformMonAffineAnimCmds[] = //83FF130 { AFFINEANIMCMD_FRAME(-12, 20, 0, 8), AFFINEANIMCMD_FRAME(12, -20, 0, 8), @@ -512,7 +514,7 @@ const union AffineAnimCmd DefenseCurlDeformMonAffineAnimCmds[] = AFFINEANIMCMD_END, }; -const struct SpriteTemplate gBatonPassPokeballSpriteTemplate = +const struct SpriteTemplate gBatonPassPokeballSpriteTemplate = //83FF150 { .tileTag = ANIM_TAG_POKEBALL, .paletteTag = ANIM_TAG_POKEBALL, @@ -523,7 +525,7 @@ const struct SpriteTemplate gBatonPassPokeballSpriteTemplate = .callback = AnimBatonPassPokeball, }; -const struct SpriteTemplate gWishStarSpriteTemplate = +const struct SpriteTemplate gWishStarSpriteTemplate = //83FF168 { .tileTag = ANIM_TAG_GOLD_STARS, .paletteTag = ANIM_TAG_GOLD_STARS, @@ -534,7 +536,7 @@ const struct SpriteTemplate gWishStarSpriteTemplate = .callback = AnimWishStar, }; -const struct SpriteTemplate gMiniTwinklingStarSpriteTemplate = +const struct SpriteTemplate gMiniTwinklingStarSpriteTemplate = //83FF180 { .tileTag = ANIM_TAG_GOLD_STARS, .paletteTag = ANIM_TAG_GOLD_STARS, @@ -545,7 +547,7 @@ const struct SpriteTemplate gMiniTwinklingStarSpriteTemplate = .callback = AnimMiniTwinklingStar, }; -const union AffineAnimCmd gStockpileDeformMonAffineAnimCmds[] = +const union AffineAnimCmd gStockpileDeformMonAffineAnimCmds[] = //83FF198 { AFFINEANIMCMD_FRAME(8, -8, 0, 12), AFFINEANIMCMD_FRAME(-16, 16, 0, 12), @@ -554,7 +556,7 @@ const union AffineAnimCmd gStockpileDeformMonAffineAnimCmds[] = AFFINEANIMCMD_END, }; -const union AffineAnimCmd gSpitUpDeformMonAffineAnimCmds[] = +const union AffineAnimCmd gSpitUpDeformMonAffineAnimCmds[] = //83FF1C0 { AFFINEANIMCMD_FRAME(0, 6, 0, 20), AFFINEANIMCMD_FRAME(0, 0, 0, 20), @@ -565,7 +567,7 @@ const union AffineAnimCmd gSpitUpDeformMonAffineAnimCmds[] = AFFINEANIMCMD_END, }; -const struct SpriteTemplate gSwallowBlueOrbSpriteTemplate = +const struct SpriteTemplate gSwallowBlueOrbSpriteTemplate = //83FF1F8 { .tileTag = ANIM_TAG_BLUE_ORB, .paletteTag = ANIM_TAG_BLUE_ORB, @@ -576,7 +578,7 @@ const struct SpriteTemplate gSwallowBlueOrbSpriteTemplate = .callback = AnimSwallowBlueOrb, }; -const union AffineAnimCmd gSwallowDeformMonAffineAnimCmds[] = +const union AffineAnimCmd gSwallowDeformMonAffineAnimCmds[] = //83FF210 { AFFINEANIMCMD_FRAME(0, 6, 0, 20), AFFINEANIMCMD_FRAME(0, 0, 0, 20), @@ -586,7 +588,7 @@ const union AffineAnimCmd gSwallowDeformMonAffineAnimCmds[] = AFFINEANIMCMD_END, }; -const s8 gMorningSunLightBeamCoordsTable[] = +const s8 gMorningSunLightBeamCoordsTable[] = //83FF240 { 0xE8, 0x18, @@ -594,33 +596,33 @@ const s8 gMorningSunLightBeamCoordsTable[] = 0x00, }; -const union AnimCmd gGreenStarAnimCmds1[] = +const union AnimCmd gGreenStarAnimCmds1[] = //83FF244 { ANIMCMD_FRAME(0, 6), ANIMCMD_FRAME(4, 6), ANIMCMD_JUMP(0), }; -const union AnimCmd gGreenStarAnimCmds2[] = +const union AnimCmd gGreenStarAnimCmds2[] = //83FF250 { ANIMCMD_FRAME(8, 6), ANIMCMD_END, }; -const union AnimCmd gGreenStarAnimCmds3[] = +const union AnimCmd gGreenStarAnimCmds3[] = //83FF258 { ANIMCMD_FRAME(12, 6), ANIMCMD_END, }; -const union AnimCmd *const gGreenStarAnimTable[] = +const union AnimCmd *const gGreenStarAnimTable[] = //83FF260 { gGreenStarAnimCmds1, gGreenStarAnimCmds2, gGreenStarAnimCmds3, }; -const struct SpriteTemplate gGreenStarSpriteTemplate = +const struct SpriteTemplate gGreenStarSpriteTemplate = //83FF26C { .tileTag = ANIM_TAG_GREEN_STAR, .paletteTag = ANIM_TAG_GREEN_STAR, @@ -631,7 +633,7 @@ const struct SpriteTemplate gGreenStarSpriteTemplate = .callback = AnimGreenStar, }; -const s8 gDoomDesireLightBeamCoordTable[] = +const s8 gDoomDesireLightBeamCoordTable[] = //83FF284 { 0x78, 0x50, @@ -639,7 +641,7 @@ const s8 gDoomDesireLightBeamCoordTable[] = 0x00, }; -const u8 gDoomDesireLightBeamDelayTable[] = +const u8 gDoomDesireLightBeamDelayTable[] = //83FF288 { 0, 0, @@ -648,7 +650,7 @@ const u8 gDoomDesireLightBeamDelayTable[] = 50, }; -const union AffineAnimCmd gStrongFrustrationAffineAnimCmds[] = +const union AffineAnimCmd gStrongFrustrationAffineAnimCmds[] = //83FF290 { AFFINEANIMCMD_FRAME(0, -15, 0, 7), AFFINEANIMCMD_FRAME(0, 15, 0, 7), @@ -656,7 +658,7 @@ const union AffineAnimCmd gStrongFrustrationAffineAnimCmds[] = AFFINEANIMCMD_END, }; -const struct SpriteTemplate gWeakFrustrationAngerMarkSpriteTemplate = +const struct SpriteTemplate gWeakFrustrationAngerMarkSpriteTemplate = //83FF2B0 { .tileTag = ANIM_TAG_ANGER, .paletteTag = ANIM_TAG_ANGER, @@ -667,7 +669,7 @@ const struct SpriteTemplate gWeakFrustrationAngerMarkSpriteTemplate = .callback = AnimWeakFrustrationAngerMark, }; -const union AnimCmd gSweetScentPetalAnimCmds1[] = +const union AnimCmd gSweetScentPetalAnimCmds1[] = //83FF2C8 { ANIMCMD_FRAME(0, 8), ANIMCMD_FRAME(1, 8), @@ -680,7 +682,7 @@ const union AnimCmd gSweetScentPetalAnimCmds1[] = ANIMCMD_JUMP(0), }; -const union AnimCmd gSweetScentPetalAnimCmds2[] = +const union AnimCmd gSweetScentPetalAnimCmds2[] = //83FF2EC { ANIMCMD_FRAME(0, 8, .hFlip = TRUE), ANIMCMD_FRAME(1, 8, .hFlip = TRUE), @@ -693,20 +695,20 @@ const union AnimCmd gSweetScentPetalAnimCmds2[] = ANIMCMD_JUMP(0), }; -const union AnimCmd gSweetScentPetalAnimCmds3[] = +const union AnimCmd gSweetScentPetalAnimCmds3[] = //83FF310 { ANIMCMD_FRAME(0, 8), ANIMCMD_END, }; -const union AnimCmd *const gSweetScentPetalAnimCmdTable[] = +const union AnimCmd *const gSweetScentPetalAnimCmdTable[] = //83FF318 { gSweetScentPetalAnimCmds1, gSweetScentPetalAnimCmds2, gSweetScentPetalAnimCmds3, }; -const struct SpriteTemplate gSweetScentPetalSpriteTemplate = +const struct SpriteTemplate gSweetScentPetalSpriteTemplate = //83FF324 { .tileTag = ANIM_TAG_PINK_PETAL, .paletteTag = ANIM_TAG_PINK_PETAL, @@ -717,9 +719,9 @@ const struct SpriteTemplate gSweetScentPetalSpriteTemplate = .callback = AnimSweetScentPetal, }; -const u16 gUnknown_085CE55C[] = INCBIN_U16("graphics/unknown/unknown_85CE55C.gbapal"); +const u16 gUnknown_83FF33C[] = INCBIN_U16("graphics/unknown/unk_83FF33C.gbapal"); //Unused -const union AnimCmd gPainSplitAnimCmds[] = +const union AnimCmd gPainSplitAnimCmds[] = //83FF35C { ANIMCMD_FRAME(0, 5), ANIMCMD_FRAME(4, 9), @@ -727,12 +729,12 @@ const union AnimCmd gPainSplitAnimCmds[] = ANIMCMD_END, }; -const union AnimCmd *const gPainSplitAnimCmdTable[] = +const union AnimCmd *const gPainSplitAnimCmdTable[] = //83FF36C { gPainSplitAnimCmds, }; -const struct SpriteTemplate gPainSplitProjectileSpriteTemplate = +const struct SpriteTemplate gPainSplitProjectileSpriteTemplate = //83FF370 { .tileTag = ANIM_TAG_PAIN_SPLIT, .paletteTag = ANIM_TAG_PAIN_SPLIT, @@ -743,7 +745,7 @@ const struct SpriteTemplate gPainSplitProjectileSpriteTemplate = .callback = AnimPainSplitProjectile, }; -const struct SpriteTemplate gFlatterConfettiSpriteTemplate = +const struct SpriteTemplate gFlatterConfettiSpriteTemplate = //83FF388 { .tileTag = ANIM_TAG_CONFETTI, .paletteTag = ANIM_TAG_CONFETTI, @@ -754,7 +756,7 @@ const struct SpriteTemplate gFlatterConfettiSpriteTemplate = .callback = AnimFlatterConfetti, }; -const struct SpriteTemplate gFlatterSpotlightSpriteTemplate = +const struct SpriteTemplate gFlatterSpotlightSpriteTemplate = //83FF3A0 { .tileTag = ANIM_TAG_SPOTLIGHT, .paletteTag = ANIM_TAG_SPOTLIGHT, @@ -765,7 +767,7 @@ const struct SpriteTemplate gFlatterSpotlightSpriteTemplate = .callback = AnimFlatterSpotlight, }; -const struct SpriteTemplate gReversalOrbSpriteTemplate = +const struct SpriteTemplate gReversalOrbSpriteTemplate = //83FF3B8 { .tileTag = ANIM_TAG_BLUE_ORB, .paletteTag = ANIM_TAG_BLUE_ORB, @@ -776,7 +778,7 @@ const struct SpriteTemplate gReversalOrbSpriteTemplate = .callback = AnimReversalOrb, }; -const union AffineAnimCmd gDeepInhaleAffineAnimCmds[] = +const union AffineAnimCmd gDeepInhaleAffineAnimCmds[] = //83FF3D0 { AFFINEANIMCMD_FRAME(16, 0, 0, 4), AFFINEANIMCMD_FRAME(0, -3, 0, 16), @@ -786,7 +788,7 @@ const union AffineAnimCmd gDeepInhaleAffineAnimCmds[] = AFFINEANIMCMD_END, }; -const union AffineAnimCmd gYawnCloudAffineAnimCmds1[] = +const union AffineAnimCmd gYawnCloudAffineAnimCmds1[] = //83FF400 { AFFINEANIMCMD_FRAME(0x80, 0x80, 0, 0), AFFINEANIMCMD_FRAME(-8, -8, 0, 8), @@ -794,7 +796,7 @@ const union AffineAnimCmd gYawnCloudAffineAnimCmds1[] = AFFINEANIMCMD_JUMP(0), }; -const union AffineAnimCmd gYawnCloudAffineAnimCmds2[] = +const union AffineAnimCmd gYawnCloudAffineAnimCmds2[] = //83FF420 { AFFINEANIMCMD_FRAME(0xC0, 0xC0, 0, 0), AFFINEANIMCMD_FRAME(8, 8, 0, 8), @@ -802,7 +804,7 @@ const union AffineAnimCmd gYawnCloudAffineAnimCmds2[] = AFFINEANIMCMD_JUMP(0), }; -const union AffineAnimCmd gYawnCloudAffineAnimCmds3[] = +const union AffineAnimCmd gYawnCloudAffineAnimCmds3[] = //83FF440 { AFFINEANIMCMD_FRAME(0x100, 0x100, 0, 0), AFFINEANIMCMD_FRAME(8, 8, 0, 8), @@ -810,14 +812,14 @@ const union AffineAnimCmd gYawnCloudAffineAnimCmds3[] = AFFINEANIMCMD_JUMP(0), }; -const union AffineAnimCmd *const gYawnCloudAffineAnimTable[] = +const union AffineAnimCmd *const gYawnCloudAffineAnimTable[] = //83FF460 { gYawnCloudAffineAnimCmds1, gYawnCloudAffineAnimCmds2, gYawnCloudAffineAnimCmds3, }; -const struct SpriteTemplate gYawnCloudSpriteTemplate = +const struct SpriteTemplate gYawnCloudSpriteTemplate = //83FF46C { .tileTag = ANIM_TAG_PINK_CLOUD, .paletteTag = ANIM_TAG_PINK_CLOUD, @@ -828,7 +830,7 @@ const struct SpriteTemplate gYawnCloudSpriteTemplate = .callback = AnimYawnCloud, }; -const union AffineAnimCmd gSmokeBallEscapeCloudAffineAnimCmds1[] = +const union AffineAnimCmd gSmokeBallEscapeCloudAffineAnimCmds1[] = //83FF484 { AFFINEANIMCMD_FRAME(0x80, 0x80, 0, 0), AFFINEANIMCMD_FRAME(-4, -6, 0, 16), @@ -836,7 +838,7 @@ const union AffineAnimCmd gSmokeBallEscapeCloudAffineAnimCmds1[] = AFFINEANIMCMD_JUMP(0), }; -const union AffineAnimCmd gSmokeBallEscapeCloudAffineAnimCmds2[] = +const union AffineAnimCmd gSmokeBallEscapeCloudAffineAnimCmds2[] = //83FF4A4 { AFFINEANIMCMD_FRAME(0xC0, 0xC0, 0, 0), AFFINEANIMCMD_FRAME(4, 6, 0, 16), @@ -844,7 +846,7 @@ const union AffineAnimCmd gSmokeBallEscapeCloudAffineAnimCmds2[] = AFFINEANIMCMD_JUMP(0), }; -const union AffineAnimCmd gSmokeBallEscapeCloudAffineAnimCmds3[] = +const union AffineAnimCmd gSmokeBallEscapeCloudAffineAnimCmds3[] = //83FF4C4 { AFFINEANIMCMD_FRAME(0x100, 0x100, 0, 0), AFFINEANIMCMD_FRAME(4, 6, 0, 16), @@ -852,7 +854,7 @@ const union AffineAnimCmd gSmokeBallEscapeCloudAffineAnimCmds3[] = AFFINEANIMCMD_JUMP(0), }; -const union AffineAnimCmd gSmokeBallEscapeCloudAffineAnimCmds4[] = +const union AffineAnimCmd gSmokeBallEscapeCloudAffineAnimCmds4[] = //83FF4E4 { AFFINEANIMCMD_FRAME(0x100, 0x100, 0, 0), AFFINEANIMCMD_FRAME(8, 10, 0, 30), @@ -860,7 +862,7 @@ const union AffineAnimCmd gSmokeBallEscapeCloudAffineAnimCmds4[] = AFFINEANIMCMD_JUMP(0), }; -const union AffineAnimCmd *const gSmokeBallEscapeCloudAffineAnimTable[] = +const union AffineAnimCmd *const gSmokeBallEscapeCloudAffineAnimTable[] = //83FF504 { gSmokeBallEscapeCloudAffineAnimCmds1, gSmokeBallEscapeCloudAffineAnimCmds2, @@ -868,7 +870,7 @@ const union AffineAnimCmd *const gSmokeBallEscapeCloudAffineAnimTable[] = gSmokeBallEscapeCloudAffineAnimCmds4, }; -const struct SpriteTemplate gSmokeBallEscapeCloudSpriteTemplate = +const struct SpriteTemplate gSmokeBallEscapeCloudSpriteTemplate = //83FF514 { .tileTag = ANIM_TAG_PINK_CLOUD, .paletteTag = ANIM_TAG_PINK_CLOUD, @@ -879,7 +881,7 @@ const struct SpriteTemplate gSmokeBallEscapeCloudSpriteTemplate = .callback = AnimSmokeBallEscapeCloud, }; -const union AffineAnimCmd gFacadeSquishAffineAnimCmds[] = +const union AffineAnimCmd gFacadeSquishAffineAnimCmds[] = //83FF52C { AFFINEANIMCMD_FRAME(-16, 16, 0, 6), AFFINEANIMCMD_FRAME(16, -16, 0, 12), @@ -887,7 +889,7 @@ const union AffineAnimCmd gFacadeSquishAffineAnimCmds[] = AFFINEANIMCMD_END, }; -const struct SpriteTemplate gFacadeSweatDropSpriteTemplate = +const struct SpriteTemplate gFacadeSweatDropSpriteTemplate = //83FF54C { .tileTag = ANIM_TAG_SWEAT_DROP, .paletteTag = ANIM_TAG_SWEAT_DROP, @@ -898,7 +900,8 @@ const struct SpriteTemplate gFacadeSweatDropSpriteTemplate = .callback = AnimFacadeSweatDrop, }; -const u16 gFacadeBlendColors[] = { +const u16 gFacadeBlendColors[] = //83FF564 +{ RGB(28, 25, 1), RGB(28, 21, 5), RGB(27, 18, 8), @@ -925,27 +928,27 @@ const u16 gFacadeBlendColors[] = { RGB(29, 27, 0), }; -const union AnimCmd gRoarNoiseLineAnimCmds1[] = +const union AnimCmd gRoarNoiseLineAnimCmds1[] = //83FF594 { ANIMCMD_FRAME(0, 3), ANIMCMD_FRAME(16, 3), ANIMCMD_JUMP(0), }; -const union AnimCmd gRoarNoiseLineAnimCmds2[] = +const union AnimCmd gRoarNoiseLineAnimCmds2[] = //83FF5A0 { ANIMCMD_FRAME(32, 3), ANIMCMD_FRAME(48, 3), ANIMCMD_JUMP(0), }; -const union AnimCmd *const gRoarNoiseLineAnimTable[] = +const union AnimCmd *const gRoarNoiseLineAnimTable[] = //83FF5AC { gRoarNoiseLineAnimCmds1, gRoarNoiseLineAnimCmds2, }; -const struct SpriteTemplate gRoarNoiseLineSpriteTemplate = +const struct SpriteTemplate gRoarNoiseLineSpriteTemplate = //83FF5B4 { .tileTag = ANIM_TAG_NOISE_LINE, .paletteTag = ANIM_TAG_NOISE_LINE, @@ -956,7 +959,7 @@ const struct SpriteTemplate gRoarNoiseLineSpriteTemplate = .callback = AnimRoarNoiseLine, }; -const struct SpriteTemplate gGlareEyeDotSpriteTemplate = +const struct SpriteTemplate gGlareEyeDotSpriteTemplate = //83FF5CC { .tileTag = ANIM_TAG_SMALL_RED_EYE, .paletteTag = ANIM_TAG_SMALL_RED_EYE, @@ -967,7 +970,7 @@ const struct SpriteTemplate gGlareEyeDotSpriteTemplate = .callback = AnimGlareEyeDot, }; -const struct SpriteTemplate gAssistPawprintSpriteTemplate = +const struct SpriteTemplate gAssistPawprintSpriteTemplate = //83FF5E4 { .tileTag = ANIM_TAG_PAW_PRINT, .paletteTag = ANIM_TAG_PAW_PRINT, @@ -978,26 +981,26 @@ const struct SpriteTemplate gAssistPawprintSpriteTemplate = .callback = AnimAssistPawprint, }; -const union AffineAnimCmd gBarrageBallAffineAnimCmds1[] = +const union AffineAnimCmd gBarrageBallAffineAnimCmds1[] = //83FF5FC { AFFINEANIMCMD_FRAME(0, 0, -4, 24), AFFINEANIMCMD_END, }; -const union AffineAnimCmd gBarrageBallAffineAnimCmds2[] = +const union AffineAnimCmd gBarrageBallAffineAnimCmds2[] = //83FF60C { AFFINEANIMCMD_FRAME(0x100, 0x100, -64, 0), AFFINEANIMCMD_FRAME(0, 0, 4, 24), AFFINEANIMCMD_END, }; -const union AffineAnimCmd *const gBarrageBallAffineAnimTable[] = +const union AffineAnimCmd *const gBarrageBallAffineAnimTable[] = //83FF624 { gBarrageBallAffineAnimCmds1, gBarrageBallAffineAnimCmds2, }; -const struct SpriteTemplate gBarrageBallSpriteTemplate = +const struct SpriteTemplate gBarrageBallSpriteTemplate = //83FF62C { .tileTag = ANIM_TAG_RED_BALL, .paletteTag = ANIM_TAG_RED_BALL, @@ -1008,7 +1011,7 @@ const struct SpriteTemplate gBarrageBallSpriteTemplate = .callback = SpriteCallbackDummy, }; -const struct SpriteTemplate gSmellingSaltsHandSpriteTemplate = +const struct SpriteTemplate gSmellingSaltsHandSpriteTemplate = //83FF644 { .tileTag = ANIM_TAG_TAG_HAND, .paletteTag = ANIM_TAG_TAG_HAND, @@ -1019,14 +1022,14 @@ const struct SpriteTemplate gSmellingSaltsHandSpriteTemplate = .callback = AnimSmellingSaltsHand, }; -const union AffineAnimCmd gSmellingSaltsSquishAffineAnimCmds[] = +const union AffineAnimCmd gSmellingSaltsSquishAffineAnimCmds[] = //83FF65C { AFFINEANIMCMD_FRAME(0, -16, 0, 6), AFFINEANIMCMD_FRAME(0, 16, 0, 6), AFFINEANIMCMD_END, }; -const struct SpriteTemplate gSmellingSaltExclamationSpriteTemplate = +const struct SpriteTemplate gSmellingSaltExclamationSpriteTemplate = //83FF674 { .tileTag = ANIM_TAG_SMELLINGSALT_EFFECT, .paletteTag = ANIM_TAG_SMELLINGSALT_EFFECT, @@ -1037,7 +1040,7 @@ const struct SpriteTemplate gSmellingSaltExclamationSpriteTemplate = .callback = AnimSmellingSaltExclamation, }; -const struct SpriteTemplate gHelpingHandClapSpriteTemplate = +const struct SpriteTemplate gHelpingHandClapSpriteTemplate = //83FF68C { .tileTag = ANIM_TAG_TAG_HAND, .paletteTag = ANIM_TAG_TAG_HAND, @@ -1048,7 +1051,7 @@ const struct SpriteTemplate gHelpingHandClapSpriteTemplate = .callback = AnimHelpingHandClap, }; -const struct SpriteTemplate gForesightMagnifyingGlassSpriteTemplate = +const struct SpriteTemplate gForesightMagnifyingGlassSpriteTemplate = //83FF6A4 { .tileTag = ANIM_TAG_MAGNIFYING_GLASS, .paletteTag = ANIM_TAG_MAGNIFYING_GLASS, @@ -1059,7 +1062,7 @@ const struct SpriteTemplate gForesightMagnifyingGlassSpriteTemplate = .callback = AnimForesightMagnifyingGlass, }; -const struct SpriteTemplate gMeteorMashStarSpriteTemplate = +const struct SpriteTemplate gMeteorMashStarSpriteTemplate = //83FF6BC { .tileTag = ANIM_TAG_GOLD_STARS, .paletteTag = ANIM_TAG_GOLD_STARS, @@ -1070,7 +1073,7 @@ const struct SpriteTemplate gMeteorMashStarSpriteTemplate = .callback = AnimMeteorMashStar, }; -const struct SpriteTemplate gUnknown_085CE8F4 = +const struct SpriteTemplate gUnknown_83FF6D4 = //83FF6D4 { .tileTag = ANIM_TAG_GOLD_STARS, .paletteTag = ANIM_TAG_GOLD_STARS, @@ -1081,7 +1084,7 @@ const struct SpriteTemplate gUnknown_085CE8F4 = .callback = AnimParticuleBurst, }; -const struct SpriteTemplate gBlockXSpriteTemplate = +const struct SpriteTemplate gBlockXSpriteTemplate = //83FF6EC { .tileTag = ANIM_TAG_X_SIGN, .paletteTag = ANIM_TAG_X_SIGN, @@ -1092,7 +1095,7 @@ const struct SpriteTemplate gBlockXSpriteTemplate = .callback = AnimBlockX, }; -const struct SpriteTemplate gUnknown_085CE924 = +const struct SpriteTemplate gUnknown_83FF704 = //83FF704 { .tileTag = ANIM_TAG_ITEM_BAG, .paletteTag = ANIM_TAG_ITEM_BAG, @@ -1100,42 +1103,42 @@ const struct SpriteTemplate gUnknown_085CE924 = .anims = gDummySpriteAnimTable, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_815FE80, + .callback = sub_80E3E84, }; -const union AnimCmd gKnockOffStrikeAnimCmds[] = +const union AnimCmd gKnockOffStrikeAnimCmds[] = //83FF71C { ANIMCMD_FRAME(0, 4), ANIMCMD_FRAME(64, 4), ANIMCMD_END, }; -const union AnimCmd *const gKnockOffStrikeAnimTable[] = +const union AnimCmd *const gKnockOffStrikeAnimTable[] = //83FF728 { gKnockOffStrikeAnimCmds, }; -const union AffineAnimCmd gKnockOffStrikeAffineanimCmds1[] = +const union AffineAnimCmd gKnockOffStrikeAffineanimCmds1[] = //83FF72C { AFFINEANIMCMD_FRAME(0x100, 0x100, 0, 0), AFFINEANIMCMD_FRAME(0, 0, -4, 8), AFFINEANIMCMD_END, }; -const union AffineAnimCmd gKnockOffStrikeAffineanimCmds2[] = +const union AffineAnimCmd gKnockOffStrikeAffineanimCmds2[] = //83FF744 { AFFINEANIMCMD_FRAME(-0x100, 0x100, 0, 0), AFFINEANIMCMD_FRAME(0, 0, 4, 8), AFFINEANIMCMD_END, }; -const union AffineAnimCmd *const gKnockOffStrikeAffineAnimTable[] = +const union AffineAnimCmd *const gKnockOffStrikeAffineAnimTable[] = //83FF75C { gKnockOffStrikeAffineanimCmds1, gKnockOffStrikeAffineanimCmds2, }; -const struct SpriteTemplate gKnockOffStrikeSpriteTemplate = +const struct SpriteTemplate gKnockOffStrikeSpriteTemplate = //83FF764 { .tileTag = ANIM_TAG_SLAM_HIT_2, .paletteTag = ANIM_TAG_SLAM_HIT_2, @@ -1146,18 +1149,18 @@ const struct SpriteTemplate gKnockOffStrikeSpriteTemplate = .callback = AnimKnockOffStrike, }; -const union AffineAnimCmd gRecycleSpriteAffineAnimCmds[] = +const union AffineAnimCmd gRecycleSpriteAffineAnimCmds[] = //83FF77C { AFFINEANIMCMD_FRAME(0, 0, -4, 64), AFFINEANIMCMD_JUMP(0), }; -const union AffineAnimCmd *const gRecycleSpriteAffineAnimTable[] = +const union AffineAnimCmd *const gRecycleSpriteAffineAnimTable[] = //83FF78C { gRecycleSpriteAffineAnimCmds, }; -const struct SpriteTemplate gRecycleSpriteTemplate = +const struct SpriteTemplate gRecycleSpriteTemplate = //83FF790 { .tileTag = ANIM_TAG_RECYCLE, .paletteTag = ANIM_TAG_RECYCLE, @@ -1168,7 +1171,7 @@ const struct SpriteTemplate gRecycleSpriteTemplate = .callback = AnimRecycle, }; -const union AffineAnimCmd gSlackOffSquishAffineAnimCmds[] = +const union AffineAnimCmd gSlackOffSquishAffineAnimCmds[] = //83FF7A8 { AFFINEANIMCMD_FRAME(0, 16, 0, 4), AFFINEANIMCMD_FRAME(-2, 0, 0, 8), @@ -1179,6 +1182,8 @@ const union AffineAnimCmd gSlackOffSquishAffineAnimCmds[] = }; // Functions + +// 80DE2C0 void AnimBlackSmoke(struct Sprite *sprite) { sprite->pos1.x += gBattleAnimArgs[0]; @@ -1944,7 +1949,7 @@ static void TormentAttacker_Step(u8 taskId) task->data[5] -= 6; } - PrepareAffineAnimInTaskData(task, task->data[15], gUnknown_085CE2A0); + PrepareAffineAnimInTaskData(task, task->data[15], gUnknown_83FF080); task->data[1]++; task->data[0] = 1; break; @@ -2049,7 +2054,7 @@ void AnimTask_DefenseCurlDeformMon(u8 taskId) switch (gTasks[taskId].data[0]) { case 0: - PrepareAffineAnimInTaskData(&gTasks[taskId], GetAnimBattlerSpriteId(ANIM_ATTACKER), gUnknown_085CE350); + PrepareAffineAnimInTaskData(&gTasks[taskId], GetAnimBattlerSpriteId(ANIM_ATTACKER), DefenseCurlDeformMonAffineAnimCmds); gTasks[taskId].data[0]++; break; case 1: @@ -2191,7 +2196,7 @@ void AnimTask_StockpileDeformMon(u8 taskId) { if (!gTasks[taskId].data[0]) { - PrepareAffineAnimInTaskData(&gTasks[taskId], GetAnimBattlerSpriteId(ANIM_ATTACKER), gUnknown_085CE3B8); + PrepareAffineAnimInTaskData(&gTasks[taskId], GetAnimBattlerSpriteId(ANIM_ATTACKER), gStockpileDeformMonAffineAnimCmds); gTasks[taskId].data[0]++; } else @@ -2205,7 +2210,7 @@ void AnimTask_SpitUpDeformMon(u8 taskId) { if (!gTasks[taskId].data[0]) { - PrepareAffineAnimInTaskData(&gTasks[taskId], GetAnimBattlerSpriteId(ANIM_ATTACKER), gUnknown_085CE3E0); + PrepareAffineAnimInTaskData(&gTasks[taskId], GetAnimBattlerSpriteId(ANIM_ATTACKER), gSpitUpDeformMonAffineAnimCmds); gTasks[taskId].data[0]++; } else @@ -2238,7 +2243,7 @@ void AnimTask_SwallowDeformMon(u8 taskId) { if (!gTasks[taskId].data[0]) { - PrepareAffineAnimInTaskData(&gTasks[taskId], GetAnimBattlerSpriteId(ANIM_ATTACKER), gUnknown_085CE430); + PrepareAffineAnimInTaskData(&gTasks[taskId], GetAnimBattlerSpriteId(ANIM_ATTACKER), gSwallowDeformMonAffineAnimCmds); gTasks[taskId].data[0]++; } else @@ -2248,6 +2253,7 @@ void AnimTask_SwallowDeformMon(u8 taskId) } } +// case 2 quite different :/ void AnimTask_TransformMon(u8 taskId) { int i, j; @@ -2456,7 +2462,7 @@ void AnimTask_MorningSunLightBeam(u8 taskId) if (!gTasks[taskId].data[1]) { - gBattle_BG1_X = gUnknown_085CE460[gTasks[taskId].data[2]] + gTasks[taskId].data[10]; + gBattle_BG1_X = gMorningSunLightBeamCoordsTable[gTasks[taskId].data[2]] + gTasks[taskId].data[10]; if (++gTasks[taskId].data[2] == 4) gTasks[taskId].data[0] = 4; else @@ -2503,8 +2509,8 @@ void AnimGreenStar(struct Sprite *sprite) sprite->data[1] = gBattleAnimArgs[0]; sprite->data[2] = gBattleAnimArgs[1]; - spriteId1 = CreateSprite(&gUnknown_085CE48C, sprite->pos1.x, sprite->pos1.y, sprite->subpriority + 1); - spriteId2 = CreateSprite(&gUnknown_085CE48C, sprite->pos1.x, sprite->pos1.y, sprite->subpriority + 1); + spriteId1 = CreateSprite(&gGreenStarSpriteTemplate, sprite->pos1.x, sprite->pos1.y, sprite->subpriority + 1); + spriteId2 = CreateSprite(&gGreenStarSpriteTemplate, sprite->pos1.x, sprite->pos1.y, sprite->subpriority + 1); StartSpriteAnim(&gSprites[spriteId1], 1); StartSpriteAnim(&gSprites[spriteId2], 2); @@ -2595,10 +2601,10 @@ void AnimTask_DoomDesireLightBeam(u8 taskId) sub_80A6D60(&animBg, &gUnknown_08C2A6EC, 0); */ - sub_80752A0 - sub_807543C - sub_80753B4 - LoadCompressedPalette + sub_80752A0( , + sub_807543C( , gUnknown_8D2A8C0 + sub_80753B4( , gUnknown_8D2A808 + LoadCompressedPalette(gUnknown_8D2A808 //... if (IsContest()) @@ -2631,8 +2637,8 @@ void AnimTask_DoomDesireLightBeam(u8 taskId) gBattle_BG1_Y = 0; } - AnimLoadCompressedBgGfx(animBg.bgId, gUnknown_08C2A634, animBg.tilesOffset); - LoadCompressedPalette(gUnknown_08C2A6D4, animBg.paletteId * 16, 32); + //AnimLoadCompressedBgGfx(animBg.bgId, gUnknown_08C2A634, animBg.tilesOffset); + //LoadCompressedPalette(gUnknown_08C2A6D4, animBg.paletteId * 16, 32); gTasks[taskId].data[10] = gBattle_BG1_X; gTasks[taskId].data[11] = gBattle_BG1_Y; gTasks[taskId].data[0]++; @@ -2640,9 +2646,9 @@ void AnimTask_DoomDesireLightBeam(u8 taskId) case 1: gTasks[taskId].data[3] = 0; if (GetBattlerSide(gBattleAnimTarget) == B_SIDE_OPPONENT) - gBattle_BG1_X = gTasks[taskId].data[10] + gUnknown_085CE4A4[gTasks[taskId].data[2]]; + gBattle_BG1_X = gTasks[taskId].data[10] + gDoomDesireLightBeamCoordTable[gTasks[taskId].data[2]]; else - gBattle_BG1_X = gTasks[taskId].data[10] - gUnknown_085CE4A4[gTasks[taskId].data[2]]; + gBattle_BG1_X = gTasks[taskId].data[10] - gDoomDesireLightBeamCoordTable[gTasks[taskId].data[2]]; if (++gTasks[taskId].data[2] == 5) gTasks[taskId].data[0] = 5; @@ -2658,7 +2664,7 @@ void AnimTask_DoomDesireLightBeam(u8 taskId) gTasks[taskId].data[0]++; break; case 3: - if (++gTasks[taskId].data[3] > gUnknown_085CE4A8[gTasks[taskId].data[2]]) + if (++gTasks[taskId].data[3] > gDoomDesireLightBeamDelayTable[gTasks[taskId].data[2]]) gTasks[taskId].data[0]++; break; case 4: diff --git a/src/battle_anim_special.c b/src/battle_anim_special.c new file mode 100644 index 000000000..d0d40a6d8 --- /dev/null +++ b/src/battle_anim_special.c @@ -0,0 +1,2296 @@ +#include "global.h" +#include "battle.h" +#include "battle_anim.h" +#include "battle_controllers.h" +#include "battle_interface.h" +#include "decompress.h" +#include "dma3.h" +#include "gpu_regs.h" +#include "graphics.h" +#include "m4a.h" +#include "main.h" +#include "palette.h" +#include "pokeball.h" +#include "sound.h" +#include "sprite.h" +#include "task.h" +#include "trig.h" +#include "util.h" +#include "constants/items.h" +#include "constants/moves.h" +#include "constants/songs.h" +#include "constants/rgb.h" + +// Defines +#define TAG_PARTICLES_POKEBALL 55020 +#define TAG_PARTICLES_GREATBALL 55021 +#define TAG_PARTICLES_SAFARIBALL 55022 +#define TAG_PARTICLES_ULTRABALL 55023 +#define TAG_PARTICLES_MASTERBALL 55024 +#define TAG_PARTICLES_NETBALL 55025 +#define TAG_PARTICLES_DIVEBALL 55026 +#define TAG_PARTICLES_NESTBALL 55027 +#define TAG_PARTICLES_REPEATBALL 55028 +#define TAG_PARTICLES_TIMERBALL 55029 +#define TAG_PARTICLES_LUXURYBALL 55030 +#define TAG_PARTICLES_PREMIERBALL 55031 + +// IWRAM +EWRAM_DATA int gUnknown_3005424 = 0; +EWRAM_DATA u16 gUnknown_3005428 = 0; +EWRAM_DATA u16 gUnknown_300542C = 0; + +// Function Declarations +static void sub_80EEDF4(u8); +static void sub_80EF1CC(u8); +static void sub_80EF698(u8); +static void sub_80EF8C0(struct Sprite *); +static void sub_80EF7EC(u8); +static void sub_80EF864(u8); +static void sub_80EF8F0(struct Sprite *); +static void sub_80F0478(struct Sprite *); +static void sub_80EF9B4(struct Sprite *); +static void sub_80EFA0C(struct Sprite *); +static void sub_80EFB58(struct Sprite *); +static void sub_80EFB9C(struct Sprite *); +static void sub_80EFF80(struct Sprite *); +static void sub_80EFCA0(struct Sprite *); +static void sub_80EFCEC(struct Sprite *); +static void sub_80EFFA4(struct Sprite *); +static void sub_80F02B0(struct Sprite *); +static void sub_80EFFC4(struct Sprite *); +static void sub_80F01B8(struct Sprite *); +static void sub_80F00A4(struct Sprite *); +static void sub_80F018C(struct Sprite *); +static void sub_80F05B4(u8); +static void sub_80F0278(struct Sprite *); +static void sub_80F0378(struct Sprite *); +static void sub_80F04B4(struct Sprite *); +static void PokeBallOpenParticleAnimation_Step1(struct Sprite *); +static void PokeBallOpenParticleAnimation_Step2(struct Sprite *); +static void DestroyBallOpenAnimationParticle(struct Sprite *); +static void FanOutBallOpenParticles_Step1(struct Sprite *); +static void RepeatBallOpenParticleAnimation_Step1(struct Sprite *); +static void PremierBallOpenParticleAnimation_Step1(struct Sprite *); +static void sub_80F12E0(u8); +static void sub_80F1370(u8); +static void sub_80F13C0(u8); +static void sub_80F181C(u8); +static void sub_80F1A2C(struct Sprite *); +static void sub_80F1A80(struct Sprite *); +static void sub_80F19E0(u8); +static void sub_80F1BCC(struct Sprite *); +static void sub_80F1C04(struct Sprite *); +static void sub_80F1C30(struct Sprite *); +static void PokeBallOpenParticleAnimation(u8); +static void GreatBallOpenParticleAnimation(u8); +static void SafariBallOpenParticleAnimation(u8); +static void UltraBallOpenParticleAnimation(u8); +static void MasterBallOpenParticleAnimation(u8); +static void DiveBallOpenParticleAnimation(u8); +static void RepeatBallOpenParticleAnimation(u8); +static void TimerBallOpenParticleAnimation(u8); +static void PremierBallOpenParticleAnimation(u8); +static void sub_80F1B3C(struct Sprite *); + +// Data +struct BallCaptureSuccessStarData +{ + s8 xOffset; + s8 yOffset; + s8 unk2; +}; + +static const struct BallCaptureSuccessStarData sBallCaptureSuccessStarData[] = //gUnknown_840BF3C +{ + { + .xOffset = 10, + .yOffset = 2, + .unk2 = -3, + }, + { + .xOffset = 15, + .yOffset = 0, + .unk2 = -4, + }, + { + .xOffset = -10, + .yOffset = 2, + .unk2 = -4, + }, +}; + +const struct CompressedSpriteSheet gBallParticleSpritesheets[] = //gUnknown_840BF48 +{ + {gBattleAnimSpriteGfx_Particles, 0x100, TAG_PARTICLES_POKEBALL}, + {gBattleAnimSpriteGfx_Particles, 0x100, TAG_PARTICLES_GREATBALL}, + {gBattleAnimSpriteGfx_Particles, 0x100, TAG_PARTICLES_SAFARIBALL}, + {gBattleAnimSpriteGfx_Particles, 0x100, TAG_PARTICLES_ULTRABALL}, + {gBattleAnimSpriteGfx_Particles, 0x100, TAG_PARTICLES_MASTERBALL}, + {gBattleAnimSpriteGfx_Particles, 0x100, TAG_PARTICLES_NETBALL}, + {gBattleAnimSpriteGfx_Particles, 0x100, TAG_PARTICLES_DIVEBALL}, + {gBattleAnimSpriteGfx_Particles, 0x100, TAG_PARTICLES_NESTBALL}, + {gBattleAnimSpriteGfx_Particles, 0x100, TAG_PARTICLES_REPEATBALL}, + {gBattleAnimSpriteGfx_Particles, 0x100, TAG_PARTICLES_TIMERBALL}, + {gBattleAnimSpriteGfx_Particles, 0x100, TAG_PARTICLES_LUXURYBALL}, + {gBattleAnimSpriteGfx_Particles, 0x100, TAG_PARTICLES_PREMIERBALL}, +}; + +const struct CompressedSpritePalette gBallParticlePalettes[] = //gUnknown_840BFA8 +{ + {gBattleAnimSpritePal_CircleImpact, TAG_PARTICLES_POKEBALL}, + {gBattleAnimSpritePal_CircleImpact, TAG_PARTICLES_GREATBALL}, + {gBattleAnimSpritePal_CircleImpact, TAG_PARTICLES_SAFARIBALL}, + {gBattleAnimSpritePal_CircleImpact, TAG_PARTICLES_ULTRABALL}, + {gBattleAnimSpritePal_CircleImpact, TAG_PARTICLES_MASTERBALL}, + {gBattleAnimSpritePal_CircleImpact, TAG_PARTICLES_NETBALL}, + {gBattleAnimSpritePal_CircleImpact, TAG_PARTICLES_DIVEBALL}, + {gBattleAnimSpritePal_CircleImpact, TAG_PARTICLES_NESTBALL}, + {gBattleAnimSpritePal_CircleImpact, TAG_PARTICLES_REPEATBALL}, + {gBattleAnimSpritePal_CircleImpact, TAG_PARTICLES_TIMERBALL}, + {gBattleAnimSpritePal_CircleImpact, TAG_PARTICLES_LUXURYBALL}, + {gBattleAnimSpritePal_CircleImpact, TAG_PARTICLES_PREMIERBALL}, +}; + +const union AnimCmd gAnim_RegularBall[] = //gAnimCmd_840C008 +{ + ANIMCMD_FRAME(0, 1), + ANIMCMD_FRAME(1, 1), + ANIMCMD_FRAME(2, 1), + ANIMCMD_FRAME(0, 1, .hFlip = TRUE), + ANIMCMD_FRAME(2, 1), + ANIMCMD_FRAME(1, 1), + ANIMCMD_JUMP(0), +}; + +const union AnimCmd gAnim_MasterBall[] = //gAnimCmd_840C024 +{ + ANIMCMD_FRAME(3, 1), + ANIMCMD_END, +}; + +const union AnimCmd gAnim_NetDiveBall[] = //gAnimCmd_840C02C +{ + ANIMCMD_FRAME(4, 1), + ANIMCMD_END, +}; + +const union AnimCmd gAnim_NestBall[] = //gAnimCmd_840C034 +{ + ANIMCMD_FRAME(5, 1), + ANIMCMD_END, +}; + +const union AnimCmd gAnim_LuxuryPremierBall[] = //gAnimCmd_840C03C +{ + ANIMCMD_FRAME(6, 4), + ANIMCMD_FRAME(7, 4), + ANIMCMD_JUMP(0), +}; + +const union AnimCmd gAnim_UltraRepeatTimerBall[] = //gAnimCmd_840C048 +{ + ANIMCMD_FRAME(7, 4), + ANIMCMD_END, +}; + +const union AnimCmd *const gAnims_BallParticles[] = //gSpriteAnimTable_840C050 +{ + gAnim_RegularBall, + gAnim_MasterBall, + gAnim_NetDiveBall, + gAnim_NestBall, + gAnim_LuxuryPremierBall, + gAnim_UltraRepeatTimerBall, +}; + +const u8 gBallParticleAnimNums[] = //gUnknown_840C068 +{ + [BALL_POKE] = 0, + [BALL_GREAT] = 0, + [BALL_SAFARI] = 0, + [BALL_ULTRA] = 5, + [BALL_MASTER] = 1, + [BALL_NET] = 2, + [BALL_DIVE] = 2, + [BALL_NEST] = 3, + [BALL_REPEAT] = 5, + [BALL_TIMER] = 5, + [BALL_LUXURY] = 4, + [BALL_PREMIER] = 4, +}; + +const TaskFunc gBallParticleAnimationFuncs[] = //gUnknown_840C074 +{ + PokeBallOpenParticleAnimation, + GreatBallOpenParticleAnimation, + SafariBallOpenParticleAnimation, + UltraBallOpenParticleAnimation, + MasterBallOpenParticleAnimation, + SafariBallOpenParticleAnimation, + DiveBallOpenParticleAnimation, + UltraBallOpenParticleAnimation, + RepeatBallOpenParticleAnimation, + TimerBallOpenParticleAnimation, + GreatBallOpenParticleAnimation, + PremierBallOpenParticleAnimation, +}; + +const struct SpriteTemplate gBallParticlesSpriteTemplates[] = //gUnknown_840C0A4 +{ + { + .tileTag = TAG_PARTICLES_POKEBALL, + .paletteTag = TAG_PARTICLES_POKEBALL, + .oam = &gOamData_AffineOff_ObjNormal_8x8, + .anims = gAnims_BallParticles, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCallbackDummy, + }, + { + .tileTag = TAG_PARTICLES_GREATBALL, + .paletteTag = TAG_PARTICLES_GREATBALL, + .oam = &gOamData_AffineOff_ObjNormal_8x8, + .anims = gAnims_BallParticles, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCallbackDummy, + }, + { + .tileTag = TAG_PARTICLES_SAFARIBALL, + .paletteTag = TAG_PARTICLES_SAFARIBALL, + .oam = &gOamData_AffineOff_ObjNormal_8x8, + .anims = gAnims_BallParticles, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCallbackDummy, + }, + { + .tileTag = TAG_PARTICLES_ULTRABALL, + .paletteTag = TAG_PARTICLES_ULTRABALL, + .oam = &gOamData_AffineOff_ObjNormal_8x8, + .anims = gAnims_BallParticles, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCallbackDummy, + }, + { + .tileTag = TAG_PARTICLES_MASTERBALL, + .paletteTag = TAG_PARTICLES_MASTERBALL, + .oam = &gOamData_AffineOff_ObjNormal_8x8, + .anims = gAnims_BallParticles, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCallbackDummy, + }, + { + .tileTag = TAG_PARTICLES_NETBALL, + .paletteTag = TAG_PARTICLES_NETBALL, + .oam = &gOamData_AffineOff_ObjNormal_8x8, + .anims = gAnims_BallParticles, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCallbackDummy, + }, + { + .tileTag = TAG_PARTICLES_DIVEBALL, + .paletteTag = TAG_PARTICLES_DIVEBALL, + .oam = &gOamData_AffineOff_ObjNormal_8x8, + .anims = gAnims_BallParticles, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCallbackDummy, + }, + { + .tileTag = TAG_PARTICLES_NESTBALL, + .paletteTag = TAG_PARTICLES_NESTBALL, + .oam = &gOamData_AffineOff_ObjNormal_8x8, + .anims = gAnims_BallParticles, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCallbackDummy, + }, + { + .tileTag = TAG_PARTICLES_REPEATBALL, + .paletteTag = TAG_PARTICLES_REPEATBALL, + .oam = &gOamData_AffineOff_ObjNormal_8x8, + .anims = gAnims_BallParticles, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCallbackDummy, + }, + { + .tileTag = TAG_PARTICLES_TIMERBALL, + .paletteTag = TAG_PARTICLES_TIMERBALL, + .oam = &gOamData_AffineOff_ObjNormal_8x8, + .anims = gAnims_BallParticles, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCallbackDummy, + }, + { + .tileTag = TAG_PARTICLES_LUXURYBALL, + .paletteTag = TAG_PARTICLES_LUXURYBALL, + .oam = &gOamData_AffineOff_ObjNormal_8x8, + .anims = gAnims_BallParticles, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCallbackDummy, + }, + { + .tileTag = TAG_PARTICLES_PREMIERBALL, + .paletteTag = TAG_PARTICLES_PREMIERBALL, + .oam = &gOamData_AffineOff_ObjNormal_8x8, + .anims = gAnims_BallParticles, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCallbackDummy, + }, +}; + +const u16 gBallOpenFadeColors[] = //gUnknown_840C1C4 +{ + [BALL_POKE] = RGB(31, 22, 30), + [BALL_GREAT] = RGB(16, 23, 30), + [BALL_SAFARI] = RGB(23, 30, 20), + [BALL_ULTRA] = RGB(31, 31, 15), + [BALL_MASTER] = RGB(23, 20, 28), + [BALL_NET] = RGB(21, 31, 25), + [BALL_DIVE] = RGB(12, 25, 30), + [BALL_NEST] = RGB(30, 27, 10), + [BALL_REPEAT] = RGB(31, 24, 16), + [BALL_TIMER] = RGB(29, 30, 30), + [BALL_LUXURY] = RGB(31, 17, 10), + [BALL_PREMIER] = RGB(31, 9, 10), + + // Garbage data + RGB(0, 0, 0), + RGB(1, 16, 0), + RGB(3, 0, 1), + RGB(1, 8, 0), + RGB(0, 8, 0), + RGB(3, 8, 1), + RGB(6, 8, 1), + RGB(4, 0, 0), +}; + +const struct SpriteTemplate gPokeblockSpriteTemplate = //gUnknown_840C1EC +{ + .tileTag = ANIM_TAG_POKEBLOCK, + .paletteTag = ANIM_TAG_POKEBLOCK, + .oam = &gOamData_AffineOff_ObjNormal_16x16, + .anims = gDummySpriteAnimTable, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = sub_80F1B3C, +}; + +const union AnimCmd gUnknown_840C204[] = +{ + ANIMCMD_FRAME(64, 1), + ANIMCMD_END, +}; + +const union AnimCmd *const gSpriteAnimTable_840C20C[] = { + gUnknown_840C204, +}; + +const struct SpriteTemplate gUnknown_840C210 = +{ + .tileTag = ANIM_TAG_ROCKS, + .paletteTag = ANIM_TAG_ROCKS, + .oam = &gOamData_AffineOff_ObjNormal_32x32, + .anims = gSpriteAnimTable_840C20C, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = sub_80F1B3C, +}; + +extern const struct SpriteTemplate gWishStarSpriteTemplate; +extern const struct SpriteTemplate gMiniTwinklingStarSpriteTemplate; + +// Functions +void sub_80EEC0C(u8 taskId) +{ + struct BattleAnimBgData unknownStruct; + u8 healthBoxSpriteId; + u8 battler; + u8 spriteId1, spriteId2, spriteId3, spriteId4; + + battler = gBattleAnimAttacker; + gBattle_WIN0H = 0; + gBattle_WIN0V = 0; + SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG_ALL | WININ_WIN0_OBJ | WININ_WIN0_CLR | WININ_WIN1_BG_ALL | WININ_WIN1_OBJ | WININ_WIN1_CLR); + SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WIN01_BG0 | WINOUT_WIN01_BG2 | WINOUT_WIN01_BG3 | WINOUT_WIN01_OBJ | WINOUT_WIN01_CLR | WINOUT_WINOBJ_BG_ALL | WINOUT_WINOBJ_OBJ | WINOUT_WINOBJ_CLR); + SetGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_OBJWIN_ON); + SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG1 | BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_ALL); + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(0, 16)); + SetAnimBgAttribute(1, BG_ANIM_PRIORITY, 0); + SetAnimBgAttribute(1, BG_ANIM_SCREEN_SIZE, 0); + SetAnimBgAttribute(1, BG_ANIM_AREA_OVERFLOW_MODE, 1); + SetAnimBgAttribute(1, BG_ANIM_CHAR_BASE_BLOCK, 1); + + healthBoxSpriteId = gHealthboxSpriteIds[battler]; + spriteId1 = gSprites[healthBoxSpriteId].oam.affineParam; + spriteId2 = gSprites[healthBoxSpriteId].data[5]; + spriteId3 = CreateInvisibleSpriteWithCallback(SpriteCallbackDummy); + spriteId4 = CreateInvisibleSpriteWithCallback(SpriteCallbackDummy); + gSprites[healthBoxSpriteId].oam.priority = 1; + gSprites[spriteId1].oam.priority = 1; + gSprites[spriteId2].oam.priority = 1; + gSprites[spriteId3] = gSprites[healthBoxSpriteId]; + gSprites[spriteId4] = gSprites[spriteId1]; + gSprites[spriteId3].oam.objMode = ST_OAM_OBJ_WINDOW; + gSprites[spriteId4].oam.objMode = ST_OAM_OBJ_WINDOW; + gSprites[spriteId3].callback = SpriteCallbackDummy; + gSprites[spriteId4].callback = SpriteCallbackDummy; + + sub_80A6B30(&unknownStruct); + AnimLoadCompressedBgTilemap(unknownStruct.bgId, gUnknown_08C2EA9C); + AnimLoadCompressedBgGfx(unknownStruct.bgId, gUnknown_08C2EA50, unknownStruct.tilesOffset); + LoadCompressedPalette(gCureBubblesPal, unknownStruct.paletteId << 4, 32); + + gBattle_BG1_X = -gSprites[spriteId3].pos1.x + 32; + gBattle_BG1_Y = -gSprites[spriteId3].pos1.y - 32; + gTasks[taskId].data[1] = 640; + gTasks[taskId].data[0] = spriteId3; + gTasks[taskId].data[2] = spriteId4; + gTasks[taskId].func = sub_80EEDF4; +} + +static void sub_80EEDF4(u8 taskId) +{ + u8 spriteId1, spriteId2; + u8 battler; + + battler = gBattleAnimAttacker; + gTasks[taskId].data[13] += gTasks[taskId].data[1]; + gBattle_BG1_Y += (u16)gTasks[taskId].data[13] >> 8; + gTasks[taskId].data[13] &= 0xFF; + + switch (gTasks[taskId].data[15]) + { + case 0: + if (gTasks[taskId].data[11]++ > 1) + { + gTasks[taskId].data[11] = 0; + gTasks[taskId].data[12]++; + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(gTasks[taskId].data[12], 16 - gTasks[taskId].data[12])); + if (gTasks[taskId].data[12] == 8) + gTasks[taskId].data[15]++; + } + break; + case 1: + if (++gTasks[taskId].data[10] == 30) + gTasks[taskId].data[15]++; + break; + case 2: + if (gTasks[taskId].data[11]++ > 1) + { + gTasks[taskId].data[11] = 0; + gTasks[taskId].data[12]--; + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(gTasks[taskId].data[12], 16 - gTasks[taskId].data[12])); + if (gTasks[taskId].data[12] == 0) + { + sub_80A477C(0); + gBattle_WIN0H = 0; + gBattle_WIN0V = 0; + SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG_ALL | WININ_WIN0_OBJ | WININ_WIN0_CLR | WININ_WIN1_BG_ALL | WININ_WIN1_OBJ | WININ_WIN1_CLR); + SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WIN01_BG_ALL | WINOUT_WIN01_OBJ | WINOUT_WIN01_CLR | WINOUT_WINOBJ_BG_ALL | WINOUT_WINOBJ_OBJ | WINOUT_WINOBJ_CLR); + if (!IsContest()) + SetAnimBgAttribute(1, BG_ANIM_CHAR_BASE_BLOCK, 0); + + SetGpuReg(REG_OFFSET_DISPCNT, GetGpuReg(REG_OFFSET_DISPCNT) ^ DISPCNT_OBJWIN_ON); + SetGpuReg(REG_OFFSET_BLDCNT, 0); + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(0, 0)); + DestroySprite(&gSprites[gTasks[taskId].data[0]]); + DestroySprite(&gSprites[gTasks[taskId].data[2]]); + SetAnimBgAttribute(1, BG_ANIM_AREA_OVERFLOW_MODE, 0); + spriteId1 = gSprites[gHealthboxSpriteIds[battler]].oam.affineParam; + spriteId2 = gSprites[gHealthboxSpriteIds[battler]].data[5]; + gSprites[gHealthboxSpriteIds[battler]].oam.priority = 1; + gSprites[spriteId1].oam.priority = 1; + gSprites[spriteId2].oam.priority = 1; + DestroyAnimVisualTask(taskId); + } + } + break; + } +} + +static void sub_80EEFC8(u8 *paletteId1, u8 *paletteId2, u8 battler) +{ + u8 healthBoxSpriteId; + u8 spriteId1, spriteId2; + u16 offset1, offset2; + + healthBoxSpriteId = gHealthboxSpriteIds[battler]; + spriteId1 = gSprites[healthBoxSpriteId].oam.affineParam; + spriteId2 = gSprites[healthBoxSpriteId].data[5]; + *paletteId1 = AllocSpritePalette(0xD709); + *paletteId2 = AllocSpritePalette(0xD70A); + + offset1 = (gSprites[healthBoxSpriteId].oam.paletteNum * 16) + 0x100; + offset2 = (gSprites[spriteId2].oam.paletteNum * 16) + 0x100; + LoadPalette(&gPlttBufferUnfaded[offset1], *paletteId1 * 16 + 0x100, 0x20); + LoadPalette(&gPlttBufferUnfaded[offset2], *paletteId2 * 16 + 0x100, 0x20); + + gSprites[healthBoxSpriteId].oam.paletteNum = *paletteId1; + gSprites[spriteId1].oam.paletteNum = *paletteId1; + gSprites[spriteId2].oam.paletteNum = *paletteId2; +} + +void sub_80EF0B4(u8 taskId) +{ + u8 paletteId1, paletteId2; + sub_80EEFC8(&paletteId1, &paletteId2, gBattleAnimAttacker); + DestroyAnimVisualTask(taskId); +} + +static void sub_80EF0E0(u8 battler) +{ + u8 healthBoxSpriteId; + u8 spriteId1, spriteId2; + u8 paletteId1, paletteId2; + + healthBoxSpriteId = gHealthboxSpriteIds[battler]; + spriteId1 = gSprites[healthBoxSpriteId].oam.affineParam; + spriteId2 = gSprites[healthBoxSpriteId].data[5]; + + FreeSpritePaletteByTag(0xD709); + FreeSpritePaletteByTag(0xD70A); + paletteId1 = IndexOfSpritePaletteTag(0xD6FF); + paletteId2 = IndexOfSpritePaletteTag(0xD704); + gSprites[healthBoxSpriteId].oam.paletteNum = paletteId1; + gSprites[spriteId1].oam.paletteNum = paletteId1; + gSprites[spriteId2].oam.paletteNum = paletteId2; +} + +void sub_80EF180(u8 taskId) +{ + sub_80EF0E0(gBattleAnimAttacker); + DestroyAnimVisualTask(taskId); +} + +void sub_80EF1A0(u8 taskId) +{ + gTasks[taskId].data[10] = gBattleAnimArgs[0]; + gTasks[taskId].data[11] = gBattleAnimArgs[1]; + gTasks[taskId].func = sub_80EF1CC; +} + +static void sub_80EF1CC(u8 taskId) +{ + u8 paletteNum; + int paletteOffset, colorOffset; + + gTasks[taskId].data[0]++; + if (gTasks[taskId].data[0]++ >= gTasks[taskId].data[11]) + { + gTasks[taskId].data[0] = 0; + paletteNum = IndexOfSpritePaletteTag(0xD709); + colorOffset = gTasks[taskId].data[10] == 0 ? 6 : 2; + switch (gTasks[taskId].data[1]) + { + case 0: + gTasks[taskId].data[2] += 2; + if (gTasks[taskId].data[2] > 16) + gTasks[taskId].data[2] = 16; + + paletteOffset = paletteNum * 16 + 0x100; + BlendPalette(paletteOffset + colorOffset, 1, gTasks[taskId].data[2], RGB(20, 27, 31)); + if (gTasks[taskId].data[2] == 16) + gTasks[taskId].data[1]++; + break; + case 1: + gTasks[taskId].data[2] -= 2; + if (gTasks[taskId].data[2] < 0) + gTasks[taskId].data[2] = 0; + + paletteOffset = paletteNum * 16 + 0x100; + BlendPalette(paletteOffset + colorOffset, 1, gTasks[taskId].data[2], RGB(20, 27, 31)); + if (gTasks[taskId].data[2] == 0) + DestroyAnimVisualTask(taskId); + break; + } + } +} + +void sub_80EF298(u8 taskId) +{ + u8 spriteId; + + spriteId = gBattlerSpriteIds[gBattleAnimAttacker]; + switch (gTasks[taskId].data[0]) + { + case 0: + PrepareBattlerSpriteForRotScale(spriteId, ST_OAM_OBJ_NORMAL); + gTasks[taskId].data[10] = 0x100; + gTasks[taskId].data[0]++; + break; + case 1: + gTasks[taskId].data[10] += 0x30; + SetSpriteRotScale(spriteId, gTasks[taskId].data[10], gTasks[taskId].data[10], 0); + SetBattlerSpriteYOffsetFromYScale(spriteId); + if (gTasks[taskId].data[10] >= 0x2D0) + gTasks[taskId].data[0]++; + break; + case 2: + ResetSpriteRotScale(spriteId); + gSprites[spriteId].invisible = 1; + DestroyAnimVisualTask(taskId); + break; + } +} + +void sub_80EF344(u8 taskId) +{ + u8 spriteId; + u16 ball; + u8 ballId; + u8 x, y; + u8 priority, subpriority; + u32 selectedPalettes; + + spriteId = gBattlerSpriteIds[gBattleAnimAttacker]; + if (GetBattlerSide(gBattleAnimAttacker) == B_SIDE_PLAYER) + ball = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gBattleAnimAttacker]], MON_DATA_POKEBALL); + else + ball = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattleAnimAttacker]], MON_DATA_POKEBALL); + + ballId = ItemIdToBallId(ball); + switch (gTasks[taskId].data[0]) + { + case 0: + x = GetBattlerSpriteCoord(gBattleAnimAttacker, 0); + y = GetBattlerSpriteCoord(gBattleAnimAttacker, 1); + priority = gSprites[spriteId].oam.priority; + subpriority = gSprites[spriteId].subpriority; + gTasks[taskId].data[10] = AnimateBallOpenParticles(x, y + 32, priority, subpriority, ballId); + selectedPalettes = sub_80A75AC(1, 0, 0, 0, 0, 0, 0); + gTasks[taskId].data[11] = LaunchBallFadeMonTask(0, gBattleAnimAttacker, selectedPalettes, ballId); + gTasks[taskId].data[0]++; + break; + case 1: + if (!gTasks[gTasks[taskId].data[10]].isActive && !gTasks[gTasks[taskId].data[11]].isActive) + DestroyAnimVisualTask(taskId); + break; + } +} + +void sub_80EF490(u8 taskId) +{ + u8 ballId = ItemIdToBallId(gLastUsedItem); + LoadBallGfx(ballId); + DestroyAnimVisualTask(taskId); +} + +void sub_80EF4B8(u8 taskId) +{ + u8 ballId = ItemIdToBallId(gLastUsedItem); + FreeBallGfx(ballId); + DestroyAnimVisualTask(taskId); +} + +void AnimTask_IsBallBlockedByTrainer(u8 taskId) +{ + if (gBattleSpritesDataPtr->animationData->ballThrowCaseId == BALL_TRAINER_BLOCK) + gBattleAnimArgs[ARG_RET_ID] = -1; + else + gBattleAnimArgs[ARG_RET_ID] = 0; + + DestroyAnimVisualTask(taskId); +} + +u8 ItemIdToBallId(u16 ballItem) +{ + switch (ballItem) + { + case ITEM_MASTER_BALL: + return BALL_MASTER; + case ITEM_ULTRA_BALL: + return BALL_ULTRA; + case ITEM_GREAT_BALL: + return BALL_GREAT; + case ITEM_SAFARI_BALL: + return BALL_SAFARI; + case ITEM_NET_BALL: + return BALL_NET; + case ITEM_DIVE_BALL: + return BALL_DIVE; + case ITEM_NEST_BALL: + return BALL_NEST; + case ITEM_REPEAT_BALL: + return BALL_REPEAT; + case ITEM_TIMER_BALL: + return BALL_TIMER; + case ITEM_LUXURY_BALL: + return BALL_LUXURY; + case ITEM_PREMIER_BALL: + return BALL_PREMIER; + case ITEM_POKE_BALL: + default: + return BALL_POKE; + } +} + +void sub_80EF5AC(u8 taskId) +{ + u8 ballId; + u8 spriteId; + + ballId = ItemIdToBallId(gLastUsedItem); + spriteId = CreateSprite(&gBallSpriteTemplates[ballId], 32, 80, 29); + gSprites[spriteId].data[0] = 34; + gSprites[spriteId].data[1] = GetBattlerSpriteCoord(gBattleAnimTarget, 0); + gSprites[spriteId].data[2] = GetBattlerSpriteCoord(gBattleAnimTarget, 1) - 16; + gSprites[spriteId].callback = sub_80EF8C0; + gBattleSpritesDataPtr->animationData->field_9_x2 = gSprites[gBattlerSpriteIds[gBattleAnimTarget]].invisible; + gTasks[taskId].data[0] = spriteId; + gTasks[taskId].func = sub_80EF698; +} + +static void sub_80EF698(u8 taskId) +{ + u8 spriteId = gTasks[taskId].data[0]; + if ((u16)gSprites[spriteId].data[0] == 0xFFFF) + DestroyAnimVisualTask(taskId); +} + +void sub_80EF6D4(u8 taskId) +{ + int x, y; + u8 ballId; + u8 subpriority; + u8 spriteId; + + if (gBattleTypeFlags & BATTLE_TYPE_WALLY_TUTORIAL) + { + x = 32; + y = 11; + } + else + { + x = 23; + y = 5; + } + + ballId = ItemIdToBallId(gLastUsedItem); + subpriority = GetBattlerSpriteSubpriority(GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT)) + 1; + spriteId = CreateSprite(&gBallSpriteTemplates[ballId], x + 32, y | 80, subpriority); + gSprites[spriteId].data[0] = 34; + gSprites[spriteId].data[1] = GetBattlerSpriteCoord(gBattleAnimTarget, 0); + gSprites[spriteId].data[2] = GetBattlerSpriteCoord(gBattleAnimTarget, 1) - 16; + gSprites[spriteId].callback = SpriteCallbackDummy; + gSprites[gBattlerSpriteIds[GetBattlerAtPosition(B_POSITION_PLAYER_LEFT)]].callback = sub_8039E84; + gTasks[taskId].data[0] = spriteId; + gTasks[taskId].func = sub_80EF7EC; +} + +static void sub_80EF7EC(u8 taskId) +{ + if (gSprites[gBattlerSpriteIds[GetBattlerAtPosition(B_POSITION_PLAYER_LEFT)]].animCmdIndex == 1) + { + PlaySE12WithPanning(SE_NAGERU, 0); + gSprites[gTasks[taskId].data[0]].callback = sub_80EF8C0; + CreateTask(sub_80EF864, 10); + gTasks[taskId].func = sub_80EF698; + } +} + +static void sub_80EF864(u8 taskId) +{ + if (gSprites[gBattlerSpriteIds[GetBattlerAtPosition(B_POSITION_PLAYER_LEFT)]].animEnded) + { + StartSpriteAnim(&gSprites[gBattlerSpriteIds[GetBattlerAtPosition(B_POSITION_PLAYER_LEFT)]], 0); + DestroyTask(taskId); + } +} + +static void sub_80EF8C0(struct Sprite *sprite) +{ + u16 temp = sprite->data[1]; + u16 temp2 = sprite->data[2]; + sprite->data[1] = sprite->pos1.x; + sprite->data[2] = temp; + sprite->data[3] = sprite->pos1.y; + sprite->data[4] = temp2; + sprite->data[5] = -40; + InitAnimArcTranslation(sprite); + sprite->callback = sub_80EF8F0; +} + +static void sub_80EF8F0(struct Sprite *sprite) +{ + int i; + u8 ballId; + + if (TranslateAnimHorizontalArc(sprite)) + { + if (gBattleSpritesDataPtr->animationData->ballThrowCaseId == BALL_TRAINER_BLOCK) + { + sprite->callback = sub_80F0478; + } + else if (gBattleSpritesDataPtr->animationData->ballThrowCaseId == BALL_GHOST_DODGE) + { + sprite->callback = sub_80F052C; + } + else + { + StartSpriteAnim(sprite, 1); + sprite->pos1.x += sprite->pos2.x; + sprite->pos1.y += sprite->pos2.y; + sprite->pos2.x = 0; + sprite->pos2.y = 0; + + for (i = 0; i < 8; i++) + sprite->data[i] = 0; + + sprite->data[5] = 0; + sprite->callback = sub_80EF9B4; + + ballId = ItemIdToBallId(gLastUsedItem); + switch (ballId) + { + case 0 ... POKEBALL_COUNT - 1: + AnimateBallOpenParticles(sprite->pos1.x, sprite->pos1.y - 5, 1, 28, ballId); + LaunchBallFadeMonTask(0, gBattleAnimTarget, 14, ballId); + break; + } + } + } +} + +static void sub_80EF9B4(struct Sprite *sprite) +{ + if (++sprite->data[5] == 10) + { + sprite->data[5] = CreateTask(TaskDummy, 50); + sprite->callback = sub_80EFA0C; + gSprites[gBattlerSpriteIds[gBattleAnimTarget]].data[1] = 0; + } +} + +static void sub_80EFA0C(struct Sprite *sprite) +{ + u8 spriteId; + u8 taskId; + + spriteId = gBattlerSpriteIds[gBattleAnimTarget]; + taskId = sprite->data[5]; + + if (++gTasks[taskId].data[1] == 11) + PlaySE(SE_SUIKOMU); + + switch (gTasks[taskId].data[0]) + { + case 0: + PrepareBattlerSpriteForRotScale(spriteId, ST_OAM_OBJ_NORMAL); + gTasks[taskId].data[10] = 256; + gUnknown_3005424 = 28; + gUnknown_300542C = (gSprites[spriteId].pos1.y + gSprites[spriteId].pos2.y) - (sprite->pos1.y + sprite->pos2.y); + gUnknown_3005428 = (u32)(gUnknown_300542C * 256) / 28; + gTasks[taskId].data[2] = gUnknown_3005428; + gTasks[taskId].data[0]++; + break; + case 1: + gTasks[taskId].data[10] += 0x20; + SetSpriteRotScale(spriteId, gTasks[taskId].data[10], gTasks[taskId].data[10], 0); + gTasks[taskId].data[3] += gTasks[taskId].data[2]; + gSprites[spriteId].pos2.y = -gTasks[taskId].data[3] >> 8; + if (gTasks[taskId].data[10] >= 0x480) + gTasks[taskId].data[0]++; + break; + case 2: + ResetSpriteRotScale(spriteId); + gSprites[spriteId].invisible = 1; + gTasks[taskId].data[0]++; + break; + default: + if (gTasks[taskId].data[1] > 10) + { + DestroyTask(taskId); + StartSpriteAnim(sprite, 2); + sprite->data[5] = 0; + sprite->callback = sub_80EFB58; + } + break; + } +} + +static void sub_80EFB58(struct Sprite *sprite) +{ + int angle; + + if (sprite->animEnded) + { + sprite->data[3] = 0; + sprite->data[4] = 40; + sprite->data[5] = 0; + angle = 0; + sprite->pos1.y += Cos(angle, 40); + sprite->pos2.y = -Cos(angle, sprite->data[4]); + sprite->callback = sub_80EFB9C; + } +} + +static void sub_80EFB9C(struct Sprite *sprite) +{ + bool8 lastBounce; + int bounceCount; + + lastBounce = 0; + + switch (sprite->data[3] & 0xFF) + { + case 0: + sprite->pos2.y = -Cos(sprite->data[5], sprite->data[4]); + sprite->data[5] += (sprite->data[3] >> 8) + 4; + if (sprite->data[5] >= 64) + { + sprite->data[4] -= 10; + sprite->data[3] += 257; + + bounceCount = sprite->data[3] >> 8; + if (bounceCount == 4) + lastBounce = 1; + + // Play a different sound effect for each pokeball bounce. + switch (bounceCount) + { + case 1: + PlaySE(SE_KON); + break; + case 2: + PlaySE(SE_KON2); + break; + case 3: + PlaySE(SE_KON3); + break; + default: + PlaySE(SE_KON4); + break; + } + } + break; + case 1: + sprite->pos2.y = -Cos(sprite->data[5], sprite->data[4]); + sprite->data[5] -= (sprite->data[3] >> 8) + 4; + if (sprite->data[5] <= 0) + { + sprite->data[5] = 0; + sprite->data[3] &= -0x100; + } + break; + } + + if (lastBounce) + { + sprite->data[3] = 0; + sprite->pos1.y += Cos(64, 40); + sprite->pos2.y = 0; + if (gBattleSpritesDataPtr->animationData->ballThrowCaseId == BALL_NO_SHAKES) + { + sprite->data[5] = 0; + sprite->callback = sub_80EFF80; + } + else + { + sprite->callback = sub_80EFCA0; + sprite->data[4] = 1; + sprite->data[5] = 0; + } + } +} + +static void sub_80EFCA0(struct Sprite *sprite) +{ + if (++sprite->data[3] == 31) + { + sprite->data[3] = 0; + sprite->affineAnimPaused = 1; + StartSpriteAffineAnim(sprite, 1); + gBattleSpritesDataPtr->animationData->field_C = 0; + sprite->callback = sub_80EFCEC; + PlaySE(SE_BOWA); + } +} + +static void sub_80EFCEC(struct Sprite *sprite) +{ + s8 state; + u16 var0; + + switch (sprite->data[3] & 0xFF) + { + case 0: + if (gBattleSpritesDataPtr->animationData->field_C > 0xFF) + { + sprite->pos2.x += sprite->data[4]; + gBattleSpritesDataPtr->animationData->field_C &= 0xFF; + } + else + { + gBattleSpritesDataPtr->animationData->field_C += 0xB0; + } + + sprite->data[5]++; + sprite->affineAnimPaused = 0; + var0 = sprite->data[5] + 7; + if (var0 > 14) + { + gBattleSpritesDataPtr->animationData->field_C = 0; + sprite->data[3]++; + sprite->data[5] = 0; + } + break; + case 1: + if (++sprite->data[5] == 1) + { + sprite->data[5] = 0; + sprite->data[4] = -sprite->data[4]; + sprite->data[3]++; + sprite->affineAnimPaused = 0; + if (sprite->data[4] < 0) + ChangeSpriteAffineAnim(sprite, 2); + else + ChangeSpriteAffineAnim(sprite, 1); + } + else + { + sprite->affineAnimPaused = 1; + } + break; + case 2: + if (gBattleSpritesDataPtr->animationData->field_C > 0xFF) + { + sprite->pos2.x += sprite->data[4]; + gBattleSpritesDataPtr->animationData->field_C &= 0xFF; + } + else + { + gBattleSpritesDataPtr->animationData->field_C += 0xB0; + } + + sprite->data[5]++; + sprite->affineAnimPaused = 0; + var0 = sprite->data[5] + 12; + if (var0 > 24) + { + gBattleSpritesDataPtr->animationData->field_C = 0; + sprite->data[3]++; + sprite->data[5] = 0; + } + break; + case 3: + if (sprite->data[5]++ < 0) + { + sprite->affineAnimPaused = 1; + break; + } + + sprite->data[5] = 0; + sprite->data[4] = -sprite->data[4]; + sprite->data[3]++; + sprite->affineAnimPaused = 0; + if (sprite->data[4] < 0) + ChangeSpriteAffineAnim(sprite, 2); + else + ChangeSpriteAffineAnim(sprite, 1); + // fall through + case 4: + if (gBattleSpritesDataPtr->animationData->field_C > 0xFF) + { + sprite->pos2.x += sprite->data[4]; + gBattleSpritesDataPtr->animationData->field_C &= 0xFF; + } + else + { + gBattleSpritesDataPtr->animationData->field_C += 0xB0; + } + + sprite->data[5]++; + sprite->affineAnimPaused = 0; + var0 = sprite->data[5] + 4; + if (var0 > 8) + { + gBattleSpritesDataPtr->animationData->field_C = 0; + sprite->data[3]++; + sprite->data[5] = 0; + sprite->data[4] = -sprite->data[4]; + } + break; + case 5: + sprite->data[3] += 0x100; + state = sprite->data[3] >> 8; + if (state == gBattleSpritesDataPtr->animationData->ballThrowCaseId) + { + sprite->affineAnimPaused = 1; + sprite->callback = sub_80EFF80; + } + else + { + if (gBattleSpritesDataPtr->animationData->ballThrowCaseId == BALL_3_SHAKES_SUCCESS && state == 3) + { + sprite->callback = sub_80EFFA4; + sprite->affineAnimPaused = 1; + } + else + { + sprite->data[3]++; + sprite->affineAnimPaused = 1; + } + } + break; + case 6: + default: + if (++sprite->data[5] == 31) + { + sprite->data[5] = 0; + sprite->data[3] &= -0x100; + StartSpriteAffineAnim(sprite, 3); + if (sprite->data[4] < 0) + StartSpriteAffineAnim(sprite, 2); + else + StartSpriteAffineAnim(sprite, 1); + + PlaySE(SE_BOWA); + } + break; + } +} + +static void sub_80EFF80(struct Sprite *sprite) +{ + if (++sprite->data[5] == 31) + { + sprite->data[5] = 0; + sprite->callback = sub_80F02B0; + } +} + +static void sub_80EFFA4(struct Sprite *sprite) +{ + sprite->animPaused = 1; + sprite->callback = sub_80EFFC4; + sprite->data[3] = 0; + sprite->data[4] = 0; + sprite->data[5] = 0; +} + +static void sub_80EFFC4(struct Sprite *sprite) +{ + u8 *battler = &gBattleAnimTarget; + + sprite->data[4]++; + if (sprite->data[4] == 40) + { + PlaySE(SE_RG_GETTING); + BlendPalettes(0x10000 << sprite->oam.paletteNum, 6, RGB(0, 0, 0)); + sub_80F01B8(sprite); + } + else if (sprite->data[4] == 60) + { + BeginNormalPaletteFade(0x10000 << sprite->oam.paletteNum, 2, 6, 0, RGB(0, 0, 0)); + } + else if (sprite->data[4] == 95) + { + gDoingBattleAnim = 0; + UpdateOamPriorityInAllHealthboxes(1); + m4aMPlayAllStop(); + PlaySE(MUS_RG_FAN6); + } + else if (sprite->data[4] == 315) + { + FreeOamMatrix(gSprites[gBattlerSpriteIds[*battler]].oam.matrixNum); + DestroySprite(&gSprites[gBattlerSpriteIds[*battler]]); + sprite->data[0] = 0; + sprite->callback = sub_80F00A4; + } +} + +static void sub_80F00A4(struct Sprite *sprite) +{ + u8 paletteIndex; + + switch (sprite->data[0]) + { + case 0: + sprite->data[1] = 0; + sprite->data[2] = 0; + sprite->oam.objMode = ST_OAM_OBJ_BLEND; + SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_ALL); + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(16, 0)); + paletteIndex = IndexOfSpritePaletteTag(sprite->template->paletteTag); + BeginNormalPaletteFade(1 << (paletteIndex + 0x10), 0, 0, 16, RGB(31, 31, 31)); + sprite->data[0]++; + break; + case 1: + if (sprite->data[1]++ > 0) + { + sprite->data[1] = 0; + sprite->data[2]++; + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(16 - sprite->data[2], sprite->data[2])); + if (sprite->data[2] == 16) + sprite->data[0]++; + } + break; + case 2: + sprite->invisible = 1; + sprite->data[0]++; + break; + default: + if (!gPaletteFade.active) + { + SetGpuReg(REG_OFFSET_BLDCNT, 0); + SetGpuReg(REG_OFFSET_BLDALPHA, 0); + sprite->data[0] = 0; + sprite->callback = sub_80F018C; + } + break; + } +} + +static void sub_80F018C(struct Sprite *sprite) +{ + if (sprite->data[0] == 0) + { + sprite->data[0] = -1; + } + else + { + FreeSpriteOamMatrix(sprite); + DestroySprite(sprite); + } +} + +static void sub_80F01B8(struct Sprite *sprite) +{ + u32 i; + u8 subpriority; + + if (sprite->subpriority) + { + subpriority = sprite->subpriority - 1; + } + else + { + subpriority = 0; + sprite->subpriority = 1; + } + + sub_80F05B4(4); + for (i = 0; i < 3; i++) + { + u8 spriteId = CreateSprite(&gBallParticlesSpriteTemplates[4], sprite->pos1.x, sprite->pos1.y, subpriority); + if (spriteId != MAX_SPRITES) + { + gSprites[spriteId].data[0] = 24; + gSprites[spriteId].data[2] = sprite->pos1.x + sBallCaptureSuccessStarData[i].xOffset; + gSprites[spriteId].data[4] = sprite->pos1.y + sBallCaptureSuccessStarData[i].yOffset; + gSprites[spriteId].data[5] = sBallCaptureSuccessStarData[i].unk2; + InitAnimArcTranslation(&gSprites[spriteId]); + gSprites[spriteId].callback = sub_80F0278; + StartSpriteAnim(&gSprites[spriteId], gBallParticleAnimNums[4]); + } + } +} + +static void sub_80F0278(struct Sprite *sprite) +{ + sprite->invisible = !sprite->invisible; + if (TranslateAnimHorizontalArc(sprite)) + DestroySprite(sprite); +} + +static void sub_80F02B0(struct Sprite *sprite) +{ + u8 ballId; + + StartSpriteAnim(sprite, 1); + StartSpriteAffineAnim(sprite, 0); + sprite->callback = sub_80F0378; + + ballId = ItemIdToBallId(gLastUsedItem); + switch (ballId) + { + case 0 ... POKEBALL_COUNT - 1: + AnimateBallOpenParticles(sprite->pos1.x, sprite->pos1.y - 5, 1, 28, ballId); + LaunchBallFadeMonTask(1, gBattleAnimTarget, 14, ballId); + break; + } + + gSprites[gBattlerSpriteIds[gBattleAnimTarget]].invisible = 0; + StartSpriteAffineAnim(&gSprites[gBattlerSpriteIds[gBattleAnimTarget]], 1); + AnimateSprite(&gSprites[gBattlerSpriteIds[gBattleAnimTarget]]); + gSprites[gBattlerSpriteIds[gBattleAnimTarget]].data[1] = 0x1000; +} + +static void sub_80F0378(struct Sprite *sprite) +{ + int next = FALSE; + + if (sprite->animEnded) + sprite->invisible = 1; + + if (gSprites[gBattlerSpriteIds[gBattleAnimTarget]].affineAnimEnded) + { + StartSpriteAffineAnim(&gSprites[gBattlerSpriteIds[gBattleAnimTarget]], 0); + next = TRUE; + } + else + { + gSprites[gBattlerSpriteIds[gBattleAnimTarget]].data[1] -= 288; + gSprites[gBattlerSpriteIds[gBattleAnimTarget]].pos2.y = gSprites[gBattlerSpriteIds[gBattleAnimTarget]].data[1] >> 8; + } + + if (sprite->animEnded && next) + { + gSprites[gBattlerSpriteIds[gBattleAnimTarget]].pos2.y = 0; + gSprites[gBattlerSpriteIds[gBattleAnimTarget]].invisible = gBattleSpritesDataPtr->animationData->field_9_x2; + sprite->data[0] = 0; + sprite->callback = sub_80F018C; + gDoingBattleAnim = 0; + UpdateOamPriorityInAllHealthboxes(1); + } +} + +static void sub_80F0478(struct Sprite *sprite) +{ + int i; + + sprite->pos1.x += sprite->pos2.x; + sprite->pos1.y += sprite->pos2.y; + sprite->pos2.y = 0; + sprite->pos2.x = 0; + for (i = 0; i < 6; i++) + sprite->data[i] = 0; + + sprite->callback = sub_80F04B4; +} + +static void sub_80F04B4(struct Sprite *sprite) +{ + s16 var0 = sprite->data[0] + 0x800; + s16 var1 = sprite->data[1] + 0x680; + sprite->pos2.x -= var1 >> 8; + sprite->pos2.y += var0 >> 8; + sprite->data[0] = (sprite->data[0] + 0x800) & 0xFF; + sprite->data[1] = (sprite->data[1] + 0x680) & 0xFF; + + if (sprite->pos1.y + sprite->pos2.y > 160 + || sprite->pos1.x + sprite->pos2.x < -8) + { + sprite->data[0] = 0; + sprite->callback = sub_80F018C; + gDoingBattleAnim = 0; + UpdateOamPriorityInAllHealthboxes(1); + } +} + +// GhostBallDodge +static void sub_80F052C(struct Sprite *sprite) +{ + // to do +} + +static void sub_80F0574(struct Sprite *sprite) +{ + //to do +} + +static void sub_80F05B4(u8 ballId) +{ + u8 taskId; + + if (GetSpriteTileStartByTag(gBallParticleSpritesheets[ballId].tag) == 0xFFFF) + { + LoadCompressedSpriteSheetUsingHeap(&gBallParticleSpritesheets[ballId]); + LoadCompressedSpritePaletteUsingHeap(&gBallParticlePalettes[ballId]); + } +} + +u8 AnimateBallOpenParticles(u8 x, u8 y, u8 priority, u8 subpriority, u8 ballId) +{ + u8 taskId; + + sub_80F05B4(ballId); + taskId = CreateTask(gBallParticleAnimationFuncs[ballId], 5); + gTasks[taskId].data[1] = x; + gTasks[taskId].data[2] = y; + gTasks[taskId].data[3] = priority; + gTasks[taskId].data[4] = subpriority; + gTasks[taskId].data[15] = ballId; + PlaySE(SE_BOWA2); + + return taskId; +} + +void sub_80F0674(void) +{ + if (gMain.inBattle) + gBattleSpritesDataPtr->animationData->field_A++; +} + +static void PokeBallOpenParticleAnimation(u8 taskId) +{ + u8 spriteId; + u8 x, y; + u8 priority, subpriority; + u8 ballId; + u8 var0; + + ballId = gTasks[taskId].data[15]; + if (gTasks[taskId].data[0] < 16) + { + x = gTasks[taskId].data[1]; + y = gTasks[taskId].data[2]; + priority = gTasks[taskId].data[3]; + subpriority = gTasks[taskId].data[4]; + + spriteId = CreateSprite(&gBallParticlesSpriteTemplates[ballId], x, y, subpriority); + if (spriteId != MAX_SPRITES) + { + sub_80F0674(); + StartSpriteAnim(&gSprites[spriteId], gBallParticleAnimNums[ballId]); + gSprites[spriteId].callback = PokeBallOpenParticleAnimation_Step1; + gSprites[spriteId].oam.priority = priority; + + var0 = (u8)gTasks[taskId].data[0]; + if (var0 >= 8) + var0 -= 8; + + gSprites[spriteId].data[0] = var0 * 32; + } + + if (gTasks[taskId].data[0] == 15) + { + if (!gMain.inBattle) + gSprites[spriteId].data[7] = 1; + + DestroyTask(taskId); + return; + } + } + + gTasks[taskId].data[0]++; +} + +static void PokeBallOpenParticleAnimation_Step1(struct Sprite *sprite) +{ + if (sprite->data[1] == 0) + sprite->callback = PokeBallOpenParticleAnimation_Step2; + else + sprite->data[1]--; +} + +static void PokeBallOpenParticleAnimation_Step2(struct Sprite *sprite) +{ + sprite->pos2.x = Sin(sprite->data[0], sprite->data[1]); + sprite->pos2.y = Cos(sprite->data[0], sprite->data[1]); + sprite->data[1] += 2; + if (sprite->data[1] == 50) + DestroyBallOpenAnimationParticle(sprite); +} + +static void TimerBallOpenParticleAnimation(u8 taskId) +{ + u8 i; + u8 x, y, priority, subpriority, ballId; + u8 spriteId; + + ballId = gTasks[taskId].data[15]; + x = gTasks[taskId].data[1]; + y = gTasks[taskId].data[2]; + priority = gTasks[taskId].data[3]; + subpriority = gTasks[taskId].data[4]; + + for (i = 0; i < 8; i++) + { + spriteId = CreateSprite(&gBallParticlesSpriteTemplates[ballId], x, y, subpriority); + if (spriteId != MAX_SPRITES) + { + sub_80F0674(); + StartSpriteAnim(&gSprites[spriteId], gBallParticleAnimNums[ballId]); + gSprites[spriteId].callback = FanOutBallOpenParticles_Step1; + gSprites[spriteId].oam.priority = priority; + gSprites[spriteId].data[0] = i * 32; + gSprites[spriteId].data[4] = 10; + gSprites[spriteId].data[5] = 2; + gSprites[spriteId].data[6] = 1; + } + } + + if (!gMain.inBattle) + gSprites[spriteId].data[7] = 1; + + DestroyTask(taskId); +} + +static void DiveBallOpenParticleAnimation(u8 taskId) +{ + u8 i; + u8 x, y, priority, subpriority, ballId; + u8 spriteId; + + ballId = gTasks[taskId].data[15]; + x = gTasks[taskId].data[1]; + y = gTasks[taskId].data[2]; + priority = gTasks[taskId].data[3]; + subpriority = gTasks[taskId].data[4]; + + for (i = 0; i < 8; i++) + { + spriteId = CreateSprite(&gBallParticlesSpriteTemplates[ballId], x, y, subpriority); + if (spriteId != MAX_SPRITES) + { + sub_80F0674(); + StartSpriteAnim(&gSprites[spriteId], gBallParticleAnimNums[ballId]); + gSprites[spriteId].callback = FanOutBallOpenParticles_Step1; + gSprites[spriteId].oam.priority = priority; + gSprites[spriteId].data[0] = i * 32; + gSprites[spriteId].data[4] = 10; + gSprites[spriteId].data[5] = 1; + gSprites[spriteId].data[6] = 2; + } + } + + if (!gMain.inBattle) + gSprites[spriteId].data[7] = 1; + + DestroyTask(taskId); +} + +// Also used for Net Ball +static void SafariBallOpenParticleAnimation(u8 taskId) +{ + u8 i; + u8 x, y, priority, subpriority, ballId; + u8 spriteId; + + ballId = gTasks[taskId].data[15]; + x = gTasks[taskId].data[1]; + y = gTasks[taskId].data[2]; + priority = gTasks[taskId].data[3]; + subpriority = gTasks[taskId].data[4]; + + for (i = 0; i < 8; i++) + { + spriteId = CreateSprite(&gBallParticlesSpriteTemplates[ballId], x, y, subpriority); + if (spriteId != MAX_SPRITES) + { + sub_80F0674(); + StartSpriteAnim(&gSprites[spriteId], gBallParticleAnimNums[ballId]); + gSprites[spriteId].callback = FanOutBallOpenParticles_Step1; + gSprites[spriteId].oam.priority = priority; + gSprites[spriteId].data[0] = i * 32; + gSprites[spriteId].data[4] = 4; + gSprites[spriteId].data[5] = 1; + gSprites[spriteId].data[6] = 1; + } + } + + if (!gMain.inBattle) + gSprites[spriteId].data[7] = 1; + + DestroyTask(taskId); +} + +// Also used for Nest Ball +static void UltraBallOpenParticleAnimation(u8 taskId) +{ + u8 i; + u8 x, y, priority, subpriority, ballId; + u8 spriteId; + + ballId = gTasks[taskId].data[15]; + x = gTasks[taskId].data[1]; + y = gTasks[taskId].data[2]; + priority = gTasks[taskId].data[3]; + subpriority = gTasks[taskId].data[4]; + + for (i = 0; i < 10; i++) + { + spriteId = CreateSprite(&gBallParticlesSpriteTemplates[ballId], x, y, subpriority); + if (spriteId != MAX_SPRITES) + { + sub_80F0674(); + StartSpriteAnim(&gSprites[spriteId], gBallParticleAnimNums[ballId]); + gSprites[spriteId].callback = FanOutBallOpenParticles_Step1; + gSprites[spriteId].oam.priority = priority; + gSprites[spriteId].data[0] = i * 25; + gSprites[spriteId].data[4] = 5; + gSprites[spriteId].data[5] = 1; + gSprites[spriteId].data[6] = 1; + } + } + + if (!gMain.inBattle) + gSprites[spriteId].data[7] = 1; + + DestroyTask(taskId); +} + +// Also used for Luxury Ball +static void GreatBallOpenParticleAnimation(u8 taskId) +{ + u8 i; + u8 x, y, priority, subpriority, ballId; + u8 spriteId; + + if (gTasks[taskId].data[7]) + { + gTasks[taskId].data[7]--; + } + else + { + ballId = gTasks[taskId].data[15]; + x = gTasks[taskId].data[1]; + y = gTasks[taskId].data[2]; + priority = gTasks[taskId].data[3]; + subpriority = gTasks[taskId].data[4]; + + for (i = 0; i < 8; i++) + { + spriteId = CreateSprite(&gBallParticlesSpriteTemplates[ballId], x, y, subpriority); + if (spriteId != MAX_SPRITES) + { + sub_80F0674(); + StartSpriteAnim(&gSprites[spriteId], gBallParticleAnimNums[ballId]); + gSprites[spriteId].callback = FanOutBallOpenParticles_Step1; + gSprites[spriteId].oam.priority = priority; + gSprites[spriteId].data[0] = i * 32; + gSprites[spriteId].data[4] = 8; + gSprites[spriteId].data[5] = 2; + gSprites[spriteId].data[6] = 2; + } + } + + gTasks[taskId].data[7] = 8; + if (++gTasks[taskId].data[0] == 2) + { + if (!gMain.inBattle) + gSprites[spriteId].data[7] = 1; + + DestroyTask(taskId); + } + } +} + +static void FanOutBallOpenParticles_Step1(struct Sprite *sprite) +{ + sprite->pos2.x = Sin(sprite->data[0], sprite->data[1]); + sprite->pos2.y = Cos(sprite->data[0], sprite->data[2]); + sprite->data[0] = (sprite->data[0] + sprite->data[4]) & 0xFF; + sprite->data[1] += sprite->data[5]; + sprite->data[2] += sprite->data[6]; + if (++sprite->data[3] == 51) + DestroyBallOpenAnimationParticle(sprite); +} + +static void RepeatBallOpenParticleAnimation(u8 taskId) +{ + u8 i; + u8 x, y, priority, subpriority, ballId; + u8 spriteId; + + ballId = gTasks[taskId].data[15]; + x = gTasks[taskId].data[1]; + y = gTasks[taskId].data[2]; + priority = gTasks[taskId].data[3]; + subpriority = gTasks[taskId].data[4]; + + for (i = 0; i < POKEBALL_COUNT; i++) + { + spriteId = CreateSprite(&gBallParticlesSpriteTemplates[ballId], x, y, subpriority); + if (spriteId != MAX_SPRITES) + { + sub_80F0674(); + StartSpriteAnim(&gSprites[spriteId], gBallParticleAnimNums[ballId]); + gSprites[spriteId].callback = RepeatBallOpenParticleAnimation_Step1; + gSprites[spriteId].oam.priority = priority; + gSprites[spriteId].data[0] = i * 21; + } + } + + if (!gMain.inBattle) + gSprites[spriteId].data[7] = 1; + + DestroyTask(taskId); +} + +static void RepeatBallOpenParticleAnimation_Step1(struct Sprite *sprite) +{ + sprite->pos2.x = Sin(sprite->data[0], sprite->data[1]); + sprite->pos2.y = Cos(sprite->data[0], Sin(sprite->data[0], sprite->data[2])); + sprite->data[0] = (sprite->data[0] + 6) & 0xFF; + sprite->data[1]++; + sprite->data[2]++; + if (++sprite->data[3] == 51) + DestroyBallOpenAnimationParticle(sprite); +} + +static void MasterBallOpenParticleAnimation(u8 taskId) +{ + u8 i, j; + u8 x, y, priority, subpriority, ballId; + u8 spriteId; + + ballId = gTasks[taskId].data[15]; + x = gTasks[taskId].data[1]; + y = gTasks[taskId].data[2]; + priority = gTasks[taskId].data[3]; + subpriority = gTasks[taskId].data[4]; + + for (j = 0; j < 2; j++) + { + for (i = 0; i < 8; i++) + { + spriteId = CreateSprite(&gBallParticlesSpriteTemplates[ballId], x, y, subpriority); + if (spriteId != MAX_SPRITES) + { + sub_80F0674(); + StartSpriteAnim(&gSprites[spriteId], gBallParticleAnimNums[ballId]); + gSprites[spriteId].callback = FanOutBallOpenParticles_Step1; + gSprites[spriteId].oam.priority = priority; + gSprites[spriteId].data[0] = i * 32; + gSprites[spriteId].data[4] = 8; + + if (j == 0) + { + gSprites[spriteId].data[5] = 2; + gSprites[spriteId].data[6] = 1; + } + else + { + gSprites[spriteId].data[5] = 1; + gSprites[spriteId].data[6] = 2; + } + } + } + } + + if (!gMain.inBattle) + gSprites[spriteId].data[7] = 1; + + DestroyTask(taskId); +} + +static void PremierBallOpenParticleAnimation(u8 taskId) +{ + u8 i; + u8 x, y, priority, subpriority, ballId; + u8 spriteId; + + ballId = gTasks[taskId].data[15]; + x = gTasks[taskId].data[1]; + y = gTasks[taskId].data[2]; + priority = gTasks[taskId].data[3]; + subpriority = gTasks[taskId].data[4]; + + for (i = 0; i < 8; i++) + { + spriteId = CreateSprite(&gBallParticlesSpriteTemplates[ballId], x, y, subpriority); + if (spriteId != MAX_SPRITES) + { + sub_80F0674(); + StartSpriteAnim(&gSprites[spriteId], gBallParticleAnimNums[ballId]); + gSprites[spriteId].callback = PremierBallOpenParticleAnimation_Step1; + gSprites[spriteId].oam.priority = priority; + gSprites[spriteId].data[0] = i * 32; + } + } + + if (!gMain.inBattle) + gSprites[spriteId].data[7] = 1; + + DestroyTask(taskId); +} + +static void PremierBallOpenParticleAnimation_Step1(struct Sprite *sprite) +{ + sprite->pos2.x = Sin(sprite->data[0], sprite->data[1]); + sprite->pos2.y = Cos(sprite->data[0], Sin(sprite->data[0] & 0x3F, sprite->data[2])); + sprite->data[0] = (sprite->data[0] + 10) & 0xFF; + sprite->data[1]++; + sprite->data[2]++; + if (++sprite->data[3] == 51) + DestroyBallOpenAnimationParticle(sprite); +} + +static void DestroyBallOpenAnimationParticle(struct Sprite *sprite) +{ + int i, j; + + if (!gMain.inBattle) + { + if (sprite->data[7] == 1) + DestroySpriteAndFreeResources(sprite); + else + DestroySprite(sprite); + } + else + { + gBattleSpritesDataPtr->animationData->field_A--; + if (gBattleSpritesDataPtr->animationData->field_A == 0) + { + for (i = 0; i < POKEBALL_COUNT; i++) + { + if (FuncIsActiveTask(gBallParticleAnimationFuncs[i]) == TRUE) + break; + } + + if (i == POKEBALL_COUNT) + { + for (j = 0; j < POKEBALL_COUNT; j++) + { + FreeSpriteTilesByTag(gBallParticleSpritesheets[j].tag); + FreeSpritePaletteByTag(gBallParticlePalettes[j].tag); + } + } + + DestroySprite(sprite); + } + else + { + DestroySprite(sprite); + } + } +} + +u8 LaunchBallFadeMonTask(u8 unfadeLater, u8 battler, u32 selectedPalettes, u8 ballId) +{ + u8 taskId; + + taskId = CreateTask(sub_80F12E0, 5); + gTasks[taskId].data[15] = ballId; + gTasks[taskId].data[3] = battler; + gTasks[taskId].data[10] = selectedPalettes; + gTasks[taskId].data[11] = selectedPalettes >> 16; + + if (!unfadeLater) + { + BlendPalette(battler * 16 + 0x100, 16, 0, gBallOpenFadeColors[ballId]); + gTasks[taskId].data[1] = 1; + } + else + { + BlendPalette(battler * 16 + 0x100, 16, 16, gBallOpenFadeColors[ballId]); + gTasks[taskId].data[0] = 16; + gTasks[taskId].data[1] = -1; + gTasks[taskId].func = sub_80F1370; + } + + BeginNormalPaletteFade(selectedPalettes, 0, 0, 16, RGB(31, 31, 31)); + return taskId; +} + +static void sub_80F12E0(u8 taskId) +{ + u8 ballId = gTasks[taskId].data[15]; + + if (gTasks[taskId].data[2] <= 16) + { + BlendPalette(gTasks[taskId].data[3] * 16 + 0x100, 16, gTasks[taskId].data[0], gBallOpenFadeColors[ballId]); + gTasks[taskId].data[0] += gTasks[taskId].data[1]; + gTasks[taskId].data[2]++; + } + else if (!gPaletteFade.active) + { + u32 selectedPalettes = (u16)gTasks[taskId].data[10] | ((u16)gTasks[taskId].data[11] << 16); + BeginNormalPaletteFade(selectedPalettes, 0, 16, 0, RGB(31, 31, 31)); + DestroyTask(taskId); + } +} + +static void sub_80F1370(u8 taskId) +{ + if (!gPaletteFade.active) + { + u32 selectedPalettes = (u16)gTasks[taskId].data[10] | ((u16)gTasks[taskId].data[11] << 16); + BeginNormalPaletteFade(selectedPalettes, 0, 16, 0, RGB(31, 31, 31)); + gTasks[taskId].func = sub_80F13C0; + } +} + +static void sub_80F13C0(u8 taskId) +{ + u8 ballId = gTasks[taskId].data[15]; + + if (gTasks[taskId].data[2] <= 16) + { + BlendPalette(gTasks[taskId].data[3] * 16 + 0x100, 16, gTasks[taskId].data[0], gBallOpenFadeColors[ballId]); + gTasks[taskId].data[0] += gTasks[taskId].data[1]; + gTasks[taskId].data[2]++; + } + else + { + DestroyTask(taskId); + } +} + +void sub_80F1420(u8 taskId) +{ + u8 spriteId; + u32 x; + u32 done = FALSE; + + spriteId = gBattlerSpriteIds[gBattleAnimAttacker]; + switch (gTasks[taskId].data[10]) + { + case 0: + gTasks[taskId].data[11] = gBattleAnimArgs[0]; + gTasks[taskId].data[0] += 0x500; + if (GetBattlerSide(gBattleAnimAttacker) != B_SIDE_PLAYER) + gSprites[spriteId].pos2.x += gTasks[taskId].data[0] >> 8; + else + gSprites[spriteId].pos2.x -= gTasks[taskId].data[0] >> 8; + + gTasks[taskId].data[0] &= 0xFF; + x = gSprites[spriteId].pos1.x + gSprites[spriteId].pos2.x + 32; + if (x > 304) + gTasks[taskId].data[10]++; + break; + case 1: + LoadBattleMonGfxAndAnimate(gBattleAnimAttacker, gTasks[taskId].data[11], spriteId); + gTasks[taskId].data[10]++; + break; + case 2: + gTasks[taskId].data[0] += 0x500; + if (GetBattlerSide(gBattleAnimAttacker) != B_SIDE_PLAYER) + gSprites[spriteId].pos2.x -= gTasks[taskId].data[0] >> 8; + else + gSprites[spriteId].pos2.x += gTasks[taskId].data[0] >> 8; + + gTasks[taskId].data[0] &= 0xFF; + if (GetBattlerSide(gBattleAnimAttacker) != B_SIDE_PLAYER) + { + if (gSprites[spriteId].pos2.x <= 0) + { + gSprites[spriteId].pos2.x = 0; + done = TRUE; + } + } + else + { + if (gSprites[spriteId].pos2.x >= 0) + { + gSprites[spriteId].pos2.x = 0; + done = TRUE; + } + } + + if (done) + DestroyAnimVisualTask(taskId); + + break; + } +} + +void sub_80F15C8(u8 taskId) +{ + u8 spriteId; + + switch (gTasks[taskId].data[15]) + { + case 0: + if (GetBattlerSpriteBGPriorityRank(gBattleAnimAttacker) == B_POSITION_OPPONENT_LEFT) + SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG1 | BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_ALL); + else + SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG2 | BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_ALL); + + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(16, 0)); + gTasks[taskId].data[15]++; + break; + case 1: + if (gTasks[taskId].data[1]++ > 1) + { + gTasks[taskId].data[1] = 0; + gTasks[taskId].data[0]++; + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(16 - gTasks[taskId].data[0], gTasks[taskId].data[0])); + if (gTasks[taskId].data[0] == 16) + gTasks[taskId].data[15]++; + } + break; + case 2: + spriteId = gBattlerSpriteIds[gBattleAnimAttacker]; + RequestDma3Fill(0, (void *)OBJ_VRAM0 + gSprites[spriteId].oam.tileNum * TILE_SIZE_4BPP, 0x800, 1); + ClearBehindSubstituteBit(gBattleAnimAttacker); + DestroyAnimVisualTask(taskId); + break; + } +} + +void AnimTask_IsAttackerBehindSubstitute(u8 taskId) +{ + gBattleAnimArgs[ARG_RET_ID] = gBattleSpritesDataPtr->battlerData[gBattleAnimAttacker].behindSubstitute; + DestroyAnimVisualTask(taskId); +} + +void AnimTask_TargetToEffectBattler(u8 taskId) +{ + gBattleAnimTarget = gEffectBattler; + DestroyAnimVisualTask(taskId); +} + +void sub_80F1720(u8 battler, struct Pokemon *mon) +{ + int isShiny; + u32 otId, personality; + u32 shinyValue; + u8 taskId1, taskId2; + + isShiny = 0; + gBattleSpritesDataPtr->healthBoxesData[battler].flag_x80 = 1; + otId = GetMonData(mon, MON_DATA_OT_ID); + personality = GetMonData(mon, MON_DATA_PERSONALITY); + + if (IsBattlerSpriteVisible(battler)) + { + shinyValue = HIHALF(otId) ^ LOHALF(otId) ^ HIHALF(personality) ^ LOHALF(personality); + if (shinyValue < SHINY_ODDS) + isShiny = TRUE; + + if (isShiny) + { + if (GetSpriteTileStartByTag(ANIM_TAG_GOLD_STARS) == 0xFFFF) + { + LoadCompressedSpriteSheetUsingHeap(&gBattleAnimPicTable[ANIM_TAG_GOLD_STARS - ANIM_SPRITES_START]); + LoadCompressedSpritePaletteUsingHeap(&gBattleAnimPaletteTable[ANIM_TAG_GOLD_STARS - ANIM_SPRITES_START]); + } + + taskId1 = CreateTask(sub_80F181C, 10); + taskId2 = CreateTask(sub_80F181C, 10); + gTasks[taskId1].data[0] = battler; + gTasks[taskId2].data[0] = battler; + gTasks[taskId1].data[1] = 0; + gTasks[taskId2].data[1] = 1; + return; + } + } + + gBattleSpritesDataPtr->healthBoxesData[battler].field_1_x1 = 1; +} + +static void sub_80F181C(u8 taskId) +{ + u8 battler; + u8 x, y; + u8 spriteId; + u16 counter; + s16 state; + u8 pan; + + if (gTasks[taskId].data[13] < 60) + { + gTasks[taskId].data[13]++; + return; + } + + if (gBattleSpritesDataPtr->animationData->field_A) + return; + + counter = gTasks[taskId].data[10]++; + if (counter & 3) + return; + + battler = gTasks[taskId].data[0]; + x = GetBattlerSpriteCoord(battler, 0); + y = GetBattlerSpriteCoord(battler, 1); + state = gTasks[taskId].data[11]; + if (state == 0) + { + spriteId = CreateSprite(&gWishStarSpriteTemplate, x, y, 5); + } + else if (state >= 0 && gTasks[taskId].data[11] < 4) + { + spriteId = CreateSprite(&gMiniTwinklingStarSpriteTemplate, x, y, 5); + gSprites[spriteId].oam.tileNum += 4; + } + else + { + spriteId = CreateSprite(&gMiniTwinklingStarSpriteTemplate, x, y, 5); + gSprites[spriteId].oam.tileNum += 5; + } + + if (gTasks[taskId].data[1] == 0) + { + gSprites[spriteId].callback = sub_80F1A2C; + } + else + { + gSprites[spriteId].callback = sub_80F1A80; + gSprites[spriteId].pos2.x = -32; + gSprites[spriteId].pos2.y = 32; + gSprites[spriteId].invisible = 1; + if (gTasks[taskId].data[11] == 0) + { + if (GetBattlerSide(battler) == B_SIDE_PLAYER) + pan = -64; + else + pan = 63; + + PlaySE12WithPanning(SE_REAPOKE, pan); + } + } + + gSprites[spriteId].data[0] = taskId; + gTasks[taskId].data[11]++; + if (spriteId != MAX_SPRITES) + gTasks[taskId].data[12]++; + + if (gTasks[taskId].data[11] == 5) + gTasks[taskId].func = sub_80F19E0; +} + +static void sub_80F19E0(u8 taskId) +{ + u8 battler; + + if (gTasks[taskId].data[12] == 0) + { + if (gTasks[taskId].data[1] == 1) + { + battler = gTasks[taskId].data[0]; + gBattleSpritesDataPtr->healthBoxesData[battler].field_1_x1 = 1; + } + + DestroyTask(taskId); + } +} + +static void sub_80F1A2C(struct Sprite *sprite) +{ + sprite->pos2.x = Sin(sprite->data[1], 24); + sprite->pos2.y = Cos(sprite->data[1], 24); + sprite->data[1] += 12; + if (sprite->data[1] > 0xFF) + { + gTasks[sprite->data[0]].data[12]--; + FreeSpriteOamMatrix(sprite); + DestroySprite(sprite); + } +} + +static void sub_80F1A80(struct Sprite *sprite) +{ + if (sprite->data[1] < 4) + { + sprite->data[1]++; + } + else + { + sprite->invisible = 0; + sprite->pos2.x += 5; + sprite->pos2.y -= 5; + if (sprite->pos2.x > 32) + { + gTasks[sprite->data[0]].data[12]--; + FreeSpriteOamMatrix(sprite); + DestroySprite(sprite); + } + } +} + +void AnimTask_LoadPokeblockGfx(u8 taskId) +{ + u8 paletteIndex; + + LoadCompressedSpriteSheetUsingHeap(&gBattleAnimPicTable[ANIM_TAG_POKEBLOCK - ANIM_SPRITES_START]); + LoadCompressedSpritePaletteUsingHeap(&gBattleAnimPaletteTable[ANIM_TAG_POKEBLOCK - ANIM_SPRITES_START]); + paletteIndex = IndexOfSpritePaletteTag(ANIM_TAG_POKEBLOCK); // unused + DestroyAnimVisualTask(taskId); +} + +void AnimTask_FreePokeblockGfx(u8 taskId) +{ + FreeSpriteTilesByTag(ANIM_TAG_POKEBLOCK); + FreeSpritePaletteByTag(ANIM_TAG_POKEBLOCK); + DestroyAnimVisualTask(taskId); +} + +static void sub_80F1B3C(struct Sprite *sprite) +{ + InitSpritePosToAnimAttacker(sprite, 0); + sprite->data[0] = 30; + sprite->data[2] = GetBattlerSpriteCoord(GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT), 0) + gBattleAnimArgs[2]; + sprite->data[4] = GetBattlerSpriteCoord(GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT), 1) + gBattleAnimArgs[3]; + sprite->data[5] = -32; + InitAnimArcTranslation(sprite); + gSprites[gBattlerSpriteIds[gBattleAnimAttacker]].callback = sub_8039E84; + sprite->callback = sub_80F1BCC; +} + +static void sub_80F1BCC(struct Sprite *sprite) +{ + if (gSprites[gBattlerSpriteIds[gBattleAnimAttacker]].animCmdIndex == 1) + sprite->callback = sub_80F1C04; +} + +static void sub_80F1C04(struct Sprite *sprite) +{ + if (TranslateAnimHorizontalArc(sprite)) //TranslateAnimArc? + { + sprite->data[0] = 0; + sprite->invisible = 1; + sprite->callback = sub_80F1C30; + } +} + +static void sub_80F1C30(struct Sprite *sprite) +{ + if (gSprites[gBattlerSpriteIds[gBattleAnimAttacker]].animEnded) + { + if (++sprite->data[0] > 0) + { + StartSpriteAnim(&gSprites[gBattlerSpriteIds[gBattleAnimAttacker]], 0); + DestroyAnimSprite(sprite); + } + } +} + +void sub_80F1C8C(u8 taskId) +{ + switch (gBattleAnimArgs[0]) + { + case 0: + gBattleAnimAttacker = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT); + gBattleAnimTarget = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT); + break; + case 1: + gBattleAnimAttacker = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT); + gBattleAnimTarget = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT); + break; + } + + DestroyAnimVisualTask(taskId); +} + +void sub_80F1C8C(u8 taskId) +{ + // to do +} + +// 080F1D14 +void AnimTask_GetTrappedMoveAnimId(u8 taskId) +{ + if (gBattleSpritesDataPtr->animationData->animArg == MOVE_FIRE_SPIN) + gBattleAnimArgs[0] = TRAP_ANIM_FIRE_SPIN; + else if (gBattleSpritesDataPtr->animationData->animArg == MOVE_WHIRLPOOL) + gBattleAnimArgs[0] = TRAP_ANIM_WHIRLPOOL; + else if (gBattleSpritesDataPtr->animationData->animArg == MOVE_CLAMP) + gBattleAnimArgs[0] = TRAP_ANIM_CLAMP; + else if (gBattleSpritesDataPtr->animationData->animArg == MOVE_SAND_TOMB) + gBattleAnimArgs[0] = TRAP_ANIM_SAND_TOMB; + else + gBattleAnimArgs[0] = TRAP_ANIM_BIND; + + DestroyAnimVisualTask(taskId); +} + +void AnimTask_GetBattlersFromArg(u8 taskId) +{ + gBattleAnimAttacker = gBattleSpritesDataPtr->animationData->animArg; + gBattleAnimTarget = gBattleSpritesDataPtr->animationData->animArg >> 8; + DestroyAnimVisualTask(taskId); +} |