Killer Gorilla disassembly ========================== Killer Gorilla is a clone of Donkey Kong for the BBC Micro. It was written by Adrian Stephens and published by Micropower in 1984. 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 authors will accept it in the good faith it was intended - as a tribute to their skills. Technical notes =============== The binary begins with a BASIC loader, which calls a relocation routine. The locations of both player and enemies are stored as a horizontal position, a platform number (counting from the floor) and an offset from that platform. Enemies are divided into two groups of five, for barrels/pies/girders and fireballs respectively. The game's difficulty changes as follows: level 1 25m first barrel falls vertically, turns into fireball 50m conveyors move 2 frames out of 4 maximum 3 fireballs 75m extra life after stage completion 2 25m first barrel falls diagonally, doesn't turn into fireball even platforms have holes 50m conveyors move 3 frames out of 4 pies 50% more likely to appear maximum 4 fireballs 3 25m odd platforms have holes 50m conveyors move 4 frames out of 4 pies 100% more likely to appear maximum 5 fireballs 75m lifts move twice as fast 15 maximum speed reached Fireballs have a (level * 4) / 256 likelihood of using ladders. Interesting Pokes ================= &1692 = &60 player isn't harmed by enemies &1ce9 = &18, &1cea = &60 player never falls off platforms &13ea = &00 infinite time &11b1 = &58 player can jump with hammer &11f2 = &5e, &1b58 = &23, &1b59 = &1b player can climb with hammer &1411 = &a5, &1419 = &a5 hammer never disappears Disassembly =========== ; BASIC loader &1900 0d 00 0a 1d f4 20 4b 69 6c 6c 65 72 20 47 6f 72 ; 10REM Killer Gorilla (C) 1983 &1910 69 6c 6c 61 20 28 43 29 20 31 39 38 33 0d 00 14 ; 20 &1920 05 20 0d 00 1e 16 eb 37 3a ef 32 33 3b 38 32 30 ; 30MODE7:VDU23;8202;0;0;0; &1930 32 3b 30 3b 30 3b 30 3b 0d 00 28 14 e3 49 25 3d ; 40FORI%=0 TO &400 STEP 4 &1940 30 20 b8 20 26 34 30 30 20 88 20 34 0d 00 32 17 ; 50I%!&7C00=I%!TOP:NEXT I% &1950 49 25 21 26 37 43 30 30 3d 49 25 21 b8 50 3a ed : 60 &1960 20 49 25 0d 00 3c 05 20 0d 00 46 1a e3 49 25 3d ; 70FORI%=225TO232:VDU23,I%:READA$ &1970 32 32 34 b8 32 33 32 3a ef 32 33 2c 49 25 3a f3 ; 80FORJ%=1TO15STEP2 &1980 41 24 0d 00 50 0e e3 4a 25 3d 31 b8 31 35 88 32 ; 90VDU EVAL("&"+MID$(A$,J%,2)) &1990 0d 00 5a 16 ef 20 a0 28 22 26 22 2b c1 41 24 2c ; 100NEXT, &19a0 4a 25 2c 32 29 29 0d 00 64 06 ed 2c 0d 00 6e 05 ; 110 &19b0 20 0d 00 78 26 e2 31 2c 31 2c 30 2c 30 2c 30 2c ; 120ENVELOPE1,1,0,0,0,0,0,0,126,-1,0,-5,126,0 &19c0 30 2c 30 2c 30 2c 31 32 36 2c 2d 31 2c 30 2c 2d ; 130ENVELOPE2,133,8,4,8,3,1,1,126,0,0,-10,126,0 &19d0 35 2c 31 32 36 2c 30 0d 00 82 28 e2 32 2c 31 33 ; 140ENVELOPE3,1,30,0,-30,6,1,6,13,0,0,-126,126,0 &19e0 33 2c 38 2c 34 2c 38 2c 33 2c 31 2c 31 2c 31 32 ; 150ENVELOPE4,129,0,8,0,2,6,6,60,0,0,1,126,126 &19f0 36 2c 30 2c 30 2c 2d 31 30 2c 31 32 36 2c 30 0d ; 160 &1a00 00 8c 29 e2 33 2c 31 2c 33 30 2c 30 2c 2d 33 30 ; 170I%=INKEY(500) &1a10 2c 36 2c 31 2c 36 2c 31 33 2c 30 2c 30 2c 2d 31 ; 180 &1a20 32 36 2c 31 32 36 2c 30 0d 00 96 27 e2 34 2c 31 ; 190CALL (PAGE+&3300) &1a30 32 39 2c 30 2c 38 2c 30 2c 32 2c 36 2c 36 2c 36 ; 200 &1a40 30 2c 30 2c 30 2c 31 2c 31 32 36 2c 31 32 36 0d ; 210DATA FF182424424281FF &1a50 00 a0 05 20 0d 00 aa 0d 49 25 3d a6 28 35 30 30 ; 220DATA 818181FF81818181 &1a60 29 0d 00 b4 05 20 0d 00 be 0f d6 20 28 90 2b 26 ; 230DATA 6CFEFEFE7C381000 &1a70 33 33 30 30 29 0d 00 c8 05 20 0d 00 d2 16 dc 20 ; 240DATA 6CEEDEEE5C381000 &1a80 46 46 31 38 32 34 32 34 34 32 34 32 38 31 46 46 ; 250DATA FF888888888888FF &1a90 0d 00 dc 16 dc 20 38 31 38 31 38 31 46 46 38 31 ; 260DATA 8142241818244281 &1aa0 38 31 38 31 38 31 0d 00 e6 16 dc 20 36 43 46 45 ; 270DATA FFE7C38181C3E7FF &1ab0 46 45 46 45 37 43 33 38 31 30 30 30 0d 00 f0 16 ; 280DATA AEE8AE080E000000 &1ac0 dc 20 36 43 45 45 44 45 45 45 35 43 33 38 31 30 ; 290DATA 9995959991D11001 &1ad0 30 30 0d 00 fa 16 dc 20 46 46 38 38 38 38 38 38 &1ae0 38 38 38 38 38 38 46 46 0d 01 04 16 dc 20 38 31 &1af0 34 32 32 34 31 38 31 38 32 34 34 32 38 31 0d 01 &1b00 0e 16 dc 20 46 46 45 37 43 33 38 31 38 31 43 33 &1b10 45 37 46 46 0d 01 18 16 dc 20 41 45 45 38 41 45 &1b20 30 38 30 45 30 30 30 30 30 30 0d 01 22 16 dc 20 &1b30 39 39 39 35 39 35 39 39 39 31 44 31 31 30 30 31 &1b40 0d ff ; MODE 7 title screen &1b42 96 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ; ". `x/4 " &1b52 20 60 78 2f 34 20 20 20 20 20 20 20 20 20 20 20 ; ". #5ktp " &1b62 20 20 20 20 20 20 20 20 96 20 20 20 20 20 20 20 ; ". i"/.'t8 " &1b72 20 20 20 20 20 20 20 20 20 20 23 35 6b 74 70 20 ; ". )<&# " &1b82 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ; " . `ppppppppppppuppppppppppp0 " &1b92 96 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ; " . j.. KILLER GORILLA .5 " &1ba2 20 20 20 69 22 2f 7f 27 74 38 20 20 20 20 20 20 ; " . .h . KILLER GORILLA . 4 " &1bb2 20 20 20 20 20 20 20 20 96 20 20 20 20 20 20 20 ; " . ".//////////////////////.! " &1bc2 20 20 20 20 20 20 20 20 20 20 20 20 29 3c 26 23 ; " ... x|0. . . " &1bd2 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ; " .. .h..% x &0d2e 07 06 0d 09 0f 09 04 0f 0b 07 04 0f ; 50m &0d3a 02 07 0c 11 06 0d 02 07 0c 11 01 12 ; 75m ; stage_75m_ladders_x &0d46 00 01 12 10 12 0e 05 07 0b 0b ; 100m &0d50 01 09 12 02 07 0c 11 03 09 10 04 07 0c 0f ; unused &0d5e 00 00 ; ladders_platform &0d60 00 ; 25m <- holes -> &0d61 00 02 03 04 00 01 01 02 02 03 03 04 ; 50m &0d6d 00 00 00 00 01 01 02 02 02 02 03 03 ; 75m &0d79 01 02 01 02 03 04 02 02 02 03 ; 100m &0d83 00 00 00 01 01 01 01 02 02 02 03 03 03 03 ; unused &0d91 00 00 00 ; barrel_parabola &0d94 00 00 02 06 0b 11 19 22 ; bonus_string &0d9c 3d 4c 00 0e 1f 04 11 30 30 03 10 1f 53 55 4e 4f ; TAB(&0e, &02); "BONUS" &0dac 42 02 0e 1f ; TAB(&10, &03); "00" ; COLOUR 4; TAB(&0e, &00); "L=" ; unused &0db0 0c 00 ; game_over_string &0db2 05 12 03 01 19 04 80 01 7f 01 47 41 4d 45 20 4f ; GCOL 3, 1; MOVE &0180, &017f; "GAME OVER" &0dc2 56 45 52 0d ; sound_0 # Used for scoring ; chan vol pitch dur unused &0dc6 01 00 02 00 8d 00 04 00 00 # Ninth byte is unused ; sound_1 # Used for melodies and girder ; chan vol pitch dur unused &0dcf 01 00 01 00 28 00 03 00 00 # Ninth byte is unused ; stage_melody_notes_pitch &0dd8 85 8d 85 8d 85 69 79 71 69 69 ; stage_melody_notes_duration &0de2 0c 03 03 03 03 06 06 03 03 06 ; how_high_can_you_try_string &0dec 3f 59 52 54 20 55 4f 59 1d 08 1f 4e 41 43 20 48 ; TAB(&08, &1c); "HOW HIGH CAN" &0dfc 47 49 48 20 57 4f 48 1c 08 1f 0d ; TAB(&08, &1d); "YOU TRY?" ; plot_stage_routines_low &0e07 e7 90 7a 66 ; check_for_platform_routines_low &0e0b 2b 5e 51 82 ; calculate_platform_y_routines_low &0e0f 25 c8 fd dc ; update_enemies_routines_low &0e13 55 f0 3a 07 ; plot_stage_routines_high &0e17 23 26 20 27 ; check_for_platform_routines_high &0e1b 28 28 21 28 ; calculate_platform_y_routines_high &0e1f 25 28 21 28 ; update_enemies_routines_high &0e23 25 28 22 2a ; unused &0e27 2d ; "-" ; ladder_data_offsets &0e28 00 0c 18 22 30 ; top_platforms &0e2d 05 03 05 ff ; collectibles_type_and_score &0e31 2c 31 32 36 ; ",126" ; collectibles_x &0e35 2c 30 2c 2d ; ",0,-" ; collectibles_platform &0e39 31 30 2c 2d ; "10,-" ; stage_100m_supports_string &0e3d 03 06 1f 00 5f 00 00 01 19 03 20 03 00 04 19 00 ; MOVE &01ff, &0320; DRAW +&0000, +&005f; &0e4d 5f 00 00 01 19 03 20 01 ff 04 19 ; MOVE &0300, &0320; DRAW +&0000, +&005f; TAB(&06, &03) ; unused &0e58 37 45 39 3d ; "7E9=" ; stage_75_platforms ; x y length &0e5c 00 1d 02 &0e5f 00 17 02 &0e62 00 0e 02 &0e65 0a 1d 02 &0e68 0d 1c 01 &0e6b 0f 1b 02 &0e6e 12 1a 02 &0e71 12 15 02 &0e74 10 14 01 &0e77 0e 13 01 &0e7a 0b 12 02 &0e7d 0a 0d 03 &0e80 0e 0c 01 &0e83 10 0b 01 &0e86 12 0a 02 &0e89 10 0f 04 &0e8c 00 06 0f &0e92 04 0e 04 &0e95 05 1a 03 ; unused # Source code fragment corresponding to &37fa - &37ff &0e95 2c 33 2c 36 2c 36 2c 31 32 2c 31 32 2c 36 ; ",3,6,6,12,12,6" ; stage_75m_ladders_y &0ea3 1c 16 19 13 0e 0b 19 19 11 2c ; mode_two_cursor_off_string &0ead 00 00 00 00 00 00 20 0a 00 17 02 16 ; help_string &0eb9 07 11 e8 e7 03 11 00 0a 1f ; TAB(&0a, &00); COLOUR 3; HE LP!; COLOUR 7 ; delete_help_string &0ec2 7f 7f 00 0c 1f ; TAB(&0c, &00) ; unused &0ec7 37 ; "7" ; stage_75m_platform_heights ; x 0 4 8 c 10 14 18 1c 20 24 28 2c 30 34 38 3c 40 44 48 4c &0ec8 dc dc dc dc dc dc dc dc dc dc dc dc d8 d4 d0 cc cc c8 c4 c4 ; platform 1 &0edc ac ac ac ac c4 c4 c4 c4 c4 c4 84 84 84 88 8c 90 94 98 9c 9c ; platform 2 &0ef0 64 64 64 64 64 64 64 64 64 64 64 64 6c 6c 6c 6c 6c 6c 6c 6c ; platform 3 &0f04 00 00 00 00 00 00 00 00 00 5c 5c 5c 5c 58 54 50 4c 48 44 44 ; platform 4 ; unused &0f18 26 ; "&" ; lifts_string &0f19 e6 e6 1e 08 1f e6 e6 07 08 1f e6 e6 1e 02 1f e6 ; GCOL 0, 1 &0f29 e6 07 02 1f 02 11 02 dc 00 00 01 19 00 40 02 40 ; MOVE &00c0, &0040; DRAW +&0000, +&02dc &0f39 04 19 02 dc 00 00 01 19 00 40 00 c0 04 19 01 00 ; MOVE &0240, &0040; DRAW +&0000, +&02dc; COLOUR 2; &0f49 12 ; TAB(&02, &07); DIAMOND DIAMOND; TAB(&02, &1e); DIAMOND DIAMOND; ; TAB(&08, &07); DIAMOND DIAMOND; TAB(&08, &1e); DIAMOND DIAMOND; ; unused &0f4a 64 65 ; "de" ; stage_75m_ladders_lengths &0f4c 05 08 04 04 04 05 0b 0b 04 04 ; stage_75m_girder_bounce &0f56 2a 19 0f 0c 0f 19 ; stage_75m_platform_bits # Bit clear if platform present &0f5c 3f ca 40 ; 00111111 11001010 01000000 ; platform one &0f5f 38 e5 40 ; 00110100 11100101 01000000 ; platform two &0f62 30 ff 00 ; 00110000 11111111 00000000 ; platform three &0f65 ff c5 40 ; 11111111 11000101 01000000 ; platform four ; sound_3 # Used for player walking ; chan vol pitch dur unused &0f68 03 00 03 00 00 00 03 00 45 # Ninth byte is unused ; stage_completion_melody_notes_duration &0f71 51 65 75 81 75 81 95 95 ; stage_completion_melody_notes_pitch &0f79 06 06 03 03 03 06 03 06 ; death_melody_notes &0f81 35 21 35 3d 45 49 51 59 61 65 6d 75 79 81 89 91 &0f91 95 ; sound_2 # Used for player jumping ; chan vol pitch dur unused &0f92 02 00 04 00 4a 00 03 00 78 # Ninth byte is unused ; starting_melody_notes_pitch &0f9b 11 2d 35 35 25 19 19 21 2d 2d 2d 25 35 35 35 ; starting_melody_notes_duration &0faa 06 03 03 06 06 06 06 14 06 06 06 14 06 06 06 ; clear_window_string &0fb9 1a 0c 07 0d 1e 06 1c ; define text window(&06, &1e, &0d, &07); CLS; restore window ; give_up_string &0fc0 50 55 16 09 1f 45 56 49 47 14 08 1f ; TAB(&08, &14); "GIVE"; TAB(&09, &16); "UP" ; give_up_melody_notes_pitch &0fcc 75 79 75 79 75 6d 81 89 89 91 95 75 ; give_up_melody_notes_duration &0fd8 0f 01 01 04 03 10 07 07 16 07 16 07 ; killer_gorilla_scores_string &0fe4 ea 94 73 65 72 6f 63 73 83 41 4c 4c 49 52 4f 47 ; "..5.KILLER GORILLA.scores.." &0ff4 20 52 45 4c 4c 49 4b 81 35 94 8d 0d ; please_enter_your_name_string &1000 65 6d 61 6e 20 72 75 6f 79 20 72 65 74 6e 65 20 ; "..Please enter your name" &1010 65 73 61 65 6c 50 81 88 0d ; high_score_names &1019 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 0d &1029 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 0d &1039 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 0d &1049 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 0d &1059 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 0d &1069 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 0d &1079 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 0d &1089 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 0d ; unused &1099 0d ; high_scores_three &109a 00 00 00 00 00 00 00 00 ; high_scores_two &10a2 00 00 00 00 00 00 00 00 ; high_scores_one &10aa 00 00 00 00 00 00 00 00 ; unused &10b2 30 ; press_space_or_fire_string &10b3 65 72 69 46 20 72 6f 20 65 63 61 70 53 20 73 73 ; TAB(&08, &18); "..Press Space or Fire" &10c3 65 72 50 85 88 18 08 1f 0d ; collapse_melody_notes_pitch &10cc 95 81 75 81 ; collapse_melody_notes_duration &10d0 0c 04 04 04 ; play_game &10d4 a5 29 LDA &29 ; sound_enabled &10d6 f0 54 BEQ &112c ; skip_starting_melody &10d8 a9 00 LDA #&00 &10da 8d d1 0d STA &0dd1 ; sound_1_volume &10dd a0 71 LDY #&71 &10df 20 ce 1d JSR &1dce ; play_sound_with_pitch_and_duration # Silence any sound &10e2 ee cf 0d INC &0dcf ; sound_1_channel &10e5 ee d0 0d INC &0dd0 ; sound_1_channel_high # Synchronise two channels &10e8 ee d1 0d INC &0dd1 ; sound_1_volume &10eb a2 0e LDX #&0e ; play_starting_melody_loop # Play starting melody &10ed bd aa 0f LDA &0faa,X ; starting_melody_notes_duration &10f0 a8 TAY &10f1 bd 9b 0f LDA &0f9b,X ; starting_melody_notes_pitch &10f4 48 PHA &10f5 20 ce 1d JSR &1dce ; play_sound_with_pitch_and_duration &10f8 68 PLA &10f9 18 CLC &10fa 69 30 ADC #&30 &10fc ee cf 0d INC &0dcf ; sound_1_channel # Play each note as a chord on channels 1 and 2 &10ff 20 d1 1d JSR &1dd1 ; play_sound_with_pitch_and_previous_duration &1102 ce cf 0d DEC &0dcf ; sound_1_channel &1105 ca DEX &1106 10 e5 BPL &10ed ; play_starting_melody_loop &1108 ee d0 0d INC &0dd0 ; sound_1_channel_high # Synchronise three channels &110b a9 19 LDA #&19 &110d a0 0a LDY #&0a &110f 20 ce 1d JSR &1dce ; play_sound_with_pitch_and_duration # Play final chord on channels 1, 2 and 3 &1112 ee cf 0d INC &0dcf ; sound_1_channel &1115 a9 25 LDA #&25 &1117 20 d1 1d JSR &1dd1 ; play_sound_with_pitch_and_previous_duration &111a a9 01 LDA #&01 &111c 8d cf 0d STA &0dcf ; sound_1_channel &111f a9 35 LDA #&35 &1121 20 d1 1d JSR &1dd1 ; play_sound_with_pitch_and_previous_duration &1124 a9 0a LDA #&0a &1126 20 da 19 JSR &19da ; delay_for_a # (returns X = 0) &1129 8e d0 0d STX &0dd0 ; sound_1_channel_high # Reset synchronisation ; skip_starting_melody &112c a2 0b LDX #&0b ; write_mode_two_cursor_off_loop # Change to MODE 2, turn cursor off &112e bd ad 0e LDA &0ead,X ; mode_two_cursor_off_string &1131 20 ee ff JSR &ffee ; OSWRCH &1134 ca DEX &1135 10 f7 BPL &112e ; write_mode_two_cursor_off_loop &1137 a2 03 LDX #&03 &1139 86 64 STX &64 ; player_lives # Player starts with three lives &113b a2 01 LDX #&01 &113d 86 67 STX &67 ; level # on level 1 &113f ca DEX &1140 86 25 STX &25 ; stage # on stage 25m &1142 86 60 STX &60 ; score_one &1144 86 61 STX &61 ; score_two &1146 86 62 STX &62 ; score_three &1148 a9 0b LDA #&0b ; Auto Repeat Delay &114a 20 f4 ff JSR &fff4 ; OSBYTE ; start_stage_with_how_high_can_you_try &114d 20 a9 1b JSR &1ba9 ; how_high_can_you_try_screen # Display "How high can you try?" screen ; start_stage &1150 a6 25 LDX &25 ; stage &1152 bd 07 0e LDA &0e07,X ; plot_stage_routines_low &1155 85 80 STA &80 ; plot_stage_routine_low &1157 bd 17 0e LDA &0e17,X ; plot_stage_routines_high &115a 85 81 STA &81 ; plot_stage_routine_high &115c bd 0b 0e LDA &0e0b,X ; check_for_platform_routines_low &115f 85 30 STA &30 ; check_for_platform_routine_low &1161 bd 1b 0e LDA &0e1b,X ; check_for_platform_routines_high &1164 85 31 STA &31 ; check_for_platform_routine_high &1166 bd 0f 0e LDA &0e0f,X ; calculate_platform_y_routines_low &1169 85 32 STA &32 ; calculate_platform_y_routine_low &116b bd 1f 0e LDA &0e1f,X ; calculate_platform_y_routines_high &116e 85 33 STA &33 ; calculate_platform_y_routine_high &1170 bd 13 0e LDA &0e13,X ; update_enemies_routines_low &1173 85 34 STA &34 ; update_enemies_routine_low &1175 bd 23 0e LDA &0e23,X ; update_enemies_routines_high &1178 85 35 STA &35 ; update_enemies_routine_high &117a a9 00 LDA #&00 &117c 85 22 STA &22 ; number_of_collectibles &117e 85 28 STA &28 ; player_walking_sound_timer &1180 20 d7 19 JSR &19d7 ; plot_stage # Plot level ; game_loop_resetting_jump_and_buffer &1183 a9 00 LDA #&00 &1185 85 56 STA &56 ; player_platform_offset # Player isn't climbing a ladder &1187 85 58 STA &58 ; player_jump_timer # or jumping &1189 20 0b 1b JSR &1b0b ; plot_player_depending_on_state &118c a9 0f LDA #&0f ; Flush input buffer &118e a2 01 LDX #&01 &1190 20 f4 ff JSR &fff4 ; OSBYTE ; game_loop &1193 20 c6 13 JSR &13c6 ; update_game_with_bonus_countdown &1196 a9 81 LDA #&81 ; Read key with time limit &1198 a2 00 LDX #&00 &119a a0 00 LDY #&00 &119c 20 f4 ff JSR &fff4 ; OSBYTE &119f e0 0d CPX #&0d ; RETURN # Did the player press RETURN? &11a1 f0 0d BEQ &11b0 ; player_pressed_return &11a3 a5 2a LDA &2a ; use_joystick_input # A = &80, Read I/O device or buffer status for joystick &11a5 f0 19 BEQ &11c0 ; not_jumping &11a7 a2 00 LDX #&00 &11a9 20 f4 ff JSR &fff4 ; OSBYTE &11ac 8a TXA &11ad 4a LSR A &11ae 90 10 BCC &11c0 ; not_jumping # or press fire? ; player_pressed_return &11b0 a5 63 LDA &63 ; hammer_countdown &11b2 d0 0c BNE &11c0 ; not_jumping # If so, and the player isn't wielding an hammer, &11b4 20 3f 13 JSR &133f ; start_jump # start a jump &11b7 a5 52 LDA &52 ; player_feet &11b9 49 04 EOR #&04 &11bb 85 52 STA &52 ; player_feet &11bd 4c 83 11 JMP &1183 ; game_loop_resetting_jump_and_buffer ; not_jumping &11c0 a5 2a LDA &2a ; use_joystick_input # A = &80, Read I/O device or buffer status for joystick &11c2 f0 0f BEQ &11d3 ; check_keyboard_for_left_or_right &11c4 a2 01 LDX #&01 &11c6 20 f4 ff JSR &fff4 ; OSBYTE &11c9 c0 d0 CPY #&d0 &11cb b0 0d BCS &11da ; joystick_left # Move left if the joystick is to the left &11cd c0 02 CPY #&02 &11cf b0 1c BCS &11ed ; not_pressed_right &11d1 90 14 BCC &11e7 ; joystick_right # and right if the joystick is to the right ; check_keyboard_for_left_or_right &11d3 a2 9e LDX #&9e ; Z &11d5 20 1d 1a JSR &1a1d ; check_for_keypress &11d8 d0 06 BNE &11e0 ; not_pressed_left ; joystick_left &11da 20 ed 12 JSR &12ed ; move_player_left # Move left if the player pressed Z &11dd 4c 93 11 JMP &1193 ; game_loop ; not_pressed_left &11e0 a2 bd LDX #&bd ; X &11e2 20 1d 1a JSR &1a1d ; check_for_keypress &11e5 d0 06 BNE &11ed ; not_pressed_right ; joystick_right &11e7 20 1d 13 JSR &131d ; move_player_right # Move right if the player pressed X ; to_game_loop &11ea 4c 93 11 JMP &1193 ; game_loop ; not_pressed_right &11ed a9 00 LDA #&00 &11ef 85 5e STA &5e ; player_horizontal_speed &11f1 a5 63 LDA &63 ; hammer_countdown &11f3 d0 9e BNE &1193 ; game_loop # If the player isn't wielding an hammer, &11f5 a5 2a LDA &2a ; use_joystick_input # A = &80, Read I/O device or buffer status for joystick &11f7 f0 0f BEQ &1208 ; check_keyboard_for_up_or_down &11f9 a2 02 LDX #&02 &11fb 20 f4 ff JSR &fff4 ; OSBYTE &11fe c0 d0 CPY #&d0 &1200 b0 0d BCS &120f ; joystick_up # Climb up if joystick is up &1202 c0 02 CPY #&02 &1204 b0 e4 BCS &11ea ; to_game_loop &1206 90 2e BCC &1236 ; joystick_down # Climb down if joystick is down ; check_keyboard_for_up_or_down &1208 a2 b7 LDX #&b7 ; * &120a 20 1d 1a JSR &1a1d ; check_for_keypress &120d d0 20 BNE &122f ; not_pressed_up # Climb up if the player pressed * ; joystick_up &120f 20 af 1a JSR &1aaf ; check_player_x_y_for_ladder &1212 b0 d6 BCS &11ea ; to_game_loop # but only if there is a ladder on this platform &1214 86 6b STX &6b ; player_ladder_number &1216 84 6c STY &6c ; player_ladder_length &1218 20 0b 1b JSR &1b0b ; plot_player_depending_on_state # Unplot player &121b e6 51 INC &51 ; player_platform &121d a5 6b LDA &6b ; player_ladder_number &121f c9 21 CMP #&21 # Is this the fifth ladder from the left in stage 75m? &1221 d0 04 BNE &1227 ; skip_extra_platform_up &1223 e6 51 INC &51 ; player_platform # If so, it joins platform three and five &1225 e6 6b INC &6b ; player_ladder_number ; skip_extra_platform_up &1227 a4 6c LDY &6c ; player_ladder_length &1229 88 DEY &122a 88 DEY &122b 84 56 STY &56 ; player_platform_offset # Put the player just above the bottom of the ladder &122d d0 1b BNE &124a ; player_is_climbing_ladder ; not_pressed_up &122f a2 97 LDX #&97 ; ? &1231 20 1d 1a JSR &1a1d ; check_for_keypress &1234 d0 b4 BNE &11ea ; to_game_loop # Climb down if the player pressed ? ; joystick_down &1236 c6 51 DEC &51 ; player_platform &1238 20 af 1a JSR &1aaf ; check_player_x_y_for_ladder &123b e6 51 INC &51 ; player_platform &123d b0 ab BCS &11ea ; to_game_loop # but only if there is a ladder on the platform below &123f 86 6b STX &6b ; player_ladder_number &1241 84 6c STY &6c ; player_ladder_length &1243 20 0b 1b JSR &1b0b ; plot_player_depending_on_state # Unplot player &1246 a9 02 LDA #&02 &1248 85 56 STA &56 ; player_platform_offset # Put the player just below the top of the ladder ; player_is_climbing_ladder &124a a5 50 LDA &50 ; player_platform_x &124c 18 CLC &124d 69 02 ADC #&02 &124f 29 fc AND #&fc # Align the player horizontally with the ladder &1251 85 50 STA &50 ; player_platform_x &1253 20 0b 1b JSR &1b0b ; plot_player_depending_on_state # Replot the player ; climbing_game_loop # While on the ladder, use a different input loop &1256 20 c6 13 JSR &13c6 ; update_game_with_bonus_countdown &1259 a5 2a LDA &2a ; use_joystick_input # A = &80, Read I/O device or buffer status for joystick &125b f0 0f BEQ &126c ; skip_joystick &125d a2 02 LDX #&02 &125f 20 f4 ff JSR &fff4 ; OSBYTE &1262 c0 d0 CPY #&d0 &1264 b0 3e BCS &12a4 ; player_pressed_up_on_ladder # Climb up if the joystick is up &1266 c0 02 CPY #&02 &1268 b0 ec BCS &1256 ; climbing_game_loop &126a 90 0e BCC &127a ; player_pressed_down_on_ladder # Climb down if the joystick is down ; skip_joystick &126c a2 b7 LDX #&b7 ; * &126e 20 1d 1a JSR &1a1d ; check_for_keypress &1271 f0 31 BEQ &12a4 ; player_pressed_up_on_ladder # Climb up if the player pressed * &1273 a2 97 LDX #&97 ; ? &1275 20 1d 1a JSR &1a1d ; check_for_keypress &1278 d0 dc BNE &1256 ; climbing_game_loop # Climb down if the player pressed ? ; player_pressed_down_on_ladder &127a a5 6b LDA &6b ; player_ladder_number &127c c9 05 CMP #&05 &127e b0 06 BCS &1286 ; not_a_ladder_with_a_hole_down # If the ladder has a hole, &1280 a5 56 LDA &56 ; player_platform_offset &1282 c9 10 CMP #&10 &1284 f0 d0 BEQ &1256 ; climbing_game_loop # stop the player climbing beyond it ; not_a_ladder_with_a_hole_down &1286 20 0b 1b JSR &1b0b ; plot_player_depending_on_state # Unplot player &1289 e6 56 INC &56 ; player_platform_offset &128b e6 56 INC &56 ; player_platform_offset # Climb up by two pixels &128d a5 56 LDA &56 ; player_platform_offset &128f c5 6c CMP &6c ; player_ladder_length &1291 d0 b7 BNE &124a ; player_is_climbing_ladder # Is the player at the top of the ladder? &1293 a5 6b LDA &6b ; player_ladder_number &1295 c9 22 CMP #&22 # Is this the fifth ladder from the left in stage 75m? &1297 d0 02 BNE &129b ; skip_extra_platform_down &1299 c6 51 DEC &51 ; player_platform # If so, it moves the player down two platforms ; skip_extra_platform_down &129b c6 51 DEC &51 ; player_platform &129d a9 02 LDA #&02 &129f 85 52 STA &52 ; player_feet &12a1 4c 83 11 JMP &1183 ; game_loop_resetting_jump_and_buffer # Return to the running game loop ; player_pressed_up_on_ladder &12a4 a6 6b LDX &6b ; player_ladder_number &12a6 e0 05 CPX #&05 &12a8 b0 06 BCS &12b0 ; not_a_ladder_with_a_hole_up # If the ladder has a hole, &12aa a5 56 LDA &56 ; player_platform_offset &12ac c9 18 CMP #&18 &12ae f0 a6 BEQ &1256 ; climbing_game_loop # stop the player climbing beyond it ; not_a_ladder_with_a_hole_up &12b0 e0 17 CPX #&17 &12b2 d0 05 BNE &12b9 ; not_left_ladder_on_stage_50m # Is this one of the top ladders on the 50m stage? &12b4 a5 68 LDA &68 ; left_ladder_top &12b6 4c bf 12 JMP &12bf ; not_left_ladder_on_stage_50m &12b9 e0 18 CPX #&18 &12bb d0 0b BNE &12c8 ; not_right_ladder_on_stage_50m &12bd a5 69 LDA &69 ; right_ladder_top ; consider_top_ladder_on_stage_50m &12bf 29 3f AND #&3f &12c1 18 CLC &12c2 69 07 ADC #&07 &12c4 c5 56 CMP &56 ; player_platform_offset &12c6 b0 8e BCS &1256 ; climbing_game_loop # Don't allow the player to climb beyond the top ; not_right_ladder_on_stage_50m &12c8 20 0b 1b JSR &1b0b ; plot_player_depending_on_state # Unplot the player &12cb c6 56 DEC &56 ; player_platform_offset &12cd c6 56 DEC &56 ; player_platform_offset # Climb down by two pixels &12cf a5 56 LDA &56 ; player_platform_offset &12d1 c9 08 CMP #&08 &12d3 90 03 BCC &12d8 ; player_has_reached_top_of_ladder &12d5 4c 4a 12 JMP &124a ; player_is_climbing_ladder ; player_has_reached_top_of_ladder # If the player has reached the top of the ladder, &12d8 a5 50 LDA &50 ; player_platform_x &12da c9 26 CMP #&26 &12dc a9 01 LDA #&01 &12de 2a ROL A &12df 85 52 STA &52 ; player_feet # make them face towards the centre of the screen &12e1 a5 6a LDA &6a ; top_platform &12e3 c5 51 CMP &51 ; player_platform &12e5 b0 03 BCS &12ea ; to_game_loop_resetting_jump_and_buffer # If the player has reached the top of the stage, &12e7 4c e3 17 JMP &17e3 ; complete_stage # complete it ; to_game_loop_resetting_jump_and_buffer &12ea 4c 83 11 JMP &1183 ; game_loop_resetting_jump_and_buffer # Otherwise, return to the running game loop ; move_player_left &12ed a6 50 LDX &50 ; player_platform_x &12ef f0 28 BEQ &1319 ; leave # Can't move left at edge of screen &12f1 a5 63 LDA &63 ; hammer_countdown &12f3 f0 04 BEQ &12f9 ; skip_hammer_check &12f5 e0 05 CPX #&05 &12f7 90 20 BCC &1319 ; leave # Or too close to edge while wielding hammer ; skip_hammer_check &12f9 20 e0 1d JSR &1de0 ; handle_player_walking_sound &12fc a9 ff LDA #&ff &12fe 85 5e STA &5e ; player_horizontal_speed &1300 20 0b 1b JSR &1b0b ; plot_player_depending_on_state # Unplot player &1303 c6 50 DEC &50 ; player_platform_x &1305 a5 52 LDA &52 ; player_feet &1307 09 01 ORA #&01 # Set the player facing left &1309 49 06 EOR #&06 # Alternate between FEET and FEET_2 &130b 85 52 STA &52 ; player_feet ; check_for_absence_of_platform_to_left &130d 20 e9 1c JSR &1ce9 ; check_player_x_y_for_platform &1310 90 08 BCC &131a ; to_plot_player_depending_on_state &1312 a5 51 LDA &51 ; player_platform # If the player has walked off the edge of a platform, &1314 d0 26 BNE &133c ; to_kill_player_with_fall # make them fall to their death, unless they are on &1316 4c 0e 1e JMP &1e0e ; kill_player_without_unplotting # platform zero, in which case, just kill them ; leave &1319 60 RTS ; to_plot_player_depending_on_state &131a 4c 0b 1b JMP &1b0b ; plot_player_depending_on_state # Replot player ; move_player_right &131d a6 50 LDX &50 ; player_platform_x &131f e0 4c CPX #&4c &1321 f0 f6 BEQ &1319 ; leave # Can't move right at edge of screen &1323 a9 01 LDA #&01 &1325 85 5e STA &5e ; player_horizontal_speed &1327 20 e0 1d JSR &1de0 ; handle_player_walking_sound &132a 20 0b 1b JSR &1b0b ; plot_player_depending_on_state # Unplot player &132d e6 50 INC &50 ; player_platform_x &132f a5 52 LDA &52 ; player_feet &1331 29 fe AND #&fe # Set the player facing right &1333 49 06 EOR #&06 # Alternate between FEET and FEET_2 &1335 85 52 STA &52 ; player_feet ; check_for_absence_of_platform_to_right &1337 20 e9 1c JSR &1ce9 ; check_player_x_y_for_platform &133a 90 de BCC &131a ; to_plot_player_depending_on_state ; to_kill_player_with_fall # If the player has walked off the edge of a platform, &133c 4c 16 1e JMP &1e16 ; kill_player_with_fall # make them fall to their death ; start_jump &133f a2 92 LDX #&92 &1341 a0 0f LDY #&0f ; &0f92 = sound_2 &1343 20 dc 18 JSR &18dc ; play_sound # Play sound for jumping &1346 20 0b 1b JSR &1b0b ; plot_player_depending_on_state # Unplot player &1349 a9 08 LDA #&08 &134b 85 58 STA &58 ; player_jump_timer &134d a5 52 LDA &52 ; player_feet &134f 29 01 AND #&01 &1351 09 06 ORA #&06 # Use FEET_3, in direction player is facing &1353 85 52 STA &52 ; player_feet &1355 20 0b 1b JSR &1b0b ; plot_player_depending_on_state # Plot player ; jumping_game_loop # Separate game loop while jumping &1358 20 c6 13 JSR &13c6 ; update_game_with_bonus_countdown &135b a5 5e LDA &5e ; player_horizontal_speed &135d f0 19 BEQ &1378 ; player_not_moving # If the player was running while jumping, &135f 20 0b 1b JSR &1b0b ; plot_player_depending_on_state # Unplot player &1362 a6 50 LDX &50 ; player_platform_x &1364 a5 5e LDA &5e ; player_horizontal_speed &1366 30 08 BMI &1370 ; player_moving_left &1368 e0 4c CPX #&4c &136a f0 09 BEQ &1375 ; replot_player # Can't move right at right edge of screen ; player_moving_right &136c e6 50 INC &50 ; player_platform_x # Keep them moving right &136e d0 05 BNE &1375 ; replot_player ; player_moving_left &1370 8a TXA &1371 f0 02 BEQ &1375 ; replot_player # Can't move left at left edge of screen &1373 c6 50 DEC &50 ; player_platform_x # Keep them moving left ; replot_player &1375 20 0b 1b JSR &1b0b ; plot_player_depending_on_state # Replot player ; player_not_moving &1378 a5 63 LDA &63 ; hammer_countdown &137a d0 36 BNE &13b2 ; continue_jump # If the player isn't already wielding an hammer, &137c a2 01 LDX #&01 ; check_hammers_loop # have they jumped into one? &137e bd 00 0d LDA &0d00,X ; hammers_x &1381 38 SEC &1382 e5 5a SBC &5a ; player_x &1384 c9 03 CMP #&03 &1386 90 04 BCC &138c ; within_range &1388 c9 fd CMP #&fd &138a 90 23 BCC &13af ; didn't_collect_hammer ; within_range &138c bd 02 0d LDA &0d02,X ; hammers_y &138f c5 51 CMP &51 ; player_platform &1391 d0 1c BNE &13af ; didn't_collect_hammer &1393 a8 TAY &1394 bd 00 0d LDA &0d00,X ; hammers_x &1397 09 80 ORA #&80 # If so, mark the hammer as collected &1399 9d 00 0d STA &0d00,X ; hammers_x &139c 29 7f AND #&7f &139e aa TAX &139f 20 9c 1b JSR &1b9c ; plot_hammer # and unplot it &13a2 20 0b 1b JSR &1b0b ; plot_player_depending_on_state # Unplot player, without hammer &13a5 a9 aa LDA #&aa # Hammers last 110 frames &13a7 85 63 STA &63 ; hammer_countdown &13a9 20 0b 1b JSR &1b0b ; plot_player_depending_on_state # Replot player, with hammer &13ac 4c b2 13 JMP &13b2 ; continue_jump ; didn't_collect_hammer &13af ca DEX &13b0 10 cc BPL &137e ; check_hammers_loop ; continue_jump &13b2 c6 58 DEC &58 ; player_jump_timer &13b4 d0 a2 BNE &1358 ; jumping_game_loop &13b6 e6 58 INC &58 ; player_jump_timer &13b8 20 0b 1b JSR &1b0b ; plot_player_depending_on_state # Unplot player in jumping state &13bb c6 58 DEC &58 ; player_jump_timer &13bd 20 e9 1c JSR &1ce9 ; check_player_x_y_for_platform &13c0 b0 01 BCS &13c3 ; to_kill_player_with_fall # Kill the player if they jumped off a platform &13c2 60 RTS ; to_kill_player_with_fall &13c3 4c 16 1e JMP &1e16 ; kill_player_with_fall ; update_game_with_bonus_countdown &13c6 a9 40 LDA #&40 &13c8 8d 6b fe STA &fe6b ; Auxiliary control register &13cb a5 67 LDA &67 ; level &13cd 0a ASL A &13ce 0a ASL A &13cf 0a ASL A &13d0 0a ASL A &13d1 85 80 STA &80 ; speed &13d3 a9 ff LDA #&ff # Set interrupt based on speed &13d5 8d 66 fe STA &fe66 ; User VIA Timer 1 latch LSB &13d8 38 SEC &13d9 e5 80 SBC &80 ; speed &13db 8d 67 fe STA &fe67 ; User VIA Timer 1 latch MSB &13de 8d 65 fe STA &fe65 ; User VIA Timer 1 latch/counter MSB &13e1 c6 66 DEC &66 ; bonus_fraction &13e3 d0 19 BNE &13fe ; update_game &13e5 a5 65 LDA &65 ; bonus_hundreds # Decrease the bonus by 100 points ever 20 frames &13e7 f8 SED &13e8 38 SEC &13e9 e9 01 SBC #&01 &13eb 85 65 STA &65 ; bonus_hundreds &13ed d8 CLD &13ee 20 5a 1b JSR &1b5a ; write_bonus &13f1 a9 14 LDA #&14 &13f3 85 66 STA &66 ; bonus_fraction &13f5 a5 65 LDA &65 ; bonus_hundreds &13f7 05 59 ORA &59 ; player_has_died &13f9 d0 03 BNE &13fe ; update_game &13fb 4c 0b 1e JMP &1e0b ; kill_player # Kill the player when the bonus runs out ; update_game &13fe 20 f4 1d JSR &1df4 ; check_for_sound_keypresses &1401 e6 23 INC &23 ; frame_counter &1403 20 ad 14 JSR &14ad ; update_enemies &1406 a5 63 LDA &63 ; hammer_countdown &1408 f0 16 BEQ &1420 ; skip_hammer # If the player is wielding an hammer, &140a 29 03 AND #&03 &140c d0 0b BNE &1419 ; skip_updating_hammer &140e 20 9a 1d JSR &1d9a ; plot_player_hammer_offset # Every four frames, update its animation &1411 c6 63 DEC &63 ; hammer_countdown &1413 20 9a 1d JSR &1d9a ; plot_player_hammer_offset &1416 4c 20 14 JMP &1420 ; skip_hammer ; skip_updating_hammer &1419 c6 63 DEC &63 ; hammer_countdown &141b d0 03 BNE &1420 ; skip_hammer &141d 20 9a 1d JSR &1d9a ; plot_player_hammer_offset ; skip_hammer &1420 a6 22 LDX &22 ; number_of_collectibles &1422 f0 3d BEQ &1461 ; skip_collectible_check # If there are collectibles on the stage, &1424 a5 56 LDA &56 ; player_platform_offset &1426 05 58 ORA &58 ; player_jump_timer &1428 d0 37 BNE &1461 ; skip_collectible_check # and the player isn't climbing or jumping, ; check_collectibles_loop &142a bd 38 0e LDA &0e38,X ; collectibles_platform - 1 &142d c5 51 CMP &51 ; player_platform &142f d0 2d BNE &145e ; consider_next_collectible # check if the player is collecting one &1431 bd 34 0e LDA &0e34,X ; collectibles_x - 1 &1434 c5 50 CMP &50 ; player_platform_x &1436 d0 26 BNE &145e ; consider_next_collectible &1438 09 80 ORA #&80 # If so, mark it as collected &143a 9d 34 0e STA &0e34,X ; collectibles_x - 1 &143d bd 30 0e LDA &0e30,X ; collectibles_type_and_score &1440 48 PHA &1441 a6 50 LDX &50 ; player_platform_x &1443 a4 51 LDY &51 ; player_platform &1445 20 eb 19 JSR &19eb ; calculate_platform_y &1448 68 PLA &1449 48 PHA &144a 20 7f 1d JSR &1d7f ; plot_collectible # and unplot it &144d 68 PLA &144e 4a LSR A &144f 4a LSR A &1450 4a LSR A &1451 4a LSR A &1452 20 09 1d JSR &1d09 ; plot_small_hundreds &1455 20 6e 1b JSR &1b6e ; add_to_score # Score points for collecting collectible &1458 20 8b 16 JSR &168b ; play_sound_0 # Play sound for collecting collectible &145b 4c 61 14 JMP &1461 ; skip_collectible_check ; consider_next_collectible &145e ca DEX &145f d0 c9 BNE &142a ; check_collectibles_loop ; skip_collectible_check &1461 a5 26 LDA &26 ; help_countdown &1463 f0 07 BEQ &146c ; skip_deleting_help # If HELP! is displayed, &1465 c6 26 DEC &26 ; help_countdown &1467 d0 23 BNE &148c ; skip_deleting_help &1469 20 8b 1d JSR &1d8b ; delete_help # remove it when its timer runs out ; skip_deleting_help &146c a5 51 LDA &51 ; player_platform &146e c5 6a CMP &6a ; top_platform &1470 f0 1a BEQ &148c ; skip_writing_help # If the player hasn't reached the damsel, &1472 a5 59 LDA &59 ; player_has_died &1474 d0 16 BNE &148c ; skip_writing_help # and the player isn't dead, &1476 20 ff 19 JSR &19ff ; get_random_number &1479 29 7f AND #&7f &147b d0 0f BNE &148c ; skip_writing_help # then 1 in 128 chance of displaying HELP! &147d a2 08 LDX #&08 ; write_help_loop &147f bd b9 0e LDA &0eb9,X ; help_string &1482 20 ee ff JSR &ffee ; OSWRCH &1485 ca DEX &1486 10 f7 BPL &147f ; write_help_loop &1488 a9 1c LDA #&1c &148a 85 26 STA &26 ; help_countdown # for 28 frames ; skip_writing_help ; wait_for_via_timer # Wait for the timer interrupt to happen &148c a5 ff LDA &ff ; os_flags &148e 30 0b BMI &149b ; escape_pressed &1490 ad 6d fe LDA &fe6d ; User VIA interrupt flag register &1493 29 40 AND #&40 &1495 f0 f5 BEQ &148c ; wait_for_via_timer &1497 ad 64 fe LDA &fe64 ; Timer 1 latch/counter LSB # Return value unused &149a 60 RTS ; escape_pressed &149b 4c bd 1e JMP &1ebd ; high_score_screen # Immediately abandon game if ESCAPE pressed ; update_fireballs &149e a6 5f LDX &5f ; offset_of_last_fireball &14a0 e0 05 CPX #&05 &14a2 f0 08 BEQ &14ac ; leave # If there are any fireballs, ; update_fireballs_loop &14a4 20 b0 14 JSR &14b0 ; update_fireball # update each one in turn &14a7 ca DEX &14a8 e0 05 CPX #&05 &14aa d0 f8 BNE &14a4 ; update_fireballs_loop &14ac 60 RTS ; update_enemies &14ad 6c 34 00 JMP (&0034) ; update_enemies_routine ; update_fireball &14b0 20 c4 16 JSR &16c4 ; get_enemy_details_from_table &14b3 a5 54 LDA &54 ; enemy_x &14b5 29 7f AND #&7f &14b7 aa TAX &14b8 a4 55 LDY &55 ; enemy_platform &14ba 20 eb 19 JSR &19eb ; calculate_platform_y &14bd a5 57 LDA &57 ; enemy_platform_offset &14bf f0 45 BEQ &1506 ; fireball_not_on_ladder ; fireball_on_ladder # If the fireball is on a ladder, &14c1 29 7f AND #&7f # Top bit of platform_offset determines direction &14c3 85 80 STA &80 ; platform_offset &14c5 98 TYA &14c6 18 CLC &14c7 65 80 ADC &80 ; platform_offset &14c9 a8 TAY &14ca a9 16 LDA #&16 ; FIREBALL &14cc 20 22 19 JSR &1922 ; plot_single_height_sprite # Unplot fireball &14cf a5 57 LDA &57 ; enemy_platform_offset &14d1 30 09 BMI &14dc ; fireball_moving_up_ladder # Top bit of platform_offset set if moving down ladder ; fireball_moving_up_ladder &14d3 c6 57 DEC &57 ; enemy_platform_offset # If moving up ladder, move up two pixels &14d5 c6 57 DEC &57 ; enemy_platform_offset &14d7 88 DEY &14d8 88 DEY ; to_plot_fireball &14d9 4c 95 15 JMP &1595 ; plot_fireball # and replot fireball ; fireball_moving_down_ladder &14dc e6 57 INC &57 ; enemy_platform_offset # If moving down ladder, move down two pixels &14de e6 57 INC &57 ; enemy_platform_offset &14e0 c8 INY &14e1 c8 INY &14e2 98 TYA &14e3 48 PHA &14e4 a4 55 LDY &55 ; enemy_platform &14e6 88 DEY &14e7 20 b3 1a JSR &1ab3 ; check_x_y_for_ladder # Find the length of the ladder, returned in Y &14ea a5 54 LDA &54 ; enemy_x &14ec 29 7f AND #&7f &14ee aa TAX &14ef 84 80 STY &80 ; length_of_ladder &14f1 68 PLA &14f2 a8 TAY &14f3 a5 57 LDA &57 ; enemy_platform_offset &14f5 29 7f AND #&7f &14f7 c5 80 CMP &80 ; length_of_ladder &14f9 90 de BCC &14d9 ; to_plot_fireball # If the fireball has reached the bottom of the ladder, &14fb c6 55 DEC &55 ; enemy_platform &14fd a9 00 LDA #&00 # put it on the lower platform &14ff 85 57 STA &57 ; enemy_platform_offset &1501 a4 55 LDY &55 ; enemy_platform &1503 4c 92 15 JMP &1592 ; plot_fireball_after_calculating_y # and replot it ; fireball_not_on_ladder &1506 a9 16 LDA #&16 ; FIREBALL # If the fireball isn't on a ladder, &1508 20 22 19 JSR &1922 ; plot_single_height_sprite # Unplot it &150b e6 54 INC &54 ; enemy_x &150d a5 54 LDA &54 ; enemy_x &150f 10 04 BPL &1515 ; fireball_not_moving_left # Top bit of enemy_x set if moving right &1511 c6 54 DEC &54 ; enemy_x &1513 c6 54 DEC &54 ; enemy_x ; fireball_not_moving_left &1515 a4 55 LDY &55 ; enemy_platform &1517 20 ed 1c JSR &1ced ; check_x_y_for_platform &151a b0 1f BCS &153b ; keep_current_direction # Keep current direction if not on a platform &151c a5 54 LDA &54 ; enemy_x &151e 29 7f AND #&7f &1520 aa TAX &1521 f0 12 BEQ &1535 ; flip_fireball_direction # Change direction at the left edge of the screen &1523 e0 4c CPX #&4c &1525 f0 0e BEQ &1535 ; flip_fireball_direction # Change direction at the right edge of the screen &1527 a4 55 LDY &55 ; enemy_platform &1529 20 ed 1c JSR &1ced ; check_x_y_for_platform &152c b0 07 BCS &1535 ; flip_fireball_direction # Change direction at end of platform &152e 20 ff 19 JSR &19ff ; get_random_number &1531 29 1f AND #&1f &1533 d0 06 BNE &153b ; keep_current_direction # Change direction 1 in 32 times ; flip_fireball_direction &1535 a5 54 LDA &54 ; enemy_x &1537 49 80 EOR #&80 &1539 85 54 STA &54 ; enemy_x ; keep_current_direction &153b a5 54 LDA &54 ; enemy_x &153d 29 7f AND #&7f &153f aa TAX &1540 a4 55 LDY &55 ; enemy_platform &1542 a5 51 LDA &51 ; player_platform &1544 30 4c BMI &1592 ; skip_change_of_platform # Stay on same platform if player is riding lift &1546 c4 51 CPY &51 ; player_platform &1548 f0 48 BEQ &1592 ; skip_change_of_platform # Stay on same platform as player &154a b0 24 BCS &1570 ; consider_moving_down_a_platform &154c 20 b3 1a JSR &1ab3 ; check_x_y_for_ladder &154f b0 3a BCS &158b ; stay_on_same_platform # Stay on same platform if no ladder &1551 20 b0 15 JSR &15b0 ; probability_of_fireball_using_ladder &1554 b0 35 BCS &158b ; stay_on_same_platform &1556 88 DEY # Y is length of ladder from check_x_y_for_ladder &1557 88 DEY # so put fireball two pixels above bottom of ladder &1558 98 TYA &1559 48 PHA &155a 84 57 STY &57 ; enemy_platform_offset &155c e6 55 INC &55 ; enemy_platform # which is regarded as being on the platform above &155e a4 55 LDY &55 ; enemy_platform &1560 20 a3 15 JSR &15a3 ; align_enemy_with_ladder # Align fireball with ladder &1563 20 eb 19 JSR &19eb ; calculate_platform_y &1566 68 PLA &1567 85 80 STA &80 ; platform_offset &1569 98 TYA &156a 18 CLC &156b 65 80 ADC &80 ; platform_offset &156d a8 TAY &156e d0 25 BNE &1595 ; plot_fireball ; consider_moving_down_a_platform &1570 88 DEY &1571 20 b3 1a JSR &1ab3 ; check_x_y_for_ladder &1574 b0 15 BCS &158b ; stay_on_same_platform # Stay on same platform if no ladder &1576 20 b0 15 JSR &15b0 ; probability_of_fireball_using_ladder &1579 b0 10 BCS &158b ; stay_on_same_platform &157b a9 82 LDA #&82 # Put fireball two pixels below top of ladder, &157d 85 57 STA &57 ; enemy_platform_offset # top bit set to indicate moving down &157f 20 a3 15 JSR &15a3 ; align_enemy_with_ladder # Align fireball with ladder &1582 a4 55 LDY &55 ; enemy_platform &1584 20 eb 19 JSR &19eb ; calculate_platform_y &1587 c8 INY &1588 c8 INY &1589 d0 0a BNE &1595 ; plot_fireball ; stay_on_same_platform &158b a5 54 LDA &54 ; enemy_x &158d 29 7f AND #&7f &158f aa TAX &1590 a4 55 LDY &55 ; enemy_platform ; skip_change_of_platform ; plot_fireball_after_calculating_y &1592 20 eb 19 JSR &19eb ; calculate_platform_y ; plot_fireball &1595 a9 16 LDA #&16 ; FIREBALL &1597 20 9a 16 JSR &169a ; plot_enemy # Replot fireball ; get_enemy_details_and_check_for_collision_with_player &159a 20 d6 16 JSR &16d6 ; set_enemy_details_to_table # Store new position &159d 20 bc 15 JSR &15bc ; check_for_collision_with_player # Check if fireball has killed player &15a0 a6 86 LDX &86 ; enemy_offset &15a2 60 RTS ; align_enemy_with_ladder &15a3 a5 54 LDA &54 ; enemy_x &15a5 18 CLC &15a6 69 02 ADC #&02 &15a8 29 fc AND #&fc &15aa 85 54 STA &54 ; enemy_x &15ac 29 7f AND #&7f &15ae aa TAX &15af 60 RTS ; probability_of_fireball_using_ladder &15b0 a5 67 LDA &67 ; level &15b2 0a ASL A &15b3 0a ASL A &15b4 85 80 STA &80 ; chance &15b6 20 ff 19 JSR &19ff ; get_random_number &15b9 c5 80 CMP &80 ; chance # (level * 4) / 256 chance of fireball using ladder &15bb 60 RTS ; check_for_collision_with_player &15bc a5 63 LDA &63 ; hammer_countdown &15be f0 22 BEQ &15e2 ; not_hit_by_hammer # Is the player wielding an hammer? &15c0 29 04 AND #&04 &15c2 d0 1e BNE &15e2 ; not_hit_by_hammer # If so, is the hammer sideways, not up? &15c4 a5 57 LDA &57 ; enemy_platform_offset &15c6 05 58 ORA &58 ; player_jump_timer # If so, and the player isn't jumping, &15c8 d0 18 BNE &15e2 ; not_hit_by_hammer # and the enemy isn't moving vertically, &15ca a5 51 LDA &51 ; player_platform &15cc c5 55 CMP &55 ; enemy_platform &15ce d0 12 BNE &15e2 ; not_hit_by_hammer # Is the enemy on the same platform as the player? &15d0 a5 54 LDA &54 ; enemy_x &15d2 29 7f AND #&7f &15d4 38 SEC &15d5 e5 50 SBC &50 ; player_platform_x &15d7 48 PHA &15d8 a5 52 LDA &52 ; player_feet &15da 4a LSR A &15db b0 08 BCS &15e5 ; player_facing_left ; player_facing_right &15dd 68 PLA &15de c9 06 CMP #&06 &15e0 90 08 BCC &15ea ; enemy_hit_by_hammer # If so, is the barrel within range of the hammer? ; not_hit_by_hammer &15e2 4c 4f 16 JMP &164f ; check_for_deadly_collision_with_player ; player_facing_left &15e5 68 PLA &15e6 c9 f9 CMP #&f9 &15e8 90 f8 BCC &15e2 ; not_hit_by_hammer ; enemy_hit_by_hammer &15ea a5 54 LDA &54 ; enemy_x &15ec 29 7f AND #&7f &15ee aa TAX &15ef a4 55 LDY &55 ; enemy_platform &15f1 20 eb 19 JSR &19eb ; calculate_platform_y &15f4 a9 16 LDA #&16 ; FIREBALL &15f6 85 80 STA &80 ; enemy_sprite &15f8 a5 86 LDA &86 ; enemy_offset &15fa c9 06 CMP #&06 &15fc b0 0e BCS &160c ; unplot_enemy &15fe a9 14 LDA #&14 ; BARREL_SIDE &1600 85 80 STA &80 ; enemy_sprite &1602 a5 25 LDA &25 ; stage &1604 c9 01 CMP #&01 &1606 d0 04 BNE &160c ; unplot_enemy &1608 a9 1b LDA #&1b ; PIE &160a 85 80 STA &80 ; enemy_sprite ; unplot_enemy &160c a5 80 LDA &80 ; enemy_sprite &160e 20 22 19 JSR &1922 ; plot_single_height_sprite # Unplot enemy &1611 a9 1a LDA #&1a ; SMASHED &1613 20 22 19 JSR &1922 ; plot_single_height_sprite # Plot smashed enemy &1616 86 54 STX &54 ; enemy_x &1618 84 55 STY &55 ; enemy_platform ; three_to_eight &161a 20 ff 19 JSR &19ff ; get_random_number # Bonus randomly chosen between 300 and 800 &161d c9 03 CMP #&03 &161f 90 f9 BCC &161a ; three_to_eight &1621 c9 09 CMP #&09 &1623 b0 f5 BCS &161a ; three_to_eight &1625 48 PHA &1626 ca DEX &1627 ca DEX &1628 20 09 1d JSR &1d09 ; plot_small_hundreds # Plot bonus above smashed enemy &162b 20 6e 1b JSR &1b6e ; add_to_score # Add bonus to score &162e a9 52 LDA #&52 &1630 a0 05 LDY #&05 &1632 20 ce 1d JSR &1dce ; play_sound_with_pitch_and_duration # Play a sound for smashing &1635 20 8b 16 JSR &168b ; play_sound_0 &1638 a9 07 LDA #&07 &163a 20 da 19 JSR &19da ; delay_for_a &163d a6 54 LDX &54 ; enemy_x &163f a4 55 LDY &55 ; enemy_platform &1641 a9 1a LDA #&1a ; SMASHED &1643 20 22 19 JSR &1922 ; plot_single_height_spriteA # Unplot smashed enemy &1646 68 PLA ; score &1647 ca DEX &1648 ca DEX &1649 20 09 1d JSR &1d09 ; plot_small_hundreds # Unplot bonus &164c 4c a1 16 JMP &16a1 ; remove_enemy ; check_for_deadly_collision_with_player &164f a5 5a LDA &5a ; player_x &1651 38 SEC &1652 e5 5c SBC &5c ; collision_x &1654 aa TAX &1655 c9 03 CMP #&03 &1657 90 04 BCC &165d ; enemy_within_horizontal_range # Is the enemy within horizontal range of the player? &1659 c9 fe CMP #&fe &165b 90 3c BCC &1699 ; leave ; enemy_within_horizontal_range &165d a5 5b LDA &5b ; player_y &165f 38 SEC &1660 e5 5d SBC &5d ; collision_y &1662 c9 18 CMP #&18 &1664 90 2c BCC &1692 ; kill_player_if_not_already_dead # Is the enemy within vertical range of the player? &1666 c9 f7 CMP #&f7 &1668 b0 28 BCS &1692 ; kill_player_if_not_already_dead # If so, kill player &166a c9 f0 CMP #&f0 &166c 90 2b BCC &1699 ; leave &166e a5 58 LDA &58 ; player_jump_timer &1670 c9 02 CMP #&02 &1672 90 25 BCC &1699 ; leave # Is the player jumping? &1674 a4 5e LDY &5e ; player_horizontal_speed &1676 d0 04 BNE &167c ; player_jumping_sideways &1678 c9 04 CMP #&04 &167a 90 1d BCC &1699 ; leave # Need to jump higher if not moving sideways ; player_jumping_sideways &167c 98 TYA &167d f0 04 BEQ &1683 ; player_jumping_up &167f e0 01 CPX #&01 &1682 f0 03 BEQ &1686 ; player_jumping_up &1683 8a TXA &1684 d0 13 BNE &1699 ; leave # Is the player directly over the enemy? ; player_jumping_left &1686 a9 01 LDA #&01 &1688 20 6e 1b JSR &1b6e ; add_to_score # If so, score 100 points for jumping enemy ; play_sound_0 &168b a2 c6 LDX #&c6 &168d a0 0d LDY #&0d ; &0dc6 = sound_0 &168f 4c dc 18 JMP &18dc ; play_sound # Play sound for jumping enemy ; kill_player_if_not_already_dead &1692 a5 59 LDA &59 ; player_has_died &1694 d0 03 BNE &1699 ; leave &1696 4c 0b 1e JMP &1e0b ; kill_player ; leave &1699 60 RTS ; plot_enemy &169a 86 5c STX &5c ; collision_x &169c 84 5d STY &5d ; collision_y &169e 4c 22 19 JMP &1922 ; plot_single_height_sprite ; remove_enemy &16a1 a6 86 LDX &86 ; enemy_offset &16a3 c6 53 DEC &53 ; number_of_lower_enemies &16a5 a4 53 LDY &53 ; number_of_lower_enemies &16a7 e0 06 CPX #&06 &16a9 90 06 BCC &16b1 ; not_fireball &16ab e6 53 INC &53 ; number_of_lower_enemies &16ad c6 5f DEC &5f ; offset_of_last_fireball &16af a4 5f LDY &5f ; offset_of_last_fireball ; not_fireball &16b1 b9 04 0d LDA &0d04,Y ; enemies_x # Copy last enemy into vacated slot &16b4 9d 03 0d STA &0d03,X ; enemies_x - 1 &16b7 b9 0f 0d LDA &0d0f,Y ; enemies_platform &16ba 9d 0e 0d STA &0d0e,X ; enemies_platform - 1 &16bd b9 1a 0d LDA &0d1a,Y ; enemies_platform_offset &16c0 9d 19 0d STA &0d19,X ; enemies_platform_offset - 1 &16c3 60 RTS ; get_enemy_details_from_table &16c4 86 86 STX &86 ; enemy_offset &16c6 bd 03 0d LDA &0d03,X ; enemies_x - 1 &16c9 85 54 STA &54 ; enemy_x &16cb bd 0e 0d LDA &0d0e,X ; enemies_platform - 1 &16ce 85 55 STA &55 ; enemy_platform &16d0 bd 19 0d LDA &0d19,X ; enemies_platform_offset - 1 &16d3 85 57 STA &57 ; enemy_platform_offset &16d5 60 RTS ; set_enemy_details_to_table &16d6 a6 86 LDX &86 ; enemy_offset &16d8 a5 54 LDA &54 ; enemy_x &16da 9d 03 0d STA &0d03,X ; enemies_x - 1 &16dd a5 55 LDA &55 ; enemy_platform &16df 9d 0e 0d STA &0d0e,X ; enemies_platform - 1 &16e2 a5 57 LDA &57 ; enemy_platform_offset &16e4 9d 19 0d STA &0d19,X ; enemies_platform_offset - 1 &16e7 60 RTS ; update_75m_lift &16e8 20 c4 16 JSR &16c4 ; get_enemy_details_from_table &16eb a5 59 LDA &59 ; player_has_died &16ed d0 07 BNE &16f6 ; skip_lift_check &16ef a5 51 LDA &51 ; player_platform # Top bit set if player is riding lift &16f1 38 SEC &16f2 e9 7a SBC #&7a &16f4 c5 86 CMP &86 ; enemy_offset ; skip_lift_check &16f6 08 PHP &16f7 d0 03 BNE &16fc ; player_not_riding_this_lift # Is the player riding this lift? &16f9 20 0b 1b JSR &1b0b ; plot_player_depending_on_state # If so, unplot player ; player_not_riding_this_lift &16fc 20 15 17 JSR &1715 ; update_lift &16ff 28 PLP &1700 d0 0f BNE &1711 ; leave # If the player is riding this lift, &1702 20 0b 1b JSR &1b0b ; plot_player_depending_on_state # Replot player &1705 a6 86 LDX &86 ; enemy_offset &1707 a5 55 LDA &55 ; enemy_platform &1709 c9 54 CMP #&54 &170b f0 05 BEQ &1712 ; to_kill_player # Kill player at top of lift column &170d c9 ec CMP #&ec &170f f0 01 BEQ &1712 ; to_kill_player # Kill player at bottom of lift column ; leave &1711 60 RTS ; to_kill_player &1712 4c 0b 1e JMP &1e0b ; kill_player ; update_lift &1715 a4 55 LDY &55 ; enemy_platform # Actually enemy_y for stage 75m lifts &1717 a5 54 LDA &54 ; enemy_x # Actually 0 for left lift, 1 for right lift &1719 d0 15 BNE &1730 ; right_lift ; left_lift &171b a2 0a LDX #&0a &171d a9 28 LDA #&28 ; LIFT &171f 20 22 19 JSR &1922 ; plot_single_height_sprite # Unplot lift &1722 c0 3c CPY #&3c &1724 f0 1f BEQ &1745 ; move_lift_to_right_side &1726 88 DEY # Move left lift up one pixel per frame &1727 a5 67 LDA &67 ; level &1729 c9 03 CMP #&03 &172b 90 24 BCC &1751 ; store_lift_height_and_plot &172d 88 DEY # on levels one and two, two pixels per frame after &172e d0 21 BNE &1751 ; store_lift_height_and_plot ; right_lift &1730 a2 22 LDX #&22 &1732 a9 28 LDA #&28 ; LIFT &1734 20 22 19 JSR &1922 ; plot_single_height_sprite # Unplot lift &1737 c0 ec CPY #&ec &1739 f0 10 BEQ &174b ; move_lift_to_left_side &173b c8 INY # Move right lift down one pixel per frame &173c a5 67 LDA &67 ; level &173e c9 03 CMP #&03 &1740 90 0f BCC &1751 ; store_lift_height_and_plot &1742 c8 INY # on levels one and two, two pixels per frame after &1743 d0 0c BNE &1751 ; store_lift_height_and_plot ; move_lift_to_right_side # At the top of the left column, &1745 a2 22 LDX #&22 &1747 a9 01 LDA #&01 # move the lift to the right side (keeping height) &1749 d0 04 BNE &174f ; store_lift_side_height_and_plot ; move_lift_to_left_side # At the bottom of the right column, &174b a2 0a LDX #&0a &174d a9 00 LDA #&00 # move the lift to the left side (keeping height) ; store_lift_side_height_and_plot &174f 85 54 STA &54 ; enemy_x ; store_lift_height_and_plot &1751 84 55 STY &55 ; enemy_platform &1753 a9 28 LDA #&28 ; LIFT &1755 20 22 19 JSR &1922 ; plot_single_height_sprite # Replot lift &1758 20 d6 16 JSR &16d6 ; set_enemy_details_to_table &175b 60 RTS ; update_75m_girder &175c 20 c4 16 JSR &16c4 ; get_enemy_details_from_table &175f a5 54 LDA &54 ; enemy_x &1761 18 CLC &1762 65 57 ADC &57 ; enemy_platform_offset # Actually horizontal offset &1764 aa TAX &1765 a5 54 LDA &54 ; enemy_x &1767 c9 3c CMP #&3c &1769 b0 59 BCS &17c4 ; girder_in_free_fall # Is the girder bouncing? &176b 38 SEC ; find_modulo_twelve_loop # If so, find where it is in the bounce table &176c e9 0c SBC #&0c &176e b0 fc BCS &176c ; find_modulo_twelve_loop &1770 69 0c ADC #&0c &1772 4a LSR A &1773 a8 TAY &1774 48 PHA &1775 b9 56 0f LDA &0f56,Y ; stage_75m_girder_bounce &1778 a8 TAY &1779 a9 22 LDA #&22 ; GIRDER &177b 20 e6 18 JSR &18e6 ; plot_double_height_sprite # Unplot girder &177e 68 PLA &177f a8 TAY &1780 e8 INX # Move the girder four pixels to the right &1781 e8 INX &1782 e6 54 INC &54 ; enemy_x &1784 e6 54 INC &54 ; enemy_x &1786 c8 INY &1787 c0 06 CPY #&06 &1789 d0 1c BNE &17a7 ; update_girder_with_bounce_table # Play a sound every twelve frames &178b a5 59 LDA &59 ; player_has_died &178d d0 12 BNE &17a1 ; skip_girder_sound &178f a9 05 LDA #&05 ; girder_sound_instructions &1791 8d d1 0d STA &0dd1 ; sound_1_volume # also NOP # On OS 1.00, use envelope 1 for sound # also NOP # also NOP &1794 a9 47 LDA #&47 &1794 a9 47 LDA #&47 &1794 a9 47 LDA #&47 &1796 e0 3c CPX #&3c &1798 90 02 BCC &179c ; skip_floor &179a a9 3e LDA #&3e # Make the final note lower as the girder free falls ; skip_floor &179c a0 06 LDY #&06 &179e 20 ce 1d JSR &1dce ; play_sound_with_pitch_and_duration ; skip_girder_sound &17a1 a0 01 LDY #&01 # Use envelope 1 for future use of sound 1 &17a3 8c d1 0d STY &0dd1 ; sound_1_volume &17a6 88 DEY ; update_girder_with_bounce_table &17a7 b9 56 0f LDA &0f56,Y ; stage_75m_girder_bounce &17aa a8 TAY ; update_girder_with_x_y &17ab a9 22 LDA #&22 ; GIRDER &17ad 86 5c STX &5c ; collision_x &17af 84 5d STY &5d ; collision_y &17b1 20 e6 18 JSR &18e6 ; plot_double_height_sprite # Replot girder &17b4 20 d6 16 JSR &16d6 ; set_enemy_details_to_table &17b7 a5 5d LDA &5d ; collision_y &17b9 38 SEC &17ba e9 07 SBC #&07 &17bc 85 5d STA &5d ; collision_y &17be 20 bc 15 JSR &15bc ; check_for_collision_with_player &17c1 a6 86 LDX &86 ; enemy_offset &17c3 60 RTS ; girder_in_free_fall &17c4 a4 55 LDY &55 ; enemy_platform &17c6 a9 22 LDA #&22 ; GIRDER &17c8 20 e6 18 JSR &18e6 ; plot_double_height_sprite # Unplot girder &17cb 98 TYA &17cc 18 CLC &17cd 69 08 ADC #&08 &17cf 85 55 STA &55 ; enemy_platform # Move it eight pixels down &17d1 a8 TAY &17d2 c0 f2 CPY #&f2 &17d4 90 d5 BCC &17ab ; update_girder_with_x_y # Replot, unless it has reached the bottom of the screen &17d6 4c a1 16 JMP &16a1 ; remove_enemy ; plot_player &17d9 a6 50 LDX &50 ; player_platform_x &17db a4 51 LDY &51 ; player_platform &17dd 20 eb 19 JSR &19eb ; calculate_platform_y &17e0 4c 23 1b JMP &1b23 ; plot_player_at_x_y ; complete_stage &17e3 20 87 1d JSR &1d87 ; delete_help_if_present &17e6 a9 00 LDA #&00 &17e8 85 56 STA &56 ; player_platform_offset &17ea 20 0b 1b JSR &1b0b ; plot_player_depending_on_state # Plot player &17ed e6 59 INC &59 ; player_has_died # This merely disables further interaction with player &17ef a2 05 LDX #&05 ; write_heart_string_loop # Plot heart next to damsel &17f1 bd 25 0d LDA &0d25,X ; heart_string &17f4 20 ee ff JSR &ffee ; OSWRCH &17f7 ca DEX &17f8 10 f7 BPL &17f1 ; write_heart_string_loop &17fa 20 a7 18 JSR &18a7 ; play_stage_completion_melody # Play stage completion melody &17fd a6 25 LDX &25 ; stage &17ff ca DEX &1800 d0 06 BNE &1808 ; not_stage_50m &1802 20 dc 1c JSR &1cdc ; plot_gorilla_front # Unplot forward facing gorilla &1805 20 cc 1c JSR &1ccc ; plot_gorilla_side # Plot side facing gorilla ; not_stage_50m &1808 a2 0b LDX #&0b ; move_gorilla_right_loop &180a a0 23 LDY #&23 &180c a9 10 LDA #&10 ; GORILLA_SIDE_LEFT &180e 20 e6 18 JSR &18e6 ; plot_double_height_sprite # Unplot left half of gorilla &1811 e8 INX &1812 8a TXA &1813 48 PHA &1814 a9 10 LDA #&10 ; GORILLA_SIDE_LEFT &1816 20 e6 18 JSR &18e6 ; plot_double_height_sprite # Replot two pixels to the right &1819 e8 INX &181a e8 INX &181b e8 INX &181c a9 12 LDA #&12 ; GORILLA_SIDE_RIGHT &181e 20 e6 18 JSR &18e6 ; plot_double_height_sprite # Unplot right half of gorilla &1821 e8 INX &1822 a9 12 LDA #&12 ; GORILLA_SIDE_RIGHT &1824 20 e6 18 JSR &18e6 ; plot_double_height_sprite # Replot two pixels to the right &1827 20 fe 13 JSR &13fe ; update_game &182a 68 PLA &182b aa TAX &182c e0 1b CPX #&1b &182e d0 da BNE &180a ; move_gorilla_right_loop &1830 a0 23 LDY #&23 ; move_gorilla_up_loop &1832 a2 1b LDX #&1b &1834 a9 10 LDA #&10 ; GORILLA_SIDE_LEFT &1836 20 e6 18 JSR &18e6 ; plot_double_height_sprite # Unplot left half of gorilla &1839 88 DEY &183a a9 10 LDA #&10 ; GORILLA_SIDE_LEFT &183c 20 e6 18 JSR &18e6 ; plot_double_height_sprite # Replot one pixel above &183f c8 INY &1840 a2 1f LDX #&1f &1842 a9 12 LDA #&12 ; GORILLA_SIDE_RIGHT &1844 20 e6 18 JSR &18e6 ; plot_double_height_sprite # Unplot right half of gorilla &1847 88 DEY &1848 a9 12 LDA #&12 ; GORILLA_SIDE_RIGHT &184a 20 e6 18 JSR &18e6 ; plot_double_height_sprite # Replot one pixel above &184d 98 TYA &184e 48 PHA &184f 20 fe 13 JSR &13fe ; update_game &1852 68 PLA &1853 a8 TAY &1854 c0 0c CPY #&0c &1856 d0 da BNE &1832 ; move_gorilla_up_loop &1858 a9 7f LDA #&7f # Backspace over HEART &185a 20 ee ff JSR &ffee ; OSWRCH &185d a9 e3 LDA #&e3 ; HEART_BROKEN # and replace with HEART_BROKEN &185f 20 ee ff JSR &ffee ; OSWRCH &1862 a9 07 LDA #&07 ; W &1864 20 f0 1c JSR &1cf0 ; set_text_colour_a &1867 a5 65 LDA &65 ; bonus_hundreds # Add the bonus to the score &1869 20 6e 1b JSR &1b6e ; add_to_score &186c a2 32 LDX #&32 &186e 20 00 1b JSR &1b00 ; continue_to_update_game_for_x_frames &1871 a5 25 LDA &25 ; stage &1873 c9 02 CMP #&02 &1875 d0 23 BNE &189a ; advance_to_next_stage &1877 a5 67 LDA &67 ; level &1879 c9 01 CMP #&01 &187b d0 1d BNE &189a ; advance_to_next_stage &187d e6 64 INC &64 ; player_lives # Gain an extra life after first 75m stage &187f a5 64 LDA &64 ; player_lives &1881 0a ASL A &1882 0a ASL A &1883 38 SEC &1884 e9 08 SBC #&08 &1886 aa TAX &1887 a0 09 LDY #&09 &1889 a9 0f LDA #&0f ; PLAYER_LIFE &188b 20 22 19 JSR &1922 ; plot_single_height_sprite # Plot extra life &188e a9 c8 LDA #&c8 &1890 a0 06 LDY #&06 &1892 20 ce 1d JSR &1dce ; play_sound_with_pitch_and_duration # Play sound for gaining extra life &1895 a2 14 LDX #&14 &1897 20 00 1b JSR &1b00 ; continue_to_update_game_for_x_frames ; advance_to_next_stage &189a e6 25 INC &25 ; stage &189c a2 fd LDX #&fd &189e 9a TXS # Reset stack &189f a9 0c LDA #&0c ; CLS &18a1 20 ee ff JSR &ffee ; OSWRCH &18a4 4c 4d 11 JMP &114d ; start_stage_with_how_high_can_you_try ; play_stage_completion_melody &18a7 a2 07 LDX #&07 ; play_stage_completion_melody_loop &18a9 bd 79 0f LDA &0f79,X ; stage_completion_melody_notes_duration &18ac a8 TAY &18ad bd 71 0f LDA &0f71,X ; stage_completion_melody_notes_pitch &18b0 20 ce 1d JSR &1dce ; play_sound_with_pitch_and_duration &18b3 ca DEX &18b4 10 f3 BPL &18a9 ; play_stage_completion_melody_loop &18b6 a9 02 LDA #&02 &18b8 8d d0 0d STA &0dd0 ; sound_1_channel_high # Synchronise three channels &18bb a9 95 LDA #&95 &18bd a0 09 LDY #&09 &18bf 20 ce 1d JSR &1dce ; play_sound_with_pitch_and_duration # Play note as chord on channels 1 to 3 &18c2 ee cf 0d INC &0dcf ; sound_1_channel &18c5 a9 81 LDA #&81 &18c7 20 d1 1d JSR &1dd1 ; play_sound_with_pitch_and_previous_duration &18ca ee cf 0d INC &0dcf ; sound_1_channel &18cd a9 75 LDA #&75 &18cf 20 d1 1d JSR &1dd1 ; play_sound_with_pitch_and_previous_duration &18d2 a2 00 LDX #&00 &18d4 8e d0 0d STX &0dd0 ; sound_1_channel_high # Reset synchronisation &18d7 e8 INX &18d8 8e cf 0d STX &0dcf ; sound_1_channel &18db 60 RTS ; play_sound &18dc a5 29 LDA &29 ; sound_enabled &18de f0 05 BEQ &18e5 ; leave # Leave if sound disabled &18e0 a9 07 LDA #&07 ; Generate a sound &18e2 4c f1 ff JMP &fff1 ; OSWORD ; leave &18e5 60 RTS ; plot_double_height_sprite &18e6 48 PHA &18e7 98 TYA &18e8 38 SEC &18e9 e9 0c SBC #&0c # Offset vertically by 12 pixels &18eb a8 TAY &18ec a9 60 LDA #&60 # 96 bytes, 8 pixels wide, 24 pixels high &18ee 85 21 STA &21 ; sprite_size &18f0 a9 04 LDA #&04 &18f2 85 20 STA &20 ; sprite_width &18f4 68 PLA &18f5 20 2c 19 JSR &192c ; calculate_sprite_address &18f8 98 TYA &18f9 18 CLC &18fa 69 0c ADC #&0c # Undo offset &18fc a8 TAY &18fd 60 RTS ; plot_small_number &18fe 0a ASL A &18ff 48 PHA &1900 0a ASL A &1901 0a ASL A &1902 85 82 STA &82 ; sprite_address_low &1904 68 PLA &1905 18 CLC &1906 65 82 ADC &82 ; sprite_address_low &1908 18 CLC &1909 69 9c ADC #&9c &190b 85 82 STA &82 ; sprite_address_low &190d a9 2f LDA #&2f ; &2f9c = small_number_sprites &190f 85 83 STA &83 ; sprite_address_high &1911 a9 02 LDA #&02 &1913 85 20 STA &20 ; sprite_width &1915 a9 0a LDA #&0a &1917 85 21 STA &21 ; sprite_size &1919 d0 42 BNE &195d ; calculate_screen_address ; plot_single_height_sprite_with_offset &191b 48 PHA &191c 98 TYA &191d 38 SEC &191e e9 0c SBC #&0c &1920 a8 TAY &1921 68 PLA ; plot_single_height_sprite &1922 48 PHA &1923 a9 04 LDA #&04 &1925 85 20 STA &20 ; sprite_width &1927 a9 30 LDA #&30 # 48 bytes, 8 pixels wide, 12 pixels high &1929 85 21 STA &21 ; sprite_size &192b 68 PLA ; calculate_sprite_address &192c 48 PHA ; sprite &192d a9 00 LDA #&00 &192f 85 83 STA &83 ; sprite_address_high &1931 68 PLA &1932 48 PHA ; sprite &1933 0a ASL A &1934 85 80 STA &80 ; tmp &1936 0a ASL A &1937 65 80 ADC &80 ; tmp &1939 0a ASL A &193a 26 83 ROL &83 ; sprite_address_high &193c 0a ASL A &193d 26 83 ROL &83 ; sprite_address_high &193f 0a ASL A &1940 26 83 ROL &83 ; sprite_address_high &1942 85 82 STA &82 ; sprite_address_low &1944 a5 83 LDA &83 ; sprite_address_high &1946 18 CLC &1947 69 04 ADC #&04 ; &0400 = sprite_data_one # Sprites &00 - &14 are in sprite_data_one &1949 85 83 STA &83 ; sprite_address_high # Sprite x is at &0400 + 48 * x &194b 68 PLA &194c c9 15 CMP #&15 &194e 90 0d BCC &195d ; calculate_screen_address &1950 a5 82 LDA &82 ; sprite_address_low # Sprites &15 - &28 are in sprite_data_two &1952 18 CLC &1953 69 ec ADC #&ec &1955 85 82 STA &82 ; sprite_address_low &1957 a5 83 LDA &83 ; sprite_address_high &1959 69 23 ADC #&23 ; # &7f0 (&15 * 48) + &23ec = &2bdc (sprite_data_two) &195b 85 83 STA &83 ; sprite_address_high ; calculate_screen_address &195d a9 00 LDA #&00 &195f 85 81 STA &81 ; screen_address_high &1961 85 84 STA &84 ; tmp &1963 8a TXA &1964 0a ASL A &1965 0a ASL A &1966 26 81 ROL &81 ; screen_address_high &1968 0a ASL A &1969 26 81 ROL &81 ; screen_address_high &196b 85 80 STA &80 ; screen_address_low &196d 98 TYA &196e 4a LSR A &196f 4a LSR A &1970 4a LSR A &1971 48 PHA &1972 4a LSR A &1973 66 84 ROR &84 ; tmp &1975 18 CLC &1976 65 81 ADC &81 ; screen_address_high &1978 85 81 STA &81 ; screen_address_high &197a a5 80 LDA &80 ; screen_address_low &197c 18 CLC &197d 65 84 ADC &84 ; tmp &197f 85 80 STA &80 ; screen_address_low &1981 90 02 BCC &1985 &1983 e6 81 INC &81 ; screen_address_high &1985 68 PLA &1986 0a ASL A &1987 65 81 ADC &81 ; screen_address_high &1989 18 CLC &198a 69 30 ADC #&30 ; &3000 = start of screen memory &198c 85 81 STA &81 ; screen_address_high &198e 98 TYA &198f 48 PHA &1990 29 07 AND #&07 &1992 85 84 STA &84 ; screen_offset &1994 8a TXA &1995 48 PHA &1996 a9 00 LDA #&00 &1998 85 85 STA &85 ; sprite_offset ; plot_sprite_vertical_loop &199a a6 20 LDX &20 ; sprite_width &199c a5 84 LDA &84 ; screen_offset &199e 48 PHA ; plot_sprite_horizontal_loop &199f a4 85 LDY &85 ; sprite_offset &19a1 b1 82 LDA (&82),Y ; sprite_address &19a3 a4 84 LDY &84 ; screen_offset &19a5 51 80 EOR (&80),Y ; screen_address &19a7 91 80 STA (&80),Y ; screen_address &19a9 98 TYA &19aa 18 CLC &19ab 69 08 ADC #&08 &19ad 85 84 STA &84 ; screen_offset &19af e6 85 INC &85 ; sprite_offset &19b1 ca DEX &19b2 d0 eb BNE &199f ; plot_sprite_horizontal_loop &19b4 68 PLA ; screen_offset &19b5 a8 TAY &19b6 c8 INY &19b7 c0 08 CPY #&08 &19b9 d0 0f BNE &19ca ; plot_sprite_vertical_loop &19bb a5 80 LDA &80 ; screen_address_low &19bd 18 CLC &19be 69 80 ADC #&80 &19c0 85 80 STA &80 ; screen_address_low &19c2 a5 81 LDA &81 ; screen_address_high &19c4 69 02 ADC #&02 &19c6 85 81 STA &81 ; screen_address_high &19c8 a0 00 LDY #&00 &19ca 84 84 STY &84 ; screen_offset &19cc a5 85 LDA &85 ; sprite_offset &19ce c5 21 CMP &21 ; sprite_size &19d0 d0 c8 BNE &199a ; plot_sprite_vertical_loop &19d2 68 PLA &19d3 aa TAX &19d4 68 PLA &19d5 a8 TAY &19d6 60 RTS ; plot_stage &19d7 6c 80 00 JMP (&0080) ; plot_stage_routine ; delay_for_a &19da 85 80 STA &80 ; count &19dc a2 00 LDX #&00 &19de a0 00 LDY #&00 ; delay_for_a_loop &19e0 88 DEY &19e1 d0 fd BNE &19e0 ; delay_for_a_loop &19e3 ca DEX &19e4 d0 fa BNE &19e0 ; delay_for_a_loop &19e6 c6 80 DEC &80 ; count &19e8 d0 f6 BNE &19e0 ; delay_for_a_loop &19ea 60 RTS ; calculate_platform_y &19eb 98 TYA &19ec 30 0e BMI &19fc ; to_calculate_platform_y_routine # If not on a lift, &19ee a5 25 LDA &25 ; stage &19f0 4a LSR A &19f1 b0 09 BCS &19fc ; to_calculate_platform_y_routine # and not on 50m or 100m stage, &19f3 c4 6a CPY &6a ; top_platform &19f5 f0 05 BEQ &19fc ; to_calculate_platform_y_routine &19f7 90 03 BCC &19fc ; to_calculate_platform_y_routine &19f9 a0 0c LDY #&0c # return &0c for platform with damsel &19fb 60 RTS ; to_calculate_platform_y_routine &19fc 6c 32 00 JMP (&0032) ; calculate_platform_y_routine ; get_random_number &19ff 98 TYA &1a00 48 PHA &1a01 a0 20 LDY #&20 ; get_random_number_loop &1a03 a5 0f LDA &0f ; rnd_3 &1a05 4a LSR A &1a06 4a LSR A &1a07 4a LSR A &1a08 45 11 EOR &11 ; rnd_5 &1a0a 6a ROR A &1a0b 26 0d ROL &0d ; rnd_1 &1a0d 26 0e ROL &0e ; rnd_2 &1a0f 26 0f ROL &0f ; rnd_3 &1a11 26 10 ROL &10 ; rnd_4 &1a13 26 11 ROL &11 ; rnd_5 &1a15 88 DEY &1a16 d0 eb BNE &1a03 ; get_random_number_loop &1a18 68 PLA &1a19 a8 TAY &1a1a a5 0d LDA &0d ; rnd_1 &1a1c 60 RTS ; check_for_keypress &1a1d a0 ff LDY #&ff &1a1f a9 81 LDA #&81 ; Scan for a particular key &1a21 20 f4 ff JSR &fff4 ; OSBYTE &1a24 e0 ff CPX #&ff &1a26 60 RTS ; plot_stage_ladders &1a27 85 81 STA &81 ; ladder_length # Always called with A = 5 &1a29 a9 00 LDA #&00 &1a2b 85 83 STA &83 ; ladder_hole &1a2d a6 25 LDX &25 ; stage &1a2f bd 28 0e LDA &0e28,X ; ladder_data_offsets &1a32 85 82 STA &82 ; end_of_ladders &1a34 bd 29 0e LDA &0e29,X ; ladder_data_offsets + 1 &1a37 aa TAX ; plot_stage_ladders_loop &1a38 e0 04 CPX #&04 &1a3a d0 04 BNE &1a40 ; ladder_has_no_holes # Four ladders on stage 25m have holes &1a3c a9 02 LDA #&02 &1a3e 85 83 STA &83 ; ladder_hole ; ladder_has_no_holes &1a40 8a TXA &1a41 48 PHA &1a42 bd 60 0d LDA &0d60,X ; ladders_platform &1a45 a8 TAY &1a46 bd 2d 0d LDA &0d2d,X ; ladders_x &1a49 aa TAX &1a4a 20 55 1a JSR &1a55 ; plot_stage_ladder &1a4d 68 PLA &1a4e aa TAX &1a4f ca DEX &1a50 e4 82 CPX &82 ; end_of_ladders &1a52 d0 e4 BNE &1a38 ; plot_stage_ladders_loop &1a54 60 RTS ; plot_stage_ladder &1a55 a5 25 LDA &25 ; stage &1a57 f0 15 BEQ &1a6e ; calculate_ladder_start_25m &1a59 98 TYA # Y is ladder_platform &1a5a 0a ASL A &1a5b 85 80 STA &80 ; ladder_start &1a5d 0a ASL A &1a5e 18 CLC &1a5f 65 80 ADC &80 ; ladder_start &1a61 85 80 STA &80 ; ladder_start # ladder_start = &1c - (ladder_platform * 6) &1a63 a5 25 LDA &25 ; stage &1a65 4a LSR A &1a66 69 1c ADC #&1c &1a68 d0 10 BNE &1a7a ; invert_ladder_start ; unused # Unused code &1a6a a9 1e LDA #&1e &1a6c d0 0c BNE &1a7a ; invert_ladder_start ; calculate_ladder_start_25m &1a6e 98 TYA &1a6f 85 80 STA &80 ; ladder_start &1a71 0a ASL A &1a72 0a ASL A &1a73 18 CLC &1a74 65 80 ADC &80 ; ladder_start &1a76 85 80 STA &80 ; ladder_start &1a78 a9 1f LDA #&1f ; invert_ladder_start &1a7a 38 SEC &1a7b e5 80 SBC &80 ; ladder_start ; plot_ladder &1a7d 85 80 STA &80 ; ladder_start &1a7f a9 08 LDA #&08 &1a81 20 f0 1c JSR &1cf0 ; set_text_colour_a &1a84 a9 1f LDA #&1f # TAB(X, ladder_start) &1a86 20 ee ff JSR &ffee ; OSWRCH &1a89 8a TXA &1a8a 20 ee ff JSR &ffee ; OSWRCH &1a8d a5 80 LDA &80 ; ladder_start &1a8f 20 ee ff JSR &ffee ; OSWRCH &1a92 a6 81 LDX &81 ; ladder_length ; plot_ladder_loop &1a94 e4 83 CPX &83 ; ladder_hole &1a96 f0 0a BEQ &1aa2 ; skip_section_of_ladder &1a98 a9 e1 LDA #&e1 ; LADDER # Plot section of ladder &1a9a 20 ee ff JSR &ffee ; OSWRCH &1a9d a9 08 LDA #&08 # Backspace a character &1a9f 20 ee ff JSR &ffee ; OSWRCH ; skip_section_of_ladder &1aa2 a9 0b LDA #&0b # Move up a line &1aa4 20 ee ff JSR &ffee ; OSWRCH &1aa7 ca DEX &1aa8 d0 ea BNE &1a94 ; plot_ladder_loop &1aaa a9 05 LDA #&05 &1aac 4c f0 1c JMP &1cf0 ; set_text_colour_a ; check_player_x_y_for_ladder &1aaf a6 50 LDX &50 ; player_platform_x &1ab1 a4 51 LDY &51 ; player_platform ; check_x_y_for_ladder &1ab3 8a TXA &1ab4 18 CLC &1ab5 69 02 ADC #&02 &1ab7 4a LSR A &1ab8 4a LSR A &1ab9 38 SEC &1aba 85 80 STA &80 ; check_x &1abc c9 0b CMP #&0b &1abe d0 08 BNE &1ac8 ; not_damsel_ladder &1ac0 c0 05 CPY #&05 &1ac2 d0 04 BNE &1ac8 ; not_damsel_ladder &1ac4 a0 18 LDY #&18 # Damsel ladder is &18 long &1ac6 d0 36 BNE &1afe ; leave_with_carry_clear ; not_damsel_ladder &1ac8 a6 25 LDX &25 ; stage &1aca bd 28 0e LDA &0e28,X ; ladder_data_offsets &1acd 85 81 STA &81 ; start_of_ladders &1acf bd 29 0e LDA &0e29,X ; ladder_data_offsets + 1 &1ad2 aa TAX ; check_for_ladder_loop &1ad3 a5 80 LDA &80 ; check_x &1ad5 dd 2d 0d CMP &0d2d,X ; ladders_x &1ad8 d0 06 BNE &1ae0 ; consider_next_ladder &1ada 98 TYA &1adb dd 60 0d CMP &0d60,X ; ladders_platform &1ade f0 07 BEQ &1ae7 ; calculate_length_of_ladder ; consider_next_ladder &1ae0 ca DEX &1ae1 e4 81 CPX &81 ; start_of_ladders &1ae3 d0 ee BNE &1ad3 ; check_for_ladder_loop &1ae5 38 SEC # Leave with carry set to indicate no ladder &1ae6 60 RTS ; calculate_length_of_ladder &1ae7 a5 25 LDA &25 ; stage &1ae9 c9 02 CMP #&02 &1aeb d0 09 BNE &1af6 ; not_stage_75m &1aed bd 33 0f LDA &0f33,X ; stage_75m_ladders_lengths - &19 # Look up length of 75m ladders in table &1af0 0a ASL A &1af1 0a ASL A &1af2 0a ASL A &1af3 a8 TAY &1af4 18 CLC # Leave with carry clear to indicate ladder &1af5 60 RTS ; not_stage_75m &1af6 a0 28 LDY #&28 # Ladders on 25m stage are &28 long &1af8 a5 25 LDA &25 ; stage &1afa f0 02 BEQ &1afe ; leave_with_carry_clear &1afc a0 30 LDY #&30 # Ladders on 50m and 100m stage are &30 long ; leave_with_carry_clear &1afe 18 CLC # Leave with carry clear to indicate ladder &1aff 60 RTS ; continue_to_update_game_for_x_frames &1b00 8a TXA &1b01 48 PHA &1b02 20 fe 13 JSR &13fe ; update_game &1b05 68 PLA &1b06 aa TAX &1b07 ca DEX &1b08 d0 f6 BNE &1b00 ; continue_to_update_game_for_x_frames &1b0a 60 RTS ; plot_player_depending_on_state &1b0b a6 50 LDX &50 ; player_platform_x &1b0d a4 51 LDY &51 ; player_platform &1b0f 20 eb 19 JSR &19eb ; calculate_platform_y &1b12 a5 56 LDA &56 ; player_platform_offset &1b14 d0 2c BNE &1b42 ; plot_climbing_player &1b16 a5 59 LDA &59 ; player_has_died &1b18 d0 23 BNE &1b3d ; plot_dead_player &1b1a a5 58 LDA &58 ; player_jump_timer &1b1c f0 05 BEQ &1b23 ; plot_player_at_x_y &1b1e 98 TYA &1b1f 38 SEC &1b20 e9 0d SBC #&0d # Offset player by 13 pixels vertically when jumping &1b22 a8 TAY ; plot_player_at_x_y &1b23 a5 52 LDA &52 ; player_feet &1b25 86 5a STX &5a ; player_x &1b27 84 5b STY &5b ; player_y &1b29 20 22 19 JSR &1922 ; plot_single_height_sprite &1b2c a5 52 LDA &52 ; player_feet &1b2e 29 01 AND #&01 &1b30 20 1b 19 JSR &191b ; plot_single_height_sprite_with_offset &1b33 a5 63 LDA &63 ; hammer_countdown &1b35 f0 05 BEQ &1b3c ; leave &1b37 20 a2 1d JSR &1da2 ; plot_player_hammer &1b3a a6 50 LDX &50 ; player_platform_x ; leave &1b3c 60 RTS ; plot_dead_player &1b3d a9 17 LDA #&17 ; PLAYER_DEAD &1b3f 4c 22 19 JMP &1922 ; plot_single_height_sprite ; plot_climbing_player &1b42 29 f8 AND #&f8 &1b44 85 86 STA &86 ; ladder_offset &1b46 98 TYA &1b47 18 CLC &1b48 65 86 ADC &86 ; ladder_offset &1b4a a8 TAY &1b4b a5 56 LDA &56 ; player_platform_offset &1b4d 29 08 AND #&08 &1b4f 4a LSR A &1b50 4a LSR A &1b51 09 08 ORA #&08 &1b53 86 5a STX &5a ; player_x &1b55 84 5b STY &5b ; player_y &1b57 4c e6 18 JMP &18e6 ; plot_double_height_sprite ; write_bonus &1b5a a9 1f LDA #&1f &1b5c 20 ee ff JSR &ffee ; OSWRCH # TAB(&0e, &03) &1b5f a9 0e LDA #&0e &1b61 20 ee ff JSR &ffee ; OSWRCH &1b64 a9 03 LDA #&03 &1b66 20 ee ff JSR &ffee ; OSWRCH &1b69 a5 65 LDA &65 ; bonus_hundreds &1b6b 4c 8c 1b JMP &1b8c ; write_two_digit_number # Write top two digits of bonus ; add_to_score &1b6e f8 SED &1b6f 18 CLC &1b70 65 61 ADC &61 ; score_two &1b72 85 61 STA &61 ; score_two &1b74 a5 62 LDA &62 ; score_three &1b76 69 00 ADC #&00 &1b78 85 62 STA &62 ; score_three &1b7a d8 CLD ; write_score &1b7b a9 1e LDA #&1e ; HOME # Move cursor to top left &1b7d 20 ee ff JSR &ffee ; OSWRCH &1b80 a5 62 LDA &62 ; score_three &1b82 20 8c 1b JSR &1b8c ; write_two_digit_number &1b85 a5 61 LDA &61 ; score_two &1b87 20 8c 1b JSR &1b8c ; write_two_digit_number &1b8a a5 60 LDA &60 ; score_one ; write_two_digit_number &1b8c 48 PHA &1b8d 4a LSR A &1b8e 4a LSR A &1b8f 4a LSR A &1b90 4a LSR A &1b91 20 97 1b JSR &1b97 ; write_one_digit_number &1b94 68 PLA &1b95 29 0f AND #&0f ; write_one_digit_number &1b97 09 30 ORA #&30 &1b99 4c ee ff JMP &ffee ; OSWRCH ; plot_hammer &1b9c 20 eb 19 JSR &19eb ; calculate_platform_y &1b9f 98 TYA &1ba0 38 SEC &1ba1 e9 13 SBC #&13 &1ba3 a8 TAY &1ba4 a9 0e LDA #&0e ; HAMMER_UP &1ba6 4c 22 19 JMP &1922 ; plot_single_height_sprite ; how_high_can_you_try_screen &1ba9 a9 20 LDA #&20 &1bab 85 86 STA &86 ; gorilla_y &1bad a9 00 LDA #&00 &1baf 85 87 STA &87 ; height_low &1bb1 85 88 STA &88 ; height_high &1bb3 a6 25 LDX &25 ; stage &1bb5 bd 2d 0e LDA &0e2d,X ; top_platforms &1bb8 85 6a STA &6a ; top_platform ; plot_gorillas_loop # Plot a gorilla for each stage &1bba f8 SED &1bbb 18 CLC &1bbc a5 87 LDA &87 ; height_low &1bbe 69 25 ADC #&25 &1bc0 85 87 STA &87 ; height_low &1bc2 a5 88 LDA &88 ; height_high &1bc4 69 00 ADC #&00 &1bc6 85 88 STA &88 ; height_high &1bc8 d8 CLD &1bc9 a5 86 LDA &86 ; gorilla_y &1bcb 38 SEC &1bcc e9 04 SBC #&04 &1bce 85 86 STA &86 ; gorilla_y &1bd0 8a TXA &1bd1 48 PHA &1bd2 a2 00 LDX #&00 &1bd4 a5 86 LDA &86 ; gorilla_y &1bd6 0a ASL A &1bd7 0a ASL A &1bd8 0a ASL A &1bd9 18 CLC &1bda 69 03 ADC #&03 &1bdc a8 TAY &1bdd a9 24 LDA #&24 ; GORILLA_FRONT_LEFT # Plot gorilla &1bdf 20 e6 18 JSR &18e6 ; plot_double_height_sprite &1be2 a2 04 LDX #&04 &1be4 a9 26 LDA #&26 ; GORILLA_FRONT_RIGHT &1be6 20 e6 18 JSR &18e6 ; plot_double_height_sprite &1be9 a9 1f LDA #&1f # TAB(&04, gorilla_y) &1beb 20 ee ff JSR &ffee ; OSWRCH &1bee a9 04 LDA #&04 &1bf0 20 ee ff JSR &ffee ; OSWRCH &1bf3 a5 86 LDA &86 ; gorilla_y &1bf5 20 ee ff JSR &ffee ; OSWRCH &1bf8 a5 88 LDA &88 ; height_high &1bfa f0 0c BEQ &1c08 ; skip_hundreds &1bfc a9 08 LDA #&08 ; backspace &1bfe 20 ee ff JSR &ffee ; OSWRCH &1c01 a5 88 LDA &88 ; height_high &1c03 09 30 ORA #&30 ; "0" &1c05 20 ee ff JSR &ffee ; OSWRCH ; skip_hundreds &1c08 a5 87 LDA &87 ; height_low &1c0a 20 8c 1b JSR &1b8c ; write_two_digit_number # Write height &1c0d a9 6d LDA #&6d ; "m" &1c0f 20 ee ff JSR &ffee ; OSWRCH &1c12 68 PLA &1c13 aa TAX &1c14 ca DEX &1c15 10 a3 BPL &1bba ; plot_gorillas_loop &1c17 a2 19 LDX #&19 ; write_how_high_can_you_try_loop # Write "HOW HIGH CAN YOU TRY?" &1c19 bd ec 0d LDA &0dec,X ; how_high_can_you_try_string &1c1c 20 ee ff JSR &ffee ; OSWRCH &1c1f ca DEX &1c20 10 f7 BPL &1c19 ; write_how_high_can_you_try_loop &1c22 a2 09 LDX #&09 ; play_stage_melody_loop # Play stage melody &1c24 bd e2 0d LDA &0de2,X ; stage_melody_notes_duration &1c27 a8 TAY &1c28 bd d8 0d LDA &0dd8,X ; stage_melody_notes_pitch &1c2b 20 ce 1d JSR &1dce ; play_sound_with_pitch_and_duration &1c2e ca DEX &1c2f 10 f3 BPL &1c24 ; play_stage_melody_loop &1c31 a9 0f LDA #&0f &1c33 20 da 19 JSR &19da ; delay_for_a &1c36 a2 08 LDX #&08 &1c38 a0 00 LDY #&00 &1c3a 84 26 STY &26 ; help_countdown ; set_all_colours_to_black_loop # Set colours 0 to 8 to be logical colour 0 (black) &1c3c 20 39 1d JSR &1d39 ; define_logical_colour_x_as_y &1c3f ca DEX &1c40 d0 fa BNE &1c3c ; set_all_colours_to_black_loop &1c42 a2 15 LDX #&15 ; write_bonus_string # Write bonus and level text &1c44 bd 9b 0d LDA &0d9b,X ; bonus_string - 1 &1c47 20 ee ff JSR &ffee ; OSWRCH &1c4a ca DEX &1c4b d0 f7 BNE &1c44 ; write_bonus_string &1c4d 86 63 STX &63 ; hammer_countdown &1c4f a5 67 LDA &67 ; level &1c51 a2 2f LDX #&2f ; "0" - 1 ; find_tens_loop &1c53 e8 INX &1c54 38 SEC &1c55 e9 0a SBC #&0a &1c57 b0 fa BCS &1c53 ; find_tens_loop &1c59 48 PHA &1c5a 8a TXA &1c5b 20 ee ff JSR &ffee ; OSWRCH # Write high digit of level &1c5e 68 PLA &1c5f 18 CLC &1c60 69 3a ADC #&3a ; "0" + 10 &1c62 20 ee ff JSR &ffee ; OSWRCH # Write low digit of level &1c65 a6 64 LDX &64 ; player_lives &1c67 ca DEX &1c68 f0 13 BEQ &1c7d ; skip_plotting_lives &1c6a 86 86 STX &86 ; lives_to_plot &1c6c a2 00 LDX #&00 ; plot_lives_loop # Plot lives, if any &1c6e a0 09 LDY #&09 &1c70 a9 0f LDA #&0f ; PLAYER_LIFE &1c72 20 22 19 JSR &1922 ; plot_single_height_sprite &1c75 e8 INX &1c76 e8 INX &1c77 e8 INX &1c78 e8 INX &1c79 c6 86 DEC &86 ; lives_to_plot &1c7b d0 f1 BNE &1c6e ; plot_lives_loop ; skip_plotting_lives &1c7d a9 07 LDA #&07 &1c7f 20 f0 1c JSR &1cf0 ; set_text_colour_a &1c82 20 7b 1b JSR &1b7b ; write_score &1c85 a9 50 LDA #&50 # Initial stage bonus is 5000 &1c87 85 65 STA &65 ; bonus_hundreds &1c89 a9 14 LDA #&14 &1c8b 85 66 STA &66 ; bonus_fraction &1c8d 4c 5a 1b JMP &1b5a ; write_bonus ; plot_damsel_on_platform &1c90 a9 05 LDA #&05 ; ladder_start &1c92 85 81 STA &81 ; ladder_length &1c94 a2 07 LDX #&07 ; x &1c96 20 7d 1a JSR &1a7d ; plot_ladder # Plot a ladder at (&07, &05), length 5 &1c99 a2 05 LDX #&05 ; x &1c9b 8a TXA ; ladder_start &1c9c 20 7d 1a JSR &1a7d ; plot_ladder # Plot a ladder at (&05, &05), length 5 &1c9f a9 02 LDA #&02 &1ca1 85 81 STA &81 ; ladder_length &1ca3 a2 0b LDX #&0b ; x &1ca5 a9 05 LDA #&05 ; ladder_start &1ca7 20 7d 1a JSR &1a7d ; plot_ladder # Plot a ladder at (&0b, &05), length 2 &1caa a9 1f LDA #&1f &1cac 20 ee ff JSR &ffee ; OSWRCH # TAB(&08, &03) &1caf a9 08 LDA #&08 &1cb1 20 ee ff JSR &ffee ; OSWRCH &1cb4 a9 03 LDA #&03 &1cb6 20 ee ff JSR &ffee ; OSWRCH &1cb9 a9 e0 LDA #&e0 ; PLATFORM_GIRDER &1cbb a2 04 LDX #&04 ; plot_damsel_platform_loop # Plot a platform of length 4 &1cbd 20 ee ff JSR &ffee ; OSWRCH &1cc0 ca DEX &1cc1 d0 fa BNE &1cbd ; plot_damsel_platform_loop &1cc3 a2 24 LDX #&24 &1cc5 a0 0c LDY #&0c &1cc7 a9 20 LDA #&20 ; DAMSEL &1cc9 4c e6 18 JMP &18e6 ; plot_double_height_sprite # Plot damsel ; plot_gorilla_side &1ccc a2 0b LDX #&0b &1cce a9 10 LDA #&10 ; GORILLA_SIDE_LEFT &1cd0 20 d7 1c JSR &1cd7 ; to_plot_double_height_sprite &1cd3 a2 0f LDX #&0f &1cd5 a9 12 LDA #&12 ; GORILLA_SIDE_RIGHT ; to_plot_double_height_sprite &1cd7 a0 23 LDY #&23 &1cd9 4c e6 18 JMP &18e6 ; plot_double_height_sprite ; plot_gorilla_front &1cdc a2 0b LDX #&0b &1cde a9 24 LDA #&24 ; GORILLA_FRONT_LEFT &1ce0 20 d7 1c JSR &1cd7 ; to_plot_double_height_sprite &1ce3 a2 0f LDX #&0f &1ce5 a9 26 LDA #&26 ; GORILLA_FRONT_RIGHT &1ce7 d0 ee BNE &1cd7 ; to_plot_double_height_sprite ; check_player_x_y_for_platform &1ce9 a4 51 LDY &51 ; player_platform &1ceb a6 50 LDX &50 ; player_platform_x ; check_x_y_for_platform &1ced 6c 30 00 JMP (&0030) ; check_for_platform_routine ; set_text_colour_a &1cf0 48 PHA &1cf1 a9 11 LDA #&11 &1cf3 20 ee ff JSR &ffee ; OSWRCH &1cf6 68 PLA &1cf7 4c ee ff JMP &ffee ; OSWRCH ; set_graphics_colour_a &1cfa 48 PHA &1cfb a9 12 LDA #&12 &1cfd 20 ee ff JSR &ffee ; OSWRCH &1d00 a9 00 LDA #&00 &1d02 20 ee ff JSR &ffee ; OSWRCH &1d05 68 PLA &1d06 4c ee ff JMP &ffee ; OSWRCH ; plot_small_hundreds &1d09 48 PHA &1d0a 98 TYA &1d0b 38 SEC &1d0c e9 0c SBC #&0c &1d0e a8 TAY &1d0f 68 PLA &1d10 48 PHA &1d11 20 fe 18 JSR &18fe ; plot_small_number &1d14 e8 INX &1d15 e8 INX &1d16 a9 00 LDA #&00 &1d18 20 fe 18 JSR &18fe ; plot_small_number &1d1b e8 INX &1d1c e8 INX &1d1d a9 00 LDA #&00 &1d1f 20 fe 18 JSR &18fe ; plot_small_number &1d22 68 PLA &1d23 60 RTS ; make_stage_visible &1d24 a9 07 LDA #&07 &1d26 20 f0 1c JSR &1cf0 ; set_text_colour_a &1d29 a2 0f LDX #&0f ; set_all_colours_visible_loop # Set colours 0 to 15 to be 0 to 7 &1d2b 8a TXA &1d2c 29 07 AND #&07 &1d2e a8 TAY &1d2f 20 39 1d JSR &1d39 ; define_logical_colour_x_as_y &1d32 ca DEX &1d33 d0 f6 BNE &1d2b ; set_all_colours_visible_loop &1d35 a2 08 LDX #&08 # Set colour 8 to be 6 (cyan) &1d37 a0 06 LDY #&06 # allowing top bit to be set for ladders ; define_logical_colour_x_as_y &1d39 a9 13 LDA #&13 &1d3b 20 ee ff JSR &ffee ; OSWRCH &1d3e 8a TXA &1d3f 20 ee ff JSR &ffee ; OSWRCH &1d42 98 TYA &1d43 20 ee ff JSR &ffee ; OSWRCH &1d46 20 ee ff JSR &ffee ; OSWRCH &1d49 20 ee ff JSR &ffee ; OSWRCH &1d4c 4c ee ff JMP &ffee ; OSWRCH ; tab_to_zero_a_write_y_x_times &1d4f 48 PHA &1d50 a9 1f LDA #&1f &1d52 20 ee ff JSR &ffee ; OSWRCH &1d55 a9 00 LDA #&00 &1d57 20 ee ff JSR &ffee ; OSWRCH &1d5a 68 PLA &1d5b 20 ee ff JSR &ffee ; OSWRCH ; write_y_x_times &1d5e 98 TYA ; write_a_x_times &1d5f 20 ee ff JSR &ffee ; OSWRCH &1d62 ca DEX &1d63 d0 fa BNE &1d5f ; write_a_x_times &1d65 60 RTS ; add_collectible &1d66 48 PHA &1d67 86 80 STX &80 ; x &1d69 a6 22 LDX &22 ; number_of_collectibles &1d6b 9d 31 0e STA &0e31,X ; collectibles_type_and_score &1d6e a5 80 LDA &80 ; x &1d70 9d 35 0e STA &0e35,X ; collectibles_x &1d73 98 TYA &1d74 9d 39 0e STA &0e39,X ; collectibles_platform &1d77 a6 80 LDX &80 ; x &1d79 e6 22 INC &22 ; number_of_collectibles &1d7b 20 eb 19 JSR &19eb ; calculate_platform_y &1d7e 68 PLA ; collectible_type_and_score ; plot_collectible &1d7f 29 0f AND #&0f &1d81 18 CLC &1d82 69 1c ADC #&1c ; TELEPHONE &1d84 4c 22 19 JMP &1922 ; plot_single_height_sprite ; delete_help_if_present &1d87 a5 26 LDA &26 ; help_countdown &1d89 f0 0e BEQ &1d99 ; leave ; delete_help &1d8b a2 04 LDX #&04 ; write_delete_help_loop &1d8d bd c2 0e LDA &0ec2,X ; delete_help_string &1d90 20 ee ff JSR &ffee ; OSWRCH &1d93 ca DEX &1d94 10 f7 BPL &1d8d ; write_delete_help_loop &1d96 e8 INX &1d97 86 26 STX &26 ; help_countdown &1d99 60 RTS ; plot_player_hammer_offset &1d9a a6 5a LDX &5a ; player_x &1d9c a5 5b LDA &5b ; player_y &1d9e 38 SEC &1d9f e9 0c SBC #&0c &1da1 a8 TAY ; plot_player_hammer &1da2 a5 63 LDA &63 ; hammer_countdown &1da4 29 04 AND #&04 &1da6 f0 0a BEQ &1db2 ; hammer_is_to_the_side &1da8 98 TYA &1da9 38 SEC &1daa e9 06 SBC #&06 &1dac a8 TAY &1dad a9 0e LDA #&0e ; HAMMER_UP &1daf 4c 22 19 JMP &1922 ; plot_single_height_sprite ; hammer_is_to_the_side &1db2 e8 INX # Plot hammer eight pixels to right of player &1db3 e8 INX &1db4 e8 INX &1db5 e8 INX &1db6 a5 52 LDA &52 ; player_feet &1db8 4a LSR A &1db9 90 05 BCC &1dc0 ; player_facing_right &1dbb 8a TXA &1dbc 38 SEC &1dbd e9 08 SBC #&08 # or eight pixels to left &1dbf aa TAX ; player_facing_right &1dc0 98 TYA &1dc1 18 CLC &1dc2 69 06 ADC #&06 &1dc4 a8 TAY &1dc5 a5 52 LDA &52 ; player_feet &1dc7 29 01 AND #&01 &1dc9 09 0c ORA #&0c ; HAMMER_RIGHT &1dcb 4c 22 19 JMP &1922 ; plot_single_height_sprite ; play_sound_with_pitch_and_duration &1dce 8c d5 0d STY &0dd5 ; sound_1_duration ; play_sound_with_pitch_and_previous_duration &1dd1 8d d3 0d STA &0dd3 ; sound_1_pitch &1dd4 8a TXA &1dd5 48 PHA &1dd6 a2 cf LDX #&cf &1dd8 a0 0d LDY #&0d ; &0dcf = sound_1 &1dda 20 dc 18 JSR &18dc ; play_sound &1ddd 68 PLA &1dde aa TAX &1ddf 60 RTS ; handle_player_walking_sound &1de0 e6 28 INC &28 ; player_walking_sound_timer &1de2 a5 28 LDA &28 ; player_walking_sound_timer &1de4 c9 03 CMP #&03 &1de6 d0 0b BNE &1df3 ; leave # Play a sound every three steps &1de8 a9 00 LDA #&00 &1dea 85 28 STA &28 ; player_walking_sound_timer &1dec a2 68 LDX #&68 &1dee a0 0f LDY #&0f ; &0f68 = sound_3 &1df0 4c dc 18 JMP &18dc ; play_sound ; leave &1df3 60 RTS ; check_for_sound_keypresses &1df4 a2 ef LDX #&ef ; Q &1df6 20 1d 1a JSR &1a1d ; check_for_keypress &1df9 d0 04 BNE &1dff ; q_not_pressed &1dfb a9 00 LDA #&00 # Disable sound if the player pressed Q &1dfd 85 29 STA &29 ; sound_enabled ; q_not_pressed &1dff a2 ae LDX #&ae ; S &1e01 20 1d 1a JSR &1a1d ; check_for_keypress &1e04 d0 04 BNE &1e0a ; leave &1e06 a9 01 LDA #&01 # Enable sound if the player pressed S &1e08 85 29 STA &29 ; sound_enabled &1e0a 60 RTS ; kill_player &1e0b 20 0b 1b JSR &1b0b ; plot_player_depending_on_state # Unplot player ; kill_player_without_unplotting &1e0e a5 56 LDA &56 ; player_platform_offset &1e10 f0 32 BEQ &1e44 ; player_not_on_ladder # If the player is on a ladder, make them fall &1e12 a9 00 LDA #&00 &1e14 85 56 STA &56 ; player_platform_offset ; kill_player_with_fall &1e16 e6 59 INC &59 ; player_has_died &1e18 a4 51 LDY &51 ; player_platform ; find_lower_platform_loop # Find the height of the platform below them &1e1a c6 51 DEC &51 ; player_platform &1e1c 20 e9 1c JSR &1ce9 ; check_player_x_y_for_platform &1e1f b0 f9 BCS &1e1a ; find_lower_platform_loop &1e21 a6 50 LDX &50 ; player_platform_x &1e23 a4 51 LDY &51 ; player_platform &1e25 20 eb 19 JSR &19eb ; calculate_platform_y &1e28 84 58 STY &58 ; distance_to_fall &1e2a a5 5b LDA &5b ; player_y ; falling_loop # Animate the player falling &1e2c 48 PHA &1e2d a8 TAY &1e2e 20 23 1b JSR &1b23 ; plot_player_at_x_y # Plot player &1e31 20 c6 13 JSR &13c6 ; update_game_with_bonus_countdown &1e34 68 PLA &1e35 48 PHA &1e36 a8 TAY &1e37 a6 50 LDX &50 ; player_platform_x &1e39 20 23 1b JSR &1b23 ; plot_player_at_x_y # Unplot player &1e3c 68 PLA &1e3d 18 CLC &1e3e 69 06 ADC #&06 &1e40 c5 58 CMP &58 ; distance_to_fall &1e42 90 e8 BCC &1e2c ; falling_loop ; player_not_on_ladder &1e44 a9 00 LDA #&00 &1e46 85 58 STA &58 ; player_jump_timer &1e48 85 63 STA &63 ; hammer_countdown &1e4a e6 59 INC &59 ; player_has_died &1e4c a9 02 LDA #&02 &1e4e 85 52 STA &52 ; player_feet &1e50 20 d9 17 JSR &17d9 ; plot_player # Plot player &1e53 a9 11 LDA #&11 &1e55 85 5e STA &5e ; death_timer ; dying_loop # Play death melody &1e57 a6 5e LDX &5e ; death_timer &1e59 bd 80 0f LDA &0f80,X ; death_melody_notes - 1 &1e5c a0 03 LDY #&03 &1e5e 20 ce 1d JSR &1dce ; play_sound_with_pitch_and_duration &1e61 e0 08 CPX #&08 &1e63 d0 1f BNE &1e84 ; skip_inner_loop &1e65 a9 04 LDA #&04 &1e67 85 58 STA &58 ; player_jump_timer ; dying_inner_loop # Midway through, make the player alternate direction &1e69 20 d9 17 JSR &17d9 ; plot_player # Unplot player &1e6c a5 52 LDA &52 ; player_feet &1e6e 49 01 EOR #&01 # Alternate direction of player each frame &1e70 85 52 STA &52 ; player_feet &1e72 20 d9 17 JSR &17d9 ; plot_player # Plot player &1e75 a9 01 LDA #&01 &1e77 20 da 19 JSR &19da ; delay_for_a &1e7a c6 58 DEC &58 ; player_jump_timer &1e7c d0 eb BNE &1e69 ; dying_inner_loop &1e7e 20 d9 17 JSR &17d9 ; plot_player # Unplot player &1e81 20 0b 1b JSR &1b0b ; plot_player_depending_on_state # Plot dead player ; skip_inner_loop &1e84 c6 5e DEC &5e ; death_timer &1e86 d0 cf BNE &1e57 ; dying_loop &1e88 c6 64 DEC &64 ; player_lives &1e8a f0 13 BEQ &1e9f ; game_over # Game over if no more lives &1e8c a2 32 LDX #&32 &1e8e 20 00 1b JSR &1b00 ; continue_to_update_game_for_x_frames &1e91 a2 fd LDX #&fd &1e93 9a TXS # Otherwise, reset stack &1e94 a9 0c LDA #&0c # clear screen &1e96 20 ee ff JSR &ffee ; OSWRCH &1e99 20 a9 1b JSR &1ba9 ; how_high_can_you_try_screen &1e9c 4c 50 11 JMP &1150 ; start_stage # and start stage again ; game_over &1e9f 20 87 1d JSR &1d87 ; delete_help_if_present &1ea2 a2 00 LDX #&00 ; write_game_over_loop # Write "GAME OVER", character by character &1ea4 8a TXA &1ea5 48 PHA &1ea6 a2 05 LDX #&05 &1ea8 20 00 1b JSR &1b00 ; continue_to_update_game_for_x_frames &1eab 68 PLA &1eac aa TAX &1ead bd b2 0d LDA &0db2,X ; game_over_string &1eb0 20 ee ff JSR &ffee ; OSWRCH &1eb3 e8 INX &1eb4 c9 0d CMP #&0d &1eb6 d0 ec BNE &1ea4 ; write_game_over_loop &1eb8 a9 64 LDA #&64 &1eba 20 00 1b JSR &1b00 ; continue_to_update_game_for_x_frames ; high_score_screen &1ebd a9 7e LDA #&7e ; Acknowledge ESCAPE Condition &1ebf 20 f4 ff JSR &fff4 ; OSBYTE &1ec2 a2 fd LDX #&fd &1ec4 9a TXS # Reset stack &1ec5 a9 16 LDA #&16 &1ec7 20 ee ff JSR &ffee ; OSWRCH # MODE 7 &1eca a9 07 LDA #&07 &1ecc 20 ee ff JSR &ffee ; OSWRCH &1ecf a9 09 LDA #&09 &1ed1 a2 06 LDX #&06 &1ed3 20 5f 1d JSR &1d5f ; write_a_x_times # Move right six characters &1ed6 a9 94 LDA #&94 &1ed8 20 ee ff JSR &ffee ; OSWRCH # Blue graphics &1edb a9 70 LDA #&70 &1edd a2 19 LDX #&19 &1edf 20 5f 1d JSR &1d5f ; write_a_x_times # Write top of box &1ee2 20 e7 ff JSR &ffe7 ; OSNEWL &1ee5 a0 02 LDY #&02 ; write_double_height_text_loop &1ee7 a9 09 LDA #&09 &1ee9 a2 05 LDX #&05 &1eeb 20 5f 1d JSR &1d5f ; write_a_x_times # Move right five characters &1eee a2 1a LDX #&1a ; write_killer_gorilla_scores_loop # Write "KILLER GORILLA scores" and box sides &1ef0 bd e4 0f LDA &0fe4,X ; killer_gorilla_scores_string &1ef3 20 ee ff JSR &ffee ; OSWRCH &1ef6 ca DEX &1ef7 10 f7 BPL &1ef0 ; write_killer_gorilla_scores_loop &1ef9 20 e7 ff JSR &ffe7 ; OSNEWL &1efc 88 DEY &1efd d0 e8 BNE &1ee7 ; write_double_height_text_loop &1eff a9 09 LDA #&09 &1f01 a2 06 LDX #&06 &1f03 20 5f 1d JSR &1d5f ; write_a_x_times # Move right six characters &1f06 a9 94 LDA #&94 &1f08 20 ee ff JSR &ffee ; OSWRCH # Blue graphics &1f0b a9 60 LDA #&60 &1f0d a2 19 LDX #&19 &1f0f 20 5f 1d JSR &1d5f ; write_a_x_times # Write bottom of box &1f12 20 e7 ff JSR &ffe7 ; OSNEWL &1f15 a2 08 LDX #&08 # Starting from the bottom of the high scores, ; check_scores_loop &1f17 bd 99 10 LDA &1099,X ; high_scores_three - 1 &1f1a c5 62 CMP &62 ; score_three # is the player's score better than this position? &1f1c d0 0c BNE &1f2a ; check_this_digit &1f1e bd a1 10 LDA &10a1,X ; high_scores_two - 1 &1f21 c5 61 CMP &61 ; score_two &1f23 d0 05 BNE &1f2a ; check_this_digit &1f25 bd a9 10 LDA &10a9,X ; high_scores_one - 1 &1f28 c5 60 CMP &60 ; score_one ; check_this_digit &1f2a b0 30 BCS &1f5c ; players_score_is_higher &1f2c e0 08 CPX #&08 &1f2e f0 29 BEQ &1f59 ; check_next_score &1f30 bd 99 10 LDA &1099,X ; high_scores_three - 1 # Move score down a position &1f33 9d 9a 10 STA &109a,X ; high_scores_three &1f36 bd a1 10 LDA &10a1,X ; high_scores_two - 1 &1f39 9d a2 10 STA &10a2,X ; high_scores_two &1f3c bd a9 10 LDA &10a9,X ; high_scores_one - 1 &1f3f 9d aa 10 STA &10aa,X ; high_scores_one &1f42 86 80 STX &80 ; score &1f44 ca DEX # Calculate offset of name for this position &1f45 8a TXA &1f46 0a ASL A &1f47 0a ASL A &1f48 0a ASL A &1f49 0a ASL A &1f4a aa TAX &1f4b a0 10 LDY #&10 ; move_high_score_name_loop # Move name down a position &1f4d bd 19 10 LDA &1019,X ; high_score_names &1f50 9d 29 10 STA &1029,X ; high_score_names + 16 &1f53 e8 INX &1f54 88 DEY &1f55 d0 f6 BNE &1f4d ; move_high_score_name_loop &1f57 a6 80 LDX &80 ; score ; check_next_score &1f59 ca DEX &1f5a d0 bb BNE &1f17 ; check_scores_loop ; players_score_is_higher &1f5c e0 08 CPX #&08 &1f5e d0 06 BNE &1f66 ; new_high_score &1f60 20 22 20 JSR &2022 ; display_high_scores # If the player didn't beat the eighth place score, &1f63 4c eb 1f JMP &1feb ; finished_displaying_scores # just display the existing scores ; new_high_score &1f66 a5 60 LDA &60 ; score_one # Otherwise, put the player's score in the table &1f68 9d aa 10 STA &10aa,X ; high_scores_one &1f6b a5 61 LDA &61 ; score_two &1f6d 9d a2 10 STA &10a2,X ; high_scores_two &1f70 a5 62 LDA &62 ; score_three &1f72 9d 9a 10 STA &109a,X ; high_scores_three &1f75 8a TXA # Calculate address of name for this position &1f76 0a ASL A &1f77 48 PHA &1f78 0a ASL A &1f79 0a ASL A &1f7a 0a ASL A &1f7b aa TAX &1f7c 18 CLC &1f7d 69 19 ADC #&19 &1f7f 85 85 STA &85 ; name_address_low &1f81 a9 10 LDA #&10 ; &1019 = high_score_names &1f83 69 00 ADC #&00 &1f85 85 86 STA &86 ; name_address_high &1f87 a9 00 LDA #&00 # Set up input block: &1f89 85 80 STA &80 ; input_block + 0 # &0080 + 0..1 = buffer address (&3000) &1f8b a9 ff LDA #&ff # &0080 + 2 = maximum line length (&10) &1f8d 85 84 STA &84 ; input_block + 4 # &0080 + 3 = minimum acceptable character (&20) &1f8f a9 30 LDA #&30 ; &3000 = input_buffer # &0080 + 4 = minimum acceptable character (&ff) &1f91 85 81 STA &81 ; input_block + 1; &1f93 a9 10 LDA #&10 &1f95 a8 TAY &1f96 85 82 STA &82 ; input_block + 2; &1f98 0a ASL A &1f99 85 83 STA &83 ; input_block + 3 ; wipe_name_loop # Fill the name with spaces &1f9b 9d 19 10 STA &1019,X ; high_score_names &1f9e e8 INX &1f9f 88 DEY &1fa0 d0 f9 BNE &1f9b ; wipe_name_loop &1fa2 a9 09 LDA #&09 &1fa4 a2 07 LDX #&07 &1fa6 20 5f 1d JSR &1d5f ; write_a_x_times # Move right seven characters &1fa9 a2 17 LDX #&17 ; write_please_enter_your_name_loop # Write "Please enter your name" &1fab bd 00 10 LDA &1000,X ; please_enter_your_name_string &1fae 20 ee ff JSR &ffee ; OSWRCH &1fb1 ca DEX &1fb2 10 f7 BPL &1fab ; write_please_enter_your_name_loop &1fb4 20 22 20 JSR &2022 ; display_high_scores # Display existing high scores &1fb7 a9 1f LDA #&1f &1fb9 20 ee ff JSR &ffee ; OSWRCH # TAB(&12, position * 2 + &06) &1fbc a9 12 LDA #&12 &1fbe 20 ee ff JSR &ffee ; OSWRCH &1fc1 68 PLA ; position * 2 &1fc2 18 CLC &1fc3 69 06 ADC #&06 &1fc5 20 ee ff JSR &ffee ; OSWRCH &1fc8 a9 0f LDA #&0f ; Flush input buffer &1fca a2 01 LDX #&01 &1fcc 20 f4 ff JSR &fff4 ; OSBYTE &1fcf a2 80 LDX #&80 &1fd1 a0 00 LDY #&00 ; &0080 = input_block &1fd3 98 TYA ; Input line &1fd4 20 f1 ff JSR &fff1 ; OSWORD # Get name from player into input_buffer &1fd7 88 DEY &1fd8 30 07 BMI &1fe1 ; skip_copying_name # Copy name into high score table if not empty ; copy_name_loop &1fda b1 80 LDA (&80),Y ; input_buffer_address &1fdc 91 85 STA (&85),Y ; name_address &1fde 88 DEY &1fdf 10 f9 BPL &1fda ; copy_name_loop ; skip_copying_name &1fe1 a2 28 LDX #&28 &1fe3 a9 20 LDA #&20 ; " " ; wipe_please_enter_your_name_loop # Replace "Please enter your name" with spaces &1fe5 9d 9f 7c STA &7c9f,X ; screen memory + &9f &1fe8 ca DEX &1fe9 d0 fa BNE &1fe5 ; wipe_please_enter_your_name_loop ; finished_displaying_scores &1feb a2 0a LDX #&0a ; write_cursor_off_loop # Disable cursor &1fed bd ac 0e LDA &0eac,X ; mode_two_cursor_off_string - 1 &1ff0 20 ee ff JSR &ffee ; OSWRCH &1ff3 ca DEX &1ff4 d0 f7 BNE &1fed ; write_cursor_off_loop &1ff6 86 2a STX &2a ; use_joystick_input &1ff8 a2 17 LDX #&17 ; write_press_space_or_fire_loop # Write "Press Space or Fire" &1ffa bd b3 10 LDA &10b3,X ; press_space_or_fire_string &1ffd 20 ee ff JSR &ffee ; OSWRCH &2000 ca DEX &2001 10 f7 BPL &1ffa ; write_press_space_or_fire_loop ; wait_for_space_or_fire # Wait for player to press space or fire &2003 a9 7e LDA #&7e ; Acknowledge ESCAPE Condition &2005 20 f4 ff JSR &fff4 ; OSBYTE &2008 20 f4 1d JSR &1df4 ; check_for_sound_keypresses &200b a2 9d LDX #&9d &200d 20 1d 1a JSR &1a1d ; check_for_keypress &2010 f0 0d BEQ &201f ; to_play_game &2012 a9 80 LDA #&80 ; Read ADC Channel/Buffer/Mouse/Device status &2014 a2 00 LDX #&00 ; 0-b7=buttons, b8-b15=last ADC channel converted &2016 20 f4 ff JSR &fff4 ; OSBYTE &2019 8a TXA &201a 4a LSR A &201b 90 e6 BCC &2003 ; wait_for_space_or_fire &201d 66 2a ROR &2a ; use_joystick_input ; to_play_game &201f 4c d4 10 JMP &10d4 ; play_game # and play game again ; display_high_scores &2022 a2 00 LDX #&00 &2024 86 80 STX &80 ; position ; display_high_scores_loop &2026 20 e7 ff JSR &ffe7 ; OSNEWL # Move down two lines &2029 20 e7 ff JSR &ffe7 ; OSNEWL &202c a9 09 LDA #&09 ; RIGHT # Move cursor right four spaces &202e a2 04 LDX #&04 &2030 20 5f 1d JSR &1d5f ; write_a_x_times &2033 a5 80 LDA &80; position &2035 18 CLC &2036 69 31 ADC #&31 &2038 20 ee ff JSR &ffee ; OSWRCH # Write position &203b a9 09 LDA #&09 ; RIGHT &203d 20 ee ff JSR &ffee ; OSWRCH # Move cursor right two spaces &2040 20 ee ff JSR &ffee ; OSWRCH &2043 a6 80 LDX &80; position &2045 bd 9a 10 LDA &109a,X ; high_scores_three # Write score &2048 20 8c 1b JSR &1b8c ; write_two_digit_number &204b bd a2 10 LDA &10a2,X ; high_scores_two &204e 20 8c 1b JSR &1b8c ; write_two_digit_number &2051 bd aa 10 LDA &10aa,X ; high_scores_one &2054 20 8c 1b JSR &1b8c ; write_two_digit_number &2057 a9 2e LDA #&2e ; "." &2059 a2 05 LDX #&05 &205b 20 5f 1d JSR &1d5f ; write_a_x_times # Write "." five times &205e a5 80 LDA &80; position # Calculate offset of name for this position &2060 0a ASL A &2061 0a ASL A &2062 0a ASL A &2063 0a ASL A &2064 aa TAX &2065 a0 10 LDY #&10 ; write_name_loop # Write name &2067 bd 19 10 LDA &1019,X ; high_score_names &206a 20 ee ff JSR &ffee ; OSWRCH &206d e8 INX &206e 88 DEY &206f d0 f6 BNE &2067 ; write_name_loop &2071 e6 80 INC &80; position &2073 a5 80 LDA &80; position &2075 c9 08 CMP #&08 &2077 d0 ad BNE &2026 ; display_high_scores_loop # Repeat for all eight entries in high score table &2079 60 RTS ; plot_stage_75m &207a a9 05 LDA #&05 ; M &207c 20 f0 1c JSR &1cf0 ; set_text_colour_a # Set text colour to magenta &207f a0 e0 LDY #&e0 ; PLATFORM_GIRDER &2081 a9 1f LDA #&1f &2083 a2 13 LDX #&13 &2085 20 4f 1d JSR &1d4f ; tab_to_zero_a_write_y_x_times # Plot floor of girders, &13 long at (&00, &1f) &2088 a2 30 LDX #&30 ; write_lifts_loop # Plot top, bottom and cables of lifts &208a bd 19 0f LDA &0f19,X ; lifts_string &208d 20 ee ff JSR &ffee ; OSWRCH &2090 ca DEX &2091 10 f7 BPL &208a ; write_lifts_loop &2093 20 90 1c JSR &1c90 ; plot_damsel_on_platform # Plot damsel on top platform &2096 20 cc 1c JSR &1ccc ; plot_gorilla_side # Plot gorilla &2099 a0 00 LDY #&00 ; plot_stage_75m_platforms_loop # Plot other platforms &209b a9 1f LDA #&1f &209d 20 ee ff JSR &ffee ; OSWRCH &20a0 b9 5c 0e LDA &0e5c,Y ; stage_75_platforms &20a3 20 ee ff JSR &ffee ; OSWRCH &20a6 b9 5d 0e LDA &0e5d,Y ; stage_75_platforms + 1 &20a9 20 ee ff JSR &ffee ; OSWRCH &20ac b9 5e 0e LDA &0e5e,Y ; stage_75_platforms + 2 &20af aa TAX &20b0 a9 e0 LDA #&e0 ; PLATFORM_GIRDER &20b2 20 5f 1d JSR &1d5f ; write_a_x_times &20b5 c8 INY &20b6 c8 INY &20b7 c8 INY &20b8 c0 39 CPY #&39 &20ba d0 df BNE &209b ; plot_stage_75m_platforms_loop &20bc a9 08 LDA #&08 &20be 20 f0 1c JSR &1cf0 ; set_text_colour_a &20c1 a0 00 LDY #&00 ; plot_stage_75m_ladders_loop # Plot ladders &20c3 a9 1f LDA #&1f &20c5 20 ee ff JSR &ffee ; OSWRCH &20c8 b9 46 0d LDA &0d46,Y ; stage_75m_ladders_x &20cb 20 ee ff JSR &ffee ; OSWRCH &20ce b9 a3 0e LDA &0ea3,Y ; stage_75m_ladders_y &20d1 20 ee ff JSR &ffee ; OSWRCH &20d4 b9 4c 0f LDA &0f4c,Y ; stage_75m_ladders_lengths &20d7 aa TAX ; plot_stage_75m_ladder_loop &20d8 a9 e1 LDA #&e1 ; LADDER &20da 20 ee ff JSR &ffee ; OSWRCH &20dd a9 08 LDA #&08 &20df 20 ee ff JSR &ffee ; OSWRCH &20e2 a9 0b LDA #&0b &20e4 20 ee ff JSR &ffee ; OSWRCH &20e7 ca DEX &20e8 d0 ee BNE &20d8 ; plot_stage_75m_ladder_loop &20ea c8 INY &20eb c0 09 CPY #&09 &20ed d0 d4 BNE &20c3 ; plot_stage_75m_ladders_loop &20ef a2 02 LDX #&02 &20f1 86 52 STX &52 ; player_feet # Player starts facing right &20f3 ca DEX &20f4 86 51 STX &51 ; player_platform # Player starts on platform one &20f6 ca DEX &20f7 86 59 STX &59 ; player_has_died &20f9 86 53 STX &53 ; number_of_lower_enemies # No girder &20fb 86 50 STX &50 ; player_platform_x # Player starts at left of screen &20fd a9 80 LDA #&80 &20ff 8d 00 0d STA &0d00 ; hammers_x # No hammers &2102 8d 01 0d STA &0d01 ; hammers_x + 1 &2105 a9 07 LDA #&07 &2107 85 86 STA &86 ; enemy_offset &2109 a0 e4 LDY #&e4 # Set initial lift positions &210b 20 45 17 JSR &1745 ; move_lift_to_right_side &210e e6 86 INC &86 ; enemy_offset &2110 a0 ac LDY #&ac &2112 20 45 17 JSR &1745 ; move_lift_to_right_side &2115 e6 86 INC &86 ; enemy_offset &2117 a0 74 LDY #&74 &2119 20 45 17 JSR &1745 ; move_lift_to_right_side &211c a2 12 LDX #&12 # Add a fireball on left of platform three &211e 8e 09 0d STX &0d09 ; enemies_x + 5 &2121 a0 03 LDY #&03 &2123 8c 14 0d STY &0d14 ; enemies_platform + 5 &2126 a9 00 LDA #&00 &2128 8d 1f 0d STA &0d1f ; enemies_platform_offset + 5 &212b 20 eb 19 JSR &19eb ; calculate_platform_y &212e a9 16 LDA #&16 ; FIREBALL &2130 20 22 19 JSR &1922 ; plot_single_height_sprite &2133 a2 00 LDX #&00 # Plot collectible to left of platform three &2135 a0 03 LDY #&03 &2137 a9 31 LDA #&31 ; UMBRELLA, 300 &2139 20 66 1d JSR &1d66 ; add_collectible &213c a2 14 LDX #&14 # Plot collectible in middle of platform two &213e a0 02 LDY #&02 &2140 a9 52 LDA #&52 ; HAT, 500 &2142 20 66 1d JSR &1d66 ; add_collectible &2145 a2 48 LDX #&48 # Plot collectible to right of platform four &2147 a0 04 LDY #&04 &2149 a9 70 LDA #&70 ; TELEPHONE, 700 &214b 20 66 1d JSR &1d66 ; add_collectible &214e 4c 24 1d JMP &1d24 ; make_stage_visible ; check_for_platform_75m &2151 98 TYA &2152 30 0e BMI &2162 ; check_for_platform_on_lift &2154 d0 02 BNE &2158 ; not_floor # If the player is on platform zero, ; leave_with_carry_clear &2156 18 CLC # Leave with carry clear to indicate platform &2157 60 RTS ; not_floor &2158 c0 05 CPY #&05 &215a 90 06 BCC &2162 ; check_for_platform_on_lift # If player is too far to the right on platform five, &215c e0 3e CPX #&3e &215e 90 f6 BCC &2156 ; leave_with_carry_clear &2160 38 SEC # Leave with carry set to indicate hole &2161 60 RTS ; check_for_platform_on_lift &2162 a5 59 LDA &59 ; player_has_died &2164 d0 10 BNE &2176 ; outside_lift_shaft &2166 e0 07 CPX #&07 &2168 90 0c BCC &2176 ; outside_lift_shaft &216a e0 0d CPX #&0d &216c 90 5a BCC &21c8 ; inside_lift_shaft &216e e0 1f CPX #&1f &2170 90 04 BCC &2176 ; outside_lift_shaft &2172 e0 25 CPX #&25 &2174 90 52 BCC &21c8 ; inside_lift_shaft ; outside_lift_shaft &2176 98 TYA &2177 10 2d BPL &21a6 ; wasn't_on_lift # Was the player riding a lift? &2179 29 7f AND #&7f &217b a8 TAY &217c b9 14 0d LDA &0d14,Y ; enemies_platform + 5 &217f 85 83 STA &83 ; lift_platform &2181 a0 04 LDY #&04 ; find_nearest_platform_loop &2183 98 TYA &2184 48 PHA &2185 20 eb 19 JSR &19eb ; calculate_platform_y &2188 98 TYA &2189 38 SEC &218a e5 83 SBC &83 ; lift_y &218c b0 11 BCS &219f ; set_player_platform_and_leave_with_hole # If the lift is above a platform, use that platform &218e c9 ea CMP #&ea &2190 90 06 BCC &2198 ; consider_next_platform &2192 68 PLA ; lift_platform &2193 85 51 STA &51 ; player_platform &2195 a8 TAY &2196 d0 0e BNE &21a6 ; wasn't_on_lift ; consider_next_platform &2198 68 PLA ; lift_platform &2199 a8 TAY &219a 88 DEY &219b d0 e6 BNE &2183 ; find_nearest_platform_loop &219d f0 02 BEQ &21a1 ; set_player_platform_and_leave_with_hole # Default to platform one ; use_lift_platform_for_player_platform &219f 68 PLA ; lift_platform &21a0 a8 TAY ; set_player_platform_and_leave_with_hole &21a1 c8 INY &21a2 84 51 STY &51 ; player_platform &21a4 38 SEC # Leave with carry set to indicate hole &21a5 60 RTS ; wasn't_on_lift &21a6 88 DEY # Calculate which bit of stage_75m_platform_bits to use &21a7 84 80 STY &80 ; tmp &21a9 98 TYA &21aa 0a ASL A &21ab 65 80 ADC &80 ; tmp &21ad 85 80 STA &80 ; platform_minus_one_times_three # Three bytes each for platforms one through four &21af e8 INX &21b0 e8 INX &21b1 8a TXA &21b2 4a LSR A &21b3 4a LSR A &21b4 aa TAX # One bit for every character / 8 pixels horizontally &21b5 4a LSR A &21b6 4a LSR A &21b7 4a LSR A &21b8 18 CLC &21b9 65 80 ADC &80 ; platform_minus_one_times_three &21bb a8 TAY &21bc 8a TXA &21bd 29 07 AND #&07 &21bf aa TAX &21c0 b9 5c 0f LDA &0f5c,Y ; stage_75m_platform_bits ; get_xth_bit &21c3 0a ASL A &21c4 ca DEX &21c5 10 fc BPL &21c3 ; get_xth_bit &21c7 60 RTS # Return relevant bit in carry ; inside_lift_shaft # If the player is inside one of the lift shafts, &21c8 98 TYA &21c9 30 8b BMI &2156 ; leave_with_carry_clear # Player is on a platform if already riding lift &21cb 20 eb 19 JSR &19eb ; calculate_platform_y &21ce 98 TYA &21cf 84 80 STY &80 ; y &21d1 86 81 STX &81 ; x &21d3 a2 03 LDX #&03 # For each of the three lifts, ; check_lifts_loop &21d5 bd 14 0d LDA &0d14,X ; enemies_platform + 5 &21d8 38 SEC &21d9 e5 80 SBC &80 ; y &21db 90 1b BCC &21f8 ; consider_next_lift # Is the player above, &21dd c9 17 CMP #&17 &21df b0 17 BCS &21f8 ; consider_next_lift # but not too far above it? &21e1 a5 81 LDA &81 ; x &21e3 c9 16 CMP #&16 &21e5 90 0c BCC &21f3 ; left_shaft # If so, are they in the same shaft as the lift? ; right_shaft &21e7 bd 09 0d LDA &0d09,X ; enemies_x + 5 # Actually 1 if lift is in right shaft &21ea f0 0c BEQ &21f8 ; consider_next_lift ; on_lift # If player is close enough to lift, &21ec 8a TXA &21ed 09 80 ORA #&80 # Set top bit to indicate player is riding lift &21ef 85 51 STA &51 ; player_platform &21f1 18 CLC &21f2 60 RTS ; left_shaft &21f3 bd 09 0d LDA &0d09,X ; enemies_x + 5 # Actually 0 if lift is in left shaft &21f6 f0 f4 BEQ &21ec ; on_lift ; consider_next_lift &21f8 ca DEX &21f9 d0 da BNE &21d5 ; check_lifts_loop &21fb 38 SEC # Leave with carry set to indicate no platform &21fc 60 RTS ; calculate_platform_y_75m &21fd 98 TYA &21fe d0 03 BNE &2203 ; not_platform_zero &2200 a0 ec LDY #&ec # Platform zero has a constant height of &ec &2202 60 RTS ; not_platform_zero &2203 10 08 BPL &220d ; not_on_a_lift # If the player is on a lift, &2205 b9 94 0c LDA &0c94,Y ; enemies_platform - &80 &2208 38 SEC &2209 e9 0a SBC #&0a &220b a8 TAY # return the position of the lift &220c 60 RTS ; not_on_a_lift &220d c0 05 CPY #&05 &220f d0 03 BNE &2214 ; not_platform_five &2211 a0 24 LDY #&24 # Platform five has a constant height of &24 &2213 60 RTS ; not_platform_five # For platforms one to four, use a lookup table &2214 86 81 STX &81 ; x &2216 e8 INX &2217 e8 INX &2218 8a TXA &2219 4a LSR A &221a 4a LSR A &221b c9 14 CMP #&14 &221d d0 02 BNE &2221 ; skip_ceiling &221f a9 13 LDA #&13 ; skip_ceiling &2221 85 82 STA &82 ; x_plus_two_divided_by_four &2223 88 DEY &2224 98 TYA &2225 c8 INY &2226 0a ASL A &2227 0a ASL A &2228 85 80 STA &80 ; y_minus_one_times_four &222a 0a ASL A &222b 0a ASL A &222c 18 CLC &222d 65 80 ADC &80 ; y_minus_one_times_four # 16+4 = y*20 + x &222f 18 CLC &2230 65 82 ADC &82 &2232 aa TAX # X = ((x + 2) / 4) + &14 * (platform - 1) &2233 bd c8 0e LDA &0ec8,X ; stage_75m_platform_heights &2236 a6 81 LDX &81 ; x &2238 a8 TAY &2239 60 RTS ; update_enemies_75m &223a a2 09 LDX #&09 ; update_lifts_loop &223c 20 e8 16 JSR &16e8 ; update_75m_lift # Lifts are in enemy slots 7, 8 and 9 &223f ca DEX &2240 e0 06 CPX #&06 &2242 d0 f8 BNE &223c ; update_lifts_loop &2244 a5 53 LDA &53 ; number_of_lower_enemies &2246 d0 1e BNE &2266 ; update_girders_loop # If there isn't a girder, add one &2248 e6 53 INC &53 ; number_of_lower_enemies &224a a9 01 LDA #&01 # Girder is in enemy slot 1 &224c 85 86 STA &86 ; enemy_offset &224e a9 0c LDA #&0c &2250 85 54 STA &54 ; enemy_x &2252 20 ff 19 JSR &19ff ; get_random_number # Give girder a random horizontal offset &2255 29 03 AND #&03 &2257 85 57 STA &57 ; enemy_platform_offset &2259 18 CLC &225a 69 0c ADC #&0c &225c aa TAX &225d a9 2a LDA #&2a &225f 85 55 STA &55 ; enemy_platform &2261 a0 00 LDY #&00 &2263 20 a7 17 JSR &17a7; update_girder_with_bounce_table ; update_girders_loop # Unnecessary loop, allowing for multiple girders &2266 a6 53 LDX &53 ; number_of_lower_enemies &2268 20 5c 17 JSR &175c ; update_75m_girder &226b ca DEX &226c d0 f8 BNE &2266 ; update_girders_loop &226e a2 06 LDX #&06 # Fireball is in enemy slot 6 &2270 4c b0 14 JMP &14b0 ; update_fireball ; update_barrel &2273 20 c4 16 JSR &16c4 ; get_enemy_details_from_table &2276 a4 55 LDY &55 ; enemy_platform &2278 a6 54 LDX &54 ; enemy_x &227a a5 57 LDA &57 ; enemy_platform_offset &227c 10 4b BPL &22c9 ; regular_barrel ; first_barrel # Top bit of enemy_platform_offset set for first barrel &227e a9 15 LDA #&15 ; BARREL_FRONT &2280 20 22 19 JSR &1922 ; plot_single_height_sprite &2283 c8 INY # Move barrel down six pixels &2284 c8 INY &2285 c8 INY &2286 c8 INY &2287 c8 INY &2288 c8 INY &2289 c0 ef CPY #&ef &228b f0 13 BEQ &22a0 ; first_barrel_hits_bottom &228d 84 55 STY &55 ; enemy_platform &228f a5 67 LDA &67 ; level &2291 c9 01 CMP #&01 &2293 f0 03 BEQ &2298 ; not_moving_diagonally # On level two and above, barrel moves diagonally &2295 e8 INX # Move barrel right two pixels &2296 86 54 STX &54 ; enemy_x ; not_moving_diagonally &2298 a9 15 LDA #&15 ; BARREL_FRONT &229a 20 22 19 JSR &1922 ; plot_single_height_sprite # Plot barrel &229d 4c d6 16 JMP &16d6 ; set_enemy_details_to_table # and store updated position ; first_barrel_hits_bottom &22a0 a5 67 LDA &67 ; level # When the first barrel hits platform zero, &22a2 c9 01 CMP #&01 &22a4 f0 09 BEQ &22af ; convert_barrel_to_fireball # Convert it to a fireball on level one. &22a6 a0 00 LDY #&00 # Otherwise, turn it into a regular barrel &22a8 84 55 STY &55 ; enemy_platform &22aa 84 57 STY &57 ; enemy_platform_offset &22ac 4c da 23 JMP &23da ; plot_side_barrel ; convert_barrel_to_fireball &22af e6 5f INC &5f ; offset_of_last_fireball # Add a fireball (in first fireball slot) &22b1 a2 0e LDX #&0e &22b3 8e 09 0d STX &0d09 ; enemies_x # Manually set its position &22b6 a0 00 LDY #&00 &22b8 8c 14 0d STY &0d14 ; enemies_platform + 5 &22bb 8c 1f 0d STY &0d1f ; enemies_platform_offset + 5 &22be 20 eb 19 JSR &19eb ; calculate_platform_y &22c1 a9 16 LDA #&16 ; FIREBALL &22c3 20 22 19 JSR &1922 ; plot_single_height_sprite # Plot fireball &22c6 4c a1 16 JMP &16a1 ; remove_enemy # Remove barrel ; regular_barrel &22c9 20 eb 19 JSR &19eb ; calculate_platform_y &22cc a5 57 LDA &57 ; enemy_platform_offset &22ce f0 2b BEQ &22fb ; barrel_not_rolling_down_ladder &22d0 98 TYA # If the barrel is rolling down a ladder, &22d1 18 CLC &22d2 65 57 ADC &57 ; enemy_platform_offset &22d4 a8 TAY &22d5 a9 15 LDA #&15 ; BARREL_FRONT &22d7 20 22 19 JSR &1922 ; plot_single_height_sprite # Unplot barrel &22da e6 57 INC &57 ; enemy_platform_offset # Move barrel down two pixels &22dc e6 57 INC &57 ; enemy_platform_offset &22de a5 57 LDA &57 ; enemy_platform_offset &22e0 c9 28 CMP #&28 &22e2 d0 0b BNE &22ef ; barrel_not_at_bottom_of_ladder &22e4 a9 00 LDA #&00 &22e6 85 57 STA &57 ; enemy_platform_offset &22e8 c6 55 DEC &55 ; enemy_platform # Move the barrel on the platform below &22ea a6 54 LDX &54 ; enemy_x &22ec 4c ab 23 JMP &23ab ; set_barrel_x_and_consider_ladders # Replot barrel ; barrel_not_at_bottom_of_ladder &22ef c8 INY # Plot barrel two pixels further down &22f0 c8 INY &22f1 a6 54 LDX &54 ; enemy_x &22f3 a9 15 LDA #&15 ; BARREL_FRONT &22f5 20 9a 16 JSR &169a ; plot_enemy &22f8 4c 9a 15 JMP &159a ; get_enemy_details_and_check_for_collision_with_player ; barrel_not_rolling_down_ladder &22fb a5 55 LDA &55 ; enemy_platform &22fd 29 01 AND #&01 &22ff f0 2d BEQ &232e ; barrel_on_even_platform ; barrel_on_odd_platform &2301 e0 3f CPX #&3f # Has the barrel reached the right edge of the platform? &2303 90 20 BCC &2325 ; barrel_rolling_right_along_platform &2305 98 TYA &2306 18 CLC &2307 7d 55 0d ADC &0d55,X ; barrel_parabola - &3f # If so, make it fall in a parabola &230a a8 TAY &230b a9 14 LDA #&14 ; BARREL_SIDE &230d 20 22 19 JSR &1922 ; plot_single_height_sprite # Unplot barrel &2310 e8 INX &2311 e0 47 CPX #&47 &2313 f0 4d BEQ &2362 ; move_barrel_to_lower_platform # until it hits the next platform &2315 86 54 STX &54 ; enemy_x &2317 a4 55 LDY &55 ; enemy_platform &2319 20 eb 19 JSR &19eb ; calculate_platform_y &231c 98 TYA &231d 18 CLC &231e 7d 55 0d ADC &0d55,X ; barrel_parabola - &3f &2321 a8 TAY &2322 4c dd 23 JMP &23dd ; plot_side_barrel_with_y # Replot barrel ; barrel_rolling_right_along_platform &2325 a9 14 LDA #&14 ; BARREL_SIDE &2327 20 22 19 JSR &1922 ; plot_single_height_sprite &232a e8 INX &232b 4c ab 23 JMP &23ab ; set_barrel_x_and_consider_ladders ; barrel_on_even_platform &232e e0 0c CPX #&0c # Has the barrel reached the left edge of the platform? &2330 b0 42 BCS &2374 ; barrel_rolling_left_along_platform &2332 a9 0c LDA #&0c &2334 38 SEC &2335 e5 54 SBC &54 ; enemy_x &2337 aa TAX &2338 98 TYA &2339 18 CLC &233a 7d 94 0d ADC &0d94,X ; barrel_parabola # If so, make it fall in a parabola &233d a8 TAY &233e a6 54 LDX &54 ; enemy_x &2340 a9 14 LDA #&14 ; BARREL_SIDE &2342 20 22 19 JSR &1922 ; plot_single_height_sprite # Unplot barrel &2345 ca DEX &2346 e0 04 CPX #&04 &2348 f0 18 BEQ &2362 ; move_barrel_to_lower_platform # until it hits the next platform &234a 86 54 STX &54 ; enemy_x &234c a4 55 LDY &55 ; enemy_platform &234e 20 eb 19 JSR &19eb ; calculate_platform_y &2351 a9 0c LDA #&0c &2353 38 SEC &2354 e5 54 SBC &54 ; enemy_x &2356 aa TAX &2357 98 TYA &2358 18 CLC &2359 7d 94 0d ADC &0d94,X ; barrel_parabola &235c a8 TAY &235d a6 54 LDX &54 ; enemy_x &235f 4c dd 23 JMP &23dd ; plot_side_barrel_with_y # Replot barrel ; move_barrel_to_lower_platform &2362 c6 55 DEC &55 ; enemy_platform &2364 a5 55 LDA &55 ; enemy_platform &2366 c5 51 CMP &51 ; player_platform &2368 b0 41 BCS &23ab ; set_barrel_x_and_consider_ladders # Is the barrel on a platform lower than the player? &236a 20 ff 19 JSR &19ff ; get_random_number &236d c9 55 CMP #&55 &236f b0 3a BCS &23ab ; set_barrel_x_and_consider_ladders &2371 4c a1 16 JMP &16a1 ; remove_enemy # If so, 85 in 256 chance of it being destroyed ; barrel_rolling_left_along_platform &2374 a9 14 LDA #&14 ; BARREL_SIDE &2376 20 22 19 JSR &1922 ; plot_single_height_sprite &2379 ca DEX &237a e0 0c CPX #&0c &237c b0 2d BCS &23ab ; set_barrel_x_and_consider_ladders &237e a5 55 LDA &55 ; enemy_platform &2380 d0 29 BNE &23ab ; set_barrel_x_and_consider_ladders # Has the barrel reached the end of platform zero? &2382 20 ff 19 JSR &19ff ; get_random_number &2385 29 03 AND #&03 &2387 d0 1f BNE &23a8 ; to_remove_enemy # If so, 1 in 4 chance of it becoming a fireball, &2389 a6 5f LDX &5f ; offset_of_last_fireball &238b e0 0a CPX #&0a &238d f0 19 BEQ &23a8 ; to_remove_enemy # so long as there is a free fireball slot &238f e6 5f INC &5f ; offset_of_last_fireball &2391 a9 00 LDA #&00 &2393 9d 1a 0d STA &0d1a,X ; enemies_platform_offset &2396 9d 0f 0d STA &0d0f,X ; enemies_platform &2399 a8 TAY &239a a9 0e LDA #&0e &239c 9d 04 0d STA &0d04,X ; enemies_x # Fireball starts at left of platform zero &239f aa TAX &23a0 20 eb 19 JSR &19eb ; calculate_platform_y &23a3 a9 16 LDA #&16 ; FIREBALL &23a5 20 22 19 JSR &1922 ; plot_single_height_sprite # Plot new fireball ; to_remove_enemy &23a8 4c a1 16 JMP &16a1 ; remove_enemy # Remove the barrel regardless ; set_barrel_x_and_consider_ladders &23ab 86 54 STX &54 ; enemy_x &23ad a4 55 LDY &55 ; enemy_platform &23af 88 DEY &23b0 20 b3 1a JSR &1ab3 ; check_x_y_for_ladder &23b3 a4 55 LDY &55 ; enemy_platform &23b5 b0 21 BCS &23d8 ; plot_side_barrel_with_enemy_x # Is there a ladder on the platform below the barrel? &23b7 20 ff 19 JSR &19ff ; get_random_number &23ba 29 0f AND #&0f &23bc d0 1a BNE &23d8 ; plot_side_barrel_with_enemy_x # If so, 1 in 16 chance of barrel rolling down ladder &23be a5 56 LDA &56 ; player_platform_offset &23c0 f0 0a BEQ &23cc ; player_isn't_on_barrel's_ladder # Is the player on a ladder? &23c2 e4 6b CPX &6b ; player_ladder_number &23c4 d0 06 BNE &23cc ; player_isn't_on_barrel's_ladder # If so, is the barrel on the same ladder as the player? &23c6 29 f8 AND #&f8 &23c8 c9 18 CMP #&18 &23ca f0 0c BEQ &23d8 ; plot_side_barrel_with_enemy_x # If the player's head isn't level with the platform , ; player_isn't_on_barrel's_ladder &23cc a9 02 LDA #&02 &23ce 85 57 STA &57 ; enemy_platform_offset # Set the barrel rolling down the ladder &23d0 a6 54 LDX &54 ; enemy_x &23d2 20 eb 19 JSR &19eb ; calculate_platform_y &23d5 4c ef 22 JMP &22ef ; barrel_not_at_bottom_of_ladder ; plot_side_barrel_with_enemy_x &23d8 a6 54 LDX &54 ; enemy_x ; plot_side_barrel &23da 20 eb 19 JSR &19eb ; calculate_platform_y ; plot_side_barrel_with_y &23dd 86 54 STX &54 ; enemy_x &23df a9 14 LDA #&14 ; BARREL_SIDE &23e1 20 9a 16 JSR &169a ; plot_enemy &23e4 4c 9a 15 JMP &159a ; get_enemy_details_and_check_for_collision_with_player ; plot_stage_25m &23e7 20 90 1c JSR &1c90 ; plot_damsel_on_platform # Plot damsel on platform &23ea 20 cc 1c JSR &1ccc ; plot_gorilla_side # Plot gorilla &23ed a9 05 LDA #&05 &23ef 20 27 1a JSR &1a27 ; plot_stage_ladders # Plot ladders &23f2 a9 05 LDA #&05 &23f4 20 ee ff JSR &ffee ; OSWRCH # Plot subsequent text at graphics cursor &23f7 aa TAX ; platform_number # Six platforms &23f8 20 fa 1c JSR &1cfa ; set_graphics_colour_a ; plot_platforms_loop # Plot platforms &23fb a9 00 LDA #&00 &23fd 85 80 STA &80 ; x_low &23ff 85 82 STA &82 ; y_low &2401 8a TXA ; platform_number &2402 29 01 AND #&01 &2404 49 01 EOR #&01 &2406 85 81 STA &81 ; x_high &2408 8a TXA &2409 4a LSR A &240a 66 82 ROR &82 ; y_low &240c 85 83 STA &83 ; y_high &240e 8a TXA &240f 0a ASL A &2410 0a ASL A &2411 0a ASL A &2412 0a ASL A &2413 0a ASL A &2414 65 82 ADC &82 ; y_low &2416 85 82 STA &82 ; y_low &2418 90 02 BCC &241c &241a e6 83 INC &83 ; y_high &241c 8a TXA ; platform_number &241d 29 01 AND #&01 &241f f0 0b BEQ &242c ; skip_raise &2421 a5 82 LDA &82 ; y_low &2423 18 CLC &2424 69 26 ADC #&26 # Raise left end of odd platforms &2426 85 82 STA &82 ; y_low &2428 90 02 BCC &242c ; skip_raise &242a e6 83 INC &83 ; y_high ; skip_raise &242c a0 0f LDY #&0f # Platforms have 16 sections ; plot_platform_loop &242e a9 19 LDA #&19 &2430 20 ee ff JSR &ffee ; OSWRCH # MOVE(x, y) &2433 a9 04 LDA #&04 &2435 20 ee ff JSR &ffee ; OSWRCH &2438 a5 80 LDA &80 ; x_low &243a 20 ee ff JSR &ffee ; OSWRCH &243d 18 CLC &243e 69 40 ADC #&40 # Move right after every section &2440 85 80 STA &80 ; x_low &2442 08 PHP &2443 a5 81 LDA &81 ; x_high &2445 20 ee ff JSR &ffee ; OSWRCH &2448 28 PLP &2449 69 00 ADC #&00 &244b 85 81 STA &81 ; x_high &244d a5 82 LDA &82 ; y_low &244f 20 ee ff JSR &ffee ; OSWRCH &2452 a5 83 LDA &83 ; y_high &2454 20 ee ff JSR &ffee ; OSWRCH &2457 8a TXA ; platform_number &2458 29 01 AND #&01 &245a d0 0d BNE &2469 ; slope_downwards ; slope_upwards &245c a5 82 LDA &82 ; y_low &245e 18 CLC &245f 69 02 ADC #&02 # Even platforms slope up from the left &2461 85 82 STA &82 ; y_low &2463 90 0f BCC &2474 ; consider_holes_in_platform &2465 e6 83 INC &83 ; y_high &2467 d0 0b BNE &2474 ; consider_holes_in_platform ; slope_downwards &2469 a5 82 LDA &82 ; y_low &246b 38 SEC &246c e9 02 SBC #&02 # Odd platforms slope down from the left &246e 85 82 STA &82 ; y_low &2470 b0 02 BCS &2474 ; consider_holes_in_platform &2472 c6 83 DEC &83 ; y_high ; consider_holes_in_platform &2474 a5 67 LDA &67 ; level &2476 c9 01 CMP #&01 &2478 f0 20 BEQ &249a ; plot_platform # No holes on level one &247a c0 05 CPY #&05 &247c d0 0c BNE &248a ; consider_odd_holes &247e e0 02 CPX #&02 &2480 f0 04 BEQ &2486 ; plot_hole # Platforms two &2482 e0 04 CPX #&04 &2484 d0 14 BNE &249a ; plot_platform # and four have hole in sixth section from right ; plot_hole &2486 a9 20 LDA #&20 ; " " &2488 d0 12 BNE &249c ; plot_character ; consider_odd_holes &248a c9 02 CMP #&02 &248c f0 0c BEQ &249a ; plot_platform # No odd holes on levels one or two &248e c0 0a CPY #&0a &2490 d0 08 BNE &249a ; plot_platform &2492 e0 01 CPX #&01 &2494 f0 f0 BEQ &2486 ; plot_hole # Platforms one &2496 e0 03 CPX #&03 &2498 f0 ec BEQ &2486 ; plot_hole # and three have hole in eleventh section from right ; plot_platform &249a a9 e0 LDA #&e0 ; PLATFORM_GIRDER ; plot_character &249c 20 ee ff JSR &ffee ; OSWRCH &249f 88 DEY &24a0 10 8c BPL &242e ; plot_platform_loop &24a2 ca DEX &24a3 30 03 BMI &24a8 ; finished_plotting_platforms &24a5 4c fb 23 JMP &23fb ; plot_platforms_loop ; finished_plotting_platforms &24a8 a2 32 LDX #&32 # Plot hammer to right of platform 1 &24aa 8e 00 0d STX &0d00 ; hammers_x &24ad a0 01 LDY #&01 &24af 8c 02 0d STY &0d02 ; hammers_y &24b2 20 9c 1b JSR &1b9c ; plot_hammer &24b5 a2 10 LDX #&10 # Plot hammer to left of platform 4 &24b7 8e 01 0d STX &0d01 ; hammers_x + 1 &24ba a0 04 LDY #&04 &24bc 8c 03 0d STY &0d03 ; hammers_y + 1 &24bf 20 9c 1b JSR &1b9c ; plot_hammer &24c2 a2 08 LDX #&08 # Plot oil drum to left of platform zero &24c4 a0 f2 LDY #&f2 &24c6 a9 18 LDA #&18 ; OIL_DRUM &24c8 20 e6 18 JSR &18e6 ; plot_double_height_sprite &24cb a9 05 LDA #&05 &24cd 85 86 STA &86 ; number_of_barrels ; plot_barrel_store_loop # Plot barrels next to gorilla &24cf a5 86 LDA &86 ; number_of_barrels &24d1 29 fe AND #&fe &24d3 0a ASL A &24d4 aa TAX &24d5 a5 86 LDA &86 ; number_of_barrels &24d7 a0 12 LDY #&12 &24d9 29 01 AND #&01 &24db f0 02 BEQ &24df ; upper_row &24dd a0 22 LDY #&22 ; upper_row &24df a9 15 LDA #&15 ; BARREL_FRONT &24e1 20 22 19 JSR &1922 ; plot_single_height_sprite &24e4 c6 86 DEC &86 ; number_of_barrels &24e6 10 e7 BPL &24cf ; plot_barrel_store_loop &24e8 a9 08 LDA #&08 &24ea 20 fa 1c JSR &1cfa ; set_graphics_colour_a # Use colour of ladders (unnecessary) &24ed a9 01 LDA #&01 &24ef 85 53 STA &53 ; number_of_lower_enemies &24f1 a0 05 LDY #&05 # No fireballs initially &24f3 84 5f STY &5f ; offset_of_last_fireball &24f5 8c 0f 0d STY &0d0f ; enemies_platform # Actually y of first barrel &24f8 a9 ff LDA #&ff &24fa 8d 1a 0d STA &0d1a ; enemies_platform_offset # Top bit set to indicate first barrel is falling &24fd a2 0e LDX #&0e &24ff a5 67 LDA &67 ; level &2501 c9 03 CMP #&03 &2503 90 02 BCC &2507 ; not_diagonal_first_barrel &2505 a2 16 LDX #&16 # Change starting position for diagonally moving barrel ; not_diagonal_first_barrel &2507 8e 04 0d STX &0d04 ; enemies_x &250a a9 15 LDA #&15 ; BARREL_FRONT &250c 20 22 19 JSR &1922 ; plot_single_height_sprite # Plot first barrel &250f 20 24 1d JSR &1d24 ; make_stage_visible &2512 a2 14 LDX #&14 &2514 86 50 STX &50 ; player_platform_x # Player starts at left &2516 a0 00 LDY #&00 &2518 84 51 STY &51 ; player_platform # of platform zero &251a 84 59 STY &59 ; player_has_died &251c a9 02 LDA #&02 &251e 85 52 STA &52 ; player_feet # Player starts facing right &2520 a9 04 LDA #&04 &2522 4c ee ff JMP &ffee ; OSWRCH # Plot subsequent text at text cursor ; calculate_platform_y_25m &2525 8a TXA &2526 4a LSR A &2527 4a LSR A &2528 4a LSR A &2529 85 81 STA &81 ; x_divided_by_eight &252b 98 TYA &252c 0a ASL A &252d 0a ASL A &252e 0a ASL A &252f 85 80 STA &80 ; platform_times_eight &2531 0a ASL A &2532 0a ASL A &2533 65 80 ADC &80 ; platform_times_eight &2535 85 80 STA &80 ; platform_times_forty &2537 98 TYA &2538 29 01 AND #&01 &253a f0 0b BEQ &2547 ; even_platform ; odd_platform &253c a5 80 LDA &80 ; platform_times_forty &253e 18 CLC &253f 69 0a ADC #&0a &2541 38 SEC &2542 e5 81 SBC &81 ; x_divided_by_eight # Odd platforms slope down from the left &2544 4c 4c 25 JMP &254c ; invert_result ; even_platform &2547 a5 80 LDA &80 ; platform_times_forty &2549 18 CLC &254a 65 81 ADC &81 ; x_divided_by_eight # Even platforms slope up from the left ; invert_result &254c 85 80 STA &80 ; y &254e a9 f3 LDA #&f3 &2550 38 SEC &2551 e5 80 SBC &80 ; y &2553 a8 TAY &2554 60 RTS ; update_enemies_25m &2555 a6 53 LDX &53 ; number_of_lower_enemies &2557 e0 05 CPX #&05 &2559 f0 1e BEQ &2579 ; skip_new_barrel # Five barrels maximum &255b e0 02 CPX #&02 &255d 90 07 BCC &2566 ; new_barrel # Two barrels minimum &255f 20 ff 19 JSR &19ff ; get_random_number &2562 29 3f AND #&3f &2564 d0 13 BNE &2579 ; get_random_number # Otherwise, 1 in 64 chance of a new barrel appearing ; new_barrel &2566 e6 53 INC &53 ; number_of_lower_enemies &2568 a5 53 LDA &53 ; number_of_lower_enemies &256a 85 86 STA &86 ; enemy_offset &256c a9 00 LDA #&00 &256e 85 57 STA &57 ; enemy_platform_offset &2570 a0 05 LDY #&05 &2572 84 55 STY &55 ; enemy_platform &2574 a2 14 LDX #&14 # New barrels appear to the right of the gorilla &2576 20 ab 23 JSR &23ab ; set_barrel_x_and_consider_ladders ; skip_new_barrel &2579 a6 53 LDX &53 ; number_of_lower_enemies &257b f0 06 BEQ &2583 ; no_barrels_to_update ; update_barrels_loop &257d 20 73 22 JSR &2273 ; update_barrel &2580 ca DEX &2581 d0 fa BNE &257d ; update_barrels_loop ; no_barrels_to_update &2583 4c 9e 14 JMP &149e ; update_fireballs ; update_pie &2586 20 c4 16 JSR &16c4 ; get_enemy_details_from_table &2589 20 8d 2b JSR &2b8d ; check_level_based_speed &258c b0 25 BCS &25b3 ; skip_new_pie &258e a5 55 LDA &55 ; enemy_platform &2590 c9 01 CMP #&01 &2592 f0 22 BEQ &25b6 ; pie_on_platform_one ; pie_on_platform_three # If the pie is on platform three, &2594 a6 54 LDX &54 ; enemy_x &2596 a0 54 LDY #&54 &2598 a9 1b LDA #&1b ; PIE &259a 20 22 19 JSR &1922 ; plot_single_height_sprite # Unplot it &259d e8 INX # Move it right if it is on the left half &259e e0 28 CPX #&28 &25a0 90 02 BCC &25a4 ; pie_on_left_half_of_platform_three ; pie_on_right_half_of_platform_three &25a2 ca DEX # and left if if it is on the right half &25a3 ca DEX ; pie_on_left_half_of_platform_three &25a4 e0 20 CPX #&20 &25a6 f0 24 BEQ &25cc ; to_remove_enemy # Remove it at right edge of left half &25a8 e0 2c CPX #&2c &25aa f0 20 BEQ &25cc ; to_remove_enemy # and left edge of right half ; replot_pie &25ac a9 1b LDA #&1b ; PIE &25ae 20 9a 16 JSR &169a ; plot_enemy # Replot the pie &25b1 86 54 STX &54 ; enemy_x ; skip_new_pie &25b3 4c 9a 15 JMP &159a ; get_enemy_details_and_check_for_collision_with_player ; pie_on_platform_one # If the pie is on platform one, &25b6 a6 54 LDX &54 ; enemy_x &25b8 a0 b4 LDY #&b4 &25ba a9 1b LDA #&1b ; PIE &25bc 20 22 19 JSR &1922 ; plot_single_height_sprite # Unplot it &25bf e8 INX # Move it right &25c0 a5 27 LDA &27 ; conveyor_direction &25c2 f0 04 BEQ &25c8 ; pie_on_platform_one_moving_right ; pie_on_platform_one_moving_left &25c4 ca DEX # or left depending on the conveyor direction &25c5 ca DEX &25c6 30 04 BMI &25cc ; to_remove_enemy # Remove it at left of screen ; pie_on_platform_one_moving_right &25c8 e0 4d CPX #&4d &25ca d0 e0 BNE &25ac ; replot_pie # and right of screen; otherwise, replot it ; to_remove_enemy &25cc 4c a1 16 JMP &16a1 ; remove_enemy ; update_50m_ladder_top &25cf 85 80 STA &80 ; ladder_top &25d1 30 0d BMI &25e0 ; ladder_is_changing_height # If the ladder isn't already changing height, &25d3 20 ff 19 JSR &19ff ; get_random_number &25d6 29 3f AND #&3f &25d8 d0 1d BNE &25f7 ; leave_with_ladder_top # 1 in 64 chance of it starting to change height &25da a5 80 LDA &80 ; ladder_top &25dc 49 c0 EOR #&c0 # Set top bit to indicate ladder is changing height &25de 85 80 STA &80 ; ladder_top # Toggle second highest bit to toggle direction ; ladder_is_changing_height &25e0 a5 80 LDA &80 ; ladder_top &25e2 29 40 AND #&40 &25e4 f0 14 BEQ &25fa ; ladder_is_extending ; ladder_is_shrinking &25e6 20 07 26 JSR &2607 ; plot_ladder_top &25e9 e6 80 INC &80 ; ladder_top &25eb a5 80 LDA &80 ; ladder_top &25ed 29 1f AND #&1f &25ef d0 06 BNE &25f7 ; leave_with_ladder_top # If the ladder has reached its minimum size, ; stop_ladder &25f1 a5 80 LDA &80 ; ladder_top &25f3 29 7f AND #&7f # Unset top bit to indicate ladder isn't changing height &25f5 85 80 STA &80 ; ladder_top ; leave_with_ladder_top &25f7 a5 80 LDA &80 ; ladder_top &25f9 60 RTS ; ladder_is_extending &25fa c6 80 DEC &80 ; ladder_top &25fc 20 07 26 JSR &2607 ; plot_ladder_top &25ff a5 80 LDA &80 ; ladder_top &2601 29 3f AND #&3f &2603 f0 ec BEQ &25f1 ; stop_ladder # If the ladder has reached its maximum size, stop it &2605 d0 f0 BNE &25f7 ; leave_with_ladder_top ; plot_ladder_top &2607 a5 80 LDA &80 ; ladder_top &2609 29 3f AND #&3f &260b 48 PHA &260c 4a LSR A &260d 4a LSR A &260e 4a LSR A &260f f0 07 BEQ &2618 ; skip_calculation &2611 aa TAX ; calculate_ladder_screen_address_loop &2612 20 5a 26 JSR &265a ; add_eight_rows_to_ladder_screen_address &2615 ca DEX &2616 d0 fa BNE &2612 ; calculate_ladder_screen_address_loop ; skip_calculation &2618 68 PLA &2619 29 07 AND #&07 &261b a8 TAY &261c b1 82 LDA (&82),Y ; ladder_screen_address &261e 49 80 EOR #&80 ; CK # (Un)plot the left side of the ladder &2620 91 82 STA (&82),Y ; ladder_screen_address &2622 98 TYA &2623 18 CLC &2624 69 18 ADC #&18 &2626 a8 TAY &2627 b1 82 LDA (&82),Y ; ladder_screen_address &2629 49 40 EOR #&40 ; KC # (Un)plot the right side of the ladder &262b 91 82 STA (&82),Y ; ladder_screen_address &262d 98 TYA &262e 38 SEC &262f e9 15 SBC #&15 &2631 a8 TAY &2632 c0 08 CPY #&08 &2634 90 07 BCC &263d ; skip_moving_to_next_group &2636 98 TYA &2637 29 07 AND #&07 &2639 a8 TAY &263a 20 5a 26 JSR &265a ; add_eight_rows_to_ladder_screen_address ; skip_moving_to_next_group &263d 20 68 26 JSR &2668 ; plot_ladder_rung &2640 a5 80 LDA &80 ; ladder_top &2642 29 07 AND #&07 &2644 c9 07 CMP #&07 &2646 f0 11 BEQ &2659 ; leave &2648 98 TYA &2649 38 SEC &264a e9 17 SBC #&17 &264c a8 TAY &264d c0 08 CPY #&08 &264f d0 05 BNE &2656 ; skip_moving_to_next_group_again &2651 20 5a 26 JSR &265a ; add_eight_rows_to_ladder_screen_address &2654 a0 00 LDY #&00 ; skip_moving_to_next_group_again &2656 20 68 26 JSR &2668 ; plot_ladder_rung ; leave &2659 60 RTS ; add_eight_rows_to_ladder_screen_address &265a a5 82 LDA &82 ; ladder_screen_address_low &265c 18 CLC &265d 69 80 ADC #&80 &265f 85 82 STA &82 ; ladder_screen_address_low &2661 a5 83 LDA &83 ; ladder_screen_address_high &2663 69 02 ADC #&02 &2665 85 83 STA &83 ; ladder_screen_address_high &2667 60 RTS ; plot_ladder_rung &2668 b1 82 LDA (&82),Y ; ladder_screen_address &266a 49 40 EOR #&40 ; KC # (Un)plot first pixel of rung &266c 91 82 STA (&82),Y ; ladder_screen_address &266e 98 TYA &266f 18 CLC &2670 69 08 ADC #&08 &2672 a8 TAY &2673 b1 82 LDA (&82),Y ; ladder_screen_address &2675 49 c0 EOR #&c0 ; CC # (Un)plot next two pixels &2677 91 82 STA (&82),Y ; ladder_screen_address &2679 98 TYA &267a 18 CLC &267b 69 08 ADC #&08 &267d a8 TAY &267e b1 82 LDA (&82),Y ; ladder_screen_address &2680 49 c0 EOR #&c0 ; CC # (Un)plot next two pixels &2682 91 82 STA (&82),Y ; ladder_screen_address &2684 98 TYA &2685 18 CLC &2686 69 08 ADC #&08 &2688 a8 TAY &2689 b1 82 LDA (&82),Y ; ladder_screen_address &268b 49 80 EOR #&80 ; CK # (Un)plot last pixel of rung &268d 91 82 STA (&82),Y ; ladder_screen_address &268f 60 RTS ; plot_stage_50m &2690 20 90 1c JSR &1c90 ; plot_damsel_on_platform # Plot damsel on platform &2693 20 dc 1c JSR &1cdc ; plot_gorilla_front # Plot gorilla &2696 a0 e0 LDY #&e0 ; PLATFORM_GIRDER &2698 a2 14 LDX #&14 &269a a9 1e LDA #&1e &269c 20 4f 1d JSR &1d4f ; tab_to_zero_a_write_y_x_times # Plot platform zero (&14 long) &269f a9 12 LDA #&12 &26a1 a2 05 LDX #&05 &26a3 20 4f 1d JSR &1d4f ; tab_to_zero_a_write_y_x_times # Plot left part of platform two (5 long) &26a6 a9 09 LDA #&09 &26a8 20 ee ff JSR &ffee ; OSWRCH # One character space &26ab a2 08 LDX #&08 &26ad 20 5e 1d JSR &1d5e ; write_y_x_times # Plot middle part of platform two (8 long) &26b0 a9 09 LDA #&09 &26b2 20 ee ff JSR &ffee ; OSWRCH # One character space &26b5 a2 05 LDX #&05 &26b7 20 5e 1d JSR &1d5e ; write_y_x_times # Plot right part of platform two (5 long) &26ba a9 01 LDA #&01 ; R &26bc 20 f0 1c JSR &1cf0 ; set_text_colour_a # Set text colour to red &26bf a0 e4 LDY #&e4 ; PLATFORM_SQUARES &26c1 a9 18 LDA #&18 &26c3 a2 14 LDX #&14 &26c5 20 4f 1d JSR &1d4f ; tab_to_zero_a_write_y_x_times # Plot platform one (&14 long) &26c8 a9 06 LDA #&06 &26ca a2 14 LDX #&14 &26cc 20 4f 1d JSR &1d4f ; tab_to_zero_a_write_y_x_times # Plot platform four (&14 long) &26cf a9 0c LDA #&0c &26d1 a2 09 LDX #&09 &26d3 20 4f 1d JSR &1d4f ; tab_to_zero_a_write_y_x_times # Plot left part of platform three (9 long) &26d6 a9 09 LDA #&09 &26d8 a2 02 LDX #&02 &26da 20 5f 1d JSR &1d5f ; write_a_x_times # Two character space &26dd a2 09 LDX #&09 &26df 20 5e 1d JSR &1d5e ; write_y_x_times # Plot right part of platform three (9 long) &26e2 a9 05 LDA #&05 &26e4 20 27 1a JSR &1a27 ; plot_stage_ladders # Plot ladders &26e7 a9 03 LDA #&03 ; Y &26e9 20 f0 1c JSR &1cf0 ; set_text_colour_a # Set text colour to yellow &26ec a2 0e LDX #&0e ; plot_central_pillar_loop # Plot central pillar &26ee a9 1f LDA #&1f &26f0 20 ee ff JSR &ffee ; OSWRCH # TAB(&09, X) &26f3 a9 09 LDA #&09 &26f5 20 ee ff JSR &ffee ; OSWRCH &26f8 8a TXA &26f9 20 ee ff JSR &ffee ; OSWRCH &26fc a9 e5 LDA #&e5 ; PLATFORM_CROSS &26fe 20 ee ff JSR &ffee ; OSWRCH # Plot two characters &2701 20 ee ff JSR &ffee ; OSWRCH &2704 e8 INX &2705 e0 12 CPX #&12 &2707 d0 e5 BNE &26ee ; plot_central_pillar_loop &2709 a2 26 LDX #&26 &270b a0 64 LDY #&64 &270d a9 18 LDA #&18 ; OIL_DRUM &270f 20 e6 18 JSR &18e6 ; plot_double_height_sprite &2712 a2 26 LDX #&26 # Plot hammer in middle of platform one &2714 8e 00 0d STX &0d00 ; hammers_x &2717 a0 01 LDY #&01 &2719 8c 02 0d STY &0d02 ; hammers_x + 1 &271c 20 9c 1b JSR &1b9c ; plot_hammer &271f a2 02 LDX #&02 # Plot hammer to left of platform two &2721 8e 01 0d STX &0d01 ; hammers_y &2724 a0 02 LDY #&02 &2726 8c 03 0d STY &0d03 ; hammers_y + 1 &2729 20 9c 1b JSR &1b9c ; plot_hammer &272c a2 26 LDX #&26 # Plot collectible in middle of platform zero &272e a0 00 LDY #&00 &2730 a9 33 LDA #&33 ; HANDBAG, 300 &2732 20 66 1d JSR &1d66 ; add_collectible &2735 a2 18 LDX #&18 # Plot collectible in middle of platform two &2737 a0 02 LDY #&02 &2739 a9 52 LDA #&52 ; HAT, 500 &273b 20 66 1d JSR &1d66 ; add_collectible &273e a2 48 LDX #&48 # Plot collectible to right of platform two &2740 a0 02 LDY #&02 &2742 a9 81 LDA #&81 ; UMBRELLA, 800 &2744 20 66 1d JSR &1d66 ; add_collectible &2747 a2 14 LDX #&14 &2749 86 50 STX &50 ; player_platform_x &274b a0 00 LDY #&00 &274d 84 51 STY &51 ; player_platform # Player starts on platform zero &274f 84 23 STY &23 ; frame_counter &2751 84 68 STY &68 ; left_ladder_top # Platform three ladders start fully extended &2753 84 69 STY &69 ; right_ladder_top &2755 84 59 STY &59 ; player_has_died &2757 84 53 STY &53 ; number_of_lower_enemies &2759 84 27 STY &27 ; conveyor_direction # Conveyor starts moving right &275b a9 02 LDA #&02 &275d 85 52 STA &52 ; player_feet # Player starts facing right &275f a9 05 LDA #&05 &2761 85 5f STA &5f ; offset_of_last_fireball &2763 4c 24 1d JMP &1d24 ; make_stage_visible ; plot_stage_100m &2766 a9 04 LDA #&04 ; B &2768 20 f0 1c JSR &1cf0 ; set_text_colour_a # Set text and graphics colour to blue &276b 20 fa 1c JSR &1cfa ; set_graphics_colour_a &276e a0 e6 LDY #&e6 ; PLATFORM_DIAMOND &2770 a2 13 LDX #&13 &2772 a9 1f LDA #&1f &2774 20 4f 1d JSR &1d4f ; tab_to_zero_a_write_y_x_times # Plot a platform of length 19 at (&00, &1f) &2777 a2 1a LDX #&1a ; write_stage_100m_supports_loop &2779 bd 3d 0e LDA &0e3d,X ; stage_100m_supports_string # Draw vertical supports &277c 20 ee ff JSR &ffee ; OSWRCH &277f ca DEX &2780 10 f7 BPL &2779 ; write_stage_100m_supports_loop &2782 a2 08 LDX #&08 &2784 20 5e 1d JSR &1d5e ; write_y_x_times # Plot a platform of length 8 at (&06, &03) &2787 a9 19 LDA #&19 &2789 85 80 STA &80 ; y &278b a2 04 LDX #&04 ; plot_platforms_loop # Plot four tapering platforms &278d a9 1f LDA #&1f &278f 20 ee ff JSR &ffee ; OSWRCH &2792 86 81 STX &81 ; width_of_outside &2794 a9 05 LDA #&05 &2796 38 SEC &2797 e5 81 SBC &81 ; width_of_outside &2799 20 ee ff JSR &ffee ; OSWRCH &279c a5 80 LDA &80 ; y &279e 20 ee ff JSR &ffee ; OSWRCH &27a1 20 1a 28 JSR &281a ; plot_blue_platform_with_yellow_end # Plot left edge of platform &27a4 a2 08 LDX #&08 &27a6 20 1a 28 JSR &281a ; plot_blue_platform_with_yellow_end # Plot centre of platform, length 8 &27a9 a6 81 LDX &81 ; width_of_outside &27ab 20 5e 1d JSR &1d5e ; write_y_x_times # Plot right edge of platform &27ae a5 80 LDA &80 ; y &27b0 38 SEC &27b1 e9 06 SBC #&06 &27b3 85 80 STA &80 ; y &27b5 a6 81 LDX &81 ; width_of_outside &27b7 ca DEX &27b8 d0 d3 BNE &278d ; plot_platforms_loop &27ba a9 05 LDA #&05 &27bc 20 27 1a JSR &1a27 ; plot_stage_ladders # Plot ladders &27bf a2 24 LDX #&24 &27c1 a0 0c LDY #&0c &27c3 a9 20 LDA #&20 ; DAMSEL &27c5 20 e6 18 JSR &18e6 ; plot_double_height_sprite # Plot damsel &27c8 a0 2c LDY #&2c &27ca 8a TXA ; GORILLA_FRONT_LEFT &27cb 20 e6 18 JSR &18e6 ; plot_double_height_sprite # Plot gorilla &27ce a2 28 LDX #&28 &27d0 a0 2c LDY #&2c &27d2 a9 26 LDA #&26 ; GORILLA_FRONT_RIGHT &27d4 20 e6 18 JSR &18e6 ; plot_double_height_sprite &27d7 a2 08 LDX #&08 # Plot hammer to left of platform two &27d9 8e 00 0d STX &0d00 ; hammers_x &27dc a0 02 LDY #&02 &27de 8c 02 0d STY &0d02 ; hammers_y &27e1 20 9c 1b JSR &1b9c ; plot_hammer &27e4 a2 26 LDX #&26 # Plot hammer in middle of platform three &27e6 8e 01 0d STX &0d01 ; hammers_x + 1 &27e9 a0 03 LDY #&03 &27eb 8c 03 0d STY &0d03 ; hammers_y + 1 &27ee 20 9c 1b JSR &1b9c ; plot_hammer &27f1 a2 10 LDX #&10 # Plot collectible to left of platform four &27f3 a0 04 LDY #&04 &27f5 a9 31 LDA #&31 ; UMBRELLA, 300 &27f7 20 66 1d JSR &1d66 ; add_collectible &27fa a2 3c LDX #&3c # Plot collectible to right of platform four &27fc a0 04 LDY #&04 &27fe a9 90 LDA #&90 ; TELEPHONE, 900 &2800 20 66 1d JSR &1d66 ; add_collectible &2803 a2 14 LDX #&14 &2805 86 50 STX &50 ; player_platform_x &2807 a0 00 LDY #&00 &2809 84 51 STY &51 ; player_platform # Player starts on platform zero &280b 84 59 STY &59 ; player_has_died &280d 84 24 STY &24 ; collected_platforms_for_100m_stage # Platforms are initially uncollected &280f a9 02 LDA #&02 &2811 85 52 STA &52 ; player_feet # Player starts facing right &2813 a9 05 LDA #&05 &2815 85 5f STA &5f ; offset_of_last_fireball &2817 4c 24 1d JMP &1d24 ; make_stage_visible ; plot_blue_platform_with_yellow_end &281a 20 5e 1d JSR &1d5e ; write_y_x_times # Plot length of blue sections &281d a9 03 LDA #&03 ; Y &281f 20 f0 1c JSR &1cf0 ; set_text_colour_a &2822 98 TYA ; PLATFORM_DIAMOND &2823 20 ee ff JSR &ffee ; OSWRCH # then single yellow section &2826 a9 04 LDA #&04 ; B &2828 4c f0 1c JMP &1cf0 ; set_text_colour_a ; check_for_platform_25m &282b 98 TYA &282c 29 01 AND #&01 &282e f0 15 BEQ &2845 ; even_platforms ; odd_platforms # Odd (sloping up to the left) platforms: &2830 a5 67 LDA &67 ; level &2832 c9 03 CMP #&03 &2834 90 0c BCC &2842 ; consider_gap_to_right_of_platform # have no holes on levels one or two &2836 c0 05 CPY #&05 &2838 f0 08 BEQ &2842 ; consider_gap_to_right_of_platform # The platform with the gorilla never has any holes &283a e0 13 CPX #&13 &283c 90 42 BCC &2880 ; leave_with_carry_clear # A hole &13 <= x < &16 on level three and above &283e e0 16 CPX #&16 &2840 90 1a BCC &285c ; leave_with_carry_set ; consider_gap_to_right_of_platform &2842 e0 3d CPX #&3d &2844 60 RTS ; even_platforms # Even (sloping up to the right) platforms: &2845 98 TYA &2846 f0 0e BEQ &2856 ; consider_gap_to_left_of_platform # Platform zero has no holes &2848 a5 67 LDA &67 ; level &284a c9 01 CMP #&01 &284c f0 08 BEQ &2856 ; consider_gap_to_left_of_platform # Even platforms have no holes on level one &284e e0 3a CPX #&3a &2850 b0 2e BCS &2880 ; leave_with_carry_clear &2852 e0 36 CPX #&36 &2854 b0 06 BCS &285c ; leave_with_carry_set # but have a hole &36 <= x < &3a on level two and above ; consider_gap_to_left_of_platform &2856 e0 0f CPX #&0f &2858 90 02 BCC &285c ; leave_with_carry_set &285a 18 CLC # If there is a platform, leave with carry clear &285b 60 RTS ; leave_with_carry_set &285c 38 SEC # If there is a hole, leave with carry set &285d 60 RTS ; check_for_platform_50m &285e c0 02 CPY #&02 &2860 d0 12 BNE &2874 ; not_middle_platform &2862 e0 12 CPX #&12 &2864 90 1a BCC &2880 ; leave_with_carry_clear # Platform two has a hole &12 <= x < &17 &2866 e0 17 CPX #&17 &2868 90 f2 BCC &285c ; leave_with_carry_set &286a e0 36 CPX #&36 &286c 90 12 BCC &2880 ; leave_with_carry_clear # and a second hole &36 <= x < &3b &286e e0 3b CPX #&3b &2870 90 ea BCC &285c ; leave_with_carry_set &2872 18 CLC &2873 60 RTS ; not_middle_platform &2874 c0 03 CPY #&03 &2876 d0 08 BNE &2880 ; leave_with_carry_clear # Platforms zero, one, four and five have no holes &2878 e0 23 CPX #&23 &287a 90 04 BCC &2880 ; leave_with_carry_clear # Platform three has a hole &23 <= x < &2d &287c e0 2d CPX #&2d &287e 90 dc BCC &285c ; leave_with_carry_set ; leave_with_carry_clear &2880 18 CLC &2881 60 RTS ; check_for_platform_100m &2882 98 TYA &2883 f0 fb BEQ &2880 ; leave_with_carry_clear # Platform zero has no holes &2885 0a ASL A &2886 0a ASL A &2887 38 SEC &2888 e9 02 SBC #&02 &288a 85 80 STA &80 ; offset &288c e4 80 CPX &80 ; offset &288e 90 cc BCC &285c ; leave_with_carry_set # Other platforms have holes to their left &2890 a9 4b LDA #&4b &2892 e5 80 SBC &80 ; offset &2894 86 80 STX &80 ; x &2896 c5 80 CMP &80 ; x &2898 90 c2 BCC &285c ; leave_with_carry_set # And holes to their right &289a a5 24 LDA &24 ; collected_platforms_for_100m_stage &289c 85 80 STA &80 ; platform_bits &289e 88 DEY &289f f0 07 BEQ &28a8 ; consider_left_collectible_platform ; find_bits_corresponding_to_platform_loop # Two bits per platform, starting at platform one &28a1 46 80 LSR &80 ; platform_bits &28a3 46 80 LSR &80 ; platform_bits &28a5 88 DEY &28a6 d0 f9 BNE &28a1 ; find_bits_corresponding_to_platform_loop ; consider_left_collectible_platform &28a8 e0 12 CPX #&12 &28aa 90 d4 BCC &2880 ; leave_with_carry_clear &28ac e0 17 CPX #&17 &28ae b0 08 BCS &28b8 ; consider_right_collectible_platform &28b0 a5 80 LDA &80 ; platform_bits # If the lowest bit of the two bits is set, &28b2 29 01 AND #&01 &28b4 f0 ca BEQ &2880 ; leave_with_carry_clear &28b6 38 SEC # Leave with carry set; left platform is a hole &28b7 60 RTS ; consider_right_collectible_platform &28b8 e0 36 CPX #&36 &28ba 90 c4 BCC &2880 ; leave_with_carry_clear &28bc e0 3b CPX #&3b &28be b0 c0 BCS &2880 ; leave_with_carry_clear &28c0 a5 80 LDA &80 ; platform_bits # If the highest of the two bits is set, &28c2 29 02 AND #&02 &28c4 f0 ba BEQ &2880 ; leave_with_carry_clear &28c6 38 SEC # Leave with carry set; right platform is a hole &28c7 60 RTS ; calculate_platform_y_50m &28c8 98 TYA &28c9 0a ASL A &28ca 0a ASL A &28cb 0a ASL A &28cc 0a ASL A &28cd 85 80 STA &80 ; y_times_sixteen &28cf 0a ASL A &28d0 18 CLC &28d1 65 80 ADC &80 ; y_times_sixteen &28d3 85 80 STA &80 ; y_times_forty &28d5 a9 e4 LDA #&e4 &28d7 38 SEC &28d8 e5 80 SBC &80 ; y_times_forty &28da a8 TAY &28db 60 RTS ; calculate_platform_y_100m &28dc 98 TYA &28dd 0a ASL A &28de 0a ASL A &28df 0a ASL A &28e0 0a ASL A &28e1 85 80 STA &80 ; y_times_sixteen &28e3 0a ASL A &28e4 18 CLC &28e5 65 80 ADC &80 ; y_times_sixteen &28e7 85 80 STA &80 ; y_times_sixteen &28e9 a9 ec LDA #&ec &28eb 38 SEC &28ec e5 80 SBC &80 ; y_times_forty &28ee a8 TAY &28ef 60 RTS ; update_enemies_50m &28f0 20 8d 2b JSR &2b8d ; check_level_based_speed &28f3 90 03 BCC &28f8 ; enemies_active_this_frame &28f5 4c 96 29 JMP &2996 ; skip_new_pie_and_conveyors ; enemies_active_this_frame &28f8 a6 53 LDX &53 ; number_of_lower_enemies &28fa e0 05 CPX #&05 &28fc f0 3e BEQ &293c ; no_new_pie # Maximum of five pies &28fe 20 ff 19 JSR &19ff ; get_random_number &2901 29 1f AND #&1f &2903 d0 37 BNE &293c ; no_new_pie # 1 in 32 chance of a new pie appearing ; new_pie &2905 e6 53 INC &53 ; number_of_lower_enemies &2907 20 ff 19 JSR &19ff ; get_random_number &290a a4 53 LDY &53 ; number_of_lower_enemies &290c a2 00 LDX #&00 &290e 29 01 AND #&01 &2910 38 SEC &2911 2a ROL A &2912 99 0e 0d STA &0d0e,Y ; enemies_platform - 1 # Choose randomly between platforms one and three, &2915 a0 b4 LDY #&b4 &2917 c9 01 CMP #&01 &2919 f0 0b BEQ &2926 ; new_pie_on_platform_one &291b a0 54 LDY #&54 # If the pie is on platform three, &291d 20 ff 19 JSR &19ff ; get_random_number &2920 29 01 AND #&01 &2922 f0 08 BEQ &292c ; plot_new_pie # Choose randomly between left and right edge of screen &2924 a2 4c LDX #&4c ; new_pie_on_platform_one # If the pie is on platform one, &2926 a5 27 LDA &27 ; conveyor_direction &2928 f0 02 BEQ &292c ; plot_new_pie &292a a2 4c LDX #&4c # use the conveyor direction to choose ; plot_new_pie &292c a9 1b LDA #&1b ; PIE &292e 20 22 19 JSR &1922 ; plot_single_height_sprite &2931 a4 53 LDY &53 ; number_of_lower_enemies &2933 8a TXA &2934 99 03 0d STA &0d03,Y ; enemies_x - 1 &2937 a9 00 LDA #&00 &2939 99 19 0d STA &0d19,Y ; enemies_platform_offset - 1 ; no_new_pie ; handle_player_on_platform_three_conveyors &293c a5 51 LDA &51 ; player_platform &293e c9 03 CMP #&03 &2940 d0 2d BNE &296f ; handle_player_on_platform_one_conveyor # If the player is on platform three, &2942 a5 58 LDA &58 ; player_jump_timer &2944 05 56 ORA &56 ; player_platform_offset &2946 d0 27 BNE &296f ; handle_player_on_platform_one_conveyor # and the player isn't jumping or climbing, &2948 20 0b 1b JSR &1b0b ; plot_player_depending_on_state # unplot the player &294b a6 50 LDX &50 ; player_platform_x &294d e8 INX # The left side conveyor moves the player right &294e e0 24 CPX #&24 &2950 90 18 BCC &296a ; convey_player_on_platform_three # Has the player reached the right edge? &2952 d0 07 BNE &295b ; right_side_conveyor &2954 a5 59 LDA &59 ; player_has_died # A dead player doesn't fall off the edge &2956 d0 14 BNE &296c ; replot_player_after_being_conveyed_on_platform_three &2958 4c 37 13 JMP &1337 ; check_for_absence_of_platform_to_right # Otherwise, handle the hole on the right edge ; right_side_conveyor &295b ca DEX # The right side conveyor moves the player left &295c ca DEX &295d e0 2b CPX #&2b # Has the player reached the left edge? &295f 90 0b BCC &296c ; replot_player_after_being_conveyed_on_platform_three &2961 d0 07 BNE &296a ; convey_player_on_platform_three &2963 a5 59 LDA &59 ; player_has_died # A dead player doesn't fall off the edge &2965 d0 05 BNE &296c ; replot_player_after_being_conveyed_on_platform_three &2967 4c 0d 13 JMP &130d ; check_for_absence_of_platform_to_left # Otherwise, handle the hole on the left edge ; convey_player_on_platform_three &296a 86 50 STX &50 ; player_platform_x ; replot_player_after_being_conveyed_on_platform_three &296c 20 0b 1b JSR &1b0b ; plot_player_depending_on_state # Replot player ; handle_player_on_platform_one_conveyor &296f a5 51 LDA &51 ; player_platform &2971 c9 01 CMP #&01 &2973 d0 21 BNE &2996 ; skip_new_pie_and_conveyors # If the player is on platform one, &2975 a5 58 LDA &58 ; player_jump_timer &2977 05 56 ORA &56 ; player_platform_offset &2979 d0 1b BNE &2996 ; skip_new_pie_and_conveyors # and the player isn't jumping or climbing, &297b 20 0b 1b JSR &1b0b ; plot_player_depending_on_state # unplot the player &297e a5 27 LDA &27 ; conveyor_direction &2980 f0 09 BEQ &298b ; conveyor_moving_right &2982 a5 50 LDA &50 ; player_platform_x # If the conveyor is moving left, &2984 f0 0d BEQ &2993 ; replot_player_after_being_conveyed # and the player isn't at the left of the screen, &2986 c6 50 DEC &50 ; player_platform_x # move the player left &2988 4c 93 29 JMP &2993 ; replot_player_after_being_conveyed ; conveyor_moving_right &298b a5 50 LDA &50 ; player_platform_x # If the conveyor is moving right, &298d c9 4c CMP #&4c &298f f0 02 BEQ &2993 ; replot_player_after_being_conveyed # and the player isn't at the right of the screen, &2991 e6 50 INC &50 ; player_platform_x # move the player right ; replot_player_after_being_conveyed_on_platform_one &2993 20 0b 1b JSR &1b0b ; plot_player_depending_on_state # Replot player ; skip_new_pie_and_conveyors &2996 a6 53 LDX &53 ; number_of_lower_enemies &2998 f0 06 BEQ &29a0 ; no_pies ; update_pies_loop # Update any pies &299a 20 86 25 JSR &2586 ; update_pie &299d ca DEX &299e d0 fa BNE &299a ; update_pies_loop ; no_pies &29a0 a9 a0 LDA #&a0 &29a2 85 82 STA &82 ; ladder_screen_address_low &29a4 a9 41 LDA #&41 ; &41a0 = screen address of top left of left ladder &29a6 85 83 STA &83 ; ladder_screen_address_high &29a8 a5 68 LDA &68 ; left_ladder_top &29aa 20 cf 25 JSR &25cf ; update_50m_ladder_top # Update ladder to left of platform three &29ad 85 68 STA &68 ; left_ladder_top &29af a9 c0 LDA #&c0 &29b1 85 82 STA &82 ; ladder_screen_address_low &29b3 a9 43 LDA #&43 ; &43c0 = screen address of top left of right ladder &29b5 85 83 STA &83 ; ladder_screen_address_high &29b7 a5 69 LDA &69 ; right_ladder_top &29b9 20 cf 25 JSR &25cf ; update_50m_ladder_top # Update ladder to right of platform three &29bc 85 69 STA &69 ; right_ladder_top &29be a5 23 LDA &23 ; frame_counter &29c0 c9 3c CMP #&3c &29c2 d0 33 BNE &29f7 ; skip_new_fireball # Every 64 frames, consider adding a new fireball &29c4 a5 67 LDA &67 ; level &29c6 18 CLC &29c7 69 05 ADC #&05 # Maximum number of fireballs is (level + 1), up to 5 &29c9 c9 0a CMP #&0a &29cb 90 02 BCC &29cf ; skip_ceiling &29cd a9 09 LDA #&09 ; skip_ceiling &29cf c5 5f CMP &5f ; offset_of_last_fireball &29d1 90 24 BCC &29f7 ; skip_new_fireball &29d3 a4 5f LDY &5f ; offset_of_last_fireball &29d5 a9 00 LDA #&00 &29d7 85 23 STA &23 ; frame_counter &29d9 99 1a 0d STA &0d1a,Y ; enemies_platform_offset &29dc 20 ff 19 JSR &19ff ; get_random_number &29df 29 80 AND #&80 # Choose randomly between moving left and right &29e1 09 26 ORA #&26 # from middle of platform three &29e3 aa TAX &29e4 99 04 0d STA &0d04,Y ; enemies_x &29e7 a9 03 LDA #&03 &29e9 99 0f 0d STA &0d0f,Y ; enemies_platform &29ec e6 5f INC &5f ; offset_of_last_fireball &29ee a8 TAY &29ef 20 eb 19 JSR &19eb ; calculate_platform_y &29f2 a9 16 LDA #&16 ; FIREBALL &29f4 20 22 19 JSR &1922 ; plot_single_height_sprite ; skip_new_fireball &29f7 20 ff 19 JSR &19ff ; get_random_number &29fa 29 7f AND #&7f # 1 in 128 chance of changing direction of conveyor &29fc d0 06 BNE &2a04 ; skip_changing_conveyor_direction &29fe a5 27 LDA &27 ; conveyor_direction &2a00 49 01 EOR #&01 &2a02 85 27 STA &27 ; conveyor_direction ; skip_changing_conveyor_direction &2a04 4c 9e 14 JMP &149e ; update_fireballs # Update fireballs ; update_enemies_100m &2a07 a9 00 LDA #&00 &2a09 38 SEC &2a0a a4 51 LDY &51 ; player_platform &2a0c d0 03 BNE &2a11 ; platform_with_collectable_sections &2a0e 4c 82 2a JMP &2a82 ; skip_checking_for_collectable_platforms ; platform_with_collectable_sections # If the player is on a platform with collectible &2a11 2a ROL A # sections, calculate a bit corresponding to the &2a12 2a ROL A # first collectible section on that platform. &2a13 88 DEY &2a14 d0 fb BNE &2a11 ; platform_with_collectable_sections &2a16 85 80 STA &80 ; bit_of_platform &2a18 a6 50 LDX &50 ; player_platform_x &2a1a e0 11 CPX #&11 # If the player is at the left of the left section, &2a1c d0 04 BNE &2a22 ; not_left_edge_of_left_section &2a1e a5 5e LDA &5e ; player_horizontal_speed &2a20 30 0d BMI &2a2f ; consider_removing_left_section # and is moving left, ; not_left_edge_of_left_section &2a22 e0 17 CPX #&17 # or is at the right of the left section, &2a24 d0 0f BNE &2a35 ; not_right_edge_of_left_section &2a26 a5 5e LDA &5e ; player_horizontal_speed &2a28 c9 01 CMP #&01 &2a2a f0 03 BEQ &2a2f ; consider_removing_left_section # and is moving right, &2a2c 4c 82 2a JMP &2a82 ; skip_checking_for_collectable_platforms ; consider_removing_left_section &2a2f 46 80 LSR &80 ; bit_of_platform &2a31 a2 06 LDX #&06 ; horizontal co-ordinate of left section &2a33 d0 14 BNE &2a49 ; consider_removing_section ; not_right_edge_of_left_section &2a35 e0 35 CPX #&35 # or the player is at the left of the right section, &2a37 d0 04 BNE &2a3d ; not_left_edge_of_right_section &2a39 a5 5e LDA &5e ; player_horizontal_speed &2a3b 30 0a BMI &2a47 ; consider_removing_right_section # and is moving left, ; not_left_edge_of_right_section &2a3d e0 3b CPX #&3b &2a3f d0 41 BNE &2a82 ; skip_checking_for_collectable_platforms # or is at the right of the right section &2a41 a5 5e LDA &5e ; player_horizontal_speed &2a43 c9 01 CMP #&01 &2a45 d0 3b BNE &2a82 ; skip_checking_for_collectable_platforms # and moving right, ; consider_removing_right_section &2a47 a2 0f LDX #&0f ; horizontal co-ordinate of right section ; consider_removing_section &2a49 a5 24 LDA &24 ; collected_platforms_for_100m_stage &2a4b 25 80 AND &80 ; bit_of_platform &2a4d d0 33 BNE &2a82 ; skip_checking_for_collectable_platforms # then, if the platform hasn't already been collected, &2a4f a9 1f LDA #&1f &2a51 20 ee ff JSR &ffee ; OSWRCH &2a54 8a TXA &2a55 20 ee ff JSR &ffee ; OSWRCH &2a58 a5 51 LDA &51 ; player_platform &2a5a 0a ASL A &2a5b 85 81 STA &81 ; y &2a5d 0a ASL A &2a5e 18 CLC &2a5f 65 81 ADC &81 ; y &2a61 85 81 STA &81 ; y &2a63 a9 1f LDA #&1f &2a65 38 SEC &2a66 e5 81 SBC &81 ; y &2a68 20 ee ff JSR &ffee ; OSWRCH &2a6b a9 7f LDA #&7f &2a6d 20 ee ff JSR &ffee ; OSWRCH # Remove the section from the screen &2a70 a9 01 LDA #&01 &2a72 20 6e 1b JSR &1b6e ; add_to_score # Score 100 points for collecting section &2a75 20 8b 16 JSR &168b ; play_sound_0 &2a78 a5 24 LDA &24 ; collected_platforms_for_100m_stage &2a7a 05 80 ORA &80 ; bit_of_platform # Mark the platform as collected in the bits &2a7c 85 24 STA &24 ; collected_platforms_for_100m_stage &2a7e c9 ff CMP #&ff &2a80 f0 5a BEQ &2adc ; stage_100m_completion # Complete the stage if all sections collected ; skip_checking_for_collectable_platforms &2a82 a5 59 LDA &59 ; player_has_died &2a84 d0 13 BNE &2a99 ; skip_checking_for_gorilla_collision &2a86 a5 51 LDA &51 ; player_platform &2a88 c9 04 CMP #&04 &2a8a d0 0d BNE &2a99 ; skip_checking_for_gorilla_collision &2a8c a5 50 LDA &50 ; player_platform_x &2a8e c9 20 CMP #&20 &2a90 90 07 BCC &2a99 ; skip_checking_for_gorilla_collision &2a92 c9 2c CMP #&2c &2a94 b0 03 BCS &2a99 ; skip_checking_for_gorilla_collision &2a96 4c 0b 1e JMP &1e0b ; kill_player # Kill the player if they touch the gorilla ; skip_checking_for_gorilla_collision &2a99 a6 5f LDX &5f ; offset_of_last_fireball &2a9b e0 0a CPX #&0a &2a9d f0 3a BEQ &2ad9 ; to_update_fireballs # If there are fewer than five fireballs on screen, &2a9f e0 07 CPX #&07 &2aa1 90 07 BCC &2aaa ; guaranteed_fireball &2aa3 20 ff 19 JSR &19ff ; get_random_number &2aa6 29 3f AND #&3f # 1 in 64 chance of adding another, after first two &2aa8 d0 2f BNE &2ad9 ; to_update_fireballs ; guaranteed_fireball &2aaa a9 00 LDA #&00 &2aac 9d 1a 0d STA &0d1a,X ; enemies_platform_offset &2aaf 20 ff 19 JSR &19ff ; get_random_number &2ab2 29 03 AND #&03 # Pick a random platform between zero and three &2ab4 9d 0f 0d STA &0d0f,X ; enemies_platform &2ab7 a8 TAY &2ab8 0a ASL A &2ab9 0a ASL A &2aba 85 80 STA &80 ; x &2abc a5 50 LDA &50 ; player_platform_x &2abe c9 26 CMP #&26 &2ac0 b0 07 BCS &2ac9 ; player_to_right_of_platform # Put the fireball on the edge furthest from the player &2ac2 a9 ca LDA #&ca &2ac4 38 SEC &2ac5 e5 80 SBC &80 ; x &2ac7 85 80 STA &80 ; x ; player_to_right_of_platform &2ac9 a5 80 LDA &80 ; x &2acb 9d 04 0d STA &0d04,X ; enemies_x &2ace aa TAX &2acf 20 eb 19 JSR &19eb ; calculate_platform_y &2ad2 a9 16 LDA #&16 ; FIREBALL &2ad4 20 22 19 JSR &1922 ; plot_single_height_sprite # Plot the new fireball &2ad7 e6 5f INC &5f ; offset_of_last_fireball ; to_update_fireballs &2ad9 4c 9e 14 JMP &149e ; update_fireballs ; stage_100m_completion &2adc a9 02 LDA #&02 &2ade 8d d0 0d STA &0dd0 ; sound_1_channel_high # Synchronise three channels &2ae1 a2 04 LDX #&04 ; play_collapse_melody_loop # Play "collapse" melody &2ae3 bd cf 10 LDA &10cf,X ; collapse_melody_notes_duration - 1 &2ae6 a8 TAY &2ae7 bd cb 10 LDA &10cb,X ; collapse_melody_notes_pitch - 1 &2aea 48 PHA &2aeb 20 ce 1d JSR &1dce ; play_sound_with_pitch_and_duration # Play each note as a chord on channels 1 to 3 &2aee 68 PLA &2aef 48 PHA &2af0 38 SEC &2af1 e9 14 SBC #&14 &2af3 ee cf 0d INC &0dcf ; sound_1_channel &2af6 20 d1 1d JSR &1dd1 ; play_sound_with_pitch_and_previous_duration &2af9 68 PLA &2afa 38 SEC &2afb e9 20 SBC #&20 &2afd ee cf 0d INC &0dcf ; sound_1_channel &2b00 20 d1 1d JSR &1dd1 ; play_sound_with_pitch_and_previous_duration &2b03 a9 01 LDA #&01 &2b05 8d cf 0d STA &0dcf ; sound_1_channel &2b08 ca DEX &2b09 d0 d8 BNE &2ae3 ; play_collapse_melody_loop &2b0b 8e d0 0d STX &0dd0 ; sound_1_channel_high # Reset synchronisation &2b0e 20 0b 1b JSR &1b0b ; plot_player_depending_on_state &2b11 a2 06 LDX #&06 ; write_clear_window_loop # Clear the middle of the stage &2b13 bd b9 0f LDA &0fb9,X ; clear_window_string &2b16 20 ee ff JSR &ffee ; OSWRCH &2b19 ca DEX &2b1a 10 f7 BPL &2b13 ; write_clear_window_loop &2b1c a9 0a LDA #&0a &2b1e 20 da 19 JSR &19da ; delay_for_a &2b21 a0 2c LDY #&2c ; drop_gorilla_loop # Drop gorilla &2b23 98 TYA &2b24 48 PHA &2b25 a9 24 LDA #&24 ; GORILLA_FRONT_LEFT &2b27 aa TAX &2b28 20 e6 18 JSR &18e6 ; plot_double_height_sprite # Unplot gorilla &2b2b 68 PLA &2b2c 48 PHA &2b2d a8 TAY &2b2e a9 26 LDA #&26 ; GORILLA_FRONT_RIGHT &2b30 a2 28 LDX #&28 &2b32 20 e6 18 JSR &18e6 ; plot_double_height_sprite &2b35 68 PLA &2b36 18 CLC &2b37 69 08 ADC #&08 &2b39 48 PHA &2b3a a8 TAY &2b3b a9 24 LDA #&24 ; GORILLA_FRONT_LEFT &2b3d aa TAX &2b3e 20 e6 18 JSR &18e6 ; plot_double_height_sprite # Replot gorilla eight pixels further down &2b41 68 PLA &2b42 48 PHA &2b43 a8 TAY &2b44 a9 26 LDA #&26 ; GORILLA_FRONT_RIGHT &2b46 a2 28 LDX #&28 &2b48 20 e6 18 JSR &18e6 ; plot_double_height_sprite &2b4b 20 8c 14 JSR &148c ; wait_for_via_timer &2b4e 68 PLA &2b4f a8 TAY &2b50 c0 ec CPY #&ec &2b52 d0 cf BNE &2b23 ; drop_gorilla_loop &2b54 a5 65 LDA &65 ; bonus_hundreds &2b56 20 6e 1b JSR &1b6e ; add_to_score # Add bonus to score &2b59 a9 3d LDA #&3d &2b5b a0 05 LDY #&05 &2b5d 20 ce 1d JSR &1dce ; play_sound_with_pitch_and_duration &2b60 a9 0a LDA #&0a &2b62 20 da 19 JSR &19da ; delay_for_a &2b65 a2 0b LDX #&0b ; write_give_up_loop # Write "GIVE UP" &2b67 bd c0 0f LDA &0fc0,X ; give_up_string &2b6a 20 ee ff JSR &ffee ; OSWRCH &2b6d ca DEX &2b6e 10 f7 BPL &2b67 ; write_give_up_loop &2b70 a2 0b LDX #&0b ; play_give_up_melody_loop # Play "give up" melody &2b72 bd d8 0f LDA &0fd8,X ; give_up_melody_notes_duration &2b75 a8 TAY &2b76 bd cc 0f LDA &0fcc,X ; give_up_melody_notes_pitch &2b79 20 ce 1d JSR &1dce ; play_sound_with_pitch_and_duration &2b7c ca DEX &2b7d 10 f3 BPL &2b72 ; play_give_up_melody_loop &2b7f a9 23 LDA #&23 &2b81 20 da 19 JSR &19da ; delay_for_a &2b84 a9 ff LDA #&ff &2b86 85 25 STA &25 ; stage &2b88 e6 67 INC &67 ; level &2b8a 4c 9a 18 JMP &189a ; advance_to_next_stage # Start the next level at 25m stage ; check_level_based_speed &2b8d a5 23 LDA &23 ; frame_counter &2b8f a6 67 LDX &67 ; level &2b91 e0 03 CPX #&03 &2b93 90 02 BCC &2b97 ; level_one_or_two ; leave_with_carry_clear &2b95 18 CLC # On level three, always leave with carry clear &2b96 60 RTS ; level_one_or_two &2b97 29 03 AND #&03 &2b99 f0 07 BEQ &2ba2 ; leave_with_carry_set &2b9b e0 02 CPX #&02 # On level two, &2b9d f0 f6 BEQ &2b95 ; leave_with_carry_clear # Leave with carry clear three frames out of four &2b9f 4a LSR A # On level one, &2ba0 b0 f3 BCS &2b95 ; leave_with_carry_clear # Leave with carry clear two frames out of four ; leave_with_carry_set &2ba2 38 SEC &2ba3 60 RTS ; unused # Source code fragment corresponding to &0fdf - &0fe3 &2ba4 2c 37 2c 32 32 2c 37 2c 32 32 2c 37 0d 01 d6 0e ; ,7,22,7,22,7 &2bb4 f2 52 28 65 6f 66 2c 31 35 29 0d 01 e0 33 dc 38 ; 470 PROC R(eof,15) &2bc4 31 2c 31 30 31 2c 31 31 37 2c 31 32 39 2c 31 31 ; 480 DATA 81,101,117,129,117,129,14 # and &0f71 - &0f77 &2bd4 37 2c 31 32 39 2c 31 34 ; sprite_data_two ; sprite &15 - BARREL_FRONT &2bdc 00 00 00 00 00 00 00 00 01 03 03 02 0b 03 03 07 &2bec 0f 0f 0f 0f 0b 03 03 07 0b 03 03 07 0f 0f 0f 0f &2bfc 0b 03 03 07 0b 03 03 07 0f 0f 0f 0f 01 03 03 02 ; sprite &16 - FIREBALL &2c0c 02 00 02 01 03 00 02 03 03 01 03 02 01 01 25 02 &2c1c 01 12 25 02 01 25 0b 03 03 30 25 03 07 0f 30 03 &2c2c 03 1a 30 02 01 03 21 02 01 03 03 00 00 03 03 00 ; sprite &17 - PLAYER_DEAD &2c3c 05 0f 00 00 0a 00 0a 00 05 0f 00 03 00 00 00 11 &2c4c 00 00 22 11 00 00 22 11 02 00 0a 11 02 22 0a 11 &2c5c 13 33 0a 04 13 33 0f 0c 03 33 0f 0c 01 02 0f 0c ; sprite &18 - OIL_DRUM &2c6c 01 00 02 02 01 02 0b 03 00 03 07 03 00 01 07 02 &2c7c 00 03 0f 02 00 07 0f 02 01 07 25 02 01 1a 25 03 &2c8c 01 1a 25 03 01 1a 25 02 3c 3c 3c 3c 3c 3c 3c 3c &2c9c 05 0f 0f 0a 14 3c 3c 28 14 0f 0f 28 14 0f 0f 28 &2cac 14 0f 0f 28 14 0f 0f 28 14 0f 0f 28 14 0f 0f 28 &2cbc 14 3c 3c 28 05 0f 0f 0a 3c 3c 3c 3c 3c 3c 3c 3c ; sprite &1a - SMASHED &2ccc 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 &2cdc 00 00 00 00 00 00 00 00 0a 00 00 0a 05 00 05 00 &2cec 00 0a 0a 00 0a 00 00 0a 05 00 05 00 00 0a 0a 00 ; sprite &1b - PIE &2cfc 00 00 00 00 00 00 00 00 00 00 00 00 00 05 0a 00 &2d0c 00 0f 0f 00 05 0b 0f 0a 05 07 0b 0a 0f 07 07 07 &2d1c 0b 0f 0f 0f 3c 3e 3c 3c 14 3d 3c 28 00 3c 3c 00 ; sprite &1c - TELEPHONE &2d2c 00 00 00 00 11 33 33 22 33 02 01 33 22 13 23 11 &2d3c 33 11 22 33 33 11 22 33 00 37 3b 00 00 3e 3d 00 &2d4c 11 3e 3d 22 11 37 3b 22 11 33 33 22 11 33 33 22 ; sprite &1d - UMBRELLA &2d5c 00 03 03 00 01 03 03 02 03 03 03 03 02 01 02 01 &2d6c 00 00 0a 00 00 00 0a 00 00 00 0a 00 00 00 0a 00 &2d7c 00 00 0a 00 00 00 0a 00 00 0a 0a 00 00 05 00 00 ; sprite &1e - HAT &2d8c 00 00 00 00 00 00 00 00 00 00 00 15 00 14 28 3f &2d9c 00 3c 3c 3f 00 3c 2d 2a 00 3c 3d 00 00 3c 3d 00 &2dac 28 0f 0f 14 2d 0f 0f 3c 2d 3c 3c 3c 05 3c 14 28 ; sprite &1f - HANDBAG &2dbc 00 00 00 0c 00 00 04 04 00 00 08 04 00 04 00 08 &2dcc 00 04 00 08 00 08 04 00 00 08 04 00 01 21 12 02 &2ddc 01 21 12 02 01 21 12 02 01 30 1a 02 01 03 03 02 ; sprite &20 - DAMSEL &2dec 00 00 00 00 00 0f 0a 00 05 0f 0f 00 05 31 25 00 &2dfc 05 13 07 00 05 23 27 00 0a 15 00 0a 14 3e 3e 00 &2e0c 3f 3d 3d 2a 2a 3f 2a 2a 2a 3f 2a 2a 2a 3f 2a 2a &2e1c 22 3f 2a 22 22 03 02 22 00 3f 2a 00 15 3f 3f 00 &2e2c 15 3f 3f 00 15 3f 3f 00 15 3f 3f 00 3e 3e 3e 2a &2e3c 3d 3d 3d 28 00 22 22 00 00 22 22 00 11 22 33 00 ; sprite &22 - GIRDER &2e4c 3c 3c 3c 28 3c 3c 3c 28 00 14 00 00 00 14 00 00 &2e5c 00 14 00 00 00 14 00 00 00 14 00 00 00 14 00 00 &2e6c 00 14 00 00 00 14 00 00 00 14 00 00 00 14 00 00 &2e7c 00 14 00 00 00 14 00 00 00 14 00 00 00 14 00 00 &2e8c 3c 3c 3c 28 3c 3c 3c 28 00 00 00 00 00 00 00 00 &2e9c 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ; sprite &24 - GORILLA_FRONT_LEFT &2eac 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 &2ebc 00 00 00 00 00 00 00 00 00 01 11 33 00 13 17 3b &2ecc 01 13 17 20 01 03 13 22 01 03 33 33 03 03 37 15 &2edc 03 03 13 33 03 03 03 03 03 02 03 33 03 02 13 33 &2eec 03 02 13 33 01 13 33 33 01 13 33 33 00 13 13 33 &2efc 00 00 03 33 00 01 03 03 00 01 03 02 00 33 33 22 ; sprite &26 - GORILLA_FRONT_RIGHT &2f0c 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 &2f1c 00 00 00 00 00 00 00 00 33 22 02 00 37 2b 23 00 &2f2c 10 2b 23 02 11 23 03 02 33 33 03 02 15 11 03 03 &2f3c 33 23 03 03 03 03 03 03 33 03 01 03 33 23 01 03 &2f4c 33 23 01 03 33 33 23 02 33 33 23 02 33 23 23 00 &2f5c 33 03 00 00 03 03 02 00 01 03 02 00 11 33 33 00 ; sprite &28 - LIFT &2f6c 00 00 00 00 00 00 00 00 03 03 03 03 33 33 33 33 &2f7c 00 11 22 00 00 22 11 00 00 22 11 00 11 00 00 22 &2f8c 11 00 00 22 22 00 00 11 33 33 33 33 03 03 03 03 ; small_number_sprites &2f9c ff aa aa aa aa aa aa aa ff aa ; 0 &2fa6 55 00 ff 00 55 00 55 00 ff aa ; 1 &2fb0 ff aa 00 aa ff aa aa 00 ff aa ; 2 &2fba ff aa 00 aa ff aa 00 aa ff aa ; 3 &2fc4 aa aa aa aa ff aa 00 aa 00 aa ; 4 &2fce ff aa aa 00 ff aa 00 aa ff aa ; 5 &2fd8 ff aa aa 00 ff aa aa aa ff aa ; 6 &2fe2 ff aa 00 aa 00 aa 00 aa 00 aa ; 7 &2fec ff aa aa aa ff aa aa aa ff aa ; 8 &2ff6 ff aa aa aa ff aa 00 aa ff aa ; 9 ; copied to &0400 - &07ff ; unrelocated_sprite_data_one ; sprite &00 - PLAYER_RIGHT_HEAD &3000 00 00 00 00 00 00 00 00 00 03 02 00 01 03 03 02 &3010 01 17 2a 00 01 37 31 00 01 33 33 00 00 33 22 00 &3020 00 11 00 00 00 05 00 00 00 0f 0a 00 00 1a 0f 1b ; sprite &01 - PLAYER_LEFT_HEAD &3030 00 00 00 00 00 00 00 00 00 01 03 00 01 03 03 02 &3040 00 15 2b 02 00 32 3b 02 00 33 33 02 00 11 33 00 &3050 00 00 22 00 00 00 0a 00 00 05 0f 00 27 0f 25 00 ; sprite &02 - PLAYER_RIGHT_FEET &3060 00 0f 25 1b 00 0f 0a 00 00 0c 08 00 00 0c 08 00 &3070 00 0c 0c 00 00 08 04 22 00 08 00 22 00 22 00 22 &3080 00 22 00 22 00 22 00 03 00 22 00 00 00 03 00 00 ; sprite &03 - PLAYER_LEFT_FEET &3090 27 1a 0f 00 00 05 0f 00 00 04 0c 00 00 04 0c 00 &30a0 00 0c 0c 00 11 08 04 00 11 00 04 00 11 00 11 00 &30b0 11 00 11 00 03 00 11 00 00 00 11 00 00 00 03 00 ; sprite &04 - PLAYER_RIGHT_FEET_2 &30c0 00 0f 25 1b 00 0f 0a 00 00 0c 08 00 00 0c 08 00 &30d0 00 08 08 00 00 08 08 00 00 22 08 00 11 22 22 00 &30e0 13 00 22 00 02 00 22 00 01 00 22 00 00 00 03 00 ; sprite &05 - PLAYER_LEFT_FEET_2 &30f0 27 1a 0f 00 00 05 0f 00 00 04 0c 00 00 04 0c 00 &3100 00 04 04 00 00 04 04 00 00 04 11 00 00 11 11 22 &3110 00 11 00 23 00 11 00 01 00 11 00 02 00 03 00 00 ; sprite &06 - PLAYER_RIGHT_FEET_3 &3120 00 0f 25 1b 00 0f 0a 00 00 0c 08 00 00 0c 0c 22 &3130 00 08 00 22 00 08 00 22 00 22 00 22 13 22 00 22 &3140 02 00 00 22 02 00 00 03 00 00 00 00 00 00 00 00 ; sprite &07 - PLAYER_LEFT_FEET_3 &3150 27 1a 0f 00 00 05 0f 00 00 04 0c 00 11 0c 0c 00 &3160 11 00 04 00 11 00 04 00 11 00 11 00 11 00 11 23 &3170 11 00 00 01 03 00 00 01 00 00 00 00 00 00 00 00 ; sprite &08 - PLAYER_CLIMBING_HEAD &3180 00 00 00 00 00 00 00 00 00 03 02 22 01 03 03 22 &3190 01 03 03 0a 01 03 03 0a 23 03 03 0a 22 33 22 0a &31a0 0a 11 00 0a 0f 0f 0f 0a 0f 0f 0f 00 00 0f 0a 00 ; sprite &09 - PLAYER_CLIMBING_FEET &31b0 00 0f 0a 00 00 0f 0a 00 00 0c 08 00 00 0c 08 00 &31c0 00 08 08 00 00 08 22 00 00 22 22 00 00 22 22 00 &31d0 00 22 02 00 00 22 03 00 00 02 00 00 01 02 00 00 ; sprite &0a - PLAYER_CLIMBING_HEAD_2 &31e0 00 00 00 00 00 00 00 00 22 03 02 00 23 03 03 00 &31f0 0b 03 03 00 0b 03 03 00 0b 03 03 22 0a 33 22 22 &3200 0a 11 00 0a 0f 0f 0f 0a 05 0f 0f 0a 00 0f 0a 00 ; sprite &0b - PLAYER_CLIMBING_FEET_2 &3210 00 0f 0a 00 00 0f 0a 00 00 0c 08 00 00 0c 08 00 &3220 00 08 08 00 00 22 08 00 00 22 22 00 00 22 22 00 &3230 00 02 22 00 01 02 22 00 00 00 02 00 00 00 03 00 ; sprite &0c - HAMMER_RIGHT &3240 00 00 03 00 00 01 03 02 00 01 2b 02 00 01 17 02 &3250 00 01 17 02 0f 0b 03 07 00 01 03 02 00 01 17 02 &3260 00 01 17 02 00 01 03 02 00 00 03 00 00 00 00 00 ; sprite &0d - HAMMER_LEFT &3270 00 03 00 00 01 03 02 00 01 17 02 00 01 2b 02 00 &3280 01 2b 02 00 0b 03 07 0f 01 03 02 00 01 2b 02 00 &3290 01 2b 02 00 01 03 02 00 00 03 00 00 00 00 00 00 ; sprite &0e - HAMMER_UP &32a0 00 05 00 00 01 03 03 00 03 3f 03 02 17 03 17 02 &32b0 03 03 03 02 03 03 03 02 01 03 03 00 00 05 00 00 &32c0 00 05 00 00 00 05 00 00 00 05 00 00 00 05 00 00 ; sprite &0f - PLAYER_LIFE &32d0 01 03 03 00 01 37 00 00 01 32 22 00 00 33 00 00 &32e0 00 0f 1b 00 00 0f 00 00 00 0c 00 00 00 0c 08 00 &32f0 00 22 22 00 00 22 22 00 00 22 03 00 00 03 00 00 ; sprite &10 - GORILLA_SIDE_LEFT &3300 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 &3310 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 &3320 00 00 00 03 00 00 00 03 00 00 01 03 00 00 01 03 &3330 00 00 03 03 00 00 03 03 00 00 03 03 00 01 03 03 &3340 00 01 03 03 00 01 03 03 00 03 12 13 00 03 21 33 &3350 01 03 21 22 03 12 00 00 23 02 00 00 11 22 00 00 ; sprite &12 - GORILLA_SIDE_RIGHT &3360 00 00 00 00 00 00 00 00 00 00 00 00 00 00 03 02 &3370 00 01 17 2a 00 01 17 20 00 03 33 33 03 03 33 33 &3380 03 03 13 33 03 03 03 22 03 03 02 00 03 03 02 00 &3390 03 03 02 00 12 03 02 00 12 03 02 00 12 03 03 00 &33a0 13 21 03 00 33 21 03 00 23 03 03 00 01 12 03 02 &33b0 01 12 03 02 01 03 21 23 01 03 01 33 11 33 00 13 ; sprite &14 - BARREL_SIDE &33c0 00 03 03 00 01 07 0b 02 01 30 30 02 03 0f 0f 03 &33d0 07 0f 0f 0b 12 30 30 21 07 0f 0f 0b 07 0f 0f 0b &33e0 03 30 30 03 01 0f 0f 02 01 07 0b 02 00 03 03 00 ; instructions_screen &33f0 95 20 20 20 20 20 20 20 20 20 30 20 20 20 20 68 ; ". 0 h j##)$