ui: Added basic ui state change
authorLukas Krickl <lukas@krickl.dev>
Sat, 29 Mar 2025 15:57:43 +0000 (16:57 +0100)
committerLukas Krickl <lukas@krickl.dev>
Sat, 29 Mar 2025 15:57:43 +0000 (16:57 +0100)
src/player.s
src/ui.s
tiles/bank8000.inc
tiles/bank8800.inc
tiles/bank9000.inc

index 251c25b8c836004d595f1b3ea2d1ae3c4f35bb7b..a67d4af1830aa0479bd91ff237b85a6096ca1f40 100644 (file)
@@ -124,6 +124,14 @@ handle_inputs:
     ld bc, st_cursor_delay 
     ret
 @notright:
+
+  input_just BTNSELECT
+  jr z, @not_select REL
+    ; select goes to build menu
+
+    ld bc, st_ui_building_selector 
+    ret
+@not_select:
 @done:
   ldnull bc
   ret
index a60af0693844bcb403ba40ac68a497d4137c3d76..05a9ded0149b89ec9b76a6271b8ff5ae0b9e56c3 100644 (file)
--- a/src/ui.s
+++ b/src/ui.s
@@ -1,4 +1,12 @@
 
+#define UI_TILE_WAREHOUSE 128
+#define UI_TILE_ROAD 129
+#define UI_TILE_FARM 130
+#define UI_TILE_LUMBER 131
+
+#define UI_CURSOR_BUILDING_BASE_X 2 
+#define UI_CURSOR_BUILDING_BASE_Y 120
+
   ; inits UI
 ui_init:
   call ui_draw
@@ -9,12 +17,53 @@ ui_init:
   ; during blanking 
 ui_draw:
   ld hl, SCRN1
-  ld a, 128
-  ld [hl], a
+  inc hl
+
+  ld a, UI_TILE_WAREHOUSE 
+  ld [hl+], a
+
+  ld a, UI_TILE_ROAD
+  ld [hl+], a
+
+  ld a, UI_TILE_FARM
+  ld [hl+], a
+
+  ld a, UI_TILE_LUMBER
+  ld [hl+], a
 
   ret
 
   ; ui building selector state
 ui_building_selector_update:
+  call ui_building_selector_inputs 
+  push bc
+  call ui_building_selector_draw 
+  pop bc
+  ret
+
+ui_building_selector_draw:
+  ld hl, PLAYER_SPRITE1
+  
+  ld a, UI_CURSOR_BUILDING_BASE_Y 
+  add a, OBJ_OFF_Y
+  ld [hl+], a
+
+  ld a, UI_CURSOR_BUILDING_BASE_X 
+  add a, OBJ_OFF_X
+  ld [hl+], a
+
+  ld a, CURSOR_TILE
+  ld [hl+], a
+
+  ret
+
+ui_building_selector_inputs:
+  input_just BTNSELECT
+  jr z, @not_select REL
+    ; select back to regular state 
+
+    ld bc, st_cursor 
+    ret
+@not_select:
   ldnull bc
   ret
index 65d982fe619a4307b1f651afeaede6f7a70f18cb..7539ccbb269a113f5d961b7f7fe75166b04f1616 100644 (file)
 .chr 00000000
 .chr 00000000
 ; tile 119
-.chr 32232223
 .chr 32222223
-.chr 32232223
 .chr 32222223
-.chr 32232223
 .chr 32222223
-.chr 32232223
+.chr 32222223
+.chr 32222223
+.chr 32222223
+.chr 32222223
 .chr 32222223
 ; tile 120
 .chr 33333333
 .chr 22222222
 .chr 22222222
-.chr 23232323
+.chr 22222222
 .chr 22222222
 .chr 22222222
 .chr 22222222
index 342a388eeae68f4265a4809cf1cd1e04174a5572..6b1a78dd66020325780298d93dc76a4c1d22b694 100644 (file)
@@ -1,38 +1,38 @@
 ; tile 0
 .chr 00000000
-.chr 00000000
-.chr 00000000
-.chr 00000000
-.chr 00000000
-.chr 00000000
-.chr 00000000
+.chr 03333330
+.chr 03002130
+.chr 03021130
+.chr 03211130
+.chr 03111130
+.chr 03333330
 .chr 00000000
 ; tile 1
 .chr 00000000
-.chr 00000000
-.chr 00000000
-.chr 00000000
-.chr 00000000
-.chr 00000000
-.chr 00000000
+.chr 03222230
+.chr 03222230
+.chr 03222230
+.chr 03222230
+.chr 03222230
+.chr 03222230
 .chr 00000000
 ; tile 2
 .chr 00000000
-.chr 00000000
-.chr 00000000
-.chr 00000000
-.chr 00000000
-.chr 00000000
-.chr 00000000
+.chr 01111110
+.chr 01200210
+.chr 01020010
+.chr 01000010
+.chr 01200210
+.chr 01111110
 .chr 00000000
 ; tile 3
 .chr 00000000
-.chr 00000000
-.chr 00000000
-.chr 00000000
-.chr 00000000
-.chr 00000000
-.chr 00000000
+.chr 00020000
+.chr 00111000
+.chr 00111000
+.chr 01111100
+.chr 01111100
+.chr 00030000
 .chr 00000000
 ; tile 4
 .chr 00000000
 .chr 00000000
 ; tile 127
 .chr 00000000
-.chr 00000000
-.chr 00000000
-.chr 00000000
-.chr 00000000
-.chr 00000000
-.chr 00000000
-.chr 00000000
+.chr 00020000
+.chr 00111000
+.chr 00111000
+.chr 01111100
+.chr 01111100
+.chr 00030000
+.chr 00020000
index e989c93940f7f3112e600fd8359c972614132a65..4293a61507c27ab729ba129c06f3542fcd1f6cbe 100644 (file)
 .chr 00000000
 .chr 00000000
 ; tile 119
-.chr 32232223
 .chr 32222223
-.chr 32232223
 .chr 32222223
-.chr 32232223
 .chr 32222223
-.chr 32232223
+.chr 32222223
+.chr 32222223
+.chr 32222223
+.chr 32222223
 .chr 32222223
 ; tile 120
 .chr 33333333
 .chr 22222222
 .chr 22222222
-.chr 23232323
+.chr 22222222
 .chr 22222222
 .chr 22222222
 .chr 22222222