From bbf7833bf5eb244fa6fb6d2ec1d0cc64d5bad6b5 Mon Sep 17 00:00:00 2001 From: AJR Date: Sun, 29 Apr 2018 22:43:48 -0400 Subject: [PATCH] mephisto.cpp: Use addressable latch for LEDs and ioport_array for inputs (nw) --- src/mame/drivers/mephisto.cpp | 125 +++++++++------------------------- 1 file changed, 32 insertions(+), 93 deletions(-) diff --git a/src/mame/drivers/mephisto.cpp b/src/mame/drivers/mephisto.cpp index 981c3612456..53f8e5e3027 100644 --- a/src/mame/drivers/mephisto.cpp +++ b/src/mame/drivers/mephisto.cpp @@ -64,6 +64,7 @@ Mephisto 4 Turbo Kit 18mhz - (mm4tk) #include "emu.h" #include "cpu/m6502/m65c02.h" +#include "machine/74259.h" #include "machine/mmboard.h" #include "machine/timer.h" #include "sound/beep.h" @@ -77,35 +78,21 @@ public: mephisto_state(const machine_config &mconfig, device_type type, const char *tag) : driver_device(mconfig, type, tag) , m_maincpu(*this, "maincpu") + , m_outlatch(*this, "outlatch") , m_beep(*this, "beeper") - , m_key1_0(*this, "KEY1_0") - , m_key1_1(*this, "KEY1_1") - , m_key1_2(*this, "KEY1_2") - , m_key1_3(*this, "KEY1_3") - , m_key1_4(*this, "KEY1_4") - , m_key1_5(*this, "KEY1_5") - , m_key1_6(*this, "KEY1_6") - , m_key1_7(*this, "KEY1_7") - , m_key2_0(*this, "KEY2_0") - , m_key2_1(*this, "KEY2_1") - , m_key2_2(*this, "KEY2_2") - , m_key2_3(*this, "KEY2_3") - , m_key2_4(*this, "KEY2_4") - , m_key2_5(*this, "KEY2_5") - , m_key2_6(*this, "KEY2_6") - , m_key2_7(*this, "KEY2_7") + , m_key1(*this, "KEY1_%u", 0U) + , m_key2(*this, "KEY2_%u", 0U) , m_digits(*this, "digit%u", 0U) { } required_device m_maincpu; + required_device m_outlatch; required_device m_beep; DECLARE_WRITE8_MEMBER(write_lcd); DECLARE_WRITE8_MEMBER(mephisto_NMI); DECLARE_READ8_MEMBER(read_keys); - DECLARE_WRITE8_MEMBER(write_led); - DECLARE_WRITE8_MEMBER(write_led_mm2); + DECLARE_WRITE_LINE_MEMBER(write_led7); uint8_t m_lcd_shift_counter; - uint8_t m_led_status; //uint8_t *m_p_ram; uint8_t m_led7; uint8_t m_allowNMI; @@ -125,27 +112,13 @@ public: void mm2_mem(address_map &map); void rebel5_mem(address_map &map); protected: - required_ioport m_key1_0; - required_ioport m_key1_1; - required_ioport m_key1_2; - required_ioport m_key1_3; - required_ioport m_key1_4; - required_ioport m_key1_5; - required_ioport m_key1_6; - required_ioport m_key1_7; - required_ioport m_key2_0; - required_ioport m_key2_1; - required_ioport m_key2_2; - required_ioport m_key2_3; - required_ioport m_key2_4; - required_ioport m_key2_5; - required_ioport m_key2_6; - required_ioport m_key2_7; + required_ioport_array<8> m_key1; + required_ioport_array<8> m_key2; output_finder<4> m_digits; }; -WRITE8_MEMBER( mephisto_state::write_lcd ) +WRITE8_MEMBER(mephisto_state::write_lcd) { if (m_led7 == 0) m_digits[m_lcd_shift_counter] = data; // 0x109 MM IV // 0x040 MM V @@ -154,80 +127,37 @@ WRITE8_MEMBER( mephisto_state::write_lcd ) m_lcd_shift_counter &= 3; } -WRITE8_MEMBER( mephisto_state::mephisto_NMI ) +WRITE8_MEMBER(mephisto_state::mephisto_NMI) { m_allowNMI = 1; } -READ8_MEMBER( mephisto_state::read_keys ) +READ8_MEMBER(mephisto_state::read_keys) { uint8_t data = 0; - if (((m_led_status & 0x80) == 0x00)) + if (!m_outlatch->q7_r()) { - switch ( offset ) - { - case 0: data = m_key1_0->read(); break; - case 1: data = m_key1_1->read(); break; - case 2: data = m_key1_2->read(); break; - case 3: data = m_key1_3->read(); break; - case 4: data = m_key1_4->read(); break; - case 5: data = m_key1_5->read(); break; - case 6: data = m_key1_6->read(); break; - case 7: data = m_key1_7->read(); break; - } + data = m_key1[offset]->read(); } else { - switch ( offset ) - { - case 0: data = m_key2_0->read(); break; - case 1: data = m_key2_1->read(); break; - case 2: data = m_key2_2->read(); break; - case 3: data = m_key2_3->read(); break; - case 4: data = m_key2_4->read(); break; - case 5: data = m_key2_5->read(); break; - case 6: data = m_key2_6->read(); break; - case 7: data = m_key2_7->read(); break; - } + data = m_key2[offset]->read(); } - logerror("Keyboard Port = %d-%d Data = %d\n ", ((m_led_status & 0x80) == 0x00) ? 0 : 1, offset, data); + logerror("Keyboard Port = %d-%d Data = %d\n ", !m_outlatch->q7_r() ? 0 : 1, offset, data); return data | 0x7f; } -WRITE8_MEMBER( mephisto_state::write_led ) +WRITE_LINE_MEMBER(mephisto_state::write_led7) { - uint8_t LED_offset=100; - data &= 0x80; - - if (data==0)m_led_status &= 255-(1<set_input_line(INPUT_LINE_NMI,PULSE_LINE); } - m_beep->set_state(m_led_status&64?1:0); + m_beep->set_state(m_outlatch->q6_r() ? 1 : 0); } TIMER_DEVICE_CALLBACK_MEMBER(mephisto_state::update_nmi_r5) { m_maincpu->set_input_line(INPUT_LINE_NMI,PULSE_LINE); - m_beep->set_state(m_led_status&64?1:0); + m_beep->set_state(m_outlatch->q6_r() ? 1 : 0); } TIMER_DEVICE_CALLBACK_MEMBER(mephisto_state::update_irq)//only mm2 { m_maincpu->set_input_line(M65C02_IRQ_LINE, HOLD_LINE); - m_beep->set_state(m_led_status&64?1:0); + m_beep->set_state(m_outlatch->q6_r() ? 1 : 0); } void mephisto_state::machine_start() @@ -372,6 +302,15 @@ MACHINE_CONFIG_START(mephisto_state::mephisto) MCFG_CPU_PROGRAM_MAP(mephisto_mem) MCFG_QUANTUM_TIME(attotime::from_hz(60)) + MCFG_DEVICE_ADD("outlatch", HC259, 0) + MCFG_ADDRESSABLE_LATCH_Q0_OUT_CB(OUTPUT("led100")) + MCFG_ADDRESSABLE_LATCH_Q1_OUT_CB(OUTPUT("led101")) + MCFG_ADDRESSABLE_LATCH_Q2_OUT_CB(OUTPUT("led102")) + MCFG_ADDRESSABLE_LATCH_Q3_OUT_CB(OUTPUT("led103")) + MCFG_ADDRESSABLE_LATCH_Q4_OUT_CB(OUTPUT("led104")) + MCFG_ADDRESSABLE_LATCH_Q5_OUT_CB(OUTPUT("led105")) + MCFG_ADDRESSABLE_LATCH_Q7_OUT_CB(WRITELINE(mephisto_state, write_led7)) + /* sound hardware */ MCFG_SPEAKER_STANDARD_MONO("mono") MCFG_SOUND_ADD("beeper", BEEP, 3250)