|
|
1.1 ! root 1: /* ! 2: File: fm.h -- header file for software emuration for FM sound genelator ! 3: ! 4: */ ! 5: #ifndef _H_FM_FM_ ! 6: #define _H_FM_FM_ ! 7: ! 8: /* #define BUILD_YM2203 (HAS_YM2203) */ /* build YM2203(OPN) emulator */ ! 9: /* #define BUILD_YM2608 (HAS_YM2608) */ /* build YM2608(OPNA) emulator */ ! 10: /* #define BUILD_YM2610 (HAS_YM2610) */ /* build YM2610(OPNB) emulator */ ! 11: /* #define BUILD_YM2610B (HAS_YM2610B) */ /* build YM2610B(OPNB?)emulator */ ! 12: #define BUILD_YM2612 (HAS_YM2612) /* build YM2612(OPN2) emulator */ ! 13: /* #define BUILD_YM2151 (HAS_YM2151) */ /* build YM2151(OPM) emulator */ ! 14: ! 15: /* stereo mixing / separate */ ! 16: /*#define FM_STEREO_MIX */ ! 17: /* output bit size 8 or 16 */ ! 18: #define FM_OUTPUT_BIT 16 ! 19: ! 20: #define YM2203_NUMBUF 1 ! 21: ! 22: #ifdef FM_STEREO_MIX ! 23: #define YM2151_NUMBUF 1 ! 24: #define YM2608_NUMBUF 1 ! 25: #define YM2612_NUMBUF 1 ! 26: #define YM2610_NUMBUF 1 ! 27: #else ! 28: #define YM2151_NUMBUF 2 /* FM L+R */ ! 29: #define YM2608_NUMBUF 2 /* FM L+R+ADPCM+RYTHM */ ! 30: #define YM2612_NUMBUF 2 /* FM L+R */ ! 31: #define YM2610_NUMBUF 2 ! 32: #endif ! 33: ! 34: #if (FM_OUTPUT_BIT==16) ! 35: typedef unsigned short FMSAMPLE; ! 36: typedef unsigned long FMSAMPLE_MIX; ! 37: #endif ! 38: #if (FM_OUTPUT_BIT==8) ! 39: typedef unsigned char FMSAMPLE; ! 40: typedef unsigned short FMSAMPLE_MIX; ! 41: #endif ! 42: ! 43: /* For YM2151/YM2608/YM2612 option */ ! 44: ! 45: typedef void (*FM_TIMERHANDLER)(int n,int c,int cnt,double stepTime); ! 46: typedef void (*FM_IRQHANDLER)(int n,int irq); ! 47: /* FM_TIMERHANDLER : Stop or Start timer */ ! 48: /* int n = chip number */ ! 49: /* int c = Channel 0=TimerA,1=TimerB */ ! 50: /* int count = timer count (0=stop) */ ! 51: /* doube stepTime = step time of one count (sec.)*/ ! 52: ! 53: /* FM_IRQHHANDLER : IRQ level changing sense */ ! 54: /* int n = chip number */ ! 55: /* int irq = IRQ level 0=OFF,1=ON */ ! 56: ! 57: #ifdef BUILD_OPN ! 58: /* -------------------- YM2203/YM2608 Interface -------------------- */ ! 59: /* ! 60: ** 'n' : YM2203 chip number 'n' ! 61: ** 'r' : register ! 62: ** 'v' : value ! 63: */ ! 64: /*void OPNWriteReg(int n, int r, int v); */ ! 65: ! 66: /* ! 67: ** read status YM2203 chip number 'n' ! 68: */ ! 69: unsigned char OPNReadStatus(int n); ! 70: ! 71: #endif /* BUILD_OPN */ ! 72: ! 73: #if BUILD_YM2203 ! 74: /* -------------------- YM2203(OPN) Interface -------------------- */ ! 75: ! 76: /* ! 77: ** Initialize YM2203 emulator(s). ! 78: ** ! 79: ** 'num' is the number of virtual YM2203's to allocate ! 80: ** 'rate' is sampling rate ! 81: ** return 0 = success ! 82: */ ! 83: int YM2203Init(int num, int baseclock, int rate, ! 84: FM_TIMERHANDLER TimerHandler,FM_IRQHANDLER IRQHandler); ! 85: ! 86: /* ! 87: ** shutdown the YM2203 emulators .. make sure that no sound system stuff ! 88: ** is touching our audio buffers ... ! 89: */ ! 90: void YM2203Shutdown(void); ! 91: ! 92: /* ! 93: ** reset all chip registers for YM2203 number 'num' ! 94: */ ! 95: void YM2203ResetChip(int num); ! 96: ! 97: void YM2203UpdateOne(int num, void *buffer, int length); ! 98: ! 99: /* ! 100: ** return : InterruptLevel ! 101: */ ! 102: int YM2203Write(int n,int a,int v); ! 103: unsigned char YM2203Read(int n,int a); ! 104: ! 105: /* ! 106: ** Timer OverFlow ! 107: */ ! 108: int YM2203TimerOver(int n, int c); ! 109: ! 110: /*int YM2203SetBuffer(int n, FMSAMPLE *buf );*/ ! 111: ! 112: #endif /* BUILD_YM2203 */ ! 113: ! 114: #if BUILD_YM2608 ! 115: /* -------------------- YM2608(OPNA) Interface -------------------- */ ! 116: ! 117: int YM2608Init(int num, int baseclock, int rate, ! 118: void **pcmroma,int *pcmsizea,short *rhythmrom,int *rhythmpos, ! 119: FM_TIMERHANDLER TimerHandler,FM_IRQHANDLER IRQHandler); ! 120: void YM2608Shutdown(void); ! 121: void YM2608ResetChip(int num); ! 122: void YM2608UpdateOne(int num, void **buffer, int length); ! 123: ! 124: int YM2608Write(int n, int a,int v); ! 125: unsigned char YM2608Read(int n,int a); ! 126: int YM2608TimerOver(int n, int c ); ! 127: /*int YM2608SetBuffer(int n, FMSAMPLE **buf );*/ ! 128: #endif /* BUILD_YM2608 */ ! 129: ! 130: #if BUILD_YM2610 ! 131: /* -------------------- YM2610(OPNB) Interface -------------------- */ ! 132: ! 133: #define MAX_2610 (2) ! 134: ! 135: int YM2610Init(int num, int baseclock, int rate, ! 136: void **pcmroma,int *pcmasize,void **pcmromb,int *pcmbsize, ! 137: FM_TIMERHANDLER TimerHandler,FM_IRQHANDLER IRQHandler); ! 138: void YM2610Shutdown(void); ! 139: void YM2610ResetChip(int num); ! 140: void YM2610UpdateOne(int num, void **buffer, int length); ! 141: #if BUILD_YM2610B ! 142: void YM2610BUpdateOne(int num, void **buffer, int length); ! 143: #endif ! 144: ! 145: int YM2610Write(int n, int a,int v); ! 146: unsigned char YM2610Read(int n,int a); ! 147: int YM2610TimerOver(int n, int c ); ! 148: /*int YM2610SetBuffer(int n, FMSAMPLE **buf );*/ ! 149: ! 150: #ifdef __RAINE__ ! 151: void Set_YM2610_ADPCM_Buffers(int num, UBYTE *bufa, UBYTE *bufb, ULONG sizea, ULONG sizeb); ! 152: #endif ! 153: #endif /* BUILD_YM2610 */ ! 154: ! 155: #if BUILD_YM2612 ! 156: int YM2612Init(int num, int baseclock, int rate, ! 157: FM_TIMERHANDLER TimerHandler,FM_IRQHANDLER IRQHandler); ! 158: void YM2612Shutdown(void); ! 159: void YM2612ResetChip(int num); ! 160: void YM2612UpdateOne(int num, void **buffer, int length); ! 161: int YM2612Write(int n, int a,int v); ! 162: unsigned char YM2612Read(int n,int a); ! 163: int YM2612TimerOver(int n, int c ); ! 164: FMSAMPLE *YM2612Buffer(int n); ! 165: /*int YM2612SetBuffer(int n, FMSAMPLE **buf );*/ ! 166: ! 167: #endif /* BUILD_YM2612 */ ! 168: ! 169: #if BUILD_YM2151 ! 170: /* -------------------- YM2151(OPM) Interface -------------------- */ ! 171: /* ! 172: ** Initialize YM2151 emulator(s). ! 173: ** ! 174: ** 'num' is the number of virtual YM2151's to allocate ! 175: ** 'rate' is sampling rate ! 176: ** 'bitsize' is sampling bits (8 or 16) ! 177: ** 'bufsiz' is the size of the buffer ! 178: */ ! 179: int OPMInit(int num, int baseclock, int rate, ! 180: FM_TIMERHANDLER TimerHandler,FM_IRQHANDLER IRQHandler); ! 181: void OPMShutdown(void); ! 182: void OPMResetChip(int num); ! 183: ! 184: void OPMUpdateOne(int num, void **buffer, int length ); ! 185: void OPMWriteReg(int n, int r, int v); ! 186: unsigned char OPMReadStatus(int n ); ! 187: /* ----- get pointer sound buffer ----- */ ! 188: FMSAMPLE *OPMBuffer(int n,int c ); ! 189: /* ----- set sound buffer ----- */ ! 190: /*int OPMSetBuffer(int n, FMSAMPLE **buf );*/ ! 191: /* ---- set user interrupt handler ----- */ ! 192: void OPMSetIrqHandler(int n, void (*handler)(void) ); ! 193: /* ---- set callback hander when port CT0/1 write ----- */ ! 194: /* CT.bit0 = CT0 , CT.bit1 = CT1 */ ! 195: void OPMSetPortHander(int n,void (*PortWrite)(int offset,int CT) ); ! 196: /* JB 981119 - so it will match MAME's memory write functions scheme*/ ! 197: ! 198: int YM2151Write(int n,int a,int v); ! 199: unsigned char YM2151Read(int n,int a); ! 200: int YM2151TimerOver(int n,int c); ! 201: #endif /* BUILD_YM2151 */ ! 202: ! 203: #endif /* _H_FM_FM_ */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.