cursor: working on making cursor movement better
authorLukas Krickl <lukas@krickl.dev>
Thu, 20 Mar 2025 18:51:28 +0000 (19:51 +0100)
committerLukas Krickl <lukas@krickl.dev>
Thu, 20 Mar 2025 18:51:28 +0000 (19:51 +0100)
Mostly trying to improvie cursor sprite positoning when scrolling.

src/player.s
src/update.s
src/video.s

index 2587b2c38f88e52ff73fc45d899b25b8c2efa876..1dd2db90fd01e2276e81687a95c49950c6dfc0a8 100644 (file)
@@ -4,7 +4,7 @@
 .def int CURSOR_TILE = 0x04
 
 #define CURSOR_MOVE_TIMER TILE_SIZE
-#define CURSOR_MOVE_SPEED 1
+#define CURSOR_MOVE_SPEED 8
 
   ; init the player 
 player_init:
@@ -112,32 +112,31 @@ handle_inputs:
 
 cursor_move:
   push af
-  ld hl, cursor
-  ; hl = cursor_y
-
-  ld b, [hl]
-  ld a, [cursor_move_y]
-  add a, b
-  ld [cursor_y], a
-
-  ; hl = cursor_x
-  inc hl
-  ld b, [hl]
-  ld a, [cursor_move_x]
-  add a, b
-  ld [cursor_x], a
-  inc hl ; hl = cursor_move_timer
-
-  ld a, [hl]
+
+
+  ld a, [cursor_move_timer]
   dec a
-  ld [hl], a
+  ld [cursor_move_timer], a
+  cp a, 0
+  jr nz, @done REL
+
+  ; if timer is 0 apply movement 
+  ; and jump to next tile
+    ld a, [cursor_y]
+    ld b, a
+
+    ld a, [cursor_move_y]
+    add a, b
+    ld [cursor_y], a
 
+    ld a, [cursor_x]
+    ld b, a
+
+    ld a, [cursor_move_x]
+    add a, b
+    ld [cursor_x], a
+
+@done:
   pop af
   ret
 
-  ; aborts cursor move 
-  ; uses: a
-cursor_abort_move:
-  xor a, a
-  ld [cursor_move_timer], a
-  ret
index 06751b8b7fe0676fea49aa8e6b7090b19c4e1ee3..fc5831d522c0be8881ed0ac756d44131bb41913c 100644 (file)
@@ -13,6 +13,8 @@ update_game:
 
   call player_update
   call sim_update 
+  
+  call scroll_update
 
   ret
 
index f288585bdc3689dc52d061618de9e6437ebefa3b..d9ad061cb034846b516940ebe2ef5b7e554e9236 100644 (file)
@@ -9,7 +9,7 @@ vblank:
   call poll_inputs
   call ui_draw
 
-  call scroll_update
+  call scroll_write
 
   ld a, 1
   ld [frame_ready], a
@@ -77,6 +77,11 @@ scroll_update:
     ld [scroll_x], a
 @no_scroll_left:
 @done:
+  ret 
+
+  ; writes scroll to scroll registers
+  ; only call during blank
+scroll_write:
   ld a, [scroll_y]
   ld [RSCY], a