]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
imported winuaesrc1600b10.zip
authorToni Wilen <twilen@winuae.net>
Sat, 24 Jan 2009 17:11:50 +0000 (19:11 +0200)
committerToni Wilen <twilen@winuae.net>
Mon, 22 Feb 2010 19:44:35 +0000 (21:44 +0200)
cfgfile.c
custom.c
drawing.c
od-win32/ahidsound.c
od-win32/clipboard_win32.c
od-win32/clipboard_win32.h
od-win32/win32.c
od-win32/win32.h
od-win32/winuaechangelog.txt

index 6dcfc36be8c618556ec5164b25109c5d26d08373..eeabd91fa9de4e003a4bac71cfcfeeffdc7744a2 100644 (file)
--- a/cfgfile.c
+++ b/cfgfile.c
@@ -2870,7 +2870,7 @@ void default_prefs (struct uae_prefs *p, int type)
     p->config_hardware_path[0] = 0;
     p->config_host_path[0] = 0;
 
-    p->gfx_scandoubler = 1;
+    p->gfx_scandoubler = 0;
     p->start_gui = 1;
     p->start_debugger = 0;
 
index b1df8edd32da1845487a0cddaf42a90821f89d4d..9f07e32286f8dd1df83acafda327559a19a00fc9 100644 (file)
--- a/custom.c
+++ b/custom.c
@@ -394,7 +394,7 @@ STATIC_INLINE int nodraw (void)
 
 static int doflickerfix (void)
 {
-    return currprefs.gfx_linedbl && doublescan < 0 && interlace_seen;
+    return currprefs.gfx_linedbl && doublescan < 0;
 }
 
 uae_u32 get_copper_address (int copno)
@@ -1684,12 +1684,14 @@ static void start_bpl_dma (int hpos, int hstart)
     if (first_bpl_vpos < 0)
        first_bpl_vpos = vpos;
 
-    if (doflickerfix () && !scandoubled_line) {
+    if (doflickerfix () && interlace_seen && !scandoubled_line) {
        int i;
        for (i = 0; i < 8; i++) {
            prevbpl[lof][vpos][i] = bplptx[i];
            if (!lof && (bplcon0 & 4))
                bplpt[i] = prevbpl[1 - lof][vpos][i];
+           if (!(bplcon0 & 4) || interlace_seen  < 0)
+               prevbpl[1 - lof][vpos][i] = prevbpl[lof][vpos][i] = 0;
        }
     }
 
@@ -2654,7 +2656,7 @@ void init_hz (void)
     write_log ("%s mode%s%s V=%dHz H=%dHz (%dx%d)\n",
        isntsc ? "NTSC" : "PAL",
        (bplcon0 & 4) ? " interlaced" : "",
-       doublescan ? " dblscan" : "",
+       doublescan > 0 ? " dblscan" : "",
        vblank_hz, vblank_hz * maxvpos,
        maxhpos, maxvpos);
 }
@@ -4384,7 +4386,7 @@ static void do_sprites (int hpos)
 
     if (vpos < sprite_vblank_endline)
        return;
-    if (doflickerfix () && (next_lineno & 1))
+    if (doflickerfix () && interlace_seen && (next_lineno & 1))
        return;
 
 #ifndef CUSTOM_SIMPLE
@@ -4807,16 +4809,18 @@ static void hsync_scandoubler (void)
        int diff;
        bpltmp[i] = bplpt[i];
        bpltmpx[i] = bplptx[i];
-       diff = prevbpl[lof][vpos][i] - prevbpl[1 - lof][vpos][i];
-       if (lof) {
-           if (bplcon0 & 4)
-               bplpt[i] = prevbpl[lof][vpos][i] - diff;
-       } else {
-           if (bplcon0 & 4)
-               bplpt[i] = prevbpl[lof][vpos][i];
-           else
-               bplpt[i] = bplpt[i] - diff;
+       if (prevbpl[lof][vpos][i] && prevbpl[1 - lof][vpos][i]) {
+           diff = prevbpl[lof][vpos][i] - prevbpl[1 - lof][vpos][i];
+           if (lof) {
+               if (bplcon0 & 4)
+                   bplpt[i] = prevbpl[lof][vpos][i] - diff;
+           } else {
+               if (bplcon0 & 4)
+                   bplpt[i] = prevbpl[lof][vpos][i];
+               else
+                   bplpt[i] = bplpt[i] - diff;
 
+           }
        }
     }
 
@@ -4942,7 +4946,7 @@ static void hsync_handler (void)
                cycle_diagram_free_cycles[f_fetchmode][GET_RES (f_bplcon0)][GET_PLANES_LIMIT (f_bplcon0)]);
        }
        hardware_line_completed (next_lineno);
-       if (doflickerfix ())
+       if (doflickerfix () && interlace_seen)
            hsync_scandoubler ();
     }
 
@@ -5004,7 +5008,7 @@ static void hsync_handler (void)
        if ((bplcon0 & 4) && currprefs.gfx_linedbl)
            notice_interlace_seen ();
        nextline_how = nln_normal;
-       if (doflickerfix ()) {
+       if (doflickerfix () && interlace_seen) {
            lineno *= 2;
        } else if (currprefs.gfx_linedbl && (doublescan <= 0 || interlace_seen > 0)) {
            lineno *= 2;
index 444869c87d381e7ef37523e3cd4279876b553ccf..9857053c60861f9f1ce8557ab2c0fa33b6f7d178 100644 (file)
--- a/drawing.c
+++ b/drawing.c
@@ -2759,10 +2759,13 @@ void vsync_handle_redraw (int long_frame, int lof_changed)
 
        if (framecnt == 0)
            finish_drawing_frame ();
-       if (interlace_seen > 0)
+       if (interlace_seen > 0) {
            interlace_seen = -1;
-       else if (interlace_seen == -1)
+       } else if (interlace_seen == -1) {
            interlace_seen = 0;
+           if (currprefs.gfx_scandoubler && currprefs.gfx_linedbl)
+               notice_screen_contents_lost ();
+       }
 
        /* At this point, we have finished both the hardware and the
         * drawing frame. Essentially, we are outside of all loops and
index d9ff13752fa8cecb7e825c4b3d8ba4f25db4a004..090c973074e94dc1eaae17ab2ffd9046d9e98560 100644 (file)
@@ -552,7 +552,7 @@ uae_u32 REGPARAM2 ahi_demux (TrapContext *context)
        return 1;
 
        case 10:
-#if 0
+#if 1
            if (OpenClipboard (0)) {
                clipdat = GetClipboardData (CF_TEXT);
                if (clipdat) {
@@ -566,7 +566,7 @@ uae_u32 REGPARAM2 ahi_demux (TrapContext *context)
 
        case 11:
        {
-#if 0
+#if 1
            int i;
            for (i = 0; i < clipsize; i++)
                put_byte (m68k_areg (&context->regs, 0) + i, clipdat[i]);
@@ -577,7 +577,7 @@ uae_u32 REGPARAM2 ahi_demux (TrapContext *context)
 
        case 12:
        {
-#if 0
+#if 1
            uae_u8 *addr = get_real_address (m68k_areg (&regs, 0));
            static LPTSTR p;
            int slen;
index 5e7efc81b0716884320c3f8401bf9342cd16ed3e..27e59a150f00609c8cf37e64ea7afbcc1f8e30a7 100644 (file)
 #include "native2amiga_api.h"
 
 static HWND chwnd;
+static HDC hdc;
 static uaecptr clipboard_data;
 static int vdelay, signaling;
 static uae_u8 *to_amiga;
 static uae_u32 to_amiga_size;
 static int clipopen;
-
-void clipboard_vsync (void)
-{
-    uaecptr task;
-    if (!signaling || !clipboard_data)
-       return;
-    vdelay--;
-    if (vdelay > 0)
-       return;
-    task = get_long (clipboard_data + 8);
-    if (task)
-       uae_Signal (task, 1 << 13);
-    vdelay = 50;
-}
-
-void clipboard_reset (void)
-{
-    vdelay = 100;
-    clipboard_data = 0;
-    signaling = 0;
-    xfree (to_amiga);
-    to_amiga = NULL;
-    to_amiga_size = 0;
-}
-
-void clipboard_init (HWND hwnd)
-{
-    chwnd = hwnd;
-}
+static int clipactive;
+static int clipboard_change;
+static void *clipboard_delayed_data;
+static int clipboard_delayed_size;
 
 static void to_amiga_start (void)
 {
@@ -134,52 +110,497 @@ static void to_iff_text (char *pctxt)
     xfree (txt);
 }
 
+static int clipboard_put_text (const char *txt);
 static void from_iff_text (uaecptr ftxt, uae_u32 len)
 {
-    uae_u32 size;
-    uae_u8 *addr;
-    char *txt, *pctxt;
+    uae_u8 *addr, *eaddr;
+    char *txt = NULL;
+    int txtsize = 0;
+    char *pctxt;
 
-    if (len < 18)
+    addr = get_real_address (ftxt);
+    eaddr = addr + len;
+    if (memcmp ("FTXT", addr + 8, 4))
        return;
-    if (!valid_address (ftxt, len))
+    addr += 12;
+    while (addr < eaddr) {
+        uae_u32 csize = (addr[4] << 24) | (addr[5] << 16) | (addr[6] << 8) | (addr[7] << 0);
+       if (addr + 8 + csize > eaddr)
+           break;
+       if (!memcmp (addr, "CHRS", 4) && csize) {
+           int prevsize = txtsize;
+           txtsize += csize;
+           if (!prevsize)
+               txtsize++; // space for terminating null
+           txt = realloc (txt, txtsize);
+           memcpy (txt + prevsize, addr + 8, csize);
+           txt[txtsize - 1] = 0;
+       }
+       addr += 8 + csize + (csize & 1);
+    }
+    pctxt = amigatopc (txt);
+    clipboard_put_text (pctxt);
+    xfree (pctxt);
+    free (txt);
+}
+
+   
+static void to_iff_ilbm (HBITMAP hbmp)
+{
+    BITMAP bmp;
+    int bmpw, w, h, bpp, iffbpp, tsize, size, x, y, i;
+    int iffsize, bodysize;
+    uae_u32 colors[256];
+    int cnt;
+    uae_u8 *iff, *p;
+    uae_u8 iffilbm[] = {
+       'F','O','R','M',0,0,0,0,'I','L','B','M',
+       'B','M','H','D',0,0,0,20, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+       'C','A','M','G',0,0,0, 4,  0,0,0,0,
+    };
+
+    if (!GetObject(hbmp, sizeof bmp, &bmp))
        return;
-    addr = get_real_address (ftxt);
-    if (memcmp ("FORM", addr, 4))
+    w = bmp.bmWidth;
+    h = bmp.bmHeight;
+    bpp = bmp.bmBitsPixel;
+    if (bpp < 8)
        return;
-    if (memcmp ("FTXTCHRS", addr + 8, 8))
+    bmpw = (w * bpp / 8 + 3) & ~3;
+    size = bmpw * h;
+    bmp.bmBits = xmalloc (size);
+    if (!GetBitmapBits (hbmp, size, bmp.bmBits)) {
+       xfree (bmp.bmBits);
+       return;
+    }
+
+    write_log ("BMP2IFF: W=%d H=%d bpp=%d\n", w, h, bpp);
+
+    iffbpp = bpp > 8 ? 24 : bpp;
+    cnt = 0;
+    for (y = 0; y < h && cnt < 256; y++) {
+        uae_u32 *s = (uae_u32*)(((uae_u8*)bmp.bmBits) + y * bmpw);
+        for (x = 0; x < w && cnt < 256; x++) {
+           uae_u32 v = s[x];
+           for (i = 0; i < cnt; i++) {
+               if (colors[i] == v)
+                   break;
+           }
+           if (i == 256)
+               break;
+           if (i == cnt)
+               colors[cnt++] = v;
+       }
+    }
+    if (cnt < 256) {
+       i = cnt;
+       iffbpp = 0;
+       while (i > 0) {
+           i >>= 1;
+           iffbpp++;
+       }
+       write_log ("BMP2IFF: Colors=%d BPP=%d\n", cnt, iffbpp);
+    }
+
+    bodysize = (((w + 15) & ~15) / 8) * h * iffbpp;
+
+    iffsize = sizeof (iffilbm) + (8 + 256 * 3 + 1) + (4 + 4) + bodysize;
+    iff = xcalloc (iffsize, 1);
+    memcpy (iff, iffilbm, sizeof iffilbm);
+    p = iff + 5 * 4;
+    // BMHD
+    p[0] = w >> 8;
+    p[1] = w;
+    p[2] = h >> 8;
+    p[3] = h;
+    p[8] = iffbpp;
+    p[14] = 1;
+    p[15] = 1;
+    p[16] = w >> 8;
+    p[17] = w;
+    p[18] = h >> 8;
+    p[19] = h;
+    p = iff + sizeof iffilbm - 4;
+    // CAMG
+    if (w > 400)
+       p[2] |= 0x80; // HIRES
+    if (h > 300)
+       p[3] |= 0x04; // LACE
+    p += 4;
+    if (iffbpp <= 8) {
+       int cols = 1 << iffbpp;
+       int cnt = 0;
+       memcpy (p, "CMAP", 4);
+       p[4] = 0;
+       p[5] = 0;
+       p[6] = (cols * 3) >> 8;
+       p[7] = (cols * 3);
+       p += 8;
+       for (i = 0; i < cols; i++) {
+           *p++ = colors[i] >> 16;
+           *p++ = colors[i] >> 8;
+           *p++ = colors[i] >> 0;
+           cnt += 3;
+       }
+       if (cnt & 1)
+           *p++ = 0;
+    }
+    memcpy (p, "BODY", 4);
+    p[4] = bodysize >> 24;
+    p[5] = bodysize >> 16;
+    p[6] = bodysize >>  8;
+    p[7] = bodysize >>  0;
+    p += 8;
+
+    if (bpp > 8 && iffbpp <= 8) {
+       for (y = 0; y < h && i < 256; y++) {
+           uae_u32 *s = (uae_u32*)(((uae_u8*)bmp.bmBits) + y * bmpw);
+           int b;
+           for (b = 0; b < iffbpp; b++) {
+               int mask2 = 1 << b;
+               for (x = 0; x < w; x++) {
+                   uae_u32 v = s[x];
+                   int off = x / 8;
+                   int mask = 1 << (7 - (x & 7));
+                   for (i = 0; i < (1 << iffbpp); i++) {
+                       if (colors[i] == v)
+                           break;
+                   }
+                   if (i & mask2)
+                       p[off] |= mask;
+               }
+               p += ((w + 15) & ~15) / 8;
+           }
+       }
+    } else if (bpp <= 8) {
+       for (y = 0; y < h; y++) {
+           uae_u8 *s = (uae_u8*)(((uae_u8*)bmp.bmBits) + y * bmpw);
+           int b;
+           for (b = 0; b < 8; b++) {
+               int mask2 = 1 << b;
+               for (x = 0; x < w; x++) {
+                   int off = x / 8;
+                   int mask = 1 << (7 - (x & 7));
+                   uae_u8 v = s[x];
+                   if (v & mask2)
+                       p[off] |= mask;
+               }
+               p += ((w + 15) & ~15) / 8;
+           }
+       }
+    } else {
+       for (y = 0; y < h; y++) {
+           uae_u32 *s = (uae_u32*)(((uae_u8*)bmp.bmBits) + y * bmpw);
+           int b, bb;
+           for (bb = 0; bb < 3; bb++) {
+               for (b = 0; b < 8; b++) {
+                   int mask2 = 1 << (((2 - bb) * 8) + b);
+                   for (x = 0; x < w; x++) {
+                       int off = x / 8;
+                       int mask = 1 << (7 - (x & 7));
+                       uae_u32 v = s[x];
+                       if (v & mask2)
+                           p[off] |= mask;
+                   }
+                   p += ((w + 15) & ~15) / 8;
+               }
+           }
+       }
+    }
+
+    tsize = p - iff - 8;
+    p = iff + 4;
+    p[0] = tsize >> 24;
+    p[1] = tsize >> 16;
+    p[2] = tsize >>  8;
+    p[3] = tsize >>  0;
+
+    to_amiga_size = 8 + tsize + (tsize & 1);
+    to_amiga = iff;
+#if 0
+    {
+       FILE *f = fopen("d:\\amiga\\amiga\\1.iff", "wb");
+       fwrite (to_amiga, to_amiga_size, 1, f);
+       fclose (f);
+    }
+#endif
+    to_amiga_start ();
+
+    xfree (bmp.bmBits);
+}
+
+static uae_u8 *iff_decomp (uae_u8 *addr, int w, int h, int planes)
+{
+    int y, i, w2;
+    uae_u8 *dst;
+
+    w2 = (w + 15) & ~15;
+    dst = xmalloc (w2 * h * planes);
+    for (y = 0; y < h * planes; y++) {
+       uae_u8 *p = dst + w2 * y;
+       uae_u8 *end = p + w2;
+       while (p < end) {
+           uae_s8 c = *addr++;
+           if (c >= 0 && c <= 127) {
+               uae_u8 cnt = c + 1;
+               for (i = 0; i < cnt && p < end; i++)
+                   *p++= *addr++;
+           } else if (c <= -1 && c >= -127) {
+               uae_u8 cnt = -c + 1;
+               uae_u8 v = *addr++;
+               for (i = 0; i < cnt && p < end; i++)
+                   *p++= v;
+           }
+       }
+    }
+    return dst;
+}
+
+static int clipboard_put_bmp (HBITMAP hbmp);
+static void from_iff_ilbm (uaecptr ilbm, uae_u32 len)
+{
+    HBITMAP hbm = NULL;
+    BITMAPINFO *bmih;
+    uae_u32 size, bmsize, camg;
+    uae_u8 *addr, *eaddr, *bmptr;
+    int i;
+    int w, bmpw, iffw, h, planes, compr, masking;
+    int bmhd, body;
+    RGBQUAD rgbx[256];
+
+    bmih = NULL;
+    bmhd = 0, body = 0;
+    bmsize = 0;
+    bmptr = NULL;
+    planes = 0; compr = 0;
+    addr = get_real_address (ilbm);
+    eaddr = addr + len;
+    size = (addr[4] << 24) | (addr[5] << 16) | (addr[6] << 8) | (addr[7] << 0);
+    if (memcmp ("ILBM", addr + 8, 4))
+       return;
+    camg = 0;
+    for (i = 0; i < 256; i++) {
+        rgbx[i].rgbRed = i;
+        rgbx[i].rgbGreen = i;
+        rgbx[i].rgbBlue = i;
+        rgbx[i].rgbReserved = 0;
+    }
+
+    addr += 12;
+    for (;;) {
+       uae_u8 chunk[4], csize;
+       uae_u8 *paddr, *ceaddr;
+
+       paddr = addr;
+       memcpy (chunk, addr, 4);
+       csize = (addr[4] << 24) | (addr[5] << 16) | (addr[6] << 8) | (addr[7] << 0);
+       addr += 8;
+       ceaddr = addr + csize;
+       if (!memcmp (chunk, "BMHD" ,4)) {
+           bmhd = 1;
+           w = (addr[0] << 8) | addr[1];
+           h = (addr[2] << 8) | addr[3];
+           planes = addr[8];
+           masking = addr[9];
+           compr = addr[10];
+
+       } else if (!memcmp (chunk, "CAMG" ,4)) {
+           camg = (addr[0] << 24) | (addr[1] << 16) | (addr[2] << 8) | (addr[3] << 0);
+           if ((camg & 0xFFFF0000) && !(camg & 0x1000))
+               camg = 0;
+       } else if (!memcmp (chunk, "CMAP" ,4)) {
+           if (planes <= 8) {
+               for (i = 0; i < (1 << planes) && addr < ceaddr; i++, addr += 3) {
+                   rgbx[i].rgbRed = addr[0];
+                   rgbx[i].rgbGreen = addr[1];
+                   rgbx[i].rgbBlue = addr[2];
+               }
+           }
+       } else if (!memcmp (chunk, "BODY" ,4) && bmhd) {
+           int x, y;
+           int ham, ehb, bmpdepth;
+           uae_u8 *caddr = NULL, *dptr;
+           body = 1;
+
+           write_log ("W=%d H=%d planes=%d mask=%d comp=%d CAMG=%08x\n", w, h, planes, masking, compr, camg);
+
+           ham = 0; ehb = 0;
+           if ((camg & 0x0800) && planes > 4)
+               ham = planes >= 7 ? 8 : 6;
+           if (!(camg & (0x0800 | 0x0400 | 0x8000 | 0x0040)) && (camg & 0x0080) && planes == 6)
+               ehb = 1;
+
+           if (planes <= 8 && !ham)
+               bmpdepth = 8;
+           else
+               bmpdepth = 32;
+           iffw = (w + 15) & ~15;
+           bmpw = (w * (bmpdepth / 8) + 3) & ~3;
+
+           bmsize = sizeof (BITMAPINFO);
+           if (bmpdepth <= 8)
+               bmsize += (1 << planes) * sizeof (RGBQUAD);
+           bmih = xcalloc (bmsize, 1);
+           bmih->bmiHeader.biSize = sizeof (bmih->bmiHeader);
+           bmih->bmiHeader.biWidth = w;
+           bmih->bmiHeader.biHeight = -h;
+           bmih->bmiHeader.biPlanes = 1;
+           bmih->bmiHeader.biBitCount = bmpdepth;
+           bmih->bmiHeader.biCompression = BI_RGB;
+           if (bmpdepth <= 8) {
+               RGBQUAD *rgb = bmih->bmiColors;
+               bmih->bmiHeader.biClrImportant = 0;
+               bmih->bmiHeader.biClrUsed = 1 << (planes + ehb);
+               for (i = 0; i < (1 << planes); i++) {
+                   rgb->rgbRed = rgbx[i].rgbRed;
+                   rgb->rgbGreen = rgbx[i].rgbGreen;
+                   rgb->rgbBlue = rgbx[i].rgbBlue;
+                   rgb++;
+               }
+               if (ehb) {
+                   for (i = 0; i < (1 << planes); i++) {
+                       rgb->rgbRed = rgbx[i].rgbRed >> 1;
+                       rgb->rgbGreen = rgbx[i].rgbGreen >> 1;
+                       rgb->rgbBlue = rgbx[i].rgbBlue >> 1;
+                       rgb++;
+                   }
+               }
+           }
+           bmptr = xcalloc (bmpw * h, 1);
+
+           if (compr)
+               addr = caddr = iff_decomp (addr, w, h, planes + (masking == 1 ? 1 : 0));
+           dptr = bmptr;
+
+           if (planes <= 8 && !ham) {
+               // paletted
+               for (y = 0; y < h; y++) {
+                   for (x = 0; x < w; x++) {
+                       int b;
+                       int off = x / 8;
+                       int mask = 1 << (7 - (x & 7));
+                       uae_u8 c = 0;
+                       for (b = 0; b < planes; b++)
+                           c |= (addr[b * iffw / 8 + off] & mask) ? (1 << b) : 0;
+                       dptr[x] = c;
+                   }
+                   dptr += bmpw;
+                   addr += planes * iffw / 8;
+                   if (masking == 1)
+                       addr += iffw / 8;
+               }
+           } else if (ham) {
+               // HAM6/8 -> 32
+               for (y = 0; y < h; y++) {
+                   DWORD ham_lastcolor = 0;
+                   for (x = 0; x < w; x++) {
+                       int b;
+                       int off = x / 8;
+                       int mask = 1 << (7 - (x & 7));
+                       uae_u8 c = 0;
+                       for (b = 0; b < planes; b++)
+                           c |= (addr[b * iffw / 8 + off] & mask) ? (1 << b) : 0;
+                       if (ham > 6) {
+                           DWORD c2 = c & 0x3f;
+                           switch (c >> 6)
+                           {
+                               case 0: ham_lastcolor = *((DWORD*)(&rgbx[c])); break;
+                               case 1: ham_lastcolor &= 0x00FFFF03; ham_lastcolor |= c2 << 2; break;
+                               case 2: ham_lastcolor &= 0x0003FFFF; ham_lastcolor |= c2 << 18; break;
+                               case 3: ham_lastcolor &= 0x00FF03FF; ham_lastcolor |= c2 << 10; break;
+                           }
+                       } else {
+                           uae_u32 c2 = c & 0x0f;
+                           switch (c >> 4)
+                           {
+                               case 0: ham_lastcolor = *((DWORD*)(&rgbx[c])); break;
+                               case 1: ham_lastcolor &= 0xFFFF00; ham_lastcolor |= c2 << 4; break;
+                               case 2: ham_lastcolor &= 0x00FFFF; ham_lastcolor |= c2 << 20; break;
+                               case 3: ham_lastcolor &= 0xFF00FF; ham_lastcolor |= c2 << 12; break;
+                           }
+                       }
+                       *((DWORD*)(&dptr[x * 4])) = ham_lastcolor;
+                   }
+                   dptr += bmpw;
+                   addr += planes * iffw / 8;
+                   if (masking == 1)
+                       addr += iffw / 8;
+               }
+           } else {
+               // 24bit RGB
+               for (y = 0; y < h; y++) {
+                   for (x = 0; x < w; x++) {
+                       uae_u8 c;
+                       int b;
+                       int off = x / 8;
+                       int mask = 1 << (7 - (x & 7));
+                       c = 0;
+                       for (b = 0; b < planes / 3; b++)
+                           c |= (addr[((0 * planes / 3) + b) * iffw / 8 + off] & mask) ? (1 << b) : 0;
+                       dptr[x * 4 + 2] = c;
+                       c = 0;
+                       for (b = 0; b < planes / 3; b++)
+                           c |= (addr[((1 * planes / 3) + b) * iffw / 8 + off] & mask) ? (1 << b) : 0;
+                       dptr[x * 4 + 1] = c;
+                       c = 0;
+                       for (b = 0; b < planes / 3; b++)
+                           c |= (addr[((2 * planes / 3) + b) * iffw / 8 + off] & mask) ? (1 << b) : 0;
+                       dptr[x * 4 + 0] = c;
+                   }
+                   dptr += bmpw;
+                   addr += planes * iffw / 8;
+                   if (masking == 1)
+                       addr += iffw / 8;
+               }
+           }
+           if (caddr)
+               xfree (caddr);
+       }
+       addr = paddr + csize + (csize & 1) + 8;
+       if (addr >= eaddr)
+           break;
+    }
+    if (body) {
+       hbm = CreateDIBitmap (hdc, &bmih->bmiHeader, CBM_INIT, bmptr, bmih, DIB_RGB_COLORS);
+       clipboard_put_bmp (hbm);
+    }
+    xfree (bmih);
+    xfree (bmptr);
+}
+
+static void from_iff (uaecptr data, uae_u32 len)
+{
+    uae_u8 *addr;
+
+    if (len < 18)
        return;
-    size = (addr[16] << 24) | (addr[17] << 16) | (addr[18] << 8) | (addr[19] << 0);
-    if (size >= len)
+    if (!valid_address (data, len))
        return;
-    txt = xcalloc (size + 1, 1);
-    if (!txt)
+    addr = get_real_address (data);
+    if (memcmp ("FORM", addr, 4))
        return;
-    memcpy (txt, addr + 20, size);
-    pctxt = amigatopc (txt);
-    clipboard_put_text (pctxt);
-    xfree (pctxt);
-    xfree (txt);
+    if (!memcmp ("FTXT", addr + 8, 4))
+       from_iff_text (data, len);
+    if (!memcmp ("ILBM", addr + 8, 4))
+       from_iff_ilbm (data, len);
 }
 
-void clipboard_changed (HWND hwnd)
+static void clipboard_read (HWND hwnd)
 {
     HGLOBAL hglb;
     UINT f;
-    int text = FALSE;
+    int text = FALSE, bmp = FALSE;
     
-    if (!clipboard_data)
-       return;
-    if (clipopen)
-       return;
     if (!OpenClipboard (hwnd))
        return;
     f = 0;
-    write_log ("clipboard: windows clipboard change: ");
+    write_log ("clipboard: windows clipboard: ");
     while (f = EnumClipboardFormats (f)) {
        write_log ("%d ", f);
        if (f == CF_TEXT)
            text = TRUE;
+       if (f == CF_BITMAP)
+           bmp = TRUE;
     }
     write_log ("\n");
     if (text) {
@@ -191,11 +612,57 @@ void clipboard_changed (HWND hwnd)
                GlobalUnlock (hglb);
            }
        }
+    } else if (bmp) {
+       HBITMAP hbmp = GetClipboardData (CF_BITMAP);
+       if (hbmp != NULL) {
+           to_iff_ilbm (hbmp);
+       }
     }
     CloseClipboard ();
 }
 
-int clipboard_put_text (const char *txt)
+static void clipboard_free_delayed (void)
+{
+    if (clipboard_delayed_data == 0)
+       return;
+    if (clipboard_delayed_size < 0)
+        xfree (clipboard_delayed_data);
+    else
+       DeleteObject (clipboard_delayed_data);
+    clipboard_delayed_data = 0;
+    clipboard_delayed_size = 0;
+}
+
+void clipboard_changed (HWND hwnd)
+{
+    if (!clipboard_data)
+       return;
+    if (clipopen)
+       return;
+    if (!clipactive) {
+       clipboard_change = 1;
+       return;
+    }
+    clipboard_read (hwnd);
+}
+
+static int clipboard_put_bmp_real (HBITMAP hbmp)
+{
+    int ret = FALSE;
+
+    if (!OpenClipboard (chwnd)) 
+       return ret;
+    clipopen++;
+    EmptyClipboard ();
+    SetClipboardData (CF_BITMAP, hbmp); 
+    ret = TRUE;
+    CloseClipboard ();
+    clipopen--;
+    write_log ("clipboard: BMP written to windows clipboard\n");
+    return ret;
+}
+
+static int clipboard_put_text_real (const char *txt)
 {
     HGLOBAL hglb;
     int ret = FALSE;
@@ -214,10 +681,29 @@ int clipboard_put_text (const char *txt)
     }
     CloseClipboard ();
     clipopen--;
-    write_log ("clipboard: writing to windows clipboard\n");
+    write_log ("clipboard: text written to windows clipboard\n");
     return ret;
 }
 
+static int clipboard_put_text (const char *txt)
+{
+    if (!clipactive)
+       return clipboard_put_text_real (txt);
+    clipboard_free_delayed ();
+    clipboard_delayed_data = my_strdup (txt);
+    clipboard_delayed_size = -1;
+    return 1;
+}
+
+static int clipboard_put_bmp (HBITMAP hbmp)
+{
+    if (!clipactive)
+       return clipboard_put_bmp_real (hbmp);
+    clipboard_delayed_data = (void*)hbmp;
+    clipboard_delayed_size = 1;
+    return 1;
+}
+
 void amiga_clipboard_init (void)
 {
     signaling = 0;
@@ -242,7 +728,7 @@ void amiga_clipboard_got_data (uaecptr data, uae_u32 size, uae_u32 actual)
 {
     uae_u8 *addr = get_real_address (data);
     write_log ("clipboard: <-amiga, %08x %d %d\n", data, size, actual);
-    from_iff_text (data, actual);
+    from_iff (data, actual);
 }
 
 void amiga_clipboard_want_data (void)
@@ -259,3 +745,54 @@ void amiga_clipboard_want_data (void)
     to_amiga = NULL;
     to_amiga_size = 0;
 }
+
+void clipboard_active (HWND hwnd, int active)
+{
+    clipactive = active;
+    if (clipactive && clipboard_change) {
+       clipboard_read (hwnd);
+       clipboard_change = 0;
+    }
+    if (!clipactive && clipboard_delayed_data) {
+       if (clipboard_delayed_size < 0) {
+           clipboard_put_text_real (clipboard_delayed_data);
+           xfree (clipboard_delayed_data);
+       } else {
+           clipboard_put_bmp_real ((HBITMAP)clipboard_delayed_data);
+       }
+       clipboard_delayed_data = NULL;
+       clipboard_delayed_size = 0;
+    }
+}
+
+void clipboard_vsync (void)
+{
+    uaecptr task;
+    if (!signaling || !clipboard_data)
+       return;
+    vdelay--;
+    if (vdelay > 0)
+       return;
+    task = get_long (clipboard_data + 8);
+    if (task)
+       uae_Signal (task, 1 << 13);
+    vdelay = 50;
+}
+
+void clipboard_reset (void)
+{
+    vdelay = 100;
+    clipboard_free_delayed ();
+    clipboard_data = 0;
+    signaling = 0;
+    xfree (to_amiga);
+    to_amiga = NULL;
+    to_amiga_size = 0;
+    ReleaseDC (chwnd, hdc);
+}
+
+void clipboard_init (HWND hwnd)
+{
+    chwnd = hwnd;
+    hdc = GetDC (chwnd);
+}
index fd14b1656799c3b01c1873815ed53c675895e317..d29dd93254e75d3a0dd418f18f7ed925241ac245 100644 (file)
@@ -1,5 +1,5 @@
 
 extern void clipboard_init (HWND hwnd);
 extern void clipboard_changed (HWND);
-extern int clipboard_put_text (const char *txt);
-extern void clipboard_reset (void);
\ No newline at end of file
+extern void clipboard_reset (void);
+extern void clipboard_active (HWND, int);
index ae71e75e208f5446ed2b085b8f18413b305d6325..a774d8dcc6b10d112dba7ec2ce8f4c43c34983c5 100644 (file)
@@ -626,6 +626,7 @@ static void winuae_active (HWND hWnd, int minimized)
     if (!minimized)
        lcd_priority (1);
 #endif
+    clipboard_active (hAmigaWnd, 1);
 }
 
 static void winuae_inactive (HWND hWnd, int minimized)
@@ -639,6 +640,7 @@ static void winuae_inactive (HWND hWnd, int minimized)
     focus = 0;
     wait_keyrelease ();
     setmouseactive (0);
+    clipboard_active (hAmigaWnd, 0);
     inputdevice_unacquire ();
     pri = &priorities[currprefs.win32_inactive_priority];
     if (!quit_program) {
index 122f1a22ea972139aaff85e0ffeb4ed1954d2fb9..04efdd10f71e9a4bba7b90d99b91d24d5473579d 100644 (file)
@@ -17,8 +17,8 @@
 
 #define WINUAEPUBLICBETA 1
 
-#define WINUAEBETA "9"
-#define WINUAEDATE MAKEBD(2009, 1, 21)
+#define WINUAEBETA "10"
+#define WINUAEDATE MAKEBD(2009, 1, 24)
 #define WINUAEEXTRA ""
 #define WINUAEREV ""
 
index c9c7547356a9babfe9ef1919da82d2817ece63aa..2886d765e777ba05f09bf7f78badcdb25266adde 100644 (file)
@@ -1,4 +1,18 @@
 
+Beta 10:
+
+- clipboard: multiple CHRS chunks inside FTXT supported
+- clipboard: IFF ILBM Amiga to PC support implemented. EHB supported,
+  HAM6/8 automatically converted to 24-bit, 24-bit IFF supported
+- clipboard: PC to Amiga IFF conversion. Counts the number of colors,
+  if 256 or less, creates normal paletted IFF image, if more, creates
+  24 bit IFF.
+- clipboard: Windows clipboard is only updated when there is new data
+  in Amiga clipboard and WinUAE loses focus. Same with Amiga clipboard,
+  do not copy contents of Windows clipboard until WinUAE gains focus.
+- switching from "artifact fixed" interlace mode to non-laced now
+  force updates the screen completely, fixes possible glitches
+
 Beta 9:
 
 - flickerfixer improved, also first and last line glitch fixed, sprite
@@ -13,7 +27,7 @@ Beta 9:
   [<if disabled plane, show it as all zeros or as all ones>]
 - automatic, transparent clipboard sharing! Data in Windows clipboard
   is automatically copied to Amiga clipboard.device unit 0 and vice
-  versa. Only text-based content currently supported.
+  versa. Only text-based content currently supported. OS2+ only.
 - REPEAT NOTE: D3D/OGL filter is still broken. Do not use.
 
 Beta 8: