Starquake disassembly ===================== Published by Bubble Bus Software in 1985, Starquake was originally written by Stephen Crow for the ZX Spectrum. It was converted to the BBC Micro in 1987 by Kenton Price. It is a platform game in which the player must recover core elements that are scattered around the depths of a 512 room planet. 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 =============== The custom tape loader is protected by a multi-stage routine written by Kenton Price and Gary Partis, which uses EOR and VIA-based decryption. The disassembly analyses each stage immediately after decryption has taken place. Interesting pokes ================= &1f13 = &00 player is invulnerable &2db6 = &10 player can move through walls &1304 = &00 infinite lives &1cf0 = &00, &3153 = &00 infinite energy &19a1 = &00 infinite fuel &19c1 = &00 infinite ammunition &2dbd = &60 no enemies Tape protection disassembly =========================== ; QUAKE2 ; 002600 002600 001000 ; entry_point &2600 a0 00 LDY #&00 # 151 successive EOR decryption loops &2602 98 TYA &2603 59 0c 26 EOR &260c,Y &2606 99 0c 26 STA &260c,Y &2609 c8 INY &260a d0 f6 BNE &2602 &260c 98 TYA &260d 59 16 26 EOR &2616,Y &2610 99 16 26 STA &2616,Y &2613 c8 INY &2614 d0 f6 BNE &260c &2616 98 TYA &2617 49 c3 EOR #&c3 &2619 59 21 26 EOR &2621,Y &261c 99 21 26 STA &2621,Y &261f c8 INY &2620 d0 f4 BNE &2616 &2622 b9 2c 26 LDA &262c,Y &2625 49 ef EOR #&ef &2627 99 2c 26 STA &262c,Y &262a c8 INY &262b d0 f5 BNE &2622 &262d a9 4c LDA #&4c &262f 8d 87 02 STA &0287 ; BREAK intercept code &2632 a9 02 LDA #&02 &2634 8d 89 02 STA &0289 ; BREAK intercept code + 2 &2637 a9 87 LDA #&87 &2639 8d 88 02 STA &0288 ; BREAK intercept code + 1 &263c 98 TYA &263d 49 9b EOR #&9b &263f 59 47 26 EOR &2647,Y &2642 99 47 26 STA &2647,Y &2645 c8 INY &2646 d0 f4 BNE &263c &2648 b9 53 26 LDA &2653,Y &264b 49 a3 EOR #&a3 &264d 99 53 26 STA &2653,Y &2650 c8 INY &2651 d0 f5 BNE &2648 &2653 98 TYA &2654 59 5d 26 EOR &265d,Y &2657 99 5d 26 STA &265d,Y &265a c8 INY &265b d0 f6 BNE &2653 &265d 98 TYA &265e 49 8d EOR #&8d &2660 59 68 26 EOR &2668,Y &2663 99 68 26 STA &2668,Y &2666 c8 INY &2667 d0 f4 BNE &265d &2669 98 TYA &266a 59 73 26 EOR &2673,Y &266d 99 73 26 STA &2673,Y &2670 c8 INY &2671 d0 f6 BNE &2669 &2673 b9 7e 26 LDA &267e,Y &2676 49 8d EOR #&8d &2678 99 7e 26 STA &267e,Y &267b c8 INY &267c d0 f5 BNE &2673 &267e 98 TYA &267f 59 88 26 EOR &2688,Y &2682 99 88 26 STA &2688,Y &2685 c8 INY &2686 d0 f6 BNE &267e &2688 98 TYA &2689 59 92 26 EOR &2692,Y &268c 99 92 26 STA &2692,Y &268f c8 INY &2690 d0 f6 BNE &2688 &2692 b9 9c 26 LDA &269c,Y &2695 49 a0 EOR #&a0 &2697 99 9c 26 STA &269c,Y &269a c8 INY &269b d0 f5 BNE &2692 &269d a9 4c LDA #&4c &269f 8d 87 02 STA &0287 ; BREAK intercept code &26a2 a9 02 LDA #&02 &26a4 8d 89 02 STA &0289 ; BREAK intercept code + 2 &26a7 a9 87 LDA #&87 &26a9 8d 88 02 STA &0288 ; BREAK intercept code + 1 &26ac 98 TYA &26ad 59 b6 26 EOR &26b6,Y &26b0 99 b6 26 STA &26b6,Y &26b3 c8 INY &26b4 d0 f6 BNE &26ac &26b6 98 TYA &26b7 59 c0 26 EOR &26c0,Y &26ba 99 c0 26 STA &26c0,Y &26bd c8 INY &26be d0 f6 BNE &26b6 &26c0 98 TYA &26c1 59 ca 26 EOR &26ca,Y &26c4 99 ca 26 STA &26ca,Y &26c7 c8 INY &26c8 d0 f6 BNE &26c0 &26ca 98 TYA &26cb 49 da EOR #&da &26cd 59 d5 26 EOR &26d5,Y &26d0 99 d5 26 STA &26d5,Y &26d3 c8 INY &26d4 d0 f4 BNE &26ca &26d6 b9 e0 26 LDA &26e0,Y &26d9 49 9c EOR #&9c &26db 99 e0 26 STA &26e0,Y &26de c8 INY &26df d0 f5 BNE &26d6 &26e1 a9 4c LDA #&4c &26e3 8d 87 02 STA &0287 ; BREAK intercept code &26e6 a9 02 LDA #&02 &26e8 8d 89 02 STA &0289 ; BREAK intercept code + 2 &26eb a9 87 LDA #&87 &26ed 8d 88 02 STA &0288 ; BREAK intercept code + 1 &26f0 b9 fa 26 LDA &26fa,Y &26f3 49 f5 EOR #&f5 &26f5 99 fa 26 STA &26fa,Y &26f8 c8 INY &26f9 d0 f5 BNE &26f0 &26fb a9 4c LDA #&4c &26fd 8d 87 02 STA &0287 ; BREAK intercept code &2700 a9 02 LDA #&02 &2702 8d 89 02 STA &0289 ; BREAK intercept code + 2 &2705 a9 87 LDA #&87 &2707 8d 88 02 STA &0288 ; BREAK intercept code + 1 &270a 98 TYA &270b 18 CLC &270c 69 80 ADC #&80 &270e 49 c4 EOR #&c4 &2710 59 24 27 EOR &2724,Y &2713 99 24 27 STA &2724,Y &2716 c8 INY &2717 d0 f1 BNE &270a &2719 a9 c8 LDA #&c8 ; Read/Write BREAK/ESCAPE effect &271b a2 03 LDX #&03 ; Clear memory on next RESET &271d a0 00 LDY #&00 &271f 20 f4 ff JSR &fff4 ; OSBYTE &2722 a0 00 LDY #&00 &2724 98 TYA &2725 49 b5 EOR #&b5 &2727 59 2f 27 EOR &272f,Y &272a 99 2f 27 STA &272f,Y &272d c8 INY &272e d0 f4 BNE &2724 &2730 b9 3b 27 LDA &273b,Y &2733 49 da EOR #&da &2735 99 3b 27 STA &273b,Y &2738 c8 INY &2739 d0 f5 BNE &2730 &273b 98 TYA &273c 59 45 27 EOR &2745,Y &273f 99 45 27 STA &2745,Y &2742 c8 INY &2743 d0 f6 BNE &273b &2745 98 TYA &2746 49 86 EOR #&86 &2748 59 50 27 EOR &2750,Y &274b 99 50 27 STA &2750,Y &274e c8 INY &274f d0 f4 BNE &2745 &2751 b9 5c 27 LDA &275c,Y &2754 49 91 EOR #&91 &2756 99 5c 27 STA &275c,Y &2759 c8 INY &275a d0 f5 BNE &2751 &275c b9 66 27 LDA &2766,Y &275f 49 bd EOR #&bd &2761 99 66 27 STA &2766,Y &2764 c8 INY &2765 d0 f5 BNE &275c &2767 a9 4c LDA #&4c &2769 8d 87 02 STA &0287 ; BREAK intercept code &276c a9 02 LDA #&02 &276e 8d 89 02 STA &0289 ; BREAK intercept code + 2 &2771 a9 87 LDA #&87 &2773 8d 88 02 STA &0288 ; BREAK intercept code + 1 &2776 98 TYA &2777 49 d7 EOR #&d7 &2779 59 81 27 EOR &2781,Y &277c 99 81 27 STA &2781,Y &277f c8 INY &2780 d0 f4 BNE &2776 &2782 98 TYA &2783 49 98 EOR #&98 &2785 59 8d 27 EOR &278d,Y &2788 99 8d 27 STA &278d,Y &278b c8 INY &278c d0 f4 BNE &2782 &278e 98 TYA &278f 49 c0 EOR #&c0 &2791 59 99 27 EOR &2799,Y &2794 99 99 27 STA &2799,Y &2797 c8 INY &2798 d0 f4 BNE &278e &279a 98 TYA &279b 49 c0 EOR #&c0 &279d 59 a5 27 EOR &27a5,Y &27a0 99 a5 27 STA &27a5,Y &27a3 c8 INY &27a4 d0 f4 BNE &279a &27a6 98 TYA &27a7 59 b0 27 EOR &27b0,Y &27aa 99 b0 27 STA &27b0,Y &27ad c8 INY &27ae d0 f6 BNE &27a6 &27b0 98 TYA &27b1 59 ba 27 EOR &27ba,Y &27b4 99 ba 27 STA &27ba,Y &27b7 c8 INY &27b8 d0 f6 BNE &27b0 &27ba 98 TYA &27bb 59 c4 27 EOR &27c4,Y &27be 99 c4 27 STA &27c4,Y &27c1 c8 INY &27c2 d0 f6 BNE &27ba &27c4 98 TYA &27c5 59 ce 27 EOR &27ce,Y &27c8 99 ce 27 STA &27ce,Y &27cb c8 INY &27cc d0 f6 BNE &27c4 &27ce 98 TYA &27cf 59 d8 27 EOR &27d8,Y &27d2 99 d8 27 STA &27d8,Y &27d5 c8 INY &27d6 d0 f6 BNE &27ce &27d8 b9 e2 27 LDA &27e2,Y &27db 49 d3 EOR #&d3 &27dd 99 e2 27 STA &27e2,Y &27e0 c8 INY &27e1 d0 f5 BNE &27d8 &27e3 a9 4c LDA #&4c &27e5 8d 87 02 STA &0287 ; BREAK intercept code &27e8 a9 02 LDA #&02 &27ea 8d 89 02 STA &0289 ; BREAK intercept code + 2 &27ed a9 87 LDA #&87 &27ef 8d 88 02 STA &0288 ; BREAK intercept code + 1 &27f2 98 TYA &27f3 59 fc 27 EOR &27fc,Y &27f6 99 fc 27 STA &27fc,Y &27f9 c8 INY &27fa d0 f6 BNE &27f2 &27fc 98 TYA &27fd 18 CLC &27fe 69 80 ADC #&80 &2800 49 87 EOR #&87 &2802 59 16 28 EOR &2816,Y &2805 99 16 28 STA &2816,Y &2808 c8 INY &2809 d0 f1 BNE &27fc &280b a9 c8 LDA #&c8 ; Read/Write BREAK/ESCAPE effect &280d a2 03 LDX #&03 ; Clear memory on next RESET &280f a0 00 LDY #&00 &2811 20 f4 ff JSR &fff4 ; OSBYTE &2814 a0 00 LDY #&00 &2816 98 TYA &2817 59 20 28 EOR &2820,Y &281a 99 20 28 STA &2820,Y &281d c8 INY &281e d0 f6 BNE &2816 &2820 98 TYA &2821 18 CLC &2822 69 80 ADC #&80 &2824 49 8c EOR #&8c &2826 59 3a 28 EOR &283a,Y &2829 99 3a 28 STA &283a,Y &282c c8 INY &282d d0 f1 BNE &2820 &282f a9 c8 LDA #&c8 ; Read/Write BREAK/ESCAPE effect &2831 a2 03 LDX #&03 &2833 a0 00 LDY #&00 &2835 20 f4 ff JSR &fff4 ; OSBYTE &2838 a0 00 LDY #&00 &283a 98 TYA &283b 59 44 28 EOR &2844,Y &283e 99 44 28 STA &2844,Y &2841 c8 INY &2842 d0 f6 BNE &283a &2844 b9 4f 28 LDA &284f,Y &2847 49 e1 EOR #&e1 &2849 99 4f 28 STA &284f,Y &284c c8 INY &284d d0 f5 BNE &2844 &284f b9 59 28 LDA &2859,Y &2852 49 af EOR #&af &2854 99 59 28 STA &2859,Y &2857 c8 INY &2858 d0 f5 BNE &284f &285a a9 4c LDA #&4c &285c 8d 87 02 STA &0287 ; BREAK intercept code &285f a9 02 LDA #&02 &2861 8d 89 02 STA &0289 ; BREAK intercept code + 2 &2864 a9 87 LDA #&87 &2866 8d 88 02 STA &0288 ; BREAK intercept code + 1 &2869 b9 73 28 LDA &2873,Y &286c 49 e1 EOR #&e1 &286e 99 73 28 STA &2873,Y &2871 c8 INY &2872 d0 f5 BNE &2869 &2874 a9 4c LDA #&4c &2876 8d 87 02 STA &0287 ; BREAK intercept code &2879 a9 02 LDA #&02 &287b 8d 89 02 STA &0289 ; BREAK intercept code + 2 &287e a9 87 LDA #&87 &2880 8d 88 02 STA &0288 ; BREAK intercept code + 1 &2883 b9 8e 28 LDA &288e,Y &2886 49 e6 EOR #&e6 &2888 99 8e 28 STA &288e,Y &288b c8 INY &288c d0 f5 BNE &2883 &288e 98 TYA &288f 59 98 28 EOR &2898,Y &2892 99 98 28 STA &2898,Y &2895 c8 INY &2896 d0 f6 BNE &288e &2898 98 TYA &2899 49 b5 EOR #&b5 &289b 59 a3 28 EOR &28a3,Y &289e 99 a3 28 STA &28a3,Y &28a1 c8 INY &28a2 d0 f4 BNE &2898 &28a4 b9 ae 28 LDA &28ae,Y &28a7 49 8a EOR #&8a &28a9 99 ae 28 STA &28ae,Y &28ac c8 INY &28ad d0 f5 BNE &28a4 &28af a9 4c LDA #&4c &28b1 8d 87 02 STA &0287 ; BREAK intercept code &28b4 a9 02 LDA #&02 &28b6 8d 89 02 STA &0289 ; BREAK intercept code + 2 &28b9 a9 87 LDA #&87 &28bb 8d 88 02 STA &0288 ; BREAK intercept code + 1 &28be b9 c8 28 LDA &28c8,Y &28c1 49 d0 EOR #&d0 &28c3 99 c8 28 STA &28c8,Y &28c6 c8 INY &28c7 d0 f5 BNE &28be &28c9 a9 4c LDA #&4c &28cb 8d 87 02 STA &0287 ; BREAK intercept code &28ce a9 02 LDA #&02 &28d0 8d 89 02 STA &0289 ; BREAK intercept code + 2 &28d3 a9 87 LDA #&87 &28d5 8d 88 02 STA &0288 ; BREAK intercept code + 1 &28d8 98 TYA &28d9 59 e2 28 EOR &28e2,Y &28dc 99 e2 28 STA &28e2,Y &28df c8 INY &28e0 d0 f6 BNE &28d8 &28e2 b9 ec 28 LDA &28ec,Y &28e5 49 ba EOR #&ba &28e7 99 ec 28 STA &28ec,Y &28ea c8 INY &28eb d0 f5 BNE &28e2 &28ed a9 4c LDA #&4c &28ef 8d 87 02 STA &0287 ; BREAK intercept code &28f2 a9 02 LDA #&02 &28f4 8d 89 02 STA &0289 ; BREAK intercept code + 2 &28f7 a9 87 LDA #&87 &28f9 8d 88 02 STA &0288 ; BREAK intercept code + 1 &28fc b9 06 29 LDA &2906,Y &28ff 49 a1 EOR #&a1 &2901 99 06 29 STA &2906,Y &2904 c8 INY &2905 d0 f5 BNE &28fc &2907 a9 4c LDA #&4c &2909 8d 87 02 STA &0287 ; BREAK intercept code &290c a9 02 LDA #&02 &290e 8d 89 02 STA &0289 ; BREAK intercept code + 2 &2911 a9 87 LDA #&87 &2913 8d 88 02 STA &0288 ; BREAK intercept code + 1 &2916 98 TYA &2917 18 CLC &2918 69 80 ADC #&80 &291a 49 b9 EOR #&b9 &291c 59 30 29 EOR &2930,Y &291f 99 30 29 STA &2930,Y &2922 c8 INY &2923 d0 f1 BNE &2916 &2925 a9 c8 LDA #&c8 ; Read/Write BREAK/ESCAPE effect &2927 a2 03 LDX #&03 ; Clear memory on next RESET &2929 a0 00 LDY #&00 &292b 20 f4 ff JSR &fff4 ; OSBYTE &292e a0 00 LDY #&00 &2930 98 TYA &2931 18 CLC &2932 69 80 ADC #&80 &2934 49 8b EOR #&8b &2936 59 4a 29 EOR &294a,Y &2939 99 4a 29 STA &294a,Y &293c c8 INY &293d d0 f1 BNE &2930 &293f a9 c8 LDA #&c8 ; Read/Write BREAK/ESCAPE effect &2941 a2 03 LDX #&03 ; Clear memory on next RESET &2943 a0 00 LDY #&00 &2945 20 f4 ff JSR &fff4 ; OSBYTE &2948 a0 00 LDY #&00 &294a b9 55 29 LDA &2955,Y &294d 49 f1 EOR #&f1 &294f 99 55 29 STA &2955,Y &2952 c8 INY &2953 d0 f5 BNE &294a &2955 98 TYA &2956 49 f1 EOR #&f1 &2958 59 60 29 EOR &2960,Y &295b 99 60 29 STA &2960,Y &295e c8 INY &295f d0 f4 BNE &2955 &2961 98 TYA &2962 49 b3 EOR #&b3 &2964 59 6c 29 EOR &296c,Y &2967 99 6c 29 STA &296c,Y &296a c8 INY &296b d0 f4 BNE &2961 &296d 98 TYA &296e 18 CLC &296f 69 80 ADC #&80 &2971 49 96 EOR #&96 &2973 59 87 29 EOR &2987,Y &2976 99 87 29 STA &2987,Y &2979 c8 INY &297a d0 f1 BNE &296d &297c a9 c8 LDA #&c8 ; Read/Write BREAK/ESCAPE effect &297e a2 03 LDX #&03 ; Clear memory on next RESET &2980 a0 00 LDY #&00 &2982 20 f4 ff JSR &fff4 ; OSBYTE &2985 a0 00 LDY #&00 &2987 b9 92 29 LDA &2992,Y &298a 49 eb EOR #&eb &298c 99 92 29 STA &2992,Y &298f c8 INY &2990 d0 f5 BNE &2987 &2992 b9 9c 29 LDA &299c,Y &2995 49 db EOR #&db &2997 99 9c 29 STA &299c,Y &299a c8 INY &299b d0 f5 BNE &2992 &299d a9 4c LDA #&4c &299f 8d 87 02 STA &0287 ; BREAK intercept code &29a2 a9 02 LDA #&02 &29a4 8d 89 02 STA &0289 ; BREAK intercept code + 2 &29a7 a9 87 LDA #&87 &29a9 8d 88 02 STA &0288 ; BREAK intercept code + 1 &29ac 98 TYA &29ad 49 a0 EOR #&a0 &29af 59 b7 29 EOR &29b7,Y &29b2 99 b7 29 STA &29b7,Y &29b5 c8 INY &29b6 d0 f4 BNE &29ac &29b8 98 TYA &29b9 49 a1 EOR #&a1 &29bb 59 c3 29 EOR &29c3,Y &29be 99 c3 29 STA &29c3,Y &29c1 c8 INY &29c2 d0 f4 BNE &29b8 &29c4 98 TYA &29c5 18 CLC &29c6 69 80 ADC #&80 &29c8 49 ef EOR #&ef &29ca 59 de 29 EOR &29de,Y &29cd 99 de 29 STA &29de,Y &29d0 c8 INY &29d1 d0 f1 BNE &29c4 &29d3 a9 c8 LDA #&c8 ; Read/Write BREAK/ESCAPE effect &29d5 a2 03 LDX #&03 ; Clear memory on next RESET &29d7 a0 00 LDY #&00 &29d9 20 f4 ff JSR &fff4 ; OSBYTE &29dc a0 00 LDY #&00 &29de b9 e8 29 LDA &29e8,Y &29e1 49 c7 EOR #&c7 &29e3 99 e8 29 STA &29e8,Y &29e6 c8 INY &29e7 d0 f5 BNE &29de &29e9 a9 4c LDA #&4c &29eb 8d 87 02 STA &0287 ; BREAK intercept code &29ee a9 02 LDA #&02 &29f0 8d 89 02 STA &0289 ; BREAK intercept code + 2 &29f3 a9 87 LDA #&87 &29f5 8d 88 02 STA &0288 ; BREAK intercept code + 1 &29f8 98 TYA &29f9 59 02 2a EOR &2a02,Y &29fc 99 02 2a STA &2a02,Y &29ff c8 INY &2a00 d0 f6 BNE &29f8 &2a02 98 TYA &2a03 59 0c 2a EOR &2a0c,Y &2a06 99 0c 2a STA &2a0c,Y &2a09 c8 INY &2a0a d0 f6 BNE &2a02 &2a0c b9 16 2a LDA &2a16,Y &2a0f 49 8b EOR #&8b &2a11 99 16 2a STA &2a16,Y &2a14 c8 INY &2a15 d0 f5 BNE &2a0c &2a17 a9 4c LDA #&4c &2a19 8d 87 02 STA &0287 ; BREAK intercept code &2a1c a9 02 LDA #&02 &2a1e 8d 89 02 STA &0289 ; BREAK intercept code + 2 &2a21 a9 87 LDA #&87 &2a23 8d 88 02 STA &0288 ; BREAK intercept code + 1 &2a26 98 TYA &2a27 49 a1 EOR #&a1 &2a29 59 31 2a EOR &2a31,Y &2a2c 99 31 2a STA &2a31,Y &2a2f c8 INY &2a30 d0 f4 BNE &2a26 &2a32 98 TYA &2a33 59 3c 2a EOR &2a3c,Y &2a36 99 3c 2a STA &2a3c,Y &2a39 c8 INY &2a3a d0 f6 BNE &2a32 &2a3c 98 TYA &2a3d 59 46 2a EOR &2a46,Y &2a40 99 46 2a STA &2a46,Y &2a43 c8 INY &2a44 d0 f6 BNE &2a3c &2a46 98 TYA &2a47 49 bd EOR #&bd &2a49 59 51 2a EOR &2a51,Y &2a4c 99 51 2a STA &2a51,Y &2a4f c8 INY &2a50 d0 f4 BNE &2a46 &2a52 b9 5d 2a LDA &2a5d,Y &2a55 49 f7 EOR #&f7 &2a57 99 5d 2a STA &2a5d,Y &2a5a c8 INY &2a5b d0 f5 BNE &2a52 &2a5d 98 TYA &2a5e 59 67 2a EOR &2a67,Y &2a61 99 67 2a STA &2a67,Y &2a64 c8 INY &2a65 d0 f6 BNE &2a5d &2a67 98 TYA &2a68 18 CLC &2a69 69 80 ADC #&80 &2a6b 49 b3 EOR #&b3 &2a6d 59 81 2a EOR &2a81,Y &2a70 99 81 2a STA &2a81,Y &2a73 c8 INY &2a74 d0 f1 BNE &2a67 &2a76 a9 c8 LDA #&c8 ; Read/Write BREAK/ESCAPE effect &2a78 a2 03 LDX #&03 ; Clear memory on next RESET &2a7a a0 00 LDY #&00 &2a7c 20 f4 ff JSR &fff4 ; OSBYTE &2a7f a0 00 LDY #&00 &2a81 98 TYA &2a82 59 8b 2a EOR &2a8b,Y &2a85 99 8b 2a STA &2a8b,Y &2a88 c8 INY &2a89 d0 f6 BNE &2a81 &2a8b 98 TYA &2a8c 18 CLC &2a8d 69 80 ADC #&80 &2a8f 49 de EOR #&de &2a91 59 a5 2a EOR &2aa5,Y &2a94 99 a5 2a STA &2aa5,Y &2a97 c8 INY &2a98 d0 f1 BNE &2a8b &2a9a a9 c8 LDA #&c8 ; Read/Write BREAK/ESCAPE effect &2a9c a2 03 LDX #&03 ; Clear memory on next RESET &2a9e a0 00 LDY #&00 &2aa0 20 f4 ff JSR &fff4 ; OSBYTE &2aa3 a0 00 LDY #&00 &2aa5 b9 b0 2a LDA &2ab0,Y &2aa8 49 d2 EOR #&d2 &2aaa 99 b0 2a STA &2ab0,Y &2aad c8 INY &2aae d0 f5 BNE &2aa5 &2ab0 98 TYA &2ab1 18 CLC &2ab2 69 80 ADC #&80 &2ab4 49 f0 EOR #&f0 &2ab6 59 ca 2a EOR &2aca,Y &2ab9 99 ca 2a STA &2aca,Y &2abc c8 INY &2abd d0 f1 BNE &2ab0 &2abf a9 c8 LDA #&c8 ; Read/Write BREAK/ESCAPE effect &2ac1 a2 03 LDX #&03 ; Clear memory on next RESET &2ac3 a0 00 LDY #&00 &2ac5 20 f4 ff JSR &fff4 ; OSBYTE &2ac8 a0 00 LDY #&00 &2aca b9 d5 2a LDA &2ad5,Y &2acd 49 f6 EOR #&f6 &2acf 99 d5 2a STA &2ad5,Y &2ad2 c8 INY &2ad3 d0 f5 BNE &2aca &2ad5 98 TYA &2ad6 18 CLC &2ad7 69 80 ADC #&80 &2ad9 49 ee EOR #&ee &2adb 59 ef 2a EOR &2aef,Y &2ade 99 ef 2a STA &2aef,Y &2ae1 c8 INY &2ae2 d0 f1 BNE &2ad5 &2ae4 a9 c8 LDA #&c8 ; Read/Write BREAK/ESCAPE effect &2ae6 a2 03 LDX #&03 ; Clear memory on next RESET &2ae8 a0 00 LDY #&00 &2aea 20 f4 ff JSR &fff4 ; OSBYTE &2aed a0 00 LDY #&00 &2aef 98 TYA &2af0 59 f9 2a EOR &2af9,Y &2af3 99 f9 2a STA &2af9,Y &2af6 c8 INY &2af7 d0 f6 BNE &2aef &2af9 98 TYA &2afa 59 03 2b EOR &2b03,Y &2afd 99 03 2b STA &2b03,Y &2b00 c8 INY &2b01 d0 f6 BNE &2af9 &2b03 98 TYA &2b04 49 f5 EOR #&f5 &2b06 59 0e 2b EOR &2b0e,Y &2b09 99 0e 2b STA &2b0e,Y &2b0c c8 INY &2b0d d0 f4 BNE &2b03 &2b0f 98 TYA &2b10 18 CLC &2b11 69 80 ADC #&80 &2b13 49 fd EOR #&fd &2b15 59 29 2b EOR &2b29,Y &2b18 99 29 2b STA &2b29,Y &2b1b c8 INY &2b1c d0 f1 BNE &2b0f &2b1e a9 c8 LDA #&c8 ; Read/Write BREAK/ESCAPE effect &2b20 a2 03 LDX #&03 ; Clear memory on next RESET &2b22 a0 00 LDY #&00 &2b24 20 f4 ff JSR &fff4 ; OSBYTE &2b27 a0 00 LDY #&00 &2b29 b9 34 2b LDA &2b34,Y &2b2c 49 93 EOR #&93 &2b2e 99 34 2b STA &2b34,Y &2b31 c8 INY &2b32 d0 f5 BNE &2b29 &2b34 98 TYA &2b35 18 CLC &2b36 69 80 ADC #&80 &2b38 49 d9 EOR #&d9 &2b3a 59 4e 2b EOR &2b4e,Y &2b3d 99 4e 2b STA &2b4e,Y &2b40 c8 INY &2b41 d0 f1 BNE &2b34 &2b43 a9 c8 LDA #&c8 ; Read/Write BREAK/ESCAPE effect &2b45 a2 03 LDX #&03 ; Clear memory on next RESET &2b47 a0 00 LDY #&00 &2b49 20 f4 ff JSR &fff4 ; OSBYTE &2b4c a0 00 LDY #&00 &2b4e b9 58 2b LDA &2b58,Y &2b51 49 80 EOR #&80 &2b53 99 58 2b STA &2b58,Y &2b56 c8 INY &2b57 d0 f5 BNE &2b4e &2b59 a9 4c LDA #&4c &2b5b 8d 87 02 STA &0287 ; BREAK intercept code &2b5e a9 02 LDA #&02 &2b60 8d 89 02 STA &0289 ; BREAK intercept code + 2 &2b63 a9 87 LDA #&87 &2b65 8d 88 02 STA &0288 ; BREAK intercept code + 1 &2b68 98 TYA &2b69 49 d0 EOR #&d0 &2b6b 59 73 2b EOR &2b73,Y &2b6e 99 73 2b STA &2b73,Y &2b71 c8 INY &2b72 d0 f4 BNE &2b68 &2b74 98 TYA &2b75 49 f2 EOR #&f2 &2b77 59 7f 2b EOR &2b7f,Y &2b7a 99 7f 2b STA &2b7f,Y &2b7d c8 INY &2b7e d0 f4 BNE &2b74 &2b80 98 TYA &2b81 49 9c EOR #&9c &2b83 59 8b 2b EOR &2b8b,Y &2b86 99 8b 2b STA &2b8b,Y &2b89 c8 INY &2b8a d0 f4 BNE &2b80 &2b8c b9 97 2b LDA &2b97,Y &2b8f 49 ab EOR #&ab &2b91 99 97 2b STA &2b97,Y &2b94 c8 INY &2b95 d0 f5 BNE &2b8c &2b97 98 TYA &2b98 59 a1 2b EOR &2ba1,Y &2b9b 99 a1 2b STA &2ba1,Y &2b9e c8 INY &2b9f d0 f6 BNE &2b97 &2ba1 b9 ab 2b LDA &2bab,Y &2ba4 49 ee EOR #&ee &2ba6 99 ab 2b STA &2bab,Y &2ba9 c8 INY &2baa d0 f5 BNE &2ba1 &2bac a9 4c LDA #&4c &2bae 8d 87 02 STA &0287 ; BREAK intercept code &2bb1 a9 02 LDA #&02 &2bb3 8d 89 02 STA &0289 ; BREAK intercept code + 2 &2bb6 a9 87 LDA #&87 &2bb8 8d 88 02 STA &0288 ; BREAK intercept code + 1 &2bbb b9 c6 2b LDA &2bc6,Y &2bbe 49 93 EOR #&93 &2bc0 99 c6 2b STA &2bc6,Y &2bc3 c8 INY &2bc4 d0 f5 BNE &2bbb &2bc6 98 TYA &2bc7 49 b1 EOR #&b1 &2bc9 59 d1 2b EOR &2bd1,Y &2bcc 99 d1 2b STA &2bd1,Y &2bcf c8 INY &2bd0 d0 f4 BNE &2bc6 &2bd2 98 TYA &2bd3 59 dc 2b EOR &2bdc,Y &2bd6 99 dc 2b STA &2bdc,Y &2bd9 c8 INY &2bda d0 f6 BNE &2bd2 &2bdc 98 TYA &2bdd 49 95 EOR #&95 &2bdf 59 e7 2b EOR &2be7,Y &2be2 99 e7 2b STA &2be7,Y &2be5 c8 INY &2be6 d0 f4 BNE &2bdc &2be8 98 TYA &2be9 18 CLC &2bea 69 80 ADC #&80 &2bec 49 c2 EOR #&c2 &2bee 59 02 2c EOR &2c02,Y &2bf1 99 02 2c STA &2c02,Y &2bf4 c8 INY &2bf5 d0 f1 BNE &2be8 &2bf7 a9 c8 LDA #&c8 ; Read/Write BREAK/ESCAPE effect &2bf9 a2 03 LDX #&03 ; Clear memory on next RESET &2bfb a0 00 LDY #&00 &2bfd 20 f4 ff JSR &fff4 ; OSBYTE &2c00 a0 00 LDY #&00 &2c02 b9 0d 2c LDA &2c0d,Y &2c05 49 96 EOR #&96 &2c07 99 0d 2c STA &2c0d,Y &2c0a c8 INY &2c0b d0 f5 BNE &2c02 &2c0d b9 18 2c LDA &2c18,Y &2c10 49 e5 EOR #&e5 &2c12 99 18 2c STA &2c18,Y &2c15 c8 INY &2c16 d0 f5 BNE &2c0d &2c18 98 TYA &2c19 49 8b EOR #&8b &2c1b 59 23 2c EOR &2c23,Y &2c1e 99 23 2c STA &2c23,Y &2c21 c8 INY &2c22 d0 f4 BNE &2c18 &2c24 98 TYA &2c25 59 2e 2c EOR &2c2e,Y &2c28 99 2e 2c STA &2c2e,Y &2c2b c8 INY &2c2c d0 f6 BNE &2c24 &2c2e 98 TYA &2c2f 49 da EOR #&da &2c31 59 39 2c EOR &2c39,Y &2c34 99 39 2c STA &2c39,Y &2c37 c8 INY &2c38 d0 f4 BNE &2c2e &2c3a b9 45 2c LDA &2c45,Y &2c3d 49 c0 EOR #&c0 &2c3f 99 45 2c STA &2c45,Y &2c42 c8 INY &2c43 d0 f5 BNE &2c3a &2c45 98 TYA &2c46 59 4f 2c EOR &2c4f,Y &2c49 99 4f 2c STA &2c4f,Y &2c4c c8 INY &2c4d d0 f6 BNE &2c45 &2c4f 98 TYA &2c50 18 CLC &2c51 69 80 ADC #&80 &2c53 49 ec EOR #&ec &2c55 59 69 2c EOR &2c69,Y &2c58 99 69 2c STA &2c69,Y &2c5b c8 INY &2c5c d0 f1 BNE &2c4f &2c5e a9 c8 LDA #&c8 ; Read/Write BREAK/ESCAPE effect &2c60 a2 03 LDX #&03 ; Clear memory on next RESET &2c62 a0 00 LDY #&00 &2c64 20 f4 ff JSR &fff4 ; OSBYTE &2c67 a0 00 LDY #&00 &2c69 b9 73 2c LDA &2c73,Y &2c6c 49 b3 EOR #&b3 &2c6e 99 73 2c STA &2c73,Y &2c71 c8 INY &2c72 d0 f5 BNE &2c69 &2c74 a9 4c LDA #&4c &2c76 8d 87 02 STA &0287 ; BREAK intercept code &2c79 a9 02 LDA #&02 &2c7b 8d 89 02 STA &0289 ; BREAK intercept code + 2 &2c7e a9 87 LDA #&87 &2c80 8d 88 02 STA &0288 ; BREAK intercept code + 1 &2c83 98 TYA &2c84 49 c0 EOR #&c0 &2c86 59 8e 2c EOR &2c8e,Y &2c89 99 8e 2c STA &2c8e,Y &2c8c c8 INY &2c8d d0 f4 BNE &2c83 &2c8f b9 99 2c LDA &2c99,Y &2c92 49 ac EOR #&ac &2c94 99 99 2c STA &2c99,Y &2c97 c8 INY &2c98 d0 f5 BNE &2c8f &2c9a a9 4c LDA #&4c &2c9c 8d 87 02 STA &0287 ; BREAK intercept code &2c9f a9 02 LDA #&02 &2ca1 8d 89 02 STA &0289 ; BREAK intercept code + 2 &2ca4 a9 87 LDA #&87 &2ca6 8d 88 02 STA &0288 ; BREAK intercept code + 1 &2ca9 b9 b3 2c LDA &2cb3,Y &2cac 49 ce EOR #&ce &2cae 99 b3 2c STA &2cb3,Y &2cb1 c8 INY &2cb2 d0 f5 BNE &2ca9 &2cb4 a9 4c LDA #&4c &2cb6 8d 87 02 STA &0287 ; BREAK intercept code &2cb9 a9 02 LDA #&02 &2cbb 8d 89 02 STA &0289 ; BREAK intercept code + 2 &2cbe a9 87 LDA #&87 &2cc0 8d 88 02 STA &0288 ; BREAK intercept code + 1 &2cc3 b9 cd 2c LDA &2ccd,Y &2cc6 49 db EOR #&db &2cc8 99 cd 2c STA &2ccd,Y &2ccb c8 INY &2ccc d0 f5 BNE &2cc3 &2cce a9 4c LDA #&4c &2cd0 8d 87 02 STA &0287 ; BREAK intercept code &2cd3 a9 02 LDA #&02 &2cd5 8d 89 02 STA &0289 ; BREAK intercept code + 2 &2cd8 a9 87 LDA #&87 &2cda 8d 88 02 STA &0288 ; BREAK intercept code + 1 &2cdd b9 e8 2c LDA &2ce8,Y &2ce0 49 ea EOR #&ea &2ce2 99 e8 2c STA &2ce8,Y &2ce5 c8 INY &2ce6 d0 f5 BNE &2cdd &2ce8 98 TYA &2ce9 49 80 EOR #&80 &2ceb 59 f3 2c EOR &2cf3,Y &2cee 99 f3 2c STA &2cf3,Y &2cf1 c8 INY &2cf2 d0 f4 BNE &2ce8 &2cf4 b9 fe 2c LDA &2cfe,Y &2cf7 49 b9 EOR #&b9 &2cf9 99 fe 2c STA &2cfe,Y &2cfc c8 INY &2cfd d0 f5 BNE &2cf4 &2cff a9 4c LDA #&4c &2d01 8d 87 02 STA &0287 ; BREAK intercept code &2d04 a9 02 LDA #&02 &2d06 8d 89 02 STA &0289 ; BREAK intercept code + 2 &2d09 a9 87 LDA #&87 &2d0b 8d 88 02 STA &0288 ; BREAK intercept code + 1 &2d0e b9 18 2d LDA &2d18,Y &2d11 49 c0 EOR #&c0 &2d13 99 18 2d STA &2d18,Y &2d16 c8 INY &2d17 d0 f5 BNE &2d0e &2d19 a9 4c LDA #&4c &2d1b 8d 87 02 STA &0287 ; BREAK intercept code &2d1e a9 02 LDA #&02 &2d20 8d 89 02 STA &0289 ; BREAK intercept code + 2 &2d23 a9 87 LDA #&87 &2d25 8d 88 02 STA &0288 ; BREAK intercept code + 1 &2d28 98 TYA &2d29 18 CLC &2d2a 69 80 ADC #&80 &2d2c 49 c4 EOR #&c4 &2d2e 59 42 2d EOR &2d42,Y &2d31 99 42 2d STA &2d42,Y &2d34 c8 INY &2d35 d0 f1 BNE &2d28 &2d37 a9 c8 LDA #&c8 ; Read/Write BREAK/ESCAPE effect &2d39 a2 03 LDX #&03 ; Clear memory on next RESET &2d3b a0 00 LDY #&00 &2d3d 20 f4 ff JSR &fff4 ; OSBYTE &2d40 a0 00 LDY #&00 &2d42 b9 4d 2d LDA &2d4d,Y &2d45 49 e8 EOR #&e8 &2d47 99 4d 2d STA &2d4d,Y &2d4a c8 INY &2d4b d0 f5 BNE &2d42 &2d4d 98 TYA &2d4e 49 d1 EOR #&d1 &2d50 59 58 2d EOR &2d58,Y &2d53 99 58 2d STA &2d58,Y &2d56 c8 INY &2d57 d0 f4 BNE &2d4d &2d59 b9 63 2d LDA &2d63,Y &2d5c 49 cf EOR #&cf &2d5e 99 63 2d STA &2d63,Y &2d61 c8 INY &2d62 d0 f5 BNE &2d59 &2d64 a9 4c LDA #&4c &2d66 8d 87 02 STA &0287 ; BREAK intercept code &2d69 a9 02 LDA #&02 &2d6b 8d 89 02 STA &0289 ; BREAK intercept code + 2 &2d6e a9 87 LDA #&87 &2d70 8d 88 02 STA &0288 ; BREAK intercept code + 1 &2d73 b9 7e 2d LDA &2d7e,Y &2d76 49 e5 EOR #&e5 &2d78 99 7e 2d STA &2d7e,Y &2d7b c8 INY &2d7c d0 f5 BNE &2d73 &2d7e 98 TYA &2d7f 59 88 2d EOR &2d88,Y &2d82 99 88 2d STA &2d88,Y &2d85 c8 INY &2d86 d0 f6 BNE &2d7e &2d88 b9 92 2d LDA &2d92,Y &2d8b 49 80 EOR #&80 &2d8d 99 92 2d STA &2d92,Y &2d90 c8 INY &2d91 d0 f5 BNE &2d88 &2d93 a9 4c LDA #&4c &2d95 8d 87 02 STA &0287 ; BREAK intercept code &2d98 a9 02 LDA #&02 &2d9a 8d 89 02 STA &0289 ; BREAK intercept code + 2 &2d9d a9 87 LDA #&87 &2d9f 8d 88 02 STA &0288 ; BREAK intercept code + 1 &2da2 b9 ac 2d LDA &2dac,Y &2da5 49 c6 EOR #&c6 &2da7 99 ac 2d STA &2dac,Y &2daa c8 INY &2dab d0 f5 BNE &2da2 &2dad a9 4c LDA #&4c &2daf 8d 87 02 STA &0287 ; BREAK intercept code &2db2 a9 02 LDA #&02 &2db4 8d 89 02 STA &0289 ; BREAK intercept code + 2 &2db7 a9 87 LDA #&87 &2db9 8d 88 02 STA &0288 ; BREAK intercept code + 1 &2dbc 98 TYA &2dbd 59 c6 2d EOR &2dc6,Y &2dc0 99 c6 2d STA &2dc6,Y &2dc3 c8 INY &2dc4 d0 f6 BNE &2dbc &2dc6 98 TYA &2dc7 59 d0 2d EOR &2dd0,Y &2dca 99 d0 2d STA &2dd0,Y &2dcd c8 INY &2dce d0 f6 BNE &2dc6 &2dd0 98 TYA &2dd1 49 82 EOR #&82 &2dd3 59 db 2d EOR &2ddb,Y &2dd6 99 db 2d STA &2ddb,Y &2dd9 c8 INY &2dda d0 f4 BNE &2dd0 &2ddc 98 TYA &2ddd 18 CLC &2dde 69 80 ADC #&80 &2de0 49 a0 EOR #&a0 &2de2 59 f6 2d EOR &2df6,Y &2de5 99 f6 2d STA &2df6,Y &2de8 c8 INY &2de9 d0 f1 BNE &2ddc &2deb a9 c8 LDA #&c8 ; Read/Write BREAK/ESCAPE effect &2ded a2 03 LDX #&03 ; Clear memory on next RESET &2def a0 00 LDY #&00 &2df1 20 f4 ff JSR &fff4 ; OSBYTE &2df4 a0 00 LDY #&00 &2df6 98 TYA &2df7 59 00 2e EOR &2e00,Y &2dfa 99 00 2e STA &2e00,Y &2dfd c8 INY &2dfe d0 f6 BNE &2df6 &2e00 b9 0b 2e LDA &2e0b,Y &2e03 49 9d EOR #&9d &2e05 99 0b 2e STA &2e0b,Y &2e08 c8 INY &2e09 d0 f5 BNE &2e00 &2e0b b9 16 2e LDA &2e16,Y &2e0e 49 db EOR #&db &2e10 99 16 2e STA &2e16,Y &2e13 c8 INY &2e14 d0 f5 BNE &2e0b &2e16 b9 21 2e LDA &2e21,Y &2e19 49 99 EOR #&99 &2e1b 99 21 2e STA &2e21,Y &2e1e c8 INY &2e1f d0 f5 BNE &2e16 &2e21 98 TYA &2e22 59 2b 2e EOR &2e2b,Y &2e25 99 2b 2e STA &2e2b,Y &2e28 c8 INY &2e29 d0 f6 BNE &2e21 &2e2b 98 TYA &2e2c 18 CLC &2e2d 69 80 ADC #&80 &2e2f 49 e5 EOR #&e5 &2e31 59 45 2e EOR &2e45,Y &2e34 99 45 2e STA &2e45,Y &2e37 c8 INY &2e38 d0 f1 BNE &2e2b &2e3a a9 c8 LDA #&c8 ; Read/Write BREAK/ESCAPE effect &2e3c a2 03 LDX #&03 ; Clear memory on next RESET &2e3e a0 00 LDY #&00 &2e40 20 f4 ff JSR &fff4 ; OSBYTE &2e43 a0 00 LDY #&00 &2e45 98 TYA &2e46 49 b2 EOR #&b2 &2e48 59 50 2e EOR &2e50,Y &2e4b 99 50 2e STA &2e50,Y &2e4e c8 INY &2e4f d0 f4 BNE &2e45 &2e51 98 TYA &2e52 49 b2 EOR #&b2 &2e54 59 5c 2e EOR &2e5c,Y &2e57 99 5c 2e STA &2e5c,Y &2e5a c8 INY &2e5b d0 f4 BNE &2e51 &2e5d b9 68 2e LDA &2e68,Y &2e60 49 9e EOR #&9e &2e62 99 68 2e STA &2e68,Y &2e65 c8 INY &2e66 d0 f5 BNE &2e5d &2e68 98 TYA &2e69 59 72 2e EOR &2e72,Y &2e6c 99 72 2e STA &2e72,Y &2e6f c8 INY &2e70 d0 f6 BNE &2e68 &2e72 98 TYA &2e73 49 b5 EOR #&b5 &2e75 59 7d 2e EOR &2e7d,Y &2e78 99 7d 2e STA &2e7d,Y &2e7b c8 INY &2e7c d0 f4 BNE &2e72 &2e7e b9 89 2e LDA &2e89,Y &2e81 49 a3 EOR #&a3 &2e83 99 89 2e STA &2e89,Y &2e86 c8 INY &2e87 d0 f5 BNE &2e7e &2e89 98 TYA &2e8a 49 d6 EOR #&d6 &2e8c 59 94 2e EOR &2e94,Y &2e8f 99 94 2e STA &2e94,Y &2e92 c8 INY &2e93 d0 f4 BNE &2e89 &2e95 98 TYA &2e96 49 9b EOR #&9b &2e98 59 a0 2e EOR &2ea0,Y &2e9b 99 a0 2e STA &2ea0,Y &2e9e c8 INY &2e9f d0 f4 BNE &2e95 &2ea1 98 TYA &2ea2 18 CLC &2ea3 69 80 ADC #&80 &2ea5 49 ac EOR #&ac &2ea7 59 bb 2e EOR &2ebb,Y &2eaa 99 bb 2e STA &2ebb,Y &2ead c8 INY &2eae d0 f1 BNE &2ea1 &2eb0 a9 c8 LDA #&c8 ; Read/Write BREAK/ESCAPE effect &2eb2 a2 03 LDX #&03 ; Clear memory on next RESET &2eb4 a0 00 LDY #&00 &2eb6 20 f4 ff JSR &fff4 ; OSBYTE &2eb9 a0 00 LDY #&00 &2ebb 98 TYA &2ebc 18 CLC &2ebd 69 80 ADC #&80 &2ebf 49 88 EOR #&88 &2ec1 59 d5 2e EOR &2ed5,Y &2ec4 99 d5 2e STA &2ed5,Y &2ec7 c8 INY &2ec8 d0 f1 BNE &2ebb &2eca a9 c8 LDA #&c8 ; Read/Write BREAK/ESCAPE effect &2ecc a2 03 LDX #&03 ; Clear memory on next RESET &2ece a0 00 LDY #&00 &2ed0 20 f4 ff JSR &fff4 ; OSBYTE &2ed3 a0 00 LDY #&00 &2ed5 b9 df 2e LDA &2edf,Y &2ed8 49 b0 EOR #&b0 &2eda 99 df 2e STA &2edf,Y &2edd c8 INY &2ede d0 f5 BNE &2ed5 &2ee0 a9 4c LDA #&4c &2ee2 8d 87 02 STA &0287 ; BREAK intercept code &2ee5 a9 02 LDA #&02 &2ee7 8d 89 02 STA &0289 ; BREAK intercept code + 2 &2eea a9 87 LDA #&87 &2eec 8d 88 02 STA &0288 ; BREAK intercept code + 1 &2eef b9 fa 2e LDA &2efa,Y &2ef2 49 92 EOR #&92 &2ef4 99 fa 2e STA &2efa,Y &2ef7 c8 INY &2ef8 d0 f5 BNE &2eef &2efa 98 TYA &2efb 59 04 2f EOR &2f04,Y &2efe 99 04 2f STA &2f04,Y &2f01 c8 INY &2f02 d0 f6 BNE &2efa &2f04 98 TYA &2f05 49 99 EOR #&99 &2f07 59 0f 2f EOR &2f0f,Y &2f0a 99 0f 2f STA &2f0f,Y &2f0d c8 INY &2f0e d0 f4 BNE &2f04 &2f10 b9 1a 2f LDA &2f1a,Y &2f13 49 b1 EOR #&b1 &2f15 99 1a 2f STA &2f1a,Y &2f18 c8 INY &2f19 d0 f5 BNE &2f10 &2f1b a9 4c LDA #&4c &2f1d 8d 87 02 STA &0287 ; BREAK intercept code &2f20 a9 02 LDA #&02 &2f22 8d 89 02 STA &0289 ; BREAK intercept code + 2 &2f25 a9 87 LDA #&87 &2f27 8d 88 02 STA &0288 ; BREAK intercept code + 1 &2f2a 98 TYA &2f2b 49 d9 EOR #&d9 &2f2d 59 35 2f EOR &2f35,Y &2f30 99 35 2f STA &2f35,Y &2f33 c8 INY &2f34 d0 f4 BNE &2f2a &2f36 b9 40 2f LDA &2f40,Y &2f39 49 b3 EOR #&b3 &2f3b 99 40 2f STA &2f40,Y &2f3e c8 INY &2f3f d0 f5 BNE &2f36 &2f41 a9 4c LDA #&4c &2f43 8d 87 02 STA &0287 ; BREAK intercept code &2f46 a9 02 LDA #&02 &2f48 8d 89 02 STA &0289 ; BREAK intercept code + 2 &2f4b a9 87 LDA #&87 &2f4d 8d 88 02 STA &0288 ; BREAK intercept code + 1 &2f50 98 TYA &2f51 18 CLC &2f52 69 80 ADC #&80 &2f54 49 c8 EOR #&c8 &2f56 59 6a 2f EOR &2f6a,Y &2f59 99 6a 2f STA &2f6a,Y &2f5c c8 INY &2f5d d0 f1 BNE &2f50 &2f5f a9 c8 LDA #&c8 ; Read/Write BREAK/ESCAPE effect &2f61 a2 03 LDX #&03 ; Clear memory on next RESET &2f63 a0 00 LDY #&00 &2f65 20 f4 ff JSR &fff4 ; OSBYTE &2f68 a0 00 LDY #&00 &2f6a 4c bd 2f JMP &2fbd ; decrypt_via_decryption ; unused # &2f6d - &2fbc is never executed &2f6d 49 dd EOR #&dd &2f6f 99 74 2f STA &2f74,Y &2f72 c8 INY &2f73 d0 28 BNE &2f9d &2f75 a9 4c LDA #&4c &2f77 8d 87 02 STA &0287 ; BREAK intercept code &2f7a a9 02 LDA #&02 &2f7c 8d 89 02 STA &0289 ; BREAK intercept code + 2 &2f7f a9 87 LDA #&87 &2f81 8d 88 02 STA &0288 ; BREAK intercept code + 1 &2f84 b9 8e 2f LDA &2f8e,Y &2f87 49 d6 EOR #&d6 &2f89 99 8e 2f STA &2f8e,Y &2f8c c8 INY &2f8d d0 23 BNE &2fb2 &2f8f a9 4c LDA #&4c &2f91 8d 87 02 STA &0287 ; BREAK intercept code &2f94 a9 02 LDA #&02 &2f96 8d 89 02 STA &0289 ; BREAK intercept code + 2 &2f99 a9 87 LDA #&87 &2f9b 8d 88 02 STA &0288 ; BREAK intercept code + 1 &2f9e 98 TYA &2f9f 49 99 EOR #&99 &2fa1 59 a9 2f EOR &2fa9,Y &2fa4 99 a9 2f STA &2fa9,Y &2fa7 c8 INY &2fa8 d0 6d BNE &3017 &2faa 98 TYA &2fab 18 CLC &2fac 69 80 ADC #&80 &2fae 49 e9 EOR #&e9 &2fb0 59 c4 2f EOR &2fc4,Y &2fb3 99 c4 2f STA &2fc4,Y &2fb6 c8 INY &2fb7 d0 f1 BNE &2faa &2fb9 a9 c8 LDA #&c8 &2fbb a2 03 LDX #&03 ; decrypt_via_decryption &2fbd a0 00 LDY #&00 # Decrypt main decryption routine &2fbf 84 8e STY &8e ; address_low &2fc1 a9 30 LDA #&30 ; &3000 = via_decryption &2fc3 85 8f STA &8f ; address_high &2fc5 84 8d STY &8d ; eor &2fc7 a2 06 LDX #&06 ; decrypt_via_decryption_loop # Decrypt &3000 - &35ff &2fc9 98 TYA &2fca 51 8e EOR (&8e),Y ; address &2fcc 49 ad EOR #&ad &2fce 91 8e STA (&8e),Y ; address &2fd0 45 8d EOR &8d ; eor &2fd2 85 8d STA &8d ; eor &2fd4 c8 INY &2fd5 d0 f2 BNE &2fc9 ; decrypt_via_decryption_loop &2fd7 e6 8f INC &8f ; address_high &2fd9 ca DEX &2fda d0 ed BNE &2fc9 ; decrypt_via_decryption_loop &2fdc 78 SEI &2fdd a9 4c LDA #&4c &2fdf 8d 87 02 STA &0287 ; BREAK intercept code &2fe2 a9 02 LDA #&02 &2fe4 8d 89 02 STA &0289 ; BREAK intercept code + 2 &2fe7 a9 87 LDA #&87 &2fe9 8d 88 02 STA &0288 ; BREAK intercept code + 1 &2fec a5 8d LDA &8d ; eor &2fee c9 62 CMP #&62 &2ff0 f0 03 BEQ &2ff5 ; skip_reset # Reset system if decrypted data not as expected &2ff2 6c fc ff JMP (&fffc) ; os_reset_address ; skip_reset &2ff5 a0 00 LDY #&00 ; copy_0800_loop &2ff7 b9 00 08 LDA &0800,Y # Copy &0800 - &08ff to &1100 - &11ff &2ffa 99 00 11 STA &1100,Y # (OS sound workspace, buffers and envelopes) &2ffd c8 INY &2ffe d0 f7 BNE &2ff7 ; copy_0800_loop ; via_decryption &3000 a9 0f LDA #&0f ; Flush all buffers &3002 a2 00 LDX #&00 &3004 20 f4 ff JSR &fff4 ; OSBYTE &3007 a9 c8 LDA #&c8 ; Read/Write BREAK/ESCAPE effect &3009 a2 03 LDX #&03 ; Clear memory on next RESET &300b a0 00 LDY #&00 &300d 20 f4 ff JSR &fff4 ; OSBYTE &3010 78 SEI &3011 a9 df LDA #&df # Set User VIA timer 2 to timed interrupt &3013 2d 6b fe AND &fe6b ; User VIA auxiliary control register &3016 8d 6b fe STA &fe6b ; User VIA auxiliary control register &3019 a9 a0 LDA #&a0 # Enable interrupts for User VIA timer 2 &301b 8d 6e fe STA &fe6e ; User VIA interrupt enable register &301e a9 00 LDA #&00 &3020 8d 68 fe STA &fe68 ; User VIA timer 2 counter LSB &3023 8d 69 fe STA &fe69 ; User VIA timer 2 counter MSB &3026 38 SEC &3027 a2 00 LDX #&00 # 256 rounds &3029 a0 00 LDY #&00 ; via_decryption_loop &302b b9 00 31 LDA &3100,Y ; payload &302e 59 41 32 EOR &3241,Y # Runs over &3241 - &3340 &3031 4d 00 34 EOR &3400 # actually EOR &3400 + via_decryption_offset_one # Runs over &3400 - &34ff &3034 4d 68 fe EOR &fe68 ; User VIA timer 2 counter LSB &3037 5d 01 32 EOR &3201,X # Runs over &3201 - &3300 &303a 48 PHA &303b a9 7f LDA #&7f # Disable all system interrupts &303d 8d 4e fe STA &fe4e ; System VIA interrupt enable register &3040 68 PLA &3041 5d 46 32 EOR &3246,X # Runs over &3246 - &3345 &3044 4d 69 fe EOR &fe69 ; User VIA timer 2 counter MSB &3047 4d 24 33 EOR &3324 # actually EOR &3300 + via_decryption_offset_two # Runs over &3300 - &33ff, starting at &3324 &304a 5d f2 33 EOR &33f2,X # Runs over &33f2 - &34f1 &304d 59 01 32 EOR &3201,Y # Runs over &3201 - &3300 &3050 49 38 EOR #&38 &3052 4d 68 fe EOR &fe68 ; User VIA timer 2 counter LSB &3055 5d 24 33 EOR &3324,X # Runs over &3324 - &3423 &3058 4d 83 33 EOR &3383 # actually EOR &3300 + via_decryption_offset_three # Runs over &3300 - &33ff, starting at &3383 &305b 4d 69 fe EOR &fe69 ; User VIA timer 2 counter MSB &305e 5d 01 33 EOR &3301,X # Runs over &3301 - &3400 &3061 59 84 33 EOR &3384,Y # Runs over &3384 - &3483 &3064 4d 68 fe EOR &fe68 ; User VIA timer 2 counter LSB &3067 4d ff 33 EOR &33ff # actually EOR &3300 + via_decryption_offset_four # Runs over &3300 - &33ff, starting at &33ff &306a 59 81 32 EOR &3281,Y # Runs over &3281 - &3380 &306d 4d 68 fe EOR &fe68 ; User VIA timer 2 counter LSB &3070 4d 69 fe EOR &fe69 ; User VIA timer 2 counter MSB &3073 4d 77 32 EOR &3277 # actually EOR &3200 + via_decryption_offset_five # Runs over &3200 - &32ff, starting at &3277 &3076 4d 68 fe EOR &fe68 ; User VIA timer 2 counter LSB &3079 4d 69 fe EOR &fe69 ; User VIA timer 2 counter MSB &307c 4d 5a 33 EOR &335a # actually EOR &3300 + via_decryption_offset_six # Runs over &3300 - &33ff, starting at &335a &307f 59 33 33 EOR &3333,Y # Runs over &3333 - &3432 &3082 4d 69 fe EOR &fe69 ; User VIA timer 2 counter MSB &3085 5d 71 33 EOR &3371,X # Runs over &3371 - &3470 &3088 5d 01 32 EOR &3201,X # Runs over &3201 - &3300 &308b 59 01 32 EOR &3201,Y # Runs over &3201 - &3300 &308e 99 00 31 STA &3100,Y ; payload &3091 ad 68 30 LDA &3068 ; via_decryption_offset_four &3094 4d 68 fe EOR &fe68 ; User VIA timer 2 counter LSB &3097 4d 69 fe EOR &fe69 ; User VIA timer 2 counter MSB &309a 8d 68 30 STA &3068 ; via_decryption_offset_four &309d 4d 7d 30 EOR &307d ; via_decryption_offset_six &30a0 49 38 EOR #&38 &30a2 4d 68 fe EOR &fe68 ; User VIA timer 2 counter LSB &30a5 8d 7d 30 STA &307d ; via_decryption_offset_six &30a8 4d 48 30 EOR &3048 ; via_decryption_offset_two &30ab 4d 69 fe EOR &fe69 ; User VIA timer 2 counter MSB &30ae 4d 68 30 EOR &3068 ; via_decryption_offset_four &30b1 4d 74 30 EOR &3074 ; via_decryption_offset_five &30b4 8d 48 30 STA &3048 ; via_decryption_offset_two &30b7 4d 32 30 EOR &3032 ; via_decryption_offset_one &30ba 4d 48 30 EOR &3048 ; via_decryption_offset_two &30bd 8d 32 30 STA &3032 ; via_decryption_offset_one &30c0 4d 74 30 EOR &3074 ; via_decryption_offset_five &30c3 4d 68 fe EOR &fe68 ; User VIA timer 2 counter LSB &30c6 e9 c8 SBC #&c8 &30c8 4d 32 30 EOR &3032 ; via_decryption_offset_one &30cb 8d 74 30 STA &3074 ; via_decryption_offset_five &30ce 4d 48 30 EOR &3048 ; via_decryption_offset_two &30d1 4d 59 30 EOR &3059 ; via_decryption_offset_three &30d4 4d 69 fe EOR &fe69 ; User VIA timer 2 counter MSB &30d7 8d 59 30 STA &3059 ; via_decryption_offset_three &30da c8 INY &30db f0 03 BEQ &30e0 ; next_round &30dd 4c 2b 30 JMP &302b ; via_decryption_loop ; next_round # Run over every byte of payload 256 times &30e0 e8 INX &30e1 f0 03 BEQ &30e6 ; finished_decryption &30e3 4c 2b 30 JMP &302b ; via_decryption_loop ; finished_decryption &30e6 a9 20 LDA #&20 # Disable interrupts for User VIA timer 2 &30e8 8d 6e fe STA &fe6e ; User VIA interrupt enable register &30eb a2 00 LDX #&00 &30ed 8a TXA ; wipe_3000_to_30ea_loop # Wipe &3000 - &30ea (via_decryption) &30ee 9d 00 30 STA &3000,X ; via_decryption &30f1 e8 INX &30f2 e0 eb CPX #&eb &30f4 d0 f8 BNE &30ee ; wipe_3000_to_30ea_loop &30f6 a2 00 LDX #&00 &30f8 8a TXA ; checksum_3100_to_31ff_loop &30f9 18 CLC &30fa 7d 00 31 ADC &3100,X ; payload # Ensure &3100 - &31ff (payload) is as expected &30fd e8 INX # Note that &3000 - &30ff (via_decryption) is never &30fe d0 f9 BNE &30f9 ; checksum_3100_to_31ff_loop # checked, so could be trapped at &30e6 - &30ff ; payload &3100 cd 00 32 CMP &3200 ; expected_checksum &3103 f0 03 BEQ &3108 ; checksum_matches ; to_reset &3105 6c fc ff JMP (&fffc) ; os_reset_address # Reset system if payload not as expected ; checksum_matches &3108 2c e5 fe BIT &fee5 ; tube ULA data register 3 # Reset system if second processor present ? &310b 10 f8 BPL &3105 ; to_reset ; reset_vector_table # Reset all vectors to OS defaults &310d ad b7 ff LDA &ffb7 ; os_rom_default_vector_table_address_low &3110 85 10 STA &10 ; default_vector_table_address_low &3112 ad b8 ff LDA &ffb8 ; os_rom_default_vector_table_address_high &3115 85 11 STA &11 ; default_vector_table_address_high &3117 ac b9 ff LDY &ffb9 ; OSRDRM # Bug: should be &ffb6, os_rom_vector_table_length ; reset_vector_table_loop &311a b1 10 LDA (&10),Y ; default_vector_table_address &311c 99 00 02 STA &0200,Y ; os_vector_table &311f 88 DEY &3120 10 f8 BPL &311a ; reset_vector_table_loop ; check_roms &3122 a2 00 LDX #&00 ; check_roms_loop &3124 8e 30 fe STX &fe30 ; paged ROM latch # Check each ROM in turn &3127 ad 09 80 LDA &8009 ; rom_title_string &312a 29 df AND #&df &312c c9 52 CMP #&52 ; "R" &312e d0 12 BNE &3142 &3130 ad 0a 80 LDA &800a ; rom_title_string + 1 &3133 29 df AND #&df &3135 c9 45 CMP #&45 ; "E" &3137 d0 09 BNE &3142 &3139 ad 0b 80 LDA &800b ; rom_title_string + 2 &313c 29 df AND #&df &313e c9 50 CMP #&50 ; "P" &3140 f0 c3 BEQ &3105 ; to_reset # Reset system if Replay ROM detected &3142 e8 INX &3143 d0 df BNE &3124 ; check_roms_loop ; make_cypher_table # Make a pseudo-random table at &0600 - &06ff &3145 a9 df LDA #&df # Set User VIA timer 2 to timed interrupt &3147 2d 6b fe AND &fe6b ; User VIA auxiliary control register &314a 8d 6b fe STA &fe6b ; User VIA auxiliary control register &314d a9 a0 LDA #&a0 # Enable interrupts for User VIA timer 2 &314f 8d 6e fe STA &fe6e ; User VIA interrupt enable register &3152 a9 00 LDA #&00 &3154 8d 68 fe STA &fe68 ; User VIA timer 2 counter LSB &3157 8d 69 fe STA &fe69 ; User VIA timer 2 counter MSB &315a a2 00 LDX #&00 ; initialise_cypher_table_loop &315c 8a TXA &315d 49 ff EOR #&ff &315f 9d 00 06 STA &0600,X ; cypher_table &3162 e8 INX &3163 d0 f7 BNE &315c ; initialise_cypher_table_loop &3165 a2 00 LDX #&00 ; scramble_cypher_table_x_loop &3167 86 70 STX &70 ; x &3169 a0 00 LDY #&00 ; scramble_cypher_table_y_loop &316b 84 71 STY &71 ; y &316d ae 68 fe LDX &fe68 ; User VIA timer 2 counter LSB &3170 bd 00 06 LDA &0600,X ; cypher_table &3173 85 72 STA &72 ; tmp &3175 e8 INX &3176 bd 00 06 LDA &0600,X ; cypher_table &3179 ca DEX &317a 9d 00 06 STA &0600,X ; cypher_table &317d e8 INX &317e a5 72 LDA &72 ; tmp &3180 9d 00 06 STA &0600,X ; cypher_table &3183 ac 68 fe LDY &fe68 ; User VIA timer 2 counter LSB &3186 ae 69 fe LDX &fe69 ; User VIA timer 2 counter MSB &3189 bd 00 06 LDA &0600,X ; cypher_table &318c 85 72 STA &72 ; tmp &318e b9 00 06 LDA &0600,Y ; cypher_table &3191 9d 00 06 STA &0600,X ; cypher_table &3194 a5 72 LDA &72 ; tmp &3196 99 00 06 STA &0600,Y ; cypher_table &3199 a4 71 LDY &71 ; y &319b c8 INY &319c d0 cd BNE &316b ; scramble_cypher_table_y_loop &319e a6 70 LDX &70 ; x &31a0 e8 INX &31a1 d0 c4 BNE &3167 ; scramble_cypher_table_x_loop ; decrypt_tape_loader &31a3 a9 20 LDA #&20 # Disable interrupts for User VIA timer 2 &31a5 8d 6e fe STA &fe6e ; User VIA interrupt enable register &31a8 a0 00 LDY #&00 &31aa 84 10 STY &10 ; target_address_low &31ac a9 20 LDA #&20 ; &2000 = prepare_tape_loader &31ae 85 11 STA &11 ; target_address_high &31b0 a9 01 LDA #&01 &31b2 85 12 STA &12 ; source_address_low &31b4 a9 32 LDA #&32 ; &3201 = encrypted_tape_loader &31b6 85 13 STA &13 ; source_address_high &31b8 a9 0f LDA #&0f &31ba 85 ff STA &ff ; pages_to_decrypt ; decrypt_tape_loader_loop # Decrypt &3201 - &4200 to &2000 - &2fff &31bc b1 12 LDA (&12),Y ; source_address &31be 59 00 06 EOR &0600,Y ; cypher_table # using previously generated pseudo-random table &31c1 91 10 STA (&10),Y ; target_address &31c3 8a TXA &31c4 91 12 STA (&12),Y ; source_address # Wipe encrypted data &31c6 c8 INY &31c7 d0 f3 BNE &31bc ; decrypt_tape_loader_loop &31c9 e6 11 INC &11 ; target_address_high &31cb e6 13 INC &13 ; source_address_high &31cd c6 ff DEC &ff ; pages_to_decrypt &31cf 10 eb BPL &31bc ; decrypt_tape_loader_loop &31d1 a9 c8 LDA #&c8 ; Read/Write BREAK/ESCAPE effect &31d3 a2 03 LDX #&03 ; Clear memory on next RESET &31d5 20 f4 ff JSR &fff4 ; OSBYTE &31d8 a9 ff LDA #&ff # Enable all system interrupts &31da 8d 4e fe STA &fe4e ; System VIA interrupt enable register &31dd 4c 00 20 JMP &2000 ; prepare_tape_loader ; unused &31e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 &31f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ; expected_checksum &3200 00 # &3201 - &4200 is decrypted to &2000 - &2fff at &31bc ; prepare_tape_loader &2000 a2 00 LDX #&00 ; backup_zero_page_loop &2002 b5 00 LDA &00,X # Copy &0000 - &00ff to &0100 - &01ff &2004 9d 00 01 STA &0100,X &2007 e8 INX &2008 10 f8 BPL &2002 ; backup_zero_page_loop ; move_loading_screen &200a a0 00 LDY #&00 &200c 84 00 STY &00 ; target_address_low &200e 84 02 STY &02 ; source_address_low &2010 a9 4c LDA #&4c ; &4c00 &2012 85 01 STA &01 ; target_address_high &2014 a9 50 LDA #&50 ; &5000 &2016 85 03 STA &03 ; source_address_high ; move_loading_screen_loop # Move &5000 - &7fff to &4c00 - &7bff &2018 b1 02 LDA (&02),Y ; source_address &201a 91 00 STA (&00),Y ; target_address &201c a9 00 LDA #&00 &201e 91 02 STA (&02),Y ; source_address # Wipe &7c00 - &7fff as part of this &2020 c8 INY &2021 d0 f5 BNE &2018 ; move_loading_screen_loop &2023 e6 01 INC &01 ; target_address_high &2025 e6 03 INC &03 ; source_address_high &2027 10 ef BPL &2018 ; move_loading_screen_loop ; disable_shadow_memory &2029 a9 72 LDA #&72 ; Specify video memory to use on next MODE change &202b a2 01 LDX #&01 ; only use shadow memory if MODE number is > 127 &202d a0 00 LDY #&00 &202f 20 f4 ff JSR &fff4 ; OSBYTE ; create_font_data # Populate &0900 - &0bff with character definitions &2032 a9 14 LDA #&14 ; Implode user defined character font RAM &2034 a2 00 LDX #&00 &2036 20 f4 ff JSR &fff4 ; OSBYTE &2039 a9 00 LDA #&00 &203b 85 00 STA &00 ; font_address_low &203d a9 09 LDA #&09 ; &0900 = font_data &203f 85 01 STA &01 ; font_address_high &2041 a9 20 LDA #&20 ; " " &2043 85 02 STA &02 ; character ; create_font_data_loop &2045 a2 02 LDX #&02 &2047 a0 00 LDY #&00 ; &0002 &2049 a9 0a LDA #&0a ; Read character definition &204b 20 f1 ff JSR &fff1 ; OSWORD &204e a0 07 LDY #&07 ; copy_character_loop &2050 b9 03 00 LDA &0003,Y ; character + 1 # &0003 - &000a contains character definition &2053 91 00 STA (&00),Y ; font_address &2055 88 DEY &2056 10 f8 BPL &2050 ; copy_character_loop &2058 a5 00 LDA &00 ; font_address_low &205a 18 CLC &205b 69 08 ADC #&08 &205d 85 00 STA &00 ; font_address_low &205f a5 01 LDA &01 ; font_address_high &2061 69 00 ADC #&00 &2063 85 01 STA &01 ; font_address_high &2065 e6 02 INC &02 &2067 10 dc BPL &2045 ; create_font_data_loop &2069 78 SEI &206a a2 ff LDX #&ff &206c 9a TXS ; relocate_tape_loader &206d a9 bc LDA #&bc &206f 85 00 STA &00 ; source_address_low &2071 a9 20 LDA #&20 ; &20bc = unrelocated_tape_loader &2073 85 01 STA &01 ; source_address_high &2075 a9 04 LDA #&04 ; &0400 = tape_loader &2077 85 03 STA &03 ; target_address_high &2079 a0 00 LDY #&00 &207b 84 02 STY &02 ; target_address_low ; relocate_tape_loader_loop # Move &20bc - &24bb to &0400 - &08ff &207d b1 00 LDA (&00),Y ; source_address &207f 91 02 STA (&02),Y ; target_address &2081 c8 INY &2082 d0 f9 BNE &207d ; relocate_tape_loader_loop &2084 e6 01 INC &01 ; source_address_high &2086 e6 03 INC &03 ; target_address_high &2088 a5 03 LDA &03 ; target_address_high &208a c9 09 CMP #&09 &208c d0 ef BNE &207d ; relocate_tape_loader_loop &208e a9 c8 LDA #&c8 ; Read/Write BREAK/ESCAPE effect &2090 a2 03 LDX #&03 &2092 20 f4 ff JSR &fff4 ; OSBYTE &2095 a9 7f LDA #&7f # Disable all interrupts &2097 8d 6e fe STA &fe6e ; User VIA interrupt enable register &209a 8d 4e fe STA &fe4e ; System VIA interrupt enable register &209d a2 06 LDX #&06 # R6: Vertical displayed register &209f a9 1a LDA #&1a &20a1 20 5d 06 JSR &065d ; set_video_register &20a4 a2 0c LDX #&0c # R12: Displayed screen start address register (high) &20a6 a9 09 LDA #&09 &20a8 20 5d 06 JSR &065d ; set_video_register &20ab a2 0d LDX #&0d # R13: Displayed screen start address register (low) &20ad a9 80 LDA #&80 # Set screen start address to &4c00 &20af 20 5d 06 JSR &065d ; set_video_register &20b2 a2 07 LDX #&07 # R7: Vertical sync position &20b4 a9 20 LDA #&20 &20b6 20 5d 06 JSR &065d ; set_video_register &20b9 4c 00 04 JMP &0400 ; tape_loader # &20bc - &24bc is moved to &0400 - &08ff at &207d ; tape_loader &0400 78 SEI &0401 20 50 06 JSR &0650 ; clear_status_area &0404 a0 00 LDY #&00 ; delay_loop &0406 98 TYA &0407 48 PHA &0408 a2 ff LDX #&ff # Unnecessary code &040a 86 60 STX &60 ; unused &040c e8 INX &040d 86 61 STX &61 ; unused &040f a2 05 LDX #&05 &0411 20 08 06 JSR &0608 ; set_text_position &0414 a9 02 LDA #&02 ; C &0416 8d 07 06 STA &0607 ; text_colour &0419 20 2f 06 JSR &062f ; plot_text &041c 4c 6f 6f 6b 69 6e 67 20 66 6f 72 20 53 74 61 72 ; "Looking for Star" &042c 20 51 75 61 6b 65 00 ; "Quake" &0433 68 PLA &0434 a8 TAY &0435 88 DEY &0436 d0 ce BNE &0406 ; delay_loop &0438 58 CLI ; start_load &0439 a2 ff LDX #&ff &043b 9a TXS &043c a2 0e LDX #&0e # Turn off CAPS LOCK LED &043e 8e 40 fe STX &fe40 ; System VIA port B input/output register &0441 e8 INX ; &0f # Turn off SHIFT LOCK LED &0442 8e 40 fe STX &fe40 ; System VIA port B input/output register &0445 a9 85 LDA #&85 # Set to 2400 baud, switch on cassette motor &0447 8d 10 fe STA &fe10 ; Serial ULA control register &044a a9 1f LDA #&1f # Master reset &044c 8d 08 fe STA &fe08 ; Cassette ACIA control register &044f a9 1d LDA #&1d # 8 bit word, 1 stop bit, even parity, 1200 baud &0451 8d 08 fe STA &fe08 ; Cassette ACIA control register &0454 a0 00 LDY #&00 &0456 84 02 STY &02 ; waiting_for_start_of_data # Zero to indicate waiting for start of data &0458 84 00 STY &00 ; load_address_low &045a a9 12 LDA #&12 ; &1200 # Start loading main binary at &1200 &045c 85 01 STA &01 ; load_address_high ; wait_for_start_of_actual_data # Actual data starts with &aa &4b &4d &00 sequence &045e 20 64 06 JSR &0664 ; get_byte_from_tape &0461 c9 aa CMP #&aa &0463 d0 f9 BNE &045e ; wait_for_start_of_actual_data &0465 20 64 06 JSR &0664 ; get_byte_from_tape &0468 c9 4b CMP #&4b ; "K" &046a d0 f2 BNE &045e ; wait_for_start_of_actual_data &046c 20 64 06 JSR &0664 ; get_byte_from_tape &046f c9 4d CMP #&4d ; "M" &0471 d0 eb BNE &045e ; wait_for_start_of_actual_data &0473 20 64 06 JSR &0664 ; get_byte_from_tape &0476 c9 00 CMP #&00 &0478 d0 e4 BNE &045e ; wait_for_start_of_actual_data &047a 85 04 STA &04 ; decryption_code_byte &047c a9 64 LDA #&64 &047e 85 02 STA &02 ; waiting_for_start_of_data # Non-zero to indicate reading data &0480 85 05 STA &05 ; bytes_remaining_in_sector # 100 bytes of data per sector &0482 a9 32 LDA #&32 ; "2" &0484 85 1e STA &1e ; sectors &0486 a9 35 LDA #&35 ; "5" &0488 85 1f STA &1f ; sectors + 1 &048a 85 20 STA &20 ; sectors + 2 &048c 20 50 06 JSR &0650 ; clear_status_area &048f 20 6d 05 JSR &056d ; plot_sectors_left ; read_data_loop &0492 20 64 06 JSR &0664 ; get_byte_from_tape &0495 84 03 STY &03 ; load_address_offset &0497 45 03 EOR &03 ; load_address_offset &0499 45 01 EOR &01 ; load_address_high &049b 20 2e 05 JSR &052e ; decrypt_byte &049e 91 00 STA (&00),Y ; load_address &04a0 c6 05 DEC &05 ; bytes_remaining_in_sector &04a2 d0 03 BNE &04a7 ; not_new_sector &04a4 20 3b 05 JSR &053b ; decrement_sector_count ; not_new_sector &04a7 c8 INY &04a8 d0 e8 BNE &0492 ; read_data_loop &04aa e6 01 INC &01 ; load_address_high &04ac a5 01 LDA &01 ; load_address_high &04ae c9 76 CMP #&76 ; &7600 &04b0 d0 e0 BNE &0492 ; read_data_loop &04b2 8c 10 fe STY &fe10 ; Serial ULA control register # Switch off cassette motor &04b5 20 50 06 JSR &0650 ; clear_status_area &04b8 a9 01 LDA #&01 ; R &04ba 8d 07 06 STA &0607 ; text_colour &04bd a2 07 LDX #&07 &04bf 20 08 06 JSR &0608 ; set_text_position &04c2 20 2f 06 JSR &062f ; plot_text &04c5 54 68 69 6e 6b 69 6e 67 20 61 67 61 69 6e 2e 2e ; "Thinking again.." &04d5 2e 00 ; "." &04d7 20 00 0c JSR &0c00 ; decrypt_main_binary &04da a9 ff LDA #&ff # Enable all system interrupts &04dc 8d 4e fe STA &fe4e ; System VIA interrupt enable register &04df a9 00 LDA #&00 &04e1 8d 6e fe STA &fe6e ; User VIA interrupt enable register # ? &04e4 8d 6b fe STA &fe6b ; User VIA auxiliary control register # Set timer 1 and timer 2 to timed interrupts &04e7 a2 01 LDX #&01 # R1: Number of characters per line &04e9 a9 00 LDA #&00 # Hide screen &04eb 20 5d 06 JSR &065d ; set_video_register &04ee a2 07 LDX #&07 # R7: Vertical sync position &04f0 a9 1f LDA #&1f &04f2 20 5d 06 JSR &065d ; set_video_register &04f5 a2 06 LDX #&06 # R6: Vertical displayed register &04f7 a9 18 LDA #&18 &04f9 20 5d 06 JSR &065d ; set_video_register &04fc a2 00 LDX #&00 ; restore_zero_page_loop # Copy &0100 - &01ff to &0000 - &00ff &04fe bd 00 01 LDA &0100,X &0501 95 00 STA &00,X &0503 e8 INX &0504 10 f8 BPL &04fe ; restore_zero_page_loop &0506 78 SEI ; reset_vector_table # Reset all vectors to OS defaults &0507 ac b6 ff LDY &ffb6 ; os_rom_vector_table_length &050a ad b7 ff LDA &ffb7 ; os_rom_default_vector_table_address_low &050d 85 10 STA &10 ; default_vector_table_address_low &050f ad b8 ff LDA &ffb8 ; os_rom_default_vector_table_address_high &0512 85 11 STA &11 ; default_vector_table_address_high ; reset_vector_table_loop &0514 b1 10 LDA (&10),Y ; default_vector_table_address &0516 99 00 02 STA &0200,Y ; os_vector_table &0519 88 DEY &051a 10 f8 BPL &0514 ; reset_vector_table_loop &051c a2 01 LDX #&01 # R1: Number of characters per line &051e a9 40 LDA #&40 # Restore screen &0520 20 5d 06 JSR &065d ; set_video_register &0523 58 CLI &0524 a9 0f LDA #&0f ; Flush all buffers &0526 a2 00 LDX #&00 &0528 20 f4 ff JSR &fff4 ; OSBYTE &052b 4c fc 14 JMP &14fc ; main_binary_entry_point ; decrypt_byte &052e 48 PHA &052f 29 55 AND #&55 &0531 0a ASL A &0532 85 0a STA &0a ; tmp &0534 68 PLA &0535 29 aa AND #&aa &0537 4a LSR A &0538 05 0a ORA &0a ; tmp &053a 60 RTS ; decrement_sector_count &053b 20 64 06 JSR &0664 ; get_byte_from_tape &053e 20 2e 05 JSR &052e ; decrypt_byte &0541 a6 04 LDX &04 ; decryption_code_byte &0543 9d 00 0c STA &0c00,X ; decryption_main_binary # One byte of decryption code per sector &0546 e6 04 INC &04 ; decryption_code_byte &0548 a9 64 LDA #&64 &054a 85 05 STA &05 ; bytes_remaining_in_sector &054c c6 20 DEC &20 ; sectors + 2 &054e a5 20 LDA &20 ; sectors + 2 &0550 c9 2f CMP #&2f ; "0" - 1 &0552 d0 19 BNE &056d ; plot_sectors_left &0554 a9 39 LDA #&39 ; "9" &0556 85 20 STA &20 ; sectors + 2 &0558 c6 1f DEC &1f ; sectors + 1 &055a a5 1f LDA &1f ; sectors + 1 &055c c9 2f CMP #&2f ; "0" - 1 &055e d0 0d BNE &056d ; plot_sectors_left &0560 a9 39 LDA #&39 ; "9" &0562 85 1f STA &1f ; sectors + 1 &0564 c6 1e DEC &1e ; sectors &0566 a5 1e LDA &1e ; sectors &0568 c9 2f CMP #&2f ; "0" - 1 &056a d0 01 BNE &056d ; plot_sectors_left # Always branches &056c 60 RTS ; plot_sectors_left &056d 98 TYA &056e 48 PHA &056f a2 07 LDX #&07 &0571 20 08 06 JSR &0608 ; set_text_position &0574 a9 03 LDA #&03 ; W &0576 8d 07 06 STA &0607 ; text_colour &0579 20 2f 06 JSR &062f ; plot_text &057c 53 65 63 74 6f 72 73 20 6c 65 66 74 20 3a 00 ; "Sectors left :" &058b a5 1e LDA &1e ; sectors &058d 20 9d 05 JSR &059d ; plot_character &0590 a5 1f LDA &1f ; sectors + 1 &0592 20 9d 05 JSR &059d ; plot_character &0595 a5 20 LDA &20 ; sectors + 2 &0597 20 9d 05 JSR &059d ; plot_character &059a 68 PLA &059b a8 TAY &059c 60 RTS ; plot_character &059d 38 SEC &059e e9 20 SBC #&20 &05a0 85 28 STA &28 ; font_address_low &05a2 a9 00 LDA #&00 &05a4 06 28 ASL &28 ; font_address_low &05a6 2a ROL A &05a7 06 28 ASL &28 ; font_address_low &05a9 2a ROL A &05aa 06 28 ASL &28 ; font_address_low &05ac 2a ROL A &05ad 69 09 ADC #&09 ; &0900 = font_data # &900 + 8 * (character - 32) &05af 85 29 STA &29 ; font_address_high &05b1 a5 2a LDA &2a ; screen_address_low &05b3 18 CLC &05b4 69 08 ADC #&08 &05b6 85 2c STA &2c ; right_screen_address_low &05b8 a5 2b LDA &2b ; screen_address_high &05ba 69 00 ADC #&00 &05bc 85 2d STA &2d ; right_screen_address_high &05be 98 TYA &05bf 48 PHA &05c0 a0 07 LDY #&07 ; plot_character_loop &05c2 b1 28 LDA (&28),Y ; font_address &05c4 4a LSR A &05c5 4a LSR A &05c6 4a LSR A &05c7 4a LSR A &05c8 20 e9 05 JSR &05e9 ; multiply_font_byte_by_colour &05cb 91 2a STA (&2a),Y ; screen_address &05cd b1 28 LDA (&28),Y ; font_address &05cf 29 0f AND #&0f &05d1 20 e9 05 JSR &05e9 ; multiply_font_byte_by_colour &05d4 91 2c STA (&2c),Y ; right_screen_address &05d6 88 DEY &05d7 10 e9 BPL &05c2 ; plot_character_loop &05d9 a5 2a LDA &2a ; screen_address_low &05db 18 CLC &05dc 69 10 ADC #&10 &05de 85 2a STA &2a ; screen_address_low &05e0 a5 2b LDA &2b ; screen_address_high &05e2 69 00 ADC #&00 &05e4 85 2b STA &2b ; screen_address_high &05e6 68 PLA &05e7 a8 TAY &05e8 60 RTS ; multiply_font_byte_by_colour &05e9 ae 07 06 LDX &0607 ; text_colour &05ec f0 17 BEQ &0605 ; is_zero &05ee e0 01 CPX #&01 &05f0 d0 01 BNE &05f3 ; is_two_or_three ; is_one &05f2 60 RTS # Leave with A ; is_two_or_three &05f3 e0 02 CPX #&02 &05f5 d0 05 BNE &05fc ; is_three &05f7 0a ASL A &05f8 0a ASL A &05f9 0a ASL A &05fa 0a ASL A &05fb 60 RTS # Leave with A * 16 ; is_three &05fc 85 2e STA &2e ; a &05fe 0a ASL A &05ff 0a ASL A &0600 0a ASL A &0601 0a ASL A &0602 05 2e ORA &2e ; a &0604 60 RTS # Leave with A * 17 ; is_zero &0605 8a TXA &0606 60 RTS # Leave with zero ; text_colour &0607 00 ; set_text_position &0608 86 2c STX &2c ; x &060a a9 00 LDA #&00 &060c 85 2a STA &2a ; screen_address_low &060e a9 7e LDA #&7e ; &7e00 &0610 85 2b STA &2b ; screen_address_high &0612 a9 00 LDA #&00 &0614 06 2c ASL &2c ; x &0616 2a ROL A &0617 06 2c ASL &2c ; x &0619 2a ROL A &061a 06 2c ASL &2c ; x &061c 2a ROL A &061d 85 2d STA &2d ; x_high &061f 06 2c ASL &2c ; x &0621 2a ROL A &0622 a5 2a LDA &2a ; screen_address_low &0624 65 2c ADC &2c ; x &0626 85 2a STA &2a ; screen_address_low &0628 a5 2b LDA &2b ; screen_address_high &062a 65 2d ADC &2d ; x_high &062c 85 2b STA &2b ; screen_address_high &062e 60 RTS ; plot_text &062f 68 PLA &0630 85 32 STA &32 ; text_address_low &0632 68 PLA &0633 85 33 STA &33 ; text_address_high &0635 a0 00 LDY #&00 ; plot_text_loop &0637 e6 32 INC &32 &0639 d0 02 BNE &063d ; skip_page &063b e6 33 INC &33 ; text_address_high ; skip_page &063d b1 32 LDA (&32),Y ; text_address &063f f0 06 BEQ &0647 ; leave_after_text &0641 20 9d 05 JSR &059d ; plot_character &0644 4c 37 06 JMP &0637 ; plot_text_loop ; leave_after_text &0647 e6 32 INC &32 ; text_address_low &0649 d0 02 BNE &064d ; skip_page &064b e6 33 INC &33 ; text_address_high ; skip_page &064d 6c 32 00 JMP (&0032) ; text_address # Return after end of string ; clear_status_area &0650 a2 00 LDX #&00 &0652 8a TXA ; clear_status_area_loop &0653 9d 00 7e STA &7e00,X # Wipe &7e00 - &7fff &0656 9d 00 7f STA &7f00,X &0659 e8 INX &065a d0 f7 BNE &0653 ; clear_status_area_loop &065c 60 RTS ; set_video_register &065d 8e 00 fe STX &fe00 ; video register number &0660 8d 01 fe STA &fe01 ; video register value &0663 60 RTS ; get_byte_from_tape &0664 ad 08 fe LDA &fe08 ; Cassette ACIA status register &0667 29 70 AND #&70 # Is there a framing, receiver overrun or parity error? &0669 f0 04 BEQ &066f ; not_error &066b a5 02 LDA &02 ; waiting_for_start_of_data &066d d0 0b BNE &067a ; load_error # Non-zero if reading data ; not_error &066f ad 08 fe LDA &fe08 ; Cassette ACIA status register &0672 29 01 AND #&01 # Is it a receiver interrupt? &0674 f0 ee BEQ &0664 ; get_byte_from_tape &0676 ad 09 fe LDA &fe09 ; Cassette ACIA data register # If so, return a byte of data &0679 60 RTS ; load_error &067a 20 50 06 JSR &0650 ; clear_status_area &067d a9 00 LDA #&00 # Switch off cassette motor &067f 8d 10 fe STA &fe10 ; Serial ULA control register &0682 a9 01 LDA #&01 ; R &0684 8d 07 06 STA &0607 ; text_colour &0687 a2 07 LDX #&07 &0689 20 08 06 JSR &0608 ; set_text_position &068c 20 2f 06 JSR &062f ; plot_text &068f 50 75 74 20 74 61 70 65 20 74 6f 20 73 74 61 72 ; "Put tape to star" &069f 74 00 ; "t" &06a1 4c 39 04 JMP &0439 ; start_load # Restart the load ; unused &3561 98 66 11 21 fd ee 21 # Not meaningful either encrypted or decrypted # Text decrypted by decrypt_3000_to_35ff &3568 2a 2a 2a 20 4f 6b 61 79 2c 20 73 6f 20 79 6f 75 ; "*** Okay, so you" &3578 20 67 6f 74 20 70 61 73 74 20 74 68 65 20 65 61 ; " got past the ea" &3588 73 79 20 62 69 74 2c 20 62 69 67 20 68 61 73 73 ; "sy bit, big hass" &3598 6c 65 20 2a 2a 2a 20 54 68 61 6e 6b 73 20 74 6f ; "le *** Thanks to" &35a8 20 47 61 72 79 20 50 61 72 74 69 73 20 66 6f 72 ; " Gary Partis for" &35b8 20 64 6f 69 6e 67 20 74 68 65 20 72 65 61 6c 20 ; " doing the real " &35c8 70 72 6f 74 65 63 74 69 6f 6e 20 61 74 20 74 68 ; "protection at th" &35d8 65 20 6c 61 73 74 20 6d 69 6e 75 74 65 20 2a 2a ; "e last minute **" &35e8 2a 20 42 79 20 4b 65 6e 74 6f 6e 20 50 72 69 63 ; "* By Kenton Pric" &35f8 65 20 2a 2a 2a 00 ff cc ; "e ***..." Decryption code read one byte at end of each sector: ; decrypt_main_binary &0c00 78 SEI &0c01 d8 CLD &0c02 a9 df LDA #&df # Set User VIA timer 2 to timed interrupt &0c04 2d 6b fe AND &fe6b ; User VIA auxiliary control register &0c07 8d 6b fe STA &fe6b ; User VIA auxiliary control register &0c0a a9 a0 LDA #&a0 # Enable interrupts for User VIA timer 2 &0c0c 8d 6e fe STA &fe6e ; User VIA interrupt enable register &0c0f a9 00 LDA #&00 &0c11 8d 68 fe STA &fe68 ; User VIA timer 2 counter LSB &0c14 8d 69 fe STA &fe69 ; User VIA timer 2 counter MSB &0c17 a2 04 LDX #&04 # 4 rounds ; decrypt_main_binary_loop &0c19 86 60 STX &60 ; round &0c1b ad 69 fe LDA &fe69 ; User VIA timer 2 counter MSB &0c1e 48 PHA &0c1f ad 68 fe LDA &fe68 ; User VIA timer 2 counter LSB &0c22 8d 69 fe STA &fe69 ; User VIA timer 2 counter MSB &0c25 68 PLA &0c26 8d 68 fe STA &fe68 ; User VIA timer 2 counter LSB &0c29 8a TXA &0c2a 18 CLC &0c2b 6d 68 fe ADC &fe68 ; User VIA timer 2 counter LSB &0c2e a8 TAY &0c2f ad 00 12 LDA &1200 # Start decryption at &1200 # actually LDA source_address &0c32 4d 68 fe EOR &fe68 ; User VIA timer 2 counter LSB &0c35 5d 00 0c EOR &0c00,X ; decrypt_main_binary # Runs over &0c01 - &0c04 &0c38 4d 69 fe EOR &fe69 ; User VIA timer 2 counter MSB &0c3b 49 ff EOR #&ff # actually EOR decrypt_eor_one &0c3d 45 60 EOR &60 ; round &0c3f 48 PHA &0c40 ad 68 fe LDA &fe68 ; User VIA timer 2 counter LSB &0c43 38 SEC &0c44 6d 69 fe ADC &fe69 ; User VIA timer 2 counter MSB &0c47 49 55 EOR #&55 # Fixed value, inverts even bits &0c49 8d 68 fe STA &fe68 ; User VIA timer 2 counter LSB &0c4c 68 PLA &0c4d 59 00 0c EOR &0c00,Y ; decrypt_main_binary # Runs over &0c00 - &0cff &0c50 ac 30 0c LDY &0c30 ; source_address_low &0c53 59 00 0c EOR &0c00,Y ; decrypt_main_binary # Runs over &0c00 - &0cff &0c56 49 00 EOR #&00 # actually EOR decrypt_eor_two &0c58 4d 69 fe EOR &fe69 ; User VIA timer 2 counter MSB &0c5b 4d 80 0c EOR &0c80 # actually EOR &0c00 + decrypt_offset_one # Runs over &0c00 - &0cff &0c5e ee 5c 0c INC &0c5c ; decrypt_offset_one &0c61 ac 68 fe LDY &fe68 ; User VIA timer 2 counter LSB &0c64 59 00 0c EOR &0c00,Y ; decrypt_main_binary # Runs over &0c00 - &0cff &0c67 49 ff EOR #&ff # actually EOR decrypt_eor_three &0c69 ac 69 fe LDY &fe69 ; User VIA timer 2 counter MSB &0c6c 59 00 0c EOR &0c00,Y ; decrypt_main_binary # Runs over &0c00 - &0cff &0c6f c8 INY &0c70 4d 00 0c EOR &0c00 ; decrypt_main_binary # actually EOR &0c00 + decrypt_offset_two # Runs over &0c00 - &0cff &0c73 48 PHA &0c74 ad 71 0c LDA &0c71 ; decrypt_offset_two &0c77 6d 68 fe ADC &fe68 ; User VIA timer 2 counter LSB &0c7a 8d 71 0c STA &0c71 ; decrypt_offset_two &0c7d 68 PLA &0c7e 48 PHA &0c7f b9 00 0c LDA &0c00,Y ; decrypt_main_binary # Runs over &0c00 - &0cff &0c82 5d 00 0c EOR &0c00,X ; decrypt_main_binary # Runs over &0c00 - &0cff &0c85 4d 68 fe EOR &fe68 ; User VIA timer 2 counter LSB &0c88 4d 69 fe EOR &fe69 ; User VIA timer 2 counter MSB &0c8b 8d 90 0c STA &0c90 ; decrypt_eor_four &0c8e 68 PLA &0c8f 49 00 EOR #&00 # actually EOR decrypt_eor_four &0c91 ee 95 0c INC &0c95 ; decrypt_eor_five &0c94 49 5d EOR #&5d # actually EOR decrypt_eor_five &0c96 5d 00 0c EOR &0c00,X ; decrypt_main_binary # Runs over &0c01 - &0c04 &0c99 49 26 EOR #&26 # actually EOR decrypt_eor_six &0c9b 8d 00 12 STA &1200 # actually STA target_address &0c9e ad 68 0c LDA &0c68 ; decrypt_eor_three &0ca1 18 CLC &0ca2 6d 68 fe ADC &fe68 ; User VIA timer 2 counter LSB &0ca5 49 55 EOR #&55 # Fixed value, inverts even bits &0ca7 8d 68 0c STA &0c68 ; decrypt_eor_three &0caa ad 3c 0c LDA &0c3c ; decrypt_eor_one &0cad ed 69 fe SBC &fe69 ; User VIA timer 2 counter MSB &0cb0 49 aa EOR #&aa # Fixed value, inverts odd bits &0cb2 8d 3c 0c STA &0c3c ; decrypt_eor_one &0cb5 ad 57 0c LDA &0c57 ; decrypt_eor_two &0cb8 ed 68 fe SBC &fe68 ; User VIA timer 2 counter LSB &0cbb 6d 69 fe ADC &fe69 ; User VIA timer 2 counter MSB &0cbe 4d 68 fe EOR &fe68 ; User VIA timer 2 counter LSB &0cc1 0d 69 fe ORA &fe69 ; User VIA timer 2 counter MSB &0cc4 8d 57 0c STA &0c57 ; decrypt_eor_two &0cc7 ad 9a 0c LDA &0c9a ; decrypt_eor_six &0cca 6d 68 fe ADC &fe68 ; User VIA timer 2 counter LSB &0ccd f9 00 0c SBC &0c00,Y ; decrypt_main_binary # Runs over &0c00 - &0cff &0cd0 5d 00 0c EOR &0c00,X ; decrypt_main_binary # Runs over &0c01 - &0c04 &0cd3 8d 9a 0c STA &0c9a ; decrypt_eor_six &0cd6 ee 31 0c INC &0c31 ; source_address_high # Decrypt &1200, &1300, &1400, ... &7f00 &0cd9 ee 9d 0c INC &0c9d ; target_address_high &0cdc 30 03 BMI &0ce1 ; wrap_address &0cde 4c 19 0c JMP &0c19 ; decrypt_main_binary_loop ; wrap_address &0ce1 a9 20 LDA #&20 # then continue decryption at &2001, &2101, &2201, ... &0ce3 8d 31 0c STA &0c31 ; source_address_high # Bug: &1201 - &12ff, &1301 - &13ff, etc, not decrypted &0ce6 8d 9d 0c STA &0c9d ; target_address_high &0ce9 ee 30 0c INC &0c30 ; source_address_low &0cec ee 9c 0c INC &0c9c ; target_address_low &0cef f0 03 BEQ &0cf4 ; next_round &0cf1 4c 19 0c JMP &0c19 ; decrypt_main_binary_loop ; next_round &0cf4 ca DEX &0cf5 f0 03 BEQ &0cfa ; disable_interrupt_and_leave &0cf7 4c 19 0c JMP &0c19 ; decrypt_main_binary_loop ; disable_interrupt_and_leave &0cfa a9 20 LDA #&20 # Disable interrupts for User VIA timer 2 &0cfc 8d 6e fe STA &fe6e ; User VIA interrupt enable register &0cff 60 RTS Game disassembly ================ ; (no filename) ; 001200 0014fc 006400 ; &0000 - &000a keys ; &000b - &000c adventure_score ; &000d gate_screen_address_low ; &000e (unused) ; &000f - &0012 pockets ; &0013 - &0016 previous_pockets ; &0017 - &001f core_elements_required ; &0020 player_touching_death ; &0021 previous_player_on_hopper ; &0022 player_facing ; &0023 game_time_countdown ; &0024 game_time_low ; &0025 game_time_high ; &0026 player_room_history ; &0027 player_room_history + 1 ; &0028 player_room_history + 2 ; &0029 player_room_history + 3 ; &002a new_enemies_cooldown_history ; &002b new_enemies_needed_history ; &002c new_enemies_cooldown_history + 2 ; &002d new_enemies_needed_history + 2 ; &002e new_enemies_cooldown ; &002f new_enemies_needed ; &0030 - &0032 previous_score ; &0031 previous_player_lives ; &0034 - &0039 previous_player_energy_low ; &003a - &003f player_energy_low ; &0040 enemy_previous_screen_address_low ; &0041 enemy_previous_screen_address_high ; &0042 enemy_previous_type ; &0043 enemy_previous_animation ; &0044 only_unplot_enemies ; &0045 player_walking_direction ; &0046 - &0048 score ; &0049 player_lives ; &004a passage_direction ; &004b passage_destination_room_low ; &004c passage_screen_address_low ; &004d passage_screen_address_high ; &004e passage_destination_screen_address_low ; &004f passage_destination_screen_address_high ; &0050 previous_cfs_timeout_counter ; &0051 - &0052 (unused) ; &0053 room_item_data_address_low ; &0054 room_item_data_address_high ; &0055 room_item_colour_mask ; &0056 room_item_sprite ; &0057 room_item_unused ; &0058 room_item_screen_address_low ; &0059 room_item_screen_address_high ; &005a player_entry_screen_address_low ; &005b player_entry_screen_address_high ; &005c player_entry_sprite ; &005d player_entry_on_platform ; &005e - &0063 (unused) ; &0064 hopper_pad_screen_address_low ; &0065 hopper_pad_screen_address_high ; &0090 - &0097 palette ; &0098 player_group_address_low ; &0099 hopper_sprite ; &009a rnd_1 ; &009b rnd_2 ; &009c rnd_3 ; &009d rnd_4 ; &009e player_in_pipe ; &009f core_elements_placed ; &00a0 - &00ab (unused) ; &00ac space_lock_entrance_screen_address_low ; &00ad space_lock_entrance_screen_address_high ; &00ae space_lock_entrance_screen_address_low + 2 ; &00af space_lock_entrance_screen_address_high + 2 ; &0100 - &011f spark_data ; Eight bytes per spark ; &0100 sparks_screen_address_low ; &0101 sparks_screen_address_high ; &0102 sparks_subtile_address_low # Set but not used ; &0103 sparks_subtile_address_high # Set but not used ; &0104 sparks_frame ; &0105 sparks_ignition_frame ; &0106 sparks_total_frames ; &0107 (unused) ; &0120 - &014f pipe_in_tile ; &0150 - &0157 pipe_arrow_columns_status ; &0158 - &0187 previous_enemies_data ; &0188 - &01b7 enemies_data (four enemies, twelve bytes per enemy) ; &0188 enemies_screen_address_low ; &0189 enemies_screen_address_high ; &018a enemies_type ; &018b enemies_direction ; &018c enemies_inertia ; &018d enemies_maximum_homing_cooldown ; &018e enemies_behaviour ; &018f enemies_move_cooldown ; &0190 enemies_homing_cooldown ; &0191 enemies_materialisation_timer ; &0192 enemies_animation ; &0193 enemies_materialising ; &01c8 - &01d0 player_subtiles ; &0380 - &03ff rooms_visited ; &0400 - &042f room_tiles ; &0400 - &041f bridging_platform_data ; Two bytes per platform: ; 84218421 ........ subtile_address_low ; ........ ......21 subtile_address_high ; ........ 842184.. time to live ; &0528 - &0577 core_elements_data ; Four bytes per element: ; 84218421 ........ ........ ........ room_low ; ........ ......21 ........ ........ room_high ; ........ 842184.. ........ ........ screen_address_low ; ........ ........ 84218421 ........ screen_address_high ; ........ ........ ........ 84218421 sprite ; &05a0 - &07df room_subtiles ; &0c00 - &0dff item_data ; Two bytes per item: ; 84218421 8....... room (low, high) ; ........ .4218421 screen address ; &6600 - &7eff screen memory # &1200 - &6fff is decrypted to &0e00 - &6bff at &7518 ; prepare_teleport_or_pyramid_screen &0e00 20 11 0f JSR &0f11 ; clear_screen_and_flush_buffers ; choose_random_colour_one &0e03 20 40 64 JSR &6440 ; rnd &0e06 29 07 AND #&07 &0e08 c9 05 CMP #&05 &0e0a b0 f7 BCS &0e03 ; choose_random_colour_one &0e0c 85 93 STA &93 ; palette + 3 # Set colour one of bottom section ; choose_random_colour_two &0e0e 20 40 64 JSR &6440 ; rnd &0e11 29 07 AND #&07 &0e13 c5 93 CMP &93 ; palette + 3 &0e15 f0 f7 BEQ &0e0e ; choose_random_colour_two &0e17 c9 05 CMP #&05 &0e19 b0 f3 BCS &0e0e ; choose_random_colour_two &0e1b 69 01 ADC #&01 &0e1d 85 95 STA &95 ; palette + 5 # Set colour two of bottom section &0e1f e6 93 INC &93 ; palette + 3 &0e21 20 00 7f JSR &7f00 ; to_set_screen_colours ; play_enter_teleport_sound &0e24 a2 14 LDX #&14 &0e26 a0 10 LDY #&10 ; &1014 = enter_teleport_sound &0e28 4c 2b 35 JMP &352b ; play_sound_using_envelope ; enter_teleport &0e2b a2 00 LDX #&00 &0e2d a4 f5 LDY &f5 ; room_teleport_offset ; poke_teleport_code_loop &0e2f b9 1d 62 LDA &621d,Y ; teleport_data - 8 # Poke teleport code into text &0e32 9d 52 0f STA &0f52,X ; teleport_text + &2c &0e35 c8 INY &0e36 e8 INX &0e37 e0 05 CPX #&05 &0e39 d0 f4 BNE &0e2f ; poke_teleport_code_loop &0e3b 20 00 0e JSR &0e00 ; prepare_teleport_or_pyramid_screen &0e3e a9 24 LDA #&24 &0e40 85 8c STA &8c ; sprite_address_low &0e42 a9 61 LDA #&61 ; &6124 = tile_sprite_25 &0e44 85 8d STA &8d ; sprite_address_high &0e46 a9 d0 LDA #&d0 &0e48 85 8e STA &8e ; screen_address_low &0e4a a9 6f LDA #&6f ; &6fd0 &0e4c 85 8f STA &8f ; screen_address_high &0e4e a2 04 LDX #&04 # 16 pixels wide &0e50 a0 03 LDY #&03 # 24 pixels high &0e52 20 00 65 JSR &6500 ; plot_aligned_sprite_using_write # Plot teleport sprite &0e55 a2 26 LDX #&26 &0e57 a0 0f LDY #&0f ; &0f26 = teleport_text &0e59 20 80 0a JSR &0a80 ; plot_text &0e5c a9 00 LDA #&00 &0e5e 85 86 STA &86 ; input_offset ; get_character &0e60 20 e0 ff JSR &ffe0 ; OSRDCH &0e63 29 5f AND #&5f # Convert to uppercase &0e65 c9 41 CMP #&41 ; "A" &0e67 90 f7 BCC &0e60 ; get_character &0e69 c9 5b CMP #&5b ; "Z" + 1 &0e6b b0 f3 BCS &0e60 ; get_character # Get a character between "A" and "Z" &0e6d a6 86 LDX &86 ; input_offset &0e6f 9d 90 0f STA &0f90,X ; entered_code &0e72 8d 95 0f STA &0f95 ; character_entered_text &0e75 a2 95 LDX #&95 &0e77 a0 0f LDY #&0f ; &0f95 = character_entered_text &0e79 20 80 0a JSR &0a80 ; plot_text # Display character &0e7c a2 1e LDX #&1e &0e7e a0 0f LDY #&0f ; &0f1e = character_entered_sound &0e80 20 3d 35 JSR &353d ; play_sound &0e83 e6 86 INC &86 ; input_offset &0e85 a5 86 LDA &86 ; input_offset &0e87 c9 05 CMP #&05 &0e89 d0 d5 BNE &0e60 ; get_character &0e8b a0 08 LDY #&08 ; check_teleport_codes_loop &0e8d a2 00 LDX #&00 ; check_characters_loop &0e8f b9 1d 62 LDA &621d,Y ; teleport_data - 8 # Does the entered code match any teleport code? &0e92 dd 90 0f CMP &0f90,X ; entered_code &0e95 d0 08 BNE &0e9f ; consider_next_code &0e97 c8 INY &0e98 e8 INX &0e99 e0 05 CPX #&05 &0e9b d0 f2 BNE &0e8f ; check_characters_loop &0e9d f0 13 BEQ &0eb2 ; code_matches ; consider_next_code &0e9f 98 TYA &0ea0 18 CLC &0ea1 69 08 ADC #&08 &0ea3 29 f8 AND #&f8 &0ea5 a8 TAY &0ea6 10 e5 BPL &0e8d ; check_teleport_codes_loop &0ea8 20 17 0f JSR &0f17 ; play_error_sound &0eab a5 f5 LDA &f5 ; room_teleport_offset # If not, return to current room &0ead 48 PHA &0eae a2 98 LDX #&98 ; &0f98 = code_not_recognised_text # and display an error &0eb0 d0 0d BNE &0ebf ; flash_text ; code_matches &0eb2 98 TYA &0eb3 29 f8 AND #&f8 &0eb5 48 PHA # Otherwise, return to destination room &0eb6 a2 59 LDX #&59 &0eb8 a0 04 LDY #&04 ; &0459 = teleporting_sound &0eba 20 2b 35 JSR &352b ; play_sound_using_envelope &0ebd a2 b0 LDX #&b0 ; &0fb0 = now_teleporting_text ; flash_text &0ebf a9 d5 LDA #&d5 &0ec1 85 86 STA &86 ; timer &0ec3 86 7e STX &7e ; text_address_low ; flash_text_loop &0ec5 a5 86 LDA &86 ; timer &0ec7 29 03 AND #&03 # Cycle through all four colours &0ec9 09 80 ORA #&80 # Top bit set to set colour &0ecb 8d b0 0f STA &0fb0 ; now_teleporting_text &0ece 8d 98 0f STA &0f98 ; code_not_recognised_text &0ed1 a6 7e LDX &7e ; text_address_low &0ed3 a0 0f LDY #&0f &0ed5 20 80 0a JSR &0a80 ; plot_text &0ed8 a9 13 LDA #&13 ; Wait for v-sync &0eda 20 f4 ff JSR &fff4 ; OSBYTE &0edd e6 86 INC &86 ; timer &0edf d0 e4 BNE &0ec5 ; flash_text_loop &0ee1 68 PLA ; teleport_offset &0ee2 a8 TAY &0ee3 b9 24 62 LDA &6224,Y ; teleport_data - 1 # Top nibble of last byte of teleport data &0ee6 4a LSR A &0ee7 4a LSR A &0ee8 4a LSR A &0ee9 4a LSR A &0eea 85 8e STA &8e ; tmp &0eec 0a ASL A &0eed 65 8e ADC &8e ; tmp # sets y position of destination tile &0eef 69 6e ADC #&6e &0ef1 85 71 STA &71 ; player_screen_address_high &0ef3 b9 24 62 LDA &6224,Y ; teleport_data - 1 # Bottom nibble of last byte of teleport data &0ef6 4a LSR A # (excluding bottom bit) &0ef7 0a ASL A &0ef8 0a ASL A &0ef9 0a ASL A &0efa 0a ASL A &0efb 0a ASL A &0efc 38 SEC &0efd e9 08 SBC #&08 &0eff 85 70 STA &70 ; player_screen_address_low # sets x position of destination tile &0f01 a9 0b LDA #&0b &0f03 85 72 STA &72 ; player_sprite # Player faces right, one step out of teleport &0f05 b9 23 62 LDA &6223,Y ; teleport_data - 2 &0f08 85 7e STA &7e ; player_room_low # Second last byte of teleport data &0f0a b9 24 62 LDA &6224,Y ; teleport_data - 1 &0f0d 29 01 AND #&01 # and bottom bit of last byte of teleport data &0f0f 85 7f STA &7f ; player_room_high # set destination room ; clear_screen_and_flush_buffers &0f11 20 78 34 JSR &3478 ; clear_screen &0f14 4c 24 35 JMP &3524 ; flush_buffers ; play_error_sound &0f17 a2 c4 LDX #&c4 &0f19 a0 0f LDY #&0f ; &0fc4 = error_sound &0f1b 4c 2b 35 JMP &352b ; play_sound_using_envelope ; character_entered_sound ; chan vol pitch dur &0f1e 10 00 f1 00 01 00 01 00 ; teleport_text &0f26 81 &0f27 1f 03 07 &0f2a 59 4f 55 00 00 48 41 56 45 00 00 45 4e 54 45 52 ; "YOU HAVE ENTERED" &0f3a 45 44 &0f3c 1f 13 09 &0f34 54 45 4c 45 50 4f 52 54 ; "TELEPORT" &0f47 1f 0a 0b &0f4a 43 4f 44 45 5b 6b 5b ; "CODE : " &0f51 83 &0f52 28 43 29 4b 50 ; "(C)KP" # Overwritten by teleport code &0f57 1f 0c 0e &0f5a 82 &0f5b 45 4e 54 45 52 5b 54 45 4c 45 50 4f 52 54 41 4c ; "ENTER TELEPORTAL" &0f6b 1f 0c 10 &0f6e 44 45 53 54 49 4e 41 54 49 4f 4e 5b 43 4f 44 45 ; "DESTINATION CODE" &0f7e 1f 1a 13 &0f81 83 &0f82 6d 5b 6d 5b 6d 5b 6d 5b 6d 81 ; "_ _ _ _ _" &0f8c 1f 1a 13 &0f8f 0d ; entered_code &0f90 00 00 00 00 00 ; character_entered_text &0f95 5b 5b ; " " &0f97 0d ; code_not_recognised_text &0f98 81 &0f99 1f 05 15 &0f9c 43 4f 44 45 5b 4e 4f 54 5b 52 45 43 4f 47 4e 49 ; "CODE NOT RECOGNISED" &0fac 53 45 44 &0faf 0d ; now_teleporting_text &0fb0 81 &0fb1 1f 0e 15 &0fb3 4e 4f 57 5b 54 45 4c 45 50 4f 52 54 49 4e 47 ; "NOW TELEPORTING" &0fc3 0d ; error_sound &0fc4 04 01 0a 14 1e 01 01 01 7e 00 00 82 7e 7e ; chan vol pitch dur &0fd2 11 00 04 00 c0 00 1e 00 ; cheops_pyramid_text &0fda 1f 0e 08 &0fdd 82 &0fde 43 48 45 4f 50 53 5b 50 59 52 41 4d 49 44 ; "CHEOPS PYRAMID" &0fec 1f 0e 0c &0fef 81 &0ff0 45 58 43 48 41 4e 47 45 5b 5b 5b 46 4f 52 ; "EXCHANGE FOR" &0ffe 1f 06 0e &1001 62 5e 5b 5b 63 5e 5b 5b 64 5e 5b 5b 65 5e 5b 5b ; "1. 2. 3. 4. 5." &1011 66 5e &1013 0d ; enter_teleport_sound ; envelope &1014 04 01 f6 f1 ec 04 04 04 7e fa f3 dc 7e 5a ; chan vol pitch dur &1022 02 00 04 00 78 00 02 00 ; enter_pyramid &102a 20 00 0e JSR &0e00 ; prepare_teleport_or_pyramid_screen &102d a2 da LDX #&da &102f a0 0f LDY #&0f ; &0fda = cheops_pyramid_text &1031 20 80 0a JSR &0a80 ; plot_text ; choose_random_pocket &1034 20 40 64 JSR &6440 ; rnd # Choose a pocket at random &1037 29 03 AND #&03 &1039 a8 TAY &103a b9 0f 00 LDA &000f,Y ; pockets &103d f0 f5 BEQ &1034 ; choose_random_pocket # Check that it contains something &103f 84 80 STY &80 ; pocket_to_swap &1041 85 89 STA &89 ; pocket_contents # pocket_contents = pyramid_choices + 4 &1043 a9 03 LDA #&03 &1045 85 8e STA &8e ; count ; choose_random_core_element &1047 20 40 64 JSR &6440 ; rnd # Choose a core element at random &104a c9 09 CMP #&09 &104c b0 f9 BCS &1047 ; choose_random_core_element &104e a8 TAY &104f b9 17 00 LDA &0017,Y ; core_elements_required &1052 c9 80 CMP #&80 # Top bit set if core element restored &1054 b0 f1 BCS &1047 ; choose_random_core_element &1056 a6 8e LDX &8e ; count &1058 29 1f AND #&1f &105a 95 85 STA &85,X ; pyramid_options &105c c6 8e DEC &8e ; count &105e 10 e7 BPL &1047 ; choose_random_core_element ; plot_chosen_pocket &1060 a2 ff LDX #&ff # White &1062 a0 00 LDY #&00 # Overwrite screen &1064 a9 90 LDA #&90 &1066 85 8e STA &8e ; screen_address_low &1068 a9 72 LDA #&72 ; &7290 &106a 85 8f STA &8f ; screen_address_high &106c a5 89 LDA &89 ; pocket_contents &106e 20 b3 0b JSR &0bb3 ; plot_packed_two_colour_sprite # Plot contents of chosen pocket ; plot_options &1071 a9 18 LDA #&18 &1073 85 8e STA &8e ; screen_address_low &1075 a9 76 LDA #&76 &1077 85 8f STA &8f ; screen_address_high &1079 a9 00 LDA #&00 &107b 85 81 STA &81 ; option ; plot_options_loop &107d a4 81 LDY &81 ; option &107f b9 85 00 LDA &0085,Y ; pyramid_options &1082 a2 ff LDX #&ff # White &1084 a0 00 LDY #&00 # Overwrite screen &1086 20 b3 0b JSR &0bb3 ; plot_packed_two_colour_sprite &1089 38 SEC &108a a5 8e LDA &8e ; screen_address_low &108c e9 d0 SBC #&d0 &108e 85 8e STA &8e ; screen_address_low &1090 a5 8f LDA &8f ; screen_address_high &1092 e9 01 SBC #&01 &1094 85 8f STA &8f ; screen_address_high &1096 e6 81 INC &81 ; option &1098 a5 81 LDA &81 ; option &109a c9 05 CMP #&05 &109c d0 df BNE &107d ; plot_options_loop &109e a9 0f LDA #&0f ; Flush all buffers &10a0 a2 00 LDX #&00 &10a2 20 f4 ff JSR &fff4 ; OSBYTE ; get_number &10a5 20 e0 ff JSR &ffe0 ; OSRDCH &10a8 38 SEC &10a9 e9 31 SBC #&31 ; "1" &10ab 90 f8 BCC &10a5 ; get_number &10ad c9 05 CMP #&05 &10af b0 f4 BCS &10a5 ; get_number # Get a character between "1" and "5" &10b1 48 PHA &10b2 a8 TAY &10b3 b9 85 00 LDA &0085,Y ; options &10b6 a4 80 LDY &80 ; pocket_to_swap &10b8 99 0f 00 STA &000f,Y ; pockets # Put the corresponding option in chosen pocket &10bb 85 87 STA &87 ; chosen_option &10bd 68 PLA &10be 0a ASL A &10bf 0a ASL A &10c0 0a ASL A &10c1 0a ASL A &10c2 85 86 STA &86 ; option_screen_address_low &10c4 0a ASL A &10c5 65 86 ADC &86 ; option_screen_address_low &10c7 69 18 ADC #&18 &10c9 85 86 STA &86 ; option_screen_address_low &10cb 20 17 0f JSR &0f17 ; play_error_sound &10ce a9 32 LDA #&32 &10d0 85 88 STA &88 ; count &10d2 a9 00 LDA #&00 &10d4 85 89 STA &89 ; colour ; flash_option &10d6 a9 13 LDA #&13 ; Wait for v-sync &10d8 20 f4 ff JSR &fff4 ; OSBYTE &10db a5 86 LDA &86 ; option_screen_address_low &10dd 85 8e STA &8e ; screen_address_low &10df a9 76 LDA #&76 &10e1 85 8f STA &8f ; screen_address_high &10e3 a5 89 LDA &89 ; colour &10e5 49 ff EOR #&ff &10e7 85 89 STA &89 ; colour &10e9 aa TAX # Alternate between white and black &10ea a0 00 LDY #&00 # Overwrite screen &10ec a5 87 LDA &87 ; chosen_option &10ee 20 b3 0b JSR &0bb3 ; plot_packed_two_colour_sprite # Flash chosen option &10f1 c6 88 DEC &88 ; count &10f3 d0 e1 BNE &10d6 ; flash_option &10f5 a8 TAY &10f6 91 53 STA (&53),Y ; room_item_data_address # Remove chosen option from world &10f8 c8 INY &10f9 91 53 STA (&53),Y ; room_item_data_address &10fb 60 RTS # &10fc - &111b correspond to &14fc - &151b before the binary is decrypted. ; entry_point &14fc a0 00 LDY #&00 &14fe 84 ff STY &ff ; os_escape_pressed # Clear ESCAPE condition ; decrypt_74e8_to_75e7_loop # Decrypt &74e8 - &75e7 &1500 b9 e8 74 LDA &74e8,Y ; decrypted_entry_point &1503 49 ad EOR #&ad &1505 99 e8 74 STA &74e8,Y ; decrypted_entry_point &1508 c8 INY &1509 d0 f5 BNE &1500 ; decrypt_74e8_to_75e7_loop ; restore_0800_loop &150b b9 00 11 LDA &1100,Y # &0800 - &08ff was copied to &1100 - &11ff in loader &150e 99 00 08 STA &0800,Y # (OS sound workspace, buffers and envelopes) &1511 c8 INY &1512 d0 f7 BNE &150b ; restore_0800_loop &1514 4c e8 74 JMP &74e8 ; decrypted_entry_point ; unused &1517 3e 92 2d 8e 64 # Not meaningful encrypted or decrypted # After decryption, this code is obscured, then overwritten by: ; &10fc - &111b ula_palette_data ; start_game &111c a0 09 LDY #&09 ; reset_gates_loop &111e b9 c3 61 LDA &61c3,Y ; gate_table &1121 29 fd AND #&fd # Unset &02 to indicate gate is present &1123 99 c3 61 STA &61c3,Y ; gate_table &1126 88 DEY &1127 88 DEY &1128 10 f4 BPL &111e ; reset_gates_loop &112a a9 80 LDA #&80 &112c 85 70 STA &70 ; player_screen_address_low &112e a9 77 LDA #&77 &1130 85 71 STA &71 ; player_screen_address_high &1132 a9 00 LDA #&00 &1134 85 46 STA &46 ; score &1136 85 47 STA &47 ; score + 1 &1138 85 48 STA &48 ; score + 2 &113a a9 05 LDA #&05 &113c 85 49 STA &49 ; player_lives &113e a0 00 LDY #&00 &1140 98 TYA ; wipe_item_data_loop &1141 99 00 0c STA &0c00,Y ; item_data # Wipe &0c00 - &0dff &1144 99 00 0d STA &0d00,Y ; item_data + &100 &1147 c8 INY &1148 d0 f7 BNE &1141 ; wipe_item_data_loop ; reset_rooms_visited_loop &114a 99 80 03 STA &0380,Y ; rooms_visited # Wipe &0380 - &03ff &114d c8 INY &114e 10 fa BPL &114a ; reset_rooms_visited_loop &1150 a0 07 LDY #&07 ; reset_pockets_loop &1152 98 TYA &1153 29 04 AND #&04 # Set pockets to 0, previous_pockets to 4, &1155 99 0f 00 STA &000f,Y ; pockets # forcing redraw &1158 88 DEY &1159 10 f7 BPL &1152 ; reset_pockets_loop &115b 20 a0 20 JSR &20a0 ; wipe_subtiles &115e a9 00 LDA #&00 &1160 85 0b STA &0b ; adventure_score &1162 85 0c STA &0c ; adventure_score + 1 ; place_items &1164 85 88 STA &88 ; item_data_address_low &1166 a9 0c LDA #&0c ; &0c00 = item_data &1168 85 89 STA &89 ; item_data_address_high ; place_items_loop &116a 20 40 64 JSR &6440 ; rnd # Pick a random room between &0000 and &01ff &116d 85 8e STA &8e ; items_used_address_low &116f 20 40 64 JSR &6440 ; rnd &1172 0a ASL A &1173 0a ASL A &1174 0a ASL A &1175 0a ASL A &1176 05 8e ORA &8e ; items_used_address_low &1178 85 8e STA &8e ; items_used_address_low &117a 20 40 64 JSR &6440 ; rnd &117d 29 03 AND #&03 &117f 85 8a STA &8a ; subtile_x &1181 4a LSR A &1182 09 06 ORA #&06 # items_used_address is between &0600 and &07ff &1184 85 8f STA &8f ; items_used_address_high &1186 a0 00 LDY #&00 &1188 b1 8e LDA (&8e),Y ; items_used_address &118a d0 de BNE &116a ; place_items_loop # Is there already an item in this room? &118c a9 01 LDA #&01 &118e 91 8e STA (&8e),Y ; items_used_address &1190 a5 8e LDA &8e ; items_used_address_low &1192 aa TAX &1193 18 CLC &1194 69 c0 ADC #&c0 &1196 85 8e STA &8e ; item_locations_address_low &1198 a5 8f LDA &8f ; items_used_address_high &119a 69 31 ADC #&31 ; &31c0 = possible_item_locations - &600 &119c 85 8f STA &8f ; item_locations_address_high &119e b1 8e LDA (&8e),Y ; item_locations_address # Get a byte of data for possible item location &11a0 85 8d STA &8d ; location_byte &11a2 29 3f AND #&3f # Low six bits are tile to put item in &11a4 c9 30 CMP #&30 &11a6 b0 c2 BCS &116a ; place_items_loop &11a8 85 8c STA &8c ; tile &11aa 8a TXA &11ab 91 88 STA (&88),Y ; item_data_address # First byte of item data is room_low &11ad a5 8d LDA &8d ; location_byte &11af 29 c0 AND #&c0 # Top two bits set where item can be placed vertically &11b1 0a ASL A &11b2 2a ROL A &11b3 2a ROL A &11b4 69 01 ADC #&01 &11b6 85 8b STA &8b ; subtile_y_limit ; choose_random_subtile_y &11b8 20 40 64 JSR &6440 ; rnd &11bb 29 03 AND #&03 &11bd c5 8b CMP &8b ; subtile_y_limit &11bf b0 f7 BCS &11b8 ; choose_random_subtile &11c1 65 8c ADC &8c ; tile &11c3 46 8a LSR &8a ; subtile_x &11c5 66 8a ROR &8a ; subtile_x &11c7 66 8a ROR &8a ; subtile_x &11c9 05 8a ORA &8a ; subtile_x &11cb a0 01 LDY #&01 &11cd 91 88 STA (&88),Y ; item_data_address # Second byte of item data is room_high and position &11cf e6 88 INC &88 ; item_data_address_low &11d1 e6 88 INC &88 ; item_data_address_low &11d3 d0 95 BNE &116a ; initialise_items_loop &11d5 e6 89 INC &89 ; item_data_address_high &11d7 a5 89 LDA &89 ; item_data_address_high &11d9 c9 0e CMP #&0e &11db d0 8d BNE &116a ; initialise_items_loop ; initialise_player &11dd a9 00 LDA #&00 &11df 85 72 STA &72 ; player_sprite &11e1 85 22 STA &22 ; player_facing # Zero to indicate facing left &11e3 85 9f STA &9f ; core_elements_placed &11e5 a9 01 LDA #&01 ; FIRE_LEFT &11e7 85 76 STA &76 ; player_on_hopper # Non-zero to indicate player not on hopper &11e9 85 7a STA &7a ; fire_direction &11eb a0 0b LDY #&0b ; reset_core_elements_required_loop &11ed 98 TYA &11ee 99 0c 00 STA &000c,Y ; core_elements_required - &b # Wipe &0017 - &001f &11f1 c8 INY &11f2 c0 14 CPY #&14 &11f4 d0 f7 BNE &11ed ; reset_core_elements_required_loop ; choose_core_elements &11f6 a9 04 LDA #&04 # Change four core elements to non-structural types &11f8 85 8e STA &8e ; count ; choose_core_elements_loop &11fa 20 40 64 JSR &6440 ; rnd # Pick a random non-structural type of element &11fd c9 0a CMP #&0a &11ff b0 f9 BCS &11fa ; choose_core_elements_loop &1201 69 14 ADC #&14 ; ITEM_CORE_CHIP_1 &1203 a0 08 LDY #&08 ; check_if_element_already_used_loop &1205 d9 17 00 CMP &0017,Y ; core_elements_required &1208 f0 f0 BEQ &11fa ; choose_core_elements_loop # Has this element already been used? &120a 88 DEY &120b 10 f8 BPL &1205 ; check_if_element_already_used_loop &120d 48 PHA ; choose_random_position &120e 20 40 64 JSR &6440 ; rnd # If not, pick a random position to put it in &1211 c9 09 CMP #&09 &1213 b0 f9 BCS &120e ; choose_random_position &1215 aa TAX &1216 b5 17 LDA &17,X ; core_elements_required &1218 c9 14 CMP #&14 ; ITEM_CORE_CHIP_1 # Is there already a non-structural element there? &121a b0 f2 BCS &120e ; choose_random_position &121c 68 PLA &121d 95 17 STA &17,X ; core_elements_required # If not, change the core element &121f c6 8e DEC &8e ; count &1221 10 d7 BPL &11fa ; change_core_elements_loop ; place_core_elements &1223 a9 00 LDA #&00 &1225 85 8c STA &8c ; possible_locations_offset &1227 85 8d STA &8d ; data_offset &1229 85 8b STA &8b ; core_element_to_consider ; place_core_elements_loop &122b 20 40 64 JSR &6440 ; rnd &122e 29 02 AND #&02 &1230 18 CLC &1231 65 8c ADC &8c ; possible_locations_offset &1233 a8 TAY &1234 b9 cd 61 LDA &61cd,Y ; possible_core_element_locations &1237 a6 8d LDX &8d ; data_offset &1239 9d 28 05 STA &0528,X ; core_elements_data + 0 # Set room_low &123c b9 ce 61 LDA &61ce,Y ; possible_core_element_locations + 1 &123f 48 PHA &1240 48 PHA &1241 29 01 AND #&01 &1243 9d 29 05 STA &0529,X ; core_elements_data + 1 # Set room_high &1246 68 PLA &1247 0a ASL A &1248 0a ASL A &1249 0a ASL A &124a 0a ASL A &124b 29 e0 AND #&e0 &124d 09 08 ORA #&08 &124f 1d 29 05 ORA &0529,X ; core_elements_data + 1 &1252 9d 29 05 STA &0529,X ; core_elements_data + 1 # Set screen_address_low &1255 68 PLA &1256 29 70 AND #&70 &1258 4a LSR A &1259 4a LSR A &125a 4a LSR A &125b 85 8e STA &8e ; tmp &125d 4a LSR A &125e 65 8e ADC &8e ; tmp &1260 69 6e ADC #&6e &1262 9d 2a 05 STA &052a,X ; core_elements_data + 2 # Set screen_address_high &1265 a5 8b LDA &8b ; core_element_to_consider &1267 c9 0b CMP #&0b &1269 b0 0a BCS &1275 ; use_random_sprite ; use_required_sprite &126b a8 TAY &126c b9 15 00 LDA &0015,Y ; core_elements_required - 2 &126f 9d 2b 05 STA &052b,X ; core_elements_data + 3 # Set sprite &1272 4c 88 12 JMP &1288 ; consider_next_core_element ; use_random_sprite &1275 20 40 64 JSR &6440 ; rnd &1278 a5 9b LDA &9b ; rnd_2 &127a 29 1f AND #&1f &127c c9 13 CMP #&13 ; ITEM_CORE_EXTINGUISHER - &0b &127e b0 f5 BCS &1275 ; use_random_sprite # Choose a random type between &13 and &1d &1280 18 CLC &1281 69 0b ADC #&0b ; ITEM_CORE_TOP_LEFT &1283 a6 8d LDX &8d ; data_offset &1285 9d 2b 05 STA &052b,X ; core_elements_data + 3 # Set sprite ; consider_next_core_element &1288 18 CLC &1289 a5 8c LDA &8c ; possible_locations_offset &128b 69 04 ADC #&04 &128d 85 8c STA &8c ; possible_locations_offset &128f a5 8d LDA &8d ; data_offset &1291 69 04 ADC #&04 &1293 85 8d STA &8d ; data_offset &1295 e6 8b INC &8b ; core_element_to_consider &1297 a5 8b LDA &8b ; core_element_to_consider &1299 c9 01 CMP #&01 &129b f0 04 BEQ &12a1 ; is_pass_or_key &129d c9 03 CMP #&03 &129f d0 11 BNE &12b2 ; not_pass_or_key ; is_pass_or_key &12a1 38 SEC # ITEM_PASS and ITEM_KEY can go in one of four rooms &12a2 a5 8d LDA &8d ; data_offset &12a4 e9 04 SBC #&04 &12a6 85 8d STA &8d ; data_offset &12a8 20 40 64 JSR &6440 ; rnd &12ab 29 01 AND #&01 # 1 in 2 chance to use second set of two rooms &12ad f0 d9 BEQ &1288 ; consider_next_core_element ; to_place_core_elements_loop &12af 4c 2b 12 JMP &122b ; place_core_elements_loop ; not_pass_or_key &12b2 a5 8b LDA &8b ; core_element_to_consider &12b4 c9 16 CMP #&16 &12b6 d0 f7 BNE &12af ; place_core_elements_loop &12b8 a9 09 LDA #&09 ; ITEM_PASS &12ba 8d 2b 05 STA &052b ; core_elements_data + 3 # Set core element 0 sprite &12bd a9 0a LDA #&0a ; ITEM_KEY &12bf 8d 2f 05 STA &052f ; core_elements_data + 7 # Set core element 1 sprite &12c2 a9 08 LDA #&08 &12c4 85 7e STA &7e ; player_room_low &12c6 a9 00 LDA #&00 &12c8 85 7f STA &7f ; player_room_high &12ca 78 SEI &12cb 85 23 STA &23 ; game_time_countdown &12cd e6 23 INC &23 ; game_time_countdown &12cf 85 24 STA &24 ; game_time_low &12d1 85 25 STA &25 ; game_time_high &12d3 58 CLI &12d4 85 9e STA &9e ; player_in_pipe &12d6 85 35 STA &35 ; previous_player_energy_high &12d8 85 37 STA &37 ; previous_player_fuel_high &12da 85 39 STA &39 ; previous_player_ammunition_high &12dc a9 0f LDA #&0f &12de 85 31 STA &31 ; previous_score + 1 &12e0 a9 10 LDA #&10 &12e2 85 3f STA &3f ; player_ammunition_high &12e4 a9 06 LDA #&06 &12e6 85 3d STA &3d ; player_fuel_high &12e8 a9 ff LDA #&ff &12ea 85 3e STA &3e ; player_ammunition_low &12ec 20 60 25 JSR &2560 ; store_player_entry_position ; start_new_life &12ef a5 5a LDA &5a ; player_entry_screen_address_low &12f1 85 70 STA &70 ; player_screen_address_low &12f3 a5 5b LDA &5b ; player_entry_screen_address_high &12f5 85 71 STA &71 ; player_screen_address_high &12f7 a5 5c LDA &5c ; player_entry_sprite &12f9 85 72 STA &72 ; player_sprite &12fb a5 5d LDA &5d ; player_entry_on_platform &12fd 85 76 STA &76 ; player_on_hopper &12ff f8 SED &1300 38 SEC &1301 a5 49 LDA &49 ; player_lives &1303 e9 01 SBC #&01 &1305 85 49 STA &49 ; player_lives &1307 d8 CLD &1308 b0 01 BCS &130b ; player_is_still_alive &130a 60 RTS # Leave with carry clear to indicate game not completed ; player_is_still_alive &130b a9 10 LDA #&10 &130d 85 3b STA &3b ; player_energy_high &130f a5 3d LDA &3d ; player_fuel_high &1311 09 01 ORA #&01 &1313 85 3d STA &3d ; player_fuel_high &1315 a9 ff LDA #&ff &1317 85 3c STA &3c ; player_fuel_low &1319 85 3a STA &3a ; player_energy_low ; enter_room_after_pyramid &131b a9 03 LDA #&03 &131d 85 29 STA &29 ; player_room_history + 3 # Remove enemies from nearby rooms &131f 85 27 STA &27 ; player_room_history + 1 ; enter_room &1321 20 24 35 JSR &3524 ; flush_buffers &1324 20 60 25 JSR &2560 ; store_player_entry_position &1327 a5 80 LDA &80 ; player_action &1329 48 PHA &132a a0 2f LDY #&2f ; swap_enemies_loop &132c b9 88 01 LDA &0188,Y ; enemies_data &132f aa TAX &1330 b9 58 01 LDA &0158,Y ; previous_enemies_data &1333 99 88 01 STA &0188,Y ; enemies_data &1336 8a TXA &1337 99 58 01 STA &0158,Y ; previous_enemies_data &133a 88 DEY &133b 10 ef BPL &132c ; swap_enemies_loop &133d 20 a0 20 JSR &20a0 ; wipe_subtiles ; mark_room_as_visited &1340 a5 7f LDA &7f ; player_room_high &1342 4a LSR A &1343 a5 7e LDA &7e ; player_room_low &1345 6a ROR A &1346 4a LSR A &1347 4a LSR A &1348 a8 TAY &1349 a9 00 LDA #&00 &134b 85 8f STA &8f ; bit &134d a5 7e LDA &7e ; player_room_low &134f 29 07 AND #&07 &1351 aa TAX &1352 38 SEC ; calculate_bit_loop &1353 26 8f ROL &8f ; bit &1355 ca DEX &1356 10 fb BPL &1353 ; calculate_bit_loop &1358 b9 80 03 LDA &0380,Y ; rooms_visited &135b 25 8f AND &8f ; bit &135d d0 1e BNE &137d ; room_already_visisted &135f b9 80 03 LDA &0380,Y ; rooms_visited &1362 05 8f ORA &8f ; bit &1364 99 80 03 STA &0380,Y ; rooms_visited &1367 a0 02 LDY #&02 # Score 250 for visiting an unvisited room &1369 a2 50 LDX #&50 &136b 20 4f 35 JSR &354f ; increase_score &136e 18 CLC &136f a5 0b LDA &0b ; adventure_score &1371 69 32 ADC #&32 # Score 50/256 % for visiting an unvisited room &1373 85 0b STA &0b ; adventure_score &1375 a5 0c LDA &0c ; adventure_score + 1 &1377 f8 SED &1378 69 00 ADC #&00 &137a d8 CLD &137b 85 0c STA &0c ; adventure_score + 1 ; room_already_visisted &137d a6 7e LDX &7e ; player_room_low &137f a4 7f LDY &7f ; player_room_high &1381 20 f0 25 JSR &25f0 ; plot_room &1384 20 71 25 JSR &2571 ; calculate_player_group_address_and_hopper_sprite &1387 a6 70 LDX &70 ; player_screen_address_low &1389 a4 71 LDY &71 ; player_screen_address_high &138b 20 2f 25 JSR &252f ; calculate_below_subtile_address_from_screen_address &138e 86 74 STX &74 ; below_player_subtile_address_low &1390 84 75 STY &75 ; below_player_subtile_address_high &1392 a9 00 LDA #&00 &1394 85 73 STA &73 ; falling_time &1396 68 PLA ; player_action &1397 85 80 STA &80 ; player_action &1399 20 d4 23 JSR &23d4 ; plot_status &139c a5 2e LDA &2e ; new_enemies_cooldown # Store room's enemy state in history &139e 85 2c STA &2c ; new_enemies_cooldown_history + 2 &13a0 a5 2f LDA &2f ; new_enemies_needed &13a2 85 2d STA &2d ; new_enemies_needed_history + 2 &13a4 a5 26 LDA &26 ; player_room_history &13a6 c5 7e CMP &7e ; player_room_low &13a8 d0 11 BNE &13bb ; not_previous_room # Is this the previous room visited? &13aa a5 27 LDA &27 ; player_room_history + 1 &13ac c5 7f CMP &7f ; player_room_high &13ae d0 0b BNE &13bb ; not_previous_room &13b0 a5 2a LDA &2a ; new_enemies_cooldown_history # If so, use previous enemies &13b2 85 2e STA &2e ; new_enemies_cooldown &13b4 a5 2b LDA &2b ; new_enemies_needed_history &13b6 85 2f STA &2f ; new_enemies_needed &13b8 4c 30 14 JMP &1430 ; skip_initialising_enemies ; not_previous_room # Otherwise, &13bb 20 40 64 JSR &6440 ; rnd &13be 09 10 ORA #&10 # Between &10 and &1f frames before new enemies appear &13c0 85 2e STA &2e ; new_enemies_cooldown &13c2 20 40 64 JSR &6440 ; rnd &13c5 29 01 AND #&01 &13c7 09 02 ORA #&02 # 3 or 4 enemies &13c9 85 2f STA &2f ; new_enemies_needed &13cb a0 2f LDY #&2f &13cd a9 00 LDA #&00 ; wipe_enemies_data_loop # Wipe previous enemies &13cf 99 88 01 STA &0188,Y ; enemies_data &13d2 88 DEY &13d3 10 fa BPL &13cf ; wipe_enemies_data_loop &13d5 a5 7f LDA &7f ; player_room_high &13d7 f0 57 BEQ &1430 ; skip_initialising_enemies ; check_room_for_patrolling_droids &13d9 a9 26 LDA #&26 &13db 85 8e STA &8e ; special_rooms_offset ; consider_next_room &13dd c6 8e DEC &8e ; special_rooms_offset &13df c6 8e DEC &8e ; special_rooms_offset &13e1 30 4d BMI &1430 ; skip_initialising_enemies &13e3 a4 8e LDY &8e ; special_rooms_offset &13e5 b9 85 61 LDA &6185,Y ; rooms_with_patrolling_droids # Does this room have patrolling droids? &13e8 c5 7e CMP &7e ; player_room_low &13ea d0 f1 BNE &13dd ; consider_next_room &13ec b9 86 61 LDA &6186,Y ; rooms_with_patrolling_droids + 1 &13ef 48 PHA &13f0 29 f8 AND #&f8 &13f2 8d 32 23 STA &2332 ; patrolling_droid_data # Set enemies_screen_address_low &13f5 68 PLA &13f6 29 03 AND #&03 &13f8 85 8e STA &8e ; patrolling_droids_needed &13fa a0 00 LDY #&00 ; initialise_patrolling_droids_loop &13fc 84 8f STY &8f ; enemy_offset &13fe 20 40 64 JSR &6440 ; rnd # Patrolling droids have random speed &1401 69 08 ADC #&08 &1403 8d 36 23 STA &2336 ; patrolling_droid_data + 4 # Set enemies_inertia &1406 20 40 64 JSR &6440 ; rnd # Patrolling droids have random direction &1409 29 01 AND #&01 &140b aa TAX &140c bd 3e 23 LDA &233e,X ; patrolling_droid_direction_table &140f 8d 35 23 STA &2335 ; patrolling_droid_data + 5 # Set enemies_direction &1412 a4 8f LDY &8f ; enemy_offset &1414 a2 00 LDX #&00 ; copy_patrolling_droid_data_loop &1416 bd 32 23 LDA &2332,X ; patrolling_droid_data &1419 99 88 01 STA &0188,Y ; enemies_data &141c e8 INX &141d c8 INY &141e e0 0c CPX #&0c &1420 90 f4 BCC &1416 ; copy_patrolling_droid_data_loop &1422 ad 32 23 LDA &2332 ; patrolling_droid_data # Increase enemies_screen_address_low &1425 69 1f ADC #&1f &1427 8d 32 23 STA &2332 ; patrolling_droid_data &142a c6 2f DEC &2f ; new_enemies_needed &142c c6 8e DEC &8e ; patrolling_droids_needed &142e 10 cc BPL &13fc ; initialise_patrolling_droids_loop ; skip_initialising_enemies &1430 a9 01 LDA #&01 &1432 85 0d STA &0d ; gate_screen_address_low &1434 20 b6 2e JSR &2eb6 ; update_enemies # Unplot enemies &1437 20 66 23 JSR &2366 ; plot_gates &143a a0 00 LDY #&00 ; rotate_player_room_and_enemy_history_loop &143c b9 28 00 LDA &0028,Y ; player_room_history + 2 # Move &0028 - &002f to &0026 - &002d &143f 99 26 00 STA &0026,Y ; player_room_history # i.e. rotate player_room_history &1442 c8 INY # new_enemies_cooldown_history &1443 c0 08 CPY #&08 # and new_enemies_needed_history &1445 d0 f5 BNE &143c ; rotate_player_room_and_enemy_history_loop &1447 a5 7e LDA &7e ; player_room_low # Store current room in room history &1449 85 28 STA &28 ; player_room_history + 2 &144b a5 7f LDA &7f ; player_room_high &144d 85 29 STA &29 ; player_room_history + 3 &144f a5 7f LDA &7f ; player_room_high &1451 d0 0e BNE &1461 ; is_regular_room &1453 a5 7e LDA &7e ; player_room_low &1455 c9 c7 CMP #&c7 # Is the core room? (&0c7) &1457 f0 0b BEQ &1464 ; is_core_room &1459 c9 c6 CMP #&c6 # or the room to the left of the core room? (&0c6) &145b d0 04 BNE &1461 ; is_regular_room ; is_left_of_core_room &145d a9 ff LDA #&ff # Stop enemies spawning in room left of core room &145f 85 2e STA &2e ; new_enemies_cooldown ; is_regular_room &1461 4c ec 15 JMP &15ec ; not_core_room ; is_core_room &1464 a9 01 LDA #&01 # Unplot enemies, don't update &1466 20 b6 2e JSR &2eb6 ; update_enemies &1469 a9 6d LDA #&6d &146b 85 8e STA &8e ; subtile_address_low &146d a9 06 LDA #&06 ; &066d = room_subtiles + &20 * 6 + &d # Move four subtiles down, thirteen across &146f 85 8f STA &8f ; subtile_address_high &1471 a2 06 LDX #&06 ; set_subtiles_column_loop &1473 a0 05 LDY #&05 ; set_subtiles_row_loop &1475 a9 18 LDA #&18 ; SUBTILE_NO_ENEMIES | SUBTILE_NO_PLAYER &1477 91 8e STA (&8e),Y ; subtile_address # Set core area to be impassable &1479 88 DEY &147a 10 f9 BPL &1475 ; set_subtiles_row_loop &147c 18 CLC &147d a5 8e LDA &8e ; subtile_address_low &147f 69 20 ADC #&20 &1481 85 8e STA &8e ; subtile_address_low &1483 90 02 BCC &1487 ; skip_overflow &1485 e6 8f INC &8f ; subtile_address_high ; skip_overflow &1487 ca DEX &1488 d0 e9 BNE &1473 ; set_subtiles_column_loop &148a 20 63 35 JSR &3563 ; set_core_element_colours &148d a9 00 LDA #&00 &148f a2 73 LDX #&73 ; &7300 &1491 20 87 35 JSR &3587 ; plot_full_core_array # Plot core array &1494 20 00 7f JSR &7f00 ; to_set_screen_colours &1497 a9 00 LDA #&00 &1499 85 84 STA &84 ; pocket_to_consider # For each pocket, ; check_pockets_for_core_elements_pocket_loop &149b a4 84 LDY &84 ; pocket_to_consider &149d b9 0f 00 LDA &000f,Y ; pockets &14a0 a0 08 LDY #&08 ; check_pockets_for_core_elements_element_loop &14a2 d9 17 00 CMP &0017,Y ; core_elements_required # does it contain a required core element? &14a5 f0 06 BEQ &14ad ; pocket_contains_required_core_element &14a7 88 DEY &14a8 10 f8 BPL &14a2 ; check_pockets_for_core_elements_element_loop &14aa 4c 06 15 JMP &1506 ; consider_next_pocket ; pocket_contains_required_core_element &14ad 85 83 STA &83 ; core_element_type &14af 84 85 STY &85 ; core_element_offset &14b1 85 81 STA &81 ; core_element_for_pocket &14b3 a9 0f LDA #&0f &14b5 85 86 STA &86 ; count &14b7 b9 75 35 LDA &3575,Y ; initial_core_element_colours &14ba 8d 9e 20 STA &209e ; core_element_flash_colours # Set first colour of flash to be colour 1 or 2 ; flash_restored_core_element_loop &14bd a5 86 LDA &86 ; count &14bf 29 01 AND #&01 &14c1 aa TAX &14c2 bd 9e 20 LDA &209e,X ; core_element_flash_colours # Alternate between first flash colour and white &14c5 a4 85 LDY &85 ; core_element_offset &14c7 99 f7 0b STA &0bf7,Y ; core_elements_colours &14ca a4 84 LDY &84 ; pocket_to_consider &14cc a5 81 LDA &81 ; core_element_for_pocket &14ce 99 0f 00 STA &000f,Y ; pockets &14d1 45 83 EOR &83 ; core_element_type # Alternate pocket between core element and empty &14d3 85 81 STA &81 ; core_element_for_pocket &14d5 a2 34 LDX #&34 &14d7 a0 60 LDY #&60 ; &6034 = core_element_from_pocket_sound &14d9 20 3d 35 JSR &353d ; play_sound &14dc a9 00 LDA #&00 &14de a2 73 LDX #&73 &14e0 20 93 35 JSR &3593 ; plot_partial_core_array &14e3 20 d4 23 JSR &23d4 ; plot_status &14e6 a9 07 LDA #&07 &14e8 20 42 35 JSR &3542 ; wait_for_a_frames &14eb c6 86 DEC &86 ; count &14ed 10 ce BPL &14bd ; flash_restored_core_element_loop &14ef a5 85 LDA &85 ; core_element_offset &14f1 a8 TAY &14f2 18 CLC &14f3 69 8b ADC #&8b # Set top bit to indicate core element has been &14f5 99 17 00 STA &0017,Y ; core_elements_required # restore, use structural element for position &14f8 a9 ff LDA #&ff # Set restored core element to be white in array &14fa 99 f7 0b STA &0bf7,Y ; core_elements_colours &14fd e6 9f INC &9f ; core_elements_placed &14ff a5 9f LDA &9f ; core_elements_placed &1501 c9 09 CMP #&09 # Have all nine core elements been restored? If so, &1503 90 01 BCC &1506 ; consider_next_pocket &1505 60 RTS # Leave with carry set to indicate game completed ; consider_next_pocket &1506 e6 84 INC &84 ; pocket_to_consider &1508 a5 84 LDA &84 ; pocket_to_consider &150a c9 04 CMP #&04 &150c d0 8d BNE &149b ; check_pockets_for_core_elements_pocket_loop &150e a0 2f LDY #&2f ; copy_core_room_materialisation_data_loop &1510 b9 02 23 LDA &2302,Y ; core_room_materialisation_data # Use core room materialisations for enemies &1513 99 88 01 STA &0188,Y ; enemies_screen_address_low &1516 88 DEY &1517 10 f7 BPL &1510 ; copy_core_room_materialisation_data_loop &1519 a9 08 LDA #&08 &151b 85 8e STA &8e ; count ; randomise_materialisation_positions_loop &151d 20 40 64 JSR &6440 ; rnd # Choose a random multiple of 12 for enemy offset &1520 a5 9b LDA &9b ; rnd_2 &1522 29 18 AND #&18 &1524 85 8f STA &8f ; random_enemy_offset &1526 4a LSR A &1527 65 8f ADC &8f ; random_enemy_offset &1529 a8 TAY &152a b9 88 01 LDA &0188,Y ; enemies_screen_address_low &152d 49 08 EOR #&08 # Move enemy by 4 pixels left or right &152f 99 88 01 STA &0188,Y ; enemies_screen_address_low &1532 20 40 64 JSR &6440 ; rnd # Choose a random multiple of 12 for enemy offset &1535 a5 9b LDA &9b ; rnd_2 &1537 29 18 AND #&18 &1539 85 8f STA &8f ; random_enemy_offset &153b 4a LSR A &153c 65 8f ADC &8f ; random_enemy_offset &153e a8 TAY &153f b9 89 01 LDA &0189,Y ; enemies_screen_address_high &1542 49 01 EOR #&01 # Move enemy by 8 pixels up or down &1544 99 89 01 STA &0189,Y ; enemies_screen_address_high &1547 c6 8e DEC &8e ; count &1549 d0 d2 BNE &151d ; randomise_materialisation_positions_loop &154b a5 9f LDA &9f ; core_elements_placed &154d 85 70 STA &70 ; unused # Unnecessary code &154f 38 SEC &1550 a9 08 LDA #&08 &1552 e5 9f SBC &9f ; core_elements_placed # Add one materialisation for every two core elements &1554 4a LSR A # restored ; remove_enemies_loop &1555 85 8e STA &8e ; count &1557 c6 8e DEC &8e ; count &1559 30 1f BMI &157a ; skip_removing_enemies ; choose_random_enemy &155b 20 40 64 JSR &6440 ; rnd # Choose a random multiple of 12 for enemy offset &155e a5 9b LDA &9b ; rnd_2 &1560 29 18 AND #&18 &1562 85 8f STA &8f ; random_enemy_offset &1564 4a LSR A &1565 65 8f ADC &8f ; random_enemy_offset &1567 aa TAX &1568 bd 89 01 LDA &0189,X ; enemies_screen_address_high # Is there an enemy in this slot? &156b f0 ee BEQ &155b ; choose_random_enemy # If not, choose another slot &156d a9 00 LDA #&00 &156f a0 0c LDY #&0c ; wipe_enemy_loop &1571 9d 88 01 STA &0188,X ; enemies_screen_address_low &1574 e8 INX &1575 88 DEY &1576 d0 f9 BNE &1571 ; wipe_enemy_loop &1578 f0 dd BEQ &1557 ; remove_enemies_loop ; skip_removing_enemies &157a a9 01 LDA #&01 # Unplot enemies, don't update &157c 20 b6 2e JSR &2eb6 ; update_enemies &157f a9 64 LDA #&64 ; core_room_loop &1581 48 PHA ; frames ; choose_random_colour &1582 20 40 64 JSR &6440 ; rnd # Choose a random colour &1585 c9 05 CMP #&05 # from green, yellow, blue, magenta or cyan &1587 b0 f9 BCS &1582 ; choose_random_colour &1589 69 02 ADC #&02 &158b 85 95 STA &95 ; palette + 5 # Set colour two of bottom section &158d a9 02 LDA #&02 ; core_room_inner_loop &158f 48 PHA ; inner_frames &1590 a9 13 LDA #&13 ; Wait for v-sync &1592 20 f4 ff JSR &fff4 ; OSBYTE &1595 ad 3e 60 LDA &603e ; restored_core_element_sound + 2 &1598 49 f1 EOR #&f1 # Alternate volume between silent and full &159a 8d 3e 60 STA &603e ; restored_core_element_sound + 2 &159d a2 3c LDX #&3c &159f a0 60 LDY #&60 ; &603c = restored_core_element_sound &15a1 20 3d 35 JSR &353d ; play_sound &15a4 a9 00 LDA #&00 # Update and replot enemies &15a6 20 b6 2e JSR &2eb6 ; update_enemies &15a9 68 PLA ; inner_frames &15aa 38 SEC &15ab e9 01 SBC #&01 &15ad d0 e0 BNE &158f ; core_room_inner_loop &15af 20 00 7f JSR &7f00 ; to_set_screen_colours &15b2 a9 00 LDA #&00 &15b4 a2 73 LDX #&73 &15b6 20 93 35 JSR &3593 ; plot_partial_core_array &15b9 a9 08 LDA #&08 &15bb 85 8e STA &8e ; count ; randomise_colours_of_unrestored_core_elements_loop &15bd 20 40 64 JSR &6440 ; rnd # Choose colour 1 or 2 at random &15c0 a2 f0 LDX #&f0 &15c2 29 01 AND #&01 &15c4 d0 02 BNE &15c8 ; use_colour_2 &15c6 a2 0f LDX #&0f ; use_colour_2 &15c8 a4 8e LDY &8e ; count &15ca 8a TXA &15cb b6 17 LDX &17,Y ; core_elements_required &15cd 30 03 BMI &15d2 ; skip_element # Has this core element been restored? &15cf 99 f7 0b STA &0bf7,Y ; core_elements_colours # If not, set its colour ; skip_element &15d2 c6 8e DEC &8e ; count &15d4 10 e7 BPL &15bd ; randomise_colours_of_unrestored_core_elements_loop &15d6 68 PLA ; frames &15d7 38 SEC &15d8 e9 01 SBC #&01 &15da f0 03 BEQ &15df ; finished_in_core_room &15dc 4c 81 15 JMP &1581 ; core_room_loop ; finished_in_core_room &15df c6 7e DEC &7e ; player_room_low # Return player to room left of core room &15e1 a9 03 LDA #&03 # Prevent any falling or walking sound &15e3 85 73 STA &73 ; falling_time &15e5 a9 e8 LDA #&e8 # Put player at right edge of room &15e7 85 70 STA &70 ; player_screen_address_low &15e9 4c 21 13 JMP &1321 ; enter_room ; not_core_room &15ec 20 d9 20 JSR &20d9 ; replot_player &15ef 20 00 7f JSR &7f00 ; to_set_screen_colours &15f2 a9 00 LDA #&00 &15f4 85 77 STA &77 ; player_on_hopper_pad # Zero to indicate player not on hopper pad &15f6 85 7b STA &7b ; fire_hit_something &15f8 85 7c STA &7c ; fire_screen_address_low &15fa 85 7d STA &7d ; fire_screen_address_high &15fc 85 45 STA &45 ; player_walking_direction &15fe ad 40 02 LDA &0240 ; os_cfs_timeout_counter &1601 85 50 STA &50 ; previous_cfs_timeout_counter ; main_game_loop &1603 a5 76 LDA &76 ; player_on_hopper &1605 85 21 STA &21 ; previous_player_on_hopper &1607 20 54 25 JSR &2554 ; calculate_below_player_subtile_address &160a a5 80 LDA &80 ; player_action &160c 85 81 STA &81 ; previous_player_action &160e 29 0f AND #&0f ; PLAYER_LEFT | PLAYER_RIGHT | PLAYER_UP | PLAYER_DOWN &1610 f0 0e BEQ &1620 ; skip_setting_fire_direction &1612 c9 0f CMP #&0f ; PLAYER_LEFT | PLAYER_RIGHT | PLAYER_UP | PLAYER_DOWN &1614 f0 0a BEQ &1620 ; skip_setting_fire_direction &1616 c9 03 CMP #&03 ; PLAYER_LEFT | PLAYER_RIGHT &1618 f0 06 BEQ &1620 ; skip_setting_fire_direction &161a c9 0c CMP #&0c ; PLAYER_UP | PLAYER_DOWN &161c f0 02 BEQ &1620 ; skip_setting_fire_direction &161e 85 79 STA &79 ; player_fire_direction ; skip_setting_fire_direction &1620 a9 00 LDA #&00 &1622 85 80 STA &80 ; player_action &1624 a4 0a LDY &0a ; input_method &1626 c0 0a CPY #&0a &1628 90 3c BCC &1666 ; check_keys ; check_joystick &162a a9 80 LDA #&80 ; Read I/O device &162c a2 01 LDX #&01 ; Analogue channel 1 &162e 20 f4 ff JSR &fff4 ; OSBYTE &1631 a2 00 LDX #&00 &1633 c0 38 CPY #&38 &1635 b0 02 BCS &1639 ; joystick_not_right &1637 a2 02 LDX #&02 ; PLAYER_RIGHT ; joystick_not_right &1639 c0 c8 CPY #&c8 &163b 90 02 BCC &163f ; joystick_not_left &163d a2 01 LDX #&01 ; PLAYER_LEFT ; joystick_not_left &163f 86 80 STX &80 ; player_action &1641 a9 80 LDA #&80 ; Read I/O device &1643 a2 02 LDX #&02 ; Analogue channel 2 &1645 20 f4 ff JSR &fff4 ; OSBYTE &1648 a5 80 LDA &80 ; player_action &164a c0 38 CPY #&38 &164c b0 02 BCS &1650 ; joystick_not_down &164e 09 08 ORA #&08 ; PLAYER_DOWN ; joystick_not_down &1650 c0 c8 CPY #&c8 &1652 90 02 BCC &1656 ; joystick_not_up &1654 09 04 ORA #&04 ; PLAYER_UP ; joystick_not_up &1656 85 80 STA &80 ; player_action &1658 a9 80 LDA #&80 ; Read I/O device &165a a2 00 LDX #&00 ; buttons &165c 20 f4 ff JSR &fff4 ; OSBYTE &165f 8a TXA &1660 29 03 AND #&03 &1662 f0 4b BEQ &16af ; fire_not_pressed &1664 d0 43 BNE &16a9 ; fire_pressed ; check_keys &1666 b6 00 LDX &00,Y ; key_left &1668 20 94 20 JSR &2094 ; check_for_keypress &166b d0 06 BNE &1673 ; left_not_pressed &166d a5 80 LDA &80 ; player_action &166f 09 01 ORA #&01 ; PLAYER_LEFT &1671 85 80 STA &80 ; player_action ; left_not_pressed &1673 a4 0a LDY &0a ; input_method &1675 b6 01 LDX &01,Y ; key_right &1677 20 94 20 JSR &2094 ; check_for_keypress &167a d0 06 BNE &1682 ; right_not_pressed &167c a5 80 LDA &80 ; player_action &167e 09 02 ORA #&02 ; PLAYER_RIGHT &1680 85 80 STA &80 ; player_action ; right_not_pressed &1682 a4 0a LDY &0a ; input_method &1684 b6 02 LDX &02,Y ; key_up &1686 20 94 20 JSR &2094 ; check_for_keypress &1689 d0 06 BNE &1691 ; up_not_pressed &168b a5 80 LDA &80 ; player_action &168d 09 04 ORA #&04 ; PLAYER_UP &168f 85 80 STA &80 ; player_action ; up_not_pressed &1691 a4 0a LDY &0a ; input_method &1693 b6 03 LDX &03,Y ; key_down &1695 20 94 20 JSR &2094 ; check_for_keypress &1698 d0 06 BNE &16a0 ; down_not_pressed &169a a5 80 LDA &80 ; player_action &169c 09 08 ORA #&08 ; PLAYER_DOWN &169e 85 80 STA &80 ; player_action ; down_not_pressed &16a0 a4 0a LDY &0a ; input_method &16a2 b6 04 LDX &04,Y ; key_fire &16a4 20 94 20 JSR &2094 ; check_for_keypress &16a7 d0 06 BNE &16af ; fire_not_pressed ; fire_pressed &16a9 a5 80 LDA &80 ; player_action &16ab 09 10 ORA #&10 ; PLAYER_FIRE &16ad 85 80 STA &80 ; player_action ; fire_not_pressed &16af a9 00 LDA #&00 &16b1 85 f8 STA &f8 ; obstacles_found &16b3 a6 70 LDX &70 ; player_screen_address_low &16b5 a4 71 LDY &71 ; player_screen_address_high &16b7 20 e0 65 JSR &65e0 ; calculate_subtile_address_from_screen_address &16ba 86 8e STX &8e ; player_subtile_right_address_low &16bc 84 8f STY &8f ; player_subtile_right_address_high &16be 84 8d STY &8d ; player_subtile_left_address_high &16c0 ca DEX &16c1 86 8c STX &8c ; player_subtile_left_address_low &16c3 a2 02 LDX #&02 # Check two rows of subtiles &16c5 a0 00 LDY #&00 &16c7 a5 70 LDA &70 ; player_screen_address_low &16c9 29 07 AND #&07 &16cb f0 01 BEQ &16ce ; player_isn't_straddling_group_left &16cd e8 INX # Add extra row if player sprite is straddling group ; player_isn't_straddling_group_left &16ce a5 77 LDA &77 ; player_on_hopper_pad # Non-zero if player on hopper pad &16d0 d0 05 BNE &16d7 ; player_isn't_on_platform_left &16d2 a5 76 LDA &76 ; player_on_hopper # Non-zero if player not on hopper &16d4 d0 01 BNE &16d7 ; player_isn't_on_platform_left &16d6 e8 INX # Add extra row if player is on hopper ; player_isn't_on_platform_left ; check_for_obstacles_left &16d7 b1 8c LDA (&8c),Y ; player_subtile_left_address &16d9 29 08 AND #&08 ; SUBTILE_NO_PLAYER &16db d0 12 BNE &16ef ; left_subtile_has_obstacle &16dd 18 CLC &16de a5 8c LDA &8c ; player_subtile_left_address_low &16e0 69 20 ADC #&20 # Move down one subtile &16e2 85 8c STA &8c ; player_subtile_left_address_low &16e4 a5 8d LDA &8d ; player_subtile_left_address_high &16e6 69 00 ADC #&00 &16e8 85 8d STA &8d ; player_subtile_left_address_high &16ea ca DEX &16eb d0 ea BNE &16d7 ; check_for_obstacles_left &16ed f0 0c BEQ &16fb ; no_obstacle_to_left ; left_subtile_has_obstacle &16ef a5 72 LDA &72 ; player_sprite # Is the player at the left of a subtile? &16f1 29 03 AND #&03 &16f3 d0 06 BNE &16fb ; no_obstacle_to_left # Skip checking for left obstacle if not &16f5 a5 f8 LDA &f8 ; obstacles_found &16f7 09 01 ORA #&01 ; OBSTACLE_LEFT &16f9 85 f8 STA &f8 ; obstacles_found ; no_obstacle_to_left &16fb a2 02 LDX #&02 # Check two rows of subtiles &16fd a0 02 LDY #&02 &16ff a5 70 LDA &70 ; player_screen_address_low &1701 29 07 AND #&07 &1703 f0 01 BEQ &1706 ; player_isn't_straddling_group_right &1705 e8 INX # Add extra row if player sprite is straddling group ; player_isn't_straddling_group_right &1706 a5 77 LDA &77 ; player_on_hopper_pad # Non-zero if player on hopper pad &1708 d0 05 BNE &170f ; player_isn't_on_platform_right &170a a5 76 LDA &76 ; player_on_hopper # Non-zero if player not on hopper &170c d0 01 BNE &170f ; player_isn't_on_platform_right &170e e8 INX # Add extra row if player is on hopper ; player_isn't_on_platform_right ; check_for_obstacles_right &170f b1 8e LDA (&8e),Y ; player_subtile_right_address &1711 29 08 AND #&08 ; SUBTILE_NO_PLAYER &1713 d0 0b BNE &1720 ; right_subtile_has_obstacle &1715 18 CLC &1716 98 TYA &1717 69 20 ADC #&20 # Move down one subtile &1719 a8 TAY &171a ca DEX &171b d0 f2 BNE &170f ; check_for_obstacles_right &171d 4c 26 17 JMP &1726 ; no_obstacle_to_right ; right_subtile_has_obstacle &1720 a5 f8 LDA &f8 ; obstacles_found &1722 09 02 ORA #&02 ; OBSTACLE_RIGHT &1724 85 f8 STA &f8 ; obstacles_found ; no_obstacle_to_right &1726 a5 2e LDA &2e ; new_enemies_cooldown &1728 f0 07 BEQ &1731 ; consider_adding_enemy &172a 30 20 BMI &174c ; skip_adding_enemies &172c c6 2e DEC &2e ; new_enemies_cooldown &172e 4c 4c 17 JMP &174c ; skip_adding_enemies ; consider_adding_enemy &1731 a5 2f LDA &2f ; new_enemies_needed &1733 30 17 BMI &174c ; skip_adding_enemies &1735 20 40 64 JSR &6440 ; rnd &1738 29 03 AND #&03 &173a d0 10 BNE &174c ; skip_adding_enemies &173c 20 bd 2d JSR &2dbd ; add_enemy &173f a5 2f LDA &2f ; new_enemies_needed &1741 10 09 BPL &174c ; skip_adding_enemies &1743 20 40 64 JSR &6440 ; rnd # 1 in 8 chance &1746 29 07 AND #&07 &1748 d0 02 BNE &174c ; skip_adding_enemies &174a c6 2e DEC &2e ; new_enemies_cooldown # of permanently killing an enemy ; skip_adding_enemies &174c a5 76 LDA &76 ; player_on_hopper # Zero if player on hopper &174e f0 1d BEQ &176d ; skip_falling_and_walking_sound &1750 a5 73 LDA &73 ; falling_time &1752 f0 0e BEQ &1762 ; consider_walking_sound &1754 c9 01 CMP #&01 &1756 d0 15 BNE &176d ; skip_falling_and_walking_sound &1758 a2 54 LDX #&54 &175a a0 60 LDY #&60 ; &6054 = player_falling_sound &175c 20 3d 35 JSR &353d ; play_sound &175f 4c 6d 17 JMP &176d ; skip_falling_and_walking_sound ; consider_walking_sound &1762 a5 45 LDA &45 ; player_walking_direction &1764 f0 07 BEQ &176d ; skip_falling_and_walking_sound &1766 a2 d1 LDX #&d1 &1768 a0 20 LDY #&20 ; &20d1 = player_walking_sound &176a 20 3d 35 JSR &353d ; play_sound ; skip_falling_and_walking_sound ; wait_for_vsync &176d ad 40 02 LDA &0240 ; os_cfs_timeout_counter &1770 c5 50 CMP &50 ; previous_cfs_timeout_counter &1772 f0 f9 BEQ &176d ; wait_for_vsync &1774 85 50 STA &50 ; previous_cfs_timeout_counter &1776 20 d9 20 JSR &20d9 ; replot_player &1779 20 71 25 JSR &2571 ; calculate_player_group_address_and_hopper_sprite &177c a5 80 LDA &80 ; player_action &177e 29 03 AND #&03 ; PLAYER_LEFT | PLAYER_RIGHT &1780 c9 03 CMP #&03 ; PLAYER_LEFT | PLAYER_RIGHT &1782 f0 66 BEQ &17ea ; player_not_moving_left_or_right &1784 a5 f8 LDA &f8 ; obstacles_found &1786 29 01 AND #&01 ; OBSTACLE_LEFT # Is there an obstacle to the left? &1788 d0 2d BNE &17b7 ; player_not_moving_left &178a a5 80 LDA &80 ; player_action &178c 29 01 AND #&01 ; PLAYER_LEFT # If not, does the player want to move left? &178e f0 27 BEQ &17b7 ; player_not_moving_left &1790 85 45 STA &45 ; player_walking_direction &1792 a5 77 LDA &77 ; player_on_hopper_pad # Zero if player not on hopper pad &1794 f0 04 BEQ &179a ; not_leaving_hopper_pad_to_left &1796 a9 01 LDA #&01 # Non-zero to indicate player not on hopper &1798 85 76 STA &76 ; player_on_hopper ; not_leaving_hopper_pad_to_left &179a c6 72 DEC &72 ; player_sprite &179c a5 72 LDA &72 ; player_sprite &179e 29 07 AND #&07 &17a0 85 72 STA &72 ; player_sprite &17a2 29 03 AND #&03 &17a4 c9 03 CMP #&03 &17a6 d0 09 BNE &17b1 ; not_new_subtile_to_left &17a8 38 SEC &17a9 a5 70 LDA &70 ; player_screen_address_low &17ab e9 08 SBC #&08 # Move left four pixels &17ad 85 70 STA &70 ; player_screen_address_low &17af c6 74 DEC &74 ; below_player_subtile_address_low ; not_new_subtile_to_left &17b1 a5 22 LDA &22 ; player_facing &17b3 29 fe AND #&fe # Unset lowest bit to indicate facing left &17b5 85 22 STA &22 ; player_facing ; player_not_moving_left &17b7 a5 f8 LDA &f8 ; obstacles_found &17b9 29 02 AND #&02 ; OBSTACLE_RIGHT # Is there an obstacle to the right? &17bb d0 2d BNE &17ea ; player_not_moving_left_or_right &17bd a5 80 LDA &80 ; player_action &17bf 29 02 AND #&02 : PLAYER_RIGHT # If not, does the player want to move right? &17c1 f0 27 BEQ &17ea ; player_not_moving_left_or_right &17c3 85 45 STA &45 ; player_walking_direction &17c5 a5 77 LDA &77 ; player_on_hopper_pad &17c7 f0 04 BEQ &17cd ; not_leaving_hopper_pad_to_right &17c9 a9 01 LDA #&01 &17cb 85 76 STA &76 ; player_on_hopper ; not_leaving_hopper_pad_to_right &17cd 18 CLC &17ce a5 72 LDA &72 ; player_sprite &17d0 29 07 AND #&07 &17d2 69 01 ADC #&01 &17d4 09 08 ORA #&08 &17d6 85 72 STA &72 ; player_sprite &17d8 29 03 AND #&03 &17da d0 08 BNE &17e4 ; not_new_subtile_to_right &17dc a5 70 LDA &70 ; player_screen_address_low &17de 69 08 ADC #&08 # Move right four pixels &17e0 85 70 STA &70 ; player_screen_address_low &17e2 e6 74 INC &74 ; below_player_subtile_address_low ; not_new_subtile_to_right &17e4 a5 22 LDA &22 ; player_facing &17e6 09 01 ORA #&01 # Set lowest bit to indicate facing right &17e8 85 22 STA &22 ; player_facing ; player_not_moving_left_or_right &17ea a5 76 LDA &76 ; player_on_hopper # Zero if player on hopper &17ec f0 03 BEQ &17f1 ; on_platform ; player_not_moving_up_or_down &17ee 4c af 18 JMP &18af ; consider_bridging_platform ; on_platform &17f1 a5 80 LDA &80 ; player_action &17f3 29 0c AND #&0c ; PLAYER_UP | PLAYER_DOWN &17f5 c9 0c CMP #&0c ; PLAYER_UP | PLAYER_DOWN &17f7 f0 f5 BEQ &17ee ; player_not_moving_up_or_down &17f9 a6 70 LDX &70 ; player_screen_address_low # Get the address of the subtile containing the platform &17fb a4 71 LDY &71 ; player_screen_address_high &17fd 20 2f 25 JSR &252f ; calculate_below_subtile_address_from_screen_address &1800 38 SEC &1801 8a TXA &1802 e9 60 SBC #&60 # Move up three subtiles &1804 85 8c STA &8c ; subtile_address_low &1806 98 TYA &1807 e9 00 SBC #&00 &1809 85 8d STA &8d ; subtile_address_high &180b a0 02 LDY #&02 &180d a5 72 LDA &72 ; player_sprite &180f 29 03 AND #&03 &1811 d0 01 BNE &1814 ; check_for_obstacles_above &1813 88 DEY # Player is three or two subtiles wide ; check_for_obstacles_above &1814 b1 8c LDA (&8c),Y ; subtile_address &1816 29 08 AND #&08 ; SUBTILE_NO_PLAYER &1818 d0 06 BNE &1820 ; top_subtile_has_obstacle &181a 88 DEY &181b 10 f7 BPL &1814 ; check_for_obstacles_above &181d 4c 2c 18 JMP &182c ; no_obstacle_above ; top_subtile_has_obstacle &1820 a5 70 LDA &70 ; player_screen_address_low &1822 29 06 AND #&06 &1824 d0 06 BNE &182c ; no_obstacle_above # Player can move up if not aligned with group &1826 a5 f8 LDA &f8 ; obstacles_found &1828 09 04 ORA #&04 ; OBSTACLE_ABOVE &182a 85 f8 STA &f8 ; obstacles_found ; no_obstacle_above &182c a0 22 LDY #&22 &182e a5 72 LDA &72 ; player_sprite &1830 29 03 AND #&03 &1832 d0 01 BNE &1835 ; check_for_obstacles_below &1834 88 DEY # Player is three or two subtiles wide ; check_for_obstacles_below &1835 b1 8e LDA (&8e),Y ; player_subtile_right_address &1837 29 08 AND #&08 ; SUBTILE_NO_PLAYER &1839 d0 08 BNE &1843 ; bottom_subtile_has_obstacle &183b 88 DEY &183c c0 1f CPY #&1f &183e d0 f5 BNE &1835 ; check_for_obstacles_below &1840 4c 49 18 JMP &1849 ; no_obstacle_below ; bottom_subtile_has_obstacle &1843 a5 f8 LDA &f8 ; obstacles_found &1845 09 08 ORA #&08 ; OBSTACLE_BELOW &1847 85 f8 STA &f8 ; obstacles_found ; no_obstacle_below &1849 a5 f8 LDA &f8 ; obstacles_found &184b 29 04 AND #&04 ; OBSTACLE_ABOVE # Is there an obstacle above the player? &184d d0 35 BNE &1884 ; align_player_with_group_up &184f a5 80 LDA &80 ; player_action &1851 29 04 AND #&04 ; PLAYER_UP # If not, does the player want to move up? &1853 f0 35 BEQ &188a ; player_not_moving_up &1855 a5 f8 LDA &f8 ; obstacles_found &1857 29 f7 AND #&f7 &1859 85 f8 STA &f8 ; obstacles_found &185b 38 SEC &185c a5 70 LDA &70 ; player_screen_address_low &185e 29 07 AND #&07 &1860 e9 02 SBC #&02 # Move up two pixels &1862 b0 19 BCS &187d ; move_up_within_group &1864 38 SEC &1865 a5 70 LDA &70 ; player_screen_address_low &1867 e9 fa SBC #&fa &1869 85 70 STA &70 ; player_screen_address_low &186b b0 02 BCS &186f ; skip_underflow &186d c6 71 DEC &71 ; player_screen_address_high ; skip_underflow &186f 38 SEC &1870 a5 74 LDA &74 ; below_player_subtile_address_low &1872 e9 20 SBC #&20 # Move up one subtile &1874 85 74 STA &74 ; below_player_subtile_address_low &1876 b0 02 BCS &187a ; skip_underflow &1878 c6 75 DEC &75 ; below_player_subtile_address_high ; skip_underflow &187a 4c 8a 18 JMP &188a ; player_not_moving_up ; move_up_within_group &187d c6 70 DEC &70 ; player_screen_address_low &187f c6 70 DEC &70 ; player_screen_address_low &1881 4c 8a 18 JMP &188a ; player_not_moving_up ; align_player_with_group_up &1884 a5 70 LDA &70 ; player_screen_address_low &1886 29 f8 AND #&f8 &1888 85 70 STA &70 ; player_screen_address_low ; player_not_moving_up &188a a5 f8 LDA &f8 ; obstacles_found &188c 29 08 AND #&08 ; OBSTACLE_BELOW # Is there an obstacle below the player? &188e d0 19 BNE &18a9 ; align_player_with_group_down &1890 a5 80 LDA &80 ; player_action &1892 29 08 AND #&08 ; PLAYER_DOWN # If not, does the player want to move down? &1894 f0 19 BEQ &18af ; player_not_moving_down &1896 a9 02 LDA #&02 # Move down two pixels &1898 20 61 20 JSR &2061 ; move_player_down &189b 18 CLC &189c a5 74 LDA &74 ; below_player_subtile_address_low &189e 69 20 ADC #&20 # Move down one subtile &18a0 85 74 STA &74 ; below_player_subtile_address_low &18a2 90 02 BCC &18a6 ; skip_overflow &18a4 e6 75 INC &75 ; below_player_subtile_address_high ; skip_overflow &18a6 4c af 18 JMP &18af ; player_not_moving_down ; align_player_with_group_down &18a9 a5 70 LDA &70 ; player_screen_address_low &18ab 29 f8 AND #&f8 &18ad 85 70 STA &70 ; player_screen_address_low ; player_not_moving_down ; consider_bridging_platform &18af a5 76 LDA &76 ; player_on_hopper # Zero if player on hopper &18b1 f0 16 BEQ &18c9 ; to_skip_bridging_platform &18b3 a5 9e LDA &9e ; player_in_pipe # Non-zero if player in pipe &18b5 d0 12 BNE &18c9 ; to_skip_bridging_platform &18b7 a5 81 LDA &81 ; previous_player_action &18b9 29 08 AND #&08 ; PLAYER_DOWN &18bb d0 0c BNE &18c9 ; to_skip_bridging_platform # Does the player want to create a bridging platform? &18bd a5 80 LDA &80 ; player_action &18bf 29 08 AND #&08 ; PLAYER_DOWN &18c1 f0 06 BEQ &18c9 ; to_skip_bridging_platform # No key repeat &18c3 a5 71 LDA &71 ; player_screen_address_high &18c5 c9 6d CMP #&6d # Is the player above the top of the screen? &18c7 10 03 BPL &18cc ; consider_making_bridging_platform ; to_skip_bridging_platform &18c9 4c af 19 JMP &19af ; skip_bridging_platform ; consider_making_bridging_platform &18cc a5 71 LDA &71 ; player_screen_address_high &18ce c9 7d CMP #&7d # Is the player at or below the bottom of the screen? &18d0 b0 f7 BCS &18c9 ; to_skip_bridging_platform &18d2 a5 3d LDA &3d ; player_fuel_high &18d4 f0 f3 BEQ &18c9 ; to_skip_bridging_platform # Does the player have fuel? &18d6 a5 81 LDA &81 ; previous_player_action &18d8 29 08 AND #&08 ; PLAYER_DOWN &18da d0 ed BNE &18c9 ; to_skip_bridging_platform &18dc a5 80 LDA &80 ; player_action &18de 29 08 AND #&08 ; PLAYER_DOWN &18e0 f0 e7 BEQ &18c9 ; to_skip_bridging_platform &18e2 a5 80 LDA &80 ; player_action &18e4 29 03 AND #&03 ; PLAYER_LEFT | PLAYER_RIGHT &18e6 d0 e1 BNE &18c9 ; to_skip_bridging_platform &18e8 a6 70 LDX &70 ; player_screen_address_low &18ea a4 71 LDY &71 ; player_screen_address_high &18ec a5 73 LDA &73 ; falling_time &18ee f0 04 BEQ &18f4 ; player_isn't_falling &18f0 c8 INY # Calculate subtile address four tiles below player &18f1 c8 INY &18f2 c8 INY &18f3 c8 INY ; player_isn't_falling &18f4 88 DEY # (three if player isn't falling) &18f5 20 e0 65 JSR &65e0 ; calculate_subtile_address_from_screen_address &18f8 a0 02 LDY #&02 &18fa a5 72 LDA &72 ; player_sprite &18fc 29 03 AND #&03 &18fe d0 01 BNE &1901 ; check_for_obstacles &1900 88 DEY # Player is three or two subtiles wide ; check_for_obstacles &1901 b1 6b LDA (&6b),Y ; subtile_address &1903 29 08 AND #&08 ; SUBTILE_NO_PLAYER &1905 d0 0f BNE &1916 ; obstacle_found &1907 88 DEY &1908 10 f7 BPL &1901 ; check_for_obstacles &190a a5 73 LDA &73 ; falling_time &190c f0 18 BEQ &1926 ; create_bridging_platform &190e a5 71 LDA &71 ; player_screen_address_high &1910 c9 7c CMP #&7c &1912 90 12 BCC &1926 ; create_bridging_platform &1914 b0 04 BCS &191a ; align_player_with_group # Always branches ; obstacle_found &1916 a5 73 LDA &73 ; falling_time &1918 f0 af BEQ &18c9 ; to_skip_bridging_platform ; align_player_with_group &191a a5 70 LDA &70 ; player_screen_address_low &191c 29 f8 AND #&f8 # Align player with group &191e 85 70 STA &70 ; player_screen_address_low &1920 a9 00 LDA #&00 &1922 85 73 STA &73 ; falling_time &1924 e6 71 INC &71 ; player_screen_address_high ; create_bridging_platform &1926 a0 00 LDY #&00 &1928 20 c2 20 JSR &20c2 ; find_bridging_platform_slot &192b d0 52 BNE &197f ; to_skip_bridging_platform # Non-zero if no slot available for new platform &192d a5 70 LDA &70 ; player_screen_address_low &192f 29 f8 AND #&f8 # Align platform with group &1931 85 8e STA &8e ; platform_screen_address_low &1933 a5 73 LDA &73 ; falling_time &1935 d0 0f BNE &1946 ; skip_up_subtile &1937 c6 71 DEC &71 ; player_screen_address_high &1939 38 SEC &193a a5 74 LDA &74 ; below_player_subtile_address_low &193c e9 20 SBC #&20 # Move up a subtile if player isn't falling &193e 85 74 STA &74 ; below_player_subtile_address_low &1940 a5 75 LDA &75 ; below_player_subtile_address_high &1942 e9 00 SBC #&00 &1944 85 75 STA &75 ; below_player_subtile_address_high ; skip_up_subtile &1946 a6 8e LDX &8e ; platform_screen_address_low &1948 18 CLC &1949 a5 72 LDA &72 ; player_sprite &194b 29 02 AND #&02 &194d f0 05 BEQ &1954 ; skip_adjustment &194f 8a TXA &1950 69 08 ADC #&08 # Move platform right four pixels &1952 85 8e STA &8e ; platform_screen_address_low ; skip_adjustment &1954 a5 71 LDA &71 ; player_screen_address_high &1956 69 02 ADC #&02 # Platform is two subtiles below player &1958 84 6d STY &6d ; platform_screen_address_high &195a a8 TAY &195b a5 73 LDA &73 ; falling_time &195d f0 01 BEQ &1960 ; not_falling &195f c8 INY # three if player is falling ; not_falling &1960 a6 8e LDX &8e ; player_group_address_low &1962 20 e0 65 JSR &65e0 ; calculate_subtile_address_from_screen_address &1965 86 8e STX &8e ; platform_subtile_address_low &1967 84 8f STY &8f ; platform_subtile_address_high &1969 a6 6d LDX &6d ; platform_screen_address_high &196b a0 00 LDY #&00 &196d b1 8e LDA (&8e),Y ; platform_subtile_address &196f 29 07 AND #&07 ; SUBTILE_GATE | SUBTILE_HIDE_PLAYER | SUBTILE_PIPE &1971 c9 07 CMP #&07 # Never matches &1973 d0 0d BNE &1982 ; skip_unused_code # Always branches &1975 ad fe 65 LDA &65fe ; unused_zero_one # Unused code &1978 85 70 STA &70 ; player_screen_address_low &197a ad ff 65 LDA &65ff ; unused_zero_two &197d 85 71 STA &71 ; player_screen_address_high ; to_skip_bridging_platform &197f 4c af 19 JMP &19af ; skip_bridging_platform ; skip_unused_code &1982 b1 8e LDA (&8e),Y ; platform_subtile_address &1984 09 08 ORA #&08 ; SUBTILE_NO_PLAYER # Stop player falling through left half of platform &1986 91 8e STA (&8e),Y ; platform_subtile_address &1988 c8 INY &1989 b1 8e LDA (&8e),Y ; platform_subtile_address &198b 09 08 ORA #&08 ; SUBTILE_NO_PLAYER # Stop player falling through right half of platform &198d 91 8e STA (&8e),Y ; platform_subtile_address &198f a5 8f LDA &8f ; platform_subtile_address_high &1991 29 03 AND #&03 &1993 09 e0 ORA #&e0 # Set time to live &1995 9d 01 04 STA &0401,X ; bridging_platform_data + 1 &1998 a5 8e LDA &8e ; platform_subtile_address_low &199a 9d 00 04 STA &0400,X ; bridging_platform_data &199d 38 SEC &199e a5 3c LDA &3c ; player_fuel_low &19a0 e9 40 SBC #&40 # Temporary platform uses &0040 fuel &19a2 85 3c STA &3c ; player_fuel_low &19a4 b0 02 BCS &19a8 ; skip_underflow &19a6 c6 3d DEC &3d ; player_fuel_high ; skip_underflow &19a8 a2 5c LDX #&5c &19aa a0 60 LDY #&60 ; &605c = bridging_platform_sound &19ac 20 3d 35 JSR &353d ; play_sound ; skip_bridging_platform ; consider_firing &19af a5 80 LDA &80 ; player_action &19b1 29 10 AND #&10 ; PLAYER_FIRE # Did the player press fire? &19b3 f0 4f BEQ &1a04 ; not_firing &19b5 a5 7d LDA &7d ; fire_screen_address_high &19b7 d0 4b BNE &1a04 ; not_firing &19b9 a5 3f LDA &3f ; player_ammunition_high # Does the player have ammunition? &19bb f0 47 BEQ &1a04 ; not_firing &19bd 38 SEC &19be a5 3e LDA &3e ; player_ammunition_low &19c0 e9 20 SBC #&20 # Firing uses &0020 ammunition &19c2 85 3e STA &3e ; player_ammunition_low &19c4 b0 02 BCS &19c8 ; skip_overflow &19c6 c6 3f DEC &3f ; player_ammunition_high ; skip_overflow &19c8 a5 76 LDA &76 ; player_on_hopper # Zero if player on hopper &19ca 49 01 EOR #&01 &19cc 85 78 STA &78 ; fire_type &19ce a5 70 LDA &70 ; player_screen_address_low &19d0 85 7c STA &7c ; fire_screen_address_low &19d2 85 8e STA &8e ; screen_address_low # Unnecessary code &19d4 a5 71 LDA &71 ; player_screen_address_high &19d6 09 80 ORA #&80 # Top bit set to indicate fire doesn't need unplotting &19d8 aa TAX &19d9 a5 70 LDA &70 ; player_screen_address_low &19db 29 04 AND #&04 &19dd f0 01 BEQ &19e0 ; player_aligned_with_group &19df e8 INX # Move down a group if player not aligned with group ; player_aligned_with_group &19e0 a5 76 LDA &76 ; player_on_hopper # Zero if player on hopper &19e2 f0 01 BEQ &19e5 ; player_is_on_platform &19e4 e8 INX ; player_is_on_platform &19e5 86 7d STX &7d ; fire_screen_address_high &19e7 86 8f STX &8f ; screen_address_high # Unnecessary code &19e9 a6 79 LDX &79 ; player_fire_direction &19eb a5 76 LDA &76 ; player_on_hopper # Zero if player on hopper &19ed f0 0a BEQ &19f9 ; set_fire_direction &19ef a2 81 LDX #&81 ; FIRE_LEFT | FIRE_NO_BOUNCE &19f1 a5 72 LDA &72 ; player_sprite &19f3 29 08 AND #&08 # Is the player facing right? &19f5 f0 02 BEQ &19f9 ; set_fire_direction &19f7 a2 82 LDX #&82 ; FIRE_RIGHT | FIRE_NO_BOUNCE ; set_fire_direction &19f9 86 7a STX &7a ; fire_direction &19fb a2 44 LDX #&44 &19fd a0 60 LDY #&60 ; &6044 = player_firing_sound &19ff a9 07 LDA #&07 ; Generate a sound (SOUND) &1a01 20 f1 ff JSR &fff1 ; OSWORD ; not_firing &1a04 a5 76 LDA &76 ; player_on_hopper # Zero if player on hopper &1a06 d0 03 BNE &1a0b ; consider_falling &1a08 4c b4 1a JMP &1ab4 ; skip_falling ; consider_falling &1a0b 20 4e 20 JSR &204e ; check_if_player_can_fall # Returns negative set if no obstacle &1a0e 30 09 BMI &1a19 ; make_player_fall &1a10 b1 74 LDA (&74),Y ; below_subtile_address &1a12 29 04 AND #&04 ; SUBTILE_PIPE # Is the player in a pipe? &1a14 f0 03 BEQ &1a19 ; make_player_fall &1a16 4c b0 1a JMP &1ab0 ; skip_falling_and_reset_falling_time # If so, the player doesn't fall ; make_player_fall &1a19 a4 73 LDY &73 ; falling_time &1a1b b9 b1 20 LDA &20b1,Y ; falling_speeds &1a1e 20 61 20 JSR &2061 ; move_player_down &1a21 a5 73 LDA &73 ; falling_time &1a23 c9 10 CMP #&10 &1a25 b0 02 BCS &1a29 ; skip_increase &1a27 e6 73 INC &73 ; falling_time ; skip_increase &1a29 20 4e 20 JSR &204e ; check_if_player_can_fall # Returns negative unset if obstacle &1a2c 10 03 BPL &1a31 ; player_falls_into_obstacle ; to_skip_falling &1a2e 4c b4 1a JMP &1ab4 ; skip_falling ; player_falls_into_obstacle &1a31 b1 74 LDA (&74),Y ; below_subtile_address &1a33 29 04 AND #&04 ; SUBTILE_PIPE &1a35 d0 f7 BNE &1a2e ; to_skip_falling &1a37 b1 74 LDA (&74),Y ; below_subtile_address &1a39 29 01 AND #&01 ; SUBTILE_GATE &1a3b 49 01 EOR #&01 &1a3d d0 6b BNE &1aaa ; align_player_with_group # Align player if obstacle isn't a horizontal gate &1a3f a5 73 LDA &73 ; falling_time &1a41 c9 10 CMP #&10 &1a43 30 65 BMI &1aaa ; align_player_with_group # Is the player falling into the gate at maximum speed? &1a45 a5 74 LDA &74 ; below_player_subtile_address_low &1a47 85 8e STA &8e ; gate_subtile_address_low &1a49 a5 75 LDA &75 ; below_player_subtile_address_high &1a4b 85 8f STA &8f ; gate_subtile_address_high &1a4d 85 89 STA &89 ; bridging_platform_subtile_address_high ; find_start_of_gate_loop &1a4f c6 8e DEC &8e ; gate_subtile_address_low &1a51 b1 8e LDA (&8e),Y ; gate_subtile_address &1a53 29 01 AND #&01 ; SUBTILE_GATE &1a55 d0 f8 BNE &1a4f ; find_start_of_gate_loop &1a57 88 DEY &1a58 98 TYA &1a59 18 CLC &1a5a 65 8e ADC &8e ; gate_subtile_low # Calculate screen address of gate &1a5c 85 8e STA &8e ; gate_subtile_low &1a5e 85 88 STA &88 ; bridging_platform_subtile_address_low &1a60 06 8e ASL &8e ; gate_subtile_low &1a62 26 8f ROL &8f ; gate_subtile_high &1a64 06 8e ASL &8e ; gate_subtile_low &1a66 26 8f ROL &8f ; gate_subtile_high &1a68 06 8e ASL &8e ; gate_subtile_low / screen_address_low &1a6a 26 8f ROL &8f ; gate_subtile_high &1a6c a5 8f LDA &8f ; gate_subtile_high &1a6e 09 60 ORA #&60 &1a70 85 8f STA &8f ; screen_address_high &1a72 a9 e0 LDA #&e0 &1a74 85 8c STA &8c ; sprite_address_low &1a76 a9 40 LDA #&40 ; &40e0 = bridging_platform_frame_7 &1a78 85 8d STA &8d ; sprite_address_high &1a7a a2 04 LDX #&04 &1a7c a0 01 LDY #&01 &1a7e 20 00 65 JSR &6500 ; plot_aligned_sprite_using_write # Plot bridging platform over gate &1a81 a0 00 LDY #&00 &1a83 20 c2 20 JSR &20c2 ; find_bridging_platform_slot &1a86 a5 89 LDA &89 ; bridging_platform_subtile_address_high # Add two bridging platforms in place of gate &1a88 29 03 AND #&03 &1a8a 09 80 ORA #&80 # Set time to live &1a8c 99 01 04 STA &0401,Y ; bridging_platform_data + 1 &1a8f a5 88 LDA &88 ; bridging_platform_subtile_address_low &1a91 99 00 04 STA &0400,Y ; bridging_platform_data + 1 &1a94 a0 00 LDY #&00 &1a96 20 c2 20 JSR &20c2 ; find_bridging_platform_slot &1a99 a5 89 LDA &89 ; bridging_platform_subtile_address_high &1a9b 29 03 AND #&03 &1a9d 09 80 ORA #&80 # Set time to live &1a9f 99 01 04 STA &0401,Y ; bridging_platform_data + 1 &1aa2 a5 88 LDA &88 ; bridging_platform_subtile_address_low &1aa4 18 CLC &1aa5 69 02 ADC #&02 &1aa7 99 00 04 STA &0400,Y ; bridging_platform_data ; align_player_with_group &1aaa a5 70 LDA &70 ; player_screen_address_low &1aac 29 f8 AND #&f8 &1aae 85 70 STA &70 ; player_screen_address_low ; skip_falling_and_reset_falling_time &1ab0 a9 00 LDA #&00 &1ab2 85 73 STA &73 ; falling_time ; skip_falling &1ab4 a9 00 LDA #&00 &1ab6 85 77 STA &77 ; player_on_hopper_pad &1ab8 a5 72 LDA &72 ; player_sprite &1aba 29 03 AND #&03 &1abc d0 1f BNE &1add ; not_hopper_pad &1abe a5 70 LDA &70 ; player_screen_address_low &1ac0 29 f8 AND #&f8 &1ac2 c5 64 CMP &64 ; hopper_pad_screen_address_low &1ac4 d0 17 BNE &1add ; not_hopper_pad &1ac6 a5 71 LDA &71 ; player_screen_address_high &1ac8 c5 65 CMP &65 ; hopper_pad_screen_address_high &1aca d0 11 BNE &1add ; not_hopper_pad &1acc a9 01 LDA #&01 &1ace 85 77 STA &77 ; player_on_hopper_pad &1ad0 a5 70 LDA &70 ; player_screen_address_low &1ad2 29 f8 AND #&f8 &1ad4 85 70 STA &70 ; player_screen_address_low &1ad6 a9 00 LDA #&00 # Zero to indicate player on hopper &1ad8 85 76 STA &76 ; player_on_hopper &1ada 20 71 25 JSR &2571 ; calculate_player_group_address_and_hopper_sprite ; not_hopper_pad &1add a5 76 LDA &76 ; player_on_hopper &1adf c5 21 CMP &21 ; previous_player_on_hopper &1ae1 f0 1a BEQ &1afd ; no_change_of_platform &1ae3 a5 64 LDA &64 ; hopper_pad_screen_address_low &1ae5 85 8e STA &8e ; screen_address_low &1ae7 a5 65 LDA &65 ; hopper_pad_screen_address_high &1ae9 18 CLC &1aea 69 02 ADC #&02 &1aec 85 8f STA &8f ; screen_address_high &1aee a9 20 LDA #&20 &1af0 85 8c STA &8c ; sprite_address_low &1af2 a9 41 LDA #&41 ; &4120 = hopper_frame_1 &1af4 85 8d STA &8d ; sprite_address_high &1af6 a2 02 LDX #&02 # 8 pixels wide &1af8 a0 01 LDY #&01 # 8 pixels high &1afa 20 ad 65 JSR &65ad ; plot_aligned_sprite_using_eor ; no_change_of_platform &1afd a5 72 LDA &72 ; player_sprite &1aff 29 03 AND #&03 &1b01 d0 60 BNE &1b63 ; set_player_not_in_pipe &1b03 38 SEC &1b04 a5 74 LDA &74 ; below_player_subtile_address_low &1b06 e9 61 SBC #&61 # Move up three subtiles, left one subtile &1b08 85 8c STA &8c ; subtile_address_low &1b0a a5 75 LDA &75 ; below_player_subtile_address_high &1b0c e9 00 SBC #&00 &1b0e 85 8d STA &8d ; subtile_address_high &1b10 a0 21 LDY #&21 # Consider subtile (+1, +1), i.e. (0, -2) &1b12 b1 8c LDA (&8c),Y ; subtile_address &1b14 29 0c AND #&0c ; SUBTILE_NO_PLAYER | SUBTILE_PIPE &1b16 c9 04 CMP #&04 ; SUBTILE_PIPE &1b18 d0 49 BNE &1b63 ; set_player_not_in_pipe &1b1a a0 22 LDY #&22 # Consider subtile (+2, +1), i.e. (1, -2) &1b1c b1 8c LDA (&8c),Y ; subtile_address &1b1e 29 0c AND #&0c ; SUBTILE_NO_PLAYER | SUBTILE_PIPE &1b20 c9 04 CMP #&04 ; SUBTILE_PIPE &1b22 d0 3f BNE &1b63 ; set_player_not_in_pipe # If both are pipes, &1b24 a5 75 LDA &75 ; below_player_subtile_address_high &1b26 c9 05 CMP #&05 &1b28 f0 19 BEQ &1b43 ; skip_second_check # and the player is not at the top of the screen, &1b2a a5 70 LDA &70 ; player_screen_address_low &1b2c 29 06 AND #&06 &1b2e d0 13 BNE &1b43 ; skip_second_check &1b30 a0 01 LDY #&01 # Consider subtile (+1, 0), i.e. (0, -3) &1b32 b1 8c LDA (&8c),Y ; subtile_address &1b34 29 0c AND #&0c ; SUBTILE_NO_PLAYER | SUBTILE_PIPE &1b36 c9 04 CMP #&04 ; SUBTILE_PIPE &1b38 d0 29 BNE &1b63 ; set_player_not_in_pipe &1b3a c8 INY # Consider subtile (+2, 0), i.e. (1, -3) &1b3b b1 8c LDA (&8c),Y ; subtile_address &1b3d 29 0c AND #&0c ; SUBTILE_NO_PLAYER | SUBTILE_PIPE &1b3f c9 04 CMP #&04 ; SUBTILE_PIPE &1b41 d0 20 BNE &1b63 ; set_player_not_in_pipe # If both are pipes, ; skip_second_check &1b43 a5 70 LDA &70 ; player_screen_address_low &1b45 29 06 AND #&06 &1b47 e9 02 SBC #&02 &1b49 90 0a BCC &1b55 ; align_player &1b4b a5 70 LDA &70 ; player_screen_address_low &1b4d 29 fe AND #&fe &1b4f e9 02 SBC #&02 &1b51 85 70 STA &70 ; player_screen_address_low &1b53 b0 0a BCS &1b5f ; set_player_in_pipe ; align_player &1b55 a5 70 LDA &70 ; player_screen_address_low &1b57 29 f8 AND #&f8 &1b59 09 06 ORA #&06 &1b5b 85 70 STA &70 ; player_screen_address_low &1b5d c6 71 DEC &71 ; player_screen_address_high ; set_player_in_pipe &1b5f a9 01 LDA #&01 # Non-zero to indicate player in pipe &1b61 d0 02 BNE &1b65 ; update_player_in_pipe # Always branches ; set_player_not_in_pipe &1b63 a9 00 LDA #&00 ; update_player_in_pipe &1b65 85 9e STA &9e ; player_in_pipe &1b67 a5 76 LDA &76 ; player_on_hopper # Zero if player on hopper &1b69 f0 06 BEQ &1b71 ; skip_lower_check &1b6b a5 71 LDA &71 ; player_screen_address_high &1b6d c9 7d CMP #&7d # If not, is the player at the bottom of the screen? &1b6f d0 24 BNE &1b95 ; not_falling_into_new_room ; skip_check_check &1b71 a5 71 LDA &71 ; player_screen_address_high &1b73 c9 7c CMP #&7c # If so, is the platform at the bottom of the screen? &1b75 30 1e BMI &1b95 ; not_falling_into_new_room &1b77 a5 70 LDA &70 ; player_screen_address_low &1b79 29 07 AND #&07 &1b7b f0 18 BEQ &1b95 ; not_falling_into_new_room &1b7d a9 6d LDA #&6d # Put player at top of screen &1b7f 85 71 STA &71 ; player_screen_address_high &1b81 a5 70 LDA &70 ; player_screen_address_low &1b83 29 f8 AND #&f8 &1b85 85 70 STA &70 ; player_screen_address_low &1b87 18 CLC &1b88 a5 7e LDA &7e ; player_room_low &1b8a 69 10 ADC #&10 # Move player down a room &1b8c 85 7e STA &7e ; player_room_low &1b8e 90 02 BCC &1b92 ; skip_overflow &1b90 e6 7f INC &7f ; player_room_high ; skip_overflow &1b92 4c 21 13 JMP &1321 ; enter_room ; not_falling_into_new_room &1b95 a5 71 LDA &71 ; player_screen_address_high &1b97 c9 6c CMP #&6c # Is the player at the top of the screen? &1b99 d0 1e BNE &1bb9 ; not_ascending_into_new_room &1b9b a9 7c LDA #&7c # Put player at bottom of screen &1b9d 85 71 STA &71 ; player_screen_address_high &1b9f a5 70 LDA &70 ; player_screen_address_low &1ba1 29 f8 AND #&f8 &1ba3 05 76 ORA &76 ; player_on_hopper # Zero if player on hopper &1ba5 85 70 STA &70 ; player_screen_address_low &1ba7 a9 07 LDA #&07 &1ba9 85 75 STA &75 ; below_player_subtile_address_high # Unnecessary code &1bab 38 SEC &1bac a5 7e LDA &7e ; player_room_low &1bae e9 10 SBC #&10 # Move player up a room &1bb0 85 7e STA &7e ; player_room_low &1bb2 b0 02 BCS &1bb6 ; skip_underflow &1bb4 c6 7f DEC &7f ; player_room_high ; skip_underflow &1bb6 4c 21 13 JMP &1321 ; enter_room ; not_ascending_into_new_room &1bb9 a5 72 LDA &72 ; player_sprite &1bbb 29 03 AND #&03 &1bbd c9 03 CMP #&03 &1bbf d0 1f BNE &1be0 ; not_moving_right_into_new_room # Is the player about to move right into a new subtile? &1bc1 a5 74 LDA &74 ; below_player_subtile_address_low &1bc3 29 1f AND #&1f &1bc5 c9 1d CMP #&1d # Is the player at the right of the screen? &1bc7 d0 17 BNE &1be0 ; not_moving_right_into_new_room &1bc9 a5 70 LDA &70 ; player_screen_address_low &1bcb 29 07 AND #&07 # Put player at left of screen &1bcd 85 70 STA &70 ; player_screen_address_low &1bcf a5 72 LDA &72 ; player_sprite &1bd1 29 f8 AND #&f8 &1bd3 09 01 ORA #&01 # Put player at left of subtile &1bd5 85 72 STA &72 ; player_sprite &1bd7 e6 7e INC &7e ; player_room_low # Move player right a room &1bd9 d0 02 BNE &1bdd ; skip_overflow &1bdb e6 7f INC &7f ; player_room_high ; skip_overflow &1bdd 4c 21 13 JMP &1321 ; enter_room ; not_moving_right_into_new_room &1be0 a5 72 LDA &72 ; player_sprite &1be2 29 03 AND #&03 &1be4 d0 24 BNE &1c0a ; not_moving_left_into_new_room # Is the player about to move left into a new subtile? &1be6 a5 74 LDA &74 ; below_player_subtile_address_low &1be8 29 1f AND #&1f &1bea d0 1e BNE &1c0a ; not_moving_left_into_new_room # Is the player at the left of the screen? &1bec a5 70 LDA &70 ; player_screen_address_low &1bee 29 07 AND #&07 &1bf0 09 e8 ORA #&e8 # Put player at right of screen &1bf2 85 70 STA &70 ; player_screen_address_low &1bf4 a5 72 LDA &72 ; player_sprite &1bf6 29 f8 AND #&f8 &1bf8 09 02 ORA #&02 # Put player at right of subtile &1bfa 85 72 STA &72 ; player_sprite &1bfc 38 SEC &1bfd a5 7e LDA &7e ; player_room_low &1bff e9 01 SBC #&01 # Move player left a room &1c01 85 7e STA &7e ; player_room_low &1c03 b0 02 BCS &1c07 ; skip_underflow &1c05 c6 7f DEC &7f ; player_room_high ; skip_underflow &1c07 4c 21 13 JMP &1321 ; enter_room ; not_moving_left_into_new_room &1c0a 20 d9 20 JSR &20d9 ; replot_player &1c0d 20 0f 22 JSR &220f ; update_fire &1c10 a9 00 LDA #&00 # Update and replot enemies &1c12 20 b6 2e JSR &2eb6 ; update_enemies &1c15 20 45 20 JSR &2045 ; update_scenery &1c18 a5 71 LDA &71 ; player_screen_address_high &1c1a c5 59 CMP &59 ; room_item_screen_address_high # Does the player overlap the room item vertically? &1c1c f0 02 BEQ &1c20 ; player_is_vertically_aligned_with_item &1c1e b0 3c BCS &1c5c ; to_done_collecting ; player_is_vertically_aligned_with_item &1c20 a2 02 LDX #&02 &1c22 a5 70 LDA &70 ; player_screen_address_low &1c24 29 07 AND #&07 &1c26 d0 01 BNE &1c29 ; player_is_aligned_with_group &1c28 ca DEX ; player_is_aligned_with_group &1c29 8a TXA &1c2a 18 CLC &1c2b 65 71 ADC &71 ; player_screen_address_high &1c2d c5 59 CMP &59 ; room_item_screen_address_high &1c2f 90 2b BCC &1c5c ; to_done_collecting &1c31 a5 70 LDA &70 ; player_screen_address_low # If so, does the player overlap it horizontally? &1c33 29 f8 AND #&f8 &1c35 c5 58 CMP &58 ; room_item_screen_address_low &1c37 f0 02 BEQ &1c3b ; player_is_horizontally_aligned_with_item &1c39 b0 21 BCS &1c5c ; to_done_collecting ; player_is_horizontally_aligned_with_item &1c3b 18 CLC &1c3c 69 08 ADC #&08 &1c3e c5 58 CMP &58 ; room_item_screen_address_low &1c40 90 1a BCC &1c5c ; to_done_collecting &1c42 a5 56 LDA &56 ; room_item_sprite # Is the item a boost? &1c44 c9 05 CMP #&05 ; ITEM_LIVES &1c46 f0 2d BEQ &1c75 ; boost_lives &1c48 c9 03 CMP #&03 ; ITEM_AMMO &1c4a 90 34 BCC &1c80 ; boost_energy &1c4c f0 7a BEQ &1cc8 ; boost_ammunition &1c4e c9 04 CMP #&04 ; ITEM_FUEL &1c50 f0 3c BEQ &1c8e ; boost_fuel &1c52 c9 06 CMP #&06 ; ITEM_RANDOM &1c54 f0 40 BEQ &1c96 ; random_boost &1c56 a5 80 LDA &80 ; player_action # If not, the item is a pyramid &1c58 29 04 AND #&04 ; PLAYER_UP &1c5a d0 03 BNE &1c5f ; player_pressing_up_on_item ; to_done_collecting &1c5c 4c ec 1c JMP &1cec ; done_collecting ; player_pressing_up_on_item &1c5f a5 76 LDA &76 ; player_on_hopper # Zero if player on hopper &1c61 f0 f9 BEQ &1c5c ; to_done_collecting # Can't enter pyramid while on hopper &1c63 a0 04 LDY #&04 ; check_for_pass_loop &1c65 88 DEY &1c66 30 f4 BMI &1c5c ; to_done_collecting # Can't enter pyramid without pass &1c68 b9 0f 00 LDA &000f,Y ; pockets &1c6b c9 09 CMP #&09 ; ITEM_PASS &1c6d d0 f6 BNE &1c65 ; check_for_pass_loop &1c6f 20 2a 10 JSR &102a ; enter_pyramid &1c72 4c 1b 13 JMP &131b ; enter_room_after_pyramid ; boost_lives &1c75 18 CLC &1c76 f8 SED &1c77 a5 49 LDA &49 ; player_lives &1c79 69 01 ADC #&01 # Gain one life &1c7b 85 49 STA &49 ; player_lives &1c7d d8 CLD &1c7e d0 4e BNE &1cce ; done_boosting # Always branches ; boost_energy &1c80 aa TAX # Amount of energy depends on item collected ; boost_energy_with_X &1c81 bd 8b 1c LDA &1c8b,X ; energy_boost_table &1c84 18 CLC &1c85 65 3b ADC &3b ; player_energy_high &1c87 85 3b STA &3b ; player_energy_high &1c89 d0 43 BNE &1cce ; done_boosting # Always branches ; energy_boost_table &1c8b 10 0b 06 ; boost_fuel &1c8e a5 3d STA &3d ; player_fuel_high &1c90 69 08 ADC #&08 # Gain &0800 fuel &1c92 85 3d STA &3d ; player_fuel_high &1c94 d0 38 BNE &1cce ; done_boosting # Always branches ; random_boost &1c96 a2 00 LDX #&00 # Score 100 for collecting a random boost &1c98 a0 01 LDY #&01 &1c9a 20 4f 35 JSR &354f ; increase_score &1c9d 20 40 64 JSR &6440 ; rnd # Choose a random number between 6 and 9 &1ca0 29 03 AND #&03 &1ca2 18 CLC &1ca3 69 06 ADC #&06 &1ca5 85 8e STA &8e ; unused # Unnecessary code &1ca7 a0 00 LDY #&00 &1ca9 a2 00 LDX #&00 &1cab a5 49 LDA &49 ; player_lives &1cad f0 c6 BEQ &1c75 ; boost_lives ; find_lowest_bar_loop # Find lowest of energy, fuel and ammunition &1caf b5 3b LDA &3b,X ; player_energy_high &1cb1 d9 3b 00 CMP &003b,Y ; player_energy_high &1cb4 b0 02 BCS &1cb8 ; skip_swap &1cb6 8a TXA &1cb7 a8 TAY ; skip_swap &1cb8 e8 INX &1cb9 e8 INX &1cba e0 06 CPX #&06 &1cbc d0 f1 BNE &1caf ; find_lowest_bar_loop &1cbe a2 00 LDX #&00 # Gain &1000 energy &1cc0 c0 00 CPY #&00 &1cc2 f0 bd BEQ &1c81 ; boost_energy_with_X &1cc4 c0 02 CPY #&02 &1cc6 f0 c6 BEQ &1c8e ; boost_fuel ; boost_ammunition &1cc8 a5 3f LDA &3f ; player_ammunition_high &1cca 69 0b ADC #&0b # Gain &0b00 ammunition &1ccc 85 3f STA &3f ; player_ammunition_high ; done_boosting &1cce a5 58 LDA &58 ; room_item_screen_address_low &1cd0 85 8e STA &8e ; screen_address_low &1cd2 a5 59 LDA &59 ; room_item_screen_address_high &1cd4 85 8f STA &8f ; screen_address_high &1cd6 a5 56 LDA &56 ; room_item_sprite &1cd8 a6 55 LDX &55 ; room_item_colour_mask &1cda a0 ff LDY #&ff # EOR &1cdc 20 b3 0b JSR &0bb3 ; plot_packed_two_colour_sprite # Unplot item from room &1cdf a0 00 LDY #&00 &1ce1 98 TYA &1ce2 91 53 STA (&53),Y ; room_item_data_address # Remove item from room_item_data &1ce4 c8 INY &1ce5 91 53 STA (&53),Y; room_item_data_address &1ce7 85 59 STA &59 ; room_item_screen_address_high # Zero to indicate item is no longer in room &1ce9 20 24 0e JSR &0e24 ; play_enter_teleport_sound ; done_collecting &1cec 38 SEC &1ced a5 3a LDA &3a ; player_energy_low &1cef e9 01 SBC #&01 # Lose &0001 energy per frame &1cf1 85 3a STA &3a ; player_energy_low &1cf3 b0 02 BCS &1cf7 ; skip_underflow &1cf5 c6 3b DEC &3b ; player_energy_high ; skip_underflow &1cf7 a5 3b LDA &3b ; player_energy_high &1cf9 10 04 BPL &1cff ; skip_floor &1cfb a9 00 LDA #&00 ; skip_floor &1cfd 85 3b STA &3b ; player_energy_high &1cff 20 d4 23 JSR &23d4 ; plot_status ; check_for_player_entering_teleport &1d02 a5 f6 LDA &f6 ; teleport_screen_address_low &1d04 c5 70 CMP &70 ; player_screen_address_low &1d06 d0 11 BNE &1d19 ; not_teleport &1d08 a5 f7 LDA &f7 ; teleport_screen_address_high &1d0a c5 71 CMP &71 ; player_screen_address_high &1d0c d0 0b BNE &1d19 ; not_teleport &1d0e a9 13 LDA #&13 ; Wait for v-sync &1d10 20 f4 ff JSR &fff4 ; OSBYTE &1d13 20 2b 0e JSR &0e2b ; enter_teleport &1d16 4c 21 13 JMP &1321 ; enter_room ; not_teleport &1d19 a5 72 LDA &72 ; player_sprite &1d1b 29 03 AND #&03 &1d1d d0 2f BNE &1d4e ; not_passage # Is the player horizontally aligned with a subtile? &1d1f a5 70 LDA &70 ; player_screen_address_low &1d21 c5 4c CMP &4c ; passage_screen_address_low &1d23 d0 29 BNE &1d4e ; not_passage &1d25 a5 71 LDA &71 ; player_screen_address_high &1d27 c5 4d CMP &4d ; passage_screen_address_high &1d29 d0 23 BNE &1d4e ; not_passage &1d2b a5 4e LDA &4e ; passage_destination_screen_address_low &1d2d 85 70 STA &70 ; player_screen_address_low &1d2f a5 4f LDA &4f ; passage_destination_screen_address_high &1d31 85 71 STA &71 ; player_screen_address_high &1d33 a5 4b LDA &4b ; passage_destination_room_low &1d35 85 7e STA &7e ; player_room_low &1d37 a5 72 LDA &72 ; player_sprite &1d39 29 fc AND #&fc # Align player horizontally with subtile &1d3b 05 4a ORA &4a ; passage_direction &1d3d 85 72 STA &72 ; player_sprite &1d3f a2 19 LDX #&19 &1d41 a0 25 LDY #&25; &2519 = entering_passage_sound &1d43 20 2b 35 JSR &352b ; play_sound_using_envelope &1d46 a9 0a LDA #&0a &1d48 20 42 35 JSR &3542 ; wait_for_a_frames &1d4b 4c 21 13 JMP &1321 ; enter_room ; not_passage &1d4e 38 SEC &1d4f a5 70 LDA &70 ; player_screen_address_low &1d51 29 f8 AND #&f8 &1d53 e9 10 SBC #&10 &1d55 c5 0d CMP &0d ; gate_screen_address_low &1d57 f0 07 BEQ &1d60 ; consider_gate &1d59 18 CLC &1d5a 69 20 ADC #&20 &1d5c c5 0d CMP &0d ; gate_screen_address_low &1d5e d0 30 BNE &1d90 ; not_opening_gate ; consider_gate &1d60 a5 72 LDA &72 ; player_sprite &1d62 29 03 AND #&03 &1d64 d0 2a BNE &1d90 ; not_opening_gate # Is the player horizontally aligned with a subtile? &1d66 a0 04 LDY #&04 ; check_for_key_loop &1d68 88 DEY &1d69 30 25 BMI &1d90 ; not_opening_gate # Can't open gate without key &1d6b b9 0f 00 LDA &000f,Y ; pockets &1d6e c9 0a CMP #&0a ; ITEM_KEY &1d70 d0 f6 BNE &1d68 ; check_for_key_loop ; player_has_key &1d72 20 24 35 JSR &3524 ; flush_buffers &1d75 a2 fb LDX #&fb &1d77 a0 24 LDY #&24 ; &24fb = opening_gate_sound &1d79 20 2b 35 JSR &352b ; play_sound_using_envelope &1d7c a9 11 LDA #&11 &1d7e 20 42 35 JSR &3542 ; wait_for_a_frames &1d81 20 66 23 JSR &2366 ; plot_gates # Unplot gate &1d84 b9 c4 61 LDA &61c4,Y ; gate_table + 1 &1d87 09 02 ORA #&02 # Set &02 to indicate gate isn't present &1d89 99 c4 61 STA &61c4,Y ; gate_table + 1 &1d8c a9 01 LDA #&01 # Prevent player touching gate again &1d8e 85 0d STA &0d ; gate_screen_address_low ; not_opening_gate ; check_for_player_collecting_core_element &1d90 a5 76 LDA &76 ; player_on_hopper &1d92 f0 12 BEQ &1da6 ; not_collecting_core_element &1d94 a5 80 LDA &80 ; player_action &1d96 29 04 AND #&04 ; PLAYER_UP # Player must press up &1d98 f0 0c BEQ &1da6 ; not_collecting_core_element &1d9a a5 81 LDA &81 ; previous_player_action &1d9c 29 04 AND #&04 ; PLAYER_UP &1d9e d0 06 BNE &1da6 ; not_collecting_core_element &1da0 a5 80 LDA &80 ; player_action &1da2 29 03 AND #&03 ; PLAYER_LEFT | PLAYER_RIGHT # without left or right to collect core element &1da4 f0 03 BEQ &1da9 ; player_is_trying_to_collect_core_element ; not_collecting_core_element &1da6 4c 5d 1e JMP &1e5d ; skip_collecting_core_element ; player_is_trying_to_collect_core_element &1da9 a2 11 LDX #&11 &1dab a0 25 LDY #&25 ; &2511 = collecting_sound &1dad 20 3d 35 JSR &353d ; play_sound &1db0 a9 00 LDA #&00 # For each core element, &1db2 85 8d STA &8d ; core_element_to_consider ; consider_core_elements_loop &1db4 a6 8d LDX &8d ; core_element_to_consider &1db6 bd 28 05 LDA &0528,X ; core_elements_data + 0 # room_low of core element &1db9 c5 7e CMP &7e ; player_room_low &1dbb d0 4e BNE &1e0b ; consider_next_core_element # is it in the same room as the player? &1dbd bd 29 05 LDA &0529,X ; core_elements_data + 1 &1dc0 29 03 AND #&03 # room_high of core element &1dc2 c5 7f CMP &7f ; player_room_high &1dc4 d0 45 BNE &1e0b ; consider_next_core_element &1dc6 bd 29 05 LDA &0529,X ; core_elements_data + 1 &1dc9 29 f8 AND #&f8 # screen_address_low of core element &1dcb 38 SEC &1dcc e9 18 SBC #&18 &1dce 90 04 BCC &1dd4 ; skip_checking_left_edge &1dd0 c5 70 CMP &70 ; player_screen_address_low &1dd2 b0 37 BCS &1e0b ; consider_next_core_element # Is the player overlapping it horizontally? ; skip_checking_left_edge &1dd4 69 20 ADC #&20 &1dd6 b0 04 BCS &1ddc ; skip_checking_right_edge &1dd8 c5 70 CMP &70 ; player_screen_address_low &1dda 90 2f BCC &1e0b ; consider_next_core_element ; skip_checking_right_edge &1ddc bd 2a 05 LDA &052a,X ; core_elements_data + 2 # screen_address_high of core element &1ddf e9 02 SBC #&02 &1de1 c5 71 CMP &71 ; player_screen_address_high &1de3 b0 26 BCS &1e0b ; consider_next_core_element # Is the player overlapping it vertically? &1de5 69 03 ADC #&03 &1de7 c5 71 CMP &71 ; player_screen_address_high &1de9 90 20 BCC &1e0b ; consider_next_core_element ; player_is_collecting_core_element &1deb bd 29 05 LDA &0529,X ; core_elements_data + 1 &1dee 29 f8 AND #&f8 &1df0 85 8e STA &8e ; screen_address_low &1df2 a9 03 LDA #&03 # Set room_high to &3 &1df4 9d 29 05 STA &0529,X ; core_elements_data + 1 # to indicate core element is no longer in room &1df7 bd 2a 05 LDA &052a,X ; core_elements_data + 2 &1dfa 85 8f STA &8f ; screen_address_high &1dfc bd 2b 05 LDA &052b,X ; core_elements_data + 3 &1dff 85 86 STA &86 ; core_element_collected &1e01 a2 ff LDX #&ff # White &1e03 a0 ff LDY #&ff # EOR &1e05 20 b3 0b JSR &0bb3 ; plot_packed_two_colour_sprite # Unplot core element &1e08 4c 1a 1e JMP &1e1a ; consider_dropping_core_element ; consider_next_core_element &1e0b 18 CLC &1e0c a5 8d LDA &8d ; core_element_to_consider &1e0e 69 04 ADC #&04 &1e10 85 8d STA &8d ; core_element_to_consider &1e12 c9 50 CMP #&50 &1e14 d0 9e BNE &1db4 ; consider_core_elements_loop &1e16 a9 00 LDA #&00 &1e18 85 86 STA &86 ; core_element_collected ; consider_dropping_core_element &1e1a a5 12 LDA &12 ; pockets + 4 &1e1c f0 30 BEQ &1e4e ; not_dropping_core_element # Is the player dropping a core element &1e1e a0 fc LDY #&fc ; find_empty_slot &1e20 c8 INY &1e21 c8 INY &1e22 c8 INY &1e23 c8 INY &1e24 b9 29 05 LDA &0529,Y ; core_elements_data + 1 &1e27 29 02 AND #&02 # room_high of core element, &2 set if slot empty &1e29 f0 f5 BEQ &1e20 ; find_empty_slot &1e2b a5 7e LDA &7e ; player_room_low # Put core element in slot &1e2d 99 28 05 STA &0528,Y ; core_elements_data + 0 # room_low of core_element &1e30 a5 70 LDA &70 ; player_screen_address_low &1e32 29 f8 AND #&f8 &1e34 85 8e STA &8e ; screen_address_low &1e36 05 7f ORA &7f ; player_room_high &1e38 99 29 05 STA &0529,Y ; core_elements_data + 1 # room_high | screen_address_low of core element &1e3b a5 71 LDA &71 ; player_screen_address_high &1e3d 99 2a 05 STA &052a,Y ; core_elements_data + 2 # screen_address_high of core element &1e40 85 8f STA &8f ; screen_address_high &1e42 a5 12 LDA &12 ; pockets + 4 &1e44 99 2b 05 STA &052b,Y ; core_elements_data + 3 # sprite of core element &1e47 a2 ff LDX #&ff # White &1e49 a0 ff LDY #&ff # EOR &1e4b 20 b3 0b JSR &0bb3 ; plot_packed_two_colour_sprite # Plot core element ; not_dropping_core_element &1e4e a0 02 LDY #&02 ; rotate_pockets_loop &1e50 b9 0f 00 LDA &000f,Y ; pockets &1e53 99 10 00 STA &0010,Y ; pockets + 1 &1e56 88 DEY &1e57 10 f7 BPL &1e50 ; rotate_pockets_loop &1e59 a5 86 LDA &86 ; core_element_collected &1e5b 85 0f STA &0f ; pockets ; skip_collecting_core_element &1e5d a5 71 LDA &71 ; player_screen_address_high &1e5f c5 af CMP &af ; space_lock_entrance_screen_address_high + 2 &1e61 d0 6e BNE &1ed1 ; not_space_lock # Is the player vertically aligned with space locks? &1e63 a5 72 LDA &72 ; player_sprite &1e65 29 03 AND #&03 &1e67 d0 68 BNE &1ed1 ; not_space_lock # Is the player aligned within the subtile? &1e69 a5 70 LDA &70 ; player_screen_address_low &1e6b a0 02 LDY #&02 # Right space lock &1e6d a2 09 LDX #&09 ; new_player_sprite &1e6f c5 ac CMP &ac ; space_lock_entrance_screen_address_low # Is the player entering the left space lock? &1e71 f0 12 BEQ &1e85 ; consider_entering_space_lock &1e73 a0 00 LDY #&00 # Left space lock &1e75 a2 03 LDX #&03 ; new_player_sprite &1e77 c5 ae CMP &ae ; space_lock_entrance_screen_address_low + 2 &1e79 d0 56 BNE &1ed1 ; not_space_lock # Is the player entering the right space lock? &1e7b a5 7f LDA &7f ; player_room_high &1e7d f0 06 BEQ &1e85 ; consider_entering_space_lock &1e7f a5 7e LDA &7e ; player_room_low &1e81 c9 6a CMP #&6a # The space lock in room &16a doesn't work &1e83 f0 4c BEQ &1ed1 ; not_space_lock # (it's part of a passage) ; consider_entering_space_lock &1e85 84 86 STY &86 ; destination_space_lock &1e87 a0 04 LDY #&04 ; check_for_pass_key_loop &1e89 88 DEY &1e8a 30 45 BMI &1ed1 ; not_space_lock # Can't enter space lock without pass &1e8c b9 0f 00 LDA &000f,Y ; pockets &1e8f c9 09 CMP #&09 ; ITEM_PASS &1e91 d0 f6 BNE &1e89 ; check_for_pass_loop &1e93 8a TXA &1e94 48 PHA ; new_player_sprite &1e95 a5 72 LDA &72 ; player_sprite &1e97 20 d9 20 JSR &20d9 ; replot_player # Unplot player &1e9a a2 50 LDX #&50 &1e9c a0 23 LDY #&23 ; &2350 = entering_space_lock_sound &1e9e 20 2b 35 JSR &352b ; play_sound_using_envelope &1ea1 68 PLA ; new_player_sprite &1ea2 aa TAX &1ea3 a4 86 LDY &86 ; destination_space_lock &1ea5 b9 ac 00 LDA &00ac,Y ; space_lock_entrance_screen_address_low # Move player to other space lock &1ea8 85 70 STA &70 ; player_screen_address_low &1eaa 86 72 STX &72 ; player_sprite &1eac e0 03 CPX #&03 # Is this the left space lock? &1eae d0 05 BNE &1eb5 ; skip_adjustment &1eb0 38 SEC &1eb1 e9 08 SBC #&08 # IF so, move player left four pixels &1eb3 85 70 STA &70 ; player_screen_address_low ; skip_adjustment &1eb5 a9 06 LDA #&06 &1eb7 85 8b STA &8b ; count ; flash_background_loop &1eb9 a9 03 LDA #&03 &1ebb 20 42 35 JSR &3542 ; wait_for_a_frames &1ebe a5 91 LDA &91 ; palette + 1 &1ec0 49 07 EOR #&07 # Flash colour 0 of bottom section white and black &1ec2 85 91 STA &91 ; palette + 1 &1ec4 20 00 7f JSR &7f00 ; to_set_screen_colours &1ec7 c6 8b DEC &8b ; count &1ec9 d0 ee BNE &1eb9 ; flash_background_loop &1ecb 20 24 35 JSR &3524 ; flush_buffers &1ece 20 d9 20 JSR &20d9 ; replot_player # Replot player ; not_space_lock ; check_for_player_touching_bad_subtiles &1ed1 20 54 25 JSR &2554 ; calculate_below_player_subtile_address &1ed4 a0 40 LDY #&40 # Check three subtiles vertically &1ed6 38 SEC &1ed7 a5 74 LDA &74 ; below_player_subtile_address_low &1ed9 e9 40 SBC #&40 # Move up two subtiles &1edb 85 8c STA &8c ; subtile_address_low &1edd a5 75 LDA &75 ; below_player_subtile_address_high &1edf e9 00 SBC #&00 &1ee1 85 8d STA &8d ; subtile_address_high &1ee3 a5 70 LDA &70 ; player_screen_address_low &1ee5 29 07 AND #&07 &1ee7 d0 02 BNE &1eeb ; not_group # If player isn't straddling group, &1ee9 a0 20 LDY #&20 # only check two subtiles vertically ; not_group &1eeb a2 01 LDX #&01 # Check two subtiles horizontally &1eed a5 72 LDA &72 ; player_sprite &1eef 29 03 AND #&03 &1ef1 f0 01 BEQ &1ef4 ; not_wide &1ef3 e8 INX # Check three subtiles horizontally ; not_wide &1ef4 86 8e STX &8e ; width ; check_for_player_touching_bad_subtiles_column_loop &1ef6 98 TYA &1ef7 29 60 AND #&60 &1ef9 05 8e ORA &8e ; width &1efb a8 TAY ; check_for_player_touching_bad_subtiles_row_loop &1efc b1 8c LDA (&8c),Y ; subtile_address &1efe 29 40 AND #&40 ; SUBTILE_DEADLY &1f00 f0 04 BEQ &1f06 ; nothing_deadly_in_subtile &1f02 a9 01 LDA #&01 ; TOUCHING_SPIKE &1f04 85 20 STA &20 ; player_touching_death ; nothing_deadly_in_subtile &1f06 88 DEY &1f07 98 TYA &1f08 29 18 AND #&18 &1f0a f0 f0 BEQ &1efc ; check_for_player_touching_bad_subtiles_row_loop &1f0c c0 ff CPY #&ff &1f0e d0 e6 BNE &1ef6 ; check_for_player_touching_bad_subtiles_column_loop &1f10 a5 20 LDA &20 ; player_touching_death &1f12 d0 0e BNE &1f22 ; player_is_touching_death # Has the played touched something deadly? &1f14 a5 3b LDA &3b ; player_energy_high &1f16 f0 03 BEQ &1f1b ; player_is_out_of_energy # If not, is the player out of energy? &1f18 4c da 1f JMP &1fda ; player_hasn't_died ; player_is_out_of_energy &1f1b a9 01 LDA #&01 # Unplot enemies, don't update &1f1d 20 b6 2e JSR &2eb6 ; update_enemies &1f20 a9 0c LDA #&0c ; player_is_touching_death &1f22 48 PHA &1f23 20 24 35 JSR &3524 ; flush_buffers &1f26 20 17 0f JSR &0f17 ; play_error_sound &1f29 68 PLA &1f2a 0a ASL A &1f2b 0a ASL A &1f2c 85 86 STA &86 ; count &1f2e a9 01 LDA #&01 # Remove fire &1f30 85 7b STA &7b ; fire_hit_something &1f32 20 0f 22 JSR &220f ; update_fire # Unplot fire ; flash_dying_player_loop &1f35 a9 13 LDA #&13 ; Wait for v-sync &1f37 20 f4 ff JSR &fff4 ; OSBYTE &1f3a 20 d9 20 JSR &20d9 ; replot_player &1f3d c6 86 DEC &86 ; count &1f3f 10 f4 BPL &1f35 ; flash_dying_player_loop &1f41 a5 20 LDA &20 ; player_touching_death &1f43 48 PHA &1f44 f0 26 BEQ &1f6c ; skip_moving_droid # Keep enemies on screen if player is out of energy &1f46 48 PHA &1f47 a9 01 LDA #&01 # Unplot enemies, don't update &1f49 20 b6 2e JSR &2eb6 ; update_enemies &1f4c 68 PLA &1f4d c9 02 CMP #&02 ; TOUCHING_DROID &1f4f f0 04 BEQ &1f55 ; move_droid_to_player # Was the player killed by a droid? &1f51 c9 03 CMP #&03 ; TOUCHING_NON_PATROLLING_DROID &1f53 d0 17 BNE &1f6c ; skip_moving_droid ; move_droid_to_player &1f55 a5 70 LDA &70 ; player_screen_address_low &1f57 85 8e STA &8e ; screen_address_low &1f59 a5 71 LDA &71 ; player_screen_address_high &1f5b 85 8f STA &8f ; screen_address_high &1f5d a9 00 LDA #&00 &1f5f 85 8c STA &8c ; sprite_address_low &1f61 a9 3c LDA #&3c ; &3c00 = enemy_type_three_frame_1 &1f63 85 8d STA &8d ; sprite_address_high &1f65 a2 03 LDX #&03 &1f67 a0 02 LDY #&02 &1f69 20 26 65 JSR &6526 ; plot_unaligned_sprite # If so, replot that droid at player's location ; skip_moving_droid &1f6c a5 70 LDA &70 ; player_screen_address_low &1f6e 29 f8 AND #&f8 &1f70 8d 40 23 STA &2340 ; player_dematerialisation_data # Set enemies_screen_address_low &1f73 a5 71 LDA &71 ; player_screen_address_high &1f75 8d 41 23 STA &2341 ; player_dematerialisation_data + 1 # Set enemies_screen_address_high &1f78 a9 00 LDA #&00 &1f7a 85 8e STA &8e ; enemy_offset ; add_player_dematerialisations_loop &1f7c 20 40 64 JSR &6440 ; rnd &1f7f 29 03 AND #&03 &1f81 a8 TAY &1f82 b9 4c 23 LDA &234c,Y ; random_directions_for_player_dematerialisations &1f85 8d 43 23 STA &2343 ; player_dematerialisation_data + 3 # Set enemies_direction &1f88 20 40 64 JSR &6440 ; rnd &1f8b 29 07 AND #&07 &1f8d 18 CLC &1f8e 69 04 ADC #&04 &1f90 8d 44 23 STA &2344 ; player_dematerialisation_data + 4 # Set enemies_inertia &1f93 a4 8e LDY &8e ; enemy_offset &1f95 a2 00 LDX #&00 ; copy_player_dematerialisation_data_loop &1f97 bd 40 23 LDA &2340,X ; player_dematerialisation_data &1f9a 99 88 01 STA &0188,Y ; enemies_data &1f9d c8 INY &1f9e e8 INX &1f9f e0 0c CPX #&0c &1fa1 d0 f4 BNE &1f97 ; copy_player_dematerialisation_data_loop &1fa3 84 8e STY &8e ; enemy_offset &1fa5 c0 30 CPY #&30 &1fa7 d0 d3 BNE &1f7c ; add_player_dematerialisations_loop &1fa9 a9 01 LDA #&01 # Plot player dematerialisations, don't update &1fab 20 b6 2e JSR &2eb6 ; update_enemies &1fae 20 24 35 JSR &3524 ; flush_buffers &1fb1 a2 43 LDX #&43 &1fb3 a0 04 LDY #&04 ; &0443 = player_exploding_sound &1fb5 20 2b 35 JSR &352b ; play_sound_using_envelope &1fb8 a9 78 LDA #&78 &1fba 85 69 STA &69 ; count ; update_player_dematerialisations_loop &1fbc a9 13 LDA #&13 ; Wait for v-sync &1fbe 20 f4 ff JSR &fff4 ; OSBYTE &1fc1 a9 00 LDA #&00 # Update and replot player dematerialisations &1fc3 20 b6 2e JSR &2eb6 ; update_enemies &1fc6 20 45 20 JSR &2045 ; update_scenery &1fc9 c6 69 DEC &69 ; count &1fcb d0 ef BNE &1fbc ; update_player_dematerialisations_loop &1fcd 68 PLA ; player_touching_death &1fce f0 04 BEQ &1fd4 ; store_position # If the player ran out of energy, &1fd0 c9 03 CMP #&03 ; TOUCHING_PATROLLING_DROID &1fd2 90 03 BCC &1fd7 ; to_start_new_life # touched a spark or a patrolling droid, ; store_position &1fd4 20 60 25 JSR &2560 ; store_player_entry_position # then store their position ; to_start_new_life &1fd7 4c ef 12 JMP &12ef ; start_new_life ; player_hasn't_died &1fda a2 9f LDX #&9f ; TAB &1fdc 20 94 20 JSR &2094 ; check_for_keypress &1fdf d0 1a BNE &1ffb ; pause_not_pressed &1fe1 20 24 35 JSR &3524 ; flush_buffers &1fe4 20 e0 ff JSR &ffe0 ; OSRDCH &1fe7 29 5f AND #&5f # Convert to uppercase &1fe9 a2 00 LDX #&00 &1feb c9 53 CMP #&53 ; "S" &1fed f0 05 BEQ &1ff4 ; set_sound &1fef e8 INX &1ff0 c9 51 CMP #&51 ; "Q" &1ff2 d0 07 BNE &1ffb ; q_not_pressed ; set_sound &1ff4 a0 00 LDY #&00 &1ff6 a9 d2 LDA #&d2 ; Read/Write sound suppression flag &1ff8 20 f4 ff JSR &fff4 ; OSBYTE ; q_not_pressed ; pause_not_pressed &1ffb a0 00 LDY #&00 ; sort_enemies_by_screen_address_loop &1ffd 84 8f STY &8f ; enemy_offset &1fff a6 8f LDX &8f ; enemy_offset ; sort_enemies_by_screen_address_check_loop &2001 bd 89 01 LDA &0189,X ; enemies_screen_address_high &2004 d9 89 01 CMP &0189,Y ; enemies_screen_address_high &2007 b0 02 BCS &200b ; not_lower &2009 86 8f STX &8f ; enemy_offset ; not_lower &200b 18 CLC &200c 8a TXA &200d 69 0c ADC #&0c &200f aa TAX &2010 e0 30 CPX #&30 &2012 30 ed BMI &2001 ; sort_enemies_by_screen_address_check_loop &2014 a9 0c LDA #&0c &2016 85 8c STA &8c ; size &2018 a6 8f LDX &8f ; enemy_offset ; swap_enemy_data_loop &201a bd 88 01 LDA &0188,X ; enemies_screen_address_low &201d 48 PHA &201e b9 88 01 LDA &0188,Y ; enemies_screen_address_low &2021 9d 88 01 STA &0188,X ; enemies_screen_address_low &2024 68 PLA &2025 99 88 01 STA &0188,Y ; enemies_screen_address_low &2028 c8 INY &2029 e8 INX &202a c6 8c DEC &8c ; size &202c d0 ec BNE &201a ; swap_enemy_data_loop &202e c0 24 CPY #&24 &2030 90 cb BCC &1ffd ; sort_enemies_by_screen_address_loop &2032 a2 fe LDX #&fe ; CTRL &2034 20 94 20 JSR &2094 ; check_for_keypress &2037 d0 07 BNE &2040 ; to_main_game_loop &2039 a2 8f LDX #&8f ; ESCAPE &203b 20 94 20 JSR &2094 ; check_for_keypress &203e f0 03 BEQ &2043 ; escape_pressed ; to_main_game_loop &2040 4c 03 16 JMP &1603 ; main_game_loop ; escape_pressed &2043 18 CLC # Leave with carry clear to indicate game not completed &2044 60 RTS ; update_scenery &2045 20 49 21 JSR &2149 ; update_bridging_platforms &2048 20 61 64 JSR &6461 ; update_sparks &204b 4c ad 62 JMP &62ad ; update_pipe_arrows ; check_if_player_can_fall &204e a0 02 LDY #&02 # Player is three subtiles wide &2050 a5 72 LDA &72 ; player_sprite &2052 29 03 AND #&03 &2054 d0 01 BNE &2057 ; player_not_straddling_subtiles &2056 88 DEY # or two subtiles wide ; player_not_straddling_subtiles ; check_if_player_can_fall_loop &2057 b1 74 LDA (&74),Y ; below_player_subtile_address &2059 29 0c AND #&0c ; SUBTILE_NO_PLAYER | SUBTILE_PIPE &205b d0 03 BNE &2060 ; leave # Leave with negative unset if obstacle &205d 88 DEY &205e 10 f7 BPL &2057 ; check_if_player_can_fall_loop # Leave with negative set if no obstacle ; leave &2060 60 RTS ; move_player_down &2061 85 8e STA &8e ; distance &2063 a5 70 LDA &70 ; player_screen_address_low &2065 29 07 AND #&07 &2067 18 CLC &2068 65 8e ADC &8e ; distance &206a 29 08 AND #&08 &206c f0 1a BEQ &2088 ; same_subtile &206e 18 CLC &206f a5 74 LDA &74 ; below_player_subtile_address_low &2071 69 20 ADC #&20 # Move down a subtile &2073 85 74 STA &74 ; below_player_subtile_address_low &2075 a5 75 LDA &75 ; below_player_subtile_address_high &2077 69 00 ADC #&00 &2079 85 75 STA &75 ; below_player_subtile_address_high &207b 18 CLC &207c a5 70 LDA &70 ; player_screen_address_low &207e 69 f8 ADC #&f8 &2080 85 70 STA &70 ; player_screen_address_low &2082 a5 71 LDA &71 ; player_screen_address_high &2084 69 00 ADC #&00 &2086 85 71 STA &71 ; player_screen_address_high ; same_subtile &2088 18 CLC &2089 a5 70 LDA &70 ; player_screen_address_low &208b 65 8e ADC &8e ; distance &208d 85 70 STA &70 ; player_screen_address_low &208f 90 02 BCC &2093 ; leave &2091 e6 71 INC &71 ; player_screen_address_high ; leave &2093 60 RTS ; check_for_keypress &2094 a9 81 LDA #&81 ; Scan for a particular key &2096 a0 ff LDY #&ff &2098 20 f4 ff JSR &fff4 ; OSBYTE &209b e0 ff CPX #&ff # Leave with equal if key pressed &209d 60 RTS ; core_element_flash_colours &209e 00 ff ; KK WW ; wipe_subtiles &20a0 a0 00 LDY #&00 ; wipe_subtiles_loop # Wipe &0580 - &07ff &20a2 a9 00 LDA #&00 &20a4 99 80 05 STA &0580,Y &20a7 99 00 06 STA &0600,Y &20aa 99 00 07 STA &0700,Y &20ad c8 INY &20ae d0 f2 BNE &20a2 ; wipe_subtiles_loop &20b0 60 RTS ; falling_speeds &20b1 01 00 01 00 01 02 01 02 01 02 02 03 02 03 03 04 &20c1 04 ; find_bridging_platform_slot &20c2 b9 01 04 LDA &0401,Y ; bridging_platform_data + 1 &20c5 f0 09 BEQ &20d0 ; leave &20c7 c8 INY &20c8 c8 INY &20c9 98 TYA &20ca 29 1f AND #&1f &20cc d0 f4 BNE &20c2 ; find_bridging_platform_slot &20ce a9 01 LDA #&01 ; leave &20d0 60 RTS ; player_walking_sound ; chan vol pitch dur &20d1 10 00 f9 00 03 00 01 00 ; replot_player &20d9 a6 70 LDX &70 ; player_screen_address_low &20db 86 8e STX &8e ; screen_address_low &20dd a6 71 LDX &71 ; player_screen_address_high &20df 86 8f STX &8f ; screen_address_high &20e1 a5 72 LDA &72 ; player_sprite &20e3 0a ASL A &20e4 85 8c STA &8c ; sprite_address_low &20e6 4a LSR A &20e7 65 8c ADC &8c ; sprite_address_low &20e9 69 08 ADC #&08 &20eb 85 8c STA &8c ; sprite_address_low &20ed a9 00 LDA #&00 &20ef 85 8d STA &8d ; sprite_address_high &20f1 a2 04 LDX #&04 ; multiply_loop &20f3 06 8c ASL &8c ; sprite_address_low &20f5 26 8d ROL &8d ; sprite_address_high &20f7 ca DEX &20f8 d0 f9 BNE &20f3 ; multiply_loop &20fa a5 8d LDA &8d ; sprite_address_high &20fc 69 3d ADC #&3d ; &3d00 = player_sprites - &80 &20fe 85 8d STA &8d ; sprite_address_high &2100 a2 03 LDX #&03 # 12 pixels wide &2102 a0 02 LDY #&02 # 8 pixels high &2104 20 00 63 JSR &6300 ; plot_player &2107 a5 76 LDA &76 ; player_on_hopper &2109 d0 c5 BNE &20d0 ; leave &210b a5 70 LDA &70 ; player_screen_address_low &210d 29 07 AND #&07 &210f 05 98 ORA &98 ; player_group_address_low &2111 85 8e STA &8e ; screen_address_low &2113 18 CLC &2114 a5 71 LDA &71 ; player_screen_address_high &2116 69 02 ADC #&02 &2118 85 8f STA &8f ; screen_address_high &211a a5 99 LDA &99 ; hopper_sprite &211c aa TAX &211d 0a ASL A &211e 85 8c STA &8c ; sprite_address_low &2120 18 CLC &2121 8a TXA &2122 65 8c ADC &8c ; sprite_address_low &2124 85 8c STA &8c ; sprite_address_low &2126 a9 00 LDA #&00 &2128 85 8d STA &8d ; sprite_address_high &212a 06 8c ASL &8c ; sprite_address_low &212c 26 8d ROL &8d ; sprite_address_high &212e 06 8c ASL &8c ; sprite_address_low &2130 26 8d ROL &8d ; sprite_address_high &2132 06 8c ASL &8c ; sprite_address_low &2134 26 8d ROL &8d ; sprite_address_high &2136 a5 8c LDA &8c ; sprite_address_low &2138 69 20 ADC #&20 &213a 85 8c STA &8c ; sprite_address_low &213c a5 8d LDA &8d ; sprite_address_high &213e 69 41 ADC #&41 ; &4120 = hopper_sprites &2140 85 8d STA &8d ; sprite_address_high &2142 a2 03 LDX #&03 # 12 pixels wide &2144 a0 01 LDY #&01 # 8 pixels high &2146 4c 26 65 JMP &6526 ; plot_unaligned_sprite # Plot hopper ; update_bridging_platforms &2149 a9 00 LDA #&00 &214b 85 87 STA &87 ; bridging_platform_to_consider ; update_bridging_platforms_loop &214d a4 87 LDY &87 ; bridging_platform_to_consider &214f b9 00 04 LDA &0400,Y ; bridging_platform_data &2152 85 85 STA &85 ; platform_subtile_address_low &2154 b9 01 04 LDA &0401,Y ; bridging_platform_data + 1 &2157 85 86 STA &86 ; platform_subtile_address_high_and_ttl &2159 29 fc AND #&fc # Top six bits are time to live &215b f0 4c BEQ &21a9 ; consider_next_bridging_platform # Zero if there is no platform in this slot &215d 38 SEC &215e a5 86 LDA &86 ; platform_subtile_address_high_and_ttl &2160 e9 04 SBC #&04 # Reduce time to live by one &2162 85 86 STA &86 ; platform_subtile_address_high_and_ttl &2164 29 1c AND #&1c &2166 c9 1c CMP #&1c &2168 d0 33 BNE &219d ; skip_replotting_platform # Replot platform every eight frames &216a a5 86 LDA &86 ; platform_subtile_address_high_and_ttl &216c 29 e0 AND #&e0 &216e 4a LSR A &216f 09 80 ORA #&80 &2171 85 8c STA &8c ; sprite_address_low &2173 a9 40 LDA #&40 ; &4080 = bridging_platform_sprites &2175 85 8d STA &8d ; sprite_address_high &2177 20 b4 21 JSR &21b4 ; plot_bridging_platform # Single plot, EORs successively &217a a5 86 LDA &86 ; platform_subtile_address_high_and_ttl &217c 29 fc AND #&fc &217e c9 1c CMP #&1c &2180 d0 1b BNE &219d ; platform_still_exists # Has the platform reached its end of life? &2182 a5 86 LDA &86 ; platform_subtile_address_high_and_ttl &2184 29 03 AND #&03 &2186 09 04 ORA #&04 &2188 85 86 STA &86 ; platform_subtile_address_high &218a a0 01 LDY #&01 &218c b1 85 LDA (&85),Y ; platform_subtile_address &218e 29 f7 AND #&f7 ; !SUBTILE_NO_PLAYER # Allow player to fall through empty subtiles &2190 91 85 STA (&85),Y ; platform_subtile_address &2192 88 DEY &2193 b1 85 LDA (&85),Y ; platform_subtile_address &2195 29 f7 AND #&f7 ; !SUBTILE_NO_PLAYER &2197 91 85 STA (&85),Y ; platform_subtile_address &2199 84 85 STY &85 ; platform_subtile_address_low # Wipe platform data &219b 84 86 STY &86 ; platform_subtile_address_high_and_ttl ; platform_still_exists ; skip_replotting_platform &219d a4 87 LDY &87 ; bridging_platform_to_consider &219f a5 85 LDA &85 ; platform_subtile_address_low &21a1 99 00 04 STA &0400,Y; bridging_platform_data &21a4 a5 86 LDA &86 ; platform_subtile_address_high_and_ttl &21a6 99 01 04 STA &0401,Y ; bridging_platform_data + 1 ; consider_next_bridging_platform &21a9 e6 87 INC &87 ; bridging_platform_to_consider &21ab e6 87 INC &87 ; bridging_platform_to_consider &21ad a5 87 LDA &87 ; bridging_platform_to_consider &21af c9 20 CMP #&20 &21b1 30 9a BMI &214d ; update_bridging_platforms_loop &21b3 60 RTS ; plot_bridging_platform &21b4 a5 85 LDA &85 ; platform_subtile_address_low &21b6 85 8e STA &8e ; screen_address_low &21b8 a5 86 LDA &86 ; platform_subtile_address_high_and_ttl &21ba 29 03 AND #&03 &21bc 85 8f STA &8f ; screen_address_high &21be 06 8e ASL &8e ; screen_address_low &21c0 26 8f ROL &8f ; screen_address_high &21c2 06 8e ASL &8e ; screen_address_low &21c4 26 8f ROL &8f ; screen_address_high &21c6 06 8e ASL &8e ; screen_address_low &21c8 26 8f ROL &8f ; screen_address_high &21ca a5 8f LDA &8f ; screen_address_high &21cc 09 60 ORA #&60 &21ce 85 8f STA &8f ; screen_address_high &21d0 4c d4 65 JMP &65d4 ; plot_single_character_sprite ; plot_fire &21d3 a5 78 LDA &78 ; fire_type &21d5 f0 17 BEQ &21ee ; player_not_on_platform &21d7 a9 3c LDA #&3c ; &3cc0 = player_materialising_frame_1 &21d9 85 8d STA &8d ; sprite_address_high &21db a5 8e LDA &8e ; screen_address_low &21dd 29 10 AND #&10 &21df 49 10 EOR #&10 &21e1 85 8c STA &8c ; sprite_address_low &21e3 0a ASL A &21e4 65 8c ADC &8c ; sprite_address_low &21e6 69 c0 ADC #&c0 &21e8 90 0c BCC &21f6 ; set_fire_sprite_address &21ea e6 8d INC &8d ; sprite_address_high &21ec d0 08 BNE &21f6 ; set_fire_sprite_address ; player_not_on_platform &21ee a9 41 LDA #&41 ; &4100 = fire_sprites &21f0 85 8d STA &8d ; sprite_address_high &21f2 a5 8e LDA &8e ; screen_address_low &21f4 29 10 AND #&10 ; set_fire_sprite_address &21f6 85 8c STA &8c ; sprite_address_low &21f8 a5 8f LDA &8f ; screen_address_high &21fa 29 1f AND #&1f &21fc 09 60 ORA #&60 &21fe 85 8f STA &8f ; screen_address_high &2200 a5 8e LDA &8e ; screen_address_low &2202 29 f8 AND #&f8 &2204 85 8e STA &8e ; screen_address_low &2206 a6 78 LDX &78 ; fire_type &2208 e8 INX &2209 8a TXA &220a a8 TAY &220b e8 INX &220c 4c ad 65 JMP &65ad ; plot_aligned_sprite_using_eor ; update_fire &220f a5 7d LDA &7d ; fire_screen_address_high &2211 30 0b BMI &221e ; skip_unplot # Top bit set indicates fire not plotted &2213 f0 19 BEQ &222e ; leave # Zero if no fire &2215 85 8f STA &8f ; screen_address_high &2217 a5 7c LDA &7c ; fire_screen_address_low &2219 85 8e STA &8e ; screen_address_low &221b 20 d3 21 JSR &21d3 ; plot_fire # unplot fire ; skip_unplot &221e a5 7d LDA &7d ; fire_screen_address_high &2220 29 7f AND #&7f # Clear top bit to indicate fire needs unplotting &2222 85 7d STA &7d ; fire_screen_address_high &2224 a5 7b LDA &7b ; fire_hit_something &2226 f0 07 BEQ &222f ; move_fire &2228 a9 00 LDA #&00 # Set to zero to indicate no fire &222a 85 7d STA &7d ; fire_screen_address_high &222c 85 7b STA &7b ; fire_hit_something ; leave &222e 60 RTS ; move_fire &222f a5 7a LDA &7a ; fire_direction &2231 29 01 AND #&01 ; FIRE_LEFT &2233 f0 09 BEQ &223e ; fire_not_moving_left &2235 38 SEC &2236 a5 7c LDA &7c ; fire_screen_address_low &2238 e9 08 SBC #&08 # Move left four pixels &223a 85 7c STA &7c ; fire_screen_address_low &223c 90 75 BCC &22b3 ; fire_hit_left_or_right_edge_of_screen ; fire_not_moving_left &223e a5 7a LDA &7a ; fire_direction &2240 29 02 AND #&02 ; FIRE_RIGHT &2242 f0 0b BEQ &224f ; fire_not_moving_right &2244 18 CLC &2245 a5 7c LDA &7c ; fire_screen_address_low &2247 69 08 ADC #&08 # Move right four pixels &2249 85 7c STA &7c ; fire_screen_address_low &224b c9 f8 CMP #&f8 &224d b0 64 BCS &22b3 ; fire_hit_left_or_right_edge_of_screen ; fire_not_moving_right &224f a5 7a LDA &7a ; fire_direction &2251 29 04 AND #&04 ; FIRE_UP &2253 f0 08 BEQ &225d ; fire_not_moving_up &2255 c6 7d DEC &7d ; fire_screen_address_high # Move up eight pixels &2257 a5 7d LDA &7d ; fire_screen_address_high &2259 c9 6d CMP #&6d &225b 90 5d BCC &22ba ; fire_hit_top_or_bottom_edge_of_screen ; fire_not_moving_up &225d a5 7a LDA &7a ; fire_direction &225f 29 08 AND #&08 ; FIRE_DOWN &2261 f0 08 BEQ &226b ; fire_not_moving_down &2263 e6 7d INC &7d ; fire_screen_address_high # Move down eight pixels &2265 a5 7d LDA &7d ; fire_screen_address_high &2267 c9 7e CMP #&7e &2269 b0 4f BCS &22ba ; fire_hit_top_or_bottom_edge_of_screen ; fire_not_moving_down &226b a6 7c LDX &7c ; fire_screen_address_low &226d a4 7d LDY &7d ; fire_screen_address_high &226f 20 e0 65 JSR &65e0 ; calculate_subtile_address_from_screen_address &2272 a2 00 LDX #&00 &2274 86 8e STX &8e ; fire_bounced ; check_for_obstacles_column_loop &2276 a0 00 LDY #&00 ; check_for_obstacles_row_loop &2278 b1 6b LDA (&6b),Y ; subtile_address &227a 29 08 AND #&08 ; SUBTILE_NO_PLAYER &227c 9d fe 22 STA &22fe,X ; fire_bounce_subtile_values &227f f0 02 BEQ &2283 ; no_bounce &2281 85 8e STA &8e ; fire_bounced ; no_bounce &2283 c8 INY # Move right one subtile &2284 e8 INX &2285 c0 02 CPY #&02 &2287 d0 ef BNE &2278 ; check_for_obstacles_row_loop &2289 18 CLC &228a a5 6b LDA &6b ; subtile_address_low &228c 69 20 ADC #&20 # Move down one subtile &228e 85 6b STA &6b ; subtile_address_low &2290 90 02 BCC &2294 ; skip_overflow &2292 e6 6c INC &6c ; subtile_address_high ; skip_overflow &2294 8a TXA &2295 4a LSR A &2296 e9 00 SBC #&00 &2298 c5 78 CMP &78 ; fire_type # Zero if fired from player, one if fired from hopper &229a 90 da BCC &2276 ; check_for_obstacles_column_loop # Player fire is one subtile high, hopper fire is two &229c a5 8e LDA &8e ; fire_bounced &229e d0 0b BNE &22ab ; bounce_off_wall &22a0 a5 7c LDA &7c ; fire_screen_address_low &22a2 85 8e STA &8e ; screen_address_low &22a4 a5 7d LDA &7d ; fire_screen_address_high &22a6 85 8f STA &8f ; screen_address_high &22a8 4c d3 21 JMP &21d3 ; plot_fire # Plot fire ; bounce_off_wall &22ab ad fe 22 LDA &22fe ; fire_bounce_subtile_values &22ae 4d ff 22 EOR &22ff ; fire_bounce_subtile_values + 1 &22b1 f0 07 BEQ &22ba ; fire_hit_top_or_bottom_edge_of_screen ; fire_hit_left_or_right_edge_of_screen &22b3 a5 7a LDA &7a ; fire_direction &22b5 49 83 EOR #&83 ; FIRE_LEFT | FIRE_RIGHT | FIRE_NO_BOUNCE # Flip direction, allow second bounce &22b7 4c be 22 JMP &22be ; set_direction ; fire_hit_top_or_bottom_edge_of_screen &22ba a5 7a LDA &7a ; fire_direction &22bc 49 8c EOR #&8c ; FIRE_UP | FIRE_DOWN | FIRE_NO_BOUNCE # Flip direction, allow second bounce ; set_direction &22be 85 7a STA &7a ; fire_direction &22c0 29 03 AND #&03 ; FIRE_LEFT | FIRE_RIGHT &22c2 f0 04 BEQ &22c8 ; fire_bouncing_vertically &22c4 49 03 EOR #&03 ; FIRE_LEFT | FIRE_RIGHT &22c6 d0 0f BNE &22d7 ; consider_horizontal_bounce # Always branches ; fire_bouncing_vertically &22c8 20 40 64 JSR &6440 ; rnd &22cb 29 03 AND #&03 ; FIRE_LEFT | FIRE_RIGHT # Add random left or right velocity after bounce &22cd f0 f9 BEQ &22c8 ; fire_moving_vertically &22cf 49 03 EOR #&03 ; FIRE_LEFT | FIRE_RIGHT &22d1 f0 f5 BEQ &22c8 ; fire_moving_vertically &22d3 45 7a EOR &7a ; fire_direction &22d5 85 7a STA &7a ; fire_direction ; consider_horizontal_bounce &22d7 a5 7a LDA &7a ; fire_direction &22d9 29 0c AND #&0c ; FIRE_UP | FIRE_DOWN &22db f0 04 BEQ &22e1 ; fire_moving_horizontally &22dd 49 0c EOR #&0c ; FIRE_UP | FIRE_DOWN &22df d0 0f BNE &22f0 ; remove_fire_if_bounced_twice # Always branches ; fire_bouncing_horizontally &22e1 20 40 64 JSR &6440 ; rnd &22e4 29 0c AND #&0c ; FIRE_UP | FIRE_DOWN # Add random up or down velocity after bounce &22e6 f0 f9 BEQ &22e1 ; fire_bouncing_horizontally &22e8 49 0c EOR #&0c ; FIRE_UP | FIRE_DOWN &22ea f0 f5 BEQ &22e1 ; fire_bouncing_horizontally &22ec 45 7a EOR &7a ; fire_direction &22ee 85 7a STA &7a ; fire_direction ; remove_fire_if_bounced_twice &22f0 a5 7a LDA &7a ; fire_direction # Top bit set if fire has already bounced &22f2 10 03 BPL &22f7 ; remove_fire # Remove fire if bounced already &22f4 4c 2f 22 JMP &222f ; move_fire ; remove_fire &22f7 a9 00 LDA #&00 &22f9 85 7c STA &7c ; fire_screen_address_low &22fb 85 7d STA &7d ; fire_screen_address_high &22fd 60 RTS ; fire_bounce_subtile_values &22fe 00 00 00 00 ; core_room_materialisation_data ; enemy slot 0 &2302 40 ; enemies_screen_address_low &2303 70 ; enemies_screen_address_high &2304 04 ; enemies_type # ENEMY_DEMATERIALISING &2305 06 ; enemies_direction # ENEMY_LEFT | ENEMY_DOWN &2306 04 ; enemies_inertia &2307 78 ; enemies_maximum_homing_cooldown &2308 00 ; enemies_behaviour # BEHAVIOUR_0: keeps moving until obstacle &2309 00 ; enemies_move_cooldown &230a 78 ; enemies_homing_cooldown &230b fa ; enemies_materialisation_timer &230c 00 ; enemies_animation &230d 00 ; enemies_materialising ; enemy slot 1 &230e a0 ; enemies_screen_address_low &230f 70 ; enemies_screen_address_high &2310 04 ; enemies_type # ENEMY_DEMATERIALISING &2311 0c ; enemies_direction # ENEMY_LEFT | ENEMY_UP &2312 04 ; enemies_inertia &2313 78 ; enemies_maximum_homing_cooldown &2314 00 ; enemies_behaviour # BEHAVIOUR_0: keeps moving until obstacle &2315 00 ; enemies_move_cooldown &2316 78 ; enemies_homing_cooldown &2317 fa ; enemies_materialisation_timer &2318 00 ; enemies_animation &2319 00 ; enemies_materialising ; enemy slot 2 &231a 40 ; enemies_screen_address_low &231b 78 ; enemies_screen_address_high &231c 04 ; enemies_type # ENEMY_DEMATERIALISING &231d 03 ; enemies_direction # ENEMY_RIGHT | ENEMY_DOWN &231e 04 ; enemies_inertia &231f 78 ; enemies_maximum_homing_cooldown &2320 00 ; enemies_behaviour # BEHAVIOUR_0: keeps moving until obstacle &2321 00 ; enemies_move_cooldown &2322 78 ; enemies_homing_cooldown &2323 fa ; enemies_materialisation_timer &2324 00 ; enemies_animation &2325 00 ; enemies_materialising ; enemy slot 3 &2326 a0 ; enemies_screen_address_low &2327 78 ; enemies_screen_address_high &2328 04 ; enemies_type # ENEMY_DEMATERIALISING &2329 09 ; enemies_direction # ENEMY_RIGHT | ENEMY_UP &232a 04 ; enemies_inertia &232b 78 ; enemies_maximum_homing_cooldown &232c 00 ; enemies_behaviour # BEHAVIOUR_0: keeps moving until obstacle &232d 00 ; enemies_move_cooldown &232e 78 ; enemies_homing_cooldown &232f fa ; enemies_materialisation_timer &2330 00 ; enemies_animation &2331 00 ; enemies_materialising ; patrolling_droid_data &2332 00 ; enemies_screen_address_low &2333 7a ; enemies_screen_address_high &2334 03 ; enemies_type # ENEMY_DROID &2335 01 ; enemies_direction # ENEMY_RIGHT &2336 0c ; enemies_inertia &2337 1e ; enemies_maximum_homing_cooldown &2338 00 ; enemies_behaviour # BEHAVIOUR_0: keeps moving until obstacle &2339 01 ; enemies_move_cooldown &233a 1e ; enemies_homing_cooldown &233b 00 ; enemies_materialisation_timer &233c 00 ; enemies_animation &233d 00 ; enemies_materialising ; patrolling_droid_direction_table &233e 01 ; ENEMY_RIGHT &233f 04 ; ENEMY_LEFT ; player_dematerialisation_data &2340 00 ; enemies_screen_address_low &2341 00 ; enemies_screen_address_high &2342 04 ; enemies_type # ENEMY_DEMATERIALISING &2343 00 ; enemies_direction &2344 00 ; enemies_inertia &2345 78 ; enemies_maximum_homing_cooldown &2346 00 ; enemies_behaviour # BEHAVIOUR_0: keeps moving until obstacle &2347 00 ; enemies_move_cooldown &2348 78 ; enemies_homing_cooldown &2349 fa ; enemies_materialisation_timer &234a 00 ; enemies_animation &234b 00 ; enemies_materialising ; random_directions_for_player_dematerialisations &234c 03 ; ENEMY_RIGHT | ENEMY_DOWN &234d 06 ; ENEMY_LEFT | ENEMY_DOWN &234e 09 ; ENEMY_RIGHT | ENEMY_UP &234f 0c ; ENEMY_LEFT | ENEMY_UP ; entering_space_lock_sound ; envelope &2350 04 01 f5 eb e1 01 02 02 7e 00 00 82 82 82 ; chan vol pitch dur &235e 11 00 04 00 c8 00 06 00 ; plot_gates &2366 a0 00 LDY #&00 ; plot_gates_loop &2368 b9 c3 61 LDA &61c3,Y ; gate_table &236b c5 7e CMP &7e ; player_room_low # Is the gate in this room? &236d d0 5e BNE &23cd ; consider_next_gate &236f b9 c4 61 LDA &61c4,Y ; gate_table + 1 &2372 29 03 AND #&03 &2374 c5 7f CMP &7f ; player_room_high &2376 d0 55 BNE &23cd ; consider_next_gate &2378 98 TYA &2379 48 PHA &237a b9 c4 61 LDA &61c4,Y ; gate_table + 1 &237d 29 f8 AND #&f8 &237f 85 8e STA &8e ; screen_address_low &2381 85 0d STA &0d ; gate_screen_address_low &2383 48 PHA &2384 a9 76 LDA #&76 &2386 85 8f STA &8f ; screen_address_high &2388 48 PHA &2389 a9 ab LDA #&ab &238b 85 8c STA &8c ; sprite_address_low &238d a9 61 LDA #&61 ; &61ab = gate_sprite &238f 85 8d STA &8d ; sprite_address_high &2391 a2 30 LDX #&30 &2393 a0 01 LDY #&01 &2395 20 79 0b JSR &0b79 ; unpack_character &2398 a2 02 LDX #&02 # 8 pixels wide &239a a0 03 LDY #&03 # 24 pixels high &239c 20 ad 65 JSR &65ad ; plot_aligned_sprite_using_eor &239f 68 PLA &23a0 a8 TAY &23a1 68 PLA &23a2 aa TAX &23a3 20 e0 65 JSR &65e0 ; calculate_subtile_address_from_screen_address &23a6 86 8e STX &8e ; subtile_address_low &23a8 84 8f STY &8f ; subtile_address_high &23aa a2 03 LDX #&03 &23ac a0 00 LDY #&00 ; set_subtiles_for_gate_loop &23ae b1 8e LDA (&8e),Y ; subtile_address &23b0 49 18 EOR #&18 ; SUBTILE_NO_ENEMIES | SUBTILE_NO_PLAYER # Neither player nor enemies can pass through gate &23b2 91 8e STA (&8e),Y ; subtile_address &23b4 c8 INY # Move right one subtile &23b5 b1 8e LDA (&8e),Y ; subtile_address &23b7 49 0c EOR #&0c ; SUBTILE_NO_PLAYER | SUBTILE_PIPE # Bug: should be SUBTILE_NO_ENEMIES | SUBTILE_NO_PLAYER &23b9 91 8e STA (&8e),Y ; subtile_address &23bb 88 DEY # Move left one subtile &23bc 18 CLC &23bd a5 8e LDA &8e ; subtile_address_low &23bf 69 40 ADC #&40 # Move down two subtiles &23c1 85 8e STA &8e ; subtile_address_low &23c3 90 02 BCC &23c7 ; skip_overflow &23c5 e6 8f INC &8f ; subtile_address_high ; skip_overflow &23c7 ca DEX &23c8 d0 e4 BNE &23ae ; set_subtiles_for_gate_loop &23ca 68 PLA &23cb a8 TAY &23cc 60 RTS ; consider_next_gate &23cd c8 INY &23ce c8 INY &23cf c0 0a CPY #&0a &23d1 d0 95 BNE &2368 ; plot_gates_loop &23d3 60 RTS ; plot_status &23d4 a2 04 LDX #&04 &23d6 a0 00 LDY #&00 &23d8 ca DEX ; check_score_loop &23d9 30 5a BMI &2435 ; skip_plotting_score &23db b5 30 LDA &30,X ; previous_score &23dd d5 46 CMP &46,X ; score &23df f0 f7 BEQ &23d8 ; check_score_loop &23e1 a2 00 LDX #&00 ; poke_score_into_text_loop &23e3 b5 46 LDA &46,X ; score # Top nibble is first digit &23e5 4a LSR A &23e6 4a LSR A &23e7 4a LSR A &23e8 4a LSR A &23e9 18 CLC &23ea 69 61 ADC #&61 ; "a" &23ec 99 e7 24 STA &24e7,Y ; score_text &23ef c8 INY &23f0 b5 46 LDA &46,X ; score &23f2 29 0f AND #&0f # Bottom nibble is second digit &23f4 69 61 ADC #&61 ; "a" &23f6 99 e7 24 STA &24e7,Y ; score_text &23f9 c8 INY &23fa e8 INX &23fb e0 04 CPX #&04 # Also pokes player_lives into lives_text &23fd d0 e4 BNE &23e3 ; poke_score_into_text_loop &23ff a9 0d LDA #&0d &2401 8d ec 24 STA &24ec ; score_text + 5 # Separate score_text and lives_text &2404 a9 18 LDA #&18 &2406 85 8a STA &8a ; screen_address_low &2408 a9 68 LDA #&68 ; &6818 &240a 85 8b STA &8b ; screen_address_high &240c a9 00 LDA #&00 &240e 85 87 STA &87 ; screen_offset &2410 a9 f0 LDA #&f0 # Colour 2 &2412 85 89 STA &89 ; text_colour_mask &2414 a2 e7 LDX #&e7 &2416 a0 24 LDY #&24 ; &24e7 = score_text &2418 20 80 0a JSR &0a80 ; plot_text &241b a9 60 LDA #&60 ; &6960 &241d 85 8a STA &8a ; screen_address_low &241f e6 8b INC &8b ; screen_address_high &2421 a9 00 LDA #&00 &2423 85 87 STA &87 ; screen_offset &2425 a2 ed LDX #&ed &2427 a0 24 LDY #&24 ; &24ed = lives_text &2429 20 80 0a JSR &0a80 ; plot_text &242c a2 03 LDX #&03 ; copy_score_loop &242e b5 46 LDA &46,X ; score &2430 95 30 STA &30,X ; previous_score &2432 ca DEX &2433 10 f9 BPL &242e ; copy_score_loop ; skip_plotting_score ; plot_bars &2435 a9 67 LDA #&67 ; &6788 &2437 85 8f STA &8f ; screen_address_high &2439 a9 88 LDA #&88 &243b 85 8e STA &8e ; screen_address_low &243d a9 00 LDA #&00 &243f 85 8a STA &8a ; bar_to_plot ; plot_bars_loop &2441 a6 8a LDX &8a ; bar_to_plot &2443 b5 35 LDA &35,X ; previous_player_energy_high &2445 d5 3b CMP &3b,X ; player_energy_high &2447 f0 4d BEQ &2496 ; skip_plotting_bar &2449 a9 f0 LDA #&f0 # Colour 2 for energy and ammunition &244b e0 02 CPX #&02 &244d d0 02 BNE &2451 ; not_fuel &244f a9 ff LDA #&ff # Colour 3 for fuel ; not_fuel &2451 85 8c STA &8c ; bar_colour_mask &2453 b5 3b LDA &3b,X ; player_energy_high &2455 c9 11 CMP #&11 &2457 90 08 BCC &2461 ; skip_overflow &2459 a9 ff LDA #&ff &245b 95 3a STA &3a,X ; player_energy_low &245d a9 10 LDA #&10 &245f 95 3b STA &3b,X ; player_energy_high ; skip_overflow &2461 85 89 STA &89 ; filled_length &2463 a9 03 LDA #&03 &2465 85 88 STA &88 ; total_length &2467 a0 00 LDY #&00 ; plot_bar_row_loop &2469 a9 00 LDA #&00 ; KK &246b a6 89 LDX &89 ; filled_length &246d 30 09 BMI &2478 ; skip_table &246f a9 ff LDA #&ff ; WW &2471 e0 04 CPX #&04 &2473 b0 03 BCS &2478 ; skip_table &2475 bd ef 24 LDA &24ef,X ; partial_bar_pixel_values ; skip_table &2478 25 8c AND &8c ; bar_colour_mask &247a 85 8d STA &8d ; bar_mask &247c a2 00 LDX #&00 ; plot_bar_column_loop &247e bd f3 24 LDA &24f3,X ; full_bar_pixel_values &2481 25 8d AND &8d ; bar_mask &2483 91 8e STA (&8e),Y ; screen_address &2485 c8 INY &2486 e8 INX &2487 e0 08 CPX #&08 &2489 d0 f3 BNE &247e ; plot_bar_column_loop &248b 38 SEC &248c a5 89 LDA &89 ; filled_length &248e e9 04 SBC #&04 &2490 85 89 STA &89 ; filled_length &2492 c6 88 DEC &88 ; total_length &2494 10 d3 BPL &2469 ; plot_bar_row_loop ; skip_plotting_bar &2496 e6 8f INC &8f ; screen_address_high &2498 e6 8a INC &8a ; bar_to_plot &249a e6 8a INC &8a ; bar_to_plot &249c a5 8a LDA &8a ; bar_to_plot &249e c9 06 CMP #&06 &24a0 d0 9f BNE &2441 ; plot_bars_loop ; copy_values &24a2 a0 05 LDY #&05 ; copy_values_loop &24a4 b9 3a 00 LDA &003a,Y ; player_energy_low &24a7 99 34 00 STA &0034,Y ; previous_player_energy_low &24aa 88 DEY &24ab 10 f7 BPL &24a4 ; copy_values_loop ; plot_pockets &24ad a9 b0 LDA #&b0 &24af 85 8e STA &8e ; screen_address_low &24b1 a9 00 LDA #&00 &24b3 85 87 STA &87 ; pocket_to_plot ; plot_pockets_loop &24b5 a6 87 LDX &87 ; pocket_to_plot &24b7 b5 0f LDA &0f,X ; pockets &24b9 d5 13 CMP &13,X ; previous_pockets &24bb f0 11 BEQ &24ce ; skip_pocket &24bd a2 67 LDX #&67 &24bf 86 8f STX &8f ; screen_address_high &24c1 a2 f0 LDX #&f0 # Colour 2 &24c3 a0 00 LDY #&00 # Overwrite screen &24c5 c9 00 CMP #&00 &24c7 d0 02 BNE &24cb ; pocket_isn't_empty &24c9 a9 08 LDA #&08 ; ITEM_EMPTY ; pocket_isn't_empty &24cb 20 b3 0b JSR &0bb3 ; plot_packed_two_colour_sprite ; skip_pocket &24ce 18 CLC &24cf a5 8e LDA &8e ; screen_address_low &24d1 69 10 ADC #&10 # Move right 8 pixels &24d3 85 8e STA &8e ; screen_address_low &24d5 e6 87 INC &87 ; pocket_to_plot &24d7 c9 f0 CMP #&f0 &24d9 90 da BCC &24b5 ; plot_pockets_loop ; copy_pockets &24db a0 03 LDY #&03 ; copy_pockets_loop &24dd b9 0f 00 LDA &000f,Y ; pockets &24e0 99 13 00 STA &0013,Y ; previous_pockets &24e3 88 DEY &24e4 10 f7 BPL &24dd ; copy_pockets_loop &24e6 60 RTS ; score_text &24e7 00 00 00 00 00 00 ; lives_text &24ed 00 0d ; partial_bar_pixel_values &24ef 00 88 cc ee ; full_bar_pixel_values &24f3 ff 00 ee ee ee 00 ff 00 ; opening_gate_sound ; envelope &24fb 04 01 fb f9 f6 04 04 04 7e 00 00 82 7e 7e ; chan vol pitch dur &2509 12 00 04 00 64 00 07 00 ; collecting_sound ; chan vol pitch dur &2511 12 00 f6 00 32 00 01 00 ; entering_passage_sound ; envelope &2519 04 01 00 00 00 00 00 00 08 ec ec ec 7e 5a ; chan vol pitch dur &2527 10 00 04 00 04 00 04 00 ; calculate_below_subtile_address_from_screen_address &252f 86 8e STX &8e ; screen_address_low &2531 84 8f STY &8f ; screen_address_high &2533 a2 03 LDX #&03 ; divide_by_eight_loop &2535 46 8f LSR &8f ; screen_address_high &2537 66 8e ROR &8e ; screen_address_low &2539 ca DEX &253a d0 f9 BNE &2535 ; divide_by_eight_loop &253c a5 8f LDA &8f ; screen_address_high &253e 29 03 AND #&03 &2540 09 04 ORA #&04 &2542 85 8f STA &8f ; screen_address_high &2544 18 CLC &2545 a5 8e LDA &8e ; screen_address_low &2547 69 40 ADC #&40 # Move down two subtiles &2549 85 8e STA &8e ; screen_address_low &254b aa TAX &254c a5 8f LDA &8f ; screen_address_high &254e 69 00 ADC #&00 &2550 85 8f STA &8f ; screen_address_high &2552 a8 TAY &2553 60 RTS ; calculate_below_player_subtile_address &2554 a6 70 LDX &70 ; player_screen_address_low &2556 a4 71 LDY &71 ; player_screen_address_high &2558 20 2f 25 JSR &252f ; calculate_below_subtile_address_from_screen_address &255b 86 74 STX &74 ; below_player_subtile_address_low &255d 84 75 STY &75 ; below_player_subtile_address_high &255f 60 RTS ; store_player_entry_position &2560 a5 70 LDA &70 ; player_screen_address_low &2562 85 5a STA &5a ; player_entry_screen_address_low &2564 a5 71 LDA &71 ; player_screen_address_high &2566 85 5b STA &5b ; player_entry_screen_address_high &2568 a5 72 LDA &72 ; player_sprite &256a 85 5c STA &5c ; player_entry_sprite &256c a5 76 LDA &76 ; player_on_hopper &256e 85 5d STA &5d ; player_entry_on_platform &2570 60 RTS ; calculate_player_group_address_and_hopper_sprite &2571 a5 70 LDA &70 ; player_screen_address_low &2573 29 f8 AND #&f8 &2575 85 98 STA &98 ; player_group_address_low &2577 a5 72 LDA &72 ; player_sprite &2579 29 03 AND #&03 &257b 85 99 STA &99 ; hopper_sprite &257d a9 00 LDA #&00 &257f 85 45 STA &45 ; player_walking_direction &2581 60 RTS ; set_subtiles_from_tile &2582 a6 86 LDX &86 ; tile_offset &2584 bd 00 04 LDA &0400,X ; room_tiles &2587 29 3f AND #&3f # Remove any colour from tile, leaving tile type &2589 85 8f STA &8f ; tile_sprite &258b 0a ASL A &258c 65 8f ADC &8f ; tile_sprite &258e 0a ASL A &258f 85 69 STA &69 ; offset &2591 a0 00 LDY #&00 ; set_subtiles_loop &2593 a6 69 LDX &69 ; offset &2595 bd 80 59 LDA &5980,X ; tile_subtile_table &2598 29 0f AND #&0f # Bottom nibble determines type of left subtile &259a aa TAX &259b bd b5 2d LDA &2db5,X ; subtile_flags_table &259e 91 80 STA (&80),Y ; subtile_address &25a0 c8 INY # Move right a subtile &25a1 a6 69 LDX &69 ; offset &25a3 bd 80 59 LDA &5980,X ; tile_subtile_table &25a6 29 f0 AND #&f0 # Top nibble determines type of next subtile &25a8 4a LSR A &25a9 4a LSR A &25aa 4a LSR A &25ab 4a LSR A &25ac aa TAX &25ad bd b5 2d LDA &2db5,X ; subtile_flags_table &25b0 91 80 STA (&80),Y ; subtile_address &25b2 c8 INY # Move right a subtile &25b3 e6 69 INC &69 ; tile_sprite_times_six &25b5 a5 69 LDA &69 ; tile_sprite_times_six &25b7 29 01 AND #&01 &25b9 d0 d8 BNE &2593 ; set_subtiles_loop # Tile is four subtile wide &25bb 98 TYA &25bc 18 CLC &25bd 69 1c ADC #&1c # Move back to left of tile, and down asubtile &25bf a8 TAY &25c0 c0 60 CPY #&60 # Tile is three subtiles high &25c2 d0 cf BNE &2593 ; set_subtiles_loop &25c4 60 RTS ; calculate_room_data_address &25c5 86 8e STX &8e ; room_low &25c7 84 8f STY &8f ; room_high &25c9 86 8c STX &8c ; unused_room_low # Unnecessary code &25cb 84 8d STY &8d ; unused_room_high # Unnecessary code &25cd 06 8e ASL &8e ; twice_room_low &25cf 26 8f ROL &8f ; twice_room_high &25d1 8a TXA &25d2 65 8e ADC &8e ; twice_room_low &25d4 85 80 STA &80 ; room_data_address_low &25d6 98 TYA &25d7 65 8f ADC &8f ; twice_room_high &25d9 85 81 STA &81 ; room_data_address_high &25db 06 80 ASL &80 ; room_data_address_low &25dd 26 81 ROL &81 ; room_data_address_high &25df 06 80 ASL &80 ; room_data_address_low &25e1 26 81 ROL &81 ; room_data_address_high &25e3 a5 80 LDA &80 ; room_data_address_low &25e5 69 80 ADC #&80 &25e7 85 80 STA &80 ; room_data_address_low &25e9 a5 81 LDA &81 ; room_data_address_high &25eb 69 41 ADC #&41 ; &4180 = room_data # Room data is at &4180 + 12 * room &25ed 85 81 STA &81 ; room_data_address_high &25ef 60 RTS ; plot_room &25f0 86 89 STX &89 ; room_low_one # Two copies of each variable, identical values &25f2 86 84 STX &84 ; room_low_two &25f4 84 8a STY &8a ; room_high_one &25f6 84 85 STY &85 ; room_high_two &25f8 a9 13 LDA #&13 ; Wait for v-sync &25fa 20 f4 ff JSR &fff4 ; OSBYTE &25fd a9 00 LDA #&00 ; K # Hide status section &25ff 85 93 STA &93 ; palette + 3 &2601 85 95 STA &95 ; palette + 5 &2603 85 97 STA &97 ; palette + 7 &2605 85 4d STA &4d ; passage_screen_address_high # No passage by default &2607 85 59 STA &59 ; room_item_screen_address_high # No item by default &2609 85 af STA &af ; space_lock_entrance_screen_address_high + 2 &260b 85 ad STA &ad ; space_lock_entrance_screen_address_high # No space lock by default &260d a0 57 LDY #&57 ; wipe_spark_data &260f 99 00 01 STA &0100,Y ; spark_data # Wipe &0100 - &0157, i.e. spark_data, pipe_in_tile &2612 88 DEY # and pipe_arrow_columns_status &2613 10 fa BPL &260f ; wipe_spark_data &2615 20 00 7f JSR &7f00 ; to_set_screen_colours &2618 a6 89 LDX &89 ; room_low_one &261a a4 8a LDY &8a ; room_high_one &261c 20 c5 25 JSR &25c5 ; calculate_room_data_address &261f a0 00 LDY #&00 &2621 b1 80 LDA (&80),Y ; room_data_address # Get first byte of room data &2623 48 PHA &2624 48 PHA &2625 29 07 AND #&07 # Lowest three bits set type of wall &2627 8d ab 2d STA &2dab ; room_primary_wall_type &262a 68 PLA &262b 29 e0 AND #&e0 # Top two bits set colour 2 &262d 0a ASL A &262e 2a ROL A &262f 2a ROL A &2630 2a ROL A &2631 85 95 STA &95 ; palette + 5 &2633 68 PLA &2634 29 18 AND #&18 # Two of remaining three bits set colour 1 from table &2636 4a LSR A &2637 4a LSR A &2638 4a LSR A &2639 aa TAX &263a bd b1 2d LDA &2db1,X ; room_colours_from_bits &263d 85 93 STA &93 ; palette + 3 &263f c8 INY &2640 b1 80 LDA (&80),Y ; room_data_address # Get second byte of room data &2642 48 PHA &2643 29 0f AND #&0f # Bottom nibble sets first extra type &2645 8d ac 2d STA &2dac ; room_extras_types &2648 68 PLA &2649 4a LSR A # Top nibble sets second extra type &264a 4a LSR A &264b 4a LSR A &264c 4a LSR A &264d 8d ad 2d STA &2dad ; room_extras_types + 1 &2650 a2 00 LDX #&00 &2652 a0 02 LDY #&02 # For third and fourth, then fifth and sixth bytes: ; get_additional_wall_types_loop &2654 b1 80 LDA (&80),Y ; room_data_address # From third / fifth byte of room data: &2656 29 c0 AND #&c0 # take top two bits 84...... -> ......21 &2658 0a ASL A &2659 2a ROL A &265a 2a ROL A &265b 85 8e STA &8e ; tmp &265d c8 INY &265e b1 80 LDA (&80),Y ; room_data_address # From fourth / sixth byte of room data: &2660 29 c0 AND #&c0 # take top two bits 84...... -> ....84.. &2662 4a LSR A &2663 4a LSR A &2664 4a LSR A &2665 4a LSR A &2666 05 8e ORA &8e ; tmp &2668 9d ae 2d STA &2dae,X ; room_additional_wall_types # and combine to set first / second additional wall type &266b c8 INY &266c e8 INX &266d e0 02 CPX #&02 &266f d0 e3 BNE &2654 ; get_additional_wall_types_loop &2671 a9 00 LDA #&00 # No teleport by default &2673 85 f7 STA &f7 ; teleport_screen_address_high &2675 a9 06 LDA #&06 ; C # Status section uses cyan for colour 1 &2677 85 92 STA &92 ; palette + 2 &2679 a9 03 LDA #&03 ; Y # Status section uses yellow for colour 2 &267b 85 94 STA &94 ; palette + 4 &267d a9 01 LDA #&01 ; R # Status section uses red for colour 2 &267f 85 96 STA &96 ; palette + 6 &2681 a9 07 LDA #&07 ; W # Bottom section uses white for colour 3 &2683 85 97 STA &97 ; palette + 7 ; initialise_walls &2685 a0 06 LDY #&06 # Seventh through twelfth bytes of room data set walls &2687 a2 00 LDX #&00 ; initialise_walls_column_loop &2689 b1 80 LDA (&80),Y ; room_data_address # Get a byte of room data for row of walls &268b 85 8f STA &8f ; row_bits # One byte per row of eight tiles ; initialise_walls_row_loop &268d a9 00 LDA #&00 ; TILE_EMPTY &268f 06 8f ASL &8f; row_bits &2691 90 1c BCC &26af ; set_wall # Unset bit indicates empty tile &2693 a5 85 LDA &85 ; room_high_two &2695 d0 0e BNE &26a5 ; use_wall &2697 a5 84 LDA &84 ; room_low_two &2699 c9 10 CMP #&10 # Rooms &000 - &00f, &269b b0 08 BCS &26a ; use_wall &269d c0 08 CPY #&08 # first two rows &269f b0 04 BCS &26a ; use_wall &26a1 a9 d8 LDA #&d8 ; TILE_STARS | COLOUR_3 # use stars as wall &26a3 d0 0a BNE &26af ; set_wall # Always branches ; use_wall &26a5 84 8e STY &8e ; row &26a7 ac ab 2d LDY &2dab ; room_primary_wall_type &26aa b9 90 2d LDA &2d90,Y ; primary_wall_tiles_table # Get wall tile &26ad a4 8e LDY &8e ; row ; set_wall &26af 9d 00 04 STA &0400,X ; room_tiles &26b2 e8 INX &26b3 8a TXA &26b4 29 07 AND #&07 &26b6 d0 d5 BNE &268d ; initialise_walls_row_loop &26b8 c8 INY &26b9 c0 0c CPY #&0c &26bb d0 cc BNE &2689 ; initialise_walls_column_loop ; add_extras &26bd a9 02 LDA #&02 # Third through sixth bytes of room data add extras &26bf 85 8d STA &8d ; extra_offset ; add_extras_loop &26c1 a5 8d LDA &8d ; extra_offset &26c3 c9 04 CMP #&04 &26c5 30 0a BMI &26d1 ; skip_check # For the second set of extras, &26c7 a8 TAY &26c8 b9 aa 2d LDA &2daa,Y ; room_additional_wall_types - 4 &26cb c9 0f CMP #&0f ; NOT_ADDITIONAL_WALL # skip if additional wall type isn't &0f &26cd d0 40 BNE &270f ; to_consider_next_extra # (rectangles will be added separately) &26cf a5 8d LDA &8d ; extra_offset ; skip_check &26d1 29 01 AND #&01 # Third and fifth byte use first extra type &26d3 aa TAX # Fourth and sixth byte use second extra type &26d4 bc ac 2d LDY &2dac,X ; room_extras_types &26d7 b9 98 2d LDA &2d98,Y ; extra_tiles_table &26da 85 8e STA &8e ; extra_tile &26dc a4 8d LDY &8d ; extra_offset &26de b1 80 LDA (&80),Y ; room_data_address # Get a byte of room data for position &26e0 29 3f AND #&3f # Lowest six bits set position &26e2 c9 30 CMP #&30 &26e4 b0 29 BCS &270f ; to_consider_next_extra # Don't add an extra if this isn't a valid tile &26e6 aa TAX &26e7 a5 8d LDA &8d ; extra_offset &26e9 29 01 AND #&01 &26eb a8 TAY &26ec b9 ac 2d LDA &2dac,Y ; room_extras_types &26ef c9 06 CMP #&06 ; EXTRA_SKELETONAUT &26f1 b0 33 BCS &2726 ; is_special_extra # Does the extra span several tiles? &26f3 c9 03 CMP #&03 ; EXTRA_SPARK_HEAD &26f5 f0 1b BEQ &2712 ; add_spark_head # Or is it a spark head? &26f7 a5 8e LDA &8e ; extra_tile &26f9 29 3f AND #&3f &26fb c9 09 CMP #&09 ; TILE_HOPPER_PAD &26fd d0 0b BNE &270a ; set_tile # If not, and it's not a hopper pad, just set a tile &26ff a0 00 LDY #&00 # Hopper pad number is on left &2701 bd 00 04 LDA &0400,X ; room_tiles &2704 f0 02 BEQ &2708 ; set_hopper_pad_address &2706 a0 18 LDY #&18 # Hopper pad number is on right ; set_hopper_pad_address &2708 84 64 STY &64 ; hopper_pad_screen_address_low ; set_tile &270a a5 8e LDA &8e ; extra_tile &270c 9d 00 04 STA &0400,X ; room_tiles ; to_consider_next_extra &270f 4c 39 28 JMP &2839 ; consider_next_extra ; add_spark_head &2712 bc 00 04 LDY &0400,X ; room_tiles &2715 a9 cc LDA #&cc ; TILE_SPARK_HEAD | COLOUR_3 &2717 9d 00 04 STA &0400,X ; room_tiles &271a c0 00 CPY #&00 # Was the tile empty? &271c f0 f1 BEQ &270f ; to_consider_next_extra &271e 8a TXA &271f 18 CLC &2720 69 08 ADC #&08 # If not, add a dome below the spark head &2722 aa TAX &2723 4c 2a 28 JMP &282a ; add_dome ; is_special_extra &2726 c9 0f CMP #&0f ; EXTRA_RECTANGLE &2728 f0 2b BEQ &2755 ; to_consider_next_extra &272a c9 0e CMP #&0e ; EXTRA_PIPE &272c d0 03 BNE &2731 ; not_pipe &272e 4c a9 27 JMP &27a9 ; add_pipe ; not_pipe &2731 c9 0d CMP #&0d ; EXTRA_PLANT &2733 f0 30 BEQ &2765 ; add_plant &2735 c9 06 CMP #&06 ; EXTRA_SKELETONAUT &2737 d0 03 BNE &273c ; not_skeletonaut &2739 4c f1 27 JMP &27f1 ; add_skeletonaut ; not_skeletonaut &273c c9 09 CMP #&09 ; EXTRA_SPIKE &273e d0 03 BNE &2743 ; not_spike &2740 4c fe 27 JMP &27fe ; add_spike ; not_spike &2743 c9 08 CMP #&08 ; EXTRA_DOME &2745 d0 03 BNE &274a ; not_dome &2747 4c 2a 28 JMP &282a ; add_dome &274a c9 0a CMP #&0a ; EXTRA_ALTAR &274c d0 03 BNE &2751 ; not_altar &274e 4c 0c 28 JMP &280c ; add_altar ; not_altar &2751 c9 07 CMP #&07 ; EXTRA_SPACE_LOCK &2753 f0 03 BEQ &2758 ; add_space_lock ; to_consider_next_extra &2755 4c 39 28 JMP &2839 ; consider_next_extra ; add_space_lock &2758 a9 a3 LDA #&a3 : TILE_SPACE_LOCK_LEFT | COLOUR_2 &275a 9d 00 04 STA &0400,X ; room_tiles &275d a9 a4 LDA #&a4 ; TILE_SPACE_LOCK_RIGHT | COLOUR_2 &275f 9d 01 04 STA &0401,X ; room_tiles + 1 &2762 4c 39 28 JMP &2839 ; consider_next_extra ; add_plant &2765 c6 8e DEC &8e ; extra_tile # Turn TILE_PLANT_BRANCHES into &1c (see &2777) &2767 a9 1a LDA #&1a ; TILE_PLANT_FLOWER - 1 &2769 85 8f STA &8f ; plant_tile &276b bd 00 04 LDA &0400,X ; room_tiles # Was the tile empty? &276e d0 1d BNE &278d ; add_downwards_plant_loop # If not, plant is growing downwards &2770 a9 18 LDA #&18 ; TILE_PLANT_HEAD - 1 &2772 85 8f STA &8f ; plant_tile ; add_upwards_plant_loop &2774 a5 8f LDA &8f ; plant_tile &2776 18 CLC &2777 69 01 ADC #&01 # All plant tiles are unnecessarily offset by one &2779 9d 00 04 STA &0400,X ; room_tiles &277c a5 8e LDA &8e ; extra_tile &277e 85 8f STA &8f ; plant_tile # Use TILE_PLANT_BRANCHES after first tile &2780 8a TXA &2781 e9 07 SBC #&07 # Move up a row &2783 aa TAX &2784 90 cf BCC &2755 ; to_consider_next_extra # until top of screen &2786 bd 00 04 LDA &0400,X ; room_tiles &2789 f0 e9 BEQ &2774 ; add_upwards_plant_loop # or non-empty tile &278b d0 61 BNE &27ee ; to_consider_next_extra # Always branches ; add_downwards_plant_loop &278d a5 8f LDA &8f ; plant_tile &278f 18 CLC &2790 69 01 ADC #&01 # All plant tiles are unnecessarily offset by one &2792 9d 00 04 STA &0400,X ; room_tiles &2795 a5 8e LDA &8e ; extra_tile &2797 85 8f STA &8f ; plant_tile # Use TILE_PLANT_BRANCHES after first tile &2799 8a TXA &279a 18 CLC &279b 69 08 ADC #&08 # Move down a row &279d aa TAX &279e e0 30 CPX #&30 &27a0 b0 b3 BCS &2755 ; to_consider_next_extra # until bottom of screen &27a2 bd 00 04 LDA &0400,X ; room_tiles &27a5 f0 e6 BEQ &278d ; add_downwards_plant_loop # or non-empty tile &27a7 d0 45 BNE &27ee ; to_consider_next_extra # Always branches ; add_pipe &27a9 a5 95 LDA &95 ; palette + 5 &27ab 85 8b STA &8b ; pipe_pattern &27ad a9 00 LDA #&00 # Pipe is closed &27af bc 00 04 LDY &0400,X ; room_tiles &27b2 f0 02 BEQ &27b6 ; tile_was_empty &27b4 a9 01 LDA #&01 # unless tile was empty &27b6 85 8c STA &8c ; pipe_state ; tile_was_empty &27b8 a9 97 LDA #&97 ; TILE_PIPE_TOP | COLOUR_2 &27ba e0 08 CPX #&08 &27bc 10 02 BPL &27c0 ; use_top_pipe # If the pipe starts at the top of the screen, &27be a5 8e LDA &8e ; extra_tile # Use TILE_PIPE_CLOSED | COLOUR_2 ; use_top_pipe &27c0 85 8f STA &8f ; pipe_tile ; add_pipe_loop &27c2 a5 8f LDA &8f ; pipe_tile &27c4 9d 00 04 STA &0400,X ; room_tiles &27c7 a9 93 LDA #&93 ; TILE_PIPE_CLOSED | COLOUR_2 &27c9 85 8f STA &8f ; pipe_tile &27cb a5 8c LDA &8c ; pipe_state &27cd 49 01 EOR #&01 # Openings in pipe &27cf 85 8c STA &8c ; pipe_state &27d1 d0 06 BNE &27d9 ; pipe_is_closed &27d3 46 8b LSR &8b ; pipe_pattern # use a room dependent pattern &27d5 90 02 BCC &27d9 ; pipe_is_closed &27d7 e6 8f INC &8f ; pipe_tile # Turn TILE_PIPE_CLOSED into TILE_PIPE_BOTH ; pipe_is_closed &27d9 18 CLC &27da 8a TXA &27db 69 08 ADC #&08 # Move down a row &27dd aa TAX &27de a9 93 LDA #&93 ; TILE_PIPE_CLOSED | COLOUR_2 &27e0 e0 30 CPX #&30 # Pipe ends at bottom of screen (closed at bottom) &27e2 b0 07 BCS &27eb ; set_tile_above_pipe &27e4 bd 00 04 LDA &0400,X ; room_tiles &27e7 f0 d9 BEQ &27c2 ; add_pipe_loop # or non-empty tile (open at bottom) &27e9 a9 94 LDA #&94 ; TILE_PIPE_BOTH | COLOUR_2 ; set_tile_above_pipe &27eb 9d f8 03 STA &03f8,X ; room_tiles - 8 ; to_consider_next_extra &27ee 4c 39 28 JMP &2839 ; consider_next_extra ; add_skeletonaut &27f1 a5 8e LDA &8e ; extra_tile &27f3 9d 00 04 STA &0400,X ; room_tiles &27f6 18 CLC &27f7 69 01 ADC #&01 # Turn TILE_SKELETONAUT_LEFT into TILE_SKELETONAUT_RIGHT &27f9 9d 01 04 STA &0401,X ; room_tiles + 1 &27fc d0 f0 BNE &27ee ; to_consider_next_extra # Always branches ; add_spike &27fe bd 08 04 LDA &0408,X ; room_tiles + 8 &2801 d0 02 BNE &2805 ; tile_is_on_wall # If the spike isn't above a wall, &2803 e6 8e INC &8e ; extra_tile # Turn TILE_SPIKE into TILE_SPIKE_ON_LEDGE ; tile_is_on_wall &2805 a5 8e LDA &8e ; extra_tile &2807 9d 00 04 STA &0400,X ; room_tiles &280a d0 e2 BNE &27ee ; to_consider_next_extra # Always branches ; add_altar &280c a9 e1 LDA #&e1 ; TILE_THREE_HEADED_DOME | COLOUR_3 &280e 9d 10 04 STA &0410,X ; room_tiles + 2 * 8 &2811 9d 13 04 STA &0413,X ; room_tiles + 2 * 8 + 3 &2814 9d 08 04 STA &0408,X ; room_tiles + 1 * 8 &2817 9d 0b 04 STA &040b,X ; room_tiles + 1 * 8 + 3 &281a a9 62 LDA #&62 ; TILE_WHEELED_WALL | COLOUR_3 # WWWW &281c 9d 00 04 STA &0400,X ; room_tiles # D D &281f 9d 02 04 STA &0402,X ; room_tiles + 2 # D D &2822 9d 01 04 STA &0401,X ; room_tiles + 1 &2825 9d 03 04 STA &0403,X ; room_tiles + 3 &2828 d0 0f BNE &2839 ; consider_next_extra # Always branches ; add_dome &282a bd 00 04 LDA &0400,X ; room_tiles &282d f0 05 BEQ &2834 ; skip_pipe_top # If tile wasn't empty, add a pipe below the dome &282f a9 97 LDA #&97 ; TILE_PIPE_TOP | COLOUR_2 &2831 9d 08 04 STA &0408,X ; room_tiles + 8 ; skip_pipe_top &2834 a9 d0 LDA #&d0 ; TILE_DOME | COLOUR_3 &2836 9d 00 04 STA &0400,X ; room_tiles ; consider_next_extra &2839 e6 8d INC &8d ; extra_offset &283b a5 8d LDA &8d ; extra_offset &283d c9 06 CMP #&06 &283f f0 03 BEQ &2844 ; finished_adding_extras &2841 4c c1 26 JMP &26c1 ; add_extras_loop ; finished_adding_extras &2844 20 f9 2c JSR &2cf9 ; add_additional_walls ; add_teleports &2847 a0 08 LDY #&08 ; add_teleports_loop &2849 b9 23 62 LDA &6223,Y ; teleport_data - 2 # Seventh byte of teleport data is room_low &284c c5 84 CMP &84 ; room_low_two &284e d0 33 BNE &2883 ; consider_next_teleport &2850 b9 24 62 LDA &6224,Y ; teleport_data - 1 # Lowest bit of eighth byte is room_high &2853 29 01 AND #&01 &2855 c5 85 CMP &85 ; room_high_two &2857 d0 2a BNE &2883 ; consider_next_teleport &2859 b9 24 62 LDA &6224,Y ; teleport_data - 1 # Remaining bits of eighth byte are tile offset &285c 4a LSR A &285d aa TAX &285e a9 25 LDA #&25 ; TILE_TELEPORT &2860 9d 00 04 STA &0400,X ; room_tiles &2863 b9 22 62 LDA &6222,Y ; teleport_data - 3 # Sixth byte of teleport data is tile on top of teleport &2866 9d f8 03 STA &03f8,X ; room_tiles - 8 # (always &cc TILE_SPARK_HEAD | COLOUR_3) &2869 84 f5 STY &f5 ; room_teleport_offset &286b 8a TXA &286c 29 07 AND #&07 &286e 0a ASL A &286f 0a ASL A &2870 0a ASL A &2871 0a ASL A &2872 0a ASL A &2873 85 f6 STA &f6 ; teleport_screen_address_low &2875 8a TXA &2876 4a LSR A &2877 4a LSR A &2878 29 0e AND #&0e &287a 85 8e STA &8e ; tmp &287c 4a LSR A &287d 65 8e ADC &8e ; tmp &287f 69 6e ADC #&6e &2881 85 f7 STA &f7 ; teleport_screen_address_high ; consider_next_teleport &2883 18 CLC &2884 98 TYA &2885 69 08 ADC #&08 &2887 a8 TAY &2888 10 bf BPL &2849 ; add_teleports_loop ; add_sparks &288a a9 00 LDA #&00 &288c 85 8d STA &8d ; tile_offset ; add_sparks_loop &288e a6 8d LDX &8d ; tile_offset &2890 bd 00 04 LDA &0400,X ; room_tiles &2893 29 3f AND #&3f &2895 c9 0b CMP #&0b ; TILE_SPARK_GATE &2897 f0 04 BEQ &289d ; has_spark &2899 c9 0c CMP #&0c ; TILE_SPARK_HEAD &289b d0 52 BNE &28ef ; consider_next_tile ; has_spark &289d 29 01 AND #&01 &289f 85 8c STA &8c ; spark_offset &28a1 a0 17 LDY #&17 ; move_sparks_loop &28a3 b9 00 01 LDA &0100,Y ; sparks_screen_address_low &28a6 99 08 01 STA &0108,Y ; sparks_screen_address_low + 8 &28a9 88 DEY &28aa 10 f7 BPL &28a3 ; move_sparks_loop &28ac 8a TXA &28ad 29 38 AND #&38 &28af 4a LSR A &28b0 4a LSR A &28b1 85 8b STA &8b ; tmp &28b3 4a LSR A &28b4 65 8b ADC &8b ; tmp &28b6 65 8c ADC &8c ; spark_offset &28b8 69 6d ADC #&6d &28ba 8d 01 01 STA &0101 ; sparks_screen_address_high &28bd a8 TAY &28be 8a TXA &28bf 29 07 AND #&07 &28c1 0a ASL A &28c2 0a ASL A &28c3 69 01 ADC #&01 &28c5 0a ASL A &28c6 0a ASL A &28c7 0a ASL A &28c8 8d 00 01 STA &0100 ; sparks_screen_address_low &28cb aa TAX &28cc 20 e0 65 JSR &65e0 ; calculate_subtile_address_from_screen_address &28cf 8e 02 01 STX &0102 ; sparks_subtile_address_low # Set but not unused &28d2 8c 03 01 STY &0103 ; sparks_subtile_address_high # Set but not unused &28d5 20 40 64 JSR &6440 ; rnd &28d8 a5 9b LDA &9b ; rnd_2 &28da 29 1f AND #&1f &28dc 8d 04 01 STA &0104 ; sparks_frame &28df a9 2c LDA #&2c &28e1 8d 05 01 STA &0105 ; sparks_ignition_frame &28e4 20 40 64 JSR &6440 ; rnd &28e7 29 1c AND #&1c &28e9 18 CLC &28ea 69 50 ADC #&50 &28ec 8d 06 01 STA &0106 ; sparks_total_frames ; consider_next_tile &28ef e6 8d INC &8d ; tile_offset &28f1 a5 8d LDA &8d ; tile_offset &28f3 c9 30 CMP #&30 &28f5 d0 97 BNE &288e ; add_sparks_loop ; add_three_headed_domes &28f7 a5 84 LDA &84 ; room_low_two &28f9 c9 b0 CMP #&b0 # Rooms &1bb - &1bf, &1cb - &1cf, &1db - &1df, &28fb 90 3e BCC &293b ; skip_three_headed_domes # &1eb - &1ef and &1fb - &1ff have special edges &28fd 29 0f AND #&0f &28ff c9 0b CMP #&0b &2901 90 38 BCC &293b ; skip_three_headed_domes &2903 a5 85 LDA &85 ; room_high_two &2905 f0 34 BEQ &293b ; skip_three_headed_domes &2907 a0 00 LDY #&00 &2909 a9 01 LDA #&01 &290b 85 8e STA &8e ; delta ; add_domes_loop # Replace left and right edges walls &290d b9 00 04 LDA &0400,Y ; room_tiles &2910 f0 09 BEQ &291b ; skip_dome &2912 c9 c0 CMP #&c0 ; TILE_EMPTY | COLOUR_3 &2914 b0 05 BCS &291b ; skip_dome &2916 a9 e1 LDA #&e1 ; TILE_THREE_HEADED_DOME | COLOUR_3 &2918 99 00 04 STA &0400,Y ; room_tiles ; skip_dome &291b a5 8e LDA &8e ; delta &291d 49 06 EOR #&06 # Add 1 or 7 alternately &291f 85 8e STA &8e ; delta &2921 98 TYA &2922 18 CLC &2923 65 8e ADC &8e ; delta &2925 a8 TAY &2926 c0 30 CPY #&30 &2928 d0 e3 BNE &290d ; add_domes_loop &292a ad 04 04 LDA &0404 ; room_tiles + 4 &292d f0 16 BEQ &2945 ; add_hexagonal_floor &292f a0 07 LDY #&07 ; add_wheeled_wall_loop &2931 a9 62 LDA #&62 ; TILE_WHEELED_WALL | COLOUR_1 # Replace top edge walls &2933 99 00 04 STA &0400,Y ; room_tiles &2936 88 DEY &2937 10 f8 BPL &2931 ; add_wheeled_wall_loop &2939 30 0a BMI &2945 ; add_hexagonal_floor # Always branches ; skip_three_headed_domes &293b a5 84 LDA &84 ; room_low_two &293d c9 f0 CMP #&f0 # Rooms &01f0 - &01ff have hexagonal floors &293f 90 1a BCC &295b ; skip_hexagonal_floor &2941 a5 85 LDA &85 ; room_high_two &2943 f0 16 BEQ &295b ; skip_hexagonal_floor ; add_hexagonal_floor &2945 ad 2c 04 LDA &042c ; room_tiles + 5 * 8 + 4 &2948 f0 11 BEQ &295b ; skip_hexagonal_floor &294a a0 07 LDY #&07 ; add_hexagonal_floor_loop &294c b9 28 04 LDA &0428,Y ; room_tiles + 5 * 8 &294f c9 c9 CMP #&c9 ; TILE_HOPPER_PAD | COLOUR_3 &2951 f0 05 BEQ &2958 ; skip_tile &2953 a9 5f LDA #&5f ; TILE_HEXAGONS | COLOUR_1 &2955 99 28 04 STA &0428,Y ; room_tiles + 5 * 8 ; skip_tile &2958 88 DEY &2959 10 f1 BPL &294c ; add_hexagonal_floor_loop ; skip_hexagonal_floor &295b a0 08 LDY #&08 ; change_pipes_loop &295d b9 f8 03 LDA &03f8,Y ; rooms_tiles - 8 &2960 29 3f AND #&3f &2962 c9 17 CMP #&17 ; TILE_PIPE_TOP &2964 10 34 BPL &299a ; consider_next &2966 c9 13 CMP #&13 ; TILE_PIPE_CLOSED &2968 30 30 BMI &299a ; consider_next &296a 48 PHA &296b a9 01 LDA #&01 &296d 99 18 01 STA &0118,Y ; pipe_in_tile - 8 &2970 a9 02 LDA #&02 ; G # Set colour 2 to green when screen has pipes &2972 85 95 STA &95 ; palette + 5 &2974 68 PLA &2975 c9 14 CMP #&14 ; TILE_PIPE_BOTH &2977 d0 21 BNE &299a ; consider_next_tile &2979 b9 f7 03 LDA &03f7,Y ; rooms_tiles - 8 - 1 &297c f0 12 BEQ &2990 ; has_left_opening &297e b9 f9 03 LDA &03f9,Y ; rooms_tiles - 8 + 1 &2981 f0 08 BEQ &298b ; has_right_opening &2983 a9 93 LDA #&93 ; TILE_PIPE_CLOSED | COLOUR_2 &2985 99 f8 03 STA &03f8,Y ; room_tiles - 8 &2988 4c 9a 29 JMP &299a ; consider_next_tile ; has_right_opening &298b a9 96 LDA #&96 ; TILE_PIPE_RIGHT | COLOUR_2 &298d 99 f8 03 STA &03f8,Y ; room_tiles - 8 ; has_left_opening &2990 b9 f9 03 LDA &03f9,Y ; room_tiles - 8 + 1 &2993 f0 05 BEQ &299a ; consider_next_tile &2995 a9 95 LDA #&95 ; TILE_PIPE_LEFT | COLOUR_2 &2997 99 f8 03 STA &03f8,Y ; room_tiles ; consider_next_tile &299a c8 INY &299b c0 38 CPY #&38 &299d d0 be BNE &295d ; change_pipes_loop ; set_pipe_arrow_columns_status &299f a9 07 LDA #&07 &29a1 85 8f STA &8f ; column ; set_pipe_arrow_columns_status_loop &29a3 20 40 64 JSR &6440 ; rnd &29a6 09 10 ORA #&10 &29a8 a4 8f LDY &8f ; column &29aa 99 50 01 STA &0150,Y ; pipe_arrow_columns_status &29ad c6 8f DEC &8f ; column &29af 10 f2 BPL &29a3 ; set_pipe_arrow_columns_status_loop ; add_sign &29b1 a5 84 LDA &84 ; room_low_two &29b3 c9 f4 CMP #&f4 # Room &1f4 has a sign &29b5 d0 09 BNE &29c0 ; not_room_1f4 &29b7 a5 85 LDA &85 ; room_low_high &29b9 f0 05 BEQ &29c0 ; not_room_1f4 &29bb a9 87 LDA #&87 ; TILE_SIGN | COLOUR_2 &29bd 8d 23 04 STA &0423 ; room_tiles + 4 * 8 + 3 ; not_room_1f4 &29c0 a5 85 LDA &85 ; room_low_high &29c2 d0 0b BNE &29cf ; not_room_0ec &29c4 a5 84 LDA &84 ; room_low_two &29c6 c9 ec CMP #&ec # Room &0ec has a pipe next to a passage &29c8 d0 05 BNE &29cf ; not_room_0ec &29ca a9 94 LDA #&94 ; TILE_PIPE_BOTH | COLOUR_2 # Make it open on both sides &29cc 8d 25 04 STA &0425 ; room_tiles + 4 * 8 + 5 ; not_room_0ec &29cf a9 a0 LDA #&a0 &29d1 85 80 STA &80 ; subtile_address_low &29d3 a9 05 LDA #&05 ; &05a0 &29d5 85 81 STA &81 ; subtile_address_high &29d7 a9 00 LDA #&00 &29d9 85 82 STA &82 ; tile_screen_address_low &29db 85 65 STA &65 ; hopper_pad_screen_address_high &29dd 85 86 STA &86 ; tile_offset &29df a9 6d LDA #&6d ; &6d00 &29e1 85 83 STA &83 ; tile_screen_address_high ; plot_tiles_loop &29e3 a4 86 LDY &86 ; tile_offset &29e5 b9 00 04 LDA &0400,Y ; room_tiles &29e8 29 3f AND #&3f # Bottom six bits of tile type set sprite &29ea 85 8c STA &8c ; sprite_address_low &29ec b9 00 04 LDA &0400,Y ; room_tiles &29ef 29 c0 AND #&c0 # Top two bits of tile type set colour &29f1 0a ASL A &29f2 2a ROL A &29f3 2a ROL A &29f4 aa TAX &29f5 bd a7 2d LDA &2da7,X ; tile_colour_masks &29f8 85 8b STA &8b ; colour_mask &29fa a9 00 LDA #&00 &29fc 85 8d STA &8d ; sprite_address_high &29fe a5 8c LDA &8c ; sprite_address_low &2a00 0a ASL A &2a01 65 8c ADC &8c ; sprite_address_low &2a03 85 8c STA &8c ; sprite_address_low &2a05 06 8c ASL &8c ; sprite_address_low &2a07 26 8d ROL &8d ; sprite_address_high &2a09 06 8c ASL &8c ; sprite_address_low &2a0b 26 8d ROL &8d ; sprite_address_high &2a0d 06 8c ASL &8c ; sprite_address_low &2a0f 26 8d ROL &8d ; sprite_address_high &2a11 06 8c ASL &8c ; sprite_address_low &2a13 26 8d ROL &8d ; sprite_address_high &2a15 a5 8c LDA &8c ; sprite_address_low &2a17 69 34 ADC #&34 &2a19 85 8c STA &8c ; sprite_address_low &2a1b a5 8d LDA &8d ; sprite_address_high &2a1d 69 5a ADC #&5a ; &5a34 = tile_sprites - &30 &2a1f 85 8d STA &8d ; sprite_address_high &2a21 a5 82 LDA &82 ; tile_screen_address_low &2a23 85 8e STA &8e ; screen_address_low &2a25 a5 83 LDA &83 ; tile_screen_address_high &2a27 85 8f STA &8f ; screen_address_high &2a29 e0 00 CPX #&00 &2a2b d0 17 BNE &2a44 ; plot_two_colour_tile ; plot_four_colour_tile &2a2d b9 00 04 LDA &0400,Y ; room_tiles &2a30 d0 08 BNE &2a3a ; use_sprite &2a32 a9 80 LDA #&80 &2a34 85 8c STA &8c ; sprite_address_low &2a36 a9 6c LDA #&6c ; &6c80 = empty_sprite # Use an empty part of screen memory for empty tile &2a38 85 8d STA &8d ; sprite_address_high ; use_sprite &2a3a a2 04 LDX #&04 # 16 pixels wide &2a3c a0 03 LDY #&03 # 24 pixels high &2a3e 20 00 65 JSR &6500 ; plot_aligned_sprite_using_write &2a41 4c 88 2a JMP &2a88 ; consider_tile ; plot_two_colour_tile &2a44 a5 8d LDA &8d ; sprite_address_high &2a46 8d 5a 2a STA &2a5a ; plot_sprite_address_one_high &2a49 8d 6c 2a STA &2a6c ; plot_sprite_address_two_high &2a4c a5 8c LDA &8c ; sprite_address_low &2a4e 8d 59 2a STA &2a59 ; plot_sprite_address_one_low &2a51 8d 6b 2a STA &2a6b ; plot_sprite_address_two_low &2a54 a2 00 LDX #&00 ; plot_tile_x_loop &2a56 a0 00 LDY #&00 ; plot_tile_y_loop &2a58 bd 00 70 LDA &7000,X # actually LDA plot_sprite_address_one,X &2a5b 29 0f AND #&0f # Use bottom nibble for one row &2a5d 85 8d STA &8d ; sprite_address_high &2a5f 0a ASL A &2a60 0a ASL A &2a61 0a ASL A &2a62 0a ASL A &2a63 65 8d ADC &8d ; sprite_address_high &2a65 25 8b AND &8b ; colour_mask &2a67 91 8e STA (&8e),Y ; screen_address &2a69 c8 INY &2a6a bd 00 70 LDA &7000,X # actually LDA plot_sprite_address_two,X &2a6d 29 f0 AND #&f0 # Use top nibble for next row &2a6f 85 8d STA &8d ; sprite_address_high &2a71 4a LSR A &2a72 4a LSR A &2a73 4a LSR A &2a74 4a LSR A &2a75 65 8d ADC &8d ; sprite_address_high &2a77 25 8b AND &8b ; colour_mask &2a79 91 8e STA (&8e),Y ; screen_address &2a7b c8 INY &2a7c e8 INX &2a7d 8a TXA &2a7e 29 0f AND #&0f # 16 pixels wide &2a80 d0 d6 BNE &2a58 ; plot_tile_y_loop &2a82 e6 8f INC &8f ; screen_address_high # Move down eight pixels &2a84 e0 30 CPX #&30 &2a86 30 ce BMI &2a56 ; plot_tile_x_loop # 24 pixels high ; consider_tile &2a88 a4 86 LDY &86 ; tile_offset &2a8a b9 00 04 LDA &0400,Y ; room_tiles &2a8d 29 3f AND #&3f &2a8f c9 09 CMP #&09 ; TILE_HOPPER_PAD &2a91 f0 20 BEQ &2ab3 ; is_hopper_pad &2a93 c9 23 CMP #&23 ; TILE_SPACE_LOCK_LEFT &2a95 f0 04 BEQ &2a9b ; is_space_lock &2a97 c9 24 CMP #&24 ; TILE_SPACE_LOCK_RIGHT &2a99 d0 15 BNE &2ab0 ; to_plot_next_tile_after_setting_subtiles ; is_space_lock &2a9b 29 01 AND #&01 &2a9d 49 01 EOR #&01 &2a9f 0a ASL A &2aa0 a8 TAY &2aa1 0a ASL A &2aa2 0a ASL A &2aa3 0a ASL A &2aa4 65 8e ADC &8e ; scren_addess_low &2aa6 99 ac 00 STA &00ac,Y ; space_lock_entrance_screen_address_low &2aa9 a5 8f LDA &8f ; screen_address_high &2aab e9 01 SBC #&01 &2aad 99 ad 00 STA &00ad,Y ; space_lock_entrance_screen_address_high ; to_plot_next_tile_after_setting_subtiles &2ab0 4c 46 2b JMP &2b46 ; plot_next_tile_after_setting_subtiles ; is_hopper_pad &2ab3 38 SEC &2ab4 a5 8f LDA &8f ; screen_address_high &2ab6 e9 04 SBC #&04 # Move up thirty two pixels &2ab8 85 8f STA &8f ; screen_address_high &2aba e9 01 SBC #&01 # Move up eight pixels &2abc 85 65 STA &65 ; hopper_pad_screen_address_high &2abe a5 8e LDA &8e ; screen_address_low &2ac0 c9 20 CMP #&20 &2ac2 90 0a BCC &2ace ; skip_check &2ac4 a5 64 LDA &64 ; hopper_pad_screen_address_low # Is the hopper pad on leftmost tile? &2ac6 d0 06 BNE &2ace ; skip_check &2ac8 a0 eb LDY #&eb # If not, is the tile to the left empty &2aca b1 8e LDA (&8e),Y ; screen_address &2acc f0 5a BEQ &2b28 ; skip_plotting_hopper_pad_number # If so, don't plot hopper pad number ; skip_check ; get_modulo_three_loop &2ace a5 7e LDA &7e ; player_room_low # Number on hopper pad is room_low % 3 &2ad0 38 SEC &2ad1 e9 03 SBC #&03 &2ad3 c9 03 CMP #&03 &2ad5 b0 fa BCS &2ad1 ; get_modulo_three_loop &2ad7 0a ASL A &2ad8 0a ASL A &2ad9 0a ASL A &2ada 85 8b STA &8b ; sprite_offset &2adc a4 64 LDY &64 ; hopper_pad_screen_address_low ; plot_hopper_pad_number &2ade a6 8b LDX &8b ; sprite_offset ; plot_hopper_pad_number_loop &2ae0 bd 68 0a LDA &0a68,X ; hopper_pad_numbers &2ae3 91 8e STA (&8e),Y ; screen_address &2ae5 c8 INY &2ae6 e8 INX &2ae7 98 TYA &2ae8 29 07 AND #&07 &2aea c9 07 CMP #&07 &2aec d0 f2 BNE &2ae0 ; plot_hopper_pad_number_loop &2aee a9 11 LDA #&11 ; colour 3 right pixel &2af0 c0 07 CPY #&07 &2af2 f0 02 BEQ &2af6 ; set_row &2af4 a9 88 LDA #&88 ; colour 3 left pixel ; set_row &2af6 91 8e STA (&8e),Y ; screen_address_low # Set row underneath hopper pad number &2af8 38 SEC &2af9 a5 80 LDA &80 ; subtile_address_low &2afb e9 20 SBC #&20 # Move up one subtile &2afd 85 8c STA &8c ; above_subtile_address_low &2aff a5 81 LDA &81 ; subtile_address_high &2b01 e9 00 SBC #&00 &2b03 85 8d STA &8d ; above_subtile_address_high &2b05 98 TYA &2b06 29 18 AND #&18 &2b08 4a LSR A &2b09 4a LSR A &2b0a 4a LSR A &2b0b a8 TAY &2b0c a9 18 LDA #&18 ; SUBTILE_NO_ENEMIES | SUBTILE_NO_PLAYER # Set subtile for hopper pad number &2b0e 91 8c STA (&8c),Y ; above_subtile_address &2b10 c0 03 CPY #&03 &2b12 d0 14 BNE &2b28 ; skip_plotting_hopper_pad_number # Is the hopper pad number on the right? &2b14 a5 8e LDA &8e ; screen_address_low &2b16 c9 20 CMP #&20 &2b18 90 0e BCC &2b28 ; skip_plotting_hopper_pad_number # If so, and this isn't the leftmost tile &2b1a c6 8f DEC &8f ; screen_address_high &2b1c a0 f5 LDY #&f5 &2b1e b1 8e LDA (&8e),Y ; screen_address &2b20 e6 8f INC &8f ; screen_address_high &2b22 a0 00 LDY #&00 &2b24 c9 00 CMP #&00 # Is the tile to the left non-empty? &2b26 d0 b6 BNE &2ade ; plot_hopper_pad_number # If so, plot second hopper pad number on left ; skip_plotting_hopper_pad_number &2b28 a5 8e LDA &8e ; screen_address_low &2b2a 18 CLC &2b2b 69 08 ADC #&08 &2b2d 85 64 STA &64 ; hopper_pad_screen_address_low &2b2f 85 8e STA &8e ; screen_address_low &2b31 e6 8f INC &8f ; screen_address_high &2b33 a5 76 LDA &76 ; player_on_hopper &2b35 f0 0f BEQ &2b46 ; plot_next_tile_after_setting_subtiles # Is the player riding a hopper? &2b37 a9 20 LDA #&20 # If not, plot hopper in pad &2b39 85 8c STA &8c ; sprite_address_low &2b3b a9 41 LDA #&41 ; &4120 = hopper_frame_1 &2b3d 85 8d STA &8d ; sprite_address_high &2b3f a2 02 LDX #&02 # 8 pixels wide &2b41 a0 01 LDY #&01 # 8 pixels high &2b43 20 00 65 JSR &6500 ; plot_aligned_sprite_using_write ; plot_next_tile_after_setting_subtiles &2b46 20 82 25 JSR &2582 ; set_subtiles_from_tile &2b49 e6 86 INC &86 ; tile_offset &2b4b 18 CLC &2b4c a5 80 LDA &80 ; subtile_address_low &2b4e 69 04 ADC #&04 # Move left four subtiles, i.e. one tile &2b50 85 80 STA &80 ; subtile_address_low &2b52 90 02 BCC &2b56 ; skip_overflow &2b54 e6 81 INC &81 ; subtile_address_high ; skip_overflow &2b56 18 CLC &2b57 a5 82 LDA &82 ; tile_screen_address_low &2b59 69 20 ADC #&20 # Move right sixteen pixels, i.e. one tile &2b5b 85 82 STA &82 ; tile_screen_address_low &2b5d f0 03 BEQ &2b62 ; next_row ; to_plot_tiles_loop &2b5f 4c e3 29 JMP &29e3 ; plot_tiles_loop ; next_row &2b62 18 CLC &2b63 a5 80 LDA &80 ; subtile_address_low &2b65 69 40 ADC #&40 # Move down two more subtiles &2b67 85 80 STA &80 ; subtile_address_low # (first row was accounted for in previous loop) &2b69 90 02 BCC &2b6d ; skip_overflow &2b6b e6 81 INC &81 ; subtile_address_high ; skip_overflow &2b6d 18 CLC &2b6e a5 83 LDA &83 ; tile_screen_address_high &2b70 69 03 ADC #&03 # Move down twenty four pixels &2b72 85 83 STA &83 ; tile_screen_address_high &2b74 c9 7f CMP #&7f &2b76 d0 e7 BNE &2b5f ; to_plot_tiles_loop # Continue until end of screen ; check_passages &2b78 a9 26 LDA #&26 &2b7a 85 86 STA &86 ; passage_to_consider ; check_passages_loop &2b7c a6 86 LDX &86 ; passage_to_consider &2b7e bd d8 63 LDA &63d8,X ; passage_data # First byte of passage data is room_low &2b81 c5 84 CMP &84 ; room_low_two &2b83 d0 78 BNE &2bfd ; consider_next_passage &2b85 bd d9 63 LDA &63d9,X ; passage_data + 1 &2b88 29 01 AND #&01 # Lowest bit of second byte is room_high &2b8a c5 85 CMP &85 ; room_low_high &2b8c d0 6f BNE &2bfd ; consider_next_passage &2b8e bd d9 63 LDA &63d9,X ; passage_data + 1 &2b91 4a LSR A # Remaining bits of second byte are position of passage &2b92 20 e2 2c JSR &2ce2 ; convert_byte_to_screen_address &2b95 8a TXA &2b96 29 02 AND #&02 # Odd passages are offset by four pixels &2b98 0a ASL A &2b99 0a ASL A &2b9a 65 8e ADC &8e ; screen_address_low &2b9c 85 8e STA &8e ; screen_address_low &2b9e 85 4c STA &4c ; passage_screen_address_low &2ba0 a5 8f LDA &8f ; screen_address_high &2ba2 85 4d STA &4d ; passage_screen_address_high &2ba4 a9 6c LDA #&6c ; &6c80 = empty_sprite # Use an empty part of screen memory for passage &2ba6 85 8d STA &8d ; sprite_address_high &2ba8 a9 80 LDA #&80 &2baa 85 8c STA &8c ; sprite_address_low &2bac a2 03 LDX #&03 # Twelve pixels wide &2bae a0 02 LDY #&02 # Sixteen pixels high &2bb0 20 00 65 JSR &6500 ; plot_aligned_sprite_using_write ; clear_passage_subtiles &2bb3 a6 4c LDX &4c ; passage_screen_address_low &2bb5 a4 4d LDY &4d ; passage_screen_address_high &2bb7 20 e0 65 JSR &65e0 ; calculate_subtile_address_from_screen_address &2bba a0 00 LDY #&00 ; clear_passage_subtiles_loop &2bbc a9 00 LDA #&00 &2bbe 91 6b STA (&6b),Y ; subtile_address # Set subtile to be empty &2bc0 c8 INY &2bc1 98 TYA &2bc2 29 03 AND #&03 &2bc4 c9 03 CMP #&03 &2bc6 90 f4 BCC &2bbc ; clear_passage_subtiles &2bc8 98 TYA &2bc9 69 1c ADC #&1c # Move down one subtile &2bcb a8 TAY &2bcc c0 40 CPY #&40 &2bce 90 ec BCC &2bbc ; clear_passage_subtiles &2bd0 a5 4c LDA &4c ; passage_screen_address_low &2bd2 09 08 ORA #&08 &2bd4 85 4c STA &4c ; passage_screen_address_low &2bd6 a5 86 LDA &86 ; passage_to_consider &2bd8 49 02 EOR #&02 # Consider other end of passage &2bda aa TAX &2bdb bd d9 63 LDA &63d9,X ; passage_data + 1 &2bde 4a LSR A &2bdf 20 e2 2c JSR &2ce2 ; convert_byte_to_screen_address &2be2 8a TXA &2be3 29 02 AND #&02 &2be5 0a ASL A &2be6 0a ASL A &2be7 05 8e ORA &8e ; screen_address_low &2be9 85 4e STA &4e ; passage_destination_screen_address_low &2beb a5 8f LDA &8f ; screen_address_high &2bed 85 4f STA &4f ; passage_destination_screen_address_high &2bef bd d8 63 LDA &63d8,X ; passage_data &2bf2 85 4b STA &4b ; passage_destination_room_low &2bf4 8a TXA &2bf5 29 02 AND #&02 &2bf7 49 02 EOR #&02 &2bf9 09 01 ORA #&01 &2bfb 85 4a STA &4a ; passage_direction ; consider_next_passage &2bfd c6 86 DEC &86 ; passage_to_consider &2bff c6 86 DEC &86 ; passage_to_consider &2c01 30 03 BMI &2c06 ; check_for_items &2c03 4c 7c 2b JMP &2b7c ; check_passages_loop ; check_for_items &2c06 a9 00 LDA #&00 &2c08 85 8d STA &8d ; item_offset &2c0a a9 00 LDA #&00 &2c0c 85 8a STA &8a ; item_data_address_low &2c0e a9 0c LDA #&0c ; &0c00 = item_data &2c10 85 8b STA &8b ; item_data_address_high &2c12 a2 02 LDX #&02 &2c14 a5 7e LDA &7e ; player_room_low &2c16 d0 04 BNE &2c1c ; check_for_items_loop &2c18 a5 7f LDA &7f ; player_room_high &2c1a f0 1e BEQ &2c3a ; to_plot_core_elements # No items in room &000 ; check_for_items_loop &2c1c a4 8d LDY &8d ; item_offset &2c1e b1 8a LDA (&8a),Y ; item_data_address &2c20 c5 84 CMP &84 ; room_low_two &2c22 d0 0b BNE &2c2f ; consider_next_item &2c24 c8 INY &2c25 b1 8a LDA (&8a),Y ; item_data_address &2c27 29 80 AND #&80 &2c29 0a ASL A &2c2a 2a ROL A &2c2b c5 85 CMP &85 ; room_low_high &2c2d f0 0d BEQ &2c3c ; item_is_in_room ; consider_next_item &2c2f e6 8d INC &8d ; item_to_consider &2c31 e6 8d INC &8d ; item_to_consider &2c33 d0 e7 BNE &2c1c ; check_for_items_loop &2c35 e6 8b INC &8b ; item_data_address_high &2c37 ca DEX &2c38 d0 e2 BNE &2c1c ; check_for_items_loop ; to_plot_core_elements &2c3a f0 60 BEQ &2c9c ; plot_core_elements # Always branches ; item_is_in_room &2c3c 86 8c STX &8c ; unused # Unnecessary code &2c3e a5 8d LDA &8d ; item_to_consider &2c40 85 53 STA &53 ; room_item_data_address_low &2c42 a5 8b LDA &8b ; item_data_address_high &2c44 85 54 STA &54 ; room_item_data_address_high &2c46 b1 8a LDA (&8a),Y ; item_data_address &2c48 48 PHA &2c49 29 3f AND #&3f &2c4b 48 PHA &2c4c 20 e2 2c JSR &2ce2 ; convert_byte_to_screen_address &2c4f 18 CLC &2c50 a5 8e LDA &8e ; screen_address_low &2c52 69 08 ADC #&08 &2c54 85 8e STA &8e ; screen_address_low &2c56 46 8b LSR &8b ; item_data_address_high &2c58 a5 8d LDA &8d ; item_to_consider &2c5a 6a ROR A &2c5b 6a ROR A &2c5c 29 f0 AND #&f0 &2c5e 85 8c STA &8c ; this_item_sprite &2c60 a9 53 LDA #&53 &2c62 85 8d STA &8d ; this_item_unused # Unnecessary code &2c64 68 PLA &2c65 aa TAX &2c66 bc 00 04 LDY &0400,X ; room_tiles &2c69 f0 02 BEQ &2c6d ; empty_tile &2c6b c6 8f DEC &8f ; screen_address_high # Move up eight pixels if item is in spark head ; empty_tile &2c6d 68 PLA &2c6e 29 40 AND #&40 &2c70 0a ASL A &2c71 2a ROL A &2c72 2a ROL A &2c73 85 8b STA &8b ; this_item_colour_mask &2c75 a5 84 LDA &84 ; item_data_address_high &2c77 29 01 AND #&01 &2c79 0a ASL A &2c7a 05 8b ORA &8b ; this_item_colour_mask &2c7c aa TAX &2c7d bd de 2c LDA &2cde,X ; room_item_colours &2c80 85 8b STA &8b ; this_item_colour_mask &2c82 a0 04 LDY #&04 ; copy_item_data_loop # Set room_item_colour_mask, &2c84 b9 8b 00 LDA &008b,Y ; this_item_data # room_item_sprite, &2c87 99 55 00 STA &0055,Y ; room_item_data # room_item_unused, &2c8a 88 DEY # room_item_screen_address_low and &2c8b 10 f7 BPL &2c84 ; copy_item_data_loop # room_item_screen_address_high &2c8d a5 8c LDA &8c ; this_item_sprite &2c8f 4a LSR A &2c90 4a LSR A &2c91 4a LSR A &2c92 4a LSR A &2c93 85 56 STA &56 ; room_item_sprite &2c95 a6 8b LDX &8b ; room_item_colour &2c97 a0 ff LDY #&ff # EOR &2c99 20 b3 0b JSR &0bb3 ; plot_packed_two_colour_sprite # Plot item ; plot_core_elements &2c9c a9 00 LDA #&00 &2c9e 85 88 STA &88 ; core_element_to-consider ; plot_core_elements_loop &2ca0 a4 88 LDY &88 ; core_element_to-consider &2ca2 b9 28 05 LDA &0528,Y ; core_elements_data + 0 # First byte of core element data is room_low &2ca5 c5 7e CMP &7e ; player_room_low &2ca7 d0 1f BNE &2cc8 ; consider_next_core_element &2ca9 b9 29 05 LDA &0529,Y ; core_elements_data + 1 &2cac 29 03 AND #&03 # Lowest two bits of second byte is room_high &2cae c5 7f CMP &7f ; player_room_high &2cb0 d0 16 BNE &2cc8 ; consider_next_core_element &2cb2 b9 29 05 LDA &0529,Y ; core_elements_data + 1 &2cb5 29 f8 AND #&f8 # Remaining bits of second byte are screen_address_low &2cb7 85 8e STA &8e ; screen_address_low &2cb9 b9 2a 05 LDA &052a,Y ; core_elements_data + 2 # Third byte of core element data is screen_address_high &2cbc 85 8f STA &8f ; screen_address_high &2cbe b9 2b 05 LDA &052b,Y ; core_elements_data + 3 # Fourth byte of core element data is sprite &2cc1 a2 ff LDX #&ff # White &2cc3 a0 ff LDY #&ff # EOR &2cc5 20 b3 0b JSR &0bb3 ; plot_packed_two_colour_sprite # Plot core element ; consider_next_core_element &2cc8 18 CLC &2cc9 a5 88 LDA &88 ; core_element_to-consider &2ccb 69 04 ADC #&04 &2ccd 85 88 STA &88 ; core_element_to-consider &2ccf c9 50 CMP #&50 &2cd1 d0 cd BNE &2ca0 ; plot_core_elements_loop ; wipe_room_tiles_loop &2cd3 a0 3f LDY #&3f &2cd5 a9 00 LDA #&00 &2cd7 99 00 04 STA &0400,Y ; room_tiles # Used for bridging platform data &2cda 88 DEY &2cdb 10 f8 BPL &2cd5 ; wipe_room_tiles_loop &2cdd 60 RTS ; room_item_colours ; 3 1 2 1 &2cde ff 0f f0 0f ; convert_byte_to_screen_address &2ce2 48 PHA &2ce3 4a LSR A &2ce4 4a LSR A &2ce5 4a LSR A &2ce6 85 8e STA &8e ; screen_address_low &2ce8 0a ASL A &2ce9 65 8e ADC &8e ; screen_address_low &2ceb 69 6e ADC #&6e &2ced 85 8f STA &8f ; screen_address_high &2cef 68 PLA &2cf0 29 07 AND #&07 &2cf2 4a LSR A &2cf3 6a ROR A &2cf4 6a ROR A &2cf5 6a ROR A &2cf6 85 8e STA &8e ; screen_address_low &2cf8 60 RTS ; add_additional_walls &2cf9 a9 02 LDA #&02 &2cfb 85 8d STA &8d ; extra_offset ; add_additional_walls_loop &2cfd a4 8d LDY &8d ; extra_offset &2cff b1 80 LDA (&80),Y ; room_data_address &2d01 29 3f AND #&3f &2d03 c9 30 CMP #&30 &2d05 b0 11 BCS &2d18 ; to_consider_next_more &2d07 85 8c STA &8c ; tile_offset &2d09 a5 8d LDA &8d ; extra_offset &2d0b 29 02 AND #&02 &2d0d f0 0c BEQ &2d1b ; is_four_or_five # For the first set of extras, &2d0f a4 8d LDY &8d ; extra_offset &2d11 b9 aa 2d LDA &2daa,Y ; room_extras_types - 2 &2d14 c9 0f CMP #&0f ; EXTRA_RECTANGLE # add rectangles if type is EXTRA_RECTANGLE &2d16 f0 0c BEQ &2d24 ; find_extent_of_rectangle ; to_consider_next_extra &2d18 4c 7d 2d JMP &2d7d ; consider_next_extra ; is_four_or_five &2d1b a4 8d LDY &8d ; extra_offset # For the second set of extras, &2d1d b9 aa 2d LDA &2daa,Y ; room_additional_wall_types - 4 &2d20 c9 0f CMP #&0f ; NOT_ADDITIONAL_WALL # skip rectangles if additional wall type if &0f &2d22 f0 f4 BEQ &2d18 ; to_consider_next_extra # (extras were added earlier) ; find_extent_of_rectangle &2d24 a9 01 LDA #&01 # Start with a 1x1 rectangle &2d26 85 8a STA &8a ; width &2d28 85 8b STA &8b ; height ; extend_vertically &2d2a a6 8c LDX &8c ; tile_offset ; extend_vertically_loop # Extend vertically &2d2c bd 00 04 LDA &0400,X ; room_tiles &2d2f d0 0d BNE &2d3e ; find_horizontal_extent # Stop at non-empty tile &2d31 e0 30 CPX #&30 &2d33 b0 09 BCS &2d3e ; find_horizontal_extent # Stop at bottom of screen &2d35 e6 8b INC &8b ; height &2d37 8a TXA &2d38 69 08 ADC #&08 &2d3a aa TAX &2d3b 4c 2c 2d JMP &2d2c ; extend_vertically_loop ; find_horizontal_extent &2d3e a6 8c LDX &8c ; tile_offset ; extend_horizontally_loop # Extend horizontally &2d40 e8 INX &2d41 8a TXA &2d42 29 07 AND #&07 &2d44 f0 0f BEQ &2d55 ; skip_removing_tile # Stop at right edge of screen &2d46 bd 00 04 LDA &0400,X ; room_tiles &2d49 d0 05 BNE &2d50 ; remove_tile # Stop at non-empty tile &2d4b e6 8a INC &8a ; width &2d4d 4c 40 2d JMP &2d40 ; extend_horizontally_loop ; remove_tile &2d50 a9 00 LDA #&00 ; TILE_EMPTY # Remove the tile that marked the size of the rectangle &2d52 9d 00 04 STA &0400,X ; room_tiles ; skip_removing_tile &2d55 a5 8d LDA &8d ; extra_offset &2d57 29 01 AND #&01 &2d59 aa TAX &2d5a bc ae 2d LDY &2dae,X ; room_additional_wall_types &2d5d b9 89 2d LDA &2d89,Y ; additional_wall_tiles_table &2d60 85 88 STA &88 ; wall_tile ; add_rectangle_column_loop &2d62 a5 8a LDA &8a ; width &2d64 85 89 STA &89 ; row_length &2d66 a6 8c LDX &8c ; tile_offset ; add_rectangle_row_loop &2d68 a5 88 LDA &88 ; wall_tile &2d6a 9d 00 04 STA &0400,X ; room_tiles &2d6d e8 INX &2d6e c6 89 DEC &89 ; row_length &2d70 d0 f6 BNE &2d68 ; add_rectangle_row_loop &2d72 18 CLC &2d73 a5 8c LDA &8c ; tile_offset &2d75 69 08 ADC #&08 &2d77 85 8c STA &8c ; tile_offset &2d79 c6 8b DEC &8b ; height &2d7b d0 e5 BNE &2d62 ; add_rectangle_column_loop ; consider_next_extra &2d7d e6 8d INC &8d ; extra_offset &2d7f a5 8d LDA &8d ; extra_offset &2d81 c9 06 CMP #&06 &2d83 f0 03 BEQ &2d88 ; leave &2d85 4c fd 2c JMP &2cfd ; add_additional_walls_loop ; leave &2d88 60 RTS ; additional_wall_tiles_table &2d89 d8 ; &00 TILE_STARS | COLOUR_3 &2d8a 82 ; &01 TILE_WALL_WISPS | COLOUR_2 &2d8b 81 ; &02 TILE_WALL_EARTH | COLOUR_2 &2d8c 00 ; &03 TILE_EMPTY &2d8d 00 ; &04 TILE_EMPTY &2d8e 84 ; &05 TILE_WALL_MOLECULES | COLOUR_2 &2d8f 1d ; &06 TILE_PLANT_BRANCHES # &0f NOT_ADDITIONAL_WALL ; primary_wall_tiles_table &2d90 41 ; &00 TILE_WALL_EARTH | COLOUR_1 &2d91 42 ; &01 TILE_WALL_WISPS | COLOUR_1 &2d92 43 ; &02 TILE_WALL_STONES | COLOUR_1 &2d93 44 ; &03 TILE_WALL_MOLECULES | COLOUR_1 &2d94 45 ; &04 TILE_WALL_SQUARES | COLOUR_1 &2d95 46 ; &05 TILE_WALL_RECTANGLES | COLOUR_1 &2d96 1d ; &06 TILE_PLANT_BRANCHES &2d97 88 ; &07 TILE_WALL_TWIN | COLOUR_2 ; extra_tiles_table &2d98 c9 ; &00 EXTRA_HOPPER : TILE_HOPPER_PAD | COLOUR_3 &2d99 ca ; &01 EXTRA_TILE_HORIZONTAL_GATE : TILE_HORIZONTAL_GATE | COLOUR_3 &2d9a cb ; &02 EXTRA_SPARK_GATE : TILE_SPARK_GATE | COLOUR_3 &2d9b cc ; &03 EXTRA_SPARK_HEAD : TILE_SPARK_HEAD | COLOUR_3 &2d9c cd ; &04 EXTRA_MUSHROOM : TILE_MUSHROOM | COLOUR_3 &2d9d e1 ; &05 EXTRA_THREE_HEADED_DOME : TILE_THREE_HEADED_DOME | COLOUR_3 &2d9e ce ; &06 EXTRA_SKELETONAUT : TILE_SKELETONAUT_LEFT | COLOUR_3 &2d9f 46 ; &07 EXTRA_SPACE_LOCK : TILE_WALL_RECTANGLES | COLOUR_1 &2da0 d0 ; &08 EXTRA_DOME : TILE_DOME | COLOUR_3 &2da1 d1 ; &09 EXTRA_SPIKE : TILE_SPIKE | COLOUR_3 &2da2 00 ; &0a EXTRA_ALTAR : TILE_EMPTY &2da3 00 ; &0b (unused) : TILE_EMPTY &2da4 00 ; &0c (unused) : TILE_EMPTY &2da5 1d ; &0d EXTRA_PLANT : TILE_PLANT_BRANCHES &2da6 93 ; &0e EXTRA_PIPE : TILE_PIPE_CLOSED | COLOUR_2 # &0f EXTRA_RECTANGLE ; tile_colour_masks ; 0 1 2 3 &2da7 00 0f f0 ff ; room_primary_wall_type &2dab 00 ; room_extras_types &2dac 00 00 ; room_additional_wall_types &2dae 00 00 ; unused &2db0 00 ; room_colours_from_bits ; R Y C M &2db1 01 03 06 05 # Subtile flags # ============= # 1 SUBTILE_GATE # 2 SUBTILE_HIDE_PLAYER # 4 SUBTILE_PIPE # 8 SUBTILE_NO_PLAYER # 10 SUBTILE_NO_ENEMIES # 20 (unused) # 40 SUBTILE_DEADLY # 80 (unused) ; subtile_flags_table &2db5 00 ; &00 &2db6 18 ; &01 SUBTILE_NO_ENEMIES | SUBTILE_NO_PLAYER &2db7 40 ; &02 SUBTILE_DEADLY &2db8 16 ; &03 SUBTILE_NO_ENEMIES | SUBTILE_PIPE | SUBTILE_HIDE_PLAYER &2db9 19 ; &04 SUBTILE_NO_ENEMIES | SUBTILE_NO_PLAYER | SUBTILE_GATE &2dba 1e ; &05 SUBTILE_NO_ENEMIES | SUBTILE_NO_PLAYER | SUBTILE_PIPE | SUBTILE_HIDE_PLAYER &2dbb 14 ; &06 SUBTILE_NO_ENEMIES | SUBTILE_PIPE &2dbc 10 ; &07 SUBTILE_NO_ENEMIES ; add_enemy &2dbd a9 0f LDA #&0f &2dbf 85 8d STA &8d ; attempts &2dc1 a0 00 LDY #&00 ; find_free_slot_loop &2dc3 b9 89 01 LDA &0189,Y ; enemies_screen_address_high &2dc6 f0 07 BEQ &2dcf ; found_empty_slot &2dc8 18 CLC &2dc9 98 TYA &2dca 69 0c ADC #&0c &2dcc a8 TAY &2dcd d0 f4 BNE &2dc3 ; find_free_slot_loop ; found_empty_slot &2dcf 84 86 STY &86 ; enemy_offset ; try_again &2dd1 c6 8d DEC &8d ; attempts &2dd3 d0 01 BNE &2dd6 ; try_to_add_enemy &2dd5 60 RTS ; try_to_add_enemy &2dd6 20 76 2e JSR &2e76 ; rnd_for_enemy # Choose a random y position &2dd9 a5 9b LDA &9b ; rnd_2 &2ddb 29 1f AND #&1f &2ddd c9 11 CMP #&11 &2ddf b0 f0 BCS &2dd1 ; try_again &2de1 69 6d ADC #&6d &2de3 85 8f STA &8f ; screen_address_high &2de5 20 76 2e JSR &2e76 ; rnd_for_enemy # Choose a random x position &2de8 a5 9b LDA &9b ; rnd_2 &2dea 29 f8 AND #&f8 &2dec c9 f8 CMP #&f8 &2dee b0 e1 BCS &2dd1 ; try_again &2df0 85 8e STA &8e ; screen_address_low &2df2 a5 8f LDA &8f ; screen_address_high &2df4 c9 6f CMP #&6f &2df6 90 0e BCC &2e06 ; check_tile &2df8 c9 7c CMP #&7c &2dfa b0 0a BCS &2e06 ; check_tile &2dfc a5 8e LDA &8e ; screen_address_low &2dfe c9 18 CMP #&18 &2e00 90 04 BCC &2e06 ; check_tile &2e02 c9 e8 CMP #&e8 &2e04 90 cb BCC &2dd1 ; try_again ; check_tile &2e06 a6 8e LDX &8e ; screen_address_low &2e08 a4 8f LDY &8f ; screen_address_high &2e0a 20 89 2e JSR &2e89 ; check_if_new_enemy_can_go_in_subtiles &2e0d b0 c2 BCS &2dd1 ; try_again # Check enemy can go in tile &2e0f a5 8e LDA &8e ; screen_address_low &2e11 9d 88 01 STA &0188,X ; enemies_screen_address_low &2e14 a5 8f LDA &8f ; screen_address_high &2e16 9d 89 01 STA &0189,X ; enemies_screen_address_high &2e19 a9 00 LDA #&00 ; ENEMY_MATERIALISATION &2e1b 9d 8a 01 STA &018a,X ; enemies_type &2e1e 9d 8e 01 STA &018e,X ; enemies_behaviour # Enemy bounces off walls &2e21 9d 92 01 STA &0192,X ; enemies_animation &2e24 9d 93 01 STA &0193,X ; enemies_materialising &2e27 a9 01 LDA #&01 # Make enemy move on next update &2e29 9d 8f 01 STA &018f,X ; enemies_move_cooldown &2e2c 9d 90 01 STA &0190,X ; enemies_homing_cooldown &2e2f a9 14 LDA #&14 # Set enemy materialising &2e31 9d 91 01 STA &0191,X ; enemies_materialisation_timer &2e34 20 76 2e JSR &2e76 ; rnd_for_enemy # Choose a random diagonal direction &2e37 29 03 AND #&03 &2e39 a8 TAY &2e3a b9 7c 2e LDA &2e7c,Y ; random_directions &2e3d 9d 8b 01 STA &018b,X ; enemies_direction ; choose_random_maximum_move_cooldown &2e40 20 76 2e JSR &2e76 ; rnd_for_enemy # Choose a random number between 1 and 3 &2e43 29 03 AND #&03 &2e45 f0 f9 BEQ &2e40 ; choose_random_maximum_move_cooldown &2e47 a8 TAY &2e48 b9 7e 2e LDA &2e7e,Y ; inertias - 1 # corresponding to an inertia of 6, 4 or 8 &2e4b 9d 8c 01 STA &018c,X ; enemies_inertia ; choose_random_maximum_homing_cooldown &2e4e 20 76 2e JSR &2e76 ; rnd_for_enemy # Choose a random number between 0 and 4 &2e51 29 07 AND #&07 &2e53 c9 05 CMP #&05 &2e55 b0 f7 BCS &2e4e ; choose_random_maximum_homing_cooldown &2e57 a8 TAY &2e58 b9 84 2e LDA &2e84,Y ; maximum_homing_cooldowns # corresponding to cooldown of 2, 4, 8, 16 or 32 &2e5b 9d 8d 01 STA &018d,X ; enemies_maximum_homing_cooldown &2e5e a2 4c LDX #&4c &2e60 a0 60 LDY #&60 ; &604c = enemy_materialising_sound &2e62 20 3d 35 JSR &353d ; play_sound &2e65 c6 2f DEC &2f ; new_enemies_needed &2e67 a9 c0 LDA #&c0 &2e69 85 8c STA &8c ; sprite_address_low &2e6b a9 39 LDA #&39 ; &39c0 = enemy_materialising_frame_1 &2e6d 85 8d STA &8d ; sprite_address_high &2e6f a2 03 LDX #&03 # 12 pixels wide &2e71 a0 02 LDY #&02 # 16 pixels high &2e73 4c ad 65 JMP &65ad ; plot_aligned_sprite_using_eor ; rnd_for_enemy &2e76 20 40 64 JSR &6440 ; rnd &2e79 a6 86 LDX &86 ; enemy_to_consider &2e7b 60 RTS ; random_directions &2e7c 03 ; ENEMY_RIGHT | ENEMY_DOWN &2e7d 0c ; ENEMY_LEFT | ENEMY_UP &2e7e 09 ; ENEMY_RIGHT | ENEMY_UP ; intertias &2e7f 06 ; ENEMY_LEFT | ENEMY_DOWN &2e80 04 ; ENEMY_DOWN &2e81 08 ; ENEMY_UP &2e82 02 ; ENEMY_LEFT &2e83 01 ; ENEMY_RIGHT ; maximum_homing_cooldowns &2e84 02 04 08 10 20 ; check_if_new_enemy_can_go_in_subtiles &2e89 a2 20 LDX #&20 # Enemies are two subtiles high &2e8b a0 02 LDY #&02 # and three subtiles wide ; check_if_enemy_can_go_in_subtiles &2e8d 86 8a STX &8a ; height &2e8f 84 8b STY &8b ; width &2e91 a6 8e LDX &8e ; screen_address_low &2e93 a4 8f LDY &8f ; screen_address_high &2e95 20 e0 65 JSR &65e0 ; calculate_subtile_address_from_screen_address &2e98 a6 86 LDX &86 ; check_if_enemy_can_go_in_subtiles_column_loop &2e9a a5 8b LDA &8b ; width &2e9c 05 8a ORA &8a ; height &2e9e a8 TAY ; check_if_enemy_can_go_in_subtiles_row_loop &2e9f b1 6b LDA (&6b),Y ; subtile_address &2ea1 29 10 AND #&10 ; SUBTILE_NO_ENEMIES &2ea3 d0 0f BNE &2eb4 ; leave_with_carry_set &2ea5 88 DEY # Move left a subtile &2ea6 c4 8a CPY &8a ; start_offset &2ea8 10 f5 BPL &2e9f ; check_if_enemy_can_go_in_subtiles_row_loop &2eaa 38 SEC &2eab a5 8a LDA &8a ; height &2ead e9 20 SBC #&20 # Move up a subtile &2eaf 85 8a STA &8a ; height &2eb1 b0 e7 BCS &2e9a ; check_if_enemy_can_go_in_subtiles_column_loop ; leave_with_carry_clear # Leave with carry clear if all subtiles are passable &2eb3 60 RTS ; leave_with_carry_set # Leave with carry set if any subtile contains a wall &2eb4 38 SEC &2eb5 60 RTS ; update_enemies &2eb6 85 44 STA &44 ; only_unplot_enemies &2eb8 a9 00 LDA #&00 &2eba 85 86 STA &86 ; enemy_to_consider &2ebc 85 20 STA &20 ; player_touching_death ; update_enemies_loop &2ebe a6 86 LDX &86 ; enemy_to_consider &2ec0 bd 89 01 LDA &0189,X ; enemies_screen_address_high &2ec3 85 41 STA &41 ; enemy_previous_screen_address_high &2ec5 c9 6d CMP #&6d # Is there an enemy in this slot? &2ec7 90 20 BCC &2ee9 ; to_consider_next_enemy &2ec9 a5 44 LDA &44 ; only_unplot_enemies &2ecb d0 1f BNE &2eec ; to_unplot_enemy_at_current_position &2ecd bd 88 01 LDA &0188,X ; enemies_screen_address_low &2ed0 85 40 STA &40 ; enemy_previous_screen_address_low &2ed2 bd 8a 01 LDA &018a,X ; enemies_type &2ed5 85 42 STA &42 ; enemy_previous_type &2ed7 bd 92 01 LDA &0192,X ; enemies_animation &2eda 85 43 STA &43 ; enemy_previous_animation &2edc bd 8f 01 LDA &018f,X ; enemies_move_cooldown &2edf e9 04 SBC #&04 &2ee1 9d 8f 01 STA &018f,X ; enemies_move_cooldown &2ee4 90 09 BCC &2eef ; move_enemy &2ee6 4c 9f 30 JMP &309f ; skip_moving_enemy ; to_consider_next_enemy &2ee9 4c a0 31 JMP &31a0 ; consider_next_enemy ; to_unplot_enemy_at_current_position &2eec 4c 89 31 JMP &3189 ; unplot_enemy_at_current_position ; move_enemy &2eef 7d 8c 01 ADC &018c,X ; enemies_inertia &2ef2 9d 8f 01 STA &018f,X ; enemies_move_cooldown &2ef5 bd 89 01 LDA &0189,X ; enemies_screen_address_high &2ef8 85 8f STA &8f ; screen_address_high &2efa bd 92 01 LDA &0192,X ; enemies_animation &2efd 85 8d STA &8d ; enemy_animation ; move_enemy_horizontally &2eff bd 88 01 LDA &0188,X ; enemies_screen_address_low &2f02 85 8e STA &8e ; screen_address_low &2f04 bd 8b 01 LDA &018b,X ; enemies_direction &2f07 29 05 AND #&05 ; ENEMY_LEFT | ENEMY_RIGHT &2f09 c9 01 CMP #&01 ; ENEMY_RIGHT &2f0b f0 20 BEQ &2f2d ; move_enemy_right &2f0d c9 04 CMP #&04 ; ENEMY_LEFT &2f0f d0 59 BNE &2f6a ; move_enemy_vertically ; move_enemy_left &2f11 c6 8d DEC &8d ; enemy_animation &2f13 10 29 BPL &2f3e ; check_horizontal_move &2f15 a9 03 LDA #&03 &2f17 85 8d STA &8d ; enemy_animation &2f19 38 SEC &2f1a a5 8e LDA &8e ; screen_address_low # Move left two pixels &2f1c e9 08 SBC #&08 &2f1e 85 8e STA &8e ; screen_address_low &2f20 b0 1c BCS &2f3e ; check_horizontal_move ; flip_horizontal_direction &2f22 bd 8b 01 LDA &018b,X ; enemies_direction &2f25 49 05 EOR #&05 ; ENEMY_LEFT | ENEMY_RIGHT &2f27 9d 8b 01 STA &018b,X ; enemies_direction &2f2a 4c 6a 2f JMP &2f6a ; move_enemy_vertically ; move_enemy_right &2f2d e6 8d INC &8d ; enemy_animation &2f2f a5 8d LDA &8d ; enemy_animation &2f31 29 03 AND #&03 &2f33 85 8d STA &8d ; enemy_animation &2f35 d0 07 BNE &2f3e ; check_horizontal_move &2f37 18 CLC &2f38 a5 8e LDA &8e ; screen_address_low # Move right two pixels &2f3a 69 08 ADC #&08 &2f3c 85 8e STA &8e ; screen_address_low ; check_horizontal_move &2f3e a0 02 LDY #&02 # Three subtiles wide &2f40 a5 8d LDA &8d ; enemy_animation &2f42 d0 01 BNE &2f45 ; skip_subtile_horizontally &2f44 88 DEY # or two, depending on animation frame ; skip_subtile_horizontally &2f45 a2 20 LDX #&20 # Two subtiles high &2f47 a5 8e LDA &8e ; screen_address_low &2f49 29 07 AND #&07 &2f4b f0 02 BEQ &2f4f ; skip_subtile_vertically &2f4d a2 40 LDX #&40 # or four, if straddling group &2f4f 20 8d 2e JSR &2e8d ; check_if_enemy_can_go_in_subtiles &2f52 a6 86 LDX &86 ; enemy_to_consider &2f54 b0 cc BCS &2f22 ; flip_horizontal_direction # Flip direction if enemy has hit wall &2f56 a5 8e LDA &8e ; screen_address_low &2f58 c9 f0 CMP #&f0 &2f5a 90 04 BCC &2f60 ; set_animation &2f5c a5 8d LDA &8d ; enemy_animation &2f5e d0 c2 BNE &2f22 ; flip_direction # Flip direction if enemy has hit edge of screen ; set_animation &2f60 a5 8d LDA &8d ; enemy_animation &2f62 9d 92 01 STA &0192,X ; enemies_animation &2f65 a5 8e LDA &8e ; screen_address_low &2f67 9d 88 01 STA &0188,X ; enemies_screen_address_low ; move_enemy_vertically &2f6a bd 88 01 LDA &0188,X ; enemies_screen_address_low &2f6d 85 8e STA &8e ; screen_address_low &2f6f bd 89 01 LDA &0189,X ; enemies_screen_address_high &2f72 85 8f STA &8f ; screen_address_high &2f74 bd 8b 01 LDA &018b,X ; enemies_direction &2f77 29 0a AND #&0a ; ENEMY_DOWN | ENEMY_UP &2f79 c9 02 CMP #&02 ; ENEMY_DOWN &2f7b f0 25 BEQ &2fa2 ; move_enemy_down &2f7d c9 08 CMP #&08 ; ENEMY_UP &2f7f d0 67 BNE &2fe8 ; skip_vertical_move ; move_enemy_up &2f81 a5 8e LDA &8e ; screen_address_low # Move up two pixels &2f83 e9 02 SBC #&02 &2f85 85 8e STA &8e ; screen_address_low &2f87 29 06 AND #&06 &2f89 c9 06 CMP #&06 &2f8b 90 28 BCC &2fb5 ; check_vertical_move &2f8d a5 8e LDA &8e ; screen_address_low &2f8f 69 07 ADC #&07 &2f91 85 8e STA &8e ; screen_address_low &2f93 c6 8f DEC &8f ; screen_address_high &2f95 d0 1e BNE &2fb5 ; check_vertical_move ; flip_vertical_direction &2f97 bd 8b 01 LDA &018b,X ; enemies_direction &2f9a 49 0a EOR #&0a ; ENEMY_DOWN | ENEMY_UP &2f9c 9d 8b 01 STA &018b,X ; enemies_direction &2f9f 4c e8 2f JMP &2fe8 ; skip_vertical_move ; move_enemy_down &2fa2 18 CLC &2fa3 a5 8e LDA &8e ; screen_address_low # Move down two pixels &2fa5 69 02 ADC #&02 &2fa7 85 8e STA &8e ; screen_address_low &2fa9 29 07 AND #&07 &2fab d0 08 BNE &2fb5 ; check_vertical_move &2fad a5 8e LDA &8e ; screen_address_low &2faf e9 07 SBC #&07 &2fb1 85 8e STA &8e ; screen_address_low &2fb3 e6 8f INC &8f ; screen_address_high ; check_vertical_move &2fb5 a0 01 LDY #&01 # Two subtiles wide &2fb7 bd 92 01 LDA &0192,X ; enemies_animation &2fba f0 01 BEQ &2fbd ; skip_horizontal_subtile &2fbc c8 INY # or three, depending on animation frame ; skip_horizontal_subtile &2fbd a2 20 LDX #&20 # Two subtiles high &2fbf a5 8e LDA &8e ; screen_address_low &2fc1 29 07 AND #&07 &2fc3 f0 02 BEQ &2fc7 ; skip_vertical_subtile &2fc5 a2 40 LDX #&40 # or three, if straddling group ; skip_vertical_subtile &2fc7 20 8d 2e JSR &2e8d ; check_if_enemy_can_go_in_subtiles &2fca a6 86 LDX &86 ; enemy_to_consider &2fcc b0 c9 BCS &2f97 ; flip_vertical_direction # Flip direction if enemy has hit wall &2fce a5 8f LDA &8f ; screen_address_high &2fd0 c9 6d CMP #&6d &2fd2 90 c3 BCC &2f97 ; flip_vertical_direction # Flip direction if enemy has hit top of screen &2fd4 c9 7d CMP #&7d &2fd6 90 06 BCC &2fde ; skip_flip_check &2fd8 a5 8e LDA &8e &2fda 29 07 AND #&07 &2fdc d0 b9 BNE &2f97 ; flip_vertical_direction # Flip direction if enemy has hit bottom of screen ; skip_flip_check &2fde a5 8e LDA &8e ; screen_address_low &2fe0 9d 88 01 STA &0188,X ; enemies_screen_address_low &2fe3 a5 8f LDA &8f ; screen_address_high &2fe5 9d 89 01 STA &0189,X ; enemies_screen_address_high ; skip_vertical_move &2fe8 bd 93 01 LDA &0193,X ; enemies_materialising &2feb d0 2c BNE &3019 ; skip_materialisation &2fed bd 91 01 LDA &0191,X ; enemies_materialisation_timer &2ff0 f0 27 BEQ &3019 ; skip_materialisation &2ff2 de 91 01 DEC &0191,X ; enemies_materialisation_timer &2ff5 d0 22 BNE &3019 ; skip_materialisation ; set_random_behaviour &2ff7 20 76 2e JSR &2e76 ; rnd_for_enemy # Get random number between 0 and 4 for behaviour &2ffa c9 05 CMP #&05 &2ffc b0 f9 BCS &2ff7 ; set_random_behaviour &2ffe 9d 8e 01 STA &018e,X ; enemies_behaviour &3001 c9 04 CMP #&04 ; BEHAVIOUR_4 # If BEHAVIOUR_4, enemy is a droid &3003 d0 09 BNE &300e ; not_droid &3005 20 76 2e JSR &2e76 ; rnd_for_enemy # Make droids half as likely to occur &3008 29 02 AND #&02 &300a f0 eb BEQ &2ff7 ; set_random_behaviour &300c d0 05 BNE &3013 ; set_enemy_type # Always branches ; not_droid &300e 20 76 2e JSR &2e76 ; rnd_for_enemy # Choose random enemy type &3011 29 01 AND #&01 ; set_enemy_type &3013 18 CLC &3014 69 01 ADC #&01 &3016 9d 8a 01 STA &018a,X ; enemies_type ; skip_materialisation &3019 a6 86 LDX &86 ; enemy_to_consider &301b de 90 01 DEC &0190,X ; enemies_homing_cooldown &301e d0 7f BNE &309f ; skip_homing_towards_player &3020 bd 8d 01 LDA &018d,X ; enemies_maximum_homing_cooldown &3023 9d 90 01 STA &0190,X ; enemies_homing_cooldown &3026 bd 8e 01 LDA &018e,X ; enemies_behaviour &3029 f0 74 BEQ &309f ; skip_homing_towards_player # BEHAVIOUR_0 bounces off walls &302b c9 03 CMP #&03 &302d 90 4a BCC &3079 ; set_random_direction # BEHAVIOUR_1 and BEHAVIOUR_2 move randomly &302f d0 5f BNE &3090 ; move_droid ; move_enemy_towards_player # BEHAVIOUR_3 moves towards player &3031 a0 00 LDY #&00 &3033 a5 70 LDA &70 ; player_screen_address_low &3035 29 f8 AND #&f8 &3037 dd 88 01 CMP &0188,X ; enemies_screen_address_low &303a 90 13 BCC &304f ; enemy_right_of_player &303c f0 02 BEQ &3040 ; enemy_horizontally_aligned_with_player &303e b0 09 BCS &3049 ; enemy_left_of_player ; enemy_horizontally_aligned_with_player &3040 20 76 2e JSR &2e76 ; rnd_for_enemy &3043 a0 00 LDY #&00 &3045 29 01 AND #&01 &3047 f0 06 BEQ &304f ; enemy_right_of_player ; enemy_left_of_player &3049 98 TYA &304a 09 01 ORA #&01 ; ENEMY_RIGHT &304c a8 TAY &304d d0 04 BNE &3053 ; consider_vertical_position ; enemy_right_of_player &304f 98 TYA &3050 09 04 ORA #&04 : ENEMY_LEFT &3052 a8 TAY ; consider_vertical_position &3053 a5 71 LDA &71 ; player_screen_address_high &3055 dd 89 01 CMP &0189,X ; enemies_screen_address_high &3058 90 15 BCC &306f ; enemy_below_player &305a f0 02 BEQ &305e ; enemy_vertically_aligned_with_player &305c b0 0b BCS &3069 ; enemy_above_player ; enemy_vertically_aligned_with_player &305e 84 8f STY &8f ; tmp &3060 20 76 2e JSR &2e76 ; rnd_for_enemy &3063 a4 8f LDY &8f ; tmp &3065 29 01 AND #&01 &3067 f0 06 BEQ &306f ; enemy_below_player ; enemy_above_player &3069 98 TYA &306a 09 02 ORA #&02 ; ENEMY_DOWN &306c a8 TAY &306d d0 04 BNE &3073 ; set_direction # Always branches ; enemy_below_player &306f 98 TYA &3070 09 08 ORA #&08 ; ENEMY_UP &3072 a8 TAY ; set_direction &3073 98 TYA &3074 9d 8b 01 STA &018b,X ; enemies_direction &3077 d0 26 BNE &309f ; skip_homing_towards_player # Always branches ; set_random_direction &3079 a8 TAY &307a b9 8d 30 LDA &308d,Y ; direction_ranges &307d 85 8f STA &8f ; tmp &307f 20 76 2e JSR &2e76 ; rnd_for_enemy &3082 25 8f AND &8f ; tmp &3084 a8 TAY &3085 b9 7c 2e LDA &2e7c,Y ; random_directions_table &3088 9d 8b 01 STA &018b,X ; enemies_direction &308b d0 12 BNE &309f ; skip_homing_towards_player ; direction_ranges &308d 07 ; (droids) : all directions &308e 07 ; (BEHAVIOUR_1) : all directions &308f 03 ; (BEHAVIOUR_2) : diagonals only ; move_droid &3090 20 76 2e JSR &2e76 ; rnd_for_enemy # Returns a random number between &00 and &0f &3093 4a LSR A &3094 c9 03 CMP #&03 &3096 f0 99 BEQ &3031 ; move_enemy_towards_player # 1 in 8 chance of droid moving towards player &3098 a9 00 LDA #&00 &309a 90 dd BCC &3079 ; set_random_direction # 3 in 8 chance of changing to a random direction &309c 9d 8b 01 STA &018b,X ; enemies_direction # 1 in 2 chance of stopping ; skip_homing_towards_player ; skip_moving_enemy &309f a5 7b LDA &7b ; fire_hit_something &30a1 d0 44 BNE &30e7 ; enemy_not_hit_by_fire # Only one enemy can be hit at once &30a3 bd 8a 01 LDA &018a,X ; enemies_type &30a6 c9 04 CMP #&04 ; ENEMY_DEMATERIALISING &30a8 b0 3d BCS &30e7 ; enemy_not_hit_by_fire # Dematerialising enemies can't be hit &30aa a5 7c LDA &7c ; fire_screen_address_low &30ac 29 f8 AND #&f8 &30ae e9 0f SBC #&0f &30b0 b0 02 BCS &30b4 ; skip_floor &30b2 a9 00 LDA #&00 ; skip_floor &30b4 dd 88 01 CMP &0188,X ; enemies_screen_address_low &30b7 b0 2e BCS &30e7 ; enemy_not_hit_by_fire &30b9 a5 7c LDA &7c ; fire_screen_address_low &30bb 29 f8 AND #&f8 &30bd 69 08 ADC #&08 &30bf 90 02 BCC &30c3 ; skip_ceiling &30c1 a9 ff LDA #&ff ; skip_ceiling &30c3 dd 88 01 CMP &0188,X ; enemies_screen_address_low &30c6 90 1f BCC &30e7 ; enemy_not_hit_by_fire &30c8 bd 89 01 LDA &0189,X ; enemies_screen_address_high &30cb 69 01 ADC #&01 &30cd c5 7d CMP &7d ; fire_screen_address_high &30cf 90 16 BCC &30e7 ; enemy_not_hit_by_fire &30d1 a4 76 LDY &76 ; player_on_hopper &30d3 c0 01 CPY #&01 # Fire from hopper is twice as high &30d5 e9 03 SBC #&03 &30d7 c5 7d CMP &7d ; fire_screen_address_high &30d9 b0 0c BCS &30e7 ; enemy_not_hit_by_fire &30db a9 04 LDA #&04 ; ENEMY_DEMATERIALISING &30dd 85 7b STA &7b ; fire_hit_something &30df 9d 8a 01 STA &018a,X ; enemies_type # Set enemey dematerialising &30e2 a9 14 LDA #&14 &30e4 9d 93 01 STA &0193,X ; enemies_materialising ; enemy_not_hit_by_fire &30e7 bd 93 01 LDA &0193,X ; enemies_materialising &30ea f0 32 BEQ &311e ; enemy_not_dematerialising &30ec c9 13 CMP #&13 &30ee d0 09 BNE &30f9 ; skip_score &30f0 a2 50 LDX #&50 # Score 150 for destroying an enemy &30f2 a0 01 LDY #&01 &30f4 20 4f 35 JSR &354f ; increase_score &30f7 a6 86 LDX &86 ; enemy_to_consider ; skip_score &30f9 de 93 01 DEC &0193,X ; enemies_materialising &30fc d0 20 BNE &311e ; enemy_not_dematerialising &30fe 20 af 31 JSR &31af ; unplot_enemy # Remove enemy &3101 a5 2e LDA &2e ; new_enemies_cooldown &3103 30 09 BMI &310e ; skip_new_enemy &3105 e6 2f INC &2f ; new_enemies_needed # Spawn a new enemy &3107 20 76 2e JSR &2e76 ; rnd_for_enemy &310a 09 20 ORA #&20 &310c 85 2e STA &2e ; new_enemies_cooldown # after a random delay ; skip_new_enemy &310e a6 86 LDX &86 ; enemy_to_consider &3110 a0 0c LDY #&0c &3112 a9 00 LDA #&00 ; wipe_enemy_loop &3114 9d 88 01 STA &0188,X ; enemies_screen_address_low &3117 e8 INX &3118 88 DEY &3119 d0 f9 BNE &3114 ; wipe_enemy_loop &311b 4c a0 31 JMP &31a0 ; consider_next_enemy ; enemy_not_dematerialising &311e bd 8a 01 LDA &018a,X ; enemies_type &3121 f0 47 BEQ &316a ; enemy_not_touching_player &3123 c9 04 CMP #&04 ; ENEMY_DEMATERIALISING &3125 b0 43 BCS &316a ; enemy_not_touching_player # Dematerialising enemies can't harm player &3127 bd 88 01 LDA &0188,X ; enemies_screen_address_low &312a 29 f8 AND #&f8 &312c 85 8e STA &8e ; screen_address_low &312e a5 70 LDA &70 ; player_screen_address_low &3130 29 f8 AND #&f8 &3132 e9 0f SBC #&0f &3134 90 04 BCC &313a ; skip_left_check &3136 c5 8e CMP &8e ; screen_address_low &3138 b0 30 BCS &316a ; enemy_not_touching_player ; skip_left_check &313a 69 18 ADC #&18 &313c c5 8e CMP &8e ; screen_address_low &313e 90 2a BCC &316a ; enemy_not_touching_player &3140 a5 71 LDA &71 ; player_screen_address_high &3142 e9 02 SBC #&02 &3144 dd 89 01 CMP &0189,X ; enemies_screen_address_high &3147 b0 21 BCS &316a ; enemy_not_touching_player &3149 69 03 ADC #&03 &314b dd 89 01 CMP &0189,X ; enemies_screen_address_high &314e 90 1a BCC &316a ; enemy_not_touching_player ; enemy_touching_player &3150 a5 3a LDA &3a ; player_energy_low &3152 e9 2a SBC #&2a # Drain &002a energy for touching enemy &3154 85 3a STA &3a ; player_energy_low &3156 b0 02 BCS &315a ; skip_underflow &3158 c6 3b DEC &3b ; player_energy_high ; skip_underflow &315a bd 8a 01 LDA &018a,X ; enemies_type &315d c9 03 CMP #&03 ; ENEMY_DROID # Is the enemy a droid? &315f d0 09 BNE &316a ; enemy_not_touching_player &3161 bd 8e 01 LDA &018e,X ; enemies_behaviour # If the enemy is a patrolling droid, behaviour is 0, &3164 4a LSR A # otherwise behaviour is 4 &3165 4a LSR A &3166 09 02 ORA #&02 ; TOUCHING_DROID # or TOUCHING_NON_PATROLLING_DROID &3168 85 20 STA &20 ; player_touching_death # Kill player ; enemy_not_touching_player &316a bd 88 01 LDA &0188,X ; enemies_screen_address_low # Has the enemy moved? &316d c5 40 CMP &40 ; enemy_previous_screen_address_low &316f d0 15 BNE &3186 ; replot_enemy &3171 bd 89 01 LDA &0189,X ; enemies_screen_address_high &3174 c5 41 CMP &41 ; enemy_previous_screen_address_high &3176 d0 0e BNE &3186 ; replot_enemy &3178 bd 8a 01 LDA &018a,X ; enemies_type &317b c5 42 CMP &42 ; enemy_previous_type &317d d0 07 BNE &3186 ; replot_enemy &317f bd 92 01 LDA &0192,X ; enemies_animation &3182 c5 43 CMP &43 ; enemy_previous_animation &3184 f0 1a BEQ &31a0 ; skip_replotting_enemy ; replot_enemy &3186 20 af 31 JSR &31af ; unplot_enemy # IF so, unplot enemy at old position ; unplot_enemy_at_current_position &3189 a6 86 LDX &86 ; enemy_to_consider &318b bd 88 01 LDA &0188,X ; enemies_screen_address_low &318e 85 8e STA &8e ; screen_address_low &3190 bd 89 01 LDA &0189,X ; enemies_screen_address_high &3193 85 8f STA &8f ; screen_address_high &3195 bd 92 01 LDA &0192,X ; enemies_animation &3198 a8 TAY &3199 bd 8a 01 LDA &018a,X ; enemies_type &319c aa TAX &319d 20 bb 31 JSR &31bb ; plot_enemy # Replot enemy at new position ; skip_replotting_enemy ; consider_next_enemy &31a0 18 CLC &31a1 a5 86 LDA &86 ; enemy_to_consider &31a3 69 0c ADC #&0c &31a5 85 86 STA &86 ; enemy_to_consider &31a7 c9 30 CMP #&30 &31a9 b0 03 BCS &31ae ; leave &31ab 4c be 2e JMP &2ebe ; update_enemies_loop ; leave &31ae 60 RTS ; unplot_enemy &31af a5 40 LDA &40 ; enemy_previous_screen_address_low &31b1 85 8e STA &8e ; screen_address_low &31b3 a5 41 LDA &41 ; enemy_previous_screen_address_high &31b5 85 8f STA &8f ; screen_address_high &31b7 a6 42 LDX &42 ; enemy_previous_type &31b9 a4 43 LDY &43 ; enemy_previous_animation ; plot_enemy &31bb 8a TXA &31bc 0a ASL A &31bd 0a ASL A &31be 85 8c STA &8c ; sprite_address_low &31c0 98 TYA &31c1 05 8c ORA &8c ; sprite_address_low &31c3 0a ASL A &31c4 85 8c STA &8c ; sprite_address_low &31c6 0a ASL A &31c7 65 8c ADC &8c ; sprite_address_low &31c9 85 8c STA &8c ; sprite_address_low &31cb a9 00 LDA #&00 &31cd 85 8d STA &8d ; sprite_address_high &31cf 06 8c ASL &8c ; sprite_address_low &31d1 26 8d ROL &8d ; sprite_address_high &31d3 06 8c ASL &8c ; sprite_address_low &31d5 26 8d ROL &8d ; sprite_address_high &31d7 06 8c ASL &8c ; sprite_address_low &31d9 26 8d ROL &8d ; sprite_address_high &31db a5 8c LDA &8c ; sprite_address_low &31dd 69 c0 ADC #&c0 &31df 85 8c STA &8c ; sprite_address_low &31e1 a5 8d LDA &8d ; sprite_address_high &31e3 69 39 ADC #&39 ; &39c0 = enemy_sprites &31e5 85 8d STA &8d ; sprite_address_high &31e7 a2 03 LDX #&03 # 12 pixels wide &31e9 a0 02 LDY #&02 # 16 pixels high &31eb 4c 26 65 JMP &6526 ; plot_unaligned_sprite ; game_over_screen &31ee 08 PHP &31ef 20 24 35 JSR &3524 ; flush_buffers &31f2 20 63 35 JSR &3563 ; set_core_element_colours &31f5 a5 25 LDA &25 ; game_time_high # Poke time into game over text &31f7 20 13 35 JSR &3513 ; convert_number_to_two_digits_in_x_and_y &31fa 8c f0 33 STY &33f0 ; game_over_text + &65 &31fd 8e f1 33 STX &33f1 ; game_over_text + &66 &3200 a5 24 LDA &24 ; game_time_low &3202 20 13 35 JSR &3513 ; convert_number_to_two_digits_in_x_and_y &3205 8c f3 33 STY &33f3 ; game_over_text + &68 &3208 8e f4 33 STX &33f4 ; game_over_text + &69 &320b a0 07 LDY #&07 ; copy_game_over_palette_loop &320d b9 0b 35 LDA &350b,Y ; game_over_palette # Hide status section &3210 99 90 00 STA &0090,Y ; palette &3213 88 DEY &3214 10 f7 BPL &320d ; copy_game_over_palette_loop &3216 20 78 34 JSR &3478 ; clear_screen &3219 20 00 7f JSR &7f00 ; to_set_screen_colours &321c a9 07 LDA #&07 # R7: Vertical sync position &321e 8d 00 fe STA &fe00 ; video register number &3221 a9 24 LDA #&24 # Balance screen for hidden status section &3223 8d 01 fe STA &fe01 ; video register value &3226 a9 0f LDA #&0f &3228 8d 6a 7f STA &7f6a ; timer2_msb &322b 28 PLP # Carry set if game completed &322c 90 17 BCC &3245 ; game_not_completed &322e a2 f6 LDX #&f6 &3230 a0 33 LDY #&33 ; &33f6 = ending_text &3232 20 80 0a JSR &0a80 ; plot_text # Completion text &3235 a9 00 LDA #&00 &3237 a2 79 LDX #&79 ; &7900 &3239 20 87 35 JSR &3587 ; plot_full_core_array &323c a2 7b LDX #&7b ; ending_tune &323e a0 14 LDY #&14 &3240 a9 0e LDA #&0e &3242 20 91 34 JSR &3491 ; play_tune ; game_not_completed &3245 a5 9f LDA &9f ; core_elements_placed # Poke core elements into game over text &3247 18 CLC &3248 69 61 ADC #&61 ; "a" &324a 8d ba 33 STA &33ba ; game_over_text + &2f &324d a5 0c LDA &0c ; adventure_score + 1 # Poke adventure score into game over text &324f 20 13 35 JSR &3513 ; convert_number_to_two_digits_in_x_and_y &3252 8e df 33 STX &33df ; game_over_text + &54 &3255 8c de 33 STY &33de ; game_over_text + &55 &3258 a5 46 LDA &46 ; score # Poke score into game over text &325a 20 13 35 JSR &3513 ; convert_number_to_two_digits_in_x_and_y &325d 8c c5 33 STY &33c5 ; game_over_text + &3a &3260 8e c6 33 STX &33c6 ; game_over_text + &3b &3263 a5 47 LDA &47 ; score + 1 &3265 20 13 35 JSR &3513 ; convert_number_to_two_digits_in_x_and_y &3268 8c c7 33 STY &33c7 ; game_over_text + &3c &326b 8e c8 33 STX &33c8 ; game_over_text + &3d &326e a5 48 LDA &48 ; score + 2 &3270 20 13 35 JSR &3513 ; convert_number_to_two_digits_in_x_and_y &3273 8c c9 33 STY &33c9 ; game_over_text + &3e &3276 20 78 34 JSR &3478 ; clear_screen &3279 a2 8b LDX #&8b &327b a0 33 LDY #&33 ; &338b = game_over_text &327d 20 80 0a JSR &0a80 ; plot_text # Game over text &3280 a9 40 LDA #&40 &3282 a2 79 LDX #&79 ; &7940 &3284 20 87 35 JSR &3587 ; plot_full_core_array &3287 a2 50 LDX #&50 ; game_over_tune &3289 a0 14 LDY #&14 &328b a9 07 LDA #&07 &328d 20 91 34 JSR &3491 ; play_tune ; title_screen &3290 20 78 34 JSR &3478 ; clear_screen &3293 a2 03 LDX #&03 &3295 a0 33 LDY #&33; &3303 = title_screen_text &3297 20 80 0a JSR &0a80 ; plot_text &329a a2 00 LDX #&00 ; title_tune &329c a0 14 LDY #&14 &329e a9 0a LDA #&0a &32a0 20 91 34 JSR &3491 ; play_tune # Returns character pressed if tune ended &32a3 d0 0a BNE &32af ; process_keypress ; title_screen_loop &32a5 a2 53 LDX #&53 &32a7 a0 33 LDY #&33 ; &3353 = input_methods_text &32a9 20 80 0a JSR &0a80 ; plot_text &32ac 20 e0 ff JSR &ffe0 ; OSRDCH # Wait for character ; process_keypress &32af 38 SEC &32b0 e9 30 SBC #&30 ; "0" &32b2 f0 2e BEQ &32e2 ; zero_pressed &32b4 c9 04 CMP #&04 &32b6 b0 ed BCS &32a5 ; title_screen_loop &32b8 e9 00 SBC #&00 &32ba 85 8f STA &8f ; tmp &32bc 0a ASL A &32bd 0a ASL A &32be 65 8f ADC &8f ; tmp &32c0 c5 0a CMP &0a ; input_method &32c2 f0 e1 BEQ &32a5 ; title_screen_loop &32c4 85 0a STA &0a ; input_method &32c6 0a ASL A &32c7 0a ASL A &32c8 a8 TAY &32c9 a9 82 LDA #&82 ; COLOUR 2 &32cb 8d 53 33 STA &3353 ; input_methods_text &32ce 8d 67 33 STA &3367 ; input_methods_text + &14 &32d1 8d 7b 33 STA &337b ; input_methods_text + &28 &32d4 a9 81 LDA #&81 ; COLOUR 1 # Highlight selected input method &32d6 99 53 33 STA &3353,Y ; input_methods_text &32d9 20 24 35 JSR &3524 ; flush_buffers &32dc 20 24 0e JSR &0e24 ; play_enter_teleport_sound &32df 4c a5 32 JMP &32a5 ; title_screen_loop ; zero_pressed &32e2 a2 2c LDX #&2c ; start_game_tune &32e4 a0 14 LDY #&14 &32e6 a9 07 LDA #&07 &32e8 20 91 34 JSR &3491 ; play_tune &32eb 20 78 34 JSR &3478 ; clear_screen &32ee a9 07 LDA #&07 # R7: Vertical sync position &32f0 8d 00 fe STA &fe00 ; video register number &32f3 a9 1e LDA #&1e # Balance screen for visible status section &32f5 8d 01 fe STA &fe01 ; video register value &32f8 a9 1b LDA #&1b &32fa 8d 6a 7f STA &7f6a ; timer2_msb &32fd 20 1c 11 JSR &111c ; start_game &3300 4c ee 31 JMP &31ee ; game_over_screen ; title_screen_text &3303 83 ; COLOUR 3 &3304 1f 0a 0a ; TAB(&0a, &0a) &3307 53 5d 54 5d 41 5d 52 5d 51 5d 55 5d 41 5d 4b 5d ; "S-T-A-R-Q-U-A-K-E" &3317 45 &3318 1f 0f 14 ; TAB(&0f, &14) &331b 42 59 00 00 4b 45 4e 54 4f 4e 00 00 50 52 49 43 ; "BY KENTON PRICE" &332b 45 &332c 1f 0b 15 ; TAB(&0b, &14) &332f 43 5e 62 6a 69 68 00 00 42 55 42 42 4c 45 00 00 ; "C.1987 BUBBLE BUS" &33ff 42 55 53 &3342 82 ; COLOUR 2 &3343 1f 0e 11 ; TAB(&0e, &11) &3346 61 5e 00 53 54 41 52 54 5b 47 41 4d 45 ; "0. START GAME" ; input_methods_text &3353 81 ; COLOUR 1 &3354 1f 0e 0d ; TAB(&0e, &0d) &3357 62 5e 00 4b 45 59 42 4f 41 52 44 5b 5a 58 6b 6c ; "1. KEYBOARD ZX=/" &3367 82 ; COLOUR 2 &3368 1f 0e 0e ; TAB(&0e, &0e) &336b 63 5e 00 4b 45 59 42 4f 41 52 44 5b 55 5e 44 5e ; "2. KEYBOARD U.D." &337b 82 ; COLOUR 2 &337c 1f 0e 0f ; TAB(&0e, &0f) &337f 64 5e 00 4a 4f 59 53 54 49 43 4b ; "3. JOYSTICK" &338a 0d ; game_over_text &338b 1f 18 07 &338e 83 &338f 47 41 4d 45 5b 4f 56 45 52 ; "GAME OVER" &3398 1f 12 12 &339b 82 &339c 43 4f 52 45 ; "CORE" &33a0 1f 0a 13 &33a3 45 4c 45 4d 45 4e 54 53 ; "ELEMENTS" &33ab 1f 0a 14 &33ae 52 45 50 4c 41 43 45 44 ; "PLACED" &33b6 1f 16 16 &33b9 61 61 ; "00" &33bb 81 &33bc 1f 14 0a &33bf 53 43 4f 52 45 5b 61 61 61 61 61 ; "SCORE 00000" &33cc 1f 04 0c &33cd 41 44 56 45 4e 54 55 52 45 00 00 53 43 4f 52 45 ; "ADVENTURE SCORE 00" &33dd 5b 61 61 60 &33e1 1f 0b 0e &33e4 54 49 4d 45 00 00 54 41 4b 45 4e 5b 61 61 6b 61 ; "TIME TAKEN 00:00" &33f4 61 &33f5 0d ; ending_text &33f6 82 &33f7 1f 08 06 &33fa 54 48 45 5b 43 4f 52 45 53 5b 43 4f 4d 50 4c 45 ; "THE CORES COMPLETE" &340a 54 45 &340c 1f 02 08 &340f 42 55 54 5b 48 4f 57 5b 41 52 45 5b 59 4f 55 5b ; "BUT HOW ARE YOU GONNA" &341f 47 4f 4e 4e 41 &3424 1f 04 0a &3427 47 45 54 5b 48 4f 4d 45 5b 57 48 45 4e 5b 4f 4e ; "GET HOME WHEN ONLY A" &3437 4c 59 5b 41 &343b 1f 06 0c &343e 54 48 54 55 50 49 44 5b 4c 4f 4f 4e 59 5b 57 4f ; "THTUPID LOONY WOULD" &344e 55 4c 44 &3451 1f 06 0e &3454 57 41 4e 44 45 52 5b 54 48 49 53 5b 46 41 52 5b ; "WANDER THIS FAR OUT" &3464 4f 55 54 &3467 1f 12 10 &346a 49 4e 5b 54 48 45 5b 47 41 4c 41 58 59 ; "IN THE GALAXY" &3477 0d ; clear_screen &3478 a9 00 LDA #&00 &347a 85 8e STA &8e ; screen_address_low &347c a9 6d LDA #&6d ; &6d00 &347e 85 8f STA &8f ; screen_address_high ; clear_screen_page_loop &3480 a9 00 LDA #&00 &3482 a8 TAY ; clear_screen_loop &3483 91 8e STA (&8e),Y ; screen_address # Wipe &6d00 - &7fff &3485 c8 INY &3486 d0 fb BNE &3483 ; clear_screen_loop &3488 e6 8f INC &8f ; screen_address_high &348a a5 8f LDA &8f ; screen_address_high &348c c9 7f CMP #&7f &348e d0 f0 BNE &3480 ; clear_screen_page_loop &3490 60 RTS ; play_tune &3491 86 8c STX &8c ; tune_offset &3493 85 8d STA &8d ; speed &3495 84 8f STY &8f ; pitch_change &3497 a2 6f LDX #&6f &3499 a0 04 LDY #&04 ; &046f = tune_envelope &349b a9 08 LDA #&08 ; Define a sound envelope (ENVELOPE) &349d 20 f1 ff JSR &fff1 ; OSWORD ; play_tune_loop &34a0 a6 8c LDX &8c ; tune_offset &34a2 bd 7d 04 LDA &047d,X ; tune_data &34a5 c9 ff CMP #&ff # &ff marks end of tune &34a7 f0 53 BEQ &34fc ; leave_after_flushing_buffers &34a9 48 PHA &34aa 29 1f AND #&1f &34ac 0a ASL A &34ad 0a ASL A &34ae 65 8f ADC &8f ; pitch_change &34b0 8d 07 35 STA &3507 ; tune_sound + 4 # Set pitch &34b3 68 PLA &34b4 29 e0 AND #&e0 &34b6 0a ASL A &34b7 2a ROL A &34b8 2a ROL A &34b9 2a ROL A &34ba 69 01 ADC #&01 &34bc 85 8b STA &8b ; note_length &34be a6 8d LDX &8d ; speed &34c0 a9 00 LDA #&00 ; lengthen_note_loop &34c2 65 8b ADC &8b ; note_length &34c4 ca DEX &34c5 d0 fb BNE &34c2 ; lengthen_note_loop &34c7 85 8b STA &8b ; note_length &34c9 a9 11 LDA #&11 &34cb 8d 03 35 STA &3503 ; tune_sound # Set channel ; play_note_loop &34ce a2 03 LDX #&03 &34d0 a0 35 LDY #&35 ; &3503 = tune_sound &34d2 a9 07 LDA #&07 ; Generate a sound (SOUND) &34d4 20 f1 ff JSR &fff1 ; OSWORD &34d7 ee 03 35 INC &3503 ; tune_sound # Next channel &34da ee 07 35 INC &3507 ; tune_sound + 4 &34dd ad 03 35 LDA &3503 ; tune_sound &34e0 c9 14 CMP #&14 # Play note on channels 1 - 3 &34e2 d0 ea BNE &34ce ; play_note_loop ; wait_for_next_note &34e4 a9 81 LDA #&81 ; Wait for input character &34e6 a2 00 LDX #&00 &34e8 a0 00 LDY #&00 &34ea 20 f4 ff JSR &fff4 ; OSBYTE # Returns X = character &34ed 90 0d BCC &34fc ; leave_after_flushing_buffers # Leave if a key is pressed &34ef a9 13 LDA #&13 ; Wait for v-sync &34f1 20 f4 ff JSR &fff4 ; OSBYTE &34f4 c6 8b DEC &8b ; note_length &34f6 d0 ec BNE &34e4 ; wait_for_next_note &34f8 e6 8c INC &8c ; tune_offset &34fa d0 a4 BNE &34a0 ; play_tune_loop ; leave_after_flushing_buffers &34fc 8a TXA &34fd 48 PHA &34fe 20 24 35 JSR &3524 ; flush_buffers &3501 68 PLA &3502 60 RTS # Leave with character pressed, or zero if tune ended ; tune_sound ; chan vol pitch dur &3503 11 00 04 00 00 00 19 00 ; game_over_palette # Use red, green and white for game over screen, &350b 00 00 00 01 00 02 00 07 # hide status section ; convert_number_to_two_digits_in_x_and_y &3513 48 PHA &3514 29 0f AND #&0f &3516 18 CLC &3517 69 61 ADC #&61 ; "a" &3519 aa TAX &351a 68 PLA &351b 4a LSR A &351c 4a LSR A &351d 4a LSR A &351e 4a LSR A &351f 18 CLC &3520 69 61 ADC #&61 ; "a" &3522 a8 TAY &3523 60 RTS ; flush_buffers &3524 a9 0f LDA #&0f ; Flush all buffers &3526 a2 00 LDX #&00 &3528 4c f4 ff JMP &fff4 ; OSBYTE ; play_sound_using_envelope &352b 18 CLC &352c 8a TXA &352d 69 0e ADC #&0e &352f 48 PHA &3530 98 TYA &3531 69 00 ADC #&00 &3533 48 PHA &3534 a9 08 LDA #&08 ; Define a sound envelope (ENVELOPE) &3536 20 f1 ff JSR &fff1 ; OSWORD &3539 68 PLA &353a a8 TAY &353b 68 PLA &353c aa TAX ; play_sound &353d a9 07 LDA #&07 ; Generate a sound (SOUND) &353f 4c f1 ff JMP &fff1 ; OSWORD ; wait_for_a_frames &3542 48 PHA &3543 a9 13 LDA #&13 ; Wait for v-sync &3545 20 f4 ff JSR &fff4 ; OSBYTE &3548 68 PLA &3549 38 SEC &354a e9 01 SBC #&01 &354c d0 f4 BNE &3542 ; wait_for_a_frames &354e 60 RTS ; increase_score &354f 18 CLC &3550 f8 SED &3551 8a TXA &3552 65 48 ADC &48 ; score + 2 &3554 85 48 STA &48 ; score + 2 &3556 98 TYA &3557 65 47 ADC &47 ; score + 1 &3559 85 47 STA &47 ; score + 1 &355b a5 46 LDA &46 ; score &355d 69 00 ADC #&00 &355f 85 46 STA &46 ; score &3561 d8 CLD &3562 60 RTS ; set_core_element_colours &3563 a0 08 LDY #&08 ; set_core_element_colours_loop &3565 a9 ff LDA #&ff &3567 b6 17 LDX &17,Y ; core_elements_required &3569 30 03 BMI &356e ; set_colour &356b b9 75 35 LDA &3575,Y ; initial_core_element_colours ; set_colour &356e 99 f7 0b STA &0bf7,Y ; core_elements_colours &3571 88 DEY &3572 10 f1 BPL &3565 ; set_core_element_colours_loop &3574 60 RTS ; initial_core_element_colours ; 2 1 2 1 2 1 2 1 2 &3575 f0 0f f0 0f f0 0f f0 0f f0 ; core_elements_plotted &357e 00 00 00 00 00 00 00 00 00 ; plot_full_core_array &3587 48 PHA &3588 a0 08 LDY #&08 ; mark_elements_as_unplotted_loop &358a a9 01 LDA #&01 # Not a colour to indicate core element needs plotting &358c 99 7e 35 STA &357e,Y ; core_elements_plotted &358f 88 DEY &3590 10 f8 BPL &358a ; mark_elements_as_unplotted_loop &3592 68 PLA ; plot_partial_core_array &3593 85 69 STA &69 ; row_screen_address_low &3595 86 89 STX &89 ; row_screen_address_high &3597 a9 00 LDA #&00 &3599 85 87 STA &87 ; core_element_to_plot ; plot_core_elements_column_loop &359b a9 68 LDA #&68 &359d 85 88 STA &88 ; element_screen_address_low ; plot_core_elements_row_loop &359f 18 CLC &35a0 a5 88 LDA &88 ; element_screen_address_low &35a2 65 69 ADC &69 ; row_screen_address_low &35a4 85 8e STA &8e ; screen_address_low &35a6 a5 89 LDA &89 ; row_screen_address_high &35a8 85 8f STA &8f ; screen_address_high &35aa a4 87 LDY &87 ; core_element_to_plot &35ac b9 f7 0b LDA &0bf7,Y ; core_elements_colours &35af d9 7e 35 CMP &357e,Y ; core_elements_plotted &35b2 f0 09 BEQ &35bd ; skip_element &35b4 aa TAX &35b5 b9 17 00 LDA &0017,Y ; core_elements_required &35b8 a0 00 LDY #&00 # Overwrite screen &35ba 20 b3 0b JSR &0bb3 ; plot_packed_two_colour_sprite ; skip_element &35bd e6 87 INC &87 ; core_element_to_plot &35bf 18 CLC &35c0 a5 88 LDA &88 ; element_screen_address_low &35c2 69 10 ADC #&10 &35c4 85 88 STA &88 ; element_screen_address_low &35c6 c9 98 CMP #&98 &35c8 90 d5 BCC &359f ; plot_core_elements_row_loop &35ca e6 89 INC &89 ; row_screen_address_high &35cc e6 89 INC &89 ; row_screen_address_high &35ce a5 87 LDA &87 ; core_element_to_plot &35d0 c9 09 CMP #&09 &35d2 90 c7 BCC &359b ; plot_core_elements_loop &35d4 a0 08 LDY #&08 ; mark_elements_as_plotted_loop &35d6 b9 f7 0b LDA &0bf7,Y ; core_elements_colours &35d9 99 7e 35 STA &357e,Y ; core_elements_plotted &35dc 88 DEY &35dd 10 f7 BPL &35d6 ; mark_elements_as_plotted_loop &35df 60 RTS ; packed_two_colour_sprite_data ; packed_sprite_00 ITEM_ENERGY &35e0 53 b5 bb ba ec f6 f7 fb 50 05 8b 0f a0 0a 1f 0f ; packed_sprite_01 ITEM_ENGERY_2 &35f0 73 57 75 13 ec ae ea 8c 62 d6 85 0d 64 b6 1a 0b ; packed_sprite_02 ITEM_ENERGY_3 &3600 56 08 21 22 73 0d c8 cc 62 56 d5 0f ec a6 fa 0f ; packed_sprite_03 ITEM_AMMO &3610 12 04 26 01 a8 41 09 04 22 22 52 0b cc cc a4 0f ; packed_sprite_04 ITEM_FUEL &3620 c0 1d 64 90 30 8b 62 90 f4 dd 0f 0b f2 33 0f 0d ; packed_sprite_05 ITEM_LIFE &3630 21 32 01 11 c8 cc 08 88 11 70 fc 07 88 e0 f3 0e ; packed_sprite_06 ITEM_RANDOM &3640 ac 31 74 43 53 c8 e2 2c 37 74 43 03 ce e2 2c 0c ; packed_sprite_07 PYRAMID &3650 11 22 44 88 88 cc ee ff 0f 57 45 07 0f 2e 2a 0e ; packed_sprite_08 ITEM_EMPTY &3660 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ; packed_sprite_09 ITEM_PASS &3670 00 00 c7 ef 00 00 3e 7f ce 8c 99 07 77 bb 11 0e ; packed_sprite_0a ITEM_KEY &3680 00 40 66 55 00 00 00 00 54 65 46 00 7f 15 00 00 ; packed_sprite_0b ITEM_CORE_TOP_LEFT &3690 00 00 00 00 31 13 20 44 00 11 42 ee 88 00 00 31 ; packed_sprite_0c ITEM_CORE_TOP &36a0 90 3b 81 2a 90 cd 18 45 44 84 1a 93 22 12 85 9c ; packed_sprite_0d ITEM_CORE_TOP_RIGHT &36b0 c8 8c 40 22 00 00 00 00 11 00 00 c8 00 88 24 77 ; packed_sprite_0e ITEM_CORE_LEFT &36c0 24 01 10 e4 13 42 28 30 4e 20 10 40 03 42 08 35 ; packed_sprite_0f ITEM_CORE_MIDDLE &36d0 08 10 33 77 01 80 cc ee 55 32 01 80 ee cc 08 10 ; packed_sprite_10 ITEM_CORE_RIGHT &36e0 8c 24 41 c0 42 08 80 72 0c 24 01 ca 27 40 80 20 ; packed_sprite_11 ITEM_CORE_BOTTOM_LEFT &36f0 ee 24 11 00 13 00 00 88 00 00 00 00 44 02 31 13 ; packed_sprite_12 ITEM_CORE_BOTTOM &3700 39 a1 48 44 c9 58 21 22 a2 18 b3 09 54 81 dc 09 ; packed_sprite_13 ITEM_CORE_BOTTOM_RGHT &3710 8c 00 00 11 77 42 88 00 22 04 c8 8c 00 00 00 00 ; packed_sprite_14 ITEM_CORE_CHIP_1 &3720 00 30 77 77 00 e0 77 33 77 03 55 05 f3 0e 55 05 ; packed_sprite_15 ITEM_CORE_CHIP_2 &3730 00 30 76 66 00 e0 b3 73 76 03 55 05 f3 0e 55 05 ; packed_sprite_16 ITEM_CORE_CHIP_3 &3740 00 30 76 77 00 e0 b3 73 77 03 55 05 7f 0e 55 05 ; packed_sprite_17 ITEM_CORE_TRANSISTOR &3750 10 23 22 07 c0 e6 ee 0f 22 22 44 04 aa aa 59 05 ; packed_sprite_18 ITEM_CORE_XXX &3760 00 31 65 56 00 ec b5 5b 35 10 22 62 e5 40 22 32 ; packed_sprite_19 ITEM_CORE_AERIAL &3770 00 20 27 00 22 aa af aa 00 00 10 01 02 e4 fe 0f ; packed_sprite_1a ITEM_CORE_LIGHTBULB &3780 21 55 55 22 ec ff ff ee 11 10 10 00 c4 c0 c8 08 ; packed_sprite_1b ITEM_CORE_FLOPPY &3790 70 44 77 67 f0 67 ff b7 76 77 77 07 7b 7f 77 0f ; packed_sprite_1c ITEM_CORE_BOTTLE &37a0 00 01 01 21 80 cc 0c 2c 23 22 03 03 ee ee 0e 0e ; packed_sprite_1d ITEM_CORE_EXTINGUISHER &37b0 40 77 14 11 f0 66 0f 88 31 33 33 03 c8 40 04 0c ; possible_item_locations # One byte per room, low six bits set tile &37c0 19 a5 12 5a 5e e3 e4 dc 23 e2 53 1e e3 1e 4c 0b &37d0 66 a3 59 52 62 54 c9 1e 64 e4 0e 62 64 19 56 60 &37e0 23 9a 1e 09 13 e2 1e c9 13 19 e4 e2 e4 14 e1 16 &38f0 a5 20 1e 19 e4 a1 13 15 9d e2 15 21 0e 09 26 4a &3800 21 e1 16 12 54 27 24 0d 3f 12 e2 e3 20 e2 21 1d &3810 0e 1d 65 0a 21 0d 1b 26 51 e4 e2 12 0b 13 1e 16 &3820 27 05 1d 20 14 11 12 91 92 11 3f 4c 24 e2 e3 20 &3830 16 27 4c 05 1d a1 e4 1d 21 4a e2 1d d9 e3 0b 0a &3840 14 e1 e1 14 e3 e1 15 54 e1 0e 20 95 20 e0 4b 12 &3850 12 1d 0d e1 20 56 22 12 27 1d 64 14 09 14 65 12 &3860 12 a5 12 11 e2 1a 64 21 0b 64 e2 e3 e0 11 da 65 &3870 27 16 09 10 16 25 60 21 e3 20 27 dc 16 51 9d 0d &3880 1b 16 9d e4 1e 93 25 3f 11 16 15 66 66 5b 14 26 &3890 02 13 5a 0d 51 5e 23 25 0c e1 11 21 66 60 04 16 &38a0 02 e2 16 e2 1b 16 1b 20 12 1d 0c 93 e1 62 e1 01 &38b0 53 64 a3 5b e2 e3 60 1d e1 19 21 e4 9d 19 58 06 &38c0 51 16 66 23 62 1b 1d 58 59 5e 5e 58 58 27 4c 11 &38d0 11 1e e1 d0 27 e2 1f 21 1b 13 98 14 e2 e1 20 26 &38e0 54 e0 a2 27 e2 27 54 15 1b 14 1d 1b 14 27 0a 1b &38f0 27 0a 1d 61 e2 e1 3f 05 51 0c 1c 27 1a 20 20 0d &3900 e3 1d 14 e2 63 66 60 16 e2 ca 1a e2 60 e2 9c 16 &3910 1b e0 27 e2 e0 1d 15 9a 1d e4 04 27 15 27 20 42 &3920 1c 16 16 0b 12 0c 1b 16 11 21 21 12 e2 e1 e4 e2 &3930 27 41 53 26 06 19 a4 1e 16 1d 0a 27 9c 16 1b 19 &3940 0b a4 43 e3 e1 14 27 e2 63 1a 19 e1 27 e3 0b 06 &3950 e2 16 12 20 20 19 5c 27 20 12 11 16 11 e1 1d 01 &3960 27 1a 27 27 16 4b 09 27 27 20 43 19 66 5e e3 3f &3970 12 19 59 4b 06 16 16 20 53 0c 05 15 15 1d 12 1d &3980 09 1a e3 27 27 e1 e2 e1 e0 16 1d 0a e2 12 0d 24 &3990 61 65 21 1a 27 1a a0 1a 15 1d 12 1a 20 3f 62 20 &39a0 27 66 14 ca e1 0d 66 27 e1 27 20 3f 12 21 3f 26 &39b0 21 3f 27 a5 60 43 3f a4 21 26 26 e3 66 3f ca e1 ; enemy_sprites ; enemy_materialising_frame_1 &39c0 00 41 00 08 00 00 00 cc 80 00 60 00 34 40 33 33 &39d0 00 00 00 00 00 00 00 00 cc cc 20 c2 00 60 00 10 &39e0 33 00 00 00 01 00 28 00 00 00 00 00 00 00 00 00 ; enemy_materialising_frame_2 &39f0 00 00 00 66 66 66 00 00 80 02 00 30 00 10 02 10 &3a00 00 00 00 00 00 08 00 80 60 01 24 00 30 00 01 00 &3a10 00 00 11 11 11 00 00 40 00 00 88 88 88 00 00 00 ; enemy_materialising_frame_3 &3a20 00 00 20 20 10 02 30 00 cc cc cd 00 08 00 00 00 &3a30 00 00 00 00 80 00 08 40 20 01 00 10 00 00 00 00 &3a40 00 00 00 01 00 3b 33 33 00 c0 04 80 40 40 00 00 ; enemy_materialising_frame_4 &3a50 00 00 00 10 00 00 00 01 14 a0 a0 20 00 80 00 00 &3a60 00 00 cc cc cc 00 00 00 00 00 00 00 00 00 00 00 &3a70 00 00 00 cc dc dc 10 20 02 00 40 00 20 40 40 08 ; enemy_type_one_frame_1 &3a80 08 0c 06 02 01 01 20 60 01 03 06 04 08 08 40 60 &3a90 00 00 00 00 00 00 00 00 70 d0 22 54 66 90 f0 50 &3aa0 e0 b0 54 a2 66 90 f0 a0 00 00 00 00 00 00 00 00 ; enemy_type_one_frame_2 &3ab0 00 00 06 07 00 00 10 30 00 00 01 03 0c 0c 20 30 &3ac0 00 00 08 08 00 00 00 00 30 60 51 22 33 60 70 10 &3ad0 f0 d0 22 d1 33 d0 f0 60 00 80 80 00 00 80 80 00 ; enemy_type_one_frame_3 &3ae0 00 00 00 01 03 02 00 10 00 00 00 09 06 06 90 90 &3af0 00 00 00 08 0c 04 00 80 10 30 20 11 11 20 30 10 &3b00 f0 60 99 60 99 60 f0 80 80 c0 40 88 88 40 c0 80 ; enemy_type_one_frame_4 &3b10 00 00 01 01 00 00 00 00 00 00 08 0c 03 03 40 c0 &3b20 00 00 06 0e 00 00 80 c0 00 10 10 00 00 10 10 00 &3b30 f0 b0 44 b8 cc 30 f0 60 c0 60 a8 44 cc 20 e0 80 ; enemy_type_two_frame_1 &3b40 02 15 15 15 0a 0f 0e 04 aa 55 55 f5 a0 00 00 01 &3b50 00 00 00 00 00 00 00 00 0c 0c 06 0e 0b 07 05 03 &3b60 01 02 03 07 0f 0e 0a 0c 00 00 00 00 00 00 00 00 ; enemy_type_two_frame_2 &3b70 01 02 02 02 05 07 07 02 55 aa aa fa 50 08 00 00 &3b80 00 88 88 88 00 00 00 08 06 06 03 07 05 03 02 01 &3b90 00 01 01 03 0f 0f 0d 0e 08 00 08 08 08 00 00 00 ; enemy_type_two_frame_3 &3ba0 00 01 01 01 02 03 03 01 2a 55 55 75 28 0c 08 00 &3bb0 88 44 44 c4 80 00 00 08 03 03 01 03 02 01 01 00 &3bc0 00 00 08 09 0f 0f 06 0f 08 0c 0c 08 0c 08 08 00 ; enemy_type_two_frame_4 &3bd0 00 00 00 00 01 01 01 00 15 2a 2a 3a 14 0e 0c 08 &3ce0 44 aa aa ea 40 00 00 04 01 01 00 01 01 00 00 00 &3cf0 08 08 0c 0c 07 0f 0b 07 04 06 06 0c 0e 0c 04 08 ; enemy_type_three_frame_1 &3c00 11 22 22 00 bb bb bb 00 88 cc cc 00 bb bb bb 00 &3c10 00 00 00 00 00 00 00 00 22 22 22 22 00 55 00 11 &3c20 cc cc cc cc 00 ee 00 88 00 00 00 00 00 00 00 00 ; enemy_type_three_frame_2 &3c30 00 11 11 00 33 33 33 00 cc 66 66 00 bb bb bb 00 &3c40 00 00 00 00 88 88 88 00 11 11 11 11 00 33 00 00 &3c50 66 66 66 66 00 dd 00 cc 00 00 00 00 00 00 00 00 ; enemy_type_three_frame_3 &3c60 00 00 00 00 33 33 33 00 66 bb bb 00 bb bb bb 00 &3c70 00 00 00 00 88 88 88 00 00 00 00 00 00 11 00 00 &3c80 bb bb bb bb 00 dd 00 66 00 00 00 00 00 88 00 00 ; enemy_type_three_frame_4 &3c90 00 00 00 00 11 11 11 00 33 55 55 00 bb bb bb 00 &3ca0 00 88 88 00 aa aa aa 00 00 00 00 00 00 00 00 00 &3cb0 55 55 55 55 00 dd 00 33 88 88 88 88 00 cc 00 00 ; player_materialising_frame_1 # Also dematerialising enemies and platform fire &3cc0 22 77 22 88 00 22 88 00 00 44 11 00 22 77 22 00 &3cd0 00 00 00 00 00 00 00 00 00 44 00 00 99 00 44 00 &3ce0 88 00 22 88 cc 99 22 00 00 00 00 00 00 00 00 00 ; player_materialising_frame_2 &3cf0 00 00 11 00 44 11 44 00 22 88 cc 88 11 33 11 88 &3d00 00 00 00 00 00 88 00 00 00 22 11 33 11 44 22 00 &3d10 00 22 00 88 11 00 00 88 00 00 00 88 00 00 88 00 ; player_materialising_frame_3 &3d20 00 00 00 11 00 22 00 00 99 00 88 cc 99 00 00 11 &3d30 00 00 88 00 00 00 88 cc 00 11 00 00 11 00 00 22 &3d40 44 00 22 00 00 44 ee 44 88 00 00 00 00 88 00 44 ; player_materialising_frame_4 &3d50 00 00 11 00 00 00 00 00 22 00 11 44 ee 44 00 44 &3d60 22 00 00 44 00 00 00 22 11 00 00 11 00 00 11 00 &3d70 11 88 00 22 00 88 dd 88 00 44 ee 44 00 00 00 44 ; player_sprites ; player_left_frame_1 &3d80 11 00 33 55 22 66 88 cc bb dd 44 aa ee 77 33 77 &3d90 00 00 00 00 00 00 00 00 ee ff ff 66 66 bb 88 66 &3da0 ff ff 77 aa cc 22 66 cc 00 00 00 00 00 00 00 00 ; player_left_frame_2 &3db0 00 00 11 22 11 33 44 66 dd 66 aa dd 77 33 11 33 &3dc0 88 88 00 00 00 88 88 88 77 77 77 33 33 55 44 33 &3dd0 77 ff bb 55 66 99 33 66 88 88 88 00 00 00 00 00 ; player_left_frame_3 &3de0 00 00 00 11 00 11 22 33 33 11 dd 66 bb 99 00 11 &3df0 44 00 00 88 88 cc cc cc 33 33 33 11 11 00 00 00 &3e00 bb ff dd aa aa 22 ee 66 cc cc cc 88 88 00 cc 88 ; player_left_frame_4 &3e10 00 00 00 00 00 00 11 11 11 00 66 bb 55 cc 00 88 &3e20 aa 88 88 44 cc ee 66 ee 11 11 11 00 00 00 00 00 &3e30 dd ff ee dd dd 11 77 33 ee ee ee 44 44 00 66 44 ; player_left_frame_5 &3e40 11 00 33 55 22 66 88 cc bb 66 44 aa ee 77 33 77 &3e50 00 00 00 00 00 00 00 00 ee ff ff 66 66 11 77 22 &3e60 ff ff 77 aa aa 99 33 66 00 00 00 00 00 00 00 00 ; player_left_frame_6 &3e70 00 00 11 22 11 33 44 66 dd 33 aa dd 77 33 11 33 &3e80 88 00 00 00 00 88 88 88 77 77 77 33 33 00 33 11 &3e90 77 ff bb 55 55 cc 99 33 88 88 88 00 00 88 88 00 ; player_left_frame_7 &3ea0 00 00 00 11 00 11 22 33 55 11 dd 66 bb 99 00 11 &3eb0 88 00 00 88 88 cc cc cc 33 33 33 11 11 22 22 11 &3ec0 bb ff dd aa bb dd 33 66 cc cc cc 88 00 00 00 00 ; player_left_frame_8 &3ed0 00 00 00 00 00 00 11 11 22 00 66 bb 55 cc 00 88 &3ee0 cc 88 88 44 cc ee 66 ee 11 11 11 00 00 11 11 00 &3ef0 dd ff ee dd dd 66 11 bb ee ee ee 44 88 88 88 00 ; player_right_frame_1 &3f00 66 22 22 55 77 ee cc ee 88 00 cc aa 44 66 11 33 &3f10 00 00 00 00 00 00 00 00 ff ff ee 55 33 22 33 11 &3f20 77 ff ff 66 66 dd 11 aa 00 00 00 00 00 00 00 00 ; player_right_frame_2 &3f30 33 11 11 22 33 77 66 77 44 00 66 dd aa 33 00 11 &3f40 00 00 00 00 00 00 88 88 77 77 77 22 11 11 11 00 &3f50 bb ff 77 bb bb 66 88 dd 88 88 88 00 00 88 88 00 ; player_right_frame_3 &3f60 33 11 00 11 11 33 33 33 66 88 bb 66 dd 99 00 88 &3f70 00 00 00 88 00 88 44 cc 33 33 33 11 11 22 33 11 &3f80 dd ff bb 55 55 66 33 99 cc cc cc 88 88 00 88 00 ; player_right_frame_4 &3f90 11 00 00 00 00 11 11 11 bb cc 55 bb ee cc 88 cc &4fa0 00 00 88 44 88 cc 22 66 11 11 11 00 00 11 11 00 &4fb0 ee ff dd aa aa 33 99 cc ee ee ee cc cc 00 cc 88 ; player_right_frame_5 &4fc0 bb 22 22 55 77 ee cc ee 00 00 cc aa 44 66 11 33 &4fd0 00 00 00 00 00 00 00 00 ff ff ee 55 55 11 dd 55 &4fe0 77 ff ff 66 66 00 cc 88 00 00 00 00 00 00 00 00 ; player_right_frame_6 &4ff0 55 11 11 22 33 77 66 77 88 00 66 dd aa 33 00 11 &4000 00 00 00 00 00 00 88 88 77 77 77 22 22 00 66 22 &4010 bb ff 77 bb bb 88 ee cc 88 88 88 00 00 00 00 00 ; player_right_frame_7 &4020 33 22 00 11 11 33 33 33 66 cc bb 66 dd 99 00 88 &4030 00 00 00 88 00 88 44 cc 33 33 33 11 00 11 11 00 &4040 dd ff bb 55 dd 33 88 dd cc cc cc 88 88 44 44 88 ; player_right_frame_8 &4050 11 11 00 00 00 11 11 11 bb 66 55 bb ee cc 88 cc &4060 00 00 88 44 88 cc 22 66 11 11 11 00 00 00 00 00 &4070 ee ff dd aa 66 99 cc 66 ee ee ee cc cc aa 22 cc ; bridging_platform_sprites # EORed successively ; bridging_platform_frame_1 &4080 00 00 44 00 00 00 88 11 00 00 22 00 00 00 44 00 ; bridging_platform_frame_2 &4090 00 00 00 11 00 00 00 00 00 00 88 00 22 00 00 00 ; bridging_platform_frame_3 &40a0 00 88 00 00 44 00 22 00 00 33 00 88 00 88 00 00 ; bridging_platform_frame_4 &40b0 00 44 99 00 00 11 00 00 00 00 11 00 00 00 11 88 ; bridging_platform_frame_5 &40c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ; bridging_platform_frame_6 &40d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ; bridging_platform_frame_7 &40e0 00 cc dd 11 44 11 aa 11 00 33 bb 88 22 88 55 88 ; bridging_platform_frame_8 &40f0 00 cc dd 11 44 11 aa 11 00 33 bb 88 22 88 55 88 ; fire_sprites ; fire_frame_1 &4100 22 55 00 00 00 00 00 00 22 55 88 00 00 00 00 00 ; fire_frame_2 &4110 00 55 22 00 00 00 00 00 88 55 22 00 00 00 00 00 ; hopper_sprites ; hopper_frame_1 &4120 dd 00 55 bb bb dd 55 00 dd 00 aa 55 55 bb aa 00 &4130 00 00 00 00 00 00 00 00 ; hopper_frame_2 &4138 55 00 22 55 55 66 22 00 dd 00 dd 66 66 dd dd 00 &4148 88 00 00 88 88 88 00 00 ; hopper_frame_3 &4150 11 00 11 22 22 33 11 00 dd 00 66 77 77 66 66 00 &4160 cc 00 88 44 44 cc 88 00 ; hopper_frame_4 &4168 11 00 00 11 11 11 00 00 dd 00 bb 77 77 bb bb 00 &4178 cc 00 44 22 22 66 44 00 # Room data # ========= # Twelve bytes per room # # First byte: # .....421 room_primary_wall_type # 84...... palette + 5 # ...18... palette + 3 # # Second byte: # 8421.... room_extras_types + 1 # ....8421 room_extras_types # # Third and fourth, fifth and sixth bytes: # 84...... 84...... room_additional_wall_types # ..218421 ........ extra position # ........ ..218421 extra position # # Seventh through twelve bytes are bitmaps for walls, one byte per row ; room_data ; 0 1 2 3 4 5 6 7 8 9 a b &4180 d8 5f 13 3f 55 2f ff fa 9e 80 c0 c0 ; room &000 &418c 49 30 3f 3f 11 3f ff 32 60 08 00 c7 ; room &001 &4198 41 20 3f 3f 3f 3f ff 4d 00 20 00 ff ; room &002 &41a4 51 40 3f 3f 3f 3f ff dd 03 05 33 81 ; room &003 &41b0 41 1d 3f 3f 3f 3f ff ec c0 b0 c3 81 ; room &004 &41bc 59 50 3f 3f 15 3f ff 11 06 00 c0 ff ; room &005 &41c8 51 4f 12 3f 14 3f ff 9b 3a 00 00 c7 ; room &006 &41d4 49 30 3f 3f 12 3f ff d1 30 00 0f c1 ; room &007 &41e0 78 5f 60 3f 2f 11 ff ba 60 00 4c 9c ; room &008 &41ec 51 40 3f 3f 12 3f ff 5a 30 08 00 ff ; room &009 &41f8 51 40 3f 3f 3f 3f ff 43 00 18 00 81 ; room &00a &4204 59 5f 1f 3f 15 3f ff cb 04 01 03 c1 ; room &00b &4210 41 1d 3f 3f 10 18 ff f1 a0 c4 c0 ff ; room &00c &421c d8 53 5e 3f 28 3f ff b3 00 00 0f 2f ; room &00d &4228 d8 50 7f 3f 14 3f ff a0 0a 00 ff ff ; room &00e &4234 48 40 1a 25 16 3f ff 0f 18 38 f8 fc ; room &00f &4240 c0 f0 2a 07 7f 2c c1 c0 c0 80 80 d0 ; room &010 &424c 41 10 3f 3f 3f 3f c7 40 08 00 03 9f ; room &011 &4258 49 36 1c 3f 3f 3f ff 07 03 01 ff ff ; room &012 &4264 41 10 3f 3f 3f 3f 81 81 c3 f1 c1 81 ; room &013 &4270 78 5f 40 3f 47 2c 41 80 80 80 c0 f0 ; room &014 &427c 41 10 3f 3f 3f 3f ff 07 03 0f 21 81 ; room &015 &4288 49 30 3f 3f 3f 3f c7 81 f9 c1 83 bf ; room &016 &4294 49 30 3f 3f 3f 3f c1 c1 e1 c1 83 81 ; room &017 &42a0 30 4f 51 3f 00 3f 5d 0c 6f 07 03 0f ; room &018 &42ac b0 30 6a 3f 40 0d 80 04 c0 80 90 ff ; room &019 &42b8 c1 10 bf 3f 28 3f 81 81 03 11 01 21 ; room &01a &42c4 41 10 3f 3f 3f 3f c1 80 88 84 c0 f1 ; room &01b &42d0 41 10 1b 3f 3f 3f ff 07 01 09 03 ff ; room &01c &42dc 78 5f 61 3f 40 08 af 49 01 01 21 07 ; room &01d &42e8 50 40 1d 3f 3f 3f ff 90 80 83 f0 e1 ; room &01e &42f4 48 34 25 13 17 06 fc 04 0a 89 3b ff ; room &01f &4300 50 40 3f 3f 3f 3f ff 89 81 81 89 99 ; room &020 &430c b0 3f 43 1c c0 da 50 80 c0 c0 f8 ff ; room &021 &4318 d9 50 bf 3f 28 3f ff 05 03 11 03 23 ; room &022 &4324 d9 4f a6 3f 87 2f 80 94 c0 a8 82 90 ; room &023 &4330 b0 f0 5c 0f 46 2e fe a5 84 9e 8c 8c ; room &024 &433c 59 53 0c 3f 3f 3f 81 80 3c 00 00 ff ; room &025 &4348 49 30 3f 3f 3f 3f bf 0b 05 01 03 c7 ; room &026 &4354 79 50 bf 3f 2c 3f 81 80 fc c0 80 80 ; room &027 &4360 d8 3f 40 15 52 1b cf 03 33 1b 07 ff ; room &028 &436c 48 30 dc ff 3f 3f ff c7 c3 87 c1 81 ; room &029 &4378 a8 f0 2a 14 7f 07 c1 c0 cc e0 c0 df ; room &02a &4384 70 ff 6a 26 40 07 89 00 00 00 02 c0 ; room &02b &4390 41 10 3f 3f 3f 3f ff 16 20 18 f0 ff ; room &02c &439c 28 4f 68 3f 00 3f a7 07 07 0f 07 c3 ; room &02d &43a8 40 10 2e 3f 3f 3f e1 80 83 81 81 ff ; room &02e &43b4 58 22 1d 1b 3f 3f ff 09 c1 eb c1 c1 ; room &02f &43c0 40 10 3f 3f 3f 3f 99 88 88 c8 88 8f ; room &030 &43cc 58 9d d2 de 1c 3f ff 09 01 01 01 81 ; room &031 &43d8 39 94 8a 0c 98 00 23 01 89 41 03 07 ; room &032 &43e4 29 f0 aa 2b 96 07 90 80 f8 88 c0 c0 ; room &033 &43f0 40 4d 5c 1a 46 0f 8e 81 c0 c0 c0 ff ; room &034 &43fc 71 3f a4 1c 28 3f ff 98 00 00 0c 00 ; room &035 &4408 29 16 bf 3f 28 3f c7 00 24 10 00 00 ; room &036 &4414 30 49 5e 3f 00 3f cf 09 39 1d 19 99 ; room &037 &4420 40 90 24 1a 3f 3f ff 88 80 c0 ff ff ; room &038 &442c 50 4d 1c 3f 3f 3f 81 08 00 00 c0 ff ; room &039 &4438 58 56 3f 3f 3f 3f ff 09 01 25 01 93 ; room &03a &4444 60 ff 6f 1c 42 0f e0 81 80 8c 80 c0 ; room &03b &4450 49 30 1b 3f 3f 3f ff 81 0b 19 03 ff ; room &03c &445c d8 ff 5a 14 40 11 43 03 6f 33 03 01 ; room &03d &4468 58 04 1a 2c 3f 3f ff c9 c1 c1 c1 c7 ; room &03e &4474 48 4d 18 1c 3f 3f c1 81 31 13 91 81 ; room &03f &4480 58 93 0a 1e 3f 3f 8f 81 b1 81 81 c1 ; room &040 &448c 58 d0 2e 14 3f 3f 81 89 81 a0 81 ff ; room &041 &4498 b0 33 5a 15 45 0f 84 f1 81 03 ff ff ; room &042 &44a4 40 d3 1e 18 3f 3f ff 96 00 20 83 83 ; room &043 &44b0 a8 3d 52 3f 1c 3f ff 66 40 0a c0 ff ; room &044 &44bc 58 dd 22 3f 3f 3f ff 45 04 00 00 81 ; room &045 &44c8 40 10 1a 3f 3f 3f ff 9f 0f 1f 07 ff ; room &046 &44d4 50 4d 23 3f 3f 3f 99 99 9d c9 81 81 ; room &047 &44e0 50 0d 1a 1c 3f 3f ff 85 81 85 81 81 ; room &048 &44ec 40 2d e8 ff 24 3f ff 18 00 20 00 01 ; room &049 &44f8 40 10 3f 3f 3f 3f 93 01 05 21 01 ff ; room &04a &4504 b0 4f 54 3f 47 1d c1 80 ec e6 e0 ff ; room &04b &4510 c9 3f af 3f 28 3f ff 2b 14 00 00 48 ; room &04c &451c 50 9d 5c 1e 5a 00 41 8f 01 31 01 ff ; room &04d &4528 50 4d 24 3f 3f 3f cf 82 80 80 a3 e1 ; room &04e &4534 40 39 dc ca 1e 3f 81 05 21 01 ff ff ; room &04f &4540 40 20 ac 5d 10 3f c1 81 73 9b 93 97 ; room &050 &454c 40 f2 bf 5b 48 25 ff 64 00 98 c6 c1 ; room &051 &4558 40 08 12 2c 3f 3f ff 09 21 01 31 f7 ; room &052 &4564 48 33 ca ff 1c 3f 83 81 a1 83 89 81 ; room &053 &4570 58 20 aa 5d d0 db ff 87 43 aa 80 df ; room &054 &457c 48 4e 3f 3f 3f 3f 81 80 84 20 00 81 ; room &055 &4588 40 09 da e8 1c 3f ff 25 01 03 7f ff ; room &056 &4594 48 99 cc de 1a 3f 81 81 89 81 a1 83 ; room &057 &45a0 40 22 cb cd db dd 81 eb 81 eb 81 83 ; room &058 &45ac 43 83 4a 12 15 3f 81 80 a6 80 f0 ff ; room &059 &45b8 58 5d 1c 3f 3f 3f ff 08 00 00 00 ff ; room &05a &45c4 d8 56 7f 3f 1a 3f ff 1d 0d 39 01 81 ; room &05b &45d0 c0 14 51 3f 44 13 8d 81 99 c3 c3 e7 ; room &05c &45dc 40 14 11 3f 3f 3f ff 88 80 d2 c0 89 ; room &05d &45e8 58 83 da d4 1e 3f e1 00 08 00 3e ff ; room &05e &45f4 58 50 2c 3f 3f 3f ff 19 09 03 07 ff ; room &05f &4600 40 08 14 2a 3f 3f 9f 90 8a c2 ce df ; room &060 &460c 78 ff 6c 1b 51 0d c1 07 61 19 01 8d ; room &061 &4618 40 10 1b 3f 3f 3f ff 80 80 80 94 81 ; room &062 &4624 50 45 3f 3f 3f 3f 81 00 00 00 00 81 ; room &063 &4630 58 50 1b 3f 3f 3f ff 01 01 39 01 81 ; room &064 &463c 40 18 14 3f 3f 3f 81 81 89 c3 89 81 ; room &065 &4648 60 42 db d1 5d 1e ff 88 80 ea c3 81 ; room &066 &4654 79 3f 80 3f a0 06 c0 00 0c f0 00 00 ; room &067 &4660 58 42 cb d1 1d 3f 83 ef 83 fb c3 83 ; room &068 &466c 58 20 1a 1d 3f 3f ff 93 83 da c0 ff ; room &069 &4678 58 5d 24 3f 3f 3f ff d1 d1 11 01 81 ; room &06a &4684 58 5d e4 ff 1a 3f 81 a1 8d 81 81 81 ; room &06b &4690 58 59 1c 3a 3f 3f e7 e7 f7 e7 e7 ef ; room &06c &469c 50 44 21 3f 3f 3f 89 8c 98 80 80 ff ; room &06d &46a8 48 3d 3f 3f 3f 3f ff 10 10 10 00 ff ; room &06e &46b4 48 dd d2 ff 15 3f ff 01 01 01 01 81 ; room &06f &46c0 50 dd 22 24 3f 3f ff 81 81 83 83 83 ; room &070 &46cc 50 40 2d 3f 3f 3f 89 a1 81 89 81 83 ; room &071 &46d8 50 4d 24 3f 3f 3f 81 80 8c 80 80 81 ; room &072 &46e4 40 11 3f 3f 3f 3f 81 24 00 42 10 81 ; room &073 &46f0 40 30 1b 1d 3f 3f 81 01 01 01 15 81 ; room &074 &46fc 50 09 1e 2c 3f 3f 81 81 fd 81 85 f5 ; room &075 &4708 50 3d 1c 1a 3f 3f 81 88 80 80 e0 ff ; room &076 &4714 48 3d 12 1d 3f 3f ff 01 01 01 05 81 ; room &077 &4720 40 0d 18 1b 3f 3f c3 81 00 08 80 c1 ; room &078 &472c 60 13 5e 3f 12 3f ff 80 28 00 03 ff ; room &079 &4738 60 f3 19 13 7f 1d 81 00 18 06 c0 ff ; room &07a &4744 60 19 5c 3f 12 3f 81 01 31 03 0f ff ; room &07b &4750 48 33 3f 3f 3f 3f ef 8f bf 81 fc fd ; room &07c &475c 58 3d d8 d2 1c 3f ff 00 20 00 20 ff ; room &07d &4768 40 40 1a 1c 3f 3f ff 01 11 71 11 81 ; room &07e &4774 48 30 1c 0a ff cd 81 81 a5 bd a5 81 ; room &07f &4780 48 30 1b 0a 3f 3f 83 80 a0 a8 a0 81 ; room &080 &478c 58 59 1e 3f 3f 3f 87 11 41 05 01 ff ; room &081 &4798 40 1d 3f 3f 3f 3f 81 80 80 80 80 ff ; room &082 &47a4 50 83 db dc 14 3f 81 00 00 00 18 81 ; room &083 &47b0 50 4a 3f 3f 3f 3f 81 01 01 01 01 ff ; room &084 &47bc 60 bf 68 7f 20 3f fd 90 80 a4 c0 00 ; room &085 &47c8 58 5d 5a 3f 5d 68 ff 20 00 06 00 00 ; room &086 &47d4 b0 f0 5b 28 5c 67 81 01 03 0b 00 40 ; room &087 &47e0 50 0d 58 5a 60 68 c1 00 00 10 c0 00 ; room &088 &47ec 38 5a 7f 7f 68 7f ff 18 12 50 00 00 ; room &089 &47f8 58 59 1e 3f 3f 3f ff 25 01 01 01 81 ; room &08a &4804 40 10 29 3f 3f 3f ff 80 80 a7 80 bf ; room &08b &4810 58 56 14 3f 3f 3f fd 20 00 cc 00 83 ; room &08c &481c 58 59 3f 3f 3f 3f ff 39 11 01 01 ff ; room &08d &4828 40 13 cb fa 0c 3f 81 81 99 81 81 81 ; room &08e &4834 a0 5f 5a 64 64 4d 81 87 81 b1 8d 81 ; room &08f &4840 40 11 3f 3f 3f 3f 81 88 80 a0 8c 81 ; room &090 &484c 58 83 d2 ff 1d 3f ff 04 20 00 24 81 ; room &091 &4858 50 90 1c 1e 3f 3f ff 21 05 0d 25 81 ; room &092 &4864 38 ff 4a 0d 5b 1e 81 b6 80 9b 80 ff ; room &093 &4870 b0 4f 51 3f 62 1c ff 25 61 0b 31 81 ; room &094 &487c 43 10 1d 3f 3f 3f ff 90 c0 83 80 ff ; room &095 &4888 5b 53 15 3f 3f 3f ff 11 01 c1 1f bf ; room &096 &4894 4b 36 3f 3f bf bf 81 91 85 a1 89 81 ; room &097 &48a0 43 1d 24 3f ff ff ff 9e 80 a0 80 81 ; room &098 &48ac 5b 53 da ff dd 3f ff 25 01 01 25 81 ; room &099 &48b8 50 48 96 d1 ff e3 81 80 a2 e0 e3 ff ; room &09a &48c4 48 03 59 5b ff 3f ff 21 01 09 c1 c1 ; room &09b &48d0 50 4d 28 3f bf bf 83 80 c0 04 10 01 ; room &09c &48dc 48 bd 12 7f ff ff ff 07 07 0f 0f ff ; room &09d &48e8 50 d0 6c 5a bf bf 81 a1 85 c1 c1 f7 ; room &09e &48f4 c3 4f 80 21 a9 07 40 10 04 20 08 20 ; room &09f &4900 50 43 14 3f bf bf 81 85 89 a1 89 81 ; room &0a0 &490c 50 80 2a 14 bf bf 81 80 88 80 98 ff ; room &0a1 &4918 40 3e 11 15 bf 3f 81 01 01 23 0f ff ; room &0a2 &4924 50 10 1c 1b ff bf ff 80 84 fc 87 81 ; room &0a3 &4930 60 1f 4c 3f 51 1b 81 0c 60 12 c0 ff ; room &0a4 &493c 5b 5d 1c 3f ff 3f ff 3b 13 01 21 81 ; room &0a5 &4948 4b 30 3f 3f bf bf bf 81 fd 88 a3 8f ; room &0a6 &4954 5b 5d 1c 3f bf bf 81 8d 81 21 81 c1 ; room &0a7 &4960 4b 30 0d 3f bf bf 81 83 91 85 a1 81 ; room &0a8 &496c 41 83 ca ff de ff 81 a0 a0 82 f0 ff ; room &0a9 &4978 40 dd dc d2 16 3f ff 08 00 00 00 ff ; room &0aa &4984 40 03 0b 3f 3f 3f c1 04 10 00 00 ff ; room &0ab &4990 50 00 2c 3f 3f 3f 81 01 39 03 07 ff ; room &0ac &499c 40 83 14 1c 3f 3f ff a0 80 c0 c8 81 ; room &0ad &49a8 58 30 3f 1e ff da ff 64 44 00 3e ff ; room &0ae &49b4 58 e0 19 14 3f 3f c1 01 01 31 01 ff ; room &0af &49c0 40 70 2a 1c 3f 3f 81 a1 83 80 9e ff ; room &0b0 &49cc 50 1e 93 5d 08 3f ff 41 81 0b 01 f9 ; room &0b1 &49d8 40 0d 28 3f 3f 3f ff 84 c0 03 08 01 ; room &0b2 &49e4 50 00 3f 3f 3f 3f 81 18 00 81 00 ff ; room &0b3 &49f0 58 0d 14 3f 3f 3f ff 11 11 93 03 c3 ; room &0b4 &49fc 5b 33 d4 d2 cc d6 81 c8 aa aa 80 ff ; room &0b5 &4a08 53 0d 1c 2a 3f 3f 8f 09 21 01 01 df ; room &0b6 &4a14 53 d0 2a 18 3f 3f c1 84 20 0a 80 df ; room &0b7 &4a20 43 04 0c 3f 3f 3f 81 10 18 00 00 ff ; room &0b8 &4a2c 53 0d 24 3f 3f 3f ff 09 01 01 01 81 ; room &0b9 &4a38 50 dd d8 d2 24 3f ff 08 00 00 80 81 ; room &0ba &4a44 40 70 a8 5a 0c 3f ff 06 08 00 7f ff ; room &0bb &4a50 90 0e 15 3f 3f 3f ff 19 01 03 f3 c3 ; room &0bc &4a5c 58 e0 ea 14 3f 3f 81 80 80 e0 c3 df ; room &0bd &4a68 50 00 3f 3f 3f 3f ff 18 18 00 ff ff ; room &0be &4a74 50 00 1c 3f 3f 3f ff 21 05 1d c5 c1 ; room &0bf &4a80 58 90 2d 1e 3f 3f ff 88 80 80 93 87 ; room &0c0 &4a8c 50 93 19 1c 3f 3f f9 11 01 03 cf ff ; room &0c1 &4a98 50 04 1c 3f 3f 3f 81 80 b0 b0 bf ff ; room &0c2 &4aa4 48 0d 1e 1a 3f 3f ff 04 10 30 f0 ff ; room &0c3 &4ab0 48 00 3f 3f 3f 3f c3 01 09 01 33 81 ; room &0c4 &4abc 5b 00 1a 3f 3f 3f ff 82 80 9c 80 81 ; room &0c5 &4ac8 53 33 d2 d4 d6 cc ff 49 2a 2a 00 ff ; room &0c6 &4ad4 43 00 3f 3f 3f 3f ff c3 c3 c3 c3 ff ; room &0c7 &4ae0 5b 07 1c 3f 3f 3f ff 83 82 c0 ff ff ; room &0c8 &4aec 4b 09 da ff 0c 3f 81 81 09 03 a1 81 ; room &0c9 &4af8 50 9d 0a 1e 3f 3f 81 a9 81 85 a1 81 ; room &0ca &4b04 80 de 12 18 ff d4 ff 80 00 00 88 83 ; room &0cb &4b10 38 0e 05 3f 3f 3f c7 40 00 10 00 ff ; room &0cc &4b1c 48 3e d6 dc d1 db ff 10 00 00 18 ff ; room &0cd &4b28 88 ed 12 0e 3f 3f ff 09 01 09 21 81 ; room &0ce &4b34 50 d0 2d 0a 3f 3f c1 a1 81 81 a1 87 ; room &0cf &4b40 50 0d 1a 3f 3f 3f 87 a5 81 8b 83 83 ; room &0d0 &4b4c 88 de 49 16 5b 25 ff 80 80 98 86 81 ; room &0d1 &4b58 40 e7 9c 59 0e 3f ff 05 02 00 3f ff ; room &0d2 &4b64 40 00 1c 3f 3f 3f ff 03 07 1f c7 c1 ; room &0d3 &4b70 48 10 1e 1d ff db 81 81 81 eb c1 81 ; room &0d4 &4b7c 43 30 2a 15 ff df 81 80 a0 80 8f df ; room &0d5 &4b88 5b 33 d8 da dc de ff 44 00 00 aa ff ; room &0d6 &4b94 53 99 da dc 1e 3f ff 14 00 00 2a ff ; room &0d7 &4ba0 7b 00 3f 3f 3f 3f ff 40 08 22 08 81 ; room &0d8 &4bac 43 00 3f 3f 3f 3f 81 01 01 01 01 ff ; room &0d9 &4bb8 40 00 3f 3f 3f 3f 81 81 81 c1 81 81 ; room &0da &4bc4 80 0e d6 ff 02 3f 83 81 81 81 81 f1 ; room &0db &4bd0 40 de 25 22 3f 3f ff c0 c0 80 80 83 ; room &0dc &4bdc 58 ed 1c 22 3f 3f ff 01 01 01 01 c1 ; room &0dd &4be8 80 de 06 0a 3f 3f 81 a9 81 85 a1 81 ; room &0de &4bf4 40 00 3f 3f 3f 3f 87 81 81 83 81 81 ; room &0df &4c00 40 0d e2 ff 0c 3f 83 a9 81 81 89 81 ; room &0e0 &4c0c 88 9e 41 1e 4d 13 81 86 98 80 83 ff ; room &0e1 &4c18 58 06 1a 3f 3f 3f ff 21 01 03 ff ff ; room &0e2 &4c24 40 d2 cb dc 0d 3f c1 eb c1 c0 c0 ff ; room &0e3 &4c30 40 d0 2a 0c 3f 3f 81 88 80 00 1c ff ; room &0e4 &4c3c 53 03 14 3f 3f 3f ff 21 09 03 0f 87 ; room &0e5 &4c48 53 e3 1d 25 3f 3f ff 88 a2 80 90 83 ; room &0e6 &4c54 4b 0d e4 ff 22 3f ff 28 00 00 00 81 ; room &0e7 &4c60 4b 0d 0c 3f 3f 3f 81 09 01 21 09 81 ; room &0e8 &4c6c 9b 0e 13 3f 3f 3f ff 84 80 80 84 c1 ; room &0e9 &4c78 48 00 1a 3f 3f 3f 81 01 09 19 09 81 ; room &0ea &4c84 90 2e c9 cd 06 3f f1 99 81 9f 80 ff ; room &0eb &4c90 90 e3 0b 05 3f 3f 83 c3 d3 83 03 ff ; room &0ec &4c9c 90 e4 11 02 ff cd c1 80 80 f0 c0 ff ; room &0ed &4ca8 80 0e 06 3f 3f 3f 81 05 11 41 01 ff ; room &0ee &4cb4 50 00 3f 3f 3f 3f 81 c1 91 85 81 81 ; room &0ef &4cc0 50 42 da d1 1d 3f 81 83 83 db c3 81 ; room &0f0 &4ccc 50 20 1a 1c 3f 3f ff 83 93 b7 93 9f ; room &0f1 &4cd8 50 00 3f 3f 3f 3f ff c0 c7 f3 c3 df ; room &0f2 &4ce4 e8 e3 db d6 dc d1 ff 00 81 81 99 ff ; room &0f3 &4cf0 88 0e e1 ff 0e 3f ff 01 fd c1 81 bf ; room &0f4 &4cfc 4b 0d 0a 3f 3f 3f 87 e0 c8 c2 e0 ff ; room &0f5 &4d08 8b e0 2a 05 3f 3f 83 03 23 03 0f df ; room &0f6 &4d14 4b 00 3f 3f 3f 3f 81 c1 91 81 85 81 ; room &0f7 &4d20 4b 0d 1a 3f 3f 3f 81 e0 80 80 80 ff ; room &0f8 &4d2c 3b e3 19 03 3f 3f d1 01 09 03 41 ff ; room &0f9 &4d38 50 d0 2a 0c 3f 3f 81 89 81 81 9c ff ; room &0fa &4d44 50 d0 2a 16 3f 3f ff c4 d4 84 10 ff ; room &0fb &4d50 40 30 2a 1e 3f 3f ff 18 08 00 1f ff ; room &0fc &4d5c 40 03 d9 ff 1e 3f ff 24 00 00 c3 ff ; room &0fd &4d68 40 00 3f 3f 3f 3f ff 07 03 03 c3 c1 ; room &0fe &4d74 48 00 3f 3f 3f 3f 81 83 89 a1 81 81 ; room &0ff &4d80 48 22 db dc ca cd 81 db 81 e7 81 81 ; room &100 &4d8c 48 0d c0 ff 1c 3f 9f 01 21 03 c1 81 ; room &101 &4d98 e0 e4 21 15 3f 3f df 99 b1 91 80 ff ; room &102 &4da4 40 e8 d2 da d4 dc ff d5 c1 81 01 fd ; room &103 &4db0 88 0e 01 2c 3f 3f bf a0 80 80 87 ff ; room &104 &4dbc 58 99 da dc 1e 3f ff 14 00 00 ff ff ; room &105 &4dc8 58 90 22 1c ff de ff 16 00 00 ff ff ; room &106 &4dd4 80 0e 0c 1a 3f 3f 81 00 10 30 f3 ff ; room &107 &4de0 58 33 d9 da dd de ff 18 00 00 ff ff ; room &108 &4dec 58 07 9c 62 0e 3f ff 01 02 00 ff ff ; room &109 &4df8 58 99 e2 e3 e4 e5 ff 18 18 00 c3 ff ; room &10a &4e04 58 00 3f 3f 3f 3f ff 18 18 00 c3 ff ; room &10b &4e10 58 30 1a 1c 3f 3f ff 01 11 31 f9 c1 ; room &10c &4e1c 60 6f 62 1a 15 3f ff 80 86 80 a8 81 ; room &10d &4e28 78 0f 5a 3f 14 3f c1 01 0b 31 01 ff ; room &10e &4e34 40 00 3f 3f 3f 3f 81 c3 91 c3 89 c3 ; room &10f &4e40 54 00 3f 3f 3f 3f 81 81 91 c5 81 81 ; room &110 &4e4c 5c 03 da ff 0d 3f 81 c1 85 81 a3 81 ; room &111 &4e58 55 00 3f 3f 3f 3f ff 81 80 bf 81 fd ; room &112 &4e64 f5 0e 14 3f 3f 3f fd 81 01 f1 e1 ff ; room &113 &4e70 55 0d da ff 1c 3f ff a0 80 88 88 81 ; room &114 &4e7c 55 00 1b 3f 3f 3f ff 20 00 1c 00 ff ; room &115 &4e88 55 0d d2 ff 16 3f ff 20 02 00 03 ff ; room &116 &4e94 55 0d 24 3f 3f 3f ff 39 11 11 81 c1 ; room &117 &4ea0 50 0d 1c 3f 3f 3f ff 88 80 88 98 81 ; room &118 &4eac 48 0e d4 ff 26 3f ff 20 00 10 01 fd ; room &119 &4eb8 48 de 0e 1c ff d2 ff 01 01 09 e9 81 ; room &11a &4ec4 4c 0d 22 3f 3f 3f ff e0 c0 88 80 81 ; room &11b &4ed0 44 0d 0a 0d 3f 3f c1 23 21 01 03 ff ; room &11c &4edc 4c 00 3f 3f 3f 3f 81 88 c2 90 80 ff ; room &11d &4ee8 44 03 da ff 1d 3f ff 09 01 01 25 81 ; room &11e &4ef4 4a 09 1c 3f 3f 3f c3 81 91 81 89 c3 ; room &11f &4f00 4c 00 1b 3f 3f 3f 81 80 c0 8c 80 81 ; room &120 &4f0c 4c 03 15 3f 3f 3f 81 01 21 03 0f ff ; room &121 &4f18 55 02 1b 3f 3f 3f fd 81 c1 ef 87 bf ; room &122 &4f24 55 3d e8 ff 14 3f ff a0 08 00 08 01 ; room &123 &4f30 55 00 3f 3f 3f 3f 81 01 01 01 01 ff ; room &124 &4f3c 4d 03 14 3f 3f 3f ff a0 88 80 88 81 ; room &125 &4f48 4d 00 1b 3f 3f 3f ff 25 01 0d 09 81 ; room &126 &4f54 45 0d 0a 3f 3f 3f c1 a9 81 85 a1 81 ; room &127 &4f60 48 00 3f 3f 3f 3f 81 81 85 81 91 81 ; room &128 &4f6c 68 ed 12 06 3f 3f ff 91 a1 89 a1 81 ; room &129 &4f78 88 de 06 1a ff cc 83 c9 89 a1 a5 81 ; room &12a &4f84 5c 00 3f 3f 3f 3f 81 88 82 c0 90 81 ; room &12b &4f90 54 00 1b 3f 3f 3f ff 20 00 18 00 81 ; room &12c &4f9c 4c 0d d4 ff 22 3f ff 60 08 00 08 81 ; room &12d &4fa8 5c 09 1c 3f 3f 3f 81 01 23 01 09 81 ; room &12e &4fb4 4a 00 3f 3f 3f 3f c3 81 a1 85 91 81 ; room &12f &4fc0 5c 00 3f 3f 3f 3f 81 80 a2 88 80 81 ; room &130 &4fcc 54 06 1c 3f 3f 3f ff 01 21 01 0d 81 ; room &131 &4fd8 ed 0e 13 3f 3f 3f bf 99 c1 81 85 fd ; room &132 &4fe4 4d 30 2b 1c 3f 3f 81 80 80 80 88 ff ; room &133 &4ff0 45 00 3f 3f 3f 3f ff 00 00 00 00 ff ; room &134 &4ffc 4d 0d 0c 2d 3f 3f 81 09 19 01 03 ff ; room &135 &5008 4d 00 1d 3f 3f 3f 81 81 81 8d 99 81 ; room &136 &5014 4d 09 ca ff 1c 3f 81 85 a1 81 89 81 ; room &137 &5020 40 02 db ff 1c 3f 81 81 81 e7 81 81 ; room &138 &502c 20 9e d1 e2 c6 e3 83 81 89 81 81 bf ; room &139 &5038 80 0e d1 ff 06 3f 81 85 81 a1 89 83 ; room &13a &5044 54 0d 0c 3f 3f 3f 81 88 80 80 88 81 ; room &13b &5050 4c 00 3f 3f 3f 3f 81 00 10 04 20 81 ; room &13c &505c 4c 09 3f 3f 3f 3f 81 00 00 00 00 81 ; room &13d &5068 4c 0d 24 3f 3f 3f 81 09 01 21 01 81 ; room &13e &5074 5a 03 da ff 0d 3f 81 81 85 81 a1 81 ; room &13f &5080 4c 0d 1a 1d 3f 3f 81 90 80 a2 e0 ff ; room &140 &508c 4c 00 3f 3f 3f 3f 81 09 41 11 05 81 ; room &141 &5098 55 02 db ff 1d 3f f9 81 83 eb 80 ff ; room &142 &50a4 55 0d 18 3f 3f 3f ff b8 10 00 00 ff ; room &143 &50b0 55 0e da ff 1d 3f ff 10 00 00 00 ff ; room &144 &50bc 55 0e 13 3f 3f 3f ff 04 00 08 00 ff ; room &145 &50c8 5d 0e 12 2d 3f 3f 81 01 01 01 03 ff ; room &146 &50d4 5d 0d e4 ff 22 3f 81 a9 81 83 81 81 ; room &147 &50e0 50 02 d2 ff 15 3f 81 83 db da c0 ff ; room &148 &50ec 90 0e c1 ff 0e 3f bf 81 fd 01 01 ff ; room &149 &50f8 98 de ce dc 01 3f 83 91 81 89 e9 c1 ; room &14a &5104 4c 03 0c 3f 3f 3f 81 80 88 80 80 ff ; room &14b &5110 4c 0d 14 2a 3f 3f 81 00 08 00 0c df ; room &14c &511c 4c 00 3f 3f 3f 3f 81 00 00 00 00 ff ; room &14d &5128 4c 00 2a 3f 3f 3f 81 01 01 01 0f df ; room &14e &5134 4a 09 da ff 0c 3f 81 81 89 83 a1 81 ; room &14f &5140 5c 00 3f 3f 3f 3f ff 80 80 80 90 81 ; room &150 &514c 44 09 1c 3f 3f 3f 81 00 00 00 08 ff ; room &151 &5158 45 00 3f 3f 3f 3f ff 00 00 00 00 81 ; room &152 &5164 45 0d 1c 3f 3f 3f ff 18 00 00 00 ff ; room &153 &5170 5d dd d4 da 1e 3f ff 62 08 00 08 ff ; room &154 &517c 45 3d 1a 1d 3f 3f ff 18 00 20 24 81 ; room &155 &5188 45 00 3f 3f 3f 3f ff 00 20 04 00 ff ; room &156 &5194 4d 30 29 15 3f 3f 81 00 00 00 3e ff ; room &157 &51a0 45 0d 1a 3f 3f 3f ff 18 00 20 24 81 ; room &158 &51ac 45 0e 11 2b 3f 3f ff 08 00 00 00 ff ; room &159 &51b8 98 0e d1 ff 06 3f c3 09 01 21 01 cf ; room &15a &51c4 4a 3d 1a 1d 3f 3f ff 80 80 a0 a4 81 ; room &15b &51d0 4a 00 3f 3f 3f 3f ff 01 01 05 21 81 ; room &15c &51dc 4a 00 3f 3f 3f 3f ff 80 80 80 80 81 ; room &15d &51e8 4a 00 3f 3f 3f 3f ff 01 01 01 01 81 ; room &15e &51f4 52 00 3f 3f 3f 3f 81 b1 81 8d 81 81 ; room &15f &5200 44 07 1a 3f 3f 3f 81 81 c1 81 b9 e1 ; room &160 &520c 54 0d da ff 1c 3f ff a9 81 83 81 81 ; room &161 &5218 4d 0d d2 ff 14 3f 81 81 a9 83 a9 81 ; room &162 &5224 45 00 3f 3f 3f 3f ff 80 92 80 a4 81 ; room &163 &5230 5d 00 1b 3f 3f 3f ff 05 01 31 01 81 ; room &164 &523c 83 3e 14 0c 3f 3f 81 80 80 80 80 81 ; room &165 &5248 53 e3 1b 23 3f 3f ff 01 01 01 01 81 ; room &166 &5254 44 0d e2 ff 24 3f ff a9 81 83 81 81 ; room &167 &5260 3d 2e ca d9 cd de 81 81 81 81 81 81 ; room &168 &526c 58 0d da ff 24 3f ff 83 83 83 83 c3 ; room &169 &5278 58 70 2a 1c 3f 3f cf 85 a5 85 9f ff ; room &16a &5284 da ff 4b 15 5a 24 81 99 87 b1 8d 81 ; room &16b &5290 5a 00 3f 3f 3f 3f 81 80 80 80 80 ff ; room &16c &529c 5a 00 2d 3f 3f 3f 81 01 01 01 01 ff ; room &16d &52a8 5a 00 2b 3f 3f 3f 81 80 a4 80 80 ef ; room &16e &52b4 52 06 0c 3f 3f 3f 81 01 0d 21 01 ff ; room &16f &52c0 44 5d 12 1d 3f 3f e1 81 a0 80 a4 81 ; room &170 &52cc 54 02 cb ff 0d 3f 81 eb 01 01 01 ff ; room &171 &52d8 5d 02 da ff 1d 3f 81 81 81 db 81 81 ; room &172 &52e4 5d 6d 0a 0c 3f 3f 81 a1 8d 81 a1 83 ; room &173 &52f0 5d 09 ca ff 1c 3f 81 83 b1 81 cd 81 ; room &174 &52fc 8b de 04 1a 3f 3f 81 80 80 a0 fe ff ; room &175 &5308 4b 0e 03 3f 3f 3f 81 01 01 05 01 ff ; room &176 &5314 54 ff 13 15 22 24 81 c1 9f 81 bf 81 ; room &177 &5320 75 2e c2 de c5 d9 81 81 81 81 81 81 ; room &178 &532c 50 0d 0a 3f 3f 3f c3 a0 a0 80 84 81 ; room &179 &5338 42 d0 19 24 3f 3f ff 09 21 61 21 81 ; room &17a &5344 ca ff 4a 0d 5e 24 81 b6 80 83 8c 81 ; room &17b &5350 4a 30 29 13 3f 3f ff 01 01 01 3f ff ; room &17c &535c 4a 6d 22 1c 3f 3f ff a1 81 83 8d 81 ; room &17d &5368 4a 29 da e1 dc ff ff 80 80 80 bf 81 ; room &17e &5374 4a 03 d9 ff 1b 3f ff 09 01 01 f1 81 ; room &17f &5380 5c 33 e2 cb 1d 3f 81 80 90 80 84 a1 ; room &180 &538c 4c 90 68 1a ff db ff 49 01 03 71 ff ; room &181 &5398 55 22 e1 e3 e4 e6 81 db 81 81 a5 81 ; room &182 &53a4 55 0d 0a 3f 3f 3f 83 e0 c0 c4 e0 ff ; room &183 &53b0 4d d5 0b 0c 3f 3f 81 08 3c 00 00 ff ; room &184 &53bc 4c 00 1b 3f 3f 3f ff 42 00 08 00 81 ; room &185 &53c8 54 03 d9 ff 1e 3f ff 24 00 00 42 ff ; room &186 &53d4 5c f0 7f 12 3f 15 81 01 37 01 01 ff ; room &187 &53e0 2d 2e c2 d9 c5 de 81 81 81 81 81 bd ; room &188 &53ec 40 40 2b 11 3f 3f 81 81 81 c3 ef ff ; room &189 &53f8 52 99 ca cb dc dd 81 83 b1 81 cd 81 ; room &18a &5404 ca 0f 4a 3f 55 1b 81 b0 86 98 80 ff ; room &18b &5410 82 0e d3 ff 14 3f ff 00 00 00 00 81 ; room &18c &541c 5a 0d ca ff 0c 3f 81 29 29 01 01 ff ; room &18d &5428 4a 03 0b 3f 3f 3f 81 81 91 81 81 81 ; room &18e &5434 4a 06 ca ff 1c 3f 81 83 b1 81 8d 81 ; room &18f &5440 54 00 3f 3f 3f 3f a1 88 a2 88 80 ff ; room &190 &544c 4c 0d e2 ff 24 3f ff 29 01 03 01 81 ; room &191 &5458 5d 00 1b 3f 3f 3f 81 80 80 b8 80 81 ; room &192 &5464 55 dd da e4 1e 3f ff 3a 00 00 00 81 ; room &193 &5470 95 0e 14 3f 3f 3f ff 09 01 01 03 81 ; room &194 &547c 4c 99 ca cb dc dd 81 83 b1 81 cd 81 ; room &195 &5488 95 0e 12 3f 3f 3f ff 80 80 80 8c 81 ; room &196 &5494 55 03 d9 ff 1e 3f ff 18 00 00 42 c3 ; room &197 &54a0 5d 00 3f 3f 3f 3f bd 00 00 00 00 81 ; room &198 &54ac 4d d0 1b 24 3f 3f ff 41 09 39 01 81 ; room &199 &54b8 52 00 3f 3f 3f 3f 81 81 8f c0 8f 81 ; room &19a &54c4 4a 0d 1c 3f 3f 3f ff 89 e1 03 e1 81 ; room &19b &54d0 32 0e c3 ff 04 3f 91 81 81 c1 81 83 ; room &19c &54dc 4a 9d 1c 1e 3f 3f ff 88 80 c0 83 ff ; room &19d &54e8 52 03 1d 3f 3f 3f 81 01 01 01 85 81 ; room &19e &54f4 42 99 cc cd da db 81 c1 8d 81 b3 81 ; room &19f &5500 44 90 2e 1c ff db ff 98 80 c0 fc fd ; room &1a0 &550c 4c 83 ff ff d4 dc 81 01 01 01 29 81 ; room &1a1 &5518 5d 99 ca cb dc dd 81 80 b0 80 8c 81 ; room &1a2 &5524 55 00 3f 3f 3f 3f 81 08 40 11 04 81 ; room &1a3 &5530 95 0e 04 3f 3f 3f 89 01 01 83 21 81 ; room &1a4 &553c 4c 00 3f 3f 3f 3f 81 c1 99 83 99 c1 ; room &1a5 &5548 9d e2 c9 c2 d9 ff a1 80 80 80 8c 81 ; room &1a6 &5554 5d 03 db ff 1c 3f c3 42 42 42 5a c3 ; room &1a7 &5560 4d 00 3f 3f 3f 3f 81 00 00 00 00 81 ; room &1a8 &556c 4d 0d ca ff 0c 3f 81 29 01 01 29 81 ; room &1a9 &5578 4a 0d 1a 3f 3f 3f 81 99 81 a1 a5 81 ; room &1aa &5584 4a 6d 1a 0c 3f 3f 81 80 8c a0 e0 ff ; room &1ab &5590 4a e0 e9 c3 ff c4 83 00 00 00 3c ff ; room &1ac &559c 4a 07 1c 3f 3f 3f ff 18 10 00 1f ff ; room &1ad &55a8 52 03 ca ff 0d 3f 81 01 25 01 81 ff ; room &1ae &55b4 52 05 db ff 0d 3f 81 81 85 81 91 81 ; room &1af &55c0 54 33 d2 dc 16 3f ff 80 80 a2 88 81 ; room &1b0 &55cc 5c 00 28 3f 3f 3f 81 11 01 01 4f ff ; room &1b1 &55d8 4d 90 2d 1b ff de 81 80 80 80 f3 ff ; room &1b2 &55e4 4d 00 3f 3f 3f 3f 81 00 18 00 81 ff ; room &1b3 &55f0 4d 0e 04 3f 3f 3f 89 03 01 01 f1 ff ; room &1b4 &55fc 54 6d 12 0c 3f 3f c1 81 ad 83 b1 81 ; room &1b5 &5608 2d 0e 02 1d 3f 3f 81 80 80 82 f0 81 ; room &1b6 &5614 5d 0d d9 ff 1e 3f c3 42 00 00 00 81 ; room &1b7 &5620 a5 00 7f 3f 1b 3f 81 00 00 14 00 81 ; room &1b8 &562c 45 30 1b 0c 3f 3f 81 01 09 39 01 81 ; room &1b9 &5638 4a 0d dd ff 0a 3f 81 a5 81 81 a1 81 ; room &1ba &5644 57 0d 12 3f 3f 3f ff 81 a1 85 a1 81 ; room &1bb &5650 47 06 5a 3f 22 3f ff 80 80 84 a8 81 ; room &1bc &565c 5f 03 da ff 1d 3f ff 01 01 01 25 81 ; room &1bd &5668 47 0d 24 3f 3f 3f ff 80 80 a0 80 81 ; room &1be &5674 cf 00 3f 3f 3f 3f 81 25 01 11 05 81 ; room &1bf &5680 56 0d 1c 3f 3f 3f 81 80 c0 88 88 81 ; room &1c0 &568c 4e 3d 1c 1a 3f 3f ff 00 00 00 20 81 ; room &1c1 &5698 46 0d da ff 14 3f ff 00 00 22 20 ff ; room &1c2 &56a4 4e 9d 1a 1d 3f 3f ff 10 00 20 24 81 ; room &1c3 &56b0 56 d0 2b 16 3f 3f ff 04 04 20 0e ff ; room &1c4 &56bc 5e 90 2d 0a ff cd 81 01 25 01 01 ff ; room &1c5 &56c8 5d 6d 0a 0c 3f 3f 81 a0 ac a0 80 ff ; room &1c6 &56d4 5d 0d 1c 3f 3f 3f 81 18 00 40 00 ff ; room &1c7 &56e0 5d 90 2d 0a ff cd 81 00 24 00 00 ff ; room &1c8 &56ec 9d e3 0a 12 3f 3f 81 01 01 03 0f ff ; room &1c9 &56f8 5e f3 dd d2 8a 25 81 81 b1 81 87 81 ; room &1ca &5704 4f df 52 0c 1e 3f 81 88 b0 83 88 81 ; room &1cb &5710 47 d0 59 0c 1a 3f 81 09 09 31 01 ff ; room &1cc &571c 4e 00 23 3f 3f 3f 81 81 81 a1 ad 81 ; room &1cd &5728 47 d3 0d 0a 3f 3f 81 a1 85 81 a1 81 ; room &1ce &5734 47 99 e3 ca e5 cc 81 81 a9 81 81 ff ; room &1cf &5740 5e 50 2b 0a ff cd 81 80 a4 80 80 ff ; room &1d0 &574c 9e e3 5a 0c 3f 3f 81 01 01 03 21 ff ; room &1d1 &5758 5e 90 2f 1e ff e4 ff 88 88 c0 82 fe ; room &1d2 &5764 46 00 3f 3f 3f 3f 81 15 41 09 23 81 ; room &1d3 &5770 5e 6d 1a 1c 3f 3f ff 84 80 80 8c 81 ; room &1d4 &577c 56 03 da ff 1d 3f ff 00 00 00 24 81 ; room &1d5 &5788 56 d0 2b 12 3f 3f ff 01 01 01 05 ff ; room &1d6 &5794 46 00 3f 3f 3f 3f ff 80 84 80 a0 81 ; room &1d7 &57a0 46 55 9a 1d a5 22 ff 42 02 00 36 81 ; room &1d8 &57ac 56 0d e3 ff 14 3f ff 01 01 41 05 81 ; room &1d9 &57b8 5e 3f 9a 12 dd d5 81 81 81 b7 81 81 ; room &1da &57c4 7f 03 da ff 0d 3f 81 80 84 80 a0 81 ; room &1db &57d0 90 30 28 21 3f 3f ff 01 01 01 01 ff ; room &1dc &57dc 5f a9 e1 da 26 3f 81 81 81 81 81 ff ; room &1dd &57e8 b7 60 29 24 3f 3f 81 80 a4 80 80 ff ; room &1de &57f4 48 00 3f 3f 3f 3f ff 01 01 01 01 81 ; room &1df &5800 46 9d 9a 1d a2 25 ff 80 80 a0 b6 81 ; room &1e0 &580c 46 0a 12 3f 3f 3f ff 00 20 00 00 ff ; room &1e1 &5818 5e 1e 13 1d 3f 3f ff 61 61 0b 4b fb ; room &1e2 &5824 56 03 ca ff 0d 3f 81 80 bc 80 80 ff ; room &1e3 &5830 4e 00 2d 3f 3f 3f 81 05 21 01 01 ff ; room &1e4 &583c 46 3d 62 0d 3f 3f 81 80 e4 a0 80 81 ; room &1e5 &5848 4e 3d d3 d9 16 3f ff 14 04 00 44 ff ; room &1e6 &5854 5e 00 bf 3f e3 13 81 00 04 10 14 81 ; room &1e7 &5860 56 99 ca d4 15 3f 81 01 21 0d 01 ff ; room &1e8 &586c 46 99 d2 d3 d5 d4 81 80 80 bc 80 81 ; room &1e9 &5878 56 00 3f 3f 3f 3f 81 01 01 01 01 81 ; room &1ea &5884 4f 9d 92 7f dc ff 81 80 a0 8a a0 81 ; room &1eb &5890 5f 0d 1c 3f 3f 3f ff 01 01 21 01 81 ; room &1ec &589c 57 90 2e 23 ff e4 ff 82 80 a2 80 fd ; room &1ed &58a8 c0 93 ff db e7 dc ff 00 00 00 18 81 ; room &1ee &58b4 88 93 60 23 ff e5 81 01 01 01 01 ff ; room &1ef &58c0 46 33 4a 0d 52 15 81 80 b6 80 80 ff ; room &1f0 &58cc 56 35 e1 d9 e6 de ff 10 00 00 00 ff ; room &1f1 &58d8 5e 95 e1 d9 e6 de fb 42 00 00 00 ff ; room &1f2 &58e4 5e 0d 1e 3f 3f 3f ff 1a 08 08 08 ff ; room &1f3 &58f0 5e 6d d1 e4 16 3f ff 40 00 00 00 ff ; room &1f4 &58fc 56 99 e5 e4 e3 e2 81 19 01 01 01 ff ; room &1f5 &5908 46 90 2e 23 ff e4 ff 82 82 a0 80 fd ; room &1f6 &5914 56 65 27 23 ff 3f 81 01 01 01 01 ff ; room &1f7 &5920 5e d0 2e 1d 3f 3f ff 80 80 c0 80 fd ; room &1f8 &592c 4e 63 0d 24 3f 3f 81 01 25 21 21 ff ; room &1f9 &5938 56 05 e0 ea 27 3f 81 81 81 81 00 df ; room &1fa &5944 50 f9 ca d2 8c 54 81 81 bd 81 81 ff ; room &1fb &5950 40 60 2c 22 3f 3f 81 80 80 80 80 f7 ; room &1fc &595c 88 53 d9 e1 de e6 ff 00 00 00 00 ff ; room &1fd &5968 70 0a 12 3f 3f 3f 81 00 20 00 00 ff ; room &1fe &5974 58 d0 ff da e9 dc ff 01 01 01 01 ff ; room &1ff ; tile_subtile_table &5980 00 00 00 00 00 00 ; TILE_EMPTY ; tile_subtile_table &5980 00 00 00 00 00 00 ; TILE_EMPTY &5986 11 11 11 11 11 11 ; TILE_WALL_EARTH &598c 11 11 11 11 10 01 ; TILE_WALL_WISPS &5992 11 11 11 11 11 11 ; TILE_WALL_STONES &5998 11 11 11 11 11 11 ; TILE_WALL_MOLECULES &599e 11 11 11 11 11 11 ; TILE_WALL_SQUARES &59a4 11 11 11 11 11 11 ; TILE_WALL_RECTANGLES &59aa 11 11 11 11 11 11 ; TILE_SIGN &59b0 11 11 11 11 11 11 ; TILE_WALL_TWIN &59b6 71 17 11 11 11 11 ; TILE_HOPPER_PAD &59bc 11 44 00 00 00 00 ; TILE_HORIZONTAL_GATE &59c2 01 10 01 10 01 10 ; TILE_SPARK_GATE &59c8 00 00 00 00 10 01 ; TILE_SPARK_HEAD &59ce 11 00 11 00 11 00 ; TILE_MUSHROOM &59d4 00 00 10 11 11 11 ; TILE_SKELETONAUT_LEFT &59da 00 00 01 00 11 11 ; TILE_SKELETONAUT_RIGHT &59e0 11 11 11 11 11 11 ; TILE_DOME &59e6 00 00 20 02 20 02 ; TILE_SPIKE &59ec 00 22 00 22 00 10 ; TILE_SPIKE_ON_LEDGE &59f2 65 56 35 53 35 53 ; TILE_PIPE_CLOSED &59f8 65 56 33 33 33 33 ; TILE_PIPE_BOTH &59fe 65 56 33 53 33 53 ; TILE_PIPE_LEFT &5a04 65 56 35 33 35 33 ; TILE_PIPE_RIGHT &5a0a 11 11 33 33 33 33 ; TILE_PIPE_TOP &5a10 11 11 11 11 11 11 ; TILE_STARS &5a16 11 11 11 11 11 11 ; TILE_PLANT_HEAD &5a1c 11 11 11 11 11 11 ; (unused) &5a22 11 11 11 11 11 11 ; TILE_PLANT_FLOWER &5a28 11 11 11 11 11 11 ; (unused) &5a2e 11 11 11 11 11 11 ; TILE_PLANT_BRANCHES &5a34 11 11 11 11 11 11 ; (unused) &5a3a 11 11 11 11 11 11 ; TILE_HEXAGONS &5a40 11 11 11 11 11 11 ; (unused) &5a46 11 11 11 11 11 11 ; TILE_THREE_HEADED_DOME &5a4c 11 11 11 11 11 11 ; TILE_WHEELED_WALL &5a52 11 11 00 11 00 11 ; TILE_SPACE_LOCK_LEFT &5a58 11 11 11 00 11 00 ; TILE_SPACE_LOCK_RIGHT &5a5e 11 11 00 11 00 11 ; TILE_TELEPORT ; tile_sprites ; tile_sprite_01 TILE_WALL_EARTH &5a64 d9 6f aa ba 4c b6 f9 06 6d 6e 76 d5 7d af ba 66 &5a74 59 55 2b 66 8d 31 46 9d 2b 22 9b cc 45 66 a6 bb &5a84 dc b9 ce 54 e8 26 e2 dd b7 7e fe dd 39 37 a2 62 ; tile_sprite_02 TILE_WALL_WISPS &5a94 c0 3e 02 00 10 c0 00 70 90 5f 00 ef f0 09 00 88 &5aa4 00 7c 15 6c 8d 80 5f 00 04 11 4c 00 00 7c 02 71 &5ab4 13 00 00 00 5f 00 a7 08 81 00 e8 1b 0c 00 00 00 ; tile_sprite_03 TILE_WALL_STONES &5ac4 73 77 8b f6 d9 cd 7b 67 e8 de b3 d0 ff 16 3b ed &5ad4 ff 06 e6 bd 61 ff 6f d9 ee 46 d1 ee ee c2 ee 8e &5ae4 3b 61 ee 4f 9d f6 ff 06 ee 2c 77 6f f6 ff 06 f6 ; tile_sprite_04 TILE_WALL_MOLECULES &5af4 31 13 20 40 a0 18 01 00 01 d8 8c 80 20 77 02 42 &5b04 ee 04 02 31 01 39 13 80 00 a0 08 00 40 ee 04 18 &5b14 13 00 00 00 08 98 e4 4e 72 27 20 12 04 00 00 00 ; tile_sprite_05 TILE_WALL_SQUARES &5b24 30 33 33 00 e0 ee ee 00 11 01 ff ff ee 6e 66 06 &5b34 77 77 54 15 88 99 e0 ee 00 cc cc cc 00 ff ff ff &5b44 11 01 00 00 ee 0e 77 77 e0 ee ee ee 00 00 00 00 ; tile_sprite_06 TILE_WALL_RECTANGLES &5b54 6e 6e 6e 4e 00 00 13 13 13 13 8b 88 00 60 62 62 &5b64 4d 0d 01 01 9b 9b 9b 9b 88 88 88 9b 62 62 62 62 &5b74 01 01 00 00 9b 1b 13 00 9b 9b 9b 13 00 00 00 00 ; tile_sprite_07 TILE_SIGN &5b84 a7 88 aa ff af aa ab 7f 4f 4d 45 ff 9e 9b 9d ff &5b94 7e 01 00 00 70 1e 10 11 f0 87 80 88 e7 08 00 00 &5ba4 00 00 00 00 11 10 23 55 88 80 cc ee 00 00 00 00 ; tile_sprite_08 TILE_WALL_TWIN &5bb4 30 73 e7 cc b0 db ed a6 b0 7b f6 dd 80 c8 64 aa &5bc4 ba fc 77 3b 6a ee dd bb ff ff 76 bb aa 6a c4 8a &5bd4 34 13 00 00 77 cb 7b 03 dc 7b ca 08 84 08 00 00 ; tile_sprite_09 TILE_HOPPER_PAD &5be4 ae ee 0a aa 00 00 00 00 00 00 00 00 57 77 05 55 &5bf4 ae aa ba bb fc cc 7c 55 f3 bb 2f 22 57 55 d5 dd &5c04 fb ee 7f 37 37 cc c3 ff ce 33 3c ff fd 77 ef ce ; tile_sprite_0a TILE_HORIZONTAL_GATE &5c14 b7 ea dd 88 60 bf cf 00 60 df 3f 00 de 75 bb 11 &5c24 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 &5c34 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ; tile_sprite_0b TILE_SPARK_GATE &5c44 60 bf ff 9f 00 00 00 00 00 00 00 00 60 df ff 9f &5c54 28 ff 2f 98 00 80 00 00 00 10 00 00 41 ff 4f 91 &5c64 ff bf 6f 00 00 00 00 00 00 00 00 00 ff df 6f 00 ; tile_sprite_0c TILE_SPARK_HEAD &5c74 60 bf fb 43 00 00 00 00 00 00 00 00 60 bf fb 2c &5c84 44 66 33 22 00 00 00 c8 00 00 00 31 22 66 cc 44 &5c94 11 01 00 00 63 95 98 07 ec fe ff 0e 88 08 00 00 ; tile_sprite_0d TILE_MUSHROOM &5ca4 30 55 bf 78 80 c4 a6 ce 00 00 00 00 00 00 00 00 &5cb4 50 85 05 55 80 48 08 88 00 00 00 00 00 00 00 00 &5cc4 55 99 ab d2 08 53 d7 6f 00 00 00 00 00 00 00 00 ; tile_sprite_0e TILE_SKELETONAUT_LEFT &5cd4 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 &5ce4 00 00 10 21 10 70 b7 d5 80 16 88 cc e0 69 7d a0 &5cf4 22 03 41 0b bd 7b 1e 8e dd cd f1 0e 55 45 44 85 ; tile_sprite_0f TILE_SKELETONAUT_RIGHT &5d04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 &5d14 00 1e 5d 0d 00 00 00 00 00 00 00 00 00 00 00 00 &5d24 40 92 99 0a 31 23 45 e0 00 00 e8 02 00 00 d2 19 ; tile_sprite_10 TILE_DOME &5d34 00 11 22 44 f0 b7 db de f0 ef ad a5 00 88 cc ee &5d44 aa 99 88 99 bb 77 ff 77 c5 a7 b5 a6 dd bb 77 bb &5d54 aa cc aa 07 5b 5b 5b 0f c4 84 88 0f b5 b5 b5 0e ; tile_sprite_11 TILE_SPIKE &5d64 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 &5d74 00 00 00 00 11 d9 75 37 00 b9 6a c6 00 00 00 00 &5d84 00 00 00 00 7d 73 d5 19 ef c4 b6 89 00 00 00 00 ; tile_sprite_12 TILE_SPIKE_ON_LEDGE &5d94 00 00 00 00 00 00 00 00 11 d9 75 37 00 b9 6a c6 &5da4 00 00 00 00 00 00 00 00 7d 73 d5 19 ef c4 b6 89 &5db4 00 00 00 00 00 00 00 00 30 32 01 00 e0 7f ff 00 ; tile_sprite_13 TILE_PIPE_CLOSED &5dc4 bb bb bb bb ef bd d9 cd 7f db b9 3b dd dd dd dd &5dd4 bb bb bb bb ff ff ff ff ff ff ff ff dd dd dd dd &5de4 bb bb bb bb ff ff ff ff ff ff ff ff dd dd dd dd ; tile_sprite_14 TILE_PIPE_BOTH &5df4 bb bb bb db ef bd d9 cd 7f db b9 3b dd dd dd bd &5e04 55 55 55 55 ff ff ff ff ff ff ff ff aa aa aa aa &5e14 55 55 55 b5 ff ff ff ff ff ff ff ff aa aa aa da ; tile_sprite_15 TILE_PIPE_LEFT &5e24 bb bb bb db ef bd d9 cd 7f db b9 3b dd dd dd dd &5e34 55 55 55 55 ff ff ff ff ff ff ff ff dd dd dd dd &5e44 55 55 55 b5 ff ff ff ff ff ff ff ff dd dd dd dd ; tile_sprite_16 TILE_PIPE_RIGHT &5e54 bb bb bb bb ef bd d9 cd 7f db b9 3b dd dd dd bd &5e64 bb bb bb bb ff ff ff ff ff ff ff ff aa aa aa aa &5e74 bb bb bb bb ff ff ff ff ff ff ff ff aa aa aa da ; tile_sprite_17 TILE_PIPE_TOP &5e84 ff ff f0 bf ff ff f0 ff ff ff f0 ff ff ff f0 df &5e94 55 55 55 55 ff ff ff ff ff ff ff ff aa aa aa aa &5ea4 55 55 55 b5 ff ff ff ff ff ff ff ff aa aa aa da ; tile_sprite_18 TILE_STARS &5eb4 00 00 40 00 00 00 00 01 00 00 80 8c 00 00 00 00 &5ec4 00 00 10 00 00 00 00 00 00 00 20 00 00 02 00 00 &5ed4 00 00 20 27 00 20 00 00 00 00 00 00 00 00 00 04 ; tile_sprite_19 TILE_PLANT_HEAD &5ee4 10 40 60 50 30 00 00 01 81 01 03 02 06 0c 09 03 &5ef4 08 60 b0 60 01 0f 2e aa 00 00 00 00 08 08 88 88 &5e04 01 02 02 02 03 03 01 01 17 0c 08 2a 3f 07 08 07 &5e14 aa 88 22 bb cf 0c 03 0f 00 88 cc 0c 00 0c 0c 04 &5e24 01 00 00 00 00 00 00 00 06 08 0d 06 06 03 00 00 &5e34 0d 07 0e 05 0f 0c 00 00 0c 08 08 08 00 00 00 00 ; tile_sprite_1b TILE_PLANT_FLOWER &5e44 00 00 06 09 0b 0c 0e 07 00 00 01 01 01 01 00 0a &5e54 00 0d 0e 0e 0e 0e 0c 00 00 08 0c 0c 0c 04 00 ee &5e64 07 03 03 01 00 00 00 00 0d 0d 0d 0e 0f 03 00 01 &5e74 1d 1d 0c 0c 0a 07 07 07 99 11 15 0e 0e 06 04 00 &5e84 00 00 00 10 10 10 00 40 01 01 c1 61 c1 00 00 00 &5e94 02 00 00 00 30 68 18 08 00 00 00 00 00 80 80 00 ; tile_sprite_1d TILE_PLANT_BRANCHES &5ea4 a0 60 20 00 40 50 70 20 00 60 50 b0 60 01 01 01 &5eb4 08 18 38 38 18 08 00 00 00 80 40 80 80 20 30 f0 &5ec4 03 06 0c 40 e0 50 40 20 09 0c 07 03 00 c0 60 c1 &5ed4 00 08 0f 07 04 0c 18 18 20 0e 0f 08 80 c0 40 40 &5ee4 00 70 c0 a0 c0 10 00 20 01 01 01 01 c1 41 41 80 &5ef4 00 00 00 60 70 40 20 08 20 20 a0 60 20 60 40 00 ; tile_sprite_1f TILE_HEXAGONS &6004 00 10 fe ff f7 ff ff 87 fe ff ff 1e 00 80 f7 ff &6014 ff 1e 2e 01 f7 ff ff 87 fe ff ff 1e ff 87 47 08 &6024 21 1e 2e 01 47 08 48 87 2e 01 21 1e 48 87 47 08 ; core_element_from_pocket_sound ; chan vol pitch dur &6034 10 00 f1 00 02 00 02 00 ; restored_core_element_sound ; chan vol pitch dur &603c 11 00 00 00 ff 00 01 00 ; player_firing_sound ; chan vol pitch dur &6044 12 00 01 00 3c 00 02 00 ; enemy_materialising_sound ; chan vol pitch dur &604c 13 00 02 00 14 00 05 00 ; player_falling_sound ; chan vol pitch dur &6054 12 00 03 00 64 00 01 00 ; bridging_platform_sound ; chan vol pitch dur &605c 10 00 f9 00 02 00 01 00 ; tile_sprite_21 TILE_THREE_HEADED_DOME &6064 00 21 40 44 97 73 f0 4f de fe f0 2f 00 48 a0 2a &6074 73 5d 3f 5d 5b 75 aa 1a ad ea 55 85 ec ab cf ab &6084 20 01 00 00 74 03 99 09 f2 0e dd 0d 40 08 00 00 ; tile_sprite_22 TILE_WHEELED_WALL &6094 00 c0 de ad 00 10 d3 ad 00 c0 de ad 00 10 d3 2d &60a4 6a 55 64 a6 3a 55 b1 2b 5a 45 45 a6 52 15 d9 2b &60b4 db ed cc 89 d6 3d 99 0c db ed cc 89 d6 3d 99 0c ; tile_sprite_23 TILE_SPACE_LOCK_LEFT &60c4 33 ed ee 40 ff 0f ff 10 cc 7b 56 f0 f0 70 ff 70 &60d4 88 88 88 88 00 00 00 00 ae ae ae ee ce 89 ed ff &60e4 88 88 88 48 00 00 00 10 ea ee aa ea f9 8f 8b ff ; tile_sprite_24 TILE_SPACE_LOCK_RIGHT &60f4 f0 e0 ff e0 33 ed a6 f0 ff 0f ff 80 cc 7b 77 20 &6104 b7 91 73 ff 57 57 57 77 00 00 00 00 11 11 11 11 &6114 9f ff d1 f1 75 77 55 75 00 00 00 80 11 11 11 21 ; tile_sprite_25 TILE_TELEPORT &6124 00 33 66 55 dd ff 88 44 ff 88 77 ff ff ff 00 10 &6134 ff 11 ee ff ff ff 33 d1 00 cc 66 aa bb ff 11 11 &6144 88 88 88 88 88 88 88 88 00 00 00 00 00 00 00 00 &6154 e0 a0 e0 a0 e0 a0 e0 e0 bb bb bb ff dd dd dd dd &6164 88 88 88 88 88 88 88 44 00 00 00 00 00 00 00 10 &6174 a0 e0 e0 e0 a0 a0 a0 e0 dd dd dd dd dd dd dd dd ; unused &6184 00 ; rooms_with_patrolling_droids &6185 b3 4b ; room &1b3 &6187 0b 4b ; room &10b &6189 86 4b ; room &186 &618b dc 4b ; room &1dc &618d fb 4b ; room &1fb &618f fd 4b ; room &1fd &6191 ff 4b ; room &1ff &6193 ff 4b ; room &1ff (repeated) &6195 de 49 ; room &1de &6197 cf 4b ; room &1cf &6199 9d 4b ; room &19d &619b ae 4b ; room &1ae &619d d2 4b ; room &1d2 &619f f2 4b ; room &1f2 &61a1 f1 4b ; room &1f1 &61a3 b1 49 ; room &1b1 &61a5 81 8a ; room &181 &61a7 f8 4b ; room &1f8 &61a9 f6 2b ; room &1f6 ; gate_sprite &61ab 77 33 55 22 ee cc aa 44 11 32 23 11 88 c4 4c 88 &61bb 22 55 33 77 44 aa cc ee ; gate_table &61c3 be 78 ; room &0be &61c5 fc 88 ; room &0fc &61c7 c4 a9 ; room &1c4 &61c9 e6 a9 ; room &1e6 &61cb e2 29 ; room &1e2 ; possible_core_element_locations &61cd 08 4e 28 40 ; room &008 or room &028, ITEM_PASS # ITEM_PASS can occur in one of four rooms &61d1 a8 2a b6 46 ; room &0a8 or room &0b6, ITEM_PASS &61d5 96 22 c6 46 ; room &096 or room &0c6, ITEM_KEY # ITEM_KEY can occur in one of four rooms &61d9 c8 34 f6 38 ; room &0c8 or room &0f6, ITEM_KEY &61dd b4 4d a6 23 ; room &1b4 or room &1a6, core elements # Core elements can occur in one of two rooms &61e1 ec 02 de 2a ; room &0ec or room &0de &61e5 34 46 10 46 ; room &034 or room &010 &61e9 f6 25 f8 23 ; room &1f6 or room &1f8 &61ed 28 1b 3a 0b ; room &128 or room &13a &61f1 48 2a 6a 40 ; room &048 or room &06a &61f5 36 29 16 47 ; room &136 or room &116 &61f9 38 22 2a 46 ; room &038 or room &02a &61fd a0 23 60 43 ; room &1a0 or room &160 &6201 8c 4c 0e 36 ; room &08c or room &00e &6205 0a 33 3c 4f ; room &10a or room &13c &6209 dc 4d e2 2d ; room &1dc or room &1e2 &620d 54 24 56 2c ; room &054 or room &056 &6211 de 4d 3e 4a ; room &1de or room &03e &6215 50 4a 52 36 ; room &050 or room &052 &6219 e2 38 c2 42 ; room &0e2 or room &0c2 &621d 72 4e 74 40 ; room &072 or room &074 &6221 d2 23 74 33 ; room &1d2 or room &174 ; teleport_data ; -8 -7 -6 -5 -4 -3 -2 -1 ; password tl rm xy &6225 52 4f 47 41 4c cc 1f 36 ; room &01f, "ROGAL" &622d 56 49 4c 47 41 cc 28 3a ; room &028, "VILGA" &6235 54 41 4d 49 53 cc 42 3a ; room &042, "TAMIS" &623d 41 53 4f 47 45 cc 96 3a ; room &096, "ASOGE" &6245 44 41 52 41 51 cc a2 3a ; room &0a2, "DARAQ" &624d 51 55 41 52 4b cc d5 3a ; room &0d5, "QUARK" &6255 53 41 4d 41 4c cc 21 3b ; room &121, "SAMAL" &625d 4c 45 58 49 41 cc 57 3b ; room &157, "LEXIA" &6265 4b 4f 50 45 58 cc 7c 37 ; room &17c, "KOPEX" &626d 55 52 49 41 48 cc b1 3b ; room &1b1, "URIAH" &6275 48 41 52 49 41 cc c9 3b ; room &1c9, "HARIA &627d 4f 4b 52 49 50 cc cd 3b ; room &1cd, "OKRIP &6285 41 52 4c 4f 4e cc d6 3b ; room &1d6, "ARLON" &628d 4d 49 53 45 53 cc f3 47 ; room &1f3, "MISES &6295 4f 54 52 55 4e cc fa 4b ; room &1fa, "OTRUN" ; pipe_arrow_sprite &629d 00 11 22 44 66 22 22 33 00 88 44 22 66 44 66 44 44 cc ; update_pipe_arrows &62ad a9 00 LDA #&00 &62af 85 8b STA &8b ; column_to_consider ; update_pipe_arrows_loop &62b1 a4 8b LDY &8b ; column_to_consider &62b3 38 SEC &62b4 b9 50 01 LDA &0150,Y ; pipe_arrow_columns_status &62b7 e9 01 SBC #&01 &62b9 29 3f AND #&3f &62bb 99 50 01 STA &0150,Y ; pipe_arrow_columns_status &62be 29 01 AND #&01 &62c0 d0 35 BNE &62f7 ; consider_next_pipe_arrow &62c2 b9 50 01 LDA &0150,Y ; pipe_arrow_columns_status &62c5 c9 0c CMP #&0c # If an even number between 0 and 10, &62c7 10 2e BPL &62f7 ; consider_next_pipe_arrow &62c9 0a ASL A &62ca 0a ASL A &62cb 85 8e STA &8e ; tmp # consider the corresponding row between 0 and 5 &62cd 98 TYA &62ce 65 8e ADC &8e ; tmp &62d0 aa TAX &62d1 bd 20 01 LDA &0120,X ; pipe_in_tile # and the tile in that row. Is it a pipe? &62d4 f0 21 BEQ &62f7 ; consider_next_pipe_arrow &62d6 b9 50 01 LDA &0150,Y ; pipe_arrow_columns_status # If so, calculate the corresponding screen address &62d9 85 8f STA &8f ; screen_address_high &62db 4a LSR A &62dc 65 8f ADC &8f ; screen_address_high &62de 69 6d ADC #&6d &62e0 85 8f STA &8f ; screen_address_high &62e2 98 TYA &62e3 0a ASL A &62e4 0a ASL A &62e5 0a ASL A &62e6 0a ASL A &62e7 0a ASL A &62e8 69 08 ADC #&08 &62ea 85 8e STA &8e ; screen_address_low &62ec a9 9d LDA #&9d &62ee 85 8c STA &8c ; sprite_address_low &62f0 a9 62 LDA #&62 ; &629d = pipe_arrow_sprite &62f2 85 8d STA &8d ; sprite_address_high &62f4 20 d4 65 JSR &65d4 ; plot_single_character_sprite # Plot or unplot arrow on pipe ; consider_next_pipe_arrow &62f7 e6 8b INC &8b ; column_to_consider &62f9 a5 8b LDA &8b ; column_to_consider &62fb c9 08 CMP #&08 &62fd d0 b2 BNE &62b1 ; update_pipe_arrows_loop &62ff 60 RTS ; plot_player # Called with X = width, Y = height &6300 a5 8e LDA &8e ; screen_address_low &6302 29 07 AND #&07 &6304 85 89 STA &89 ; row_in_group &6306 8a TXA &6307 0a ASL A &6308 0a ASL A &6309 0a ASL A &630a 85 8a STA &8a ; bytes_in_group &630c 84 8b STY &8b ; groups_to_plot &630e a5 8e LDA &8e ; screen_address_low &6310 29 f8 AND #&f8 &6312 aa TAX &6313 a4 8f LDY &8f ; screen_address_high &6315 20 e0 65 JSR &65e0 ; calculate_subtile_address_from_screen_address ; store_player_subtiles &6318 a2 00 LDX #&00 &631a a0 00 LDY #&00 ; store_player_subtiles_loop &631c b1 6b LDA (&6b),Y ; subtile_address &631e 29 02 AND #&02 ; SUBTILE_HIDE_PLAYER # Note if part of player is obscured by pipe &6320 9d c8 01 STA &01c8,X ; player_subtiles &6323 e8 INX &6324 c8 INY # Move right one subtile &6325 98 TYA &6326 29 03 AND #&03 &6328 c9 03 CMP #&03 # Three subtiles wide &632a d0 f0 BNE &631c ; store_player_subtiles_loop &632c 98 TYA &632d 18 CLC &632e 69 1d ADC #&1d # Move down one subtile &6330 a8 TAY &6331 c0 60 CPY #&60 # Three subtiles high &6333 30 e7 BMI &631c ; store_player_subtiles_loop ; plot_subtiles &6335 a9 00 LDA #&00 &6337 85 87 STA &87 ; subtile_offset ; plot_subtiles_column_loop &6339 a0 00 LDY #&00 &633b 38 SEC &633c a5 8e LDA &8e ; screen_address_low &633e 29 07 AND #&07 &6340 85 88 STA &88 ; sprite_offset &6342 a9 08 LDA #&08 &6344 e5 88 SBC &88 ; sprite_offset &6346 85 88 STA &88 ; sprite_offset ; plot_top_subtiles_row_loop &6348 a6 87 LDX &87 ; subtile_offset &634a bd c8 01 LDA &01c8,X ; player_subtiles &634d f0 04 BEQ &6353 ; plot_top_subtile # Is the subtile obscured? &634f c8 INY # If so, move right a subtile &6350 4c 5e 63 JMP &635e ; skip_plotting_top_subtile ; plot_top_subtile &6353 b1 8e LDA (&8e),Y ; screen_address &6355 51 8c EOR (&8c),Y ; sprite_address &6357 91 8e STA (&8e),Y ; screen_address &6359 c8 INY &635a c4 88 CPY &88 ; sprite_offset &635c d0 f5 BNE &6353 ; plot_top_subtile &635e e6 87 INC &87 ; subtile_offset ; skip_plotting_top_subtile &6360 98 TYA &6361 18 CLC &6362 69 07 ADC #&07 &6364 29 f8 AND #&f8 &6366 a8 TAY &6367 a5 88 LDA &88 ; sprite_offset &6369 69 08 ADC #&08 &636b 85 88 STA &88 ; sprite_offset &636d c4 8a CPY &8a ; bytes_in_group &636f d0 d7 BNE &6348 ; plot_top_subtiles_row_loop &6371 18 CLC &6372 a5 8e LDA &8e ; screen_address_low &6374 69 f8 ADC #&f8 &6376 85 8e STA &8e ; screen_address_low &6378 a5 8f LDA &8f ; screen_address_high &637a 69 00 ADC #&00 &637c 85 8f STA &8f ; screen_address_high &637e a5 89 LDA &89 ; row_in_group &6380 f0 36 BEQ &63b8 ; next_group # If sprite aligned with group, no bottom to plot &6382 a0 00 LDY #&00 ; plot_bottom_subtiles_row_loop &6384 38 SEC &6385 a9 08 LDA #&08 &6387 e5 89 SBC &89 ; row_in_group &6389 85 88 STA &88 ; sprite_offset &638b 98 TYA &638c 05 88 ORA &88 ; sprite_offset &638e a8 TAY &638f a6 87 LDX &87 ; subtile_offset &6391 bd c8 01 LDA &01c8,X ; player_subtiles # Is subtile obscured? &6394 f0 0a BEQ &63a0 ; plot_bottom_subtile &6396 98 TYA # If so, move right a subtile &6397 18 CLC &6398 69 08 ADC #&08 &639a 29 f8 AND #&f8 &639c a8 TAY &639d 4c ac 63 JMP &63ac ; skip_plotting_bottom_subtile ; plot_bottom_subtile &63a0 b1 8e LDA (&8e),Y ; screen_address &63a2 51 8c EOR (&8c),Y ; sprite_address &63a4 91 8e STA (&8e),Y ; screen_address &63a6 c8 INY &63a7 98 TYA &63a8 29 07 AND #&07 &63aa d0 f4 BNE &63a0 ; plot_bottom_subtile ; skip_plotting_bottom_subtile &63ac e6 87 INC &87 ; subtile_offset &63ae c4 8a CPY &8a ; bytes_in_group &63b0 d0 d2 BNE &6384 ; plot_bottom_subtiles_row_loop &63b2 c6 87 DEC &87 ; subtile_offset &63b4 c6 87 DEC &87 ; subtile_offset &63b6 c6 87 DEC &87 ; subtile_offset ; next_group &63b8 18 CLC &63b9 a5 8e LDA &8e ; screen_address_low &63bb 69 08 ADC #&08 &63bd 85 8e STA &8e ; screen_address_low &63bf a5 8f LDA &8f ; screen_address_high &63c1 69 00 ADC #&00 &63c3 85 8f STA &8f ; screen_address_high &63c5 a5 8c LDA &8c ; sprite_address_low &63c7 65 8a ADC &8a ; bytes_in_group &63c9 85 8c STA &8c ; sprite_address_low &63cb 90 02 BCC &63cf ; skip_overflow &63cd e6 8d INC &8d ; sprite_address_high ; skip_overflow &63cf c6 8b DEC &8b ; groups_to_plot &63d1 f0 03 BEQ &63d6 ; leave &63d3 4c 39 63 JMP &6339 ; plot_subtiles_column_loop ; leave &63d6 60 RTS ; unused &63d7 00 ; passage_data &63d8 29 2c 2a 22 ; room &029 <-> room &02a &63dc 33 4c 34 42 ; room &033 <-> room &034 &63e0 3d 2c 3e 22 ; room &03d <-> room &03e &63e4 9a 4c 9b 42 ; room &09a <-> room &09b &63e8 9d 48 9e 42 ; room &09d <-> room &09e &63ec c2 44 c3 46 ; room &0c2 <-> room &0c3 &63f0 ec 4c ed 42 ; room &0ec <-> room &0ed &63f4 f1 4c f2 22 ; room &0f1 <-> room &0f2 &63f6 69 2d 6a 3b ; room &169 <-> room &16a &63fc 79 4c 7a 42 ; room &079 <-> room &07a ; spark_sprites ; spark_sprite_0 &6400 00 00 44 aa 11 00 00 00 00 00 44 aa 11 00 00 00 ; spark_sprite_1 &6410 44 44 aa aa 22 11 11 00 44 44 aa aa 99 00 00 00 ; spark_sprite_2 &6420 00 00 22 55 88 00 00 00 00 00 22 55 88 00 00 00 ; spark_sprite_3 &6430 22 22 55 dd 99 00 00 00 22 22 55 55 44 88 88 00 ; rnd &6440 a6 9a LDX &9a ; rnd_1 &6442 a4 9b LDY &9b ; rnd_2 &6444 06 9a ASL &9a ; rnd_1 &6446 26 9b ROL &9b ; rnd_2 &6448 8a TXA &6449 85 9d STA &9d ; rnd_4 &644b 18 CLC &644c 65 9a ADC &9a ; rnd_1 &644e 08 PHP &644f 18 CLC &6450 69 03 ADC #&03 &6452 85 9a STA &9a ; rnd_1 &6454 98 TYA &6455 65 9b ADC &9b ; rnd_2 &6457 28 PLP &6458 65 9d ADC &9d ; rnd_4 &645a 85 9b STA &9b ; rnd_2 &645c 29 0f AND #&0f &645e 85 9c STA &9c ; rnd_3 &6460 60 RTS ; update_sparks &6461 a9 00 LDA #&00 &6463 85 88 STA &88 ; spark_offset ; update_sparks_loop &6465 a6 88 LDX &88 ; spark_offset &6467 bd 00 01 LDA &0100,X ; sparks_screen_address_low # Is there a spark in this slot? &646a d0 01 BNE &646d ; update_spark &646c 60 RTS ; update_spark &646d bd 04 01 LDA &0104,X ; sparks_frame &6470 85 89 STA &89 ; spark_frame &6472 dd 05 01 CMP &0105,X ; sparks_ignition_frame # Is the spark active? &6475 30 09 BMI &6480 ; skip_unplotting_spark &6477 29 03 AND #&03 &6479 c9 03 CMP #&03 &647b d0 03 BNE &6480 ; skip_unplotting_spark &647d 20 d9 64 JSR &64d9 ; plot_spark # If so, unplot spark every four frames ; skip_unplotting_spark &6480 18 CLC &6481 a6 88 LDX &88 ; spark_offset &6483 a5 89 LDA &89 ; spark_frame &6485 69 01 ADC #&01 &6487 dd 06 01 CMP &0106,X ; sparks_total_frames &648a 30 02 BMI &648e ; skip_overflow &648c a9 00 LDA #&00 ; skip_overflow &648e 9d 04 01 STA &0104,X ; sparks_frame &6491 85 89 STA &89 ; spark_frame &6493 dd 05 01 CMP &0105,X ; sparks_ignition_frame &6496 30 35 BMI &64cd ; consider_next_spark # Is the spark active? &6498 29 03 AND #&03 &649a d0 03 BNE &649f ; skip_plotting_spark &649c 20 d9 64 JSR &64d9 ; plot_spark # If so, replot spark every four frames ; skip_plotting_spark &649f a6 88 LDX &88 ; spark_offset # Is the player touching the spark? &64a1 a5 70 LDA &70 ; player_screen_address_low &64a3 29 f8 AND #&f8 &64a5 38 SEC &64a6 e9 10 SBC #&10 &64a8 dd 00 01 CMP &0100,X ; sparks_screen_address_low &64ab b0 20 BCS &64cd ; consider_next_spark &64ad 69 20 ADC #&20 &64af dd 00 01 CMP &0100,X ; sparks_screen_address_low &64b2 90 19 BCC &64cd ; consider_next_spark &64b4 d0 06 BNE &64bc ; check_y &64b6 a5 72 LDA &72 ; player_sprite &64b8 29 03 AND #&03 &64ba f0 11 BEQ &64cd ; consider_next_spark ; check_y &64bc bd 01 01 LDA &0101,X ; sparks_screen_address_high &64bf c5 71 CMP &71 ; player_screen_address_high &64c1 90 0a BCC &64cd ; consider_next_spark &64c3 e9 03 SBC #&03 &64c5 c5 71 CMP &71 ; player_screen_address_high &64c7 b0 04 BCS &64cd ; consider_next_spark &64c9 a9 04 LDA #&04 ; TOUCHING_SPARK # If so, kill player &64cb 85 20 STA &20 ; player_touching_death ; consider_next_spark &64cd 18 CLC &64ce a5 88 LDA &88 ; spark_offset &64d0 69 08 ADC #&08 # Move to next spark &64d2 85 88 STA &88 ; spark_offset &64d4 29 20 AND #&20 # Maximum of four sparks &64d6 f0 8d BEQ &6465 ; update_sparks_loop &64d8 60 RTS ; plot_spark &64d9 a5 89 LDA &89 ; spark_frame &64db 29 0c AND #&0c &64dd 0a ASL A &64de 0a ASL A &64df 85 8c STA &8c ; sprite_address_low &64e1 a9 64 LDA #&64 ; &6400 = spark_sprites &64e3 85 8d STA &8d ; sprite_address_high &64e5 bd 00 01 LDA &0100,X ; sparks_screen_address_low &64e8 85 8e STA &8e ; screen_address_low &64ea bd 01 01 LDA &0101,X ; sparks_screen_address_high &64ed 85 8f STA &8f ; screen_address_high &64ef 4c d4 65 JMP &65d4 ; plot_single_character_sprite ; unused &64f2 dd 99 bb 99 ff 00 ff 99 dd 99 dd 99 ff 00 # Copy of &0a72 - &0a7f, end of font_data ; plot_aligned_sprite_using_write &6500 84 8b STY &8b ; height &6502 8a TXA &6503 0a ASL A &6504 0a ASL A &6505 0a ASL A &6506 85 8a STA &8a ; width ; plot_aligned_sprite_using_write_column_loop &6508 a4 8a LDY &8a ; width &650a 88 DEY ; plot_aligned_sprite_using_write_row_loop &650b b1 8c LDA (&8c),Y ; sprite_address &650d 91 8e STA (&8e),Y ; screen_address &650f 88 DEY &6510 10 f9 BPL &650b ; plot_aligned_sprite_using_write_row_loop &6512 e6 8f INC &8f ; screen_address_high # Move down eight pixels &6514 18 CLC &6515 a5 8c LDA &8c ; sprite_address_low &6517 65 8a ADC &8a ; width &6519 85 8c STA &8c ; sprite_address_low &651b a5 8d LDA &8d ; sprite_address_high &651d 69 00 ADC #&00 &651f 85 8d STA &8d ; sprite_address_high &6521 c6 8b DEC &8b ; height &6523 d0 e3 BNE &6508 ; plot_aligned_sprite_using_write_column_loop &6525 60 RTS ; plot_unaligned_sprite &6526 a5 8e LDA &8e ; screen_address_low &6528 29 07 AND #&07 &652a 85 89 STA &89 ; row_in_group &652c 8a TXA &652d 0a ASL A &652e 0a ASL A &652f 0a ASL A &6530 85 8a STA &8a ; width &6532 84 8b STY &8b ; height ; plot_unaligned_sprite_group_loop &6534 a0 00 LDY #&00 &6536 38 SEC &6537 a5 8e LDA &8e ; screen_address_low &6539 29 07 AND #&07 &653b 85 88 STA &88 ; rows_to_plot &653d a9 08 LDA #&08 &653f e5 88 SBC &88 ; rows_to_plot &6541 85 88 STA &88 ; rows_to_plot ; plot_top_partial_group_loop &6543 b1 8e LDA (&8e),Y ; screen_address &6545 51 8c EOR (&8c),Y ; sprite_address &6547 91 8e STA (&8e),Y ; screen_address &6549 c8 INY &654a c4 88 CPY &88 ; rows_to_plot &654c d0 f5 BNE &6543 ; plot_top_partial_group_loop &654e 98 TYA &654f 18 CLC &6550 69 07 ADC #&07 &6552 29 f8 AND #&f8 &6554 a8 TAY &6555 a5 88 LDA &88 ; rows_to_plot &6557 69 08 ADC #&08 &6559 85 88 STA &88 ; rows_to_plot &655b c4 8a CPY &8a ; width &655d d0 e4 BNE &6543 ; plot_top_partial_group_loop &655f 18 CLC &6560 a5 8e LDA &8e ; screen_address_low &6562 69 f8 ADC #&f8 &6564 85 8e STA &8e ; screen_address_low &6566 a5 8f LDA &8f ; screen_address_high &6568 69 00 ADC #&00 &656a 85 8f STA &8f ; screen_address_high &656c a5 89 LDA &89 ; row_in_group &656e f0 1f BEQ &658f ; skip_bottom_partial_group # If sprite aligned with group, no bottom to plot &6570 a0 00 LDY #&00 ; plot_bottom_partial_group_column_loop &6572 38 SEC &6573 a9 08 LDA #&08 &6575 e5 89 SBC &89 ; row_in_group &6577 85 88 STA &88 ; rows_to_plot &6579 98 TYA &657a 05 88 ORA &88 ; rows_to_plot &657c a8 TAY ; plot_bottom_partial_group_row_loop &657d b1 8e LDA (&8e),Y ; screen_address &657f 51 8c EOR (&8c),Y ; sprite_address &6581 91 8e STA (&8e),Y ; screen_address &6583 c8 INY &6584 84 87 STY &87 ; unused # Unnecessary code &6586 98 TYA &6587 29 07 AND #&07 &6589 d0 f2 BNE &657d ; plot_bottom_partial_group_row_loop &658b c4 8a CPY &8a ; width &658d d0 e3 BNE &6572 ; plot_bottom_partial_group_column_loop ; skip_bottom_partial_group &658f 18 CLC &6590 a5 8e LDA &8e ; screen_address_low &6592 69 08 ADC #&08 &6594 85 8e STA &8e ; screen_address_low &6596 a5 8f LDA &8f ; screen_address_high &6598 69 00 ADC #&00 &659a 85 8f STA &8f ; screen_address_high &659c a5 8c LDA &8c ; sprite_address_low &659e 65 8a ADC &8a &65a0 85 8c STA &8c ; sprite_address_low &65a2 a5 8d LDA &8d ; sprite_address_high &65a4 69 00 ADC #&00 &65a6 85 8d STA &8d ; sprite_address_high &65a8 c6 8b DEC &8b ; height &65aa d0 88 BNE &6534 ; plot_unaligned_sprite_group_loop &65ac 60 RTS ; plot_aligned_sprite_using_eor &65ad 84 8b STY &8b ; height &65af 8a TXA &65b0 0a ASL A &65b1 0a ASL A &65b2 0a ASL A &65b3 85 8a STA &8a ; width ; plot_aligned_sprite_using_eor_column_loop &65b5 a4 8a LDY &8a ; width &65b7 88 DEY ; plot_aligned_sprite_using_eor_row_loop &65b8 b1 8e LDA (&8e),Y ; screen_address &65ba 51 8c EOR (&8c),Y ; sprite_address &65bc 91 8e STA (&8e),Y ; screen_address &65be 88 DEY &65bf 10 f7 BPL &65b8 ; plot_aligned_sprite_using_eor_row_loop &65c1 a5 8c LDA &8c ; sprite_address_low &65c3 65 8a ADC &8a ; width &65c5 85 8c STA &8c ; sprite_address_low &65c7 a5 8d LDA &8d ; sprite_address_high &65c9 69 00 ADC #&00 &65cb 85 8d STA &8d ; sprite_address_high &65cd e6 8f INC &8f ; screen_address_high # Move down eight pixels &65cf c6 8b DEC &8b ; height &65d1 d0 e2 BNE &65b5 ; plot_aligned_sprite_using_eor_column_loop &65d3 60 RTS ; plot_single_character_sprite # Plots 4 * 8 pixels &65d4 a0 0f LDY #&0f ; plot_single_character_sprite_loop &65d6 b1 8e LDA (&8e),Y ; screen_address &65d8 51 8c EOR (&8c),Y ; sprite_address &65da 91 8e STA (&8e),Y ; screen_address &65dc 88 DEY &65dd 10 f7 BPL &65d6 ; plot_single_character_sprite_loop &65df 60 RTS ; calculate_subtile_address_from_screen_address &65e0 86 6b STX &6b ; subtile_address_low &65e2 84 6c STY &6c ; subtile_address_high &65e4 46 6c LSR &6c ; subtile_address_high &65e6 66 6b ROR &6b ; subtile_address_low &65e8 46 6c LSR &6c ; subtile_address_high &65ea 66 6b ROR &6b ; subtile_address_low &65ec 46 6c LSR &6c ; subtile_address_high &65ee 66 6b ROR &6b ; subtile_address_low &65f0 a5 6c LDA &6c ; subtile_address_high &65f2 29 03 AND #&03 &65f4 09 04 ORA #&04 &65f6 85 6c STA &6c ; subtile_address_high &65f8 a8 TAY &65f9 a6 6b LDX &6b ; subtile_address_low &65fb 60 RTS ; unused &65fc 00 00 ; unused_zero_one # Values used in unused code at &1975 &65fe 00 ; unused_zero_two &65ff 00 ; status_section # Raw MODE 5 screen data &6600 10 30 50 d0 e0 e0 f0 f0 f0 80 80 e0 e0 c0 40 70 &6610 c0 c0 91 91 91 91 c0 c0 00 00 ff 33 77 ff 00 00 &6620 00 00 ff ff ff ff 00 00 00 00 ff ff ff ff 00 00 &6630 00 00 ee aa 22 ee 00 00 00 00 ff 99 bb ff 00 00 &6640 00 00 ff ff ff ff 00 00 00 00 ff ff ff ff 00 00 &6650 00 00 ff ee cc ff 00 00 00 00 bb aa aa bb 00 00 &6660 00 00 ff 77 ff ff 00 00 00 00 ff ff ff ff 00 30 &6670 00 00 ff ff ff ff 00 40 00 00 ee aa 22 ee 00 00 &6680 00 00 ff 99 bb ff 00 00 00 00 ff ff ff ff 00 00 &6690 00 00 ff ff ff ff 00 00 00 00 ff ee cc ff 00 00 &66a0 00 00 bb aa aa bb 00 00 00 00 ff 77 ff ff 00 00 &66b0 00 00 ff ff ff ff 00 00 00 00 ff ff ff ff 00 00 &66c0 00 00 ee aa 22 ee 00 00 00 00 ff 99 bb ff 00 00 &66d0 00 00 ff ff ff ff 00 00 00 00 ff ff ff ff 00 00 &66e0 00 00 ff ee cc ff 00 00 30 30 98 98 98 98 30 00 &66f0 f0 10 10 70 70 30 20 e0 80 c0 a0 b0 70 70 f0 f0 &6700 b0 b0 a0 a0 80 80 f0 80 80 80 83 83 83 83 83 83 &6710 00 07 0f 0f 0f 08 0b 0a 00 0f 0f 0f 0f 00 0f 00 &6720 00 0f 0f 0f 0f 00 0f 00 00 0f 0f 0f 0f 00 0f 00 &6730 00 0f 0f 0f 0f 00 0f 00 00 0f 0f 0f 0f 00 0f 00 &6740 00 0f 0f 0f 0f 00 0f 00 00 0f 0f 0f 0f 00 0f 00 &6750 00 0f 0f 0f 0f 00 0e 02 00 0a 0a 0a 0a 0a 0a 0a &6760 00 10 20 10 30 40 60 70 10 d0 f0 60 30 10 30 70 &6770 00 00 00 80 80 c0 c0 c0 00 0b 0a 0a 0b 0b 0b 08 &6780 00 0e 0a 0e 0a 0a 0e 00 00 00 00 00 00 00 00 00 &6790 00 00 00 aa aa ee aa aa 00 00 00 ee 44 44 44 ee &67a0 00 00 00 00 00 00 00 00 00 05 05 05 05 05 05 05 &67b0 00 66 55 66 55 66 00 00 00 55 55 55 55 22 00 00 &67c0 00 66 55 66 55 66 00 00 00 66 55 66 55 66 00 00 &67d0 00 44 44 44 44 66 00 00 00 cc 88 cc 88 cc 00 00 &67e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 &67f0 10 10 14 14 14 14 14 14 d0 d0 50 50 10 10 f0 10 &6800 80 77 77 55 55 77 77 77 83 03 07 07 07 07 07 07 &6810 0a 0a 0a 0a 0a 0a 0a 0a 00 cc aa cc aa cc 00 00 &6820 00 aa aa 66 22 cc 00 00 00 55 55 66 55 55 00 00 &6830 00 33 22 33 22 22 00 00 00 33 aa 33 22 22 00 00 &6840 00 22 aa 22 aa aa 00 00 00 55 99 99 99 55 00 00 &6850 02 8a 02 8a 02 8a 02 02 0a 0a 0a 0a 0a 0a 0a 0a &6860 70 70 30 30 50 40 30 00 f0 d0 a0 b0 80 30 70 00 &6870 c0 c0 80 00 80 80 00 00 08 0b 0b 08 0a 08 09 08 &6880 00 06 06 08 0a 00 04 00 00 00 00 22 33 22 22 22 &6890 00 00 00 aa aa aa aa 99 00 00 00 aa bb aa aa 22 &68a0 00 00 00 88 88 88 88 88 05 05 05 05 05 05 05 05 &68b0 00 00 00 00 00 00 00 00 33 22 33 22 33 00 00 00 &68c0 22 aa 22 aa 11 00 00 00 99 aa 99 88 33 00 00 00 &68d0 88 00 00 88 00 00 00 00 00 11 11 00 00 00 00 00 &68e0 00 22 55 22 55 22 00 00 00 77 11 11 22 22 00 00 &68f0 14 04 06 06 06 06 06 06 10 ee ee aa aa ee ee ee &6900 77 77 77 77 55 55 77 77 07 07 07 07 07 07 07 03 &6910 0a 0b 08 08 0f 0f 0f 0f 00 0f 00 00 0f 0f 0e 0e &6920 00 0f 00 00 0f 0f 0f 0f 00 0f 00 00 0f 0f 03 02 &6930 00 0f 00 00 0f 0f 0f 07 00 0f 00 00 0f 0f 0f 0f &6940 00 0f 00 00 0f 0f 0f 0f 00 0f 00 00 0f 0f 0d 0d &6950 02 0e 00 00 0f 0f 0f 0f 0a 0a 0a 0a 0a 0a 0a 0a &6960 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 &6970 00 00 00 00 00 00 00 00 08 08 09 0b 0a 08 08 08 &6980 00 04 04 0e 0a 0a 02 00 00 00 00 00 00 00 00 00 &6990 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 &69a0 00 00 00 00 00 00 00 00 05 05 04 04 05 05 05 05 &69b0 00 0f 00 00 0f 0f 0f 0f 00 0f 00 00 0f 00 07 0f &69c0 00 0f 00 00 0f 07 07 07 00 0f 00 00 0f 0f 0f 0f &69d0 00 0f 00 00 0f 0f 0f 0f 00 0f 00 00 0f 0e 0e 0e &69e0 00 0f 00 00 0f 00 0e 0f 00 0f 00 00 0f 0f 0f 0f &69f0 06 06 06 06 0e 0e 0e 0c ee ee ee ee aa aa ee ee &6a00 80 80 f0 80 80 a0 a0 b0 83 83 83 83 83 80 80 70 &6a10 0f 0f 0f 0f 0f 03 01 c0 0e 0e 0e 0f 0f 0f 0f 00 &6a20 0f 0f 03 0f 0f 0f 0f 00 02 02 02 02 0f 0f 0f 00 &6a30 04 04 04 04 0f 0f 0f 00 0f 09 09 09 0f 0f 0f 00 &6a40 0f 0f 03 03 0f 0f 0f 00 0d 0d 01 0f 0f 0f 0f 00 &6a50 0f 0f 0f 0f 0f 0f 0f 00 0a 0a 0b 08 08 0f 0f 00 &6a60 00 00 0f 00 00 0f 0f 00 00 00 0f 00 00 0f 0f 00 &6a70 00 00 0e 00 00 0f 0f 00 08 08 0f 00 00 0f 0f 00 &6a80 00 00 0f 00 00 0f 0f 00 00 00 0f 00 00 0f 0f 00 &6a90 00 00 0f 00 00 0f 0f 00 00 00 0f 00 00 0f 0f 00 &6aa0 00 00 0f 00 00 0f 0f 00 05 05 0d 01 01 0f 0f 00 &6ab0 0f 0e 0c 0e 0e 0e 0f 00 07 03 01 03 03 03 0f 00 &6ac0 07 07 07 02 0f 0f 0f 00 0f 0f 0f 09 0f 0f 0f 00 &6ad0 0f 0f 0f 01 0f 0f 0f 00 0e 0e 0e 00 0f 0f 0f 00 &6ae0 0c 0c 0c 08 0c 0e 0f 00 07 07 07 03 07 0c 08 30 &6af0 1c 1c 1c 1c 1c 10 10 e0 10 10 f0 10 10 50 50 d0 &6b00 b0 e0 e0 d0 50 30 10 00 40 c0 e0 e0 80 80 f0 00 &6b10 c0 91 91 91 91 c0 c0 00 00 ff 33 77 ff 00 00 00 &6b20 00 ff ff ff ff 00 00 00 00 ff ff ff ff 00 00 00 &6b30 00 ee aa 22 ee 00 00 00 00 ff 99 bb ff 00 00 00 &6b40 00 ff ff ff ff 00 00 00 00 ff ff ff ff 00 00 00 &6b50 00 ff ee cc ff 00 00 00 00 bb aa aa bb 00 00 00 &6b60 00 ff 77 ff ff 00 00 00 00 ff ff ff ff 00 00 00 &6b70 00 ff ff ff ff 00 00 00 00 ee aa 22 ee 00 00 00 &6b80 00 ff 99 bb ff 00 00 00 00 ff ff ff ff 00 00 00 &6b90 00 ff ff ff ff 00 00 00 00 ff ee cc ff 00 00 00 &6ba0 00 bb aa aa bb 00 00 00 00 ff 77 ff ff 00 00 00 &6bb0 00 ff ff ff ff 00 00 00 00 ff ff ff ff 00 00 00 &6bc0 00 ee aa 22 ee 00 00 00 00 ff 99 bb ff 00 00 00 &6bd0 00 ff ff ff ff 00 00 00 00 ff ff ff ff 00 00 00 &6be0 00 ff ee cc ff 00 00 00 30 98 98 98 98 30 30 00 &6bf0 20 30 70 70 10 10 f0 00 d0 70 70 b0 a0 c0 80 00 # &7000 - &72ff is decrypted to &0900 - &0bff at &752c ; font_data &0900 70 66 ef ee 80 88 88 88 ; "A" &0908 f0 dd df fd 80 88 80 88 ; "B" &0910 f0 ee ee fe 80 08 00 88 ; "C" &0918 f0 6e 66 fe 80 88 88 88 ; "D" &0920 f0 fc ee ff 00 00 00 88 ; "E" &0928 f0 fc ee ee 80 80 00 00 ; "F" &0930 f0 cd dd fc 80 08 88 88 ; "G" &0938 e0 ee ef ee 80 88 88 88 ; "H" &0940 f0 77 77 f7 80 00 00 80 ; "I" &0948 70 33 33 fb 80 88 88 88 ; "J" &0950 e0 fe ff ee 80 88 80 88 ; "K" &0958 e0 ee ee fe 00 00 00 80 ; "L" &0960 f0 af 88 cc 80 88 88 88 ; "M" &0968 e0 ee df cd 80 88 88 88 ; "N" &0970 f0 ee ee fe 80 88 88 88 ; "O" &0978 f0 ee ef ee 80 88 08 00 ; "P" &0980 f0 dd fd fd 00 00 00 88 ; "Q" &0988 f0 dd ef ee 00 00 88 88 ; "R" &0990 f0 cd 0f ff 00 00 88 88 ; "S" &0998 f0 77 77 77 80 00 00 00 ; "T" &09a0 e0 ee ee fe 80 88 88 88 ; "U" &09a8 e0 ee fe ef 80 88 88 00 ; "V" &09b0 c0 8c aa ff 80 88 88 88 ; "W" &09b8 e0 ee e7 ee 80 88 80 88 ; "X" &09c0 e0 fe 7f 77 80 88 00 00 ; "Y" &09c8 70 04 cf ff 80 88 08 88 ; "Z" &09d0 00 00 00 00 00 00 00 00 ; " " ([) &09d8 00 00 00 44 00 00 00 88 ; " " (~) &09e0 00 00 22 00 00 00 00 00 ; "-" (]) &09e8 00 00 00 44 00 00 00 00 ; "." (^) &09f0 00 00 00 00 00 00 00 00 ; " " (_) &09f8 00 dc 63 9d 00 88 00 88 ; "%" (`) &0a00 f0 bb bb fb 00 00 88 88 ; "0" (a) &0a08 f0 77 f7 ff 00 00 80 88 ; "1" (b) &0a10 f0 19 8f ff 80 88 08 88 ; "2" (c) &0a18 f0 33 3f ff 00 00 88 88 ; "3" (d) &0a20 b0 fb 3f 33 00 80 88 88 ; "4" (e) &0a28 f0 8b 3f ff 00 00 88 88 ; "5" (f) &0a30 f0 8b bf fb 00 00 88 88 ; "6" (g) &0a38 f0 3b 33 33 00 00 88 88 ; "7" (h) &0a40 f0 bb bf fb 00 88 88 88 ; "8" (i) &0a48 f0 bb 3f 33 80 88 88 88 ; "9" (j) &0a50 00 77 70 07 00 00 00 00 ; ":" (k) &0a58 10 31 67 cc 80 08 00 00 ; "/" (l) &0a60 00 00 00 ff 00 00 00 88 ; "_" (m) ; hopper_pad_numbers &0a68 ff dd dd 99 99 99 ff 00 ; "1" (n) &0a70 ff 99 dd 99 bb 99 ff 00 ; "2" (o) &0a78 ff 99 dd 99 dd 99 ff 00 ; "3" (p) ; plot_text &0a80 86 8e STX &8e ; text_address_low &0a82 84 8f STY &8f ; text_address_high ; plot_text_loop &0a84 a0 00 LDY #&00 &0a86 b1 8e LDA (&8e),Y ; text_address &0a88 f0 0b BEQ &0a95 ; set_alignment &0a8a 30 17 BMI &0aa3 ; set_colour # Top bit set to set colour &0a8c c9 20 CMP #&20 &0a8e b0 43 BCS &0ad3 ; plot_character &0a90 c9 1f CMP #&1f &0a92 f0 18 BEQ &0aac ; set_position # &1f to set screen address &0a94 60 RTS ; set_alignment # Zero byte sets alignment of next character &0a95 a5 87 LDA &87 ; alignment # One zero byte = misaligned, two = aligned &0a97 f0 03 BEQ &0a9c ; set_misalignment &0a99 4c 12 0b JMP &0b12 ; set_alignment_and_move # Y = zero to indicate next character is aligned ; set_misalignment &0a9c a9 01 LDA #&01 # Non-zero to indicate next character is misaligned &0a9e 85 87 STA &87 ; alignment &0aa0 4c 6c 0b JMP &0b6c ; consider_next_byte ; set_colour &0aa3 a8 TAY &0aa4 b9 f5 0a LDA &0af5,Y ; colour_mask_table - &80 &0aa7 85 89 STA &89 ; text_colour_mask &0aa9 4c 6c 0b JMP &0b6c ; consider_next_byte ; set_position &0aac c8 INY &0aad b1 8e LDA (&8e),Y ; text_address_low # Get a byte for x position &0aaf 85 8a STA &8a ; screen_address_low &0ab1 0a ASL A &0ab2 65 8a ADC &8a ; screen_address_low &0ab4 48 PHA &0ab5 29 f8 AND #&f8 &0ab7 85 8a STA &8a ; screen_address_low &0ab9 68 PLA &0aba 29 04 AND #&04 &0abc 85 87 STA &87 ; alignment &0abe c8 INY &0abf b1 8e LDA (&8e),Y ; text_address_low # Get a byte for y position &0ac1 18 CLC &0ac2 69 67 ADC #&67 &0ac4 85 8b STA &8b ; screen_address_high &0ac6 a5 8e LDA &8e ; text_address_low &0ac8 69 03 ADC #&03 &0aca 85 8e STA &8e ; text_address_low &0acc 90 02 BCC &0ad0 ; skip_overflow &0ace e6 8f INC &8f ; text_address_high ; skip_overflow &0ad0 4c 84 0a JMP &0a84 ; plot_text_loop ; plot_character &0ad3 84 8d STY &8d ; text_offset &0ad5 38 SEC &0ad6 e9 41 SBC #&41 ; "A" &0ad8 0a ASL A &0ad9 85 8c STA &8c ; font_address_low &0adb 06 8c ASL &8c ; font_address_low &0add 26 8d ROL &8d ; font_address_high &0adf 06 8c ASL &8c ; font_address_low &0ae1 26 8d ROL &8d ; font_address_high &0ae3 a5 8d LDA &8d ; font_address_high &0ae5 69 09 ADC #&09 ; &0900 = font_data &0ae7 85 8d STA &8d ; font_address_high &0ae9 a2 10 LDX #&10 &0aeb 20 79 0b JSR &0b79 ; unpack_character &0aee a0 00 LDY #&00 &0af0 a5 87 LDA &87 ; alignment # Zero if character is aligned with column horizontally &0af2 d0 2d BNE &0b21 ; plot_misaligned_character_first_column_loop ; plot_aligned_character_first_column_loop &0af4 b1 8c LDA (&8c),Y ; unpacked_character_address # Write four pixels to first column &0af6 25 89 AND &89 ; text_colour_mask &0af8 91 8a STA (&8a),Y ; screen_address &0afa c8 INY &0afb c0 08 CPY #&08 &0afd d0 f5 BNE &0af4 ; plot_aligned_character_first_column_loop ; plot_aligned_character_second_column_loop &0aff b1 8a LDA (&8a),Y ; screen_address &0b01 29 33 AND #&33 ; two rightmost pixels &0b03 85 88 STA &88 ; screen_value &0b05 b1 8c LDA (&8c),Y ; unpacked_character_address # Write two pixels to left of next column &0b07 25 89 AND &89 ; text_colour_mask &0b09 05 88 ORA &88 ; screen_value &0b0b 91 8a STA (&8a),Y ; screen_address &0b0d c8 INY &0b0e c0 10 CPY #&10 # Non-zero to indicate next character is misaligned &0b10 d0 ed BNE &0aff ; plot_aligned_character_second_column_loop ; set_alignment_and_move &0b12 84 87 STY &87 ; alignment &0b14 18 CLC &0b15 a5 8a LDA &8a ; screen_address_low &0b17 69 08 ADC #&08 # Move right eight pixels &0b19 85 8a STA &8a ; screen_address_low &0b1b 90 4f BCC &0b6c ; consider_next_byte &0b1d e6 8b INC &8b ; screen_address_high &0b1f b0 4b BCS &0b6c ; consider_next_byte # Always branches ; plot_misaligned_character_first_column_loop &0b21 b1 8c LDA (&8c),Y ; unpacked_character_address # Write two pixels to right of first column &0b23 4a LSR A &0b24 4a LSR A &0b25 29 33 AND #&33 ; two rightmost pixels &0b27 25 89 AND &89 ; text_colour_mask &0b29 85 88 STA &88 ; font_value &0b2b b1 8a LDA (&8a),Y ; screen_address &0b2d 29 cc AND #&cc ; two leftmost pixels &0b2f 05 88 ORA &88 ; font_value &0b31 91 8a STA (&8a),Y ; screen_address &0b33 c8 INY &0b34 c0 08 CPY #&08 &0b36 d0 e9 BNE &0b21 ; plot_misaligned_character_first_column_loop ; plot_misaligned_character_second_column_loop &0b38 b1 8c LDA (&8c),Y ; unpacked_character_address # Get two pixels from one column of font data &0b3a 4a LSR A &0b3b 4a LSR A &0b3c 25 89 AND &89 ; text_colour_mask &0b3e 85 88 STA &88 ; font_value &0b40 98 TYA &0b41 49 08 EOR #&08 &0b43 a8 TAY &0b44 b1 8c LDA (&8c),Y ; unpacked_character_address # Combine with two pixels from next column &0b46 29 33 AND #&33 ; two rightmost pixels &0b48 25 89 AND &89 ; text_colour_mask &0b4a 0a ASL A &0b4b 0a ASL A &0b4c 05 88 ORA &88 ; font_value &0b4e 85 88 STA &88 ; font_value &0b50 98 TYA &0b51 49 08 EOR #&08 &0b53 a8 TAY &0b54 a5 88 LDA &88 ; font_value &0b56 91 8a STA (&8a),Y ; screen_address # Write to next screen column &0b58 c8 INY &0b59 c0 10 CPY #&10 &0b5b d0 db BNE &0b38 ; plot_misaligned_character_second_column_loop &0b5d 18 CLC &0b5e a5 8a LDA &8a ; screen_address_low &0b60 69 10 ADC #&10 # Move right sixteen pixels &0b62 85 8a STA &8a ; screen_address_low &0b64 90 02 BCC &0b68 ; skip_overflow &0b66 e6 8b INC &8b ; screen_address_high ; skip_overflow &0b68 a0 00 LDY #&00 # Zero to indicate next character is aligned &0b6a 84 87 STY &87 ; alignment ; consider_next_byte &0b6c e6 8e INC &8e ; text_address_low &0b6e d0 02 BNE &0b72 ; skip_page &0b70 e6 8f INC &8f ; text_address_high ; skip_page &0b72 4c 84 0a JMP &0a84 ; plot_text_loop ; colour_mask_table ; 0 1 2 3 &0b75 00 0f f0 ff ; unpack_character &0b79 8e f5 0b STX &0bf5 ; character_size &0b7c a2 00 LDX #&00 &0b7e a0 00 LDY #&00 ; unpack_character_loop &0b80 b1 8c LDA (&8c),Y ; font_address &0b82 29 0f AND #&0f # Low nibble &0b84 8d f6 0b STA &0bf6 ; font_nibble &0b87 0a ASL A # Multiply by 17 to use colour 3 &0b88 0a ASL A &0b89 0a ASL A &0b8a 0a ASL A &0b8b 0d f6 0b ORA &0bf6 ; font_nibble &0b8e 9d c0 03 STA &03c0,X ; unpacked_character_buffer &0b91 e8 INX &0b92 b1 8c LDA (&8c),Y ; font_address &0b94 29 f0 AND #&f0 # High nibble &0b96 8d f6 0b STA &0bf6 ; font_nibble &0b99 4a LSR A # Divide by 16, then multiply by 17 to use colour 3 &0b9a 4a LSR A &0b9b 4a LSR A &0b9c 4a LSR A &0b9d 0d f6 0b ORA &0bf6 ; font_nibble &0ba0 9d c0 03 STA &03c0,X ; unpacked_character_buffer &0ba3 e8 INX &0ba4 c8 INY &0ba5 ec f5 0b CPX &0bf5 ; character_size &0ba8 d0 d6 BNE &0b80 ; unpack_character_loop &0baa a9 03 LDA #&03 ; &03c0 = unpacked_character_buffer &0bac 85 8d STA &8d ; unpacked_character_address &0bae a9 c0 LDA #&c0 &0bb0 85 8c STA &8c ; unpacked_character_address &0bb2 60 RTS ; plot_packed_two_colour_sprite &0bb3 86 8b STX &8b ; colour_mask &0bb5 84 8a STY &8a ; screen_mask &0bb7 0a ASL A &0bb8 0a ASL A &0bb9 0a ASL A &0bba 85 8c STA &8c ; font_address_low &0bbc 06 8c ASL &8c ; font_address_low &0bbe a9 00 LDA #&00 &0bc0 69 35 ADC #&35 ; &35e0 = packed_two_colour_sprite_data &0bc2 48 PHA &0bc3 a5 8c LDA &8c ; font_address_low &0bc5 69 e0 ADC #&e0 &0bc7 85 8c STA &8c ; font_address_low &0bc9 68 PLA &0bca 69 00 ADC #&00 &0bcc 85 8d STA &8d ; font_address_high &0bce a2 20 LDX #&20 &0bd0 20 79 0b JSR &0b79 ; unpack_character &0bd3 a2 00 LDX #&00 ; plot_packed_two_colour_sprite_group_loop &0bd5 a0 00 LDY #&00 ; plot_packed_two_colour_sprite_row_loop &0bd7 bd c0 03 LDA &03c0,X ; unpacked_character_buffer &0bda 25 8b AND &8b ; colour_mask &0bdc 8d f6 0b STA &0bf6 ; sprite_byte &0bdf b1 8e LDA (&8e),Y ; screen_address &0be1 25 8a AND &8a ; screen_mask &0be3 4d f6 0b EOR &0bf6 ; sprite_byte &0be6 91 8e STA (&8e),Y ; screen_address &0be8 c8 INY &0be9 e8 INX &0bea c0 10 CPY #&10 &0bec d0 e9 BNE &0bd7 ; plot_packed_two_colour_sprite_row_loop &0bee e6 8f INC &8f ; screen_address_high &0bf0 e0 20 CPX #&20 &0bf2 d0 e1 BNE &0bd5 ; plot_packed_two_colour_sprite_group_loop &0bf4 60 RTS ; character_size &0bf5 00 ; font_nibble ; sprite_byte &0bf6 00 ; core_elements_colours &0bf7 00 00 00 00 00 00 00 00 00 # &7300 - &73ff is decrypted to &7f00 - &7fff at &754a ; to_set_screen_colours &7f00 4c b9 7f JMP &7fb9 ; set_screen_colours ; initialise_vectors &7f03 a9 6f LDA #&6f &7f05 8d 20 02 STA &0220 ; event_vector_low &7f08 a9 7f LDA #&7f ; &7f6f = event_handler &7f0a 8d 21 02 STA &0221 ; event_vector_high &7f0d a9 0e LDA #&0e ; Enable Event &7f0f a2 04 LDX #&04 ; vsync event &7f11 20 f4 ff JSR &fff4 ; OSBYTE &7f14 78 SEI &7f15 ad 07 02 LDA &0207 ; irq2_vector_high &7f18 10 13 BPL &7f2d ; leave &7f1a 8d fe 7f STA &7ffe ; previous_irq2_handler_high &7f1d ad 06 02 LDA &0206 ; irq2_vector_low &7f20 8d fd 7f STA &7ffd ; previous_irq2_handler_low &7f23 a9 2f LDA #&2f &7f25 8d 06 02 STA &0206 ; irq2_vector_low &7f28 a9 7f LDA #&7f ; &7f2f = irq2_handler &7f2a 8d 07 02 STA &0207 ; irq2_vector_high ; leave &7f2d 58 CLI &7f2e 60 RTS ; irq2_handler &7f2f 08 PHP &7f30 48 PHA &7f31 8a TXA &7f32 48 PHA &7f33 98 TYA &7f34 48 PHA &7f35 ad 6d fe LDA &fe6d ; User VIA interrupt flag register &7f38 29 20 AND #&20 # User VIA timer 2 timeout &7f3a f0 0d BEQ &7f49 ; not_timer_2 &7f3c a2 00 LDX #&00 ; write_palette_data_loop &7f3e bd 0c 11 LDA &110c,X ; ula_palette_data + &10 # Use palette for bottom section of screen &7f41 8d 21 fe STA &fe21 ; video ULA palette register &7f44 e8 INX &7f45 e0 10 CPX #&10 &7f47 d0 f5 BNE &7f3e ; write_palette_data_loop ; not_timer_2 &7f49 a9 20 LDA #&20 # Disable User VIA timer 2 interrupts &7f4b 8d 6e fe STA &fe6e ; User VIA interrupt enable register &7f4e 68 PLA &7f4f a8 TAY &7f50 68 PLA &7f51 aa TAX &7f52 68 PLA &7f53 28 PLP &7f54 6c fd 7f JMP (&7ffd) ; previous_irq2_handler ; set_timer &7f57 ad 6b fe LDA &fe6b ; User VIA auxiliary control register &7f5a 29 df AND #&df # Set User VIA timer 2 to timed interrupt &7f5c 8d 6b fe STA &fe6b ; User VIA auxiliary control register &7f5f a9 a0 LDA #&a0 # Enable interrupts for User VIA timer 2 &7f61 8d 6e fe STA &fe6e ; User VIA interrupt enable register &7f64 a9 00 LDA #&00 &7f66 8d 68 fe STA &fe68 ; User VIA timer 2 counter LSB &7f69 a9 0f LDA #&0f # actually LDA timer2_msb &7f6b 8d 69 fe STA &fe69 ; User VIA timer 2 counter MSB &7f6e 60 RTS ; event_handler &7f6f 08 PHP &7f70 c9 04 CMP #&04 &7f72 d0 3b BNE &7faf ; not_vsync &7f74 48 PHA &7f75 8a TXA &7f76 48 PHA &7f77 98 TYA &7f78 48 PHA &7f79 a2 00 LDX #&00 ; write_palette_data_loop &7f7b bd fc 10 LDA &10fc,X ; ula_palette_data # Use palette for top (status) section of screen &7f7e 8d 21 fe STA &fe21 ; video ULA palette register &7f81 e8 INX &7f82 e0 10 CPX #&10 &7f84 d0 f5 BNE &7f7b ; write_palette_data_loop &7f86 20 57 7f JSR &7f57 ; set_timer &7f89 c6 23 DEC &23 ; game_time_countdown &7f8b a5 23 LDA &23 ; game_time_countdown &7f8d d0 1a BNE &7fa9 ; skip_overflow &7f8f a9 32 LDA #&32 &7f91 85 23 STA &23 ; game_time_countdown &7f93 f8 SED &7f94 18 CLC &7f95 a5 24 LDA &24 ; game_time_low &7f97 69 01 ADC #&01 &7f99 85 24 STA &24 ; game_time_low &7f9b d8 CLD &7f9c c9 60 CMP #&60 &7f9e 90 09 BCC &7fa9 ; skip_overflow &7fa0 a9 00 LDA #&00 &7fa2 85 24 STA &24 ; game_time_low &7fa4 f8 SED &7fa5 65 25 ADC &25 ; game_time_high &7fa7 85 25 STA &25 ; game_time_high ; skip_overflow &7fa9 d8 CLD &7faa 68 PLA &7fab a8 TAY &7fac 68 PLA &7fad aa TAX &7fae 68 PLA ; not_vsync &7faf 28 PLP &7fb0 60 RTS ; logical_colours &7fb1 00 20 80 a0 ; logical_colour_equivalents &7fb5 00 10 40 50 ; set_screen_colours &7fb9 a9 07 LDA #&07 &7fbb 85 8c STA &8c ; colour &7fbd a9 10 LDA #&10 # &10 for bottom section of screen, &00 for top &7fbf 85 8d STA &8d ; section_offset ; set_screen_colours_loop &7fc1 a4 8c LDY &8c ; colour &7fc3 b6 90 LDX &90,Y ; palette &7fc5 98 TYA &7fc6 4a LSR A &7fc7 a4 8d LDY &8d ; section_offset &7fc9 86 8e STX &8e ; palette_value &7fcb 85 8f STA &8f ; physical_colour &7fcd aa TAX &7fce bd b1 7f LDA &7fb1,X ; logical_colours &7fd1 18 CLC &7fd2 65 8e ADC &8e ; palette_value &7fd4 49 07 EOR #&07 &7fd6 85 8e STA &8e ; actual_colour &7fd8 98 TYA &7fd9 06 8f ASL &8f ; physical_colour &7fdb 06 8f ASL &8f ; physical_colour &7fdd 18 CLC &7fde 65 8f ADC &8f ; physical_colour &7fe0 a8 TAY &7fe1 a2 00 LDX #&00 ; calculate_ula_data_loop &7fe3 18 CLC &7fe4 a5 8e LDA &8e ; actual_colour &7fe6 7d b5 7f ADC &7fb5,X ; logical_colour_equivalents &7fe9 99 fc 10 STA &10fc,Y ; ula_palette_data &7fec e8 INX &7fed c8 INY &7fee e0 04 CPX #&04 &7ff0 d0 f1 BNE &7fe3 ; calculate_ula_data_loop &7ff2 a5 8d LDA &8d ; section_offset &7ff4 49 10 EOR #&10 &7ff6 85 8d STA &8d ; section_offset &7ff8 c6 8c DEC &8c ; colour &7ffa 10 c5 BPL &7fc1 ; set_screen_colours_loop &7ffc 60 RTS ; previous_irq2_handler_low &7ffd 00 ; previous_irq2_handler_high &7ffe 00 ; unused &7fff 20 # &7400 - &74e7 is decrypted to &0440 - &0527 at &7569 ; unused &0440 00 00 00 ; player_exploding_sound ; envelope &0443 04 01 00 00 00 00 00 00 7e ff ff ff 7e 5a ; chan vol pitch dur &0451 00 00 04 00 06 00 01 00 ; teleporting_sound ; envelope &0459 04 01 f8 f0 e8 04 04 04 7e 00 00 82 7e 7e ; chan vol pitch dur &0467 11 00 04 00 c8 00 11 00 ; tune_envelope &046f 04 02 01 01 01 01 01 01 28 00 00 82 7e 7e ; tune_data ; title_tune &047d 0a 06 03 2a 06 23 0b 08 03 2b 08 23 08 05 01 28 &048d 05 21 0a 06 01 2a 06 21 0a 06 03 2a 06 23 0b 08 &049d 03 2b 08 23 08 05 01 28 05 21 66 ff ; start_game_tune &04a9 21 08 01 06 48 21 08 2b 4d 21 08 01 06 48 21 08 &04b9 26 44 21 08 01 06 48 21 08 2b 4d 21 08 01 06 48 &04c9 26 24 41 ff ; game_over_tune &04cd 09 08 66 24 26 28 29 2d eb e8 09 08 66 24 26 28 &04dd 29 2d eb eb 0d 0b ad 26 28 29 2d 0b 09 ab 24 26 &04ed 28 2b 09 08 a9 21 26 28 29 e6 ff ; ending_tune &04f8 01 08 4d 10 0f 4b 06 08 4b 06 08 4d 01 08 4d 0f &0508 10 54 0f 0d 4b 06 08 4d 01 08 4d 10 0f 4b 06 08 &0518 4b 06 08 4d 01 08 4d 0f 10 54 0f 0d 4b 46 6d ff # &74e8 - &75e7 is decrypted at &1500; &75e8 - &75ff is unencrypted ; decrypted_entry_point &74e8 a9 8c LDA #&8c ; Select Tape FS &74ea a2 0c LDX #&0c ; 1200 baud &74ec 20 f4 ff JSR &fff4 ; OSBYTE &74ef a9 c8 LDA #&c8 ; Read/Write BREAK/ESCAPE effect &74f1 a2 03 LDX #&03 ; Clear memory on next RESET &74f3 a0 00 LDY #&00 &74f5 20 f4 ff JSR &fff4 ; OSBYTE &74f8 a9 04 LDA #&04 ; Define action of cursor editing keys &74fa a2 01 LDX #&01 ; Cursor keys return ASCII values 135-139 &74fc a0 00 LDY #&00 &74fe 20 f4 ff JSR &fff4 ; OSBYTE &7501 a9 0b LDA #&0b ; Set auto-repeat delay &7503 a2 00 LDX #&00 ; Disable auto-repeat &7505 a0 00 LDY #&00 &7507 20 f4 ff JSR &fff4 ; OSBYTE &750a a0 00 LDY #&00 &750c 84 8e STY &8e ; source_address_low &750e 84 8c STY &8c ; target_address_low &7510 a9 12 LDA #&12 ; &1200 &7512 85 8f STA &8f ; source_address_high &7514 a9 0e LDA #&0e ; &0e00 &7516 85 8d STA &8d ; target_address_high ; move_1200_to_6fff_loop # Decrypt &1200 - &6fff and move to &0e00 - &6bff &7518 98 TYA &7519 49 ed EOR #&ed &751b 51 8e EOR (&8e),Y ; source_address &751d 91 8c STA (&8c),Y ; target_address &751f c8 INY &7520 d0 f6 BNE &7518 ; move_1200_to_6fff_loop &7522 e6 8d INC &8d ; target_address_high &7524 e6 8f INC &8f ; source_address_low &7526 a5 8f LDA &8f ; source_address_low &7528 c9 70 CMP #&70 &752a d0 ec BNE &7518 ; move_1200_to_6fff_loop ; move_7000_to_72ff_loop # Decrypt &7000 - &72ff and move to &0900 - &0bff &752c 98 TYA &752d 49 ed EOR #&ed &752f 59 00 70 EOR &7000,Y &7532 99 00 09 STA &0900,Y &7535 98 TYA &7536 49 ed EOR #&ed &7538 59 00 71 EOR &7100,Y &753b 99 00 0a STA &0a00,Y &753e 98 TYA &753f 49 ed EOR #&ed &7541 59 00 72 EOR &7200,Y &7544 99 00 0b STA &0b00,Y &7547 c8 INY &7548 d0 e2 BNE &752c ; move_7000_to_72ff_loop ; move_7300_to_73ff_loop # Decrypt &7300 - &73ff and move to &7f00 - &7fff &754a 98 TYA &754b 49 ed EOR #&ed &754d 59 00 73 EOR &7300,Y &7550 99 00 7f STA &7f00,Y &7553 c8 INY &7554 d0 f4 BNE &754a ; move_7300_to_73ff_loop &7556 98 TYA ; wipe_0400_to_07ff_loop # Wipe &0400 - &07ff and &6c00 - &6cff &7557 99 00 04 STA &0400,Y &755a 99 00 05 STA &0500,Y &755d 99 00 06 STA &0600,Y &7560 99 00 07 STA &0700,Y &7563 99 00 6c STA &6c00,Y &7566 c8 INY &7567 d0 ee BNE &7557 ; wipe_0400_to_07ff_loop ; move_7400_to_74e7_loop # Decrypt &7400 - &74e7 and move to &0440 - &0527 &7569 98 TYA &756a 49 ed EOR #&ed &756c 59 00 74 EOR &7400,Y &756f 99 40 04 STA &0440,Y &7572 c8 INY &7573 c0 e8 CPY #&e8 &7575 d0 f2 BNE &7569 ; move_7400_to_74e7_loop &7577 a0 0a LDY #&0a ; wipe_0000_to_00af_loop # Wipe &0000 to &00af &7579 a9 00 LDA #&00 &757b 99 00 00 STA &0000,Y &757e c8 INY &757f c0 b0 CPY #&b0 &7581 d0 f6 BNE &7579 ; wipe_0000_to_00af_loop &7583 a0 07 LDY #&07 ; move_75da_to_75e1_loop # Move &75da - &75e1 to &0090 - &0097 &7585 b9 da 75 LDA &75da,Y ; unrelocated_palette &7588 99 90 00 STA &0090,Y ; palette &758b 88 DEY &758c 10 f7 BPL &7585 ; move_75da_to_75e1_loop &758e a5 00 LDA &00 ; loader_rnd_1 &7590 85 9a STA &9a ; rnd_1 &7592 a5 01 LDA &01 ; loader_rnd_2 &7594 85 9b STA &9b ; rnd_2 &7596 a9 9e LDA #&9e ; Z &7598 85 00 STA &00 ; key_left &759a a9 bd LDA #&bd ; X &759c 85 01 STA &01 ; key_right &759e a9 b7 LDA #&b7 ; * &75a0 85 02 STA &02 ; key_up &75a2 a9 97 LDA #&97 ; ? &75a4 85 03 STA &03 ; key_down &75a6 a9 b6 LDA #&b6 ; RETURN &75a8 85 04 STA &04 ; key_fire &75aa a5 07 LDA &07 ; user_defined_key_up &75ac a6 08 LDX &08 ; user_defined_key_down &75ae 85 08 STA &08 ; user_defined_key_down &75b0 86 07 STX &07 ; user_defined_key_up &75b2 c8 INY ; set_video_registers_loop &75b3 b9 e2 75 LDA &75e2,Y ; video_register_table &75b6 8d 00 fe STA &fe00 ; video register number &75b9 c8 INY &75ba b9 e2 75 LDA &75e2,Y ; video_register_table &75bd 8d 01 fe STA &fe01 ; video register value &75c0 c8 INY &75c1 c0 0e CPY #&0e &75c3 d0 ee BNE &75b3 ; set_video_registers_loop &75c5 a9 9a LDA #&9a ; Write to Video ULA control register and RAM copy &75c7 a2 64 LDX #&64 # MODE 5, small cursor, 4 byte cursor &75c9 20 f4 ff JSR &fff4 ; OSBYTE &75cc 20 03 7f JSR &7f03 ; initialise_vectors &75cf 20 00 7f JSR &7f00 ; to_set_screen_colours &75d2 a9 0f LDA #&0f ; Flush input buffer &75d4 20 f4 ff JSR &fff4 ; OSBYTE &75d7 4c 90 32 JMP &3290 ; title_screen # &75da - &75e1 is moved to &0090 - &0097 at &7585 ; palette &0090 00 00 00 01 00 02 00 07 ; video_register_table &75e2 01 20 ; R1: Number of characters per line &75e4 06 19 ; R6: Vertical displayed register &75e6 0c 0c ; R12: Displayed screen start address register (high) # Set screen start address to &6600 &75e8 0d c0 ; R13: Displayed screen start address register (low) &75ea 07 24 ; R7: Vertical sync position &75ec 02 2e ; R2: Horizontal sync position register &75ee 00 3f ; R0: Horizontal total register ; unused &75f0 ae 34 14 bb d2 d2 a6 f9 0d bb f2 a7 93 c9 a0 c0 3b # Not meaningful encrypted or decrypted