-
Notifications
You must be signed in to change notification settings - Fork 12
/
sound.asm
93 lines (88 loc) · 2.25 KB
/
sound.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
;===================================================================================================
; Sound
;
; Written By: Oded Cnaan ([email protected])
; Site: http://odedc.net
; Licence: GPLv3 (see LICENSE file)
; Package: UtilLib
;
; Description:
; Allows playing sounds
;===================================================================================================
LOCALS @@
;----------------------------------------------------------------------
; Plays a beep sound based on the given frequency
; Credit: http://www.edaboard.com/thread182595.html
;
; push FREQUENCY IN HERTZ
; call Beep
;----------------------------------------------------------------------
PROC Beep
store_sp_bp
push ax
push dx
push cx
mov cx,[bp+4]
cmp cx, 014H
jb @@STARTSOUND_DONE
;CALL STOPSOUND
in al, 061H
;AND AL, 0FEH
;OR AL, 002H
or al, 003H
dec ax
out 061H, al ;TURN AND GATE ON; TURN TIMER OFF
mov dx, 00012H ;HIGH WORD OF 1193180
mov ax, 034DCH ;LOW WORD OF 1193180
div cx
mov dx,ax
mov al, 0B6H
pushf
cli ;!!!
out 043H, al
mov al, dl
out 042H, al
mov al, DH
out 042H, al
popf
in al, 061H
or al, 003H
out 061H, AL
@@STARTSOUND_DONE:
pop cx
pop dx
pop ax
restore_sp_bp
ret 2
ENDP Beep
;----------------------------------------------------------------------
; Stop beep by destroying AL
;----------------------------------------------------------------------
PROC StopBeep
push ax
in al, 061H
and al, 0FCH
out 061H, al
pop ax
ret
ENDP StopBeep
;////////////////////////////////////////////////////////////////////////////
; FUNCTION LIKE MACROS
;////////////////////////////////////////////////////////////////////////////
;----------------------------------------------------------------------
; Plays a beep sound based on the given frequency
;
; grm_Beep (freq)
;----------------------------------------------------------------------
MACRO utm_Beep freq
push freq
call Beep
ENDM
;----------------------------------------------------------------------
; Stop beep by destroying AL
;
; grm_StopBeep()
;----------------------------------------------------------------------
MACRO utm_StopBeep
call StopBeep
ENDM