ShinyDragonHunter's DayNight Branch bug fixes and optional changes - Pawkkie/Team-Aquas-Asset-Repo GitHub Wiki
Here's a few bug fixes and optional changes you might wanna consider when you merge in ShinyDragonHunter's DayNight branch.
Table of contents:
- Yellow Water Fix 🐛
- Palette Overrides
- Dynamic Palettes Compatibility
- Tinting Battle Backgrounds
- Tinting Weather
- Fixing Other Feature Branch OW Palettes
Yellow Water Fix:
The DNS adds the yellow lighting by overriding a palette slot, in this case the slot for the blue used in windows and also the water. There's an equivalent blue in another palette, so you just change the tiles you want to stay blue to use the other palette.
Palette Overrides:
const struct PaletteOverride gTilesetPalOverrides_Petalburg[] =
{
{
.slot = 6,
.startHour = HOUR_NIGHT,
.endHour = HOUR_MORNING,
.palette = sTilesetPalOverride_Petalburg06_08,
},
{
.slot = 8,
.startHour = HOUR_NIGHT,
.endHour = HOUR_MORNING,
.palette = sTilesetPalOverride_Petalburg06_08,
},
OVERRIDES_END
};
Basically, you need to make a palette override entry for the tileset.
.slot
is the tileset palette it's overriding, startHour
is the starting hour of when the override is loaded, .endHour
is the hour of which said override unloads and .palette
is the palette itself.
JASC-PAL
0100
16
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
229 229 163
196 196 106
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
And with your override palette itself, whatever isn't 0 0 0, will be applied to the palette it's overriding.
const struct Tileset gTileset_Petalburg =
{
.isCompressed = TRUE,
.isSecondary = TRUE,
.tiles = gTilesetTiles_Petalburg,
.palettes = gTilesetPalettes_Petalburg,
.metatiles = gMetatiles_Petalburg,
.metatileAttributes = gMetatileAttributes_Petalburg,
.callback = InitTilesetAnim_Petalburg,
.paletteOverrides = gTilesetPalOverrides_Petalburg,
};
And then you update the respective tileset header.
Dynamic Palettes Compatibility:
There are some functionality conflicts when integrating this DNS with dynamic palettes that need to be sorted out. I'd (Pawkkie) recommend using an updated version of the Exposeed dynamic palettes for now, and I'm personally using AsparagusEduardo's updated version here, and here's my commit merging it into my project initially.
In field_effect_scripts.s
:
gFieldEffectScript_SandPile::
- field_eff_loadfadedpal_callnative gSpritePalette_GeneralFieldEffect0, FldEff_SandPile
+ field_eff_loadfadedpaldaynight_callnative gSpritePalette_GeneralFieldEffect0, FldEff_SandPile
field_eff_end
In event_object_movement.c
:
static u8 LoadSpritePaletteIfTagExists(const struct SpritePalette *spritePalette)
{
if (IndexOfSpritePaletteTag(spritePalette->tag) != 0xFF)
return 0xFF;
- return LoadSpritePalette(spritePalette);
+ return LoadSpritePaletteDayNight(spritePalette);
}
In field_effect_helpers.c
:
void LoadSpecialReflectionPalette(struct Sprite *sprite)
{
u32 R, G, B, i;
u16 color;
u16* pal;
struct SpritePalette reflectionPalette;
CpuCopy16(&gPlttBufferUnfaded[0x100 + sprite->oam.paletteNum * 16], gReflectionPaletteBuffer, 32);
pal = gReflectionPaletteBuffer;
for (i = 0; i < 16; ++i)
{
color = pal[i];
R = GET_R(color) + 8;
G = GET_G(color) + 8;
B = GET_B(color) + 16;
if (R > 31) R = 31;
if (G > 31) G = 31;
if (B > 31) B = 31;
pal[i] = RGB(R, G, B);
}
reflectionPalette.data = gReflectionPaletteBuffer;
reflectionPalette.tag = GetSpritePaletteTagByPaletteNum(sprite->oam.paletteNum) + 0x1000;
- LoadSpritePalette(&reflectionPalette);
+ LoadSpritePaletteDayNight(&reflectionPalette);
sprite->oam.paletteNum = IndexOfSpritePaletteTag(reflectionPalette.tag);
UpdatePaletteGammaType(sprite->oam.paletteNum, GAMMA_ALT);
UpdateSpritePaletteWithWeather(sprite->oam.paletteNum);
}
Tinting Battle Backgrounds:
Add #include "day_night.h"
to the top of src/battle_bg.c
, and then swap out LoadCompressedPalette
for LoadCompressedPaletteDayNight
in the appropriate DrawMainBattleBackground
cases.
Here's an example, again in the DrawMainBattleBackground
function:
case MAP_BATTLE_SCENE_NORMAL:
LZDecompressVram(sBattleTerrainTable[gBattleTerrain].tileset, (void *)(BG_CHAR_ADDR(2)));
LZDecompressVram(sBattleTerrainTable[gBattleTerrain].tilemap, (void *)(BG_SCREEN_ADDR(26)));
- LoadCompressedPalette(sBattleTerrainTable[gBattleTerrain].palette, BG_PLTT_ID(2), 3 * PLTT_SIZE_4BPP);
+ LoadCompressedPaletteDayNight(sBattleTerrainTable[gBattleTerrain].palette, BG_PLTT_ID(2), 3 * PLTT_SIZE_4BPP);
break;
Tinting Weather:
There are two changes that are needed to tint all weather, one to tint weather using unique palettes (sandstorm etc.) and one to tint weather using the generic fog palette (rain / snow / etc. all use this). Tinting the former is the usual swap; in LoadCustomWeatherSpritePalette
, swap LoadSpritePalette
for LoadSpritePaletteDayNight
.
Tinting the latter is a recent discovery at least to my (Pawkkie) and ShinyDragonHunter's knowledge, so we'd like to add a disclaimer that while I haven't found any issue since discovering it, some certainly may be present.
In field_weather.c
, add #include day_night.h
to the top of the file. In StartWeather
, change CpuCopy32(gFogPalette, &gPlttBufferUnfaded[OBJ_PLTT_ID(index)], PLTT_SIZE_4BPP);
to LoadPaletteDayNight(gFogPalette, OBJ_PLTT_ID(index), PLTT_SIZE_4BPP);
. Again if you find this results in any strange visual bugs, let us know! We aren't away of any at present but this is very new and relatively untested.
Fixing Other Feature Branch OW Palettes (ghoul's Dexnav and Item Headers, etc.):
Fixing issues related to field effects palettes
In ProcessImmediateTimeEvents
at src/day_night.c
:
if (gWeatherPtr->palProcessingState != WEATHER_PAL_STATE_SCREEN_FADING_IN &&
gWeatherPtr->palProcessingState != WEATHER_PAL_STATE_SCREEN_FADING_OUT)
{
s32 paletteIndex;
CpuCopy16(gPlttBufferUnfaded, gPlttBufferFaded, PLTT_SIZE);
for (paletteIndex = 0; paletteIndex < NUM_PALS_TOTAL; paletteIndex++)
+ {
ApplyWeatherColorMapToPal(paletteIndex);
+ UpdateSpritePaletteWithWeather(paletteIndex);
+ }
}