From ade50b257ac81f21f82fdba6c2e9c80cc2b7a17b Mon Sep 17 00:00:00 2001 From: Zihao Yu Date: Tue, 16 Jan 2024 23:33:30 +0800 Subject: [PATCH] kernels,typing-game: assume uptime does not start from zero * on platform tha can re-run the game, the game will skip some beginning frames in the second run --- kernels/typing-game/game.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernels/typing-game/game.c b/kernels/typing-game/game.c index fa0c61b..f2273a9 100644 --- a/kernels/typing-game/game.c +++ b/kernels/typing-game/game.c @@ -151,8 +151,9 @@ int main() { printf("Type 'ESC' to exit\n"); int current = 0, rendered = 0; + uint64_t t0 = io_read(AM_TIMER_UPTIME).us; while (1) { - int frames = io_read(AM_TIMER_UPTIME).us / (1000000 / FPS); + int frames = (io_read(AM_TIMER_UPTIME).us - t0) / (1000000 / FPS); for (; current < frames; current++) { game_logic_update(current);