[Scummvm-cvs-logs] CVS: scummvm/sound fmopl.cpp,1.9,1.10 fmopl.h,1.4,1.5
Max Horn
fingolfin at users.sourceforge.net
Sun May 4 14:18:34 CEST 2003
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/backends/midi adlib.cpp,1.15,1.16
- Next message: [Scummvm-cvs-logs] CVS: scummvm/sky adlibchannel.h,1.1,1.2 adlibchannel.cpp,1.1,1.2 adlibmusic.cpp,1.1,1.2 adlibmusic.h,1.1,1.2
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/scummvm/scummvm/sound
In directory sc8-pr-cvs1:/tmp/cvs-serv4049/sound
Modified Files:
fmopl.cpp fmopl.h
Log Message:
new fmopl (from adplug, which has it from mame; we can use it under the LGPL should we ever have to)
Index: fmopl.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound/fmopl.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- fmopl.cpp 6 Mar 2003 21:46:53 -0000 1.9
+++ fmopl.cpp 4 May 2003 21:17:41 -0000 1.10
@@ -1,101 +1,288 @@
-/* ScummVM - Scumm Interpreter
- * Copyright (C) 1999-2000 Tatsuyuki Satoh
- * Copyright (C) 2001-2003 The ScummVM project
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+/*
+**
+** File: fmopl.c - software implementation of FM sound generator
[...3194 lines suppressed...]
+}
+
+void Y8950SetPortHandler(int which,OPL_PORTHANDLER_W PortHandler_w,OPL_PORTHANDLER_R PortHandler_r,int param)
+{
+ FM_OPL *OPL = OPL_Y8950[which];
+ OPL->porthandler_w = PortHandler_w;
+ OPL->porthandler_r = PortHandler_r;
+ OPL->port_param = param;
+}
+
+void Y8950SetKeyboardHandler(int which,OPL_PORTHANDLER_W KeyboardHandler_w,OPL_PORTHANDLER_R KeyboardHandler_r,int param)
+{
+ FM_OPL *OPL = OPL_Y8950[which];
+ OPL->keyboardhandler_w = KeyboardHandler_w;
+ OPL->keyboardhandler_r = KeyboardHandler_r;
+ OPL->keyboard_param = param;
+}
+
+#endif
+
Index: fmopl.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound/fmopl.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- fmopl.h 6 Mar 2003 21:46:54 -0000 1.4
+++ fmopl.h 4 May 2003 21:17:42 -0000 1.5
@@ -18,135 +18,120 @@
*
* $Header$
*
- * LGPL licensed version of MAMEs fmopl (V0.37a modified) by
- * Tatsuyuki Satoh. Included from LGPL'ed AdPlug.
+ * LGPL licensed version of MAMEs fmopl (V0.60a modified) by
+ * Tatsuyuki Satoh and Jarek Burczynski. Included from LGPL'ed AdPlug.
*/
-
#ifndef __FMOPL_H_
#define __FMOPL_H_
-#include "scummsys.h"
+
+#define HAS_YM3812 1
+
+/* --- select emulation chips --- */
+#define BUILD_YM3812 (HAS_YM3812)
+#define BUILD_YM3526 (HAS_YM3526)
+#define BUILD_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
+
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);
-#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] */
+#if BUILD_YM3812
- /* LFO */
- uint8 ams; /* ams flag */
- uint8 vib; /* vibrate flag */
- /* wave selector */
- int **wavetable;
-} OPL_SLOT;
+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);
-/* ---------- 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 */
+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);
- /* 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;
+#endif
-/* 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 */
+#if BUILD_YM3526
- /* FM channel slots */
- OPL_CH *P_CH; /* pointer of CH */
- int max_ch; /* maximum channel */
+/*
+** 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);
- /* 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 */
+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);
- /* LFO */
- int *ams_table;
- int *vib_table;
- int amsCnt;
- int amsIncr;
- int vibCnt;
- int vibIncr;
+#endif
- /* 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;
+#if BUILD_Y8950
-/* ---------- Generic interface section ---------- */
-#define OPL_TYPE_YM3526 (0)
-#define OPL_TYPE_YM3812 (OPL_TYPE_WAVESEL)
+#include "ymdeltat.h"
-void OPLBuildTables(int ENV_BITS_PARAM, int EG_ENT_PARAM);
+/* 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
-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
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/backends/midi adlib.cpp,1.15,1.16
- Next message: [Scummvm-cvs-logs] CVS: scummvm/sky adlibchannel.h,1.1,1.2 adlibchannel.cpp,1.1,1.2 adlibmusic.cpp,1.1,1.2 adlibmusic.h,1.1,1.2
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Scummvm-git-logs
mailing list