summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/diexec.cpp
diff options
context:
space:
mode:
author hap <happppp@users.noreply.github.com>2024-11-16 15:33:25 +0100
committer hap <happppp@users.noreply.github.com>2024-11-16 15:37:37 +0100
commitea02851fc85a5b8f6d4b645484419763573e636b (patch)
treea5ab70d84a382957597fe7be9b47fe8f28a6d06c /src/emu/diexec.cpp
parent2b37fd59cdd7376eb6e40174222e85d1030e24c2 (diff)
diexec: don't eat negative cycles with abort_timeslice when icount<0
Diffstat (limited to 'src/emu/diexec.cpp')
-rw-r--r--src/emu/diexec.cpp22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/emu/diexec.cpp b/src/emu/diexec.cpp
index 60ba1e7e8ba..4a9f50e152a 100644
--- a/src/emu/diexec.cpp
+++ b/src/emu/diexec.cpp
@@ -98,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;
}
}
@@ -128,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;
@@ -143,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();
@@ -656,7 +657,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
@@ -689,7 +690,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++)
{
@@ -698,7 +700,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);