don't calculate largest track if there are no tracks

This commit is contained in:
4am 2019-02-19 14:31:46 -05:00
parent 44c654c3be
commit 98d1763c34
3 changed files with 5 additions and 2 deletions

BIN
test/valid1.woz Normal file

Binary file not shown.

BIN
test/valid2.woz Normal file

Binary file not shown.

View File

@ -545,8 +545,11 @@ class WozWriter(WozDiskImage, WozValidator):
compatible_hardware_bitfield |= (1 << offset)
compatible_hardware_raw = to_uint16(compatible_hardware_bitfield)
required_ram_raw = to_uint16(self.info["required_ram"])
if self.tracks:
largest_bit_count = max([track.bit_count for track in self.tracks])
largest_block_count = (((largest_bit_count+7)//8)+511)//512
else:
largest_block_count = 0
largest_track_raw = to_uint16(largest_block_count)
chunk.extend(disk_sides_raw) # 1 byte, 1 or 2
chunk.extend(boot_sector_format_raw) # 1 byte, 0,1,2,3