; Routine: Adjust background colors if neccessary { $A6:A4D6 0A ASL A $A6:A4D7 AA TAX $A6:A4D8 BC EB A4 LDY $A4EB,x[$A6:A4EB] $A6:A4DB D0 02 BNE $02 [$A4DF] $A6:A4DD 38 SEC $A6:A4DE 60 RTS $A6:A4DF A2 E2 00 LDX #$00E2 $A6:A4E2 A9 0E 00 LDA #$000E $A6:A4E5 22 E4 D2 A9 JSL $A9D2E4[$A9:D2E4] $A6:A4E9 18 CLC $A6:A4EA 60 RTS $A6:A4EB db 0B, A5, 27, A5, 43, A5, 5F, A5, 7B, A5, 97, A5, B3, A5, CF, A5, EB, A5, 07, A6, 23, A6, 3F, A6, 5B, A6, 77, A6, 93, A6, 00, 00, 01, 00, 01, 00, 01, 00, 00, 00, 00, 00, 00, 00, 00, 00, 01, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 42, 08, 23, 00, 03, 00, 03, 00, 01, 00, 01, 00, 00, 00, 00, 00, 01, 00, 01, 00, 00, 00, 00, 00, 01, 00, 01, 00, 84, 10, 44, 00, 24, 00, 04, 00, 02, 04, 01, 00, 00, 00, 00, 00, 02, 00, 01, 00, 00, 00, 00, 00, 01, 00, 01, 00, C6, 18, 65, 00, 25, 00, 05, 00, 03, 04, 02, 00, 01, 00, 00, 00, 03, 00, 02, 00, 01, 00, 00, 00, 02, 00, 02, 00, 08, 21, 87, 00, 47, 00, 07, 00, 04, 04, 02, 04, 01, 00, 00, 00, 04, 00, 03, 00, 01, 00, 00, 00, 02, 04, 03, 00, 4A, 29, 88, 00, 48, 00, 08, 00, 04, 08, 03, 04, 01, 00, 00, 00, 05, 00, 03, 00, 01, 00, 00, 00, 03, 04, 03, 00, 8C, 31, AA, 00, 4A, 00, 2A, 00, 05, 08, 03, 04, 01, 00, 00, 00, 06, 04, 04, 00, 01, 00, 00, 00, 03, 04, 04, 00, CE, 39, CB, 00, 6B, 00, 2B, 00, 06, 08, 04, 04, 02, 00, 00, 00, 07, 04, 04, 00, 02, 00, 00, 00, 04, 04, 04, 00, 10, 42, ED, 00, 6D, 00, 2D, 00, 07, 0C, 04, 04, 02, 00, 00, 00, 08, 04, 05, 00, 02, 00, 00, 00, 04, 04, 05, 00, 52, 4A, 0E, 01, 8E, 00, 2E, 00, 08, 0C, 05, 08, 02, 00, 00, 00, 09, 04, 06, 00, 02, 00, 00, 00, 05, 08, 06, 00, 94, 52, 10, 01, 90, 00, 30, 00, 08, 0C, 05, 08, 03, 00, 00, 00, 0A, 04, 06, 00, 03, 00, 00, 00, 05, 08, 06, 00, D6, 5A, 31, 01, 91, 00, 31, 00, 09, 10, 06, 08, 03, 00, 00, 00, 0B, 04, 07, 00, 03, 00, 00, 00, 06, 08, 07, 00, 18, 63, 53, 01, B3, 00, 33, 00, 0A, 10, 07, 08, 03, 00, 00, 00, 0C, 04, 07, 00, 03, 00, 00, 00, 07, 08, 07, 00, 5A, 6B, 74, 05, B4, 04, 34, 04, 0B, 10, 07, 08, 03, 04, 00, 00, 0D, 04, 08, 04, 03, 00, 00, 00, 07, 08, 08, 04, BD, 77, 96, 05, D6, 04, 56, 04, 0C, 14, 08, 0C, 04, 04, 00, 00, 0E, 08, 09, 04, 04, 00, 00, 00, 08, 0C, 09, 04, FF, 7F } ; Routine: Get new AI script for B321 { ; Check for spin jump { $A6:B335 AD 1F 0A LDA $0A1F [$7E:0A1F] ; Samus' movement type $A6:B338 29 FF 00 AND #$00FF $A6:B33B C9 03 00 CMP #$0003 ; Spin jump $A6:B33E D0 06 BNE $06 [$B346] LDA #$B3CC ; 8/8 B5C4 (consider pogo) STA $12 RTS } ; Check if Ridley is dead { $A6:B346 AD 8C 0F LDA $0F8C [$7E:0F8C] ; Ridley's HP $A6:B349 D0 0F BNE $0F [$B35A] LDA #$B3DC ; 8/8 BAB7 STA $12 LDA $7E800A INC A STA $7E800A ; Death swoop counter RTS } ; Check if HP < 14400 { $A6:B35A C9 40 38 CMP #$3840 $A6:B35D 10 06 BPL $06 [$B365] $A6:B35F A0 8C B3 LDY #$B38C ; 4/8 B6A7 (pogo) and 4/8 B441 (swoop) $A6:B362 84 12 STY $12 [$7E:0012] $A6:B364 60 RTS } ; Check if Samus' Y is below #$0160 { $A6:B365 20 20 BD JSR $BD20 [$A6:BD20] $A6:B368 90 06 BCC $06 [$B370] $A6:B36A A0 BC B3 LDY #$B3BC ; 8/8 B6A7 $A6:B36D 84 12 STY $12 [$7E:0012] $A6:B36F 60 RTS } ; Check if spin jumping, grappling or spinback from hurt { $A6:B370 20 F1 BC JSR $BCF1 [$A6:BCF1] ; CLC if spin jump, grappling, or spin back from hurt $A6:B373 90 06 BCC $06 [$B37B] $A6:B375 A0 AC B3 LDY #$B3AC ; 6/8 BAB7 and 2/8 B6A7 $A6:B378 84 12 STY $12 [$7E:0012] $A6:B37A 60 RTS } ; If not any of those { LDY #$B38C ; 4/8 B6A7 (pogo) and 4/8 B441 (swoop) LDA $0F8C ; HP ; Ridley's HP CMP #$2328 ; Compare HP to 9000 BPL BRANCH_ZETA ; A previous check confirmed over 14400 hp. Ergo, this always branches. Not that it much matters LDY #$B39C ; Pointer to a set of new AI scripts to run if below 9000 HP: 4/8 B441 (swoop), 4/8 B6A7 (pogo) } STY $12 RTS ; Data for choosing AI in B321 { $A6:B38E db A7, B6 $A6:B394 db 41, B4 $A6:B398 db 41, B4, 41, B4 $A6:B3B4 db B7, BA $A6:B3BA db A7, B6 $A6:B3C8 db A7, B6 } } ; Routine: Check if tail has collided with a block? { $A6:B7E7 AF A4 20 7E LDA $7E20A4[$7E:20A4] ; Tail tip X position $A6:B7EB AA TAX $A6:B7EC AF A6 20 7E LDA $7E20A6[$7E:20A6] ; Tail tip Y position $A6:B7F0 18 CLC $A6:B7F1 69 10 00 ADC #$0010 $A6:B7F4 A8 TAY $A6:B7F5 22 F9 D4 A6 JSL $A6D4F9[$A6:D4F9] $A6:B7F9 B0 51 BCS $51 [$B84C] $A6:B7FB AF 90 20 7E LDA $7E2090[$7E:2090] $A6:B7FF AA TAX $A6:B800 AF 92 20 7E LDA $7E2092[$7E:2092] $A6:B804 18 CLC $A6:B805 69 12 00 ADC #$0012 $A6:B808 A8 TAY $A6:B809 22 F9 D4 A6 JSL $A6D4F9[$A6:D4F9] $A6:B80D B0 3D BCS $3D [$B84C] $A6:B80F AF 7C 20 7E LDA $7E207C[$7E:207C] $A6:B813 AA TAX $A6:B814 AF 7E 20 7E LDA $7E207E[$7E:207E] $A6:B818 18 CLC $A6:B819 69 12 00 ADC #$0012 $A6:B81C A8 TAY $A6:B81D 22 F9 D4 A6 JSL $A6D4F9[$A6:D4F9] $A6:B821 B0 29 BCS $29 [$B84C] $A6:B823 AF 68 20 7E LDA $7E2068[$7E:2068] $A6:B827 AA TAX $A6:B828 AF 6A 20 7E LDA $7E206A[$7E:206A] $A6:B82C 18 CLC $A6:B82D 69 12 00 ADC #$0012 $A6:B830 A8 TAY $A6:B831 22 F9 D4 A6 JSL $A6D4F9[$A6:D4F9] $A6:B835 B0 15 BCS $15 [$B84C] $A6:B837 AF 54 20 7E LDA $7E2054[$7E:2054] $A6:B83B AA TAX $A6:B83C AF 56 20 7E LDA $7E2056[$7E:2056] $A6:B840 18 CLC $A6:B841 69 12 00 ADC #$0012 $A6:B844 A8 TAY $A6:B845 22 F9 D4 A6 JSL $A6D4F9[$A6:D4F9] $A6:B849 B0 01 BCS $01 [$B84C] $A6:B84B EA NOP $A6:B84C 60 RTS } ; Routine: Set A+Y=[4, 8, A, C] depending on General Speed Byte { $A6:B42E AF 24 78 7E LDA $7E7824[$7E:7824] ; General speed byte $A6:B432 0A ASL A $A6:B433 A8 TAY $A6:B434 B9 39 B4 LDA $B439,y[$A6:B439] $A6:B437 A8 TAY $A6:B438 60 RTS $A6:B439 db 04, 00 $A6:B43F db 0C, 00 } ; Routine: Fly towards $12 (X position) / Samus' Y position. (B641) { LDA $0AFA ;Samus's Y position CMP #$0160 BMI BRANCH_ALPHA LDA #$0160 BRANCH_ALPHA ;Maximum cap is 160 STA $14 LDX #$0000 JSR $B42E ;Y = 4, 8, A, or C, depending on general speed byte JSR $D523 ;Accelerates Ridley towards the desired X/Y ($12/$14). No deceleration boost ($1A), Y is index value to find acceleration divisor ($18), X is enemy's index LDA #$0001 STA $7E2004 ;Tail fling trigger LDA $0A1F ;Samus's movement type AND #$00FF CMP #$0003 ;Spin jump BNE BRANCH_BETA LDA $05E5 ;Random number AND #$00FF CMP #$0080 BCC BRANCH_GAMMA ;50% chance of not fireballing LDA $7E781E ;Current sound playing? BNE BRANCH_GAMMA LDA $7E7820 ;Facing direction ; Ridley's direction (0 = left, 2 = right) DEC A BEQ BRANCH_GAMMA ;Branch if facing forward LDA #$E73A ;Fireballing AI JSR $D467 ;STA to GraphicAI instruction (0F92), delay (0F94) = 1, STZ $0F90 BRANCH_GAMMA CLC RTS BRANCH_BETA SEC RTS } ; Routine: Reset tail { $A6:B84D A9 01 00 LDA #$0001 $A6:B850 8F 00 20 7E STA $7E2000[$7E:2000] ; Tail control index $A6:B854 8F 14 20 7E STA $7E2014[$7E:2014] ; Tail rotational speed $A6:B858 60 RTS } ; Routine: Attempt to grab Samus { $A6:B859 20 F1 BC JSR $BCF1 [$A6:BCF1] ; CLC if spin jump, grappling, or spin back from hurt $A6:B85C B0 01 BCS $01 [$B85F] RTS $A6:B85F A2 04 00 LDX #$0004 $A6:B862 A0 04 00 LDY #$0004 $A6:B865 86 16 STX $16 [$7E:0016] $A6:B867 84 18 STY $18 [$7E:0018] $A6:B869 AF 20 78 7E LDA $7E7820[$7E:7820] ; Ridley's direction (0 = left, 2 = right) $A6:B86D 0A ASL A $A6:B86E A8 TAY $A6:B86F B9 D5 B9 LDA $B9D5,y[$A6:B9D9] $A6:B872 18 CLC $A6:B873 6D 7A 0F ADC $0F7A [$7E:0F7A] ; Ridley's X position $A6:B876 85 12 STA $12 [$7E:0012] $A6:B878 AF 3A 78 7E LDA $7E783A[$7E:783A] $A6:B87C A8 TAY $A6:B87D B9 DB B9 LDA $B9DB,y[$A6:B9DB] $A6:B880 18 CLC $A6:B881 6D 7E 0F ADC $0F7E [$7E:0F7E] ; Ridley's Y position $A6:B884 85 14 STA $14 [$7E:0014] $A6:B886 4C 29 DF JMP $DF29 [$A6:DF29] ; Efficient collision detection for Samus and $12/$14 (size of $12/$14 is $16/$18). SEC if collision } ; Routine: Change direction when Ridley is pogoing, sometimes? { $A6:B8A9 AD AA 0F LDA $0FAA [$7E:0FAA] ; X speed (1/100 pixels) $A6:B8AC D0 0F BNE $0F [$B8BD] $A6:B8BD AD 7A 0F LDA $0F7A [$7E:0F7A] ; Ridley's X position $A6:B8C0 38 SEC $A6:B8C1 ED F6 0A SBC $0AF6 [$7E:0AF6] ; Samus' X position $A6:B8C4 4D AA 0F EOR $0FAA [$7E:0FAA] ; X speed (1/100 pixels) $A6:B8C7 30 22 BMI $22 [$B8EB] $A6:B8C9 AD 7A 0F LDA $0F7A [$7E:0F7A] ; Ridley's X position $A6:B8CC CF 04 80 7E CMP $7E8004[$7E:8004] $A6:B8D0 30 31 BMI $31 [$B903] $A6:B8D2 CF 06 80 7E CMP $7E8006[$7E:8006] $A6:B8D6 10 31 BPL $31 [$B909] $A6:B8D8 AD E5 05 LDA $05E5 [$7E:05E5] $A6:B8DB C9 55 05 CMP #$0555 $A6:B8DE 90 0A BCC $0A [$B8EA] $A6:B8E0 AD AA 0F LDA $0FAA [$7E:0FAA] ; X speed (1/100 pixels) $A6:B8E3 49 FF FF EOR #$FFFF $A6:B8E6 1A INC A $A6:B8E7 8D AA 0F STA $0FAA [$7E:0FAA] ; X speed (1/100 pixels) $A6:B8EA 60 RTS $A6:B8EB AD 7A 0F LDA $0F7A [$7E:0F7A] ; Ridley's X position $A6:B8EE CF 04 80 7E CMP $7E8004[$7E:8004] $A6:B8F2 30 0F BMI $0F [$B903] $A6:B8F4 CF 06 80 7E CMP $7E8006[$7E:8006] $A6:B8F8 10 0F BPL $0F [$B909] $A6:B8FA AD E5 05 LDA $05E5 [$7E:05E5] $A6:B8FD C9 55 05 CMP #$0555 $A6:B900 90 DE BCC $DE [$B8E0] $A6:B902 60 RTS } ; Routine: Set speeds for pogo { $A6:B90F AD E5 05 LDA $05E5 [$7E:05E5] $A6:B912 29 03 00 AND #$0003 $A6:B915 0A ASL A $A6:B916 A8 TAY $A6:B917 B9 65 B9 LDA $B965,y[$A6:B96B] $A6:B91A 85 12 STA $12 [$7E:0012] $A6:B91C B9 6D B9 LDA $B96D,y[$A6:B973] $A6:B91F 85 14 STA $14 [$7E:0014] $A6:B921 AF 24 78 7E LDA $7E7824[$7E:7824] ; General speed byte $A6:B925 18 CLC $A6:B926 69 02 00 ADC #$0002 $A6:B929 0A ASL A $A6:B92A A8 TAY $A6:B92B B9 4D B9 LDA $B94D,y[$A6:B951] $A6:B92E 8F 0E 20 7E STA $7E200E[$7E:200E] ; Ridley pogo acceleration upwards (after hitting ground) $A6:B932 B9 59 B9 LDA $B959,y[$A6:B95D] $A6:B935 8F 0C 20 7E STA $7E200C[$7E:200C] ; Ridley pogo speed $A6:B939 B1 14 LDA ($14),y[$A6:B9CD] $A6:B93B 8D AC 0F STA $0FAC [$7E:0FAC] ; Y speed (1/100 pixels) $A6:B93E B1 12 LDA ($12),y[$A6:B99D] $A6:B940 AE AA 0F LDX $0FAA [$7E:0FAA] ; X speed (1/100 pixels) $A6:B943 10 04 BPL $04 [$B949] $A6:B945 49 FF FF EOR #$FFFF $A6:B948 1A INC A $A6:B949 8D AA 0F STA $0FAA [$7E:0FAA] ; X speed (1/100 pixels) $A6:B94C 60 RTS ; Data used here? Missing some (B94D) { $A6:B951 db 20, 00 $A6:B95D db 40, 00 $A6:B965 db 75, B9 $A6:B969 db 8D, B9, 99, B9, A5, B9 $A6:B971 db BD, B9, C9, B9 $A6:B979 db A0, 00 $A6:B991 db E0, 00 $A6:B99D db 00, 01 $A6:B9A9 db E0, FC $A6:B9C1 db 60, FC $A6:B9CD db 40, FC } } ; Routine: If holding Samus, move Samus to Ridley's claws { $A6:B9D5 db 0C, 00 $A6:B9D9 db F4, FF, 23, 00 $A6:B9E1 AF 28 78 7E LDA $7E7828[$7E:7828] $A6:B9E5 F0 1F BEQ $1F [$BA06] $A6:B9E7 85 12 STA $12 [$7E:0012] $A6:B9E9 10 04 BPL $04 [$B9EF] $A6:B9EB 49 FF FF EOR #$FFFF $A6:B9EE 1A INC A $A6:B9EF 38 SEC $A6:B9F0 E9 04 00 SBC #$0004 $A6:B9F3 10 05 BPL $05 [$B9FA] $A6:B9F5 A9 00 00 LDA #$0000 $A6:B9F8 80 08 BRA $08 [$BA02] $A6:B9FA 24 12 BIT $12 [$7E:0012] $A6:B9FC 10 04 BPL $04 [$BA02] $A6:B9FE 49 FF FF EOR #$FFFF $A6:BA01 1A INC A $A6:BA02 8F 28 78 7E STA $7E7828[$7E:7828] $A6:BA06 AF 2A 78 7E LDA $7E782A[$7E:782A] $A6:BA0A F0 1F BEQ $1F [$BA2B] $A6:BA0C 85 12 STA $12 [$7E:0012] $A6:BA0E 10 04 BPL $04 [$BA14] $A6:BA14 38 SEC $A6:BA15 E9 04 00 SBC #$0004 $A6:BA18 10 05 BPL $05 [$BA1F] $A6:BA1A A9 00 00 LDA #$0000 $A6:BA1D 80 08 BRA $08 [$BA27] $A6:BA1F 24 12 BIT $12 [$7E:0012] $A6:BA21 10 04 BPL $04 [$BA27] $A6:BA27 8F 2A 78 7E STA $7E782A[$7E:782A] $A6:BA2B AF 20 78 7E LDA $7E7820[$7E:7820] ; Ridley's direction (0 = left, 2 = right) $A6:BA2F 0A ASL A $A6:BA30 A8 TAY $A6:BA31 B9 D5 B9 LDA $B9D5,y[$A6:B9D5] $A6:BA34 6D 7A 0F ADC $0F7A [$7E:0F7A] ; Ridley's X position $A6:BA37 18 CLC $A6:BA38 6F 28 78 7E ADC $7E7828[$7E:7828] $A6:BA3C 8D F6 0A STA $0AF6 [$7E:0AF6] ; Samus' X position $A6:BA3F AF 3A 78 7E LDA $7E783A[$7E:783A] $A6:BA43 A8 TAY $A6:BA44 B9 DB B9 LDA $B9DB,y[$A6:B9DB] $A6:BA47 18 CLC $A6:BA48 6D 7E 0F ADC $0F7E [$7E:0F7E] ; Ridley's Y position $A6:BA4B 18 CLC $A6:BA4C 6F 2A 78 7E ADC $7E782A[$7E:782A] $A6:BA50 8D FA 0A STA $0AFA [$7E:0AFA] ; Samus' Y position $A6:BA53 60 RTS } ; Routine: Set displacement for Ridley grabbing Samus { $A6:BA54 AF 20 78 7E LDA $7E7820[$7E:7820] ; Ridley's direction (0 = left, 2 = right) $A6:BA58 0A ASL A $A6:BA59 A8 TAY $A6:BA5A B9 D5 B9 LDA $B9D5,y[$A6:B9D5] $A6:BA5D 6D 7A 0F ADC $0F7A [$7E:0F7A] ; Ridley's X position $A6:BA60 38 SEC $A6:BA61 ED F6 0A SBC $0AF6 [$7E:0AF6] ; Samus' X position $A6:BA64 49 FF FF EOR #$FFFF $A6:BA67 1A INC A $A6:BA68 8F 28 78 7E STA $7E7828[$7E:7828] $A6:BA6C AF 3A 78 7E LDA $7E783A[$7E:783A] $A6:BA70 A8 TAY $A6:BA71 B9 DB B9 LDA $B9DB,y[$A6:B9DB] $A6:BA74 18 CLC $A6:BA75 6D 7E 0F ADC $0F7E [$7E:0F7E] ; Ridley's Y position $A6:BA78 38 SEC $A6:BA79 ED FA 0A SBC $0AFA [$7E:0AFA] ; Samus' Y position $A6:BA7C 49 FF FF EOR #$FFFF $A6:BA7F 1A INC A $A6:BA80 8F 2A 78 7E STA $7E782A[$7E:782A] $A6:BA84 60 RTS } ; Routine: Grab Samus { $A6:BC68 20 54 BA JSR $BA54 [$A6:BA54] ; Set displacement for Ridley grabbing Samus $A6:BC6B AD 86 0F LDA $0F86 [$7E:0F86] ; Property bits of Ridley $A6:BC6E 09 00 04 ORA #$0400 $A6:BC71 8D 86 0F STA $0F86 [$7E:0F86] ; Property bits of Ridley $A6:BC74 A9 01 00 LDA #$0001 $A6:BC77 8F 36 78 7E STA $7E7836[$7E:7836] ; Set if Ridley is holding Samus $A6:BC7B 3A DEC A $A6:BC7C 22 84 F0 90 JSL $90F084[$90:F084] $A6:BC80 38 SEC $A6:BC81 4C 8B DA JMP $DA8B [$A6:DA8B] ; Write to VRAM for Ridley's claws $A6:BC84 A9 01 00 LDA #$0001 $A6:BC87 8F 04 20 7E STA $7E2004[$7E:2004] ; Tail fling trigger $A6:BC8B 8F 00 20 7E STA $7E2000[$7E:2000] ; Tail control index $A6:BC8F AF 02 78 7E LDA $7E7802[$7E:7802] $A6:BC93 30 0F BMI $0F [$BCA4] $A6:BC95 20 F1 BC JSR $BCF1 [$A6:BCF1] ; CLC if spin jump, grappling, or spin back from hurt $A6:BC98 A9 06 00 LDA #$0006 $A6:BC9B 70 03 BVS $03 [$BCA0] $A6:BC9D A9 0A 00 LDA #$000A $A6:BCA0 8F 3C 78 7E STA $7E783C[$7E:783C] $A6:BCA4 A9 00 00 LDA #$0000 $A6:BCA7 8F 36 78 7E STA $7E7836[$7E:7836] ; Set if Ridley is holding Samus $A6:BCAB 1A INC A $A6:BCAC 22 84 F0 90 JSL $90F084[$90:F084] $A6:BCB0 18 CLC $A6:BCB1 4C 8B DA JMP $DA8B [$A6:DA8B] ; Write to VRAM for Ridley's claws $A6:BCB4 AF 02 78 7E LDA $7E7802[$7E:7802] $A6:BCB8 30 36 BMI $36 [$BCF0] $A6:BCBA F0 18 BEQ $18 [$BCD4] $A6:BCBC 20 7A DE JSR $DE7A [$A6:DE7A] ; Checks if Ridley is on screen $A6:BCBF 90 0A BCC $0A [$BCCB] $A6:BCC1 AD 86 0F LDA $0F86 [$7E:0F86] ; Property bits of Ridley $A6:BCC4 09 00 04 ORA #$0400 $A6:BCC7 8D 86 0F STA $0F86 [$7E:0F86] ; Property bits of Ridley $A6:BCCA 60 RTS $A6:BCCB AD 86 0F LDA $0F86 [$7E:0F86] ; Property bits of Ridley $A6:BCCE 29 FF FB AND #$FBFF $A6:BCD1 8D 86 0F STA $0F86 [$7E:0F86] ; Property bits of Ridley $A6:BCD4 AF 3C 78 7E LDA $7E783C[$7E:783C] $A6:BCD8 F0 16 BEQ $16 [$BCF0] $A6:BCDA 3A DEC A $A6:BCDB 8F 3C 78 7E STA $7E783C[$7E:783C] $A6:BCDF D0 0F BNE $0F [$BCF0] $A6:BCE1 AF 02 78 7E LDA $7E7802[$7E:7802] $A6:BCE5 30 09 BMI $09 [$BCF0] $A6:BCE7 AD 86 0F LDA $0F86 [$7E:0F86] ; Property bits of Ridley $A6:BCEA 29 FF FB AND #$FBFF $A6:BCED 8D 86 0F STA $0F86 [$7E:0F86] ; Property bits of Ridley $A6:BCF0 60 RTS } ; Routine: CLC if spin jump, grappling, or spin back from hurt { $A6:BCF1 AD 1F 0A LDA $0A1F [$7E:0A1F] ; Samus' movement type $A6:BCF4 29 FF 00 AND #$00FF $A6:BCF7 DA PHX $A6:BCF8 AA TAX $A6:BCF9 3C 03 BD BIT $BD03,x[$A6:BD05] $A6:BCFC 30 03 BMI $03 [$BD01] ; Yes? { $A6:BD0E FA PLX $A6:BD0F 18 CLC $A6:BD10 60 RTS } ; No? { $A6:BD01 FA PLX $A6:BD02 38 SEC $A6:BD03 60 RTS } ; Data used above. Might be missing something? { ; Yes: 03 (spin), 0B (Unused), 0C (Unused), 16 (Grappling), 19 (dmg boost), 1A (Grabbed by Draygon) ; BD04 db 80, 80, 80, 00, ff, 80, 80, ff ; BD0C db ff, ff, 80, 00, 00, 80, 80, 80 ; BD04 db 80, ff, ff, ff, 80, 80, 00, 80 ; BD0C db 80, 00, 00, 80 } } ; Routine: Check if Y is below #$0160 { $A6:BD20 AD FA 0A LDA $0AFA [$7E:0AFA] ; Samus' Y position $A6:BD23 C9 60 01 CMP #$0160 $A6:BD26 10 02 BPL $02 [$BD2A] $A6:BD28 18 CLC $A6:BD29 60 RTS $A6:BD2A 38 SEC $A6:BD2B 60 RTS } ; Routine: Powerbomb check/reaction { $A6:BD2C AF 02 78 7E LDA $7E7802[$7E:7802] $A6:BD30 30 1B BMI $1B [$BD4D] $A6:BD32 F0 19 BEQ $19 [$BD4D] $A6:BD34 C9 02 00 CMP #$0002 $A6:BD37 F0 14 BEQ $14 [$BD4D] $A6:BD39 AD EE 0C LDA $0CEE [$7E:0CEE] ; Powerbomb timer $A6:BD3C F0 0F BEQ $0F [$BD4D] $A6:BD4D 60 RTS } ; Routine: Move to death spot (80,148) { $A6:C601 A2 80 00 LDX #$0080 $A6:C604 86 12 STX $12 [$7E:0012] $A6:C606 A0 48 01 LDY #$0148 $A6:C609 84 14 STY $14 [$7E:0014] $A6:C60B A2 00 00 LDX #$0000 $A6:C60E A0 00 00 LDY #$0000 $A6:C611 A9 10 00 LDA #$0010 $A6:C614 20 26 D5 JSR $D526 [$A6:D526] ; Accelerates Ridley towards the desired X/Y ($12/$14). No deceleration boost ($1A), Y is index value to find acceleration divisor ($18), X is enemy's index $A6:C617 A9 04 00 LDA #$0004 $A6:C61A 85 16 STA $16 [$7E:0016] $A6:C61C 85 18 STA $18 [$7E:0018] $A6:C61E 22 06 EF A9 JSL $A9EF06[$A9:EF06] ; Checks an enemy with index of X colliding with $12/$14 with a size of $16/$18, CLC if collided $A6:C622 60 RTS } ; Routine: Spawn/play explosions? { $A6:C623 AF 0E 80 7E LDA $7E800E[$7E:800E] $A6:C627 3A DEC A $A6:C628 30 05 BMI $05 [$C62F] $A6:C62A 8F 0E 80 7E STA $7E800E[$7E:800E] $A6:C62E 60 RTS $A6:C62F A9 04 00 LDA #$0004 $A6:C632 8F 0E 80 7E STA $7E800E[$7E:800E] $A6:C636 AF 10 80 7E LDA $7E8010[$7E:8010] $A6:C63A 1A INC A $A6:C63B C9 0A 00 CMP #$000A $A6:C63E 30 03 BMI $03 [$C643] $A6:C640 A9 00 00 LDA #$0000 $A6:C643 8F 10 80 7E STA $7E8010[$7E:8010] $A6:C647 0A ASL A $A6:C648 0A ASL A $A6:C649 A8 TAY $A6:C64A B9 6E C6 LDA $C66E,y[$A6:C672] $A6:C64D 18 CLC $A6:C64E 6D 7A 0F ADC $0F7A [$7E:0F7A] ; Ridley's X position $A6:C651 85 12 STA $12 [$7E:0012] $A6:C653 B9 70 C6 LDA $C670,y[$A6:C674] $A6:C656 18 CLC $A6:C657 6D 7E 0F ADC $0F7E [$7E:0F7E] ; Ridley's Y position $A6:C65A 85 14 STA $14 [$7E:0014] $A6:C65C A9 03 00 LDA #$0003 $A6:C65F A0 09 E5 LDY #$E509 $A6:C662 22 97 80 86 JSL $868097[$86:8097] $A6:C666 A9 24 00 LDA #$0024 $A6:C669 22 B7 90 80 JSL $8090B7[$80:90B7] $A6:C66D 60 RTS $A6:C66E db E8, FF, E8, FF, EC, FF, 14, 00, 10, 00, E2, FF, 1E, 00, FD, FF, 0E, 00, F3, FF, FE, FF, 12, 00, FE, FF, E0, FF, E1, FF, 08, 00, FC, FF, F6, FF, 13, 00, 13, 00 } ; Routine: Set PLM instruction { $A6:D467 8D 92 0F STA $0F92 [$7E:0F92] ; Set PLM instruction? $A6:D46A A9 01 00 LDA #$0001 $A6:D46D 8D 94 0F STA $0F94 [$7E:0F94] $A6:D470 9C 90 0F STZ $0F90 [$7E:0F90] $A6:D473 60 RTS } ; Routine: Checks for collisions with blocks at pixel X/Y. ; All non-air blocks are considered fully solid, SEC if hit, CLC if air { $A6:D4F9 98 TYA $A6:D4FA 4A LSR A $A6:D4FB 4A LSR A $A6:D4FC 4A LSR A $A6:D4FD 4A LSR A $A6:D4FE E2 20 SEP #$20 $A6:D500 8D 02 42 STA $4202 [$7E:4202] $A6:D503 AD A5 07 LDA $07A5 [$7E:07A5] $A6:D506 8D 03 42 STA $4203 [$7E:4203] $A6:D509 C2 20 REP #$20 $A6:D50B 8A TXA $A6:D50C 4A LSR A $A6:D50D 4A LSR A $A6:D50E 4A LSR A $A6:D50F 4A LSR A $A6:D510 18 CLC $A6:D511 6D 16 42 ADC $4216 [$7E:4216] $A6:D514 0A ASL A $A6:D515 AA TAX $A6:D516 BF 02 00 7F LDA $7F0002,x[$7F:0102] $A6:D51A 29 00 F0 AND #$F000 $A6:D51D D0 02 BNE $02 [$D521] $A6:D51F 18 CLC $A6:D520 6B RTL $A6:D521 38 SEC $A6:D522 6B RTL } ; $D523: Accelerates Ridley towards the desired X/Y ($12/$14). No deceleration boost ($1A), Y is index value to find acceleration divisor ($18), X is enemy's index { $A6:D523 A9 00 00 LDA #$0000 $A6:D526 85 1A STA $1A [$7E:001A] $A6:D528 B9 1F D6 LDA $D61F,y[$A6:D62D] $A6:D52B 29 FF 00 AND #$00FF $A6:D52E 85 18 STA $18 [$7E:0018] $A6:D530 20 A9 D5 JSR $D5A9 [$A6:D5A9] ; Accelerates Ridley towards the desired X position ($12). Deceleration boost in $1A, acceleration divisor in $18, X is enemy's index $A6:D533 BD 7E 0F LDA $0F7E,x[$7E:0F7E] ; Ridley's Y position $A6:D536 38 SEC $A6:D537 E5 14 SBC $14 [$7E:0014] $A6:D539 F0 39 BEQ $39 [$D574] $A6:D53B 10 38 BPL $38 [$D575] $A6:D53D 49 FF FF EOR #$FFFF $A6:D540 1A INC A $A6:D541 8D 04 42 STA $4204 [$7E:4204] $A6:D544 E2 20 SEP #$20 $A6:D546 A5 18 LDA $18 [$7E:0018] $A6:D548 8D 06 42 STA $4206 [$7E:4206] $A6:D54B C2 20 REP #$20 $A6:D54D EB XBA $A6:D54E EB XBA $A6:D54F EA NOP $A6:D550 EA NOP $A6:D551 AD 14 42 LDA $4214 [$7E:4214] $A6:D554 D0 01 BNE $01 [$D557] $A6:D556 1A INC A $A6:D557 85 16 STA $16 [$7E:0016] $A6:D559 BD AC 0F LDA $0FAC,x[$7E:0FAC] ; Y speed (1/100 pixels) $A6:D55C 10 09 BPL $09 [$D567] $A6:D55E 18 CLC $A6:D55F 65 1A ADC $1A [$7E:001A] $A6:D561 18 CLC $A6:D562 69 08 00 ADC #$0008 $A6:D565 65 16 ADC $16 [$7E:0016] $A6:D567 65 16 ADC $16 [$7E:0016] $A6:D569 C9 00 05 CMP #$0500 $A6:D56C 30 03 BMI $03 [$D571] $A6:D571 9D AC 0F STA $0FAC,x[$7E:0FAC] ; Y speed (1/100 pixels) $A6:D574 60 RTS $A6:D575 8D 04 42 STA $4204 [$7E:4204] $A6:D578 E2 20 SEP #$20 $A6:D57A A5 18 LDA $18 [$7E:0018] $A6:D57C 8D 06 42 STA $4206 [$7E:4206] $A6:D57F C2 20 REP #$20 $A6:D581 EB XBA $A6:D582 EB XBA $A6:D583 EA NOP $A6:D584 EA NOP $A6:D585 AD 14 42 LDA $4214 [$7E:4214] $A6:D588 D0 01 BNE $01 [$D58B] $A6:D58A 1A INC A $A6:D58B 85 16 STA $16 [$7E:0016] $A6:D58D BD AC 0F LDA $0FAC,x[$7E:0FAC] ; Y speed (1/100 pixels) $A6:D590 30 09 BMI $09 [$D59B] $A6:D592 38 SEC $A6:D593 E5 1A SBC $1A [$7E:001A] $A6:D595 38 SEC $A6:D596 E9 08 00 SBC #$0008 $A6:D599 E5 16 SBC $16 [$7E:0016] $A6:D59B E5 16 SBC $16 [$7E:0016] $A6:D59D C9 00 FB CMP #$FB00 $A6:D5A0 10 03 BPL $03 [$D5A5] $A6:D5A2 A9 00 FB LDA #$FB00 $A6:D5A5 9D AC 0F STA $0FAC,x[$7E:0FAC] ; Y speed (1/100 pixels) $A6:D5A8 60 RTS ; Data used here? { $A6:D61F db 10, 0F, 0E, 0D, 0C, 0B $A6:D626 db 09, 08 $A6:D629 db 06, 05, 04, 03, 02, 01 } } ; Routine: Accelerates Ridley towards the desired X position ($12). Deceleration boost in $1A, acceleration divisor in $18, X is enemy's index { $A6:D5A9 BD 7A 0F LDA $0F7A,x[$7E:0F7A] ; Ridley's X position $A6:D5AC 38 SEC $A6:D5AD E5 12 SBC $12 [$7E:0012] $A6:D5AF F0 39 BEQ $39 [$D5EA] $A6:D5B1 10 38 BPL $38 [$D5EB] $A6:D5B3 49 FF FF EOR #$FFFF $A6:D5B6 1A INC A $A6:D5B7 8D 04 42 STA $4204 [$7E:4204] $A6:D5BA E2 20 SEP #$20 $A6:D5BC A5 18 LDA $18 [$7E:0018] $A6:D5BE 8D 06 42 STA $4206 [$7E:4206] $A6:D5C1 C2 20 REP #$20 $A6:D5C3 EB XBA $A6:D5C4 EB XBA $A6:D5C5 EA NOP $A6:D5C6 EA NOP $A6:D5C7 AD 14 42 LDA $4214 [$7E:4214] $A6:D5CA D0 01 BNE $01 [$D5CD] $A6:D5CC 1A INC A $A6:D5CD 85 16 STA $16 [$7E:0016] $A6:D5CF BD AA 0F LDA $0FAA,x[$7E:0FAA] ; X speed (1/100 pixels) $A6:D5D2 10 09 BPL $09 [$D5DD] $A6:D5D4 18 CLC $A6:D5D5 65 1A ADC $1A [$7E:001A] $A6:D5D7 18 CLC $A6:D5D8 69 08 00 ADC #$0008 $A6:D5DB 65 16 ADC $16 [$7E:0016] $A6:D5DD 65 16 ADC $16 [$7E:0016] $A6:D5DF C9 00 05 CMP #$0500 $A6:D5E2 30 03 BMI $03 [$D5E7] $A6:D5E7 9D AA 0F STA $0FAA,x[$7E:0FAA] ; X speed (1/100 pixels) $A6:D5EA 60 RTS $A6:D5EB 8D 04 42 STA $4204 [$7E:4204] $A6:D5EE E2 20 SEP #$20 $A6:D5F0 A5 18 LDA $18 [$7E:0018] $A6:D5F2 8D 06 42 STA $4206 [$7E:4206] $A6:D5F5 C2 20 REP #$20 $A6:D5F7 EB XBA $A6:D5F8 EB XBA $A6:D5F9 EA NOP $A6:D5FA EA NOP $A6:D5FB AD 14 42 LDA $4214 [$7E:4214] $A6:D5FE D0 01 BNE $01 [$D601] $A6:D600 1A INC A $A6:D601 85 16 STA $16 [$7E:0016] $A6:D603 BD AA 0F LDA $0FAA,x[$7E:0FAA] ; X speed (1/100 pixels) $A6:D606 30 09 BMI $09 [$D611] $A6:D608 38 SEC $A6:D609 E5 1A SBC $1A [$7E:001A] $A6:D60B 38 SEC $A6:D60C E9 08 00 SBC #$0008 $A6:D60F E5 16 SBC $16 [$7E:0016] $A6:D611 E5 16 SBC $16 [$7E:0016] $A6:D613 C9 00 FB CMP #$FB00 $A6:D616 10 03 BPL $03 [$D61B] $A6:D61B 9D AA 0F STA $0FAA,x[$7E:0FAA] ; X speed (1/100 pixels) $A6:D61E 60 RTS } ; Routine: Update Ridley's U Swoop speed and U Swoop angle, and calculate current X and Y speed { $A6:D800 A5 16 LDA $16 [$7E:0016] $A6:D802 CF 16 78 7E CMP $7E7816[$7E:7816] $A6:D806 F0 28 BEQ $28 [$D830] $A6:D808 10 14 BPL $14 [$D81E] $A6:D80A AF 16 78 7E LDA $7E7816[$7E:7816] $A6:D80E 38 SEC $A6:D80F E9 20 00 SBC #$0020 $A6:D812 C5 16 CMP $16 [$7E:0016] $A6:D814 10 02 BPL $02 [$D818] $A6:D818 8F 16 78 7E STA $7E7816[$7E:7816] $A6:D81C 80 12 BRA $12 [$D830] $A6:D81E AF 16 78 7E LDA $7E7816[$7E:7816] $A6:D822 18 CLC $A6:D823 69 20 00 ADC #$0020 $A6:D826 C5 16 CMP $16 [$7E:0016] $A6:D828 30 02 BMI $02 [$D82C] $A6:D82A A5 16 LDA $16 [$7E:0016] $A6:D82C 8F 16 78 7E STA $7E7816[$7E:7816] $A6:D830 A5 12 LDA $12 [$7E:0012] $A6:D832 30 0B BMI $0B [$D83F] $A6:D834 18 CLC $A6:D835 6F 14 78 7E ADC $7E7814[$7E:7814] ; Swoop angle (0 = down, increase moves counterclockwise, 1 loop = 10000) $A6:D839 C5 14 CMP $14 [$7E:0014] $A6:D83B 30 0D BMI $0D [$D84A] $A6:D83D 80 09 BRA $09 [$D848] $A6:D83F 18 CLC $A6:D840 6F 14 78 7E ADC $7E7814[$7E:7814] ; Swoop angle (0 = down, increase moves counterclockwise, 1 loop = 10000) $A6:D844 C5 14 CMP $14 [$7E:0014] $A6:D846 10 02 BPL $02 [$D84A] $A6:D848 A5 14 LDA $14 [$7E:0014] $A6:D84A 8F 14 78 7E STA $7E7814[$7E:7814] ; Swoop angle (0 = down, increase moves counterclockwise, 1 loop = 10000) $A6:D84E EB XBA $A6:D84F 29 FF 00 AND #$00FF $A6:D852 85 12 STA $12 [$7E:0012] $A6:D854 AF 16 78 7E LDA $7E7816[$7E:7816] $A6:D858 22 6C C2 86 JSL $86C26C[$86:C26C] ; Calculates A * sin ($12 * 360/256), result in A $A6:D85C 8D AA 0F STA $0FAA [$7E:0FAA] ; X speed (1/100 pixels) $A6:D85F AF 16 78 7E LDA $7E7816[$7E:7816] $A6:D863 22 72 C2 86 JSL $86C272[$86:C272] ; Calculates A * cos ($12 * 360/256), result in A $A6:D867 8D AC 0F STA $0FAC [$7E:0FAC] ; Y speed (1/100 pixels) $A6:D86A 60 RTS } ; Routine: Handles movement and main body wall collisions { $A6:D86B A9 00 00 LDA #$0000 $A6:D86E 8F 3E 78 7E STA $7E783E[$7E:783E] ; Wall collision. 0 = none, 1 = left, 2 = right, 4 = top, 8 = bottom. 4 and 8 take priority over 1 and 2 $A6:D872 AE 54 0E LDX $0E54 [$7E:0E54] $A6:D875 BD AA 0F LDA $0FAA,x[$7E:0FAA] ; X speed (1/100 pixels) $A6:D878 E2 20 SEP #$20 $A6:D87A 18 CLC $A6:D87B 7D 7D 0F ADC $0F7D,x[$7E:0F7D] $A6:D87E 9D 7D 0F STA $0F7D,x[$7E:0F7D] $A6:D881 C2 20 REP #$20 $A6:D883 29 00 FF AND #$FF00 $A6:D886 EB XBA $A6:D887 10 03 BPL $03 [$D88C] $A6:D889 09 00 FF ORA #$FF00 $A6:D88C 7D 7A 0F ADC $0F7A,x[$7E:0F7A] ; Ridley's X position $A6:D88F CF 04 80 7E CMP $7E8004[$7E:8004] $A6:D893 10 16 BPL $16 [$D8AB] $A6:D895 20 14 D9 JSR $D914 [$A6:D914] ; Cause room shaking, only happens in Ceres. Has unreachable code for Norfair room shaking $A6:D898 AF 04 80 7E LDA $7E8004[$7E:8004] $A6:D89C 9D 7A 0F STA $0F7A,x[$7E:0F7A] ; Ridley's X position $A6:D89F 9E AA 0F STZ $0FAA,x[$7E:0FAA] ; X speed (1/100 pixels) $A6:D8A2 A9 01 00 LDA #$0001 $A6:D8A5 8F 3E 78 7E STA $7E783E[$7E:783E] ; Wall collision. 0 = none, 1 = left, 2 = right, 4 = top, 8 = bottom. 4 and 8 take priority over 1 and 2 $A6:D8A9 80 17 BRA $17 [$D8C2] $A6:D8AB CF 06 80 7E CMP $7E8006[$7E:8006] $A6:D8AF 30 0E BMI $0E [$D8BF] $A6:D8B1 9E AA 0F STZ $0FAA,x[$7E:0FAA] ; X speed (1/100 pixels) $A6:D8B4 A9 02 00 LDA #$0002 $A6:D8B7 8F 3E 78 7E STA $7E783E[$7E:783E] ; Wall collision. 0 = none, 1 = left, 2 = right, 4 = top, 8 = bottom. 4 and 8 take priority over 1 and 2 $A6:D8BB AF 06 80 7E LDA $7E8006[$7E:8006] $A6:D8BF 9D 7A 0F STA $0F7A,x[$7E:0F7A] ; Ridley's X position $A6:D8C2 BD AC 0F LDA $0FAC,x[$7E:0FAC] ; Y speed (1/100 pixels) $A6:D8C5 E2 20 SEP #$20 $A6:D8C7 18 CLC $A6:D8C8 7D 81 0F ADC $0F81,x[$7E:0F81] $A6:D8CB 9D 81 0F STA $0F81,x[$7E:0F81] $A6:D8CE C2 20 REP #$20 $A6:D8D0 29 00 FF AND #$FF00 $A6:D8D3 EB XBA $A6:D8D4 10 03 BPL $03 [$D8D9] $A6:D8D6 09 00 FF ORA #$FF00 $A6:D8D9 7D 7E 0F ADC $0F7E,x[$7E:0F7E] ; Ridley's Y position $A6:D8DC CF 00 80 7E CMP $7E8000[$7E:8000] $A6:D8E0 10 16 BPL $16 [$D8F8] $A6:D8E2 AF 00 80 7E LDA $7E8000[$7E:8000] $A6:D8E6 9D 7E 0F STA $0F7E,x[$7E:0F7E] ; Ridley's Y position $A6:D8E9 9E AC 0F STZ $0FAC,x[$7E:0FAC] ; Y speed (1/100 pixels) $A6:D8EC AF 3E 78 7E LDA $7E783E[$7E:783E] ; Wall collision. 0 = none, 1 = left, 2 = right, 4 = top, 8 = bottom. 4 and 8 take priority over 1 and 2 $A6:D8F0 A9 04 00 LDA #$0004 $A6:D8F3 8F 3E 78 7E STA $7E783E[$7E:783E] ; Wall collision. 0 = none, 1 = left, 2 = right, 4 = top, 8 = bottom. 4 and 8 take priority over 1 and 2 $A6:D8F7 60 RTS $A6:D8F8 CF 02 80 7E CMP $7E8002[$7E:8002] $A6:D8FC 30 12 BMI $12 [$D910] $A6:D910 9D 7E 0F STA $0F7E,x[$7E:0F7E] ; Ridley's Y position $A6:D913 60 RTS } ; Routine (Ceres only): Cause room shaking, only happens in Ceres. Has unreachable code for Norfair room shaking { $A6:D914 AD 9F 07 LDA $079F [$7E:079F] ; Region number (2 = Norfair) $A6:D917 C9 02 00 CMP #$0002 $A6:D91A F0 38 BEQ $38 [$D954] $A6:D954 60 RTS } ; Routine: Turn around if facing away from the center of the room (facing a wall) { $A6:D955 AF 20 78 7E LDA $7E7820[$7E:7820] ; Ridley's direction (0 = left, 2 = right) $A6:D959 F0 0D BEQ $0D [$D968] $A6:D95B 3A DEC A $A6:D95C F0 1E BEQ $1E [$D97C] $A6:D95E AD 79 0F LDA $0F79 [$7E:0F79] $A6:D961 10 19 BPL $19 [$D97C] $A6:D963 A9 06 E7 LDA #$E706 ; Turn from right to left $A6:D966 80 08 BRA $08 [$D970] $A6:D968 AD 79 0F LDA $0F79 [$7E:0F79] $A6:D96B 30 0F BMI $0F [$D97C] $A6:D96D A9 F0 E6 LDA #$E6F0 ; Turn from left to right $A6:D970 8D 92 0F STA $0F92 [$7E:0F92] ; PLM instructions $A6:D973 A9 02 00 LDA #$0002 $A6:D976 8D 94 0F STA $0F94 [$7E:0F94] $A6:D979 9C 90 0F STZ $0F90 [$7E:0F90] $A6:D97C 60 RTS } ; Routine: Handle wing flapping { $A6:D97D 20 A8 D9 JSR $D9A8 [$A6:D9A8] ; Calculate wing flap speed $A6:D980 AF 12 78 7E LDA $7E7812[$7E:7812] ; Wing flap counter $A6:D984 38 SEC $A6:D985 EF 10 78 7E SBC $7E7810[$7E:7810] ; Wing flap speed $A6:D989 8F 12 78 7E STA $7E7812[$7E:7812] ; Wing flap counter $A6:D98D 10 18 BPL $18 [$D9A7] $A6:D98F A9 20 00 LDA #$0020 $A6:D992 8F 12 78 7E STA $7E7812[$7E:7812] ; Wing flap counter $A6:D996 AF 0E 78 7E LDA $7E780E[$7E:780E] $A6:D99A 1A INC A $A6:D99B C9 0A 00 CMP #$000A $A6:D99E 90 03 BCC $03 [$D9A3] $A6:D9A0 A9 00 00 LDA #$0000 $A6:D9A3 8F 0E 78 7E STA $7E780E[$7E:780E] $A6:D9A7 60 RTS } ; Routine: Calculate wing flap speed { $A6:D9A8 AD AA 0F LDA $0FAA [$7E:0FAA] ; X speed (1/100 pixels) $A6:D9AB 10 04 BPL $04 [$D9B1] $A6:D9AD 49 FF FF EOR #$FFFF $A6:D9B0 1A INC A $A6:D9B1 85 12 STA $12 [$7E:0012] $A6:D9B3 AD AC 0F LDA $0FAC [$7E:0FAC] ; Y speed (1/100 pixels) $A6:D9B6 10 04 BPL $04 [$D9BC] $A6:D9B8 49 FF FF EOR #$FFFF $A6:D9BB 1A INC A $A6:D9BC 18 CLC $A6:D9BD 65 12 ADC $12 [$7E:0012] $A6:D9BF D0 05 BNE $05 [$D9C6] $A6:D9C1 8F 10 78 7E STA $7E7810[$7E:7810] ; Wing flap speed $A6:D9C5 60 RTS $A6:D9C6 38 SEC $A6:D9C7 E5 12 SBC $12 [$7E:0012] $A6:D9C9 C5 12 CMP $12 [$7E:0012] $A6:D9CB 10 02 BPL $02 [$D9CF] $A6:D9CD A5 12 LDA $12 [$7E:0012] $A6:D9CF 0A ASL A $A6:D9D0 0A ASL A $A6:D9D1 29 00 0F AND #$0F00 $A6:D9D4 EB XBA $A6:D9D5 0A ASL A $A6:D9D6 C9 0E 00 CMP #$000E $A6:D9D9 90 03 BCC $03 [$D9DE] $A6:D9DB A9 0E 00 LDA #$000E $A6:D9DE AA TAX $A6:D9DF BD ED D9 LDA $D9ED,x[$A6:D9F7] $A6:D9E2 2C AC 0F BIT $0FAC [$7E:0FAC] ; Y speed (1/100 pixels) $A6:D9E5 30 01 BMI $01 [$D9E8] $A6:D9E7 4A LSR A $A6:D9E8 8F 10 78 7E STA $7E7810[$7E:7810] ; Wing flap speed $A6:D9EC 60 RTS $A6:D9ED db 0C, 00, 0E, 00, 10, 00, 12, 00, 1C, 00, 20, 00, 28, 00, 30, 00 } ; Routine: Store DA71 to 7E:780A, 1 to 7E:780C. Has to do with Ridley's ribs? { $A6:D9FD A9 71 DA LDA #$DA71 $A6:DA00 8F 0A 78 7E STA $7E780A[$7E:780A] $A6:DA04 A9 01 00 LDA #$0001 $A6:DA07 8F 0C 78 7E STA $7E780C[$7E:780C] $A6:DA0B 60 RTS } ; Routine: Checks if Ridley is on screen { $A6:DE7A AD 7E 0F LDA $0F7E [$7E:0F7E] ; Ridley's Y position $A6:DE7D 30 25 BMI $25 [$DEA4] $A6:DE7F 18 CLC $A6:DE80 69 20 00 ADC #$0020 $A6:DE83 38 SEC $A6:DE84 ED 15 09 SBC $0915 [$7E:0915] $A6:DE87 30 1B BMI $1B [$DEA4] $A6:DE89 C9 20 01 CMP #$0120 $A6:DE8C 10 16 BPL $16 [$DEA4] $A6:DE8E AD 7A 0F LDA $0F7A [$7E:0F7A] ; Ridley's X position $A6:DE91 30 11 BMI $11 [$DEA4] $A6:DE93 18 CLC $A6:DE94 69 20 00 ADC #$0020 $A6:DE97 38 SEC $A6:DE98 ED 11 09 SBC $0911 [$7E:0911] $A6:DE9B 30 07 BMI $07 [$DEA4] $A6:DE9D C9 40 01 CMP #$0140 $A6:DEA0 10 02 BPL $02 [$DEA4] $A6:DEA2 18 CLC $A6:DEA3 60 RTS $A6:DEA4 38 SEC $A6:DEA5 60 RTS } ; Routine: Check Tail/Projectile collisions { $A6:DEA6 AD CE 0C LDA $0CCE [$7E:0CCE] $A6:DEA9 D0 02 BNE $02 [$DEAD] $A6:DEAB 18 CLC $A6:DEAC 60 RTS $A6:DEAD A0 00 00 LDY #$0000 $A6:DEB0 B9 18 0C LDA $0C18,y[$7E:0C18] $A6:DEB3 10 35 BPL $35 [$DEEA] $A6:DEB5 EB XBA $A6:DEB6 29 0F 00 AND #$000F $A6:DEB9 C9 03 00 CMP #$0003 $A6:DEBC 10 2C BPL $2C [$DEEA] $A6:DEBE B9 64 0B LDA $0B64,y[$7E:0B64] $A6:DEC1 38 SEC $A6:DEC2 E5 12 SBC $12 [$7E:0012] $A6:DEC4 10 04 BPL $04 [$DECA] $A6:DEC6 49 FF FF EOR #$FFFF $A6:DEC9 1A INC A $A6:DECA 38 SEC $A6:DECB F9 B4 0B SBC $0BB4,y[$7E:0BB4] $A6:DECE 90 04 BCC $04 [$DED4] $A6:DED0 C5 16 CMP $16 [$7E:0016] $A6:DED2 B0 16 BCS $16 [$DEEA] $A6:DED4 B9 78 0B LDA $0B78,y[$7E:0B78] $A6:DED7 38 SEC $A6:DED8 E5 14 SBC $14 [$7E:0014] $A6:DEDA 10 04 BPL $04 [$DEE0] $A6:DEDC 49 FF FF EOR #$FFFF $A6:DEDF 1A INC A $A6:DEE0 38 SEC $A6:DEE1 F9 C8 0B SBC $0BC8,y[$7E:0BC8] $A6:DEE4 90 0D BCC $0D [$DEF3] $A6:DEE6 C5 18 CMP $18 [$7E:0018] $A6:DEE8 90 09 BCC $09 [$DEF3] $A6:DEEA C8 INY $A6:DEEB C8 INY $A6:DEEC C0 0A 00 CPY #$000A $A6:DEEF 30 BF BMI $BF [$DEB0] $A6:DEF1 18 CLC $A6:DEF2 60 RTS $A6:DEF3 A5 12 LDA $12 [$7E:0012] $A6:DEF5 99 64 0B STA $0B64,y[$7E:0B64] $A6:DEF8 A5 14 LDA $14 [$7E:0014] $A6:DEFA 99 78 0B STA $0B78,y[$7E:0B78] $A6:DEFD B9 04 0C LDA $0C04,y[$7E:0C04] $A6:DF00 09 10 00 ORA #$0010 $A6:DF03 99 04 0C STA $0C04,y[$7E:0C04] $A6:DF06 38 SEC $A6:DF07 60 RTS } ; Routine: Efficient collision detection for Samus and $12/$14 (size of $12/$14 is $16/$18). SEC if collision { $A6:DF29 AD F6 0A LDA $0AF6 [$7E:0AF6] ; Samus' X position $A6:DF2C 38 SEC $A6:DF2D E5 12 SBC $12 [$7E:0012] $A6:DF2F 10 04 BPL $04 [$DF35] $A6:DF31 49 FF FF EOR #$FFFF $A6:DF34 1A INC A $A6:DF35 38 SEC $A6:DF36 ED FE 0A SBC $0AFE [$7E:0AFE] $A6:DF39 90 04 BCC $04 [$DF3F] $A6:DF3B C5 16 CMP $16 [$7E:0016] $A6:DF3D B0 16 BCS $16 [$DF55] $A6:DF3F AD FA 0A LDA $0AFA [$7E:0AFA] ; Samus' Y position $A6:DF42 38 SEC $A6:DF43 E5 14 SBC $14 [$7E:0014] $A6:DF45 10 04 BPL $04 [$DF4B] $A6:DF47 49 FF FF EOR #$FFFF $A6:DF4A 1A INC A $A6:DF4B 38 SEC $A6:DF4C ED 00 0B SBC $0B00 [$7E:0B00] $A6:DF4F 90 06 BCC $06 [$DF57] $A6:DF51 C5 18 CMP $18 [$7E:0018] $A6:DF53 90 02 BCC $02 [$DF57] $A6:DF55 18 CLC $A6:DF56 60 RTS $A6:DF57 38 SEC $A6:DF58 60 RTS } ; Routine: Check if Ridley should die { $A6:DFB7 AD 8C 0F LDA $0F8C [$7E:0F8C] ; Ridley's HP $A6:DFBA D0 1C BNE $1C [$DFD8] $A6:DFBC AF 02 78 7E LDA $7E7802[$7E:7802] $A6:DFC0 30 16 BMI $16 [$DFD8] $A6:DFC2 A9 FF FF LDA #$FFFF $A6:DFC5 8F 02 78 7E STA $7E7802[$7E:7802] $A6:DFC9 AD 86 0F LDA $0F86 [$7E:0F86] ; Property bits of Ridley $A6:DFCC 09 00 04 ORA #$0400 $A6:DFCF 8D 86 0F STA $0F86 [$7E:0F86] ; Property bits of Ridley $A6:DFD2 A9 38 C5 LDA #$C538 ; Move Ridley to 80,148 to die $A6:DFD5 8D A8 0F STA $0FA8 [$7E:0FA8] $A6:DFD8 6B RTL }