From f1d017401b0efef229a45d1b4ffeca95a287594b Mon Sep 17 00:00:00 2001 From: Jeffrey Armstrong Date: Wed, 6 Nov 2024 16:47:33 -0500 Subject: Initial commit with functioning CPU detection code --- support/in2data.py | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 support/in2data.py (limited to 'support') diff --git a/support/in2data.py b/support/in2data.py new file mode 100644 index 0000000..5f497a9 --- /dev/null +++ b/support/in2data.py @@ -0,0 +1,52 @@ +import sys + +def pascal_to_basic(line): + if len(line.strip()) == 0: + return "", 0 + + ret = "" + bytes = 0 + commands = line.strip().split("/") + + for c in commands: + c = c.strip() + if c.startswith("$"): + if c == commands[0]: + ret = "DATA " + else: + ret = ret + ", " + + cnum = c[1:] + ret = ret + "&H" + cnum + bytes = bytes + 1 + + elif c.startswith("{"): + if c != commands[0]: + ret = ret + " : " + ret = ret + "REM " + c.strip()[1:-1] + + return ret, bytes + + +def inline_to_basic(input_file, output_file, line_start): + total_bytes = 0 + line_number = line_start + for line in input_file: + line = line.strip() + + basline, line_bytes = pascal_to_basic(line) + if basline is not None and len(basline) > 0: + output_file.write("{0} {1}\r\n".format(line_number, basline)) + total_bytes = total_bytes + line_bytes + line_number = line_number + 1 + + output_file.write("{0} REM Total Bytes in Data: {1}\r\n".format(line_number, total_bytes)) + +if __name__ == "__main__": + fpin = open(sys.argv[1], "r") + fpout = open(sys.argv[2], "w") + + inline_to_basic(fpin, fpout, int(sys.argv[3])) + + fpin.close() + fpout.close() -- cgit v1.2.3