-
Notifications
You must be signed in to change notification settings - Fork 2.8k
/
Copy pathfield_weather.h
234 lines (223 loc) · 6.53 KB
/
field_weather.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
#ifndef GUARD_WEATHER_H
#define GUARD_WEATHER_H
#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
};
#define NUM_WEATHER_COLOR_MAPS 19
struct Weather
{
union
{
struct
{
struct Sprite *rainSprites[MAX_RAIN_SPRITES];
struct Sprite *snowflakeSprites[101];
struct Sprite *cloudSprites[NUM_CLOUD_SPRITES];
} s1;
struct
{
u8 filler0[0xA0];
struct Sprite *fogHSprites[NUM_FOG_HORIZONTAL_SPRITES];
struct Sprite *ashSprites[NUM_ASH_SPRITES];
struct Sprite *fogDSprites[NUM_FOG_DIAGONAL_SPRITES];
struct Sprite *sandstormSprites1[NUM_SANDSTORM_SPRITES];
struct Sprite *sandstormSprites2[NUM_SWIRL_SANDSTORM_SPRITES];
} s2;
} sprites;
u8 darkenedContrastColorMaps[NUM_WEATHER_COLOR_MAPS][32];
u8 contrastColorMaps[NUM_WEATHER_COLOR_MAPS][32];
s8 colorMapIndex;
s8 targetColorMapIndex;
u8 colorMapStepDelay;
u8 colorMapStepCounter;
u16 fadeDestColor;
u8 palProcessingState;
u8 fadeScreenCounter;
bool8 readyForInit;
u8 taskId;
u8 fadeInFirstFrame;
u8 fadeInTimer;
u16 initStep;
u16 finishStep;
u8 currWeather;
u8 nextWeather;
u8 weatherGfxLoaded;
bool8 weatherChangeComplete;
u8 weatherPicSpritePalIndex;
u8 contrastColorMapSpritePalIndex;
// Rain
u16 rainSpriteVisibleCounter;
u8 curRainSpriteIndex;
u8 targetRainSpriteCount;
u8 rainSpriteCount;
u8 rainSpriteVisibleDelay;
u8 isDownpour;
u8 rainStrength;
u8 cloudSpritesCreated;
// Snow
u16 snowflakeVisibleCounter;
u16 snowflakeTimer;
u8 snowflakeSpriteCount;
u8 targetSnowflakeSpriteCount;
// Thunderstorm
u16 thunderTimer; // general-purpose timer for state transitions
u16 thunderSETimer; // timer for thunder sound effect
bool8 thunderAllowEnd;
bool8 thunderLongBolt; // true if this cycle will end in a long lightning bolt
u8 thunderShortBolts; // the number of short bolts this cycle
bool8 thunderEnqueued;
// Horizontal fog
u16 fogHScrollPosX;
u16 fogHScrollCounter;
u16 fogHScrollOffset;
u8 lightenedFogSpritePals[6];
u8 lightenedFogSpritePalsCount;
u8 fogHSpritesCreated;
// Ash
u16 ashBaseSpritesX;
u16 ashUnused;
u8 ashSpritesCreated;
// Sandstorm
u32 sandstormXOffset;
u32 sandstormYOffset;
u16 sandstormUnused;
u16 sandstormBaseSpritesX;
u16 sandstormPosY;
u16 sandstormWaveIndex;
u16 sandstormWaveCounter;
u8 sandstormSpritesCreated;
u8 sandstormSwirlSpritesCreated;
// Diagonal fog
u16 fogDBaseSpritesX;
u16 fogDPosY;
u16 fogDScrollXCounter;
u16 fogDScrollYCounter;
u16 fogDXOffset;
u16 fogDYOffset;
u8 fogDSpritesCreated;
// Bubbles
u16 bubblesDelayCounter;
u16 bubblesDelayIndex;
u16 bubblesCoordsIndex;
u16 bubblesSpriteCount;
u8 bubblesSpritesCreated;
u16 currBlendEVA;
u16 currBlendEVB;
u16 targetBlendEVA;
u16 targetBlendEVB;
u8 blendUpdateCounter;
u8 blendFrameCounter;
u8 blendDelay;
// Drought
s16 droughtBrightnessStage;
s16 droughtLastBrightnessStage;
s16 droughtTimer;
s16 droughtState;
u8 droughtUnused[9];
s8 loadDroughtPalsIndex;
u8 loadDroughtPalsOffset;
};
// field_weather.c
extern struct Weather gWeather;
extern struct Weather *const gWeatherPtr;
extern const u16 gFogPalette[];
// field_weather_effect.c
extern const u8 gWeatherFogHorizontalTiles[];
void StartWeather(void);
void SetNextWeather(u8 weather);
void SetCurrentAndNextWeather(u8 weather);
void SetCurrentAndNextWeatherNoDelay(u8 weather);
void ApplyWeatherColorMapIfIdle(s8 colorMapIndex);
void ApplyWeatherColorMapIfIdle_Gradual(u8 colorMapIndex, u8 targetColorMapIndex, u8 colorMapStepDelay);
void FadeScreen(u8 mode, s8 delay);
bool8 IsWeatherNotFadingIn(void);
void UpdateSpritePaletteWithWeather(u8 spritePaletteIndex);
void ApplyWeatherColorMapToPal(u8 paletteIndex);
void LoadCustomWeatherSpritePalette(const u16 *palette);
void ResetDroughtWeatherPaletteLoading(void);
bool8 LoadDroughtWeatherPalettes(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);
u8 GetCurrentWeather(void);
void SetRainStrengthFromSoundEffect(u16 soundEffect);
void PlayRainStoppingSoundEffect(void);
u8 IsWeatherChangeComplete(void);
void SetWeatherScreenFadeOut(void);
void SetWeatherPalStateIdle(void);
void PreservePaletteInWeather(u8 preservedPalIndex);
void ResetPreservedPalettesInWeather(void);
// field_weather_effect.c
void Clouds_InitVars(void);
void Clouds_Main(void);
void Clouds_InitAll(void);
bool8 Clouds_Finish(void);
void Sunny_InitVars(void);
void Sunny_Main(void);
void Sunny_InitAll(void);
bool8 Sunny_Finish(void);
void Rain_InitVars(void);
void Rain_Main(void);
void Rain_InitAll(void);
bool8 Rain_Finish(void);
void Snow_InitVars(void);
void Snow_Main(void);
void Snow_InitAll(void);
bool8 Snow_Finish(void);
void Thunderstorm_InitVars(void);
void Thunderstorm_Main(void);
void Thunderstorm_InitAll(void);
bool8 Thunderstorm_Finish(void);
void FogHorizontal_InitVars(void);
void FogHorizontal_Main(void);
void FogHorizontal_InitAll(void);
bool8 FogHorizontal_Finish(void);
void Ash_InitVars(void);
void Ash_Main(void);
void Ash_InitAll(void);
bool8 Ash_Finish(void);
void Sandstorm_InitVars(void);
void Sandstorm_Main(void);
void Sandstorm_InitAll(void);
bool8 Sandstorm_Finish(void);
void FogDiagonal_InitVars(void);
void FogDiagonal_Main(void);
void FogDiagonal_InitAll(void);
bool8 FogDiagonal_Finish(void);
void Shade_InitVars(void);
void Shade_Main(void);
void Shade_InitAll(void);
bool8 Shade_Finish(void);
void Drought_InitVars(void);
void Drought_Main(void);
void Drought_InitAll(void);
bool8 Drought_Finish(void);
void Downpour_InitVars(void);
void Downpour_InitAll(void);
void Bubbles_InitVars(void);
void Bubbles_Main(void);
void Bubbles_InitAll(void);
bool8 Bubbles_Finish(void);
u8 GetSavedWeather(void);
void SetSavedWeather(u32 weather);
void SetSavedWeatherFromCurrMapHeader(void);
void SetWeather(u32 weather);
void DoCurrentWeather(void);
void UpdateWeatherPerDay(u16 increment);
void ResumePausedWeather(void);
#endif // GUARD_WEATHER_H