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
This commit is contained in:
h2o-DS
2024-10-19 23:15:03 -04:00
parent 304a6714dd
commit bffc52cf48
28 changed files with 868 additions and 812 deletions

View File

@@ -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);

View File

@@ -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

View File

@@ -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

View File

@@ -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);

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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;

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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;

View File

@@ -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

View File

@@ -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);

View File

@@ -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@'
]

View File

@@ -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);
}

View File

@@ -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:

View File

@@ -3,127 +3,129 @@
#include <nitro.h>
#include <string.h>
#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, &param3[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;
}

View File

@@ -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]);

File diff suppressed because it is too large Load Diff

View File

@@ -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)++;
}

View File

@@ -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;
}

View File

@@ -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;

View File

@@ -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])

View File

@@ -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'])