From: Lukas Krickl Date: Tue, 1 Apr 2025 19:25:41 +0000 (+0200) Subject: cursor: Added preview tile X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=e0ff6928129d1b2f1a9e07a6d4f2398fba4d9e01;p=gbrg%2F.git cursor: Added preview tile --- diff --git a/src/buildings.s b/src/buildings.s index a8d365b..bd117e1 100644 --- a/src/buildings.s +++ b/src/buildings.s @@ -4,6 +4,8 @@ ; e.g. not enough resources, not enough space ; executes cursor_state state machine update building_build: + ld de, cursor_state + call st_update ret build_warehouse: diff --git a/src/player.s b/src/player.s index a67d4af..aa75cb0 100644 --- a/src/player.s +++ b/src/player.s @@ -12,6 +12,7 @@ player_init: ld hl, actor_player ld bc, st_size call memcpy + ret ; update the player @@ -56,8 +57,26 @@ player_draw_cursor: xor a, a ld [hl+], a - ldnull bc + ; preview tile + ld hl, PLAYER_SPRITE1+oamsize + + ld a, [cursor_y] + add a, OBJ_OFF_Y + sub a, b + ld [hl+], a + + ld a, [cursor_x] + add a, OBJ_OFF_X + sub a, c + ld [hl+], a + + ld a, [cursor_preview_tile] + ld [hl+], a + xor a, a + ld [hl+], a + + ldnull bc ret handle_inputs: diff --git a/src/ui.s b/src/ui.s index 4c1e15d..0ed272c 100644 --- a/src/ui.s +++ b/src/ui.s @@ -22,6 +22,13 @@ ui_cursor_label_table: dw STR_FARM dw STR_LUMBER + ; tile to display for each selection +ui_cursor_tile_table: + .db UI_TILE_WAREHOUSE + .db UI_TILE_ROAD + .db UI_TILE_FARM + .db UI_TILE_LUMBER + ; converts from UI cursor position ; to building state ui_to_building_selecction_table: @@ -176,6 +183,15 @@ ui_building_selector_inputs: ld bc, st_size call memcpy + ; load tile for preview + ld hl, ui_cursor_tile_table + ld d, 0 + ld a, [ui_cursor_pos] + ld e, a + add hl, de + ld a, [hl] + ld [cursor_preview_tile], a + ld bc, st_ui_buildung_selector_exit ret @not_a: diff --git a/src/wram.s b/src/wram.s index e9f6fa9..9619372 100644 --- a/src/wram.s +++ b/src/wram.s @@ -18,6 +18,7 @@ game_mode: .adv st_size ; cursor state cursor_state: .adv st_size +cursor_preview_tile: .adv 1 ; actors ; actors are state machines