Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; ---------------------------------------------------------------------------
- ; Subroutines to perform a Drop Dash
- ; notes:
- ; normal speeds:
- ; min: $800
- ; max: $C00
- ; super speeds:
- ; min: $C00
- ; max: $D00
- ; ---------------------------------------------------------------------------
- Sonic_DropDash:
- tst.b dropdash_timer(a0) ; has been dropdash triggered?
- bmi.s .chkhold ; if yes, branch
- bne.s .chktimer ; else, check if buttons are still hold yet
- btst #Status_Shield,status_secondary(a0) ; do we have a shield?
- bne.s .done ; if yes, don't do anything
- move.b Ctrl_1_pressed_logical.w,d0 ; get button presses
- andi.b #btnABC,d0 ; ...for A/B/C
- beq.s .done ; if none of them have been pressed, branch
- move.b #20,dropdash_timer(a0) ; set the timer
- rts
- .chktimer pea .chkhold(pc) ; check and cancel if buttons aren't hold
- subq.b #1,dropdash_timer(a0) ; substract from timer
- bne.s .done ; if not ready, branch
- move.b #-1,dropdash_timer(a0) ; set "dropdash triggered" flag
- move.b #id_DropDash,obAnim(a0) ; set animation
- ; to-do: play sound!
- rts
- .chkhold move.b Ctrl_1_held_logical.w,d0 ; get held buttons
- andi.b #btnABC,d0 ; ... A/B/C
- bne.s .done ; if still held, branch
- .cancel clr.b dropdash_timer(a0) ; clear timer/flag
- bra.w Sonic_ForceRoll2 ; keep rolling
- .done rts
- Sonic_DropDash_Release:
- ; to-do: clear flags when getting hurt, jumping on a spring, etc
- ; to-do: check for Super Sonic
- tst.b dropdash_timer(a0) ; has dropdash been successfully triggered?
- bpl.s DD_SetFlags.done ; if not, branch
- move.w obInertia(a0),d0 ; get ground speed
- move.w #$800,d1 ; set dashspeed
- move.w #$C00,d2 ; set maxspeed
- pea DD_SetFlags(pc) ; submit configs next
- btst #Status_Facing,obStatus(a0) ; is Sonic facing left?
- bne.s DD_Left ; if so, branch
- DD_Right:
- tst.w d0 ; test ground speed
- bpl.s + ; if positive, branch
- tst.b obAngle(a0) ; is Sonic standing in a slope?
- bne.s ++ ; if yes, branch
- move.w d1,d0 ; else, just use plain dashspeed
- rts
- + asr.w #1,d0 ; divide ground speed by 2
- + asr.w #1,d0 ; divide ground speed by 2
- add.w d1,d0 ; add dashspeed to it
- cmp.w d2,d0 ; do we exceed maxspeed?
- bcs.s + ; if not, branch
- move.w d2,d0 ; else, cap the final value
- + rts
- DD_Left: ; basically DD_Right, hacked to run all checks inverted
- neg.w d0 ; negate ground speed
- bsr.s DD_Right
- neg.w d0 ; negate final result
- rts
- DD_SetFlags:
- move.w d0,obInertia(a0) ; set new inertia
- move.b #$E,y_radius(a0) ; fix radius
- move.b #7,x_radius(a0) ; fix radius
- move.b #id_Roll,anim(a0) ; set roll animation
- bset #Status_Roll,status(a0) ; set roll status
- move.w #sfx_Teleport,d0 ; play sound
- jsr (PlaySound_Special).l ; ''
- .done clr.b dropdash_timer(a0) ; clear timer/flag
- rts
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement