Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
psytp2 committed Aug 13, 2024
2 parents f3b6efd + 38752b5 commit efa4031
Showing 1 changed file with 31 additions and 7 deletions.
38 changes: 31 additions & 7 deletions src/type_icons.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ static bool32 ShouldFlipTypeIcon(bool32, u32, u32);

static void SpriteCB_TypeIcon(struct Sprite*);
static void DestroyTypeIcon(struct Sprite*);
static void FreeAllTypeIconResources(void);
static bool32 ShouldHideTypeIcon(u32);
static s32 GetTypeIconHideMovement(bool32, u32);
static s32 GetTypeIconSlideMovement(bool32, u32, s32);
Expand Down Expand Up @@ -429,22 +430,45 @@ static void SpriteCB_TypeIcon(struct Sprite* sprite)
sprite->y = GetTypeIconBounceMovement(sprite->tVerticalPosition,position);
}

static const u32 typeIconTags[] =
{
TYPE_ICON_TAG,
TYPE_ICON_TAG_2
};

static void DestroyTypeIcon(struct Sprite* sprite)
{
u32 i;
u32 spriteId, tag;

DestroySpriteAndFreeResources(sprite);

for (i = 0; i < MAX_SPRITES; ++i)
for (spriteId = 0; spriteId < MAX_SPRITES; ++spriteId)
{
if (!gSprites[i].inUse)
if (!gSprites[spriteId].inUse)
continue;

if (gSprites[i].template->paletteTag == TYPE_ICON_TAG)
return;
for (tag = 0; tag < 2; tag++)
{
if (gSprites[spriteId].template->paletteTag == typeIconTags[tag])
return;

if (gSprites[spriteId].template->tileTag == typeIconTags[tag])
return;
}
}

FreeSpritePaletteByTag(TYPE_ICON_TAG);
FreeSpritePaletteByTag(TYPE_ICON_TAG_2);
FreeAllTypeIconResources();
}

static void FreeAllTypeIconResources(void)
{
u32 tag;

for (tag = 0; tag < 2; tag++)
{
FreeSpriteTilesByTag(typeIconTags[tag]);
FreeSpritePaletteByTag(typeIconTags[tag]);
}
}

static bool32 ShouldHideTypeIcon(u32 battlerId)
Expand Down

0 comments on commit efa4031

Please sign in to comment.