fix duration reading code

This commit is contained in:
Tibo Ulens 2021-10-08 14:37:32 +02:00
parent e2747fc424
commit 1d00d5f393

View file

@ -162,7 +162,12 @@ beep:
mov ah, 0x00 ; read keypress mov ah, 0x00 ; read keypress
int 0x16 int 0x16
;; Read ASCII character is in al ;; Read ASCII character is in al
sub al, 'a' ; normalise (a=0, b=1, c=...) ;; the character must be normalised to a=1, b=2, ...
;; and not a=0, b=1, ... because during the waiting loop
;; see #NOTE_LOOP
;; the duration counter gets decremented BEFORE
;; it gets compared to zero
sub al, 'b' ; normalise (a=1, b=2, c=...)
;; interrupt 0x16, ah=0 returns the read scancode in ah ;; interrupt 0x16, ah=0 returns the read scancode in ah
;; so ah must be reset ;; so ah must be reset
@ -207,6 +212,9 @@ beep:
dec cx ; count down dec cx ; count down
jne .pause2 ; if not zero keep counting down jne .pause2 ; if not zero keep counting down
;; #NOTE_LOOP
;; the duration gets decremented before being checked
;; hence why it was normalised to 'b' and not 'a'
dec ax ; decrement duration counter dec ax ; decrement duration counter
jne .pause1 ; keep doing that until it is 0 jne .pause1 ; keep doing that until it is 0