mirror of
https://github.com/robmcmullen/atrcopy.git
synced 2025-01-20 12:31:20 +00:00
Changed to floor division which works on both py2 and py3
This commit is contained in:
parent
afc59593bd
commit
8284ae23b3
@ -2,7 +2,6 @@ from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from builtins import str
|
||||
from builtins import range
|
||||
from past.utils import old_div
|
||||
from builtins import object
|
||||
import numpy as np
|
||||
|
||||
@ -366,7 +365,7 @@ class AtrHeader(BaseHeader):
|
||||
def encode(self, raw):
|
||||
values = raw.view(dtype=self.format)[0]
|
||||
values[0] = 0x296
|
||||
paragraphs = old_div(self.image_size, 16)
|
||||
paragraphs = self.image_size // 16
|
||||
parshigh, pars = divmod(paragraphs, 256*256)
|
||||
values[1] = pars
|
||||
values[2] = self.sector_size
|
||||
@ -402,7 +401,7 @@ class AtrHeader(BaseHeader):
|
||||
self.sectors_per_track = 18
|
||||
self.payload_bytes = self.sector_size - 3
|
||||
initial_bytes = self.initial_sector_size * self.num_initial_sectors
|
||||
self.max_sectors = (old_div((self.image_size - initial_bytes), self.sector_size)) + self.num_initial_sectors
|
||||
self.max_sectors = ((self.image_size - initial_bytes) // self.sector_size) + self.num_initial_sectors
|
||||
|
||||
def get_pos(self, sector):
|
||||
if not self.sector_is_valid(sector):
|
||||
@ -494,14 +493,14 @@ class AtariDosDiskImage(DiskImageBase):
|
||||
|
||||
def calc_vtoc_code(self):
|
||||
# From AA post: http://atariage.com/forums/topic/179868-mydos-vtoc-size/
|
||||
num = 1 + old_div((self.total_sectors + 80), (self.header.sector_size * 8))
|
||||
num = 1 + (self.total_sectors + 80) // (self.header.sector_size * 8)
|
||||
if self.header.sector_size == 128:
|
||||
if num == 1:
|
||||
code = 2
|
||||
else:
|
||||
if num & 1:
|
||||
num += 1
|
||||
code = (old_div((num + 1), 2)) + 2
|
||||
code = ((num + 1) // 2) + 2
|
||||
else:
|
||||
if self.total_sectors < 1024:
|
||||
code = 2
|
||||
@ -687,7 +686,7 @@ class BootDiskImage(AtariDosDiskImage):
|
||||
# before the boot sectors are finished loading
|
||||
max_ram = 0xc000
|
||||
max_size = max_ram - bload
|
||||
max_sectors = old_div(max_size, self.header.sector_size)
|
||||
max_sectors = max_size // self.header.sector_size
|
||||
if nsec > max_sectors or nsec < 1:
|
||||
raise InvalidDiskImage("Number of boot sectors out of range")
|
||||
if bload < 0x200 or bload > (0xc000 - (nsec * self.header.sector_size)):
|
||||
|
@ -4,7 +4,6 @@ from __future__ import division
|
||||
from builtins import str
|
||||
from builtins import range
|
||||
from builtins import object
|
||||
from past.utils import old_div
|
||||
import numpy as np
|
||||
|
||||
from .errors import *
|
||||
@ -63,7 +62,7 @@ class Dos33TSSector(WriteableSector):
|
||||
|
||||
|
||||
class Dos33VTOC(VTOC):
|
||||
max_tracks = old_div((256 - 0x38), 4) # 50, but kept here in case sector size changed
|
||||
max_tracks = (256 - 0x38) // 4 # 50, but kept here in case sector size changed
|
||||
max_sectors = max_tracks * 16
|
||||
vtoc_bit_reorder_index = np.tile(np.arange(15, -1, -1), max_tracks) + (np.repeat(np.arange(max_tracks), 16) * 16)
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from past.utils import old_div
|
||||
import numpy as np
|
||||
|
||||
from .errors import *
|
||||
@ -27,7 +26,7 @@ class KBootDirent(AtariDosDirent):
|
||||
else:
|
||||
self.exe_size = count
|
||||
self.exe_start = start
|
||||
self.num_sectors = old_div(count, 128) + 1
|
||||
self.num_sectors = count // 128 + 1
|
||||
|
||||
def parse_raw_dirent(self, image, bytes):
|
||||
pass
|
||||
@ -68,18 +67,18 @@ def insert_bytes(data, offset, string, color):
|
||||
s = np.fromstring(string.upper(), dtype=np.uint8) - 32 # convert to internal
|
||||
s = s | color
|
||||
count = len(s)
|
||||
tx = offset + old_div((20 - count), 2)
|
||||
tx = offset + (20 - count) // 2
|
||||
data[tx:tx+count] = s
|
||||
|
||||
|
||||
def add_xexboot_header(bytes, bootcode=None, title=b"DEMO", author=b"an atari user"):
|
||||
sec_size = 128
|
||||
xex_size = len(bytes)
|
||||
num_sectors = old_div((xex_size + sec_size - 1), sec_size)
|
||||
num_sectors = (xex_size + sec_size - 1) // sec_size
|
||||
padded_size = num_sectors * sec_size
|
||||
if xex_size < padded_size:
|
||||
bytes = np.append(bytes, np.zeros([padded_size - xex_size], dtype=np.uint8))
|
||||
paragraphs = old_div(padded_size, 16)
|
||||
paragraphs = padded_size // 16
|
||||
|
||||
if bootcode is None:
|
||||
bootcode = np.fromstring(xexboot_header, dtype=np.uint8)
|
||||
|
@ -1,7 +1,6 @@
|
||||
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
|
||||
@ -50,7 +49,7 @@ class TestAtariCart(object):
|
||||
rawdata = SegmentData(data)
|
||||
image = AtariCartImage(rawdata, cart_type)
|
||||
image.parse_segments()
|
||||
assert len(image.segments) == 1 + 1 + old_div((k_size - main_size),banked_size)
|
||||
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
|
||||
|
@ -2,7 +2,6 @@ from __future__ import print_function
|
||||
from __future__ import division
|
||||
from builtins import range
|
||||
from builtins import object
|
||||
from past.utils import old_div
|
||||
import os
|
||||
|
||||
import numpy as np
|
||||
@ -28,7 +27,7 @@ class TestKbootHeader(object):
|
||||
newatr = KBootImage(rawdata)
|
||||
image = newatr.bytes
|
||||
print(image[0:16])
|
||||
paragraphs = old_div(image_size, 16)
|
||||
paragraphs = image_size // 16
|
||||
print(newatr.header, paragraphs)
|
||||
assert int(image[2:4].view(dtype='<u2')) == paragraphs
|
||||
assert int(image[16 + 9:16 + 9 + 2].view('<u2')) == xex_size
|
||||
|
Loading…
x
Reference in New Issue
Block a user