From 26c38e80935af834eab2e043f3bc4cbfcb9781c9 Mon Sep 17 00:00:00 2001 From: Ariel A <24759293+aarant@users.noreply.github.com> Date: Wed, 22 Dec 2021 22:30:48 -0500 Subject: [PATCH] Removed lighting/day-night/shadow code from follower branch. --- common_syms/overworld.txt | 1 - include/event_object_movement.h | 1 - include/global.fieldmap.h | 2 +- include/global.h | 3 +- include/overworld.h | 2 - include/palette.h | 1 - .../field_effect_object_template_pointers.h | 1 - src/data/field_effects/field_effect_objects.h | 6 - .../object_events/object_event_graphics.h | 2 - src/event_object_movement.c | 151 ++++-------------- src/field_effect.c | 4 +- src/field_effect_helpers.c | 3 - src/field_weather.c | 1 - src/field_weather_effect.c | 8 +- src/overworld.c | 59 ------- src/palette.c | 47 ------ 16 files changed, 37 insertions(+), 255 deletions(-) diff --git a/common_syms/overworld.txt b/common_syms/overworld.txt index 4833362098..e136f54449 100644 --- a/common_syms/overworld.txt +++ b/common_syms/overworld.txt @@ -6,4 +6,3 @@ gFieldCallback gFieldCallback2 gLocalLinkPlayerId gFieldLinkPlayerCount -gTimeOfDay diff --git a/include/event_object_movement.h b/include/event_object_movement.h index 0ba2846f7a..b6d7addfc4 100644 --- a/include/event_object_movement.h +++ b/include/event_object_movement.h @@ -100,7 +100,6 @@ void UpdateFollowingPokemon(void); void RemoveFollowingPokemon(void); struct ObjectEvent * GetFollowerObject(void); u8 GetDirectionToFace(s16, s16, s16, s16); -void UpdateLightSprite(struct Sprite *); void TrySpawnObjectEvents(s16, s16); u8 CreateObjectGraphicsSprite(u16, void (*)(struct Sprite *), s16 x, s16 y, u8 subpriority); u8 TrySpawnObjectEvent(u8, u8, u8); diff --git a/include/global.fieldmap.h b/include/global.fieldmap.h index 75d55e9377..6babb4b917 100644 --- a/include/global.fieldmap.h +++ b/include/global.fieldmap.h @@ -181,7 +181,7 @@ struct ObjectEvent u32 inShallowFlowingWater:1; u32 inSandPile:1; u32 inHotSprings:1; - u32 noShadow:1; + u32 hasShadow:1; u32 spriteAnimPausedBackup:1; /*0x03*/ u32 spriteAffineAnimPausedBackup:1; u32 disableJumpLandingGroundEffect:1; diff --git a/include/global.h b/include/global.h index c4094ffc25..13bdf02823 100644 --- a/include/global.h +++ b/include/global.h @@ -497,7 +497,6 @@ struct SaveBlock2 extern struct SaveBlock2 *gSaveBlock2Ptr; -extern u8 UpdateSpritePaletteWithTime(u8); extern bool8 IsAccurateGBA(void); struct SecretBaseParty @@ -872,7 +871,7 @@ struct MysteryGiftSave struct WonderCardMetadata cardMetadata; u16 questionnaireWords[NUM_QUESTIONNAIRE_WORDS]; struct WonderNewsMetadata newsMetadata; - u32 trainerIds[2][5]; // Saved ids for 10 trainers, 5 each for battles and trades + u32 trainerIds[2][5]; // Saved ids for 10 trainers, 5 each for battles and trades }; // 0x36C 0x3598 // For external event data storage. The majority of these may have never been used. diff --git a/include/overworld.h b/include/overworld.h index 9cd71f8e05..0c573eec2a 100644 --- a/include/overworld.h +++ b/include/overworld.h @@ -57,7 +57,6 @@ extern void (*gFieldCallback)(void); extern bool8 (*gFieldCallback2)(void); extern u8 gLocalLinkPlayerId; extern u8 gFieldLinkPlayerCount; -extern u8 gTimeOfDay; // Exported ROM declarations extern const struct UCoords32 gDirectionToVectors[]; @@ -136,7 +135,6 @@ void CleanupOverworldWindowsAndTilemaps(void); bool32 IsOverworldLinkActive(void); void CB1_Overworld(void); void CB2_OverworldBasic(void); -void BlendPalettesWithTime(u32); void CB2_Overworld(void); void SetMainCallback1(void (*cb)(void)); void SetUnusedCallback(void *a0); diff --git a/include/palette.h b/include/palette.h index bd27651d02..81a1e1caec 100644 --- a/include/palette.h +++ b/include/palette.h @@ -59,7 +59,6 @@ void TransferPlttBuffer(void); u8 UpdatePaletteFade(void); void ResetPaletteFade(void); bool8 BeginNormalPaletteFade(u32, s8, u8, u8, u16); -bool8 BeginTimeOfDayPaletteFade(u32, s8, u8, u8, u16); void PaletteStruct_ResetById(u16); void ResetPaletteFadeControl(void); void InvertPlttBuffer(u32); diff --git a/src/data/field_effects/field_effect_object_template_pointers.h b/src/data/field_effects/field_effect_object_template_pointers.h index eb8e52029d..41d6271bf2 100755 --- a/src/data/field_effects/field_effect_object_template_pointers.h +++ b/src/data/field_effects/field_effect_object_template_pointers.h @@ -35,7 +35,6 @@ const struct SpriteTemplate gFieldEffectObjectTemplate_AshLaunch; const struct SpriteTemplate gFieldEffectObjectTemplate_Bubbles; const struct SpriteTemplate gFieldEffectObjectTemplate_SmallSparkle; const struct SpriteTemplate gFieldEffectObjectTemplate_Rayquaza; -const struct SpriteTemplate gFieldEffectObjectTemplate_BallLight; const struct SpriteTemplate *const gFieldEffectObjectTemplatePointers[] = { [FLDEFFOBJ_SHADOW_S] = &gFieldEffectObjectTemplate_ShadowSmall, diff --git a/src/data/field_effects/field_effect_objects.h b/src/data/field_effects/field_effect_objects.h index f6b83d5ad8..b50faedc46 100755 --- a/src/data/field_effects/field_effect_objects.h +++ b/src/data/field_effects/field_effect_objects.h @@ -28,12 +28,6 @@ static const struct SpriteFrameImage sPicTable_ShadowExtraLarge[] = { obj_frame_tiles(gFieldEffectObjectPic_ShadowExtraLarge), }; -const struct SpriteFrameImage gFieldEffectObjectPicTable_BallLight[] = { - obj_frame_tiles(gFieldEffectObjectPic_BallLight), -}; - -const struct SpriteTemplate gFieldEffectObjectTemplate_BallLight = {TAG_NONE, OBJ_EVENT_PAL_TAG_LIGHT, &gObjectEventBaseOam_32x32, sAnimTable_Inanimate, gFieldEffectObjectPicTable_BallLight, gDummySpriteAffineAnimTable, UpdateLightSprite}; - const struct SpriteTemplate gFieldEffectObjectTemplate_ShadowSmall = { .tileTag = TAG_NONE, .paletteTag = OBJ_EVENT_PAL_TAG_MAY, diff --git a/src/data/object_events/object_event_graphics.h b/src/data/object_events/object_event_graphics.h index 51ad7d3937..43ccdcff77 100755 --- a/src/data/object_events/object_event_graphics.h +++ b/src/data/object_events/object_event_graphics.h @@ -281,7 +281,6 @@ const u32 gFieldEffectObjectPic_ShadowSmall[] = INCBIN_U32("graphics/field_effec const u32 gFieldEffectObjectPic_ShadowMedium[] = INCBIN_U32("graphics/field_effects/pics/shadow_medium.4bpp"); const u32 gFieldEffectObjectPic_ShadowLarge[] = INCBIN_U32("graphics/field_effects/pics/shadow_large.4bpp"); const u32 gFieldEffectObjectPic_ShadowExtraLarge[] = INCBIN_U32("graphics/field_effects/pics/shadow_extra_large.4bpp"); -const u32 gFieldEffectObjectPic_BallLight[] = INCBIN_U32("graphics/object_events/pics/misc/light.4bpp"); static const u32 sFiller[0x48] = {}; const u8 gFieldEffectPic_CutGrass[] = INCBIN_U8("graphics/field_effects/pics/cut_grass.4bpp"); const u32 gFieldEffectPic_CutGrass_Copy[] = INCBIN_U32("graphics/field_effects/pics/cut_grass.4bpp"); @@ -779,5 +778,4 @@ const u32 gObjectEventPic_RayquazaCutscene[] = INCBIN_U32("graphics/object_event const u16 gObjectEventPal_HoOh[] = INCBIN_U16("graphics/object_events/palettes/ho_oh.gbapal"); const u16 gObjectEventPal_Lugia[] = INCBIN_U16("graphics/object_events/palettes/lugia.gbapal"); -const u16 gObjectEventPaletteLight[] = INCBIN_U16("graphics/object_events/palettes/light.gbapal"); const u16 gObjectEventPaletteEmotes[] = INCBIN_U16("graphics/misc/emotes.gbapal"); diff --git a/src/event_object_movement.c b/src/event_object_movement.c index f71a131ae7..ee12d3d579 100644 --- a/src/event_object_movement.c +++ b/src/event_object_movement.c @@ -449,7 +449,6 @@ const u8 gInitialMovementTypeFacingDirections[] = { #define OBJ_EVENT_PAL_TAG_RS_BRENDAN 0x1122 #define OBJ_EVENT_PAL_TAG_RS_MAY 0x1123 #define OBJ_EVENT_PAL_TAG_DYNAMIC 0x1124 -#define OBJ_EVENT_PAL_TAG_LIGHT 0x8001 #define OBJ_EVENT_PAL_TAG_EMOTES 0x8002 #define OBJ_EVENT_PAL_TAG_NONE 0x11FF @@ -499,7 +498,6 @@ static const struct SpritePalette sObjectEventSpritePalettes[] = { {gObjectEventPal_RubySapphireBrendan, OBJ_EVENT_PAL_TAG_RS_BRENDAN}, {gObjectEventPal_RubySapphireMay, OBJ_EVENT_PAL_TAG_RS_MAY}, {gObjectEventPal_Npc1, OBJ_EVENT_PAL_TAG_DYNAMIC}, - {gObjectEventPaletteLight, OBJ_EVENT_PAL_TAG_LIGHT}, {gObjectEventPaletteEmotes, OBJ_EVENT_PAL_TAG_EMOTES}, {NULL, 0x0000}, }; @@ -1684,7 +1682,6 @@ static void FollowerSetGraphics(struct ObjectEvent *objectEvent, u16 species, u8 if (IndexOfSpritePaletteTag(spritePalette->tag) == 0xFF) { // Load compressed palette LoadCompressedSpritePalette(spritePalette); sprite->oam.paletteNum = IndexOfSpritePaletteTag(spritePalette->tag); // Tag is always present - UpdateSpritePaletteWithTime(sprite->oam.paletteNum); } else sprite->oam.paletteNum = IndexOfSpritePaletteTag(spritePalette->tag); // Tag is always present } @@ -1937,87 +1934,6 @@ bool8 ScrFunc_followerfly(struct ScriptContext *ctx) { return FALSE; } -// Sprite callback for light sprites -void UpdateLightSprite(struct Sprite *sprite) { - s16 left = gSaveBlock1Ptr->pos.x - 2; - s16 right = gSaveBlock1Ptr->pos.x + 17; - s16 top = gSaveBlock1Ptr->pos.y; - s16 bottom = gSaveBlock1Ptr->pos.y + 15; - s16 x = sprite->data[6]; - s16 y = sprite->data[7]; - u16 sheetTileStart; - u32 paletteNum; - bool8 finished = TRUE; - // Ripped from RemoveObjectEventIfOutsideView - if (x >= left && x <= right - && y >= top && y <= bottom) - finished = FALSE; - finished = finished ? finished : gTimeOfDay != TIME_OF_DAY_NIGHT; - if (finished) { - sheetTileStart = sprite->sheetTileStart; - paletteNum = sprite->oam.paletteNum; - DestroySprite(sprite); - FieldEffectFreeTilesIfUnused(sheetTileStart); - FieldEffectFreePaletteIfUnused(paletteNum); - return; - } - - if (gPlayerAvatar.tileTransitionState) { // As long as the second coefficient stays 12, shadows will not change - Weather_SetBlendCoeffs(7, 12); - sprite->invisible = FALSE; - } else { - Weather_SetBlendCoeffs(12, 12); - sprite->invisible = gSaveBlock2Ptr->playTimeVBlanks & 1; - } -} - -// Spawn a light at a map coordinate based on metatile behavior -static void SpawnLightSprite(s16 x, s16 y, s16 camX, s16 camY, u32 behavior) { - struct Sprite *sprite; - u8 i; - for (i = 0; i < MAX_SPRITES; i++) { - sprite = &gSprites[i]; - if (sprite->inUse && sprite->callback == UpdateLightSprite && sprite->data[6] == x && sprite->data[7] == y) - return; - } - sprite = &gSprites[CreateSprite(&gFieldEffectObjectTemplate_BallLight, 0, 0, 0)]; - UpdateSpritePaletteByTemplate(&gFieldEffectObjectTemplate_BallLight, sprite); - GetMapCoordsFromSpritePos(x + camX, y + camY, &sprite->x, &sprite->y); - sprite->data[6] = x; - sprite->data[7] = y; - sprite->affineAnims = gDummySpriteAffineAnimTable; - sprite->affineAnimBeginning = TRUE; - sprite->centerToCornerVecX = -(32 >> 1); - sprite->centerToCornerVecY = -(32 >> 1); - sprite->oam.priority = 1; - sprite->oam.objMode = 1; // BLEND - sprite->oam.affineMode = ST_OAM_AFFINE_NORMAL; - sprite->coordOffsetEnabled = TRUE; - sprite->x += 8; - sprite->y += 22 + sprite->centerToCornerVecY; -} - -void TrySpawnLightSprites(s16 camX, s16 camY) { - s16 left = gSaveBlock1Ptr->pos.x - 2; - s16 right = gSaveBlock1Ptr->pos.x + 17; - s16 top = gSaveBlock1Ptr->pos.y; - s16 bottom = gSaveBlock1Ptr->pos.y + 16; - u8 i = 0; - s16 x, y; - u32 behavior; - if (gTimeOfDay != TIME_OF_DAY_NIGHT) - return; - for (i = 0; gLightMetatiles[i].x > 0; i++) { - x = gLightMetatiles[i].x; - y = gLightMetatiles[i].y; - if (x >= left && x <= right && y >= top && y <= bottom) { - behavior = MapGridGetMetatileBehaviorAt(x, y); - if (behavior == 0x04) // TODO: Use an actual constant for light metatiles - SpawnLightSprite(x, y, camX, camY, behavior); - } - } -} - void TrySpawnObjectEvents(s16 cameraX, s16 cameraY) { u8 i; @@ -2048,7 +1964,6 @@ void TrySpawnObjectEvents(s16 cameraX, s16 cameraY) TrySpawnObjectEventTemplate(template, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, cameraX, cameraY); } } - TrySpawnLightSprites(cameraX, cameraY); } void RemoveObjectEventsOutsideView(void) @@ -2102,7 +2017,6 @@ void SpawnObjectEventsOnReturnToField(s16 x, s16 y) SpawnObjectEventOnReturnToField(i, x, y); } CreateReflectionEffectSprites(); - TrySpawnLightSprites(x, y); } static void SpawnObjectEventOnReturnToField(u8 objectEventId, s16 x, s16 y) @@ -2166,7 +2080,7 @@ static void ResetObjectEventFldEffData(struct ObjectEvent *objectEvent) { objectEvent->singleMovementActive = FALSE; objectEvent->triggerGroundEffectsOnMove = TRUE; - objectEvent->noShadow = FALSE; + objectEvent->hasShadow = FALSE; objectEvent->hasReflection = FALSE; objectEvent->inShortGrass = FALSE; objectEvent->inShallowFlowingWater = FALSE; @@ -2191,7 +2105,6 @@ static u8 UpdateSpritePalette(const struct SpritePalette * spritePalette, struct sprite->inUse = TRUE; if (IndexOfSpritePaletteTag(spritePalette->tag) == 0xFF) { sprite->oam.paletteNum = LoadSpritePalette(spritePalette); - UpdateSpritePaletteWithTime(sprite->oam.paletteNum); } else { sprite->oam.paletteNum = LoadSpritePalette(spritePalette); } @@ -2437,7 +2350,6 @@ static u8 LoadSpritePaletteIfTagExists(const struct SpritePalette *spritePalette if (IndexOfSpritePaletteTag(spritePalette->tag) != 0xFF) return 0xFF; paletteNum = LoadSpritePalette(spritePalette); - UpdateSpritePaletteWithTime(paletteNum); return paletteNum; } @@ -6154,7 +6066,7 @@ bool8 MovementAction_Jump2Down_Step1(struct ObjectEvent *objectEvent, struct Spr { if (DoJumpAnim(objectEvent, sprite)) { - objectEvent->noShadow = FALSE; + objectEvent->hasShadow = FALSE; sprite->sActionFuncId = 2; return TRUE; } @@ -6171,7 +6083,7 @@ bool8 MovementAction_Jump2Up_Step1(struct ObjectEvent *objectEvent, struct Sprit { if (DoJumpAnim(objectEvent, sprite)) { - objectEvent->noShadow = FALSE; + objectEvent->hasShadow = FALSE; sprite->sActionFuncId = 2; return TRUE; } @@ -6188,7 +6100,7 @@ bool8 MovementAction_Jump2Left_Step1(struct ObjectEvent *objectEvent, struct Spr { if (DoJumpAnim(objectEvent, sprite)) { - objectEvent->noShadow = FALSE; + objectEvent->hasShadow = FALSE; sprite->sActionFuncId = 2; return TRUE; } @@ -6205,7 +6117,7 @@ bool8 MovementAction_Jump2Right_Step1(struct ObjectEvent *objectEvent, struct Sp { if (DoJumpAnim(objectEvent, sprite)) { - objectEvent->noShadow = FALSE; + objectEvent->hasShadow = FALSE; sprite->sActionFuncId = 2; return TRUE; } @@ -6976,7 +6888,7 @@ bool8 MovementAction_JumpDown_Step1(struct ObjectEvent *objectEvent, struct Spri { if (DoJumpAnim(objectEvent, sprite)) { - objectEvent->noShadow = 0; + objectEvent->hasShadow = 0; sprite->sActionFuncId = 2; return TRUE; } @@ -6993,7 +6905,7 @@ bool8 MovementAction_JumpUp_Step1(struct ObjectEvent *objectEvent, struct Sprite { if (DoJumpAnim(objectEvent, sprite)) { - objectEvent->noShadow = 0; + objectEvent->hasShadow = 0; sprite->sActionFuncId = 2; return TRUE; } @@ -7010,7 +6922,7 @@ bool8 MovementAction_JumpLeft_Step1(struct ObjectEvent *objectEvent, struct Spri { if (DoJumpAnim(objectEvent, sprite)) { - objectEvent->noShadow = 0; + objectEvent->hasShadow = 0; sprite->sActionFuncId = 2; return TRUE; } @@ -7027,7 +6939,7 @@ bool8 MovementAction_JumpRight_Step1(struct ObjectEvent *objectEvent, struct Spr { if (DoJumpAnim(objectEvent, sprite)) { - objectEvent->noShadow = 0; + objectEvent->hasShadow = 0; sprite->sActionFuncId = 2; return TRUE; } @@ -7044,7 +6956,7 @@ bool8 MovementAction_JumpInPlaceDown_Step1(struct ObjectEvent *objectEvent, stru { if (DoJumpAnim(objectEvent, sprite)) { - objectEvent->noShadow = 0; + objectEvent->hasShadow = 0; sprite->sActionFuncId = 2; return TRUE; } @@ -7061,7 +6973,7 @@ bool8 MovementAction_JumpInPlaceUp_Step1(struct ObjectEvent *objectEvent, struct { if (DoJumpAnim(objectEvent, sprite)) { - objectEvent->noShadow = 0; + objectEvent->hasShadow = 0; sprite->sActionFuncId = 2; return TRUE; } @@ -7078,7 +6990,7 @@ bool8 MovementAction_JumpInPlaceLeft_Step1(struct ObjectEvent *objectEvent, stru { if (DoJumpAnim(objectEvent, sprite)) { - objectEvent->noShadow = 0; + objectEvent->hasShadow = 0; sprite->sActionFuncId = 2; return TRUE; } @@ -7095,7 +7007,7 @@ bool8 MovementAction_JumpInPlaceRight_Step1(struct ObjectEvent *objectEvent, str { if (DoJumpAnim(objectEvent, sprite)) { - objectEvent->noShadow = 0; + objectEvent->hasShadow = 0; sprite->sActionFuncId = 2; return TRUE; } @@ -7112,7 +7024,7 @@ bool8 MovementAction_JumpInPlaceDownUp_Step1(struct ObjectEvent *objectEvent, st { if (DoJumpInPlaceAnim(objectEvent, sprite)) { - objectEvent->noShadow = 0; + objectEvent->hasShadow = 0; sprite->sActionFuncId = 2; return TRUE; } @@ -7129,7 +7041,7 @@ bool8 MovementAction_JumpInPlaceUpDown_Step1(struct ObjectEvent *objectEvent, st { if (DoJumpInPlaceAnim(objectEvent, sprite)) { - objectEvent->noShadow = 0; + objectEvent->hasShadow = 0; sprite->sActionFuncId = 2; return TRUE; } @@ -7146,7 +7058,7 @@ bool8 MovementAction_JumpInPlaceLeftRight_Step1(struct ObjectEvent *objectEvent, { if (DoJumpInPlaceAnim(objectEvent, sprite)) { - objectEvent->noShadow = 0; + objectEvent->hasShadow = 0; sprite->sActionFuncId = 2; return TRUE; } @@ -7163,7 +7075,7 @@ bool8 MovementAction_JumpInPlaceRightLeft_Step1(struct ObjectEvent *objectEvent, { if (DoJumpInPlaceAnim(objectEvent, sprite)) { - objectEvent->noShadow = 0; + objectEvent->hasShadow = 0; sprite->sActionFuncId = 2; return TRUE; } @@ -7608,7 +7520,7 @@ bool8 MovementAction_AcroWheelieHopFaceDown_Step1(struct ObjectEvent *objectEven { if (DoJumpAnim(objectEvent, sprite)) { - objectEvent->noShadow = FALSE; + objectEvent->hasShadow = FALSE; sprite->sActionFuncId = 2; return TRUE; } @@ -7625,7 +7537,7 @@ bool8 MovementAction_AcroWheelieHopFaceUp_Step1(struct ObjectEvent *objectEvent, { if (DoJumpAnim(objectEvent, sprite)) { - objectEvent->noShadow = FALSE; + objectEvent->hasShadow = FALSE; sprite->sActionFuncId = 2; return TRUE; } @@ -7642,7 +7554,7 @@ bool8 MovementAction_AcroWheelieHopFaceLeft_Step1(struct ObjectEvent *objectEven { if (DoJumpAnim(objectEvent, sprite)) { - objectEvent->noShadow = FALSE; + objectEvent->hasShadow = FALSE; sprite->sActionFuncId = 2; return TRUE; } @@ -7659,7 +7571,7 @@ bool8 MovementAction_AcroWheelieHopFaceRight_Step1(struct ObjectEvent *objectEve { if (DoJumpAnim(objectEvent, sprite)) { - objectEvent->noShadow = FALSE; + objectEvent->hasShadow = FALSE; sprite->sActionFuncId = 2; return TRUE; } @@ -7676,7 +7588,7 @@ bool8 MovementAction_AcroWheelieHopDown_Step1(struct ObjectEvent *objectEvent, s { if (DoJumpAnim(objectEvent, sprite)) { - objectEvent->noShadow = FALSE; + objectEvent->hasShadow = FALSE; sprite->sActionFuncId = 2; return TRUE; } @@ -7693,7 +7605,7 @@ bool8 MovementAction_AcroWheelieHopUp_Step1(struct ObjectEvent *objectEvent, str { if (DoJumpAnim(objectEvent, sprite)) { - objectEvent->noShadow = FALSE; + objectEvent->hasShadow = FALSE; sprite->sActionFuncId = 2; return TRUE; } @@ -7710,7 +7622,7 @@ bool8 MovementAction_AcroWheelieHopLeft_Step1(struct ObjectEvent *objectEvent, s { if (DoJumpAnim(objectEvent, sprite)) { - objectEvent->noShadow = FALSE; + objectEvent->hasShadow = FALSE; sprite->sActionFuncId = 2; return TRUE; } @@ -7727,7 +7639,7 @@ bool8 MovementAction_AcroWheelieHopRight_Step1(struct ObjectEvent *objectEvent, { if (DoJumpAnim(objectEvent, sprite)) { - objectEvent->noShadow = FALSE; + objectEvent->hasShadow = FALSE; sprite->sActionFuncId = 2; return TRUE; } @@ -7744,7 +7656,7 @@ bool8 MovementAction_AcroWheelieJumpDown_Step1(struct ObjectEvent *objectEvent, { if (DoJumpAnim(objectEvent, sprite)) { - objectEvent->noShadow = FALSE; + objectEvent->hasShadow = FALSE; sprite->sActionFuncId = 2; return TRUE; } @@ -7761,7 +7673,7 @@ bool8 MovementAction_AcroWheelieJumpUp_Step1(struct ObjectEvent *objectEvent, st { if (DoJumpAnim(objectEvent, sprite)) { - objectEvent->noShadow = FALSE; + objectEvent->hasShadow = FALSE; sprite->sActionFuncId = 2; return TRUE; } @@ -7778,7 +7690,7 @@ bool8 MovementAction_AcroWheelieJumpLeft_Step1(struct ObjectEvent *objectEvent, { if (DoJumpAnim(objectEvent, sprite)) { - objectEvent->noShadow = FALSE; + objectEvent->hasShadow = FALSE; sprite->sActionFuncId = 2; return TRUE; } @@ -7795,7 +7707,7 @@ bool8 MovementAction_AcroWheelieJumpRight_Step1(struct ObjectEvent *objectEvent, { if (DoJumpAnim(objectEvent, sprite)) { - objectEvent->noShadow = FALSE; + objectEvent->hasShadow = FALSE; sprite->sActionFuncId = 2; return TRUE; } @@ -8806,7 +8718,6 @@ static void DoFlaggedGroundEffects(struct ObjectEvent *objEvent, struct Sprite * for (i = 0; i < ARRAY_COUNT(sGroundEffectFuncs); i++, flags >>= 1) if (flags & 1) sGroundEffectFuncs[i](objEvent, sprite); - GroundEffect_Shadow(objEvent, sprite); } void filters_out_some_ground_effects(struct ObjectEvent *objEvent, u32 *flags) @@ -9512,9 +9423,9 @@ u32 StartFieldEffectForObjectEvent(u8 fieldEffectId, struct ObjectEvent *objectE static void DoShadowFieldEffect(struct ObjectEvent *objectEvent) { - if (objectEvent->noShadow) + if (!objectEvent->hasShadow) { - objectEvent->noShadow = FALSE; + objectEvent->hasShadow = 1; StartFieldEffectForObjectEvent(FLDEFF_SHADOW, objectEvent); } } diff --git a/src/field_effect.c b/src/field_effect.c index 5172ea8c80..35902b455a 100644 --- a/src/field_effect.c +++ b/src/field_effect.c @@ -771,7 +771,6 @@ void FieldEffectScript_LoadFadedPalette(u8 **script) struct SpritePalette *palette = (struct SpritePalette *)FieldEffectScript_ReadWord(script); LoadSpritePalette(palette); UpdateSpritePaletteWithWeather(IndexOfSpritePaletteTag(palette->tag)); - UpdateSpritePaletteWithTime(IndexOfSpritePaletteTag(palette->tag)); // Ensure field effects are blended (*script) += 4; } @@ -3271,7 +3270,7 @@ static void FlyOutFieldEffect_FlyOffWithBird(struct Task *task) struct ObjectEvent *objectEvent = &gObjectEvents[gPlayerAvatar.objectEventId]; ObjectEventClearHeldMovementIfActive(objectEvent); objectEvent->inanimate = FALSE; - objectEvent->noShadow = TRUE; // TODO: Make shadow smaller instead of disappearing completely ? + objectEvent->hasShadow = FALSE; SetFlyBirdPlayerSpriteId(task->tBirdSpriteId, objectEvent->spriteId); CameraObjectReset2(); task->tState++; @@ -3491,7 +3490,6 @@ static void FlyInFieldEffect_BirdSwoopDown(struct Task *task) ObjectEventTurn(objectEvent, DIR_WEST); StartSpriteAnim(&gSprites[objectEvent->spriteId], ANIM_GET_ON_OFF_POKEMON_WEST); objectEvent->invisible = FALSE; - objectEvent->noShadow = TRUE; task->tBirdSpriteId = CreateFlyBirdSprite(); StartFlyBirdSwoopDown(task->tBirdSpriteId); SetFlyBirdPlayerSpriteId(task->tBirdSpriteId, objectEvent->spriteId); diff --git a/src/field_effect_helpers.c b/src/field_effect_helpers.c index cf8ba8c477..977893279c 100755 --- a/src/field_effect_helpers.c +++ b/src/field_effect_helpers.c @@ -157,7 +157,6 @@ static void LoadObjectRegularReflectionPalette(struct ObjectEvent *objectEvent, } paletteNum = LoadSpritePalette(&filteredPalette); UpdateSpritePaletteWithWeather(paletteNum); - UpdateSpritePaletteWithTime(paletteNum); } sprite->oam.paletteNum = paletteNum; sprite->oam.objMode = 1; // Alpha blending @@ -210,7 +209,6 @@ static void UpdateObjectReflectionSprite(struct Sprite *reflectionSprite) } paletteNum = LoadSpritePalette(&filteredPalette); UpdateSpritePaletteWithWeather(paletteNum); - UpdateSpritePaletteWithTime(paletteNum); } reflectionSprite->oam.paletteNum = paletteNum; } @@ -355,7 +353,6 @@ void UpdateShadowFieldEffect(struct Sprite *sprite) sprite->y = linkedSprite->y + sprite->data[3]; sprite->invisible = linkedSprite->invisible; if (!objectEvent->active - || objectEvent->noShadow || MetatileBehavior_IsPokeGrass(objectEvent->currentMetatileBehavior) || MetatileBehavior_IsSurfableWaterOrUnderwater(objectEvent->currentMetatileBehavior) || MetatileBehavior_IsSurfableWaterOrUnderwater(objectEvent->previousMetatileBehavior)) diff --git a/src/field_weather.c b/src/field_weather.c index 2006f9f761..698b079ec2 100644 --- a/src/field_weather.c +++ b/src/field_weather.c @@ -862,7 +862,6 @@ void LoadCustomWeatherSpritePalette(const u16 *palette) { LoadPalette(palette, 0x100 + gWeatherPtr->weatherPicSpritePalIndex * 16, 32); UpdateSpritePaletteWithWeather(gWeatherPtr->weatherPicSpritePalIndex); - UpdateSpritePaletteWithTime(gWeatherPtr->weatherPicSpritePalIndex); } static void LoadDroughtWeatherPalette(u8 *gammaIndexPtr, u8 *a1) diff --git a/src/field_weather_effect.c b/src/field_weather_effect.c index 58e5d8c3d3..c9231c71fc 100644 --- a/src/field_weather_effect.c +++ b/src/field_weather_effect.c @@ -479,7 +479,7 @@ void Rain_InitVars(void) gWeatherPtr->rainSpriteVisibleDelay = 8; gWeatherPtr->isDownpour = FALSE; gWeatherPtr->targetRainSpriteCount = 10; - gWeatherPtr->gammaTargetIndex = gTimeOfDay == TIME_OF_DAY_DAY ? 3 : 0; + gWeatherPtr->gammaTargetIndex = 3; gWeatherPtr->gammaStepDelay = 20; SetRainStrengthFromSoundEffect(SE_RAIN); } @@ -1045,7 +1045,7 @@ void Thunderstorm_InitVars(void) gWeatherPtr->rainSpriteVisibleDelay = 4; gWeatherPtr->isDownpour = FALSE; gWeatherPtr->targetRainSpriteCount = 16; - gWeatherPtr->gammaTargetIndex = gTimeOfDay == TIME_OF_DAY_DAY ? 3 : 0; + gWeatherPtr->gammaTargetIndex = 3; gWeatherPtr->gammaStepDelay = 20; gWeatherPtr->weatherGfxLoaded = FALSE; // duplicate assignment gWeatherPtr->thunderTriggered = FALSE; @@ -1142,8 +1142,6 @@ void Thunderstorm_Main(void) if (--gWeatherPtr->thunderDelay == 0) { ApplyWeatherGammaShiftIfIdle(3); - if (gTimeOfDay != TIME_OF_DAY_DAY) - BlendPalettesWithTime(0xFFFFFFFF); gWeatherPtr->thunderAllowEnd = TRUE; if (--gWeatherPtr->thunderShortRetries != 0) { @@ -1184,7 +1182,7 @@ void Thunderstorm_Main(void) case TSTORM_STATE_FADE_THUNDER_LONG: if (--gWeatherPtr->thunderDelay == 0) { - gTimeOfDay == TIME_OF_DAY_DAY ? ApplyWeatherGammaShiftIfIdle_Gradual(19, 3, 5) : BlendPalettesWithTime(0xFFFFFFFF); + ApplyWeatherGammaShiftIfIdle_Gradual(19, 3, 5); gWeatherPtr->initStep++; } break; diff --git a/src/overworld.c b/src/overworld.c index 913a9645d5..697fd444d5 100644 --- a/src/overworld.c +++ b/src/overworld.c @@ -184,7 +184,6 @@ static u16 (*sPlayerKeyInterceptCallback)(u32); static bool8 sReceivingFromLink; static u8 sRfuKeepAliveTimer; -u8 static gTimeOfDayState; // IWRAM common u16 *gBGTilemapBuffers1; @@ -196,7 +195,6 @@ bool8 (*gFieldCallback2)(void); u8 gLocalLinkPlayerId; // This is our player id in a multiplayer mode. u8 gFieldLinkPlayerCount; -u8 gTimeOfDay; // EWRAM vars EWRAM_DATA static u8 sObjectEventLoadFlag = 0; @@ -847,7 +845,6 @@ void LoadMapFromCameraTransition(u8 mapGroup, u8 mapNum) RoamerMove(); DoCurrentWeather(); ResetFieldTasksArgs(); - BlendPalettesWithTime(0xFFFFFFFF); RunOnResumeMapScript(); if (gMapHeader.regionMapSectionId != MAPSEC_BATTLE_FRONTIER @@ -1483,59 +1480,6 @@ void CB1_Overworld(void) DoCB1_Overworld(gMain.newKeys, gMain.heldKeys); } -struct TimeOfDayBlend { - u8 coeff:4; - u16 blendColor; -}; - -static const struct TimeOfDayBlend sTimeOfDayBlendVars[] = -{ - [TIME_OF_DAY_NIGHT] = {.coeff = 10, .blendColor = 0x1400}, - [TIME_OF_DAY_TWILIGHT] = {.coeff = 4, .blendColor = 0x155D}, - [TIME_OF_DAY_DAY] = {.coeff = 0, .blendColor = 0}, -}; - -u8 UpdateTimeOfDay(void) { - RtcCalcLocalTime(); - if (gLocalTime.hours >= 20 || gLocalTime.hours < 4) - return gTimeOfDay = TIME_OF_DAY_NIGHT; - else if (gLocalTime.hours >= 10 && gLocalTime.hours < 20) - return gTimeOfDay = TIME_OF_DAY_DAY; - return gTimeOfDay = TIME_OF_DAY_TWILIGHT; -} - -static bool8 MapHasNaturalLight(u8 mapType) { // Weather a map type is naturally lit/outside - return mapType == MAP_TYPE_TOWN || mapType == MAP_TYPE_CITY || mapType == MAP_TYPE_ROUTE; -} - -static bool8 FadePalettesWithTime(void) { - gTimeOfDayState = 0; - gTimeOfDay = UpdateTimeOfDay(); - if (MapHasNaturalLight(gMapHeader.mapType)) { - ResetPaletteFade(); - BeginTimeOfDayPaletteFade(0xFFFFFFFF, 0, 16, sTimeOfDayBlendVars[gTimeOfDay].coeff, sTimeOfDayBlendVars[gTimeOfDay].blendColor); - } -} - -void BlendPalettesWithTime(u32 palettes) { - // Only blend if not transitioning between times and the map type allows - if (gTimeOfDayState == 0 && MapHasNaturalLight(gMapHeader.mapType)) { - u8 i; - for (i = 0; i < 16; i++) { - if (GetSpritePaletteTagByPaletteNum(i) & 0x8000) // Don't blend special sprite palette tags - palettes &= ~(1 << (i + 16)); - } - palettes &= ~0xE000; // Don't blend tile palettes [13,15] - gTimeOfDay = gTimeOfDay > TIME_OF_DAY_MAX ? TIME_OF_DAY_MAX : gTimeOfDay; - BlendPalettes(palettes, sTimeOfDayBlendVars[gTimeOfDay].coeff, sTimeOfDayBlendVars[gTimeOfDay].blendColor); - } -} - -u8 UpdateSpritePaletteWithTime(u8 paletteNum) { - BlendPalettesWithTime(1 << (paletteNum + 16)); - return paletteNum; -} - static void OverworldBasic(void) { ScriptContext2_RunScript(); @@ -1559,7 +1503,6 @@ void CB2_Overworld(void) { u32 *debugPtr = (u32*) 0x0203de00; bool32 fading = (gPaletteFade.active != 0); - *debugPtr = (u32) &gTimeOfDay; if (fading) SetVBlankCallback(NULL); OverworldBasic(); @@ -1662,7 +1605,6 @@ static void CB2_LoadMap2(void) DoMapLoadLoop(&gMain.state); SetFieldVBlankCallback(); SetMainCallback1(CB1_Overworld); - FadePalettesWithTime(); SetMainCallback2(CB2_Overworld); } @@ -1719,7 +1661,6 @@ static void CB2_ReturnToFieldLocal(void) if (ReturnToFieldLocal(&gMain.state)) { SetFieldVBlankCallback(); - FadePalettesWithTime(); SetMainCallback2(CB2_Overworld); } } diff --git a/src/palette.c b/src/palette.c index d9da876256..58c05e1877 100644 --- a/src/palette.c +++ b/src/palette.c @@ -205,53 +205,6 @@ bool8 BeginNormalPaletteFade(u32 selectedPalettes, s8 delay, u8 startY, u8 targe } } -// Like normal palette fade but respects sprite/tile palettes immune to time of day fading -bool8 BeginTimeOfDayPaletteFade(u32 selectedPalettes, s8 delay, u8 startY, u8 targetY, u16 blendColor) -{ - u8 temp; - u16 color = blendColor; - - if (gPaletteFade.active) - { - return FALSE; - } - else - { - gPaletteFade.deltaY = 2; - - if (delay < 0) - { - gPaletteFade.deltaY += (delay * -1); - delay = 0; - } - - gPaletteFade_selectedPalettes = selectedPalettes; - gPaletteFade.delayCounter = delay; - gPaletteFade_delay = delay; - gPaletteFade.y = startY; - gPaletteFade.targetY = targetY; - gPaletteFade.blendColor = color; - gPaletteFade.active = 1; - gPaletteFade.mode = TIME_OF_DAY_FADE; - - if (startY < targetY) - gPaletteFade.yDec = 0; - else - gPaletteFade.yDec = 1; - - UpdatePaletteFade(); - - temp = gPaletteFade.bufferTransferDisabled; - gPaletteFade.bufferTransferDisabled = 0; - CpuCopy32(gPlttBufferFaded, (void *)PLTT, PLTT_SIZE); - sPlttBufferTransferPending = 0; - if (gPaletteFade.mode == HARDWARE_FADE && gPaletteFade.active) - UpdateBlendRegisters(); - gPaletteFade.bufferTransferDisabled = temp; - return TRUE; - } -} - // Unused static bool8 BeginPlttFade(u32 selectedPalettes, u8 delay, u8 startY, u8 targetY, u16 blendColor) {