actor: fixed movement being slow when picking two directions
authorLukas Krickl <lukas@krickl.dev>
Sat, 28 Jun 2025 10:11:39 +0000 (12:11 +0200)
committerLukas Krickl <lukas@krickl.dev>
Sat, 28 Jun 2025 10:11:39 +0000 (12:11 +0200)
This was caused due to try_move_x destroying registers.
The fix was to simply push and pop de and hl.

BUGS.md
src/unit.s

diff --git a/BUGS.md b/BUGS.md
index fa76b8e3bca331d9707d094128afd9e013442fb0..b5b30c1f3fe773c8ca117d9fd9aea54ef1ccb45e 100644 (file)
--- a/BUGS.md
+++ b/BUGS.md
@@ -1,6 +1,4 @@
 # Known Bugs
 
-## Movement in multiple directions slows donw movement to a crawl
 
-When pressing two direction buttons movement speed calculations slow down a lot.
 
index 7768801dbb26da76c2f215974eaa876dd2d49874..6a3833942e2a69de67e2b73f29d005cb9cacb6d1 100644 (file)
@@ -221,8 +221,12 @@ unit_handle_inputs:
 
   input_held BTNUP
   jr z, @notup REL
-
+    
+    push de
+    push hl
     call unit_try_move_up
+    pop hl
+    pop de
 
     pop bc
     ld bc, st_unit_delay_to_active
@@ -232,8 +236,12 @@ unit_handle_inputs:
   input_held BTNDOWN
   jr z, @notdown REL
     
+    push de
+    push hl
     call unit_try_move_down
-    
+    pop hl
+    pop de
+
     pop bc
     ld bc, st_unit_delay_to_active
     push bc
@@ -242,7 +250,11 @@ unit_handle_inputs:
   input_held BTNLEFT
   jr z, @notleft REL
 
+    push de
+    push hl
     call unit_try_move_left
+    pop hl
+    pop de
 
     pop bc
     ld bc, st_unit_delay_to_active