mrhappyasthma / Sega-Genesis-Checksum-Utility

A simple command line utility to verify (or correct) Sega Genesis ROM checksums.
16 stars 4 forks source link

Rare failure in read_byte_as_int #2

Open ParzivalWolfram opened 2 months ago

ParzivalWolfram commented 2 months ago

With some ROMs, it's possible for read_byte_as_int to fail as such:

Traceback (most recent call last):
  File "/tmp/sega_genesis_checksum_utility.py", line 192, in <module>
    main()
  File "/tmp/sega_genesis_checksum_utility.py", line 40, in main
    computed_checksum = compute_checksum(genesis_file)
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/sega_genesis_checksum_utility.py", line 171, in compute_checksum
    word = read_word_as_int(open_file)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/sega_genesis_checksum_utility.py", line 101, in read_word_as_int
    low_bits = read_byte_as_int(open_file)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/sega_genesis_checksum_utility.py", line 88, in read_byte_as_int
    return ord(open_file.read(1))
           ^^^^^^^^^^^^^^^^^^^^^^
TypeError: ord() expected a character, but string of length 0 found
mrhappyasthma commented 2 months ago

Do you have example rom names to check?

ParzivalWolfram commented 2 months ago

The only ROM in the No-Intro set that is affected by this is "Desert Demolition (USA, Europe) (Beta) (06.12.1994).md" but the problem also crops up on multiple ROM hacks. From what I can see, it only happens on ROMs with an odd number of bytes, as you're not double-checking if there are actually two more bytes to read. If memory serves, the missing byte should be treated as "\x00".