From a8a7a3d3d13fc1273f68743ff2c47de7e679937c Mon Sep 17 00:00:00 2001 From: redfast00 Date: Tue, 1 Oct 2019 01:23:27 +0200 Subject: [PATCH] Add duration of note --- messages.asm | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/messages.asm b/messages.asm index d337561..17f188c 100644 --- a/messages.asm +++ b/messages.asm @@ -70,14 +70,15 @@ mov sp, 0x2000 jmp .loop .beep: + call .readduration + mov ah, 0 + push ax mov al, 182 ; Prepare the speaker for the out 43h, al ; note. call .readbyte mov ah, 0 sal ax, 5 ; multiply by 32 add ax, 1140 - ;mov ax, 4560 ; Frequency number (in decimal) - ; ; for middle C. out 42h, al ; Output low byte. mov al, ah ; Output high byte. out 42h, al @@ -85,7 +86,14 @@ mov sp, 0x2000 ; port 61h). or al, 00000011b ; Set bits 1 and 0. out 61h, al ; Send new value. - mov bx, 50000 ; Pause for duration of note. + ;; mov bx, 50000 ; Pause for duration of note. + pop bx + push ax + mov ax, 3125 + mul bx + mov bx, ax + pop ax + .pause1: mov cx, 65535 .pause2: @@ -161,6 +169,14 @@ mov sp, 0x2000 or al, bl ret +.readduration: + ;; Read duration (0-16 supported) + mov ah, 0x00 + int 0x16 + ;; Read character is in al + sub al, 'a' + ret + halt: hlt color_mode: db 0x02