mephisto_montec.cpp: Use addressable latches (nw)

This commit is contained in:
AJR 2020-04-11 23:51:52 -04:00
parent bfa00a7910
commit 622763753c

View File

@ -26,6 +26,7 @@
#include "bus/generic/slot.h"
#include "bus/generic/carts.h"
#include "cpu/m6502/m65c02.h"
#include "machine/74259.h"
#include "machine/nvram.h"
#include "machine/mmboard.h"
#include "sound/dac.h"
@ -48,6 +49,7 @@ public:
: driver_device(mconfig, type, tag)
, m_maincpu(*this, "maincpu")
, m_board(*this, "board")
, m_muxlatch(*this, "muxlatch")
, m_lcd(*this, "lcd%u", 0)
, m_dac(*this, "dac")
, m_keys(*this, "KEY.%u", 0)
@ -56,50 +58,61 @@ public:
, m_high_leds(*this, "led%u", 100U)
{ }
void smondial(machine_config &config);
void smondial2(machine_config &config);
void montec(machine_config &config);
void monteciv(machine_config &config);
void megaiv(machine_config &config);
private:
protected:
uint8_t montec_input_r();
uint8_t montec_nmi_ack_r();
void montec_nmi_ack_w(uint8_t data);
void montec_mux_w(offs_t offset, uint8_t data);
void montec_led_w(uint8_t data);
void montec_beeper_w(uint8_t data);
void montec_lcd_data_w(uint8_t data);
void montec_ldc_cs0_w(uint8_t data);
void montec_ldc_cs1_w(uint8_t data);
void montec_lcd_clk_w(uint8_t data);
template<int N> void montec_lcd_s_w(uint32_t data);
uint8_t megaiv_input_r(offs_t offset);
void megaiv_led_w(uint8_t data);
void smondial_board_mux_w(offs_t offset, uint8_t data);
void smondial_led_data_w(offs_t offset, uint8_t data);
void megaiv_mem(address_map &map);
void montec_mem(address_map &map);
void smondial2_mem(address_map &map);
void smondial_mem(address_map &map);
virtual void machine_start() override;
virtual void machine_reset() override;
required_device<cpu_device> m_maincpu;
required_device<mephisto_board_device> m_board;
required_device<hc259_device> m_muxlatch;
required_device_array<pcf2112_device, 2> m_lcd;
required_device<dac_bit_interface> m_dac;
required_ioport_array<2> m_keys;
output_finder<8> m_digits;
output_finder<16> m_low_leds, m_high_leds;
uint8_t m_input_mux;
uint8_t m_leds_mux;
uint8_t m_smondial_board_mux;
};
class mephisto_smondial_state : public mephisto_montec_state
{
public:
mephisto_smondial_state(const machine_config &mconfig, device_type type, const char *tag)
: mephisto_montec_state(mconfig, type, tag)
, m_ledlatch(*this, "ledlatch")
, m_boardlatch(*this, "boardlatch")
{ }
void smondial(machine_config &config);
private:
template<int N> DECLARE_WRITE_LINE_MEMBER(led_mux_w);
DECLARE_WRITE_LINE_MEMBER(leds_a_w);
DECLARE_WRITE_LINE_MEMBER(leds_b_w);
DECLARE_WRITE_LINE_MEMBER(leds_c_w);
void smondial_mem(address_map &map);
required_device<hc259_device> m_ledlatch;
required_device<hc259_device> m_boardlatch;
};
@ -109,16 +122,12 @@ void mephisto_montec_state::machine_start()
m_low_leds.resolve();
m_high_leds.resolve();
save_item(NAME(m_input_mux));
save_item(NAME(m_leds_mux));
save_item(NAME(m_smondial_board_mux));
}
void mephisto_montec_state::machine_reset()
{
m_input_mux = 0x00;
m_leds_mux = 0x00;
m_smondial_board_mux = 0xff;
}
void mephisto_montec_state::montec_led_w(uint8_t data)
@ -136,41 +145,11 @@ void mephisto_montec_state::montec_lcd_s_w(uint32_t data)
m_digits[i + N*4] = bitswap<8>(data >> (8 * i), 7,4,5,0,1,2,3,6);
}
void mephisto_montec_state::montec_lcd_data_w(uint8_t data)
{
m_lcd[0]->data_w(BIT(data, 7));
m_lcd[1]->data_w(BIT(data, 7));
}
void mephisto_montec_state::montec_ldc_cs0_w(uint8_t data)
{
m_lcd[0]->dlen_w(BIT(data, 7));
}
void mephisto_montec_state::montec_ldc_cs1_w(uint8_t data)
{
m_lcd[1]->dlen_w(BIT(data, 7));
}
void mephisto_montec_state::montec_lcd_clk_w(uint8_t data)
{
m_lcd[0]->clb_w(BIT(data, 7));
m_lcd[1]->clb_w(BIT(data, 7));
}
void mephisto_montec_state::montec_mux_w(offs_t offset, uint8_t data)
{
if (data)
m_input_mux &= ~(1 << offset);
else
m_input_mux |= (1 << offset);
}
uint8_t mephisto_montec_state::montec_input_r()
{
if (m_input_mux & 0x01) return m_keys[1]->read();
else if (m_input_mux & 0x02) return m_keys[0]->read();
if (!m_muxlatch->q0_r()) return m_keys[1]->read();
else if (!m_muxlatch->q1_r()) return m_keys[0]->read();
return m_board->input_r() ^ 0xff;
}
@ -187,11 +166,6 @@ void mephisto_montec_state::montec_nmi_ack_w(uint8_t data)
m_maincpu->set_input_line(INPUT_LINE_NMI, CLEAR_LINE);
}
void mephisto_montec_state::montec_beeper_w(uint8_t data)
{
m_dac->write(BIT(data, 7));
}
void mephisto_montec_state::megaiv_led_w(uint8_t data)
{
if (m_leds_mux != m_board->mux_r())
@ -213,10 +187,10 @@ void mephisto_montec_state::megaiv_led_w(uint8_t data)
uint8_t mephisto_montec_state::megaiv_input_r(offs_t offset)
{
if (m_input_mux & 0x01) return BIT(m_keys[1]->read(), 0 + offset) << 7;
else if (m_input_mux & 0x02) return BIT(m_keys[1]->read(), 4 + offset) << 7;
else if (m_input_mux & 0x04) return BIT(m_keys[0]->read(), 0 + offset) << 7;
else if (m_input_mux & 0x08) return BIT(m_keys[0]->read(), 4 + offset) << 7;
if (!m_muxlatch->q0_r()) return BIT(m_keys[1]->read(), 0 + offset) << 7;
else if (!m_muxlatch->q1_r()) return BIT(m_keys[1]->read(), 4 + offset) << 7;
else if (!m_muxlatch->q2_r()) return BIT(m_keys[0]->read(), 0 + offset) << 7;
else if (!m_muxlatch->q3_r()) return BIT(m_keys[0]->read(), 4 + offset) << 7;
return BIT(m_board->input_r(), offset) << 7;
}
@ -225,17 +199,12 @@ uint8_t mephisto_montec_state::megaiv_input_r(offs_t offset)
void mephisto_montec_state::montec_mem(address_map &map)
{
map(0x0000, 0x1fff).ram().share("nvram");
map(0x2000, 0x2000).rw(FUNC(mephisto_montec_state::montec_nmi_ack_r), FUNC(mephisto_montec_state::montec_nmi_ack_w));
map(0x2400, 0x2400).r(FUNC(mephisto_montec_state::montec_input_r));
map(0x2800, 0x2800).w(m_board, FUNC(mephisto_board_device::mux_w));
map(0x2c00, 0x2c00).w(m_board, FUNC(mephisto_board_device::led_w));
map(0x3000, 0x3007).w(m_muxlatch, FUNC(hc259_device::write_d7));
map(0x3400, 0x3400).w(FUNC(mephisto_montec_state::montec_led_w));
map(0x3000, 0x3001).w(FUNC(mephisto_montec_state::montec_mux_w));
map(0x3002, 0x3002).w(FUNC(mephisto_montec_state::montec_beeper_w));
map(0x3004, 0x3004).w(FUNC(mephisto_montec_state::montec_lcd_data_w));
map(0x3005, 0x3005).w(FUNC(mephisto_montec_state::montec_ldc_cs1_w));
map(0x3006, 0x3006).w(FUNC(mephisto_montec_state::montec_lcd_clk_w));
map(0x3007, 0x3007).w(FUNC(mephisto_montec_state::montec_ldc_cs0_w));
map(0x2000, 0x2000).rw(FUNC(mephisto_montec_state::montec_nmi_ack_r), FUNC(mephisto_montec_state::montec_nmi_ack_w));
map(0x8000, 0xffff).rom();
}
@ -244,11 +213,7 @@ void mephisto_montec_state::megaiv_mem(address_map &map)
map(0x0000, 0x1fff).ram().share("nvram");
map(0x2400, 0x2400).w(FUNC(mephisto_montec_state::megaiv_led_w));
map(0x2800, 0x2800).w(m_board, FUNC(mephisto_board_device::mux_w));
map(0x2c00, 0x2c03).w(FUNC(mephisto_montec_state::montec_mux_w)).nopr();
map(0x2c04, 0x2c04).w(FUNC(mephisto_montec_state::montec_lcd_data_w));
map(0x2c05, 0x2c05).w(FUNC(mephisto_montec_state::montec_ldc_cs1_w));
map(0x2c06, 0x2c06).w(FUNC(mephisto_montec_state::montec_lcd_clk_w));
map(0x2c07, 0x2c07).w(FUNC(mephisto_montec_state::montec_ldc_cs0_w));
map(0x2c00, 0x2c07).w(m_muxlatch, FUNC(hc259_device::write_d7)).nopr();
map(0x3000, 0x3007).r(FUNC(mephisto_montec_state::megaiv_input_r));
map(0x8000, 0xffff).rom();
}
@ -261,44 +226,43 @@ void mephisto_montec_state::smondial2_mem(address_map &map)
}
void mephisto_montec_state::smondial_board_mux_w(offs_t offset, uint8_t data)
template<int N>
WRITE_LINE_MEMBER(mephisto_smondial_state::led_mux_w)
{
if (data)
m_smondial_board_mux &= ~(1 << offset);
else
m_smondial_board_mux |= (1 << offset);
m_board->mux_w(m_smondial_board_mux);
for (int i=0; i<8; i++)
{
if (m_leds_mux & 0x03) m_high_leds[i] = BIT(~m_smondial_board_mux, i);
if (m_leds_mux & 0x0c) m_low_leds[8 + i] = BIT(~m_smondial_board_mux, i);
if (m_leds_mux & 0x30) m_low_leds[0 + i] = BIT(~m_smondial_board_mux, i);
}
uint8_t leds_mux = ~m_ledlatch->output_state();
if (leds_mux & 0x03) m_high_leds[N] = state;
if (leds_mux & 0x0c) m_low_leds[8 + N] = state;
if (leds_mux & 0x30) m_low_leds[0 + N] = state;
}
void mephisto_montec_state::smondial_led_data_w(offs_t offset, uint8_t data)
WRITE_LINE_MEMBER(mephisto_smondial_state::leds_a_w)
{
if (data & 0x80)
m_leds_mux &= ~(1 << offset);
else
m_leds_mux |= (1 << offset);
m_dac->write(BIT(m_leds_mux, 7));
if (!m_ledlatch->q0_r() || !m_ledlatch->q1_r())
for (int i = 0; i < 8; i++)
m_high_leds[i] = BIT(m_boardlatch->output_state(), i);
}
void mephisto_montec_state::smondial_mem(address_map &map)
WRITE_LINE_MEMBER(mephisto_smondial_state::leds_b_w)
{
if (!m_ledlatch->q2_r() || !m_ledlatch->q3_r())
for (int i = 0; i < 8; i++)
m_low_leds[8 + i] = BIT(m_boardlatch->output_state(), i);
}
WRITE_LINE_MEMBER(mephisto_smondial_state::leds_c_w)
{
if (!m_ledlatch->q4_r() || !m_ledlatch->q5_r())
for (int i = 0; i < 8; i++)
m_low_leds[0 + i] = BIT(m_boardlatch->output_state(), i);
}
void mephisto_smondial_state::smondial_mem(address_map &map)
{
map(0x0000, 0x1fff).ram().share("nvram");
map(0x4000, 0x4007).r(FUNC(mephisto_montec_state::megaiv_input_r));
map(0x6400, 0x6407).w(FUNC(mephisto_montec_state::smondial_led_data_w));
map(0x6800, 0x6807).w(FUNC(mephisto_montec_state::smondial_board_mux_w));
map(0x6c00, 0x6c03).w(FUNC(mephisto_montec_state::montec_mux_w));
map(0x6c04, 0x6c04).w(FUNC(mephisto_montec_state::montec_lcd_data_w));
map(0x6c05, 0x6c05).w(FUNC(mephisto_montec_state::montec_ldc_cs1_w));
map(0x6c06, 0x6c06).w(FUNC(mephisto_montec_state::montec_lcd_clk_w));
map(0x6c07, 0x6c07).w(FUNC(mephisto_montec_state::montec_ldc_cs0_w));
map(0x4000, 0x4007).r(FUNC(mephisto_smondial_state::megaiv_input_r));
map(0x6400, 0x6407).w(m_ledlatch, FUNC(hc259_device::write_d7));
map(0x6800, 0x6807).w(m_boardlatch, FUNC(hc259_device::write_d7));
map(0x6c00, 0x6c07).w(m_muxlatch, FUNC(hc259_device::write_d7));
map(0x8000, 0xffff).rom();
}
@ -376,6 +340,15 @@ void mephisto_montec_state::montec(machine_config &config)
NVRAM(config, "nvram", nvram_device::DEFAULT_ALL_0);
HC259(config, m_muxlatch);
m_muxlatch->q_out_cb<2>().set(m_dac, FUNC(dac_bit_interface::write));
m_muxlatch->q_out_cb<4>().set(m_lcd[0], FUNC(pcf2112_device::data_w));
m_muxlatch->q_out_cb<4>().append(m_lcd[1], FUNC(pcf2112_device::data_w));
m_muxlatch->q_out_cb<5>().set(m_lcd[1], FUNC(pcf2112_device::dlen_w));
m_muxlatch->q_out_cb<6>().set(m_lcd[0], FUNC(pcf2112_device::clb_w));
m_muxlatch->q_out_cb<6>().append(m_lcd[1], FUNC(pcf2112_device::clb_w));
m_muxlatch->q_out_cb<7>().set(m_lcd[0], FUNC(pcf2112_device::dlen_w));
PCF2112(config, m_lcd[0], 50); // frequency guessed
m_lcd[0]->write_segs().set(FUNC(mephisto_montec_state::montec_lcd_s_w<0>));
PCF2112(config, m_lcd[1], 50); // "
@ -405,24 +378,48 @@ void mephisto_montec_state::megaiv(machine_config &config)
m_maincpu->set_addrmap(AS_PROGRAM, &mephisto_montec_state::megaiv_mem);
m_maincpu->set_periodic_int(FUNC(mephisto_montec_state::nmi_line_pulse), attotime::from_hz(XTAL(4'915'200) / (1 << 13)));
m_muxlatch->q_out_cb<2>().set_nop();
MEPHISTO_BUTTONS_BOARD(config.replace(), m_board);
m_board->set_delay(attotime::from_msec(250));
m_board->set_disable_leds(true);
config.set_default_layout(layout_mephisto_megaiv);
}
void mephisto_montec_state::smondial(machine_config &config)
void mephisto_smondial_state::smondial(machine_config &config)
{
megaiv(config);
m_maincpu->set_clock(XTAL(4'000'000));
m_maincpu->set_addrmap(AS_PROGRAM, &mephisto_montec_state::smondial_mem);
m_maincpu->set_addrmap(AS_PROGRAM, &mephisto_smondial_state::smondial_mem);
m_maincpu->set_periodic_int(FUNC(mephisto_montec_state::nmi_line_pulse), attotime::from_hz(XTAL(4'000'000) / (1 << 13)));
HC259(config, m_ledlatch);
m_ledlatch->q_out_cb<0>().set(FUNC(mephisto_smondial_state::leds_a_w));
m_ledlatch->q_out_cb<1>().set(FUNC(mephisto_smondial_state::leds_a_w));
m_ledlatch->q_out_cb<2>().set(FUNC(mephisto_smondial_state::leds_b_w));
m_ledlatch->q_out_cb<3>().set(FUNC(mephisto_smondial_state::leds_b_w));
m_ledlatch->q_out_cb<4>().set(FUNC(mephisto_smondial_state::leds_c_w));
m_ledlatch->q_out_cb<5>().set(FUNC(mephisto_smondial_state::leds_c_w));
m_ledlatch->q_out_cb<7>().set(m_dac, FUNC(dac_bit_interface::write));
HC259(config, m_boardlatch);
m_boardlatch->parallel_out_cb().set(m_board, FUNC(mephisto_board_device::mux_w)).invert();
m_boardlatch->q_out_cb<0>().set(FUNC(mephisto_smondial_state::led_mux_w<0>));
m_boardlatch->q_out_cb<1>().set(FUNC(mephisto_smondial_state::led_mux_w<1>));
m_boardlatch->q_out_cb<2>().set(FUNC(mephisto_smondial_state::led_mux_w<2>));
m_boardlatch->q_out_cb<3>().set(FUNC(mephisto_smondial_state::led_mux_w<3>));
m_boardlatch->q_out_cb<4>().set(FUNC(mephisto_smondial_state::led_mux_w<4>));
m_boardlatch->q_out_cb<5>().set(FUNC(mephisto_smondial_state::led_mux_w<5>));
m_boardlatch->q_out_cb<6>().set(FUNC(mephisto_smondial_state::led_mux_w<6>));
m_boardlatch->q_out_cb<7>().set(FUNC(mephisto_smondial_state::led_mux_w<7>));
}
void mephisto_montec_state::smondial2(machine_config &config)
{
smondial(config);
megaiv(config);
m_maincpu->set_clock(XTAL(4'000'000));
m_maincpu->set_addrmap(AS_PROGRAM, &mephisto_montec_state::smondial2_mem);
m_maincpu->set_periodic_int(FUNC(mephisto_montec_state::nmi_line_pulse), attotime::from_hz(XTAL(4'000'000) / (1 << 13)));
GENERIC_CARTSLOT(config, "cartslot", generic_plain_slot, "smondial2_cart");
SOFTWARE_LIST(config, "cart_list").set_original("mephisto_smondial2");
@ -481,10 +478,10 @@ ROM_END
CONS( 1988, megaiv, 0, 0, megaiv, megaiv, mephisto_montec_state, empty_init, "Hegener + Glaser", "Mephisto Mega IV (set 1)", MACHINE_SUPPORTS_SAVE | MACHINE_CLICKABLE_ARTWORK )
CONS( 1988, megaiva, megaiv, 0, megaiv, megaiv, mephisto_montec_state, empty_init, "Hegener + Glaser", "Mephisto Mega IV (set 2)", MACHINE_SUPPORTS_SAVE | MACHINE_CLICKABLE_ARTWORK )
CONS( 1986, smondial, 0, 0, smondial, megaiv, mephisto_montec_state, empty_init, "Hegener + Glaser", "Mephisto Super Mondial (ver. A)", MACHINE_SUPPORTS_SAVE | MACHINE_CLICKABLE_ARTWORK )
CONS( 1986, smondialab, smondial, 0, smondial, megaiv, mephisto_montec_state, empty_init, "Hegener + Glaser", "Mephisto Super Mondial (ver. AB)", MACHINE_SUPPORTS_SAVE | MACHINE_CLICKABLE_ARTWORK )
CONS( 1986, smondialb, smondial, 0, megaiv, megaiv, mephisto_montec_state, empty_init, "Hegener + Glaser", "Mephisto Super Mondial (ver. B)", MACHINE_SUPPORTS_SAVE | MACHINE_CLICKABLE_ARTWORK )
CONS( 1988, smondial2, 0, 0, smondial2, smondial2, mephisto_montec_state, empty_init, "Hegener + Glaser", "Mephisto Super Mondial II", MACHINE_SUPPORTS_SAVE | MACHINE_CLICKABLE_ARTWORK )
CONS( 1986, smondial, 0, 0, smondial, megaiv, mephisto_smondial_state, empty_init, "Hegener + Glaser", "Mephisto Super Mondial (ver. A)", MACHINE_SUPPORTS_SAVE | MACHINE_CLICKABLE_ARTWORK )
CONS( 1986, smondialab, smondial, 0, smondial, megaiv, mephisto_smondial_state, empty_init, "Hegener + Glaser", "Mephisto Super Mondial (ver. AB)", MACHINE_SUPPORTS_SAVE | MACHINE_CLICKABLE_ARTWORK )
CONS( 1986, smondialb, smondial, 0, megaiv, megaiv, mephisto_montec_state, empty_init, "Hegener + Glaser", "Mephisto Super Mondial (ver. B)", MACHINE_SUPPORTS_SAVE | MACHINE_CLICKABLE_ARTWORK )
CONS( 1988, smondial2, 0, 0, smondial2, smondial2, mephisto_montec_state, empty_init, "Hegener + Glaser", "Mephisto Super Mondial II", MACHINE_SUPPORTS_SAVE | MACHINE_CLICKABLE_ARTWORK )
CONS( 1987, montec, 0, 0, montec, montec, mephisto_montec_state, empty_init, "Hegener + Glaser", "Mephisto Monte Carlo (ver. MC3)", MACHINE_SUPPORTS_SAVE | MACHINE_CLICKABLE_ARTWORK )
CONS( 1987, monteca, montec, 0, montec, montec, mephisto_montec_state, empty_init, "Hegener + Glaser", "Mephisto Monte Carlo (ver. MC2)", MACHINE_SUPPORTS_SAVE | MACHINE_CLICKABLE_ARTWORK )