mirror of
https://github.com/holub/mame
synced 2025-04-20 23:42:22 +03:00
pwm_display: add separate handlers for matrix x/y sides
This commit is contained in:
parent
926dbbddcb
commit
ffb70cfb71
@ -84,6 +84,7 @@ void pwm_display_device::device_start()
|
||||
|
||||
// initialize
|
||||
m_rowsel = 0;
|
||||
m_rowdata_last = 0;
|
||||
std::fill(std::begin(m_rowdata), std::end(m_rowdata), 0);
|
||||
|
||||
for (auto &bri : m_bri)
|
||||
@ -105,6 +106,7 @@ void pwm_display_device::device_start()
|
||||
save_item(NAME(m_segmask));
|
||||
save_item(NAME(m_rowsel));
|
||||
save_item(NAME(m_rowdata));
|
||||
save_item(NAME(m_rowdata_last));
|
||||
|
||||
save_item(NAME(m_bri));
|
||||
save_item(NAME(m_sync_time));
|
||||
@ -161,6 +163,7 @@ void pwm_display_device::matrix_partial(u8 start, u8 height, u64 rowsel, u64 row
|
||||
|
||||
// update selected rows
|
||||
u64 rowmask = (u64(1) << m_width) - 1;
|
||||
m_rowdata_last = rowdata & rowmask;
|
||||
for (int y = start; y < (start + height) && y < m_height; y++)
|
||||
{
|
||||
m_rowdata[y] = (rowsel & 1) ? (rowdata & rowmask) : 0;
|
||||
|
@ -35,10 +35,16 @@ public:
|
||||
void set_bri_one(u8 i, double level) { m_levels[i] = level; }
|
||||
void segmask_one(u8 y, u64 mask) { m_segmask[y] = mask; }
|
||||
|
||||
// matrix accessors
|
||||
void matrix_partial(u8 start, u8 height, u64 rowsel, u64 rowdata);
|
||||
void matrix(u64 rowsel, u64 rowdata) { matrix_partial(0, m_height, rowsel, rowdata); }
|
||||
void clear() { matrix(0, 0); }
|
||||
|
||||
void write_my(u64 y) { matrix(y, m_rowdata_last); }
|
||||
void write_mx(u64 x) { matrix(m_rowsel, x); }
|
||||
u64 read_my() { return m_rowsel; }
|
||||
u64 read_mx() { return m_rowdata_last; }
|
||||
|
||||
// directly handle individual element (does not affect m_rowsel), y = row num, x = row bit
|
||||
int read_element(u8 y, u8 x) { return BIT(m_rowdata[y], x); }
|
||||
void write_element(u8 y, u8 x, int state) { sync(); m_rowdata[y] = (m_rowdata[y] & ~(u64(1) << x)) | (u64(state ? 1 : 0) << x); }
|
||||
@ -81,6 +87,7 @@ private:
|
||||
u64 m_segmask[0x40];
|
||||
u64 m_rowsel;
|
||||
u64 m_rowdata[0x40];
|
||||
u64 m_rowdata_last;
|
||||
|
||||
double m_bri[0x40][0x41];
|
||||
attotime m_sync_time;
|
||||
|
@ -120,10 +120,7 @@ private:
|
||||
void pio1_pb_w(u8 data);
|
||||
u8 pio2_pb_r();
|
||||
|
||||
void update_display();
|
||||
|
||||
u8 m_digit = 0;
|
||||
u8 m_segment = 0;
|
||||
u8 m_matrix = 0;
|
||||
};
|
||||
|
||||
|
||||
@ -236,11 +233,6 @@ WRITE_LINE_MEMBER(lc80_state::ctc_z2_w)
|
||||
|
||||
// Z80-PIO Interface
|
||||
|
||||
void lc80_state::update_display()
|
||||
{
|
||||
m_display->matrix(m_digit >> 1, m_segment);
|
||||
}
|
||||
|
||||
void lc80_state::pio1_pa_w(u8 data)
|
||||
{
|
||||
/*
|
||||
@ -258,8 +250,7 @@ void lc80_state::pio1_pa_w(u8 data)
|
||||
|
||||
*/
|
||||
|
||||
m_segment = bitswap<8>(~data, 4, 3, 1, 6, 7, 5, 0, 2);
|
||||
update_display();
|
||||
m_display->write_mx(bitswap<8>(~data, 4, 3, 1, 6, 7, 5, 0, 2));
|
||||
}
|
||||
|
||||
u8 lc80_state::pio1_pb_r()
|
||||
@ -289,11 +280,11 @@ void lc80_state::pio1_pb_w(u8 data)
|
||||
m_cassette->output(BIT(data, 1) ? +1.0 : -1.0);
|
||||
|
||||
// speaker
|
||||
m_speaker->level_w(!BIT(data, 1));
|
||||
m_speaker->level_w(BIT(~data, 1));
|
||||
|
||||
// 7segs/led/keyboard
|
||||
m_digit = ~data;
|
||||
update_display();
|
||||
m_display->write_my(~data >> 1);
|
||||
m_matrix = ~data >> 2 & 0x3f;
|
||||
}
|
||||
|
||||
u8 lc80_state::pio2_pb_r()
|
||||
@ -316,7 +307,7 @@ u8 lc80_state::pio2_pb_r()
|
||||
u8 data = 0;
|
||||
|
||||
for (int i = 0; i < 6; i++)
|
||||
if (BIT(m_digit, i+2))
|
||||
if (BIT(m_matrix, i))
|
||||
data |= m_inputs[i]->read() << 4;
|
||||
|
||||
return data ^ 0xf0;
|
||||
@ -347,8 +338,7 @@ void lc80_state::machine_start()
|
||||
program.install_ram(start, start + m_ram->size() - 1, mirror, m_ram->pointer());
|
||||
|
||||
// register for state saving
|
||||
save_item(NAME(m_digit));
|
||||
save_item(NAME(m_segment));
|
||||
save_item(NAME(m_matrix));
|
||||
}
|
||||
|
||||
|
||||
|
@ -101,25 +101,17 @@ private:
|
||||
u8 pio1_pb_r();
|
||||
void pio1_pb_w(u8 data);
|
||||
|
||||
void update_display();
|
||||
|
||||
u8 m_digit = 0;
|
||||
u8 m_segment = 0;
|
||||
u8 m_matrix = 0;
|
||||
bool m_nmi = false;
|
||||
};
|
||||
|
||||
|
||||
// Read/Write Handlers
|
||||
|
||||
void poly880_state::update_display()
|
||||
{
|
||||
m_display->matrix(m_digit, m_segment);
|
||||
}
|
||||
|
||||
void poly880_state::cldig_w(u8 data)
|
||||
{
|
||||
m_digit = data;
|
||||
update_display();
|
||||
m_display->write_my(data);
|
||||
m_matrix = data;
|
||||
}
|
||||
|
||||
|
||||
@ -229,7 +221,7 @@ void poly880_state::pio1_pa_w(u8 data)
|
||||
PA0 SD0 segment E
|
||||
PA1 SD1 segment D
|
||||
PA2 SD2 segment C
|
||||
PA3 SD3 segment P
|
||||
PA3 SD3 segment DP
|
||||
PA4 SD4 segment G
|
||||
PA5 SD5 segment A
|
||||
PA6 SD6 segment F
|
||||
@ -237,8 +229,7 @@ void poly880_state::pio1_pa_w(u8 data)
|
||||
|
||||
*/
|
||||
|
||||
m_segment = bitswap<8>(data, 3, 4, 6, 0, 1, 2, 7, 5);
|
||||
update_display();
|
||||
m_display->write_mx(bitswap<8>(data, 3, 4, 6, 0, 1, 2, 7, 5));
|
||||
}
|
||||
|
||||
u8 poly880_state::pio1_pb_r()
|
||||
@ -262,7 +253,7 @@ u8 poly880_state::pio1_pb_r()
|
||||
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
if (BIT(m_digit, i))
|
||||
if (BIT(m_matrix, i))
|
||||
{
|
||||
if (BIT(m_inputs[0]->read(), i)) data |= 0x10;
|
||||
if (BIT(m_inputs[1]->read(), i)) data |= 0x20;
|
||||
@ -317,8 +308,7 @@ static const z80_daisy_config poly880_daisy_chain[] =
|
||||
void poly880_state::machine_start()
|
||||
{
|
||||
// register for state saving
|
||||
save_item(NAME(m_digit));
|
||||
save_item(NAME(m_segment));
|
||||
save_item(NAME(m_matrix));
|
||||
save_item(NAME(m_nmi));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user