add GetDistance8bit_Long to sprite_new_functions

This commit is contained in:
scawful
2024-06-21 12:57:01 -04:00
parent a58482a72f
commit dec147375a

View File

@@ -813,4 +813,24 @@ Sprite_ApplySpeedTowardsPlayerXOrY_Long:
LDA.b #$00 : CLC : ADC $00 : STA.w SprXSpeed
STZ.w SprYSpeed
RTL
}
GetDistance8bit_Long:
{
LDA $04 ; Sprite X
SEC : SBC $02 ; - Player X
BPL +
EOR.b #$FF : INC
+
STA $00 ; Distance X (ABS)
LDA $05 ; Sprite Y
SEC : SBC $03 ; - Player Y
BPL +
EOR.b #$FF : INC
+
; Add it back to X Distance
CLC : ADC $00 : STA $00 ; distance total X, Y (ABS)
RTL
}