#!/usr/bin/env python3 """Dump every `.prm` primitive's keyframe group (alpha + time) for a UI build. The screen-transition fade lives here -- see docs/re/screen-transitions.md. Usage: PAK= fade_quads.py [build...] (default: GP_TITLE, builds 2 4 5 6)""" import struct, sys, glob, os, zlib # The monorepo migration left this pointing at /work/Syplheed-Reborn, a path # that no longer exists -- so the command screen-transitions.md cites as its # evidence could not be re-run. Resolve beside this file instead. _SD = os.path.dirname(os.path.abspath(__file__)) sys.path.insert(0, _SD) src = open(os.path.join(_SD, "regn_decode.py")).read() exec(src.split("# ── POF0")[0]) DECL_AT, DECL_ENTRY, KF = 0x20, 60, 40 def be32(b,o): return struct.unpack_from(">I", b, o)[0] def parse(bundle): n = be32(bundle, 0x14) names=[] for i in range(n): o = DECL_AT + i*DECL_ENTRY names.append(bundle[o:o+28].split(b"\0")[0].decode("ascii","replace")) groups={} pos = DECL_AT + n*DECL_ENTRY for _ in range(n): if pos+8 > len(bundle): break idx = be32(bundle,pos); frames = be32(bundle,pos+4) if idx>=n or frames==0 or frames>4096: break first = pos+12; end = first + frames*KF - 4 g=[] for k in range(frames): blk = first + k*KF if blk+36 > len(bundle) or blk+36 > end: break g.append(dict(fade=be32(bundle,blk), sx=be32(bundle,blk+16), sy=be32(bundle,blk+20), x=struct.unpack_from(">i",bundle,blk+28)[0], y=struct.unpack_from(">i",bundle,blk+32)[0], # A POSE'S TIME PRECEDES IT (ui-keyframe-record-layout.md). # This read `blk+36` -- the NEXT record's time word -- # which shifted every time by one slot and left the # last pose untimed. That stale association is what # made screen-transitions.md print a 0.87-4.08 s # fade-in and an untimed fade-out. Corrected 2026-08-30. t=be32(bundle,blk-4))) groups[idx]=g; pos=end return names, groups # ...and the default pak pointed at /work/sylph_extract, which the disc mount # replaced. $SYLPHEED_DISC is what run-canary and sylpheed-cli both use. pak = os.environ.get("PAK") or os.path.join( os.environ.get("SYLPHEED_DISC", "/disc"), "dat", "GP_TITLE.pak") E = pak_entries(pak) E = [b for h,b in E] # build index -> pak entry index, from `screen list`: 0..9 then 12, 15 BUILDS = {0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,10:12,11:15} # An argument may be a BUILD ordinal (mapped through BUILDS) or, prefixed with # `e`, a raw PAK ENTRY -- the splashes are entries 10/11 and are NOT screen # builds, so no build ordinal addresses them. Writing `e10` says which index # space is meant, which is the whole lesson of build-ordinal-vs-entry.md. want = sys.argv[1:] or ["2","4","5","6"] for arg in want: if str(arg).startswith("e"): idx = int(str(arg)[1:]); label = f"entry {idx}" else: idx = BUILDS[int(arg)]; label = f"build {arg} (entry {idx})" names, groups = parse(E[idx]) print(f"=== {label} ===") for i,nm in enumerate(names): if not nm.endswith(".prm"): continue g = groups.get(i, []) print(f" [{i}] {nm} {len(g)} kf") for k in g: a=(k['fade']>>24)&0xff print(f" t={str(k['t']):>5} fade=0x{k['fade']:08x} (alpha {a:3d}) scale={k['sx']}x{k['sy']} pos=({k['x']},{k['y']})")