:: commit 85bb87a3ae5e0293e4bb77bdfac7d5cbd2413f36

mintsuki <mintsuki@protonmail.com> — 2022-02-19 16:19

parents: b795c3b209

readline: Fix argument handling in sleep.asmb

diff --git a/common/lib/sleep.asmb b/common/lib/sleep.asmb
index fc1c4dd0..30c3d159 100644
--- a/common/lib/sleep.asmb
+++ b/common/lib/sleep.asmb
@@ -64,9 +64,13 @@ _pit_sleep_and_quit_on_keypress:
 
     sti
 
+    mov byte [.mods], 0
+    mov byte [.ascii], 0
+    mov byte [.scan], 0
+
   .loop:
     cmp dword [int_08_ticks_counter], edx
-    je .timeout
+    je .done
 
     push ecx
     push edx
@@ -81,10 +85,17 @@ _pit_sleep_and_quit_on_keypress:
     ; on keypress
     xor ax, ax
     int 0x16
-    jmp .done
+    mov byte [.ascii], al
+    mov byte [.scan], ah
 
-  .timeout:
-    xor eax, eax
+    mov ax, 0x0200
+    int 0x16
+    test al, 0x04
+    jz .done
+
+    ; ctrl handling
+    mov byte [.mods], 0x04
+    add byte [.ascii], 0x60
 
   .done:
     cli
@@ -119,22 +130,26 @@ _pit_sleep_and_quit_on_keypress:
     mov edx, dword [int_08_callback]
     mov dword [0x08*4], edx
 
-    test eax, eax
-    jz .out
+    cmp byte [.ascii], 0
+    je .fail
 
-    xor edx, edx
-    mov dl, ah
-    xor ah, ah
-    push eax
-    push edx
+    push dword [.mods]
+    push dword [.ascii]
+    push dword [.scan]
     call getchar_internal
-    pop edx
-    pop edx
+    add esp, 3*4
 
-  .out:
+    ret
+
+  .fail:
+    xor eax, eax
     ret
 
   .gdt:      dq 0
   .idt:      dq 0
   .rm_idt:   dw 0x3ff
              dd 0
+
+  .mods:  dd 0
+  .ascii: dd 0
+  .scan:  dd 0
tab: 248 wrap: offon