update: Added auto-ticking
authorLukas Krickl <lukas@krickl.dev>
Fri, 16 Jan 2026 07:41:35 +0000 (08:41 +0100)
committerLukas Krickl <lukas@krickl.dev>
Fri, 16 Jan 2026 07:41:35 +0000 (08:41 +0100)
This might be useful if the game should not be turn-based

src/defs.s
src/player.s
src/update.s
src/wram.s

index 50b275a4e7903c5004ef2ebb5bd7ceb2cbc8f033..6e3926ab5deb5606a715b77ffa672803e6f293fb 100644 (file)
@@ -5,6 +5,10 @@
 
 #define UI_STATUS_LINE shadow_ui+1
 
+       ; how often should turns auto-end
+       ; frame timer
+#define TICK_RATE 10
+
 .def int OAMDMAFN = 0xFF80 
 #define WRAM 0xC000
 #define WRAM1 0xD000
index aac8bae33efc8b8525d9cd85e3d18581b30db491..ac71ae1662ef5e2cf13caf78dbc2f288da1b1f7d 100644 (file)
@@ -219,12 +219,6 @@ player_collided:
 
        ; code to run when player has moved
 player_moved:
-       ld de, player
-       call act_clear_tact
-
-       ld de, player
-       call act_set_tact
-
        call map_full_draw
        call player_end_turn
        ret
@@ -233,4 +227,7 @@ player_moved:
 player_end_turn:
        ld a, 1
        ld [turn_flag], a
+       
+       xor a, a
+       ld [ticks], a
        ret
index 241aecf3659e03d83cc00f822dfbbbc259afde21..c66cdbc3ecccc89a4ee5fc9eb70c7c6447da51b1 100644 (file)
@@ -9,6 +9,7 @@ update_game:
        ; player should update even in debug mode
        call player_update
        call player_draw
+       call tick
        
        ; if turn flag is 1 -> update actors
        ld a, [turn_flag]
@@ -28,6 +29,16 @@ update_game:
 
   ret
 
+       ; ticks the game
+       ; ends turn if ticks == TICK_RATE
+tick:
+       ld a, [ticks]
+       inc a
+       cp a, TICK_RATE
+       jp z, player_end_turn
+       ld [ticks], a
+       ret
+
        
        ; draws a single tile
        ; inputs:
index efadecba86777b082ea520e4a7c1b9233f62b39b..0c5372f607cc3c147117ff7551ea36dc1cc49fe2 100644 (file)
@@ -128,6 +128,8 @@ col_tile: .adv 2
 col_y: .adv 1
 col_x: .adv 1
 
+ticks: .adv 1
+
 map_mark_flag: .adv 1
 
 #ifdef DEBUG_CANARY