mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-11-16 19:47:35 +01:00
Sync src/pokeball.c with pokefirered
This commit is contained in:
parent
40805fffc0
commit
897b3d07f6
141
src/pokeball.c
141
src/pokeball.c
@ -44,49 +44,49 @@ static u16 GetBattlerPokeballItemId(u8 battlerId);
|
||||
|
||||
// rom const data
|
||||
|
||||
#define GFX_TAG_POKEBALL 55000
|
||||
#define GFX_TAG_GREATBALL 55001
|
||||
#define GFX_TAG_SAFARIBALL 55002
|
||||
#define GFX_TAG_ULTRABALL 55003
|
||||
#define GFX_TAG_MASTERBALL 55004
|
||||
#define GFX_TAG_NETBALL 55005
|
||||
#define GFX_TAG_DIVEBALL 55006
|
||||
#define GFX_TAG_NESTBALL 55007
|
||||
#define GFX_TAG_REPEATBALL 55008
|
||||
#define GFX_TAG_TIMERBALL 55009
|
||||
#define GFX_TAG_LUXURYBALL 55010
|
||||
#define GFX_TAG_PREMIERBALL 55011
|
||||
#define GFX_TAG_POKE_BALL 55000
|
||||
#define GFX_TAG_GREAT_BALL 55001
|
||||
#define GFX_TAG_SAFARI_BALL 55002
|
||||
#define GFX_TAG_ULTRA_BALL 55003
|
||||
#define GFX_TAG_MASTER_BALL 55004
|
||||
#define GFX_TAG_NET_BALL 55005
|
||||
#define GFX_TAG_DIVE_BALL 55006
|
||||
#define GFX_TAG_NEST_BALL 55007
|
||||
#define GFX_TAG_REPEAT_BALL 55008
|
||||
#define GFX_TAG_TIMER_BALL 55009
|
||||
#define GFX_TAG_LUXURY_BALL 55010
|
||||
#define GFX_TAG_PREMIER_BALL 55011
|
||||
|
||||
const struct CompressedSpriteSheet gBallSpriteSheets[POKEBALL_COUNT] =
|
||||
{
|
||||
[BALL_POKE] = {gBallGfx_Poke, 384, GFX_TAG_POKEBALL},
|
||||
[BALL_GREAT] = {gBallGfx_Great, 384, GFX_TAG_GREATBALL},
|
||||
[BALL_SAFARI] = {gBallGfx_Safari, 384, GFX_TAG_SAFARIBALL},
|
||||
[BALL_ULTRA] = {gBallGfx_Ultra, 384, GFX_TAG_ULTRABALL},
|
||||
[BALL_MASTER] = {gBallGfx_Master, 384, GFX_TAG_MASTERBALL},
|
||||
[BALL_NET] = {gBallGfx_Net, 384, GFX_TAG_NETBALL},
|
||||
[BALL_DIVE] = {gBallGfx_Dive, 384, GFX_TAG_DIVEBALL},
|
||||
[BALL_NEST] = {gBallGfx_Nest, 384, GFX_TAG_NESTBALL},
|
||||
[BALL_REPEAT] = {gBallGfx_Repeat, 384, GFX_TAG_REPEATBALL},
|
||||
[BALL_TIMER] = {gBallGfx_Timer, 384, GFX_TAG_TIMERBALL},
|
||||
[BALL_LUXURY] = {gBallGfx_Luxury, 384, GFX_TAG_LUXURYBALL},
|
||||
[BALL_PREMIER] = {gBallGfx_Premier, 384, GFX_TAG_PREMIERBALL},
|
||||
[BALL_POKE] = {gBallGfx_Poke, 384, GFX_TAG_POKE_BALL},
|
||||
[BALL_GREAT] = {gBallGfx_Great, 384, GFX_TAG_GREAT_BALL},
|
||||
[BALL_SAFARI] = {gBallGfx_Safari, 384, GFX_TAG_SAFARI_BALL},
|
||||
[BALL_ULTRA] = {gBallGfx_Ultra, 384, GFX_TAG_ULTRA_BALL},
|
||||
[BALL_MASTER] = {gBallGfx_Master, 384, GFX_TAG_MASTER_BALL},
|
||||
[BALL_NET] = {gBallGfx_Net, 384, GFX_TAG_NET_BALL},
|
||||
[BALL_DIVE] = {gBallGfx_Dive, 384, GFX_TAG_DIVE_BALL},
|
||||
[BALL_NEST] = {gBallGfx_Nest, 384, GFX_TAG_NEST_BALL},
|
||||
[BALL_REPEAT] = {gBallGfx_Repeat, 384, GFX_TAG_REPEAT_BALL},
|
||||
[BALL_TIMER] = {gBallGfx_Timer, 384, GFX_TAG_TIMER_BALL},
|
||||
[BALL_LUXURY] = {gBallGfx_Luxury, 384, GFX_TAG_LUXURY_BALL},
|
||||
[BALL_PREMIER] = {gBallGfx_Premier, 384, GFX_TAG_PREMIER_BALL},
|
||||
};
|
||||
|
||||
const struct CompressedSpritePalette gBallSpritePalettes[POKEBALL_COUNT] =
|
||||
{
|
||||
[BALL_POKE] = {gBallPal_Poke, GFX_TAG_POKEBALL},
|
||||
[BALL_GREAT] = {gBallPal_Great, GFX_TAG_GREATBALL},
|
||||
[BALL_SAFARI] = {gBallPal_Safari, GFX_TAG_SAFARIBALL},
|
||||
[BALL_ULTRA] = {gBallPal_Ultra, GFX_TAG_ULTRABALL},
|
||||
[BALL_MASTER] = {gBallPal_Master, GFX_TAG_MASTERBALL},
|
||||
[BALL_NET] = {gBallPal_Net, GFX_TAG_NETBALL},
|
||||
[BALL_DIVE] = {gBallPal_Dive, GFX_TAG_DIVEBALL},
|
||||
[BALL_NEST] = {gBallPal_Nest, GFX_TAG_NESTBALL},
|
||||
[BALL_REPEAT] = {gBallPal_Repeat, GFX_TAG_REPEATBALL},
|
||||
[BALL_TIMER] = {gBallPal_Timer, GFX_TAG_TIMERBALL},
|
||||
[BALL_LUXURY] = {gBallPal_Luxury, GFX_TAG_LUXURYBALL},
|
||||
[BALL_PREMIER] = {gBallPal_Premier, GFX_TAG_PREMIERBALL},
|
||||
[BALL_POKE] = {gBallPal_Poke, GFX_TAG_POKE_BALL},
|
||||
[BALL_GREAT] = {gBallPal_Great, GFX_TAG_GREAT_BALL},
|
||||
[BALL_SAFARI] = {gBallPal_Safari, GFX_TAG_SAFARI_BALL},
|
||||
[BALL_ULTRA] = {gBallPal_Ultra, GFX_TAG_ULTRA_BALL},
|
||||
[BALL_MASTER] = {gBallPal_Master, GFX_TAG_MASTER_BALL},
|
||||
[BALL_NET] = {gBallPal_Net, GFX_TAG_NET_BALL},
|
||||
[BALL_DIVE] = {gBallPal_Dive, GFX_TAG_DIVE_BALL},
|
||||
[BALL_NEST] = {gBallPal_Nest, GFX_TAG_NEST_BALL},
|
||||
[BALL_REPEAT] = {gBallPal_Repeat, GFX_TAG_REPEAT_BALL},
|
||||
[BALL_TIMER] = {gBallPal_Timer, GFX_TAG_TIMER_BALL},
|
||||
[BALL_LUXURY] = {gBallPal_Luxury, GFX_TAG_LUXURY_BALL},
|
||||
[BALL_PREMIER] = {gBallPal_Premier, GFX_TAG_PREMIER_BALL},
|
||||
};
|
||||
|
||||
static const struct OamData sBallOamData =
|
||||
@ -206,8 +206,8 @@ const struct SpriteTemplate gBallSpriteTemplates[POKEBALL_COUNT] =
|
||||
{
|
||||
[BALL_POKE] =
|
||||
{
|
||||
.tileTag = GFX_TAG_POKEBALL,
|
||||
.paletteTag = GFX_TAG_POKEBALL,
|
||||
.tileTag = GFX_TAG_POKE_BALL,
|
||||
.paletteTag = GFX_TAG_POKE_BALL,
|
||||
.oam = &sBallOamData,
|
||||
.anims = sBallAnimSequences,
|
||||
.images = NULL,
|
||||
@ -216,8 +216,8 @@ const struct SpriteTemplate gBallSpriteTemplates[POKEBALL_COUNT] =
|
||||
},
|
||||
[BALL_GREAT] =
|
||||
{
|
||||
.tileTag = GFX_TAG_GREATBALL,
|
||||
.paletteTag = GFX_TAG_GREATBALL,
|
||||
.tileTag = GFX_TAG_GREAT_BALL,
|
||||
.paletteTag = GFX_TAG_GREAT_BALL,
|
||||
.oam = &sBallOamData,
|
||||
.anims = sBallAnimSequences,
|
||||
.images = NULL,
|
||||
@ -226,8 +226,8 @@ const struct SpriteTemplate gBallSpriteTemplates[POKEBALL_COUNT] =
|
||||
},
|
||||
[BALL_SAFARI] =
|
||||
{
|
||||
.tileTag = GFX_TAG_SAFARIBALL,
|
||||
.paletteTag = GFX_TAG_SAFARIBALL,
|
||||
.tileTag = GFX_TAG_SAFARI_BALL,
|
||||
.paletteTag = GFX_TAG_SAFARI_BALL,
|
||||
.oam = &sBallOamData,
|
||||
.anims = sBallAnimSequences,
|
||||
.images = NULL,
|
||||
@ -236,8 +236,8 @@ const struct SpriteTemplate gBallSpriteTemplates[POKEBALL_COUNT] =
|
||||
},
|
||||
[BALL_ULTRA] =
|
||||
{
|
||||
.tileTag = GFX_TAG_ULTRABALL,
|
||||
.paletteTag = GFX_TAG_ULTRABALL,
|
||||
.tileTag = GFX_TAG_ULTRA_BALL,
|
||||
.paletteTag = GFX_TAG_ULTRA_BALL,
|
||||
.oam = &sBallOamData,
|
||||
.anims = sBallAnimSequences,
|
||||
.images = NULL,
|
||||
@ -246,8 +246,8 @@ const struct SpriteTemplate gBallSpriteTemplates[POKEBALL_COUNT] =
|
||||
},
|
||||
[BALL_MASTER] =
|
||||
{
|
||||
.tileTag = GFX_TAG_MASTERBALL,
|
||||
.paletteTag = GFX_TAG_MASTERBALL,
|
||||
.tileTag = GFX_TAG_MASTER_BALL,
|
||||
.paletteTag = GFX_TAG_MASTER_BALL,
|
||||
.oam = &sBallOamData,
|
||||
.anims = sBallAnimSequences,
|
||||
.images = NULL,
|
||||
@ -256,8 +256,8 @@ const struct SpriteTemplate gBallSpriteTemplates[POKEBALL_COUNT] =
|
||||
},
|
||||
[BALL_NET] =
|
||||
{
|
||||
.tileTag = GFX_TAG_NETBALL,
|
||||
.paletteTag = GFX_TAG_NETBALL,
|
||||
.tileTag = GFX_TAG_NET_BALL,
|
||||
.paletteTag = GFX_TAG_NET_BALL,
|
||||
.oam = &sBallOamData,
|
||||
.anims = sBallAnimSequences,
|
||||
.images = NULL,
|
||||
@ -266,8 +266,8 @@ const struct SpriteTemplate gBallSpriteTemplates[POKEBALL_COUNT] =
|
||||
},
|
||||
[BALL_DIVE] =
|
||||
{
|
||||
.tileTag = GFX_TAG_DIVEBALL,
|
||||
.paletteTag = GFX_TAG_DIVEBALL,
|
||||
.tileTag = GFX_TAG_DIVE_BALL,
|
||||
.paletteTag = GFX_TAG_DIVE_BALL,
|
||||
.oam = &sBallOamData,
|
||||
.anims = sBallAnimSequences,
|
||||
.images = NULL,
|
||||
@ -276,8 +276,8 @@ const struct SpriteTemplate gBallSpriteTemplates[POKEBALL_COUNT] =
|
||||
},
|
||||
[BALL_NEST] =
|
||||
{
|
||||
.tileTag = GFX_TAG_NESTBALL,
|
||||
.paletteTag = GFX_TAG_NESTBALL,
|
||||
.tileTag = GFX_TAG_NEST_BALL,
|
||||
.paletteTag = GFX_TAG_NEST_BALL,
|
||||
.oam = &sBallOamData,
|
||||
.anims = sBallAnimSequences,
|
||||
.images = NULL,
|
||||
@ -286,8 +286,8 @@ const struct SpriteTemplate gBallSpriteTemplates[POKEBALL_COUNT] =
|
||||
},
|
||||
[BALL_REPEAT] =
|
||||
{
|
||||
.tileTag = GFX_TAG_REPEATBALL,
|
||||
.paletteTag = GFX_TAG_REPEATBALL,
|
||||
.tileTag = GFX_TAG_REPEAT_BALL,
|
||||
.paletteTag = GFX_TAG_REPEAT_BALL,
|
||||
.oam = &sBallOamData,
|
||||
.anims = sBallAnimSequences,
|
||||
.images = NULL,
|
||||
@ -296,8 +296,8 @@ const struct SpriteTemplate gBallSpriteTemplates[POKEBALL_COUNT] =
|
||||
},
|
||||
[BALL_TIMER] =
|
||||
{
|
||||
.tileTag = GFX_TAG_TIMERBALL,
|
||||
.paletteTag = GFX_TAG_TIMERBALL,
|
||||
.tileTag = GFX_TAG_TIMER_BALL,
|
||||
.paletteTag = GFX_TAG_TIMER_BALL,
|
||||
.oam = &sBallOamData,
|
||||
.anims = sBallAnimSequences,
|
||||
.images = NULL,
|
||||
@ -306,8 +306,8 @@ const struct SpriteTemplate gBallSpriteTemplates[POKEBALL_COUNT] =
|
||||
},
|
||||
[BALL_LUXURY] =
|
||||
{
|
||||
.tileTag = GFX_TAG_LUXURYBALL,
|
||||
.paletteTag = GFX_TAG_LUXURYBALL,
|
||||
.tileTag = GFX_TAG_LUXURY_BALL,
|
||||
.paletteTag = GFX_TAG_LUXURY_BALL,
|
||||
.oam = &sBallOamData,
|
||||
.anims = sBallAnimSequences,
|
||||
.images = NULL,
|
||||
@ -316,8 +316,8 @@ const struct SpriteTemplate gBallSpriteTemplates[POKEBALL_COUNT] =
|
||||
},
|
||||
[BALL_PREMIER] =
|
||||
{
|
||||
.tileTag = GFX_TAG_PREMIERBALL,
|
||||
.paletteTag = GFX_TAG_PREMIERBALL,
|
||||
.tileTag = GFX_TAG_PREMIER_BALL,
|
||||
.paletteTag = GFX_TAG_PREMIER_BALL,
|
||||
.oam = &sBallOamData,
|
||||
.anims = sBallAnimSequences,
|
||||
.images = NULL,
|
||||
@ -337,7 +337,7 @@ u8 DoPokeballSendOutAnimation(s16 pan, u8 kindOfThrow)
|
||||
u8 taskId;
|
||||
|
||||
gDoingBattleAnim = TRUE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive = 1;
|
||||
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive = TRUE;
|
||||
|
||||
taskId = CreateTask(Task_DoPokeballSendOutAnim, 5);
|
||||
gTasks[taskId].tPan = pan;
|
||||
@ -407,7 +407,7 @@ static void Task_DoPokeballSendOutAnim(u8 taskId)
|
||||
}
|
||||
|
||||
// this will perform an unused ball throw animation
|
||||
gSprites[ballSpriteId].data[0] = 0x22;
|
||||
gSprites[ballSpriteId].data[0] = 34;
|
||||
gSprites[ballSpriteId].data[2] = GetBattlerSpriteCoord(gBattlerTarget, BATTLER_COORD_X);
|
||||
gSprites[ballSpriteId].data[4] = GetBattlerSpriteCoord(gBattlerTarget, BATTLER_COORD_Y) - 16;
|
||||
gSprites[ballSpriteId].data[5] = -40;
|
||||
@ -431,7 +431,7 @@ static void SpriteCB_BallThrow(struct Sprite *sprite)
|
||||
u8 noOfShakes = gTasks[taskId].tThrowId;
|
||||
|
||||
StartSpriteAnim(sprite, 1);
|
||||
sprite->affineAnimPaused = 1;
|
||||
sprite->affineAnimPaused = TRUE;
|
||||
sprite->x += sprite->x2;
|
||||
sprite->y += sprite->y2;
|
||||
sprite->x2 = 0;
|
||||
@ -475,6 +475,7 @@ static void SpriteCB_BallThrow_ShrinkMon(struct Sprite *sprite)
|
||||
sprite->data[5]++;
|
||||
if (sprite->data[5] == 11)
|
||||
PlaySE(SE_BALL_TRADE);
|
||||
|
||||
if (gSprites[gBattlerSpriteIds[sprite->sBattler]].affineAnimEnded)
|
||||
{
|
||||
StartSpriteAnim(sprite, 2);
|
||||
@ -644,6 +645,7 @@ static void SpriteCB_BallThrow_Shake(struct Sprite *sprite)
|
||||
StartSpriteAffineAnim(sprite, 2);
|
||||
else
|
||||
StartSpriteAffineAnim(sprite, 1);
|
||||
|
||||
PlaySE(SE_BALL);
|
||||
}
|
||||
break;
|
||||
@ -864,13 +866,13 @@ static void HandleBallAnimEnd(struct Sprite *sprite)
|
||||
|
||||
gSprites[gBattlerSpriteIds[battlerId]].y2 = 0;
|
||||
gDoingBattleAnim = FALSE;
|
||||
gBattleSpritesDataPtr->healthBoxesData[battlerId].ballAnimActive = 0;
|
||||
gBattleSpritesDataPtr->healthBoxesData[battlerId].ballAnimActive = FALSE;
|
||||
FreeSpriteOamMatrix(sprite);
|
||||
DestroySprite(sprite);
|
||||
|
||||
for (doneBattlers = 0, i = 0; i < MAX_BATTLERS_COUNT; i++)
|
||||
{
|
||||
if (gBattleSpritesDataPtr->healthBoxesData[i].ballAnimActive == 0)
|
||||
if (gBattleSpritesDataPtr->healthBoxesData[i].ballAnimActive == FALSE)
|
||||
doneBattlers++;
|
||||
}
|
||||
if (doneBattlers == MAX_BATTLERS_COUNT)
|
||||
@ -902,7 +904,7 @@ static void SpriteCB_BallThrow_CaptureMon(struct Sprite *sprite)
|
||||
DestroySprite(&gSprites[gBattlerSpriteIds[sprite->sBattler]]);
|
||||
DestroySpriteAndFreeResources(sprite);
|
||||
if (gMain.inBattle)
|
||||
gBattleSpritesDataPtr->healthBoxesData[battlerId].ballAnimActive = 0;
|
||||
gBattleSpritesDataPtr->healthBoxesData[battlerId].ballAnimActive = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1134,7 +1136,6 @@ static void SpriteCB_ReleasedMonFlyOut(struct Sprite *sprite)
|
||||
#undef sFinalMonY
|
||||
#undef sTrigIdx
|
||||
|
||||
|
||||
#define sTimer data[5]
|
||||
|
||||
u8 CreateTradePokeballSprite(u8 monSpriteId, u8 monPalNum, u8 x, u8 y, u8 oamPriority, u8 subPriority, u8 delay, u32 fadePalettes)
|
||||
@ -1224,7 +1225,8 @@ static void SpriteCB_TradePokeballEnd(struct Sprite *sprite)
|
||||
#undef sFadePalsHi
|
||||
#undef sTimer
|
||||
|
||||
static void Unref_DestroySpriteAndFreeResources(struct Sprite *sprite)
|
||||
// Unreferenced here and in RS, but used in FRLG, possibly by mistake.
|
||||
static void DestroySpriteAndFreeResources_Ball(struct Sprite *sprite)
|
||||
{
|
||||
DestroySpriteAndFreeResources(sprite);
|
||||
}
|
||||
@ -1306,11 +1308,12 @@ void LoadBallGfx(u8 ballId)
|
||||
{
|
||||
u16 var;
|
||||
|
||||
if (GetSpriteTileStartByTag(gBallSpriteSheets[ballId].tag) == 0xFFFF)
|
||||
if (GetSpriteTileStartByTag(gBallSpriteSheets[ballId].tag) == TAG_NONE)
|
||||
{
|
||||
LoadCompressedSpriteSheetUsingHeap(&gBallSpriteSheets[ballId]);
|
||||
LoadCompressedSpritePaletteUsingHeap(&gBallSpritePalettes[ballId]);
|
||||
}
|
||||
|
||||
switch (ballId)
|
||||
{
|
||||
case BALL_DIVE:
|
||||
|
Loading…
Reference in New Issue
Block a user