def test_unbanked(self, k_size, cart_type): data = self.get_cart(k_size, cart_type) rawdata = SegmentData(data) image = AtariCartImage(rawdata, cart_type) image.parse_segments() assert len(image.segments) == 2 assert len(image.segments[0]) == 16 assert len(image.segments[1]) == k_size * 1024
def test_banked(self, k_size, main_size, banked_size, cart_type): data = self.get_cart(k_size, cart_type) rawdata = SegmentData(data) image = AtariCartImage(rawdata, cart_type) image.parse_segments() assert len(image.segments) == 1 + 1 + (k_size - main_size) //banked_size assert len(image.segments[0]) == 16 assert len(image.segments[1]) == main_size * 1024 assert len(image.segments[2]) == banked_size * 1024
def test_banked(self, k_size, main_size, banked_size, cart_type): data = self.get_cart(k_size, cart_type) rawdata = SegmentData(data) image = AtariCartImage(rawdata, cart_type) image.parse_segments() assert len( image.segments) == 1 + 1 + (k_size - main_size) // banked_size assert len(image.segments[0]) == 16 assert len(image.segments[1]) == main_size * 1024 assert len(image.segments[2]) == banked_size * 1024
def test_bad(self): k_size = 32 # check for error because invalid data in cart image itself data = self.get_cart(k_size, 1337) rawdata = SegmentData(data) with pytest.raises(errors.InvalidDiskImage): image = AtariCartImage(rawdata, 1337) with pytest.raises(errors.InvalidDiskImage): image = AtariCartImage(rawdata, 12) # check for error with valid cart image, but invalid cart type supplied # to the image parser data = self.get_cart(k_size, 12) rawdata = SegmentData(data) with pytest.raises(errors.InvalidDiskImage): image = AtariCartImage(rawdata, 1337)
def test_unbanked(self): carts = [ (8, 1), (16, 2), (8, 21), (2, 57), (4, 58), (4, 59), ] for k_size, cart_type in carts: data = self.get_cart(k_size, cart_type) rawdata = SegmentData(data) image = AtariCartImage(rawdata, cart_type) image.parse_segments() assert len(image.segments) == 2 assert len(image.segments[0]) == 16 assert len(image.segments[1]) == k_size * 1024
def test_banked(self): carts = [ (32, 8, 8, 12), (64, 8, 8, 13), (64, 8, 8, 67), (128, 8, 8, 14), (256, 8, 8, 23), (512, 8, 8, 24), (1024, 8, 8, 25), ] for k_size, main_size, banked_size, cart_type in carts: data = self.get_cart(k_size, cart_type) rawdata = SegmentData(data) image = AtariCartImage(rawdata, cart_type) image.parse_segments() assert len(image.segments) == 1 + 1 + (k_size - main_size)/banked_size assert len(image.segments[0]) == 16 assert len(image.segments[1]) == main_size * 1024 assert len(image.segments[2]) == banked_size * 1024
def test_conversion_to_atari_cart(self, cart): cart_type = cart[0] name = cart[1] k_size = cart[2] if "Bounty" in name: return data = self.get_rom(k_size) rawdata = SegmentData(data) rom_image = RomImage(rawdata) rom_image.strict_check() rom_image.parse_segments() new_cart_image = AtariCartImage(rawdata, cart_type) new_cart_image.relaxed_check() new_cart_image.parse_segments() assert new_cart_image.header.valid s = new_cart_image.create_emulator_boot_segment() assert len(s) == len(rawdata) + new_cart_image.header.nominal_length assert s[0:4].tobytes() == b'CART' assert s[4:8].view(dtype=">u4") == cart_type