From 6ec3066e0ab50881297948ccc64127dc49432bc5 Mon Sep 17 00:00:00 2001 From: hap Date: Wed, 3 Dec 2014 21:41:26 +0100 Subject: added prelim input/outputs, you can see it strobing the 7segleds --- src/mess/drivers/cnsector.c | 61 +++++++++++++++++++++++++++++++++++++++----- src/mess/layout/cnsector.lay | 46 +++++++++++++++++++++++++++++++++ 2 files changed, 100 insertions(+), 7 deletions(-) diff --git a/src/mess/drivers/cnsector.c b/src/mess/drivers/cnsector.c index 05ada6e36c0..c78f19d074d 100644 --- a/src/mess/drivers/cnsector.c +++ b/src/mess/drivers/cnsector.c @@ -14,17 +14,22 @@ #include "cnsector.lh" +// master clock is cpu internal, the value below is an approximation +#define MASTER_CLOCK (250000) + + class cnsector_state : public driver_device { public: cnsector_state(const machine_config &mconfig, device_type type, const char *tag) : driver_device(mconfig, type, tag), - m_maincpu(*this, "maincpu") + m_maincpu(*this, "maincpu"), + m_button_matrix(*this, "IN") { } required_device m_maincpu; + required_ioport_array<5> m_button_matrix; - UINT16 m_r; UINT16 m_o; DECLARE_READ8_MEMBER(read_k); @@ -44,16 +49,31 @@ public: READ8_MEMBER(cnsector_state::read_k) { - return 0; + UINT8 k = 0; + + // read selected button rows + for (int i = 0; i < 5; i++) + if (m_o & (1 << i)) + k |= m_button_matrix[i]->read(); + + return k; } WRITE16_MEMBER(cnsector_state::write_r) { - m_r = data; + // R0-R5: select digit + for (int i = 0; i < 6; i++) + output_set_digit_value(i, (data >> i & 1) ? m_o : 0); + + // R6-R9: direction leds + for (int i = 6; i < 10; i++) + output_set_lamp_value(i - 6, data >> i & 1); } WRITE16_MEMBER(cnsector_state::write_o) { + // O0-O4: input mux + // O0-O7: digit segments m_o = data; } @@ -66,6 +86,35 @@ WRITE16_MEMBER(cnsector_state::write_o) ***************************************************************************/ static INPUT_PORTS_START( cnsector ) + PORT_START("IN.0") // O0 + PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Q) // ? next + PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_W) // ? left + PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_E) // nc? + PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_R) // ? range + + PORT_START("IN.1") // O1 + PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_T) // ? aim + PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Y) // ? right + PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_U) // nc? + PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_I) // ?nc + + PORT_START("IN.2") // O2 + PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_O) // ? fire + PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_A) // ? evasive + PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_S) // nc? + PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_D) // ? recall + + PORT_START("IN.3") // O3 + PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F) // ? finder + PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_G) // ? slow + PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_H) // nc? + PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_J) // ?nc + + PORT_START("IN.4") // O4 + PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_K) // ? teach + PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_L) // ? fast + PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Z) // nc? + PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_X) // ? move INPUT_PORTS_END @@ -78,10 +127,8 @@ INPUT_PORTS_END void cnsector_state::machine_start() { - m_r = 0; m_o = 0; - save_item(NAME(m_r)); save_item(NAME(m_o)); } @@ -89,7 +136,7 @@ void cnsector_state::machine_start() static MACHINE_CONFIG_START( cnsector, cnsector_state ) /* basic machine hardware */ - MCFG_CPU_ADD("maincpu", TMS0970, 250000) + MCFG_CPU_ADD("maincpu", TMS0970, MASTER_CLOCK) MCFG_TMS1XXX_READ_K_CB(READ8(cnsector_state, read_k)) MCFG_TMS1XXX_WRITE_O_CB(WRITE16(cnsector_state, write_o)) MCFG_TMS1XXX_WRITE_R_CB(WRITE16(cnsector_state, write_r)) diff --git a/src/mess/layout/cnsector.lay b/src/mess/layout/cnsector.lay index 08148b1f45a..42dcb2e7f92 100644 --- a/src/mess/layout/cnsector.lay +++ b/src/mess/layout/cnsector.lay @@ -1,8 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3