Skip to content

Instantly share code, notes, and snippets.

@blark
Created December 10, 2019 18:59
Show Gist options
  • Save blark/78375002420af6e3816990c489d93755 to your computer and use it in GitHub Desktop.
Save blark/78375002420af6e3816990c489d93755 to your computer and use it in GitHub Desktop.
A quick and dirty Python 3 script to byteswap an Amiga ROM
#!/usr/bin/env python3
import argparse
parser = argparse.ArgumentParser(description="Byteswap an Amiga 500 ROM file")
parser.add_argument("infile", type=str, help="the ROM file to convert")
parser.add_argument("outfile", type=str, help="filename to output")
args = parser.parse_args()
with open(args.infile, "rb") as f:
data = f.read()
data = bytearray(data)
for i in range(0, len(data), 2):
data[i], data[i+1] = data[i+1], data[i]
with open(args.outfile, "wb") as f:
f.write(bytes(data))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment