- Visual C++源码
- Visual Basic源码
- C++ Builder源码
- Java源码
- Delphi源码
- C/C++源码
- PHP源码
- Perl源码
- Python源码
- Asm源码
- Pascal源码
- Borland C++源码
- Others源码
- SQL源码
- VBScript源码
- JavaScript源码
- ASP/ASPX源码
- C#源码
- Flash/ActionScript源码
- matlab源码
- PowerBuilder源码
- LabView源码
- Flex源码
- MathCAD源码
- VBA源码
- IDL源码
- Lisp/Scheme源码
- VHDL源码
- Objective-C源码
- Fortran源码
- tcl/tk源码
- QT源码
FMMUSIC.C
资源名称:泡泡龙源代码.zip [点击查看]
上传用户:junwei_58
上传日期:2007-05-15
资源大小:79k
文件大小:1k
源码类别:
其他智力游戏
开发平台:
Visual C++
- #define FMMUSIC_C
- #include <dos.h>
- #include <conio.h>
- #include <stdio.h>
- #include "fmmusic.h"
- #include "fmcreate.h"
- extern char *FMfilename;
- Note notetable[13]={_R,_C,_Ch,_D,_Dh,_E,_F,_Fh,_G,_Gh,_A,_Ah,_B,};
- int timetable[8]={_2_0*2, _2_0, _1_1, _1_2, _1_4, _1_8, _1_16, _1_32,};
- void WriteFM(char reg,char data){asm{
- mov dx,FM_PORT
- mov al,reg
- out dx,al
- inc dx
- mov al,data
- out dx,al
- }}
- char ReadFM(){asm{
- mov dx,FM_PORT
- in al,dx
- }}
- void FMSound(int freq,char block){
- WriteFM(0xa0,freq&0x00ff);
- WriteFM(0xb0,(block<<2)|((freq&0xff00)>>8)|0x20);
- }
- void FMSoundOFF(int freq,char block){
- WriteFM(0xa0,freq&0x00ff);
- WriteFM(0xb0,(block<<2)|((freq&0xff00)>>8));
- }
- void delayFM(int time){
- char i;
- WriteFM(0x04,0x80);
- WriteFM(0x03,216);
- WriteFM(0x04,0x42);
- for(i=1;i<time;i++){
- while(((char)ReadFM()&0xe0)<0xa0);
- WriteFM(0x04,0x82);
- }
- }
- int FMready(){
- // char i;
- WriteFM(0x04,0x80);
- WriteFM(0x03,216);
- WriteFM(0x04,0x42);
- if(((char)ReadFM()&0xe0)>=0xa0){
- WriteFM(0x04,0x82);
- return 1;
- } else return 0;
- }
- void initPiano(){
- int n;
- WriteFM(1,0);
- WriteFM(8,0);
- WriteFM(0xbd,0);
- WriteFM(0x20,0x21);
- WriteFM(0x23,0x11);
- WriteFM(0x40,0x4c);
- WriteFM(0x43,0);
- WriteFM(0x60,0xd2);
- WriteFM(0x63,0xd2);
- WriteFM(0x80,0x32);
- WriteFM(0x83,0x11);
- WriteFM(0xe0,0);
- WriteFM(0xe3,0);
- WriteFM(0xc0,4);
- music=FMload(FMfilename,&length);
- }