This is the first step to being able to place buildings
--- /dev/null
+ ; places a building at the current cursor position
+ ; performs pre-checks and displays an error
+ ; if pre-conditions for building fail
+ ; e.g. not enough resources, not enough space
+building_build:
+ ret
; custom parameter
.de act_p0, 1
.de act_size, 0
+
+ ; building selection
+.se 0
+.de BT_ROAD, 1
+.de BT_WAREHOUSE, 1
+.de BT_FARM, 1
+.de BT_LUMBER, 1
#include "map.s"
#include "simulation.s"
#include "state.s"
+#include "buildings.s"
#include "tiles.inc"
; fill bank
dw STR_FARM
dw STR_LUMBER
+ ; converts from UI cursor position
+ ; to building type
+ui_to_building_selecction_table:
+ .db BT_WAREHOUSE
+ .db BT_ROAD
+ .db BT_FARM
+ .db BT_LUMBER
+
+
; inits UI
ui_init:
call ui_draw
ret
@not_left:
+ input_just BTNA
+ jr z, @not_a REL
+
+ ; load building to be built into building selector
+ ld a, [ui_cursor_pos]
+ ld d, 0
+ ld e, a
+ ld hl, ui_to_building_selecction_table
+ add hl, de ; hl = correct value
+ ld a, [hl]
+ ld [cursor_selected_building], a
+ ld bc, st_ui_buildung_selector_exit
+ ret
+@not_a:
+
ldnull bc
ret
cursor_move_y: .adv 1
cursor_move_x: .adv 1
+ ; enum of type BT_
+cursor_selected_building: .adv 1
+
; +/-1 for each time the cursor moves
; allows us to move scroll when needed
scroll_move_y: .adv 1
scroll_y: .adv 1
scroll_x: .adv 1
-money: .adv 3
-debt: .adv 3
-demand_house: .adv 1
-demand_shop: .adv 1
-demand_factory: .adv 1
-population: .adv 3
+ ; resources
+r_gold: .adv 2
+r_lumber: .adv 2
+r_stone: .adv 2
+r_food: .adv 2
+r_population: .adv 2
state_cells: .adv c_size * MAP_SIZE
state_cells_end: