data = open(r"C:/Users/vikto/Documents/Claude/rt-4d/radio-spi-dump.bin","rb").read()

# Check 0x14C000 region: is it sequential GBK codepoints?
seg = data[0x14C000:0x14C000+40]
print("bytes @0x14C000:", seg.hex(' '))
# decode as gbk pairs
try:
    print("gbk:", seg.decode('gbk'))
except Exception as e:
    print(e)

# Are the CJK chars strictly increasing in unicode order?
region = data[0x14C000:0x157000]
chars=[]
i=0
while i < len(region)-1:
    pair = region[i:i+2]
    try:
        c = pair.decode('gbk')
        if len(c)==1 and ord(c)>0x2000:
            chars.append(ord(c))
    except:
        pass
    i+=2
inc = sum(1 for a,b in zip(chars,chars[1:]) if b>a)
print(f"CJK chars in 0x14C000-0x157000: {len(chars)}, monotonic-increasing fraction: {inc/max(1,len(chars)-1):.2%}")
print("first codepoints:", [hex(c) for c in chars[:8]], "last:", [hex(c) for c in chars[-4:]])

# search whole dump for meaningful ascii keywords (case-insensitive)
kws = [b'RADTEL', b'Radtel', b'RT-4D', b'RT4D', b'FIRMWARE', b'VERSION', b'BOOT', b'COPYRIGHT',
       b'WELCOME', b'BRANDMEISTER', b'OpenGD', b'DMR ID', b'CALLSIGN', b'\x00V1.', b'V2.', b'BETA', b'.4rdmf']
for k in kws:
    idx = data.find(k)
    if idx>=0:
        print(f"FOUND {k!r} @0x{idx:06X}")
