From 57ada86a3f952355f0be515eca3e3f1b5ccfb482 Mon Sep 17 00:00:00 2001 From: Martin Matyas Date: Sun, 8 Nov 2026 17:14:47 +0100 Subject: [PATCH 1/3] check_sizes.py: the build folders named are the ones checked It took folders on its command line but always read build/c, zx, zx128, cpc, c64 and pc, so a build made elsewhere (the CI toolchain's, in build/ci-zx128) was reported with the figures of whatever lay in the default folder. A named folder is now told by its files and checked; one it cannot size fails. Without arguments it checks the defaults as before. Co-Authored-By: Claude Opus 5.5 --- tools/check_sizes.py | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/tools/check_sizes.py b/tools/check_sizes.py index b426a7d..06dde70 100644 --- a/tools/check_sizes.py +++ b/tools/check_sizes.py @@ -5,7 +5,11 @@ grows into the stack does not: the 128K Spectrum once kept 32 bytes, see docs/net-timing.md.) - tools/check_sizes.py [build dir ...] default: whichever of the builds below exist + tools/check_sizes.py [build dir ...] default: whichever of build/c, zx, zx128, cpc, c64, pc exist + +A named folder is told by its files (bomber.mzf: the MZ-800, bomber.cpc: the +CPC, bank6.map: the 128K Spectrum, bomber.tap: the 48K, bomber.prg.elf: the +C64, BOMBER.EXE: the PC); one with none of them fails. The Spectrum limits: the stack starts at FFFFh. Since the lobby's buffers are static it does not reach below FF00h in a 4-player match on either model @@ -58,17 +62,30 @@ def check_pc(d): return ('PC', False, 'no DGROUP in the map') -CHECKS = [ - lambda: check_z80('MZ-800', os.path.join(ROOT, 'build', 'c'), 0xC000, 'the stack (from D000h) wants it under'), - lambda: check_z80('ZX 48K', os.path.join(ROOT, 'build', 'zx'), 0xFEA0, 'the stack (down from FFFFh) wants it under'), - lambda: check_z80('ZX 128K', os.path.join(ROOT, 'build', 'zx128'), 0xFEA0, 'the stack (down from FFFFh) wants it under'), - lambda: check_z80('CPC', os.path.join(ROOT, 'build', 'cpc'), 0xBC00, 'the firmware stubs (BCCBh) and the stack (BE00h) want it under'), - lambda: check_c64(os.path.join(ROOT, 'build', 'c64')), - lambda: check_pc(os.path.join(ROOT, 'build', 'pc')), +Z80 = 'the stack (down from FFFFh) wants it under' +KINDS = [ # a build told by its files (the first that matches): its check + ('bomber.mzf', lambda d: check_z80('MZ-800', d, 0xC000, 'the stack (from D000h) wants it under')), + ('bomber.cpc', lambda d: check_z80('CPC', d, 0xBC00, 'the firmware stubs (BCCBh) and the stack (BE00h) want it under')), + ('bank6.map', lambda d: check_z80('ZX 128K', d, 0xFEA0, Z80)), + ('bomber.tap', lambda d: check_z80('ZX 48K', d, 0xFEA0, Z80)), + ('bomber.prg.elf', check_c64), + ('BOMBER.EXE', check_pc), ] +DEFAULT = [os.path.join(ROOT, 'build', d) for d in ('c', 'zx', 'zx128', 'cpc', 'c64', 'pc')] + + +def check(d): + for f, fn in KINDS: + if os.path.exists(os.path.join(d, f)): return fn(d) + return None if __name__ == '__main__': - results = [r for r in (c() for c in CHECKS) if r] + dirs = sys.argv[1:] or DEFAULT + results = [] + for d in dirs: + r = check(d) + if r: results.append((r[0] + ('' if dirs is DEFAULT else f' ({os.path.relpath(d)})'),) + r[1:]) + elif dirs is not DEFAULT: results.append((os.path.relpath(d), False, 'not a build this knows (no map with a budget)')) if not results: # (the Atari's linker checks its own memory map; Amiga, ST, web: no tight limit) print('no build with a budget here'); sys.exit(0) fails = 0 From be5b74e4c34c5855e5e61f5adfc1d4d81edb6dd4 Mon Sep 17 00:00:00 2001 From: Martin Matyas Date: Sun, 8 Nov 2026 17:21:51 +0100 Subject: [PATCH 2/3] check_sizes.py: review fixes The defaults are checked by their folder again (a build whose last step failed still has its map read); a named folder with files of two machines fails, as does a recognised build without its map. Co-Authored-By: Claude Opus 5.5 --- tools/check_sizes.py | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/tools/check_sizes.py b/tools/check_sizes.py index 06dde70..81393c0 100644 --- a/tools/check_sizes.py +++ b/tools/check_sizes.py @@ -63,29 +63,33 @@ def check_pc(d): Z80 = 'the stack (down from FFFFh) wants it under' -KINDS = [ # a build told by its files (the first that matches): its check - ('bomber.mzf', lambda d: check_z80('MZ-800', d, 0xC000, 'the stack (from D000h) wants it under')), - ('bomber.cpc', lambda d: check_z80('CPC', d, 0xBC00, 'the firmware stubs (BCCBh) and the stack (BE00h) want it under')), - ('bank6.map', lambda d: check_z80('ZX 128K', d, 0xFEA0, Z80)), - ('bomber.tap', lambda d: check_z80('ZX 48K', d, 0xFEA0, Z80)), - ('bomber.prg.elf', check_c64), - ('BOMBER.EXE', check_pc), +MZ = lambda d: check_z80('MZ-800', d, 0xC000, 'the stack (from D000h) wants it under') +CPC = lambda d: check_z80('CPC', d, 0xBC00, 'the firmware stubs (BCCBh) and the stack (BE00h) want it under') +ZX128 = lambda d: check_z80('ZX 128K', d, 0xFEA0, Z80) +ZX48 = lambda d: check_z80('ZX 48K', d, 0xFEA0, Z80) +DEFAULT = [(os.path.join(ROOT, 'build', d), fn) for d, fn in + (('c', MZ), ('zx', ZX48), ('zx128', ZX128), ('cpc', CPC), ('c64', check_c64), ('pc', check_pc))] +KINDS = [ # a named build told by its files: the machine, its check + ('bomber.mzf', 'MZ-800', MZ), ('bomber.cpc', 'CPC', CPC), ('bank6.map', 'ZX 128K', ZX128), + ('bomber.tap', 'ZX 48K', ZX48), ('bomber.prg.elf', 'C64', check_c64), ('BOMBER.EXE', 'PC', check_pc), ] -DEFAULT = [os.path.join(ROOT, 'build', d) for d in ('c', 'zx', 'zx128', 'cpc', 'c64', 'pc')] -def check(d): - for f, fn in KINDS: - if os.path.exists(os.path.join(d, f)): return fn(d) - return None +def check_named(d): + """a build folder from the command line: its machine from its files, never two""" + found = [(m, fn) for f, m, fn in KINDS if os.path.exists(os.path.join(d, f))] + if len(found) == 2 and found[0][0] == 'ZX 128K' and found[1][0] == 'ZX 48K': found = found[:1] # the 128K's tape too + name = os.path.relpath(d) + if not found: return (name, False, 'not a build this knows (no bomber.mzf, .cpc, .tap, bank6.map, .prg.elf, BOMBER.EXE)') + if len(found) > 1: return (name, False, 'files of more than one machine: ' + ', '.join(m for m, _ in found)) + r = found[0][1](d) + if r is None: return (f'{found[0][0]} ({name})', False, 'its map is missing (bomber.map, or bomber.prg.elf)') + return (f'{r[0]} ({name})',) + r[1:] + if __name__ == '__main__': - dirs = sys.argv[1:] or DEFAULT - results = [] - for d in dirs: - r = check(d) - if r: results.append((r[0] + ('' if dirs is DEFAULT else f' ({os.path.relpath(d)})'),) + r[1:]) - elif dirs is not DEFAULT: results.append((os.path.relpath(d), False, 'not a build this knows (no map with a budget)')) + if sys.argv[1:]: results = [check_named(d) for d in sys.argv[1:]] + else: results = [r for r in (fn(d) for d, fn in DEFAULT) if r] # the defaults: whichever exist if not results: # (the Atari's linker checks its own memory map; Amiga, ST, web: no tight limit) print('no build with a budget here'); sys.exit(0) fails = 0 From 31a84caecbef41160152541bfebcc57847680f7b Mon Sep 17 00:00:00 2001 From: Martin Matyas Date: Sun, 8 Nov 2026 17:22:11 +0100 Subject: [PATCH 3/3] check_sizes.py: the usage says when a named folder fails Co-Authored-By: Claude Opus 5.5 --- tools/check_sizes.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/check_sizes.py b/tools/check_sizes.py index 81393c0..efdc4f7 100644 --- a/tools/check_sizes.py +++ b/tools/check_sizes.py @@ -9,7 +9,8 @@ A named folder is told by its files (bomber.mzf: the MZ-800, bomber.cpc: the CPC, bank6.map: the 128K Spectrum, bomber.tap: the 48K, bomber.prg.elf: the -C64, BOMBER.EXE: the PC); one with none of them fails. +C64, BOMBER.EXE: the PC); one with none of them, with files of two machines, +or without its map fails. The Spectrum limits: the stack starts at FFFFh. Since the lobby's buffers are static it does not reach below FF00h in a 4-player match on either model