summary refs log tree commit diff stats
path: root/src/input.asm
diff options
context:
space:
mode:
authorChristian Krinitsin <code@krinitsin.xyz>2024-11-21 14:51:27 +0100
committerChristian Krinitsin <code@krinitsin.xyz>2024-11-21 14:51:27 +0100
commit3c90c7ab15aa276b6766f37d6b159a31fbe778bc (patch)
tree8549c822158cc192e6103f0cd66c588b92006a51 /src/input.asm
parentb1ae885a7e701f69a8b18c2e3012329733c8e57c (diff)
downloadx86_64-Snake-3c90c7ab15aa276b6766f37d6b159a31fbe778bc.tar.gz
x86_64-Snake-3c90c7ab15aa276b6766f37d6b159a31fbe778bc.zip
add fruit, which respawns when touched and snake with length 2
Diffstat (limited to 'src/input.asm')
-rw-r--r--src/input.asm19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/input.asm b/src/input.asm
index 278b640..f411eed 100644
--- a/src/input.asm
+++ b/src/input.asm
@@ -1,5 +1,5 @@
 section .bss
-    input_buffer resb 1
+    input_buffer resb 250
 
 section .text
     global input
@@ -13,6 +13,7 @@ input:
 
 handle_input:
     mov al, byte [input_buffer]
+    mov ah, byte [direction]
     cmp al, 'w'
     je _input_up
     cmp al, 's'
@@ -26,15 +27,31 @@ handle_input:
     ret
 
 _input_up:
+    cmp ah, 1
+    jnz _set_up
+    ret
+_set_up:
     mov byte [direction], 3
     ret
 _input_down:
+    cmp ah, 3
+    jnz _set_down
+    ret
+_set_down:
     mov byte [direction], 1
     ret
 _input_left:
+    cmp ah, 0
+    jnz _set_left
+    ret
+_set_left:
     mov byte [direction], 2
     ret
 _input_right:
+    cmp ah, 2
+    jnz _set_right
+    ret
+_set_right:
     mov byte [direction], 0
     ret