diff --git a/src/emu/machine/n68681.c b/src/emu/machine/n68681.c index 9184a92f7da..9d532afad23 100644 --- a/src/emu/machine/n68681.c +++ b/src/emu/machine/n68681.c @@ -97,7 +97,7 @@ void duartn68681_device::device_start() write_irq.resolve_safe(); write_a_tx.resolve_safe(); write_b_tx.resolve_safe(); - read_inport.resolve_safe(0); + read_inport.resolve(); write_outport.resolve_safe(); duart_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(duartn68681_device::duart_timer_callback),this), NULL); @@ -298,7 +298,14 @@ READ8_MEMBER( duartn68681_device::read ) break; case 0x0d: /* IP */ - r = read_inport(); // TODO: go away + if (!read_inport.isnull()) + { + r = read_inport(); // TODO: go away + } + else + { + r = IP_last_state; + } break; case 0x0e: /* Start counter command */ diff --git a/src/emu/machine/n68681.h b/src/emu/machine/n68681.h index 2b468b7d874..36b71add8b3 100644 --- a/src/emu/machine/n68681.h +++ b/src/emu/machine/n68681.h @@ -17,6 +17,7 @@ #define MCFG_DUARTN68681_B_TX_CALLBACK(_cb) \ devcb = &duartn68681_device::set_b_tx_cb(*device, DEVCB2_##_cb); +// deprecated: use ipX_w() instead #define MCFG_DUARTN68681_INPORT_CALLBACK(_cb) \ devcb = &duartn68681_device::set_inport_cb(*device, DEVCB2_##_cb); diff --git a/src/mess/drivers/cat.c b/src/mess/drivers/cat.c index 66b8513551c..9155a602d29 100644 --- a/src/mess/drivers/cat.c +++ b/src/mess/drivers/cat.c @@ -406,7 +406,6 @@ public: optional_device m_via1; // only swyft uses this DECLARE_WRITE_LINE_MEMBER(cat_duart_irq_handler); DECLARE_WRITE_LINE_MEMBER(cat_duart_txa); - DECLARE_READ8_MEMBER(cat_duart_input); DECLARE_WRITE8_MEMBER(cat_duart_output); //required_device m_speaker; optional_shared_ptr m_svram; @@ -993,11 +992,10 @@ TIMER_CALLBACK_MEMBER(cat_state::counter_6ms_callback) { // This is effectively also the KTOBF line 'clock' output to the d-latch before the duart // Hence, invert the d-latch on the duart's input ports. - // is there some way to 'strobe' the duart to tell it that its input ports just changed? - // with the devcb stuff, there definitely should be! + // n68681 now properly generates interrupts when this bit changes, the previous hack is no longer necessary. m_duart_inp ^= 0x04; + m_duart->ip2_w((m_duart_inp>>2)&1); m_6ms_counter++; - m_maincpu->set_input_line(M68K_IRQ_1, ASSERT_LINE); // hack until duart ints work; as of march 2013 they do not work correctly here (they fire at the wrong rate) } IRQ_CALLBACK_MEMBER(cat_state::cat_int_ack) @@ -1066,11 +1064,13 @@ UINT32 cat_state::screen_update_cat(screen_device &screen, bitmap_ind16 &bitmap, */ WRITE_LINE_MEMBER(cat_state::cat_duart_irq_handler) { + int irqvector = m_duart->get_irq_vector(); + #ifdef DEBUG_DUART_IRQ_HANDLER - fprintf(stderr, "Duart IRQ handler called: state: %02X, vector: %06X\n", state, vector); + fprintf(stderr, "Duart IRQ handler called: state: %02X, vector: %06X\n", state, irqvector); #endif m_duart_irq_state = state; - //device->m_maincpu->set_input_line_and_vector(M68K_IRQ_1, state, vector); + m_maincpu->set_input_line_and_vector(M68K_IRQ_1, state, irqvector); } WRITE_LINE_MEMBER(cat_state::cat_duart_txa) @@ -1088,13 +1088,6 @@ WRITE_LINE_MEMBER(cat_state::cat_duart_txa) * IP4: Centronics BUSY * IP5: DSR */ -READ8_MEMBER(cat_state::cat_duart_input) -{ -#ifdef DEBUG_DUART_INPUT_LINES - fprintf(stderr, "Duart input lines read!\n"); -#endif - return m_duart_inp; -} /* mc68681 DUART Output pins: * OP0: RTS [using the duart builtin hardware-RTS feature?] @@ -1138,7 +1131,6 @@ static MACHINE_CONFIG_START( cat, cat_state ) MCFG_DUARTN68681_ADD( "duartn68681", XTAL_19_968MHz*2/11 ) // duart is normally clocked by 3.6864mhz xtal, but cat seemingly uses a divider from the main xtal instead which probably yields 3.63054545Mhz. There is a trace to cut and a mounting area to allow using an actual 3.6864mhz xtal if you so desire MCFG_DUARTN68681_IRQ_CALLBACK(WRITELINE(cat_state, cat_duart_irq_handler)) MCFG_DUARTN68681_A_TX_CALLBACK(WRITELINE(cat_state, cat_duart_txa)) - MCFG_DUARTN68681_INPORT_CALLBACK(READ8(cat_state, cat_duart_input)) MCFG_DUARTN68681_OUTPORT_CALLBACK(WRITE8(cat_state, cat_duart_output)) MCFG_NVRAM_ADD_0FILL("nvram") diff --git a/src/mess/drivers/esq1.c b/src/mess/drivers/esq1.c index b2be6ea182f..e70ef45827e 100644 --- a/src/mess/drivers/esq1.c +++ b/src/mess/drivers/esq1.c @@ -409,7 +409,6 @@ public: DECLARE_WRITE_LINE_MEMBER(duart_irq_handler); DECLARE_WRITE_LINE_MEMBER(duart_tx_a); DECLARE_WRITE_LINE_MEMBER(duart_tx_b); - DECLARE_READ8_MEMBER(duart_input); DECLARE_WRITE8_MEMBER(duart_output); int m_mapper_state; @@ -537,11 +536,6 @@ WRITE_LINE_MEMBER(esq1_state::duart_irq_handler) m_maincpu->set_input_line(M6809_IRQ_LINE, state); }; -READ8_MEMBER(esq1_state::duart_input) -{ - return 0; -} - WRITE8_MEMBER(esq1_state::duart_output) { int bank = ((data >> 1) & 0x7); @@ -606,7 +600,6 @@ static MACHINE_CONFIG_START( esq1, esq1_state ) MCFG_DUARTN68681_IRQ_CALLBACK(WRITELINE(esq1_state, duart_irq_handler)) MCFG_DUARTN68681_A_TX_CALLBACK(WRITELINE(esq1_state, duart_tx_a)) MCFG_DUARTN68681_B_TX_CALLBACK(WRITELINE(esq1_state, duart_tx_b)) - MCFG_DUARTN68681_INPORT_CALLBACK(READ8(esq1_state, duart_input)) MCFG_DUARTN68681_OUTPORT_CALLBACK(WRITE8(esq1_state, duart_output)) MCFG_ESQPANEL2x40_ADD("panel", esqpanel_config) diff --git a/src/mess/drivers/esq5505.c b/src/mess/drivers/esq5505.c index fa7003f8dd0..7b8e5986419 100644 --- a/src/mess/drivers/esq5505.c +++ b/src/mess/drivers/esq5505.c @@ -196,7 +196,6 @@ public: DECLARE_WRITE_LINE_MEMBER(duart_irq_handler); DECLARE_WRITE_LINE_MEMBER(duart_tx_a); DECLARE_WRITE_LINE_MEMBER(duart_tx_b); - DECLARE_READ8_MEMBER(duart_input); DECLARE_WRITE8_MEMBER(duart_output); int m_system_type; @@ -269,6 +268,9 @@ void esq5505_state::machine_start() void esq5505_state::machine_reset() { + floppy_connector *con = machine().device("wd1772:0"); + floppy_image_device *floppy = con ? con->get_device() : 0; + m_rom = (UINT16 *)(void *)memregion("osrom")->base(); m_ram = (UINT16 *)(void *)memshare("osram")->ptr(); m_maincpu->set_irq_acknowledge_callback(device_irq_acknowledge_delegate(FUNC(esq5505_state::maincpu_irq_acknowledge_callback),this)); @@ -282,6 +284,27 @@ void esq5505_state::machine_reset() m_analog_values[5] = 0xffff; // Volume control: full on. m_analog_values[6] = 0x7fc0; // Battery voltage: something reasonable. m_analog_values[7] = 0x5540; // vRef to check battery. + + // on VFX, bit 0 is 1 for 'cartridge present'. + // on VFX-SD and later, bit 0 is 1 for floppy present, bit 1 is 1 for cartridge present + if (mame_stricmp(machine().system().name, "vfx") == 0) + { + // todo: handle VFX cart-in when we support cartridges + m_duart->ip0_w(ASSERT_LINE); + } + else + { + m_duart->ip1_w(CLEAR_LINE); + + if (floppy) + { + m_duart->ip0_w(ASSERT_LINE); + } + else + { + m_duart->ip0_w(CLEAR_LINE); + } + } } void esq5505_state::update_irq_to_maincpu() { @@ -420,33 +443,6 @@ WRITE_LINE_MEMBER(esq5505_state::duart_irq_handler) update_irq_to_maincpu(); }; -READ8_MEMBER(esq5505_state::duart_input) -{ - floppy_connector *con = machine().device("wd1772:0"); - floppy_image_device *floppy = con ? con->get_device() : 0; - UINT8 result = 0; // DUART input lines are separate from the output lines - - // on VFX, bit 0 is 1 for 'cartridge present'. - // on VFX-SD and later, bit 0 is 1 for floppy present, bit 1 is 1 for cartridge present - if (mame_stricmp(machine().system().name, "vfx") == 0) - { - // todo: handle VFX cart-in when we support cartridges - } - else - { - if (floppy) - { - // ready_r returns true if the drive is *not* ready, false if it is -// if (!floppy->ready_r()) - { - result |= 1; - } - } - } - - return result; -} - WRITE8_MEMBER(esq5505_state::duart_output) { floppy_connector *con = machine().device("wd1772:0"); @@ -655,7 +651,6 @@ static MACHINE_CONFIG_START( vfx, esq5505_state ) MCFG_DUARTN68681_IRQ_CALLBACK(WRITELINE(esq5505_state, duart_irq_handler)) MCFG_DUARTN68681_A_TX_CALLBACK(WRITELINE(esq5505_state, duart_tx_a)) MCFG_DUARTN68681_B_TX_CALLBACK(WRITELINE(esq5505_state, duart_tx_b)) - MCFG_DUARTN68681_INPORT_CALLBACK(READ8(esq5505_state, duart_input)) MCFG_DUARTN68681_OUTPORT_CALLBACK(WRITE8(esq5505_state, duart_output)) MCFG_DUARTN68681_SET_EXTERNAL_CLOCKS(500000, 500000, 1000000, 1000000) @@ -717,7 +712,6 @@ static MACHINE_CONFIG_START(vfx32, esq5505_state) MCFG_DUARTN68681_IRQ_CALLBACK(WRITELINE(esq5505_state, duart_irq_handler)) MCFG_DUARTN68681_A_TX_CALLBACK(WRITELINE(esq5505_state, duart_tx_a)) MCFG_DUARTN68681_B_TX_CALLBACK(WRITELINE(esq5505_state, duart_tx_b)) - MCFG_DUARTN68681_INPORT_CALLBACK(READ8(esq5505_state, duart_input)) MCFG_DUARTN68681_OUTPORT_CALLBACK(WRITE8(esq5505_state, duart_output)) MCFG_DUARTN68681_SET_EXTERNAL_CLOCKS(500000, 500000, 1000000, 1000000) diff --git a/src/mess/drivers/esqkt.c b/src/mess/drivers/esqkt.c index 6bd6060944c..f4bfded1e4c 100644 --- a/src/mess/drivers/esqkt.c +++ b/src/mess/drivers/esqkt.c @@ -56,7 +56,6 @@ public: DECLARE_WRITE_LINE_MEMBER(duart_irq_handler); DECLARE_WRITE_LINE_MEMBER(duart_tx_a); DECLARE_WRITE_LINE_MEMBER(duart_tx_b); - DECLARE_READ8_MEMBER(duart_input); DECLARE_WRITE8_MEMBER(duart_output); UINT8 m_duart_io; @@ -172,13 +171,6 @@ WRITE_LINE_MEMBER(esqkt_state::duart_irq_handler) m_maincpu->set_input_line(M68K_IRQ_3, state); }; -READ8_MEMBER(esqkt_state::duart_input) -{ - UINT8 result = 0; // DUART input lines are separate from the output lines - - return result; -} - WRITE8_MEMBER(esqkt_state::duart_output) { m_duart_io = data; @@ -244,7 +236,6 @@ static MACHINE_CONFIG_START( kt, esqkt_state ) MCFG_DUARTN68681_IRQ_CALLBACK(WRITELINE(esqkt_state, duart_irq_handler)) MCFG_DUARTN68681_A_TX_CALLBACK(WRITELINE(esqkt_state, duart_tx_a)) MCFG_DUARTN68681_B_TX_CALLBACK(WRITELINE(esqkt_state, duart_tx_b)) - MCFG_DUARTN68681_INPORT_CALLBACK(READ8(esqkt_state, duart_input)) MCFG_DUARTN68681_OUTPORT_CALLBACK(WRITE8(esqkt_state, duart_output)) MCFG_DUARTN68681_SET_EXTERNAL_CLOCKS(500000, 500000, 1000000, 1000000) MCFG_DUARTN68681_SET_EXTERNAL_CLOCKS(500000, 500000, 1000000, 1000000) diff --git a/src/mess/drivers/ht68k.c b/src/mess/drivers/ht68k.c index d161fa42064..ebb381cea9f 100644 --- a/src/mess/drivers/ht68k.c +++ b/src/mess/drivers/ht68k.c @@ -58,7 +58,6 @@ public: floppy_image_device *m_floppy; DECLARE_WRITE_LINE_MEMBER(duart_irq_handler); DECLARE_WRITE_LINE_MEMBER(duart_txb); - DECLARE_READ8_MEMBER(duart_input); DECLARE_WRITE8_MEMBER(duart_output); required_shared_ptr m_p_ram; virtual void machine_reset(); @@ -101,11 +100,6 @@ WRITE_LINE_MEMBER(ht68k_state::duart_txb) //This is the second serial channel named AUX, for modem or other serial devices. } -READ8_MEMBER(ht68k_state::duart_input) -{ - return 0; -} - WRITE8_MEMBER(ht68k_state::duart_output) { m_floppy = NULL; @@ -136,7 +130,6 @@ static MACHINE_CONFIG_START( ht68k, ht68k_state ) MCFG_DUARTN68681_IRQ_CALLBACK(WRITELINE(ht68k_state, duart_irq_handler)) MCFG_DUARTN68681_A_TX_CALLBACK(DEVWRITELINE("rs232", rs232_port_device, write_txd)) MCFG_DUARTN68681_B_TX_CALLBACK(WRITELINE(ht68k_state, duart_txb)) - MCFG_DUARTN68681_INPORT_CALLBACK(READ8(ht68k_state, duart_input)) MCFG_DUARTN68681_OUTPORT_CALLBACK(WRITE8(ht68k_state, duart_output)) MCFG_RS232_PORT_ADD("rs232", default_rs232_devices, "serial_terminal")