From dec147375a7087768281710c262dfef628ba6f76 Mon Sep 17 00:00:00 2001 From: scawful Date: Fri, 21 Jun 2024 12:57:01 -0400 Subject: [PATCH] add GetDistance8bit_Long to sprite_new_functions --- Sprites/ZSpriteLib/sprite_new_functions.asm | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Sprites/ZSpriteLib/sprite_new_functions.asm b/Sprites/ZSpriteLib/sprite_new_functions.asm index 5a3b591..6b563ab 100644 --- a/Sprites/ZSpriteLib/sprite_new_functions.asm +++ b/Sprites/ZSpriteLib/sprite_new_functions.asm @@ -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 } \ No newline at end of file