summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--src/mame/drivers/mephisto.cpp125
1 files 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<m65c02_device> m_maincpu;
+ required_device<hc259_device> m_outlatch;
required_device<beep_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<<offset) ; else m_led_status|=1<<offset;
- if (offset<6)output().set_led_value(LED_offset+offset, m_led_status&1<<offset?1:0);
- if (offset==7) m_led7=data& 0x80 ? 0x00 :0xff;
- logerror("LEDs Offset = %d Data = %d\n",offset,data);
-}
-
-WRITE8_MEMBER( mephisto_state::write_led_mm2 )
-{
- uint8_t LED_offset=100;
- data &= 0x80;
-
- if (data==0)
- m_led_status &= 255-(1<<offset);
- else
- m_led_status|=1<<offset;
-
- if (offset<6)
- output().set_led_value(LED_offset+offset, m_led_status&1<<offset?1:0);
-
- if (offset==7)
- m_led7= BIT(data, 7) ? 0xff :0x00; //MM2
+ m_led7 = state ? 0x00 : 0xff;
}
void mephisto_state::rebel5_mem(address_map &map)
{
map(0x0000, 0x1fff).ram(); // AM_BASE(m_p_ram)
- map(0x2000, 0x2007).w(this, FUNC(mephisto_state::write_led)); // Status LEDs+ buzzer
+ map(0x2000, 0x2007).w("outlatch", FUNC(hc259_device::write_d7)); // Status LEDs+ buzzer
map(0x3000, 0x4000).r("board", FUNC(mephisto_board_device::input_r));
map(0x3000, 0x3007).r(this, FUNC(mephisto_state::read_keys)); // Rebel 5.0
map(0x5000, 0x5000).w(this, FUNC(mephisto_state::write_lcd));
@@ -245,7 +175,7 @@ void mephisto_state::mephisto_mem(address_map &map)
map(0x2800, 0x2800).w("board", FUNC(mephisto_board_device::mux_w));
map(0x2c00, 0x2c07).r(this, FUNC(mephisto_state::read_keys));
map(0x3000, 0x3000).r("board", FUNC(mephisto_board_device::input_r));
- map(0x3400, 0x3407).w(this, FUNC(mephisto_state::write_led)); // Status LEDs+ buzzer
+ map(0x3400, 0x3407).w("outlatch", FUNC(hc259_device::write_d7)); // Status LEDs+ buzzer
map(0x3800, 0x3800).w(this, FUNC(mephisto_state::mephisto_NMI)); // NMI enable
map(0x4000, 0x7fff).rom(); // Opening Library
map(0x8000, 0xffff).rom();
@@ -254,7 +184,7 @@ void mephisto_state::mephisto_mem(address_map &map)
void mephisto_state::mm2_mem(address_map &map)
{
map(0x0000, 0x0fff).ram(); //AM_BASE(m_p_ram)
- map(0x1000, 0x1007).w(this, FUNC(mephisto_state::write_led_mm2)); //Status LEDs
+ map(0x1000, 0x1007).w("outlatch", FUNC(hc259_device::write_d7)); //Status LEDs
map(0x1800, 0x1807).r(this, FUNC(mephisto_state::read_keys));
map(0x2000, 0x2000).r("board", FUNC(mephisto_board_device::input_r));
map(0x2800, 0x2800).w(this, FUNC(mephisto_state::write_lcd));
@@ -311,20 +241,20 @@ TIMER_DEVICE_CALLBACK_MEMBER(mephisto_state::update_nmi)
m_allowNMI = 0;
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_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)