Review comments

This commit is contained in:
Hedara 2025-04-11 11:37:36 +02:00
parent d78afca94f
commit 301ef288f5
15 changed files with 89 additions and 134 deletions

View File

@ -22,4 +22,4 @@ on separate lines to mark those colors as being light-blended, i.e:
A: Set `OW_OBJECT_VANILLA_SHADOWS` to `TRUE` in `include/config/overworld.h`.
### Q: How do I disable shadows for certain locations?
A: Shadows can be disabled for certain locations by modifying the `CurrentMapHasShadows` function in `src/overworld.c`
A: Shadows can be disabled for certain locations by modifying the `CurrentMapHasShadows` function in `src/overworld.c`.

View File

@ -1278,26 +1278,3 @@ Gen 4-style shadows are defined by the `SHADOW` macro which takes the following
- `SHADOW_SIZE_XL_BATTLE_ONLY`
To make the Pokémon have no shadow, use the `NO_SHADOW` macro instead of `SHADOW`.
## 6. Limiting species allowed as followers
You may use the following configs in `include/config/overworld.h`
```c
#define OW_FOLLOWERS_ALLOWED_SPECIES (0)
#define OW_FOLLOWERS_ALLOWED_MET_LVL (0)
#define OW_FOLLOWERS_ALLOWED_MET_LOC (0)
```
Examples:
```c
// Yellow Pikachu:
#define OW_FOLLOWERS_ALLOWED_SPECIES (SPECIES_PIKACHU)
#define OW_FOLLOWERS_ALLOWED_MET_LVL (0)
#define OW_FOLLOWERS_ALLOWED_MET_LOC (MAPSEC_PALLET_TOWN)
// Hoenn Starter:
#define OW_FOLLOWERS_ALLOWED_SPECIES (0)
#define OW_FOLLOWERS_ALLOWED_MET_LVL (5)
#define OW_FOLLOWERS_ALLOWED_MET_LOC (MAPSEC_ROUTE_101)
// Species set in VAR_XXXX:
#define OW_FOLLOWERS_ALLOWED_SPECIES (VAR_XXXX)
#define OW_FOLLOWERS_ALLOWED_MET_LVL (0)
#define OW_FOLLOWERS_ALLOWED_MET_LOC (0)
```

View File

@ -96,10 +96,10 @@
// Lighting
#define OW_SHADOW_INTENSITY 4 // Ranges from 0 to 16, where 0 is fully transparent and 16 is black.
#define OW_OBJECT_SUBPRIORITY 148 // The higher the value, the farther back compared to other sprites. Shadows should be behind object events.
#define OW_ENABLE_DNS TRUE // If set to TRUE, overworld will be tinted depending on time of day
#define OW_ENABLE_DNS TRUE // If set to TRUE, the overworld will be tinted depending on time of day.
// Object Event Shadows
#define OW_OBJECT_VANILLA_SHADOWS FALSE // In vanilla shadows in the overworld is only shown when jumping
#define OW_OBJECT_VANILLA_SHADOWS FALSE // In vanilla shadows in the overworld are only shown when jumping.
// Overworld flags
// To use the following features in scripting, replace the 0s with the flag ID you're assigning it to.

View File

@ -4,7 +4,7 @@
#include "config/overworld.h"
// sPaletteColorMapTypes & field_effect_scripts
enum
enum ColorMapType
{
COLOR_MAP_NONE,
COLOR_MAP_DARK_CONTRAST,

View File

@ -148,7 +148,7 @@ void SetCurrentAndNextWeatherNoDelay(u8 weather);
void ApplyWeatherColorMapIfIdle(s8 colorMapIndex);
void ApplyWeatherColorMapIfIdle_Gradual(u8 colorMapIndex, u8 targetColorMapIndex, u8 colorMapStepDelay);
void FadeScreen(u8 mode, s8 delay);
u32 FadeScreenHardware(u32 mode, s32 delay);
void FadeScreenHardware(u32 mode, s32 delay);
bool8 IsWeatherNotFadingIn(void);
void UpdateSpritePaletteWithWeather(u8 spritePaletteIndex, bool8 allowFog);
void ApplyWeatherColorMapToPals(u8 startPalIndex, u8 numPalettes);
@ -166,7 +166,7 @@ void PlayRainStoppingSoundEffect(void);
u8 IsWeatherChangeComplete(void);
void SetWeatherScreenFadeOut(void);
void SetWeatherPalStateIdle(void);
const u8* SetPaletteColorMapType(u8 paletteIndex, u8 colorMapType);
const u8* SetPaletteColorMapType(u8 paletteIndex, enum ColorMapType colorMapType);
void PreservePaletteInWeather(u8 preservedPalIndex);
void ResetPaletteColorMapType(u8 paletteIndex);
void ResetPreservedPalettesInWeather(void);

View File

@ -38,7 +38,7 @@ typedef void (*TilesetCB)(void);
struct Tileset
{
/*0x00*/ u8 isCompressed:1;
/*0x00*/ u8 swapPalettes:7; // bitmask determining whether palette has an alternate, night-time palette
/*0x00*/ u8 swapPalettes:7; // Bitmask determining whether palette has an alternate, night-time palette
/*0x01*/ bool8 isSecondary;
/*0x02*/ u8 lightPalettes; // Bitmask determining whether a palette should be time-blended as a light
/*0x03*/ u8 customLightColor; // Bitmask determining which light palettes have custom light colors (color 15)

View File

@ -40,7 +40,15 @@ const struct SpriteFrameImage gFieldEffectObjectPicTable_MartLight[] = {
obj_frame_tiles(gFieldEffectObjectPic_MartLight),
};
const struct SpriteTemplate gFieldEffectObjectTemplate_BallLight = {OBJ_EVENT_PAL_TAG_LIGHT, OBJ_EVENT_PAL_TAG_LIGHT, &gObjectEventBaseOam_32x32, sAnimTable_Inanimate, gFieldEffectObjectPicTable_BallLight, gDummySpriteAffineAnimTable, UpdateLightSprite};
const struct SpriteTemplate gFieldEffectObjectTemplate_BallLight = {
.tileTag = OBJ_EVENT_PAL_TAG_LIGHT,
.paletteTag = OBJ_EVENT_PAL_TAG_LIGHT,
.oam = &gObjectEventBaseOam_32x32,
.anims = sAnimTable_Inanimate,
.images = gFieldEffectObjectPicTable_BallLight,
.affineAnims = gDummySpriteAffineAnimTable,
.callback = UpdateLightSprite,
};
const struct SpriteTemplate gFieldEffectObjectTemplate_PokeCenterLight = {
.tileTag = TAG_NONE,

View File

@ -296,7 +296,6 @@ const u32 gFieldEffectObjectPic_ShadowExtraLarge[] = INCBIN_U32("graphics/field_
const u32 gFieldEffectObjectPic_BallLight[] = INCBIN_U32("graphics/object_events/pics/misc/light.4bpp");
const u32 gFieldEffectObjectPic_PokeCenterLight[] = INCBIN_U32("graphics/object_events/pics/misc/poke_center_light.4bpp");
const u32 gFieldEffectObjectPic_MartLight[] = INCBIN_U32("graphics/object_events/pics/misc/mart_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");
const u16 gFieldEffectPal_CutGrass[] = INCBIN_U16("graphics/field_effects/palettes/cut_grass.gbapal");

View File

@ -811,7 +811,7 @@ void FadeScreen(u8 mode, s8 delay)
// Note: This enables blending in all windows;
// These bits may need to be disabled later
// (i.e if blending lighting effects using WINOBJ)
u32 FadeScreenHardware(u32 mode, s32 delay)
void FadeScreenHardware(u32 mode, s32 delay)
{
u32 bldCnt = GetGpuReg(REG_OFFSET_BLDCNT) & BLDCNT_TGT2_ALL;
bldCnt |= BLDCNT_TGT1_ALL;
@ -834,8 +834,6 @@ u32 FadeScreenHardware(u32 mode, s32 delay)
BeginHardwarePaletteFade(bldCnt | BLDCNT_EFFECT_LIGHTEN, delay, 0, 16, FALSE);
break;
}
return 0;
}
bool8 IsWeatherNotFadingIn(void)
@ -896,17 +894,6 @@ void UpdateSpritePaletteWithWeather(u8 spritePaletteIndex, bool8 allowFog)
}
break;
}
// If faded out, i.e due to fadescreenswapbuffers,
// Copy unfaded palette to pal decomp buffer
// so it will be restored on fade-in
/*
if (gPaletteFade.y == 16)
CpuFastCopy(
gPlttBufferUnfaded + OBJ_PLTT_ID(spritePaletteIndex),
gDecompressionBuffer + 2 * OBJ_PLTT_ID(spritePaletteIndex),
PLTT_SIZE_4BPP
);
*/
}
void ApplyWeatherColorMapToPals(u8 startPalIndex, u8 numPalettes)
@ -1162,7 +1149,7 @@ void SetWeatherPalStateIdle(void)
gWeatherPtr->palProcessingState = WEATHER_PAL_STATE_IDLE;
}
const u8* SetPaletteColorMapType(u8 paletteIndex, u8 colorMapType)
const u8 *SetPaletteColorMapType(u8 paletteIndex, enum ColorMapType colorMapType)
{
if (sPaletteColorMapTypes[paletteIndex] == colorMapType)
return sPaletteColorMapTypes;

View File

@ -886,12 +886,11 @@ static void LoadTilesetPalette(struct Tileset const *tileset, u16 destOffset, u1
{
if (tileset->isSecondary == FALSE)
{
// LoadPalette(&black, destOffset, 2);
if (skipFaded)
CpuFastCopy(tileset->palettes, &gPlttBufferUnfaded[destOffset], size); // always word-aligned
else
LoadPaletteFast(tileset->palettes, destOffset, size);
gPlttBufferFaded[destOffset] = gPlttBufferUnfaded[destOffset] = RGB_BLACK; // why does it have to be black?
gPlttBufferFaded[destOffset] = gPlttBufferUnfaded[destOffset] = RGB_BLACK;
ApplyGlobalTintToPaletteEntries(destOffset + 1, (size - 2) >> 1);
low = 0;
high = NUM_PALS_IN_PRIMARY;

View File

@ -1624,8 +1624,7 @@ bool32 MapHasNaturalLight(u8 mapType)
return (mapType == MAP_TYPE_TOWN
|| mapType == MAP_TYPE_CITY
|| mapType == MAP_TYPE_ROUTE
|| mapType == MAP_TYPE_OCEAN_ROUTE
);
|| mapType == MAP_TYPE_OCEAN_ROUTE);
}
bool32 CurrentMapHasShadows(void)
@ -1658,9 +1657,9 @@ void UpdateAltBgPalettes(u16 palettes)
if (palettes & 1)
{
if (i < NUM_PALS_IN_PRIMARY)
AvgPaletteWeighted(&((u16*)primary->palettes)[i*16], &((u16*)primary->palettes)[((i+9)%16)*16], gPlttBufferUnfaded + i * 16, gTimeBlend.altWeight);
AvgPaletteWeighted(&((u16 *)primary->palettes)[i * 16], &((u16 *)primary->palettes)[((i + 9) % 16) * 16], gPlttBufferUnfaded + i * 16, gTimeBlend.altWeight);
else
AvgPaletteWeighted(&((u16*)secondary->palettes)[i*16], &((u16*)secondary->palettes)[((i+9)%16)*16], gPlttBufferUnfaded + i * 16, gTimeBlend.altWeight);
AvgPaletteWeighted(&((u16 *)secondary->palettes)[i * 16], &((u16 *)secondary->palettes)[((i + 9) % 16) * 16], gPlttBufferUnfaded + i * 16, gTimeBlend.altWeight);
}
i++;
palettes >>= 1;
@ -1669,10 +1668,8 @@ void UpdateAltBgPalettes(u16 palettes)
void UpdatePalettesWithTime(u32 palettes)
{
if (!OW_ENABLE_DNS)
if (!OW_ENABLE_DNS || !MapHasNaturalLight(gMapHeader.mapType))
return;
if (MapHasNaturalLight(gMapHeader.mapType))
{
u32 i;
u32 mask = 1 << 16;
if (palettes >= (1 << 16))
@ -1686,19 +1683,14 @@ void UpdatePalettesWithTime(u32 palettes)
if (!palettes)
return;
TimeMixPalettes(palettes, gPlttBufferUnfaded, gPlttBufferFaded, &gTimeBlend.startBlend, &gTimeBlend.endBlend, gTimeBlend.weight);
}
}
u8 UpdateSpritePaletteWithTime(u8 paletteNum)
{
if (!OW_ENABLE_DNS)
return paletteNum;
if (MapHasNaturalLight(gMapHeader.mapType))
{
if (IS_BLEND_IMMUNE_TAG(GetSpritePaletteTagByPaletteNum(paletteNum)))
return paletteNum;
if (OW_ENABLE_DNS
&& MapHasNaturalLight(gMapHeader.mapType)
&& !IS_BLEND_IMMUNE_TAG(GetSpritePaletteTagByPaletteNum(paletteNum)))
TimeMixPalettes(1, &gPlttBufferUnfaded[OBJ_PLTT_ID(paletteNum)], &gPlttBufferFaded[OBJ_PLTT_ID(paletteNum)], &gTimeBlend.startBlend, &gTimeBlend.endBlend, gTimeBlend.weight);
}
return paletteNum;
}

View File

@ -161,11 +161,8 @@ bool32 BeginTimeOfDayPaletteFade(u32 selectedPalettes, s8 delay, u8 startY, u8 t
u8 temp;
if (gPaletteFade.active)
{
return FALSE;
}
else
{
gPaletteFade.deltaY = 2;
if (delay < 0)
@ -202,7 +199,6 @@ bool32 BeginTimeOfDayPaletteFade(u32 selectedPalettes, s8 delay, u8 startY, u8 t
UpdateBlendRegisters();
gPaletteFade.bufferTransferDisabled = temp;
return TRUE;
}
}
void ResetPaletteFadeControl(void)
@ -316,16 +312,14 @@ static u8 UpdateTimeOfDayPaletteFade(void)
if (!gPaletteFade.yDec)
{
val = gPaletteFade.y;
val += gPaletteFade.deltaY;
val = gPaletteFade.y + gPaletteFade.deltaY;
if (val > gPaletteFade.targetY)
val = gPaletteFade.targetY;
gPaletteFade.y = val;
}
else
{
val = gPaletteFade.y;
val -= gPaletteFade.deltaY;
val = gPaletteFade.y - gPaletteFade.deltaY;
if (val < 0)
val = 0;
gPaletteFade.y = val;
@ -732,7 +726,7 @@ static void UpdateBlendRegisters(void)
SetGpuReg(REG_OFFSET_BLDCNT, (u16)gPaletteFade_blendCnt);
SetGpuReg(REG_OFFSET_BLDY, gPaletteFade.y);
// If fade-out, also adjust BLDALPHA and DISPCNT
if (!gPaletteFade.yDec /*&& gPaletteFade.mode == HARDWARE_FADE*/)
if (!gPaletteFade.yDec)
{
u16 bldAlpha = GetGpuReg(REG_OFFSET_BLDALPHA);
u8 tgt1 = BLDALPHA_TGT1(bldAlpha);
@ -744,25 +738,24 @@ static void UpdateBlendRegisters(void)
// FADE_TO_BLACK
case BLDCNT_EFFECT_DARKEN:
bldFade = BLDALPHA_TGT1(max(0, 16 - gPaletteFade.y));
SetGpuReg(
REG_OFFSET_BLDALPHA,
BLDALPHA_BLEND(min(tgt1, bldFade), min(tgt2, bldFade))
);
SetGpuReg(REG_OFFSET_BLDALPHA,
BLDALPHA_BLEND(min(tgt1, bldFade), min(tgt2, bldFade)));
break;
// FADE_TO_WHITE
case BLDCNT_EFFECT_LIGHTEN:
SetGpuReg(
REG_OFFSET_BLDALPHA,
BLDALPHA_BLEND(min(++tgt1, 31), min(++tgt2, 31))
);
SetGpuReg(REG_OFFSET_BLDALPHA,
BLDALPHA_BLEND(min(++tgt1, 31), min(++tgt2, 31)));
// cause display to show white when finished
// (otherwise blend-mode sprites will still be visible)
if (gPaletteFade.hardwareFadeFinishing && gPaletteFade.y >= 16)
SetGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_FORCED_BLANK);
break;
}
} else
}
else
{
ClearGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_FORCED_BLANK);
}
if (gPaletteFade.hardwareFadeFinishing)
{
@ -849,8 +842,8 @@ void BlendPalettes(u32 selectedPalettes, u8 coeff, u32 color)
void TimeBlendPalette(u16 palOffset, u32 coeff, u32 blendColor)
{
s32 newR, newG, newB, defR, defG, defB;
u16 * src = gPlttBufferUnfaded + palOffset;
u16 * dst = gPlttBufferFaded + palOffset;
u16 *src = gPlttBufferUnfaded + palOffset;
u16 *dst = gPlttBufferFaded + palOffset;
u32 defaultBlendColor = DEFAULT_LIGHT_COLOR;
u16 *srcEnd = src + 16;
u32 altBlendColor = *dst++ = *src++; // color 0 is copied through unchanged
@ -1182,8 +1175,8 @@ void TintPalette_CustomTone(u16 *palette, u32 count, u16 rTone, u16 gTone, u16 b
void TintPalette_RGB_Copy(u16 palOffset, u32 blendColor)
{
s32 newR, newG, newB, rTone = 0, gTone = 0, bTone = 0;
u16 * src = gPlttBufferUnfaded + palOffset;
u16 * dst = gPlttBufferFaded + palOffset;
u16 *src = gPlttBufferUnfaded + palOffset;
u16 *dst = gPlttBufferFaded + palOffset;
u32 defaultBlendColor = DEFAULT_LIGHT_COLOR;
u16 *srcEnd = src + 16;
u16 altBlendIndices = *dst++ = *src++; // color 0 is copied through unchanged
@ -1249,6 +1242,8 @@ void TintPalette_RGB_Copy(u16 palOffset, u32 blendColor)
}
}
#undef DEFAULT_LIGHT_COLOR
#define tCoeff data[0]
#define tCoeffTarget data[1]
#define tCoeffDelta data[2]

View File

@ -387,7 +387,7 @@ void UpdatePulseBlend(struct PulseBlend *pulseBlend)
pulseBlendPalette->delayCounter = pulseBlendPalette->pulseBlendSettings.delay;
CpuFastCopy(gPlttBufferUnfaded + pulseBlendPalette->pulseBlendSettings.paletteOffset, gPlttBufferFaded + pulseBlendPalette->pulseBlendSettings.paletteOffset, PLTT_SIZE_4BPP);
UpdatePalettesWithTime(1 << (pulseBlendPalette->pulseBlendSettings.paletteOffset >> 4));
// pulseBlendSettings has a numColors field, but it is only ever set to 16 (for Mirage tower)
// pulseBlendSettings has a numColors field, but it is only ever set to 16 (for Mirage Tower)
// So, it's ok to use the fine blending here which blends the entire palette
BlendPalettesFine(1, gPlttBufferFaded + pulseBlendPalette->pulseBlendSettings.paletteOffset, gPlttBufferFaded + pulseBlendPalette->pulseBlendSettings.paletteOffset, pulseBlendPalette->blendCoeff, pulseBlendPalette->pulseBlendSettings.blendColor);
switch (pulseBlendPalette->pulseBlendSettings.fadeType)

View File

@ -839,10 +839,8 @@ bool8 ScrCmd_fadescreenswapbuffers(struct ScriptContext *ctx)
case FADE_FROM_WHITE:
// Restore last weather blend before fading in,
// since BLDALPHA was modified by fade-out
SetGpuReg(
REG_OFFSET_BLDALPHA,
BLDALPHA_BLEND(gWeatherPtr->currBlendEVA, gWeatherPtr->currBlendEVB)
);
SetGpuReg(REG_OFFSET_BLDALPHA,
BLDALPHA_BLEND(gWeatherPtr->currBlendEVA, gWeatherPtr->currBlendEVB));
break;
}