GBA: Better debug logging if event processing breaks
Jeffrey Pfau jeffrey@endrift.com
Sun, 04 Sep 2016 09:32:07 -0700
2 files changed,
19 insertions(+),
5 deletions(-)
M
src/gba/gba.c
→
src/gba/gba.c
@@ -234,33 +234,41 @@ #endif
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 @@
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); }