st_def 0x00, unit_player_init, st_unit_idle
act_def ACT_T_DEMO_1, 0, 2, 2, 0
act_stat_def1 1, 1, 1, 1, 1
- act_stat_def2 1, 1, 1, 1, 1, 1, 1, 48
+ act_stat_def2 1, 1, 1, 1, 1, 1, 1, 90
act_skill_def_empty
act_inventory_empty
act_equipment_empty
ld a, CF_COLLISION
ret
#undefine scratch_loop_i
-
- ; transitions a unit
- ; to a movement animation
- ; the animation time is dependant on movement
- ; speed (100-stat_calc_speed)
- ; the end-state of the move_animation should
- ; clear rt_sub_tile to 0
+
+ ; sets st_unit_delay_to_active speed to unit's move speed
+ ; (STAT_MAX-stat_calc_speed)
; inputs:
; de: actor
; a: mask for rt_sub_tile
; rt_subtile |= a
-unit_transition_to_move_animation:
+unit_set_delay_to_active_speed:
+ push de
+ ld hl, act_rt_sub_tile
+ add hl, de ; hl = ptr to sub_tile
+
+ ld b, a
+ ld a, [hl]
+ or a, b ; apply the mask
+ ld [hl], a ; store new value
+
+ ; get movement speed
+ pop de
+ call stat_calc_speed
+ ld de, st_unit_delay_to_active ; de == st_time
+ ; this overwrites the wait time
+ ; by calculating the movement speed
+ ; and subtracting it from STAT_MAX
+ ld b, a ; b = current speed
+ ld a, STAT_MAX
+ ; a - b
+ sub a, b
+ ld [de], a ; delay timer is now speed
ret
; moves a unit up
; not bits set
ld a, 0b00000000
- call unit_transition_to_move_animation
+ call unit_set_delay_to_active_speed
ret
; set down bit
ld a, 0b10000000
- call unit_transition_to_move_animation
+ call unit_set_delay_to_active_speed
ret
; no bits set
ld a, 0b00000000
- call unit_transition_to_move_animation
+ call unit_set_delay_to_active_speed
ret
; set right bit
ld a, 0b01000000
- call unit_transition_to_move_animation
+ call unit_set_delay_to_active_speed
ret
st_unit_idle:
st_def 0x00, unit_idle, st_unit_idle
-st_unit_delay_to_active:
+ ; template for st_unit_delay_to_active
+ ; in wram
+st_unit_delay_to_active_template:
st_def 8, unit_delay_to_active, st_unit_switch_to_active
st_unit_delay_to_active_fast:
; ptr to actor for next UI update
ui_draw_actor: .adv 2
+ ; can be used for custom state transtions
+ ; simple write state info to this location
+ ; and return st_custom
+st_custom: .adv st_size
+ ; it is common for delay to active to have a custom
+ ; timer to simulate movement speed
+ ; this is a valid delay state and should only be written to
+ ; to change its timer
+st_unit_delay_to_active: .adv st_size
+
; game state
; this region holds the entire game state
; everything thats needed for a savme game should be