Added alpha-blending shadows.
This commit is contained in:
parent
85995c8a92
commit
12e3b4efad
4 changed files with 27 additions and 8 deletions
|
@ -15,6 +15,7 @@ bool8 sub_8155DA0(struct ObjectEvent *);
|
|||
void sub_8155D78(struct ObjectEvent *);
|
||||
void StartAshFieldEffect(s16, s16, u16, s16);
|
||||
void SetUpReflection(struct ObjectEvent*, struct Sprite*, u8);
|
||||
void SetUpShadow(struct ObjectEvent*, struct Sprite*);
|
||||
u32 StartFieldEffectForObjectEvent(u8, struct ObjectEvent*);
|
||||
u8 FindTallGrassFieldEffectSpriteId(u8 localId, u8 mapNum, u8 mapGroup, s16 x, s16 y);
|
||||
void UpdateRayquazaSpotlightEffect(struct Sprite*);
|
||||
|
|
|
@ -8650,6 +8650,10 @@ static void (*const sGroundEffectFuncs[])(struct ObjectEvent *objEvent, struct S
|
|||
GroundEffect_Seaweed // GROUND_EFFECT_FLAG_SEAWEED
|
||||
};
|
||||
|
||||
static void GroundEffect_Shadow(struct ObjectEvent *objEvent, struct Sprite *sprite) {
|
||||
SetUpShadow(objEvent, sprite);
|
||||
}
|
||||
|
||||
static void DoFlaggedGroundEffects(struct ObjectEvent *objEvent, struct Sprite *sprite, u32 flags)
|
||||
{
|
||||
u8 i;
|
||||
|
@ -8660,6 +8664,7 @@ 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)
|
||||
|
|
|
@ -34,12 +34,20 @@ static void sub_81556E8(struct ObjectEvent *, struct Sprite *);
|
|||
static void CreateBobbingEffect(struct ObjectEvent *, struct Sprite *, struct Sprite *);
|
||||
static void sub_8155850(struct Sprite *);
|
||||
static u32 ShowDisguiseFieldEffect(u8, u8, u8);
|
||||
u32 FldEff_Shadow(void);
|
||||
|
||||
#define sReflectionObjEventId data[0]
|
||||
#define sReflectionObjEventLocalId data[1]
|
||||
#define sReflectionVerticalOffset data[2]
|
||||
#define sIsStillReflection data[7]
|
||||
|
||||
void SetUpShadow(struct ObjectEvent *objectEvent, struct Sprite *sprite) {
|
||||
gFieldEffectArguments[0] = objectEvent->localId;
|
||||
gFieldEffectArguments[1] = gSaveBlock1Ptr->location.mapNum;
|
||||
gFieldEffectArguments[2] = gSaveBlock1Ptr->location.mapGroup;
|
||||
FldEff_Shadow();
|
||||
}
|
||||
|
||||
void SetUpReflection(struct ObjectEvent *objectEvent, struct Sprite *sprite, bool8 stillReflection)
|
||||
{
|
||||
struct Sprite *reflectionSprite;
|
||||
|
@ -141,7 +149,7 @@ static void LoadObjectRegularReflectionPalette(struct ObjectEvent *objectEvent,
|
|||
}
|
||||
sprite->oam.paletteNum = paletteNum;
|
||||
// Apply alpha blending
|
||||
SetGpuReg(REG_OFFSET_BLDALPHA, sprite->data[7] == FALSE ? BLDALPHA_BLEND(8, 12) : BLDALPHA_BLEND(8, 8));
|
||||
// SetGpuReg(REG_OFFSET_BLDALPHA, sprite->data[7] == FALSE ? BLDALPHA_BLEND(8, 12) : BLDALPHA_BLEND(8, 8));
|
||||
sprite->oam.objMode = 1; // BLEND
|
||||
}
|
||||
|
||||
|
@ -293,12 +301,19 @@ u32 FldEff_Shadow(void)
|
|||
u8 objectEventId;
|
||||
const struct ObjectEventGraphicsInfo *graphicsInfo;
|
||||
u8 spriteId;
|
||||
|
||||
u8 i;
|
||||
for (i = 0; i < MAX_SPRITES; i++) {
|
||||
// Return early if a shadow sprite already exists
|
||||
if (gSprites[i].data[0] == gFieldEffectArguments[0] && gSprites[i].callback == UpdateShadowFieldEffect)
|
||||
return 0;
|
||||
}
|
||||
objectEventId = GetObjectEventIdByLocalIdAndMap(gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2]);
|
||||
graphicsInfo = GetObjectEventGraphicsInfo(gObjectEvents[objectEventId].graphicsId);
|
||||
spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[sShadowEffectTemplateIds[graphicsInfo->shadowSize]], 0, 0, 0x94);
|
||||
if (spriteId != MAX_SPRITES)
|
||||
{
|
||||
// SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(8, 12));
|
||||
gSprites[spriteId].oam.objMode = 1; // BLEND
|
||||
gSprites[spriteId].coordOffsetEnabled = TRUE;
|
||||
gSprites[spriteId].data[0] = gFieldEffectArguments[0];
|
||||
gSprites[spriteId].data[1] = gFieldEffectArguments[1];
|
||||
|
@ -325,12 +340,11 @@ void UpdateShadowFieldEffect(struct Sprite *sprite)
|
|||
sprite->oam.priority = linkedSprite->oam.priority;
|
||||
sprite->pos1.x = linkedSprite->pos1.x;
|
||||
sprite->pos1.y = linkedSprite->pos1.y + sprite->data[3];
|
||||
if (!objectEvent->active || !objectEvent->hasShadow
|
||||
sprite->invisible = linkedSprite->invisible;
|
||||
if (!objectEvent->active
|
||||
|| MetatileBehavior_IsPokeGrass(objectEvent->currentMetatileBehavior)
|
||||
|| MetatileBehavior_IsSurfableWaterOrUnderwater(objectEvent->currentMetatileBehavior)
|
||||
|| MetatileBehavior_IsSurfableWaterOrUnderwater(objectEvent->previousMetatileBehavior)
|
||||
|| MetatileBehavior_IsReflective(objectEvent->currentMetatileBehavior)
|
||||
|| MetatileBehavior_IsReflective(objectEvent->previousMetatileBehavior))
|
||||
|| MetatileBehavior_IsSurfableWaterOrUnderwater(objectEvent->previousMetatileBehavior))
|
||||
{
|
||||
FieldEffectStop(sprite, FLDEFF_SHADOW);
|
||||
}
|
||||
|
|
|
@ -155,6 +155,7 @@ void Sunny_InitVars(void)
|
|||
{
|
||||
gWeatherPtr->gammaTargetIndex = 0;
|
||||
gWeatherPtr->gammaStepDelay = 20;
|
||||
Weather_SetBlendCoeffs(8, 12);
|
||||
}
|
||||
|
||||
void Sunny_InitAll(void)
|
||||
|
@ -2581,5 +2582,3 @@ static void UpdateRainCounter(u8 newWeather, u8 oldWeather)
|
|||
&& (newWeather == WEATHER_RAIN || newWeather == WEATHER_RAIN_THUNDERSTORM))
|
||||
IncrementGameStat(GAME_STAT_GOT_RAINED_ON);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue