Merge pull request #553 from GriffinRichards/sync-fld-weather-eff

Sync field weather effects
This commit is contained in:
GriffinR
2022-09-12 17:56:14 -04:00
committed by GitHub
2 changed files with 167 additions and 126 deletions
+147 -120
View File
@@ -30,7 +30,7 @@ static const struct Coords16 sCloudSpriteMapCoords[] = {
static const struct SpriteSheet sCloudSpriteSheet = {
.data = gWeatherCloudTiles,
.size = 0x0800,
.tag = 0x1200
.tag = GFXTAG_CLOUD
};
static const struct OamData sCloudSpriteOamData = {
@@ -59,8 +59,8 @@ static const union AnimCmd *const sCloudSpriteAnimCmds[] = {
};
static const struct SpriteTemplate sCloudSpriteTemplate = {
.tileTag = 0x1200,
.paletteTag = 0x1200,
.tileTag = GFXTAG_CLOUD,
.paletteTag = PALTAG_WEATHER,
.oam = &sCloudSpriteOamData,
.anims = sCloudSpriteAnimCmds,
.images = NULL,
@@ -189,7 +189,7 @@ static void DestroyCloudSprites(void)
DestroySprite(gWeatherPtr->sprites.s1.cloudSprites[i]);
}
FreeSpriteTilesByTag(0x1200);
FreeSpriteTilesByTag(GFXTAG_CLOUD);
gWeatherPtr->cloudSpritesCreated = FALSE;
}
@@ -405,8 +405,8 @@ static const union AnimCmd *const sRainSpriteAnimCmds[] = {
};
static const struct SpriteTemplate sRainSpriteTemplate = {
.tileTag = 0x1206,
.paletteTag = 0x1200,
.tileTag = GFXTAG_RAIN,
.paletteTag = PALTAG_WEATHER,
.oam = &sRainSpriteOamData,
.anims = sRainSpriteAnimCmds,
.images = NULL,
@@ -431,7 +431,7 @@ static const u16 sRainSpriteFallingDurations[][2] = {
static const struct SpriteSheet sRainSpriteSheet = {
.data = gWeatherRainTiles,
.size = 0x0600,
.tag = 0x1206,
.tag = GFXTAG_RAIN,
};
void Rain_InitVars(void)
@@ -482,8 +482,8 @@ bool8 Rain_Finish(void)
{
case 0:
if (gWeatherPtr->nextWeather == WEATHER_RAIN
|| gWeatherPtr->nextWeather == WEATHER_RAIN_THUNDERSTORM
|| gWeatherPtr->nextWeather == WEATHER_DOWNPOUR)
|| gWeatherPtr->nextWeather == WEATHER_RAIN_THUNDERSTORM
|| gWeatherPtr->nextWeather == WEATHER_DOWNPOUR)
{
gWeatherPtr->finishStep = 0xFF;
return FALSE;
@@ -524,8 +524,7 @@ static void StartRainSpriteFall(struct Sprite *sprite)
if (sprite->tRandom == 0)
sprite->tRandom = 361;
// Standard RNG sequence.
rand = sprite->tRandom * 1103515245 + 12345;
rand = ISO_RANDOMIZE2(sprite->tRandom);
sprite->tRandom = ((rand & 0x7FFF0000) >> 16) % 600;
numFallingFrames = sRainSpriteFallingDurations[gWeatherPtr->isDownpour][0];
@@ -563,8 +562,8 @@ static void UpdateRainSprite(struct Sprite *sprite)
sprite->y = sprite->tPosY >> 4;
if (sprite->tActive
&& (sprite->x >= -8 && sprite->x <= 248)
&& sprite->y >= -16 && sprite->y <= 176)
&& (sprite->x >= -8 && sprite->x <= DISPLAY_WIDTH + 8)
&& sprite->y >= -16 && sprite->y <= DISPLAY_HEIGHT + 16)
sprite->invisible = FALSE;
else
sprite->invisible = TRUE;
@@ -643,7 +642,7 @@ static bool8 CreateRainSprite(void)
if (spriteId != MAX_SPRITES)
{
gSprites[spriteId].tActive = 0;
gSprites[spriteId].tActive = FALSE;
gSprites[spriteId].tRandom = spriteIndex * 145;
while (gSprites[spriteId].tRandom >= 600)
gSprites[spriteId].tRandom -= 600;
@@ -710,7 +709,7 @@ static void DestroyRainSprites(void)
DestroySprite(gWeatherPtr->sprites.s1.rainSprites[i]);
}
gWeatherPtr->rainSpriteCount = 0;
FreeSpriteTilesByTag(0x1206);
FreeSpriteTilesByTag(GFXTAG_RAIN);
}
#undef tCounter
@@ -838,8 +837,8 @@ static const union AnimCmd *const sSnowflakeAnimCmds[] = {
};
static const struct SpriteTemplate sSnowflakeSpriteTemplate = {
.tileTag = 0xFFFF,
.paletteTag = 0x1200,
.tileTag = TAG_NONE,
.paletteTag = PALTAG_WEATHER,
.oam = &sSnowflakeSpriteOamData,
.anims = sSnowflakeAnimCmds,
.images = sSnowflakeSpriteImages,
@@ -901,13 +900,14 @@ static void InitSnowflakeSpriteMovement(struct Sprite *sprite)
static void WaitSnowflakeSprite(struct Sprite *sprite)
{
if (gWeatherPtr->unknown_6E2 > 18)
// Timer is never incremented
if (gWeatherPtr->snowflakeTimer > 18)
{
sprite->invisible = FALSE;
sprite->callback = UpdateSnowflakeSprite;
sprite->y = 250 - (gSpriteCoordOffsetY + sprite->centerToCornerVecY);
sprite->tPosY = sprite->y * 128;
gWeatherPtr->unknown_6E2 = 0;
gWeatherPtr->snowflakeTimer = 0;
}
}
@@ -971,9 +971,32 @@ static void UpdateSnowflakeSprite(struct Sprite *sprite)
// WEATHER_RAIN_THUNDERSTORM
//------------------------------------------------------------------------------
enum {
// This block of states is run only once
// when first setting up the thunderstorm
TSTORM_STATE_LOAD_RAIN,
TSTORM_STATE_CREATE_RAIN,
TSTORM_STATE_INIT_RAIN,
TSTORM_STATE_WAIT_CHANGE,
// The thunderstorm loops through these states,
// not necessarily in order.
TSTORM_STATE_LOOP_START,
TSTORM_STATE_LOOP_WAIT,
TSTORM_STATE_INIT_THUNDER_SHORT_1,
TSTORM_STATE_INIT_THUNDER_SHORT_2,
TSTORM_STATE_TRY_THUNDER_SHORT,
TSTORM_STATE_TRY_NEW_THUNDER,
TSTORM_STATE_WAIT_THUNDER_SHORT,
TSTORM_STATE_INIT_THUNDER_LONG,
TSTORM_STATE_WAIT_THUNDER_LONG,
TSTORM_STATE_FADE_THUNDER_LONG,
TSTORM_STATE_END_THUNDER_LONG,
};
void Thunderstorm_InitVars(void)
{
gWeatherPtr->initStep = 0;
gWeatherPtr->initStep = TSTORM_STATE_LOAD_RAIN;
gWeatherPtr->weatherGfxLoaded = FALSE;
gWeatherPtr->rainSpriteVisibleCounter = 0;
gWeatherPtr->rainSpriteVisibleDelay = 4;
@@ -1002,7 +1025,7 @@ static void SetThunderCounter(u16);
void Downpour_InitVars(void)
{
gWeatherPtr->initStep = 0;
gWeatherPtr->initStep = TSTORM_STATE_LOAD_RAIN;
gWeatherPtr->weatherGfxLoaded = FALSE;
gWeatherPtr->rainSpriteVisibleCounter = 0;
gWeatherPtr->rainSpriteVisibleDelay = 4;
@@ -1026,100 +1049,105 @@ void Thunderstorm_Main(void)
UpdateThunderSound();
switch (gWeatherPtr->initStep)
{
case 0:
case TSTORM_STATE_LOAD_RAIN:
LoadRainSpriteSheet();
gWeatherPtr->initStep++;
break;
case 1:
case TSTORM_STATE_CREATE_RAIN:
if (!CreateRainSprite())
gWeatherPtr->initStep++;
break;
case 2:
case TSTORM_STATE_INIT_RAIN:
if (!UpdateVisibleRainSprites())
{
gWeatherPtr->weatherGfxLoaded = TRUE;
gWeatherPtr->initStep++;
}
break;
case 3:
case TSTORM_STATE_WAIT_CHANGE:
if (gWeatherPtr->palProcessingState != WEATHER_PAL_STATE_CHANGING_WEATHER)
gWeatherPtr->initStep = 6;
gWeatherPtr->initStep = TSTORM_STATE_INIT_THUNDER_SHORT_1;
break;
case 4:
gWeatherPtr->unknown_6EA = 1;
gWeatherPtr->unknown_6E6 = (Random() % 360) + 360;
case TSTORM_STATE_LOOP_START:
gWeatherPtr->thunderAllowEnd = TRUE;
gWeatherPtr->thunderDelay = (Random() % 360) + 360;
gWeatherPtr->initStep++;
// fall through
case 5:
if (--gWeatherPtr->unknown_6E6 == 0)
case TSTORM_STATE_LOOP_WAIT:
// Wait between 360-720 frames before trying thunder again
if (--gWeatherPtr->thunderDelay == 0)
gWeatherPtr->initStep++;
break;
case 6:
gWeatherPtr->unknown_6EA = 1;
gWeatherPtr->unknown_6EB = Random() % 2;
case TSTORM_STATE_INIT_THUNDER_SHORT_1:
gWeatherPtr->thunderAllowEnd = TRUE;
gWeatherPtr->thunderSkipShort = Random() % 2;
gWeatherPtr->initStep++;
break;
case 7:
gWeatherPtr->unknown_6EC = (Random() & 1) + 1;
case TSTORM_STATE_INIT_THUNDER_SHORT_2:
gWeatherPtr->thunderShortRetries = (Random() & 1) + 1;
gWeatherPtr->initStep++;
// fall through
case 8:
case TSTORM_STATE_TRY_THUNDER_SHORT:
WeatherShiftGammaIfPalStateIdle(19);
if (gWeatherPtr->unknown_6EB == 0 && gWeatherPtr->unknown_6EC == 1)
SetThunderCounter(20);
if (!gWeatherPtr->thunderSkipShort && gWeatherPtr->thunderShortRetries == 1)
SetThunderCounter(20); // Do short thunder
gWeatherPtr->unknown_6E6 = (Random() % 3) + 6;
gWeatherPtr->thunderDelay = (Random() % 3) + 6;
gWeatherPtr->initStep++;
break;
case 9:
if (--gWeatherPtr->unknown_6E6 == 0)
case TSTORM_STATE_TRY_NEW_THUNDER:
if (--gWeatherPtr->thunderDelay == 0)
{
WeatherShiftGammaIfPalStateIdle(3);
gWeatherPtr->unknown_6EA = 1;
if (--gWeatherPtr->unknown_6EC != 0)
gWeatherPtr->thunderAllowEnd = TRUE;
if (--gWeatherPtr->thunderShortRetries != 0)
{
gWeatherPtr->unknown_6E6 = (Random() % 16) + 60;
gWeatherPtr->initStep = 10;
// Try a short thunder again
gWeatherPtr->thunderDelay = (Random() % 16) + 60;
gWeatherPtr->initStep = TSTORM_STATE_WAIT_THUNDER_SHORT;
}
else if (gWeatherPtr->unknown_6EB == 0)
else if (!gWeatherPtr->thunderSkipShort)
{
gWeatherPtr->initStep = 4;
// No more thunder, restart loop
gWeatherPtr->initStep = TSTORM_STATE_LOOP_START;
}
else
{
gWeatherPtr->initStep = 11;
// Set up long thunder
gWeatherPtr->initStep = TSTORM_STATE_INIT_THUNDER_LONG;
}
}
break;
case 10:
if (--gWeatherPtr->unknown_6E6 == 0)
gWeatherPtr->initStep = 8;
case TSTORM_STATE_WAIT_THUNDER_SHORT:
if (--gWeatherPtr->thunderDelay == 0)
gWeatherPtr->initStep = TSTORM_STATE_TRY_THUNDER_SHORT;
break;
case 11:
gWeatherPtr->unknown_6E6 = (Random() % 16) + 60;
case TSTORM_STATE_INIT_THUNDER_LONG:
gWeatherPtr->thunderDelay = (Random() % 16) + 60;
gWeatherPtr->initStep++;
break;
case 12:
if (--gWeatherPtr->unknown_6E6 == 0)
case TSTORM_STATE_WAIT_THUNDER_LONG:
if (--gWeatherPtr->thunderDelay == 0)
{
// Do long thunder
SetThunderCounter(100);
WeatherShiftGammaIfPalStateIdle(19);
gWeatherPtr->unknown_6E6 = (Random() & 0xF) + 30;
gWeatherPtr->thunderDelay = (Random() & 0xF) + 30;
gWeatherPtr->initStep++;
}
break;
case 13:
if (--gWeatherPtr->unknown_6E6 == 0)
case TSTORM_STATE_FADE_THUNDER_LONG:
if (--gWeatherPtr->thunderDelay == 0)
{
WeatherBeginGammaFade(19, 3, 5);
gWeatherPtr->initStep++;
}
break;
case 14:
case TSTORM_STATE_END_THUNDER_LONG:
if (gWeatherPtr->palProcessingState == WEATHER_PAL_STATE_IDLE)
{
gWeatherPtr->unknown_6EA = 1;
gWeatherPtr->initStep = 4;
gWeatherPtr->thunderAllowEnd = TRUE;
gWeatherPtr->initStep = TSTORM_STATE_LOOP_START;
}
break;
}
@@ -1130,16 +1158,16 @@ bool8 Thunderstorm_Finish(void)
switch (gWeatherPtr->finishStep)
{
case 0:
gWeatherPtr->unknown_6EA = 0;
gWeatherPtr->thunderAllowEnd = FALSE;
gWeatherPtr->finishStep++;
// fall through
case 1:
Thunderstorm_Main();
if (gWeatherPtr->unknown_6EA)
if (gWeatherPtr->thunderAllowEnd)
{
if (gWeatherPtr->nextWeather == WEATHER_RAIN
|| gWeatherPtr->nextWeather == WEATHER_RAIN_THUNDERSTORM
|| gWeatherPtr->nextWeather == WEATHER_DOWNPOUR)
|| gWeatherPtr->nextWeather == WEATHER_RAIN_THUNDERSTORM
|| gWeatherPtr->nextWeather == WEATHER_DOWNPOUR)
return FALSE;
gWeatherPtr->targetRainSpriteCount = 0;
@@ -1197,10 +1225,9 @@ static void UpdateThunderSound(void)
// WEATHER_FOG_HORIZONTAL and WEATHER_UNDERWATER
//------------------------------------------------------------------------------
// unused data
static const u16 unusedData_839AB1C[] = {0, 6, 6, 12, 18, 42, 300, 300};
static const u16 sUnusedData[] = {0, 6, 6, 12, 18, 42, 300, 300};
static const struct OamData gOamData_839AB2C = {
static const struct OamData sOamData_FogH = {
.y = 0,
.affineMode = ST_OAM_AFFINE_OFF,
.objMode = ST_OAM_OBJ_BLEND,
@@ -1216,62 +1243,62 @@ static const struct OamData gOamData_839AB2C = {
.affineParam = 0,
};
static const union AnimCmd gSpriteAnim_839AB34[] = {
static const union AnimCmd sAnim_FogH_0[] = {
ANIMCMD_FRAME(0, 16),
ANIMCMD_END,
};
static const union AnimCmd gSpriteAnim_839AB3C[] = {
static const union AnimCmd sAnim_FogH_1[] = {
ANIMCMD_FRAME(32, 16),
ANIMCMD_END,
};
static const union AnimCmd gSpriteAnim_839AB44[] = {
static const union AnimCmd sAnim_FogH_2[] = {
ANIMCMD_FRAME(64, 16),
ANIMCMD_END,
};
static const union AnimCmd gSpriteAnim_839AB4C[] = {
static const union AnimCmd sAnim_FogH_3[] = {
ANIMCMD_FRAME(96, 16),
ANIMCMD_END,
};
static const union AnimCmd gSpriteAnim_839AB54[] = {
static const union AnimCmd sAnim_FogH_4[] = {
ANIMCMD_FRAME(128, 16),
ANIMCMD_END,
};
static const union AnimCmd gSpriteAnim_839AB5C[] = {
static const union AnimCmd sAnim_FogH_5[] = {
ANIMCMD_FRAME(160, 16),
ANIMCMD_END,
};
static const union AnimCmd *const gSpriteAnimTable_839AB64[] = {
gSpriteAnim_839AB34,
gSpriteAnim_839AB3C,
gSpriteAnim_839AB44,
gSpriteAnim_839AB4C,
gSpriteAnim_839AB54,
gSpriteAnim_839AB5C,
static const union AnimCmd *const sAnims_FogH[] = {
sAnim_FogH_0,
sAnim_FogH_1,
sAnim_FogH_2,
sAnim_FogH_3,
sAnim_FogH_4,
sAnim_FogH_5,
};
static const union AffineAnimCmd gSpriteAffineAnim_839AB7C[] = {
static const union AffineAnimCmd sAffineAnim_FogH[] = {
AFFINEANIMCMD_FRAME(0x200, 0x200, 0, 0),
AFFINEANIMCMD_END,
};
static const union AffineAnimCmd *const gSpriteAffineAnimTable_839AB8C[] = {
gSpriteAffineAnim_839AB7C,
static const union AffineAnimCmd *const sAffineAnims_FogH[] = {
sAffineAnim_FogH,
};
static void FogHorizontalSpriteCallback(struct Sprite *);
static const struct SpriteTemplate sFogHorizontalSpriteTemplate = {
.tileTag = 0x1201,
.paletteTag = 0x1200,
.oam = &gOamData_839AB2C,
.anims = gSpriteAnimTable_839AB64,
.tileTag = GFXTAG_FOG_H,
.paletteTag = PALTAG_WEATHER,
.oam = &sOamData_FogH,
.anims = sAnims_FogH,
.images = NULL,
.affineAnims = gSpriteAffineAnimTable_839AB8C,
.affineAnims = sAffineAnims_FogH,
.callback = FogHorizontalSpriteCallback,
};
@@ -1363,9 +1390,9 @@ static void FogHorizontalSpriteCallback(struct Sprite *sprite)
{
sprite->y2 = (u8)gSpriteCoordOffsetY;
sprite->x = gWeatherPtr->fogHScrollPosX + 32 + sprite->tSpriteColumn * 64;
if (sprite->x > 271)
if (sprite->x >= DISPLAY_WIDTH + 32)
{
sprite->x = 480 + gWeatherPtr->fogHScrollPosX - (4 - sprite->tSpriteColumn) * 64;
sprite->x = (DISPLAY_WIDTH * 2) + gWeatherPtr->fogHScrollPosX - (4 - sprite->tSpriteColumn) * 64;
sprite->x &= 0x1FF;
}
}
@@ -1381,7 +1408,7 @@ static void CreateFogHorizontalSprites(void)
struct SpriteSheet fogHorizontalSpriteSheet = {
.data = gWeatherFogHorizontalTiles,
.size = 0x0800,
.tag = 0x1201,
.tag = GFXTAG_FOG_H,
};
LoadSpriteSheet(&fogHorizontalSpriteSheet);
for (i = 0; i < NUM_FOG_HORIZONTAL_SPRITES; i++)
@@ -1417,7 +1444,7 @@ static void DestroyFogHorizontalSprites(void)
DestroySprite(gWeatherPtr->sprites.s2.fogHSprites[i]);
}
FreeSpriteTilesByTag(0x1201);
FreeSpriteTilesByTag(GFXTAG_FOG_H);
gWeatherPtr->fogHSpritesCreated = FALSE;
}
}
@@ -1439,7 +1466,7 @@ void Ash_InitVars(void)
gWeatherPtr->weatherGfxLoaded = FALSE;
gWeatherPtr->gammaTargetIndex = 0;
gWeatherPtr->gammaStepDelay = 20;
gWeatherPtr->unknown_6FE = 20;
gWeatherPtr->ashUnused = 20; // Never read
if (!gWeatherPtr->ashSpritesCreated)
{
Weather_SetBlendCoeffs(0, 16);
@@ -1457,8 +1484,8 @@ void Ash_InitAll(void)
void Ash_Main(void)
{
gWeatherPtr->ashBaseSpritesX = gSpriteCoordOffsetX & 0x1FF;
while (gWeatherPtr->ashBaseSpritesX >= 240)
gWeatherPtr->ashBaseSpritesX -= 240;
while (gWeatherPtr->ashBaseSpritesX >= DISPLAY_WIDTH)
gWeatherPtr->ashBaseSpritesX -= DISPLAY_WIDTH;
switch (gWeatherPtr->initStep)
{
@@ -1514,7 +1541,7 @@ bool8 Ash_Finish(void)
static const struct SpriteSheet sAshSpriteSheet = {
.data = gWeatherAshTiles,
.size = 0x1000,
.tag = 0x1202,
.tag = GFXTAG_ASH,
};
static void LoadAshSpriteSheet(void)
@@ -1546,8 +1573,8 @@ static const union AnimCmd *const sAshSpriteAnimCmds[] = {
};
static const struct SpriteTemplate sAshSpriteTemplate = {
.tileTag = 0x1202,
.paletteTag = 0x1200,
.tileTag = GFXTAG_ASH,
.paletteTag = PALTAG_WEATHER,
.oam = &sAshSpriteOamData,
.anims = sAshSpriteAnimCmds,
.images = NULL,
@@ -1602,7 +1629,7 @@ static void DestroyAshSprites(void)
DestroySprite(gWeatherPtr->sprites.s2.ashSprites[i]);
}
FreeSpriteTilesByTag(0x1202);
FreeSpriteTilesByTag(GFXTAG_ASH);
gWeatherPtr->ashSpritesCreated = FALSE;
}
}
@@ -1617,9 +1644,9 @@ static void UpdateAshSprite(struct Sprite *sprite)
sprite->y = gSpriteCoordOffsetY + sprite->tOffsetY;
sprite->x = gWeatherPtr->ashBaseSpritesX + 32 + sprite->tSpriteColumn * 64;
if (sprite->x > 271)
if (sprite->x >= DISPLAY_WIDTH + 32)
{
sprite->x = gWeatherPtr->ashBaseSpritesX + 480 - (4 - sprite->tSpriteColumn) * 64;
sprite->x = gWeatherPtr->ashBaseSpritesX + (DISPLAY_WIDTH * 2) - (4 - sprite->tSpriteColumn) * 64;
sprite->x &= 0x1FF;
}
}
@@ -1732,7 +1759,7 @@ static void UpdateFogDiagonalMovement(void)
static const struct SpriteSheet gFogDiagonalSpriteSheet = {
.data = gWeatherFogDiagonalTiles,
.size = 0x0800,
.tag = 0x1203,
.tag = GFXTAG_FOG_D,
};
static const struct OamData sFogDiagonalSpriteOamData = {
@@ -1758,8 +1785,8 @@ static const union AnimCmd *const sFogDiagonalSpriteAnimCmds[] = {
};
static const struct SpriteTemplate sFogDiagonalSpriteTemplate = {
.tileTag = 0x1203,
.paletteTag = 0x1200,
.tileTag = GFXTAG_FOG_D,
.paletteTag = PALTAG_WEATHER,
.oam = &sFogDiagonalSpriteOamData,
.anims = sFogDiagonalSpriteAnimCmds,
.images = NULL,
@@ -1813,7 +1840,7 @@ static void DestroyFogDiagonalSprites(void)
DestroySprite(gWeatherPtr->sprites.s2.fogDSprites[i]);
}
FreeSpriteTilesByTag(0x1203);
FreeSpriteTilesByTag(GFXTAG_FOG_D);
gWeatherPtr->fogDSpritesCreated = FALSE;
}
}
@@ -1822,9 +1849,9 @@ static void UpdateFogDiagonalSprite(struct Sprite *sprite)
{
sprite->y2 = gWeatherPtr->fogDPosY;
sprite->x = gWeatherPtr->fogDBaseSpritesX + 32 + sprite->tSpriteColumn * 64;
if (sprite->x > 271)
if (sprite->x >= DISPLAY_WIDTH + 32)
{
sprite->x = gWeatherPtr->fogDBaseSpritesX + 480 - (4 - sprite->tSpriteColumn) * 64;
sprite->x = gWeatherPtr->fogDBaseSpritesX + (DISPLAY_WIDTH * 2) - (4 - sprite->tSpriteColumn) * 64;
sprite->x &= 0x1FF;
}
}
@@ -1956,7 +1983,7 @@ static void DestroySandstormSprites(void)
}
gWeatherPtr->sandstormSpritesCreated = FALSE;
FreeSpriteTilesByTag(0x1204);
FreeSpriteTilesByTag(GFXTAG_SANDSTORM);
}
if (gWeatherPtr->sandstormSwirlSpritesCreated)
@@ -2000,8 +2027,8 @@ static const union AnimCmd *const sSandstormSpriteAnimCmds[] = {
};
static const struct SpriteTemplate sSandstormSpriteTemplate = {
.tileTag = 0x1204,
.paletteTag = 0x1200,
.tileTag = GFXTAG_SANDSTORM,
.paletteTag = PALTAG_WEATHER,
.oam = &sSandstormSpriteOamData,
.anims = sSandstormSpriteAnimCmds,
.images = NULL,
@@ -2012,7 +2039,7 @@ static const struct SpriteTemplate sSandstormSpriteTemplate = {
static const struct SpriteSheet sSandstormSpriteSheet = {
.data = gWeatherSandstormTiles,
.size = 0x0a00,
.tag = 0x1204,
.tag = GFXTAG_SANDSTORM,
};
// Regular sandstorm sprites
@@ -2092,9 +2119,9 @@ static void UpdateSandstormSprite(struct Sprite *sprite)
{
sprite->y2 = gWeatherPtr->sandstormPosY;
sprite->x = gWeatherPtr->sandstormBaseSpritesX + 32 + sprite->tSpriteColumn * 64;
if (sprite->x > 271)
if (sprite->x >= DISPLAY_WIDTH + 32)
{
sprite->x = gWeatherPtr->sandstormBaseSpritesX + 480 - (4 - sprite->tSpriteColumn) * 64;
sprite->x = gWeatherPtr->sandstormBaseSpritesX + (DISPLAY_WIDTH * 2) - (4 - sprite->tSpriteColumn) * 64;
sprite->x &= 0x1FF;
}
}
@@ -2111,7 +2138,7 @@ static void UpdateSandstormSwirlSprite(struct Sprite *sprite)
if (--sprite->y < -48)
{
sprite->y = 208;
sprite->y = DISPLAY_HEIGHT + 48;
sprite->tRadius = 4;
}
@@ -2173,7 +2200,7 @@ static const u8 sBubbleStartDelays[] = {40, 90, 60, 90, 2, 60, 40, 30};
static const struct SpriteSheet sWeatherBubbleSpriteSheet = {
.data = gWeatherBubbleTiles,
.size = 0x0040,
.tag = 0x1205,
.tag = GFXTAG_BUBBLE,
};
static const s16 sBubbleStartCoords[][2] = {
@@ -2249,8 +2276,8 @@ static const union AnimCmd *const sBubbleSpriteAnimCmds[] = {
};
static const struct SpriteTemplate sBubbleSpriteTemplate = {
.tileTag = 0x1205,
.paletteTag = 0x1200,
.tileTag = GFXTAG_BUBBLE,
.paletteTag = PALTAG_WEATHER,
.oam = &gOamData_AffineOff_ObjNormal_8x8,
.anims = sBubbleSpriteAnimCmds,
.images = NULL,
@@ -2288,7 +2315,7 @@ static void DestroyBubbleSprites(void)
DestroySprite(&gSprites[i]);
}
FreeSpriteTilesByTag(0x1205);
FreeSpriteTilesByTag(GFXTAG_BUBBLE);
}
static void UpdateBubbleSprite(struct Sprite *sprite)