Files
Sylpheed/tools/re-capture/fade_quads.py
sylph-decoder dd4f30a79f tools: fade_quads could not run -- two pre-monorepo paths
`screen-transitions.md` cites `fade_quads.py` as the command behind its decoded
fade ramp, and the command had been dead since the monorepo migration: it read
regn_decode.py from /work/Syplheed-Reborn and defaulted its pak to
/work/sylph_extract, neither of which exists. Resolve the helper beside the
script and default the pak under $SYLPHEED_DISC, the way run-canary and
sylpheed-cli already do.

A cited command that no longer runs is a citation nobody can check.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014voBspJ6kFncNErZJuZcLw
2026-08-29 12:15:06 +00:00

60 lines
2.6 KiB
Python
Executable File

#!/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=<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],
t=(be32(bundle,blk+36) if blk+40<=end else None)))
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}
want = [int(a) for a in sys.argv[1:]] or [2,4,5,6]
for b in want:
names, groups = parse(E[BUILDS[b]])
print(f"=== build {b} ===")
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']})")