; AI Script: Clear speed & do nothing? { $A6:A354 9C AA 0F STZ $0FAA [$7E:0FAA] ; X speed (1/100 pixels) $A6:A357 9C AC 0F STZ $0FAC [$7E:0FAC] ; Y speed (1/100 pixels) $A6:A35A 60 RTS } ; AI Script: Startup, 1st run { $A6:A35B AD 97 07 LDA $0797 [$7E:0797] ; Room transition flag $A6:A35E D0 28 BNE $28 [$A388] ; RTS $A6:A360 A9 77 A3 LDA #$A377 ; Startup, initial wait $A6:A363 8D A8 0F STA $0FA8 [$7E:0FA8] ; Set counter to 0x200 if Norfair, 0xAA if Ceres { $A6:A366 A9 00 02 LDA #$0200 $A6:A369 AC 9F 07 LDY $079F [$7E:079F] ; Region number (2 = Norfair) $A6:A36C C0 02 00 CPY #$0002 $A6:A36F D0 03 BNE $03 [$A374] $A6:A371 A9 AA 00 LDA #$00AA $A6:A374 8D B2 0F STA $0FB2 [$7E:0FB2] ; Counter } ; AI Script: Startup, initial wait { $A6:A377 CE B2 0F DEC $0FB2 [$7E:0FB2] ; Counter $A6:A37A 10 0C BPL $0C [$A388] ; RTS $A6:A37C A9 89 A3 LDA #$A389 ; Startup, eyes appear $A6:A37F 8D A8 0F STA $0FA8 [$7E:0FA8] $A6:A382 9C B0 0F STZ $0FB0 [$7E:0FB0] ; Index during init $A6:A385 9C B2 0F STZ $0FB2 [$7E:0FB2] ; Counter $A6:A388 60 RTS } } ; AI Scrip: Startup, eyes appear { $A6:A389 AD B0 0F LDA $0FB0 [$7E:0FB0] ; Index during init $A6:A38C 30 3F BMI $3F [$A3CD] $A6:A38E A8 TAY $A6:A38F EE B2 0F INC $0FB2 [$7E:0FB2] ; Counter $A6:A392 AD B2 0F LDA $0FB2 [$7E:0FB2] ; Counter $A6:A395 C9 01 00 CMP #$0001 $A6:A398 90 33 BCC $33 [$A3CD] ; RTS $A6:A39A 9C B2 0F STZ $0FB2 [$7E:0FB2] ; Counter $A6:A39D BB TYX $A6:A39E BD 69 E2 LDA $E269,x[$A6:E269] ; 1 byte values from F to 0 (10 values), then 30 more 00's, and finally an FF (41 values total) $A6:A3A1 29 FF 00 AND #$00FF $A6:A3A4 C9 FF 00 CMP #$00FF $A6:A3A7 F0 25 BEQ $25 [$A3CE] $A6:A3A9 85 12 STA $12 [$7E:0012] $A6:A3AB 0A ASL A $A6:A3AC 18 CLC $A6:A3AD 65 12 ADC $12 [$7E:0012] $A6:A3AF 0A ASL A $A6:A3B0 A8 TAY $A6:A3B1 E8 INX $A6:A3B2 8E B0 0F STX $0FB0 [$7E:0FB0] ; Index during init $A6:A3B5 A2 F8 01 LDX #$01F8 $A6:A3B8 B9 AA E2 LDA $E2AA,y[$A6:E304] $A6:A3BB 9F 00 C0 7E STA $7EC000,x[$7E:C1F8] $A6:A3BF B9 AC E2 LDA $E2AC,y[$A6:E306] $A6:A3C2 9F 02 C0 7E STA $7EC002,x[$7E:C1FA] $A6:A3C6 B9 AE E2 LDA $E2AE,y[$A6:E308] $A6:A3C9 9F 04 C0 7E STA $7EC004,x[$7E:C1FC] $A6:A3CD 60 RTS ; Run at the very end { $A6:A3CE 9C B0 0F STZ $0FB0 [$7E:0FB0] ; Index during init $A6:A3D1 A9 DF A3 LDA #$A3DF ; Startup, main body appears $A6:A3D4 8D A8 0F STA $0FA8 [$7E:0FA8] $A6:A3D7 A9 01 00 LDA #$0001 $A6:A3DA 8F 04 78 7E STA $7E7804[$7E:7804] ; Set if Ridley is active $A6:A3DE 60 RTS } } ; AI Script: Startup, main body appears { $A6:A3DF EE B2 0F INC $0FB2 [$7E:0FB2] ; Counter $A6:A3E2 AD B2 0F LDA $0FB2 [$7E:0FB2] ; Counter $A6:A3E5 C9 02 00 CMP #$0002 $A6:A3E8 90 39 BCC $39 [$A423] ; RTS $A6:A3EA 9C B2 0F STZ $0FB2 [$7E:0FB2] ; Counter $A6:A3ED AC B0 0F LDY $0FB0 [$7E:0FB0] ; Index during init $A6:A3F0 A9 22 01 LDA #$0122 $A6:A3F3 85 12 STA $12 [$7E:0012] $A6:A3F5 A9 E2 01 LDA #$01E2 $A6:A3F8 85 14 STA $14 [$7E:0014] $A6:A3FA A9 0B 00 LDA #$000B ; Loop { $A6:A3FD 48 PHA $A6:A3FE B9 0A E3 LDA $E30A,y[$A6:E30A] $A6:A401 A6 12 LDX $12 [$7E:0012] $A6:A403 9F 00 C0 7E STA $7EC000,x[$7E:C122] $A6:A407 A6 14 LDX $14 [$7E:0014] $A6:A409 9F 00 C0 7E STA $7EC000,x[$7E:C1E2] $A6:A40D C8 INY $A6:A40E C8 INY $A6:A40F E6 12 INC $12 [$7E:0012] $A6:A411 E6 12 INC $12 [$7E:0012] $A6:A413 E6 14 INC $14 [$7E:0014] $A6:A415 E6 14 INC $14 [$7E:0014] $A6:A417 68 PLA $A6:A418 3A DEC A $A6:A419 D0 E2 BNE $E2 [$A3FD] } $A6:A41B C0 60 01 CPY #$0160 $A6:A41E B0 04 BCS $04 [$A424] $A6:A420 8C B0 0F STY $0FB0 [$7E:0FB0] ; Index during init $A6:A423 60 RTS ; Run at the end { $A6:A424 AD 9F 07 LDA $079F [$7E:079F] ; Region number (2 = Norfair) $A6:A427 C9 02 00 CMP #$0002 $A6:A42A D0 06 BNE $06 [$A432] ; Norfair only { $A6:A42C A9 02 00 LDA #$0002 $A6:A42F 8D 9A 0F STA $0F9A [$7E:0F9A] } $A6:A432 AD 86 0F LDA $0F86 [$7E:0F86] ; Property bits of Ridley $A6:A435 29 FF FB AND #$FBFF $A6:A438 8D 86 0F STA $0F86 [$7E:0F86] ; Property bits of Ridley $A6:A43B A0 00 00 LDY #$0000 $A6:A43E 8C B0 0F STY $0FB0 [$7E:0FB0] ; Index during init $A6:A441 A9 55 A4 LDA #$A455 ; Startup, Ridley roars $A6:A444 8D A8 0F STA $0FA8 [$7E:0FA8] $A6:A447 A9 04 00 LDA #$0004 $A6:A44A 8D B2 0F STA $0FB2 [$7E:0FB2] ; Counter $A6:A44D A9 05 00 LDA #$0005 ; \ $A6:A450 22 C1 8F 80 JSL $808FC1[$80:8FC1] ; } Queue song 0 music track $A6:A454 60 RTS } } ; AI Script: Startup, Ridley Roars { $A6:A455 CE B2 0F DEC $0FB2 [$7E:0FB2] ; Counter $A6:A458 10 1D BPL $1D [$A477] ; RTS $A6:A45A A9 90 E6 LDA #$E690 ; Ridley roars $A6:A45D 20 67 D4 JSR $D467 [$A6:D467] ; Set PLM instruction? $A6:A460 9C B2 0F STZ $0FB2 [$7E:0FB2] ; Counter $A6:A463 A9 78 A4 LDA #$A478 ; Starup, color background in Norfair/Start AI $A6:A466 8D A8 0F STA $0FA8 [$7E:0FA8] $A6:A469 AD 9F 07 LDA $079F [$7E:079F] ; Region number (2 = Norfair) $A6:A46C C9 02 00 CMP #$0002 $A6:A46F F0 06 BEQ $06 [$A477] ; Ceres only { $A6:A471 A9 FC 00 LDA #$00FC $A6:A474 8D B2 0F STA $0FB2 [$7E:0FB2] ; Counter } $A6:A477 60 RTS } ; AI Script: Startup, color background in Norfair/Start AI { $A6:A478 AD 9F 07 LDA $079F [$7E:079F] ; Region number (2 = Norfair) $A6:A47B C9 02 00 CMP #$0002 $A6:A47E D0 2C BNE $2C [$A4AC] ; Norfair only { $A6:A480 CE B2 0F DEC $0FB2 [$7E:0FB2] ; Counter $A6:A483 10 F2 BPL $F2 [$A477] ; Runs at end { $A6:A485 A9 02 00 LDA #$0002 $A6:A488 8D B2 0F STA $0FB2 [$7E:0FB2] ; Counter $A6:A48B AD B0 0F LDA $0FB0 [$7E:0FB0] ; Index during init $A6:A48E 1A INC A $A6:A48F 8D B0 0F STA $0FB0 [$7E:0FB0] ; Index during init $A6:A492 3A DEC A $A6:A493 20 D6 A4 JSR $A4D6 [$A6:A4D6] ; Adjust background colors if neccessary $A6:A496 90 DF BCC $DF [$A477] $A6:A498 A9 B8 01 LDA #$01B8 $A6:A49B 8D 7A 19 STA $197A [$7E:197A] ; Lava height $A6:A49E A9 A0 FF LDA #$FFA0 $A6:A4A1 8D 7C 19 STA $197C [$7E:197C] ; Lava speed $A6:A4A4 A9 20 00 LDA #$0020 $A6:A4A7 8D 80 19 STA $1980 [$7E:1980] $A6:A4AA 80 05 BRA $05 [$A4B1] } } $A6:A4AC CE B2 0F DEC $0FB2 [$7E:0FB2] ; Counter $A6:A4AF 10 C6 BPL $C6 [$A477] ; RTS ; Runs at the end { $A6:A4B1 9C B0 0F STZ $0FB0 [$7E:0FB0] ; Index during init $A6:A4B4 A9 1D E9 LDA #$E91D ; Fly up & start main AI? $A6:A4B7 20 67 D4 JSR $D467 [$A6:D467] ; Set PLM instruction? $A6:A4BA A9 08 00 LDA #$0008 $A6:A4BD 8F 10 78 7E STA $7E7810[$7E:7810] ; Wing flap speed $A6:A4C1 8F 12 78 7E STA $7E7812[$7E:7812] ; Wing flap counter $A6:A4C5 20 D9 D3 JSR $D3D9 [$A6:D3D9] ; Set all tail parts to moving $A6:A4C8 A9 01 00 LDA #$0001 $A6:A4CB 8F 00 20 7E STA $7E2000[$7E:2000] ; Tail control index $A6:A4CF A9 54 A3 LDA #$A354 ; Clear speed & do nothing? $A6:A4D2 8D A8 0F STA $0FA8 [$7E:0FA8] $A6:A4D5 60 RTS } } ; AI Script: Startup liftoff, facing right { ; Run until collided with [$40, $100] { $A6:B2F3 A2 40 00 LDX #$0040 $A6:B2F6 A0 00 01 LDY #$0100 $A6:B2F9 86 12 STX $12 [$7E:0012] $A6:B2FB 84 14 STY $14 [$7E:0014] $A6:B2FD A2 00 00 LDX #$0000 $A6:B300 A0 0E 00 LDY #$000E $A6:B303 20 23 D5 JSR $D523 [$A6: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:B306 A9 08 00 LDA #$0008 $A6:B309 85 16 STA $16 [$7E:0016] $A6:B30B 85 18 STA $18 [$7E:0018] $A6:B30D 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:B311 90 01 BCC $01 [$B314] $A6:B313 60 RTS } ; Run once we collide with [$40, $100] { $A6:B314 A9 01 00 LDA #$0001 $A6:B317 8F 02 78 7E STA $7E7802[$7E:7802] $A6:B31B A9 21 B3 LDA #$B321 ; Get next AI $A6:B31E 8D A8 0F STA $0FA8 [$7E:0FA8] } } ; AI Script: Get next AI { $A6:B321 20 35 B3 JSR $B335 [$A6:B335] ; Get new AI script $A6:B324 22 11 81 80 JSL $808111[$80:8111] $A6:B328 29 07 00 AND #$0007 $A6:B32B 0A ASL A $A6:B32C A8 TAY $A6:B32D B1 12 LDA ($12),y[$A6:B3C8] $A6:B32F 8D A8 0F STA $0FA8 [$7E:0FA8] $A6:B332 6C A8 0F JMP ($0FA8)[$A6:B6A7] } ; AI Script: Initialize movement towards center { $A6:B3EC A9 F8 B3 LDA #$B3F8 ; Move to center side $A6:B3EF 8D A8 0F STA $0FA8 [$7E:0FA8] $A6:B3F2 A9 80 00 LDA #$0080 $A6:B3F5 8D B2 0F STA $0FB2 [$7E:0FB2] ; Counter } ; AI Script: Move to center side { $A6:B3F8 CE B2 0F DEC $0FB2 [$7E:0FB2] ; Counter $A6:B3FB 30 2A BMI $2A [$B427] ; Runs every frame { $A6:B3FD A2 C0 00 LDX #$00C0 $A6:B400 AF 20 78 7E LDA $7E7820[$7E:7820] ; Ridley's direction (0 = left, 2 = right) $A6:B404 F0 03 BEQ $03 [$B409] $A6:B406 A2 60 00 LDX #$0060 $A6:B409 86 12 STX $12 [$7E:0012] ; 0xC0 if left, 0x60 if right $A6:B40B A0 00 01 LDY #$0100 $A6:B40E 84 14 STY $14 [$7E:0014] $A6:B410 20 2E B4 JSR $B42E [$A6:B42E] ; Set A+Y=[4, 8, A, C] depending on General Speed Byte $A6:B413 A2 00 00 LDX #$0000 $A6:B416 20 23 D5 JSR $D523 [$A6: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:B419 A9 08 00 LDA #$0008 $A6:B41C 85 16 STA $16 [$7E:0016] $A6:B41E 85 18 STA $18 [$7E:0018] $A6:B420 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:B424 90 01 BCC $01 [$B427] $A6:B426 60 RTS } ; Runs at the end, or if Ridley reached his position { $A6:B427 A9 21 B3 LDA #$B321 ; Get next AI $A6:B42A 8D A8 0F STA $0FA8 [$7E:0FA8] $A6:B42D 60 RTS } } ; AI Script: Swoop { $A6:B441 A9 55 B4 LDA #$B455 $A6:B444 8D A8 0F STA $0FA8 [$7E:0FA8] $A6:B447 A9 0A 00 LDA #$000A $A6:B44A 8F 00 78 7E STA $7E7800[$7E:7800] ; Swoop timer $A6:B44E A9 00 00 LDA #$0000 $A6:B451 8F 14 78 7E STA $7E7814[$7E:7814] ; Swoop angle (0 = down, increase moves counterclockwise, 1 loop = 10000) } ; AI Script: Fly to Swoop start { ; X = 0xC0 if left, 0x40 if right $A6:B455 A2 C0 00 LDX #$00C0 $A6:B458 AF 20 78 7E LDA $7E7820[$7E:7820] ; Ridley's direction (0 = left, 2 = right) $A6:B45C F0 03 BEQ $03 [$B461] $A6:B45E A2 40 00 LDX #$0040 $A6:B461 86 12 STX $12 [$7E:0012] $A6:B463 A0 80 00 LDY #$0080 $A6:B466 84 14 STY $14 [$7E:0014] $A6:B468 A2 00 00 LDX #$0000 $A6:B46B A0 01 00 LDY #$0001 $A6:B46E 20 23 D5 JSR $D523 [$A6: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:B471 A9 08 00 LDA #$0008 $A6:B474 85 16 STA $16 [$7E:0016] $A6:B476 85 18 STA $18 [$7E:0018] $A6:B478 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:B47C B0 14 BCS $14 [$B492] ; If we collided { $A6:B47E A9 93 B4 LDA #$B493 ; Swoop, first dive $A6:B481 8D A8 0F STA $0FA8 [$7E:0FA8] $A6:B484 A9 20 00 LDA #$0020 $A6:B487 8F 00 78 7E STA $7E7800[$7E:7800] ; Swoop timer $A6:B48B A9 00 00 LDA #$0000 $A6:B48E 8F 14 78 7E STA $7E7814[$7E:7814] ; Swoop angle (0 = down, increase moves counterclockwise, 1 loop = 10000) } $A6:B492 60 RTS } ; AI Script: Swoop, first dive { $A6:B493 AF 20 78 7E LDA $7E7820[$7E:7820] ; Ridley's direction (0 = left, 2 = right) $A6:B497 D0 0C BNE $0C [$B4A5] ; If facing left { $A6:B499 A9 E0 FF LDA #$FFE0 $A6:B49C 85 12 STA $12 [$7E:0012] $A6:B49E A9 00 FE LDA #$FE00 $A6:B4A1 85 14 STA $14 [$7E:0014] $A6:B4A3 80 0A BRA $0A [$B4AF] } ; Else if facing right { $A6:B4A5 A9 20 00 LDA #$0020 $A6:B4A8 85 12 STA $12 [$7E:0012] $A6:B4AA A9 00 02 LDA #$0200 $A6:B4AD 85 14 STA $14 [$7E:0014] } $A6:B4AF A9 80 04 LDA #$0480 $A6:B4B2 85 16 STA $16 [$7E:0016] $A6:B4B4 20 00 D8 JSR $D800 [$A6:D800] ; Update Ridley's U Swoop speed and U Swoop angle, and calculate current X and Y speed $A6:B4B7 AF 00 78 7E LDA $7E7800[$7E:7800] ; Swoop timer $A6:B4BB F0 06 BEQ $06 [$B4C3] ; Run every frame { $A6:B4BD 3A DEC A $A6:B4BE 8F 00 78 7E STA $7E7800[$7E:7800] ; Swoop timer $A6:B4C2 60 RTS } ; Run at end { $A6:B4C3 A9 D1 B4 LDA #$B4D1 ; Swoop, dive to halfpoint $A6:B4C6 8D A8 0F STA $0FA8 [$7E:0FA8] $A6:B4C9 A9 14 00 LDA #$0014 $A6:B4CC 8F 00 78 7E STA $7E7800[$7E:7800] ; Swoop timer $A6:B4D0 60 RTS } } ; AI Script: Swoop, dive to halfpoint { $A6:B4D1 AF 20 78 7E LDA $7E7820[$7E:7820] ; Ridley's direction (0 = left, 2 = right) $A6:B4D5 D0 0C BNE $0C [$B4E3] ; If facing left { $A6:B4D7 A9 C0 FE LDA #$FEC0 $A6:B4DA 85 12 STA $12 [$7E:0012] $A6:B4DC A9 00 C0 LDA #$C000 $A6:B4DF 85 14 STA $14 [$7E:0014] $A6:B4E1 80 0A BRA $0A [$B4ED] } ; Else if facing right { $A6:B4E3 A9 40 01 LDA #$0140 $A6:B4E6 85 12 STA $12 [$7E:0012] $A6:B4E8 A9 00 40 LDA #$4000 $A6:B4EB 85 14 STA $14 [$7E:0014] } $A6:B4ED A9 00 05 LDA #$0500 $A6:B4F0 85 16 STA $16 [$7E:0016] $A6:B4F2 20 00 D8 JSR $D800 [$A6:D800] ; Update Ridley's U Swoop speed and U Swoop angle, and calculate current X and Y speed $A6:B4F5 AF 00 78 7E LDA $7E7800[$7E:7800] ; Swoop timer $A6:B4F9 F0 06 BEQ $06 [$B501] ; Run every frame { $A6:B4FB 3A DEC A $A6:B4FC 8F 00 78 7E STA $7E7800[$7E:7800] ; Swoop timer $A6:B500 60 RTS } ; Run at end { $A6:B501 A9 16 B5 LDA #$B516 ; Swoop, climb after halfpoint $A6:B504 8D A8 0F STA $0FA8 [$7E:0FA8] $A6:B507 A9 10 00 LDA #$0010 $A6:B50A 8F 00 78 7E STA $7E7800[$7E:7800] ; Swoop timer $A6:B50E A9 01 00 LDA #$0001 $A6:B511 8F 04 20 7E STA $7E2004[$7E:2004] ; Tail fling trigger $A6:B515 60 RTS } } ; AI Script: Swoop, climb after halfpoint { $A6:B516 AF 20 78 7E LDA $7E7820[$7E:7820] ; Ridley's direction (0 = left, 2 = right) $A6:B51A D0 0C BNE $0C [$B528] ; If left { $A6:B51C A9 00 FE LDA #$FE00 $A6:B51F 85 12 STA $12 [$7E:0012] $A6:B521 A9 00 88 LDA #$8800 $A6:B524 85 14 STA $14 [$7E:0014] $A6:B526 80 0A BRA $0A [$B532] } ; Else if right { $A6:B528 A9 00 02 LDA #$0200 $A6:B52B 85 12 STA $12 [$7E:0012] $A6:B52D A9 00 78 LDA #$7800 $A6:B530 85 14 STA $14 [$7E:0014] } $A6:B532 A9 00 03 LDA #$0300 $A6:B535 85 16 STA $16 [$7E:0016] $A6:B537 20 00 D8 JSR $D800 [$A6:D800] ; Update Ridley's U Swoop speed and U Swoop angle, and calculate current X and Y speed $A6:B53A AF 00 78 7E LDA $7E7800[$7E:7800] ; Swoop timer $A6:B53E F0 06 BEQ $06 [$B546] ; Run every frame { $A6:B540 3A DEC A $A6:B541 8F 00 78 7E STA $7E7800[$7E:7800] ; Swoop timer $A6:B545 60 RTS } ; Run at end { $A6:B546 A9 54 B5 LDA #$B554 ; Swoop, still climbing $A6:B549 8D A8 0F STA $0FA8 [$7E:0FA8] $A6:B54C A9 20 00 LDA #$0020 $A6:B54F 8F 00 78 7E STA $7E7800[$7E:7800] ; Swoop timer $A6:B553 60 RTS } } ; AI Script: Swoop, still climbing { $A6:B554 AF 20 78 7E LDA $7E7820[$7E:7820] ; Ridley's direction (0 = left, 2 = right) $A6:B558 D0 0C BNE $0C [$B566] ; If left { $A6:B55A A9 00 FC LDA #$FC00 $A6:B55D 85 12 STA $12 [$7E:0012] $A6:B55F A9 00 88 LDA #$8800 $A6:B562 85 14 STA $14 [$7E:0014] $A6:B564 80 0A BRA $0A [$B570] } ; Else if right { $A6:B566 A9 00 04 LDA #$0400 $A6:B569 85 12 STA $12 [$7E:0012] $A6:B56B A9 00 78 LDA #$7800 $A6:B56E 85 14 STA $14 [$7E:0014] } $A6:B570 A9 00 03 LDA #$0300 $A6:B573 85 16 STA $16 [$7E:0016] $A6:B575 20 00 D8 JSR $D800 [$A6:D800] ; Update Ridley's U Swoop speed and U Swoop angle, and calculate current X and Y speed $A6:B578 AF 00 78 7E LDA $7E7800[$7E:7800] ; Swoop timer $A6:B57C F0 06 BEQ $06 [$B584] ; Run every frame { $A6:B57E 3A DEC A $A6:B57F 8F 00 78 7E STA $7E7800[$7E:7800] ; Swoop timer $A6:B583 60 RTS } ; Run at end { $A6:B584 A9 94 B5 LDA #$B594 ; Swoop end $A6:B587 8D A8 0F STA $0FA8 [$7E:0FA8] $A6:B58A A9 20 00 LDA #$0020 $A6:B58D 8F 00 78 7E STA $7E7800[$7E:7800] ; Swoop timer $A6:B591 4C 55 D9 JMP $D955 [$A6:D955] ; Turn around if facing away from the center of the room (facing a wall) } } ; AI Script: Swoop end { $A6:B594 64 12 STZ $12 [$7E:0012] $A6:B596 A9 00 80 LDA #$8000 $A6:B599 85 14 STA $14 [$7E:0014] $A6:B59B A9 C0 01 LDA #$01C0 $A6:B59E 85 16 STA $16 [$7E:0016] $A6:B5A0 20 00 D8 JSR $D800 [$A6:D800] ; Update Ridley's U Swoop speed and U Swoop angle, and calculate current X and Y speed $A6:B5A3 AF 00 78 7E LDA $7E7800[$7E:7800] ; Swoop timer $A6:B5A7 F0 06 BEQ $06 [$B5AF] ; Run every frame { $A6:B5A9 3A DEC A $A6:B5AA 8F 00 78 7E STA $7E7800[$7E:7800] ; Swoop timer $A6:B5AE 60 RTS } ; Run at end { $A6:B5AF 20 F1 BC JSR $BCF1 [$A6:BCF1] ; CLC if spin jump, grappling, or spin back from hurt $A6:B5B2 A0 21 B3 LDY #$B321 ; Get next AI $A6:B5B5 90 03 BCC $03 [$B5BA] $A6:B5B7 A0 B7 BA LDY #$BAB7 $A6:B5BA 8C A8 0F STY $0FA8 [$7E:0FA8] $A6:B5BD 60 RTS } } ; AI Script: Consider pogo (B5C4) { LDA #$000B STA $7E201E ; Tail movement threshold LDA #$0180 STA $7E2012 ; Tail extension rate LDA #$B5E5 ; Considering pogo STA $0FA8 ; Next main AI script LDA $05E5 ; Random number AND #$001F CLC ADC #$0020 ; 20 - 3F STA $0FB2 ; Variable use timer ; Counter } ; AI Script: B5E5: Considering pogo { LDA $7E7820 ; Facing direction. 0 = left, 1 = forward, 2 = right ASL A TAY LDA $B60D, Y ; 00C0, 0080, or 0040 STA $12 JSR $B641 ; Fly towards $12 (X position) / Samus's Y position. If Samus is not spin jumping, SEC before RTS. Else CLC and randomly fireball if allowed. BCC BRANCH_ALPHA ; Branch if Samus is spinjumping JMP $B68B ... B68B: LDA #$00F0 STA $7E2012 ; Tail extension rate LDA #$0010 STA $7E201E ; Tail movement threshold LDA #$0001 STA $7E2000 ; Tail control index LDA #$B6A7 ; Fly to start pogoing STA $0FA8 ; Next AI script RTS BRANCH_ALPHA DEC $0FB2 ; Timer ; Counter BPL BRANCH_BETA LDA #$B613 ; Hover since Samus is spin jumping STA $0FA8 ; Next AI script LDA #$0080 STA $0FB2 ; Timer ; Counter JMP $D955 ; Turn around if facing away from the center of the room (facing a wall) BRANCH_BETA RTS } ; AI Script: Hover since Samus is spinjumping (B613) { LDA $7E7820 ; Direction facing ; Ridley's direction (0 = left, 2 = right) ASL A TAY LDA $B63B, Y ; 0040, 0080, or 00C0 STA $12 JSR $B641 ; Fly towards $12 (X position) / Samus's Y position. If Samus is not spin jumping, SEC before RTS. Else CLC and randomly fireball if allowed. BCC BRANCH_ALPHA JMP $B68B ; See above, sets AI=B6A7 (fly to start pogoing) BRANCH_ALPHA DEC $0FB2 ; Counter BPL BRANCH_BETA LDA #$B5E5 ; Considering tail bouncing STA $0FA8 ; Use as next AI script LDA #$0080 STA $0FB2 ; Counter JMP $D955 ; Turn around if facing away from the center of the room (facing a wall) BRANCH_BETA RTS } ; AI Script: Fly to start pogoing { $A6:B6A7 AD 7E 0F LDA $0F7E [$7E:0F7E] ; Ridley's Y position $A6:B6AA C9 20 01 CMP #$0120 $A6:B6AD 30 1F BMI $1F [$B6CE] ; If Ridley Y >= 0x120 { $A6:B6AF AF 20 78 7E LDA $7E7820[$7E:7820] ; Ridley's direction (0 = left, 2 = right) $A6:B6B3 0A ASL A $A6:B6B4 A8 TAY $A6:B6B5 B9 C8 B6 LDA $B6C8,y[$A6:B6CC] $A6:B6B8 85 12 STA $12 [$7E:0012] $A6:B6BA A9 20 01 LDA #$0120 $A6:B6BD 85 14 STA $14 [$7E:0014] $A6:B6BF A2 00 00 LDX #$0000 $A6:B6C2 A0 00 00 LDY #$0000 $A6:B6C5 4C 23 D5 JMP $D523 [$A6: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:B6CC db 60, 00 } ; If Ridley Y < 0x120 { $A6:B6CE 20 55 D9 JSR $D955 [$A6:D955] ; Turn around if facing away from the center of the room (facing a wall) $A6:B6D1 A9 DD B6 LDA #$B6DD ; Start pogo $A6:B6D4 8D A8 0F STA $0FA8 [$7E:0FA8] $A6:B6D7 A9 20 00 LDA #$0020 $A6:B6DA 8D B2 0F STA $0FB2 [$7E:0FB2] ; Counter } } ; AI Script: Start pogo { $A6:B6DD AD 7A 0F LDA $0F7A [$7E:0F7A] ; Ridley's X position $A6:B6E0 85 12 STA $12 [$7E:0012] $A6:B6E2 A9 20 01 LDA #$0120 $A6:B6E5 85 14 STA $14 [$7E:0014] $A6:B6E7 A2 00 00 LDX #$0000 $A6:B6EA A0 00 00 LDY #$0000 $A6:B6ED 20 23 D5 JSR $D523 [$A6: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:B6F0 CE B2 0F DEC $0FB2 [$7E:0FB2] ; Counter $A6:B6F3 10 18 BPL $18 [$B70D] ; RTS ; Run when counter is 0 { $A6:B6F5 20 33 CB JSR $CB33 [$A6:CB33] ; Extend the tail $A6:B6F8 20 0F B9 JSR $B90F [$A6:B90F] ; Set pogo speed (depends on random and speed) $A6:B6FB A9 0E B7 LDA #$B70E $A6:B6FE 8D A8 0F STA $0FA8 [$7E:0FA8] $A6:B701 AD E5 05 LDA $05E5 [$7E:05E5] $A6:B704 29 3F 00 AND #$003F $A6:B707 69 80 00 ADC #$0080 $A6:B70A 8D B2 0F STA $0FB2 [$7E:0FB2] ; Counter } $A6:B70D 60 RTS } ; AI Script: Main pogo { $A6:B70E 20 59 B8 JSR $B859 [$A6:B859] ; Attempt to grab Samus $A6:B711 90 07 BCC $07 [$B71A] ; If we grabbed Samus { $A6:B713 20 4D B8 JSR $B84D [$A6:B84D] ; Reset tail $A6:B716 4C 89 B8 JMP $B889 [$A6:B889] $A6:B719 60 RTS } ; Add to Ridley's Y speed. Max speed is 0x600 { $A6:B71A AD AC 0F LDA $0FAC [$7E:0FAC] ; Y speed (1/100 pixels) $A6:B71D 18 CLC $A6:B71E 6F 0C 20 7E ADC $7E200C[$7E:200C] ; Ridley pogo speed $A6:B722 C9 00 06 CMP #$0600 $A6:B725 30 03 BMI $03 [$B72A] $A6:B727 A9 00 06 LDA #$0600 $A6:B72A 8D AC 0F STA $0FAC [$7E:0FAC] ; Y speed (1/100 pixels) } $A6:B72D 20 E7 B7 JSR $B7E7 [$A6:B7E7] ; Check if tail has collided with a block? $A6:B730 90 E7 BCC $E7 [$B719] ; RTS if not ; We collided with a block { ; Add smoke to where the tail hit the block { $A6:B732 AF A4 20 7E LDA $7E20A4[$7E:20A4] ; Tail tip X position $A6:B736 85 12 STA $12 [$7E:0012] $A6:B738 AF A6 20 7E LDA $7E20A6[$7E:20A6] ; Tail tip Y position $A6:B73C 18 CLC $A6:B73D 69 0C 00 ADC #$000C $A6:B740 85 14 STA $14 [$7E:0014] $A6:B742 A9 09 00 LDA #$0009 $A6:B745 A0 09 E5 LDY #$E509 $A6:B748 22 97 80 86 JSL $868097[$86:8097] } ; Play sound { $A6:B74C A9 76 00 LDA #$0076 $A6:B74F 22 CB 90 80 JSL $8090CB[$80:90CB] } ; Shake room { $A6:B753 A9 0D 00 LDA #$000D $A6:B756 8D 3E 18 STA $183E [$7E:183E] $A6:B759 A9 04 00 LDA #$0004 $A6:B75C 8D 40 18 STA $1840 [$7E:1840] } $A6:B75F 20 A9 B8 JSR $B8A9 [$A6:B8A9] ; Change direction? TODO $A6:B762 20 0F B9 JSR $B90F [$A6:B90F] ; Set pogo speed (depends on random and speed) ; Tail stuff { $A6:B765 A2 7C D3 LDX #$D37C $A6:B768 A0 26 20 LDY #$2026 $A6:B76B 20 B4 D3 JSR $D3B4 [$A6:D3B4] ; Copy 7 entries from (X) to 7E:(Y), 7E:(Y+14), 7E:(Y+28), 7E:(Y+3C), etc. $A6:B76E A9 00 0C LDA #$0C00 $A6:B771 8F 28 20 7E STA $7E2028[$7E:2028] $A6:B775 8F 3C 20 7E STA $7E203C[$7E:203C] $A6:B779 8F 50 20 7E STA $7E2050[$7E:2050] $A6:B77D 8F 64 20 7E STA $7E2064[$7E:2064] $A6:B781 8F 78 20 7E STA $7E2078[$7E:2078] $A6:B785 8F 8C 20 7E STA $7E208C[$7E:208C] $A6:B789 8F A0 20 7E STA $7E20A0[$7E:20A0] $A6:B78D A9 04 00 LDA #$0004 $A6:B790 8F 00 20 7E STA $7E2000[$7E:2000] ; Tail control index } $A6:B794 AF 0C 80 7E LDA $7E800C[$7E:800C] $A6:B798 1A INC A $A6:B799 C9 02 00 CMP #$0002 $A6:B79C 30 10 BMI $10 [$B7AE] ; Run every other time we collide { $A6:B79E AF 20 78 7E LDA $7E7820[$7E:7820] ; Ridley's direction (0 = left, 2 = right) $A6:B7A2 3A DEC A $A6:B7A3 F0 06 BEQ $06 [$B7AB] $A6:B7A5 A9 3A E7 LDA #$E73A ; Fireballing $A6:B7A8 20 67 D4 JSR $D467 [$A6:D467] ; Set PLM instruction? $A6:B7AB A9 00 00 LDA #$0000 } $A6:B7AE 8F 0C 80 7E STA $7E800C[$7E:800C] $A6:B7B2 A9 B9 B7 LDA #$B7B9 ; Pogo, hit ground $A6:B7B5 8D A8 0F STA $0FA8 [$7E:0FA8] $A6:B7B8 60 RTS } } ; Extended AI: Grabbed Samus { ; Probably reverses Y speed { $A6:B889 AD AC 0F LDA $0FAC [$7E:0FAC] ; Y speed (1/100 pixels) $A6:B88C 30 04 BMI $04 [$B892] $A6:B88E 49 FF FF EOR #$FFFF $A6:B891 1A INC A $A6:B892 C9 00 FE CMP #$FE00 $A6:B895 30 03 BMI $03 [$B89A] ; .. missing code .. $A6:B89A 8D AC 0F STA $0FAC [$7E:0FAC] ; Y speed (1/100 pixels) } $A6:B89D 20 4D B8 JSR $B84D [$A6:B84D] ; Reset tail $A6:B8A0 A9 8F BB LDA #$BB8F ; Ridley in position to grab Samus, no powerbombs $A6:B8A3 8D A8 0F STA $0FA8 [$7E:0FA8] $A6:B8A6 4C 8F BB JMP $BB8F [$A6:BB8F] ; Ridley in position to grab Samus, no powerbombs } ; AI Script: Pogo, hit ground { $A6:B7B9 20 20 BD JSR $BD20 [$A6:BD20] ; Check if Samus' Y is below #$0160 $A6:B7BC 90 1F BCC $1F [$B7DD] ; Branch if above $A6:B7BE CE B2 0F DEC $0FB2 [$7E:0FB2] ; Counter $A6:B7C1 30 1A BMI $1A [$B7DD] $A6:B7C3 AD AC 0F LDA $0FAC [$7E:0FAC] ; Y speed (1/100 pixels) $A6:B7C6 18 CLC $A6:B7C7 6F 0E 20 7E ADC $7E200E[$7E:200E] ; Ridley pogo acceleration upwards (after hitting ground) $A6:B7CB 8D AC 0F STA $0FAC [$7E:0FAC] ; Y speed (1/100 pixels) $A6:B7CE 30 0C BMI $0C [$B7DC] $A6:B7D0 A9 00 00 LDA #$0000 $A6:B7D3 8D AC 0F STA $0FAC [$7E:0FAC] ; Y speed (1/100 pixels) $A6:B7D6 A9 0E B7 LDA #$B70E $A6:B7D9 8D A8 0F STA $0FA8 [$7E:0FA8] $A6:B7DC 60 RTS $A6:B7DD 20 4D B8 JSR $B84D [$A6:B84D] ; Reset tail $A6:B7E0 A9 21 B3 LDA #$B321 ; Get next AI $A6:B7E3 8D A8 0F STA $0FA8 [$7E:0FA8] $A6:B7E6 60 RTS } ; Part of AI Script BAB7 { $A6:BA85 AF 0A 80 7E LDA $7E800A[$7E:800A] $A6:BA89 C9 0A 00 CMP #$000A $A6:BA8C 30 0D BMI $0D [$BA9B] JSL $A6DFB7 ; Check if Ridley should die LDA #$C53E STA $0FA8 ; Set next AI script JMP $C53E ; and run it. When that RTSes, it goes to Ridley's main AI loop. $A6:BA9B AD EE 0C LDA $0CEE [$7E:0CEE] ; Powerbomb timer $A6:BA9E F0 09 BEQ $09 [$BAA9] LDA #$BD4E ; Dodge a powerbomb STA $0FA8 ; Set next AI script to dodge powerbombs JMP $BD4E ; and run it. When that RTSes, it goes to Ridley's main AI loop. $A6:BAA9 A9 EC B3 LDA #$B3EC $A6:BAAC 8D A8 0F STA $0FA8 [$7E:0FA8] $A6:BAAF A9 01 00 LDA #$0001 $A6:BAB2 8F 04 20 7E STA $7E2004[$7E:2004] ; Tail fling trigger $A6:BAB6 60 RTS } ; AI Script BAB7 { ; If Samus is spin jumping, grappling or damage boosting { $A6:BAB7 20 F1 BC JSR $BCF1 [$A6:BCF1] ; CLC if spin jump, grappling, or spin back from hurt $A6:BABA 90 C9 BCC $C9 [$BA85] } ; If Ridley collided with a wall { $A6:BABC 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:BAC0 D0 C3 BNE $C3 [$BA85] } ; If Ridley is not facing towards Samus, and Samus is further than 2 blocks away { $A6:BAC2 AF 20 78 7E LDA $7E7820[$7E:7820] ; Ridley's direction (0 = left, 2 = right) $A6:BAC6 0A ASL A $A6:BAC7 A8 TAY $A6:BAC8 B9 48 BB LDA $BB48,y[$A6:BB4C] $A6:BACB 85 12 STA $12 [$7E:0012] $A6:BACD AD 7A 0F LDA $0F7A [$7E:0F7A] ; Ridley's X position $A6:BAD0 38 SEC $A6:BAD1 ED F6 0A SBC $0AF6 [$7E:0AF6] ; Samus' X position $A6:BAD4 85 14 STA $14 [$7E:0014] $A6:BAD6 45 12 EOR $12 [$7E:0012] $A6:BAD8 10 0D BPL $0D [$BAE7] $A6:BADA A5 14 LDA $14 [$7E:0014] $A6:BADC 10 04 BPL $04 [$BAE2] $A6:BAE2 C9 20 00 CMP #$0020 $A6:BAE5 10 9E BPL $9E [$BA85] } ; If Samus is above Ridley { $A6:BAE7 AD 7E 0F LDA $0F7E [$7E:0F7E] ; Ridley's Y position $A6:BAEA 18 CLC $A6:BAEB 69 23 00 ADC #$0023 $A6:BAEE 38 SEC $A6:BAEF ED FA 0A SBC $0AFA [$7E:0AFA] ; Samus' Y position $A6:BAF2 10 91 BPL $91 [$BA85] } ; X = 10 if left, -10 if right { $A6:BAF4 A2 F0 FF LDX #$FFF0 $A6:BAF7 AF 20 78 7E LDA $7E7820[$7E:7820] ; Ridley's direction (0 = left, 2 = right) $A6:BAFB F0 03 BEQ $03 [$BB00] $A6:BAFD A2 10 00 LDX #$0010 } ; Accelerate towards Samus { $A6:BB00 8A TXA $A6:BB01 18 CLC $A6:BB02 6D F6 0A ADC $0AF6 [$7E:0AF6] ; Samus' X position $A6:BB05 85 12 STA $12 [$7E:0012] $A6:BB07 AD FA 0A LDA $0AFA [$7E:0AFA] ; Samus' Y position $A6:BB0A 18 CLC $A6:BB0B 69 FC FF ADC #$FFFC $A6:BB0E 85 14 STA $14 [$7E:0014] $A6:BB10 A2 00 00 LDX #$0000 $A6:BB13 AF 24 78 7E LDA $7E7824[$7E:7824] ; General speed byte $A6:BB17 0A ASL A $A6:BB18 A8 TAY $A6:BB19 B9 4E BB LDA $BB4E,y[$A6:BB4E] $A6:BB1C A8 TAY $A6:BB1D 20 23 D5 JSR $D523 [$A6: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 } ; Check if we can grab Samus { $A6:BB20 AF 20 78 7E LDA $7E7820[$7E:7820] ; Ridley's direction (0 = left, 2 = right) $A6:BB24 0A ASL A $A6:BB25 A8 TAY $A6:BB26 B9 D5 B9 LDA $B9D5,y[$A6:B9D9] $A6:BB29 18 CLC $A6:BB2A 6D 7A 0F ADC $0F7A [$7E:0F7A] ; Ridley's X position $A6:BB2D 85 12 STA $12 [$7E:0012] $A6:BB2F A9 23 00 LDA #$0023 $A6:BB32 18 CLC $A6:BB33 6D 7E 0F ADC $0F7E [$7E:0F7E] ; Ridley's Y position $A6:BB36 85 14 STA $14 [$7E:0014] $A6:BB38 A9 08 00 LDA #$0008 $A6:BB3B 85 16 STA $16 [$7E:0016] $A6:BB3D A9 0C 00 LDA #$000C $A6:BB40 85 18 STA $18 [$7E:0018] $A6:BB42 20 29 DF JSR $DF29 [$A6:DF29] ; Efficient collision detection for Samus and $12/$14 (size of $12/$14 is $16/$18). SEC if collision } $A6:BB45 B0 0F BCS $0F [$BB56] $A6:BB47 60 RTS $A6:BB48 db 00, 00 $A6:BB4C db 00, 80, 01, 00, 03, 00, 07, 00, 0A, 00 ; If we can grab Samus { ; Reverse Y speed { $A6:BB56 AD AC 0F LDA $0FAC [$7E:0FAC] ; Y speed (1/100 pixels) $A6:BB59 49 FF FF EOR #$FFFF $A6:BB5C 1A INC A $A6:BB5D 8D AC 0F STA $0FAC [$7E:0FAC] ; Y speed (1/100 pixels) } $A6:BB60 AD 8C 0F LDA $0F8C [$7E:0F8C] ; Ridley's HP $A6:BB63 F0 14 BEQ $14 [$BB79] $A6:BB65 AD EE 0C LDA $0CEE [$7E:0CEE] ; Powerbomb timer $A6:BB68 AD EE 0C LDA $0CEE [$7E:0CEE] ; Powerbomb timer $A6:BB6B F0 22 BEQ $22 [$BB8F] ; Ridley in position to grab Samus, no powerbombs ; If Ridley dead or we dropped a power bomb { $A6:BB79 AF 36 78 7E LDA $7E7836[$7E:7836] ; Set if Ridley is holding Samus $A6:BB7D D0 03 BNE $03 [$BB82] $A6:BB7F 20 68 BC JSR $BC68 [$A6:BC68] ; Grab Samus $A6:BB82 22 B7 DF A6 JSL $A6DFB7[$A6:DFB7] ; Check if Ridley should die $A6:BB86 A9 38 C5 LDA #$C538 ; Move Ridley to 80,148 to die $A6:BB89 8D A8 0F STA $0FA8 [$7E:0FA8] $A6:BB8C 4C 38 C5 JMP $C538 [$A6:C538] ; Move Ridley to 80,148 to die } } } ; AI Script: Ridley in position to grab Samus, no powerbombs { $A6:BB8F AF 20 78 7E LDA $7E7820[$7E:7820] ; Ridley's direction (0 = left, 2 = right) $A6:BB93 0A ASL A $A6:BB94 A8 TAY ; Set X to 0x40 or 0xD0 { $A6:BB95 B9 EB BB LDA $BBEB,y[$A6:BBEB] $A6:BB98 8F 2E 78 7E STA $7E782E[$7E:782E] ; Target X when Samus i grabbed } ; Set Y to Ridley's Y position - 0x40, but not lower than 0x0100 (meaning high up on the screen) { $A6:BB9C AD 7E 0F LDA $0F7E [$7E:0F7E] ; Ridley's Y position $A6:BB9F 18 CLC $A6:BBA0 69 C0 FF ADC #$FFC0 $A6:BBA3 C9 00 01 CMP #$0100 $A6:BBA6 10 03 BPL $03 [$BBAB] $A6:BBA7 A9 00 01 LDA #$0100 $A6:BBAB 8F 30 78 7E STA $7E7830[$7E:7830] ; Target Y when holding Samus } $A6:BBAF AF 36 78 7E LDA $7E7836[$7E:7836] ; Set if Ridley is holding Samus $A6:BBB3 D0 03 BNE $03 [$BBB8] $A6:BBB5 20 68 BC JSR $BC68 [$A6:BC68] ; Grab Samus $A6:BBB8 A9 C4 BB LDA #$BBC4 ; Ridley is holding Samus $A6:BBBB 8D A8 0F STA $0FA8 [$7E:0FA8] $A6:BBBE A9 20 00 LDA #$0020 $A6:BBC1 8D B2 0F STA $0FB2 [$7E:0FB2] ; Counter } ; AI Script: Ridley is holding Samus. Move to target position. { $A6:BBC4 AF 2E 78 7E LDA $7E782E[$7E:782E] ; Target X when Samus i grabbed $A6:BBC8 85 12 STA $12 [$7E:0012] $A6:BBCA AF 30 78 7E LDA $7E7830[$7E:7830] ; Target Y when holding Samus $A6:BBCE 85 14 STA $14 [$7E:0014] $A6:BBD0 A2 00 00 LDX #$0000 $A6:BBD3 A0 00 00 LDY #$0000 $A6:BBD6 20 23 D5 JSR $D523 [$A6: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:BBD9 CE B2 0F DEC $0FB2 [$7E:0FB2] ; Counter $A6:BBDC 10 0C BPL $0C [$BBEA] ; Run after counter is 0 { $A6:BBDE A9 F1 BB LDA #$BBF1 ; Drop Samus $A6:BBE1 8D A8 0F STA $0FA8 [$7E:0FA8] $A6:BBE4 A9 20 00 LDA #$0020 $A6:BBE7 8D B2 0F STA $0FB2 [$7E:0FB2] ; Counter } $A6:BBEA 60 RTS } ; Data used above { $A6:BBEB db 40, 00 $A6:BBEF db D0, 00 } ; AI Script: Drop Samus { $A6:BBF1 CE B2 0F DEC $0FB2 [$7E:0FB2] ; Counter $A6:BBF4 30 14 BMI $14 [$BC0A] ; Run until counter is 0 { $A6:BBF6 AF 2E 78 7E LDA $7E782E[$7E:782E] ; Target X when Samus i grabbed $A6:BBFA 85 12 STA $12 [$7E:0012] $A6:BBFC A9 00 01 LDA #$0100 $A6:BBFF 85 14 STA $14 [$7E:0014] $A6:BC01 A2 00 00 LDX #$0000 $A6:BC04 A0 00 00 LDY #$0000 $A6:BC07 4C 23 D5 JMP $D523 [$A6: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 } ; Run at end { $A6:BC0A A9 08 00 LDA #$0008 $A6:BC0D 8F 1E 20 7E STA $7E201E[$7E:201E] ; Tail movement threshold $A6:BC11 A9 F0 00 LDA #$00F0 $A6:BC14 8F 12 20 7E STA $7E2012[$7E:2012] ; Tail extension rate $A6:BC18 20 84 BC JSR $BC84 [$A6:BC84] ; Let go of Samus $A6:BC1B A9 2E BC LDA #$BC2E ; Post-dropped Samus $A6:BC1E 8D A8 0F STA $0FA8 [$7E:0FA8] $A6:BC21 A9 40 00 LDA #$0040 $A6:BC24 8D B2 0F STA $0FB2 [$7E:0FB2] ; Counter } $A6:BC27 60 RTS } ; AI Script: Post-dropped Samus { $A6:BC2E CE B2 0F DEC $0FB2 [$7E:0FB2] ; Counter $A6:BC31 30 1A BMI $1A [$BC4D] ; Run until counter is 0 { $A6:BC33 AF 20 78 7E LDA $7E7820[$7E:7820] ; Ridley's direction (0 = left, 2 = right) $A6:BC37 0A ASL A $A6:BC38 A8 TAY $A6:BC39 B9 62 BC LDA $BC62,y[$A6:BC62] $A6:BC3C 85 12 STA $12 [$7E:0012] $A6:BC3E A9 E0 00 LDA #$00E0 $A6:BC41 85 14 STA $14 [$7E:0014] $A6:BC43 A2 00 00 LDX #$0000 $A6:BC46 A0 00 00 LDY #$0000 $A6:BC49 20 23 D5 JSR $D523 [$A6: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:BC4C 60 RTS } ; Run at end { $A6:BC4D A9 10 00 LDA #$0010 $A6:BC50 8F 1E 20 7E STA $7E201E[$7E:201E] ; Tail movement threshold $A6:BC54 A9 F0 00 LDA #$00F0 $A6:BC57 8F 12 20 7E STA $7E2012[$7E:2012] ; Tail extension rate $A6:BC5B A9 21 B3 LDA #$B321 ; Get next AI $A6:BC5E 8D A8 0F STA $0FA8 [$7E:0FA8] $A6:BC61 60 RTS } $A6:BC62 db B0, 00 $A6:BC66 db 50, 00 } ; AI Script: Dodge a powerbomb (BD4E) { LDA $0CEE ; Powerbomb timer BEQ BRANCH_ALPHA ; Powerbomb timer is on { LDA #$0002 STA $7E7802 ; Main battle AI is momentarily paused? LDY #$0050 LDA $0CE2 ; X position of powerbomb explosion CMP #$0080 BPL BRANCH_BETA LDY #$00C0 BRANCH_BETA STY $12 LDY #$00C0 LDA $0CE4 ; Y position of powerbomb explosion CMP #$0100 BPL BRANCH_GAMMA LDY #$0180 BRANCH_GAMMA STY $14 LDX #$0000 JSR $B42E ; Y = 4, 8, A, or C, depending on general speed byte JMP $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 } ; Power bomb timer is 0 BRANCH_ALPHA { LDA #$0001 STA $7E7802 ; Resume main battle AI LDY #$B321 LDA $7E7836 ; Holding Samus flag BEQ BRANCH_DELTA LDY #$BB8F ; Go to normal holding Samus AI BRANCH_DELTA { STY $0FA8 ; Next main AI script RTS } } } ; AI Script: Move Ridley to 80,148 to die { $A6:C538 20 01 C6 JSR $C601 [$A6:C601] ; Move Ridley to [0x80, 0x148] to die $A6:C53B 90 01 BCC $01 [$C53E] ; Final roar $A6:C53D 60 RTS } ; AI Script: Final roar { $A6:C53E A9 C8 E6 LDA #$E6C8 ; Death roar $A6:C541 20 67 D4 JSR $D467 [$A6:D467] ; Set PLM instruction? $A6:C544 A9 51 C5 LDA #$C551 ; Move to death spot, lower lava & wait $A6:C547 8D A8 0F STA $0FA8 [$7E:0FA8] $A6:C54A A9 20 00 LDA #$0020 $A6:C54D 8D B2 0F STA $0FB2 [$7E:0FB2] ; Counter $A6:C550 60 RTS } ; AI Script: Move to death spot, lower lava & wait { $A6:C551 20 01 C6 JSR $C601 [$A6:C601] ; Move to death spot $A6:C554 CE B2 0F DEC $0FB2 [$7E:0FB2] ; Counter $A6:C557 10 F7 BPL $F7 [$C550] ; Run at the end { $A6:C559 9C AA 0F STZ $0FAA [$7E:0FAA] ; X speed (1/100 pixels) $A6:C55C 9C AC 0F STZ $0FAC [$7E:0FAC] ; Y speed (1/100 pixels) ; Lava related { $A6:C55F A9 10 02 LDA #$0210 $A6:C562 8D 7A 19 STA $197A [$7E:197A] ; Lava height $A6:C565 A9 40 00 LDA #$0040 $A6:C568 8D 7C 19 STA $197C [$7E:197C] ; Lava speed $A6:C56B A9 01 00 LDA #$0001 $A6:C56E 8D 80 19 STA $1980 [$7E:1980] } $A6:C571 A9 00 00 LDA #$0000 $A6:C574 8F 0E 80 7E STA $7E800E[$7E:800E] $A6:C578 8F 10 80 7E STA $7E8010[$7E:8010] $A6:C57C A9 88 C5 LDA #$C588 ; Explosions for death $A6:C57F 8D A8 0F STA $0FA8 [$7E:0FA8] $A6:C582 A9 A0 00 LDA #$00A0 $A6:C585 8D B2 0F STA $0FB2 [$7E:0FB2] ; Counter } } ; AI Script: Explosions for death. After a while, drop Samus if needed. { $A6:C588 20 23 C6 JSR $C623 [$A6:C623] ; Spawn/play explosions $A6:C58B CE B2 0F DEC $0FB2 [$7E:0FB2] ; Counter $A6:C58E 10 C0 BPL $C0 [$C550] ; Run at end { $A6:C590 AF 36 78 7E LDA $7E7836[$7E:7836] ; Set if Ridley is holding Samus $A6:C594 F0 03 BEQ $03 [$C599] ; If we are holding Samus { $A6:C596 20 84 BC JSR $BC84 [$A6:BC84] ; Let go of Samus } $A6:C599 A9 A8 C5 LDA #$C5A8 ; Disable Ridley $A6:C59C 8D A8 0F STA $0FA8 [$7E:0FA8] $A6:C59F 9C AA 0F STZ $0FAA [$7E:0FAA] ; X speed (1/100 pixels) $A6:C5A2 9C AC 0F STZ $0FAC [$7E:0FAC] ; Y speed (1/100 pixels) $A6:C5A5 4C 32 C9 JMP $C932 [$A6:C932] } } ; AI Script: Disable Ridley { $A6:C5A8 20 23 C6 JSR $C623 [$A6:C623] ; Spawn/play explosions $A6:C5AB A9 00 00 LDA #$0000 $A6:C5AE 8F 04 78 7E STA $7E7804[$7E:7804] ; Set if Ridley is active $A6:C5B2 AD 86 0F LDA $0F86 [$7E:0F86] ; Property bits of Ridley $A6:C5B5 09 00 01 ORA #$0100 $A6:C5B8 8D 86 0F STA $0F86 [$7E:0F86] ; Property bits of Ridley $A6:C5BB A9 C8 C5 LDA #$C5C8 ; Wait 20 frames $A6:C5BE 8D A8 0F STA $0FA8 [$7E:0FA8] $A6:C5C1 A9 20 00 LDA #$0020 $A6:C5C4 8D B2 0F STA $0FB2 [$7E:0FB2] ; Counter $A6:C5C7 60 RTS } ; AI Script: Wait 20 frames { $A6:C5C8 CE B2 0F DEC $0FB2 [$7E:0FB2] ; Counter $A6:C5CB 10 83 BPL $83 [$C550] ; Run at end { $A6:C5CD A9 DA C5 LDA #$C5DA ; Wait 100 frames, drop items, change music & set boss bit $A6:C5D0 8D A8 0F STA $0FA8 [$7E:0FA8] $A6:C5D3 A9 00 01 LDA #$0100 $A6:C5D6 8D B2 0F STA $0FB2 [$7E:0FB2] ; Counter $A6:C5D9 60 RTS } } ; AI Script: Wait 100 frames, drop items, change music & set boss bit { $A6:C5DA CE B2 0F DEC $0FB2 [$7E:0FB2] ; Counter $A6:C5DD 10 21 BPL $21 [$C600] ; Run at end { $A6:C5DF A9 01 00 LDA #$0001 $A6:C5E2 22 A6 81 80 JSL $8081A6[$80:81A6] $A6:C5E6 22 A5 B9 A0 JSL $A0B9A5[$A0:B9A5] $A6:C5EA A9 03 00 LDA #$0003 ; \ $A6:C5ED 22 C1 8F 80 JSL $808FC1[$80:8FC1] ; } Queue elevator music track $A6:C5F1 AD 86 0F LDA $0F86 [$7E:0F86] ; Property bits of Ridley $A6:C5F4 09 00 02 ORA #$0200 $A6:C5F7 8D 86 0F STA $0F86 [$7E:0F86] ; Property bits of Ridley $A6:C5FA A9 00 C6 LDA #$C600 ; Wait for deletion $A6:C5FD 8D A8 0F STA $0FA8 [$7E:0FA8] } } ; AI Script: Wait for deletion { $A6:C600 60 RTS }