From c92ee7270bddda658bfd165cc15520a76839f488 Mon Sep 17 00:00:00 2001 From: hap Date: Fri, 22 Sep 2023 15:58:06 +0200 Subject: z80pio: change an if/else block to switch/case, dl1416: don't randomize ram at power on --- src/devices/machine/z80pio.cpp | 22 ++++++++++++++++++---- src/devices/machine/z80pio.h | 16 ++++++++-------- src/devices/video/dl1416.cpp | 20 ++++++++------------ src/devices/video/dl1416.h | 2 ++ src/mame/handheld/lk3000.cpp | 2 +- 5 files changed, 37 insertions(+), 25 deletions(-) diff --git a/src/devices/machine/z80pio.cpp b/src/devices/machine/z80pio.cpp index 4f40a1699f8..407c814f327 100644 --- a/src/devices/machine/z80pio.cpp +++ b/src/devices/machine/z80pio.cpp @@ -559,10 +559,24 @@ void z80pio_device::pio_port::write(uint8_t data) data &= mask; - if ((m_icw & 0x60) == 0 && data != mask) match = true; - else if ((m_icw & 0x60) == 0x20 && data != 0) match = true; - else if ((m_icw & 0x60) == 0x40 && data == 0) match = true; - else if ((m_icw & 0x60) == 0x60 && data == mask) match = true; + switch (m_icw & 0x60) + { + case 0x00: + match = data != mask; + break; + + case 0x20: + match = data != 0; + break; + + case 0x40: + match = data == 0; + break; + + case 0x60: + match = data == mask; + break; + } if (!m_match && match && !m_ius) { diff --git a/src/devices/machine/z80pio.h b/src/devices/machine/z80pio.h index ca638bb88f7..5e9c562187e 100644 --- a/src/devices/machine/z80pio.h +++ b/src/devices/machine/z80pio.h @@ -58,6 +58,7 @@ public: // construction/destruction z80pio_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + // configuration helpers auto out_int_callback() { return m_out_int_cb.bind(); } auto in_pa_callback() { return m_in_pa_cb.bind(); } auto out_pa_callback() { return m_out_pa_cb.bind(); } @@ -66,7 +67,6 @@ public: auto out_pb_callback() { return m_out_pb_cb.bind(); } auto out_brdy_callback() { return m_out_brdy_cb.bind(); } - // I/O line access int rdy(int which) { return m_port[which].rdy(); } void strobe(int which, bool state) { m_port[which].strobe(state); } @@ -196,9 +196,9 @@ private: int m_mode; // mode register int m_next_control_word; // next control word - uint8_t m_input; // input latch - uint8_t m_output; // output latch - uint8_t m_ior; // input/output register + uint8_t m_input; // input latch + uint8_t m_output; // output latch + uint8_t m_ior; // input/output register bool m_rdy; // ready bool m_stb; // strobe @@ -206,14 +206,14 @@ private: bool m_ie; // interrupt enabled bool m_ip; // interrupt pending bool m_ius; // interrupt under service - uint8_t m_icw; // interrupt control word - uint8_t m_vector; // interrupt vector - uint8_t m_mask; // interrupt mask + uint8_t m_icw; // interrupt control word + uint8_t m_vector; // interrupt vector + uint8_t m_mask; // interrupt mask bool m_match; // logic equation match }; // internal state - pio_port m_port[2]; + pio_port m_port[2]; devcb_write_line m_out_int_cb; devcb_read8 m_in_pa_cb; diff --git a/src/devices/video/dl1416.cpp b/src/devices/video/dl1416.cpp index b50a6c72452..ca5ef344f38 100644 --- a/src/devices/video/dl1416.cpp +++ b/src/devices/video/dl1416.cpp @@ -225,15 +225,6 @@ void dl1414_device::device_start() m_wr_in = true; m_addr_in = 0x00; m_data_in = 0x00; - - // randomise internal RAM - for (unsigned i = 0; 4 > i; ++i) - { - m_digit_ram[i] = machine().rand() & 0x3f; - // TODO: only enable the following line if the device actually has a cursor (DL1416T and DL1416B), if DL1414 then cursor is always 0! - //m_cursor_state[i] = bool(BIT(device->machine().rand(), 7)); - m_cursor_state[i] = false; - } } void dl1416_device::device_start() @@ -261,7 +252,7 @@ void dl1414_device::device_reset() { // push initial display state for (unsigned i = 0; 4 > i; ++i) - m_update_cb(i, translate(m_digit_ram[i], m_cursor_state[i]), 0xffff); + do_update(i); } @@ -325,7 +316,7 @@ void dl1414_device::bus_w(offs_t offset, u8 data) if (m_digit_ram[offset] != data) { m_digit_ram[offset] = data; - m_update_cb(offset, translate(m_digit_ram[offset], m_cursor_state[offset]), 0xffff); + do_update(offset); } } @@ -336,6 +327,11 @@ void dl1414_device::set_cursor_state(offs_t offset, bool state) if (state != m_cursor_state[offset]) { m_cursor_state[offset] = state; - m_update_cb(offset, translate(m_digit_ram[offset], m_cursor_state[offset]), 0xffff); + do_update(offset); } } + +void dl1414_device::do_update(offs_t offset) +{ + m_update_cb(offset, translate(m_digit_ram[offset], m_cursor_state[offset]), 0xffff); +} diff --git a/src/devices/video/dl1416.h b/src/devices/video/dl1416.h index a0543f11565..9a220b5e781 100644 --- a/src/devices/video/dl1416.h +++ b/src/devices/video/dl1416.h @@ -66,6 +66,8 @@ protected: private: devcb_write16 m_update_cb; + void do_update(offs_t offset); + // internal state u8 m_digit_ram[4]; // holds the digit code for each position bool m_cursor_state[4]; // holds the cursor state for each position diff --git a/src/mame/handheld/lk3000.cpp b/src/mame/handheld/lk3000.cpp index bb8ba95a34d..7506b48ae56 100644 --- a/src/mame/handheld/lk3000.cpp +++ b/src/mame/handheld/lk3000.cpp @@ -9,7 +9,7 @@ It was also licensed to Nixdorf. Hardware notes: - 3870 MCU (Motorola brand) @ 4MHz(2MHz internal) - optional external ROM or RAM -- 4*Litronix DL 1414 (16*17segs total) +- 4*Litronix DL1414 (16*17segs total) - 33-button keypad The CPU and memory is on the cartridge. In theory, any hardware configuration -- cgit v1.2.3