diff options
author | hap <happppp@users.noreply.github.com> | 2017-07-29 21:58:06 +0200 |
---|---|---|
committer | hap <happppp@users.noreply.github.com> | 2017-07-29 21:58:31 +0200 |
commit | c8c3f073f9f02ad2d99f6b46d9b3c784327a5be2 (patch) | |
tree | a28e386bf9dae2c1c7922b9ef93fb7c3dd56fee0 /src/mame/drivers/k28.cpp | |
parent | 70115f6f2541919b596e75f191a499cf12bbb8cf (diff) |
hh*: added output finder (nw)
Diffstat (limited to 'src/mame/drivers/k28.cpp')
-rw-r--r-- | src/mame/drivers/k28.cpp | 60 |
1 files changed, 22 insertions, 38 deletions
diff --git a/src/mame/drivers/k28.cpp b/src/mame/drivers/k28.cpp index 1debe2a5faf..5e4cf519161 100644 --- a/src/mame/drivers/k28.cpp +++ b/src/mame/drivers/k28.cpp @@ -38,6 +38,9 @@ public: m_speech(*this, "speech"), m_onbutton_timer(*this, "on_button"), m_inp_matrix(*this, "IN.%u", 0), + m_out_x(*this, "%u.%u", 0U, 0U), + m_out_a(*this, "%u.a", 0U), + m_out_digit(*this, "digit%u", 0U), m_display_wait(33), m_display_maxy(1), m_display_maxx(0) @@ -49,6 +52,9 @@ public: required_device<votrax_sc01_device> m_speech; required_device<timer_device> m_onbutton_timer; required_ioport_array<7> m_inp_matrix; + output_finder<0x20, 0x20> m_out_x; + output_finder<0x20> m_out_a; + output_finder<0x20> m_out_digit; // display common int m_display_wait; // led/lamp off-delay in milliseconds (default 33ms) @@ -57,7 +63,6 @@ public: u32 m_display_state[0x20]; // display matrix rows data (last bit is used for always-on) u16 m_display_segmask[0x20]; // if not 0, display matrix row is a digit, mask indicates connected segments - u32 m_display_cache[0x20]; // (internal use) u8 m_display_decay[0x20][0x20]; // (internal use) TIMER_DEVICE_CALLBACK_MEMBER(display_decay_tick); @@ -96,9 +101,13 @@ protected: void k28_state::machine_start() { + // resolve handlers + m_out_x.resolve(); + m_out_a.resolve(); + m_out_digit.resolve(); + // zerofill memset(m_display_state, 0, sizeof(m_display_state)); - memset(m_display_cache, ~0, sizeof(m_display_cache)); memset(m_display_decay, 0, sizeof(m_display_decay)); memset(m_display_segmask, 0, sizeof(m_display_segmask)); @@ -119,7 +128,6 @@ void k28_state::machine_start() save_item(NAME(m_display_wait)); save_item(NAME(m_display_state)); - /* save_item(NAME(m_display_cache)); */ // don't save! save_item(NAME(m_display_decay)); save_item(NAME(m_display_segmask)); @@ -168,11 +176,9 @@ void k28_state::power_off() void k28_state::display_update() { - u32 active_state[0x20]; - for (int y = 0; y < m_display_maxy; y++) { - active_state[y] = 0; + u32 active_state = 0; for (int x = 0; x <= m_display_maxx; x++) { @@ -182,41 +188,19 @@ void k28_state::display_update() // determine active state u32 ds = (m_display_decay[y][x] != 0) ? 1 : 0; - active_state[y] |= (ds << x); - } - } + active_state |= (ds << x); - // on difference, send to output - for (int y = 0; y < m_display_maxy; y++) - if (m_display_cache[y] != active_state[y]) - { - if (m_display_segmask[y] != 0) - output().set_digit_value(y, active_state[y] & m_display_segmask[y]); - - const int mul = (m_display_maxx <= 10) ? 10 : 100; - for (int x = 0; x <= m_display_maxx; x++) - { - int state = active_state[y] >> x & 1; - char buf1[0x10]; // lampyx - char buf2[0x10]; // y.x - - if (x == m_display_maxx) - { - // always-on if selected - sprintf(buf1, "lamp%da", y); - sprintf(buf2, "%d.a", y); - } - else - { - sprintf(buf1, "lamp%d", y * mul + x); - sprintf(buf2, "%d.%d", y, x); - } - output().set_value(buf1, state); - output().set_value(buf2, state); - } + // output to y.x, or y.a when always-on + if (x != m_display_maxx) + m_out_x[y][x] = ds; + else + m_out_a[y] = ds; } - memcpy(m_display_cache, active_state, sizeof(m_display_cache)); + // output to digity + if (m_display_segmask[y] != 0) + m_out_digit[y] = active_state & m_display_segmask[y]; + } } TIMER_DEVICE_CALLBACK_MEMBER(k28_state::display_decay_tick) |