Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PlayerControl equ $FFFFF602
- Joypad equ $FFFFF604
- Held equ 0
- Press equ 1
- iStart equ 7
- iA equ 6
- iC equ 5
- iB equ 4
- iRight equ 3
- iLeft equ 2
- iDown equ 1
- iUp equ 0
- Start equ 1<<7
- A equ 1<<6
- C equ 1<<5
- B equ 1<<4
- Right equ 1<<3
- Left equ 1<<2
- Down equ 1<<1
- Up equ 1
- ; =============================================================
- ; Macro to check button presses
- ; Arguments: 1 - buttons to check
- ; 2 - bitfield to check
- ; -------------------------------------------------------------
- tpress macro
- move.b (\2+1),d0
- andi.b #\1,d0
- endm
- ; =============================================================
- ; Macro to check if buttons are held
- ; Arguments: 1 - buttons to check
- ; 2 - bitfield to check
- ; -------------------------------------------------------------
- theld macro
- move.b \2,d0
- andi.b #\1,d0
- endm
- GlideCheck:
- cmpi.b #$02, ($FFFFFFF7).w ; glide state equal to 2?
- beq.w Return_JMP ; if yes, branch
- btst #7,$22(a0) ; was Glide flag set?
- bne.w GlideLeft ; if yes, branch
- cmpi.b #2,$1C(a0) ; is player rolling?
- bne.w Return_JMP ; if no, branch
- tpress A+B+C,(PlayerControl) ; is A, B or C pressed?
- beq.w Return_JMP ; if not, branch
- move.b #$00, ($FFFFFFF7).w ; set glide state to 0
- bset #7,$22(a0) ; set Glide flag
- bra.w GlideLeft
- Return_JMP:
- jmp Return
- GlideLeft:
- theld A+B+C,(PlayerControl) ; A, B or C held?
- beq.w GlideEnd ; if not, branch
- move.w $12(a0),d0 ; load Y-velocity
- move.w $10(a0),d1 ; load X-velocity
- btst #0,$22(a0) ; is Player facing right?
- beq.w GlideRight ; if yes, branch
- btst #iRight,(Joypad|Press) ; is right pressed?
- beq.w GlideLeft2 ; if not, branch
- cmpi.w #$100,$12(a0) ; is Y-velocity greater than 100?
- blt.w GlideLeftUp ; if not, branch
- tst.b ($FFFFFFF7).w ; glide state equal to 0?
- beq.w GlideLeftUp ; if yes, branch
- move.b #$00, ($FFFFFFF7).w ; set glide state to 0
- cmpi.w #$0,$10(a0) ; is X-velocity 0?
- beq.w GlideLeftUp ; if yes, branch
- divs.w #$2,d0
- add.w #$100,d0
- neg.w d0 ;negate Y-velocity
- GlideLeft2:
- btst #iLeft,(PlayerControl|Held).w ; is Left being pressed?
- beq.w GlideLeftDown ; if not, branch
- move.b #$01, ($FFFFFFF7).w ; set glide state to 1
- GlideLeftDown:
- cmpi.b #$00, ($FFFFFFF7).w ; glide state equal to 0?
- beq.w GlideLeftUp ; if yes, branch
- move.b #$20,$1C(a0) ; use down glide animation
- add.w #$18,d0
- sub.w #$2C,d1
- bra.w GlideLeftCalc1
- GlideLeftUp:
- move.b #$1F,$1C(a0) ; use up glide animation
- add.w #$04,d1
- btst #6,$22(a0) ; is Sonic underwater?
- bne.s GlideLeftCalc1 ; if yes, branch
- sub.w #$20,d0
- GlideLeftCalc1:
- move.w d1,$10(a0)
- cmpi.w #-$200,$10(a0) ; is X-velocity greater than -200?
- blt.w GlideYCalc ; if not, branch
- move.w #-$200,$10(a0)
- bra.w GlideYCalc
- GlideRight:
- btst #iLeft,(Joypad|Press) ; is left pressed?
- beq.w GlideRight2 ; if not, branch
- cmpi.w #$100,$12(a0) ; is Y-velocity greater than 100?
- blt.w GlideRightUp ; if not, branch
- tst.b ($FFFFFFF7).w ; glide state equal to 0?
- beq.w GlideRightUp ; if yes, branch
- move.b #$00, ($FFFFFFF7).w ; set glide state to 0
- cmpi.w #$0,$10(a0) ; is X-velocity 0?
- beq.w GlideRightUp ; if yes, branch
- divs.w #$2,d0
- add.w #$100,d0
- neg.w d0 ;negate Y-velocity
- GlideRight2:
- btst #iRight,(PlayerControl|Held).w ; is right being pressed?
- beq.w GlideRightDown ; if not, branch
- move.b #$01, ($FFFFFFF7).w ; set glide state to 1
- GlideRightDown:
- cmpi.b #$00, ($FFFFFFF7).w ; glide state equal to 0?
- beq.w GlideRightUp ; if yes, branch
- move.b #$20,$1C(a0) ; use down glide animation
- add.w #$18,d0
- add.w #$2C,d1
- bra.w GlideRightCalc1
- GlideRightUp:
- move.b #$1F,$1C(a0) ; use up glide animation
- sub.w #$04,d1
- btst #6,$22(a0) ; is player underwater?
- bne.s GlideRightCalc1 ; if yes, branch
- sub.w #$20,d0
- GlideRightCalc1:
- move.w d1,$10(a0)
- cmpi.w #$200,$10(a0) ; is X-velocity less than 200?
- bgt.w GlideYCalc ; if not, branch
- move.w #$200,$10(a0)
- GlideYCalc:
- move.w d0,$12(a0)
- cmpi.w #-$800,$12(a0) ; is Y-velocity less than -800?
- bgt.w Return ; if not, branch
- move.w #-$800,$12(a0)
- bra.w Return
- GlideEnd:
- move.b #$02, ($FFFFFFF7).w ; set glide state to 2
- bclr #7,$22(a0) ; clear Glide flag
- move.b #$2,$1C(a0) ; use rolling animation
- bset #2,$22(a0)
- Return:
- rts
- ; End of function Ray_Glide
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement