From 7d5c5640e44f7578b8d7c5bc9b436dcfe55bcdf6 Mon Sep 17 00:00:00 2001 From: wildfire Date: Thu, 8 Feb 2024 12:42:04 +0000 Subject: [PATCH 1/5] Create Sinnoh Pokedex json --- res/pokemon/sinnoh_pokedex.json | 213 ++++++++++++++++++++++++++++++++ 1 file changed, 213 insertions(+) create mode 100644 res/pokemon/sinnoh_pokedex.json diff --git a/res/pokemon/sinnoh_pokedex.json b/res/pokemon/sinnoh_pokedex.json new file mode 100644 index 0000000000..fd0cb8a138 --- /dev/null +++ b/res/pokemon/sinnoh_pokedex.json @@ -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" +] \ No newline at end of file From 331d1aeaa1abca021d7e7ccf025e9dd16bca7f42 Mon Sep 17 00:00:00 2001 From: wildfire Date: Thu, 8 Feb 2024 13:33:35 +0000 Subject: [PATCH 2/5] Build pl_pokezukan.narc and shinzukan.narc from json --- platinum.us/rom.rsf | 10 ++++-- res/pokemon/meson.build | 30 +++++++++++++++++ res/prebuilt/poketool/meson.build | 2 -- tools/scripts/make_pl_pokezukan.py | 54 ++++++++++++++++++++++++++++++ tools/scripts/make_shinzukan.py | 54 ++++++++++++++++++++++++++++++ tools/scripts/meson.build | 2 ++ 6 files changed, 148 insertions(+), 4 deletions(-) create mode 100644 tools/scripts/make_pl_pokezukan.py create mode 100644 tools/scripts/make_shinzukan.py diff --git a/platinum.us/rom.rsf b/platinum.us/rom.rsf index 1490b83ea6..2542c943cd 100644 --- a/platinum.us/rom.rsf +++ b/platinum.us/rom.rsf @@ -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 diff --git a/res/pokemon/meson.build b/res/pokemon/meson.build index 325b6eabbc..acd398f728 100644 --- a/res/pokemon/meson.build +++ b/res/pokemon/meson.build @@ -725,6 +725,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@', + pokemon_subdirs + ] +) + +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@', + pokemon_subdirs + ] +) + nitrofs_files += pl_personal_narc nitrofs_files += evo_narc nitrofs_files += pl_poke_icon_narc @@ -733,3 +761,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 diff --git a/res/prebuilt/poketool/meson.build b/res/prebuilt/poketool/meson.build index 3c63e7c73c..73e10e907d 100644 --- a/res/prebuilt/poketool/meson.build +++ b/res/prebuilt/poketool/meson.build @@ -8,9 +8,7 @@ subdir('trmsg') subdir('waza') prebuilt_files = [ - 'pl_pokezukan.narc', 'pokezukan.narc', - 'shinzukan.narc' ] foreach f : prebuilt_files diff --git a/tools/scripts/make_pl_pokezukan.py b/tools/scripts/make_pl_pokezukan.py new file mode 100644 index 0000000000..a946d04d92 --- /dev/null +++ b/tools/scripts/make_pl_pokezukan.py @@ -0,0 +1,54 @@ +#!/usr/bin/env python3 +import argparse +import json +import pathlib +import subprocess + +from consts.generated.py.species import PokemonSpecies + + +argparser = argparse.ArgumentParser( + prog='make_pl_pokezukan_py', + description='Packs the archive containing NatDex->SinnohDex number mapping' +) +argparser.add_argument('-k', '--knarc', + required=True, + help='Path to knarc executable') +argparser.add_argument('-s', '--source-dir', + required=True, + help='Path to the source directory (res/pokemon)') +argparser.add_argument('-p', '--private-dir', + required=True, + help='Path to the private directory (where binaries will be made)') +argparser.add_argument('-o', '--output-dir', + required=True, + help='Path to the output directory (where the NARC will be made)') +argparser.add_argument('subdirs', + nargs='+', + help='List of subdirectories to process in-order') +args = argparser.parse_args() + +source_dir = pathlib.Path(args.source_dir) +private_dir = pathlib.Path(args.private_dir) +output_dir = pathlib.Path(args.output_dir) + +private_dir.mkdir(parents=True, exist_ok=True) + +NUM_POKEMON = 494 + +pokedex = [0 for i in range(NUM_POKEMON)] + +with open(source_dir / 'sinnoh_pokedex.json') as data_file: + dex_data = json.load(data_file) + for i, mon in enumerate(dex_data): + pokedex[PokemonSpecies[mon].value] = i + +target_fname = private_dir / f'pl_pokezukan_0.bin' +with open(target_fname, 'wb+') as target_file: + pl_pokezukan = [0 for i in range(NUM_POKEMON * 2)] + for i in range(NUM_POKEMON): + pl_pokezukan[i*2] = pokedex[i] & 0xff + pl_pokezukan[i*2 + 1] = (pokedex[i] >> 8) & 0xff + target_file.write(bytes(pl_pokezukan)) + +subprocess.run([args.knarc, '-d', private_dir, '-p', output_dir / 'pl_pokezukan.narc']) diff --git a/tools/scripts/make_shinzukan.py b/tools/scripts/make_shinzukan.py new file mode 100644 index 0000000000..bf31152314 --- /dev/null +++ b/tools/scripts/make_shinzukan.py @@ -0,0 +1,54 @@ +#!/usr/bin/env python3 +import argparse +import json +import pathlib +import subprocess + +from consts.generated.py.species import PokemonSpecies + + +argparser = argparse.ArgumentParser( + prog='make_shinzukan_py', + description='Packs the archive containing SinnohDex->NatDex number mapping' +) +argparser.add_argument('-k', '--knarc', + required=True, + help='Path to knarc executable') +argparser.add_argument('-s', '--source-dir', + required=True, + help='Path to the source directory (res/pokemon)') +argparser.add_argument('-p', '--private-dir', + required=True, + help='Path to the private directory (where binaries will be made)') +argparser.add_argument('-o', '--output-dir', + required=True, + help='Path to the output directory (where the NARC will be made)') +argparser.add_argument('subdirs', + nargs='+', + help='List of subdirectories to process in-order') +args = argparser.parse_args() + +source_dir = pathlib.Path(args.source_dir) +private_dir = pathlib.Path(args.private_dir) +output_dir = pathlib.Path(args.output_dir) + +private_dir.mkdir(parents=True, exist_ok=True) + +NUM_SINNOH = 211 + +pokedex = [0 for i in range(NUM_SINNOH)] + +with open(source_dir / 'sinnoh_pokedex.json') as data_file: + dex_data = json.load(data_file) + for i, mon in enumerate(dex_data): + pokedex[i] = PokemonSpecies[mon].value + +target_fname = private_dir / f'shinzukan_0.bin' +with open(target_fname, 'wb+') as target_file: + shinzukan = [0 for i in range(NUM_SINNOH * 2)] + for i in range(NUM_SINNOH): + shinzukan[i*2] = pokedex[i] & 0xff + shinzukan[i*2 + 1] = (pokedex[i] >> 8) & 0xff + target_file.write(bytes(shinzukan)) + +subprocess.run([args.knarc, '-d', private_dir, '-p', output_dir / 'shinzukan.narc']) diff --git a/tools/scripts/meson.build b/tools/scripts/meson.build index f9a7df73a1..44e26c4c08 100644 --- a/tools/scripts/meson.build +++ b/tools/scripts/meson.build @@ -3,3 +3,5 @@ make_pl_pokegra_py = find_program('make_pl_pokegra.py', native: true) make_pl_otherpoke_py = find_program('make_pl_otherpoke.py', native: true) make_height_py = find_program('make_height.py', native: true) make_script_bin_sh = find_program('make_script_bin.sh', native: true) +make_pl_pokezukan_py = find_program('make_pl_pokezukan.py', native: true) +make_shinzukan_py = find_program('make_shinzukan.py', native: true) From 277621e2015a237aa39676e3d6042a01c5dd8518 Mon Sep 17 00:00:00 2001 From: wildfire Date: Thu, 8 Feb 2024 13:35:59 +0000 Subject: [PATCH 3/5] Document functions for NatDex/SinnohDex mapping --- include/pokemon.h | 19 +++++++++++++++++-- src/overlay021/ov21_021D0D80.c | 2 +- src/overlay028/ov28_022561C0.c | 2 +- src/pokemon.c | 11 +++++------ src/unk_0202631C.c | 6 +++--- src/unk_0203F6C4.c | 2 +- src/unk_0207A274.c | 2 +- 7 files changed, 29 insertions(+), 15 deletions(-) diff --git a/include/pokemon.h b/include/pokemon.h index d19974bc93..14149bcc67 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -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 monNatDexNumber The National Pokedex number of a pokemon + * @return The Sinnoh Pokedex number of that pokemon (or zero if none exists) + */ +u16 Pokemon_GetSinnohDexNumber(u16 monNatDexNumber); + +/** + * @brief Gets the National Pokedex number of a pokemon from its Sinnoh Pokedex number + * (Note: Inputting 0 here will return 493 (Arceus)) + * + * @param monSinnohDexNumber The Sinnoh Pokedex number of a pokemon + * @return The National Pokedex number of that pokemon (or zero if none exists) + */ +u16 Pokemon_GetNationalDexNumber(u16 monSinnohDexNumber); + void Pokemon_Copy(Pokemon *src, Pokemon *dest); void BoxPokemon_Copy(BoxPokemon *src, BoxPokemon *dest); void BoxPokemon_FromPokemon(Pokemon *src, BoxPokemon *dest); diff --git a/src/overlay021/ov21_021D0D80.c b/src/overlay021/ov21_021D0D80.c index 16d2c46973..1fba970a43 100644 --- a/src/overlay021/ov21_021D0D80.c +++ b/src/overlay021/ov21_021D0D80.c @@ -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_GetSinnohDexNumber(param2); if ((param2 != 377) && (param2 != 378) && (param2 != 379)) { GF_ASSERT(v1 > 0); diff --git a/src/overlay028/ov28_022561C0.c b/src/overlay028/ov28_022561C0.c index c4fd5da46d..f116d4b0a9 100644 --- a/src/overlay028/ov28_022561C0.c +++ b/src/overlay028/ov28_022561C0.c @@ -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_GetNationalDexNumber((u16)v0); } if (((v2 > 0) && (v2 <= 493)) && sub_02026FE8(v1, v2)) { diff --git a/src/pokemon.c b/src/pokemon.c index b8dc758f8d..1d7b5149eb 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -3804,22 +3804,21 @@ u8 Party_GetMaxLevel(Party *party) return result; } -u16 sub_020775A4(u16 param0) +u16 Pokemon_GetSinnohDexNumber(u16 monNatDexNumber) { u16 result; - NARC_ReadFromMemberByIndexPair(&result, NARC_INDEX_POKETOOL__PL_POKEZUKAN, 0, param0 * 2, 2); + NARC_ReadFromMemberByIndexPair(&result, NARC_INDEX_POKETOOL__PL_POKEZUKAN, 0, monNatDexNumber * 2, 2); return result; } -u16 sub_020775C4(u16 param0) +u16 Pokemon_GetNationalDexNumber(u16 monSinnohDexNumber) { u16 result = 0; - // TODO enum value? - if (param0 <= 210) { - NARC_ReadFromMemberByIndexPair(&result, NARC_INDEX_POKETOOL__SHINZUKAN, 0, param0 * 2, 2); + if (monSinnohDexNumber <= 210) { + NARC_ReadFromMemberByIndexPair(&result, NARC_INDEX_POKETOOL__SHINZUKAN, 0, monSinnohDexNumber * 2, 2); } return result; diff --git a/src/unk_0202631C.c b/src/unk_0202631C.c index 31de966e0d..e69708c7b7 100644 --- a/src/unk_0202631C.c +++ b/src/unk_0202631C.c @@ -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_GetSinnohDexNumber(v0) != 0) { v1++; } } @@ -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_GetSinnohDexNumber(v0) != 0) { v1++; } } @@ -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_GetSinnohDexNumber(v0); if (v2 != 0) { if (sub_02026D68(v0) == 1) { diff --git a/src/unk_0203F6C4.c b/src/unk_0203F6C4.c index 8fcfaf8477..1f684abf17 100644 --- a/src/unk_0203F6C4.c +++ b/src/unk_0203F6C4.c @@ -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_GetSinnohDexNumber(v4) != 0)) { if (v5 == v3) { *v1 = v4; break; diff --git a/src/unk_0207A274.c b/src/unk_0207A274.c index 7b2742de1c..6eefb0ca3a 100644 --- a/src/unk_0207A274.c +++ b/src/unk_0207A274.c @@ -32,7 +32,7 @@ u32 sub_0207A280 (const UnkStruct_02026324 * param0) u32 sub_0207A294 (u32 param0, u32 param1) { if (param0 == 0) { - return sub_020775A4(param1); + return Pokemon_GetSinnohDexNumber(param1); } return param1; From b813f7fcffec77de0e9ace63ddc84df37d4f04b9 Mon Sep 17 00:00:00 2001 From: wildfire Date: Sat, 10 Feb 2024 15:07:15 +0000 Subject: [PATCH 4/5] Make narc build scripts take correct arguments --- res/pokemon/meson.build | 5 +++-- tools/scripts/make_pl_pokezukan.py | 7 +++---- tools/scripts/make_shinzukan.py | 7 +++---- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/res/pokemon/meson.build b/res/pokemon/meson.build index acd398f728..3a963fd00e 100644 --- a/res/pokemon/meson.build +++ b/res/pokemon/meson.build @@ -24,6 +24,7 @@ otherpoke_shared = files( '.shared/shadows.png', ) +sinnoh_pokedex = files('sinnoh_pokedex.json') # Process mons in national dex order pokemon_subdirs = [ @@ -735,7 +736,7 @@ pl_pokezukan_narc = custom_target('pl_pokezukan.narc', '--source-dir', '@CURRENT_SOURCE_DIR@', '--private-dir', '@PRIVATE_DIR@', '--output-dir', '@OUTDIR@', - pokemon_subdirs + sinnoh_pokedex ] ) @@ -749,7 +750,7 @@ shinzukan_narc = custom_target('shinzukan.narc', '--source-dir', '@CURRENT_SOURCE_DIR@', '--private-dir', '@PRIVATE_DIR@', '--output-dir', '@OUTDIR@', - pokemon_subdirs + sinnoh_pokedex ] ) diff --git a/tools/scripts/make_pl_pokezukan.py b/tools/scripts/make_pl_pokezukan.py index a946d04d92..c90571bbe4 100644 --- a/tools/scripts/make_pl_pokezukan.py +++ b/tools/scripts/make_pl_pokezukan.py @@ -23,9 +23,8 @@ argparser.add_argument('-o', '--output-dir', required=True, help='Path to the output directory (where the NARC will be made)') -argparser.add_argument('subdirs', - nargs='+', - help='List of subdirectories to process in-order') +argparser.add_argument('pokedex', + help='List of pokemon in the Sinnoh Pokedex') args = argparser.parse_args() source_dir = pathlib.Path(args.source_dir) @@ -38,7 +37,7 @@ pokedex = [0 for i in range(NUM_POKEMON)] -with open(source_dir / 'sinnoh_pokedex.json') as data_file: +with open(args.pokedex) as data_file: dex_data = json.load(data_file) for i, mon in enumerate(dex_data): pokedex[PokemonSpecies[mon].value] = i diff --git a/tools/scripts/make_shinzukan.py b/tools/scripts/make_shinzukan.py index bf31152314..d0f44a871d 100644 --- a/tools/scripts/make_shinzukan.py +++ b/tools/scripts/make_shinzukan.py @@ -23,9 +23,8 @@ argparser.add_argument('-o', '--output-dir', required=True, help='Path to the output directory (where the NARC will be made)') -argparser.add_argument('subdirs', - nargs='+', - help='List of subdirectories to process in-order') +argparser.add_argument('pokedex', + help='List of pokemon in the Sinnoh Pokedex') args = argparser.parse_args() source_dir = pathlib.Path(args.source_dir) @@ -38,7 +37,7 @@ pokedex = [0 for i in range(NUM_SINNOH)] -with open(source_dir / 'sinnoh_pokedex.json') as data_file: +with open(args.pokedex) as data_file: dex_data = json.load(data_file) for i, mon in enumerate(dex_data): pokedex[i] = PokemonSpecies[mon].value From ddee29c51e4f4acdaf263c70b333edaa4023f517 Mon Sep 17 00:00:00 2001 From: wildfire Date: Sun, 11 Feb 2024 15:42:01 +0000 Subject: [PATCH 5/5] Rename functions to to better fit codebase style --- include/pokemon.h | 8 ++++---- src/overlay021/ov21_021D0D80.c | 2 +- src/overlay028/ov28_022561C0.c | 2 +- src/pokemon.c | 10 +++++----- src/unk_0202631C.c | 6 +++--- src/unk_0203F6C4.c | 2 +- src/unk_0207A274.c | 2 +- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/include/pokemon.h b/include/pokemon.h index 14149bcc67..3a26652529 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -787,19 +787,19 @@ u8 Party_GetMaxLevel(Party *party); /** * @brief Gets the Sinnoh Pokedex number of a pokemon from its National Pokedex number * - * @param monNatDexNumber The National Pokedex number of a pokemon + * @param species The National Pokedex number of a pokemon * @return The Sinnoh Pokedex number of that pokemon (or zero if none exists) */ -u16 Pokemon_GetSinnohDexNumber(u16 monNatDexNumber); +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 monSinnohDexNumber The Sinnoh Pokedex number of a pokemon + * @param sinnohDexNumber The Sinnoh Pokedex number of a pokemon * @return The National Pokedex number of that pokemon (or zero if none exists) */ -u16 Pokemon_GetNationalDexNumber(u16 monSinnohDexNumber); +u16 Pokemon_NationalDexNumber(u16 sinnohDexNumber); void Pokemon_Copy(Pokemon *src, Pokemon *dest); void BoxPokemon_Copy(BoxPokemon *src, BoxPokemon *dest); diff --git a/src/overlay021/ov21_021D0D80.c b/src/overlay021/ov21_021D0D80.c index 1fba970a43..7dd235468b 100644 --- a/src/overlay021/ov21_021D0D80.c +++ b/src/overlay021/ov21_021D0D80.c @@ -707,7 +707,7 @@ Window * ov21_021D172C (UnkStruct_ov21_021D4C0C * param0, int param1, int param2 Window * v0; int v1; - v1 = Pokemon_GetSinnohDexNumber(param2); + v1 = Pokemon_SinnohDexNumber(param2); if ((param2 != 377) && (param2 != 378) && (param2 != 379)) { GF_ASSERT(v1 > 0); diff --git a/src/overlay028/ov28_022561C0.c b/src/overlay028/ov28_022561C0.c index f116d4b0a9..b697cb4b87 100644 --- a/src/overlay028/ov28_022561C0.c +++ b/src/overlay028/ov28_022561C0.c @@ -640,7 +640,7 @@ static void ov28_02256914 (UnkStruct_ov28_02256210 * param0, const UnkStruct_ov2 if (sub_02027474(v1)) { v2 = v0; } else { - v2 = Pokemon_GetNationalDexNumber((u16)v0); + v2 = Pokemon_NationalDexNumber((u16)v0); } if (((v2 > 0) && (v2 <= 493)) && sub_02026FE8(v1, v2)) { diff --git a/src/pokemon.c b/src/pokemon.c index 1d7b5149eb..06a2e7a10a 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -3804,21 +3804,21 @@ u8 Party_GetMaxLevel(Party *party) return result; } -u16 Pokemon_GetSinnohDexNumber(u16 monNatDexNumber) +u16 Pokemon_SinnohDexNumber(u16 species) { u16 result; - NARC_ReadFromMemberByIndexPair(&result, NARC_INDEX_POKETOOL__PL_POKEZUKAN, 0, monNatDexNumber * 2, 2); + NARC_ReadFromMemberByIndexPair(&result, NARC_INDEX_POKETOOL__PL_POKEZUKAN, 0, species * 2, 2); return result; } -u16 Pokemon_GetNationalDexNumber(u16 monSinnohDexNumber) +u16 Pokemon_NationalDexNumber(u16 sinnohDexNumber) { u16 result = 0; - if (monSinnohDexNumber <= 210) { - NARC_ReadFromMemberByIndexPair(&result, NARC_INDEX_POKETOOL__SHINZUKAN, 0, monSinnohDexNumber * 2, 2); + if (sinnohDexNumber <= 210) { + NARC_ReadFromMemberByIndexPair(&result, NARC_INDEX_POKETOOL__SHINZUKAN, 0, sinnohDexNumber * 2, 2); } return result; diff --git a/src/unk_0202631C.c b/src/unk_0202631C.c index e69708c7b7..6a4b1c1169 100644 --- a/src/unk_0202631C.c +++ b/src/unk_0202631C.c @@ -816,7 +816,7 @@ u16 sub_02026E64 (const UnkStruct_02026324 * param0) for (v0 = 1; v0 <= 493; v0++) { if (Pokedex_CaughtSpecies(param0, v0) == 1) { - if (Pokemon_GetSinnohDexNumber(v0) != 0) { + if (Pokemon_SinnohDexNumber(v0) != 0) { v1++; } } @@ -835,7 +835,7 @@ u16 sub_02026EAC (const UnkStruct_02026324 * param0) for (v0 = 1; v0 <= 493; v0++) { if (sub_02026FE8(param0, v0) == 1) { - if (Pokemon_GetSinnohDexNumber(v0) != 0) { + if (Pokemon_SinnohDexNumber(v0) != 0) { v1++; } } @@ -898,7 +898,7 @@ u16 sub_02026F58 (const UnkStruct_02026324 * param0) for (v0 = 1; v0 <= 493; v0++) { if (sub_02026FE8(param0, v0) == 1) { - v2 = Pokemon_GetSinnohDexNumber(v0); + v2 = Pokemon_SinnohDexNumber(v0); if (v2 != 0) { if (sub_02026D68(v0) == 1) { diff --git a/src/unk_0203F6C4.c b/src/unk_0203F6C4.c index 1f684abf17..2f6d1079b4 100644 --- a/src/unk_0203F6C4.c +++ b/src/unk_0203F6C4.c @@ -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) && (Pokemon_GetSinnohDexNumber(v4) != 0)) { + if ((sub_02026FE8(v0, v4) == 1) && (Pokemon_SinnohDexNumber(v4) != 0)) { if (v5 == v3) { *v1 = v4; break; diff --git a/src/unk_0207A274.c b/src/unk_0207A274.c index 6eefb0ca3a..60809f603c 100644 --- a/src/unk_0207A274.c +++ b/src/unk_0207A274.c @@ -32,7 +32,7 @@ u32 sub_0207A280 (const UnkStruct_02026324 * param0) u32 sub_0207A294 (u32 param0, u32 param1) { if (param0 == 0) { - return Pokemon_GetSinnohDexNumber(param1); + return Pokemon_SinnohDexNumber(param1); } return param1;