all repos — mgba @ 6822b8cabe2bca29944fe88f18226f1b89eab055

mGBA Game Boy Advance Emulator

GBA: Ensure cycles never go negative
Jeffrey Pfau jeffrey@endrift.com
Tue, 11 Aug 2015 01:16:57 -0700
commit

6822b8cabe2bca29944fe88f18226f1b89eab055

parent

e36f3c8211d6b10dbbd3e6c123773bc3b387cee8

3 files changed, 10 insertions(+), 0 deletions(-)

jump to
M CHANGESCHANGES

@@ -71,6 +71,7 @@ - GBA Video: Prevent tiles < 512 from being used in modes 3 - 5

- Qt: Fix passing command line options - Qt: Fix crashes on Windows by using using QMetaObject to do cross-thread calls - GBA Video: Fix timing on first scanline + - GBA: Ensure cycles never go negative Misc: - Qt: Handle saving input settings better - Debugger: Free watchpoints in addition to breakpoints
M src/gba/gba.csrc/gba/gba.c

@@ -184,6 +184,11 @@ struct GBA* gba = (struct GBA*) cpu->master;

int32_t cycles = cpu->nextEvent; int32_t nextEvent = INT_MAX; int32_t testEvent; +#ifndef NDEBUG + if (cycles < 0) { + GBALog(gba, GBA_LOG_FATAL, "Negative cycles passed: %i", cycles); + } +#endif gba->bus = cpu->prefetch[1]; if (cpu->executionMode == MODE_THUMB) {
M src/gba/serialize.csrc/gba/serialize.c

@@ -87,6 +87,10 @@ if (state->cpu.cycles < 0) {

GBALog(gba, GBA_LOG_WARN, "Savestate is corrupted: CPU cycles are negative"); error = true; } + if (state->cpu.nextEvent < 0) { + GBALog(gba, GBA_LOG_WARN, "Savestate is corrupted: Next event is negative"); + error = true; + } if (state->video.eventDiff < 0) { GBALog(gba, GBA_LOG_WARN, "Savestate is corrupted: video eventDiff is negative"); error = true;