summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/diexec.c
diff options
context:
space:
mode:
author Aaron Giles <aaron@aarongiles.com>2010-08-26 15:21:19 +0000
committer Aaron Giles <aaron@aarongiles.com>2010-08-26 15:21:19 +0000
commit47dd9fe5680add9e438e75d71ce476b082382fdf (patch)
tree55f9ab6e9fe1351cbff6992924197ed9a6a33e26 /src/emu/diexec.c
parent33e4664bb21d437c5b8fee3c470b00084d0d9d8a (diff)
De-converted MACHINE_DRIVER from tokens back to constructor functions, regaining
type safety. If legacy devices still use inline data, those types are not checked. However, new devices no longer have access to the generic m_inline_data. Instead their MDRV_* macros should map to calls to static functions in the device config class which downcast a generic device_config to the specific device config, and then set the appropriate values. This is not to be done inline in order to prevent further code bloat in the constructors. See eeprom/7474/i2cmem/okim6295 for examples. #ifdef'ed several unused machine driver definitions that weren't referenced.
Diffstat (limited to 'src/emu/diexec.c')
-rw-r--r--src/emu/diexec.c90
1 files changed, 51 insertions, 39 deletions
diff --git a/src/emu/diexec.c b/src/emu/diexec.c
index eb6dfe8eca5..4d34e6e4520 100644
--- a/src/emu/diexec.c
+++ b/src/emu/diexec.c
@@ -78,7 +78,7 @@ device_config_execute_interface::device_config_execute_interface(const machine_c
m_vblank_interrupts_per_frame(0),
m_vblank_interrupt_screen(NULL),
m_timed_interrupt(NULL),
- m_timed_interrupt_period(0)
+ m_timed_interrupt_period(attotime_zero)
{
}
@@ -93,6 +93,51 @@ device_config_execute_interface::~device_config_execute_interface()
//-------------------------------------------------
+// static_set_disable - configuration helper to
+// set the disabled state of a device
+//-------------------------------------------------
+
+void device_config_execute_interface::static_set_disable(device_config *device)
+{
+ device_config_execute_interface *exec = dynamic_cast<device_config_execute_interface *>(device);
+ if (exec == NULL)
+ throw emu_fatalerror("MDRV_DEVICE_DISABLE called on device '%s' with no execute interface", device->tag());
+ exec->m_disabled = true;
+}
+
+
+//-------------------------------------------------
+// static_set_vblank_int - configuration helper
+// to set up VBLANK interrupts on the device
+//-------------------------------------------------
+
+void device_config_execute_interface::static_set_vblank_int(device_config *device, device_interrupt_func function, const char *tag, int rate)
+{
+ device_config_execute_interface *exec = dynamic_cast<device_config_execute_interface *>(device);
+ if (exec == NULL)
+ throw emu_fatalerror("MDRV_DEVICE_VBLANK_INT called on device '%s' with no execute interface", device->tag());
+ exec->m_vblank_interrupt = function;
+ exec->m_vblank_interrupts_per_frame = rate;
+ exec->m_vblank_interrupt_screen = tag;
+}
+
+
+//-------------------------------------------------
+// static_set_periodic_int - configuration helper
+// to set up periodic interrupts on the device
+//-------------------------------------------------
+
+void device_config_execute_interface::static_set_periodic_int(device_config *device, device_interrupt_func function, attotime rate)
+{
+ device_config_execute_interface *exec = dynamic_cast<device_config_execute_interface *>(device);
+ if (exec == NULL)
+ throw emu_fatalerror("MDRV_DEVICE_PERIODIC_INT called on device '%s' with no execute interface", device->tag());
+ exec->m_timed_interrupt = function;
+ exec->m_timed_interrupt_period = rate;
+}
+
+
+//-------------------------------------------------
// execute_clocks_to_cycles - convert the number
// of clocks to cycles, rounding down if necessary
//-------------------------------------------------
@@ -161,39 +206,6 @@ UINT32 device_config_execute_interface::execute_default_irq_vector() const
//-------------------------------------------------
-// interface_process_token - token processing for
-// the sound interface
-//-------------------------------------------------
-
-bool device_config_execute_interface::interface_process_token(UINT32 entrytype, const machine_config_token *&tokens)
-{
- switch (entrytype)
- {
- // disable a device
- case MCONFIG_TOKEN_DIEXEC_DISABLE:
- m_disabled = true;
- return true;
-
- // VBLANK interrupt
- case MCONFIG_TOKEN_DIEXEC_VBLANK_INT:
- TOKEN_UNGET_UINT32(tokens);
- TOKEN_GET_UINT32_UNPACK2(tokens, entrytype, 8, m_vblank_interrupts_per_frame, 24);
- m_vblank_interrupt = TOKEN_GET_PTR(tokens, cpu_interrupt);
- m_vblank_interrupt_screen = TOKEN_GET_STRING(tokens);
- return true;
-
- // timed interrupt
- case MCONFIG_TOKEN_DIEXEC_PERIODIC_INT:
- m_timed_interrupt = TOKEN_GET_PTR(tokens, cpu_interrupt);
- TOKEN_EXTRACT_UINT64(tokens, m_timed_interrupt_period);
- return true;
- }
-
- return false;
-}
-
-
-//-------------------------------------------------
// interface_validity_check - validation for a
// device after the configuration has been
// constructed
@@ -234,12 +246,12 @@ bool device_config_execute_interface::interface_validity_check(const game_driver
error = true;
}
- if (m_timed_interrupt != NULL && m_timed_interrupt_period == 0)
+ if (m_timed_interrupt != NULL && attotime_compare(m_timed_interrupt_period, attotime_zero) == 0)
{
mame_printf_error("%s: %s device '%s' has a timer interrupt handler with 0 period!\n", driver.source_file, driver.name, devconfig->tag());
error = true;
}
- else if (m_timed_interrupt == NULL && m_timed_interrupt_period != 0)
+ else if (m_timed_interrupt == NULL && attotime_compare(m_timed_interrupt_period, attotime_zero) != 0)
{
mame_printf_error("%s: %s device '%s' has a no timer interrupt handler but has a non-0 period given!\n", driver.source_file, driver.name, devconfig->tag());
error = true;
@@ -548,7 +560,7 @@ void device_execute_interface::interface_pre_start()
// allocate timers if we need them
if (m_execute_config.m_vblank_interrupts_per_frame > 1)
m_partial_frame_timer = timer_alloc(&m_machine, static_trigger_partial_frame_interrupt, (void *)this);
- if (m_execute_config.m_timed_interrupt_period != 0)
+ if (attotime_compare(m_execute_config.m_timed_interrupt_period, attotime_zero) != 0)
m_timedint_timer = timer_alloc(&m_machine, static_trigger_periodic_interrupt, (void *)this);
// register for save states
@@ -624,9 +636,9 @@ void device_execute_interface::interface_post_reset()
}
// reconfigure periodic interrupts
- if (m_execute_config.m_timed_interrupt_period != 0)
+ if (attotime_compare(m_execute_config.m_timed_interrupt_period, attotime_zero) != 0)
{
- attotime timedint_period = UINT64_ATTOTIME_TO_ATTOTIME(m_execute_config.m_timed_interrupt_period);
+ attotime timedint_period = m_execute_config.m_timed_interrupt_period;
assert(m_timedint_timer != NULL);
timer_adjust_periodic(m_timedint_timer, timedint_period, 0, timedint_period);
}