diff --git a/Dynamic-overworld-palette-system.md b/Dynamic-overworld-palette-system.md index f96d770..7d9b5a7 100644 --- a/Dynamic-overworld-palette-system.md +++ b/Dynamic-overworld-palette-system.md @@ -1,4 +1,4 @@ -For this tutorial we will be editting one function within **src/overworld.c** and three functions within **src/event_object_movement.c** along with adding one new function to make it easier when adding new overworlds, with new palettes. +For this tutorial we will be editting one function within **src/overworld.c** and three functions within **src/event_object_movement.c** to make it easier when adding new overworlds, with new palettes. Note that the current implementation breaks the reflection palette system, though for ease of adding new overworlds that should be adapted so it is dynamic as well, rather than requiring explicit reflection palettes. @@ -167,22 +167,6 @@ static u8 TrySetupEventObjectSprite(struct EventObjectTemplate *eventObjectTempl } ``` ### RemoveEventObjectInternal() -First we need to add a new function, courtesy of ShantyTown. -```c -void FreeSpritePaletteIfUnused(u8 paletteNum) -{ - u8 i; - u16 tag = GetSpritePaletteTagByPaletteNum(paletteNum); - - if (tag != 0xFFFF) - { - for (i = 0; i < MAX_SPRITES; i++) - if (gSprites[i].inUse && gSprites[i].oam.paletteNum == paletteNum) - return; - FreeSpritePaletteByTag(tag); - } -} -``` ```diff static void RemoveEventObjectInternal(struct EventObject *eventObject) { @@ -193,7 +177,8 @@ static void RemoveEventObjectInternal(struct EventObject *eventObject) gSprites[eventObject->spriteId].images = ℑ + paletteNum = gSprites[eventObject->spriteId].oam.paletteNum; DestroySprite(&gSprites[eventObject->spriteId]); -+ FreeSpritePaletteIfUnused(paletteNum); ++ FieldEffectFreePaletteIfUnused(paletteNum); + } ``` becomes: @@ -207,7 +192,7 @@ static void RemoveEventObjectInternal(struct EventObject *eventObject) gSprites[eventObject->spriteId].images = ℑ paletteNum = gSprites[eventObject->spriteId].oam.paletteNum; DestroySprite(&gSprites[eventObject->spriteId]); - FreeSpritePaletteIfUnused(paletteNum); + FieldEffectFreePaletteIfUnused(paletteNum); } ``` ### sub_808E1B8()