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 20:12:29 +0100
committerChristian Krinitsin <code@krinitsin.xyz>2024-11-21 20:12:29 +0100
commit4efed0763417d76736fd628acef641abb7fd74a1 (patch)
treedfbe63f57824ac38543fae5ed961c10c93889d55 /src/input.asm
parent06c6e78a06d486cc6176754e00df7fea03286994 (diff)
downloadx86_64-Snake-4efed0763417d76736fd628acef641abb7fd74a1.tar.gz
x86_64-Snake-4efed0763417d76736fd628acef641abb7fd74a1.zip
add game over, and start/pause/gameover screen with text
Diffstat (limited to 'src/input.asm')
-rw-r--r--src/input.asm43
1 files changed, 41 insertions, 2 deletions
diff --git a/src/input.asm b/src/input.asm
index f411eed..66794f1 100644
--- a/src/input.asm
+++ b/src/input.asm
@@ -3,8 +3,13 @@ section .bss
 
 section .text
     global input
+    global read_input
+    global start_screen
     extern direction
     extern exit
+    extern timespec
+    extern write_pause_message
+    extern write_start_message
 
 input:
     call read_input
@@ -12,7 +17,6 @@ input:
     ret
 
 handle_input:
-    mov al, byte [input_buffer]
     mov ah, byte [direction]
     cmp al, 'w'
     je _input_up
@@ -23,7 +27,11 @@ handle_input:
     cmp al, 'd'
     je _input_right
     cmp al, 27 ; escape
-    je exit
+    je _pause
+    ret
+_pause:
+    mov byte [input_buffer], 'w'
+    call pause
     ret
 
 _input_up:
@@ -61,4 +69,35 @@ read_input:
     mov rsi, input_buffer
     mov rdx, 250          
     syscall
+    mov al, byte [input_buffer]
+    ret
+
+pause:
+    call write_pause_message
+    mov rax, 35            
+    lea rdi, [timespec]   
+    xor rsi, rsi           
+    syscall
+
+    call read_input
+    cmp al, 'q'
+    je exit
+    cmp al, 27 ; esc
+    jne pause
+    mov byte [input_buffer], '0'
+    ret
+
+start_screen:
+    call write_start_message
+    mov rax, 35            
+    lea rdi, [timespec]   
+    xor rsi, rsi           
+    syscall
+
+    call read_input
+    cmp al, 'q'
+    je exit
+    cmp al, 32 ; space
+    jne start_screen
+    mov byte [input_buffer], '0'
     ret