1 /***************************************************************************
2 
3     sndintrf.h
4 
5     Core sound interface functions and definitions.
6 
7     Copyright (c) 1996-2007, Nicola Salmoria and the MAME Team.
8     Visit http://mamedev.org for licensing and usage restrictions.
9 
10 ***************************************************************************/
11 
12 #if 0		/* QUASI88 (Compiler depend) */
13 #pragma once
14 #endif		/* QUASI88 */
15 
16 #ifndef __SNDINTRF_H__
17 #define __SNDINTRF_H__
18 
19 #if 0		/* QUASI88 */
20 #include "memory.h"
21 #endif		/* QUASI88 */
22 #include "mame.h"
23 #include "state.h"
24 #include "timer.h"
25 
26 
27 /***************************************************************************
28     CONSTANTS
29 ***************************************************************************/
30 
31 /* Enum listing all the sound chips */
32 enum
33 {
34 	SOUND_DUMMY,
35 	SOUND_CUSTOM,
36 	SOUND_SAMPLES,
37 	SOUND_DAC,
38 	SOUND_DMADAC,
39 	SOUND_DISCRETE,
40 	SOUND_AY8910,
41 	SOUND_YM2203,
42 	SOUND_YM2151,
43 	SOUND_YM2608,
44 	SOUND_YM2610,
45 	SOUND_YM2610B,
46 	SOUND_YM2612,
47 	SOUND_YM3438,
48 	SOUND_YM2413,
49 	SOUND_YM3812,
50 	SOUND_YM3526,
51 	SOUND_YMZ280B,
52 	SOUND_Y8950,
53 	SOUND_SN76477,
54 	SOUND_SN76496,
55 	SOUND_POKEY,
56 	SOUND_NES,
57 	SOUND_ASTROCADE,
58 	SOUND_NAMCO,
59 	SOUND_NAMCO_15XX,
60 	SOUND_NAMCO_CUS30,
61 	SOUND_NAMCO_52XX,
62 	SOUND_NAMCO_54XX,
63 	SOUND_NAMCO_63701X,
64 	SOUND_NAMCONA,
65 	SOUND_TMS36XX,
66 	SOUND_TMS3615,
67 	SOUND_TMS5110,
68 	SOUND_TMS5220,
69 	SOUND_VLM5030,
70 	SOUND_OKIM6295,
71 	SOUND_MSM5205,
72 	SOUND_MSM5232,
73 	SOUND_UPD7759,
74 	SOUND_HC55516,
75 	SOUND_K005289,
76 	SOUND_K007232,
77 	SOUND_K051649,
78 	SOUND_K053260,
79 	SOUND_K054539,
80 	SOUND_SEGAPCM,
81 	SOUND_RF5C68,
82 	SOUND_CEM3394,
83 	SOUND_C140,
84 	SOUND_QSOUND,
85 	SOUND_SAA1099,
86 	SOUND_IREMGA20,
87 	SOUND_ES5503,
88 	SOUND_ES5505,
89 	SOUND_ES5506,
90 	SOUND_BSMT2000,
91 	SOUND_YMF262,
92 	SOUND_YMF278B,
93 	SOUND_GAELCO_CG1V,
94 	SOUND_GAELCO_GAE1,
95 	SOUND_X1_010,
96 	SOUND_MULTIPCM,
97 	SOUND_C6280,
98 	SOUND_TIA,
99 	SOUND_SP0250,
100 	SOUND_SCSP,
101 	SOUND_PSXSPU,
102 	SOUND_YMF271,
103 	SOUND_CDDA,
104 	SOUND_ICS2115,
105 	SOUND_ST0016,
106 	SOUND_C352,
107 	SOUND_VRENDER0,
108 	SOUND_VOTRAX,
109 	SOUND_ES8712,
110 	SOUND_RF5C400,
111 	SOUND_SPEAKER,
112 	SOUND_CDP1869,
113 	SOUND_BEEP,
114 	SOUND_WAVE,
115 	SOUND_SID6581,
116 	SOUND_SID8580,
117 	SOUND_SP0256,
118 	SOUND_S14001A,
119 
120 #if 1		/* QUASI88 */
121 	SOUND_BEEP88,
122 	SOUND_FMGEN2203,
123 	SOUND_FMGEN2608,
124 #endif		/* QUASI88 */
125 
126 	/* filters start here */
127 	SOUND_FILTER_VOLUME,
128 	SOUND_FILTER_RC,
129 	SOUND_FILTER_LOWPASS,
130 
131 	SOUND_COUNT
132 };
133 
134 
135 /* Sound information constants */
136 enum
137 {
138 	/* --- the following bits of info are returned as 64-bit signed integers --- */
139 	SNDINFO_INT_FIRST = 0x00000,
140 
141 	SNDINFO_INT_CORE_SPECIFIC = 0x08000,				/* R/W: core-specific values start here */
142 
143 	/* --- the following bits of info are returned as pointers to data or functions --- */
144 	SNDINFO_PTR_FIRST = 0x10000,
145 
146 	SNDINFO_PTR_SET_INFO = SNDINFO_PTR_FIRST,			/* R/O: void (*set_info)(void *token, UINT32 state, sndinfo *info) */
147 	SNDINFO_PTR_START,									/* R/O: void *(*start)(int index, int clock, const void *config) */
148 	SNDINFO_PTR_STOP,									/* R/O: void (*stop)(void *token) */
149 	SNDINFO_PTR_RESET,									/* R/O: void (*reset)(void *token) */
150 
151 	SNDINFO_PTR_CORE_SPECIFIC = 0x18000,				/* R/W: core-specific values start here */
152 
153 	/* --- the following bits of info are returned as NULL-terminated strings --- */
154 	SNDINFO_STR_FIRST = 0x20000,
155 
156 	SNDINFO_STR_NAME = SNDINFO_STR_FIRST,				/* R/O: name of the sound chip */
157 	SNDINFO_STR_CORE_FAMILY,							/* R/O: family of the sound chip */
158 	SNDINFO_STR_CORE_VERSION,							/* R/O: version of the sound core */
159 	SNDINFO_STR_CORE_FILE,								/* R/O: file containing the sound core */
160 	SNDINFO_STR_CORE_CREDITS,							/* R/O: credits for the sound core */
161 
162 	SNDINFO_STR_CORE_SPECIFIC = 0x28000					/* R/W: core-specific values start here */
163 };
164 
165 
166 
167 /***************************************************************************
168     TYPE DEFINITIONS
169 ***************************************************************************/
170 
171 typedef union _sndinfo sndinfo;
172 union _sndinfo
173 {
174 	INT64	i;											/* generic integers */
175 	void *	p;											/* generic pointers */
176 	genf *  f;											/* generic function pointers */
177 	const char *s;										/* generic strings */
178 
179 	void	(*set_info)(void *token, UINT32 state, sndinfo *info);
180 	void *	(*start)(int index, int clock, const void *config);/* SNDINFO_PTR_START */
181 	void	(*stop)(void *token);						/* SNDINFO_PTR_STOP */
182 	void	(*reset)(void *token);						/* SNDINFO_PTR_RESET */
183 };
184 
185 
186 
187 /***************************************************************************
188     CHIP INTERFACES BY INDEX
189 ***************************************************************************/
190 
191 /* get info accessors */
192 INT64 sndnum_get_info_int(int sndnum, UINT32 state);
193 void *sndnum_get_info_ptr(int sndnum, UINT32 state);
194 genf *sndnum_get_info_fct(int sndnum, UINT32 state);
195 const char *sndnum_get_info_string(int sndnum, UINT32 state);
196 
197 /* set info accessors */
198 void sndnum_set_info_int(int sndnum, UINT32 state, INT64 data);
199 void sndnum_set_info_ptr(int sndnum, UINT32 state, void *data);
200 void sndnum_set_info_fct(int sndnum, UINT32 state, genf *data);
201 
202 #define sndnum_name(sndnum)						sndnum_get_info_string(sndnum, SNDINFO_STR_NAME)
203 #define sndnum_core_family(sndnum)				sndnum_get_info_string(sndnum, SNDINFO_STR_CORE_FAMILY)
204 #define sndnum_core_version(sndnum)				sndnum_get_info_string(sndnum, SNDINFO_STR_CORE_VERSION)
205 #define sndnum_core_file(sndnum)				sndnum_get_info_string(sndnum, SNDINFO_STR_CORE_FILE)
206 #define sndnum_core_credits(sndnum)				sndnum_get_info_string(sndnum, SNDINFO_STR_CORE_CREDITS)
207 
208 /* misc accessors */
209 void sndnum_reset(int sndnum);
210 int sndnum_clock(int sndnum);
211 void *sndnum_token(int sndnum);
212 
213 
214 
215 /***************************************************************************
216     CHIP INTERFACES BY (TYPE,INDEX) PAIR
217 ***************************************************************************/
218 
219 /* get info accessors */
220 INT64 sndti_get_info_int(int sndtype, int sndindex, UINT32 state);
221 void *sndti_get_info_ptr(int sndtype, int sndindex, UINT32 state);
222 genf *sndti_get_info_fct(int sndtype, int sndindex, UINT32 state);
223 const char *sndti_get_info_string(int sndtype, int sndindex, UINT32 state);
224 
225 /* set info accessors */
226 void sndti_set_info_int(int sndtype, int sndindex, UINT32 state, INT64 data);
227 void sndti_set_info_ptr(int sndtype, int sndindex, UINT32 state, void *data);
228 void sndti_set_info_fct(int sndtype, int sndindex, UINT32 state, genf *data);
229 
230 #define sndti_name(sndtype, sndindex)			sndti_get_info_string(sndtype, sndindex, SNDINFO_STR_NAME)
231 #define sndti_core_family(sndtype, sndindex)	sndti_get_info_string(sndtype, sndindex, SNDINFO_STR_CORE_FAMILY)
232 #define sndti_core_version(sndtype, sndindex)	sndti_get_info_string(sndtype, sndindex, SNDINFO_STR_CORE_VERSION)
233 #define sndti_core_file(sndtype, sndindex)		sndti_get_info_string(sndtype, sndindex, SNDINFO_STR_CORE_FILE)
234 #define sndti_core_credits(sndtype, sndindex)	sndti_get_info_string(sndtype, sndindex, SNDINFO_STR_CORE_CREDITS)
235 
236 /* misc accessors */
237 void sndti_reset(int type, int index);
238 int sndti_clock(int sndtype, int sndindex);
239 void *sndti_token(int sndtype, int sndindex);
240 
241 
242 
243 /***************************************************************************
244     CHIP INTERFACES BY TYPE
245 ***************************************************************************/
246 
247 /* get info accessors */
248 INT64 sndtype_get_info_int(int sndtype, UINT32 state);
249 void *sndtype_get_info_ptr(int sndtype, UINT32 state);
250 genf *sndtype_get_info_fct(int sndtype, UINT32 state);
251 const char *sndtype_get_info_string(int sndtype, UINT32 state);
252 
253 #define sndtype_name(sndtype)					sndtype_get_info_string(sndtype, SNDINFO_STR_NAME)
254 #define sndtype_core_family(sndtype)			sndtype_get_info_string(sndtype, SNDINFO_STR_CORE_FAMILY)
255 #define sndtype_core_version(sndtype)			sndtype_get_info_string(sndtype, SNDINFO_STR_CORE_VERSION)
256 #define sndtype_core_file(sndtype)				sndtype_get_info_string(sndtype, SNDINFO_STR_CORE_FILE)
257 #define sndtype_core_credits(sndtype)			sndtype_get_info_string(sndtype, SNDINFO_STR_CORE_CREDITS)
258 
259 
260 
261 /***************************************************************************
262     FUNCTION PROTOTYPES
263 ***************************************************************************/
264 
265 /* Initialization/Tear down */
266 #if 0		/* QUASI88 */
267 void sndintrf_init(running_machine *machine);
268 #else		/* QUASI88 */
269 void sndintrf_init(void);
270 #endif		/* QUASI88 */
271 int sndintrf_init_sound(int sndnum, int sndtype, int clock, const void *config);
272 void sndintrf_exit_sound(int sndnum);
273 void sndintrf_register_token(void *token);
274 
275 /* Misc helpers */
276 int sndti_exists(int type, int index);
277 int sndti_to_sndnum(int type, int index);
278 int sndnum_to_sndti(int sndnum, int *index);
279 
280 
281 #endif	/* __SNDINTRF_H__ */
282