@no_player:
ld [who], a
- ; advance some other values
- ; related to the next turn starting
- call anim_next
-
ret
; each frame the latest animation is
; updated
- ; animation functions:
- ; inputs:
- ; hl: actor ptr
- ; bc: anim ptr
-
- ; sets up animation ptr
-anim_init:
- ld hl, anim_table
- ld a, l
- ld [anim_ptr], a
- ld a, h
- ld [anim_ptr+1], a
- ret
-
- ; advances animation ptr to
- ; its next value
-anim_next:
- ld a, [who]
- cp a, 0
- jp z, anim_init
-
- ld a, [anim_ptr]
- ld l, a
- ld a, [anim_ptr+1]
- ld h, a
-
- ld de, anim_size
- add hl, de ; hl = next animation ptr
-
- ld a, l
- ld [anim_ptr], a
- ld a, h
- ld [anim_ptr+1], a
-
- ret
-
anim_walk_north:
ret
.de GM_PAUSE, 1
.de GAME_OVER, 1
-
- ; animation flags enum
-.se 1
-
-
-; animation table entries
+ ; struct state
.se 0
-.de ANIM_TNOP, 1
-.de ANIM_TWALK_SIMPLE, 1
+.de sm_state, 1
+.de sm_param, 2
+.de sm_size, 0
- ; anim entry struct
-.se 0
-.de anim_type, 1
-.de anim_step, 1
-.de anim_flags, 1
-.de anim_p0, 1
-.de anim_size, 0
+; state table entries
+.se 1
+.de smt_end_turn, 1
#include "audio.s"
#include "animation.s"
#include "combat.s"
+#include "state.s"
#include "tiles.inc"
call memset
call rand_init
- call anim_init
; copy shadow oam dma function
ld de, shadow_oam_to_oam
ld e, a ; e = target x + 8 to center on tile
call player_collision_check
+@update_end:
@skip_input:
; hl should be player_y here
--- /dev/null
+; the state machine can be used by the current actor (who)
+; to store their current state and call small re-usable routines
+
+ ; table of all states
+state_table:
+ dw sm_nop
+ dw sm_end_turn
+
+sm_nop:
+ ret
+
+sm_end_turn:
+ call sm_clear
+ ret
+
+ ; clears the state machine
+sm_clear:
+ xor a, a
+ ld hl, state_machine
+ ld a, [hl+]
+ ld a, [hl+]
+ ld a, [hl+]
+ ret
anim_target_y: .adv 1
anim_target_x: .adv 1
- ; pointing to current animation
- ; advanced in who_next
- ; l/h ptr
-anim_ptr: .adv 2
- ; 1 animation buffer for each actor + player
-anim_table: .adv anim_size * (ACTORS_MAX + 1)
+state_machine: .adv sm_size
; collision tile tmp values
ct_poy: .adv 1