From: Lukas Krickl Date: Wed, 21 May 2025 15:58:02 +0000 (+0200) Subject: unit: working on fixing sprite flickering when moving X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=235518fdc911c5d05ddb9cffedff71b3e4beaf73;p=gbrg%2F.git unit: working on fixing sprite flickering when moving --- diff --git a/src/map.s b/src/map.s index e4e1265..43a9503 100644 --- a/src/map.s +++ b/src/map.s @@ -113,6 +113,11 @@ map_load_demo_actors: ld hl, p0_units + act_size ld bc, act_size call memcpy + + ld de, unit_demo_3 + ld hl, p0_units + act_size * 2 + ld bc, act_size + call memcpy ld de, p_empty_unit call unit_next_request diff --git a/src/unit.s b/src/unit.s index ca3d388..ffe9524 100644 --- a/src/unit.s +++ b/src/unit.s @@ -81,6 +81,14 @@ unit_demo_1_draw: ldnull bc 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 ; inputs: ; de: actor @@ -137,7 +145,7 @@ unit_handle_inputs: jr z, @notup REL call unit_try_move_up - ld bc, st_unit_delay_to_active + ld bc, st_unit_demo_1_delay_to_active ret @notup: @@ -145,7 +153,7 @@ unit_handle_inputs: jr z, @notdown REL call unit_try_move_down - ld bc, st_unit_delay_to_active + ld bc, st_unit_demo_1_delay_to_active ret @notdown: @@ -153,7 +161,7 @@ unit_handle_inputs: jr z, @notleft REL call unit_try_move_left - ld bc, st_unit_delay_to_active + ld bc, st_unit_demo_1_delay_to_active ret @notleft: @@ -161,7 +169,7 @@ unit_handle_inputs: jr z, @notright REL call unit_try_move_right - ld bc, st_unit_delay_to_active + ld bc, st_unit_demo_1_delay_to_active ret @notright: @@ -571,7 +579,12 @@ unit_demo_1: unit_demo_2: st_def 0x00, unit_demo_1_init, st_unit_demo_1_idle - act_def ACT_T_DEMO_1, 0, 1, 2, 3, 0, 5, 3, 3, 0 + act_def ACT_T_DEMO_1, 0, 1, 2, 3, 1, 5, 3, 3, 0 + act_st_def NULL, NULL, st_unit_demo_1_update, st_unit_demo_1_idle + +unit_demo_3: + st_def 0x00, unit_demo_1_init, st_unit_demo_1_idle + act_def ACT_T_DEMO_1, 0, 1, 2, 3, 0, 5, 4, 4, 0 act_st_def NULL, NULL, st_unit_demo_1_update, st_unit_demo_1_idle st_unit_demo_1_update: @@ -580,8 +593,8 @@ st_unit_demo_1_update: st_unit_demo_1_idle: st_def 0x00, unit_demo_1_idle, st_unit_demo_1_idle -st_unit_delay_to_active: - st_def CURSOR_MOVE_TIMER, unit_delay_to_active, st_unit_switch_to_active +st_unit_demo_1_delay_to_active: + st_def CURSOR_MOVE_TIMER, unit_demo_1_delay_to_active, st_unit_switch_to_active st_unit_switch_to_active: st_def 0, unit_switch_to_active, st_unit_switch_to_active