diff options
Diffstat (limited to 'src/mame/drivers/s8.cpp')
-rw-r--r-- | src/mame/drivers/s8.cpp | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/src/mame/drivers/s8.cpp b/src/mame/drivers/s8.cpp index e3fe43dbd8c..0666195a459 100644 --- a/src/mame/drivers/s8.cpp +++ b/src/mame/drivers/s8.cpp @@ -69,6 +69,7 @@ public: , m_pia28(*this, "pia28") , m_pia30(*this, "pia30") , m_digits(*this, "digit%u", 0U) + , m_swarray(*this, "SW.%u", 0U) { } void s8(machine_config &config); @@ -103,7 +104,7 @@ private: uint8_t m_sound_data; uint8_t m_strobe; - uint8_t m_kbdrow; + uint8_t m_switch_col; bool m_data_ok; emu_timer* m_irq_timer; virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override; @@ -117,6 +118,7 @@ private: required_device<pia6821_device> m_pia28; required_device<pia6821_device> m_pia30; output_finder<61> m_digits; + required_ioport_array<8> m_swarray; }; void s8_state::s8_main_map(address_map &map) @@ -139,10 +141,7 @@ void s8_state::s8_audio_map(address_map &map) } static INPUT_PORTS_START( s8 ) - PORT_START("X0") - PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNUSED ) - - PORT_START("X1") + PORT_START("SW.0") PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_TILT ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_OTHER ) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_START ) @@ -152,12 +151,12 @@ static INPUT_PORTS_START( s8 ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_OTHER ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_OTHER ) - PORT_START("X2") + PORT_START("SW.1") PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_OTHER ) PORT_CODE(KEYCODE_A) PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_OTHER ) PORT_CODE(KEYCODE_F) PORT_BIT( 0xf6, IP_ACTIVE_LOW, IPT_UNUSED ) - PORT_START("X4") + PORT_START("SW.2") PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_OTHER ) PORT_CODE(KEYCODE_L) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_OTHER ) PORT_CODE(KEYCODE_Z) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_OTHER ) PORT_CODE(KEYCODE_C) @@ -167,21 +166,21 @@ static INPUT_PORTS_START( s8 ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_OTHER ) PORT_CODE(KEYCODE_M) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_OTHER ) PORT_CODE(KEYCODE_COMMA) - PORT_START("X8") + PORT_START("SW.3") PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_OTHER ) PORT_CODE(KEYCODE_STOP) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_OTHER ) PORT_CODE(KEYCODE_SLASH) PORT_BIT( 0xfc, IP_ACTIVE_LOW, IPT_UNUSED ) - PORT_START("X10") + PORT_START("SW.4") PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNUSED ) - PORT_START("X20") + PORT_START("SW.5") PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNUSED ) - PORT_START("X40") + PORT_START("SW.6") PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNUSED ) - PORT_START("X80") + PORT_START("SW.7") PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_START("DIAGS") @@ -254,14 +253,22 @@ void s8_state::dig1_w(uint8_t data) uint8_t s8_state::switch_r() { - char kbdrow[8]; - sprintf(kbdrow,"X%X",m_kbdrow); - return ioport(kbdrow)->read() ^ 0xff; + char retval = 0xff; + // scan all 8 input columns, since multiple can be selected at once + for (int i = 0; i < 7; i++) + { + if (m_switch_col & (1<<i)) + retval &= m_swarray[i]->read(); + } + //retval &= ioport("OPTOS")->read(); // optos should be read here as well, and are always active even if no column is selected + return ~retval; } void s8_state::switch_w(uint8_t data) { - m_kbdrow = data; + // this drives the pulldown 2N3904 NPN transistors Q7-Q14, each of which drives one column of the switch matrix low + // it is possible for multiple columns to be enabled at once, this is handled in switch_r above. + m_switch_col = data; } uint8_t s8_state::sound_r() |