Function to get form tables

This commit is contained in:
Eduardo Quezada 2022-10-10 16:52:19 -03:00
parent 24d2a1765e
commit 69243b7618
3 changed files with 12 additions and 7 deletions

View file

@ -408,7 +408,6 @@ extern const u8 gStatStageRatios[MAX_STAT_STAGE + 1][2];
extern const u16 gUnionRoomFacilityClasses[];
extern const struct SpriteTemplate gBattlerSpriteTemplates[];
extern const s8 gNatureStatTable[][5];
extern const u16 *const gFormSpeciesIdTables[NATIONAL_DEX_COUNT + 1];
extern const u32 sExpCandyExperienceTable[];
void ZeroBoxMonData(struct BoxPokemon *boxMon);
@ -558,6 +557,7 @@ bool8 HasTwoFramesAnimation(u16 species);
struct MonSpritesGfxManager *CreateMonSpritesGfxManager(u8 managerId, u8 mode);
void DestroyMonSpritesGfxManager(u8 managerId);
u8 *MonSpritesGfxManager_GetSpritePtr(u8 managerId, u8 spriteNum);
const u16 *GetFormSpeciesTable(u16 speciesId);
u16 GetFormSpeciesId(u16 speciesId, u8 formId);
u8 GetFormIdFromFormSpeciesId(u16 formSpeciesId);
u16 GetFormChangeTargetSpecies(struct Pokemon *mon, u16 method, u32 arg);

View file

@ -8416,9 +8416,14 @@ u8 *MonSpritesGfxManager_GetSpritePtr(u8 managerId, u8 spriteNum)
}
}
const u16 *GetFormSpeciesTable(u16 speciesId)
{
return gFormSpeciesIdTables[SpeciesToNationalPokedexNum(speciesId)];
}
u16 GetFormSpeciesId(u16 speciesId, u8 formId)
{
const u16 * formTable = gFormSpeciesIdTables[SpeciesToNationalPokedexNum(speciesId)];
const u16 * formTable = GetFormSpeciesTable(speciesId);
if (formTable != NULL)
return formTable[formId];
else
@ -8428,7 +8433,7 @@ u16 GetFormSpeciesId(u16 speciesId, u8 formId)
u8 GetFormIdFromFormSpeciesId(u16 formSpeciesId)
{
u8 targetFormId = 0;
const u16 * formTable = gFormSpeciesIdTables[SpeciesToNationalPokedexNum(formSpeciesId)];
const u16 * formTable = GetFormSpeciesTable(formSpeciesId);
if (formTable != NULL)
{

View file

@ -444,7 +444,7 @@ static void PrintInstructionsOnWindow(struct PokemonDebugMenu *data)
{
AddTextPrinterParameterized(WIN_BOTTOM_LEFT, fontId, textL, 30, 0, 0, NULL);
AddTextPrinterParameterized(WIN_BOTTOM_LEFT, fontId, textR, 30, 12, 0, NULL);
if (gFormSpeciesIdTables[SpeciesToNationalPokedexNum(data->currentmonId)] != NULL)
if (GetFormSpeciesTable(data->currentmonId) != NULL)
AddTextPrinterParameterized(WIN_BOTTOM_LEFT, fontId, textBottomForms, 0, 0, 0, NULL);
else
AddTextPrinterParameterized(WIN_BOTTOM_LEFT, fontId, textBottom, 0, 0, 0, NULL);
@ -1348,7 +1348,7 @@ static void UpdateSubmenuOneOptionValue(u8 taskId, bool8 increment)
break;
case 3:
{
const u16 * formTable = gFormSpeciesIdTables[SpeciesToNationalPokedexNum(data->currentmonId)];
const u16 * formTable = GetFormSpeciesTable(data->currentmonId);
if (formTable != NULL)
{
struct PokemonDebugModifyArrows *modArrows = &data->modifyArrows;
@ -1599,7 +1599,7 @@ static void Handle_Input_Debug_Pokemon(u8 taskId)
data->submenuYpos[1] += 1;
if (data->submenuYpos[1] >= 3)
{
if ((gFormSpeciesIdTables[SpeciesToNationalPokedexNum(data->currentmonId)] == NULL) || (data->submenuYpos[1] >= 4))
if ((GetFormSpeciesTable(data->currentmonId) == NULL) || (data->submenuYpos[1] >= 4))
data->submenuYpos[1] = 0;
}
data->optionArrows.currentDigit = data->submenuYpos[1];
@ -1609,7 +1609,7 @@ static void Handle_Input_Debug_Pokemon(u8 taskId)
{
if (data->submenuYpos[1] == 0)
{
if (gFormSpeciesIdTables[SpeciesToNationalPokedexNum(data->currentmonId)] != NULL)
if (GetFormSpeciesTable(data->currentmonId) != NULL)
data->submenuYpos[1] = 3;
else
data->submenuYpos[1] = 2;