summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/machine/ripple_counter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/machine/ripple_counter.cpp')
-rw-r--r--src/devices/machine/ripple_counter.cpp64
1 files changed, 22 insertions, 42 deletions
diff --git a/src/devices/machine/ripple_counter.cpp b/src/devices/machine/ripple_counter.cpp
index 96ce53aeec6..6c60d7238a5 100644
--- a/src/devices/machine/ripple_counter.cpp
+++ b/src/devices/machine/ripple_counter.cpp
@@ -15,7 +15,7 @@
**********************************************************************/
#include "emu.h"
-#include "machine/ripple_counter.h"
+#include "ripple_counter.h"
//**************************************************************************
// GLOBAL VARIABLES
@@ -33,16 +33,16 @@ DEFINE_DEVICE_TYPE(RIPPLE_COUNTER, ripple_counter_device, "ripple_counter", "Gen
// ripple_counter_device - constructor
//-------------------------------------------------
-ripple_counter_device::ripple_counter_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
- : device_t(mconfig, RIPPLE_COUNTER, tag, owner, clock),
- device_rom_interface(mconfig, *this),
- m_count_out_cb(*this),
- m_rom_out_cb(*this),
- m_count_timer(nullptr),
- m_count_mask(0),
- m_count(1),
- m_clk(false),
- m_reset(false)
+ripple_counter_device::ripple_counter_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) :
+ device_t(mconfig, RIPPLE_COUNTER, tag, owner, clock),
+ device_rom_interface(mconfig, *this),
+ m_count_out_cb(*this),
+ m_rom_out_cb(*this),
+ m_count_timer(nullptr),
+ m_count_mask(0),
+ m_count(1),
+ m_clk(false),
+ m_reset(false)
{
}
@@ -54,7 +54,7 @@ ripple_counter_device::ripple_counter_device(const machine_config &mconfig, cons
device_memory_interface::space_config_vector ripple_counter_device::memory_space_config() const
{
- if (m_rom_out_cb.isnull())
+ if (m_rom_out_cb.isunset())
return space_config_vector();
else
return device_rom_interface::memory_space_config();
@@ -74,27 +74,13 @@ void ripple_counter_device::device_validity_check(validity_checker &valid) const
//-------------------------------------------------
-// device_resolve_objects - resolve objects that
-// may be needed for other devices to set
-// initial conditions at start time
-//-------------------------------------------------
-
-void ripple_counter_device::device_resolve_objects()
-{
- // resolve callbacks
- m_count_out_cb.resolve_safe();
- m_rom_out_cb.resolve();
-}
-
-
-//-------------------------------------------------
// device_start - device-specific startup
//-------------------------------------------------
void ripple_counter_device::device_start()
{
// initialize timers
- m_count_timer = timer_alloc(TIMER_COUNT);
+ m_count_timer = timer_alloc(FUNC(ripple_counter_device::advance_counter), this);
// register internal state
save_item(NAME(m_count));
@@ -116,11 +102,11 @@ void ripple_counter_device::device_clock_changed()
//-------------------------------------------------
-// rom_bank_updated - called when the ROM bank
-// is changed
+// rom_bank_post_change - called after the ROM
+// bank is changed
//-------------------------------------------------
-void ripple_counter_device::rom_bank_updated()
+void ripple_counter_device::rom_bank_post_change()
{
m_rom_out_cb(read_byte(m_count));
}
@@ -135,7 +121,7 @@ void ripple_counter_device::set_count(u32 count)
{
m_count = count;
m_count_out_cb(count);
- if (!m_rom_out_cb.isnull())
+ if (!m_rom_out_cb.isunset())
m_rom_out_cb(read_byte(count));
}
@@ -144,7 +130,7 @@ void ripple_counter_device::set_count(u32 count)
// clock_w - handle falling-edge clock input
//-------------------------------------------------
-WRITE_LINE_MEMBER(ripple_counter_device::clock_w)
+void ripple_counter_device::clock_w(int state)
{
if (m_clk != bool(state))
{
@@ -159,7 +145,7 @@ WRITE_LINE_MEMBER(ripple_counter_device::clock_w)
// reset_w - handle active-high reset input
//-------------------------------------------------
-WRITE_LINE_MEMBER(ripple_counter_device::reset_w)
+void ripple_counter_device::reset_w(int state)
{
if (m_reset != bool(state))
{
@@ -174,16 +160,10 @@ WRITE_LINE_MEMBER(ripple_counter_device::reset_w)
//-------------------------------------------------
-// device_timer - called whenever a device timer
-// fires
+// advance_counter -
//-------------------------------------------------
-void ripple_counter_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+TIMER_CALLBACK_MEMBER(ripple_counter_device::advance_counter)
{
- switch (id)
- {
- case TIMER_COUNT:
- set_count((m_count + 1) & m_count_mask);
- break;
- }
+ set_count((m_count + 1) & m_count_mask);
}