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;
|
timing->masterCycles += cycles;
|
||||||
uint32_t masterCycles = timing->masterCycles;
|
uint32_t masterCycles = timing->masterCycles;
|
||||||
while (mTimingEventListSize(&timing->events)) {
|
while (mTimingEventListSize(&timing->events)) {
|
||||||
struct mTimingEvent* next = *mTimingEventListGetPointer(&timing->events, 0);
|
struct mTimingEvent* next = *mTimingEventListGetPointer(&timing->events, 0);
|
||||||
int32_t nextWhen = next->when - masterCycles;
|
int32_t nextWhen = next->when - masterCycles;
|
||||||
if (nextWhen > 0) {
|
if (nextWhen > 0) {
|
||||||
*timing->nextEvent = nextWhen;
|
return nextWhen;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
mTimingEventListShift(&timing->events, 0, 1);
|
mTimingEventListShift(&timing->events, 0, 1);
|
||||||
next->callback(timing, next->context, -nextWhen);
|
next->callback(timing, next->context, -nextWhen);
|
||||||
}
|
}
|
||||||
|
return *timing->nextEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mTimingNextEvent(struct mTiming* timing) {
|
int32_t mTimingNextEvent(struct mTiming* timing) {
|
||||||
|
|
|
@ -32,7 +32,7 @@ void mTimingDeinit(struct mTiming* timing);
|
||||||
void mTimingClear(struct mTiming* timing);
|
void mTimingClear(struct mTiming* timing);
|
||||||
void mTimingSchedule(struct mTiming* timing, struct mTimingEvent*, int32_t when);
|
void mTimingSchedule(struct mTiming* timing, struct mTimingEvent*, int32_t when);
|
||||||
void mTimingDeschedule(struct mTiming* timing, struct mTimingEvent*);
|
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);
|
int32_t mTimingNextEvent(struct mTiming* timing);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -546,10 +546,7 @@ void GBProcessEvents(struct LR35902Core* cpu) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mTimingTick(&gb->timing, cycles);
|
cpu->nextEvent = mTimingTick(&gb->timing, cycles);
|
||||||
nextEvent = cpu->nextEvent;
|
|
||||||
|
|
||||||
cpu->nextEvent = nextEvent;
|
|
||||||
|
|
||||||
if (cpu->halted) {
|
if (cpu->halted) {
|
||||||
cpu->cycles = cpu->nextEvent;
|
cpu->cycles = cpu->nextEvent;
|
||||||
|
|
|
@ -235,8 +235,8 @@ static void GBAProcessEvents(struct ARMCore* cpu) {
|
||||||
gba->springIRQ = 0;
|
gba->springIRQ = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t nextEvent;
|
int32_t nextEvent = cpu->nextEvent;
|
||||||
do {
|
while (cpu->cycles >= nextEvent) {
|
||||||
int32_t cycles = cpu->cycles;
|
int32_t cycles = cpu->cycles;
|
||||||
int32_t testEvent;
|
int32_t testEvent;
|
||||||
|
|
||||||
|
@ -250,8 +250,7 @@ static void GBAProcessEvents(struct ARMCore* cpu) {
|
||||||
#endif
|
#endif
|
||||||
nextEvent = cycles;
|
nextEvent = cycles;
|
||||||
do {
|
do {
|
||||||
mTimingTick(&gba->timing, nextEvent);
|
nextEvent = mTimingTick(&gba->timing, nextEvent);
|
||||||
nextEvent = cpu->nextEvent;
|
|
||||||
} while (gba->cpuBlocked);
|
} while (gba->cpuBlocked);
|
||||||
|
|
||||||
testEvent = GBASIOProcessEvents(&gba->sio, cycles);
|
testEvent = GBASIOProcessEvents(&gba->sio, cycles);
|
||||||
|
@ -275,7 +274,7 @@ static void GBAProcessEvents(struct ARMCore* cpu) {
|
||||||
mLOG(GBA, FATAL, "Negative cycles will pass: %i", nextEvent);
|
mLOG(GBA, FATAL, "Negative cycles will pass: %i", nextEvent);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
} while (cpu->cycles >= nextEvent);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GBAAttachDebugger(struct GBA* gba, struct mDebugger* debugger) {
|
void GBAAttachDebugger(struct GBA* gba, struct mDebugger* debugger) {
|
||||||
|
|
Loading…
Reference in New Issue