From: Lukas Krickl Date: Wed, 21 May 2025 16:23:22 +0000 (+0200) Subject: unit: implemented a temporary fix for unit redrawing failing X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=afdbd064d86e3148edf9661c40ecd3667f947c90;p=gbrg%2F.git unit: implemented a temporary fix for unit redrawing failing 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. --- diff --git a/src/defs.s b/src/defs.s index 232845a..4e97540 100644 --- a/src/defs.s +++ b/src/defs.s @@ -38,6 +38,10 @@ ; 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 diff --git a/src/sys.s b/src/sys.s index 500aac4..078879d 100644 --- a/src/sys.s +++ b/src/sys.s @@ -65,6 +65,10 @@ load_scroll: ; 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] @@ -79,3 +83,6 @@ load_unit_obj: ld [unit_sprite], a ret +@load_unit_empty: + ld hl, empty_oam + ret diff --git a/src/unit.s b/src/unit.s index ffe9524..c856bf2 100644 --- a/src/unit.s +++ b/src/unit.s @@ -84,9 +84,6 @@ unit_demo_1_draw: ; 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 @@ -267,6 +264,9 @@ unit_use_move: 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 @@ -562,6 +562,7 @@ unit_reset_all_moves: ; inputs: ; de: unit unit_delay_to_active: + call unit_resume_objs ld hl, act_moves add hl, de ; hl = moves ld a, [hl] @@ -570,6 +571,20 @@ unit_delay_to_active: 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 diff --git a/src/wram.s b/src/wram.s index c7cc74b..3940f9b 100644 --- a/src/wram.s +++ b/src/wram.s @@ -35,6 +35,9 @@ bg_update_queue: .adv bge_size * BGE_MAX 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