summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/sound/ymopl.cpp
blob: e647e6fd4bfbd61ffacd37f7567f666f3f4c3ae2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
// license:BSD-3-Clause
// copyright-holders:Aaron Giles

#include "emu.h"
#include "ymopl.h"


//*********************************************************
//  YM3526 DEVICE
//*********************************************************

DEFINE_DEVICE_TYPE(YM3526, ym3526_device, "ym3526", "YM3526 OPL")

//-------------------------------------------------
//  ym3526_device - constructor
//-------------------------------------------------

ym3526_device::ym3526_device(const machine_config &mconfig, const char *tag, device_t *owner, const XTAL &clock) :
	ymfm_device_base<ymfm::ym3526>(mconfig, tag, owner, clock, YM3526)
{
}



//*********************************************************
//  Y8950 DEVICE
//*********************************************************

DEFINE_DEVICE_TYPE(Y8950, y8950_device, "y8950", "Y8950 OPL MSX-Audio")

//-------------------------------------------------
//  y8950_device - constructor
//-------------------------------------------------

y8950_device::y8950_device(const machine_config &mconfig, const char *tag, device_t *owner, const XTAL &clock) :
	ymfm_device_base<ymfm::y8950>(mconfig, tag, owner, clock, Y8950),
	device_rom_interface(mconfig, *this)
{
}


//-------------------------------------------------
//  rom_bank_pre_change - refresh the stream if the
//  ROM banking changes
//-------------------------------------------------

void y8950_device::rom_bank_pre_change()
{
	m_stream->update();
}


//-------------------------------------------------
//  ymfm_external_read - callback to read data for
//  the ADPCM-B engine; in this case, from our
//  default address space
//-------------------------------------------------

uint8_t y8950_device::ymfm_external_read(ymfm::access_class type, uint32_t offset)
{
	if (type == ymfm::ACCESS_ADPCM_B)
		return read_byte(offset);
	return parent::ymfm_external_read(type, offset);
}


//-------------------------------------------------
//  ymfm_external_write - callback to write data to
//  the ADPCM-B engine; in this case, to our
//  default address space
//-------------------------------------------------

void y8950_device::ymfm_external_write(ymfm::access_class type, uint32_t offset, uint8_t data)
{
	if (type == ymfm::ACCESS_ADPCM_B)
		return space().write_byte(offset, data);
	parent::ymfm_external_write(type, offset, data);
}



//*********************************************************
//  YM3812 DEVICE
//*********************************************************

DEFINE_DEVICE_TYPE(YM3812, ym3812_device, "ym3812", "YM3812 OPL2")

//-------------------------------------------------
//  ym3812_device - constructor
//-------------------------------------------------

ym3812_device::ym3812_device(const machine_config &mconfig, const char *tag, device_t *owner, const XTAL &clock) :
	ymfm_device_base<ymfm::ym3812>(mconfig, tag, owner, clock, YM3812)
{
}



//*********************************************************
//  YMF262 DEVICE
//*********************************************************

DEFINE_DEVICE_TYPE(YMF262, ymf262_device, "ymf262", "YMF262 OPL3")

//-------------------------------------------------
//  ymf262_device - constructor
//-------------------------------------------------

ymf262_device::ymf262_device(const machine_config &mconfig, const char *tag, device_t *owner, const XTAL &clock) :
	ymfm_device_base<ymfm::ymf262>(mconfig, tag, owner, clock, YMF262)
{
}



//*********************************************************
//  YMF278B DEVICE
//*********************************************************

DEFINE_DEVICE_TYPE(YMF278B, ymf278b_device, "ymf278b", "YMF278B OPL4")

//-------------------------------------------------
//  ymf278b_device - constructor
//-------------------------------------------------

ymf278b_device::ymf278b_device(const machine_config &mconfig, const char *tag, device_t *owner, const XTAL &clock) :
	ymfm_device_base<ymfm::ymf278b>(mconfig, tag, owner, clock, YMF278B),
	device_rom_interface(mconfig, *this)
{
}


//-------------------------------------------------
//  rom_bank_pre_change - refresh the stream if the
//  ROM banking changes
//-------------------------------------------------

void ymf278b_device::rom_bank_pre_change()
{
	m_stream->update();
}


//-------------------------------------------------
//  ymfm_external_read - callback to read data for
//  the ADPCM-B engine; in this case, from our
//  default address space
//-------------------------------------------------

uint8_t ymf278b_device::ymfm_external_read(ymfm::access_class type, uint32_t offset)
{
	if (type == ymfm::ACCESS_PCM)
		return read_byte(offset);
	return 0;
}


//-------------------------------------------------
//  ymfm_external_write - callback to write data to
//  the ADPCM-B engine; in this case, to our
//  default address space
//-------------------------------------------------

void ymf278b_device::ymfm_external_write(ymfm::access_class type, uint32_t offset, uint8_t data)
{
	if (type == ymfm::ACCESS_PCM)
		return space().write_byte(offset, data);
}


//-------------------------------------------------
//  ymfm_external_write - callback to write data to
//  the ADPCM-B engine; in this case, to our
//  default address space
//-------------------------------------------------

void ymf278b_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
	// rotate the outputs so that the DO2 outputs are first
	parent::update_internal(outputs, 2);
}



//*********************************************************
//  YM2413 DEVICE
//*********************************************************

DEFINE_DEVICE_TYPE(YM2413, ym2413_device, "ym2413", "YM2413 OPLL")

//-------------------------------------------------
//  ym2413_device - constructor
//-------------------------------------------------

ym2413_device::ym2413_device(const machine_config &mconfig, const char *tag, device_t *owner, const XTAL &clock) :
	ymfm_device_base<ymfm::ym2413>(mconfig, tag, owner, clock, YM2413),
	m_internal(*this, "internal")
{
}


//-------------------------------------------------
//  device_start - device startup
//-------------------------------------------------

void ym2413_device::device_start()
{
	parent::device_start();
	m_chip.set_instrument_data(m_internal);
}


//-------------------------------------------------
//  device_rom_region - return a pointer to our
//  ROM region
//-------------------------------------------------

ROM_START( ym2413 )
	ROM_REGION( 0x90, "internal", 0 )
	//
	// This is not the exact format
	//
	ROM_LOAD16_WORD( "ym2413_instruments.bin", 0x0000, 0x0090, CRC(6f582d01) SHA1(bb5537717e0b34849456b5ca7d405403dc3f8fda) )
ROM_END

const tiny_rom_entry *ym2413_device::device_rom_region() const
{
	return ROM_NAME( ym2413 );
}



//*********************************************************
//  YM2423 DEVICE (OPLL-X)
//*********************************************************

DEFINE_DEVICE_TYPE(YM2423, ym2423_device, "ym2423", "YM2423 OPLL-X")

//-------------------------------------------------
//  ym2423_device - constructor
//-------------------------------------------------

ym2423_device::ym2423_device(const machine_config &mconfig, const char *tag, device_t *owner, const XTAL &clock) :
	ymfm_device_base<ymfm::ym2423>(mconfig, tag, owner, clock, YM2423),
	m_internal(*this, "internal")
{
}


//-------------------------------------------------
//  device_start - device startup
//-------------------------------------------------

void ym2423_device::device_start()
{
	parent::device_start();
	m_chip.set_instrument_data(m_internal);
}


//-------------------------------------------------
//  device_rom_region - return a pointer to our
//  ROM region
//-------------------------------------------------

ROM_START( ym2423 )
	ROM_REGION( 0x90, "internal", 0 )
	//
	// This is not the exact format
	//
	ROM_LOAD16_WORD( "ym2423_instruments.bin", 0x0000, 0x0090, CRC(cc51dd1b) SHA1(59c51918f02891d6a0e917f7ebc27e42f7eadd15) )
ROM_END

const tiny_rom_entry *ym2423_device::device_rom_region() const
{
	return ROM_NAME( ym2423 );
}



//*********************************************************
//  YMF281 DEVICE (OPLLP)
//*********************************************************

DEFINE_DEVICE_TYPE(YMF281, ymf281_device, "ymf281", "YMF281 OPLLP")

//-------------------------------------------------
//  ymf281_device - constructor
//-------------------------------------------------

ymf281_device::ymf281_device(const machine_config &mconfig, const char *tag, device_t *owner, const XTAL &clock) :
	ymfm_device_base<ymfm::ymf281>(mconfig, tag, owner, clock, YMF281),
	m_internal(*this, "internal")
{
}


//-------------------------------------------------
//  device_start - device startup
//-------------------------------------------------

void ymf281_device::device_start()
{
	parent::device_start();
	m_chip.set_instrument_data(m_internal);
}


//-------------------------------------------------
//  device_rom_region - return a pointer to our
//  ROM region
//-------------------------------------------------

ROM_START( ymf281 )
	ROM_REGION( 0x90, "internal", 0 )
	//
	// This is not the exact format
	//
	ROM_LOAD16_WORD( "ymf281_instruments.bin", 0x0000, 0x0090, CRC(1c68abba) SHA1(5242d7b9c677c48e156ba5753db1a73db627a1a9) )
ROM_END

const tiny_rom_entry *ymf281_device::device_rom_region() const
{
	return ROM_NAME( ymf281 );
}



//*********************************************************
//  DS1001 DEVICE (Konami VRC7)
//*********************************************************

DEFINE_DEVICE_TYPE(DS1001, ds1001_device, "ds1001", "Yamaha DS1001 / Konami 053982")

//-------------------------------------------------
//  ds1001_device - constructor
//-------------------------------------------------

ds1001_device::ds1001_device(const machine_config &mconfig, const char *tag, device_t *owner, const XTAL &clock) :
	ymfm_device_base<ymfm::ds1001>(mconfig, tag, owner, clock, DS1001),
	m_internal(*this, "internal")
{
}


//-------------------------------------------------
//  device_start - device startup
//-------------------------------------------------

void ds1001_device::device_start()
{
	parent::device_start();
	m_chip.set_instrument_data(m_internal);
}


//-------------------------------------------------
//  device_rom_region - return a pointer to our
//  ROM region
//-------------------------------------------------

ROM_START( ds1001 )
	ROM_REGION( 0x90, "internal", 0 )
	//
	// This is not the exact format
	//
	ROM_LOAD16_WORD( "ds1001_instruments.bin", 0x0000, 0x0090, CRC(9d699efc) SHA1(7adf1d77bab12c50ebfa9921774f9aea1e74dd7b) )
ROM_END

const tiny_rom_entry *ds1001_device::device_rom_region() const
{
	return ROM_NAME( ds1001 );
}