From: Lukas Krickl Date: Fri, 16 Jan 2026 07:41:35 +0000 (+0100) Subject: update: Added auto-ticking X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=b193e959efdee2b598b22384c4a67131be8d1c78;p=gbrg%2F.git update: Added auto-ticking This might be useful if the game should not be turn-based --- diff --git a/src/defs.s b/src/defs.s index 50b275a..6e3926a 100644 --- a/src/defs.s +++ b/src/defs.s @@ -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 diff --git a/src/player.s b/src/player.s index aac8bae..ac71ae1 100644 --- a/src/player.s +++ b/src/player.s @@ -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 diff --git a/src/update.s b/src/update.s index 241aecf..c66cdbc 100644 --- a/src/update.s +++ b/src/update.s @@ -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: diff --git a/src/wram.s b/src/wram.s index efadecb..0c5372f 100644 --- a/src/wram.s +++ b/src/wram.s @@ -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