#!/usr/bin/env python3 """Decode probe-suite saves (probes/suite) and set them side by side. python -I scripts/suite_results.py console.srm mesen.srm board.srm Each file is a 32 KiB battery RAM image: a header, a boot log, a directory (tag, slot, length per test) and the slots (probes/suite/suite.s). Every test becomes rows of (label, value); one column per file, and a `*` in front of a row whose values are not all equal. The first file is taken as the judge when naming the column headers (normally the console's .srm). """ from __future__ import annotations import argparse from collections.abc import Callable, Iterator from pathlib import Path MAGIC = b"SNESUITE" STATUS = {0: "not run", 1: "started", 2: "done", 3: "HUNG"} MASTER_HZ = 21_477_272.727 FRAME_CLOCKS = 357_366 TIMER2_HZ = 64_000 Rows = Iterator[tuple[str, str]] def u16(b: bytes, o: int) -> int: return b[o] | b[o + 1] << 8 def u24(b: bytes, o: int) -> int: return b[o] | b[o + 1] << 8 | b[o + 2] << 16 class Save: def __init__(self, path: Path) -> None: self.path = path self.data = path.read_bytes() if self.data[:8] != MAGIC: raise SystemExit(f"{path}: not a suite save (starts {self.data[:8]!r})") self.format = self.data[8] self.state = self.data[9] self.boots = u16(self.data, 10) self.runs = u16(self.data, 12) n = self.data[14] self.tests: dict[str, tuple[int, bytes]] = {} for i in range(n): o = 0x200 + 8 * i tag = self.data[o : o + 4].decode("ascii", "replace") slot, length = u16(self.data, o + 4), u16(self.data, o + 6) self.tests[tag] = (self.data[0x10 + i], self.data[slot : slot + length]) def boot_log(self) -> list[bytes]: count = min(self.boots, 16) first = self.boots - count return [ self.data[0x100 + 16 * (b % 16) : 0x100 + 16 * (b % 16) + 16] for b in range(first, self.boots) ] # --- decoders: payload -> rows ----------------------------------------------- OPEN_BUS = [ # label, mask, fullsnes's prediction (probes/open_bus) ("2100 abs (MDR)", 0xFF, 0x21), ("2100 long (MDR)", 0xFF, 0x00), ("213E, PPU1 = FF", 0x10, 0x10), ("213E, PPU1 = 00", 0x10, 0x00), ("213F, PPU2 = FF", 0x20, 0x20), ("213F, PPU2 = 00", 0x20, 0x00), ("CGRAM high, PPU2 = FF", 0x80, 0x80), ("213E, PPU1 FF then PPU2 00", 0x10, 0x10), ("213F, PPU1 FF then PPU2 00", 0x20, 0x00), ("213E, PPU1 00 then PPU2 FF", 0x10, 0x00), ("213F, PPU1 00 then PPU2 FF", 0x20, 0x20), ] def obus(p: bytes) -> Rows: for (label, mask, want), got in zip(OPEN_BUS, p, strict=True): yield label, f"${got:02X} {'ok' if got & mask == want else 'DIFF'}" def hvlt(p: bytes) -> Rows: for d, dot in enumerate((40, 150, 300)): block = p[d * 128 : (d + 1) * 128] for name, part in (("$2137", block[:64]), ("WRIO", block[64:])): hs = sorted({u16(part, i) for i in range(0, 64, 4)}) yield f"IRQ dot {dot}: H by {name}", " ".join(f"${h:03X}" for h in hs) MIDF = ["CG active", "CG H-Blank", "CG V-Blank", "OAM active", "OAM H-Blank", "OAM V-Blank"] def midf(p: bytes) -> Rows: for case, label in enumerate(MIDF): runs = [] for run in range(3): o = (case * 3 + run) * 5 where = u16(p, o) spot = "---" if where == 0xFFFF else f"{where:03X}" runs.append(f"{spot}/{p[o + 2]} H{u16(p, o + 3):03X}") yield label, " ".join(runs) def oam_write(p: bytes) -> Rows: for i in range(85): o = i * 21 n = p[o + 2] changes = [f"{u16(p, o + 3 + 3 * k):03X}={p[o + 5 + 3 * k]:02X}" for k in range(min(n, 6))] yield f"dot {4 * i:3}", f"H{u16(p, o):03X} {n}: " + " ".join(changes) def oam_gap(p: bytes) -> Rows: for g, (label, value) in enumerate(oam_write(p + bytes(85 * 21 - len(p)))): if g == 32: break yield f"gap {g:2} (36 clocks each)", value def two_reads(p: bytes) -> Rows: for i in range(85): o = i * 4 yield f"dot {4 * i:3}", f"H{u16(p, o + 2):03X} {p[o]:02X} {p[o + 1]:02X}" def cgws(p: bytes) -> Rows: for i in range(85): o = i * 15 n = p[o + 2] changes = [f"{p[o + 3 + 3 * k]:02X}={u16(p, o + 4 + 3 * k):04X}" for k in range(min(n, 4))] yield f"dot {4 * i:3}", f"H{u16(p, o):03X} {n}: " + " ".join(changes) def clkr(p: bytes) -> Rows: runs, samples, step = p[0], p[1], u16(p, 2) if runs == 0xFF: yield "upload", "the S-SMP never answered" return for r in range(runs): ticks = [u24(p, 4 + 3 * (r * samples + s)) for s in range(samples)] total = (ticks[-1] - ticks[0]) & 0xFFFFFF frames = step * (samples - 1) nominal = frames * FRAME_CLOCKS / MASTER_HZ * TIMER2_HZ yield ( f"run {r + 1}: ticks in {frames} frames", f"{total} ({(total / nominal - 1) * 1e6:+.0f} ppm)", ) steps = [(b - a) & 0xFFFFFF for a, b in zip(ticks, ticks[1:], strict=False)] yield f"run {r + 1}: per {step} frames", " ".join(str(s) for s in steps) AJ_CLEAR = [0, 64, 128, 192, 256, 384, 512, *range(140, 182, 2)] # tests_autojoy.inc AJ_GAP = [0, 32, 64, 96, 128, 160, 192, 196, 200, 202, 204, 206, 208, 210, 214, 220, 230, 256] AJ_PRE = [0, *(6 * n for n in range(20, 37)), 252] AJ_VARIANTS = ["blip", "clear", "enable", "latch clear", "latch set", "JOYSER0 read"] AJ_ROWS = [ (0, 0), (224, 200), (224, 308), (225, 0), (225, 16), (225, 32), (225, 48), (225, 64), (225, 80), (225, 96), (225, 192), (226, 20), (227, 20), (228, 20), (229, 0), ] def latch(b: bytes, o: int) -> str: return f"H{b[o] | (b[o + 1] & 1) << 8:03X} V{b[o + 2]:03}" def ajt1(p: bytes) -> Rows: yield "timeouts", str(p[0]) for i in range(16): o = 1 + 6 * i yield f"trial {i:2}: rise, fall", f"{latch(p, o)} {latch(p, o + 3)}" def ajcl(p: bytes) -> Rows: yield "timeouts", str(p[0]) yield "header JOY1 / manual / JOY2", f"{u16(p, 1):04X} {u16(p, 3):04X} {u16(p, 5):04X}" for i in range(2 * len(AJ_CLEAR)): o = 17 + 5 * i poll = "--" if p[o] == 0xFF else str(p[o]) yield ( f"pass {i // len(AJ_CLEAR) + 1} clear +{AJ_CLEAR[i % len(AJ_CLEAR)]:3}", f"poll {poll:>2} manual {u16(p, o + 1):04X} JOY1 {u16(p, o + 3):04X}", ) def blips(values: list[int], what: str) -> Callable[[bytes], Rows]: def decode(p: bytes) -> Rows: yield "timeouts", str(p[0]) for i in range(2 * len(values)): o = 1 + 3 * i yield ( f"pass {i // len(values) + 1} {what} {values[i % len(values)]:3}", f"count {p[o]:3} JOY1 {u16(p, o + 1):04X}", ) return decode def ajlt(p: bytes) -> Rows: yield "timeouts", str(p[0]) for i in range(16): o = 1 + 4 * i yield f"trial {i:2}", f"JOYSER0 {p[o]:02X} {p[o + 1]:02X} JOY1 {u16(p, o + 2):04X}" def ajir(p: bytes) -> Rows: yield "timeouts", str(p[0]) o = 1 for name in AJ_VARIANTS: yield f"{name}: JOY1 after poison", f"{u16(p, o):04X}" o += 2 for v, h in AJ_ROWS: fired = "no IRQ " if p[o + 7] & 0x80 else "" yield ( f"{name}: IRQ at V{v} H{h}", f"count {u16(p, o)} JOY1 {u16(p, o + 2):04X} manual {u16(p, o + 4):04X} " f"{fired}{latch(p, o + 6)}", ) o += 9 def mulf(p: bytes) -> Rows: o = 0 for what, ks in (("mul FAST", 9), ("mul SLOW", 9), ("div FAST", 17), ("div SLOW", 17)): for k in range(ks): q = p[o + 4 * k : o + 4 * k + 4] yield f"{what} k={k + 2:2}", f"RDDIV {q[1]:02X}{q[0]:02X} RDMPY {q[3]:02X}{q[2]:02X}" o += 4 * ks def div0(p: bytes) -> Rows: for i, dividend in enumerate((0x0000, 0x000C, 0x1234, 0xFFFF)): q = p[4 * i : 4 * i + 4] yield f"${dividend:04X} / 0", f"RDDIV {q[1]:02X}{q[0]:02X} RDMPY {q[3]:02X}{q[2]:02X}" for i, k in enumerate((2, 5, 9, 13, 17)): q = p[16 + 4 * i : 20 + 4 * i] yield ( f"$1234 / 0 after $00 x $A5, k={k:2}", f"RDDIV {q[1]:02X}{q[0]:02X} RDMPY {q[3]:02X}{q[2]:02X}", ) def mrep(p: bytes) -> Rows: for row, b2 in enumerate([0xFF] + [0x100 >> i & 0xFF for i in range(1, 10)]): values = " ".join(f"{u16(p, 16 * row + 2 * g):04X}" for g in range(8)) yield f"B2=${b2:02X}, g=2..9", values def drst(p: bytes) -> Rows: for g in range(16): q = p[4 * g : 4 * g + 4] yield f"restart g={g + 2:2}", f"RDDIV {q[1]:02X}{q[0]:02X} RDMPY {q[3]:02X}{q[2]:02X}" def mrfs(p: bytes, first: int = 10) -> Rows: for h in range(32): q = p[3 * h : 3 * h + 3] yield f"HTIME {first + h}", f"RDDIV {q[2]:02X}{q[0]:02X} at H{q[1]:02X}" def hvff(p: bytes) -> Rows: hexes = lambda b: " ".join(f"{x:02X}" for x in b) # noqa: E731 yield "F1 213C x4, 213D x4", hexes(p[0:8]) yield "F2 3C 3D 3C 3D", hexes(p[8:12]) yield "F3 3C, 3F, 3C", hexes(p[12:15]) yield "F4 3C, latch, 3C", hexes(p[15:17]) yield "F7 3F, latch 3F, 3F", hexes(p[17:20]) WDMA = [ "W1 ROM->2180", "W2 7E:2100->2180", "W3 00:0B00->2180", "W4 7F:2100->2180", "W5 2180->7E:2200", "W6 2180->00:0B40", "W7 2180->SRAM", "W8 7E:3000->2180 (same)", ] def wdma(p: bytes) -> Rows: o = 0 for i, label in enumerate(WDMA): dest = p[o : o + 8].hex(" ") probe = p[o + 8] o += 9 extra = "" if i in (4, 5): extra = f" WMADD region {p[o : o + 8].hex(' ')}" o += 8 yield label, f"{dest} probe {probe:02X}{extra}" def rfsh(p: bytes) -> Rows: o = 0 for name in ("field 0", "field 1", "field 0 +prelude", "field 1 +prelude"): raw, hs = p[o], p[o + 1 : o + 97] steps = [(b - a) & 0xFF for a, b in zip(hs, hs[1:], strict=False)] big = [i for i, s in enumerate(steps) if s > 0x40 or 24 <= s <= 32] yield f"{name} ($213F {raw:02X})", " ".join(f"{h:02X}" for h in hs) yield f"{name} long steps at", " ".join(f"{i}:{steps[i]}" for i in big) o += 97 for f in range(8): q = p[o + 3 * f : o + 3 * f + 3] yield ( f"frame {f} ($213F {q[0]:02X})", f"H {q[1]:02X} -> {q[2]:02X} ({(q[2] - q[1]) & 0xFF})", ) IRQ_TIMES = [ 0, 1, 2, 3, 4, 5, 8, 16, 100, 101, 102, 103, 152, 153, 154, 255, 256, 257, 321, 322, 323, 324, 325, 326, 327, 328, 329, 338, 339, 340, 511, ] def irqn(p: bytes) -> Rows: for i, h in enumerate(IRQ_TIMES): q = p[5 * i : 5 * i + 5] yield ( f"7a HTIME {h:3}", f"V100: H{q[0] | (q[1] & 1) << 8:03X} V{q[2]:02X} raw {q[1]:02X}; " f"V101: H{q[3] | (q[4] & 1) << 8:03X}", ) o = 155 for h in (1, 100, 153, 256, 323, 339): yield f"7b vector HTIME {h:3}", f"H{p[o] | (p[o + 1] & 1) << 8:03X} V{p[o + 2]:02X}" o += 3 for (v, h), n in zip( ((240, 153), (240, 152), (240, 154), (261, 153), (261, 152), (100, 153)), p[o : o + 6], strict=True, ): yield f"7c IRQs in 4 frames at V{v} H{h}", str(n) o += 6 yield "7d NMI from WAI", f"H{p[o] | (p[o + 1] & 1) << 8:03X} V{p[o + 2]:02X}" o += 3 for n in (0, 16, 32, 64, 128): q = p[o : o + 4] label = "7d NMI in the sled" if n == 0 else f"7d NMI in the sled after a {n}-byte DMA" yield label, f"NOP {q[0]} H{q[1] | (q[2] & 1) << 8:03X} V{q[3]:02X}" o += 4 def line(p: bytes) -> Rows: for f in range(8): q = p[3 * f : 3 * f + 3] mode = "interlace" if f >= 4 else "progressive" yield f"frame {f} {mode} ($213F {q[0]:02X})", f"last V {q[1] | (q[2] & 1) << 8}" def ppuw(p: bytes) -> Rows: for m, mem in enumerate(("VRAM", "CGRAM", "OAM")): for r, run in enumerate(("active 100/20", "H-Blank 100/276", "V-Blank 230/20")): o = 40 * (3 * m + r) n = u16(p, o) changes = [ f"{u16(p, o + 2 + 3 * k):03X}={p[o + 4 + 3 * k]:02X}" for k in range(min(n, 12)) ] marker = u16(p, o + 38) spot = "none" if marker == 0xFFFF else f"{marker:03X}" yield f"{mem} {run}", f"{n} changed, marker at {spot}: " + " ".join(changes) OBJF = [ "D1 36 small", "D2 12 large", "D3 12 large flipped", "D4 8 at X=256 + 32", "D5 8 large + 4 at X=256", "D6 8 at X=-64 + 32", "D7 8 large + 4 at X=-64", ] def objf(p: bytes) -> Rows: for i, label in enumerate(OBJF): q = p[8 * i : 8 * i + 8] first = ( "none" if q[1] == 0xFF and q[2] == 0xFF else (f"{q[1]:02X} at V{q[2]} H{q[3] | (q[4] & 1) << 8:03X}") ) second = "none" if q[5] == 0xFF else f"V{q[5]} H{q[6] | (q[7] & 1) << 8:03X}" yield label, f"$213E {q[0]:02X}; first {first}; second {second}" def disp(p: bytes) -> Rows: for i, h in enumerate((0, 32, 64, 66, 128, 274, 330)): q = p[3 * i : 3 * i + 3] rise = "none" if q[0] == 0xFF else f"V{q[0]} H{q[1] | (q[2] & 1) << 8:03X}" yield f"E1 on at 59/{h}: range over at", rise for i, case in enumerate( ( "a blanked", "b on 200-230", "c on 225/100-226", "d on+off 100/100", "e on 100/100-101", "f on+off 230", ) ): yield f"E2 {case}: OAM read", f"{p[21 + i]:02X} ($24 no reload, $20 reload)" def ipls(p: bytes) -> Rows: if p[0] == 0xFF and not any(p[1:]): yield "upload", "the S-SMP never answered" return for r in range(3): o = 9 * r start, frames, end = p[o : o + 4], p[o + 4], p[o + 5 : o + 9] yield ( f"block {r + 1}", f"{frames} frames, H{start[0] | (start[1] & 1) << 8:03X} " f"V{start[2] | (start[3] & 1) << 8} -> H{end[0] | (end[1] & 1) << 8:03X} " f"V{end[2] | (end[3] & 1) << 8}", ) def hdor(p: bytes) -> Rows: for v, label in enumerate(("ch0 writes, ch1 reads", "ch0 reads, ch1 writes (control)")): q = p[4 * v : 4 * v + 4] yield label, f"NLTR0 {q[0]:02X} A2A0 {q[1]:02X} NLTR1 {q[2]:02X} A2A1 {q[3]:02X}" HDSW = [ "off", "1 direct, no transfer", "1 direct repeat", "1 mode 3 repeat", "1 direct, reload every line", "8 direct repeat", "1 indirect, reload every line", ] HDSW_INIT = ["off", "1 direct", "1 indirect", "8 direct", "8 indirect"] def hdsw(p: bytes) -> Rows: h = lambda o: p[o] | (p[o + 1] & 1) << 8 # noqa: E731 for c, label in enumerate(HDSW): spans = [ f"{h(32 * c + 4 * s):03X}+{(h(32 * c + 4 * s + 2) - h(32 * c + 4 * s)) % 341}" for s in range(8) ] yield f"per line: {label}", " ".join(spans) o = 224 for label in HDSW_INIT: spans = [] for _ in range(4): spans.append(f"{h(o):03X}->{h(o + 2):03X}/V{p[o + 4]}") o += 5 yield f"init: {label}", " ".join(spans) def hdlt(p: bytes) -> Rows: o = 0 for chan in (0, 7): for par in (0, 1): cells = [] for h in range(240, 280): q = p[o : o + 4] cells.append(f"{q[0] | (q[1] & 1) << 8:03X}:{q[2]:02X}/{q[3]:02X}") o += 4 for k in range(0, 40, 10): yield ( f"ch{chan} line {100 + par} HTIME {240 + k}-{249 + k}", " ".join(cells[k : k + 10]), ) for chan in range(8): q = p[o : o + 4] yield ( f"transfer flag ch{chan}", f"line 101 NLTR {q[0]:02X} dA2A {q[1]:02X}; line 102 NLTR {q[2]:02X} dA2A {q[3]:02X}", ) o += 4 def scpa(p: bytes) -> Rows: yield "tests / failed / failed again", f"{u16(p, 0)} / {u16(p, 2)} / {u16(p, 4)}" v = u16(p, 6) yield "first failure", "none" if v == 0xFFFF else f"V{v} DAS {u16(p, 8):04X}" yield "WRAM bytes not 1", str(u16(p, 10)) def dend(p: bytes) -> Rows: n0 = u16(p, 0) yield "N0 (first end at V0 H>=8, HDMA off)", str(n0) cal = [p[2 + 2 * i] | (p[3 + 2 * i] & 1) << 8 for i in range(32)] yield "end H for N0-24..N0+7", " ".join(f"{h:03X}" for h in cal) for i in range(64): o = 66 + 8 * i q = p[o : o + 8] end = f"{'V0 ' if not q[1] & 0x80 else 'V? '}H{q[0] | (q[1] & 1) << 8:03X}" yield ( f"N0{i // 2 - 24:+d} frame {i % 2}", f"end {end} line 0: dA2A {q[2]:02X} NLTR {q[3]:02X} vblank: dA2A {u16(q, 4)} NLTR {q[6]:02X}", ) def crsh(p: bytes) -> Rows: if p[0] != ord("K"): yield "state", "not started" return yield "next / lost / running", f"{p[1]} / {p[2]} / {'none' if p[3] == 0xFF else p[3]}" cal = [p[8 + 2 * i] | (p[9 + 2 * i] & 1) << 8 for i in range(96)] for line in (1, 2): for ht in range(4): idx = [(line - 1) * 48 + ht * 12 + n for n in range(12)] yield ( f"calibration V{line} HTIME {21 + ht}: DMA end H, N=1..12", " ".join(f"{cal[i]:03X}" for i in idx), ) yield ( f"attempt V{line} HTIME {21 + ht}: status/NLTR7, N=1..12", " ".join(f"{p[8 + 2 * (96 + i)]:02X}/{p[9 + 2 * (96 + i)]:02X}" for i in idx), ) for r in range(min(p[2], 8)): q = p[392 + 16 * r : 408 + 16 * r] kind = {1: "reached BRK/COP", 2: "still running at NMI", 3: "never came back"}.get( q[1], q[1] ) yield ( f"lost {r + 1}: attempt {q[0]}", f"{kind}; P {q[2]:02X} PC {q[5]:02X}:{q[4]:02X}{q[3]:02X} A {u16(q, 6):04X} " f"X {u16(q, 8):04X} Y {u16(q, 10):04X} S {u16(q, 12):04X} H{q[14]:02X} V{q[15]:02X}", ) DECODERS: dict[str, Callable[[bytes], Rows]] = { "HDOR": hdor, "HDSW": hdsw, "HDLT": hdlt, "SCPA": scpa, "DEND": dend, "CRSH": crsh, "PPUW": ppuw, "OBJF": objf, "DISP": disp, "IPLS": ipls, "HVFF": hvff, "WDMA": wdma, "RFSH": rfsh, "IRQN": irqn, "LINE": line, "MULF": mulf, "DIV0": div0, "MREP": mrep, "DRST": drst, "MRFS": mrfs, "AJT1": ajt1, "AJCL": ajcl, "AJBG": blips(AJ_GAP, "gap"), "AJBP": blips(AJ_PRE, "delay"), "AJLT": ajlt, "AJIR": ajir, "OBUS": obus, "HVLT": hvlt, "MIDF": midf, "OAWA": oam_write, "OAWB": oam_write, "OAWC": oam_write, "OAWD": lambda p: oam_gap(p), "OAMR": two_reads, "CGWS": cgws, "CGRS": two_reads, "CLKR": clkr, } def boot_rows(save: Save) -> Rows: yield "boots / runs / state", f"{save.boots} / {save.runs} / {save.state}" for entry in save.boot_log(): number, state, started = u16(entry, 0), entry[2], entry[3] cpu, ppu1, ppu2 = entry[4], entry[5], entry[6] h, v = u16(entry, 8), u16(entry, 10) mid = "" if started == 0xFF else f" test {started + 1} was running" yield ( f"boot {number}", f"CPU {cpu & 15} PPU1 {ppu1 & 15} PPU2 {ppu2 & 15} " f"{'PAL' if ppu2 & 0x10 else 'NTSC'}, reset at H{h:03X} V{v:03X}, state {state}{mid}", ) def main() -> int: parser = argparse.ArgumentParser(description=__doc__.splitlines()[0]) parser.add_argument("srm", type=Path, nargs="+") parser.add_argument("--only", nargs="*", help="test tags to show") parser.add_argument("--diff", action="store_true", help="only rows whose values differ") args = parser.parse_args() saves = [Save(p) for p in args.srm] names = [s.path.stem for s in saves] width = max(14, *(len(n) for n in names)) def table(title: str, columns: list[list[tuple[str, str]]]) -> None: labels: list[str] = [] for col in columns: for label, _ in col: if label not in labels: labels.append(label) values = [dict(col) for col in columns] lines = [] for label in labels: row = [v.get(label, "-") for v in values] differ = len(set(row)) > 1 if args.diff and not differ: continue mark = "*" if differ else " " if len(saves) == 1: lines.append(f" {mark} {label:30} {row[0]}") else: lines.append(f" {mark} {label}") lines.extend(f" {n:{width}} {v}" for n, v in zip(names, row, strict=True)) if lines: print(title) print("\n".join(lines)) if not args.only: table("BOOT", [list(boot_rows(s)) for s in saves]) tags: list[str] = [] for s in saves: tags.extend(t for t in s.tests if t not in tags) for tag in tags: if args.only and tag not in args.only: continue columns = [] for s in saves: status, payload = s.tests.get(tag, (0, b"")) if status != 2: columns.append([("status", STATUS.get(status, str(status)))]) elif tag == "MRFS" and s.format == 1: columns.append(list(mrfs(payload, first=104))) elif tag == "AJIR" and s.format == 1: # Format 1 stored rows past offset 255 in the wrong place (an # 8-bit offset sum, fixed in format 2): not decodable. columns.append([("format 1", "rows misplaced; rerun with format 2")]) elif tag in DECODERS: columns.append(list(DECODERS[tag](payload))) else: columns.append([("raw", payload.hex())]) table(tag, columns) return 0 if __name__ == "__main__": raise SystemExit(main())