#!/usr/bin/env python3 """Per-frame full-screen UNTEXTURED quads across a screen change. The `.prm` primitives are the transition machinery: one RISES to 255 (the outgoing screen going black), one DECAYS from 255 (the incoming screen's own fade-in), and a screen's constant primitive sits at a fixed alpha throughout. This prints them per frame, with draw counts, so the spans can be checked against durations the FILE declares. fade_pair.py [--from N] [--to N] ⚠️ An earlier version of this tool tried to CLASSIFY the quads into rising and decaying series automatically, by picking the constant series as "whatever value appears on a frame with one quad". That worked on a menu->title capture and produced nonsense on a title->menu one, where the title has no full-screen primitive at rest and the heuristic latched onto a transient. The classification is now left to the reader: the tool prints, it does not decide. """ import re import sys V = re.compile(r"col=([0-9A-F]{8})") def main(): a = sys.argv lo = int(a[a.index("--from") + 1]) if "--from" in a else 0 hi = int(a[a.index("--to") + 1]) if "--to" in a else 10 ** 9 frame, pend = None, None untex, tex, nd, nt = {}, {}, {}, {} for line in open(a[1]): if line.startswith("--- frame"): frame = int(line.split()[2]) untex.setdefault(frame, []); tex.setdefault(frame, []) nd[frame] = nt[frame] = 0 continue if frame is None: continue m = re.match(r"\s*(\d+) prim=(\d+)", line) if m: nd[frame] += 1 if "tex[base=" in line: nt[frame] += 1 pend = ("tex" if "tex[base=" in line else "untex") if m.group(2) == "13" else None continue if "vb=0x" in line and pend: c = V.findall(line) if c and pend == "untex" and "[-1.00,1.00," in line: untex[frame] += [int(x[:2], 16) for x in c[::4]] elif c and pend == "tex": tex[frame] += [int(x[:2], 16) for x in c[::4]] pend = None print("frame untextured full-screen textured (distinct) draws tex") for f in sorted(untex): if lo <= f <= hi: print(f"{f:5d} {str(untex[f]):22s} {str(sorted(set(tex[f]))):26s} {nd[f]:4d} {nt[f]:3d}") return 0 if __name__ == "__main__": raise SystemExit(main())