This fix currently pauses all obj updates while a unit is moving.
This is not a great solution and will need to be addressed properly
later.
State machine transitions are causing unit redraws to not happen.
Maybe a proper solution would be to have a few sprites for units in
motion that are not affected by the regular unit updates.
; draw flags
.se 1
.de DRAWF_UPDATE_UI, 1
+ ; if set to 1, return
+ ; an invalid object from soam
+ ; when units want to draw
+.de DRAWF_SKIP_UNIT_OBJS, 2
; gameplay flags
.se 1
; returns;
; hl: current unit sprite
load_unit_obj:
+ ld a, [draw_flags]
+ and a, DRAWF_SKIP_UNIT_OBJS
+ jr nz, @load_unit_empty REL
+
ld a, [unit_sprite]
ld [unit_sprite], a
ret
+@load_unit_empty:
+ ld hl, empty_oam
+ ret
; inputs:
; de: actor
unit_demo_1_delay_to_active:
- push de
- call unit_demo_1_draw
- pop de
jp unit_delay_to_active
; draws any unit
dec a
ld [hl], a
+
+ call unit_pause_objs
+
; we need the z flag to not be set ehre
; so just do something that will always unset it
or a, 1
; inputs:
; de: unit
unit_delay_to_active:
+ call unit_resume_objs
ld hl, act_moves
add hl, de ; hl = moves
ld a, [hl]
ldnull bc
ret
+ ; pauses object redraws
+ ; until unpause is called
+unit_pause_objs:
+ ld a, [draw_flags]
+ or a, DRAWF_SKIP_UNIT_OBJS
+ ld [draw_flags], a
+ ret
+
+ ; resumes obj updates
+unit_resume_objs:
+ ld a, [draw_flags]
+ and a, ~DRAWF_SKIP_UNIT_OBJS & 0xFF
+ ld [draw_flags], a
+ ret
unit_demo_1:
st_def 0x00, unit_demo_1_init, st_unit_demo_1_idle
draw_flags: .adv 1
gameplay_flags: .adv 1
+; dummy oam
+; same memory as empty_unit
+empty_oam: .adv 0
; a dummy unit
p_empty_unit: .adv act_size