game: Added new unit placement state
authorLukas Krickl <lukas@krickl.dev>
Tue, 6 May 2025 15:04:23 +0000 (17:04 +0200)
committerLukas Krickl <lukas@krickl.dev>
Tue, 6 May 2025 15:04:23 +0000 (17:04 +0200)
src/mem.s
src/player.s
src/state.s
src/update.s

index 64d93ee1a5033dce58b965f74966f85db2b86b98..ab644d44717ce6e6d517671a9ac2faca61d1fc6f 100644 (file)
--- a/src/mem.s
+++ b/src/mem.s
@@ -14,13 +14,19 @@ mem_init:
   call memcpy
 
   ; set up game mode 
-  call game_init 
+  call unit_placement_init 
   call mbc1_init
   
   ret
 
+unit_placement_init:
+  ld de, st_update_unit_placement
+  ld hl, game_mode
+  ld bc, st_size
+  jp memcpy
+
 game_init:
-  ld de, st_update_game
+  ld de, st_update_game 
   ld hl, game_mode
   ld bc, st_size
   jp memcpy
index bec7b87bc41222e061e27a6efdd873210e3af028..c790126044ddeae940d7c461be409f8c1eff1f95 100644 (file)
@@ -63,7 +63,10 @@ player_draw_cursor:
 handle_inputs:
   input_held BTNA
   jr z, @not_a REL
-    
+    ; TODO: remove demo actor load
+    ; and load real units
+    call map_load_demo_actors
+    call game_init 
 @not_a:
 
   ; movement keys with cooldown
index 15d6743d29e1b42acd9adf8c4b654bcad857635a..fef5c98c918f7bcc0298b51c867c0caf0cf5fb63 100644 (file)
@@ -90,6 +90,8 @@ st_cursor_delay:
 
 st_update_game:
   st_def 0x00, update_game, st_update_game
+st_update_unit_placement:
+  st_def 0x00, update_unit_placement, st_update_unit_placement
 st_update_pause:
   st_def 0x00, update_pause, st_update_pause
 st_update_game_over:
index e078d9a92685ad2fcb433954c0a3879b89ce86d8..170c2b56cdf57c2d4a5082fd8c10337a5d615bd1 100644 (file)
@@ -6,6 +6,16 @@ update_game:
   call rand
   call rand_save_srand
 
+  ld hl, p0_units
+  call units_update
+  ld hl, p1_units
+  call units_update
+
+  ldnull bc
+  ret
+
+update_unit_placement:
+
   ld de, actor_player 
   call st_update