#star_blazer.ihx \
#../loader/lzss_unpack_rev_aux_mem.bin \
#../loader/star_blazer_pack_rev.a2bin
-# ../utils/a2_pack.py ${LOAD_ADDR} ../loader/lzss_unpack_rev_aux_mem.bin $< $@
+# ../utils/a2_pack.py --entry_point 0x`sed -ne 's/^:00\(....\)01..$$/\1/p' star_blazer.ihx` --aux_mem star_blazer_aux_mem.ihx ${LOAD_ADDR} ../loader/lzss_unpack_rev_aux_mem.bin $< $@
# -diff -q ../loader/star_blazer_pack_rev.a2bin $@
#star_blazer.ihx: star_blazer.rel
# ${ASLINK} -nmu \
#-a data5=0x9100 \
#-a udata1=0xab00 \
#-a text2=0xb880 \
-#-a data6=0x15c00 \
+#-a data6=0x5c00 \
#-i+$@ $<
# HGR
star_blazer.ihx \
../loader/lzss_unpack_rev.bin \
../loader/star_blazer_pack_rev.a2bin
- ../utils/a2_pack.py ${LOAD_ADDR} ../loader/lzss_unpack_rev.bin $< $@
+ ../utils/a2_pack.py --entry_point 0x`sed -ne 's/^:00\(....\)01..$$/\1/p' star_blazer.ihx` ${LOAD_ADDR} ../loader/lzss_unpack_rev.bin $< $@
-diff -q ../loader/star_blazer_pack_rev.a2bin $@
star_blazer.ihx: star_blazer.rel
${ASLINK} -nmu \
object_index.inc \
object_data.inc \
draw_misc_table.inc
- ${AS6500} -3lo+$@ $<
+ ${AS6500} -lo+$@ $<
shape_index_pixel.inc shape_data_pixel.inc: star_blazer.txt shape_pixel.json
./shape_compile.py $^ shape_index_pixel.inc shape_data_pixel.inc
# but the restriction is that end of the decompressor can be no higher
# than the start of DOS at 0x9600, in turn limiting the uncompressed size
+# intelhex cannot understand the 16-bit ihx files created by aslink, which have
+# the entry point encoded as the address field of the "end of file" (01) record
+# and in these cases we use sed to extract it and pass it in with --entry_point
+
rev = True
+entry_point = None
+aux_mem = None
while len(sys.argv) >= 2:
if sys.argv[1] == '--rev':
rev = True
+ del sys.argv[1]
elif sys.argv[1] == '--fwd':
rev = False
+ del sys.argv[1]
+ elif sys.argv[1] == '--entry_point':
+ entry_point = int(sys.argv[2], 0)
+ del sys.argv[1:3]
+ elif sys.argv[1] == '--aux_mem':
+ aux_mem = sys.argv[2]
+ del sys.argv[1:3]
else:
break
- del sys.argv[1]
if len(sys.argv) < 5:
print(
- f'usage: {sys.argv[0]:s} [--rev|--fwd] (load|end)_addr lzss_unpack_(rev|fwd)(_aux_mem).bin in.ihx out.a2bin'
+ f'usage: {sys.argv[0]:s} [--rev|--fwd] [--entry_point 0xNNNN] [--aux_mem aux_in.ihx] (load|end)_addr lzss_unpack_(rev|fwd)(_aux_mem).bin in.ihx out.a2bin'
)
sys.exit(EXIT_FAILURE)
load_or_end_addr = int(sys.argv[1], 0)
with open(lzss_unpack_bin, 'rb') as fin:
lzss_unpack = list(fin.read())
-if rev:
- if len(lzss_unpack) == 0x9c:
- aux_mem = False
- elif len(lzss_unpack) == 0xa3:
- aux_mem = True
- else:
- assert False
-elif len(lzss_unpack) == 0x96:
- aux_mem = False
-elif len(lzss_unpack) == 0x9d:
- aux_mem = True
-else:
- assert False
+assert len(lzss_unpack) == (
+ (0x9c if aux_mem is None else 0xa3)
+if rev else
+ (0x96 if aux_mem is None else 0x9d)
+)
def lzss_pack(dest, bin, rev):
if rev:
return lzss
intelhex = IntelHex(in_ihx)
-entry_point = intelhex.start_addr['EIP']
+if entry_point is None:
+ entry_point = intelhex.start_addr['EIP']
+if aux_mem is not None:
+ # for now, emulate the old modified aslink which created a unified ihx file
+ intelhex_aux_mem = IntelHex(aux_mem)
+ for start, end in intelhex_aux_mem.segments():
+ for i in range(start, end):
+ intelhex[i + 0x10000] = intelhex_aux_mem[i]
segments = [j for i in intelhex.segments() for j in i]
# create separate segments for the separate memory areas:
# the lzss_unpack_(rev|fwd)_aux_mem routine needs to be patched accordingly
# the rev routine defaults to bank 1 since this is normally unpacked first
# the fwd routine defaults to bank 0 since this is normally unpacked first
-lzss_unpack_bank = int(rev and aux_mem)
+lzss_unpack_bank = int(rev and aux_mem is not None)
# language card can be in unknown state or known state
# to place in known state, sta 0xc080 | one of below values:
# there is a compressed segment
# the aux mem decompressor must be run from the stack
# this allows it to use hw_rdcardram without clobbering itself
- if aux_mem:
+ if aux_mem is not None:
addr0 = 0x100
addr1 = 0x100 + len(lzss_unpack)
data = lzss_unpack
else:
if len(data) > 0x100 and bank != lzss_unpack_bank:
lzss_unpack_bank = bank
- assert aux_mem and lzss_unpack[-0x11:-0xe] == [
+ assert aux_mem is not None and lzss_unpack[-0x11:-0xe] == [
0x8d, 0x02 | rev, 0xc0 # sta hw_rd(main|card)ram
]
section_loader.fixups.extend(
for report_type, addr0, addr1, addr2, addr3 in report:
text = (
f'[0x{addr0:05x}, 0x{addr1:05x})'
- if aux_mem else
+ if aux_mem is not None else
f'[0x{addr0:04x}, 0x{addr1:04x})'
)
if report_type >= REPORT_TYPE_UNCOMPRESSED: