Add beep with ESC with frequencies
This commit is contained in:
parent
1ca2ba1e6b
commit
26f7032808
1 changed files with 28 additions and 21 deletions
47
messages.asm
47
messages.asm
|
@ -27,6 +27,7 @@ mov dl, 0x00
|
||||||
mov bh, 0x00
|
mov bh, 0x00
|
||||||
mov ah, 0x02
|
mov ah, 0x02
|
||||||
int 0x10
|
int 0x10
|
||||||
|
mov sp, 0x2000
|
||||||
|
|
||||||
.loop:
|
.loop:
|
||||||
;; Read character
|
;; Read character
|
||||||
|
@ -42,21 +43,7 @@ int 0x10
|
||||||
jmp .nonewline
|
jmp .nonewline
|
||||||
|
|
||||||
.change_color_mode:
|
.change_color_mode:
|
||||||
;; Read character
|
call .readbyte
|
||||||
mov ah, 0x00
|
|
||||||
int 0x16
|
|
||||||
;; Read character is in al
|
|
||||||
sub al, 'a'
|
|
||||||
mov bl, al
|
|
||||||
shl bl, 0x4
|
|
||||||
|
|
||||||
;; Read character
|
|
||||||
mov ah, 0x00
|
|
||||||
int 0x16
|
|
||||||
;; Read character is in al
|
|
||||||
sub al, 'a'
|
|
||||||
or al, bl
|
|
||||||
|
|
||||||
mov [color_mode], al
|
mov [color_mode], al
|
||||||
jmp .loop
|
jmp .loop
|
||||||
|
|
||||||
|
@ -85,8 +72,12 @@ int 0x10
|
||||||
.beep:
|
.beep:
|
||||||
mov al, 182 ; Prepare the speaker for the
|
mov al, 182 ; Prepare the speaker for the
|
||||||
out 43h, al ; note.
|
out 43h, al ; note.
|
||||||
mov ax, 4560 ; Frequency number (in decimal)
|
call .readbyte
|
||||||
; for middle C.
|
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.
|
out 42h, al ; Output low byte.
|
||||||
mov al, ah ; Output high byte.
|
mov al, ah ; Output high byte.
|
||||||
out 42h, al
|
out 42h, al
|
||||||
|
@ -94,7 +85,7 @@ int 0x10
|
||||||
; port 61h).
|
; port 61h).
|
||||||
or al, 00000011b ; Set bits 1 and 0.
|
or al, 00000011b ; Set bits 1 and 0.
|
||||||
out 61h, al ; Send new value.
|
out 61h, al ; Send new value.
|
||||||
mov bx, 5000 ; Pause for duration of note.
|
mov bx, 50000 ; Pause for duration of note.
|
||||||
.pause1:
|
.pause1:
|
||||||
mov cx, 65535
|
mov cx, 65535
|
||||||
.pause2:
|
.pause2:
|
||||||
|
@ -142,7 +133,6 @@ int 0x10
|
||||||
mov dl, 0x00
|
mov dl, 0x00
|
||||||
mov ah, 0x02
|
mov ah, 0x02
|
||||||
int 0x10
|
int 0x10
|
||||||
|
|
||||||
jmp .loop
|
jmp .loop
|
||||||
|
|
||||||
.noeol:
|
.noeol:
|
||||||
|
@ -151,9 +141,26 @@ int 0x10
|
||||||
inc dl
|
inc dl
|
||||||
mov ah, 0x02
|
mov ah, 0x02
|
||||||
int 0x10
|
int 0x10
|
||||||
|
|
||||||
jmp .loop
|
jmp .loop
|
||||||
|
|
||||||
|
|
||||||
|
.readbyte:
|
||||||
|
;; Read character
|
||||||
|
mov ah, 0x00
|
||||||
|
int 0x16
|
||||||
|
;; Read character is in al
|
||||||
|
sub al, 'a'
|
||||||
|
mov bl, al
|
||||||
|
shl bl, 0x4
|
||||||
|
|
||||||
|
;; Read character
|
||||||
|
mov ah, 0x00
|
||||||
|
int 0x16
|
||||||
|
;; Read character is in al
|
||||||
|
sub al, 'a'
|
||||||
|
or al, bl
|
||||||
|
ret
|
||||||
|
|
||||||
halt: hlt
|
halt: hlt
|
||||||
|
|
||||||
color_mode: db 0x02
|
color_mode: db 0x02
|
||||||
|
|
Loading…
Reference in a new issue