es5503 used devcb2 instead of custom callbacks (nw)

This commit is contained in:
Miodrag Milanovic 2014-03-23 09:50:45 +00:00
parent c9b2942ca5
commit dc7511306f
8 changed files with 57 additions and 68 deletions

View File

@ -66,8 +66,8 @@ es5503_device::es5503_device(const machine_config &mconfig, const char *tag, dev
device_sound_interface(mconfig, *this),
device_memory_interface(mconfig, *this),
m_space_config("es5503_samples", ENDIANNESS_LITTLE, 8, 17, 0, NULL, *ADDRESS_MAP_NAME(es5503)),
m_irq_func(NULL),
m_adc_func(NULL)
m_irq_func(*this),
m_adc_func(*this)
{
}
@ -92,18 +92,6 @@ void es5503_device::static_set_channels(device_t &device, int channels)
es5503.output_channels = channels;
}
void es5503_device::static_set_irqf(device_t &device, void (*irqf)(device_t *device, int state))
{
es5503_device &es5503 = downcast<es5503_device &>(device);
es5503.m_irq_func = irqf;
}
void es5503_device::static_set_adcf(device_t &device, UINT8 (*adcf)(device_t *device))
{
es5503_device &es5503 = downcast<es5503_device &>(device);
es5503.m_adc_func = adcf;
}
//-------------------------------------------------
// device_timer - called when our device timer expires
//-------------------------------------------------
@ -157,10 +145,7 @@ void es5503_device::halt_osc(int onum, int type, UINT32 *accumulator, int resshi
{
pOsc->irqpend = 1;
if (m_irq_func)
{
m_irq_func(this, 1);
}
m_irq_func(1);
}
}
@ -248,6 +233,9 @@ void es5503_device::device_start()
// find our direct access
m_direct = &space().direct();
m_irq_func.resolve_safe();
m_adc_func.resolve_safe(0);
rege0 = 0xff;
for (osc = 0; osc < 32; osc++)
@ -346,10 +334,7 @@ READ8_MEMBER( es5503_device::read )
case 0xe0: // interrupt status
retval = rege0;
if (m_irq_func)
{
m_irq_func(this, 0);
}
m_irq_func(0);
// scan all oscillators
for (i = 0; i < oscsenabled+1; i++)
@ -372,10 +357,7 @@ READ8_MEMBER( es5503_device::read )
{
if (oscillators[i].irqpend)
{
if (m_irq_func)
{
m_irq_func(this, 1);
}
m_irq_func(1);
break;
}
}
@ -386,11 +368,7 @@ READ8_MEMBER( es5503_device::read )
return oscsenabled<<1;
case 0xe2: // A/D converter
if (m_adc_func)
{
return m_adc_func(this);
}
break;
return m_adc_func();
}
}

View File

@ -5,24 +5,18 @@
// channels must be a power of two
#define MCFG_ES5503_ADD(_tag, _clock, _channels, _irqf, _adcf) \
MCFG_DEVICE_ADD(_tag, ES5503, _clock) \
MCFG_ES5503_OUTPUT_CHANNELS(_channels) \
MCFG_ES5503_IRQ_FUNC(_irqf) \
MCFG_ES5503_ADC_FUNC(_adcf)
#define MCFG_ES5503_REPLACE(_tag, _clock, _channels, _irqf, _adcf) \
MCFG_DEVICE_REPLACE(_tag, ES5503, _clock) \
MCFG_ES5503_OUTPUT_CHANNELS(_channels) \
MCFG_ES5503_IRQ_FUNC(_irqf) \
MCFG_ES5503_ADC_FUNC(_adcf)
#define MCFG_ES5503_ADD(_tag, _clock) \
MCFG_DEVICE_ADD(_tag, ES5503, _clock)
#define MCFG_ES5503_OUTPUT_CHANNELS(_channels) \
es5503_device::static_set_channels(*device, _channels);
#define MCFG_ES5503_IRQ_FUNC(_irqf) \
es5503_device::static_set_irqf(*device, _irqf);
#define MCFG_ES5503_ADC_FUNC(_adcf) \
es5503_device::static_set_adcf(*device, _adcf);
#define MCFG_ES5503_IRQ_FUNC(_write) \
devcb = &es5503_device::static_set_irqf(*device, DEVCB2_##_write);
#define MCFG_ES5503_ADC_FUNC(_read) \
devcb = &es5503_device::static_set_adcf(*device, DEVCB2_##_read);
// ======================> es5503_device
class es5503_device : public device_t,
@ -34,13 +28,14 @@ public:
es5503_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
static void static_set_channels(device_t &device, int channels);
static void static_set_irqf(device_t &device, void (*irqf)(device_t *device, int state));
static void static_set_adcf(device_t &device, UINT8 (*adcf)(device_t *device));
template<class _Object> static devcb2_base &static_set_irqf(device_t &device, _Object object) { return downcast<es5503_device &>(device).m_irq_func.set_callback(object); }
template<class _Object> static devcb2_base &static_set_adcf(device_t &device, _Object object) { return downcast<es5503_device &>(device).m_adc_func.set_callback(object); }
DECLARE_READ8_MEMBER(read);
DECLARE_WRITE8_MEMBER(write);
UINT8 get_channel_strobe() { return m_channel_strobe; }
UINT8 get_channel_strobe() { return m_channel_strobe; }
sound_stream *m_stream;
@ -58,8 +53,8 @@ protected:
const address_space_config m_space_config;
void (*m_irq_func)(device_t *device, int state);
UINT8 (*m_adc_func)(device_t *device);
devcb2_write_line m_irq_func;
devcb2_read8 m_adc_func;
emu_timer *m_sync_timer;

View File

@ -411,7 +411,8 @@ static MACHINE_CONFIG_START( mquake, mquake_state )
MCFG_SOUND_ROUTE(2, "rspeaker", 0.50)
MCFG_SOUND_ROUTE(3, "lspeaker", 0.50)
MCFG_ES5503_ADD("es5503", 7159090, 1, NULL, NULL) /* ES5503 is likely mono due to channel strobe used as bank select */
MCFG_ES5503_ADD("es5503", 7159090) /* ES5503 is likely mono due to channel strobe used as bank select */
MCFG_ES5503_OUTPUT_CHANNELS(1)
MCFG_DEVICE_ADDRESS_MAP(AS_0, mquake_es5503_map)
MCFG_SOUND_ROUTE(0, "lspeaker", 0.50)
MCFG_SOUND_ROUTE(0, "rspeaker", 0.50)

View File

@ -156,7 +156,7 @@ PALETTE_INIT_MEMBER(apple2gs_state,apple2gs)
}
}
UINT8 apple2gs_adc_read(device_t *device)
READ8_MEMBER(apple2gs_state::apple2gs_adc_read)
{
return 0x80;
}
@ -376,7 +376,11 @@ static MACHINE_CONFIG_START( apple2gs, apple2gs_state )
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
MCFG_ES5503_ADD("es5503", APPLE2GS_7M, 2, apple2gs_doc_irq, apple2gs_adc_read)
MCFG_ES5503_ADD("es5503", APPLE2GS_7M)
MCFG_ES5503_OUTPUT_CHANNELS(2)
MCFG_ES5503_IRQ_FUNC(WRITELINE(apple2gs_state, apple2gs_doc_irq))
MCFG_ES5503_ADC_FUNC(READ8(apple2gs_state, apple2gs_adc_read))
MCFG_SOUND_ROUTE(0, "lspeaker", 1.0)
MCFG_SOUND_ROUTE(1, "rspeaker", 1.0)

View File

@ -409,6 +409,9 @@ public:
DECLARE_WRITE_LINE_MEMBER(duart_tx_b);
DECLARE_WRITE8_MEMBER(duart_output);
DECLARE_WRITE_LINE_MEMBER(esq1_doc_irq);
DECLARE_READ8_MEMBER(esq1_adc_read);
int m_mapper_state;
int m_seq_bank;
UINT8 m_seqram[0x10000];
@ -420,11 +423,11 @@ public:
};
static void esq1_doc_irq(device_t *device, int state)
WRITE_LINE_MEMBER(esq1_state::esq1_doc_irq)
{
}
static UINT8 esq1_adc_read(device_t *device)
READ8_MEMBER(esq1_state::esq1_adc_read)
{
return 0x00;
}
@ -601,7 +604,11 @@ static MACHINE_CONFIG_START( esq1, esq1_state )
MCFG_SOUND_ROUTE(0, "lspeaker", 1.0)
MCFG_SOUND_ROUTE(1, "rspeaker", 1.0)
MCFG_ES5503_ADD("es5503", 7000000, 8, esq1_doc_irq, esq1_adc_read)
MCFG_ES5503_ADD("es5503", 7000000)
MCFG_ES5503_OUTPUT_CHANNELS(8)
MCFG_ES5503_IRQ_FUNC(WRITELINE(esq1_state, esq1_doc_irq))
MCFG_ES5503_ADC_FUNC(READ8(esq1_state, esq1_adc_read))
MCFG_SOUND_ROUTE_EX(0, "filters", 1.0, 0)
MCFG_SOUND_ROUTE_EX(1, "filters", 1.0, 1)
MCFG_SOUND_ROUTE_EX(2, "filters", 1.0, 2)

View File

@ -77,6 +77,8 @@ public:
UINT32 screen_update_mirage(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
DECLARE_WRITE8_MEMBER(mirage_via_write_porta);
DECLARE_WRITE8_MEMBER(mirage_via_write_portb);
DECLARE_WRITE_LINE_MEMBER(mirage_doc_irq);
DECLARE_READ8_MEMBER(mirage_adc_read);
UINT8 m_l_segs, m_r_segs;
int m_l_hi, m_r_hi;
@ -90,12 +92,12 @@ static SLOT_INTERFACE_START( ensoniq_floppies )
SLOT_INTERFACE( "35dd", FLOPPY_35_DD )
SLOT_INTERFACE_END
static void mirage_doc_irq(device_t *device, int state)
WRITE_LINE_MEMBER(mirage_state::mirage_doc_irq)
{
// m_maincpu->set_input_line(M6809_IRQ_LINE, state);
}
static UINT8 mirage_adc_read(device_t *device)
READ8_MEMBER(mirage_state::mirage_adc_read)
{
return 0x00;
}
@ -209,7 +211,11 @@ static MACHINE_CONFIG_START( mirage, mirage_state )
MCFG_DEFAULT_LAYOUT( layout_mirage )
MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
MCFG_ES5503_ADD("es5503", 7000000, 2, mirage_doc_irq, mirage_adc_read)
MCFG_ES5503_ADD("es5503", 7000000)
MCFG_ES5503_OUTPUT_CHANNELS(2)
MCFG_ES5503_IRQ_FUNC(WRITELINE(mirage_state, mirage_doc_irq))
MCFG_ES5503_ADC_FUNC(READ8(mirage_state, mirage_adc_read))
MCFG_SOUND_ROUTE(0, "lspeaker", 1.0)
MCFG_SOUND_ROUTE(1, "rspeaker", 1.0)

View File

@ -260,10 +260,9 @@ public:
DECLARE_WRITE8_MEMBER( apple2gs_E12xxx_w );
DECLARE_WRITE8_MEMBER( apple2gs_slowmem_w );
DECLARE_READ8_MEMBER(apple2gs_bank_echo_r);
DECLARE_WRITE_LINE_MEMBER( apple2gs_doc_irq);
DECLARE_READ8_MEMBER(apple2gs_adc_read);
};
/*----------- defined in machine/apple2gs.c -----------*/
void apple2gs_doc_irq(device_t *device, int state);
#endif /* APPLE2GS_H_ */

View File

@ -275,16 +275,15 @@ void apple2gs_state::apple2gs_remove_irq(UINT16 irq_mask)
}
}
void apple2gs_doc_irq(device_t *device, int state)
WRITE_LINE_MEMBER(apple2gs_state::apple2gs_doc_irq)
{
apple2gs_state *drvstate = device->machine().driver_data<apple2gs_state>();
if (state)
{
drvstate->apple2gs_add_irq(IRQ_DOC);
apple2gs_add_irq(IRQ_DOC);
}
else
{
drvstate->apple2gs_remove_irq(IRQ_DOC);
apple2gs_remove_irq(IRQ_DOC);
}
}