Add duration of note
This commit is contained in:
parent
26f7032808
commit
a8a7a3d3d1
1 changed files with 19 additions and 3 deletions
22
messages.asm
22
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
|
||||
|
|
Loading…
Reference in a new issue