soundgd.h
来自「c游戏编程从入门到精通_全部源代码和文档」· C头文件 代码 · 共 61 行
H
61 行
void interrupt(*old_int9)();
int HZ[4][7]={ {131,147,165,175,196,220,247},
{262,294,330,349,392,440,494},
{523,587,659,698,784,880,988},
{1047,1174,1319,1568,1760,1976}};
int *s;
void Sound(int freq)
{
asm{
mov al, 0B6h
out 43h, al
mov dx, 12h
mov ax, 34DEh
div freq
out 42h, al
mov al, ah
out 42h, al
in al, 61h
or al, 3
out 61h, al
}
}
void Nosound(void)
{
asm{
in al, 61h
and al, 252
out 61h, al
}
}
void interrupt new_int9()
{
static int count,tt=0;
count++;
if(*s!=0)
{
if(count>=tt)
{
Sound(HZ[*s/10][*s%10-1]);
s++;
tt=*s*18.2/1000;
s++;
count=0;
}
}
else
Nosound();
(*old_int9)();
}
void play(int *ms)
{
s=ms;
old_int9=getvect(0x1c);
setvect(0x1c,new_int9);
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?