summary refs log tree commit diff stats
path: root/utils.asm
diff options
context:
space:
mode:
authorChristian Krinitsin <code@krinitsin.xyz>2024-11-20 22:25:23 +0100
committerChristian Krinitsin <code@krinitsin.xyz>2024-11-20 22:25:23 +0100
commit0532d16d65c09494ff21b7e1a9cd3005058be8fc (patch)
tree615179ac9033fc686dc25ecb86698faa15b0896f /utils.asm
parent816561455ca037530d67e2606ffd7f887ef742de (diff)
downloadx86_64-Snake-0532d16d65c09494ff21b7e1a9cd3005058be8fc.tar.gz
x86_64-Snake-0532d16d65c09494ff21b7e1a9cd3005058be8fc.zip
hide cursor in game
Diffstat (limited to 'utils.asm')
-rw-r--r--utils.asm29
1 files changed, 29 insertions, 0 deletions
diff --git a/utils.asm b/utils.asm
index 7c7dc31..9281ed2 100644
--- a/utils.asm
+++ b/utils.asm
@@ -11,6 +11,9 @@ section .data
     right_cursor db 0x1B , '[C', 0
     right_cursor_len equ $ - right_cursor
 
+    hide_cursor_code db 0x1B, '[', '?', '2', '5', 'l', 0  ; Escape sequence to hide the cursor
+    show_cursor_code db 0x1B, '[', '?', '2', '5', 'h', 0  ; Escape sequence to show the cursor
+
 section .bss
     ; adress for syscall for write_byte wrapper
     byte_to_write resb 1
@@ -21,6 +24,32 @@ section .text
     global move_cursor_right
     global move_cursor_down
     global reset_cursor
+    global hide_cursor
+    global show_cursor
+
+hide_cursor:
+    push rdi
+    
+    mov rax, 1                      
+    mov rdi, 1                      
+    mov rsi, hide_cursor_code 
+    mov rdx, 6                
+    syscall                         
+
+    pop rdi
+    ret
+
+show_cursor:
+    push rdi
+    
+    mov rax, 1                      
+    mov rdi, 1                      
+    mov rsi, show_cursor_code 
+    mov rdx, 6                
+    syscall                         
+
+    pop rdi
+    ret
 
 reset_cursor:
     push rdi