[M1] Somersault ball conundrum (Updated for clarity and small improvements)

Started by Stinktier, March 02, 2015, 06:49:09 PM

Previous topic - Next topic

Stinktier

Update: Updated thread for clarity's sake. Code snippet has gotten improvements. Now it doesn't bug out . still not the desired effect, though.

Goal: To make samus being able to morph into a ball while somersaulting (but not when jumping) as a nod to Metroid prime cutscenes.
Implementation: I let this code run on repeat in the main game loop for now.
What works: Checks if somersault is active. if not, branch. Checks if down is pressed. If, jump to morphball subroutine. Else branch and continue with the main game loop
What doesn't work: Game just aborts the somersault. In effect, pushing down just cancels somersaulting/screw attacking.
What has been tried: Replacing the gravitation-branch check (which is in the beginning of the morphball subroutine) with "No Operation" opcodes. Effect it had: Stops somersaulting for one frame, then continue to somersault. But the morph 'swoop' sound is heard.
Main Question: Do anybody know if there is any other roadblocks that hinder samus from morphing mid-air? I've searched and searched...
Side-question:what is the difference between loading controller status, bitwise scan, compare, and simply load controller status and AND-check down button?


lda AnimResetIndex ad0503
cmp #an_SamusSalto c90E
bne 12 d00c

lda joy1change a512
jsr bitscan                   20e1e1
cmp 02 2902
bcc 03 9003
jsr SetSamusRoll       20b5d0



Update II
The code contained some faults. It is kept here for history and learning purposes. Works better now but main and side questions are not yet solved. Part of solution: there seems to be a looping reset for the somersaulting animation offset to be stored in the animation index in the samusRun subroutine. branching past it would work partly (ball will still break just as the somersault when passing below a certain line of height) but there's not enough memory to do so as it is. Repetive tapping of the down button (usually two presses) circumvenes this first roadblock (though not the second one) but it is unintuitive. 

New code replacing the above:

lda AnimResetIndex ad0503
cmp #an_SamusSalto c90E
bne 12 d00c
lda joy1change a512
jsr bitscan         20e1e1
cmp 02 c902
bne 03 d003
jsr SetSamusRoll       20b5d0