Sync drought with pokefirered, add weather tags

This commit is contained in:
GriffinR 2021-04-03 22:47:58 -04:00
parent a0b3d4df12
commit 1494a83035
3 changed files with 82 additions and 68 deletions

View File

@ -4,6 +4,21 @@
#include "sprite.h"
#include "constants/field_weather.h"
#define TAG_WEATHER_START 0x1200
enum {
GFXTAG_CLOUD = TAG_WEATHER_START,
GFXTAG_FOG_H,
GFXTAG_ASH,
GFXTAG_FOG_D,
GFXTAG_SANDSTORM,
GFXTAG_BUBBLE,
GFXTAG_RAIN,
};
enum {
PALTAG_WEATHER = TAG_WEATHER_START,
PALTAG_WEATHER_2
};
struct Weather
{
union
@ -105,10 +120,10 @@ struct Weather
u8 blendFrameCounter;
u8 blendDelay;
u8 filler_73B[0x3C-0x3B];
s16 unknown_73C;
s16 unknown_73E;
s16 unknown_740;
s16 unknown_742;
s16 droughtBrightnessStage;
s16 droughtLastBrightnessStage;
s16 droughtTimer;
s16 droughtState;
u8 filler_744[0xD-4];
s8 loadDroughtPalsIndex;
u8 loadDroughtPalsOffset;
@ -136,9 +151,8 @@ u8 sub_80ABF20(void);
void LoadCustomWeatherSpritePalette(const u16 *palette);
void ResetDroughtWeatherPaletteLoading(void);
bool8 LoadDroughtWeatherPalettes(void);
void sub_80ABFE0(s8 gammaIndex);
void sub_80ABFF0(void);
void sub_80AC01C(void);
void DroughtStateInit(void);
void DroughtStateRun(void);
void Weather_SetBlendCoeffs(u8 eva, u8 evb);
void Weather_SetTargetBlendCoeffs(u8 eva, u8 evb, int delay);
bool8 Weather_UpdateBlend(void);

View File

@ -160,11 +160,11 @@ void StartWeather(void)
{
if (!FuncIsActiveTask(Task_WeatherMain))
{
u8 index = AllocSpritePalette(0x1200);
u8 index = AllocSpritePalette(TAG_WEATHER_START);
CpuCopy32(gFogPalette, &gPlttBufferUnfaded[0x100 + index * 16], 32);
BuildGammaShiftTables();
gWeatherPtr->altGammaSpritePalIndex = index;
gWeatherPtr->weatherPicSpritePalIndex = AllocSpritePalette(0x1201);
gWeatherPtr->weatherPicSpritePalIndex = AllocSpritePalette(PALTAG_WEATHER_2);
gWeatherPtr->rainSpriteCount = 0;
gWeatherPtr->curRainSpriteIndex = 0;
gWeatherPtr->cloudSpritesCreated = 0;
@ -885,50 +885,50 @@ bool8 LoadDroughtWeatherPalettes(void)
return FALSE;
}
void sub_80ABFE0(s8 gammaIndex)
static void SetDroughtGamma(s8 gammaIndex)
{
sub_80ABC48(-gammaIndex - 1);
}
void sub_80ABFF0(void)
void DroughtStateInit(void)
{
gWeatherPtr->unknown_73C = 0;
gWeatherPtr->unknown_740 = 0;
gWeatherPtr->unknown_742 = 0;
gWeatherPtr->unknown_73E = 0;
gWeatherPtr->droughtBrightnessStage = 0;
gWeatherPtr->droughtTimer = 0;
gWeatherPtr->droughtState = 0;
gWeatherPtr->droughtLastBrightnessStage = 0;
}
void sub_80AC01C(void)
void DroughtStateRun(void)
{
switch (gWeatherPtr->unknown_742)
switch (gWeatherPtr->droughtState)
{
case 0:
if (++gWeatherPtr->unknown_740 > 5)
if (++gWeatherPtr->droughtTimer > 5)
{
gWeatherPtr->unknown_740 = 0;
sub_80ABFE0(gWeatherPtr->unknown_73C++);
if (gWeatherPtr->unknown_73C > 5)
gWeatherPtr->droughtTimer = 0;
SetDroughtGamma(gWeatherPtr->droughtBrightnessStage++);
if (gWeatherPtr->droughtBrightnessStage > 5)
{
gWeatherPtr->unknown_73E = gWeatherPtr->unknown_73C;
gWeatherPtr->unknown_742 = 1;
gWeatherPtr->unknown_740 = 0x3C;
gWeatherPtr->droughtLastBrightnessStage = gWeatherPtr->droughtBrightnessStage;
gWeatherPtr->droughtState = 1;
gWeatherPtr->droughtTimer = 60;
}
}
break;
case 1:
gWeatherPtr->unknown_740 = (gWeatherPtr->unknown_740 + 3) & 0x7F;
gWeatherPtr->unknown_73C = ((gSineTable[gWeatherPtr->unknown_740] - 1) >> 6) + 2;
if (gWeatherPtr->unknown_73C != gWeatherPtr->unknown_73E)
sub_80ABFE0(gWeatherPtr->unknown_73C);
gWeatherPtr->unknown_73E = gWeatherPtr->unknown_73C;
gWeatherPtr->droughtTimer = (gWeatherPtr->droughtTimer + 3) & 0x7F;
gWeatherPtr->droughtBrightnessStage = ((gSineTable[gWeatherPtr->droughtTimer] - 1) >> 6) + 2;
if (gWeatherPtr->droughtBrightnessStage != gWeatherPtr->droughtLastBrightnessStage)
SetDroughtGamma(gWeatherPtr->droughtBrightnessStage);
gWeatherPtr->droughtLastBrightnessStage = gWeatherPtr->droughtBrightnessStage;
break;
case 2:
if (++gWeatherPtr->unknown_740 > 5)
if (++gWeatherPtr->droughtTimer > 5)
{
gWeatherPtr->unknown_740 = 0;
sub_80ABFE0(--gWeatherPtr->unknown_73C);
if (gWeatherPtr->unknown_73C == 3)
gWeatherPtr->unknown_742 = 0;
gWeatherPtr->droughtTimer = 0;
SetDroughtGamma(--gWeatherPtr->droughtBrightnessStage);
if (gWeatherPtr->droughtBrightnessStage == 3)
gWeatherPtr->droughtState = 0;
}
break;
}

View File

@ -51,7 +51,7 @@ static const struct SpriteSheet sCloudSpriteSheet =
{
.data = gWeatherCloudTiles,
.size = sizeof(gWeatherCloudTiles),
.tag = 0x1200
.tag = GFXTAG_CLOUD
};
static const struct OamData sCloudSpriteOamData =
@ -84,8 +84,8 @@ static const union AnimCmd *const sCloudSpriteAnimCmds[] =
static const struct SpriteTemplate sCloudSpriteTemplate =
{
.tileTag = 0x1200,
.paletteTag = 0x1201,
.tileTag = GFXTAG_CLOUD,
.paletteTag = PALTAG_WEATHER_2,
.oam = &sCloudSpriteOamData,
.anims = sCloudSpriteAnimCmds,
.images = NULL,
@ -214,7 +214,7 @@ static void DestroyCloudSprites(void)
DestroySprite(gWeatherPtr->sprites.s1.cloudSprites[i]);
}
FreeSpriteTilesByTag(0x1200);
FreeSpriteTilesByTag(GFXTAG_CLOUD);
gWeatherPtr->cloudSpritesCreated = FALSE;
}
@ -264,19 +264,19 @@ void Drought_Main(void)
gWeatherPtr->initStep++;
break;
case 3:
sub_80ABFF0();
DroughtStateInit();
gWeatherPtr->initStep++;
break;
case 4:
sub_80AC01C();
if (gWeatherPtr->unknown_73C == 6)
DroughtStateRun();
if (gWeatherPtr->droughtBrightnessStage == 6)
{
gWeatherPtr->weatherGfxLoaded = TRUE;
gWeatherPtr->initStep++;
}
break;
default:
sub_80AC01C();
DroughtStateRun();
break;
}
}
@ -288,7 +288,7 @@ bool8 Drought_Finish(void)
void StartDroughtWeatherBlend(void)
{
CreateTask(UpdateDroughtBlend, 0x50);
CreateTask(UpdateDroughtBlend, 80);
}
#define tState data[0]
@ -437,8 +437,8 @@ static const union AnimCmd *const sRainSpriteAnimCmds[] =
static const struct SpriteTemplate sRainSpriteTemplate =
{
.tileTag = 4614,
.paletteTag = 0x1200,
.tileTag = GFXTAG_RAIN,
.paletteTag = PALTAG_WEATHER,
.oam = &sRainSpriteOamData,
.anims = sRainSpriteAnimCmds,
.images = NULL,
@ -466,7 +466,7 @@ static const struct SpriteSheet sRainSpriteSheet =
{
.data = gWeatherRainTiles,
.size = sizeof(gWeatherRainTiles),
.tag = 0x1206,
.tag = GFXTAG_RAIN,
};
void Rain_InitVars(void)
@ -744,7 +744,7 @@ static void DestroyRainSprites(void)
DestroySprite(gWeatherPtr->sprites.s1.rainSprites[i]);
}
gWeatherPtr->rainSpriteCount = 0;
FreeSpriteTilesByTag(0x1206);
FreeSpriteTilesByTag(GFXTAG_RAIN);
}
#undef tCounter
@ -879,7 +879,7 @@ static const union AnimCmd *const sSnowflakeAnimCmds[] =
static const struct SpriteTemplate sSnowflakeSpriteTemplate =
{
.tileTag = 0xFFFF,
.paletteTag = 0x1200,
.paletteTag = PALTAG_WEATHER,
.oam = &sSnowflakeSpriteOamData,
.anims = sSnowflakeAnimCmds,
.images = sSnowflakeSpriteImages,
@ -1317,8 +1317,8 @@ static const union AffineAnimCmd *const gSpriteAffineAnimTable_839AB8C[] =
static void FogHorizontalSpriteCallback(struct Sprite *);
static const struct SpriteTemplate sFogHorizontalSpriteTemplate =
{
.tileTag = 0x1201,
.paletteTag = 0x1200,
.tileTag = GFXTAG_FOG_H,
.paletteTag = PALTAG_WEATHER,
.oam = &gOamData_839AB2C,
.anims = gSpriteAnimTable_839AB64,
.images = NULL,
@ -1433,7 +1433,7 @@ static void CreateFogHorizontalSprites(void)
struct SpriteSheet fogHorizontalSpriteSheet = {
.data = gWeatherFogHorizontalTiles,
.size = sizeof(gWeatherFogHorizontalTiles),
.tag = 0x1201,
.tag = GFXTAG_FOG_H,
};
LoadSpriteSheet(&fogHorizontalSpriteSheet);
for (i = 0; i < NUM_FOG_HORIZONTAL_SPRITES; i++)
@ -1469,7 +1469,7 @@ static void DestroyFogHorizontalSprites(void)
DestroySprite(gWeatherPtr->sprites.s2.fogHSprites[i]);
}
FreeSpriteTilesByTag(0x1201);
FreeSpriteTilesByTag(GFXTAG_FOG_H);
gWeatherPtr->fogHSpritesCreated = 0;
}
}
@ -1567,7 +1567,7 @@ static const struct SpriteSheet sAshSpriteSheet =
{
.data = gWeatherAshTiles,
.size = sizeof(gWeatherAshTiles),
.tag = 0x1202,
.tag = GFXTAG_ASH,
};
static void LoadAshSpriteSheet(void)
@ -1603,8 +1603,8 @@ static const union AnimCmd *const sAshSpriteAnimCmds[] =
static const struct SpriteTemplate sAshSpriteTemplate =
{
.tileTag = 4610,
.paletteTag = 0x1200,
.tileTag = GFXTAG_ASH,
.paletteTag = PALTAG_WEATHER,
.oam = &sAshSpriteOamData,
.anims = sAshSpriteAnimCmds,
.images = NULL,
@ -1659,7 +1659,7 @@ static void DestroyAshSprites(void)
DestroySprite(gWeatherPtr->sprites.s2.ashSprites[i]);
}
FreeSpriteTilesByTag(0x1202);
FreeSpriteTilesByTag(GFXTAG_ASH);
gWeatherPtr->ashSpritesCreated = FALSE;
}
}
@ -1790,7 +1790,7 @@ static const struct SpriteSheet gFogDiagonalSpriteSheet =
{
.data = gWeatherFogDiagonalTiles,
.size = sizeof(gWeatherFogDiagonalTiles),
.tag = 0x1203,
.tag = GFXTAG_FOG_D,
};
static const struct OamData sFogDiagonalSpriteOamData =
@ -1820,8 +1820,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,
@ -1875,7 +1875,7 @@ static void DestroyFogDiagonalSprites(void)
DestroySprite(gWeatherPtr->sprites.s2.fogDSprites[i]);
}
FreeSpriteTilesByTag(0x1203);
FreeSpriteTilesByTag(GFXTAG_FOG_D);
gWeatherPtr->fogDSpritesCreated = FALSE;
}
}
@ -2018,7 +2018,7 @@ static void DestroySandstormSprites(void)
}
gWeatherPtr->sandstormSpritesCreated = FALSE;
FreeSpriteTilesByTag(0x1204);
FreeSpriteTilesByTag(GFXTAG_SANDSTORM);
}
if (gWeatherPtr->sandstormSwirlSpritesCreated)
@ -2067,8 +2067,8 @@ static const union AnimCmd *const sSandstormSpriteAnimCmds[] =
static const struct SpriteTemplate sSandstormSpriteTemplate =
{
.tileTag = 0x1204,
.paletteTag = 0x1201,
.tileTag = GFXTAG_SANDSTORM,
.paletteTag = PALTAG_WEATHER_2,
.oam = &sSandstormSpriteOamData,
.anims = sSandstormSpriteAnimCmds,
.images = NULL,
@ -2080,7 +2080,7 @@ static const struct SpriteSheet sSandstormSpriteSheet =
{
.data = gWeatherSandstormTiles,
.size = sizeof(gWeatherSandstormTiles),
.tag = 0x1204,
.tag = GFXTAG_SANDSTORM,
};
// Regular sandstorm sprites
@ -2242,7 +2242,7 @@ static const struct SpriteSheet sWeatherBubbleSpriteSheet =
{
.data = gWeatherBubbleTiles,
.size = sizeof(gWeatherBubbleTiles),
.tag = 0x1205,
.tag = GFXTAG_BUBBLE,
};
static const s16 sBubbleStartCoords[][2] =
@ -2322,8 +2322,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,
@ -2363,7 +2363,7 @@ static void DestroyBubbleSprites(void)
DestroySprite(&gSprites[i]);
}
FreeSpriteTilesByTag(0x1205);
FreeSpriteTilesByTag(GFXTAG_BUBBLE);
gWeatherPtr->bubblesSpriteCount = 0;
}
}