summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDizzyEggg <jajkodizzy@wp.pl>2019-04-14 11:41:02 +0200
committerhuderlem <huderlem@gmail.com>2019-04-14 10:19:50 -0500
commit59797e48010feaf1c41fec2aeb8771577ed11f2d (patch)
treec673a9d431c8cdc0a58451012ee973847b8ecb59
parentdc764698c9026f79fe4a9b3891a5a5b373decd55 (diff)
Use constants in battle_anim_special.c
-rw-r--r--data/battle_anim_scripts.s18
-rw-r--r--graphics/battle_anims/sprites/pokeblock.png (renamed from graphics/battle_anims/sprites/red_brick.png)bin179 -> 179 bytes
-rw-r--r--include/constants/battle_anim.h2
-rw-r--r--include/graphics.h4
-rw-r--r--src/battle_anim.c4
-rwxr-xr-xsrc/battle_anim_special.c131
-rw-r--r--src/graphics.c4
7 files changed, 77 insertions, 86 deletions
diff --git a/data/battle_anim_scripts.s b/data/battle_anim_scripts.s
index 0d5ce89a8..f366d4426 100644
--- a/data/battle_anim_scripts.s
+++ b/data/battle_anim_scripts.s
@@ -10331,15 +10331,15 @@ General_SubstituteAppear:
General_PokeblockThrow:
createvisualtask sub_817345C, 2, 0
- createvisualtask sub_81732B0, 2
+ createvisualtask AnimTask_LoadPokeblockGfx, 2
delay 0
waitplaysewithpan SE_W026, SOUND_PAN_ATTACKER, 22
- createsprite gBattleAnimSpriteTemplate_85E5338, ANIM_TARGET, 3, -18, 12, 0, 32
+ createsprite gPokeblockSpriteTemplate, ANIM_TARGET, 3, -18, 12, 0, 32
delay 50
loopsewithpan SE_W039, SOUND_PAN_TARGET, 19, 2
createvisualtask AnimTask_SwayMon, 5, 1, 8, 1536, 2, ANIM_TARGET
waitforvisualfinish
- createvisualtask sub_81732E4, 2
+ createvisualtask AnimTask_FreePokeblockGfx, 2
end
General_ItemKnockoff:
@@ -10516,7 +10516,7 @@ General_Hail:
goto Move_HAIL
General_LeechSeedDrain:
- createvisualtask sub_817351C, 5
+ createvisualtask AnimTask_GetBattlersFromArg, 5
delay 0
goto Move_ABSORB
@@ -10535,7 +10535,7 @@ General_MonHit:
General_ItemSteal:
loadspritegfx ANIM_TAG_ITEM_BAG
createvisualtask sub_8117F30, 2
- createvisualtask sub_8172ED0, 2
+ createvisualtask AnimTask_TargetToEffectBattler, 2
delay 1
createsprite gItemStealSpriteTemplate, ANIM_ATTACKER, 2, 0, -5, 10, 2, -1
end
@@ -10664,8 +10664,8 @@ General_WishHeal:
end
AnimScript_82D85A3:
- createvisualtask sub_8172E9C, 2
- jumpreteq 1, AnimScript_82D85B4
+ createvisualtask AnimTask_IsAttackerBehindSubstitute, 2
+ jumprettrue AnimScript_82D85B4
AnimScript_82D85B2:
waitforvisualfinish
return
@@ -10675,8 +10675,8 @@ AnimScript_82D85B4:
goto AnimScript_82D85B2
AnimScript_82D85C3:
- createvisualtask sub_8172E9C, 2
- jumpreteq 1, AnimScript_82D85D4
+ createvisualtask AnimTask_IsAttackerBehindSubstitute, 2
+ jumprettrue AnimScript_82D85D4
AnimScript_82D85D2:
waitforvisualfinish
return
diff --git a/graphics/battle_anims/sprites/red_brick.png b/graphics/battle_anims/sprites/pokeblock.png
index d699f4c48..d699f4c48 100644
--- a/graphics/battle_anims/sprites/red_brick.png
+++ b/graphics/battle_anims/sprites/pokeblock.png
Binary files differ
diff --git a/include/constants/battle_anim.h b/include/constants/battle_anim.h
index 1209dfa19..0a023f0c2 100644
--- a/include/constants/battle_anim.h
+++ b/include/constants/battle_anim.h
@@ -276,7 +276,7 @@
#define ANIM_TAG_GREEN_SPIKE (ANIM_SPRITES_START + 266)
#define ANIM_TAG_WHITE_CIRCLE_OF_LIGHT (ANIM_SPRITES_START + 267)
#define ANIM_TAG_GLOWY_BLUE_ORB (ANIM_SPRITES_START + 268)
-#define ANIM_TAG_RED_BRICK (ANIM_SPRITES_START + 269)
+#define ANIM_TAG_POKEBLOCK (ANIM_SPRITES_START + 269)
#define ANIM_TAG_WHITE_FEATHER (ANIM_SPRITES_START + 270)
#define ANIM_TAG_SPARKLE_6 (ANIM_SPRITES_START + 271)
#define ANIM_TAG_SPLASH (ANIM_SPRITES_START + 272)
diff --git a/include/graphics.h b/include/graphics.h
index 2dfd7953e..4e558b508 100644
--- a/include/graphics.h
+++ b/include/graphics.h
@@ -4388,7 +4388,7 @@ extern const u32 gBattleAnimSpriteGfx_IcicleSpear[];
extern const u32 gBattleAnimSpriteGfx_Hail[];
extern const u32 gBattleAnimSpriteGfx_GlowyRedOrb[];
extern const u32 gBattleAnimSpriteGfx_GreenSpike[];
-extern const u32 gBattleAnimSpriteGfx_RedBrick[];
+extern const u32 gBattleAnimSpriteGfx_Pokeblock[];
extern const u32 gBattleAnimSpriteGfx_WhiteFeather[];
extern const u32 gBattleAnimSpriteGfx_Sparkle6[];
extern const u32 gBattleAnimSpriteGfx_Splash[];
@@ -4674,7 +4674,7 @@ extern const u32 gBattleAnimSpritePal_GlowyGreenOrb[];
extern const u32 gBattleAnimSpritePal_GreenSpike[];
extern const u32 gBattleAnimSpritePal_WhiteCircleOfLight[];
extern const u32 gBattleAnimSpritePal_GlowyBlueOrb[];
-extern const u32 gBattleAnimSpritePal_RedBrick[];
+extern const u32 gBattleAnimSpritePal_Pokeblock[];
extern const u32 gBattleAnimSpritePal_WhiteFeather[];
extern const u32 gBattleAnimSpritePal_Sparkle6[];
extern const u32 gBattleAnimSpritePal_Splash[];
diff --git a/src/battle_anim.c b/src/battle_anim.c
index b265bf7bc..3cac9f33e 100644
--- a/src/battle_anim.c
+++ b/src/battle_anim.c
@@ -1394,7 +1394,7 @@ const struct CompressedSpriteSheet gBattleAnimPicTable[] =
{gBattleAnimSpriteGfx_GreenSpike, 0x0080, ANIM_TAG_GREEN_SPIKE},
{gBattleAnimSpriteGfx_CircleOfLight, 0x0800, ANIM_TAG_WHITE_CIRCLE_OF_LIGHT},
{gBattleAnimSpriteGfx_GlowyRedOrb, 0x0020, ANIM_TAG_GLOWY_BLUE_ORB},
- {gBattleAnimSpriteGfx_RedBrick, 0x0080, ANIM_TAG_RED_BRICK},
+ {gBattleAnimSpriteGfx_Pokeblock, 0x0080, ANIM_TAG_POKEBLOCK},
{gBattleAnimSpriteGfx_WhiteFeather, 0x0400, ANIM_TAG_WHITE_FEATHER},
{gBattleAnimSpriteGfx_Sparkle6, 0x0080, ANIM_TAG_SPARKLE_6},
{gBattleAnimSpriteGfx_Splash, 0x0800, ANIM_TAG_SPLASH},
@@ -1687,7 +1687,7 @@ const struct CompressedSpritePalette gBattleAnimPaletteTable[] =
{gBattleAnimSpritePal_GreenSpike, ANIM_TAG_GREEN_SPIKE},
{gBattleAnimSpritePal_WhiteCircleOfLight, ANIM_TAG_WHITE_CIRCLE_OF_LIGHT},
{gBattleAnimSpritePal_GlowyBlueOrb, ANIM_TAG_GLOWY_BLUE_ORB},
- {gBattleAnimSpritePal_RedBrick, ANIM_TAG_RED_BRICK},
+ {gBattleAnimSpritePal_Pokeblock, ANIM_TAG_POKEBLOCK},
{gBattleAnimSpritePal_WhiteFeather, ANIM_TAG_WHITE_FEATHER},
{gBattleAnimSpritePal_Sparkle6, ANIM_TAG_SPARKLE_6},
{gBattleAnimSpritePal_Splash, ANIM_TAG_SPLASH},
diff --git a/src/battle_anim_special.c b/src/battle_anim_special.c
index ee37d199f..8a7737f82 100755
--- a/src/battle_anim_special.c
+++ b/src/battle_anim_special.c
@@ -16,9 +16,10 @@
#include "task.h"
#include "trig.h"
#include "util.h"
-#include "constants/rgb.h"
#include "constants/items.h"
+#include "constants/moves.h"
#include "constants/songs.h"
+#include "constants/rgb.h"
// iwram
int gUnknown_030062DC;
@@ -355,10 +356,10 @@ const u16 gUnknown_085E5310[] =
RGB(4, 0, 0),
};
-const struct SpriteTemplate gBattleAnimSpriteTemplate_85E5338 =
+const struct SpriteTemplate gPokeblockSpriteTemplate =
{
- .tileTag = ANIM_TAG_RED_BRICK,
- .paletteTag = ANIM_TAG_RED_BRICK,
+ .tileTag = ANIM_TAG_POKEBLOCK,
+ .paletteTag = ANIM_TAG_POKEBLOCK,
.oam = &gUnknown_0852490C,
.anims = gDummySpriteAnimTable,
.images = NULL,
@@ -675,9 +676,9 @@ void sub_8170D24(u8 taskId)
void AnimTask_IsBallBlockedByTrainer(u8 taskId)
{
if (gBattleSpritesDataPtr->animationData->ballThrowCaseId == BALL_TRAINER_BLOCK)
- gBattleAnimArgs[7] = -1;
+ gBattleAnimArgs[ARG_RET_ID] = -1;
else
- gBattleAnimArgs[7] = 0;
+ gBattleAnimArgs[ARG_RET_ID] = 0;
DestroyAnimVisualTask(taskId);
}
@@ -687,30 +688,30 @@ u8 ItemIdToBallId(u16 ballItem)
switch (ballItem)
{
case ITEM_MASTER_BALL:
- return 4;
+ return BALL_MASTER;
case ITEM_ULTRA_BALL:
- return 3;
+ return BALL_ULTRA;
case ITEM_GREAT_BALL:
- return 1;
+ return BALL_GREAT;
case ITEM_SAFARI_BALL:
- return 2;
+ return BALL_SAFARI;
case ITEM_NET_BALL:
- return 5;
+ return BALL_NET;
case ITEM_DIVE_BALL:
- return 6;
+ return BALL_DIVE;
case ITEM_NEST_BALL:
- return 7;
+ return BALL_NEST;
case ITEM_REPEAT_BALL:
- return 8;
+ return BALL_REPEAT;
case ITEM_TIMER_BALL:
- return 9;
+ return BALL_TIMER;
case ITEM_LUXURY_BALL:
- return 10;
+ return BALL_LUXURY;
case ITEM_PREMIER_BALL:
- return 11;
+ return BALL_PREMIER;
case ITEM_POKE_BALL:
default:
- return 0;
+ return BALL_POKE;
}
}
@@ -804,7 +805,6 @@ static void sub_8171134(struct Sprite *sprite)
{
int i;
u8 ballId;
- int ballId2; // extra var needed to match
if (TranslateAnimHorizontalArc(sprite))
{
@@ -825,15 +825,15 @@ static void sub_8171134(struct Sprite *sprite)
sprite->data[5] = 0;
sprite->callback = sub_81711E8;
+
ballId = ItemIdToBallId(gLastUsedItem);
- ballId2 = ballId;
- if (ballId2 > 11)
- return;
- if (ballId2 < 0)
- return;
-
- AnimateBallOpenParticles(sprite->pos1.x, sprite->pos1.y - 5, 1, 28, ballId);
- LaunchBallFadeMonTask(0, gBattleAnimTarget, 14, ballId);
+ switch (ballId)
+ {
+ case 0 ... POKEBALL_COUNT - 1:
+ AnimateBallOpenParticles(sprite->pos1.x, sprite->pos1.y - 5, 1, 28, ballId);
+ LaunchBallFadeMonTask(0, gBattleAnimTarget, 14, ballId);
+ break;
+ }
}
}
}
@@ -1280,28 +1280,23 @@ static void sub_8171AAC(struct Sprite *sprite)
DestroySprite(sprite);
}
-// fakematching. I think the return type of ItemIdToBallId()
-// is wrong because of the weird required casting.
static void sub_8171AE4(struct Sprite *sprite)
{
u8 ballId;
- int ballId2; // extra var needed to match
StartSpriteAnim(sprite, 1);
StartSpriteAffineAnim(sprite, 0);
sprite->callback = sub_8171BAC;
ballId = ItemIdToBallId(gLastUsedItem);
- ballId2 = ballId;
- if (ballId2 > 11)
- goto LABEL;
- if (ballId2 < 0)
- goto LABEL;
-
- AnimateBallOpenParticles(sprite->pos1.x, sprite->pos1.y - 5, 1, 28, ballId);
- LaunchBallFadeMonTask(1, gBattleAnimTarget, 14, ballId);
+ switch (ballId)
+ {
+ case 0 ... POKEBALL_COUNT - 1:
+ AnimateBallOpenParticles(sprite->pos1.x, sprite->pos1.y - 5, 1, 28, ballId);
+ LaunchBallFadeMonTask(1, gBattleAnimTarget, 14, ballId);
+ break;
+ }
- LABEL:
gSprites[gBattlerSpriteIds[gBattleAnimTarget]].invisible = 0;
StartSpriteAffineAnim(&gSprites[gBattlerSpriteIds[gBattleAnimTarget]], 1);
AnimateSprite(&gSprites[gBattlerSpriteIds[gBattleAnimTarget]]);
@@ -1906,9 +1901,8 @@ void sub_8172BF0(u8 taskId)
{
u8 spriteId;
u32 x;
- u32 done;
+ u32 done = FALSE;
- done = FALSE;
spriteId = gBattlerSpriteIds[gBattleAnimAttacker];
switch (gTasks[taskId].data[10])
{
@@ -1942,8 +1936,7 @@ void sub_8172BF0(u8 taskId)
if (gSprites[spriteId].pos2.x <= 0)
{
gSprites[spriteId].pos2.x = 0;
- // done = FALSE; // fakematching--can't get the tail merge correct
- goto DONE;
+ done = TRUE;
}
}
else
@@ -1956,10 +1949,8 @@ void sub_8172BF0(u8 taskId)
}
if (done)
- {
- DONE:
DestroyAnimVisualTask(taskId);
- }
+
break;
}
}
@@ -1998,13 +1989,13 @@ void sub_8172D98(u8 taskId)
}
}
-void sub_8172E9C(u8 taskId)
+void AnimTask_IsAttackerBehindSubstitute(u8 taskId)
{
- gBattleAnimArgs[7] = gBattleSpritesDataPtr->battlerData[gBattleAnimAttacker].behindSubstitute;
+ gBattleAnimArgs[ARG_RET_ID] = gBattleSpritesDataPtr->battlerData[gBattleAnimAttacker].behindSubstitute;
DestroyAnimVisualTask(taskId);
}
-void sub_8172ED0(u8 taskId)
+void AnimTask_TargetToEffectBattler(u8 taskId)
{
gBattleAnimTarget = gEffectBattler;
DestroyAnimVisualTask(taskId);
@@ -2030,10 +2021,10 @@ void sub_8172EF0(u8 battler, struct Pokemon *mon)
if (isShiny)
{
- if (GetSpriteTileStartByTag(0x27F9) == 0xFFFF)
+ if (GetSpriteTileStartByTag(ANIM_TAG_GOLD_STARS) == 0xFFFF)
{
- LoadCompressedSpriteSheetUsingHeap(&gBattleAnimPicTable[233]);
- LoadCompressedSpritePaletteUsingHeap(&gBattleAnimPaletteTable[233]);
+ LoadCompressedSpriteSheetUsingHeap(&gBattleAnimPicTable[ANIM_TAG_GOLD_STARS - ANIM_SPRITES_START]);
+ LoadCompressedSpritePaletteUsingHeap(&gBattleAnimPaletteTable[ANIM_TAG_GOLD_STARS - ANIM_SPRITES_START]);
}
taskId1 = CreateTask(sub_8172FEC, 10);
@@ -2103,7 +2094,7 @@ static void sub_8172FEC(u8 taskId)
if (gTasks[taskId].data[11] == 0)
{
if (GetBattlerSide(battler) == B_SIDE_PLAYER)
- pan = 192;
+ pan = -64;
else
pan = 63;
@@ -2169,20 +2160,20 @@ static void sub_8173250(struct Sprite *sprite)
}
}
-void sub_81732B0(u8 taskId)
+void AnimTask_LoadPokeblockGfx(u8 taskId)
{
u8 paletteIndex;
- LoadCompressedSpriteSheetUsingHeap(&gBattleAnimPicTable[269]);
- LoadCompressedSpritePaletteUsingHeap(&gBattleAnimPaletteTable[269]);
- paletteIndex = IndexOfSpritePaletteTag(0x281D); // unused
+ 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 sub_81732E4(u8 taskId)
+void AnimTask_FreePokeblockGfx(u8 taskId)
{
- FreeSpriteTilesByTag(0x281D);
- FreeSpritePaletteByTag(0x281D);
+ FreeSpriteTilesByTag(ANIM_TAG_POKEBLOCK);
+ FreeSpritePaletteByTag(ANIM_TAG_POKEBLOCK);
DestroyAnimVisualTask(taskId);
}
@@ -2245,21 +2236,21 @@ void sub_817345C(u8 taskId)
void AnimTask_GetTrappedMoveAnimId(u8 taskId)
{
- if (gBattleSpritesDataPtr->animationData->animArg == 83)
- gBattleAnimArgs[0] = 1;
- else if (gBattleSpritesDataPtr->animationData->animArg == 250)
- gBattleAnimArgs[0] = 2;
- else if (gBattleSpritesDataPtr->animationData->animArg == 128)
- gBattleAnimArgs[0] = 3;
- else if (gBattleSpritesDataPtr->animationData->animArg == 328)
- gBattleAnimArgs[0] = 4;
+ 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] = 0;
+ gBattleAnimArgs[0] = TRAP_ANIM_BIND;
DestroyAnimVisualTask(taskId);
}
-void sub_817351C(u8 taskId)
+void AnimTask_GetBattlersFromArg(u8 taskId)
{
gBattleAnimAttacker = gBattleSpritesDataPtr->animationData->animArg;
gBattleAnimTarget = gBattleSpritesDataPtr->animationData->animArg >> 8;
diff --git a/src/graphics.c b/src/graphics.c
index 163cecf5b..0832101d8 100644
--- a/src/graphics.c
+++ b/src/graphics.c
@@ -1042,8 +1042,8 @@ const u32 gBattleAnimSpritePal_Splash[] = INCBIN_U32("graphics/battle_anims/spri
const u32 gBattleAnimSpriteGfx_SweatBead[] = INCBIN_U32("graphics/battle_anims/sprites/sweat_bead.4bpp.lz");
-const u32 gBattleAnimSpriteGfx_RedBrick[] = INCBIN_U32("graphics/battle_anims/sprites/red_brick.4bpp.lz");
-const u32 gBattleAnimSpritePal_RedBrick[] = INCBIN_U32("graphics/battle_anims/sprites/red_brick.gbapal.lz");
+const u32 gBattleAnimSpriteGfx_Pokeblock[] = INCBIN_U32("graphics/battle_anims/sprites/pokeblock.4bpp.lz");
+const u32 gBattleAnimSpritePal_Pokeblock[] = INCBIN_U32("graphics/battle_anims/sprites/pokeblock.gbapal.lz");
const u32 gBattleAnimSpriteGfx_Gem1[] = INCBIN_U32("graphics/battle_anims/sprites/gem_1.4bpp.lz");
const u32 gBattleAnimSpriteGfx_Gem2[] = INCBIN_U32("graphics/battle_anims/sprites/gem_2.4bpp.lz");