Created
September 15, 2022 05:55
-
-
Save dansanderson/f4883c1be3b65062101642ea9fa19f14 to your computer and use it in GitHub Desktop.
Identifies the version of a given MEGA65 ROM file
This file contains 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 python | |
import sys | |
PREFIX = b'\x42\x41\x53\x49\x43\x20\x36\x35\x20' | |
def main(args): | |
if len(args) != 1: | |
print('Usage: python3 whichrom.py mega65.rom') | |
return 1 | |
dat = open(args[0], 'rb').read() | |
i = dat.find(PREFIX) | |
if i == -1: | |
print( | |
f'Could not find ROM version prefix. ' | |
f'Is {args[1]} a MEGA65 ROM file?') | |
return 1 | |
i += len(PREFIX) + 1 | |
print(str(dat[i:i + 6], encoding='ascii')) | |
if __name__ == '__main__': | |
sys.exit(main(sys.argv[1:])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment