From f676e765089b783357b0340b01efdabcdec4bd5b Mon Sep 17 00:00:00 2001 From: AJR Date: Fri, 1 Dec 2017 11:44:28 -0500 Subject: [PATCH] thomson.cpp: Use input_merger_device for IRQ & FIRQ (nw) --- src/mame/drivers/thomson.cpp | 24 +++++--- src/mame/includes/thomson.h | 17 ++---- src/mame/machine/thomson.cpp | 109 +++-------------------------------- 3 files changed, 27 insertions(+), 123 deletions(-) diff --git a/src/mame/drivers/thomson.cpp b/src/mame/drivers/thomson.cpp index 7864b3a1d8c..8b5e9086f6d 100644 --- a/src/mame/drivers/thomson.cpp +++ b/src/mame/drivers/thomson.cpp @@ -626,6 +626,12 @@ static MACHINE_CONFIG_START( to7 ) MCFG_CPU_ADD ( "maincpu", M6809, 1000000 ) MCFG_CPU_PROGRAM_MAP ( to7) + MCFG_INPUT_MERGER_ANY_HIGH("mainirq") + MCFG_INPUT_MERGER_OUTPUT_HANDLER(INPUTLINE("maincpu", M6809_IRQ_LINE)) + + MCFG_INPUT_MERGER_ANY_HIGH("mainfirq") + MCFG_INPUT_MERGER_OUTPUT_HANDLER(INPUTLINE("maincpu", M6809_FIRQ_LINE)) + /* video */ MCFG_SCREEN_ADD("screen", RASTER) MCFG_SCREEN_REFRESH_RATE ( /*50*/ 1./0.019968 ) @@ -664,7 +670,7 @@ static MACHINE_CONFIG_START( to7 ) MCFG_MC6846_OUT_CP2_CB(DEVWRITELINE("buzzer", dac_bit_interface, write)) MCFG_MC6846_IN_PORT_CB(READ8(thomson_state, to7_timer_port_in)) MCFG_MC6846_OUT_CTO_CB(WRITELINE(thomson_state, to7_set_cassette)) - MCFG_MC6846_IRQ_CB(WRITELINE(thomson_state, thom_dev_irq_0)) + MCFG_MC6846_IRQ_CB(DEVWRITELINE("mainirq", input_merger_device, in_w<0>)) /* floppy */ MCFG_DEVICE_ADD("mc6843", MC6843, 0) @@ -699,16 +705,16 @@ static MACHINE_CONFIG_START( to7 ) MCFG_PIA_WRITEPB_HANDLER(WRITE8(thomson_state, to7_sys_portb_out)) MCFG_PIA_CA2_HANDLER(WRITELINE(thomson_state, to7_set_cassette_motor)) MCFG_PIA_CB2_HANDLER(WRITELINE(thomson_state, to7_sys_cb2_out)) - MCFG_PIA_IRQA_HANDLER(WRITELINE(thomson_state, thom_firq_1)) - MCFG_PIA_IRQB_HANDLER(WRITELINE(thomson_state, thom_firq_1)) + MCFG_PIA_IRQA_HANDLER(DEVWRITELINE("mainfirq", input_merger_device, in_w<1>)) + MCFG_PIA_IRQB_HANDLER(DEVWRITELINE("mainfirq", input_merger_device, in_w<1>)) MCFG_DEVICE_ADD(THOM_PIA_GAME, PIA6821, 0) MCFG_PIA_READPA_HANDLER(READ8(thomson_state, to7_game_porta_in)) MCFG_PIA_READPB_HANDLER(READ8(thomson_state, to7_game_portb_in)) MCFG_PIA_WRITEPB_HANDLER(WRITE8(thomson_state, to7_game_portb_out)) MCFG_PIA_CB2_HANDLER(WRITELINE(thomson_state, to7_game_cb2_out)) - MCFG_PIA_IRQA_HANDLER(WRITELINE(thomson_state, thom_irq_1)) - MCFG_PIA_IRQB_HANDLER(WRITELINE(thomson_state, thom_irq_1)) + MCFG_PIA_IRQA_HANDLER(DEVWRITELINE("mainirq", input_merger_device, in_w<1>)) + MCFG_PIA_IRQB_HANDLER(DEVWRITELINE("mainirq", input_merger_device, in_w<1>)) /* TODO: CONVERT THIS TO A SLOT DEVICE (RF 57-932) */ MCFG_DEVICE_ADD("acia", MOS6551, 0) @@ -1130,7 +1136,7 @@ static MACHINE_CONFIG_DERIVED( mo5, to7 ) MCFG_PIA_WRITEPB_HANDLER(DEVWRITE8("buzzer", dac_bit_interface, write)) MCFG_PIA_CA2_HANDLER(WRITELINE(thomson_state, mo5_set_cassette_motor)) MCFG_PIA_CB2_HANDLER(NOOP) - MCFG_PIA_IRQB_HANDLER(WRITELINE(thomson_state, thom_irq_1)) /* WARNING: differs from TO7 ! */ + MCFG_PIA_IRQB_HANDLER(DEVWRITELINE("mainirq", input_merger_device, in_w<1>)) // WARNING: differs from TO7 ! MCFG_DEVICE_REMOVE("cartslot") MCFG_GENERIC_CARTSLOT_ADD("cartslot", generic_plain_slot, "mo_cart") @@ -1866,7 +1872,7 @@ static MACHINE_CONFIG_DERIVED( to9p, to7 ) MCFG_PIA_WRITEPB_HANDLER(WRITE8(thomson_state, to8_sys_portb_out)) MCFG_PIA_CB2_HANDLER(NOOP) MCFG_PIA_IRQA_HANDLER(NOOP) - MCFG_PIA_IRQB_HANDLER(WRITELINE(thomson_state, thom_firq_1)) + MCFG_PIA_IRQB_HANDLER(DEVWRITELINE("mainfirq", input_merger_device, in_w<1>)) MCFG_CENTRONICS_ADD("centronics", centronics_devices, "printer") MCFG_CENTRONICS_BUSY_HANDLER(WRITELINE(thomson_state, write_centronics_busy)) @@ -2221,7 +2227,7 @@ static MACHINE_CONFIG_DERIVED( mo6, to7 ) MCFG_PIA_WRITEPB_HANDLER(DEVWRITE8("buzzer", dac_bit_interface, write)) MCFG_PIA_CA2_HANDLER(WRITELINE(thomson_state, mo5_set_cassette_motor)) MCFG_PIA_CB2_HANDLER(WRITELINE(thomson_state, mo6_sys_cb2_out)) - MCFG_PIA_IRQB_HANDLER(WRITELINE(thomson_state, thom_irq_1)) /* differs from TO */ + MCFG_PIA_IRQB_HANDLER(DEVWRITELINE("mainirq", input_merger_device, in_w<1>)) // differs from TO MCFG_DEVICE_MODIFY(THOM_PIA_GAME) MCFG_PIA_WRITEPA_HANDLER(WRITE8(thomson_state, mo6_game_porta_out)) @@ -2490,7 +2496,7 @@ static MACHINE_CONFIG_DERIVED( mo5nr, to7 ) MCFG_PIA_WRITEPB_HANDLER(DEVWRITE8("buzzer", dac_bit_interface, write)) MCFG_PIA_CA2_HANDLER(WRITELINE(thomson_state, mo5_set_cassette_motor)) MCFG_PIA_CB2_HANDLER(WRITELINE(thomson_state, mo6_sys_cb2_out)) - MCFG_PIA_IRQB_HANDLER(WRITELINE(thomson_state, thom_irq_1)) /* differs from TO */ + MCFG_PIA_IRQB_HANDLER(DEVWRITELINE("mainirq", input_merger_device, in_w<1>)) // differs from TO MCFG_DEVICE_MODIFY(THOM_PIA_GAME) MCFG_PIA_WRITEPA_HANDLER(WRITE8(thomson_state, mo6_game_porta_out)) diff --git a/src/mame/includes/thomson.h b/src/mame/includes/thomson.h index 58223220730..52ca0698b01 100644 --- a/src/mame/includes/thomson.h +++ b/src/mame/includes/thomson.h @@ -20,6 +20,7 @@ #include "imagedev/floppy.h" #include "machine/6821pia.h" #include "machine/6850acia.h" +#include "machine/input_merger.h" #include "machine/mc6843.h" #include "machine/mc6846.h" #include "machine/mc6846.h" @@ -116,6 +117,8 @@ public: m_mc6843(*this, "mc6843"), m_acia6850(*this, "acia6850"), m_screen(*this, "screen"), + m_mainirq(*this, "mainirq"), + m_mainfirq(*this, "mainfirq"), m_io_game_port_directions(*this, "game_port_directions"), m_io_game_port_buttons(*this, "game_port_buttons"), m_io_mouse_x(*this, "mouse_x"), @@ -152,8 +155,6 @@ public: DECLARE_WRITE_LINE_MEMBER( to7_set_cassette_motor ); DECLARE_WRITE_LINE_MEMBER( mo5_set_cassette_motor ); DECLARE_WRITE_LINE_MEMBER( thom_dev_irq_0 ); - DECLARE_WRITE_LINE_MEMBER( thom_irq_1 ); - DECLARE_WRITE_LINE_MEMBER( thom_firq_1 ); DECLARE_WRITE8_MEMBER( to7_cartridge_w ); DECLARE_READ8_MEMBER( to7_cartridge_r ); DECLARE_WRITE8_MEMBER( to7_timer_port_out ); @@ -369,6 +370,8 @@ protected: optional_device m_mc6843; optional_device m_acia6850; required_device m_screen; + required_device m_mainirq; + required_device m_mainfirq; required_ioport m_io_game_port_directions; required_ioport m_io_game_port_buttons; required_ioport m_io_mouse_x; @@ -403,9 +406,6 @@ protected: /* buffer storing demodulated bits, only for k7 and with speed hack */ uint32_t m_to7_k7_bitsize; uint8_t* m_to7_k7_bits; - /* several devices on the same irqs */ - uint8_t m_thom_irq; - uint8_t m_thom_firq; /* ------------ cartridge ------------ */ uint8_t m_thom_cart_nb_banks; /* number of 16 KB banks (up to 4) */ uint8_t m_thom_cart_bank; /* current bank */ @@ -513,14 +513,7 @@ protected: int to7_get_cassette(); int mo5_get_cassette(); void mo5_set_cassette( int data ); - void thom_set_irq( int line, int state ); - void thom_set_firq( int line, int state ); void thom_irq_reset(); - void thom_irq_init(); - void thom_irq_0( int state ); - void thom_irq_3( int state ); - void thom_firq_2( int state ); - void thom_irq_4( int state ); void thom_set_caps_led( int led ); void to7_update_cart_bank(); void to7_set_init( int init ); diff --git a/src/mame/machine/thomson.cpp b/src/mame/machine/thomson.cpp index 315845a3408..a5c958f1eb6 100644 --- a/src/mame/machine/thomson.cpp +++ b/src/mame/machine/thomson.cpp @@ -226,100 +226,13 @@ WRITE_LINE_MEMBER( thomson_state::mo5_set_cassette_motor ) /* ------------ IRQs ------------ */ -void thomson_state::thom_set_irq( int line, int state ) -{ - int old = m_thom_irq; - - if ( state ) - m_thom_irq |= 1 << line; - else - m_thom_irq &= ~(1 << line); - - if ( !old && m_thom_irq ) - LOG_IRQ(( "%f thom_set_irq: irq line up %i\n", machine().time().as_double(), line )); - if ( old && !m_thom_irq ) - LOG_IRQ(( "%f thom_set_irq: irq line down %i\n", machine().time().as_double(), line )); - - m_maincpu->set_input_line(M6809_IRQ_LINE, m_thom_irq ? ASSERT_LINE : CLEAR_LINE); -} - - - -void thomson_state::thom_set_firq ( int line, int state ) -{ - int old = m_thom_firq; - - if ( state ) - m_thom_firq |= 1 << line; - else - m_thom_firq &= ~(1 << line); - - if ( !old && m_thom_firq ) - LOG_IRQ(( "%f thom_set_firq: firq line up %i\n", machine().time().as_double(), line )); - if ( old && !m_thom_firq ) - LOG_IRQ(( "%f thom_set_firq: firq line down %i\n", machine().time().as_double(), line )); - - m_maincpu->set_input_line(M6809_FIRQ_LINE, m_thom_firq ? ASSERT_LINE : CLEAR_LINE); -} - - - void thomson_state::thom_irq_reset() { - m_thom_irq = 0; - m_thom_firq = 0; - m_maincpu->set_input_line(M6809_IRQ_LINE, CLEAR_LINE ); - m_maincpu->set_input_line(M6809_FIRQ_LINE, CLEAR_LINE ); + m_mainfirq->in_w<2>(0); } -void thomson_state::thom_irq_init() -{ - save_item(NAME(m_thom_irq)); - save_item(NAME(m_thom_firq)); -} - - - -void thomson_state::thom_irq_0( int state ) -{ - thom_set_irq( 0, state ); -} - -WRITE_LINE_MEMBER( thomson_state::thom_dev_irq_0 ) -{ - thom_irq_0( state ); -} - - - -WRITE_LINE_MEMBER( thomson_state::thom_irq_1 ) -{ - thom_set_irq ( 1, state ); -} - -void thomson_state::thom_irq_3( int state ) -{ - thom_set_irq ( 3, state ); -} - -WRITE_LINE_MEMBER( thomson_state::thom_firq_1 ) -{ - thom_set_firq ( 1, state ); -} - -void thomson_state::thom_firq_2( int state ) -{ - thom_set_firq ( 2, state ); -} - -void thomson_state::thom_irq_4( int state ) -{ - thom_set_irq ( 4, state ); -} - - /* current IRQ usage: @@ -614,8 +527,8 @@ MACHINE_CONFIG_MEMBER( to7_io_line_device::device_add_mconfig ) MCFG_PIA_WRITEPA_HANDLER(WRITE8(to7_io_line_device, porta_out)) MCFG_PIA_WRITEPB_HANDLER(DEVWRITE8("cent_data_out", output_latch_device, write)) MCFG_PIA_CB2_HANDLER(DEVWRITELINE("centronics", centronics_device, write_strobe)) - MCFG_PIA_IRQA_HANDLER(DEVWRITELINE("^", thomson_state, thom_firq_1)) - MCFG_PIA_IRQB_HANDLER(DEVWRITELINE("^", thomson_state, thom_firq_1)) + MCFG_PIA_IRQA_HANDLER(DEVWRITELINE("^mainfirq", input_merger_device, in_w<1>)) + MCFG_PIA_IRQB_HANDLER(DEVWRITELINE("^mainfirq", input_merger_device, in_w<1>)) MCFG_RS232_PORT_ADD("rs232", default_rs232_devices, nullptr) MCFG_RS232_RXD_HANDLER(WRITELINE(to7_io_line_device, write_rxd)) @@ -1082,7 +995,6 @@ MACHINE_START_MEMBER( thomson_state, to7 ) LOG (( "to7: machine start called\n" )); /* subsystems */ - thom_irq_init(); to7_game_init(); to7_floppy_init(mem + 0x20000); to7_modem_init(); @@ -1306,7 +1218,6 @@ MACHINE_START_MEMBER( thomson_state, to770 ) LOG (( "to770: machine start called\n" )); /* subsystems */ - thom_irq_init(); to7_game_init(); to7_floppy_init( mem + 0x20000 ); to7_modem_init(); @@ -1687,7 +1598,6 @@ MACHINE_START_MEMBER( thomson_state, mo5 ) LOG (( "mo5: machine start called\n" )); /* subsystems */ - thom_irq_init(); to7_game_init(); to7_floppy_init( mem + 0x20000 ); to7_modem_init(); @@ -2150,7 +2060,7 @@ void thomson_state::to9_kbd_update_irq() if ( (m_to9_kbd_intr & 3) == 1 && (m_to9_kbd_status & ACIA_6850_TDRE) ) m_to9_kbd_status |= ACIA_6850_irq; /* ready to transmit interrupt */ - thom_irq_3( m_to9_kbd_status & ACIA_6850_irq ); + m_mainirq->in_w<3>( m_to9_kbd_status & ACIA_6850_irq ); } @@ -2630,7 +2540,6 @@ MACHINE_START_MEMBER( thomson_state, to9 ) LOG (( "to9: machine start called\n" )); /* subsystems */ - thom_irq_init(); to7_game_init(); to9_floppy_init( mem + 0xe000, mem + 0x40000 ); to9_kbd_init(); @@ -3327,7 +3236,7 @@ READ8_MEMBER( thomson_state::to8_gatearray_r ) { if ( !machine().side_effect_disabled() ) { - thom_firq_2( 0 ); + m_mainfirq->in_w<2>(0); m_to8_lightpen_intr = 0; } res = count & 0xff; @@ -3574,7 +3483,7 @@ void thomson_state::to8_lightpen_cb( int step ) if ( ! m_to7_lightpen ) return; - thom_firq_2( 1 ); + m_mainfirq->in_w<2>(1); m_to7_lightpen_step = step; m_to8_lightpen_intr = 1; } @@ -3641,7 +3550,6 @@ MACHINE_START_MEMBER( thomson_state, to8 ) LOG (( "to8: machine start called\n" )); /* subsystems */ - thom_irq_init(); to7_game_init(); to8_floppy_init(); to8_kbd_init(); @@ -3792,7 +3700,6 @@ MACHINE_START_MEMBER( thomson_state, to9p ) LOG (( "to9p: machine start called\n" )); /* subsystems */ - thom_irq_init(); to7_game_init(); to8_floppy_init(); to9_kbd_init(); @@ -4282,7 +4189,7 @@ READ8_MEMBER( thomson_state::mo6_gatearray_r ) { if ( !machine().side_effect_disabled() ) { - thom_firq_2( 0 ); + m_mainfirq->in_w<2>(0); m_to8_lightpen_intr = 0; } res = count & 0xff; @@ -4478,7 +4385,6 @@ MACHINE_START_MEMBER( thomson_state, mo6 ) LOG (( "mo6: machine start called\n" )); /* subsystems */ - thom_irq_init(); mo6_game_init(); to7_floppy_init( mem + 0x30000 ); to9_palette_init(); @@ -4702,7 +4608,6 @@ MACHINE_START_MEMBER( thomson_state, mo5nr ) LOG (( "mo5nr: machine start called\n" )); /* subsystems */ - thom_irq_init(); mo5nr_game_init(); to7_floppy_init( mem + 0x30000 ); to9_palette_init();