Rename labels in the disassembly to reflect latest understanding
authorNick Downing <nick@ndcode.org>
Sun, 26 Jun 2022 01:09:34 +0000 (11:09 +1000)
committerNick Downing <nick@ndcode.org>
Tue, 28 Jun 2022 03:21:38 +0000 (13:21 +1000)
disasm/star_blazer.asm.patch
disasm/star_blazer.txt

index 42520b2..7c21edb 100644 (file)
@@ -1,5 +1,5 @@
---- star_blazer.asm0   2022-06-26 00:00:24.179412175 +1000
-+++ star_blazer.asm    2022-06-26 00:02:51.759410350 +1000
+--- star_blazer.asm0   2022-06-26 11:07:42.795984293 +1000
++++ star_blazer.asm    2022-06-26 11:09:09.991983215 +1000
 @@ -1,3 +1,10 @@
 +UNREACHABLE = 1
 +DHGR = 0
        stx     *ucode_sp               ; 1097 -> 1098 -> 109a r
        ldx     *ucode_x_save_c9        ; 1098 -> 109a -> 109c r
 -      lda     0xaee0,x                ; 109a -> 109c -> 109f r x=01..7f
-+      lda     object1080_start_sentinel - 0x10,x ;0xaee0,x            ; 109a -> 109c -> 109f r x=01..7f
-       sta     *ucode_start_sentinel   ; 109c -> 109f -> 10a1 r
- ucode_execute_1093_entry:
++      lda     object1080_state - 0x10,x ;0xaee0,x             ; 109a -> 109c -> 109f r x=01..7f
+       sta     *ucode_object_state     ; 109c -> 109f -> 10a1 r
+ ucode_execute_words_entry:
        ldy     #0x00                   ; 1090,109f -> 10a1 -> 10a3 r
 @@ -1098,7 +1144,7 @@
-       jsr     do_ucode_pair           ; 10c6 -> 10c8 -> 106a r s=f7..f9,02
+       jsr     do_ucode_word           ; 10c6 -> 10c8 -> 106a r s=f7..f9,02
        bne     3$                      ; 107b -> 10cb -> 10c0 r z=0
- ucode_execute_1093_done:
+ ucode_execute_words_done:
 -      lda     0xaee0,x                ; 1093,10a5,10ba,10c2,10c6 -> 10cd -> 10d0 r x=01..7f
-+      lda     object1080_start_sentinel - 0x10,x ;0xaee0,x            ; 1093,10a5,10ba,10c2,10c6 -> 10cd -> 10d0 r x=01..7f
++      lda     object1080_state - 0x10,x ;0xaee0,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_10d1:
+ ucode_execute_fire_in_state_fn:
        beq     rts_10ec                ; 1216,123b,1260,1285 -> 10d1 -> 10d3,10ec r z=0..1
 @@ -1980,10 +2026,35 @@
        sta     *button_state           ; 17ce r
index 36e4d98..87ece1e 100644 (file)
@@ -58,8 +58,9 @@ items
 #   decimal + 0xc: ship left
 #   decimal + 0xe: bonus/1000
 0x00b0,0x0010,decimal,byte
+# index into microcode for ucode_execute_words
 0x00c0,0x0002,ucode_ptr_c0,word
-0x00c2,0x0001,ucode_pair_object,byte
+0x00c2,0x0001,ucode_word_object,byte
 0x00c7,0x0001,ucode_object_c7,byte
 0x00c8,0x0001,sp_save,byte
 0x00c9,0x0001,ucode_x_save_c9,byte
@@ -69,18 +70,20 @@ items
 #   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_10d1
+# and also used as an index into ucode in ucode_execute_fire_in_state_fn
 0x00cb,0x0001,ucode_state_save,byte
-# may contain a value from object1080_ucode_start_sentinel (basically
-# the current state of the object) and also seems to be used as a counter
-0x00cc,0x0001,ucode_start_sentinel,byte
+# 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
 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
 0x00e6,0x0002,ucode_ptr_e6,word
 0x00f0,0x0001,demo_mode,byte # 0xff = demo mode, 0x00 = play mode
 # 0xc0 = ctrl-c state (forces joystick control)
@@ -100,7 +103,6 @@ items
 0x0680,0x0070,object1080_onscreen_shape_ptr_hi,byte
 0x0700,0x0070,object1080_onscreen_y0,byte
 0x0780,0x0070,object1080_onscreen_y1,byte
-0x09fd,0x0001,,code # entry point
 0x0a00,0x0001,sign_extend_a_to_ya,code
 0x0a08,0x0001,abs_a,code
 0x0a0c,0x0001,neg_a,code
@@ -160,47 +162,47 @@ items
 # 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_start_sentinel + object, and
+#     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_start_sentinel + object
+#       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_pair routine seems implicated in launching this:
-# 0$:  ldy     object1080_start_sentinel - 0x10,x
+# 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,set_object_shape,code
+0x0d81,0x0001,ucode_set_object_shape,code
 0x0de5,0x0001,calculate_direction_nibble,code
-0x0ebc,0x0001,set_decimal_0,code
-0x0ec1,0x0001,set_decimal_score_var_4b80_score_var_4b00_by_mission,code
-0x0ece,0x0001,set_decimal_1,code
-0x0ed4,0x0001,set_decimal_score_var_4880_score_var_4800,code
-0x0edc,0x0001,set_decimal_score_var_4980_score_var_4900,code
-0x0ee4,0x0001,set_decimal_score_var_4a80_score_var_4a00,code
-0x0eec,0x0001,set_decimal_score_var_4b80_score_var_4b00,code
-0x0ef2,0x0001,set_decimal_save,code
-0x0ef7,0x0010,set_decimal_vectors,word,code_m1
-0x0f07,0x0010,bits_4_to_6_vectors,word,code_m1
-0x0f17,0x0010,bits_0_to_2_vectors,word,code_m1
-0x0f27,0x000c,ucode_08_to_0e_vectors,word,code_m1
-0x0f33,0x0001,vector_on_bits_4_to_6,code
-0x0f46,0x0001,vector_on_bits_0_to_2,code
-0x0f57,0x0001,decimal_inc,code
-0x0f66,0x0001,decimal_dec,code
-0x0f83,0x0001,vector_to_set_decimal,code
+0x0ebc,0x0001,ucode_decimal_set_0,code
+0x0ec1,0x0001,ucode_decimal_set_score_var_4b80_score_var_4b00_by_mission,code
+0x0ece,0x0001,ucode_decimal_set_1,code
+0x0ed4,0x0001,ucode_decimal_set_score_var_4880_score_var_4800,code
+0x0edc,0x0001,ucode_decimal_set_score_var_4980_score_var_4900,code
+0x0ee4,0x0001,ucode_decimal_set_score_var_4a80_score_var_4a00,code
+0x0eec,0x0001,ucode_decimal_set_score_var_4b80_score_var_4b00,code
+0x0ef2,0x0001,ucode_decimal_set_save,code
+0x0ef7,0x0010,ucode_decimal_set_vectors,word,code_m1
+0x0f07,0x0010,ucode_update_bits_4_to_6_vectors,word,code_m1
+0x0f17,0x0010,ucode_update_bits_0_to_2_vectors,word,code_m1
+0x0f27,0x000c,ucode_byte_vectors,word,code_m1
+0x0f33,0x0001,vector_on_ucode_update_bits_4_to_6,code
+0x0f46,0x0001,vector_on_ucode_update_bits_0_to_2,code
+0x0f57,0x0001,ucode_decimal_inc,code
+0x0f66,0x0001,ucode_decimal_dec,code
+0x0f83,0x0001,vector_to_ucode_decimal_set,code
 0x0f8d,0x0001,ucode_decimal,code
 0x0fb1,0x0001,adjust_score_for_reset_object,code
 0x0fb9,0x0001,ucode_byte,code
 0x0fdb,0x0001,go_ucode_decimal,code
-# enter with ucode_pair_object = 1st byte of ucode pair, a = 2nd byte
-# these values come from do_ucode_pair (I think the only external caller)
-# does ldx *ucode_pair_object first, so in below, "object" refers to this
+# 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)
@@ -273,45 +275,45 @@ items
 #      .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_start_sentinel[x] != 0:
+#     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_pair,code
+0x0fdd,0x0001,ucode_word,code
 0x1009,0x0001,vector_to_ucode,code
 0x1016,0x0001,ucode_escape,code
-# enter with a = value for ucode_pair_object, ucode_ptr_c0 setup,
+# 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_pair
-0x106a,0x0001,do_ucode_pair,code
+# 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_start_sentinel from object1080_start_sentinel,
+# 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_start_sentinel
+#   >= 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_pair, and check zf return because
+#   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_1093,code
+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_1093 that comes from scoring?
-0x10a1,0x0001,ucode_execute_1093_entry,code
-# returns the current value of object1080_start_sentinel for the object in x
+# 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?
-0x10cd,0x0001,ucode_execute_1093_done,code_ign # bug? spans ae80 and aef0 tables, don't merge them
+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_pair, this may read adjacent value?
-# ucode_start_sentinel = counter that gets decremented to 0
+# 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_10d1,code
+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
@@ -330,19 +332,19 @@ items
 #   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_start_sentinel == 0xf0
+#   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_start_sentinel == 0xf1
+#   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_start_sentinel == 0xf2
+#   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_start_sentinel == 0xf3
+#   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
@@ -532,10 +534,9 @@ items
 0xada0,0x0070,object1080_x1,byte
 0xae10,0x0070,object1080_y0,byte
 0xae80,0x0070,object1080_y1,byte
-# current state of object
 # 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_start_sentinel,byte
+0xaef0,0x0070,object1080_state,byte
 0xaf60,0x0070,object1080_velocity_x_hi,byte
 0xafd0,0x0070,object1080_velocity_y_hi,byte
 0xb040,0x0070,object1080_velocity_x_lo,byte