; 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
ret
build_road:
+ call cursor_get_cell
ldnull bc
ret
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:
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
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
; 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