Generate the 64 GCR values used by Apple DOS 3.3 and ProDos

for i in range(128):
    b = f"{i:07b}"                    # All these tests apply to the low 7 bits
    if '000' in b: continue           # 3 consecutive zeros disallowed
    if b.count('00') > 1: continue    # only one pair of consecutive 0s allowed
    if not '11' in b: continue        # one pair of consecutive 1s required 
    print(hex(i | 128), bin(i | 128)) # top bit is always a 1


Entry first conceived on 15 April 2022, 16:23 UTC, last modified on 15 April 2022, 16:27 UTC
Website Copyright © 2004-2024 Jeff Epler