mirror of
https://github.com/pmret/papermario.git
synced 2024-11-27 07:30:30 +00:00
use c shape files
This commit is contained in:
parent
bfe9a42b06
commit
8dceac971a
@ -486,7 +486,6 @@ class Configure:
|
||||
skip_outputs: Set[str],
|
||||
non_matching: bool,
|
||||
modern_gcc: bool,
|
||||
c_maps: bool = False,
|
||||
):
|
||||
assert self.linker_entries is not None
|
||||
|
||||
@ -1039,21 +1038,21 @@ class Configure:
|
||||
},
|
||||
asset_deps=[f"mapfs/tex/{name}"],
|
||||
)
|
||||
elif name.endswith("_shape_built"):
|
||||
elif name.endswith("_shape"):
|
||||
base_name = name[:-6]
|
||||
raw_bin_path = self.resolve_asset_path(f"assets/x/mapfs/geom/{base_name}.bin")
|
||||
bin_path = bin_path.parent / "geom" / (base_name + ".bin")
|
||||
|
||||
if c_maps:
|
||||
# raw bin -> c -> o -> elf -> objcopy -> final bin file
|
||||
c_file_path = (bin_path.parent / "geom" / base_name).with_suffix(".c")
|
||||
o_path = bin_path.parent / "geom" / (base_name + ".o")
|
||||
elf_path = bin_path.parent / "geom" / (base_name + ".elf")
|
||||
|
||||
build(c_file_path, [raw_bin_path], "shape")
|
||||
# Backwards-compatibility: if there is a .bin file, use that
|
||||
path_deprecated = self.resolve_asset_path(path.with_suffix(".bin"))
|
||||
if path_deprecated.is_file():
|
||||
print(f"warning: {name} has a .bin file, which is deprecated. use a .c file instead.")
|
||||
print(bin_path, path_deprecated)
|
||||
build(bin_path, [path_deprecated], "cp")
|
||||
else:
|
||||
o_path = bin_path.with_suffix(".o")
|
||||
elf_path = bin_path.with_suffix(".elf")
|
||||
build(
|
||||
o_path,
|
||||
[c_file_path],
|
||||
[path],
|
||||
"cc" if not modern_gcc else "cc_modern",
|
||||
variables={
|
||||
"cflags": "",
|
||||
@ -1063,8 +1062,6 @@ class Configure:
|
||||
)
|
||||
build(elf_path, [o_path], "shape_ld")
|
||||
build(bin_path, [elf_path], "shape_objcopy")
|
||||
else:
|
||||
build(bin_path, [raw_bin_path], "cp")
|
||||
|
||||
compress = True
|
||||
out_dir = out_dir / "geom"
|
||||
@ -1399,7 +1396,7 @@ if __name__ == "__main__":
|
||||
sys.path.append(str((ROOT / "tools/splat_ext").resolve()))
|
||||
|
||||
configure.split(not args.no_split_assets, args.split_code, args.shift, args.debug)
|
||||
configure.write_ninja(ninja, skip_files, non_matching, args.modern_gcc, args.c_maps)
|
||||
configure.write_ninja(ninja, skip_files, non_matching, args.modern_gcc)
|
||||
|
||||
all_rom_oks.append(str(configure.rom_ok_path()))
|
||||
|
||||
|
@ -12,6 +12,9 @@ import yaml as yaml_loader
|
||||
import n64img.image
|
||||
from tex_archives import TexArchive
|
||||
|
||||
sys.path.append(os.path.join(os.path.dirname(__file__), "..", "..", "build")) # terrible
|
||||
from mapfs.shape import ShapeFile
|
||||
|
||||
script_dir = Path(os.path.dirname(os.path.realpath(__file__)))
|
||||
|
||||
|
||||
@ -49,15 +52,13 @@ def parse_palette(data):
|
||||
return palette
|
||||
|
||||
|
||||
def add_file_ext(name: str, linker: bool = False) -> str:
|
||||
def add_file_ext(name: str) -> str:
|
||||
if name.startswith("party_"):
|
||||
return "party/" + name + ".png"
|
||||
elif name.endswith("_hit"):
|
||||
return "geom/" + name + ".bin"
|
||||
elif name.endswith("_shape"):
|
||||
if linker:
|
||||
name += "_built"
|
||||
return "geom/" + name + ".bin"
|
||||
return "geom/" + name + ".c"
|
||||
elif name.endswith("_tex"):
|
||||
return "tex/" + name + ".bin"
|
||||
elif name.endswith("_bg"):
|
||||
@ -213,6 +214,12 @@ class N64SegPm_map_data(N64Segment):
|
||||
|
||||
elif name.endswith("_tex"):
|
||||
TexArchive.extract(bytes, fs_dir / "tex" / name)
|
||||
elif name.endswith("_shape"):
|
||||
map_name = name[:-6]
|
||||
shape = ShapeFile(map_name, bytes)
|
||||
shape.digest()
|
||||
with open(path, "w") as f:
|
||||
shape.write_to_c(f)
|
||||
else:
|
||||
assert path is not None
|
||||
with open(path, "wb") as f:
|
||||
@ -231,7 +238,7 @@ class N64SegPm_map_data(N64Segment):
|
||||
|
||||
src_paths = []
|
||||
for name, file in self.files.items():
|
||||
src_paths.append(fs_dir / add_file_ext(name, linker=True))
|
||||
src_paths.append(fs_dir / add_file_ext(name))
|
||||
if file.get("dump_raw", False):
|
||||
src_paths.append(fs_dir / f"{name}.raw.dat")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user