diff options
| -rw-r--r-- | input.asm | 2 | ||||
| -rw-r--r-- | main.asm | 4 | ||||
| -rw-r--r-- | utils.asm | 29 |
3 files changed, 34 insertions, 1 deletions
diff --git a/input.asm b/input.asm index b80b509..278b640 100644 --- a/input.asm +++ b/input.asm @@ -42,6 +42,6 @@ read_input: mov rax, 0 mov rdi, 0 mov rsi, input_buffer - mov rdx, 1 + mov rdx, 250 syscall ret diff --git a/main.asm b/main.asm index d0e1e3a..4828b35 100644 --- a/main.asm +++ b/main.asm @@ -37,6 +37,8 @@ section .text extern reset_cursor extern move_cursor_right extern move_cursor_down + extern hide_cursor + extern show_cursor global _start global exit @@ -87,6 +89,7 @@ _move_up: ret _start: + call hide_cursor mov byte [snake], 5 mov byte [snake+1], 5 @@ -106,6 +109,7 @@ main_loop: jmp main_loop exit: ; exit syscall with return code 0 + call show_cursor mov rax, 60 xor rdi, rdi syscall 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 |