#!/usr/bin/env python3 """Both players' state runs within a frame window. usage: ai2_window.py REC FROM TO""" import sys W = 0x800 rec = open(sys.argv[1], 'rb').read(); n = len(rec) // W lo, hi = int(sys.argv[2]), int(sys.argv[3]) for nm, sa, base in (('P1', 0x20D, 0x202), ('P2', 0x46D, 0x462)): out, cur, beg = [], None, 0 for f in range(max(0, lo - 1), min(n, hi)): s = rec[f * W + sa] if s != cur: if cur is not None: out.append(f'{beg + 1}:{cur:02X}x{f - beg}') cur, beg = s, f out.append(f'{beg + 1}:{cur:02X}x{min(n, hi) - beg}+') print(nm, ' '.join(out))