ld a, b
ld [tmp_act_direction], a
+ ; a = direction
+ call actor_test_movement_write_points
; check all static rectangles
ld hl, rectangles
; hl = actor already
ld a, 1
ret
+
+ ; writes a point to a rectangle
+ ; inputs:
+ ; hl: rectangle
+ ; bc: tmp_rect_points ptr
+ ; $1 rect_tr,bl,br,tl
+#macro act_test_movement_write_point_at
+ push hl
+ push bc
+ call $1
+ pop bc
+ pop hl
+
+ ld a, d
+ ld [bc], a
+ inc bc
+ ld a, e
+ ld [bc], a
+ inc bc
+#endmacro
+
+ ; writes tmp rect points to
+ ; tmp_rect_points. only writes 2 points
+ ; based on the chosen direction
+ ; inputs:
+ ; a: direction
+ ; tmp_rect: the rectangle
+actor_test_movement_write_points:
+ ld hl, tmp_rect
+ ld bc, tmp_rect_points
+
+ cp a, DIRDOWN
+ jp z, @down
+ cp a, DIRLEFT
+ jp z, @left
+ cp a, DIRRIGHT
+ jp z, @right
+
+ ; default case: up
+@up:
+ act_test_movement_write_point_at rect_tl
+ act_test_movement_write_point_at rect_tr
+ ret
+@down:
+ act_test_movement_write_point_at rect_bl
+ act_test_movement_write_point_at rect_br
+ ret
+@right:
+ act_test_movement_write_point_at rect_br
+ act_test_movement_write_point_at rect_tr
+ ret
+@left:
+ act_test_movement_write_point_at rect_bl
+ act_test_movement_write_point_at rect_tl
+ ret
; tests a single rectangle against an actor
; based on the current direction only 2 points are tested
tmp_rect: .adv r_size
tmp_rect_mask: .adv 1
+ ; temporary points
+ ; has enough space for 4 points
+ ; store pre-calculated points here for collision checking
+tmp_rect_points: .adv 4 * 2
+
; temporary actor direction mask
tmp_act_direction: .adv 1