Skip to content

Commit

Permalink
Merge pull request #143 from wildfire248/dex_numbers
Browse files Browse the repository at this point in the history
Build SinnohDex<->NatDex mappings from source
  • Loading branch information
lhearachel authored Feb 11, 2024
2 parents 3e8a882 + ddee29c commit 3471f61
Show file tree
Hide file tree
Showing 14 changed files with 389 additions and 19 deletions.
19 changes: 17 additions & 2 deletions include/pokemon.h
Original file line number Diff line number Diff line change
Expand Up @@ -784,8 +784,23 @@ void Pokemon_FromBoxPokemon(BoxPokemon *boxMon, Pokemon *mon);
*/
u8 Party_GetMaxLevel(Party *party);

u16 sub_020775A4(u16 param0);
u16 sub_020775C4(u16 param0);
/**
* @brief Gets the Sinnoh Pokedex number of a pokemon from its National Pokedex number
*
* @param species The National Pokedex number of a pokemon
* @return The Sinnoh Pokedex number of that pokemon (or zero if none exists)
*/
u16 Pokemon_SinnohDexNumber(u16 species);

/**
* @brief Gets the National Pokedex number of a pokemon from its Sinnoh Pokedex number
* (Note: Inputting 0 here will return 493 (Arceus))
*
* @param sinnohDexNumber The Sinnoh Pokedex number of a pokemon
* @return The National Pokedex number of that pokemon (or zero if none exists)
*/
u16 Pokemon_NationalDexNumber(u16 sinnohDexNumber);

void Pokemon_Copy(Pokemon *src, Pokemon *dest);
void BoxPokemon_Copy(BoxPokemon *src, BoxPokemon *dest);
void BoxPokemon_FromPokemon(Pokemon *src, BoxPokemon *dest);
Expand Down
10 changes: 8 additions & 2 deletions platinum.us/rom.rsf
Original file line number Diff line number Diff line change
Expand Up @@ -390,8 +390,14 @@ RomSpec
File arc/tv.narc
File fielddata/maptable/mapname.bin
File poketool/pokezukan.narc
File poketool/pl_pokezukan.narc
File poketool/shinzukan.narc

Root /poketool
HostRoot res/pokemon
File pl_pokezukan.narc
File shinzukan.narc

Root /
HostRoot res/prebuilt
File poketool/pokeanm/pokeanm.narc
File poketool/pokeanm/pl_pokeanm.narc
File demo/shinka/data/particle/shinka_demo_particle.narc
Expand Down
31 changes: 31 additions & 0 deletions res/pokemon/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ otherpoke_shared = files(
'.shared/shadows.png',
)

sinnoh_pokedex = files('sinnoh_pokedex.json')

# Process mons in national dex order
pokemon_subdirs = [
Expand Down Expand Up @@ -725,6 +726,34 @@ pl_poke_data_narc = custom_target('pl_poke_data.narc',
]
)

pl_pokezukan_narc = custom_target('pl_pokezukan.narc',
output: 'pl_pokezukan.narc',
input: personal_files,
env: json2bin_env,
command: [
make_pl_pokezukan_py,
'--knarc', knarc_exe,
'--source-dir', '@CURRENT_SOURCE_DIR@',
'--private-dir', '@PRIVATE_DIR@',
'--output-dir', '@OUTDIR@',
sinnoh_pokedex
]
)

shinzukan_narc = custom_target('shinzukan.narc',
output: 'shinzukan.narc',
input: personal_files,
env: json2bin_env,
command: [
make_shinzukan_py,
'--knarc', knarc_exe,
'--source-dir', '@CURRENT_SOURCE_DIR@',
'--private-dir', '@PRIVATE_DIR@',
'--output-dir', '@OUTDIR@',
sinnoh_pokedex
]
)

nitrofs_files += pl_personal_narc
nitrofs_files += evo_narc
nitrofs_files += pl_poke_icon_narc
Expand All @@ -733,3 +762,5 @@ nitrofs_files += pl_otherpoke_narc
nitrofs_files += wotbl_narc
nitrofs_files += height_narc
nitrofs_files += pl_poke_data_narc
nitrofs_files += pl_pokezukan_narc
nitrofs_files += shinzukan_narc
213 changes: 213 additions & 0 deletions res/pokemon/sinnoh_pokedex.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
[
"SPECIES_ARCEUS",
"SPECIES_TURTWIG",
"SPECIES_GROTLE",
"SPECIES_TORTERRA",
"SPECIES_CHIMCHAR",
"SPECIES_MONFERNO",
"SPECIES_INFERNAPE",
"SPECIES_PIPLUP",
"SPECIES_PRINPLUP",
"SPECIES_EMPOLEON",
"SPECIES_STARLY",
"SPECIES_STARAVIA",
"SPECIES_STARAPTOR",
"SPECIES_BIDOOF",
"SPECIES_BIBAREL",
"SPECIES_KRICKETOT",
"SPECIES_KRICKETUNE",
"SPECIES_SHINX",
"SPECIES_LUXIO",
"SPECIES_LUXRAY",
"SPECIES_ABRA",
"SPECIES_KADABRA",
"SPECIES_ALAKAZAM",
"SPECIES_MAGIKARP",
"SPECIES_GYARADOS",
"SPECIES_BUDEW",
"SPECIES_ROSELIA",
"SPECIES_ROSERADE",
"SPECIES_ZUBAT",
"SPECIES_GOLBAT",
"SPECIES_CROBAT",
"SPECIES_GEODUDE",
"SPECIES_GRAVELER",
"SPECIES_GOLEM",
"SPECIES_ONIX",
"SPECIES_STEELIX",
"SPECIES_CRANIDOS",
"SPECIES_RAMPARDOS",
"SPECIES_SHIELDON",
"SPECIES_BASTIODON",
"SPECIES_MACHOP",
"SPECIES_MACHOKE",
"SPECIES_MACHAMP",
"SPECIES_PSYDUCK",
"SPECIES_GOLDUCK",
"SPECIES_BURMY",
"SPECIES_WORMADAM",
"SPECIES_MOTHIM",
"SPECIES_WURMPLE",
"SPECIES_SILCOON",
"SPECIES_BEAUTIFLY",
"SPECIES_CASCOON",
"SPECIES_DUSTOX",
"SPECIES_COMBEE",
"SPECIES_VESPIQUEN",
"SPECIES_PACHIRISU",
"SPECIES_BUIZEL",
"SPECIES_FLOATZEL",
"SPECIES_CHERUBI",
"SPECIES_CHERRIM",
"SPECIES_SHELLOS",
"SPECIES_GASTRODON",
"SPECIES_HERACROSS",
"SPECIES_AIPOM",
"SPECIES_AMBIPOM",
"SPECIES_DRIFLOON",
"SPECIES_DRIFBLIM",
"SPECIES_BUNEARY",
"SPECIES_LOPUNNY",
"SPECIES_GASTLY",
"SPECIES_HAUNTER",
"SPECIES_GENGAR",
"SPECIES_MISDREAVUS",
"SPECIES_MISMAGIUS",
"SPECIES_MURKROW",
"SPECIES_HONCHKROW",
"SPECIES_GLAMEOW",
"SPECIES_PURUGLY",
"SPECIES_GOLDEEN",
"SPECIES_SEAKING",
"SPECIES_BARBOACH",
"SPECIES_WHISCASH",
"SPECIES_CHINGLING",
"SPECIES_CHIMECHO",
"SPECIES_STUNKY",
"SPECIES_SKUNTANK",
"SPECIES_MEDITITE",
"SPECIES_MEDICHAM",
"SPECIES_BRONZOR",
"SPECIES_BRONZONG",
"SPECIES_PONYTA",
"SPECIES_RAPIDASH",
"SPECIES_BONSLY",
"SPECIES_SUDOWOODO",
"SPECIES_MIME_JR",
"SPECIES_MR_MIME",
"SPECIES_HAPPINY",
"SPECIES_CHANSEY",
"SPECIES_BLISSEY",
"SPECIES_CLEFFA",
"SPECIES_CLEFAIRY",
"SPECIES_CLEFABLE",
"SPECIES_CHATOT",
"SPECIES_PICHU",
"SPECIES_PIKACHU",
"SPECIES_RAICHU",
"SPECIES_HOOTHOOT",
"SPECIES_NOCTOWL",
"SPECIES_SPIRITOMB",
"SPECIES_GIBLE",
"SPECIES_GABITE",
"SPECIES_GARCHOMP",
"SPECIES_MUNCHLAX",
"SPECIES_SNORLAX",
"SPECIES_UNOWN",
"SPECIES_RIOLU",
"SPECIES_LUCARIO",
"SPECIES_WOOPER",
"SPECIES_QUAGSIRE",
"SPECIES_WINGULL",
"SPECIES_PELIPPER",
"SPECIES_GIRAFARIG",
"SPECIES_HIPPOPOTAS",
"SPECIES_HIPPOWDON",
"SPECIES_AZURILL",
"SPECIES_MARILL",
"SPECIES_AZUMARILL",
"SPECIES_SKORUPI",
"SPECIES_DRAPION",
"SPECIES_CROAGUNK",
"SPECIES_TOXICROAK",
"SPECIES_CARNIVINE",
"SPECIES_REMORAID",
"SPECIES_OCTILLERY",
"SPECIES_FINNEON",
"SPECIES_LUMINEON",
"SPECIES_TENTACOOL",
"SPECIES_TENTACRUEL",
"SPECIES_FEEBAS",
"SPECIES_MILOTIC",
"SPECIES_MANTYKE",
"SPECIES_MANTINE",
"SPECIES_SNOVER",
"SPECIES_ABOMASNOW",
"SPECIES_SNEASEL",
"SPECIES_WEAVILE",
"SPECIES_UXIE",
"SPECIES_MESPRIT",
"SPECIES_AZELF",
"SPECIES_DIALGA",
"SPECIES_PALKIA",
"SPECIES_MANAPHY",
"SPECIES_ROTOM",
"SPECIES_GLIGAR",
"SPECIES_GLISCOR",
"SPECIES_NOSEPASS",
"SPECIES_PROBOPASS",
"SPECIES_RALTS",
"SPECIES_KIRLIA",
"SPECIES_GARDEVOIR",
"SPECIES_GALLADE",
"SPECIES_LICKITUNG",
"SPECIES_LICKILICKY",
"SPECIES_EEVEE",
"SPECIES_VAPOREON",
"SPECIES_JOLTEON",
"SPECIES_FLAREON",
"SPECIES_ESPEON",
"SPECIES_UMBREON",
"SPECIES_LEAFEON",
"SPECIES_GLACEON",
"SPECIES_SWABLU",
"SPECIES_ALTARIA",
"SPECIES_TOGEPI",
"SPECIES_TOGETIC",
"SPECIES_TOGEKISS",
"SPECIES_HOUNDOUR",
"SPECIES_HOUNDOOM",
"SPECIES_MAGNEMITE",
"SPECIES_MAGNETON",
"SPECIES_MAGNEZONE",
"SPECIES_TANGELA",
"SPECIES_TANGROWTH",
"SPECIES_YANMA",
"SPECIES_YANMEGA",
"SPECIES_TROPIUS",
"SPECIES_RHYHORN",
"SPECIES_RHYDON",
"SPECIES_RHYPERIOR",
"SPECIES_DUSKULL",
"SPECIES_DUSCLOPS",
"SPECIES_DUSKNOIR",
"SPECIES_PORYGON",
"SPECIES_PORYGON2",
"SPECIES_PORYGON_Z",
"SPECIES_SCYTHER",
"SPECIES_SCIZOR",
"SPECIES_ELEKID",
"SPECIES_ELECTABUZZ",
"SPECIES_ELECTIVIRE",
"SPECIES_MAGBY",
"SPECIES_MAGMAR",
"SPECIES_MAGMORTAR",
"SPECIES_SWINUB",
"SPECIES_PILOSWINE",
"SPECIES_MAMOSWINE",
"SPECIES_SNORUNT",
"SPECIES_GLALIE",
"SPECIES_FROSLASS",
"SPECIES_ABSOL",
"SPECIES_GIRATINA"
]
2 changes: 0 additions & 2 deletions res/prebuilt/poketool/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ subdir('trmsg')
subdir('waza')

prebuilt_files = [
'pl_pokezukan.narc',
'pokezukan.narc',
'shinzukan.narc'
]

foreach f : prebuilt_files
Expand Down
2 changes: 1 addition & 1 deletion src/overlay021/ov21_021D0D80.c
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ Window * ov21_021D172C (UnkStruct_ov21_021D4C0C * param0, int param1, int param2
Window * v0;
int v1;

v1 = sub_020775A4(param2);
v1 = Pokemon_SinnohDexNumber(param2);

if ((param2 != 377) && (param2 != 378) && (param2 != 379)) {
GF_ASSERT(v1 > 0);
Expand Down
2 changes: 1 addition & 1 deletion src/overlay028/ov28_022561C0.c
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ static void ov28_02256914 (UnkStruct_ov28_02256210 * param0, const UnkStruct_ov2
if (sub_02027474(v1)) {
v2 = v0;
} else {
v2 = sub_020775C4((u16)v0);
v2 = Pokemon_NationalDexNumber((u16)v0);
}

if (((v2 > 0) && (v2 <= 493)) && sub_02026FE8(v1, v2)) {
Expand Down
11 changes: 5 additions & 6 deletions src/pokemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -3804,22 +3804,21 @@ u8 Party_GetMaxLevel(Party *party)
return result;
}

u16 sub_020775A4(u16 param0)
u16 Pokemon_SinnohDexNumber(u16 species)
{
u16 result;

NARC_ReadFromMemberByIndexPair(&result, NARC_INDEX_POKETOOL__PL_POKEZUKAN, 0, param0 * 2, 2);
NARC_ReadFromMemberByIndexPair(&result, NARC_INDEX_POKETOOL__PL_POKEZUKAN, 0, species * 2, 2);

return result;
}

u16 sub_020775C4(u16 param0)
u16 Pokemon_NationalDexNumber(u16 sinnohDexNumber)
{
u16 result = 0;

// TODO enum value?
if (param0 <= 210) {
NARC_ReadFromMemberByIndexPair(&result, NARC_INDEX_POKETOOL__SHINZUKAN, 0, param0 * 2, 2);
if (sinnohDexNumber <= 210) {
NARC_ReadFromMemberByIndexPair(&result, NARC_INDEX_POKETOOL__SHINZUKAN, 0, sinnohDexNumber * 2, 2);
}

return result;
Expand Down
6 changes: 3 additions & 3 deletions src/unk_0202631C.c
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,7 @@ u16 sub_02026E64 (const UnkStruct_02026324 * param0)

for (v0 = 1; v0 <= 493; v0++) {
if (Pokedex_CaughtSpecies(param0, v0) == 1) {
if (sub_020775A4(v0) != 0) {
if (Pokemon_SinnohDexNumber(v0) != 0) {
v1++;
}
}
Expand All @@ -835,7 +835,7 @@ u16 sub_02026EAC (const UnkStruct_02026324 * param0)

for (v0 = 1; v0 <= 493; v0++) {
if (sub_02026FE8(param0, v0) == 1) {
if (sub_020775A4(v0) != 0) {
if (Pokemon_SinnohDexNumber(v0) != 0) {
v1++;
}
}
Expand Down Expand Up @@ -898,7 +898,7 @@ u16 sub_02026F58 (const UnkStruct_02026324 * param0)

for (v0 = 1; v0 <= 493; v0++) {
if (sub_02026FE8(param0, v0) == 1) {
v2 = sub_020775A4(v0);
v2 = Pokemon_SinnohDexNumber(v0);

if (v2 != 0) {
if (sub_02026D68(v0) == 1) {
Expand Down
2 changes: 1 addition & 1 deletion src/unk_0203F6C4.c
Original file line number Diff line number Diff line change
Expand Up @@ -6606,7 +6606,7 @@ static BOOL sub_02044BE8 (UnkStruct_0203E724 * param0)
*v1 = 25;

for (v4 = 1, v5 = 0; v4 <= 493; v4++) {
if ((sub_02026FE8(v0, v4) == 1) && (sub_020775A4(v4) != 0)) {
if ((sub_02026FE8(v0, v4) == 1) && (Pokemon_SinnohDexNumber(v4) != 0)) {
if (v5 == v3) {
*v1 = v4;
break;
Expand Down
Loading

0 comments on commit 3471f61

Please sign in to comment.