Created
May 11, 2025 07:25
-
-
Save McZonk/1e643871186dc486845c1012c66592c7 to your computer and use it in GitHub Desktop.
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
import os | |
import sys | |
romName = sys.argv[1] | |
checksum = 0 | |
with open(romName, 'rb') as rom: | |
while True: | |
byte = rom.read(1) | |
if len(byte) == 0: | |
break | |
checksum += byte[0] | |
if romName.endswith('prom1.cpu'): | |
rom.seek(0x1ff8, os.SEEK_SET) | |
checksumBytes = rom.read(2) | |
for byte in checksumBytes: | |
checksum -= byte | |
checksum += 0x01fe | |
checksum %= 65536 | |
print(f'Checksum {hex(checksum)}') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment