00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef FMOPL_H
00025 #define FMOPL_H
00026
00027 #ifdef USE_FMOPL_MIDI
00028
00029 namespace FMOpl_Pentagram {
00030
00031 typedef void (*OPL_TIMERHANDLER)(int channel,double interval_Sec);
00032 typedef void (*OPL_IRQHANDLER)(int param,int irq);
00033 typedef void (*OPL_UPDATEHANDLER)(int param,int min_interval_us);
00034
00035 #define OPL_TYPE_WAVESEL 0x01
00036
00037
00038 #define INDEX_AVEKM_M 0
00039 #define INDEX_KSLTL_M 2
00040 #define INDEX_AD_M 4
00041 #define INDEX_SR_M 6
00042 #define INDEX_WAVE_M 8
00043
00044
00045 #define INDEX_AVEKM_C 1
00046 #define INDEX_KSLTL_C 3
00047 #define INDEX_AD_C 5
00048 #define INDEX_SR_C 7
00049 #define INDEX_WAVE_C 9
00050
00051 #define INDEX_FB_C 10
00052 #define INDEX_PERC 11
00053
00054 #define CHP_CHAN 0
00055 #define CHP_NOTE 1
00056 #define CHP_COUNTER 2
00057 #define CHP_VEL 3
00058
00059
00060
00061 typedef struct fm_opl_slot {
00062 int TL;
00063 int TLL;
00064 uint8 KSR;
00065 int *AR;
00066 int *DR;
00067 int SL;
00068 int *RR;
00069 uint8 ksl;
00070 uint8 ksr;
00071 uint32 mul;
00072 uint32 Cnt;
00073 uint32 Incr;
00074
00075
00076 uint8 eg_typ;
00077 uint8 evm;
00078 int evc;
00079 int eve;
00080 int evs;
00081 int evsa;
00082 int evsd;
00083 int evsr;
00084
00085
00086 uint8 ams;
00087 uint8 vib;
00088
00089 int **wavetable;
00090 } OPL_SLOT;
00091
00092
00093 typedef struct fm_opl_channel {
00094 OPL_SLOT SLOT[2];
00095 uint8 CON;
00096 uint8 FB;
00097 int *connect1;
00098 int *connect2;
00099 int op1_out[2];
00100
00101
00102 uint32 block_fnum;
00103 uint8 kcode;
00104 uint32 fc;
00105 uint32 ksl_base;
00106 uint8 keyon;
00107 uint8 PAN;
00108 } OPL_CH;
00109
00110
00111 typedef struct fm_opl_f {
00112 uint8 type;
00113 int clock;
00114 int rate;
00115 double freqbase;
00116 double TimerBase;
00117 uint8 address;
00118 uint8 status;
00119 uint8 statusmask;
00120 uint32 mode;
00121
00122
00123 int T[2];
00124 uint8 st[2];
00125
00126
00127 OPL_CH *P_CH;
00128 int max_ch;
00129
00130
00131 uint8 rythm;
00132
00133
00134 int AR_TABLE[75];
00135 int DR_TABLE[75];
00136 uint32 FN_TABLE[1024];
00137
00138
00139 int *ams_table;
00140 int *vib_table;
00141 int amsCnt;
00142 int amsIncr;
00143 int vibCnt;
00144 int vibIncr;
00145
00146
00147 uint8 wavesel;
00148
00149
00150 OPL_TIMERHANDLER TimerHandler;
00151 int TimerParam;
00152 OPL_IRQHANDLER IRQHandler;
00153 int IRQParam;
00154 OPL_UPDATEHANDLER UpdateHandler;
00155 int UpdateParam;
00156 } FM_OPL;
00157
00158
00159 #define OPL_TYPE_YM3526 (0)
00160 #define OPL_TYPE_YM3812 (OPL_TYPE_WAVESEL)
00161
00162
00163 #define OPL_REG_AVEKM_M 0x20
00164 #define OPL_REG_KSLTL_M 0x40
00165 #define OPL_REG_AD_M 0x60
00166 #define OPL_REG_SR_M 0x80
00167 #define OPL_REG_WAVE_M 0xE0
00168
00169
00170 #define OPL_REG_AVEKM_C 0x23
00171 #define OPL_REG_KSLTL_C 0x43
00172 #define OPL_REG_AD_C 0x63
00173 #define OPL_REG_SR_C 0x83
00174 #define OPL_REG_WAVE_C 0xE3
00175
00176 #define OPL_REG_FB_C 0xC0
00177
00178
00179 FM_OPL *OPLCreate(int type, int clock, int rate);
00180 void OPLDestroy(FM_OPL *OPL);
00181 void OPLSetTimerHandler(FM_OPL *OPL,OPL_TIMERHANDLER TimerHandler,int channelOffset);
00182 void OPLSetIRQHandler(FM_OPL *OPL,OPL_IRQHANDLER IRQHandler,int param);
00183 void OPLSetUpdateHandler(FM_OPL *OPL,OPL_UPDATEHANDLER UpdateHandler,int param);
00184
00185 void OPLResetChip(FM_OPL *OPL);
00186 int OPLWrite(FM_OPL *OPL,int a,int v);
00187 unsigned char OPLRead(FM_OPL *OPL,int a);
00188 int OPLTimerOver(FM_OPL *OPL,int c);
00189 void OPLWriteReg(FM_OPL *OPL, int r, int v);
00190 void OPLSetPan(FM_OPL *OPL,int c, int pan);
00191
00192 void YM3812UpdateOne_Mono(FM_OPL *OPL, sint16 *buffer, int length);
00193 void YM3812UpdateOne_Stereo(FM_OPL *OPL, sint16 *buffer, int length);
00194
00195 };
00196
00197 #endif //USE_FMOPL_MIDI
00198
00199 #endif //FMOPL_H