Skip to content

Dynamic overworld palette system

smithk200 edited this page Nov 9, 2023 · 13 revisions

TODO: Update this tutorial properly, explaining the changes that are made and the reasoning behind. NOTE This tutorial is a work in progress. Will add everything eventually, but currently I (smithk200) am adding this bit by bit. This is a long thing to write!

Goal: To replace the static overworld palettes with a dynamic system that loads the correct palette slot when you are playing the game, versus the palette slots being hardcoded when the game begins.

The most up to date code at time of writing can be found here. This also fixes some of the problems with the below system, like broken reflections and berry trees.

If you don't want to pull from a repository, you can look at this link here, and make the changes accordingly: https://github.com/pret/pokeemerald/compare/master...ExpoSeed:pokeemerald:dynamic-ow-pals

1. include/event_object_movement.h

First, remove this line:

- extern const u8 gReflectionEffectPaletteMap[];

Then, change these two lines

extern const u8 *const gBerryTreeObjectEventGraphicsIdTablePointers[];
extern const u8 *const gBerryTreePaletteSlotTablePointers[];

to this.

extern const u16 *const gBerryTreeObjectEventGraphicsIdTablePointers[];
extern const u16 *const gBerryTreePaletteSlotTablePointers[];

Finally, after these lines,

s16 GetFigure8XOffset(s16 idx);
s16 GetFigure8YOffset(s16 idx);
void CameraObjectReset2(void);

add this one.

void LoadObjectEventPalette(u16 paletteTag);

2. include/field_effect_helpers.h

After this line

void ShowWarpArrowSprite(u8 spriteId, u8 direction, s16 x, s16 y);

add this:

void LoadFieldEffectPalette(u8 fieldEffect);

3. include/field_weather.h

After this line extern const u16 gFogPalette[];

add this:

enum
{
    GAMMA_NONE,
    GAMMA_NORMAL,
    GAMMA_ALT,
};

void UpdatePaletteGammaType(u8 index, u8 gammaType);

Next, find this line: void LoadCustomWeatherSpritePalette(const u16 *palette);

And change it to this: void LoadCustomWeatherSpritePalette(const struct SpritePalette *palette);

That's it for the includes! As to what those functions will actually do is something I will add later. That will be covered in a lot of files in the src folder. This tutorial is NOT complete! If I don't get to this, hopefully someone else will!

Clone this wiki locally