diff --git a/platinum.us/rom.rsf b/platinum.us/rom.rsf index f6e1ee17cd..7b44fb7907 100644 --- a/platinum.us/rom.rsf +++ b/platinum.us/rom.rsf @@ -212,7 +212,13 @@ RomSpec File poketool/personal/growtbl.narc File poketool/personal/pl_growtbl.narc File poketool/personal/pms.narc - File poketool/personal/wotbl.narc + + Root /poketool/personal + HostRoot res/pokemon + File wotbl.narc + + Root / + HostRoot res/prebuilt File poketool/trainer/trdata.narc File poketool/trainer/trpoke.narc File poketool/trmsg/trtbl.narc diff --git a/res/pokemon/meson.build b/res/pokemon/meson.build index 9143b721c6..2c6f0f8b7e 100644 --- a/res/pokemon/meson.build +++ b/res/pokemon/meson.build @@ -604,6 +604,18 @@ endforeach # Generate NARCs +wotbl_narc = custom_target('wotbl.narc', + output: 'wotbl.narc', + input: personal_files, + command: [ + pokemon_wotbl_data_py, + '--knarc', knarc_exe, + '--source-dir', '@CURRENT_SOURCE_DIR@', + '--private-dir', '@PRIVATE_DIR@', + '--output-dir', '@OUTDIR@', + ] +) + pl_personal_narc = custom_target('pl_personal.narc', output: 'pl_personal.narc', input: personal_files, @@ -670,3 +682,4 @@ nitrofs_files += pl_personal_narc nitrofs_files += pl_poke_icon_narc nitrofs_files += pl_pokegra_narc nitrofs_files += pl_otherpoke_narc +nitrofs_files += wotbl_narc diff --git a/res/prebuilt/poketool/personal/meson.build b/res/prebuilt/poketool/personal/meson.build index 8ebe517459..d2242703f0 100644 --- a/res/prebuilt/poketool/personal/meson.build +++ b/res/prebuilt/poketool/personal/meson.build @@ -4,7 +4,6 @@ prebuilt_files = [ 'personal.narc', 'pl_growtbl.narc', 'pms.narc', - 'wotbl.narc' ] foreach f : prebuilt_files diff --git a/res/prebuilt/poketool/personal/wotbl.narc b/res/prebuilt/poketool/personal/wotbl.narc deleted file mode 100644 index 29885c89ca..0000000000 Binary files a/res/prebuilt/poketool/personal/wotbl.narc and /dev/null differ diff --git a/tools/json2bin/meson.build b/tools/json2bin/meson.build index e6a19bc11b..b1e4bcde30 100644 --- a/tools/json2bin/meson.build +++ b/tools/json2bin/meson.build @@ -1,3 +1,4 @@ encounters_py = find_program('encounters.py', native: true) movedata_py = find_program('movedata.py', native: true) pokemon_personal_data_py = find_program('pokemon_personal_data.py', native: true) +pokemon_wotbl_data_py = find_program('pokemon_wotbl_data.py', native: true) diff --git a/tools/json2bin/pokemon_personal_data.py b/tools/json2bin/pokemon_personal_data.py index 4cd631ce7d..3d6a2da153 100644 --- a/tools/json2bin/pokemon_personal_data.py +++ b/tools/json2bin/pokemon_personal_data.py @@ -89,8 +89,8 @@ FORM_INDICES = { def indexer(file_path: pathlib.Path) -> int: name = file_path.parent.stem.upper() if name == '000': return 0 - if name == '494': return 494 - if name == '495': return 495 + if name == 'egg': return 494 + if name == 'bad_egg': return 495 if file_path.parent.parent.stem == 'forms': species_idx = file_path.parent.parent.parent.stem.upper() form = file_path.parent.stem.upper() diff --git a/tools/json2bin/pokemon_wotbl_data.py b/tools/json2bin/pokemon_wotbl_data.py new file mode 100644 index 0000000000..02e408e8a1 --- /dev/null +++ b/tools/json2bin/pokemon_wotbl_data.py @@ -0,0 +1,88 @@ +#!/usr/bin/env python3 +import pathlib + +import json2bin as j2b + +from consts import ( + moves +) + +from consts.pokemon import ( + species +) + +def table_line(move_id: int, level: int) -> bytes: + return ((move_id & 0x01FF) | ((level & 0x7F) << 9)).to_bytes(2, 'little', signed=False) + +def pad_bytes(data: bytes) -> bytes: + '''Aligns data to 4-byte boundary.''' + alignment = len(data) % 4 + padding = (4 - alignment) if alignment != 0 else 0 + return data + [0x00] * padding + +def parse_level_up_moves(table: dict, _size: int, _enum: None): + out = [] + for key, value in table.items(): + level = int(key) + level_moves = value + if type(level_moves) == str: + out += table_line(moves.Move[level_moves].value, level) + elif type(level_moves) == list: + for move in level_moves: + out += table_line(moves.Move[move].value, level) + else: + print('ERROR') + out += [0xFF, 0xFF] # Sentinel value for end of list + return pad_bytes(out) + + +SCHEMA = j2b.Parser() \ + .register_name(lambda s: s) \ + .register('learnset.level_up', 0, parse_level_up_moves) # Level-up learnsets are not fixed size + + +FORM_INDICES = { + 'DEOXYS' : { + 'ATTACK': 496, + 'DEFENSE': 497, + 'SPEED': 498, + }, + 'WORMADAM': { + 'SANDY': 499, + 'TRASH': 500, + }, + 'GIRATINA': { + 'ORIGIN': 501, + }, + 'SHAYMIN': { + 'SKY': 502, + }, + 'ROTOM': { + 'HEAT': 503, + 'WASH': 504, + 'FROST': 505, + 'FAN': 506, + 'MOW': 507, + }, +} +def indexer(file_path: pathlib.Path) -> int: + name = file_path.parent.stem.upper() + if name == '000': return 0 + if name == 'egg': return 494 + if name == 'bad_egg': return 495 + if file_path.parent.parent.stem == 'forms': + species_idx = file_path.parent.parent.parent.stem.upper() + form = file_path.parent.stem.upper() + return FORM_INDICES[species_idx][form] + return species.PokemonSpecies[f'SPECIES_{name}'].value + + +args = j2b.ARGPARSER.parse_args() +j2b.json2bin(args.source_dir, + SCHEMA, + args.private_dir, + args.output_dir, + indexer, + glob_pattern='**/data.json', + narc_name='wotbl', + narc_packer=args.knarc)