Merge pull request #1915 from GriffinRichards/misc-tasks

Add some task/sprite data defines
This commit is contained in:
GriffinR 2023-10-07 21:34:52 -04:00 committed by GitHub
commit 104e81b359
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 585 additions and 491 deletions

File diff suppressed because it is too large Load diff

View file

@ -205,22 +205,45 @@ static bool8 UNUSED StartMenu_ShowMapNamePopup(void)
return TRUE;
}
// States and data defines for Task_MapNamePopUpWindow
enum {
STATE_SLIDE_IN,
STATE_WAIT,
STATE_SLIDE_OUT,
STATE_UNUSED,
STATE_ERASE,
STATE_END,
STATE_PRINT, // For some reason the first state is numerically last.
};
#define POPUP_OFFSCREEN_Y 40
#define POPUP_SLIDE_SPEED 2
#define tState data[0]
#define tOnscreenTimer data[1]
#define tYOffset data[2]
#define tIncomingPopUp data[3]
#define tPrintTimer data[4]
void ShowMapNamePopup(void)
{
if (FlagGet(FLAG_HIDE_MAP_NAME_POPUP) != TRUE)
{
if (!FuncIsActiveTask(Task_MapNamePopUpWindow))
{
// New pop up window
sPopupTaskId = CreateTask(Task_MapNamePopUpWindow, 90);
SetGpuReg(REG_OFFSET_BG0VOFS, 40);
gTasks[sPopupTaskId].data[0] = 6;
gTasks[sPopupTaskId].data[2] = 40;
SetGpuReg(REG_OFFSET_BG0VOFS, POPUP_OFFSCREEN_Y);
gTasks[sPopupTaskId].tState = STATE_PRINT;
gTasks[sPopupTaskId].tYOffset = POPUP_OFFSCREEN_Y;
}
else
{
if (gTasks[sPopupTaskId].data[0] != 2)
gTasks[sPopupTaskId].data[0] = 2;
gTasks[sPopupTaskId].data[3] = 1;
// There's already a pop up window running.
// Hurry the old pop up offscreen so the new one can appear.
if (gTasks[sPopupTaskId].tState != STATE_SLIDE_OUT)
gTasks[sPopupTaskId].tState = STATE_SLIDE_OUT;
gTasks[sPopupTaskId].tIncomingPopUp = TRUE;
}
}
}
@ -229,61 +252,65 @@ static void Task_MapNamePopUpWindow(u8 taskId)
{
struct Task *task = &gTasks[taskId];
switch (task->data[0])
switch (task->tState)
{
case 6:
task->data[4]++;
if (task->data[4] > 30)
case STATE_PRINT:
// Wait, then create and print the pop up window
if (++task->tPrintTimer > 30)
{
task->data[0] = 0;
task->data[4] = 0;
task->tState = STATE_SLIDE_IN;
task->tPrintTimer = 0;
ShowMapNamePopUpWindow();
}
break;
case 0:
task->data[2] -= 2;
if (task->data[2] <= 0 )
case STATE_SLIDE_IN:
// Slide the window onscreen.
task->tYOffset -= POPUP_SLIDE_SPEED;
if (task->tYOffset <= 0 )
{
task->data[2] = 0;
task->data[0] = 1;
task->tYOffset = 0;
task->tState = STATE_WAIT;
gTasks[sPopupTaskId].data[1] = 0;
}
break;
case 1:
task->data[1]++;
if (task->data[1] > 120 )
case STATE_WAIT:
// Wait while the window is fully onscreen.
if (++task->tOnscreenTimer > 120)
{
task->data[1] = 0;
task->data[0] = 2;
task->tOnscreenTimer = 0;
task->tState = STATE_SLIDE_OUT;
}
break;
case 2:
task->data[2] += 2;
if (task->data[2] > 39)
case STATE_SLIDE_OUT:
// Slide the window offscreen.
task->tYOffset += POPUP_SLIDE_SPEED;
if (task->tYOffset >= POPUP_OFFSCREEN_Y)
{
task->data[2] = 40;
if (task->data[3])
task->tYOffset = POPUP_OFFSCREEN_Y;
if (task->tIncomingPopUp)
{
task->data[0] = 6;
task->data[4] = 0;
task->data[3] = 0;
// A new pop up window is incoming,
// return to the first state to show it.
task->tState = STATE_PRINT;
task->tPrintTimer = 0;
task->tIncomingPopUp = FALSE;
}
else
{
task->data[0] = 4;
task->tState = STATE_ERASE;
return;
}
}
break;
case 4:
case STATE_ERASE:
ClearStdWindowAndFrame(GetMapNamePopUpWindowId(), TRUE);
task->data[0] = 5;
task->tState = STATE_END;
break;
case 5:
case STATE_END:
HideMapNamePopUpWindow();
return;
}
SetGpuReg(REG_OFFSET_BG0VOFS, task->data[2]);
SetGpuReg(REG_OFFSET_BG0VOFS, task->tYOffset);
}
void HideMapNamePopUpWindow(void)

View file

@ -23,6 +23,12 @@
#include "constants/rgb.h"
#include "constants/songs.h"
enum {
TAG_VERSION = 1000,
TAG_PRESS_START_COPYRIGHT,
TAG_LOGO_SHINE,
};
#define VERSION_BANNER_RIGHT_TILEOFFSET 64
#define VERSION_BANNER_LEFT_X 98
#define VERSION_BANNER_RIGHT_X 162
@ -158,8 +164,8 @@ static const union AnimCmd *const sVersionBannerRightAnimTable[] =
static const struct SpriteTemplate sVersionBannerLeftSpriteTemplate =
{
.tileTag = 1000,
.paletteTag = 1000,
.tileTag = TAG_VERSION,
.paletteTag = TAG_VERSION,
.oam = &sVersionBannerLeftOamData,
.anims = sVersionBannerLeftAnimTable,
.images = NULL,
@ -169,8 +175,8 @@ static const struct SpriteTemplate sVersionBannerLeftSpriteTemplate =
static const struct SpriteTemplate sVersionBannerRightSpriteTemplate =
{
.tileTag = 1000,
.paletteTag = 1000,
.tileTag = TAG_VERSION,
.paletteTag = TAG_VERSION,
.oam = &sVersionBannerRightOamData,
.anims = sVersionBannerRightAnimTable,
.images = NULL,
@ -183,7 +189,7 @@ static const struct CompressedSpriteSheet sSpriteSheet_EmeraldVersion[] =
{
.data = gTitleScreenEmeraldVersionGfx,
.size = 0x1000,
.tag = 1000
.tag = TAG_VERSION
},
{},
};
@ -205,75 +211,80 @@ static const struct OamData sOamData_CopyrightBanner =
.affineParam = 0,
};
static const union AnimCmd sCopyrightBannerAnim0[] =
static const union AnimCmd sAnim_PressStart_0[] =
{
ANIMCMD_FRAME(1, 4),
ANIMCMD_END,
};
static const union AnimCmd sCopyrightBannerAnim1[] =
static const union AnimCmd sAnim_PressStart_1[] =
{
ANIMCMD_FRAME(5, 4),
ANIMCMD_END,
};
static const union AnimCmd sCopyrightBannerAnim2[] =
static const union AnimCmd sAnim_PressStart_2[] =
{
ANIMCMD_FRAME(9, 4),
ANIMCMD_END,
};
static const union AnimCmd sCopyrightBannerAnim3[] =
static const union AnimCmd sAnim_PressStart_3[] =
{
ANIMCMD_FRAME(13, 4),
ANIMCMD_END,
};
static const union AnimCmd sCopyrightBannerAnim4[] =
static const union AnimCmd sAnim_PressStart_4[] =
{
ANIMCMD_FRAME(17, 4),
ANIMCMD_END,
};
static const union AnimCmd sCopyrightBannerAnim5[] =
static const union AnimCmd sAnim_Copyright_0[] =
{
ANIMCMD_FRAME(21, 4),
ANIMCMD_END,
};
static const union AnimCmd sCopyrightBannerAnim6[] =
static const union AnimCmd sAnim_Copyright_1[] =
{
ANIMCMD_FRAME(25, 4),
ANIMCMD_END,
};
static const union AnimCmd sCopyrightBannerAnim7[] =
static const union AnimCmd sAnim_Copyright_2[] =
{
ANIMCMD_FRAME(29, 4),
ANIMCMD_END,
};
static const union AnimCmd sCopyrightBannerAnim8[] =
static const union AnimCmd sAnim_Copyright_3[] =
{
ANIMCMD_FRAME(33, 4),
ANIMCMD_END,
};
static const union AnimCmd sCopyrightBannerAnim9[] =
static const union AnimCmd sAnim_Copyright_4[] =
{
ANIMCMD_FRAME(37, 4),
ANIMCMD_END,
};
static const union AnimCmd *const sStartCopyrightBannerAnimTable[] =
// The "Press Start" and copyright graphics are each 5 32x8 segments long
#define NUM_PRESS_START_FRAMES 5
#define NUM_COPYRIGHT_FRAMES 5
static const union AnimCmd *const sStartCopyrightBannerAnimTable[NUM_PRESS_START_FRAMES + NUM_COPYRIGHT_FRAMES] =
{
sCopyrightBannerAnim0,
sCopyrightBannerAnim1,
sCopyrightBannerAnim2,
sCopyrightBannerAnim3,
sCopyrightBannerAnim4,
sCopyrightBannerAnim5,
sCopyrightBannerAnim6,
sCopyrightBannerAnim7,
sCopyrightBannerAnim8,
sCopyrightBannerAnim9,
sAnim_PressStart_0,
sAnim_PressStart_1,
sAnim_PressStart_2,
sAnim_PressStart_3,
sAnim_PressStart_4,
[NUM_PRESS_START_FRAMES] =
sAnim_Copyright_0,
sAnim_Copyright_1,
sAnim_Copyright_2,
sAnim_Copyright_3,
sAnim_Copyright_4,
};
static const struct SpriteTemplate sStartCopyrightBannerSpriteTemplate =
{
.tileTag = 1001,
.paletteTag = 1001,
.tileTag = TAG_PRESS_START_COPYRIGHT,
.paletteTag = TAG_PRESS_START_COPYRIGHT,
.oam = &sOamData_CopyrightBanner,
.anims = sStartCopyrightBannerAnimTable,
.images = NULL,
@ -286,7 +297,7 @@ static const struct CompressedSpriteSheet sSpriteSheet_PressStart[] =
{
.data = gTitleScreenPressStartGfx,
.size = 0x520,
.tag = 1001
.tag = TAG_PRESS_START_COPYRIGHT
},
{},
};
@ -295,7 +306,7 @@ static const struct SpritePalette sSpritePalette_PressStart[] =
{
{
.data = gTitleScreenPressStartPal,
.tag = 1001
.tag = TAG_PRESS_START_COPYRIGHT
},
{},
};
@ -330,8 +341,8 @@ static const union AnimCmd *const sPokemonLogoShineAnimTable[] =
static const struct SpriteTemplate sPokemonLogoShineSpriteTemplate =
{
.tileTag = 1002,
.paletteTag = 1001,
.tileTag = TAG_LOGO_SHINE,
.paletteTag = TAG_PRESS_START_COPYRIGHT,
.oam = &sPokemonLogoShineOamData,
.anims = sPokemonLogoShineAnimTable,
.images = NULL,
@ -344,15 +355,25 @@ static const struct CompressedSpriteSheet sPokemonLogoShineSpriteSheet[] =
{
.data = sTitleScreenLogoShineGfx,
.size = 0x800,
.tag = 1002
.tag = TAG_LOGO_SHINE
},
{},
};
// code
// Task data for the main title screen tasks (Task_TitleScreenPhase#)
#define tCounter data[0]
#define tSkipToNext data[1]
#define tPointless data[2] // Incremented but never used to do anything.
#define tBg2Y data[3]
#define tBg1Y data[4]
// Sprite data for sVersionBannerLeftSpriteTemplate / sVersionBannerRightSpriteTemplate
#define sAlphaBlendIdx data[0]
#define sParentTaskId data[1]
static void SpriteCB_VersionBannerLeft(struct Sprite *sprite)
{
if (gTasks[sprite->data[1]].data[1] != 0)
if (gTasks[sprite->sParentTaskId].tSkipToNext)
{
sprite->oam.objMode = ST_OAM_OBJ_NORMAL;
sprite->y = VERSION_BANNER_Y_GOAL;
@ -361,15 +382,15 @@ static void SpriteCB_VersionBannerLeft(struct Sprite *sprite)
{
if (sprite->y != VERSION_BANNER_Y_GOAL)
sprite->y++;
if (sprite->data[0] != 0)
sprite->data[0]--;
SetGpuReg(REG_OFFSET_BLDALPHA, gTitleScreenAlphaBlend[sprite->data[0]]);
if (sprite->sAlphaBlendIdx != 0)
sprite->sAlphaBlendIdx--;
SetGpuReg(REG_OFFSET_BLDALPHA, gTitleScreenAlphaBlend[sprite->sAlphaBlendIdx]);
}
}
static void SpriteCB_VersionBannerRight(struct Sprite *sprite)
{
if (gTasks[sprite->data[1]].data[1] != 0)
if (gTasks[sprite->sParentTaskId].tSkipToNext)
{
sprite->oam.objMode = ST_OAM_OBJ_NORMAL;
sprite->y = VERSION_BANNER_Y_GOAL;
@ -381,13 +402,16 @@ static void SpriteCB_VersionBannerRight(struct Sprite *sprite)
}
}
// Sprite data for SpriteCB_PressStartCopyrightBanner
#define sAnimate data[0]
#define sTimer data[1]
static void SpriteCB_PressStartCopyrightBanner(struct Sprite *sprite)
{
if (sprite->data[0] == 1)
if (sprite->sAnimate == TRUE)
{
sprite->data[1]++;
// Alternate between hidden and shown every 16th frame
if (sprite->data[1] & 16)
if (++sprite->sTimer & 16)
sprite->invisible = FALSE;
else
sprite->invisible = TRUE;
@ -404,11 +428,11 @@ static void CreatePressStartBanner(s16 x, s16 y)
u8 spriteId;
x -= 64;
for (i = 0; i < 5; i++, x += 32)
for (i = 0; i < NUM_PRESS_START_FRAMES; i++, x += 32)
{
spriteId = CreateSprite(&sStartCopyrightBannerSpriteTemplate, x, y, 0);
StartSpriteAnim(&gSprites[spriteId], i);
gSprites[spriteId].data[0] = 1;
gSprites[spriteId].sAnimate = TRUE;
}
}
@ -418,93 +442,122 @@ static void CreateCopyrightBanner(s16 x, s16 y)
u8 spriteId;
x -= 64;
for (i = 0; i < 5; i++, x += 32)
for (i = 0; i < NUM_COPYRIGHT_FRAMES; i++, x += 32)
{
spriteId = CreateSprite(&sStartCopyrightBannerSpriteTemplate, x, y, 0);
StartSpriteAnim(&gSprites[spriteId], i + 5);
StartSpriteAnim(&gSprites[spriteId], i + NUM_PRESS_START_FRAMES);
}
}
#undef sAnimate
#undef sTimer
// Defines for SpriteCB_PokemonLogoShine
enum {
SHINE_MODE_SINGLE_NO_BG_COLOR,
SHINE_MODE_DOUBLE,
SHINE_MODE_SINGLE,
};
#define SHINE_SPEED 4
#define sMode data[0]
#define sBgColor data[1]
static void SpriteCB_PokemonLogoShine(struct Sprite *sprite)
{
if (sprite->x < DISPLAY_WIDTH + 32)
{
if (sprite->data[0]) // Flash background
// In any mode except SHINE_MODE_SINGLE_NO_BG_COLOR the background
// color will change, in addition to the shine sprite moving.
if (sprite->sMode != SHINE_MODE_SINGLE_NO_BG_COLOR)
{
u16 backgroundColor;
if (sprite->x < DISPLAY_WIDTH / 2)
{
// Brighten background color
if (sprite->data[1] < 31)
sprite->data[1]++;
if (sprite->data[1] < 31)
sprite->data[1]++;
if (sprite->sBgColor < 31)
sprite->sBgColor++;
if (sprite->sBgColor < 31)
sprite->sBgColor++;
}
else
{
// Darken background color
if (sprite->data[1] != 0)
sprite->data[1]--;
if (sprite->data[1] != 0)
sprite->data[1]--;
if (sprite->sBgColor != 0)
sprite->sBgColor--;
if (sprite->sBgColor != 0)
sprite->sBgColor--;
}
backgroundColor = _RGB(sprite->data[1], sprite->data[1], sprite->data[1]);
if (sprite->x == DISPLAY_WIDTH / 2 + 12
|| sprite->x == DISPLAY_WIDTH / 2 + 16
|| sprite->x == DISPLAY_WIDTH / 2 + 20
|| sprite->x == DISPLAY_WIDTH / 2 + 24)
backgroundColor = _RGB(sprite->sBgColor, sprite->sBgColor, sprite->sBgColor);
// Flash the background green for 4 frames of movement.
// Otherwise use the updating color.
if (sprite->x == DISPLAY_WIDTH / 2 + (3 * SHINE_SPEED)
|| sprite->x == DISPLAY_WIDTH / 2 + (4 * SHINE_SPEED)
|| sprite->x == DISPLAY_WIDTH / 2 + (5 * SHINE_SPEED)
|| sprite->x == DISPLAY_WIDTH / 2 + (6 * SHINE_SPEED))
gPlttBufferFaded[0] = RGB(24, 31, 12);
else
gPlttBufferFaded[0] = backgroundColor;
}
sprite->x += 4;
sprite->x += SHINE_SPEED;
}
else
{
// Sprite has moved fully offscreen
gPlttBufferFaded[0] = RGB_BLACK;
DestroySprite(sprite);
}
}
static void SpriteCB_PokemonLogoShine2(struct Sprite *sprite)
static void SpriteCB_PokemonLogoShine_Fast(struct Sprite *sprite)
{
if (sprite->x < DISPLAY_WIDTH + 32)
sprite->x += 8;
sprite->x += SHINE_SPEED * 2;
else
DestroySprite(sprite);
}
static void StartPokemonLogoShine(u8 flashBg)
static void StartPokemonLogoShine(u8 mode)
{
u8 spriteId;
switch (flashBg)
switch (mode)
{
case 0:
case 2:
case SHINE_MODE_SINGLE_NO_BG_COLOR:
case SHINE_MODE_SINGLE:
// Create one regular shine sprite.
// If mode is SHINE_MODE_SINGLE it will also change the background color.
spriteId = CreateSprite(&sPokemonLogoShineSpriteTemplate, 0, 68, 0);
gSprites[spriteId].oam.objMode = ST_OAM_OBJ_WINDOW;
gSprites[spriteId].data[0] = flashBg;
gSprites[spriteId].sMode = mode;
break;
case 1:
case SHINE_MODE_DOUBLE:
// Create an invisible sprite with mode set to update the background color
spriteId = CreateSprite(&sPokemonLogoShineSpriteTemplate, 0, 68, 0);
gSprites[spriteId].oam.objMode = ST_OAM_OBJ_WINDOW;
gSprites[spriteId].data[0] = flashBg;
gSprites[spriteId].sMode = mode;
gSprites[spriteId].invisible = TRUE;
// Create two faster shine sprites
spriteId = CreateSprite(&sPokemonLogoShineSpriteTemplate, 0, 68, 0);
gSprites[spriteId].callback = SpriteCB_PokemonLogoShine2;
gSprites[spriteId].callback = SpriteCB_PokemonLogoShine_Fast;
gSprites[spriteId].oam.objMode = ST_OAM_OBJ_WINDOW;
spriteId = CreateSprite(&sPokemonLogoShineSpriteTemplate, -80, 68, 0);
gSprites[spriteId].callback = SpriteCB_PokemonLogoShine2;
gSprites[spriteId].callback = SpriteCB_PokemonLogoShine_Fast;
gSprites[spriteId].oam.objMode = ST_OAM_OBJ_WINDOW;
break;
}
}
#undef sMode
#undef sBgColor
static void VBlankCB(void)
{
ScanlineEffect_InitHBlankDmaTransfer();
@ -514,9 +567,6 @@ static void VBlankCB(void)
SetGpuReg(REG_OFFSET_BG1VOFS, gBattle_BG1_Y);
}
#define tCounter data[0]
#define tSkipToNext data[1]
void CB2_InitTitleScreen(void)
{
switch (gMain.state)
@ -573,13 +623,13 @@ void CB2_InitTitleScreen(void)
gTasks[taskId].tCounter = 256;
gTasks[taskId].tSkipToNext = FALSE;
gTasks[taskId].data[2] = -16;
gTasks[taskId].data[3] = -32;
gTasks[taskId].tPointless = -16;
gTasks[taskId].tBg2Y = -32;
gMain.state = 3;
break;
}
case 3:
BeginNormalPaletteFade(PALETTES_ALL, 1, 0x10, 0, RGB_WHITEALPHA);
BeginNormalPaletteFade(PALETTES_ALL, 1, 16, 0, RGB_WHITEALPHA);
SetVBlankCallback(VBlankCB);
gMain.state = 4;
break;
@ -614,7 +664,7 @@ void CB2_InitTitleScreen(void)
case 5:
if (!UpdatePaletteFade())
{
StartPokemonLogoShine(0);
StartPokemonLogoShine(SHINE_MODE_SINGLE_NO_BG_COLOR);
ScanlineEffect_InitWave(0, DISPLAY_HEIGHT, 4, 4, 0, SCANLINE_EFFECT_REG_BG1HOFS, TRUE);
SetMainCallback2(MainCB2);
}
@ -634,7 +684,7 @@ static void MainCB2(void)
static void Task_TitleScreenPhase1(u8 taskId)
{
// Skip to next phase when A, B, Start, or Select is pressed
if (JOY_NEW(A_B_START_SELECT) || gTasks[taskId].data[1] != 0)
if (JOY_NEW(A_B_START_SELECT) || gTasks[taskId].tSkipToNext)
{
gTasks[taskId].tSkipToNext = TRUE;
gTasks[taskId].tCounter = 0;
@ -644,9 +694,9 @@ static void Task_TitleScreenPhase1(u8 taskId)
{
u16 frameNum = gTasks[taskId].tCounter;
if (frameNum == 176)
StartPokemonLogoShine(1);
StartPokemonLogoShine(SHINE_MODE_DOUBLE);
else if (frameNum == 64)
StartPokemonLogoShine(2);
StartPokemonLogoShine(SHINE_MODE_SINGLE);
gTasks[taskId].tCounter--;
}
@ -663,18 +713,21 @@ static void Task_TitleScreenPhase1(u8 taskId)
// Create left side of version banner
spriteId = CreateSprite(&sVersionBannerLeftSpriteTemplate, VERSION_BANNER_LEFT_X, VERSION_BANNER_Y, 0);
gSprites[spriteId].data[0] = 64;
gSprites[spriteId].data[1] = taskId;
gSprites[spriteId].sAlphaBlendIdx = ARRAY_COUNT(gTitleScreenAlphaBlend);
gSprites[spriteId].sParentTaskId = taskId;
// Create right side of version banner
spriteId = CreateSprite(&sVersionBannerRightSpriteTemplate, VERSION_BANNER_RIGHT_X, VERSION_BANNER_Y, 0);
gSprites[spriteId].data[1] = taskId;
gSprites[spriteId].sParentTaskId = taskId;
gTasks[taskId].tCounter = 144;
gTasks[taskId].func = Task_TitleScreenPhase2;
}
}
#undef sParentTaskId
#undef sAlphaBlendIdx
// Create "Press Start" and copyright banners, and slide Pokemon logo up
static void Task_TitleScreenPhase2(u8 taskId)
{
@ -705,31 +758,31 @@ static void Task_TitleScreenPhase2(u8 taskId)
| DISPCNT_OBJ_ON);
CreatePressStartBanner(START_BANNER_X, 108);
CreateCopyrightBanner(START_BANNER_X, 148);
gTasks[taskId].data[4] = 0;
gTasks[taskId].tBg1Y = 0;
gTasks[taskId].func = Task_TitleScreenPhase3;
}
if (!(gTasks[taskId].tCounter & 3) && gTasks[taskId].data[2] != 0)
gTasks[taskId].data[2]++;
if (!(gTasks[taskId].tCounter & 1) && gTasks[taskId].data[3] != 0)
gTasks[taskId].data[3]++;
if (!(gTasks[taskId].tCounter & 3) && gTasks[taskId].tPointless != 0)
gTasks[taskId].tPointless++;
if (!(gTasks[taskId].tCounter & 1) && gTasks[taskId].tBg2Y != 0)
gTasks[taskId].tBg2Y++;
// Slide Pokemon logo up
yPos = gTasks[taskId].data[3] * 256;
yPos = gTasks[taskId].tBg2Y * 256;
SetGpuReg(REG_OFFSET_BG2Y_L, yPos);
SetGpuReg(REG_OFFSET_BG2Y_H, yPos / 0x10000);
gTasks[taskId].data[5] = 15;
gTasks[taskId].data[6] = 6;
gTasks[taskId].data[5] = 15; // Unused
gTasks[taskId].data[6] = 6; // Unused
}
// Show Rayquaza silhouette and process main title screen input
static void Task_TitleScreenPhase3(u8 taskId)
{
if ((JOY_NEW(A_BUTTON)) || (JOY_NEW(START_BUTTON)))
if (JOY_NEW(A_BUTTON) || JOY_NEW(START_BUTTON))
{
FadeOutBGM(4);
BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 0x10, RGB_WHITEALPHA);
BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 16, RGB_WHITEALPHA);
SetMainCallback2(CB2_GoToMainMenu);
}
else if (JOY_HELD(CLEAR_SAVE_BUTTON_COMBO) == CLEAR_SAVE_BUTTON_COMBO)
@ -740,30 +793,29 @@ static void Task_TitleScreenPhase3(u8 taskId)
&& CanResetRTC() == TRUE)
{
FadeOutBGM(4);
BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 0x10, RGB_BLACK);
BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 16, RGB_BLACK);
SetMainCallback2(CB2_GoToResetRtcScreen);
}
else if (JOY_HELD(BERRY_UPDATE_BUTTON_COMBO) == BERRY_UPDATE_BUTTON_COMBO)
{
FadeOutBGM(4);
BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 0x10, RGB_BLACK);
BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 16, RGB_BLACK);
SetMainCallback2(CB2_GoToBerryFixScreen);
}
else
{
SetGpuReg(REG_OFFSET_BG2Y_L, 0);
SetGpuReg(REG_OFFSET_BG2Y_H, 0);
gTasks[taskId].tCounter++;
if (gTasks[taskId].tCounter & 1)
if (++gTasks[taskId].tCounter & 1)
{
gTasks[taskId].data[4]++;
gBattle_BG1_Y = gTasks[taskId].data[4] / 2;
gTasks[taskId].tBg1Y++;
gBattle_BG1_Y = gTasks[taskId].tBg1Y / 2;
gBattle_BG1_X = 0;
}
UpdateLegendaryMarkingColor(gTasks[taskId].tCounter);
if ((gMPlayInfo_BGM.status & 0xFFFF) == 0)
{
BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 0x10, RGB_WHITEALPHA);
BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 16, RGB_WHITEALPHA);
SetMainCallback2(CB2_GoToCopyrightScreen);
}
}

View file

@ -1115,7 +1115,7 @@ static u8 UNUSED GetPartyIdFromSelectionId_(u8 selectionId)
static void LoadAndCreateUpDownSprites(void)
{
u16 i, spriteId;
u16 i;
LoadSpriteSheet(&sSpriteSheet_UpDown);
LoadSpritePalette(&sSpritePalette_UpDown);
@ -1125,7 +1125,7 @@ static void LoadAndCreateUpDownSprites(void)
{
if (sInfo->enhancements[i] != 0)
{
spriteId = CreateSprite(&sSpriteTemplate_UpDown, sUpDownCoordsOnGraph[i][0], sUpDownCoordsOnGraph[i][1], 0);
u16 spriteId = CreateSprite(&sSpriteTemplate_UpDown, sUpDownCoordsOnGraph[i][0], sUpDownCoordsOnGraph[i][1], 0);
if (spriteId != MAX_SPRITES)
{
if (sInfo->enhancements[i] != 0) // Always true here
@ -1136,20 +1136,24 @@ static void LoadAndCreateUpDownSprites(void)
}
}
#define tTimer data[0]
static void SpriteCB_UpDown(struct Sprite *sprite)
{
if (sprite->data[0] < 6)
if (sprite->tTimer < 6)
sprite->y2 -= 2;
else if (sprite->data[0] < 12)
else if (sprite->tTimer < 12)
sprite->y2 += 2;
if (++sprite->data[0] > 60)
if (++sprite->tTimer > 60)
{
DestroySprite(sprite);
sInfo->numEnhancements--;
}
}
#undef tTimer
static void LoadPartyInfo(void)
{
u16 i;
@ -1611,12 +1615,15 @@ static void LoadConditionGfx(void)
LoadSpritePalette(&spritePalette);
}
#define sSpeed data[0]
#define sTargetX data[1]
static void CreateConditionSprite(void)
{
u16 i;
s16 xDiff, xStart;
int yStart = 17;
int var = 8;
int speed = 8;
struct Sprite **sprites = sMenu->condition;
const struct SpriteTemplate *template = &sSpriteTemplate_Condition;
@ -1625,9 +1632,9 @@ static void CreateConditionSprite(void)
u8 spriteId = CreateSprite(template, i * xDiff + xStart, yStart, 0);
if (spriteId != MAX_SPRITES)
{
gSprites[spriteId].data[0] = var;
gSprites[spriteId].data[1] = (i * xDiff) | 0x20;
gSprites[spriteId].data[2] = i;
gSprites[spriteId].sSpeed = speed;
gSprites[spriteId].sTargetX = (i * xDiff) | 0x20;
gSprites[spriteId].data[2] = i; // Unused
StartSpriteAnim(&gSprites[spriteId], i);
sprites[i] = &gSprites[spriteId];
}
@ -1656,11 +1663,15 @@ static void SpriteCB_Condition(struct Sprite *sprite)
{
s16 prevX = sprite->x;
sprite->x += sprite->data[0];
if ((prevX <= sprite->data[1] && sprite->x >= sprite->data[1])
|| (prevX >= sprite->data[1] && sprite->x <= sprite->data[1]))
// Slide onscreen
sprite->x += sprite->sSpeed;
// Check if target position has been reached/surpassed
if ((prevX <= sprite->sTargetX && sprite->x >= sprite->sTargetX)
|| (prevX >= sprite->sTargetX && sprite->x <= sprite->sTargetX))
{
sprite->x = sprite->data[1];
// End slide onscreen, become static sprite.
sprite->x = sprite->sTargetX;
sprite->callback = SpriteCallbackDummy;
}
}