ScummVM API documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
fm_opl.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef NUVIE_SOUND_ADPLUG_FM_OPL_H
23 #define NUVIE_SOUND_ADPLUG_FM_OPL_H
24 
25 #include "common/scummsys.h"
26 
27 namespace Ultima {
28 namespace Nuvie {
29 
30 #define HAS_YM3812 1
31 #define HAS_YM3526 0
32 #define HAS_Y8950 0
33 
34 /* --- select emulation chips --- */
35 #define BUILD_YM3812 (HAS_YM3812)
36 #define BUILD_YM3526 (HAS_YM3526)
37 #define BUILD_Y8950 (HAS_Y8950)
38 
39 /* select output bits size of output : 8 or 16 */
40 #define OPL_SAMPLE_BITS 16
41 
42 #if (OPL_SAMPLE_BITS==16)
43 typedef int16 OPLSAMPLE;
44 #endif
45 #if (OPL_SAMPLE_BITS==8)
46 typedef int8 OPLSAMPLE;
47 #endif
48 
49 
50 typedef void (*OPL_TIMERHANDLER)(int channel, double interval_Sec);
51 typedef void (*OPL_IRQHANDLER)(int param, int irq);
52 typedef void (*OPL_UPDATEHANDLER)(int param, int min_interval_us);
53 typedef void (*OPL_PORTHANDLER_W)(int param, unsigned char data);
54 typedef unsigned char (*OPL_PORTHANDLER_R)(int param);
55 
56 
57 #if BUILD_YM3812
58 
59 int YM3812Init(int num, int clock, int rate);
60 void YM3812Shutdown(void);
61 void YM3812ResetChip(int which);
62 int YM3812Write(int which, int a, int v);
63 unsigned char YM3812Read(int which, int a);
64 int YM3812TimerOver(int which, int c);
65 void YM3812UpdateOne(int which, int16 *buffer, int length);
66 
67 void YM3812SetTimerHandler(int which, OPL_TIMERHANDLER TimerHandler, int channelOffset);
68 void YM3812SetIRQHandler(int which, OPL_IRQHANDLER IRQHandler, int param);
69 void YM3812SetUpdateHandler(int which, OPL_UPDATEHANDLER UpdateHandler, int param);
70 
71 #endif
72 
73 
74 #if BUILD_YM3526
75 
76 /*
77 ** Initialize YM3526 emulator(s).
78 **
79 ** 'num' is the number of virtual YM3526's to allocate
80 ** 'clock' is the chip clock in Hz
81 ** 'rate' is sampling rate
82 */
83 int YM3526Init(int num, int clock, int rate);
84 /* shutdown the YM3526 emulators*/
85 void YM3526Shutdown(void);
86 void YM3526ResetChip(int which);
87 int YM3526Write(int which, int a, int v);
88 unsigned char YM3526Read(int which, int a);
89 int YM3526TimerOver(int which, int c);
90 /*
91 ** Generate samples for one of the YM3526's
92 **
93 ** 'which' is the virtual YM3526 number
94 ** '*buffer' is the output buffer pointer
95 ** 'length' is the number of samples that should be generated
96 */
97 void YM3526UpdateOne(int which, int16 *buffer, int length);
98 
99 void YM3526SetTimerHandler(int which, OPL_TIMERHANDLER TimerHandler, int channelOffset);
100 void YM3526SetIRQHandler(int which, OPL_IRQHANDLER IRQHandler, int param);
101 void YM3526SetUpdateHandler(int which, OPL_UPDATEHANDLER UpdateHandler, int param);
102 
103 #endif
104 
105 } // End of namespace Nuvie
106 } // End of namespace Ultima
107 
108 #if BUILD_Y8950
109 
110 #include "ymdeltat.h"
111 
112 namespace Ultima {
113 namespace Nuvie {
114 
115 /* Y8950 port handlers */
116 void Y8950SetPortHandler(int which, OPL_PORTHANDLER_W PortHandler_w, OPL_PORTHANDLER_R PortHandler_r, int param);
117 void Y8950SetKeyboardHandler(int which, OPL_PORTHANDLER_W KeyboardHandler_w, OPL_PORTHANDLER_R KeyboardHandler_r, int param);
118 void Y8950SetDeltaTMemory(int which, void *deltat_rom, int deltat_rom_size);
119 
120 int Y8950Init(int num, int clock, int rate);
121 void Y8950Shutdown(void);
122 void Y8950ResetChip(int which);
123 int Y8950Write(int which, int a, int v);
124 unsigned char Y8950Read(int which, int a);
125 int Y8950TimerOver(int which, int c);
126 void Y8950UpdateOne(int which, int16 *buffer, int length);
127 
128 void Y8950SetTimerHandler(int which, OPL_TIMERHANDLER TimerHandler, int channelOffset);
129 void Y8950SetIRQHandler(int which, OPL_IRQHANDLER IRQHandler, int param);
130 void Y8950SetUpdateHandler(int which, OPL_UPDATEHANDLER UpdateHandler, int param);
131 
132 } // End of namespace Nuvie
133 } // End of namespace Ultima
134 
135 #endif
136 
137 #endif
Definition: detection.h:27