Starship Command disassembly ============================ Written by Peter Irvin, co-author of Exile, Starship Command was published by Acornsoft for the BBC Micro in 1983. The player controls a starship, defending against never-ending waves of hostile enemy ships. The following disassembly was created by reverse engineering a binary image, without access to any source code. It is nevertheless reasonably complete, allowing the technical approaches used to be understood. The author of this disassembly imposes no additional copyright restrictions beyond those already present on the game itself. It is provided for educational purposes only, and it is hoped that the original author will accept it in the good faith it was intended - as a tribute to his skills. Technical notes =============== The starship never rotates or moves. Instead, everything else does! Enemy ship co-ordinates are stored as three bytes, corresponding to screens, pixels and fractions of a pixel. Torpedo co-ordinates are stored as two bytes, for pixels and fractions of a pixel. Tables of pre-calculated sines and cosines are used in multiplication and division routines for trigonometric functions. Angles are stored such that &100 = 360 degrees, starting from up at &00 and increasing clockwise. &40 = right, &80 = down, &c0 = left. The main screen is (&7f, &7f). Game-play notes =============== There are always eight enemy ships. Each is assigned one of eight behaviour patterns at random, which can change with probability &06/&ff per frame: 0 Timid ship, retreats upwards as soon as on screen 1 Comes to a stop near edge of screen when starship is stationary, follows closer when starship is moving 2 Approaches starship, stops or retreats 3 Approaches close, then stops 4 Approaches very close, then stops 5 Approaches very close, then retreats 6 Comes up from below starship to near stop above 7 Crashes into starship when going more than half speed They also have five properties which are determined by the command number: * defensive about damage (less likely in later commands) if set, enemy ship retreats when hit by starship torpedo * defensive about angle (less likely in later commands) if set, enemy ship retreats when directly in front of the starship * fires cluster torpedoes (more likely in later commands) if set, fires groups of four torpedoes at once * large and capable of cloaking (more likely in later commands) if set, can become invisible * torpedo cooldown (more likely to be lower in later commands) number of frames between successive torpedo firings command number 1 2 3 4 5 6 7 8 9 10 11 12 13+ probability of enemy ships being: defensive about damage c0 ac 98 84 70 5c 48 34 20 20 20 20 20 defensive about angle 82 74 66 58 4a 3c 2e 20 12 04 04 04 04 fires cluster torpedoes 04 13 22 31 40 4f 5e 6d 7c 8b 9a a9 b8 large and capable of cloaking 02 19 30 47 5e 75 8c a3 ba d1 e8 ff ff maximum torpedo cooldown 0f 0d 0b 09 07 05 03 02 02 02 02 02 02 number of stars 11 0f 0d 0b 09 07 05 03 01 01 01 01 01 The game reaches its maximum difficulty at command thirteen. Energy is handled as follows: maximum starship energy c80 (four bars) low energy warning - flashing text 320 (one bar) - beep 190 minimum starship energy to avoid explosion 40 drain from accelerating or decelerating starship 4 drain from rotating starship 4 drain from firing starship torpedo 4 starship regeneration (every 3 frames) c damage from enemy torpedo 10 damage from collision with enemy ship (maximum ff) c0 + enemy_energy/2 damage from passing through enemy explosion explosion_timer/2 (all multiplied by four when shields are off) damage from self-destruct 4000 damage sufficient to cause shields to fail 3c (with probability &6c/&ff) maximum energy ship energy (all types) ff enemy ship regeneration (every 4 frames) 1 damage from starship torpedo 10 damage from collision with other enemy ship 20 damage from other collisions 14 + rnd(3f) The size of starship and enemy torpedoes makes no difference to their damage. Points are scored for destroyed enemy ships as follows: regular enemy ship, starship torpedo 8 large enemy ship, starship torpedo 12 regular enemy ship, enemy torpedo 1 large enemy ship, enemy torpedo 2 regular enemy ship, escape capsule 32 large enemy ship, escape capsule 40 regular enemy ship, collision with other enemy ship 1 large enemy ship, collision with other enemy ship 2 regular enemy ship, collision with starship 2 large enemy ship, collision with starship 4 A random, undisclosed factor of between 0 and 39 points is added to the score at the end of a command, for comparison against the following table: < 40 furious, and they retire you from active service < 60 displeased, and they retire you from active service < 80 disappointed, and they retire you from active service < 100 disappointed, but they allow you the command of another starship < 200 satisfied, and they allow you the command of another starship < 280 pleased, and they allow you the command of another starship < 400 impressed, and they allow you the command of another starship 400+ delighted, and they allow you the command of another starship The player must thus score at least 100 points to guarantee another command. Interesting Pokes ================= &1aa3 = &60, &1aba = &60 starship doesn't take damage &3ca9 = &06 authorities always "delighted" &3bc7 = &ee, &298c = &00 escape capsule always launched and safely returned Notes ===== Enemy ships are stored in two arrays at &0400 and &0480: &0400 enemy_ships_previous_on_screen &0401 enemy_ships_previous_x_fraction &0402 enemy_ships_previous_x_pixels &0403 enemy_ships_previous_x_screens &0404 enemy_ships_previous_x_fraction &0405 enemy_ships_previous_x_pixels &0406 enemy_ships_previous_x_screens &0407 enemy_ships_previous_angle &0408 enemy_ships_velocity &0409 enemy_ships_flags_or_explosion_timer: ....8421 enemy ship behaviour type ...1.... fires cluster torpedoes ..2..... defensive about angle .4...... defensive about damage &040a enemy_ships_type 0 = regular 1 = large 4 = cloaked &0480 enemy_ships_on_screen &0481 enemy_ships_x_fraction &0482 enemy_ships_x_pixels &0483 enemy_ships_x_screens &0484 enemy_ships_x_fraction &0485 enemy_ships_x_pixels &0486 enemy_ships_x_screens &0487 enemy_ships_angle &0488 enemy_ships_temporary_behaviour_flags ....8421 enemy_ship_hit_count ...1.... behaviour 0: enemy_ship_was_on_screen_above behaviour 7: kamikaze_one ..2..... behaviour 7: kamikaze_two .4...... retreating because of angle 8....... retreating &0489 enemy_ships_energy &048a enemy_ships_firing_cooldown ....8421 current torpedo cooldown 8421.... maximum torpedo cooldown Enemy torpedoes are stored in an array at &4fb4, 6 bytes per torpedo: +0 ttl +1 x_fraction +2 x_pixels +3 y_fraction +4 y_pixels +5 angle Starship torpedoes are stored in an array at &4f00, 9 bytes per torpedo: +0 ttl +1 x_fraction for head of torpedo +2 x_pixels +3 y_fraction +4 y_pixels +5 x_fraction for tail of torpedo +6 x_pixels +7 y_fraction +8 y_pixels Stars are stored in an array at &4b00, 4 bytes per star: +0 x_fraction +1 x_pixels +2 y_fraction +3 y_pixels Enemy explosion pieces are stored in arrays at &4d00, 2 bytes per piece: +0 age (top two bits are used to determine size of piece) +1 radius ......21 speed of ageing (via lookup table), if not a segment Starship explosion pieces are stored in arrays at &4bd0, 3 bytes per piece: +0 age (top two bits are used to determine size of piece, if not a segment) +1 segment angle or ageing rate 8....... piece is a segment (probability 1/&3c) ...18421 angle of segment, if piece is a segment .....421 speed of ageing (via lookup table), if not a segment +2 radius Disassembly =========== ; $.COMMAND ; 002000 0062b1 0042f9 &0e00 0d ff 53 54 41 52 53 48 49 50 20 43 4f 4d 4d 41 ; "STARSHIP COMMAND 1.20 Copyright (c) 1982" &0e10 4e 44 20 31 2e 32 30 20 43 6f 70 79 72 69 67 68 &0e20 74 20 28 63 29 20 31 39 38 32 0d ; unused &0e2b ff ff ; number_of_delay_loops &0e2d ff ; enemy_ship_was_previously_on_screen &0e2e ff ; enemy_ship_was_on_screen &0e2f ff ; additional_damage_from_collision_with_enemy_ship &0e30 c0 ; damage_enemy_ship_incurs_from_collision_with_other_enemy_ship &0e31 20 ; starship_angle_fraction &0e32 ff ; starship_angle_delta &0e33 ff ; damage_to_enemy_ship_from_starship_torpedo &0e34 10 ; maximum_number_of_explosions &0e35 08 ; value_used_for_enemy_torpedo_ttl &0e36 20 ; frame_of_enemy_ship_explosion_after_which_no_collisions &0e37 1b ; frame_of_enemy_ship_explosion_after_which_no_segments_are_plotted &0e38 23 ; enemy_ship_explosion_duration &0e39 25 ; size_of_enemy_ship_for_collisions_with_torpedoes &0e3a 05 ; size_of_enemy_ship_for_collisions_between_enemy_ships &0e3b 08 ; unused &0e3c ff ; enemy_torpedo_table_address_low &0e3d b4 ; enemy_torpedo_table_address_high &0e3e 4f ; unused &0e3f ff 00 ; bit_table &0e41 80 40 20 10 08 04 02 01 ; star_table_address_low &0e49 00 ; star_table_address_high &0e4a 4b ; starship_torpedo_table_address_low &0e4b 00 ; starship_torpedo_table_address_high &0e4c 4f ; starship_torpedo_tail_table_address_low &0e4d 04 ; starship_torpedo_tail_table_address_high &0e4e 4f ; maximum_number_of_enemy_ships &0e4f 08 ; maximum_number_of_stars &0e50 11 ; maximum_number_of_starship_torpedoes &0e51 0c ; maximum_number_of_enemy_torpedoes &0e52 18 ; starship_torpedoes_time_to_live &0e53 0f ; enemy_ships_still_to_consider &0e54 00 ; torpedoes_still_to_consider &0e55 00 ; starship_shields_active &0e56 00 ; unused &0e57 00 ; sine_table &0e58 00 01 02 03 04 05 05 06 06 06 05 05 04 03 02 01 &0e68 00 ff fe fd fc fb fb fa fa fa fb fb fc fd fe ff ; cosine_table &0e78 fa fa fb fb fc fd fe ff 00 01 02 03 04 05 05 06 &0e88 06 06 05 05 04 03 02 01 00 ff fe fd fc fb fb fa ; segment_angle_to_x_y_deltas_table &0e98 03 ; x+ y0 &0e99 0f ; x+ y+ &0e9a 03 ; x+ y0 &0e9b 0f ; x+ y+ &0e9c 0f ; x+ y+ &0e9d 0c ; x0 y+ &0e9e 0f ; x+ y+ &0e9f 0c ; x0 y+ &0ea0 0c ; x0 y+ &0ea1 0d ; x- y+ &0ea2 0c ; x0 y+ &0ea3 0d ; x- y+ &0ea4 0d ; x- y+ &0ea5 01 ; x- y0 &0ea6 0d ; x- y+ &0ea7 01 ; x- y0 &0ea8 01 ; x- y0 &0ea9 05 ; x- y- &0eaa 01 ; x- y0 &0eab 05 ; x- y- &0eac 05 ; x- y- &0ead 04 ; x0 y- &0eae 05 ; x- y- &0eaf 04 ; x0 y- &0eb0 04 ; x0 y- &0eb1 07 ; x+ y- &0eb2 04 ; x0 y- &0eb3 07 ; x+ y- &0eb4 07 ; x+ y- &0eb5 03 ; x+ y0 &0eb6 07 ; x+ y- &0eb7 03 ; x+ y0 ; unused &0eb8 00 ff ff ff ff ff ; starship_rotation_cosine_table &0ebe 00 fe f8 ee e0 ce ; starship_rotation_sine_table &0ec4 00 02 04 06 08 0a ; unused &0eca 00 00 00 00 00 00 ; rotated_x_correction_lsb &0ed0 00 ff fc f7 f0 e7 ; rotated_x_correction_screens &0ed6 00 00 01 02 03 04 ; rotated_y_correction_lsb &0edc 00 01 04 09 10 19 ; rotated_y_correction_screens &0ee2 00 01 02 03 04 05 ; rotated_x_correction_fraction &0ee8 00 fe ff fc fa f6 ; rotated_x_correction_pixels &0eee 00 fe fb f6 ef e6 ; rotated_y_correction_fraction &0ef4 01 00 02 00 ff fe ; rotated_y_correction_pixels &0efa 00 01 04 09 0f 18 ; starship_velocity_high &0f00 00 ; starship_velocity_low &0f01 00 ; starship_rotation &0f02 00 ; starship_rotation_magnitude &0f03 00 ; starship_rotation_cosine &0f04 00 ; starship_rotation_sine_magnitude &0f05 00 ; set_pixel &0f06 20 18 0f JSR &0f18 ; calculate_pixel_address &0f09 11 70 ORA (&70),Y ; screen_address &0f0b 91 70 STA (&70),Y ; screen_address &0f0d 60 RTS ; unset_pixel &0f0e 20 18 0f JSR &0f18 ; calculate_pixel_address &0f11 49 ff EOR #&ff &0f13 31 70 AND (&70),Y ; screen_address &0f15 91 70 STA (&70),Y ; screen_address &0f17 60 RTS ; calculate_pixel_address &0f18 a9 00 LDA #&00 &0f1a 85 70 STA &70 ; screen_address_low &0f1c a5 7b LDA &7b ; y &0f1e 4a LSR A &0f1f 4a LSR A &0f20 4a LSR A &0f21 85 71 STA &71 ; screen_address_high &0f23 4a LSR A &0f24 66 70 ROR &70 ; screen_address_low &0f26 4a LSR A &0f27 66 70 ROR &70 ; screen_address_low &0f29 65 71 ADC &71 ; screen_address_high &0f2b 65 79 ADC &79 ; screen_start_high &0f2d 85 71 STA &71 ; screen_address_high &0f2f a5 7b LDA &7b ; y &0f31 29 07 AND #&07 &0f33 65 70 ADC &70 ; screen_address_low &0f35 85 70 STA &70 ; screen_address_low &0f37 a5 7a LDA &7a ; x &0f39 29 f8 AND #&f8 &0f3b a8 TAY &0f3c a5 7a LDA &7a ; x &0f3e 29 07 AND #&07 &0f40 aa TAX &0f41 bd 41 0e LDA &0e41,X ; bit_table &0f44 60 RTS ; unused_infinite_loop &0f45 ea NOP &0f46 ea NOP &0f47 d0 fc BNE &0f45 ; unused_infinite_loop &0f49 60 RTS ; eor_pixel_within_box_around_origin &0f4a a5 7a LDA &7a ; x &0f4c 38 SEC &0f4d e5 77 SBC &77 ; origin_x &0f4f b0 02 BCS &0f53 ; skip_inversion_x &0f51 49 ff EOR #&ff ; skip_inversion_x &0f53 c9 20 CMP #&20 &0f55 b0 42 BCS &0f99 ; leave &0f57 a5 7b LDA &7b ; y &0f59 38 SEC &0f5a e5 76 SBC &76 ; origin_y &0f5c b0 02 BCS &0f60 ; skip_inversion_y &0f5e 49 ff EOR #&ff ; skip_inversion_y &0f60 c9 20 CMP #&20 &0f62 b0 35 BCS &0f99 ; leave ; eor_pixel &0f64 a9 00 LDA #&00 &0f66 85 70 STA &70 ; screen_address_low &0f68 a5 7b LDA &7b ; y &0f6a 4a LSR A &0f6b 4a LSR A &0f6c 4a LSR A &0f6d 85 71 STA &71 ; screen_address_high &0f6f 4a LSR A &0f70 66 70 ROR &70 ; screen_address_low &0f72 4a LSR A &0f73 66 70 ROR &70 ; screen_address_low &0f75 65 71 ADC &71 ; screen_address_high &0f77 65 79 ADC &79 ; screen_start_high &0f79 85 71 STA &71 ; screen_address_high &0f7b a5 7b LDA &7b ; y &0f7d 29 07 AND #&07 &0f7f 65 70 ADC &70 ; screen_address_low &0f81 85 70 STA &70 ; screen_address_low &0f83 a5 7a LDA &7a ; x &0f85 29 f8 AND #&f8 &0f87 a8 TAY &0f88 a5 7a LDA &7a ; x &0f8a 29 07 AND #&07 &0f8c aa TAX &0f8d bd 41 0e LDA &0e41,X ; bit_table &0f90 51 70 EOR (&70),Y ; screen_address &0f92 91 70 STA (&70),Y ; screen_address &0f94 60 RTS ; unused &0f95 ea NOP &0f96 ea NOP &0f97 91 70 STA (&70),Y ; screen_address ; leave &0f99 60 RTS ; multiply_torpedo_position_by_starship_rotation_sine_magnitude &0f9a ad 05 0f LDA &0f05 ; starship_rotation_sine_magnitude &0f9d 85 7c STA &7c ; multiplier &0f9f b1 80 LDA (&80),Y ; object_fraction &0fa1 85 75 STA &75 ; input_fraction &0fa3 c8 INY &0fa4 b1 80 LDA (&80),Y ; object_pixels &0fa6 85 73 STA &73 ; input_pixels &0fa8 a9 00 LDA #&00 &0faa a2 10 LDX #&10 # 16-bit multiplication of input by multiplier ; loop_over_bits_of_input &0fac 46 73 LSR &73 ; input_pixels &0fae 66 75 ROR &75 ; input_fraction &0fb0 90 03 BCC &0fb5 ; input_bit_unset &0fb2 18 CLC &0fb3 65 7c ADC &7c ; multiplier ; input_bit_unset &0fb5 6a ROR A &0fb6 66 72 ROR &72 ; output_pixels &0fb8 ca DEX &0fb9 d0 f1 BNE &0fac ; loop_over_bits_of_input &0fbb 85 73 STA &73 ; output_fraction &0fbd 60 RTS ; multiply_torpedo_position_by_starship_rotation_cosine &0fbe ad 04 0f LDA &0f04 ; starship_rotation_cosine &0fc1 85 75 STA &75 ; multiplier &0fc3 a9 00 LDA #&00 &0fc5 a2 08 LDX #&08 # 8-bit multiplication of input by multiplier ; loop_over_bits_of_multiplier &0fc7 46 75 LSR &75 ; multiplier &0fc9 90 03 BCC &0fce ; multiplier_bit_unset &0fcb 18 CLC &0fcc 71 80 ADC (&80),Y ; input_fraction ; multiplier_bit_unset &0fce 6a ROR A &0fcf ca DEX &0fd0 d0 f5 BNE &0fc7 ; loop_over_bits_of_multiplier &0fd2 38 SEC &0fd3 f1 80 SBC (&80),Y ; input_fraction &0fd5 aa TAX &0fd6 b1 80 LDA (&80),Y ; input_fraction &0fd8 e9 00 SBC #&00 &0fda 85 75 STA &75 ; output_pixels &0fdc 8a TXA &0fdd 88 DEY &0fde 18 CLC &0fdf 71 80 ADC (&80),Y ; input_fraction &0fe1 90 02 BCC &0fe5 ; leave &0fe3 e6 75 INC &75 ; output_pixels &0fe5 60 RTS ; update_object_position_for_starship_rotation_and_speed &0fe6 c8 INY &0fe7 b1 80 LDA (&80),Y ; object_x_pixels &0fe9 85 7a STA &7a ; x_pixels &0feb ae 02 0f LDX &0f02 ; starship_rotation &0fee 30 0c BMI &0ffc ; skip_inversion &0ff0 49 ff EOR #&ff &0ff2 91 80 STA (&80),Y ; object_x_pixels &0ff4 88 DEY &0ff5 b1 80 LDA (&80),Y ; object_x_fraction &0ff7 49 ff EOR #&ff &0ff9 91 80 STA (&80),Y ; object_x_fraction &0ffb c8 INY ; skip_inversion &0ffc c8 INY &0ffd c8 INY &0ffe b1 80 LDA (&80),Y ; object_y_pixels &1000 85 7b STA &7b ; y_pixels &1002 ae 05 0f LDX &0f05 ; starship_rotation_sine_magnitude &1005 d0 06 BNE &100d ; update_position_for_rotation &1007 20 0d 12 JSR &120d ; brief_delay_80 &100a 4c 6f 10 JMP &106f ; add_starship_velocity_to_position ; update_position_for_rotation &100d 88 DEY ; y &100e 20 9a 0f JSR &0f9a ; multiply_torpedo_position_by_starship_rotation_sine_magnitude &1011 88 DEY &1012 88 DEY ; x &1013 20 be 0f JSR &0fbe ; multiply_torpedo_position_by_starship_rotation_cosine &1016 18 CLC &1017 65 72 ADC &72 ; sine_y_fraction &1019 85 76 STA &76 ; cosine_x_plus_sine_y_fraction &101b a5 75 LDA &75 ; cosine_x_pixels &101d 65 73 ADC &73 ; sine_y_pixels &101f 85 77 STA &77 ; cosine_x_plus_sine_y_pixels &1021 20 9a 0f JSR &0f9a ; multiply_torpedo_position_by_starship_rotation_sine_magnitude &1024 c8 INY &1025 c8 INY ; y &1026 20 be 0f JSR &0fbe ; multiply_torpedo_position_by_starship_rotation_cosine &1029 38 SEC &102a e5 72 SBC &72 ; sine_x_fraction &102c 91 80 STA (&80),Y ; object_y_fraction &102e c8 INY &102f a5 75 LDA &75 ; cosine_y_pixels &1031 e5 73 SBC &73 ; sine_x_pixels &1033 91 80 STA (&80),Y ; object_y_pixels &1035 88 DEY &1036 88 DEY &1037 88 DEY &1038 ae 03 0f LDX &0f03 ; starship_rotation_magnitude &103b a5 76 LDA &76 ; cosine_x_plus_sine_y_fraction &103d 38 SEC &103e fd d0 0e SBC &0ed0,X ; rotated_x_correction_lsb &1041 91 80 STA (&80),Y ; object_x_fraction &1043 c8 INY &1044 a5 77 LDA &77 ; cosine_x_plus_sine_y_pixels &1046 fd d6 0e SBC &0ed6,X ; rotated_x_correction_screens &1049 91 80 STA (&80),Y ; object_x_pixels &104b ad 02 0f LDA &0f02 ; starship_rotation &104e 30 0e BMI &105e ; skip_uninversion &1050 88 DEY &1051 b1 80 LDA (&80),Y ; object_x_fraction &1053 49 ff EOR #&ff &1055 91 80 STA (&80),Y ; object_x_fraction &1057 c8 INY &1058 b1 80 LDA (&80),Y ; object_x_pixels &105a 49 ff EOR #&ff &105c 91 80 STA (&80),Y ; object_x_pixels ; skip_uninversion &105e c8 INY &105f b1 80 LDA (&80),Y ; object_y_fraction &1061 18 CLC &1062 7d dc 0e ADC &0edc,X ; rotated_y_correction_lsb &1065 91 80 STA (&80),Y ; object_y_fraction &1067 c8 INY &1068 b1 80 LDA (&80),Y ; object_y_pixels &106a 7d e2 0e ADC &0ee2,X ; rotated_y_correction_screens &106d 91 80 STA (&80),Y ; object_y_pixels ; add_starship_velocity_to_position &106f 88 DEY &1070 b1 80 LDA (&80),Y ; object_y_fraction &1072 18 CLC &1073 6d 01 0f ADC &0f01 ; starship_velocity_low &1076 91 80 STA (&80),Y ; object_y_fraction &1078 c8 INY &1079 b1 80 LDA (&80),Y ; object_y_pixels &107b 6d 00 0f ADC &0f00 ; starship_velocity_high &107e 91 80 STA (&80),Y ; object_y_pixels &1080 60 RTS ; multiply_enemy_position_by_starship_rotation_sine_magnitude &1081 ad 05 0f LDA &0f05 ; starship_rotation_sine_magnitude &1084 85 74 STA &74 ; multiplier &1086 bd 81 04 LDA &0481,X ; enemy_ships_x_fraction &1089 85 76 STA &76 ; input_fraction &108b bd 82 04 LDA &0482,X ; enemy_ships_x_pixels &108e 85 77 STA &77 ; input_pixels &1090 bd 83 04 LDA &0483,X ; enemy_ships_x_screens &1093 85 78 STA &78 ; input_screens &1095 a9 00 LDA #&00 &1097 a0 18 LDY #&18 # 24-bit multiplication of input by multiplier ; loop_over_bits_of_input &1099 46 78 LSR &78 ; input_screens &109b 66 77 ROR &77 ; input_pixels &109d 66 76 ROR &76 ; input_fraction # Get lowest bit of (fraction, pixels, screen) &109f 90 03 BCC &10a4 ; input_bit_unset &10a1 18 CLC &10a2 65 74 ADC &74 ; multiplier ; input_bit_unset &10a4 6a ROR A &10a5 66 73 ROR &73 ; sine_output_pixels &10a7 66 72 ROR &72 ; sine_output_fraction &10a9 88 DEY &10aa d0 ed BNE &1099 ; loop_over_bits_of_input &10ac 85 74 STA &74 ; sine_output_screens &10ae 60 RTS ; multiply_enemy_position_by_starship_rotation_cosine &10af ad 04 0f LDA &0f04 ; starship_rotation_cosine &10b2 85 78 STA &78 ; multiplier &10b4 bd 82 04 LDA &0482,X ; enemy_ships_x_pixels &10b7 85 76 STA &76 ; input_pixels &10b9 bd 83 04 LDA &0483,X ; enemy_ships_x_screens &10bc 85 77 STA &77 ; input_screens &10be a9 00 LDA #&00 &10c0 a0 10 LDY #&10 # 16-bit multiplication of input by multiplier ; loop_over_bits_of_input &10c2 46 77 LSR &77 ; input_screens &10c4 66 76 ROR &76 ; input_pixels # Get lowest bit of (screens, pixels) &10c6 90 03 BCC &10cb ; input_bit_unset &10c8 18 CLC &10c9 65 78 ADC &78 ; multiplier ; input_bit_unset &10cb 6a ROR A &10cc 66 75 ROR &75 ; tmp_fraction &10ce 88 DEY &10cf d0 f1 BNE &10c2 ; loop_over_bits_of_input &10d1 a8 TAY ; output_pixels &10d2 a5 75 LDA &75 ; tmp_fraction &10d4 18 CLC &10d5 7d 81 04 ADC &0481,X ; enemy_ships_x_fraction &10d8 85 76 STA &76 ; cosine_output_fraction &10da 98 TYA &10db 7d 82 04 ADC &0482,X ; enemy_ships_x_pixels &10de a8 TAY &10df bd 83 04 LDA &0483,X ; enemy_ships_x_screens &10e2 69 00 ADC #&00 &10e4 85 78 STA &78 ; cosine_output_screens &10e6 a5 76 LDA &76 ; cosine_output_fraction &10e8 38 SEC &10e9 fd 82 04 SBC &0482,X ; enemy_ships_x_pixels &10ec 85 76 STA &76 ; cosine_output_fraction &10ee 98 TYA &10ef fd 83 04 SBC &0483,X ; enemy_ships_x_screens &10f2 85 77 STA &77 ; cosine_output_pixels &10f4 a5 78 LDA &78 ; cosine_output_screens &10f6 e9 00 SBC #&00 &10f8 85 78 STA &78 ; cosine_output_screens &10fa 60 RTS ; apply_starship_rotation_and_velocity_to_enemy_ships &10fb ad 05 0f LDA &0f05 ; starship_rotation_sine_magnitude &10fe d0 06 BNE &1106 ; starship_is_rotating &1100 20 11 12 JSR &1211 ; brief_delay_40 &1103 4c f1 11 JMP &11f1 ; apply_starship_velocity_to_enemy_ship ; starship_is_rotating &1106 bd 02 04 LDA &0402,X ; enemy_ships_previous_x_pixels &1109 18 CLC &110a 69 80 ADC #&80 &110c 9d 82 04 STA &0482,X ; enemy_ships_x_pixels &110f 90 03 BCC &1114 &1111 fe 83 04 INC &0483,X ; enemy_ships_x_screens &1114 bd 05 04 LDA &0405,X ; enemy_ships_previous_y_pixels &1117 18 CLC &1118 69 80 ADC #&80 &111a 9d 85 04 STA &0485,X ; enemy_ships_y_pixels &111d 90 03 BCC &1122 &111f fe 86 04 INC &0486,X ; enemy_ships_y_screens &1122 ac 02 0f LDY &0f02 ; starship_rotation &1125 30 18 BMI &113f ; skip_inversion &1127 bd 01 04 LDA &0401,X ; enemy_ships_previous_x_fraction &112a 49 ff EOR #&ff &112c 9d 81 04 STA &0481,X ; enemy_ships_x_fraction &112f bd 82 04 LDA &0482,X ; enemy_ships_x_pixels &1132 49 ff EOR #&ff &1134 9d 82 04 STA &0482,X ; enemy_ships_x_pixels &1137 bd 83 04 LDA &0483,X ; enemy_ships_x_screens &113a 49 ff EOR #&ff &113c 9d 83 04 STA &0483,X ; enemy_ships_x_screens ; skip_inversion &113f e8 INX ; y &1140 e8 INX &1141 e8 INX &1142 20 81 10 JSR &1081 ; multiply_enemy_position_by_starship_rotation_sine_magnitude &1145 ca DEX ; x &1146 ca DEX &1147 ca DEX &1148 20 af 10 JSR &10af ; multiply_enemy_position_by_starship_rotation_cosine &114b a5 76 LDA &76 ; cosine_x_fraction &114d 18 CLC &114e 65 72 ADC &72 ; sine_y_fraction &1150 85 7a STA &7a ; sine_y_plus_cosine_x_fraction &1152 a5 77 LDA &77 ; cosine_x_pixels &1154 65 73 ADC &73 ; sine_y_pixels &1156 85 7b STA &7b ; sine_y_plus_cosine_x_pixels &1158 a5 78 LDA &78 ; cosine_x_screens &115a 65 74 ADC &74 ; sine_y_screens &115c 85 7c STA &7c ; sine_y_plus_cosine_x_screens &115e 20 81 10 JSR &1081 ; multiply_enemy_position_by_starship_rotation_sine_magnitude &1161 e8 INX ; y &1162 e8 INX &1163 e8 INX &1164 20 af 10 JSR &10af ; multiply_enemy_position_by_starship_rotation_cosine &1167 ca DEX ; x &1168 ca DEX &1169 ca DEX &116a a5 76 LDA &76 ; cosine_y_fraction &116c 38 SEC &116d e5 72 SBC &72 ; sine_x_fraction &116f 85 76 STA &76 ; cosine_y_minus_sine_x_fraction &1171 a5 77 LDA &77 ; cosine_y_pixels &1173 e5 73 SBC &73 ; sine_y_pixels &1175 85 77 STA &77 ; cosine_y_minus_sine_x_pixels &1177 a5 78 LDA &78 ; cosine_y_screens &1179 e5 74 SBC &74 ; sine_y_screens &117b 85 78 STA &78 ; cosine_y_minus_sine_x_screens &117d ac 03 0f LDY &0f03 ; starship_rotation_magnitude &1180 a5 7a LDA &7a ; sine_y_plus_cosine_x_fraction &1182 38 SEC &1183 f9 e8 0e SBC &0ee8,Y ; rotated_x_correction_fraction &1186 9d 81 04 STA &0481,X ; enemy_ships_x_fraction &1189 a5 7b LDA &7b ; sine_y_plus_cosine_x_pixels &118b f9 ee 0e SBC &0eee,Y ; rotated_x_correction_pixels &118e 9d 82 04 STA &0482,X ; enemy_ships_x_pixels &1191 a5 7c LDA &7c ; sine_y_plus_cosine_x_screens &1193 f9 d6 0e SBC &0ed6,Y ; rotated_x_correction_screens &1196 9d 83 04 STA &0483,X ; enemy_ships_x_screens &1199 ad 02 0f LDA &0f02 ; starship_rotation &119c 30 18 BMI &11b6 ; skip_uninversion &119e bd 81 04 LDA &0481,X ; enemy_ships_x_fraction &11a1 49 ff EOR #&ff &11a3 9d 81 04 STA &0481,X ; enemy_ships_x_fraction &11a6 bd 82 04 LDA &0482,X ; enemy_ships_x_pixels &11a9 49 ff EOR #&ff &11ab 9d 82 04 STA &0482,X ; enemy_ships_x_pixels &11ae bd 83 04 LDA &0483,X ; enemy_ships_x_screens &11b1 49 ff EOR #&ff &11b3 9d 83 04 STA &0483,X ; enemy_ships_x_screens ; skip_uninversion &11b6 a5 76 LDA &76 ; cosine_y_minus_sine_x_fraction &11b8 18 CLC &11b9 79 f4 0e ADC &0ef4,Y ; rotated_y_correction_fraction &11bc 9d 84 04 STA &0484,X ; enemy_ships_y_fraction &11bf a5 77 LDA &77 ; cosine_y_minus_sine_x_pixels &11c1 79 fa 0e ADC &0efa,Y ; rotated_y_correction_pixels &11c4 9d 85 04 STA &0485,X ; enemy_ships_y_pixels &11c7 a5 78 LDA &78 ; cosine_y_minus_sine_x_screens &11c9 79 e2 0e ADC &0ee2,Y ; rotated_y_correction_screens &11cc 9d 86 04 STA &0486,X ; enemy_ships_y_screens &11cf bd 85 04 LDA &0485,X ; enemy_ships_y_pixels &11d2 38 SEC &11d3 e9 80 SBC #&80 &11d5 9d 85 04 STA &0485,X ; enemy_ships_y_pixels &11d8 bd 86 04 LDA &0486,X ; enemy_ships_y_screens &11db e9 00 SBC #&00 &11dd 9d 86 04 STA &0486,X ; enemy_ships_y_screens &11e0 bd 82 04 LDA &0482,X ; enemy_ships_x_pixels &11e3 38 SEC &11e4 e9 80 SBC #&80 &11e6 9d 82 04 STA &0482,X ; enemy_ships_x_pixels &11e9 bd 83 04 LDA &0483,X ; enemy_ships_x_screens &11ec e9 00 SBC #&00 &11ee 9d 83 04 STA &0483,X ; enemy_ships_x_screens ; apply_starship_velocity_to_enemy_ship &11f1 bd 84 04 LDA &0484,X ; enemy_ships_y_fraction &11f4 18 CLC &11f5 6d 01 0f ADC &0f01 ; starship_velocity_low &11f8 9d 84 04 STA &0484,X ; enemy_ships_y_fraction &11fb bd 85 04 LDA &0485,X ; enemy_ships_y_pixels &11fe 6d 00 0f ADC &0f00 ; starship_velocity_high &1201 9d 85 04 STA &0485,X ; enemy_ships_y_pixels &1204 bd 86 04 LDA &0486,X ; enemy_ships_y_screens &1207 69 00 ADC #&00 &1209 9d 86 04 STA &0486,X ; enemy_ships_y_screens &120c 60 RTS ; brief_delay_80 &120d a9 80 LDA #&80 &120f d0 02 BNE &1213 ; brief_delay_loop ; brief_delay_40 &1211 a9 c0 LDA #&c0 ; brief_delay_loop &1213 18 CLC &1214 69 01 ADC #&01 &1216 d0 fb BNE &1213 ; brief_delay_loop &1218 60 RTS ; plot_starship_torpedoes &1219 ad 51 0e LDA &0e51 ; maximum_number_of_starship_torpedoes &121c 8d 55 0e STA &0e55 ; torpedoes_still_to_consider &121f ad 4b 0e LDA &0e4b ; starship_torpedo_table_address_low &1222 85 80 STA &80 ; starship_torpedo_address_low &1224 ad 4c 0e LDA &0e4c ; starship_torpedo_table_address_high &1227 85 81 STA &81 ; starship_torpedo_address_high &1229 ad 4d 0e LDA &0e4d ; starship_torpedo_tail_table_address_low &122c 85 82 STA &82 ; starship_torpedo_tail_address_low &122e ad 4e 0e LDA &0e4e ; starship_torpedo_tail_table_address_high &1231 85 83 STA &83 ; starship_torpedo_tail_address_high ; plot_starship_torpedoes_loop &1233 a0 00 LDY #&00 &1235 b1 80 LDA (&80),Y ; torpedo_ttl &1237 d0 03 BNE &123c ; torpedo_present &1239 4c d8 12 JMP &12d8 ; update_next_torpedo ; torpedo_present &123c 38 SEC &123d e9 01 SBC #&01 # Decrease torpedo TTL &123f 91 80 STA (&80),Y ; torpedo_ttl &1241 d0 09 BNE &124c ; torpedo_still_alive &1243 ce 57 26 DEC &2657 ; number_of_live_starship_torpedoes &1246 20 8a 13 JSR &138a ; plot_expiring_torpedo &1249 4c d8 12 JMP &12d8 ; update_next_torpedo ; torpedo_still_alive &124c 20 5a 14 JSR &145a ; plot_starship_torpedo &124f a0 01 LDY #&01 &1251 20 e6 0f JSR &0fe6 ; update_object_position_for_starship_rotation_and_speed &1254 a0 05 LDY #&05 &1256 20 e6 0f JSR &0fe6 ; update_object_position_for_starship_rotation_and_speed &1259 a0 01 LDY #&01 &125b b1 80 LDA (&80),Y ; torpedo_x_fraction &125d 38 SEC &125e f1 82 SBC (&82),Y ; torpedo_tail_x_fraction &1260 85 72 STA &72 ; torpedo_velocity_x_fraction &1262 c8 INY &1263 b1 80 LDA (&80),Y ; torpedo_x_pixels &1265 f1 82 SBC (&82),Y ; torpedo_tail_x_pixels &1267 06 72 ASL &72 ; torpedo_velocity_x_fraction &1269 2a ROL A &126a 06 72 ASL &72 ; torpedo_velocity_x_fraction &126c 2a ROL A &126d 85 73 STA &73 ; torpedo_velocity_x_pixels &126f c8 INY &1270 b1 80 LDA (&80),Y ; torpedo_y_fraction &1272 38 SEC &1273 f1 82 SBC (&82),Y ; torpedo_tail_y_fraction &1275 85 76 STA &76 ; torpedo_velocity_y_fraction &1277 c8 INY &1278 b1 80 LDA (&80),Y ; torpedo_x_pixels &127a f1 82 SBC (&82),Y ; torpedo_tail_y_pixels &127c 06 76 ASL &76 ; torpedo_velocity_y_fraction &127e 2a ROL A &127f 06 76 ASL &76 ; torpedo_velocity_y_fraction &1281 2a ROL A &1282 85 77 STA &77 ; torpedo_velocity_y_pixels &1284 a0 01 LDY #&01 &1286 b1 80 LDA (&80),Y ; torpedo_x_fraction &1288 18 CLC &1289 65 72 ADC &72 ; torpedo_velocity_x_fraction &128b 91 80 STA (&80),Y ; torpedo_x_fraction &128d c8 INY &128e b1 80 LDA (&80),Y ; torpedo_x_pixels &1290 65 73 ADC &73 ; torpedo_velocity_x_pixels &1292 91 80 STA (&80),Y ; torpedo_x_pixels &1294 c8 INY &1295 b1 80 LDA (&80),Y ; torpedo_y_fraction &1297 18 CLC &1298 65 76 ADC &76 ; torpedo_velocity_y_fraction &129a 91 80 STA (&80),Y ; torpedo_y_fraction &129c c8 INY &129d b1 80 LDA (&80),Y ; torpedo_y_pixels &129f 65 77 ADC &77 ; torpedo_velocity_y_pixels &12a1 91 80 STA (&80),Y ; torpedo_y_pixels &12a3 a0 01 LDY #&01 &12a5 b1 82 LDA (&82),Y ; torpedo_tail_x_fraction &12a7 18 CLC &12a8 65 72 ADC &72 ; torpedo_velocity_x_fraction &12aa 91 82 STA (&82),Y ; torpedo_tail_x_fraction &12ac c8 INY &12ad b1 82 LDA (&82),Y ; torpedo_tail_x_pixels &12af 65 73 ADC &73 ; torpedo_velocity_x_pixels &12b1 91 82 STA (&82),Y ; torpedo_tail_x_pixels &12b3 c8 INY &12b4 b1 82 LDA (&82),Y ; torpedo_tail_y_fraction &12b6 18 CLC &12b7 65 76 ADC &76 ; torpedo_velocity_y_fraction &12b9 91 82 STA (&82),Y ; torpedo_tail_y_fraction &12bb c8 INY &12bc b1 82 LDA (&82),Y ; torpedo_tail_y_pixels &12be 65 77 ADC &77 ; torpedo_velocity_y_pixels &12c0 91 82 STA (&82),Y ; torpedo_tail_y_pixels &12c2 20 9d 15 JSR &159d ; check_for_collision_with_enemy_ships &12c5 b0 11 BCS &12d8 ; update_next_torpedo &12c7 a0 00 LDY #&00 &12c9 b1 80 LDA (&80),Y ; torpedo_ttl &12cb c9 02 CMP #&02 &12cd b0 06 BCS &12d5 ; unplot_torpedo &12cf 20 8a 13 JSR &138a ; plot_expiring_torpedo &12d2 38 SEC &12d3 b0 03 BCS &12d8 ; update_next_torpedo ; unplot_torpedo &12d5 20 5a 14 JSR &145a ; plot_starship_torpedo ; update_next_torpedo &12d8 a5 80 LDA &80 ; starship_torpedo_address_low &12da 18 CLC &12db 69 09 ADC #&09 &12dd 85 80 STA &80 ; starship_torpedo_address_low &12df 90 02 BCC &12e3 &12e1 e6 81 INC &81 ; starship_torpedo_address_high &12e3 a5 82 LDA &82 ; starship_torpedo_tail_address_low &12e5 18 CLC &12e6 69 09 ADC #&09 &12e8 85 82 STA &82 ; starship_torpedo_tail_address_low &12ea 90 02 BCC &12ee &12ec e6 83 INC &83 ; starship_torpedo_tail_address_high &12ee ce 55 0e DEC &0e55 ; torpedoes_still_to_consider &12f1 f0 03 BEQ &12f6 ; leave &12f3 4c 33 12 JMP &1233 ; plot_starship_torpedoes_loop ; leave &12f6 60 RTS ; fire_starship_torpedo &12f7 ad 57 26 LDA &2657 ; number_of_live_starship_torpedoes &12fa cd 51 0e CMP &0e51 ; maximum_number_of_starship_torpedoes &12fd b0 23 BCS &1322 ; leave &12ff ee 57 26 INC &2657 ; number_of_live_starship_torpedoes &1302 ee 58 26 INC &2658 ; starship_fired_torpedo &1305 ad 4b 0e LDA &0e4b ; starship_torpedo_table_address_low &1308 85 80 STA &80 ; starship_torpedo_address_low &130a ad 4c 0e LDA &0e4c ; starship_torpedo_table_address_high &130d 85 81 STA &81 ; starship_torpedo_address_high &130f a0 00 LDY #&00 &1311 b1 80 LDA (&80),Y ; torpedo_ttl &1313 f0 0e BEQ &1323 ; empty_torpedo_slot &1315 a5 80 LDA &80 ; starship_torpedo_table_address_low &1317 18 CLC &1318 69 09 ADC #&09 &131a 85 80 STA &80 ; starship_torpedo_table_address_low &131c 90 f3 BCC &1311 &131e e6 81 INC &81 ; starship_torpedo_table_address_high &1320 d0 ef BNE &1311 ; leave &1322 60 RTS ; empty_torpedo_slot &1323 ad 53 0e LDA &0e53 ; starship_torpedoes_time_to_live &1326 91 80 STA (&80),Y ; torpedo_ttl &1328 a5 80 LDA &80 ; starship_torpedo_address_low &132a 18 CLC &132b 69 04 ADC #&04 &132d 85 82 STA &82 ; starship_torpedo_tail_address_low &132f a5 81 LDA &81 ; starship_torpedo_address_high &1331 69 00 ADC #&00 &1333 85 83 STA &83 ; starship_torpedo_tail_address_high &1335 c8 INY &1336 a9 7f LDA #&7f &1338 91 80 STA (&80),Y ; torpedo_x_fraction &133a 91 82 STA (&82),Y ; torpedo_tail_x_fraction &133c c8 INY &133d 91 80 STA (&80),Y ; torpedo_x_pixels &133f 91 82 STA (&82),Y ; torpedo_tail_x_pixels &1341 c8 INY &1342 a9 80 LDA #&80 &1344 91 80 STA (&80),Y ; torpedo_y_fraction &1346 a9 90 LDA #&90 &1348 91 82 STA (&82),Y ; torpedo_tail_y_fraction &134a c8 INY &134b a9 75 LDA #&75 &134d 91 80 STA (&80),Y ; torpedo_y_pixels &134f a9 77 LDA #&77 &1351 91 82 STA (&82),Y ; torpedo_tail_y_pixels &1353 a9 00 LDA #&00 &1355 8d e0 1c STA &1ce0 ; how_enemy_ship_was_damaged &1358 20 9d 15 JSR &159d ; check_for_collision_with_enemy_ships &135b b0 03 BCS &1360 ; leave &135d 4c 5a 14 JMP &145a ; plot_starship_torpedo ; leave &1360 60 RTS &1361 ea NOP ; plot_big_torpedo &1362 e6 7a INC &7a ; x &1364 20 64 0f JSR &0f64 ; eor_pixel &1367 e6 7b INC &7b ; y &1369 20 64 0f JSR &0f64 ; eor_pixel &136c c6 7a DEC &7a ; x &136e 20 64 0f JSR &0f64 ; eor_pixel &1371 e6 7b INC &7b ; y &1373 20 64 0f JSR &0f64 ; eor_pixel &1376 c6 7a DEC &7a ; x &1378 c6 7b DEC &7b ; y &137a 20 64 0f JSR &0f64 ; eor_pixel &137d c6 7b DEC &7b ; y &137f 20 64 0f JSR &0f64 ; eor_pixel &1382 c6 7b DEC &7b ; y &1384 e6 7a INC &7a ; x &1386 20 64 0f JSR &0f64 ; eor_pixel &1389 60 RTS ; plot_expiring_torpedo &138a a0 02 LDY #&02 &138c b1 80 LDA (&80),Y ; torpedo_x_pixels &138e 85 7a STA &7a ; x &1390 a0 04 LDY #&04 &1392 b1 80 LDA (&80),Y ; torpedo_y_pixels &1394 85 7b STA &7b ; y &1396 20 64 0f JSR &0f64 ; eor_pixel &1399 e6 7b INC &7b ; y &139b 20 64 0f JSR &0f64 ; eor_pixel &139e e6 7a INC &7a ; x &13a0 20 64 0f JSR &0f64 ; eor_pixel &13a3 e6 7a INC &7a ; x &13a5 c6 7b DEC &7b ; y &13a7 20 64 0f JSR &0f64 ; eor_pixel &13aa c6 7a DEC &7a ; x &13ac 20 64 0f JSR &0f64 ; eor_pixel &13af c6 7b DEC &7b ; y &13b1 20 64 0f JSR &0f64 ; eor_pixel &13b4 c6 7a DEC &7a ; x &13b6 20 64 0f JSR &0f64 ; eor_pixel &13b9 c6 7a DEC &7a ; x &13bb 20 64 0f JSR &0f64 ; eor_pixel &13be c6 7a DEC &7a ; x &13c0 e6 7b INC &7b ; y &13c2 20 64 0f JSR &0f64 ; eor_pixel &13c5 e6 7a INC &7a ; x &13c7 20 64 0f JSR &0f64 ; eor_pixel &13ca e6 7b INC &7b ; y &13cc 20 64 0f JSR &0f64 ; eor_pixel &13cf 60 RTS ; update_stars &13d0 ad 49 0e LDA &0e49 ; star_table_address_low &13d3 85 80 STA &80 ; star_address_low &13d5 ad 4a 0e LDA &0e4a ; star_table_address_high &13d8 85 81 STA &81 ; star_address_high &13da ad 50 0e LDA &0e50 ; maximum_number_of_stars &13dd 8d 54 0e STA &0e54 ; stars_still_to_consider ; update_stars_loop &13e0 a0 00 LDY #&00 &13e2 20 e6 0f JSR &0fe6 ; update_object_position_for_starship_rotation_and_speed &13e5 20 64 0f JSR &0f64 ; eor_pixel &13e8 a0 01 LDY #&01 &13ea b1 80 LDA (&80),Y ; star_x_pixels &13ec 85 7a STA &7a ; x &13ee a0 03 LDY #&03 &13f0 b1 80 LDA (&80),Y ; star_y_pixels &13f2 85 7b STA &7b ; y &13f4 20 64 0f JSR &0f64 ; eor_pixel &13f7 a5 80 LDA &80 ; star_address_low &13f9 18 CLC &13fa 69 04 ADC #&04 &13fc 85 80 STA &80 ; star_address_low &13fe 90 02 BCC &1402 &1400 e6 81 INC &81 ; star_address_high &1402 ce 54 0e DEC &0e54 ; stars_still_to_consider &1405 d0 d9 BNE &13e0 ; update_stars_loop &1407 60 RTS ; unplot_long_range_scanner_if_shields_inactive &1408 ad 56 0e LDA &0e56 ; starship_shields_active &140b f0 4b BEQ &1458 ; leave &140d a9 00 LDA #&00 &140f 8d 56 0e STA &0e56 ; starship_shields_active &1412 20 38 14 JSR &1438 ; plot_top_and_right_edge_of_long_range_scanner_without_text &1415 20 19 30 JSR &3019 ; plot_enemy_ships_on_scanners &1418 a0 1f LDY #&1f # Pixel in centre of long range scanner &141a 84 7a STY &7a ; x &141c c8 INY &141d 84 7b STY &7b ; y &141f e6 79 INC &79 ; screen_start_high # Change origin to top left of long range scanner &1421 20 0e 0f JSR &0f0e ; unset_pixel &1424 c6 79 DEC &79 ; screen_start_high # Restore origin &1426 20 bd 22 JSR &22bd ; plot_shields_text &1429 60 RTS &142a ea NOP ; plot_top_and_right_edge_of_long_range_scanner_with_blank_text &142b ad 56 0e LDA &0e56 ; starship_shields_active &142e d0 28 BNE &1458 ; leave &1430 a9 01 LDA #&01 &1432 8d 56 0e STA &0e56 ; starship_shields_active &1435 20 c9 22 JSR &22c9 ; plot_blank_text ; plot_top_and_right_edge_of_long_range_scanner_without_text &1438 e6 79 INC &79 ; screen_start_high # Change origin to top left of long range scanner &143a a9 3f LDA #&3f &143c 85 7a STA &7a ; x &143e a9 00 LDA #&00 &1440 85 7b STA &7b ; y ; plot_top_edge_loop &1442 20 64 0f JSR &0f64 ; eor_pixel &1445 c6 7a DEC &7a ; x &1447 10 f9 BPL &1442 ; plot_top_edge_loop &1449 a9 3f LDA #&3f &144b 85 7b STA &7b ; y &144d 85 7a STA &7a ; x ; plot_right_edge_loop &144f 20 64 0f JSR &0f64 ; eor_pixel &1452 c6 7b DEC &7b ; y &1454 d0 f9 BNE &144f ; plot_right_edge_loop &1456 c6 79 DEC &79 # Restore origin &1458 60 RTS &1459 ea NOP ; plot_starship_torpedo &145a a0 02 LDY #&02 ; x_pixels # Plot pixel for head of torpedo &145c b1 80 LDA (&80),Y ; torpedo_x_pixels &145e 85 7a STA &7a ; x &1460 a0 04 LDY #&04 ; y_pixels &1462 b1 80 LDA (&80),Y ; torpedo_y_pixels &1464 85 7b STA &7b ; y &1466 20 64 0f JSR &0f64 ; eor_pixel &1469 ad 5b 26 LDA &265b ; starship_torpedo_type &146c f0 03 BEQ &1471 ; small_starship_torpedoes &146e 4c 62 13 JMP &1362 ; plot_big_torpedo ; small_starship_torpedoes &1471 a0 02 LDY #&02 ; x_pixels # Plot pixel for tail of torpedo &1473 b1 82 LDA (&82),Y ; torpedo_tail_x_pixels &1475 85 7a STA &7a ; x &1477 a0 04 LDY #&04 ; y_pixels &1479 b1 82 LDA (&82),Y ; torpedo_tail_y_pixels &147b 85 7b STA &7b ; y &147d 20 64 0f JSR &0f64 ; eor_pixel &1480 a0 01 LDY #&01 ; x_fraction # Plot pixel for middle of torpedo &1482 b1 80 LDA (&80),Y ; torpedo_x_fraction &1484 18 CLC &1485 71 82 ADC (&82),Y ; torpedo_tail_x_fraction &1487 c8 INY ; x_pixels &1488 b1 80 LDA (&80),Y ; torpedo_x_pixels &148a 71 82 ADC (&82),Y ; torpedo_tail_x_pixels &148c 6a ROR A &148d 85 7a STA &7a ; x &148f c8 INY ; y_fraction &1490 b1 80 LDA (&80),Y ; torpedo_y_fraction &1492 18 CLC &1493 71 82 ADC (&82),Y ; torpedo_tail_y_fraction &1495 c8 INY ; y_pixels &1496 b1 80 LDA (&80),Y ; torpedo_y_pixels &1498 71 82 ADC (&82),Y ; torpedo_tail_y_pixels &149a 6a ROR A &149b 85 7b STA &7b ; y &149d 20 64 0f JSR &0f64 ; eor_pixel &14a0 60 RTS ; unused &14a1 ff ff ff ; apply_rotation_to_starship_angle &14a4 a9 00 LDA #&00 &14a6 8d 33 0e STA &0e33 ; starship_angle_delta &14a9 ae 03 0f LDX &0f03 ; starship_rotation_magnitude &14ac f0 23 BEQ &14d1 &14ae ad 32 0e LDA &0e32 ; starship_angle_fraction &14b1 ac 02 0f LDY &0f02 ; starship_rotation &14b4 10 0d BPL &14c3 ; subtract_fraction ; add_fraction &14b6 18 CLC &14b7 69 52 ADC #&52 &14b9 90 03 BCC &14be &14bb ce 33 0e DEC &0e33 ; starship_angle_delta &14be ca DEX &14bf d0 f5 BNE &14b6 ; add_fraction &14c1 f0 0b BEQ &14ce ; set_starship_angle_fraction ; subtract_fraction &14c3 38 SEC &14c4 e9 52 SBC #&52 &14c6 b0 03 BCS &14cb &14c8 ee 33 0e INC &0e33 ; starship_angle_delta &14cb ca DEX &14cc d0 f5 BNE &14c3 ; subtract_fraction ; set_starship_angle_fraction &14ce 8d 32 0e STA &0e32 ; starship_angle_fraction &14d1 60 RTS ; update_enemy_torpedoes &14d2 a9 01 LDA #&01 &14d4 8d e0 1c STA &1ce0 ; how_enemy_ship_was_damaged # 1 = collision with their torpedoes &14d7 ad 52 0e LDA &0e52 ; maximum_number_of_enemy_torpedoes &14da 8d 55 0e STA &0e55 ; torpedoes_still_to_consider &14dd ad 3d 0e LDA &0e3d ; enemy_torpedo_table_address_low &14e0 85 80 STA &80 ; enemy_torpedo_address_low &14e2 ad 3e 0e LDA &0e3e ; enemy_torpedo_table_address_high &14e5 85 81 STA &81 ; enemy_torpedo_address_high ; update_enemy_torpedoes_loop &14e7 a0 00 LDY #&00 &14e9 b1 80 LDA (&80),Y ; torpedo_ttl &14eb d0 03 BNE &14f0 ; enemy_torpedo_in_slot &14ed 4c 89 15 JMP &1589 ; move_to_next_enemy_torpedo ; enemy_torpedo_in_slot &14f0 38 SEC &14f1 e9 01 SBC #&01 # Decrease torpedo TTL &14f3 91 80 STA (&80),Y ; torpedo_ttl &14f5 d0 06 BNE &14fd ; enemy_torpedo_still_alive &14f7 20 8a 13 JSR &138a ; plot_expiring_torpedo &14fa 4c 89 15 JMP &1589 ; move_to_next_enemy_torpedo ; enemy_torpedo_still_alive &14fd 20 11 16 JSR &1611 ; plot_enemy_torpedo &1500 a0 01 LDY #&01 &1502 20 e6 0f JSR &0fe6 ; update_object_position_for_starship_rotation_and_speed &1505 a0 05 LDY #&05 &1507 b1 80 LDA (&80),Y ; torpedo_angle &1509 18 CLC &150a 6d 33 0e ADC &0e33 ; starship_angle_delta &150d 91 80 STA (&80),Y ; torpedo_angle &150f 4a LSR A &1510 4a LSR A &1511 4a LSR A &1512 aa TAX &1513 88 DEY &1514 bd 78 0e LDA &0e78,X ; cosine_table &1517 18 CLC &1518 71 80 ADC (&80),Y ; torpedo_y_pixels &151a 91 80 STA (&80),Y ; torpedo_y_pixels &151c 38 SEC &151d e5 7b SBC &7b ; sine_y_plus_cosine_x_pixels &151f b0 02 BCS &1523 ; skip_inversion &1521 49 ff EOR #&ff ; skip_inversion &1523 c9 40 CMP #&40 # Remove torpedo if off screen &1525 b0 15 BCS &153c ; remove_torpedo &1527 a0 02 LDY #&02 &1529 bd 58 0e LDA &0e58,X ; sine_table &152c 18 CLC &152d 71 80 ADC (&80),Y ; torpedo_x_pixels &152f 91 80 STA (&80),Y ; torpedo_x_pixels &1531 38 SEC &1532 e5 7a SBC &7a ; sine_y_plus_cosine_x_fraction &1534 b0 02 BCS &1538 ; skip_uninversion &1536 49 ff EOR #&ff ; skip_uninversion &1538 c9 40 CMP #&40 &153a 90 08 BCC &1544 ; consider_collisions ; remove_torpedo &153c a9 00 LDA #&00 &153e a8 TAY &153f 91 80 STA (&80),Y ; torpedo_ttl &1541 4c 89 15 JMP &1589 ; move_to_next_enemy_torpedo ; consider_collisions &1544 b1 80 LDA (&80),Y ; torpedo_x_pixels &1546 cd d5 25 CMP &25d5 ; starship_maximum_x_for_collisions_with_enemy_torpedoes &1549 b0 28 BCS &1573 ; enemy_torpedo_missed_starship &154b cd d6 25 CMP &25d6 ; starship_minimum_x_for_collisions_with_enemy_torpedoes &154e 90 23 BCC &1573 ; enemy_torpedo_missed_starship &1550 a0 04 LDY #&04 &1552 b1 80 LDA (&80),Y ; torpedo_y_pixels &1554 cd d7 25 CMP &25d7 ; starship_maximum_y_for_collisions_with_enemy_torpedoes &1557 b0 1a BCS &1573 ; enemy_torpedo_missed_starship &1559 cd d8 25 CMP &25d8 ; starship_minimum_y_for_collisions_with_enemy_torpedoes &155c 90 15 BCC &1573 ; enemy_torpedo_missed_starship &155e 20 8a 13 JSR &138a ; plot_expiring_torpedo &1561 ee dd 1c INC &1cdd ; enemy_torpedo_hits_against_starship &1564 ad d9 1c LDA &1cd9 ; damage_from_enemy_torpedo &1567 20 a3 1a JSR &1aa3 ; incur_damage &156a a0 00 LDY #&00 &156c a9 01 LDA #&01 &156e 91 80 STA (&80),Y ; torpedo_ttl # Remove torpedo next turn &1570 4c 89 15 JMP &1589 ; move_to_next_enemy_torpedo ; enemy_torpedo_missed_starship &1573 20 9d 15 JSR &159d ; check_for_collision_with_enemy_ships &1576 b0 11 BCS &1589 ; move_to_next_enemy_torpedo &1578 a0 00 LDY #&00 &157a b1 80 LDA (&80),Y ; torpedo_ttl &157c c9 02 CMP #&02 &157e b0 06 BCS &1586 &1580 20 8a 13 JSR &138a ; plot_expiring_torpedo # Torpedo has a final frame as a larger explosion &1583 4c 89 15 JMP &1589 ; move_to_next_enemy_torpedo &1586 20 11 16 JSR &1611 ; plot_enemy_torpedo ; move_to_next_enemy_torpedo &1589 a5 80 LDA &80 ; enemy_torpedo_address_low &158b 18 CLC &158c 69 06 ADC #&06 &158e 85 80 STA &80 ; enemy_torpedo_address_low &1590 90 02 BCC &1594 &1592 e6 81 INC &81 ; enemy_torpedo_address_high &1594 ce 55 0e DEC &0e55 ; torpedoes_still_to_consider &1597 f0 03 BEQ &159c ; leave &1599 4c e7 14 JMP &14e7 ; update_enemy_torpedoes_loop ; leave &159c 60 RTS ; check_for_collision_with_enemy_ships &159d a0 02 LDY #&02 &159f b1 80 LDA (&80),Y ; torpedo_x_pixels &15a1 85 84 STA &84 ; torpedo_x_pixels &15a3 a0 04 LDY #&04 &15a5 b1 80 LDA (&80),Y ; torpedo_y_pixels &15a7 85 85 STA &85 ; torpedo_y_pixels &15a9 ad 4f 0e LDA &0e4f ; maximum_number_of_enemy_ships &15ac 8d 54 0e STA &0e54 ; enemy_ships_still_to_consider &15af a2 00 LDX #&00 ; consider_enemy_slot &15b1 bd 80 04 LDA &0480,X ; enemy_ships_on_screen &15b4 d0 4f BNE &1605 ; move_to_next_enemy &15b6 bd 82 04 LDA &0482,X ; enemy_ships_x_pixels &15b9 38 SEC &15ba e5 84 SBC &84 ; torpedo_x_pixels &15bc b0 02 BCS &15c0 ; skip_inversion_x &15be 49 ff EOR #&ff ; skip_inversion_x &15c0 cd 3a 0e CMP &0e3a ; size_of_enemy_ship_for_collisions_with_torpedoes &15c3 b0 40 BCS &1605 ; move_to_next_enemy &15c5 bd 85 04 LDA &0485,X ; enemy_ships_y_pixels &15c8 38 SEC &15c9 e5 85 SBC &85 ; torpedo_y_pixels &15cb b0 02 BCS &15cf ; skip_inversion_y &15cd 49 ff EOR #&ff ; skip_inversion_y &15cf cd 3a 0e CMP &0e3a ; size_of_enemy_ship_for_collisions_with_torpedoes &15d2 b0 31 BCS &1605 ; move_to_next_enemy &15d4 bd 89 04 LDA &0489,X ; enemy_ships_energy &15d7 d0 0a BNE &15e3 ; skip_considering_explosion &15d9 bd 09 04 LDA &0409,X ; enemy_ships_flags_or_explosion_timer &15dc cd 37 0e CMP &0e37 ; frame_of_enemy_ship_explosion_after_which_no_collisions &15df b0 19 BCS &15fa ; collision_occurred &15e1 90 22 BCC &1605 ; move_to_next_enemy ; skip_considering_explosion &15e3 ee de 1c INC &1cde ; enemy_ship_was_hit &15e6 fe 88 04 INC &0488,X ; enemy_ships_temporary_behaviour_flags # Increase enemy_ship_hit_count &15e9 ad e0 1c LDA &1ce0 ; how_enemy_ship_was_damaged &15ec f0 06 BEQ &15f4 &15ee ad 34 0e LDA &0e34 ; damage_to_enemy_ship_from_starship_torpedo &15f1 4c f7 15 JMP &15f7 ; collision_occurred &15f4 ad df 1c LDA &1cdf ; damage_to_enemy_ship_from_other_collision ; collision_occurred &15f7 20 e7 1b JSR &1be7 ; damage_enemy_ship &15fa a0 00 LDY #&00 &15fc a9 01 LDA #&01 &15fe 91 80 STA (&80),Y ; torpedo_ttl # Remove torpedo next turn &1600 20 8a 13 JSR &138a ; plot_expiring_torpedo &1603 38 SEC # The torpedo hit something &1604 60 RTS ; move_to_next_enemy &1605 8a TXA &1606 18 CLC &1607 69 0b ADC #&0b &1609 aa TAX &160a ce 54 0e DEC &0e54 ; enemy_ships_still_to_consider &160d d0 a2 BNE &15b1 ; consider_enemy_slot &160f 18 CLC # The torpedo didn't hit anything &1610 60 RTS ; plot_enemy_torpedo &1611 a0 02 LDY #&02 &1613 b1 80 LDA (&80),Y ; torpedo_x_pixels &1615 85 7a STA &7a ; x &1617 a0 04 LDY #&04 &1619 b1 80 LDA (&80),Y ; torpedo_y_pixels &161b 85 7b STA &7b ; y &161d 20 64 0f JSR &0f64 ; eor_pixel ; enemy_torpedo_type_instruction &1620 60 RTS # actually NOP # if option_enemy_torpedoes == 1 &1621 e6 7a INC &7a ; x &1623 20 64 0f JSR &0f64 ; eor_pixel &1626 e6 7b INC &7b ; y &1628 20 64 0f JSR &0f64 ; eor_pixel &162b c6 7a DEC &7a ; x &162d 20 64 0f JSR &0f64 ; eor_pixel &1630 60 RTS ; apply_velocity_to_enemy_ships &1631 ad 4f 0e LDA &0e4f ; maximum_number_of_enemy_ships &1634 8d 54 0e STA &0e54 ; enemy_ships_still_to_consider &1637 a2 00 LDX #&00 ; apply_velocity_to_enemy_ships_loop &1639 20 fb 10 JSR &10fb ; apply_starship_rotation_and_velocity_to_enemy_ships &163c bd 07 04 LDA &0407,X ; enemy_ships_previous_angle &163f 18 CLC &1640 6d 33 0e ADC &0e33 ; starship_angle_delta &1643 9d 87 04 STA &0487,X ; enemy_ships_angle &1646 bd 08 04 LDA &0408,X ; enemy_ships_velocity &1649 85 88 STA &88 ; enemy_ship_velocity &164b f0 7f BEQ &16cc ; mark_enemy_ship_as_plotted_if_on_starship_screen &164d bd 07 04 LDA &0407,X ; enemy_ships_previous_angle &1650 4a LSR A &1651 4a LSR A &1652 4a LSR A &1653 a8 TAY &1654 b9 58 0e LDA &0e58,Y ; sine_table &1657 85 84 STA &84 ; sine &1659 b9 78 0e LDA &0e78,Y ; cosine_table &165c 85 85 STA &85 ; cosine &165e a0 05 LDY #&05 &1660 a9 00 LDA #&00 &1662 85 75 STA &75 ; sine_enemy_ship_velocity_fraction ; loop_over_bits_of_sine &1664 46 84 LSR &84 ; sine &1666 90 03 BCC &166b ; sine_bit_unset &1668 18 CLC &1669 65 88 ADC &88 ; enemy_ship_velocity ; sine_bit_unset &166b 6a ROR A &166c 66 75 ROR &75 ; sine_enemy_ship_velocity_fraction &166e 88 DEY &166f d0 f3 BNE &1664 ; loop_over_bits_of_sine &1671 a8 TAY &1672 bd 81 04 LDA &0481,X ; enemy_ships_x_fraction &1675 65 75 ADC &75 ; sine_enemy_ship_velocity_fraction &1677 9d 81 04 STA &0481,X ; enemy_ships_x_fraction &167a 98 TYA &167b 7d 82 04 ADC &0482,X ; enemy_ships_x_pixels &167e 9d 82 04 STA &0482,X ; enemy_ships_x_pixels &1681 90 03 BCC &1686 &1683 fe 83 04 INC &0483,X ; enemy_ships_x_screens &1686 a4 84 LDY &84 ; sine &1688 f0 0b BEQ &1695 ; skip_subtraction_sine &168a 38 SEC &168b e5 88 SBC &88 ; enemy_ship_velocity &168d 9d 82 04 STA &0482,X ; enemy_ships_x_pixels &1690 b0 03 BCS &1695 &1692 de 83 04 DEC &0483,X ; enemy_ships_x_screens ; skip_subtraction_sine &1695 a0 05 LDY #&05 &1697 a9 00 LDA #&00 &1699 85 75 STA &75 ; cosine_enemy_ship_velocity_fraction ; loop_over_bits_of_cosine &169b 46 85 LSR &85 ; cosine &169d 90 03 BCC &16a2 ; cosine_bit_unset &169f 18 CLC &16a0 65 88 ADC &88 ; enemy_ship_velocity ; cosine_bit_unset &16a2 6a ROR A &16a3 66 75 ROR &75 ; cosine_enemy_ship_velocity_fraction &16a5 88 DEY &16a6 d0 f3 BNE &169b ; loop_over_bits_of_cosine &16a8 a8 TAY &16a9 bd 84 04 LDA &0484,X ; enemy_ships_y_fraction &16ac 65 75 ADC &75 ; cosine_enemy_ship_velocity_fraction &16ae 9d 84 04 STA &0484,X ; enemy_ships_y_fraction &16b1 98 TYA &16b2 7d 85 04 ADC &0485,X ; enemy_ships_y_pixels &16b5 9d 85 04 STA &0485,X ; enemy_ships_y_pixels &16b8 90 03 BCC &16bd &16ba fe 86 04 INC &0486,X ; enemy_ships_y_screens &16bd a4 85 LDY &85 ; cosine &16bf f0 0b BEQ &16cc ; skip_subtraction_cosine &16c1 38 SEC &16c2 e5 88 SBC &88 ; enemy_ship_velocity &16c4 9d 85 04 STA &0485,X ; enemy_ships_y_pixels &16c7 b0 03 BCS &16cc &16c9 de 86 04 DEC &0486,X ; enemy_ships_y_screens ; skip_subtraction_cosine ; mark_enemy_ship_as_plotted_if_on_starship_screen &16cc a9 7f LDA #&7f &16ce dd 83 04 CMP &0483,X ; enemy_ships_x_screens &16d1 d0 09 BNE &16dc ; enemy_ship_not_on_starship_screen &16d3 dd 86 04 CMP &0486,X ; enemy_ships_y_screens &16d6 d0 04 BNE &16dc ; enemy_ship_not_on_starship_screen &16d8 a9 00 LDA #&00 &16da f0 02 BEQ &16de ; set_enemy_ships_on_screen ; enemy_ship_not_on_starship_screen &16dc a9 01 LDA #&01 ; set_enemy_ships_on_screen &16de 9d 80 04 STA &0480,X ; enemy_ships_on_screen &16e1 8a TXA &16e2 18 CLC &16e3 69 0b ADC #&0b &16e5 aa TAX &16e6 ce 54 0e DEC &0e54 ; enemy_ships_still_to_consider &16e9 f0 03 BEQ &16ee ; leave &16eb 4c 39 16 JMP &1639 ; apply_velocity_to_enemy_ships_loop &16ee 60 RTS ; unused NOPs &16ef ea ea ea ; plot_enemy_ships &16f2 ad 4f 0e LDA &0e4f ; maximum_number_of_enemy_ships &16f5 8d 54 0e STA &0e54 ; enemy_ships_still_to_consider &16f8 a2 00 LDX #&00 ; plot_enemy_ships_loop &16fa bd 00 04 LDA &0400,X ; enemy_ships_previous_on_screen &16fd 8d 2e 0e STA &0e2e ; enemy_ship_was_previously_on_screen &1700 bd 89 04 LDA &0489,X ; enemy_ships_energy &1703 d0 24 BNE &1729 ; enemy_ship_isn't_exploding &1705 ac 54 0e LDY &0e54 ; enemy_ships_still_to_consider &1708 b9 e1 1c LDA &1ce1,Y ; enemy_ships_explosion_number - 1 &170b a8 TAY &170c b9 f6 1c LDA &1cf6,Y ; enemy_explosion_address_low_table - 1 &170f 85 86 STA &86 ; enemy_explosion_address_low &1711 b9 07 1d LDA &1d07,Y ; enemy_explosion_address_high_table - 1 &1714 85 87 STA &87 ; enemy_explosion_address_high &1716 ad 2e 0e LDA &0e2e ; enemy_ship_was_previously_on_screen &1719 d0 06 BNE &1721 ; not_previously_on_screen &171b ce 2e 0e DEC &0e2e ; enemy_ship_was_previously_on_screen &171e 20 b4 1f JSR &1fb4 ; update_enemy_explosion_pieces ; not_previously_on_screen &1721 de 09 04 DEC &0409,X ; enemy_ships_flags_or_explosion_timer &1724 d0 03 BNE &1729 ; explosion_continuing &1726 20 d2 33 JSR &33d2 ; initialise_enemy_ship ; explosion_continuing ; enemy_ship_isn't_exploding &1729 bd 80 04 LDA &0480,X ; enemy_ships_on_screen &172c 8d 2f 0e STA &0e2f ; enemy_ship_was_on_screen &172f d0 0a BNE &173b ; not_on_screen &1731 bd 89 04 LDA &0489,X ; enemy_ships_energy &1734 d0 08 BNE &173e ; skip_extra_delay &1736 ce 2f 0e DEC &0e2f ; enemy_ship_was_on_screen &1739 d0 03 BNE &173e ; skip_extra_delay ; not_on_screen &173b ee 2d 0e INC &0e2d ; number_of_delay_loops ; skip_extra_delay &173e ad 2e 0e LDA &0e2e ; enemy_ship_was_previously_on_screen &1741 f0 08 BEQ &174b ; unplot_enemy_ship &1743 30 09 BMI &174e ; skip_plotting &1745 ee 2d 0e INC &0e2d ; number_of_delay_loops &1748 4c 4e 17 JMP &174e ; skip_unplotting ; unplot_enemy_ship &174b 20 fc 1b JSR &1bfc ; plot_enemy_ship ; skip_plotting &174e bd 87 04 LDA &0487,X ; enemy_ships_angle &1751 9d 07 04 STA &0407,X ; enemy_ships_previous_angle &1754 bd 85 04 LDA &0485,X ; enemy_ships_y_pixels &1757 9d 05 04 STA &0405,X ; enemy_ships_previous_y_pixels &175a bd 82 04 LDA &0482,X ; enemy_ships_x_pixels &175d 9d 02 04 STA &0402,X ; enemy_ships_previous_x_pixels &1760 ad 2f 0e LDA &0e2f ; enemy_ship_was_on_screen &1763 f0 08 BEQ &176d ; plot_enemy_ship_and_copy_position &1765 10 09 BPL &1770 ; copy_position_without_plotting &1767 20 0c 20 JSR &200c ; plot_enemy_ship_explosion &176a 4c 70 17 JMP &1770 ; copy_position_without_plotting ; plot_enemy_ship_and_copy_position &176d 20 fc 1b JSR &1bfc ; plot_enemy_ship ; copy_position_without_plotting &1770 bd 80 04 LDA &0480,X ; enemy_ships_on_screen &1773 9d 00 04 STA &0400,X ; enemy_ships_previous_on_screen &1776 bd 86 04 LDA &0486,X ; enemy_ships_y_screens &1779 9d 06 04 STA &0406,X ; enemy_ships_previous_y_screens &177c bd 84 04 LDA &0484,X ; enemy_ships_y_fraction &177f 9d 04 04 STA &0404,X ; enemy_ships_previous_y_fraction &1782 bd 83 04 LDA &0483,X ; enemy_ships_x_screens &1785 9d 03 04 STA &0403,X ; enemy_ships_previous_x_screens &1788 bd 81 04 LDA &0481,X ; enemy_ships_x_fraction &178b 9d 01 04 STA &0401,X ; enemy_ships_previous_x_fraction &178e 8a TXA &178f 18 CLC &1790 69 0b ADC #&0b &1792 aa TAX &1793 ce 54 0e DEC &0e54 ; enemy_ships_still_to_consider &1796 f0 03 BEQ &179b ; leave &1798 4c fa 16 JMP &16fa ; plot_enemy_ships_loop &179b 60 RTS ; delay_loop &179c a2 02 LDX #&02 ; delay_loop_outer_loop &179e a0 7f LDY #&7f ; delay_loop_inner_loop &17a0 88 DEY &17a1 d0 fd BNE &17a0 ; delay_loop_inner_loop &17a3 ca DEX &17a4 d0 f8 BNE &179e ; delay_loop_outer_loop &17a6 60 RTS ; unused &17a7 ea ea ea ff ff ff ff ff ff ff ff ; shield_state_strings &17b2 1f 22 18 20 4f 4e 20 ; TAB(&22, &18), " ON " &17b9 1f 22 18 20 4f 46 46 ; TAB(&22, &18), " OFF" &17c0 1f 22 18 41 55 54 4f ; TAB(&22, &18), "AUTO" &17c7 1f 20 18 53 68 3a 7e ; TAB(&20, &18), "Sh:~" # Unused string &17ce 0d ; unused &17cf 00 00 ; enemy_ships_collided_with_each_other &17d1 00 ; unused &17d2 00 00 00 00 00 00 ; check_for_starship_collision_with_enemy_ships &17d8 ad 4f 0e LDA &0e4f ; maximum_number_of_enemy_ships &17db 8d 54 0e STA &0e54 ; enemy_ships_still_to_consider &17de a9 00 LDA #&00 &17e0 85 80 STA &80 ; enemy_ship_offset ; check_for_starship_collision_with_enemy_ships_loop &17e2 a6 80 LDX &80 ; enemy_ship_offset &17e4 bd 80 04 LDA &0480,X ; enemy_ships_on_screen &17e7 d0 0d BNE &17f6 ; to_consider_next_enemy_ship &17e9 bd 89 04 LDA &0489,X ; enemy_ships_energy &17ec d0 0b BNE &17f9 ; check_for_collision &17ee bd 09 04 LDA &0409,X ; enemy_ships_flags_or_explosion_timer &17f1 cd 37 0e CMP &0e37 ; frame_of_enemy_ship_explosion_after_which_no_collisions &17f4 b0 03 BCS &17f9 ; check_for_collision ; to_consider_next_enemy_ship &17f6 4c d4 18 JMP &18d4 ; consider_next_enemy_ship ; check_for_collision &17f9 ad c9 1c LDA &1cc9 ; starship_has_exploded &17fc f0 08 BEQ &1806 &17fe ad ce 1c LDA &1cce ; starship_explosion_countdown &1801 cd df 25 CMP &25df ; frame_of_starship_explosion_after_which_no_collisions &1804 90 3e BCC &1844 ; no_collision &1806 bd 82 04 LDA &0482,X ; enemy_ships_x_pixels &1809 cd d9 25 CMP &25d9 ; starship_maximum_x_for_collisions_with_enemy_ships &180c b0 36 BCS &1844 ; no_collision &180e cd da 25 CMP &25da ; starship_minimum_x_for_collisions_with_enemy_ships &1811 90 31 BCC &1844 ; no_collision &1813 bd 85 04 LDA &0485,X ; enemy_ships_y_pixels &1816 cd db 25 CMP &25db ; starship_maximum_y_for_collisions_with_enemy_ships &1819 b0 29 BCS &1844 ; no_collision &181b cd dc 25 CMP &25dc ; starship_minimum_y_for_collisions_with_enemy_ships &181e 90 24 BCC &1844 ; no_collision &1820 bd 89 04 LDA &0489,X ; enemy_ships_energy &1823 f0 18 BEQ &183d ; incur_damage_from_passing_through_explosion &1825 48 PHA &1826 ee de 25 INC &25de ; starship_collided_with_enemy_ship &1829 a9 00 LDA #&00 &182b 9d 89 04 STA &0489,X ; enemy_ships_energy &182e 20 5d 1f JSR &1f5d ; explode_enemy_ship &1831 68 PLA ; energy_ship_energy &1832 4a LSR A &1833 18 CLC &1834 6d 30 0e ADC &0e30 ; additional_damage_from_collision_with_enemy_ship &1837 90 08 BCC &1841 ; incur_damage_from_collision &1839 a9 ff LDA #&ff &183b d0 04 BNE &1841 ; incur_damage_from_collision ; incur_damage_from_passing_through_explosion &183d bd 09 04 LDA &0409,X ; enemy_ships_flags_or_explosion_timer &1840 4a LSR A ; incur_damage_from_collision &1841 20 a3 1a JSR &1aa3 ; incur_damage ; no_collision &1844 86 82 STX &82 ; second_enemy_ship_offset &1846 ae 54 0e LDX &0e54 ; enemy_ships_still_to_consider &1849 ca DEX &184a 8e 55 0e STX &0e55 ; second_enemy_ships_still_to_consider &184d d0 01 BNE &1850 ; check_for_collisions_between_enemy_ships &184f 60 RTS ; check_for_collisions_between_enemy_ships &1850 a5 82 LDA &82 ; second_enemy_ship_offset &1852 18 CLC &1853 69 0b ADC #&0b &1855 85 82 STA &82 ; second_enemy_ship_offset &1857 aa TAX &1858 bd 80 04 LDA &0480,X ; enemy_ships_on_screen &185b d0 6f BNE &18cc ; consider_next_second_enemy_ship # Not if not on screen &185d a4 80 LDY &80 ; enemy_ship_offset &185f bd 82 04 LDA &0482,X ; enemy_ships_x_pixels &1862 38 SEC &1863 f9 82 04 SBC &0482,Y ; enemy_ships_x_pixels &1866 b0 02 BCS &186a ; skip_inversion_x &1868 49 ff EOR #&ff ; skip_inversion_x &186a cd 3b 0e CMP &0e3b ; size_of_enemy_ship_for_collisions_between_enemy_ships &186d b0 5d BCS &18cc ; consider_next_second_enemy_ship &186f 8d e0 25 STA &25e0 ; enemy_ships_collision_x_difference &1872 bd 85 04 LDA &0485,X ; enemy_ships_y_pixels &1875 38 SEC &1876 f9 85 04 SBC &0485,Y ; enemy_ships_y_pixels &1879 b0 02 BCS &187d ; skip_inversion_y &187b 49 ff EOR #&ff ; skip_inversion_y &187d cd 3b 0e CMP &0e3b ; size_of_enemy_ship_for_collisions_between_enemy_ships &1880 b0 4a BCS &18cc ; consider_next_second_enemy_ship &1882 8d e1 25 STA &25e1 ; enemy_ships_collision_y_difference &1885 bd 89 04 LDA &0489,X ; enemy_ships_energy &1888 d0 0a BNE &1894 ; second_ship_not_exploding &188a bd 09 04 LDA &0409,X ; enemy_ships_flags_or_explosion_timer &188d cd 37 0e CMP &0e37 ; frame_of_enemy_ship_explosion_after_which_no_collisions &1890 b0 37 BCS &18c9 ; to_collide_enemy_ships &1892 90 38 BCC &18cc ; consider_next_second_enemy_ship ; second_ship_not_exploding &1894 ee d1 17 INC &17d1 ; enemy_ships_collided_with_each_other &1897 38 SEC &1898 ed 31 0e SBC &0e31 ; damage_enemy_ship_incurs_from_collision_with_other_enemy_ship &189b b0 02 BCS &189f &189d a9 00 LDA #&00 &189f 9d 89 04 STA &0489,X ; enemy_ships_energy &18a2 d0 14 BNE &18b8 ; enemy_ship_isn't_destroyed_by_collision &18a4 ad 54 0e LDA &0e54 ; enemy_ships_still_to_consider &18a7 48 PHA &18a8 ad 55 0e LDA &0e55 ; second_enemy_ships_still_to_consider &18ab 8d 54 0e STA &0e54 ; enemy_ships_still_to_consider &18ae 20 5d 1f JSR &1f5d ; explode_enemy_ship &18b1 68 PLA ; enemy_ships_still_to_consider &18b2 8d 54 0e STA &0e54 ; enemy_ships_still_to_consider &18b5 ee dd 25 INC &25dd ; enemy_ship_was_hit_by_collision_with_other_enemy_ship ; enemy_ship_isn't_destroyed_by_collision &18b8 bd 0a 04 LDA &040a,X ; enemy_ships_type &18bb c9 04 CMP #&04 &18bd 90 0a BCC &18c9 ; to_collide_enemy_ships &18bf 29 03 AND #&03 # Uncloak ship in collision &18c1 9d 0a 04 STA &040a,X ; enemy_ships_type &18c4 a9 01 LDA #&01 &18c6 9d 00 04 STA &0400,X ; enemy_ships_previous_on_screen ; to_collide_enemy_ships &18c9 4c e0 27 JMP &27e0 ; collide_enemy_ships # this comes back at &18cc ; consider_next_second_enemy_ship &18cc ce 55 0e DEC &0e55 ; second_enemy_ships_still_to_consider &18cf f0 03 BEQ &18d4 ; consider_next_enemy_ship &18d1 4c 50 18 JMP &1850 ; check_for_collisions_between_enemy_ships ; consider_next_enemy_ship &18d4 a5 80 LDA &80 ; enemy_ship_offset &18d6 18 CLC &18d7 69 0b ADC #&0b &18d9 85 80 STA &80 ; enemy_ship_offset &18db ce 54 0e DEC &0e54 ; enemy_ships_still_to_consider &18de f0 03 BEQ &18e3 ; leave &18e0 4c e2 17 JMP &17e2 ; check_for_starship_collision_with_enemy_ships_loop &18e3 60 RTS ; plot_segment &18e4 20 4a 0f JSR &0f4a ; eor_pixel_within_box_around_origin &18e7 a4 78 LDY &78 ; segment_angle &18e9 b9 98 0e LDA &0e98,Y ; segment_angle_to_x_y_deltas_table ; consider_change_to_x &18ec 4a LSR A ; bit_1 &18ed 90 07 BCC &18f6 ; bit_1_unset &18ef 4a LSR A ; bit_2 &18f0 b0 07 BCS &18f9 ; bit_2_set &18f2 c6 7a DEC &7a ; x &18f4 90 05 BCC &18fb ; consider_change_to_y ; bit_1_unset &18f6 4a LSR A ; bit_2 &18f7 90 02 BCC &18fb ; consider_change_to_y ; bit_2_set &18f9 e6 7a INC &7a ; x ; consider_change_to_y &18fb 4a LSR A ; bit_3 &18fc 90 07 BCC &1905 ; bit_3_unset &18fe 4a LSR A ; bit_4 &18ff b0 07 BCS &1908 ; bit_4_set &1901 c6 7b DEC &7b ; y &1903 90 05 BCC &190a ; make_changes ; bit_3_unset &1905 4a LSR A ; bit_4 &1906 90 02 BCC &190a ; make_changes ; bit_4_set &1908 e6 7b INC &7b ; y ; make_changes &190a a5 78 LDA &78 ; segment_angle &190c 18 CLC &190d 65 72 ADC &72 ; segment_angle_change_per_pixel &190f 29 1f AND #&1f &1911 85 78 STA &78 ; segment_angle &1913 c6 74 DEC &74 ; segment_length &1915 d0 cd BNE &18e4 ; plot_segment &1917 60 RTS ; starship_torpedo_cooldown &1918 00 ; starship_torpedo_cooldown_after_firing &1919 01 ; fire_pressed &191a 00 ; unused &191b 00 ; starship_energy_low &191c 00 ; starship_energy_high &191d 00 ; damage_high &191e 00 ; damage_low &191f 00 ; starship_destroyed &1920 00 ; minimum_energy_value_to_avoid_starship_destruction &1921 04 ; starship_energy_divided_by_sixteen &1922 00 ; starship_energy_regeneration &1923 00 ; starship_automatic_shields &1924 00 ; value_of_x_when_incur_damage_called &1925 00 ; shields_state_delta &1926 00 ; rotation_delta &1927 00 ; starship_rotation_fraction &1928 00 ; strength_of_player_rotation &1929 f0 ; strength_of_rotation_dampers &192a 40 ; starship_energy_drain_from_acceleration &192b 04 ; rotation_damper &192c 00 ; starship_energy_drain_from_non_zero_rotation &192d 04 ; velocity_delta &192e 00 ; starship_acceleration_from_player &192f 40 ; starship_acceleration_from_velocity_damper &1930 20 ; velocity_damper &1931 00 ; maximum_starship_velocity &1932 04 ; enemy_ship_x_plus_half_sine &1933 00 ; enemy_ship_y_plus_half_cosine &1934 00 ; enemy_ship_type &1935 00 ; starship_torpedo_counter &1936 00 ; starship_torpedoes_per_round &1937 04 ; starship_torpedo_cooldown_after_round &1938 02 ; starship_energy_drain_from_firing_torpedo &1939 04 ; previous_starship_automatic_shields &193a 00 ; unused NOPs &193b ea ea ea ea ; handle_player_movement &193f a9 00 LDA #&00 &1941 8d 27 19 STA &1927 ; rotation_delta &1944 8d 2e 19 STA &192e ; velocity_delta &1947 8d 1a 19 STA &191a ; fire_pressed &194a 8d 26 19 STA &1926 ; shields_state_delta &194d ae 18 19 LDX &1918 ; starship_torpedo_cooldown &1950 f0 06 BEQ &1958 ; reset_starship_torpedo_round &1952 ce 18 19 DEC &1918 ; starship_torpedo_cooldown &1955 4c 5e 19 JMP &195e ; skip_reset_starship_torpedo_round ; reset_starship_torpedo_round &1958 ad 37 19 LDA &1937 ; starship_torpedoes_per_round &195b 8d 36 19 STA &1936 ; starship_torpedo_counter ; skip_reset_starship_torpedo_round &195e 20 4b 23 JSR &234b ; check_for_keypresses &1961 ad 20 19 LDA &1920 ; starship_destroyed &1964 f0 03 BEQ &1969 ; starship_isn't_destroyed &1966 4c 70 1a JMP &1a70 ; player_isn't_firing ; starship_isn't_destroyed &1969 ad 2e 19 LDA &192e ; velocity_delta &196c d0 0b BNE &1979 ; player_is_accelerating &196e ad 31 19 LDA &1931 ; velocity_damper &1971 f0 53 BEQ &19c6 ; finished_accelerating &1973 ad 30 19 LDA &1930 ; starship_acceleration_from_velocity_damper &1976 4c a4 19 JMP &19a4 ; set_deceleration ; player_is_accelerating &1979 30 26 BMI &19a1 ; starship_is_decelerating &197b ad 2f 19 LDA &192f ; starship_acceleration_from_player &197e 85 75 STA &75 ; starship_acceleration &1980 18 CLC &1981 6d 01 0f ADC &0f01 ; starship_velocity_low &1984 8d 01 0f STA &0f01 ; starship_velocity_low &1987 90 03 BCC &198c &1989 ee 00 0f INC &0f00 ; starship_velocity_high &198c ad 00 0f LDA &0f00 ; starship_velocity_high &198f cd 32 19 CMP &1932 ; maximum_starship_velocity &1992 90 2c BCC &19c0 ; incur_damage_from_acceleration &1994 ad 32 19 LDA &1932 ; maximum_starship_velocity &1997 8d 00 0f STA &0f00 ; starship_velocity_high &199a a9 00 LDA #&00 &199c 8d 01 0f STA &0f01 ; starship_velocity_low &199f f0 25 BEQ &19c6 ; finished_accelerating ; starship_is_decelerating &19a1 ad 2f 19 LDA &192f ; starship_acceleration_from_player ; set_deceleration &19a4 85 75 STA &75 ; starship_acceleration &19a6 ad 01 0f LDA &0f01 ; starship_velocity_low &19a9 38 SEC &19aa e5 75 SBC &75 ; starship_acceleration &19ac 8d 01 0f STA &0f01 ; starship_velocity_low &19af b0 0f BCS &19c0 ; incur_damage_from_acceleration &19b1 ce 00 0f DEC &0f00 ; starship_velocity_high &19b4 10 0a BPL &19c0 ; incur_damage_from_acceleration &19b6 a9 00 LDA #&00 &19b8 8d 01 0f STA &0f01 ; starship_velocity_low &19bb 8d 00 0f STA &0f00 ; starship_velocity_high &19be f0 06 BEQ &19c6 ; finished_accelerating ; incur_damage_from_acceleration &19c0 ad 2b 19 LDA &192b ; starship_energy_drain_from_acceleration &19c3 20 ba 1a JSR &1aba ; incur_low_damage ; finished_accelerating &19c6 ad 28 19 LDA &1928 ; starship_rotation_fraction &19c9 ac 27 19 LDY &1927 ; rotation_delta &19cc d0 1b BNE &19e9 ; player_is_turning &19ce ac 2c 19 LDY &192c ; rotation_damper &19d1 f0 6e BEQ &1a41 ; finished_rotating &19d3 ae 02 0f LDX &0f02 ; starship_rotation &19d6 10 0a BPL &19e2 ; starship_was_turned_clockwise &19d8 ca DEX &19d9 10 66 BPL &1a41 ; finished_rotating &19db 38 SEC &19dc ed 2a 19 SBC &192a ; strength_of_rotation_dampers &19df 4c ef 19 JMP &19ef ; starship_was_turned_clockwise &19e2 18 CLC &19e3 6d 2a 19 ADC &192a ; strength_of_rotation_dampers &19e6 4c 03 1a JMP &1a03 ; set_starship_rotation_fraction_and_consider_rotating ; player_is_turning &19e9 10 14 BPL &19ff ; player_is_turning_clockwise &19eb 38 SEC &19ec ed 29 19 SBC &1929 ; strength_of_player_rotation &19ef 8d 28 19 STA &1928 ; starship_rotation_fraction &19f2 b0 47 BCS &1a3b ; incur_energy_drain_from_rotation &19f4 a9 7b LDA #&7b # Minimum rotation &19f6 cd 02 0f CMP &0f02 ; starship_rotation &19f9 d0 21 BNE &1a1c ; rotate_starship_anticlockwise &19fb a9 00 LDA #&00 &19fd f0 12 BEQ &1a11 ; set_starship_rotation_fraction ; player_is_turning_clockwise &19ff 18 CLC &1a00 6d 29 19 ADC &1929 ; strength_of_player_rotation ; set_starship_rotation_fraction_and_consider_rotating &1a03 8d 28 19 STA &1928 ; starship_rotation_fraction &1a06 90 33 BCC &1a3b ; incur_energy_drain_from_rotation &1a08 a9 85 LDA #&85 # Maximum rotation &1a0a cd 02 0f CMP &0f02 ; starship_rotation &1a0d d0 08 BNE &1a17 ; rotate_starship_clockwise &1a0f a9 ff LDA #&ff ; set_starship_rotation_fraction &1a11 8d 28 19 STA &1928 ; starship_rotation_fraction &1a14 4c 41 1a JMP &1a41 ; finished_rotating ; rotate_starship_clockwise &1a17 ee 02 0f INC &0f02 ; starship_rotation &1a1a d0 03 BNE &1a1f ; rotate_starship_anticlockwise &1a1c ce 02 0f DEC &0f02 ; starship_rotation &1a1f 18 CLC &1a20 ad 02 0f LDA &0f02 ; starship_rotation &1a23 30 04 BMI &1a29 ; skip_inversion &1a25 49 ff EOR #&ff &1a27 69 01 ADC #&01 ; skip_inversion &1a29 69 80 ADC #&80 &1a2b a8 TAY &1a2c 8d 03 0f STA &0f03 ; starship_rotation_magnitude &1a2f b9 c4 0e LDA &0ec4,Y ; starship_rotation_sine_table &1a32 8d 05 0f STA &0f05 ; starship_rotation_sine_magnitude &1a35 b9 be 0e LDA &0ebe,Y ; starship_rotation_cosine_table &1a38 8d 04 0f STA &0f04 ; starship_rotation_cosine ; incur_energy_drain_from_rotation &1a3b ad 2d 19 LDA &192d ; starship_energy_drain_from_non_zero_rotation &1a3e 20 ba 1a JSR &1aba ; incur_low_damage ; finished_rotating &1a41 ad 1a 19 LDA &191a ; fire_pressed &1a44 f0 2a BEQ &1a70 ; player_isn't_firing &1a46 ad 18 19 LDA &1918 ; starship_torpedo_cooldown &1a49 d0 25 BNE &1a70 ; player_isn't_firing &1a4b ce 36 19 DEC &1936 ; starship_torpedo_counter &1a4e d0 0c BNE &1a5c ; not_end_of_round &1a50 ad 37 19 LDA &1937 ; starship_torpedoes_per_round &1a53 8d 36 19 STA &1936 ; starship_torpedo_counter &1a56 ad 38 19 LDA &1938 ; starship_torpedo_cooldown_after_round &1a59 4c 5f 1a JMP &1a5f ; set_starship_torpedo_cooldown ; not_end_of_round &1a5c ad 19 19 LDA &1919 ; starship_torpedo_cooldown_after_firing ; set_starship_torpedo_cooldown &1a5f 8d 18 19 STA &1918 ; starship_torpedo_cooldown &1a62 20 f7 12 JSR &12f7 ; fire_starship_torpedo &1a65 ad 58 26 LDA &2658 ; starship_fired_torpedo &1a68 f0 06 BEQ &1a70 ; player_isn't_firing &1a6a ad 39 19 LDA &1939 ; starship_energy_drain_from_firing_torpedo &1a6d 20 ba 1a JSR &1aba ; incur_low_damage ; player_isn't_firing &1a70 20 ae 45 JSR &45ae ; plot_auto_shields_string &1a73 ad 24 19 LDA &1924 ; starship_automatic_shields &1a76 8d 3a 19 STA &193a ; previous_starship_automatic_shields &1a79 f0 08 BEQ &1a83 ; skip_shield_activation &1a7b ad 59 26 LDA &2659 ; scanner_failure_duration &1a7e d0 03 BNE &1a83 ; skip_shield_activation &1a80 20 a1 1b JSR &1ba1 ; activate_shields_when_enemy_ship_enters_main_square ; skip_shield_activation &1a83 ad 26 19 LDA &1926 ; shields_state_delta &1a86 f0 16 BEQ &1a9e ; leave &1a88 a2 00 LDX #&00 ; ON &1a8a 8e 24 19 STX &1924 ; starship_automatic_shields &1a8d a8 TAY &1a8e 30 08 BMI &1a98 ; plot_shields_on_and_consider_activation &1a90 a2 07 LDX #&07 ; OFF &1a92 20 9d 45 JSR &459d ; plot_shields_string_and_something &1a95 4c 2b 14 JMP &142b ; plot_top_and_right_edge_of_long_range_scanner_with_blank_text ; plot_shields_on_and_consider_activation &1a98 20 9d 45 JSR &459d ; plot_shields_string_and_something &1a9b 4c 08 14 JMP &1408 ; unplot_long_range_scanner_if_shields_inactive &1a9e 60 RTS ; unused NOPs &1a9f ea ea ea ea ; incur_damage &1aa3 8e 25 19 STX &1925 ; value_of_x_when_incur_damage_called &1aa6 ae 56 0e LDX &0e56 ; starship_shields_active &1aa9 f0 0c BEQ &1ab7 ; shields_are_active &1aab 0a ASL A # Four times the damage when shields off &1aac 90 03 BCC &1ab1 &1aae ee 1e 19 INC &191e ; damage_high &1ab1 0a ASL A &1ab2 90 03 BCC &1ab7 &1ab4 ee 1e 19 INC &191e ; damage_high ; shields_are_active &1ab7 ae 25 19 LDX &1925 ; value_of_x_when_incur_damage_called ; incur_low_damage &1aba 18 CLC &1abb 6d 1f 19 ADC &191f ; damage_low &1abe 8d 1f 19 STA &191f ; damage_low &1ac1 90 03 BCC &1ac6 &1ac3 ee 1e 19 INC &191e ; damage_high &1ac6 60 RTS ; update_various_starship_statuses_on_screen &1ac7 20 d1 1a JSR &1ad1 ; apply_damage_to_starship_energy &1aca 20 45 2f JSR &2f45 ; plot_starship_velocity_and_rotation_on_gauges &1acd 4c f3 25 JMP &25f3 ; flash_energy_when_low ; unused &1ad0 60 RTS ; apply_damage_to_starship_energy &1ad1 ad 1c 19 LDA &191c ; starship_energy_low &1ad4 38 SEC &1ad5 ed 1f 19 SBC &191f ; damage_low &1ad8 8d 1c 19 STA &191c ; starship_energy_low &1adb ad 1d 19 LDA &191d ; starship_energy_high &1ade ed 1e 19 SBC &191e ; damage_high &1ae1 8d 1d 19 STA &191d ; starship_energy_high &1ae4 ad 1c 19 LDA &191c ; starship_energy_low &1ae7 18 CLC &1ae8 6d 23 19 ADC &1923 ; starship_energy_regeneration &1aeb 8d 1c 19 STA &191c ; starship_energy_low &1aee 90 03 BCC &1af3 &1af0 ee 1d 19 INC &191d ; starship_energy_high &1af3 ad 1d 19 LDA &191d ; starship_energy_high &1af6 10 0d BPL &1b05 ; starship_still_has_energy &1af8 20 af 1d JSR &1daf ; explode_starship &1afb a9 00 LDA #&00 &1afd 8d 1c 19 STA &191c ; starship_energy_low &1b00 8d 1d 19 STA &191d ; starship_energy_high &1b03 f0 17 BEQ &1b1c ; reset_damage_counter ; starship_still_has_energy &1b05 c9 0c CMP #&0c &1b07 90 13 BCC &1b1c ; reset_damage_counter &1b09 d0 07 BNE &1b12 &1b0b ad 1c 19 LDA &191c ; starship_energy_low &1b0e c9 81 CMP #&81 &1b10 90 0a BCC &1b1c &1b12 a9 0c LDA #&0c # Maximum shields = &0c80 &1b14 8d 1d 19 STA &191d ; starship_energy_high &1b17 a9 80 LDA #&80 &1b19 8d 1c 19 STA &191c ; starship_energy_low ; reset_damage_counter &1b1c a9 00 LDA #&00 &1b1e 8d 1f 19 STA &191f ; damage_low &1b21 8d 1e 19 STA &191e ; damage_high &1b24 8d 20 19 STA &1920 ; starship_destroyed &1b27 ad 1d 19 LDA &191d ; starship_energy_high &1b2a 85 84 STA &84 ; high &1b2c ad 1c 19 LDA &191c ; starship_energy_low &1b2f 46 84 LSR &84 ; high &1b31 6a ROR A &1b32 46 84 LSR &84 ; high &1b34 6a ROR A &1b35 46 84 LSR &84 ; high &1b37 6a ROR A &1b38 46 84 LSR &84 ; high &1b3a 6a ROR A &1b3b cd 21 19 CMP &1921 ; minimum_energy_value_to_avoid_starship_destruction # &04 * 16 = &0040 &1b3e b0 03 BCS &1b43 ; skip_destruction &1b40 ee 20 19 INC &1920 ; starship_destroyed ; skip_destruction &1b43 cd 22 19 CMP &1922 ; starship_energy_divided_by_sixteen &1b46 f0 58 BEQ &1ba0 ; leave ; plot_starship_energy_bars &1b48 ae 22 19 LDX &1922 ; starship_energy_divided_by_sixteen &1b4b 8d 22 19 STA &1922 ; starship_energy_divided_by_sixteen &1b4e 85 72 STA &72 ; end_energy &1b50 e4 72 CPX &72 ; end_energy &1b52 b0 03 BCS &1b57 ; skip_swapping_start_and_end &1b54 86 72 STX &72 ; end_energy &1b56 aa TAX ; skip_swapping_start_and_end &1b57 86 73 STX &73 ; start_energy &1b59 a2 03 LDX #&03 &1b5b a5 73 LDA &73 ; start_energy ; calculate_pixel_position_in_bar &1b5d c9 33 CMP #&33 &1b5f 90 06 BCC &1b67 ; finished_calculating_pixel_position_in_bar &1b61 38 SEC &1b62 e9 32 SBC #&32 &1b64 ca DEX &1b65 10 f6 BPL &1b5d ; calculate_pixel_position_in_bar ; finished_calculating_pixel_position_in_bar &1b67 18 CLC &1b68 69 0c ADC #&0c &1b6a 85 7a STA &7a ; x &1b6c 8a TXA &1b6d 0a ASL A &1b6e 0a ASL A &1b6f 0a ASL A &1b70 18 CLC &1b71 69 95 ADC #&95 &1b73 85 7b STA &7b ; y &1b75 e6 79 INC &79 ; screen_start_high # Change origin to top left of long range scanner ; plot_energy_change_loop &1b77 a9 05 LDA #&05 &1b79 20 cf 1b JSR &1bcf ; plot_vertical_line &1b7c c6 7a DEC &7a ; x &1b7e a5 7b LDA &7b ; y # Restore y &1b80 38 SEC &1b81 e9 05 SBC #&05 &1b83 85 7b STA &7b ; y &1b85 a9 0c LDA #&0c &1b87 c5 7a CMP &7a ; x &1b89 90 0b BCC &1b96 ; skip_moving_to_next_bar &1b8b a5 7b LDA &7b ; y &1b8d 18 CLC &1b8e 69 08 ADC #&08 &1b90 85 7b STA &7b ; y &1b92 a9 3e LDA #&3e &1b94 85 7a STA &7a ; x ; skip_moving_to_next_bar &1b96 c6 73 DEC &73 ; start_energy &1b98 a5 73 LDA &73 ; start_energy &1b9a c5 72 CMP &72 ; end_energy &1b9c d0 d9 BNE &1b77 ; plot_energy_change_loop &1b9e c6 79 DEC &79 ; screen_start_high ; leave &1ba0 60 RTS ; activate_shields_when_enemy_ship_enters_main_square &1ba1 ad 4f 0e LDA &0e4f ; maximum_number_of_enemy_ships &1ba4 8d 54 0e STA &0e54 ; enemy_ships_still_to_consider &1ba7 a2 00 LDX #&00 ; activate_shields_when_enemy_ship_enters_main_square_loop &1ba9 bd 80 04 LDA &0480,X ; enemy_ships_on_screen &1bac f0 12 BEQ &1bc0 ; enemy_ship_is_on_screen &1bae 8a TXA &1baf 18 CLC &1bb0 69 0b ADC #&0b &1bb2 aa TAX &1bb3 ce 54 0e DEC &0e54 ; enemy_ships_still_to_consider &1bb6 d0 f1 BNE &1ba9 ; activate_shields_when_enemy_ship_enters_main_square_loop &1bb8 ad 56 0e LDA &0e56 ; starship_shields_active &1bbb d0 0b BNE &1bc8 ; leave &1bbd 4c 2b 14 JMP &142b ; plot_top_and_right_edge_of_long_range_scanner_with_blank_text ; enemy_ship_is_on_screen &1bc0 ad 56 0e LDA &0e56 ; starship_shields_active &1bc3 f0 03 BEQ &1bc8 ; leave &1bc5 4c 08 14 JMP &1408 ; unplot_long_range_scanner_if_shields_inactive ; leave &1bc8 60 RTS ; unused NOPs &1bc9 ea ea ea ea ea ea ; plot_vertical_line &1bcf 85 84 STA &84 ; height ; plot_vertical_line_loop &1bd1 20 64 0f JSR &0f64 ; eor_pixel &1bd4 e6 7b INC &7b ; y &1bd6 c6 84 DEC &84 ; height &1bd8 d0 f7 BNE &1bd1 ; plot_vertical_line_loop &1bda 60 RTS ; plot_horizontal_line &1bdb 85 84 STA &84 ; width ; plot_horizontal_line_loop &1bdd 20 64 0f JSR &0f64 ; eor_pixel &1be0 e6 7a INC &7a ; x &1be2 c6 84 DEC &84 ; width &1be4 d0 f7 BNE &1bdd ; plot_horizontal_line_loop &1be6 60 RTS ; damage_enemy_ship &1be7 85 75 STA &75 ; damage &1be9 bd 89 04 LDA &0489,X ; enemy_ships_energy &1bec 38 SEC &1bed e5 75 SBC &75 ; damage &1bef b0 02 BCS &1bf3 &1bf1 a9 00 LDA #&00 &1bf3 9d 89 04 STA &0489,X ; enemy_ships_energy &1bf6 d0 03 BNE &1bfb ; leave &1bf8 20 5d 1f JSR &1f5d ; explode_enemy_ship ; leave &1bfb 60 RTS ; plot_enemy_ship &1bfc 86 75 STX &75 ; enemy_ship_number &1bfe bd 0a 04 LDA &040a,X ; enemy_ships_type &1c01 8d 35 19 STA &1935 ; enemy_ship_type &1c04 c9 02 CMP #&02 &1c06 90 03 BCC &1c0b ; enemy_ship_isn't_cloaked &1c08 4c c6 1c JMP &1cc6 ; enemy_ship_is_cloaked ; enemy_ship_isn't_cloaked &1c0b bd 02 04 LDA &0402,X ; enemy_ships_previous_x_pixels &1c0e 85 77 STA &77 ; origin_x &1c10 bd 05 04 LDA &0405,X ; enemy_ships_previous_y_pixels &1c13 85 76 STA &76 ; enemy_ship_y &1c15 bd 07 04 LDA &0407,X ; enemy_ships_previous_angle &1c18 4a LSR A &1c19 4a LSR A &1c1a 4a LSR A &1c1b 85 7c STA &7c ; enemy_ship_angle &1c1d 18 CLC &1c1e 69 10 ADC #&10 &1c20 29 1f AND #&1f &1c22 a8 TAY &1c23 b9 58 0e LDA &0e58,Y ; sine_table &1c26 18 CLC &1c27 10 01 BPL &1c2a ; skip_set_carry_sine &1c29 38 SEC ; skip_set_carry_sine &1c2a 6a ROR A &1c2b 18 CLC &1c2c 65 77 ADC &77 ; origin_x &1c2e 8d 33 19 STA &1933 ; enemy_ship_x_plus_half_sine &1c31 b9 78 0e LDA &0e78,Y ; cosine_table &1c34 18 CLC &1c35 10 01 BPL &1c38 ; skip_set_carry_cosine &1c37 38 SEC ; skip_set_carry_cosine &1c38 6a ROR A &1c39 18 CLC &1c3a 65 76 ADC &76 ; origin_y &1c3c 8d 34 19 STA &1934 ; enemy_ship_y_plus_half_cosine &1c3f a5 7c LDA &7c ; enemy_ship_angle &1c41 18 CLC &1c42 69 03 ADC #&03 &1c44 29 1f AND #&1f &1c46 a8 TAY &1c47 85 78 STA &78 ; segment_angle &1c49 ad 33 19 LDA &1933 ; enemy_ship_x_plus_half_sine &1c4c 18 CLC &1c4d 79 58 0e ADC &0e58,Y ; sine_table &1c50 85 7a STA &7a ; x &1c52 ad 34 19 LDA &1934 ; enemy_ship_y_plus_half_cosine &1c55 18 CLC &1c56 79 78 0e ADC &0e78,Y ; cosine_table &1c59 85 7b STA &7b ; y &1c5b a9 08 LDA #&08 &1c5d 85 74 STA &74 ; segment_length &1c5f a9 01 LDA #&01 &1c61 85 72 STA &72 ; segment_angle_change_per_pixel &1c63 20 e4 18 JSR &18e4 ; plot_segment &1c66 a5 7c LDA &7c ; enemy_ship_angle &1c68 18 CLC &1c69 69 14 ADC #&14 &1c6b 29 1f AND #&1f &1c6d 85 78 STA &78 ; segment_angle &1c6f a9 0a LDA #&0a &1c71 85 74 STA &74 ; segment_length &1c73 a9 ff LDA #&ff &1c75 85 72 STA &72 ; segment_angle_change_per_pixel &1c77 20 e4 18 JSR &18e4 ; plot_segment &1c7a a5 7c LDA &7c ; enemy_ship_angle &1c7c 18 CLC &1c7d 69 15 ADC #&15 &1c7f 29 1f AND #&1f &1c81 85 78 STA &78 ; segment_angle &1c83 a9 09 LDA #&09 &1c85 85 74 STA &74 ; segment_length &1c87 a9 01 LDA #&01 &1c89 85 72 STA &72 ; segment_angle_change_per_pixel &1c8b 20 e4 18 JSR &18e4 ; plot_segment &1c8e ad 35 19 LDA &1935 ; enemy_ship_type &1c91 f0 09 BEQ &1c9c ; regular_ship &1c93 a5 77 LDA &77 ; origin_x &1c95 85 7a STA &7a ; x &1c97 a5 76 LDA &76 ; origin_y &1c99 4c a4 1c JMP &1ca4 ; long_ship ; regular_ship &1c9c ad 33 19 LDA &1933 ; enemy_ship_x_plus_half_sine &1c9f 85 7a STA &7a ; x &1ca1 ad 34 19 LDA &1934 ; enemy_ship_y_plus_half_cosine ; long_ship &1ca4 85 7b STA &7b ; y &1ca6 a5 7c LDA &7c ; enemy_ship_angle &1ca8 18 CLC &1ca9 69 14 ADC #&14 &1cab 29 1f AND #&1f &1cad 85 78 STA &78 ; segment_angle &1caf a9 08 LDA #&08 &1cb1 85 74 STA &74 ; segment_length &1cb3 20 e4 18 JSR &18e4 ; plot_segment &1cb6 a5 7c LDA &7c ; enemy_ship_angle &1cb8 18 CLC &1cb9 69 04 ADC #&04 &1cbb 29 1f AND #&1f &1cbd 85 78 STA &78 ; segment_angle &1cbf a9 09 LDA #&09 &1cc1 85 74 STA &74 ; segment_length &1cc3 20 e4 18 JSR &18e4 ; plot_segment ; enemy_ship_is_cloaked &1cc6 a6 75 LDX &75 ; enemy_ship_number &1cc8 60 RTS ; starship_has_exploded &1cc9 00 ; starship_explosion_address_low &1cca d0 ; starship_explosion_address_high &1ccb 4b ; starship_explosion_size &1ccc 40 ; maximum_starship_explosion_countdown &1ccd 50 ; starship_explosion_countdown &1cce 00 ; number_of_bytes_per_enemy_explosion &1ccf 3f ; create_new_enemy_explosion_piece_after_one_dies &1cd0 00 ; rnd_1 &1cd1 ca ; rnd_2 &1cd2 48 ; unused &1cd3 00 00 00 ; keyboard_or_joystick &1cd6 00 ; sound_enabled &1cd7 00 ; escape_capsule_launched &1cd8 00 ; damage_from_enemy_torpedo &1cd9 10 ; frame_of_starship_explosion_after_which_no_sound &1cda 11 ; escape_capsule_sound_channel &1cdb 00 ; enemy_ship_fired_torpedo &1cdc 00 ; enemy_torpedo_hits_against_starship &1cdd 00 ; enemy_ship_was_hit &1cde 00 ; damage_to_enemy_ship_from_other_collision &1cdf ea ; how_enemy_ship_was_damaged &1ce0 ea ; unused &1ce1 00 ; enemy_ships_explosion_number &1ce2 00 00 00 00 00 00 00 00 ; unused &1cea 00 00 00 00 00 00 00 00 00 00 00 00 00 ; enemy_explosion_address_low_table &1cf7 00 40 80 c0 # Possibility of sixteen enemies? &1cfb 00 40 80 c0 &1cff 00 40 80 c0 &1d03 00 40 80 c0 ; unused &1d07 ff ; enemy_explosion_address_high_table &1d08 4d 4d 4d 4d &1d0c 4e 4e 4e 4e &1d10 4f 4f 4f 4f &1d14 50 50 50 50 ; enemy_explosion_piece_ageing_table &1d18 0f 11 13 15 ; starship_explosion_piece_ageing_table &1d1c 05 06 07 08 09 0a 0b 0c ; plot_stars &1d24 ad 49 0e LDA &0e49 ; star_table_address_low &1d27 85 80 STA &80 ; star_address_low &1d29 ad 4a 0e LDA &0e4a ; star_table_address_high &1d2c 85 81 STA &81 ; star_address_high &1d2e ad 50 0e LDA &0e50 ; maximum_number_of_stars &1d31 8d 54 0e STA &0e54 ; stars_still_to_consider ; plot_stars_loop &1d34 a0 01 LDY #&01 &1d36 b1 80 LDA (&80),Y ; star_x_pixels &1d38 85 7a STA &7a ; x &1d3a a0 03 LDY #&03 &1d3c b1 80 LDA (&80),Y ; star_y_pixels &1d3e 85 7b STA &7b ; y &1d40 20 64 0f JSR &0f64 ; eor_pixel &1d43 a5 80 LDA &80 ; star_address_low &1d45 18 CLC &1d46 69 04 ADC #&04 &1d48 85 80 STA &80 ; star_address_low &1d4a 90 02 BCC &1d4e &1d4c e6 81 INC &81 ; star_address_high &1d4e ce 54 0e DEC &0e54 ; stars_still_to_consider &1d51 d0 e1 BNE &1d34 ; plot_stars_loop &1d53 60 RTS ; unused NOPs &1d54 ea ea ea ea ; initialise_stars_at_random_positions &1d58 ad 49 0e LDA &0e49 ; star_table_address_low &1d5b 85 80 STA &80 ; star_address_low &1d5d ad 4a 0e LDA &0e4a ; star_table_address_high &1d60 85 81 STA &81 ; star_address_high &1d62 ad 50 0e LDA &0e50 ; maximum_number_of_stars &1d65 8d 54 0e STA &0e54 ; stars_still_to_consider ; initialise_stars_at_random_positions_loop &1d68 20 13 21 JSR &2113 ; random_number_generator &1d6b a0 01 LDY #&01 &1d6d ad d1 1c LDA &1cd1 ; rnd_1 &1d70 91 80 STA (&80),Y ; star_x_pixels &1d72 a0 03 LDY #&03 &1d74 ad d2 1c LDA &1cd2 ; rnd_2 &1d77 91 80 STA (&80),Y ; star_y_pixels &1d79 a5 80 LDA &80 ; star_table_address_low &1d7b 18 CLC &1d7c 69 04 ADC #&04 &1d7e 85 80 STA &80 ; star_table_address_low &1d80 90 02 BCC &1d84 &1d82 e6 81 INC &81 ; star_table_address_high &1d84 ce 54 0e DEC &0e54 ; stars_still_to_consider &1d87 d0 df BNE &1d68 ; initialise_stars_at_random_positions &1d89 60 RTS ; unused NOPs &1d8a ea ea ea ea ; plot_starship &1d8e a2 0f LDX #&0f ; plot_starship_top_loop &1d90 bd 00 0c LDA &0c00,X # Eor user-defined characters &1d93 5d 38 6b EOR &6b38,X &1d96 9d 38 6b STA &6b38,X # into screen memory &1d99 ca DEX &1d9a 10 f4 BPL &1d90 ; plot_starship_top_loop &1d9c a2 0f LDX #&0f ; plot_starship_bottom_loop &1d9e bd 10 0c LDA &0c10,X &1da1 5d 78 6c EOR &6c78,X &1da4 9d 78 6c STA &6c78,X &1da7 ca DEX &1da8 10 f4 BPL &1d9e ; plot_starship_bottom_loop &1daa 60 RTS ; unused NOPs &1dab ea ea ea ea ; explode_starship &1daf ad ca 1c LDA &1cca ; starship_explosion_address_low &1db2 85 80 STA &80 ; starship_explosion_piece_address_low &1db4 ad cb 1c LDA &1ccb ; starship_explosion_address_high &1db7 85 81 STA &81 ; starship_explosion_piece_address_high &1db9 ad cc 1c LDA &1ccc ; starship_explosion_size &1dbc 8d 54 0e STA &0e54 ; starship_explosion_pieces_still_to_consider ; plot_starship_explosion_loop &1dbf 20 3d 1e JSR &1e3d ; plot_starship_explosion_piece &1dc2 a5 80 LDA &80 ; starship_explosion_piece_address_low &1dc4 18 CLC &1dc5 69 03 ADC #&03 &1dc7 85 80 STA &80 ; starship_explosion_piece_address_low &1dc9 90 02 BCC &1dcd &1dcb e6 81 INC &81 ; starship_explosion_piece_address_high &1dcd ce 54 0e DEC &0e54 ; starship_explosion_pieces_still_to_consider &1dd0 d0 ed BNE &1dbf ; plot_starship_explosion_loop &1dd2 ee c9 1c INC &1cc9 ; starship_has_exploded &1dd5 ad d1 1c LDA &1cd1 ; rnd_1 &1dd8 09 10 ORA #&10 &1dda 8d d1 1c STA &1cd1 ; rnd_1 &1ddd 20 7c 31 JSR &317c ; turn_scanner_to_static &1de0 4c 8e 1d JMP &1d8e ; plot_starship ; unused NOPs &1de3 ea ea ea ea ea ; plot_starship_explosion &1de8 ce ce 1c DEC &1cce ; starship_explosion_countdown &1deb d0 03 BNE &1df0 ; starship_explosion_continuing &1ded 4c 07 46 JMP &4607 ; end_of_command ; starship_explosion_continuing &1df0 ad ca 1c LDA &1cca ; starship_explosion_address_low &1df3 85 80 STA &80 ; starship_explosion_piece_address_low &1df5 ad cb 1c LDA &1ccb ; starship_explosion_address_high &1df8 85 81 STA &81 ; starship_explosion_piece_address_high &1dfa ad cc 1c LDA &1ccc ; starship_explosion_size &1dfd 8d 54 0e STA &0e54 ; starship_explosion_pieces_still_to_consider &1e00 a0 00 LDY #&00 &1e02 b1 80 LDA (&80),Y ; starship_explosion_piece_age_and_size &1e04 f0 25 BEQ &1e2b ; move_to_next_starship_explosion_piece &1e06 20 3d 1e JSR &1e3d ; plot_starship_explosion_piece &1e09 a0 01 LDY #&01 &1e0b b1 80 LDA (&80),Y ; starship_explosion_piece_segment_angle_or_ageing_rate &1e0d 29 07 AND #&07 &1e0f aa TAX &1e10 bd 1c 1d LDA &1d1c,X ; starship_explosion_piece_ageing_table &1e13 88 DEY &1e14 18 CLC &1e15 71 80 ADC (&80),Y ; starship_explosion_piece_age_and_size &1e17 90 05 BCC &1e1e &1e19 98 TYA &1e1a 91 80 STA (&80),Y ; starship_explosion_piece_age_and_size &1e1c f0 0d BEQ &1e2b &1e1e 91 80 STA (&80),Y ; starship_explosion_piece_age_and_size &1e20 8a TXA &1e21 a0 02 LDY #&02 &1e23 38 SEC &1e24 71 80 ADC (&80),Y ; starship_explosion_piece_two &1e26 91 80 STA (&80),Y ; starship_explosion_piece_two &1e28 20 3d 1e JSR &1e3d ; plot_starship_explosion_piece ; move_to_next_starship_explosion_piece &1e2b a5 80 LDA &80 ; starship_explosion_piece_address_low &1e2d 18 CLC &1e2e 69 03 ADC #&03 &1e30 85 80 STA &80 ; starship_explosion_piece_address_low &1e32 90 02 BCC &1e36 &1e34 e6 81 INC &81 ; starship_explosion_piece_address_high &1e36 ce 54 0e DEC &0e54 ; starship_explosion_pieces_still_to_consider &1e39 d0 c5 BNE &1e00 &1e3b 60 RTS ; unused &1e3c ea ; plot_starship_explosion_piece &1e3d a0 00 LDY #&00 &1e3f b1 80 LDA (&80),Y ; starship_explosion_piece_age_and_size &1e41 29 c0 AND #&c0 &1e43 85 75 STA &75 ; fragment_size_or_segment_type &1e45 a0 02 LDY #&02 &1e47 b1 80 LDA (&80),Y ; starship_explosion_piece_radius &1e49 85 7c STA &7c ; radius &1e4b ad 54 0e LDA &0e54 ; starship_explosion_pieces_still_to_consider &1e4e 29 1f AND #&1f &1e50 aa TAX &1e51 bd 58 0e LDA &0e58,X ; sine_table &1e54 10 05 BPL &1e5b ; skip_inversion_sine &1e56 49 1f EOR #&1f &1e58 18 CLC &1e59 69 01 ADC #&01 ; skip_inversion_sine &1e5b 85 7a STA &7a ; sine &1e5d bd 78 0e LDA &0e78,X ; cosine_table &1e60 10 05 BPL &1e67 ; skip_inversion_cosine &1e62 49 1f EOR #&1f &1e64 18 CLC &1e65 69 01 ADC #&01 ; skip_inversion_cosine &1e67 85 7b STA &7b ; cosine &1e69 a2 03 LDX #&03 # 3-bit multiplication of sine by radius &1e6b a9 00 LDA #&00 ; loop_over_bits_of_sine &1e6d 46 7a LSR &7a ; sine &1e6f 90 03 BCC &1e74 ; sine_bit_unset &1e71 18 CLC &1e72 65 7c ADC &7c ; radius ; sine_bit_unset &1e74 6a ROR A &1e75 ca DEX &1e76 d0 f5 BNE &1e6d ; loop_over_bits_of_sine &1e78 a6 7a LDX &7a ; x &1e7a f0 02 BEQ &1e7e ; skip_uninversion_sine &1e7c 49 ff EOR #&ff ; skip_uninversion_sine &1e7e 49 80 EOR #&80 &1e80 85 7a STA &7a ; x # x = radius * sin(piece) &1e82 a2 03 LDX #&03 # 3-bit multiplication of cosine by radius &1e84 a9 00 LDA #&00 ; loop_over_bits_of_cosine &1e86 46 7b LSR &7b ; cosine &1e88 90 03 BCC &1e8d ; cosine_bit_unset &1e8a 18 CLC &1e8b 65 7c ADC &7c ; radius &1e8d 6a ROR A &1e8e ca DEX &1e8f d0 f5 BNE &1e86 ; loop_over_bits_of_cosine &1e91 a6 7b LDX &7b ; y ; skip_uninversion_cosine &1e93 f0 02 BEQ &1e97 ; skip_uninversion_cosine &1e95 49 ff EOR #&ff ; skip_uninversion_cosine &1e97 49 80 EOR #&80 &1e99 85 7b STA &7b ; y # y = radius * cos(piece) &1e9b 88 DEY &1e9c b1 80 LDA (&80),Y ; starship_explosion_piece_segment_angle_or_ageing_rate &1e9e 10 26 BPL &1ec6 ; plot_variable_size_fragment &1ea0 a5 75 LDA &75 ; fragment_size_or_segment_type &1ea2 18 CLC &1ea3 2a ROL A &1ea4 2a ROL A &1ea5 2a ROL A &1ea6 85 72 STA &72 ; segment_angle_change_per_pixel &1ea8 49 03 EOR #&03 &1eaa 18 CLC &1eab 69 01 ADC #&01 &1ead 38 SEC &1eae 2a ROL A &1eaf 85 74 STA &74 ; segment_length &1eb1 e6 72 INC &72 ; segment_angle_change_per_pixel &1eb3 c8 INY &1eb4 b1 80 LDA (&80),Y ; starship_explosion_piece_two &1eb6 29 1f AND #&1f &1eb8 85 78 STA &78 ; segment_angle &1eba a5 7a LDA &7a ; x &1ebc 85 77 STA &77 ; origin_x &1ebe a5 7b LDA &7b ; y &1ec0 85 76 STA &76 ; origin_y &1ec2 20 e4 18 JSR &18e4 ; plot_segment &1ec5 60 RTS ; plot_variable_size_fragment &1ec6 20 64 0f JSR &0f64 ; eor_pixel &1ec9 a5 75 LDA &75 ; fragment_size_or_segment_type &1ecb c9 c0 CMP #&c0 &1ecd f0 2f BEQ &1efe ; leave &1ecf e6 7a INC &7a ; x &1ed1 20 64 0f JSR &0f64 ; eor_pixel &1ed4 a5 75 LDA &75 ; fragment_size_or_segment_type &1ed6 30 26 BMI &1efe ; leave &1ed8 e6 7b INC &7b ; y &1eda 20 64 0f JSR &0f64 ; eor_pixel &1edd c6 7a DEC &7a ; x &1edf 20 64 0f JSR &0f64 ; eor_pixel &1ee2 a5 75 LDA &75 ; fragment_size_or_segment_type &1ee4 d0 18 BNE &1efe ; leave &1ee6 e6 7b INC &7b ; y &1ee8 20 64 0f JSR &0f64 ; eor_pixel &1eeb c6 7b DEC &7b ; y &1eed c6 7a DEC &7a ; x &1eef 20 64 0f JSR &0f64 ; eor_pixel &1ef2 c6 7b DEC &7b ; y &1ef4 20 64 0f JSR &0f64 ; eor_pixel &1ef7 c6 7b DEC &7b ; y &1ef9 e6 7a INC &7a ; x &1efb 20 64 0f JSR &0f64 ; eor_pixel &1efe 60 RTS ; unused NOPs &1eff ea ea ea ea ; initialise_starship_explosion_pieces &1f03 ad cd 1c LDA &1ccd ; maximum_starship_explosion_countdown &1f06 8d ce 1c STA &1cce ; starship_explosion_countdown &1f09 ad ca 1c LDA &1cca ; starship_explosion_address_low &1f0c 85 80 STA &80 ; starship_explosion_piece_address_low &1f0e ad cb 1c LDA &1ccb ; starship_explosion_address_high &1f11 85 81 STA &81 ; starship_explosion_piece_address_high &1f13 ad cc 1c LDA &1ccc ; starship_explosion_size &1f16 8d 54 0e STA &0e54 ; starship_explosion_pieces_still_to_consider ; initialise_starship_explosion_pieces_loop &1f19 20 2d 1f JSR &1f2d ; initialise_starship_explosion_piece &1f1c a5 80 LDA &80 ; starship_explosion_piece_address_low &1f1e 18 CLC &1f1f 69 03 ADC #&03 &1f21 85 80 STA &80 ; starship_explosion_piece_address_low &1f23 90 02 BCC &1f27 &1f25 e6 81 INC &81 ; starship_explosion_piece_address_high &1f27 ce 54 0e DEC &0e54 ; enemy_ships_still_to_consider &1f2a d0 ed BNE &1f19 ; initialise_starship_explosion_pieces_loop &1f2c 60 RTS ; initialise_starship_explosion_piece &1f2d 20 13 21 JSR &2113 ; random_number_generator &1f30 a0 02 LDY #&02 &1f32 ad d1 1c LDA &1cd1 ; rnd_1 &1f35 29 07 AND #&07 &1f37 91 80 STA (&80),Y ; starship_explosion_piece_radius &1f39 88 DEY &1f3a ad d2 1c LDA &1cd2 ; rnd_2 &1f3d 4a LSR A &1f3e 91 80 STA (&80),Y ; starship_explosion_piece_segment_angle_or_ageing_rate &1f40 ad d1 1c LDA &1cd1 ; rnd_1 &1f43 29 3c AND #&3c &1f45 d0 06 BNE &1f4d ; not_a_segment &1f47 b1 80 LDA (&80),Y ; starship_explosion_piece_segment_angle_or_ageing_rate &1f49 09 80 ORA #&80 &1f4b 91 80 STA (&80),Y ; starship_explosion_piece_segment_angle_or_ageing_rate ; not_a_segment &1f4d 88 DEY &1f4e ad d1 1c LDA &1cd1 ; rnd_1 &1f51 29 1f AND #&1f &1f53 18 CLC &1f54 69 01 ADC #&01 &1f56 91 80 STA (&80),Y ; starship_explosion_piece_age_and_size &1f58 60 RTS ; unused NOPs &1f59 ea ea ea ea ; explode_enemy_ship &1f5d bd 00 04 LDA &0400,X ; enemy_ships_previous_on_screen &1f60 d0 03 BNE &1f65 ; skip_unplotting &1f62 20 fc 1b JSR &1bfc ; plot_enemy_ship ; skip_unplotting &1f65 ad 39 0e LDA &0e39 ; enemy_ship_explosion_duration &1f68 9d 09 04 STA &0409,X ; enemy_ships_flags_or_explosion_timer &1f6b ac 4f 0e LDY &0e4f ; maximum_number_of_enemy_ships &1f6e a9 00 LDA #&00 ; find_free_explosion_slot_loop &1f70 d9 e1 1c CMP &1ce1,Y ; enemy_ships_explosion_number - 1 &1f73 b0 03 BCS &1f78 &1f75 b9 e1 1c LDA &1ce1,Y ; enemy_ships_explosion_number - 1 &1f78 88 DEY &1f79 d0 f5 BNE &1f70 ; find_free_explosion_slot_loop &1f7b cd 35 0e CMP &0e35 ; maximum_number_of_explosions &1f7e f0 03 BEQ &1f83 ; too_many_explosions # This branch can never happen. &1f80 18 CLC &1f81 69 01 ADC #&01 ; too_many_explosions &1f83 ac 54 0e LDY &0e54 ; enemy_ships_still_to_consider &1f86 99 e1 1c STA &1ce1,Y ; enemy_ships_explosion_number - 1 &1f89 a8 TAY &1f8a b9 f6 1c LDA &1cf6,Y ; enemy_explosion_address_low_table - 1 &1f8d 85 86 STA &86 ; enemy_explosion_address_low &1f8f b9 07 1d LDA &1d07,Y ; enemy_explosion_address_high_table - 1 &1f92 85 87 STA &87 ; enemy_explosion_address_high &1f94 ac cf 1c LDY &1ccf ; number_of_bytes_per_enemy_explosion &1f97 20 13 21 JSR &2113 ; random_number_generator ; enemy_explosion_initialisation_loop &1f9a ad d2 1c LDA &1cd2 ; rnd_2 &1f9d 29 3f AND #&3f &1f9f 91 86 STA (&86),Y ; enemy_explosion_piece_radius &1fa1 88 DEY &1fa2 ad d1 1c LDA &1cd1 ; rnd_1 &1fa5 29 3f AND #&3f &1fa7 18 CLC &1fa8 69 68 ADC #&68 &1faa 91 86 STA (&86),Y ; enemy_explosion_piece_age &1fac 88 DEY &1fad 10 e8 BPL &1f97 ; enemy_explosion_initialisation_loop &1faf 4c 86 2d JMP &2d86 ; score_points_for_destroying_enemy_ship ; unused NOPs &1fb2 ea ea ; update_enemy_explosion_pieces &1fb4 bd 09 04 LDA &0409,X ; enemy_ships_flags_or_explosion_timer &1fb7 cd 37 0e CMP &0e37 ; frame_of_enemy_ship_explosion_after_which_no_collisions &1fba a9 01 LDA #&01 # Create new explosion pieces when old ones die &1fbc b0 02 BCS &1fc0 &1fbe a9 00 LDA #&00 # Don't create new explosion pieces when old ones die &1fc0 8d d0 1c STA &1cd0 ; create_new_enemy_explosion_piece_after_one_dies &1fc3 20 a4 20 JSR &20a4 ; plot_enemy_ship_or_explosion_segments &1fc6 ac cf 1c LDY &1ccf ; number_of_bytes_per_enemy_explosion ; update_enemy_explosion_pieces_loop &1fc9 88 DEY &1fca b1 86 LDA (&86),Y ; enemy_explosion_piece_radius &1fcc f0 34 BEQ &2002 ; move_to_next_piece &1fce 20 25 20 JSR &2025 ; plot_explosion_dots &1fd1 b1 86 LDA (&86),Y ; enemy_explosion_piece_radius &1fd3 29 03 AND #&03 &1fd5 aa TAX &1fd6 bd 18 1d LDA &1d18,X ; enemy_explosion_piece_ageing_table &1fd9 88 DEY &1fda 18 CLC &1fdb 71 86 ADC (&86),Y ; enemy_explosion_piece_age &1fdd 90 16 BCC &1ff5 ; piece_still_active &1fdf ad d0 1c LDA &1cd0 ; create_new_enemy_explosion_piece_after_one_dies &1fe2 91 86 STA (&86),Y ; enemy_explosion_piece_age &1fe4 f0 1c BEQ &2002 ; move_to_next_piece &1fe6 20 13 21 JSR &2113 ; random_number_generator &1fe9 ad d2 1c LDA &1cd2 ; rnd_2 &1fec 4a LSR A &1fed 29 3f AND #&3f &1fef c8 INY &1ff0 91 86 STA (&86),Y ; enemy_explosion_piece_radius &1ff2 4c 01 20 JMP &2001 ; move_to_next_piece_after_dey ; piece_still_active &1ff5 91 86 STA (&86),Y ; enemy_explosion_piece_age &1ff7 c8 INY &1ff8 e8 INX &1ff9 8a TXA &1ffa 0a ASL A &1ffb 0a ASL A &1ffc 18 CLC &1ffd 71 86 ADC (&86),Y ; enemy_explosion_piece_radius &1fff 91 86 STA (&86),Y ; enemy_explosion_piece_radius ; move_to_next_piece_after_dey &2001 88 DEY ; move_to_next_piece &2002 88 DEY &2003 10 c4 BPL &1fc9 ; update_enemy_explosion_pieces_loop &2005 a6 88 LDX &88 ; enemy_ship_offset &2007 60 RTS ; unused NOPs &2008 ea ea ea ea ; plot_enemy_ship_explosion &200c 20 a4 20 JSR &20a4 ; plot_enemy_ship_or_explosion_segments &200f ac cf 1c LDY &1ccf ; number_of_bytes_per_enemy_explosion ; plot_enemy_ship_explosion_loop &2012 88 DEY &2013 b1 86 LDA (&86),Y ; enemy_explosion_piece_age &2015 f0 04 BEQ &201b ; move_to_next_explosion_piece &2017 20 25 20 JSR &2025 ; plot_enemy_explosion_fragment &201a 88 DEY ; move_to_next_explosion_piece &201b 88 DEY &201c 10 f4 BPL &2012 ; plot_enemy_ship_explosion_loop &201e a6 88 LDX &88 ; enemy_ship_offset &2020 60 RTS ; unused NOPs &2021 ea ea ea ea ; plot_enemy_explosion_fragment &2025 b1 86 LDA (&86),Y ; enemy_explosion_piece_age &2027 29 c0 AND #&c0 &2029 85 78 STA &78 ; fragment_size &202b c8 INY &202c b1 86 LDA (&86),Y ; enemy_explosion_piece_radius &202e 4a LSR A &202f 4a LSR A &2030 85 7c STA &7c ; radius &2032 98 TYA &2033 4a LSR A &2034 aa TAX &2035 bd 58 0e LDA &0e58,X ; sine_table &2038 10 05 BPL &203f ; skip_inversion_sine &203a 49 1f EOR #&1f &203c 18 CLC &203d 69 01 ADC #&01 ; skip_inversion_sine &203f 85 7a STA &7a ; sine &2041 bd 78 0e LDA &0e78,X ; cosine_table &2044 10 05 BPL &204b ; skip_inversion_cosine &2046 49 1f EOR #&1f &2048 18 CLC &2049 69 01 ADC #&01 ; skip_inversion_cosine &204b 85 7b STA &7b ; cosine &204d a2 03 LDX #&03 # 3-bit multiplication of sine by radius &204f a9 00 LDA #&00 ; loop_over_bits_of_sine &2051 46 7a LSR &7a ; sine &2053 90 03 BCC &2058 ; sine_bit_unset &2055 18 CLC &2056 65 7c ADC &7c ; radius ; sine_bit_unset &2058 6a ROR A &2059 ca DEX &205a d0 f5 BNE &2051 ; loop_over_bits_of_sine &205c a6 7a LDX &7a ; sine &205e f0 02 BEQ &2062 ; skip_uninversion_sine &2060 49 ff EOR #&ff ; skip_uninversion_sine &2062 18 CLC &2063 65 77 ADC &77 ; origin_x &2065 85 7a STA &7a ; x # x = origin_x + radius * sin(piece / 2) &2067 a2 03 LDX #&03 # 3-bit multiplication of cosine by radius &2069 a9 00 LDA #&00 ; loop_over_bits_of_cosine &206b 46 7b LSR &7b ; cosine &206d 90 03 BCC &2072 ; cosine_bit_unset &206f 18 CLC &2070 65 7c ADC &7c ; radius ; cosine_bit_unset &2072 6a ROR A &2073 ca DEX &2074 d0 f5 BNE &206b ; loop_over_bits_of_cosine &2076 a6 7b LDX &7b ; cosine &2078 f0 02 BEQ &207c ; skip_uninversion_cosine &207a 49 ff EOR #&ff ; skip_uninversion_cosine &207c 18 CLC &207d 65 76 ADC &76 ; origin_y &207f 85 7b STA &7b ; y # y = origin_y + radius * cos(piece / 2) &2081 84 7c STY &7c ; piece_offset &2083 20 4a 0f JSR &0f4a ; eor_pixel_within_box_around_origin &2086 a5 78 LDA &78 ; fragment_size &2088 30 13 BMI &209d ; leave_after_restoring_y &208a e6 7a INC &7a ; x &208c 20 4a 0f JSR &0f4a ; eor_pixel_within_box_around_origin &208f a5 78 LDA &78 ; fragment_size &2091 d0 0a BNE &209d ; leave_after_restoring_y &2093 e6 7b INC &7b ; y &2095 20 4a 0f JSR &0f4a ; eor_pixel_within_box_around_origin &2098 c6 7a DEC &7a ; x &209a 20 4a 0f JSR &0f4a ; eor_pixel_within_box_around_origin ; leave_after_restoring_y &209d a4 7c LDY &7c ; piece_offset &209f 60 RTS ; unused NOPs &20a0 ea ea ea ea ; plot_enemy_ship_or_explosion_segments &20a4 86 88 STX &88 ; enemy_ship_offset &20a6 bd 02 04 LDA &0402,X ; enemy_ships_previous_x_pixels &20a9 85 77 STA &77 ; origin_x &20ab bd 05 04 LDA &0405,X ; enemy_ships_previous_y_pixels &20ae 85 76 STA &76 ; origin_y &20b0 bd 09 04 LDA &0409,X ; enemy_ships_flags_or_explosion_timer &20b3 cd 37 0e CMP &0e37 ; frame_of_enemy_ship_explosion_after_which_no_collisions &20b6 90 09 BCC &20c1 ; leave &20b8 cd 38 0e CMP &0e38 ; frame_of_enemy_ship_explosion_after_which_no_segments_are_plotted &20bb 90 08 BCC &20c5 ; plot_enemy_explosion_segments &20bd 20 fc 1b JSR &1bfc ; plot_enemy_ship &20c0 60 RTS ; leave &20c1 60 RTS ; unused NOPs &20c2 ea ea ea ; plot_enemy_explosion_segments &20c5 29 1f AND #&1f &20c7 85 78 STA &78 ; segment_angle &20c9 a5 77 LDA &77 ; origin_x &20cb 85 7a STA &7a ; x &20cd a5 76 LDA &76 ; origin_y &20cf 85 7b STA &7b ; y &20d1 a9 0a LDA #&0a &20d3 85 74 STA &74 ; segment_length &20d5 a9 01 LDA #&01 &20d7 85 72 STA &72 ; segment_angle_change_per_pixel &20d9 20 e4 18 JSR &18e4 ; plot_segment &20dc a6 88 LDX &88 ; enemy_ship_offset &20de bd 09 04 LDA &0409,X ; enemy_ships_flags_or_explosion_timer &20e1 49 1f EOR #&1f &20e3 29 1f AND #&1f &20e5 85 78 STA &78 ; segment_angle &20e7 a9 07 LDA #&07 &20e9 85 74 STA &74 ; segment_length &20eb e6 72 INC &72 ; segment_angle_change_per_pixel &20ed 20 e4 18 JSR &18e4 ; plot_segment &20f0 a6 88 LDX &88 ; enemy_ship_offset &20f2 a5 77 LDA &77 ; origin_x &20f4 85 7a STA &7a ; x &20f6 a5 76 LDA &76 ; origin_y &20f8 85 7b STA &7b ; y &20fa bd 09 04 LDA &0409,X ; enemy_ships_flags_or_explosion_timer &20fd 49 0f EOR #&0f &20ff 29 1f AND #&1f &2101 85 78 STA &78 ; segment_angle &2103 a9 06 LDA #&06 &2105 85 74 STA &74 ; segment_length &2107 a9 ff LDA #&ff &2109 85 72 STA &72 ; segment_angle_change_per_pixel &210b 20 e4 18 JSR &18e4 ; plot_segment &210e 60 RTS ; unused NOPs &210f ea ea ea ea ; random_number_generator &2113 ad d1 1c LDA &1cd1 ; rnd_1 &2116 85 7b STA &7b ; old_high &2118 ad d2 1c LDA &1cd2 ; rnd_2 &211b 85 7a STA &7a ; old_low &211d a9 08 LDA #&08 &211f 85 7c STA &7c ; loop_counter &2121 a9 d5 LDA #&d5 ; 11010101 ; random_number_generator_loop &2123 46 7a LSR &7a ; old_high &2125 66 7b ROR &7b ; old_low &2127 90 03 BCC &212c ; lowest_bit_unset &2129 18 CLC &212a 69 25 ADC #&25 ; 00100101 ; lowest_bit_unset &212c 6a ROR A &212d 66 75 ROR &75 ; new_low &212f c6 7c DEC &7c ; loop_counter &2131 d0 f0 BNE &2123 ; random_number_generator_loop &2133 18 CLC &2134 6d d1 1c ADC &1cd1 ; rnd_1 &2137 8d d2 1c STA &1cd2 ; rnd_2 &213a a5 75 LDA &75 ; new_low &213c 8d d1 1c STA &1cd1 ; rnd_1 &213f 60 RTS ; unused NOPs &2140 ea ea ea ea ea ea ; game_key_table &2146 9e ; Z &2147 bd ; X &2148 9a ; M &2149 99 ; , &214a aa ; N &214b ac ; G &214c bc ; F &214d df ; f0 &214e 8e ; f1 &214f ce ; 2 &2150 ee ; 3 &2151 9c ; V &2152 9b ; B &2153 ad ; C &2154 96 ; COPY # Five unused keys &2155 ff ; SHIFT &2156 ff ; SHIFT &2157 ff ; SHIFT &2158 ff ; SHIFT &2159 96 ; COPY ; screen_border_string &215a 00 00 03 ff 05 19 ; MOVE &0400, &02fc &2160 03 ff 03 ff 05 19 ; DRAW &04ff, &02fc &2166 03 ff 00 00 05 19 ; DRAW &04ff, &0000 &216c 00 00 00 00 05 19 ; DRAW &0000, &0000 &2172 00 00 04 ff 05 19 ; DRAW &0000, &03ff &2178 02 fc 04 ff 05 19 ; DRAW &03ff, &03ff &217e 02 fc 04 00 04 19 ; DRAW &03ff, &0000 ; envelope_1 &2184 01 00 f8 fa 0f 04 0a 08 7f fe fc ff 7e 64 ; envelope_2 &2192 02 00 f8 fa fe 04 0a 08 7f fe ff ff 64 50 ; envelope_3 &21a0 03 86 ff 00 01 03 01 02 7f ff fd fd 7e 78 : envelope_4 &21ae 04 00 10 f0 10 04 08 04 7f ff ff ff 7e 64 ; unused &21bc 01 02 03 04 05 06 07 08 09 0a 0b 0c # Unused table ; chan vol pitch dur ; sound_1 &21c8 11 00 00 00 00 00 08 00 # Exploding starship 1 ; sound_2 &21d0 10 00 00 00 07 00 08 00 # Exploding starship 2 ; sound_3 &21d8 13 00 01 00 80 00 04 00 # Starship fired torpedo ; sound_4 &21e0 12 00 02 00 c0 00 1f 00 # Enemy ship fired torpedo ; sound_5 &21e8 12 00 04 00 40 00 08 00 # Enemy ship hit by torpedo ; sound_6 &21f0 12 00 04 00 be 00 08 00 # Starship hit by torpedo ; sound_7 &21f8 13 00 02 00 6c 00 08 00 # Enemy ships collided with each other ; sound_8 &2200 13 00 00 00 64 00 04 00 # Escape capsule launched ; sound_9 &2208 11 00 f1 ff c8 00 04 00 # Low energy warning ; set_foreground_colour_to_white_string &2210 00 00 00 07 01 13 ; VDU 19,1,7,0,0,0 ; set_foreground_colour_to_black_string &2216 00 00 00 00 01 13 ; VDU 19,1,0,0,0,0 ; set_background_colour_to_black_string &221c 00 00 00 00 00 13 ; VDU 19,0,0,0,0,0 ; energy_string &2222 59 47 52 45 4e 45 11 21 1f ; TAB(&21, &11), "ENERGY" ; one_two_three_four_string &222b 04 34 0a 08 33 0a 08 32 0a 08 31 05 01 ac 04 08 ; MOVE &0408, &01ac; "1\n2\n3\n4" &223b 04 19 ; shields_string &223d 4e 4f 05 23 1f 53 44 4c 45 49 48 53 02 21 1f ; TAB(&21, &02), "SHIELDS", TAB(&23, &05), "NO" ; blank_string &224c 20 20 05 23 1f 20 20 20 20 20 20 20 02 21 1f ; TAB(&21, &02), " ", TAB(&23, &05), " " ; enable_cursor_string &225b 00 00 00 00 00 00 60 0a 00 17 ; set CRTC register 10 to &60 ; disable_cursor_string &2265 00 00 00 00 00 00 3c 0a 00 17 ; set CRTC register 10 to &3c ; unused NOPs &226f ea ea ea ea ea ea ; plot_energy_bar_edges &2275 a9 93 LDA #&93 &2277 85 7b STA &7b ; y &2279 a9 05 LDA #&05 &227b 85 75 STA &75 ; count &227d e6 79 INC &79 ; screen_start_high # Change origin to top left of long range scanner ; plot_energy_bar_edges_loop &227f a9 0d LDA #&0d &2281 85 7a STA &7a ; x &2283 a9 32 LDA #&32 &2285 20 db 1b JSR &1bdb ; plot_horizontal_line &2288 a5 7b LDA &7b ; y &228a 18 CLC &228b 69 08 ADC #&08 &228d 85 7b STA &7b ; y &228f c6 75 DEC &75 ; count &2291 d0 ec BNE &227f ; plot_energy_bar_edges_loop &2293 a9 93 LDA #&93 &2295 85 7b STA &7b ; y &2297 a9 0c LDA #&0c &2299 85 7a STA &7a ; x &229b a9 21 LDA #&21 &229d 20 cf 1b JSR &1bcf ; plot_vertical_line &22a0 c6 79 DEC &79 ; screen_start_high # Restore origin &22a2 60 RTS ; plot_energy_text &22a3 a2 08 LDX #&08 &22a5 bd 22 22 LDA &2222,X ; energy_string &22a8 20 ee ff JSR &ffee ; OSWRCH &22ab ca DEX &22ac 10 f7 BPL &22a5 &22ae a2 11 LDX #&11 &22b0 60 RTS ; plot_one_two_three_four_text &22b1 a2 11 LDX #&11 &22b3 bd 2b 22 LDA &222b,X ; one_two_three_four_string &22b6 20 ee ff JSR &ffee ; OSWRCH &22b9 ca DEX &22ba 10 f7 BPL &22b3 &22bc 60 RTS ; plot_shields_text &22bd a2 0e LDX #&0e &22bf bd 3d 22 LDA &223d,X ; shields_string &22c2 20 ee ff JSR &ffee ; OSWRCH &22c5 ca DEX &22c6 10 f7 BPL &22bf &22c8 60 RTS ; plot_blank_text &22c9 a2 0e LDX #&0e &22cb bd 4c 22 LDA &224c,X ; blank_string &22ce 20 ee ff JSR &ffee ; OSWRCH &22d1 ca DEX &22d2 10 f7 BPL &22cb &22d4 60 RTS ; initialise_envelopes &22d5 a2 84 LDX #&84 &22d7 a0 21 LDY #&21 ; &2184 = envelope_1 &22d9 a9 08 LDA #&08 ; Define a sound envelope (ENVELOPE) &22db 20 f1 ff JSR &fff1 ; OSWORD &22de a2 92 LDX #&92 &22e0 a0 21 LDY #&21 ; &2192 = envelope_2 &22e2 a9 08 LDA #&08 ; Define a sound envelope (ENVELOPE) &22e4 20 f1 ff JSR &fff1 ; OSWORD &22e7 a2 a0 LDX #&a0 &22e9 a0 21 LDY #&21 ; &21a0 = envelope_3 &22eb a9 08 LDA #&08 ; Define a sound envelope (ENVELOPE) &22ed 20 f1 ff JSR &fff1 ; OSWORD &22f0 a2 ae LDX #&ae &22f2 a0 21 LDY #&21 ; &21ae = envelope_4 &22f4 a9 08 LDA #&08 ; Define a sound envelope (ENVELOPE) &22f6 20 f1 ff JSR &fff1 ; OSWORD &22f9 60 RTS ; plot_screen_border &22fa a2 29 LDX #&29 &22fc bd 5a 21 LDA &215a,X ; screen_border_string &22ff 20 ee ff JSR &ffee ; OSWRCH &2302 ca DEX &2303 10 f7 BPL &22fc &2305 60 RTS ; set_foreground_colour_to_white &2306 a2 05 LDX #&05 &2308 bd 10 22 LDA &2210,X ; set_foreground_colour_to_white_string &230b 20 ee ff JSR &ffee ; OSWRCH &230e ca DEX &230f 10 f7 BPL &2308 &2311 60 RTS ; set_foreground_colour_to_black &2312 a2 05 LDX #&05 &2314 bd 16 22 LDA &2216,X ; set_foreground_colour_to_black_string &2317 20 ee ff JSR &ffee ; OSWRCH &231a ca DEX &231b 10 f7 BPL &2314 &231d 60 RTS ; set_background_colour_to_black &231e a2 05 LDX #&05 &2320 bd 1c 22 LDA &221c,X ; set_background_colour_to_black_string &2323 20 ee ff JSR &ffee ; OSWRCH &2326 ca DEX &2327 10 f7 BPL &2320 &2329 60 RTS ; enable_cursor # Unused code &232a a2 09 LDX #&09 ; enable_cursor_loop &232c bd 5b 22 LDA &225b,X ; enable_cursor_string &232f 20 ee ff JSR &ffee ; OSWRCH &2332 ca DEX &2333 10 f7 BPL &232c ; enable_cursor_loop &2335 60 RTS ; disable_cursor &2336 a2 09 LDX #&09 ; disable_cursor_loop &2338 bd 65 22 LDA &2265,X ; disable_cursor_string &233b 20 ee ff JSR &ffee ; OSWRCH &233e ca DEX &233f 10 f7 BPL &2338 ; disable_cursor_loop &2341 60 RTS ; unused NOPs &2342 ea ea ea ea ea ea ea ea ea ; check_for_keypresses &234b ac d8 1c LDY &1cd8 ; escape_capsule_launched &234e d0 67 BNE &23b7 ; leave &2350 ac d6 1c LDY &1cd6 ; keyboard_or_joystick &2353 f0 09 BEQ &235e ; use_keyboard_input &2355 20 00 49 JSR &4900 ; get_joystick_input &2358 a9 04 LDA #&04 &235a 85 75 STA &75 ; key_to_check &235c d0 2c BNE &238a ; check_for_additional_keys ; use_keyboard_input &235e a9 ff LDA #&ff &2360 85 75 STA &75 ; key_to_check &2362 20 36 24 JSR &2436 ; check_key # Z &2365 f0 03 BEQ &236a ; not_rotate_anticlockwise &2367 ce 27 19 DEC &1927 ; rotation_delta ; not_rotate_anticlockwise &236a 20 36 24 JSR &2436 ; check_key # X &236d f0 03 BEQ &2372 ; not_rotate_clockwise &236f ee 27 19 INC &1927 ; rotation_delta ; not_rotate_clockwise &2372 20 36 24 JSR &2436 ; check_key # M &2375 f0 03 BEQ &237a ; not_accelerate &2377 ee 2e 19 INC &192e ; velocity_delta ; not_accelerate &237a 20 36 24 JSR &2436 ; check_key # , &237d f0 03 BEQ &2382 ; not_decelerate &237f ce 2e 19 DEC &192e ; velocity_delta ; not_decelerate &2382 20 36 24 JSR &2436 ; check_key # N &2385 f0 03 BEQ &238a ; not_fire &2387 ee 1a 19 INC &191a ; fire_pressed ; not_fire ; check_for_additional_keys &238a 20 36 24 JSR &2436 ; check_key # G &238d f0 03 BEQ &2392 ; not_launch_starboard_escape_capsule &238f 4c db 28 JMP &28db ; launch_escape_capsule_starboard ; not_launch_starboard_escape_capsule &2392 20 36 24 JSR &2436 ; check_key # F &2395 f0 03 BEQ &239a ; not_launch_port_escape_capsule &2397 4c d7 28 JMP &28d7 ; launch_escape_capsule_port ; not_launch_port_escape_capsule &239a ad d6 1c LDA &1cd6 ; keyboard_or_joystick &239d f0 06 BEQ &23a5 ; is_keyboard &239f a9 0a LDA #&0a &23a1 85 75 STA &75 ; key_to_check &23a3 d0 34 BNE &23d9 ; skip_damper_keys ; is_keyboard &23a5 ad 27 19 LDA &1927 ; rotation_delta &23a8 0d 2e 19 ORA &192e ; velocity_delta &23ab d0 0a BNE &23b7 ; leave # Dampers only work when not accelerating / turning &23ad 20 36 24 JSR &2436 ; check_key # f0 &23b0 f0 06 BEQ &23b8 ; not_enable_rotation_damper &23b2 a9 01 LDA #&01 &23b4 8d 2c 19 STA &192c ; rotation_damper &23b7 60 RTS ; not_enable_rotation_damper &23b8 20 36 24 JSR &2436 ; check_key # f1 &23bb f0 06 BEQ &23c3 ; not_enable_velocity_damper &23bd a9 01 LDA #&01 &23bf 8d 31 19 STA &1931 ; velocity_damper &23c2 60 RTS ; not_enable_velocity_damper &23c3 20 36 24 JSR &2436 ; check_key # 2 &23c6 f0 06 BEQ &23ce ; not_disable_rotation_damper &23c8 a9 00 LDA #&00 &23ca 8d 2c 19 STA &192c ; rotation_damper &23cd 60 RTS ; not_disable_rotation_damper &23ce 20 36 24 JSR &2436 ; check_key # 3 &23d1 f0 06 BEQ &23d9 ; not_enable_rotation_damper &23d3 a9 00 LDA #&00 &23d5 8d 31 19 STA &1931 ; velocity_damper &23d8 60 RTS ; not_enable_rotation_damper ; skip_damper_keys &23d9 20 36 24 JSR &2436 ; check_key # V &23dc f0 04 BEQ &23e2 ; not_enable_shields &23de ee 26 19 INC &1926 ; shields_state_delta &23e1 60 RTS ; not_enable_shields &23e2 20 36 24 JSR &2436 ; check_key # B &23e5 f0 04 BEQ &23eb ; not_disable_shields &23e7 ce 26 19 DEC &1926 ; shields_state_delta &23ea 60 RTS ; not_disable_shields &23eb 20 36 24 JSR &2436 ; check_key # C &23ee f0 2e BEQ &241e ; not_auto_shields &23f0 a9 01 LDA #&01 &23f2 8d 24 19 STA &1924 ; starship_automatic_shields &23f5 60 RTS ; unused # Unused code that would allow check for five more keys &23f6 20 36 24 JSR &2436 ; check_key # COPY &23f9 f0 03 BEQ &23fe ; not_unused_copy &23fb 4c 1e 24 JMP &241e ; check_for_copy ; not_unused_copy &23fe 20 36 24 JSR &2436 ; check_key # SHIFT &2401 f0 03 BEQ &2406 ; not_unused_shift_one &2403 4c 1e 24 JMP &241e ; check_for_copy ; not_unused_shift_one &2406 20 36 24 JSR &2436 ; check_key # SHIFT &2409 f0 03 BEQ &240e ; not_unused_shift_two &240b 4c 1e 24 JMP &241e ; check_for_copy ; not_unused_shift_two &240e 20 36 24 JSR &2436 ; check_key # SHIFT &2411 f0 03 BEQ &2416 ; not_unused_shift_three &2413 4c 1e 24 JMP &241e ; check_for_copy ; not_unused_shift_three &2416 20 36 24 JSR &2436 ; check_key # SHIFT &2419 f0 03 BEQ &241e ; not_unused_shift_four &241b 4c 1e 24 JMP &241e ; check_for_copy ; not_unused_shift_four ; not_auto_shields ; check_for_copy &241e 20 36 24 JSR &2436 ; check_key # COPY &2421 f0 03 BEQ &2426 ; leave &2423 4c 49 24 JMP &2449 ; pause_game ; leave &2426 60 RTS ; unused NOPs &2427 ea ea ea ea ea ea ea ea ea ea ea ea ea ea ea ; check_key &2436 e6 75 INC &75 ; key_to_check &2438 a6 75 LDX &75 ; key_to_check &243a bd 46 21 LDA &2146,X ; game_key_table &243d a8 TAY &243e aa TAX &243f a9 81 LDA #&81 ; Read Key &2441 20 f4 ff JSR &fff4 ; OSBYTE &2444 98 TYA &2445 60 RTS ; unused NOPs &2446 ea ea ea ; pause_game &2449 a2 a6 LDX #&a6 ; DELETE &244b a0 a6 LDY #&a6 &244d a9 81 LDA #&81 ; Read Key &244f 20 f4 ff JSR &fff4 ; OSBYTE &2452 98 TYA &2453 f0 f4 BEQ &2449 ; pause_game &2455 60 RTS ; unused NOPs &2456 ea ea ea ea ; play_sounds &245a ad d7 1c LDA &1cd7 ; sound_enabled &245d f0 01 BEQ &2460 ; sound_is_enabled &245f 60 RTS ; sound_is_enabled &2460 ad dd 1c LDA &1cdd ; enemy_torpedo_hits_against_starship &2463 f0 0b BEQ &2470 ; no_enemy_torpedo_hits_against_starship &2465 ad c9 1c LDA &1cc9 ; starship_has_exploded &2468 d0 1f BNE &2489 ; skip_explosion_or_firing_sound &246a a2 f0 LDX #&f0 &246c a0 21 LDY #&21 ; &21f0 = sound_6 &246e d0 14 BNE &2484 ; play_explosion_or_firing_sound ; no_enemy_torpedo_hits_against_starship &2470 ad de 1c LDA &1cde ; enemy_ship_was_hit &2473 f0 06 BEQ &247b ; no_enemy_ship_was_hit &2475 a2 e8 LDX #&e8 &2477 a0 21 LDY #&21 ; &21e8 = sound_5 &2479 d0 09 BNE &2484 ; play_explosion_or_firing_sound ; no_enemy_ship_was_hit &247b ad dc 1c LDA &1cdc ; enemy_ship_fired_torpedo &247e f0 09 BEQ &2489 ; skip_explosion_or_firing_sound &2480 a2 e0 LDX #&e0 &2482 a0 21 LDY #&21 ; &21e0 = sound_4 ; play_explosion_or_firing_sound &2484 a9 07 LDA #&07 ; Generate a sound (SOUND) &2486 20 f1 ff JSR &fff1 ; OSWORD ; skip_explosion_or_firing_sound &2489 a0 00 LDY #&00 &248b ad d8 1c LDA &1cd8 ; escape_capsule_launched &248e f0 06 BEQ &2496 ; set_escape_capsule_sound_channel &2490 ad 90 28 LDA &2890 ; escape_capsule_destroyed &2493 d0 01 BNE &2496 ; set_escape_capsule_sound_channel &2495 c8 INY ; set_escape_capsule_sound_channel &2496 8c db 1c STY &1cdb ; escape_capsule_sound_channel # 1 if launched, but not collided with enemy ship &2499 ad c9 1c LDA &1cc9 ; starship_has_exploded &249c d0 68 BNE &2506 ; play_sound_for_exploding_starship &249e ad 63 2d LDA &2d63 ; score_delta_low &24a1 0d 64 2d ORA &2d64 ; score_delta_high &24a4 f0 0d BEQ &24b3 ; skip_sound_for_exploding_enemy_ship &24a6 a5 7a LDA &7a ; x # Set in plot_starship_velocity_and_rotation_on_gauges &24a8 f0 09 BEQ &24b3 ; skip_sound_for_exploding_enemy_ship # or apply_damage_to_starship_energy; a bug? &24aa a2 f8 LDX #&f8 &24ac a0 49 LDY #&49 ; &49f8 = sound_11 &24ae a9 07 LDA #&07 ; Generate a sound (SOUND) &24b0 20 f1 ff JSR &fff1 ; OSWORD ; skip_sound_for_exploding_enemy_ship &24b3 ad db 1c LDA &1cdb ; escape_capsule_sound_channel &24b6 f0 03 BEQ &24bb ; escape_capsule_not_launched &24b8 4c 51 25 JMP &2551 ; play_escape_capsule_sound ; escape_capsule_not_launched &24bb ad f1 25 LDA &25f1 ; sound_needed_for_low_energy &24be f0 0f BEQ &24cf ; play_starship_engine_sound &24c0 ce f1 25 DEC &25f1 ; sound_needed_for_low_energy &24c3 a2 08 LDX #&08 &24c5 a0 22 LDY #&22 ; &2208 = sound_9 &24c7 a9 07 LDA #&07 ; Generate a sound (SOUND) &24c9 20 f1 ff JSR &fff1 ; OSWORD &24cc 4c 81 25 JMP &2581 ; consider_torpedo_sound ; play_starship_engine_sound &24cf ad 01 0f LDA &0f01 ; starship_velocity_low &24d2 18 CLC &24d3 69 40 ADC #&40 &24d5 85 7a STA &7a ; fraction &24d7 a9 00 LDA #&00 &24d9 6d 00 0f ADC &0f00 ; starship_velocity_high &24dc 06 7a ASL &7a ; fraction &24de 2a ROL A &24df 6d 03 0f ADC &0f03 ; starship_rotation_magnitude &24e2 8d f4 49 STA &49f4 ; sound_10_pitch # Pitch = (velocity_high * 2) + rotation_magnitude &24e5 c9 0a CMP #&0a &24e7 90 03 BCC &24ec ; skip_ceiling &24e9 a9 09 LDA #&09 &24eb 18 CLC ; skip_ceiling &24ec 49 ff EOR #&ff &24ee 69 01 ADC #&01 &24f0 8d f2 49 STA &49f2 ; sound_10_volume_low &24f3 a9 ff LDA #&ff &24f5 69 00 ADC #&00 &24f7 8d f3 49 STA &49f3 ; sound_10_volume_high # Volume = -min(pitch, 9) + 1 &24fa a2 f0 LDX #&f0 &24fc a0 49 LDY #&49 ; &49f0 = sound_10 &24fe a9 07 LDA #&07 ; Generate a sound (SOUND) &2500 20 f1 ff JSR &fff1 ; OSWORD &2503 4c 81 25 JMP &2581 ; consider_torpedo_sound ; play_sound_for_exploding_starship &2506 ad ce 1c LDA &1cce ; starship_explosion_countdown &2509 38 SEC &250a ed da 1c SBC &1cda ; frame_of_starship_explosion_after_which_no_sound &250d 90 38 BCC &2547 ; skip_starship_explosion_sound &250f 85 7a STA &7a ; pitch &2511 2a ROL A &2512 c9 56 CMP #&56 &2514 90 04 BCC &251a ; skip_pitch_bend &2516 e9 40 SBC #&40 &2518 2a ROL A &2519 2a ROL A ; skip_pitch_bend &251a 8d cc 21 STA &21cc ; sound_1_pitch &251d a5 7a LDA &7a ; pitch &251f 4a LSR A &2520 c9 10 CMP #&10 &2522 90 03 BCC &2527 ; skip_ceiling &2524 a9 0f LDA #&0f &2526 18 CLC ; skip_ceiling &2527 49 ff EOR #&ff &2529 69 01 ADC #&01 &252b 8d d2 21 STA &21d2 ; sound_1_volume_low &252e a9 ff LDA #&ff &2530 69 00 ADC #&00 &2532 8d d3 21 STA &21d3 ; sound_1_volume_high &2535 a2 c8 LDX #&c8 &2537 a0 21 LDY #&21 ; &21c8 = sound_1 &2539 a9 07 LDA #&07 ; Generate a sound (SOUND) &253b 20 f1 ff JSR &fff1 ; OSWORD &253e a2 d0 LDX #&d0 &2540 a0 21 LDY #&21 ; &21d0 = sound_2 &2542 a9 07 LDA #&07 ; Generate a sound (SOUND) &2544 20 f1 ff JSR &fff1 ; OSWORD ; skip_starship_explosion_sound &2547 ad db 1c LDA &1cdb ; escape_capsule_sound_channel &254a f0 35 BEQ &2581 ; consider_torpedo_sound &254c a9 03 LDA #&03 &254e 8d db 1c STA &1cdb ; escape_capsule_sound_channel # 3 if starship exploding ; play_escape_capsule_sound &2551 09 10 ORA #&10 # Flush channel; play sound immediately &2553 8d 00 22 STA &2200 ; sound_8_channel &2556 ad 91 28 LDA &2891 ; self_destruct_countdown &2559 29 01 AND #&01 &255b f0 0a BEQ &2567 ; set_volume &255d ad 91 28 LDA &2891 ; self_destruct_countdown &2560 4a LSR A &2561 4a LSR A &2562 49 ff EOR #&ff &2564 18 CLC &2565 69 01 ADC #&01 ; set_volume &2567 8d 02 22 STA &2202 ; sound_8_volume_low &256a f0 02 BEQ &256e ; set_volume_high &256c a9 ff LDA #&ff ; set_volume_high &256e 8d 03 22 STA &2203 ; sound_8_volume_high &2571 a2 00 LDX #&00 &2573 a0 22 LDY #&22 ; &2200 = sound_8 &2575 a9 07 LDA #&07 ; Generate a sound (SOUND) &2577 20 f1 ff JSR &fff1 ; OSWORD &257a ad db 1c LDA &1cdb ; escape_capsule_sound_channel &257d c9 03 CMP #&03 # Has the starship exploded? &257f f0 1c BEQ &259d leave ; consider_torpedo_sound &2581 ad 58 26 LDA &2658 ; starship_fired_torpedo &2584 f0 09 BEQ &258f ; skip_starship_torpedo_sound &2586 a2 d8 LDX #&d8 &2588 a0 21 LDY #&21 ; &21d8 = sound_3 &258a a9 07 LDA #&07 ; Generate a sound (SOUND) &258c 4c f1 ff JMP &fff1 ; OSWORD ; skip_starship_torpedo_sound &258f ad d1 17 LDA &17d1 ; enemy_ships_collided_with_each_other &2592 f0 09 BEQ &259d ; leave &2594 a2 f8 LDX #&f8 &2596 a0 21 LDY #&21 ; &21f8 = sound_7 &2598 a9 07 LDA #&07 ; Generate a sound (SOUND) &259a 20 f1 ff JSR &fff1 ; OSWORD ; leave &259d 60 RTS ; unused NOPs &259e ea ea ; unused &25a0 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff &25b0 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff &25c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 &25d0 00 00 00 00 00 ; starship_maximum_x_for_collisions_with_enemy_torpedoes &25d5 86 ; starship_minimum_x_for_collisions_with_enemy_torpedoes &25d6 78 ; starship_maximum_y_for_collisions_with_enemy_torpedoes &25d7 86 ; starship_minimum_y_for_collisions_with_enemy_torpedoes &25d8 7a ; starship_maximum_x_for_collisions_with_enemy_ships &25d9 8c ; starship_minimum_x_for_collisions_with_enemy_ships &25da 73 ; starship_maximum_y_for_collisions_with_enemy_ships &25db 8c ; starship_minimum_y_for_collisions_with_enemy_ships &25dc 76 ; enemy_ship_was_hit_by_collision_with_other_enemy_ship &25dd 00 ; starship_collided_with_enemy_ship &25de 00 ; frame_of_starship_explosion_after_which_no_collisions &25df 4a ; enemy_ships_collision_x_difference &25e0 00 ; enemy_ships_collision_y_difference &25e1 00 ; unused &25e2 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ; timer_for_low_energy_warning_sound &25f0 00 ; sound_needed_for_low_energy &25f1 00 ; energy_flash_timer &25f2 00 ; flash_energy_when_low &25f3 ad f2 25 LDA &25f2 ; energy_flash_timer &25f6 d0 12 BNE &260a ; energy_is_already_low &25f8 ad 22 19 LDA &1922 ; starship_energy_divided_by_sixteen &25fb c9 32 CMP #&32 &25fd b0 15 BCS &2614 ; consider_warning_sound &25ff a9 04 LDA #&04 &2601 8d f2 25 STA &25f2 ; energy_flash_timer &2604 20 29 26 JSR &2629 ; invert_energy_text &2607 4c 14 26 JMP &2614 ; consider_warning_sound ; energy_is_already_low &260a ce f2 25 DEC &25f2 ; energy_flash_timer &260d c9 02 CMP #&02 &260f d0 03 BNE &2614 &2611 20 29 26 JSR &2629 ; invert_energy_text ; consider_warning_sound &2614 ce f0 25 DEC &25f0 ; timer_for_low_energy_warning_sound &2617 d0 0f BNE &2628 ; leave &2619 a9 08 LDA #&08 &261b 8d f0 25 STA &25f0 ; timer_for_low_energy_warning_sound &261e ad 22 19 LDA &1922 ; starship_energy_divided_by_sixteen &2621 c9 19 CMP #&19 &2623 b0 03 BCS &2628 ; leave &2625 ee f1 25 INC &25f1 ; sound_needed_for_low_energy &2628 60 RTS ; invert_energy_text &2629 a0 2f LDY #&2f ; invert_energy_text_loop &262b b9 48 6e LDA &6e48,Y &262e 49 ff EOR #&ff &2630 99 48 6e STA &6e48,Y &2633 88 DEY &2634 10 f5 BPL &262b ; invert_energy_text_loop &2636 60 RTS ; unused NOPs &2637 ea ea ea ; unused &263a ff ff ff ff ff ff &2640 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ; enemy_ships_can_cloak &2652 01 # A compile-time constant? ; probability_of_enemy_ship_cloaking &2653 3f ; minimum_energy_for_enemy_ship_to_cloak &2654 40 ; enemy_ship_desired_angle_divided_by_eight &2655 00 ; unused &2656 07 ; number_of_live_starship_torpedoes &2657 00 ; starship_fired_torpedo &2658 ea ; scanner_failure_duration &2659 ea ; starship_shields_active_before_failure &265a ea ; starship_torpedo_type &265b 00 ; unused NOPs &265c ea ea ea ea ea ea ea ea ea ea ea ; handle_enemy_ships_cloaking &2667 ad 52 26 LDA &2652 ; enemy_ships_can_cloak &266a f0 5d BEQ &26c9 ; leave # This branch can never happen. &266c ad 4f 0e LDA &0e4f ; maximum_number_of_enemy_ships &266f 8d 54 0e STA &0e54 ; enemy_ships_still_to_consider &2672 a2 00 LDX #&00 ; handle_enemy_ships_cloaking_loop &2674 bd 0a 04 LDA &040a,X ; enemy_ships_type &2677 c9 04 CMP #&04 &2679 66 75 ROR &75 ; cloak_state &267b 30 04 BMI &2681 ; enemy_ship_is_already_cloaked &267d c9 01 CMP #&01 # Only long ships can cloak &267f d0 3e BNE &26bf ; handle_enemy_ships_cloaking_next ; enemy_ship_is_already_cloaked &2681 bc 80 04 LDY &0480,X ; enemy_ships_on_screen &2684 f0 08 BEQ &268e ; enemy_ship_is_on_screen &2686 29 03 AND #&03 # Ships decloak when not on main screen &2688 9d 0a 04 STA &040a,X ; enemy_ships_type &268b 4c bf 26 JMP &26bf ; handle_enemy_ships_cloaking_next ; enemy_ship_is_on_screen &268e bc 89 04 LDY &0489,X ; enemy_ships_energy &2691 cc 54 26 CPY &2654 ; minimum_energy_for_enemy_ship_to_cloak &2694 b0 0f BCS &26a5 ; enemy_ship_has_sufficient_energy_to_cloak &2696 06 75 ASL &75 ; cloak_state &2698 90 25 BCC &26bf ; handle_enemy_ships_cloaking_next &269a 29 03 AND #&03 # Uncloak it if cloaked, and plot &269c 9d 0a 04 STA &040a,X ; enemy_ships_type &269f 20 fc 1b JSR &1bfc ; plot_enemy_ship &26a2 4c bf 26 JMP &26bf ; handle_enemy_ships_cloaking_next ; enemy_ship_has_sufficient_energy_to_cloak &26a5 06 75 ASL &75 ; cloak_state &26a7 b0 16 BCS &26bf ; handle_enemy_ships_cloaking_next # Leave it cloaked if so &26a9 20 13 21 JSR &2113 ; random_number_generator &26ac ad d2 1c LDA &1cd2 ; rnd_2 &26af 2d 53 26 AND &2653 ; probability_of_enemy_ship_cloaking &26b2 d0 0b BNE &26bf ; handle_enemy_ships_cloaking_next &26b4 20 fc 1b JSR &1bfc ; plot_enemy_ship # Otherwise, mark as cloaked and unplot &26b7 bd 0a 04 LDA &040a,X ; enemy_ships_type &26ba 09 04 ORA #&04 &26bc 9d 0a 04 STA &040a,X ; enemy_ships_type ; handle_enemy_ships_cloaking_next &26bf 8a TXA &26c0 18 CLC &26c1 69 0b ADC #&0b &26c3 aa TAX &26c4 ce 54 0e DEC &0e54 ; enemy_ships_still_to_consider &26c7 d0 ab BNE &2674 ; handle_enemy_ships_cloaking_loop &26c9 60 RTS ; unused NOPs &26ca ea ea ; fire_enemy_torpedo &26cc ad 55 0e LDA &0e55 ; torpedoes_still_to_consider &26cf f0 1d BEQ &26ee ; leave_after_clearing_carry &26d1 bd 8a 04 LDA &048a,X ; enemy_ships_firing_cooldown # Lower four bits are torpedo cooldown &26d4 29 0f AND #&0f &26d6 d0 16 BNE &26ee ; leave_after_clearing_carry # Can't fire unless this is zero &26d8 a0 00 LDY #&00 ; find_enemy_torpedo_slot_loop &26da b1 80 LDA (&80),Y ; enemy_torpedo_address &26dc f0 12 BEQ &26f0 ; free_slot &26de a5 80 LDA &80 ; enemy_torpedo_address_low &26e0 18 CLC &26e1 69 06 ADC #&06 &26e3 85 80 STA &80 ; enemy_torpedo_address_low &26e5 90 02 BCC &26e9 &26e7 e6 81 INC &81 ; enemy_torpedo_address_high &26e9 ce 55 0e DEC &0e55 ; torpedoes_still_to_consider &26ec d0 ec BNE &26da ; find_enemy_torpedo_slot_loop ; leave_after_clearing_carry &26ee 18 CLC # No torpedo fired &26ef 60 RTS ; free_slot &26f0 bd 87 04 LDA &0487,X ; enemy_ships_angle &26f3 4a LSR A &26f4 4a LSR A &26f5 4a LSR A &26f6 cd 55 26 CMP &2655 ; enemy_ship_desired_angle_divided_by_eight &26f9 d0 f3 BNE &26ee ; leave_after_clearing_carry # Can't fire if not pointing at starship &26fb bd 8a 04 LDA &048a,X ; enemy_ships_firing_cooldown &26fe 4a LSR A # Upper four bits are maximum cooldown &26ff 4a LSR A &2700 4a LSR A &2701 4a LSR A &2702 7d 8a 04 ADC &048a,X ; enemy_ships_firing_cooldown &2705 9d 8a 04 STA &048a,X ; enemy_ships_firing_cooldown # Reset torpedo cooldown &2708 bd 09 04 LDA &0409,X ; enemy_ships_flags_or_explosion_timer &270b 29 10 AND #&10 ; cluster_torpedoes &270d f0 03 BEQ &2712 ; single_torpedo &270f 4c d4 29 JMP &29d4 ; fire_enemy_torpedo_cluster ; single_torpedo &2712 ad 36 0e LDA &0e36 ; value_used_for_enemy_torpedo_ttl &2715 a0 00 LDY #&00 &2717 91 80 STA (&80),Y ; torpedo_ttl &2719 bd 87 04 LDA &0487,X ; enemy_ships_angle &271c a0 05 LDY #&05 &271e 91 80 STA (&80),Y ; torpedo_angle &2720 4a LSR A &2721 4a LSR A &2722 4a LSR A &2723 a8 TAY &2724 b9 58 0e LDA &0e58,Y ; sine_table &2727 18 CLC &2728 7d 82 04 ADC &0482,X ; enemy_ships_x_pixels &272b 85 7a STA &7a ; x # torpedo_x = enemy_ship_x + sin(angle) &272d b9 78 0e LDA &0e78,Y ; cosine_table &2730 18 CLC &2731 7d 85 04 ADC &0485,X ; enemy_ships_y_pixels &2734 a0 04 LDY #&04 &2736 91 80 STA (&80),Y ; torpedo_y_pixels # torpedo_y = enemy_ship_y + cos(angle) &2738 a0 02 LDY #&02 &273a a5 7a LDA &7a ; x &273c 91 80 STA (&80),Y ; torpedo_x_pixels &273e ee dc 1c INC &1cdc ; enemy_ship_fired_torpedo &2741 86 75 STX &75 ; enemy_ship_offset &2743 20 11 16 JSR &1611 ; plot_enemy_torpedo &2746 a6 75 LDX &75 ; enemy_ship_offset &2748 ce 55 0e DEC &0e55 ; torpedoes_still_to_consider &274b a5 80 LDA &80 ; enemy_torpedo_address_low &274d 18 CLC &274e 69 06 ADC #&06 &2750 85 80 STA &80 ; enemy_torpedo_address_low &2752 90 02 BCC &2756 &2754 e6 81 INC &81 ; enemy_torpedo_address_high &2756 38 SEC # Torpedo fired &2757 60 RTS ; calculate_enemy_ship_angle_to_starship &2758 a5 76 LDA &76 ; enemy_y &275a 38 SEC &275b 30 05 BMI &2762 ; skip_inversion_y &275d 49 ff EOR #&ff &275f e9 01 SBC #&01 &2761 18 CLC ; skip_inversion_y &2762 66 75 ROR &75 ; note_of_inversions_and_swap # Note whether inversion occurred &2764 38 SEC &2765 e9 7f SBC #&7f &2767 85 7b STA &7b ; difference_between_enemy_and_starship_y &2769 a5 77 LDA &77 ; enemy_x &276b 38 SEC &276c 30 05 BMI &2773 ; skip_inversion_x &276e 49 ff EOR #&ff &2770 e9 01 SBC #&01 &2772 18 CLC ; skip_inversion_x &2773 66 75 ROR &75 ; note_of_inversions_and_swap # Note whether inversion occurred &2775 38 SEC &2776 e9 7f SBC #&7f &2778 85 7a STA &7a ; difference_between_enemy_and_starship_x &277a c5 7b CMP &7b ; difference_between_enemy_and_starship_y &277c b0 06 BCS &2784 ; skip_swap # Swap if y is bigger than x &277e a4 7b LDY &7b ; difference_between_enemy_and_starship_y &2780 84 7a STY &7a ; difference_between_enemy_and_starship_x &2782 85 7b STA &7b ; difference_between_enemy_and_starship_y ; skip_swap &2784 66 75 ROR &75 ; note_of_inversions_and_swap # Note whether swap occurred &2786 a9 00 LDA #&00 &2788 85 7c STA &7c ; difference_x_divided_by_difference_y &278a a0 0c LDY #&0c # 12-bit division of difference_x by difference_y ; division_loop &278c 06 7a ASL &7a ; difference_between_enemy_and_starship_x &278e 2a ROL A &278f c5 7b CMP &7b ; difference_between_enemy_and_starship_y &2791 90 02 BCC &2795 ; still_less_than &2793 e5 7b SBC &7b ; difference_between_enemy_and_starship_y ; still_less_than &2795 26 7c ROL &7c ; difference_x_divided_by_difference_y &2797 b0 3a BCS &27d3 ; ninety_degrees # (x*8/y) > &ff (arctan(x/y) > 82.8) = 90 degrees &2799 88 DEY &279a d0 f0 BNE &278c ; division_loop &279c a0 0c LDY #&0c # (x*8/y) < &14 (arctan(x/y) < 32.0) = 0 degrees &279e a5 7c LDA &7c ; difference_x_divided_by_difference_y &27a0 c9 14 CMP #&14 &27a2 90 10 BCC &27b4 ; finished_calculating_partial_angle &27a4 88 DEY ; &b # (x*8/y) < &1e (arctan(x/y) < 43.1) = 22.5 degrees &27a5 c9 1e CMP #&1e &27a7 90 0b BCC &27b4 ; finished_calculating_partial_angle &27a9 88 DEY ; &a # (x*8/y) < &35 (arctan(x/y) < 58.8) = 45 degrees &27aa c9 35 CMP #&35 &27ac 90 06 BCC &27b4 ; finished_calculating_partial_angle &27ae 88 DEY ; &9 # (x*8/y) < &a3 (arctan(x/y) < 78.9) = 67.5 degrees &27af c9 a3 CMP #&a3 &27b1 90 01 BCC &27b4 ; finished_calculating_partial_angle &27b3 88 DEY ; &8 # otherwise = 90 degrees ; finished_calculating_partial_angle &27b4 98 TYA ; adjust_angle_for_inversions_and_swap &27b5 26 75 ROL &75 ; note_of_inversions_and_swap # Set if x and y weren't swapped &27b7 b0 04 BCS &27bd ; skip_angle_swap &27b9 49 07 EOR #&07 &27bb 69 01 ADC #&01 ; skip_angle_swap &27bd 26 75 ROL &75 ; note_of_inversions_and_swap # Set if x wasn't inverted &27bf b0 04 BCS &27c5 ; skip_angle_inversion_x &27c1 49 1f EOR #&1f &27c3 69 01 ADC #&01 ; skip_angle_inversion_x &27c5 26 75 ROL &75 ; note_of_inversions_and_swap # Set if y wasn't inverted &27c7 b0 04 BCS &27cd ; skip_angle_inversion_y &27c9 49 0f EOR #&0f &27cb 69 01 ADC #&01 ; skip_angle_inversion_x &27cd 29 1f AND #&1f &27cf 8d 55 26 STA &2655 ; enemy_ship_desired_angle_divided_by_eight &27d2 60 RTS ; ninety_degrees &27d3 a9 08 LDA #&08 &27d5 d0 de BNE &27b5 ; adjust_angle_for_inversions_and_swap ; unused &27d7 ea ea ea ea 00 00 00 00 00 ; collide_enemy_ships &27e0 a6 80 LDX &80 ; enemy_ship_offset &27e2 bd 89 04 LDA &0489,X ; enemy_ships_energy &27e5 f0 24 BEQ &280b ; first_ship_is_already_exploding &27e7 38 SEC &27e8 ed 31 0e SBC &0e31 ; damage_enemy_ship_incurs_from_collision_with_other_enemy_ship &27eb b0 02 BCS &27ef ; skip_floor &27ed a9 00 LDA #&00 ; skip_floor &27ef 9d 89 04 STA &0489,X ; enemy_ships_energy &27f2 d0 06 BNE &27fa ; first_ship_survives_collision &27f4 20 5d 1f JSR &1f5d ; explode_enemy_ship &27f7 ee dd 25 INC &25dd ; enemy_ship_was_hit_by_collision_with_other_enemy_ship ; first_ship_survives_collision &27fa bd 0a 04 LDA &040a,X ; enemy_ships_type &27fd c9 04 CMP #&04 &27ff 90 0a BCC &280b ; first_ship_isn't_cloaked &2801 29 03 AND #&03 # Remove cloaking &2803 9d 0a 04 STA &040a,X ; enemy_ships_type &2806 a9 01 LDA #&01 &2808 9d 00 04 STA &0400,X ; enemy_ships_previous_on_screen ; first_ship_isn't_cloaked ; first_ship_is_already_exploding &280b a4 82 LDY &82 ; second_enemy_ship_offset &280d bd 08 04 LDA &0408,X ; enemy_ships_velocity &2810 85 7a STA &7a ; first_ship_velocity &2812 b9 08 04 LDA &0408,Y ; enemy_ships_velocity &2815 85 7b STA &7b ; second_ship_velocity &2817 bd 87 04 LDA &0487,X ; enemy_ships_angle # Swap the angles of the two ships &281a 85 88 STA &88 ; first_ship_angle &281c b9 87 04 LDA &0487,Y ; enemy_ships_angle &281f 9d 87 04 STA &0487,X ; enemy_ships_angle &2822 a5 88 LDA &88 ; first_ship_angle &2824 99 87 04 STA &0487,Y ; enemy_ships_angle &2827 38 SEC &2828 fd 87 04 SBC &0487,X ; enemy_ships_angle &282b 10 02 BPL &282f ; skip_inversion &282d 49 ff EOR #&ff ; skip_inversion &282f 4a LSR A &2830 4a LSR A &2831 4a LSR A &2832 4a LSR A &2833 4a LSR A &2834 f0 09 BEQ &283f ; skip_velocity_absorption ; angle_loop # For every 11.25 degrees difference in angle, &2836 46 7a LSR &7a ; first_ship_velocity # halve both ships' velocities &2838 46 7b LSR &7b ; second_ship_velocity &283a 38 SEC &283b e9 01 SBC #&01 &283d d0 f7 BNE &2836 ; angle_loop ; skip_velocity_absorption &283f a5 7a LDA &7a ; first_ship_velocity # Swap the velocities of the two ships &2841 99 08 04 STA &0408,Y ; enemy_ships_velocity &2844 a5 7b LDA &7b ; second_ship_velocity &2846 9d 08 04 STA &0408,X ; enemy_ships_velocity &2849 ad e0 25 LDA &25e0 ; enemy_ships_collision_x_difference &284c cd e1 25 CMP &25e1 ; enemy_ships_collision_y_difference &284f b0 09 BCS &285a ; use_x_pixels_and_difference &2851 e8 INX # Use y_pixels rather than x_pixels &2852 e8 INX &2853 e8 INX &2854 c8 INY &2855 c8 INY &2856 c8 INY &2857 ad e1 25 LDA &25e1 ; enemy_ships_collision_y_difference ; use_x_pixels_and_difference &285a 85 7b STA &7b ; collision_difference &285c ad 3b 0e LDA &0e3b ; size_of_enemy_ship_for_collisions_between_enemy_ships &285f 38 SEC &2860 e5 7b SBC &7b ; collision_difference &2862 18 CLC &2863 69 01 ADC #&01 &2865 4a LSR A &2866 85 7b STA &7b ; something_like_collision_difference &2868 bd 82 04 LDA &0482,X ; enemy_ships_x_pixels &286b d9 82 04 CMP &0482,Y ; enemy_ships_x_pixels &286e b0 06 BCS &2876 ; don't_swap_two_ships_for_collision &2870 84 7a STY &7a ; tmp # First and second swap &2872 8a TXA &2873 a8 TAY &2874 a6 7a LDX &7a ; tmp ; don't_swap_two_ships_for_collision &2876 bd 82 04 LDA &0482,X ; enemy_ships_x_pixels &2879 18 CLC &287a 65 7b ADC &7b ; something_like_collision_difference # Add difference to one &287c b0 03 BCS &2881 ; ; don't_alter_first_ship's_position &287e 9d 82 04 STA &0482,X ; enemy_ships_x_pixels ; don't_alter_first_ship's_position &2881 b9 82 04 LDA &0482,Y ; enemy_ships_x_pixels &2884 38 SEC &2885 e5 7b SBC &7b ; something_like_collision_difference # Subtract it from the other &2887 90 03 BCC &288c ; don't_alter_second_ship's_position &2889 99 82 04 STA &0482,Y ; enemy_ships_x_pixels ; don't_alter_second_ship's_position &288c 4c cc 18 JMP &18cc ; consider_next_second_enemy_ship ; unused &288f ff ; escape_capsule_destroyed &2890 00 ; self_destruct_countdown &2891 00 ; escape_capsule_address ; escape_capsule_on_screen &2892 00 ; escape_capsule_x_fraction &2893 00 ; escape_capsule_x_pixels &2894 00 ; escape_capsule_y_fraction &2895 00 ; escape_capsule_y_pixels &2896 00 ; escape_capsule_launch_direction &2897 00 ; unused NOPs &2898 ea ea ea ea ea ea ea ea ; initialise_game_screen &28a0 20 36 23 JSR &2336 ; disable_cursor &28a3 20 12 23 JSR &2312 ; set_foreground_colour_to_black &28a6 20 1e 23 JSR &231e ; set_background_colour_to_black &28a9 20 03 1f JSR &1f03 ; initialise_starship_explosion_pieces &28ac 20 d5 22 JSR &22d5 ; initialise_envelopes &28af 20 8e 1d JSR &1d8e ; plot_starship &28b2 20 a3 22 JSR &22a3 ; plot_energy_text &28b5 20 b1 22 JSR &22b1 ; plot_one_two_three_four_text &28b8 20 75 22 JSR &2275 ; plot_energy_bar_edges &28bb 20 ac 2e JSR &2eac ; plot_gauge_edges &28be 20 61 2e JSR &2e61 ; plot_scanner_grid &28c1 20 a5 35 JSR &35a5 ; plot_command_number &28c4 20 fa 22 JSR &22fa ; plot_screen_border &28c7 20 24 1d JSR &1d24 ; plot_stars &28ca 20 2b 14 JSR &142b ; plot_top_and_right_edge_of_long_range_scanner_with_blank_text &28cd 20 2f 36 JSR &362f ; initialise_joystick_and_cursor_keys &28d0 20 06 23 JSR &2306 ; set_foreground_colour_to_white &28d3 60 RTS ; unused NOPs &28d4 ea ea ea ; launch_escape_capsule_port &28d7 a0 c0 LDY #&c0 &28d9 d0 02 BNE &28dd ; launch_escape_capsule ; launch_escape_capsule_starboard &28db a0 40 LDY #&40 ; launch_escape_capsule &28dd ee d8 1c INC &1cd8 ; escape_capsule_launched &28e0 8c 97 28 STY &2897 ; escape_capsule_launch_direction &28e3 a9 3f LDA #&3f &28e5 8d 91 28 STA &2891 ; self_destruct_countdown &28e8 20 f7 35 JSR &35f7 ; plot_escape_capsule_launched &28eb a9 7f LDA #&7f &28ed 8d 94 28 STA &2894 ; escape_capsule_x_pixels &28f0 8d 96 28 STA &2896 ; escape_capsule_y_pixels &28f3 8d 92 28 STA &2892 ; escape_capsule_on_screen &28f6 d0 1c BNE &2914 ; update_escape_capsule ; handle_starship_self_destruct &28f8 ad d8 1c LDA &1cd8 ; escape_capsule_launched &28fb f0 67 BEQ &2964 ; leave # Self-destruct only after escape capsule launched &28fd ad 91 28 LDA &2891 ; self_destruct_countdown &2900 f0 0a BEQ &290c ; skip_immense_damage &2902 ce 91 28 DEC &2891 ; self_destruct_countdown &2905 d0 05 BNE &290c ; skip_immense_damage &2907 a9 40 LDA #&40 &2909 8d 1e 19 STA &191e ; damage_high ; skip_immense_damage &290c ad 92 28 LDA &2892 ; escape_capsule_on_screen &290f f0 53 BEQ &2964 ; leave &2911 20 98 29 JSR &2998 ; plot_escape_capsule ; update_escape_capsule &2914 a9 92 LDA #&92 &2916 85 80 STA &80 ; escape_capsule_address_low &2918 a9 28 LDA #&28 ; &2892 = escape_capsule_address &291a 85 81 STA &81 ; escape_capsule_address_high &291c a0 01 LDY #&01 &291e 20 e6 0f JSR &0fe6 ; update_object_position_for_starship_rotation_and_speed &2921 ad 97 28 LDA &2897 ; escape_capsule_launch_direction &2924 18 CLC &2925 6d 33 0e ADC &0e33 ; starship_angle_delta &2928 8d 97 28 STA &2897 ; escape_capsule_launch_direction &292b 4a LSR A &292c 4a LSR A &292d 4a LSR A &292e a8 TAY &292f b9 58 0e LDA &0e58,Y ; sine_table &2932 18 CLC &2933 6d 94 28 ADC &2894 ; escape_capsule_x_pixels &2936 8d 94 28 STA &2894 ; escape_capsule_x_pixels &2939 b9 78 0e LDA &0e78,Y ; cosine_table &293c 18 CLC &293d 6d 96 28 ADC &2896 ; escape_capsule_y_pixels &2940 8d 96 28 STA &2896 ; escape_capsule_y_pixels &2943 38 SEC &2944 e5 7b SBC &7b ; sine_y_plus_cosine_x_pixels &2946 b0 02 BCS &294a ; skip_inversion &2948 49 ff EOR #&ff ; skip_inversion &294a c9 40 CMP #&40 &294c b0 43 BCS &2991 ; mark_escape_capsule_as_off_screen &294e ad 94 28 LDA &2894 ; escape_capsule_x_pixels &2951 38 SEC &2952 e5 7a SBC &7a ; sine_y_plus_cosine_x_fraction &2954 b0 02 BCS &2958 ; skip_inversion &2956 49 ff EOR #&ff ; skip_inversion &2958 c9 40 CMP #&40 &295a b0 35 BCS &2991 ; mark_escape_capsule_as_off_screen &295c 20 9d 15 JSR &159d ; check_for_collision_with_enemy_ships &295f b0 04 BCS &2965 ; escape_capsule_collided_with_enemy_ship &2961 20 98 29 JSR &2998 ; plot_escape_capsule &2964 60 RTS ; escape_capsule_collided_with_enemy_ship &2965 ad 4f 0e LDA &0e4f ; maximum_number_of_enemy_ships &2968 38 SEC &2969 ed 54 0e SBC &0e54 ; enemy_ships_still_to_consider &296c 85 7a STA &7a ; enemy_ship_offset &296e 0a ASL A &296f 0a ASL A &2970 65 7a ADC &7a ; enemy_ship_offset &2972 0a ASL A &2973 65 7a ADC &7a ; enemy_ship_offset &2975 aa TAX &2976 bd 89 04 LDA &0489,X ; enemy_ships_energy &2979 f0 08 BEQ &2983 ; enemy_ship_is_already_exploding &297b a9 00 LDA #&00 &297d 9d 89 04 STA &0489,X ; enemy_ships_energy &2980 20 5d 1f JSR &1f5d ; explode_enemy_ship ; enemy_ship_is_already_exploding &2983 a0 00 LDY #&00 &2985 8c 92 28 STY &2892 ; escape_capsule_on_screen &2988 20 8a 13 JSR &138a ; plot_expiring_torpedo &298b a9 01 LDA #&01 &298d 8d 90 28 STA &2890 ; escape_capsule_destroyed &2990 60 RTS ; mark_escape_capsule_as_off_screen &2991 a9 00 LDA #&00 &2993 8d 92 28 STA &2892 ; escape_capsule_on_screen &2996 60 RTS ; unused &2997 ea ; plot_escape_capsule &2998 ad 94 28 LDA &2894 ; escape_capsule_x_pixels &299b 85 7a STA &7a ; x &299d ad 96 28 LDA &2896 ; escape_capsule_y_pixels &29a0 85 7b STA &7b ; y &29a2 20 64 0f JSR &0f64 ; eor_pixel &29a5 e6 7a INC &7a ; x &29a7 20 64 0f JSR &0f64 ; eor_pixel &29aa e6 7b INC &7b ; y &29ac c6 7a DEC &7a ; x &29ae 20 64 0f JSR &0f64 ; eor_pixel &29b1 c6 7a DEC &7a ; x &29b3 c6 7b DEC &7b ; y &29b5 20 64 0f JSR &0f64 ; eor_pixel &29b8 e6 7a INC &7a ; x &29ba c6 7b DEC &7b ; y &29bc 20 64 0f JSR &0f64 ; eor_pixel &29bf 60 RTS ; unused NOPs &29c0 ea ea ea ea ea ea ea ea ea ea ea ea ea ea ea ea &29d0 ea ea ea ea ; fire_enemy_torpedo_cluster &29d4 bd 87 04 LDA &0487,X ; enemy_ships_angle &29d7 4a LSR A &29d8 4a LSR A &29d9 4a LSR A &29da a8 TAY &29db b9 58 0e LDA &0e58,Y ; sine_table &29de 18 CLC &29df 7d 82 04 ADC &0482,X ; enemy_ships_x_pixels &29e2 85 73 STA &73 ; x_pixels # torpedo_x = enemy_ship_x + sin(angle) &29e4 b9 78 0e LDA &0e78,Y ; cosine_table &29e7 18 CLC &29e8 7d 85 04 ADC &0485,X ; enemy_ships_y_pixels &29eb 85 72 STA &72 ; y_pixels # torpedo_y = enemy_ship_y + cos(angle) &29ed 20 13 2a JSR &2a13 ; add_single_torpedo_to_enemy_torpedo_cluster &29f0 c6 73 DEC &73 ; x_pixels &29f2 c6 73 DEC &73 ; x_pixels # torpedo_x = enemy_ship_x + sin(angle) - 2 &29f4 c6 72 DEC &72 ; y_pixels &29f6 c6 72 DEC &72 ; y_pixels # torpedo_y = enemy_ship_y + cos(angle) - 2 &29f8 20 13 2a JSR &2a13 ; add_single_torpedo_to_enemy_torpedo_cluster &29fb e6 73 INC &73 ; x_pixels &29fd e6 73 INC &73 ; x_pixels # torpedo_x = enemy_ship_x + sin(angle) &29ff c6 72 DEC &72 ; y_pixels &2a01 c6 72 DEC &72 ; y_pixels # torpedo_y = enemy_ship_y + cos(angle) - 4 &2a03 20 13 2a JSR &2a13 ; add_single_torpedo_to_enemy_torpedo_cluster &2a06 e6 73 INC &73 ; x_pixels &2a08 e6 73 INC &73 ; x_pixels # torpedo_x = enemy_ship_x + sin(angle) + 2 &2a0a e6 72 INC &72 ; y_pixels &2a0c e6 72 INC &72 ; y_pixels # torpedo_y = enemy_ship_y + cos(angle) - 2 &2a0e 20 13 2a JSR &2a13 ; add_single_torpedo_to_enemy_torpedo_cluster &2a11 38 SEC # Torpedo was fired &2a12 60 RTS ; add_single_torpedo_to_enemy_torpedo_cluster &2a13 a0 00 LDY #&00 &2a15 ad 36 0e LDA &0e36 ; value_used_for_enemy_torpedo_ttl &2a18 91 80 STA (&80),Y ; torpedo_ttl &2a1a a0 02 LDY #&02 &2a1c a5 73 LDA &73 ; x_pixels &2a1e 91 80 STA (&80),Y ; torpedo_x_pixels &2a20 a0 04 LDY #&04 &2a22 a5 72 LDA &72 ; y_pixels &2a24 91 80 STA (&80),Y ; torpedo_y_pixels &2a26 c8 INY &2a27 bd 87 04 LDA &0487,X ; enemy_ships_angle &2a2a 91 80 STA (&80),Y ; torpedo_angle &2a2c ee dc 1c INC &1cdc ; enemy_ship_fired_torpedo &2a2f 86 75 STX &75 ; enemy_ship_offset &2a31 20 11 16 JSR &1611 ; plot_enemy_torpedo &2a34 a6 75 LDX &75 ; enemy_ship_offset &2a36 a0 00 LDY #&00 ; find_free_torpedo_slot &2a38 ce 55 0e DEC &0e55 ; torpedoes_still_to_consider &2a3b f0 10 BEQ &2a4d ; don't_add_any_more_torpedoes_to_cluster &2a3d a5 80 LDA &80 ; enemy_torpedo_address_low &2a3f 18 CLC &2a40 69 06 ADC #&06 &2a42 85 80 STA &80 ; enemy_torpedo_address_low &2a44 90 02 BCC &2a48 &2a46 e6 81 INC &81 ; enemy_torpedo_address_high &2a48 b1 80 LDA (&80),Y ; torpedo_ttl &2a4a d0 ec BNE &2a38 ; find_free_torpedo_slot &2a4c 60 RTS ; don't_add_any_more_torpedoes_to_cluster &2a4d 68 PLA # Abandon remainder of fire_enemy_torpedo_cluster &2a4e 68 PLA &2a4f 38 SEC # Torpedo was fired &2a50 60 RTS ; unused NOPs &2a51 ea ea ea ea ea ; angle_to_action_table &2a56 00 ; decrease angle &2a57 00 ; decrease angle &2a58 01 ; decrease velocity, decrease angle &2a59 03 ; decrease velocity twice, decrease angle &2a5a 07 ; decrease velocity twice, increase angle &2a5b 05 ; decrease velocity, increase angle &2a5c 02 ; increase angle &2a5d 02 ; increase angle ; unused &2a5e ea ; enemy_ship_behaviour_routine_low_table ; 0 1 2 3 4 5 6 7 4 0 7 5 6 2 3 4 &2a5f 49 b1 ee 1e 41 6a 2e 61 41 49 61 6a 2e ee 1e b1 ; unused &2a60 ea ; enemy_ship_behaviour_routine_high_table ; 0 1 2 3 4 5 6 7 4 0 7 5 6 2 3 4 &2a70 32 32 32 33 33 33 37 37 33 32 37 33 37 32 33 32 ; unused &2a80 ea ; enemy_ship_desired_velocity &2a81 00 ; partial_velocity_for_damaged_enemy_ships &2a82 06 ; desired_velocity_for_intact_enemy_ships &2a83 18 ; unused NOPs &2a84 ea ea ea ea ea ea ea ; enemy_ship_defensive_behaviour_handling &2a8b bd 80 04 LDA &0480,X ; enemy_ships_on_screen &2a8e d0 5f BNE &2aef ; unset_retreating_flags &2a90 bd 82 04 LDA &0482,X ; enemy_ships_x_pixels &2a93 85 77 STA &77 ; enemy_x &2a95 bd 85 04 LDA &0485,X ; enemy_ships_y_pixels &2a98 85 76 STA &76 ; enemy_y &2a9a 20 58 27 JSR &2758 ; calculate_enemy_ship_angle_to_starship &2a9d bc 88 04 LDY &0488,X ; enemy_ships_temporary_behaviour_flags &2aa0 30 10 BMI &2ab2 ; skip_retreating_because_of_damage # If not already retreating, &2aa2 bd 09 04 LDA &0409,X ; enemy_ships_flags_or_explosion_timer &2aa5 29 40 AND #&40 ; defensive_about_damage &2aa7 f0 09 BEQ &2ab2 ; skip_retreating_because_of_damage # and enemy ship is defensive_about_damage &2aa9 98 TYA &2aaa 29 0f AND #&0f &2aac f0 04 BEQ &2ab2 ; skip_retreating_because_of_damage # and enemy_ship_hit_count > 0 &2aae 98 TYA &2aaf 09 80 ORA #&80 ; retreating # set retreating &2ab1 a8 TAY ; skip_retreating_because_of_damage &2ab2 bd 09 04 LDA &0409,X ; enemy_ships_flags_or_explosion_timer &2ab5 29 20 AND #&20 ; defensive_about_angle &2ab7 f0 26 BEQ &2adf ; skip_retreating_because_of_angle &2ab9 98 TYA &2aba 29 40 AND #&40 ; retreating_because_of_angle &2abc d0 11 BNE &2acf ; already_retreating_because_of_angle # If not already retreating because of angle, &2abe ad 55 26 LDA &2655 ; enemy_ship_desired_angle_divided_by_eight &2ac1 18 CLC &2ac2 69 03 ADC #&03 &2ac4 29 1f AND #&1f &2ac6 c9 07 CMP #&07 # If within 33.75 degrees of starship &2ac8 b0 15 BCS &2adf ; skip_retreating_because_of_angle &2aca 98 TYA &2acb 09 40 ORA #&40 ; retreating_because_of_angle # Set retreating_because_of_angle &2acd d0 11 BNE &2ae0 ; set_temporary_behaviour_flags ; already_retreating_because_of_angle # If retreating because of angle, &2acf ad 55 26 LDA &2655 ; enemy_ship_desired_angle_divided_by_eight &2ad2 18 CLC &2ad3 69 05 ADC #&05 &2ad5 29 1f AND #&1f &2ad7 c9 0b CMP #&0b # If not within 56.25 degrees of starship &2ad9 90 04 BCC &2adf ; skip_retreating_because_of_angle &2adb 98 TYA &2adc 29 bf AND #&bf # Unset retreating_because_of_angle &2ade a8 TAY ; skip_retreating_because_of_angle &2adf 98 TYA ; set_temporary_behaviour_flags &2ae0 9d 88 04 STA &0488,X ; enemy_ships_temporary_behaviour_flags &2ae3 29 c0 AND #&c0 ; retreating | retreating_because_of_angle &2ae5 f0 10 BEQ &2af7 ; leave_after_clearing_carry # If retreating, &2ae7 20 cf 2b JSR &2bcf ; turn_enemy_ship_towards_desired_angle &2aea 20 3a 2c JSR &2c3a ; increase_or_decrease_enemy_ship_velocity_towards_desired_velocity &2aed 38 SEC # Skip behaviour routine &2aee 60 RTS ; unset_retreating_flags &2aef bd 88 04 LDA &0488,X ; enemy_ships_temporary_behaviour_flags &2af2 29 3f AND #&3f # Unset retreating | retreating_because_of_angle &2af4 9d 88 04 STA &0488,X ; enemy_ships_temporary_behaviour_flags ; leave_after_clearing_carry &2af7 18 CLC # Do behaviour routine &2af8 60 RTS ; unused NOPs &2af9 ea ea ea ea ea ea ea ea ; get_rectilinear_distance_from_centre_of_screen_accounting_for_starship_velocity &2b01 bd 82 04 LDA &0482,X ; enemy_ships_x_pixels &2b04 30 02 BMI &2b08 ; skip_inversion &2b06 49 ff EOR #&ff ; skip_inversion &2b08 85 7a STA &7a ; magnitude_x_pixels &2b0a ad 01 0f LDA &0f01 ; starship_velocity_low &2b0d 85 7b STA &7b ; fraction &2b0f ad 00 0f LDA &0f00 ; starship_velocity_high &2b12 06 7b ASL &7b ; fraction &2b14 2a ROL A &2b15 06 7b ASL &7b ; fraction &2b17 2a ROL A &2b18 06 7b ASL &7b ; fraction &2b1a 2a ROL A # starship_velocity_high * 8 &2b1b 7d 85 04 ADC &0485,X ; enemy_ships_y_pixels &2b1e 30 02 BMI &2b22 ; skip_inversion &2b20 49 ff EOR #&ff ; skip_inversion &2b22 18 CLC &2b23 65 7a ADC &7a ; magnitude_x_pixels &2b25 60 RTS ; get_rectilinear_distance_from_centre_of_screen &2b26 bd 82 04 LDA &0482,X ; enemy_ships_x_pixels &2b29 30 02 BMI &2b2d ; skip_inversion_x &2b2b 49 ff EOR #&ff ; skip_inversion_x &2b2d 85 7a STA &7a : magnitude_x_pixels &2b2f bd 85 04 LDA &0485,X ; enemy_ships_y_pixels &2b32 30 02 BMI &2b36 ; skip_inversion_y &2b34 49 ff EOR #&ff ; skip_inversion_y &2b36 18 CLC &2b37 65 7a ADC &7a ; magnitude_x_pixels &2b39 60 RTS ; unused NOPs &2b3a ea ea ea ea ea ea ea ea ; turn_enemy_ship_towards_starship_using_pixels_or_screens # Unused entry point &2b42 bd 80 04 LDA &0480,X ; enemy_ships_on_screen &2b45 f0 0d BEQ &2b54 ; turn_enemy_ship_towards_starship_using_pixels ; turn_enemy_ship_towards_starship_using_screens &2b47 bd 83 04 LDA &0483,X ; enemy_ships_x_screens &2b4a 85 77 STA &77 ; enemy_x &2b4c bd 86 04 LDA &0486,X ; enemy_ships_y_screens &2b4f 85 76 STA &76 ; enemy_y &2b51 4c 5e 2b JMP &2b5e ; turn_enemy_ship_towards_starship ; turn_enemy_ship_towards_starship_using_pixels # Unused entry point &2b54 bd 82 04 LDA &0482,X ; enemy_ships_x_pixels &2b57 85 77 STA &77 ; enemy_x &2b59 bd 85 04 LDA &0485,X ; enemy_ships_y_pixels &2b5c 85 76 STA &76 ; enemy_y ; turn_enemy_ship_towards_starship &2b5e 20 58 27 JSR &2758 ; calculate_enemy_ship_angle_to_starship ; turn_enemy_ship_towards_desired_angle_accounting_for_starship_velocity &2b61 ad 55 26 LDA &2655 ; enemy_ship_desired_angle_divided_by_eight &2b64 18 CLC &2b65 69 10 ADC #&10 &2b67 29 1f AND #&1f &2b69 8d 55 26 STA &2655 ; enemy_ship_desired_angle_divided_by_eight &2b6c c9 11 CMP #&11 &2b6e 90 05 BCC &2b75 ; skip_inversion &2b70 49 1f EOR #&1f &2b72 69 00 ADC #&00 &2b74 38 SEC ; skip_inversion &2b75 66 75 ROR &75 ; note_of_inversion &2b77 a8 TAY &2b78 b9 58 0e LDA &0e58,Y ; sine_table &2b7b 85 7b STA &7b ; sine &2b7d ad 01 0f LDA &0f01 ; starship_velocity_low &2b80 85 7a STA &7a ; fraction &2b82 ad 00 0f LDA &0f00 ; starship_velocity_high &2b85 06 7a ASL &7a ; fraction &2b87 2a ROL A &2b88 06 7a ASL &7a ; fraction &2b8a 2a ROL A &2b8b 06 7a ASL &7a ; fraction &2b8d 2a ROL A &2b8e 85 7a STA &7a ; starship_velocity_times_eight &2b90 a9 00 LDA #&00 &2b92 a0 03 LDY #&03 # 3-bit multiplication of sine by starship_velocity * 8 ; loop_over_bits_of_sine &2b94 46 7b LSR &7b ; sine &2b96 90 03 BCC &2b9b ; sine_bit_unset &2b98 18 CLC &2b99 65 7a ADC &7a ; starship_velocity_times_eight ; sine_bit_unset &2b9b 6a ROR A &2b9c 88 DEY &2b9d d0 f5 BNE &2b94 ; loop_over_bits_of_sine # A = starship_velocity * 8 * sin(angle) &2b9f 4a LSR A &2ba0 c9 02 CMP #&02 &2ba2 90 15 BCC &2bb9 ; finished_calculating_change_in_angle &2ba4 c8 INY ; 1 &2ba5 c9 05 CMP #&05 &2ba7 90 10 BCC &2bb9 ; finished_calculating_change_in_angle &2ba9 c8 INY ; 2 &2baa c9 08 CMP #&08 &2bac 90 0b BCC &2bb9 ; finished_calculating_change_in_angle &2bae c8 INY ; 3 &2baf c9 0b CMP #&0b &2bb1 90 06 BCC &2bb9 ; finished_calculating_change_in_angle &2bb3 c8 INY ; 4 &2bb4 c9 0e CMP #&0e &2bb6 90 01 BCC &2bb9 ; finished_calculating_change_in_angle &2bb8 c8 INY ; 5 ; finished_calculating_change_in_angle &2bb9 98 TYA &2bba 06 75 ASL &75 ; note_of_inversion &2bbc 90 04 BCC &2bc2 ; skip_uninversion &2bbe 49 1f EOR #&1f &2bc0 69 00 ADC #&00 ; skip_uninversion &2bc2 85 7b STA &7b ; change_in_angle &2bc4 ad 55 26 LDA &2655 ; enemy_ship_desired_angle_divided_by_eight &2bc7 38 SEC &2bc8 e5 7b SBC &7b : change_in_angle # Adjust angle to account for starship velocity &2bca 29 1f AND #&1f &2bcc 8d 55 26 STA &2655 ; enemy_ship_desired_angle_divided_by_eight ; turn_enemy_ship_towards_desired_angle &2bcf bd 87 04 LDA &0487,X ; enemy_ships_angle &2bd2 4a LSR A &2bd3 4a LSR A &2bd4 4a LSR A &2bd5 38 SEC &2bd6 ed 55 26 SBC &2655 ; enemy_ship_desired_angle_divided_by_eight &2bd9 f0 35 BEQ &2c10 ; no_change_needed_to_enemy_ship_angle &2bdb 4a LSR A &2bdc 4a LSR A &2bdd 29 07 AND #&07 &2bdf a8 TAY &2be0 b9 56 2a LDA &2a56,Y ; angle_to_action_table &2be3 85 7b STA &7b ; action_bits &2be5 46 7b LSR &7b ; action_bits &2be7 90 0a BCC &2bf3 ; skip_velocity_decrease &2be9 20 29 2c JSR &2c29 ; decrease_enemy_ship_velocity &2bec 46 7b LSR &7b ; action_bits &2bee 90 03 BCC &2bf3 ; skip_velocity_decrease &2bf0 20 29 2c JSR &2c29 ; decrease_enemy_ship_velocity ; skip_velocity_decrease &2bf3 46 7b LSR &7b ; action_bits &2bf5 b0 09 BCS &2c00 ; increase_angle &2bf7 de 87 04 DEC &0487,X ; enemy_ships_angle &2bfa de 87 04 DEC &0487,X ; enemy_ships_angle &2bfd 4c 06 2c JMP &2c06 ; increase_angle &2c00 fe 87 04 INC &0487,X ; enemy_ships_angle &2c03 fe 87 04 INC &0487,X ; enemy_ships_angle &2c06 bd 87 04 LDA &0487,X ; enemy_ships_angle &2c09 4a LSR A &2c0a 4a LSR A &2c0b 4a LSR A &2c0c 38 SEC &2c0d ed 55 26 SBC &2655 ; enemy_ship_desired_angle_divided_by_eight ; no_change_needed_to_enemy_ship_angle &2c10 60 RTS ; unused NOPs &2c11 ea ea ea ea ea ea ea ea ; unused_routine_to_turn_enemy_ship_on_screen_towards_starship &2c19 bd 82 04 LDA &0482,X ; enemy_ships_x_pixels &2c1c 85 77 STA &77 ; enemy_x &2c1e bd 85 04 LDA &0485,X ; enemy_ships_y_pixels &2c21 85 76 STA &76 ; enemy_y &2c23 20 58 27 JSR &2758 ; calculate_enemy_ship_angle_to_starship &2c26 4c cf 2b JMP &2bcf ; turn_enemy_ship_towards_desired_angle ; decrease_enemy_ship_velocity &2c29 bd 08 04 LDA &0408,X ; enemy_ships_velocity &2c2c f0 06 BEQ &2c34 ; leave &2c2e 38 SEC &2c2f e9 01 SBC #&01 &2c31 9d 08 04 STA &0408,X ; enemy_ships_velocity &2c34 60 RTS ; unused_NOPs &2c35 ea ea ea ea ea ; increase_or_decrease_enemy_ship_velocity_towards_desired_velocity &2c3a ad 81 2a LDA &2a81 ; enemy_ship_desired_velocity &2c3d dd 08 04 CMP &0408,X ; enemy_ships_velocity &2c40 f0 0e BEQ &2c50 ; leave &2c42 b0 06 BCS &2c4a ; increase &2c44 de 08 04 DEC &0408,X ; enemy_ships_velocity &2c47 4c 4d 2c JMP &2c4d ; compare_velocity ; increase &2c4a fe 08 04 INC &0408,X ; enemy_ships_velocity ; compare_velocity &2c4d dd 08 04 CMP &0408,X ; enemy_ships_velocity # Comparison is never actually used &2c50 60 RTS ; unused NOPs &2c51 ea ea ea ea ea ea ea ea ; unused &2c59 00 00 00 00 00 00 00 ; starship_sprites ; starship_sprite_1 &2c60 41 41 41 43 e7 a7 a5 a3 04 04 04 84 ce ca 4a 8a &2c70 fb 4f 43 05 0d 0d 0d 07 be e4 84 40 60 60 60 c0 ; starship_sprite_2 &2c80 03 0c 10 13 24 25 24 13 80 60 10 90 48 48 48 90 &2c90 10 4c e3 e6 fc e6 e3 40 10 64 8e ce 7e ce 8e 04 ; starship_sprite_3 &2ca0 01 07 4c 4c 47 41 e2 a1 00 c0 64 64 c4 04 8e 0a &2cb0 a2 a1 93 9c a8 44 02 01 8a 0a 92 72 2a 44 80 00 ; starship_sprite_4 &2cc0 01 01 03 c3 c6 c6 cc cd 00 00 80 86 c6 c6 66 66 &2cd0 f9 c3 fc c6 f3 d9 cd 07 3e 86 7e c6 9e 36 66 c0 ; starship_sprite_5 &2ce0 00 03 04 08 11 12 11 48 00 80 40 20 10 90 10 24 &2cf0 e4 e3 d2 da ee e4 42 41 4e 8e 96 b6 ee 4e 84 04 ; starship_sprite_6 &2d00 03 06 4c 47 42 e2 a2 a2 80 c0 64 c4 84 8e 8a 8a &2d10 92 8a 85 91 a9 45 43 01 92 a2 42 12 2a 44 84 00 ; starship_sprite_7 &2d20 01 01 43 43 46 e6 ed ed 00 00 84 84 c4 ce 6e 6e &2d30 f9 c1 fd c3 f9 ed e6 43 3e 06 7e 86 3e 6e ce 84 ; starship_sprite_8 &2d40 07 0c 19 1b 1b 19 0c c7 c0 60 30 b0 b0 30 60 c6 &2d50 c1 e3 f3 db cf c3 c3 c1 06 8e 9e b6 e6 86 86 06 ; unused &2d60 ea ; velocity_gauge_position &2d61 00 ; rotation_gauge_position &2d62 00 ; score_delta_low &2d63 00 ; score_delta_high &2d64 00 ; score_as_bcd &2d65 00 00 00 ; unused NOPs &2d68 ea ea ea ea ea ea ; score_as_digits &2d6e 00 00 00 00 00 00 ; unused &2d74 ea ; scores_for_destroying_enemy_ships &2d75 08 ; regular ship, starship torpedo # &1ce0 = 0 &2d76 12 ; large or cloaked ship, starship torpedo &2d77 01 ; regular ship, enemy torpedo # &1ce0 = 1 &2d78 02 ; large or cloaked ship, enemy torpedo &2d79 32 ; regular ship, escape capsule # &1ce0 = 2 &2d7a 40 ; large or cloaked ship, escape capsule &2d7b 01 ; regular ship, collision with other enemy ship # &1ce0 = -1 &2d7c 02 ; large or cloaked ship, collision with other enemy ship &2d7d 02 ; regular ship, collision with starship # &1ce0 = -1 &2d7e 04 ; large ship, collision with starship ; unused NOPs &2d7f ea ea ea ea ea ea ea ; score_points_for_destroying_enemy_ship &2d86 a9 01 LDA #&01 &2d88 9d 00 04 STA &0400,X ; enemy_ships_previous_on_screen &2d8b ad e0 1c LDA &1ce0 ; how_enemy_ship_was_damaged &2d8e 0a ASL A &2d8f a8 TAY &2d90 ad 52 26 LDA &2652 ; enemy_ships_can_cloak &2d93 f0 0d BEQ &2da2 ; not_cloaked # This branch can never happen. &2d95 c8 INY &2d96 bd 0a 04 LDA &040a,X ; enemy_ships_type &2d99 c9 04 CMP #&04 &2d9b b0 05 BCS &2da2 ; not_cloaked &2d9d c9 01 CMP #&01 &2d9f f0 01 BEQ &2da2 ; not_cloaked &2da1 88 DEY ; not_cloaked &2da2 98 TYA &2da3 10 0d BPL &2db2 ; convert_offset_to_score &2da5 29 07 AND #&07 &2da7 a8 TAY &2da8 ad de 25 LDA &25de ; starship_collided_with_enemy_ship &2dab f0 05 BEQ &2db2 ; convert_offset_to_score &2dad ce de 25 DEC &25de ; starship_collided_with_enemy_ship &2db0 c8 INY &2db1 c8 INY ; convert_offset_to_score &2db2 b9 75 2d LDA &2d75,Y ; scores_for_destroying_enemy_ships &2db5 18 CLC &2db6 78 SEI &2db7 f8 SED &2db8 6d 63 2d ADC &2d63 ; score_delta_low &2dbb 8d 63 2d STA &2d63 ; score_delta_low &2dbe ad 64 2d LDA &2d64 ; score_delta_high &2dc1 69 00 ADC #&00 &2dc3 8d 64 2d STA &2d64 ; score_delta_high &2dc6 d8 CLD &2dc7 58 CLI &2dc8 60 RTS ; unused NOPs &2dc9 ea ea ea ea ea ea ea ; apply_delta_to_score &2dd0 ad 63 2d LDA &2d63 ; score_delta_low &2dd3 18 CLC &2dd4 78 SEI &2dd5 f8 SED &2dd6 6d 65 2d ADC &2d65 ; score_as_bcd &2dd9 8d 65 2d STA &2d65 ; score_as_bcd &2ddc ad 66 2d LDA &2d66 ; score_as_bcd + 1 &2ddf 6d 64 2d ADC &2d64 ; score_delta_high &2de2 8d 66 2d STA &2d66 ; score_as_bcd + 1 &2de5 ad 67 2d LDA &2d67 ; score_as_bcd + 2 &2de8 69 00 ADC #&00 &2dea 8d 67 2d STA &2d67 ; score_as_bcd + 2 &2ded d8 CLD &2dee 58 CLI &2def a9 00 LDA #&00 &2df1 cd 63 2d CMP &2d63 ; score_delta_low &2df4 d0 05 BNE &2dfb ; zero_score_delate &2df6 cd 64 2d CMP &2d64 ; score_delta_high &2df9 f0 63 BEQ &2e5e ; leave # No need to update score if delta is zero ; zero_score_delate &2dfb 8d 63 2d STA &2d63 ; score_delta_low &2dfe 8d 64 2d STA &2d64 ; score_delta_high ; convert_score_as_bcd_to_score_as_digits &2e01 ad 67 2d LDA &2d67 ; score_as_bcd + 2 &2e04 4a LSR A &2e05 4a LSR A &2e06 4a LSR A &2e07 4a LSR A &2e08 8d 73 2d STA &2d73 ; score_as_digits + 5 &2e0b ad 67 2d LDA &2d67 ; score_as_bcd + 2 &2e0e 29 0f AND #&0f &2e10 8d 72 2d STA &2d72 ; score_as_digits + 4 &2e13 ad 66 2d LDA &2d66 ; score_as_bcd + 1 &2e16 4a LSR A &2e17 4a LSR A &2e18 4a LSR A &2e19 4a LSR A &2e1a 8d 71 2d STA &2d71 ; score_as_digits + 3 &2e1d ad 66 2d LDA &2d66 ; score_as_bcd + 1 &2e20 29 0f AND #&0f &2e22 8d 70 2d STA &2d70 ; score_as_digits + 2 &2e25 ad 65 2d LDA &2d65 ; score_as_bcd &2e28 4a LSR A &2e29 4a LSR A &2e2a 4a LSR A &2e2b 4a LSR A &2e2c 8d 6f 2d STA &2d6f ; score_as_digits + 1 &2e2f ad 65 2d LDA &2d65 ; score_as_bcd &2e32 29 0f AND #&0f &2e34 8d 6e 2d STA &2d6e ; score_as_digits &2e37 a9 1f LDA #&1f ; TAB # TAB(&21, &1e) &2e39 20 ee ff JSR &ffee ; OSWRCH &2e3c a9 21 LDA #&21 &2e3e 20 ee ff JSR &ffee ; OSWRCH &2e41 a9 1e LDA #&1e &2e43 20 ee ff JSR &ffee ; OSWRCH &2e46 a0 05 LDY #&05 &2e48 a2 20 LDX #&20 ; " " ; plot_score_loop # Plot score with leading " "s &2e4a b9 6e 2d LDA &2d6e,Y ; score_as_digits &2e4d d0 04 BNE &2e53 ; non_zero_digit &2e4f 8a TXA &2e50 4c 58 2e JMP &2e58 ; leading_zero ; non_zero_digit &2e53 18 CLC &2e54 69 30 ADC #&30 &2e56 a2 30 LDX #&30 ; "0" ; leading_zero &2e58 20 ee ff JSR &ffee ; OSWRCH &2e5b 88 DEY &2e5c 10 ec BPL &2e4a ; plot_score_loop ; leave &2e5e 60 RTS ; unused NOPs &2e5f ea ea ; plot_scanner_grid &2e61 e6 79 INC &79 ; screen_start_high # Change origin to top left of long range scanner &2e63 a9 09 LDA #&09 &2e65 85 7a STA &7a ; x &2e67 a9 05 LDA #&05 &2e69 85 72 STA &72 ; vertical_lines &2e6b 85 73 STA &73 ; horizontal_lines ; plot_vertical_lines_outer_loop &2e6d a9 41 LDA #&41 &2e6f 85 7b STA &7b ; y &2e71 a9 31 LDA #&31 &2e73 85 7c STA &7c ; height ; plot_vertical_lines_inner_loop &2e75 20 06 0f JSR &0f06 ; set_pixel &2e78 e6 7b INC &7b ; y &2e7a c6 7c DEC &7c ; height &2e7c d0 f7 BNE &2e75 ; plot_vertical_lines_inner_loop &2e7e a5 7a LDA &7a ; x &2e80 18 CLC &2e81 69 0a ADC #&0a &2e83 85 7a STA &7a ; x &2e85 c6 72 DEC &72 ; vertical_lines &2e87 d0 e4 BNE &2e6d ; plot_vertical_lines_outer_loop &2e89 a9 4a LDA #&4a &2e8b 85 7b STA &7b ; y ; plot_horizontal_lines_outer_loop &2e8d a9 00 LDA #&00 &2e8f 85 7a STA &7a ; x &2e91 a9 32 LDA #&32 &2e93 85 7c STA &7c ; width ; plot_horizontal_lines_inner_loop &2e95 20 06 0f JSR &0f06 ; set_pixel &2e98 e6 7a INC &7a ; x &2e9a c6 7c DEC &7c ; width &2e9c d0 f7 BNE &2e95 ; plot_horizontal_lines_inner_loop &2e9e a5 7b LDA &7b ; y &2ea0 18 CLC &2ea1 69 0a ADC #&0a &2ea3 85 7b STA &7b ; y &2ea5 c6 73 DEC &73 ; horizontal_lines &2ea7 d0 e4 BNE &2e8d ; plot_horizontal_lines_outer_loop &2ea9 c6 79 DEC &79 ; screen_start_high # Restore origin &2eab 60 RTS ; plot_gauge_edges &2eac e6 79 INC &79 ; screen_start_high # Change origin to top left of long range scanner &2eae a9 35 LDA #&35 &2eb0 85 7a STA &7a ; x &2eb2 a9 41 LDA #&41 &2eb4 85 7b STA &7b ; y &2eb6 a9 42 LDA #&42 &2eb8 20 cf 1b JSR &1bcf ; plot_vertical_line &2ebb a9 3b LDA #&3b &2ebd 85 7a STA &7a ; x &2ebf a9 41 LDA #&41 &2ec1 85 7b STA &7b ; y &2ec3 a9 42 LDA #&42 &2ec5 20 cf 1b JSR &1bcf ; plot_vertical_line &2ec8 a9 05 LDA #&05 &2eca 85 7a STA &7a ; x &2ecc a9 77 LDA #&77 &2ece 85 7b STA &7b ; y &2ed0 a9 2b LDA #&2b &2ed2 20 db 1b JSR &1bdb ; plot_horizontal_line &2ed5 a9 07 LDA #&07 &2ed7 20 cf 1b JSR &1bcf ; plot_vertical_line &2eda a9 05 LDA #&05 &2edc 85 7a STA &7a ; x &2ede a9 78 LDA #&78 &2ee0 85 7b STA &7b ; y &2ee2 a9 06 LDA #&06 &2ee4 20 cf 1b JSR &1bcf ; plot_vertical_line &2ee7 a9 2c LDA #&2c &2ee9 20 db 1b JSR &1bdb ; plot_horizontal_line &2eec a9 00 LDA #&00 &2eee 85 7a STA &7a ; x &2ef0 a9 83 LDA #&83 &2ef2 85 7b STA &7b ; y &2ef4 a9 3f LDA #&3f &2ef6 20 db 1b JSR &1bdb ; plot_horizontal_line &2ef9 a9 1a LDA #&1a &2efb 85 7a STA &7a ; x &2efd a9 75 LDA #&75 &2eff 85 7b STA &7b ; y &2f01 20 06 0f JSR &0f06 ; set_pixel &2f04 e6 7a INC &7a ; x &2f06 20 06 0f JSR &0f06 ; set_pixel &2f09 e6 7b INC &7b ; y &2f0b 20 06 0f JSR &0f06 ; set_pixel &2f0e c6 7a DEC &7a ; x &2f10 20 06 0f JSR &0f06 ; set_pixel &2f13 a9 7f LDA #&7f &2f15 85 7b STA &7b ; y &2f17 20 06 0f JSR &0f06 ; set_pixel &2f1a e6 7a INC &7a ; x &2f1c 20 06 0f JSR &0f06 ; set_pixel &2f1f e6 7b INC &7b ; y &2f21 20 06 0f JSR &0f06 ; set_pixel &2f24 c6 7a DEC &7a ; x &2f26 20 06 0f JSR &0f06 ; set_pixel &2f29 a9 00 LDA #&00 &2f2b 85 7a STA &7a ; x &2f2d a9 e7 LDA #&e7 &2f2f 85 7b STA &7b ; y &2f31 a9 3f LDA #&3f &2f33 20 db 1b JSR &1bdb ; plot_horizontal_line &2f36 c6 79 DEC &79 ; screen_start_high # Restore origin &2f38 60 RTS ; unused NOPs &2f39 ea ea ea ea ea ea ea ea ea ea ea ea ; plot_starship_velocity_and_rotation_on_gauges &2f45 e6 79 INC &79 ; screen_start_high # Change origin to top left of long range scanner &2f47 ad 01 0f LDA &0f01 ; starship_velocity_low &2f4a 85 7b STA &7b ; y &2f4c ad 00 0f LDA &0f00 ; starship_velocity_high &2f4f 06 7b ASL &7b ; y &2f51 2a ROL A &2f52 06 7b ASL &7b ; y &2f54 2a ROL A &2f55 06 7b ASL &7b ; y &2f57 2a ROL A &2f58 06 7b ASL &7b ; y &2f5a 2a ROL A &2f5b cd 61 2d CMP &2d61 ; velocity_gauge_position &2f5e f0 3e BEQ &2f9e ; skip_velocity_gauge &2f60 a8 TAY &2f61 a9 81 LDA #&81 &2f63 38 SEC &2f64 ed 61 2d SBC &2d61 ; velocity_gauge_position &2f67 85 7b STA &7b ; y &2f69 8c 61 2d STY &2d61 ; velocity_gauge_position &2f6c a9 36 LDA #&36 &2f6e 85 7a STA &7a ; x &2f70 a9 05 LDA #&05 &2f72 85 88 STA &88 ; width_for_set &2f74 85 7c STA &7c ; width_for_unset ; plot_velocity_gauge_unset_loop &2f76 20 0e 0f JSR &0f0e ; unset_pixel &2f79 e6 7b INC &7b ; y &2f7b 20 0e 0f JSR &0f0e ; unset_pixel &2f7e c6 7b DEC &7b ; y &2f80 e6 7a INC &7a ; x &2f82 c6 88 DEC &88 ; width_for_unset &2f84 d0 f0 BNE &2f76 ; plot_velocity_gauge_unset_loop &2f86 a9 81 LDA #&81 &2f88 38 SEC &2f89 ed 61 2d SBC &2d61 ; velocity_gauge_position &2f8c 85 7b STA &7b ; y ; plot_velocity_gauge_set_loop &2f8e c6 7a DEC &7a ; x &2f90 20 06 0f JSR &0f06 ; set_pixel &2f93 e6 7b INC &7b ; y &2f95 20 06 0f JSR &0f06 ; set_pixel &2f98 c6 7b DEC &7b ; y &2f9a c6 7c DEC &7c ; width_for_set &2f9c d0 f0 BNE &2f8e ; plot_velocity_gauge_set_loop ; skip_velocity_gauge &2f9e ad 28 19 LDA &1928 ; starship_rotation_fraction &2fa1 85 7b STA &7b ; y &2fa3 ad 02 0f LDA &0f02 ; starship_rotation &2fa6 38 SEC &2fa7 e9 7b SBC #&7b &2fa9 06 7b ASL &7b ; y &2fab 2a ROL A &2fac 06 7b ASL &7b ; y &2fae 2a ROL A &2faf cd 62 2d CMP &2d62 ; rotation_gauge_position &2fb2 f0 56 BEQ &300a ; skip_rotation_gauge &2fb4 a8 TAY &2fb5 ad 62 2d LDA &2d62 ; rotation_gauge_position &2fb8 8c 62 2d STY &2d62 ; rotation_gauge_position &2fbb c9 15 CMP #&15 &2fbd 90 08 BCC &2fc7 ; set_rotation_gauge_position_for_unset # Rotating anticlockwise &2fbf e9 03 SBC #&03 &2fc1 c9 14 CMP #&14 &2fc3 b0 02 BCS &2fc7 ; set_rotation_gauge_position_for_unset # Rotating clockwise &2fc5 a9 14 LDA #&14 ; set_rotation_gauge_position_for_unset &2fc7 18 CLC &2fc8 69 06 ADC #&06 &2fca 85 7a STA &7a ; x &2fcc a9 78 LDA #&78 &2fce 85 7b STA &7b ; y &2fd0 a9 06 LDA #&06 &2fd2 85 88 STA &88 ; height_for_unset &2fd4 85 7c STA &7c ; height_for_set ; plot_rotation_gauge_unset_loop &2fd6 20 0e 0f JSR &0f0e ; unset_pixel &2fd9 e6 7a INC &7a ; x &2fdb 20 0e 0f JSR &0f0e ; unset_pixel &2fde c6 7a DEC &7a ; x &2fe0 e6 7b INC &7b ; y &2fe2 c6 88 DEC &88 ; height_for_unset &2fe4 d0 f0 BNE &2fd6 ; plot_rotation_gauge_unset_loop &2fe6 ad 62 2d LDA &2d62 ; rotation_gauge_position &2fe9 c9 15 CMP #&15 &2feb 90 08 BCC &2ff5 ; set_rotation_gauge_position_for_set &2fed e9 03 SBC #&03 &2fef c9 14 CMP #&14 &2ff1 b0 02 BCS &2ff5 ; set_rotation_gauge_position_for_set &2ff3 a9 14 LDA #&14 ; set_rotation_gauge_position_for_set &2ff5 18 CLC &2ff6 69 06 ADC #&06 &2ff8 85 7a STA &7a ; x ; plot_rotation_gauge_set_loop &2ffa c6 7b DEC &7b ; y &2ffc 20 06 0f JSR &0f06 ; set_pixel &2fff e6 7a INC &7a ; x &3001 20 06 0f JSR &0f06 ; set_pixel &3004 c6 7a DEC &7a ; x &3006 c6 7c DEC &7c ; height_for_set &3008 d0 f0 BNE &2ffa ; plot_rotation_gauge_set_loop ; skip_rotation_gauge &300a c6 79 DEC &79 ; screen_start_high &300c 60 RTS ; unused NOPs &300d ea ea ea ea ea ea ea ea ea ea ea ea ; plot_enemy_ships_on_scanners &3019 e6 79 INC &79 ; screen_start_high # Change origin to top left of long range scanner &301b ad 4f 0e LDA &0e4f ; maximum_number_of_enemy_ships &301e 8d 54 0e STA &0e54 ; enemy_ships_still_to_consider &3021 a2 00 LDX #&00 ; plot_enemy_ships_on_scanners_loop &3023 86 75 STX &75 ; enemy_ship_offset &3025 bd 03 04 LDA &0403,X ; enemy_ships_previous_x_screens &3028 c9 60 CMP #&60 &302a 90 79 BCC &30a5 ; skip_unplotting_enemy_ship_on_scanner &302c c9 9f CMP #&9f &302e b0 75 BCS &30a5 ; skip_unplotting_enemy_ship_on_scanner &3030 85 7a STA &7a ; x &3032 bd 06 04 LDA &0406,X ; enemy_ships_previous_y_screens &3035 c9 60 CMP #&60 &3037 90 6c BCC &30a5 ; skip_unplotting_enemy_ship_on_scanner &3039 c9 9f CMP #&9f &303b b0 68 BCS &30a5 ; skip_unplotting_enemy_ship_on_scanner &303d 69 a1 ADC #&a1 &303f 85 7b STA &7b ; y &3041 a5 7a LDA &7a ; x &3043 18 CLC &3044 69 a0 ADC #&a0 &3046 85 7a STA &7a ; x &3048 20 0e 0f JSR &0f0e ; unset_pixel # Remove from long range scanner &304b a5 7a LDA &7a ; x &304d 38 SEC &304e e9 1d SBC #&1d &3050 90 53 BCC &30a5 ; skip_unplotting_enemy_ship_on_scanner &3052 c9 05 CMP #&05 &3054 b0 4f BCS &30a5 ; skip_unplotting_enemy_ship_on_scanner &3056 a8 TAY &3057 a5 7b LDA &7b ; y &3059 38 SEC &305a e9 1e SBC #&1e &305c 90 47 BCC &30a5 ; skip_unplotting_enemy_ship_on_scanner &305e c9 05 CMP #&05 &3060 b0 43 BCS &30a5 ; skip_unplotting_enemy_ship_on_scanner &3062 0a ASL A &3063 85 7b STA &7b ; y &3065 0a ASL A &3066 0a ASL A &3067 65 7b ADC &7b ; y &3069 85 7b STA &7b ; y &306b a6 75 LDX &75 ; enemy_ship_offset &306d bd 05 04 LDA &0405,X ; enemy_ships_previous_y_pixels &3070 4a LSR A &3071 4a LSR A &3072 4a LSR A &3073 4a LSR A &3074 4a LSR A &3075 18 CLC &3076 65 7b ADC &7b ; y &3078 69 41 ADC #&41 &307a 85 7b STA &7b ; y &307c 98 TYA &307d 0a ASL A &307e 85 7a STA &7a ; x &3080 0a ASL A &3081 0a ASL A &3082 65 7a ADC &7a ; x &3084 85 7a STA &7a ; x &3086 bd 02 04 LDA &0402,X ; enemy_ships_previous_x_pixels &3089 4a LSR A &308a 4a LSR A &308b 4a LSR A &308c 4a LSR A &308d 4a LSR A &308e 18 CLC &308f 65 7a ADC &7a ; x &3091 85 7a STA &7a ; x &3093 20 0e 0f JSR &0f0e ; unset_pixel # Remove from short range scanner &3096 e6 7a INC &7a ; x &3098 20 0e 0f JSR &0f0e ; unset_pixel &309b e6 7b INC &7b ; y &309d 20 0e 0f JSR &0f0e ; unset_pixel &30a0 c6 7a DEC &7a ; x &30a2 20 0e 0f JSR &0f0e ; unset_pixel ; skip_unplotting_enemy_ship_on_scanner &30a5 ad 56 0e LDA &0e56 ; starship_shields_active &30a8 f0 07 BEQ &30b1 ; to_skip_plotting_enemy_ship_on_scanner &30aa a6 75 LDX &75 ; enemy_ship_offset &30ac bd 89 04 LDA &0489,X ; enemy_ships_energy &30af d0 03 BNE &30b4 ; to_skip_plotting_enemy_ship_on_scanner &30b1 4c 34 31 JMP &3134 ; skip_plotting_enemy_ship_on_scanner &30b4 bd 83 04 LDA &0483,X ; enemy_ships_x_screens &30b7 c9 60 CMP #&60 &30b9 90 79 BCC &3134 ; skip_plotting_enemy_ship_on_scanner &30bb c9 9f CMP #&9f &30bd b0 75 BCS &3134 ; skip_plotting_enemy_ship_on_scanner &30bf 85 7a STA &7a ; x &30c1 bd 86 04 LDA &0486,X ; enemy_ships_y_screens &30c4 c9 60 CMP #&60 &30c6 90 6c BCC &3134 ; skip_plotting_enemy_ship_on_scanner &30c8 c9 9f CMP #&9f &30ca b0 68 BCS &3134 ; skip_plotting_enemy_ship_on_scanner &30cc 69 a1 ADC #&a1 &30ce 85 7b STA &7b ; y &30d0 a5 7a LDA &7a ; x &30d2 18 CLC &30d3 69 a0 ADC #&a0 &30d5 85 7a STA &7a ; x &30d7 20 06 0f JSR &0f06 ; set_pixel # Add to long range scanner &30da a5 7a LDA &7a ; x &30dc 38 SEC &30dd e9 1d SBC #&1d &30df 90 53 BCC &3134 ; skip_plotting_enemy_ship_on_scanner &30e1 c9 05 CMP #&05 &30e3 b0 4f BCS &3134 ; skip_plotting_enemy_ship_on_scanner &30e5 a8 TAY &30e6 a5 7b LDA &7b ; y &30e8 38 SEC &30e9 e9 1e SBC #&1e &30eb 90 47 BCC &3134 ; skip_plotting_enemy_ship_on_scanner &30ed c9 05 CMP #&05 &30ef b0 43 BCS &3134 ; skip_plotting_enemy_ship_on_scanner &30f1 0a ASL A &30f2 85 7b STA &7b ; y &30f4 0a ASL A &30f5 0a ASL A &30f6 65 7b ADC &7b ; y &30f8 85 7b STA &7b ; y &30fa a6 75 LDX &75 ; enemy_ship_offset &30fc bd 85 04 LDA &0485,X ; enemy_ships_y_pixels &30ff 4a LSR A &3100 4a LSR A &3101 4a LSR A &3102 4a LSR A &3103 4a LSR A &3104 18 CLC &3105 65 7b ADC &7b ; y &3107 69 41 ADC #&41 &3109 85 7b STA &7b ; y &310b 98 TYA &310c 0a ASL A &310d 85 7a STA &7a ; x &310f 0a ASL A &3110 0a ASL A &3111 65 7a ADC &7a ; x &3113 85 7a STA &7a ; x &3115 bd 82 04 LDA &0482,X ; enemy_ships_x_pixels &3118 4a LSR A &3119 4a LSR A &311a 4a LSR A &311b 4a LSR A &311c 4a LSR A &311d 18 CLC &311e 65 7a ADC &7a ; x &3120 85 7a STA &7a ; x &3122 20 06 0f JSR &0f06 ; set_pixel # Add to short range scanner &3125 e6 7a INC &7a ; x &3127 20 06 0f JSR &0f06 ; set_pixel &312a e6 7b INC &7b ; y &312c 20 06 0f JSR &0f06 ; set_pixel &312f c6 7a DEC &7a ; x &3131 20 06 0f JSR &0f06 ; set_pixel ; skip_plotting_enemy_ship_on_scanner &3134 a5 75 LDA &75 ; enemy_ship_offset &3136 18 CLC &3137 69 0b ADC #&0b &3139 aa TAX &313a ce 54 0e DEC &0e54 ; enemy_ships_still_to_consider &313d f0 03 BEQ &3142 &313f 4c 23 30 JMP &3023 ; plot_enemy_ships_on_scanners_loop &3142 a0 1f LDY #&1f &3144 84 7a STY &7a ; x &3146 c8 INY &3147 84 7b STY &7b ; y &3149 20 06 0f JSR &0f06 ; set_pixel # Plot pixel in middle of long range scanner &314c c6 79 DEC &79 ; screen_start_high &314e 60 RTS ; unused NOPs &314f ea ea ea ea ea ea ea ea ea ea ea ea ea ea ea ea &315f ea ea ; handle_scanner_failure &3161 ad 1f 19 LDA &191f ; damage_low &3164 c9 3c CMP #&3c &3166 b0 05 BCS &316d ; starship_incurred_major_damage &3168 ad 1e 19 LDA &191e ; damage_high &316b f0 61 BEQ &31ce ; starship_didn't_incur_major_damage ; starship_incurred_major_damage &316d ad 59 26 LDA &2659 ; scanner_failure_duration &3170 d0 61 BNE &31d3 ; handle_failed_scanner &3172 20 13 21 JSR &2113 ; random_number_generator &3175 ad d2 1c LDA &1cd2 ; rnd_2 &3178 29 6c AND #&6c &317a d0 51 BNE &31cd ; leave ; turn_scanner_to_static &317c ad 56 0e LDA &0e56 ; starship_shields_active &317f 8d 5a 26 STA &265a ; starship_shields_active_before_failure &3182 f0 08 BEQ &318c ; skip_unplotting_scanners &3184 a9 00 LDA #&00 &3186 8d 56 0e STA &0e56 ; starship_shields_active &3189 20 19 30 JSR &3019 ; plot_enemy_ships_on_scanners ; skip_unplotting_scanners &318c ee 56 0e INC &0e56 ; starship_shields_active &318f ad d1 1c LDA &1cd1 ; rnd_1 &3192 09 40 ORA #&40 &3194 8d 59 26 STA &2659 ; scanner_failure_duration &3197 a9 00 LDA #&00 &3199 85 86 STA &86 ; source_address_low &319b 85 80 STA &80 ; screen_address_low &319d a9 d0 LDA #&d0 ; &d000 # Use OS ROM as source of static &319f 85 87 STA &87 ; source_address_high &31a1 a9 59 LDA #&59 ; &5900 = scanner_screen_memory_address &31a3 85 81 STA &81 ; screen_address_high &31a5 a2 08 LDX #&08 ; plot_static_row_loop &31a7 a0 3f LDY #&3f ; plot_static_column_loop &31a9 b1 86 LDA (&86),Y ; source_address &31ab 91 80 STA (&80),Y ; screen_address &31ad 88 DEY &31ae 10 f9 BPL &31a9 ; plot_static_column_loop &31b0 a5 80 LDA &80 ; screen_address_low &31b2 18 CLC &31b3 69 40 ADC #&40 &31b5 85 80 STA &80 ; screen_address_low &31b7 a5 81 LDA &81 ; source_address_high &31b9 69 01 ADC #&01 &31bb 85 81 STA &81 ; source_address_high &31bd a5 86 LDA &86 ; source_address_low &31bf 18 CLC &31c0 69 40 ADC #&40 &31c2 85 86 STA &86 ; source_address_low &31c4 a5 87 LDA &87 ; source_address_high &31c6 69 01 ADC #&01 &31c8 85 87 STA &87 ; source_address_high &31ca ca DEX &31cb d0 da BNE &31a7 ; plot_static_row_loop &31cd 60 RTS ; starship_didn't_incur_major_damage &31ce ad 59 26 LDA &2659 ; scanner_failure_duration &31d1 f0 31 BEQ &3204 ; leave ; handle_failed_scanner &31d3 ce 59 26 DEC &2659 ; scanner_failure_duration &31d6 f0 2d BEQ &3205 ; clear_long_range_scanner &31d8 a9 00 LDA #&00 &31da 85 80 STA &80 ; screen_address_low &31dc a9 59 LDA #&59 ; &5900 = scanner_screen_memory_address &31de 85 81 STA &81 ; screen_address_high &31e0 a2 08 LDX #&08 ; update_static_row_loop &31e2 a0 3f LDY #&3f ; update_static_column_loop &31e4 b1 80 LDA (&80),Y ; screen_address &31e6 45 7b EOR &7b ; static_eor &31e8 91 80 STA (&80),Y ; screen_address &31ea 85 7b STA &7b ; static_eor &31ec 88 DEY &31ed 10 f5 BPL &31e4 ; update_static_column_loop &31ef a5 80 LDA &80 ; screen_address_low &31f1 18 CLC &31f2 69 40 ADC #&40 &31f4 85 80 STA &80 ; screen_address_low &31f6 a5 81 LDA &81 ; screen_address_high &31f8 69 01 ADC #&01 &31fa 85 81 STA &81 ; screen_address_high &31fc ca DEX &31fd d0 e3 BNE &31e2 ; update_static_row_loop &31ff a5 7b LDA &7b ; static_eor &3201 8d 3f 59 STA &593f ; unused_copy_of_scanner_static_eor # Unused variable; static_eor is essentially random &3204 60 RTS ; clear_long_range_scanner &3205 a9 00 LDA #&00 &3207 85 80 STA &80 ; screen_address_low &3209 a9 59 LDA #&59 ; ; &5900 = scanner_screen_memory_address &320b 85 81 STA &81 ; screen_address_high &320d a2 08 LDX #&08 ; clear_long_range_scanner_row_loop &320f a0 3f LDY #&3f &3211 a9 00 LDA #&00 ; clear_long_range_scanner_column_loop &3213 91 80 STA (&80),Y ; screen_address &3215 88 DEY &3216 10 fb BPL &3213 ; clear_long_range_scanner_column_loop &3218 a5 80 LDA &80 ; screen_address_low &321a 18 CLC &321b 69 40 ADC #&40 &321d 85 80 STA &80 ; screen_address_low &321f a5 81 LDA &81 ; screen_address_high &3221 69 01 ADC #&01 &3223 85 81 STA &81 ; screen_address_high &3225 ca DEX &3226 d0 e7 BNE &320f ; clear_long_range_scanner_row_loop &3228 a9 00 LDA #&00 &322a 8d 56 0e STA &0e56 ; starship_shields_active &322d 20 2b 14 JSR &142b ; plot_top_and_right_edge_of_long_range_scanner_with_blank_text &3230 ad 5a 26 LDA &265a ; starship_shields_active_before_failure &3233 d0 cf BNE &3204 ; leave &3235 20 08 14 JSR &1408 ; unplot_long_range_scanner_if_shields_inactive &3238 60 RTS ; unused NOPs &3239 ea ea ea ea ea ea ea ea ea ea ea ea ea ea ea ea ; enemy_ship_behaviour_routine_zero # Timid ship, retreats upwards as soon as on screen &3249 bd 88 04 LDA &0488,X ; enemy_ships_temporary_behaviour_flags &324c 29 10 AND #&10 ; enemy_ship_was_on_screen_above &324e d0 16 BNE &3266 ; skip_setting_enemy_ship_was_on_screen_above &3250 bd 83 04 LDA &0483,X ; enemy_ships_x_screens &3253 c9 7f CMP #&7f &3255 d0 3b BNE &3292 ; not_on_screen_above &3257 bd 86 04 LDA &0486,X ; enemy_ships_y_screens &325a c9 7e CMP #&7e # Is the enemy ship on the screen above the starship? &325c d0 34 BNE &3292 ; not_on_screen_above &325e bd 88 04 LDA &0488,X ; enemy_ships_temporary_behaviour_flags &3261 09 10 ORA #&10 ; enemy_ship_was_on_screen_above # If so, set enemy_ship_was_on_screen_above &3263 9d 88 04 STA &0488,X ; enemy_ships_temporary_behaviour_flags ; skip_setting_enemy_ship_was_on_screen_above &3266 a9 04 LDA #&04 # Move slowly on screen above starship &3268 8d 81 2a STA &2a81 ; enemy_ship_desired_velocity &326b 20 3a 2c JSR &2c3a ; increase_or_decrease_enemy_ship_velocity_towards_desired_velocity &326e bd 80 04 LDA &0480,X ; enemy_ships_on_screen &3271 d0 0b BNE &327e ; not_on_screen # If it appears on main screen pointing at starship, &3273 20 61 2b JSR &2b61 ; turn_enemy_ship_towards_desired_angle_accounting_for_starship_velocity &3276 d0 36 BNE &32ae ; to_return_from_enemy_ship_behaviour_routine &3278 20 cc 26 JSR &26cc ; fire_enemy_torpedo # then fire; otherwise leave &327b 4c d2 36 JMP &36d2 ; return_from_enemy_ship_behaviour_routine ; not_on_screen &327e 20 47 2b JSR &2b47 ; turn_enemy_ship_towards_starship_using_screens &3281 a5 76 LDA &76 ; enemy_ship_y_screens &3283 c9 80 CMP #&80 # Is the enemy ship on a screen below the starship? &3285 90 27 BCC &32ae ; to_return_from_enemy_ship_behaviour_routine &3287 bd 88 04 LDA &0488,X ; enemy_ships_temporary_behaviour_flags &328a 29 ef AND #&ef # If so, unset enemy_ship_was_on_screen_above &328c 9d 88 04 STA &0488,X ; enemy_ships_temporary_behaviour_flags &328f 4c d2 36 JMP &36d2 ; return_from_enemy_ship_behaviour_routine ; not_on_screen_above &3292 bd 83 04 LDA &0483,X ; enemy_ships_x_screens &3295 85 77 STA &77 ; enemy_x &3297 bd 86 04 LDA &0486,X ; enemy_ships_y_screens &329a 18 CLC &329b 69 01 ADC #&01 &329d 85 76 STA &76 ; enemy_y &329f 20 5e 2b JSR &2b5e ; turn_enemy_ship_towards_starship # Aim at centre of screen above starship &32a2 ad 81 2a LDA &2a81 ; enemy_ship_desired_velocity &32a5 18 CLC &32a6 69 0a ADC #&0a # Boost speed &32a8 8d 81 2a STA &2a81 ; enemy_ship_desired_velocity &32ab 20 3a 2c JSR &2c3a ; increase_or_decrease_enemy_ship_velocity_towards_desired_velocity ; to_return_from_enemy_ship_behaviour_routine &32ae 4c d2 36 JMP &36d2 ; return_from_enemy_ship_behaviour_routine ; enemy_ship_behaviour_routine_one # Comes to a stop near edge of screen when starship is &32b1 bd 80 04 LDA &0480,X ; enemy_ships_on_screen # stationary, follows closer when starship is moving &32b4 d0 2f BNE &32e5 ; off_screen &32b6 20 01 2b JSR &2b01 ; get_rectilinear_distance_from_centre_of_screen_accounting_for_starship_velocity &32b9 c9 40 CMP #&40 &32bb 90 25 BCC &32e2 ; to_set_retreating_and_head_towards_desired_velocity_and_angle &32bd ad 01 0f LDA &0f01 ; starship_velocity_low &32c0 85 7a STA &7a ; fraction &32c2 ad 00 0f LDA &0f00 ; starship_velocity_high &32c5 06 7a ASL &7a ; fraction &32c7 2a ROL A &32c8 85 7b STA &7b ; velocity_high_times_two &32ca 06 7a ASL &7a ; fraction &32cc 2a ROL A &32cd 65 7b ADC &7b ; velocity_high_times_two # Limit velocity to starship_velocity_high * 6 &32cf cd 81 2a CMP &2a81 ; enemy_ship_desired_velocity &32d2 b0 03 BCS &32d7 ; skip_setting_desired_velocity &32d4 8d 81 2a STA &2a81 ; enemy_ship_desired_velocity ; skip_setting_desired_velocity &32d7 20 61 2b JSR &2b61 ; turn_enemy_ship_towards_desired_angle_accounting_for_starship_velocity &32da d0 0c BNE &32e8 ; return_after_changing_velocity &32dc 20 cc 26 JSR &26cc ; fire_enemy_torpedo # Fire if pointing at starship &32df 4c e8 32 JMP &32e8 ; return_after_changing_velocity ; to_set_retreating_and_head_towards_desired_velocity_and_angle &32e2 4c 8d 33 JMP &338d ; set_retreating_and_head_towards_desired_velocity_and_angle ; off_screen &32e5 20 47 2b JSR &2b47 ; turn_enemy_ship_towards_starship_using_screens ; return_after_changing_velocity &32e8 20 3a 2c JSR &2c3a ; increase_or_decrease_enemy_ship_velocity_towards_desired_velocity &32eb 4c d2 36 JMP &36d2 ; return_from_enemy_ship_behaviour_routine ; enemy_ship_behaviour_routine_two # Approaches starship, stops or retreats &32ee bd 80 04 LDA &0480,X ; enemy_ships_on_screen &32f1 d0 22 BNE &3315 ; off_screen &32f3 20 26 2b JSR &2b26 ; get_rectilinear_distance_from_centre_of_screen &32f6 c9 46 CMP #&46 # Retreat if too close &32f8 90 12 BCC &330c ; to_set_retreating_and_head_towards_desired_velocity_and_angle &32fa c9 6e CMP #&6e &32fc b0 11 BCS &330f ; return_after_turning_enemy_ship_towards_desired_angle &32fe 20 29 2c JSR &2c29 ; decrease_enemy_ship_velocity # Slow down when within range &3301 20 61 2b JSR &2b61 ; turn_enemy_ship_towards_desired_angle_accounting_for_starship_velocity &3304 d0 15 BNE &331b ; to_return_from_enemy_ship_behaviour_routine &3306 20 cc 26 JSR &26cc ; fire_enemy_torpedo # Fire if pointing at starship &3309 4c 1b 33 JMP &331b ; to_return_from_enemy_ship_behaviour_routine ; to_set_retreating_and_head_towards_desired_velocity_and_angle &330c 4c 8d 33 JMP &338d ; set_retreating_and_head_towards_desired_velocity_and_angle ; return_after_turning_enemy_ship_towards_desired_angle &330f 20 61 2b JSR &2b61 ; turn_enemy_ship_towards_desired_angle_accounting_for_starship_velocity &3312 4c 18 33 JMP &3318 ; return_after_changing_velocity ; off_screen &3315 20 47 2b JSR &2b47 ; turn_enemy_ship_towards_starship_using_screens ; return_after_changing_velocity &3318 20 3a 2c JSR &2c3a ; increase_or_decrease_enemy_ship_velocity_towards_desired_velocity ; to_return_from_enemy_ship_behaviour_routine &331b 4c d2 36 JMP &36d2 ; return_from_enemy_ship_behaviour_routine ; enemy_ship_behaviour_routine_three # Approaches close, then stops &331e bd 80 04 LDA &0480,X ; enemy_ships_on_screen &3321 d0 15 BNE &3338 ; off_screen &3323 20 61 2b JSR &2b61 ; turn_enemy_ship_towards_desired_angle_accounting_for_starship_velocity &3326 d0 03 BNE &332b ; skip_firing &3328 20 cc 26 JSR &26cc ; fire_enemy_torpedo # Fire if pointing at starship ; skip_firing &332b 20 26 2b JSR &2b26 ; get_rectilinear_distance_from_centre_of_screen &332e c9 78 CMP #&78 &3330 b0 0c BCS &333e ; to_return_from_enemy_ship_behaviour_routine &3332 20 29 2c JSR &2c29 ; decrease_enemy_ship_velocity # Slow down when close &3335 4c d2 36 JMP &36d2 ; return_from_enemy_ship_behaviour_routine ; off_screen &3338 20 47 2b JSR &2b47 ; turn_enemy_ship_towards_starship_using_screens &333b 20 3a 2c JSR &2c3a ; increase_or_decrease_enemy_ship_velocity_towards_desired_velocity ; to_return_from_enemy_ship_behaviour_routine &333e 4c d2 36 JMP &36d2 ; return_from_enemy_ship_behaviour_routine ; enemy_ship_behaviour_routine_four # Approaches very close, then stops &3341 bd 80 04 LDA &0480,X ; enemy_ships_on_screen &3344 d0 1b BNE &3361 ; off_screen &3346 20 26 2b JSR &2b26 ; get_rectilinear_distance_from_centre_of_screen &3349 c9 64 CMP #&64 &334b 90 06 BCC &3353 ; decelerate &334d 20 3a 2c JSR &2c3a ; increase_or_decrease_enemy_ship_velocity_towards_desired_velocity &3350 4c 56 33 JMP &3356 ; skip_deceleration ; decelerate &3353 20 29 2c JSR &2c29 ; decrease_enemy_ship_velocity # Slow down when close ; skip_deceleration &3356 20 61 2b JSR &2b61 ; turn_enemy_ship_towards_desired_angle_accounting_for_starship_velocity &3359 d0 09 BNE &3364 ; return_after_changing_velocity &335b 20 cc 26 JSR &26cc ; fire_enemy_torpedo # Fire if pointing at starship &335e 4c d2 36 JMP &36d2 ; return_from_enemy_ship_behaviour_routine ; off_screen &3361 20 47 2b JSR &2b47 ; turn_enemy_ship_towards_starship_using_screens ; return_after_changing_velocity &3364 20 3a 2c JSR &2c3a ; increase_or_decrease_enemy_ship_velocity_towards_desired_velocity &3367 4c d2 36 JMP &36d2 ; return_from_enemy_ship_behaviour_routine ; enemy_ship_behaviour_routine_five # Approaches very close, then retreats &336a bd 80 04 LDA &0480,X ; enemy_ships_on_screen &336d d0 15 BNE &3384 ; off_screen &336f 20 26 2b JSR &2b26 ; get_rectilinear_distance_from_centre_of_screen &3372 c9 50 CMP #&50 # Retreat if close &3374 90 0b BCC &3381 ; to_set_retreating_and_head_towards_desired_velocity_and_angle &3376 20 61 2b JSR &2b61 ; turn_enemy_ship_towards_desired_angle_accounting_for_starship_velocity &3379 d0 0c BNE &3387 ; return_after_changing_velocity &337b 20 cc 26 JSR &26cc ; fire_enemy_torpedo # Fire if pointing at starship &337e 4c 87 33 JMP &3387 ; return_after_changing_velocity ; to_set_retreating_and_head_towards_desired_velocity_and_angle &3381 4c 8d 33 JMP &338d ; set_retreating_and_head_towards_desired_velocity_and_angle ; off_screen &3384 20 47 2b JSR &2b47 ; turn_enemy_ship_towards_starship_using_screens ; return_after_changing_velocity &3387 20 3a 2c JSR &2c3a ; increase_or_decrease_enemy_ship_velocity_towards_desired_velocity &338a 4c d2 36 JMP &36d2 ; return_from_enemy_ship_behaviour_routine ; set_retreating_and_head_towards_desired_velocity_and_angle &338d bd 88 04 LDA &0488,X ; enemy_ships_temporary_behaviour_flags &3390 09 80 ORA #&80 ; retreating &3392 9d 88 04 STA &0488,X ; enemy_ships_temporary_behaviour_flags &3395 20 cf 2b JSR &2bcf ; turn_enemy_ship_towards_desired_angle &3398 20 3a 2c JSR &2c3a ; increase_or_decrease_enemy_ship_velocity_towards_desired_velocity &339b 4c d2 36 JMP &36d2 ; return_from_enemy_ship_behaviour_routine ; unused &339e ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff &33ae ff ff ff ; maximum_enemy_torpedo_cooldown_per_command &33b1 0f 0d 0b 09 07 05 03 02 ; command_number_used_for_maximum_enemy_torpedo_cooldown_lookup &33b9 00 ; current_command_enemy_ship_spawning_probabilities ; probability_of_new_enemy_ship_being_defensive_about_damage &33ba 00 ; probability_of_new_enemy_ship_being_defensive_about_angle &33bb 00 ; probability_of_new_enemy_ship_firing_torpedo_clusters &33bc 00 ; probability_of_new_enemy_ship_being_large &33bd 00 ; unused &33be 00 &33bf 00 ; change_in_enemy_ship_spawning_probabilities_per_command &33c0 ec &33c1 f2 &33c2 0f &33c3 17 ; unused &33c4 00 &33c5 00 ; ultimate_enemy_ship_probabilities &33c6 20 &33c7 04 &33c8 b8 &33c9 ff ; unused &33ca 00 &33cb 00 ; initial_enemy_ship_spawning_probabilities &33cc c0 &33cd 82 &33ce 04 &33cf 02 ; unused &33d0 00 &33d1 00 ; initialise_enemy_ship &33d2 a9 ff LDA #&ff &33d4 9d 89 04 STA &0489,X ; enemy_ships_energy # Full energy &33d7 ac 54 0e LDY &0e54 ; enemy_ships_still_to_consider &33da a9 00 LDA #&00 &33dc 99 e1 1c STA &1ce1,Y ; enemy_ships_explosion_number - 1 &33df 9d 88 04 STA &0488,X ; enemy_ships_temporary_behaviour_flags &33e2 20 13 21 JSR &2113 ; random_number_generator &33e5 ad d2 1c LDA &1cd2 ; rnd_2 &33e8 29 0f AND #&0f # Pick random behaviour type for enemy ship &33ea 9d 09 04 STA &0409,X ; enemy_ships_flags_or_explosion_timer &33ed a0 5f LDY #&5f &33ef ad d2 1c LDA &1cd2 ; rnd_2 &33f2 10 02 BPL &33f6 &33f4 a0 9f LDY #&9f &33f6 84 7a STY &7a ; y_screens # y_screens is randomly either &5f or &9f &33f8 ad d1 1c LDA &1cd1 ; rnd_1 &33fb 29 1f AND #&1f &33fd 18 CLC &33fe 69 70 ADC #&70 &3400 a8 TAY # x_screens is randomly chosen between &70 - &8f &3401 ad d2 1c LDA &1cd2 ; rnd_2 &3404 0a ASL A &3405 10 05 BPL &340c ; skip_swap &3407 98 TYA # 50% chance of swapping x_screens and y_screens &3408 a4 7a LDY &7a ; y_screens &340a 85 7a STA &7a ; y_screens ; skip_swap &340c 98 TYA &340d 9d 83 04 STA &0483,X ; enemy_ships_x_screens &3410 85 77 STA &77 ; enemy_x &3412 a5 7a LDA &7a ; y_screens &3414 9d 86 04 STA &0486,X ; enemy_ships_y_screens &3417 85 76 STA &76 ; enemy_y &3419 20 58 27 JSR &2758 ; calculate_enemy_ship_angle_to_starship &341c 18 CLC &341d 69 10 ADC #&10 # Initially pointing away from starship &341f 0a ASL A &3420 0a ASL A &3421 0a ASL A &3422 9d 87 04 STA &0487,X ; enemy_ships_angle &3425 20 13 21 JSR &2113 ; random_number_generator # Properties depending on command probabilities &3428 ad ba 33 LDA &33ba ; probability_of_new_enemy_ship_being_defensive_about_damage &342b cd d2 1c CMP &1cd2 ; rnd_2 &342e 90 08 BCC &3438 ; not_defensive_about_damage &3430 bd 09 04 LDA &0409,X ; enemy_ships_flags_or_explosion_timer &3433 09 40 ORA #&40 ; defensive_about_damage &3435 9d 09 04 STA &0409,X ; enemy_ships_flags_or_explosion_timer ; not_defensive_about_damage &3438 ad bb 33 LDA &33bb ; probability_of_new_enemy_ship_being_defensive_about_angle &343b cd d1 1c CMP &1cd1 ; rnd_1 &343e 90 08 BCC &3448 ; not_defensive_about_angle &3440 bd 09 04 LDA &0409,X ; enemy_ships_flags_or_explosion_timer &3443 09 20 ORA #&20 ; defensive_about_angle &3445 9d 09 04 STA &0409,X ; enemy_ships_flags_or_explosion_timer ; defensive_about_angle &3448 20 13 21 JSR &2113 ; random_number_generator &344b ad bc 33 LDA &33bc ; probability_of_new_enemy_ship_firing_torpedo_clusters &344e cd d1 1c CMP &1cd1 ; rnd_1 &3451 90 08 BCC &345b ; clusters_unset &3453 bd 09 04 LDA &0409,X ; enemy_ships_flags_or_explosion_timer &3456 09 10 ORA #&10 ; cluster_torpedoes &3458 9d 09 04 STA &0409,X ; enemy_ships_flags_or_explosion_timer ; clusters_unset &345b a0 00 LDY #&00 &345d ad bd 33 LDA &33bd ; probability_of_new_enemy_ship_being_large &3460 cd d2 1c CMP &1cd2 ; rnd_2 &3463 90 01 BCC &3466 ; small_ship &3465 c8 INY ; small_ship &3466 98 TYA &3467 9d 0a 04 STA &040a,X ; enemy_ships_type &346a 20 13 21 JSR &2113 ; random_number_generator # Maximum torpedo cooldown depends on command number &346d ac b9 33 LDY &33b9 ; command_number_used_for_maximum_enemy_torpedo_cooldown_lookup &3470 c0 08 CPY #&08 &3472 90 02 BCC &3476 ; skip_ceiling &3474 a0 07 LDY #&07 ; skip_ceiling &3476 b9 b1 33 LDA &33b1,Y ; maximum_enemy_torpedo_cooldown_per_command &3479 85 7a STA &7a ; bits_to_pick_at_random # but calculated in a curious way &347b a0 04 LDY #&04 &347d a9 00 LDA #&00 ; calculate_cooldown_loop &347f 46 7a LSR &7a ; bits_to_pick_at_random &3481 90 04 BCC &3487 ; skip_addition &3483 18 CLC &3484 6d d2 1c ADC &1cd2 ; rnd_2 ; skip_addition &3487 6a ROR A &3488 88 DEY &3489 d0 f4 BNE &347f ; calculate_cooldown_loop &348b 18 CLC &348c 69 10 ADC #&10 # and always at least 1 &348e 29 f0 AND #&f0 &3490 9d 8a 04 STA &048a,X ; enemy_ships_firing_cooldown &3493 a9 01 LDA #&01 &3495 9d 80 04 STA &0480,X ; enemy_ships_on_screen &3498 a9 ff LDA #&ff &349a 9d 08 04 STA &0408,X ; enemy_ships_velocity &349d 60 RTS ; unused NOPs &349e ea ea ea ea ea ea ea ea ea ea ea ea ea ea ea ea &34ae ea ea ; starship_type &34b0 00 ; command_number &34b1 00 ; regeneration_rate_for_enemy_ships &34b2 01 ; maximum_timer_for_enemy_ships_regeneration &34b3 04 ; timer_for_enemy_ships_regeneration &34b4 00 ; base_regeneration_rate_for_starship &34b5 0c ; maximum_timer_for_starship_energy_regeneration &34b6 03 ; timer_for_starship_energy_regeneration &34b7 00 ; base_damage_to_enemy_ship_from_other_collision &34b8 14 ; maximum_number_of_stars_in_game &34b9 11 ; minimum_number_of_stars &34ba 01 ; change_in_number_of_stars_per_command &34bb fe ; subtraction_from_starship_regeneration_when_shields_active &34bc 04 ; unused NOPs &34bd ea ea ea ; escape_capsule_launched_string &34c0 44 45 48 43 4e 55 41 4c 19 20 1f 45 4c 55 53 50 41 ; TAB(&20, 17); "ESCAPE" &34d0 43 18 20 1f 45 50 41 43 53 45 17 20 1f ; TAB(&20, 18); "CAPSULE" ; TAB(&20, 19); "LAUNCHED" ; command_move_string &34de 00 81 04 6f 04 19 ; MOVE &046f, &0081 ; command_string &34e4 44 4e 41 4d 4d 4f 43 05 00 a2 04 0f 04 19 ; MOVE &040f, &00a2; "COMMAND" ; unused NOPs &34f2 ea ea ; prepare_starship_for_next_command &34f4 ee b0 34 INC &34b0 ; starship_type &34f7 ee b9 33 INC &33b9 ; command_number_used_for_maximum_enemy_torpedo_cooldown_lookup &34fa ad b1 34 LDA &34b1 ; command_number &34fd 18 CLC &34fe 78 SEI &34ff f8 SED &3500 69 01 ADC #&01 &3502 d8 CLD &3503 58 CLI &3504 8d b1 34 STA &34b1 ; command_number &3507 a9 00 LDA #&00 &3509 8d c9 1c STA &1cc9 ; starship_has_exploded &350c 8d d8 1c STA &1cd8 ; escape_capsule_launched &350f 8d 90 28 STA &2890 ; escape_capsule_destroyed &3512 8d 64 2d STA &2d64 ; score_delta_high &3515 8d 63 2d STA &2d63 ; score_delta_low &3518 8d 1e 19 STA &191e ; damage_high &351b 8d 1f 19 STA &191f ; damage_low &351e 8d 22 19 STA &1922 ; starship_energy_divided_by_sixteen &3521 8d 2c 19 STA &192c ; rotation_damper &3524 8d 31 19 STA &1931 ; velocity_damper &3527 8d 61 2d STA &2d61 ; velocity_gauge_position &352a 8d 62 2d STA &2d62 ; rotation_gauge_position &352d 8d 01 0f STA &0f01 ; starship_velocity_low &3530 8d 03 0f STA &0f03 ; starship_rotation_magnitude &3533 8d 04 0f STA &0f04 ; starship_rotation_cosine &3536 8d 05 0f STA &0f05 ; starship_rotation_sine_magnitude &3539 8d 33 0e STA &0e33 ; starship_angle_delta &353c 8d 3a 19 STA &193a ; previous_starship_automatic_shields &353f 8d f1 25 STA &25f1 ; sound_needed_for_low_energy &3542 8d f2 25 STA &25f2 ; energy_flash_timer &3545 a9 04 LDA #&04 &3547 8d 00 0f STA &0f00 ; starship_velocity_high &354a a9 01 LDA #&01 &354c 8d 59 26 STA &2659 ; scanner_failure_duration &354f 8d 5a 26 STA &265a ; starship_shields_active_before_failure &3552 a9 80 LDA #&80 &3554 8d 32 0e STA &0e32 ; starship_angle_fraction &3557 8d 02 0f STA &0f02 ; starship_rotation &355a 8d 28 19 STA &1928 ; starship_rotation_fraction &355d 8d 24 19 STA &1924 ; starship_automatic_shields &3560 a9 0c LDA #&0c &3562 8d 1d 19 STA &191d ; starship_energy_high &3565 a9 7f LDA #&7f &3567 8d 1c 19 STA &191c ; starship_energy_low &356a a9 0c LDA #&0c &356c 20 ee ff JSR &ffee ; OSWRCH &356f a2 08 LDX #&08 &3571 a0 20 LDY #&20 ; &2008 = unused NOPs # Bug. &3573 a9 07 LDA #&07 ; Generate a sound (SOUND) &3575 20 f1 ff JSR &fff1 ; OSWORD ; initialise_starship_sprite &3578 ad b0 34 LDA &34b0 ; starship_type &357b 0a ASL A &357c 0a ASL A &357d 0a ASL A &357e 0a ASL A &357f 0a ASL A &3580 a8 TAY &3581 a2 00 LDX #&00 ; initialise_starship_sprite_loop &3583 b9 60 2c LDA &2c60,Y ; starship_sprites # Copy starship sprite into user-defined characters &3586 9d 00 0c STA &0c00,X &3589 c8 INY &358a e8 INX &358b e0 20 CPX #&20 &358d d0 f4 BNE &3583 ; initialise_starship_sprite_loop &358f 20 58 1d JSR &1d58 ; initialise_stars_at_random_positions &3592 20 14 36 JSR &3614 ; initialise_enemy_ships &3595 20 a0 28 JSR &28a0 ; initialise_game_screen &3598 20 f2 16 JSR &16f2 ; plot_enemy_ships &359b 60 RTS ; unused NOPs &359c ea ea ea ea ea ea ea ea ea ; plot_command_number &35a5 a9 d4 LDA #&d4 &35a7 85 7b STA &7b ; y &35a9 a9 00 LDA #&00 &35ab 85 7a STA &7a ; x &35ad e6 79 INC &79 ; screen_start_high # Change origin to top left of long range scanner &35af a9 3f LDA #&3f &35b1 20 db 1b JSR &1bdb ; plot_horizontal_line &35b4 c6 79 DEC &79 ; screen_start_high &35b6 a0 0d LDY #&0d ; plot_command_loop &35b8 b9 e4 34 LDA &34e4,Y ; command_string &35bb 20 ee ff JSR &ffee ; OSWRCH &35be 88 DEY &35bf 10 f7 BPL &35b8 ; plot_command_loop &35c1 a0 73 LDY #&73 &35c3 ad b1 34 LDA &34b1 ; command_number &35c6 4a LSR A &35c7 4a LSR A &35c8 4a LSR A &35c9 4a LSR A &35ca aa TAX &35cb f0 02 BEQ &35cf ; single_digit_command_number_for_move &35cd a0 63 LDY #&63 ; single_digit_command_number_for_move &35cf 8c e1 34 STY &34e1 ; command_move_text + 3 # Set horizontal position of text &35d2 a0 05 LDY #&05 ; plot_command_move_loop &35d4 b9 de 34 LDA &34de,Y ; command_move_string &35d7 20 ee ff JSR &ffee ; OSWRCH &35da 88 DEY &35db 10 f7 BPL &35d4 ; plot_command_move_loop &35dd 8a TXA &35de f0 06 BEQ &35e6 ; single_digit_command_number &35e0 18 CLC &35e1 69 30 ADC #&30 &35e3 20 ee ff JSR &ffee ; OSWRCH ; single_digit_command_number &35e6 ad b1 34 LDA &34b1 ; command_number &35e9 29 0f AND #&0f &35eb 18 CLC &35ec 69 30 ADC #&30 &35ee 20 ee ff JSR &ffee ; OSWRCH &35f1 a9 04 LDA #&04 &35f3 20 ee ff JSR &ffee ; OSWRCH &35f6 60 RTS ; plot_escape_capsule_launched &35f7 a0 1d LDY #&1d ; plot_escape_capsule_launched_loop_loop &35f9 b9 c0 34 LDA &34c0,Y ; escape_capsule_launched_string &35fc 20 ee ff JSR &ffee ; OSWRCH &35ff 88 DEY &3600 10 f7 BPL &35f9 ; plot_escape_capsule_launched_loop &3602 a9 c8 LDA #&c8 &3604 85 7b STA &7b ; y &3606 a9 3f LDA #&3f &3608 85 7a STA &7a ; x &360a e6 79 INC &79 ; screen_start_high # Change origin to top left of long range scanner &360c a9 08 LDA #&08 &360e 20 cf 1b JSR &1bcf ; plot_vertical_line &3611 c6 79 DEC &79 ; screen_start_high # Restore origin &3613 60 RTS ; initialise_enemy_ships &3614 ad 4f 0e LDA &0e4f ; maximum_number_of_enemy_ships &3617 8d 54 0e STA &0e54 ; enemy_ships_still_to_consider &361a a2 00 LDX #&00 ; initialise_enemy_ships_loop &361c 20 d2 33 JSR &33d2 ; initialise_enemy_ship &361f a9 01 LDA #&01 &3621 9d 00 04 STA &0400,X ; enemy_ships_previous_on_screen &3624 8a TXA &3625 18 CLC &3626 69 0b ADC #&0b &3628 aa TAX &3629 ce 54 0e DEC &0e54 ; enemy_ships_still_to_consider &362c d0 ee BNE &361c; initialise_enemy_ships_loop &362e 60 RTS ; initialise_joystick_and_cursor_keys &362f a2 02 LDX #&02 &3631 a9 10 LDA #&10 ; Set maximum number of ADC chanel &3633 20 f4 ff JSR &fff4 ; OSBYTE &3636 a2 01 LDX #&01 ; Cursor keys return ASCII values 135-139 &3638 a9 04 LDA #&04 ; Define action of cursor editing keys &363a 20 f4 ff JSR &fff4 ; OSBYTE &363d 20 01 2e JSR &2e01 ; convert_score_as_bcd_to_score_as_digits &3640 60 RTS ; unused NOPs &3641 ea ea ea ea ea ea ea ea ea ea ea ea ea ea ; update_enemy_ships &364f ce b4 34 DEC &34b4 ; timer_for_enemy_ships_regeneration &3652 10 06 BPL &365a ; skip_timer_reset &3654 ad b3 34 LDA &34b3 ; maximum_timer_for_enemy_ships_regeneration &3657 8d b4 34 STA &34b4 ; timer_for_enemy_ships_regeneration ; skip_timer_reset &365a ad 52 0e LDA &0e52 ; maximum_number_of_enemy_torpedoes &365d 8d 55 0e STA &0e55 ; torpedoes_still_to_consider &3660 ad 3d 0e LDA &0e3d ; enemy_torpedo_table_address_low &3663 85 80 STA &80 ; enemy_torpedo_address_low &3665 ad 3e 0e LDA &0e3e ; enemy_torpedo_table_address_high &3668 85 81 STA &81 ; enemy_torpedo_address_high &366a ad 4f 0e LDA &0e4f ; maximum_number_of_enemy_ships &366d 8d 54 0e STA &0e54 ; enemy_ships_still_to_consider &3670 a2 00 LDX #&00 ; update_enemy_ships_loop &3672 bd 89 04 LDA &0489,X ; enemy_ships_energy &3675 f0 08 BEQ &367f ; to_skip_changing_behaviour_type &3677 ac c9 1c LDY &1cc9 ; starship_has_exploded &367a f0 06 BEQ &3682 ; starship_still_viable &367c 20 29 2c JSR &2c29 ; decrease_enemy_ship_velocity ; to_skip_changing_behaviour_type &367f 4c 18 37 JMP &3718 ; skip_changing_behaviour_type ; starship_still_viable &3682 c9 ff CMP #&ff &3684 d0 05 BNE &368b ; enemy_ship_is_damaged &3686 ad 83 2a LDA &2a83 ; desired_velocity_for_intact_enemy_ships &3689 d0 08 BNE &3693 ; set_velocity ; enemy_ship_is_damaged &368b 4a LSR A &368c 4a LSR A &368d 4a LSR A &368e 4a LSR A &368f 18 CLC &3690 6d 82 2a ADC &2a82 ; partial_velocity_for_damaged_enemy_ships ; set_velocity &3693 8d 81 2a STA &2a81 ; enemy_ship_desired_velocity &3696 bd 8a 04 LDA &048a,X ; enemy_ships_firing_cooldown &3699 29 0f AND #&0f &369b f0 03 BEQ &36a0 ; cooldown_is_zero &369d de 8a 04 DEC &048a,X ; enemy_ships_firing_cooldown ; cooldown_is_zero &36a0 ad b4 34 LDA &34b4 ; timer_for_enemy_ships_regeneration &36a3 d0 15 BNE &36ba ; skip_enemy_regeneration &36a5 bd 0a 04 LDA &040a,X ; enemy_ships_type &36a8 c9 04 CMP #&04 # No regeneration if enemy ship cloaked &36aa b0 0e BCS &36ba ; skip_enemy_regeneration &36ac bd 89 04 LDA &0489,X ; enemy_ships_energy &36af 18 CLC &36b0 6d b2 34 ADC &34b2 ; regeneration_rate_for_enemy_ships &36b3 90 02 BCC &36b7 ; skip_ceiling &36b5 a9 ff LDA #&ff ; skip_ceiling &36b7 9d 89 04 STA &0489,X ; enemy_ships_energy ; skip_enemy_regeneration &36ba 20 8b 2a JSR &2a8b ; enemy_ship_defensive_behaviour_handling &36bd b0 3a BCS &36f9 ; skip_behaviour_routine &36bf bd 09 04 LDA &0409,X ; enemy_ships_flags_or_explosion_timer &36c2 29 0f AND #&0f &36c4 a8 TAY &36c5 b9 5f 2a LDA &2a5f,Y ; enemy_ship_behaviour_routine_low_table &36c8 85 82 STA &82 ; enemy_ship_behaviour_routine_low &36ca b9 70 2a LDA &2a70,Y ; enemy_ship_behaviour_routine_high_table &36cd 85 83 STA &83 ; enemy_ship_behaviour_routine_high &36cf 6c 82 00 JMP (&0082) ; enemy_ship_behaviour_routine ; return_from_enemy_ship_behaviour_routine &36d2 bd 83 04 LDA &0483,X ; enemy_ships_x_screens &36d5 30 02 BMI &36d9 ; skip_inversion_x &36d7 49 ff EOR #&ff ; skip_inversion_x &36d9 85 7a STA &7a ; tmp &36db bd 86 04 LDA &0486,X ; enemy_ships_y_screens &36de 30 02 BMI &36e2 ; skip_inversion_y &36e0 49 ff EOR #&ff ; skip_inversion_y &36e2 18 CLC &36e3 65 7a ADC &7a ; tmp &36e5 c9 06 CMP #&06 # Velocity boost if very far away &36e7 90 10 BCC &36f9 ; skip_velocity_boost &36e9 bc 08 04 LDY &0408,X ; enemy_ships_velocity &36ec c0 22 CPY #&22 &36ee b0 09 BCS &36f9 ; skip_velocity_boost # but not already boosted &36f0 69 50 ADC #&50 &36f2 90 02 BCC &36f6 ; skip_ceiling &36f4 a9 ff LDA #&ff ; skip_ceiling &36f6 9d 08 04 STA &0408,X ; enemy_ships_velocity ; skip_velocity_boost ; skip_behaviour_routine &36f9 20 13 21 JSR &2113 ; random_number_generator &36fc ad d1 1c LDA &1cd1 ; rnd_1 &36ff c9 06 CMP #&06 # 6/256 chance of changing behaviour type &3701 b0 15 BCS &3718 ; skip_changing_behaviour_type &3703 ad d2 1c LDA &1cd2 ; rnd_2 &3706 29 0f AND #&0f &3708 85 7a STA &7a ; new_behaviour_type &370a bd 09 04 LDA &0409,X ; enemy_ships_flags_or_explosion_timer &370d 29 f0 AND #&f0 &370f 05 7a ORA &7a ; new_behaviour_type &3711 9d 09 04 STA &0409,X ; enemy_ships_flags_or_explosion_timer &3714 a9 00 LDA #&00 &3716 f0 05 BEQ &371d ; skip_resetting_hit_count ; skip_changing_behaviour_type &3718 bd 88 04 LDA &0488,X ; enemy_ships_temporary_behaviour_flags &371b 29 f0 AND #&f0 # Reset enemy_ship_hit_count ; skip_resetting_hit_count &371d 9d 88 04 STA &0488,X ; enemy_ships_temporary_behaviour_flags &3720 8a TXA &3721 18 CLC &3722 69 0b ADC #&0b &3724 aa TAX &3725 ce 54 0e DEC &0e54 ; enemy_ships_still_to_consider &3728 f0 03 BEQ &372d ; leave &372a 4c 72 36 JMP &3672 ; update_enemy_ships_loop &372d 60 RTS ; enemy_ship_behaviour_routine_six # Comes up from below starship to near stop above &372e bd 80 04 LDA &0480,X ; enemy_ships_on_screen &3731 d0 25 BNE &3758 ; off_screen &3733 20 61 2b JSR &2b61 ; turn_enemy_ship_towards_desired_angle_accounting_for_starship_velocity &3736 d0 03 BNE &373b ; skip_firing &3738 20 cc 26 JSR &26cc ; fire_enemy_torpedo # Fire if pointing at starship ; skip_firing &373b bd 85 04 LDA &0485,X ; enemy_ships_y_pixels &373e 10 0b BPL &374b ; slow_to_a_crawl # Slow to a crawl if above starship &3740 29 7f AND #&7f &3742 4a LSR A &3743 18 CLC &3744 6d 54 0e ADC &0e54 ; enemy_ships_still_to_consider &3747 e9 06 SBC #&06 &3749 b0 02 BCS &374d ; use_speed_based_on_y_pixels # Otherwise, set speed proportional to position below ; slow_to_a_crawl &374b a9 01 LDA #&01 ; use_speed_based_on_y_pixels &374d cd 81 2a CMP &2a81 ; enemy_ship_desired_velocity &3750 b0 09 BCS &375b ; return_after_changing_velocity &3752 8d 81 2a STA &2a81 ; enemy_ship_desired_velocity &3755 4c 5b 37 JMP &375b ; return_after_changing_velocity ; off_screen &3758 20 47 2b JSR &2b47 ; turn_enemy_ship_towards_starship_using_screens ; return_after_changing_velocity &375b 20 3a 2c JSR &2c3a ; increase_or_decrease_enemy_ship_velocity_towards_desired_velocity &375e 4c d2 36 JMP &36d2 ; return_from_enemy_ship_behaviour_routine ; enemy_ship_behaviour_routine_seven # Crashes into starship when going more than half speed &3761 ad 81 2a LDA &2a81 ; enemy_ship_desired_velocity &3764 18 CLC &3765 69 08 ADC #&08 &3767 8d 81 2a STA &2a81 ; enemy_ship_desired_velocity &376a bd 80 04 LDA &0480,X ; enemy_ships_on_screen &376d d0 68 BNE &37d7 ; off_screen # If enemy ship is on screen, &376f bd 88 04 LDA &0488,X ; enemy_ships_temporary_behaviour_flags &3772 a8 TAY &3773 29 10 AND #&10 ; kamikaze_stage_one &3775 d0 37 BNE &37ae ; kamikaze_stage_one_set # and kamikaze_stage_one is unset, &3777 98 TYA &3778 29 20 AND #&20 ; kamikaze_stage_two &377a d0 0e BNE &378a ; skip_setting_kamikaze_stage_one # and kamikaze_stage_two is unset, &377c ad 00 0f LDA &0f00 ; starship_velocity_high &377f c9 02 CMP #&02 &3781 90 07 BCC &378a ; skip_setting_kamikaze_stage_one # and starship going at more than half speed &3783 98 TYA &3784 09 10 ORA #&10 ; kamikaze_stage_one # then set kamikaze_stage_one &3786 a8 TAY &3787 9d 88 04 STA &0488,X ; enemy_ships_temporary_behaviour_flags ; skip_setting_kamikaze_stage_one &378a 20 26 2b JSR &2b26 ; get_rectilinear_distance_from_centre_of_screen &378d c9 69 CMP #&69 &378f 90 0c BCC &379d ; decelerate # Decelerate when close to starship &3791 98 TYA &3792 29 cf AND #&cf # Unset kamikaze_stage_one and kamikaze_stage_two &3794 9d 88 04 STA &0488,X ; enemy_ships_temporary_behaviour_flags &3797 20 3a 2c JSR &2c3a ; increase_or_decrease_enemy_ship_velocity_towards_desired_velocity &379a 4c a3 37 JMP &37a3 ; skip_deceleration ; decelerate &379d 20 29 2c JSR &2c29 ; decrease_enemy_ship_velocity &37a0 20 29 2c JSR &2c29 ; decrease_enemy_ship_velocity ; skip_deceleration &37a3 20 61 2b JSR &2b61 ; turn_enemy_ship_towards_desired_angle_accounting_for_starship_velocity &37a6 d0 35 BNE &37dd ; to_return_from_enemy_ship_behaviour_routine &37a8 20 cc 26 JSR &26cc ; fire_enemy_torpedo &37ab 4c dd 37 JMP &37dd ; to_return_from_enemy_ship_behaviour_routine ; kamikaze_stage_one_set &37ae ad 55 26 LDA &2655 ; enemy_ship_desired_angle_divided_by_eight &37b1 4a LSR A &37b2 18 CLC &37b3 69 08 ADC #&08 # Ninety degrees clockwise turn &37b5 29 1f AND #&1f &37b7 8d 55 26 STA &2655 ; enemy_ship_desired_angle_divided_by_eight &37ba 20 61 2b JSR &2b61 ; turn_enemy_ship_towards_desired_angle_accounting_for_starship_velocity &37bd bd 85 04 LDA &0485,X ; enemy_ships_y_pixels &37c0 30 18 BMI &37da ; return_after_changing_velocity # Leave if underneath starship &37c2 bd 82 04 LDA &0482,X ; enemy_ships_x_pixels &37c5 38 SEC &37c6 e9 60 SBC #&60 &37c8 c9 40 CMP #&40 &37ca b0 0e BCS &37da ; return_after_changing_velocity # Leave if too far to the right &37cc bd 88 04 LDA &0488,X ; enemy_ships_temporary_behaviour_flags &37cf 49 30 EOR #&30 ; kamikaze_stage_one | kamikaze_stage_two # Unset kamikaze_stage_one, set kamikaze_stage_two &37d1 9d 88 04 STA &0488,X ; enemy_ships_temporary_behaviour_flags &37d4 4c da 37 JMP &37da ; return_after_changing_velocity ; off_screen &37d7 20 47 2b JSR &2b47 ; turn_enemy_ship_towards_starship_using_screens ; return_after_changing_velocity &37da 20 3a 2c JSR &2c3a ; increase_or_decrease_enemy_ship_velocity_towards_desired_velocity ; to_return_from_enemy_ship_behaviour_routine &37dd 4c d2 36 JMP &36d2 ; return_from_enemy_ship_behaviour_routine ; unused NOPs &37e0 ea ea ea ea ea ea ea ea ea ea ea ea ea ea ea ea &37f0 ea ea ea ; start_game_continuation &37f3 a9 ff LDA #&ff &37f5 8d b9 33 STA &33b9 ; command_number_used_for_maximum_enemy_torpedo_cooldown_lookup &37f8 8d b0 34 STA &34b0 ; starship_type &37fb a9 00 LDA #&00 &37fd 8d b1 34 STA &34b1 ; command_number &3800 8d 67 2d STA &2d67 ; score_as_bcd + 2 &3803 8d 66 2d STA &2d66 ; score_as_bcd + 1 &3806 8d 65 2d STA &2d65 ; score_as_bcd &3809 ad b9 34 LDA &34b9 ; maximum_number_of_stars_in_game &380c 8d 50 0e STA &0e50 ; maximum_number_of_stars &380f a0 03 LDY #&03 ; reset_enemy_ship_spawning_probabilities_loop &3811 b9 cc 33 LDA &33cc,Y ; initial_enemy_ship_spawning_probabilities &3814 99 ba 33 STA &33ba,Y ; current_command_enemy_ship_spawning_probabilities &3817 88 DEY &3818 10 f7 BPL &3811 ; reset_enemy_ship_spawning_probabilities_loop &381a 20 f4 34 JSR &34f4 ; prepare_starship_for_next_command &381d 4c 33 38 JMP &3833 ; main_game_loop ; unused NOPs &3820 ea ea ea ea ea ea ea ea ea ea ea ea ea ea ea ea &3830 ea ea ea ; main_game_loop &3833 a9 00 LDA #&00 &3835 8d dd 1c STA &1cdd ; enemy_torpedo_hits_against_starship &3838 8d de 1c STA &1cde ; enemy_ship_was_hit &383b 8d de 25 STA &25de ; starship_collided_with_enemy_ship &383e 8d 58 26 STA &2658 ; starship_fired_torpedo &3841 8d dc 1c STA &1cdc ; enemy_ship_fired_torpedo &3844 8d d1 17 STA &17d1 ; enemy_ships_collided_with_each_other &3847 8d 2d 0e STA &0e2d ; number_of_delay_loops &384a 20 31 16 JSR &1631 ; apply_velocity_to_enemy_ships &384d a9 ff LDA #&ff &384f 8d e0 1c STA &1ce0 ; how_enemy_ship_was_damaged # -1 = collision with starship &3852 20 d8 17 JSR &17d8 ; check_for_starship_collision_with_enemy_ships &3855 20 4f 36 JSR &364f ; update_enemy_ships &3858 ad 56 0e LDA &0e56 ; starship_shields_active &385b f0 08 BEQ &3865 ; skip_scanner_update &385d ad 59 26 LDA &2659 ; scanner_failure_duration &3860 d0 03 BNE &3865 ; skip_scanner_update &3862 20 19 30 JSR &3019 ; plot_enemy_ships_on_scanners ; skip_scanner_update &3865 20 f2 16 JSR &16f2 ; plot_enemy_ships &3868 20 d0 13 JSR &13d0 ; update_stars &386b 20 67 26 JSR &2667 ; handle_enemy_ships_cloaking &386e ee e0 1c INC &1ce0 ; how_enemy_ship_was_damaged # 0 = collision with starship torpedoes &3871 20 19 12 JSR &1219 ; plot_starship_torpedoes &3874 20 d2 14 JSR &14d2 ; update_enemy_torpedoes &3877 ee e0 1c INC &1ce0 ; how_enemy_ship_was_damaged # 2 = collision with escape pod &387a 20 f8 28 JSR &28f8 ; handle_starship_self_destruct &387d 20 61 31 JSR &3161 ; handle_scanner_failure &3880 ad 2d 0e LDA &0e2d ; number_of_delay_loops &3883 f0 0e BEQ &3893 ; skip_delay &3885 c9 0b CMP #&0b &3887 90 02 BCC &388b ; delay_loop_loop &3889 a9 0a LDA #&0a ; delay_loop_loop &388b 20 9c 17 JSR &179c ; delay_loop &388e ce 2d 0e DEC &0e2d ; number_of_delay_loops &3891 d0 f8 BNE &388b ; delay_loop_loop ; skip_delay &3893 a9 00 LDA #&00 &3895 ce b7 34 DEC &34b7 ; timer_for_starship_energy_regeneration &3898 d0 16 BNE &38b0 ; set_regeneration &389a ad b6 34 LDA &34b6 ; maximim_timer_for_starship_energy_regeneration &389d 8d b7 34 STA &34b7 ; timer_for_starship_energy_regeneration &38a0 ad b5 34 LDA &34b5 ; base_regeneration_rate_for_starship &38a3 38 SEC &38a4 ed 00 0f SBC &0f00 ; starship_velocity_high &38a7 ac 56 0e LDY &0e56 ; starship_shields_active &38aa d0 04 BNE &38b0 ; set_regeneration &38ac 38 SEC &38ad ed bc 34 SBC &34bc ; subtraction_from_starship_regeneration_when_shields_active ; set_regeneration &38b0 8d 23 19 STA &1923 ; starship_energy_regeneration &38b3 ad c9 1c LDA &1cc9 ; starship_has_exploded &38b6 f0 06 BEQ &38be ; starship_hasn't_exploded &38b8 20 e8 1d JSR &1de8 ; plot_starship_explosion &38bb 4c c4 38 JMP &38c4 ; skip_player_movement ; starship_hasn't_exploded &38be 20 c7 1a JSR &1ac7 ; update_various_starship_statuses_on_screen &38c1 20 3f 19 JSR &193f ; handle_player_movement ; skip_player_movement &38c4 20 a4 14 JSR &14a4 ; apply_rotation_to_starship_angle &38c7 20 5a 24 JSR &245a ; play_sounds &38ca 20 d0 2d JSR &2dd0 ; apply_delta_to_score &38cd 20 13 21 JSR &2113 ; random_number_generator &38d0 ad d2 1c LDA &1cd2 ; rnd_2 &38d3 29 3f AND #&3f &38d5 18 CLC &38d6 6d b8 34 ADC &34b8 ; base_damage_to_enemy_ship_from_other_collision &38d9 8d df 1c STA &1cdf ; damage_to_enemy_ship_from_other_collision &38dc ad 00 0f LDA &0f00 ; starship_velocity_high &38df 85 7b STA &7b ; tmp &38e1 ad 01 0f LDA &0f01 ; starship_velocity_low &38e4 0a ASL A &38e5 26 7b ROL &7b ; tmp &38e7 0a ASL A &38e8 26 7b ROL &7b ; tmp &38ea ad d1 1c LDA &1cd1 ; rnd_1 &38ed 29 1f AND #&1f &38ef 65 7b ADC &7b ; tmp &38f1 69 0c ADC #&0c &38f3 8d 36 0e STA &0e36 ; value_used_for_enemy_torpedo_ttl &38f6 4c 33 38 JMP &3833 ; main_game_loop ; unused NOPs &38f9 ea ea ea ea ea ea ea ea ea ea ea ea ea ea ; previous_score_as_bcd &3907 00 00 00 ; allowed_another_command &390a 00 ; unused NOPs &390b ea ea ea ea ea ea ea ; combat_experience_rating_string &3912 1f 0b 05 53 54 41 52 53 48 49 50 20 43 4f 4d 4d ; TAB(&0b, &05) "STARSHIP COMMAND" &3922 41 4e 44 1f 05 0a 41 6e 20 65 73 63 61 70 65 20 ; TAB(&05, &0a) "An escape capsule was launched" &3932 63 61 70 73 75 6c 65 20 77 61 73 20 6c 61 75 6e ; TAB(&04, &0f) "Your official combat experience" &3942 63 68 65 64 1f 04 0f 59 6f 75 72 20 6f 66 66 69 ; TAB(&04, &11) "rating is now recorded as" &3952 63 69 61 6c 20 63 6f 6d 62 61 74 20 65 78 70 65 ; TAB(&0d, &1f) "Press " &3962 72 69 65 6e 63 65 1f 04 11 72 61 74 69 6e 67 20 &3972 69 73 20 6e 6f 77 20 72 65 63 6f 72 64 65 64 20 &3982 61 73 2e 1f 0d 1f 50 72 65 73 73 20 3c 52 45 54 &3992 55 52 4e 3e 0d ; no_before_the_starship_exploded_string &3997 1f 05 0a 4e 4f 1f 05 0b 62 65 66 6f 72 65 20 74 ; TAB(&05, &0a) "NO" &39a7 68 65 20 73 74 61 72 73 68 69 70 20 65 78 70 6c ; TAB(&05, &0b) "before the starship exploded." &39b7 6f 64 65 64 2e 0d ; after_your_performance_string &39bd 1f 03 16 41 66 74 65 72 20 20 79 6f 75 72 20 20 ; TAB(&03, &16) "After your performance on this" &39cd 70 65 72 66 6f 72 6d 61 6e 63 65 20 20 6f 6e 20 ; TAB(&03, &17) "command the Star-Fleet authorities" &39dd 20 74 68 69 73 1f 03 17 63 6f 6d 6d 61 6e 64 20 ; TAB(&03, &18) "are said to be "" &39ed 74 68 65 20 53 74 61 72 2d 46 6c 65 65 74 20 61 &39fd 75 74 68 6f 72 69 74 69 65 73 1f 03 18 61 72 65 &3a0d 20 20 73 61 69 64 20 20 74 6f 20 20 62 65 20 20 &3a1d 22 0d ; and_returned_safely_text &3a1f 1f 05 0b 61 6e 64 20 72 65 74 75 72 6e 65 64 20 ; TAB(&05, &0b) "and returned safely from the" &3a2f 73 61 66 65 6c 79 20 66 72 6f 6d 20 74 68 65 1f ; TAB(&05, &0c) "combat zone." &3a3f 05 0c 63 6f 6d 62 61 74 20 7a 6f 6e 65 2e 0d ; but_collided_string &3a4e 1f 05 0b 62 75 74 20 63 6f 6c 6c 69 64 65 64 20 ; TAB(&05, &0b) "but collided with an enemy ship" &3a5e 77 69 74 68 20 61 6e 20 65 6e 65 6d 79 20 73 68 &3a6e 69 70 2e 0d ; having_just_gained_string &3a72 1f 04 13 68 61 76 69 6e 67 20 20 6a 75 73 74 20 ; TAB(&04, &13) "having just gained " &3a82 20 67 61 69 6e 65 64 20 20 0d ; and_but_they_allow_string &3a8c 61 6e 64 20 ; "and " &3a90 62 75 74 20 74 68 65 79 20 61 6c 6c 6f 77 20 79 ; "but they allow you the command of &3aa0 6f 75 20 74 68 65 20 63 6f 6d 6d 61 6e 64 20 6f ; TAB(&03, &1b) "another starship." &3ab0 66 1f 03 1b 61 6e 6f 74 68 65 72 20 73 74 61 72 &3ac0 73 68 69 70 2e 0d ; emotions ; # score + bcd(rnd(&3f)) &3ac6 22 66 75 72 69 6f 75 73 ; ""furious" # < 40, 1 &3ace 22 64 69 73 70 6c 65 61 73 65 64 ; ""displeased" # < 60, 2 &3ad9 22 64 69 73 61 70 70 6f 69 6e 74 65 64 ; ""disappointed" # < 80, 3, and they retire you from active service &3ae6 22 64 69 73 61 70 70 6f 69 6e 74 65 64 ; ""disappointed" # <100, 4, but they allow you the command &3af3 22 73 61 74 69 73 66 69 65 64 ; ""satisfied" # <200, 5, and they allow you the command &3afd 22 70 6c 65 61 73 65 64 ; ""pleased" # <280, 6 &3b05 22 69 6d 70 72 65 73 73 65 64 ; ""impressed" # <400, 7 &3b0f 22 64 65 6c 69 67 68 74 65 64 ; ""delighted" # >=400, 8 &3b19 22 0d ; and_they_retire_you_string &3b1b 1f 00 1a 61 6e 64 20 74 68 65 79 20 72 65 74 69 ; TAB(&00, &1a) "and they retire you from active service." &3b2b 72 65 20 79 6f 75 20 66 72 6f 6d 20 61 63 74 69 &3b3b 76 65 20 73 65 72 76 69 63 65 2e 0d ; threshold_table ; 2 3 4 5 6 7 8 &3b47 02 03 04 07 0d 14 1e ; unused NOPs &3b4e ea ea ea ea ea ea ea ea ea ea ea ea ea ea ea ea &3b5e ea ea ea ; plot_debriefing &3b61 a9 0a LDA #&0a &3b63 20 ee ff JSR &ffee ; OSWRCH &3b66 a0 0d LDY #&0d ; plot_row_of_starships_top_line_loop &3b68 a9 20 LDA #&20 &3b6a 20 ee ff JSR &ffee ; OSWRCH &3b6d a9 e0 LDA #&e0 &3b6f 20 ee ff JSR &ffee ; OSWRCH &3b72 a9 e1 LDA #&e1 &3b74 20 ee ff JSR &ffee ; OSWRCH &3b77 88 DEY &3b78 d0 ee BNE &3b68 ; plot_row_of_starships_top_line_loop &3b7a a9 20 LDA #&20 &3b7c 20 ee ff JSR &ffee ; OSWRCH &3b7f a0 0d LDY #&0d ; plot_row_of_starships_bottom_line_loop &3b81 a9 20 LDA #&20 &3b83 20 ee ff JSR &ffee ; OSWRCH &3b86 a9 e2 LDA #&e2 &3b88 20 ee ff JSR &ffee ; OSWRCH &3b8b a9 e3 LDA #&e3 &3b8d 20 ee ff JSR &ffee ; OSWRCH &3b90 88 DEY &3b91 d0 ee BNE &3b81 ; plot_row_of_starships_bottom_line_loop &3b93 20 1b 3d JSR &3d1b ; plot_line_of_underscores &3b96 a0 00 LDY #&00 ; plot_combat_experience_rating_text_loop &3b98 b9 12 39 LDA &3912,Y ; combat_experience_rating_string &3b9b 20 ee ff JSR &ffee ; OSWRCH &3b9e c8 INY &3b9f c9 3e CMP #&3e &3ba1 d0 f5 BNE &3b98 ; plot_combat_experience_rating_text_loop ; plot_command_number &3ba3 a0 05 LDY #&05 &3ba5 a2 1c LDX #&1c &3ba7 20 30 3d JSR &3d30 ; tab_to_x_y &3baa ad b1 34 LDA &34b1 ; command_number &3bad 4a LSR A &3bae 4a LSR A &3baf 4a LSR A &3bb0 4a LSR A &3bb1 f0 06 BEQ &3bb9 ; single_digit_command_number &3bb3 18 CLC &3bb4 69 30 ADC #&30 &3bb6 20 ee ff JSR &ffee ; OSWRCH ; single_digit_command_number &3bb9 ad b1 34 LDA &34b1 ; command_number &3bbc 29 0f AND #&0f &3bbe 18 CLC &3bbf 69 30 ADC #&30 &3bc1 20 ee ff JSR &ffee ; OSWRCH &3bc4 20 1b 3d JSR &3d1b ; plot_line_of_underscores &3bc7 ad d8 1c LDA &1cd8 ; escape_capsule_launched &3bca d0 0f BNE &3bdb ; escape_capsule_was_launched &3bcc a0 00 LDY #&00 ; plot_no_before_the_starship_exploded_loop &3bce b9 97 39 LDA &3997,Y ; no_before_the_starship_exploded_string &3bd1 20 ee ff JSR &ffee ; OSWRCH &3bd4 c8 INY &3bd5 c9 2e CMP #&2e &3bd7 d0 f5 BNE &3bce ; plot_no_before_the_starship_exploded_loop &3bd9 f0 21 BEQ &3bfc ; plot_score_in_debriefing ; escape_capsule_was_launched &3bdb ad 90 28 LDA &2890 ; escape_capsule_destroyed &3bde d0 0f BNE &3bef ; escape_capsule_was_destroyed &3be0 a0 00 LDY #&00 ; plot_and_returned_safely_loop &3be2 b9 1f 3a LDA &3a1f,Y ; and_returned_safely_string &3be5 20 ee ff JSR &ffee ; OSWRCH &3be8 c8 INY &3be9 c9 2e CMP #&2e &3beb d0 f5 BNE &3be2 ; plot_and_returned_safely_loop &3bed f0 0d BEQ &3bfc ; plot_score_in_debriefing ; escape_capsule_was_destroyed &3bef a0 00 LDY #&00 ; plot_but_collided_loop &3bf1 b9 4e 3a LDA &3a4e,Y ; but_collided_string &3bf4 20 ee ff JSR &ffee ; OSWRCH &3bf7 c8 INY &3bf8 c9 2e CMP #&2e &3bfa d0 f5 BNE &3bf1 ; plot_but_collided_loop ; plot_score_in_debriefing &3bfc a0 11 LDY #&11 &3bfe a2 1e LDX #&1e &3c00 20 30 3d JSR &3d30 ; tab_to_x_y &3c03 a2 fe LDX #&fe ; "." &3c05 a0 05 LDY #&05 ; plot_score_in_debriefing_loop # Plot score with leading "."s &3c07 b9 6e 2d LDA &2d6e,Y ; score_as_digits &3c0a d0 07 BNE &3c13 ; non_zero_digit &3c0c 98 TYA &3c0d f0 04 BEQ &3c13 ; non_zero_digit # except for final digit &3c0f 8a TXA &3c10 4c 15 3c JMP &3c15 ; leading_zero ; non_zero_digit &3c13 a2 00 LDX #&00 ; "0" ; leading_zero &3c15 18 CLC &3c16 69 30 ADC #&30 &3c18 20 ee ff JSR &ffee ; OSWRCH &3c1b 88 DEY &3c1c 10 e9 BPL &3c07 ; plot_score_in_debriefing_loop &3c1e ad 65 2d LDA &2d65 ; score_as_bcd &3c21 38 SEC &3c22 78 SEI &3c23 f8 SED &3c24 ed 07 39 SBC &3907 ; previous_score_as_bcd &3c27 8d 07 39 STA &3907 ; previous_score_as_bcd &3c2a ad 66 2d LDA &2d66 ; score_as_bcd + 1 &3c2d ed 08 39 SBC &3908 ; previous_score_as_bcd + 1 &3c30 8d 08 39 STA &3908 ; previous_score_as_bcd + 1 &3c33 ad 67 2d LDA &2d67 ; score_as_bcd + 2 &3c36 ed 09 39 SBC &3909 ; previous_score_as_bcd + 2 &3c39 8d 09 39 STA &3909 ; previous_score_as_bcd + 2 &3c3c d8 CLD &3c3d 58 CLI &3c3e ad 90 28 LDA &2890 ; escape_capsule_destroyed &3c41 4d d8 1c EOR &1cd8 ; escape_capsule_launched &3c44 8d 0a 39 STA &390a ; allowed_another_command &3c47 ad b1 34 LDA &34b1 ; command_number &3c4a c9 01 CMP #&01 &3c4c f0 29 BEQ &3c77 ; skip_previous_command_score &3c4e a0 00 LDY #&00 ; plot_having_just_gained_loop &3c50 b9 72 3a LDA &3a72,Y ; having_just_gained_string &3c53 20 ee ff JSR &ffee ; OSWRCH &3c56 c8 INY &3c57 c0 19 CPY #&19 &3c59 d0 f5 BNE &3c50 ; plot_having_just_gained_loop &3c5b a2 01 LDX #&01 &3c5d ad 09 39 LDA &3909 ; previous_score_as_bcd + 2 &3c60 20 3e 3d JSR &3d3e ; plot_bcd_number_as_two_digits &3c63 ad 08 39 LDA &3908 ; previous_score_as_bcd + 1 &3c66 20 3e 3d JSR &3d3e ; plot_bcd_number_as_two_digits &3c69 ad 07 39 LDA &3907 ; previous_score_as_bcd &3c6c 20 3e 3d JSR &3d3e ; plot_bcd_number_as_two_digits &3c6f 8a TXA &3c70 f0 05 BEQ &3c77 ; skip_previous_command_score &3c72 a9 30 LDA #&30 &3c74 20 ee ff JSR &ffee ; OSWRCH ; skip_previous_command_score &3c77 ad 0a 39 LDA &390a ; allowed_another_command &3c7a d0 03 BNE &3c7f ; plot_after_your_performance &3c7c 4c 17 3d JMP &3d17 ; leave_after_plotting_line_of_underscores ; plot_after_your_performance &3c7f a0 00 LDY #&00 ; plot_after_your_performance_loop &3c81 b9 bd 39 LDA &39bd,Y ; after_your_performance_string &3c84 20 ee ff JSR &ffee ; OSWRCH &3c87 c8 INY &3c88 c0 61 CPY #&61 &3c8a d0 f5 BNE &3c81 ; plot_after_your_performance_loop ; judge_player &3c8c ad d2 1c LDA &1cd2 ; rnd_2 # Add random &00 - &3f to score &3c8f 29 3f AND #&3f &3c91 18 CLC &3c92 6d 07 39 ADC &3907 ; previous_score_as_bcd &3c95 8d 07 39 STA &3907 ; previous_score_as_bcd &3c98 ad 08 39 LDA &3908 ; previous_score_as_bcd + 1 &3c9b 69 00 ADC #&00 &3c9d a0 05 LDY #&05 ; division_loop &3c9f 4a LSR A &3ca0 6e 07 39 ROR &3907 ; previous_score_as_bcd # Divide first four digits by 32 &3ca3 88 DEY &3ca4 d0 f9 BNE &3c9f ; division_loop &3ca6 a0 08 LDY #&08 &3ca8 0d 09 39 ORA &3909 ; previous_score_as_bcd + 2 # Automatic delighted if score > 10000 &3cab d0 0f BNE &3cbc ; end_of_calculation &3cad a0 01 LDY #&01 &3caf ad 07 39 LDA &3907 ; previous_score_as_bcd ; check_threshold_loop &3cb2 d9 46 3b CMP &3b46,Y ; threshold_table - 1 # Otherwise, compare against threshold &3cb5 90 05 BCC &3cbc ; end_of_calculation &3cb7 c8 INY &3cb8 c0 08 CPY #&08 &3cba d0 f6 BNE &3cb2 ; check_threshold_loop ; end_of_calculation &3cbc 84 7b STY &7b ; said_to_be_value # to find authorities' emotion &3cbe a2 ff LDX #&ff &3cc0 a9 22 LDA #&22 ; find_emotion_loop &3cc2 e8 INX &3cc3 dd c6 3a CMP &3ac6,X ; emotions &3cc6 d0 fa BNE &3cc2 ; find_emotion_loop &3cc8 88 DEY &3cc9 d0 f7 BNE &3cc2 ; find_emotion_loop ; plot_emotion_loop &3ccb e8 INX &3ccc bd c6 3a LDA &3ac6,X ; emotions &3ccf 20 ee ff JSR &ffee ; OSWRCH &3cd2 c9 22 CMP #&22 &3cd4 d0 f5 BNE &3ccb ; plot_emotion_loop &3cd6 a5 7b LDA &7b ; said_to_be_value &3cd8 c9 04 CMP #&04 &3cda 90 2b BCC &3d07 ; player_retired &3cdc a0 1a LDY #&1a &3cde a2 03 LDX #&03 &3ce0 20 30 3d JSR &3d30 ; tab_to_x_y &3ce3 a0 00 LDY #&00 ; and &3ce5 a5 7b LDA &7b ; said_to_be_value &3ce7 c9 04 CMP #&04 &3ce9 d0 02 BNE &3ced ; plot_and_or_but_loop &3ceb a0 04 LDY #&04 ; but ; plot_and_or_but_loop &3ced b9 8c 3a LDA &3a8c,Y ; and_but_they_allow_string &3cf0 20 ee ff JSR &ffee ; OSWRCH &3cf3 c8 INY &3cf4 c9 20 CMP #&20 &3cf6 d0 f5 BNE &3ced ; plot_and_or_but_loop &3cf8 a0 08 LDY #&08 ; they ; plot_they_allow_you_loop &3cfa b9 8c 3a LDA &3a8c,Y ; and_but_they_allow_string &3cfd 20 ee ff JSR &ffee ; OSWRCH &3d00 c8 INY &3d01 c9 2e CMP #&2e &3d03 d0 f5 BNE &3cfa ; plot_they_allow_you_loop &3d05 f0 10 BEQ &3d17 ; leave_after_plotting_line_of_underscores ; player_retired &3d07 a0 00 LDY #&00 &3d09 8c 0a 39 STY &390a ; allowed_another_command ; plot_and_they_retire_you_loop &3d0c b9 1b 3b LDA &3b1b,Y ; and_they_retire_you_string &3d0f 20 ee ff JSR &ffee ; OSWRCH &3d12 c8 INY &3d13 c9 2e CMP #&2e &3d15 d0 f5 BNE &3d0c ; plot_and_they_retire_you_loop ; leave_after_plotting_line_of_underscores &3d17 20 1b 3d JSR &3d1b ; plot_line_of_underscores &3d1a 60 RTS ; plot_line_of_underscores &3d1b a9 0d LDA #&0d &3d1d 20 ee ff JSR &ffee ; OSWRCH &3d20 a9 0a LDA #&0a &3d22 20 ee ff JSR &ffee ; OSWRCH &3d25 a0 28 LDY #&28 ; plot_line_of_underscores_loop &3d27 a9 5f LDA #&5f &3d29 20 ee ff JSR &ffee ; OSWRCH &3d2c 88 DEY &3d2d d0 f8 BNE &3d27 ; plot_line_of_underscores_loop &3d2f 60 RTS ; tab_to_x_y &3d30 a9 1f LDA #&1f &3d32 20 ee ff JSR &ffee ; OSWRCH &3d35 8a TXA &3d36 20 ee ff JSR &ffee ; OSWRCH &3d39 98 TYA &3d3a 20 ee ff JSR &ffee ; OSWRCH &3d3d 60 RTS ; plot_bcd_number_as_two_digits &3d3e a8 TAY &3d3f 4a LSR A &3d40 4a LSR A &3d41 4a LSR A &3d42 4a LSR A &3d43 d0 03 BNE &3d48 ; has_non_zero_tens &3d45 8a TXA &3d46 d0 08 BNE &3d50 ; skip_leading_zeroes ; has_non_zero_tens &3d48 a2 00 LDX #&00 &3d4a 18 CLC &3d4b 69 30 ADC #&30 &3d4d 20 ee ff JSR &ffee ; OSWRCH ; skip_leading_zeroes &3d50 98 TYA &3d51 29 0f AND #&0f &3d53 d0 03 BNE &3d58 ; has_non_zero_ones &3d55 8a TXA &3d56 d0 08 BNE &3d60 ; skip_leading_zeroes_again ; has_non_zero_ones &3d58 a2 00 LDX #&00 &3d5a 18 CLC &3d5b 69 30 ADC #&30 &3d5d 20 ee ff JSR &ffee ; OSWRCH ; skip_leading_zeroes_again &3d60 60 RTS ; unused &3d61 ea ea ea ea ea ea ea ea ea ea ea ea ea ea ea ea &3d71 ea ea ea 00 00 00 00 00 00 00 00 00 00 00 00 ff &3d81 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff &3d91 ff ; instructions_string &3d92 1f 06 02 2a 2a 2a 2a 20 53 54 41 52 53 48 49 50 ; TAB(&06, &02) "**** STARSHIP CONTROLS ****" &3da2 20 43 4f 4e 54 52 4f 4c 53 20 2a 2a 2a 2a 1f 03 ; TAB(&03, &05) "Z - Rotate left" &3db2 05 5a 20 20 2d 20 20 52 6f 74 61 74 65 20 6c 65 ; TAB(&03, &06) "X - Rotate right" &3dc2 66 74 1f 03 06 58 20 20 2d 20 20 52 6f 74 61 74 ; TAB(&03, &07) "N - Fire torpedoes" &3dd2 65 20 72 69 67 68 74 1f 03 07 4e 20 20 2d 20 20 ; TAB(&03, &08) "M - Thrust" &3de2 46 69 72 65 20 74 6f 72 70 65 64 6f 65 73 1f 03 ; TAB(&03, &09) ", - Brake" &3df2 08 4d 20 20 2d 20 20 54 68 72 75 73 74 1f 03 09 ; TAB(&03, &0b) "F - Launch port escape capsule" &3e02 2c 20 20 2d 20 20 42 72 61 6b 65 1f 03 0b 46 20 ; TAB(&03, &0c) "G - Launch starboard escape capsule" &3e12 20 2d 20 20 4c 61 75 6e 63 68 20 70 6f 72 74 20 ; TAB(&00, &0e) "All the above may operate simultaneously" &3e22 65 73 63 61 70 65 20 63 61 70 73 75 6c 65 1f 03 ; "Alternatively , ONE of the following may" &3e32 0c 47 20 20 2d 20 20 4c 61 75 6e 63 68 20 73 74 ; "be depressed...." &3e42 61 72 62 6f 61 72 64 20 65 73 63 61 70 65 20 63 ; TAB(&03, &12) "B - Shields ON / Scanners OFF" &3e52 61 70 73 75 6c 65 1f 00 0e 41 6c 6c 20 74 68 65 ; TAB(&03, &13) "V - Scanners ON / Shields OFF" &3e62 20 61 62 6f 76 65 20 6d 61 79 20 6f 70 65 72 61 ; TAB(&03, &14) "C - "Auto-Changeover" ON" &3e72 74 65 20 73 69 6d 75 6c 74 61 6e 65 6f 75 73 6c ; TAB(&03, &16) "f0 - "Rotation Dampers" ON" &3e82 79 41 6c 74 65 72 6e 61 74 69 76 65 6c 79 20 2c ; TAB(&03, &17) "2 - "Rotation Dampers" OFF" &3e92 20 4f 4e 45 20 6f 66 20 74 68 65 20 66 6f 6c 6c ; TAB(&03, &18) "f1 - "Velocity Dampers" ON" &3ea2 6f 77 69 6e 67 20 6d 61 79 62 65 20 64 65 70 72 ; TAB(&03, &19) "3 - "Velocity Dampers" OFF" &3eb2 65 73 73 65 64 2e 2e 2e 2e 1f 03 12 42 20 20 2d ; TAB(&03, &1b) " - FREEZE" &3ec2 20 20 53 68 69 65 6c 64 73 20 4f 4e 20 2f 20 53 ; TAB(&03, &1c) " - UNFREEZE" &3ed2 63 61 6e 6e 65 72 73 20 4f 46 46 1f 03 13 56 20 ; TAB(&0d, &1f) "Press " &3ee2 20 2d 20 20 53 63 61 6e 6e 65 72 73 20 4f 4e 20 ; "~" &3ef2 2f 20 53 68 69 65 6c 64 73 20 4f 46 46 1f 03 14 &3f02 43 20 20 2d 20 20 22 41 75 74 6f 2d 43 68 61 6e &3f12 67 65 6f 76 65 72 22 20 4f 4e 1f 03 16 66 30 20 &3f22 2d 20 20 22 52 6f 74 61 74 69 6f 6e 20 44 61 6d &3f32 70 65 72 73 22 20 4f 4e 1f 03 17 32 20 20 2d 20 &3f42 20 22 52 6f 74 61 74 69 6f 6e 20 44 61 6d 70 65 &3f52 72 73 22 20 4f 46 46 1f 03 18 66 31 20 2d 20 20 &3f62 22 56 65 6c 6f 63 69 74 79 20 44 61 6d 70 65 72 &3f72 73 22 20 4f 4e 1f 03 19 33 20 20 2d 20 20 22 56 &3f82 65 6c 6f 63 69 74 79 20 44 61 6d 70 65 72 73 22 &3f92 20 4f 46 46 1f 03 1b 3c 43 4f 50 59 3e 20 20 20 &3fa2 2d 20 46 52 45 45 5a 45 1f 03 1c 3c 44 45 4c 45 &3fb2 54 45 3e 20 2d 20 55 4e 46 52 45 45 5a 45 1f 0d &3fc2 1f 50 72 65 73 73 20 3c 52 45 54 55 52 4e 3e 7e ; unused &3fd2 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 &3fe2 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 &3ff2 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ff ff &4002 ff ff ff ff ff ff ff ff ff ea ea ea ea ea ea ea &4012 ea ea ea ea ; plot_instructions &4016 a9 92 LDA #&92 &4018 85 80 STA &80 ; text_address_low &401a a9 3d LDA #&3d ; &3d92 = instructions_string &401c 85 81 STA &81 ; text_address_high &401e a0 00 LDY #&00 ; plot_instructions_loop &4020 b1 80 LDA (&80),Y ; text_address &4022 c9 7e CMP #&7e &4024 f0 0b BEQ &4031 ; finished_plotting_instructions &4026 20 ee ff JSR &ffee ; OSWRCH &4029 e6 80 INC &80 ; text_address_low &402b d0 f3 BNE &4020 ; plot_instructions_loop &402d e6 81 INC &81 ; text_address_high &402f d0 ef BNE &4020 ; plot_instructions_loop ; finished_plotting_instructions &4031 a9 00 LDA #&00 &4033 20 4c 40 JSR &404c ; plot_line_of_underscores_at_y &4036 a9 03 LDA #&03 &4038 20 4c 40 JSR &404c ; plot_line_of_underscores_at_y &403b a9 1d LDA #&1d &403d 20 4c 40 JSR &404c ; plot_line_of_underscores_at_y &4040 60 RTS ; unused NOPs &4041 ea ea ea ea ea ea ea ea ea ea ea ; plot_line_of_underscores_at_y &404c a8 TAY &404d a9 1f LDA #&1f &404f 20 ee ff JSR &ffee ; OSWRCH &4052 a9 00 LDA #&00 &4054 20 ee ff JSR &ffee ; OSWRCH &4057 98 TYA &4058 20 ee ff JSR &ffee ; OSWRCH &405b a0 28 LDY #&28 &405d a9 5f LDA #&5f ; "_" ; plot_line_of_underscores_at_y_loop &405f 20 ee ff JSR &ffee ; OSWRCH &4062 88 DEY &4063 d0 fa BNE &405f ; plot_line_of_underscores_at_y_loop &4065 60 RTS ; combat_preparation_screen_key_table &4066 df ; f0 &4067 8e ; f1 &4068 8d ; f2 &4069 8c ; f3 &406a eb ; f4 &406b 8b ; f5 &406c 8a ; f6 &406d e9 ; f7 &406e 89 ; f8 &406f 88 ; f9 ; game_options ; option_sound &4070 00 ; &1cd7 = sound_enabled (&00, &01) ; option_starship_torpedoes &4071 00 ; &265b = starship_torpedo_type (&00, &01) ; option_enemy_torpedoes &4072 00 ; &1620 = enemy_torpedo_type_instruction (&60 = RTS, &ea = NOP) ; option_keyboard_joystick &4073 00 ; &1cd6 = keyboard_or_joystick (&00, &01) ; options_values_to_write &4074 00 01 00 01 60 ea 00 01 ; option_address_low_table &407c d7 5b 20 d6 ; option_address_high_table &4080 1c 26 16 1c ; combat_preparation_string &4084 1f 06 03 2a 2a 2a 2a 20 43 4f 4d 42 41 54 20 50 ; TAB(&06, &03) "**** COMBAT PREPARATION ****" &4094 52 45 50 41 52 41 54 49 4f 4e 20 2a 2a 2a 2a 1f ; TAB(&06, &07) "f0 View starship controls" &40a4 06 07 66 30 20 20 56 69 65 77 20 73 74 61 72 73 ; TAB(&06, &09) "f1 View Star-Fleet records" &40b4 68 69 70 20 63 6f 6e 74 72 6f 6c 73 1f 06 09 66 ; TAB(&06, &0b) "f2 Enable" &40c4 31 20 20 56 69 65 77 20 53 74 61 72 2d 46 6c 65 ; TAB(&11, &0c) "}the sound effects" &40d4 65 74 20 72 65 63 6f 72 64 73 1f 06 0b 66 32 20 ; TAB(&06, &0d) "f3 Disable" &40e4 20 45 6e 61 62 6c 65 1f 11 0c 7d 74 68 65 20 73 ; TAB(&06, &0f) "f4 Small" &40f4 6f 75 6e 64 20 65 66 66 65 63 74 73 1f 06 0d 66 ; TAB(&11, &10) "}starship torpedoes" &4104 33 20 20 44 69 73 61 62 6c 65 1f 06 0f 66 34 20 ; TAB(&06, &11) "f5 Large" &4114 20 53 6d 61 6c 6c 1f 11 10 7d 73 74 61 72 73 68 ; TAB(&06, &13) "f6 Small" &4124 69 70 20 74 6f 72 70 65 64 6f 65 73 1f 06 11 66 ; TAB(&11, &14) "}enemy torpedoes" &4134 35 20 20 4c 61 72 67 65 1f 06 13 66 36 20 20 53 ; TAB(&06, &15) "f7 Large" &4144 6d 61 6c 6c 1f 11 14 7d 65 6e 65 6d 79 20 74 6f ; TAB(&06, &17) "f8 Keyboard" &4154 72 70 65 64 6f 65 73 1f 06 15 66 37 20 20 4c 61 ; TAB(&06, &19) "f9 Joystick" &4164 72 67 65 1f 06 17 66 38 20 20 4b 65 79 62 6f 61 ; TAB(&0d, &1e) "Press " &4174 72 64 1f 06 19 66 39 20 20 4a 6f 79 73 74 69 63 ; "~" &4184 6b 1f 0d 1e 50 72 65 73 73 20 3c 52 45 54 55 52 &4194 4e 3e 7e ; unused &4197 ff ff ff ff ; plot_selected_options &419b a2 03 LDX #&03 ; plot_selected_options_loop &419d a9 1f LDA #&1f &419f 20 ee ff JSR &ffee ; OSWRCH &41a2 a9 09 LDA #&09 &41a4 20 ee ff JSR &ffee ; OSWRCH &41a7 8a TXA &41a8 0a ASL A &41a9 7d 70 40 ADC &4070,X ; game_options &41ac 0a ASL A &41ad 69 0b ADC #&0b &41af 20 ee ff JSR &ffee ; OSWRCH &41b2 a9 2d LDA #&2d ; "-" &41b4 20 ee ff JSR &ffee ; OSWRCH &41b7 ca DEX &41b8 10 e3 BPL &419d ; plot_selected_options_loop &41ba 60 RTS ; wait_for_return &41bb a9 0f LDA #&0f ; Flush all buffers/input buffer &41bd a2 01 LDX #&01 ; Flushes just the input buffer &41bf a0 00 LDY #&00 &41c1 20 f4 ff JSR &fff4 ; OSBYTE ; wait_for_return_loop &41c4 a9 81 LDA #&81 ; Read key &41c6 a2 32 LDX #&32 &41c8 a0 00 LDY #&00 &41ca 20 f4 ff JSR &fff4 ; OSBYTE &41cd c0 1b CPY #&1b ; ESCAPE &41cf f0 10 BEQ &41e1 ; escape_pressed &41d1 c0 ff CPY #&ff &41d3 f0 ef BEQ &41c4 ; wait_for_return_loop &41d5 e0 60 CPX #&60 ; "£" &41d7 f0 05 BEQ &41de ; bad_program &41d9 e0 0d CPX #&0d ; RETURN &41db d0 e7 BNE &41c4 ; wait_for_return_loop &41dd 60 RTS ; bad_program &41de 00 BRK # Bug: "Bad program" when pound sign pressed &41df 60 RTS # in instructions or records screen ; unused &41e0 00 BRK ; escape_pressed &41e1 a9 7e LDA #&7e ; Acknowledge ESCAPE Condition &41e3 20 f4 ff JSR &fff4 ; OSBYTE &41e6 4c c4 41 JMP &41c4 ; wait_for_return_loop ; instructions_screen &41e9 a9 16 LDA #&16 # MODE 4 &41eb 20 ee ff JSR &ffee ; OSWRCH &41ee a9 04 LDA #&04 &41f0 20 ee ff JSR &ffee ; OSWRCH &41f3 20 36 23 JSR &2336 ; disable_cursor &41f6 20 12 23 JSR &2312 ; set_foreground_colour_to_black &41f9 20 16 40 JSR &4016 ; plot_instructions &41fc 20 06 23 JSR &2306 ; set_foreground_colour_to_white &41ff 20 bb 41 JSR &41bb ; wait_for_return &4202 60 RTS ; combat_preparation_screen &4203 a9 16 LDA #&16 # MODE 4 &4205 20 ee ff JSR &ffee ; OSWRCH &4208 a9 04 LDA #&04 &420a 20 ee ff JSR &ffee ; OSWRCH &420d 20 36 23 JSR &2336 ; disable_cursor &4210 20 12 23 JSR &2312 ; set_foreground_colour_to_black &4213 a9 84 LDA #&84 &4215 85 80 STA &80 ; text_address_low &4217 a9 40 LDA #&40 ; &4084 = combat_preparation_string &4219 85 81 STA &81 ; text_address_high &421b a0 00 LDY #&00 ; plot_combat_preparations_loop &421d b1 80 LDA (&80),Y ; text_address &421f c9 7e CMP #&7e &4221 f0 0b BEQ &422e ; finished_plotting_combat_preparations &4223 20 ee ff JSR &ffee ; OSWRCH &4226 e6 80 INC &80 ; text_address_low &4228 d0 f3 BNE &421d ; plot_combat_preparations_loop &422a e6 81 INC &81 ; text_address_high &422c d0 ef BNE &421d ; plot_combat_preparations_loop ; finished_plotting_combat_preparations &422e a9 01 LDA #&01 &4230 20 4c 40 JSR &404c ; plot_line_of_underscores_at_y &4233 a9 04 LDA #&04 &4235 20 4c 40 JSR &404c ; plot_line_of_underscores_at_y &4238 20 06 23 JSR &2306 ; set_foreground_colour_to_white &423b 20 9b 41 JSR &419b ; plot_selected_options ; get_keypress &423e a9 0f LDA #&0f ; Flush all buffers/input buffer &4240 a2 01 LDX #&01 ; Flushes just the input buffer &4242 20 f4 ff JSR &fff4 ; OSBYTE &4245 a9 81 LDA #&81 ; Read key &4247 a2 05 LDX #&05 &4249 a0 00 LDY #&00 &424b 20 f4 ff JSR &fff4 ; OSBYTE &424e e0 0d CPX #&0d ; RETURN &4250 f0 52 BEQ &42a4 ; leave &4252 a9 7e LDA #&7e ; Acknowledge ESCAPE Condition &4254 20 f4 ff JSR &fff4 ; OSBYTE &4257 a9 0a LDA #&0a &4259 85 7a STA &7a ; key_to_check ; check_next_key &425b c6 7a DEC &7a ; key_to_check &425d 30 df BMI &423e ; get_keypress &425f a6 7a LDX &7a ; key_to_check &4261 bd 66 40 LDA &4066,X ; combat_preparation_screen_key_table &4264 aa TAX &4265 a8 TAY &4266 a9 81 LDA #&81 ; Read key &4268 20 f4 ff JSR &fff4 ; OSBYTE &426b 98 TYA &426c f0 ed BEQ &425b ; check_next_key &426e a6 7a LDX &7a ; key_to_check &4270 d0 06 BNE &4278 ; not_f0 &4272 20 e9 41 JSR &41e9 ; instructions_screen &4275 4c 03 42 JMP &4203 ; combat_preparation_screen ; not_f0 &4278 e0 01 CPX #&01 &427a d0 06 BNE &4282 ; not_f1 &427c 20 d7 43 JSR &43d7 ; starfleet_records_screen &427f 4c 03 42 JMP &4203 ; combat_preparation_screen ; not_f1 &4282 8a TXA &4283 4a LSR A &4284 a8 TAY &4285 8a TXA &4286 29 01 AND #&01 &4288 d9 6f 40 CMP &406f,Y ; game_options - 1 &428b f0 ce BEQ &425b ; check_next_key &428d 99 6f 40 STA &406f,Y ; game_options - 1 &4290 b9 7b 40 LDA &407b,Y ; option_address_low_table - 1 &4293 85 80 STA &80 ; option_address_low &4295 b9 7f 40 LDA &407f,Y ; option_address_high_table - 1 &4298 85 81 STA &81 ; option_address_high &429a bd 72 40 LDA &4072,X ; options_values_to_write - 2 &429d a0 00 LDY #&00 &429f 91 80 STA (&80),Y ; option_address &42a1 4c 03 42 JMP &4203 ; combat_preparation_screen &42a4 60 RTS ; starfleet_records_string &42a5 1f 06 01 2a 2a 2a 2a 20 53 54 41 52 2d 46 4c 45 ; TAB(&06, &01) "**** STAR-FLEET RECORDS ****" &42b5 45 54 20 52 45 43 4f 52 44 53 20 2a 2a 2a 2a 1f ; TAB(&00, &04) "Below is a list of the most highly rated" &42c5 00 04 42 65 6c 6f 77 20 69 73 20 61 20 6c 69 73 ; "of Star-Fleet's past commanders." &42d5 74 20 6f 66 20 74 68 65 20 6d 6f 73 74 20 68 69 ; TAB(&0d, &18) "Press " &42e5 67 68 6c 79 20 72 61 74 65 64 6f 66 20 53 74 61 ; "~" &42f5 72 2d 46 6c 65 65 74 27 73 20 70 61 73 74 20 63 &4305 6f 6d 6d 61 6e 64 65 72 73 2e 1f 0d 18 50 72 65 &4315 73 73 20 3c 52 45 54 55 52 4e 3e 7e 0d ; unused &4322 ff ff ff ff ff ea ea ea ea ea ea ea ea ea ea ea &4332 ea ea ea ; high_score_table ; msb--lsb name---------------------------------- &4335 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 &4345 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 &4355 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 &4365 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 &4375 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 &4385 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 &4395 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 &43a5 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ; unused &43b5 ff ff ff ff ff ff ff ff ff ff ff 00 00 00 00 00 &43c5 ea ea ea ea ea ea ea ea ea ea ea ea ea ea ea ea &43d5 ea ea ; starfleet_records_screen &43d7 a9 16 LDA #&16 # MODE 7 &43d9 20 ee ff JSR &ffee ; OSWRCH &43dc a9 07 LDA #&07 &43de 20 ee ff JSR &ffee ; OSWRCH &43e1 20 36 23 JSR &2336 ; disable_cursor &43e4 a9 a5 LDA #&a5 &43e6 85 80 STA &80 ; text_address_low &43e8 a9 42 LDA #&42 ; &42a5 = starfleet_records_string &43ea 85 81 STA &81 ; text_address_high &43ec a0 00 LDY #&00 ; plot_starfleet_records_loop &43ee b1 80 LDA (&80),Y ; text_address &43f0 c9 7e CMP #&7e &43f2 f0 0b BEQ &43ff ; finished_plotting_starfleet_records &43f4 20 ee ff JSR &ffee ; OSWRCH &43f7 e6 80 INC &80 ; text_address_low &43f9 d0 f3 BNE &43ee ; plot_starfleet_records_loop &43fb e6 81 INC &81 ; text_address_high &43fd d0 ef BNE &43ee ; plot_starfleet_records_loop ; finished_plotting_starfleet_records &43ff a9 08 LDA #&08 &4401 85 75 STA &75 ; number_of_records &4403 a2 00 LDX #&00 ; plot_high_scores_loop &4405 a9 1f LDA #&1f &4407 20 ee ff JSR &ffee ; OSWRCH &440a a9 07 LDA #&07 &440c 20 ee ff JSR &ffee ; OSWRCH &440f 8a TXA &4410 4a LSR A &4411 4a LSR A &4412 4a LSR A &4413 18 CLC &4414 69 08 ADC #&08 # TAB(&07, x/8 + 8) &4416 20 ee ff JSR &ffee ; OSWRCH &4419 bd 38 43 LDA &4338,X ; high_score_table + 3 &441c f0 48 BEQ &4466 ; leave_after_plotting_underscores &441e 8a TXA &441f 4a LSR A &4420 4a LSR A &4421 4a LSR A &4422 4a LSR A &4423 18 CLC &4424 69 31 ADC #&31 &4426 20 ee ff JSR &ffee ; OSWRCH # CHAR((x/16) + &31) &4429 a9 20 LDA #&20 &442b 20 ee ff JSR &ffee ; OSWRCH &442e 20 ee ff JSR &ffee ; OSWRCH &4431 20 ee ff JSR &ffee ; OSWRCH &4434 e8 INX &4435 e8 INX &4436 e8 INX &4437 a0 0d LDY #&0d ; plot_name_loop &4439 bd 35 43 LDA &4335,X ; high_score_table &443c 20 ee ff JSR &ffee ; OSWRCH &443f e8 INX &4440 88 DEY &4441 d0 f6 BNE &4439 ; plot_name_loop &4443 a9 20 LDA #&20 &4445 20 ee ff JSR &ffee ; OSWRCH &4448 20 ee ff JSR &ffee ; OSWRCH &444b 20 ee ff JSR &ffee ; OSWRCH &444e a0 20 LDY #&20 ; " " # Leading zeros will be spaces &4450 bd 25 43 LDA &4325,X ; high_score_table - 16 &4453 20 79 44 JSR &4479 ; plot_two_digit_high_score &4456 bd 26 43 LDA &4326,X ; high_score_table - 15 &4459 20 79 44 JSR &4479 ; plot_two_digit_high_score &445c bd 27 43 LDA &4327,X ; high_score_table - 14 &445f 20 79 44 JSR &4479 ; plot_two_digit_high_score &4462 c6 75 DEC &75 ; number_of_records &4464 d0 9f BNE &4405 ; plot_high_scores_loop ; leave_after_plotting_underscores &4466 a9 00 LDA #&00 &4468 20 4c 40 JSR &404c ; plot_line_of_underscores_at_y &446b a9 02 LDA #&02 &446d 20 4c 40 JSR &404c ; plot_line_of_underscores_at_y &4470 a9 17 LDA #&17 &4472 20 4c 40 JSR &404c ; plot_line_of_underscores_at_y &4475 20 bb 41 JSR &41bb ; wait_for_return &4478 60 RTS ; plot_two_digit_high_score &4479 85 88 STA &88 ; bcd_value &447b 4a LSR A &447c 4a LSR A &447d 4a LSR A &447e 4a LSR A &447f 20 86 44 JSR &4486 ; plot_one_digit_high_score &4482 a5 88 LDA &88 ; bcd_value &4484 29 0f AND #&0f ; plot_one_digit_high_score &4486 d0 03 BNE &448b ; not_zero &4488 98 TYA &4489 d0 05 BNE &4490 ; leading_zero ; not_zero &448b a0 30 LDY #&30 ; "0" # Subsequent zeros will be zeros &448d 18 CLC &448e 69 30 ADC #&30 ; leading_zero &4490 20 ee ff JSR &ffee ; OSWRCH &4493 60 RTS ; enter_your_name_string &4494 1f 00 0a 45 6e 74 65 72 20 79 6f 75 72 20 6e 61 ; TAB(&00, &0a) "Enter your name for Star-fleet records." &44a4 6d 65 20 66 6f 72 20 53 74 61 72 2d 46 6c 65 65 ; TAB(&0d, &10) "-------------" &44b4 74 20 72 65 63 6f 72 64 73 2e 1f 0d 10 2d 2d 2d ; TAB(&0d, &0f) &44c4 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 1f 0d 0f 7e 0d ; input_buffer &44d3 00 00 00 00 00 00 00 00 00 00 00 00 00 ; input_osword_block &44e1 d3 44 0d 20 ff ; &44d3 = input_buffer, length &0d, acceptable values &20 - &ff ; unused &44e6 00 ea ; check_for_highscore &44e8 a9 16 LDA #&16 # MODE 4 &44ea 20 ee ff JSR &ffee ; OSWRCH &44ed a9 04 LDA #&04 &44ef 20 ee ff JSR &ffee ; OSWRCH &44f2 ad 65 2d LDA &2d65 ; score_as_bcd &44f5 0d 66 2d ORA &2d66 ; score_as_bcd + 1 &44f8 0d 67 2d ORA &2d67 ; score_as_bcd + 2 &44fb f0 2b BEQ &4528 ; leave # Don't check if player scored zero &44fd a9 08 LDA #&08 &44ff 85 75 STA &75 ; records_left_to_consider &4501 a2 00 LDX #&00 ; consider_records_loop &4503 ad 67 2d LDA &2d67 ; score_as_bcd + 2 &4506 dd 35 43 CMP &4335,X ; high_score_table &4509 90 14 BCC &451f ; consider_next_record &450b d0 1c BNE &4529 ; higher_score &450d ad 66 2d LDA &2d66 ; score_as_bcd + 1 &4510 dd 36 43 CMP &4336,X ; high_score_table + 1 &4513 90 0a BCC &451f ; consider_next_record &4515 d0 12 BNE &4529 ; higher_score &4517 ad 65 2d LDA &2d65 ; score_as_bcd &451a dd 37 43 CMP &4337,X ; high_score_table + 2 &451d b0 0a BCS &4529 ; higher_score ; consider_next_record &451f 8a TXA &4520 18 CLC &4521 69 10 ADC #&10 &4523 aa TAX &4524 c6 75 DEC &75 ; records_left_to_consider &4526 d0 db BNE &4503 ; consider_records_loop &4528 60 RTS ; higher_score &4529 86 88 STX &88 ; record_offset &452b a2 70 LDX #&70 ; move_records_down_a_slot_loop &452d e4 88 CPX &88 ; record_offset &452f f0 0a BEQ &453b ; finished_moving_records &4531 ca DEX &4532 bd 35 43 LDA &4335,X ; high_score_table &4535 9d 45 43 STA &4345,X ; high_score_table + 16 &4538 4c 2d 45 JMP &452d ; move_records_down_a_slot_loop ; finished_moving_records &453b a9 94 LDA #&94 &453d 85 80 STA &80 ; text_address_low &453f a9 44 LDA #&44 ; &4494 = enter_your_name_string &4541 85 81 STA &81 ; text_address_high &4543 a0 00 LDY #&00 ; plot_enter_your_name_loop &4545 b1 80 LDA (&80),Y ; text_address &4547 c9 7e CMP #&7e &4549 f0 0b BEQ &4556 ; finished_plotting_enter_your_name &454b 20 ee ff JSR &ffee ; OSWRCH &454e e6 80 INC &80 ; text_address_low &4550 d0 f3 BNE &4545 ; plot_enter_your_name_loop &4552 e6 81 INC &81 ; text_address_high &4554 d0 ef BNE &4545 ; plot_enter_your_name_loop ; finished_plotting_enter_your_name &4556 a2 e1 LDX #&e1 &4558 a0 44 LDY #&44 ; &44e1 = input_osword_block &455a a9 00 LDA #&00 ; Input line (INPUT) &455c 20 f1 ff JSR &fff1 ; OSWORD &455f 84 7b STY &7b ; input_length &4561 90 05 BCC &4568 ; escape_not_pressed &4563 a9 7e LDA #&7e ; Acknowledge ESCAPE Condition &4565 20 f4 ff JSR &fff4 ; OSBYTE ; escape_not_pressed &4568 a6 88 LDX &88 ; record_offset &456a ad 65 2d LDA &2d65 ; score_as_bcd &456d 9d 37 43 STA &4337,X ; high_score_table + 2 &4570 ad 66 2d LDA &2d66 ; score_as_bcd + 1 &4573 9d 36 43 STA &4336,X ; high_score_table + 1 &4576 ad 67 2d LDA &2d67 ; score_as_bcd + 2 &4579 9d 35 43 STA &4335,X ; high_score_table &457c a0 00 LDY #&00 ; copy_name_loop &457e c4 7b CPY &7b ; input_length &4580 f0 0a BEQ &458c ; finished_copying_name &4582 b9 d3 44 LDA &44d3,Y ; input_buffer &4585 9d 38 43 STA &4338,X ; high_score_table + 3 &4588 e8 INX &4589 c8 INY &458a d0 f2 BNE &457e ; copy_name_loop ; finished_copying_name ; pad_name_loop &458c c0 0d CPY #&0d &458e f0 09 BEQ &4599 ; finished_padding_name &4590 a9 20 LDA #&20 &4592 9d 38 43 STA &4338,X ; high_score_table + 3 &4595 e8 INX &4596 c8 INY &4597 d0 f3 BNE &458c ; pad_name_loop ; finished_padding_name &4599 20 d7 43 JSR &43d7 ; starfleet_records_screen &459c 60 RTS ; plot_shields_string_and_something &459d 20 b8 45 JSR &45b8 ; plot_shields_string &45a0 ad 59 26 LDA &2659 ; scanner_failure_duration &45a3 f0 08 BEQ &45ad ; leave &45a5 68 PLA # Abandon any further plotting in handle_player_movement &45a6 68 PLA &45a7 8a TXA &45a8 29 01 AND #&01 &45aa 8d 56 0e STA &0e56 ; starship_shields_active &45ad 60 RTS ; plot_auto_shields_string &45ae ad 3a 19 LDA &193a ; previous_starship_automatic_shields &45b1 cd 24 19 CMP &1924 ; starship_automatic_shields &45b4 10 0e BPL &45c4 ; leave &45b6 a2 0e LDX #&0e ; AUTO ; plot_shields_string &45b8 a0 07 LDY #&07 ; plot_shields_string_loop &45ba bd b2 17 LDA &17b2,X ; shield_state_strings &45bd 20 ee ff JSR &ffee ; OSWRCH &45c0 e8 INX &45c1 88 DEY &45c2 d0 f6 BNE &45ba ; plot_shields_string_loop &45c4 60 RTS ; unused &45c5 ea NOP &45c6 ea NOP &45c7 ea NOP &45c8 60 RTS ; unused &45c9 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 &45a9 00 ; start_game &45da a9 16 LDA #&16 &45dc 20 ee ff JSR &ffee ; OSWRCH &45df a9 04 LDA #&04 &45e1 20 ee ff JSR &ffee ; OSWRCH &45e4 20 36 23 JSR &2336 ; disable_cursor &45e7 a9 00 LDA #&00 &45e9 8d 07 39 STA &3907 ; previous_score_as_bcd &45ec 8d 08 39 STA &3908 ; previous_score_as_bcd + 1 &45ef 8d 09 39 STA &3909 ; previous_score_as_bcd + 2 &45f2 8d 57 26 STA &2657 ; number_of_live_starship_torpedoes &45f5 4c f3 37 JMP &37f3 ; start_game_continuation ; unused NOPs &45f8 ea ea ea ea ea ea ea ea ea ea ea ea ea ea ea ; end_of_command &4607 68 PLA # Remove plot_starship_explosion from stack &4608 68 PLA &4609 ad 01 04 LDA &0401 ; enemy_ships_previous_x_fraction &460c 8d d2 1c STA &1cd2 ; rnd_2 # Re-seed the RNG with two essentially random numbers &460f ad 04 04 LDA &0404 ; enemy_ships_previous_y_fraction &4612 8d d1 1c STA &1cd1 ; rnd_1 &4615 a9 16 LDA #&16 # MODE 4 &4617 20 ee ff JSR &ffee ; OSWRCH &461a a9 04 LDA #&04 &461c 20 ee ff JSR &ffee ; OSWRCH &461f 20 36 23 JSR &2336 ; disable_cursor &4622 20 12 23 JSR &2312 ; set_foreground_colour_to_black &4625 20 61 3b JSR &3b61 ; plot_debriefing &4628 20 06 23 JSR &2306 ; set_foreground_colour_to_white &462b 20 bb 41 JSR &41bb ; wait_for_return &462e ad 0a 39 LDA &390a ; allowed_another_command &4631 d0 06 BNE &4639 ; start_next_command &4633 20 e8 44 JSR &44e8 ; check_for_highscore &4636 4c b1 47 JMP &47b1 ; frontiers_of_space_screen ; start_next_command &4639 20 03 42 JSR &4203 ; combat_preparation_screen &463c ad 65 2d LDA &2d65 ; score_as_bcd &463f 8d 07 39 STA &3907 ; previous_score_as_bcd &4642 ad 66 2d LDA &2d66 ; score_as_bcd + 1 &4645 8d 08 39 STA &3908 ; previous_score_as_bcd + 1 &4648 ad 67 2d LDA &2d67 ; score_as_bcd + 2 &464b 8d 09 39 STA &3909 ; previous_score_as_bcd + 2 &464e a0 03 LDY #&03 ; change_probabilities_loop &4650 b9 ba 33 LDA &33ba,Y ; current_command_enemy_ship_spawning_probabilities &4653 d9 c6 33 CMP &33c6,Y ; ultimate_enemy_ship_probabilities &4656 f0 07 BEQ &465f ; skip_change_of_probability &4658 18 CLC &4659 79 c0 33 ADC &33c0,Y ; change_in_enemy_ship_spawning_probabilities_per_command &465c 99 ba 33 STA &33ba,Y ; current_command_enemy_ship_spawning_probabilities ; skip_change_of_probability &465f 88 DEY &4660 10 ee BPL &4650 ; change_probabilities_loop &4662 ad 50 0e LDA &0e50 ; maximum_number_of_stars &4665 cd ba 34 CMP &34ba ; minimum_number_of_stars &4668 f0 07 BEQ &4671 ; skip_change_of_stars &466a 18 CLC &466b 6d bb 34 ADC &34bb ; change_in_number_of_stars_per_command &466e 8d 50 0e STA &0e50 ; maximum_number_of_stars ; skip_change_of_stars &4671 a9 16 LDA #&16 # MODE 4 &4673 20 ee ff JSR &ffee ; OSWRCH &4676 a9 04 LDA #&04 &4678 20 ee ff JSR &ffee ; OSWRCH &467b 20 36 23 JSR &2336 ; disable_cursor &467e 20 f4 34 JSR &34f4 ; prepare_starship_for_next_command &4681 4c 33 38 JMP &3833 ; main_game_loop ; unused NOPs &4684 ea ea ea ea ea ea ea ea ea ea ea ea ea ea ea ; the_frontiers_string &4693 1f 00 05 20 20 54 68 65 20 66 72 6f 6e 74 69 65 ; TAB(&00, &05) " The frontiers of space are frequently " &46a3 72 73 20 6f 66 20 73 70 61 63 65 20 61 72 65 20 ; "penetrated by hostile alien ships . " &46b3 66 72 65 71 75 65 6e 74 6c 79 20 70 65 6e 65 74 ; " These are tackled by battle starships ," &46c3 72 61 74 65 64 20 20 62 79 20 20 68 6f 73 74 69 ; "the command of which is given to " &46d3 6c 65 20 20 61 6c 69 65 6e 20 20 73 68 69 70 73 ; "deserving captains from the Star-Fleet ." &46e3 20 2e 20 20 54 68 65 73 65 20 61 72 65 20 74 61 ; TAB(&0b, &02) "STARSHIP COMMAND" &46f3 63 6b 6c 65 64 20 62 79 20 62 61 74 74 6c 65 20 ; TAB(&06, &0a) "To begin your first command" &4703 73 74 61 72 73 68 69 70 73 20 2c 74 68 65 20 20 ; TAB(&0c, &0b) "Press " &4713 63 6f 6d 6d 61 6e 64 20 20 6f 66 20 20 77 68 69 ; "~" &4723 63 68 20 20 69 73 20 20 67 69 76 65 6e 20 20 74 &4733 6f 20 20 64 65 73 65 72 76 69 6e 67 20 63 61 70 &4743 74 61 69 6e 73 20 66 72 6f 6d 20 74 68 65 20 53 &4753 74 61 72 2d 46 6c 65 65 74 20 2e 1f 0b 02 53 54 &4763 41 52 53 48 49 50 20 20 43 4f 4d 4d 41 4e 44 1f &4773 06 0a 54 6f 20 62 65 67 69 6e 20 79 6f 75 72 20 &4783 66 69 72 73 74 20 63 6f 6d 6d 61 6e 64 1f 0c 0b &4793 50 72 65 73 73 20 3c 52 45 54 55 52 4e 3e 7e 0d ; unused &47a3 ff ea ea ea ea ea ea ea ea ea ea ea ea ea ; frontiers_of_space_screen &47b1 ad 49 0e LDA &0e49 ; star_table_address_low &47b4 85 80 STA &80 ; star_address_low &47b6 ad 4a 0e LDA &0e4a ; star_table_address_high &47b9 85 81 STA &81 ; star_address_high &47bb a0 00 LDY #&00 &47bd a2 00 LDX #&00 ; initialise_stars_loop &47bf a9 80 LDA #&80 &47c1 91 80 STA (&80),Y ; star_address &47c3 c8 INY &47c4 bd 00 4a LDA &4a00,X ; initial_star_positions &47c7 91 80 STA (&80),Y ; star_address &47c9 c8 INY &47ca d0 02 BNE &47ce &47cc e6 81 INC &81 ; star_address_high &47ce e8 INX &47cf d0 ee BNE &47bf ; initialise_stars_loop &47d1 20 2f 36 JSR &362f ; initialise_joystick_and_cursor_keys &47d4 a9 16 LDA #&16 # MODE 4 &47d6 20 ee ff JSR &ffee ; OSWRCH &47d9 a9 04 LDA #&04 &47db 20 ee ff JSR &ffee ; OSWRCH &47de a9 0d LDA #&0d &47e0 20 ee ff JSR &ffee ; OSWRCH &47e3 a9 00 LDA #&00 &47e5 20 4c 40 JSR &404c ; plot_line_of_underscores_at_y &47e8 a9 03 LDA #&03 &47ea 20 4c 40 JSR &404c ; plot_line_of_underscores_at_y &47ed a9 93 LDA #&93 &47ef 85 80 STA &80 ; text_address_low &47f1 a9 46 LDA #&46 ; &4693 = the_frontiers_string &47f3 85 81 STA &81 ; text_address_high &47f5 a0 00 LDY #&00 ; plot_the_frontiers_loop &47f7 b1 80 LDA (&80),Y ; text_address &47f9 c9 7e CMP #&7e &47fb f0 0b BEQ &4808 ; finished_the_frontiers &47fd 20 ee ff JSR &ffee ; OSWRCH &4800 e6 80 INC &80 ; text_address_low &4802 d0 f3 BNE &47f7 ; plot_the_frontiers_loop &4804 e6 81 INC &81 ; text_address_high &4806 d0 ef BNE &47f7 ; plot_the_frontiers_loop ; finished_the_frontiers &4808 a9 0f LDA #&0f ; Flush all buffers/input buffer &480a a2 01 LDX #&01 ; Flushes just the input buffer &480c a0 00 LDY #&00 &480e 20 f4 ff JSR &fff4 ; OSBYTE &4811 a9 80 LDA #&80 &4813 8d 50 0e STA &0e50 ; maximum_number_of_stars &4816 a9 01 LDA #&01 &4818 8d 00 0f STA &0f00 ; starship_velocity_high &481b 8d 01 0f STA &0f01 ; starship_velocity_low &481e a9 85 LDA #&85 &4820 8d 02 0f STA &0f02 ; starship_rotation &4823 a9 05 LDA #&05 &4825 8d 03 0f STA &0f03 ; starship_rotation_magnitude &4828 a9 ce LDA #&ce &482a 8d 04 0f STA &0f04 ; starship_rotation_cosine &482d a9 0a LDA #&0a &482f 8d 05 0f STA &0f05 ; starship_rotation_sine_magnitude &4832 a9 62 LDA #&62 &4834 85 79 STA &79 ; screen_start_high &4836 20 24 1d JSR &1d24 ; plot_stars ; wait_for_return_in_frontiers &4839 ee d1 1c INC &1cd1 ; rnd_1 &483c 78 SEI &483d 20 d0 13 JSR &13d0 ; update_stars &4840 58 CLI &4841 a9 81 LDA #&81 ; Read key &4843 a2 02 LDX #&02 &4845 a0 00 LDY #&00 &4847 20 f4 ff JSR &fff4 ; OSBYTE &484a e0 0d CPX #&0d ; RETURN &484c f0 0c BEQ &485a ; return_pressed &484e c0 1b CPY #&1b : ESCAPE &4850 d0 e7 BNE &4839 ; wait_for_return_in_frontiers &4852 a9 7e LDA #&7e ; Acknowledge ESCAPE Condition ; osbyte_then_wait_for_return &4854 20 f4 ff JSR &fff4 ; OSBYTE &4857 4c 39 48 JMP &4839 ; wait_for_return_in_frontiers ; return_pressed &485a a9 58 LDA #&58 &485c 85 79 STA &79 ; screen_start_high &485e ad d1 1c LDA &1cd1 ; rnd_1 &4861 49 cd EOR #&cd &4863 8d d2 1c STA &1cd2 ; rnd_2 &4866 a9 0d LDA #&0d &4868 20 ee ff JSR &ffee ; OSWRCH &486b 20 03 42 JSR &4203 ; combat_preparation_screen &486e 4c da 45 JMP &45da ; start_game ; unused # Unused code fragment &4871 54 &4872 48 PHA &4873 e0 0d CPX #&0d &4875 d0 dd BNE &4854 ; osbyte_then_wait_for_return &4877 60 RTS &4878 00 BRK ; unused_title_string &4879 1f 0b 0a 53 54 41 52 53 48 49 50 20 43 4f 4d 4d ; TAB(&0b, &0a) "STARSHIP COMMAND I" &4889 41 4e 44 20 49 1f 0b 0c 43 4f 50 59 52 49 47 48 ; TAB(&0b, &0c) "COPYRIGHT (c) 1982" &4899 54 20 28 63 29 20 31 39 38 32 1f 0b 0e 50 65 74 ; TAB(&0b, &0e) "Peter J.M. Irvin." &48a9 65 72 20 4a 2e 4d 2e 20 49 72 76 69 6e 2e 7e 0d ; "~" ; unused &48b9 ff ; unused_title_screen &48ba a9 16 LDA #&16 # MODE 7 &48bb 20 ee ff JSR &ffee ; OSWRCH &48be a9 07 LDA #&07 &48c1 20 ee ff JSR &ffee ; OSWRCH &48c4 a0 00 LDY #&00 ; plot_title_loop &48c6 b9 79 48 LDA &4879,Y ; title_text &48c9 c9 7e CMP #&7e &48cb f0 06 BEQ &48d3 ; finished_plotting_title &48cd 20 ee ff JSR &ffee ; OSWRCH &48d0 c8 INY &48d1 d0 f3 BNE &48c6 ; plot_title_loop ; finished_plotting_title &48d3 a0 00 LDY #&00 &48d5 a2 64 LDX #&64 &48d7 a9 81 LDA #&81 ; Read key &48d9 20 f4 ff JSR &fff4 ; OSBYTE &48dc 4c b1 47 JMP &47b1 ; frontiers_of_space_screen ; unused &48df 9c a9 b8 a9 be ec 86 e2 81 e2 ec 85 be ba a5 a2 # Not meaningful as code. &48ef e2 ; unused &48f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ; get_joystick_input &4900 a9 80 LDA #&80 ; Read I/O device or buffer status &4902 a2 00 LDX #&00 ; buttons &4904 20 f4 ff JSR &fff4 ; OSBYTE &4907 8a TXA &4908 29 03 AND #&03 &490a f0 03 BEQ &490f ; fire_not_pressed &490c ee 1a 19 INC &191a ; fire_pressed ; fire_not_pressed &490f a9 80 LDA #&80 ; Read I/O device or buffer status &4911 a2 02 LDX #&02 ; Analogue Channel 2 &4913 20 f4 ff JSR &fff4 ; OSBYTE &4916 ad 00 0f LDA &0f00 ; starship_velocity_high &4919 85 7a STA &7a ; velocity_high_shifted &491b ad 01 0f LDA &0f01 ; starship_velocity_low &491e 0a ASL A &491f 26 7a ROL &7a ; velocity_high_shifted &4921 0a ASL A &4922 26 7a ROL &7a ; velocity_high_shifted &4924 98 TYA &4925 4a LSR A &4926 4a LSR A &4927 4a LSR A &4928 38 SEC &4929 e9 08 SBC #&08 &492b b0 02 BCS &492f ; skip_floor &492d a9 00 LDA #&00 ; skip_floor &492f c5 7a CMP &7a ; velocity_high_shifted &4931 f0 0b BEQ &493e ; consider_rotation &4933 90 06 BCC &493b ; decrease_velocity ; increase_velocity &4935 ee 2e 19 INC &192e ; velocity_delta &4938 4c 3e 49 JMP &493e ; consider_rotation ; decrease_velocity &493b ce 2e 19 DEC &192e ; velocity_delta ; consider_rotation &493e a9 80 LDA #&80 ; Read I/O device or buffer status &4940 a2 01 LDX #&01 ; Analogue Channel 1 &4942 20 f4 ff JSR &fff4 ; OSBYTE &4945 98 TYA &4946 49 ff EOR #&ff &4948 4a LSR A &4949 4a LSR A &494a 4a LSR A &494b 4a LSR A &494c c9 08 CMP #&08 &494e 90 03 BCC &4953 ; skip_subtraction &4950 e9 01 SBC #&01 &4952 18 CLC ; skip_subtraction &4953 69 79 ADC #&79 &4955 cd 02 0f CMP &0f02 ; starship_rotation &4958 f0 0b BEQ &4965 ; leave &495a b0 06 BCS &4962 ; rotate_clockwise ; rotate_anticlockwise &495c ce 27 19 DEC &1927 ; rotation_delta &495f 4c 65 49 JMP &4965 ; leave ; rotate_clockwise &4962 ee 27 19 INC &1927 ; rotation_delta &4965 60 RTS ; unused &4966 00 00 00 00 00 00 00 00 00 00 ; unused_copyright_string &4970 0c 1f 0c 08 53 54 41 52 53 48 49 50 20 43 4f 4d ; CLS &4980 4d 41 4e 44 1f 01 0a 43 6f 70 79 72 69 67 68 74 ; TAB(&0c, &08), "STARSHIP COMMAND" &4990 20 28 63 29 20 41 63 6f 72 6e 73 6f 66 74 20 4c ; TAB(&01, &0a), "Copyright (c) Acornsoft Limited 1982" &49a0 69 6d 69 74 65 64 20 31 39 38 32 1f 06 0c 43 72 ; TAB(&06, &0c), "Created by Peter J.M. Irvin" &49b0 65 61 74 65 64 20 62 79 20 50 65 74 65 72 20 4a ; TAB(&0a, &0e), "All rights reserved" &49c0 2e 4d 2e 20 49 72 76 69 6e 1f 0a 0e 41 6c 6c 20 &49d0 72 69 67 68 74 73 20 72 65 73 65 72 76 65 64 0d ; unused &49e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ; chan vol pitch dur ; sound_10 &49f0 11 00 00 00 00 00 04 00 # Starship engine ; sound_11 &49f8 10 00 03 00 07 00 1e 00 # Enemy ship explosion ; initial_star_positions &4a00 d5 82 d5 7b d5 88 d5 75 d3 8f d3 6e d3 84 d3 79 &4a10 d2 8d d2 70 d1 95 d1 68 cf 92 cf 6b cf 9b cf 62 &4a20 cf 87 cf 76 cb a0 cb 5d cb 98 cb 65 c9 8b c9 72 &4a30 c7 9c c7 61 c7 a5 c7 58 c3 aa c3 53 c2 8d c2 70 &4a40 c1 a0 c1 5d be ae be 4f bb a4 bb 59 b9 90 b9 6d &4a50 b8 b2 b8 4b b4 a7 b4 56 b3 b5 b3 48 af 91 af 6c &4a60 ad b7 ad 46 ad a9 ad 54 a6 b9 a6 44 a5 ab a5 52 &4a70 a5 92 a5 6b a0 ba a0 43 9d ab 9d 52 9a bb 9a 43 &4a80 9a 93 9a 6b 96 ab 96 52 93 ba 93 43 8e ab 8e 52 &4a90 8e 92 8e 6b 8d b9 8d 44 86 a9 86 54 86 b7 86 46 &4aa0 84 91 84 6c 80 b5 80 48 7f a7 7f 56 7b b2 7b 4b &4ab0 7a 90 7a 6d 78 a4 78 59 75 ae 75 4f 72 a0 72 5d &4ac0 71 8d 71 70 70 aa 70 53 6c a5 6c 58 6c 9c 6c 61 &4ad0 6a 8b 6a 72 68 98 68 65 68 a0 68 5d 64 92 64 6b &4ae0 64 9b 64 62 64 87 64 76 62 95 62 68 61 8d 61 70 &4af0 60 8f 60 6e 60 84 60 79 5e 82 5e 7b 5e 88 5e 75 ; star_table &4b00 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff &4b10 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff &4b20 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff &4b30 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff &4b40 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 &4b50 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 &4b60 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 &4b70 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 &4b80 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff &4b90 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff &4ba0 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff &4bb0 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff &4bc0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ; starship_explosion_table &4bd0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 &4be0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 &4bf0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 &4c00 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff &4c10 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff &4c20 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff &4c30 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff &4c40 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 &4c50 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 &4c60 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 &4c70 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 &4c80 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ; further_star_table # &4b00 - &4cff is used for stars in "frontiers" screen &4c90 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff &4ca0 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff &4cb0 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff &4cc0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 &4cd0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 &4ce0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 &4cf0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ; enemy_explosion_tables &4d00 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff &4d10 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff &4d20 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff &4d30 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ; &4d40 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 &4d50 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 &4d60 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 &4d70 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ; &4d80 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff &4d90 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff &4da0 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff &4db0 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ; &4dc0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 &4dd0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 &4de0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 &4df0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ; &4e00 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff &4e10 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff &4e20 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff &4e30 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ; &4e40 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 &4e50 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 &4e60 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 &4e70 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ; &4e80 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff &4e90 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff &4ea0 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff &4eb0 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ; &4ec0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 &4ed0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 &4ee0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 &4ef0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ; starship_torpedoes_table &4f00 00 ff ff ff ff ff ff ff ff &4f09 00 ff ff ff ff ff ff ff ff &4f12 00 ff ff ff ff ff ff ff ff &4f1b 00 ff ff ff ff ff ff ff ff &4f24 00 ff ff ff ff ff ff ff ff &4f2d 00 ff ff ff ff ff ff ff ff &4f36 00 ff ff ff ff ff ff ff ff &4f3f 00 00 00 00 00 00 00 00 00 &4f48 00 00 00 00 00 00 00 00 00 &4f51 00 00 00 00 00 00 00 00 00 &4f5a 00 00 00 00 00 00 00 00 00 &4f6c 00 00 00 00 00 00 00 00 00 ; unused # Space for eight extra starship torpedoes &4f6c 00 00 00 00 00 00 00 00 00 &4f75 00 00 00 00 00 00 00 00 00 &4f7e 00 00 ff ff ff ff ff ff ff &4f87 ff ff ff ff ff ff ff ff ff &4f90 ff ff ff ff ff ff ff ff ff &4f99 ff ff ff ff ff ff ff ff ff &4fa2 ff ff ff ff ff ff ff ff ff &4fab ff ff ff ff ff ff ff ff ff ; enemy_torpedoes_table &4fb4 00 ff ff ff ff ff &4fba 00 ff ff ff ff ff &4fc0 00 00 00 00 00 00 &4fc6 00 00 00 00 00 00 &4fcc 00 00 00 00 00 00 &4fd2 00 00 00 00 00 00 &4fd8 00 00 00 00 00 00 &4fde 00 00 00 00 00 00 &4fe4 00 00 00 00 00 00 &4fea 00 00 00 00 00 00 &4ff0 00 00 00 00 00 00 &4ff6 00 00 00 00 00 00 &4ffc 00 00 00 00 ff ff &5002 00 ff ff ff ff ff &5008 00 ff ff ff ff ff &500e 00 ff ff ff ff ff &5014 00 ff ff ff ff ff &501a 00 ff ff ff ff ff &5020 00 ff ff ff ff ff &5026 00 ff ff ff ff ff &502c 00 ff ff ff ff ff &5032 00 ff ff ff ff ff &5038 00 ff ff ff ff ff &503e 00 ff 00 00 00 00 ; unused # Space for eighteen extra enemy torpedoes &5044 00 00 00 00 00 00 &504a 00 00 00 00 00 00 &5050 00 00 00 00 00 00 &5056 00 00 00 00 00 00 &505c 00 00 00 00 00 00 &5062 00 00 00 00 00 00 &5068 00 00 00 00 00 00 &506e 00 00 00 00 00 00 &5074 00 00 00 00 00 00 &507a 00 00 00 00 00 00 &5080 ff ff ff ff ff ff &5086 ff ff ff ff ff ff &508c ff ff ff ff ff ff &5092 ff ff ff ff ff ff &5098 ff ff ff ff ff ff &509e ff ff ff ff ff ff &50a4 ff ff ff ff ff ff &50aa ff ff ff ff ff ff &50b0 00 ; entry_point # Addresses prior to memory moving &62b1 a9 00 LDA #&00 &62b3 a8 TAY &62b4 85 80 STA &80 ; target_address_low &62b6 a9 0e LDA #&0e ; &0e00 &62b8 85 81 STA &81 ; target_address_high &62ba a9 00 LDA #&00 &62bc 85 82 STA &82 ; source_address_low &62be a9 20 LDA #&20 ; &2000 &62c0 85 83 STA &83 ; source_address_high &62c2 a9 b0 LDA #&b0 &62c4 85 84 STA &84 ; end_address_low &62c6 a9 62 LDA #&62 ; &62b0 &62c8 85 85 STA &85 ; end_address_high ; move_memory_loop # Move &2000-&62b0 to &0e00-&50b0 &62ca b1 82 LDA (&82),Y ; source_address &62cc 91 80 STA (&80),Y ; target_address &62ce a6 82 LDX &82 ; source_address_low &62d0 e4 84 CPX &84 ; end_address_low &62d2 d0 06 BNE &62da ; not_finished &62d4 a6 83 LDX &83 ; source_address_high &62d6 e4 85 CPX &85 ; end_address_high &62d8 f0 1c BEQ &62f6 ; finished_moving_memory ; not_finished &62da 18 CLC &62db a9 01 LDA #&01 &62dd 65 82 ADC &82 ; source_address_low &62df 85 82 STA &82 ; source_address_low &62e1 a9 00 LDA #&00 &62e3 65 83 ADC &83 ; source_address_high &62e5 85 83 STA &83 ; source_address_high &62e7 a9 01 LDA #&01 &62e9 65 80 ADC &80 ; target_address_low &62eb 85 80 STA &80 ; target_address_low &62ed a9 00 LDA #&00 &62ef 65 81 ADC &81 ; target_address_high &62f1 85 81 STA &81 ; target_address_high &62f3 4c ca 62 JMP &62ca ; move_memory_loop ; finished_moving_memory &62f6 4c b1 47 JMP &47b1 ; frontiers_of_space_screen