Core: Add mTimingScheduleAbsolute

This commit is contained in:
Vicki Pfau 2020-08-10 15:57:38 -07:00
parent 6ab8193279
commit 549787227a
3 changed files with 6 additions and 2 deletions

View File

@ -35,6 +35,7 @@ void mTimingInit(struct mTiming* timing, int32_t* relativeCycles, int32_t* nextE
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);

View File

@ -50,6 +50,10 @@ void mTimingSchedule(struct mTiming* timing, struct mTimingEvent* event, int32_t
*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;

View File

@ -109,9 +109,8 @@ void GBATimerUpdateRegister(struct GBA* gba, int timer, int32_t cyclesLate) {
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) {