from __future__ import print_function import sys print() if len(sys.argv)<4: print("Please enter all needed parameters:") print("Example: dataliner file.prg data.txt 100") print() print("This converts the binary data of file.prg into C64 V2 Basic data lines beginning "+ "with line 100, stored in the file data.txt, which you can integrate in your Basic "+ "listing with any text editor and copy and paste into VICE.") sys.exit() with open(sys.argv[1], "rb") as f: if sys.version_info < (3, 0): src=[ord(v) for v in f.read()] else: src= f.read() length=len(src) if length < 3: print("Aborting. Selected binary file is too small!") sys.exit() load_addr = src[1]*256+src[0] line_number = int(sys.argv[3]) with open(sys.argv[2],'w+') as h: for i in range(2,length,16): # Die ersten beiden Adressbytes des C64 PRGs fliegen raus print("{} data {}".format(line_number, ",".join(str(x) for x in src[i:i+16])), file=h) line_number += 1 print("No. of bytes in DATA stream, omiting the first 2 address-bytes:", length-2) print("File is loading in C64 memory at ${:04x}".format(load_addr)) print("Read into C64 memory from {} to {} + {}".format(load_addr, load_addr, length-3)) print("Location of text file with C64 Basic DATAs: " + sys.argv[2]) print()