z80pio: change an if/else block to switch/case,

dl1416: don't randomize ram at power on
This commit is contained in:
hap 2023-09-22 15:58:06 +02:00
parent f848229294
commit c92ee7270b
5 changed files with 37 additions and 25 deletions

View File

@ -559,10 +559,24 @@ void z80pio_device::pio_port::write(uint8_t data)
data &= mask; data &= mask;
if ((m_icw & 0x60) == 0 && data != mask) match = true; switch (m_icw & 0x60)
else if ((m_icw & 0x60) == 0x20 && data != 0) match = true; {
else if ((m_icw & 0x60) == 0x40 && data == 0) match = true; case 0x00:
else if ((m_icw & 0x60) == 0x60 && data == mask) match = true; 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) if (!m_match && match && !m_ius)
{ {

View File

@ -58,6 +58,7 @@ public:
// construction/destruction // construction/destruction
z80pio_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); 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 out_int_callback() { return m_out_int_cb.bind(); }
auto in_pa_callback() { return m_in_pa_cb.bind(); } auto in_pa_callback() { return m_in_pa_cb.bind(); }
auto out_pa_callback() { return m_out_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_pb_callback() { return m_out_pb_cb.bind(); }
auto out_brdy_callback() { return m_out_brdy_cb.bind(); } auto out_brdy_callback() { return m_out_brdy_cb.bind(); }
// I/O line access // I/O line access
int rdy(int which) { return m_port[which].rdy(); } int rdy(int which) { return m_port[which].rdy(); }
void strobe(int which, bool state) { m_port[which].strobe(state); } void strobe(int which, bool state) { m_port[which].strobe(state); }

View File

@ -225,15 +225,6 @@ void dl1414_device::device_start()
m_wr_in = true; m_wr_in = true;
m_addr_in = 0x00; m_addr_in = 0x00;
m_data_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() void dl1416_device::device_start()
@ -261,7 +252,7 @@ void dl1414_device::device_reset()
{ {
// push initial display state // push initial display state
for (unsigned i = 0; 4 > i; ++i) 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) if (m_digit_ram[offset] != data)
{ {
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]) if (state != m_cursor_state[offset])
{ {
m_cursor_state[offset] = state; m_cursor_state[offset] = state;
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); m_update_cb(offset, translate(m_digit_ram[offset], m_cursor_state[offset]), 0xffff);
} }
}

View File

@ -66,6 +66,8 @@ protected:
private: private:
devcb_write16 m_update_cb; devcb_write16 m_update_cb;
void do_update(offs_t offset);
// internal state // internal state
u8 m_digit_ram[4]; // holds the digit code for each position u8 m_digit_ram[4]; // holds the digit code for each position
bool m_cursor_state[4]; // holds the cursor state for each position bool m_cursor_state[4]; // holds the cursor state for each position