17 lines
646 B
Python
17 lines
646 B
Python
#!/usr/bin/env python3
|
|
"""Summarise per-byte behaviour of a battle_rec.lua recording (4 KiB/frame).
|
|
usage: rec_fields.py REC LO HI (WRAM offsets, hex) -> one line per byte that ever changes"""
|
|
import sys
|
|
rec = open(sys.argv[1], 'rb').read()
|
|
W = 0x1000
|
|
n = len(rec) // W
|
|
lo, hi = int(sys.argv[2], 16), int(sys.argv[3], 16)
|
|
for a in range(lo, hi):
|
|
col = rec[a::W][:n]
|
|
ch = sum(1 for i in range(1, n) if col[i] != col[i - 1])
|
|
if ch == 0:
|
|
continue
|
|
vals = sorted(set(col))
|
|
vs = ' '.join(f'{v:02X}' for v in vals[:12]) + (' ...' if len(vals) > 12 else '')
|
|
print(f'{a:04X} changes={ch:5d} nvals={len(vals):3d} [{vs}]')
|