all repos — mgba @ 549787227a488a4f52e30ee0b14cb9bf331b327c

mGBA Game Boy Advance Emulator

Core: Add mTimingScheduleAbsolute
Vicki Pfau vi@endrift.com
Mon, 10 Aug 2020 15:57:38 -0700
commit

549787227a488a4f52e30ee0b14cb9bf331b327c

parent

6ab819327919874595767598ccd10f1d34a36913

3 files changed, 6 insertions(+), 2 deletions(-)

jump to
M include/mgba/core/timing.hinclude/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.csrc/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.csrc/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, &currentTimer->event); - mTimingSchedule(&gba->timing, &currentTimer->event, currentTime); + mTimingScheduleAbsolute(&gba->timing, &currentTimer->event, currentTime); } void GBATimerWriteTMCNT_LO(struct GBA* gba, int timer, uint16_t reload) {