GBA: Better debug logging if event processing breaks

This commit is contained in:
Jeffrey Pfau 2016-09-04 09:32:07 -07:00
parent ee3edbbd19
commit 0293e723d8
2 changed files with 19 additions and 5 deletions

View File

@ -88,6 +88,7 @@ Misc:
- GUI: Increase scrolling speed
- Qt: Rearchitect game closing codepath
- Wii: Add pixelated resample filter
- GBA: Better debug logging if event processing breaks
0.4.1: (2016-07-11)
Bugfixes:

View File

@ -234,33 +234,41 @@ static void GBAProcessEvents(struct ARMCore* cpu) {
testEvent = GBAVideoProcessEvents(&gba->video, cycles);
if (testEvent < nextEvent) {
#ifndef NDEBUG
if (testEvent == 0) {
abort();
mLOG(GBA, ERROR, "Video requiring 0 cycles");
}
#endif
nextEvent = testEvent;
}
testEvent = GBAAudioProcessEvents(&gba->audio, cycles);
if (testEvent < nextEvent) {
#ifndef NDEBUG
if (testEvent == 0) {
abort();
mLOG(GBA, ERROR, "Audio requiring 0 cycles");
}
#endif
nextEvent = testEvent;
}
testEvent = GBATimersProcessEvents(gba, cycles);
if (testEvent < nextEvent) {
#ifndef NDEBUG
if (testEvent == 0) {
abort();
mLOG(GBA, ERROR, "Timers requiring 0 cycles");
}
#endif
nextEvent = testEvent;
}
testEvent = GBAMemoryRunDMAs(gba, cycles);
if (testEvent < nextEvent) {
#ifndef NDEBUG
if (testEvent == 0) {
abort();
mLOG(GBA, ERROR, "DMAs requiring 0 cycles");
}
#endif
nextEvent = testEvent;
}
@ -275,9 +283,14 @@ static void GBAProcessEvents(struct ARMCore* cpu) {
if (cpu->halted) {
cpu->cycles = cpu->nextEvent;
}
if (cpu->nextEvent == 0) {
if (nextEvent == 0) {
break;
}
#ifndef NDEBUG
else if (nextEvent < 0) {
mLOG(GBA, FATAL, "Negative cycles will pass: %i", nextEvent);
}
#endif
} while (cpu->cycles >= cpu->nextEvent);
}