Fixed warp arrow palette bug. Optimized weather palette loading.
This commit is contained in:
parent
1834e487b9
commit
bd3c9ed3b9
4 changed files with 18 additions and 11 deletions
|
@ -106,6 +106,7 @@ u8 SpawnSpecialObjectEventParameterized(u8 graphicsId, u8 movementBehavior, u8 l
|
||||||
u8 SpawnSpecialObjectEvent(struct ObjectEventTemplate *);
|
u8 SpawnSpecialObjectEvent(struct ObjectEventTemplate *);
|
||||||
void SetSpritePosToMapCoords(s16, s16, s16 *, s16 *);
|
void SetSpritePosToMapCoords(s16, s16, s16 *, s16 *);
|
||||||
void CameraObjectReset1(void);
|
void CameraObjectReset1(void);
|
||||||
|
u8 LoadObjectEventPalette(u16);
|
||||||
u8 UpdateSpritePaletteByTemplate(const struct SpriteTemplate *, struct Sprite *);
|
u8 UpdateSpritePaletteByTemplate(const struct SpriteTemplate *, struct Sprite *);
|
||||||
void ObjectEventSetGraphicsId(struct ObjectEvent *, u8 graphicsId);
|
void ObjectEventSetGraphicsId(struct ObjectEvent *, u8 graphicsId);
|
||||||
void ObjectEventTurn(struct ObjectEvent *, u8);
|
void ObjectEventTurn(struct ObjectEvent *, u8);
|
||||||
|
|
|
@ -130,7 +130,6 @@ static void UpdateObjectEventVisibility(struct ObjectEvent *, struct Sprite *);
|
||||||
static void MakeObjectTemplateFromObjectEventTemplate(struct ObjectEventTemplate *, struct SpriteTemplate *, const struct SubspriteTable **);
|
static void MakeObjectTemplateFromObjectEventTemplate(struct ObjectEventTemplate *, struct SpriteTemplate *, const struct SubspriteTable **);
|
||||||
static void GetObjectEventMovingCameraOffset(s16 *, s16 *);
|
static void GetObjectEventMovingCameraOffset(s16 *, s16 *);
|
||||||
static struct ObjectEventTemplate *GetObjectEventTemplateByLocalIdAndMap(u8, u8, u8);
|
static struct ObjectEventTemplate *GetObjectEventTemplateByLocalIdAndMap(u8, u8, u8);
|
||||||
static void LoadObjectEventPalette(u16);
|
|
||||||
static void RemoveObjectEventIfOutsideView(struct ObjectEvent *);
|
static void RemoveObjectEventIfOutsideView(struct ObjectEvent *);
|
||||||
static void SpawnObjectEventOnReturnToField(u8, s16, s16);
|
static void SpawnObjectEventOnReturnToField(u8, s16, s16);
|
||||||
static void SetPlayerAvatarObjectEventIdAndObjectId(u8, u8);
|
static void SetPlayerAvatarObjectEventIdAndObjectId(u8, u8);
|
||||||
|
@ -2431,12 +2430,12 @@ void FreeAndReserveObjectSpritePalettes(void)
|
||||||
gReservedSpritePaletteCount = 12;
|
gReservedSpritePaletteCount = 12;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void LoadObjectEventPalette(u16 paletteTag)
|
u8 LoadObjectEventPalette(u16 paletteTag)
|
||||||
{
|
{
|
||||||
u16 i = FindObjectEventPaletteIndexByTag(paletteTag);
|
u16 i = FindObjectEventPaletteIndexByTag(paletteTag);
|
||||||
|
if (i == 0xFF)
|
||||||
if (i != OBJ_EVENT_PAL_TAG_NONE) // always true
|
return i;
|
||||||
LoadSpritePaletteIfTagExists(&sObjectEventSpritePalettes[i]);
|
return LoadSpritePaletteIfTagExists(&sObjectEventSpritePalettes[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unused
|
// Unused
|
||||||
|
@ -2448,13 +2447,15 @@ static void LoadObjectEventPaletteSet(u16 *paletteTags)
|
||||||
LoadObjectEventPalette(paletteTags[i]);
|
LoadObjectEventPalette(paletteTags[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Really just loads the palette and applies weather fade
|
||||||
static u8 LoadSpritePaletteIfTagExists(const struct SpritePalette *spritePalette)
|
static u8 LoadSpritePaletteIfTagExists(const struct SpritePalette *spritePalette)
|
||||||
{
|
{
|
||||||
u8 paletteNum;
|
u8 paletteNum = IndexOfSpritePaletteTag(spritePalette->tag);
|
||||||
if (IndexOfSpritePaletteTag(spritePalette->tag) != 0xFF)
|
if (paletteNum != 0xFF) // don't load twice; return
|
||||||
return 0xFF;
|
return paletteNum;
|
||||||
paletteNum = LoadSpritePalette(spritePalette);
|
paletteNum = LoadSpritePalette(spritePalette);
|
||||||
UpdateSpritePaletteWithWeather(paletteNum, FALSE);
|
if (paletteNum != 0xFF)
|
||||||
|
UpdateSpritePaletteWithWeather(paletteNum, FALSE);
|
||||||
return paletteNum;
|
return paletteNum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -255,6 +255,8 @@ u8 CreateWarpArrowSprite(void)
|
||||||
if (spriteId != MAX_SPRITES)
|
if (spriteId != MAX_SPRITES)
|
||||||
{
|
{
|
||||||
sprite = &gSprites[spriteId];
|
sprite = &gSprites[spriteId];
|
||||||
|
// OBJ_EVENT_PAL_TAG_MAY : OBJ_EVENT_PAL_TAG_BRENDAN
|
||||||
|
sprite->oam.paletteNum = LoadObjectEventPalette(gSaveBlock2Ptr->playerGender ? 0x1110 : 0x1100);
|
||||||
sprite->oam.priority = 1;
|
sprite->oam.priority = 1;
|
||||||
sprite->coordOffsetEnabled = TRUE;
|
sprite->coordOffsetEnabled = TRUE;
|
||||||
sprite->invisible = TRUE;
|
sprite->invisible = TRUE;
|
||||||
|
@ -1421,7 +1423,7 @@ static u32 ShowDisguiseFieldEffect(u8 fldEff, u8 fldEffObj, u8 paletteNum)
|
||||||
if (spriteId != MAX_SPRITES)
|
if (spriteId != MAX_SPRITES)
|
||||||
{
|
{
|
||||||
sprite = &gSprites[spriteId];
|
sprite = &gSprites[spriteId];
|
||||||
UpdateSpritePaletteByTemplate(gFieldEffectObjectTemplatePointers[fldEffObj], sprite);
|
sprite->oam.paletteNum = LoadObjectEventPalette(gFieldEffectObjectTemplatePointers[fldEffObj]->paletteTag);
|
||||||
sprite->coordOffsetEnabled ++;
|
sprite->coordOffsetEnabled ++;
|
||||||
sprite->sFldEff = fldEff;
|
sprite->sFldEff = fldEff;
|
||||||
sprite->sLocalId = gFieldEffectArguments[0];
|
sprite->sLocalId = gFieldEffectArguments[0];
|
||||||
|
|
|
@ -165,7 +165,7 @@ void StartWeather(void)
|
||||||
CpuCopy32(gFogPalette, &gPlttBufferUnfaded[0x100 + index * 16], 32);
|
CpuCopy32(gFogPalette, &gPlttBufferUnfaded[0x100 + index * 16], 32);
|
||||||
BuildGammaShiftTables();
|
BuildGammaShiftTables();
|
||||||
gWeatherPtr->altGammaSpritePalIndex = index;
|
gWeatherPtr->altGammaSpritePalIndex = index;
|
||||||
gWeatherPtr->weatherPicSpritePalIndex = AllocSpritePalette(PALTAG_WEATHER_2);
|
gWeatherPtr->weatherPicSpritePalIndex = 0xFF; // defer allocation until needed
|
||||||
gWeatherPtr->rainSpriteCount = 0;
|
gWeatherPtr->rainSpriteCount = 0;
|
||||||
gWeatherPtr->curRainSpriteIndex = 0;
|
gWeatherPtr->curRainSpriteIndex = 0;
|
||||||
gWeatherPtr->cloudSpritesCreated = 0;
|
gWeatherPtr->cloudSpritesCreated = 0;
|
||||||
|
@ -899,6 +899,9 @@ static bool8 IsFirstFrameOfWeatherFadeIn(void)
|
||||||
|
|
||||||
void LoadCustomWeatherSpritePalette(const u16 *palette)
|
void LoadCustomWeatherSpritePalette(const u16 *palette)
|
||||||
{
|
{
|
||||||
|
if (gWeatherPtr->weatherPicSpritePalIndex > 16) // haven't allocated palette yet
|
||||||
|
if ((gWeatherPtr->weatherPicSpritePalIndex = AllocSpritePalette(PALTAG_WEATHER_2)) > 16)
|
||||||
|
return;
|
||||||
LoadPalette(palette, 0x100 + gWeatherPtr->weatherPicSpritePalIndex * 16, 32);
|
LoadPalette(palette, 0x100 + gWeatherPtr->weatherPicSpritePalIndex * 16, 32);
|
||||||
UpdateSpritePaletteWithWeather(gWeatherPtr->weatherPicSpritePalIndex, TRUE);
|
UpdateSpritePaletteWithWeather(gWeatherPtr->weatherPicSpritePalIndex, TRUE);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue