aboutsummaryrefslogtreecommitdiff
path: root/sound/fmopl.h
diff options
context:
space:
mode:
authorJamieson Christian2003-07-11 07:14:21 +0000
committerJamieson Christian2003-07-11 07:14:21 +0000
commit8b8b964aadcf0f37cfb853c83857da7271af5ebc (patch)
tree0084198c30998e89b2331a8b678cc42a21dbfa72 /sound/fmopl.h
parent39b37df37a7fed6f5dd62d11fb10e4b8276f05c1 (diff)
downloadscummvm-rg350-8b8b964aadcf0f37cfb853c83857da7271af5ebc.tar.gz
scummvm-rg350-8b8b964aadcf0f37cfb853c83857da7271af5ebc.tar.bz2
scummvm-rg350-8b8b964aadcf0f37cfb853c83857da7271af5ebc.zip
Reverted to "old" YM3812 (FMOPL) emulator code.
Until specific information regarding the benefits of migrating to the new emulator can be made available, the "old" code will remain in effect for the benefit of slower hardware platforms such as some WinCE-based devices. svn-id: r8903
Diffstat (limited to 'sound/fmopl.h')
-rw-r--r--sound/fmopl.h234
1 files changed, 122 insertions, 112 deletions
diff --git a/sound/fmopl.h b/sound/fmopl.h
index 0b4320e715..8fbeb175e3 100644
--- a/sound/fmopl.h
+++ b/sound/fmopl.h
@@ -18,125 +18,135 @@
*
* $Header$
*
- * LGPL licensed version of MAMEs fmopl (V0.60a modified) by
- * Tatsuyuki Satoh and Jarek Burczynski. Included from LGPL'ed AdPlug.
+ * LGPL licensed version of MAMEs fmopl (V0.37a modified) by
+ * Tatsuyuki Satoh. Included from LGPL'ed AdPlug.
*/
+
#ifndef __FMOPL_H_
#define __FMOPL_H_
-
-#define HAS_YM3812 1
-
-/* --- select emulation chips --- */
-#ifdef _MSC_VER
-// FIXME: how to fix it for VC6 ?
-#define BUILD_YM3812 1
-#else
-#define BUILD_YM3812 defined(HAS_YM3812) && HAS_YM3812
-#endif
-#define BUILD_YM3526 defined(HAS_YM3526) && HAS_YM3526
-#define BUILD_Y8950 defined(HAS_Y8950) && HAS_Y8950
-
-/* select output bits size of output : 8 or 16 */
-#define OPL_SAMPLE_BITS 16
-
-/* compiler dependence */
-#ifndef OSD_CPU_H
-#define OSD_CPU_H
-typedef unsigned char UINT8; /* unsigned 8bit */
-typedef unsigned short UINT16; /* unsigned 16bit */
-typedef unsigned int UINT32; /* unsigned 32bit */
-typedef signed char INT8; /* signed 8bit */
-typedef signed short INT16; /* signed 16bit */
-typedef signed int INT32; /* signed 32bit */
-#endif
-
-#if (OPL_SAMPLE_BITS==16)
-typedef INT16 OPLSAMPLE;
-#endif
-#if (OPL_SAMPLE_BITS==8)
-typedef INT8 OPLSAMPLE;
-#endif
-
+#include "scummsys.h"
typedef void (*OPL_TIMERHANDLER)(int channel,double interval_Sec);
typedef void (*OPL_IRQHANDLER)(int param,int irq);
typedef void (*OPL_UPDATEHANDLER)(int param,int min_interval_us);
-typedef void (*OPL_PORTHANDLER_W)(int param,unsigned char data);
-typedef unsigned char (*OPL_PORTHANDLER_R)(int param);
-
-
-#if BUILD_YM3812
-
-int YM3812Init(int num, int clock, int rate);
-void YM3812Shutdown(void);
-void YM3812ResetChip(int which);
-int YM3812Write(int which, int a, int v);
-unsigned char YM3812Read(int which, int a);
-int YM3812TimerOver(int which, int c);
-void YM3812UpdateOne(int which, INT16 *buffer, int length);
-
-void YM3812SetTimerHandler(int which, OPL_TIMERHANDLER TimerHandler, int channelOffset);
-void YM3812SetIRQHandler(int which, OPL_IRQHANDLER IRQHandler, int param);
-void YM3812SetUpdateHandler(int which, OPL_UPDATEHANDLER UpdateHandler, int param);
-
-#endif
-
-
-#if BUILD_YM3526
-
-/*
-** Initialize YM3526 emulator(s).
-**
-** 'num' is the number of virtual YM3526's to allocate
-** 'clock' is the chip clock in Hz
-** 'rate' is sampling rate
-*/
-int YM3526Init(int num, int clock, int rate);
-/* shutdown the YM3526 emulators*/
-void YM3526Shutdown(void);
-void YM3526ResetChip(int which);
-int YM3526Write(int which, int a, int v);
-unsigned char YM3526Read(int which, int a);
-int YM3526TimerOver(int which, int c);
-/*
-** Generate samples for one of the YM3526's
-**
-** 'which' is the virtual YM3526 number
-** '*buffer' is the output buffer pointer
-** 'length' is the number of samples that should be generated
-*/
-void YM3526UpdateOne(int which, INT16 *buffer, int length);
-
-void YM3526SetTimerHandler(int which, OPL_TIMERHANDLER TimerHandler, int channelOffset);
-void YM3526SetIRQHandler(int which, OPL_IRQHANDLER IRQHandler, int param);
-void YM3526SetUpdateHandler(int which, OPL_UPDATEHANDLER UpdateHandler, int param);
-
-#endif
-
-
-#if BUILD_Y8950
-
-#include "ymdeltat.h"
-
-/* Y8950 port handlers */
-void Y8950SetPortHandler(int which, OPL_PORTHANDLER_W PortHandler_w, OPL_PORTHANDLER_R PortHandler_r, int param);
-void Y8950SetKeyboardHandler(int which, OPL_PORTHANDLER_W KeyboardHandler_w, OPL_PORTHANDLER_R KeyboardHandler_r, int param);
-void Y8950SetDeltaTMemory(int which, void * deltat_rom, int deltat_rom_size );
-
-int Y8950Init (int num, int clock, int rate);
-void Y8950Shutdown (void);
-void Y8950ResetChip (int which);
-int Y8950Write (int which, int a, int v);
-unsigned char Y8950Read (int which, int a);
-int Y8950TimerOver (int which, int c);
-void Y8950UpdateOne (int which, INT16 *buffer, int length);
-
-void Y8950SetTimerHandler (int which, OPL_TIMERHANDLER TimerHandler, int channelOffset);
-void Y8950SetIRQHandler (int which, OPL_IRQHANDLER IRQHandler, int param);
-void Y8950SetUpdateHandler (int which, OPL_UPDATEHANDLER UpdateHandler, int param);
-
-#endif
-
+#define OPL_TYPE_WAVESEL 0x01 /* waveform select */
+
+/* Saving is necessary for member of the 'R' mark for suspend/resume */
+/* ---------- OPL one of slot ---------- */
+typedef struct fm_opl_slot {
+ int TL; /* total level :TL << 8 */
+ int TLL; /* adjusted now TL */
+ uint8 KSR; /* key scale rate :(shift down bit) */
+ int *AR; /* attack rate :&AR_TABLE[AR<<2] */
+ int *DR; /* decay rate :&DR_TABLE[DR<<2] */
+ int SL; /* sustain level :SL_TABLE[SL] */
+ int *RR; /* release rate :&DR_TABLE[RR<<2] */
+ uint8 ksl; /* keyscale level :(shift down bits) */
+ uint8 ksr; /* key scale rate :kcode>>KSR */
+ uint mul; /* multiple :ML_TABLE[ML] */
+ uint Cnt; /* frequency count */
+ uint Incr; /* frequency step */
+
+ /* envelope generator state */
+ uint8 eg_typ;/* envelope type flag */
+ uint8 evm; /* envelope phase */
+ int evc; /* envelope counter */
+ int eve; /* envelope counter end point */
+ int evs; /* envelope counter step */
+ int evsa; /* envelope step for AR :AR[ksr] */
+ int evsd; /* envelope step for DR :DR[ksr] */
+ int evsr; /* envelope step for RR :RR[ksr] */
+
+ /* LFO */
+ uint8 ams; /* ams flag */
+ uint8 vib; /* vibrate flag */
+ /* wave selector */
+ int **wavetable;
+} OPL_SLOT;
+
+/* ---------- OPL one of channel ---------- */
+typedef struct fm_opl_channel {
+ OPL_SLOT SLOT[2];
+ uint8 CON; /* connection type */
+ uint8 FB; /* feed back :(shift down bit)*/
+ int *connect1; /* slot1 output pointer */
+ int *connect2; /* slot2 output pointer */
+ int op1_out[2]; /* slot1 output for selfeedback */
+
+ /* phase generator state */
+ uint block_fnum; /* block+fnum */
+ uint8 kcode; /* key code : KeyScaleCode */
+ uint fc; /* Freq. Increment base */
+ uint ksl_base; /* KeyScaleLevel Base step */
+ uint8 keyon; /* key on/off flag */
+} OPL_CH;
+
+/* OPL state */
+typedef struct fm_opl_f {
+ uint8 type; /* chip type */
+ int clock; /* master clock (Hz) */
+ int rate; /* sampling rate (Hz) */
+ double freqbase; /* frequency base */
+ double TimerBase; /* Timer base time (==sampling time) */
+ uint8 address; /* address register */
+ uint8 status; /* status flag */
+ uint8 statusmask; /* status mask */
+ uint mode; /* Reg.08 : CSM , notesel,etc. */
+
+ /* Timer */
+ int T[2]; /* timer counter */
+ uint8 st[2]; /* timer enable */
+
+ /* FM channel slots */
+ OPL_CH *P_CH; /* pointer of CH */
+ int max_ch; /* maximum channel */
+
+ /* Rythm sention */
+ uint8 rythm; /* Rythm mode , key flag */
+
+ /* time tables */
+ int AR_TABLE[75]; /* atttack rate tables */
+ int DR_TABLE[75]; /* decay rate tables */
+ uint FN_TABLE[1024];/* fnumber -> increment counter */
+
+ /* LFO */
+ int *ams_table;
+ int *vib_table;
+ int amsCnt;
+ int amsIncr;
+ int vibCnt;
+ int vibIncr;
+
+ /* wave selector enable flag */
+ uint8 wavesel;
+
+ /* external event callback handler */
+ OPL_TIMERHANDLER TimerHandler; /* TIMER handler */
+ int TimerParam; /* TIMER parameter */
+ OPL_IRQHANDLER IRQHandler; /* IRQ handler */
+ int IRQParam; /* IRQ parameter */
+ OPL_UPDATEHANDLER UpdateHandler; /* stream update handler */
+ int UpdateParam; /* stream update parameter */
+} FM_OPL;
+
+/* ---------- Generic interface section ---------- */
+#define OPL_TYPE_YM3526 (0)
+#define OPL_TYPE_YM3812 (OPL_TYPE_WAVESEL)
+
+void OPLBuildTables(int ENV_BITS_PARAM, int EG_ENT_PARAM);
+
+FM_OPL *OPLCreate(int type, int clock, int rate);
+void OPLDestroy(FM_OPL *OPL);
+void OPLSetTimerHandler(FM_OPL *OPL, OPL_TIMERHANDLER TimerHandler, int channelOffset);
+void OPLSetIRQHandler(FM_OPL *OPL, OPL_IRQHANDLER IRQHandler, int param);
+void OPLSetUpdateHandler(FM_OPL *OPL, OPL_UPDATEHANDLER UpdateHandler, int param);
+
+void OPLResetChip(FM_OPL *OPL);
+int OPLWrite(FM_OPL *OPL, int a, int v);
+unsigned char OPLRead(FM_OPL *OPL, int a);
+int OPLTimerOver(FM_OPL *OPL, int c);
+void OPLWriteReg(FM_OPL *OPL, int r, int v);
+void YM3812UpdateOne(FM_OPL *OPL, int16 *buffer, int length);
#endif