Refactored YM3526 to use devcb. [Curt Coder]

This commit is contained in:
Curt Coder 2012-03-07 18:42:58 +00:00
parent 6c65c7f868
commit a54ae8335f
15 changed files with 30 additions and 84 deletions

View File

@ -30,6 +30,8 @@ struct _ym3526_state
void * chip; void * chip;
const ym3526_interface *intf; const ym3526_interface *intf;
device_t *device; device_t *device;
devcb_resolved_write_line out_int_func;
}; };
@ -45,7 +47,7 @@ INLINE ym3526_state *get_safe_token(device_t *device)
static void IRQHandler(void *param,int irq) static void IRQHandler(void *param,int irq)
{ {
ym3526_state *info = (ym3526_state *)param; ym3526_state *info = (ym3526_state *)param;
if (info->intf->handler) (info->intf->handler)(info->device, irq ? ASSERT_LINE : CLEAR_LINE); info->out_int_func(irq ? ASSERT_LINE : CLEAR_LINE);
} }
/* Timer overflow callback from timer.c */ /* Timer overflow callback from timer.c */
static TIMER_CALLBACK( timer_callback_0 ) static TIMER_CALLBACK( timer_callback_0 )
@ -88,13 +90,16 @@ static void _stream_update(void *param, int interval)
static DEVICE_START( ym3526 ) static DEVICE_START( ym3526 )
{ {
static const ym3526_interface dummy = { 0 }; static const ym3526_interface dummy = { DEVCB_NULL };
ym3526_state *info = get_safe_token(device); ym3526_state *info = get_safe_token(device);
int rate = device->clock()/72; int rate = device->clock()/72;
info->intf = device->static_config() ? (const ym3526_interface *)device->static_config() : &dummy; info->intf = device->static_config() ? (const ym3526_interface *)device->static_config() : &dummy;
info->device = device; info->device = device;
// resolve callbacks
info->out_int_func.resolve(info->intf->out_int_func, *device);
/* stream system initialize */ /* stream system initialize */
info->chip = ym3526_init(device,device->clock(),rate); info->chip = ym3526_init(device,device->clock(),rate);
assert_always(info->chip != NULL, "Error creating YM3526 chip"); assert_always(info->chip != NULL, "Error creating YM3526 chip");

View File

@ -8,7 +8,7 @@
typedef struct _ym3526_interface ym3526_interface; typedef struct _ym3526_interface ym3526_interface;
struct _ym3526_interface struct _ym3526_interface
{ {
void (*handler)(device_t *device, int linestate); devcb_write_line out_int_func;
}; };
READ8_DEVICE_HANDLER( ym3526_r ); READ8_DEVICE_HANDLER( ym3526_r );

View File

@ -256,15 +256,9 @@ GFXDECODE_END
* *
*************************************/ *************************************/
static void irqhandler( device_t *device, int irq )
{
battlane_state *state = device->machine().driver_data<battlane_state>();
device_set_input_line(state->m_maincpu, M6809_FIRQ_LINE, irq ? ASSERT_LINE : CLEAR_LINE);
}
static const ym3526_interface ym3526_config = static const ym3526_interface ym3526_config =
{ {
irqhandler DEVCB_CPU_INPUT_LINE("maincpu", M6809_FIRQ_LINE)
}; };

View File

@ -354,16 +354,9 @@ GFXDECODE_END
* *
*************************************/ *************************************/
/* handler called by the 3812 emulator when the internal timers cause an IRQ */
static void irqhandler( device_t *device, int linestate )
{
brkthru_state *state = device->machine().driver_data<brkthru_state>();
device_set_input_line(state->m_audiocpu, M6809_IRQ_LINE, linestate);
}
static const ym3526_interface ym3526_config = static const ym3526_interface ym3526_config =
{ {
irqhandler DEVCB_CPU_INPUT_LINE("audiocpu", M6809_IRQ_LINE)
}; };

View File

@ -1911,7 +1911,7 @@ static void irqhandler( device_t *device, int linestate )
static const ym3526_interface ym3526_config = static const ym3526_interface ym3526_config =
{ {
irqhandler DEVCB_CPU_INPUT_LINE("audiocpu", M6502_IRQ_LINE)
}; };
static const ym3812_interface ym3812_config = static const ym3812_interface ym3812_config =

View File

@ -439,15 +439,15 @@ GFXDECODE_END
/* handler called by the 3812 emulator when the internal timers cause an IRQ */ /* handler called by the 3812 emulator when the internal timers cause an IRQ */
static void irqhandler( device_t *device, int linestate ) static WRITE_LINE_DEVICE_HANDLER( irqhandler )
{ {
exprraid_state *state = device->machine().driver_data<exprraid_state>(); exprraid_state *driver_state = device->machine().driver_data<exprraid_state>();
device_set_input_line_and_vector(state->m_slave, 0, linestate, 0xff); device_set_input_line_and_vector(driver_state->m_slave, 0, state, 0xff);
} }
static const ym3526_interface ym3526_config = static const ym3526_interface ym3526_config =
{ {
irqhandler DEVCB_LINE(irqhandler)
}; };
#if 0 #if 0

View File

@ -1047,16 +1047,9 @@ static MACHINE_CONFIG_START( borntofi, fantland_state )
MACHINE_CONFIG_END MACHINE_CONFIG_END
static void wheelrun_ym3526_irqhandler( device_t *device, int state )
{
fantland_state *driver = device->machine().driver_data<fantland_state>();
device_set_input_line(driver->m_audio_cpu, INPUT_LINE_IRQ0, state);
}
static const ym3526_interface wheelrun_ym3526_interface = static const ym3526_interface wheelrun_ym3526_interface =
{ {
wheelrun_ym3526_irqhandler DEVCB_CPU_INPUT_LINE("audiocpu", INPUT_LINE_IRQ0)
}; };
static MACHINE_CONFIG_START( wheelrun, fantland_state ) static MACHINE_CONFIG_START( wheelrun, fantland_state )

View File

@ -756,15 +756,9 @@ static INTERRUPT_GEN( karnov_interrupt )
device_set_input_line(device, 7, HOLD_LINE); /* VBL */ device_set_input_line(device, 7, HOLD_LINE); /* VBL */
} }
static void sound_irq( device_t *device, int linestate )
{
karnov_state *state = device->machine().driver_data<karnov_state>();
device_set_input_line(state->m_audiocpu, 0, linestate); /* IRQ */
}
static const ym3526_interface ym3526_config = static const ym3526_interface ym3526_config =
{ {
sound_irq DEVCB_CPU_INPUT_LINE("audiocpu", M6502_IRQ_LINE)
}; };
/************************************* /*************************************

View File

@ -350,17 +350,9 @@ static MACHINE_CONFIG_START( matmania, matmania_state )
MACHINE_CONFIG_END MACHINE_CONFIG_END
/* handler called by the 3526 emulator when the internal timers cause an IRQ */
static void irqhandler(device_t *device, int linestate)
{
matmania_state *state = device->machine().driver_data<matmania_state>();
device_set_input_line(state->m_audiocpu, 1, linestate);
}
static const ym3526_interface ym3526_config = static const ym3526_interface ym3526_config =
{ {
irqhandler DEVCB_CPU_INPUT_LINE("audiocpu", M6809_FIRQ_LINE)
}; };

View File

@ -259,15 +259,9 @@ GFXDECODE_END
***************************************************************************/ ***************************************************************************/
static void metlclsh_irqhandler(device_t *device, int linestate)
{
metlclsh_state *state = device->machine().driver_data<metlclsh_state>();
device_set_input_line(state->m_maincpu, M6809_IRQ_LINE, linestate);
}
static const ym3526_interface ym3526_config = static const ym3526_interface ym3526_config =
{ {
metlclsh_irqhandler DEVCB_CPU_INPUT_LINE("maincpu", M6809_IRQ_LINE)
}; };

View File

@ -407,7 +407,7 @@ GFXDECODE_END
/* Sound Interfaces */ /* Sound Interfaces */
// Handler called by the 3526 emulator when the internal timers cause an IRQ // Handler called by the 3526 emulator when the internal timers cause an IRQ
static void irqhandler(device_t *device, int irq) static WRITE_LINE_DEVICE_HANDLER( irqhandler )
{ {
logerror("YM3526 firing an IRQ\n"); logerror("YM3526 firing an IRQ\n");
// cputag_set_input_line(device->machine(), "audiocpu", 0, irq ? ASSERT_LINE : CLEAR_LINE); // cputag_set_input_line(device->machine(), "audiocpu", 0, irq ? ASSERT_LINE : CLEAR_LINE);
@ -415,7 +415,7 @@ static void irqhandler(device_t *device, int irq)
static const ym3526_interface ym3526_config = static const ym3526_interface ym3526_config =
{ {
irqhandler DEVCB_LINE(irqhandler)
}; };
/* Interrupt Generator */ /* Interrupt Generator */

View File

@ -890,16 +890,9 @@ static GFXDECODE_START( renegade )
GFXDECODE_END GFXDECODE_END
/* handler called by the 3526 emulator when the internal timers cause an IRQ */
static void irqhandler(device_t *device, int linestate)
{
cputag_set_input_line(device->machine(), "audiocpu", M6809_FIRQ_LINE, linestate);
}
static const ym3526_interface ym3526_config = static const ym3526_interface ym3526_config =
{ {
irqhandler DEVCB_CPU_INPUT_LINE("audiocpu", M6809_FIRQ_LINE)
}; };

View File

@ -245,16 +245,9 @@ static GFXDECODE_START( sidepckt )
GFXDECODE_END GFXDECODE_END
/* handler called by the 3526 emulator when the internal timers cause an IRQ */
static void irqhandler(device_t *device, int linestate)
{
cputag_set_input_line(device->machine(), "audiocpu", 0, linestate);
}
static const ym3526_interface ym3526_config = static const ym3526_interface ym3526_config =
{ {
irqhandler DEVCB_CPU_INPUT_LINE("audiocpu", M6502_IRQ_LINE)
}; };

View File

@ -457,27 +457,27 @@ static TIMER_CALLBACK( sndirq_update_callback )
static void ymirq_callback_1(device_t *device, int irq) static WRITE_LINE_DEVICE_HANDLER( ymirq_callback_1 )
{ {
if (irq) if (state)
device->machine().scheduler().synchronize(FUNC(sndirq_update_callback), YM1IRQ_ASSERT); device->machine().scheduler().synchronize(FUNC(sndirq_update_callback), YM1IRQ_ASSERT);
} }
static void ymirq_callback_2(device_t *device, int irq) static WRITE_LINE_DEVICE_HANDLER( ymirq_callback_2 )
{ {
if (irq) if (state)
device->machine().scheduler().synchronize(FUNC(sndirq_update_callback), YM2IRQ_ASSERT); device->machine().scheduler().synchronize(FUNC(sndirq_update_callback), YM2IRQ_ASSERT);
} }
static const ym3526_interface ym3526_config_1 = static const ym3526_interface ym3526_config_1 =
{ {
ymirq_callback_1 DEVCB_LINE(ymirq_callback_1)
}; };
static const ym3526_interface ym3526_config_2 = static const ym3526_interface ym3526_config_2 =
{ {
ymirq_callback_2 DEVCB_LINE(ymirq_callback_2)
}; };
static const ym3812_interface ym3812_config_1 = static const ym3812_interface ym3812_config_1 =

View File

@ -910,14 +910,9 @@ MACHINE_CONFIG_END
Best Of Best Best Of Best
***************************************************************************/ ***************************************************************************/
static void bestbest_ym3526_irqhandler(device_t *device, int state)
{
cputag_set_input_line(device->machine(), "audiocpu", INPUT_LINE_IRQ0, state);
}
static const ym3526_interface bestbest_ym3526_interface = static const ym3526_interface bestbest_ym3526_interface =
{ {
bestbest_ym3526_irqhandler DEVCB_CPU_INPUT_LINE("audiocpu", INPUT_LINE_IRQ0)
}; };
static WRITE8_DEVICE_HANDLER( bestbest_ay8910_port_a_w ) static WRITE8_DEVICE_HANDLER( bestbest_ay8910_port_a_w )