Fixed cartridge for py3

This commit is contained in:
Rob McMullen 2017-05-07 14:03:25 -07:00
parent bddae24cb1
commit fa476b1eab
2 changed files with 10 additions and 5 deletions

View File

@ -1,4 +1,6 @@
from __future__ import absolute_import
from builtins import str
from builtins import object
from collections import defaultdict
import numpy as np
@ -146,7 +148,7 @@ class A8CartHeader(object):
if len(bytes) == 16:
values = bytes.view(dtype=self.format)[0]
if values[0] != 'CART':
if values[0] != b'CART':
raise InvalidCartHeader
self.cart_type = int(values[1])
self.crc = int(values[2])
@ -206,9 +208,9 @@ class AtariCartImage(DiskImageBase):
return str(self.header)
def read_header(self):
bytes = self.bytes[0:16]
data = self.bytes[0:16]
try:
self.header = A8CartHeader(bytes)
self.header = A8CartHeader(data)
except InvalidCartHeader:
self.header = A8CartHeader()
self.header.set_type(self.cart_type)

View File

@ -1,4 +1,7 @@
from __future__ import print_function
from __future__ import division
from builtins import object
from past.utils import old_div
from mock import *
from atrcopy import AtariCartImage, SegmentData, InvalidDiskImage
@ -10,7 +13,7 @@ class TestAtariCart(object):
def get_cart(self, k_size, cart_type):
data = np.zeros((k_size * 1024)+16, dtype=np.uint8)
data[0:4].view("|a4")[0] = 'CART'
data[0:4].view("|a4")[0] = b'CART'
data[4:8].view(">u4")[0] = cart_type
return data
@ -47,7 +50,7 @@ class TestAtariCart(object):
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) == 1 + 1 + old_div((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