Revert to the distribution version of asxv5pxx v5.50, modify /utils/a2_pack.py to...
authorNick Downing <nick@ndcode.org>
Thu, 18 Jul 2024 08:57:17 +0000 (18:57 +1000)
committerNick Downing <nick@ndcode.org>
Thu, 18 Jul 2024 08:57:17 +0000 (18:57 +1000)
asxv5pxx
star_blazer/Makefile
star_blazer/star_blazer.asm.patch
utils/a2_pack.py

index b6cfa1a..146cfaf 160000 (submodule)
--- a/asxv5pxx
+++ b/asxv5pxx
@@ -1 +1 @@
-Subproject commit b6cfa1adfc8d900586fe745d34eeb347f827358c
+Subproject commit 146cfafffdede23ec7c8e13bd9b21f83f7f59353
index bd30e14..9fd5f80 100644 (file)
@@ -24,7 +24,7 @@ star_blazer.dsk: ../util/bootable.dsk star_blazer_pack_rev.a2bin
 #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 \
@@ -39,7 +39,7 @@ star_blazer.dsk: ../util/bootable.dsk star_blazer_pack_rev.a2bin
 #-a data5=0x9100 \
 #-a udata1=0xab00 \
 #-a text2=0xb880 \
-#-a data6=0x15c00 \
+#-a data6=0x5c00 \
 #-i+$@ $<
 
 # HGR
@@ -47,7 +47,7 @@ star_blazer_pack_rev.a2bin: \
 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 \
@@ -78,7 +78,7 @@ object_defs.inc \
 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
index d3aa2d9..0d494b2 100644 (file)
@@ -1,5 +1,5 @@
---- star_blazer.asm0   2024-07-18 15:50:40.764029819 +1000
-+++ star_blazer.asm    2024-07-18 17:11:18.945116204 +1000
+--- star_blazer.asm0   2024-07-18 17:12:06.417563470 +1000
++++ star_blazer.asm    2024-07-18 18:22:11.609439822 +1000
 @@ -1,3 +1,10 @@
 +UNREACHABLE = 1
 +DHGR = 0
  bvar_8e00:
        .db     0x30                    ; 8e00 r
        .db     0x0f                    ; 8e01
-@@ -26633,6 +27309,13 @@
+@@ -26633,6 +27309,14 @@
        .db     0x7c                    ; 9dea
        .db     0x98                    ; 9deb
        .db     0x00                    ; 9dec
 +.endif
 +
 +.if DHGR
-+      .area   data6
++      .bank   aux_mem (fsfx=_aux_mem)
++      .area   data6 (bank=aux_mem)
 +
 +.include "../shape/dhgr_pixel_shape_data_aux.inc"
 +.endif
index d5a9785..2d0976d 100755 (executable)
@@ -40,18 +40,31 @@ MAX_LEN = (1 << LEN_BITS1) + 1 # length codes are 2..MAX_LEN
 # 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)
@@ -61,19 +74,11 @@ out_a2bin = sys.argv[4]
 
 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:
@@ -253,7 +258,14 @@ def lzss_pack(dest, bin, 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:
@@ -349,7 +361,7 @@ ordinary_bank = 0
 # 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:
@@ -396,7 +408,7 @@ for i in range(0, len(segments), 2):
     # 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
@@ -488,7 +500,7 @@ for i in range(0, len(segments), 2):
   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(
@@ -797,7 +809,7 @@ else:
 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: