diff --git a/include/field_effect.h b/include/field_effect.h index 5842b0b4f6..93a74f1ba2 100644 --- a/include/field_effect.h +++ b/include/field_effect.h @@ -13,7 +13,7 @@ u32 FieldEffectStart(u8); bool8 FieldEffectActiveListContains(u8 id); void FieldEffectActiveListClear(void); void ReturnToFieldFromFlyMapSelect(void); -void FieldCallback_Fly(void); +void FieldCallback_UseFly(void); u8 AddNewGameBirchObject(s16, s16, u8); void FieldEffectStop(struct Sprite *sprite, u8 id); u8 CreateTrainerSprite(u8 trainerSpriteID, s16 x, s16 y, u8 subpriority, u8 *buffer); diff --git a/src/field_effect.c b/src/field_effect.c index 51a03a13c3..dd5e35df3c 100644 --- a/src/field_effect.c +++ b/src/field_effect.c @@ -1341,10 +1341,10 @@ static void SpriteCB_HallOfFameMonitor(struct Sprite *sprite) void ReturnToFieldFromFlyMapSelect(void) { SetMainCallback2(CB2_ReturnToField); - gFieldCallback = FieldCallback_Fly; + gFieldCallback = FieldCallback_UseFly; } -void FieldCallback_Fly(void) +void FieldCallback_UseFly(void) { FadeInFromBlack(); CreateTask(Task_UseFly, 0); @@ -3081,7 +3081,7 @@ static void SurfFieldEffect_End(struct Task *task) gPlayerAvatar.flags &= ~PLAYER_AVATAR_FLAG_CONTROLLABLE; ObjectEventSetHeldMovement(objectEvent, GetFaceDirectionMovementAction(objectEvent->movementDirection)); if (followerObject) - ObjectEventClearHeldMovementIfFinished(followerObject); + ObjectEventClearHeldMovementIfFinished(followerObject); SetSurfBlob_BobState(objectEvent->fieldEffectSpriteId, BOB_PLAYER_AND_MON); UnfreezeObjectEvents(); UnlockPlayerFieldControls(); @@ -3137,10 +3137,10 @@ u8 FldEff_NPCFlyOut(void) u8 spriteId = CreateSprite(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_BIRD], 0x78, 0, 1); struct Sprite *sprite = &gSprites[spriteId]; + sprite->oam.paletteNum = LoadObjectEventPalette(gSaveBlock2Ptr->playerGender ? FLDEFF_PAL_TAG_MAY : FLDEFF_PAL_TAG_BRENDAN); sprite->oam.priority = 1; sprite->callback = SpriteCB_NPCFlyOut; sprite->data[1] = gFieldEffectArguments[0]; - sprite->oam.paletteNum = LoadObjectEventPalette(gSaveBlock2Ptr->playerGender ? FLDEFF_PAL_TAG_MAY : FLDEFF_PAL_TAG_BRENDAN); PlaySE(SE_M_FLY); return spriteId; } @@ -3319,9 +3319,9 @@ static u8 CreateFlyBirdSprite(void) struct Sprite *sprite; spriteId = CreateSprite(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_BIRD], 0xff, 0xb4, 0x1); sprite = &gSprites[spriteId]; + sprite->oam.paletteNum = LoadObjectEventPalette(gSaveBlock2Ptr->playerGender ? FLDEFF_PAL_TAG_MAY : FLDEFF_PAL_TAG_BRENDAN); sprite->oam.priority = 1; sprite->callback = SpriteCB_FlyBirdLeaveBall; - sprite->oam.paletteNum = LoadObjectEventPalette(gSaveBlock2Ptr->playerGender ? FLDEFF_PAL_TAG_MAY : FLDEFF_PAL_TAG_BRENDAN); return spriteId; } diff --git a/src/naming_screen.c b/src/naming_screen.c index 945691a7ee..8a910f3d11 100644 --- a/src/naming_screen.c +++ b/src/naming_screen.c @@ -2584,3 +2584,5 @@ static const struct SpritePalette sSpritePalettes[] = {gNamingScreenMenu_Pal[4], PALTAG_OK_BUTTON}, {} }; + + diff --git a/src/overworld.c b/src/overworld.c index 0ac2b4d661..819594ef18 100644 --- a/src/overworld.c +++ b/src/overworld.c @@ -193,8 +193,6 @@ bool8 (*gFieldCallback2)(void); u8 gLocalLinkPlayerId; // This is our player id in a multiplayer mode. u8 gFieldLinkPlayerCount; - -// EWRAM vars EWRAM_DATA static u8 sObjectEventLoadFlag = 0; EWRAM_DATA struct WarpData gLastUsedWarp = {0}; EWRAM_DATA static struct WarpData sWarpDestination = {0}; // new warp position @@ -206,7 +204,6 @@ EWRAM_DATA static u16 sAmbientCrySpecies = 0; EWRAM_DATA static bool8 sIsAmbientCryWaterMon = FALSE; EWRAM_DATA struct LinkPlayerObjectEvent gLinkPlayerObjectEvents[4] = {0}; - static const struct WarpData sDummyWarpData = { .mapGroup = MAP_GROUP(UNDEFINED), @@ -2001,10 +1998,10 @@ static bool32 ReturnToFieldLocal(u8 *state) ResetScreenForMapLoad(); ResumeMap(FALSE); InitObjectEventsReturnToField(); - if (gFieldCallback == FieldCallback_Fly) - RemoveFollowingPokemon(); + if (gFieldCallback == FieldCallback_UseFly) + RemoveFollowingPokemon(); else - UpdateFollowingPokemon(); + UpdateFollowingPokemon(); SetCameraToTrackPlayer(); (*state)++; break; @@ -2020,6 +2017,7 @@ static bool32 ReturnToFieldLocal(u8 *state) case 3: return TRUE; } + return FALSE; } diff --git a/src/palette.c b/src/palette.c index 3dbb27cee8..6ce47a4933 100644 --- a/src/palette.c +++ b/src/palette.c @@ -11,7 +11,6 @@ enum NORMAL_FADE, FAST_FADE, HARDWARE_FADE, - TIME_OF_DAY_FADE, }; // These are structs for some unused palette system. @@ -53,7 +52,6 @@ static u8 UpdateNormalPaletteFade(void); static void BeginFastPaletteFadeInternal(u8); static u8 UpdateFastPaletteFade(void); static u8 UpdateHardwarePaletteFade(void); -static u8 UpdateTimeOfDayPaletteFade(void); static void UpdateBlendRegisters(void); static bool8 IsSoftwarePaletteFadeFinishing(void); static void Task_BlendPalettesGradually(u8 taskId); @@ -127,8 +125,6 @@ u8 UpdatePaletteFade(void) result = UpdateNormalPaletteFade(); else if (gPaletteFade.mode == FAST_FADE) result = UpdateFastPaletteFade(); - else if (gPaletteFade.mode == TIME_OF_DAY_FADE) - result = UpdateTimeOfDayPaletteFade(); else result = UpdateHardwarePaletteFade(); @@ -411,103 +407,6 @@ static u8 PaletteStruct_GetPalNum(u16 id) return NUM_PALETTE_STRUCTS; } -// Like normal palette fade, but respects sprite/tile palettes immune to time of day fading -static u8 UpdateTimeOfDayPaletteFade(void) // Like normal, but respects sprite palettes immune to fading -{ - u8 paletteNum; - u16 paletteOffset; - u16 selectedPalettes; - - if (!gPaletteFade.active) - return PALETTE_FADE_STATUS_DONE; - - if (IsSoftwarePaletteFadeFinishing()) - return gPaletteFade.active ? PALETTE_FADE_STATUS_ACTIVE : PALETTE_FADE_STATUS_DONE; - - if (!gPaletteFade.objPaletteToggle) - { - if (gPaletteFade.delayCounter < gPaletteFade_delay) - { - gPaletteFade.delayCounter++; - return 2; - } - gPaletteFade.delayCounter = 0; - } - - paletteOffset = 0; - - if (!gPaletteFade.objPaletteToggle) - { - selectedPalettes = gPaletteFade_selectedPalettes; - } - else - { - selectedPalettes = gPaletteFade_selectedPalettes >> 16; - paletteOffset = 256; - } - - for (paletteNum = 0; paletteNum < 16; paletteNum++, selectedPalettes >>= 1, paletteOffset += 16) - { - if (selectedPalettes & 1) - { - if (gPaletteFade.yDec) - { - if (gPaletteFade.objPaletteToggle) - { - // sprite palettes - if (gPaletteFade.y >= gPaletteFade.targetY || GetSpritePaletteTagByPaletteNum(paletteNum) & 0x8000) - BlendPalette(paletteOffset, 16, gPaletteFade.y, gPaletteFade.blendColor); - // tile palettes - } - else if (gPaletteFade.y >= gPaletteFade.targetY || (paletteNum >= 13 && paletteNum <= 15)) - { - BlendPalette(paletteOffset, 16, gPaletteFade.y, gPaletteFade.blendColor); - } - } - else - { - BlendPalette(paletteOffset, 16, gPaletteFade.y, gPaletteFade.blendColor); - } - } - } - - gPaletteFade.objPaletteToggle ^= 1; - - if (!gPaletteFade.objPaletteToggle) - { - if ((gPaletteFade.yDec && gPaletteFade.y == 0) || (!gPaletteFade.yDec && gPaletteFade.y == gPaletteFade.targetY)) - { - gPaletteFade_selectedPalettes = 0; - gPaletteFade.softwareFadeFinishing = 1; - } - else - { - s8 val; - - if (!gPaletteFade.yDec) - { - val = gPaletteFade.y; - val += gPaletteFade.deltaY; - if (val > gPaletteFade.targetY) - val = gPaletteFade.targetY; - gPaletteFade.y = val; - } - else - { - val = gPaletteFade.y; - val -= gPaletteFade.deltaY; - if (val < 0) - val = 0; - gPaletteFade.y = val; - } - } - } - - // gPaletteFade.active cannot change since the last time it was checked. So this - // is equivalent to `return PALETTE_FADE_STATUS_ACTIVE;` - return PALETTE_FADE_STATUS_ACTIVE; -} - static u8 UpdateNormalPaletteFade(void) { u16 paletteOffset; @@ -824,6 +723,7 @@ static u8 UpdateFastPaletteFade(void) gPaletteFade.mode = NORMAL_FADE; gPaletteFade.softwareFadeFinishing = TRUE; } + // gPaletteFade.active cannot change since the last time it was checked. So this // is equivalent to `return PALETTE_FADE_STATUS_ACTIVE;` return gPaletteFade.active ? PALETTE_FADE_STATUS_ACTIVE : PALETTE_FADE_STATUS_DONE; diff --git a/src/trainer_see.c b/src/trainer_see.c index 2bcb240134..da1c4c636c 100644 --- a/src/trainer_see.c +++ b/src/trainer_see.c @@ -271,7 +271,8 @@ static const union AnimCmd *const sSpriteAnimTable_Icons[] = sSpriteAnim_Icons2 }; -static const union AnimCmd *const sSpriteAnimTable_Emotes[] = { +static const union AnimCmd *const sSpriteAnimTable_Emotes[] = +{ sSpriteAnim_Emotes0, sSpriteAnim_Emotes1, sSpriteAnim_Emotes2, @@ -601,7 +602,7 @@ static bool8 TrainerExclamationMark(u8 taskId, struct Task *task, struct ObjectE FieldEffectStart(FLDEFF_EXCLAMATION_MARK_ICON); direction = GetFaceDirectionMovementAction(trainerObj->facingDirection); ObjectEventSetHeldMovement(trainerObj, direction); - task->tFuncId++; + task->tFuncId++; // TRSEE_EXCLAMATION_WAIT return TRUE; } @@ -871,6 +872,7 @@ u8 FldEff_QuestionMarkIcon(void) u8 FldEff_HeartIcon(void) { u8 spriteId = CreateSpriteAtEnd(&sSpriteTemplate_HeartIcon, 0, 0, 0x52); + if (spriteId != MAX_SPRITES) { struct Sprite *sprite = &gSprites[spriteId];