⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 soundgd.h

📁 c游戏编程从入门到精通_全部源代码和文档
💻 H
字号:
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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -