summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/diexec.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/emu/diexec.cpp')
-rw-r--r--src/emu/diexec.cpp72
1 files changed, 28 insertions, 44 deletions
diff --git a/src/emu/diexec.cpp b/src/emu/diexec.cpp
index 4b06edc36d5..1cd5266c518 100644
--- a/src/emu/diexec.cpp
+++ b/src/emu/diexec.cpp
@@ -70,8 +70,6 @@ device_execute_interface::device_execute_interface(const machine_config &mconfig
, m_attoseconds_per_cycle(0)
, m_spin_end_timer(nullptr)
{
- memset(&m_localtime, 0, sizeof(m_localtime));
-
// configure the fast accessor
assert(!device.interfaces().m_execute);
device.interfaces().m_execute = this;
@@ -100,12 +98,11 @@ void device_execute_interface::abort_timeslice() noexcept
return;
// swallow the remaining cycles
- if (m_icountptr != nullptr)
+ if (m_icountptr != nullptr && *m_icountptr > 0)
{
- int delta = *m_icountptr;
- m_cycles_stolen += delta;
- m_cycles_running -= delta;
- *m_icountptr -= delta;
+ m_cycles_stolen += *m_icountptr;
+ m_cycles_running -= *m_icountptr;
+ *m_icountptr = 0;
}
}
@@ -130,7 +127,8 @@ void device_execute_interface::suspend_resume_changed()
void device_execute_interface::suspend(u32 reason, bool eatcycles)
{
-if (TEMPLOG) printf("suspend %s (%X)\n", device().tag(), reason);
+ if (TEMPLOG) printf("suspend %s (%X)\n", device().tag(), reason);
+
// set the suspend reason and eat cycles flag
m_nextsuspend |= reason;
m_nexteatcycles = eatcycles;
@@ -145,7 +143,8 @@ if (TEMPLOG) printf("suspend %s (%X)\n", device().tag(), reason);
void device_execute_interface::resume(u32 reason)
{
-if (TEMPLOG) printf("resume %s (%X)\n", device().tag(), reason);
+ if (TEMPLOG) printf("resume %s (%X)\n", device().tag(), reason);
+
// clear the suspend reason and eat cycles flag
m_nextsuspend &= ~reason;
suspend_resume_changed();
@@ -285,17 +284,6 @@ u32 device_execute_interface::execute_max_cycles() const noexcept
//-------------------------------------------------
-// execute_input_lines - return the total number
-// of input lines for the device
-//-------------------------------------------------
-
-u32 device_execute_interface::execute_input_lines() const noexcept
-{
- return 0;
-}
-
-
-//-------------------------------------------------
// execute_default_irq_vector - return the default
// IRQ vector when an acknowledge is processed
//-------------------------------------------------
@@ -318,18 +306,6 @@ bool device_execute_interface::execute_input_edge_triggered(int linenum) const n
//-------------------------------------------------
-// execute_burn - called after we consume a bunch
-// of cycles for artifical reasons (such as
-// spinning devices for performance optimization)
-//-------------------------------------------------
-
-void device_execute_interface::execute_burn(s32 cycles)
-{
- // by default, do nothing
-}
-
-
-//-------------------------------------------------
// execute_set_input - called when a synchronized
// input is changed
//-------------------------------------------------
@@ -462,7 +438,7 @@ void device_execute_interface::interface_post_reset()
if (m_vblank_interrupt_screen != nullptr)
{
// get the screen that will trigger the VBLANK
- screen_device * screen = device().siblingdevice<screen_device>(m_vblank_interrupt_screen);
+ screen_device *const screen = device().siblingdevice<screen_device>(m_vblank_interrupt_screen);
assert(screen != nullptr);
screen->register_vblank_callback(vblank_state_delegate(&device_execute_interface::on_vblank, this));
@@ -537,7 +513,7 @@ int device_execute_interface::standard_irq_callback(int irqline, offs_t pc)
vector = m_driver_irq(device(), irqline);
// notify the debugger
- if (device().machine().debug_flags & DEBUG_FLAG_ENABLED)
+ if (debugger_enabled())
device().debug()->interrupt_hook(irqline, pc);
return vector;
@@ -608,21 +584,28 @@ TIMER_CALLBACK_MEMBER(device_execute_interface::trigger_periodic_interrupt)
void device_execute_interface::pulse_input_line(int irqline, const attotime &duration)
{
- // treat instantaneous pulses as ASSERT+CLEAR
+ const attotime expiry = m_pulse_end_timers[irqline]->expire();
if (duration == attotime::zero)
{
- if (irqline != INPUT_LINE_RESET && !input_edge_triggered(irqline))
+ // treat instantaneous pulses as ASSERT+CLEAR
+ if ((irqline != INPUT_LINE_RESET) && !input_edge_triggered(irqline))
throw emu_fatalerror("device '%s': zero-width pulse is not allowed for input line %d\n", device().tag(), irqline);
- set_input_line(irqline, ASSERT_LINE);
- set_input_line(irqline, CLEAR_LINE);
+ if (expiry.is_never() || (expiry <= m_scheduler->time()))
+ {
+ set_input_line(irqline, ASSERT_LINE);
+ set_input_line(irqline, CLEAR_LINE);
+ }
}
else
{
- set_input_line(irqline, ASSERT_LINE);
+ const attotime target_time = local_time() + duration;
+ if (expiry.is_never() || (target_time > expiry))
+ {
+ set_input_line(irqline, ASSERT_LINE);
- attotime target_time = local_time() + duration;
- m_pulse_end_timers[irqline]->adjust(target_time - m_scheduler->time(), irqline);
+ m_pulse_end_timers[irqline]->adjust(target_time - m_scheduler->time(), irqline);
+ }
}
}
@@ -681,7 +664,7 @@ void device_execute_interface::device_input::set_state_synced(int state, int vec
{
LOG(("set_state_synced('%s',%d,%d,%02x)\n", m_execute->device().tag(), m_linenum, state, vector));
-if (TEMPLOG) printf("setline(%s,%d,%d,%d)\n", m_execute->device().tag(), m_linenum, state, (vector == USE_STORED_VECTOR) ? 0 : vector);
+ if (TEMPLOG) printf("setline(%s,%d,%d,%d)\n", m_execute->device().tag(), m_linenum, state, (vector == USE_STORED_VECTOR) ? 0 : vector);
assert(state == ASSERT_LINE || state == HOLD_LINE || state == CLEAR_LINE);
// if we're full of events, flush the queue and log a message
@@ -714,7 +697,8 @@ if (TEMPLOG) printf("setline(%s,%d,%d,%d)\n", m_execute->device().tag(), m_linen
TIMER_CALLBACK_MEMBER(device_execute_interface::device_input::empty_event_queue)
{
-if (TEMPLOG) printf("empty_queue(%s,%d,%d)\n", m_execute->device().tag(), m_linenum, m_qindex);
+ if (TEMPLOG) printf("empty_queue(%s,%d,%d)\n", m_execute->device().tag(), m_linenum, m_qindex);
+
// loop over all events
for (int curevent = 0; curevent < m_qindex; curevent++)
{
@@ -723,7 +707,7 @@ if (TEMPLOG) printf("empty_queue(%s,%d,%d)\n", m_execute->device().tag(), m_line
// set the input line state and vector
m_curstate = input_event & 0xff;
m_curvector = input_event >> 8;
-if (TEMPLOG) printf(" (%d,%d)\n", m_curstate, m_curvector);
+ if (TEMPLOG) printf(" (%d,%d)\n", m_curstate, m_curvector);
assert(m_curstate == ASSERT_LINE || m_curstate == HOLD_LINE || m_curstate == CLEAR_LINE);