From b57f1952ff06f77f1da8ae6af8e1f324286e6e7a Mon Sep 17 00:00:00 2001 From: smf- Date: Fri, 10 May 2013 21:38:13 +0000 Subject: [PATCH] modernized the YM2608 [smf] --- src/emu/sound/2608intf.c | 235 ++++++++++++++-------------------- src/emu/sound/2608intf.h | 49 +++---- src/mame/drivers/bbusters.c | 16 +-- src/mame/drivers/itech8.c | 22 ++-- src/mame/drivers/pipedrm.c | 16 +-- src/mame/drivers/tail2nos.c | 24 ++-- src/mame/drivers/wc90.c | 16 +-- src/mess/drivers/pc8801.c | 32 ++--- src/mess/machine/pc9801_118.c | 24 ++-- src/mess/machine/pc9801_86.c | 24 ++-- 10 files changed, 203 insertions(+), 255 deletions(-) diff --git a/src/emu/sound/2608intf.c b/src/emu/sound/2608intf.c index bdf9d1842f4..32f36444acd 100644 --- a/src/emu/sound/2608intf.c +++ b/src/emu/sound/2608intf.c @@ -16,49 +16,28 @@ #include "2608intf.h" #include "fm.h" -struct ym2608_state -{ - sound_stream * stream; - emu_timer * timer[2]; - void * chip; - void * psg; - const ym2608_interface *intf; - device_t *device; - devcb_resolved_write_line irqhandler; -}; - - -INLINE ym2608_state *get_safe_token(device_t *device) -{ - assert(device != NULL); - assert(device->type() == YM2608); - return (ym2608_state *)downcast(device)->token(); -} - - - static void psg_set_clock(void *param, int clock) { - ym2608_state *info = (ym2608_state *)param; - ay8910_set_clock_ym(info->psg, clock); + ym2608_device *ym2608 = (ym2608_device *) param; + ay8910_set_clock_ym(ym2608->_psg(), clock); } static void psg_write(void *param, int address, int data) { - ym2608_state *info = (ym2608_state *)param; - ay8910_write_ym(info->psg, address, data); + ym2608_device *ym2608 = (ym2608_device *) param; + ay8910_write_ym(ym2608->_psg(), address, data); } static int psg_read(void *param) { - ym2608_state *info = (ym2608_state *)param; - return ay8910_read_ym(info->psg); + ym2608_device *ym2608 = (ym2608_device *) param; + return ay8910_read_ym(ym2608->_psg()); } static void psg_reset(void *param) { - ym2608_state *info = (ym2608_state *)param; - ay8910_reset_ym(info->psg); + ym2608_device *ym2608 = (ym2608_device *) param; + ay8910_reset_ym(ym2608->_psg()); } static const ssg_callbacks psgintf = @@ -69,151 +48,166 @@ static const ssg_callbacks psgintf = psg_reset }; +void *ym2608_device::_psg() +{ + return m_psg; +} /* IRQ Handler */ static void IRQHandler(void *param,int irq) { - ym2608_state *info = (ym2608_state *)param; - if (!info->irqhandler.isnull()) - info->irqhandler(irq); + ym2608_device *ym2608 = (ym2608_device *) param; + ym2608->_IRQHandler(irq); +} + +void ym2608_device::_IRQHandler(int irq) +{ + if (!m_irq_handler.isnull()) + m_irq_handler(irq); } /* Timer overflow callback from timer.c */ -static TIMER_CALLBACK( timer_callback_2608_0 ) +void ym2608_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) { - ym2608_state *info = (ym2608_state *)ptr; - ym2608_timer_over(info->chip,0); -} + switch(id) + { + case 0: + ym2608_timer_over(m_chip,0); + break; -static TIMER_CALLBACK( timer_callback_2608_1 ) -{ - ym2608_state *info = (ym2608_state *)ptr; - ym2608_timer_over(info->chip,1); + case 1: + ym2608_timer_over(m_chip,1); + break; + } } static void timer_handler(void *param,int c,int count,int clock) { - ym2608_state *info = (ym2608_state *)param; + ym2608_device *ym2608 = (ym2608_device *) param; + ym2608->_timer_handler(c, count, clock); +} + +void ym2608_device::_timer_handler(int c,int count,int clock) +{ if( count == 0 ) { /* Reset FM Timer */ - info->timer[c]->enable(false); + m_timer[c]->enable(false); } else { /* Start FM Timer */ attotime period = attotime::from_hz(clock) * count; - if (!info->timer[c]->enable(true)) - info->timer[c]->adjust(period); + + if (!m_timer[c]->enable(true)) + m_timer[c]->adjust(period); } } /* update request from fm.c */ void ym2608_update_request(void *param) { - ym2608_state *info = (ym2608_state *)param; - info->stream->update(); + ym2608_device *ym2608 = (ym2608_device *) param; + ym2608->_ym2608_update_request(); } -static STREAM_UPDATE( ym2608_stream_update ) +void ym2608_device::_ym2608_update_request() { - ym2608_state *info = (ym2608_state *)param; - ym2608_update_one(info->chip, outputs, samples); + m_stream->update(); +} + +//------------------------------------------------- +// sound_stream_update - handle a stream update +//------------------------------------------------- + +void ym2608_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) +{ + ym2608_update_one(m_chip, outputs, samples); } -static void ym2608_intf_postload(ym2608_state *info) +void ym2608_device::device_post_load() { - ym2608_postload(info->chip); + ym2608_postload(m_chip); } -static DEVICE_START( ym2608 ) +//------------------------------------------------- +// device_start - device-specific startup +//------------------------------------------------- + +void ym2608_device::device_start() { - static const ym2608_interface generic_2608 = + static const ay8910_interface generic_ay8910 = { - { - AY8910_LEGACY_OUTPUT | AY8910_SINGLE_OUTPUT, - AY8910_DEFAULT_LOADS, - DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL - }, - DEVCB_NULL + AY8910_LEGACY_OUTPUT | AY8910_SINGLE_OUTPUT, + AY8910_DEFAULT_LOADS, + DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL }; - const ym2608_interface *intf = device->static_config() ? (const ym2608_interface *)device->static_config() : &generic_2608; - int rate = device->clock()/72; + + int rate = clock()/72; void *pcmbufa; int pcmsizea; - ym2608_state *info = get_safe_token(device); - - info->intf = intf; - info->device = device; - - info->irqhandler.resolve(intf->irqhandler, *device); + const ay8910_interface *ay8910_intf = m_ay8910_intf != NULL ? m_ay8910_intf : &generic_ay8910; + m_irq_handler.resolve(); /* FIXME: Force to use simgle output */ - info->psg = ay8910_start_ym(NULL, YM2608, device, device->clock(), &intf->ay8910_intf); - assert_always(info->psg != NULL, "Error creating YM2608/AY8910 chip"); + m_psg = ay8910_start_ym(NULL, type(), this, clock(), ay8910_intf); + assert_always(m_psg != NULL, "Error creating YM2608/AY8910 chip"); /* Timer Handler set */ - info->timer[0] = device->machine().scheduler().timer_alloc(FUNC(timer_callback_2608_0), info); - info->timer[1] = device->machine().scheduler().timer_alloc(FUNC(timer_callback_2608_1), info); + m_timer[0] = timer_alloc(0); + m_timer[1] = timer_alloc(1); /* stream system initialize */ - info->stream = device->machine().sound().stream_alloc(*device,0,2,rate,info,ym2608_stream_update); + m_stream = machine().sound().stream_alloc(*this,0,2,rate); /* setup adpcm buffers */ - pcmbufa = *device->region(); - pcmsizea = device->region()->bytes(); + pcmbufa = *region(); + pcmsizea = region()->bytes(); /* initialize YM2608 */ - info->chip = ym2608_init(info,device,device->clock(),rate, + m_chip = ym2608_init(this,this,clock(),rate, pcmbufa,pcmsizea, timer_handler,IRQHandler,&psgintf); - assert_always(info->chip != NULL, "Error creating YM2608 chip"); - - device->machine().save().register_postload(save_prepost_delegate(FUNC(ym2608_intf_postload), info)); + assert_always(m_chip != NULL, "Error creating YM2608 chip"); } -static DEVICE_STOP( ym2608 ) +//------------------------------------------------- +// device_stop - device-specific stop +//------------------------------------------------- + +void ym2608_device::device_stop() { - ym2608_state *info = get_safe_token(device); - ym2608_shutdown(info->chip); - ay8910_stop_ym(info->psg); + ym2608_shutdown(m_chip); + ay8910_stop_ym(m_psg); } -static DEVICE_RESET( ym2608 ) +//------------------------------------------------- +// device_reset - device-specific reset +//------------------------------------------------- + +void ym2608_device::device_reset() { - ym2608_state *info = get_safe_token(device); - ym2608_reset_chip(info->chip); + ym2608_reset_chip(m_chip); } -READ8_DEVICE_HANDLER( ym2608_r ) +READ8_MEMBER( ym2608_device::read ) { - ym2608_state *info = get_safe_token(device); - return ym2608_read(info->chip, offset & 3); + return ym2608_read(m_chip, offset & 3); } -WRITE8_DEVICE_HANDLER( ym2608_w ) +WRITE8_MEMBER( ym2608_device::write ) { - ym2608_state *info = get_safe_token(device); - ym2608_write(info->chip, offset & 3, data); + ym2608_write(m_chip, offset & 3, data); } -READ8_DEVICE_HANDLER( ym2608_read_port_r ) { return ym2608_r(device, space, 1); } -READ8_DEVICE_HANDLER( ym2608_status_port_a_r ) { return ym2608_r(device, space, 0); } -READ8_DEVICE_HANDLER( ym2608_status_port_b_r ) { return ym2608_r(device, space, 2); } - -WRITE8_DEVICE_HANDLER( ym2608_control_port_a_w ) { ym2608_w(device, space, 0, data); } -WRITE8_DEVICE_HANDLER( ym2608_control_port_b_w ) { ym2608_w(device, space, 2, data); } -WRITE8_DEVICE_HANDLER( ym2608_data_port_a_w ) { ym2608_w(device, space, 1, data); } -WRITE8_DEVICE_HANDLER( ym2608_data_port_b_w ) { ym2608_w(device, space, 3, data); } - const device_type YM2608 = &device_creator; ym2608_device::ym2608_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : device_t(mconfig, YM2608, "YM2608", tag, owner, clock), - device_sound_interface(mconfig, *this) + device_sound_interface(mconfig, *this), + m_irq_handler(*this) { - m_token = global_alloc_clear(ym2608_state); } //------------------------------------------------- @@ -225,40 +219,3 @@ ym2608_device::ym2608_device(const machine_config &mconfig, const char *tag, dev void ym2608_device::device_config_complete() { } - -//------------------------------------------------- -// device_start - device-specific startup -//------------------------------------------------- - -void ym2608_device::device_start() -{ - DEVICE_START_NAME( ym2608 )(this); -} - -//------------------------------------------------- -// device_reset - device-specific reset -//------------------------------------------------- - -void ym2608_device::device_reset() -{ - DEVICE_RESET_NAME( ym2608 )(this); -} - -//------------------------------------------------- -// device_stop - device-specific stop -//------------------------------------------------- - -void ym2608_device::device_stop() -{ - DEVICE_STOP_NAME( ym2608 )(this); -} - -//------------------------------------------------- -// sound_stream_update - handle a stream update -//------------------------------------------------- - -void ym2608_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) -{ - // should never get here - fatalerror("sound_stream_update called; not applicable to legacy sound devices\n"); -} diff --git a/src/emu/sound/2608intf.h b/src/emu/sound/2608intf.h index ad1583096cc..d4bdec6c039 100644 --- a/src/emu/sound/2608intf.h +++ b/src/emu/sound/2608intf.h @@ -3,52 +3,57 @@ #ifndef __2608INTF_H__ #define __2608INTF_H__ -#include "devlegcy.h" - +#include "emu.h" #include "fm.h" #include "ay8910.h" void ym2608_update_request(void *param); -struct ym2608_interface -{ - const ay8910_interface ay8910_intf; - devcb_write_line irqhandler; /* IRQ handler for the YM2608 */ -}; +#define MCFG_YM2608_IRQ_HANDLER(_devcb) \ + devcb = &ym2608_device::set_irq_handler(*device, DEVCB2_##_devcb); -DECLARE_READ8_DEVICE_HANDLER( ym2608_r ); -DECLARE_WRITE8_DEVICE_HANDLER( ym2608_w ); - -DECLARE_READ8_DEVICE_HANDLER( ym2608_read_port_r ); -DECLARE_READ8_DEVICE_HANDLER( ym2608_status_port_a_r ); -DECLARE_READ8_DEVICE_HANDLER( ym2608_status_port_b_r ); - -DECLARE_WRITE8_DEVICE_HANDLER( ym2608_control_port_a_w ); -DECLARE_WRITE8_DEVICE_HANDLER( ym2608_control_port_b_w ); -DECLARE_WRITE8_DEVICE_HANDLER( ym2608_data_port_a_w ); -DECLARE_WRITE8_DEVICE_HANDLER( ym2608_data_port_b_w ); +#define MCFG_YM2608_AY8910_INTF(_ay8910_intf) \ + ym2608_device::set_ay8910_intf(*device, _ay8910_intf); class ym2608_device : public device_t, public device_sound_interface { public: ym2608_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - ~ym2608_device() { global_free(m_token); } - // access to legacy token - void *token() const { assert(m_token != NULL); return m_token; } + // static configuration helpers + template static devcb2_base &set_irq_handler(device_t &device, _Object object) { return downcast(device).m_irq_handler.set_callback(object); } + static void set_ay8910_intf(device_t &device, const ay8910_interface *ay8910_intf) { downcast(device).m_ay8910_intf = ay8910_intf; } + + DECLARE_READ8_MEMBER( read ); + DECLARE_WRITE8_MEMBER( write ); + + void *_psg(); + void _IRQHandler(int irq); + void _timer_handler(int c,int count,int clock); + void _ym2608_update_request(); + protected: // device-level overrides virtual void device_config_complete(); virtual void device_start(); + virtual void device_post_load(); virtual void device_stop(); virtual void device_reset(); + virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); + // sound stream update overrides virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples); + private: // internal state - void *m_token; + sound_stream * m_stream; + emu_timer * m_timer[2]; + void * m_chip; + void * m_psg; + devcb2_write_line m_irq_handler; + const ay8910_interface *m_ay8910_intf; }; extern const device_type YM2608; diff --git a/src/mame/drivers/bbusters.c b/src/mame/drivers/bbusters.c index d417aa143af..7bb8d2d88e2 100644 --- a/src/mame/drivers/bbusters.c +++ b/src/mame/drivers/bbusters.c @@ -383,7 +383,7 @@ ADDRESS_MAP_END static ADDRESS_MAP_START( sounda_portmap, AS_IO, 8, bbusters_state ) ADDRESS_MAP_GLOBAL_MASK(0xff) - AM_RANGE(0x00, 0x03) AM_DEVREADWRITE_LEGACY("ymsnd", ym2608_r, ym2608_w) + AM_RANGE(0x00, 0x03) AM_DEVREADWRITE("ymsnd", ym2608_device, read, write) AM_RANGE(0xc0, 0xc1) AM_WRITENOP /* -> Main CPU */ ADDRESS_MAP_END @@ -638,14 +638,11 @@ WRITE_LINE_MEMBER(bbusters_state::sound_irq) m_audiocpu->set_input_line(0, state ? ASSERT_LINE : CLEAR_LINE); } -static const ym2608_interface ym2608_config = +static const ay8910_interface ay8910_config = { - { - AY8910_LEGACY_OUTPUT | AY8910_SINGLE_OUTPUT, - AY8910_DEFAULT_LOADS, - DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL - }, - DEVCB_DRIVER_LINE_MEMBER(bbusters_state,sound_irq) + AY8910_LEGACY_OUTPUT | AY8910_SINGLE_OUTPUT, + AY8910_DEFAULT_LOADS, + DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL }; /******************************************************************************/ @@ -726,7 +723,8 @@ static MACHINE_CONFIG_START( mechatt, bbusters_state ) MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") MCFG_SOUND_ADD("ymsnd", YM2608, 8000000) - MCFG_SOUND_CONFIG(ym2608_config) + MCFG_YM2608_IRQ_HANDLER(WRITELINE(bbusters_state, sound_irq)) + MCFG_YM2608_AY8910_INTF(&ay8910_config) MCFG_SOUND_ROUTE(0, "lspeaker", 0.50) MCFG_SOUND_ROUTE(0, "rspeaker", 0.50) MCFG_SOUND_ROUTE(1, "lspeaker", 1.0) diff --git a/src/mame/drivers/itech8.c b/src/mame/drivers/itech8.c index 639192b4d8d..d00e097d389 100644 --- a/src/mame/drivers/itech8.c +++ b/src/mame/drivers/itech8.c @@ -936,7 +936,7 @@ ADDRESS_MAP_END static ADDRESS_MAP_START( sound2608b_map, AS_PROGRAM, 8, itech8_state ) AM_RANGE(0x1000, 0x1000) AM_WRITENOP AM_RANGE(0x2000, 0x2000) AM_READ(sound_data_r) - AM_RANGE(0x4000, 0x4003) AM_DEVREADWRITE_LEGACY("ymsnd", ym2608_r, ym2608_w) + AM_RANGE(0x4000, 0x4003) AM_DEVREADWRITE("ymsnd", ym2608_device, read, write) AM_RANGE(0x6000, 0x67ff) AM_RAM AM_RANGE(0x8000, 0xffff) AM_ROM ADDRESS_MAP_END @@ -1649,17 +1649,14 @@ static const ym2203_interface ym2203_config = }; -static const ym2608_interface ym2608b_config = +static const ay8910_interface ay8910_config = { - { - AY8910_LEGACY_OUTPUT, - AY8910_DEFAULT_LOADS, - DEVCB_NULL, - DEVCB_NULL, - DEVCB_NULL, - DEVCB_DRIVER_MEMBER(itech8_state,ym2203_portb_out), - }, - DEVCB_DRIVER_LINE_MEMBER(itech8_state,generate_sound_irq) + AY8910_LEGACY_OUTPUT, + AY8910_DEFAULT_LOADS, + DEVCB_NULL, + DEVCB_NULL, + DEVCB_NULL, + DEVCB_DRIVER_MEMBER(itech8_state,ym2203_portb_out), }; @@ -1741,7 +1738,8 @@ static MACHINE_CONFIG_FRAGMENT( itech8_sound_ym2608b ) /* sound hardware */ MCFG_SOUND_ADD("ymsnd", YM2608, CLOCK_8MHz) - MCFG_SOUND_CONFIG(ym2608b_config) + MCFG_YM2608_IRQ_HANDLER(WRITELINE(itech8_state, generate_sound_irq)) + MCFG_YM2608_AY8910_INTF(&ay8910_config) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.75) MACHINE_CONFIG_END diff --git a/src/mame/drivers/pipedrm.c b/src/mame/drivers/pipedrm.c index 3039d4b9631..23b4aa8efdb 100644 --- a/src/mame/drivers/pipedrm.c +++ b/src/mame/drivers/pipedrm.c @@ -330,7 +330,7 @@ ADDRESS_MAP_END static ADDRESS_MAP_START( hatris_sound_portmap, AS_IO, 8, pipedrm_state ) ADDRESS_MAP_GLOBAL_MASK(0xff) - AM_RANGE(0x00, 0x03) AM_MIRROR(0x08) AM_DEVREADWRITE_LEGACY("ymsnd", ym2608_r, ym2608_w) + AM_RANGE(0x00, 0x03) AM_MIRROR(0x08) AM_DEVREADWRITE("ymsnd", ym2608_device, read, write) AM_RANGE(0x04, 0x04) AM_READ(sound_command_r) AM_RANGE(0x05, 0x05) AM_READWRITE(pending_command_r, pending_command_clear_w) ADDRESS_MAP_END @@ -581,14 +581,11 @@ WRITE_LINE_MEMBER(pipedrm_state::irqhandler) } -static const ym2608_interface ym2608_config = +static const ay8910_interface ay8910_config = { - { - AY8910_LEGACY_OUTPUT | AY8910_SINGLE_OUTPUT, - AY8910_DEFAULT_LOADS, - DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL - }, - DEVCB_DRIVER_LINE_MEMBER(pipedrm_state,irqhandler) + AY8910_LEGACY_OUTPUT | AY8910_SINGLE_OUTPUT, + AY8910_DEFAULT_LOADS, + DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL }; @@ -716,7 +713,8 @@ static MACHINE_CONFIG_START( hatris, pipedrm_state ) MCFG_SPEAKER_STANDARD_MONO("mono") MCFG_SOUND_ADD("ymsnd", YM2608, 8000000) - MCFG_SOUND_CONFIG(ym2608_config) + MCFG_YM2608_IRQ_HANDLER(WRITELINE(pipedrm_state, irqhandler)) + MCFG_YM2608_AY8910_INTF(&ay8910_config) MCFG_SOUND_ROUTE(0, "mono", 0.50) MCFG_SOUND_ROUTE(1, "mono", 1.0) MCFG_SOUND_ROUTE(2, "mono", 1.0) diff --git a/src/mame/drivers/tail2nos.c b/src/mame/drivers/tail2nos.c index d6871932434..b17b97025d2 100644 --- a/src/mame/drivers/tail2nos.c +++ b/src/mame/drivers/tail2nos.c @@ -57,9 +57,9 @@ ADDRESS_MAP_END static ADDRESS_MAP_START( sound_port_map, AS_IO, 8, tail2nos_state ) ADDRESS_MAP_GLOBAL_MASK(0xff) AM_RANGE(0x07, 0x07) AM_READ(soundlatch_byte_r) AM_WRITENOP /* the write is a clear pending command */ - AM_RANGE(0x08, 0x0b) AM_DEVWRITE_LEGACY("ymsnd", ym2608_w) + AM_RANGE(0x08, 0x0b) AM_DEVWRITE("ymsnd", ym2608_device, write) #if 0 - AM_RANGE(0x18, 0x1b) AM_DEVREAD_LEGACY("ymsnd", ym2608_r) + AM_RANGE(0x18, 0x1b) AM_DEVREAD("ymsnd", ym2608_device, read) #endif ADDRESS_MAP_END @@ -181,17 +181,14 @@ WRITE_LINE_MEMBER(tail2nos_state::irqhandler) m_audiocpu->set_input_line(0, state ? ASSERT_LINE : CLEAR_LINE); } -static const ym2608_interface ym2608_config = +static const ay8910_interface ay8910_config = { - { - AY8910_LEGACY_OUTPUT | AY8910_SINGLE_OUTPUT, - AY8910_DEFAULT_LOADS, - DEVCB_NULL, - DEVCB_NULL, - DEVCB_NULL, - DEVCB_DRIVER_MEMBER(tail2nos_state,sound_bankswitch_w) - }, - DEVCB_DRIVER_LINE_MEMBER(tail2nos_state,irqhandler) + AY8910_LEGACY_OUTPUT | AY8910_SINGLE_OUTPUT, + AY8910_DEFAULT_LOADS, + DEVCB_NULL, + DEVCB_NULL, + DEVCB_NULL, + DEVCB_DRIVER_MEMBER(tail2nos_state,sound_bankswitch_w) }; @@ -256,7 +253,8 @@ static MACHINE_CONFIG_START( tail2nos, tail2nos_state ) MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") MCFG_SOUND_ADD("ymsnd", YM2608, XTAL_8MHz) /* verified on pcb */ - MCFG_SOUND_CONFIG(ym2608_config) + MCFG_YM2608_IRQ_HANDLER(WRITELINE(tail2nos_state, irqhandler)) + MCFG_YM2608_AY8910_INTF(&ay8910_config) MCFG_SOUND_ROUTE(0, "lspeaker", 0.25) MCFG_SOUND_ROUTE(0, "rspeaker", 0.25) MCFG_SOUND_ROUTE(1, "lspeaker", 1.0) diff --git a/src/mame/drivers/wc90.c b/src/mame/drivers/wc90.c index 5a1d92d9c95..4c2f81992f0 100644 --- a/src/mame/drivers/wc90.c +++ b/src/mame/drivers/wc90.c @@ -154,7 +154,7 @@ ADDRESS_MAP_END static ADDRESS_MAP_START( sound_map, AS_PROGRAM, 8, wc90_state ) AM_RANGE(0x0000, 0xbfff) AM_ROM AM_RANGE(0xf000, 0xf7ff) AM_RAM - AM_RANGE(0xf800, 0xf803) AM_DEVREADWRITE_LEGACY("ymsnd", ym2608_r, ym2608_w) + AM_RANGE(0xf800, 0xf803) AM_DEVREADWRITE("ymsnd", ym2608_device, read, write) AM_RANGE(0xfc00, 0xfc00) AM_READNOP /* ??? adpcm ??? */ AM_RANGE(0xfc10, 0xfc10) AM_READ(soundlatch_byte_r) ADDRESS_MAP_END @@ -295,14 +295,11 @@ WRITE_LINE_MEMBER(wc90_state::irqhandler) m_audiocpu->set_input_line(0, state ? ASSERT_LINE : CLEAR_LINE); } -static const ym2608_interface ym2608_config = +static const ay8910_interface ay8910_config = { - { - AY8910_LEGACY_OUTPUT | AY8910_SINGLE_OUTPUT, - AY8910_DEFAULT_LOADS, - DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL - }, - DEVCB_DRIVER_LINE_MEMBER(wc90_state,irqhandler) + AY8910_LEGACY_OUTPUT | AY8910_SINGLE_OUTPUT, + AY8910_DEFAULT_LOADS, + DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL }; static MACHINE_CONFIG_START( wc90, wc90_state ) @@ -336,7 +333,8 @@ static MACHINE_CONFIG_START( wc90, wc90_state ) MCFG_SPEAKER_STANDARD_MONO("mono") MCFG_SOUND_ADD("ymsnd", YM2608, XTAL_8MHz) /* verified on pcb */ - MCFG_SOUND_CONFIG(ym2608_config) + MCFG_YM2608_IRQ_HANDLER(WRITELINE(wc90_state, irqhandler)) + MCFG_YM2608_AY8910_INTF(&ay8910_config) MCFG_SOUND_ROUTE(0, "mono", 0.50) MCFG_SOUND_ROUTE(1, "mono", 1.0) MCFG_SOUND_ROUTE(2, "mono", 1.0) diff --git a/src/mess/drivers/pc8801.c b/src/mess/drivers/pc8801.c index 52c545f7ce9..247893692c9 100644 --- a/src/mess/drivers/pc8801.c +++ b/src/mess/drivers/pc8801.c @@ -304,7 +304,8 @@ public: m_pic(*this, I8214_TAG), m_rtc(*this, UPD1990A_TAG), m_cassette(*this, "cassette"), - m_beeper(*this, "beeper") + m_beeper(*this, "beeper"), + m_opna(*this, "opna") { } required_device m_maincpu; @@ -313,6 +314,7 @@ public: required_device m_rtc; required_device m_cassette; required_device m_beeper; + required_device m_opna; UINT8 *m_work_ram; UINT8 *m_hi_work_ram; UINT8 *m_ext_work_ram; @@ -1696,7 +1698,7 @@ WRITE8_MEMBER(pc8801_state::pc8801_rtc_w) READ8_MEMBER(pc8801_state::pc8801_sound_board_r) { if(m_has_opna) - return ym2608_r(machine().device("opna"), space, offset); + return m_opna->read(space, offset); return (offset & 2) ? 0xff : ym2203_r(machine().device("opn"), space, offset); } @@ -1704,7 +1706,7 @@ READ8_MEMBER(pc8801_state::pc8801_sound_board_r) WRITE8_MEMBER(pc8801_state::pc8801_sound_board_w) { if(m_has_opna) - ym2608_w(machine().device("opna"), space, offset,data); + m_opna->write(space, offset,data); else if((offset & 2) == 0) ym2203_w(machine().device("opn"), space, offset,data); } @@ -1712,7 +1714,7 @@ WRITE8_MEMBER(pc8801_state::pc8801_sound_board_w) READ8_MEMBER(pc8801_state::pc8801_opna_r) { if(m_has_opna && (offset & 2) == 0) - return ym2608_r(machine().device("opna"), space, (offset & 1) | ((offset & 4) >> 1)); + return m_opna->read(space, (offset & 1) | ((offset & 4) >> 1)); return 0xff; } @@ -1720,7 +1722,7 @@ READ8_MEMBER(pc8801_state::pc8801_opna_r) WRITE8_MEMBER(pc8801_state::pc8801_opna_w) { if(m_has_opna && (offset & 2) == 0) - ym2608_w(machine().device("opna"), space, (offset & 1) | ((offset & 4) >> 1),data); + m_opna->write(space, (offset & 1) | ((offset & 4) >> 1),data); else if(m_has_opna && offset == 2) { m_sound_irq_mask = ((data & 0x80) == 0); @@ -2599,17 +2601,14 @@ static const ym2203_interface pc88_ym2203_intf = DEVCB_DRIVER_LINE_MEMBER(pc8801_state,pc8801_sound_irq) }; -static const ym2608_interface pc88_ym2608_intf = +static const ay8910_interface ay8910_config = { - { - AY8910_LEGACY_OUTPUT | AY8910_SINGLE_OUTPUT, - AY8910_DEFAULT_LOADS, - DEVCB_DRIVER_MEMBER(pc8801_state,opn_porta_r), - DEVCB_DRIVER_MEMBER(pc8801_state,opn_portb_r), - DEVCB_NULL, - DEVCB_NULL - }, - DEVCB_DRIVER_LINE_MEMBER(pc8801_state,pc8801_sound_irq) + AY8910_LEGACY_OUTPUT | AY8910_SINGLE_OUTPUT, + AY8910_DEFAULT_LOADS, + DEVCB_DRIVER_MEMBER(pc8801_state,opn_porta_r), + DEVCB_DRIVER_MEMBER(pc8801_state,opn_portb_r), + DEVCB_NULL, + DEVCB_NULL }; /* Cassette Configuration */ @@ -2707,7 +2706,8 @@ static MACHINE_CONFIG_START( pc8801, pc8801_state ) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00) MCFG_SOUND_ADD("opna", YM2608, MASTER_CLOCK*2) - MCFG_SOUND_CONFIG(pc88_ym2608_intf) + MCFG_YM2608_IRQ_HANDLER(WRITELINE(pc8801_state, pc8801_sound_irq)) + MCFG_YM2608_AY8910_INTF(&ay8910_config) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00) MCFG_SOUND_ADD("beeper", BEEP, 0) diff --git a/src/mess/machine/pc9801_118.c b/src/mess/machine/pc9801_118.c index 32ebc0936f7..ffee7810610 100644 --- a/src/mess/machine/pc9801_118.c +++ b/src/mess/machine/pc9801_118.c @@ -41,23 +41,21 @@ WRITE_LINE_MEMBER(pc9801_118_device::pc9801_sound_irq) pic8259_ir4_w(machine().device("pic8259_slave"), state); } -static const ym2608_interface pc98_ym2608_intf = +static const ay8910_interface ay8910_config = { - { - AY8910_LEGACY_OUTPUT, - AY8910_DEFAULT_LOADS, - DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, pc9801_118_device,opn_porta_r), - DEVCB_NULL,//(pc9801_state,opn_portb_r), - DEVCB_NULL,//(pc9801_state,opn_porta_w), - DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, pc9801_118_device,opn_portb_w), - }, - DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, pc9801_118_device,pc9801_sound_irq) + AY8910_LEGACY_OUTPUT, + AY8910_DEFAULT_LOADS, + DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, pc9801_118_device,opn_porta_r), + DEVCB_NULL,//(pc9801_state,opn_portb_r), + DEVCB_NULL,//(pc9801_state,opn_porta_w), + DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, pc9801_118_device,opn_portb_w), }; static MACHINE_CONFIG_FRAGMENT( pc9801_118_config ) MCFG_SPEAKER_STANDARD_MONO("mono") MCFG_SOUND_ADD("opn3", YM2608, MAIN_CLOCK_X1*4) // actually YMF288, unknown clock / divider - MCFG_SOUND_CONFIG(pc98_ym2608_intf) + MCFG_YM2608_IRQ_HANDLER(DEVWRITELINE(DEVICE_SELF_OWNER, pc9801_118_device, pc9801_sound_irq)) + MCFG_YM2608_AY8910_INTF(&ay8910_config) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00) MACHINE_CONFIG_END @@ -192,7 +190,7 @@ void pc9801_118_device::device_reset() READ8_MEMBER(pc9801_118_device::pc9801_118_r) { if(((offset & 5) == 0) || m_ext_reg) - return ym2608_r(m_opn3, space, offset >> 1); + return m_opn3->read(space, offset >> 1); else // odd { //printf("PC9801-118: Read to undefined port [%02x]\n",offset+0x188); @@ -204,7 +202,7 @@ READ8_MEMBER(pc9801_118_device::pc9801_118_r) WRITE8_MEMBER(pc9801_118_device::pc9801_118_w) { if(((offset & 5) == 0) || m_ext_reg) - ym2608_w(m_opn3,space, offset >> 1,data); + m_opn3->write(space, offset >> 1,data); //else // odd // printf("PC9801-118: Write to undefined port [%02x] %02x\n",offset+0x188,data); } diff --git a/src/mess/machine/pc9801_86.c b/src/mess/machine/pc9801_86.c index e8bec291344..4d60e9a8be5 100644 --- a/src/mess/machine/pc9801_86.c +++ b/src/mess/machine/pc9801_86.c @@ -41,23 +41,21 @@ WRITE_LINE_MEMBER(pc9801_86_device::pc9801_sound_irq) pic8259_ir4_w(machine().device("pic8259_slave"), state); } -static const ym2608_interface pc98_ym2608_intf = +static const ay8910_interface ay8910_config = { - { - AY8910_LEGACY_OUTPUT, - AY8910_DEFAULT_LOADS, - DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, pc9801_86_device,opn_porta_r), - DEVCB_NULL,//(pc9801_state,opn_portb_r), - DEVCB_NULL,//(pc9801_state,opn_porta_w), - DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, pc9801_86_device,opn_portb_w), - }, - DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, pc9801_86_device,pc9801_sound_irq) + AY8910_LEGACY_OUTPUT, + AY8910_DEFAULT_LOADS, + DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, pc9801_86_device,opn_porta_r), + DEVCB_NULL,//(pc9801_state,opn_portb_r), + DEVCB_NULL,//(pc9801_state,opn_porta_w), + DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, pc9801_86_device,opn_portb_w), }; static MACHINE_CONFIG_FRAGMENT( pc9801_86_config ) MCFG_SPEAKER_STANDARD_MONO("mono") MCFG_SOUND_ADD("opna", YM2608, MAIN_CLOCK_X1*4) // unknown clock / divider - MCFG_SOUND_CONFIG(pc98_ym2608_intf) + MCFG_YM2608_IRQ_HANDLER(DEVWRITELINE(DEVICE_SELF_OWNER, pc9801_86_device, pc9801_sound_irq)) + MCFG_YM2608_AY8910_INTF(&ay8910_config) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00) MACHINE_CONFIG_END @@ -192,7 +190,7 @@ void pc9801_86_device::device_reset() READ8_MEMBER(pc9801_86_device::pc9801_86_r) { if((offset & 1) == 0) - return ym2608_r(m_opna, space, offset >> 1); + return m_opna->read(space, offset >> 1); else // odd { printf("PC9801-86: Read to undefined port [%02x]\n",offset+0x188); @@ -204,7 +202,7 @@ READ8_MEMBER(pc9801_86_device::pc9801_86_r) WRITE8_MEMBER(pc9801_86_device::pc9801_86_w) { if((offset & 1) == 0) - ym2608_w(m_opna,space, offset >> 1,data); + m_opna->write(space, offset >> 1,data); else // odd printf("PC9801-86: Write to undefined port [%02x] %02x\n",offset+0x188,data); }