Lorom ;ipsum dolor sit amet ;Stops Samus from going into Morph Ball if she is midair, ;unless Spring Ball is also equipped. She can still demorph anywhere. ;This JSR overwrites an LDA that puts Samus' equipped item flags into A. ;The next instruction will check for Morph Ball and blocks the morph if it is not equipped. ;By replacing the LDA with a subroutine, we can toggle the morph ball ;flag based on whether we want her to be able to morph. org $91F7CE JSR $FFEE org $91FFEE JSL midairMorphLock ;There isn't enough room in the bank for the subroutine, sadly. RTS ;Pop into a bank with more room, and hop into the ;There's also a check for morph ball in this bank. ;(Not that that matters.) ;Maybe it's Torizo? Maybe it's Maybelline. org $82F70F ;Free Space. Change it to whatever you damn well please. midairMorphLock: LDA $09A2 ;Samus' equipped items flags BIT #$0004 ;check Morph Ball BEQ failure ;when using BIT, BEQ after means branch if NOT equipped. BIT #$0002 ;Morphball is equipped. So + springball = instant success. BNE success ;Branch if Equipped. ;Can't tell whether to block based on items. We have to test whether Samus is midair. ;LDA Samus' PREVIOUS pose, as her current pose is now (trying to be) the morphing pose. LDA $0A20 ;Kejardon's RAM Map is awesome. CMP #$0017 ;BIT for items flags, CMP for poses. BEQ failure ;Zero left over means the pose is a match. CMP #$0018 ;These are her midair poses. So we block if any match. BEQ failure ;Branch if Equal = Branch if Zero. CMP #$002D ;CMP = subtract but don't actually subtract. But pretend you did. BEQ failure CMP #$002E ;These are the 4 poses from which Samus could conceivably moprh while midair. BEQ failure ;If you've fallen through all the BEQ without hitting any, ;we want Samus to be able to morph. success: LDA $09A2 ;We already know Morph Ball is equipped. RTL ;So return the equipped item flags as they are. failure: LDA $09A2 ;Otherwise, load them up, but hide Morph Ball. AND #$FFFB RTL ;Execute Clever Ruse Alpha.