]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Fix hardware emulated graphics board screenshots.
authorToni Wilen <twilen@winuae.net>
Sat, 19 Sep 2020 10:32:17 +0000 (13:32 +0300)
committerToni Wilen <twilen@winuae.net>
Sat, 19 Sep 2020 10:32:17 +0000 (13:32 +0300)
gfxboard.cpp
include/gfxboard.h
include/gfxfilter.h
include/uae/time.h
od-win32/avioutput.cpp
od-win32/picasso96_win.cpp
od-win32/screenshot.cpp
od-win32/win32.cpp

index dc7a5a72b075fc3b4a24ad0397a1c6edf36be175..ed37af6edfd900caa9d50b05f383f59ce7426e77 100644 (file)
@@ -43,6 +43,7 @@ static bool memlogw = true;
 #include "rommgr.h"
 #include "xwin.h"
 #include "devices.h"
+#include "gfxfilter.h"
 #include "pcem/device.h"
 #include "pcem/vid_s3_virge.h"
 #include "pcem/vid_cl5429.h"
@@ -601,6 +602,8 @@ void gfxboard_free_vram(int index)
                vram_ram_a8 = 0;
 }
 
+extern uae_u8 *getpcembuffer32(int, int, int);
+
 // PCEM
 void video_blit_memtoscreen(int x, int y, int y1, int y2, int w, int h)
 {
@@ -615,7 +618,6 @@ void video_blit_memtoscreen(int x, int y, int y1, int y2, int w, int h)
                                        struct picasso_vidbuf_description *vidinfo = &picasso_vidinfo[gb->monitor_id];
                                        for (int yy = y1; yy < y2 && yy < vidinfo->height; yy++) {
                                                uae_u8 *d = gb->gfxboard_surface + yy * vidinfo->rowbytes;
-                                               extern uae_u8 *getpcembuffer32(int, int, int);
                                                uae_u8 *s = getpcembuffer32(x, y, yy);
                                                memcpy(d, s, vidinfo->width * vidinfo->pixbytes);
                                        }
@@ -3976,7 +3978,7 @@ static uae_u32 REGPARAM2 gfxboard_lget_vram_pcem(uaecptr addr)
        if (addr & 0x800000) {
                v = do_byteswap_32(v);
        } else if (addr & 0x400000) {
-               v = do_byteswap_32(v);
+               v = (v >> 16) | (v << 16);
        } else {
                ;
        }
@@ -4013,7 +4015,7 @@ static void REGPARAM2 gfxboard_lput_vram_pcem(uaecptr addr, uae_u32 l)
        if (addr & 0x800000) {
                l = do_byteswap_32(l);
        } else if (addr & 0x400000) {
-               l = do_byteswap_32(l);
+               l = (l >> 16) | (l << 16);
        } else {
                ;
        }
@@ -5097,3 +5099,71 @@ int pcem_getvramsize(void)
        }
        return 0;
 }
+
+
+bool gfxboard_isgfxboardscreen(int monid)
+{
+       int index = rtg_visible[monid];
+       if (index < 0)
+               return false;
+       struct rtgboardconfig *rbc = &currprefs.rtgboards[index];
+       struct rtggfxboard *gb = &rtggfxboards[rbc->rtg_index];
+       return gb->active && rtg_visible[monid] >= 0;
+}
+uae_u8 *gfxboard_getrtgbuffer(int monid, int *widthp, int *heightp, int *pitch, int *depth, uae_u8 *palette)
+{
+       int index = rtg_visible[monid];
+       if (index < 0)
+               return NULL;
+       struct rtgboardconfig *rbc = &currprefs.rtgboards[index];
+
+       if (rbc->rtgmem_type < GFXBOARD_HARDWARE) {
+               return uaegfx_getrtgbuffer(monid, widthp, heightp, pitch, depth, palette);
+       }
+
+       struct rtggfxboard *gb = &rtggfxboards[rbc->rtg_index];
+       struct picasso_vidbuf_description *vidinfo = &picasso_vidinfo[monid];
+       struct picasso96_state_struct *state = &picasso96_state[monid];
+
+       if (!gb->pcemdev)
+               return NULL;
+
+       int width = state->VirtualWidth;
+       int height = state->VirtualHeight;
+       if (!width || !height)
+               return NULL;
+
+       uae_u8 *dst = xmalloc(uae_u8, width * height * 4);
+       if (!dst)
+               return NULL;
+
+       uae_u8 *d = dst;
+       for (int yy = 0; yy < height; yy++) {
+               uae_u8 *s = getpcembuffer32(32, 0, yy);
+               memcpy(d, s, width * 4);
+               d += width * 4;
+       }
+
+       *widthp = width;
+       *heightp = height;
+       *pitch = width * 4;
+       *depth = 4 * 8;
+
+       return dst;
+}
+void gfxboard_freertgbuffer(int monid, uae_u8 *dst)
+{
+       int index = rtg_visible[monid];
+       if (index < 0) {
+               uaegfx_freertgbuffer(monid, dst);
+               return;
+       }
+       struct rtgboardconfig *rbc = &currprefs.rtgboards[index];
+
+       if (rbc->rtgmem_type < GFXBOARD_HARDWARE) {
+               uaegfx_freertgbuffer(monid, dst);
+               return;
+       }
+
+       xfree(dst);
+}
index bf7e56fa263cc3a2bdcc8ef45e9e7159cc7861d2..8a6e184567ec7b9b4462b44e1eeb95657101e56f 100644 (file)
@@ -35,6 +35,10 @@ extern bool gfxboard_init_board(struct autoconfig_info*);
 extern bool gfxboard_set(int monid, bool rtg);
 extern void gfxboard_resize(int width, int height, void *p);
 
+uae_u8 *gfxboard_getrtgbuffer(int monid, int *widthp, int *heightp, int *pitch, int *depth, uae_u8 *palette);
+void gfxboard_freertgbuffer(int monid, uae_u8 *dst);
+bool gfxboard_isgfxboardscreen(int monid);
+
 extern struct gfxboard_func a2410_func;
 extern struct gfxboard_func harlequin_func;
 
index b46003b6de228a0c2fc0f4fa1c61af58ee234895..801f2ef253eb59b78c78275d76f9043cfd183a0f 100644 (file)
@@ -84,8 +84,8 @@ uae_u8 *getfilterbuffer3d(int monid, int *widthp, int *heightp, int *pitch, int
 uae_u8 *getfilterbuffer(int monid, int *widthp, int *heightp, int *pitch, int *depth);
 void freefilterbuffer(int monid, uae_u8*);
 
-uae_u8 *getrtgbuffer(int monid, int *widthp, int *heightp, int *pitch, int *depth, uae_u8 *palette);
-void freertgbuffer(int monid, uae_u8 *dst);
+uae_u8 *uaegfx_getrtgbuffer(int monid, int *widthp, int *heightp, int *pitch, int *depth, uae_u8 *palette);
+void uaegfx_freertgbuffer(int monid, uae_u8 *dst);
 
 extern void getrtgfilterrect2(int monid, RECT *sr, RECT *dr, RECT *zr, int dst_width, int dst_height);
 
index 4c620804ada60763c14a687c0efac4885afa83ea..be43bd4f8d560a8f83d14b577be21945b4a32fb9 100644 (file)
@@ -10,6 +10,8 @@ void uae_time_init(void);
 void uae_time_calibrate(void);
 uae_time_t uae_time(void);
 
+extern int syncbase;
+
 #ifdef _WIN32
 void uae_time_use_rdtsc(bool enable);
 uae_u32 read_system_time(void);
index 1c8f6663c5c14398c28583ea555e1539482c9cc3..d1b2f71f78ff30101f2dbc57edfa566f087956bd 100644 (file)
@@ -43,6 +43,7 @@ Copyright(c) 2001 - 2002; 
 #include "threaddep/thread.h"
 #include "zfile.h"
 #include "savestate.h"
+#include "gfxboard.h"
 
 #define MAX_AVI_SIZE (0x80000000 - 0x1000000)
 
@@ -539,10 +540,10 @@ static int AVIOutput_AllocateVideo(void)
                avioutput_fps = ispal() ? 50 : 60;
        if (avioutput_originalsize || WIN32GFX_IsPicassoScreen(mon)) {
                int pitch;
-               if (!WIN32GFX_IsPicassoScreen(mon)) {
+               if (!gfxboard_isgfxboardscreen(0)) {
                        getfilterbuffer(0, &avioutput_width, &avioutput_height, &pitch, &avioutput_bits);
                } else {
-                       freertgbuffer(0, getrtgbuffer(0, &avioutput_width, &avioutput_height, &pitch, &avioutput_bits, NULL));
+                       gfxboard_freertgbuffer(0, gfxboard_getrtgbuffer(0, &avioutput_width, &avioutput_height, &pitch, &avioutput_bits, NULL));
                }
        }
 
@@ -1105,12 +1106,12 @@ static int getFromBuffer(struct avientry *ae, int original)
        mem = NULL;
        dpitch = ((aviout_width_out * avioutput_bits + 31) & ~31) / 8;
        if (original || WIN32GFX_IsPicassoScreen(mon)) {
-               if (!WIN32GFX_IsPicassoScreen(mon)) {
+               if (!gfxboard_isgfxboardscreen(aviout_monid)) {
                        src = getfilterbuffer(aviout_monid, &w, &h, &spitch, &d);
                        maxw = vidinfo->outbuffer->outwidth;
                        maxh = vidinfo->outbuffer->outheight;
                } else {
-                       src = mem = getrtgbuffer(aviout_monid, &w, &h, &spitch, &d, NULL);
+                       src = mem = gfxboard_getrtgbuffer(aviout_monid, &w, &h, &spitch, &d, NULL);
                        maxw = w;
                        maxh = h;
                }
@@ -1188,7 +1189,7 @@ static int getFromBuffer(struct avientry *ae, int original)
                src += spitch;
        }
        if (mem)
-               freertgbuffer(aviout_monid, mem);
+               gfxboard_freertgbuffer(aviout_monid, mem);
        return 1;
 }
 #endif
index 443282239efd7a4bf93dd582fa9bb23160abf17f..f1eeb6d2373d3e396de0874b9679276183aca485 100644 (file)
@@ -5117,7 +5117,7 @@ static void copyall (int monid, uae_u8 *src, uae_u8 *dst, int pwidth, int pheigh
        }
 }
 
-uae_u8 *getrtgbuffer(int monid, int *widthp, int *heightp, int *pitch, int *depth, uae_u8 *palette)
+uae_u8 *uaegfx_getrtgbuffer(int monid, int *widthp, int *heightp, int *pitch, int *depth, uae_u8 *palette)
 {
        struct picasso_vidbuf_description *vidinfo = &picasso_vidinfo[monid];
        struct picasso96_state_struct *state = &picasso96_state[monid];
@@ -5172,7 +5172,7 @@ uae_u8 *getrtgbuffer(int monid, int *widthp, int *heightp, int *pitch, int *dept
 
        return dst;
 }
-void freertgbuffer(int monid, uae_u8 *dst)
+void uaegfx_freertgbuffer(int monid, uae_u8 *dst)
 {
        xfree (dst);
 }
index 15a41cfb0326e5f8fb5fa71cef022c3ebbc01eb9..dbbadb68ddbdc361840ef9ab0224f2b43f7db375 100644 (file)
@@ -21,7 +21,7 @@
 #include "drawing.h"
 #include "fsdb.h"
 #include "zfile.h"
-#include "picasso96_win.h"
+#include "gfxboard.h"
 
 #include "png.h"
 
@@ -144,8 +144,8 @@ static int screenshot_prepare(int monid, int imagemode, struct vidbuffer *vb, bo
                int screenshot_width = 0, screenshot_height = 0;
                int screenshot_xoffset = -1, screenshot_yoffset = -1;
 
-               if (WIN32GFX_IsPicassoScreen(mon)) {
-                       src = mem = getrtgbuffer(monid, &width, &height, &spitch, &bits, pal);
+               if (gfxboard_isgfxboardscreen(monid)) {
+                       src = mem = gfxboard_getrtgbuffer(monid, &width, &height, &spitch, &bits, pal);
                        needfree = true;
                        rgb_bb2 = 8;
                        rgb_gb2 = 8;
@@ -189,7 +189,7 @@ static int screenshot_prepare(int monid, int imagemode, struct vidbuffer *vb, bo
                if (width == 0 || height == 0) {
                        if (needfree) {
                                if (WIN32GFX_IsPicassoScreen(mon))
-                                       freertgbuffer(0, mem);
+                                       gfxboard_freertgbuffer(0, mem);
                                else
                                        freefilterbuffer(0, mem);
                        }
@@ -290,7 +290,7 @@ static int screenshot_prepare(int monid, int imagemode, struct vidbuffer *vb, bo
                if (!(lpvBits = xmalloc(uae_u8, bi->bmiHeader.biSizeImage))) {
                        if (needfree) {
                                if (WIN32GFX_IsPicassoScreen(mon))
-                                       freertgbuffer(monid, mem);
+                                       gfxboard_freertgbuffer(monid, mem);
                                else
                                        freefilterbuffer(monid, mem);
                        }
@@ -408,8 +408,8 @@ static int screenshot_prepare(int monid, int imagemode, struct vidbuffer *vb, bo
                        src += spitch;
                }
                if (needfree) {
-                       if (WIN32GFX_IsPicassoScreen(mon))
-                               freertgbuffer(monid, mem);
+                       if (gfxboard_isgfxboardscreen(monid))
+                               gfxboard_freertgbuffer(monid, mem);
                        else
                                freefilterbuffer(monid, mem);
                }
index b0bd538cb126a5dacafe6e75e0ee398455efffa3..85952882a697c89e7c232397d52e6b53ac624a37 100644 (file)
@@ -4158,6 +4158,21 @@ void target_fixup_options (struct uae_prefs *p)
                nojoy = true;
        }
        
+       if (p->rtg_hardwaresprite && !p->gfx_api) {
+               error_log(_T("DirectDraw is not RTG hardware sprite compatible."));
+               p->rtg_hardwaresprite = false;
+       }
+       if (p->rtgboards[0].rtgmem_type >= GFXBOARD_HARDWARE) {
+               p->rtg_hardwareinterrupt = false;
+               p->rtg_hardwaresprite = false;
+               p->win32_rtgmatchdepth = false;
+               p->color_mode = 5;
+               if (p->ppc_model && !p->gfx_api) {
+                       error_log(_T("Graphics board and PPC: Direct3D enabled."));
+                       p->gfx_api = os_win7 ? 2 : 1;
+               }
+       }
+
        struct MultiDisplay *md = getdisplay(p, 0);
        for (int j = 0; j < MAX_AMIGADISPLAYS; j++) {
                if (p->gfx_monitor[j].gfx_size_fs.special == WH_NATIVE) {
@@ -4190,22 +4205,7 @@ void target_fixup_options (struct uae_prefs *p)
                        p->color_mode = p->color_mode == 5 ? 2 : 5;
                }
        }
-       if (p->rtg_hardwaresprite && !p->gfx_api) {
-               error_log (_T("DirectDraw is not RTG hardware sprite compatible."));
-               p->rtg_hardwaresprite = false;
-       }
-       if (p->rtgboards[0].rtgmem_type >= GFXBOARD_HARDWARE) {
-               p->rtg_hardwareinterrupt = false;
-               p->rtg_hardwaresprite = false;
-               p->win32_rtgmatchdepth = false;
-               if (gfxboard_need_byteswap (&p->rtgboards[0]))
-                       p->color_mode = 5;
-               if (p->ppc_model && !p->gfx_api) {
-                       error_log (_T("Graphics board and PPC: Direct3D enabled."));
-                       p->gfx_api = os_win7 ? 2 : 1;
-               }
 
-       }
        if ((p->gfx_apmode[0].gfx_vsyncmode || p->gfx_apmode[1].gfx_vsyncmode) ) {
                if (p->produce_sound && sound_devices[p->win32_soundcard]->type == SOUND_DEVICE_DS) {
                        p->win32_soundcard = 0;