Core: Add mTimingScheduleAbsolute
Vicki Pfau vi@endrift.com
Mon, 10 Aug 2020 15:57:38 -0700
3 files changed,
6 insertions(+),
2 deletions(-)
M
include/mgba/core/timing.h
→
include/mgba/core/timing.h
@@ -35,6 +35,7 @@ void mTimingInit(struct mTiming* timing, int32_t* relativeCycles, int32_t* nextEvent);
void mTimingDeinit(struct mTiming* timing); void mTimingClear(struct mTiming* timing); void mTimingSchedule(struct mTiming* timing, struct mTimingEvent*, int32_t when); +void mTimingScheduleAbsolute(struct mTiming* timing, struct mTimingEvent*, int32_t when); void mTimingDeschedule(struct mTiming* timing, struct mTimingEvent*); bool mTimingIsScheduled(const struct mTiming* timing, const struct mTimingEvent*); int32_t mTimingTick(struct mTiming* timing, int32_t cycles);
M
src/core/timing.c
→
src/core/timing.c
@@ -50,6 +50,10 @@ event->next = next;
*previous = event; } +void mTimingScheduleAbsolute(struct mTiming* timing, struct mTimingEvent* event, int32_t when) { + mTimingSchedule(timing, event, when - mTimingCurrentTime(timing)); +} + void mTimingDeschedule(struct mTiming* timing, struct mTimingEvent* event) { if (timing->reroot) { timing->root = timing->reroot;
M
src/gba/timer.c
→
src/gba/timer.c
@@ -109,9 +109,8 @@ // Schedule next update
tickIncrement = (0x10000 - tickIncrement) << prescaleBits; currentTime += tickIncrement; currentTime &= ~tickMask; - currentTime -= mTimingCurrentTime(&gba->timing); mTimingDeschedule(&gba->timing, ¤tTimer->event); - mTimingSchedule(&gba->timing, ¤tTimer->event, currentTime); + mTimingScheduleAbsolute(&gba->timing, ¤tTimer->event, currentTime); } void GBATimerWriteTMCNT_LO(struct GBA* gba, int timer, uint16_t reload) {