"""Offline packaging of Jackbox / Jukebox art for the MASM32 assembly renderer.""" from pathlib import Path import struct from PIL import Image ROOT = Path(__file__).resolve().parents[2] SOURCE = ROOT / "assets/sprites/jackbox" OUT = ROOT / "assets/animations/hall" def pack(path: Path, frames: list): w, h = frames[0].size raw = b"".join(image.tobytes("raw", "BGRA") for image in frames) path.parent.mkdir(parents=True, exist_ok=True) path.write_bytes(struct.pack("<4s4I", b"ANM1", w, h, len(frames), len(raw)) + raw) print(f"Packed {len(frames)} frame(s) ({w}x{h}) into {path.name}: {len(raw)} bytes") def main(): front_path = SOURCE / "Jackbox_front.jpg" side_path = SOURCE / "Jackbox_side.jpg" ui_path = SOURCE / "Jackbox_UI.jpg" assert front_path.exists(), f"Missing {front_path}" assert side_path.exists(), f"Missing {side_path}" assert ui_path.exists(), f"Missing {ui_path}" # 1. World Cabinet Pack: 2 frames (256x512 BGRA) front_img = Image.open(front_path).convert("RGBA").resize((256, 512), Image.Resampling.LANCZOS) side_img = Image.open(side_path).convert("RGBA").resize((256, 512), Image.Resampling.LANCZOS) pack(OUT / "jackbox-v1.bin", [front_img, side_img]) # 2. Screen UI Pack: 1 frame (640x480 BGRA) ui_img = Image.open(ui_path).convert("RGBA").resize((640, 480), Image.Resampling.LANCZOS) pack(OUT / "jackbox-ui-v1.bin", [ui_img]) print("Jackbox asset packaging complete.") if __name__ == "__main__": main()