]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Round 24-bit pixel width to prevent possible missing pixels. Extra safety check.
authorToni Wilen <twilen@winuae.net>
Sat, 19 Oct 2019 13:13:52 +0000 (16:13 +0300)
committerToni Wilen <twilen@winuae.net>
Sat, 19 Oct 2019 13:13:52 +0000 (16:13 +0300)
od-win32/picasso96_win.cpp

index ef9a0a57b415039e15475b1c7dcd4b5d412d78b3..3879657f7c50a95b1f75f71f06a9c58082061d91 100644 (file)
@@ -5161,6 +5161,12 @@ static void picasso_flushpixels(int index, uae_u8 *src, int off, bool render)
        struct picasso_vidbuf_description *vidinfo = &picasso_vidinfo[monid];
        bool overlay_updated = false;
 
+       // safety check
+       if (pwidth * state->BytesPerPixel > vidinfo->rowbytes)
+               pwidth = vidinfo->rowbytes / state->BytesPerPixel;
+       if (pheight > vidinfo->height)
+               pheight = vidinfo->height;
+
        src_start = src + (off & ~gwwpagemask[index]);
        src_end = src + ((off + state->BytesPerRow * pheight + gwwpagesize[index] - 1) & ~gwwpagemask[index]);
 #if 0
@@ -5259,7 +5265,7 @@ static void picasso_flushpixels(int index, uae_u8 *src, int off, bool render)
 
                                y = realoffset / state->BytesPerRow;
                                if (y < pheight) {
-                                       int w = gwwpagesize[index] / state->BytesPerPixel;
+                                       int w = (gwwpagesize[index] + state->BytesPerPixel - 1) / state->BytesPerPixel;
                                        x = (realoffset % state->BytesPerRow) / state->BytesPerPixel;
                                        if (x < pwidth) {
                                                copyrow(monid, src + off, dst, x, y, pwidth - x,
@@ -5268,7 +5274,7 @@ static void picasso_flushpixels(int index, uae_u8 *src, int off, bool render)
                                                        state->RGBFormat == vidinfo->host_mode, vidinfo->picasso_convert, p96_rgbx16);
                                                flushlines++;
                                        }
-                                       w = (gwwpagesize[index] - (state->BytesPerRow - x * state->BytesPerPixel)) / state->BytesPerPixel;
+                                       w = (gwwpagesize[index] - (state->BytesPerRow - x * state->BytesPerPixel) + state->BytesPerPixel - 1) / state->BytesPerPixel;
                                        if (y < miny)
                                                miny = y;
                                        y++;