Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document pokedex_data #321

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions include/pokedex_data.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#ifndef POKEPLATINUM_POKEDEX_DATA_H
#define POKEPLATINUM_POKEDEX_DATA_H

#include "struct_decls/pokedexdata_decl.h"

#include "pokemon.h"
#include "savedata.h"

int PokedexData_SaveSize(void);
PokedexData *PokedexData_Alloc(u32 heapID);
void PokedexData_Copy(const PokedexData *src, PokedexData *dest);
void PokedexData_Init(PokedexData *pokedexData);
u16 PokedexData_CountCaught_National(const PokedexData *pokedexData);
u16 PokedexData_CountSeen_National(const PokedexData *pokedexData);
u16 PokedexData_CountSeen(const PokedexData *pokedexData);
u16 PokedexData_CountCaught_Local(const PokedexData *pokedexData);
u16 PokedexData_CountSeen_Local(const PokedexData *pokedexData);
BOOL PokedexData_NationalDexCompleted(const PokedexData *pokedexData);
BOOL PokedexData_LocalDexCompleted(const PokedexData *pokedexData);
u16 PokedexData_NumCaught_National(const PokedexData *pokedexData);
u16 PokedexData_NumCaught_Local(const PokedexData *pokedexData);
BOOL PokedexData_HasCaughtSpecies(const PokedexData *pokedexData, u16 species);
BOOL PokedexData_HasSeenSpecies(const PokedexData *pokedexData, u16 species);
u32 PokedexData_GetForm_Spinda(const PokedexData *pokedexData, u8 formIndex);
u32 PokedexData_DisplayedGender(const PokedexData *pokedexData, u16 species, int displaySecondary);
u32 PokedexData_GetForm_Unown(const PokedexData *pokedexData, int formIndex);
u32 PokedexData_NumFormsSeen_Unown(const PokedexData *pokedexData);
u32 PokedexData_GetForm_Shellos(const PokedexData *pokedexData, int formIndex);
u32 PokedexData_NumFormsSeen_Shellos(const PokedexData *pokedexData);
u32 PokedexData_GetForm_Gastrodon(const PokedexData *pokedexData, int formIndex);
u32 PokedexData_NumFormsSeen_Gastrodon(const PokedexData *pokedexData);
u32 PokedexData_GetForm_Burmy(const PokedexData *pokedexData, int formIndex);
u32 PokedexData_NumFormsSeen_Burmy(const PokedexData *pokedexData);
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_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);
void PokedexData_TurnOnFormDetection(PokedexData *pokedexData);
BOOL PokedexData_IsLanguageObtained(const PokedexData *pokedexData, u16 species, u32 languageIndex);
void PokedexData_TurnOnLanguageDetection(PokedexData *pokedexData);
BOOL PokedexData_CanDetectLanguages(const PokedexData *pokedexData);
BOOL PokedexData_IsObtained(const PokedexData *pokedexData);
void PokedexData_ObtainPokedex(PokedexData *pokedexData);
PokedexData *SaveData_PokedexData(SaveData *saveData);
u32 PokedexData_GetDisplayForm(const PokedexData *pokedexData, int species, int formIndex);
u32 PokedexData_NumFormsSeen(const PokedexData *pokedexData, int species);

#endif // POKEPLATINUM_POKEDEX_DATA_H
53 changes: 0 additions & 53 deletions include/unk_0202631C.h

This file was deleted.

2 changes: 1 addition & 1 deletion platinum.us/main.lsf
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ Static main
Object main.nef.p/src_unk_0202602C.c.o
Object main.nef.p/src_unk_02026150.c.o
Object main.nef.p/src_unk_020261E4.c.o
Object main.nef.p/src_unk_0202631C.c.o
Object main.nef.p/src_pokedex_data.c.o
Object main.nef.p/src_savedata_misc.c.o
Object main.nef.p/src_game_options.c.o
Object main.nef.p/src_berry_patches.c.o
Expand Down
8 changes: 4 additions & 4 deletions src/battle/ov16_0223B140.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
#include "overlay_manager.h"
#include "palette.h"
#include "party.h"
#include "pokedex_data.h"
#include "pokemon.h"
#include "render_text.h"
#include "render_window.h"
Expand All @@ -80,7 +81,6 @@
#include "unk_0201E3D8.h"
#include "unk_0202419C.h"
#include "unk_02024220.h"
#include "unk_0202631C.h"
#include "unk_0202F1D4.h"
#include "unk_02033200.h"
#include "unk_020363E8.h"
Expand Down Expand Up @@ -731,7 +731,7 @@ static void ov16_0223BCB4(OverlayManager *param0)
sub_02015760(v0->unk_1AC);
Bag_Copy(v0->unk_58, v1->bag);
Heap_FreeToHeap(v0->unk_58);
Pokedex_Copy(v0->pokedex, v1->pokedex);
PokedexData_Copy(v0->pokedex, v1->pokedex);
Heap_FreeToHeap(v0->pokedex);

v1->pcBoxes = v0->pcBoxes;
Expand Down Expand Up @@ -1084,8 +1084,8 @@ static void ov16_0223C2C0(BattleSystem *param0, FieldBattleDTO *param1)
param0->unk_58 = Bag_New(5);

Bag_Copy(param1->bag, param0->unk_58);
param0->pokedex = sub_02026324(5);
Pokedex_Copy(param1->pokedex, param0->pokedex);
param0->pokedex = PokedexData_Alloc(5);
PokedexData_Copy(param1->pokedex, param0->pokedex);

param0->pcBoxes = param1->pcBoxes;
param0->unk_1B0 = param1->options;
Expand Down
10 changes: 5 additions & 5 deletions src/battle/ov16_0223DF00.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
#include "message.h"
#include "palette.h"
#include "party.h"
#include "pokedex_data.h"
#include "pokemon.h"
#include "poketch_data.h"
#include "render_text.h"
Expand All @@ -69,7 +70,6 @@
#include "unk_02005474.h"
#include "unk_0200F174.h"
#include "unk_02014A84.h"
#include "unk_0202631C.h"
#include "unk_0202F1D4.h"
#include "unk_0206CCB0.h"

Expand Down 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))) {
sub_020272A4(param0->pokedex, v1);
PokedexData_Encounter(param0->pokedex, v1);
}
}

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

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

sub_0202736C(param0->pokedex, v1);
PokedexData_Capture(param0->pokedex, v1);
}
}
}
}

BOOL BattleSystem_CaughtSpecies(BattleSystem *battleSys, int species)
{
return Pokedex_HasCaughtSpecies(battleSys->pokedex, species);
return PokedexData_HasCaughtSpecies(battleSys->pokedex, species);
}

void Battle_SetDefaultBlend(void)
Expand Down
24 changes: 12 additions & 12 deletions src/field_battle_data_transfer.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include "message.h"
#include "party.h"
#include "player_avatar.h"
#include "pokedex_data.h"
#include "pokemon.h"
#include "poketch_data.h"
#include "rtc.h"
Expand All @@ -49,7 +50,6 @@
#include "system_flags.h"
#include "trainer_info.h"
#include "unk_0202602C.h"
#include "unk_0202631C.h"
#include "unk_02027F84.h"
#include "unk_0202C858.h"
#include "unk_0202CC64.h"
Expand Down Expand Up @@ -105,7 +105,7 @@ FieldBattleDTO *FieldBattleDTO_New(enum HeapId heapID, u32 battleType)
}

dto->bag = Bag_New(heapID);
dto->pokedex = sub_02026324(heapID);
dto->pokedex = PokedexData_Alloc(heapID);
dto->options = Options_New(heapID);
dto->unk_10C = sub_0206D140(heapID);
dto->bagCursor = NULL;
Expand Down Expand Up @@ -243,7 +243,7 @@ void FieldBattleDTO_InitFromGameState(FieldBattleDTO *dto, const FieldSystem *fi
TrainerInfo *trainerInfo = SaveData_GetTrainerInfo(save);
Party *party = Party_GetFromSavedata(save);
Bag *bag = SaveData_GetBag(save);
PokedexData *pokedex = SaveData_Pokedex(save);
PokedexData *pokedex = SaveData_PokedexData(save);
ChatotCry *chatotCry = GetChatotCryDataFromSave(save);
Options *options = SaveData_Options(save);
FieldOverworldState *fieldOverworldState = SaveData_GetFieldOverworldState(save);
Expand All @@ -262,7 +262,7 @@ void FieldBattleDTO_InitFromGameState(FieldBattleDTO *dto, const FieldSystem *fi
FieldBattleDTO_CopyTrainerInfoToBattler(dto, trainerInfo, BATTLER_PLAYER_SLOT_1);
FieldBattleDTO_CopyPartyToBattler(dto, party, BATTLER_PLAYER_SLOT_1);
Bag_Copy(bag, dto->bag);
Pokedex_Copy(pokedex, dto->pokedex);
PokedexData_Copy(pokedex, dto->pokedex);
Options_Copy(options, dto->options);
FieldBattleDTO_CopyChatotCryToBattler(dto, chatotCry, BATTLER_PLAYER_SLOT_1);

Expand Down Expand Up @@ -296,7 +296,7 @@ void FieldBattleDTO_InitWithNormalizedMonLevels(FieldBattleDTO *dto, const Field
TrainerInfo *trainerInfo = SaveData_GetTrainerInfo(fieldSystem->saveData);
Party *party = Party_GetFromSavedata(fieldSystem->saveData);
Bag *bag = SaveData_GetBag(fieldSystem->saveData);
PokedexData *pokedex = SaveData_Pokedex(fieldSystem->saveData);
PokedexData *pokedex = SaveData_PokedexData(fieldSystem->saveData);
ChatotCry *chatotCry = GetChatotCryDataFromSave(fieldSystem->saveData);
Options *options = SaveData_Options(fieldSystem->saveData);

Expand All @@ -321,7 +321,7 @@ void FieldBattleDTO_InitWithNormalizedMonLevels(FieldBattleDTO *dto, const Field
Heap_FreeToHeap(mon);

Bag_Copy(bag, dto->bag);
Pokedex_Copy(pokedex, dto->pokedex);
PokedexData_Copy(pokedex, dto->pokedex);
Options_Copy(options, dto->options);
FieldBattleDTO_CopyChatotCryToBattler(dto, chatotCry, BATTLER_PLAYER_SLOT_1);

Expand All @@ -344,7 +344,7 @@ void FieldBattleDTO_InitWithPartyOrder(FieldBattleDTO *dto, const FieldSystem *f
{
TrainerInfo *trainerInfo = SaveData_GetTrainerInfo(fieldSystem->saveData);
Bag *bag = SaveData_GetBag(fieldSystem->saveData);
PokedexData *pokedex = SaveData_Pokedex(fieldSystem->saveData);
PokedexData *pokedex = SaveData_PokedexData(fieldSystem->saveData);
ChatotCry *chatotCry = GetChatotCryDataFromSave(fieldSystem->saveData);
Options *options = SaveData_Options(fieldSystem->saveData);
const BattleRegulation *regulation = fieldSystem->unk_B0;
Expand Down Expand Up @@ -387,7 +387,7 @@ void FieldBattleDTO_InitWithPartyOrder(FieldBattleDTO *dto, const FieldSystem *f
}

Bag_Copy(bag, dto->bag);
Pokedex_Copy(pokedex, dto->pokedex);
PokedexData_Copy(pokedex, dto->pokedex);
Options_Copy(options, dto->options);
FieldBattleDTO_CopyChatotCryToBattler(dto, chatotCry, BATTLER_PLAYER_SLOT_1);

Expand Down Expand Up @@ -424,13 +424,13 @@ void FieldBattleDTO_UpdateFieldSystem(const FieldBattleDTO *dto, FieldSystem *fi
TrainerInfo *trainerInfo = SaveData_GetTrainerInfo(fieldSystem->saveData);
Party *party = Party_GetFromSavedata(fieldSystem->saveData);
Bag *bag = SaveData_GetBag(fieldSystem->saveData);
PokedexData *pokedex = SaveData_Pokedex(fieldSystem->saveData);
PokedexData *pokedex = SaveData_PokedexData(fieldSystem->saveData);
u16 *fieldSysSafariBalls = FieldOverworldState_GetSafariBallCount(SaveData_GetFieldOverworldState(fieldSystem->saveData));

TrainerInfo_Copy(dto->trainerInfo[BATTLER_PLAYER_SLOT_1], trainerInfo);
Party_cpy(dto->parties[BATTLER_PLAYER_SLOT_1], party);
Bag_Copy(dto->bag, bag);
Pokedex_Copy(dto->pokedex, pokedex);
PokedexData_Copy(dto->pokedex, pokedex);

*fieldSysSafariBalls = dto->countSafariBalls;
}
Expand All @@ -440,9 +440,9 @@ void FieldBattleDTO_UpdatePokedex(const FieldBattleDTO *dto, FieldSystem *fieldS
TrainerInfo *trainerInfo = SaveData_GetTrainerInfo(fieldSystem->saveData);
Party *party = Party_GetFromSavedata(fieldSystem->saveData);
Bag *bag = SaveData_GetBag(fieldSystem->saveData);
PokedexData *pokedex = SaveData_Pokedex(fieldSystem->saveData);
PokedexData *pokedex = SaveData_PokedexData(fieldSystem->saveData);

Pokedex_Copy(dto->pokedex, pokedex);
PokedexData_Copy(dto->pokedex, pokedex);
}

static const enum Terrain sTerrainForBackground[] = {
Expand Down
10 changes: 5 additions & 5 deletions src/field_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
#include "narc.h"
#include "party.h"
#include "player_avatar.h"
#include "pokedex_data.h"
#include "pokemon.h"
#include "poketch_data.h"
#include "render_window.h"
Expand All @@ -69,7 +70,6 @@
#include "unk_0200C6E4.h"
#include "unk_0200F174.h"
#include "unk_02014A84.h"
#include "unk_0202631C.h"
#include "unk_02028124.h"
#include "unk_0202D778.h"
#include "unk_02033200.h"
Expand Down Expand Up @@ -360,7 +360,7 @@ static u32 sub_0203ABD0(FieldSystem *fieldSystem)
{
u32 v0 = 0;

if (Pokedex_IsObtained(SaveData_Pokedex(fieldSystem->saveData)) == FALSE) {
if (PokedexData_IsObtained(SaveData_PokedexData(fieldSystem->saveData)) == FALSE) {
v0 |= 0x1;
}

Expand Down Expand Up @@ -949,7 +949,7 @@ static BOOL FieldMenu_Pokedex(FieldTask *taskMan)
fieldSystem = FieldTask_GetFieldSystem(taskMan);
menu = FieldTask_GetEnv(taskMan);
v2 = Heap_AllocFromHeap(11, sizeof(UnkStruct_ov21_021D0D80));
v3 = SaveData_Pokedex(fieldSystem->saveData);
v3 = SaveData_PokedexData(fieldSystem->saveData);
v4 = SaveData_GetTrainerInfo(fieldSystem->saveData);
v5 = SaveData_GetVarsFlags(fieldSystem->saveData);

Expand Down Expand Up @@ -1930,9 +1930,9 @@ static void FieldMenu_EvolveInit(FieldTask *taskMan)
v4 = Party_GetPokemonBySlotIndex(v3, v2->unk_00);

if (v2->unk_01 == 0) {
v5 = sub_0207AE68(v3, v4, v2->unk_04, SaveData_Options(fieldSystem->saveData), PokemonSummaryScreen_ShowContestData(fieldSystem->saveData), SaveData_Pokedex(fieldSystem->saveData), SaveData_GetBag(fieldSystem->saveData), SaveData_GetGameRecordsPtr(fieldSystem->saveData), SaveData_PoketchData(fieldSystem->saveData), v2->unk_08, 0x1, 73);
v5 = sub_0207AE68(v3, v4, v2->unk_04, SaveData_Options(fieldSystem->saveData), PokemonSummaryScreen_ShowContestData(fieldSystem->saveData), SaveData_PokedexData(fieldSystem->saveData), SaveData_GetBag(fieldSystem->saveData), SaveData_GetGameRecordsPtr(fieldSystem->saveData), SaveData_PoketchData(fieldSystem->saveData), v2->unk_08, 0x1, 73);
} else {
v5 = sub_0207AE68(v3, v4, v2->unk_04, SaveData_Options(fieldSystem->saveData), PokemonSummaryScreen_ShowContestData(fieldSystem->saveData), SaveData_Pokedex(fieldSystem->saveData), SaveData_GetBag(fieldSystem->saveData), SaveData_GetGameRecordsPtr(fieldSystem->saveData), SaveData_PoketchData(fieldSystem->saveData), v2->unk_08, NULL, 73);
v5 = sub_0207AE68(v3, v4, v2->unk_04, SaveData_Options(fieldSystem->saveData), PokemonSummaryScreen_ShowContestData(fieldSystem->saveData), SaveData_PokedexData(fieldSystem->saveData), SaveData_GetBag(fieldSystem->saveData), SaveData_GetGameRecordsPtr(fieldSystem->saveData), SaveData_PoketchData(fieldSystem->saveData), v2->unk_08, NULL, 73);
}

{
Expand Down
4 changes: 2 additions & 2 deletions src/game_records.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include "game_records.h"
#include "math.h"
#include "unk_0202631C.h"
#include "pokedex_data.h"

#define START_ENCODED_RECORDS RECORD_TRAINER_SCORE
#define SIZE_ENCODED_RECORDS (sizeof(GameRecords) - sizeof(EncodingSeed) - (START_ENCODED_RECORDS * sizeof(u32)))
Expand Down Expand Up @@ -409,7 +409,7 @@ u32 GameRecords_GetTrainerScore(GameRecords *records)

void GameRecords_IncrementTrainerScoreOnCatch(GameRecords *records, const PokedexData *pokedex, const u16 species)
{
if (!Pokedex_HasCaughtSpecies(pokedex, species)) {
if (!PokedexData_HasCaughtSpecies(pokedex, species)) {
GameRecords_IncrementTrainerScore(records, TRAINER_SCORE_EVENT_CAUGHT_SPECIES);
}
}
2 changes: 1 addition & 1 deletion src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ pokeplatinum_c = files(
'unk_0202602C.c',
'unk_02026150.c',
'unk_020261E4.c',
'unk_0202631C.c',
'pokedex_data.c',
'savedata_misc.c',
'game_options.c',
'berry_patches.c',
Expand Down
Loading
Loading