Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SBN encoding #1085

Merged
merged 12 commits into from
Jul 25, 2023
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ build/
/assets/jp
/assets/pal
/assets/ique
*.sbn

# Star Rod
/sprite/SpriteTable.xml
Expand Down
25 changes: 25 additions & 0 deletions tools/build/audio/sbn.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#! /usr/bin/python3

from sys import argv, path
from pathlib import Path

# allow importing splat_ext
path.append(str(Path(__file__).parent.parent.parent))

from splat_ext.pm_sbn import SBN

if __name__ == "__main__":
out = argv[1]
inputs = [Path(p) for p in argv[2:]]

sbn = SBN()

for input in inputs:
# if input is a sbn.yaml, read its directory
if input.suffix == ".yaml":
sbn.read(input.parent)

data = sbn.encode()

with open(out, "wb") as f:
f.write(data)
9 changes: 9 additions & 0 deletions tools/build/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,8 @@ def write_ninja_rules(
"effect_data", command=f"$python {BUILD_TOOLS}/effects.py $in_yaml $out_dir"
)

ninja.rule("pm_sbn", command=f"$python {BUILD_TOOLS}/audio/sbn.py $out $in")

with Path("tools/permuter_settings.toml").open("w") as f:
f.write(
f"compiler_command = \"{cc} {CPPFLAGS.replace('$version', 'pal')} {cflags} -DPERMUTER -fforce-addr\"\n"
Expand Down Expand Up @@ -378,6 +380,7 @@ def split(self, assets: bool, code: bool, shift: bool, debug: bool):
"pm_effect_shims",
"pm_sprite_shading_profiles",
"pm_imgfx_data",
"pm_sbn",
]
)
if code:
Expand Down Expand Up @@ -1110,6 +1113,12 @@ def build(
},
)
build(entry.object_path, [entry.object_path.with_suffix("")], "bin")
elif seg.type == "pm_sbn":
sbn_path = entry.object_path.with_suffix("")
build(sbn_path, entry.src_paths, "pm_sbn") # could have non-yaml inputs be implicit
bates64 marked this conversation as resolved.
Show resolved Hide resolved
build(entry.object_path, [sbn_path], "bin")
elif seg.type == "linker" or seg.type == "linker_offset":
pass
elif seg.type == "pm_imgfx_data":
c_file_path = (
Path(f"assets/{self.version}") / "imgfx" / (seg.name + ".c")
Expand Down
Loading
Loading