From d9d89fad2b10df544fd882d3c9999c8905f9d533 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Mon, 27 Aug 2018 18:08:14 -0700 Subject: [PATCH] Core: Fix ordering events when scheduling during events --- CHANGES | 1 + src/core/timing.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 3181ae785..3637665aa 100644 --- a/CHANGES +++ b/CHANGES @@ -46,6 +46,7 @@ Bugfixes: - GB, GBA Savedata: Fix savestate loading overwriting saves on reset - GBA Video: Make layer disabling work consistently - GB: Fix IRQ disabling on the same T-cycle as an assert + - Core: Fix ordering events when scheduling during events Misc: - GBA Timer: Use global cycles for timers - GBA: Extend oddly-sized ROMs to full address space (fixes mgba.io/i/722) diff --git a/src/core/timing.c b/src/core/timing.c index adbbfbbf8..e82efe892 100644 --- a/src/core/timing.c +++ b/src/core/timing.c @@ -33,7 +33,7 @@ void mTimingSchedule(struct mTiming* timing, struct mTimingEvent* event, int32_t unsigned priority = event->priority; while (next) { int32_t nextWhen = next->when - timing->masterCycles; - if (nextWhen > when || (nextWhen == when && next->priority > priority)) { + if (nextWhen > nextEvent || (nextWhen == nextEvent && next->priority > priority)) { break; } previous = &next->next;