Quest disassembly ================= Quest was written by Tony Oakden, and published by Superior Software for the BBC Micro in 1988. It is an arcade adventure. The following disassembly was created by reverse engineering binary images, 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 =============== Both disk and tape versions are analysed here. The disk version loads the main binary from sectors marked as containing deleted data. Code written by Kevin Edwards allows both forty and eight track drives to load other files from the same disk. The tape version is derived from the disk version, and moves some screen initialisation code into the main binary. A screenshot map may be found at: http://www.level7.org.uk/miscellany/quest-map.png Interesting pokes ================= &2b94 = &00 infinite energy &2b57 = &18, &2b58 = &60 enemies don't cause damage &297c = &bd spikes don't cause damage &30f3 = &a9 infinite stun grenades &2688 = &00 jet boots work in all rooms &29d6 = &00, &29dd = &00 open doors by touching Loader disassembly ================== ; $.QUEST ; FF1900 FF8023 00021C &1900 0d # Start of BASIC program &1901 00 0a 0a 2a 2f 49 4e 49 54 0d ; 10*/INIT # Run 40/80 track compatibility code &190b 00 0f 13 ef 32 33 3b 38 32 30 32 3b 30 3b 30 3b ; 15VDU23;8202;0;0;0; # Disable cursor &191b 30 3b 0d &191e 00 14 15 f4 20 28 63 29 20 54 4f 4e 59 20 4f 41 ; 20REM (c) TONY OAKDEN &192e 4b 44 45 4e 0d &1933 00 1e 20 f4 20 46 4f 52 20 53 55 50 45 52 49 4f ; 30REM FOR SUPERIOR SOFTWARE 1988 &1943 52 20 53 4f 46 54 57 41 52 45 20 31 39 38 38 0d &1953 00 28 32 eb 35 3a ef 32 33 3b 38 32 30 32 3b 30 ; 40MODE5: &1963 3b 30 3b 30 3b 31 39 2c 31 2c 32 3b 30 3b 31 39 ; VDU23;8202;0;0;0; # Disable cursor &1973 2c 33 2c 35 3b 30 3b 3a 2a 4c 2e 51 55 45 53 54 ; 19,1,2;0; # Set colour 1 to green &1983 4f 0d ; 19,3,5;0;: # Set colour 3 to magenta ; *L.QUESTO # Load loading screen &1985 00 2d 1b f1 8a 33 2c 32 37 29 22 42 79 20 54 6f ; 45PRINTTAB(3,27)"By Tony Oakden" &1995 6e 79 20 4f 61 6b 64 65 6e 22 0d &19a0 00 2e 10 54 25 3d 91 3a 2a 46 58 31 35 2c 30 0d ; 46T%=TIME: ; *FX15,0 # Flush all buffers &19b0 00 2f 1a f5 fd 91 3e 54 25 2b 31 32 30 30 20 84 ; 47REPEATUNTILTIME>T%+1200 ORINKEY(10)<>-1 &19c0 a6 28 31 30 29 3c 3e 2d 31 0d &19ca 00 32 06 eb 31 0d ; 50MODE1 &19d0 00 3c 11 ef 31 39 2c 32 2c 30 2c 30 2c 30 2c 30 ; 60VDU19,2,0,0,0,0 # Set colour 2 to black &19e0 0d &19e1 00 46 11 ef 31 39 2c 33 2c 30 2c 30 2c 30 2c 30 ; 70VDU19,3,0,0,0,0 # Set colour 3 to black &19f1 0d &19f2 00 50 13 ef 31 39 2c 31 2c 30 2c 30 2c 30 2c 30 ; 80VDU19,1,0,0,0,0 # Set colour 1 to black &1a02 20 20 0d &1a05 00 5a 13 ef 32 33 2c 31 2c 30 3b 30 3b 30 3b 30 ; 90VDU23,1,0;0;0;0; # Disable cursor &1a15 3b 20 0d &1a18 00 64 16 ef 32 34 2c 30 3b 33 32 3b 31 32 37 39 ; 100VDU24,0;32;1279;831; # Define graphics window &1a28 3b 38 33 31 3b 0d &1a2e 00 6e 2a ef 32 33 2c 31 32 38 2c 31 32 34 2c 31 ; 110VDU23,128,124,198,198,198,198,214,124,15 &1a3e 39 38 2c 31 39 38 2c 31 39 38 2c 31 39 38 2c 32 # Define character 80 &1a4e 31 34 2c 31 32 34 2c 31 35 0d &1a58 00 78 24 ef 32 33 2c 31 32 39 2c 36 2c 36 2c 31 ; 120VDU23,129,6,6,15,235,237,79,79,239 &1a68 35 2c 32 33 35 2c 32 33 37 2c 37 39 2c 37 39 2c # Define character 81 &1a78 32 33 39 0d &1a7c 00 82 06 fb 31 0d ; 130COLOUR1 &1a82 00 8c 05 db 0d ; 140CLS &1a87 00 96 0b f1 8a 30 2c 33 31 29 0d ; 150PRINTTAB(0,31) &1a92 00 a0 16 3f 26 46 45 30 30 3d 36 3a 3f 26 46 45 ; 160?&FE00=6: # R6: Vertical displayed register &1aa2 30 31 3d 32 37 0d ; ?&FE01=27 &1aa8 00 aa 16 3f 26 46 45 30 30 3d 37 3a 3f 26 46 45 ; 170?&FE00=7: # R7: Vertical sync position &1ab8 30 31 3d 33 32 0d ; ?&FE01=32 &1abe 00 b4 16 3f 26 46 45 30 30 3d 31 32 3a 3f 26 46 ; 180?&FE00=12: # R12: Displayed screen start address register (high) &1ace 45 30 31 3d 37 0d ; ?&FE01=7 &1ad4 00 be 18 3f 26 46 45 30 30 3d 31 33 3a 3f 26 46 ; 190?&FE00=13: # R13: Displayed screen start address register (low) &1ae4 45 30 31 3d 31 34 34 0d ; ?&FE01=144 # Set screen start address to &3c80 &1aec 00 c8 0c 3f 26 46 45 30 30 3d 32 0d ; 200?&FE00=2 # R2: Horizontal sync position register # Bug: no value written &1af8 00 d2 14 2a 4c 4f 41 44 20 69 6e 74 63 6f 64 20 ; 210*LOAD intcod 380 &1b08 33 38 30 0d &1b0c 00 dc 0f 2a 52 55 4e 20 51 55 45 53 54 31 0d ; 220*RUN QUEST1 # Run second stage of loader &1b1b ff # End of BASIC program ; $.INIT ; 001400 001400 0002C2 ; entry_point &1400 a2 d1 LDX #&d1 ; &14d1 = disc_command &1402 a0 14 LDY #&14 &1404 20 f7 ff JSR &fff7 ; OSCLI # *DISC &1407 20 7f 16 JSR &167f ; seek_track &140a a2 b7 LDX #&b7 ; &16b7 = read_ids_block &140c a0 16 LDY #&16 &140e 20 83 16 JSR &1683 ; disk_operation # Read IDs for track four &1411 ad c2 16 LDA &16c2 ; sector_ids &1414 c9 04 CMP #&04 &1416 f0 05 BEQ &141d ; not_eighty_track_drive ; is_eighty_track_drive &1418 a2 ff LDX #&ff &141a 8e 5c 14 STX &145c ; forty_or_eighty_track_drive # Set to negative to indicate eighty track drive ; not_eighty_track_drive &141d a2 ac LDX #&ac ; &16ac = read_catalogue_block &141f a0 16 LDY #&16 &1421 20 83 16 JSR &1683 ; disk_operation # Read catalogue &1424 ad c7 17 LDA &17c7 ; catalogue_data + &105 # Number of catalogue entries times eight &1427 4a LSR A &1428 4a LSR A &1429 4a LSR A &142a 8d 5e 14 STA &145e ; number_of_catalogue_entries &142d ad 12 02 LDA &0212 ; osfile_vector_low &1430 8d c4 14 STA &14c4 ; previous_osfile_vector_low &1433 ad 13 02 LDA &0213 ; osfile_vector_high &1436 8d c5 14 STA &14c5 ; previous_osfile_vector_high &1439 ad 1e 02 LDA &021e ; file_system_control_vector_low &143c 8d cf 14 STA &14cf ; previous_file_system_control_vector_low &143f ad 1f 02 LDA &021f ; file_system_control_vector_high &1442 8d d0 14 STA &14d0 ; previous_file_system_control_vector_high &1445 78 SEI &1446 a9 88 LDA #&88 ; &1488 = osfile_handler &1448 8d 12 02 STA &0212 ; osfile_vector_low &144b a9 14 LDA #&14 &144d 8d 13 02 STA &0213 ; osfile_vector_high &1450 a9 c6 LDA #&c6 ; &14c6 = file_system_control_handler &1452 8d 1e 02 STA &021e ; file_system_control_vector_low &1455 a9 14 LDA #&14 &1457 8d 1f 02 STA &021f ; file_system_control_vector_high &145a 58 CLI &145b 60 RTS ; forty_or_eighty_track_drive &145c 00 ; filename_length &145d 00 ; number_of_catalogue_entries &145e 00 ; loading_or_running &145f 00 ; has_load_address &1460 00 ; quote_state &1461 00 ; tmp_a &1462 00 ; tmp_x &1463 00 ; tmp_y &1464 00 ; unused &1465 34 30 2f 38 30 20 4c 6f 61 64 65 72 20 28 63 29 ; "40/80 Loader (c)" &.... 20 4b 65 76 69 6e 20 45 64 77 61 72 64 73 20 31 ; " Kevin Edwards 1" &.... 39 38 36 ; "986" ; osfile_handler # Called with XY = address of OSFILE block, A = action &1488 c9 ff CMP #&ff # &ff if loading file &148a d0 37 BNE &14c3 ; to_previous_osfile_vector_low ; is_load &148c 8d 62 14 STA &1462 ; tmp_a &148f 8e 63 14 STX &1463 ; tmp_x &1492 8c 64 14 STY &1464 ; tmp_y &1495 86 72 STX &72 ; block_address_low &1497 84 73 STY &73 ; block_address_high &1499 a0 06 LDY #&06 ; execution address low &149b a2 ff LDX #&ff # Non-zero to indicate no load address defined &149d b1 72 LDA (&72),Y ; block_address &149f d0 0e BNE &14af ; skip_setting_load_address # If zero, use load address in OSFILE block ; set_load_address_from_osfile_block &14a1 e8 INX ; 0 # Zero to indicate load address defined &14a2 a0 02 LDY #&02 ; load address low &14a4 b1 72 LDA (&72),Y ; block_address &14a6 8d a2 16 STA &16a2 ; read_data_block + 1 (address low) &14a9 c8 INY ; 3 : load address high &14aa b1 72 LDA (&72),Y ; block_address &14ac 8d a3 16 STA &16a3 ; read_data_block + 2 (address high) ; skip_setting_load_address &14af 8e 60 14 STX &1460 ; has_load_address &14b2 a0 00 LDY #&00 &14b4 8c 5f 14 STY &145f ; loading_or_running # Set to positive to indicate loading, not running &14b7 b1 72 LDA (&72),Y ; block_address &14b9 85 70 STA &70 ; filename_address_low &14bb c8 INY ; 1 &14bc b1 72 LDA (&72),Y ; block_address &14be 85 71 STA &71 ; filename_address_high &14c0 4c fb 14 JMP &14fb ; process_filename ; to_previous_osfile_vector_low &14c3 4c ff ff JMP &ffff # actually JMP previous_osfile_vector ; file_system_control_handler # Called with XY = address of filename, A = action &14c6 c9 02 CMP #&02 # &02 if */ &14c8 90 04 BCC &14ce ; to_previous_file_system_control_vector # &03 if unrecognised command &14ca c9 05 CMP #&05 # &04 if *RUN &14cc 90 18 BCC &14e6 ; handle_run ; to_previous_file_system_control_vector &14ce 4c ff ff JMP &ffff # actually JMP previous_file_system_control_vector ; disc_command &14d1 44 49 53 43 0d ; "DISC" ; invalid_fsp_error &14d6 00 BRK &14d7 ff &14d8 49 6e 76 61 6c 69 64 20 3c 66 73 70 3e 00 ; "Invalid " ; handle_run # Called with XY = address of filename &14e6 8d 62 14 STA &1462 ; tmp_a &14e9 8e 63 14 STX &1463 ; tmp_x &14ec 8c 64 14 STY &1464 ; tmp_y &14ef a9 ff LDA #&ff &14f1 8d 5f 14 STA &145f ; loading_or_running # Set to negative to indicate running &14f4 8d 60 14 STA &1460 ; has_load_address # Set to non-zero to indicate no load address defined &14f7 86 70 STX &70 ; filename_address_low &14f9 84 71 STY &71 ; filename_address_high ; process_filename &14fb a0 ff LDY #&ff # Becomes zero on first pass &14fd 8c 61 14 STY &1461 ; quote_state # Set to &ff to indicate no quotation marks used ; find_start_of_filename_loop &1500 c8 INY &1501 b1 70 LDA (&70),Y ; filename_address &1503 c9 20 CMP #&20 ; " " &1505 f0 f9 BEQ &1500 ; find_start_of_filename_loop &1507 c9 0d CMP #&0d ; CR &1509 f0 cb BEQ &14d6 ; invalid_fsp_error &150b aa TAX &150c e0 22 CPX #&22 ; " " &150e d0 07 BNE &1517 ; found_start_of_filename &1510 ee 61 14 INC &1461 ; quote_state # Set to zero on first quotation mark &1513 d0 c1 BNE &14d6 ; invalid_fsp_error # Multiple quotation mark at start are an error &1515 f0 e9 BEQ &1500 ; find_start_of_filename_loop # Always branches ; found_start_of_filename &1517 a9 24 LDA #&24 ; "$" &1519 8d a3 15 STA &15a3 ; directory &151c 98 TYA &151d 20 75 16 JSR &1675 ; add_to_filename_address # Move past spaces and quotation marks at start &1520 a0 01 LDY #&01 &1522 b1 70 LDA (&70),Y ; filename_address &1524 c9 2e CMP #&2e ; "." &1526 d0 08 BNE &1530 ; skip_setting_directory ; set_directory &1528 8e a3 15 STX &15a3 ; directory &152b a9 02 LDA #&02 &152d 20 75 16 JSR &1675 ; add_to_filename_address # Move past directory letter and separator ; skip_setting_directory &1530 a0 ff LDY #&ff ; find_end_of_filename_loop &1532 c8 INY &1533 b1 70 LDA (&70),Y ; filename_address &1535 c9 20 CMP #&20 ; " " &1537 f0 0d BEQ &1546 ; found_end_of_filename &1539 c9 0d CMP #&0d ; CR &153b f0 09 BEQ &1546 ; found_end_of_filename &153d c9 22 CMP #&22 ; """ &153f d0 f1 BNE &1532 ; find_end_of_filename_loop &1541 ad 61 14 LDA &1461 ; quote_state # Negative if no previous quotation marks &1544 30 90 BMI &14d6 ; invalid_fsp_error # First quotation mark at end is an error ; found_end_of_filename &1546 98 TYA &1547 f0 8d BEQ &14d6 ; invalid_fsp_error # Zero length filename is an error &1549 c0 08 CPY #&08 &154b b0 89 BCS &14d6 ; invalid_fsp_error # Overly long filename is an error &154d 8c 5d 14 STY &145d ; filename_length &1550 a9 ca LDA #&ca ; &16ca = catalogue_data + 8 # First page of catalogue contains filenames &1552 85 72 STA &72 ; catalogue_data_address_low # + 8 to begin with first filename in catalogue &1554 a9 16 LDA #&16 &1556 85 73 STA &73 ; catalogue_data_address_high &1558 ae 5e 14 LDX &145e ; number_of_catalogue_entries ; find_filename_in_catalogue ; find_filename_in_catalogue_file_loop &155b ac 5d 14 LDY &145d ; filename_length &155e b1 72 LDA (&72),Y ; catalogue_data_address &1560 88 DEY &1561 c0 06 CPY #&06 &1563 f0 04 BEQ &1569 ; find_filename_in_catalogue_filename_loop # If not full length filename, &1565 c9 20 CMP #&20 ; " " &1567 d0 13 BNE &157c ; consider_next_file # Don't allow partial matches ; find_filename_in_catalogue_filename_loop &1569 b1 72 LDA (&72),Y ; catalogue_data_address &156b 29 df AND #&df # Convert character to uppercase &156d 85 75 STA &75 ; catalogue_byte &156f b1 70 LDA (&70),Y ; filename_address &1571 29 df AND #&df # Convert character to uppercase &1573 c5 75 CMP &75 ; catalogue_byte &1575 d0 05 BNE &157c ; consider_next_file &1577 88 DEY &1578 10 ef BPL &1569 ; find_filename_in_catalogue_filename_loop &157a 30 20 BMI &159c ; found_file_in_catalogue # Always branches ; consider_next_file &157c a5 72 LDA &72 ; catalogue_data_address_low &157e 18 CLC &157f 69 08 ADC #&08 # Move to next file in catalogue &1581 85 72 STA &72 ; catalogue_data_address_low &1583 90 02 BCC &1587 ; skip_page &1585 e6 73 INC &73 ; catalogue_data_address_high ; skip_page &1587 ca DEX &1588 d0 d1 BNE &155b ; find_filename_in_catalogue_file_loop # Continue until all filenames have been considered ; fsp_not_found_error &158a 00 BRK &158b ff &158c 3c 66 73 70 3e 20 6e 6f 74 20 66 6f 75 6e 64 00 ; " not found" ; found_file_in_catalogue &159c a0 07 LDY #&07 &159e b1 72 LDA (&72),Y ; catalogue_data_address # Directory of file in catalogue &15a0 29 7f AND #&7f # Ignore top bit &15a2 c9 ff CMP #&ff # actually CMP directory &15a4 d0 e4 BNE &158a ; fsp_not_found_error # Directory must match &15a6 e6 73 INC &73 ; catalogue_data_address_high # Move to second page of catalogue, containing metadata &15a8 ad 60 14 LDA &1460 ; has_load_address # Zero if load address already defined &15ab f0 0d BEQ &15ba ; skip_setting_load_address ; set_load_address_from_metadata &15ad a0 00 LDY #&00 &15af b1 72 LDA (&72),Y ; catalogue_data_address # Bytes 0 - 1 of metadata are load address &15b1 8d a2 16 STA &16a2 ; read_data_block + 1 (address low) &15b4 c8 INY ; 1 &15b5 b1 72 LDA (&72),Y ; catalogue_data_address &15b7 8d a3 16 STA &16a3 ; read_data_block + 2 (address high) ; skip_setting_load_address &15ba a0 02 LDY #&02 &15bc b1 72 LDA (&72),Y ; catalogue_data_address # Bytes 2 - 3 of metadata are execution address &15be 85 77 STA &77 ; execution_address_low &15c0 c8 INY ; 3 &15c1 b1 72 LDA (&72),Y ; catalogue_data_address &15c3 85 78 STA &78 ; execution_address_high &15c5 a0 05 LDY #&05 &15c7 b1 72 LDA (&72),Y ; catalogue_data_address # Bytes 4 - 5 of metadata are file length &15c9 aa TAX ; length high &15ca 88 DEY ; 4 &15cb b1 72 LDA (&72),Y ; catalogue_data_address &15cd f0 01 BEQ &15d0 ; skip_extra_sector &15cf e8 INX # Read an extra sector if partial number of pages ; skip_extra_sector &15d0 86 76 STX &76 ; sectors_remaining &15d2 a0 07 LDY #&07 &15d4 b1 72 LDA (&72),Y ; catalogue_data_address # Byte 7 is low eight bits of start sector &15d6 aa TAX ; start sector low &15d7 88 DEY ; 6 &15d8 b1 72 LDA (&72),Y ; catalogue_data_address # Byte 6 is high two bits of start sector in lowest two bits &15da 29 03 AND #&03 &15dc a8 TAY ; start sector high &15dd 8a TXA ; start sector low &15de a2 00 LDX #&00 ; track ; calculate_track_loop &15e0 c0 00 CPY #&00 &15e2 d0 04 BNE &15e8 ; not_remainder &15e4 c9 0a CMP #&0a &15e6 90 09 BCC &15f1 ; set_track_and_sector ; not_remainder &15e8 e8 INX ; track &15e9 38 SEC &15ea e9 0a SBC #&0a &15ec b0 f2 BCS &15e0 ; calculate_track_loop &15ee 88 DEY &15ef 90 ef BCC &15e0 ; calculate_track_loop ; set_track_and_sector &15f1 8d a9 16 STA &16a9 ; read_data_block + 8 (sector) &15f4 8e a8 16 STX &16a8 ; read_data_block + 7 (track) ; read_data_loop &15f7 a9 0a LDA #&0a &15f9 38 SEC &15fa ed a9 16 SBC &16a9 ; read_data_block + 8 (sector) &15fd c5 76 CMP &76 ; sectors_remaining &15ff 90 02 BCC &1603 ; skip_floor &1601 a5 76 LDA &76 ; sectors_remaining ; skip_floor &1603 85 74 STA &74 ; sectors_to_read &1605 09 20 ORA #&20 ; 256 byte sectors # Use 256 byte sectors &1607 8d aa 16 STA &16aa ; read_data_block + 9 (size and count) &160a a5 76 LDA &76 ; sectors_remaining &160c 38 SEC &160d e5 74 SBC &74 ; sectors_to_read &160f 85 76 STA &76 ; sectors_remaining &1611 2c 5c 14 BIT &145c ; forty_or_eighty_track_drive # Negative if eighty track drive &1614 10 13 BPL &1629 ; skip_seeking_to_doubled_track &1616 ad a8 16 LDA &16a8 ; read_data_block + 7 (track) &1619 0a ASL A &161a 8d 95 16 STA &1695 ; seek_track_block + 7 (value) &161d 20 7f 16 JSR &167f ; seek_track &1620 ad a8 16 LDA &16a8 ; read_data_block + 7 (track) &1623 8d 9f 16 STA &169f ; set_track_register_block + 8 (value) &1626 20 88 16 JSR &1688 ; set_track_register ; skip_seeking_to_doubled_track &1629 a2 a1 LDX #&a1 ; &16a1 = read_data_block &162b a0 16 LDY #&16 &162d 20 83 16 JSR &1683 ; disk_operation # Read sectors &1630 2c 5c 14 BIT &145c ; forty_or_eighty_track_drive # Negative if eighty track drive &1633 10 06 BPL &163b ; skip_doubling_track &1635 0e 9f 16 ASL &169f ; set_track_register_block + 8 (value) &1638 20 88 16 JSR &1688 ; set_track_register ; skip_doubling_track &163b a9 00 LDA #&00 &163d 8d a9 16 STA &16a9 ; read_data_block + 8 (sector) &1640 a5 74 LDA &74 ; sectors_to_read &1642 18 CLC &1643 6d a3 16 ADC &16a3 ; read_data_block + 2 (address high) &1646 8d a3 16 STA &16a3 ; read_data_block + 2 (address high) &1649 ee a8 16 INC &16a8 ; read_data_block + 7 (track) &164c ad ab 16 LDA &16ab ; read_data_block + 10 (result) &164f f0 0e BEQ &165f ; not_fault ; disc_fault_error &1651 00 BRK &1652 ff &1653 44 69 73 63 20 46 61 75 6c 74 21 00 ; "Disc Fault!" ; not_fault &165f a5 76 LDA &76 ; sectors_remaining &1661 d0 94 BNE &15f7 ; read_data_loop &1663 ad 62 14 LDA &1462 ; tmp_a &1666 ae 63 14 LDX &1463 ; tmp_x &1669 ac 64 14 LDY &1464 ; tmp_y &166c 2c 5f 14 BIT &145f ; loading_or_running # Positive if loading, negative if running &166f 10 03 BPL &1674 ; leave &1671 6c 77 00 JMP (&0077) ; execution_address # Run file ; leave &1674 60 RTS ; add_to_filename_address &1675 18 CLC &1676 65 70 ADC &70 ; filename_address_low &1678 85 70 STA &70 ; filename_address_low &167a 90 02 BCC &167e ; skip_page &167c e6 71 INC &71 ; filename_address_high ; skip_page &167e 60 RTS ; seek_track &167f a2 8e LDX #&8e ; &168e = seek_track_block &1681 a0 16 LDY #&16 ; disk_operation &1683 a9 7f LDA #&7f ; Floppy disk operation &1685 4c f1 ff JMP &fff1 ; OSWORD ; set_track_register &1688 a2 97 LDX #&97 ; &1697 = set_track_register_block &168a a0 16 LDY #&16 &168c d0 f5 BNE &1683 ; disk_operation # Always branches ; seek_track_block &168e 00 ; drive &168f ff ff ff ff ; address &1693 01 ; parameters &1694 69 ; command : seek &1695 00 ; track &1696 00 ; result ; set_track_register_block &1697 00 ; drive &1698 ff ff ff ff ; address &169c 02 ; parameters &169d 7a ; command : write special register &169e 12 ; register : track register &169f 00 ; value &16a0 00 ; result ; read_data_block &16a1 00 ; drive &16a2 ff ff ff ff ; address &16a6 03 ; parameters &16a7 53 ; command : read data &16a8 00 ; track &16a9 00 ; sector &16aa 2a ; size and count : ten 256 byte sectors &16ab 00 ; result ; read_catalogue_block &16ac 00 ; drive &16ad c2 16 ff ff ; address : &16c2 = catalogue_data &16b1 03 ; parameters &16b2 53 ; command : read data &16b3 00 ; track &16b4 00 ; sector &16b5 22 ; size and count : two 256 byte sectors &16b6 00 ; result ; read_ids_block &16b7 00 ; drive &16b8 c2 16 ff ff ; address : &16c2 = sector_ids &16bc 03 ; parameters &16bd 5b ; command : read IDs &16be 04 ; track 4 &16bf 00 ; zero parameter &16c0 01 ; count &16c1 00 ; result ; $.QUEST1 ; FF0400 FF0400 0000D9 &0400 20 9c 04 JSR &049c ; seek_to_track # Seek to track zero &0403 a2 c9 LDX #&c9 ; &04c9 = read_ids_block &0405 a0 04 LDY #&04 &0407 20 a0 04 JSR &04a0 ; disk_operation # Read IDs from track four &040a ad d5 04 LDA &04d5 ; id_data &040d c9 04 CMP #&04 &040f f0 05 BEQ &0416 ; not_eighty_track_drive ; is_eighty_track_drive &0411 a2 ff LDX #&ff &0413 8e d4 04 STX &04d4 ; forty_or_eighty_track_drive # Set to negative to indicate eighty track drive ; not_eighty_track_drive &0416 a9 00 LDA #&00 ; sector &0418 a2 0f LDX #&0f ; track &041a a0 3f LDY #&3f # Read &3f00 of data starting from track 15, sector 0 &041c 8d c6 04 STA &04c6 ; read_data_block + 8 (sector) &041f 8e c5 04 STX &04c5 ; read_data_block + 7 (track) &0422 84 72 STY &72 ; sectors_remaining ; read_data_loop &0424 a9 0a LDA #&0a &0426 38 SEC &0427 ed c6 04 SBC &04c6 ; read_data_block + 8 (sector) &042a c5 72 CMP &72 ; sectors_remaining &042c 90 02 BCC &0430 ; not_last_sectors &042e a5 72 LDA &72 ; sectors_remaining ; not_last_sectors &0430 85 70 STA &70 ; sectors_to_read &0432 09 20 ORA #&20 ; use 256 byte sectors &0434 8d c7 04 STA &04c7 ; read_data_block + 9 (size and count) &0437 a5 72 LDA &72 ; sectors_remaining &0439 38 SEC &043a e5 70 SBC &70 ; sectors_to_read &043c 85 72 STA &72 ; sectors_remaining &043e 2c d4 04 BIT &04d4 ; forty_or_eighty_track_drive # Negative if eighty track drive &0441 10 13 BPL &0456 ; skip_seeking_to_doubled_track &0443 ad c5 04 LDA &04c5 ; read_data_block + 7 (track) &0446 0a ASL A &0447 8d b2 04 STA &04b2 ; seek_track_block + 7 (track) &044a 20 9c 04 JSR &049c ; seek_to_track &044d ad c5 04 LDA &04c5 ; read_data_block + 7 (track) &0450 8d bc 04 STA &04bc ; set_track_register_block + 8 (track) &0453 20 a5 04 JSR &04a5 ; set_track_register ; skip_seeking_to_doubled_track &0456 a2 be LDX #&be ; &04be = read_data_block &0458 a0 04 LDY #&04 &045a 20 a0 04 JSR &04a0 ; disk_operation &045d 2c d4 04 BIT &04d4 ; forty_or_eighty_track_drive # Negative if eighty track drive &0460 10 06 BPL &0468 ; skip_doubling_track &0462 0e bc 04 ASL &04bc ; set_track_register_block + 8 (track) &0465 20 a5 04 JSR &04a5 ; set_track_register ; skip_doubling_track &0468 a9 00 LDA #&00 &046a 8d c6 04 STA &04c6 ; read_data_block + 8 (sector) &046d a5 70 LDA &70 ; load_address_high &046f 18 CLC &0470 6d c0 04 ADC &04c0 ; read_data_block + 2 (address high) &0473 8d c0 04 STA &04c0 ; read_data_block + 2 (address high) &0476 ee c5 04 INC &04c5 ; read_data_block + 7 (track) &0479 ad c8 04 LDA &04c8 ; read_data_block + 10 (result) &047c ea NOP # Probably commented out error checking &047d 4c 95 04 JMP &0495 ; consider_next_read ; unused &0480 00 BRK &0481 ff &0482 53 65 63 74 6f 72 20 72 65 61 64 20 66 61 75 6c ; "Sector read fault!" &0492 74 21 00 ; consider_next_read &0495 a5 72 LDA &72 ; sectors_remaining &0497 d0 8b BNE &0424 ; read_data_loop &0499 4c 80 59 JMP &5980 ; main_binary_entry_point ; seek_to_track &049c a2 ab LDX #&ab ; &04ab = seek_track_block &049e a0 04 LDY #&04 ; disk_operation &04a0 a9 7f LDA #&7f ; Floppy disk operation &04a2 4c f1 ff JMP &fff1 ; OSWORD ; set_track_register &04a5 a2 b4 LDX #&b4 ; &04b4 = set_track_register_block &04a7 a0 04 LDY #&04 &04a9 d0 f5 BNE &04a0 ; disk_operation # Always branches ; seek_track_block &04ab 00 ; drive &04ac ff ff ff ff ; address &04b0 01 ; parameters &04b1 69 ; command : seek &04b2 00 ; track 0 &04b3 00 ; result ; set_track_register_block &04b4 00 ; drive &04b5 ff ff ff ff ; address &04b9 02 ; parameters &04ba 7a ; command : write special register &04bb 12 ; register : track register &04bc 00 ; value &04bd 00 ; result ; read_data_block &04be 00 ; drive &04bf 00 1d ff ff ; address : &1d00 = main_binary_load_address &04c3 03 ; parameters &04c4 57 ; command : read data and deleted data &04c5 00 ; track &04c6 00 ; sector &04c7 2a ; size and count : ten 256 byte sectors &04c8 00 ; result ; read_ids_block &04c9 00 ; drive &04ca d5 04 ff ff ; address : &04d5 = id_data &04ce 03 ; parameters &04cf 5b ; command : read IDs &04d0 04 ; track 4 &04d1 00 ; zero &04d2 01 ; count &04d3 00 ; result ; forty_or_eighty_track_drive &04d4 00 ; id_data &04d5 ff ; unused &04d6 ff ff ff Game disassembly ================ # &1d00 - &5bff is loaded from deleted data on disk by QUEST1 # &1d00 - &25ff is moved to &0400 - &0cff at &599b ; sprite_caterpillar_right_frame_one &0400 00 00 00 00 06 6f 6f 06 00 00 00 06 6f 6f 6f 06 &0410 00 00 06 6f 7f 7f 6f 06 77 88 0e 6f 69 0f 08 0e ; sprite_caterpillar_left_frame_one &0420 ee 11 07 69 6f 0f 01 07 00 00 06 6f ef ef 6f 06 &0430 00 00 00 06 6f 6f 6f 06 00 00 00 00 06 6f 6f 06 ; sprite_caterpillar_right_frame_two &0440 00 00 00 00 07 6f 6f 06 00 06 6f 6f 6f 0e 00 00 &0450 33 06 6f 6f 6f 06 00 00 88 44 0e 69 6f 0f 08 0e ; sprite_caterpillar_left_frame_two &0460 11 22 07 6f 69 0f 01 07 cc 06 6f 6f 6f 06 00 00 &0470 00 06 6f 6f 6f 07 00 00 00 00 00 00 0e 6f 6f 06 ; sprite_bat_frame_one &0480 0c 86 c3 61 30 10 00 00 88 44 22 0f 6f 87 e3 22 &0490 11 22 44 0f 6f 1e 4c 44 03 16 3c 68 c0 80 00 00 ; sprite_bat_frame_two &04a0 00 00 00 03 34 70 00 00 22 22 22 0f 6f 87 23 22 &04b0 44 44 44 0f 6f 1e 4c 44 00 00 00 0e e1 f0 00 00 ; sprite_butterfly_frame_one &04c0 02 05 00 00 33 cc 11 ee 00 00 68 61 cf 03 cd 01 &04d0 00 00 61 68 3f 0c 3b 08 04 0a 00 00 cc 33 88 77 ; sprite_butterfly_frame_two &04e0 03 00 00 ee 11 cc 33 00 08 04 60 61 cf 03 cd 01 &04f0 01 02 60 68 3f 0c 3b 08 0c 00 00 77 88 33 cc 00 ; sprite_player_head_right &0500 00 00 11 11 11 11 16 78 77 f8 f0 c3 c3 c3 6b a5 &0510 ff f1 87 ff 0f 0f 0c 87 88 00 00 88 88 08 00 00 &0520 9e f8 f0 f0 f0 70 70 00 c3 87 c3 87 c3 87 c3 07 &0530 08 84 08 84 48 84 48 84 00 00 00 00 00 00 00 00 ; sprite_player_feet_right_one &0540 00 00 11 11 32 32 03 03 fa e8 e4 c0 88 80 4e 0e &0550 e0 ea 71 75 31 32 03 03 00 00 00 00 00 80 4e 0e ; sprite_player_head_left &0560 11 00 00 11 11 01 00 00 ff f8 1e ff 0f 0f 03 1e &0570 ee f1 f0 3c 3c 3c 6d 5a 00 00 88 88 88 88 86 e1 &0580 00 00 00 00 00 00 00 00 01 12 01 12 21 12 21 12 &0590 b4 1e 3c 1e 3c 1e 3c 0e 97 f1 f0 f0 f0 e0 e0 ee ; sprite_player_feet_left_one &05a0 00 00 00 00 00 10 27 07 70 75 e8 ea c8 c4 0c 0c &05b0 f5 71 72 30 11 10 27 07 00 00 88 88 c4 c4 0c 0c ; sprite_player_feet_left_two &05c0 00 00 00 00 00 00 00 00 11 10 00 00 00 00 27 07 &05d0 f5 fa e4 ea e4 ea 0e 0e 00 00 00 00 00 00 00 00 ; sprite_player_feet_right_two &05e0 00 00 00 00 00 00 00 00 fa f5 72 75 72 75 07 07 &05f0 88 80 00 00 00 00 4e 0e 00 00 00 00 00 00 00 00 ; sprite_jellyfish_frame_two &0600 00 03 07 0f 9f 09 99 05 0f 0f 0f 0f 22 02 22 04 &0610 0f 0f 0f 0f 99 09 44 04 00 0c 0e 0f 2f 02 aa 09 ; sprite_jellyfish_frame_one &0620 03 07 0f 0f 99 04 22 02 08 0f 0f 0f 33 0a aa 0a &0630 01 0f 0f 0f 99 0a aa 0a 0c 0e 0f 0e 22 04 88 08 ; sprite_whirligig_frame_one &0640 57 57 00 30 0f 0f 30 00 5f 5f 30 f0 ff ff f0 30 &0650 5f 5f c0 f0 0f 0f f0 c0 4e 4e 00 c0 ff ff c0 00 ; sprite_whirligig_frame_two &0660 00 00 00 30 ff ff 30 00 07 07 30 f0 0f 0f f0 30 &0670 0e 0e c0 f0 ff ff f0 c0 00 00 00 c0 0f 0f c0 00 ; sprite_mouse_right &0680 11 22 44 44 44 33 00 00 00 33 77 77 ff ff ee 77 &0690 00 cc ff ff ff ee 33 00 cc cc 88 4c ff 00 00 88 ; sprite_fish_right &06a0 08 0c 86 0f 4b 86 0c 08 01 07 0f 0f 0f 0f 07 01 &06b0 0e 0f 3c 3c 0f 0c 0f 0e 00 08 0c 0e 0f 00 0c 00 ; sprite_ghost_right &06c0 00 00 00 00 00 00 00 00 00 00 00 00 10 72 74 f0 &06d0 30 60 40 c0 80 80 80 00 c0 20 00 0a 00 00 20 40 &06e0 00 10 10 30 30 72 74 70 f1 f2 f0 f8 f0 a0 f8 f0 &06f0 f2 f0 f4 f0 e0 10 f0 f0 fa e0 c3 01 80 80 80 80 &0700 60 80 10 10 00 30 70 c0 f0 f0 f0 b0 70 f0 e0 d0 &0710 f0 e0 d0 d0 b0 60 60 e0 80 80 80 00 00 00 00 00 ; sprite_ghost_left &0720 70 80 00 0a 00 00 80 40 80 c0 60 20 30 30 30 00 &0730 00 00 00 00 80 e0 c0 f0 00 00 00 00 00 00 00 00 &0740 72 3c 38 00 00 00 00 00 fa f0 f0 70 b0 c0 f0 f0 &0750 d0 e0 f0 f0 d0 30 f0 f0 00 00 80 00 c0 c0 e0 e0 &0760 10 10 10 00 00 00 00 00 f0 b0 f0 b0 d0 60 70 30 &0770 60 70 d0 e0 f0 f0 70 b0 60 10 80 c0 00 e0 e0 30 ; reset_tiles &0780 a9 0b LDA #&0b ; TILE_CRYSTAL &0782 8d fd 37 STA &37fd ; tile_data + 0 * &78 + 1 * &28 + 1 * &05 + 0; room (1, 0), tile (0, 1) &0785 8d 89 38 STA &3889 ; tile_data + 1 * &78 + 1 * &28 + 5 * &05 + 0; room (5, 1), tile (0, 1) &0788 8d 12 39 STA &3912 ; tile_data + 2 * &78 + 2 * &28 + 0 * &05 + 2; room (0, 2), tile (2, 2) &078b 8d fd 38 STA &38fd ; tile_data + 2 * &78 + 1 * &28 + 4 * &05 + 1; room (4, 2), tile (1, 1) &078e 8d 83 39 STA &3983 ; tile_data + 3 * &78 + 1 * &28 + 7 * &05 + 0; room (7, 3), tile (0, 1) &0791 8d 45 39 STA &3945 ; tile_data + 3 * &78 + 0 * &28 + 2 * &05 + 3; room (2, 3), tile (3, 0) &0794 8d d5 39 STA &39d5 ; tile_data + 4 * &78 + 0 * &28 + 7 * &05 + 2; room (7, 4), tile (2, 0) &0797 8d 72 3a STA &3a72 ; tile_data + 5 * &78 + 1 * &28 + 6 * &05 + 4; room (6, 5), tile (4, 1) &079a 8d c2 3a STA &3ac2 ; tile_data + 6 * &78 + 0 * &28 + 6 * &05 + 4; room (6, 6), tile (4, 0) &079d 8d 75 3b STA &3b75 ; tile_data + 7 * &78 + 2 * &28 + 2 * &05 + 3; room (2, 7), tile (3, 2) &07a0 8d 29 3c STA &3c29 ; tile_data + 9 * &78 + 0 * &28 + 6 * &05 + 3; room (6, 9), tile (3, 0) &07a3 8d 5f 3c STA &3c5f ; tile_data + 9 * &78 + 2 * &28 + 1 * &05 + 2; room (1, 9), tile (2, 2) &07a6 a9 14 LDA #&14 ; TILE_CLOSED_DOOR &07a8 8d 42 38 STA &3842 ; tile_data + 0 * &78 + 2 * &28 + 6 * &05 + 4; room (6, 0), tile (4, 2) &07ab 8d 88 38 STA &3888 ; tile_data + 1 * &78 + 1 * &28 + 4 * &05 + 4; room (4, 1), tile (4, 1) &07ae 8d 82 39 STA &3982 ; tile_data + 3 * &78 + 1 * &28 + 6 * &05 + 4; room (6, 3), tile (4, 1) &07b1 a2 07 LDX #&07 ; TILE_DOOR_ONE &07b3 8e da 39 STX &39da ; tile_data + 4 * &78 + 1 * &28 + 0 * &05 + 2; room (0, 4), tile (2, 1) &07b6 8e cb 3a STX &3acb ; tile_data + 6 * &78 + 1 * &28 + 0 * &05 + 3; room (0, 6), tile (3, 1) &07b9 8e fc 37 STX &37fc ; tile_data + 0 * &78 + 1 * &28 + 0 * &05 + 4; room (0, 0), tile (4, 1) &07bc e8 INX ; &08 : TILE_DOOR_TWO &07bd 8e fc 3b STX &3bfc ; tile_data + 8 * &78 + 2 * &28 + 5 * &05 + 3; room (5, 8), tile (3, 2) &07c0 a9 11 LDA #&11 ; TILE_ELEPHANT &07c2 8d 0c 39 STA &390c ; tile_data + 2 * &78 + 1 * &28 + 7 * &05 + 1; room (7, 2), tile (1, 1) &07c5 8d 87 3a STA &3a87 ; tile_data + 5 * &78 + 2 * &28 + 3 * &05 + 0; room (3, 5), tile (0, 2) &07c8 a9 39 LDA #&39 ; TILE_WALL_BOTTOM_HALF &07ca 8d 0e 39 STA &390e ; tile_data + 2 * &78 + 1 * &28 + 7 * &05 + 3; room (7, 2), tile (3, 1) &07cd 8d 95 3a STA &3a95 ; tile_data + 5 * &78 + 2 * &28 + 5 * &05 + 4; room (5, 5), tile (4, 2) &07d0 8d 89 3a STA &3a89 ; tile_data + 5 * &78 + 2 * &28 + 3 * &05 + 2; room (3, 5), tile (2, 2) &07d3 a9 32 LDA #&32 ; TILE_VAT_OF_ACID &07d5 8d 7a 39 STA &397a ; tile_data + 3 * &78 + 1 * &28 + 5 * &05 + 1; room (5, 3), tile (1, 1) &07d8 8d 7c 39 STA &397c ; tile_data + 3 * &78 + 1 * &28 + 5 * &05 + 3; room (5, 3), tile (3, 1) &07db a9 6f LDA #&6f ; TILE_REACTOR | TILE_FLIPPED_VERTICALLY &07dd 8d 11 3a STA &3a11 ; tile_data + 4 * &78 + 2 * &28 + 3 * &05 + 2; room (3, 4), tile (2, 2) &07e0 8d fc 3a STA &3afc ; tile_data + 6 * &78 + 2 * &28 + 2 * &05 + 2; room (2, 6), tile (2, 2) &07e3 8d 6a 3b STA &3b6a ; tile_data + 7 * &78 + 2 * &28 + 0 * &05 + 2; room (0, 7), tile (2, 2) &07e6 a9 1e LDA #&1e ; TILE_MUSIC_ROOM_TEXT &07e8 8d 5d 38 STA &385d ; tile_data + 1 * &78 + 0 * &28 + 4 * &05 + 1; room (4, 1), tile (1, 0) &07eb a9 28 LDA #&28 ; TILE_THE_ORACLE_TEXT &07ed 8d 32 3c STA &3c32 ; tile_data + 9 * &78 + 1 * &28 + 0 * &05 + 2; room (0, 9), tile (2, 1) &07f0 a9 3c LDA #&3c ; TILE_SNAIL &07f2 8d 93 3a STA &3a93 ; tile_data + 5 * &78 + 2 * &28 + 5 * &05 + 2; room (5, 5), tile (2, 2) &07f5 a9 39 LDA #&39 ; TILE_WALL_BOTTOM_HALF &07f7 8d af 3a STA &3aaf ; tile_data + 6 * &78 + 0 * &28 + 3 * &05 + 0; room (3, 6), tile (0, 0) &07fa a9 3f LDA #&3f ; TILE_WALL_COLUMN_RIGHT_EDGED &07fc 8d 5e 3c STA &3c5e ; tile_data + 9 * &78 + 2 * &28 + 1 * &05 + 1; room (1, 9), tile (1, 2) &07ff 60 RTS ; os_sound_workspace &0800 cc 00 00 00 00 00 00 00 c0 c0 c0 c0 04 04 04 04 &0810 00 00 00 64 00 00 00 ff 00 00 00 00 00 00 00 00 &0820 00 00 00 05 00 00 00 ff 00 00 00 00 00 00 00 00 &0830 00 00 00 00 00 00 00 00 ff 00 00 00 00 f0 00 0e &0840 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 &0850 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 &0860 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 &0870 64 06 90 64 06 90 64 06 90 64 06 00 00 00 00 90 ; status_sprite_data &0880 01 03 17 3f 17 03 01 f0 10 08 0c 8e 0c 08 10 f0 # &00 : STATUS_SPRITE_CRYSTAL &0890 01 01 03 13 17 37 3f f0 10 00 08 08 0c 8c 9e f0 # &01 : STATUS_SPRITE_GRENADE &08a0 13 17 1f fe ef 47 07 f0 18 0c 0e ee ee 4c 1c f0 # &02 : STATUS_SPRITE_REACTOR &08b0 00 00 00 00 00 00 00 f0 10 00 00 00 00 00 10 f0 # &03 : STATUS_SPRITE_BLANK ; os_envelope_data &08c0 01 fe 04 08 14 14 14 32 ff 00 fb 78 50 00 00 00 ; 1 # Using terminal, picking up or dropping object, door opening or closing, moving features &08d0 06 f1 f6 0a 0c 0a 0a 32 f6 fb fb 78 00 00 00 00 ; 2 # Collecting crystal &08e0 01 02 ff 06 0a 0a 32 32 ff 00 ec 7e 00 00 00 00 ; 3 # Starting jump &08f0 01 05 17 36 02 07 19 14 00 00 ff 7e 7d 00 00 00 ; 4 # Auto-transport ; object_data ; ry rx y x &0900 08 06 19 1a ; &28 (OBJECT_KEY_ONE) : room (6, 8) &0904 01 01 11 10 ; &2a (OBJECT_KEY_TWO) : room (1, 1) &0908 04 00 11 15 ; &2c (OBJECT_KEY_THREE) : room (0, 4) &090c 08 07 08 16 ; &2e (OBJECT_GOLDEN_DRAGON) : room (7, 8) &0910 05 07 13 20 ; &30 (OBJECT_WORM) : room (7, 5) &0914 02 00 19 1d ; &32 (OBJECT_CARD) : room (0, 2) &0918 0a 00 11 1a ; &34 (OBJECT_HERRING) : must be collected from horizontal enemy using worm &091c 0a 00 11 28 ; &36 (OBJECT_MOUSE) : must be collected from horizontal enemy using cheese &0920 01 05 17 36 ; &38 (OBJECT_CHEESE) : room (5, 1) &0924 02 07 19 12 ; &3a (OBJECT_CROSS) : room (7, 2) &0928 03 05 12 16 ; &3c (OBJECT_EYE) : room (5, 3) &092c 01 01 0a 45 ; &3e (OBJECT_BOTTLE) : room (1, 1) # Actually room (5, 7); see &09ac - &09af ; horizontal_enemy_data ; ry rx y x- x+ &0930 40 01 10 1d 46 ; room (1, 0), 2 horizontal enemies, type 0 (HORIZONTAL_ENEMY_TYPE_CATERPILLAR) &0935 03 00 18 30 46 ; room (0, 3), 1 horizontal enemy, type 0 (HORIZONTAL_ENEMY_TYPE_CATERPILLAR) &093a 05 01 18 04 1b ; room (1, 5), 1 horizontal enemy, type 0 (HORIZONTAL_ENEMY_TYPE_CATERPILLAR) &093f c4 02 13 10 2b ; room (2, 4), 4 horizontal enemies, type 0 (HORIZONTAL_ENEMY_TYPE_CATERPILLAR) &0944 01 02 0a 2c 3c ; room (2, 1), 1 horizontal enemy, type 0 (HORIZONTAL_ENEMY_TYPE_CATERPILLAR) &0949 42 01 18 23 4a ; room (1, 2), 2 horizontal enemies, type 0 (HORIZONTAL_ENEMY_TYPE_CATERPILLAR) &094e 81 26 19 1a 33 ; room (6, 1), 3 horizontal enemies, type 2 (HORIZONTAL_ENEMY_TYPE_MOUSE) &0953 00 05 10 1d 2f ; room (5, 0), 1 horizontal enemy, type 0 (HORIZONTAL_ENEMY_TYPE_CATERPILLAR) &0958 02 32 0f 14 3f ; room (2, 2), 1 horizontal enemy, type 3 (HORIZONTAL_ENEMY_TYPE_PLATFORM) &095d 03 33 0e 04 18 ; room (3, 3), 1 horizontal enemy, type 3 (HORIZONTAL_ENEMY_TYPE_PLATFORM) &0962 03 06 0a 0e 2d ; room (6, 3), 1 horizontal enemy, type 0 (HORIZONTAL_ENEMY_TYPE_CATERPILLAR) &0967 04 36 0c 1c 40 ; room (6, 4), 1 horizontal enemy, type 3 (HORIZONTAL_ENEMY_TYPE_PLATFORM) &096c 05 06 12 20 3b ; room (6, 5), 1 horizontal enemy, type 0 (HORIZONTAL_ENEMY_TYPE_CATERPILLAR) &0971 09 26 19 1a 33 ; room (6, 9), 1 horizontal enemy, type 2 (HORIZONTAL_ENEMY_TYPE_MOUSE) &0976 07 14 16 00 2f ; room (4, 7), 1 horizontal enemy, type 1 (HORIZONTAL_ENEMY_TYPE_FISH) &097b 06 04 10 24 45 ; room (4, 6), 1 horizontal enemy, type 0 (HORIZONTAL_ENEMY_TYPE_CATERPILLAR) ; initial_object_data &0980 08 06 19 08 ; &28 (OBJECT_KEY_ONE) : room (6, 8) &0984 01 01 11 10 ; &2a (OBJECT_KEY_TWO) : room (1, 1) &0988 04 00 11 15 ; &2c (OBJECT_KEY_THREE) : room (0, 4) &098c 08 07 08 16 ; &2e (OBJECT_GOLDEN_DRAGON) : room (7, 8) &0990 05 07 13 20 ; &30 (OBJECT_WORM) : room (7, 5) &0994 02 00 19 1d ; &32 (OBJECT_CARD) : room (0, 2) &0998 0a 00 11 1a ; &34 (OBJECT_HERRING) : must be collected from horizontal enemy using worm &099c 0a 00 11 28 ; &36 (OBJECT_MOUSE) : must be collected from horizontal enemy using cheese &09a0 01 05 17 36 ; &38 (OBJECT_CHEESE) : room (5, 1) &09a4 02 07 19 12 ; &3a (OBJECT_CROSS) : room (7, 2) &09a8 03 05 12 16 ; &3c (OBJECT_EYE) : room (5, 3) &09ac 07 05 11 24 ; &3e (OBJECT_BOTTLE) : room (5, 7) ; rooms_colour_and_wall_type # ....8421 room colour ; x 0 1 2 3 4 5 6 7 y # 8421.... wall type &09b0 03 13 06 06 32 92 16 16 ; 0 &09b8 67 12 83 26 13 13 16 65 ; 1 &09c0 66 33 a2 26 c3 36 62 17 ; 2 &09c8 a6 26 53 63 96 15 36 82 ; 3 &09d0 63 13 52 09 35 42 62 b6 ; 4 &09d8 62 06 92 42 42 43 42 73 ; 5 &09e0 07 23 0b 12 45 56 15 26 ; 6 &09e8 0b 23 42 16 53 36 05 60 ; 7 &09f0 6a 16 16 16 16 16 12 13 ; 8 &09f8 15 16 16 16 72 12 c3 b2 ; 9 ; diagonal_enemy_data ; ry rx y- x- y+ x+ &0a00 05 01 06 11 18 1c ; room (1, 5), 1 diagonal enemy, type 0 (DIAGONAL_ENEMY_TYPE_BAT) &0a06 03 12 05 04 1a 1e ; room (2, 3), 1 diagonal enemy, type 1 (DIAGONAL_ENEMY_TYPE_WHIRLIGIG) &0a0c 41 15 02 00 0c 4a ; room (5, 1), 2 diagonal enemies, type 1 (DIAGONAL_ENEMY_TYPE_WHIRLIGIG) &0a12 40 03 06 11 11 3c ; room (3, 0), 2 diagonal enemies, type 0 (DIAGONAL_ENEMY_TYPE_BAT) &0a18 41 00 03 21 18 2c ; room (0, 1), 2 diagonal enemies, type 0 (DIAGONAL_ENEMY_TYPE_BAT) &0a1e 01 12 03 18 0b 49 ; room (2, 1), 1 diagonal enemy, type 1 (DIAGONAL_ENEMY_TYPE_WHIRLIGIG) &0a24 43 11 07 14 17 43 ; room (1, 3), 2 diagonal enemies, type 1 (DIAGONAL_ENEMY_TYPE_WHIRLIGIG) &0a2a 06 11 04 06 0b 3e ; room (1, 6), 1 diagonal enemy, type 1 (DIAGONAL_ENEMY_TYPE_WHIRLIGIG) &0a30 45 22 04 00 11 2b ; room (2, 5), 2 diagonal enemies, type 2 (DIAGONAL_ENEMY_TYPE_BUTTERFLY) &0a36 02 06 06 1d 08 28 ; room (6, 2), 1 diagonal enemy, type 0 (DIAGONAL_ENEMY_TYPE_BAT) &0a3c 45 24 04 00 14 40 ; room (4, 5), 2 diagonal enemies, type 2 (DIAGONAL_ENEMY_TYPE_BUTTERFLY) &0a42 42 14 06 34 18 4b ; room (4, 2), 2 diagonal enemies, type 1 (DIAGONAL_ENEMY_TYPE_WHIRLIGIG) &0a48 02 10 17 15 18 4b ; room (0, 2), 1 diagonal enemy, type 1 (DIAGONAL_ENEMY_TYPE_WHIRLIGIG) &0a4e 03 04 04 00 13 3e ; room (4, 3), 1 diagonal enemy, type 0 (DIAGONAL_ENEMY_TYPE_BAT) &0a54 44 25 04 15 14 32 ; room (5, 4), 2 diagonal enemies, type 2 (DIAGONAL_ENEMY_TYPE_BUTTERFLY) &0a5a 04 24 04 08 19 2e ; room (4, 4), 1 diagonal enemy, type 2 (DIAGONAL_ENEMY_TYPE_BUTTERFLY) &0a60 47 27 06 0a 18 42 ; room (7, 7), 2 diagonal enemies, type 2 (DIAGONAL_ENEMY_TYPE_BUTTERFLY) &0a66 06 03 0c 10 12 3b ; room (3, 6), 1 diagonal enemy, type 0 (DIAGONAL_ENEMY_TYPE_BAT) # actually DIAGONAL_ENEMY_TYPE_JELLYFISH &0a6c 47 12 05 07 12 49 ; room (2, 7), 2 diagonal enemies, type 1 (DIAGONAL_ENEMY_TYPE_WHIRLIGIG) # actually DIAGONAL_ENEMY_TYPE_JELLYFISH &0a72 47 23 04 00 19 41 ; room (3, 7), 2 diagonal enemies, type 2 (DIAGONAL_ENEMY_TYPE_BUTTERFLY) # actually DIAGONAL_ENEMY_TYPE_JELLYFISH ; crossing_enemies_limits_and_y_table # .....421 ........ ........ minimum room x ; x- x+ y r sx r sx # 84218... ........ ........ minimum screen x &0a78 51 8d 0f : room_y = 0 : from 1.28 to 5.44 # ........ .....421 ........ maximum room x &0a7b 1d 46 07 ; room_y = 1 : from 5.0c to 6.20 # ........ 84218... ........ maximum screen x &0a7e 8c 76 13 ; room_y = 2 : from 4.44 to 6.38 # ........ ........ ..218421 screen y &0a81 7b 7e 0a ; room_y = 3 : from 3.3c to 6.3c &0a84 60 3a 11 ; room_y = 4 : from 0.30 to 2.1c &0a87 69 7a 18 ; room_y = 5 : from 1.34 to 2.3c &0a8a 4d 8e 08 ; room_y = 6 : from 5.24 to 6.44 &0a8d 6a 94 0b ; room_y = 7 : from 2.34 to 4.48 &0a90 28 3f 19 ; room_y = 8 : from 0.14 to 7.1c # Used to initialise ghost positions &0a93 60 7f 1c ; room_y = 9 : from 0.30 to 7.3c ; vertical_enemy_data ; ry rx x y- y+ &0a96 44 00 08 07 1b ; room (0, 4), 2 vertical enemies, type 0 (VERTICAL_ENEMY_TYPE_PLATFORM) &0a9b 42 01 28 0c 16 ; room (1, 2), 2 vertical enemies, type 0 (VERTICAL_ENEMY_TYPE_PLATFORM) &0aa0 06 01 44 14 1b ; room (1, 6), 1 vertical enemy, type 0 (VERTICAL_ENEMY_TYPE_PLATFORM) &0aa5 02 16 1e 0c 13 ; room (6, 2), 1 vertical enemy, type 1 (VERTICAL_ENEMY_TYPE_BUTTERFLY) &0aaa 41 10 08 04 13 ; room (0, 1), 2 vertical enemies, type 1 (VERTICAL_ENEMY_TYPE_BUTTERFLY) &0aaf 03 11 06 07 10 ; room (1, 3), 1 vertical enemy, type 1 (VERTICAL_ENEMY_TYPE_BUTTERFLY) &0ab4 40 12 14 0c 16 ; room (2, 0), 2 vertical enemies, type 1 (VERTICAL_ENEMY_TYPE_BUTTERFLY) &0ab9 48 16 08 11 18 ; room (6, 8), 2 vertical enemies, type 1 (VERTICAL_ENEMY_TYPE_BUTTERFLY) &0abe 00 15 26 05 10 ; room (5, 0), 1 vertical enemy, type 1 (VERTICAL_ENEMY_TYPE_BUTTERFLY) &0ac3 08 14 10 08 0e ; room (4, 8), 1 vertical enemy, type 1 (VERTICAL_ENEMY_TYPE_BUTTERFLY) &0ac8 05 14 21 09 11 ; room (4, 5), 1 vertical enemy, type 1 (VERTICAL_ENEMY_TYPE_BUTTERFLY) &0acd 08 16 00 14 18 ; room (6, 8), 1 vertical enemy, type 1 (VERTICAL_ENEMY_TYPE_BUTTERFLY) &0ad2 05 16 2e 0c 12 ; room (6, 5), 1 vertical enemy, type 1 (VERTICAL_ENEMY_TYPE_BUTTERFLY) &0ad7 07 17 26 0e 18 ; room (7, 7), 1 vertical enemy, type 1 (VERTICAL_ENEMY_TYPE_BUTTERFLY) &0adc 44 17 18 05 0c ; room (7, 4), 2 vertical enemies, type 1 (VERTICAL_ENEMY_TYPE_BUTTERFLY) &0ae1 03 14 2e 04 12 ; room (4, 3), 1 vertical enemy, type 1 (VERTICAL_ENEMY_TYPE_BUTTERFLY) &0ae6 42 12 34 05 13 ; room (2, 2), 2 vertical enemies, type 1 (VERTICAL_ENEMY_TYPE_BUTTERFLY) &0aeb 06 14 40 0d 19 ; room (4, 6), 1 vertical enemy, type 1 (VERTICAL_ENEMY_TYPE_BUTTERFLY) &0af0 08 11 26 04 15 ; room (1, 8), 1 vertical enemy, type 1 (VERTICAL_ENEMY_TYPE_BUTTERFLY) &0af5 45 13 38 11 16 ; room (3, 5), 2 vertical enemies, type 1 (VERTICAL_ENEMY_TYPE_BUTTERFLY) ; unused # Source code fragment &0afa 7c 0e 4c 44 59 63 ; (3)80LDYc ... ; to_reset_game &0b00 4c c8 0b JMP &0bc8 ; reset_game ; object_names &0b03 20 20 20 20 20 20 ; &00 (OBJECT_NONE) : " " &0b09 20 20 6b 65 79 20 ; &28 (OBJECT_KEY_ONE) : " key " &0b0f 20 20 6b 65 79 20 ; &2a (OBJECT_KEY_TWO) : " key " &0b15 20 20 6b 65 79 20 ; &2c (OBJECT_KEY_THREE) : " key " &0b1b 20 20 73 61 6c 74 ; &2e (OBJECT_GOLDEN_DRAGON) : " salt" &0b21 20 77 6f 72 6d 20 ; &30 (OBJECT_WORM) : " worm " &0b27 20 20 63 61 72 64 ; &32 (OBJECT_CARD) : " card" &0b2d 68 65 72 72 69 6e ; &34 (OBJECT_HERRING) : "herrin" &0b33 20 6d 6f 75 73 65 ; &36 (OBJECT_MOUSE) : " mouse" &0b39 63 68 65 65 73 65 ; &38 (OBJECT_CHEESE) : "cheese" &0b3f 20 63 72 6f 73 73 ; &3a (OBJECT_CROSS) : " cross" &0b45 20 20 65 79 65 20 ; &3c (OBJECT_EYE) : " eye " &0b4b 62 6f 74 74 6c 65 ; &3e (OBJECT_BOTTLE) : "bottle" ; unused &0b51 00 00 ; music_room_expected_pitches ; 0 1 2 3 4 5 6 7 8 9 a b # 3rd, 2nd, 1st, 3rd, 2nd, 1st, 5th, 4th, 3rd, 5th, 4th, 3rd &0b53 44 3c 34 44 3c 34 50 48 44 50 48 44 # E, D, C, E, D, C, G, F, E, G, F, E ; sprite_addresses_table # Entries &00 - &0e are overwritten per room &0b5f 00 00 ; &00 (SPRITE_HORIZONTAL_ENEMY_RIGHT_FRAME_ONE) : &0000 &0b61 00 00 ; &02 (SPRITE_HORIZONTAL_ENEMY_LEFT_FRAME_ONE) : &0000 &0b63 00 00 ; &04 (SPRITE_HORIZONTAL_ENEMY_RIGHT_FRAME_TWO) : &0000 &0b65 00 00 ; &06 (SPRITE_HORIZONTAL_ENEMY_LEFT_FRAME_TWO) : &0000 &0b67 00 00 ; &08 (SPRITE_DIAGONAL_ENEMY_FRAME_ONE) : &0000 &0b69 00 00 ; &0a (SPRITE_DIAGONAL_ENEMY_FRAME_TWO) : &0000 &0b6b 00 00 ; &0c (SPRITE_VERTICAL_ENEMY_FRAME_ONE) : &0000 &0b6d 00 00 ; &0e (SPRITE_VERTICAL_ENEMY_FRAME_TWO) : &0000 &0b6f 40 06 ; &10 (SPRITE_WHIRLIGIG_FRAME_ONE) : &0640 = sprite_whirligig_frame_one &0b71 60 06 ; &12 (SPRITE_WHIRLIGIG_FRAME_TWO) : &0660 = sprite_whirligig_frame_two &0b73 c0 06 ; &14 (SPRITE_GHOST_RIGHT) : &06c0 = sprite_ghost_right &0b75 20 07 ; &16 (SPRITE_GHOST_LEFT) : &0720 = sprite_ghost_left &0b77 00 05 ; &18 (SPRITE_PLAYER_HEAD_RIGHT) : &0500 = sprite_player_head_right &0b79 60 05 ; &1a (SPRITE_PLAYER_HEAD_LEFT) : &0560 = sprite_player_head_left &0b7b 40 05 ; &1c (SPRITE_PLAYER_FEET_RIGHT_FRAME_ONE) : &0540 = sprite_player_feet_right_one &0b7d e0 05 ; &1e (SPRITE_PLAYER_FEET_RIGHT_FRAME_TWO) : &05e0 = sprite_player_feet_right_two &0b7f a0 05 ; &20 (SPRITE_PLAYER_FEET_LEFT_FRAME_ONE) : &05a0 = sprite_player_feet_left_one &0b81 c0 05 ; &22 (SPRITE_PLAYER_FEET_LEFT_FRAME_TWO) : &05c0 = sprite_player_feet_left_two ; event_handler &0b83 08 PHP &0b84 48 PHA ; tmp_a &0b85 98 TYA &0b86 48 PHA ; tmp_y &0b87 8a TXA &0b88 48 PHA ; tmp_x &0b89 a2 9b LDX #&9b ; &0b9b = write_timer_block &0b8b a0 0b LDY #&0b &0b8d a9 04 LDA #&04 ; Write interval timer &0b8f 20 f1 ff JSR &fff1 ; OSWORD &0b92 85 6d STA &6d ; time_needs_replotting # Set to non-zero to indicate time needs replotting &0b94 68 PLA ; tmp_x &0b95 aa TAX &0b96 68 PLA ; tmp_y &0b97 a8 TAY &0b98 68 PLA ; tmp_a &0b99 28 PLP &0b9a 60 RTS ; write_timer_block &0b9b 90 e8 ff ff ff ; -6000 # Trigger event every minute ; reset_clock &0ba0 a9 02 LDA #&02 ; Write system clock &0ba2 a2 00 LDX #&00 &0ba4 a0 0e LDY #&0e &0ba6 4c f1 ff JMP &fff1 ; OSWORD ; write_two_digit_number # Called with A = number &0ba9 48 PHA ; number &0baa 4a LSR A &0bab 4a LSR A &0bac 4a LSR A &0bad 4a LSR A &0bae 18 CLC &0baf 69 30 ADC #&30 ; "0" &0bb1 20 ee ff JSR &ffee ; OSWRCH &0bb4 68 PLA ; number &0bb5 29 0f AND #&0f &0bb7 18 CLC &0bb8 69 30 ADC #&30 ; "0" &0bba 4c ee ff JMP &ffee ; OSWRCH ; to_gain_stun_grenade &0bbd 4c 43 0c JMP &0c43 ; gain_stun_grenade ; music_room_pipes_pitch_table ; 0 1 2 3 4 5 6 7 ; C D E F G A B C &0bc0 34 3c 44 48 50 58 60 64 ; reset_game &0bc8 20 80 07 JSR &0780 ; reset_tiles &0bcb 20 45 32 JSR &3245 ; reset_objects &0bce 20 6e 0c JSR &0c6e ; title_screen ; new_game &0bd1 a9 01 LDA #&01 # Player starts in room (1, 0) &0bd3 85 90 STA &90 ; player_room_x &0bd5 a9 00 LDA #&00 &0bd7 85 8f STA &8f ; player_room_y &0bd9 85 a0 STA &a0 ; bottle_contains_salt # Set to zero to indicate bottle doesn't contain salt &0bdb 85 70 STA &70 ; player_room_y_data_offset_low # 0 * &78 &0bdd 85 71 STA &71 ; player_room_y_data_offset_high &0bdf a9 44 LDA #&44 # Clock starts at 10:44 &0be1 8d c3 32 STA &32c3 ; time_minutes &0be4 a9 10 LDA #&10 &0be6 8d c4 32 STA &32c4 ; time_hours ; plot_crystals_remaining &0be9 a9 02 LDA #&02 ; SUBTILE_SET_STATUS_SPRITES &0beb 8d 24 12 STA &1224 ; subtile_set &0bee a0 0c LDY #&0c &0bf0 84 2a STY &2a ; crystals_remaining &0bf2 a9 f0 LDA #&f0 ; &3cf0 &0bf4 85 7c STA &7c ; screen_address_low &0bf6 a9 3c LDA #&3c &0bf8 85 7d STA &7d ; screen_address_high ; plot_crystals_remaining_loop &0bfa a9 00 LDA #&00 ; STATUS_SPRITE_CRYSTAL &0bfc 85 79 STA &79 ; underwater # Set to zero to not use water for blank &0bfe f0 10 BEQ &0c10 ; skip_character_data # Always branches ; user_defined_character_data &0c00 7c c6 c6 c6 c6 d6 7c 0f ; &80 : Q # Used in room (1, 0) &0c08 06 06 0f eb ed 4f 4f ef ; &81 : glass and bottle # Used in room (7, 8) ; skip_character_data &0c10 20 26 12 JSR &1226 ; to_plot_subtile &0c13 88 DEY &0c14 d0 e4 BNE &0bfa ; plot_crystals_remaining_loop ; plot_reactors_remaining &0c16 a9 70 LDA #&70 ; &3f70 &0c18 85 7c STA &7c ; screen_address_low &0c1a a9 3f LDA #&3f &0c1c 85 7d STA &7d ; screen_address_high &0c1e a9 02 LDA #&02 ; STATUS_SPRITE_REACTOR &0c20 20 26 12 JSR &1226 ; to_plot_subtile &0c23 20 26 12 JSR &1226 ; to_plot_subtile &0c26 20 26 12 JSR &1226 ; to_plot_subtile &0c29 a9 60 LDA #&60 ; &7460 &0c2b 85 36 STA &36 ; player_previous_screen_address_low &0c2d 85 38 STA &38 ; player_screen_address_low &0c2f a9 74 LDA #&74 &0c31 85 37 STA &37 ; player_previous_screen_address_high &0c33 85 39 STA &39 ; player_screen_address_high &0c35 a9 1c LDA #&1c &0c37 85 35 STA &35 ; player_x &0c39 a9 b0 LDA #&b0 &0c3b 85 2c STA &2c ; player_y &0c3d 20 00 22 JSR &2200 ; to_play_game &0c40 4c c8 0b JMP &0bc8 : reset_game ; gain_stun_grenade &0c43 a5 a1 LDA &a1 ; stun_grenades_carried_plus_four &0c45 c9 0c CMP #&0c &0c47 f0 24 BEQ &0c6d ; leave &0c49 e6 a1 INC &a1 ; stun_grenades_carried_plus_four &0c4b a5 a1 LDA &a1 ; stun_grenades_carried_plus_four &0c4d 0a ASL A &0c4e 0a ASL A &0c4f 0a ASL A &0c50 0a ASL A &0c51 69 60 ADC #&60 &0c53 85 7c STA &7c ; screen_address_low &0c55 a9 3f LDA #&3f &0c57 69 00 ADC #&00 &0c59 85 7d STA &7d ; screen_address_high &0c5b a9 02 LDA #&02 ; SUBTILE_SET_STATUS_SPRITES &0c5d 8d 24 12 STA &1224 ; subtile_set &0c60 a9 01 LDA #&01 ; STATUS_SPRITE_GRENADE &0c62 20 26 12 JSR &1226 ; to_plot_subtile &0c65 a9 00 LDA #&00 ; SUBTILE_SET_TILE_SPRITES &0c67 8d 24 12 STA &1224 ; subtile_set &0c6a 60 RTS ; leave_after_double_pla &0c6b 68 PLA ; cooldown &0c6c 68 PLA ; title screen room offset ; leave &0c6d 60 RTS ; title_screen &0c6e a2 9f LDX #&9f &0c70 a9 00 LDA #&00 ; wipe_0001_to_009f_loop &0c72 95 00 STA &00,X # Wipe &0001 - &009f &0c74 ca DEX &0c75 d0 fb BNE &0c72 ; wipe_0001_to_009f_loop &0c77 a2 04 LDX #&04 &0c79 86 a2 STX &a2 ; force_fields_remaining &0c7b ca DEX ; 3 &0c7c 86 89 STX &89 ; reactors_remaining &0c7e a9 01 LDA #&01 &0c80 85 41 STA &41 ; sprite_height &0c82 a0 10 LDY #&10 ; title_screen_room_loop &0c84 b9 ec 0c LDA &0cec,Y ; title_screen_rooms_coordinates_data + 1 &0c87 85 31 STA &31 ; coordinates &0c89 29 0f AND #&0f &0c8b 85 90 STA &90 ; player_room_x &0c8d a5 31 LDA &31 ; coordinates &0c8f 4a LSR A &0c90 4a LSR A &0c91 4a LSR A &0c92 4a LSR A &0c93 85 8f STA &8f ; player_room_y &0c95 a9 00 LDA #&00 &0c97 85 70 STA &70 ; player_room_y_data_offset_low &0c99 85 71 STA &71 ; player_room_y_data_offset_high &0c9b a2 78 LDX #&78 ; calculate_player_room_y_data_offset_loop &0c9d 18 CLC &0c9e a5 70 LDA &70 ; player_room_y_data_offset_low &0ca0 65 8f ADC &8f ; player_room_y &0ca2 85 70 STA &70 ; player_room_y_data_offset_low &0ca4 90 02 BCC &0ca8 ; skip_page &0ca6 e6 71 INC &71 ; player_room_y_data_offset_high ; skip_page &0ca8 ca DEX &0ca9 d0 f2 BNE &0c9d ; calculate_player_room_y_data_offset_loop &0cab 98 TYA &0cac 48 PHA ; title screen room offset &0cad 20 06 12 JSR &1206 ; to_plot_room &0cb0 20 1f 22 JSR &221f ; to_initialise_crossing_enemies &0cb3 a2 46 LDX #&46 ; 70 ; title_screen_loop &0cb5 8a TXA &0cb6 48 PHA ; cooldown &0cb7 e0 28 CPX #&28 ; 40 &0cb9 d0 14 BNE &0ccf ; skip_writing_press_space &0cbb 20 56 32 JSR &3256 ; write_string &0cbe 1f 0e 07 ; TAB(&0e, &07) &0cc1 20 50 52 45 53 53 20 53 50 41 43 45 20 ; " PRESS SPACE " &0cce 00 ; end of string &0ccf 20 a0 0b JSR &0ba0 ; reset_clock ; skip_writing_press_space &0cd2 20 1b 22 JSR &221b ; to_update_title_screen &0cd5 a9 81 LDA #&81 ; Scan for a particular key &0cd7 a0 ff LDY #&ff &0cd9 a2 9d LDX #&9d ; SPACE &0cdb 20 f4 ff JSR &fff4 ; OSBYTE &0cde b0 8b BCS &0c6b ; leave_after_double_pla &0ce0 68 PLA ; cooldown &0ce1 aa TAX &0ce2 ca DEX &0ce3 d0 d0 BNE &0cb5 ; title_screen_loop &0ce5 68 PLA ; title screen room offset &0ce6 a8 TAY &0ce7 88 DEY &0ce8 d0 9a BNE &0c84 ; title_screen_room_loop &0cea 4c 6e 0c JMP &0c6e ; title_screen ; title_screen_rooms_coordinates_data # ....8421 room x ; 1 2 3 4 5 6 7 8 9 a b c d e f 10 # 8421.... room y &0ced 86 31 14 05 96 42 35 73 17 54 90 53 61 45 60 01 ; unused &0cfd 20 3a 34 ; " :4" # &2600 - &597f is moved to &0e00 - &417f at &59c6 ; tile_sprite_data &0e00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ; &00 : SUBTILE_BLANK &0e10 01 03 17 17 07 17 16 03 01 0f ff 5f af 5f fa 0f ; &01 : SUBTILE_STONE_ONE &0e20 00 0f ff 5f af 5f fa 0f 08 0e cf 4f 8f 4f cb 0e ; &02 : SUBTILE_STONE_TWO &0e30 7f 3f 3f 1f 1f 0f 0f 0f fe fc fc f8 f8 f0 f0 f0 ; &03 : SUBTILE_BEVELLED_BLOCK_ONE &0e40 0f 0e 0e 0c 0c 08 08 7f f0 70 70 30 30 10 10 fe ; &04 : SUBTILE_BEVELLED_BLOCK_TWO &0e50 00 00 00 11 33 76 fc e8 33 76 fc e8 c0 80 00 00 ; &05 : SUBTILE_DIAGONAL &0e60 f0 f0 00 0c 00 04 00 02 c0 e0 30 18 10 1c 10 10 ; &06 : SUBTILE_TERMINAL_RIGHT &0e70 cc 66 33 11 11 32 64 c8 11 32 64 c8 cc 66 33 11 ; &07 : SUBTILE_CRISSCROSS &0e80 0c 0c 0f cc e6 73 31 0f 0c 0c 0f 33 76 ec c8 0f ; &08 : SUBTILE_WALL_EDGE &0e90 0a 05 0a 05 0a 05 0a 05 0a 05 0a 05 0a 05 0a 05 ; &09 : SUBTILE_ACID ; sprite_platform &0ea0 ff ff 23 11 00 00 00 00 ff ff 0f 0f f8 f8 00 00 ; &0a : SUBTILE_PLATFORM &0eb0 ff ff 0f 0e d0 d0 00 00 ff ff 04 08 00 00 00 00 ; &0b : SUBTILE_PLATFORM_RIGHT &0ec0 00 00 10 30 60 60 f0 f1 00 e0 90 10 00 00 80 e0 ; &0c : SUBTILE_SNAIL_TOP_RIGHT &0ed0 f4 f0 f0 f4 f0 82 80 f0 f4 f0 f8 e0 c0 04 04 c0 ; &0d : SUBTILE_SNAIL_BOTTOM_RIGHT &0ee0 66 77 22 33 33 11 0e 0f 00 cc ee 66 bb dd 67 0f ; &0e : SUBTILE_LEAF_LEFT &0ef0 00 33 77 66 dd bb ef 0f ee ee 66 cc cc 88 0e 03 ; &0f : SUBTILE_LEAF_RIGHT &0f00 00 00 00 01 01 03 17 7a 01 12 17 3e f7 fa fd fa ; &10 : SUBTILE_CRYSTAL_LEFT &0f10 08 84 8e c7 fe f5 fb f5 00 00 00 08 08 0c 8e e5 ; &11 : SUBTILE_CRYSTAL_RIGHT &0f20 c0 00 c0 00 c0 00 c0 00 c0 00 c0 00 c0 00 c0 00 ; &12 : SUBTILE_WATER &0f30 df df df df df df df df 5e 5e 5e 5e 5e 5e 5e 5e ; &13 : SUBTILE_PIPE &0f40 df df df df df ce cc 88 5e 4e 4c 08 00 00 00 00 ; &14 : SUBTILE_PIPE_BOTTOM &0f50 07 0f 09 01 77 df df df 0e 0f 09 08 ee 5e 5e 5c ; &15 : SUBTILE_PIPE_TOP &0f60 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ; &16 : SUBTILE_SOLID &0f70 08 8c ce ef ef ff ff ff 00 00 00 00 08 0c 8e cf ; &17 : SUBTILE_EDGED_TRIANGLE &0f80 00 00 00 00 01 67 47 0f 11 23 8f c1 c0 e0 f7 ee ; &18 : SUBTILE_BUMP_LEFT &0f90 08 48 2d 2d 3c 98 cc dc 00 00 00 00 08 0c c3 f0 ; &19 : SUBTILE_BUMP_RIGHT &0fa0 c0 f0 3c 8f ef ff 7f b7 00 80 c0 e0 68 68 3c bc ; &1a : SUBTILE_TUBE_CORNER_LEFT &0fb0 00 10 30 70 61 61 c3 d3 30 f0 c3 1f 7f ff ef de ; &1b : SUBTILE_TUBE_CORNER_RIGHT &0fc0 30 70 c0 80 80 81 80 80 f0 f0 00 0c 00 05 00 08 ; &1c : SUBTILE_TERMINAL_LEFT &0fd0 ff ff 0f 00 00 00 00 00 ff ff 0f 00 00 00 00 00 ; &1d : SUBTILE_SURFACE &0fe0 b7 b7 b7 b7 b7 b7 b7 b7 de de de de de de de de ; &1e : SUBTILE_TUBE_VERTICAL &0ff0 00 00 11 33 33 77 77 77 00 77 ff ff ff ff ff ff ; &1f : SUBTILE_ELEPHANT_TOP_LEFT &1000 f0 0f ff ff ff ff 0f f0 f0 0f ff ff ff ff 0f f0 ; &20 : SUBTILE_TUBE_HORIZONTAL &1010 88 ef cf 8f 9e 2d 4b 0f 07 0f a5 0f 4b 2d 0f 0f ; &21 : SUBTILE_ELEPHANT_HEAD_LEFT &1020 7f 3f 1f 1f 3e 3e 7e 7f cc ee ff ff f3 3f 3f ff ; &22 : SUBTILE_ELEPHANT_HEAD_TOP_RIGHT &1030 7f 7f 7f 7f 7f f7 fb 31 ff ff ff ee ee ee ee cc ; &23 : SUBTILE_ELEPHANT_HEAD_BOTTOM_RIGHT &1040 11 10 11 10 11 10 11 10 cc cc cc cc cc cc cc cc ; &24 : SUBTILE_LEG &1050 77 77 77 77 77 77 77 77 ee ee ee ee ee ee ee ee ; &25 : SUBTILE_PILLAR &1060 00 00 00 00 00 00 ff ff 00 00 00 00 00 00 ff ff ; &26 : SUBTILE_PLATFORM_FLOOR &1070 00 44 44 44 4e ee 4e f0 00 44 44 44 4e ee 4e f0 ; &27 : SUBTILE_SPIKES &1080 0f 0f 3c 3c 3c 1c 0f 0f 0f 0f c3 c3 c3 c3 0f 0f ; &28 : SUBTILE_KEY_ONE # Used for OBJECT_KEY_ONE &1090 00 00 00 0f 0f 00 00 00 00 00 02 0f 0f 0e 0c 04 ; &29 : SUBTILE_KEY_ONE_RIGHT &10a0 01 03 06 3c 3c 16 03 01 08 0c 86 c3 c3 86 0c 08 ; &2a : SUBTILE_KEY_TWO # Used for OBJECT_KEY_TWO &10b0 00 00 00 0f 0f 00 00 00 00 00 00 0f 0f 0e 06 02 ; &2b : SUBTILE_KEY_TWO_RIGHT &10c0 0f 0f 3c 3c 3c 3c 0f 0f 0f 0f c3 c3 c3 83 0f 0f ; &2c : SUBTILE_KEY_THREE # Used for OBJECT_KEY_THREE &10d0 00 00 00 0f 0f 00 00 00 00 00 00 0f 0f 0e 0a 0a ; &2d : SUBTILE_KEY_THREE_RIGHT &10e0 00 00 ff bb 0c 03 33 ff 11 ff fc ff 0f 7f ff 88 ; &2e : SUBTILE_GOLDEN_DRAGON # Used for OBJECT_GOLDEN_DRAGON &10f0 cc ff ef ef ff ff 77 77 06 0e 0c 4c ee ee ee cc ; &2f : SUBTILE_GOLDEN_DRAGON_RIGHT &1100 00 00 00 77 bf ff 11 77 00 11 33 76 fa ec cc 00 ; &30 : SUBTILE_WORM # Used for OBJECT_WORM &1110 cc ee fd 73 32 11 00 00 00 00 00 00 88 88 cc 73 ; &31 : SUBTILE_WORM_RIGHT &1120 30 70 f0 f0 e1 c3 70 33 f0 e1 c3 69 3c 1e f0 ff ; &32 : SUBTILE_CARD # Used for OBJECT_CARD &1130 f0 3c 1e 0f 87 c3 f0 ff c0 e0 f0 f0 78 3c e0 cc ; &33 : SUBTILE_CARD_RIGHT ; sprite_fish_left &1140 00 01 03 07 0f 00 03 00 07 0f c3 c3 0f 03 0f 07 ; &34 : SUBTILE_HERRING # Used for OBJECT_HERRING &1150 08 0e 0f 0f 0f 0f 0e 08 01 03 16 0f 2d 16 03 01 ; &35 : SUBTILE_HERRING_RIGHT ; sprite_mouse_left &1160 33 33 11 23 ff 00 00 11 00 33 ff ff ff 77 cc 00 ; &36 : SUBTILE_MOUSE # Used for OBJECT_MOUSE &1170 00 cc ee ee ff ff 66 cc cc 22 11 11 22 cc 00 00 ; &37 : SUBTILE_MOUSE_RIGHT &1180 00 33 66 77 55 ff bb ff 00 cc ff bb ff ee 77 ff ; &38 : SUBTILE_CHEESE # Used for OBJECT_CHEESE &1190 00 00 00 cc ff dd 77 ff 00 00 00 00 00 cc 66 ff ; &39 : SUBTILE_CHEESE_RIGHT &11a0 01 01 10 0f 0f 01 01 01 08 08 08 0f 0f 80 08 08 ; &3a : SUBTILE_CROSS # Used for OBJECT_CROSS &11b0 00 00 00 0f 0f 00 00 00 00 00 07 0f 0f 07 00 00 ; &3b : SUBTILE_CROSS_RIGHT &11c0 00 03 06 0c 0c 06 03 00 0f 1c 30 60 60 30 1c 0f ; &3c : SUBTILE_EYE # Used for OBJECT_EYE &11d0 0f 83 c0 60 60 c0 83 0f 00 0c 06 03 03 06 0c 00 ; &3d : SUBTILE_EYE_RIGHT &11e0 00 10 fc bc fc ac 10 00 f0 f0 f0 f0 f0 70 80 f0 ; &3e : SUBTILE_BOTTLE # Used for OBJECT_BOTTLE &11f0 f0 f0 f0 f0 f0 f0 00 f0 e0 f0 f0 f0 f0 d0 30 e0 ; &3f : SUBTILE_BOTTLE_RIGHT ; to_calculate_screen_address &1200 4c f0 1d JMP &1df0 ; calculate_screen_address ; to_move_up_a_room &1203 4c b5 1c JMP &1cb5 ; move_up_a_room ; to_plot_room &1206 4c 98 1b JMP &1b98 ; plot_room ; to_move_down_a_room &1209 4c c7 1c JMP &1cc7 ; move_down_a_room ; move_left_a_room_and_plot_room &120c c6 90 DEC &90 ; player_room_x &120e 4c 98 1b JMP &1b98 ; plot_room ; move_right_a_room_and_plot_room &1211 e6 90 INC &90 ; player_room_x &1213 4c 98 1b JMP &1b98 ; plot_room ; unused &1216 00 00 00 00 00 00 ea ; horizontal_enemies_y &121d 00 ; horizontal_enemies_minimum_x &121e 00 ; horizontal_enemies_maximum_x &121f 00 ; room_has_horizontal_enemies &1220 00 ; diagonal_enemies_type &1221 00 ; offset_of_last_diagonal_enemy &1222 00 ; offset_of_last_horizontal_enemy_plus_two &1223 00 ; subtile_set &1224 00 ; horizontal_enemies_type &1225 00 ; to_plot_subtile &1226 4c e4 1c JMP &1ce4 ; plot_subtile ; unused &1229 00 ; horizontal_enemies_x_velocity + 0 &122a 00 ; unused &122b 00 ; horizontal_enemies_x_velocity + 2 &122c 00 ; unused &122d 00 ; horizontal_enemies_unused + 0 &122e 00 ; unused &122f 00 ; horizontal_enemies_unused + 2 &1230 00 ; diagonal_enemies_y + 0 &1231 00 ; unused &1232 00 ; diagonal_enemies_y + 2 &1233 00 ; unused &1234 00 ; diagonal_enemies_maximum_x &1235 00 ; diagonal_enemies_minimum_x &1236 00 ; diagonal_enemies_minimum_y &1237 00 ; diagonal_enemies_maximum_y &1238 00 ; room_has_diagonal_enemies &1239 00 ; diagonal_enemies_x_velocity + 0 &123a 00 ; diagonal_enemies_y_velocity + 0 &123b 00 ; diagonal_enemies_x_velocity + 2 &123c 00 ; diagonal_enemies_y_velocity + 2 &123d 00 ; unused &123e 00 00 00 00 ; game_event &1242 00 ; feature_screen_address_low &1243 00 ; feature_screen_address_high &1244 00 ; room_has_vertical_enemies &1245 00 ; vertical_enemies_minimum_y &1246 00 ; vertical_enemies_maximum_y &1247 00 ; vertical_enemy_x &1248 00 ; vertical_enemy_type &1249 00 ; vertical_enemy_top_two_bits_plus_ten &124a 00 ; to_terminal_screen &124b 4c b3 20 JMP &20b3 ; terminal_screen ; plot_byte_to_tile_screen_address &124e 91 7a STA (&7a),Y ; tile_screen_address &1250 18 CLC &1251 a5 7a LDA &7a ; tile_screen_address_low &1253 69 08 ADC #&08 # Move right four pixels &1255 85 7a STA &7a ; tile_screen_address_low &1257 90 02 BCC &125b ; skip_page &1259 e6 7b INC &7b ; tile_screen_address_high ; skip_page &125b ca DEX &125c 60 RTS ; set_status_section_colours &125d a9 a3 LDA #&a3 # Set colour 3 to yellow &125f 20 69 12 JSR &1269 ; set_palette &1262 a9 21 LDA #&21 # Set colour 1 to blue &1264 20 69 12 JSR &1269 ; set_palette &1267 a9 84 LDA #&84 # Set colour 2 to red ; set_palette &1269 49 07 EOR #&07 &126b 48 PHA ; palette value &126c 8d 21 fe STA &fe21 ; video ULA palette register &126f 68 PLA ; palette value &1270 48 PHA ; palette value &1271 09 40 ORA #&40 &1273 8d 21 fe STA &fe21 ; video ULA palette register &1276 68 PLA ; palette value &1277 48 PHA ; palette value &1278 09 10 ORA #&10 &127a 8d 21 fe STA &fe21 ; video ULA palette register &127d 68 PLA ; palette value &127e 09 50 ORA #&50 &1280 8d 21 fe STA &fe21 ; video ULA palette register &1283 60 RTS ; plot_row_of_subtiles_for_row_of_tiles &1284 a5 09 LDA &09 ; row_in_tile &1286 85 f8 STA &f8 ; original_row_in_tile # &09 (row_in_tile) may be modified during plotting &1288 a0 00 LDY #&00 ; plot_row_of_subtiles_for_row_of_tiles_loop &128a a9 00 LDA #&00 &128c 85 43 STA &43 ; tile_is_flipped_vertically # Clear top bit to indicate not flipped vertically &128e b1 76 LDA (&76),Y ; tile_data_address &1290 8d 25 12 STA &1225 ; tile &1293 29 3f AND #&3f &1295 85 31 STA &31 ; tile_type &1297 84 03 STY &03 ; tile_x &1299 20 a8 12 JSR &12a8 ; plot_row_of_subtiles_for_tile &129c a5 f8 LDA &f8 ; original_row_in_tile &129e 85 09 STA &09 ; row_in_tile # Restore original value &12a0 a4 03 LDY &03 ; tile_x &12a2 c8 INY &12a3 c0 05 CPY #&05 &12a5 d0 e3 BNE &128a ; plot_row_of_subtiles_for_row_of_tiles_loop &12a7 60 RTS ; plot_row_of_subtiles_for_tile &12a8 ad 25 12 LDA &1225 ; tile &12ab 0a ASL A &12ac 90 03 BCC &12b1 ; call_plot_row_of_subtiles_for_tile_type_routine &12ae 4c 23 1b JMP &1b23 ; plot_row_of_character_tile # If top bit of tile set, tile is a character ; call_plot_row_of_subtiles_for_tile_type_routine # If top bit of tile clear, tile is not a character &12b1 06 31 ASL &31 ; tile_type &12b3 a6 31 LDX &31 ; tile_type &12b5 bd d3 12 LDA &12d3,X ; plot_row_of_subtiles_for_tile_type_routine_addresses_table + 1 &12b8 48 PHA ; routine address high # Push address of plot_row_of_subtiles_for_tile_type_XX onto stack &12b9 bd d2 12 LDA &12d2,X ; plot_row_of_subtiles_for_tile_type_routine_addresses_table &12bc 48 PHA ; routine address low &12bd ad 25 12 LDA &1225 ; tile &12c0 0a ASL A &12c1 0a ASL A &12c2 90 0b BCC &12cf ; skip_flipping_vertically # If &40 of tile set, tile is flipped vertically ; is_flipped_vertically ; flip_row_in_tile &12c4 a9 07 LDA #&07 &12c6 38 SEC &12c7 e5 09 SBC &09 ; row_in_tile &12c9 85 09 STA &09 ; row_in_tile &12cb a9 ff LDA #&ff &12cd 85 43 STA &43 ; tile_is_flipped_vertically # Set top bit to indicate flipped vertically ; skip_flipping_vertically &12cf a5 09 LDA &09 ; row_in_tile &12d1 60 RTS # Leave via plot_row_of_subtiles_for_tile_type_XX ; plot_row_of_subtiles_for_tile_type_routine_addresses_table &12d2 61 13 ; &1361 = plot_row_of_subtiles_for_tile_type_00 - 1 # TILE_SPACE &12d4 00 1b ; &1b00 = plot_row_of_subtiles_for_tile_type_01 - 1 # TILE_SPIKE_PIT &12d6 70 13 ; &1370 = plot_row_of_subtiles_for_tile_type_02 - 1 # TILE_WALL &12d8 b1 13 ; &13b1 = plot_row_of_subtiles_for_tile_type_03 - 1 # TILE_WALL_COLUMN_RIGHT &12da bb 13 ; &13bb = plot_row_of_subtiles_for_tile_type_04 - 1 # TILE_WALL_COLUMN_LEFT &12dc 04 14 ; &1404 = plot_row_of_subtiles_for_tile_type_05 - 1 # TILE_WALL_BOTTOM_LEFT_CORNER_EDGED &12de 1c 14 ; &141c = plot_row_of_subtiles_for_tile_type_06 - 1 # TILE_WALL_BOTTOM_RIGHT_CORNER_EDGED &12e0 42 14 ; &1442 = plot_row_of_subtiles_for_tile_type_07 - 1 # TILE_DOOR_ONE &12e2 47 14 ; &1447 = plot_row_of_subtiles_for_tile_type_08 - 1 # TILE_DOOR_TWO &12e4 8e 15 ; &158e = plot_row_of_subtiles_for_tile_type_09 - 1 # TILE_FORCE_FIELDS &12e6 36 14 ; &1436 = plot_row_of_subtiles_for_tile_type_0a - 1 # TILE_VAT_OF_WATER &12e8 a4 14 ; &14a4 = plot_row_of_subtiles_for_tile_type_0b - 1 # TILE_CRYSTAL &12ea 9f 14 ; &149f = plot_row_of_subtiles_for_tile_type_0c - 1 # TILE_OPEN_DOOR &12ec ef 14 ; &14ef = plot_row_of_subtiles_for_tile_type_0d - 1 # TILE_COLLECTED_CRYSTAL &12ee 17 15 ; &1517 = plot_row_of_subtiles_for_tile_type_0e - 1 # TILE_STONE_WINDOW &12f0 51 13 ; &1351 = plot_row_of_subtiles_for_tile_type_0f - 1 # TILE_SPIKES &12f2 3d 15 ; &153d = plot_row_of_subtiles_for_tile_type_10 - 1 # TILE_WALL_EDGED &12f4 4f 15 ; &154f = plot_row_of_subtiles_for_tile_type_11 - 1 # TILE_ELEPHANT &12f6 b0 15 ; &15b0 = plot_row_of_subtiles_for_tile_type_12 - 1 # TILE_STONE_FLOOR &12f8 c5 15 ; &15c5 = plot_row_of_subtiles_for_tile_type_13 - 1 # TILE_STONE_CEILING_EDGED &12fa 3d 14 ; &143d = plot_row_of_subtiles_for_tile_type_14 - 1 # TILE_CLOSED_DOOR &12fc de 15 ; &15de = plot_row_of_subtiles_for_tile_type_15 - 1 # TILE_ORGAN_PIPES &12fe 38 16 ; &1638 = plot_row_of_subtiles_for_tile_type_16 - 1 # TILE_DOUBLE_TRIANGLE &1300 4f 16 ; &164f = plot_row_of_subtiles_for_tile_type_17 - 1 # TILE_PILLAR &1302 a9 19 ; &19a9 = plot_row_of_subtiles_for_tile_type_18 - 1 # TILE_WALL_BOTTOM_RIGHT_CORNER &1304 b1 19 ; &19b1 = plot_row_of_subtiles_for_tile_type_19 - 1 # TILE_WALL_BOTTOM_LEFT_CORNER &1306 75 16 ; &1675 = plot_row_of_subtiles_for_tile_type_1a - 1 # TILE_TRANSMOGRIFIER &1308 84 16 ; &1684 = plot_row_of_subtiles_for_tile_type_1b - 1 # TILE_CROSSING_TRIANGLES &130a c1 16 ; &16c1 = plot_row_of_subtiles_for_tile_type_1c - 1 # TILE_STRIPS &130c dc 16 ; &16dc = plot_row_of_subtiles_for_tile_type_1d - 1 # TILE_CROSSING_TRIANGLES_ON_STRIPS &130e e9 16 ; &16e9 = plot_row_of_subtiles_for_tile_type_1e - 1 # TILE_MUSIC_ROOM_TEXT &1310 e9 16 ; &16e9 = plot_row_of_subtiles_for_tile_type_1f - 1 # TILE_LEVEL_SECTOR_TEXT &1312 e9 16 ; &16e9 = plot_row_of_subtiles_for_tile_type_20 - 1 # TILE_ELEPHANT_HOUSE_TEXT &1314 e9 16 ; &16e9 = plot_row_of_subtiles_for_tile_type_21 - 1 # TILE_JOKE_SHOP_TEXT &1316 e9 16 ; &16e9 = plot_row_of_subtiles_for_tile_type_22 - 1 # TILE_TELEPORT_TEXT &1318 e9 16 ; &16e9 = plot_row_of_subtiles_for_tile_type_23 - 1 # TILE_THE_ARMOURY_TEXT &131a e9 16 ; &16e9 = plot_row_of_subtiles_for_tile_type_24 - 1 # TILE_HYDROPONICS_TEXT &131c e9 16 ; &16e9 = plot_row_of_subtiles_for_tile_type_25 - 1 # TILE_HCL_TEXT &131e e9 16 ; &16e9 = plot_row_of_subtiles_for_tile_type_26 - 1 # TILE_NAOH_TEXT &1320 e9 16 ; &16e9 = plot_row_of_subtiles_for_tile_type_27 - 1 # TILE_TIME_WARP_TEXT &1322 e9 16 ; &16e9 = plot_row_of_subtiles_for_tile_type_28 - 1 # TILE_THE_ORACLE_TEXT &1324 e9 16 ; &16e9 = plot_row_of_subtiles_for_tile_type_29 - 1 # TILE_OPTICIAN_TEXT &1326 e9 16 ; &16e9 = plot_row_of_subtiles_for_tile_type_2a - 1 # TILE_CHEMICAL_SUPPLIES_TEXT &1328 e9 16 ; &16e9 = plot_row_of_subtiles_for_tile_type_2b - 1 # TILE_GHOST_MAZE_TEXT &132a e9 16 ; &16e9 = plot_row_of_subtiles_for_tile_type_2c - 1 # TILE_CHAPEL_TEXT &132c e9 16 ; &16e9 = plot_row_of_subtiles_for_tile_type_2d - 1 # TILE_PASSWORD_TEXT &132e 73 19 ; &1973 = plot_row_of_subtiles_for_tile_type_2e - 1 # TILE_WATER &1330 9f 19 ; &199f = plot_row_of_subtiles_for_tile_type_2f - 1 # TILE_REACTOR &1332 be 15 ; &15be = plot_row_of_subtiles_for_tile_type_30 - 1 # TILE_STONE_HORIZONTAL_PASSAGE_EDGED &1334 b1 18 ; &18b1 = plot_row_of_subtiles_for_tile_type_31 - 1 # TILE_STONE_VERTICAL_PASSAGE &1336 c0 18 ; &18c0 = plot_row_of_subtiles_for_tile_type_32 - 1 # TILE_VAT_OF_ACID &1338 15 19 ; &1915 = plot_row_of_subtiles_for_tile_type_33 - 1 # TILE_MOVING_PLATFORMS_TYPE_ONE &133a 03 19 ; &1903 = plot_row_of_subtiles_for_tile_type_34 - 1 # TILE_MOVING_PLATFORMS_TYPE_TWO &133c 80 19 ; &1980 = plot_row_of_subtiles_for_tile_type_35 - 1 # TILE_WALL_PYRAMID &133e b9 19 ; &19b9 = plot_row_of_subtiles_for_tile_type_36 - 1 # TILE_WALL_MIDDLE_AND_BOTTOM_LINES &1340 c7 19 ; &19c7 = plot_row_of_subtiles_for_tile_type_37 - 1 # TILE_WALL_MIDDLE_LINE &1342 ce 19 ; &19ce = plot_row_of_subtiles_for_tile_type_38 - 1 # TILE_WALL_BOTTOM_LINE &1344 d5 19 ; &19d5 = plot_row_of_subtiles_for_tile_type_39 - 1 # TILE_WALL_BOTTOM_HALF &1346 dc 19 ; &19dc = plot_row_of_subtiles_for_tile_type_3a - 1 # TILE_SINGLE_TRIANGLE &1348 6b 1a ; &1a6b = plot_row_of_subtiles_for_tile_type_3b - 1 # TILE_TERMINAL &134a 9a 1a ; &1a9a = plot_row_of_subtiles_for_tile_type_3c - 1 # TILE_SNAIL &134c d1 1a ; &1ad1 = plot_row_of_subtiles_for_tile_type_3d - 1 # TILE_TABLE_AND_CHAIRS &134e c5 13 ; &13c5 = plot_row_of_subtiles_for_tile_type_3e - 1 # TILE_WALL_COLUMN_LEFT_EDGED &1350 cc 13 ; &13cc = plot_row_of_subtiles_for_tile_type_3f - 1 # TILE_WALL_COLUMN_RIGHT_EDGED ; plot_row_of_subtiles_for_tile_type_0f # TILE_SPIKES &1352 c9 07 CMP #&07 &1354 d0 0c BNE &1362 ; plot_tile_width_of_blanks &1356 a2 08 LDX #&08 ; plot_row_of_subtiles_for_tile_type_0f_bottom_row_loop &1358 a9 27 LDA #&27 ; SUBTILE_SPIKES &135a 20 d8 1c JSR &1cd8 ; plot_subtile_considering_tile_vertical_flip &135d ca DEX &135e d0 f8 BNE &1358 ; plot_row_of_subtiles_for_tile_type_0f_bottom_row_loop &1360 60 RTS ; leave &1361 60 RTS ; plot_row_of_subtiles_for_tile_type_00 # TILE_SPACE ; plot_tile_width_of_blanks &1362 a2 08 LDX #&08 ; plot_X_subtiles_of_blanks &1364 e0 00 CPX #&00 &1366 f0 f9 BEQ &1361 ; leave &1368 a9 00 LDA #&00 ; SUBTILE_BLANK ; plot_X_subtiles_of_blanks_loop &136a 20 e4 1c JSR &1ce4 ; plot_subtile &136d ca DEX &136e d0 fa BNE &136a ; plot_X_subtiles_of_blanks_loop &1370 60 RTS ; plot_row_of_subtiles_for_tile_type_02 # TILE_WALL ; plot_tile_width_of_wall_subtiles &1371 a2 08 LDX #&08 ; plot_row_of_wall_subtiles &1373 e0 00 CPX #&00 &1375 f0 ea BEQ &1361 ; leave &1377 a5 f8 LDA &f8 ; initial_row_in_tile &1379 6a ROR A &137a b0 27 BCS &13a3 ; use_bottom_row_of_wall # Alternate between top and bottom subtiles ; use_top_row_of_wall &137c ad fc 7f LDA &7ffc ; room_wall_subtiles + 0 &137f 8d f9 7f STA &7ff9 ; left_subtile &1382 ad fd 7f LDA &7ffd ; room_wall_subtiles + 1 &1385 8d fa 7f STA &7ffa ; right_subtile ; plot_row_of_wall_subtiles_loop &1388 a5 7c LDA &7c ; screen_address_low &138a 29 1f AND #&1f &138c c9 10 CMP #&10 &138e f0 09 BEQ &1399 ; plot_right_subtile # Alternate between left and right subtiles ; plot_left_subtile &1390 ad f9 7f LDA &7ff9 ; left_subtile &1393 20 e4 1c JSR &1ce4 ; plot_subtile &1396 4c 9f 13 JMP &139f ; next_subtile ; plot_right_subtile &1399 ad fa 7f LDA &7ffa ; right_subtile &139c 20 e4 1c JSR &1ce4 ; plot_subtile ; next_subtile &139f ca DEX &13a0 d0 e6 BNE &1388 ; plot_row_of_wall_subtiles_loop ; leave &13a2 60 RTS ; use_bottom_row_of_wall &13a3 ad fe 7f LDA &7ffe ; room_wall_subtiles + 2 &13a6 8d f9 7f STA &7ff9 ; left_subtile &13a9 ad ff 7f LDA &7fff ; room_wall_subtiles + 3 &13ac 8d fa 7f STA &7ffa ; right_subtile &13af 4c 88 13 JMP &1388 ; plot_row_of_wall_subtiles_loop ; plot_row_of_subtiles_for_tile_type_03 # TILE_WALL_COLUMN_RIGHT &13b2 a2 06 LDX #&06 &13b4 20 64 13 JSR &1364 ; plot_X_subtiles_of_blanks &13b7 a2 02 LDX #&02 &13b9 4c 73 13 JMP &1373 ; plot_row_of_wall_subtiles ; plot_row_of_subtiles_for_tile_type_04 # TILE_WALL_COLUMN_LEFT &13bc a2 02 LDX #&02 &13be 20 73 13 JSR &1373 ; plot_row_of_wall_subtiles &13c1 a2 06 LDX #&06 &13c3 4c 64 13 JMP &1364 ; plot_X_subtiles_of_blanks ; plot_row_of_subtiles_for_tile_type_3e # TILE_WALL_COLUMN_LEFT_EDGED &13c6 c9 07 CMP #&07 &13c8 d0 f2 BNE &13bc ; plot_row_of_subtiles_for_tile_type_04 &13ca 4c 71 13 JMP &1371 ; plot_tile_width_of_wall_subtiles ; plot_row_of_subtiles_for_tile_type_3f # TILE_WALL_COLUMN_RIGHT_EDGED &13cd c9 07 CMP #&07 &13cf d0 e1 BNE &13b2 ; plot_row_of_subtiles_for_tile_type_03 &13d1 4c 71 13 JMP &1371 ; plot_tile_width_of_wall_subtiles ; plot_tile_width_of_stone &13d4 a2 08 LDX #&08 ; plot_X_subtiles_of_stone &13d6 a9 01 LDA #&01 ; SUBTILE_STONE_ONE &13d8 8d f9 7f STA &7ff9 ; alternating_subtile_one &13db a9 02 LDA #&02 ; SUBTILE_STONE_TWO &13dd 8d fa 7f STA &7ffa ; alternating_subtile_two ; plot_alternating_subtiles # Called with X = number of subtiles to plot &13e0 a5 f8 LDA &f8 ; initial_row_in_tile &13e2 6a ROR A &13e3 90 09 BCC &13ee ; use_subtile_two ; plot_alternating_subtiles_loop &13e5 ad f9 7f LDA &7ff9 ; alternating_subtile_one &13e8 20 d8 1c JSR &1cd8 ; plot_subtile_considering_tile_vertical_flip &13eb ca DEX &13ec f0 b4 BEQ &13a2 ; leave ; use_subtile_two &13ee ad fa 7f LDA &7ffa ; alternating_subtile_two &13f1 20 d8 1c JSR &1cd8 ; plot_subtile_considering_tile_vertical_flip &13f4 ca DEX &13f5 d0 ee BNE &13e5 ; plot_alternating_subtiles_loop &13f7 60 RTS ; plot_X_subtiles_of_lattice # Called with X = number of subtiles to plot &13f8 a9 05 LDA #&05 ; SUBTILE_DIAGONAL &13fa 8d f9 7f STA &7ff9 ; alternating_subtile_one &13fd a9 45 LDA #&45 ; SUBTILE_DIAGONAL | SUBTILE_FLIPPED_VERTICALLY &13ff 8d fa 7f STA &7ffa ; alternating_subtile_two &1402 4c e0 13 JMP &13e0 ; plot_alternating_subtiles ; plot_row_of_subtiles_for_tile_type_05 # TILE_WALL_BOTTOM_LEFT_CORNER_EDGED &1405 a0 08 LDY #&08 ; SUBTILE_WALL_EDGE &1407 8c fb 7f STY &7ffb ; edge_subtile ; plot_left_wall_slope &140a aa TAX &140b 20 73 13 JSR &1373 ; plot_row_of_wall_subtiles &140e ad fb 7f LDA &7ffb ; edge_subtile &1411 20 d8 1c JSR &1cd8 ; plot_subtile_considering_tile_vertical_flip &1414 a9 07 LDA #&07 &1416 38 SEC &1417 e5 09 SBC &09 ; row_in_tile &1419 aa TAX &141a 4c 64 13 JMP &1364 ; plot_X_subtiles_of_blanks ; plot_row_of_subtiles_for_tile_type_06 # TILE_WALL_BOTTOM_RIGHT_CORNER_EDGED &141d a0 08 LDY #&08 ; SUBTILE_WALL_EDGE &141f 8c fb 7f STY &7ffb ; edge_subtile ; plot_right_wall_slope &1422 aa TAX &1423 a9 07 LDA #&07 &1425 38 SEC &1426 e5 09 SBC &09 ; row_in_tile &1428 aa TAX &1429 20 64 13 JSR &1364 ; plot_X_subtiles_of_blanks &142c ad fb 7f LDA &7ffb ; edge_subtile &142f 20 d8 1c JSR &1cd8 ; plot_subtile_considering_tile_vertical_flip &1432 a6 09 LDX &09 ; row_in_tile &1434 4c 73 13 JMP &1373 ; plot_row_of_wall_subtiles ; plot_row_of_subtiles_for_tile_type_0a # TILE_VAT_OF_WATER &1437 a2 12 LDX #&12 ; SUBTILE_WATER &1439 86 34 STX &34 ; vat_contents_subtile &143b 4c c5 18 JMP &18c5 ; plot_row_of_vat ; plot_row_of_subtiles_for_tile_type_14 # TILE_CLOSED_DOOR &143e a0 ff LDY #&ff # Set door_key_subtile to &ff to indicate no key usable &1440 4c 4a 14 JMP &144a ; plot_row_of_subtiles_for_door ; plot_row_of_subtiles_for_tile_type_07 # TILE_DOOR_ONE &1443 a0 28 LDY #&28 ; SUBTILE_KEY_ONE &1445 4c 4a 14 JMP &144a ; plot_row_of_subtiles_for_door ; plot_row_of_subtiles_for_tile_type_08 # TILE_DOOR_TWO &1448 a0 2a LDY #&2a ; SUBTILE_KEY_TWO ; plot_row_of_subtiles_for_door &144a 84 a4 STY &a4 ; door_key_subtile &144c c9 02 CMP #&02 &144e 10 03 BPL &1453 ; not_top_of_door ; to_plot_row_of_subtiles_of_bevelled_block &1450 4c 2f 15 JMP &152f ; plot_row_of_subtiles_of_bevelled_block ; not_top_of_door &1453 c9 07 CMP #&07 &1455 f0 26 BEQ &147d ; plot_row_of_subtiles_for_bottom_of_door &1457 c9 02 CMP #&02 &1459 d0 03 BNE &145e ; skip_setting_feature_location &145b 20 d9 14 JSR &14d9 ; set_feature_location ; skip_setting_feature_location &145e c9 06 CMP #&06 &1460 10 ee BPL &1450 ; to_plot_row_of_subtiles_of_bevelled_block ; is_middle_of_door &1462 a2 03 LDX #&03 &1464 20 64 13 JSR &1364 ; plot_X_subtiles_of_blanks &1467 c0 00 CPY #&00 ; SUBTILE_BLANK # Y = door_key_subtile &1469 f0 05 BEQ &1470 ; is_open ; is_closed &146b a9 25 LDA #&25 ; SUBTILE_PILLAR &146d 4c 72 14 JMP &1472 ; plot_row_of_subtiles_for_middle_of_door ; is_open &1470 a9 00 LDA #&00 ; SUBTILE_BLANK ; plot_row_of_subtiles_for_middle_of_door &1472 20 e4 1c JSR &1ce4 ; plot_subtile &1475 20 e4 1c JSR &1ce4 ; plot_subtile &1478 a2 03 LDX #&03 &147a 4c 64 13 JMP &1364 ; plot_X_subtiles_of_blanks ; plot_row_of_subtiles_for_bottom_of_door # Y = door_key_subtile &147d c0 ff CPY #&ff # &ff if closed door &147f f0 cf BEQ &1450 ; to_plot_row_of_subtiles_of_bevelled_block &1481 c0 00 CPY #&00 ; SUBTILE_BLANK &1483 f0 cb BEQ &1450 ; to_plot_row_of_subtiles_of_bevelled_block &1485 a2 02 LDX #&02 &1487 20 31 15 JSR &1531 ; plot_X_subtiles_of_bevelled_block &148a a9 00 LDA #&00 ; SUBTILE_BLANK &148c 20 e4 1c JSR &1ce4 ; plot_subtile &148f 98 TYA ; door_key_subtile &1490 20 e4 1c JSR &1ce4 ; plot_subtile # Plot key needed for door &1493 20 e4 1c JSR &1ce4 ; plot_subtile &1496 a9 00 LDA #&00 ; SUBTILE_BLANK &1498 20 e4 1c JSR &1ce4 ; plot_subtile &149b a2 02 LDX #&02 &149d 4c 31 15 JMP &1531 ; plot_X_subtiles_of_bevelled_block ; plot_row_of_subtiles_for_tile_type_0c # TILE_OPEN_DOOR &14a0 a0 00 LDY #&00 ; SUBTILE_BLANK # Set door_key_subtile to &00 to indicate no key needed &14a2 4c 4a 14 JMP &144a ; plot_row_of_subtiles_for_door ; plot_row_of_subtiles_for_tile_type_0b # TILE_CRYSTAL &14a5 c9 04 CMP #&04 &14a7 30 47 BMI &14f0 ; plot_row_of_subtiles_for_crystal_alcove &14a9 c9 06 CMP #&06 &14ab 10 43 BPL &14f0 ; plot_row_of_subtiles_for_crystal_alcove &14ad a2 03 LDX #&03 &14af 20 64 13 JSR &1364 ; plot_X_subtiles_of_blanks &14b2 a5 09 LDA &09 ; row_in_tile &14b4 c9 04 CMP #&04 &14b6 d0 12 BNE &14ca ; plot_bottom_of_crystal ; plot_top_of_crystal &14b8 20 d9 14 JSR &14d9 ; set_feature_location &14bb a9 10 LDA #&10 ; SUBTILE_CRYSTAL_LEFT &14bd 20 e4 1c JSR &1ce4 ; plot_subtile &14c0 a9 11 LDA #&11 ; SUBTILE_CRYSTAL_RIGHT &14c2 20 e4 1c JSR &1ce4 ; plot_subtile &14c5 a2 03 LDX #&03 &14c7 4c 64 13 JMP &1364 ; plot_X_subtiles_of_blanks ; plot_bottom_of_crystal &14ca a9 50 LDA #&50 ; SUBTILE_CRYSTAL_LEFT | SUBTILE_FLIPPED_VERTICALLY &14cc 20 e4 1c JSR &1ce4 ; plot_subtile &14cf a9 51 LDA #&51 ; SUBTILE_CRYSTAL_RIGHT | SUBTILE_FLIPPED_VERTICALLY &14d1 20 e4 1c JSR &1ce4 ; plot_subtile &14d4 a2 03 LDX #&03 &14d6 4c 64 13 JMP &1364 ; plot_X_subtiles_of_blanks ; set_feature_location &14d9 a5 7c LDA &7c ; screen_address_low &14db 8d 43 12 STA &1243 ; feature_screen_address_low &14de a5 7d LDA &7d ; screen_address_high &14e0 8d 44 12 STA &1244 ; feature_screen_address_high &14e3 a5 76 LDA &76 ; tile_data_address_low &14e5 85 00 STA &00 ; feature_tile_data_address_low &14e7 a5 77 LDA &77 ; tile_data_address_high &14e9 85 01 STA &01 ; feature_tile_data_address_high &14eb a5 03 LDA &03 ; tile_x &14ed 85 02 STA &02 ; feature_tile_x &14ef 60 RTS ; plot_row_of_subtiles_for_tile_type_0d # TILE_COLLECTED_CRYSTAL ; plot_row_of_subtiles_for_crystal_alcove &14f0 c9 02 CMP #&02 &14f2 10 17 BPL &150b ; not_top_of_alcove ; is_top_of_alcove &14f4 a2 03 LDX #&03 &14f6 20 73 13 JSR &1373 ; plot_row_of_wall_subtiles # Returns X = 0 &14f9 a5 79 LDA &79 ; underwater &14fb 48 PHA ; underwater &14fc 86 79 STX &79 ; underwater # Set to zero to not use water for blank for this tile &14fe a2 02 LDX #&02 &1500 20 64 13 JSR &1364 ; plot_X_subtiles_of_blanks &1503 68 PLA ; underwater &1504 85 79 STA &79 ; underwater # Restore room value &1506 a2 03 LDX #&03 &1508 4c 73 13 JMP &1373 ; plot_row_of_wall_subtiles ; plot_row_of_wall_subtiles &150b c9 06 CMP #&06 &150d 10 03 BPL &1512 ; to_plot_tile_width_of_wall_subtiles &150f 4c 62 13 JMP &1362 ; plot_tile_width_of_blanks ; to_plot_tile_width_of_wall_subtiles &1512 4c 71 13 JMP &1371 ; plot_tile_width_of_wall_subtiles ; to_plot_tile_width_of_stone &1515 4c d4 13 JMP &13d4 ; plot_tile_width_of_stone ; plot_row_of_subtiles_for_tile_type_0e # TILE_STONE_WINDOW &1518 c9 00 CMP #&00 &151a f0 f9 BEQ &1515 ; to_plot_tile_width_of_stone &151c c9 07 CMP #&07 &151e f0 f5 BEQ &1515 ; to_plot_tile_width_of_stone &1520 a2 01 LDX #&01 &1522 20 d6 13 JSR &13d6 ; plot_X_subtiles_of_stone &1525 a2 05 LDX #&05 &1527 20 f8 13 JSR &13f8 ; plot_X_subtiles_of_lattice &152a a2 02 LDX #&02 &152c 4c d6 13 JMP &13d6 ; plot_X_subtiles_of_stone ; plot_row_of_subtiles_of_bevelled_block &152f a2 08 LDX #&08 ; plot_X_subtiles_of_bevelled_block &1531 a9 04 LDA #&04 ; SUBTILE_BEVELLED_BLOCK_TWO &1533 8d f9 7f STA &7ff9 ; alternating_subtile_one &1536 a9 03 LDA #&03 ; SUBTILE_BEVELLED_BLOCK_ONE &1538 8d fa 7f STA &7ffa ; alternating_subtile_two &153b 4c e0 13 JMP &13e0 ; plot_alternating_subtiles ; plot_row_of_subtiles_for_tile_type_10 # TILE_WALL_EDGED &153e c9 00 CMP #&00 &1540 f0 03 BEQ &1545 ; plot_row_of_wall_edge &1542 4c 71 13 JMP &1371 ; plot_tile_width_of_wall_subtiles ; plot_row_of_wall_edge &1545 a2 08 LDX #&08 ; plot_row_of_wall_edge_loop &1547 a9 08 LDA #&08 ; SUBTILE_WALL_EDGE &1549 20 e4 1c JSR &1ce4 ; plot_subtile &154c ca DEX &154d d0 f8 BNE &1547 ; plot_row_of_wall_edge_loop &154f 60 RTS ; plot_row_of_subtiles_for_tile_type_11 # TILE_ELEPHANT &1550 c9 00 CMP #&00 &1552 d0 03 BNE &1557 ; skip_setting_feature_location &1554 20 d9 14 JSR &14d9 ; set_feature_location ; skip_setting_feature_location &1557 c9 04 CMP #&04 &1559 30 03 BMI &155e ; plot_row_of_subtiles_for_elephant &155b 4c 71 13 JMP &1371 ; plot_tile_width_of_wall_subtiles ; plot_row_of_subtiles_for_elephant &155e a2 04 LDX #&04 &1560 20 64 13 JSR &1364 ; plot_X_subtiles_of_blanks &1563 a9 6e LDA #&6e ; &156e = elephant_subtile_data &1565 85 7e STA &7e ; subtile_data_address_low &1567 a9 15 LDA #&15 &1569 85 7f STA &7f ; subtile_data_address_high &156b 4c 96 16 JMP &1696 ; plot_four_subtiles_from_data ; elephant_subtile_data &156e 1f ; SUBTILE_ELEPHANT_TOP_LEFT &156f 16 ; SUBTILE_SOLID &1570 21 ; SUBTILE_ELEPHANT_HEAD_LEFT &1571 22 ; SUBTILE_ELEPHANT_HEAD_TOP_RIGHT ; &1572 16 ; SUBTILE_SOLID &1573 16 ; SUBTILE_SOLID &1574 61 ; SUBTILE_ELEPHANT_HEAD_LEFT | SUBTILE_FLIPPED_VERTICALLY &1575 23 ; SUBTILE_ELEPHANT_HEAD_BOTTOM_RIGHT ; &1576 25 ; SUBTILE_PILLAR &1577 1d ; SUBTILE_SURFACE &1578 25 ; SUBTILE_PILLAR &1579 24 ; SUBTILE_LEG ; &157a 25 ; SUBTILE_PILLAR &157b 00 ; SUBTILE_BLANK &157c 25 ; SUBTILE_PILLAR &157d 00 ; SUBTILE_BLANK ; plot_subtiles_from_data # Called with X = number of subtiles, Y = scaling factor &157e a5 09 LDA &09 ; row_in_tile ; calculate_offset_loop &1580 0a ASL A &1581 88 DEY &1582 d0 fc BNE &1580 ; calculate_offset_loop &1584 a8 TAY ; plot_subtiles_from_data_loop &1585 b1 7e LDA (&7e),Y ; subtile_data_address &1587 20 d8 1c JSR &1cd8 ; plot_subtile_considering_tile_vertical_flip &158a c8 INY &158b ca DEX &158c d0 f7 BNE &1585 ; plot_subtiles_from_data_loop ; leave &158e 60 RTS ; plot_row_of_subtiles_for_tile_type_09 # TILE_FORCE_FIELDS &158f c9 00 CMP #&00 &1591 f0 33 BEQ &15c6 ; plot_row_of_subtiles_for_stone_ceiling_with_bumpy_edge &1593 a9 04 LDA #&04 &1595 38 SEC &1596 e5 a2 SBC &a2 ; force_fields_remaining &1598 0a ASL A &1599 aa TAX &159a 20 64 13 JSR &1364 ; plot_X_subtiles_of_blanks &159d a6 a2 LDX &a2 ; force_fields_remaining &159f e0 00 CPX #&00 &15a1 f0 eb BEQ &158e ; leave ; plot_force_fields_loop &15a3 a9 87 LDA #&87 ; SUBTILE_CRISSCROSS | SUBTILE_CHANGE_COLOUR &15a5 20 e4 1c JSR &1ce4 ; plot_subtile &15a8 a9 00 LDA #&00 &15aa 20 e4 1c JSR &1ce4 ; plot_subtile &15ad ca DEX &15ae d0 f3 BNE &15a3 ; plot_force_fields_loop &15b0 60 RTS ; plot_row_of_subtiles_for_tile_type_12 # TILE_STONE_FLOOR &15b1 c9 06 CMP #&06 &15b3 d0 03 BNE &15b8 ; not_second_to_bottom_row &15b5 4c 45 15 JMP &1545 ; plot_row_of_wall_edge ; not_second_to_bottom_row &15b8 c9 07 CMP #&07 &15ba f0 20 BEQ &15dc ; to_plot_tile_width_of_wall_subtiles ; to_plot_tile_width_of_blanks &15bc 4c 62 13 JMP &1362 ; plot_tile_width_of_blanks ; plot_row_of_subtiles_for_tile_type_30 # TILE_STONE_HORIZONTAL_PASSAGE_EDGED &15bf c9 02 CMP #&02 &15c1 30 03 BMI &15c6 ; skip_flipping &15c3 20 c4 12 JSR &12c4 ; flip_row_in_tile # Make floor like ceiling ; skip_flipping ; plot_row_of_subtiles_for_tile_type_13 # TILE_STONE_CEILING_EDGED ; plot_row_of_subtiles_for_stone_ceiling_with_bumpy_edge &15c6 a2 08 LDX #&08 &15c8 c9 02 CMP #&02 &15ca 10 f0 BPL &15bc ; to_plot_tile_width_of_blanks &15cc c9 01 CMP #&01 &15ce d0 0c BNE &15dc ; to_plot_tile_width_of_wall_subtiles &15d0 a0 58 LDY #&58 ; SUBTILE_BUMP_LEFT | SUBTILE_FLIPPED_VERTICALLY &15d2 8c f9 7f STY &7ff9 ; alternating_subtile_one &15d5 c8 INY ; &59 : SUBTILE_BUMP_RIGHT | SUBTILE_FLIPPED_VERTICALLY &15d6 8c fa 7f STY &7ffa ; alternating_subtile_two &15d9 4c e0 13 JMP &13e0 ; plot_alternating_subtiles ; to_plot_tile_width_of_wall_subtiles &15dc 4c 71 13 JMP &1371 ; plot_tile_width_of_wall_subtiles ; plot_row_of_subtiles_for_tile_type_15 # TILE_ORGAN_PIPES &15df c9 00 CMP #&00 &15e1 d0 10 BNE &15f3 ; not_pipe_tops &15e3 a2 04 LDX #&04 ; plot_row_of_pipe_tops_loop &15e5 a9 15 LDA #&15 ; SUBTILE_PIPE_TOP &15e7 20 e4 1c JSR &1ce4 ; plot_subtile &15ea a9 00 LDA #&00 ; SUBTILE_BLANK &15ec 20 e4 1c JSR &1ce4 ; plot_subtile &15ef ca DEX &15f0 d0 f3 BNE &15e5 ; plot_row_of_pipe_tops_loop ; leave &15f2 60 RTS ; not_pipe_tops &15f3 c9 04 CMP #&04 &15f5 10 05 BPL &15fc ; not_full_row &15f7 a2 04 LDX #&04 &15f9 4c 2b 16 JMP &162b ; plot_full_pipes_loop ; not_full_row &15fc c9 07 CMP #&07 &15fe d0 0a BNE &160a ; not_bottom_row &1600 a9 14 LDA #&14 ; SUBTILE_PIPE_BOTTOM &1602 20 e4 1c JSR &1ce4 ; plot_subtile &1605 a2 07 LDX #&07 &1607 4c 64 13 JMP &1364 ; plot_X_subtiles_of_blanks ; not_bottom_row &160a 38 SEC &160b a9 07 LDA #&07 &160d e5 09 SBC &09 ; row_in_tile &160f aa TAX &1610 20 2b 16 JSR &162b ; plot_full_pipes_loop &1613 a9 14 LDA #&14 ; SUBTILE_PIPE_BOTTOM &1615 20 e4 1c JSR &1ce4 ; plot_subtile &1618 a9 00 LDA #&00 ; SUBTILE_BLANK &161a 20 e4 1c JSR &1ce4 ; plot_subtile &161d a5 09 LDA &09 ; row_in_tile &161f c9 04 CMP #&04 &1621 f0 cf BEQ &15f2 ; leave &1623 38 SEC &1624 e9 04 SBC #&04 &1626 0a ASL A &1627 aa TAX &1628 4c 64 13 JMP &1364 ; plot_X_subtiles_of_blanks ; plot_full_pipes_loop &162b a9 13 LDA #&13 ; SUBTILE_PIPE &162d 20 e4 1c JSR &1ce4 ; plot_subtile &1630 a9 07 LDA #&07 ; SUBTILE_CRISSCROSS &1632 20 e4 1c JSR &1ce4 ; plot_subtile &1635 ca DEX &1636 d0 f3 BNE &162b ; plot_full_pipes_loop &1638 60 RTS ; plot_row_of_subtiles_for_tile_type_16 # TILE_DOUBLE_TRIANGLE ; plot_row_of_subtiles_for_double_height_triangle &1639 c9 07 CMP #&07 &163b f0 03 BEQ &1640 ; is_bottom_row &163d 4c c6 15 JMP &15c6 ; plot_row_of_subtiles_for_stone_ceiling_with_bumpy_edge ; is_bottom_row &1640 20 c6 15 JSR &15c6 ; plot_row_of_subtiles_for_stone_ceiling_with_bumpy_edge &1643 a9 02 LDA #&02 # Double height triangle &1645 8d 6b 1a STA &1a6b ; draw_triangle_string + &1b &1648 a9 84 LDA #&84 &164a 8d f9 7f STA &7ff9 ; triangle_gcol_mode &164d 4c f7 19 JMP &19f7 ; plot_triangle ; plot_row_of_subtiles_for_tile_type_17 # TILE_PILLAR &1650 a6 04 LDX &04 ; row_in_room &1652 e0 1f CPX #&1f &1654 f0 04 BEQ &165a ; to_plot_tile_width_of_wall_subtiles &1656 e0 07 CPX #&07 &1658 d0 03 BNE &165d ; not_top_or_bottom_of_room ; to_plot_tile_width_of_wall_subtiles &165a 4c 71 13 JMP &1371 ; plot_tile_width_of_wall_subtiles ; not_top_or_bottom_of_room &165d a2 02 LDX #&02 &165f 20 64 13 JSR &1364 ; plot_X_subtiles_of_blanks &1662 a9 13 LDA #&13 ; SUBTILE_PIPE &1664 20 e4 1c JSR &1ce4 ; plot_subtile &1667 a2 02 LDX #&02 &1669 20 31 15 JSR &1531 ; plot_X_subtiles_of_bevelled_block &166c a9 13 LDA #&13 ; SUBTILE_PIPE &166e 20 e4 1c JSR &1ce4 ; plot_subtile &1671 a2 02 LDX #&02 &1673 4c 64 13 JMP &1364 ; plot_X_subtiles_of_blanks ; plot_row_of_subtiles_for_tile_type_1a # TILE_TRANSMOGRIFIER &1676 c9 00 CMP #&00 &1678 d0 04 BNE &167e ; not_top_row &167a a9 01 LDA #&01 &167c 85 a6 STA &a6 ; transmogrifier_present # Set to non-zero to indicate room has transmogrifier ; not_top_row &167e 48 PHA ; row &167f 20 d4 13 JSR &13d4 ; plot_tile_width_of_stone &1682 4c e8 19 JMP &19e8 ; plot_single_height_triangle_if_row_seven ; plot_row_of_subtiles_for_tile_type_1b # TILE_CROSSING_TRIANGLES &1685 c9 04 CMP #&04 &1687 10 14 BPL &169d ; is_bottom_half ; is_top_half &1689 a2 04 LDX #&04 &168b 20 64 13 JSR &1364 ; plot_X_subtiles_of_blanks ; plot_four_subtiles_of_crossing_triangles &168e a9 b2 LDA #&b2 ; &16b2 = crossing_triangles_subtile_data &1690 85 7e STA &7e ; subtile_data_address_low &1692 a9 16 LDA #&16 &1694 85 7f STA &7f ; subtile_data_address_high ; plot_four_subtiles_from_data &1696 a2 04 LDX #&04 ; columns &1698 a0 02 LDY #&02 ; scaling &169a 4c 7e 15 JMP &157e ; plot_subtiles_from_data ; is_bottom_half &169d 38 SEC &169e e9 04 SBC #&04 &16a0 85 09 STA &09 ; row_in_tile &16a2 20 8e 16 JSR &168e ; plot_four_subtiles_of_crossing_triangles &16a5 a9 13 LDA #&13 &16a7 20 e4 1c JSR &1ce4 ; plot_subtile &16aa 20 e4 1c JSR &1ce4 ; plot_subtile &16ad a2 02 LDX #&02 &16af 4c 73 13 JMP &1373 ; plot_row_of_wall_subtiles ; crossing_triangles_subtile_data &16b2 17 ; SUBTILE_EDGED_TRIANGLE &16b3 00 ; SUBTILE_BLANK &16b4 00 ; SUBTILE_BLANK &16b5 18 ; SUBTILE_BUMP_LEFT ; &16b6 16 ; SUBTILE_SOLID &16b7 17 ; SUBTILE_EDGED_TRIANGLE &16b8 18 ; SUBTILE_BUMP_LEFT &16b9 da ; SUBTILE_TUBE_CORNER_LEFT | SUBTILE_FLIPPED_VERTICALLY | SUBTILE_CHANGE_COLOUR ; &16ba 16 ; SUBTILE_SOLID &16bb 16 ; SUBTILE_SOLID &16bc da ; SUBTILE_TUBE_CORNER_LEFT | SUBTILE_FLIPPED_VERTICALLY | SUBTILE_CHANGE_COLOUR &16bd db ; SUBTILE_TUBE_CORNER_RIGHT | SUBTILE_FLIPPED_VERTICALLY | SUBTILE_CHANGE_COLOUR ; &16be 16 ; SUBTILE_SOLID &16bf 13 ; SUBTILE_PIPE &16c0 9a ; SUBTILE_TUBE_CORNER_LEFT | SUBTILE_CHANGE_COLOUR &16c1 9b ; SUBTILE_TUBE_CORNER_RIGHT | SUBTILE_CHANGE_COLOUR ; plot_row_of_subtiles_for_tile_type_1c # TILE_STRIPS ; plot_row_of_vertical_strips &16c2 20 d2 16 JSR &16d2 ; plot_two_subtiles_of_pipe &16c5 a2 02 LDX #&02 &16c7 20 f8 13 JSR &13f8 ; plot_X_subtiles_of_lattice &16ca 20 d2 16 JSR &16d2 ; plot_two_subtiles_of_pipe &16cd a2 02 LDX #&02 &16cf 4c 73 13 JMP &1373 ; plot_row_of_wall_subtiles ; plot_two_subtiles_of_pipe &16d2 a2 02 LDX #&02 ; plot_two_subtiles_of_pipe_loop &16d4 a9 13 LDA #&13 ; SUBTILE_PIPE &16d6 20 e4 1c JSR &1ce4 ; plot_subtile &16d9 ca DEX &16da d0 f8 BNE &16d4 ; plot_two_subtiles_of_pipe_loop &16dc 60 RTS ; plot_row_of_subtiles_for_tile_type_1d # TILE_CROSSING_TRIANGLES_ON_STRIPS &16dd c9 04 CMP #&04 &16df 10 06 BPL &16e7 ; to_plot_row_of_vertical_strips &16e1 20 8e 16 JSR &168e ; plot_four_subtiles_of_crossing_triangles &16e4 4c 8e 16 JMP &168e ; plot_four_subtiles_of_crossing_triangles ; to_plot_row_of_vertical_strips &16e7 4c c2 16 JMP &16c2 ; plot_row_of_vertical_strips ; plot_row_of_subtiles_for_tile_type_1e # TILE_MUSIC_ROOM_TEXT ; plot_row_of_subtiles_for_tile_type_1f # TILE_LEVEL_SECTOR_TEXT ; plot_row_of_subtiles_for_tile_type_20 # TILE_ELEPHANT_HOUSE_TEXT ; plot_row_of_subtiles_for_tile_type_21 # TILE_JOKE_SHOP_TEXT ; plot_row_of_subtiles_for_tile_type_22 # TILE_TELEPORT_TEXT ; plot_row_of_subtiles_for_tile_type_23 # TILE_THE_ARMOURY_TEXT ; plot_row_of_subtiles_for_tile_type_24 # TILE_HYDROPONICS_TEXT ; plot_row_of_subtiles_for_tile_type_25 # TILE_HCL_TEXT ; plot_row_of_subtiles_for_tile_type_26 # TILE_NAOH_TEXT ; plot_row_of_subtiles_for_tile_type_27 # TILE_TIME_WARP_TEXT ; plot_row_of_subtiles_for_tile_type_28 # TILE_THE_ORACLE_TEXT ; plot_row_of_subtiles_for_tile_type_29 # TILE_OPTICIAN_TEXT ; plot_row_of_subtiles_for_tile_type_2a # TILE_CHEMICAL_SUPPLIES_TEXT ; plot_row_of_subtiles_for_tile_type_2b # TILE_GHOST_MAZE_TEXT ; plot_row_of_subtiles_for_tile_type_2c # TILE_CHAPEL_TEXT ; plot_row_of_subtiles_for_tile_type_2d # TILE_PASSWORD_TEXT &16ea c9 02 CMP #&02 &16ec 30 03 BMI &16f1 ; write_tile_string &16ee 4c 62 13 JMP &1362 ; plot_tile_width_of_blanks ; write_tile_string &16f1 a5 8f LDA &8f ; player_room_y &16f3 18 CLC &16f4 69 30 ADC #&30 ; "0" &16f6 8d c7 17 STA &17c7 ; tile_strings + &17 # Set level number &16f9 a5 90 LDA &90 ; player_room_x &16fb 69 41 ADC #&41 ; "A" &16fd 8d cf 17 STA &17cf ; tile_strings + &1f # Set sector letter &1700 18 CLC &1701 a5 7c LDA &7c ; screen_address_low &1703 69 80 ADC #&80 &1705 85 7c STA &7c ; screen_address_low &1707 a5 7d LDA &7d ; screen_address_high &1709 69 00 ADC #&00 &170b 85 7d STA &7d ; screen_address_high &170d 20 56 32 JSR &3256 ; write_string &1710 11 02 ; COLOUR 2 &1712 11 83 ; COLOUR 128 + 3 &1714 1f ; TAB &1715 00 ; end of string &1716 a5 03 LDA &03 ; tile_x &1718 0a ASL A &1719 0a ASL A &171a 0a ASL A &171b 20 ee ff JSR &ffee ; OSWRCH # TAB(tile_x * 8, (row_in_tile - 1)) &171e a5 04 LDA &04 ; row_in_room &1720 38 SEC &1721 e9 01 SBC #&01 &1723 20 ee ff JSR &ffee ; OSWRCH &1726 a5 09 LDA &09 ; row_in_tile &1728 0a ASL A &1729 0a ASL A &172a 0a ASL A &172b 85 31 STA &31 ; offset &172d ad 25 12 LDA &1225 ; tile &1730 c9 21 CMP #&21 ; TILE_JOKE_SHOP_TEXT &1732 d0 02 BNE &1736 ; not_joke_shop &1734 85 4c STA &4c ; room_is_joke_shop # Set &01 to indicate room is joke shop ; not_joke_shop &1736 c9 28 CMP #&28 ; TILE_THE_ORACLE_TEXT &1738 d0 0b BNE &1745 ; not_oracle # Is the player in the Oracle room? &173a a9 3c LDA #&3c ; OBJECT_EYE &173c 20 3c 21 JSR &213c ; check_if_object_carried # Returns carry set if object carried &173f a9 28 LDA #&28 ; TILE_THE_ORACLE_TEXT &1741 90 02 BCC &1745 ; not_carrying_eye # Is the player carrying the eye in the Oracle room? &1743 a9 2d LDA #&2d ; TILE_PASSWORD_TEXT # If so, display password ; not_carrying_eye ; not_oracle &1745 85 4e STA &4e ; room_feature &1747 38 SEC &1748 e9 1e SBC #&1e ; TILE_MUSIC_ROOM_TEXT &174a 0a ASL A &174b 0a ASL A &174c 0a ASL A &174d 0a ASL A &174e 65 31 ADC &31 ; offset &1750 a8 TAY &1751 a2 00 LDX #&00 ; write_tile_string_loop &1753 b9 b0 17 LDA &17b0,Y ; tile_strings &1756 f0 12 BEQ &176a ; write_password_for_player_room_x &1758 20 ee ff JSR &ffee ; OSWRCH &175b c8 INY &175c e8 INX &175d e0 08 CPX #&08 &175f d0 f2 BNE &1753 ; write_tile_string_loop ; reset_text_colour_and_leave &1761 20 56 32 JSR &3256 ; write_string &1764 11 01 ; COLOUR 1 &1766 11 80 ; COLOUR 128 + 0 &1768 00 ; end of string &1769 60 RTS ; write_password_for_player_room_x &176a a6 90 LDX &90 ; player_room_x &176c bd aa 18 LDA &18aa,X ; passwords_for_x_table ; write_password_A # Called with A = password number &176f aa TAX &1770 18 CLC &1771 69 31 ADC #&31 ; "1" &1773 20 ee ff JSR &ffee ; OSWRCH &1776 a9 01 LDA #&01 &1778 95 91 STA &91,X ; passwords_seen # Set to non-zero to indicate password seen &177a 8a TXA &177b 85 31 STA &31 ; offset &177d 0a ASL A &177e 18 CLC &177f 65 31 ADC &31 ; offset &1781 aa TAX &1782 20 56 32 JSR &3256 ; write_string &1785 3d ; "=" &1786 00 ; end of string &1787 a0 05 LDY #&05 ; write_password_loop &1789 bd 96 17 LDA &1796,X ; passwords &178c 20 ee ff JSR &ffee ; OSWRCH &178f e8 INX &1790 88 DEY &1791 d0 f6 BNE &1789 ; write_password_loop &1793 4c 61 17 JMP &1761 ; reset_text_colour_and_leave ; passwords &1796 53 41 4c ; "SAL" # 0 : password 1 : "SALLY" &1799 4c 59 4e ; "LYN" # 1 : password 2 : "LYNDA" &179c 44 41 56 ; "DAV" # 2 : password 3 : "DAVID" &179f 49 44 49 ; "IDI" # 3 : password 4 : "IDIOT" &17a2 4f 54 54 ; "OTT" # 4 : password 5 : "OTTER" &17a5 45 52 41 ; "ERA" # 5 : password 6 : "ERASE" &17a8 53 45 56 ; "SEV" # 6 : password 7 : "SEVEN" &17ab 45 4e 54 ; "ENT" # 7 : password 8 : "ENTER" &17ae 45 52 ; "ER" ; tile_strings &17b0 20 4d 75 73 69 63 20 20 ; " Music " # TILE_MUSIC_ROOM_TEXT &17b8 20 52 6f 6f 6d 20 20 20 ; " Room " &17c0 4c 65 76 65 6c 20 7c 20 ; "Level | " # TILE_LEVEL_SECTOR_TEXT &17c8 53 65 63 74 6f 72 7c 00 ; "Sector|" &17d0 45 4c 45 50 48 41 4e 54 ; "ELEPHANT" # TILE_ELEPHANT_HOUSE_TEXT &17d8 20 20 48 4f 55 53 45 20 ; " HOUSE " &17e0 2a 4a 6f 6b 65 2a 2a 2a ; "*Joke***" # TILE_JOKE_SHOP_TEXT &17e8 2a 2a 2a 53 68 6f 70 2a ; "***Shop*" &17f0 54 45 4c 45 50 4f 52 54 ; "TELEPORT" # TILE_TELEPORT_TEXT &17f8 7b 7d 7b 7d 7b 7d 7b 7d ; "{}{}{}{}" &1800 54 68 65 20 20 20 20 20 ; "The " # TILE_THE_ARMOURY_TEXT &1808 41 72 6d 6f 75 72 79 20 ; "Armoury " &1810 20 48 79 64 72 6f 2d 20 ; " Hydro- " # TILE_HYDROPONICS_TEXT &1818 20 70 6f 6e 69 63 73 20 ; "ponics " &1820 20 20 48 43 4c 20 20 20 ; " HCL " # TILE_HCL_TEXT &1828 20 5e 5e 5e 5e 5e 20 20 ; " ^^^^^ " &1830 20 4e 61 2d 4f 48 20 20 ; " Na-OH " # TILE_NAOH_TEXT &1838 5e 5e 5e 5e 5e 5e 5e 20 ; "^^^^^^^ " &1840 2f 2f 54 49 4d 45 5c 5c ; "//TIME\\" # TILE_TIME_WARP_TEXT &1848 5c 5c 57 41 52 50 2f 2f ; "\\WARP//" &1850 20 20 54 68 65 20 20 20 ; " The " # TILE_THE_ORACLE_TEXT &1858 20 4f 72 61 63 6c 65 20 ; "Oracle " &1860 4f 70 74 69 63 69 61 6e ; "Optician" # TILE_OPTICIAN_TEXT &1868 27 27 27 27 27 27 27 27 ; "''''''''" &1870 43 48 45 4d 49 43 41 4c ; "CHEMICAL" # TILE_CHEMICAL_SUPPLIES_TEXT &1878 53 55 50 50 4c 49 45 53 ; "SUPPLIES" &1880 7e 47 68 6f 73 74 7e 7e ; "~Ghost~~" # TILE_GHOST_MAZE_TEXT &1888 7e 7e 4d 61 7a 65 7e 7e ; "~~Maze~~" &1890 20 20 20 20 20 20 20 20 ; " " # TILE_CHAPEL_TEXT &1898 20 43 68 61 70 65 6c 20 ; " Chapel " &18a0 50 41 53 53 57 4f 52 44 ; "PASSWORD" # TILE_PASSWORD_TEXT &18a8 3e 00 ; ; ">" ; passwords_for_x_table &18aa 07 ; room_x = 0 : password 8 : "ENTER" # revealed if carrying eye in room (0, 9), The Oracle &18ab 02 ; room_x = 1 : password 3 : "DAVID" # room (1, 9) &18ac 06 ; room_x = 2 : password 7 : "SEVEN" # room (2, 7) &18ad 00 ; room_x = 3 : password 1 : "SALLY" # room (3, 4) &18ae 05 ; room_x = 4 : password 6 : "ERASE" # revealed when tune played in room (1, 4), Music Room &18af 01 ; room_x = 5 : password 2 : "LYNDA" # room (5, 5) &18b0 04 ; room_x = 6 : password 5 : "OTTER" # room (6, 0) &18b1 03 ; room_x = 7 : password 4 : "IDIOT" # room (7, 3) ; plot_row_of_subtiles_for_tile_type_31 # TILE_STONE_VERTICAL_PASSAGE &18b2 a2 02 LDX #&02 &18b4 20 d6 13 JSR &13d6 ; plot_X_subtiles_of_stone &18b7 a2 04 LDX #&04 &18b9 20 64 13 JSR &1364 ; plot_X_subtiles_of_blanks &18bc a2 02 LDX #&02 &18be 4c d6 13 JMP &13d6 ; plot_X_subtiles_of_stone ; plot_row_of_subtiles_for_tile_type_32 # TILE_VAT_OF_ACID &18c1 a2 09 LDX #&09 ; SUBTILE_ACID &18c3 86 34 STX &34 ; vat_contents_subtile ; plot_row_of_vat &18c5 c9 00 CMP #&00 &18c7 d0 23 BNE &18ec ; not_top_row_of_vat ; plot_top_row_of_vat &18c9 a9 1a LDA #&1a ; SUBTILE_TUBE_CORNER_LEFT &18cb 20 e4 1c JSR &1ce4 ; plot_subtile &18ce a2 06 LDX #&06 &18d0 20 64 13 JSR &1364 ; plot_X_subtiles_of_blanks &18d3 a9 1b LDA #&1b ; SUBTILE_TUBE_CORNER_RIGHT &18d5 4c e4 1c JMP &1ce4 ; plot_subtile ; plot_middle_row_of_vat &18d8 a9 1e LDA #&1e ; SUBTILE_TUBE_VERTICAL &18da 20 e4 1c JSR &1ce4 ; plot_subtile &18dd a5 34 LDA &34 ; vat_contents_subtile &18df a2 06 LDX #&06 ; plot_middle_row_of_vat_loop &18e1 20 e4 1c JSR &1ce4 ; plot_subtile &18e4 ca DEX &18e5 d0 fa BNE &18e1 ; plot_middle_row_of_vat_loop &18e7 a9 1e LDA #&1e ; SUBTILE_TUBE_VERTICAL &18e9 4c e4 1c JMP &1ce4 ; plot_subtile ; not_top_row_of_vat &18ec c9 07 CMP #&07 &18ee d0 e8 BNE &18d8 ; plot_middle_row_of_vat ; plot_bottom_row_of_vat &18f0 a9 5b LDA #&5b ; SUBTILE_TUBE_CORNER_LEFT | SUBTILE_FLIPPED_VERTICALLY &18f2 20 e4 1c JSR &1ce4 ; plot_subtile &18f5 a2 06 LDX #&06 &18f7 a9 20 LDA #&20 ; SUBTILE_TUBE_HORIZONTAL ; plot_bottom_row_of_vat_loop &18f9 20 e4 1c JSR &1ce4 ; plot_subtile &18fc ca DEX &18fd d0 fa BNE &18f9 ; plot_bottom_row_of_vat_loop &18ff a9 5a LDA #&5a ; SUBTILE_TUBE_CORNER_RIGHT | SUBTILE_FLIPPED_VERTICALLY &1901 4c e4 1c JMP &1ce4 ; plot_subtile ; plot_row_of_subtiles_for_tile_type_34 # TILE_MOVING_PLATFORMS_TYPE_TWO, faster to right &1904 a5 f8 LDA &f8 ; initial_row_in_tile &1906 f0 07 BEQ &190f ; is_top_row &1908 a0 0e LDY #&0e ; first slot for initialisation # Platforms are ordered from right to left &190a a2 10 LDX #&10 ; last_vertical_platform_offset_plus_two # Use slots 8, a, c and e &190c 4c 25 19 JMP &1925 ; plot_row_of_platforms_if_bottom_row ; is_top_row &190f a9 01 LDA #&01 &1911 85 a5 STA &a5 ; room_has_type_two_moving_platforms ; to_plot_tile_width_of_blanks &1913 4c 62 13 JMP &1362 ; plot_tile_width_of_blanks ; plot_row_of_subtiles_for_tile_type_33 # TILE_MOVING_PLATFORMS_TYPE_ONE, faster to left &1916 a5 f8 LDA &f8 ; initial_row_in_tile &1918 f0 07 BEQ &1921 ; is_top_row &191a a2 08 LDX #&08 ; last_vertical_platform_offset_plus_two # Use slots 0, 2, 4 and 6 &191c a0 00 LDY #&00 ; first slot for initialisation # Platforms are ordered from left to right &191e 4c 25 19 JMP &1925 ; plot_row_of_platforms ; is_top_row &1921 a9 01 LDA #&01 &1923 85 a3 STA &a3 ; room_has_type_one_moving_platforms ; plot_row_of_platforms_if_bottom_row &1925 c9 07 CMP #&07 &1927 d0 ea BNE &1913 ; to_plot_tile_width_of_blanks ; is_bottom_row &1929 c5 09 CMP &09 ; row_in_tile &192b d0 0a BNE &1937 ; is_butterfly # Branch if TILE_FLIPPED_VERTICALLY (&40) set ; is_platform &192d a9 d0 LDA #&d0 &192f 8d 46 12 STA &1246 ; vertical_enemies_minimum_y &1932 a9 00 LDA #&00 ; VERTICAL_ENEMY_TYPE_PLATFORM # Tile types &33 and &34 add moving platforms &1934 4c 3e 19 JMP &193e ; set_vertical_enemy_type ; is_butterfly &1937 a9 cc LDA #&cc &1939 8d 46 12 STA &1246 ; vertical_enemies_minimum_y &193c a9 01 LDA #&01 ; VERTICAL_ENEMY_TYPE_BUTTERFLY # Tile types &73 and &74 add moving butterflies ; set_vertical_enemy_type &193e 8d 49 12 STA &1249 ; vertical_enemy_type &1941 86 34 STX &34 ; last_vertical_platform_offset_plus_two &1943 20 58 1b JSR &1b58 ; initialise_moving_platforms &1946 a2 08 LDX #&08 ; plot_platform_floor_loop &1948 a9 26 LDA #&26 ; SUBTILE_PLATFORM_FLOOR &194a 20 e4 1c JSR &1ce4 ; plot_subtile # Plot floor beneath platforms &194d ca DEX &194e d0 f8 BNE &1948 ; plot_platform_floor_loop &1950 a9 00 LDA #&00 &1952 8d 4a 12 STA &124a ; vertical_enemy_top_two_bits_plus_ten &1955 20 6d 20 JSR &206d ; initialise_vertical_enemy_sprite_addresses &1958 a5 7c LDA &7c ; screen_address_low &195a 48 PHA ; screen_address_low &195b a5 7d LDA &7d ; screen_address_high &195d 48 PHA ; screen_address_high &195e a5 34 LDA &34 ; last_vertical_platform_offset_plus_two &1960 38 SEC &1961 e9 08 SBC #&08 &1963 a8 TAY ; plot_platforms_loop &1964 20 18 22 JSR &2218 ; to_plot_or_unplot_vertical_enemy # Plot platform &1967 c8 INY &1968 c8 INY &1969 c4 34 CPY &34 ; last_vertical_platform_offset_plus_two &196b d0 f7 BNE &1964 ; plot_platforms_loop &196d 68 PLA ; screen_address_low &196e 85 7d STA &7d ; screen_address_high &1970 68 PLA ; screen_address_high &1971 85 7c STA &7c ; screen_address_low ; leave &1973 60 RTS ; plot_row_of_subtiles_for_tile_type_2e # TILE_WATER &1974 a9 01 LDA #&01 &1976 85 79 STA &79 ; underwater # Set to non-zero to use water for blank henceforth &1978 a5 f8 LDA &f8 ; initial_row_in_tile &197a c5 09 CMP &09 ; row_in_tile &197c d0 58 BNE &19d6 ; plot_row_of_subtiles_for_tile_type_39 # Branch if TILE_FLIPPED_VERTICALLY (&40) set ; to_plot_tile_width_of_blanks # Tile type &6e is water filled wall bottom half, used for room room (3, 6) &197e 4c 62 13 JMP &1362 ; plot_tile_width_of_blanks ; plot_row_of_subtiles_for_tile_type_35 # TILE_WALL_PYRAMID &1981 c9 00 CMP #&00 &1983 f0 f9 BEQ &197e ; to_plot_tile_width_of_blanks &1985 38 SEC &1986 a9 07 LDA #&07 &1988 e5 09 SBC &09 ; row_in_tile &198a 4a LSR A &198b 85 64 STA &64 ; horizontal_enemies_x + 0 &198d aa TAX &198e 20 64 13 JSR &1364 ; plot_X_subtiles_of_blanks &1991 a5 09 LDA &09 ; row_in_tile &1993 29 fe AND #&fe &1995 aa TAX &1996 e8 INX &1997 20 73 13 JSR &1373 ; plot_row_of_wall_subtiles &199a a6 64 LDX &64 ; horizontal_enemies_x + 0 &199c e8 INX &199d 4c 64 13 JMP &1364 ; plot_X_subtiles_of_blanks ; plot_row_of_subtiles_for_tile_type_2f # TILE_REACTOR &19a0 a2 ff LDX #&ff ; FEATURE_REACTOR &19a2 86 4e STX &4e ; room_feature &19a4 20 39 16 JSR &1639 ; plot_row_of_subtiles_for_double_height_triangle &19a7 4c d9 14 JMP &14d9 ; set_feature_location ; plot_row_of_subtiles_for_tile_type_18 # TILE_WALL_BOTTOM_RIGHT_CORNER &19aa a0 00 LDY #&00 &19ac 8c fb 7f STY &7ffb ; edge_subtile &19af 4c 22 14 JMP &1422 ; plot_right_wall_slope ; plot_row_of_subtiles_for_tile_type_19 # TILE_WALL_BOTTOM_LEFT_CORNER &19b2 a0 00 LDY #&00 &19b4 8c fb 7f STY &7ffb ; edge_subtile &19b7 4c 0a 14 JMP &140a ; plot_left_wall_slope ; plot_row_of_subtiles_for_tile_type_36 # TILE_WALL_MIDDLE_AND_BOTTOM_LINES &19ba c9 03 CMP #&03 &19bc f0 07 BEQ &19c5 ; to_plot_tile_width_of_wall_subtiles &19be c9 07 CMP #&07 &19c0 f0 03 BEQ &19c5 ; to_plot_tile_width_of_wall_subtiles &19c2 4c 62 13 JMP &1362 ; plot_tile_width_of_blanks ; to_plot_tile_width_of_wall_subtiles &19c5 4c 71 13 JMP &1371 ; plot_tile_width_of_wall_subtiles ; plot_row_of_subtiles_for_tile_type_37 # TILE_WALL_MIDDLE_LINE &19c8 c9 03 CMP #&03 &19ca f0 f9 BEQ &19c5 ; to_plot_tile_width_of_wall_subtiles &19cc 4c 62 13 JMP &1362 ; plot_tile_width_of_blanks ; plot_row_of_subtiles_for_tile_type_38 # TILE_WALL_BOTTOM_LINE &19cf c9 07 CMP #&07 &19d1 f0 f2 BEQ &19c5 ; to_plot_tile_width_of_wall_subtiles &19d3 4c 62 13 JMP &1362 ; plot_tile_width_of_blanks ; plot_row_of_subtiles_for_tile_type_39 # TILE_WALL_BOTTOM_HALF &19d6 c9 04 CMP #&04 &19d8 10 eb BPL &19c5 ; to_plot_tile_width_of_wall_subtiles &19da 4c 62 13 JMP &1362 ; plot_tile_width_of_blanks ; plot_row_of_subtiles_for_tile_type_3a # TILE_SINGLE_TRIANGLE &19dd c9 04 CMP #&04 &19df d0 03 BNE &19e4 ; skip_setting_feature_location &19e1 20 d9 14 JSR &14d9 ; set_feature_location ; skip_setting_feature_location &19e4 48 PHA ; row &19e5 20 62 13 JSR &1362 ; plot_tile_width_of_blanks ; plot_single_height_triangle_if_row_seven &19e8 68 PLA ; row &19e9 c9 07 CMP #&07 &19eb d0 86 BNE &1973 ; leave &19ed a9 01 LDA #&01 # Single height triangle &19ef 8d 6b 1a STA &1a6b ; draw_triangle_string + &1b &19f2 a9 4b LDA #&4b &19f4 8d f9 7f STA &7ff9 ; triangle_gcol_mode ; plot_triangle &19f7 18 CLC &19f8 ad f9 7f LDA &7ff9 ; triangle_gcol_mode &19fb ea NOP &19fc ea NOP &19fd ea NOP &19fe 8d 58 1a STA &1a58 ; draw_triangle_string + &01 (gcol mode) &1a01 a5 03 LDA &03 ; tile_x &1a03 8d 5d 1a STA &1a5d ; draw_triangle_string + &06 (origin x high) &1a06 a5 04 LDA &04 ; row_in_room &1a08 8d 5e 1a STA &1a5e ; draw_triangle_string + &07 (origin y low) &1a0b a9 00 LDA #&00 &1a0d 8d 5f 1a STA &1a5f ; draw_triangle_string + &08 (origin y high) &1a10 a5 43 LDA &43 ; tile_is_flipped_vertically # Top bit set if tile is flipped vertically &1a12 10 19 BPL &1a2d ; skip_flipping_triangle &1a14 38 SEC &1a15 a9 00 LDA #&00 &1a17 ed 6b 1a SBC &1a6b ; draw_triangle_string + &1b (fill y high) &1a1a 8d 6b 1a STA &1a6b ; draw_triangle_string + &1b (fill y high) &1a1d 18 CLC &1a1e ad 6b 1a LDA &1a6b ; draw_triangle_string + &1b (fill y high) &1a21 0a ASL A &1a22 0a ASL A &1a23 0a ASL A &1a24 6d 5e 1a ADC &1a5e ; draw_triangle_string + &07 (origin y low) &1a27 38 SEC &1a28 e9 02 SBC #&02 &1a2a 8d 5e 1a STA &1a5e ; draw_triangle_string + &07 (origin y low) ; skip_flipping_triangle &1a2d a2 04 LDX #&04 ; scale_loop &1a2f 0e 5e 1a ASL &1a5e ; draw_triangle_string + &07 (origin y low) &1a32 2e 5f 1a ROL &1a5f ; draw_triangle_string + &08 (origin y high) &1a35 ca DEX &1a36 10 f7 BPL &1a2f ; scale_loop &1a38 38 SEC &1a39 a9 e0 LDA #&e0 &1a3b ed 5e 1a SBC &1a5e ; draw_triangle_string + &07 (origin y low) &1a3e 8d 5e 1a STA &1a5e ; draw_triangle_string + &07 (origin y low) &1a41 a9 03 LDA #&03 &1a43 ed 5f 1a SBC &1a5f ; draw_triangle_string + &08 (origin y high) &1a46 8d 5f 1a STA &1a5f ; draw_triangle_string + &08 (origin y high) &1a49 a2 00 LDX #&00 ; write_draw_triangle_loop &1a4b bd 57 1a LDA &1a57,X ; draw_triangle_string &1a4e 20 ee ff JSR &ffee ; OSWRCH &1a51 e8 INX &1a52 e0 15 CPX #&15 &1a54 d0 f5 BNE &1a4b ; write_draw_triangle_loop &1a56 60 RTS ; draw_triangle_string &1a57 12 00 03 ; GCOL 0, 3 # Mode overwritten &1a5a 19 04 00 00 00 00 ; MOVE &0000, &0000 # x high, y low and y high overwritten &1a60 19 01 00 01 00 00 ; DRAW +&0100, &0000 &1a66 19 51 80 ff 00 00 ; FILL TRIANGLE -&0080, -&0000 # y high overwritten ; plot_row_of_subtiles_for_tile_type_3b # TILE_TERMINAL &1a6c c9 05 CMP #&05 &1a6e 10 03 BPL &1a73 ; is_bottom_half &1a70 4c 62 13 JMP &1362 ; plot_tile_width_of_blanks ; is_bottom_half &1a73 38 SEC &1a74 e9 05 SBC #&05 &1a76 85 09 STA &09 ; row_in_tile &1a78 85 6e STA &6e ; terminal_pending_activation # Set to non-zero to indicate terminal not yet activated &1a7a a2 02 LDX #&02 &1a7c 20 64 13 JSR &1364 ; plot_X_subtiles_of_blanks &1a7f a9 8f LDA #&8f ; &1a8f = terminal_subtile_data &1a81 85 7e STA &7e ; subtile_data_address_low &1a83 a9 1a LDA #&1a &1a85 85 7f STA &7f ; subtile_data_address_high &1a87 20 96 16 JSR &1696 ; plot_four_subtiles_from_data &1a8a a2 02 LDX #&02 &1a8c 4c 64 13 JMP &1364 ; plot_X_subtiles_of_blanks ; terminal_subtile_data &1a8f 00 ; SUBTILE_BLANK &1a90 1c ; SUBTILE_TERMINAL_LEFT &1a91 06 ; SUBTILE_TERMINAL_RIGHT &1a92 00 ; SUBTILE_BLANK ; &1a93 00 ; SUBTILE_BLANK &1a94 5c ; SUBTILE_TERMINAL_LEFT | SUBTILE_FLIPPED_VERTICALLY &1a95 46 ; SUBTILE_TERMINAL_RIGHT | SUBTILE_FLIPPED_VERTICALLY &1a96 00 ; SUBTILE_BLANK ; &1a97 5d ; SUBTILE_SURFACE | SUBTILE_FLIPPED_VERTICALLY &1a98 24 ; SUBTILE_LEG &1a99 24 ; SUBTILE_LEG &1a9a 5d ; SUBTILE_SURFACE | SUBTILE_FLIPPED_VERTICALLY ; ; plot_row_of_subtiles_for_tile_type_3c # TILE_SNAIL &1a9b c9 00 CMP #&00 &1a9d d0 05 BNE &1aa4 ; skip_setting_feature_location &1a9f 20 d9 14 JSR &14d9 ; set_feature_location &1aa2 a9 00 LDA #&00 ; skip_setting_feature_location &1aa4 c9 04 CMP #&04 &1aa6 30 03 BMI &1aab ; is_top_half ; to_plot_tile_width_of_wall_subtiles &1aa8 4c 71 13 JMP &1371 ; plot_tile_width_of_wall_subtiles ; is_top_half &1aab c9 02 CMP #&02 &1aad 10 03 BPL &1ab2 ; plot_row_of_subtiles_for_snail &1aaf 4c 62 13 JMP &1362 ; plot_tile_width_of_blanks ; plot_row_of_subtiles_for_snail &1ab2 a2 04 LDX #&04 &1ab4 20 64 13 JSR &1364 ; plot_X_subtiles_of_blanks &1ab7 a9 ca LDA #&ca ; &1aca = snail_subtile_data &1ab9 85 7e STA &7e ; subtile_data_address_low &1abb a9 1a LDA #&1a &1abd 85 7f STA &7f ; subtile_data_address_high &1abf c6 09 DEC &09 ; row_in_tile # Move up for purposes of subtile data &1ac1 c6 09 DEC &09 ; row_in_tile &1ac3 a2 04 LDX #&04 ; columns &1ac5 a0 02 LDY #&02 ; scaling &1ac7 4c 7e 15 JMP &157e ; plot_subtiles_from_data ; snail_subtile_data &1aca 1b ; SUBTILE_TUBE_CORNER_RIGHT &1acb 1a ; SUBTILE_TUBE_CORNER_LEFT &1acc 0c ; SUBTILE_SNAIL_TOP_RIGHT &1acd 00 ; SUBTILE_BLANK ; &1ace 5b ; SUBTILE_TUBE_CORNER_RIGHT | SUBTILE_FLIPPED_VERTICALLY &1acf 20 ; SUBTILE_TUBE_HORIZONTAL &1ad0 0d ; SUBTILE_SNAIL_BOTTOM_RIGHT &1ad1 00 ; SUBTILE_BLANK ; plot_row_of_subtiles_for_tile_type_3d # TILE_TABLE_AND_CHAIRS &1ad2 c9 04 CMP #&04 &1ad4 10 03 BPL &1ad9 ; is_bottom_half &1ad6 4c 62 13 JMP &1362 ; plot_tile_width_of_blanks ; is_bottom_half &1ad9 c9 06 CMP #&06 &1adb 10 cb BPL &1aa8 ; to_plot_tile_width_of_wall_subtiles &1add 38 SEC &1ade e9 04 SBC #&04 &1ae0 85 09 STA &09 ; row_in_tile &1ae2 a9 f1 LDA #&f1 ; &1af1 = table_and_chairs_subtile_data &1ae4 85 7e STA &7e ; subtile_data_address_low &1ae6 a9 1a LDA #&1a &1ae8 85 7f STA &7f ; subtile_data_address_high &1aea a2 08 LDX #&08 ; columns &1aec a0 03 LDY #&03 ; scaling &1aee 4c 7e 15 JMP &157e ; plot_subtiles_from_data ; table_and_chairs_subtile_data &1af1 00 ; SUBTILE_BLANK &1af2 45 ; SUBTILE_DIAGONAL | SUBTILE_FLIPPED_VERTICALLY &1af3 5d ; SUBTILE_SURFACE | SUBTILE_FLIPPED_VERTICALLY &1af4 1d ; SUBTILE_SURFACE &1af5 16 ; SUBTILE_SOLID &1af6 1d ; SUBTILE_SURFACE &1af7 5d ; SUBTILE_SURFACE | SUBTILE_FLIPPED_VERTICALLY &1af8 05 ; SUBTILE_DIAGONAL ; &1af9 00 ; SUBTILE_BLANK &1afa 00 ; SUBTILE_BLANK &1afb 24 ; SUBTILE_LEG &1afc 00 ; SUBTILE_BLANK &1afd 16 ; SUBTILE_SOLID &1afe 00 ; SUBTILE_BLANK &1aff 24 ; SUBTILE_LEG &1b00 00 ; SUBTILE_BLANK ; plot_row_of_subtiles_for_tile_type_01 # TILE_SPIKE_PIT &1b01 c9 00 CMP #&00 &1b03 f0 07 BEQ &1b0c ; is_top_row &1b05 c9 01 CMP #&01 &1b07 f0 17 BEQ &1b20 ; to_plot_tile_width_of_stone &1b09 4c 71 13 JMP &1371 ; plot_tile_width_of_wall_subtiles ; is_top_row &1b0c a9 02 LDA #&02 ; SUBTILE_STONE_TWO &1b0e 20 e4 1c JSR &1ce4 ; plot_subtile &1b11 a2 06 LDX #&06 ; plot_spikes_loop &1b13 a9 27 LDA #&27 ; SUBTILE_SPIKES &1b15 20 d8 1c JSR &1cd8 ; plot_subtile_considering_tile_vertical_flip &1b18 ca DEX &1b19 d0 f8 BNE &1b13 ; plot_spikes_loop &1b1b a9 01 LDA #&01 ; SUBTILE_STONE_ONE &1b1d 4c e4 1c JMP &1ce4 ; plot_subtile ; to_plot_tile_width_of_stone &1b20 4c d4 13 JMP &13d4 ; plot_tile_width_of_stone ; plot_row_of_character_tile # &80 - &e0 : Character tile &20 - &80 &1b23 ad 25 12 LDA &1225 ; tile &1b26 29 40 AND #&40 &1b28 18 CLC &1b29 65 31 ADC &31 ; tile_type &1b2b 69 20 ADC #&20 ; " " &1b2d 8d ef 7f STA &7fef ; character_block &1b30 a2 ef LDX #&ef ; &7fef = character_block &1b32 a0 7f LDY #&7f &1b34 a9 0a LDA #&0a ; Read character definition &1b36 20 f1 ff JSR &fff1 ; OSWORD &1b39 a6 09 LDX &09 ; row_in_tile &1b3b e8 INX &1b3c bd ef 7f LDA &7fef,X ; character_block &1b3f 8d ef 7f STA &7fef ; row_bitmap &1b42 a0 08 LDY #&08 ; plot_row_of_character_tile_column_loop &1b44 a2 01 LDX #&01 &1b46 0e ef 7f ASL &7fef ; row_bitmap &1b49 b0 06 BCS &1b51 ; is_filled ; is_empty &1b4b 20 64 13 JSR &1364 ; plot_X_subtiles_of_blanks &1b4e 4c 54 1b JMP &1b54 ; consider_next_column ; is_filled &1b51 20 73 13 JSR &1373 ; plot_row_of_wall_subtiles ; consider_next_column &1b54 88 DEY &1b55 d0 ed BNE &1b44 ; plot_row_of_character_tile_column_loop &1b57 60 RTS ; initialise_moving_platforms # Called with Y = first vertical enemy slot to use, &1b58 a2 00 LDX #&00 # &0e for faster to right, &00 for faster to left &1b5a a5 7c LDA &7c ; screen_address_low &1b5c 48 PHA ; screen_address_low &1b5d a5 7d LDA &7d ; screen_address_high &1b5f 48 PHA ; screen_address_high ; initialise_moving_platforms_loop &1b60 18 CLC &1b61 a5 7c LDA &7c ; screen_address_low &1b63 99 51 00 STA &0051,Y ; vertical_enemies_screen_address_low - 8 &1b66 69 20 ADC #&20 # Move right sixteen pixels &1b68 85 7c STA &7c ; screen_address_low &1b6a a5 7d LDA &7d ; screen_address_high &1b6c 99 52 00 STA &0052,Y ; vertical_enemies_screen_address_high - 8 &1b6f 69 00 ADC #&00 &1b71 85 7d STA &7d ; screen_address_high &1b73 a9 fe LDA #&fe &1b75 99 18 00 STA &0018,Y ; vertical_enemies_y_velocity - 8 &1b78 a9 00 LDA #&00 &1b7a 99 19 00 STA &0019,Y ; vertical_enemies_y - 8 &1b7d c8 INY # Move to next slot &1b7e c8 INY # If faster to left (tile type &33), Y goes 0, 2, 4, 6 &1b7f c0 0a CPY #&0a &1b81 30 04 BMI &1b87 ; skip_reverse &1b83 88 DEY # If faster to right (tile type &34), Y goes e, c, a, 8 &1b84 88 DEY &1b85 88 DEY &1b86 88 DEY ; skip_reverse &1b87 e8 INX &1b88 e0 04 CPX #&04 &1b8a d0 d4 BNE &1b60 ; initialise_moving_platforms_loop &1b8c 68 PLA ; screen_address_low &1b8d 85 7d STA &7d ; screen_address_high &1b8f 68 PLA ; screen_address_high &1b90 85 7c STA &7c ; screen_address_low &1b92 a9 fe LDA #&fe &1b94 8d 47 12 STA &1247 ; vertical_enemies_maximum_y &1b97 60 RTS ; plot_room &1b98 a9 01 LDA #&01 &1b9a 85 a7 STA &a7 ; room_is_being_plotted # Set to non-zero to set all colours to black &1b9c a9 80 LDA #&80 &1b9e 85 7c STA &7c ; screen_address_low &1ba0 a9 41 LDA #&41 &1ba2 85 7d STA &7d ; screen_address_high &1ba4 a9 00 LDA #&00 &1ba6 85 a3 STA &a3 ; room_has_type_one_moving_platforms # Set to zero to indicate room has no moving platforms &1ba8 85 a5 STA &a5 ; room_has_type_two_moving_platforms # Set to zero to indicate room has no moving platforms &1baa 85 a6 STA &a6 ; transmogrifier_present # Set to zero to indicate room has no transmogrifier &1bac 8d 20 12 STA &1220 ; room_has_horizontal_enemies # Set to zero to indicate room has no horizontal enemies &1baf 85 79 STA &79 ; underwater # Set to zero to not use water for blank &1bb1 8d 39 12 STA &1239 ; room_has_diagonal_enemies # Set to zero to indicate room has no diagonal enemies &1bb4 85 6e STA &6e ; terminal_pending_activation # Set to zero to indicate no terminal &1bb6 8d 42 12 STA &1242 ; game_event # Set to zero to indicate no event occurring &1bb9 85 61 STA &61 ; plotting_or_updating_enemies # Set to zero to indicate plotting enemies &1bbb 8d 45 12 STA &1245 ; room_has_vertical_enemies # Set to zero to indicate room has no vertical enemies &1bbe 85 4c STA &4c ; room_is_joke_shop # Clear &01 to indicate room is not joke shop &1bc0 85 4e STA &4e ; room_feature # Set to zero to indicate no feature in room &1bc2 8d bf 32 STA &32bf ; music_room_correct_notes_played &1bc5 a9 01 LDA #&01 &1bc7 85 4d STA &4d ; player_y_acceleration # Set default thrust acceleration &1bc9 a9 08 LDA #&08 &1bcb 85 4f STA &4f ; wait_duration # Set default time speed &1bcd a5 70 LDA &70 ; player_room_y_data_offset_low &1bcf 85 72 STA &72 ; copy_of_player_room_y_data_offset_low &1bd1 a5 71 LDA &71 ; player_room_y_data_offset_high &1bd3 85 73 STA &73 ; copy_of_player_room_y_data_offset_high &1bd5 a9 07 LDA #&07 &1bd7 85 04 STA &04 ; row_in_room &1bd9 85 09 STA &09 ; row_in_tile &1bdb 20 87 1c JSR &1c87 ; calculate_tile_data_address &1bde a5 76 LDA &76 ; tile_data_address_low &1be0 38 SEC &1be1 e9 28 SBC #&28 # Move up a row of tile data &1be3 85 76 STA &76 ; tile_data_address_low &1be5 a5 77 LDA &77 ; tile_data_address_high &1be7 e9 00 SBC #&00 &1be9 85 77 STA &77 ; tile_data_address_high &1beb c6 8f DEC &8f ; player_room_y &1bed 20 69 1d JSR &1d69 ; set_room_colour_and_wall_subtiles &1bf0 e6 8f INC &8f ; player_room_y &1bf2 a5 8f LDA &8f ; player_room_y &1bf4 d0 03 BNE &1bf9 ; plot_row_of_room_above &1bf6 4c 7f 1c JMP &1c7f ; skip_row_of_room_above ; plot_row_of_room_above &1bf9 20 84 12 JSR &1284 ; plot_row_of_subtiles_for_row_of_tiles # Plot row of tiles for room above &1bfc a2 50 LDX #&50 &1bfe a9 80 LDA #&80 ; &4180 &1c00 85 7a STA &7a ; tile_screen_address_low &1c02 a9 41 LDA #&41 &1c04 85 7b STA &7b ; tile_screen_address_high ; clear_ceiling_loop &1c06 a0 00 LDY #&00 &1c08 b1 7a LDA (&7a),Y ; tile_screen_address &1c0a c9 c0 CMP #&c0 ; 3300 &1c0c f0 08 BEQ &1c16 ; skip_clearing_ceiling # Branch if water &1c0e a9 00 LDA #&00 ; 0000 &1c10 91 7a STA (&7a),Y ; tile_screen_address # Clear two rows between room above and status section &1c12 c8 INY &1c13 91 7a STA (&7a),Y ; tile_screen_address &1c15 c8 INY ; skip_clearing_ceiling &1c16 20 4e 12 JSR &124e ; plot_byte_to_tile_screen_address &1c19 d0 eb BNE &1c06 ; clear_ceiling_loop ; plot_rows_of_this_room &1c1b 20 69 1d JSR &1d69 ; set_room_colour_and_wall_subtiles ; plot_rows_of_this_room_tile_loop &1c1e a9 00 LDA #&00 &1c20 85 09 STA &09 ; row_in_tile &1c22 20 a9 1c JSR &1ca9 ; move_down_a_row_of_tiles ; plot_rows_of_this_room_row_loop &1c25 e6 04 INC &04 ; row_in_room &1c27 20 84 12 JSR &1284 ; plot_row_of_subtiles_for_row_of_tiles &1c2a e6 09 INC &09 ; row_in_tile &1c2c a5 09 LDA &09 ; row_in_tile &1c2e c9 08 CMP #&08 &1c30 d0 f3 BNE &1c25 ; plot_rows_of_this_room_row_loop &1c32 a5 04 LDA &04 ; row_in_room &1c34 c9 1f CMP #&1f &1c36 d0 e6 BNE &1c1e ; plot_rows_of_this_room_tile_loop &1c38 20 c4 1d JSR &1dc4 ; initialise_room_objects &1c3b 20 6c 1e JSR &1e6c ; initialise_horizontal_enemies &1c3e 20 2f 1f JSR &1f2f ; initialise_diagonal_enemies &1c41 20 ef 1f JSR &1fef ; initialise_vertical_enemies &1c44 a9 00 LDA #&00 &1c46 85 a7 STA &a7 ; room_is_being_plotted # Set to zero to use room colours &1c48 a2 03 LDX #&03 &1c4a a9 09 LDA #&09 ; Set first flashing colour duration &1c4c 20 f4 ff JSR &fff4 ; OSBYTE &1c4f a9 0a LDA #&0a ; Set second flashing colour duration &1c51 20 f4 ff JSR &fff4 ; OSBYTE &1c54 a5 35 LDA &35 ; player_x &1c56 85 2d STA &2d ; initial_player_x &1c58 a5 2c LDA &2c ; player_y &1c5a 85 2e STA &2e ; initial_player_y &1c5c a5 38 LDA &38 ; player_screen_address_low &1c5e 85 2f STA &2f ; initial_player_screen_address_low # Unused variable &1c60 a5 39 LDA &39 ; player_screen_address_high &1c62 85 30 STA &30 ; initial_player_screen_address_high # Unused variable &1c64 a9 15 LDA #&15 ; Flush buffer &1c66 a2 04 LDX #&04 ; sound channel 0 &1c68 20 f4 ff JSR &fff4 ; OSBYTE &1c6b a9 00 LDA #&00 &1c6d 85 6c STA &6c ; double_sprite # Set to zero to indicate sprite not doubled vertically &1c6f 85 13 STA &13 ; player_wants_to_jump # Unnecessary code &1c71 85 75 STA &75 ; change_colour_of_subtile # Set to zero to not add force_field to subtile &1c73 a5 8f LDA &8f ; player_room_y &1c75 c9 08 CMP #&08 &1c77 10 03 BPL &1c7c ; skip_initialising_whirligigs &1c79 20 1f 22 JSR &221f ; to_initialise_crossing_enemies # If player_room_y < 8, initialise whirligigs ; skip_initialising_whirligigs &1c7c 4c a0 0b JMP &0ba0 ; reset_clock ; skip_row_of_room_above &1c7f a2 28 LDX #&28 ; 40 &1c81 20 64 13 JSR &1364 ; plot_X_subtiles_of_blanks # Plot full row of blanks in place of room above &1c84 4c 1b 1c JMP &1c1b ; plot_rows_of_this_room ; calculate_tile_data_address &1c87 a5 90 LDA &90 ; player_room_x &1c89 0a ASL A &1c8a 0a ASL A &1c8b 65 90 ADC &90 ; player_room_x # Add player_room_x * 5 &1c8d 85 32 STA &32 ; offset_low &1c8f a5 72 LDA &72 ; copy_of_player_room_y_data_offset_low # player_room_y * &78 &1c91 65 32 ADC &32 ; offset_low &1c93 85 32 STA &32 ; offset_low &1c95 a5 73 LDA &73 ; copy_of_player_room_y_data_offset_high &1c97 69 00 ADC #&00 &1c99 85 33 STA &33 ; offset_high &1c9b a9 d0 LDA #&d0 ; &37d0 = tile_data &1c9d 18 CLC &1c9e 65 32 ADC &32 ; offset_low &1ca0 85 76 STA &76 ; tile_data_address_low &1ca2 a9 37 LDA #&37 &1ca4 65 33 ADC &33 ; offset_high &1ca6 85 77 STA &77 ; tile_data_address_high &1ca8 60 RTS ; move_down_a_row_of_tiles &1ca9 18 CLC &1caa a5 76 LDA &76 ; tile_data_address_low &1cac 69 28 ADC #&28 # Move down a row of tile data &1cae 85 76 STA &76 ; tile_data_address_low &1cb0 90 f6 BCC &1ca8 ; skip_page &1cb2 e6 77 INC &77 ; tile_data_address_high ; skip_page &1cb4 60 RTS ; move_up_a_room &1cb5 c6 8f DEC &8f ; player_room_y &1cb7 38 SEC &1cb8 a5 70 LDA &70 ; player_room_y_data_offset_low &1cba e9 78 SBC #&78 ; &28 * 3 # Move up three rows of tile data &1cbc 85 70 STA &70 ; player_room_y_data_offset_low &1cbe a5 71 LDA &71 ; player_room_y_data_offset_high &1cc0 e9 00 SBC #&00 &1cc2 85 71 STA &71 ; player_room_y_data_offset_high &1cc4 4c 98 1b JMP &1b98 ; plot_room ; move_down_a_room &1cc7 e6 8f INC &8f ; player_room_y &1cc9 18 CLC &1cca a5 70 LDA &70 ; player_room_y_data_offset_low &1ccc 69 78 ADC #&78 ; &28 * 3 # Move down three rows of tile data &1cce 85 70 STA &70 ; player_room_y_data_offset_low &1cd0 90 02 BCC &1cd4 ; skip_overflow &1cd2 e6 71 INC &71 ; player_room_y_data_offset_high ; skip_overflow &1cd4 4c 98 1b JMP &1b98 ; plot_room ; unused &1cd7 00 ; plot_subtile_considering_tile_vertical_flip # Called with A = subtile &1cd8 48 PHA ; subtile &1cd9 a5 43 LDA &43 ; tile_is_flipped_vertically # Top bit set if tile is flipped vertically &1cdb 2a ROL A # Set carry if tile is flipped vertically &1cdc 68 PLA ; subtile &1cdd 90 05 BCC &1ce4 ; plot_subtile &1cdf 18 CLC &1ce0 69 40 ADC #&40 ; SUBTILE_FLIPPED_VERTICALLY # Set &40 to indicate subtile is flipped vertically &1ce2 29 7f AND #&7f ; plot_subtile # Called with A = subtile &1ce4 85 33 STA &33 ; subtile_and_flags &1ce6 29 3f AND #&3f &1ce8 85 31 STA &31 ; subtile_sprite_offset_low &1cea 48 PHA ; tmp_a &1ceb 8a TXA &1cec 48 PHA ; tmp_x &1ced 98 TYA &1cee 48 PHA ; tmp_y &1cef a5 31 LDA &31 ; subtile_sprite_offset_low # Zero if SUBTILE_BLANK &1cf1 d0 08 BNE &1cfb ; skip_using_water &1cf3 a5 79 LDA &79 ; underwater # Non-zero if room uses water for blank &1cf5 f0 04 BEQ &1cfb ; skip_using_water ; is_underwater &1cf7 a9 12 LDA #&12 ; SUBTILE_WATER &1cf9 85 31 STA &31 ; subtile_sprite_offset_low # Use water subtile in place of blank subtile ; skip_using_water &1cfb a9 00 LDA #&00 &1cfd 85 32 STA &32 ; subtile_sprite_offset_low &1cff 85 75 STA &75 ; change_colour_of_subtile # Set to zero to not add force_field to subtile &1d01 a2 04 LDX #&04 ; calculate_subtile_sprite_offset_loop # Multiply by sixteen &1d03 06 31 ASL &31 ; subtile_sprite_offset_low &1d05 26 32 ROL &32 ; subtile_sprite_offset_high &1d07 ca DEX &1d08 d0 f9 BNE &1d03 ; calculate_subtile_sprite_offset_loop &1d0a ae 24 12 LDX &1224 ; subtile_set &1d0d bd 34 1d LDA &1d34,X ; subtile_sprite_addresses &1d10 65 31 ADC &31 ; subtile_sprite_offset_low &1d12 85 7a STA &7a ; sprite_address_low &1d14 bd 35 1d LDA &1d35,X ; subtile_sprite_addresses + 1 &1d17 65 32 ADC &32 ; subtile_sprite_offset_high &1d19 85 7b STA &7b ; sprite_address_high &1d1b 06 33 ASL &33 ; subtile_flags # Is SUBTILE_CHANGE_COLOUR (&80) set? &1d1d 90 04 BCC &1d23 ; skip_changing_colour &1d1f a9 01 LDA #&01 &1d21 85 75 STA &75 ; change_colour_of_subtile # If so, set to non-zero to change colour ; skip_changing_colour &1d23 06 33 ASL &33 ; subtile_flags # Is SUBTILE_FLIPPED_VERTICALLY &40 set? &1d25 b0 11 BCS &1d38 ; plot_flipped_subtile # If so, plot subtile flipped &1d27 a0 00 LDY #&00 ; plot_unflipped_subtile_loop &1d29 20 52 1d JSR &1d52 ; plot_byte_of_subtile &1d2c c8 INY &1d2d c0 10 CPY #&10 &1d2f d0 f8 BNE &1d29 ; plot_unflipped_subtile_loop &1d31 4c 4c 1d JMP &1d4c ; leave_after_restoring_registers ; subtile_sprite_addresses &1d34 00 0e ; &00 (SUBTILE_SET_STATUS_SPRITES) : &0e00 = tile_sprite_data &1d36 80 08 ; &02 (SUBTILE_SET_TILE_SPRITES) : &0880 = status_sprite_data ; plot_flipped_subtile &1d38 a0 07 LDY #&07 ; plot_flipped_subtile_first_column_loop &1d3a 20 52 1d JSR &1d52 ; plot_byte_of_subtile &1d3d 88 DEY &1d3e c0 ff CPY #&ff &1d40 d0 f8 BNE &1d3a ; plot_flipped_subtile_first_column_loop &1d42 a0 0f LDY #&0f ; plot_flipped_subtile_second_column_loop &1d44 20 52 1d JSR &1d52 ; plot_byte_of_subtile &1d47 88 DEY &1d48 c0 07 CPY #&07 &1d4a d0 f8 BNE &1d44 ; plot_flipped_subtile_second_column_loop ; leave_after_restoring_registers &1d4c 68 PLA ; tmp_y &1d4d a8 TAY &1d4e 68 PLA ; tmp_x &1d4f aa TAX &1d50 68 PLA ; tmp-a &1d51 60 RTS ; plot_byte_of_subtile &1d52 b1 7a LDA (&7a),Y ; sprite_address &1d54 84 31 STY &31 ; subtile_sprite_offset &1d56 a4 75 LDY &75 ; change_colour_of_subtile &1d58 f0 02 BEQ &1d5c ; skip_changing_colour &1d5a 49 90 EOR #&90 ; 2020 # Change first and third pixels if SUBTILE_CHANGE_COLOUR set ; skip_changing_colour &1d5c a0 00 LDY #&00 &1d5e 91 7c STA (&7c),Y ; screen_address &1d60 e6 7c INC &7c ; screen_address_low &1d62 d0 02 BNE &1d66 ; skip_page &1d64 e6 7d INC &7d ; screen_address_high ; skip_page &1d66 a4 31 LDY &31 ; subtile_sprite_offset &1d68 60 RTS ; set_room_colour_and_wall_subtiles &1d69 a5 8f LDA &8f ; player_room_y &1d6b 0a ASL A &1d6c 0a ASL A &1d6d 0a ASL A &1d6e 65 90 ADC &90 ; player_room_x &1d70 aa TAX &1d71 a9 0f LDA #&0f # ....8421 room colour &1d73 3d b0 09 AND &09b0,X ; rooms_colour_and_wall_type &1d76 8d 82 03 STA &0382 ; room_colour &1d79 bd b0 09 LDA &09b0,X ; rooms_colour_and_wall_type # 8421.... wall type &1d7c 4a LSR A # 84218421 -> .8421842 &1d7d 4a LSR A # -> ..842184 &1d7e 29 fc AND #&fc # -> ..8421 &1d80 aa TAX &1d81 a0 00 LDY #&00 ; set_wall_subtile_loop &1d83 bd 90 1d LDA &1d90,X ; wall_types_subtiles_table &1d86 99 fc 7f STA &7ffc,Y ; room_wall_subtiles &1d89 c8 INY &1d8a e8 INX &1d8b c0 04 CPY #&04 &1d8d d0 f4 BNE &1d83 ; set_wall_subtile_loop &1d8f 60 RTS ; wall_types_subtiles_table # 0 : wavy patterns &1d90 d0 ; SUBTILE_CRYSTAL_LEFT | SUBTILE_FLIPPED_VERTICALLY | SUBTILE_CHANGE_COLOUR &1d91 d1 ; SUBTILE_CRYSTAL_RIGHT | SUBTILE_FLIPPED_VERTICALLY | SUBTILE_CHANGE_COLOUR &1d92 91 ; SUBTILE_CRYSTAL_LEFT | SUBTILE_CHANGE_COLOUR &1d93 90 ; SUBTILE_CRYSTAL_RIGHT | SUBTILE_CHANGE_COLOUR ; # 1 : stone &1d94 02 ; SUBTILE_STONE_TWO &1d95 01 ; SUBTILE_STONE_ONE &1d96 01 ; SUBTILE_STONE_ONE &1d97 02 ; SUBTILE_STONE_TWO ; # 2 : large crisscross &1d98 05 ; SUBTILE_DIAGONAL &1d99 45 ; SUBTILE_DIAGONAL | SUBTILE_FLIPPED_VERTICALLY &1d9a 45 ; SUBTILE_DIAGONAL | SUBTILE_FLIPPED_VERTICALLY &1d9b 05 ; SUBTILE_DIAGONAL ; # 3 : wavy tubes &1d9c 1a ; SUBTILE_TUBE_CORNER_LEFT &1d9d 1b ; SUBTILE_TUBE_CORNER_RIGHT &1d9e 5b ; SUBTILE_TUBE_CORNER_RIGHT | SUBTILE_FLIPPED_VERTICALLY &1d9f 5a ; SUBTILE_TUBE_CORNER_LEFT | SUBTILE_FLIPPED_VERTICALLY ; # 4 : leaves &1da0 4e ; SUBTILE_LEAF_LEFT | SUBTILE_FLIPPED_VERTICALLY &1da1 4f ; SUBTILE_LEAF_RIGHT | SUBTILE_FLIPPED_VERTICALLY &1da2 0f ; SUBTILE_LEAF_RIGHT &1da3 0e ; SUBTILE_LEAF_LEFT ; # 5 : straight tubes &1da4 68 ; SUBTILE_KEY_ONE | SUBTILE_FLIPPED_VERTICALLY &1da5 20 ; SUBTILE_TUBE_HORIZONTAL &1da6 1e ; SUBTILE_TUBE_VERTICAL &1da7 00 ; SUBTILE_BLANK ; # 6 : bevelled blocks &1da8 03 ; SUBTILE_BEVELLED_BLOCK_ONE &1da9 04 ; SUBTILE_BEVELLED_BLOCK_TWO &1daa 04 ; SUBTILE_BEVELLED_BLOCK_TWO &1dab 03 ; SUBTILE_BEVELLED_BLOCK_ONE ; # 7 : dot pattern &1dac c6 ; SUBTILE_TERMINAL_RIGHT | SUBTILE_FLIPPED_VERTICALLY | SUBTILE_CHANGE_COLOUR &1dad dc ; SUBTILE_TERMINAL_LEFT | SUBTILE_FLIPPED_VERTICALLY | SUBTILE_CHANGE_COLOUR &1dae 86 ; SUBTILE_TERMINAL_RIGHT | SUBTILE_CHANGE_COLOUR &1daf 9c ; SUBTILE_TERMINAL_LEFT | SUBTILE_CHANGE_COLOUR ; # 8 : woven tubes &1db0 1e ; SUBTILE_TUBE_VERTICAL &1db1 20 ; SUBTILE_TUBE_HORIZONTAL &1db2 20 ; SUBTILE_TUBE_HORIZONTAL &1db3 1e ; SUBTILE_TUBE_VERTICAL ; # 9 : weave with holes &1db4 6a ; SUBTILE_KEY_TWO | SUBTILE_FLIPPED_VERTICALLY &1db5 7a ; SUBTILE_CROSS | SUBTILE_FLIPPED_VERTICALLY &1db6 7a ; SUBTILE_CROSS | SUBTILE_FLIPPED_VERTICALLY &1db7 6a ; SUBTILE_KEY_TWO | SUBTILE_FLIPPED_VERTICALLY ; # a : circles &1db8 9f ; SUBTILE_ELEPHANT_TOP_LEFT | SUBTILE_CHANGE_COLOUR &1db9 97 ; SUBTILE_EDGED_TRIANGLE | SUBTILE_CHANGE_COLOUR &1dba df ; SUBTILE_ELEPHANT_TOP_LEFT | SUBTILE_FLIPPED_VERTICALLY | SUBTILE_CHANGE_COLOUR &1dbb d7 ; SUBTILE_EDGED_TRIANGLE | SUBTILE_FLIPPED_VERTICALLY | SUBTILE_CHANGE_COLOUR ; # b : small crisscross &1dbc 07 ; SUBTILE_CRISSCROSS &1dbd 07 ; SUBTILE_CRISSCROSS &1dbe 07 ; SUBTILE_CRISSCROSS &1dbf 07 ; SUBTILE_CRISSCROSS ; # c : patterned stone &1dc0 82 ; SUBTILE_STONE_TWO | SUBTILE_CHANGE_COLOUR &1dc1 81 ; SUBTILE_STONE_ONE | SUBTILE_CHANGE_COLOUR &1dc2 81 ; SUBTILE_STONE_ONE | SUBTILE_CHANGE_COLOUR &1dc3 82 ; SUBTILE_STONE_TWO | SUBTILE_CHANGE_COLOUR ; initialise_room_objects &1dc4 a2 0b LDX #&0b &1dc6 a9 00 LDA #&00 ; &0900 = object_data &1dc8 85 13 STA &13 ; data_address_low &1dca a9 09 LDA #&09 &1dcc 85 14 STA &14 ; data_address_high ; initialise_room_objects_loop &1dce 8a TXA &1dcf 0a ASL A &1dd0 0a ASL A &1dd1 a8 TAY &1dd2 20 8a 20 JSR &208a ; check_if_data_is_for_player_room # Returns carry set if player room &1dd5 b0 04 BCS &1ddb ; is_in_room ; consider_next_object &1dd7 ca DEX &1dd8 10 f4 BPL &1dce ; initialise_room_objects_loop &1dda 60 RTS ; is_in_room &1ddb c8 INY &1ddc b9 00 09 LDA &0900,Y ; object_data &1ddf 85 0a STA &0a ; screen_y &1de1 c8 INY &1de2 b9 00 09 LDA &0900,Y ; object_data &1de5 85 0b STA &0b ; screen_x &1de7 20 f0 1d JSR &1df0 ; calculate_screen_address &1dea 20 29 1e JSR &1e29 ; plot_object &1ded 4c d7 1d JMP &1dd7 ; consider_next_object ; calculate_screen_address &1df0 8a TXA &1df1 48 PHA ; tmp_x &1df2 a5 0a LDA &0a ; screen_y &1df4 0a ASL A &1df5 0a ASL A &1df6 65 0a ADC &0a ; screen_y &1df8 85 7c STA &7c ; screen_address_low &1dfa a9 00 LDA #&00 &1dfc 85 7d STA &7d ; screen_address_high &1dfe a2 07 LDX #&07 ; calculate_group_offset_loop &1e00 06 7c ASL &7c ; screen_address_low &1e02 26 7d ROL &7d ; screen_address_high &1e04 ca DEX &1e05 d0 f9 BNE &1e00 ; calculate_group_offset_loop &1e07 a5 0b LDA &0b ; screen_x &1e09 85 33 STA &33 ; column_offset_low &1e0b a9 00 LDA #&00 &1e0d 85 34 STA &34 ; column_offset_high &1e0f a2 03 LDX #&03 ; calculate_column_offset_loop &1e11 06 33 ASL &33 ; column_offset_low &1e13 26 34 ROL &34 ; column_offset_high &1e15 ca DEX &1e16 d0 f9 BNE &1e11 ; calculate_column_offset_loop &1e18 a5 33 LDA &33 ; column_offset_low &1e1a 65 7c ADC &7c ; screen_address_low &1e1c 85 7c STA &7c ; screen_address_low &1e1e a5 34 LDA &34 ; column_offset_high &1e20 65 7d ADC &7d ; screen_address_high &1e22 69 3a ADC #&3a ; &3a00 = screen_memory - &280 &1e24 85 7d STA &7d ; screen_address_high &1e26 68 PLA ; tmp_x &1e27 aa TAX &1e28 60 RTS ; plot_object # Called with X = object offset &1e29 8a TXA &1e2a 48 PHA ; tmp_x &1e2b c9 03 CMP #&03 ; (OBJECT_GOLDEN_DRAGON - OBJECT_KEY_ONE) / 2 &1e2d d0 03 BNE &1e32 ; not_the_golden_dragon &1e2f 20 3f 1e JSR &1e3f ; plot_the_golden_dragon ; not_the_golden_dragon &1e32 68 PLA ; tmp_x &1e33 0a ASL A &1e34 69 28 ADC #&28 ; SUBTILE_KEY_ONE # First object &1e36 20 e4 1c JSR &1ce4 ; plot_subtile # Plot left of object &1e39 18 CLC &1e3a 69 01 ADC #&01 &1e3c 4c e4 1c JMP &1ce4 ; plot_subtile # Plot right of object ; plot_the_golden_dragon &1e3f 20 56 32 JSR &3256 ; write_string &1e42 1f 0a 07 ; TAB(&0a, &07) &1e45 54 48 45 ; "THE" &1e48 1f 09 09 ; TAB(&09, &09) &1e4b 47 4f 4c 44 45 4e ; "GOLDEN" &1e51 1f 09 0d ; TAB(&09, &0d) &1e54 44 52 41 47 4f 4e ; "DRAGON" &1e5a 1f 13 12 ; TAB(&13, &12) &1e5d 81 20 81 ; glasses and bottles &1e60 1f 1b 12 ; TAB(&1b, &12) &1e63 81 20 81 ; glasses and bottles &1e66 00 ; end of string &1e67 a9 ff LDA #&ff # Set to negative non-zero to indicate game complete &1e69 85 62 STA &62 ; player_state &1e6b 60 RTS ; initialise_horizontal_enemies &1e6c a2 00 LDX #&00 &1e6e a9 30 LDA #&30 ; &0930 = horizontal_enemy_data &1e70 85 13 STA &13 ; data_address_low &1e72 a9 09 LDA #&09 &1e74 85 14 STA &14 ; data_address_high ; find_horizontal_enemy_data_loop &1e76 8a TXA &1e77 0a ASL A &1e78 0a ASL A &1e79 85 33 STA &33 ; offset &1e7b 8a TXA &1e7c 65 33 ADC &33 ; offset &1e7e a8 TAY # Y = X * 5 &1e7f 20 8a 20 JSR &208a ; check_if_data_is_for_player_room # Returns carry set if player room &1e82 b0 06 BCS &1e8a ; found_horizontal_enemy_data &1e84 e8 INX &1e85 e0 10 CPX #&10 &1e87 d0 ed BNE &1e76 ; find_horizontal_enemy_data_loop &1e89 60 RTS ; found_horizontal_enemy_data &1e8a a5 32 LDA &32 ; second_byte_top_four_bits &1e8c 8d 25 12 STA &1225 ; horizontal_enemies_type &1e8f a6 31 LDX &31 ; first_byte_top_two_bits &1e91 e8 INX &1e92 e8 INX &1e93 8e 23 12 STX &1223 ; offset_of_last_horizontal_enemy_plus_two &1e96 ad 25 12 LDA &1225 ; horizontal_enemies_type &1e99 c9 01 CMP #&01 ; HORIZONTAL_ENEMY_TYPE_FISH &1e9b f0 04 BEQ &1ea1 ; is_fish_or_mouse &1e9d c9 02 CMP #&02 ; HORIZONTAL_ENEMY_TYPE_MOUSE &1e9f d0 05 BNE &1ea6 ; add_horizontal_enemies ; is_fish_or_mouse &1ea1 a5 63 LDA &63 ; suppress_fish_and_mice # Non-zero if fish or mouse has been collected &1ea3 f0 01 BEQ &1ea6 ; add_horizontal_enemies &1ea5 60 RTS ; add_horizontal_enemies &1ea6 a2 01 LDX #&01 &1ea8 8e 20 12 STX &1220 ; room_has_horizontal_enemies # Set to non-zero to indicate room has horizontal enemies &1eab ca DEX ; 0 ; initialise_horizontal_enemy_variables_loop # Third byte -> &121d ; horizontal_enemies_y &1eac c8 INY ; +2 # Fourth byte -> &121e ; horizontal_enemies_minimum_x &1ead b9 30 09 LDA &0930,Y ; horizontal_enemy_data # Fifth byte -> &121f ; horizontal_enemies_maximum_x &1eb0 9d 1d 12 STA &121d,X ; horizontal_enemies_y, horizontal_enemies_minimum_x - 1, horizontal_enemies_maximum_x - 2 &1eb3 e8 INX &1eb4 e0 03 CPX #&03 &1eb6 d0 f4 BNE &1eac ; initialise_horizontal_enemy_variables_loop &1eb8 18 CLC &1eb9 ad 1e 12 LDA &121e ; horizontal_enemies_minimum_x &1ebc 85 64 STA &64 ; horizontal_enemies_x + 0 &1ebe 6d 1f 12 ADC &121f ; horizontal_enemies_maximum_x &1ec1 6a ROR A &1ec2 69 07 ADC #&07 &1ec4 85 66 STA &66 ; horizontal_enemies_x + 2 &1ec6 85 68 STA &68 ; diagonal_enemies_x + 0 # Unnecessary code &1ec8 ad 1f 12 LDA &121f ; horizontal_enemies_maximum_x # &1ecb 85 6a STA &6a ; diagonal_enemies_x + 2 # &1ecd a2 00 LDX #&00 ; initialise_horizontal_enemies_loop &1ecf ad 1d 12 LDA &121d ; horizontal_enemies_y &1ed2 85 0a STA &0a ; screen_y &1ed4 b5 64 LDA &64,X ; horizontal_enemies_x &1ed6 85 0b STA &0b ; screen_x &1ed8 20 f0 1d JSR &1df0 ; calculate_screen_address &1edb a5 7c LDA &7c ; screen_address_low &1edd 95 43 STA &43,X ; horizontal_enemies_screen_address_low &1edf a5 7d LDA &7d ; screen_address_high &1ee1 95 44 STA &44,X ; horizontal_enemies_screen_address_high &1ee3 e8 INX &1ee4 e8 INX &1ee5 e0 08 CPX #&08 &1ee7 d0 e6 BNE &1ecf ; initialise_horizontal_enemies_loop &1ee9 ad 25 12 LDA &1225 ; horizontal_enemies_type &1eec 0a ASL A &1eed 0a ASL A &1eee 0a ASL A &1eef a8 TAY &1ef0 a2 00 LDX #&00 ; initialise_horizontal_enemies_sprite_addresses_loop &1ef2 b9 0f 1f LDA &1f0f,Y ; horizontal_enemy_sprite_addresses_table &1ef5 9d 5f 0b STA &0b5f,X ; sprite_addresses_table + 0 (SPRITE_HORIZONTAL_ENEMY_RIGHT_FRAME_ONE) &1ef8 c8 INY &1ef9 e8 INX &1efa e0 08 CPX #&08 &1efc d0 f4 BNE &1ef2 ; initialise_horizontal_enemies_sprite_addresses_loop &1efe a9 01 LDA #&01 &1f00 8d 2a 12 STA &122a ; horizontal_enemies_x_velocity + 0 &1f03 8d 2e 12 STA &122e ; horizontal_enemies_unused + 0 # Unused variable &1f06 a9 ff LDA #&ff &1f08 8d 2c 12 STA &122c ; horizontal_enemies_x_velocity + 2 &1f0b 8d 30 12 STA &1230 ; horizontal_enemies_unused + 2 # Unused variable &1f0e 60 RTS ; horizontal_enemy_sprite_addresses_table &1f0f 00 04 ; &00 (HORIZONTAL_ENEMY_TYPE_CATERPILLAR) : &0400 = sprite_caterpillar_right_frame_one &1f11 20 04 ; &0420 = sprite_caterpillar_left_frame_one &1f13 40 04 ; &0440 = sprite_caterpillar_right_frame_two &1f15 60 04 ; &0460 = sprite_caterpillar_left_frame_two &1f17 a0 06 ; &01 (HORIZONTAL_ENEMY_TYPE_FISH) : &06a0 = sprite_fish_right &1f19 40 11 ; &1140 = sprite_fish_left &1f1b a0 06 ; &06a0 = sprite_fish_right &1f1d 40 11 ; &1140 = sprite_fish_left &1f1f 80 06 ; &02 (HORIZONTAL_ENEMY_TYPE_MOUSE) : &0680 = sprite_mouse_right &1f21 60 11 ; &1160 = sprite_mouse_left &1f23 80 06 ; &0680 = sprite_mouse_right &1f25 60 11 ; &1160 = sprite_mouse_left &1f27 a0 0e ; &03 (HORIZONTAL_ENEMY_TYPE_PLATFORM) : &0ea0 = sprite_platform &1f29 a0 0e ; &0ea0 = sprite_platform &1f2b a0 0e ; &0ea0 = sprite_platform &1f2d a0 0e ; &0ea0 = sprite_platform ; initialise_diagonal_enemies &1f2f a2 00 LDX #&00 &1f31 a9 00 LDA #&00 ; &0a00 = diagonal_enemy_data &1f33 85 13 STA &13 ; data_address_low &1f35 a9 0a LDA #&0a &1f37 85 14 STA &14 ; data_address_high ; find_diagonal_enemy_data_loop &1f39 8a TXA &1f3a 0a ASL A &1f3b 18 CLC &1f3c 85 33 STA &33 ; offset &1f3e 8a TXA &1f3f 65 33 ADC &33 ; offset &1f41 0a ASL A &1f42 a8 TAY # Y = X * 6 &1f43 20 8a 20 JSR &208a ; check_if_data_is_for_player_room # Returns carry set if player room &1f46 b0 06 BCS &1f4e ; found_diagonal_enemy_data &1f48 e8 INX &1f49 e0 14 CPX #&14 &1f4b d0 ec BNE &1f39 ; find_diagonal_enemy_data_loop &1f4d 60 RTS ; found_diagonal_enemy_data &1f4e a5 31 LDA &31 ; first_byte_top_two_bits &1f50 8d 22 12 STA &1222 ; offset_of_last_diagonal_enemy &1f53 a5 32 LDA &32 ; second_byte_top_four_bits &1f55 8d 21 12 STA &1221 ; diagonal_enemies_type &1f58 a9 01 LDA #&01 &1f5a 8d 39 12 STA &1239 ; room_has_diagonal_enemies # Set to non-zero to indicate room has diagonal enemies &1f5d c8 INY ; +2 &1f5e b9 00 0a LDA &0a00,Y ; diagonal_enemy_data &1f61 85 0a STA &0a ; screen_y &1f63 0a ASL A &1f64 0a ASL A &1f65 0a ASL A &1f66 8d 37 12 STA &1237 ; diagonal_enemies_minimum_y &1f69 8d 31 12 STA &1231 ; diagonal_enemies_y + 0 &1f6c c8 INY ; +3 &1f6d b9 00 0a LDA &0a00,Y ; diagonal_enemy_data &1f70 8d 36 12 STA &1236 ; diagonal_enemies_minimum_x &1f73 18 CLC &1f74 69 0a ADC #&0a &1f76 85 0b STA &0b ; screen_x &1f78 85 68 STA &68 ; diagonal_enemies_x + 0 &1f7a 20 f0 1d JSR &1df0 ; calculate_screen_address &1f7d a5 7c LDA &7c ; screen_address_low &1f7f 85 47 STA &47 ; diagonal_enemies_screen_address_low + 0 &1f81 a5 7d LDA &7d ; screen_address_high &1f83 85 48 STA &48 ; diagonal_enemies_screen_address_high + 0 &1f85 c8 INY ; +4 &1f86 b9 00 0a LDA &0a00,Y ; diagonal_enemy_data &1f89 38 SEC &1f8a e9 03 SBC #&03 &1f8c 85 0a STA &0a ; screen_y &1f8e 0a ASL A &1f8f 0a ASL A &1f90 0a ASL A &1f91 8d 33 12 STA &1233 ; diagonal_enemies_y + 2 &1f94 b9 00 0a LDA &0a00,Y ; diagonal_enemy_data &1f97 0a ASL A &1f98 0a ASL A &1f99 0a ASL A &1f9a 8d 38 12 STA &1238 ; diagonal_enemies_maximum_y &1f9d c8 INY : +5 &1f9e b9 00 0a LDA &0a00,Y ; diagonal_enemy_data &1fa1 8d 35 12 STA &1235 ; diagonal_enemies_maximum_x &1fa4 38 SEC &1fa5 e9 06 SBC #&06 &1fa7 85 0b STA &0b ; screen_x &1fa9 85 6a STA &6a ; diagonal_enemies_x + 2 &1fab 20 f0 1d JSR &1df0 ; calculate_screen_address &1fae a5 7c LDA &7c ; screen_address_low &1fb0 85 49 STA &49 ; diagonal_enemies_screen_address_low + 2 &1fb2 a5 7d LDA &7d ; screen_address_high &1fb4 85 4a STA &4a ; diagonal_enemies_screen_address_high + 2 &1fb6 a0 0c LDY #&0c ; &1feb - &1fdf # Use jellyfish if underwater &1fb8 a5 79 LDA &79 ; underwater # Non-zero if underwater &1fba d0 06 BNE &1fc2 ; skip_setting_sprite_from_type &1fbc ad 21 12 LDA &1221 ; diagonal_enemies_type &1fbf 0a ASL A &1fc0 0a ASL A &1fc1 a8 TAY ; skip_setting_sprite_from_type &1fc2 a2 00 LDX #&00 ; initialise_diagonal_enemy_sprite_addresses_loop &1fc4 b9 df 1f LDA &1fdf,Y ; diagonal_enemy_sprite_addresses_table &1fc7 9d 67 0b STA &0b67,X ; sprite_addresses_table + 8 (SPRITE_DIAGONAL_ENEMY_FRAME_ONE) &1fca e8 INX &1fcb c8 INY &1fcc e0 04 CPX #&04 &1fce d0 f4 BNE &1fc4 ; initialise_diagonal_enemy_sprite_addresses_loop &1fd0 a2 01 LDX #&01 &1fd2 8a TXA ; initialise_diagonal_enemy_velocities_loop &1fd3 9d 39 12 STA &1239,X ; diagonal_enemies_x_velocity - 1,+ 0, diagonal_enemies_y_velocity - 2 + 0 &1fd6 9d 3b 12 STA &123b,X ; diagonal_enemies_y_velocity - 1 + 2, diagonal_enemies_y_velocity - 2 + 2 &1fd9 e8 INX &1fda e0 03 CPX #&03 &1fdc d0 f4 BNE &1fd2 ; initialise_diagonal_enemy_velocities_loop &1fde 60 RTS ; diagonal_enemy_sprite_addresses_table &1fdf 80 04 ; &00 (DIAGONAL_ENEMY_TYPE_BAT) : &0480 = sprite_bat_frame_one &1fe1 a0 04 ; &04a0 = sprite_bat_frame_two &1fe3 40 06 ; &01 (DIAGONAL_ENEMY_TYPE_WHIRLIGIG) : &0640 = sprite_whirligig_frame_one &1fe5 60 06 ; &0660 = sprite_whirligig_frame_two &1fe7 c0 04 ; &02 (DIAGONAL_ENEMY_TYPE_BUTTERFLY) : &04c0 = sprite_butterfly_frame_one &1fe9 e0 04 ; &04e0 = sprite_butterfly_frame_two &1feb 20 06 ; &03 (DIAGONAL_ENEMY_TYPE_JELLYFISH) : &0620 = sprite_jellyfish_frame_one &1fed 00 06 ; &0600 = sprite_jellyfish_frame_two ; initialise_vertical_enemies &1fef a9 96 LDA #&96 ; &0a96 = vertical_enemy_data &1ff1 85 13 STA &13 ; data_address_low &1ff3 a9 0a LDA #&0a &1ff5 85 14 STA &14 ; data_address_high &1ff7 a2 00 LDX #&00 ; find_vertical_enemy_data_loop &1ff9 8a TXA &1ffa 0a ASL A &1ffb 0a ASL A &1ffc 85 33 STA &33 ; offset &1ffe 8a TXA &1fff 65 33 ADC &33 ; offset &2001 a8 TAY # Y = X * 5 &2002 20 8a 20 JSR &208a ; check_if_data_is_for_player_room # Returns carry set if player room &2005 b0 06 BCS &200d ; found_vertical_enemy_data &2007 e8 INX &2008 e0 14 CPX #&14 &200a d0 ed BNE &1ff9 ; find_vertical_enemy_data_loop &200c 60 RTS ; found_vertical_enemy_data &200d a5 31 LDA &31 ; first_byte_top_two_bits &200f 18 CLC &2010 69 0a ADC #&0a &2012 8d 4a 12 STA &124a ; vertical_enemy_top_two_bits_plus_ten &2015 a5 32 LDA &32 ; second_byte_top_four_bits &2017 8d 49 12 STA &1249 ; vertical_enemy_type &201a a9 01 LDA #&01 &201c 8d 45 12 STA &1245 ; room_has_vertical_enemies # Set to non-zero to indicate room has vertical enemies &201f c8 INY ; +2 &2020 b9 96 0a LDA &0a96,Y ; vertical_enemy_data &2023 8d 48 12 STA &1248 ; vertical_enemy_x &2026 38 SEC &2027 e9 04 SBC #&04 &2029 85 0b STA &0b ; screen_x &202b c8 INY ; +3 &202c b9 96 0a LDA &0a96,Y ; vertical_enemy_data &202f 85 0a STA &0a ; screen_y &2031 0a ASL A &2032 0a ASL A &2033 0a ASL A &2034 8d 46 12 STA &1246 ; vertical_enemies_minimum_y &2037 85 23 STA &23 ; vertical_enemies_y + 2 &2039 20 f0 1d JSR &1df0 ; calculate_screen_address &203c a5 7c LDA &7c ; screen_address_low &203e 85 5b STA &5b ; vertical_enemies_screen_address_low + 2 &2040 a5 7d LDA &7d ; screen_address_high &2042 85 5c STA &5c ; vertical_enemies_screen_address_high + 2 &2044 ad 48 12 LDA &1248 ; vertical_enemy_x &2047 85 0b STA &0b ; screen_x &2049 c8 INY ; +4 &204a b9 96 0a LDA &0a96,Y ; vertical_enemy_data &204d 38 SEC &204e e9 02 SBC #&02 &2050 85 0a STA &0a ; screen_y &2052 0a ASL A &2053 0a ASL A &2054 0a ASL A &2055 85 21 STA &21 ; vertical_enemies_y + 0 &2057 69 10 ADC #&10 &2059 8d 47 12 STA &1247 ; vertical_enemies_maximum_y &205c 20 f0 1d JSR &1df0 ; calculate_screen_address &205f a5 7c LDA &7c ; screen_address_low &2061 85 59 STA &59 ; vertical_enemies_screen_address_low + 0 &2063 a5 7d LDA &7d ; screen_address_high &2065 85 5a STA &5a ; vertical_enemies_screen_address_high + 0 &2067 a9 02 LDA #&02 &2069 85 20 STA &20 ; vertical_enemies_y_velocity + 0 &206b 85 22 STA &22 ; vertical_enemies_y_velocity + 2 ; initialise_vertical_enemy_sprite_addresses &206d ad 49 12 LDA &1249 ; vertical_enemy_type &2070 0a ASL A &2071 0a ASL A &2072 a8 TAY &2073 a2 00 LDX #&00 ; initialise_vertical_enemy_sprite_addresses_loop &2075 b9 82 20 LDA &2082,Y ; vertical_enemy_sprite_addresses &2078 9d 6b 0b STA &0b6b,X ; sprite_addresses_table + &0c (SPRITE_VERTICAL_ENEMY_FRAME_ONE) &207b c8 INY &207c e8 INX &207d e0 04 CPX #&04 &207f d0 f4 BNE &2075 ; initialise_vertical_enemy_sprite_addresses_loop &2081 60 RTS ; vertical_enemy_sprite_addresses &2082 a0 0e ; &00 (VERTICAL_ENEMY_TYPE_PLATFORM) : &0ea0 = sprite_platform &2084 a0 0e ; &0ea0 = sprite_platform &2086 c0 04 ; &01 (VERTICAL_ENEMY_TYPE_BUTTERFLY) : &04c0 = sprite_butterfly_frame_one &2088 e0 04 ; &04e0 = sprite_butterfly_frame_two ; check_if_data_is_for_player_room &208a b1 13 LDA (&13),Y ; room_data_address &208c 29 3f AND #&3f # ..218421 ........ room y &208e c5 8f CMP &8f ; player_room_y &2090 d0 1e BNE &20b0 ; leave_with_carry_clear &2092 b1 13 LDA (&13),Y ; room_data_address &2094 4a LSR A # 84218421 -> .8421842 &2095 4a LSR A # -> ..842184 &2096 4a LSR A # -> ...84218 &2097 4a LSR A # -> ....8421 &2098 4a LSR A # -> .....842 &2099 29 fe AND #&fe # -> .....84. &209b 85 31 STA &31 ; first_byte_top_two_bits &209d c8 INY ; +1 &209e b1 13 LDA (&13),Y ; room_data_address # ........ ....8421 room x &20a0 29 0f AND #&0f &20a2 c5 90 CMP &90 ; player_room_x &20a4 d0 0a BNE &20b0 ; leave_with_carry_clear &20a6 b1 13 LDA (&13),Y ; room_data_address &20a8 4a LSR A # 84218421 -> .8421842 &20a9 4a LSR A # -> ..842184 &20aa 4a LSR A # -> ...84218 &20ab 4a LSR A # -> ....8421 &20ac 85 32 STA &32 ; second_byte_top_four_bits &20ae 38 SEC # Leave with carry set to indicate player room &20af 60 RTS ; leave_with_carry_clear &20b0 18 CLC # Leave with carry clear to indicate not player room ; leave &20b1 60 RTS ; terminal_sound_volume &20b2 00 ; terminal_screen &20b3 a5 90 LDA &90 ; player_room_x &20b5 18 CLC &20b6 69 31 ADC #&31 ; "1" &20b8 8d a2 21 STA &21a2 ; terminal_string + &c # Set terminal number in string &20bb a5 90 LDA &90 ; player_room_x &20bd 48 PHA ; player_room_x &20be a5 8f LDA &8f ; player_room_y &20c0 48 PHA ; player_room_y &20c1 a5 70 LDA &70 ; player_room_y_data_offset_low &20c3 48 PHA ; player_room_y_data_offset_low &20c4 a5 71 LDA &71 ; player_room_y_data_offset_high &20c6 48 PHA ; player_room_y_data_offset_high &20c7 a9 07 LDA #&07 # Use room (7, 9) for terminal screen &20c9 85 90 STA &90 ; player_room_x &20cb a9 09 LDA #&09 &20cd 85 8f STA &8f ; player_room_y &20cf a9 38 LDA #&38 ; &0438 = 9 * &78 &20d1 85 70 STA &70 ; player_room_y_data_offset_low &20d3 a9 04 LDA #&04 &20d5 85 71 STA &71 ; player_room_y_data_offset_high &20d7 20 98 1b JSR &1b98 ; plot_room # Plot terminal screen &20da 68 PLA ; player_room_y_data_offset_high &20db 85 71 STA &71 ; player_room_y_data_offset_high &20dd 68 PLA ; player_room_y_data_offset_low &20de 85 70 STA &70 ; player_room_y_data_offset_low &20e0 68 PLA ; player_room_y &20e1 85 8f STA &8f ; player_room_y &20e3 68 PLA ; player_room_x &20e4 85 90 STA &90 ; player_room_x &20e6 a2 00 LDX #&00 &20e8 8e b2 20 STX &20b2 ; terminal_sound_volume # Set to zero to not play any sound by default ; write_terminal_string_loop &20eb bd 96 21 LDA &2196,X ; terminal_string &20ee c9 ff CMP #&ff # &ff indicates end of string &20f0 f0 13 BEQ &2105 ; is_end_of_string &20f2 c9 fe CMP #&fe # &fe checks if card carried, and jumps in string if not &20f4 f0 36 BEQ &212c ; check_if_card_carried &20f6 c9 fd CMP #&fd # &fd checks for access, and jumps in string if not &20f8 f0 4c BEQ &2146 ; check_for_terminal_activation &20fa c9 fc CMP #&fc # &fc writes known passwords &20fc f0 6d BEQ &216b ; write_known_passwords &20fe 20 ee ff JSR &ffee ; OSWRCH &2101 e8 INX &2102 4c eb 20 JMP &20eb ; write_terminal_string_loop ; is_end_of_string &2105 a2 0a LDX #&0a &2107 8e a6 32 STX &32a6 ; sound_block + 6 (duration) &210a 8e a4 32 STX &32a4 ; sound_block + 4 (pitch) &210d ad b2 20 LDA &20b2 ; terminal_sound_volume &2110 20 33 33 JSR &3333 ; play_sound_on_channel_two # Play sound for terminal ; wait_for_space &2113 a2 9d LDX #&9d ; SPACE &2115 a9 81 LDA #&81 ; Scan for a particular key &2117 a0 ff LDY #&ff &2119 20 f4 ff JSR &fff4 ; OSBYTE &211c 90 f5 BCC &2113 ; wait_for_space &211e 20 98 1b JSR &1b98 ; plot_room &2121 ad b2 20 LDA &20b2 ; terminal_sound_volume # Non-zero if terminal was activated &2124 f0 8b BEQ &20b1 ; leave &2126 a9 00 LDA #&00 &2128 85 6e STA &6e ; terminal_pending_activation # Set to zero to indicate terminal has been activated ; leave_with_carry_clear &212a 18 CLC &212b 60 RTS ; check_if_card_carried &212c a9 32 LDA #&32 ; OBJECT_CARD &212e 20 3c 21 JSR &213c ; check_if_object_carried # Returns carry set if object carried &2131 b0 05 BCS &2138 ; grant_access &2133 a2 3a LDX #&3a ; &21d0 (denied_string) - &2196 (terminal_string) &2135 4c eb 20 JMP &20eb ; write_terminal_string_loop ; grant_access &2138 e8 INX &2139 4c eb 20 JMP &20eb ; write_terminal_string_loop ; check_if_object_carried &213c c5 0c CMP &0c ; player_pockets + 0 &213e f0 04 BEQ &2144 ; leave_with_carry_set &2140 c5 0d CMP &0d ; player_pockets + 1 &2142 d0 e6 BNE &212a ; leave_with_carry_clear # Leave with carry clear to indicate object not carried ; leave_with_carry_set &2144 38 SEC # Leave with object set to indicate object carried &2145 60 RTS ; check_for_terminal_activation &2146 8a TXA &2147 48 PHA ; terminal_string_offset &2148 a6 90 LDX &90 ; player_room_x &214a b5 91 LDA &91,X ; passwords_seen # Non-zero if password seen &214c c9 01 CMP #&01 &214e d0 15 BNE &2165 ; does_not_have_password ; has_password &2150 8d b2 20 STA &20b2 ; terminal_sound_volume # Set to one to use envelope 1 for sound &2153 e0 05 CPX #&05 &2155 d0 05 BNE &215c ; not_chemical_supplies_room &2157 a9 0a LDA #&0a ; TILE_VAT_OF_WATER # Set HCl vat in Chemical Supplies room to water &2159 8d 7c 39 STA &397c ; tile_data + 3 * &78 + 1 * &28 + 5 * &05 + 3; room (5, 3), tile (3, 1) ; not_chemical_supplies_room &215c 20 14 32 JSR &3214 ; change_tile_because_of_terminal_activation &215f 68 PLA ; terminal_string_offset &2160 aa TAX &2161 e8 INX &2162 4c eb 20 JMP &20eb ; write_terminal_string_loop ; does_not_have_password &2165 68 PLA ; terminal_string_offset &2166 a2 42 LDX #&42 ; &21d8 (invalid_password_string) - &2196 (terminal_string) &2168 4c eb 20 JMP &20eb ; write_terminal_string_loop ; write_known_passwords &216b 8a TXA &216c 48 PHA ; terminal_string_offset &216d a2 00 LDX #&00 &216f a9 15 LDA #&15 &2171 85 33 STA &33 ; password_y ; write_known_passwords_loop &2173 b5 91 LDA &91,X ; passwords_seen # Zero if password has not been seen &2175 f0 14 BEQ &218b ; skip_writing_password &2177 20 56 32 JSR &3256 ; write_string &217a 1f 1b ; TAB(&1b, ...) &217c 00 ; end of string &217d a5 33 LDA &33 ; password_y &217f 20 ee ff JSR &ffee ; OSWRCH # TAB(&1b, password_y) &2182 e6 33 INC &33 ; password_y &2184 8a TXA &2185 48 PHA ; password number &2186 20 6f 17 JSR &176f ; write_password_A &2189 68 PLA ; password number &218a aa TAX ; skip_writing_password &218b e8 INX &218c e0 08 CPX #&08 &218e d0 e3 BNE &2173 ; write_known_passwords_loop &2190 68 PLA ; terminal_string_offset &2191 aa TAX &2192 e8 INX &2193 4c eb 20 JMP &20eb ; write_terminal_string_loop ; terminal_string &2196 1f 07 13 ; TAB(&07, &13) &2199 54 45 52 4d 49 4e 41 4c 20 ; "TERMINAL " &21a2 00 &21a3 1f 1a 11 ; TAB(&1a, &11) &21a6 50 41 53 53 57 4f 52 44 53 ; "PASSWORDS" &21af fc &21b0 1f 05 17 ; TAB(&05, &17) &21b3 41 43 43 45 53 53 20 ; "ACCESS" &21ba fe &21bb 47 52 41 4e 54 45 44 ; "GRANTED" &21c2 fd &21c3 1f 07 1a ; TAB(&07, &1a) &21c6 41 43 54 49 56 41 54 45 44 ; "ACTIVATED" &21cf ff ; denied_string &21d0 20 44 45 4e 49 45 44 ; " DENIED" &21d7 ff ; invalid_password_string &21d8 1f 04 1a ; TAB(&04, &1a) &21db 49 4e 56 41 4c 49 44 20 50 41 53 53 57 4f 52 44 ; "INVALID PASSWORD" &21eb ff ; unused &21ec 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 &21fc 00 00 00 00 ; to_play_game &2200 4c 2f 25 JMP &252f ; play_game ; to_check_if_near_player_fixed_distance &2203 4c 9e 2b JMP &2b9e ; check_if_near_player_fixed_distance ; to_lose_energy_if_touching_enemy &2206 4c 57 2b JMP &2b57 ; lose_energy_if_touching_enemy ; to_check_row_for_obstacle &2209 4c 57 29 JMP &2957 ; check_row_for_obstacle ; to_check_column_for_obstacle &220c 4c 0b 29 JMP &290b ; check_column_for_obstacle ; to_check_row_above_for_obstacle &220f 4c 3f 29 JMP &293f ; check_row_above_for_obstacle ; to_consider_using_object # Unused &2212 4c 81 2d JMP &2d81 ; consider_using_object ; to_check_if_near_player_variable_distance &2215 4c aa 2b JMP &2baa ; check_if_near_player_variable_distance ; to_plot_or_unplot_vertical_enemy &2218 4c c7 23 JMP &23c7 ; plot_or_unplot_vertical_enemy ; to_update_title_screen &221b 4c 3b 22 JMP &223b ; update_title_screen ; unused &221e ea ; to_initialise_crossing_enemies &221f 4c d4 2d JMP &2dd4 ; initialise_crossing_enemies ; energy_pixel_values ; 0 1 2 3 &2222 00 08 0c 0e ; 0000 1000 1100 1110 ; read_clock_block &2226 00 00 00 00 00 ; crossing_enemies_room_x &222b 00 ; crossing_enemies_x_velocity &222c 00 ; crossing_enemies_room_x + 2 &222d 00 ; crossing_enemies_x_velocity + 2 &222e 00 ; crossing_enemies_x &222f 00 ; crossing_enemies_y &2230 00 ; crossing_enemies_x + 2 &2231 00 ; crossing_enemies_y + 2 &2232 00 ; crossing_enemies_direction &2233 00 ; crossing_enemies_y_velocity &2234 fe ; crossing_enemies_direction + 2 &2235 00 ; crossing_enemies_y_velocity + 2 &2236 fe ; update_game &2237 a9 00 LDA #&00 &2239 85 88 STA &88 ; suppress_jumping_and_dropping # Set to zero to allow player to jump and drop objects ; update_title_screen &223b 20 44 2e JSR &2e44 ; update_whirligigs_or_ghosts &223e ad 39 12 LDA &1239 ; room_has_diagonal_enemies # Non-zero if room has diagonal enemies &2241 f0 03 BEQ &2246 ; skip_updating_diagonal_enemies &2243 20 63 35 JSR &3563 ; update_diagonal_enemies ; skip_updating_diagonal_enemies &2246 a5 6e LDA &6e ; terminal_pending_activation # Zero if terminal has been activated &2248 d0 63 BNE &22ad ; skip_gaining_stun_grenade &224a a5 4e LDA &4e ; room_feature &224c c9 22 CMP #&22 ; TILE_TELEPORT_TEXT # Is the player in the teleport room? &224e d0 03 BNE &2253 ; skip_considering_using_teleport &2250 20 c8 31 JSR &31c8 ; consider_using_teleport ; skip_considering_using_teleport &2253 ad 20 12 LDA &1220 ; room_has_horizontal_enemies # Non-zero if room has horizontal enemies &2256 f0 03 BEQ &225b ; skip_updating_horizontal_enemies &2258 20 c1 33 JSR &33c1 ; update_horizontal_enemies ; skip_updating_horizontal_enemies &225b a5 a3 LDA &a3 ; room_has_type_one_moving_platforms # Non-zero if room has type one moving platforms &225d f0 03 BEQ &2262 ; skip_updating_moving_platforms_type_one &225f 20 d6 22 JSR &22d6 ; update_moving_platforms_type_one ; skip_updating_moving_platforms_type_one &2262 a5 a5 LDA &a5 ; room_has_type_two_moving_platforms # Non-zero if room has type two moving platforms &2264 f0 03 BEQ &2269 ; skip_updating_moving_platforms_type_two &2266 20 f6 23 JSR &23f6 ; update_moving_platforms_type_two ; skip_updating_moving_platforms_type_two &2269 ad 42 12 LDA &1242 ; game_event &226c c9 0c CMP #&0c ; EVENT_OPENING_DOOR &226e d0 03 BNE &2273 ; not_opening_door &2270 20 a3 2d JSR &2da3 ; open_door ; not_opening_door &2273 ad 42 12 LDA &1242 ; game_event &2276 c9 04 CMP #&04 ; EVENT_MOVING_FEATURE &2278 d0 03 BNE &227d ; not_moving_feature &227a 20 8e 31 JSR &318e ; animate_moving_feature # Open altar, move elephant, or move snail ; not_moving_feature &227d a5 6d LDA &6d ; time_needs_replotting &227f f0 03 BEQ &2284 ; skip_replotting_time &2281 20 6f 37 JSR &376f ; update_time ; skip_replotting_time &2284 ad 42 12 LDA &1242 ; game_event &2287 c9 14 CMP #&14 ; EVENT_CLOSING_DOOR &2289 d0 03 BNE &228e ; not_closing_door &228b 20 98 2d JSR &2d98 ; close_door ; not_closing_door &228e ad 45 12 LDA &1245 ; room_has_vertical_enemies # Non-zero if room has vertical enemies &2291 f0 03 BEQ &2296 ; skip_updating_vertical_enemies &2293 20 01 24 JSR &2401 ; update_vertical_enemies ; skip_updating_vertical_enemies &2296 a5 4e LDA &4e ; room_feature &2298 c9 23 CMP #&23 ; TILE_THE_ARMOURY_TEXT &229a d0 11 BNE &22ad ; skip_gaining_stun_grenade &229c 20 bd 0b JSR &0bbd ; to_gain_stun_grenade &229f a9 01 LDA #&01 &22a1 85 6e STA &6e ; terminal_pending_activation # Set to non-zero to indicate terminal can be activated again &22a3 a2 08 LDX #&08 ; drain_energy_for_gaining_stun_grenade_loop &22a5 c6 3a DEC &3a ; player_previous_energy &22a7 20 8f 2b JSR &2b8f ; lose_energy_without_sound # Lose energy for gaining stun grenade &22aa ca DEX &22ab d0 f8 BNE &22a5 ; drain_energy_for_gaining_stun_grenade_loop ; skip_gaining_stun_grenade &22ad a5 4c LDA &4c ; room_is_joke_shop # &01 set if room is joke shop &22af 4a LSR A &22b0 90 03 BCC &22b5 ; not_in_joke_shop &22b2 20 e7 24 JSR &24e7 ; set_player_acceleration_in_joke_shop ; not_in_joke_shop &22b5 a5 4e LDA &4e ; room_feature &22b7 c9 27 CMP #&27 ; TILE_TIME_WARP_TEXT &22b9 d0 03 BNE &22be ; not_in_time_warp &22bb 20 f9 24 JSR &24f9 ; warp_time ; not_in_time_warp &22be a2 01 LDX #&01 &22c0 86 61 STX &61 ; plotting_or_updating_enemies # Set to non-zero to indicate updating enemies &22c2 ca DEX ; 0 &22c3 86 74 STX &74 ; enemies_are_stunned # Set to zero to indicate enemies are not stunned ; wait_for_clock &22c5 a9 01 LDA #&01 ; Read system clock &22c7 a2 26 LDX #&26 ; &2226 = read_clock_block &22c9 a0 22 LDY #&22 &22cb 20 f1 ff JSR &fff1 ; OSWORD &22ce ad 26 22 LDA &2226 ; read_clock_block &22d1 c5 4f CMP &4f ; wait_duration &22d3 30 f0 BMI &22c5 ; wait_for_clock ; leave &22d5 60 RTS ; update_moving_platforms_type_one # Platforms are faster to the left &22d6 e6 28 INC &28 ; type_one_platforms_state &22d8 a5 28 LDA &28 ; type_one_platforms_state &22da 85 34 STA &34 ; platforms_bitmap &22dc a0 00 LDY #&00 ; platform slot ; update_moving_platforms # Y = 0 for type one platforms, 8 for type two platforms &22de 20 c7 23 JSR &23c7 ; plot_or_unplot_vertical_enemy # Unplot moving platform in slot 0 or 8 &22e1 20 fe 22 JSR &22fe ; update_moving_platform # Move platform in slot 0 or 8 twice every update &22e4 20 fe 22 JSR &22fe ; update_moving_platform &22e7 20 c7 23 JSR &23c7 ; plot_or_unplot_vertical_enemy # Plot moving platform in slot 0 or 8 &22ea c8 INY ; 2 &22eb c8 INY &22ec 20 fe 22 JSR &22fe ; update_moving_platform # Move platform in slot 2 or a once every update &22ef c8 INY ; +4 &22f0 c8 INY &22f1 66 34 ROR &34 ; platforms_bitmap &22f3 90 03 BCC &22f8 ; skip_second_update &22f5 4c fe 22 JMP &22fe ; update_moving_platform # Move platform in slot 4 or c once every two updates ; skip_second_update &22f8 c8 INY &22f9 c8 INY &22fa 66 34 ROR &34 ; platforms_bitmap &22fc 90 d7 BCC &22d5 ; leave ; update_moving_platform # Move platform in slot 6 or e once every four updates &22fe 20 75 23 JSR &2375 ; check_if_vertical_enemy_at_minimum_or_maximum_y &2301 20 bf 23 JSR &23bf ; plot_or_unplot_moving_platform # Unplot moving platform &2304 20 0d 23 JSR &230d ; move_moving_platform &2307 20 94 23 JSR &2394 ; apply_y_velocity_to_vertical_enemy &230a 4c bf 23 JMP &23bf ; plot_or_unplot_moving_platform # Plot moving platform ; move_moving_platform &230d 98 TYA &230e 48 PHA ; tmp_y &230f b9 18 00 LDA &0018,Y ; vertical_enemies_y_velocity - 8 &2312 c9 fe CMP #&fe &2314 d0 1a BNE &2330 ; is_moving_down ; is_moving_up &2316 b9 51 00 LDA &0051,Y ; vertical_enemies_screen_address_low - 8 &2319 85 7c STA &7c ; screen_address_low &231b b9 52 00 LDA &0052,Y ; vertical_enemies_screen_address_high - 8 &231e 85 7d STA &7d ; screen_address_high &2320 20 3f 29 JSR &293f ; check_row_above_for_obstacle # Sets obstacle_present to non-zero if obstacle present &2323 20 5c 23 JSR &235c ; check_if_player_touching_moving_platform # Returns zero if player is touching moving platform &2326 d0 31 BNE &2359 ; leave_after_restoring_Y ; is_touching_rising_platform &2328 a9 01 LDA #&01 ; distance &232a 20 ae 28 JSR &28ae ; move_player_up &232d 4c 52 23 JMP &2352 ; drain_energy_if_platform_pushing_player_into_obstacle ; is_moving_down &2330 18 CLC &2331 b9 51 00 LDA &0051,Y ; vertical_enemies_screen_address_low - 8 &2334 69 80 ADC #&80 &2336 85 7c STA &7c ; screen_address_low &2338 b9 52 00 LDA &0052,Y ; vertical_enemies_screen_address_high - 8 &233b 69 02 ADC #&02 &233d 85 7d STA &7d ; screen_address_high &233f 20 57 29 JSR &2957 ; check_row_for_obstacle # Sets obstacle_present to non-zero if obstacle present &2342 20 5c 23 JSR &235c ; check_if_player_touching_moving_platform # Returns zero if player is touching moving platform &2345 d0 12 BNE &2359 ; leave_after_restoring_Y ; is_touching_falling_platform &2347 a9 01 LDA #&01 &2349 85 88 STA &88 ; suppress_jumping_and_dropping # Set to non-zero stop player dropping object on platform &234b a9 fe LDA #&fe &234d 85 0e STA &0e ; player_y_velocity &234f 20 13 28 JSR &2813 ; update_falling_player ; drain_energy_if_platform_pushing_player_into_obstacle &2352 a5 0b LDA &0b ; obstacle_present # Non-zero if platform is pushing player into obstacle &2354 f0 03 BEQ &2359 ; leave_after_restoring_Y &2356 20 88 2b JSR &2b88 ; lose_energy # Lose energy for being pushed into obstacle by platform ; leave_after_restoring_Y &2359 68 PLA ; tmp_y &235a a8 TAY &235b 60 RTS ; check_if_player_touching_moving_platform &235c a6 0b LDX &0b ; obstacle_present # Non-zero if obstacle present &235e a9 00 LDA #&00 &2360 85 0b STA &0b ; obstacle_present &2362 ad 49 12 LDA &1249 ; vertical_enemy_type &2365 c9 01 CMP #&01 ; VERTICAL_ENEMY_TYPE_BUTTERFLY &2367 d0 09 BNE &2372 ; skip_draining_energy &2369 e0 01 CPX #&01 &236b d0 05 BNE &2372 ; skip_draining_energy &236d a2 00 LDX #&00 # Set to zero to stop butterflies lifting player &236f 20 88 2b JSR &2b88 ; lose_energy # Lose energy for touching moving butterfly ; skip_draining_energy &2372 e0 01 CPX #&01 # Leave with zero set if player touching platform &2374 60 RTS ; check_if_vertical_enemy_at_minimum_or_maximum_y &2375 a9 01 LDA #&01 # Set to non-zero to indicate vertical enemy. This is &2377 85 75 STA &75 ; player_or_vertical_enemy # unnecessary; value is only checked when the player &2379 b9 19 00 LDA &0019,Y ; vertical_enemies_y - 8 &237c 29 fe AND #&fe &237e cd 46 12 CMP &1246 ; vertical_enemies_minimum_y &2381 f0 06 BEQ &2389 ; set_vertical_enemy_moving_down &2383 cd 47 12 CMP &1247 ; vertical_enemies_maximum_y &2386 f0 07 BEQ &238f ; set_vertical_enemy_moving_up &2388 60 RTS ; set_vertical_enemy_moving_down &2389 a9 02 LDA #&02 ; set_vertical_enemy_y_velocity &238b 99 18 00 STA &0018,Y ; vertical_enemies_y_velocity - 8 &238e 60 RTS ; set_vertical_enemy_moving_up &238f a9 fe LDA #&fe &2391 4c 8b 23 JMP &238b ; set_vertical_enemy_y_velocity ; apply_y_velocity_to_vertical_enemy &2394 b9 19 00 LDA &0019,Y ; vertical_enemies_y - 8 &2397 85 3c STA &3c ; sprite_y &2399 b9 18 00 LDA &0018,Y ; vertical_enemies_y_velocity - 8 &239c 85 40 STA &40 ; y_velocity &239e b9 51 00 LDA &0051,Y ; vertical_enemies_screen_address_low - 8 &23a1 85 3e STA &3e ; sprite_screen_address_low &23a3 b9 52 00 LDA &0052,Y ; vertical_enemies_screen_address_high - 8 &23a6 85 3f STA &3f ; sprite_screen_address_high &23a8 20 f1 34 JSR &34f1 ; apply_y_velocity_to_sprite &23ab a5 3c LDA &3c ; sprite_y &23ad 99 19 00 STA &0019,Y ; vertical_enemies_y - 8 &23b0 a5 3e LDA &3e ; sprite_screen_address_low &23b2 99 51 00 STA &0051,Y ; vertical_enemies_screen_address_low - 8 &23b5 a5 3f LDA &3f ; sprite_screen_address_high &23b7 99 52 00 STA &0052,Y ; vertical_enemies_screen_address_high - 8 &23ba a9 00 LDA #&00 &23bc 85 75 STA &75 ; player_or_vertical_enemy # Set to zero to indicate player &23be 60 RTS ; plot_or_unplot_moving_platform # Called with Y = vertical enemy slot &23bf c0 00 CPY #&00 &23c1 f0 fb BEQ &23be ; leave # Don't plot fastest moving platform for type one &23c3 c0 08 CPY #&08 &23c5 f0 f7 BEQ &23be ; leave # Don't plot fastest moving platform for type two ; plot_or_unplot_vertical_enemy &23c7 a2 0c LDX #&0c ; SPRITE_VERTICAL_ENEMY_FRAME_ONE &23c9 ad 49 12 LDA &1249 ; vertical_enemy_type &23cc 4a LSR A # Set carry if VERTICAL_ENEMY_TYPE_BUTTERFLY &23cd 90 18 BCC &23e7 ; is_moving_platform ; is_butterfly &23cf b9 19 00 LDA &0019,Y ; vertical_enemies_y - 8 &23d2 4a LSR A # Animate moving butterflies based on y position &23d3 4a LSR A &23d4 4a LSR A &23d5 b0 02 BCS &23d9 ; skip_using_frame_two &23d7 a2 0e LDX #&0e ; SPRITE_VERTICAL_ENEMY_FRAME_TWO ; skip_using_frame_two &23d9 ad 4a 12 LDA &124a ; vertical_enemy_top_two_bits_plus_ten &23dc f0 09 BEQ &23e7 ; is_single_height ; is_double_height &23de a9 01 LDA #&01 &23e0 85 6c STA &6c ; double_sprite # Set to non-zero to indicate sprite doubled vertically &23e2 a9 02 LDA #&02 &23e4 4c e9 23 JMP &23e9 ; set_sprite_height_and_plot_vertical_enemy ; is_moving_platform ; is_single_height &23e7 a9 01 LDA #&01 ; set_sprite_height_and_plot_vertical_enemy &23e9 85 41 STA &41 ; sprite_height &23eb b9 52 00 LDA &0052,Y ; vertical_enemies_screen_address_high - 8 &23ee 85 7d STA &7d ; screen_address_high &23f0 b9 51 00 LDA &0051,Y ; vertical_enemies_screen_address_low - 8 &23f3 4c c5 32 JMP &32c5 ; plot_sprite ; update_moving_platforms_type_two # Platforms are faster to the right &23f6 a0 08 LDY #&08 ; platform slot &23f8 e6 29 INC &29 ; platforms_type_two_state &23fa a5 29 LDA &29 ; platforms_type_two_state &23fc 85 34 STA &34 ; platforms_bitmap &23fe 4c de 22 JMP &22de ; update_moving_platforms ; update_vertical_enemies &2401 a0 08 LDY #&08 # Start with first vertical enemy ; update_vertical_enemies_loop &2403 a5 61 LDA &61 ; plotting_or_updating_enemies # Zero if plotting, non-zero if updating &2405 f0 03 BEQ &240a ; skip_unplotting &2407 20 c7 23 JSR &23c7 ; plot_or_unplot_vertical_enemy # Unplot vertical enemy ; skip_unplotting &240a 20 23 24 JSR &2423 ; update_vertical_enemy &240d c0 0a CPY #&0a &240f d0 03 BNE &2414 ; skip_double_update &2411 20 23 24 JSR &2423 ; update_vertical_enemy # Second vertical enemy moves twice as fast ; skip_double_update &2414 20 c7 23 JSR &23c7 ; plot_or_unplot_vertical_enemy # Plot vertical enemy &2417 c8 INY &2418 c8 INY &2419 cc 4a 12 CPY &124a ; vertical_enemy_top_two_bits_plus_ten &241c d0 e5 BNE &2403 ; update_vertical_enemies_loop &241e a9 00 LDA #&00 &2420 85 6c STA &6c ; double_sprite # Set to zero to indicate sprite not doubled vertically &2422 60 RTS ; update_vertical_enemy # Called with Y = &08 for first, &0e = for second enemy &2423 98 TYA &2424 38 SEC &2425 e9 08 SBC #&08 # -> &00 -> &06 &2427 0a ASL A # -> &00 -> &0c &2428 85 31 STA &31 ; x_offset # i.e. move second enemy to left for collision purposes &242a 20 75 23 JSR &2375 ; check_if_vertical_enemy_at_minimum_or_maximum_y &242d ad 49 12 LDA &1249 ; vertical_enemy_type &2430 c9 01 CMP #&01 ; VERTICAL_ENEMY_TYPE_BUTTERFLY &2432 d0 14 BNE &2448 ; is_moving_platform ; is_butterfly &2434 b9 19 00 LDA &0019,Y ; vertical_enemies_y - 8 &2437 4a LSR A &2438 85 3c STA &3c ; sprite_y &243a 38 SEC &243b ad 48 12 LDA &1248 ; vertical_enemy_x &243e e5 31 SBC &31 ; x_offset &2440 85 11 STA &11 ; sprite_x &2442 20 57 2b JSR &2b57 ; lose_energy_if_touching_enemy # Lose energy if touching vertical enemy &2445 4c 4b 24 JMP &244b ; to_apply_y_velocity_to_vertical_enemy ; is_moving_platform &2448 20 0d 23 JSR &230d ; move_moving_platform ; to_apply_y_velocity_to_vertical_enemy &244b 4c 94 23 JMP &2394 ; apply_y_velocity_to_vertical_enemy ; set_feature_tile &244e a4 02 LDY &02 ; feature_tile_x &2450 91 00 STA (&00),Y ; feature_tile_data_address &2452 60 RTS ; collect_crystal &2453 c6 2a DEC &2a ; crystals_remaining &2455 d0 02 BNE &2459 ; not_all_collected &2457 c6 a2 DEC &a2 ; force_fields_remaining # Remove a force field for collecting all crystals ; not_all_collected &2459 a9 ff LDA #&ff &245b 8d a4 32 STA &32a4 ; sound_block + 4 (pitch) &245e a9 0e LDA #&0e &2460 8d a6 32 STA &32a6 ; sound_block + 6 (duration) &2463 a9 02 LDA #&02 &2465 20 33 33 JSR &3333 ; play_sound_on_channel_two # Play sound for collecting crystal &2468 20 d2 24 JSR &24d2 ; gain_energy # Gain energy for collecting crystal &246b 20 71 24 JSR &2471 ; unplot_crystal &246e 4c eb 31 JMP &31eb ; plot_bar_across_top_of_status_section ; unplot_crystal &2471 a2 02 LDX #&02 &2473 a5 2a LDA &2a ; crystals_remaining &2475 0a ASL A &2476 0a ASL A &2477 0a ASL A &2478 0a ASL A &2479 18 CLC &247a 69 f0 ADC #&f0 ; &3cf0 &247c 85 7c STA &7c ; screen_address_low &247e a9 00 LDA #&00 &2480 69 3c ADC #&3c &2482 85 7d STA &7d ; screen_address_high &2484 20 c2 24 JSR &24c2 ; unplot_status_sprite_at_screen_address &2487 ad 43 12 LDA &1243 ; feature_screen_address_low &248a 85 7c STA &7c ; screen_address_low &248c ad 44 12 LDA &1244 ; feature_screen_address_high &248f 85 7d STA &7d ; screen_address_high &2491 a9 0d LDA #&0d ; TILE_COLLECTED_CRYSTAL &2493 20 4e 24 JSR &244e ; set_feature_tile ; plot_X_rows_of_two_blank_subtiles &2496 a9 00 LDA #&00 ; SUBTILE_BLANK &2498 85 34 STA &34 ; subtile_to_plot ; plot_X_rows_of_two_subtiles ; plot_X_rows_of_two_subtiles_row_loop &249a a5 34 LDA &34 ; subtile_to_plot &249c 20 26 12 JSR &1226 ; to_plot_subtile &249f 20 26 12 JSR &1226 ; to_plot_subtile &24a2 18 CLC &24a3 a5 7c LDA &7c ; screen_address_low &24a5 69 60 ADC #&60 # Move down a group &24a7 85 7c STA &7c ; screen_address_low &24a9 a5 7d LDA &7d ; screen_address_high &24ab 69 02 ADC #&02 &24ad 85 7d STA &7d ; screen_address_high &24af ca DEX &24b0 d0 e8 BNE &249a ; plot_X_rows_of_two_subtiles_row_loop &24b2 60 RTS ; unplot_status_sprite_at_position # Called with A = x position in status bar &24b3 0a ASL A &24b4 0a ASL A &24b5 0a ASL A &24b6 0a ASL A &24b7 18 CLC &24b8 69 70 ADC #&70 ; &3f70 &24ba 85 7c STA &7c ; screen_address_low &24bc a9 00 LDA #&00 &24be 69 3f ADC #&3f &24c0 85 7d STA &7d ; screen_address_high ; unplot_status_sprite_at_screen_address &24c2 a9 02 LDA #&02 ; SUBTILE_SET_STATUS_SPRITES &24c4 8d 24 12 STA &1224 ; subtile_set &24c7 a9 03 LDA #&03 ; STATUS_SPRITE_BLANK &24c9 20 26 12 JSR &1226 ; to_plot_subtile &24cc a9 00 LDA #&00 ; SUBTILE_SET_TILE_SPRITES &24ce 8d 24 12 STA &1224 ; subtile_set &24d1 60 RTS ; gain_energy &24d2 a2 1c LDX #&1c ; 28 ; gain_energy_loop &24d4 e6 3a INC &3a ; player_previous_energy &24d6 d0 04 BNE &24dc ; skip_ceiling &24d8 a9 ff LDA #&ff ; skip_ceiling &24da 85 3a STA &3a ; player_previous_energy &24dc a5 3a LDA &3a ; player_previous_energy &24de 85 3b STA &3b ; player_energy &24e0 20 30 26 JSR &2630 ; plot_energy_section &24e3 ca DEX &24e4 d0 ee BNE &24d4 ; gain_energy_loop &24e6 60 RTS ; set_player_acceleration_in_joke_shop &24e7 a5 16 LDA &16 ; player_previous_x &24e9 4a LSR A &24ea 4a LSR A &24eb 4a LSR A &24ec 4a LSR A &24ed aa TAX &24ee bd f4 24 LDA &24f4,X ; joke_shop_acceleration_table &24f1 85 4d STA &4d ; player_y_acceleration ; leave &24f3 60 RTS ; joke_shop_acceleration_table ; 0 1 2 3 4 &24f4 01 ff 02 fe 03 ; warp_time &24f9 ee 2e 25 INC &252e ; time_warp_timer &24fc 38 SEC &24fd a9 10 LDA #&10 &24ff e5 4f SBC &4f ; wait_duration &2501 cd 2e 25 CMP &252e ; time_warp_timer &2504 10 ed BPL &24f3 ; leave &2506 a9 00 LDA #&00 &2508 8d 2e 25 STA &252e ; time_warp_timer &250b 18 CLC &250c a5 4f LDA &4f ; wait_duration &250e 6d 2d 25 ADC &252d ; time_warp_acceleration &2511 85 4f STA &4f ; wait_duration &2513 a5 4f LDA &4f ; wait_duration &2515 c9 10 CMP #&10 &2517 f0 05 BEQ &251e ; reverse_time_warp_acceleration &2519 c9 03 CMP #&03 &251b f0 01 BEQ &251e ; reverse_time_warp_acceleration &251d 60 RTS ; reverse_time_warp_acceleration &251e 20 83 0b JSR &0b83 ; event_handler &2521 ad 2d 25 LDA &252d ; time_warp_acceleration &2524 49 ff EOR #&ff &2526 8d 2d 25 STA &252d ; time_warp_acceleration &2529 ee 2d 25 INC &252d ; time_warp_acceleration &252c 60 RTS ; time_warp_acceleration &252d 01 ; time_warp_timer &252e 08 ; play_game &252f a9 04 LDA #&04 &2531 85 a1 STA &a1 ; stun_grenades_carried_plus_four &2533 a2 08 LDX #&08 # Start game with eight stun grenades ; reset_stun_grenades_loop &2535 20 bd 0b JSR &0bbd ; to_gain_stun_grenade &2538 ca DEX &2539 d0 fa BNE &2535 ; reset_stun_grenades_loop ; new_life &253b 20 06 12 JSR &1206 ; to_plot_room &253e 20 d4 2d JSR &2dd4 ; initialise_crossing_enemies &2541 20 a1 2c JSR &2ca1 ; plot_carried_objects &2544 20 89 2a JSR &2a89 ; plot_or_unplot_player # Plot player &2547 20 ce 30 JSR &30ce ; recharge_energy &254a 20 83 0b JSR &0b83 ; event_handler ; main_game_loop &254d 20 a0 0b JSR &0ba0 ; reset_clock &2550 20 5a 26 JSR &265a ; update_player &2553 20 37 22 JSR &2237 ; update_game &2556 20 c4 25 JSR &25c4 ; consider_auto_transporting_player &2559 a5 62 LDA &62 ; player_state # Positive non-zero if dead, negative if game completed &255b f0 f0 BEQ &254d ; main_game_loop &255d 30 5a BMI &25b9 ; is_completed ; has_died &255f a9 00 LDA #&00 &2561 85 62 STA &62 ; player_state # Set to zero to indicate not dead, nor game completed &2563 e6 9d INC &9d ; reincarnations_used &2565 20 dc 25 JSR &25dc ; animate_auto_transport &2568 20 42 31 JSR &3142 ; flash_background &256b a5 3d LDA &3d ; allow_reincarnation # Non-zero if reincarnation allowed &256d f0 30 BEQ &259f ; skip_reincarnating ; consider_reincarnating &256f a5 9d LDA &9d ; reincarnations_used &2571 c9 05 CMP #&05 &2573 10 2a BPL &259f ; skip_reincarnating &2575 20 56 32 JSR &3256 ; write_string &2578 1f 0a 0f ; TAB(&0a, &0f) &257b 52 45 49 4e 43 41 52 4e 41 54 45 3f 20 28 59 20 ; "REINCARNATE? (Y or N)" &258b 6f 72 20 4e 29 &2590 00 ; end of string ; wait_for_y_or_n &2591 a2 bb LDX #&bb ; Y &2593 20 90 27 JSR &2790 ; check_for_keypress &2596 b0 a3 BCS &253b ; new_life &2598 a2 aa LDX #&aa ; N &259a 20 90 27 JSR &2790 ; check_for_keypress &259d 90 f2 BCC &2591 ; wait_for_y_or_n ; skip_reincarnating &259f 20 56 32 JSR &3256 ; write_string &25a2 1f 10 11 ; TAB(&10, &11) &25a5 47 41 4d 45 20 4f 56 45 52 ; "GAME OVER &25ae 00 ; end of string &25af 20 a0 0b JSR &0ba0 ; reset_clock &25b2 a9 80 LDA #&80 &25b4 85 4f STA &4f ; wait_duration &25b6 4c c5 22 JMP &22c5 ; wait_for_clock ; is_completed &25b9 20 8f 32 JSR &328f ; completion_screen ; wait_for_space &25bc a2 9d LDX #&9d ; SPACE &25be 20 90 27 JSR &2790 ; check_for_keypress &25c1 90 f9 BCC &25bc ; wait_for_space ; leave &25c3 60 RTS ; consider_auto_transporting_player &25c4 38 SEC &25c5 a5 3a LDA &3a ; player_previous_energy &25c7 e5 3b SBC &3b ; player_energy &25c9 f0 49 BEQ &2614 ; not_taking_damage ; is_taking_damage &25cb 85 33 STA &33 ; player_energy_delta &25cd a5 3b LDA &3b ; player_energy &25cf 85 3a STA &3a ; player_previous_energy &25d1 38 SEC &25d2 a5 4b LDA &4b ; player_energy_remaining_before_transport &25d4 e5 33 SBC &33 ; player_energy_delta &25d6 85 4b STA &4b ; player_energy_remaining_before_transport &25d8 10 e9 BPL &25c3 ; leave &25da 85 9f STA &9f ; player_underwater_breath_timer # Start a new breath on auto-transport ; animate_auto_transport &25dc a2 09 LDX #&09 ; flashing red/cyan &25de 20 4f 31 JSR &314f ; set_background_colour &25e1 a9 0f LDA #&0f &25e3 8d a6 32 STA &32a6 ; sound_block + 6 (duration) &25e6 8d a4 32 STA &32a4 ; sound_block + 4 (pitch) &25e9 a9 04 LDA #&04 &25eb 20 33 33 JSR &3333 ; play_sound_on_channel_two # Play sound for auto-transport ; animate_auto_transport_loop &25ee a5 2e LDA &2e ; initial_player_y &25f0 4a LSR A &25f1 85 31 STA &31 ; half_initial_player_y &25f3 a2 02 LDX #&02 &25f5 a5 2c LDA &2c ; player_y &25f7 4a LSR A &25f8 c5 31 CMP &31 ; half_initial_player_y &25fa 18 CLC &25fb f0 0a BEQ &2607 ; skip_moving_player_vertically &25fd 30 02 BMI &2601 ; is_above_initial_position ; is_below_initial_position &25ff a2 fe LDX #&fe ; is_above_initial_position &2601 86 40 STX &40 ; y_velocity &2603 20 ef 28 JSR &28ef ; apply_y_velocity_to_player &2606 38 SEC ; skip_moving_player_vertically &2607 b0 10 BCS &2619 ; not_at_initial_position &2609 a5 35 LDA &35 ; player_x &260b c5 2d CMP &2d ; initial_player_x &260d d0 0a BNE &2619 ; not_at_initial_position ; at_initial_position &260f a2 00 LDX #&00 ; black &2611 20 4f 31 JSR &314f ; set_background_colour ; not_taking_damage &2614 a9 0c LDA #&0c # Player can take 12 damage before auto-transport &2616 85 4b STA &4b ; player_energy_remaining_before_transport &2618 60 RTS ; not_at_initial_position &2619 a5 35 LDA &35 ; player_x &261b c5 2d CMP &2d ; initial_player_x &261d f0 0b BEQ &262a ; skip_moving_player_horizontally &261f 10 06 BPL &2627 ; is_right_of_initial_position ; is_left_of_initial_position &2621 20 c8 27 JSR &27c8 ; move_player_right &2624 4c 2a 26 JMP &262a ; skip_moving_player_horizontally ; is_right_of_initial_position &2627 20 05 28 JSR &2805 ; move_player_left ; skip_moving_player_horizontally &262a 20 82 27 JSR &2782 ; replot_player &262d 4c ee 25 JMP &25ee ; animate_auto_transport_loop ; plot_energy_section &2630 98 TYA &2631 48 PHA ; tmp_y &2632 a5 3b LDA &3b ; player_energy &2634 29 f8 AND #&f8 &2636 18 CLC &2637 69 71 ADC #&71 ; &4071 &2639 85 7c STA &7c ; screen_address_low &263b a9 40 LDA #&40 &263d 69 00 ADC #&00 &263f 85 7d STA &7d ; screen_address_high &2641 a5 3b LDA &3b ; player_energy &2643 29 07 AND #&07 &2645 4a LSR A &2646 a8 TAY &2647 b9 22 22 LDA &2222,Y ; energy_pixel_values &264a a0 04 LDY #&04 ; plot_energy_section_loop &264c 91 7c STA (&7c),Y ; screen_address &264e 88 DEY &264f d0 fb BNE &264c ; plot_energy_section_loop &2651 68 PLA ; tmp_y &2652 a8 TAY &2653 60 RTS ; reincarnate_keycodes &2654 dd ; E &2655 cc ; R &2656 dc ; T &2657 be ; A &2658 aa ; N &2659 da ; I ; update_player &265a a9 00 LDA #&00 &265c 85 13 STA &13 ; player_wants_to_jump # Set to zero to indicate doesn't want to jump &265e a2 9e LDX #&9e ; Z &2660 20 90 27 JSR &2790 ; check_for_keypress &2663 90 06 BCC &266b ; left_not_pressed &2665 a9 ff LDA #&ff &2667 85 07 STA &07 ; player_desired_x_velocity &2669 85 08 STA &08 ; player_facing # Set to negative to indicate facing left ; left_not_pressed &266b a2 bd LDX #&bd ; X &266d 20 90 27 JSR &2790 ; check_for_keypress &2670 90 09 BCC &267b ; right_not_pressed &2672 a9 01 LDA #&01 &2674 85 07 STA &07 ; player_desired_x_velocity &2676 85 08 STA &08 ; player_facing # Set to positive to indicate facing right &2678 4c 85 26 JMP &2685 ; fire_not_pressed ; right_not_pressed &267b a2 9d LDX #&9d ; SPACE &267d 20 90 27 JSR &2790 ; check_for_keypress &2680 90 03 BCC &2685 ; fire_not_pressed &2682 20 ed 30 JSR &30ed ; fire_stun_grenade ; fire_not_pressed &2685 a5 a6 LDA &a6 ; transmogrifier_present # Non-zero if room has transmogrifier &2687 f0 1e BEQ &26a7 ; half_thrust_not_pressed # Can't thrust if no transmogrifier in room &2689 a2 b7 LDX #&b7 ; : &268b 20 90 27 JSR &2790 ; check_for_keypress &268e 90 09 BCC &2699 ; full_thrust_not_pressed &2690 a5 0e LDA &0e ; player_y_velocity &2692 18 CLC &2693 65 4d ADC &4d ; player_y_acceleration &2695 65 4d ADC &4d ; player_y_acceleration &2697 85 0e STA &0e ; player_y_velocity ; full_thrust_not_pressed &2699 a2 97 LDX #&97 ; / &269b 20 90 27 JSR &2790 ; check_for_keypress &269e 90 07 BCC &26a7 ; half_thrust_not_pressed &26a0 18 CLC &26a1 a5 0e LDA &0e ; player_y_velocity &26a3 65 4d ADC &4d ; player_y_acceleration &26a5 85 0e STA &0e ; player_y_velocity ; half_thrust_not_pressed &26a7 a2 b6 LDX #&b6 ; RETURN &26a9 20 90 27 JSR &2790 ; check_for_keypress &26ac 90 07 BCC &26b5 ; jump_not_pressed &26ae a9 01 LDA #&01 &26b0 85 13 STA &13 ; player_wants_to_jump # Set to non-zero to indicate player wants to jump &26b2 4c c6 26 JMP &26c6 ; copy_not_pressed ; jump_not_pressed &26b5 a2 96 LDX #&96 ; COPY &26b7 20 90 27 JSR &2790 ; check_for_keypress &26ba 90 0a BCC &26c6 ; copy_not_pressed ; wait_for_delete &26bc a2 a6 LDX #&a6 ; DELETE # DELETE is wired on all BBC Micros, as any fule kno &26be 20 90 27 JSR &2790 ; check_for_keypress &26c1 90 f9 BCC &26bc ; wait_for_delete &26c3 20 a0 0b JSR &0ba0 ; reset_clock ; copy_not_pressed &26c6 a5 07 LDA &07 ; player_desired_x_velocity &26c8 c9 01 CMP #&01 &26ca d0 03 BNE &26cf ; not_wanting_to_move_right &26cc 20 97 27 JSR &2797 ; consider_moving_player_right ; not_wanting_to_move_right &26cf a5 07 LDA &07 ; player_desired_x_velocity &26d1 c9 ff CMP #&ff &26d3 d0 03 BNE &26d8 ; not_wanting_to_move_left &26d5 20 d6 27 JSR &27d6 ; consider_moving_player_left ; not_wanting_to_move_left &26d8 a5 0e LDA &0e ; player_y_velocity &26da f0 0b BEQ &26e7 ; consider_draining_energy_for_spending_too_long_underwater &26dc 10 06 BPL &26e4 ; is_rising ; is_falling &26de 20 13 28 JSR &2813 ; update_falling_player &26e1 4c e7 26 JMP &26e7 ; consider_draining_energy_for_spending_too_long_underwater ; is_rising &26e4 20 a7 28 JSR &28a7 ; update_rising_player ; consider_draining_energy_for_spending_too_long_underwater &26e7 a5 39 LDA &39 ; player_screen_address_high &26e9 c9 41 CMP #&41 &26eb 30 0d BMI &26fa ; is_in_water # If player crossing top of room , assume in water ; not_crossing_top_of_room &26ed a0 00 LDY #&00 &26ef b1 38 LDA (&38),Y ; player_screen_address # Get byte at top left of player &26f1 29 ee AND #&ee ; 3330 &26f3 d0 05 BNE &26fa ; is_in_water # Branch if in water ; not_in_water &26f5 84 9f STY &9f ; player_underwater_breath_timer # Set to zero if player in air &26f7 4c 03 27 JMP &2703 ; not_out_of_breath ; is_in_water &26fa c6 9f DEC &9f ; player_underwater_breath_timer &26fc d0 05 BNE &2703 ; not_out_of_breath &26fe 20 88 2b JSR &2b88 ; lose_energy # Lose energy for spending too long in water &2701 e6 9f INC &9f ; player_underwater_breath_timer # Set to &01 to continue draining until auto-transport ; not_out_of_breath &2703 a5 36 LDA &36 ; player_previous_screen_address_low &2705 c5 38 CMP &38 ; player_screen_address_low &2707 d0 64 BNE &276d ; skip_checking_for_stationary_actions &2709 a5 05 LDA &05 ; player_previous_facing &270b c5 08 CMP &08 ; player_facing &270d d0 5e BNE &276d ; skip_checking_for_stationary_actions &270f a5 37 LDA &37 ; player_previous_screen_address_high &2711 c5 39 CMP &39 ; player_screen_address_high &2713 d0 58 BNE &276d ; skip_checking_for_stationary_actions ; check_for_stationary_actions &2715 a2 cd LDX #&cd ; D &2717 20 90 27 JSR &2790 ; check_for_keypress &271a 90 03 BCC &271f ; drop_not_pressed &271c 20 e6 2c JSR &2ce6 ; consider_dropping_object ; drop_not_pressed &271f a2 c8 LDX #&c8 ; P &2721 20 90 27 JSR &2790 ; check_for_keypress &2724 90 03 BCC &2729 ; pick_up_not_pressed &2726 20 0e 2c JSR &2c0e ; consider_picking_up_object ; pick_up_not_pressed &2729 a2 8f LDX #&8f ; ESCAPE &272b 20 90 27 JSR &2790 ; check_for_keypress &272e 90 04 BCC &2734 ; escape_not_pressed &2730 a9 01 LDA #&01 # Set to positive non-zero to indicate player dead &2732 85 62 STA &62 ; player_state ; escape_not_pressed &2734 a2 ef LDX #&ef ; Q &2736 20 90 27 JSR &2790 ; check_for_keypress &2739 90 04 BCC &273f ; q_not_pressed &273b a9 01 LDA #&01 &273d 85 9e STA &9e ; suppress_sound # Set to non-zero to suppress sound ; q_not_pressed &273f a2 ae LDX #&ae ; S &2741 20 90 27 JSR &2790 ; check_for_keypress &2744 90 04 BCC &274a ; s_not_pressed &2746 a9 00 LDA #&00 &2748 85 9e STA &9e ; suppress_sound # Set to zero to allow sound ; s_not_pressed &274a a2 ad LDX #&ad ; C &274c 20 90 27 JSR &2790 ; check_for_keypress &274f 90 19 BCC &276a ; reincarnate_not_pressed &2751 a0 05 LDY #&05 ; check_for_reincarnate_loop # IF R, E, I, N, C, A and T pressed together, &2753 98 TYA &2754 48 PHA &2755 b9 54 26 LDA &2654,Y ; reincarnate_keycodes &2758 aa TAX &2759 20 90 27 JSR &2790 ; check_for_keypress &275c 68 PLA &275d a8 TAY &275e 90 0a BCC &276a ; reincarnate_not_pressed &2760 88 DEY &2761 10 f0 BPL &2753 ; check_for_reincarnate_loop &2763 84 3d STY &3d ; allow_reincarnation # Set to non-zero to allow reincarnation &2765 a9 07 LDA #&07 ; BELL &2767 20 ee ff JSR &ffee ; OSWRCH ; reincarnate_not_pressed &276a 4c 70 27 JMP &2770 ; apply_player_y_acceleration ; skip_checking_for_stationary_actions &276d 20 82 27 JSR &2782 ; replot_player ; apply_player_y_acceleration &2770 a9 00 LDA #&00 &2772 85 07 STA &07 ; player_desired_x_velocity &2774 85 0a STA &0a ; screen_y # Unnecessary code &2776 85 15 STA &15 ; player_is_supported &2778 85 0b STA &0b ; screen_x # Unnecessary code &277a 38 SEC &277b a5 0e LDA &0e ; player_y_velocity &277d e5 4d SBC &4d ; player_y_acceleration &277f 85 0e STA &0e ; player_y_velocity ; leave &2781 60 RTS ; replot_player &2782 a9 13 LDA #&13 ; Wait for vertical retrace &2784 20 f4 ff JSR &fff4 ; OSBYTE &2787 20 89 2a JSR &2a89 ; plot_or_unplot_player # Unplot player &278a 20 ba 2a JSR &2aba ; store_previous_player_variables &278d 4c 89 2a JMP &2a89 ; plot_or_unplot_player # Plot player ; check_for_keypress &2790 a0 ff LDY #&ff &2792 a9 81 LDA #&81 ; Scan for a particular key &2794 4c f4 ff JMP &fff4 ; OSBYTE ; consider_moving_player_right &2797 a5 35 LDA &35 ; player_x &2799 c9 4c CMP #&4c # Is the player at the right of the screen? &279b d0 03 BNE &27a0 ; not_at_right_edge_of_room &279d 4c cf 2a JMP &2acf ; move_right_a_room ; not_at_right_edge_of_room &27a0 18 CLC &27a1 a5 38 LDA &38 ; player_screen_address_low &27a3 69 20 ADC #&20 # Check immediately to right of player &27a5 85 7c STA &7c ; screen_address_low &27a7 a5 39 LDA &39 ; player_screen_address_high &27a9 69 00 ADC #&00 &27ab 85 7d STA &7d ; screen_address_high &27ad a9 18 LDA #&18 &27af 85 41 STA &41 ; rows_to_check &27b1 20 0b 29 JSR &290b ; check_column_for_obstacle # Returns carry set if obstacle &27b4 90 12 BCC &27c8 ; move_player_right ; is_obstacle_to_right &27b6 18 CLC &27b7 a5 38 LDA &38 ; player_screen_address_low &27b9 29 f0 AND #&f0 &27bb 69 b5 ADC #&b5 ; &0280 + &20 + &10 + 5 # Check bottom three rows, eight pixels to right of player &27bd 85 7c STA &7c ; screen_address_low &27bf a5 39 LDA &39 ; player_screen_address_high &27c1 69 02 ADC #&02 &27c3 85 7d STA &7d ; screen_address_high &27c5 4c b9 29 JMP &29b9 ; check_for_player_touching_subtiles ; move_player_right &27c8 e6 35 INC &35 ; player_x &27ca a5 38 LDA &38 ; player_screen_address_low &27cc 18 CLC &27cd 69 08 ADC #&08 # Move right four pixels &27cf 85 38 STA &38 ; player_screen_address_low &27d1 90 ae BCC &2781 ; leave &27d3 e6 39 INC &39 ; player_screen_address_high ; leave &27d5 60 RTS ; consider_moving_player_left &27d6 a5 35 LDA &35 ; player_x &27d8 d0 03 BNE &27dd ; not_at_left_edge_of_room # Is the player at the left of the screen? &27da 4c e6 2a JMP &2ae6 ; move_left_a_room ; not_at_left_edge_of_room &27dd 38 SEC &27de a5 38 LDA &38 ; player_screen_address_low &27e0 e9 08 SBC #&08 # Check immediately to left of player &27e2 85 7c STA &7c ; screen_address_low &27e4 a5 39 LDA &39 ; player_screen_address_high &27e6 e9 00 SBC #&00 &27e8 85 7d STA &7d ; screen_address_high &27ea a9 18 LDA #&18 &27ec 85 41 STA &41 ; rows_to_check &27ee 20 0b 29 JSR &290b ; check_column_for_obstacle # Returns carry set if obstacle &27f1 90 12 BCC &2805 ; move_player_left ; is_obstacle_to_left &27f3 18 CLC &27f4 a5 38 LDA &38 ; player_screen_address_low &27f6 29 f0 AND #&f0 &27f8 69 75 ADC #&75 ; &0280 - &10 + 5 # Check bottom three rows, eight pixels to left of player &27fa 85 7c STA &7c ; screen_address_low &27fc a5 39 LDA &39 ; player_screen_address_high &27fe 69 02 ADC #&02 &2800 85 7d STA &7d ; screen_address_high &2802 4c b9 29 JMP &29b9 ; check_for_player_touching_subtiles ; move_player_left &2805 c6 35 DEC &35 ; player_x &2807 38 SEC &2808 a5 38 LDA &38 ; player_screen_address_low &280a e9 08 SBC #&08 # Move left four pixels &280c 85 38 STA &38 ; player_screen_address_low &280e b0 c5 BCS &27d5 ; leave &2810 c6 39 DEC &39 ; player_screen_address_high &2812 60 RTS ; update_falling_player &2813 38 SEC &2814 a9 ff LDA #&ff &2816 e5 0e SBC &0e ; player_y_velocity &2818 69 04 ADC #&04 &281a 4a LSR A &281b 4a LSR A &281c 85 0f STA &0f ; distance_to_move ; move_player_down_loop &281e a5 2c LDA &2c ; player_y &2820 4a LSR A &2821 c9 60 CMP #&60 &2823 30 0a BMI &282f ; not_crossing_bottom_of_room &2825 c9 6c CMP #&6c &2827 10 06 BPL &282f ; not_crossing_bottom_of_room ; is_crossing_bottom_of_room &2829 20 ba 2a JSR &2aba ; store_previous_player_variables &282c 4c fd 2a JMP &2afd ; consider_moving_down_a_room ; not_crossing_bottom_of_room &282f 20 93 28 JSR &2893 ; check_row_below_player_for_obstacle # Returns carry set if obstacle &2832 90 38 BCC &286c ; not_supported ; is_supported &2834 a9 01 LDA #&01 &2836 85 15 STA &15 ; player_is_supported # Set to non-zero to indicate player is supported &2838 a5 0e LDA &0e ; player_y_velocity &283a c9 f2 CMP #&f2 &283c 10 08 BPL &2846 ; not_landing_too_fast ; is_landing_too_fast &283e 20 88 2b JSR &2b88 ; lose_energy # Lose energy for colliding with floor too fast &2841 e6 0e INC &0e ; player_y_velocity &2843 e6 0e INC &0e ; player_y_velocity &2845 60 RTS ; not_landing_too_fast &2846 20 35 2a JSR &2a35 ; check_if_touching_pipe_top &2849 a5 13 LDA &13 ; player_wants_to_jump &284b f0 1a BEQ &2867 ; not_starting_jump &284d a5 88 LDA &88 ; suppress_jumping_and_dropping # Non-zero if player is falling on platform or being drained &284f d0 16 BNE &2867 ; not_starting_jump ; start_jump &2851 a9 09 LDA #&09 &2853 85 0e STA &0e ; player_y_velocity &2855 a9 05 LDA #&05 &2857 8d a6 32 STA &32a6 ; sound_block + 6 (duration) &285a a9 3c LDA #&3c &285c 8d a4 32 STA &32a4 ; sound_block + 4 (pitch) &285f a9 03 LDA #&03 &2861 20 33 33 JSR &3333 ; play_sound_on_channel_two # Play sound for starting jump &2864 4c a7 28 JMP &28a7 ; update_rising_player ; not_starting_jump &2867 a9 00 LDA #&00 &2869 85 0e STA &0e ; player_y_velocity ; leave &286b 60 RTS ; not_supported &286c a9 00 LDA #&00 &286e 85 15 STA &15 ; player_is_supported # Set to zero to indicate player is not supported &2870 a9 02 LDA #&02 &2872 85 40 STA &40 ; y_velocity &2874 20 ef 28 JSR &28ef ; apply_y_velocity_to_player &2877 c6 0f DEC &0f ; distance_to_move &2879 d0 a3 BNE &281e ; move_player_down_loop ; consider_floating &287b a5 79 LDA &79 ; underwater # Non-zero if underwater &287d f0 ec BEQ &286b ; leave &287f a5 0e LDA &0e ; player_y_velocity &2881 c9 fc CMP #&fc &2883 10 06 BPL &288b ; is_sinking_slowly &2885 18 CLC &2886 69 04 ADC #&04 # Make player float upwards in water &2888 85 0e STA &0e ; player_y_velocity &288a 60 RTS ; is_sinking_slowly &288b a5 13 LDA &13 ; player_wants_to_jump &288d f0 dc BEQ &286b ; leave ; start_jump_in_water &288f a9 0a LDA #&0a &2891 85 0e STA &0e ; player_y_velocity # Player starts jump slightly faster in water ; check_row_below_player_for_obstacle &2893 20 99 28 JSR &2899 ; calculate_screen_address_below_player &2896 4c 57 29 JMP &2957 ; check_row_for_obstacle ; calculate_screen_address_below_player &2899 a5 38 LDA &38 ; player_screen_address_low &289b 18 CLC &289c 69 80 ADC #&80 ; &0780 = 3 * &280 &289e 85 7c STA &7c ; screen_address_low &28a0 a5 39 LDA &39 ; player_screen_address_high &28a2 69 07 ADC #&07 &28a4 85 7d STA &7d ; screen_address_high &28a6 60 RTS ; update_rising_player &28a7 18 CLC &28a8 a5 0e LDA &0e ; player_y_velocity &28aa 69 04 ADC #&04 &28ac 4a LSR A &28ad 4a LSR A ; move_player_up &28ae 85 0f STA &0f ; distance_to_move ; move_player_up_loop &28b0 a5 2c LDA &2c ; player_y &28b2 4a LSR A &28b3 c9 09 CMP #&09 &28b5 10 0a BPL &28c1 ; not_crossing_top_of_room &28b7 a5 75 LDA &75 ; player_or_vertical_enemy # Zero if player, non-zero if vertical enemy &28b9 d0 28 BNE &28e3 ; can_move_up # Always zero, never branches ; is_crossing_top_of_room &28bb 20 ba 2a JSR &2aba ; store_previous_player_variables &28be 4c 37 2b JMP &2b37 ; consider_moving_up_a_room ; not_crossing_top_of_room &28c1 a5 38 LDA &38 ; player_screen_address_low &28c3 85 7c STA &7c ; screen_address_low &28c5 a5 39 LDA &39 ; player_screen_address_high &28c7 85 7d STA &7d ; screen_address_high &28c9 20 3f 29 JSR &293f ; check_row_above_for_obstacle &28cc 90 15 BCC &28e3 ; can_move_up ; is_blocked_above &28ce a5 0e LDA &0e ; player_y_velocity &28d0 c9 0a CMP #&0a &28d2 30 0a BMI &28de ; not_colliding_too_fast ; is_colliding_too_fast &28d4 20 88 2b JSR &2b88 ; lose_energy # Lose energy for colliding with ceiling too fast &28d7 c6 0e DEC &0e ; player_y_velocity &28d9 c6 0e DEC &0e ; player_y_velocity &28db c6 0e DEC &0e ; player_y_velocity &28dd 60 RTS ; not_colliding_too_fast &28de a9 00 LDA #&00 &28e0 85 0e STA &0e ; player_y_velocity &28e2 60 RTS ; can_move_up &28e3 a9 fe LDA #&fe &28e5 85 40 STA &40 ; y_velocity &28e7 20 ef 28 JSR &28ef ; apply_y_velocity_to_player &28ea c6 0f DEC &0f ; distance_to_move &28ec d0 c2 BNE &28b0 ; move_player_up_loop &28ee 60 RTS ; apply_y_velocity_to_player &28ef a5 2c LDA &2c ; player_y &28f1 85 3c STA &3c ; sprite_y &28f3 a5 38 LDA &38 ; player_screen_address_low &28f5 85 3e STA &3e ; sprite_screen_address_low &28f7 a5 39 LDA &39 ; player_screen_address_high &28f9 85 3f STA &3f ; sprite_screen_address_high &28fb 20 f1 34 JSR &34f1 ; apply_y_velocity_to_sprite &28fe a5 3c LDA &3c ; sprite_y &2900 85 2c STA &2c ; player_y &2902 a5 3e LDA &3e ; sprite_screen_address_low &2904 85 38 STA &38 ; player_screen_address_low &2906 a5 3f LDA &3f ; sprite_screen_address_high &2908 85 39 STA &39 ; player_screen_address_high &290a 60 RTS ; check_column_for_obstacle &290b a2 00 LDX #&00 ; check_column_for_obstacle_loop &290d 20 a7 32 JSR &32a7 ; check_if_screen_address_is_outside_room # Returns carry set if outside room &2910 b0 0c BCS &291e ; consider_next_row &2912 a0 00 LDY #&00 &2914 b1 7c LDA (&7c),Y ; screen_address &2916 f0 06 BEQ &291e ; consider_next_row # Branch if blank space &2918 c9 c0 CMP #&c0 ; 3300 &291a f0 02 BEQ &291e ; consider_next_row # Branch if water &291c 38 SEC # Leave with carry set to indicate obstacle &291d 60 RTS ; consider_next_row &291e a5 7c LDA &7c ; screen_address_low &2920 29 07 AND #&07 &2922 c9 07 CMP #&07 &2924 f0 09 BEQ &292f ; next_group &2926 e6 7c INC &7c ; screen_address_low # Move down a row ; next_row &2928 e8 INX &2929 e4 41 CPX &41 ; rows_to_check &292b d0 e0 BNE &290d ; check_column_for_obstacle_loop &292d 18 CLC # Leave with carry clear to indicate no obstacle ; leave &292e 60 RTS ; next_group &292f 18 CLC &2930 a5 7c LDA &7c ; screen_address_low &2932 69 79 ADC #&79 # Move down a group &2934 85 7c STA &7c ; screen_address_low &2936 a5 7d LDA &7d ; screen_address_high &2938 69 02 ADC #&02 &293a 85 7d STA &7d ; screen_address_high &293c 4c 28 29 JMP &2928 ; next_row ; check_row_above_for_obstacle &293f a5 7c LDA &7c ; screen_address_low &2941 29 07 AND #&07 &2943 d0 10 BNE &2955 ; not_previous_group ; is_previous_group &2945 a5 7c LDA &7c ; screen_address_low &2947 38 SEC &2948 e9 79 SBC #&79 # Move up a group &294a 85 7c STA &7c ; screen_address_low &294c a5 7d LDA &7d ; screen_address_high &294e e9 02 SBC #&02 &2950 85 7d STA &7d ; screen_address_high &2952 4c 57 29 JMP &2957 ; check_row_for_obstacle ; not_previous_group &2955 c6 7c DEC &7c ; screen_address_low ; check_row_for_obstacle &2957 a2 04 LDX #&04 &2959 a0 00 LDY #&00 &295b 84 0b STY &0b ; obstacle_present # Set to zero to indicate no obstacle present by default &295d 84 31 STY &31 ; player_in_acid # Set to zero to indicate player not in acid by default &295f 84 79 STY &79 ; underwater # Set to zero to indicate player underwater by default &2961 84 32 STY &32 # Unclear &2963 20 a7 32 JSR &32a7 ; check_if_screen_address_is_outside_room # Returns carry set if outside room &2966 b0 c6 BCS &292e ; leave ; check_row_for_obstacle_loop &2968 b1 7c LDA (&7c),Y ; screen_address &296a f0 1d BEQ &2989 ; consider_next_column &296c c9 c0 CMP #&c0 ; 3300 &296e f0 15 BEQ &2985 ; is_water &2970 c9 0a CMP #&0a ; 1010 &2972 f0 27 BEQ &299b ; is_acid &2974 c9 05 CMP #&05 ; 0101 &2976 f0 23 BEQ &299b ; is_acid &2978 c9 44 CMP #&44 ; 0300 &297a d0 03 BNE &297f ; not_spikes ; is_spikes &297c 20 88 2b JSR &2b88 ; lose_energy # Lose energy for touching spikes ; not_spikes &297f a9 01 LDA #&01 &2981 85 0b STA &0b ; obstacle_present # Set to non-zero to indicate obstacle present &2983 38 SEC # Leave with carry set to indicate obstacle &2984 60 RTS ; is_water &2985 a9 01 LDA #&01 &2987 85 79 STA &79 ; underwater # Set to non-zero to indicate player is underwater ; consider_next_column &2989 98 TYA &298a 18 CLC &298b 69 08 ADC #&08 &298d a8 TAY &298e ca DEX &298f d0 d7 BNE &2968 ; check_row_for_obstacle_loop &2991 a5 31 LDA &31 ; player_in_acid # Non-zero if player in acid &2993 18 CLC # Leave with carry clear to indicate no obstacle &2994 f0 98 BEQ &292e ; leave ; is_in_acid &2996 20 88 2b JSR &2b88 ; lose_energy # Lose energy for touching acid &2999 18 CLC # Leave with carry clear to indicate no obstacle &299a 60 RTS ; is_acid &299b a9 01 LDA #&01 &299d 85 31 STA &31 ; player_in_acid # Set to non-zero to indicate player in acid &299f 4c 89 29 JMP &2989 ; consider_next_column ; leave_with_carry_set &29a2 38 SEC &29a3 60 RTS ; check_if_floor_suitable_for_object &29a4 20 99 28 JSR &2899 ; calculate_screen_address_below_player &29a7 a0 00 LDY #&00 # Check left of player &29a9 b1 7c LDA (&7c),Y ; screen_address &29ab c9 ff CMP #&ff ; 3333 # Don't allow object to be dropped on or beneath moving platforms &29ad f0 f3 BEQ &29a2 ; leave_with_carry_set # Leave with carry clear to indicate floor not suitable &29af a0 18 LDY #&18 # Check right of player &29b1 b1 7c LDA (&7c),Y ; screen_address &29b3 c9 ff CMP #&ff ; 3333 &29b5 f0 eb BEQ &29a2 ; leave_with_carry_set ; leave_with_carry_clear &29b7 18 CLC # Leave with carry clear to indicate floor suitable &29b8 60 RTS ; check_for_player_touching_subtiles &29b9 a9 11 LDA #&11 ; SUBTILE_CRYSTAL_RIGHT &29bb 20 4e 2a JSR &2a4e ; check_if_touching_subtile_type_A # Returns carry set if touching subtile &29be 90 03 BCC &29c3 ; not_collecting_crystal &29c0 20 53 24 JSR &2453 ; collect_crystal ; not_collecting_crystal &29c3 a9 25 LDA #&25 ; SUBTILE_PILLAR &29c5 20 4e 2a JSR &2a4e ; check_if_touching_subtile_type_A # Returns carry set if touching subtile &29c8 90 17 BCC &29e1 ; not_opening_door &29ca a5 a4 LDA &a4 ; door_key_subtile &29cc 20 81 2d JSR &2d81 ; consider_using_object # Returns carry set if object carried; removes object &29cf b0 0d BCS &29de ; has_key &29d1 a5 a4 LDA &a4 ; door_key_subtile &29d3 c9 28 CMP #&28 ; OBJECT_KEY_ONE &29d5 d0 0a BNE &29e1 ; not_opening_door &29d7 a9 2c LDA #&2c ; OBJECT_KEY_THREE # Key three opens door one &29d9 20 81 2d JSR &2d81 ; consider_using_object # Returns carry set if object carried; removes object &29dc 90 03 BCC &29e1 ; not_opening_door ; has_key &29de 20 a3 2d JSR &2da3 ; open_door ; not_opening_door &29e1 a9 06 LDA #&06 ; SUBTILE_TERMINAL_RIGHT &29e3 20 4e 2a JSR &2a4e ; check_if_touching_subtile_type_A # Returns carry set if touching subtile &29e6 90 06 BCC &29ee ; not_touching_terminal ; is_touching_terminal &29e8 20 4b 12 JSR &124b ; to_terminal_screen &29eb 20 89 2a JSR &2a89 ; plot_or_unplot_player # Plot player ; not_touching_terminal &29ee a9 16 LDA #&16 ; SUBTILE_SOLID &29f0 20 4e 2a JSR &2a4e ; check_if_touching_subtile_type_A # Returns carry set if touching subtile &29f3 90 1f BCC &2a14 ; not_touching_elephant &29f5 a5 4e LDA &4e ; room_feature &29f7 c9 20 CMP #&20 ; TILE_ELEPHANT_HOUSE_TEXT &29f9 d0 05 BNE &2a00 ; not_in_elephant_house ; is_in_elephant_house &29fb a9 36 LDA #&36 ; OBJECT_MOUSE # Mouse moves Elephant House elephant &29fd 4c 06 2a JMP &2a06 ; check_for_elephant_object ; not_in_elephant_house &2a00 c9 21 CMP #&21 ; TILE_JOKE_SHOP_TEXT &2a02 d0 10 BNE &2a14 ; not_touching_elephant &2a04 a9 34 LDA #&34 ; OBJECT_HERRING # (red) Herring moves Joke Shop (white) elephant ; check_for_elephant_object &2a06 20 81 2d JSR &2d81 ; consider_using_object &2a09 90 09 BCC &2a14 ; not_moving_elephant ; move_elephant &2a0b a9 11 LDA #&11 ; TILE_ELEPHANT &2a0d 20 75 31 JSR &3175 ; move_feature_two_tiles_to_right &2a10 a9 00 LDA #&00 &2a12 85 63 STA &63 ; suppress_fish_and_mice # Set to zero to allow fish and mice to appear again ; not_moving_elephant ; not_touching_elephant &2a14 a9 1a LDA #&1a ; SUBTILE_TUBE_CORNER_LEFT # Second tile in top row of snail &2a16 20 4e 2a JSR &2a4e ; check_if_touching_subtile_type_A # Returns carry set if touching subtile &2a19 90 19 BCC &2a34 ; not_touching_snail &2a1b a5 4e LDA &4e ; room_feature &2a1d c9 24 CMP #&24 ; TILE_HYDROPONICS_TEXT &2a1f d0 13 BNE &2a34 ; not_touching_snail ; is_in_hydroponics &2a21 20 88 2b JSR &2b88 ; lose_energy # Lose energy for touching snail &2a24 a5 a0 LDA &a0 ; bottle_contains_salt # Non-zero if bottle contains salt &2a26 f0 0c BEQ &2a34 ; not_moving_snail &2a28 a9 3e LDA #&3e ; OBJECT_BOTTLE # Bottle of salt moves slug &2a2a 20 81 2d JSR &2d81 ; consider_using_object &2a2d 90 05 BCC &2a34 ; not_moving_snail &2a2f a9 3c LDA #&3c ; TILE_SNAIL &2a31 20 75 31 JSR &3175 ; move_feature_two_tiles_to_right ; not_moving_snail ; not_touching_snail &2a34 60 RTS ; check_if_touching_pipe_top &2a35 18 CLC &2a36 a5 38 LDA &38 ; player_screen_address_low &2a38 29 f0 AND #&f0 &2a3a 69 95 ADC #&95 ; &0795 = &280 * 3 + &10 + 5 # Check bottom three rows of group below player's feet, middle of player &2a3c 85 7c STA &7c ; screen_address_low &2a3e a5 39 LDA &39 ; player_screen_address_high &2a40 69 07 ADC #&07 &2a42 85 7d STA &7d ; screen_address_high &2a44 a9 15 LDA #&15 ; SUBTILE_PIPE_TOP &2a46 20 4e 2a JSR &2a4e ; check_if_touching_subtile_type_A # Returns carry set if touching subtile &2a49 90 e9 BCC &2a34 ; leave &2a4b 4c 7b 33 JMP &337b ; handle_touching_pipe_top ; check_if_touching_subtile_type_A &2a4e 85 31 STA &31 ; subtile_sprite_offset_low &2a50 a9 00 LDA #&00 &2a52 85 32 STA &32 ; subtile_sprite_offset_high &2a54 a2 04 LDX #&04 ; calculate_subtile_sprite_offset_loop &2a56 06 31 ASL &31 ; subtile_sprite_offset_low &2a58 26 32 ROL &32 ; subtile_sprite_offset_high &2a5a ca DEX &2a5b d0 f9 BNE &2a56 ; calculate_subtile_sprite_offset_loop &2a5d 18 CLC &2a5e a9 05 LDA #&05 ; &0e05 = tile_sprite_data + 5 # Check bottom three rows of group &2a60 65 31 ADC &31 ; subtile_sprite_offset_low &2a62 85 7a STA &7a ; sprite_address_low &2a64 a9 0e LDA #&0e &2a66 65 32 ADC &32 ; subtile_sprite_offset_high &2a68 85 7b STA &7b ; sprite_address_high &2a6a a0 00 LDY #&00 ; check_if_touching_subtile_type_A_row_loop &2a6c a2 02 LDX #&02 ; check_if_touching_subtile_type_A_column_loop &2a6e b1 7c LDA (&7c),Y ; screen_address &2a70 d1 7a CMP (&7a),Y ; sprite_address &2a72 f0 02 BEQ &2a76 ; is_match ; not_match &2a74 18 CLC # Leave with carry clear to indicate not touching subtile &2a75 60 RTS ; is_match &2a76 98 TYA &2a77 18 CLC &2a78 69 08 ADC #&08 # Move right four pixels &2a7a a8 TAY &2a7b ca DEX &2a7c d0 f0 BNE &2a6e ; check_if_touching_subtile_type_A_column_loop &2a7e 98 TYA # Y = &10 if first pass, &12 if second pass &2a7f 38 SEC &2a80 e9 0e SBC #&0e ; &10 - 2 # Move down two rows of sprite data &2a82 a8 TAY # i.e. check last row of group for second pass &2a83 c0 02 CPY #&02 # Y = &02 if first pass, &04 if second pass &2a85 f0 e5 BEQ &2a6c ; check_if_touching_subtile_type_A_row_loop &2a87 38 SEC # Leave with carry set to indicate touching subtile &2a88 60 RTS ; plot_or_unplot_player &2a89 a2 18 LDX #&18 ; SPRITE_PLAYER_HEAD_RIGHT &2a8b a5 05 LDA &05 ; player_previous_facing # Negative if facing left, positive if facing right &2a8d 10 02 BPL &2a91 ; is_facing_right ; is_facing_left &2a8f a2 1a LDX #&1a ; SPRITE_PLAYER_HEAD_LEFT ; is_facing_right &2a91 a9 02 LDA #&02 &2a93 85 41 STA &41 ; sprite_height &2a95 a5 37 LDA &37 ; player_previous_screen_address_high &2a97 85 7d STA &7d ; screen_address_high &2a99 a5 36 LDA &36 ; player_previous_screen_address_low &2a9b 20 c5 32 JSR &32c5 ; plot_sprite # Plot player head &2a9e a2 1e LDX #&1e ; SPRITE_PLAYER_FEET_RIGHT_FRAME_TWO &2aa0 a5 05 LDA &05 ; player_previous_facing ; is_facing_left &2aa2 10 02 BPL &2aa6 ; is_facing_right &2aa4 a2 22 LDX #&22 ; SPRITE_PLAYER_FEET_LEFT_FRAME_TWO ; is_facing_right &2aa6 a5 14 LDA &14 ; player_previous_is_supported # Non-zero if player was supported &2aa8 f0 07 BEQ &2ab1 ; use_frame_two # Plot player with feet together if not supported &2aaa a5 16 LDA &16 ; player_previous_x &2aac 4a LSR A &2aad 90 02 BCC &2ab1 ; use_frame_one # Otherwise, animate them depending on x position ; use_frame_one &2aaf ca DEX &2ab0 ca DEX ; use_frame_two &2ab1 a9 01 LDA #&01 &2ab3 85 41 STA &41 ; sprite_height &2ab5 a5 7c LDA &7c ; screen_address_low &2ab7 4c c5 32 JMP &32c5 ; plot_sprite # Plot player feet ; store_previous_player_variables &2aba a5 38 LDA &38 ; player_screen_address_low &2abc 85 36 STA &36 ; player_previous_screen_address_low &2abe a5 39 LDA &39 ; player_screen_address_high &2ac0 85 37 STA &37 ; player_previous_screen_address_high &2ac2 a5 08 LDA &08 ; player_facing &2ac4 85 05 STA &05 ; player_previous_facing &2ac6 a5 15 LDA &15 ; player_is_supported &2ac8 85 14 STA &14 ; player_previous_is_supported &2aca a5 35 LDA &35 ; player_x &2acc 85 16 STA &16 ; player_previous_x ; leave &2ace 60 RTS ; move_right_a_room &2acf a9 00 LDA #&00 # Move player to left of room &2ad1 85 35 STA &35 ; player_x &2ad3 38 SEC &2ad4 a5 38 LDA &38 ; player_screen_address_low &2ad6 e9 60 SBC #&60 ; &260 # Move player to left of screen &2ad8 85 38 STA &38 ; player_screen_address_low &2ada a5 39 LDA &39 ; player_screen_address_high &2adc e9 02 SBC #&02 &2ade 85 39 STA &39 ; player_screen_address_high &2ae0 20 11 12 JSR &1211 ; move_right_a_room_and_plot_room &2ae3 4c 89 2a JMP &2a89 ; plot_or_unplot_player # Plot player ; move_left_a_room &2ae6 a9 4c LDA #&4c # Move player to right of room &2ae8 85 35 STA &35 ; player_x &2aea 18 CLC &2aeb a5 38 LDA &38 ; player_screen_address_low &2aed 69 60 ADC #&60 ; +&260 # Move player to right of screen &2aef 85 38 STA &38 ; player_screen_address_low &2af1 a5 39 LDA &39 ; player_screen_address_high &2af3 69 02 ADC #&02 &2af5 85 39 STA &39 ; player_screen_address_high &2af7 20 0c 12 JSR &120c ; move_left_a_room_and_plot_room &2afa 4c 89 2a JMP &2a89 ; plot_or_unplot_player # Plot player ; consider_moving_down_a_room &2afd 46 75 LSR &75 ; player_or_vertical_enemy # Zero if player, non-zero if vertical enemy &2aff b0 cd BCS &2ace ; leave # Always clear, never branches &2b01 20 24 2b JSR &2b24 ; calculate_player_column_offset &2b04 18 CLC &2b05 a5 38 LDA &38 ; player_screen_address_low &2b07 69 80 ADC #&80 ; &3c80 = screen_memory &2b09 85 38 STA &38 ; player_screen_address_low &2b0b a5 39 LDA &39 ; player_screen_address_high &2b0d 69 3c ADC #&3c &2b0f 85 39 STA &39 ; player_screen_address_high &2b11 a9 00 LDA #&00 # Move player to top of room &2b13 85 2c STA &2c ; player_y &2b15 20 09 12 JSR &1209 ; to_move_down_a_room &2b18 20 89 2a JSR &2a89 ; plot_or_unplot_player # Plot player &2b1b a5 8f LDA &8f ; player_room_y &2b1d c9 08 CMP #&08 &2b1f d0 ad BNE &2ace ; leave &2b21 4c d4 2d JMP &2dd4 ; initialise_crossing_enemies # Initialise ghosts when player moves down into room_y = 8 ; calculate_player_column_offset &2b24 a5 35 LDA &35 ; player_x &2b26 85 38 STA &38 ; player_screen_address_low &2b28 a9 00 LDA #&00 &2b2a 85 39 STA &39 ; player_screen_address_high &2b2c a2 03 LDX #&03 ; calculate_player_column_offset_loop # Calculate player_x * 8 &2b2e 06 38 ASL &38 ; player_screen_address_low &2b30 26 39 ROL &39 ; player_screen_address_high &2b32 ca DEX &2b33 d0 f9 BNE &2b2e ; calculate_player_column_offset_loop ; leave_with_carry_clear &2b35 18 CLC &2b36 60 RTS ; consider_moving_up_a_room &2b37 46 75 LSR &75 ; player_or_vertical_enemy # Zero if player, non-zero if vertical enemy &2b39 b0 fa BCS &2b35 ; leave_with_carry_clear # Always clear, never branches &2b3b 20 24 2b JSR &2b24 ; calculate_player_column_offset &2b3e a9 d0 LDA #&d0 &2b40 85 2c STA &2c ; player_y # Move player to bottom of room &2b42 18 CLC &2b43 a5 38 LDA &38 ; player_screen_address_low &2b45 69 80 ADC #&80 ; &7d80 = &8000 - &280, i.e. bottom group of screen &2b47 85 38 STA &38 ; player_screen_address_low &2b49 a5 39 LDA &39 ; player_screen_address_high &2b4b 69 7d ADC #&7d &2b4d 85 39 STA &39 ; player_screen_address_high &2b4f 20 03 12 JSR &1203 ; to_move_up_a_room &2b52 e6 0e INC &0e ; player_y_velocity # Accelerate slightly upwards &2b54 4c 89 2a JMP &2a89 ; plot_or_unplot_player # Plot player ; lose_energy_if_touching_enemy &2b57 a5 6c LDA &6c ; double_sprite # Non-zero if sprite doubled vertically &2b59 f0 0b BEQ &2b66 ; not_doubled ; is_doubled &2b5b a9 17 LDA #&17 &2b5d 85 41 STA &41 ; sprite_height &2b5f 18 CLC &2b60 a5 3c LDA &3c ; sprite_y &2b62 69 06 ADC #&06 &2b64 85 3c STA &3c ; sprite_y ; not_doubled &2b66 18 CLC &2b67 a5 35 LDA &35 ; player_x &2b69 69 03 ADC #&03 &2b6b c5 11 CMP &11 ; sprite_x &2b6d 30 c6 BMI &2b35 ; leave_with_carry_clear # Leave with carry clear to indicate not touching &2b6f 18 CLC &2b70 a5 11 LDA &11 ; sprite_x &2b72 69 03 ADC #&03 &2b74 c5 35 CMP &35 ; player_x &2b76 30 bd BMI &2b35 ; leave_with_carry_clear # Leave with carry clear to indicate not touching &2b78 a5 2c LDA &2c ; player_y &2b7a 4a LSR A &2b7b c5 3c CMP &3c ; sprite_y &2b7d 10 b6 BPL &2b35 ; leave_with_carry_clear # Leave with carry clear to indicate not touching &2b7f a5 2c LDA &2c ; player_y &2b81 4a LSR A &2b82 65 41 ADC &41 ; sprite_height &2b84 c5 3c CMP &3c ; sprite_y &2b86 30 ad BMI &2b35 ; leave_with_carry_clear # Leave with carry clear to indicate not touching ; lose_energy &2b88 a9 06 LDA #&06 &2b8a 85 88 STA &88 ; suppress_jumping_and_dropping # Set to non-zero to stop player jumping or dropping objects while losing energy &2b8c 20 4c 33 JSR &334c ; play_sound_on_channel_zero # Play sound for losing energy ; lose_energy_without_sound &2b8f c6 3b DEC &3b ; player_energy &2b91 d0 04 BNE &2b97 ; not_out_of_energy &2b93 a9 01 LDA #&01 # Set to positive non-zero to indicate player dead &2b95 85 62 STA &62 ; player_state ; not_out_of_energy &2b97 20 30 26 JSR &2630 ; plot_energy_section &2b9a 38 SEC # Leave with carry set to indicate touching &2b9b 60 RTS ; leave_with_carry_clear &2b9c 18 CLC # Leave with carry clear to indicate not near player &2b9d 60 RTS ; check_if_near_player_fixed_distance &2b9e a9 08 LDA #&08 &2ba0 85 31 STA &31 ; width_to_check &2ba2 a9 0a LDA #&0a &2ba4 85 32 STA &32 ; height_to_check_at_top &2ba6 a9 19 LDA #&19 &2ba8 85 33 STA &33 ; height_to_check_at_bottom ; check_if_near_player_variable_distance &2baa 18 CLC &2bab a5 35 LDA &35 ; player_x &2bad 65 31 ADC &31 ; width_to_check &2baf c5 11 CMP &11 ; sprite_x &2bb1 30 e9 BMI &2b9c ; leave_with_carry_clear &2bb3 a5 11 LDA &11 ; sprite_x &2bb5 65 31 ADC &31 ; width_to_check &2bb7 c5 35 CMP &35 ; player_x &2bb9 30 e1 BMI &2b9c ; leave_with_carry_clear &2bbb a5 2c LDA &2c ; player_y &2bbd 4a LSR A &2bbe 38 SEC &2bbf e5 32 SBC &32 ; height_to_check_at_top &2bc1 c5 3c CMP &3c ; sprite_y &2bc3 10 d7 BPL &2b9c ; leave_with_carry_clear &2bc5 a5 2c LDA &2c ; player_y &2bc7 4a LSR A &2bc8 65 33 ADC &33 ; height_to_check_at_bottom &2bca c5 3c CMP &3c ; sprite_y &2bcc 30 ce BMI &2b9c ; leave_with_carry_clear &2bce 38 SEC &2bcf a5 11 LDA &11 ; sprite_x &2bd1 e5 35 SBC &35 ; player_x &2bd3 10 0b BPL &2be0 ; is_right_of_player ; is_left_of_player &2bd5 a9 01 LDA #&01 &2bd7 85 31 STA &31 ; homing_x_velocity # Towards player &2bd9 a9 ff LDA #&ff &2bdb 85 33 STA &33 ; avoiding_x_velocity # Away from player &2bdd 4c e8 2b JMP &2be8 ; check_y ; is_right_of_player &2be0 a9 ff LDA #&ff &2be2 85 31 STA &31 ; homing_x_velocity # Towards player &2be4 a9 01 LDA #&01 &2be6 85 33 STA &33 ; avoiding_x_velocity # Away from player ; check_y &2be8 18 CLC &2be9 a5 2c LDA &2c ; player_y &2beb 69 14 ADC #&14 &2bed 38 SEC &2bee 4a LSR A &2bef e5 3c SBC &3c ; sprite_y &2bf1 10 06 BPL &2bf9 ; is_above_player ; is_below_player &2bf3 a9 fe LDA #&fe ; set_homing_y_velocity &2bf5 85 32 STA &32 ; homing_y_velocity &2bf7 38 SEC # Leave with carry set to indicate near player &2bf8 60 RTS ; is_above_player &2bf9 a9 02 LDA #&02 &2bfb 4c f5 2b JMP &2bf5 ; set_homing_y_velocity ; calculate_screen_address_for_pick_up &2bfe 18 CLC &2bff a5 38 LDA &38 ; player_screen_address_low &2c01 29 f8 AND #&f8 &2c03 69 85 ADC #&85 ; &785 = &280 * 3 + 5 # Bottom three rows of group below left of player's feet &2c05 85 7c STA &7c ; screen_address_low &2c07 a5 39 LDA &39 ; player_screen_address_high &2c09 69 07 ADC #&07 &2c0b 85 7d STA &7d ; screen_address_high &2c0d 60 RTS ; consider_picking_up_object &2c0e a9 c8 LDA #&c8 &2c10 8d a4 32 STA &32a4 ; sound_block + 4 (pitch) &2c13 20 fe 2b JSR &2bfe ; calculate_screen_address_for_pick_up &2c16 a9 28 LDA #&28 ; SUBTILE_KEY_ONE # First object &2c18 85 03 STA &03 ; object ; check_if_touching_object_loop &2c1a 20 4e 2a JSR &2a4e ; check_if_touching_subtile_type_A # Returns carry set if touching subtile &2c1d b0 0b BCS &2c2a ; is_touching_object &2c1f e6 03 INC &03 ; object &2c21 e6 03 INC &03 ; object &2c23 a5 03 LDA &03 ; object &2c25 c9 40 CMP #&40 ; SUBTILE_BOTTLE + 2 # Last object &2c27 d0 f1 BNE &2c1a ; check_if_touching_object_loop &2c29 60 RTS ; is_touching_object &2c2a a5 03 LDA &03 ; object &2c2c 48 PHA ; object &2c2d a2 38 LDX #&38 ; OBJECT_CHEESE # If the player is carrying the right food, &2c2f c9 36 CMP #&36 ; SUBTILE_MOUSE # Check if player is collecting horizontal enemy &2c31 f0 06 BEQ &2c39 ; set_suppress_fish_and_mice &2c33 c9 34 CMP #&34 ; SUBTILE_HERRING &2c35 d0 16 BNE &2c4d ; skip_removing_horizontal_enemies &2c37 a2 30 LDX #&30 ; OBJECT_WORM ; remove_fish_or_mice &2c39 8a TXA &2c3a 85 63 STA &63 ; suppress_fish_and_mice # Set to non-zero to prevent fish and mice appearing &2c3c 20 81 2d JSR &2d81 ; consider_using_object # Removes object from pocket &2c3f ad 25 12 LDA &1225 ; horizontal_enemies_type &2c42 f0 09 BEQ &2c4d ; skip_removing_horizontal_enemies # Branch if HORIZONTAL_ENEMY_TYPE_CATERPILLAR (0) &2c44 c9 03 CMP #&03 ; HORIZONTAL_ENEMY_TYPE_PLATFORM &2c46 f0 05 BEQ &2c4d ; skip_removing_horizontal_enemies ; is_fish_or_mice &2c48 a9 00 LDA #&00 &2c4a 8d 20 12 STA &1220 ; room_has_horizontal_enemies # Set to zero to indicate no horizontal enemies ; skip_removing_horizontal_enemies &2c4d 68 PLA ; object &2c4e 85 03 STA &03 ; object &2c50 a2 01 LDX #&01 ; find_empty_pocket_loop &2c52 b5 0c LDA &0c,X ; player_pockets &2c54 f0 04 BEQ &2c5a ; found_empty_pocket &2c56 ca DEX &2c57 10 f9 BPL &2c52 ; find_empty_pocket_loop &2c59 60 RTS ; found_empty_pocket &2c5a a5 03 LDA &03 ; object &2c5c 95 0c STA &0c,X ; player_pockets &2c5e 20 d8 2c JSR &2cd8 ; calculate_object_offset &2c61 a9 ff LDA #&ff &2c63 a2 04 LDX #&04 ; wipe_object_data_loop &2c65 99 00 09 STA &0900,Y ; object_data # Set to &ff to remove object from room &2c68 c8 INY &2c69 ca DEX &2c6a d0 f9 BNE &2c65 ; wipe_object_data_loop &2c6c a5 03 LDA &03 ; object ; plot_object &2c6e 85 7a STA &7a ; sprite_address_low &2c70 a9 00 LDA #&00 ; &500 = &280 * 2 &2c72 85 7b STA &7b ; sprite_address_high &2c74 20 fe 2b JSR &2bfe ; calculate_screen_address_for_pick_up &2c77 a5 7c LDA &7c ; screen_address_low &2c79 38 SEC &2c7a e9 05 SBC #&05 &2c7c 85 7c STA &7c ; screen_address_low &2c7e a2 04 LDX #&04 ; calculate_object_sprite_address_loop &2c80 06 7a ASL &7a ; sprite_address_low &2c82 26 7b ROL &7b ; sprite_address_high &2c84 ca DEX &2c85 d0 f9 BNE &2c80 ; calculate_object_sprite_address_loop &2c87 18 CLC &2c88 a5 7b LDA &7b ; sprite_address_high &2c8a 69 0e ADC #&0e ; &0e00 = tile_sprite_data &2c8c 85 7b STA &7b ; sprite_address_high &2c8e a9 01 LDA #&01 &2c90 85 41 STA &41 ; sprite_height &2c92 a5 7c LDA &7c ; screen_address_low &2c94 20 d1 32 JSR &32d1 ; plot_sprite_using_address &2c97 a9 05 LDA #&05 &2c99 8d a6 32 STA &32a6 ; sound_block + 6 (duration) &2c9c a9 01 LDA #&01 &2c9e 20 33 33 JSR &3333 ; play_sound_on_channel_two # Play sound for picking up or dropping object ; plot_carried_objects &2ca1 98 TYA &2ca2 48 PHA ; tmp_y &2ca3 a9 30 LDA #&30 ; &3e30 &2ca5 85 7c STA &7c ; screen_address_low &2ca7 a2 01 LDX #&01 &2ca9 86 03 STX &03 ; pocket &2cab a0 14 LDY #&14 ; x position of text ; plot_carried_objects_loop &2cad b5 0c LDA &0c,X ; player_pockets &2caf a2 04 LDX #&04 ; y position of text &2cb1 20 bb 34 JSR &34bb ; write_object_name &2cb4 a9 3e LDA #&3e &2cb6 85 7d STA &7d ; screen_address_high &2cb8 a6 03 LDX &03 ; pocket &2cba b5 0c LDA &0c,X ; player_pockets &2cbc f0 20 BEQ &2cde ; plot_empty_pocket ; plot_occupied_pocket &2cbe 20 26 12 JSR &1226 ; to_plot_subtile &2cc1 a8 TAY &2cc2 c8 INY &2cc3 98 TYA &2cc4 20 26 12 JSR &1226 ; to_plot_subtile ; consider_next_pocket &2cc7 a0 1e LDY #&1e ; x position of text &2cc9 a9 d0 LDA #&d0 ; &3ed0 &2ccb 85 7c STA &7c ; screen_address_low &2ccd c6 03 DEC &03 ; pocket &2ccf a6 03 LDX &03 ; pocket &2cd1 10 da BPL &2cad ; plot_carried_objects_loop &2cd3 68 PLA ; tmp_y &2cd4 a8 TAY ; to_plot_bar_across_top_of_status_section &2cd5 4c eb 31 JMP &31eb ; plot_bar_across_top_of_status_section ; calculate_object_offset &2cd8 38 SEC &2cd9 e9 28 SBC #&28 ; OBJECT_KEY_ONE # First object &2cdb 0a ASL A &2cdc a8 TAY &2cdd 60 RTS # Leave with Y = offset to object in objects_data ; plot_empty_pocket &2cde a2 01 LDX #&01 &2ce0 20 96 24 JSR &2496 ; plot_X_rows_of_two_empty_subtiles &2ce3 4c c7 2c JMP &2cc7 ; consider_next_pocket ; consider_dropping_object &2ce6 a5 88 LDA &88 ; suppress_jumping_and_dropping # Non-zero if player is on platform or being drained &2ce8 d0 eb BNE &2cd5 ; to_plot_bar_across_top_of_status_section # Can't drop object if on platform or being drained &2cea a9 32 LDA #&32 &2cec 8d a4 32 STA &32a4 ; sound_block + 4 (pitch) &2cef 20 93 28 JSR &2893 ; check_row_below_player_for_obstacle &2cf2 a5 0b LDA &0b ; obstacle_present # Non-zero if obstacle present &2cf4 f0 df BEQ &2cd5 ; to_plot_bar_across_top_of_status_section # Can't drop object if no floor beneath &2cf6 20 a4 29 JSR &29a4 ; check_if_floor_suitable_for_object # Returns carry set if floor not suitable &2cf9 b0 da BCS &2cd5 ; to_plot_bar_across_top_of_status_section # Can't drop object if no suitable floor beneath &2cfb a5 2c LDA &2c ; player_y &2cfd 4a LSR A &2cfe c9 09 CMP #&09 &2d00 30 d3 BMI &2cd5 ; to_plot_bar_across_top_of_status_section # Can't drop object if crossing top of room &2d02 a2 01 LDX #&01 ; find_object_to_drop_loop &2d04 b5 0c LDA &0c,X ; player_pockets # Non-zero if pocket contains object &2d06 d0 04 BNE &2d0c ; found_object_to_drop &2d08 ca DEX &2d09 10 f9 BPL &2d04 ; find_object_to_drop_loop &2d0b 60 RTS ; found_object_to_drop &2d0c 85 34 STA &34 ; object_to_drop &2d0e 8a TXA &2d0f 48 PHA ; pocket offset &2d10 a9 0c LDA #&0c &2d12 85 0e STA &0e ; player_y_velocity &2d14 20 a7 28 JSR &28a7 ; update_rising_player # Move player up to make space for object beneath &2d17 a9 00 LDA #&00 &2d19 85 0e STA &0e ; player_y_velocity &2d1b 68 PLA ; pocket offset &2d1c aa TAX &2d1d a5 0b LDA &0b ; obstacle_present &2d1f d0 b4 BNE &2cd5 ; to_plot_bar_across_top_of_status_section # Can't drop object if not enough space beneath &2d21 a9 00 LDA #&00 ; OBJECT_NONE &2d23 95 0c STA &0c,X ; player_pockets &2d25 a5 34 LDA &34 ; object_to_drop &2d27 48 PHA ; object_to_drop &2d28 c9 3a CMP #&3a ; OBJECT_CROSS &2d2a f0 2c BEQ &2d58 ; consider_opening_altar &2d2c c9 3e CMP #&3e ; OBJECT_BOTTLE &2d2e f0 40 BEQ &2d70 ; consider_filling_bottle_with_salt ; drop_object &2d30 68 PLA ; object_to_drop &2d31 48 PHA ; object_to_drop &2d32 20 d8 2c JSR &2cd8 ; calculate_object_offset &2d35 a5 8f LDA &8f ; player_room_y &2d37 99 00 09 STA &0900,Y ; object_data # Store object location &2d3a c8 INY ; +1 &2d3b a5 90 LDA &90 ; player_room_x &2d3d 99 00 09 STA &0900,Y ; object_data &2d40 c8 INY ; +2 &2d41 a5 2c LDA &2c ; player_y &2d43 4a LSR A &2d44 4a LSR A &2d45 4a LSR A &2d46 18 CLC &2d47 69 04 ADC #&04 &2d49 99 00 09 STA &0900,Y ; object_data &2d4c c8 INY ; +3 &2d4d a5 35 LDA &35 ; player_x &2d4f 99 00 09 STA &0900,Y ; object_data &2d52 68 PLA ; object_to_drop &2d53 20 6e 2c JSR &2c6e ; plot_object &2d56 18 CLC # Unnecessary code &2d57 60 RTS ; consider_opening_altar &2d58 a5 4e LDA &4e ; room_feature &2d5a c9 2c CMP #&2c ; TILE_CHAPEL_TEXT &2d5c d0 d2 BNE &2d30 ; drop_object &2d5e a5 2c LDA &2c ; player_y &2d60 c9 80 CMP #&80 &2d62 d0 cc BNE &2d30 ; drop_object # Is the player on the altar in the Chapel? ; has_dropped_cross_on_altar_in_chapel &2d64 a9 09 LDA #&09 &2d66 85 78 STA &78 ; game_event_timer &2d68 a9 04 LDA #&04 ; EVENT_MOVING_FEATURE &2d6a 8d 42 12 STA &1242 ; game_event # IF so, start opening altar &2d6d 4c 30 2d JMP &2d30 ; drop_object ; consider_filling_bottle_with_salt &2d70 a5 4e LDA &4e ; room_feature &2d72 c9 25 CMP #&25 ; TILE_HCL_TEXT &2d74 d0 ba BNE &2d30 ; drop_object # Is the player in room (5, 3), with the HCl and NaOH vats? &2d76 a5 9f LDA &9f ; player_underwater_breath_timer # Non-zero if player in water &2d78 f0 b6 BEQ &2d30 ; drop_object ; is_in_salty_water &2d7a a9 01 LDA #&01 &2d7c 85 a0 STA &a0 ; bottle_contains_salt # Set to non-zero to indicate bottle contains salt &2d7e 4c 30 2d JMP &2d30 ; drop_object ; consider_using_object # Called with A = object &2d81 a2 01 LDX #&01 ; consider_using_object_loop &2d83 d5 0c CMP &0c,X ; player_pockets &2d85 f0 05 BEQ &2d8c ; use_object &2d87 ca DEX &2d88 10 f9 BPL &2d83 ; consider_using_object_loop &2d8a 18 CLC # Leave with carry clear to indicate object not used &2d8b 60 RTS ; use_object &2d8c a9 00 LDA #&00 ; OBJECT_NONE &2d8e 95 0c STA &0c,X ; player_pockets # Remove object from pocket &2d90 20 a1 2c JSR &2ca1 ; plot_carried_objects &2d93 20 d2 24 JSR &24d2 ; gain_energy # Gain energy for using object &2d96 38 SEC # Leave with carry set to indicate object used &2d97 60 RTS ; close_door &2d98 a0 25 LDY #&25 ; SUBTILE_PILLAR &2d9a 84 34 STY &34 ; subtile_to_plot &2d9c 84 a4 STY &a4 ; door_key_subtile # Not a key, so door can't be opened &2d9e a9 14 LDA #&14 ; TILE_CLOSED_DOOR &2da0 4c a9 2d JMP &2da9 ; update_door ; open_door &2da3 a0 00 LDY #&00 ; SUBTILE_BLANK &2da5 84 34 STY &34 ; subtile_to_plot &2da7 a9 0c LDA #&0c ; TILE_OPEN_DOOR ; update_door &2da9 20 4e 24 JSR &244e ; set_feature_tile &2dac a9 00 LDA #&00 &2dae 8d 42 12 STA &1242 ; game_event # Set to zero to indicate event has finished &2db1 18 CLC &2db2 ad 43 12 LDA &1243 ; feature_screen_address_low &2db5 69 30 ADC #&30 ; 3 * &10 # Move to third subtile from left, i.e. pillar of door &2db7 85 7c STA &7c ; screen_address_low &2db9 ad 44 12 LDA &1244 ; feature_screen_address_high &2dbc 69 00 ADC #&00 &2dbe 85 7d STA &7d ; screen_address_high &2dc0 a2 04 LDX #&04 &2dc2 20 9a 24 JSR &249a ; plot_X_rows_of_two_subtiles # Plot or unplot pillar of door &2dc5 a9 0a LDA #&0a &2dc7 8d a6 32 STA &32a6 ; sound_block + 6 (duration) &2dca a9 64 LDA #&64 &2dcc 8d a4 32 STA &32a4 ; sound_block + 4 (pitch) &2dcf a9 01 LDA #&01 &2dd1 4c 33 33 JMP &3333 ; play_sound_on_channel_two # Play sound for door opening or closing ; initialise_crossing_enemies &2dd4 a5 8f LDA &8f ; player_room_y &2dd6 0a ASL A &2dd7 65 8f ADC &8f ; player_room_y &2dd9 a8 TAY ; player_room_y * 3 &2dda a9 01 LDA #&01 &2ddc 8d 2c 22 STA &222c ; crossing_enemies_x_velocity + 0 &2ddf a9 ff LDA #&ff &2de1 8d 2e 22 STA &222e ; crossing_enemies_x_velocity + 2 &2de4 a9 01 LDA #&01 &2de6 a2 03 LDX #&03 ; initialise_crossing_enemies_cooldown_loop &2de8 95 80 STA &80,X ; crossing_enemies_cooldown &2dea ca DEX &2deb 10 fb BPL &2de8 ; initialise_crossing_enemies_cooldown_loop &2ded b9 78 0a LDA &0a78,Y ; crossing_enemies_limits_and_y_table # First byte &2df0 29 07 AND #&07 # .....421 minimum room x &2df2 85 84 STA &84 ; whirligig_minimum_room_x &2df4 8d 2b 22 STA &222b ; crossing_enemies_room_x + 0 &2df7 b9 78 0a LDA &0a78,Y ; crossing_enemies_limits_and_y_table # Second byte &2dfa 4a LSR A # 84218... -> .84218.. minimum screen x &2dfb 29 fc AND #&fc &2dfd 85 86 STA &86 ; whirligig_minimum_screen_x &2dff 8d 2f 22 STA &222f ; crossing_enemies_x + 0 &2e02 8d 31 22 STA &2231 ; crossing_enemies_x + 2 &2e05 85 0b STA &0b ; screen_x &2e07 c8 INY ; +1 &2e08 b9 78 0a LDA &0a78,Y ; crossing_enemies_limits_and_y_table # Second byte &2e0b 29 07 AND #&07 # .....421 maximum room x &2e0d 85 85 STA &85 ; whirligig_maximum_room_x &2e0f 8d 2d 22 STA &222d ; crossing_enemies_room_x + 2 &2e12 b9 78 0a LDA &0a78,Y ; crossing_enemies_limits_and_y_table # Second byte &2e15 4a LSR A # 84218... -> .84218.. maximum screen x &2e16 29 fc AND #&fc &2e18 85 87 STA &87 ; whirligig_maximum_screen_x &2e1a c8 INY ; +2 &2e1b b9 78 0a LDA &0a78,Y ; crossing_enemies_limits_and_y_table # Third byte &2e1e 29 3f AND #&3f # ..218421 screen y &2e20 85 0a STA &0a ; screen_y &2e22 0a ASL A &2e23 0a ASL A &2e24 0a ASL A &2e25 38 SEC &2e26 e9 08 SBC #&08 &2e28 8d 30 22 STA &2230 ; crossing_enemies_y + 0 &2e2b 8d 32 22 STA &2232 ; crossing_enemies_y + 2 &2e2e 20 00 12 JSR &1200 ; to_calculate_screen_address &2e31 a5 7c LDA &7c ; screen_address_low &2e33 85 99 STA &99 ; crossing_enemies_screen_address_low + 0 &2e35 85 9b STA &9b ; crossing_enemies_screen_address_low + 2 &2e37 a5 7d LDA &7d ; screen_address_high &2e39 85 9a STA &9a ; crossing_enemies_screen_address_high + 0 &2e3b 85 9c STA &9c ; crossing_enemies_screen_address_high + 2 &2e3d a5 8f LDA &8f ; player_room_y &2e3f 85 8a STA &8a ; crossing_enemies_room_y + 0 &2e41 85 8c STA &8c ; crossing_enemies_room_y + 2 &2e43 60 RTS ; update_whirligigs_or_ghosts &2e44 a2 00 LDX #&00 ; update_whirligigs_or_ghosts_loop &2e46 a5 8f LDA &8f ; player_room_y &2e48 c9 08 CMP #&08 &2e4a 30 03 BMI &2e4f ; update_whirligigs &2e4c 4c 09 30 JMP &3009 ; update_ghosts # Ghosts in rooms (x, 8) and (x, 9) ; update_whirligigs &2e4f a9 01 LDA #&01 &2e51 85 6c STA &6c ; double_sprite # Set to non-zero to indicate sprite doubled vertically &2e53 a5 61 LDA &61 ; plotting_or_updating_enemies # Zero if plotting, non-zero if updating &2e55 f0 0b BEQ &2e62 ; skip_unplotting_whirligig &2e57 20 aa 2e JSR &2eaa ; plot_or_unplot_whirligig # Unplot whirligig &2e5a d6 80 DEC &80,X ; crossing_enemies_cooldown # Non-zero if whirligig has been stunned &2e5c d0 0f BNE &2e6d ; skip_moving_whirligig &2e5e a9 01 LDA #&01 &2e60 95 80 STA &80,X ; crossing_enemies_cooldown ; skip_unplotting_whirligig &2e62 20 ee 2e JSR &2eee ; check_if_whirligig_at_minimum_or_maximum_x &2e65 20 7c 2e JSR &2e7c ; check_if_whirligig_touching_player # Returns carry set if touching player &2e68 b0 03 BCS &2e6d ; skip_moving_whirligig &2e6a 20 12 2f JSR &2f12 ; move_whirligig_or_ghost ; skip_moving_whirligig &2e6d 20 aa 2e JSR &2eaa ; plot_or_unplot_whirligig # Plot whirligig &2e70 e8 INX # Move to next whirligig &2e71 e8 INX &2e72 e0 04 CPX #&04 &2e74 d0 d0 BNE &2e46 ; update_whirligigs_or_ghosts_loop &2e76 a9 00 LDA #&00 &2e78 85 6c STA &6c ; double_sprite # Set to zero to indicate sprite not doubled vertically ; leave_with_carry_clear &2e7a 18 CLC &2e7b 60 RTS ; check_if_whirligig_touching_player &2e7c 20 dd 2e JSR &2edd ; check_if_crossing_enemy_in_player_room # Returns carry set if in player room &2e7f 90 f9 BCC &2e7a ; leave_with_carry_clear # Leave with carry clear to indicate not touching player &2e81 bd 2f 22 LDA &222f,X ; crossing_enemies_x &2e84 85 11 STA &11 ; sprite_x &2e86 bd 30 22 LDA &2230,X ; crossing_enemies_y &2e89 18 CLC &2e8a 69 08 ADC #&08 &2e8c 4a LSR A &2e8d 85 3c STA &3c ; sprite_y &2e8f 4c 57 2b JMP &2b57 ; lose_energy_if_touching_enemy # Leave with carry set if touching player ; plot_or_unplot_ghost &2e92 8a TXA &2e93 48 PHA ; crossing enemy slot &2e94 48 PHA ; crossing enemy slot &2e95 bd 2c 22 LDA &222c,X ; crossing_enemies_x_velocity &2e98 a2 14 LDX #&14 ; SPRITE_GHOST_RIGHT &2e9a c9 00 CMP #&00 &2e9c 10 02 BPL &2ea0 ; set_ghost_sprite &2e9e a2 16 LDX #&16 ; SPRITE_GHOST_LEFT ; set_ghost_sprite &2ea0 86 31 STX &31 ; crossing_enemy_sprite &2ea2 a9 03 LDA #&03 ; sprite_height &2ea4 4c bc 2e JMP &2ebc ; plot_or_unplot_crossing_enemy ; leave_after_restoring_x &2ea7 68 PLA ; crossing enemy slot &2ea8 aa TAX &2ea9 60 RTS ; plot_or_unplot_whirligig &2eaa bd 2f 22 LDA &222f,X ; crossing_enemies_x &2ead 4a LSR A &2eae 4a LSR A &2eaf 8a TXA &2eb0 48 PHA ; crossing enemy slot &2eb1 48 PHA ; crossing enemy slot &2eb2 a2 10 LDX #&10 ; SPRITE_WHIRLIGIG_FRAME_ONE &2eb4 90 02 BCC &2eb8 ; set_whirligig_sprite # Animate whirligigs based on x position &2eb6 a2 12 LDX #&12 ; SPRITE_WHIRLIGIG_FRAME_TWO ; set_whirligig_sprite &2eb8 86 31 STX &31 ; crossing_enemy_sprite &2eba a9 02 LDA #&02 ; plot_or_unplot_crossing_enemy &2ebc 85 41 STA &41 ; sprite_height &2ebe 68 PLA ; crossing enemy slot &2ebf aa TAX &2ec0 20 dd 2e JSR &2edd ; check_if_crossing_enemy_in_player_room # Returns carry set if in player room &2ec3 90 e2 BCC &2ea7 ; leave_after_restoring_x &2ec5 b5 9a LDA &9a,X ; crossing_enemies_screen_address_high &2ec7 85 7d STA &7d ; screen_address_high &2ec9 b5 99 LDA &99,X ; crossing_enemies_screen_address_low &2ecb 48 PHA ; crossing_enemy screen_address_low &2ecc a5 74 LDA &74 ; enemies_are_stunned # Non-zero if enemies are stunned &2ece f0 04 BEQ &2ed4 ; not_stunned ; is_stunned &2ed0 a9 00 LDA #&00 &2ed2 95 80 STA &80,X ; crossing_enemies_cooldown # Stun whirligigs and exorcise ghosts ; not_stunned &2ed4 68 PLA ; crossing_enemy screen_address_low &2ed5 a6 31 LDX &31 ; crossing_enemy_sprite &2ed7 20 c5 32 JSR &32c5 ; plot_sprite &2eda 68 PLA ; crossing enemy slot &2edb aa TAX &2edc 60 RTS ; check_if_crossing_enemy_in_player_room &2edd bd 2b 22 LDA &222b,X ; crossing_enemies_room_x &2ee0 c5 90 CMP &90 ; player_room_x &2ee2 d0 08 BNE &2eec ; leave_with_carry_clear &2ee4 b5 8a LDA &8a,X ; crossing_enemies_room_y &2ee6 c5 8f CMP &8f ; player_room_y &2ee8 d0 02 BNE &2eec ; leave_with_carry_clear ; leave_with_carry_set &2eea 38 SEC # Leave with carry set to indicate whirligig in player room ; leave &2eeb 60 RTS ; leave_with_carry_clear &2eec 18 CLC # Leave with carry clear to indicate whirligig not in player room &2eed 60 RTS ; check_if_whirligig_at_minimum_or_maximum_x &2eee bd 2b 22 LDA &222b,X ; crossing_enemies_room_x &2ef1 c5 84 CMP &84 ; whirligig_minimum_room_x &2ef3 d0 0d BNE &2f02 ; not_at_minimum_x &2ef5 bd 2f 22 LDA &222f,X ; crossing_enemies_x &2ef8 c5 86 CMP &86 ; whirligig_minimum_screen_x &2efa 10 ef BPL &2eeb ; leave ; set_whirligig_moving_right &2efc a9 01 LDA #&01 ; set_direction &2efe 9d 2c 22 STA &222c,X ; crossing_enemies_x_velocity &2f01 60 RTS ; not_at_minimum_x &2f02 c5 85 CMP &85 ; whirligig_maximum_room_x &2f04 d0 e5 BNE &2eeb ; leave &2f06 bd 2f 22 LDA &222f,X ; crossing_enemies_x &2f09 c5 87 CMP &87 ; whirligig_maximum_screen_x &2f0b 30 de BMI &2eeb ; leave ; set_whirligig_moving_left &2f0d a9 ff LDA #&ff &2f0f 4c fe 2e JMP &2efe ; set_direction ; move_whirligig_or_ghost &2f12 bd 2f 22 LDA &222f,X ; crossing_enemies_x &2f15 18 CLC &2f16 7d 2c 22 ADC &222c,X ; crossing_enemies_x_velocity &2f19 9d 2f 22 STA &222f,X ; crossing_enemies_x &2f1c bd 2c 22 LDA &222c,X ; crossing_enemies_x_velocity &2f1f c9 ff CMP #&ff &2f21 f0 15 BEQ &2f38 ; is_moving_left ; is_moving_right &2f23 bd 2f 22 LDA &222f,X ; crossing_enemies_x &2f26 c9 4d CMP #&4d &2f28 10 21 BPL &2f4b ; is_at_right_edge_of_room &2f2a 18 CLC &2f2b b5 99 LDA &99,X ; crossing_enemies_screen_address_low &2f2d 69 08 ADC #&08 # Move right four pixels &2f2f 95 99 STA &99,X ; crossing_enemies_screen_address_low &2f31 b5 9a LDA &9a,X ; crossing_enemies_screen_address_high &2f33 69 00 ADC #&00 &2f35 95 9a STA &9a,X ; crossing_enemies_screen_address_high &2f37 60 RTS ; is_moving_left &2f38 bd 2f 22 LDA &222f,X ; crossing_enemies_x &2f3b 30 31 BMI &2f6e ; is_at_left_edge_of_room &2f3d 38 SEC &2f3e b5 99 LDA &99,X ; crossing_enemies_screen_address_low &2f40 e9 08 SBC #&08 # Move left four pixels &2f42 95 99 STA &99,X ; crossing_enemies_screen_address_low &2f44 b5 9a LDA &9a,X ; crossing_enemies_screen_address_high &2f46 e9 00 SBC #&00 &2f48 95 9a STA &9a,X ; crossing_enemies_screen_address_high &2f4a 60 RTS ; is_at_right_edge_of_room &2f4b bd 2b 22 LDA &222b,X ; crossing_enemies_room_x &2f4e c9 07 CMP #&07 &2f50 f0 16 BEQ &2f68 ; set_whirligig_or_ghost_moving_left # Don't move right of rightmost room ; move_whirligig_or_ghost_right_a_room &2f52 fe 2b 22 INC &222b,X ; crossing_enemies_room_x &2f55 a9 00 LDA #&00 &2f57 9d 2f 22 STA &222f,X ; crossing_enemies_x # Move to left of room &2f5a 38 SEC &2f5b b5 99 LDA &99,X ; crossing_enemies_screen_address_low &2f5d e9 60 SBC #&60 ; &260 # Move to left of screen &2f5f 95 99 STA &99,X ; crossing_enemies_screen_address_low &2f61 b5 9a LDA &9a,X ; crossing_enemies_screen_address_high &2f63 e9 02 SBC #&02 &2f65 95 9a STA &9a,X ; crossing_enemies_screen_address_high &2f67 60 RTS ; set_whirligig_or_ghost_moving_left &2f68 a9 ff LDA #&ff &2f6a 9d 2c 22 STA &222c,X ; crossing_enemies_x_velocity &2f6d 60 RTS ; is_at_left_edge_of_room &2f6e bd 2b 22 LDA &222b,X ; crossing_enemies_room_x &2f71 f0 16 BEQ &2f89 ; set_whirligig_or_ghost_moving_right # Don't move left of leftmost room ; move_whirligig_or_ghost_left_a_room &2f73 de 2b 22 DEC &222b,X ; crossing_enemies_room_x &2f76 a9 4c LDA #&4c &2f78 9d 2f 22 STA &222f,X ; crossing_enemies_x # Move to right of room &2f7b 18 CLC &2f7c b5 99 LDA &99,X ; crossing_enemies_screen_address_low &2f7e 69 60 ADC #&60 ; &260 # Move to right of screen &2f80 95 99 STA &99,X ; crossing_enemies_screen_address_low &2f82 b5 9a LDA &9a,X ; crossing_enemies_screen_address_high &2f84 69 02 ADC #&02 &2f86 95 9a STA &9a,X ; crossing_enemies_screen_address_high &2f88 60 RTS ; set_whirligig_or_ghost_moving_right &2f89 a9 01 LDA #&01 &2f8b 9d 2c 22 STA &222c,X ; crossing_enemies_x_velocity &2f8e 60 RTS ; move_ghost_vertically &2f8f bd 34 22 LDA &2234,X ; crossing_enemies_y_velocity &2f92 c9 02 CMP #&02 &2f94 d0 0a BNE &2fa0 ; is_moving_up ; is_moving_down &2f96 bd 30 22 LDA &2230,X ; crossing_enemies_y &2f99 c9 c0 CMP #&c0 &2f9b d0 0d BNE &2faa ; not_at_top_or_bottom_edge_of_room &2f9d 4c e8 2f JMP &2fe8 ; is_at_bottom_edge_of_room ; is_moving_up &2fa0 bd 30 22 LDA &2230,X ; crossing_enemies_y &2fa3 c9 10 CMP #&10 &2fa5 d0 03 BNE &2faa ; not_at_top_or_bottom_edge_of_room &2fa7 4c cd 2f JMP &2fcd ; is_at_top_edge_of_room ; not_at_top_or_bottom_edge_of_room &2faa bd 30 22 LDA &2230,X ; crossing_enemies_y &2fad 85 3c STA &3c ; sprite_y &2faf bd 34 22 LDA &2234,X ; crossing_enemies_y_velocity &2fb2 85 40 STA &40 ; y_velocity &2fb4 b5 99 LDA &99,X ; crossing_enemies_screen_address_low &2fb6 85 3e STA &3e ; sprite_screen_address_low &2fb8 b5 9a LDA &9a,X ; crossing_enemies_screen_address_high &2fba 85 3f STA &3f ; sprite_screen_address_high &2fbc 20 f1 34 JSR &34f1 ; apply_y_velocity_to_sprite # Move ghost vertically &2fbf a5 3c LDA &3c ; sprite_y &2fc1 9d 30 22 STA &2230,X ; crossing_enemies_y &2fc4 a5 3e LDA &3e ; sprite_screen_address_low &2fc6 95 99 STA &99,X ; crossing_enemies_screen_address_low &2fc8 a5 3f LDA &3f ; sprite_screen_address_high &2fca 95 9a STA &9a,X ; crossing_enemies_screen_address_high &2fcc 60 RTS ; is_at_top_edge_of_room &2fcd b5 8a LDA &8a,X ; crossing_enemies_room_y &2fcf c9 08 CMP #&08 &2fd1 f0 0f BEQ &2fe2 ; set_ghost_moving_down # Don't move up out of ghost maze ; move_ghost_up_a_room &2fd3 d6 8a DEC &8a,X ; crossing_enemies_room_y &2fd5 a9 c0 LDA #&c0 &2fd7 9d 30 22 STA &2230,X ; crossing_enemies_y # Move to bottom of room &2fda 18 CLC &2fdb b5 9a LDA &9a,X ; crossing_enemies_screen_address_high &2fdd 69 37 ADC #&37 ; &3700 # Move to bottom of screen &2fdf 95 9a STA &9a,X ; crossing_enemies_screen_address_high &2fe1 60 RTS ; set_ghost_moving_down &2fe2 a9 02 LDA #&02 &2fe4 9d 34 22 STA &2234,X ; crossing_enemies_y_velocity &2fe7 60 RTS ; is_at_bottom_edge_of_room &2fe8 b5 8a LDA &8a,X ; crossing_enemies_room_y &2fea c9 09 CMP #&09 &2fec f0 0f BEQ &2ffd ; set_ghost_moving_up # Don't move below bottommost room ; move_ghost_down_a_room &2fee f6 8a INC &8a,X ; crossing_enemies_room_y &2ff0 a9 10 LDA #&10 &2ff2 9d 30 22 STA &2230,X ; crossing_enemies_y # Move to top of room &2ff5 38 SEC &2ff6 b5 9a LDA &9a,X ; crossing_enemies_screen_address_high &2ff8 e9 37 SBC #&37 ; &3700 # Move to top of screen &2ffa 95 9a STA &9a,X ; crossing_enemies_screen_address_high &2ffc 60 RTS ; set_ghost_moving_up &2ffd a9 fe LDA #&fe &2fff 9d 34 22 STA &2234,X ; crossing_enemies_y_velocity &3002 60 RTS ; remove_or_manifest_ghost &3003 20 92 2e JSR &2e92 ; plot_or_unplot_ghost # Unplot newly exorcised ghost, plot returning ghost &3006 4c 13 30 JMP &3013 ; update_ghost ; update_ghosts &3009 a2 00 LDX #&00 ; update_ghosts_loop &300b b5 80 LDA &80,X ; crossing_enemies_cooldown # Zero if ghost has just been exorcised &300d f0 f4 BEQ &3003 ; remove_or_manifest_ghost # Unplot newly exorcised ghost &300f c9 02 CMP #&02 &3011 f0 f0 BEQ &3003 ; remove_or_manifest_ghost # Plot returning ghost ; update_ghost &3013 d6 80 DEC &80,X ; crossing_enemies_cooldown # One if ghost is active, becomes zero &3015 d0 17 BNE &302e ; consider_next_ghost # Branch if ghost not active &3017 a9 01 LDA #&01 &3019 95 80 STA &80,X ; crossing_enemies_cooldown # Set to one to keep ghost active &301b a5 61 LDA &61 ; plotting_or_updating_enemies # Zero if plotting, non-zero if updating &301d f0 03 BEQ &3022 ; skip_unplotting_ghost &301f 20 92 2e JSR &2e92 ; plot_or_unplot_ghost # Unplot active ghost ; skip_unplotting_ghost &3022 20 4f 30 JSR &304f ; move_ghost &3025 20 ac 30 JSR &30ac ; check_if_ghosts_in_same_position &3028 20 35 30 JSR &3035 ; check_if_ghost_touching_player &302b 20 92 2e JSR &2e92 ; plot_or_unplot_ghost # Plot active ghost ; consider_next_ghost &302e e8 INX &302f e8 INX &3030 e0 04 CPX #&04 &3032 d0 d7 BNE &300b ; update_ghosts_loop ; leave &3034 60 RTS ; check_if_ghost_touching_player &3035 20 dd 2e JSR &2edd ; check_if_crossing_enemy_in_player_room # Returns carry set if in player room &3038 90 fa BCC &3034 ; leave # Leave with carry clear to indicate not touching player &303a bd 2f 22 LDA &222f,X ; crossing_enemies_x &303d 85 11 STA &11 ; sprite_x &303f bd 30 22 LDA &2230,X ; crossing_enemies_y &3042 4a LSR A &3043 18 CLC &3044 69 0c ADC #&0c &3046 85 3c STA &3c ; sprite_y &3048 a9 17 LDA #&17 &304a 85 41 STA &41 ; sprite_height &304c 4c 57 2b JMP &2b57 ; lose_energy_if_touching_enemy # Leave with carry set if touching player ; move_ghost &304f a5 8f LDA &8f ; player_room_y &3051 d5 8a CMP &8a,X ; crossing_enemies_room_y &3053 d0 17 BNE &306c ; not_in_same_row_of_rooms_as_player ; is_in_same_row_of_rooms_as_player &3055 bd 30 22 LDA &2230,X ; crossing_enemies_y &3058 4a LSR A &3059 85 31 STA &31 ; half_crossing_enemy_y &305b a5 2c LDA &2c ; player_y &305d 4a LSR A &305e c5 31 CMP &31 ; half_crossing_enemy_y &3060 10 05 BPL &3067 ; set_ghost_moving_down ; set_ghost_moving_up &3062 a9 fe LDA #&fe &3064 4c 69 30 JMP &3069 ; set_ghost_y_velocity ; set_ghost_moving_down &3067 a9 02 LDA #&02 ; set_ghost_y_velocity &3069 9d 34 22 STA &2234,X ; crossing_enemies_y_velocity ; not_in_same_row_of_rooms_as_player &306c a5 90 LDA &90 ; player_room_x &306e dd 2b 22 CMP &222b,X ; crossing_enemies_room_x &3071 d0 15 BNE &3088 ; not_in_same_column_of_rooms_as_player ; is_in_same_column_of_rooms_as_player &3073 a5 35 LDA &35 ; player_x &3075 dd 2f 22 CMP &222f,X ; crossing_enemies_x &3078 30 09 BMI &3083 ; set_ghost_moving_left ; set_ghost_moving_right &307a a9 01 LDA #&01 &307c 4c 85 30 JMP &3085 ; set_ghost_x_velocity ; to_move_whirligig_or_ghost &307f 4c 12 2f JMP &2f12 ; move_whirligig_or_ghost ; unused &3082 60 RTS ; set_ghost_moving_left &3083 a9 ff LDA #&ff ; set_ghost_x_velocity &3085 9d 2c 22 STA &222c,X ; crossing_enemies_x_velocity ; not_in_same_column_of_rooms_as_player &3088 bd 33 22 LDA &2233,X ; crossing_enemies_direction # Zero if moving horizontally, two if moving vertically &308b c9 02 CMP #&02 &308d f0 10 BEQ &309f ; is_moving_vertically ; is_moving_horizontally &308f a5 35 LDA &35 ; player_x &3091 dd 2f 22 CMP &222f,X ; crossing_enemies_x &3094 d0 e9 BNE &307f ; to_move_whirligig_or_ghost &3096 a9 02 LDA #&02 &3098 9d 33 22 STA &2233,X ; crossing_enemies_direction # Set to two to set ghost moving vertically &309b 60 RTS ; to_move_ghost_vertically &309c 4c 8f 2f JMP &2f8f ; move_ghost_vertically ; is_moving_vertically &309f a5 2c LDA &2c ; player_y &30a1 dd 30 22 CMP &2230,X ; crossing_enemies_y &30a4 d0 f6 BNE &309c ; to_move_ghost_vertically &30a6 a9 00 LDA #&00 &30a8 9d 33 22 STA &2233,X ; crossing_enemies_direction # Set to zero to set ghost moving horizontally ; leave &30ab 60 RTS ; check_if_ghosts_in_same_position &30ac ad 2f 22 LDA &222f ; crossing_enemies_x + 0 &30af cd 31 22 CMP &2231 ; crossing_enemies_x + 2 &30b2 d0 f7 BNE &30ab ; leave &30b4 ad 30 22 LDA &2230 ; crossing_enemies_y + 0 &30b7 cd 32 22 CMP &2232 ; crossing_enemies_y + 2 &30ba d0 ef BNE &30ab ; leave # Are the ghosts in the same position? &30bc ad 33 22 LDA &2233 ; crossing_enemies_direction + 0 &30bf c9 02 CMP #&02 # Zero if moving horizontally, two if moving vertically &30c1 d0 06 BNE &30c9 ; set_ghost_moving_vertically ; set_ghost_moving_horizontally # If the first ghost was moving vertically, &30c3 a9 00 LDA #&00 # Set to zero to set ghost moving horizontally ; set_ghost_direction &30c5 8d 33 22 STA &2233 ; crossing_enemies_direction + 0 &30c8 60 RTS ; set_ghost_moving_vertically # If the first ghost was moving horizontally, &30c9 a9 02 LDA #&02 # Set to two to set ghost moving vertically &30cb 4c c5 30 JMP &30c5 ; set_ghost_direction ; recharge_energy &30ce a2 00 LDX #&00 ; recharge_energy_loop &30d0 a0 ff LDY #&ff ; delay_loop &30d2 88 DEY &30d3 d0 fd BNE &30d2 ; delay_loop &30d5 86 3a STX &3a ; player_previous_energy &30d7 86 3b STX &3b ; player_energy &30d9 20 e5 30 JSR &30e5 ; play_sound_for_gaining_energy &30dc 20 30 26 JSR &2630 ; plot_energy_section &30df e8 INX &30e0 e0 ff CPX #&ff &30e2 d0 ec BNE &30d0 ; recharge_energy_loop ; leave &30e4 60 RTS ; play_sound_for_gaining_energy # Called with X = energy &30e5 8e a4 32 STX &32a4 ; sound_block + 4 (pitch) &30e8 a9 11 LDA #&11 &30ea 4c c0 32 JMP &32c0 ; to_play_sound_on_channel_A # Play sound for gaining energy ; fire_stun_grenade &30ed a5 a1 LDA &a1 ; stun_grenades_carried_plus_four &30ef c9 04 CMP #&04 &30f1 f0 f1 BEQ &30e4 ; leave # Can't fire stun grenade if all used ; has_grenade &30f3 c6 a1 DEC &a1 ; stun_grenades_carried_plus_four &30f5 a5 a1 LDA &a1 ; stun_grenades_carried_plus_four &30f7 20 b3 24 JSR &24b3 ; unplot_status_sprite_at_position # Unplot grenade from status section &30fa a9 01 LDA #&01 &30fc 85 74 STA &74 ; enemies_are_stunned # Set to non-zero to stun enemies &30fe a5 4e LDA &4e ; room_feature &3100 c9 ff CMP #&ff ; FEATURE_REACTOR &3102 d0 3e BNE &3142 ; flash_background ; destroy_reactor # If the room contains a reactor, &3104 c6 a2 DEC &a2 ; force_fields_remaining # remove a force field &3106 c6 89 DEC &89 ; reactors_remaining # remove a reactor &3108 a5 89 LDA &89 ; reactors_remaining &310a 20 b3 24 JSR &24b3 ; unplot_status_sprite_at_position # Unplot reactor from status section &310d a9 53 LDA #&53 ; TILE_STONE_CEILING_EDGED | TILE_FLIPPED_VERTICALLY &310f 20 4e 24 JSR &244e ; set_feature_tile # Remove reactor &3112 a6 90 LDX &90 ; player_room_x &3114 bd 71 31 LDA &3171,X ; reactors_room_table_offsets &3117 a8 TAY &3118 a9 00 LDA #&00 # Use wavy patterns, black for destroyed reactor rooms &311a 99 b0 09 STA &09b0,Y ; rooms_colour_and_wall_type &311d 85 4e STA &4e ; room_feature # Set to zero to indicate room no longer has reactor &311f 85 9f STA &9f ; player_underwater_breath_timer # Set to zero on destruction of reactor &3121 20 42 31 JSR &3142 ; flash_background &3124 a2 01 LDX #&01 ; animate_destroying_reactor_loop &3126 86 31 STX &31 ; count &3128 a9 09 LDA #&09 ; Set first flashing colour duration &312a 20 f4 ff JSR &fff4 ; OSBYTE &312d a9 0a LDA #&0a ; Set second flashing colour duration &312f 20 f4 ff JSR &fff4 ; OSBYTE &3132 20 e5 30 JSR &30e5 ; play_sound_for_gaining_energy # Play sound for destroying reactor &3135 a9 13 LDA #&13 ; Wait for vertical retrace &3137 20 f4 ff JSR &fff4 ; OSBYTE &313a a6 31 LDX &31 ; count &313c e8 INX &313d d0 e7 BNE &3126 ; animate_destroying_reactor_loop &313f 8e 82 03 STX &0382 ; room_colour # Set room colour to black ; flash_background &3142 a2 14 LDX #&14 ; 20 ; flash_background_loop &3144 8a TXA &3145 48 PHA ; count &3146 20 4f 31 JSR &314f ; set_background_colour &3149 68 PLA ; count &314a aa TAX &314b ca DEX &314c 10 f6 BPL &3144 ; flash_background_loop &314e 60 RTS ; set_background_colour # Called with X = colour &314f a9 13 LDA #&13 ; Define logical colour &3151 20 ee ff JSR &ffee ; OSWRCH &3154 a9 00 LDA #&00 &3156 20 ee ff JSR &ffee ; OSWRCH &3159 8a TXA &315a 20 ee ff JSR &ffee ; OSWRCH &315d 8a TXA # Use colour for sound, i.e. silence sound when black &315e 20 4c 33 JSR &334c ; play_sound_on_channel_zero # Play sound for auto-transport and reactor destruction &3161 a9 00 LDA #&00 &3163 20 ee ff JSR &ffee ; OSWRCH &3166 20 ee ff JSR &ffee ; OSWRCH &3169 20 ee ff JSR &ffee ; OSWRCH &316c a9 13 LDA #&13 ; Wait for vertical retrace &316e 4c f4 ff JMP &fff4 ; OSBYTE ; reactors_room_table_offsets # Offsets into rooms_colour_and_wall_type ; 0 1 2 3 # Index is player_room_x, 1 is unused &3171 38 01 32 23 ; move_feature_two_tiles_to_right # Called with A = tile type &3175 e6 02 INC &02 ; feature_tile_x &3177 e6 02 INC &02 ; feature_tile_x &3179 20 4e 24 JSR &244e ; set_feature_tile &317c c6 02 DEC &02 ; feature_tile_x &317e c6 02 DEC &02 ; feature_tile_x &3180 a9 20 LDA #&20 &3182 85 78 STA &78 ; game_event_timer &3184 a9 04 LDA #&04 ; EVENT_MOVING_FEATURE &3186 8d 42 12 STA &1242 ; game_event &3189 a9 39 LDA #&39 ; TILE_WALL_BOTTOM_HALF &318b 4c 4e 24 JMP &244e ; set_feature_tile ; animate_moving_feature &318e c6 78 DEC &78 ; game_event_timer &3190 d0 08 BNE &319a ; not_fully_moved &3192 a9 00 LDA #&00 &3194 8d 42 12 STA &1242 ; game_event # Set to zero to indicate event has finished &3197 85 4e STA &4e ; room_feature # Set to zero to remove feature ; leave &3199 60 RTS ; not_fully_moved &319a 18 CLC &319b ad 43 12 LDA &1243 ; feature_screen_address_low &319e 69 40 ADC #&40 &31a0 85 7c STA &7c ; screen_address_low &31a2 ad 44 12 LDA &1244 ; feature_screen_address_high &31a5 69 00 ADC #&00 &31a7 85 7d STA &7d ; screen_address_high &31a9 20 2f 37 JSR &372f ; move_feature_four_pixels_to_right &31ac 18 CLC &31ad ad 43 12 LDA &1243 ; feature_screen_address_low &31b0 69 08 ADC #&08 # Move right four pixels &31b2 8d 43 12 STA &1243 ; feature_screen_address_low &31b5 90 03 BCC &31ba ; skip_page &31b7 ee 44 12 INC &1244 ; feature_screen_address_high ; skip_page &31ba a5 78 LDA &78 ; game_event_timer &31bc 0a ASL A &31bd 8d a4 32 STA &32a4 ; sound_block + 4 (pitch) &31c0 a9 01 LDA #&01 &31c2 8d a6 32 STA &32a6 ; sound_block + 6 (duration) &31c5 4c 33 33 JMP &3333 ; play_sound_on_channel_two # Play sound for opening altar or moving elephant or snail ; consider_using_teleport &31c8 a5 35 LDA &35 ; player_x &31ca c9 16 CMP #&16 &31cc d0 cb BNE &3199 ; leave &31ce a2 64 LDX #&64 ; 100 ; animate_using_teleport_loop &31d0 86 31 STX &31 ; count &31d2 20 89 2a JSR &2a89 ; plot_or_unplot_player # Flash player &31d5 a9 13 LDA #&13 ; Wait for vertical retrace &31d7 20 f4 ff JSR &fff4 ; OSBYTE &31da 20 f4 ff JSR &fff4 ; OSBYTE &31dd a6 31 LDX &31 ; count &31df 20 e5 30 JSR &30e5 ; play_sound_for_gaining_energy # Play sound for using teleport &31e2 ca DEX &31e3 d0 eb BNE &31d0 ; animate_using_teleport_loop &31e5 20 00 32 JSR &3200 ; move_player_to_sally_reactor_room &31e8 4c 89 2a JMP &2a89 ; plot_or_unplot_player # Plot player ; plot_bar_across_top_of_status_section &31eb a2 42 LDX #&42 &31ed a9 e0 LDA #&e0 ; &3ce0 &31ef 85 7a STA &7a ; tile_screen_address_low &31f1 a9 3c LDA #&3c &31f3 85 7b STA &7b ; tile_screen_address_high &31f5 a0 00 LDY #&00 ; plot_bar_across_top_of_status_section_loop &31f7 a9 f0 LDA #&f0 ; 2222 # Blue &31f9 20 4e 12 JSR &124e ; plot_byte_to_tile_screen_address # Moves right four pixels &31fc d0 f9 BNE &31f7 ; plot_bar_across_top_of_status_section_loop &31fe 60 RTS ; unused &31ff 00 ; move_player_to_sally_reactor_room # Room (3, 4) &3200 a9 04 LDA #&04 &3202 85 8f STA &8f ; player_room_y &3204 a9 03 LDA #&03 &3206 85 90 STA &90 ; player_room_x &3208 a9 e0 LDA #&e0 &320a 85 70 STA &70 ; player_room_y_data_offset_low &320c a9 01 LDA #&01 &320e 85 71 STA &71 ; player_room_y_data_offset_high &3210 4c 06 12 JMP &1206 ; to_plot_room ; unused &3213 ea ; change_tile_because_of_terminal_activation &3214 a5 90 LDA &90 ; player_room_x &3216 18 CLC &3217 0a ASL A &3218 65 90 ADC &90 ; player_room_x &321a aa TAX ; player_room_x * 3 &321b bd 2d 32 LDA &322d,X ; terminal_activation_tiles_table &321e 85 00 STA &00 ; tile_address_low &3220 bd 2e 32 LDA &322e,X ; terminal_activation_tiles_table + 1 &3223 85 01 STA &01 ; tile_address_high &3225 a0 00 LDY #&00 &3227 bd 2f 32 LDA &322f,X ; terminal_activation_tiles_table + 2 &322a 91 00 STA (&00),Y ; tile_address &322c 60 RTS # Terminals # ========= # Terminal in room (0, 0), password SALLY, turns corner tile in room (1, 0), allowing access to crystal # Terminal in room (1, 7), password LYNDA, does nothing # Terminal in room (2, 3), password DAVID, move column in room (1, 9), allowing access to crystal # Terminal in room (3, 6), password IDIOT, floods room (3, 6) with water, keeping wall (see &197c) # Terminal in room (4, 9), password OTTER, does nothing # Terminal in room (5, 3), password ERASE, changes vats of acid in room (5, 3) into vats of water (see also &2159) # Terminal in room (6, 4), password SEVEN, does nothing # Terminal in room (7, 1), password ENTER, does nothing ; terminal_activation_tiles_table ; addr t &322d fe 37 58 ; &00 : &37fe = &58 : tile_data + 0 * &78 + 1 * &28 + 1 * &05 + 1; room (1, 0), tile (1, 1) = TILE_WALL_BOTTOM_RIGHT_CORNER | TILE_FLIPPED_VERTICALLY &3230 00 00 00 ; &01 : &0000 = &00 &3233 5e 3c 3e ; &02 : &3c5e = &3e : tile_data + 9 * &78 + 2 * &28 + 1 * &05 + 1; room (1, 9), tile (1, 2) = TILE_WALL_COLUMN_LEFT_EDGED &3236 af 3a 6e ; &03 : &3aaf = &6e ; tile_data + 6 * &78 + 0 * &28 + 3 * &05 + 0; room (3, 6), tile (0, 0) = TILE_WATER | TILE_FLIPPED_VERTICALLY &3239 00 00 00 ; &04 : &0000 = &00 &323c 7a 39 0a ; &05 : &397a = &0a ; tile_data + 3 * &78 + 1 * &28 + 5 * &05 + 1; room (5, 3), tile (1, 1) = TILE_VAT_OF_WATER &323f 00 00 00 ; &06 : &0000 = &00 &3242 00 00 00 ; &07 : &0000 = &00 ; reset_objects &3245 a2 2f LDX #&2f ; reset_objects_loop &3247 bd 80 09 LDA &0980,X ; initial_object_data &324a 9d 00 09 STA &0900,X ; object_data &324d ca DEX &324e 10 f7 BPL &3247 ; reset_objects_loop &3250 a9 59 LDA #&59 ; TILE_WALL_BOTTOM_LEFT_CORNER | TILE_FLIPPED_VERTICALLY &3252 4c 80 32 JMP &3280 ; reset_start_room_corner_tile_and_reactor_room_colours ; unused &3255 ea ; write_string &3256 68 PLA # Parameters follow function call &3257 85 31 STA &31 ; text_address_low # Actually address of start of string - 1 &3259 68 PLA &325a 85 32 STA &32 ; text_address_high &325c 98 TYA &325d 48 PHA ; tmp_y ; write_string_loop &325e a0 00 LDY #&00 &3260 b1 31 LDA (&31),Y ; text_address # &00 indicates end of string &3262 f0 11 BEQ &3275 ; end_of_string &3264 c8 INY &3265 b1 31 LDA (&31),Y ; text_address # Get byte of string &3267 f0 03 BEQ &326c ; skip_character &3269 20 ee ff JSR &ffee ; OSWRCH ; skip_character &326c e6 31 INC &31 ; text_address_low &326e d0 ee BNE &325e ; write_string_loop &3270 e6 32 INC &32 ; text_address_high &3272 4c 5e 32 JMP &325e ; write_string_loop ; end_of_string &3275 68 PLA ; tmp_y &3276 a8 TAY &3277 a5 32 LDA &32 ; text_address_high &3279 48 PHA # Return to code after end of parameters &327a a5 31 LDA &31 ; text_address_low &327c 48 PHA &327d 60 RTS ; unused &327e 00 00 ; reset_start_room_corner_tile_and_reactor_room_colours # A = &59 ; TILE_WALL_BOTTOM_LEFT_CORNER | TILE_FLIPPED_VERTICALLY &3280 8d fe 37 STA &37fe ; tile_data + 0 * &78 + 1 * &28 + 1 * &05 + 1; room (1, 0), tile (1, 1) &3283 a9 69 LDA #&69 # Use bevelled blocks, flashing red/cyan for active reactor rooms &3285 8d d3 09 STA &09d3 ; rooms_colour_and_wall_type + &23 &3288 8d e2 09 STA &09e2 ; rooms_colour_and_wall_type + &33 &328b 8d e8 09 STA &09e8 ; rooms_colour_and_wall_type + &38 &328e 60 RTS ; completion_screen &328f a2 00 LDX #&00 &3291 a5 9d LDA &9d ; reincarnations_used &3293 d0 02 BNE &3297 ; not_one_life ; one_life &3295 a2 36 LDX #&36 ; completion_message_without_reincarnation - completion_message ; not_one_life &3297 a5 2a LDA &2a ; crystals_remaining &3299 f0 02 BEQ &329d ; to_write_completion_message # Should always branch &329b 68 PLA # Crash if cheating detected &329c 60 RTS ; to_write_completion_message &329d 4c 00 01 JMP &0100 ; write_completion_message ; sound_block ; chan vol pitch dur &32a0 01 00 0f ff 00 00 00 ; check_if_screen_address_is_outside_room &32a7 a5 7d LDA &7d ; screen_address_high &32a9 c9 80 CMP #&80 ; &8000 &32ab 10 10 BPL &32bd ; leave_with_carry_set &32ad c9 42 CMP #&42 &32af 10 0a BPL &32bb ; leave_with_carry_clear &32b1 c9 41 CMP #&41 ; &4180 = &3c80 + 2 * &280 &32b3 30 08 BMI &32bd ; leave_with_carry_set &32b5 a5 7c LDA &7c ; screen_address_low &32b7 c9 80 CMP #&80 &32b9 30 02 BMI &32bd ; leave_with_carry_set ; leave_with_carry_clear &32bb 18 CLC # Leave with carry clear to indicate inside room &32bc 60 RTS ; leave_with_carry_set &32bd 38 SEC # Leave with carry set to indicate outside room &32be 60 RTS ; music_room_correct_notes_played &32bf 00 ; to_play_sound_on_channel_A &32c0 4c 51 33 JMP &3351 ; play_sound_on_channel_A ; time_minutes &32c3 45 ; time_hours &32c4 10 ; plot_sprite # Called with A = screen_address_low, X = sprite &32c5 48 PHA ; screen_address_low &32c6 bd 5f 0b LDA &0b5f,X ; sprite_addresses_table &32c9 85 7a STA &7a ; sprite_address_low &32cb bd 60 0b LDA &0b60,X ; sprite_addresses_table + 1 &32ce 85 7b STA &7b ; sprite_address_high &32d0 68 PLA ; screen_address_low ; plot_sprite_using_address &32d1 85 7c STA &7c ; screen_address_low &32d3 98 TYA &32d4 48 PHA ; tmp_y &32d5 8a TXA &32d6 48 PHA ; tmp_x ; plot_sprite_group_loop &32d7 a9 08 LDA #&08 &32d9 85 50 STA &50 ; rows_remaining_in_group ; plot_sprite_middle_loop &32db a0 00 LDY #&00 &32dd 20 a7 32 JSR &32a7 ; check_if_screen_address_is_outside_room # Returns carry set if outside room &32e0 b0 0e BCS &32f0 ; skip_row ; plot_sprite_column_loop &32e2 b1 7a LDA (&7a),Y ; sprite_address &32e4 51 7c EOR (&7c),Y ; screen_address &32e6 91 7c STA (&7c),Y ; screen_address &32e8 98 TYA &32e9 69 08 ADC #&08 # Move right four pixels &32eb a8 TAY &32ec c9 20 CMP #&20 &32ee d0 f2 BNE &32e2 ; plot_sprite_column_loop ; skip_row &32f0 a5 6c LDA &6c ; double_sprite # Non-zero if sprite doubled vertically &32f2 f0 05 BEQ &32f9 ; move_to_next_row_of_sprite_data ; is_doubled &32f4 a5 50 LDA &50 ; rows_remaining_in_group &32f6 6a ROR A &32f7 90 02 BCC &32fb ; skip_moving_to_next_row_of_sprite_data ; move_to_next_row_of_sprite_data &32f9 e6 7a INC &7a ; sprite_address_low ; skip_moving_to_next_row_of_sprite_data &32fb a5 7c LDA &7c ; screen_address_low &32fd 29 07 AND #&07 &32ff c9 07 CMP #&07 &3301 10 20 BPL &3323 ; next_group &3303 e6 7c INC &7c ; screen_address_low ; next_row &3305 c6 50 DEC &50 ; rows_remaining_in_group &3307 d0 d2 BNE &32db ; plot_sprite_middle_loop &3309 c6 41 DEC &41 ; sprite_height &330b f0 11 BEQ &331e ; leave_after_restoring_registers &330d a5 6c LDA &6c ; double_sprite # Non-zero if sprite doubled vertically &330f d0 c6 BNE &32d7 ; plot_sprite_group_loop &3311 a5 7a LDA &7a ; sprite_address_low &3313 69 18 ADC #&18 # Move to next row of sprite &3315 85 7a STA &7a ; sprite_address_low &3317 90 be BCC &32d7 ; plot_sprite_group_loop &3319 e6 7b INC &7b ; sprite_address_high &331b 4c d7 32 JMP &32d7 ; plot_sprite_group_loop ; leave_after_restoring_registers &331e 68 PLA ; tmp_x &331f aa TAX &3320 68 PLA ; tmp_y &3321 a8 TAY &3322 60 RTS ; next_group &3323 18 CLC &3324 a5 7c LDA &7c ; screen_address_low &3326 69 79 ADC #&79 # Move down a group &3328 85 7c STA &7c ; screen_address_low &332a a5 7d LDA &7d ; screen_address_high &332c 69 02 ADC #&02 &332e 85 7d STA &7d ; screen_address_high &3330 4c 05 33 JMP &3305 ; next_row ; play_sound_on_channel_two # Called with A = envelope &3333 8d a2 32 STA &32a2 ; sound_block + 2 (volume low) &3336 a9 00 LDA #&00 &3338 8d a3 32 STA &32a3 ; sound_block + 3 (volume high) &333b a9 12 LDA #&12 &333d 8d a0 32 STA &32a0 ; sound_block + 0 (channel) &3340 4c 63 33 JMP &3363 ; play_sound ; use_default_sprite_size &3343 a9 01 LDA #&01 &3345 85 6c STA &6c ; double_sprite # Set to non-zero to indicate sprite doubled vertically &3347 a9 02 LDA #&02 &3349 85 41 STA &41 ; sprite_height ; leave &334b 60 RTS ; play_sound_on_channel_zero &334c 8d a4 32 STA &32a4 ; sound_block + 4 (pitch) &334f a9 10 LDA #&10 ; play_sound_on_channel_A &3351 8d a0 32 STA &32a0 ; sound_block + 0 (channel) &3354 a9 ff LDA #&ff &3356 8d a3 32 STA &32a3 ; sound_block + 3 (volume high) &3359 a9 f1 LDA #&f1 &335b 8d a2 32 STA &32a2 ; sound_block + 2 (volume low) &335e a9 01 LDA #&01 &3360 8d a6 32 STA &32a6 ; sound_block + 6 (duration) ; play_sound &3363 a5 9e LDA &9e ; suppress_sound # Non-zero if sound is suppressed &3365 d0 e4 BNE &334b ; leave &3367 48 PHA ; tmp_a &3368 8a TXA &3369 48 PHA ; tmp_x &336a 98 TYA &336b 48 PHA ; tmp_y &336c a2 a0 LDX #&a0 ; &32a0 = sound_block &336e a0 32 LDY #&32 &3370 a9 07 LDA #&07 ; Generate a sound &3372 20 f1 ff JSR &fff1 ; OSWORD &3375 68 PLA ; tmp_y &3376 a8 TAY &3377 68 PLA ; tmp_x &3378 aa TAX &3379 68 PLA ; tmp_a ; leave &337a 60 RTS ; handle_touching_pipe_top &337b 38 SEC &337c a5 35 LDA &35 ; player_x &337e e9 0e SBC #&0e &3380 4a LSR A &3381 4a LSR A &3382 a8 TAY &3383 b9 c0 0b LDA &0bc0,Y ; music_room_pipes_pitch_table &3386 8d a4 32 STA &32a4 ; sound_block + 4 (pitch) &3389 a9 11 LDA #&11 &338b 20 51 33 JSR &3351 ; play_sound_on_channel_A # Play sound for Music Room pipe &338e ae bf 32 LDX &32bf ; music_room_correct_notes_played &3391 bd 53 0b LDA &0b53,X ; music_room_expected_pitches &3394 cd a4 32 CMP &32a4 ; sound_block + 4 (pitch) &3397 d0 19 BNE &33b2 ; is_wrong_pitch ; is_right_pitch &3399 ee bf 32 INC &32bf ; music_room_correct_notes_played &339c ad bf 32 LDA &32bf ; music_room_correct_notes_played &339f c9 0c CMP #&0c ; EVENT_OPENING_DOOR &33a1 d0 d7 BNE &337a ; leave # Has the player played all twelve notes correctly? &33a3 8d 42 12 STA &1242 ; game_event # If so, open door &33a6 a5 90 LDA &90 ; player_room_x &33a8 c9 04 CMP #&04 &33aa d0 ce BNE &337a ; leave # Is the player in room (4, 1)? &33ac a9 2d LDA #&2d ; TILE_PASSWORD_TEXT # If so, also reveal password &33ae 8d 5d 38 STA &385d ; tile_data + 1 * &78 + 0 * &28 + 4 * &05 + 1; room (4, 1), tile (1, 0) &33b1 60 RTS ; is_wrong_pitch &33b2 ca DEX &33b3 bd 53 0b LDA &0b53,X ; music_room_expected_pitches &33b6 cd a4 32 CMP &32a4 ; sound_block + 4 (pitch) # Has the player repeated the previous note? &33b9 f0 bf BEQ &337a ; leave &33bb a9 00 LDA #&00 &33bd 8d bf 32 STA &32bf ; music_room_correct_notes_played # If not, reset count &33c0 60 RTS ; update_horizontal_enemies &33c1 a0 00 LDY #&00 ; update_horizontal_enemies_loop &33c3 a5 61 LDA &61 ; plotting_or_updating_enemies # Zero if plotting, non-zero if updating &33c5 f0 03 BEQ &33ca ; skip_unplotting &33c7 20 53 34 JSR &3453 ; plot_or_unplot_horizontal_enemy # Unplot horizontal enemy ; skip_unplotting &33ca ad 25 12 LDA &1225 ; horizontal_enemies_type # Zero if HORIZONTAL_ENEMY_TYPE_CATERPILLAR &33cd f0 2e BEQ &33fd ; update_horizontal_enemy &33cf c9 03 CMP #&03 ; HORIZONTAL_ENEMY_TYPE_PLATFORM &33d1 f0 2a BEQ &33fd ; update_horizontal_enemy ; is_fish_or_mouse &33d3 38 SEC &33d4 b9 64 00 LDA &0064,Y ; horizontal_enemies_x &33d7 e9 01 SBC #&01 &33d9 85 11 STA &11 ; sprite_x &33db ad 1d 12 LDA &121d ; horizontal_enemies_y &33de 0a ASL A &33df 0a ASL A &33e0 85 3c STA &3c ; sprite_y &33e2 20 03 22 JSR &2203 ; to_check_if_near_player_fixed_distance # Returns carry set if near player &33e5 90 16 BCC &33fd ; update_horizontal_enemy ; is_near_player &33e7 a5 31 LDA &31 ; homing_x_velocity &33e9 99 2a 12 STA &122a,Y ; horizontal_enemies_x_velocity &33ec ad 25 12 LDA &1225 ; horizontal_enemies_type &33ef c9 01 CMP #&01 ; HORIZONTAL_ENEMY_TYPE_FISH &33f1 d0 05 BNE &33f8 ; is_mouse ; is_fish &33f3 a9 30 LDA #&30 ; OBJECT_WORM # Fish is attracted to worm &33f5 4c 2a 34 JMP &342a ; check_if_carrying_food ; is_mouse &33f8 a9 38 LDA #&38 ; OBJECT_CHEESE # Mouse is attracted to cheese &33fa 4c 2a 34 JMP &342a ; check_if_carrying_food ; update_horizontal_enemy &33fd 20 3a 34 JSR &343a ; check_if_horizontal_enemy_at_minimum_or_maximum_x &3400 20 88 34 JSR &3488 ; move_horizontal_enemy &3403 20 53 34 JSR &3453 ; plot_or_unplot_horizontal_enemy # Plot horizontal enemy &3406 ad 25 12 LDA &1225 ; horizontal_enemies_type # Zero if HORIZONTAL_ENEMY_TYPE_CATERPILLAR &3409 d0 13 BNE &341e ; consider_next_horizontal_enemy ; is_caterpillar &340b b9 64 00 LDA &0064,Y ; horizontal_enemies_x &340e 85 11 STA &11 ; sprite_x &3410 ad 1d 12 LDA &121d ; horizontal_enemies_y &3413 0a ASL A &3414 0a ASL A &3415 85 3c STA &3c ; sprite_y &3417 a9 12 LDA #&12 &3419 85 41 STA &41 ; sprite_height &341b 20 06 22 JSR &2206 ; to_lose_energy_if_touching_enemy # Lose energy for touching horizontal enemy ; consider_next_horizontal_enemy &341e c8 INY &341f c8 INY &3420 cc 23 12 CPY &1223 ; offset_of_last_horizontal_enemy_plus_two &3423 30 9e BMI &33c3 ; update_horizontal_enemies_loop ; reset_double_sprite &3425 a9 00 LDA #&00 &3427 85 6c STA &6c ; double_sprite # Set to zero to indicate sprite not doubled vertically &3429 60 RTS ; check_if_carrying_food &342a c5 0c CMP &0c ; player_pockets + 0 &342c f0 cf BEQ &33fd ; update_horizontal_enemy # If carrying food, move towards player horizontally &342e c5 0d CMP &0d ; player_pockets + 1 &3430 f0 cb BEQ &33fd ; update_horizontal_enemy ; not_carrying_food &3432 a5 33 LDA &33 ; avoiding_x_velocity # Otherwise, move away from player horizontally &3434 99 2a 12 STA &122a,Y ; horizontal_enemies_x_velocity &3437 4c fd 33 JMP &33fd ; update_horizontal_enemy ; check_if_horizontal_enemy_at_minimum_or_maximum_x &343a b9 64 00 LDA &0064,Y ; horizontal_enemies_x &343d cd 1e 12 CMP &121e ; horizontal_enemies_minimum_x &3440 f0 06 BEQ &3448 ; set_horizontal_enemy_moving_right &3442 cd 1f 12 CMP &121f ; horizontal_enemies_maximum_x &3445 f0 07 BEQ &344e ; set_horizontal_enemy_moving_left &3447 60 RTS ; set_horizontal_enemy_moving_right &3448 a9 01 LDA #&01 ; set_horizontal_enemy_x_velocity &344a 99 2a 12 STA &122a,Y ; horizontal_enemies_x_velocity &344d 60 RTS ; set_horizontal_enemy_moving_left &344e a9 ff LDA #&ff &3450 4c 4a 34 JMP &344a ; set_horizontal_enemy_x_velocity ; plot_or_unplot_horizontal_enemy &3453 a9 01 LDA #&01 &3455 85 41 STA &41 ; sprite_height &3457 a2 00 LDX #&00 ; SPRITE_HORIZONTAL_ENEMY_RIGHT_FRAME_ONE &3459 b9 2a 12 LDA &122a,Y ; horizontal_enemies_x_velocity &345c c9 ff CMP #&ff &345e d0 02 BNE &3462 ; is_moving_right ; is_moving_left &3460 a2 02 LDX #&02 ; SPRITE_HORIZONTAL_ENEMY_LEFT_FRAME_ONE ; is_moving_right &3462 b9 64 00 LDA &0064,Y ; horizontal_enemies_x &3465 6a ROR A &3466 6a ROR A &3467 6a ROR A &3468 b0 04 BCS &346e ; use_frame_one # Animate horizontal enemies based on x position ; use_frame_two &346a e8 INX &346b e8 INX &346c e8 INX &346d e8 INX ; use_frame_one &346e ad 25 12 LDA &1225 ; horizontal_enemies_type # Zero if HORIZONTAL_ENEMY_TYPE_CATERPILLAR &3471 d0 0a BNE &347d ; use_half_size ; is_caterpillar &3473 ad 23 12 LDA &1223 ; offset_of_last_horizontal_enemy_plus_two &3476 c9 05 CMP #&05 &3478 10 03 BPL &347d ; use_half_size # Half size enemies if three or more present &347a 20 43 33 JSR &3343 ; use_default_sprite_size ; use_half_size &347d b9 44 00 LDA &0044,Y ; horizontal_enemies_screen_address_low &3480 85 7d STA &7d ; screen_address_high &3482 b9 43 00 LDA &0043,Y ; horizontal_enemies_screen_address_low &3485 4c c5 32 JMP &32c5 ; plot_sprite ; move_horizontal_enemy &3488 b9 64 00 LDA &0064,Y ; horizontal_enemies_x &348b 18 CLC &348c 79 2a 12 ADC &122a,Y ; horizontal_enemies_x_velocity &348f 99 64 00 STA &0064,Y ; horizontal_enemies_x &3492 b9 2a 12 LDA &122a,Y ; horizontal_enemies_x_velocity &3495 30 12 BMI &34a9 ; is_moving_left ; is_moving_right &3497 18 CLC &3498 b9 43 00 LDA &0043,Y ; horizontal_enemies_screen_address_low &349b 69 08 ADC #&08 # Move right four pixels &349d 99 43 00 STA &0043,Y ; horizontal_enemies_screen_address_low &34a0 b9 44 00 LDA &0044,Y ; horizontal_enemies_screen_address_high &34a3 69 00 ADC #&00 &34a5 99 44 00 STA &0044,Y ; horizontal_enemies_screen_address_high &34a8 60 RTS ; is_moving_left &34a9 38 SEC &34aa b9 43 00 LDA &0043,Y ; horizontal_enemies_screen_address_low &34ad e9 08 SBC #&08 # Move left four pixels &34af 99 43 00 STA &0043,Y ; horizontal_enemies_screen_address_low &34b2 b9 44 00 LDA &0044,Y ; horizontal_enemies_screen_address_high &34b5 e9 00 SBC #&00 &34b7 99 44 00 STA &0044,Y ; horizontal_enemies_screen_address_high &34ba 60 RTS ; write_object_name # Called with Y = x, X = y, A = object &34bb 48 PHA ; tmp_a &34bc a9 1f LDA #&1f &34be 20 ee ff JSR &ffee ; OSWRCH # TAB(Y, X) &34c1 98 TYA &34c2 20 ee ff JSR &ffee ; OSWRCH &34c5 8a TXA &34c6 20 ee ff JSR &ffee ; OSWRCH &34c9 68 PLA ; tmp_a &34ca f0 12 BEQ &34de ; is_null &34cc c9 3e CMP #&3e ; OBJECT_BOTTLE &34ce d0 0b BNE &34db ; not_salt &34d0 a6 a0 LDX &a0 ; bottle_contains_salt # Non-zero if bottle contains salt &34d2 e0 00 CPX #&00 &34d4 f0 05 BEQ &34db ; not_salt &34d6 a0 18 LDY #&18 ; &0b1b - &0b13 ; "salt" &34d8 4c e4 34 JMP &34e4 ; use_offset ; not_salt &34db 38 SEC &34dc e9 26 SBC #&26 ; OBJECT_KEY_ONE - 2 # Use &26 for OBJECT_NONE ; is_null &34de 85 33 STA &33 ; offset &34e0 0a ASL A &34e1 65 33 ADC &33 ; offset &34e3 a8 TAY ; use_offset &34e4 a2 06 LDX #&06 ; write_object_name_loop &34e6 b9 03 0b LDA &0b03,Y ; object_names &34e9 20 ee ff JSR &ffee ; OSWRCH &34ec c8 INY &34ed ca DEX &34ee d0 f6 BNE &34e6 ; write_object_name_loop &34f0 60 RTS ; apply_y_velocity &34f1 a5 3c LDA &3c ; sprite_y &34f3 18 CLC &34f4 65 40 ADC &40 ; y_velocity &34f6 85 3c STA &3c ; sprite_y &34f8 a5 40 LDA &40 ; y_velocity &34fa 30 1b BMI &3517 ; move_up_two_rows &34fc a5 3e LDA &3e ; sprite_screen_address_low ; move_down_two_rows &34fe 29 07 AND #&07 &3500 c9 05 CMP #&05 &3502 10 05 BPL &3509 ; next_group &3504 e6 3e INC &3e ; sprite_screen_address_low # Move down two rows &3506 e6 3e INC &3e ; sprite_screen_address_low &3508 60 RTS ; next_group &3509 18 CLC &350a a5 3e LDA &3e ; sprite_screen_address_low &350c 69 7a ADC #&7a # Move down a group &350e 85 3e STA &3e ; sprite_screen_address_low &3510 a5 3f LDA &3f ; sprite_screen_address_high &3512 69 02 ADC #&02 &3514 85 3f STA &3f ; sprite_screen_address_high &3516 60 RTS ; move_up_two_rows &3517 a5 3e LDA &3e ; sprite_screen_address_low &3519 29 07 AND #&07 &351b c9 02 CMP #&02 &351d 30 05 BMI &3524 ; previous_group &351f c6 3e DEC &3e ; sprite_screen_address_low # Move up two rows &3521 c6 3e DEC &3e ; sprite_screen_address_low &3523 60 RTS ; previous_group &3524 38 SEC &3525 a5 3e LDA &3e ; sprite_screen_address_low &3527 e9 7a SBC #&7a # Move up a group &3529 85 3e STA &3e ; sprite_screen_address_low &352b a5 3f LDA &3f ; sprite_screen_address_high &352d e9 02 SBC #&02 &352f 85 3f STA &3f ; sprite_screen_address_high &3531 60 RTS ; plot_or_unplot_diagonal_enemy &3532 a9 01 LDA #&01 &3534 85 41 STA &41 ; sprite_height &3536 ad 21 12 LDA &1221 ; diagonal_enemies_type &3539 c9 02 CMP #&02 ; DIAGONAL_ENEMY_BUTTERFLY &353b f0 07 BEQ &3544 ; is_default_height ; is_bat_whirligig_or_jellyfish &353d ad 22 12 LDA &1222 ; offset_of_last_diagonal_enemy &3540 c9 02 CMP #&02 &3542 10 03 BPL &3547 ; is_half_height ; is_default_height &3544 20 43 33 JSR &3343 ; use_default_sprite_size ; is_half_height &3547 a2 08 LDX #&08 ; SPRITE_DIAGONAL_ENEMY_FRAME_ONE &3549 b9 68 00 LDA &0068,Y ; diagonal_enemies_x &354c 6a ROR A &354d 6a ROR A &354e b0 02 BCS &3552 ; use_frame_one # Animate diagonal enemies based on x position ; ue_frame_two &3550 a2 0a LDX #&0a ; SPRITE_DIAGONAL_ENEMY_FRAME_TWO ; use_frame_one &3552 20 58 35 JSR &3558 ; use_diagonal_enemy_screen_address &3555 4c c5 32 JMP &32c5 ; plot_sprite ; use_diagonal_enemy_screen_address &3558 b9 48 00 LDA &0048,Y ; diagonal_enemies_screen_address_high &355b 85 7d STA &7d ; screen_address_high &355d b9 47 00 LDA &0047,Y ; diagonal_enemies_screen_address_low &3560 85 7c STA &7c ; screen_address_low &3562 60 RTS ; update_diagonal_enemies &3563 ac 22 12 LDY &1222 ; offset_of_last_diagonal_enemy ; update_diagonal_enemies_loop &3566 a5 61 LDA &61 ; plotting_or_updating_enemies # Zero if plotting, non-zero if updating &3568 f0 03 BEQ &356d ; skip_unplotting &356a 20 32 35 JSR &3532 ; plot_or_unplot_diagonal_enemy # Unplot diagonal enemy ; skip_unplotting &356d ad 21 12 LDA &1221 ; diagonal_enemies_type # Zero if DIAGONAL_ENEMY_TYPE_BAT &3570 f0 1b BEQ &358d ; update_bat &3572 c9 02 CMP #&02 ; DIAGONAL_ENEMY_TYPE_BUTTERFLY &3574 d0 11 BNE &3587 ; update_whirligig_or_jellyfish ; update_butterfly &3576 20 fa 35 JSR &35fa ; move_butterfly &3579 20 ed 36 JSR &36ed ; check_if_diagonal_enemy_at_minimum_or_maximum_y &357c 20 a1 36 JSR &36a1 ; check_if_diagonal_enemy_at_minimum_or_maximum_x &357f 20 e8 35 JSR &35e8 ; check_if_diagonal_enemy_near_player # Returns carry set if near player &3582 90 2a BCC &35ae ; skip_moving_towards_player &3584 4c 93 35 JMP &3593 ; move_towards_player_if_carry_clear ; update_whirligig_or_jellyfish &3587 20 c2 35 JSR &35c2 ; check_edges_of_enemy_for_obstacles # Returns carry set if near player &358a 4c 93 35 JMP &3593 ; move_towards_player_if_carry_clear ; update_bat &358d 20 7f 36 JSR &367f ; use_diagonal_enemy_x_and_y &3590 20 03 22 JSR &2203 ; to_check_if_near_player_fixed_distance # Returns carry set if near player ; move_towards_player_if_carry_clear &3593 90 0d BCC &35a2 ; not_near_player ; is_near_player &3595 a5 31 LDA &31 ; homing_x_velocity &3597 99 3a 12 STA &123a,Y ; diagonal_enemies_x_velocity &359a a5 32 LDA &32 ; homing_y_velocity &359c 99 3b 12 STA &123b,Y ; diagonal_enemies_y_velocity &359f 4c a5 35 JMP &35a5 ; skip_minimum_or_maximum_x_check ; not_near_player &35a2 20 a1 36 JSR &36a1 ; check_if_diagonal_enemy_at_minimum_or_maximum_x ; skip_minimum_or_maximum_x_check &35a5 20 ed 36 JSR &36ed ; check_if_diagonal_enemy_at_minimum_or_maximum_y &35a8 20 ba 36 JSR &36ba ; apply_x_velocity_to_diagonal_enemy &35ab 20 08 37 JSR &3708 ; apply_y_velocity_to_diagonal_enemy ; skip_moving_towards_player &35ae 20 7f 36 JSR &367f ; use_diagonal_enemy_x_and_y &35b1 a9 10 LDA #&10 &35b3 85 41 STA &41 ; sprite_height &35b5 20 06 22 JSR &2206 ; to_lose_energy_if_touching_enemy # Lose energy for touching diagonal enemy &35b8 20 32 35 JSR &3532 ; plot_or_unplot_diagonal_enemy # Plot diagonal enemy &35bb 88 DEY &35bc 88 DEY &35bd 10 a7 BPL &3566 ; update_diagonal_enemies_loop &35bf 4c 25 34 JMP &3425 ; reset_double_sprite ; check_edges_of_enemy_for_obstacles &35c2 20 2e 36 JSR &362e ; check_left_of_enemy_for_obstacle # Returns carry set if obstacle &35c5 90 06 BCC &35cd ; no_obstacle_to_left &35c7 20 af 36 JSR &36af ; set_diagonal_enemy_moving_right &35ca 4c d5 35 JMP &35d5 ; check_top_and_bottom_of_enemy_for_obstacles ; no_obstacle_to_left &35cd 20 3e 36 JSR &363e ; check_right_of_enemy_for_obstacle # Returns carry set if obstacle &35d0 90 03 BCC &35d5 ; no_obstacle_to_right &35d2 20 b5 36 JSR &36b5 ; set_diagonal_enemy_moving_left ; no_obstacle_to_right ; check_top_and_bottom_of_enemy_for_obstacles &35d5 20 4e 36 JSR &364e ; check_above_enemy_for_obstacle # Returns carry set if obstacle &35d8 90 06 BCC &35e0 ; no_obstacle_above &35da 20 fd 36 JSR &36fd ; set_diagonal_enemy_moving_down &35dd 4c e8 35 JMP &35e8 ; check_if_diagonal_enemy_near_player ; no_obstacle_above &35e0 20 59 36 JSR &3659 ; check_below_of_enemy_for_obstacle # Returns carry set if obstacle &35e3 90 03 BCC &35e8 ; no_obstacle_below &35e5 20 03 37 JSR &3703 ; set_diagonal_enemy_moving_up ; no_obstacle_below ; check_if_diagonal_enemy_near_player &35e8 20 7f 36 JSR &367f ; use_diagonal_enemy_x_and_y &35eb a9 05 LDA #&05 &35ed 85 31 STA &31 ; width_to_check &35ef a9 01 LDA #&01 &35f1 85 32 STA &32 ; height_to_check_at_top &35f3 a9 10 LDA #&10 &35f5 85 33 STA &33 ; height_to_check_at_bottom &35f7 4c 15 22 JMP &2215 ; to_check_if_near_player_variable_distance ; move_butterfly &35fa b9 3b 12 LDA &123b,Y ; diagonal_enemies_y_velocity &35fd c9 02 CMP #&02 &35ff d0 08 BNE &3609 ; is_moving_up ; is_moving_down &3601 20 59 36 JSR &3659 ; check_below_of_enemy_for_obstacle # Returns carry set if obstacle &3604 b0 0b BCS &3611 ; move_butterfly_horizontally &3606 4c 08 37 JMP &3708 ; apply_y_velocity_to_diagonal_enemy ; is_moving_up &3609 20 4e 36 JSR &364e ; check_above_enemy_for_obstacle # Returns carry set if obstacle &360c b0 03 BCS &3611 ; move_butterfly_horizontally &360e 4c 08 37 JMP &3708 ; apply_y_velocity_to_diagonal_enemy ; move_butterfly_horizontally &3611 b9 3a 12 LDA &123a,Y ; diagonal_enemies_x_velocity &3614 c9 01 CMP #&01 &3616 d0 0b BNE &3623 ; is_moving_left ; is_moving_right &3618 20 3e 36 JSR &363e ; check_right_of_enemy_for_obstacle # Returns carry set if obstacle &361b 90 03 BCC &3620 ; to_apply_x_velocity_to_diagonal_enemy &361d 20 b5 36 JSR &36b5 ; set_diagonal_enemy_moving_left ; to_apply_x_velocity_to_diagonal_enemy &3620 4c ba 36 JMP &36ba ; apply_x_velocity_to_diagonal_enemy ; is_moving_left &3623 20 2e 36 JSR &362e ; check_left_of_enemy_for_obstacle # Returns carry set if obstacle &3626 90 f8 BCC &3620 ; to_apply_x_velocity_to_diagonal_enemy &3628 20 af 36 JSR &36af ; set_diagonal_enemy_moving_right &362b 4c 20 36 JMP &3620 ; to_apply_x_velocity_to_diagonal_enemy ; check_left_of_enemy_for_obstacle &362e b9 47 00 LDA &0047,Y ; diagonal_enemies_screen_address_low &3631 38 SEC &3632 e9 08 SBC #&08 # Move left four pixels &3634 85 7c STA &7c ; screen_address_low &3636 b9 48 00 LDA &0048,Y ; diagonal_enemies_screen_address_high &3639 e9 00 SBC #&00 &363b 4c 8b 36 JMP &368b ; check_column_of_enemy_for_obstacle ; check_right_of_enemy_for_obstacle &363e b9 47 00 LDA &0047,Y ; diagonal_enemies_screen_address_low &3641 18 CLC &3642 69 20 ADC #&20 # Move right sixteen pixels &3644 85 7c STA &7c ; screen_address_low &3646 b9 48 00 LDA &0048,Y ; diagonal_enemies_screen_address_high &3649 69 00 ADC #&00 &364b 4c 8b 36 JMP &368b ; check_column_of_enemy_for_obstacle ; check_above_enemy_for_obstacle &364e 20 58 35 JSR &3558 ; use_diagonal_enemy_screen_address &3651 98 TYA &3652 48 PHA ; tmp_y &3653 20 0f 22 JSR &220f ; to_check_row_above_for_obstacle # Returns carry set if obstacle &3656 68 PLA ; tmp_y &3657 a8 TAY &3658 60 RTS # Leave with carry set if obstacle ; check_below_of_enemy_for_obstacle &3659 b9 47 00 LDA &0047,Y ; diagonal_enemies_screen_address_low &365c a6 6c LDX &6c ; double_sprite # Non-zero if sprite doubled vertically &365e d0 14 BNE &3674 ; is_double_height &3660 18 CLC &3661 69 80 ADC #&80 ; &280 # Move down a group &3663 85 7c STA &7c ; screen_address_low &3665 b9 48 00 LDA &0048,Y ; diagonal_enemies_screen_address_high &3668 69 02 ADC #&02 ; check_below_of_enemy_for_obstacle_loop &366a 85 7d STA &7d ; screen_address_high &366c 98 TYA &366d 48 PHA ; tmp_y &366e 20 09 22 JSR &2209 ; to_check_row_for_obstacle # Returns carry set if obstacle &3671 68 PLA ; tmp_y &3672 a8 TAY &3673 60 RTS # Leave with carry set if obstacle ; is_double_height &3674 18 CLC &3675 85 7c STA &7c ; screen_address_low &3677 b9 48 00 LDA &0048,Y ; diagonal_enemies_screen_address_high &367a 69 05 ADC #&05 ; &500 # Move down two groups &367c 4c 6a 36 JMP &366a ; check_below_of_enemy_for_obstacle_loop ; use_diagonal_enemy_x_and_y &367f b9 68 00 LDA &0068,Y ; diagonal_enemies_x &3682 85 11 STA &11 ; sprite_x &3684 b9 31 12 LDA &1231,Y ; diagonal_enemies_y &3687 4a LSR A &3688 85 3c STA &3c ; sprite_y &368a 60 RTS ; check_column_of_enemy_for_obstacle &368b 85 7d STA &7d ; screen_address_high &368d a9 08 LDA #&08 &368f 85 41 STA &41 ; sprite_height &3691 98 TYA &3692 48 PHA ; tmp_y &3693 20 0c 22 JSR &220c ; to_check_column_for_obstacle &3696 90 06 BCC &369e ; leave_after_restoring_y # Leave with carry clear to indicate no obstacle ; is_obstacle &3698 a9 04 LDA #&04 &369a 20 4c 33 JSR &334c ; play_sound_on_channel_zero # Play sound for enemy hitting obstacle &369d 38 SEC # Leave with carry set to indicate obstacle ; leave_after_restoring_y &369e 68 PLA ; tmp_y &369f a8 TAY &36a0 60 RTS ; check_if_diagonal_enemy_at_minimum_or_maximum_x &36a1 b9 68 00 LDA &0068,Y ; diagonal_enemies_x &36a4 cd 36 12 CMP &1236 ; diagonal_enemies_minimum_x &36a7 30 06 BMI &36af ; set_moving_right &36a9 cd 35 12 CMP &1235 ; diagonal_enemies_maximum_x &36ac 10 07 BPL &36b5 ; set_diagonal_enemy_moving_left &36ae 60 RTS ; set_diagonal_enemy_moving_right &36af a9 01 LDA #&01 ; set_diagonal_enemy_x_velocity &36b1 99 3a 12 STA &123a,Y ; diagonal_enemies_x_velocity &36b4 60 RTS ; set_diagonal_enemy_moving_left &36b5 a9 ff LDA #&ff &36b7 4c b1 36 JMP &36b1 ; set_diagonal_enemy_x_velocity ; apply_x_velocity_to_diagonal_enemy &36ba b9 68 00 LDA &0068,Y ; diagonal_enemies_x &36bd 18 CLC &36be 79 3a 12 ADC &123a,Y ; diagonal_enemies_x_velocity &36c1 99 68 00 STA &0068,Y ; diagonal_enemies_x &36c4 b9 3a 12 LDA &123a,Y ; diagonal_enemies_x_velocity &36c7 30 12 BMI &36db ; is_moving_right ; is_moving_left &36c9 18 CLC &36ca b9 47 00 LDA &0047,Y ; diagonal_enemies_screen_address_low &36cd 69 08 ADC #&08 # Move right four pixels &36cf 99 47 00 STA &0047,Y ; diagonal_enemies_screen_address_low &36d2 b9 48 00 LDA &0048,Y ; diagonal_enemies_screen_address_high &36d5 69 00 ADC #&00 &36d7 99 48 00 STA &0048,Y ; diagonal_enemies_screen_address_high &36da 60 RTS ; is_moving_right &36db 38 SEC &36dc b9 47 00 LDA &0047,Y ; diagonal_enemies_screen_address_low &36df e9 08 SBC #&08 # Move left four pixels &36e1 99 47 00 STA &0047,Y ; diagonal_enemies_screen_address_low &36e4 b9 48 00 LDA &0048,Y ; diagonal_enemies_screen_address_high &36e7 e9 00 SBC #&00 &36e9 99 48 00 STA &0048,Y ; diagonal_enemies_screen_address_high &36ec 60 RTS ; check_if_diagonal_enemy_at_minimum_or_maximum_y &36ed b9 31 12 LDA &1231,Y ; diagonal_enemies_y &36f0 29 fe AND #&fe &36f2 cd 37 12 CMP &1237 ; diagonal_enemies_minimum_y &36f5 f0 06 BEQ &36fd ; set_diagonal_enemy_moving_down &36f7 cd 38 12 CMP &1238 ; diagonal_enemies_maximum_y &36fa f0 07 BEQ &3703 ; set_diagonal_enemy_moving_up &36fc 60 RTS ; set_diagonal_enemy_moving_down &36fd a9 02 LDA #&02 ; set_diagonal_enemy_y_velocity &36ff 99 3b 12 STA &123b,Y ; diagonal_enemies_y_velocity &3702 60 RTS ; set_diagonal_enemy_moving_up &3703 a9 fe LDA #&fe &3705 4c ff 36 JMP &36ff ; set_diagonal_enemy_y_velocity ; apply_y_velocity_to_diagonal_enemy &3708 b9 31 12 LDA &1231,Y ; diagonal_enemies_y &370b 85 3c STA &3c ; sprite_y &370d b9 3b 12 LDA &123b,Y ; diagonal_enemies_y_velocity &3710 85 40 STA &40 ; y_velocity &3712 b9 47 00 LDA &0047,Y ; diagonal_enemies_screen_address_low &3715 85 3e STA &3e ; sprite_screen_address_low &3717 b9 48 00 LDA &0048,Y ; diagonal_enemies_screen_address_high &371a 85 3f STA &3f ; sprite_screen_address_high &371c 20 f1 34 JSR &34f1 ; apply_y_velocity_to_sprite &371f a5 3c LDA &3c ; sprite_y &3721 99 31 12 STA &1231,Y ; diagonal_enemies_y &3724 a5 3e LDA &3e ; sprite_screen_address_low &3726 99 47 00 STA &0047,Y ; diagonal_enemies_screen_address_low &3729 a5 3f LDA &3f ; sprite_screen_address_high &372b 99 48 00 STA &0048,Y ; diagonal_enemies_screen_address_high &372e 60 RTS ; move_feature_four_pixels_to_right &372f a9 04 LDA #&04 &3731 85 32 STA &32 ; groups_remaining ; move_feature_four_pixels_to_right_group_loop &3733 a9 08 LDA #&08 &3735 85 31 STA &31 ; bytes_remaining ; move_feature_four_pixels_to_right_column_loop &3737 a2 08 LDX #&08 &3739 a0 38 LDY #&38 ; move_feature_four_pixels_to_right_byte_loop &373b b1 7c LDA (&7c),Y ; screen_address &373d 48 PHA ; screen byte &373e 98 TYA &373f 18 CLC &3740 69 08 ADC #&08 # Move right four pixels &3742 a8 TAY &3743 68 PLA ; screen_byte &3744 91 7c STA (&7c),Y ; screen_address &3746 38 SEC &3747 98 TYA &3748 e9 10 SBC #&10 # Move left eight pixels &374a a8 TAY &374b ca DEX &374c d0 ed BNE &373b ; move_feature_four_pixels_to_right_byte_loop &374e a9 00 LDA #&00 &3750 a8 TAY &3751 91 7c STA (&7c),Y ; screen_address &3753 e6 7c INC &7c ; screen_address_low &3755 d0 02 BNE &3759 ; skip_page &3757 e6 7d INC &7d ; screen_address_high ; skip_page &3759 c6 31 DEC &31 ; columns_remaining &375b d0 da BNE &3737 ; move_feature_four_pixels_to_right_byte_loop &375d 18 CLC &375e a5 7c LDA &7c ; screen_address_low &3760 69 78 ADC #&78 # Move down a group &3762 85 7c STA &7c ; screen_address_low &3764 a5 7d LDA &7d ; screen_address_high &3766 69 02 ADC #&02 &3768 85 7d STA &7d ; screen_address_high &376a c6 32 DEC &32 ; groups_remaining &376c d0 c5 BNE &3733 ; move_feature_four_pixels_to_right_group_loop &376e 60 RTS ; update_time &376f a9 00 LDA #&00 &3771 85 6d STA &6d ; time_needs_replotting # Set to zero to indicate time doesn't need replotting &3773 f8 SED &3774 18 CLC &3775 ad c3 32 LDA &32c3 ; time_minutes &3778 69 01 ADC #&01 &377a 8d c3 32 STA &32c3 ; time_minutes &377d c9 60 CMP #&60 &377f d0 0e BNE &378f ; skip_overflow &3781 a9 00 LDA #&00 &3783 8d c3 32 STA &32c3 ; time_minutes &3786 18 CLC &3787 ad c4 32 LDA &32c4 ; time_hours &378a 69 01 ADC #&01 &378c 8d c4 32 STA &32c4 ; time_hours ; skip_overflow &378f d8 CLD &3790 ad c3 32 LDA &32c3 ; time_minutes &3793 d0 05 BNE &379a ; not_00_minutes ; is_00_minutes &3795 a9 0c LDA #&0c ; TILE_OPEN_DOOR, EVENT_OPENING_DOOR &3797 4c a0 37 JMP &37a0 ; update_chapel_door ; not_00_minutes &379a c9 01 CMP #&01 &379c d0 17 BNE &37b5 ; skip_updating_chapel_door ; is_01_minutes &379e a9 14 LDA #&14 ; TILE_CLOSED_DOOR, EVENT_CLOSING_DOOR ; update_chapel_door &37a0 a6 90 LDX &90 ; player_room_x &37a2 e0 06 CPX #&06 &37a4 d0 0c BNE &37b2 ; set_chapel_door_tile &37a6 a6 8f LDX &8f ; player_room_y &37a8 e0 00 CPX #&00 &37aa d0 06 BNE &37b2 ; set_chapel_door_tile # Is the player in room (0, 6), left of the Chapel? &37ac 8d 42 12 STA &1242 ; game_event # If so, animate opening or closing of door &37af 4c b5 37 JMP &37b5 ; skip_updating_chapel_door_tile ; set_chapel_door_tile # Otherwise, just change the tile &37b2 8d 42 38 STA &3842 ; tile_data + 0 * &78 + 2 * &28 + 6 * &05 + 4 (room (6, 0), tile (4, 2)) ; skip_updating_chapel_door_tile &37b5 20 56 32 JSR &3256 ; write_string &37b8 1f 01 04 ; TAB(&01, &04) &37bb 00 ; end of string &37bc ad c4 32 LDA &32c4 ; time_hours &37bf 20 a9 0b JSR &0ba9 ; write_two_digit_number &37c2 a9 09 LDA #&09 ; move cursor right one character &37c4 20 ee ff JSR &ffee ; OSWRCH &37c7 ad c3 32 LDA &32c3 ; time_minutes &37ca 4c a9 0b JMP &0ba9 ; write_two_digit_number ; unused &37cd 00 00 00 ; tile_data ; y:0 x:0 x:1 x:2 x:3 x:4 x:5 x:6 x:7 &37d0 1b 5d 19 1b 1d e0 d5 c5 d3 d4 02 5d 5d 5d 02 1a 13 13 13 1a 53 53 53 53 53 38 3f 78 3e 38 38 00 00 00 3a 18 45 2c 46 19 &37f8 45 3b 46 45 02 02 59 0d 0d 0d 30 00 12 12 30 30 53 53 53 30 30 13 1f 13 13 27 78 0d 78 27 2d 3e 38 38 1a 1a 00 00 00 46 &3820 04 17 00 06 1a 02 05 58 1a 59 13 06 45 00 46 45 30 30 46 02 02 34 0f 10 05 06 32 02 32 05 12 12 12 2c 0c 0c 12 12 3a 3f ; y:1 x:0 x:1 x:2 x:3 x:4 x:5 x:6 x:7 &3848 31 0e 00 02 4d 30 30 06 59 38 18 59 00 00 03 05 58 02 05 58 7e 1e 78 7f 1a 05 00 00 00 00 00 12 12 06 1a 59 52 22 3e 7f &3870 31 0e 00 02 03 02 78 4f 06 59 13 00 06 59 06 59 34 18 02 05 06 15 15 05 02 02 05 1f 52 05 06 45 29 46 7e 00 00 00 3b 3f &3898 31 1a 00 04 03 02 0f 33 59 06 10 01 02 00 06 05 58 59 33 58 0e 53 53 0e 02 1a 02 05 3d 12 4d 3d 3d 3d 31 05 56 06 02 02 ; y:2 x:0 x:1 x:2 x:3 x:4 x:5 x:6 x:7 &38c0 04 0e 05 00 06 02 02 59 06 59 1f 58 02 00 00 58 05 06 59 33 38 3f 02 59 58 1a 45 21 46 1a 05 30 30 30 03 02 02 59 21 58 &38e8 04 0e 31 34 1f 13 58 31 0e 31 05 00 00 00 03 05 58 59 06 02 02 0b 12 38 00 4f 4f 4f 4f 4f 58 59 58 59 12 12 02 39 02 03 &3910 04 0c 0d 0c 0c 4d 04 53 53 0d 0d 32 32 0a 32 02 05 34 0f 39 39 53 13 30 18 19 0f 0f 0f 0f 38 18 19 06 02 1a 30 30 4d 06 ; y:3 x:0 x:1 x:2 x:3 x:4 x:5 x:6 x:7 &3938 04 02 1a 02 02 31 04 58 02 02 59 58 02 02 4d 0c 1f 17 13 00 00 bc 8f bc 8f 13 2a 3b 1f 13 1e 00 00 58 02 02 2d 58 05 46 &3960 04 04 12 12 12 12 1a 04 58 02 04 00 3b 13 03 3e 0f 34 0f 10 05 8f bc 8f 12 06 02 02 02 05 06 15 15 05 02 02 73 74 58 03 &3988 04 05 74 0d 0d 0c 0c 00 05 58 05 00 45 06 10 02 02 02 02 0c 4d 12 18 1a 02 0e 26 0e 25 0e 02 53 53 02 02 02 02 02 38 03 ; y:4 x:0 x:1 x:2 x:3 x:4 x:5 x:6 x:7 &39b0 31 59 1f 13 12 12 12 06 02 05 12 06 05 13 7f 59 13 13 13 58 05 58 02 1f 58 59 35 78 35 58 59 3b 1f 00 3b 00 78 02 17 03 &39d8 31 12 0c 13 13 52 00 00 52 00 00 13 13 06 31 2d 7a 00 7a 03 02 05 58 00 39 35 75 35 75 35 06 17 00 00 17 00 06 02 00 0a &3a00 31 02 02 10 10 32 32 32 32 32 01 01 01 02 31 19 12 02 3a 18 02 02 19 06 02 1a 35 75 35 1a 02 17 38 38 17 06 02 02 3e 46 ; y:5 x:0 x:1 x:2 x:3 x:4 x:5 x:6 x:7 &3a28 05 0c 73 74 0c 0c 13 0e 13 13 13 53 79 1a 03 00 18 02 19 00 3e 37 37 38 1f 2d 73 18 02 02 02 02 02 02 02 59 17 58 59 03 &3a50 02 02 1a 02 02 02 00 0e 00 10 3e 30 53 53 3f 18 59 20 58 19 3e 36 38 37 7f 05 24 02 02 59 13 13 00 00 02 06 17 03 04 0a &3a78 04 00 00 12 0d 0d 12 1a 12 30 30 0f 30 53 39 02 39 02 39 39 39 37 38 06 02 1a 05 02 39 02 39 39 01 01 0e 02 33 31 31 0e ; y:6 x:0 x:1 x:2 x:3 x:4 x:5 x:6 x:7 &3aa0 04 00 33 02 02 59 78 78 58 02 6e 13 13 13 39 02 37 00 00 03 1a 05 13 30 30 30 46 1f 13 13 21 4f 4f 4f 02 06 59 06 05 58 &3ac8 04 34 0c 02 12 06 32 32 05 58 04 7a 00 7a 03 02 2e 00 3b 02 59 58 2e 0d 58 04 06 00 06 05 12 00 00 00 0e 58 19 58 59 18 &3af0 02 02 02 02 02 45 52 1f 46 31 19 3a 02 3a 18 02 02 2e 02 02 19 2e 0c 0d 18 05 03 05 00 1a 27 32 32 32 1a 00 58 19 18 59 ; y:7 x:0 x:1 x:2 x:3 x:4 x:5 x:6 x:7 &3b18 59 13 13 13 0c 0c 46 3b 00 06 59 2d 00 58 2e 00 77 77 77 58 59 00 75 1f 58 04 06 02 05 13 13 30 30 13 1a 14 4d 12 12 14 &3b40 04 7a 7a 7a 03 02 34 46 05 03 19 87 86 38 18 19 12 37 36 18 19 38 35 00 03 05 30 4d 02 03 10 79 74 39 02 14 12 52 14 14 &3b68 19 3a 02 3a 18 02 02 33 00 06 02 19 38 02 0d 0d 0d 12 38 39 39 39 39 39 02 02 02 05 00 06 02 39 39 73 0c 0c 0c 0d 0c 14 ; y:8 x:0 x:1 x:2 x:3 x:4 x:5 x:6 x:7 &3b90 b0 b2 a1 b9 0c 30 2b 04 37 36 36 36 36 37 36 36 1a 7e 38 36 36 79 1a 38 36 36 79 00 06 02 04 13 13 13 09 00 3a 13 13 58 &3bb8 59 a1 b4 58 02 3e 37 31 79 36 36 36 37 36 36 36 3f 31 79 36 36 39 39 37 36 36 38 06 02 1a 04 7a 7a 1b 1c 05 7a 3d 3d 3d &3be0 ae af af ae 02 1a 00 31 3e 36 36 1a 38 79 36 36 39 00 36 36 36 39 03 37 36 36 39 12 0c 12 12 56 1b 1c 1c 13 13 13 13 13 ; y:9 x:0 x:1 x:2 x:3 x:4 x:5 x:6 x:7 &3c08 18 45 46 19 00 04 37 3e 6d 36 36 38 58 36 36 36 36 36 37 36 36 38 36 36 36 36 79 04 1f 04 00 00 12 02 02 e0 d5 c5 d3 d4 &3c30 59 00 28 58 19 1a 37 36 36 36 36 36 36 38 38 38 04 38 36 1a 02 23 3b 23 02 02 2e 04 04 31 10 39 12 38 03 7e 78 7f 78 7f &3c58 1a 16 05 53 30 30 02 02 3e 36 36 36 36 36 36 36 36 36 36 38 38 06 1a 05 02 02 38 38 3e 3f 02 3d 12 3d 06 3e 38 3f 38 3f ; status_section_screen_data # Screen memory starts at &3c80 &3c80 f0 f0 f0 f0 f0 f0 f0 f0 f0 ee ee ee ee ee ee ee &3c90 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 &3ca0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 &3cb0 f0 30 30 30 30 30 30 30 f0 88 88 88 88 88 88 88 &3cc0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 &3cd0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 &3ce0 f0 f0 f0 f0 f0 f0 f0 f0 f0 ee ee ee ee ee ee f0 &3cf0 f0 00 00 00 00 00 00 f0 f0 00 00 00 00 00 00 f0 &3d00 f0 00 00 00 00 00 00 f0 f0 00 00 00 00 00 00 f0 &3d10 f0 00 00 00 00 00 00 f0 f0 00 00 00 00 00 00 f0 &3d20 f0 00 00 00 00 00 00 f0 f0 00 00 00 00 00 00 f0 &3d30 f0 00 00 00 00 00 00 f0 f0 00 00 00 00 00 00 f0 &3d40 f0 00 00 00 00 00 00 f0 f0 00 00 00 00 00 00 f0 &3d50 f0 00 00 00 00 00 00 f0 f0 00 00 00 00 00 00 f0 &3d60 f0 00 00 00 00 00 00 f0 f0 00 00 00 00 00 00 f0 &3d70 f0 00 00 00 00 00 00 f0 f0 00 00 00 00 00 00 f0 &3d80 f0 00 00 00 00 00 00 f0 f0 00 00 00 00 00 00 f0 &3d90 f0 00 00 00 00 00 00 f0 f0 00 00 00 00 00 00 f0 &3da0 f0 00 00 00 00 00 00 f0 f0 00 00 00 00 00 00 f0 &3db0 f0 fc fc fc fc fc fc f0 f0 f3 f3 f3 f3 f3 f3 f3 &3dc0 f0 00 00 00 00 00 00 00 f0 00 00 00 00 00 00 00 &3dd0 f0 00 00 00 00 00 00 00 f0 00 00 00 00 00 00 00 &3de0 f0 00 00 00 00 00 00 00 f0 00 00 00 00 00 00 00 &3df0 f0 00 00 00 00 00 00 00 f0 00 00 00 00 00 00 00 &3e00 f0 00 00 00 00 00 00 00 f0 00 00 00 00 00 00 00 &3e10 f0 00 00 00 00 00 00 00 f0 00 00 00 00 00 00 00 &3e20 f0 76 76 76 76 76 76 76 f0 80 80 80 80 80 80 80 &3e30 f0 00 00 00 00 00 00 00 f0 00 00 00 00 00 00 00 &3e40 f0 00 00 00 00 00 00 00 f0 00 00 00 00 00 00 00 &3e50 f0 77 77 77 77 77 77 77 f0 f0 f0 f0 f0 f0 f0 f0 &3e60 f0 00 00 00 00 00 00 00 f0 00 00 00 00 00 00 00 &3e70 f0 00 00 00 00 00 00 00 f0 00 00 00 00 00 00 00 &3e80 f0 00 00 00 00 00 00 00 f0 00 00 00 00 00 00 00 &3e90 f0 00 00 00 00 00 00 00 f0 00 00 00 00 00 00 00 &3ea0 f0 00 00 00 00 00 00 00 f0 00 00 00 00 00 00 00 &3eb0 f0 00 00 00 00 00 00 00 f0 00 00 00 00 00 00 00 &3ec0 f0 76 76 76 76 76 76 76 f0 80 80 80 80 80 80 80 &3ed0 f0 00 00 00 00 00 00 00 f0 00 00 00 00 00 00 00 &3ee0 f0 00 00 00 00 00 00 00 f0 00 00 00 00 00 00 00 &3ef0 f0 77 77 77 77 77 77 77 f0 f0 f0 f0 f0 f0 f0 f0 &3f00 f0 f0 f0 f0 f0 f0 f0 f0 f0 f0 ff ff ef 8f 0f f0 &3f10 f0 f0 00 00 00 0f 0f f0 f0 f0 00 00 00 0f 0f f0 &3f20 f0 f0 70 70 70 78 78 f0 f0 f0 ff ff ef 8f 0f f0 &3f30 f0 f0 00 00 00 0f 0f f0 f0 f0 00 00 00 0f 0f f0 &3f40 f0 f0 f1 f1 f1 f1 e1 f0 f0 f0 ee ee ce 0f 0f f0 &3f50 f0 f0 00 00 00 0f 0f f0 f0 f0 00 00 00 0f 0f f0 &3f60 f0 f0 f0 f0 f0 f0 f0 f0 ee ee ee ee ee ee ee f0 &3f70 00 00 00 00 00 00 00 f0 00 00 00 00 00 00 00 f0 &3f80 00 00 00 00 00 00 00 f0 00 00 00 00 00 00 00 f0 &3f90 00 00 00 00 00 00 00 f0 10 10 10 10 10 10 10 f0 &3fa0 f0 f0 f0 f0 f0 f0 f0 f0 ee ee ee ee ee ee ee f0 &3fb0 00 00 00 00 00 00 00 f0 00 00 00 00 00 00 00 f0 &3fc0 00 00 00 00 00 00 00 f0 00 00 00 00 00 00 00 f0 &3fd0 00 00 00 00 00 00 00 f0 00 00 00 00 00 00 00 f0 &3fe0 00 00 00 00 00 00 00 f0 00 00 00 00 00 00 00 f0 &3ff0 00 00 00 00 00 00 00 f0 00 00 00 00 00 00 00 f0 &4000 00 00 00 00 00 00 00 f0 00 00 00 00 00 00 00 f0 &4010 00 00 00 00 00 00 00 f0 00 00 00 00 00 00 00 f0 &4020 00 00 00 00 00 00 00 f0 00 00 00 00 00 00 00 f0 &4030 f0 87 84 84 87 84 87 f0 f0 04 04 06 06 05 04 f0 &4040 f0 0b 0a 0a 0b 0a 0b f0 f0 0b 02 02 0b 02 0a f0 &4050 f0 0c 05 05 0d 09 0c f0 f0 0e 00 00 06 02 0e f0 &4060 f0 08 08 05 02 02 02 f0 f0 38 38 30 30 30 30 f0 &4070 f0 00 00 00 00 00 00 f0 f0 00 00 00 00 00 00 f0 &4080 f0 00 00 00 00 00 00 f0 f0 00 00 00 00 00 00 f0 &4090 f0 00 00 00 00 00 00 f0 f0 00 00 00 00 00 00 f0 &40a0 f0 00 00 00 00 00 00 f0 f0 00 00 00 00 00 00 f0 &40b0 f0 00 00 00 00 00 00 f0 f0 00 00 00 00 00 00 f0 &40c0 f0 00 00 00 00 00 00 f0 f0 00 00 00 00 00 00 f0 &40d0 f0 00 00 00 00 00 00 f0 f0 00 00 00 00 00 00 f0 &40e0 f0 00 00 00 00 00 00 f0 f0 00 00 00 00 00 00 f0 &40f0 f0 00 00 00 00 00 00 f0 f0 00 00 00 00 00 00 f0 &4100 f0 00 00 00 00 00 00 f0 f0 00 00 00 00 00 00 f0 &4110 f0 00 00 00 00 00 00 f0 f0 00 00 00 00 00 00 f0 &4120 f0 00 00 00 00 00 00 f0 f0 00 00 00 00 00 00 f0 &4130 f0 00 00 00 00 00 00 f0 f0 00 00 00 00 00 00 f0 &4140 f0 00 00 00 00 00 00 f0 f0 00 00 00 00 00 00 f0 &4150 f0 00 00 00 00 00 00 f0 f0 00 00 00 00 00 00 f0 &4160 f0 00 00 00 00 00 00 f0 f0 00 00 00 00 00 00 f0 &4170 f0 77 77 77 77 77 77 f0 f0 f0 f0 f0 f0 f0 f0 f0 ; entry_point &5980 20 89 59 JSR &5989 ; relocate_data &5983 20 ed 59 JSR &59ed ; initialise_vectors_and_interrupts &5986 4c 00 0b JMP &0b00 ; to_reset_game ; relocate_data &5989 a9 00 LDA #&00 ; &1d00 &598b 85 7a STA &7a ; source_address_low &598d a9 1d LDA #&1d &598f 85 7b STA &7b ; source_address_high &5991 a9 00 LDA #&00 ; &0400 &5993 85 7c STA &7c ; target_address_low &5995 a9 04 LDA #&04 &5997 85 7d STA &7d ; target_address_high &5999 a0 00 LDY #&00 ; move_1d00_to_25ff_loop # Move &1d00 - &25ff to &0400 - &0cff &599b b1 7a LDA (&7a),Y ; source_address &599d 91 7c STA (&7c),Y ; target_address &599f e6 7a INC &7a ; source_address_low &59a1 d0 02 BNE &59a5 ; skip_page_source &59a3 e6 7b INC &7b ; source_address_high ; skip_page_source &59a5 e6 7c INC &7c ; target_address_low &59a7 d0 02 BNE &59ab ; skip_page_target &59a9 e6 7d INC &7d ; target_address_high ; skip_page_target &59ab a5 7b LDA &7b ; source_address_high &59ad c9 26 CMP #&26 &59af f0 03 BEQ &59b4 ; move_2600_to_5aff &59b1 4c 9b 59 JMP &599b ; move_1d00_to_25ff_loop ; move_2600_to_5aff &59b4 a9 00 LDA #&00 ; &2600 &59b6 85 7a STA &7a ; source_address_low &59b8 a9 26 LDA #&26 &59ba 85 7b STA &7b ; source_address_high &59bc a9 00 LDA #&00 ; &0e00 &59be 85 7c STA &7c ; target_address_low &59c0 a9 0e LDA #&0e &59c2 85 7d STA &7d ; target_address_high &59c4 a0 00 LDY #&00 ; move_2600_to_5aff_loop # Move &2600 - &5aff to &0e00 - &42ff &59c6 b1 7a LDA (&7a),Y ; source_address &59c8 91 7c STA (&7c),Y ; target_address &59ca e6 7a INC &7a ; source_address_low &59cc d0 02 BNE &59d0 ; skip_page_source &59ce e6 7b INC &7b ; source_address_high ; skip_page_source &59d0 e6 7c INC &7c ; target_address_low &59d2 d0 02 BNE &59d6 ; skip_page_target &59d4 e6 7d INC &7d ; target_address_high ; skip_page_target &59d6 a5 7b LDA &7b ; source_address_high &59d8 c9 5b CMP #&5b &59da f0 03 BEQ &59df ; move_5b00_to_5baf &59dc 4c c6 59 JMP &59c6 ; move_2600_to_5aff_loop ; move_5b00_to_5baf &59df a2 00 LDX #&00 ; move_5b00_to_5baf_loop # Move &5b00 - &5baf to &0100 - &01af &59e1 bd 00 5b LDA &5b00,X &59e4 9d 00 01 STA &0100,X &59e7 e8 INX &59e8 e0 b0 CPX #&b0 &59ea d0 f5 BNE &59e1 ; move_5b00_to_5baf_loop &59ec 60 RTS ; initialise_vectors_and_interrupts &59ed a9 83 LDA #&83 ; &0b83 = event_handler &59ef 8d 20 02 STA &0220 ; event_vector_low &59f2 a9 0b LDA #&0b &59f4 8d 21 02 STA &0221 ; event_vector_high &59f7 a9 c8 LDA #&c8 ; Read/Write BREAK/ESCAPE effect &59f9 a2 02 LDX #&02 ; clear memory on BREAK &59fb 20 f4 ff JSR &fff4 ; OSBYTE &59fe a9 0e LDA #&0e ; Enable event &5a00 a2 05 LDX #&05 ; interval timer crossing zero &5a02 20 f4 ff JSR &fff4 ; OSBYTE &5a05 ad 04 02 LDA &0204 ; irq1_vector_low &5a08 8d 80 03 STA &0380 ; previous_irq1_vector_low &5a0b ad 05 02 LDA &0205 ; irq1_vector_high &5a0e 8d 81 03 STA &0381 ; previous_irq1_vector_high &5a11 78 SEI &5a12 a9 83 LDA #&83 ; &0383 = irq1_handler &5a14 8d 04 02 STA &0204 ; irq1_vector_low &5a17 a9 03 LDA #&03 &5a19 8d 05 02 STA &0205 ; irq1_vector_high &5a1c 58 CLI &5a1d a9 7f LDA #&7f # Disable all interrupts &5a1f 8d 6e fe STA &fe6e ; User VIA interrupt enable register &5a22 8d 7e fe STA &fe7e # Unnecessary code; also User VIA interrupt enable register &5a25 8d 4e fe STA &fe4e ; System VIA interrupt enable register &5a28 8d 5e fe STA &fe5e # Unnecessary code; also System VIA interrupt enable register &5a2b a9 c2 LDA #&c2 # Enable System VIA CA1 (v-sync) and timer 1 interrupts &5a2d 8d 4e fe STA &fe4e ; System VIA interrupt enable register &5a30 a9 40 LDA #&40 # Set User VIA timer 2 to one-shot mode &5a32 8d 6b fe STA &fe6b ; User VIA auxiliary control register &5a35 a9 a0 LDA #&a0 # Enable User VIA timer 2 interrupts &5a37 8d 6e fe STA &fe6e ; User VIA interrupt enable register &5a3a 60 RTS ; unused &5a3b 28 43 29 20 54 6f 6e 79 20 4f 61 6b 64 65 6e 20 ; "(C) Tony Oakden " &5a4b 31 39 38 38 2e 20 54 68 61 6e 6b 73 20 74 6f 20 ; "1988. Thanks to " &5a5b 53 68 61 77 6e 20 61 6e 64 20 41 6e 64 79 2e 54 ; "Shawn and Andy.T" &5a6b 72 65 76 6f 72 2c 20 57 61 79 6e 65 20 61 6e 64 ; "revor, Wayne and" &5a7b 20 47 61 72 79 28 70 68 79 63 61 73 74 72 69 61 ; " Gary(phycastria" &5a8b 29 50 61 72 74 69 73 20 2e 54 68 65 20 53 6b 79 ; ")Partis .The Sky" &5a9b 6c 69 6e 65 20 4d 6f 75 6e 74 61 69 6e 65 65 72 ; "line Mountaineer" &5aab 69 6e 67 20 43 6c 75 62 2e 27 53 77 69 6e 67 20 ; "ing Club.'Swing " &5abb 6f 75 74 20 53 69 73 74 65 72 20 66 6f 72 20 42 ; "out Sister for B" &5acb 72 65 61 6b 2d 6f 75 74 2e 20 41 6e 64 20 67 6f ; "reak-out. And go" &5adb 6f 64 6c 75 63 6b 20 53 61 6c 6c 79 20 77 65 72 ; "odluck Sally wer" &5aeb 65 20 65 76 65 72 20 79 6f 75 20 61 72 65 21 ; "e ever you are!" ; unused &5afa 00 00 00 00 00 00 # &5b00 - &5baf is moved to &0100 - &01af at &59e1 ; write_completion_message ; write_completion_message_loop &0100 bd 0f 01 LDA &010f,X ; completion_message &0103 5d 00 70 EOR &7000,X ; screen_memory + &14 * &280 + &180 &0106 f0 06 BEQ &010e ; leave &0108 20 ee ff JSR &ffee ; OSWRCH &010b e8 INX &010c d0 f2 BNE &0100 ; write_completion_message_loop ; leave &010e 60 RTS # &010f - &019d is decrypted using &7000 - &708e, screen memory from room (7, 8) # #7000 0f 47 67 01 00 00 00 00 ee f7 e0 c0 c1 8f 23 11 # SUBTILE_BUMP_LEFT | SUBTILE_FLIPPED_VERTICALLY #7010 dc cc 98 3c 2d 2d 48 08 f0 c3 0c 08 00 00 00 00 # SUBTILE_BUMP_RIGHT | SUBTILE_FLIPPED_VERTICALLY #7020 0f 47 67 01 00 00 00 00 ee f7 e0 c0 c1 8f 23 11 #7030 dc cc 98 3c 2d 2d 48 08 f0 c3 0c 08 00 00 00 00 #7040 0f 47 67 01 00 00 00 00 ee f7 e0 c0 c1 8f 23 11 #7050 dc cc 98 3c 2d 2d 48 08 f0 c3 0c 08 00 00 00 00 #7060 0f 47 67 01 00 00 00 00 ee f7 e0 c0 c1 8f 23 11 #7070 dc cc 98 3c 2d 2d 48 08 f0 c3 0c 08 00 00 00 00 #7080 0f 47 67 01 00 00 00 00 ee f7 e0 c0 c1 8f 23 # #010f 1f 0c 1a ; TAB(&0c, &1a) #0112 59 4f 55 20 52 45 49 4e 43 41 52 4e 41 54 45 44 ; "YOU REINCARNATED!" #0122 21 #0123 1f 05 1c ; TAB(&05, &1c) #0126 53 4f 52 52 59 2c 20 57 45 20 44 4f 4e 27 54 20 ; "SORRY, WE DON'T SERVE SPIRITS!" #0136 53 45 52 56 45 20 53 50 49 52 49 54 53 21 #0144 00 ; end of string # #0145 11 03 ; COLOUR 3 #0147 1f 02 1a ; TAB(&02, &1a) #014a 43 4f 4e 47 52 41 54 55 4c 41 54 49 4f 4e 53 20 ; "CONGRATULATIONS YOU DESERVE A DRINK," #015a 59 4f 55 20 44 45 53 45 52 56 45 20 41 20 44 52 #016a 49 4e 4b 2c #016e 1f 07 1c ; TAB(&07, &1c) #0171 42 55 54 20 44 4f 4e 27 54 20 46 4f 52 47 45 54 ; "BUT DON'T FORGET TO ENTER" #0181 20 54 4f 20 45 4e 54 45 52 #018a 1f 0c 1e ; TAB(&0c, &1e) #018d 4f 55 52 20 43 4f 4d 50 45 54 49 4f 4e 21 ; "OUR COMPETION!" #019b 11 01 ; COLOUR 1 #019d 00 ; end of string ; completion_message &010f 10 4b 7d ; TAB(&0c, &1a) &0112 58 4f 55 20 52 ab be ae 83 80 dd 6d 50 88 89 dc ; "YOU REINCARNATED!" &0122 1d &0123 32 28 54 ; TAB(&05, &1c) &0126 5b bf 91 5e 51 2c 20 57 45 2f 03 28 4f 27 54 20 ; "SORRY, WE DON'T SERVE SPIRITS!" &0136 53 ab a5 b6 85 e1 dc 73 58 8e 85 cc 6f 0c &0144 2d ; end of string ; completion_message_without_reincarnation &0145 59 0b ; COLOUR 3 &0147 ef c1 16 ; TAB(&02, &1a) &014a 4b 4f 4e 47 52 4e 13 32 4d 41 54 49 4f a0 a4 c0 ; "CONGRATULATIONS YOU DESERVE A DRINK," &015a 99 8e da 03 55 99 9f dd 6e 7b 68 68 49 d0 87 5e &016a 41 4e 4b 2c &016e 1f 08 5b ; TAB(&07, &1c) &0171 25 54 54 20 44 4f a0 d0 b4 e0 87 c0 71 56 99 98 ; "BUT DON'T FORGET TO ENTER" &0181 b8 68 62 0d 0d 46 a4 86 5e &018a 17 0c 1e ; TAB(&0c, &1e) &018d 4f 55 5d 67 24 4e 4d 50 45 54 a7 b8 ae e1 ; "OUR COMPETION!" &019b d0 8e ; COLOUR 1 &019d 23 ; end of string ; unused &019e ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff &01ae ff ff ; unused &5bb0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 &5bc0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 &5bd0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 &5be0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 &5bf0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ; $.intcod ; 000380 000380 000060 ; interrupt_code ; previous_irq1_vector_low &0380 00 ; previous_irq1_vector_high &0381 00 ; room_colour &0382 00 ; irq1_handler &0383 a5 fc LDA &fc ; irq_accumulator &0385 48 PHA ; tmp_a &0386 8a TXA &0387 48 PHA ; tmp_x &0388 ad 4d fe LDA &fe4d ; System VIA interrupt flag register &038b 29 82 AND #&82 &038d c9 82 CMP #&82 # &80 set if an interrupt occurred, &02 if v-sync &038f d0 0d BNE &039e ; is_vsync ; is_vsync &0391 a9 e0 LDA #&e0 &0393 8d 68 fe STA &fe68 ; User VIA timer 2 counter LSB &0396 a9 10 LDA #&10 &0398 8d 69 fe STA &fe69 ; User VIA timer 2 counter MSB &039b 20 5d 12 JSR &125d ; set_status_section_colours ; not_vsync &039e ad 6d fe LDA &fe6d ; User VIA interrupt flag register &03a1 29 a0 AND #&a0 &03a3 c9 a0 CMP #&a0 # &80 set if an interrupt occurred, &20 if timer 2 &03a5 d0 14 BNE &03bb ; leave_after_restoring_registers ; is_timer_two &03a7 8d 6d fe STA &fe6d ; User VIA interrupt flag register &03aa a5 a7 LDA &a7 ; room_is_being_plotted # Non-zero if room is being plotted &03ac d0 15 BNE &03c3 ; set_all_colours_to_black &03ae a2 0a LDX #&0a ; delay_loop &03b0 ca DEX &03b1 d0 fd BNE &03b0 ; delay_loop &03b3 ad 82 03 LDA &0382 ; room_colour &03b6 09 a0 ORA #&a0 # Set colour 3 to room colour &03b8 20 69 12 JSR &1269 ; set_palette ; leave_after_restoring_registers &03bb 68 PLA ; tmp_x &03bc aa TAX &03bd 68 PLA ; tmp-a &03be 85 fc STA &fc ; irq_accumulator &03c0 6c 80 03 JMP (&0380) ; previous_irq1_vector ; set_all_colours_to_black &03c3 a9 00 LDA #&00 # Set colour 0 to black &03c5 48 PHA ; zero &03c6 20 69 12 JSR &1269 ; set_palette &03c9 68 PLA ; zero &03ca 48 PHA ; zero &03cb 09 a0 ORA #&a0 # Set colour 3 to black &03cd 20 69 12 JSR &1269 ; set_palette &03d0 68 PLA ; zero &03d1 48 PHA ; zero &03d2 09 20 ORA #&20 # Set colour 1 to black &03d4 20 69 12 JSR &1269 ; set_palette &03d7 68 PLA ; zero &03d8 09 80 ORA #&80 # Set colour 2 to black &03da 20 69 12 JSR &1269 ; set_palette &03dd 4c bb 03 JMP &03bb ; leave_after_restoring_registers Differences in the tape version =============================== ; QUEST ; 00FF1900 00FF1900 0229 &1900 0d # Start of BASIC program &1901 00 0a 0b ee 85 e5 8d 54 5e 40 0d ; 10ONERRORGOTO30 &190c 00 14 0c 2a 46 58 32 30 30 2c 32 0d ; 20*FX200,2 # Clear memory on BREAK &1918 00 1e 07 ee 85 41 0d ; 30ONERRORA &191f 00 28 0a 2a 54 56 32 35 35 0d ; 40*TV255 &1929 00 32 39 eb 37 3a e3 49 25 3d 30 b8 34 33 36 88 ; 50MODE7: &1939 34 3a 49 25 21 93 3d 49 25 21 b8 50 3a ed 3a ef ; FORI%=0TO436STEP4: &1949 32 38 2c 31 2c 32 33 2c 33 39 2c 31 33 2c 33 30 ; I%!HIMEM=I%!TOP: # Copy loading_screen_data to screen &1959 3a 2a 4f 50 54 32 2c 31 0d ; NEXT: ; VDU28,1,23,39,13,30: # Define text window ; *OPT2,1 # On error, prompt for re-try &1962 00 3c 10 d0 3d 26 30 45 30 30 3a 2a 52 55 4e 0d ; 60PAGE=&0E00:*RUN # Run second stage of loader &1972 ff # End of BASIC program ; loading_screen_data &1973 84 9d 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ; ".. " &1983 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ; "................... ...... " &1993 20 20 20 20 20 20 20 20 84 9d 81 9d 94 ff ff ff ; "........ ..... .. .SUPERIOR ...... " &19a3 bf a1 97 e0 fe ff bf a1 9d 94 85 20 20 20 20 20 ; "........ ..... .. .SOFTWARE ...... " &19b3 20 20 20 20 20 20 20 20 20 84 9d 87 9d 84 9d 20 ; "................. ...... " &19c3 84 9d 81 9d 94 ff ff a7 20 97 f8 ff ff a7 20 20 ; "................. .PRESENTS ...... " &19d3 9d 94 20 20 85 53 55 50 45 52 49 4f 52 20 20 20 ; "........ ..... .. ...... " &19e3 20 84 9d 87 9d 84 9d 20 84 9d 81 9d 94 ff ff f4 ; "........ ..... " &19f3 20 97 ab ff ff f4 20 20 9d 94 20 20 85 53 4f 46 ; "...... ... QUEST. ....... " &1a03 54 57 41 52 45 20 20 20 20 84 9d 87 9d 84 9d 20 ; "...... ... QUEST. ....... " &1a13 84 9d 81 9d 94 ff ff ff fd b0 97 a2 ef ff fd b0 ; ".. . .." &1a23 9d 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 &1a33 20 84 9d 87 9d 84 9d 20 84 9d 81 9d 94 ff ff ff &1a43 bf a1 97 e0 fe ff bf a1 9d 20 20 20 86 50 52 45 &1a53 53 45 4e 54 53 20 20 20 20 84 9d 87 9d 84 9d 20 &1a63 84 9d 81 9d 94 ff ff a7 20 97 f8 ff ff a7 20 20 &1a73 9d 94 20 20 20 20 20 20 20 20 20 20 20 20 20 20 &1a83 20 84 9d 87 9d 84 9d 20 84 9d 81 9d 84 9d ff a7 &1a93 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 &1aa3 20 20 20 20 20 20 20 20 20 20 9d 87 9d 84 9d 20 &1ab3 84 9d 81 9d 84 9d 20 9c 83 8d 20 20 20 20 20 20 &1ac3 20 20 51 55 45 53 54 0d 20 20 20 20 20 20 20 20 &1ad3 0d 84 9d 87 9d 84 9d 20 84 9d 81 9d 84 9d 20 9c &1ae3 83 8d 20 20 20 20 20 20 20 20 51 55 45 53 54 0d &1af3 20 20 20 20 20 20 20 20 0d 84 9d 87 9d 84 9d 20 &1b03 84 9d 20 9d 20 20 20 20 20 20 20 20 20 20 20 20 &1b13 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 &1b23 20 20 20 20 20 20 00 00 00 00 00 00 00 ; QUEST ; 00001900 00001D02 0496 &1900 0d # Start of BASIC program &1901 00 14 15 f4 20 28 63 29 20 54 4f 4e 59 20 4f 41 ; 20REM (c) TONY OAKDEN &1911 4b 44 45 4e 0d &1916 00 1e 20 f4 20 46 4f 52 20 53 55 50 45 52 49 4f ; 30REM FOR SUPERIOR SOFTWARE 1988 &1926 52 20 53 4f 46 54 57 41 52 45 20 31 39 38 38 0d &1936 00 28 4c eb 35 3a ef 31 39 2c 31 2c 32 3b 30 3b ; 40MODE5: &1946 30 3b 3a ef 31 39 2c 33 2c 35 3b 30 3b 30 3b 3a ; VDU19,1,2;0;0;: # Set colour 1 to green &1956 ef 32 33 3b 38 32 30 32 3b 30 3b 30 3b 30 3b 3a ; VDU19,3,5;0;0;: # Set colour 3 to magenta &1966 ef 32 38 2c 31 2c 33 30 2c 31 38 2c 32 38 3a 2a ; VDU23;8202;0;0;0;: # Disable cursor &1976 4c 4f 41 44 20 51 55 45 53 54 4f 0d ; VDU28,1,30,18,28: # Define text window ; *LOAD QUESTO # Load loading screen &1982 00 29 05 db 0d ; 41CLS &1987 00 2d 17 f1 22 20 20 42 79 20 54 6f 6e 79 20 4f ; 45PRINT" By Tony Oakden" &1997 61 6b 64 65 6e 22 0d &199e 00 2e 10 54 25 3d 91 3a 2a 46 58 31 35 2c 30 0d ; 46T%=TIME: ; *FX15,0 # Flush all buffers &19ae 00 2f 19 f5 fd 91 3e 54 25 2b 38 30 30 20 84 a6 ; 47REPEATUNTILTIME>T%+800 ORINKEY(10)<>-1 &19be 28 31 30 29 3c 3e 2d 31 0d &19c7 00 32 06 eb 31 0d ; 50MODE1 &19cd 00 5a 12 ef 32 33 2c 31 2c 30 3b 30 3b 30 3b 30 ; 90VDU23,1,0;0;0;0; # Disable cursor &19dd 3b 0d &19df 00 64 16 ef 32 34 2c 30 3b 33 32 3b 31 32 37 39 ; 100VDU24,0;32;1279;831; # Define graphics window &19ef 3b 38 33 31 3b 0d &19f5 00 6e 2a ef 32 33 2c 31 32 38 2c 31 32 34 2c 31 ; 110VDU23,128,124,198,198,198,198,214,124,15 &1a05 39 38 2c 31 39 38 2c 31 39 38 2c 31 39 38 2c 32 # Define character 80 &1a15 31 34 2c 31 32 34 2c 31 35 0d &1a1f 00 78 24 ef 32 33 2c 31 32 39 2c 36 2c 36 2c 31 ; 120VDU23,129,6,6,15,235,237,79,79,239 &1a2f 35 2c 32 33 35 2c 32 33 37 2c 37 39 2c 37 39 2c # Define character 81 &1a3f 32 33 39 0d &1a43 00 82 06 fb 31 0d ; 130COLOUR1 &1a49 00 8c 05 db 0d ; 140CLS &1a4e 00 96 0b f1 8a 30 2c 33 31 29 0d ; 150PRINTTAB(0,31) &1a59 00 9b 12 ef 32 38 2c 31 2c 32 37 2c 31 34 2c 32 ; 155VDU28,1,27,14,23 # Define text window &1a69 33 0d &1a6b 00 d2 0c 2a 46 58 32 31 30 2c 31 0d ; 210*FX210,1 # Disable sound &1a77 00 dc 0f 2a 52 55 4e 20 51 55 45 53 54 31 0d ; 220*RUN QUEST1 # Run main binary &1a86 ff # End of BASIC program ; unused &1a87 36 3b 0d ; ... 6; &1a8a 00 dc 0f 2a 52 55 4e 20 51 55 45 53 54 31 0d ; 220*RUN QUEST1 &1a99 ff # End of BASIC program ; unused # Source code fragment &1a9a 55 0f e7 41 25 3d 31 20 e5 8d 74 7e 40 0d ; ... IFA%=1 GOTO190 &1aa8 00 ac 0e 2a 4c 2e 48 45 41 44 45 52 45 0d ; 172*L.HEADERE &1ab6 00 ae 47 50 52 24 3d c4 28 31 39 2d a9 c0 50 52 ; 174PR$=STRING$((19-LENLEFT$(PR$,19))DIV2," ")+PR$: &1ac6 24 2c 31 39 29 29 81 32 2c 22 20 22 29 2b 50 52 ; $&1A72=PR$: &1ad6 24 3a 24 26 31 41 37 32 3d 50 52 24 3a 3f 28 26 ?(&1A72+LENPR$)=&20: &1ae6 31 41 37 32 2b a9 50 52 24 29 3d 26 32 30 3a 2a *OPT1,2 # Turn on extended messages &1af6 4f 50 54 31 2c 32 0d &1afd 00 af 09 e5 8d 64 48 40 0d ; 175GOTO200 &1b06 00 be 0d 2a 4c 2e 48 45 41 44 45 52 0d ; 190*L.HEADER &1b13 00 bf 1a eb 37 3a 24 26 31 39 36 38 3d 53 24 2b ; 191MODE7: &1b23 22 30 30 3a 2a 52 55 4e 22 0d ; $&1968=S$+"00:*RUN" &1b2d 00 c0 40 50 52 24 3d c4 28 32 31 2d a9 c0 50 52 ; 192PR$=STRING$((21-LENLEFT$(PR$,21))DIV2," ")+PR$: &1b3d 24 2c 32 31 29 29 81 32 2c 22 20 22 29 2b 50 52 ; $&1ABD=PR$: &1b4d 24 3a 24 26 31 41 42 44 3d 50 52 24 3a 24 26 31 ; $&1AE5=PR$: &1b5d 41 45 35 3d 50 52 24 3a 2a 4f 50 54 31 2c 32 0d ; *OPT1,2 # Turn on extended messages &1b6d 00 c8 09 2a 54 41 50 45 0d ; 200*TAPE &1b76 00 cd 10 2a 46 58 20 31 33 38 2c 30 2c 31 33 0d ; 205*FX 138,0,13 # Insert CR into keyboard buffer &1b86 00 d2 1f 42 46 25 3d 26 37 42 38 30 3a 58 25 3d ; 210BF%=&7B80: &1b96 42 46 25 3a 59 25 3d 42 46 25 81 32 35 36 0d ; X%=BF%: ; Y%=BF%DIV256 &1ba5 00 dc 5b e7 41 25 3d 31 8c 20 24 42 46 25 3d 22 ; 220IFA%=1THEN $BF%="*SAVE "+TN$+" FF1900+229": &1bb5 2a 53 41 56 45 20 22 2b 54 4e 24 2b 22 20 46 46 ; CALL&FFF7 # OSCLI &1bc5 31 39 30 30 2b 32 32 39 22 3a d6 26 46 46 46 37 ; ELSE $BF%="*SAVE "+TN$+" FF1900+1A0": &1bd5 20 8b 20 24 42 46 25 3d 22 2a 53 41 56 45 20 22 ; CALL&FFF7 # OSCLI &1be5 2b 54 4e 24 2b 22 20 46 46 31 39 30 30 2b 31 41 &1bf5 30 22 3a d6 26 46 46 46 37 20 0d &1c00 00 e6 09 2a 44 49 53 43 0d ; 230*DISC &1c09 01 0e 0b 2a 4f 50 54 31 2c 32 0d ; 270*OPT1,2 # Turn on extended messages &1c14 01 0f 0e e7 41 25 3d 32 8c 41 25 3d 35 0d ; 271IFA%=2THENA%=5 &1c22 01 10 11 e5 28 32 30 30 2b 31 30 30 2a 41 25 29 ; 272GOTO(200+100*A%) &1c32 0d &1c33 01 2c 0f f4 20 42 42 43 20 46 49 4c 45 53 0d ; 300REM BBC FILES &1c42 01 36 14 2a 4c 4f 41 44 20 51 55 45 53 54 20 31 ; 310*LOAD QUEST 1900 &1c52 39 30 30 0d &1c56 01 40 09 2a 54 41 50 45 0d ; 320*TAPE &1c5f 01 4a 10 2a 46 58 20 31 33 38 2c 30 2c 31 33 0d ; 330*FX 138,0,13 # Insert CR into keyboard buffer &1c6f 01 4b 09 d6 26 43 30 30 0d ; 331CALL&C00 &1c78 01 54 1d 2a 53 41 56 45 20 51 55 45 53 54 20 31 ; 340*SAVE QUEST 1900+496 1D02 &1c88 39 30 30 2b 34 39 36 20 31 44 30 32 0d &1c95 01 55 09 d6 26 43 30 44 0d ; 341CALL&C0D &1c9e 01 5e 09 2a 44 49 53 43 0d ; 350*DISC &1ca7 01 68 15 2a 4c 4f 41 44 20 51 55 45 53 54 4f 20 ; 360*LOAD QUESTO 1900 &1cb7 31 39 30 30 0d &1cbc 01 72 09 2a 54 41 50 45 0d ; 370*TAPE &1cc5 01 7c 10 2a 46 58 20 31 33 38 2c 30 2c 31 33 0d ; 380*FX 138,0,13 # Insert CR into keyboard buffer &1cd5 01 86 24 2a 53 41 56 45 20 51 55 45 53 54 4f 20 ; 390*SAVE QUESTO 1900+2100 5800 5800 &1ce5 31 39 30 30 2b 32 31 30 30 20 35 38 30 30 20 35 &1cf5 38 30 30 0d &1cf9 01 90 09 2a 44 49 53 43 0d ; 400*DISC ; entry_point &1d02 ad 10 02 LDA &0210 ; osrdch_vector_low &1d05 8d 65 1d STA &1d65 ; previous_osrdch_vector_low &1d08 ad 11 02 LDA &0211 ; osrdch_vector_high &1d0b 8d 66 1d STA &1d66 ; previous_osrdch_vector_high &1d0e a9 00 LDA #&00 &1d10 8d 64 1d STA &1d64 ; offset &1d13 a9 42 LDA #&42 ; &1d42 = osrdch_handler &1d15 8d 10 02 STA &0210 ; osrdch_vector_low &1d18 a9 1d LDA #&1d &1d1a 8d 11 02 STA &0211 ; osrdch_vector_high &1d1d a9 15 LDA #&15 ; disable VDU drivers &1d1f 20 ee ff JSR &ffee ; OSWRCH &1d22 a9 81 LDA #&81 ; Check machine type &1d24 a2 00 LDX #&00 &1d26 a0 ff LDY #&ff &1d28 20 f4 ff JSR &fff4 ; OSBYTE &1d2b e0 00 CPX #&00 ; BBC A/B with OS 0.10 &1d2d f0 10 BEQ &1d3f ; is_os_0.10 &1d2f a9 b4 LDA #&b4 ; Read/Write OSHWM &1d31 a2 19 LDX #&19 &1d33 a0 00 LDY #&00 &1d35 20 f4 ff JSR &fff4 ; OSBYTE # Set OSHWM to &1900 &1d38 a2 8f LDX #&8f ; &1d8f = basic_string &1d3a a0 1d LDY #&1d &1d3c 4c f7 ff JMP &fff7 ; OSCLI # *BASIC ; is_os_0.10 &1d3f 4c 00 80 JMP &8000 ; language_entry_point ; osrdch_handler &1d42 8e 63 1d STX &1d63 ; tmp_x &1d45 ae 64 1d LDX &1d64 ; offset &1d48 bd 67 1d LDA &1d67,X ; run_string # Use byte of string as read character &1d4b ee 64 1d INC &1d64 ; offset &1d4e e0 27 CPX #&27 &1d50 d0 0c BNE &1d5e ; skip_restoring_previous_vector # At end of string, restore previous OSRDCH vector &1d52 ae 65 1d LDX &1d65 ; previous_osrdch_vector_low &1d55 8e 10 02 STX &0210 ; osrdch_vector_low &1d58 ae 66 1d LDX &1d66 ; previous_osrdch_vector_high &1d5b 8e 11 02 STX &0211 ; osrdch_vector_high ; skip_restoring_previous_vector &1d5e ae 63 1d LDX &1d63 ; tmp_x &1d61 18 CLC &1d62 60 RTS &1d63 00 ; offset &1d64 00 ; previous_osrdch_vector_low &1d65 00 ; previous_osrdch_vector_high &1d66 00 ; run_string &1d67 50 41 47 45 3d 26 31 39 30 30 0d ; "PAGE=&1900" &1d72 4f 4c 44 0d ; "OLD" &1d76 4f 4e 45 52 52 4f 52 52 55 4e 0d ; "ONERRORRUN" &1d81 2a 46 58 32 30 30 2c 32 0d ; "*FX200,2" # Clear memory on BREAK &1d8a 52 55 4e 06 0d ; "RUN" ; basic_string &1d8f 42 41 53 49 43 0d ; unused &1d95 4f ; QUEST1 ; 00001D00 00005980 3F12 # &1d00 - &597f is identical to the disk version. Differences in &5980 onwards are indicated by *** ; entry_point &5980 20 7a 5a JSR &5a7a ; initialise_screen *** &5983 20 ed 59 JSR &59ed ; initialise_vectors_and_interrupts &5986 4c 96 5a JMP &5a96 ; set_os_sound_suppression_reset_game *** ; relocate_data &5989 a9 00 LDA #&00 ; &1d00 &598b 85 7a STA &7a ; source_address_low &598d a9 1d LDA #&1d &598f 85 7b STA &7b ; source_address_high &5991 a9 00 LDA #&00 ; &0400 &5993 85 7c STA &7c ; target_address_low &5995 a9 04 LDA #&04 &5997 85 7d STA &7d ; target_address_high &5999 a0 00 LDY #&00 ; move_1d00_to_25ff_loop # Move &1d00 - &25ff to &0400 - &0cff &599b b1 7a LDA (&7a),Y ; source_address &599d 91 7c STA (&7c),Y ; target_address &599f e6 7a INC &7a ; source_address_low &59a1 d0 02 BNE &59a5 ; skip_page_source &59a3 e6 7b INC &7b ; source_address_high ; skip_page_source &59a5 e6 7c INC &7c ; target_address_low &59a7 d0 02 BNE &59ab ; skip_page_target &59a9 e6 7d INC &7d ; target_address_high ; skip_page_target &59ab a5 7b LDA &7b ; source_address_high &59ad c9 26 CMP #&26 &59af f0 03 BEQ &59b4 ; move_2600_to_5aff &59b1 4c 9b 59 JMP &599b ; move_1d00_to_25ff_loop ; move_2600_to_5aff &59b4 a9 00 LDA #&00 ; &2600 &59b6 85 7a STA &7a ; source_address_low &59b8 a9 26 LDA #&26 &59ba 85 7b STA &7b ; source_address_high &59bc a9 00 LDA #&00 ; &0e00 &59be 85 7c STA &7c ; target_address_low &59c0 a9 0e LDA #&0e &59c2 85 7d STA &7d ; target_address_high &59c4 a0 00 LDY #&00 ; move_2600_to_5aff_loop # Move &2600 - &5aff to &0e00 - &42ff &59c6 b1 7a LDA (&7a),Y ; source_address &59c8 91 7c STA (&7c),Y ; target_address &59ca e6 7a INC &7a ; source_address_low &59cc d0 02 BNE &59d0 ; skip_page_source &59ce e6 7b INC &7b ; source_address_high ; skip_page_source &59d0 e6 7c INC &7c ; target_address_low &59d2 d0 02 BNE &59d6 ; skip_page_target &59d4 e6 7d INC &7d ; target_address_high ; skip_page_target &59d6 a5 7b LDA &7b ; source_address_high &59d8 c9 5b CMP #&5b &59da f0 03 BEQ &59df ; move_5b00_to_5baf &59dc 4c c6 59 JMP &59c6 ; move_2600_to_5aff_loop ; move_5b00_to_5baf &59df a2 00 LDX #&00 ; move_5b00_to_5baf_loop # Move &5b00 - &5baf to &0100 - &01af &59e1 bd 00 5b LDA &5b00,X &59e4 9d 00 01 STA &0100,X &59e7 e8 INX &59e8 e0 b0 CPX #&b0 &59ea d0 f5 BNE &59e1 ; move_5b00_to_5baf_loop &59ec 60 RTS ; initialise_vectors_and_interrupts &59ed a9 83 LDA #&83 ; &0b83 = event_handler &59ef 8d 20 02 STA &0220 ; event_vector_low &59f2 a9 0b LDA #&0b &59f4 8d 21 02 STA &0221 ; event_vector_high &59f7 a9 c8 LDA #&c8 ; Read/Write BREAK/ESCAPE effect &59f9 a2 02 LDX #&02 ; clear memory on BREAK &59fb 20 f4 ff JSR &fff4 ; OSBYTE &59fe a9 0e LDA #&0e ; Enable event &5a00 a2 05 LDX #&05 ; interval timer crossing zero &5a02 20 f4 ff JSR &fff4 ; OSBYTE &5a05 ad 04 02 LDA &0204 ; irq1_vector_low &5a08 8d 80 03 STA &0380 ; previous_irq1_vector_low &5a0b ad 05 02 LDA &0205 ; irq1_vector_high &5a0e 8d 81 03 STA &0381 ; previous_irq1_vector_high &5a11 78 SEI &5a12 a9 83 LDA #&83 ; &0383 = irq1_handler &5a14 8d 04 02 STA &0204 ; irq1_vector_low &5a17 a9 03 LDA #&03 &5a19 8d 05 02 STA &0205 ; irq1_vector_high &5a1c 58 CLI &5a1d a9 7f LDA #&7f # Disable all interrupts &5a1f 8d 6e fe STA &fe6e ; User VIA interrupt enable register &5a22 8d 7e fe STA &fe7e # Unnecessary code; also User VIA interrupt enable register &5a25 8d 4e fe STA &fe4e ; System VIA interrupt enable register &5a28 8d 5e fe STA &fe5e # Unnecessary code; also System VIA interrupt enable register &5a2b a9 c2 LDA #&c2 # Enable System VIA CA1 (v-sync) and timer 1 interrupts &5a2d 8d 4e fe STA &fe4e ; System VIA interrupt enable register &5a30 a9 40 LDA #&40 # Set User VIA timer 2 to one-shot mode &5a32 8d 6b fe STA &fe6b ; User VIA auxiliary control register &5a35 a9 a0 LDA #&a0 # Enable User VIA timer 2 interrupts &5a37 8d 6e fe STA &fe6e ; User VIA interrupt enable register &5a3a 60 RTS ; unused &5a3b ea *** # ; initialise_video_registers # Set in lines 160 - 200 of $.QUEST in disk version &5a3c a9 06 LDA #&06 *** # R6: Vertical displayed register &5a3e 8d 00 fe STA &fe00 ; video register number *** &5a41 a9 1b LDA #&1b *** &5a43 8d 01 fe STA &fe01 ; video register value *** &5a46 a9 07 LDA #&07 *** # R7: Vertical sync position &5a48 8d 00 fe STA &fe00 ; video register number *** &5a4b a9 20 LDA #&20 *** &5a4d 8d 01 fe STA &fe01 ; video register value *** &5a50 a9 0c LDA #&0c *** # R12: Displayed screen start address register (high) &5a52 8d 00 fe STA &fe00 ; video register number *** &5a55 a9 07 LDA #&07 *** &5a57 8d 01 fe STA &fe01 ; video register value *** &5a5a a9 0d LDA #&0d *** # R13: Displayed screen start address register (low) &5a5c 8d 00 fe STA &fe00 ; video register number *** &5a5f a9 90 LDA #&90 *** # Set screen start address to &3c80 &5a61 8d 01 fe STA &fe01 ; video register value *** &5a64 a9 02 LDA #&02 *** # R2: Horizontal sync position register &5a66 8d 00 fe STA &fe00 ; video register number *** # Bug: no value written &5a69 a2 00 LDX #&00 *** ; move_5bb0_to_5c10_loop *** # Move &5bb0 - &5c10 to &0380 - &03e0 &5a6b bd b0 5b LDA &5bb0,X ; unrelocated_interrupt_code *** &5a6e 9d 80 03 STA &0380,X ; interrupt_code *** &5a71 e8 INX *** &5a72 e0 61 CPX #&61 *** &5a74 d0 f5 BNE &5a6b ; move_5bb0_to_5c10_loop *** &5a76 78 SEI *** &5a77 4c 89 59 JMP &5989 ; relocate_data *** ; initialise_screen &5a7a a9 1c LDA #&1c ; define text window *** # Define text window x:(&00, &27), y:(&00, &1e) &5a7c 20 ee ff JSR &ffee ; OSWRCH *** &5a7f a9 00 LDA #&00 *** &5a81 20 ee ff JSR &ffee ; OSWRCH *** &5a84 a9 1e LDA #&1e *** &5a86 20 ee ff JSR &ffee ; OSWRCH *** &5a89 a9 27 LDA #&27 *** &5a8b 20 ee ff JSR &ffee ; OSWRCH *** &5a8e a9 00 LDA #&00 *** &5a90 20 ee ff JSR &ffee ; OSWRCH *** &5a93 4c 3c 5a JMP &5a3c ; initialise_video_registers *** ; set_os_sound_suppression_reset_game &5a96 a9 00 LDA #&00 *** &5a98 8d 62 02 STA &0262 ; os_sound_suppression *** # Set to zero to enable sound &5a9b 4c 00 0b JMP &0b00 ; to_reset_game *** ; unused # Truncated in tape version &5a9e 65 20 4d 6f 75 6e 74 61 69 6e 65 65 72 69 6e 67 ; "e Mountaineering" &5aae 20 43 6c 75 62 2e 27 53 77 69 6e 67 20 6f 75 74 ; " Club.'Swing out" &5abe 20 53 69 73 74 65 72 20 66 6f 72 20 42 72 65 61 ; " Sister for Brea" &5ace 6b 2d 6f 75 74 2e 20 41 6e 64 20 67 6f 6f 64 6c ; "k-out. And goodl" &5ade 75 63 6b 20 53 61 6c 6c 79 20 77 65 72 65 20 65 ; "uck Sally were e" &5aee 76 65 72 20 79 6f 75 20 61 72 65 21 ; "ver you are!" ; unused &5afa 00 00 00 00 00 00 # &5b00 - &5baf is moved to &0100 - &01af at &59e1 ; write_completion_message ; write_completion_message_loop &0100 bd 0f 01 LDA &010f,X ; completion_message &0103 5d 00 70 EOR &7000,X ; screen_memory + &14 * &280 + &180 &0106 f0 06 BEQ &010e ; leave &0108 20 ee ff JSR &ffee ; OSWRCH &010b e8 INX &010c d0 f2 BNE &0100 ; write_completion_message_loop ; leave &010e 60 RTS ; completion_message &010f 10 4b 7d ; TAB(&0c, &1a) &0112 58 4f 55 20 52 ab be ae 83 80 dd 6d 50 88 89 dc ; "YOU REINCARNATED!" &0122 1d &0123 32 28 54 ; TAB(&05, &1c) &0126 5b bf 91 5e 51 2c 20 57 45 2f 03 28 4f 27 54 20 ; "SORRY, WE DON'T SERVE SPIRITS!" &0136 53 ab a5 b6 85 e1 dc 73 58 8e 85 cc 6f 0c &0144 2d ; end of string ; completion_message_without_reincarnation &0145 59 0b ; COLOUR 3 &0147 ef c1 16 ; TAB(&02, &1a) &014a 4b 4f 4e 47 52 4e 13 32 4d 41 54 49 4f a0 a4 c0 ; "CONGRATULATIONS YOU DESERVE A DRINK," &015a 99 8e da 03 55 99 9f dd 6e 7b 68 68 49 d0 87 5e &016a 41 4e 4b 2c &016e 1f 08 5b ; TAB(&07, &1c) &0171 25 54 54 20 44 4f a0 d0 b4 e0 87 c0 71 56 99 98 ; "BUT DON'T FORGET TO ENTER" &0181 b8 68 62 0d 0d 46 a4 86 5e &018a 17 0c 1e ; TAB(&0c, &1e) &018d 4f 55 5d 67 24 4e 4d 50 45 54 a7 b8 ae e1 ; "OUR COMPETION!" &019b d0 8e ; COLOUR 1 &019d 23 ; end of string ; unused &019e ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff &01ae ff ff # &5bb0 - &5c10 is moved to &0380 - &03e0 at &5a6b ; interrupt_code ; previous_irq1_vector_low &0380 00 ; previous_irq1_vector_high &0381 00 ; room_colour &0382 00 ; irq1_handler &0383 a5 fc LDA &fc ; irq_accumulator &0385 48 PHA ; tmp_a &0386 8a TXA &0387 48 PHA ; tmp_x &0388 ad 4d fe LDA &fe4d ; System VIA interrupt flag register &038b 29 82 AND #&82 &038d c9 82 CMP #&82 # &80 set if an interrupt occurred, &02 if v-sync &038f d0 0d BNE &039e ; is_vsync ; is_vsync &0391 a9 e0 LDA #&e0 &0393 8d 68 fe STA &fe68 ; User VIA timer 2 counter LSB &0396 a9 10 LDA #&10 &0398 8d 69 fe STA &fe69 ; User VIA timer 2 counter MSB &039b 20 5d 12 JSR &125d ; set_status_section_colours ; not_vsync &039e ad 6d fe LDA &fe6d ; User VIA interrupt flag register &03a1 29 a0 AND #&a0 &03a3 c9 a0 CMP #&a0 # &80 set if an interrupt occurred, &20 if timer 2 &03a5 d0 14 BNE &03bb ; leave_after_restoring_registers ; is_timer_two &03a7 8d 6d fe STA &fe6d ; User VIA interrupt flag register &03aa a5 a7 LDA &a7 ; room_is_being_plotted # Non-zero if room is being plotted &03ac d0 15 BNE &03c3 ; set_all_colours_to_black &03ae a2 0a LDX #&0a ; delay_loop &03b0 ca DEX &03b1 d0 fd BNE &03b0 ; delay_loop &03b3 ad 82 03 LDA &0382 ; room_colour &03b6 09 a0 ORA #&a0 # Set colour 3 to room colour &03b8 20 69 12 JSR &1269 ; set_palette ; leave_after_restoring_registers &03bb 68 PLA ; tmp_x &03bc aa TAX &03bd 68 PLA ; tmp-a &03be 85 fc STA &fc ; irq_accumulator &03c0 6c 80 03 JMP (&0380) ; previous_irq1_vector ; set_all_colours_to_black &03c3 a9 00 LDA #&00 # Set colour 0 to black &03c5 48 PHA ; zero &03c6 20 69 12 JSR &1269 ; set_palette &03c9 68 PLA ; zero &03ca 48 PHA ; zero &03cb 09 a0 ORA #&a0 # Set colour 3 to black &03cd 20 69 12 JSR &1269 ; set_palette &03d0 68 PLA ; zero &03d1 48 PHA ; zero &03d2 09 20 ORA #&20 # Set colour 1 to black &03d4 20 69 12 JSR &1269 ; set_palette &03d7 68 PLA ; zero &03d8 09 80 ORA #&80 # Set colour 2 to black &03da 20 69 12 JSR &1269 ; set_palette &03dd 4c bb 03 JMP &03bb ; leave_after_restoring_registers ; unused &03e0 00 *** # Extra unused byte in tape version ; unused &5c11 00