-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSB.BAK
68 lines (61 loc) · 1.26 KB
/
SB.BAK
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
#include <dos.h>
void DSPout(unsigned,unsigned char);
char DSPini(unsigned);
void play(unsigned,unsigned char *,unsigned,unsigned);
void spkon(unsigned);
void spkon(unsigned base)
{
DSPout(base,0xD1);
}
void DSPout(unsigned base,unsigned char valor)
{
asm {
mov dx,base
add dx,0Ch
}
espera:
asm {
in al,dx
and al,80h
jnz espera
mov al,valor
out dx,al
}
}
char DSPini(unsigned base)
{
outportb(base+6,1);
delay(10);
outportb(base+6,0);
delay(10);
if ((inportb(base+0xE)&0x80)==0x80 && (inportb(base+0xA))==0xAA) return(1);
else return(0);
}
void play(unsigned base,unsigned char *sonido,unsigned tam,unsigned freq)
{
unsigned pag,des,tam2=tam;
tam2--;
des=(FP_SEG(sonido)<<4)+FP_OFF(sonido);
pag=(FP_SEG(sonido)+(FP_OFF(sonido)>>4))>>12;
while (tam2>0) {
tam=(des>(0xFFFF-tam2))?0xFFFF-des:tam2;
outportb(0xA,5);
outportb(0xC,0);
outportb(0xB,0x49);
outportb(0x2,des&0x00FF);
outportb(0x2,(des&0xFF00)>>8);
outportb(0x83,pag);
outportb(0x3,tam&0x00FF);
outportb(0x3,(tam&0xFF00)>>8);
outportb(0xA,1);
DSPout(base,0x40);
DSPout(base,256-1000000/freq);
DSPout(base,0x14);
DSPout(base,tam&0x00FF);
DSPout(base,(tam&0xFF00)>>8);
while (!(inportb(0x0008)&2)) ;
tam2-=tam;
des=0;
pag++;
}
}