cursor: working on aborting cursor move and scroll when reaching the origin/scope-change
authorLukas Krickl <lukas@krickl.dev>
Wed, 19 Mar 2025 21:48:27 +0000 (22:48 +0100)
committerLukas Krickl <lukas@krickl.dev>
Wed, 19 Mar 2025 21:48:27 +0000 (22:48 +0100)
edge of the map

src/macros.inc
src/player.s

index 690a0c2b16c6ba34b4dd6ad72f82131abdbd3cb3..970075ee4d68dc0657315518b5ceb7409c183c5f 100644 (file)
   ;   $1: add/sub
   ;   $2: scroll_move_y/x
   ; uses: a
+  ;   skipped if z flag is 1
 #macro cursor_adjust_scroll
+.beginscope
     ld a, [$2]
     $1 a, 1
     ld [$2], a
+.endscope
 #endmacro
 
   ; move cursor
     ld a, CURSOR_MOVE_SPEED * $3 
     ld [$1], a
 #endmacro
+
index 0a4ac402cf7249a0c0c6e01dce7270ec9e8064eb..6ac76f40e78fb976ce732f8612888d5acbfb337e 100644 (file)
@@ -61,6 +61,8 @@ handle_inputs:
   
     cursor_move_direction cursor_move_y, cursor_move_x, 1 
     
+    ld a, [cursor_y]
+    cp a, 0
     ; adjust scroll
     cursor_adjust_scroll add, scroll_move_y
 
@@ -72,6 +74,8 @@ handle_inputs:
 
     cursor_move_direction cursor_move_y, cursor_move_x, NEGATE
 
+    ld a, [cursor_y]
+    cp a, 0
     ; adjust scroll
     cursor_adjust_scroll sub, scroll_move_y
     
@@ -83,8 +87,12 @@ handle_inputs:
 
     cursor_move_direction cursor_move_x, cursor_move_y, NEGATE
 
+    ld a, [cursor_x]
+    cp a, 0
     ; adjust scroll
     cursor_adjust_scroll sub, scroll_move_x
+    
+    call z, cursor_abort_move
 
     ret
 @notleft:
@@ -94,6 +102,8 @@ handle_inputs:
 
     cursor_move_direction cursor_move_x, cursor_move_y, 1 
 
+    ld a, [cursor_x]
+    cp a, 0
     ; adjust scroll
     cursor_adjust_scroll add, scroll_move_x
 
@@ -125,3 +135,10 @@ cursor_move:
 
   pop af
   ret
+
+  ; aborts cursor move 
+  ; uses: a
+cursor_abort_move:
+  xor a, a
+  ld [cursor_move_timer], a
+  ret