From 54cd85d236f149c66994dd1bc6334ac63effc058 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Mon, 12 Sep 2016 20:15:40 -0700 Subject: [PATCH] GB Video: Prevent dot clock from going negative --- src/gb/video.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gb/video.c b/src/gb/video.c index e83205cdc..92f19cef5 100644 --- a/src/gb/video.c +++ b/src/gb/video.c @@ -257,6 +257,9 @@ void GBVideoProcessDots(struct GBVideo* video) { video->x = video->dotCounter + video->eventDiff + (video->p->cpu->cycles >> video->p->doubleSpeed); if (video->x > GB_VIDEO_HORIZONTAL_PIXELS) { video->x = GB_VIDEO_HORIZONTAL_PIXELS; + } else if (video->x < 0) { + mLOG(GB, FATAL, "Video dot clock went negative!"); + video->x = oldX; } if (video->x == GB_VIDEO_HORIZONTAL_PIXELS) { video->dotCounter = INT_MIN;