import struct, sys, io
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
DUMP = r"C:/Users/vikto/Documents/Claude/rt-4d/radio-spi-dump.bin"
data = open(DUMP, "rb").read()
ZN_BASE=0x01C000
def hx(b): return " ".join(f"{x:02X}" for x in b)

# The occupancy said zones DATA is 0x1C000-0x1F000 (12KB). Dump each 512-byte record 0..23
print("Scanning zone region 0x1C000..0x1F000 as 512-byte records:")
for i in range(24):
    off=ZN_BASE+i*512
    d=data[off:off+512]
    if all(b==0xFF for b in d):
        continue
    # look for ascii name anywhere
    printable = bytes(b if 32<=b<127 else 0 for b in d)
    # find longest run of ascii letters
    txt=""
    for b in d[:0x40]:
        if 32<=b<127: txt+=chr(b)
        else: txt+="."
    print(f"\nrec{i} @0x{off:06X}")
    print("  0x00-0x1F:", hx(d[0:0x20]))
    print("  0x20-0x3F:", hx(d[0x20:0x40]))
    print("  ascii0-40:", txt)
