mirror of https://github.com/mgba-emu/mgba.git
Core: A few micro-optimizations
This commit is contained in:
parent
2c2a7ca436
commit
ed3a3b2fab
|
@ -53,19 +53,19 @@ void mTimingDeschedule(struct mTiming* timing, struct mTimingEvent* event) {
|
|||
}
|
||||
}
|
||||
|
||||
void mTimingTick(struct mTiming* timing, int32_t cycles) {
|
||||
int32_t mTimingTick(struct mTiming* timing, int32_t cycles) {
|
||||
timing->masterCycles += cycles;
|
||||
uint32_t masterCycles = timing->masterCycles;
|
||||
while (mTimingEventListSize(&timing->events)) {
|
||||
struct mTimingEvent* next = *mTimingEventListGetPointer(&timing->events, 0);
|
||||
int32_t nextWhen = next->when - masterCycles;
|
||||
if (nextWhen > 0) {
|
||||
*timing->nextEvent = nextWhen;
|
||||
return;
|
||||
return nextWhen;
|
||||
}
|
||||
mTimingEventListShift(&timing->events, 0, 1);
|
||||
next->callback(timing, next->context, -nextWhen);
|
||||
}
|
||||
return *timing->nextEvent;
|
||||
}
|
||||
|
||||
int32_t mTimingNextEvent(struct mTiming* timing) {
|
||||
|
|
|
@ -32,7 +32,7 @@ void mTimingDeinit(struct mTiming* timing);
|
|||
void mTimingClear(struct mTiming* timing);
|
||||
void mTimingSchedule(struct mTiming* timing, struct mTimingEvent*, int32_t when);
|
||||
void mTimingDeschedule(struct mTiming* timing, struct mTimingEvent*);
|
||||
void mTimingTick(struct mTiming* timing, int32_t cycles);
|
||||
int32_t mTimingTick(struct mTiming* timing, int32_t cycles);
|
||||
int32_t mTimingNextEvent(struct mTiming* timing);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -546,10 +546,7 @@ void GBProcessEvents(struct LR35902Core* cpu) {
|
|||
}
|
||||
}
|
||||
|
||||
mTimingTick(&gb->timing, cycles);
|
||||
nextEvent = cpu->nextEvent;
|
||||
|
||||
cpu->nextEvent = nextEvent;
|
||||
cpu->nextEvent = mTimingTick(&gb->timing, cycles);
|
||||
|
||||
if (cpu->halted) {
|
||||
cpu->cycles = cpu->nextEvent;
|
||||
|
|
|
@ -235,8 +235,8 @@ static void GBAProcessEvents(struct ARMCore* cpu) {
|
|||
gba->springIRQ = 0;
|
||||
}
|
||||
|
||||
int32_t nextEvent;
|
||||
do {
|
||||
int32_t nextEvent = cpu->nextEvent;
|
||||
while (cpu->cycles >= nextEvent) {
|
||||
int32_t cycles = cpu->cycles;
|
||||
int32_t testEvent;
|
||||
|
||||
|
@ -250,8 +250,7 @@ static void GBAProcessEvents(struct ARMCore* cpu) {
|
|||
#endif
|
||||
nextEvent = cycles;
|
||||
do {
|
||||
mTimingTick(&gba->timing, nextEvent);
|
||||
nextEvent = cpu->nextEvent;
|
||||
nextEvent = mTimingTick(&gba->timing, nextEvent);
|
||||
} while (gba->cpuBlocked);
|
||||
|
||||
testEvent = GBASIOProcessEvents(&gba->sio, cycles);
|
||||
|
@ -275,7 +274,7 @@ static void GBAProcessEvents(struct ARMCore* cpu) {
|
|||
mLOG(GBA, FATAL, "Negative cycles will pass: %i", nextEvent);
|
||||
}
|
||||
#endif
|
||||
} while (cpu->cycles >= nextEvent);
|
||||
}
|
||||
}
|
||||
|
||||
void GBAAttachDebugger(struct GBA* gba, struct mDebugger* debugger) {
|
||||
|
|
Loading…
Reference in New Issue