SBCMS.CPP
资源名称:泡泡龙源代码.zip [点击查看]
上传用户:junwei_58
上传日期:2007-05-15
资源大小:79k
文件大小:2k
源码类别:
其他智力游戏
开发平台:
Visual C++
- #define SBCMS_CPP
- #include "sbcms.h"
- #include <conio.h>
- void playnote(char voice,
- char ampl,
- char tone,
- char octave,
- char sort,
- char noiseclock,
- char envelope,
- unsigned duration){
- unsigned int cmsvoice,cmsport;
- char j,k;
- cmsport=baseport;
- cmsvoice=voice;
- if(voice>=6){
- voice -= 6;
- cmsport += 2;
- }
- outp(cmsport+1,voice);
- outp(cmsport,ampl);
- outp(cmsport+1,8+voice);
- outp(cmsport,tone);
- outp(cmsport+1,0x10+(voice/2));
- j=(octave<((voice&1)*4));
- outp(cmsport,j);
- outp(cmsport+1,0x16);
- k=(noiseclock<((voice/3)&1)*4);
- outp(cmsport,k);
- outp(cmsport+1,0x18+(voice/3));
- outp(cmsport,envelope);
- if(sort&2)cmsonfreq[cmsvoice]=1;
- if(sort&1)cmsonnoise[cmsvoice]=1;
- timevoice[cmsvoice]=duration;
- }
- void initMusic(){
- outp(baseport+1,0);
- outp(baseport,0xff);
- outp(baseport+1,0x14);
- outp(baseport,0);
- outp(baseport+1,0x8);
- outp(baseport,64);
- outp(baseport+1,0x10);
- outp(baseport,4);
- outp(baseport+1,0x15);
- outp(baseport,0);
- outp(baseport+1,0x1c);
- outp(baseport,1);
- //;oldtim=getvect(8);
- //;setvect(8,newtim);
- initcms();
- //;setvect(8,oldtim);
- //;SetTimer(newtim,100);
- }
- void interrupt newtim(...){
- //char freq;//,noise;
- int i;//,j;
- unsigned int cmsport;
- for(i=0;i<12;i++){
- if(cmsonfreq[i]||cmsonnoise[i]){
- if(timevoice[i]>0)timevoice[i]--;
- else{
- cmsonnoise[i]=0;
- cmsonfreq[i]=0;
- }
- }
- }
- freqtot=0;
- noisetot=0;
- cmsport=baseport;
- for(i=0;i<6;i++){
- if(cmsonfreq[i])freqtot+=(1<<i);
- if(cmsonnoise[i])noisetot+=(1<<i);
- }
- outp(cmsport+1,0x14);
- outp(cmsport,freqtot);
- outp(cmsport+1,0x15);
- outp(cmsport,noisetot);
- freqtot=0;
- noisetot=0;
- for(i=6;i<12;i++){
- if(cmsonfreq[i])freqtot+=(1<<(i-6));
- if(cmsonnoise[i])noisetot+=(1<<(i-6));
- }
- outp(cmsport+1,0x14);
- outp(cmsport,freqtot);
- outp(cmsport+3,0x14);
- outp(cmsport+2,freqtot);
- outp(cmsport+3,0x15);
- outp(cmsport+2,noisetot);
- // counter++;
- }
- void resetcms(){
- outp(baseport+1,0x1c);
- outp(baseport,2);
- outp(baseport+3,0x1c);
- outp(baseport+2,2);
- }
- void initcms(){
- int cnt;
- resetcms();
- outp(baseport+1,0x1c);
- outp(baseport,1);
- outp(baseport+3,0x1c);
- outp(baseport+1,1);
- for(cnt=0;cnt<12;cnt++){
- timevoice[cnt]=0;
- cmsonfreq[cnt]=0;
- cmsonnoise[cnt]=0;
- playnote(cnt,0,0,0,0,0,0,0);
- }
- }