From bffc52cf4822e2a83532cceff186175b8c2ea7db Mon Sep 17 00:00:00 2001 From: h2o-DS Date: Sat, 19 Oct 2024 23:15:03 -0400 Subject: [PATCH] Improved make tool Improved efficiency of make_enc_platinum.py Improved access of files in other folders Renamed UnkStruct_ov21_021D5890 to fieldCoordinates Renamed UnkStruct_ov21_021D5868 to dungeonCoordinates Added enums for caughtStatus and encounter gategory Removed redundant struct UnkStruct_ov21_021D0D80_1 --- include/overlay021/ov21_021D0D80.h | 4 +- include/overlay021/ov21_021D517C.h | 14 +- include/overlay021/ov21_021D57B4.h | 44 +- include/overlay021/ov21_021DC9BC.h | 6 + include/overlay021/pokedex_sort.h | 10 +- .../overlay021/struct_dungeoncoordinates.h | 11 + include/overlay021/struct_fieldcoordinates.h | 12 + include/overlay021/struct_ov21_021D0D80_1.h | 20 - include/overlay021/struct_ov21_021D3320.h | 6 +- include/overlay021/struct_ov21_021D37DC.h | 9 - include/overlay021/struct_ov21_021D3A60.h | 4 +- include/overlay021/struct_ov21_021D5844.h | 6 +- include/overlay021/struct_ov21_021D5868.h | 11 - include/overlay021/struct_ov21_021D5890.h | 12 - include/overlay021/struct_ov21_021E6A68.h | 4 +- .../overlay021/struct_speciescaughtstatus.h | 15 + include/unk_0202631C.h | 2 +- .../zukanlist/zkn_data/meson.build | 11 +- src/overlay021/ov21_021D0D80.c | 17 +- src/overlay021/ov21_021D517C.c | 207 ++--- src/overlay021/ov21_021D57B4.c | 156 ++-- src/overlay021/ov21_021D5AEC.c | 28 +- src/overlay021/ov21_021DC9BC.c | 774 +++++++++--------- src/overlay021/pokedex_sort.c | 26 +- src/scrcmd.c | 2 +- src/unk_0202631C.c | 2 +- tools/scripts/make_pokedex_data.py | 10 +- tools/scripts/make_pokedex_enc_platinum.py | 257 +++--- 28 files changed, 868 insertions(+), 812 deletions(-) create mode 100644 include/overlay021/struct_dungeoncoordinates.h create mode 100644 include/overlay021/struct_fieldcoordinates.h delete mode 100644 include/overlay021/struct_ov21_021D0D80_1.h delete mode 100644 include/overlay021/struct_ov21_021D37DC.h delete mode 100644 include/overlay021/struct_ov21_021D5868.h delete mode 100644 include/overlay021/struct_ov21_021D5890.h create mode 100644 include/overlay021/struct_speciescaughtstatus.h diff --git a/include/overlay021/ov21_021D0D80.h b/include/overlay021/ov21_021D0D80.h index 067ccaea33..e6d2c53526 100644 --- a/include/overlay021/ov21_021D0D80.h +++ b/include/overlay021/ov21_021D0D80.h @@ -6,7 +6,7 @@ #include "struct_decls/struct_02018340_decl.h" #include "struct_defs/struct_0205AA50.h" -#include "overlay021/struct_ov21_021D0D80_1.h" +#include "overlay021/struct_ov21_021D0D80.h" #include "overlay021/struct_ov21_021D0F60_decl.h" #include "overlay021/struct_ov21_021D13FC.h" #include "overlay021/struct_ov21_021D157C.h" @@ -26,7 +26,7 @@ int ov21_021D0D80(OverlayManager *param0, int *param1); int ov21_021D0E3C(OverlayManager *param0, int *param1); int ov21_021D0EC8(OverlayManager *param0, int *param1); -UnkStruct_ov21_021D0F60 *ov21_021D0F60(int param0, const UnkStruct_ov21_021D0D80_1 *param1); +UnkStruct_ov21_021D0F60 *ov21_021D0F60(int param0, const UnkStruct_ov21_021D0D80 *param1); BOOL ov21_021D10B8(UnkStruct_ov21_021D0F60 *param0); void ov21_021D12B0(int param0); void ov21_021D12C4(void); diff --git a/include/overlay021/ov21_021D517C.h b/include/overlay021/ov21_021D517C.h index 56b0ae29b0..26316d6f3d 100644 --- a/include/overlay021/ov21_021D517C.h +++ b/include/overlay021/ov21_021D517C.h @@ -3,7 +3,19 @@ #include "struct_defs/struct_0205AA50.h" +enum CellNeighbors { + CN_ALONE = 0, + CN_WEST = (1 << 0), + CN_EAST = (1 << 1), + CN_SOUTH = (1 << 2), + CN_NORTH = (1 << 3), + CN_SOUTHWEST = (1 << 4), + CN_NORTHWEST = (1 << 5), + CN_SOUTHEAST = (1 << 6), + CN_NORTHEAST = (1 << 7), +}; + void ov21_021D517C(Window *param0, u8 *param1, u16 param2, u16 param3, u8 param4, u8 *param5, u8 param6, u8 param7, u16 param8, u16 param9); -void ov21_021D5214(u8 *param0, u8 param1, u8 param2); +void MapFieldCellMatrix_SmoothCells(u8 *mapFieldCellMatrix, u8 mapHeight, u8 mapWidth); #endif // POKEPLATINUM_OV21_021D517C_H diff --git a/include/overlay021/ov21_021D57B4.h b/include/overlay021/ov21_021D57B4.h index 96b8cc26af..d957302ff1 100644 --- a/include/overlay021/ov21_021D57B4.h +++ b/include/overlay021/ov21_021D57B4.h @@ -1,19 +1,43 @@ #ifndef POKEPLATINUM_OV21_021D57B4_H #define POKEPLATINUM_OV21_021D57B4_H +#include "overlay021/struct_dungeoncoordinates.h" +#include "overlay021/struct_fieldCoordinates.h" #include "overlay021/struct_ov21_021D5844.h" -#include "overlay021/struct_ov21_021D5868.h" -#include "overlay021/struct_ov21_021D5890.h" #include "cell_actor.h" -void ov21_021D57B4(pokedexEncStruct *dexEncData, int param1, int param2, int param3); -void Free_pokedexEncData(pokedexEncStruct *dexEncData); -UnkStruct_ov21_021D5868 *ov21_021D5868(int param0, int *param1); -UnkStruct_ov21_021D5890 *ov21_021D5890(int param0, int *param1); -void ov21_021D58C0(u8 *param0, u8 param1, u8 param2, const UnkStruct_ov21_021D5890 *param3); -u32 ov21_021D5948(u8 *param0, int param1, int param2, const UnkStruct_ov21_021D5890 *param3, const pokedexEncStruct *dexEncData, const u8 *param5, u32 param6); -void ov21_021D59D8(CellActor *param0, int param1, int param2, int param3, int param4, const UnkStruct_ov21_021D5868 *param5, int param6, int param7); -int ov21_021D5A20(CellActor **param0, int param1, int param2, int param3, int param4, int param5, int param6, const UnkStruct_ov21_021D5868 *param7, const pokedexEncStruct *dexEncData, int param9, int param10, const u8 *param11, u32 param12, u32 *param13); +#define PEFI_DUNGEONMORNING 4 +#define PEFI_DUNGEONDAY (4 + MAX_SPECIES) +#define PEFI_DUNGEONNIGHT (4 + MAX_SPECIES * 2) +#define PEFI_DUNGEONSPECIAL (4 + MAX_SPECIES * 3) +#define PEFI_DUNGEONSPECIALNATDEX (4 + MAX_SPECIES * 4) +#define PEFI_FIELDMORNING (4 + MAX_SPECIES * 5) +#define PEFI_FIELDDAY (4 + MAX_SPECIES * 6) +#define PEFI_FIELDNIGHT (4 + MAX_SPECIES * 7) +#define PEFI_FIELDSPECIAL (4 + MAX_SPECIES * 8) +#define PEFI_FIELDSPECIALNATDEX (4 + MAX_SPECIES * 9) + +enum PokedexEncFileCatgegory { + PEFC_DUNGEONMORNING = 0, + PEFC_DUNGEONDAY = 1, + PEFC_DUNGEONNIGHT = 2, + PEFC_DUNGEONSPECIAL = 3, + PEFC_DUNGEONSPECIALNATDEX = 4, + PEFC_FIELDMORNING = 5, + PEFC_FIELDDAY = 6, + PEFC_FIELDNIGHT = 7, + PEFC_FIELDSPECIAL = 8, + PEFC_FIELDSPECIALNATDEX = 9, +}; + +void PokedexEncData_PopulateMapsEncounteredOn(mapsEncounteredOn *mapsEncOn, int species, int encounterCategory, int heapID); +void PokedexEncData_FreeMapsEncounteredOn(mapsEncounteredOn *mapsEncOn); +dungeonCoordinates *PokedexEncData_GetDungeonLocations(int heapID, int *numDungeons); +fieldCoordinates *PokedexEncData_GetFieldLocations(int heapID, int *numFields); +void ov21_021D58C0(u8 *param0, u8 param1, u8 param2, const fieldCoordinates *param3); +u32 ov21_021D5948(u8 *param0, int param1, int param2, const fieldCoordinates *param3, const mapsEncounteredOn *mapsEncOn, const u8 *param5, u32 param6); +void ov21_021D59D8(CellActor *param0, int param1, int param2, int param3, int param4, const dungeonCoordinates *param5, int param6, int param7); +int ov21_021D5A20(CellActor **param0, int param1, int param2, int param3, int param4, int param5, int param6, const dungeonCoordinates *param7, const mapsEncounteredOn *mapsEncOn, int param9, int param10, const u8 *param11, u32 param12, u32 *param13); #endif // POKEPLATINUM_OV21_021D57B4_H diff --git a/include/overlay021/ov21_021DC9BC.h b/include/overlay021/ov21_021DC9BC.h index 8e35b79d3d..9c8bffc362 100644 --- a/include/overlay021/ov21_021DC9BC.h +++ b/include/overlay021/ov21_021DC9BC.h @@ -4,6 +4,12 @@ #include "overlay021/struct_ov21_021D0F60_decl.h" #include "overlay021/struct_ov21_021E68F4.h" +#define POKEDEXMAPXSCALE 5 +#define POKEDEXMAPYSCALE 5 +#define POKEDEXMAPHEIGHT 30 +#define POKEDEXMAPWIDTH 30 +#define POKEDEXMAPNUMCELLS (POKEDEXMAPHEIGHT * POKEDEXMAPWIDTH) + void ov21_021DC9BC(UnkStruct_ov21_021E68F4 *param0, UnkStruct_ov21_021D0F60 *param1, int heapID); void ov21_021DCA14(UnkStruct_ov21_021E68F4 *param0); int ov21_021DCA28(const UnkStruct_ov21_021E68F4 *param0); diff --git a/include/overlay021/pokedex_sort.h b/include/overlay021/pokedex_sort.h index e332e51098..dc2ec2bef3 100644 --- a/include/overlay021/pokedex_sort.h +++ b/include/overlay021/pokedex_sort.h @@ -1,9 +1,9 @@ -#ifndef POKEPLATINUM_OV21_021D3208_H -#define POKEPLATINUM_OV21_021D3208_H +#ifndef POKEPLATINUM_POKEDEX_SORT_H +#define POKEPLATINUM_POKEDEX_SORT_H #include "overlay021/struct_ov21_021D3208.h" #include "overlay021/struct_ov21_021D3320.h" -#include "overlay021/struct_ov21_021D37DC.h" +#include "overlay021/struct_speciesCaughtStatus.h" #include "strbuf.h" @@ -40,7 +40,7 @@ int ov21_021D3770(const pokedexStruct *param0, u32 param1); BOOL ov21_021D3794(pokedexStruct *param0, int param1); int Pokedex_Sort_CurrentSpecies(const pokedexStruct *param0); int Pokedex_Sort_CurrentCaughtStatus(const pokedexStruct *param0); -const speciesCaughtStatusStruct *Pokedex_Sort_SpeciesCaughtStatus(const pokedexStruct *param0, int dexIndex); +const speciesCaughtStatus *Pokedex_Sort_SpeciesCaughtStatus(const pokedexStruct *param0, int dexIndex); BOOL ov21_021D37F8(const pokedexStruct *param0, int param1); BOOL ov21_021D3810(pokedexStruct *param0, int param1); BOOL ov21_021D3844(pokedexStruct *param0, int param1); @@ -58,4 +58,4 @@ BOOL Pokedex_Sort_CanDetectForms(const pokedexStruct *param0); void ov21_021D3960(pokedexStruct *param0); u32 ov21_021D3998(const pokedexStruct *param0); -#endif // POKEPLATINUM_OV21_021D3208_H +#endif // POKEPLATINUM_POKEDEX_SORT_H diff --git a/include/overlay021/struct_dungeoncoordinates.h b/include/overlay021/struct_dungeoncoordinates.h new file mode 100644 index 0000000000..118192470d --- /dev/null +++ b/include/overlay021/struct_dungeoncoordinates.h @@ -0,0 +1,11 @@ +#ifndef POKEPLATINUM_STRUCT_DUNGEONCOORDINATES_H +#define POKEPLATINUM_STRUCT_DUNGEONCOORDINATES_H + +typedef struct { + u8 xCoordinate; + u8 yCoordinate; + u8 unk_02; + u8 unused; +} dungeonCoordinates; + +#endif // POKEPLATINUM_STRUCT_DUNGEONCOORDINATES_H diff --git a/include/overlay021/struct_fieldcoordinates.h b/include/overlay021/struct_fieldcoordinates.h new file mode 100644 index 0000000000..215945648e --- /dev/null +++ b/include/overlay021/struct_fieldcoordinates.h @@ -0,0 +1,12 @@ +#ifndef POKEPLATINUM_STRUCT_FIELDCOORDINATES_H +#define POKEPLATINUM_STRUCT_FIELDCOORDINATES_H + +typedef struct { + u8 yCoordinate; + u8 xCoordinate; + u8 height; + u8 width; + u8 cellMatrix[32]; +} fieldCoordinates; + +#endif // POKEPLATINUM_STRUCT_FIELDCOORDINATES_H diff --git a/include/overlay021/struct_ov21_021D0D80_1.h b/include/overlay021/struct_ov21_021D0D80_1.h deleted file mode 100644 index 731ab5db7b..0000000000 --- a/include/overlay021/struct_ov21_021D0D80_1.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef POKEPLATINUM_STRUCT_OV21_021D0D80_1_H -#define POKEPLATINUM_STRUCT_OV21_021D0D80_1_H - -#include "struct_decls/pokedexdata_decl.h" -#include "struct_decls/struct_0209ACBC_decl.h" - -#include "trainer_info.h" - -typedef struct { - const PokedexData *unk_00; - const TrainerInfo *unk_04; - int timeOfDay; - BOOL pokedexSFlag_1; - BOOL pokedexSFlag_2; - BOOL pokedexSFlag_3; - BOOL pokedexSFlag_4; - UnkStruct_0209ACBC *unk_1C; -} UnkStruct_ov21_021D0D80_1; - -#endif // POKEPLATINUM_STRUCT_OV21_021D0D80_1_H diff --git a/include/overlay021/struct_ov21_021D3320.h b/include/overlay021/struct_ov21_021D3320.h index 083c1476b2..877114353e 100644 --- a/include/overlay021/struct_ov21_021D3320.h +++ b/include/overlay021/struct_ov21_021D3320.h @@ -12,14 +12,14 @@ typedef struct { const PokedexData *dexData; pokedexCompletionStruct pokedexCompletion; int isNationalDex; - BOOL nationalDexUnlocked; + BOOL isNationalDexUnlocked; int numEncountered; int numCaught; int unk_1740; int timeOfDay; HeightWeightData *HWData; - u32 TrainerGameCode; - u32 TrainerGender; + u32 trainerGameCode; + u32 trainerGender; Strbuf *trainerName; int unk_1758; u16 unk_175C; diff --git a/include/overlay021/struct_ov21_021D37DC.h b/include/overlay021/struct_ov21_021D37DC.h deleted file mode 100644 index 80b92500ea..0000000000 --- a/include/overlay021/struct_ov21_021D37DC.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef POKEPLATINUM_STRUCT_OV21_021D37DC_H -#define POKEPLATINUM_STRUCT_OV21_021D37DC_H - -typedef struct { - int species; - int caughtStatus; // 2 for caught, 1 for seen, 0 otherwise -} speciesCaughtStatusStruct; - -#endif // POKEPLATINUM_STRUCT_OV21_021D37DC_H diff --git a/include/overlay021/struct_ov21_021D3A60.h b/include/overlay021/struct_ov21_021D3A60.h index 01d387cfe6..a69ad10740 100644 --- a/include/overlay021/struct_ov21_021D3A60.h +++ b/include/overlay021/struct_ov21_021D3A60.h @@ -3,10 +3,10 @@ #include "constants/species.h" -#include "overlay021/struct_ov21_021D37DC.h" +#include "overlay021/struct_speciesCaughtStatus.h" typedef struct { - speciesCaughtStatusStruct caughtStatusArray[NATIONAL_DEX_COUNT]; + speciesCaughtStatus caughtStatusArray[NATIONAL_DEX_COUNT]; int unk_F68; int numEncountered; // number of pokemon seen int encounteredIndexArray[NATIONAL_DEX_COUNT]; // dex number for appearing in dex, dexLength+1 otherwise diff --git a/include/overlay021/struct_ov21_021D5844.h b/include/overlay021/struct_ov21_021D5844.h index 2dcf08f7fb..d70e3458e0 100644 --- a/include/overlay021/struct_ov21_021D5844.h +++ b/include/overlay021/struct_ov21_021D5844.h @@ -2,8 +2,8 @@ #define POKEPLATINUM_STRUCT_OV21_021D5844_H typedef struct { - int *pokedexEncArray; - int pokedexEncLength; -} pokedexEncStruct; + int *mapsEncounteredOnArray; + int numMapsEncounteredOn; +} mapsEncounteredOn; #endif // POKEPLATINUM_STRUCT_OV21_021D5844_H diff --git a/include/overlay021/struct_ov21_021D5868.h b/include/overlay021/struct_ov21_021D5868.h deleted file mode 100644 index 1fb797dcfc..0000000000 --- a/include/overlay021/struct_ov21_021D5868.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef POKEPLATINUM_STRUCT_OV21_021D5868_H -#define POKEPLATINUM_STRUCT_OV21_021D5868_H - -typedef struct { - u8 unk_00; - u8 unk_01; - u8 unk_02; - u8 unk_03; -} UnkStruct_ov21_021D5868; - -#endif // POKEPLATINUM_STRUCT_OV21_021D5868_H diff --git a/include/overlay021/struct_ov21_021D5890.h b/include/overlay021/struct_ov21_021D5890.h deleted file mode 100644 index 4280e97b43..0000000000 --- a/include/overlay021/struct_ov21_021D5890.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef POKEPLATINUM_STRUCT_OV21_021D5890_H -#define POKEPLATINUM_STRUCT_OV21_021D5890_H - -typedef struct { - u8 unk_00; - u8 unk_01; - u8 unk_02; - u8 unk_03; - u8 unk_04[32]; -} UnkStruct_ov21_021D5890; - -#endif // POKEPLATINUM_STRUCT_OV21_021D5890_H diff --git a/include/overlay021/struct_ov21_021E6A68.h b/include/overlay021/struct_ov21_021E6A68.h index fae833d051..20852a1991 100644 --- a/include/overlay021/struct_ov21_021E6A68.h +++ b/include/overlay021/struct_ov21_021E6A68.h @@ -1,9 +1,11 @@ #ifndef POKEPLATINUM_STRUCT_OV21_021E6A68_H #define POKEPLATINUM_STRUCT_OV21_021E6A68_H +#include "constants/heap.h" + typedef struct { int unk_00; - int heapID; + enum HeapId heapID; void *unk_08; BOOL unk_0C; BOOL unk_10; diff --git a/include/overlay021/struct_speciescaughtstatus.h b/include/overlay021/struct_speciescaughtstatus.h new file mode 100644 index 0000000000..98f690a002 --- /dev/null +++ b/include/overlay021/struct_speciescaughtstatus.h @@ -0,0 +1,15 @@ +#ifndef POKEPLATINUM_STRUCT_SPECIESCAUGHTSTATUS_H +#define POKEPLATINUM_STRUCT_SPECIESCAUGHTSTATUS_H + +enum CaughtStatus { + CS_UNENCOUNTERED = 0, + CS_ENCOUNTERED = 1, + CS_CAUGHT = 2, +}; + +typedef struct { + int species; + enum CaughtStatus caughtStatus; +} speciesCaughtStatus; + +#endif // POKEPLATINUM_STRUCT_SPECIESCAUGHTSTATUS_H diff --git a/include/unk_0202631C.h b/include/unk_0202631C.h index 9d6f2c5f50..8bd9e4aafd 100644 --- a/include/unk_0202631C.h +++ b/include/unk_0202631C.h @@ -40,7 +40,7 @@ void sub_0202736C(PokedexData *dexData, Pokemon *param1); void sub_02027454(PokedexData *dexData); BOOL Pokedex_NationalUnlocked(const PokedexData *dexData); BOOL Pokedex_CanDetectForms(const PokedexData *dexData); -void Pokedex_CanDetectForms_True(PokedexData *dexData); +void Pokedex_TurnOnFormDetection(PokedexData *dexData); BOOL sub_020274D0(const PokedexData *dexData, u16 param1, u32 param2); void sub_02027508(PokedexData *dexData); BOOL sub_02027514(const PokedexData *dexData); diff --git a/res/prebuilt/application/zukanlist/zkn_data/meson.build b/res/prebuilt/application/zukanlist/zkn_data/meson.build index ae91d0fc68..d6c47529ec 100644 --- a/res/prebuilt/application/zukanlist/zkn_data/meson.build +++ b/res/prebuilt/application/zukanlist/zkn_data/meson.build @@ -8,7 +8,8 @@ foreach f : prebuilt_files endforeach personal_files = [] -sinnoh_pokedex = files('../../../../pokemon/sinnoh_pokedex.json') +pokemon_folder = meson.project_source_root() / 'res' / 'pokemon' +encounter_folder = meson.project_source_root() / 'res' / 'field' / 'encounters' # Generate NARCs pokedex_data_narc = custom_target('zukan_data.narc', @@ -19,10 +20,9 @@ pokedex_data_narc = custom_target('zukan_data.narc', command: [ make_pokedex_data_py, '--knarc', knarc_exe, - '--source-dir', '@CURRENT_SOURCE_DIR@', + '--source-dir', pokemon_folder, '--private-dir', '@PRIVATE_DIR@', '--output-dir', '@OUTDIR@', - sinnoh_pokedex, 'giratina_origin' ] ) @@ -35,10 +35,9 @@ pokedex_data_giratina_altered_narc = custom_target('zukan_data_gira.narc', command: [ make_pokedex_data_py, '--knarc', knarc_exe, - '--source-dir', '@CURRENT_SOURCE_DIR@', + '--source-dir', pokemon_folder, '--private-dir', '@PRIVATE_DIR@', '--output-dir', '@OUTDIR@', - sinnoh_pokedex, 'giratina_altered' ] ) @@ -51,7 +50,7 @@ pokedex_enc_platinum_narc = custom_target('zukan_enc_platinum.narc', command: [ make_pokedex_enc_platinum_py, '--knarc', knarc_exe, - '--source-dir', '@CURRENT_SOURCE_DIR@', + '--source-dir', encounter_folder, '--private-dir', '@PRIVATE_DIR@', '--output-dir', '@OUTDIR@' ] diff --git a/src/overlay021/ov21_021D0D80.c b/src/overlay021/ov21_021D0D80.c index 7a093577ab..92dfab1f60 100644 --- a/src/overlay021/ov21_021D0D80.c +++ b/src/overlay021/ov21_021D0D80.c @@ -36,13 +36,11 @@ #include "overlay021/ov21_021E8484.h" #include "overlay021/pokedex_sort.h" #include "overlay021/struct_ov21_021D0D80.h" -#include "overlay021/struct_ov21_021D0D80_1.h" #include "overlay021/struct_ov21_021D13FC.h" #include "overlay021/struct_ov21_021D157C.h" #include "overlay021/struct_ov21_021D22F8.h" #include "overlay021/struct_ov21_021D3208.h" #include "overlay021/struct_ov21_021D3320.h" -#include "overlay021/struct_ov21_021D37DC.h" #include "overlay021/struct_ov21_021D3FE0_decl.h" #include "overlay021/struct_ov21_021D423C_decl.h" #include "overlay021/struct_ov21_021D4660.h" @@ -50,6 +48,7 @@ #include "overlay021/struct_ov21_021D4CA0.h" #include "overlay021/struct_ov21_021D4CB8.h" #include "overlay021/struct_ov21_021E68F4.h" +#include "overlay021/struct_speciesCaughtStatus.h" #include "overlay022/struct_ov22_022559F8.h" #include "cell_actor.h" @@ -121,7 +120,7 @@ int ov21_021D0D80(OverlayManager *param0, int *param1) { UnkStruct_ov21_021D0F18 *v0; UnkStruct_ov21_021D0D80 *v1; - UnkStruct_ov21_021D0D80_1 v2; + UnkStruct_ov21_021D0D80 v2; BOOL v3; sub_02004550(54, 0, 0); @@ -298,7 +297,7 @@ const static UnkFuncPtr_ov21_021E9B9C Unk_ov21_021E9B54[8] = { ov21_021E84E4 }; -UnkStruct_ov21_021D0F60 *ov21_021D0F60(int param0, const UnkStruct_ov21_021D0D80_1 *param1) +UnkStruct_ov21_021D0F60 *ov21_021D0F60(int param0, const UnkStruct_ov21_021D0D80 *param1) { UnkStruct_ov21_021D0F60 *v0; int v1; @@ -724,10 +723,10 @@ void ov21_021D1778(UnkStruct_ov21_021D13FC *param0, const pokedexStruct *param1, Window *v3; SpriteResource *v4; VecFx32 v5; - const speciesCaughtStatusStruct *speciesCaughtStatus; + const speciesCaughtStatus *pokeCaughtStatus; u32 v7 = ov21_021D36D8(param1); - speciesCaughtStatus = Pokedex_Sort_SpeciesCaughtStatus(param1, dexIndex); + pokeCaughtStatus = Pokedex_Sort_SpeciesCaughtStatus(param1, dexIndex); v0 = ov21_021D22A8(param0); v1 = ov21_021D22C4(param0); @@ -737,7 +736,7 @@ void ov21_021D1778(UnkStruct_ov21_021D13FC *param0, const pokedexStruct *param1, CellActor_SetPosition(v0, &v5); CellActor_SetDrawFlag(v0, 1); - if (speciesCaughtStatus->caughtStatus == 2) { + if (pokeCaughtStatus->caughtStatus == CS_CAUGHT) { v5.x = param4 + (-54 * FX32_ONE); v5.y = param5; @@ -759,10 +758,10 @@ void ov21_021D1778(UnkStruct_ov21_021D13FC *param0, const pokedexStruct *param1, v2.unk_20 = NNS_G2D_VRAM_TYPE_2DMAIN; v2.unk_24 = param2; - v3 = ov21_021D16D8(param0, param1, param2, speciesCaughtStatus->species); + v3 = ov21_021D16D8(param0, param1, param2, pokeCaughtStatus->species); v2.unk_04 = v3; - ov21_021D22E0(param0, &v2, 0, speciesCaughtStatus->species, v7); + ov21_021D22E0(param0, &v2, 0, pokeCaughtStatus->species, v7); ov21_021D4DA0(v3); } diff --git a/src/overlay021/ov21_021D517C.c b/src/overlay021/ov21_021D517C.c index 5c41f0d5e0..cd1ddb650f 100644 --- a/src/overlay021/ov21_021D517C.c +++ b/src/overlay021/ov21_021D517C.c @@ -7,265 +7,266 @@ #include "unk_02018340.h" -static void ov21_021D5248(Window *param0, u8 *param1, u16 param2, u16 param3, int param4, int param5, u8 param6, u8 param7); -static void ov21_021D52A0(u8 *param0, int param1, int param2, int param3, int param4); -static int ov21_021D52D4(u8 *param0, int param1, int param2, int param3, int param4); -static void ov21_021D5304(u8 *param0, int *param1, int param2, int param3, int param4, int param5); -static int ov21_021D5424(int param0); +static void ov21_021D5248(Window *param0, u8 *param1, u16 cellWidth, u16 cellHeight, int mapScale, int cellType, u8 yCoord, u8 xCoord); +static void MapFieldCellMatrix_CellType(u8 *mapFieldCellMatrix, int y, int x, int mapHeight, int mapWidth); +static int MapFieldCellMatrix_Value(u8 *mapFieldCellMatrix, int y, int x, int mapHeight, int mapWidth); +static void MapFieldCellMatrix_NeighboringCells(u8 *mapFieldCellMatrix, int *neighbors, int y, int x, int mapHeight, int mapWidth); +static int MapFieldCellMatrix_EmptyCellType(int neighbors); -void ov21_021D517C(Window *param0, u8 *param1, u16 param2, u16 param3, u8 param4, u8 *param5, u8 param6, u8 param7, u16 param8, u16 param9) +void ov21_021D517C(Window *param0, u8 *param1, u16 cellWidth, u16 cellHeight, u8 mapScale, u8 *mapFieldCellMatrix, u8 mapHeight, u8 mapWidth, u16 yOffset, u16 xOffset) { - int v0, v1; + int x, y; - for (v0 = 0; v0 < param7; v0++) { - for (v1 = 0; v1 < param6; v1++) { - ov21_021D5248(param0, param1, param2, param3, param4, param5[(v0 * param7) + v1], param8 + (v1 * param4), param9 + (v0 * param4)); + for (x = 0; x < mapWidth; x++) { + for (y = 0; y < mapHeight; y++) { + ov21_021D5248(param0, param1, cellWidth, cellHeight, mapScale, mapFieldCellMatrix[(x * mapWidth) + y], yOffset + (y * mapScale), xOffset + (x * mapScale)); } } } -void ov21_021D5214(u8 *param0, u8 param1, u8 param2) +void MapFieldCellMatrix_SmoothCells(u8 *mapFieldCellMatrix, u8 mapHeight, u8 mapWidth) { - int v0, v1; + int x, y; - for (v0 = 0; v0 < param2; v0++) { - for (v1 = 0; v1 < param1; v1++) { - ov21_021D52A0(param0, v1, v0, param1, param2); + for (x = 0; x < mapWidth; x++) { + for (y = 0; y < mapHeight; y++) { + MapFieldCellMatrix_CellType(mapFieldCellMatrix, y, x, mapHeight, mapWidth); } } } -static void ov21_021D5248(Window *param0, u8 *param1, u16 param2, u16 param3, int param4, int param5, u8 param6, u8 param7) +static void ov21_021D5248(Window *param0, u8 *param1, u16 cellWidth, u16 cellHeight, int mapScale, int cellType, u8 yCoord, u8 xCoord) { int v0; int v1; - if (param5 != 0) { - v0 = param5 * param4; - v1 = v0 / param2; - v0 = v0 % param2; + if (cellType != 0) { + v0 = cellType * mapScale; + v1 = v0 / cellWidth; + v0 = v0 % cellWidth; - sub_0201ADDC(param0, param1, v0, v1, param2, param3, param6, param7, param4, param4); + sub_0201ADDC(param0, param1, v0, v1, cellWidth, cellHeight, yCoord, xCoord, mapScale, mapScale); } } -static void ov21_021D52A0(u8 *param0, int param1, int param2, int param3, int param4) +static void MapFieldCellMatrix_CellType(u8 *mapFieldCellMatrix, int y, int x, int mapHeight, int mapWidth) { - int v0; - int v1; + int neighbors; + int cellType; - if (param0[(param2 * param3) + param1] == 0) { - ov21_021D5304(param0, &v0, param1, param2, param3, param4); + if (mapFieldCellMatrix[(x * mapHeight) + y] == 0) { + MapFieldCellMatrix_NeighboringCells(mapFieldCellMatrix, &neighbors, y, x, mapHeight, mapWidth); - v1 = ov21_021D5424(v0); - param0[(param2 * param3) + param1] = v1; + cellType = MapFieldCellMatrix_EmptyCellType(neighbors); + mapFieldCellMatrix[(x * mapHeight) + y] = cellType; } } -static int ov21_021D52D4(u8 *param0, int param1, int param2, int param3, int param4) +static int MapFieldCellMatrix_Value(u8 *mapFieldCellMatrix, int y, int x, int mapHeight, int mapWidth) { - if ((param1 < 0) || (param1 >= param3)) { + if ((y < 0) || (y >= mapHeight)) { return -1; } - if ((param2 < 0) || (param2 >= param4)) { + if ((x < 0) || (x >= mapWidth)) { return -1; } - return param0[(param2 * param3) + param1]; + return mapFieldCellMatrix[(x * mapHeight) + y]; } -static void ov21_021D5304(u8 *param0, int *param1, int param2, int param3, int param4, int param5) +static void MapFieldCellMatrix_NeighboringCells(u8 *mapFieldCellMatrix, int *neighbors, int y, int x, int mapHeight, int mapWidth) { int v0; - *param1 = 0; + *neighbors = 0; // binary storage of cells (NE)(SE)(NW)(SW)(N)(S)(E)(W) + // only records intercardinal directions if adjacent cardinals are both empty - if (ov21_021D52D4(param0, param2, param3 - 1, param4, param5) == 1) { - *param1 |= (1 << 0); + if (MapFieldCellMatrix_Value(mapFieldCellMatrix, y, x - 1, mapHeight, mapWidth) == 1) { + *neighbors |= CN_WEST; } - if (ov21_021D52D4(param0, param2, param3 + 1, param4, param5) == 1) { - *param1 |= (1 << 1); + if (MapFieldCellMatrix_Value(mapFieldCellMatrix, y, x + 1, mapHeight, mapWidth) == 1) { + *neighbors |= CN_EAST; } - if (ov21_021D52D4(param0, param2 - 1, param3, param4, param5) == 1) { - *param1 |= (1 << 2); + if (MapFieldCellMatrix_Value(mapFieldCellMatrix, y - 1, x, mapHeight, mapWidth) == 1) { + *neighbors |= CN_SOUTH; } - if (ov21_021D52D4(param0, param2 + 1, param3, param4, param5) == 1) { - *param1 |= (1 << 3); + if (MapFieldCellMatrix_Value(mapFieldCellMatrix, y + 1, x, mapHeight, mapWidth) == 1) { + *neighbors |= CN_NORTH; } - if ((((*param1) & (1 << 0)) == 0) && (((*param1) & (1 << 2)) == 0)) { - if (ov21_021D52D4(param0, param2 - 1, param3 - 1, param4, param5) == 1) { - *param1 |= (1 << 4); + if ((((*neighbors) & CN_WEST) == 0) && (((*neighbors) & CN_SOUTH) == 0)) { + if (MapFieldCellMatrix_Value(mapFieldCellMatrix, y - 1, x - 1, mapHeight, mapWidth) == 1) { + *neighbors |= CN_SOUTHWEST; } } - if ((((*param1) & (1 << 0)) == 0) && (((*param1) & (1 << 3)) == 0)) { - if (ov21_021D52D4(param0, param2 + 1, param3 - 1, param4, param5) == 1) { - *param1 |= (1 << 5); + if ((((*neighbors) & CN_WEST) == 0) && (((*neighbors) & CN_NORTH) == 0)) { + if (MapFieldCellMatrix_Value(mapFieldCellMatrix, y + 1, x - 1, mapHeight, mapWidth) == 1) { + *neighbors |= CN_NORTHWEST; } } - if ((((*param1) & (1 << 1)) == 0) && (((*param1) & (1 << 2)) == 0)) { - if (ov21_021D52D4(param0, param2 - 1, param3 + 1, param4, param5) == 1) { - *param1 |= (1 << 6); + if ((((*neighbors) & CN_EAST) == 0) && (((*neighbors) & CN_SOUTH) == 0)) { + if (MapFieldCellMatrix_Value(mapFieldCellMatrix, y - 1, x + 1, mapHeight, mapWidth) == 1) { + *neighbors |= CN_SOUTHEAST; } } - if ((((*param1) & (1 << 1)) == 0) && (((*param1) & (1 << 3)) == 0)) { - if (ov21_021D52D4(param0, param2 + 1, param3 + 1, param4, param5) == 1) { - *param1 |= (1 << 7); + if ((((*neighbors) & CN_EAST) == 0) && (((*neighbors) & CN_NORTH) == 0)) { + if (MapFieldCellMatrix_Value(mapFieldCellMatrix, y + 1, x + 1, mapHeight, mapWidth) == 1) { + *neighbors |= CN_NORTHEAST; } } } -static int ov21_021D5424(int param0) +static int MapFieldCellMatrix_EmptyCellType(int neighbors) { int v0; - switch (param0) { - case 0: + switch (neighbors) { + case CN_ALONE: v0 = 0; break; - case ((1 << 0)): + case (CN_WEST): v0 = 2; break; - case ((1 << 1)): + case (CN_EAST): v0 = 3; break; - case ((1 << 2)): + case (CN_SOUTH): v0 = 4; break; - case ((1 << 3)): + case (CN_NORTH): v0 = 5; break; - case ((1 << 0) | (1 << 1)): + case (CN_WEST | CN_EAST): v0 = 6; break; - case ((1 << 0) | (1 << 2)): + case (CN_WEST | CN_SOUTH): v0 = 7; break; - case ((1 << 0) | (1 << 3)): + case (CN_WEST | CN_NORTH): v0 = 8; break; - case ((1 << 1) | (1 << 2)): + case (CN_EAST | CN_SOUTH): v0 = 9; break; - case ((1 << 1) | (1 << 3)): + case (CN_EAST | CN_NORTH): v0 = 10; break; - case ((1 << 2) | (1 << 3)): + case (CN_SOUTH | CN_NORTH): v0 = 11; break; - case ((1 << 0) | (1 << 1) | (1 << 2)): + case (CN_WEST | CN_EAST | CN_SOUTH): v0 = 12; break; - case ((1 << 0) | (1 << 1) | (1 << 3)): + case (CN_WEST | CN_EAST | CN_NORTH): v0 = 13; break; - case ((1 << 0) | (1 << 2) | (1 << 3)): + case (CN_WEST | CN_SOUTH | CN_NORTH): v0 = 14; break; - case ((1 << 1) | (1 << 2) | (1 << 3)): + case (CN_EAST | CN_SOUTH | CN_NORTH): v0 = 15; break; - case ((1 << 0) | (1 << 1) | (1 << 2) | (1 << 3)): + case (CN_WEST | CN_EAST | CN_SOUTH | CN_NORTH): v0 = 16; break; - case ((1 << 4)): + case (CN_SOUTHWEST): v0 = 17; break; - case ((1 << 5)): + case (CN_NORTHWEST): v0 = 18; break; - case ((1 << 6)): + case (CN_SOUTHEAST): v0 = 19; break; - case ((1 << 7)): + case (CN_NORTHEAST): v0 = 20; break; - case ((1 << 4) | (1 << 5)): + case (CN_SOUTHWEST | CN_NORTHWEST): v0 = 21; break; - case ((1 << 4) | (1 << 6)): + case (CN_SOUTHWEST | CN_SOUTHEAST): v0 = 22; break; - case ((1 << 4) | (1 << 7)): + case (CN_SOUTHWEST | CN_NORTHEAST): v0 = 23; break; - case ((1 << 5) | (1 << 6)): + case (CN_NORTHWEST | CN_SOUTHEAST): v0 = 24; break; - case ((1 << 5) | (1 << 7)): + case (CN_NORTHWEST | CN_NORTHEAST): v0 = 25; break; - case ((1 << 6) | (1 << 7)): + case (CN_SOUTHEAST | CN_NORTHEAST): v0 = 26; break; - case ((1 << 4) | (1 << 5) | (1 << 6)): + case (CN_SOUTHWEST | CN_NORTHWEST | CN_SOUTHEAST): v0 = 27; break; - case ((1 << 4) | (1 << 5) | (1 << 7)): + case (CN_SOUTHWEST | CN_NORTHWEST | CN_NORTHEAST): v0 = 28; break; - case ((1 << 4) | (1 << 6) | (1 << 7)): + case (CN_SOUTHWEST | CN_SOUTHEAST | CN_NORTHEAST): v0 = 29; break; - case ((1 << 5) | (1 << 6) | (1 << 7)): + case (CN_NORTHWEST | CN_SOUTHEAST | CN_NORTHEAST): v0 = 30; break; - case ((1 << 4) | (1 << 5) | (1 << 6) | (1 << 7)): + case (CN_SOUTHWEST | CN_NORTHWEST | CN_SOUTHEAST | CN_NORTHEAST): v0 = 31; break; - case ((1 << 0) | (1 << 6) | (1 << 7)): + case (CN_WEST | CN_SOUTHEAST | CN_NORTHEAST): v0 = 32; break; - case ((1 << 1) | (1 << 4) | (1 << 5)): + case (CN_EAST | CN_SOUTHWEST | CN_NORTHWEST): v0 = 33; break; - case ((1 << 2) | (1 << 5) | (1 << 7)): + case (CN_SOUTH | CN_NORTHWEST | CN_NORTHEAST): v0 = 34; break; - case ((1 << 3) | (1 << 4) | (1 << 6)): + case (CN_NORTH | CN_SOUTHWEST | CN_SOUTHEAST): v0 = 35; break; - case ((1 << 0) | (1 << 2) | (1 << 7)): + case (CN_WEST | CN_SOUTH | CN_NORTHEAST): v0 = 36; break; - case ((1 << 0) | (1 << 3) | (1 << 6)): + case (CN_WEST | CN_NORTH | CN_SOUTHEAST): v0 = 37; break; - case ((1 << 1) | (1 << 2) | (1 << 5)): + case (CN_EAST | CN_SOUTH | CN_NORTHWEST): v0 = 38; break; - case ((1 << 1) | (1 << 3) | (1 << 4)): + case (CN_EAST | CN_NORTH | CN_SOUTHWEST): v0 = 39; break; - case ((1 << 0) | (1 << 6)): + case (CN_WEST | CN_SOUTHEAST): v0 = 40; break; - case ((1 << 0) | (1 << 7)): + case (CN_WEST | CN_NORTHEAST): v0 = 41; break; - case ((1 << 1) | (1 << 4)): + case (CN_EAST | CN_SOUTHWEST): v0 = 42; break; - case ((1 << 1) | (1 << 5)): + case (CN_EAST | CN_NORTHWEST): v0 = 43; break; - case ((1 << 2) | (1 << 5)): + case (CN_SOUTH | CN_NORTHWEST): v0 = 44; break; - case ((1 << 2) | (1 << 7)): + case (CN_SOUTH | CN_NORTHEAST): v0 = 45; break; - case ((1 << 3) | (1 << 4)): + case (CN_NORTH | CN_SOUTHWEST): v0 = 46; break; - case ((1 << 3) | (1 << 6)): + case (CN_NORTH | CN_SOUTHEAST): v0 = 47; break; default: diff --git a/src/overlay021/ov21_021D57B4.c b/src/overlay021/ov21_021D57B4.c index 9871dd806d..f4b94e9387 100644 --- a/src/overlay021/ov21_021D57B4.c +++ b/src/overlay021/ov21_021D57B4.c @@ -3,127 +3,129 @@ #include #include +#include "constants/species.h" + +#include "overlay021/struct_dungeoncoordinates.h" +#include "overlay021/struct_fieldCoordinates.h" #include "overlay021/struct_ov21_021D5844.h" -#include "overlay021/struct_ov21_021D5868.h" -#include "overlay021/struct_ov21_021D5890.h" #include "cell_actor.h" #include "heap.h" #include "narc.h" #include "unk_02006E3C.h" -void ov21_021D57B4(pokedexEncStruct *dexEncData, int species, int param2, int heapID) +void PokedexEncData_PopulateMapsEncounteredOn(mapsEncounteredOn *mapsEncOn, int species, int encounterCategory, int heapID) { - int v0; + int fileIndex; u32 fileSize; - switch (param2) { - case 0: // category 0, morning - v0 = 4; + switch (encounterCategory) { + case PEFC_DUNGEONMORNING: + fileIndex = PEFI_DUNGEONMORNING; break; - case 1: // category 0, day - v0 = 499; + case PEFC_DUNGEONDAY: + fileIndex = PEFI_DUNGEONDAY; break; - case 2: // category 0, night - v0 = 994; + case PEFC_DUNGEONNIGHT: + fileIndex = PEFI_DUNGEONNIGHT; break; - case 3: // category 2, regional - v0 = 1489; + case PEFC_DUNGEONSPECIAL: + fileIndex = PEFI_DUNGEONSPECIAL; break; - case 4: // category 2, national - v0 = 1984; + case PEFC_DUNGEONSPECIALNATDEX: + fileIndex = PEFI_DUNGEONSPECIALNATDEX; break; - case 5: // category 1, morning - v0 = 2479; + case PEFC_FIELDMORNING: + fileIndex = PEFI_FIELDMORNING; break; - case 6: // category 1, day - v0 = 2974; + case PEFC_FIELDDAY: + fileIndex = PEFI_FIELDDAY; break; - case 7: // category 1, night - v0 = 3469; + case PEFC_FIELDNIGHT: + fileIndex = PEFI_FIELDNIGHT; break; - case 8: // category 3, regional - v0 = 3964; + case PEFC_FIELDSPECIAL: + fileIndex = PEFI_FIELDSPECIAL; break; - case 9: // category 3, national - v0 = 4459; + case PEFC_FIELDSPECIALNATDEX: + fileIndex = PEFI_FIELDSPECIALNATDEX; break; } - dexEncData->pokedexEncArray = (int *)sub_02007068(NARC_INDEX_APPLICATION__ZUKANLIST__ZKN_DATA__ZUKAN_ENC_PLATINUM, v0 + species, 0, heapID, 0, &fileSize); - dexEncData->pokedexEncLength = fileSize / sizeof(int); + mapsEncOn->mapsEncounteredOnArray = (int *)sub_02007068(NARC_INDEX_APPLICATION__ZUKANLIST__ZKN_DATA__ZUKAN_ENC_PLATINUM, fileIndex + species, 0, heapID, 0, &fileSize); + mapsEncOn->numMapsEncounteredOn = fileSize / sizeof(int); } -void Free_pokedexEncData(pokedexEncStruct *dexEncData) +void PokedexEncData_FreeMapsEncounteredOn(mapsEncounteredOn *mapsEncOn) { - GF_ASSERT(dexEncData); - GF_ASSERT(dexEncData->pokedexEncArray); + GF_ASSERT(mapsEncOn); + GF_ASSERT(mapsEncOn->mapsEncounteredOnArray); - Heap_FreeToHeap(dexEncData->pokedexEncArray); + Heap_FreeToHeap(mapsEncOn->mapsEncounteredOnArray); - dexEncData->pokedexEncArray = NULL; - dexEncData->pokedexEncLength = 0; + mapsEncOn->mapsEncounteredOnArray = NULL; + mapsEncOn->numMapsEncounteredOn = 0; } -UnkStruct_ov21_021D5868 *ov21_021D5868(int heapID, int *param1) +dungeonCoordinates *PokedexEncData_GetDungeonLocations(int heapID, int *numDungeons) { - UnkStruct_ov21_021D5868 *v0; + dungeonCoordinates *dungeonCoordinatesArray; u32 fileSize; - v0 = (UnkStruct_ov21_021D5868 *)sub_02007068(NARC_INDEX_APPLICATION__ZUKANLIST__ZKN_DATA__ZUKAN_ENC_PLATINUM, 0, 0, heapID, 0, &fileSize); + dungeonCoordinatesArray = (dungeonCoordinates *)sub_02007068(NARC_INDEX_APPLICATION__ZUKANLIST__ZKN_DATA__ZUKAN_ENC_PLATINUM, 0, 0, heapID, 0, &fileSize); - if (param1) { - *param1 = fileSize / sizeof(UnkStruct_ov21_021D5868); + if (numDungeons) { + *numDungeons = fileSize / sizeof(dungeonCoordinates); } - return v0; + return dungeonCoordinatesArray; } -UnkStruct_ov21_021D5890 *ov21_021D5890(int heapID, int *param1) +fieldCoordinates *PokedexEncData_GetFieldLocations(int heapID, int *numFields) { - UnkStruct_ov21_021D5890 *v0; + fieldCoordinates *fieldCoordinatesArray; u32 fileSize; - v0 = (UnkStruct_ov21_021D5890 *)sub_02007068(NARC_INDEX_APPLICATION__ZUKANLIST__ZKN_DATA__ZUKAN_ENC_PLATINUM, 2, 0, heapID, 0, &fileSize); + fieldCoordinatesArray = (fieldCoordinates *)sub_02007068(NARC_INDEX_APPLICATION__ZUKANLIST__ZKN_DATA__ZUKAN_ENC_PLATINUM, 2, 0, heapID, 0, &fileSize); - if (param1) { - *param1 = fileSize / sizeof(UnkStruct_ov21_021D5890); + if (numFields) { + *numFields = fileSize / sizeof(fieldCoordinates); } - return v0; + return fieldCoordinatesArray; } -void ov21_021D58C0(u8 *param0, u8 param1, u8 param2, const UnkStruct_ov21_021D5890 *param3) +void ov21_021D58C0(u8 *mapFieldCellMatrix, u8 mapHeight, u8 mapWidth, const fieldCoordinates *fieldCoords) { - int outerIndex, innerIndex; + int xCoord, yCoord; - GF_ASSERT((param3->unk_01 + param3->unk_03) < param2); // param 1 and 2 are 30 - GF_ASSERT((param3->unk_00 + param3->unk_02) < param1); + GF_ASSERT((fieldCoords->xCoordinate + fieldCoords->width) < mapWidth); // param 1 and 2 are 30 + GF_ASSERT((fieldCoords->yCoordinate + fieldCoords->height) < mapHeight); - for (outerIndex = param3->unk_01; outerIndex < param3->unk_01 + param3->unk_03; outerIndex++) { - for (innerIndex = param3->unk_00; innerIndex < param3->unk_00 + param3->unk_02; innerIndex++) { - param0[(outerIndex * param1) + innerIndex] |= param3->unk_04[((outerIndex - param3->unk_01) * param3->unk_02) + (innerIndex - param3->unk_00)]; + for (xCoord = fieldCoords->xCoordinate; xCoord < fieldCoords->xCoordinate + fieldCoords->width; xCoord++) { + for (yCoord = fieldCoords->yCoordinate; yCoord < fieldCoords->yCoordinate + fieldCoords->height; yCoord++) { + mapFieldCellMatrix[(xCoord * mapHeight) + yCoord] |= fieldCoords->cellMatrix[((xCoord - fieldCoords->xCoordinate) * fieldCoords->height) + (yCoord - fieldCoords->yCoordinate)]; } } } -u32 ov21_021D5948(u8 *param0, int param1, int param2, const UnkStruct_ov21_021D5890 *param3, const pokedexEncStruct *dexEncData, const u8 *param5, u32 param6) +u32 ov21_021D5948(u8 *mapFieldCellMatrix, int mapHeight, int mapWidth, const fieldCoordinates *fieldCoordArray, const mapsEncounteredOn *mapsEncOn, const u8 *mapArray, u32 mapArrayLength) { - int pokedexEncIndex; - int v1; + int index; + int mapArrayIndex; u32 v2 = 0; - for (pokedexEncIndex = 0; pokedexEncIndex < dexEncData->pokedexEncLength - 1; pokedexEncIndex++) { - GF_ASSERT(dexEncData->pokedexEncArray[pokedexEncIndex]); + for (index = 0; index < mapsEncOn->numMapsEncounteredOn - 1; index++) { + GF_ASSERT(mapsEncOn->mapsEncounteredOnArray[index]); - for (v1 = 0; v1 < param6; v1++) { - if (dexEncData->pokedexEncArray[pokedexEncIndex] == param5[v1]) { + for (mapArrayIndex = 0; mapArrayIndex < mapArrayLength; mapArrayIndex++) { + if (mapsEncOn->mapsEncounteredOnArray[index] == mapArray[mapArrayIndex]) { break; } } - if (v1 >= param6) { - ov21_021D58C0(param0, param1, param2, ¶m3[dexEncData->pokedexEncArray[pokedexEncIndex]]); + if (mapArrayIndex >= mapArrayLength) { + ov21_021D58C0(mapFieldCellMatrix, mapHeight, mapWidth, &fieldCoordArray[mapsEncOn->mapsEncounteredOnArray[index]]); v2++; } } @@ -131,48 +133,48 @@ u32 ov21_021D5948(u8 *param0, int param1, int param2, const UnkStruct_ov21_021D5 return v2; } -void ov21_021D59D8(CellActor *actor, int param1, int param2, int param3, int param4, const UnkStruct_ov21_021D5868 *param5, int animID_1, int animID_2) +void ov21_021D59D8(CellActor *actor, int xOffset, int yOffset, int xScale, int yScale, const dungeonCoordinates *dungeonCoords, int animID_1, int animID_2) { VecFx32 position; - position.x = (param5->unk_00 * param3) + param1; - position.y = (param5->unk_01 * param4) + param2; + position.x = (dungeonCoords->xCoordinate * xScale) + xOffset; + position.y = (dungeonCoords->yCoordinate * yScale) + yOffset; position.x <<= FX32_SHIFT; position.y <<= FX32_SHIFT; CellActor_SetPosition(actor, &position); - if (param5->unk_02) { + if (dungeonCoords->unk_02) { CellActor_SetAnim(actor, animID_2); } else { CellActor_SetAnim(actor, animID_1); } } -int ov21_021D5A20(CellActor **param0, int param1, int param2, int param3, int param4, int param5, int param6, const UnkStruct_ov21_021D5868 *zukan_enc_plat_0, const pokedexEncStruct *dexEncData, int param9, int param10, const u8 *param11, u32 param12, u32 *param13) +int ov21_021D5A20(CellActor **cellActorArray, int initialNumDungeons, int param2, int xOffset, int yOffset, int xScale, int yScale, const dungeonCoordinates *dungeonCoordinatesArray, const mapsEncounteredOn *mapsEncOn, int animID_1, int animID_2, const u8 *mapArray, u32 mapArrayLength, u32 *param13) { - int index, v1; - int v2 = param1; + int index, mapArrayIndex; + int numDungeons = initialNumDungeons; int v3 = 0; - for (index = 0; index < dexEncData->pokedexEncLength - 1; index++) { - GF_ASSERT(dexEncData->pokedexEncArray[index]); - GF_ASSERT(v2 < param2); + for (index = 0; index < mapsEncOn->numMapsEncounteredOn - 1; index++) { + GF_ASSERT(mapsEncOn->mapsEncounteredOnArray[index]); + GF_ASSERT(numDungeons < param2); - for (v1 = 0; v1 < param12; v1++) { - if (dexEncData->pokedexEncArray[index] == param11[v1]) { + for (mapArrayIndex = 0; mapArrayIndex < mapArrayLength; mapArrayIndex++) { + if (mapsEncOn->mapsEncounteredOnArray[index] == mapArray[mapArrayIndex]) { break; } } - if (v1 >= param12) { - ov21_021D59D8(param0[v2], param3, param4, param5, param6, &zukan_enc_plat_0[dexEncData->pokedexEncArray[index]], param9, param10); - v2++; + if (mapArrayIndex >= mapArrayLength) { + ov21_021D59D8(cellActorArray[numDungeons], xOffset, yOffset, xScale, yScale, &dungeonCoordinatesArray[mapsEncOn->mapsEncounteredOnArray[index]], animID_1, animID_2); + numDungeons++; v3++; } } *param13 = v3; - return v2; + return numDungeons; } diff --git a/src/overlay021/ov21_021D5AEC.c b/src/overlay021/ov21_021D5AEC.c index e80a7ca8e0..792d409249 100644 --- a/src/overlay021/ov21_021D5AEC.c +++ b/src/overlay021/ov21_021D5AEC.c @@ -16,7 +16,6 @@ #include "overlay021/struct_ov21_021D13FC.h" #include "overlay021/struct_ov21_021D157C.h" #include "overlay021/struct_ov21_021D2648.h" -#include "overlay021/struct_ov21_021D37DC.h" #include "overlay021/struct_ov21_021D4660.h" #include "overlay021/struct_ov21_021D4CA0.h" #include "overlay021/struct_ov21_021D4CB8.h" @@ -24,6 +23,7 @@ #include "overlay021/struct_ov21_021E68F4.h" #include "overlay021/struct_ov21_021E6A68.h" #include "overlay021/struct_ov21_021E6B20.h" +#include "overlay021/struct_speciesCaughtStatus.h" #include "cell_actor.h" #include "core_sys.h" @@ -871,7 +871,7 @@ static void ov21_021D67EC(UnkStruct_ov21_021D71A8 *param0, UnkStruct_ov21_021D13 int v3; UnkStruct_ov21_021D4CB8 v4; Window *v5; - const speciesCaughtStatusStruct *speciesCaughtStatus; + const speciesCaughtStatus *pokeCaughtStatus; int dexIndex; v4.unk_00 = param1->unk_14C; @@ -898,8 +898,8 @@ static void ov21_021D67EC(UnkStruct_ov21_021D71A8 *param0, UnkStruct_ov21_021D13 dexIndex = Pokedex_Sort_SeenIndexToSpecies(param2->unk_04, v1); if (dexIndex != (NATIONAL_DEX_COUNT + 1)) { - speciesCaughtStatus = Pokedex_Sort_SpeciesCaughtStatus(param2->unk_04, dexIndex); - v5 = ov21_021D16D8(param1, param2->unk_04, param3, speciesCaughtStatus->species); + pokeCaughtStatus = Pokedex_Sort_SpeciesCaughtStatus(param2->unk_04, dexIndex); + v5 = ov21_021D16D8(param1, param2->unk_04, param3, pokeCaughtStatus->species); v4.unk_04 = v5; param0->unk_28[v2] = ov21_021D4CB8(&v4, param0->unk_4C); ov21_021D4DA0(v5); @@ -919,11 +919,11 @@ static void ov21_021D68C8(UnkStruct_ov21_021D71A8 *param0, UnkStruct_ov21_021D13 { int dexIndex; int v1; - const speciesCaughtStatusStruct *speciesCaughtStatus; + const speciesCaughtStatus *pokeCaughtStatus; v1 = ov21_021D3898(param2->unk_04); dexIndex = ov21_021D375C(param2->unk_04); - speciesCaughtStatus = Pokedex_Sort_SpeciesCaughtStatus(param2->unk_04, dexIndex); + pokeCaughtStatus = Pokedex_Sort_SpeciesCaughtStatus(param2->unk_04, dexIndex); if (Pokedex_Sort_SeenIndexToSpecies(param2->unk_04, v1) == (NATIONAL_DEX_COUNT + 1)) { ov21_021D217C(param1, 0); @@ -932,7 +932,7 @@ static void ov21_021D68C8(UnkStruct_ov21_021D71A8 *param0, UnkStruct_ov21_021D13 CellActor_SetDrawFlag(param0->unk_7C, 1); } } else { - ov21_021D1890(param1, param2->unk_04, speciesCaughtStatus->species, 2, 56, 80); + ov21_021D1890(param1, param2->unk_04, pokeCaughtStatus->species, 2, 56, 80); ov21_021D217C(param1, 1); if (param0->unk_7C) { @@ -1085,7 +1085,7 @@ static void ov21_021D6AE4(UnkStruct_ov21_021D71A8 *param0, const UnkStruct_ov21_ int v5; int v6; int v7; - const speciesCaughtStatusStruct *speciesCaughtStatus; + const speciesCaughtStatus *pokeCaughtStatus; int v9; int v10; int dexIndex; @@ -1103,9 +1103,9 @@ static void ov21_021D6AE4(UnkStruct_ov21_021D71A8 *param0, const UnkStruct_ov21_ dexIndex = Pokedex_Sort_SeenIndexToSpecies(param1->unk_04, v5); if (dexIndex != (NATIONAL_DEX_COUNT + 1)) { - speciesCaughtStatus = Pokedex_Sort_SpeciesCaughtStatus(param1->unk_04, dexIndex); + pokeCaughtStatus = Pokedex_Sort_SpeciesCaughtStatus(param1->unk_04, dexIndex); - if (speciesCaughtStatus->caughtStatus == 2) { + if (pokeCaughtStatus->caughtStatus == CS_CAUGHT) { isCaught = 1; } } @@ -1256,10 +1256,10 @@ static void ov21_021D6D78(UnkStruct_ov21_021D71A8 *param0, UnkStruct_ov21_021D13 { UnkStruct_ov21_021D4CB8 v0; Window *v1; - const speciesCaughtStatusStruct *speciesCaughtStatus; + const speciesCaughtStatus *pokeCaughtStatus; - speciesCaughtStatus = Pokedex_Sort_SpeciesCaughtStatus(param2->unk_04, dexIndex); - GF_ASSERT(speciesCaughtStatus); + pokeCaughtStatus = Pokedex_Sort_SpeciesCaughtStatus(param2->unk_04, dexIndex); + GF_ASSERT(pokeCaughtStatus); v0.unk_00 = param1->unk_14C; v0.unk_08 = param0->unk_90.paletteProxy; @@ -1271,7 +1271,7 @@ static void ov21_021D6D78(UnkStruct_ov21_021D71A8 *param0, UnkStruct_ov21_021D13 v0.unk_20 = NNS_G2D_VRAM_TYPE_2DMAIN; v0.unk_24 = param3; - v1 = ov21_021D16D8(param1, param2->unk_04, param3, speciesCaughtStatus->species); + v1 = ov21_021D16D8(param1, param2->unk_04, param3, pokeCaughtStatus->species); if (param0->unk_28[param4]) { ov21_021D4D1C(param0->unk_28[param4]); diff --git a/src/overlay021/ov21_021DC9BC.c b/src/overlay021/ov21_021DC9BC.c index 29331e8dee..1242fd3262 100644 --- a/src/overlay021/ov21_021DC9BC.c +++ b/src/overlay021/ov21_021DC9BC.c @@ -14,6 +14,8 @@ #include "overlay021/ov21_021D57B4.h" #include "overlay021/ov21_021E29DC.h" #include "overlay021/pokedex_sort.h" +#include "overlay021/struct_dungeoncoordinates.h" +#include "overlay021/struct_fieldCoordinates.h" #include "overlay021/struct_ov21_021D0F60_decl.h" #include "overlay021/struct_ov21_021D13FC.h" #include "overlay021/struct_ov21_021D2648.h" @@ -21,8 +23,6 @@ #include "overlay021/struct_ov21_021D4CA0.h" #include "overlay021/struct_ov21_021D4CB8.h" #include "overlay021/struct_ov21_021D5844.h" -#include "overlay021/struct_ov21_021D5868.h" -#include "overlay021/struct_ov21_021D5890.h" #include "overlay021/struct_ov21_021E68F4.h" #include "overlay021/struct_ov21_021E6A68.h" #include "overlay021/struct_ov21_021E6B20.h" @@ -39,7 +39,7 @@ #include "unk_02018340.h" #include "unk_0201F834.h" -static const u16 Unk_ov21_021E9D78[] = { +static const u16 extraFieldsStructFlag_1[] = { 0xffff }; @@ -47,7 +47,7 @@ static const u16 Unk_ov21_021E9D76[] = { 0xffff }; -static const u16 Unk_ov21_021E9D74[] = { +static const u16 extraFieldsStructFlag_4[] = { 0xffff }; @@ -55,7 +55,7 @@ static const u16 Unk_ov21_021E9D72[] = { 0xffff }; -static const u16 Unk_ov21_021E9D70[] = { +static const u16 extraFieldsStructFlag_2[] = { 0xffff }; @@ -63,7 +63,7 @@ static const u16 Unk_ov21_021E9D6E[] = { 0xffff }; -static const u16 Unk_ov21_021E9D6C[] = { +static const u16 extraFieldsStructFlag_3[] = { 0xffff }; @@ -94,33 +94,33 @@ typedef struct { typedef struct { int encounterTime; - u8 *unk_04; - u8 *unk_08; - u32 heapSize; - u32 unk_10; - pokedexEncStruct dexEnc0; - pokedexEncStruct dexEnc1; - pokedexEncStruct dexEnc2; - pokedexEncStruct dexEnc3; -} UnkStruct_ov21_021DDABC; + u8 *extraFields; + u8 *extraDungeons; + u32 numExtraFields; + u32 numExtraDungeons; + mapsEncounteredOn dungeonsEncounteredOn; + mapsEncounteredOn fieldsEncounteredOn; + mapsEncounteredOn dungeonSpecialEncounters; + mapsEncounteredOn fieldSpecialEncounters; +} encounterCollection; typedef struct { int encounterTime; - CellActor *unk_04[44]; + CellActor *cellActorArray[44]; SpriteResource *unk_B4[4]; - int unk_C4; + int numDungeons; CellActor *unk_C8; UnkStruct_ov21_021D4CA0 *unk_CC; SpriteResource *unk_D0[4]; UnkStruct_ov21_021D4CA0 *unk_E0[3]; - u8 unk_EC[900]; - u8 unk_470[900]; + u8 mapFieldCellMatrix_1[POKEDEXMAPNUMCELLS]; + u8 mapFieldCellMatrix_2[POKEDEXMAPNUMCELLS]; void *unk_7F4; NNSG2dCharacterData *unk_7F8; void *unk_7FC; NNSG2dCharacterData *unk_800; - UnkStruct_ov21_021D5868 *zukan_enc_plat_0; - UnkStruct_ov21_021D5890 *zukan_enc_plat_2; + dungeonCoordinates *dungeonCoordinatesArray; + fieldCoordinates *fieldCoordinatesArray; int unk_80C; int unk_810; UnkStruct_ov21_021D2648 unk_814; @@ -128,7 +128,7 @@ typedef struct { u32 unk_838; u32 unk_83C; u32 unk_840; -} UnkStruct_ov21_021DD420; +} PokedexMapDisplay; static UnkStruct_ov21_021DCACC *ov21_021DCA5C(int heapID, UnkStruct_ov21_021D0F60 *param1); static UnkStruct_ov21_021DCAE0 *ov21_021DCAA0(int param0, UnkStruct_ov21_021D0F60 *param1); @@ -142,36 +142,36 @@ static int ov21_021DCBD8(void *param0, UnkStruct_ov21_021E6B20 *param1, const vo static int ov21_021DCCD8(void *param0, UnkStruct_ov21_021E6B20 *param1, const void *param2, const UnkStruct_ov21_021E6A68 *param3); static int ov21_021DCD04(void *param0, UnkStruct_ov21_021E6B20 *param1, const void *param2, const UnkStruct_ov21_021E6A68 *param3); static void ov21_021DDCF4(UnkStruct_ov21_021DCAE0 *param0, const UnkStruct_ov21_021DCACC *param1); -static void ov21_021DD420(UnkStruct_ov21_021DD420 *param0); -static void ov21_021DD458(UnkStruct_ov21_021DD420 *param0); -static void ov21_021DD490(UnkStruct_ov21_021DD420 *param0, UnkStruct_ov21_021DCAE0 *param1, const UnkStruct_ov21_021DCACC *param2, BOOL param3); -static BOOL ov21_021DD508(UnkStruct_ov21_021DD420 *param0, UnkStruct_ov21_021DCAE0 *param1, const UnkStruct_ov21_021DCACC *param2, BOOL param3); -static void ov21_021DD554(UnkStruct_ov21_021DD420 *param0, UnkStruct_ov21_021DCAE0 *param1, const UnkStruct_ov21_021DCACC *param2, BOOL param3); -static BOOL ov21_021DD5E4(UnkStruct_ov21_021DD420 *param0, UnkStruct_ov21_021DCAE0 *param1, const UnkStruct_ov21_021DCACC *param2, BOOL param3); -static void ov21_021DCDD0(UnkStruct_ov21_021DD420 *param0, UnkStruct_ov21_021DCAE0 *param1, const UnkStruct_ov21_021DCACC *param2, const UnkStruct_ov21_021DDABC *param3, int param4); -static void ov21_021DCE20(UnkStruct_ov21_021DD420 *param0, UnkStruct_ov21_021DCAE0 *param1); +static void ov21_021DD420(PokedexMapDisplay *mapDisplay); +static void ov21_021DD458(PokedexMapDisplay *mapDisplay); +static void ov21_021DD490(PokedexMapDisplay *mapDisplay, UnkStruct_ov21_021DCAE0 *param1, const UnkStruct_ov21_021DCACC *param2, BOOL param3); +static BOOL ov21_021DD508(PokedexMapDisplay *mapDisplay, UnkStruct_ov21_021DCAE0 *param1, const UnkStruct_ov21_021DCACC *param2, BOOL param3); +static void ov21_021DD554(PokedexMapDisplay *mapDisplay, UnkStruct_ov21_021DCAE0 *param1, const UnkStruct_ov21_021DCACC *param2, BOOL param3); +static BOOL ov21_021DD5E4(PokedexMapDisplay *mapDisplay, UnkStruct_ov21_021DCAE0 *param1, const UnkStruct_ov21_021DCACC *param2, BOOL param3); +static void ov21_021DCDD0(PokedexMapDisplay *mapDisplay, UnkStruct_ov21_021DCAE0 *param1, const UnkStruct_ov21_021DCACC *param2, const encounterCollection *enCollection, int param4); +static void ov21_021DCE20(PokedexMapDisplay *mapDisplay, UnkStruct_ov21_021DCAE0 *param1); static void ov21_021DCE40(UnkStruct_ov21_021DCAE0 *param0, const UnkStruct_ov21_021DCACC *param1, int param2); -static void ov21_021DD668(UnkStruct_ov21_021DD420 *param0, UnkStruct_ov21_021DCAE0 *param1, int param2); -static void ov21_021DD6C0(UnkStruct_ov21_021DD420 *param0, UnkStruct_ov21_021DCAE0 *param1); -static void ov21_021DCFC8(UnkStruct_ov21_021DD420 *param0, UnkStruct_ov21_021DCAE0 *param1, int param2); -static void ov21_021DD114(UnkStruct_ov21_021DD420 *param0, UnkStruct_ov21_021DCAE0 *param1); -static void ov21_021DD1A8(UnkStruct_ov21_021DD420 *param0, UnkStruct_ov21_021DCAE0 *param1, int param2); -static void ov21_021DD2B8(UnkStruct_ov21_021DD420 *param0); -static void ov21_021DD2E0(UnkStruct_ov21_021DD420 *param0, UnkStruct_ov21_021DCAE0 *param1, const UnkStruct_ov21_021DCACC *param2, int param3); -static void ov21_021DD3FC(UnkStruct_ov21_021DD420 *param0); -static void ov21_021DD9E8(UnkStruct_ov21_021DD420 *param0, const UnkStruct_ov21_021DDABC *param1); -static void ov21_021DDA48(UnkStruct_ov21_021DD420 *param0, int param1); -static void ov21_021DDA80(UnkStruct_ov21_021DD420 *param0, UnkStruct_ov21_021DCAE0 *param1, const UnkStruct_ov21_021DCACC *param2, const UnkStruct_ov21_021DDABC *param3, int param4); -static void ov21_021DD710(UnkStruct_ov21_021DD420 *param0, const UnkStruct_ov21_021DCACC *param1, const UnkStruct_ov21_021DDABC *param2, int param3); -static void ov21_021DD8B4(UnkStruct_ov21_021DD420 *param0); +static void ov21_021DD668(PokedexMapDisplay *mapDisplay, UnkStruct_ov21_021DCAE0 *param1, int param2); +static void ov21_021DD6C0(PokedexMapDisplay *mapDisplay, UnkStruct_ov21_021DCAE0 *param1); +static void ov21_021DCFC8(PokedexMapDisplay *mapDisplay, UnkStruct_ov21_021DCAE0 *param1, int param2); +static void ov21_021DD114(PokedexMapDisplay *mapDisplay, UnkStruct_ov21_021DCAE0 *param1); +static void ov21_021DD1A8(PokedexMapDisplay *mapDisplay, UnkStruct_ov21_021DCAE0 *param1, int param2); +static void ov21_021DD2B8(PokedexMapDisplay *mapDisplay); +static void ov21_021DD2E0(PokedexMapDisplay *mapDisplay, UnkStruct_ov21_021DCAE0 *param1, const UnkStruct_ov21_021DCACC *param2, int param3); +static void ov21_021DD3FC(PokedexMapDisplay *mapDisplay); +static void ov21_021DD9E8(PokedexMapDisplay *mapDisplay, const encounterCollection *enCollection); +static void ov21_021DDA48(PokedexMapDisplay *mapDisplay, int param1); +static void ov21_021DDA80(PokedexMapDisplay *mapDisplay, UnkStruct_ov21_021DCAE0 *param1, const UnkStruct_ov21_021DCACC *param2, const encounterCollection *enCollection, int param4); +static void ov21_021DD710(PokedexMapDisplay *mapDisplay, const UnkStruct_ov21_021DCACC *param1, const encounterCollection *enCollection, int param3); +static void ov21_021DD8B4(PokedexMapDisplay *mapDisplay); static u8 *ov21_021DD900(u32 heapID, const UnkStruct_ov21_021DCACC *param1, u32 *param2); static u8 *ov21_021DD908(u32 param0, const UnkStruct_ov21_021DCACC *param1, u32 *param2); -static void ov21_021DD964(UnkStruct_ov21_021DD420 *param0, UnkStruct_ov21_021DCAE0 *param1); -static void ov21_021DDB8C(UnkStruct_ov21_021DD420 *param0); -static void ov21_021DDBCC(UnkStruct_ov21_021DD420 *param0); -static void ov21_021DDC14(UnkStruct_ov21_021DD420 *param0); -static void ov21_021DDABC(UnkStruct_ov21_021DDABC *param0, UnkStruct_ov21_021DCACC *param1, int heapID); -static void ov21_021DDB68(UnkStruct_ov21_021DDABC *param0); +static void ov21_021DD964(PokedexMapDisplay *mapDisplay, UnkStruct_ov21_021DCAE0 *param1); +static void ov21_021DDB8C(PokedexMapDisplay *mapDisplay); +static void ov21_021DDBCC(PokedexMapDisplay *mapDisplay); +static void ov21_021DDC14(PokedexMapDisplay *mapDisplay); +static void ov21_021DDABC(encounterCollection *enCollection, UnkStruct_ov21_021DCACC *param1, int heapID); +static void ov21_021DDB68(encounterCollection *enCollection); void ov21_021DC9BC(UnkStruct_ov21_021E68F4 *param0, UnkStruct_ov21_021D0F60 *param1, int heapID) { @@ -280,17 +280,17 @@ static int ov21_021DCAF4(void) return 0; } -static int ov21_021DCAF8(UnkStruct_ov21_021E6A68 *param0, void *param1) // dansim +static int ov21_021DCAF8(UnkStruct_ov21_021E6A68 *param0, void *param1) { UnkStruct_ov21_021DCACC *v0 = param1; - UnkStruct_ov21_021DDABC *v1; + encounterCollection *encCollection; - v1 = Heap_AllocFromHeap(param0->heapID, sizeof(UnkStruct_ov21_021DDABC)); + encCollection = Heap_AllocFromHeap(param0->heapID, sizeof(encounterCollection)); - GF_ASSERT(v1); - memset(v1, 0, sizeof(UnkStruct_ov21_021DDABC)); + GF_ASSERT(encCollection); + memset(encCollection, 0, sizeof(encounterCollection)); - param0->unk_08 = v1; + param0->unk_08 = encCollection; if (v0->pokedexS->timeOfDay == TOD_MORNING) { v0->encounterTime = ENCTIME_MORNING; @@ -302,12 +302,12 @@ static int ov21_021DCAF8(UnkStruct_ov21_021E6A68 *param0, void *param1) // dansi } } - v1->unk_04 = ov21_021DD900(param0->heapID, v0, &v1->heapSize); - v1->unk_08 = ov21_021DD908(param0->heapID, v0, &v1->unk_10); + encCollection->extraFields = ov21_021DD900(param0->heapID, v0, &encCollection->numExtraFields); + encCollection->extraDungeons = ov21_021DD908(param0->heapID, v0, &encCollection->numExtraDungeons); - ov21_021DDABC(v1, v0, param0->heapID); + ov21_021DDABC(encCollection, v0, param0->heapID); - v1->encounterTime = v0->encounterTime; + encCollection->encounterTime = v0->encounterTime; return 1; } @@ -315,7 +315,7 @@ static int ov21_021DCAF8(UnkStruct_ov21_021E6A68 *param0, void *param1) // dansi static int ov21_021DCB6C(UnkStruct_ov21_021E6A68 *param0, void *param1) { UnkStruct_ov21_021DCACC *v0 = param1; - UnkStruct_ov21_021DDABC *v1 = param0->unk_08; + encounterCollection *encCollection = param0->unk_08; if (param0->unk_0C == 1) { return 1; @@ -325,10 +325,10 @@ static int ov21_021DCB6C(UnkStruct_ov21_021E6A68 *param0, void *param1) return 0; } - if (v1->encounterTime != v0->encounterTime) { - ov21_021DDB68(v1); - ov21_021DDABC(v1, v0, param0->heapID); - v1->encounterTime = v0->encounterTime; + if (encCollection->encounterTime != v0->encounterTime) { + ov21_021DDB68(encCollection); + ov21_021DDABC(encCollection, v0, param0->heapID); + encCollection->encounterTime = v0->encounterTime; } return 0; @@ -336,18 +336,18 @@ static int ov21_021DCB6C(UnkStruct_ov21_021E6A68 *param0, void *param1) static int ov21_021DCBA8(UnkStruct_ov21_021E6A68 *param0, void *param1) { - UnkStruct_ov21_021DDABC *v0 = param0->unk_08; + encounterCollection *enCollection = param0->unk_08; - if (v0->unk_04) { - Heap_FreeToHeap(v0->unk_04); + if (enCollection->extraFields) { + Heap_FreeToHeap(enCollection->extraFields); } - if (v0->unk_08) { - Heap_FreeToHeap(v0->unk_08); + if (enCollection->extraDungeons) { + Heap_FreeToHeap(enCollection->extraDungeons); } - ov21_021DDB68(v0); - Heap_FreeToHeap(v0); + ov21_021DDB68(enCollection); + Heap_FreeToHeap(enCollection); param0->unk_08 = NULL; @@ -357,43 +357,43 @@ static int ov21_021DCBA8(UnkStruct_ov21_021E6A68 *param0, void *param1) static int ov21_021DCBD8(void *param0, UnkStruct_ov21_021E6B20 *param1, const void *param2, const UnkStruct_ov21_021E6A68 *param3) { const UnkStruct_ov21_021DCACC *v0 = param2; - const UnkStruct_ov21_021DDABC *v1 = param3->unk_08; + const encounterCollection *encCollection = param3->unk_08; UnkStruct_ov21_021DCAE0 *v2 = param0; - UnkStruct_ov21_021DD420 *v3 = param1->unk_08; + PokedexMapDisplay *mapDisplay = param1->unk_08; BOOL v4; switch (param1->unk_00) { case 0: - param1->unk_08 = Heap_AllocFromHeap(param1->heapID, sizeof(UnkStruct_ov21_021DD420)); - memset(param1->unk_08, 0, sizeof(UnkStruct_ov21_021DD420)); + param1->unk_08 = Heap_AllocFromHeap(param1->heapID, sizeof(PokedexMapDisplay)); + memset(param1->unk_08, 0, sizeof(PokedexMapDisplay)); - v3 = param1->unk_08; - v3->encounterTime = v0->encounterTime; - v3->zukan_enc_plat_0 = ov21_021D5868(param1->heapID, NULL); - v3->zukan_enc_plat_2 = ov21_021D5890(param1->heapID, NULL); + mapDisplay = param1->unk_08; + mapDisplay->encounterTime = v0->encounterTime; + mapDisplay->dungeonCoordinatesArray = PokedexEncData_GetDungeonLocations(param1->heapID, NULL); + mapDisplay->fieldCoordinatesArray = PokedexEncData_GetFieldLocations(param1->heapID, NULL); param1->unk_00++; break; case 1: - ov21_021DCDD0(v3, v2, v0, v1, param1->heapID); - ov21_021DD710(param1->unk_08, v0, v1, param1->heapID); - ov21_021DD9E8(param1->unk_08, v1); - ov21_021DDB8C(v3); - ov21_021DD964(v3, v2); + ov21_021DCDD0(mapDisplay, v2, v0, encCollection, param1->heapID); + ov21_021DD710(param1->unk_08, v0, encCollection, param1->heapID); + ov21_021DD9E8(param1->unk_08, encCollection); + ov21_021DDB8C(mapDisplay); + ov21_021DD964(mapDisplay, v2); if (v2->unk_0C == 0) { - ov21_021DD490(v3, v2, v0, 1); + ov21_021DD490(mapDisplay, v2, v0, 1); } else { - ov21_021DD554(v3, v2, v0, 1); + ov21_021DD554(mapDisplay, v2, v0, 1); } param1->unk_00++; break; case 2: if (v2->unk_0C == 0) { - v4 = ov21_021DD508(v3, v2, v0, 1); + v4 = ov21_021DD508(mapDisplay, v2, v0, 1); } else { - v4 = ov21_021DD5E4(v3, v2, v0, 1); + v4 = ov21_021DD5E4(mapDisplay, v2, v0, 1); } if (v4) { @@ -401,7 +401,7 @@ static int ov21_021DCBD8(void *param0, UnkStruct_ov21_021E6B20 *param1, const vo } break; case 3: - ov21_021DDBCC(v3); + ov21_021DDBCC(mapDisplay); return 1; } @@ -411,12 +411,12 @@ static int ov21_021DCBD8(void *param0, UnkStruct_ov21_021E6B20 *param1, const vo static int ov21_021DCCD8(void *param0, UnkStruct_ov21_021E6B20 *param1, const void *param2, const UnkStruct_ov21_021E6A68 *param3) { const UnkStruct_ov21_021DCACC *v0 = param2; - const UnkStruct_ov21_021DDABC *v1 = param3->unk_08; + const encounterCollection *encCollection = param3->unk_08; UnkStruct_ov21_021DCAE0 *v2 = param0; - UnkStruct_ov21_021DD420 *v3 = param1->unk_08; + PokedexMapDisplay *mapDisplay = param1->unk_08; - ov21_021DDC14(v3); - ov21_021DDA80(v3, v2, v0, v1, param1->heapID); + ov21_021DDC14(mapDisplay); + ov21_021DDA80(mapDisplay, v2, v0, encCollection, param1->heapID); return 0; } @@ -424,28 +424,28 @@ static int ov21_021DCCD8(void *param0, UnkStruct_ov21_021E6B20 *param1, const vo static int ov21_021DCD04(void *param0, UnkStruct_ov21_021E6B20 *param1, const void *param2, const UnkStruct_ov21_021E6A68 *param3) { const UnkStruct_ov21_021DCACC *v0 = param2; - const UnkStruct_ov21_021DDABC *v1 = param3->unk_08; + const encounterCollection *encCollection = param3->unk_08; UnkStruct_ov21_021DCAE0 *v2 = param0; - UnkStruct_ov21_021DD420 *v3 = param1->unk_08; + PokedexMapDisplay *mapDisplay = param1->unk_08; BOOL v4; switch (param1->unk_00) { case 0: - ov21_021DDB8C(v3); + ov21_021DDB8C(mapDisplay); if (v2->unk_0C == 0) { - ov21_021DD490(v3, v2, v0, 0); + ov21_021DD490(mapDisplay, v2, v0, 0); } else { - ov21_021DD554(v3, v2, v0, 0); + ov21_021DD554(mapDisplay, v2, v0, 0); } param1->unk_00++; break; case 1: if (v2->unk_0C == 0) { - v4 = ov21_021DD508(v3, v2, v0, 0); + v4 = ov21_021DD508(mapDisplay, v2, v0, 0); } else { - v4 = ov21_021DD5E4(v3, v2, v0, 0); + v4 = ov21_021DD5E4(mapDisplay, v2, v0, 0); } if (v4) { @@ -453,14 +453,14 @@ static int ov21_021DCD04(void *param0, UnkStruct_ov21_021E6B20 *param1, const vo } break; case 2: - ov21_021DD8B4(v3); - ov21_021DCE20(v3, v2); + ov21_021DD8B4(mapDisplay); + ov21_021DCE20(mapDisplay, v2); param1->unk_00++; break; case 3: GXLayers_EngineAToggleLayers(GX_BLEND_PLANEMASK_BG1, 1); - Heap_FreeToHeap(v3->zukan_enc_plat_0); - Heap_FreeToHeap(v3->zukan_enc_plat_2); + Heap_FreeToHeap(mapDisplay->dungeonCoordinatesArray); + Heap_FreeToHeap(mapDisplay->fieldCoordinatesArray); Heap_FreeToHeap(param1->unk_08); param1->unk_08 = NULL; param1->unk_00++; @@ -472,23 +472,23 @@ static int ov21_021DCD04(void *param0, UnkStruct_ov21_021E6B20 *param1, const vo return 0; } -static void ov21_021DCDD0(UnkStruct_ov21_021DD420 *param0, UnkStruct_ov21_021DCAE0 *param1, const UnkStruct_ov21_021DCACC *param2, const UnkStruct_ov21_021DDABC *param3, int param4) +static void ov21_021DCDD0(PokedexMapDisplay *mapDisplay, UnkStruct_ov21_021DCAE0 *param1, const UnkStruct_ov21_021DCACC *param2, const encounterCollection *enCollection, int param4) { ov21_021DCE40(param1, param2, param4); - ov21_021DD668(param0, param1, param4); - ov21_021DCFC8(param0, param1, param4); - ov21_021DD1A8(param0, param1, param4); - ov21_021DD2E0(param0, param1, param2, param4); - ov21_021DDA48(param0, param2->encounterTime); + ov21_021DD668(mapDisplay, param1, param4); + ov21_021DCFC8(mapDisplay, param1, param4); + ov21_021DD1A8(mapDisplay, param1, param4); + ov21_021DD2E0(mapDisplay, param1, param2, param4); + ov21_021DDA48(mapDisplay, param2->encounterTime); ov21_021DDCF4(param1, param2); } -static void ov21_021DCE20(UnkStruct_ov21_021DD420 *param0, UnkStruct_ov21_021DCAE0 *param1) +static void ov21_021DCE20(PokedexMapDisplay *mapDisplay, UnkStruct_ov21_021DCAE0 *param1) { - ov21_021DD6C0(param0, param1); - ov21_021DD3FC(param0); - ov21_021DD2B8(param0); - ov21_021DD114(param0, param1); + ov21_021DD6C0(mapDisplay, param1); + ov21_021DD3FC(mapDisplay); + ov21_021DD2B8(mapDisplay); + ov21_021DD114(mapDisplay, param1); } static void ov21_021DCE40(UnkStruct_ov21_021DCAE0 *param0, const UnkStruct_ov21_021DCACC *param1, int param2) @@ -534,49 +534,49 @@ static void ov21_021DCE40(UnkStruct_ov21_021DCAE0 *param0, const UnkStruct_ov21_ sub_0201C3C0(param0->unk_00->unk_00, 3); } -static void ov21_021DCFC8(UnkStruct_ov21_021DD420 *param0, UnkStruct_ov21_021DCAE0 *param1, int param2) +static void ov21_021DCFC8(PokedexMapDisplay *mapDisplay, UnkStruct_ov21_021DCAE0 *param1, int param2) { UnkStruct_ov21_021D13FC *v0 = param1->unk_00; NARC *v1 = ov21_021D26E0(param1->unk_00); - param0->unk_B4[0] = SpriteResourceCollection_AddTilesFrom(v0->unk_13C[0], v1, 108, 1, 108 + 6000, NNS_G2D_VRAM_TYPE_2DMAIN, param2); + mapDisplay->unk_B4[0] = SpriteResourceCollection_AddTilesFrom(v0->unk_13C[0], v1, 108, 1, 108 + 6000, NNS_G2D_VRAM_TYPE_2DMAIN, param2); - sub_0200A3DC(param0->unk_B4[0]); - SpriteResource_ReleaseData(param0->unk_B4[0]); + sub_0200A3DC(mapDisplay->unk_B4[0]); + SpriteResource_ReleaseData(mapDisplay->unk_B4[0]); - param0->unk_B4[2] = SpriteResourceCollection_AddFrom(v0->unk_13C[2], v1, 106, 1, 106 + 6000, 2, param2); - param0->unk_B4[3] = SpriteResourceCollection_AddFrom(v0->unk_13C[3], v1, 107, 1, 107 + 6000, 3, param2); - param0->unk_D0[0] = SpriteResourceCollection_AddTilesFrom(v0->unk_13C[0], v1, 93, 1, 93 + 6000, NNS_G2D_VRAM_TYPE_2DMAIN, param2); + mapDisplay->unk_B4[2] = SpriteResourceCollection_AddFrom(v0->unk_13C[2], v1, 106, 1, 106 + 6000, 2, param2); + mapDisplay->unk_B4[3] = SpriteResourceCollection_AddFrom(v0->unk_13C[3], v1, 107, 1, 107 + 6000, 3, param2); + mapDisplay->unk_D0[0] = SpriteResourceCollection_AddTilesFrom(v0->unk_13C[0], v1, 93, 1, 93 + 6000, NNS_G2D_VRAM_TYPE_2DMAIN, param2); - sub_0200A3DC(param0->unk_D0[0]); - SpriteResource_ReleaseData(param0->unk_D0[0]); + sub_0200A3DC(mapDisplay->unk_D0[0]); + SpriteResource_ReleaseData(mapDisplay->unk_D0[0]); - param0->unk_D0[1] = SpriteResourceCollection_AddPaletteFrom(v0->unk_13C[1], v1, 14, 0, 14 + 6000, NNS_G2D_VRAM_TYPE_2DMAIN, 5, param2); + mapDisplay->unk_D0[1] = SpriteResourceCollection_AddPaletteFrom(v0->unk_13C[1], v1, 14, 0, 14 + 6000, NNS_G2D_VRAM_TYPE_2DMAIN, 5, param2); - sub_0200A640(param0->unk_D0[1]); - SpriteResource_ReleaseData(param0->unk_D0[1]); + sub_0200A640(mapDisplay->unk_D0[1]); + SpriteResource_ReleaseData(mapDisplay->unk_D0[1]); - param0->unk_D0[2] = SpriteResourceCollection_AddFrom(v0->unk_13C[2], v1, 91, 1, 91 + 6000, 2, param2); - param0->unk_D0[3] = SpriteResourceCollection_AddFrom(v0->unk_13C[3], v1, 92, 1, 92 + 6000, 3, param2); + mapDisplay->unk_D0[2] = SpriteResourceCollection_AddFrom(v0->unk_13C[2], v1, 91, 1, 91 + 6000, 2, param2); + mapDisplay->unk_D0[3] = SpriteResourceCollection_AddFrom(v0->unk_13C[3], v1, 92, 1, 92 + 6000, 3, param2); } -static void ov21_021DD114(UnkStruct_ov21_021DD420 *param0, UnkStruct_ov21_021DCAE0 *param1) +static void ov21_021DD114(PokedexMapDisplay *mapDisplay, UnkStruct_ov21_021DCAE0 *param1) { UnkStruct_ov21_021D13FC *v0 = param1->unk_00; - sub_0200A4E4(param0->unk_B4[0]); - SpriteResourceCollection_Remove(v0->unk_13C[0], param0->unk_B4[0]); - SpriteResourceCollection_Remove(v0->unk_13C[2], param0->unk_B4[2]); - SpriteResourceCollection_Remove(v0->unk_13C[3], param0->unk_B4[3]); - sub_0200A4E4(param0->unk_D0[0]); - sub_0200A6DC(param0->unk_D0[1]); - SpriteResourceCollection_Remove(v0->unk_13C[0], param0->unk_D0[0]); - SpriteResourceCollection_Remove(v0->unk_13C[1], param0->unk_D0[1]); - SpriteResourceCollection_Remove(v0->unk_13C[2], param0->unk_D0[2]); - SpriteResourceCollection_Remove(v0->unk_13C[3], param0->unk_D0[3]); + sub_0200A4E4(mapDisplay->unk_B4[0]); + SpriteResourceCollection_Remove(v0->unk_13C[0], mapDisplay->unk_B4[0]); + SpriteResourceCollection_Remove(v0->unk_13C[2], mapDisplay->unk_B4[2]); + SpriteResourceCollection_Remove(v0->unk_13C[3], mapDisplay->unk_B4[3]); + sub_0200A4E4(mapDisplay->unk_D0[0]); + sub_0200A6DC(mapDisplay->unk_D0[1]); + SpriteResourceCollection_Remove(v0->unk_13C[0], mapDisplay->unk_D0[0]); + SpriteResourceCollection_Remove(v0->unk_13C[1], mapDisplay->unk_D0[1]); + SpriteResourceCollection_Remove(v0->unk_13C[2], mapDisplay->unk_D0[2]); + SpriteResourceCollection_Remove(v0->unk_13C[3], mapDisplay->unk_D0[3]); } -static void ov21_021DD1A8(UnkStruct_ov21_021DD420 *param0, UnkStruct_ov21_021DCAE0 *param1, int param2) +static void ov21_021DD1A8(PokedexMapDisplay *mapDisplay, UnkStruct_ov21_021DCAE0 *param1, int param2) { CellActorResourceData v0; CellActorInitParams v1; @@ -593,9 +593,9 @@ static void ov21_021DD1A8(UnkStruct_ov21_021DD420 *param0, UnkStruct_ov21_021DCA v1.position.x = 160 * FX32_ONE; v1.position.y = 96 * FX32_ONE; - param0->unk_C8 = CellActorCollection_Add(&v1); + mapDisplay->unk_C8 = CellActorCollection_Add(&v1); - CellActor_SetAnim(param0->unk_C8, 2); + CellActor_SetAnim(mapDisplay->unk_C8, 2); sub_020093B4(&v0, 108 + 6000, 14 + 6000, 106 + 6000, 107 + 6000, 0xffffffff, 0xffffffff, 0, 0, v2->unk_13C[0], v2->unk_13C[1], v2->unk_13C[2], v2->unk_13C[3], NULL, NULL); v1.collection = v2->unk_138; @@ -607,26 +607,26 @@ static void ov21_021DD1A8(UnkStruct_ov21_021DD420 *param0, UnkStruct_ov21_021DCA v1.position.y = 0; for (v3 = 0; v3 < (22 * 2); v3++) { - param0->unk_04[v3] = CellActorCollection_Add(&v1); - CellActor_SetDrawFlag(param0->unk_04[v3], 0); - CellActor_SetExplicitOAMMode(param0->unk_04[v3], GX_OAM_MODE_XLU); + mapDisplay->cellActorArray[v3] = CellActorCollection_Add(&v1); + CellActor_SetDrawFlag(mapDisplay->cellActorArray[v3], 0); + CellActor_SetExplicitOAMMode(mapDisplay->cellActorArray[v3], GX_OAM_MODE_XLU); } } -static void ov21_021DD2B8(UnkStruct_ov21_021DD420 *param0) +static void ov21_021DD2B8(PokedexMapDisplay *mapDisplay) { int v0; - CellActor_Delete(param0->unk_C8); - param0->unk_C8 = NULL; + CellActor_Delete(mapDisplay->unk_C8); + mapDisplay->unk_C8 = NULL; for (v0 = 0; v0 < (22 * 2); v0++) { - CellActor_Delete(param0->unk_04[v0]); - param0->unk_04[v0] = NULL; + CellActor_Delete(mapDisplay->cellActorArray[v0]); + mapDisplay->cellActorArray[v0] = NULL; } } -static void ov21_021DD2E0(UnkStruct_ov21_021DD420 *param0, UnkStruct_ov21_021DCAE0 *param1, const UnkStruct_ov21_021DCACC *param2, int param3) +static void ov21_021DD2E0(PokedexMapDisplay *mapDisplay, UnkStruct_ov21_021DCAE0 *param1, const UnkStruct_ov21_021DCACC *param2, int enCollection) { Window *v0; UnkStruct_ov21_021D4CB8 v1; @@ -636,7 +636,7 @@ static void ov21_021DD2E0(UnkStruct_ov21_021DD420 *param0, UnkStruct_ov21_021DCA int v5; u32 v6; - GF_ASSERT(param0->unk_C8); + GF_ASSERT(mapDisplay->unk_C8); v2 = SpriteResourceCollection_Find(param1->unk_00->unk_13C[1], 14 + 6000); @@ -645,20 +645,20 @@ static void ov21_021DD2E0(UnkStruct_ov21_021DD420 *param0, UnkStruct_ov21_021DCA v1.unk_18 = 1; v1.unk_1C = 31 - 1; v1.unk_20 = NNS_G2D_VRAM_TYPE_2DMAIN; - v1.unk_24 = param3; + v1.unk_24 = enCollection; v4 = sub_0201FAB4(v1.unk_08, NNS_G2D_VRAM_TYPE_2DMAIN); v0 = ov21_021D4D6C(v3->unk_14C, 16, 2); v6 = ov21_021D4DAC(v3->unk_14C, v0, 697, 35, 0, 0); v1.unk_04 = v0; - v1.unk_0C = param0->unk_C8; + v1.unk_0C = mapDisplay->unk_C8; v1.unk_10 = -(v6 / 2); v1.unk_14 = -8; - param0->unk_CC = ov21_021D4CA0(&v1); + mapDisplay->unk_CC = ov21_021D4CA0(&v1); - sub_02012A60(param0->unk_CC->unk_00, v4 + 2); + sub_02012A60(mapDisplay->unk_CC->unk_00, v4 + 2); ov21_021D4DA0(v0); for (v5 = 0; v5 < 3; v5++) { @@ -670,51 +670,51 @@ static void ov21_021DD2E0(UnkStruct_ov21_021DD420 *param0, UnkStruct_ov21_021DCA v1.unk_10 = 8 + ((9 * 8) - v6) / 2; v1.unk_14 = 32; - param0->unk_E0[v5] = ov21_021D4CA0(&v1); + mapDisplay->unk_E0[v5] = ov21_021D4CA0(&v1); - sub_02012A60(param0->unk_E0[v5]->unk_00, v4 + 2); + sub_02012A60(mapDisplay->unk_E0[v5]->unk_00, v4 + 2); ov21_021D4DA0(v0); } } -static void ov21_021DD3FC(UnkStruct_ov21_021DD420 *param0) +static void ov21_021DD3FC(PokedexMapDisplay *mapDisplay) { int v0; - ov21_021D4D1C(param0->unk_CC); + ov21_021D4D1C(mapDisplay->unk_CC); for (v0 = 0; v0 < 3; v0++) { - ov21_021D4D1C(param0->unk_E0[v0]); + ov21_021D4D1C(mapDisplay->unk_E0[v0]); } } -static void ov21_021DD420(UnkStruct_ov21_021DD420 *param0) +static void ov21_021DD420(PokedexMapDisplay *mapDisplay) { int v0; - CellActor_SetExplicitOAMMode(param0->unk_C8, GX_OAM_MODE_XLU); - sub_02012AF0(param0->unk_CC->unk_00, GX_OAM_MODE_XLU); + CellActor_SetExplicitOAMMode(mapDisplay->unk_C8, GX_OAM_MODE_XLU); + sub_02012AF0(mapDisplay->unk_CC->unk_00, GX_OAM_MODE_XLU); for (v0 = 0; v0 < 3; v0++) { - sub_02012AF0(param0->unk_E0[v0]->unk_00, GX_OAM_MODE_XLU); + sub_02012AF0(mapDisplay->unk_E0[v0]->unk_00, GX_OAM_MODE_XLU); } } -static void ov21_021DD458(UnkStruct_ov21_021DD420 *param0) +static void ov21_021DD458(PokedexMapDisplay *mapDisplay) { int v0; - CellActor_SetExplicitOAMMode(param0->unk_C8, GX_OAM_MODE_NORMAL); - sub_02012AF0(param0->unk_CC->unk_00, GX_OAM_MODE_NORMAL); + CellActor_SetExplicitOAMMode(mapDisplay->unk_C8, GX_OAM_MODE_NORMAL); + sub_02012AF0(mapDisplay->unk_CC->unk_00, GX_OAM_MODE_NORMAL); for (v0 = 0; v0 < 3; v0++) { - sub_02012AF0(param0->unk_E0[v0]->unk_00, GX_OAM_MODE_NORMAL); + sub_02012AF0(mapDisplay->unk_E0[v0]->unk_00, GX_OAM_MODE_NORMAL); } } -static void ov21_021DD490(UnkStruct_ov21_021DD420 *param0, UnkStruct_ov21_021DCAE0 *param1, const UnkStruct_ov21_021DCACC *param2, BOOL param3) +static void ov21_021DD490(PokedexMapDisplay *mapDisplay, UnkStruct_ov21_021DCAE0 *param1, const UnkStruct_ov21_021DCACC *param2, BOOL param3) { - ov21_021DD420(param0); + ov21_021DD420(mapDisplay); if (ov21_021E2A54(param2->unk_08)) { if (param3) { @@ -727,7 +727,7 @@ static void ov21_021DD490(UnkStruct_ov21_021DD420 *param0, UnkStruct_ov21_021DCA ov21_021D24FC(param1->unk_00, ¶m1->unk_00->unk_168); } -static BOOL ov21_021DD508(UnkStruct_ov21_021DD420 *param0, UnkStruct_ov21_021DCAE0 *param1, const UnkStruct_ov21_021DCACC *param2, BOOL param3) +static BOOL ov21_021DD508(PokedexMapDisplay *mapDisplay, UnkStruct_ov21_021DCAE0 *param1, const UnkStruct_ov21_021DCACC *param2, BOOL param3) { BOOL v0; @@ -739,7 +739,7 @@ static BOOL ov21_021DD508(UnkStruct_ov21_021DD420 *param0, UnkStruct_ov21_021DCA if (v0) { if (param3) { - ov21_021DD458(param0); + ov21_021DD458(mapDisplay); } return 1; @@ -750,12 +750,12 @@ static BOOL ov21_021DD508(UnkStruct_ov21_021DD420 *param0, UnkStruct_ov21_021DCA return 0; } -static void ov21_021DD554(UnkStruct_ov21_021DD420 *param0, UnkStruct_ov21_021DCAE0 *param1, const UnkStruct_ov21_021DCACC *param2, BOOL param3) +static void ov21_021DD554(PokedexMapDisplay *mapDisplay, UnkStruct_ov21_021DCAE0 *param1, const UnkStruct_ov21_021DCACC *param2, BOOL param3) { - ov21_021DD420(param0); + ov21_021DD420(mapDisplay); if (param3 == 0) { - ov21_021D2648(¶m0->unk_814, 40, param1->unk_04, 120, param1->unk_08, param1->unk_10); + ov21_021D2648(&mapDisplay->unk_814, 40, param1->unk_04, 120, param1->unk_08, param1->unk_10); } if (ov21_021E2A54(param2->unk_08)) { @@ -767,14 +767,14 @@ static void ov21_021DD554(UnkStruct_ov21_021DD420 *param0, UnkStruct_ov21_021DCA } } -static BOOL ov21_021DD5E4(UnkStruct_ov21_021DD420 *param0, UnkStruct_ov21_021DCAE0 *param1, const UnkStruct_ov21_021DCACC *param2, BOOL param3) +static BOOL ov21_021DD5E4(PokedexMapDisplay *mapDisplay, UnkStruct_ov21_021DCAE0 *param1, const UnkStruct_ov21_021DCACC *param2, BOOL param3) { BOOL v0[2]; int v1; if (param3 == 0) { - v0[0] = ov21_021D2664(¶m0->unk_814); - ov21_021D2164(param1->unk_00, param0->unk_814.unk_00, param0->unk_814.unk_04); + v0[0] = ov21_021D2664(&mapDisplay->unk_814); + ov21_021D2164(param1->unk_00, mapDisplay->unk_814.unk_00, mapDisplay->unk_814.unk_04); } else { v0[0] = 1; } @@ -793,7 +793,7 @@ static BOOL ov21_021DD5E4(UnkStruct_ov21_021DD420 *param0, UnkStruct_ov21_021DCA if (v1 == 2) { if (param3 == 1) { - ov21_021DD458(param0); + ov21_021DD458(mapDisplay); } return 1; @@ -802,441 +802,443 @@ static BOOL ov21_021DD5E4(UnkStruct_ov21_021DD420 *param0, UnkStruct_ov21_021DCA return 0; } -static void ov21_021DD668(UnkStruct_ov21_021DD420 *param0, UnkStruct_ov21_021DCAE0 *param1, int param2) +static void ov21_021DD668(PokedexMapDisplay *mapDisplay, UnkStruct_ov21_021DCAE0 *param1, int param2) { BGL_FillWindow(¶m1->unk_00->unk_04, 0); - param0->unk_7F4 = ov21_021D2808(param1->unk_00, 30, 1, ¶m0->unk_7F8, param2); - param0->unk_7FC = ov21_021D2808(param1->unk_00, 31, 1, ¶m0->unk_800, param2); + mapDisplay->unk_7F4 = ov21_021D2808(param1->unk_00, 30, 1, &mapDisplay->unk_7F8, param2); + mapDisplay->unk_7FC = ov21_021D2808(param1->unk_00, 31, 1, &mapDisplay->unk_800, param2); sub_0201C2B4(¶m1->unk_00->unk_04, 8); } -static void ov21_021DD6C0(UnkStruct_ov21_021DD420 *param0, UnkStruct_ov21_021DCAE0 *param1) +static void ov21_021DD6C0(PokedexMapDisplay *mapDisplay, UnkStruct_ov21_021DCAE0 *param1) { BGL_FillWindow(¶m1->unk_00->unk_04, 0); sub_02019EBC(param1->unk_00->unk_00, 1); - Heap_FreeToHeap(param0->unk_7F4); + Heap_FreeToHeap(mapDisplay->unk_7F4); - param0->unk_7F4 = NULL; - param0->unk_7F8 = NULL; + mapDisplay->unk_7F4 = NULL; + mapDisplay->unk_7F8 = NULL; - Heap_FreeToHeap(param0->unk_7FC); + Heap_FreeToHeap(mapDisplay->unk_7FC); - param0->unk_7FC = NULL; - param0->unk_800 = NULL; + mapDisplay->unk_7FC = NULL; + mapDisplay->unk_800 = NULL; sub_0201C2B4(¶m1->unk_00->unk_04, 0); } -static void ov21_021DD710(UnkStruct_ov21_021DD420 *param0, const UnkStruct_ov21_021DCACC *param1, const UnkStruct_ov21_021DDABC *param2, int heapID) +static void ov21_021DD710(PokedexMapDisplay *mapDisplay, const UnkStruct_ov21_021DCACC *param1, const encounterCollection *enCollection, int heapID) { int index, v1; int v2, v3; - int v4, v5; + int xOffset, yOffset; int species; - u8 *v7; - int heapSize; + u8 *combinedMapArray; + int numMaps; - ov21_021DD8B4(param0); + ov21_021DD8B4(mapDisplay); - param0->unk_838 = ov21_021D5948(param0->unk_EC, 30, 30, param0->zukan_enc_plat_2, ¶m2->dexEnc1, param2->unk_04, param2->heapSize); - heapSize = (param2->dexEnc1.pokedexEncLength - 1) + param2->heapSize; - v7 = Heap_AllocFromHeapAtEnd(heapID, heapSize); + mapDisplay->unk_838 = ov21_021D5948(mapDisplay->mapFieldCellMatrix_1, POKEDEXMAPHEIGHT, POKEDEXMAPWIDTH, mapDisplay->fieldCoordinatesArray, &enCollection->fieldsEncounteredOn, enCollection->extraFields, enCollection->numExtraFields); + numMaps = (enCollection->fieldsEncounteredOn.numMapsEncounteredOn - 1) + enCollection->numExtraFields; + combinedMapArray = Heap_AllocFromHeapAtEnd(heapID, numMaps); - for (index = 0; index < heapSize; index++) { - if (index < param2->heapSize) { - v7[index] = param2->unk_04[index]; + for (index = 0; index < numMaps; index++) { + if (index < enCollection->numExtraFields) { + combinedMapArray[index] = enCollection->extraFields[index]; } else { - v7[index] = param2->dexEnc1.pokedexEncArray[index - param2->heapSize]; + combinedMapArray[index] = enCollection->fieldsEncounteredOn.mapsEncounteredOnArray[index - enCollection->numExtraFields]; } } - param0->unk_840 = ov21_021D5948(param0->unk_470, 30, 30, param0->zukan_enc_plat_2, ¶m2->dexEnc3, v7, heapSize); + mapDisplay->unk_840 = ov21_021D5948(mapDisplay->mapFieldCellMatrix_2, POKEDEXMAPHEIGHT, POKEDEXMAPWIDTH, mapDisplay->fieldCoordinatesArray, &enCollection->fieldSpecialEncounters, combinedMapArray, numMaps); - Heap_FreeToHeap(v7); - ov21_021D5214(param0->unk_EC, 30, 30); - ov21_021D5214(param0->unk_470, 30, 30); + Heap_FreeToHeap(combinedMapArray); + MapFieldCellMatrix_SmoothCells(mapDisplay->mapFieldCellMatrix_1, POKEDEXMAPHEIGHT, POKEDEXMAPWIDTH); + MapFieldCellMatrix_SmoothCells(mapDisplay->mapFieldCellMatrix_2, POKEDEXMAPHEIGHT, POKEDEXMAPWIDTH); species = Pokedex_Sort_CurrentSpecies(param1->pokedexS); if (species == SPECIES_FEEBAS) { v2 = 4; v3 = 5; - v4 = 92 + 0; - v5 = 32 + -18; + xOffset = 92 + 0; + yOffset = 32 + -18; } else { v2 = 0; v3 = 1; - v4 = 92; - v5 = 32; + xOffset = 92; + yOffset = 32; } - param0->unk_C4 = 0; - param0->unk_C4 = ov21_021D5A20(param0->unk_04, param0->unk_C4, (22 * 2), v4, v5, 5, 5, param0->zukan_enc_plat_0, ¶m2->dexEnc0, 2, v2, param2->unk_08, param2->unk_10, ¶m0->unk_834); + mapDisplay->numDungeons = 0; + mapDisplay->numDungeons = ov21_021D5A20(mapDisplay->cellActorArray, mapDisplay->numDungeons, (22 * 2), xOffset, yOffset, POKEDEXMAPXSCALE, POKEDEXMAPYSCALE, mapDisplay->dungeonCoordinatesArray, &enCollection->dungeonsEncounteredOn, 2, v2, enCollection->extraDungeons, enCollection->numExtraDungeons, &mapDisplay->unk_834); - heapSize = (param2->dexEnc0.pokedexEncLength - 1) + param2->unk_10; - v7 = Heap_AllocFromHeapAtEnd(heapID, heapSize); + numMaps = (enCollection->dungeonsEncounteredOn.numMapsEncounteredOn - 1) + enCollection->numExtraDungeons; + combinedMapArray = Heap_AllocFromHeapAtEnd(heapID, numMaps); - for (index = 0; index < heapSize; index++) { - if (index < param2->unk_10) { - v7[index] = param2->unk_08[index]; + for (index = 0; index < numMaps; index++) { + if (index < enCollection->numExtraDungeons) { + combinedMapArray[index] = enCollection->extraDungeons[index]; } else { - v7[index] = param2->dexEnc0.pokedexEncArray[index - param2->unk_10]; + combinedMapArray[index] = enCollection->dungeonsEncounteredOn.mapsEncounteredOnArray[index - enCollection->numExtraDungeons]; } } - param0->unk_C4 = ov21_021D5A20(param0->unk_04, param0->unk_C4, (22 * 2), v4, v5, 5, 5, param0->zukan_enc_plat_0, ¶m2->dexEnc2, 3, v3, v7, heapSize, ¶m0->unk_83C); + mapDisplay->numDungeons = ov21_021D5A20(mapDisplay->cellActorArray, mapDisplay->numDungeons, (22 * 2), xOffset, yOffset, POKEDEXMAPXSCALE, POKEDEXMAPYSCALE, mapDisplay->dungeonCoordinatesArray, &enCollection->dungeonSpecialEncounters, 3, v3, combinedMapArray, numMaps, &mapDisplay->unk_83C); - Heap_FreeToHeap(v7); + Heap_FreeToHeap(combinedMapArray); } -static void ov21_021DD8B4(UnkStruct_ov21_021DD420 *param0) +static void ov21_021DD8B4(PokedexMapDisplay *mapDisplay) { int v0; - memset(param0->unk_EC, 0, sizeof(u8) * (30 * 30)); - memset(param0->unk_470, 0, sizeof(u8) * (30 * 30)); + memset(mapDisplay->mapFieldCellMatrix_1, 0, sizeof(u8) * (POKEDEXMAPHEIGHT * POKEDEXMAPWIDTH)); + memset(mapDisplay->mapFieldCellMatrix_2, 0, sizeof(u8) * (POKEDEXMAPHEIGHT * POKEDEXMAPWIDTH)); - for (v0 = 0; v0 < param0->unk_C4; v0++) { - CellActor_SetDrawFlag(param0->unk_04[v0], 0); + for (v0 = 0; v0 < mapDisplay->numDungeons; v0++) { + CellActor_SetDrawFlag(mapDisplay->cellActorArray[v0], 0); } - param0->unk_C4 = 0; + mapDisplay->numDungeons = 0; } -static u8 *ov21_021DD900(u32 heapID, const UnkStruct_ov21_021DCACC *param1, u32 *heapSize) +static u8 *ov21_021DD900(u32 heapID, const UnkStruct_ov21_021DCACC *param1, u32 *numExtraFields) { - u32 v0; - int v1; - u8 *v2; + u32 extraFieldCount; + int index; + u8 *extraFields; - v0 = 0; + extraFieldCount = 0; if (param1->pokedexS->pokedexSFlag_1 == 0) { - v1 = 0; + index = 0; - while (Unk_ov21_021E9D78[v1] != 0xffff) { - v0++; - v1++; + while (extraFieldsStructFlag_1[index] != 0xffff) { + extraFieldCount++; + index++; } } if (param1->pokedexS->pokedexSFlag_4 == 0) { - v1 = 0; + index = 0; - while (Unk_ov21_021E9D74[v1] != 0xffff) { - v0++; - v1++; + while (extraFieldsStructFlag_4[index] != 0xffff) { + extraFieldCount++; + index++; } } if (param1->pokedexS->pokedexSFlag_2 == 0) { - v1 = 0; + index = 0; - while (Unk_ov21_021E9D70[v1] != 0xffff) { - v0++; - v1++; + while (extraFieldsStructFlag_2[index] != 0xffff) { + extraFieldCount++; + index++; } } if (param1->pokedexS->pokedexSFlag_3 == 0) { - v1 = 0; + index = 0; - while (Unk_ov21_021E9D6C[v1] != 0xffff) { - v0++; - v1++; + while (extraFieldsStructFlag_3[index] != 0xffff) { + extraFieldCount++; + index++; } } - if (v0 > 0) { - v2 = Heap_AllocFromHeap(heapID, sizeof(u8) * v0); + if (extraFieldCount > 0) { + extraFields = Heap_AllocFromHeap(heapID, sizeof(u8) * extraFieldCount); } else { - v2 = NULL; + extraFields = NULL; } - *heapSize = v0; + *numExtraFields = extraFieldCount; + + extraFieldCount = 0; if (param1->pokedexS->pokedexSFlag_1 == 0) { - v1 = 0; + index = 0; - while (Unk_ov21_021E9D78[v1] != 0xffff) { - v2[v1] = Unk_ov21_021E9D78[v1]; - v0++; - v1++; + while (extraFieldsStructFlag_1[index] != 0xffff) { + extraFields[extraFieldCount] = extraFieldsStructFlag_1[index]; + extraFieldCount++; + index++; } } if (param1->pokedexS->pokedexSFlag_4 == 0) { - v1 = 0; + index = 0; - while (Unk_ov21_021E9D74[v1] != 0xffff) { - v2[v1] = Unk_ov21_021E9D74[v1]; - v0++; - v1++; + while (extraFieldsStructFlag_4[index] != 0xffff) { + extraFields[extraFieldCount] = extraFieldsStructFlag_4[index]; + extraFieldCount++; + index++; } } if (param1->pokedexS->pokedexSFlag_2 == 0) { - v1 = 0; + index = 0; - while (Unk_ov21_021E9D70[v1] != 0xffff) { - v2[v1] = Unk_ov21_021E9D70[v1]; - v0++; - v1++; + while (extraFieldsStructFlag_2[index] != 0xffff) { + extraFields[extraFieldCount] = extraFieldsStructFlag_2[index]; + extraFieldCount++; + index++; } } if (param1->pokedexS->pokedexSFlag_3 == 0) { - v1 = 0; + index = 0; - while (Unk_ov21_021E9D6C[v1] != 0xffff) { - v2[v1] = Unk_ov21_021E9D6C[v1]; - v0++; - v1++; + while (extraFieldsStructFlag_3[index] != 0xffff) { + extraFields[extraFieldCount] = extraFieldsStructFlag_3[index]; + extraFieldCount++; + index++; } } - return v2; + return extraFields; } -static u8 *ov21_021DD908(u32 param0, const UnkStruct_ov21_021DCACC *param1, u32 *param2) +static u8 *ov21_021DD908(u32 param0, const UnkStruct_ov21_021DCACC *param1, u32 *numExtraDungeons) { - u32 v0; - int v1; - u8 *v2; + u32 extraDungeonCount; + int index; + u8 *extraDungeons; - v0 = 0; + extraDungeonCount = 0; if (param1->pokedexS->pokedexSFlag_1 == 0) { - v1 = 0; + index = 0; - while (Unk_ov21_021E9D76[v1] != 0xffff) { - v0++; - v1++; + while (Unk_ov21_021E9D76[index] != 0xffff) { + extraDungeonCount++; + index++; } } if (param1->pokedexS->pokedexSFlag_4 == 0) { - v1 = 0; + index = 0; - while (Unk_ov21_021E9D72[v1] != 0xffff) { - v0++; - v1++; + while (Unk_ov21_021E9D72[index] != 0xffff) { + extraDungeonCount++; + index++; } } if (param1->pokedexS->pokedexSFlag_2 == 0) { - v1 = 0; + index = 0; - while (Unk_ov21_021E9D6E[v1] != 0xffff) { - v0++; - v1++; + while (Unk_ov21_021E9D6E[index] != 0xffff) { + extraDungeonCount++; + index++; } } if (param1->pokedexS->pokedexSFlag_3 == 0) { - v1 = 0; + index = 0; - while (Unk_ov21_021E9D7A[v1] != 0xffff) { - v0++; - v1++; + while (Unk_ov21_021E9D7A[index] != 0xffff) { + extraDungeonCount++; + index++; } } - if (v0 > 0) { - v2 = Heap_AllocFromHeap(param0, sizeof(u8) * v0); + if (extraDungeonCount > 0) { + extraDungeons = Heap_AllocFromHeap(param0, sizeof(u8) * extraDungeonCount); } else { - v2 = NULL; + extraDungeons = NULL; } - *param2 = v0; + *numExtraDungeons = extraDungeonCount; - v0 = 0; + extraDungeonCount = 0; if (param1->pokedexS->pokedexSFlag_1 == 0) { - v1 = 0; + index = 0; - while (Unk_ov21_021E9D76[v1] != 0xffff) { - v2[v0] = Unk_ov21_021E9D76[v1]; - v0++; - v1++; + while (Unk_ov21_021E9D76[index] != 0xffff) { + extraDungeons[extraDungeonCount] = Unk_ov21_021E9D76[index]; + extraDungeonCount++; + index++; } } if (param1->pokedexS->pokedexSFlag_4 == 0) { - v1 = 0; + index = 0; - while (Unk_ov21_021E9D72[v1] != 0xffff) { - v2[v0] = Unk_ov21_021E9D72[v1]; - v0++; - v1++; + while (Unk_ov21_021E9D72[index] != 0xffff) { + extraDungeons[extraDungeonCount] = Unk_ov21_021E9D72[index]; + extraDungeonCount++; + index++; } } if (param1->pokedexS->pokedexSFlag_2 == 0) { - v1 = 0; + index = 0; - while (Unk_ov21_021E9D6E[v1] != 0xffff) { - v2[v0] = Unk_ov21_021E9D6E[v1]; - v0++; - v1++; + while (Unk_ov21_021E9D6E[index] != 0xffff) { + extraDungeons[extraDungeonCount] = Unk_ov21_021E9D6E[index]; + extraDungeonCount++; + index++; } } if (param1->pokedexS->pokedexSFlag_3 == 0) { - v1 = 0; + index = 0; - while (Unk_ov21_021E9D7A[v1] != 0xffff) { - v2[v0] = Unk_ov21_021E9D7A[v1]; - v0++; - v1++; + while (Unk_ov21_021E9D7A[index] != 0xffff) { + extraDungeons[extraDungeonCount] = Unk_ov21_021E9D7A[index]; + extraDungeonCount++; + index++; } } - return v2; + return extraDungeons; } -static void ov21_021DD964(UnkStruct_ov21_021DD420 *param0, UnkStruct_ov21_021DCAE0 *param1) +static void ov21_021DD964(PokedexMapDisplay *mapDisplay, UnkStruct_ov21_021DCAE0 *param1) { BGL_FillWindow(¶m1->unk_00->unk_04, 0); - ov21_021D517C(¶m1->unk_00->unk_04, param0->unk_800->pRawData, param0->unk_800->W * 8, param0->unk_800->H * 8, 5, param0->unk_470, 30, 30, 89, 30); - ov21_021D517C(¶m1->unk_00->unk_04, param0->unk_7F8->pRawData, param0->unk_7F8->W * 8, param0->unk_7F8->H * 8, 5, param0->unk_EC, 30, 30, 89, 30); + ov21_021D517C(¶m1->unk_00->unk_04, mapDisplay->unk_800->pRawData, mapDisplay->unk_800->W * 8, mapDisplay->unk_800->H * 8, POKEDEXMAPXSCALE, mapDisplay->mapFieldCellMatrix_2, POKEDEXMAPHEIGHT, POKEDEXMAPWIDTH, 89, 30); + ov21_021D517C(¶m1->unk_00->unk_04, mapDisplay->unk_7F8->pRawData, mapDisplay->unk_7F8->W * 8, mapDisplay->unk_7F8->H * 8, POKEDEXMAPXSCALE, mapDisplay->mapFieldCellMatrix_1, POKEDEXMAPHEIGHT, POKEDEXMAPWIDTH, 89, 30); sub_0201A954(¶m1->unk_00->unk_04); } -static void ov21_021DD9E8(UnkStruct_ov21_021DD420 *param0, const UnkStruct_ov21_021DDABC *param1) +static void ov21_021DD9E8(PokedexMapDisplay *mapDisplay, const encounterCollection *enCollection) { - if ((param0->unk_834 <= 0) && (param0->unk_838 <= 0) && (param0->unk_83C <= 0) && (param0->unk_840 <= 0)) { - CellActor_SetDrawFlag(param0->unk_C8, 1); - sub_020129D0(param0->unk_CC->unk_00, 1); + if ((mapDisplay->unk_834 <= 0) && (mapDisplay->unk_838 <= 0) && (mapDisplay->unk_83C <= 0) && (mapDisplay->unk_840 <= 0)) { + CellActor_SetDrawFlag(mapDisplay->unk_C8, 1); + sub_020129D0(mapDisplay->unk_CC->unk_00, 1); } else { - CellActor_SetDrawFlag(param0->unk_C8, 0); - sub_020129D0(param0->unk_CC->unk_00, 0); + CellActor_SetDrawFlag(mapDisplay->unk_C8, 0); + sub_020129D0(mapDisplay->unk_CC->unk_00, 0); } } -static void ov21_021DDA48(UnkStruct_ov21_021DD420 *param0, int param1) +static void ov21_021DDA48(PokedexMapDisplay *mapDisplay, int param1) { int v0; for (v0 = 0; v0 < 3; v0++) { if (v0 == param1) { - sub_020129D0(param0->unk_E0[v0]->unk_00, 1); + sub_020129D0(mapDisplay->unk_E0[v0]->unk_00, 1); } else { - sub_020129D0(param0->unk_E0[v0]->unk_00, 0); + sub_020129D0(mapDisplay->unk_E0[v0]->unk_00, 0); } } } -static void ov21_021DDA80(UnkStruct_ov21_021DD420 *param0, UnkStruct_ov21_021DCAE0 *param1, const UnkStruct_ov21_021DCACC *param2, const UnkStruct_ov21_021DDABC *param3, int param4) +static void ov21_021DDA80(PokedexMapDisplay *mapDisplay, UnkStruct_ov21_021DCAE0 *param1, const UnkStruct_ov21_021DCACC *param2, const encounterCollection *enCollection, int param4) { - if (param0->encounterTime != param3->encounterTime) { - ov21_021DD710(param0, param2, param3, param4); - ov21_021DD964(param0, param1); - ov21_021DDA48(param0, param2->encounterTime); - ov21_021DD9E8(param0, param3); - param0->encounterTime = param3->encounterTime; + if (mapDisplay->encounterTime != enCollection->encounterTime) { + ov21_021DD710(mapDisplay, param2, enCollection, param4); + ov21_021DD964(mapDisplay, param1); + ov21_021DDA48(mapDisplay, param2->encounterTime); + ov21_021DD9E8(mapDisplay, enCollection); + mapDisplay->encounterTime = enCollection->encounterTime; } } -static void ov21_021DDABC(UnkStruct_ov21_021DDABC *param0, UnkStruct_ov21_021DCACC *param1, int heapID) +static void ov21_021DDABC(encounterCollection *enCollection, UnkStruct_ov21_021DCACC *param1, int heapID) { - int v0; - int v1; + int dungeonCategory; + int fieldCategory; int species = Pokedex_Sort_CurrentSpecies(param1->pokedexS); switch (param1->encounterTime) { case ENCTIME_MORNING: - v0 = 0; - v1 = 5; + dungeonCategory = PEFC_DUNGEONMORNING; + fieldCategory = PEFC_FIELDMORNING; break; case ENCTIME_DAY: - v0 = 1; - v1 = 6; + dungeonCategory = PEFC_DUNGEONDAY; + fieldCategory = PEFC_FIELDDAY; break; case ENCTIME_NIGHT: - v0 = 2; - v1 = 7; + dungeonCategory = PEFC_DUNGEONNIGHT; + fieldCategory = PEFC_FIELDNIGHT; break; default: GF_ASSERT(0); break; } - ov21_021D57B4(¶m0->dexEnc0, species, v0, heapID); - ov21_021D57B4(¶m0->dexEnc1, species, v1, heapID); + PokedexEncData_PopulateMapsEncounteredOn(&enCollection->dungeonsEncounteredOn, species, dungeonCategory, heapID); + PokedexEncData_PopulateMapsEncounteredOn(&enCollection->fieldsEncounteredOn, species, fieldCategory, heapID); if (Pokedex_Sort_PokedexUnlocked(param1->pokedexS) == 0) { - ov21_021D57B4(¶m0->dexEnc2, species, 3, heapID); - ov21_021D57B4(¶m0->dexEnc3, species, 8, heapID); + PokedexEncData_PopulateMapsEncounteredOn(&enCollection->dungeonSpecialEncounters, species, PEFC_DUNGEONSPECIAL, heapID); + PokedexEncData_PopulateMapsEncounteredOn(&enCollection->fieldSpecialEncounters, species, PEFC_FIELDSPECIAL, heapID); } else { - ov21_021D57B4(¶m0->dexEnc2, species, 4, heapID); - ov21_021D57B4(¶m0->dexEnc3, species, 9, heapID); + PokedexEncData_PopulateMapsEncounteredOn(&enCollection->dungeonSpecialEncounters, species, PEFC_DUNGEONSPECIALNATDEX, heapID); + PokedexEncData_PopulateMapsEncounteredOn(&enCollection->fieldSpecialEncounters, species, PEFC_FIELDSPECIALNATDEX, heapID); } } -static void ov21_021DDB68(UnkStruct_ov21_021DDABC *param0) +static void ov21_021DDB68(encounterCollection *enCollection) { - Free_pokedexEncData(¶m0->dexEnc0); - Free_pokedexEncData(¶m0->dexEnc1); - Free_pokedexEncData(¶m0->dexEnc2); - Free_pokedexEncData(¶m0->dexEnc3); + PokedexEncData_FreeMapsEncounteredOn(&enCollection->dungeonsEncounteredOn); + PokedexEncData_FreeMapsEncounteredOn(&enCollection->fieldsEncounteredOn); + PokedexEncData_FreeMapsEncounteredOn(&enCollection->dungeonSpecialEncounters); + PokedexEncData_FreeMapsEncounteredOn(&enCollection->fieldSpecialEncounters); } -static void ov21_021DDB8C(UnkStruct_ov21_021DD420 *param0) +static void ov21_021DDB8C(PokedexMapDisplay *mapDisplay) { - int v0; + int dungeonIndex; - param0->unk_80C = 0; - param0->unk_810 = 0; + mapDisplay->unk_80C = 0; + mapDisplay->unk_810 = 0; GXLayers_EngineAToggleLayers(GX_BLEND_PLANEMASK_BG1, 0); - for (v0 = 0; v0 < param0->unk_C4; v0++) { - CellActor_SetDrawFlag(param0->unk_04[v0], 0); + for (dungeonIndex = 0; dungeonIndex < mapDisplay->numDungeons; dungeonIndex++) { + CellActor_SetDrawFlag(mapDisplay->cellActorArray[dungeonIndex], 0); } } -static void ov21_021DDBCC(UnkStruct_ov21_021DD420 *param0) +static void ov21_021DDBCC(PokedexMapDisplay *mapDisplay) { - int v0; + int dungeonIndex; G2_SetBlendAlpha(GX_BLEND_PLANEMASK_BG1 | GX_BLEND_PLANEMASK_BG3, GX_BLEND_PLANEMASK_BG3, 0, 16); GXLayers_EngineAToggleLayers(GX_BLEND_PLANEMASK_BG1, 1); - for (v0 = 0; v0 < param0->unk_C4; v0++) { - CellActor_SetDrawFlag(param0->unk_04[v0], 0); + for (dungeonIndex = 0; dungeonIndex < mapDisplay->numDungeons; dungeonIndex++) { + CellActor_SetDrawFlag(mapDisplay->cellActorArray[dungeonIndex], 0); } } -static void ov21_021DDC14(UnkStruct_ov21_021DD420 *param0) +static void ov21_021DDC14(PokedexMapDisplay *mapDisplay) { fx32 v0; int v1; - int v2; + int dungeonIndex; - if (param0->unk_80C >= 32) { - param0->unk_80C = 0; + if (mapDisplay->unk_80C >= 32) { + mapDisplay->unk_80C = 0; - if (param0->unk_810 == 0) { - for (v2 = 0; v2 < param0->unk_C4; v2++) { - CellActor_SetDrawFlag(param0->unk_04[v2], 1); + if (mapDisplay->unk_810 == 0) { + for (dungeonIndex = 0; dungeonIndex < mapDisplay->numDungeons; dungeonIndex++) { + CellActor_SetDrawFlag(mapDisplay->cellActorArray[dungeonIndex], 1); } - param0->unk_810 = 1; + mapDisplay->unk_810 = 1; } else { GXLayers_EngineAToggleLayers(GX_BLEND_PLANEMASK_BG1, 1); - param0->unk_810 = 0; + mapDisplay->unk_810 = 0; } } - if (param0->unk_80C < 16) { - v1 = param0->unk_80C; + if (mapDisplay->unk_80C < 16) { + v1 = mapDisplay->unk_80C; } else { - v1 = 32 - param0->unk_80C; + v1 = 32 - mapDisplay->unk_80C; } v0 = FX_Mul((16 << FX32_SHIFT), (v1 << FX32_SHIFT)); @@ -1244,14 +1246,14 @@ static void ov21_021DDC14(UnkStruct_ov21_021DD420 *param0) G2_ChangeBlendAlpha(v0 >> FX32_SHIFT, 16); - param0->unk_80C++; + mapDisplay->unk_80C++; - if (param0->unk_80C >= 32) { - if (param0->unk_810 == 0) { + if (mapDisplay->unk_80C >= 32) { + if (mapDisplay->unk_810 == 0) { GXLayers_EngineAToggleLayers(GX_BLEND_PLANEMASK_BG1, 0); } else { - for (v2 = 0; v2 < param0->unk_C4; v2++) { - CellActor_SetDrawFlag(param0->unk_04[v2], 0); + for (dungeonIndex = 0; dungeonIndex < mapDisplay->numDungeons; dungeonIndex++) { + CellActor_SetDrawFlag(mapDisplay->cellActorArray[dungeonIndex], 0); } } } diff --git a/src/overlay021/pokedex_sort.c b/src/overlay021/pokedex_sort.c index f4a0608513..f370ca65d9 100644 --- a/src/overlay021/pokedex_sort.c +++ b/src/overlay021/pokedex_sort.c @@ -7,8 +7,8 @@ #include "overlay021/struct_ov21_021D3208.h" #include "overlay021/struct_ov21_021D3320.h" -#include "overlay021/struct_ov21_021D37DC.h" #include "overlay021/struct_ov21_021D3A60.h" +#include "overlay021/struct_speciesCaughtStatus.h" #include "core_sys.h" #include "heap.h" @@ -48,13 +48,13 @@ void Pokedex_Sort_PopulatePokedexStruct(pokedexStruct *pokedexS, UnkStruct_ov21_ pokedexS->timeOfDay = param1->timeOfDay; if (Pokedex_NationalUnlocked(pokedexS->dexData)) { - pokedexS->nationalDexUnlocked = 1; + pokedexS->isNationalDexUnlocked = 1; } else { - pokedexS->nationalDexUnlocked = 0; + pokedexS->isNationalDexUnlocked = 0; } if (param1->unk_20 == 2) { - if (pokedexS->nationalDexUnlocked) { + if (pokedexS->isNationalDexUnlocked) { isNationalDex = 1; } else { isNationalDex = 0; @@ -87,12 +87,12 @@ void Pokedex_Sort_PopulatePokedexStruct(pokedexStruct *pokedexS, UnkStruct_ov21_ ov21_021D3434(pokedexS, param1->unk_1C); ov21_021D344C(pokedexS, param1->unk_20); - pokedexS->TrainerGameCode = TrainerInfo_GameCode(param1->unk_04); - pokedexS->TrainerGender = TrainerInfo_Gender(param1->unk_04); + pokedexS->trainerGameCode = TrainerInfo_GameCode(param1->unk_04); + pokedexS->trainerGender = TrainerInfo_Gender(param1->unk_04); pokedexS->trainerName = TrainerInfo_NameNewStrbuf(param1->unk_04, heapID); pokedexS->HWData = Pokedex_HeightWeightData(heapID); - if (pokedexS->TrainerGender == 0) { + if (pokedexS->trainerGender == 0) { Pokedex_HeightWeightData_Load(pokedexS->HWData, 0, heapID); } else { Pokedex_HeightWeightData_Load(pokedexS->HWData, 1, heapID); @@ -359,7 +359,7 @@ BOOL ov21_021D36A4(const pokedexStruct *pokedexS, int param1) return 1; } - if (pokedexS->nationalDexUnlocked) { + if (pokedexS->isNationalDexUnlocked) { return 1; } @@ -468,7 +468,7 @@ int Pokedex_Sort_CurrentCaughtStatus(const pokedexStruct *pokedexS) return pokedexS->pokedexCompletion.caughtStatusArray[pokedexS->pokedexCompletion.unk_F68].caughtStatus; } -const speciesCaughtStatusStruct *Pokedex_Sort_SpeciesCaughtStatus(const pokedexStruct *pokedexS, int dexIndex) +const speciesCaughtStatus *Pokedex_Sort_SpeciesCaughtStatus(const pokedexStruct *pokedexS, int dexIndex) { if (Pokedex_Sort_IsValidDexIndex(pokedexS, dexIndex)) { return &pokedexS->pokedexCompletion.caughtStatusArray[dexIndex]; @@ -563,7 +563,7 @@ Strbuf *Pokedex_Sort_TrainerName(const pokedexStruct *pokedexS) u32 Pokedex_Sort_TrainerGender(const pokedexStruct *pokedexS) { - return pokedexS->TrainerGender; + return pokedexS->trainerGender; } BOOL ov21_021D392C(const pokedexStruct *pokedexS, int param1) @@ -651,9 +651,9 @@ static void Pokedex_Sort_CaughtStatus(pokedexCompletionStruct *pokedexCompletion for (index = 0; index < numEncountered; index++) { if (Pokedex_CaughtSpecies(dexData, speciesArray[index])) { - pokedexCompletion->caughtStatusArray[pokedexCompletion->numEncountered].caughtStatus = 2; + pokedexCompletion->caughtStatusArray[pokedexCompletion->numEncountered].caughtStatus = CS_CAUGHT; } else { - pokedexCompletion->caughtStatusArray[pokedexCompletion->numEncountered].caughtStatus = 1; + pokedexCompletion->caughtStatusArray[pokedexCompletion->numEncountered].caughtStatus = CS_ENCOUNTERED; } pokedexCompletion->caughtStatusArray[pokedexCompletion->numEncountered].species = speciesArray[index]; @@ -947,7 +947,7 @@ static void Pokedex_Sort_NumSeenNCaught(pokedexCompletionStruct *pokedexCompleti *numCaught = 0; for (index = 0; index < pokedexCompletion->numEncountered; index++) { - if (pokedexCompletion->caughtStatusArray[index].caughtStatus == 2) { + if (pokedexCompletion->caughtStatusArray[index].caughtStatus == CS_CAUGHT) { (*numCaught)++; } diff --git a/src/scrcmd.c b/src/scrcmd.c index d51ee84e00..28e419cab5 100644 --- a/src/scrcmd.c +++ b/src/scrcmd.c @@ -6585,7 +6585,7 @@ static BOOL ScrCmd_22B(ScriptContext *ctx) static BOOL ScrCmd_22C(ScriptContext *ctx) { - Pokedex_CanDetectForms_True(SaveData_Pokedex(ctx->fieldSystem->saveData)); + Pokedex_TurnOnFormDetection(SaveData_Pokedex(ctx->fieldSystem->saveData)); return 0; } diff --git a/src/unk_0202631C.c b/src/unk_0202631C.c index 348ad635fa..734e72166d 100644 --- a/src/unk_0202631C.c +++ b/src/unk_0202631C.c @@ -1151,7 +1151,7 @@ BOOL Pokedex_CanDetectForms(const PokedexData *dexData) return dexData->canDetectForms; } -void Pokedex_CanDetectForms_True(PokedexData *dexData) +void Pokedex_TurnOnFormDetection(PokedexData *dexData) { CheckPokedexIntegrity(dexData); dexData->canDetectForms = 1; diff --git a/tools/scripts/make_pokedex_data.py b/tools/scripts/make_pokedex_data.py index fe594cdc17..8fb75fe5a5 100644 --- a/tools/scripts/make_pokedex_data.py +++ b/tools/scripts/make_pokedex_data.py @@ -25,8 +25,6 @@ argparser.add_argument('-p', '--private-dir', argparser.add_argument('-o', '--output-dir', required=True, help='Path to the output directory (where the NARC will be made)') -argparser.add_argument('pokedex', - help='List of pokemon in the Sinnoh Pokedex') argparser.add_argument('giratina_form', help='String of either giratina_origin or giratina_altered') args = argparser.parse_args() @@ -75,7 +73,7 @@ for i, species in enumerate(PokemonSpecies): if subdir in ['egg', 'bad_egg']: continue - with open(source_dir / '../../../../pokemon' / subdir / 'data.json', 'r', encoding='utf-8') as data_file: + with open(source_dir / subdir / 'data.json', 'r', encoding='utf-8') as data_file: pkdata = json.load(data_file) pkdexdata = pkdata['pokedex_data'] if subdir == 'giratina': @@ -114,7 +112,7 @@ for i, species in enumerate(PokemonSpecies): nameData[i-1] = subdir.replace('porygon2','porygon_z2') # sinnoh dex order -with open(args.pokedex) as data_file: +with open(source_dir / 'sinnoh_pokedex.json') as data_file: dexData = json.load(data_file) for mon in dexData: if mon not in ['SPECIES_EGG', 'SPECIES_BAD_EGG', 'SPECIES_NONE', 'SPECIES_ARCEUS']: @@ -158,8 +156,10 @@ if args.giratina_form == 'giratina_origin': if args.giratina_form == 'giratina_altered': output_name = 'zukan_data_gira' +numDigits = len(str(NUM_FILES)) + for i in range(NUM_FILES): - target_fname = str(private_dir / output_name) + f'_{i:02}.bin' + target_fname = str(private_dir / output_name) + f'_{i:0{numDigits}}.bin' with open(target_fname, 'wb+') as target_file: target_file.write(binData[i]) diff --git a/tools/scripts/make_pokedex_enc_platinum.py b/tools/scripts/make_pokedex_enc_platinum.py index 370dbe0c46..f6c3e28bc7 100644 --- a/tools/scripts/make_pokedex_enc_platinum.py +++ b/tools/scripts/make_pokedex_enc_platinum.py @@ -203,13 +203,16 @@ honeyTrees = [ NUM_POKEMON = len(PokemonSpecies) - 1 NUM_FILES = NUM_POKEMON * 10 + 4 +NUM_MAPS = 183 + +numDigits = len(str(NUM_FILES)) binData = bytes() for dungeon in file_0: for pos in dungeon: binData = binData + pos.to_bytes(1, 'little') -target_fname = str(private_dir / output_name) + '_00000.bin' +target_fname = str(private_dir / output_name) + f'_{0:0{numDigits}}.bin' with open(target_fname, 'wb+') as target_file: target_file.write(binData) @@ -218,7 +221,7 @@ for dungeon in file_1: for pos in dungeon: binData = binData + pos.to_bytes(1, 'little') -target_fname = str(private_dir / output_name) + '_00001.bin' +target_fname = str(private_dir / output_name) + f'_{1:0{numDigits}}.bin' with open(target_fname, 'wb+') as target_file: target_file.write(binData) @@ -227,7 +230,7 @@ for field in file_2: for pos in field: binData = binData + pos.to_bytes(1, 'little') -target_fname = str(private_dir / output_name) + '_00002.bin' +target_fname = str(private_dir / output_name) + f'_{2:0{numDigits}}.bin' with open(target_fname, 'wb+') as target_file: target_file.write(binData) @@ -236,134 +239,154 @@ for field in file_3: for pos in field: binData = binData + pos.to_bytes(1, 'little') -target_fname = str(private_dir / output_name) + '_00003.bin' +target_fname = str(private_dir / output_name) + f'_{3:0{numDigits}}.bin' with open(target_fname, 'wb+') as target_file: target_file.write(binData) -def SearchLand(species, encounterData, absent, category): - encData = 0 - while ((encData < 12) and absent): +dungeonMorning = [set() for species in range(NUM_POKEMON)] +dungeonDay = [set() for species in range(NUM_POKEMON)] +dungeonNight = [set() for species in range(NUM_POKEMON)] +dungeonSpecial = [set() for species in range(NUM_POKEMON)] +dungeonSpecialNatDex = [set() for species in range(NUM_POKEMON)] +fieldMorning = [set() for species in range(NUM_POKEMON)] +fieldDay = [set() for species in range(NUM_POKEMON)] +fieldNight = [set() for species in range(NUM_POKEMON)] +fieldSpecial = [set() for species in range(NUM_POKEMON)] +fieldSpecialNatDex = [set() for species in range(NUM_POKEMON)] - if (((encData == 2) or (encData == 3)) and (category > 0)): - if (category == 1): - enc = encounterData["morning"][encData - 2] - if (category == 2): - enc = encounterData["night"][encData - 2] - else: - enc = encounterData["land_encounters"][encData]["species"] - if (enc == species): - absent = False - encData += 1 - return absent - -def SearchWater(species, encounterData, absent): - encData = 0 - while ((encData < 5) and absent): - enc = encounterData["surf_encounters"][encData]["species"] - if (enc == species): - absent = False - enc = encounterData["old_rod_encounters"][encData]["species"] - if (enc == species): - absent = False - enc = encounterData["good_rod_encounters"][encData]["species"] - if (enc == species): - absent = False - enc = encounterData["super_rod_encounters"][encData]["species"] - if (enc == species): - absent = False - encData += 1 - return absent - -def SearchRadar(species, encounterData, absent): - encData = 0 - while ((encData < 4) and absent): - enc = encounterData["radar"][encData] - if (enc == species): - absent = False - encData += 1 - return absent - -def SearchSpecial(species, encounterData, absent): - encData = 0 - if (species == "SPECIES_NONE"): - return False - while ((encData < len(encounterData["special_encounters"])) and absent): - enc = encounterData["special_encounters"][encData] - if (enc == species): - absent = False - encData += 1 - return absent - -def SearchSpecialNatDex(species, encounterData, absent): - encData = 0 - while ((encData < len(encounterData["specialnatdex_encounters"])) and absent): - enc = encounterData["specialnatdex_encounters"][encData] - if (enc == species): - absent = False - encData += 1 - if absent: - absent = SearchRadar(species, encounterData, absent) - return absent - -def CategorySearch(species, encounterData, category): - absent = True - - if (category < 3): - absent = SearchLand(species, encounterData, absent, category) - if absent: - absent = SearchWater(species, encounterData, absent) - if (category == 3): - absent = SearchSpecial(species, encounterData, absent) - if (category == 4): - absent = SearchSpecialNatDex(species, encounterData, absent) - - return absent - -for dexNum, species in enumerate(PokemonSpecies): - if species.name in ['SPECIES_BAD_EGG']: - continue - species = species.name - - for category in range(10): - fileNum = NUM_POKEMON * category + dexNum + 4 - encList = [] - - for archiveID in range(183): - with open(source_dir / '../../../../field/encounters' / f"{archiveID:03}.json", encoding='utf-8') as encounter_file: +for archiveID in range(NUM_MAPS): + with open(source_dir / f"{archiveID:03}.json", encoding='utf-8') as encounter_file: encounterData = json.load(encounter_file) - areaData = encounterData["map_category"] - areaType = areaData["map_type"] - areaNum = areaData["map_number"] + mapData = encounterData["map_category"] + mapType = mapData["map_type"] + mapNum = mapData["map_number"] - if (category < 5): - if (areaType == 'field'): - continue - else: - if (areaType == 'dungeon'): - continue - if (areaNum in encList): - continue + if (mapType == 'dungeon'): + for i, slot in enumerate(encounterData["land_encounters"]): + species = slot["species"] + dungeonMorning[PokemonSpecies[species].value].add(mapNum) - absent = CategorySearch(species, encounterData, category%5) + if ((i == 2) or (i == 3)): + species = encounterData["morning"][i - 2] + dungeonDay[PokemonSpecies[species].value].add(mapNum) - if not absent: - encList.append(areaNum) + species = encounterData["night"][i - 2] + dungeonNight[PokemonSpecies[species].value].add(mapNum) + else: + dungeonDay[PokemonSpecies[species].value].add(mapNum) + dungeonNight[PokemonSpecies[species].value].add(mapNum) - if (((category == 3) or (category == 4)) and (species in honeyTrees)): - encList.append(21) - if (((category == 8) or (category == 9)) and (species in honeyTrees)): - encList.append(50) - encList.sort() - encList.append(0) + for slot in encounterData["surf_encounters"]: + species = slot["species"] + dungeonMorning[PokemonSpecies[species].value].add(mapNum) + dungeonDay[PokemonSpecies[species].value].add(mapNum) + dungeonNight[PokemonSpecies[species].value].add(mapNum) + for slot in encounterData["old_rod_encounters"]: + species = slot["species"] + dungeonMorning[PokemonSpecies[species].value].add(mapNum) + dungeonDay[PokemonSpecies[species].value].add(mapNum) + dungeonNight[PokemonSpecies[species].value].add(mapNum) + + for slot in encounterData["good_rod_encounters"]: + species = slot["species"] + dungeonMorning[PokemonSpecies[species].value].add(mapNum) + dungeonDay[PokemonSpecies[species].value].add(mapNum) + dungeonNight[PokemonSpecies[species].value].add(mapNum) + + for slot in encounterData["super_rod_encounters"]: + species = slot["species"] + dungeonMorning[PokemonSpecies[species].value].add(mapNum) + dungeonDay[PokemonSpecies[species].value].add(mapNum) + dungeonNight[PokemonSpecies[species].value].add(mapNum) + + for species in encounterData["special_encounters"]: + dungeonSpecial[PokemonSpecies[species].value].add(mapNum) + dungeonSpecial[0].add(mapNum) + + for species in encounterData["radar"]: + dungeonSpecialNatDex[PokemonSpecies[species].value].add(mapNum) + for species in encounterData["specialnatdex_encounters"]: + dungeonSpecialNatDex[PokemonSpecies[species].value].add(mapNum) + + if (mapType == 'field'): + for i, slot in enumerate(encounterData["land_encounters"]): + species = slot["species"] + fieldMorning[PokemonSpecies[species].value].add(mapNum) + + if ((i == 2) or (i == 3)): + species = encounterData["morning"][i - 2] + fieldDay[PokemonSpecies[species].value].add(mapNum) + + species = encounterData["night"][i - 2] + fieldNight[PokemonSpecies[species].value].add(mapNum) + else: + fieldDay[PokemonSpecies[species].value].add(mapNum) + fieldNight[PokemonSpecies[species].value].add(mapNum) + + for slot in encounterData["surf_encounters"]: + species = slot["species"] + fieldMorning[PokemonSpecies[species].value].add(mapNum) + fieldDay[PokemonSpecies[species].value].add(mapNum) + fieldNight[PokemonSpecies[species].value].add(mapNum) + + for slot in encounterData["old_rod_encounters"]: + species = slot["species"] + fieldMorning[PokemonSpecies[species].value].add(mapNum) + fieldDay[PokemonSpecies[species].value].add(mapNum) + fieldNight[PokemonSpecies[species].value].add(mapNum) + + for slot in encounterData["good_rod_encounters"]: + species = slot["species"] + fieldMorning[PokemonSpecies[species].value].add(mapNum) + fieldDay[PokemonSpecies[species].value].add(mapNum) + fieldNight[PokemonSpecies[species].value].add(mapNum) + + for slot in encounterData["super_rod_encounters"]: + species = slot["species"] + fieldMorning[PokemonSpecies[species].value].add(mapNum) + fieldDay[PokemonSpecies[species].value].add(mapNum) + fieldNight[PokemonSpecies[species].value].add(mapNum) + + for species in encounterData["special_encounters"]: + fieldSpecial[PokemonSpecies[species].value].add(mapNum) + fieldSpecial[0].add(mapNum) + + for species in encounterData["radar"]: + fieldSpecialNatDex[PokemonSpecies[species].value].add(mapNum) + for species in encounterData["specialnatdex_encounters"]: + fieldSpecialNatDex[PokemonSpecies[species].value].add(mapNum) + +for species in honeyTrees: + dungeonSpecial[PokemonSpecies[species].value].add(21) + dungeonSpecialNatDex[PokemonSpecies[species].value].add(21) + fieldSpecial[PokemonSpecies[species].value].add(50) + fieldSpecialNatDex[PokemonSpecies[species].value].add(50) + +for species in range(NUM_POKEMON): + speciesSets = [dungeonMorning[species], + dungeonDay[species], + dungeonNight[species], + dungeonSpecial[species], + dungeonSpecialNatDex[species], + fieldMorning[species], + fieldDay[species], + fieldNight[species], + fieldSpecial[species], + fieldSpecialNatDex[species]] + + for i, mapSet in enumerate(speciesSets): binData = bytes() - for areaNum in encList: - binData = binData + areaNum.to_bytes(4, 'little') + mapList = list(mapSet) + mapList.sort() + mapList.append(0) + for map in mapList: + binData = binData + map.to_bytes(4, 'little') - target_fname = str(private_dir / output_name) + f'_{fileNum:05}.bin' + fileNum = 4 + species + NUM_POKEMON * i + target_fname = str(private_dir / output_name) + f'_{fileNum:0{numDigits}}.bin' with open(target_fname, 'wb+') as target_file: target_file.write(binData) - subprocess.run([args.knarc, '-d', private_dir, '-p', str(output_dir / output_name) + '.narc'])