cleanup sprite movement functions lib

This commit is contained in:
scawful
2024-05-03 22:57:00 -04:00
parent aa2f687e3f
commit de1bbfae55

View File

@@ -1,6 +1,7 @@
;================================================================= ;==========================================================
;Long function, return Carry Set if Active ;Long function, return Carry Set if Active
;================================================================= ;==========================================================
Sprite_CheckActive: Sprite_CheckActive:
{ {
; Deactivates the sprite in certain situations ; Deactivates the sprite in certain situations
@@ -14,11 +15,11 @@ Sprite_CheckActive:
LDA $0F00, X : BEQ .active LDA $0F00, X : BEQ .active
.inactive .inactive
CLC CLC
RTL RTL
.active .active
SEC SEC
RTL RTL
} }
@@ -27,6 +28,7 @@ Sprite_CheckActive:
; make the sprite move X axis ; make the sprite move X axis
;========================================================== ;==========================================================
Sprite_MoveHoriz: Sprite_MoveHoriz:
{
LDA.w $0D50, X : BEQ .no_velocity LDA.w $0D50, X : BEQ .no_velocity
ASL : ASL : ASL : ASL ASL : ASL : ASL : ASL
CLC : ADC.w $0D70,X : STA.w $0D70,X CLC : ADC.w $0D70,X : STA.w $0D70,X
@@ -39,25 +41,30 @@ Sprite_MoveHoriz:
ORA.b #$F0 ORA.b #$F0
DEY DEY
++ ADC.w $0D10,X : STA.w $0D10,X ++ ADC.w $0D10,X : STA.w $0D10,X
TYA : ADC.w $0D30,X : STA.w $0D30,X TYA : ADC.w $0D30,X : STA.w $0D30,X
.no_velocity .no_velocity
RTL RTL
}
;==========================================================
;===================================================================================================
; make the sprite move both directions (also height) ; make the sprite move both directions (also height)
;=================================================================================================== ;==========================================================
Sprite_MoveXyz: Sprite_MoveXyz:
JSL Sprite_MoveAltitude JSL Sprite_MoveAltitude
Sprite_Move: Sprite_Move:
JSL Sprite_MoveHoriz JSL Sprite_MoveHoriz
; no RTL, just continue into Sprite_MoveVert ; no RTL, just continue into Sprite_MoveVert
;=================================================================================================== ;==========================================================
; make the sprite move Y axis ; make the sprite move Y axis
;=================================================================================================== ;==========================================================
Sprite_MoveVert: Sprite_MoveVert:
{
LDA.w $0D40, X : BEQ .no_velocity LDA.w $0D40, X : BEQ .no_velocity
ASL : ASL : ASL : ASL ASL : ASL : ASL : ASL
CLC : ADC.w $0D60,X : STA.w $0D60,X CLC : ADC.w $0D60,X : STA.w $0D60,X
@@ -70,17 +77,20 @@ Sprite_MoveVert:
ORA.b #$F0 ORA.b #$F0
DEY DEY
++ ADC.w $0D00,X : STA.w $0D00,X ++ ADC.w $0D00,X : STA.w $0D00,X
TYA : ADC.w $0D20,X : STA.w $0D20,X TYA : ADC.w $0D20,X : STA.w $0D20,X
.no_velocity .no_velocity
RTL RTL
}
;=================================================================================================== ;==========================================================
; make the sprite move Z axis (height) ; make the sprite move Z axis (height)
;=================================================================================================== ;==========================================================
Sprite_MoveZ: Sprite_MoveZ:
Sprite_MoveAltitude: Sprite_MoveAltitude:
{
LDA.w $0F80, X : ASL : ASL : ASL : ASL LDA.w $0F80, X : ASL : ASL : ASL : ASL
CLC : ADC.w $0F90,X : STA.w $0F90,X CLC : ADC.w $0F90,X : STA.w $0F90,X
@@ -90,18 +100,21 @@ Sprite_MoveAltitude:
ORA.b #$F0 ORA.b #$F0
.positive .positive
ADC.w $0F70,X : STA.w $0F70,X ADC.w $0F70,X : STA.w $0F70,X
RTL RTL
}
;=================================================================================================== ;==========================================================
; make the sprite bounce toward player (like vitreous) ; make the sprite bounce toward player (like vitreous)
; Movement, Collision are handled by this function (height:20 = vitreous) ; Movement, Collision are handled by this function (height:20 = vitreous)
; $09 = speed, $08 = max height ; $09 = speed, $08 = max height
;=================================================================================================== ;==========================================================
Sprite_BounceTowardPlayer: Sprite_BounceTowardPlayer:
{
JSL Sprite_MoveAltitude JSL Sprite_MoveAltitude
DEC.w $0F80,X : DEC.w $0F80,X DEC.w $0F80,X : DEC.w $0F80,X
@@ -126,8 +139,10 @@ Sprite_BounceTowardPlayer:
.dontmove .dontmove
RTL RTL
}
Sprite_BounceFromTileCollision: Sprite_BounceFromTileCollision:
{
JSL Sprite_CheckTileCollision : AND.b #$03 : BEQ ++ JSL Sprite_CheckTileCollision : AND.b #$03 : BEQ ++
LDA.w $0D50,X : EOR.b #$FF : INC : STA.w $0D50,X LDA.w $0D50,X : EOR.b #$FF : INC : STA.w $0D50,X
INC.w $0ED0, X INC.w $0ED0, X
@@ -137,8 +152,7 @@ Sprite_BounceFromTileCollision:
INC.w $0ED0, X INC.w $0ED0, X
++ RTL ++ RTL
}
; ==============================================================================
Intro_Dungeon_Main: Intro_Dungeon_Main:
{ {