Moved pokemon graphics lookup into table.

This commit is contained in:
Ariel Antonitis 2020-06-18 14:21:06 -04:00
parent 84668d0d40
commit b6eed75fd8
4 changed files with 12 additions and 31 deletions

View file

@ -1599,11 +1599,9 @@ void AllocSpriteTileRange(u16 tag, u16 start, u16 count)
void FreeAllSpritePalettes(void) void FreeAllSpritePalettes(void)
{ {
u8 i; u8 i;
u16 emptyPalette[16] = {0};
gReservedSpritePaletteCount = 0; gReservedSpritePaletteCount = 0;
for (i = 0; i < 16; i++) for (i = 0; i < 16; i++)
sSpritePaletteTags[i] = 0xFFFF; sSpritePaletteTags[i] = 0xFFFF;
LoadPalette(emptyPalette, i * 16 + 0x100, 32); // TODO: DEBUG: Remove this or battle palettes break
} }
u8 LoadSpritePalette(const struct SpritePalette *palette) u8 LoadSpritePalette(const struct SpritePalette *palette)

View file

@ -244,9 +244,13 @@ const struct ObjectEventGraphicsInfo gObjectEventGraphicsInfo_RubySapphireMay =
const struct ObjectEventGraphicsInfo gObjectEventGraphicsInfo_Lugia = {0xFFFF, OBJ_EVENT_PAL_TAG_LUGIA, OBJ_EVENT_PAL_TAG_NONE, 512, 32, 32, 10, SHADOW_SIZE_M, FALSE, FALSE, TRACKS_FOOT, &gObjectEventBaseOam_32x32, gObjectEventSpriteOamTables_32x32, gObjectEventImageAnimTable_Standard, gObjectEventPicTable_Lugia, gDummySpriteAffineAnimTable}; const struct ObjectEventGraphicsInfo gObjectEventGraphicsInfo_Lugia = {0xFFFF, OBJ_EVENT_PAL_TAG_LUGIA, OBJ_EVENT_PAL_TAG_NONE, 512, 32, 32, 10, SHADOW_SIZE_M, FALSE, FALSE, TRACKS_FOOT, &gObjectEventBaseOam_32x32, gObjectEventSpriteOamTables_32x32, gObjectEventImageAnimTable_Standard, gObjectEventPicTable_Lugia, gDummySpriteAffineAnimTable};
const struct ObjectEventGraphicsInfo gObjectEventGraphicsInfo_HoOh = {0xFFFF, OBJ_EVENT_PAL_TAG_HO_OH, OBJ_EVENT_PAL_TAG_NONE, 512, 32, 32, 10, SHADOW_SIZE_M, FALSE, FALSE, TRACKS_FOOT, &gObjectEventBaseOam_32x32, gObjectEventSpriteOamTables_32x32, gObjectEventImageAnimTable_HoOh, gObjectEventPicTable_HoOh, gDummySpriteAffineAnimTable}; const struct ObjectEventGraphicsInfo gObjectEventGraphicsInfo_HoOh = {0xFFFF, OBJ_EVENT_PAL_TAG_HO_OH, OBJ_EVENT_PAL_TAG_NONE, 512, 32, 32, 10, SHADOW_SIZE_M, FALSE, FALSE, TRACKS_FOOT, &gObjectEventBaseOam_32x32, gObjectEventSpriteOamTables_32x32, gObjectEventImageAnimTable_HoOh, gObjectEventPicTable_HoOh, gDummySpriteAffineAnimTable};
const struct ObjectEventGraphicsInfo gObjectEventGraphicsInfo_AnimatedBall = {0xFFFF, OBJ_EVENT_PAL_TAG_3, OBJ_EVENT_PAL_TAG_NONE, 256, 16, 32, 2, SHADOW_SIZE_M, FALSE, FALSE, TRACKS_FOOT, &gObjectEventBaseOam_16x32, gObjectEventSpriteOamTables_16x32, gObjectEventImageAnimTable_Following, gObjectEventPicTable_AnimatedBall, gDummySpriteAffineAnimTable}; const struct ObjectEventGraphicsInfo gObjectEventGraphicsInfo_AnimatedBall = {0xFFFF, OBJ_EVENT_PAL_TAG_3, OBJ_EVENT_PAL_TAG_NONE, 256, 16, 32, 2, SHADOW_SIZE_M, FALSE, FALSE, TRACKS_FOOT, &gObjectEventBaseOam_16x32, gObjectEventSpriteOamTables_16x32, gObjectEventImageAnimTable_Following, gObjectEventPicTable_AnimatedBall, gDummySpriteAffineAnimTable};
const struct ObjectEventGraphicsInfo gObjectEventGraphicsInfo_Marshtomp = {0xFFFF, OBJ_EVENT_PAL_TAG_DYNAMIC, OBJ_EVENT_PAL_TAG_NONE, 256, 16, 32, 2, SHADOW_SIZE_M, FALSE, FALSE, TRACKS_FOOT, &gObjectEventBaseOam_16x32, gObjectEventSpriteOamTables_16x32, gObjectEventImageAnimTable_Following, gObjectEventPicTable_Marshtomp, gDummySpriteAffineAnimTable};
const struct ObjectEventGraphicsInfo gObjectEventGraphicsInfo_Altaria = {0xFFFF, OBJ_EVENT_PAL_TAG_DYNAMIC, OBJ_EVENT_PAL_TAG_NONE, 512, 32, 32, 2, SHADOW_SIZE_M, FALSE, FALSE, TRACKS_FOOT, &gObjectEventBaseOam_32x32, gObjectEventSpriteOamTables_32x32, gObjectEventImageAnimTable_Standard, gObjectEventPicTable_Altaria, gDummySpriteAffineAnimTable};
const struct ObjectEventGraphicsInfo gObjectEventGraphicsInfo_Togetic = {0xFFFF, OBJ_EVENT_PAL_TAG_DYNAMIC, OBJ_EVENT_PAL_TAG_NONE, 512, 32, 32, 2, SHADOW_SIZE_M, FALSE, FALSE, TRACKS_NONE, &gObjectEventBaseOam_32x32, gObjectEventSpriteOamTables_32x32, gObjectEventImageAnimTable_Following, gObjectEventPicTable_Togetic, gDummySpriteAffineAnimTable};
const struct ObjectEventGraphicsInfo gObjectEventGraphicsInfo_Charizard = {0xFFFF, OBJ_EVENT_PAL_TAG_DYNAMIC, OBJ_EVENT_PAL_TAG_NONE, 512, 32, 32, 2, SHADOW_SIZE_M, FALSE, FALSE, TRACKS_FOOT, &gObjectEventBaseOam_32x32, gObjectEventSpriteOamTables_32x32, gObjectEventImageAnimTable_Following, gObjectEventPicTable_Charizard, gDummySpriteAffineAnimTable};
const struct ObjectEventGraphicsInfo gObjectEventGraphicsInfo_Follower = {0xFFFF, OBJ_EVENT_PAL_TAG_DYNAMIC, OBJ_EVENT_PAL_TAG_NONE, 512, 32, 32, 2, SHADOW_SIZE_M, FALSE, FALSE, TRACKS_FOOT, &gObjectEventBaseOam_32x32, gObjectEventSpriteOamTables_32x32, gObjectEventImageAnimTable_Following, gObjectEventPicTable_Togetic, gDummySpriteAffineAnimTable}; const struct ObjectEventGraphicsInfo gObjectEventGraphicsInfo_Follower = {0xFFFF, OBJ_EVENT_PAL_TAG_DYNAMIC, OBJ_EVENT_PAL_TAG_NONE, 512, 32, 32, 2, SHADOW_SIZE_M, FALSE, FALSE, TRACKS_FOOT, &gObjectEventBaseOam_32x32, gObjectEventSpriteOamTables_32x32, gObjectEventImageAnimTable_Following, gObjectEventPicTable_Togetic, gDummySpriteAffineAnimTable};
const struct ObjectEventGraphicsInfo gObjectEventGraphicsInfo_Banette = {0xFFFF, OBJ_EVENT_PAL_TAG_DYNAMIC, OBJ_EVENT_PAL_TAG_NONE, 512, 32, 32, 2, SHADOW_SIZE_M, FALSE, FALSE, TRACKS_FOOT, &gObjectEventBaseOam_32x32, gObjectEventSpriteOamTables_32x32, gObjectEventImageAnimTable_Following, gObjectEventPicTable_Banette, gDummySpriteAffineAnimTable};
// Species-indexed pokemon object event table
const struct ObjectEventGraphicsInfo gPokemonObjectGraphics[] = {
[SPECIES_CHARIZARD] = {0xFFFF, OBJ_EVENT_PAL_TAG_DYNAMIC, OBJ_EVENT_PAL_TAG_NONE, 512, 32, 32, 2, SHADOW_SIZE_M, FALSE, FALSE, TRACKS_FOOT, &gObjectEventBaseOam_32x32, gObjectEventSpriteOamTables_32x32, gObjectEventImageAnimTable_Following, gObjectEventPicTable_Charizard, gDummySpriteAffineAnimTable},
[SPECIES_TOGETIC] = {0xFFFF, OBJ_EVENT_PAL_TAG_DYNAMIC, OBJ_EVENT_PAL_TAG_NONE, 512, 32, 32, 2, SHADOW_SIZE_M, FALSE, FALSE, TRACKS_NONE, &gObjectEventBaseOam_32x32, gObjectEventSpriteOamTables_32x32, gObjectEventImageAnimTable_Following, gObjectEventPicTable_Togetic, gDummySpriteAffineAnimTable},
[SPECIES_MARSHTOMP] = {0xFFFF, OBJ_EVENT_PAL_TAG_DYNAMIC, OBJ_EVENT_PAL_TAG_NONE, 256, 16, 32, 2, SHADOW_SIZE_M, FALSE, FALSE, TRACKS_FOOT, &gObjectEventBaseOam_16x32, gObjectEventSpriteOamTables_16x32, gObjectEventImageAnimTable_Following, gObjectEventPicTable_Marshtomp, gDummySpriteAffineAnimTable},
[SPECIES_ALTARIA] = {0xFFFF, OBJ_EVENT_PAL_TAG_DYNAMIC, OBJ_EVENT_PAL_TAG_NONE, 512, 32, 32, 2, SHADOW_SIZE_M, FALSE, FALSE, TRACKS_FOOT, &gObjectEventBaseOam_32x32, gObjectEventSpriteOamTables_32x32, gObjectEventImageAnimTable_Standard, gObjectEventPicTable_Altaria, gDummySpriteAffineAnimTable},
[SPECIES_BANETTE] = {0xFFFF, OBJ_EVENT_PAL_TAG_DYNAMIC, OBJ_EVENT_PAL_TAG_NONE, 512, 32, 32, 2, SHADOW_SIZE_M, FALSE, FALSE, TRACKS_FOOT, &gObjectEventBaseOam_32x32, gObjectEventSpriteOamTables_32x32, gObjectEventImageAnimTable_Following, gObjectEventPicTable_Banette, gDummySpriteAffineAnimTable},
};

View file

@ -239,10 +239,6 @@ const struct ObjectEventGraphicsInfo gObjectEventGraphicsInfo_Lugia;
const struct ObjectEventGraphicsInfo gObjectEventGraphicsInfo_HoOh; const struct ObjectEventGraphicsInfo gObjectEventGraphicsInfo_HoOh;
// Begin pokemon event objects // Begin pokemon event objects
const struct ObjectEventGraphicsInfo gObjectEventGraphicsInfo_AnimatedBall; const struct ObjectEventGraphicsInfo gObjectEventGraphicsInfo_AnimatedBall;
const struct ObjectEventGraphicsInfo gObjectEventGraphicsInfo_Marshtomp;
const struct ObjectEventGraphicsInfo gObjectEventGraphicsInfo_Altaria;
const struct ObjectEventGraphicsInfo gObjectEventGraphicsInfo_Togetic;
const struct ObjectEventGraphicsInfo gObjectEventGraphicsInfo_Charizard;
const struct ObjectEventGraphicsInfo gObjectEventGraphicsInfo_Follower; const struct ObjectEventGraphicsInfo gObjectEventGraphicsInfo_Follower;
const struct ObjectEventGraphicsInfo gObjectEventGraphicsInfo_Bard; const struct ObjectEventGraphicsInfo gObjectEventGraphicsInfo_Bard;

View file

@ -1617,27 +1617,10 @@ struct ObjectEvent * GetFollowerObject(void) { // Return follower ObjectEvent or
return NULL; return NULL;
} }
// Return graphicsInfo for a pokemon species TODO: Make this into a table lookup // Return graphicsInfo for a pokemon species
static const struct ObjectEventGraphicsInfo * SpeciesToGraphicsInfo(u16 species) { static const struct ObjectEventGraphicsInfo * SpeciesToGraphicsInfo(u16 species) {
switch (species) { const struct ObjectEventGraphicsInfo *graphicsInfo = &gPokemonObjectGraphics[species];
case SPECIES_MARSHTOMP : return graphicsInfo->tileTag != 0xFFFF ? &gObjectEventGraphicsInfo_Dusclops : graphicsInfo;
return &gObjectEventGraphicsInfo_Marshtomp;
break;
case SPECIES_TOGETIC :
return &gObjectEventGraphicsInfo_Togetic;
break;
case SPECIES_ALTARIA :
return &gObjectEventGraphicsInfo_Altaria;
break;
case SPECIES_CHARIZARD :
return &gObjectEventGraphicsInfo_Charizard;
break;
case SPECIES_BANETTE :
return &gObjectEventGraphicsInfo_Banette;
break;
default:
return &gObjectEventGraphicsInfo_Dusclops;
}
} }
// Set graphics & sprite for a follower object event by species // Set graphics & sprite for a follower object event by species