#endmacro
+ ; adjust player scroll
+ ; inputs:
+ ; $1: add/sub
+ ; $2: scroll_move_y/x
+ ; uses: a
+#macro cursor_adjust_scroll
+ ld a, [$2]
+ $1 a, 1
+ ld [$2], a
+#endmacro
+
+ ; move cursor
+ ; inputs:
+ ; $1: cursor_move_y/x -> move
+ ; $2: cursor_move_y/x -> clear
+ ; $2: -1/1
+#macro cursor_move_direction
+ xor a, a
+ ld [$2], a
+ ld a, CURSOR_MOVE_TIMER
+ ld [cursor_move_timer], a
+ ld a, CURSOR_MOVE_SPEED * $3
+ ld [$1], a
+#endmacro
input_held BTNDOWN
jr z, @notdown REL
- xor a, a
- ld [cursor_move_x], a
- ld a, CURSOR_MOVE_TIMER
- ld [cursor_move_timer], a
- ld a, CURSOR_MOVE_SPEED
- ld [cursor_move_y], a
-
+ cursor_move_direction cursor_move_y, cursor_move_x, 1
; adjust scroll
- ld a, [scroll_move_y]
- add a, 1
- ld [scroll_move_y], a
+ cursor_adjust_scroll add, scroll_move_y
ret
@notdown:
input_held BTNUP
jr z, @notup REL
- xor a, a
- ld [cursor_move_x], a
- ld a, CURSOR_MOVE_TIMER
- ld [cursor_move_timer], a
- ld a, CURSOR_MOVE_SPEED * NEGATE
- ld [cursor_move_y], a
+ cursor_move_direction cursor_move_y, cursor_move_x, NEGATE
; adjust scroll
- ld a, [scroll_move_y]
- sub a, 1
- ld [scroll_move_y], a
+ cursor_adjust_scroll sub, scroll_move_y
ret
@notup:
input_held BTNLEFT
jr z, @notleft REL
- xor a, a
- ld [cursor_move_y], a
- ld a, CURSOR_MOVE_TIMER
- ld [cursor_move_timer], a
- ld a, CURSOR_MOVE_SPEED * NEGATE
- ld [cursor_move_x], a
+ cursor_move_direction cursor_move_x, cursor_move_y, NEGATE
; adjust scroll
- ld a, [scroll_move_x]
- sub a, 1
- ld [scroll_move_x], a
+ cursor_adjust_scroll sub, scroll_move_x
ret
@notleft:
input_held BTNRIGHT
jr z, @notright REL
- xor a, a
- ld [cursor_move_y], a
- ld a, CURSOR_MOVE_TIMER
- ld [cursor_move_timer], a
- ld a, CURSOR_MOVE_SPEED
- ld [cursor_move_x], a
+ cursor_move_direction cursor_move_x, cursor_move_y, 1
; adjust scroll
- ld a, [scroll_move_x]
- add a, 1
- ld [scroll_move_x], a
+ cursor_adjust_scroll add, scroll_move_x
@notright: