mirror of
https://github.com/mgba-emu/mgba.git
synced 2026-10-12 02:18:55 +00:00
Core: Let interrupted timing properly exit early
This commit is contained in:
+17
-12
@@ -39,12 +39,16 @@ void mTimingSchedule(struct mTiming* timing, struct mTimingEvent* event, int32_t
|
||||
if (nextEvent < *timing->nextEvent) {
|
||||
*timing->nextEvent = nextEvent;
|
||||
}
|
||||
struct mTimingEvent** previous;
|
||||
struct mTimingEvent* next;
|
||||
if (timing->reroot) {
|
||||
timing->root = timing->reroot;
|
||||
timing->reroot = NULL;
|
||||
previous = &timing->reroot;
|
||||
next = timing->reroot;
|
||||
} else {
|
||||
previous = &timing->root;
|
||||
next = timing->root;
|
||||
}
|
||||
struct mTimingEvent** previous = &timing->root;
|
||||
struct mTimingEvent* next = timing->root;
|
||||
|
||||
unsigned priority = event->priority;
|
||||
while (next) {
|
||||
int32_t nextWhen = next->when - timing->masterCycles;
|
||||
@@ -63,12 +67,16 @@ void mTimingScheduleAbsolute(struct mTiming* timing, struct mTimingEvent* event,
|
||||
}
|
||||
|
||||
void mTimingDeschedule(struct mTiming* timing, struct mTimingEvent* event) {
|
||||
struct mTimingEvent** previous;
|
||||
struct mTimingEvent* next;
|
||||
if (timing->reroot) {
|
||||
timing->root = timing->reroot;
|
||||
timing->reroot = NULL;
|
||||
previous = &timing->reroot;
|
||||
next = timing->reroot;
|
||||
} else {
|
||||
previous = &timing->root;
|
||||
next = timing->root;
|
||||
}
|
||||
struct mTimingEvent** previous = &timing->root;
|
||||
struct mTimingEvent* next = timing->root;
|
||||
|
||||
while (next) {
|
||||
if (next == event) {
|
||||
*previous = next->next;
|
||||
@@ -105,13 +113,10 @@ int32_t mTimingTick(struct mTiming* timing, int32_t cycles) {
|
||||
timing->root = next->next;
|
||||
next->callback(timing, next->context, -nextWhen);
|
||||
}
|
||||
if (timing->reroot) {
|
||||
if (UNLIKELY(timing->reroot)) {
|
||||
timing->root = timing->reroot;
|
||||
timing->reroot = NULL;
|
||||
*timing->nextEvent = mTimingNextEvent(timing);
|
||||
if (*timing->nextEvent <= 0) {
|
||||
return mTimingTick(timing, 0);
|
||||
}
|
||||
}
|
||||
return *timing->nextEvent;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user