mirror of
https://github.com/pmret/papermario.git
synced 2024-11-14 23:13:10 +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>
53 lines
1.6 KiB
Python
53 lines
1.6 KiB
Python
import os, sys
|
|
import subprocess
|
|
import argparse
|
|
from struct import unpack_from
|
|
from pathlib import Path
|
|
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument("baserom")
|
|
parser.add_argument("start", type=lambda x:int(x, 0))
|
|
parser.add_argument("end", type=lambda x:int(x, 0))
|
|
args = parser.parse_args()
|
|
|
|
baserom_path = Path(__file__).parent.parent / "baserom.z64"
|
|
baserom = baserom_path.read_bytes()
|
|
gfxdis_path = Path(__file__).parent / "gfxdis.f3dex2"
|
|
|
|
rom_start = 0xBFD880
|
|
|
|
i = args.start
|
|
while i < args.end:
|
|
dis_start = i
|
|
while unpack_from(">2I", baserom, i) != (0xDF000000, 0x0):
|
|
i += 4
|
|
i += 8
|
|
while unpack_from("B", baserom, i)[0] == 0:
|
|
i += 1
|
|
|
|
#print(f"Start {hex(dis_start)} end {hex(i)}")
|
|
gfxdis = subprocess.run(f"{gfxdis_path.resolve()} " + f"-x " + f"-dc " + f"-d {baserom[dis_start:i].hex()}",
|
|
capture_output=True, shell=True, text=True)
|
|
|
|
commands = gfxdis.stdout.splitlines()[1:-1]
|
|
new_commands = []
|
|
for command in commands:
|
|
if "unk_" in command:
|
|
nn = []
|
|
for s in command.split(","):
|
|
if "unk_" in s:
|
|
vram = int(s.split("unk_")[1].split(")")[0], 16)
|
|
rom = rom_start + (vram - 0x80240000)
|
|
name = f"D_{vram:X}_{rom:X}"
|
|
nn.append(name)
|
|
else:
|
|
nn.append(s)
|
|
new_commands.append(", ".join(nn))
|
|
else:
|
|
new_commands.append(command)
|
|
|
|
vram = 0x80240000 + (dis_start - rom_start)
|
|
print(f"Gfx D_{vram:X}[] = {{")
|
|
print("\n".join(new_commands))
|
|
print(f"}};\n")
|