]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Fix mode switch and range checks.
authorToni Wilen <twilen@winuae.net>
Sat, 22 Feb 2020 12:58:22 +0000 (14:58 +0200)
committerToni Wilen <twilen@winuae.net>
Sat, 22 Feb 2020 12:58:22 +0000 (14:58 +0200)
od-win32/picasso96_win.cpp
od-win32/win32gfx.cpp

index 3879657f7c50a95b1f75f71f06a9c58082061d91..e2da354e162e02e536a8348b151500bcb3bf2dab 100644 (file)
@@ -5084,8 +5084,8 @@ uae_u8 *getrtgbuffer(int monid, int *widthp, int *heightp, int *pitch, int *dept
 {
        struct picasso_vidbuf_description *vidinfo = &picasso_vidinfo[monid];
        struct picasso96_state_struct *state = &picasso96_state[monid];
-       uae_u8 *src = gfxmem_bank.start + natmem_offset;
-       int off = state->XYOffset - gfxmem_bank.start;
+       uae_u8 *src = gfxmem_banks[monid]->start + natmem_offset;
+       int off = state->XYOffset - gfxmem_banks[monid]->start;
        int width, height, pixbytes;
        uae_u8 *dst;
        int convert;
@@ -5162,8 +5162,8 @@ static void picasso_flushpixels(int index, uae_u8 *src, int off, bool render)
        bool overlay_updated = false;
 
        // safety check
-       if (pwidth * state->BytesPerPixel > vidinfo->rowbytes)
-               pwidth = vidinfo->rowbytes / state->BytesPerPixel;
+       if (pwidth > vidinfo->rowbytes / vidinfo->pixbytes)
+               pwidth = vidinfo->rowbytes / vidinfo->pixbytes;
        if (pheight > vidinfo->height)
                pheight = vidinfo->height;
 
index c83503781e0718d7215b3fb20792e7fa03c393bb..2667bd61a8fdafd2fb8c21d61a8d695fbf432d5a 100644 (file)
@@ -3161,6 +3161,21 @@ end:
 #endif
 }
 
+static void updatepicasso96(struct AmigaMonitor *mon)
+{
+#ifdef PICASSO96
+       struct picasso_vidbuf_description *vidinfo = &picasso_vidinfo[mon->monitor_id];
+       vidinfo->rowbytes = 0;
+       vidinfo->pixbytes = mon->currentmode.current_depth / 8;
+       vidinfo->rgbformat = 0;
+       vidinfo->extra_mem = 1;
+       vidinfo->height = mon->currentmode.current_height;
+       vidinfo->width = mon->currentmode.current_width;
+       vidinfo->depth = mon->currentmode.current_depth;
+       vidinfo->offset = 0;
+#endif
+}
+
 void gfx_set_picasso_modeinfo(int monid, RGBFTYPE rgbfmt)
 {
        struct AmigaMonitor *mon = &AMonitors[monid];
@@ -3177,10 +3192,10 @@ void gfx_set_picasso_modeinfo(int monid, RGBFTYPE rgbfmt)
        } else if (need < 0) {
                struct picasso96_state_struct *state = &picasso96_state[mon->monitor_id];
                struct winuae_currentmode *wc = &mon->currentmode;
-               if (state->Width != wc->current_width ||
-                       state->Height != wc->current_height ||
-                       state->BytesPerPixel * 8 != wc->current_depth)
+               if (state->Width != wc->native_width || state->Width != wc->current_width ||
+                       state->Height != wc->native_height || state->Height != wc->current_height) {
                        open_windows(mon, true, true);
+               }
        }
 #ifdef RETROPLATFORM
        rp_set_hwnd(mon->hAmigaWnd);
@@ -4103,17 +4118,8 @@ retry:
 #endif
        }
 
-#ifdef PICASSO96
-       struct picasso_vidbuf_description *vidinfo = &picasso_vidinfo[mon->monitor_id];
-       vidinfo->rowbytes = 0;
-       vidinfo->pixbytes = mon->currentmode.current_depth / 8;
-       vidinfo->rgbformat = 0;
-       vidinfo->extra_mem = 1;
-       vidinfo->height = mon->currentmode.current_height;
-       vidinfo->width = mon->currentmode.current_width;
-       vidinfo->depth = mon->currentmode.current_depth;
-       vidinfo->offset = 0;
-#endif
+       updatepicasso96(mon);
+
        if (!scrlinebuf)
                scrlinebuf = xmalloc (uae_u8, max_uae_width * 4);