mirror of
https://github.com/pmret/papermario.git
synced 2024-11-18 08:52:40 +01:00
8837fbdf65
* WIP work on sprites (sprite_stuff.py) * cleanup of various stuff * separate compiler installation into separate script * wipz * more * renames, bugfixes * more * very grood * cleanin * goods and services * oopth * oopth2 * Parse palette data from xml * more work * more wipperz * more * it working * git subrepo pull --force tools/splat subrepo: subdir: "tools/splat" merged: "e72a868f9f" upstream: origin: "https://github.com/ethteck/splat.git" branch: "master" commit: "e72a868f9f" git-subrepo: version: "0.4.5" origin: "https://github.com/ingydotnet/git-subrepo" commit: "aa416e4" * fix symbol_addrs for new splat * upd8s * Use generated header, other versions, fixes * fixes & formatting * wip fusing npc + player extraction & cleanup * remove npc_files * buildin * fix some bugs * Cleanup, yay0s separately * cleen * cleanup * Respect stack during build * jp spritz * dun * fix c files --------- Co-authored-by: pixel-stuck <mathmcclintic@gmail.com>
35 lines
953 B
Python
Executable File
35 lines
953 B
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
from sys import argv
|
|
import re
|
|
import png # type: ignore
|
|
|
|
if __name__ == "__main__":
|
|
infile, outfile = argv[1:3]
|
|
|
|
if len(argv) > 3 and argv[3]:
|
|
cname = argv[3]
|
|
else:
|
|
cname = re.sub(r"[^0-9a-zA-Z_]", "_", infile)
|
|
|
|
if cname.startswith("ver_"):
|
|
cname = "_".join(cname.split("_")[2:])
|
|
|
|
if cname.startswith("src_"):
|
|
cname = cname[4:]
|
|
elif cname.startswith("assets_"):
|
|
cname = "_".join(cname.split("_")[2:])
|
|
|
|
img = png.Reader(infile)
|
|
width, height, rows, info = img.read()
|
|
|
|
with open(outfile, "w") as f:
|
|
f.write("// Generated file, do not edit.\n")
|
|
f.write(f"#ifndef _{cname.upper()}_\n")
|
|
f.write(f"#define _{cname.upper()}_\n")
|
|
f.write(f"\n")
|
|
f.write(f"#define {cname}_width {width}\n")
|
|
f.write(f"#define {cname}_height {height}\n")
|
|
f.write(f"\n")
|
|
f.write(f"#endif\n")
|