diff options
Diffstat (limited to 'src/mame/drivers/hh_amis2k.cpp')
-rw-r--r-- | src/mame/drivers/hh_amis2k.cpp | 130 |
1 files changed, 9 insertions, 121 deletions
diff --git a/src/mame/drivers/hh_amis2k.cpp b/src/mame/drivers/hh_amis2k.cpp index 4eb4046608f..8d4bdddb745 100644 --- a/src/mame/drivers/hh_amis2k.cpp +++ b/src/mame/drivers/hh_amis2k.cpp @@ -9,12 +9,11 @@ - were any other handhelds with this MCU released? - wildfire sound can be improved, volume decay should be more steep at the start, and the pitch sounds wrong too (latter is an MCU emulation problem) - - leds are sometimes strobed faster/longer to appear at a different brightness, - eg. wildfire bumpers ***************************************************************************/ #include "emu.h" +#include "includes/screenless.h" #include "cpu/amis2000/amis2000.h" #include "machine/timer.h" @@ -27,28 +26,19 @@ //#include "hh_amis2k_test.lh" // common test-layout - use external artwork -class hh_amis2k_state : public driver_device +class hh_amis2k_state : public screenless_state { public: hh_amis2k_state(const machine_config &mconfig, device_type type, const char *tag) : - driver_device(mconfig, type, tag), + screenless_state(mconfig, type, tag), m_maincpu(*this, "maincpu"), 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_speaker(*this, "speaker"), - m_display_wait(33), - m_display_maxy(1), - m_display_maxx(0) + m_speaker(*this, "speaker") { } // devices required_device<amis2000_base_device> m_maincpu; optional_ioport_array<4> m_inp_matrix; // max 4 - output_finder<0x20, 0x20> m_out_x; - output_finder<0x20> m_out_a; - output_finder<0x20> m_out_digit; optional_device<speaker_sound_device> m_speaker; // misc common @@ -59,21 +49,6 @@ public: u8 read_inputs(int columns); - // display common - int m_display_wait; // led/lamp off-delay in milliseconds (default 33ms) - int m_display_maxy; // display matrix number of rows - int m_display_maxx; // display matrix number of columns (max 31 for now) - - 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 - u8 m_display_decay[0x20][0x20]; // (internal use) - - TIMER_DEVICE_CALLBACK_MEMBER(display_decay_tick); - void display_update(); - void set_display_size(int maxx, int maxy); - void set_display_segmask(u32 digits, u32 mask); - void display_matrix(int maxx, int maxy, u32 setx, u32 sety, bool update = true); - protected: virtual void machine_start() override; virtual void machine_reset() override; @@ -84,30 +59,15 @@ protected: void hh_amis2k_state::machine_start() { - // resolve handlers - m_out_x.resolve(); - m_out_a.resolve(); - m_out_digit.resolve(); + screenless_state::machine_start(); // zerofill - memset(m_display_state, 0, sizeof(m_display_state)); - memset(m_display_decay, 0, sizeof(m_display_decay)); - memset(m_display_segmask, 0, sizeof(m_display_segmask)); - m_a = 0; m_d = 0; m_f = 0; m_inp_mux = 0; // register for savestates - save_item(NAME(m_display_maxy)); - save_item(NAME(m_display_maxx)); - save_item(NAME(m_display_wait)); - - save_item(NAME(m_display_state)); - save_item(NAME(m_display_decay)); - save_item(NAME(m_display_segmask)); - save_item(NAME(m_a)); save_item(NAME(m_d)); save_item(NAME(m_f)); @@ -126,80 +86,6 @@ void hh_amis2k_state::machine_reset() ***************************************************************************/ -// The device may strobe the outputs very fast, it is unnoticeable to the user. -// To prevent flickering here, we need to simulate a decay. - -void hh_amis2k_state::display_update() -{ - for (int y = 0; y < m_display_maxy; y++) - { - u32 active_state = 0; - - for (int x = 0; x <= m_display_maxx; x++) - { - // turn on powered segments - if (m_display_state[y] >> x & 1) - m_display_decay[y][x] = m_display_wait; - - // determine active state - u32 ds = (m_display_decay[y][x] != 0) ? 1 : 0; - active_state |= (ds << x); - - // 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; - } - - // output to digity - if (m_display_segmask[y] != 0) - m_out_digit[y] = active_state & m_display_segmask[y]; - } -} - -TIMER_DEVICE_CALLBACK_MEMBER(hh_amis2k_state::display_decay_tick) -{ - // slowly turn off unpowered segments - for (int y = 0; y < m_display_maxy; y++) - for (int x = 0; x <= m_display_maxx; x++) - if (m_display_decay[y][x] != 0) - m_display_decay[y][x]--; - - display_update(); -} - -void hh_amis2k_state::set_display_size(int maxx, int maxy) -{ - m_display_maxx = maxx; - m_display_maxy = maxy; -} - -void hh_amis2k_state::set_display_segmask(u32 digits, u32 mask) -{ - // set a segment mask per selected digit, but leave unselected ones alone - for (int i = 0; i < 0x20; i++) - { - if (digits & 1) - m_display_segmask[i] = mask; - digits >>= 1; - } -} - -void hh_amis2k_state::display_matrix(int maxx, int maxy, u32 setx, u32 sety, bool update) -{ - set_display_size(maxx, maxy); - - // update current state - u32 mask = (1 << maxx) - 1; - for (int y = 0; y < maxy; y++) - m_display_state[y] = (sety >> y & 1) ? ((setx & mask) | (1 << maxx)) : 0; - - if (update) - display_update(); -} - - // generic input handlers u8 hh_amis2k_state::read_inputs(int columns) @@ -258,7 +144,10 @@ class wildfire_state : public hh_amis2k_state public: wildfire_state(const machine_config &mconfig, device_type type, const char *tag) : hh_amis2k_state(mconfig, type, tag) - { } + { + // bumpers are dimmed + set_display_levels(2, 0.015, 0.1); + } void prepare_display(); DECLARE_WRITE8_MEMBER(write_d); @@ -360,7 +249,6 @@ void wildfire_state::wildfire(machine_config &config) m_maincpu->write_a().set(FUNC(wildfire_state::write_a)); m_maincpu->write_f().set(FUNC(wildfire_state::write_f)); - TIMER(config, "display_decay").configure_periodic(FUNC(hh_amis2k_state::display_decay_tick), attotime::from_msec(1)); config.set_default_layout(layout_wildfire); /* sound hardware */ |