# make-fixtures.py - write the PETSCII SEQ test files that c64project.json puts on the disk. # python test/make-fixtures.py import os def petscii(text): out = bytearray() for ch in text.encode("ascii"): if ch == 10: out.append(13) elif 0x61 <= ch <= 0x7A: out.append(ch - 0x20) # lower case -> $41-$5A elif 0x41 <= ch <= 0x5A: out.append(ch + 0x80) # upper case -> $C1-$DA else: out.append(ch) return bytes(out) here = os.path.dirname(os.path.abspath(__file__)) files = { "sample.seq": "alpha\nbravo\ncharlie\ndelta\n", # 100 numbered lines, line 50 is 300 characters long (split at 240 on load) "long.seq": "".join( ("line %d " % n) + ("x" * 292 if n == 50 else "") + "\n" for n in range(1, 101) ), } for name, text in files.items(): with open(os.path.join(here, name), "wb") as f: f.write(petscii(text))