tools: Generate move animation script ordering via moveproc

This commit is contained in:
Rachel
2026-05-21 13:15:06 -07:00
parent 84ee56c183
commit b896e9587f
44 changed files with 70 additions and 478 deletions

View File

@@ -1,23 +0,0 @@
{
"name": "",
"class": "CLASS_SPECIAL",
"type": "TYPE_NORMAL",
"power": 100,
"accuracy": 100,
"pp": 10,
"effect": {
"type": "BATTLE_EFFECT_HIT",
"chance": 0
},
"range": "RANGE_SINGLE_TARGET",
"priority": 0,
"flags": [
"MOVE_FLAG_CAN_PROTECT",
"MOVE_FLAG_CAN_MIRROR_MOVE",
"MOVE_FLAG_TRIGGERS_KINGS_ROCK"
],
"contest": {
"effect": "CONTEST_EFFECT_LOW_VOLTAGE_ADVANTAGE",
"type": "CONTEST_TYPE_BEAUTY"
}
}

View File

@@ -1,10 +0,0 @@
#include "macros/btlanimcmd.inc"
L_0:
Func_Nop
Func_AnimExample
Func_SoundExample
Func_GenericExample
PlaySoundEffectR SEQ_SE_DP_030
Delay 60
End

View File

@@ -1,23 +0,0 @@
{
"name": "",
"class": "CLASS_SPECIAL",
"type": "TYPE_NORMAL",
"power": 100,
"accuracy": 100,
"pp": 10,
"effect": {
"type": "BATTLE_EFFECT_HIT",
"chance": 0
},
"range": "RANGE_SINGLE_TARGET",
"priority": 0,
"flags": [
"MOVE_FLAG_CAN_PROTECT",
"MOVE_FLAG_CAN_MIRROR_MOVE",
"MOVE_FLAG_TRIGGERS_KINGS_ROCK"
],
"contest": {
"effect": "CONTEST_EFFECT_FIRST_PERFORMANCE_ADVANTAGE",
"type": "CONTEST_TYPE_CUTE"
}
}

View File

@@ -1,10 +0,0 @@
#include "macros/btlanimcmd.inc"
L_0:
Func_Nop
Func_AnimExample
Func_SoundExample
Func_GenericExample
PlaySoundEffectR SEQ_SE_DP_030
Delay 60
End

View File

@@ -1,23 +0,0 @@
{
"name": "",
"class": "CLASS_SPECIAL",
"type": "TYPE_NORMAL",
"power": 100,
"accuracy": 100,
"pp": 10,
"effect": {
"type": "BATTLE_EFFECT_HIT",
"chance": 0
},
"range": "RANGE_SINGLE_TARGET",
"priority": 0,
"flags": [
"MOVE_FLAG_CAN_PROTECT",
"MOVE_FLAG_CAN_MIRROR_MOVE",
"MOVE_FLAG_TRIGGERS_KINGS_ROCK"
],
"contest": {
"effect": "CONTEST_EFFECT_FINAL_PERFORMANCE_ADVANTAGE",
"type": "CONTEST_TYPE_SMART"
}
}

View File

@@ -1,10 +0,0 @@
#include "macros/btlanimcmd.inc"
L_0:
Func_Nop
Func_AnimExample
Func_SoundExample
Func_GenericExample
PlaySoundEffectR SEQ_SE_DP_030
Delay 60
End

View File

@@ -1,10 +0,0 @@
#include "macros/btlanimcmd.inc"
L_0:
Func_Nop
Func_AnimExample
Func_SoundExample
Func_GenericExample
PlaySoundEffectR SEQ_SE_DP_030
Delay 60
End

View File

@@ -1,10 +0,0 @@
#include "macros/btlanimcmd.inc"
L_0:
Func_Nop
Func_AnimExample
Func_SoundExample
Func_GenericExample
PlaySoundEffectR SEQ_SE_DP_030
Delay 60
End

View File

@@ -1,10 +0,0 @@
#include "macros/btlanimcmd.inc"
L_0:
Func_Nop
Func_AnimExample
Func_SoundExample
Func_GenericExample
PlaySoundEffectR SEQ_SE_DP_030
Delay 60
End

View File

@@ -1,10 +0,0 @@
#include "macros/btlanimcmd.inc"
L_0:
Func_Nop
Func_AnimExample
Func_SoundExample
Func_GenericExample
PlaySoundEffect SEQ_SE_DP_BASI
Delay 60
End

View File

@@ -1,10 +0,0 @@
#include "macros/btlanimcmd.inc"
L_0:
Func_Nop
Func_AnimExample
Func_SoundExample
Func_GenericExample
PlaySoundEffect SEQ_SE_DP_BASI
Delay 60
End

View File

@@ -1,10 +0,0 @@
#include "macros/btlanimcmd.inc"
L_0:
Func_Nop
Func_AnimExample
Func_SoundExample
Func_GenericExample
PlaySoundEffect SEQ_SE_DP_BASI
Delay 60
End

View File

@@ -1,10 +0,0 @@
#include "macros/btlanimcmd.inc"
L_0:
Func_Nop
Func_AnimExample
Func_SoundExample
Func_GenericExample
PlaySoundEffect SEQ_SE_DP_BASI
Delay 60
End

View File

@@ -1,10 +0,0 @@
#include "macros/btlanimcmd.inc"
L_0:
Func_Nop
Func_AnimExample
Func_SoundExample
Func_GenericExample
PlaySoundEffect SEQ_SE_DP_BASI
Delay 60
End

View File

@@ -1,10 +0,0 @@
#include "macros/btlanimcmd.inc"
L_0:
Func_Nop
Func_AnimExample
Func_SoundExample
Func_GenericExample
PlaySoundEffect SEQ_SE_DP_BASI
Delay 60
End

View File

@@ -1,10 +0,0 @@
#include "macros/btlanimcmd.inc"
L_0:
Func_Nop
Func_AnimExample
Func_SoundExample
Func_GenericExample
PlaySoundEffect SEQ_SE_DP_BASI
Delay 60
End

View File

@@ -1,10 +0,0 @@
#include "macros/btlanimcmd.inc"
L_0:
Func_Nop
Func_AnimExample
Func_SoundExample
Func_GenericExample
PlaySoundEffect SEQ_SE_DP_BASI
Delay 60
End

View File

@@ -1,10 +0,0 @@
#include "macros/btlanimcmd.inc"
L_0:
Func_Nop
Func_AnimExample
Func_SoundExample
Func_GenericExample
PlaySoundEffect SEQ_SE_DP_BASI
Delay 60
End

View File

@@ -1,10 +0,0 @@
#include "macros/btlanimcmd.inc"
L_0:
Func_Nop
Func_AnimExample
Func_SoundExample
Func_GenericExample
PlaySoundEffect SEQ_SE_DP_BASI
Delay 60
End

View File

@@ -1,10 +0,0 @@
#include "macros/btlanimcmd.inc"
L_0:
Func_Nop
Func_AnimExample
Func_SoundExample
Func_GenericExample
PlaySoundEffect SEQ_SE_DP_BASI
Delay 60
End

View File

@@ -1,10 +0,0 @@
#include "macros/btlanimcmd.inc"
L_0:
Func_Nop
Func_AnimExample
Func_SoundExample
Func_GenericExample
PlaySoundEffect SEQ_SE_DP_BASI
Delay 60
End

View File

@@ -1,10 +0,0 @@
#include "macros/btlanimcmd.inc"
L_0:
Func_Nop
Func_AnimExample
Func_SoundExample
Func_GenericExample
PlaySoundEffect SEQ_SE_DP_BASI
Delay 60
End

View File

@@ -1,10 +0,0 @@
#include "macros/btlanimcmd.inc"
L_0:
Func_Nop
Func_AnimExample
Func_SoundExample
Func_GenericExample
PlaySoundEffect SEQ_SE_DP_BASI
Delay 60
End

View File

@@ -1,10 +0,0 @@
#include "macros/btlanimcmd.inc"
L_0:
Func_Nop
Func_AnimExample
Func_SoundExample
Func_GenericExample
PlaySoundEffect SEQ_SE_DP_BASI
Delay 60
End

View File

@@ -1,10 +0,0 @@
#include "macros/btlanimcmd.inc"
L_0:
Func_Nop
Func_AnimExample
Func_SoundExample
Func_GenericExample
PlaySoundEffect SEQ_SE_DP_BASI
Delay 60
End

View File

@@ -1,10 +0,0 @@
#include "macros/btlanimcmd.inc"
L_0:
Func_Nop
Func_AnimExample
Func_SoundExample
Func_GenericExample
PlaySoundEffect SEQ_SE_DP_BASI
Delay 60
End

View File

@@ -1,10 +0,0 @@
#include "macros/btlanimcmd.inc"
L_0:
Func_Nop
Func_AnimExample
Func_SoundExample
Func_GenericExample
PlaySoundEffect SEQ_SE_DP_BASI
Delay 60
End

View File

@@ -1,10 +0,0 @@
#include "macros/btlanimcmd.inc"
L_0:
Func_Nop
Func_AnimExample
Func_SoundExample
Func_GenericExample
PlaySoundEffect SEQ_SE_DP_BASI
Delay 60
End

View File

@@ -1,10 +0,0 @@
#include "macros/btlanimcmd.inc"
L_0:
Func_Nop
Func_AnimExample
Func_SoundExample
Func_GenericExample
PlaySoundEffect SEQ_SE_DP_BASI
Delay 60
End

View File

@@ -1,10 +0,0 @@
#include "macros/btlanimcmd.inc"
L_0:
Func_Nop
Func_AnimExample
Func_SoundExample
Func_GenericExample
PlaySoundEffect SEQ_SE_DP_BASI
Delay 60
End

View File

@@ -1,10 +0,0 @@
#include "macros/btlanimcmd.inc"
L_0:
Func_Nop
Func_AnimExample
Func_SoundExample
Func_GenericExample
PlaySoundEffect SEQ_SE_DP_BASI
Delay 60
End

View File

@@ -1,10 +0,0 @@
#include "macros/btlanimcmd.inc"
L_0:
Func_Nop
Func_AnimExample
Func_SoundExample
Func_GenericExample
PlaySoundEffect SEQ_SE_DP_BASI
Delay 60
End

View File

@@ -1,10 +0,0 @@
#include "macros/btlanimcmd.inc"
L_0:
Func_Nop
Func_AnimExample
Func_SoundExample
Func_GenericExample
PlaySoundEffect SEQ_SE_DP_BASI
Delay 60
End

View File

@@ -1,10 +0,0 @@
#include "macros/btlanimcmd.inc"
L_0:
Func_Nop
Func_AnimExample
Func_SoundExample
Func_GenericExample
PlaySoundEffect SEQ_SE_DP_BASI
Delay 60
End

View File

@@ -1,48 +1,3 @@
anim_script_subdirs = [
'none',
'0468',
'0469',
'0470',
'0471',
'0472',
'0473',
'0474',
'0475',
'0476',
'0477',
'0478',
'0479',
'0480',
'0481',
'0482',
'0483',
'0484',
'0485',
'0486',
'0487',
'0488',
'0489',
'0490',
'0491',
'0492',
'0493',
'0494',
'0495',
'0496',
'0497',
'0498',
'0499',
'0500', ]
move_consts = fs.read(moves_txt).splitlines()
foreach move : move_consts
if move.startswith('MOVE_') and move != 'MOVE_NONE'
move_name = move.replace('MOVE_', '').to_lower()
# pl_waza_tbl_subdirs += move_name
anim_script_subdirs += move_name
endif
endforeach
move_text_bank_names = [
'move_names.json',
'move_names_uppercase.json',
@@ -53,6 +8,7 @@ move_text_bank_names = [
move_data = custom_target('move_data',
output: [
'move_data.narc',
'anim_scripts.order',
move_text_bank_names,
],
@@ -67,12 +23,21 @@ move_data = custom_target('move_data',
depfile: 'move_data.d',
)
move_anim_scripts_order = move_data[1]
move_data_outputs = move_data.to_list()
move_text_banks = move_data_outputs.slice(1, move_data_outputs.length())
move_text_banks = move_data_outputs.slice(2, move_data_outputs.length())
anim_script_srcs = []
foreach subdir : anim_script_subdirs
anim_script_srcs += subdir / 'anim.s'
anim_script_srcs = [
'.shared/anim_0468_0474.s',
'.shared/anim_0475_0500.s',
]
move_consts = fs.read(moves_txt).splitlines()
foreach move : move_consts
if move.startswith('MOVE_')
move_stem = move.replace('MOVE_', '').to_lower()
anim_script_srcs += move_stem / 'anim.s'
endif
endforeach
# This generator is shared by both move-specific animations (in this directory)
@@ -105,12 +70,6 @@ battle_anim_script_bin_gen = generator(make_script_bin_sh,
relative_build_dir = fs.relative_to(meson.current_build_dir(), meson.project_build_root())
anim_scripts_order = custom_target('anim_scripts.order',
output: 'anim_scripts.order',
input: [ moves_txt ],
command: [ ordergen_battle_anim_scripts_py, '@INPUT@', meson.current_source_dir(), '@OUTPUT@' ],
)
anim_scripts_narc = custom_target('anim_scripts.narc',
output: 'anim_scripts.narc',
input: battle_anim_script_bin_gen.process(
@@ -124,7 +83,7 @@ anim_scripts_narc = custom_target('anim_scripts.narc',
command: [
nitroarc_exe,
'--create',
'--files-from', anim_scripts_order,
'--files-from', move_anim_scripts_order,
'--file', '@OUTPUT0@',
'@PRIVATE_DIR@',
],

View File

@@ -92,6 +92,7 @@ enum diaglevel dp_report(datafile_t *df);
void dp_error(datanode_t *dn, const char *fmt, ...) __attribute__((format(printf, 2, 3)));
void dp_warn(datanode_t *dn, const char *fmt, ...) __attribute__((format(printf, 2, 3)));
void dp_note(datanode_t *dn, const char *fmt, ...) __attribute__((format(printf, 2, 3)));
void dp_gerror(datafile_t *df, size_t beg, size_t end, const char *errfmt, ...) __attribute__((format(printf, 4, 5)));
datanode_t dp_try(datafile_t *df, const char *path);
datanode_t dp_get(datafile_t *df, const char *path);

View File

@@ -20,7 +20,4 @@ struct diagnostic {
diagnostic_t *next;
};
__attribute__((format(printf, 4, 5)))
void dp_gerror(datafile_t *df, size_t beg, size_t end, const char *errfmt, ...);
#endif // DATAPROC_PRIVATE_H

View File

@@ -3,12 +3,14 @@
#include <assert.h>
#include <errno.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/stat.h>
#include "dataproc.h"
#include "libenum.h"
@@ -676,3 +678,9 @@ void bank_pushlines(datanode_t *root, const char *id, ...) {
va_end(content);
}
bool order_subfile(const char *basename, const char *subfile, FILE *f_order) {
fprintf(f_order, "%s/%s\n", basename, subfile);
return true;
}

View File

@@ -199,4 +199,6 @@ void bank_pushlines(datanode_t *root, const char *id, ...);
#define bank_pushm(bank, id, ...) bank_pushlines(&textbanks[bank].root, id, __VA_ARGS__, NULL)
bool order_subfile(const char *basename, const char *subfile, FILE *f_order);
#endif // DATAPROC_COMMON_H

View File

@@ -1,10 +1,12 @@
#include <assert.h>
#include <getopt.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include "common.h"
#include "dataproc.h"
@@ -55,7 +57,11 @@ static textbank_template_t textbanks[] = {
static void parse_args(int *pargc, char ***pargv);
static void proc_move(datafile_t *df);
static void proc_text(datafile_t *df, size_t i, const char *basename);
static void prep_scripts(const char *basename);
static void pack_extra_moves(void);
static void prep_extra_scripts(void);
static void init_orderfiles(void);
static int close_orderfiles(void);
static char *filename = NULL;
static char *base_dir = NULL;
@@ -77,6 +83,7 @@ int main(int argc, char **argv) {
.archives = archives,
.textbanks = textbanks,
.extra_files = 3,
.hook_before = init_orderfiles,
);
for (size_t i = 0; i < moves.size; i++) {
@@ -89,6 +96,7 @@ int main(int argc, char **argv) {
if (dp_load(&df, filepath) == 0) {
proc_move(&df);
proc_text(&df, i, basename);
prep_scripts(basename);
}
if (dp_report(&df) == DIAG_ERROR) errc = EXIT_FAILURE;
@@ -99,7 +107,8 @@ int main(int argc, char **argv) {
}
pack_extra_moves();
return common_done(errc, NULL);
prep_extra_scripts();
return common_done(errc, close_orderfiles);
}
static void proc_move(datafile_t *df) {
@@ -180,7 +189,28 @@ static void proc_text(datafile_t *df, size_t i, const char *basename) {
#undef strfmt2
}
static FILE *f_anim_scripts = NULL;
static void init_orderfiles(void) {
char *filepath = pathjoin(output_dir, NULL, "anim_scripts.order");
f_anim_scripts = fopen(filepath, "wb");
free(filepath);
}
static void prep_scripts(const char *basename) {
order_subfile(basename, "anim", f_anim_scripts);
}
static int close_orderfiles(void) {
fclose(f_anim_scripts);
return EXIT_SUCCESS;
}
static void pack_extra_moves(void) {
// MATCH DETAIL: The retail game contains these 3 additional entries at the tail of the move data
// archive. They are inaccessible, but must be present to produce a binary match.
MoveTable m468 = {
.class = CLASS_SPECIAL,
.type = TYPE_NORMAL,
@@ -231,6 +261,19 @@ static void pack_extra_moves(void) {
nitroarc_ppack(&archives[0].packer, &m470, sizeof(m470), NULL);
}
static void prep_extra_scripts(void) {
// MATCH DETAIL: The retail game contains additional entries in the animation scripts archive that
// must be present to produce a binary match.
for (size_t i = 468; i <= 474; i++) {
order_subfile(".shared", "anim_0468_0474", f_anim_scripts);
}
for (size_t i = 475; i <= 500; i++) {
order_subfile(".shared", "anim_0475_0500", f_anim_scripts);
}
}
static char *program_name = NULL;
static void usage(const char *fmt, ...) {

View File

@@ -1,38 +0,0 @@
#!/usr/bin/env python3
import sys
from pathlib import Path
def usage():
print("Usage: battle_anim_scripts.py <MOVES_FILE> <MOVES_DIR> <OUTFILE>")
print()
print("Process an input file containing a list of moves into an")
print("output file to order the contents of anim_scripts.narc.")
if len(sys.argv) < 4:
usage()
sys.exit(1)
with (
open(sys.argv[1], "r", encoding="utf-8") as infile,
open(sys.argv[3], "w", encoding="utf-8") as outfile,
):
added = set()
def add(move_name):
print(f"{move_name}/anim", file=outfile)
added.add(move_name)
for move in infile:
move = move.strip()
if not move or not move.startswith("MOVE_"):
continue
move_name = move.replace("MOVE_", "").lower()
add(move_name)
for path in sorted(Path(sys.argv[2]).iterdir()):
if not path.is_dir() or not (path / 'anim.s').exists():
continue
move_name = path.name
if move_name in added:
continue
add(move_name)

View File

@@ -1,4 +1,3 @@
ordergen_battle_anim_scripts_py = find_program('battle_anim_scripts.py', native: true)
ordergen_forms_py = find_program('forms.py', native: true)
ordergen_species_py = find_program('species.py', native: true)
ordergen_text_banks_py = find_program('text_banks.py', native: true)