cp1.cpp, mpf1.cpp: Use output finders (nw)

This commit is contained in:
AJR 2018-04-04 12:20:55 -04:00
parent b4c6d1b2a2
commit ed7253e918
3 changed files with 44 additions and 44 deletions

View File

@ -28,18 +28,18 @@ public:
m_i8155(*this, "i8155"), m_i8155(*this, "i8155"),
m_i8155_cp3(*this, "i8155_cp3"), m_i8155_cp3(*this, "i8155_cp3"),
m_cassette(*this, "cassette"), m_cassette(*this, "cassette"),
m_io_lines(*this, {"LINE0", "LINE1", "LINE2", "LINE3", "LINE4"}), m_io_lines(*this, "LINE%u", 0U),
m_io_config(*this, "CONFIG") m_io_config(*this, "CONFIG"),
m_digits(*this, "digit%u", 0U)
{ } { }
required_device<cpu_device> m_maincpu; void cp1(machine_config &config);
required_device<i8155_device> m_i8155; private:
required_device<i8155_device> m_i8155_cp3; void cp1_io(address_map &map);
required_device<cassette_image_device> m_cassette;
required_ioport_array<5> m_io_lines;
required_ioport m_io_config;
virtual void machine_start() override;
virtual void machine_reset() override; virtual void machine_reset() override;
DECLARE_READ8_MEMBER(port1_r); DECLARE_READ8_MEMBER(port1_r);
DECLARE_READ8_MEMBER(port2_r); DECLARE_READ8_MEMBER(port2_r);
DECLARE_WRITE8_MEMBER(port1_w); DECLARE_WRITE8_MEMBER(port1_w);
@ -53,9 +53,14 @@ public:
DECLARE_WRITE8_MEMBER(i8155_portb_w); DECLARE_WRITE8_MEMBER(i8155_portb_w);
DECLARE_WRITE8_MEMBER(i8155_portc_w); DECLARE_WRITE8_MEMBER(i8155_portc_w);
void cp1(machine_config &config); required_device<cpu_device> m_maincpu;
void cp1_io(address_map &map); required_device<i8155_device> m_i8155;
private: 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_7seg;
uint8_t m_port2; uint8_t m_port2;
uint8_t m_matrix; uint8_t m_matrix;
@ -151,12 +156,12 @@ WRITE8_MEMBER(cp1_state::i8155_porta_w)
if (m_7seg) if (m_7seg)
{ {
if (!(m_matrix & 0x01)) output().set_digit_value(5, data); if (!(m_matrix & 0x01)) m_digits[5] = data;
if (!(m_matrix & 0x02)) output().set_digit_value(4, data); if (!(m_matrix & 0x02)) m_digits[4] = data;
if (!(m_matrix & 0x04)) output().set_digit_value(3, data); if (!(m_matrix & 0x04)) m_digits[3] = data;
if (!(m_matrix & 0x08)) output().set_digit_value(2, data | 0x80); // this digit has always the dot active if (!(m_matrix & 0x08)) m_digits[2] = data | 0x80; // this digit has always the dot active
if (!(m_matrix & 0x10)) output().set_digit_value(1, data); if (!(m_matrix & 0x10)) m_digits[1] = data;
if (!(m_matrix & 0x20)) output().set_digit_value(0, data); if (!(m_matrix & 0x20)) m_digits[0] = data;
} }
m_7seg ^= 0x01; m_7seg ^= 0x01;
@ -224,6 +229,11 @@ INPUT_PORTS_START( cp1 )
PORT_CONFSETTING( 0x02, DEF_STR( Yes ) ) PORT_CONFSETTING( 0x02, DEF_STR( Yes ) )
INPUT_PORTS_END INPUT_PORTS_END
void cp1_state::machine_start()
{
m_digits.resolve();
}
void cp1_state::machine_reset() void cp1_state::machine_reset()
{ {
m_port2 = 0; m_port2 = 0;

View File

@ -251,12 +251,9 @@ INPUT_PORTS_END
TIMER_CALLBACK_MEMBER(mpf1_state::led_refresh) TIMER_CALLBACK_MEMBER(mpf1_state::led_refresh)
{ {
if (BIT(m_lednum, 5)) output().set_digit_value(0, param); for (int digit = 0; digit < 6; digit++)
if (BIT(m_lednum, 4)) output().set_digit_value(1, param); if (BIT(m_lednum, 5 - digit))
if (BIT(m_lednum, 3)) output().set_digit_value(2, param); m_digits[digit] = 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);
} }
READ8_MEMBER( mpf1_state::ppi_pa_r ) READ8_MEMBER( mpf1_state::ppi_pa_r )
@ -264,12 +261,9 @@ READ8_MEMBER( mpf1_state::ppi_pa_r )
uint8_t data = 0x7f; uint8_t data = 0x7f;
/* bit 0 to 5, keyboard rows 0 to 5 */ /* bit 0 to 5, keyboard rows 0 to 5 */
if (!BIT(m_lednum, 0)) data &= m_pc0->read(); for (int row = 0; row < 6; row++)
if (!BIT(m_lednum, 1)) data &= m_pc1->read(); if (!BIT(m_lednum, row))
if (!BIT(m_lednum, 2)) data &= m_pc2->read(); data &= m_pc[row]->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();
/* bit 6, user key */ /* bit 6, user key */
data &= m_special->read() & 1 ? 0xff : 0xbf; 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 */ /* 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_speaker->level_w(BIT(data, 7));
m_cassette->output( BIT(data, 7) ? 1.0 : -1.0); 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 // 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 // TODO: processor seems to halt, but restarts(?) at 0x0000 after a while -> fix
int64_t led_halt = m_maincpu->state_int(Z80_HALT); 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() void mpf1_state::machine_start()
{ {
m_led_refresh_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(mpf1_state::led_refresh),this)); 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 */ /* register for state saving */
save_item(NAME(m_break)); save_item(NAME(m_break));

View File

@ -32,26 +32,20 @@ public:
m_ctc(*this, Z80CTC_TAG), m_ctc(*this, Z80CTC_TAG),
m_speaker(*this, "speaker"), m_speaker(*this, "speaker"),
m_cassette(*this, "cassette"), m_cassette(*this, "cassette"),
m_pc0(*this, "PC0"), m_pc(*this, "PC%u", 0U),
m_pc1(*this, "PC1"), m_special(*this, "SPECIAL"),
m_pc2(*this, "PC2"), m_digits(*this, "digit%u", 0U),
m_pc3(*this, "PC3"), m_leds(*this, "led%u", 0U)
m_pc4(*this, "PC4"),
m_pc5(*this, "PC5"),
m_special(*this, "SPECIAL")
{ } { }
required_device<cpu_device> m_maincpu; required_device<cpu_device> m_maincpu;
required_device<z80ctc_device> m_ctc; required_device<z80ctc_device> m_ctc;
required_device<speaker_sound_device> m_speaker; required_device<speaker_sound_device> m_speaker;
required_device<cassette_image_device> m_cassette; required_device<cassette_image_device> m_cassette;
required_ioport m_pc0; required_ioport_array<6> m_pc;
required_ioport m_pc1;
required_ioport m_pc2;
required_ioport m_pc3;
required_ioport m_pc4;
required_ioport m_pc5;
required_ioport m_special; required_ioport m_special;
output_finder<6> m_digits;
output_finder<2> m_leds;
virtual void machine_start() override; virtual void machine_start() override;
virtual void machine_reset() override; virtual void machine_reset() override;