From 2368fa7b7f7fe2da5a2b29dbb0887023769a7d89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juhani=20Krekel=C3=A4?= Date: Sat, 14 Jan 2023 22:14:07 +0200 Subject: [PATCH] Tune snake speed and fix a bug with turning code --- mato8.asm | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/mato8.asm b/mato8.asm index 3587355..50f2a0e 100644 --- a/mato8.asm +++ b/mato8.asm @@ -4,7 +4,7 @@ ; Under Creative Commons Zero 1.0 ; Assemble with c8asm (https://github.com/wernsey/chip8) -define frames_wait 4 +define frames_wait 5 define up_key 2 define down_key 8 @@ -46,6 +46,8 @@ mainloop: ld v0, frames_wait ld dt, v0 + ld v1, head_direction_reg + ld v0, up_key sknp v0 call turn_up @@ -116,22 +118,22 @@ spawn_fruit: turn_up: ; Don't allow 180° turns (which would kill the snake instantly) - se head_direction_reg, direction_down + se v1, direction_down ld head_direction_reg, direction_up ret turn_down: - se head_direction_reg, direction_up + se v1, direction_up ld head_direction_reg, direction_down ret turn_left: - se head_direction_reg, direction_right + se v1, direction_right ld head_direction_reg, direction_left ret turn_right: - se head_direction_reg, direction_left + se v1, direction_left ld head_direction_reg, direction_right ret