From: Lukas Krickl Date: Tue, 20 May 2025 12:53:22 +0000 (+0200) Subject: wip: unit switching bugfixing X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=45aad93fe2d69e595381d9dd81700f190b169da0;p=gbrg%2F.git wip: unit switching bugfixing The switching code is still broken, but now at least the correct init value and actor ptr are stored by the end :^) --- diff --git a/src/map.s b/src/map.s index 1aa148d..b103d87 100644 --- a/src/map.s +++ b/src/map.s @@ -114,7 +114,8 @@ map_load_demo_actors: ld bc, act_size call memcpy - call unit_next_no_current + call unit_next_no_current + call ui_unit_need_draw ret diff --git a/src/ui.s b/src/ui.s index b305c00..e3d2882 100644 --- a/src/ui.s +++ b/src/ui.s @@ -41,8 +41,6 @@ ui_display_current_unit: ; this should only be called ; during blanking ui_draw: - call ui_display_current_unit - ld a, [draw_flags] xor a, DRAWF_UPDATE_UI ld [draw_flags], a diff --git a/src/unit.s b/src/unit.s index 201277a..564dcb6 100644 --- a/src/unit.s +++ b/src/unit.s @@ -402,14 +402,17 @@ unit_next_no_current: ; than the previous actor ld de, act_init add hl, de - ld a, [hl] - ld d, a ; b = init of new actor ld a, [unit_next_best_init] + cp a, 0 ; if prev best is 0 proceed anyway + ld d, a ; d = previous best init + ld a, [hl] ; a = init of new actor + jr z, @first_hit REL ; on first match + ; check if this init value is better ; if not proceed cp a, d - jr nc, @skip REL ; d > a? - + jr c, @skip REL ; d > a? +@first_hit: ; otherwise store new init value and hl pop hl push hl @@ -478,7 +481,7 @@ unit_reset_all_moves: unit_demo_1: st_def 0x00, unit_demo_1_init, st_unit_demo_1_idle - act_def ACT_T_DEMO_1, 0, 1, 2, 3, 4, 5, 2, 2, 0 + act_def ACT_T_DEMO_1, 0, 1, 2, 3, 4, 6, 2, 2, 0 act_st_def NULL, NULL, st_unit_demo_1_update, st_unit_demo_1_idle diff --git a/src/update.s b/src/update.s index 95c051c..2c83a23 100644 --- a/src/update.s +++ b/src/update.s @@ -9,6 +9,7 @@ update_game: ld a, [draw_flags] and a, DRAWF_UPDATE_UI call nz, ui_draw + call ui_display_current_unit ld hl, p0_units call units_update