Created
May 14, 2024 10:41
-
-
Save shadwork/8826e64411e0285630025dac1c611969 to your computer and use it in GitHub Desktop.
Python script to decompile ZX-Spectrum BASIC to text using tzxtools library
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| import argparse | |
| import sys | |
| from tzxlib.convert import convertToBasic | |
| def main(): | |
| parser = argparse.ArgumentParser(description='Convert Sinclair Basic code representation into Text') | |
| parser.add_argument('file', | |
| nargs='?', | |
| type=argparse.FileType('rb'), | |
| default=(None if sys.stdin.isatty() else sys.stdin.buffer), | |
| help='Input file, stdin if omitted') | |
| parser.add_argument('-o', '--to', | |
| dest='to', | |
| metavar='TARGET', | |
| type=argparse.FileType('wb'), | |
| default=sys.stdout.buffer, | |
| help='Target text file, stdout if omitted') | |
| args = parser.parse_args() | |
| if args.file is None: | |
| parser.print_help(sys.stderr) | |
| sys.exit(1) | |
| args = parser.parse_args() | |
| data = bytearray(args.file.read()) | |
| convertToBasic(data,args.to) | |
| if __name__ == "__main__": | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
listbasicfrom the fuse emulator will also do this.You can do the reverse (BASIC source → .tap or .p) using
zmakebas.