buildings: cusros can now call the building state
authorLukas Krickl <lukas@krickl.dev>
Thu, 10 Apr 2025 15:27:55 +0000 (17:27 +0200)
committerLukas Krickl <lukas@krickl.dev>
Thu, 10 Apr 2025 15:27:55 +0000 (17:27 +0200)
src/buildings.s
src/player.s
src/ui.s
src/wram.s

index c601cbde603eb79e6a36a6957c1d159ff94c7e39..3ad7d435d92577ab1ab261c4bfc26a793b5f5771 100644 (file)
@@ -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
 
index 39b875830e7bcfe8135983b1db2027c3a9fa33d9..feebc68fa45a54656ee0249e4acfb2cb11c8eaac 100644 (file)
@@ -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
 
index 0ed272c9e0210b0594e116f2226a6e37db73ac19..30eb95ae0fe92d3bf6910bb7c5460be1b636eb4d 100644 (file)
--- 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
 
index 349ca5b4af6abccb6e4837901f1d068636b30ff6..b587f8e900ecfa9002138815822a7ef422b80313 100644 (file)
@@ -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