]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
uaegfx and Picasso IV 8-bit paletted overlay support.
authorToni Wilen <twilen@winuae.net>
Fri, 29 Mar 2019 17:43:18 +0000 (19:43 +0200)
committerToni Wilen <twilen@winuae.net>
Fri, 29 Mar 2019 17:43:18 +0000 (19:43 +0200)
od-win32/picasso96_win.cpp
od-win32/picasso96_win.h
od-win32/win32gfx.cpp
qemuvga/vga.cpp
qemuvga/vga_int.h

index d9302c2c471ca174d428e8483cf8e7761f31452b..0e1e69c436ab473630b946c44a38643a1984e50c 100644 (file)
@@ -167,8 +167,10 @@ static uaecptr boardinfo, ABI_interrupt;
 static int interrupt_enabled;
 float p96vblank;
 
-static int overlay_src_width, overlay_src_height;
-static uae_u32 overlay_format, overlay_color;
+#define OVERLAY_DEBUG 1
+static int overlay_src_width_in, overlay_src_height_in;
+static int overlay_src_height, overlay_src_width;
+static uae_u32 overlay_format, overlay_color, overlay_color_unswapped;
 static uae_u32 overlay_modeformat, overlay_modeinfo;
 static int overlay_x, overlay_y;
 static int overlay_w, overlay_h;
@@ -178,6 +180,8 @@ static int overlay_vram_offset;
 static int overlay_active;
 static int overlay_convert;
 static int overlay_occlusion;
+static struct MyCLUTEntry overlay_clutc[256];
+static uae_u32 overlay_clut[256];
 static uae_u32 *p96_rgbx16_ovl;
 
 static int uaegfx_old, uaegfx_active;
@@ -1033,7 +1037,7 @@ static void setconvert(int monid)
        else
                alloc_colors_rgb(5, 6, 5, 11, 5, 0, 0, 0, 0, 0, p96rc, p96gc, p96bc);
        gfx_set_picasso_colors(monid, state->RGBFormat);
-       picasso_palette(monid, state->CLUT);
+       picasso_palette(state->CLUT, vidinfo->clut);
        if (vidinfo->host_mode != vidinfo->ohost_mode || state->RGBFormat != vidinfo->orgbformat) {
                write_log (_T("RTG conversion: Depth=%d HostRGBF=%d P96RGBF=%d Mode=%d\n"),
                        picasso_vidinfo[monid].pixbytes, vidinfo->host_mode, state->RGBFormat, vidinfo->picasso_convert);
@@ -2785,6 +2789,7 @@ static int updateclut(TrapContext *ctx, uaecptr clut, int start, int count)
        bool uaegfx = currprefs.rtgboards[0].rtgmem_type < GFXBOARD_HARDWARE && currprefs.rtgboards[0].rtgmem_size;
        int monid = currprefs.rtgboards[0].monitor_id;
        struct picasso96_state_struct *state = &picasso96_state[monid];
+       struct picasso_vidbuf_description *vidinfo = &picasso_vidinfo[monid];
        uae_u8 clutbuf[256 * 3];
        int i, changed = 0;
        clut += start * 3;
@@ -2810,7 +2815,8 @@ static int updateclut(TrapContext *ctx, uaecptr clut, int start, int count)
                        state->CLUT[i].Blue = b;
                }
        }
-       changed |= picasso_palette(monid, state->CLUT);
+
+       changed |= picasso_palette(state->CLUT, vidinfo->clut);
        return changed;
 }
 static uae_u32 REGPARAM2 picasso_SetColorArray (TrapContext *ctx)
@@ -4498,7 +4504,7 @@ void copyrow_scale(int monid, uae_u8 *src, uae_u8 *src_screen, uae_u8 *dst,
        int screenbytesperrow, int screenpixbytes,
        int dx, int dy, int dstwidth, int dstheight, int dstbytesperrow, int dstpixbytes,
        bool ck, uae_u32 colorkey,
-       int convert_mode, uae_u32 *p96_rgbx16p)
+       int convert_mode, uae_u32 *p96_rgbx16p, uae_u32 *clut)
 {
        struct picasso_vidbuf_description *vidinfo = &picasso_vidinfo[monid];
        uae_u8 *src2 = src + sy * srcbytesperrow;
@@ -4759,36 +4765,36 @@ void copyrow_scale(int monid, uae_u8 *src, uae_u8 *src_screen, uae_u8 *dst,
                                x = sx >> 8;
                                sx += sxadd;
                                CKCHECK
-                                       ((uae_u16*)dst2)[dx] = vidinfo->clut[src2[x]];
+                                       ((uae_u16*)dst2)[dx] = clut[src2[x]];
                                dx++;
                        }
                        while (sx < endx4) {
                                x = sx >> 8;
                                sx += sxadd;
                                CKCHECK
-                                       ((uae_u16*)dst2)[dx] = vidinfo->clut[src2[x]];
+                                       ((uae_u16*)dst2)[dx] = clut[src2[x]];
                                dx++;
                                x = sx >> 8;
                                sx += sxadd;
                                CKCHECK
-                                       ((uae_u16*)dst2)[dx] = vidinfo->clut[src2[x]];
+                                       ((uae_u16*)dst2)[dx] = clut[src2[x]];
                                dx++;
                                x = sx >> 8;
                                sx += sxadd;
                                CKCHECK
-                                       ((uae_u16*)dst2)[dx] = vidinfo->clut[src2[x]];
+                                       ((uae_u16*)dst2)[dx] = clut[src2[x]];
                                dx++;
                                x = sx >> 8;
                                sx += sxadd;
                                CKCHECK
-                                       ((uae_u16*)dst2)[dx] = vidinfo->clut[src2[x]];
+                                       ((uae_u16*)dst2)[dx] = clut[src2[x]];
                                dx++;
                        }
                        while (sx < endx) {
                                x = sx >> 8;
                                sx += sxadd;
                                CKCHECK
-                                       ((uae_u16*)dst2)[dx] = vidinfo->clut[src2[x]];
+                                       ((uae_u16*)dst2)[dx] = clut[src2[x]];
                                dx++;
                        }
                }
@@ -4801,36 +4807,36 @@ void copyrow_scale(int monid, uae_u8 *src, uae_u8 *src_screen, uae_u8 *dst,
                                x = sx >> 8;
                                sx += sxadd;
                                CKCHECK
-                                       ((uae_u32*)dst2)[dx] = vidinfo->clut[src2[x]];
+                                       ((uae_u32*)dst2)[dx] = clut[src2[x]];
                                dx++;
                        }
                        while (sx < endx4) {
                                x = sx >> 8;
                                sx += sxadd;
                                CKCHECK
-                                       ((uae_u32*)dst2)[dx] = vidinfo->clut[src2[x]];
+                                       ((uae_u32*)dst2)[dx] = clut[src2[x]];
                                dx++;
                                x = sx >> 8;
                                sx += sxadd;
                                CKCHECK
-                                       ((uae_u32*)dst2)[dx] = vidinfo->clut[src2[x]];
+                                       ((uae_u32*)dst2)[dx] = clut[src2[x]];
                                dx++;
                                x = sx >> 8;
                                sx += sxadd;
                                CKCHECK
-                                       ((uae_u32*)dst2)[dx] = vidinfo->clut[src2[x]];
+                                       ((uae_u32*)dst2)[dx] = clut[src2[x]];
                                dx++;
                                x = sx >> 8;
                                sx += sxadd;
                                CKCHECK
-                                       ((uae_u32*)dst2)[dx] = vidinfo->clut[src2[x]];
+                                       ((uae_u32*)dst2)[dx] = clut[src2[x]];
                                dx++;
                        }
                        while (sx < endx) {
                                x = sx >> 8;
                                sx += sxadd;
                                CKCHECK
-                                       ((uae_u32*)dst2)[dx] = vidinfo->clut[src2[x]];
+                                       ((uae_u32*)dst2)[dx] = clut[src2[x]];
                                dx++;
                        }
                }
@@ -4919,23 +4925,23 @@ static void picasso_flushoverlay(int index, uae_u8 *src, int scr_offset, uae_u8
        uae_u8 *vram_end = src + gfxmem_banks[0]->allocated_size;
        uae_u8 *s = src + overlay_vram_offset;
        uae_u8 *ss = src + scr_offset;
-       int mx = overlay_src_width * 256 / overlay_w;
-       int my = overlay_src_height * 256 / overlay_h;
+       int mx = overlay_src_width_in * 256 / overlay_w;
+       int my = overlay_src_height_in * 256 / overlay_h;
        int y = 0;
 
        for (int dy = 0; dy < overlay_h; dy++) {
-               if (s + (y >> 8) * overlay_src_width * overlay_pix > vram_end)
+               if (s + (y >> 8) * overlay_src_width_in * overlay_pix > vram_end)
                        break;
                if (ss + (overlay_y + dy) * state->BytesPerRow > vram_end)
                        break;
                if (dst + (overlay_y + dy) * vidinfo->rowbytes > vram_end)
                        break;
                copyrow_scale(monid, s, ss, dst,
-                       0, (y >> 8), mx, overlay_src_width, overlay_src_width * overlay_pix, overlay_pix,
+                       0, (y >> 8), mx, overlay_src_width_in, overlay_src_width * overlay_pix, overlay_pix,
                        state->BytesPerRow, state->BytesPerPixel,
                        overlay_x, overlay_y + dy, vidinfo->width, vidinfo->height, vidinfo->rowbytes, vidinfo->pixbytes,
                        overlay_occlusion != 0, overlay_color,
-                       overlay_convert, p96_rgbx16_ovl);
+                       overlay_convert, p96_rgbx16_ovl, overlay_clut);
                y += my;
        }
 }
@@ -5423,6 +5429,9 @@ static uaecptr gettag(TrapContext *ctx, uaecptr p, uae_u32 *tagp, uae_u32 *valp)
        for (;;) {
                uae_u32 tag = trap_get_long(ctx, p);
                uae_u32 val = trap_get_long(ctx, p + 4);
+#if OVERLAY_DEBUG > 2
+               write_log(_T("TAG %08x: %08x %08x\n"), p, tag, val);
+#endif
                if (tag == TAG_DONE)
                        return 0;
                if (tag == TAG_IGNORE) {
@@ -5430,7 +5439,7 @@ static uaecptr gettag(TrapContext *ctx, uaecptr p, uae_u32 *tagp, uae_u32 *valp)
                        continue;
                }
                if (tag == TAG_SKIP) {
-                       p += val * 8;
+                       p += (val + 1) * 8;
                        continue;
                }
                if (tag == TAG_MORE) {
@@ -5444,12 +5453,16 @@ static uaecptr gettag(TrapContext *ctx, uaecptr p, uae_u32 *tagp, uae_u32 *valp)
 }
 static void settag(TrapContext *ctx, uaecptr p, uae_u32 v)
 {
-       uaecptr addr = trap_get_long(ctx, p - 8 + 4);
-       trap_put_long(ctx, addr, v);
+       trap_put_long(ctx, p, v);
+#if OVERLAY_DEBUG > 2
+       write_log(_T(" - %08x -> %08x\n"), p, v);
+#endif
 }
 
-static void overlaygettag(uae_u32 tag, uae_u32 val)
+static void overlaygettag(TrapContext *ctx, uae_u32 tag, uae_u32 val)
 {
+       struct picasso_vidbuf_description *vidinfo = &picasso_vidinfo[0];
+
        switch (tag)
        {
        case FA_Active:
@@ -5471,10 +5484,10 @@ static void overlaygettag(uae_u32 tag, uae_u32 val)
                overlay_h = val;
                break;
        case FA_SourceWidth:
-               overlay_src_width = val;
+               overlay_src_width_in = val;
                break;
        case FA_SourceHeight:
-               overlay_src_height = val;
+               overlay_src_height_in = val;
                break;
        case FA_Format:
                overlay_format = val;
@@ -5487,25 +5500,104 @@ static void overlaygettag(uae_u32 tag, uae_u32 val)
                break;
        case FA_Color:
                overlay_color = val;
+               overlay_color_unswapped = val;
                endianswap(&overlay_color, picasso96_state[0].BytesPerPixel);
                break;
+       case FA_Colors32:
+               {
+                       while(val) {
+                               uae_u8 tmpbuf[256 * 3 * 4 + 4];
+                               uae_u32 v = trap_get_long(ctx, val);
+                               val += 4;
+                               uae_u16 num = v >> 16;
+                               if (num > 256)
+                                       break;
+                               uae_u16 first = v & 0xffff;
+                               trap_get_bytes(ctx, tmpbuf, val, num * 3 * 4 + 4);
+                               for (int i = 0; i < num && (first + i) < 256; i++) {
+                                       overlay_clutc[first + i].Red = tmpbuf[i * 3 * 4 + 0];
+                                       overlay_clutc[first + i].Green = tmpbuf[i * 3 * 4 + 4];
+                                       overlay_clutc[first + i].Blue = tmpbuf[i * 3 * 4 + 8];
+                               }
+                               if (!tmpbuf[num])
+                                       break;
+                               val += num * 3 * 4;
+                       }
+                       if (picasso_palette(overlay_clutc, overlay_clut))
+                               vidinfo->full_refresh = 1;
+               }
+               break;
+       case FA_Colors:
+               {
+                       while (val) {
+                               uae_u8 tmpbuf[4 * 2];
+                               trap_get_bytes(ctx, tmpbuf, val, 4 * 2);
+                               uae_u16 idx = (tmpbuf[0] << 8) | tmpbuf[1];
+                               if (idx >= 256)
+                                       break;
+                               overlay_clutc[idx].Red = ((tmpbuf[3] & 15) << 4) | (tmpbuf[3] & 15);
+                               overlay_clutc[idx].Green = ((tmpbuf[5] & 15) << 4) | (tmpbuf[5] & 15);
+                               overlay_clutc[idx].Blue = ((tmpbuf[7] & 15) << 4) | (tmpbuf[7] & 15);
+                               val += 4 * 2;
+                       }
+                       if (picasso_palette(overlay_clutc, overlay_clut))
+                               vidinfo->full_refresh = 1;
+               }
+               break;
        }
 }
 
-static void overlaysettag(TrapContext *ctx, uaecptr p, uae_u32 tag, uae_u32 val)
+static void overlaysettag(TrapContext *ctx, uae_u32 tag, uae_u32 val)
 {
+       uae_u32 t;
        switch (tag)
        {
+       case FA_Active:
+               settag(ctx, val, overlay_active);
+               break;
+       case FA_Occlusion:
+               settag(ctx, val, overlay_occlusion);
+               break;
        case FA_MinWidth:
        case FA_MinHeight:
-               settag(ctx, p, 16);
+               settag(ctx, val, 16);
                break;
        case FA_MaxWidth:
        case FA_MaxHeight:
-               settag(ctx, p, 4096);
+               settag(ctx, val, 4096);
+               break;
+       case FA_Left:
+               settag(ctx, val, overlay_x);
+               break;
+       case FA_Top:
+               settag(ctx, val, overlay_y);
+               break;
+       case FA_Width:
+               settag(ctx, val, overlay_w);
+               break;
+       case FA_Height:
+               settag(ctx, val, overlay_h);
+               break;
+       case FA_SourceWidth:
+               settag(ctx, val, overlay_src_width_in);
+               break;
+       case FA_SourceHeight:
+               settag(ctx, val, overlay_src_height_in);
                break;
        case FA_BitMap:
-               settag(ctx, p, overlay_bitmap);
+               settag(ctx, val, overlay_bitmap);
+               break;
+       case FA_Format:
+               settag(ctx, val, overlay_format);
+               break;
+       case FA_ModeFormat:
+               settag(ctx, val, overlay_modeformat);
+               break;
+       case FA_ModeInfo:
+               settag(ctx, val, overlay_modeinfo);
+               break;
+       case FA_Color:
+               settag(ctx, val, overlay_color_unswapped);
                break;
        }
 }
@@ -5518,18 +5610,25 @@ static uae_u32 REGPARAM2 picasso_SetFeatureAttrs(TrapContext *ctx)
        uaecptr tagp = trap_get_areg(ctx, 2);
        uae_u32 type = trap_get_dreg(ctx, 0);
 
+#if OVERLAY_DEBUG > 1
+       write_log(_T("picasso_SetFeatureAttrs %08x %d\n"), tagp, type);
+#endif
        for (;;) {
                uae_u32 tag, val;
                tagp = gettag(ctx, tagp, &tag, &val);
                if (!tagp)
                        break;
+#if OVERLAY_DEBUG > 1
                write_log(_T("picasso_SetFeatureAttrs %08x tag %08x (%d) %08x\n"), tagp - 8, tag, tag & 0x7fffffff, val);
-               overlaygettag(tag, val);
+#endif
+               overlaygettag(ctx, tag, val);
        }
+#if OVERLAY_DEBUG > 1
        write_log(_T("RTG Overlay: X=%d Y=%d W=%d H=%d Act=%d SrcW=%d SrcH=%d BPP=%d VRAM=%08x\n"),
                overlay_x, overlay_y, overlay_w, overlay_h,
-               overlay_active, overlay_src_width, overlay_src_height,
+               overlay_active, overlay_src_width_in, overlay_src_height_in,
                overlay_pix, overlay_vram);
+#endif
        vidinfo->full_refresh = 1;
        return 0;
 }
@@ -5541,89 +5640,124 @@ static uae_u32 REGPARAM2 picasso_GetFeatureAttrs(TrapContext *ctx)
        uaecptr tagp = trap_get_areg(ctx, 2);
        uae_u32 type = trap_get_dreg(ctx, 0);
 
+#if OVERLAY_DEBUG > 1
+       write_log(_T("picasso_GetFeatureAttrs %08x %d\n"), tagp, type);
+#endif
        for (;;) {
                uae_u32 tag, val;
                tagp = gettag(ctx, tagp, &tag, &val);
                if (!tagp)
                        break;
-               write_log(_T("picasso_GetFeatureAttrs %08x tag %08x (%d) %08x\n"), tagp - 8, tag, tag & 0x7fffffff, val);
-               overlaysettag(ctx, tagp, tag, val);
+               overlaysettag(ctx, tag, val);
+#if OVERLAY_DEBUG > 1
+               write_log(_T("picasso_GetFeatureAttrs %08x tag %08x (%d) %08x\n"), tagp, tag, tag & 0x7fffffff, val);
+#endif
        }
        return 0;
 }
 
-// undocumented tags from picassoiv driver..
+// Tags from picassoiv driver..
 static const uae_u32 ovltags[] = {
-       0x80000003, 1,
-       0x80000004, 1,
-       0x80000005, 1,
-       0x80000008, 0,
-       0x80000009, 0,
-       0x80000010, 0,
-       0x80000006, 0,
-       0x8000000c, 0,
-       0x8000000d, 0,
-       0x8000000e, 0,
-       0x8000000f, 0,
-       0,0
+       ABMA_Clear, 1,
+       ABMA_Displayable, 1,
+       ABMA_Visible, 1,
+       ABMA_Colors, 0,
+       ABMA_Colors32, 0,
+       ABMA_ConstantBytesPerRow, 0,
+       ABMA_NoMemory, 0,
+       ABMA_RenderFunc, 0,
+       ABMA_SaveFunc, 0,
+       ABMA_UserData, 0,
+       ABMA_Alignment, 0,
+       TAG_DONE, 0
 };
+#define ALLOC_TAG_SIZE (13 * 8)
+
+// "VBInt PicassoIV (0)" -0x14
+// AllocCardMem=274 AllocBitMap=506 SetColorArray=286
+// CLUTEntry=578
 
 static uae_u32 REGPARAM2 picasso_CreateFeature(TrapContext *ctx)
 {
        struct picasso_vidbuf_description *vidinfo = &picasso_vidinfo[0];
+       struct picasso96_state_struct *state = &picasso96_state[0];
        uaecptr bi = trap_get_areg(ctx, 0);
        uae_u32 type = trap_get_dreg(ctx, 0);
        uaecptr tagp = trap_get_areg(ctx, 1);
 
-       write_log(_T("picasso_CreateFeature type %d\n"), type);
+#if OVERLAY_DEBUG
+       write_log(_T("picasso_CreateFeature type %d %08x %08x\n"), type, bi, tagp);
+#endif
        if (type != SFT_MEMORYWINDOW)
                return 0;
        if (overlay_vram)
                return 0;
-       overlay_src_width = -1;
-       overlay_src_height = -1;
+       memcpy(overlay_clutc, state->CLUT, sizeof(struct MyCLUTEntry) * 256);
+       overlay_src_width_in = -1;
+       overlay_src_height_in = -1;
        overlay_format = 0;
        for (;;) {
                uae_u32 tag, val;
                tagp = gettag(ctx, tagp, &tag, &val);
                if (!tagp)
                        break;
+#if OVERLAY_DEBUG
                write_log(_T("picasso_CreateFeature tag %08x (%d) %08x\n"), tag, tag & 0x7fffffff, val);
-               overlaygettag(tag, val);
+#endif
+               overlaygettag(ctx, tag, val);
        }
-       if (overlay_src_width < 16 || overlay_src_height < 16)
+       if (overlay_src_width_in < 16 || overlay_src_height_in < 16) {
+#if OVERLAY_DEBUG
+               write_log(_T("picasso_CreateFeature overlay width or height too small (%d*%d)\n"), overlay_src_width, overlay_src_height);
+#endif
                return 0;
-       if (overlay_src_width > vidinfo->width || overlay_src_height > vidinfo->height)
+       }
+       if (overlay_src_width_in > vidinfo->width || overlay_src_height_in > vidinfo->height) {
+#if OVERLAY_DEBUG
+               write_log(_T("picasso_CreateFeature overlay width or height too large (%d*%d)\n"), overlay_src_width, overlay_src_height);
+#endif
                return 0;
-       if (overlay_format <= RGBFB_CLUT || overlay_format >= RGBFB_MaxFormats)
+       }
+       if (overlay_format < RGBFB_CLUT || overlay_format >= RGBFB_MaxFormats) {
+#if OVERLAY_DEBUG
+               write_log(_T("picasso_CreateFeature overlay unknown format %d\n"), overlay_format);
+#endif
                return 0;
+       }
        overlay_pix = GetBytesPerPixel(overlay_format);
-       uaecptr tagmem = uae_AllocMem(ctx, 13 * 8, 65536, trap_get_long(ctx, 4));
-       if (!tagmem)
+       uaecptr overlay_tagmem = uae_AllocMem(ctx, ALLOC_TAG_SIZE, 65536, trap_get_long(ctx, 4));
+       if (!overlay_tagmem)
                return 0;
        uaecptr func = trap_get_long(ctx, bi + PSSO_BoardInfo_AllocBitMap);
-       trap_put_long(ctx, tagmem + 0, 0x80000002);
-       trap_put_long(ctx, tagmem + 4, overlay_format);
+       trap_put_long(ctx, overlay_tagmem + 0, ABMA_RGBFormat);
+       trap_put_long(ctx, overlay_tagmem + 4, overlay_format);
        for (int i = 0; ovltags[i]; i += 2) {
-               trap_put_long(ctx, tagmem + 8 + i * 4 + 0, ovltags[i + 0]);
-               trap_put_long(ctx, tagmem + 8 + i * 4 + 4, ovltags[i + 1]);
+               trap_put_long(ctx, overlay_tagmem + 8 + i * 4 + 0, ovltags[i + 0]);
+               trap_put_long(ctx, overlay_tagmem + 8 + i * 4 + 4, ovltags[i + 1]);
        }
        trap_call_add_areg(ctx, 0, bi);
-       trap_call_add_dreg(ctx, 0, overlay_src_width);
-       trap_call_add_dreg(ctx, 1, overlay_src_height);
-       trap_call_add_areg(ctx, 1, tagmem);
+       trap_call_add_dreg(ctx, 0, overlay_src_width_in);
+       trap_call_add_dreg(ctx, 1, overlay_src_height_in);
+       trap_call_add_areg(ctx, 1, overlay_tagmem);
        overlay_bitmap = trap_call_func(ctx, func);
-       uae_FreeMem(ctx, tagmem, 13 * 8, trap_get_long(ctx, 4));
-       if (!overlay_bitmap)
+       uae_FreeMem(ctx, overlay_tagmem, ALLOC_TAG_SIZE, trap_get_long(ctx, 4));
+       if (!overlay_bitmap) {
                return 0;
-       // probably should use GetBitMapAttr() but tags are not documented..
+       }
+       // probably should use GetBitMapAttr() but function is not documented enough.
+       overlay_src_width = trap_get_word(ctx, overlay_bitmap + 0) / overlay_pix;
+       overlay_src_height = trap_get_word(ctx, overlay_bitmap + 2);
        overlay_vram = trap_get_long(ctx, overlay_bitmap + 8);
        overlay_vram_offset = overlay_vram - gfxmem_banks[0]->start;
        overlay_convert = getconvert(overlay_format, picasso_vidinfo[0].pixbytes);
        if (!p96_rgbx16_ovl)
                p96_rgbx16_ovl = xcalloc(uae_u32, 65536);
        alloc_colors_picasso(8, 8, 8, 16, 8, 0, overlay_format, p96_rgbx16_ovl);
-       write_log(_T("picasso_CreateFeature overlay bitmap %08x, vram %08x\n"), overlay_bitmap, overlay_vram);
+#if OVERLAY_DEBUG
+       write_log(_T("picasso_CreateFeature overlay bitmap %08x, vram %08x (%dx%d)\n"),
+               overlay_bitmap, overlay_vram, overlay_src_width, overlay_src_height);
+#endif
+       picasso_palette(overlay_clutc, overlay_clut);
        vidinfo->full_refresh = 1;
        return OVERLAY_COOKIE;
 }
@@ -5634,7 +5768,9 @@ static uae_u32 REGPARAM2 picasso_DeleteFeature(TrapContext *ctx)
        uae_u32 type = trap_get_dreg(ctx, 0);
        uaecptr featuredata = trap_get_areg(ctx, 1);
 
+#if OVERLAY_DEBUG
        write_log(_T("picasso_DeleteFeature type %d data %08x\n"), type, featuredata);
+#endif
        if (type != SFT_MEMORYWINDOW)
                return 0;
        if (featuredata != OVERLAY_COOKIE)
@@ -5896,7 +6032,7 @@ static void inituaegfxfuncs(TrapContext *ctx, uaecptr start, uaecptr ABI)
        if (currprefs.rtg_hardwareinterrupt)
                RTGCALL2(PSSO_BoardInfo_SetInterrupt, picasso_SetInterrupt);
 
-       write_log (_T("uaegfx.card magic code: %08X-%08X ABI=%08X\n"), start, here (), ABI);
+       write_log (_T("uaegfx.card magic code: %08X-%08X BI=%08X\n"), start, here (), ABI);
 
        if (ABI && currprefs.rtg_hardwareinterrupt)
                initvblankABI(ctx, uaegfx_base, ABI);
@@ -5950,7 +6086,7 @@ void uaegfx_install_code (uaecptr start)
 }
 
 #define UAEGFX_VERSION 3
-#define UAEGFX_REVISION 3
+#define UAEGFX_REVISION 4
 
 static uae_u32 REGPARAM2 gfx_open(TrapContext *ctx)
 {
@@ -5977,7 +6113,7 @@ static uaecptr uaegfx_card_install (TrapContext *ctx, uae_u32 extrasize)
        if (uaegfx_old || !(gfxmem_bank.flags & ABFLAG_MAPPED))
                return 0;
 
-       uaegfx_resid = ds (_T("UAE Graphics Card 3.3"));
+       uaegfx_resid = ds (_T("UAE Graphics Card 3.4"));
        uaegfx_vblankname = ds (_T("UAE Graphics Card VBLANK"));
        uaegfx_portsname = ds (_T("UAE Graphics Card PORTS"));
 
index 8b5a930aca98ef876d29bbd48f4f9324c659eb7c..633f804a7697105e513be6739892023155d70a19 100644 (file)
@@ -309,28 +309,74 @@ enum {
 #ifndef TAG_USER
 #define TAG_USER 0x80000000
 #endif
-#define        FA_Restore                      (TAG_USER+0)
-#define        FA_Onboard                      (TAG_USER+1)
-#define        FA_Active                       (TAG_USER+2)
-#define        FA_Left                         (TAG_USER+3)
-#define        FA_Top                          (TAG_USER+4)
-#define        FA_Width                        (TAG_USER+5)
-#define        FA_Height                       (TAG_USER+6)
-#define        FA_Format                       (TAG_USER+7)
-#define        FA_Color                        (TAG_USER+8)
-#define        FA_Occlusion            (TAG_USER+9)
-#define        FA_SourceWidth          (TAG_USER+10)
-#define        FA_SourceHeight         (TAG_USER+11)
-#define        FA_MinWidth                     (TAG_USER+12)
-#define        FA_MinHeight            (TAG_USER+13)
-#define        FA_MaxWidth                     (TAG_USER+14)
-#define        FA_MaxHeight            (TAG_USER+15)
-#define        FA_Interlace            (TAG_USER+16)
-#define        FA_PAL                          (TAG_USER+17)
-#define        FA_BitMap                       (TAG_USER+18)
-#define        FA_Brightness           (TAG_USER+19)
-#define        FA_ModeInfo                     (TAG_USER+20)
-#define        FA_ModeFormat           (TAG_USER+21)
+#define        FA_Restore                              (TAG_USER+0)
+#define        FA_Onboard                              (TAG_USER+1)
+#define        FA_Active                               (TAG_USER+2)
+#define        FA_Left                                 (TAG_USER+3)
+#define        FA_Top                                  (TAG_USER+4)
+#define        FA_Width                                (TAG_USER+5)
+#define        FA_Height                               (TAG_USER+6)
+#define        FA_Format                               (TAG_USER+7)
+#define        FA_Color                                (TAG_USER+8)
+#define        FA_Occlusion                    (TAG_USER+9)
+#define        FA_SourceWidth                  (TAG_USER+10)
+#define        FA_SourceHeight                 (TAG_USER+11)
+#define        FA_MinWidth                             (TAG_USER+12)
+#define        FA_MinHeight                    (TAG_USER+13)
+#define        FA_MaxWidth                             (TAG_USER+14)
+#define        FA_MaxHeight                    (TAG_USER+15)
+#define        FA_Interlace                    (TAG_USER+16)
+#define        FA_PAL                                  (TAG_USER+17)
+#define        FA_BitMap                               (TAG_USER+18)
+#define        FA_Brightness                   (TAG_USER+19)
+#define        FA_ModeInfo                             (TAG_USER+20)
+#define        FA_ModeFormat                   (TAG_USER+21)
+#define FA_Colors                              (TAG_USER+22)
+#define FA_Colors32                            (TAG_USER+23)
+#define FA_NoMemory                            (TAG_USER+24)
+#define FA_RenderFunc                  (TAG_USER+25)
+#define FA_SaveFunc                            (TAG_USER+26)
+#define FA_UserData                            (TAG_USER+27)
+#define FA_Alignment                   (TAG_USER+28)
+#define FA_ConstantBytesPerRow (TAG_USER+29)
+#define FA_DoubleBuffer                        (TAG_USER+30)
+#define FA_Pen                                 (TAG_USER+31)
+#define FA_ModeMemorySize              (TAG_USER+32)
+#define FA_ClipLeft                            (TAG_USER+33)
+#define FA_ClipTop                             (TAG_USER+34)
+#define FA_ClipWidth                   (TAG_USER+35)
+#define FA_ClipHeight                  (TAG_USER+36)
+#define FA_ConstantByteSwapping        (TAG_USER+37)
+
+#define GBMA_MEMORY                            (TAG_USER+0)
+#define GBMA_BASEMEMORY                        (TAG_USER+1)
+#define GBMA_BYTESPERROW               (TAG_USER+2)
+#define GBMA_BYTESPERPIXEL             (TAG_USER+3)
+#define GBMA_BITSPERPIXEL              (TAG_USER+4)
+#define GBMA_RGBFORMAT                 (TAG_USER+6)
+#define GBMA_WIDTH                             (TAG_USER+7)
+#define GBMA_HEIGHT                            (TAG_USER+8)
+#define GBMA_DEPTH                             (TAG_USER+9)
+
+#define ABMA_Friend                                    (TAG_USER+0)
+#define ABMA_Depth                                     (TAG_USER+1)
+#define ABMA_RGBFormat                         (TAG_USER+2)
+#define ABMA_Clear                                     (TAG_USER+3)
+#define ABMA_Displayable                       (TAG_USER+4)
+#define ABMA_Visible                           (TAG_USER+5)
+#define ABMA_NoMemory                          (TAG_USER+6)
+#define ABMA_NoSprite                          (TAG_USER+7)
+#define ABMA_Colors                                    (TAG_USER+8)
+#define ABMA_Colors32                          (TAG_USER+9)
+#define ABMA_ModeWidth                         (TAG_USER+10)
+#define ABMA_ModeHeight                                (TAG_USER+11)
+#define ABMA_RenderFunc                                (TAG_USER+12)
+#define ABMA_SaveFunc                          (TAG_USER+13)
+#define ABMA_UserData                          (TAG_USER+14)
+#define ABMA_Alignment                         (TAG_USER+15)
+#define ABMA_ConstantBytesPerRow       (TAG_USER+16)
+#define ABMA_UserPrivate                       (TAG_USER+17)
+#define ABMA_ConstantByteSwapping      (TAG_USER+18)
 
 #define PSSO_BoardInfo_RegisterBase                0
 #define PSSO_BoardInfo_MemoryBase                  PSSO_BoardInfo_RegisterBase + 4
@@ -586,7 +632,7 @@ extern void picasso_trigger_vblank(void);
 extern void picasso_reset(int monid);
 extern bool picasso_is_active(int monid);
 extern int picasso_setwincursor(int monid);
-extern int picasso_palette(int monid, struct MyCLUTEntry *CLUT);
+extern int picasso_palette(struct MyCLUTEntry *MCLUT, uae_u32 *clut);
 extern void picasso_allocatewritewatch (int index, int gfxmemsize);
 extern void picasso_getwritewatch (int index, int offset);
 extern bool picasso_is_vram_dirty (int index, uaecptr addr, int size);
index 6fd177ad30f5410f0a2d6a4b7a9c173499e44520..e6a26daded4cd320f9afaabfa7a99a9225f68d03 100644 (file)
@@ -2771,13 +2771,11 @@ void init_colors(int monid)
 
 #ifdef PICASSO96
 
-int picasso_palette(int monid, struct MyCLUTEntry *CLUT)
+int picasso_palette(struct MyCLUTEntry *CLUT, uae_u32 *clut)
 {
-       struct picasso_vidbuf_description *vidinfo = &picasso_vidinfo[monid];
-       int i, changed;
+       int changed = 0;
 
-       changed = 0;
-       for (i = 0; i < 256; i++) {
+       for (int i = 0; i < 256; i++) {
                int r = CLUT[i].Red;
                int g = CLUT[i].Green;
                int b = CLUT[i].Blue;
@@ -2785,9 +2783,9 @@ int picasso_palette(int monid, struct MyCLUTEntry *CLUT)
                        | doMask256 (g, green_bits, green_shift)
                        | doMask256 (b, blue_bits, blue_shift))
                        | doMask256 (0xff, alpha_bits, alpha_shift);
-               if (v != vidinfo->clut[i]) {
+               if (v != clut[i]) {
                        //write_log (_T("%d:%08x\n"), i, v);
-                       vidinfo->clut[i] = v;
+                       clut[i] = v;
                        changed = 1;
                }
        }
index 75e3019cf155f985c87355c7741437e852cbefae..e2372e67bd1f9081f74fa6835a9db492ef3f36f3 100644 (file)
@@ -1195,6 +1195,11 @@ static int update_basic_params(VGACommonState *s)
         s->line_compare = line_compare;
         full_update = 1;
     }
+       if (s->ovl_changed) {
+               full_update = 1;
+               s->ovl_changed = 0;
+       }
+
     return full_update;
 }
 
@@ -1936,14 +1941,17 @@ static void vga_draw_graphic(VGACommonState *s, int full_update)
                        int screenbytesperrow, int screenpixbytes,
                        int dx, int dy, int dstwidth, int dstheight, int dstbytesperrow, int dstpixbytes,
                        bool ck, uint32_t colorkey,
-                       int convert_mode, uint32_t *p96_rgbx16p);
+                       int convert_mode, uint32_t *p96_rgbx16p, uint32_t *clut);
                void alloc_colors_picasso(int rw, int gw, int bw, int rs, int gs, int bs, int rgbfmt, uint32_t *rgbx16);
                int getconvert(int rgbformat, int pixbytes);
 
                int outbpp = surface_bits_per_pixel(surface) / 8;
+               uint32_t format = (s->cr[0x3e] >> 1) & 7;
+
                if (!s->cirrus_rgbx16) {
                        s->cirrus_rgbx16 = (uint32_t*)malloc(65536 * 4);
                }
+               bool clutmode = format == 2;
                int ovl_format = 5;
                if (s->old_ovl_format != ovl_format) {
                        alloc_colors_picasso(8, 8, 8, 16, 8, 0, ovl_format, s->cirrus_rgbx16);
@@ -1960,7 +1968,6 @@ static void vga_draw_graphic(VGACommonState *s, int full_update)
                uint32_t r2dsz = s->cr[0x35] | (((s->cr[0x36] >> 4) & 3) << 8);
                uint32_t wvs = s->cr[0x37] | (((s->cr[0x39] >> 0) & 3) << 8);
                uint32_t wve = s->cr[0x38] | (((s->cr[0x39] >> 2) & 3) << 8);
-               uint32_t format = (s->cr[0x3e] >> 1) & 7;
                bool occlusion = ((s->cr[0x3e] >> 7) & 1) != 0 && bits < 24;
                uint32_t region1size = 32 * r1sz / gfxbpp + (r1adjust * 8 / gfxbpp);
                uint32_t region2size = 32 * r2sz / gfxbpp + (r2adjust * 8 / gfxbpp);
@@ -1978,10 +1985,15 @@ static void vga_draw_graphic(VGACommonState *s, int full_update)
                        occlusion = false;
                }
 
-               int overlaybpp = 2;
+               int overlaybpp = clutmode ? 1 : 2;
                int overlay_width = overlaybpp * r2dsz;
                int vertical_height = wve - wvs + 1;
-               int convert = getconvert(5, outbpp);
+               int convert = getconvert(clutmode ? 1 : 5, outbpp);
+
+               if (clutmode) {
+                       update_palette256(s);
+                       overlay_width *= 4;
+               }
 
                if (!hzoom)
                        hzoom = 256;
@@ -2001,12 +2013,12 @@ static void vga_draw_graphic(VGACommonState *s, int full_update)
                                line_offset, bits / 8,
                                region1size, wvs, width, height, linesize, outbpp,
                                occlusion, colorkey,
-                               convert, s->cirrus_rgbx16);
+                               convert, s->cirrus_rgbx16, s->last_palette);
                        wvs++;
                        y += vzoom;
                }
 
-               s->last_width = -1;
+               s->ovl_changed = 1;
                s->old_overlay = 1;
 
                if (y_start < 0 || y_start > wvs)
@@ -2017,7 +2029,7 @@ static void vga_draw_graphic(VGACommonState *s, int full_update)
        } else if (s->old_overlay) {
 
                s->old_overlay = 0;
-               s->last_width = -1;
+               s->ovl_changed = 1;
 
        }
 
index ec3e86b9f9ae81806ba1abf05e22a3b5aa3bb7bd..71236ce33421dade58d250d6c7cb3d19a8e86872 100644 (file)
@@ -176,6 +176,7 @@ typedef struct VGACommonState {
        int monid;
        int old_ovl_format;
        int old_overlay;
+       int ovl_changed;
 } VGACommonState;
 
 STATIC_INLINE int c6_to_8(int v)