; $1: point name
; returns:
; b/c: y/x tile position
-#macro _act_tile_col_load_pt
+#macro _act_col_load_pt
ld a, [$1]
- div16 a
ld b, a
ld a, [$1+1]
- div16 a
ld c, a
#endmacro
- ; test direction routines:
- ; preserve: de
-_act_test_tile_left_collision:
- push de
-
- ; top left point
- _act_tile_col_load_pt col_point_tl
+ ; checks collision
+ ; inputs:
+ ; $1: point to check
+ ; $2: label to jump to (jr)
+#macro _act_tile_col_check
+ _act_col_load_pt $1
+ div16 b
+ div16 c
call map_get_tile
ld de, t_flags
add hl, de
ld a, [hl]
and a, TF_WALL
- jr nz, @collision REL
+ jr nz, $2 REL
+#endmacro
+
+ ; test direction routines:
+ ; preserve: de
+_act_test_tile_left_collision:
+ push de
- ; bottom left point
- _act_tile_col_load_pt col_point_bl
+ ; top left point
+ _act_tile_col_check col_point_tl, @collision
- call map_get_tile
- ld de, t_flags
- add hl, de
- ld a, [hl]
- and a, TF_WALL
- jr nz, @collision REL
+ ; bottom left point
+ _act_tile_col_check col_point_bl, @collision
pop de
ret
_act_test_tile_right_collision:
push de
+ ; top right point
+ _act_tile_col_check col_point_tr, @collision
+
+ ; bottom right point
+ _act_tile_col_check col_point_br, @collision
+
+ pop de
+ ret
+@collision:
pop de
+ call act_rollback_pos_x
ret
_act_test_tile_up_collision:
push de
+
+ ; top left point
+ _act_tile_col_check col_point_tl, @collision
+
+ ; top right point
+ _act_tile_col_check col_point_tr, @collision
+
pop de
ret
+@collision:
+ pop de
+ call act_rollback_pos_y
+ ret
_act_test_tile_down_collision:
push de
+
+ ; bottom left point
+ _act_tile_col_check col_point_bl, @collision
+
+ ; bottom rihgt point
+ _act_tile_col_check col_point_br, @collision
+
+ pop de
+ ret
+@collision:
pop de
+ call act_rollback_pos_y
ret
; update routines for each actor
.db TWL, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS
.db TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS
.db TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS
- .db TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS
+ .db TGS, TGS, TGS, TGS, TWL, TGS, TGS, TGS, TGS, TGS
.db TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS
.db TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS
.db TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TWL