From: Lukas Krickl Date: Thu, 10 Apr 2025 15:27:55 +0000 (+0200) Subject: buildings: cusros can now call the building state X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=f86ce0ecd154cc80b02a3278f5b121d9b08e1bcf;p=gbrg%2F.git buildings: cusros can now call the building state --- diff --git a/src/buildings.s b/src/buildings.s index c601cbd..3ad7d43 100644 --- a/src/buildings.s +++ b/src/buildings.s @@ -4,7 +4,7 @@ ; e.g. not enough resources, not enough space ; executes cursor_state state machine update building_build: - ld de, cursor_state + ld de, building_state call st_update ret @@ -13,6 +13,7 @@ build_warehouse: ret build_road: + call cursor_get_cell ldnull bc ret diff --git a/src/player.s b/src/player.s index 39b8758..feebc68 100644 --- a/src/player.s +++ b/src/player.s @@ -154,10 +154,9 @@ handle_inputs: input_just BTNA jr z, @not_a REL - - ; place tile at cursor position - call cursor_place_tile + ; next state: building state + call building_build ldnull bc ret @not_a: @@ -214,10 +213,12 @@ try_abort_move_at: cp a, b ret - ; places the current selection - ; at cursor_y/x - ; aborts if the tiel will not fit -cursor_place_tile: + ; gets the current cell + ; the cursor is pointing at + ; at cursor_y/x + ; returns: + ; hl: cell ptr +cursor_get_cell: ; find the cell the cursor has selected ld hl, state_cells diff --git a/src/ui.s b/src/ui.s index 0ed272c..30eb95a 100644 --- a/src/ui.s +++ b/src/ui.s @@ -179,7 +179,7 @@ ui_building_selector_inputs: ld a, [hl] ld d, a ; de = source of state ptr - ld hl, cursor_state + ld hl, building_state ld bc, st_size call memcpy diff --git a/src/wram.s b/src/wram.s index 349ca5b..b587f8e 100644 --- a/src/wram.s +++ b/src/wram.s @@ -19,6 +19,9 @@ game_mode: .adv st_size ; cursor state cursor_state: .adv st_size cursor_preview_tile: .adv 1 + + ; selected building state +building_state: .adv st_size ; actors ; actors are state machines