From 693c94f028c9c51c8b72765af0341c6d218f721c Mon Sep 17 00:00:00 2001 From: AJR Date: Mon, 23 Jul 2018 09:47:18 -0400 Subject: modena: Split to separate driver file; slight code cleanup (nw) --- scripts/target/mame/mess.lua | 1 + src/mame/drivers/modena.cpp | 175 +++++++++++++++++++++++++++++++++++++++++++ src/mame/drivers/polgar.cpp | 154 +------------------------------------ src/mame/mame.lst | 4 +- src/mame/mess.flt | 1 + 5 files changed, 181 insertions(+), 154 deletions(-) create mode 100644 src/mame/drivers/modena.cpp diff --git a/scripts/target/mame/mess.lua b/scripts/target/mame/mess.lua index 71aa52b0e9f..8c24fcadf41 100644 --- a/scripts/target/mame/mess.lua +++ b/scripts/target/mame/mess.lua @@ -2163,6 +2163,7 @@ files { MAME_DIR .. "src/mame/drivers/mephisto.cpp", MAME_DIR .. "src/mame/drivers/mephisto_montec.cpp", MAME_DIR .. "src/mame/drivers/mmodular.cpp", + MAME_DIR .. "src/mame/drivers/modena.cpp", MAME_DIR .. "src/mame/drivers/polgar.cpp", MAME_DIR .. "src/mame/drivers/risc2500.cpp", MAME_DIR .. "src/mame/drivers/stratos.cpp", diff --git a/src/mame/drivers/modena.cpp b/src/mame/drivers/modena.cpp new file mode 100644 index 00000000000..d0336b61ed2 --- /dev/null +++ b/src/mame/drivers/modena.cpp @@ -0,0 +1,175 @@ +// license:BSD-3-Clause +// copyright-holders:Sandro Ronco +/************************************************************************************************** + + Mephisto Modena + +**************************************************************************************************/ + + +#include "emu.h" +#include "cpu/m6502/m65c02.h" +#include "machine/nvram.h" +#include "machine/mmboard.h" +#include "machine/timer.h" +#include "speaker.h" + +#include "mephisto_modena.lh" + + +class mephisto_modena_state : public driver_device +{ +public: + mephisto_modena_state(const machine_config &mconfig, device_type type, const char *tag) + : driver_device(mconfig, type, tag) + , m_maincpu(*this, "maincpu") + , m_board(*this, "board") + , m_beeper(*this, "beeper") + , m_keys(*this, "KEY") + , m_digits(*this, "digit%u", 0U) + , m_leds1(*this, "led%u", 100U) + , m_leds2(*this, "led%u", 0U) + , m_leds3(*this, "led%u", 8U) + { } + + DECLARE_READ8_MEMBER(modena_input_r); + DECLARE_WRITE8_MEMBER(modena_digits_w); + DECLARE_WRITE8_MEMBER(modena_io_w); + DECLARE_WRITE8_MEMBER(modena_led_w); + TIMER_DEVICE_CALLBACK_MEMBER(nmi_on) { m_maincpu->set_input_line(M6502_NMI_LINE, ASSERT_LINE); } + TIMER_DEVICE_CALLBACK_MEMBER(nmi_off) { m_maincpu->set_input_line(M6502_NMI_LINE, CLEAR_LINE); } + + void modena(machine_config &config); + void modena_mem(address_map &map); +protected: + virtual void machine_reset() override; + virtual void machine_start() override; + +private: + required_device m_maincpu; + required_device m_board; + required_device m_beeper; + required_ioport m_keys; + output_finder<4> m_digits; + output_finder<8> m_leds1; + output_finder<8> m_leds2; + output_finder<8> m_leds3; + uint8_t m_digits_idx; + uint8_t m_io_ctrl; +}; + + +READ8_MEMBER(mephisto_modena_state::modena_input_r) +{ + if (m_board->mux_r(space, offset) == 0xff) + return m_keys->read(); + else + return m_board->input_r(space, offset) ^ 0xff; +} + +WRITE8_MEMBER(mephisto_modena_state::modena_led_w) +{ + m_board->mux_w(space, offset, data); + + if (m_io_ctrl & 0x0e) + { + for(int i=0; i<8; i++) + { + if (BIT(m_io_ctrl, 1)) + m_leds1[i] = BIT(data, i) ? 0 : 1; + if (BIT(m_io_ctrl, 2)) + m_leds2[i] = BIT(data, i) ? 0 : 1; + if (BIT(m_io_ctrl, 3)) + m_leds3[i] = BIT(data, i) ? 0 : 1; + } + } +} + +WRITE8_MEMBER(mephisto_modena_state::modena_io_w) +{ + m_io_ctrl = data; + m_beeper->set_state(BIT(data, 6)); +} + +WRITE8_MEMBER(mephisto_modena_state::modena_digits_w) +{ + m_digits[m_digits_idx] = data ^ ((m_io_ctrl & 0x10) ? 0xff : 0x00); + m_digits_idx = (m_digits_idx + 1) & 3; +} + +void mephisto_modena_state::modena_mem(address_map &map) +{ + map(0x0000, 0x1fff).ram().share("nvram"); + map(0x4000, 0x4000).w(FUNC(mephisto_modena_state::modena_digits_w)); + map(0x5000, 0x5000).w(FUNC(mephisto_modena_state::modena_led_w)); + map(0x6000, 0x6000).w(FUNC(mephisto_modena_state::modena_io_w)); + map(0x7000, 0x7fff).r(FUNC(mephisto_modena_state::modena_input_r)); + map(0x8000, 0xffff).rom().region("maincpu", 0); +} + + +static INPUT_PORTS_START( modena ) + PORT_START("KEY") + PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_NAME("BOOK") PORT_CODE(KEYCODE_B) + PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_NAME("INFO") PORT_CODE(KEYCODE_I) + PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_NAME("MEMORY") PORT_CODE(KEYCODE_M) + PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_NAME("POSITION") PORT_CODE(KEYCODE_O) + PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_NAME("LEVEL") PORT_CODE(KEYCODE_L) + PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_NAME("FUNCTION") PORT_CODE(KEYCODE_F) + PORT_BIT(0x40, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_NAME("ENTER") PORT_CODE(KEYCODE_ENTER) + PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_NAME("CLEAR") PORT_CODE(KEYCODE_BACKSPACE) +INPUT_PORTS_END + + +void mephisto_modena_state::machine_start() +{ + m_digits.resolve(); + m_leds1.resolve(); + m_leds2.resolve(); + m_leds3.resolve(); + save_item(NAME(m_digits_idx)); + save_item(NAME(m_io_ctrl)); +} + +void mephisto_modena_state::machine_reset() +{ + m_digits_idx = 0; + m_io_ctrl = 0; +} + + +MACHINE_CONFIG_START(mephisto_modena_state::modena) + MCFG_DEVICE_ADD("maincpu", M65C02, XTAL(4'194'304)) // W65C02SP + MCFG_DEVICE_PROGRAM_MAP(modena_mem) + MCFG_TIMER_DRIVER_ADD_PERIODIC("nmi_on", mephisto_modena_state, nmi_on, attotime::from_hz(XTAL(4'194'304) / (1 << 13))) + MCFG_TIMER_START_DELAY(attotime::from_hz(XTAL(4'194'304) / (1 << 13)) - attotime::from_usec(975)) // active for 975us + MCFG_TIMER_DRIVER_ADD_PERIODIC("nmi_off", mephisto_modena_state, nmi_off, attotime::from_hz(XTAL(4'194'304) / (1 << 13))) + + MCFG_NVRAM_ADD_0FILL("nvram") + + MCFG_MEPHISTO_BUTTONS_BOARD_ADD("board") + MCFG_MEPHISTO_BOARD_DISABLE_LEDS(true) + config.set_default_layout(layout_mephisto_modena); + + /* sound hardware */ + SPEAKER(config, "mono").front_center(); + MCFG_DEVICE_ADD("beeper", BEEP, 3250) + MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) +MACHINE_CONFIG_END + + +ROM_START(modena) + ROM_REGION(0x8000, "maincpu", 0) + ROM_SYSTEM_BIOS( 0, "v1", "v1" ) + ROMX_LOAD("modena 12aug1992.bin", 0x0000, 0x8000, CRC(dd7b4920) SHA1(4606b9d1f8a30180aabedfc0ed3cca0c96618524), ROM_BIOS(0)) + ROM_SYSTEM_BIOS( 1, "v1alt", "v1alt" ) + ROMX_LOAD("27c256,457f.bin", 0x0000, 0x8000, CRC(2889082c) SHA1(b63f0d856793b4f87471837e2219ce2a42fe18de), ROM_BIOS(1)) +ROM_END + + +/*************************************************************************** + Game driver(s) +***************************************************************************/ + +/* YEAR NAME PARENT COMPAT MACHINE INPUT CLASS INIT COMPANY FULLNAME FLAGS */ +CONS( 1992, modena, 0, 0, modena, modena, mephisto_modena_state, empty_init, "Hegener & Glaser", "Mephisto Modena", MACHINE_SUPPORTS_SAVE | MACHINE_CLICKABLE_ARTWORK ) diff --git a/src/mame/drivers/polgar.cpp b/src/mame/drivers/polgar.cpp index d89775b73f6..3874f3a056a 100644 --- a/src/mame/drivers/polgar.cpp +++ b/src/mame/drivers/polgar.cpp @@ -14,15 +14,12 @@ #include "machine/nvram.h" #include "machine/mmboard.h" #include "machine/ram.h" -#include "machine/timer.h" #include "video/hd44780.h" -#include "screen.h" #include "speaker.h" #include "mephisto_lcd.lh" #include "mephisto_academy.lh" #include "mephisto_milano.lh" -#include "mephisto_modena.lh" class mephisto_polgar_state : public driver_device @@ -31,7 +28,6 @@ public: mephisto_polgar_state(const machine_config &mconfig, device_type type, const char *tag) : driver_device(mconfig, type, tag) , m_keys(*this, "KEY") - , m_digits(*this, "digit%u", 0U) { } DECLARE_READ8_MEMBER(polgar_keys_r); @@ -39,10 +35,8 @@ public: void polgar10(machine_config &config); void polgar(machine_config &config); void polgar_mem(address_map &map); - virtual void sound_start() override { m_digits.resolve(); } protected: - optional_ioport m_keys; - output_finder<4> m_digits; + required_ioport m_keys; }; class mephisto_risc_state : public mephisto_polgar_state @@ -107,43 +101,6 @@ private: uint8_t m_led_latch; }; -class mephisto_modena_state : public mephisto_polgar_state -{ -public: - mephisto_modena_state(const machine_config &mconfig, device_type type, const char *tag) - : mephisto_polgar_state(mconfig, type, tag) - , m_maincpu(*this, "maincpu") - , m_board(*this, "board") - , m_beeper(*this, "beeper") - , m_leds1(*this, "led%u", 100U) - , m_leds2(*this, "led%u", 0U) - , m_leds3(*this, "led%u", 8U) - { } - - DECLARE_READ8_MEMBER(modena_input_r); - DECLARE_WRITE8_MEMBER(modena_digits_w); - DECLARE_WRITE8_MEMBER(modena_io_w); - DECLARE_WRITE8_MEMBER(modena_led_w); - TIMER_DEVICE_CALLBACK_MEMBER(nmi_on) { m_maincpu->set_input_line(M6502_NMI_LINE, ASSERT_LINE); } - TIMER_DEVICE_CALLBACK_MEMBER(nmi_off) { m_maincpu->set_input_line(M6502_NMI_LINE, CLEAR_LINE); } - - void modena(machine_config &config); - void modena_mem(address_map &map); -protected: - virtual void machine_reset() override; - virtual void machine_start() override; - -private: - required_device m_maincpu; - required_device m_board; - required_device m_beeper; - output_finder<8> m_leds1; - output_finder<8> m_leds2; - output_finder<8> m_leds3; - uint8_t m_digits_idx; - uint8_t m_io_ctrl; -}; - class mephisto_academy_state : public mephisto_polgar_state { public: @@ -301,55 +258,6 @@ void mephisto_milano_state::milano_mem(address_map &map) } -READ8_MEMBER(mephisto_modena_state::modena_input_r) -{ - if (m_board->mux_r(space, offset) == 0xff) - return m_keys->read(); - else - return m_board->input_r(space, offset) ^ 0xff; -} - -WRITE8_MEMBER(mephisto_modena_state::modena_led_w) -{ - m_board->mux_w(space, offset, data); - - if (m_io_ctrl & 0x0e) - { - for(int i=0; i<8; i++) - { - if (BIT(m_io_ctrl, 1)) - m_leds1[i] = BIT(data, i) ? 0 : 1; - if (BIT(m_io_ctrl, 2)) - m_leds2[i] = BIT(data, i) ? 0 : 1; - if (BIT(m_io_ctrl, 3)) - m_leds3[i] = BIT(data, i) ? 0 : 1; - } - } -} - -WRITE8_MEMBER(mephisto_modena_state::modena_io_w) -{ - m_io_ctrl = data; - m_beeper->set_state(BIT(data, 6)); -} - -WRITE8_MEMBER(mephisto_modena_state::modena_digits_w) -{ - m_digits[m_digits_idx] = data ^ ((m_io_ctrl & 0x10) ? 0xff : 0x00); - m_digits_idx = (m_digits_idx + 1) & 3; -} - -void mephisto_modena_state::modena_mem(address_map &map) -{ - map(0x0000, 0x1fff).ram().share("nvram"); - map(0x4000, 0x4000).w(FUNC(mephisto_modena_state::modena_digits_w)); - map(0x5000, 0x5000).w(FUNC(mephisto_modena_state::modena_led_w)); - map(0x6000, 0x6000).w(FUNC(mephisto_modena_state::modena_io_w)); - map(0x7000, 0x7fff).r(FUNC(mephisto_modena_state::modena_input_r)); - map(0x8000, 0xffff).rom(); -} - - INTERRUPT_GEN_MEMBER(mephisto_academy_state::academy_irq) { if (m_enable_nmi) @@ -406,18 +314,6 @@ static INPUT_PORTS_START( polgar ) PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYPAD) PORT_NAME("CL") PORT_CODE(KEYCODE_BACKSPACE) INPUT_PORTS_END -static INPUT_PORTS_START( modena ) - PORT_START("KEY") - PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_NAME("BOOK") PORT_CODE(KEYCODE_B) - PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_NAME("INFO") PORT_CODE(KEYCODE_I) - PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_NAME("MEMORY") PORT_CODE(KEYCODE_M) - PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_NAME("POSITION") PORT_CODE(KEYCODE_O) - PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_NAME("LEVEL") PORT_CODE(KEYCODE_L) - PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_NAME("FUNCTION") PORT_CODE(KEYCODE_F) - PORT_BIT(0x40, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_NAME("ENTER") PORT_CODE(KEYCODE_ENTER) - PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_NAME("CLEAR") PORT_CODE(KEYCODE_BACKSPACE) -INPUT_PORTS_END - void mephisto_risc_state::machine_start() { m_disable_boot_rom_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(mephisto_risc_state::disable_boot_rom), this)); @@ -451,26 +347,11 @@ void mephisto_milano_state::machine_reset() m_led_latch = 0; } -void mephisto_modena_state::machine_start() -{ - m_leds1.resolve(); - m_leds2.resolve(); - m_leds3.resolve(); - save_item(NAME(m_digits_idx)); - save_item(NAME(m_io_ctrl)); -} - void mephisto_academy_state::machine_start() { m_leds.resolve(); } -void mephisto_modena_state::machine_reset() -{ - m_digits_idx = 0; - m_io_ctrl = 0; -} - void mephisto_academy_state::machine_reset() { m_enable_nmi = true; @@ -555,30 +436,6 @@ MACHINE_CONFIG_START(mephisto_academy_state::academy) config.set_default_layout(layout_mephisto_academy); MACHINE_CONFIG_END -MACHINE_CONFIG_START(mephisto_modena_state::modena) - polgar(config); - MCFG_DEVICE_MODIFY("maincpu") // W65C02SP - MCFG_DEVICE_CLOCK(XTAL(4'194'304)) - MCFG_DEVICE_PROGRAM_MAP(modena_mem) - MCFG_DEVICE_PERIODIC_INT_REMOVE() - MCFG_TIMER_DRIVER_ADD_PERIODIC("nmi_on", mephisto_modena_state, nmi_on, attotime::from_hz(XTAL(4'194'304) / (1 << 13))) - MCFG_TIMER_START_DELAY(attotime::from_hz(XTAL(4'194'304) / (1 << 13)) - attotime::from_usec(975)) // active for 975us - MCFG_TIMER_DRIVER_ADD_PERIODIC("nmi_off", mephisto_modena_state, nmi_off, attotime::from_hz(XTAL(4'194'304) / (1 << 13))) - - MCFG_DEVICE_REMOVE("board") - MCFG_DEVICE_REMOVE("display") - MCFG_MEPHISTO_BUTTONS_BOARD_ADD("board") - MCFG_MEPHISTO_BOARD_DISABLE_LEDS(true) - config.set_default_layout(layout_mephisto_modena); - - MCFG_DEVICE_REMOVE("outlatch") - - /* sound hardware */ - SPEAKER(config, "mono").front_center(); - MCFG_DEVICE_ADD("beeper", BEEP, 3250) - MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) -MACHINE_CONFIG_END - ROM_START(polgar) ROM_REGION(0x10000, "maincpu", 0) @@ -641,14 +498,6 @@ ROM_START(nshort) ROM_LOAD("nshort.bin", 0x00000, 0x10000, CRC(4bd51e23) SHA1(3f55cc1c55dae8818b7e9384b6b8d43dc4f0a1af)) ROM_END -ROM_START(modena) - ROM_REGION(0x10000, "maincpu", 0) - ROM_SYSTEM_BIOS( 0, "v1", "v1" ) - ROMX_LOAD("modena 12aug1992.bin", 0x8000, 0x8000, CRC(dd7b4920) SHA1(4606b9d1f8a30180aabedfc0ed3cca0c96618524), ROM_BIOS(0)) - ROM_SYSTEM_BIOS( 1, "v1alt", "v1alt" ) - ROMX_LOAD("27c256,457f.bin", 0x8000, 0x8000, CRC(2889082c) SHA1(b63f0d856793b4f87471837e2219ce2a42fe18de), ROM_BIOS(1)) -ROM_END - /*************************************************************************** Game driver(s) @@ -664,4 +513,3 @@ CONS( 1994, mrisc2, mrisc, 0, mrisc, polgar, mephisto_risc_state, CONS( 1989, academy, 0, 0, academy, polgar, mephisto_academy_state, empty_init, "Hegener & Glaser", "Mephisto Academy", MACHINE_SUPPORTS_SAVE | MACHINE_CLICKABLE_ARTWORK ) CONS( 1991, milano, 0, 0, milano, polgar, mephisto_milano_state, empty_init, "Hegener & Glaser", "Mephisto Milano", MACHINE_SUPPORTS_SAVE | MACHINE_CLICKABLE_ARTWORK ) CONS( 1993, nshort, milano, 0, milano, polgar, mephisto_milano_state, empty_init, "Hegener & Glaser", "Mephisto Nigel Short", MACHINE_SUPPORTS_SAVE | MACHINE_CLICKABLE_ARTWORK ) -CONS( 1992, modena, 0, 0, modena, modena, mephisto_modena_state, empty_init, "Hegener & Glaser", "Mephisto Modena", MACHINE_SUPPORTS_SAVE | MACHINE_CLICKABLE_ARTWORK ) diff --git a/src/mame/mame.lst b/src/mame/mame.lst index afe6e4c2a09..162b81b607d 100644 --- a/src/mame/mame.lst +++ b/src/mame/mame.lst @@ -21591,6 +21591,9 @@ vs2v991 // 1999.?? Virtual Striker 2 ver.99.1 @source:modellot.cpp modellot // +@source:modena.cpp +modena // 1992 Mephisto Modena + @source:mogura.cpp mogura // GX141 (c) 1991 @@ -32186,7 +32189,6 @@ mrisc // 1992 Mephisto RISC 1MB mrisc2 // 1994 Mephisto RISC II academy // 1989 Mephisto Academy milano // 1991 Mephisto Milano -modena // 1992 Mephisto Modena nshort // 1993 Mephisto Nigel Short @source:policetr.cpp diff --git a/src/mame/mess.flt b/src/mame/mess.flt index 5a83f1f3e76..f022750873e 100644 --- a/src/mame/mess.flt +++ b/src/mame/mess.flt @@ -423,6 +423,7 @@ mmd1.cpp mmodular.cpp mod8.cpp modellot.cpp +modena.cpp molecular.cpp monty.cpp mpf1.cpp -- cgit v1.2.3