Advertisement
Guest User

Sonic DropDash

a guest
May 28th, 2018
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; ---------------------------------------------------------------------------
  2. ; Subroutines to perform a Drop Dash
  3.  
  4. ; notes:
  5. ; normal speeds:
  6. ; min: $800
  7. ; max: $C00
  8. ; super speeds:
  9. ; min: $C00
  10. ; max: $D00
  11. ; ---------------------------------------------------------------------------
  12.  
  13. Sonic_DropDash:
  14.             tst.b   dropdash_timer(a0)                      ; has been dropdash triggered?
  15.             bmi.s   .chkhold                                ; if yes, branch
  16.             bne.s   .chktimer                               ; else, check if buttons are still hold yet
  17.             btst    #Status_Shield,status_secondary(a0)     ; do we have a shield?
  18.             bne.s   .done                                   ; if yes, don't do anything
  19.             move.b  Ctrl_1_pressed_logical.w,d0             ; get button presses
  20.             andi.b  #btnABC,d0                              ; ...for A/B/C
  21.             beq.s   .done                                   ; if none of them have been pressed, branch
  22.             move.b  #20,dropdash_timer(a0)                  ; set the timer
  23.             rts
  24. .chktimer   pea     .chkhold(pc)                            ; check and cancel if buttons aren't hold
  25.             subq.b  #1,dropdash_timer(a0)                   ; substract from timer
  26.             bne.s   .done                                   ; if not ready, branch
  27.             move.b  #-1,dropdash_timer(a0)                  ; set "dropdash triggered" flag
  28.             move.b  #id_DropDash,obAnim(a0)                 ; set animation
  29.     ; to-do: play sound!
  30.             rts
  31. .chkhold    move.b  Ctrl_1_held_logical.w,d0                ; get held buttons
  32.             andi.b  #btnABC,d0                              ; ... A/B/C
  33.             bne.s   .done                                   ; if still held, branch
  34. .cancel     clr.b   dropdash_timer(a0)                      ; clear timer/flag
  35.             bra.w   Sonic_ForceRoll2                        ; keep rolling
  36. .done       rts
  37.  
  38. Sonic_DropDash_Release:
  39.     ; to-do: clear flags when getting hurt, jumping on a spring, etc
  40.     ; to-do: check for Super Sonic
  41.             tst.b   dropdash_timer(a0)                      ; has dropdash been successfully triggered?
  42.             bpl.s   DD_SetFlags.done                        ; if not, branch
  43.  
  44.             move.w  obInertia(a0),d0                        ; get ground speed
  45.             move.w  #$800,d1                                ; set dashspeed
  46.             move.w  #$C00,d2                                ; set maxspeed
  47.             pea     DD_SetFlags(pc)                         ; submit configs next
  48.             btst    #Status_Facing,obStatus(a0)             ; is Sonic facing left?
  49.             bne.s   DD_Left                                 ; if so, branch
  50.  
  51. DD_Right:
  52.             tst.w   d0                                      ; test ground speed
  53.             bpl.s   +                                       ; if positive, branch
  54.             tst.b   obAngle(a0)                             ; is Sonic standing in a slope?
  55.             bne.s   ++                                      ; if yes, branch
  56.             move.w  d1,d0                                   ; else, just use plain dashspeed
  57.             rts
  58. +           asr.w   #1,d0                                   ; divide ground speed by 2
  59. +           asr.w   #1,d0                                   ; divide ground speed by 2
  60.             add.w   d1,d0                                   ; add dashspeed to it
  61.             cmp.w   d2,d0                                   ; do we exceed maxspeed?
  62.             bcs.s   +                                       ; if not, branch
  63.             move.w  d2,d0                                   ; else, cap the final value
  64. +           rts
  65.  
  66. DD_Left:    ; basically DD_Right, hacked to run all checks inverted
  67.             neg.w   d0                                      ; negate ground speed
  68.             bsr.s   DD_Right
  69.             neg.w   d0                                      ; negate final result
  70.             rts
  71.  
  72. DD_SetFlags:
  73.             move.w  d0,obInertia(a0)                        ; set new inertia
  74.             move.b  #$E,y_radius(a0)                        ; fix radius
  75.             move.b  #7,x_radius(a0)                         ; fix radius
  76.             move.b  #id_Roll,anim(a0)                       ; set roll animation
  77.             bset    #Status_Roll,status(a0)                 ; set roll status
  78.             move.w  #sfx_Teleport,d0                        ; play sound
  79.             jsr     (PlaySound_Special).l                   ; ''
  80. .done       clr.b   dropdash_timer(a0)                      ; clear timer/flag
  81.             rts
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement