.db 0x64,0x0, 0x64,0x0, 0x64,0x0, 0x64,0x0, 0x64,0x0, 0x64,0x0, 0x64,0x0, 0x64,0x0
.db 0x64,0x0, 0x64,0x0, 0x64,0x0, 0x64,0x0, 0x64,0x0, 0x64,0x0, 0x64,0x0, 0x64,0x0
.db 0x64,0x0, 0x64,0x0, 0x64,0x0, 0x64,0x0, 0x64,0x0, 0x64,0x0, 0x64,0x0, 0x64,0x0
-.db 0x64,0x0, 0x64,0x0, 0x64,0x0, 0x64,0x0, 0x64,0x0, 0x64,0x0, 0x64,0x0, 0x64,0x0
+.db 0x64,0x0, 0x64,0x0, 0x6b,0x1, 0x6b,0x1, 0x6b,0x1, 0x64,0x0, 0x64,0x0, 0x64,0x0
.db 0x64,0x0, 0x64,0x0, 0x64,0x0, 0x64,0x0, 0x64,0x0, 0x64,0x0, 0x64,0x0, 0x64,0x0
.db 0x64,0x0, 0x64,0x0, 0x64,0x0, 0x64,0x0, 0x64,0x0, 0x64,0x0, 0x64,0x0, 0x64,0x0
.db 0x64,0x0, 0x64,0x0, 0x64,0x0, 0x64,0x0, 0x64,0x0, 0x64,0x0, 0x64,0x0, 0x64,0x0
ldnull bc
ret
+ ; performs a generic collision test
+ ; before a move is attempted
+ ; ret on nz
+ ; inputs:
+ ; $1: dec/inc instruction
+ ; $2: collision mask for tile
+#macro unit_test_collision
+ ; perform tile collision check
+ push de
+ call unit_get_pos
+ $1
+ call map_get_tile
+ and a, $2
+ pop de
+ ret nz
+#endmacro
+
; moves a unit up
; moves are aborted
; if no more initiative is left
call unit_use_move
ret z
+ ; y - 1
+ unit_test_collision dec b, CF_COLLISION
+
ld hl, act_pos_y
add hl, de
; hl = actor y
unit_try_move_down:
call unit_use_move
ret z
+
+ ; y + 1
+ unit_test_collision inc b, CF_COLLISION
ld hl, act_pos_y
add hl, de
unit_try_move_left:
call unit_use_move
ret z
+
+ ; x - 1
+ unit_test_collision dec c, CF_COLLISION
ld hl, act_pos_x
add hl, de
unit_try_move_right:
call unit_use_move
ret z
+
+ ; x + 1
+ unit_test_collision inc c, CF_COLLISION
ld hl, act_pos_x
add hl, de
; inputs:
; de: unit
; returns:
- ; a: flags
- ; b: tile index
-unit_get_tile:
+ ; bc: y/x
+unit_get_pos:
ld hl, act_pos_y
add hl, de ; hl = pos y
ld a, [hl+]
ld b, a ; b = y
ld a, [hl]
ld c, a ; c = x
- jp map_get_tile
+ ret
unit_demo_1:
st_def 0x00, unit_demo_1_init, st_unit_idle
unit_demo_2:
st_def 0x00, unit_demo_1_init, st_unit_idle
act_def ACT_T_DEMO_1, 0, 3, 3, 0
- act_stat_def 1, 2, 3, 0, 0, 0, 1, 5
+ act_stat_def 1, 2, 3, 0, 0, 0, 0, 5
act_inventory_empty
act_equipment_empty
act_effects_empty