# and holds quotient during div_a_by_7 routine
# and used as general temp (loop count, etc)
0x0018,0x0001,score_temp,byte
+# used by the copy_variables routine
+0x0019,0x0001,copy_variables_0019,byte
+0x001a,0x0001,copy_variables_001a,byte
+0x001b,0x0001,copy_variables_001b,byte
+0x001c,0x0001,copy_variables_001c,byte
0x001f,0x0001,gal_bvar_001f,byte
0x0020,0x0001,draw_x_save,byte
# high score in 4-digit BCD
0x004f,0x0001,gal_barr_004f,byte
0x0057,0x0001,gal_barr_0057,byte
0x005f,0x0001,gal_bvar_005f,byte
-0x0060,0x0001,gal_bvar_0060,byte
+# used by AI routine in demo mode
+# might be simulated paddle reading (17..f3)
+0x0060,0x0001,simulated_paddle,byte
0x0061,0x0001,gal_bvar_0061,byte
0x0062,0x0001,gal_bvar_0062,byte
0x0063,0x0001,gal_bvar_0063,byte
-0x0064,0x0001,gal_bvar_0064,byte
+# something to do with ship collision test
+0x0064,0x0001,ship_collision_test_0064,byte
0x0067,0x0001,ship_x,byte
0x0068,0x0001,gal_bvar_0068,byte
# ships in 2-digit BCD
0x006a,0x0001,active_aliens,byte
0x006b,0x0001,gal_bvar_006b,byte
0x006c,0x0001,gal_bvar_006c,byte
-0x006d,0x0001,gal_bvar_006d,byte
+# something to do with ship collision test
+0x006d,0x0001,ship_active,byte
0x006e,0x0001,gal_bvar_006e,byte
0x006f,0x0001,gal_bvar_006f,byte
# gets set to value of bvar_48a0 when win awarded
# wins in 2-digit BCD
0x0072,0x0001,wins,byte
# bit 7 set when formation exceeds its bounds
-0x0073,0x0001,formation_flag,byte
+0x0073,0x0001,fire_shell_flag,byte
# value of (x, y) which is outside formation bounds
# probably used to determine new direction of movement
0x0074,0x0001,formation_outside_x,byte
0x007a,0x0001,gal_bvar_007a,byte
0x007b,0x0001,gal_bvar_007b,byte
0x007c,0x0001,gal_bvar_007c,byte
-# set to monotonic_492e[gal_bvar_007e]
+# set to monotonic_492e[difficulty_level]
+# sometimes incremented when processing an alien,
+# this depends on monotonic_491e[difficulty_level]
0x007d,0x0001,gal_bvar_007d,byte
# it increments up to a maximum of 0x0f
# is it to do with the formation shape or difficulty level?
-0x007e,0x0001,gal_bvar_007e,byte
+0x007e,0x0001,difficulty_level,byte
0x007f,0x0001,gal_bvar_007f,byte
0x0080,0x0001,gal_bvar_0080,byte
-0x0081,0x0001,gal_bvar_0081,byte
+# shell will only fire if low 2 bits = 0
+# it is then incremented, to fire every 4 cycles?
+0x0081,0x0001,fire_shell_count,byte
+# used in vector_alien_to_ship
+0x0083,0x0001,half_alien_x,byte
+0x0084,0x0001,half_alien_y,byte
0x0085,0x0001,gal_bvar_0085,byte
# stores bounding rectangle
# object_(xy)(01): for alien
0x008e,0x0001,gal_bvar_008e,byte
# saves x reg during calculation
0x0091,0x0001,score_x_save,byte
+# something to do with ship collision test
+0x0092,0x0001,ship_collision_test_0092,byte
0x0093,0x0001,gal_bvar_0093,byte
# sizes have not been examined yet
0x00a9,0x0001,gal_barr_00a9,byte
-0x00b1,0x0001,gal_barr_00b1,byte
+0x00b1,0x0008,shell_active,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
0x4864,0x0001,formation_centre_y,byte
0x4866,0x0001,formation_centre_x,byte
0x4868,0x0001,alien_orientation_init,byte
-0x486c,0x0001,gal_bvar_486c,byte
+0x486a,0x0001,formation_y_init,byte
+0x486c,0x0001,formation_x_init,byte
0x486e,0x0001,shell_y_velocity,byte
0x4870,0x0001,shell_x_velocity_fraction,byte
0x4872,0x0001,missile_y_velocity,byte
0x4876,0x0001,ship_y,byte
+# at initialization:
+# gal_bvar_0078 = val_bvar_4880
+# gal_bvar_0079 = -val_bvar_4880
0x4880,0x0001,gal_bvar_4880,byte
+# at initalization:
+# gal_bvar_007f = 0xff shifted right until < gal_bvar_4882
0x4882,0x0001,gal_bvar_4882,byte
0x4884,0x0001,gal_bvar_4884,byte
0x4886,0x0001,high_score_init,byte
-0x4888,0x0001,gal_bvar_4888,byte
+# not quite sure what this does, see read_paddle routine
+0x4888,0x0001,ship_x_threshold,byte
0x488a,0x0001,gal_bvar_488a,byte
0x488c,0x0001,gal_bvar_488c,byte
0x488e,0x0001,gal_bvar_488e,byte
-0x4890,0x0001,gal_bvar_4890,byte
-0x4892,0x0001,gal_bvar_4892,byte
+0x4890,0x0001,ship_x_max,byte
+0x4892,0x0001,ship_x_min,byte
0x4894,0x0001,gal_bvar_4894,byte
0x489a,0x0001,gal_bvar_489a,byte
-0x489c,0x0001,gal_bvar_489c,byte
-0x489e,0x0001,gal_bvar_489e,byte
+# something to do with ship collision test
+0x489c,0x0001,ship_collision_test_threshold,byte
+0x489e,0x0001,gal_bvar_006c_init,byte
0x48a0,0x0001,gal_bvar_48a0,byte
0x48a2,0x0001,gal_bvar_48a2,byte
# ships won't be redrawn if they exceed this
0x48a4,0x0001,max_displayed_ships,byte
0x48aa,0x0001,starfield_count_init,byte
0x48ac,0x0001,gal_bvar_48ac,byte
-0x48ae,0x0001,gal_bvar_48ae,byte
+0x48ae,0x0001,active_aliens_init,byte
0x48b0,0x0001,gal_bvar_48b0,byte
# used for clearing the screen in the beginning
# seems to be x0, x1, y0, y1
# it will be offset by the centre values x = 0x6c, y = 0x20
0x48b2,0x0004,screen_size,byte
-0x48b6,0x0001,gal_bvar_48b6,byte
-0x48b7,0x0001,gal_bvar_48b7,byte
-0x48b8,0x0001,gal_bvar_48b8,byte
-0x48b9,0x0001,gal_bvar_48b9,byte
-0x48ba,0x0001,gal_bvar_48ba,byte
-0x48bb,0x0001,gal_bvar_48bb,byte
-0x48bc,0x0001,gal_bvar_48bc,byte
-0x48bd,0x0001,gal_bvar_48bd,byte
+0x48b6,0x0001,shell_bounds_x0,byte
+0x48b7,0x0001,shell_bounds_x1,byte
+0x48b8,0x0001,shell_bounds_y0,byte
+0x48b9,0x0001,shell_bounds_y1,byte
+0x48ba,0x0001,missile_bounds_x0,byte
+0x48bb,0x0001,missile_bounds_x1,byte
+0x48bc,0x0001,missile_bounds_y0,byte
+0x48bd,0x0001,missile_bounds_y1,byte
# formation inner bounds?
# used to determine if alien should be moved in formation
0x48c2,0x0001,formation_inner_x0,byte
0x48ee,0x0010,title_display_y,byte
0x48fe,0x0010,title_display_x,byte
# mysterious monotonic sequences
+# testing active_aliens >= monotonic_490e[difficulty_level]
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
+# see also code at 0x9768 (main loop) -- comparing with these values
0x493f,0x0040,barr_493f,byte
# then zeros... padding?
0x49c0,0x0040,alien_49c0,byte
0x4c70,0x0001,gal_barr_4c70,byte
0x4c78,0x0001,gal_barr_4c78,byte
# identity[x] = x, used for ship x position
+# seems to be needed because the ship_x value is from paddle
+# therefore the table could be used to calibrate the paddle
0x4c80,0x0100,identity,byte
0x4d81,0x0001,gal_barr_4d81,byte
# size of 0x400 as there are 4 different alien kinds
0x9228,0x0040,alien_9228,byte
0x932b,0x0001,gal_sub_932b,code
0x937c,0x0001,init_bvar_0019,byte
-0x9383,0x0001,gal_sub_9383,code
+# copies a large number of variables from one set to another
+# also does some +3 and +variable, is it computing bounds?
+0x9383,0x0001,copy_variables,code
# see screen_size
0x93a4,0x0004,screen_offset,byte
# initialize clip_rect, clear screen, set hires
0x9577,0x00c0,video_line_table_lo,byte,byte,10000
0x9637,0x00c0,video_line_table_hi,byte,byte,10000
0x9707,0x0001,start,code
-0x9751,0x0001,gal_sub_9751,code
+0x9751,0x0001,process_all,code
# initializes zpage, and probably other init, and draws something
0x9780,0x0001,zpage_init,code
0x9784,0x0001,,code_ign # zeroing zpage, don't merge cleared variables
0x990f,0x0001,,code_ign # accessing video_line_table before clipping y
0x9934,0x0001,gal_sub_9934,code
0x9960,0x0001,gal_sub_9960,code
-0x99aa,0x0001,gal_sub_99aa,code
-0x99da,0x0001,gal_loc_99da,code
-0x9a5d,0x0001,gal_sub_9a5d,code
-0x9a6a,0x0001,gal_loc_9a6a,code
+# if in demo mode, goes to an AI routine at 0x99bf
+0x99aa,0x0001,read_paddle,code
+0x99da,0x0001,process_ship,code
+0x9a5d,0x0001,init_missile,code
+0x9a6a,0x0001,process_missile,code
+0x9a99,0x0001,process_ship_fire,code
# 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
0x9add,0x0001,init_game,code
+# 0x9b2b is nop, I think it should be "beq activate_aliens"
0x9b2d,0x0001,maybe_activate_aliens,code
0x9b34,0x0001,activate_aliens,code
-0x9b93,0x0001,zero_bvar_006b_bvar_0076_bvar_0080_bvar_0073,code
+0x9b93,0x0001,zero_bvar_006b_bvar_0076_bvar_0080_fire_shell_flag,code
0x9b9e,0x0001,check_formation_bounds,code
0x9bdc,0x0001,move_alien_in_formation,code
0x9bfe,0x0001,init_alien,code
-0x9c10,0x0001,gal_sub_9c10,code
+0x9c10,0x0001,copy_alien,code
+# only if ship is active
+# then stores something in alien_9068
+0x9c6b,0x0001,maybe_vector_alien_to_ship,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_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
+# stores gal_bvar_0076 in alien_9068 for all aliens and the 0th entry
+0x9d88,0x0001,set_all_alien_9068,code
+# moves the alien depending on its status and then does other processing
+0x9d9e,0x0001,process_alien,code
+0x9e14,0x0001,inactivate_shell,code
+# enter with x = shell index
+# maybe fire the given shell, then move it and other processing
+0x9e28,0x0001,process_shell,code
+0x9e61,0x0001,maybe_fire_shell,code
+# shell has a slight x velocity towards player
+# enter with a = x component of vector from alien to ship
+# makes it positive, processes it, reapplies the sign
+0x9ea6,0x0001,calculate_shell_velocity_x,code
+# enter with a, y = alien_x / 2, alien_y / 2
+# returns a, y = signed vector from alien to ship
+0x9ecb,0x0001,vector_alien_to_ship,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
+# something to do with the alien orientation
0x9ef7,0x0001,physics_9ef7,code
0x9efe,0x0002,gal_ptr_9efe,word
0x9f18,0x0001,gal_ptr_9f18,word
+# something to do with the alien orientation
+# is it moving it based on cos(angle) and sin(angle)?
0x9f22,0x0001,physics_9f22,code
0x9f5b,0x0001,move_shell_by_velocity,code
0x9f7d,0x0001,move_missile_by_velocity,code
0x9f88,0x0001,move_alien_shape_9f88,code
0x9fcf,0x0001,move_missile,code
0xa018,0x0001,move_shell,code
-0xa061,0x0001,maybe_move_ship,code
+# set up object0 as a shell or an alien first
+# returns whether collision occurred (in zf and a)
+0xa061,0x0001,ship_collision_test,code
0xa098,0x0001,maybe_award_points,code
# calculates object_(xy)(01)[object]
# object 0 is alien, object 1 is ship
0xa0d3,0x0001,calculate_bounds0,code
0xa0d9,0x0001,calculate_bounds1,code
0xa0dd,0x0001,calculate_bounds_entry,code
-0xa0f4,0x0001,clip_xy,code
+0xa0f4,0x0001,collision_test,code
0xa10d,0x0001,move_ship,code
-0xa12e,0x0001,move_shape_a12e,code
-0xa147,0x0001,gal_loc_a147,code
+0xa12e,0x0001,move_ship_entry0,code
+0xa147,0x0001,move_ship_entry1,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
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
+# called at the end of award_points routine
+0xa255,0x0001,move_alien_shape_a22e_entry,code
# called when an alien is killed and needs to be erased
# decrements active_aliens, awards a win if decremented to zero
0xa264,0x0001,erase_shape_a264,code