From 4989fc4fbf6fdddef54516dac23171151233fcb9 Mon Sep 17 00:00:00 2001 From: hap Date: Fri, 28 Jun 2019 22:43:40 +0200 Subject: chesstrv: add chesspieces (nw) --- src/devices/machine/sensorboard.cpp | 20 +- src/devices/machine/sensorboard.h | 5 +- src/mame/drivers/scisys_chesstrv.cpp | 75 +++--- src/mame/layout/scisys_chesstrv.lay | 480 +++++++++++++++++++++++++++++++++-- 4 files changed, 511 insertions(+), 69 deletions(-) diff --git a/src/devices/machine/sensorboard.cpp b/src/devices/machine/sensorboard.cpp index b2106665aaf..7f2bee9ae04 100644 --- a/src/devices/machine/sensorboard.cpp +++ b/src/devices/machine/sensorboard.cpp @@ -58,7 +58,7 @@ sensorboard_device::sensorboard_device(const machine_config &mconfig, const char // set defaults for most common use case (aka chess) set_size(8, 8); set_spawnpoints(12); - m_sensordelay = attotime::from_msec(75); + set_delay(attotime::from_msec(75)); } @@ -184,6 +184,20 @@ void sensorboard_device::device_reset() // public handlers //------------------------------------------------- +sensorboard_device &sensorboard_device::set_type(sb_type type) +{ + m_inductive = (type == INDUCTIVE); + m_magnets = (type == MAGNETS) || m_inductive; + + if (type == NOSENSORS) + { + set_mod_enable(false); + set_delay(attotime::never); + } + + return *this; +} + u8 sensorboard_device::read_sensor(u8 x, u8 y) { if (x >= m_width || y >= m_height) @@ -192,7 +206,7 @@ u8 sensorboard_device::read_sensor(u8 x, u8 y) u8 live_state = BIT(m_inp_rank[y]->read(), x); int pos = (y << 4 & 0xf0) | (x & 0x0f); - if (m_magnets || m_inductive) + if (m_magnets) { u8 piece = read_piece(x, y); u8 state = (piece != 0 && pos != m_handpos && pos != m_droppos) ? 1 : 0; @@ -383,7 +397,7 @@ INPUT_CHANGED_MEMBER(sensorboard_device::sensor) return; // auto click / sensor delay - if (m_sensordelay != attotime::never && (m_magnets || m_inductive || (pos != m_handpos && ~m_inp_ui->read() & 2))) + if (m_sensordelay != attotime::never && (m_magnets || (pos != m_handpos && ~m_inp_ui->read() & 2))) { m_sensorpos = pos; m_sensortimer->adjust(m_sensordelay); diff --git a/src/devices/machine/sensorboard.h b/src/devices/machine/sensorboard.h index 77f43bfd26c..da59b02854a 100644 --- a/src/devices/machine/sensorboard.h +++ b/src/devices/machine/sensorboard.h @@ -18,13 +18,14 @@ public: enum sb_type { - BUTTONS = 0, + NOSENSORS = 0, + BUTTONS, MAGNETS, INDUCTIVE }; // configuration helpers - sensorboard_device &set_type(sb_type t) { m_magnets = (t == MAGNETS); m_inductive = (t == INDUCTIVE); return *this; } // sensor type + sensorboard_device &set_type(sb_type type); // sensor type sensorboard_device &set_size(u8 width, u8 height) { m_width = width; m_height = height; return *this; } // board dimensions, max 10 * 10 sensorboard_device &set_spawnpoints(u8 i) { m_maxspawn = i; m_maxid = i; return *this; } // number of piece spawnpoints, max 16 sensorboard_device &set_max_id(u8 i) { m_maxid = i; return *this; } // maximum piece id (if larger than set_spawnpoints) diff --git a/src/mame/drivers/scisys_chesstrv.cpp b/src/mame/drivers/scisys_chesstrv.cpp index ad2f415a699..bc34f9457c9 100644 --- a/src/mame/drivers/scisys_chesstrv.cpp +++ b/src/mame/drivers/scisys_chesstrv.cpp @@ -5,6 +5,7 @@ SciSys Chess Traveler +Hardware notes: - Fairchild 3870 MCU, label SL90387 (does not use the timer or irq at all) - 256 bytes RAM(3539) - 4-digit 7seg led panel @@ -21,7 +22,8 @@ digit DP lights up). #include "emu.h" #include "cpu/f8/f8.h" #include "machine/f3853.h" -#include "machine/timer.h" +#include "video/pwm.h" +#include "machine/sensorboard.h" // internal artwork #include "scisys_chesstrv.lh" // clickable @@ -35,9 +37,8 @@ public: chesstrv_state(const machine_config &mconfig, device_type type, const char *tag) : driver_device(mconfig, type, tag), m_maincpu(*this, "maincpu"), - m_keypad(*this, "LINE%u", 1U), - m_delay_display(*this, "delay_display_%u", 0), - m_out_digit(*this, "digit%u", 0U) + m_display(*this, "display"), + m_inputs(*this, "IN.%u", 0) { } void chesstrv(machine_config &config); @@ -48,15 +49,13 @@ protected: private: // devices/pointers required_device m_maincpu; - required_ioport_array<4> m_keypad; - required_device_array m_delay_display; - output_finder<4> m_out_digit; + required_device m_display; + required_ioport_array<4> m_inputs; void chesstrv_mem(address_map &map); void chesstrv_io(address_map &map); - TIMER_DEVICE_CALLBACK_MEMBER(delay_display); - + void update_display(); DECLARE_WRITE8_MEMBER(matrix_w); DECLARE_WRITE8_MEMBER(digit_w); DECLARE_READ8_MEMBER(input_r); @@ -69,23 +68,23 @@ private: std::unique_ptr m_ram; u8 m_ram_address; - u8 m_matrix; + u8 m_inp_mux; + u8 m_7seg_data; }; void chesstrv_state::machine_start() { - // resolve handlers - m_out_digit.resolve(); - // zerofill m_ram = make_unique_clear(0x100); m_ram_address = 0; - m_matrix = 0; + m_inp_mux = 0; + m_7seg_data = 0; // register for savestates save_pointer(NAME(m_ram), 0x100); save_item(NAME(m_ram_address)); - save_item(NAME(m_matrix)); + save_item(NAME(m_inp_mux)); + save_item(NAME(m_7seg_data)); } @@ -96,44 +95,37 @@ void chesstrv_state::machine_start() // F3870 ports -TIMER_DEVICE_CALLBACK_MEMBER(chesstrv_state::delay_display) +void chesstrv_state::update_display() { - // clear digits if inactive - if (BIT(m_matrix, 3 - param)) - m_out_digit[param] = 0; + m_display->matrix(~m_inp_mux, m_7seg_data); } WRITE8_MEMBER(chesstrv_state::digit_w) { - // digit segments, update display here - for (int i = 0; i < 4; i++) - if (!BIT(m_matrix, 3 - i)) - m_out_digit[i] = bitswap<8>(data,0,1,2,3,4,5,6,7) & 0x7f; + // digit segments + m_7seg_data = bitswap<8>(data,0,1,2,3,4,5,6,7) & 0x7f; + update_display(); } WRITE8_MEMBER(chesstrv_state::matrix_w) { // d0-d3: input/digit select (active low) - // they're strobed, so on rising edge, delay them going off to prevent flicker or stuck display - for (int i = 0; i < 4; i++) - if (BIT(~m_matrix & data, 3 - i)) - m_delay_display[i]->adjust(attotime::from_msec(20), i); - - m_matrix = data; + m_inp_mux = data; + update_display(); } READ8_MEMBER(chesstrv_state::input_r) { - u8 data = m_matrix; + u8 data = m_inp_mux; // d0-d3: multiplexed inputs from d4-d7 for (int i = 0; i < 4; i++) - if (BIT(m_matrix, i+4)) - data |= m_keypad[i]->read(); + if (BIT(m_inp_mux, i+4)) + data |= m_inputs[i]->read(); // d4-d7: multiplexed inputs from d0-d3 for (int i = 0; i < 4; i++) - if (m_matrix & m_keypad[i]->read()) + if (m_inp_mux & m_inputs[i]->read()) data |= 1 << (i+4); return data; @@ -165,25 +157,25 @@ void chesstrv_state::chesstrv_io(address_map &map) ******************************************************************************/ static INPUT_PORTS_START( chesstrv ) - PORT_START("LINE1") + PORT_START("IN.0") PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_A) PORT_CODE(KEYCODE_1) PORT_CODE(KEYCODE_1_PAD) PORT_NAME("A 1 / Pawn") PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_B) PORT_CODE(KEYCODE_2) PORT_CODE(KEYCODE_2_PAD) PORT_NAME("B 2 / Knight") PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_C) PORT_CODE(KEYCODE_3) PORT_CODE(KEYCODE_3_PAD) PORT_NAME("C 3 / Bishop") PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_D) PORT_CODE(KEYCODE_4) PORT_CODE(KEYCODE_4_PAD) PORT_NAME("D 4 / Rook") - PORT_START("LINE2") + PORT_START("IN.1") PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_E) PORT_CODE(KEYCODE_5) PORT_CODE(KEYCODE_5_PAD) PORT_NAME("E 5 / Queen") PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_F) PORT_CODE(KEYCODE_6) PORT_CODE(KEYCODE_6_PAD) PORT_NAME("F 6 / King") PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_G) PORT_CODE(KEYCODE_7) PORT_CODE(KEYCODE_7_PAD) PORT_NAME("G 7 / White") PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_H) PORT_CODE(KEYCODE_8) PORT_CODE(KEYCODE_8_PAD) PORT_NAME("H 8 / Black") - PORT_START("LINE3") + PORT_START("IN.2") PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_L) PORT_NAME("LV / CS") // level/clear square PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_K) PORT_NAME("FP") // find position PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_O) PORT_NAME("EP") // enter position PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_Q) PORT_NAME("CB") // clear board - PORT_START("LINE4") + PORT_START("IN.3") PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_DEL) PORT_CODE(KEYCODE_BACKSPACE) PORT_NAME("CE") // clear entry PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_ENTER) PORT_CODE(KEYCODE_ENTER_PAD) PORT_NAME("Enter") PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_M) PORT_NAME("MM") // multi move @@ -209,10 +201,13 @@ void chesstrv_state::chesstrv(machine_config &config) psu.read_b().set(FUNC(chesstrv_state::input_r)); psu.write_b().set(FUNC(chesstrv_state::matrix_w)); - /* video hardware */ - for (int i = 0; i < 4; i++) - TIMER(config, m_delay_display[i]).configure_generic(FUNC(chesstrv_state::delay_display)); + // built-in chessboard is not electronic + sensorboard_device &board(SENSORBOARD(config, "board").set_type(sensorboard_device::NOSENSORS)); + board.init_cb().set("board", FUNC(sensorboard_device::preset_chess)); + /* video hardware */ + PWM_DISPLAY(config, m_display).set_size(4, 7); + m_display->set_segmask(0xf, 0x7f); config.set_default_layout(layout_scisys_chesstrv); } diff --git a/src/mame/layout/scisys_chesstrv.lay b/src/mame/layout/scisys_chesstrv.lay index 2e09672a0a4..e41a73519c5 100644 --- a/src/mame/layout/scisys_chesstrv.lay +++ b/src/mame/layout/scisys_chesstrv.lay @@ -3,7 +3,7 @@ - + @@ -46,37 +46,468 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - + + + + - + + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + @@ -103,7 +534,8 @@ - + + -- cgit v1.2.3