#define ACT_GUARD_MOVE_FRAMES 40
+act_guard_state_table:
+ dw act_guard_walk_right
+ dw act_guard_shoot
+ dw act_guard_walk_left
+
; updates the guard enemy
; inputs:
; de: actor ptr
ld hl, act_state
add hl, de
ld a, [hl]
- cp a, ACT_GUARD_WALK_RIGHT
- jp z, act_guard_walk_right
-
- cp a, ACT_GUARD_SHOOT
- jp z, act_guard_shoot
-
- cp a, ACT_GUARD_WALK_LEFT
- jp z, act_guard_walk_left
+ ld hl, act_guard_state_table
+ jp call_tbl
ret
@despawn:
; a: table index
; [hl]: pointer to function ptr table
; Note: do not call, just jp
+ ; uses:
+ ; hl, a, bc
call_tbl:
add a, a ; * 2
- ld d, 0
- ld e, a
- add hl, de ; hl + index * 2
+ ld b, 0
+ ld c, a
+ add hl, bc ; hl + index * 2
; hl = ptr to routine table
; => load functon ptr into hl