push de
call unit_handle_inputs
pop de
-
+
+ push de
+ call unit_scroll_center
+ pop de
+
push bc
call unit_demo_1_draw
pop bc
add hl, de
; hl = actor y
ld a, [hl]
+ cp a, 0 ; upper bound
+ ret z
+
dec a
ld [hl], a
add hl, de
; hl = actor y
ld a, [hl]
+ cp a, MAP_H - 1 ; lower bound
+ ret z
+
inc a
ld [hl], a
ret
add hl, de
; hl = actor x
ld a, [hl]
+ cp a, 0 ; left bound
+ ret z
+
dec a
ld [hl], a
ret
add hl, de
; hl = actor x
ld a, [hl]
+ cp a, MAP_W - 1 ; right bound
+ ret z
+
inc a
ld [hl], a
ret
; inputs:
; de: actor
unit_scroll_center:
+ ld hl, act_pos_y
+ add hl, de
+ ; hl = pos y
+ ld a, [hl+]
+ mul8 a
+ ld [scroll_y], a
+
+ ld a, [hl]
+ mul8 a
+ ld [scroll_x], a
+
+
ret
; switches a unit to active state