Skip to content

Commit

Permalink
Clarified Names
Browse files Browse the repository at this point in the history
Within PokedexData <species>Forms -> <species>FormsSeen
for pokemon with multiple forms
  • Loading branch information
h2o-DS committed Dec 29, 2024
1 parent 5236914 commit 2daced4
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 70 deletions.
4 changes: 2 additions & 2 deletions include/pokedex_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ u32 PokedexData_GetForm_Wormadam(const PokedexData *pokedexData, int formIndex);
u32 PokedexData_NumFormsSeen_Wormadam(const PokedexData *pokedexData);
u32 PokedexData_GetForm_Deoxys(const PokedexData *pokedexData, int formIndex);
u32 PokedexData_NumFormsSeen_Deoxys(const PokedexData *pokedexData);
void PokedexData_CaptureEntry(PokedexData *pokedexData, Pokemon *pokemon);
void PokedexData_TradeEntry(PokedexData *pokedexData, Pokemon *pokemon);
void PokedexData_Encounter(PokedexData *pokedexData, Pokemon *pokemon);
void PokedexData_Capture(PokedexData *pokedexData, Pokemon *pokemon);
void PokedexData_ObtainNationalDex(PokedexData *pokedexData);
BOOL PokedexData_IsNationalDexObtained(const PokedexData *pokedexData);
BOOL PokedexData_CanDetectForms(const PokedexData *pokedexData);
Expand Down
6 changes: 3 additions & 3 deletions src/battle/ov16_0223DF00.c
Original file line number Diff line number Diff line change
Expand Up @@ -1690,12 +1690,12 @@ void BattleSystem_DexFlagSeen(BattleSystem *param0, int param1)

if ((param0->battleType & (0x4 | 0x80)) == 0) {
if ((v0 & 0x1) || (param0->battleType == (0x2 | 0x8 | 0x40)) || (param0->battleType == ((0x2 | 0x1) | 0x8 | 0x40))) {
PokedexData_CaptureEntry(param0->pokedex, v1);
PokedexData_Encounter(param0->pokedex, v1);
}
}

if (((v0 & 0x1) == 0) && (Pokemon_GetValue(v1, MON_DATA_SPECIES_EGG, NULL) == 412)) {
PokedexData_TradeEntry(param0->pokedex, v1);
PokedexData_Capture(param0->pokedex, v1);
}
}

Expand All @@ -1714,7 +1714,7 @@ void ov16_0223F9A0(BattleSystem *param0, int param1)
v2 = BattleContext_Get(param0, param0->battleCtx, 2, param1);
v1 = BattleSystem_PartyPokemon(param0, param1, v2);

PokedexData_TradeEntry(param0->pokedex, v1);
PokedexData_Capture(param0->pokedex, v1);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/overlay005/ov5_021F6454.c
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ BOOL ScrCmd_304(ScriptContext *param0)
v4 = Party_GetPokemonBySlotIndex(v5, v7);

Pokemon_SetRotomForm(v4, v10, v8);
PokedexData_TradeEntry(SaveData_PokedexData(fieldSystem->saveData), v4);
PokedexData_Capture(SaveData_PokedexData(fieldSystem->saveData), v4);

return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion src/overlay118/ov118_021D0D80.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ int ov118_021D0DBC(GameWindowLayout *param0)
break;
}

PokedexData_TradeEntry(SaveData_PokedexData(FieldSystem_GetSaveData(param0->unk_5A4->unk_1C)), v1);
PokedexData_Capture(SaveData_PokedexData(FieldSystem_GetSaveData(param0->unk_5A4->unk_1C)), v1);
}
v0->unk_00++;
break;
Expand Down
110 changes: 54 additions & 56 deletions src/pokedex_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,20 @@ typedef struct PokedexData {
u32 caughtPokemon[DEX_SIZE_U32];
u32 seenPokemon[DEX_SIZE_U32];
u32 recordedGenders[2][DEX_SIZE_U32];
u32 spindaForms;
u8 shellosForms;
u8 gastrodonForms;
u8 burmyForms;
u8 wormadamForms;
u8 unownForms[UNOWN_COUNT];
u32 spindaForm;
u8 shellosFormsSeen;
u8 gastrodonFormsSeen;
u8 burmyFormsSeen;
u8 wormadamFormsSeen;
u8 unownFormsSeen[UNOWN_COUNT];
u8 recordedLanguages[MAX_SPECIES + 1];
u8 canDetectForms;
u8 canDetectLanguages;
u8 pokedexObtained;
u8 nationalDexObtained;
u32 rotomForms;
u8 shayminForms;
u8 giratinaForms;
u32 rotomFormsSeen;
u8 shayminFormsSeen;
u8 giratinaFormsSeen;
} PokedexData;

int PokedexData_SaveSize(void)
Expand Down Expand Up @@ -160,7 +160,7 @@ static inline u8 GetGender(const PokedexData *pokedexData, u16 species, u8 bitIn
static inline void SetForm_Spinda(PokedexData *pokedexData, u16 species, u32 personality)
{
if (species == SPECIES_SPINDA) {
pokedexData->spindaForms = personality;
pokedexData->spindaForm = personality;
}
}

Expand All @@ -169,7 +169,7 @@ static int NumFormsSeen_Unown(const PokedexData *pokedexData)
int formIndex;

for (formIndex = 0; formIndex < UNOWN_COUNT; formIndex++) {
if (pokedexData->unownForms[formIndex] == TERMINAL_U8) {
if (pokedexData->unownFormsSeen[formIndex] == TERMINAL_U8) {
break;
}
}
Expand All @@ -180,7 +180,7 @@ static int NumFormsSeen_Unown(const PokedexData *pokedexData)
static BOOL UnownFormSeen(const PokedexData *pokedexData, u8 form)
{
for (int formIndex = 0; formIndex < UNOWN_COUNT; formIndex++) {
if (pokedexData->unownForms[formIndex] == form) {
if (pokedexData->unownFormsSeen[formIndex] == form) {
return TRUE;
}
}
Expand All @@ -197,7 +197,7 @@ static void SetUnownForm(PokedexData *pokedexData, int form)
int numUnownSeen = NumFormsSeen_Unown(pokedexData);

if (numUnownSeen < UNOWN_COUNT) {
pokedexData->unownForms[numUnownSeen] = form;
pokedexData->unownFormsSeen[numUnownSeen] = form;
}
}

Expand All @@ -212,16 +212,16 @@ static int NumFormsSeen_TwoForms(const PokedexData *pokedexData, u32 species)
const u8 *formArray;
switch (species) {
case SPECIES_SHELLOS:
formArray = &pokedexData->shellosForms;
formArray = &pokedexData->shellosFormsSeen;
break;
case SPECIES_GASTRODON:
formArray = &pokedexData->gastrodonForms;
formArray = &pokedexData->gastrodonFormsSeen;
break;
case SPECIES_SHAYMIN:
formArray = &pokedexData->shayminForms;
formArray = &pokedexData->shayminFormsSeen;
break;
case SPECIES_GIRATINA:
formArray = &pokedexData->giratinaForms;
formArray = &pokedexData->giratinaFormsSeen;
break;
}

Expand All @@ -246,16 +246,16 @@ static BOOL FormSeen_TwoForms(const PokedexData *pokedexData, u32 species, u8 fo
const u8 *formArray;
switch (species) {
case SPECIES_SHELLOS:
formArray = &pokedexData->shellosForms;
formArray = &pokedexData->shellosFormsSeen;
break;
case SPECIES_GASTRODON:
formArray = &pokedexData->gastrodonForms;
formArray = &pokedexData->gastrodonFormsSeen;
break;
case SPECIES_SHAYMIN:
formArray = &pokedexData->shayminForms;
formArray = &pokedexData->shayminFormsSeen;
break;
case SPECIES_GIRATINA:
formArray = &pokedexData->giratinaForms;
formArray = &pokedexData->giratinaFormsSeen;
break;
}

Expand Down Expand Up @@ -283,16 +283,16 @@ static void UpdateForms_TwoForms(PokedexData *pokedexData, u32 species, int form
u8 *formArray;
switch (species) {
case SPECIES_SHELLOS:
formArray = &pokedexData->shellosForms;
formArray = &pokedexData->shellosFormsSeen;
break;
case SPECIES_GASTRODON:
formArray = &pokedexData->gastrodonForms;
formArray = &pokedexData->gastrodonFormsSeen;
break;
case SPECIES_SHAYMIN:
formArray = &pokedexData->shayminForms;
formArray = &pokedexData->shayminFormsSeen;
break;
case SPECIES_GIRATINA:
formArray = &pokedexData->giratinaForms;
formArray = &pokedexData->giratinaFormsSeen;
break;
}

Expand All @@ -317,9 +317,9 @@ static int NumFormsSeen_ThreeForms(const PokedexData *pokedexData, u32 species)

const u8 *formArray;
if (species == SPECIES_BURMY) {
formArray = &pokedexData->burmyForms;
formArray = &pokedexData->burmyFormsSeen;
} else {
formArray = &pokedexData->wormadamForms;
formArray = &pokedexData->wormadamFormsSeen;
}

int formIndex;
Expand All @@ -344,9 +344,9 @@ static BOOL FormSeen_ThreeForms(const PokedexData *pokedexData, u32 species, u8

const u8 *formArray;
if (species == SPECIES_BURMY) {
formArray = &pokedexData->burmyForms;
formArray = &pokedexData->burmyFormsSeen;
} else {
formArray = &pokedexData->wormadamForms;
formArray = &pokedexData->wormadamFormsSeen;
}

for (int formIndex = 0; formIndex < 3; formIndex++) {
Expand All @@ -370,9 +370,9 @@ static void UpdateForms_ThreeForms(PokedexData *pokedexData, u32 species, int fo

u8 *formArray;
if (species == SPECIES_BURMY) {
formArray = &pokedexData->burmyForms;
formArray = &pokedexData->burmyFormsSeen;
} else {
formArray = &pokedexData->wormadamForms;
formArray = &pokedexData->wormadamFormsSeen;
}

int numFormsSeen = NumFormsSeen_ThreeForms(pokedexData, species);
Expand Down Expand Up @@ -409,9 +409,7 @@ static void UpdateFormArray_Deoxys(PokedexData *pokedexData, u8 form, u8 bitInde
static inline u32 ReadBit_Deoxys(const u32 *array, u8 bitIndex)
{
u32 bitOffset = (24 + (bitIndex * 4));
u32 form = (array[DEX_SIZE_U32 - 1] >> bitOffset) & 0xf;

return form;
return (array[DEX_SIZE_U32 - 1] >> bitOffset) & 0xf;
}

static u32 GetForm_Deoxys(const PokedexData *pokedexData, u8 formIndex)
Expand Down Expand Up @@ -498,7 +496,7 @@ static int NumFormsSeen_Rotom(const PokedexData *pokedexData, u32 species)
int numFormsSeen = 0;

for (formIndex = 0; formIndex < ROTOM_COUNT; formIndex++) {
form = ReadBit_Rotom(pokedexData->rotomForms, formIndex);
form = ReadBit_Rotom(pokedexData->rotomFormsSeen, formIndex);

if (form != TERMINAL_4BITS) {
numFormsSeen++;
Expand All @@ -522,7 +520,7 @@ static BOOL FormSeen_Rotom(const PokedexData *pokedexData, u32 species, u8 form)
u32 numFormsSeen = NumFormsSeen_Rotom(pokedexData, species);

for (formIndex = 0; formIndex < numFormsSeen; formIndex++) {
u32 rotomForm = ReadBit_Rotom(pokedexData->rotomForms, formIndex);
u32 rotomForm = ReadBit_Rotom(pokedexData->rotomFormsSeen, formIndex);

if (rotomForm == form) {
return TRUE;
Expand All @@ -545,7 +543,7 @@ static void UpdateForms_Rotom(PokedexData *pokedexData, u32 species, int form)
numFormsSeen = NumFormsSeen_Rotom(pokedexData, species);

if (numFormsSeen < ROTOM_COUNT) {
SetBit_Rotom(&pokedexData->rotomForms, numFormsSeen, form);
SetBit_Rotom(&pokedexData->rotomFormsSeen, numFormsSeen, form);
}
}

Expand Down Expand Up @@ -638,7 +636,7 @@ static u32 GetDisplayGender(const PokedexData *pokedexData, u16 species, int dis

static inline int GetForm_Unown(const PokedexData *pokedexData, int formIndex)
{
return pokedexData->unownForms[formIndex];
return pokedexData->unownFormsSeen[formIndex];
}

static int GetForm_TwoForms(const PokedexData *pokedexData, u32 species, int formIndex)
Expand All @@ -650,16 +648,16 @@ static int GetForm_TwoForms(const PokedexData *pokedexData, u32 species, int for

switch (species) {
case SPECIES_SHELLOS:
formArray = &pokedexData->shellosForms;
formArray = &pokedexData->shellosFormsSeen;
break;
case SPECIES_GASTRODON:
formArray = &pokedexData->gastrodonForms;
formArray = &pokedexData->gastrodonFormsSeen;
break;
case SPECIES_SHAYMIN:
formArray = &pokedexData->shayminForms;
formArray = &pokedexData->shayminFormsSeen;
break;
case SPECIES_GIRATINA:
formArray = &pokedexData->giratinaForms;
formArray = &pokedexData->giratinaFormsSeen;
break;
}

Expand All @@ -671,7 +669,7 @@ static int GetForm_Rotom(const PokedexData *pokedexData, u32 species, int formIn
GF_ASSERT(species == SPECIES_ROTOM);
GF_ASSERT(formIndex < ROTOM_COUNT);

return ReadBit_Rotom(pokedexData->rotomForms, formIndex);
return ReadBit_Rotom(pokedexData->rotomFormsSeen, formIndex);
}

static int GetForm_3Forms(const PokedexData *pokedexData, u32 species, int formIndex)
Expand All @@ -682,9 +680,9 @@ static int GetForm_3Forms(const PokedexData *pokedexData, u32 species, int formI
GF_ASSERT(formIndex < 3);

if (species == SPECIES_BURMY) {
formArray = &pokedexData->burmyForms;
formArray = &pokedexData->burmyFormsSeen;
} else {
formArray = &pokedexData->wormadamForms;
formArray = &pokedexData->wormadamFormsSeen;
}

return ReadBit_3Forms(formArray, formIndex);
Expand Down Expand Up @@ -731,15 +729,15 @@ void PokedexData_Init(PokedexData *pokedexData)
pokedexData->magic = MAGIC_NUMBER;
pokedexData->nationalDexObtained = FALSE;

memset(pokedexData->unownForms, TERMINAL_U8, sizeof(u8) * UNOWN_COUNT);
memset(pokedexData->unownFormsSeen, TERMINAL_U8, sizeof(u8) * UNOWN_COUNT);

pokedexData->shellosForms = TERMINAL_U8;
pokedexData->gastrodonForms = TERMINAL_U8;
pokedexData->burmyForms = TERMINAL_U8;
pokedexData->wormadamForms = TERMINAL_U8;
pokedexData->rotomForms = TERMINAL_U32;
pokedexData->shayminForms = TERMINAL_U8;
pokedexData->giratinaForms = TERMINAL_U8;
pokedexData->shellosFormsSeen = TERMINAL_U8;
pokedexData->gastrodonFormsSeen = TERMINAL_U8;
pokedexData->burmyFormsSeen = TERMINAL_U8;
pokedexData->wormadamFormsSeen = TERMINAL_U8;
pokedexData->rotomFormsSeen = TERMINAL_U32;
pokedexData->shayminFormsSeen = TERMINAL_U8;
pokedexData->giratinaFormsSeen = TERMINAL_U8;

InitDeoxys(pokedexData);
}
Expand Down Expand Up @@ -903,7 +901,7 @@ u32 PokedexData_GetForm_Spinda(const PokedexData *pokedexData, u8 formIndex)
u32 form;
switch (formIndex) {
case 0:
form = pokedexData->spindaForms;
form = pokedexData->spindaForm;
break;
default:
GF_ASSERT(FALSE);
Expand Down Expand Up @@ -1025,7 +1023,7 @@ u32 PokedexData_NumFormsSeen_Deoxys(const PokedexData *pokedexData)
return NumFormsSeen_Deoxys(pokedexData);
}

void PokedexData_CaptureEntry(PokedexData *pokedexData, Pokemon *pokemon)
void PokedexData_Encounter(PokedexData *pokedexData, Pokemon *pokemon)
{
u16 species = Pokemon_GetValue(pokemon, MON_DATA_SPECIES, NULL);
u32 personality = Pokemon_GetValue(pokemon, MON_DATA_PERSONALITY, NULL);
Expand All @@ -1052,7 +1050,7 @@ void PokedexData_CaptureEntry(PokedexData *pokedexData, Pokemon *pokemon)
Write_SeenSpecies(pokedexData, species);
}

void PokedexData_TradeEntry(PokedexData *pokedexData, Pokemon *pokemon)
void PokedexData_Capture(PokedexData *pokedexData, Pokemon *pokemon)
{
u16 species = Pokemon_GetValue(pokemon, MON_DATA_SPECIES, NULL);
u32 language = Pokemon_GetValue(pokemon, MON_DATA_LANGUAGE, NULL);
Expand Down
6 changes: 3 additions & 3 deletions src/scrcmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -6773,7 +6773,7 @@ static void sub_020451B4(FieldSystem *fieldSystem, u16 param1)

Pokemon_Init(v1);
Pokemon_InitWith(v1, param1, 50, 32, FALSE, 0, OTID_NOT_SET, 0);
PokedexData_CaptureEntry(v0, v1);
PokedexData_Encounter(v0, v1);
Heap_FreeToHeap(v1);

return;
Expand Down Expand Up @@ -6896,7 +6896,7 @@ static BOOL ScrCmd_263(ScriptContext *ctx)
if (v3 == SPECIES_DEOXYS) {
Pokemon_SetValue(v5, MON_DATA_FORM, &v0);
Pokemon_CalcLevelAndStats(v5);
PokedexData_TradeEntry(v6, v5);
PokedexData_Capture(v6, v5);
}
}

Expand Down Expand Up @@ -8333,7 +8333,7 @@ static BOOL ScrCmd_328(ScriptContext *ctx)
v5 = Party_GetPokemonBySlotIndex(v1, v3);

if ((Pokemon_GetValue(v5, MON_DATA_IS_EGG, NULL) == 0) && (Pokemon_GetValue(v5, MON_DATA_SPECIES, NULL) == SPECIES_GIRATINA)) {
PokedexData_TradeEntry(SaveData_PokedexData(fieldSystem->saveData), v5);
PokedexData_Capture(SaveData_PokedexData(fieldSystem->saveData), v5);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/unk_0202F180.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ void sub_0202F180(SaveData *param0, const Pokemon *param1)
PokedexData *v0 = SaveData_PokedexData(param0);

GameRecords_IncrementTrainerScoreOnCatch(SaveData_GetGameRecordsPtr(param0), v0, Pokemon_GetValue((Pokemon *)param1, MON_DATA_SPECIES, NULL));
PokedexData_TradeEntry(v0, (Pokemon *)param1);
PokedexData_Capture(v0, (Pokemon *)param1);
PoketchData_PokemonHistoryEnqueue(SaveData_PoketchData(param0), (const BoxPokemon *)param1);
}
}
Loading

0 comments on commit 2daced4

Please sign in to comment.