"""Reports side by side: loop counts, and DMA time in H counter steps. python tools/compare.py NAME=FILE ... """ import statistics import sys from pathlib import Path sys.path.insert(0, str(Path(__file__).resolve().parent)) import old_report as decode STEPS = 210 # H40: $00-$B6, then $E4-$FF def pos(h): # counted from $A5, where the V counter steps p = h if h <= 0xB6 else h - (0xE4 - 0xB7) return (p - 0xA5) % STEPS def elapsed(v): a, b = v >> 16, v & 0xFFFF return ((b >> 8) - (a >> 8)) * STEPS + pos(b & 255) - pos(a & 255) NAMES = {1: "ROM loop, display off", 3: "RAM loop, display off", 2: "ROM loop, display on", 4: "RAM loop, display on", 5: "ROM loop, 1024-word DMA each VINT", 6: "DMA 16 words", 7: "DMA 64 words", 8: "DMA 256 words", 9: "DMA 1024 words", 10: "DMA 64 words, in picture", 11: "68K ROM, Z80 in its RAM", 21: " Z80 count", 12: "68K RAM, Z80 in its RAM", 22: " Z80 count", 13: "68K ROM, Z80 reading ROM", 23: " Z80 count", 14: "68K RAM, Z80 reading ROM", 24: " Z80 count"} R = {} for arg in sys.argv[1:]: name, path = arg.split("=", 1) R[name] = decode.load(path) print(f"{'':36}" + "".join(f"{n:>22}" for n in R)) for i, label in NAMES.items(): row = f"{label:36}" for n, r in R.items(): v = [x[2] for x in r["records"] if x[0] == i] v = sorted(elapsed(x) for x in v) if 6 <= i <= 10 else sorted(v) row += f"{(str(v[0]) + '-' + str(v[-1]) if v[0] != v[-1] else str(v[0])):>22}" print(row) print("hw " + " ".join(f"{n}={r['hw']:02X}" for n, r in R.items()))