;Enabling Kago bugs to cause confusion: ;Make them not die on contact with Samus, set graphic AI, use graphic AI to set confusion and kill invincibility and itself. ;Find room in bank 86, add code for set confusion, kill invincibility, kill self, in that order (Minikraid will make use of the kill invincibility, kill self) org $86D036 DW $4014,CauseConfusion org $86DE82 DW $4004,CauseConfusion org $86F4B0 CauseConfusion: DW CCCode,KillInvAndSelf CCCode: LDA $0D28 CLC ADC #$0080 CMP #$0400 BMI + LDA #$0400 + STA $0D28 ; RTS ;Let's save a byte and a bunch of cycles KillInvAndSelf: STZ $18A8 ; LDX $1992 ;Don't think I'll need this either. STZ $1997,X PLA RTS ;Random controls ;Hijack JSR to E90F, mess around with buttons depending on 'confused' counter. 0D28 is free from the grapple code, so let's use that. ;OK! Confusion engine works PERFECTLY now. Only need to make enemies to cause confusion. org $90E6B3 JSR $FBF0 org $90E700 JSR $FBF0 org $809465 ;Minor change to preserve previous $8B in $97 during the whole frame instead of just a few instructions LDA $8B STA $97 LDA $4218 STA $8B EOR $97 AND $8B STA $8F STA $93 LDA $8B BEQ + CMP $97 BNE + DEC $A3 BNE ++ LDA $8B STA $93 LDA $89 STA $A3 BRA ++ + LDA $87 STA $A3 ++ ;Keys: ;7E:09B2 Shoot ;7E:09B4 Jump ;7E:09B6 Run ;7E:09B8 Item Cancel ;7E:09BA Switch Item ;7E:09BC Aim Up ;7E:09BE Aim Down ; ;0800: Up ;0400: Down ;0200: Left ;0100: Right org $90FBF0 LDA $0D28 BEQ NoConfusion STZ $12 ;Which bits to set CMP #$0080 BMI Confused1 CMP #$0100 BMI Confused2 CMP #$0180 BMI Confused3 CMP #$0200 BMI Confused4 CMP #$0280 BMI Confused5 CMP #$0300 BMI Confused6 LDX #ConfusionT7 JSR ConfuseCommands Confused6: LDX #ConfusionT6 JSR ConfuseCommands Confused5: LDX #ConfusionT5 JSR ConfuseDirections Confused4: LDX #ConfusionT4 JSR ConfuseCommands Confused3: LDX #ConfusionT3 JSR ConfuseDirections Confused2: LDX #ConfusionT2 JSR ConfuseCommands Confused1: LDX #ConfusionT1 JSR ConfuseCommands LDA $12 ORA $8B STA $8B EOR $97 AND $8B STA $8F DEC $0D28 NoConfusion: JMP ($0A60) ConfuseCommands: LDY $8B - TYA AND ($00,X) BEQ + TRB $8B LDA ($02,X) TSB $12 + INX INX LDA $02,X BNE - RTS ConfuseDirections: LDY $8B - TYA AND $00,X BEQ + TRB $8B LDA $02,X TSB $12 + INX INX LDA $02,X BNE - RTS ;ConfusionTable ;Swap aim up/down, swap jump/fire, swap left/right, swap item select/cancel, shuffle left/down/right/up, shuffle jump/fire/run, shuffle cancel/aim up/select/aim down ;Because it's called from direct page, bank byte is $00, so this must be stored in bank $80. Yay contrived programming. org $80D5C0 ConfusionT7: DW $09B8,$09BC,$09BA,$09BE,$09B8,$0000 ConfusionT6: DW $09B2,$09B4,$09B6,$09B2,$0000 ConfusionT5: DW $0200,$0800,$0400,$0100,$0200,$0000 ConfusionT4: DW $09BA,$09B8,$09BA,$0000 ConfusionT3: DW $0200,$0100,$0200,$0000 ConfusionT2: DW $09B4,$09B2,$09B4,$0000 ConfusionT1: DW $09BC,$09BE,$09BC,$0000