Starting to analyze alien structures
authorNick Downing <nick@ndcode.org>
Wed, 29 Jun 2022 13:21:09 +0000 (23:21 +1000)
committerNick Downing <nick@ndcode.org>
Wed, 29 Jun 2022 13:21:09 +0000 (23:21 +1000)
galaxian/galaxian.txt

index 2e34af0..5d2b5db 100644 (file)
@@ -30,7 +30,10 @@ items
 # lo byte of (shift count * 0x80) + shape
 # also y coordinate temporary storage
 0x0017,0x0001,draw_temp,byte
-# saves value of ships before increment
+# used for calculating object bounds
+# also saves value of ships before increment
+# and holds quotient during div_a_by_7 routine
+# and used as general temp (loop count, etc)
 0x0018,0x0001,score_temp,byte
 0x001f,0x0001,gal_bvar_001f,byte
 0x0020,0x0001,draw_x_save,byte
@@ -63,7 +66,7 @@ items
 0x0062,0x0001,gal_bvar_0062,byte
 0x0063,0x0001,gal_bvar_0063,byte
 0x0064,0x0001,gal_bvar_0064,byte
-0x0067,0x0001,gal_bvar_0067,byte
+0x0067,0x0001,ship_x,byte
 0x0068,0x0001,gal_bvar_0068,byte
 # ships in 2-digit BCD
 0x0069,0x0001,ships,byte
@@ -93,6 +96,13 @@ items
 0x0080,0x0001,gal_bvar_0080,byte
 0x0081,0x0001,gal_bvar_0081,byte
 0x0085,0x0001,gal_bvar_0085,byte
+# stores bounding rectangle
+# object_(xy)(01): for alien
+# object_(xy)(01) + 1: for ship
+0x0086,0x0002,object_y0,byte
+0x0088,0x0002,object_y1,byte
+0x008a,0x0002,object_x0,byte
+0x008c,0x0002,object_x1,byte
 0x008e,0x0001,gal_bvar_008e,byte
 # saves x reg during calculation
 0x0091,0x0001,score_x_save,byte
@@ -100,11 +110,10 @@ items
 # sizes have not been examined yet
 0x00a9,0x0001,gal_barr_00a9,byte
 0x00b1,0x0001,gal_barr_00b1,byte
-0x00c0,0x0001,gal_barr_00c0,byte
 # bits 0 and 7 seem to be used for something
 # there seem to be aliens 0x01 (maybe 0x00) to 0x12
 # or maybe entry 0 is used for currently processing alien
-0x00c1,0x0012,alien_status,byte
+0x00c0,0x0040,alien_status,byte
 0x2000,0x0028,VIDEO_LINE_00,byte
 0x2028,0x0028,VIDEO_LINE_40,byte
 0x2050,0x0028,VIDEO_LINE_80,byte
@@ -312,6 +321,7 @@ items
 0x486e,0x0001,shell_y_velocity,byte
 0x4870,0x0001,shell_x_velocity_fraction,byte
 0x4872,0x0001,missile_y_velocity,byte
+0x4876,0x0001,ship_y,byte
 0x4880,0x0001,gal_bvar_4880,byte
 0x4882,0x0001,gal_bvar_4882,byte
 0x4884,0x0001,gal_bvar_4884,byte
@@ -358,19 +368,26 @@ items
 0x48de,0x0010,title_display_delay,byte
 0x48ee,0x0010,title_display_y,byte
 0x48fe,0x0010,title_display_x,byte
-# sizes have not been examined yet
-0x490f,0x0001,gal_barr_490f,byte
-0x492f,0x0001,gal_barr_492f,byte
-0x49c0,0x0013,gal_barr_49c0,byte
-0x4a01,0x0001,gal_barr_4a01,byte
-0x4a41,0x0001,gal_barr_4a41,byte
-0x4a81,0x0001,gal_barr_4a81,byte
-0x4b41,0x0001,gal_barr_4b41,byte
-0x4b81,0x0001,gal_barr_4b81,byte
-# the basic shape
-# a value from a lookup table gets added to this
-0x4c01,0x0012,alien_shapes,byte
-# sizes have not been examined yet
+# mysterious monotonic sequences
+0x490e,0x0010,monotonic_490e,byte
+0x491e,0x0010,monotonic_491e,byte
+0x492e,0x0010,monotonic_492e,byte
+# 0493e might be part of preceding or following table?
+# next one is filled with 0x46, 0x4d, 0x53 seemingly randomly
+0x493f,0x0040,barr_493f,byte
+# then zeros... padding?
+0x49c0,0x0040,alien_49c0,byte
+0x4a00,0x0040,alien_4a00,byte
+0x4a40,0x0040,alien_4a40,byte
+0x4a80,0x0040,alien_4a80,byte
+0x4ac0,0x0040,alien_4ac0,byte
+0x4b00,0x0040,alien_4b00,byte
+0x4b40,0x0040,alien_4b41,byte
+0x4b80,0x0040,alien_4b81,byte
+# I think this is used when the alien is diving
+# the basic shape, it gets adjusted for orientation
+0x4c00,0x0040,alien_shape_4c00,byte
+# these seem to be 8 bytes apart, maybe for shells?
 0x4c40,0x0001,gal_barr_4c40,byte
 0x4c48,0x0001,gal_barr_4c48,byte
 0x4c50,0x0001,gal_barr_4c50,byte
@@ -379,11 +396,18 @@ items
 0x4c68,0x0001,gal_barr_4c68,byte
 0x4c70,0x0001,gal_barr_4c70,byte
 0x4c78,0x0001,gal_barr_4c78,byte
+# identity[x] = x, used for ship x position
+0x4c80,0x0100,identity,byte
 0x4d81,0x0001,gal_barr_4d81,byte
-0x4e80,0x0001,gal_bvar_4e80,byte
-0x5280,0x0001,gal_bvar_5280,byte
-0x5281,0x0001,gal_barr_5281,byte
-0x5680,0x0001,gal_bvar_5680,byte
+# size of 0x400 as there are 4 different alien kinds
+# each has its own page of values for the alien shape
+# I think there might be separate tables for head and foot
+# all values 0..2, added to shape to select orientation
+0x4e80,0x0400,ptr_9ef1_table,byte
+# all values -4..6, ???
+0x5280,0x0400,ptr_9f18_table,byte
+# all values -0x28..0x28, ???
+0x5680,0x0400,ptr_9efe_table,byte
 0x5a80,0x1800,shape_data,byte
 0x7280,0x0380,shape_data_ptr_lo,byte
 0x7600,0x0380,shape_data_ptr_hi,byte
@@ -414,18 +438,27 @@ items
 # sizes have not been examined yet
 0x8fd9,0x0001,gal_barr_8fd9,byte
 0x8fe1,0x0001,missile_x,byte
-# sizes have not been examined yet
-0x8fe8,0x0001,gal_barr_8fe8,byte
-0x9028,0x0012,y_9028,byte
-# sizes have not been examined yet
-0x9068,0x0001,gal_barr_9068,byte
-0x90a8,0x0012,x_90a8,byte
-# sizes have not been examined yet
-0x90e9,0x0001,gal_barr_90e9,byte
-0x9129,0x0001,gal_barr_9129,byte
-0x9168,0x0001,gal_barr_9168,byte
-0x91e9,0x0001,gal_barr_91e9,byte
-0x9229,0x0001,gal_barr_9229,byte
+# a value 0x00..0xff which I think is the angle
+# it is applied to one of the ptr_9ef1_table pages
+0x8fe8,0x0040,alien_orientation,byte
+0x9028,0x0040,alien_y,byte
+0x9068,0x0040,alien_9068,byte
+0x90a8,0x0040,alien_x,byte
+0x90e8,0x0040,alien_90e8,byte
+# I think this gets used when the alien is in formation
+# it will be transformed in several ways to animate a foot
+0x9128,0x0040,alien_shape_9128,byte
+# value from here selects a series of page-sized lookup tables
+# ptr_9ef1 <- ptr_9ef1_base + alien_kind[alien] * 0x100
+# ptr_9efe <- ptr_9efe_base + alien_kind[alien] * 0x100
+# ptr_9f18 <- ptr_9f18_base + alien_kind[alien] * 0x100
+0x9168,0x0040,alien_kind,byte
+0x91a8,0x0040,alien_91a8,byte
+# seems to be a counter, low 3 bits used to animate the foot
+# also gets compared against gal_bvar_488e, some kind of threshold?
+0x91e8,0x0040,alien_animate,byte
+# flag which is nonzero to draw a foot? or does it have other uses?
+0x9228,0x0040,alien_9228,byte
 0x932b,0x0001,gal_sub_932b,code
 0x937c,0x0001,init_bvar_0019,byte
 0x9383,0x0001,gal_sub_9383,code
@@ -518,7 +551,8 @@ items
 0x99da,0x0001,gal_loc_99da,code
 0x9a5d,0x0001,gal_sub_9a5d,code
 0x9a6a,0x0001,gal_loc_9a6a,code
-# these get barr_9168[current alien] added to them and stored where indicated
+# lookup tables for determining alien shape
+# their size is 0x100 * number of possible alien_kind values
 0x9ad7,0x0002,ptr_9ef1_base,word,byte
 0x9ad9,0x0002,ptr_9efe_base,word,byte
 0x9adb,0x0002,ptr_9f18_base,word,byte
@@ -527,18 +561,23 @@ items
 0x9b34,0x0001,gal_loc_9b34,code
 0x9b9e,0x0001,gal_sub_9b9e,code
 0x9bdc,0x0001,gal_sub_9bdc,code
+0x9bfe,0x0001,init_alien,code
 0x9c10,0x0001,gal_sub_9c10,code
 0x9c85,0x0001,gal_sub_9c85,code
 0x9ca1,0x0001,gal_sub_9ca1,code
 # this is probably called when we start to process a certain alien
 # it sets lookup tables that are used for animating the shape and other things
-0x9cb1,0x0001,setup_ptr_9ef1_ptr_9efe_ptr_9f18,code
+0x9cb1,0x0001,setup_alien_kind,code
 0x9ccb,0x0001,gal_sub_9ccb,code
 0x9e14,0x0001,gal_sub_9e14,code
 0x9e28,0x0001,gal_loc_9e28,code
 0x9ea6,0x0001,gal_sub_9ea6,code
 0x9ecb,0x0001,gal_sub_9ecb,code
-0x9eec,0x0001,get_alien_shape_9eec,code
+# enter with y = x coordinate
+# lets a = x via identity transformation, gets y
+0x9ee5,0x0001,get_ship_top_centre,code
+# it calculates the shape from alien_orientation
+0x9eec,0x0001,get_alien_shape,code
 0x9ef1,0x0002,gal_ptr_9ef1,word
 0x9ef7,0x0001,physics_9ef7,code
 0x9efe,0x0002,gal_ptr_9efe,word
@@ -551,24 +590,28 @@ items
 0xa018,0x0001,move_shell,code
 0xa061,0x0001,maybe_move_ship,code
 0xa098,0x0001,maybe_award_points,code
-0xa0d3,0x0001,calculate_xy_a0d3,code
-0xa0d9,0x0001,calculate_xy_a0d9,code
+# calculates object_(xy)(01)[object]
+# object 0 is alien, object 1 is ship
+# enter with a = centre x, y = top y, score_temp = 1/2 width (height is 7)
+0xa0d3,0x0001,calculate_bounds0,code
+0xa0d9,0x0001,calculate_bounds1,code
+0xa0dd,0x0001,calculate_bounds_entry,code
 0xa0f4,0x0001,clip_xy,code
 0xa10d,0x0001,move_ship,code
 0xa12e,0x0001,move_shape_a12e,code
 0xa147,0x0001,gal_loc_a147,code
-# returns a = x, y = y
-0xa156,0x0001,get_new_position,code
+# returns a = ship_x (via identity transformation) - 4, y = ship_y
+0xa156,0x0001,get_ship_top_left,code
 0xa15f,0x0001,get_shape_a15f,code
 0xa166,0x0001,gal_rts_a166,code
 0xa167,0x0001,do_erase_shape,code
 # might also be doing collision detection?
 0xa173,0x0001,award_points,code
-# returns a = object x - 3, y = object y
-0xa205,0x0001,get_old_position,code
+# returns a = alien_x[x] - 3, y = alien_y[x]
+0xa205,0x0001,get_alien_top_left,code
 # it can calculate a foot or an explosion shape
 # it can also return a value from a table directly
-0xa20f,0x0001,get_alien_shape_a20f,code
+0xa20f,0x0001,get_alien_part_shape,code
 0xa22d,0x0001,gal_rts_a22d,code
 0xa22e,0x0001,move_alien_shape_a22e,code
 0xa255,0x0001,gal_loc_a255,code