From: Toni Wilen Date: Sat, 22 Feb 2020 12:58:22 +0000 (+0200) Subject: Fix mode switch and range checks. X-Git-Tag: 4400~115 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=0e0e1f6710a1e2456b53b73c704a2f55e392661d;p=francis%2Fwinuae.git Fix mode switch and range checks. --- diff --git a/od-win32/picasso96_win.cpp b/od-win32/picasso96_win.cpp index 3879657f..e2da354e 100644 --- a/od-win32/picasso96_win.cpp +++ b/od-win32/picasso96_win.cpp @@ -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; diff --git a/od-win32/win32gfx.cpp b/od-win32/win32gfx.cpp index c8350378..2667bd61 100644 --- a/od-win32/win32gfx.cpp +++ b/od-win32/win32gfx.cpp @@ -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);