diff options
Diffstat (limited to 'src/mame/machine/mmboard.cpp')
-rw-r--r-- | src/mame/machine/mmboard.cpp | 210 |
1 files changed, 50 insertions, 160 deletions
diff --git a/src/mame/machine/mmboard.cpp b/src/mame/machine/mmboard.cpp index e40c9e45514..489853a6c80 100644 --- a/src/mame/machine/mmboard.cpp +++ b/src/mame/machine/mmboard.cpp @@ -2,145 +2,114 @@ // copyright-holders:Sandro Ronco /********************************************************************** - Mephisto Sensors Board emulation - Mephisto Display Modul emulation +Hegener + Glaser Mephisto Sensors Board, for modular chesscomputers +- Modular +- Muenchen +- Exclusive + +This device can also apply to non-modular boards if I/O is similar +Bavaria board is not emulated here, additional handlers for it are in the driver. *********************************************************************/ #include "emu.h" #include "mmboard.h" -#include "sound/volt_reg.h" - -//************************************************************************** -// DEVICE DEFINITIONS -//************************************************************************** DEFINE_DEVICE_TYPE(MEPHISTO_SENSORS_BOARD, mephisto_sensors_board_device, "msboard", "Mephisto Sensors Board") DEFINE_DEVICE_TYPE(MEPHISTO_BUTTONS_BOARD, mephisto_buttons_board_device, "mbboard", "Mephisto Buttons Board") -DEFINE_DEVICE_TYPE(MEPHISTO_DISPLAY_MODUL, mephisto_display_modul_device, "mdisplay_modul", "Mephisto Display Modul") - - -//*************************************************************************** -// IMPLEMENTATION -//*************************************************************************** //------------------------------------------------- -// device_add_mconfig - add device-specific -// machine configuration +// constructor //------------------------------------------------- -void mephisto_sensors_board_device::device_add_mconfig(machine_config &config) +mephisto_board_device::mephisto_board_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) + : device_t(mconfig, type, tag, owner, clock) + , m_board(*this, "board") + , m_led_pwm(*this, "led_pwm") + , m_sensordelay(attotime::from_msec(150)) + , m_led_out(*this, "led%u", 0U) + , m_disable_leds(false) { - SENSORBOARD(config, m_board); - m_board->set_type(sensorboard_device::MAGNETS); - m_board->init_cb().set(m_board, FUNC(sensorboard_device::preset_chess)); } -//------------------------------------------------- -// device_add_mconfig - add device-specific -// machine configuration -//------------------------------------------------- +mephisto_sensors_board_device::mephisto_sensors_board_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) + : mephisto_board_device(mconfig, MEPHISTO_SENSORS_BOARD, tag, owner, clock) +{ +} -void mephisto_buttons_board_device::device_add_mconfig(machine_config &config) +mephisto_buttons_board_device::mephisto_buttons_board_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) + : mephisto_board_device(mconfig, MEPHISTO_BUTTONS_BOARD, tag, owner, clock) { - SENSORBOARD(config, m_board); - m_board->set_type(sensorboard_device::BUTTONS); - m_board->init_cb().set(m_board, FUNC(sensorboard_device::preset_chess)); } -//************************************************************************** -// LIVE DEVICE -//************************************************************************** //------------------------------------------------- -// mephisto_board_device - constructor +// device_add_mconfig //------------------------------------------------- -mephisto_board_device::mephisto_board_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) - : device_t(mconfig, type, tag, owner, clock) - , m_board(*this, "board") - , m_sensordelay(attotime::from_msec(150)) - , m_led(*this, "led%u", 0U) - , m_disable_leds(false) +void mephisto_sensors_board_device::device_add_mconfig(machine_config &config) { + set_config(config, sensorboard_device::MAGNETS); } -//------------------------------------------------- -// mephisto_sensors_board_device - constructor -//------------------------------------------------- - -mephisto_sensors_board_device::mephisto_sensors_board_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : mephisto_board_device(mconfig, MEPHISTO_SENSORS_BOARD, tag, owner, clock) +void mephisto_buttons_board_device::device_add_mconfig(machine_config &config) { + set_config(config, sensorboard_device::BUTTONS); } -//------------------------------------------------- -// mephisto_buttons_board_device - constructor -//------------------------------------------------- -mephisto_buttons_board_device::mephisto_buttons_board_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : mephisto_board_device(mconfig, MEPHISTO_BUTTONS_BOARD, tag, owner, clock) +void mephisto_board_device::set_config(machine_config &config, sensorboard_device::sb_type board_type) { + SENSORBOARD(config, m_board).set_type(board_type); + m_board->init_cb().set(m_board, FUNC(sensorboard_device::preset_chess)); + + PWM_DISPLAY(config, m_led_pwm).set_size(8, 8); + m_led_pwm->output_x().set(FUNC(mephisto_board_device::refresh_leds_w)); } + //------------------------------------------------- // device_start - device-specific startup //------------------------------------------------- void mephisto_board_device::device_start() { - m_led.resolve(); - m_leds_update_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(mephisto_board_device::leds_update_callback), this)); - m_leds_refresh_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(mephisto_board_device::leds_refresh_callback), this)); - m_leds_update_timer->adjust(attotime::from_hz(60), 0, attotime::from_hz(60)); - m_leds_refresh_timer->adjust(attotime::from_hz(5), 0, attotime::from_hz(5)); + m_led_out.resolve(); save_item(NAME(m_mux)); - save_item(NAME(m_leds)); - save_item(NAME(m_leds_state)); + save_item(NAME(m_led_data)); m_board->set_delay(m_sensordelay); } + //------------------------------------------------- // device_reset - device-specific reset //------------------------------------------------- void mephisto_board_device::device_reset() { - m_mux = 0x00; - m_leds = 0x00; - memset(m_leds_state, 0, sizeof(m_leds_state)); + m_mux = 0xff; + m_led_data = 0x00; + update_led_pwm(); } -TIMER_CALLBACK_MEMBER(mephisto_board_device::leds_update_callback) -{ - for (int i=0; i<8; i++) - for (int j=0; j<8; j++) - { - if (!m_leds_state[i*8 + j] && !BIT(m_mux, i) && BIT(m_leds, j)) - m_leds_state[i*8 + j] = 2; - } -} -TIMER_CALLBACK_MEMBER(mephisto_board_device::leds_refresh_callback) +//------------------------------------------------- +// I/O handlers +//------------------------------------------------- + +WRITE8_MEMBER( mephisto_board_device::refresh_leds_w ) { - for (int i=0; i<8; i++) - for (int j=0; j<8; j++) - { - if (!m_disable_leds) - m_led[i*8 + j] = (m_leds_state[i*8 + j] > 1) ? 1 : 0; - - if (m_leds_state[i*8 + j]) - m_leds_state[i*8 + j]--; - } + if (!m_disable_leds) + m_led_out[(offset >> 6 & 7) | (offset & 7) << 3] = data; } READ8_MEMBER( mephisto_board_device::input_r ) { uint8_t data = 0xff; - for (int i=0; i<8; i++) + for (int i = 0; i < 8; i++) if (!BIT(m_mux, i)) data &= ~m_board->read_rank(i); @@ -155,90 +124,11 @@ READ8_MEMBER( mephisto_board_device::mux_r ) WRITE8_MEMBER( mephisto_board_device::mux_w ) { m_mux = data; + update_led_pwm(); } WRITE8_MEMBER( mephisto_board_device::led_w ) { - m_leds = data; -} - - - -//------------------------------------------------- -// mephisto_display_modul_device - constructor -//------------------------------------------------- - -mephisto_display_modul_device::mephisto_display_modul_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : device_t(mconfig, MEPHISTO_DISPLAY_MODUL, tag, owner, clock) - , m_lcdc(*this, "hd44780") - , m_dac(*this, "dac") -{ -} - -//------------------------------------------------- -// device_add_mconfig -//------------------------------------------------- - -void mephisto_display_modul_device::device_add_mconfig(machine_config &config) -{ - /* video hardware */ - screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_LCD)); - screen.set_refresh_hz(50); - screen.set_size(16*6, 9*2); - screen.set_visarea(0, 16*6-1, 0, 9*2-3); - screen.set_screen_update("hd44780", FUNC(hd44780_device::screen_update)); - screen.set_palette("palette"); - PALETTE(config, "palette", FUNC(mephisto_display_modul_device::lcd_palette), 2); - - HD44780(config, m_lcdc, 0); - m_lcdc->set_lcd_size(2, 16); - - /* sound hardware */ - SPEAKER(config, "speaker").front_center(); - DAC_2BIT_BINARY_WEIGHTED_ONES_COMPLEMENT(config, m_dac).add_route(ALL_OUTPUTS, "speaker", 0.25); - voltage_regulator_device &vref(VOLTAGE_REGULATOR(config, "vref")); - vref.add_route(0, "dac", 1.0, DAC_VREF_POS_INPUT); - vref.add_route(0, "dac", -1.0, DAC_VREF_NEG_INPUT); -} - - -void mephisto_display_modul_device::lcd_palette(palette_device &palette) const -{ - palette.set_pen_color(0, rgb_t(138, 146, 148)); - palette.set_pen_color(1, rgb_t(92, 83, 88)); -} - -//------------------------------------------------- -// device_start - device-specific startup -//------------------------------------------------- - -void mephisto_display_modul_device::device_start() -{ - save_item(NAME(m_latch)); - save_item(NAME(m_ctrl)); -} - -//------------------------------------------------- -// device_reset - device-specific reset -//------------------------------------------------- - -void mephisto_display_modul_device::device_reset() -{ - m_latch = 0; - m_ctrl = 0; -} - -WRITE8_MEMBER(mephisto_display_modul_device::latch_w) -{ - m_latch = data; -} - -WRITE8_MEMBER(mephisto_display_modul_device::io_w) -{ - if (BIT(data, 1) && !BIT(m_ctrl, 1)) - m_lcdc->write(BIT(data, 0), m_latch); - - m_dac->write(data >> 2 & 3); - - m_ctrl = data; + m_led_data = data; + update_led_pwm(); } |