; if timer is 0 apply movement
; and jump to next tile
+ call try_abort_move
+
ld a, [cursor_y]
ld b, a
pop af
ret
+try_abort_move:
+ ld b, CURSOR_MIN_X
+ ld c, CURSOR_MOVE_SPEED * NEGATE
+ ld hl, cursor_x
+ ld de, cursor_move_x
+ call try_abort_move_at
+
+ ret
+
+ ; aborts a move direciton
+ ; inputs:
+ ; b: compare variable (e.g. min or max value)
+ ; c: move direction compare value (e.g. move + or -)
+ ; hl: position ptr
+ ; de: move variable to set to 0
+try_abort_move_at:
+ ; do not abort if position is wrong
+ ld a, [hl]
+ cp a, b
+ ret nz
+
+ ; do not abort if direction is wrong
+ ld a, [de]
+ cp a, c
+ ret nz
+
+ xor a, a
+ ld [de], a
+
+ ret
ret
; updates scroll based on scroll_move_y/x
+ ; do nothing if scroll would move oob
scroll_update:
ld a, [cursor_move_timer]
cp a, 0