mirror of
https://github.com/pmret/papermario.git
synced 2024-11-08 20:12:30 +01:00
78a729a7a3
* remove BattleID and NpcAnimId typedefs * change NPC_ANIM generation * struct for StaticNpc.animations * ~peach_make_disguise_npc
42 lines
1.3 KiB
Python
Executable File
42 lines
1.3 KiB
Python
Executable File
#! /usr/bin/python3
|
|
|
|
from sys import argv, path
|
|
from pathlib import Path
|
|
path.append(str(Path(__file__).parent.parent.parent / "splat"))
|
|
path.append(str(Path(__file__).parent.parent.parent / "splat_ext"))
|
|
from pm_npc_sprites import Sprite
|
|
|
|
if __name__ == "__main__":
|
|
if len(argv) < 4:
|
|
print("usage: gen_sprite_animations_h.py [OUT] [DIR] [ID]")
|
|
exit(1)
|
|
|
|
_, outfile, sprite_dir, s = argv
|
|
|
|
with open(outfile, "w") as f:
|
|
# get sprite index
|
|
s = int(s)
|
|
assert s >= 1
|
|
|
|
sprite_dir = Path(sprite_dir)
|
|
|
|
sprite = Sprite.from_dir(sprite_dir, read_images=False)
|
|
sprite_name = sprite_dir.stem
|
|
|
|
f.write(f"#ifndef _NPC_SPRITE_{sprite_name.upper()}_H_\n")
|
|
f.write(f"#define _NPC_SPRITE_{sprite_name.upper()}_H_\n")
|
|
f.write("\n")
|
|
f.write('#include "types.h"\n')
|
|
f.write("\n")
|
|
|
|
seen_palette_names = set()
|
|
for p, palette_name in enumerate(sprite.palette_names):
|
|
if palette_name not in seen_palette_names:
|
|
seen_palette_names.add(palette_name)
|
|
|
|
for a, name in enumerate(sprite.animation_names):
|
|
f.write(f"#define NPC_ANIM_{sprite_name}_{palette_name}_{name} 0x{s:02X}{p:02X}{a:02X}\n")
|
|
|
|
f.write("\n")
|
|
f.write("#endif\n")
|