+ ; skips actor if acto != who
+ ; returns:
+ ; nz: if actor is not who
+#macro actor_check_who
+ ; if who is current actor simply
+ ; skip
+ ld a, [act]
+ ld d, a
+ ld a, [who]
+ cp a, d
+#endmacro
+
+ ; skips a turn by calling turn_finish
+ ; and who_next
+#macro actor_skip_turn
+ call turn_finish
+ call who_next
+#endmacro
+
; function ptrs for each actor type
; inputs:
; bc: actor ptr
; actor_soam_ptr: next soam item
actor_update_table:
dw actor_update_null
+ dw actor_update_bat
dw actor_update_rock
actor_update_null:
- ; if who is current actor simply
- ; skip
- ld a, [act]
- ld b, a
- ld a, [who]
- cp a, b
+ actor_check_who
jr nz, @skip REL
- call turn_finish
- call who_next
+ actor_skip_turn
+@skip:
+ ret
+
+ ; bat actor
+actor_update_bat:
+ actor_check_who
+ jr nz, @skip REL
+
+ actor_skip_turn
@skip:
+ ; load oam ptr
+ ld a, [actor_soam_ptr]
+ ld h, a
+ ld a, [actor_soam_ptr+1]
+ ld l, a
+
+ inc bc ; bc = actor_y
+
+ ld a, [bc] ; a = y
+ ld [hl+], a ; set y
+ inc bc
+
+ ld a, [bc] ; a = x
+ ld [hl+], a ; set x
+
+ ld a, PLAYER_TILE_IDLE1
+ ld [hl+], a
+
+ xor a, a
+ ld [hl+], a
+
+ ; store soam ptr again
+ ld a, l
+ ld [actor_soam_ptr+1], a
+ ld a, h
+ ld [actor_soam_ptr], a
+
ret
+ ; rock actor
actor_update_rock:
-
- ld a, [act]
- ld d, a
- ld a, [who]
- cp a, d
+ actor_check_who
jr nz, @skip REL
- call turn_finish
- call who_next
+ actor_skip_turn
@skip:
ld a, h
ld [actor_soam_ptr], a
-
- ; check player collision
- ; if collision occured
- ; set collision flag
-
ret
; updates all active actors from