diff options
author | Marcus Huderle <huderlem@gmail.com> | 2018-01-20 14:17:03 -0800 |
---|---|---|
committer | Marcus Huderle <huderlem@gmail.com> | 2018-01-20 14:17:03 -0800 |
commit | 003ed9293b2c51f0481ed31f0e0459cbecbf757e (patch) | |
tree | 2ee03f3c11f552976589d1ac0b0de474bf78fb96 /src | |
parent | 428f712da678b3f5b9256d85c0e3248cacd8e7c2 (diff) |
More documentation of field_weather
Diffstat (limited to 'src')
-rw-r--r-- | src/battle/battle_transition.c | 4 | ||||
-rw-r--r-- | src/engine/cable_club.c | 4 | ||||
-rw-r--r-- | src/engine/time_events.c | 2 | ||||
-rw-r--r-- | src/field/choose_party.c | 2 | ||||
-rw-r--r-- | src/field/decoration.c | 20 | ||||
-rw-r--r-- | src/field/field_effect.c | 12 | ||||
-rw-r--r-- | src/field/field_effect_helpers.c | 4 | ||||
-rw-r--r-- | src/field/field_fadetransition.c | 14 | ||||
-rw-r--r-- | src/field/field_weather.c | 259 | ||||
-rw-r--r-- | src/field/field_weather_effects.c | 11 | ||||
-rw-r--r-- | src/field/item_menu.c | 4 | ||||
-rw-r--r-- | src/field/item_use.c | 2 | ||||
-rw-r--r-- | src/field/overworld.c | 2 | ||||
-rw-r--r-- | src/field/player_pc.c | 12 | ||||
-rw-r--r-- | src/field/scrcmd.c | 4 | ||||
-rw-r--r-- | src/field/secret_base.c | 8 | ||||
-rw-r--r-- | src/field/shop.c | 6 | ||||
-rw-r--r-- | src/field/start_menu.c | 2 | ||||
-rw-r--r-- | src/pokemon/pokemon_menu.c | 2 | ||||
-rw-r--r-- | src/scene/cable_car.c | 7 |
20 files changed, 202 insertions, 179 deletions
diff --git a/src/battle/battle_transition.c b/src/battle/battle_transition.c index f7cdc0694..a94974b27 100644 --- a/src/battle/battle_transition.c +++ b/src/battle/battle_transition.c @@ -6,6 +6,7 @@ #include "palette.h" #include "trig.h" #include "field_effect.h" +#include "field_weather.h" #include "random.h" #include "sprite.h" #include "sound.h" @@ -15,7 +16,6 @@ #include "ewram.h" #include "scanline_effect.h" -void sub_807DE10(void); void ScanlineEffect_Clear(void); extern const struct OamData gFieldOamData_32x32; @@ -567,7 +567,7 @@ static void Task_BattleTransitionMain(u8 taskID) static bool8 Transition_Phase1(struct Task* task) { - sub_807DE10(); + SetWeatherScreenFadeOut(); CpuCopy32(gPlttBufferFaded, gPlttBufferUnfaded, 0x400); if (sPhase1_Tasks[task->tTransitionID] != NULL) { diff --git a/src/engine/cable_club.c b/src/engine/cable_club.c index 44d832e2b..e7c504c7b 100644 --- a/src/engine/cable_club.c +++ b/src/engine/cable_club.c @@ -676,7 +676,7 @@ static void sub_808382C(u8 taskId) switch (task->data[0]) { case 0: - fade_screen(1, 0); + FadeScreen(1, 0); gLinkType = 0x2211; ClearLinkCallback_2(); task->data[0]++; @@ -812,7 +812,7 @@ static void sub_8083AAC(u8 taskId) { case 0: ScriptContext2_Enable(); - fade_screen(1, 0); + FadeScreen(1, 0); ClearLinkCallback_2(); task->data[0]++; break; diff --git a/src/engine/time_events.c b/src/engine/time_events.c index 3e3054aa3..4bd732788 100644 --- a/src/engine/time_events.c +++ b/src/engine/time_events.c @@ -93,7 +93,7 @@ void UpdateShoalTideFlag(void) static void Task_WaitWeather(u8 taskId) { - if (sub_807DDFC()) + if (IsWeatherChangeComplete()) { EnableBothScriptContexts(); DestroyTask(taskId); diff --git a/src/field/choose_party.c b/src/field/choose_party.c index 3ba04e489..18d26f007 100644 --- a/src/field/choose_party.c +++ b/src/field/choose_party.c @@ -930,7 +930,7 @@ void sub_81231AC(void) static void sub_81231C4(u8 taskId) { - if (sub_807D770() == TRUE) + if (IsWeatherNotFadingIn() == TRUE) { DestroyTask(taskId); ScriptContext2_Disable(); diff --git a/src/field/decoration.c b/src/field/decoration.c index 1cc3bbe06..0e7fa5f41 100644 --- a/src/field/decoration.c +++ b/src/field/decoration.c @@ -2239,7 +2239,7 @@ void sub_80FF5BC(u8 taskId) { if (sub_80FF58C() == TRUE) { - fade_screen(1, 0); + FadeScreen(1, 0); gTasks[taskId].data[2] = 0; gTasks[taskId].func = sub_80FF6AC; } else @@ -2289,7 +2289,7 @@ void sub_80FF6AC(u8 taskId) gTasks[taskId].data[2] = 2; break; case 2: - if (sub_807D770() == TRUE) + if (IsWeatherNotFadingIn() == TRUE) { gTasks[taskId].data[12] = 0; sub_810065C(taskId); @@ -3193,7 +3193,7 @@ void sub_810026C(u8 taskId) void sub_810028C(u8 taskId) { - fade_screen(1, 0); + FadeScreen(1, 0); gTasks[taskId].data[2] = 0; gTasks[taskId].func = c1_overworld_prev_quest; } @@ -3222,7 +3222,7 @@ void c1_overworld_prev_quest(u8 taskId) void sub_8100334(u8 taskId) { - if (sub_807D770() == TRUE) + if (IsWeatherNotFadingIn() == TRUE) { gTasks[taskId].func = sub_80FE948; } @@ -3629,7 +3629,7 @@ void sub_8100A0C(u8 taskId) { if (sub_8100D38(taskId) == 1) { - fade_screen(1, 0); + FadeScreen(1, 0); gTasks[taskId].data[2] = 0; gTasks[taskId].func = sub_8100E70; } else @@ -3735,7 +3735,7 @@ void sub_8100C88(u8 taskId) gTasks[taskId].data[2] = 3; break; case 3: - if (sub_807D770() == TRUE) + if (IsWeatherNotFadingIn() == TRUE) { gTasks[taskId].data[13] = -1; DisplayItemMessageOnField(taskId, gSecretBaseText_DecorReturned, sub_81010F0, 0); @@ -3800,7 +3800,7 @@ void sub_8100E70(u8 taskId) data[2] = 2; break; case 2: - if (sub_807D770() == TRUE) + if (IsWeatherNotFadingIn() == TRUE) { data[12] = 1; sub_8100EEC(taskId); @@ -4138,7 +4138,7 @@ void sub_8101518(u8 taskId) void sub_810153C(u8 taskId) { - fade_screen(1, 0); + FadeScreen(1, 0); gTasks[taskId].data[2] = 0; gTasks[taskId].func = sub_8100C88; } @@ -4157,7 +4157,7 @@ void sub_8101590(u8 taskId) void sub_81015B0(u8 taskId) { - fade_screen(1, 0); + FadeScreen(1, 0); gTasks[taskId].data[2] = 0; gTasks[taskId].func = sub_81015E0; } @@ -4184,7 +4184,7 @@ void sub_81015E0(u8 taskId) void sub_8101648(u8 taskId) { - if (sub_807D770() == TRUE) + if (IsWeatherNotFadingIn() == TRUE) { gTasks[taskId].func = Task_DecorationPCProcessMenuInput; } diff --git a/src/field/field_effect.c b/src/field/field_effect.c index a3134552d..ad570cf7f 100644 --- a/src/field/field_effect.c +++ b/src/field/field_effect.c @@ -407,7 +407,7 @@ void FieldEffectScript_LoadFadedPalette(u8 **script) { struct SpritePalette *palette = (struct SpritePalette *)FieldEffectScript_ReadWord(script); LoadSpritePalette(palette); - sub_807D78C(IndexOfSpritePaletteTag(palette->tag)); + UpdateSpritePaletteWithWeather(IndexOfSpritePaletteTag(palette->tag)); (*script) += 4; } @@ -1091,7 +1091,7 @@ void task00_8084310(u8 taskId) task = &gTasks[taskId]; if (!task->data[0]) { - if (!sub_807D770()) + if (!IsWeatherNotFadingIn()) { return; } @@ -1191,7 +1191,7 @@ bool8 sub_80867AC(struct Task *task) // gUnknown_0839F2CC[0] bool8 sub_8086854(struct Task *task) // gUnknown_0839F2CC[1] { - if (sub_807D770()) + if (IsWeatherNotFadingIn()) { task->data[0]++; } @@ -1813,7 +1813,7 @@ bool8 sub_80874CC(struct Task *task, struct MapObject *mapObject, struct Sprite bool8 sub_80874FC(struct Task *task, struct MapObject *mapObject, struct Sprite *sprite) { - if (sub_807D770()) + if (IsWeatherNotFadingIn()) { gFieldEffectArguments[0] = mapObject->coords2.x; gFieldEffectArguments[1] = mapObject->coords2.y; @@ -2046,7 +2046,7 @@ void sub_8087A74(u8 taskId) void sub_8087AA4(struct Task *task) { - if (sub_807D770()) + if (IsWeatherNotFadingIn()) { task->data[0]++; task->data[15] = player_get_direction_lower_nybble(); @@ -2199,7 +2199,7 @@ void sub_8087E4C(struct Task *task) { struct Sprite *sprite; s16 centerToCornerVecY; - if (sub_807D770()) + if (IsWeatherNotFadingIn()) { sprite = &gSprites[gPlayerAvatar.spriteId]; centerToCornerVecY = -(sprite->centerToCornerVecY << 1); diff --git a/src/field/field_effect_helpers.c b/src/field/field_effect_helpers.c index 165829a55..93fc62bd5 100644 --- a/src/field/field_effect_helpers.c +++ b/src/field/field_effect_helpers.c @@ -95,7 +95,7 @@ static void npc_pal_op_B(struct MapObject *mapObject, u8 paletteNum) { pal_patch_for_npc(npc_paltag_by_palslot(paletteNum), paletteNum); } - sub_807D78C(paletteNum); + UpdateSpritePaletteWithWeather(paletteNum); } } @@ -107,7 +107,7 @@ static void npc_pal_op_A(struct MapObject *mapObject, u8 paletteNum) if (graphicsInfo->paletteTag2 != 0x11ff) { pal_patch_for_npc(graphicsInfo->paletteTag2, paletteNum); - sub_807D78C(paletteNum); + UpdateSpritePaletteWithWeather(paletteNum); } } diff --git a/src/field/field_fadetransition.c b/src/field/field_fadetransition.c index 5014e97e3..ad1cd4a59 100644 --- a/src/field/field_fadetransition.c +++ b/src/field/field_fadetransition.c @@ -44,18 +44,18 @@ void pal_fill_for_map_transition(void) switch (fade_type_for_given_maplight_pair(map_light, Overworld_GetMapTypeOfSaveblockLocation())) { case 0: - fade_screen(0, 0); + FadeScreen(0, 0); palette_bg_fill_black(); break; case 1: - fade_screen(2, 0); + FadeScreen(2, 0); palette_bg_fill_white(); } } void pal_fill_black(void) { - fade_screen(0, 0); + FadeScreen(0, 0); palette_bg_fill_black(); } @@ -65,10 +65,10 @@ void fade_8080918(void) switch (sub_810CDB8(light_level, warp1_get_mapheader()->mapType)) { case 0: - fade_screen(1, 0); + FadeScreen(1, 0); break; case 1: - fade_screen(3, 0); + FadeScreen(3, 0); } } @@ -366,7 +366,7 @@ bool32 sub_8080E64(void) bool32 sub_8080E70(void) { - if (sub_807D770() == TRUE) + if (IsWeatherNotFadingIn() == TRUE) return TRUE; else return FALSE; @@ -483,7 +483,7 @@ void sub_8081050(u8 taskId) { case 0: ClearLinkCallback_2(); - fade_screen(1, 0); + FadeScreen(1, 0); sub_8053FF8(); PlaySE(SE_KAIDAN); data[0]++; diff --git a/src/field/field_weather.c b/src/field/field_weather.c index 2a5c311ab..7beb1b440 100644 --- a/src/field/field_weather.c +++ b/src/field/field_weather.c @@ -71,10 +71,18 @@ static const u8 *const sCompressedDroughtPalettes[] = // this file produces the same result as accessing gWeather directly. struct Weather *const gWeatherPtr = &gWeather; -static bool8 sub_807D574(u8); -static void DroughtBlendSomething_807D304(s8 gammaIndex, u8 blendCoeff, u16 blendColor); +static bool8 LightenSpritePaletteInFog(u8); static void BuildGammaShiftTables(void); -static void UpdateGammaShift(void); +static void UpdateWeatherGammaShift(void); +static void ApplyGammaShift(u8 startPalIndex, u8 numPalettes, s8 gammaIndex); +static void ApplyGammaShiftWithBlend(u8 startPalIndex, u8 numPalettes, s8 gammaIndex, u8 blendCoeff, u16 blendColor); +static void ApplyDroughtGammaShiftWithBlend(s8 gammaIndex, u8 blendCoeff, u16 blendColor); +static void ApplyFogBlend(u8 blendCoeff, u16 blendColor); +static bool8 FadeInScreen_RainShowShade(void); +static bool8 FadeInScreen_Drought(void); +static bool8 FadeInScreen_Fog1(void); +static void FadeInScreenWithWeather(void); +static void DoNothing(void); void None_Init(void); void None_Main(void); bool8 None_Finish(void); @@ -154,12 +162,12 @@ static const struct WeatherCallbacks sWeatherFuncs[] = {Bubbles_InitVars, Bubbles_Main, Bubbles_InitAll, Bubbles_Finish}, }; -void (*const gUnknown_083970B8[])(void) = +void (*const gWeatherPalStateFuncs[])(void) = { - UpdateGammaShift, - sub_807CCAC, - nullsub_39, - nullsub_39, + UpdateWeatherGammaShift, // WEATHER_PAL_STATE_CHANGING_WEATHER + FadeInScreenWithWeather, // WEATHER_PAL_STATE_SCREEN_FADING_IN + DoNothing, // WEATHER_PAL_STATE_SCREEN_FADING_OUT + DoNothing, // WEATHER_PAL_STATE_IDLE }; // This table specifies which of the gamma shift tables should be @@ -214,7 +222,7 @@ void StartWeather(void) CpuCopy32(gUnknown_083970E8, &gPlttBufferUnfaded[0x100 + index * 16], 32); BuildGammaShiftTables(); gWeatherPtr->altGammaSpritePalIndex = index; - gWeatherPtr->unknown_6D4 = AllocSpritePalette(0x1201); + gWeatherPtr->weatherPicSpritePalIndex = AllocSpritePalette(0x1201); gWeatherPtr->rainSpriteCount = 0; gWeatherPtr->unknown_6D8 = 0; gWeatherPtr->cloudSpritesCreated = 0; @@ -225,13 +233,13 @@ void StartWeather(void) gWeatherPtr->sandstormSprites1Created = 0; gWeatherPtr->sandstormSprites2Created = 0; gWeatherPtr->unknown_72E = 0; - gWeatherPtr->unknown_6FA = 0; + gWeatherPtr->lightenedFogSpritePalsCount = 0; Weather_SetBlendCoeffs(16, 0); gWeatherPtr->currWeather = 0; - gWeatherPtr->unknown_6C6 = 3; - gWeatherPtr->unknown_6C8 = 0; - gWeatherPtr->unknown_6D3 = 1; - gWeatherPtr->unknown_6C9 = CreateTask(Task_WeatherInit, 80); + gWeatherPtr->palProcessingState = WEATHER_PAL_STATE_IDLE; + gWeatherPtr->readyForInit = FALSE; + gWeatherPtr->weatherChangeComplete = TRUE; + gWeatherPtr->taskId = CreateTask(Task_WeatherInit, 80); } } @@ -247,7 +255,7 @@ void ChangeWeather(u8 weather) sWeatherFuncs[weather].initVars(); } - gWeatherPtr->unknown_6D3 = 0; + gWeatherPtr->weatherChangeComplete = FALSE; gWeatherPtr->nextWeather = weather; gWeatherPtr->finishStep = 0; } @@ -264,12 +272,14 @@ void sub_807C9B4(u8 weather) PlayRainSoundEffect(); gWeatherPtr->currWeather = weather; gWeatherPtr->nextWeather = weather; - gWeatherPtr->unknown_6C8 = 1; + gWeatherPtr->readyForInit = TRUE; } void Task_WeatherInit(u8 taskId) { - if (gWeatherPtr->unknown_6C8) + // Waits until it's ok to initialize weather. + // When the screen fades in, this is set to TRUE. + if (gWeatherPtr->readyForInit) { sWeatherFuncs[gWeatherPtr->currWeather].initAll(); gTasks[taskId].func = Task_WeatherMain; @@ -282,18 +292,20 @@ void Task_WeatherMain(u8 taskId) { if (!sWeatherFuncs[gWeatherPtr->currWeather].finish()) { + // Finished cleaning up previous weather. Now transition to next weather. sWeatherFuncs[gWeatherPtr->nextWeather].initVars(); gWeatherPtr->gammaStepFrameCounter = 0; - gWeatherPtr->unknown_6C6 = 0; + gWeatherPtr->palProcessingState = WEATHER_PAL_STATE_CHANGING_WEATHER; gWeatherPtr->currWeather = gWeatherPtr->nextWeather; - gWeatherPtr->unknown_6D3 = 1; + gWeatherPtr->weatherChangeComplete = TRUE; } } else { sWeatherFuncs[gWeatherPtr->currWeather].main(); } - gUnknown_083970B8[gWeatherPtr->unknown_6C6](); + + gWeatherPalStateFuncs[gWeatherPtr->palProcessingState](); } void None_Init(void) @@ -383,11 +395,11 @@ static void BuildGammaShiftTables(void) // When the weather is changing, it gradually updates the palettes // towards the desired gamma shift. -static void UpdateGammaShift(void) +static void UpdateWeatherGammaShift(void) { if (gWeatherPtr->gammaIndex == gWeatherPtr->gammaTargetIndex) { - gWeatherPtr->unknown_6C6 = 3; + gWeatherPtr->palProcessingState = WEATHER_PAL_STATE_IDLE; } else { @@ -398,15 +410,17 @@ static void UpdateGammaShift(void) gWeatherPtr->gammaIndex++; else gWeatherPtr->gammaIndex--; - BlendSomething_807CEBC(0, 32, gWeatherPtr->gammaIndex); + + ApplyGammaShift(0, 32, gWeatherPtr->gammaIndex); } } } -void sub_807CCAC(void) +static void FadeInScreenWithWeather(void) { if (++gWeatherPtr->unknown_6CB > 1) gWeatherPtr->unknown_6CA = 0; + switch (gWeatherPtr->currWeather) { case WEATHER_RAIN_LIGHT: @@ -414,24 +428,24 @@ void sub_807CCAC(void) case WEATHER_RAIN_HEAVY: case WEATHER_SNOW: case WEATHER_SHADE: - if (RainSnowShadeBlend_807CDC4() == 0) + if (FadeInScreen_RainShowShade() == FALSE) { gWeatherPtr->gammaIndex = 3; - gWeatherPtr->unknown_6C6 = 3; + gWeatherPtr->palProcessingState = WEATHER_PAL_STATE_IDLE; } break; case WEATHER_DROUGHT: - if (DroughtBlend_807CE24() == 0) + if (FadeInScreen_Drought() == FALSE) { gWeatherPtr->gammaIndex = -6; - gWeatherPtr->unknown_6C6 = 3; + gWeatherPtr->palProcessingState = WEATHER_PAL_STATE_IDLE; } break; case WEATHER_FOG_1: - if (Fog1Blend_807CE7C() == 0) + if (FadeInScreen_Fog1() == FALSE) { gWeatherPtr->gammaIndex = 0; - gWeatherPtr->unknown_6C6 = 3; + gWeatherPtr->palProcessingState = WEATHER_PAL_STATE_IDLE; } break; case WEATHER_ASH: @@ -442,54 +456,58 @@ void sub_807CCAC(void) if (!gPaletteFade.active) { gWeatherPtr->gammaIndex = gWeatherPtr->gammaTargetIndex; - gWeatherPtr->unknown_6C6 = 3; + gWeatherPtr->palProcessingState = WEATHER_PAL_STATE_IDLE; } break; } } -u8 RainSnowShadeBlend_807CDC4(void) +bool8 FadeInScreen_RainShowShade(void) { - if (gWeatherPtr->unknown_6C7 == 0x10) - return 0; - if (++gWeatherPtr->unknown_6C7 >= 0x10) + if (gWeatherPtr->fadeScreenCounter == 16) + return FALSE; + + if (++gWeatherPtr->fadeScreenCounter >= 16) { - BlendSomething_807CEBC(0, 32, 3); - gWeatherPtr->unknown_6C7 = 0x10; - return 0; + ApplyGammaShift(0, 32, 3); + gWeatherPtr->fadeScreenCounter = 16; + return FALSE; } - BlendSomething_807D1BC(0, 32, 3, 0x10 - gWeatherPtr->unknown_6C7, gWeatherPtr->fadeDestColor); - return 1; + + ApplyGammaShiftWithBlend(0, 32, 3, 16 - gWeatherPtr->fadeScreenCounter, gWeatherPtr->fadeDestColor); + return TRUE; } -u8 DroughtBlend_807CE24(void) +bool8 FadeInScreen_Drought(void) { - if (gWeatherPtr->unknown_6C7 == 0x10) - return 0; - if (++gWeatherPtr->unknown_6C7 >= 0x10) + if (gWeatherPtr->fadeScreenCounter == 16) + return FALSE; + + if (++gWeatherPtr->fadeScreenCounter >= 16) { - BlendSomething_807CEBC(0, 32, -6); - gWeatherPtr->unknown_6C7 = 0x10; - return 0; + ApplyGammaShift(0, 32, -6); + gWeatherPtr->fadeScreenCounter = 16; + return FALSE; } - DroughtBlendSomething_807D304(-6, 0x10 - gWeatherPtr->unknown_6C7, gWeatherPtr->fadeDestColor); - return 1; -} -u8 Fog1Blend_807CE7C(void) -{ - if (gWeatherPtr->unknown_6C7 == 0x10) - return 0; - ++gWeatherPtr->unknown_6C7; - BlendSomething_807D424(0x10 - gWeatherPtr->unknown_6C7, gWeatherPtr->fadeDestColor); - return 1; + ApplyDroughtGammaShiftWithBlend(-6, 16 - gWeatherPtr->fadeScreenCounter, gWeatherPtr->fadeDestColor); + return TRUE; } -void nullsub_39(void) +bool8 FadeInScreen_Fog1(void) { + if (gWeatherPtr->fadeScreenCounter == 16) + return FALSE; + + gWeatherPtr->fadeScreenCounter++; + ApplyFogBlend(16 - gWeatherPtr->fadeScreenCounter, gWeatherPtr->fadeDestColor); + return TRUE; } -void BlendSomething_807CEBC(u8 startPalIndex, u8 numPalettes, s8 gammaIndex) +static void DoNothing(void) +{ } + +static void ApplyGammaShift(u8 startPalIndex, u8 numPalettes, s8 gammaIndex) { u16 curPalIndex; u16 palOffset; @@ -607,7 +625,7 @@ void BlendSomething_807CEBC(u8 startPalIndex, u8 numPalettes, s8 gammaIndex) } } -void BlendSomething_807D1BC(u8 startPalIndex, u8 numPalettes, s8 gammaIndex, u8 blendCoeff, u16 blendColor) +static void ApplyGammaShiftWithBlend(u8 startPalIndex, u8 numPalettes, s8 gammaIndex, u8 blendCoeff, u16 blendColor) { u16 palOffset; u16 curPalIndex; @@ -658,7 +676,7 @@ void BlendSomething_807D1BC(u8 startPalIndex, u8 numPalettes, s8 gammaIndex, u8 } } -void DroughtBlendSomething_807D304(s8 gammaIndex, u8 blendCoeff, u16 blendColor) +void ApplyDroughtGammaShiftWithBlend(s8 gammaIndex, u8 blendCoeff, u16 blendColor) { struct RGBColor color; u8 rBlend; @@ -713,7 +731,7 @@ void DroughtBlendSomething_807D304(s8 gammaIndex, u8 blendCoeff, u16 blendColor) } } -void BlendSomething_807D424(u8 blendCoeff, u16 blendColor) +void ApplyFogBlend(u8 blendCoeff, u16 blendColor) { struct RGBColor color; u8 rBlend; @@ -729,7 +747,7 @@ void BlendSomething_807D424(u8 blendCoeff, u16 blendColor) for (curPalIndex = 16; curPalIndex < 32; curPalIndex++) { - if (sub_807D574(curPalIndex)) + if (LightenSpritePaletteInFog(curPalIndex)) { u16 palEnd = (curPalIndex + 1) * 16; u16 palOffset = curPalIndex * 16; @@ -760,22 +778,22 @@ void BlendSomething_807D424(u8 blendCoeff, u16 blendColor) } } -void sub_807D540(u8 paletteIndex) +static void MarkFogSpritePalToLighten(u8 paletteIndex) { - if (gWeatherPtr->unknown_6FA < 6) + if (gWeatherPtr->lightenedFogSpritePalsCount < 6) { - gWeatherPtr->unknown_6F4[gWeatherPtr->unknown_6FA] = paletteIndex; - gWeatherPtr->unknown_6FA++; + gWeatherPtr->lightenedFogSpritePals[gWeatherPtr->lightenedFogSpritePalsCount] = paletteIndex; + gWeatherPtr->lightenedFogSpritePalsCount++; } } -bool8 sub_807D574(u8 paletteIndex) +static bool8 LightenSpritePaletteInFog(u8 paletteIndex) { u16 i; - for (i = 0; i < gWeatherPtr->unknown_6FA; i++) + for (i = 0; i < gWeatherPtr->lightenedFogSpritePalsCount; i++) { - if (gWeatherPtr->unknown_6F4[i] == paletteIndex) + if (gWeatherPtr->lightenedFogSpritePals[i] == paletteIndex) return TRUE; } @@ -784,18 +802,18 @@ bool8 sub_807D574(u8 paletteIndex) void sub_807D5BC(s8 gammaIndex) { - if (gWeatherPtr->unknown_6C6 == 3) + if (gWeatherPtr->palProcessingState == WEATHER_PAL_STATE_IDLE) { - BlendSomething_807CEBC(0, 32, gammaIndex); + ApplyGammaShift(0, 32, gammaIndex); gWeatherPtr->gammaIndex = gammaIndex; } } void sub_807D5F0(u8 gammaIndex, u8 gammaTargetIndex, u8 gammaStepDelay) { - if (gWeatherPtr->unknown_6C6 == 3) + if (gWeatherPtr->palProcessingState == WEATHER_PAL_STATE_IDLE) { - gWeatherPtr->unknown_6C6 = 0; + gWeatherPtr->palProcessingState = WEATHER_PAL_STATE_CHANGING_WEATHER; gWeatherPtr->gammaIndex = gammaIndex; gWeatherPtr->gammaTargetIndex = gammaTargetIndex; gWeatherPtr->gammaStepFrameCounter = 0; @@ -804,29 +822,29 @@ void sub_807D5F0(u8 gammaIndex, u8 gammaTargetIndex, u8 gammaStepDelay) } } -void fade_screen(u8 mode, u8 delay) +void FadeScreen(u8 mode, u8 delay) { u32 fadeColor; - bool8 fadeTo; + bool8 fadeOut; bool8 useWeatherPal; switch (mode) { case FADE_FROM_BLACK: fadeColor = 0; - fadeTo = FALSE; + fadeOut = FALSE; break; case FADE_FROM_WHITE: fadeColor = 0xFFFF; - fadeTo = FALSE; + fadeOut = FALSE; break; case FADE_TO_BLACK: fadeColor = 0; - fadeTo = TRUE; + fadeOut = TRUE; break; case FADE_TO_WHITE: fadeColor = 0xFFFF; - fadeTo = TRUE; + fadeOut = TRUE; break; default: return; @@ -848,59 +866,63 @@ void fade_screen(u8 mode, u8 delay) break; } - if (fadeTo) + if (fadeOut) { if (useWeatherPal) CpuFastCopy(gPlttBufferFaded, gPlttBufferUnfaded, 0x400); + BeginNormalPaletteFade(0xFFFFFFFF, delay, 0, 16, fadeColor); - gWeatherPtr->unknown_6C6 = 2; + gWeatherPtr->palProcessingState = WEATHER_PAL_STATE_SCREEN_FADING_OUT; } else { gWeatherPtr->fadeDestColor = fadeColor; if (useWeatherPal) - gWeatherPtr->unknown_6C7 = 0; + gWeatherPtr->fadeScreenCounter = 0; else BeginNormalPaletteFade(0xFFFFFFFF, delay, 16, 0, fadeColor); - gWeatherPtr->unknown_6C6 = 1; + + gWeatherPtr->palProcessingState = WEATHER_PAL_STATE_SCREEN_FADING_IN; gWeatherPtr->unknown_6CA = 1; gWeatherPtr->unknown_6CB = 0; Weather_SetBlendCoeffs(gWeatherPtr->currBlendEVA, gWeatherPtr->currBlendEVB); - gWeatherPtr->unknown_6C8 = 1; + gWeatherPtr->readyForInit = TRUE; } } -bool8 sub_807D770(void) +bool8 IsWeatherNotFadingIn(void) { - return (gWeatherPtr->unknown_6C6 != 1); + return (gWeatherPtr->palProcessingState != WEATHER_PAL_STATE_SCREEN_FADING_IN); } -void sub_807D78C(u8 spritePaletteIndex) +void UpdateSpritePaletteWithWeather(u8 spritePaletteIndex) { u16 paletteIndex = 16 + spritePaletteIndex; u16 i; - switch (gWeatherPtr->unknown_6C6) + switch (gWeatherPtr->palProcessingState) { - case 1: + case WEATHER_PAL_STATE_SCREEN_FADING_IN: if (gWeatherPtr->unknown_6CA != 0) { if (gWeatherPtr->currWeather == WEATHER_FOG_1) - sub_807D540(paletteIndex); + MarkFogSpritePalToLighten(paletteIndex); paletteIndex *= 16; for (i = 0; i < 16; i++) gPlttBufferFaded[paletteIndex + i] = gWeatherPtr->fadeDestColor; } break; - case 2: + case WEATHER_PAL_STATE_SCREEN_FADING_OUT: paletteIndex *= 16; CpuFastCopy(gPlttBufferFaded + paletteIndex, gPlttBufferUnfaded + paletteIndex, 32); BlendPalette(paletteIndex, 16, gPaletteFade.y, gPaletteFade.blendColor); break; + // WEATHER_PAL_STATE_CHANGING_WEATHER + // WEATHER_PAL_STATE_CHANGING_IDLE default: if (gWeatherPtr->currWeather != WEATHER_FOG_1) { - BlendSomething_807CEBC(paletteIndex, 1, gWeatherPtr->gammaIndex); + ApplyGammaShift(paletteIndex, 1, gWeatherPtr->gammaIndex); } else { @@ -911,23 +933,23 @@ void sub_807D78C(u8 spritePaletteIndex) } } -void sub_807D874(u8 paletteIndex) +void ApplyWeatherGammaShiftToPal(u8 paletteIndex) { - BlendSomething_807CEBC(paletteIndex, 1, gWeatherPtr->gammaIndex); + ApplyGammaShift(paletteIndex, 1, gWeatherPtr->gammaIndex); } u8 unref_sub_807D894(void) { - if (gWeatherPtr->unknown_6C6 == 1) + if (gWeatherPtr->palProcessingState == WEATHER_PAL_STATE_SCREEN_FADING_IN) return gWeatherPtr->unknown_6CA; else return 0; } -void sub_807D8C0(const u16 *palette) +void LoadCustomWeatherSpritePalette(const u16 *palette) { - LoadPalette(palette, 0x100 + gWeatherPtr->unknown_6D4 * 16, 32); - sub_807D78C(gWeatherPtr->unknown_6D4); + LoadPalette(palette, 0x100 + gWeatherPtr->weatherPicSpritePalIndex * 16, 32); + UpdateSpritePaletteWithWeather(gWeatherPtr->weatherPicSpritePalIndex); } static void LoadDroughtWeatherPalette(u8 *gammaIndexPtr, u8 *b) @@ -1085,34 +1107,34 @@ void unref_sub_807DCB4(u8 a) switch (a) { case 1: - SetWeather(1); + SetWeather(WEATHER_CLOUDS); break; case 2: - SetWeather(2); + SetWeather(WEATHER_SUNNY); break; case 3: - SetWeather(3); + SetWeather(WEATHER_RAIN_LIGHT); break; case 4: - SetWeather(4); + SetWeather(WEATHER_SNOW); break; case 5: - SetWeather(5); + SetWeather(WEATHER_RAIN_MED); break; case 6: - SetWeather(6); + SetWeather(WEATHER_FOG_1); break; case 7: - SetWeather(9); + SetWeather(WEATHER_FOG_2); break; case 8: - SetWeather(7); + SetWeather(WEATHER_ASH); break; case 9: - SetWeather(8); + SetWeather(WEATHER_SANDSTORM); break; case 10: - SetWeather(11); + SetWeather(WEATHER_SHADE); break; } } @@ -1122,11 +1144,11 @@ u8 GetCurrentWeather(void) return gWeatherPtr->currWeather; } -void SetRainStrengthFromSoundEffect(u16 sndEff) +void SetRainStrengthFromSoundEffect(u16 soundEffect) { - if (gWeatherPtr->unknown_6C6 != 2) + if (gWeatherPtr->palProcessingState != WEATHER_PAL_STATE_SCREEN_FADING_OUT) { - switch (sndEff) + switch (soundEffect) { case SE_T_KOAME: gWeatherPtr->rainStrength = 0; @@ -1140,7 +1162,8 @@ void SetRainStrengthFromSoundEffect(u16 sndEff) default: return; } - PlaySE(sndEff); + + PlaySE(soundEffect); } } @@ -1164,19 +1187,19 @@ void PlayRainSoundEffect(void) } } -u8 sub_807DDFC(void) +u8 IsWeatherChangeComplete(void) { - return gWeatherPtr->unknown_6D3; + return gWeatherPtr->weatherChangeComplete; } -void sub_807DE10(void) +void SetWeatherScreenFadeOut(void) { - gWeatherPtr->unknown_6C6 = 2; + gWeatherPtr->palProcessingState = WEATHER_PAL_STATE_SCREEN_FADING_OUT; } void unref_sub_807DE24(void) { - gWeatherPtr->unknown_6C6 = 3; + gWeatherPtr->palProcessingState = WEATHER_PAL_STATE_IDLE; } void PreservePaletteInWeather(u8 preservedPalIndex) diff --git a/src/field/field_weather_effects.c b/src/field/field_weather_effects.c index 0fee26b89..eff702f8c 100644 --- a/src/field/field_weather_effects.c +++ b/src/field/field_weather_effects.c @@ -75,7 +75,6 @@ static const struct SpriteTemplate sCloudSpriteTemplate = }; extern void sub_807D5BC(s8 gammaIndex); -extern void sub_807D8C0(const u16 *palette); extern void sub_807DA14(void); extern void sub_807DA4C(void); extern void Weather_SetTargetBlendCoeffs(u8 a, u8 b, int c); @@ -182,7 +181,7 @@ void CreateCloudSprites(void) if (gWeatherPtr->cloudSpritesCreated == TRUE) return; LoadSpriteSheet(&sCloudSpriteSheet); - sub_807D8C0(gUnknown_08397108); + LoadCustomWeatherSpritePalette(gUnknown_08397108); for (i = 0; i < 3; i++) { u8 spriteId = CreateSprite(&sCloudSpriteTemplate, 0, 0, 0xFF); @@ -252,7 +251,7 @@ void Drought_Main(void) switch (gWeatherPtr->initStep) { case 0: - if (gWeatherPtr->unknown_6C6 != 0) + if (gWeatherPtr->palProcessingState != WEATHER_PAL_STATE_CHANGING_WEATHER) gWeatherPtr->initStep++; break; case 1: @@ -1137,7 +1136,7 @@ void Rain_Main(void) gWeatherPtr->initStep++; break; case 3: - if (gWeatherPtr->unknown_6C6 == 0) + if (gWeatherPtr->palProcessingState == WEATHER_PAL_STATE_CHANGING_WEATHER) break; gWeatherPtr->initStep = 6; break; @@ -1211,7 +1210,7 @@ void Rain_Main(void) gWeatherPtr->initStep++; break; case 14: - if (gWeatherPtr->unknown_6C6 != 3) + if (gWeatherPtr->palProcessingState != WEATHER_PAL_STATE_IDLE) break; gWeatherPtr->unknown_6EA = 1; gWeatherPtr->initStep = 4; @@ -2013,7 +2012,7 @@ void CreateSandstormSprites_1(void) if (!gWeatherPtr->sandstormSprites1Created) { LoadSpriteSheet(&sSandstormSpriteSheet); - sub_807D8C0(gUnknown_08397128); + LoadCustomWeatherSpritePalette(gUnknown_08397128); for (i = 0; i < 20; i++) { u8 spriteId = CreateSpriteAtEnd(&sSandstormSpriteTemplate, 0, (i / 5) * 64, 1); diff --git a/src/field/item_menu.c b/src/field/item_menu.c index 6bad9f4d6..959eb09ae 100644 --- a/src/field/item_menu.c +++ b/src/field/item_menu.c @@ -47,7 +47,7 @@ extern void sub_808B5B4(); extern u8 sub_80F92F4(); extern void sub_80C9C7C(u8); extern void pal_fill_black(void); -extern bool8 sub_807D770(void); +extern bool8 IsWeatherNotFadingIn(void); extern u8 sub_80F931C(); extern void sub_808A3F8(u8); extern void Shop_FadeReturnToMartMenu(void); @@ -2699,7 +2699,7 @@ void ExecuteItemUseFromBlackPalette(void) static void Task_CallItemUseOnFieldCallback(u8 taskId) { - if (sub_807D770() == TRUE) + if (IsWeatherNotFadingIn() == TRUE) gFieldItemUseCallback(taskId); } diff --git a/src/field/item_use.c b/src/field/item_use.c index cdad3f840..219ef5080 100644 --- a/src/field/item_use.c +++ b/src/field/item_use.c @@ -100,7 +100,7 @@ void ItemMenu_ConfirmNormalFade(u8 var) void ItemMenu_ConfirmComplexFade(u8 var) { ExecuteSwitchToOverworldFromItemUse(var); - fade_screen(1, 0); + FadeScreen(1, 0); } void SetUpItemUseOnFieldCallback(u8 taskId) diff --git a/src/field/overworld.c b/src/field/overworld.c index fc313693a..07453e4fe 100644 --- a/src/field/overworld.c +++ b/src/field/overworld.c @@ -612,7 +612,7 @@ void sub_80538F0(u8 mapGroup, u8 mapNum) apply_map_tileset2_palette(gMapHeader.mapData); for (paletteIndex = 6; paletteIndex < 12; paletteIndex++) - sub_807D874(paletteIndex); + ApplyWeatherGammaShiftToPal(paletteIndex); sub_8072ED0(); UpdateLocationHistoryForRoamer(); diff --git a/src/field/player_pc.c b/src/field/player_pc.c index 3719b7c7a..27427ecaa 100644 --- a/src/field/player_pc.c +++ b/src/field/player_pc.c @@ -29,7 +29,7 @@ extern void DestroyVerticalScrollIndicator(u8); extern void PauseVerticalScrollIndicator(u8); extern void LoadScrollIndicatorPalette(void); extern void ClearMailStruct(struct MailStruct *); -extern u8 sub_807D770(void); +extern u8 IsWeatherNotFadingIn(void); extern void sub_808B020(void); extern void ClearVerticalScrollIndicatorPalettes(void); @@ -357,12 +357,12 @@ static void Task_ItemStorage_Deposit(u8 taskId) static void ItemStorage_Deposit(u8 taskId) { TASK.FUNC = Task_ItemStorage_Deposit; - fade_screen(1, 0); + FadeScreen(1, 0); } static void ItemStorage_HandleReturnToProcessInput(u8 taskId) { - if (sub_807D770() == TRUE) + if (IsWeatherNotFadingIn() == TRUE) TASK.FUNC = ItemStorageMenuProcessInput; } @@ -1196,7 +1196,7 @@ static void Mailbox_MailOptionsProcessInput(u8 taskId) static void Mailbox_DoMailRead(u8 taskId) { - fade_screen(1, 0); + FadeScreen(1, 0); TASK.FUNC = Mailbox_FadeAndReadMail; } @@ -1211,7 +1211,7 @@ static void Mailbox_FadeAndReadMail(u8 taskId) static void Mailbox_HandleReturnToProcessInput(u8 taskId) // Mailbox_HandleReturnToProcessInput { - if(sub_807D770() == TRUE) // is black fade finished? why not gPaletteFade.active? + if (IsWeatherNotFadingIn() == TRUE) // is black fade finished? why not gPaletteFade.active? TASK.FUNC = Mailbox_ProcessInput; } @@ -1280,7 +1280,7 @@ static void Mailbox_Give(u8 taskId) Mailbox_NoPokemonForMail(taskId); // cannot be reached normally else { - fade_screen(1, 0); + FadeScreen(1, 0); TASK.FUNC = Mailbox_DoGiveMailPokeMenu; } } diff --git a/src/field/scrcmd.c b/src/field/scrcmd.c index 36edbe472..bc5cd0b1d 100644 --- a/src/field/scrcmd.c +++ b/src/field/scrcmd.c @@ -626,7 +626,7 @@ bool8 IsPaletteNotActive(void) bool8 ScrCmd_fadescreen(struct ScriptContext *ctx) { - fade_screen(ScriptReadByte(ctx), 0); + FadeScreen(ScriptReadByte(ctx), 0); SetupNativeScript(ctx, IsPaletteNotActive); return TRUE; } @@ -636,7 +636,7 @@ bool8 ScrCmd_fadescreenspeed(struct ScriptContext *ctx) u8 duration = ScriptReadByte(ctx); u8 delay = ScriptReadByte(ctx); - fade_screen(duration, delay); + FadeScreen(duration, delay); SetupNativeScript(ctx, IsPaletteNotActive); return TRUE; } diff --git a/src/field/secret_base.c b/src/field/secret_base.c index 134aebbc6..2d02de004 100644 --- a/src/field/secret_base.c +++ b/src/field/secret_base.c @@ -348,7 +348,7 @@ void sub_80BBA48(u8 taskid) void sub_80BBAF0(void) { CreateTask(sub_80BBA48, 0); - fade_screen(1, 0); + FadeScreen(1, 0); saved_warp2_set(0, gSaveBlock1.location.mapGroup, gSaveBlock1.location.mapNum, -1); } @@ -362,7 +362,7 @@ bool8 sub_80BBB24(void) void sub_80BBB50(u8 taskid) { FieldObjectTurn(&(gMapObjects[gPlayerAvatar.mapObjectId]), 2); - if (sub_807D770() == 1) { + if (IsWeatherNotFadingIn() == 1) { EnableBothScriptContexts(); DestroyTask(taskid); } @@ -397,7 +397,7 @@ void sub_80BBC78(void) { u8 taskid = CreateTask(sub_80BBBEC, 0); gTasks[taskid].data[0] = 0; - fade_screen(1, 0); + FadeScreen(1, 0); } bool8 CurrentMapIsSecretBase(void) @@ -534,7 +534,7 @@ void sub_80BC074(u8 taskid) void sub_80BC0F8(void) { CreateTask(sub_80BC074, 0); - fade_screen(1, 0); + FadeScreen(1, 0); } void sub_80BC114(void) { diff --git a/src/field/shop.c b/src/field/shop.c index a228ff92f..e087628da 100644 --- a/src/field/shop.c +++ b/src/field/shop.c @@ -173,7 +173,7 @@ static void Task_HandleShopMenuBuy(u8 taskId) gTasks[taskId].data[8] = (u32)BuyMenuDrawGraphics >> 16; gTasks[taskId].data[9] = (u32)BuyMenuDrawGraphics; gTasks[taskId].func = Shop_FadeAndRunBuySellCallback; - fade_screen(1, 0); + FadeScreen(1, 0); } static void Task_HandleShopMenuSell(u8 taskId) @@ -181,7 +181,7 @@ static void Task_HandleShopMenuSell(u8 taskId) gTasks[taskId].data[8] = (u32)ItemMenu_LoadSellMenu >> 16; gTasks[taskId].data[9] = (u32)ItemMenu_LoadSellMenu; gTasks[taskId].func = Shop_FadeAndRunBuySellCallback; - fade_screen(1, 0); + FadeScreen(1, 0); } static void Task_HandleShopMenuQuit(u8 taskId) @@ -213,7 +213,7 @@ static void ReturnToShopMenuAfterExitingSellMenu(u8 taskId) static void Task_ReturnToMartMenu(u8 taskId) { - if (sub_807D770() == 1) + if (IsWeatherNotFadingIn() == 1) { if (gMartInfo.martType == MART_TYPE_2) DisplayItemMessageOnField(taskId, gOtherText_CanIHelpYou, ReturnToShopMenuAfterExitingSellMenu, 0); diff --git a/src/field/start_menu.c b/src/field/start_menu.c index 89cd404e9..381c19bb7 100644 --- a/src/field/start_menu.c +++ b/src/field/start_menu.c @@ -329,7 +329,7 @@ static u8 StartMenu_InputProcessCallback(void) if (gMenuCallback != StartMenu_SaveCallback && gMenuCallback != StartMenu_ExitCallback && gMenuCallback != StartMenu_RetireCallback) - fade_screen(1, 0); + FadeScreen(1, 0); return 0; } if (gMain.newKeys & (START_BUTTON | B_BUTTON)) diff --git a/src/pokemon/pokemon_menu.c b/src/pokemon/pokemon_menu.c index a41e197f2..c0cae9353 100644 --- a/src/pokemon/pokemon_menu.c +++ b/src/pokemon/pokemon_menu.c @@ -786,7 +786,7 @@ void FieldCallback_Teleport(void) static void sub_808ABA8(u8 taskID) { - if (sub_807D770() == TRUE) + if (IsWeatherNotFadingIn() == TRUE) { gFieldEffectArguments[0] = GetMonData(&gPlayerParty[gLastFieldPokeMenuOpened], MON_DATA_SPECIES); gUnknown_03005CE4(); diff --git a/src/scene/cable_car.c b/src/scene/cable_car.c index 8b4a1bb28..7faa8d844 100644 --- a/src/scene/cable_car.c +++ b/src/scene/cable_car.c @@ -18,6 +18,7 @@ #include "event_data.h" #include "cable_car_util.h" #include "constants/map_objects.h" +#include "constants/weather.h" // Static type declarations @@ -328,7 +329,7 @@ static void sub_8123740(void) i = 0; sub_8123FBC(0); gSpriteCoordOffsetX = 0; - sub_807C9B4(0); + sub_807C9B4(WEATHER_NONE); for (; i < 20; i++) { gWeatherPtr->sprites.s2.ashSprites[i] = NULL; @@ -769,7 +770,7 @@ static void LoadSprites(void) gSprites[spriteId].data[1] = 0x63; sCableCarPtr->unk_0002 = 7; sCableCarPtr->unk_0004 = 0x15e; - sub_807C9B4(2); + sub_807C9B4(WEATHER_SUNNY); break; case 1: CableCarUtil_CopyWrapped(sCableCarPtr->unk_00fc, eCableCar2->mtChimneyTilemap + 0x24, 0x18, 0x1a, 0x0c, 0x03); @@ -793,7 +794,7 @@ static void LoadSprites(void) gSprites[spriteId].data[1] = 0x41; sCableCarPtr->unk_0002 = 2; sCableCarPtr->unk_0004 = 0x109; - sub_807C9B4(7); + sub_807C9B4(WEATHER_ASH); break; } for (i = 0; i < 9; i++) |