mirror of
https://github.com/pret/pokeplatinum.git
synced 2026-09-29 04:48:30 -05:00
Build pl_pokezukan.narc and shinzukan.narc from json
This commit is contained in:
54
tools/scripts/make_pl_pokezukan.py
Normal file
54
tools/scripts/make_pl_pokezukan.py
Normal file
@@ -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'])
|
||||
54
tools/scripts/make_shinzukan.py
Normal file
54
tools/scripts/make_shinzukan.py
Normal file
@@ -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'])
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user