Document evolution scene

This commit is contained in:
GriffinR 2021-02-03 15:04:25 -05:00
parent 64460e01ae
commit 15906ca143
12 changed files with 837 additions and 653 deletions

View File

@ -3,13 +3,11 @@
void LoadEvoSparkleSpriteAndPal(void);
u8 LaunchTask_PreEvoSparklesSet1(u16 arg0);
u8 LaunchTask_PreEvoSparklesSet2(void);
u8 LaunchTask_PostEvoSparklesSet1(void);
u8 LaunchTask_PostEvoSparklesSet2AndFlash(u16 species);
u8 LaunchTask_PostEvoSparklesSet2AndFlash_Trade(u16 species);
u8 sub_817C3A0(u8 preEvoSpriteID, u8 postEvoSpriteID);
#define EvoGraphicsTaskEvoStop data[8]
u8 EvolutionSparkles_SpiralUpward(u16 arg0);
u8 EvolutionSparkles_ArcDown(void);
u8 EvolutionSparkles_CircleInward(void);
u8 EvolutionSparkles_SprayAndFlash(u16 species);
u8 EvolutionSparkles_SprayAndFlash_Trade(u16 species);
u8 CycleEvolutionMonSprite(u8 preEvoSpriteID, u8 postEvoSpriteID);
#endif // GUARD_EVOLUTION_GRAPHICS_H

View File

@ -10,40 +10,46 @@
#include "palette.h"
#include "constants/rgb.h"
// this file's functions
static void EvoSparkle_DummySpriteCb(struct Sprite* sprite);
static void EvoTask_BeginPreSet1_FadeAndPlaySE(u8 taskID);
static void EvoTask_CreatePreEvoSparkleSet1(u8 taskID);
static void EvoTask_WaitForPre1SparklesToGoUp(u8 taskID);
static void EvoTask_BeginPreSparklesSet2(u8 taskID);
static void EvoTask_CreatePreEvoSparklesSet2(u8 taskID);
static void EvoTask_DestroyPreSet2Task(u8 taskID);
static void EvoTask_BeginPostSparklesSet1(u8 taskID);
static void EvoTask_CreatePostEvoSparklesSet1(u8 taskID);
static void EvoTask_DestroyPostSet1Task(u8 taskID);
static void EvoTask_BeginPostSparklesSet2_AndFlash(u8 taskID);
static void EvoTask_CreatePostEvoSparklesSet2_AndFlash(u8 taskID);
static void EvoTask_BeginPostSparklesSet2_AndFlash_Trade(u8 taskID);
static void EvoTask_CreatePostEvoSparklesSet2_AndFlash_Trade(u8 taskID);
static void EvoTask_DestroyPostSet2AndFlashTask(u8 taskID);
static void sub_817C4EC(u8 taskID);
static void sub_817C510(u8 taskID);
static void PreEvoVisible_PostEvoInvisible_KillTask(u8 taskID);
static void PreEvoInvisible_PostEvoVisible_KillTask(u8 taskID);
static void sub_817C560(u8 taskID);
static void SpriteCB_Sparkle_Dummy(struct Sprite* sprite);
static const u16 sEvoSparklePalette[] = INCBIN_U16("graphics/misc/evo_sparkle.gbapal");
static const u32 sEvoSparkleTiles[] = INCBIN_U32("graphics/misc/evo_sparkle.4bpp.lz");
static void Task_Sparkles_SpiralUpward_Init(u8 taskId);
static void Task_Sparkles_SpiralUpward(u8 taskId);
static void Task_Sparkles_SpiralUpward_End(u8 taskId);
static void Task_Sparkles_ArcDown_Init(u8 taskId);
static void Task_Sparkles_ArcDown(u8 taskId);
static void Task_Sparkles_ArcDown_End(u8 taskId);
static void Task_Sparkles_CircleInward_Init(u8 taskId);
static void Task_Sparkles_CircleInward(u8 taskId);
static void Task_Sparkles_CircleInward_End(u8 taskId);
static void Task_Sparkles_SprayAndFlash_Init(u8 taskId);
static void Task_Sparkles_SprayAndFlash(u8 taskId);
static void Task_Sparkles_SprayAndFlashTrade_Init(u8 taskId);
static void Task_Sparkles_SprayAndFlashTrade(u8 taskId);
static void Task_Sparkles_SprayAndFlash_End(u8 taskId);
static void Task_CycleEvolutionMonSprite_Init(u8 taskId);
static void Task_CycleEvolutionMonSprite_TryEnd(u8 taskId);
static void Task_CycleEvolutionMonSprite_UpdateSize(u8 taskId);
static void EndOnPreEvoMon(u8 taskId);
static void EndOnPostEvoMon(u8 taskId);
#define TAG_SPARKLE 1001
static const u16 sEvoSparkle_Pal[] = INCBIN_U16("graphics/misc/evo_sparkle.gbapal");
static const u32 sEvoSparkle_Gfx[] = INCBIN_U32("graphics/misc/evo_sparkle.4bpp.lz");
static const struct CompressedSpriteSheet sEvoSparkleSpriteSheets[] =
{
{sEvoSparkleTiles, 0x20, 1001},
{sEvoSparkle_Gfx, 0x20, TAG_SPARKLE},
{NULL, 0, 0}
};
static const struct SpritePalette sEvoSparkleSpritePals[] =
{
{sEvoSparklePalette, 1001},
{sEvoSparkle_Pal, TAG_SPARKLE},
{NULL, 0}
};
@ -77,13 +83,13 @@ static const union AnimCmd *const sSpriteAnimTable_EvoSparkle[] =
static const struct SpriteTemplate sEvoSparkleSpriteTemplate =
{
.tileTag = 1001,
.paletteTag = 1001,
.tileTag = TAG_SPARKLE,
.paletteTag = TAG_SPARKLE,
.oam = &sOamData_EvoSparkle,
.anims = sSpriteAnimTable_EvoSparkle,
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
.callback = EvoSparkle_DummySpriteCb
.callback = SpriteCB_Sparkle_Dummy
};
static const s16 sEvoSparkleMatrices[] =
@ -93,7 +99,7 @@ static const s16 sEvoSparkleMatrices[] =
-1, 0x70, 0x1, 0x70, 0x2, 0x50, 0x3, 0x30, 0x4, 0x10
};
static void EvoSparkle_DummySpriteCb(struct Sprite *sprite)
static void SpriteCB_Sparkle_Dummy(struct Sprite *sprite)
{
}
@ -107,7 +113,7 @@ static void SetEvoSparklesMatrices(void)
}
}
static void SpriteCB_PreEvoSparkleSet1(struct Sprite* sprite)
static void SpriteCB_Sparkle_SpiralUpward(struct Sprite* sprite)
{
if (sprite->pos1.y > 8)
{
@ -133,7 +139,7 @@ static void SpriteCB_PreEvoSparkleSet1(struct Sprite* sprite)
DestroySprite(sprite);
}
static void CreatePreEvoSparkleSet1(u8 arg0)
static void CreateSparkle_SpiralUpward(u8 arg0)
{
u8 spriteID = CreateSprite(&sEvoSparkleSpriteTemplate, 120, 88, 0);
if (spriteID != MAX_SPRITES)
@ -143,11 +149,11 @@ static void CreatePreEvoSparkleSet1(u8 arg0)
gSprites[spriteID].data[7] = 0;
gSprites[spriteID].oam.affineMode = ST_OAM_AFFINE_NORMAL;
gSprites[spriteID].oam.matrixNum = 31;
gSprites[spriteID].callback = SpriteCB_PreEvoSparkleSet1;
gSprites[spriteID].callback = SpriteCB_Sparkle_SpiralUpward;
}
}
static void SpriteCB_PreEvoSparkleSet2(struct Sprite* sprite)
static void SpriteCB_Sparkle_ArcDown(struct Sprite* sprite)
{
if (sprite->pos1.y < 88)
{
@ -161,7 +167,7 @@ static void SpriteCB_PreEvoSparkleSet2(struct Sprite* sprite)
DestroySprite(sprite);
}
static void CreatePreEvoSparkleSet2(u8 arg0)
static void CreateSparkle_ArcDown(u8 arg0)
{
u8 spriteID = CreateSprite(&sEvoSparkleSpriteTemplate, 120, 8, 0);
if (spriteID != MAX_SPRITES)
@ -172,11 +178,11 @@ static void CreatePreEvoSparkleSet2(u8 arg0)
gSprites[spriteID].oam.affineMode = ST_OAM_AFFINE_NORMAL;
gSprites[spriteID].oam.matrixNum = 25;
gSprites[spriteID].subpriority = 1;
gSprites[spriteID].callback = SpriteCB_PreEvoSparkleSet2;
gSprites[spriteID].callback = SpriteCB_Sparkle_ArcDown;
}
}
static void SpriteCB_PostEvoSparkleSet1(struct Sprite* sprite)
static void SpriteCB_Sparkle_CircleInward(struct Sprite* sprite)
{
if (sprite->data[5] > 8)
{
@ -189,7 +195,7 @@ static void SpriteCB_PostEvoSparkleSet1(struct Sprite* sprite)
DestroySprite(sprite);
}
static void CreatePostEvoSparkleSet1(u8 arg0, u8 arg1)
static void CreateSparkle_CircleInward(u8 arg0, u8 arg1)
{
u8 spriteID = CreateSprite(&sEvoSparkleSpriteTemplate, 120, 56, 0);
if (spriteID != MAX_SPRITES)
@ -201,11 +207,11 @@ static void CreatePostEvoSparkleSet1(u8 arg0, u8 arg1)
gSprites[spriteID].oam.affineMode = ST_OAM_AFFINE_NORMAL;
gSprites[spriteID].oam.matrixNum = 31;
gSprites[spriteID].subpriority = 1;
gSprites[spriteID].callback = SpriteCB_PostEvoSparkleSet1;
gSprites[spriteID].callback = SpriteCB_Sparkle_CircleInward;
}
}
static void SpriteCB_PostEvoSparkleSet2(struct Sprite* sprite)
static void SpriteCB_Sparkle_Spray(struct Sprite* sprite)
{
if (!(sprite->data[7] & 3))
sprite->pos1.y++;
@ -235,7 +241,7 @@ static void SpriteCB_PostEvoSparkleSet2(struct Sprite* sprite)
DestroySprite(sprite);
}
static void CreatePostEvoSparkleSet2(u8 arg0)
static void CreateSparkle_Spray(u8 id)
{
u8 spriteID = CreateSprite(&sEvoSparkleSpriteTemplate, 120, 56, 0);
if (spriteID != MAX_SPRITES)
@ -246,7 +252,7 @@ static void CreatePostEvoSparkleSet2(u8 arg0)
gSprites[spriteID].oam.affineMode = ST_OAM_AFFINE_NORMAL;
gSprites[spriteID].oam.matrixNum = 31;
gSprites[spriteID].subpriority = 20;
gSprites[spriteID].callback = SpriteCB_PostEvoSparkleSet2;
gSprites[spriteID].callback = SpriteCB_Sparkle_Spray;
}
}
@ -256,357 +262,386 @@ void LoadEvoSparkleSpriteAndPal(void)
LoadSpritePalettes(sEvoSparkleSpritePals);
}
#define tFrameCounter data[15]
#define tPalNum data[1]
#define tTimer data[15]
u8 LaunchTask_PreEvoSparklesSet1(u16 arg0)
u8 EvolutionSparkles_SpiralUpward(u16 palNum)
{
u8 taskID = CreateTask(EvoTask_BeginPreSet1_FadeAndPlaySE, 0);
gTasks[taskID].data[1] = arg0;
return taskID;
u8 taskId = CreateTask(Task_Sparkles_SpiralUpward_Init, 0);
gTasks[taskId].tPalNum = palNum;
return taskId;
}
static void EvoTask_BeginPreSet1_FadeAndPlaySE(u8 taskID)
static void Task_Sparkles_SpiralUpward_Init(u8 taskId)
{
SetEvoSparklesMatrices();
gTasks[taskID].tFrameCounter = 0;
BeginNormalPaletteFade(3 << gTasks[taskID].data[1], 0xA, 0, 0x10, RGB_WHITE);
gTasks[taskID].func = EvoTask_CreatePreEvoSparkleSet1;
PlaySE(SE_M_MEGA_KICK);
gTasks[taskId].tTimer = 0;
BeginNormalPaletteFade(3 << gTasks[taskId].tPalNum, 0xA, 0, 0x10, RGB_WHITE);
gTasks[taskId].func = Task_Sparkles_SpiralUpward;
PlaySE(SE_M_MEGA_KICK); // 'Charging up' sound for the sparkles as they spiral upwards
}
static void EvoTask_CreatePreEvoSparkleSet1(u8 taskID)
static void Task_Sparkles_SpiralUpward(u8 taskId)
{
if (gTasks[taskID].tFrameCounter < 64)
if (gTasks[taskId].tTimer < 64)
{
if (!(gTasks[taskID].tFrameCounter & 7))
if (!(gTasks[taskId].tTimer & 7))
{
u8 i;
for (i = 0; i < 4; i++)
CreatePreEvoSparkleSet1((0x78 & gTasks[taskID].tFrameCounter) * 2 + i * 64);
CreateSparkle_SpiralUpward((0x78 & gTasks[taskId].tTimer) * 2 + i * 64);
}
gTasks[taskID].tFrameCounter++;
gTasks[taskId].tTimer++;
}
else
{
gTasks[taskID].tFrameCounter = 96;
gTasks[taskID].func = EvoTask_WaitForPre1SparklesToGoUp;
gTasks[taskId].tTimer = 96;
gTasks[taskId].func = Task_Sparkles_SpiralUpward_End;
}
}
static void EvoTask_WaitForPre1SparklesToGoUp(u8 taskID)
static void Task_Sparkles_SpiralUpward_End(u8 taskId)
{
if (gTasks[taskID].tFrameCounter != 0)
gTasks[taskID].tFrameCounter--;
if (gTasks[taskId].tTimer != 0)
gTasks[taskId].tTimer--;
else
DestroyTask(taskID);
DestroyTask(taskId);
}
u8 LaunchTask_PreEvoSparklesSet2(void)
u8 EvolutionSparkles_ArcDown(void)
{
return CreateTask(EvoTask_BeginPreSparklesSet2, 0);
return CreateTask(Task_Sparkles_ArcDown_Init, 0);
}
static void EvoTask_BeginPreSparklesSet2(u8 taskID)
static void Task_Sparkles_ArcDown_Init(u8 taskId)
{
SetEvoSparklesMatrices();
gTasks[taskID].tFrameCounter = 0;
gTasks[taskID].func = EvoTask_CreatePreEvoSparklesSet2;
gTasks[taskId].tTimer = 0;
gTasks[taskId].func = Task_Sparkles_ArcDown;
PlaySE(SE_M_BUBBLE_BEAM2);
}
static void EvoTask_CreatePreEvoSparklesSet2(u8 taskID)
static void Task_Sparkles_ArcDown(u8 taskId)
{
if (gTasks[taskID].tFrameCounter < 96)
if (gTasks[taskId].tTimer < 96)
{
if (gTasks[taskID].tFrameCounter < 6)
if (gTasks[taskId].tTimer < 6)
{
u8 i;
for (i = 0; i < 9; i++)
CreatePreEvoSparkleSet2(i * 16);
CreateSparkle_ArcDown(i * 16);
}
gTasks[taskID].tFrameCounter++;
gTasks[taskId].tTimer++;
}
else
gTasks[taskID].func = EvoTask_DestroyPreSet2Task;
gTasks[taskId].func = Task_Sparkles_ArcDown_End;
}
static void EvoTask_DestroyPreSet2Task(u8 taskID)
static void Task_Sparkles_ArcDown_End(u8 taskId)
{
DestroyTask(taskID);
DestroyTask(taskId);
}
u8 LaunchTask_PostEvoSparklesSet1(void)
u8 EvolutionSparkles_CircleInward(void)
{
return CreateTask(EvoTask_BeginPostSparklesSet1, 0);
return CreateTask(Task_Sparkles_CircleInward_Init, 0);
}
static void EvoTask_BeginPostSparklesSet1(u8 taskID)
static void Task_Sparkles_CircleInward_Init(u8 taskId)
{
SetEvoSparklesMatrices();
gTasks[taskID].tFrameCounter = 0;
gTasks[taskID].func = EvoTask_CreatePostEvoSparklesSet1;
gTasks[taskId].tTimer = 0;
gTasks[taskId].func = Task_Sparkles_CircleInward;
PlaySE(SE_SHINY);
}
static void EvoTask_CreatePostEvoSparklesSet1(u8 taskID)
static void Task_Sparkles_CircleInward(u8 taskId)
{
if (gTasks[taskID].tFrameCounter < 48)
if (gTasks[taskId].tTimer < 48)
{
if (gTasks[taskID].tFrameCounter == 0)
if (gTasks[taskId].tTimer == 0)
{
u8 i;
for (i = 0; i < 16; i++)
CreatePostEvoSparkleSet1(i * 16, 4);
CreateSparkle_CircleInward(i * 16, 4);
}
if (gTasks[taskID].tFrameCounter == 32)
if (gTasks[taskId].tTimer == 32)
{
u8 i;
for (i = 0; i < 16; i++)
CreatePostEvoSparkleSet1(i * 16, 8);
CreateSparkle_CircleInward(i * 16, 8);
}
gTasks[taskID].tFrameCounter++;
gTasks[taskId].tTimer++;
}
else
gTasks[taskID].func = EvoTask_DestroyPostSet1Task;
gTasks[taskId].func = Task_Sparkles_CircleInward_End;
}
static void EvoTask_DestroyPostSet1Task(u8 taskID)
static void Task_Sparkles_CircleInward_End(u8 taskId)
{
DestroyTask(taskID);
DestroyTask(taskId);
}
u8 LaunchTask_PostEvoSparklesSet2AndFlash(u16 species)
#define tSpecies data[2] // Never read
u8 EvolutionSparkles_SprayAndFlash(u16 species)
{
u8 taskID = CreateTask(EvoTask_BeginPostSparklesSet2_AndFlash, 0);
gTasks[taskID].data[2] = species;
return taskID;
u8 taskId = CreateTask(Task_Sparkles_SprayAndFlash_Init, 0);
gTasks[taskId].tSpecies = species;
return taskId;
}
static void EvoTask_BeginPostSparklesSet2_AndFlash(u8 taskID)
static void Task_Sparkles_SprayAndFlash_Init(u8 taskId)
{
SetEvoSparklesMatrices();
gTasks[taskID].tFrameCounter = 0;
gTasks[taskId].tTimer = 0;
CpuSet(&gPlttBufferFaded[0x20], &gPlttBufferUnfaded[0x20], 0x30);
BeginNormalPaletteFade(0xFFF9041C, 0, 0, 0x10, RGB_WHITE); // was 0xFFF9001C in R/S
gTasks[taskID].func = EvoTask_CreatePostEvoSparklesSet2_AndFlash;
gTasks[taskId].func = Task_Sparkles_SprayAndFlash;
PlaySE(SE_M_PETAL_DANCE);
}
static void EvoTask_CreatePostEvoSparklesSet2_AndFlash(u8 taskID)
static void Task_Sparkles_SprayAndFlash(u8 taskId)
{
if (gTasks[taskID].tFrameCounter < 128)
if (gTasks[taskId].tTimer < 128)
{
u8 i;
switch (gTasks[taskID].tFrameCounter)
switch (gTasks[taskId].tTimer)
{
default:
if (gTasks[taskID].tFrameCounter < 50)
CreatePostEvoSparkleSet2(Random() & 7);
if (gTasks[taskId].tTimer < 50)
CreateSparkle_Spray(Random() & 7);
break;
case 0:
for (i = 0; i < 8; i++)
CreatePostEvoSparkleSet2(i);
CreateSparkle_Spray(i);
break;
case 32:
BeginNormalPaletteFade(0xFFFF041C, 0x10, 0x10, 0, RGB_WHITE); // was 0xFFF9001C in R/S
break;
}
gTasks[taskID].tFrameCounter++;
gTasks[taskId].tTimer++;
}
else
gTasks[taskID].func = EvoTask_DestroyPostSet2AndFlashTask;
gTasks[taskId].func = Task_Sparkles_SprayAndFlash_End;
}
static void EvoTask_DestroyPostSet2AndFlashTask(u8 taskID)
static void Task_Sparkles_SprayAndFlash_End(u8 taskId)
{
if (!gPaletteFade.active)
DestroyTask(taskID);
DestroyTask(taskId);
}
u8 LaunchTask_PostEvoSparklesSet2AndFlash_Trade(u16 species)
// Separate from EvolutionSparkles_SprayAndFlash for difference in fade color
u8 EvolutionSparkles_SprayAndFlash_Trade(u16 species)
{
u8 taskID = CreateTask(EvoTask_BeginPostSparklesSet2_AndFlash_Trade, 0);
gTasks[taskID].data[2] = species;
return taskID;
u8 taskId = CreateTask(Task_Sparkles_SprayAndFlashTrade_Init, 0);
gTasks[taskId].tSpecies = species;
return taskId;
}
static void EvoTask_BeginPostSparklesSet2_AndFlash_Trade(u8 taskID)
static void Task_Sparkles_SprayAndFlashTrade_Init(u8 taskId)
{
SetEvoSparklesMatrices();
gTasks[taskID].tFrameCounter = 0;
gTasks[taskId].tTimer = 0;
CpuSet(&gPlttBufferFaded[0x20], &gPlttBufferUnfaded[0x20], 0x30);
BeginNormalPaletteFade(0xFFF90400, 0, 0, 0x10, RGB_WHITE); // was 0xFFFF0001 in R/S
gTasks[taskID].func = EvoTask_CreatePostEvoSparklesSet2_AndFlash_Trade;
gTasks[taskId].func = Task_Sparkles_SprayAndFlashTrade;
PlaySE(SE_M_PETAL_DANCE);
}
static void EvoTask_CreatePostEvoSparklesSet2_AndFlash_Trade(u8 taskID)
static void Task_Sparkles_SprayAndFlashTrade(u8 taskId)
{
if (gTasks[taskID].tFrameCounter < 128)
if (gTasks[taskId].tTimer < 128)
{
u8 i;
switch (gTasks[taskID].tFrameCounter)
switch (gTasks[taskId].tTimer)
{
default:
if (gTasks[taskID].tFrameCounter < 50)
CreatePostEvoSparkleSet2(Random() & 7);
if (gTasks[taskId].tTimer < 50)
CreateSparkle_Spray(Random() & 7);
break;
case 0:
for (i = 0; i < 8; i++)
CreatePostEvoSparkleSet2(i);
CreateSparkle_Spray(i);
break;
case 32:
BeginNormalPaletteFade(0xFFFF0400, 0x10, 0x10, 0, RGB_WHITE); // was 0xFFFF0001 in R/S
break;
}
gTasks[taskID].tFrameCounter++;
gTasks[taskId].tTimer++;
}
else
gTasks[taskID].func = EvoTask_DestroyPostSet2AndFlashTask;
gTasks[taskId].func = Task_Sparkles_SprayAndFlash_End;
}
#undef tFrameCounter
#undef tTimer
#undef tSpecies
static void PokeEvoSprite_DummySpriteCB(struct Sprite* sprite)
static void SpriteCB_EvolutionMonSprite(struct Sprite* sprite)
{
}
#define tPreEvoSpriteID data[1]
#define tPostEvoSpriteID data[2]
#define tPreEvoSpriteId data[1]
#define tPostEvoSpriteId data[2]
#define tPreEvoScale data[3]
#define tPostEvoScale data[4]
#define tShowingPostEvo data[5]
#define tScaleSpeed data[6]
#define tEvoStopped data[8]
u8 sub_817C3A0(u8 preEvoSpriteID, u8 postEvoSpriteID)
#define MATRIX_PRE_EVO 30
#define MATRIX_POST_EVO 31
#define MON_MAX_SCALE 256
#define MON_MIN_SCALE 16
// Alternately grow/shrink the pre-evolution and post-evolution mon sprites
u8 CycleEvolutionMonSprite(u8 preEvoSpriteId, u8 postEvoSpriteId)
{
u16 i;
u16 stack[16];
u8 taskID;
u8 taskId;
s32 toDiv;
for (i = 0; i < 16; i++)
for (i = 0; i < ARRAY_COUNT(stack); i++)
stack[i] = 0x7FFF;
taskID = CreateTask(sub_817C4EC, 0);
gTasks[taskID].tPreEvoSpriteID = preEvoSpriteID;
gTasks[taskID].tPostEvoSpriteID = postEvoSpriteID;
gTasks[taskID].data[3] = 256;
gTasks[taskID].data[4] = 16;
taskId = CreateTask(Task_CycleEvolutionMonSprite_Init, 0);
gTasks[taskId].tPreEvoSpriteId = preEvoSpriteId;
gTasks[taskId].tPostEvoSpriteId = postEvoSpriteId;
gTasks[taskId].tPreEvoScale = MON_MAX_SCALE;
gTasks[taskId].tPostEvoScale = MON_MIN_SCALE;
toDiv = 65536;
SetOamMatrix(30, 256, 0, 0, 256);
SetOamMatrix(31, toDiv / gTasks[taskID].data[4], 0, 0, toDiv / gTasks[taskID].data[4]);
SetOamMatrix(MATRIX_PRE_EVO, MON_MAX_SCALE, 0, 0, MON_MAX_SCALE);
SetOamMatrix(MATRIX_POST_EVO, toDiv / gTasks[taskId].tPostEvoScale, 0, 0, toDiv / gTasks[taskId].tPostEvoScale);
gSprites[preEvoSpriteID].callback = PokeEvoSprite_DummySpriteCB;
gSprites[preEvoSpriteID].oam.affineMode = ST_OAM_AFFINE_NORMAL;
gSprites[preEvoSpriteID].oam.matrixNum = 30;
gSprites[preEvoSpriteID].invisible = FALSE;
CpuSet(stack, &gPlttBufferFaded[0x100 + (gSprites[preEvoSpriteID].oam.paletteNum * 16)], 16);
gSprites[preEvoSpriteId].callback = SpriteCB_EvolutionMonSprite;
gSprites[preEvoSpriteId].oam.affineMode = ST_OAM_AFFINE_NORMAL;
gSprites[preEvoSpriteId].oam.matrixNum = MATRIX_PRE_EVO;
gSprites[preEvoSpriteId].invisible = FALSE;
CpuSet(stack, &gPlttBufferFaded[0x100 + (gSprites[preEvoSpriteId].oam.paletteNum * 16)], 16);
gSprites[postEvoSpriteID].callback = PokeEvoSprite_DummySpriteCB;
gSprites[postEvoSpriteID].oam.affineMode = ST_OAM_AFFINE_NORMAL;
gSprites[postEvoSpriteID].oam.matrixNum = 31;
gSprites[postEvoSpriteID].invisible = FALSE;
CpuSet(stack, &gPlttBufferFaded[0x100 + (gSprites[postEvoSpriteID].oam.paletteNum * 16)], 16);
gSprites[postEvoSpriteId].callback = SpriteCB_EvolutionMonSprite;
gSprites[postEvoSpriteId].oam.affineMode = ST_OAM_AFFINE_NORMAL;
gSprites[postEvoSpriteId].oam.matrixNum = MATRIX_POST_EVO;
gSprites[postEvoSpriteId].invisible = FALSE;
CpuSet(stack, &gPlttBufferFaded[0x100 + (gSprites[postEvoSpriteId].oam.paletteNum * 16)], 16);
gTasks[taskID].tEvoStopped = FALSE;
return taskID;
gTasks[taskId].tEvoStopped = FALSE;
return taskId;
}
static void sub_817C4EC(u8 taskID)
static void Task_CycleEvolutionMonSprite_Init(u8 taskId)
{
gTasks[taskID].data[5] = 0;
gTasks[taskID].data[6] = 8;
gTasks[taskID].func = sub_817C510;
gTasks[taskId].tShowingPostEvo = FALSE;
gTasks[taskId].tScaleSpeed = 8;
gTasks[taskId].func = Task_CycleEvolutionMonSprite_TryEnd;
}
static void sub_817C510(u8 taskID)
// Try to end sprite cycling
// If evo hasn't stopped or growth/shrink speed hasn't been maxed out, start another cycle
static void Task_CycleEvolutionMonSprite_TryEnd(u8 taskId)
{
if (gTasks[taskID].tEvoStopped)
PreEvoVisible_PostEvoInvisible_KillTask(taskID);
else if (gTasks[taskID].data[6] == 128)
PreEvoInvisible_PostEvoVisible_KillTask(taskID);
if (gTasks[taskId].tEvoStopped)
EndOnPreEvoMon(taskId);
else if (gTasks[taskId].tScaleSpeed == 128)
EndOnPostEvoMon(taskId);
else
{
gTasks[taskID].data[6] += 2;
gTasks[taskID].data[5] ^= 1;
gTasks[taskID].func = sub_817C560;
gTasks[taskId].tScaleSpeed += 2;
gTasks[taskId].tShowingPostEvo ^= 1;
gTasks[taskId].func = Task_CycleEvolutionMonSprite_UpdateSize;
}
}
static void sub_817C560(u8 taskID)
static void Task_CycleEvolutionMonSprite_UpdateSize(u8 taskId)
{
if (gTasks[taskID].tEvoStopped)
gTasks[taskID].func = PreEvoVisible_PostEvoInvisible_KillTask;
if (gTasks[taskId].tEvoStopped)
gTasks[taskId].func = EndOnPreEvoMon;
else
{
u16 oamMatrixArg;
u8 r6 = 0;
if (gTasks[taskID].data[5] == 0)
u8 numSpritesFinished = 0;
if (!gTasks[taskId].tShowingPostEvo)
{
if (gTasks[taskID].data[3] < 256 - gTasks[taskID].data[6])
gTasks[taskID].data[3] += gTasks[taskID].data[6];
// Set pre-evo sprite growth
if (gTasks[taskId].tPreEvoScale < MON_MAX_SCALE - gTasks[taskId].tScaleSpeed)
gTasks[taskId].tPreEvoScale += gTasks[taskId].tScaleSpeed;
else
{
gTasks[taskID].data[3] = 256;
r6++;
gTasks[taskId].tPreEvoScale = MON_MAX_SCALE;
numSpritesFinished++;
}
if (gTasks[taskID].data[4] > 16 + gTasks[taskID].data[6])
gTasks[taskID].data[4] -= gTasks[taskID].data[6];
else
{
gTasks[taskID].data[4] = 16;
r6++;
}
}
else
{
if (gTasks[taskID].data[4] < 256 - gTasks[taskID].data[6])
gTasks[taskID].data[4] += gTasks[taskID].data[6];
else
{
gTasks[taskID].data[4] = 256;
r6++;
}
if (gTasks[taskID].data[3] > 16 + gTasks[taskID].data[6])
gTasks[taskID].data[3] -= gTasks[taskID].data[6];
else
{
gTasks[taskID].data[3] = 16;
r6++;
}
}
oamMatrixArg = 65536 / gTasks[taskID].data[3];
SetOamMatrix(30, oamMatrixArg, 0, 0, oamMatrixArg);
oamMatrixArg = 65536 / gTasks[taskID].data[4];
SetOamMatrix(31, oamMatrixArg, 0, 0, oamMatrixArg);
if (r6 == 2)
gTasks[taskID].func = sub_817C510;
// Set post-evo sprite shrink
if (gTasks[taskId].tPostEvoScale > MON_MIN_SCALE + gTasks[taskId].tScaleSpeed)
gTasks[taskId].tPostEvoScale -= gTasks[taskId].tScaleSpeed;
else
{
gTasks[taskId].tPostEvoScale = MON_MIN_SCALE;
numSpritesFinished++;
}
}
else
{
// Set post-evo sprite growth
if (gTasks[taskId].tPostEvoScale < MON_MAX_SCALE - gTasks[taskId].tScaleSpeed)
gTasks[taskId].tPostEvoScale += gTasks[taskId].tScaleSpeed;
else
{
gTasks[taskId].tPostEvoScale = MON_MAX_SCALE;
numSpritesFinished++;
}
// Set pre-evo sprite shrink
if (gTasks[taskId].tPreEvoScale > MON_MIN_SCALE + gTasks[taskId].tScaleSpeed)
gTasks[taskId].tPreEvoScale -= gTasks[taskId].tScaleSpeed;
else
{
gTasks[taskId].tPreEvoScale = MON_MIN_SCALE;
numSpritesFinished++;
}
}
// Grow/shrink pre-evo sprite
oamMatrixArg = 65536 / gTasks[taskId].tPreEvoScale;
SetOamMatrix(MATRIX_PRE_EVO, oamMatrixArg, 0, 0, oamMatrixArg);
// Grow/shrink post-evo sprite
oamMatrixArg = 65536 / gTasks[taskId].tPostEvoScale;
SetOamMatrix(MATRIX_POST_EVO, oamMatrixArg, 0, 0, oamMatrixArg);
// Both sprites have reached their size extreme
if (numSpritesFinished == 2)
gTasks[taskId].func = Task_CycleEvolutionMonSprite_TryEnd;
}
}
static void PreEvoInvisible_PostEvoVisible_KillTask(u8 taskID)
static void EndOnPostEvoMon(u8 taskId)
{
gSprites[gTasks[taskID].tPreEvoSpriteID].oam.affineMode = ST_OAM_AFFINE_OFF;
gSprites[gTasks[taskID].tPreEvoSpriteID].oam.matrixNum = 0;
gSprites[gTasks[taskID].tPreEvoSpriteID].invisible = TRUE;
gSprites[gTasks[taskId].tPreEvoSpriteId].oam.affineMode = ST_OAM_AFFINE_OFF;
gSprites[gTasks[taskId].tPreEvoSpriteId].oam.matrixNum = 0;
gSprites[gTasks[taskId].tPreEvoSpriteId].invisible = TRUE;
gSprites[gTasks[taskID].tPostEvoSpriteID].oam.affineMode = ST_OAM_AFFINE_OFF;
gSprites[gTasks[taskID].tPostEvoSpriteID].oam.matrixNum = 0;
gSprites[gTasks[taskID].tPostEvoSpriteID].invisible = FALSE;
gSprites[gTasks[taskId].tPostEvoSpriteId].oam.affineMode = ST_OAM_AFFINE_OFF;
gSprites[gTasks[taskId].tPostEvoSpriteId].oam.matrixNum = 0;
gSprites[gTasks[taskId].tPostEvoSpriteId].invisible = FALSE;
DestroyTask(taskID);
DestroyTask(taskId);
}
static void PreEvoVisible_PostEvoInvisible_KillTask(u8 taskID)
static void EndOnPreEvoMon(u8 taskId)
{
gSprites[gTasks[taskID].tPreEvoSpriteID].oam.affineMode = ST_OAM_AFFINE_OFF;
gSprites[gTasks[taskID].tPreEvoSpriteID].oam.matrixNum = 0;
gSprites[gTasks[taskID].tPreEvoSpriteID].invisible = FALSE;
gSprites[gTasks[taskId].tPreEvoSpriteId].oam.affineMode = ST_OAM_AFFINE_OFF;
gSprites[gTasks[taskId].tPreEvoSpriteId].oam.matrixNum = 0;
gSprites[gTasks[taskId].tPreEvoSpriteId].invisible = FALSE;
gSprites[gTasks[taskID].tPostEvoSpriteID].oam.affineMode = ST_OAM_AFFINE_OFF;
gSprites[gTasks[taskID].tPostEvoSpriteID].oam.matrixNum = 0;
gSprites[gTasks[taskID].tPostEvoSpriteID].invisible = TRUE;
gSprites[gTasks[taskId].tPostEvoSpriteId].oam.affineMode = ST_OAM_AFFINE_OFF;
gSprites[gTasks[taskId].tPostEvoSpriteId].oam.matrixNum = 0;
gSprites[gTasks[taskId].tPostEvoSpriteId].invisible = TRUE;
DestroyTask(taskID);
DestroyTask(taskId);
}

File diff suppressed because it is too large Load Diff

View File

@ -2993,7 +2993,7 @@ void GiveBoxMonInitialMoveset(struct BoxPokemon *boxMon)
u16 MonTryLearningNewMove(struct Pokemon *mon, bool8 firstMove)
{
u32 retVal = 0;
u32 retVal = MOVE_NONE;
u16 species = GetMonData(mon, MON_DATA_SPECIES, NULL);
u8 level = GetMonData(mon, MON_DATA_LEVEL, NULL);
@ -3009,7 +3009,7 @@ u16 MonTryLearningNewMove(struct Pokemon *mon, bool8 firstMove)
{
sLearningMoveTableID++;
if (gLevelUpLearnsets[species][sLearningMoveTableID] == LEVEL_UP_END)
return 0;
return MOVE_NONE;
}
}