mirror of
https://github.com/pret/pokeplatinum.git
synced 2026-08-20 16:35:19 -05:00
Build pl_pokezukan.narc and shinzukan.narc from json
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -8,9 +8,7 @@ subdir('trmsg')
|
||||
subdir('waza')
|
||||
|
||||
prebuilt_files = [
|
||||
'pl_pokezukan.narc',
|
||||
'pokezukan.narc',
|
||||
'shinzukan.narc'
|
||||
]
|
||||
|
||||
foreach f : prebuilt_files
|
||||
|
||||
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