mirror of https://github.com/pret/pokeemerald.git
Updated Dynamic overworld palette system (markdown)
parent
3837e23676
commit
02609abc8e
|
@ -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.
|
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()
|
### 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
|
```diff
|
||||||
static void RemoveEventObjectInternal(struct EventObject *eventObject)
|
static void RemoveEventObjectInternal(struct EventObject *eventObject)
|
||||||
{
|
{
|
||||||
|
@ -193,7 +177,8 @@ static void RemoveEventObjectInternal(struct EventObject *eventObject)
|
||||||
gSprites[eventObject->spriteId].images = ℑ
|
gSprites[eventObject->spriteId].images = ℑ
|
||||||
+ paletteNum = gSprites[eventObject->spriteId].oam.paletteNum;
|
+ paletteNum = gSprites[eventObject->spriteId].oam.paletteNum;
|
||||||
DestroySprite(&gSprites[eventObject->spriteId]);
|
DestroySprite(&gSprites[eventObject->spriteId]);
|
||||||
+ FreeSpritePaletteIfUnused(paletteNum);
|
+ FieldEffectFreePaletteIfUnused(paletteNum);
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
becomes:
|
becomes:
|
||||||
|
@ -207,7 +192,7 @@ static void RemoveEventObjectInternal(struct EventObject *eventObject)
|
||||||
gSprites[eventObject->spriteId].images = ℑ
|
gSprites[eventObject->spriteId].images = ℑ
|
||||||
paletteNum = gSprites[eventObject->spriteId].oam.paletteNum;
|
paletteNum = gSprites[eventObject->spriteId].oam.paletteNum;
|
||||||
DestroySprite(&gSprites[eventObject->spriteId]);
|
DestroySprite(&gSprites[eventObject->spriteId]);
|
||||||
FreeSpritePaletteIfUnused(paletteNum);
|
FieldEffectFreePaletteIfUnused(paletteNum);
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
### sub_808E1B8()
|
### sub_808E1B8()
|
||||||
|
|
Loading…
Reference in New Issue