Changed to my own bootloader rather than kboot

This commit is contained in:
Rob McMullen 2016-05-05 17:44:20 -07:00
parent eaca5e166a
commit 6d2f483f40
3 changed files with 38 additions and 22 deletions

View File

@ -10,7 +10,7 @@ except ImportError:
from errors import *
from ataridos import AtariDosDiskImage, AtariDosFile, get_xex
from diskimages import AtrHeader, BootDiskImage
from kboot import KBootImage, add_kboot_header
from kboot import KBootImage, add_xexboot_header
from segments import SegmentData, SegmentSaver, DefaultSegment, EmptySegment, ObjSegment, RawSectorsSegment, user_bit_mask, match_bit_mask, comment_bit_mask, data_bit_mask, selected_bit_mask, diff_bit_mask, not_user_bit_mask
from spartados import SpartaDosDiskImage
from utils import to_numpy

View File

@ -55,24 +55,26 @@ class KBootImage(DiskImageBase):
raw = self.rawdata[start:end]
return XexSegment(raw, 0, 0, start, end, name="KBoot Executable")
kboot_header = '\x96\x020\x13\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x07\x14\x07L\x14\x07\xff\x97\x00\x00\xa9F\x8d\xc6\x02\xd0\xfe\xa0\x00\xa9k\x91X \xd9\x07\xb0\xee \xc4\x07\xadz\x08\rv\x08\xd0\xe3\xa5\x80\x8d\xe0\x02\xa5\x81\x8d\xe1\x02\xa9\x00\x8d\xe2\x02\x8d\xe3\x02 \xeb\x07\xb0\xcc\xa0\x00\x91\x80\xa5\x80\xc5\x82\xd0\x06\xa5\x81\xc5\x83\xf0\x08\xe6\x80\xd0\x02\xe6\x81\xd0\xe3\xadv\x08\xd0\xaf\xad\xe2\x02\x8dp\x07\r\xe3\x02\xf0\x0e\xad\xe3\x02\x8dq\x07 \xff\xff\xadz\x08\xd0\x13\xa9\x00\x8d\xe2\x02\x8d\xe3\x02 \xae\x07\xadz\x08\xd0\x03L<\x07\xa9\x00\x85\x80\x85\x81\x85\x82\x85\x83\xad\xe0\x02\x85\n\x85\x0c\xad\xe1\x02\x85\x0b\x85\r\xa9\x01\x85\t\xa9\x00\x8dD\x02l\xe0\x02 \xeb\x07\x85\x80 \xeb\x07\x85\x81\xa5\x80\xc9\xff\xd0\x10\xa5\x81\xc9\xff\xd0\n \xeb\x07\x85\x80 \xeb\x07\x85\x81 \xeb\x07\x85\x82 \xeb\x07\x85\x83` \xeb\x07\xc9\xff\xd0\t \xeb\x07\xc9\xff\xd0\x02\x18`8`\xad\t\x07\r\n\x07\r\x0b\x07\xf0y\xacy\x08\x10P\xeew\x08\xd0\x03\xeex\x08\xa91\x8d\x00\x03\xa9\x01\x8d\x01\x03\xa9R\x8d\x02\x03\xa9@\x8d\x03\x03\xa9\x80\x8d\x04\x03\xa9\x08\x8d\x05\x03\xa9\x1f\x8d\x06\x03\xa9\x80\x8d\x08\x03\xa9\x00\x8d\t\x03\xadw\x08\x8d\n\x03\xadx\x08\x8d\x0b\x03 Y\xe4\xad\x03\x03\xc9\x02\xb0"\xa0\x00\x8cy\x08\xb9\x80\x08\xaa\xad\t\x07\xd0\x0b\xad\n\x07\xd0\x03\xce\x0b\x07\xce\n\x07\xce\t\x07\xeey\x08\x8a\x18`\xa0\x01\x8cv\x088`\xa0\x01\x8cz\x088`\x00\x03\x00\x80\x00\x00\x00\x00\x00\x00'
xexboot_header = '\x00\x03\x00\x07\r\x07L\r\x07\xff\xff\x00\x00\xa0\x00\x8c\t\x03\x8c\x04\x03\x8cD\x02\x8c\xe2\x02\x8c\xe3\x02\xc8\x84\t\x8c\x01\x03\xce\x06\x03\xa91\x8d\x00\x03\xa9R\x8d\x02\x03\xa9\x80\x8d\x08\x03\xa9\x01\x8d\x05\x03\xa9\xdd\x8d0\x02\xa9\x07\x8d1\x02\xa9\x00\xaa\x8d\x0b\x03\xa9\x04\x8d\n\x03 \xb6\x07\xca \x9f\x07\x85C \x9f\x07\x85D%C\xc9\xff\xf0\xf0 \x9f\x07\x85E \x9f\x07\x85F \x9f\x07\x91C\xe6C\xd0\x02\xe6D\xa5E\xc5C\xa5F\xe5D\xb0\xeb\xad\xe2\x02\r\xe3\x02\xf0\xc9\x86\x19 \x9c\x07\xa6\x19\xa0\x00\x8c\xe2\x02\x8c\xe3\x02\xf0\xb8l\xe2\x02\xad\t\x07\xd0\x0b\xad\n\x07\xd0\x03l\xe0\x02\xce\n\x07\xce\t\x07\xe0\x80\x90"\xa9@\x8d\x03\x03 Y\xe4\x10\x06\xce\x01\x07\xd0\xf1\x00\xee\n\x03\xd0\x03\xee\x0b\x03\xad\n\x03\x8d\x19\xd0\xa0\x00\xa2\x00\xbd\x00\x01\xe8`pppppF\xf2\x07p\x07ppp\x06p\x06p\x06A\xdd\x07\x00\x00\x00\x00\x00,/!$).\'\x0e\x0e\x0e\x00\x00\x00\x00\x00\xea\xf5\xed\xf0\xed\xe1\xee\x00\xec\xe5\xf6\xe5\xec\x00\xf4\xe5\xf3\xf4\xe5\xf2\x00\x00\x00\x00\x00\x00\x00&2/-\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00playermissileNcom\x00\x00\x00\x00ataripodcastNcom\x00\x00'
def add_kboot_header(bytes):
def add_xexboot_header(bytes):
sec_size = 128
size = len(bytes)
num_sectors = (size + sec_size - 1) / sec_size
xex_size = len(bytes)
num_sectors = (xex_size + sec_size - 1) / sec_size
padded_size = num_sectors * sec_size
if size < padded_size:
bytes = np.append(bytes, np.zeros([padded_size - size], dtype=np.uint8))
if xex_size < padded_size:
bytes = np.append(bytes, np.zeros([padded_size - xex_size], dtype=np.uint8))
paragraphs = padded_size / 16
print size, num_sectors, paragraphs
header = np.fromstring(kboot_header, dtype=np.uint8)
image = np.append(header, bytes)
print image
words = image.view(dtype='<u2')
print words
words[1] = paragraphs
print words
words = image[16 + 9:16 + 9 + 2].view('<u2')
words[0] = size
print xex_size, num_sectors, paragraphs, padded_size
bootcode = np.fromstring(xexboot_header, dtype=np.uint8)
bootsize = np.alen(bootcode)
v = bootcode[9:11].view(dtype="<u2")
v[0] = xex_size
print bootcode[0:16]
bootsectors = np.zeros([384], dtype=np.uint8)
bootsectors[0:bootsize] = bootcode
image = np.append(bootsectors, bytes)
print np.alen(image)
return image

View File

@ -2,7 +2,7 @@ import os
import numpy as np
from atrcopy import KBootImage, add_kboot_header
from atrcopy import SegmentData, KBootImage, add_xexboot_header
class TestKbootHeader(object):
@ -10,10 +10,24 @@ class TestKbootHeader(object):
pass
def check_size(self, data):
size = np.alen(data)
image = add_kboot_header(data)
assert int(image[2:4].view(dtype='<u2')) == ((size + 127) / 128) * 128 / 16
assert int(image[16 + 9:16 + 9 + 2].view('<u2')) == size
xex_size = len(data)
bytes = add_xexboot_header(data)
rawdata = SegmentData(bytes)
size = len(rawdata)
atr = KBootImage(rawdata)
atr.rebuild_header()
header_data = atr.header.to_array()
print header_data
newdata = np.append(header_data, atr.bytes)
newrawdata = SegmentData(newdata)
atr = KBootImage(newrawdata)
atr.rebuild_header()
image = atr.bytes
print image[0:16]
paragraphs = size / 16
print atr.header, paragraphs
assert int(image[2:4].view(dtype='<u2')) == paragraphs
assert int(image[16 + 9:16 + 9 + 2].view('<u2')) == xex_size
return image
def test_simple(self):