From ce12927fb9186b251ffdf02f49b0b42981b70b9a Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Tue, 20 May 2025 05:57:52 +0200 Subject: [PATCH] unit: wip unit selector --- src/map.s | 5 ++++- src/ui.s | 15 +++++++++++++++ src/unit.s | 22 +++++++++++++++++++--- 3 files changed, 38 insertions(+), 4 deletions(-) diff --git a/src/map.s b/src/map.s index 1e777e6..1aa148d 100644 --- a/src/map.s +++ b/src/map.s @@ -109,10 +109,13 @@ map_load_demo_actors: ld bc, act_size call memcpy - ld de, unit_demo_1 + ld de, unit_demo_2 ld hl, p0_units + act_size ld bc, act_size call memcpy + + call unit_next_no_current + ret #include "default_map.s" diff --git a/src/ui.s b/src/ui.s index 5b5f521..b305c00 100644 --- a/src/ui.s +++ b/src/ui.s @@ -24,10 +24,25 @@ ui_unit_need_draw: ret + ; displays the current unit +ui_display_current_unit: + ld a, [ui_draw_actor] + ld e, a + ld a, [ui_draw_actor+1] + ld d, a + + ld b, CURSOR_TILE + ld c, 0 + call unit_generic_draw + + ret + ; update the UI ; 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 6e13caf..201277a 100644 --- a/src/unit.s +++ b/src/unit.s @@ -64,6 +64,12 @@ unit_demo_1_update: call unit_demo_1_draw pop bc ret + + ; inputs + ; de: actor +unit_demo_1_idle: + call unit_demo_1_draw + ret ; inputs ; de: actor @@ -354,6 +360,7 @@ unit_next: ld hl, act_moves add hl, de ld [hl], 0 ; moves = 0 +unit_next_no_current: @again: xor a, a ld [unit_next_best_init], a @@ -470,13 +477,22 @@ unit_reset_all_moves: unit_demo_1: - st_def 0x00, unit_demo_1_init, st_unit_demo_1_update + 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_st_def NULL, NULL, st_unit_demo_1_update, NULL - + act_st_def NULL, NULL, st_unit_demo_1_update, st_unit_demo_1_idle + + +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, 4, 5, 3, 3, 0 + act_st_def NULL, NULL, st_unit_demo_1_update, st_unit_demo_1_idle + st_unit_demo_1_update: st_def 0x00, unit_demo_1_update, 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: st_def CURSOR_MOVE_TIMER, st_null_fn, st_unit_switch_to_active -- 2.30.2