Add ; lines in star_blazer.txt which are copied to the output before each label
authorNick Downing <nick@ndcode.org>
Sat, 13 Jul 2024 11:05:54 +0000 (21:05 +1000)
committerNick Downing <nick@ndcode.org>
Sat, 13 Jul 2024 12:14:36 +0000 (22:14 +1000)
star_blazer/draw_misc_compile.py
star_blazer/draw_misc_extract.py
star_blazer/object_compile.py
star_blazer/object_extract.py
star_blazer/shape_compile.py
star_blazer/shape_extract.py
star_blazer/star_blazer.asm.patch
star_blazer/star_blazer.txt
utils/disasm.py

index 62ce141..d598ddf 100755 (executable)
@@ -22,6 +22,8 @@ with open(addrs_txt) as fin:
       line = fin.readline()
       if len(line) == 0:
         return []
+      if line[0] == ';':
+        continue
       i = line.find('#')
       if i >= 0:
         line = line[:i]
index 8375849..8f72b46 100755 (executable)
@@ -28,6 +28,8 @@ with open(addrs_txt) as fin:
       line = fin.readline()
       if len(line) == 0:
         return []
+      if line[0] == ';':
+        continue
       i = line.find('#')
       if i >= 0:
         line = line[:i]
index 3bf27dd..1a6442c 100755 (executable)
@@ -26,6 +26,8 @@ with open(addrs_txt) as fin:
       line = fin.readline()
       if len(line) == 0:
         return []
+      if line[0] == ';':
+        continue
       i = line.find('#')
       if i >= 0:
         line = line[:i]
index e0b4eb6..c1daf0d 100755 (executable)
@@ -165,6 +165,8 @@ with open(addrs_txt) as fin:
       line = fin.readline()
       if len(line) == 0:
         return []
+      if line[0] == ';':
+        continue
       i = line.find('#')
       if i >= 0:
         line = line[:i]
index 78b8b06..eedcf93 100755 (executable)
@@ -23,6 +23,8 @@ with open(addrs_txt) as fin:
       line = fin.readline()
       if len(line) == 0:
         return []
+      if line[0] == ';':
+        continue
       i = line.find('#')
       if i >= 0:
         line = line[:i]
index fcc2f5c..481cc96 100755 (executable)
@@ -28,6 +28,8 @@ with open(addrs_txt) as fin:
       line = fin.readline()
       if len(line) == 0:
         return []
+      if line[0] == ';':
+        continue
       i = line.find('#')
       if i >= 0:
         line = line[:i]
index df3a033..b441e1f 100644 (file)
@@ -1,5 +1,5 @@
---- star_blazer.asm0   2022-06-28 11:55:37.439914841 +1000
-+++ star_blazer.asm    2022-06-28 12:09:26.663904584 +1000
+--- star_blazer.asm0   2024-07-13 21:00:10.594972588 +1000
++++ star_blazer.asm    2024-07-13 21:04:39.607915464 +1000
 @@ -1,3 +1,10 @@
 +UNREACHABLE = 1
 +DHGR = 0
  accumulator:
        .ds     3                       ; 0090 rw
        .ds     1                       ; 0093
-@@ -1071,7 +1117,7 @@
+@@ -1084,7 +1130,7 @@
        tsx                             ; 1095 -> 1097 -> 1098 r
        stx     *ucode_sp               ; 1097 -> 1098 -> 109a r
        ldx     *ucode_x_save_c9        ; 1098 -> 109a -> 109c r
 -      lda     object1080_y1 + 0x60,x  ; 109a -> 109c -> 109f r x=01..7f
 +      lda     object1080_state - 0x10,x ;object1080_y1 + 0x60,x       ; 109a -> 109c -> 109f r x=01..7f
        sta     *ucode_object_state     ; 109c -> 109f -> 10a1 r
+ ; alternative entry point for ucode_execute_words that comes from scoring?
  ucode_execute_words_entry:
-       ldy     #0x00                   ; 1090,109f -> 10a1 -> 10a3 r
-@@ -1098,7 +1144,7 @@
-       jsr     do_ucode_word           ; 10c6 -> 10c8 -> 106a r s=f7..f9,02
-       bne     3$                      ; 107b -> 10cb -> 10c0 r z=0
+@@ -1114,7 +1160,7 @@
+ ; returns the current value of object1080_state for the object in x
+ ; I think this might be to provide the correct flags return?
  ucode_execute_words_done:
 -      lda     object1080_y1 + 0x60,x  ; 1093,10a5,10ba,10c2,10c6 -> 10cd -> 10d0 r x=01..7f
 +      lda     object1080_state - 0x10,x ;object1080_y1 + 0x60,x       ; 1093,10a5,10ba,10c2,10c6 -> 10cd -> 10d0 r x=01..7f
        rts                             ; 10cd -> 10d0 -> 123e,143a,1615,1629,1633,1649,165b,1759 r s=f7..fd,02
  ucode_execute_fire_in_state_fn:
        beq     rts_10ec                ; 1216,123b,1260,1285 -> 10d1 -> 10d3,10ec r z=0..1
-@@ -1577,16 +1623,20 @@
+@@ -1593,16 +1639,20 @@
        bpl     loc_14c9                ; 14a0 -> 14a3 -> 14a5,14c9 r n=0..1
        iny                             ; 14a3 -> 14a5 -> 14a6 r
        bne     ucode_test_fire_all_objects_active ; 14a5 -> 14a6 -> 149b r z=0
 +.if UNREACHABLE
        beq     loc_14c9                ; 14b7 r
 +.endif
- ucode_test_object_fire:
-       cmp     #0x01                   ; 153c -> 14b9 -> 14bb r a=01..03,02
-       beq     ucode_test_fire_all_objects_active ; 14b9 -> 14bb -> 149b,14bd r z=0..1
-@@ -1610,17 +1660,21 @@
+ ; opcode is followed by null-terminated list of objects to test
+ ; note: some of these opcodes never executed in the trace
+ ; references to object1080_y1 + 0x60 should be object1080_state - 0x10
+@@ -1636,17 +1686,21 @@
        bmi     loc_14c9                ; 14d5 -> 14d8 -> 14da r n=0
        iny                             ; 14d8 -> 14da -> 14db r
        bne     ucode_test_fire_any_object_active ; 14da -> 14db -> 14d0 r z=0
  test_object_fire_in_state_f0:
        lda     object6080_fire_count - 0x60,x ; 1668 -> 14ef -> 14f2 r x=60..7f
        beq     test_object_fire_false  ; 14ef -> 14f2 -> 14f4,153f r z=0..1
-@@ -1980,10 +2034,35 @@
+@@ -2008,10 +2062,35 @@
        sta     *button_state           ; 17ce r
  rts_17d0:
        rts                             ; 17ab,17ca -> 17d0 -> 1768,176f r s=fd
        ldx     #0x01                   ; 17db r
  0$:   jsr     ROM_PREAD               ; 17dd r
        cpy     #0xff                   ; 17e0 r
-@@ -1994,7 +2073,12 @@
+@@ -2022,7 +2101,12 @@
        sta     bvar_179e               ; 17e9 r
        sta     bvar_17a3               ; 17ec r
        sta     bvar_1e0e               ; 17ef r
  
        .area   text1
  
-@@ -2062,10 +2146,12 @@
+@@ -2090,10 +2174,12 @@
        lda     *result + 1             ; 186e r
        ldy     *result + 2             ; 1870 r
        rts                             ; 1872 r
  random_init:
        lda     *random_seed            ; 16ae -> 187a -> 187c r
        ora     #0x01                   ; 187a -> 187c -> 187e r
-@@ -2224,16 +2310,30 @@
+@@ -2252,16 +2338,30 @@
        ldx     #>HIRES_SCREEN          ; 199b -> 199d -> 199f r
        stx     *video_line_ptr + 1     ; 199d -> 199f -> 19a1 r
        tay                             ; 199f -> 19a1 -> 19a2 r
        rts                             ; 19b5 -> 19b8 -> 1713 r s=fd
  video_clear_rectangle:
        ldx     *clip_y0                ; 1064 -> 19b9 -> 19bb r
-@@ -2241,8 +2341,20 @@
+@@ -2269,8 +2369,20 @@
        sta     *video_line_ptr         ; 19bb -> 19be -> 19c0 r
        lda     video_line_table_hi - 0x20,x ; 19be -> 19c0 -> 19c3 r x=28..cf
        sta     *video_line_ptr + 1     ; 19c0 -> 19c3 -> 19c5 r
  1$:   sta     (*video_line_ptr),y     ; 19c7,19ce -> 19c9 -> 19cb r y=6c..93
        iny                             ; 19c9 -> 19cb -> 19cc r
        cpy     *clip_x1                ; 19cb -> 19cc -> 19ce r y=6d..94
-@@ -2291,6 +2403,7 @@
+@@ -2319,6 +2431,7 @@
        sta     object1080_y0 - 0x10,x  ; 1a1b -> 1a1e -> 1a21 r x=10..7f
        adc     #0x01                   ; 1a1e -> 1a21 -> 1a23 r c=0..1 d=0
        sta     object1080_y1 - 0x10,x  ; 1a21 -> 1a23 -> 1a26 r x=10..7f
        rts                             ; 1a23 -> 1a26 -> 1076,1179,1602 r s=f1..f9,02
  pixel_data_table_left:
        .db     0x83                    ; 1a27 r
-@@ -2373,14 +2486,17 @@
+@@ -2401,14 +2514,17 @@
        lda     object1080_onscreen_shape_ptr_hi - 0x10,x ; 1aa5 -> 1aa7 -> 1aaa r x=20..4f
        ora     (*video_line_ptr),y     ; 1aa7 -> 1aaa -> 1aac r y=6d..93,02
        sta     (*video_line_ptr),y     ; 1aaa -> 1aac -> 1aae r y=6d..93,02
        lda     object1080_y0 - 0x10,x  ; 1ab9 -> 1abb -> 1abe r x=14..77
        cmp     object1080_y1 - 0x10,x  ; 1abb -> 1abe -> 1ac1 r a=11..d4 x=14..77
        bcs     rts_1aae                ; 1abe -> 1ac1 -> 1ac3 r c=0
-@@ -2433,7 +2549,12 @@
+@@ -2461,7 +2577,12 @@
        stx     *x_save                 ; 1b32 -> 1b35 -> 1b37 r
        lda     *draw_y                 ; 1b35 -> 1b37 -> 1b39 r
        cmp     *clip_y0                ; 1b37 -> 1b39 -> 1b3b r a=11..d4
        lda     *clip_y1                ; 1b3b -> 1b3d -> 1b3f r
        cmp     *draw_y1                ; 1b3d -> 1b3f -> 1b41 r a=d0
        bcc     8$                      ; 1b3f -> 1b41 -> 1b43,1b83 r c=0..1
-@@ -2444,16 +2565,59 @@
+@@ -2472,16 +2593,59 @@
        cmp     *draw_x1                ; 1b49 -> 1b4b -> 1b4d r a=94
        bcc     8$                      ; 1b4b -> 1b4d -> 1b4f,1b83 r c=0..1
        lda     object1080_onscreen_shape_ptr_lo - 0x10,x ; 1b4d -> 1b4f -> 1b52 r x=14..77
  6$:   .db     0xbd                    ; 1b69,1b76 -> 1b6b -> 1b6e r "lda bvar_6f9f,x" x=00..39
  7$:   .dw     0x6f9f                  ; 1b6c rw
        ora     (*video_line_ptr),y     ; 1b6b -> 1b6e -> 1b70 r y=6c..93
-@@ -2470,16 +2634,50 @@
+@@ -2498,16 +2662,50 @@
        rts                             ; 1b80 -> 1b82 -> 15cd r s=fb
  8$:   inc     object1080_onscreen_clipped - 0x10,x ; 1b3b,1b41,1b47,1b4d -> 1b83 -> 1b86 r x=14..77
        lda     object1080_onscreen_shape_ptr_lo - 0x10,x ; 1b83 -> 1b86 -> 1b89 r x=14..77
  10$:  lda     *draw_y                 ; 1ba0,1bbf -> 1ba2 -> 1ba4 r
        cmp     *clip_y0                ; 1ba2 -> 1ba4 -> 1ba6 r a=11..d8
        bcc     12$                     ; 1ba4 -> 1ba6 -> 1ba8,1bbb r c=0..1
-@@ -2489,6 +2687,16 @@
+@@ -2517,6 +2715,16 @@
        bcc     12$                     ; 1bac -> 1bae -> 1bb0,1bbb r c=0..1
        cpy     *clip_x1                ; 1bae -> 1bb0 -> 1bb2 r y=6c..a4
        bcs     12$                     ; 1bb0 -> 1bb2 -> 1bb4,1bbb r c=0..1
        .db     0xbd                    ; 1bb2 -> 1bb4 -> 1bb7 r "lda 0x6fab,x" x=00..39
  11$:  .dw     0x6fab                  ; 1bb5 rw
        ora     (*video_line_ptr),y     ; 1bb4 -> 1bb7 -> 1bb9 r y=6c..93
-@@ -2502,6 +2710,7 @@
+@@ -2530,6 +2738,7 @@
        cpy     *draw_y1                ; 1bc3 -> 1bc5 -> 1bc7 r y=12..d9
        bcc     9$                      ; 1bc5 -> 1bc7 -> 1b96,1bc9 r c=0..1
        ldx     *x_save                 ; 1bc7 -> 1bc9 -> 1bcb r
        rts                             ; 1bc9 -> 1bcb -> 15cd r s=fb
  erase_pixel_object:
        lda     #0x00                   ; 1c12 -> 1bcc -> 1bce r
-@@ -2533,12 +2742,15 @@
+@@ -2561,12 +2770,15 @@
        eor     #0xff                   ; 1c03 -> 1c06 -> 1c08 r
        and     (*video_line_ptr),y     ; 1c06 -> 1c08 -> 1c0a r y=6d..93,02
        sta     (*video_line_ptr),y     ; 1c08 -> 1c0a -> 1c0c r y=6d..93,02
        lda     #0x00                   ; 1c12 -> 1c14 -> 1c16 r
        sta     object1080_onscreen - 0x10,x ; 1c14 -> 1c16 -> 1c19 r x=14..77
        lda     object1080_onscreen_x0 - 0x10,x ; 1c16 -> 1c19 -> 1c1c r x=14..77
-@@ -2553,16 +2765,61 @@
+@@ -2581,16 +2793,61 @@
        stx     *x_save                 ; 1c2d -> 1c30 -> 1c32 r
        bne     3$                      ; 1c30 -> 1c32 -> 1c34,1c6a r z=0..1
        lda     object1080_onscreen_shape_ptr_lo - 0x10,x ; 1c32 -> 1c34 -> 1c37 r x=14..77
  1$:   .db     0xbd                    ; 1c4e,1c5d -> 1c50 -> 1c53 r "lda 0x6f93,x" x=00..39
  2$:   .dw     0x6f93                  ; 1c51 rw
        eor     #0xff                   ; 1c50 -> 1c53 -> 1c55 r
-@@ -2579,16 +2836,51 @@
+@@ -2607,16 +2864,51 @@
        ldx     *x_save                 ; 1c65 -> 1c67 -> 1c69 r
        rts                             ; 1c67 -> 1c69 -> 1076,16a8 r s=f3..f9,02
  3$:   lda     object1080_onscreen_shape_ptr_lo - 0x10,x ; 1c32 -> 1c6a -> 1c6d r x=14..77
  5$:   lda     *draw_y                 ; 1c84,1ca5 -> 1c86 -> 1c88 r
        cmp     *clip_y0                ; 1c86 -> 1c88 -> 1c8a r a=11..d8
        bcc     7$                      ; 1c88 -> 1c8a -> 1c8c,1ca1 r c=0..1
-@@ -2598,6 +2890,17 @@
+@@ -2626,6 +2918,17 @@
        bcc     7$                      ; 1c90 -> 1c92 -> 1c94,1ca1 r c=0..1
        cpy     *clip_x1                ; 1c92 -> 1c94 -> 1c96 r y=6c..a4
        bcs     7$                      ; 1c94 -> 1c96 -> 1c98,1ca1 r c=0..1
        .db     0xbd                    ; 1c96 -> 1c98 -> 1c9b r "lda 0x6fab,x" x=00..39
  6$:   .dw     0x6fab                  ; 1c99 rw
        eor     #0xff                   ; 1c98 -> 1c9b -> 1c9d r
-@@ -2617,9 +2920,24 @@
+@@ -2645,9 +2948,24 @@
        stx     *x_save                 ; 1db0 -> 1cb2 -> 1cb4 r
        tay                             ; 1cb2 -> 1cb4 -> 1cb5 r
        lda     shape_data_ptr_lo,y     ; 1cb4 -> 1cb5 -> 1cb8 r y=16..ff
        lda     shape_width_bytes,y     ; 1cbe -> 1cc1 -> 1cc4 r y=16..ff
        clc                             ; 1cc1 -> 1cc4 -> 1cc5 r
        adc     *draw_x0                ; 1cc4 -> 1cc5 -> 1cc7 r c=0 d=0
-@@ -2627,6 +2945,11 @@
+@@ -2655,6 +2973,11 @@
        lda     *draw_x0                ; 1cc7 -> 1cc9 -> 1ccb r
        lsr     a                       ; 1cc9 -> 1ccb -> 1ccc r
        bcc     0$                      ; 1ccb -> 1ccc -> 1cce,1cd4 r c=0..1
        lda     *draw_misc_mask         ; 1ccc -> 1cce -> 1cd0 r
        eor     *draw_misc_mask_xor     ; 1cce -> 1cd0 -> 1cd2 r
        sta     *draw_misc_mask         ; 1cd0 -> 1cd2 -> 1cd4 r
-@@ -2642,9 +2965,56 @@
+@@ -2670,9 +2993,56 @@
        lda     video_line_table_hi,y   ; 1ce5 -> 1ce7 -> 1cea r y=00..bc
        adc     #0x00                   ; 1ce7 -> 1cea -> 1cec r c=0..1 d=0
        sta     *video_line_ptr + 1     ; 1cea -> 1cec -> 1cee r
  2$:   lda     *draw_y                 ; 1cf2,1d0f -> 1cf4 -> 1cf6 r
        cmp     #0xc0                   ; 1cf4 -> 1cf6 -> 1cf8 r a=00..bc
        bcs     4$                      ; 1cf6 -> 1cf8 -> 1cfa r c=0
-@@ -2664,7 +3034,12 @@
+@@ -2692,7 +3062,12 @@
        inc     *draw_y                 ; 1d0f -> 1d11 -> 1d13 r
        ldy     *draw_y                 ; 1d11 -> 1d13 -> 1d15 r
        cpy     *draw_y1                ; 1d13 -> 1d15 -> 1d17 r y=01..bd
        ldx     *x_save                 ; 1d17 -> 1d19 -> 1d1b r
        rts                             ; 1d19 -> 1d1b -> 1db3 r s=ec..f5
  draw_misc_from_table:
-@@ -2677,7 +3052,7 @@
+@@ -2705,7 +3080,7 @@
        asl     a                       ; 1d23 -> 1d24 -> 1d25 r
        sta     *draw_misc_ptr          ; 1d24 -> 1d25 -> 1d27 r
        lda     #0x00                   ; 1d25 -> 1d27 -> 1d29 r
        sta     *draw_misc_ptr + 1      ; 1d29 -> 1d2b -> 1d2d r
        lda     *half_dimension         ; 1d2b -> 1d2d -> 1d2f r
        lsr     a                       ; 1d2d -> 1d2f -> 1d30 r
-@@ -2686,10 +3061,20 @@
+@@ -2714,10 +3089,20 @@
        lsr     a                       ; 1d31 -> 1d32 -> 1d33 r
        lsr     a                       ; 1d32 -> 1d33 -> 1d34 r
        tay                             ; 1d33 -> 1d34 -> 1d35 r
        lda     *half_dimension         ; 1d3d -> 1d3f -> 1d41 r
        and     #0x1f                   ; 1d3f -> 1d41 -> 1d43 r
        cmp     #0x08                   ; 1d41 -> 1d43 -> 1d45 r a=00..1f
-@@ -2707,6 +3092,14 @@
+@@ -2735,6 +3120,14 @@
        iny                             ; 1d57 -> 1d59 -> 1d5a r
  1$:   lda     (*draw_misc_ptr),y      ; 1d59,1d69 -> 1d5a -> 1d5c r y=03..0c
        beq     2$                      ; 1d5a -> 1d5c -> 1d5e,1d61 r z=0..1
        jsr     do_draw_misc            ; 1d5c -> 1d5e -> 1da6 r s=f3..f9,02
  2$:   iny                             ; 1d5c,1db5 -> 1d61 -> 1d62 r
        cpy     #0x10                   ; 1d61 -> 1d62 -> 1d64 r y=04..0d
-@@ -2762,6 +3155,84 @@
+@@ -2790,6 +3183,84 @@
        ldy     *draw_misc_y_save       ; 1d1b -> 1db3 -> 1db5 r
  rts_1db5:
        rts                             ; 1da1,1db3 -> 1db5 -> 1076,1d61,1d7d,1d82,1d87 r s=ee..f7
  draw_misc_mask_table:
        .db     0xff                    ; 1db6 r
        .db     0x00                    ; 1db7 r
-@@ -2772,14 +3243,15 @@
+@@ -2800,14 +3271,15 @@
        .db     0xd5                    ; 1dbc r
        .db     0xff                    ; 1dbd r
  draw_misc_mask_xor_table:
  
        .area   text2
  
-@@ -3083,6 +3555,15 @@
+@@ -3111,6 +3583,15 @@
  
        .area   data2
  
  shape_data_ptr_lo:
        .db     <bvar_5d01              ; 4000 r
        .db     <bvar_5d01              ; 4001 r
-@@ -4625,6 +5106,12 @@
+@@ -4653,6 +5134,12 @@
        .db     0x01                    ; 45fd r
        .db     0x01                    ; 45fe r
        .db     0x04                    ; 45ff r
 +.if DRAW_MISC
 +.include "draw_misc_table.inc"
 +.else
+ ; 0x20 entries of 0x10 bytes
  draw_misc_table:
        .db     0x01                    ; 4600 r
-       .db     0x07                    ; 4601 r
-@@ -5138,9 +5625,168 @@
+@@ -5167,9 +5654,168 @@
        .db     0x00                    ; 47fd r
        .db     0x00                    ; 47fe r
        .db     0x00                    ; 47ff r
  score_var_4800:
        .db     0x03                    ; 4800 r
  score_table_4801:
-@@ -9271,9 +9917,19 @@
+@@ -9308,9 +9954,19 @@
        .dw     0x0000                  ; 5bba r
        .dw     bvar_9d1d               ; 5bbc r
        .dw     0x0000                  ; 5bbe r
        .db     0x5c                    ; 5c00
        .db     0x02                    ; 5c01
        .db     0x00                    ; 5c02
-@@ -21699,9 +22355,15 @@
+@@ -21736,9 +22392,15 @@
        .db     0xe0                    ; 8c05
        .db     0x83                    ; 8c06
        .db     0x9e                    ; 8c07
  bvar_8e00:
        .db     0x30                    ; 8e00 r
        .db     0x0f                    ; 8e01
-@@ -26272,6 +26934,13 @@
+@@ -26309,6 +26971,13 @@
        .db     0x7c                    ; 9dea
        .db     0x98                    ; 9deb
        .db     0x00                    ; 9dec
index de7f32e..8d4ab80 100644 (file)
@@ -32,15 +32,15 @@ items
 0x008d,0x0001,draw_misc_mask,byte
 0x008e,0x0001,draw_misc_mask_temp,byte
 0x008f,0x0001,draw_misc_mask_xor,byte
-# 24-bit register, repurposed for divide routine as
-#   accumulator: divisor
-#   accumulator + 1: remainder
+; 24-bit register, repurposed for divide routine as
+;   accumulator: divisor
+;   accumulator + 1: remainder
 0x0090,0x0003,accumulator,byte
-# 24-bit register
+; 24-bit register
 0x0094,0x0003,register,byte
-# 24-bit register, repurposed for divide routine as
-#   result: quotient
-#   result + 1: loop count
+; 24-bit register, repurposed for divide routine as
+;   result: quotient
+;   result + 1: loop count
 0x0098,0x0003,result,byte
 0x009c,0x0002,random_seed,word
 0x00a0,0x0001,current_sound,byte # is it really?
@@ -48,51 +48,52 @@ items
 0x00aa,0x0001,draw_misc_y_save,byte
 0x00ab,0x0001,draw_misc_y0,byte
 0x00ad,0x0001,draw_misc_count,byte
-# array of 8 * 4-digit numbers in BCD
-#   decimal: score/10
-#   decimal + 2: high score/10
-#   decimal + 4: spare
-#   decimal + 6: mission
-#   decimal + 8: fuel
-#   decimal + 0xa: bomb
-#   decimal + 0xc: ship left
-#   decimal + 0xe: bonus/1000
+; array of 8 * 4-digit numbers in BCD
+;   decimal: score/10
+;   decimal + 2: high score/10
+;   decimal + 4: spare
+;   decimal + 6: mission
+;   decimal + 8: fuel
+;   decimal + 0xa: bomb
+;   decimal + 0xc: ship left
+;   decimal + 0xe: bonus/1000
 0x00b0,0x0010,decimal,byte
-# index into microcode for ucode_execute_words
+; index into microcode for ucode_execute_words
 0x00c0,0x0002,ucode_ptr_c0,word
 0x00c2,0x0001,ucode_word_object,byte
 0x00c7,0x0001,ucode_object_c7,byte
 0x00c8,0x0001,sp_save,byte
 0x00c9,0x0001,ucode_x_save_c9,byte
 0x00ca,0x0001,ucode_y_save_ca,byte
-# seems to preserve a value from one of:
-#   object6080_b500 (execute_object6080_ucode_fire_in_state_f0)
-#   object6080_b520 (execute_object6080_ucode_fire_in_state_f1)
-#   object6080_b540 (execute_object6080_ucode_fire_in_state_f2)
-#   object6080_b560 (execute_object6080_ucode_fire_in_state_f3)
-# and also used as an index into ucode in ucode_execute_fire_in_state_fn
+; seems to preserve a value from one of:
+;   object6080_b500 (execute_object6080_ucode_fire_in_state_f0)
+;   object6080_b520 (execute_object6080_ucode_fire_in_state_f1)
+;   object6080_b540 (execute_object6080_ucode_fire_in_state_f2)
+;   object6080_b560 (execute_object6080_ucode_fire_in_state_f3)
+; and also used as an index into ucode in ucode_execute_fire_in_state_fn
 0x00cb,0x0001,ucode_state_save,byte
-# seems to contain value from object1080_state
-# and also used as a counter in ucode_execute_fire_in_state_fn
+; seems to contain value from object1080_state
+; and also used as a counter in ucode_execute_fire_in_state_fn
 0x00cc,0x0001,ucode_object_state,byte
 0x00cd,0x0001,ucode_sp,byte
-# index into microcode for ucode_ucode_set_object_shape
+; index into microcode for ucode_ucode_set_object_shape
 0x00d0,0x0002,ucode_ptr_d0,word # or shape_ptr?
 0x00d2,0x0002,temp,word
 0x00d4,0x0001,y_save,byte
 0x00e2,0x0001,ucode_x_save_e2,byte
 0x00e3,0x0001,ucode_y_save_e3,byte
-0x00e4,0x0002,homing_ptr,word # is it really?
-# index into microcode for ucode_collision_test, ucode_test_fire_in_state_fn
+; used by execute_object6080_ucode_homing to store base of ucode_homing table
+0x00e4,0x0002,homing_ptr,word
+; index into microcode for ucode_collision_test, ucode_test_fire_in_state_fn
 0x00e6,0x0002,ucode_ptr_e6,word
 0x00f0,0x0001,demo_mode,byte # 0xff = demo mode, 0x00 = play mode
-# 0xc0 = ctrl-c state (forces joystick control)
-# 0x80 = button pressed
-# 0x40 = ctrl-s state (unknown what this does)
-# 0x20 = pause / single step
-# 0x02 = fire by keyboard
+; 0xc0 = ctrl-c state (forces joystick control)
+; 0x80 = button pressed
+; 0x40 = ctrl-s state (unknown what this does)
+; 0x20 = pause / single step
+; 0x02 = fire by keyboard
 0x00f1,0x0001,button_state,byte
-# >= 0x80 = key waiting (uses lsr to clear it)
+; >= 0x80 = key waiting (uses lsr to clear it)
 0x00f2,0x0001,key_state,byte
 0x0200,0x0002,vec_restart,word
 0x0400,0x0070,object1080_onscreen,byte
@@ -145,38 +146,38 @@ items
 0x0d38,0x0001,maybe_copy_one_of_arr_52a0_52e0_5320_5360_to_arr_b480,code
 0x0d5e,0x0001,calculate_object_direction,code
 0x0d6c,0x0001,calculate_object_shape,code
-# example: object1080_ucode_animate_shape_4d_headquarters_radar_icbm
-#              -> implied start of section 0xf0
-#      .db     0x72 headquarters shape
-#      .db     0xf2 -> start of section 0xf2
-#      .db     0x76 icbm shape
-#      .db     0xf1 -> start of section 0xf1
-#      .db     0x73 radar0 shape
-#      .db     0x74 radar1 shape
-#      .db     0x75 radar2 shape
-#      .db     0x74 radar1 shape
-#      .db     0xf9 -> repeating, & 0xf3 for start sentinel (0xf1)
-#      .db     0x00 sentinel
-# object1080_animate_shape_index + 0x4d holds the index into above table
-# loc_0da6 does a post-increment
-# loc_0daf controls wraparound when sentinel >= 0xf0 reached
-#   loc_0dac for 0xff
-#   loc_0db9 for 0xf8..0xfe (repeating, & 0xf3 for the start sentinel)
-#     0xf0..0xf3 value is poked into object1080_state + object, and
-#     something happens when it changes, if object >= 0x60 ... then loc_0dcb
-#   loc_0dcb for 0xf0..0xf7
-#     scan the table from the beginning (except if sentinel was 0xf0)
-#       loc_0ddc when end of table is reached
-#       scan until we find the value at object1080_state + object
-#   loc_0ddc a = table index where start sentinel was found (or end sentinel)
-#     update object1080_animate_shape_index with this index (causes the
-#     wrapping to restart the animation sequence) ... resume at loc_0da6
-# note: the ucode_word routine seems implicated in launching this:
-# 0$:  ldy     object1080_state - 0x10,x
-#      bpl     2$
-#      and     #0x03
-#      ora     #0xf0
-#      jmp     [vec_calculate_object_shape]
+; example: object1080_ucode_animate_shape_4d_headquarters_radar_icbm
+;              -> implied start of section 0xf0
+;      .db     0x72 headquarters shape
+;      .db     0xf2 -> start of section 0xf2
+;      .db     0x76 icbm shape
+;      .db     0xf1 -> start of section 0xf1
+;      .db     0x73 radar0 shape
+;      .db     0x74 radar1 shape
+;      .db     0x75 radar2 shape
+;      .db     0x74 radar1 shape
+;      .db     0xf9 -> repeating, & 0xf3 for start sentinel (0xf1)
+;      .db     0x00 sentinel
+; object1080_animate_shape_index + 0x4d holds the index into above table
+; loc_0da6 does a post-increment
+; loc_0daf controls wraparound when sentinel >= 0xf0 reached
+;   loc_0dac for 0xff
+;   loc_0db9 for 0xf8..0xfe (repeating, & 0xf3 for the start sentinel)
+;     0xf0..0xf3 value is poked into object1080_state + object, and
+;     something happens when it changes, if object >= 0x60 ... then loc_0dcb
+;   loc_0dcb for 0xf0..0xf7
+;     scan the table from the beginning (except if sentinel was 0xf0)
+;       loc_0ddc when end of table is reached
+;       scan until we find the value at object1080_state + object
+;   loc_0ddc a = table index where start sentinel was found (or end sentinel)
+;     update object1080_animate_shape_index with this index (causes the
+;     wrapping to restart the animation sequence) ... resume at loc_0da6
+; note: the ucode_word routine seems implicated in launching this:
+; 0$:  ldy     object1080_state - 0x10,x
+;      bpl     2$
+;      and     #0x03
+;      ora     #0xf0
+;      jmp     [vec_calculate_object_shape]
 0x0d81,0x0001,ucode_set_object_shape,code
 0x0de5,0x0001,calculate_direction_nibble,code
 0x0ebc,0x0001,ucode_decimal_set_0,code
@@ -200,155 +201,155 @@ items
 0x0fb1,0x0001,adjust_score_for_reset_object,code
 0x0fb9,0x0001,ucode_byte,code
 0x0fdb,0x0001,go_ucode_decimal,code
-# enter with ucode_word_object = 1st byte of ucode pair, a = 2nd byte
-# these values come from do_ucode_word (I think the only external caller)
-# does ldx *ucode_word_object first, so in below, "object" refers to this
-# 1st byte:
-#   < 0x10: go to ucode_escape
-#     if 1st byte bit 0 = 1, only do the rest if demo mode (otherwise continue)
-#     if 1st byte bit 1 = 1, only do the rest if NOT demo mode (otherwise done)
-#     < 0x04: go to 2$
-#       2nd byte:
-#         < 0x20: clear demo mode, set mission from 2nd byte bits 0..3
-#         < 0x30: set demo mode, set mission from 2nd byte bits 0..3
-#         < 0xa0: vector to start game
-#         >= 0xa0: start game demo
-#     < 0x08: go to ucode_decimal, with unusual bcc -> bcc instruction
-#       2nd byte bits 4..7
-#         == 0x30: vector to update a decimal based on 2nd byte bits 0..2
-#      .dw     set_decimal_0 - 1
-#      .dw     set_decimal_0 - 1
-#      .dw     set_decimal_score_var_4b80_score_var_4b00_by_mission - 1
-#      .dw     set_decimal_1 - 1
-#      .dw     set_decimal_score_var_4880_score_var_4800 - 1
-#      .dw     set_decimal_score_var_4980_score_var_4900 - 1
-#      .dw     set_decimal_score_var_4a80_score_var_4a00 - 1
-#      .dw     set_decimal_score_var_4b80_score_var_4b00 - 1
-#         == 0x40: decimal increment
-#           2nd byte bits 0..2 are *2 and give index into decimals array
-#         == 0x50: decimal decrement
-#           2nd byte bits 0..2 are *2 and give index into decimals array
-#         == 0x70: go to 0$
-#           2nd byte bits 0..2 are *2 and give index into decimals array
-#         == 0x20: vector to draw misc from table
-#           2nd byte bits 0..2 are +1 and sent into draw_misc_from_table
-#         otherwise ignored
-#     < 0x0c: go to 6$
-#       2nd byte:
-#         < 0xe1: vector to draw_misc_from_table (title display, etc)
-#         >= 0xe1:
-#           2nd byte bit 0 = 0: vector to restart
-#           2nd byte bit 0 = 1: video clear rectangle
-#     >= 0x0c: 2nd byte is a sound channel? 01..10
-#      store 1st byte into sound_status_ab80[2nd byte - 1]
-#   >= 0x10: 1st byte is object for opcode in 2nd byte
-# 2nd byte:
-#   < 0x08: go to 0$
-#     if object is active, change its shape using 2nd byte bits 0..1
-#   < 0x0e: go to 3$
-#     vector to ucode_08_to_0e_vectors routine based on 2nd byte bits 0..2
-#      .dw     horizontal_collision_and_zero - 1
-#      .dw     vertical_collision_and_zero - 1
-#      .dw     horizontal_collision - 1
-#      .dw     vertical_collision - 1
-#      .dw     horizontal_collision_and_copy - 1
-#      .dw     vertical_collision_and_copy - 1
-#   = 0x0e: go to 1$
-#     decrement object1080_countdown_b190, returns zf=1 terminal count?
-#   != 0x0f: go to ucode_byte
-#     if bit 7 = 0, then only do the rest if the object is inactive
-#     vector to routine based on 2nd byte bits 4..6
-#      .dw     rts_0a11 - 1
-#      .dw     randomize_object_position - 1
-#      .dw     copy_object_position - 1
-#      .dw     randomize_object_position_relative - 1
-#      .dw     move_object_pos_pos - 1
-#      .dw     move_object_neg_pos - 1
-#      .dw     move_object_neg_neg - 1
-#      .dw     move_object_pos_neg - 1
-#     vector to routine based on 2nd byte bits 0..2
-#      .dw     rts_0a11 - 1
-#      .dw     randomize_object_velocity - 1
-#      .dw     copy_object_velocity - 1
-#      .dw     randomize_object_velocity_relative - 1
-#      .dw     update_object_velocity - 1
-#      .dw     update_object_velocity_rotate_90 - 1
-#      .dw     update_object_velocity_rotate_180 - 1
-#      .dw     update_object_velocity_rotate_270 - 1
-#     if bit 3 = 1, and object1080_state[x] != 0:
-#       make object active and compute bounds
-#     else
-#       reset object state
-#   = 0x0f: if object is active, make it inactive and erase it
+; enter with ucode_word_object = 1st byte of ucode pair, a = 2nd byte
+; these values come from do_ucode_word (I think the only external caller)
+; does ldx *ucode_word_object first, so in below, "object" refers to this
+; 1st byte:
+;   < 0x10: go to ucode_escape
+;     if 1st byte bit 0 = 1, only do the rest if demo mode (otherwise continue)
+;     if 1st byte bit 1 = 1, only do the rest if NOT demo mode (otherwise done)
+;     < 0x04: go to 2$
+;       2nd byte:
+;         < 0x20: clear demo mode, set mission from 2nd byte bits 0..3
+;         < 0x30: set demo mode, set mission from 2nd byte bits 0..3
+;         < 0xa0: vector to start game
+;         >= 0xa0: start game demo
+;     < 0x08: go to ucode_decimal, with unusual bcc -> bcc instruction
+;       2nd byte bits 4..7
+;         == 0x30: vector to update a decimal based on 2nd byte bits 0..2
+;      .dw     set_decimal_0 - 1
+;      .dw     set_decimal_0 - 1
+;      .dw     set_decimal_score_var_4b80_score_var_4b00_by_mission - 1
+;      .dw     set_decimal_1 - 1
+;      .dw     set_decimal_score_var_4880_score_var_4800 - 1
+;      .dw     set_decimal_score_var_4980_score_var_4900 - 1
+;      .dw     set_decimal_score_var_4a80_score_var_4a00 - 1
+;      .dw     set_decimal_score_var_4b80_score_var_4b00 - 1
+;         == 0x40: decimal increment
+;           2nd byte bits 0..2 are *2 and give index into decimals array
+;         == 0x50: decimal decrement
+;           2nd byte bits 0..2 are *2 and give index into decimals array
+;         == 0x70: go to 0$
+;           2nd byte bits 0..2 are *2 and give index into decimals array
+;         == 0x20: vector to draw misc from table
+;           2nd byte bits 0..2 are +1 and sent into draw_misc_from_table
+;         otherwise ignored
+;     < 0x0c: go to 6$
+;       2nd byte:
+;         < 0xe1: vector to draw_misc_from_table (title display, etc)
+;         >= 0xe1:
+;           2nd byte bit 0 = 0: vector to restart
+;           2nd byte bit 0 = 1: video clear rectangle
+;     >= 0x0c: 2nd byte is a sound channel? 01..10
+;      store 1st byte into sound_status_ab80[2nd byte - 1]
+;   >= 0x10: 1st byte is object for opcode in 2nd byte
+; 2nd byte:
+;   < 0x08: go to 0$
+;     if object is active, change its shape using 2nd byte bits 0..1
+;   < 0x0e: go to 3$
+;     vector to ucode_08_to_0e_vectors routine based on 2nd byte bits 0..2
+;      .dw     horizontal_collision_and_zero - 1
+;      .dw     vertical_collision_and_zero - 1
+;      .dw     horizontal_collision - 1
+;      .dw     vertical_collision - 1
+;      .dw     horizontal_collision_and_copy - 1
+;      .dw     vertical_collision_and_copy - 1
+;   = 0x0e: go to 1$
+;     decrement object1080_countdown_b190, returns zf=1 terminal count?
+;   != 0x0f: go to ucode_byte
+;     if bit 7 = 0, then only do the rest if the object is inactive
+;     vector to routine based on 2nd byte bits 4..6
+;      .dw     rts_0a11 - 1
+;      .dw     randomize_object_position - 1
+;      .dw     copy_object_position - 1
+;      .dw     randomize_object_position_relative - 1
+;      .dw     move_object_pos_pos - 1
+;      .dw     move_object_neg_pos - 1
+;      .dw     move_object_neg_neg - 1
+;      .dw     move_object_pos_neg - 1
+;     vector to routine based on 2nd byte bits 0..2
+;      .dw     rts_0a11 - 1
+;      .dw     randomize_object_velocity - 1
+;      .dw     copy_object_velocity - 1
+;      .dw     randomize_object_velocity_relative - 1
+;      .dw     update_object_velocity - 1
+;      .dw     update_object_velocity_rotate_90 - 1
+;      .dw     update_object_velocity_rotate_180 - 1
+;      .dw     update_object_velocity_rotate_270 - 1
+;     if bit 3 = 1, and object1080_state[x] != 0:
+;       make object active and compute bounds
+;     else
+;       reset object state
+;   = 0x0f: if object is active, make it inactive and erase it
 0x0fdd,0x0001,ucode_word,code
 0x1009,0x0001,vector_to_ucode,code
 0x1016,0x0001,ucode_escape,code
-# enter with a = value for ucode_word_object, ucode_ptr_c0 setup,
-# y = index into table at ucode_ptr_c0 (it will be incremented twice)
-# routine loads first byte from the ucode table and calls ucode_word
+; enter with a = value for ucode_word_object, ucode_ptr_c0 setup,
+; y = index into table at ucode_ptr_c0 (it will be incremented twice)
+; routine loads first byte from the ucode table and calls ucode_word
 0x106a,0x0001,do_ucode_word,code
 0x107c,0x0001,decimal_zero,code
-# zf=1 -> go to loc_10cd
-# otherwise load ucode_object_state from object1080_state,
-# and enter a loop scanning ucode table at ucode_ptr_c0 from index 0,
-# when value read from ucode table is:
-#   == 0x00: go to loc_10cd
-#   >= 0xf0: see if it's the start sentinel in ucode_object_state
-#     if it's not then keep skipping 2 locations until end of table or found
-#     when found, skip 2 locations and check for more commands (0 is end of
-#     table, >= 0xf0 is a different section, otherwise execute + zf=0 repeat
-#   otherwise execute it via do_ucode_word, and check zf return because
-#   zf=1 means terminate the loop at loc_10cd otherwise keep executing loop
-# in summary there seems to be a global section at the start of the table that
-# is always executed, and a specific section to execute based on current state
+; zf=1 -> go to loc_10cd
+; otherwise load ucode_object_state from object1080_state,
+; and enter a loop scanning ucode table at ucode_ptr_c0 from index 0,
+; when value read from ucode table is:
+;   == 0x00: go to loc_10cd
+;   >= 0xf0: see if it's the start sentinel in ucode_object_state
+;     if it's not then keep skipping 2 locations until end of table or found
+;     when found, skip 2 locations and check for more commands (0 is end of
+;     table, >= 0xf0 is a different section, otherwise execute + zf=0 repeat
+;   otherwise execute it via do_ucode_word, and check zf return because
+;   zf=1 means terminate the loop at loc_10cd otherwise keep executing loop
+; in summary there seems to be a global section at the start of the table that
+; is always executed, and a specific section to execute based on current state
 0x1093,0x0001,ucode_execute_words,code
 0x109c,0x0001,,code_ign # bug? spans ae80 and aef0 tables, don't merge them
-# alternative entry point for ucode_execute_words that comes from scoring?
+; alternative entry point for ucode_execute_words that comes from scoring?
 0x10a1,0x0001,ucode_execute_words_entry,code
-# returns the current value of object1080_state for the object in x
-# I think this might be to provide the correct flags return?
+; returns the current value of object1080_state for the object in x
+; I think this might be to provide the correct flags return?
 0x10cd,0x0001,ucode_execute_words_done,code_ign # bug? spans ae80 and aef0 tables, don't merge them
-# it seems to read values from table at ucode_ptr_c0 with some complicated
-# indirection (value from table = index to use for next read from table?) and
-# it executes them by calling do_ucode_word, this may read adjacent value?
-# ucode_object_state = counter that gets decremented to 0
-# bvar_00cb = start index in table, and is advanced by the routine
+; it seems to read values from table at ucode_ptr_c0 with some complicated
+; indirection (value from table = index to use for next read from table?) and
+; it executes them by calling do_ucode_word, this may read adjacent value?
+; ucode_object_state = counter that gets decremented to 0
+; bvar_00cb = start index in table, and is advanced by the routine
 0x10d1,0x0001,ucode_execute_fire_in_state_fn,code
 0x10ed,0x0001,adjust_score,code
 0x1153,0x0001,reset_decimals,code
 0x1160,0x0001,reset_object_state,code
 0x11a7,0x0001,make_object_active_and_compute_bounds,code
 0x11b2,0x0001,make_object_inactive_and_erase,code
-# called from update_object, when:
-#   object1080_countdown_b120 or object1080_countdown_b190 expires
+; called from update_object, when:
+;   object1080_countdown_b120 or object1080_countdown_b190 expires
 0x11bd,0x0001,execute_object1080_ucode_countdown,code
-# called from update_object, when:
-#   test_object_collision returns cf=1
+; called from update_object, when:
+;   test_object_collision returns cf=1
 0x11cd,0x0001,execute_object1080_ucode_collision,code
-# called from update_object for objects >= 40, when:
-#   object1080_x_hi outside [object4080_x_hi_min, object4080_x_hi_max)
+; called from update_object for objects >= 40, when:
+;   object1080_x_hi outside [object4080_x_hi_min, object4080_x_hi_max)
 0x11dd,0x0001,execute_object4080_ucode_x_outside,code
-# called from update_object for objects >= 40, when:
-#   object1080_y_hi outside [object4080_y_hi_min, object4080_y_hi_max)
+; called from update_object for objects >= 40, when:
+;   object1080_y_hi outside [object4080_y_hi_min, object4080_y_hi_max)
 0x11ed,0x0001,execute_object4080_ucode_y_outside,code
-# called from update_object for objects >= 60, when:
-#   object1080_state == 0xf0
-#   and then test_object_fire_in_state_f0 returns cf=1
+; called from update_object for objects >= 60, when:
+;   object1080_state == 0xf0
+;   and then test_object_fire_in_state_f0 returns cf=1
 0x11fd,0x0001,execute_object6080_ucode_fire_in_state_f0,code
-# called from update_object for objects >= 60, when:
-#   object1080_state == 0xf1
-#   and then test_object_fire_in_state_f1 returns cf=1
+; called from update_object for objects >= 60, when:
+;   object1080_state == 0xf1
+;   and then test_object_fire_in_state_f1 returns cf=1
 0x1222,0x0001,execute_object6080_ucode_fire_in_state_f1,code
-# called from update_object for objects >= 60, when:
-#   object1080_state == 0xf2
-#   and then test_object_fire_in_state_f2 returns cf=1
+; called from update_object for objects >= 60, when:
+;   object1080_state == 0xf2
+;   and then test_object_fire_in_state_f2 returns cf=1
 0x1247,0x0001,execute_object6080_ucode_fire_in_state_f2,code
-# called from update_object for objects >= 60, when:
-#   object1080_state == 0xf3
-#   and then test_object_fire_in_state_f3 returns cf=1
+; called from update_object for objects >= 60, when:
+;   object1080_state == 0xf3
+;   and then test_object_fire_in_state_f3 returns cf=1
 0x126c,0x0001,execute_object6080_ucode_fire_in_state_f3,code
-# called from accelerate_object_towards_another
-# seems to have a chance to intervene in the homing logic
+; called from accelerate_object_towards_another
+; seems to have a chance to intervene in the homing logic
 0x1291,0x0001,execute_object6080_ucode_homing,code
 0x12e1,0x0001,accelerate_object_towards_another,code
 0x133f,0x0001,sign_extend_a_to_ya_asl_by_4,code
@@ -358,16 +359,16 @@ items
 0x1447,0x0001,accelerate_object_anyhow,code
 0x149b,0x0001,ucode_test_fire_all_objects_active,code
 0x14aa,0x0001,ucode_test_fire_all_objects_inactive,code
-# opcode is followed by null-terminated list of objects to test
-# note: some of these opcodes never executed in the trace
-# references to object1080_y1 + 0x60 should be object1080_state - 0x10
-# 0x01 loc_149b test that all objects are active (object1080_state >= 0x80)
-# 0x02 loc_14aa test that all objects are inactive (object1080_state < 0x80)
-# 0x03 loc_14d0 test that any object is active (object1080_state >= 0x80)
-# 0x04 loc_14e0 test that any object is inactive (object1080_state >= 0x80)
-# otherwise fall into:
-# loc_14c9: cf=0
-# loc_14ca: return cf (cf=1 from cmp equality), a=object1080_state (for zf?)
+; opcode is followed by null-terminated list of objects to test
+; note: some of these opcodes never executed in the trace
+; references to object1080_y1 + 0x60 should be object1080_state - 0x10
+; 0x01 loc_149b test that all objects are active (object1080_state >= 0x80)
+; 0x02 loc_14aa test that all objects are inactive (object1080_state < 0x80)
+; 0x03 loc_14d0 test that any object is active (object1080_state >= 0x80)
+; 0x04 loc_14e0 test that any object is inactive (object1080_state >= 0x80)
+; otherwise fall into:
+; loc_14c9: cf=0
+; loc_14ca: return cf (cf=1 from cmp equality), a=object1080_state (for zf?)
 0x14b9,0x0001,ucode_test_object_fire,code
 0x14d0,0x0001,ucode_test_fire_any_object_active,code
 0x14e0,0x0001,ucode_test_fire_any_object_inactive,code
@@ -384,9 +385,9 @@ items
 0x15ee,0x0001,update_object,code
 0x15ff,0x0001,update_object_entry,code
 0x16ae,0x0001,all_init,code
-# takes mission number in x, does not set mission if x = 0
+; takes mission number in x, does not set mission if x = 0
 0x16f1,0x0001,clear_demo_set_mission,code
-# takes mission number in x, does not set mission if x = 0
+; takes mission number in x, does not set mission if x = 0
 0x16f7,0x0001,set_demo_set_mission,code
 0x16fd,0x0001,inc_mission,code
 0x1708,0x0001,init_game,code,,10000 # suppress local for patch
@@ -438,7 +439,7 @@ items
 0x1da6,0x0001,do_draw_misc,code
 0x1db6,0x0008,draw_misc_mask_table,byte
 0x1dbe,0x0008,draw_misc_mask_xor_table,byte
-# returns cf=1 if firing (random for demo mode)
+; returns cf=1 if firing (random for demo mode)
 0x1e03,0x0001,test_player_fire,code
 0x2000,0x2000,HIRES_SCREEN,byte
 0x4000,0x0100,shape_data_ptr_lo,byte,byte
@@ -447,7 +448,7 @@ items
 0x4300,0x0100,shape_height,byte
 0x4400,0x0100,shape_size_bytes,byte
 0x4500,0x0100,shape_width,byte
-# 0x20 entries of 0x10 bytes
+; 0x20 entries of 0x10 bytes
 0x4600,0x0200,draw_misc_table,byte,,10000 # suppress local for patch
 0x4800,0x0001,score_var_4800,byte
 0x4801,0x000f,score_table_4801,byte
@@ -463,10 +464,10 @@ items
 0x4990,0x0070,object1080_animate1,byte
 0x4a00,0x0001,score_var_4a00,byte
 0x4a01,0x000f,score_table_4a01,byte
-# 0x4a10 spare
+; 0x4a10 spare
 0x4a80,0x0001,score_var_4a80,byte
 0x4a81,0x000f,score_table_4a81,byte
-# 0x4a90 spare
+; 0x4a90 spare
 0x4b00,0x0001,score_var_4b00,byte
 0x4b01,0x000f,score_table_4b01,byte
 0x4b10,0x0070,object1080_4b10,byte
@@ -477,9 +478,9 @@ items
 0x4c70,0x0070,object1080_velocity_x_random_range,byte
 0x4ce0,0x0070,object1080_velocity_y_random_base,byte
 0x4d50,0x0070,object1080_velocity_y_random_range,byte
-# 0x4dc0 spare
+; 0x4dc0 spare
 0x4ed0,0x0030,object4070_4ed0,byte # might be bigger
-# 0x4f00 spare
+; 0x4f00 spare
 0x4f40,0x0040,object4080_4f40,byte
 0x4f80,0x0040,object4080_x_random_base,byte
 0x4fc0,0x0040,object4080_x_random_range,byte
@@ -496,18 +497,18 @@ items
 0x52a0,0x0030,object5080_difference_52a0,byte
 0x52d0,0x0030,object5080_difference_52d0,byte
 0x5300,0x0020,object6080_fire_count_init_in_state_f0,byte
-# used from execute_object6080_ucode_fire_in_state_f0
+; used from execute_object6080_ucode_fire_in_state_f0
 0x5320,0x0020,object6080_5320,byte
 0x5340,0x0020,object6080_fire_count_init_in_state_f1,byte
-# used from execute_object6080_ucode_fire_in_state_f1
+; used from execute_object6080_ucode_fire_in_state_f1
 0x5360,0x0020,object6080_5360,byte
 0x5380,0x0020,object6080_fire_count_init_in_state_f2,byte
-# used from execute_object6080_ucode_fire_in_state_f2
+; used from execute_object6080_ucode_fire_in_state_f2
 0x53a0,0x0020,object6080_53a0,byte
 0x53c0,0x0020,object6080_fire_count_init_in_state_f3,byte
-# used from execute_object6080_ucode_fire_in_state_f2
+; used from execute_object6080_ucode_fire_in_state_f2
 0x53e0,0x0020,object6080_53e0,byte
-# the partitioning below is approximate and just tries to cover everything
+; the partitioning below is approximate and just tries to cover everything
 0x5400,0x0020,,word
 0x5420,0x00e0,object1080_ucode_animate_shape_ptr,word
 0x5500,0x0020,object0010_ucode_init_or_zero_ptr,word
@@ -529,17 +530,17 @@ items
 0x5b00,0x0040,object6080_ucode_fire_in_state_f2_ptr,word
 0x5b40,0x0040,object6080_ucode_test_fire_in_state_f3_ptr,word
 0x5b80,0x0040,object6080_ucode_fire_in_state_f3_ptr,word
-# 0x5bc0 padding
-# 0x5c00 shape data
-# 0x8c08 padding
-# 0x8e00 ucode data
-# 0x9ded end of image
+; 0x5bc0 padding
+; 0x5c00 shape data
+; 0x8c08 padding
+; 0x8e00 ucode data
+; 0x9ded end of image
 0xa800,0x0001,x_table_times2_div7_plus_5b,byte
 0xa900,0x0001,x_table_times2_mod7_minus_03,byte
 0xaa00,0x0001,video_line_table_lo,byte
 0xaac0,0x0001,video_line_table_hi,byte
 0xab80,0x0001,sound_status_ab80,byte
-# ab90?
+; ab90?
 0xaba0,0x0001,sound_status_aba0,byte
 0xabb0,0x0001,sound_status_abb0,byte
 0xabc0,0x0001,sound_status_abc0,byte
@@ -551,8 +552,8 @@ items
 0xada0,0x0070,object1080_x1,byte
 0xae10,0x0070,object1080_y0,byte
 0xae80,0x0070,object1080_y1,byte
-# often a value 0xf0..0xf3 to identify relevant section in ucode table,
-# but I think it has other purposes too (bit 7 may mean object is active?)
+; often a value 0xf0..0xf3 to identify relevant section in ucode table,
+; but I think it has other purposes too (bit 7 may mean object is active?)
 0xaef0,0x0070,object1080_state,byte
 0xaf60,0x0070,object1080_velocity_x_hi,byte
 0xafd0,0x0070,object1080_velocity_y_hi,byte
@@ -566,26 +567,26 @@ items
 0xb350,0x0070,object1080_animate_shape_index,byte
 0xb3c0,0x0030,object5080_abs_x_difference,byte
 0xb3f0,0x0030,object5080_abs_y_difference,byte
-# accelerate_object_somehow
-# used as a countdown for whether x should be accelerated by +/- 0x4c
+; accelerate_object_somehow
+; used as a countdown for whether x should be accelerated by +/- 0x4c
 0xb420,0x0030,object5080_abs_difference_b420,byte
-# accelerate_object_somehow
-# used as a countdown for whether y should be accelerated by +/- 0x40
+; accelerate_object_somehow
+; used as a countdown for whether y should be accelerated by +/- 0x40
 0xb450,0x0030,object5080_abs_difference_b450,byte
-# accelerate_object_anyhow
-# used as a countdown for whether x should be accelerated by calculated value
+; accelerate_object_anyhow
+; used as a countdown for whether x should be accelerated by calculated value
 0xb480,0x0030,object5080_abs_difference_b480,byte
-# accelerate_object_anyhow
-# used as a countdown for whether y should be accelerated by calculated value
+; accelerate_object_anyhow
+; used as a countdown for whether y should be accelerated by calculated value
 0xb4b0,0x0030,object5080_abs_difference_b4b0,byte
 0xb4e0,0x0020,object6080_fire_count,byte
-# used from execute_object6080_ucode_fire_in_state_f0
+; used from execute_object6080_ucode_fire_in_state_f0
 0xb500,0x0020,object6080_b500,byte
-# used from execute_object6080_ucode_fire_in_state_f1
+; used from execute_object6080_ucode_fire_in_state_f1
 0xb520,0x0020,object6080_b520,byte
-# used from execute_object6080_ucode_fire_in_state_f2
+; used from execute_object6080_ucode_fire_in_state_f2
 0xb540,0x0020,object6080_b540,byte
-# used from execute_object6080_ucode_fire_in_state_f3
+; used from execute_object6080_ucode_fire_in_state_f3
 0xb560,0x0020,object6080_b560,byte
 0xc000,0x0001,HW_KBD,byte
 0xc010,0x0001,HW_KBDSTRB,byte
index 76b49b1..62cc46e 100755 (executable)
@@ -118,10 +118,11 @@ if trace_txt is not None:
       trace_regs[pc1] = r
 
 class AreaInfo:
-  def __init__(self, size, name, _type):
+  def __init__(self, size, name, _type, comment):
     self.size = size
     self.name = name
     self.type = _type
+    self.comment = comment
 
 # extra_types contains pointed-to type(s)
 class ItemInfo:
@@ -133,7 +134,8 @@ class ItemInfo:
     extra_types,
     local_label,
     writeable,
-    mate
+    mate,
+    comment
   ):
     self.size = size
     self.name = name
@@ -142,6 +144,7 @@ class ItemInfo:
     self.local_label = local_label
     self.writeable = writeable
     self.mate = mate
+    self.comment = comment
 
 print('reading addrs')
 area_addr = []
@@ -149,11 +152,15 @@ area_info = []
 item_addr = []
 item_info = []
 with open(addrs_txt) as fin:
+  comment = []
   def get_line():
     while True:
       line = fin.readline()
       if len(line) == 0:
         return []
+      if line[0] == ';':
+        comment.append(line)
+        continue
       i = line.find('#')
       if i >= 0:
         line = line[:i]
@@ -169,6 +176,7 @@ with open(addrs_txt) as fin:
     print(section)
 
     if section == 'areas':
+      comment = []
       fields = get_line()
       while len(fields) >= 2:
         assert len(fields) == 4
@@ -182,12 +190,14 @@ with open(addrs_txt) as fin:
             addr >= area_addr[-1] + area_info[-1].size
         )
         area_addr.append(addr)
-        area_info.append(AreaInfo(size, name, _type))
+        area_info.append(AreaInfo(size, name, _type, ''.join(comment)))
 
+        comment = []
         fields = get_line()
       continue
 
     if section == 'items':
+      comment = []
       fields = get_line()
       while len(fields) >= 2:
         assert len(fields) >= 4
@@ -224,9 +234,12 @@ with open(addrs_txt) as fin:
             extra_types,
             local_label,
             writeable,
-            mate
+            mate,
+            ''.join(comment)
           )
         )
+
+        comment = []
         fields = get_line()
       continue
 
@@ -348,7 +361,8 @@ def add_item(
     extra_types,
     local_label,
     writeable,
-    (0, 0) # mate -- has to be re-detected after merging items
+    (0, 0), # mate -- has to be re-detected after merging items
+    '' # comment
   )
 
   # code items should only ever be the opcode
@@ -900,7 +914,7 @@ while modified:
           if label[0] < 'A':
             label = label[1:] # strip numeric priority indicator
           addr = item_addr[item]
-          line =  f'{label:s} = 0x{addr:04x}'
+          line = f'{label:s} = 0x{addr:04x}'
           comment = f'; {addr_chain(addr):s}'
           x = len(line)
           if x >= 40:
@@ -910,7 +924,7 @@ while modified:
               line += '\t'
               x = (x + 8) & ~7
           fout.write(
-            f'{line:s}{comment:s}\n'
+            f'{item_info[item].comment:s}{line:s}{comment:s}\n'
           )
           need_blank = 1
         item += 1
@@ -922,7 +936,7 @@ while modified:
     area = 0
     while area < len(area_addr):
       area_end = area_addr[area] + area_info[area].size
-      fout.write(f'\t.area\t{area_info[area].name:s}\n\n')
+      fout.write(f'{area_info[area].comment:s}\t.area\t{area_info[area].name:s}\n\n')
       need_blank = 0
       local_defs.clear()
       local_refs.clear()
@@ -952,10 +966,10 @@ while modified:
               if label[0] < 'A':
                 label = label[1:] # strip numeric priority indicator
             if len(label) < 7:
-              fout.write(label + ':')
+              fout.write(item_info[item].comment + label + ':')
               need_blank = 2
             else:
-              fout.write(label + ':\n')
+              fout.write(item_info[item].comment + label + ':\n')
               need_blank = 1
 
           if area_info[area].type == AREA_UNINIT: