diff options
author | AJR <ajrhacker@users.noreply.github.com> | 2018-04-04 12:20:55 -0400 |
---|---|---|
committer | AJR <ajrhacker@users.noreply.github.com> | 2018-04-04 12:20:55 -0400 |
commit | ed7253e918de69159f386828d2f649a0366d9b9b (patch) | |
tree | a60a8e0c849e000a527c3eb7b46163f3b967522e | |
parent | b4c6d1b2a237d8b29db5a3c2687e18290d6228c9 (diff) |
cp1.cpp, mpf1.cpp: Use output finders (nw)
-rw-r--r-- | src/mame/drivers/cp1.cpp | 44 | ||||
-rw-r--r-- | src/mame/drivers/mpf1.cpp | 24 | ||||
-rw-r--r-- | src/mame/includes/mpf1.h | 20 |
3 files changed, 44 insertions, 44 deletions
diff --git a/src/mame/drivers/cp1.cpp b/src/mame/drivers/cp1.cpp index 16ef8d7b843..b7d4d361257 100644 --- a/src/mame/drivers/cp1.cpp +++ b/src/mame/drivers/cp1.cpp @@ -28,18 +28,18 @@ public: m_i8155(*this, "i8155"), m_i8155_cp3(*this, "i8155_cp3"), m_cassette(*this, "cassette"), - m_io_lines(*this, {"LINE0", "LINE1", "LINE2", "LINE3", "LINE4"}), - m_io_config(*this, "CONFIG") + m_io_lines(*this, "LINE%u", 0U), + m_io_config(*this, "CONFIG"), + m_digits(*this, "digit%u", 0U) { } - required_device<cpu_device> m_maincpu; - required_device<i8155_device> m_i8155; - required_device<i8155_device> m_i8155_cp3; - required_device<cassette_image_device> m_cassette; - required_ioport_array<5> m_io_lines; - required_ioport m_io_config; + void cp1(machine_config &config); +private: + void cp1_io(address_map &map); + virtual void machine_start() override; virtual void machine_reset() override; + DECLARE_READ8_MEMBER(port1_r); DECLARE_READ8_MEMBER(port2_r); DECLARE_WRITE8_MEMBER(port1_w); @@ -53,9 +53,14 @@ public: DECLARE_WRITE8_MEMBER(i8155_portb_w); DECLARE_WRITE8_MEMBER(i8155_portc_w); - void cp1(machine_config &config); - void cp1_io(address_map &map); -private: + required_device<cpu_device> m_maincpu; + required_device<i8155_device> m_i8155; + required_device<i8155_device> m_i8155_cp3; + required_device<cassette_image_device> m_cassette; + required_ioport_array<5> m_io_lines; + required_ioport m_io_config; + output_finder<6> m_digits; + uint8_t m_7seg; uint8_t m_port2; uint8_t m_matrix; @@ -151,12 +156,12 @@ WRITE8_MEMBER(cp1_state::i8155_porta_w) if (m_7seg) { - if (!(m_matrix & 0x01)) output().set_digit_value(5, data); - if (!(m_matrix & 0x02)) output().set_digit_value(4, data); - if (!(m_matrix & 0x04)) output().set_digit_value(3, data); - if (!(m_matrix & 0x08)) output().set_digit_value(2, data | 0x80); // this digit has always the dot active - if (!(m_matrix & 0x10)) output().set_digit_value(1, data); - if (!(m_matrix & 0x20)) output().set_digit_value(0, data); + if (!(m_matrix & 0x01)) m_digits[5] = data; + if (!(m_matrix & 0x02)) m_digits[4] = data; + if (!(m_matrix & 0x04)) m_digits[3] = data; + if (!(m_matrix & 0x08)) m_digits[2] = data | 0x80; // this digit has always the dot active + if (!(m_matrix & 0x10)) m_digits[1] = data; + if (!(m_matrix & 0x20)) m_digits[0] = data; } m_7seg ^= 0x01; @@ -224,6 +229,11 @@ INPUT_PORTS_START( cp1 ) PORT_CONFSETTING( 0x02, DEF_STR( Yes ) ) INPUT_PORTS_END +void cp1_state::machine_start() +{ + m_digits.resolve(); +} + void cp1_state::machine_reset() { m_port2 = 0; diff --git a/src/mame/drivers/mpf1.cpp b/src/mame/drivers/mpf1.cpp index ac2d46bd258..468c9b8af0f 100644 --- a/src/mame/drivers/mpf1.cpp +++ b/src/mame/drivers/mpf1.cpp @@ -251,12 +251,9 @@ INPUT_PORTS_END TIMER_CALLBACK_MEMBER(mpf1_state::led_refresh) { - if (BIT(m_lednum, 5)) output().set_digit_value(0, param); - if (BIT(m_lednum, 4)) output().set_digit_value(1, param); - if (BIT(m_lednum, 3)) output().set_digit_value(2, param); - if (BIT(m_lednum, 2)) output().set_digit_value(3, param); - if (BIT(m_lednum, 1)) output().set_digit_value(4, param); - if (BIT(m_lednum, 0)) output().set_digit_value(5, param); + for (int digit = 0; digit < 6; digit++) + if (BIT(m_lednum, 5 - digit)) + m_digits[digit] = param; } READ8_MEMBER( mpf1_state::ppi_pa_r ) @@ -264,12 +261,9 @@ READ8_MEMBER( mpf1_state::ppi_pa_r ) uint8_t data = 0x7f; /* bit 0 to 5, keyboard rows 0 to 5 */ - if (!BIT(m_lednum, 0)) data &= m_pc0->read(); - if (!BIT(m_lednum, 1)) data &= m_pc1->read(); - if (!BIT(m_lednum, 2)) data &= m_pc2->read(); - if (!BIT(m_lednum, 3)) data &= m_pc3->read(); - if (!BIT(m_lednum, 4)) data &= m_pc4->read(); - if (!BIT(m_lednum, 5)) data &= m_pc5->read(); + for (int row = 0; row < 6; row++) + if (!BIT(m_lednum, row)) + data &= m_pc[row]->read(); /* bit 6, user key */ data &= m_special->read() & 1 ? 0xff : 0xbf; @@ -305,7 +299,7 @@ WRITE8_MEMBER( mpf1_state::ppi_pc_w ) } /* bit 7, tape output, tone and led */ - output().set_led_value(0, !BIT(data, 7)); + m_leds[0] = !BIT(data, 7); m_speaker->level_w(BIT(data, 7)); m_cassette->output( BIT(data, 7) ? 1.0 : -1.0); } @@ -339,12 +333,14 @@ TIMER_DEVICE_CALLBACK_MEMBER(mpf1_state::check_halt_callback) // halt-LED; the red one, is turned on when the processor is halted // TODO: processor seems to halt, but restarts(?) at 0x0000 after a while -> fix int64_t led_halt = m_maincpu->state_int(Z80_HALT); - output().set_led_value(1, led_halt); + m_leds[1] = led_halt; } void mpf1_state::machine_start() { m_led_refresh_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(mpf1_state::led_refresh),this)); + m_digits.resolve(); + m_leds.resolve(); /* register for state saving */ save_item(NAME(m_break)); diff --git a/src/mame/includes/mpf1.h b/src/mame/includes/mpf1.h index 4d4cd50efb6..de42d5ad39c 100644 --- a/src/mame/includes/mpf1.h +++ b/src/mame/includes/mpf1.h @@ -32,26 +32,20 @@ public: m_ctc(*this, Z80CTC_TAG), m_speaker(*this, "speaker"), m_cassette(*this, "cassette"), - m_pc0(*this, "PC0"), - m_pc1(*this, "PC1"), - m_pc2(*this, "PC2"), - m_pc3(*this, "PC3"), - m_pc4(*this, "PC4"), - m_pc5(*this, "PC5"), - m_special(*this, "SPECIAL") + m_pc(*this, "PC%u", 0U), + m_special(*this, "SPECIAL"), + m_digits(*this, "digit%u", 0U), + m_leds(*this, "led%u", 0U) { } required_device<cpu_device> m_maincpu; required_device<z80ctc_device> m_ctc; required_device<speaker_sound_device> m_speaker; required_device<cassette_image_device> m_cassette; - required_ioport m_pc0; - required_ioport m_pc1; - required_ioport m_pc2; - required_ioport m_pc3; - required_ioport m_pc4; - required_ioport m_pc5; + required_ioport_array<6> m_pc; required_ioport m_special; + output_finder<6> m_digits; + output_finder<2> m_leds; virtual void machine_start() override; virtual void machine_reset() override; |