sound.c
资源名称:泡泡龙源代码.zip [点击查看]
上传用户:junwei_58
上传日期:2007-05-15
资源大小:79k
文件大小:2k
源码类别:
其他智力游戏
开发平台:
Visual C++
- #define SOUND_C
- #include "game.h"
- #include <dos.h>
- int speed=1;
- char *qm="iddgwwwqqgfff dddfghhhggg ddgwwwqqqfff ddffhjqqqqq wpggjhgddgqq hhqwwqjjjggg ddgwwwqqqqgfff ddffhjqqqqqq";
- int n,pauseTime,played;
- uchar ch;
- //void pause(int);
- void sounds(int,int);
- void play(){
- int i,freq;
- int time=4*speed;
- if(pauseTime--)return;
- if(played){outp(97,ch);played=0;}
- if(*(qm+ ++n)==' ')n=0;
- i=1;
- switch(*(qm+n)){
- case 'k': time=1*speed;i=0;
- case 'i': time=6*speed;i=0;
- case 'o': time=10*speed;i=0;
- case 'p': pauseTime=time;i=0;
- case 'a': freq=523;break;
- case 's': freq=587;break;
- case 'd': freq=659;break;
- case 'f': freq=698; break;
- case 'g': freq=784; break;
- case 'h': freq=880; break;
- case 'j': freq=988; break;
- case 'z': freq=262; break;
- case 'x': freq=294; break;
- case 'c': freq=330; break;
- case 'v': freq=349; break;
- case 'b': freq=392; break;
- case 'n': freq=440; break;
- case 'm': freq=494; break;
- case 'q': freq=1047; break;
- case 'w': freq=1175; break;
- case 'e': freq=1319; break;
- case 'r': freq=1397; break;
- case 't': freq=2568; break;
- case 'y': freq=1760; break;
- case 'u': freq=1976; break;
- default: i=0; break;
- }
- if (i){
- union {
- long division;
- uchar c[2];
- }count;
- played=1;
- count.division=1193280L/freq;
- outp(67,182);
- outp(66,count.c[0]);
- outp(66,count.c[1]);
- ch=inp(97);
- outp(97,ch|3);
- pauseTime=time;
- }
- }
- /*
- void pause (int time){
- int t1,t2;
- union REGS in ,out;
- in.h.ah=0x2c;
- int86(0x21,&in,&out);
- t1=t2=100*out.h.dh+out.h.dl;
- while (t2-t1<time){
- int86(0x21,&in,&out);
- t2=100*out.h.dh+out.h.dl;
- if (t2<t1)t2+=6000;
- }
- } */