Cleanup pt4

- Removed TIME_OF_DAY_FADE and UpdateTimeOfDayPaletteFade
- Renamed FieldCallback_Fly back to FieldCallback_UseFly
This commit is contained in:
Eduardo Quezada 2023-06-18 01:45:04 -04:00
parent 634bb19560
commit c391c66249
6 changed files with 17 additions and 115 deletions

View file

@ -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);

View file

@ -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);
@ -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;
}

View file

@ -2584,3 +2584,5 @@ static const struct SpritePalette sSpritePalettes[] =
{gNamingScreenMenu_Pal[4], PALTAG_OK_BUTTON},
{}
};

View file

@ -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,7 +1998,7 @@ static bool32 ReturnToFieldLocal(u8 *state)
ResetScreenForMapLoad();
ResumeMap(FALSE);
InitObjectEventsReturnToField();
if (gFieldCallback == FieldCallback_Fly)
if (gFieldCallback == FieldCallback_UseFly)
RemoveFollowingPokemon();
else
UpdateFollowingPokemon();
@ -2020,6 +2017,7 @@ static bool32 ReturnToFieldLocal(u8 *state)
case 3:
return TRUE;
}
return FALSE;
}

View file

@ -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;

View file

@ -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];