#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
; inputs:
; hl: pointer to player memory
player_update:
- ; check cursor movement
- ld a, [cursor_move_timer]
- cp a, 0
- call nz, cursor_move_delay
- call z, handle_inputs
-
+ call handle_inputs
+ push bc
+ call player_draw_cursor
+ pop bc
+ ret
+ ; updates the cursor
+ ; sprites
+player_draw_cursor:
@draw_cursor:
; draw cursor
ld a, [scroll_y]
jr z, @notdown REL
call try_abort_move_down
- ret z
+ jp z, @done
cursor_move_direction cursor_move_y, cursor_move_x, 1
cursor_adjust_scroll add, scroll_move_y
call cursor_move
+ ld bc, st_cursor_delay
ret
@notdown:
jr z, @notup REL
call try_abort_move_up
- ret z
+ jr z, @done REL
cursor_move_direction cursor_move_y, cursor_move_x, NEGATE
cursor_adjust_scroll sub, scroll_move_y
call cursor_move
+ ld bc, st_cursor_delay
ret
@notup:
jr z, @notleft REL
call try_abort_move_left
- ret z
+ jr z, @done REL
cursor_move_direction cursor_move_x, cursor_move_y, NEGATE
cursor_adjust_scroll sub, scroll_move_x
call cursor_move
-
+ ld bc, st_cursor_delay
ret
@notleft:
jr z, @notright REL
call try_abort_move_right
- ret z
+ jr z, @done REL
cursor_move_direction cursor_move_x, cursor_move_y, 1
cursor_adjust_scroll add, scroll_move_x
call cursor_move
+ ld bc, st_cursor_delay
+ ret
@notright:
-
- ret
-
- ; updates cursor move delay
- ; cursor move delay timer--
-cursor_move_delay:
- ld a, [cursor_move_timer]
- dec a
- ld [cursor_move_timer], a
+@done:
+ ldnull bc
ret
cursor_move:
cp a, 0
jr z, @set_next_state_default REL
+ ; hl = actor ptr
+
; set returned state
push bc
pop de ; de = src
ld bc, st_size
- jp memcpy
+ call memcpy
+ ret
@set_next_state_default:
; set default state
st_cursor:
st_def 0x00, player_update, st_cursor
-
+st_cursor_draw:
+ st_def 0x00, player_draw_cursor, st_cursor
st_cursor_delay:
- st_def CURSOR_MOVE_TIMER, st_null, st_cursor
+ st_def CURSOR_MOVE_TIMER, st_null_fn, st_cursor