]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
imported winuaesrc1500b3.zip
authorToni Wilen <twilen@winuae.net>
Sat, 23 Feb 2008 10:48:11 +0000 (12:48 +0200)
committerToni Wilen <twilen@winuae.net>
Mon, 22 Feb 2010 19:38:48 +0000 (21:38 +0200)
22 files changed:
debug.c
drawing.c
expansion.c
gfxutil.c
include/xwin.h
memory.c
od-win32/ahidsound.c
od-win32/hardfile_win32.c
od-win32/machdep/maccess.h
od-win32/mman.c
od-win32/picasso96_win.c
od-win32/picasso96_win.h
od-win32/resources/resource
od-win32/resources/resource.h
od-win32/resources/winuae.rc
od-win32/sysconfig.h
od-win32/win32.c
od-win32/win32.h
od-win32/win32gfx.c
od-win32/win32gui.c
od-win32/winuaechangelog.txt
p96_blit.c [new file with mode: 0755]

diff --git a/debug.c b/debug.c
index febf5dbece0e2b517900f027087734e2c8f0081f..9470a1ab6badb61f5957d484463709145a27383a 100755 (executable)
--- a/debug.c
+++ b/debug.c
@@ -113,8 +113,8 @@ static char help[] = {
     "  H[H] <cnt>            Show PC history (HH=full CPU info) <cnt> instructions\n"
     "  C <value>             Search for values like energy or lifes in games\n"
     "  Cl                    List currently found trainer addresses\n"
-    "  D[idx <[max diff]>]   Deep trainer. i=new value must be larger, d=smaller,\n"
-    "                        x = must be same.\n"
+    "  D[idxzs <[max diff]>] Deep trainer. i=new value must be larger, d=smaller,\n"
+    "                        x = must be same, z = must be different, s = restart.\n"
     "  W <address> <value>   Write into Amiga memory\n"
     "  w <num> <address> <length> <R/W/I/F> [<value>] (read/write/opcode/freeze)\n"
     "                        Add/remove memory watchpoints\n"
@@ -900,7 +900,7 @@ static void deepcheatsearch (char **c)
     static int memsize, memsize2;
     uae_u8 *p1, *p2;
     uaecptr addr, end;
-    int i, wasmodified;
+    int i, wasmodified, nonmodified;
     static int size;
     static int inconly, deconly, maxdiff;
     int addrcnt, cnt;
@@ -951,6 +951,7 @@ static void deepcheatsearch (char **c)
     }
     inconly = deconly = 0;
     wasmodified = v == 'X' ? 0 : 1;
+    nonmodified = v == 'Z' ? 1 : 0;
     if (v == 'I')
        inconly = 1;
     if (v == 'D')
@@ -977,7 +978,7 @@ static void deepcheatsearch (char **c)
        }
 
        if (p2[addroff] & addrmask) {
-           if (wasmodified) {
+           if (wasmodified && !nonmodified) {
                int diff = b - b2;
                if (b == b2)
                    doremove = 1;
@@ -987,6 +988,8 @@ static void deepcheatsearch (char **c)
                    doremove = 1;
                if (deconly && diff > 0)
                    doremove = 1;
+           } else if (nonmodified && b != b2) {
+               doremove = 1;
            } else if (!wasmodified && b != b2) {
                doremove = 1;
            }
index a5368b90d7fc28953afcce67114280d26a641f40..5c90557375853617d473d122a456db7165a39e0c 100755 (executable)
--- a/drawing.c
+++ b/drawing.c
@@ -2512,7 +2512,7 @@ STATIC_INLINE void check_picasso (void)
 {
 #ifdef PICASSO96
     if (picasso_on && picasso_redraw_necessary)
-       picasso_refresh (1);
+       picasso_refresh ();
     picasso_redraw_necessary = 0;
 
     if (picasso_requested_on == picasso_on)
index 6d9fd9c631e3a78ed7c4f2935d141f4a20b19436..ac01d254dee4611282c434b9e641390e9f8f98dd 100755 (executable)
@@ -1264,7 +1264,9 @@ void expamem_reset (void)
     }
 
     z3fastmem_start = currprefs.z3fastmem_start;
-    if (!p96mode || !canbang)
+    if (!canbang)
+       p96mode = 0;
+    if (!p96mode)
        p96memstart();
     (*card_init[0]) ();
 }
index 0dd3a1fc05f4d9694aed9b55779ea8e626f8a374..2e36734835c9c64cf84b022ad98ee92b397696fd 100755 (executable)
--- a/gfxutil.c
+++ b/gfxutil.c
@@ -193,6 +193,20 @@ static uae_u32 lowbits(int v, int shift, int lsize)
     return v;
 }
 
+void alloc_colors_picasso (int rw, int gw, int bw, int rs, int gs, int bs, int aw, int as, int alpha, int byte_swap)
+{
+    int i;
+
+    for (i = 0; i < 65536; i++) {
+        uae_u32 r, g, b;
+        r = (((i >> 11) & 31) << 3) | lowbits (i, 11, 3);
+        g = (((i >>  5) & 63) << 2) | lowbits (i,  5, 2);
+        b = (((i >>  0) & 31) << 3) | lowbits (i,  0, 3);
+       p96_rgbx16[i] = doMask(r, rw, rs) | doMask(g, gw, gs) | doMask(b, bw, bs);
+    }
+}
+    
+
 void alloc_colors64k (int rw, int gw, int bw, int rs, int gs, int bs, int aw, int as, int alpha, int byte_swap)
 {
     int bpp = rw + gw + bw + aw;
index 281241026bd46790f38fe4e95e696445388c4fcf..b4b83084b713c54d7ce4e3530fa571db46979539 100755 (executable)
@@ -11,6 +11,7 @@ typedef uae_u32 xcolnr;
 typedef int (*allocfunc_type)(int, int, int, xcolnr *);
 
 extern xcolnr xcolors[4096];
+extern uae_u32 p96_rgbx16[65536];
 
 extern int graphics_setup (void);
 extern int graphics_init (void);
@@ -40,6 +41,7 @@ extern unsigned int doMask256 (int p, int bits, int shift);
 extern void setup_maxcol (int);
 extern void alloc_colors256 (int (*)(int, int, int, xcolnr *));
 extern void alloc_colors64k (int, int, int, int, int, int, int, int, int, int);
+extern void alloc_colors_picasso (int, int, int, int, int, int, int, int, int, int);
 extern void setup_greydither (int bits, allocfunc_type allocfunc);
 extern void setup_greydither_maxcol (int maxcol, allocfunc_type allocfunc);
 extern void setup_dither (int bits, allocfunc_type allocfunc);
index f40bdc3eb13c7808d60899984a7f72f6da452083..6e4300d7db8345ed337feaab9ab92a54564d8e3e 100755 (executable)
--- a/memory.c
+++ b/memory.c
@@ -37,6 +37,12 @@ int candirect = -1;
 int special_mem;
 #endif
 
+static int canjit (void)
+{
+    if (canbang)
+       return 1;
+    return 0;
+}
 static void nocanbang(void)
 {
     canbang = 0;
@@ -2783,7 +2789,7 @@ static shmpiece *find_shmpiece (uae_u8 *base)
 
 static void delete_shmmaps (uae_u32 start, uae_u32 size)
 {
-    if (!canbang)
+    if (!canjit ())
        return;
 
     while (size) {
@@ -2825,7 +2831,7 @@ static void add_shmmaps (uae_u32 start, addrbank *what)
     shmpiece *y;
     uae_u8 *base = what->baseaddr;
 
-    if (!canbang)
+    if (!canjit ())
        return;
     if (!base)
        return;
@@ -2856,7 +2862,7 @@ uae_u8 *mapped_malloc (size_t s, char *file)
     void *answer;
     shmpiece *x;
 
-    if (!canbang) {
+    if (!canjit()) {
        nocanbang();
        return xcalloc (s + 4, 1);
     }
index 5062245c8061c2519422210e4c473b7a61adc9d8..1e297c92252d3541c827eb04d6485356cb9c6998 100755 (executable)
@@ -605,7 +605,7 @@ uae_u32 REGPARAM2 ahi_demux (TrapContext *context)
            if (!currprefs.cs_ciaatod)
                changed_prefs.cs_ciaatod = currprefs.cs_ciaatod = currprefs.ntscmode ? 2 : 1;
            p96refresh_active=1;
-           picasso_refresh (0);
+           picasso_refresh ();
        } //end for higher P96 mouse draw rate
        return 0;
 
index e0a9e2b8b7b87c7e37345e77ef66d81d1574a3c7..57e33044eadc3dfa5c1569d821d4470fcbd4649c 100755 (executable)
@@ -641,137 +641,38 @@ int hdf_write (struct hardfiledata *hfd, void *buffer, uae_u64 offset, int len)
 
 #ifdef WINDDK
 
-/* see MS KB article Q264203 more more information */
-
-static BOOL GetDeviceProperty(HDEVINFO IntDevInfo, DWORD Index, DWORD *index2, uae_u8 *buffer)
-/*++
-
-Routine Description:
-
-    This routine enumerates the disk devices using the Device interface
-    GUID DiskClassGuid. Gets the Adapter & Device property from the port
-    driver. Then sends IOCTL through SPTI to get the device Inquiry data.
-
-Arguments:
-
-    IntDevInfo - Handles to the interface device information list
-
-    Index      - Device member
 
-Return Value:
-
-  TRUE / FALSE. This decides whether to continue or not
-
---*/
+static BOOL GetDevicePropertyFromName(const char *DevicePath, DWORD Index, DWORD *index2, uae_u8 *buffer, int ignoreduplicates)
 {
-    STORAGE_PROPERTY_QUERY              query;
-    SP_DEVICE_INTERFACE_DATA            interfaceData;
-    PSP_DEVICE_INTERFACE_DETAIL_DATA    interfaceDetailData = NULL;
+    int i, j;
+    int ret = -1;
+    PUCHAR p;
+    STORAGE_PROPERTY_QUERY query;
+    DRIVE_LAYOUT_INFORMATION           *dli;
+    struct uae_driveinfo *udi;
+    char orgname[1024];
+    HANDLE hDevice = INVALID_HANDLE_VALUE;
+    UCHAR outBuf[20000];
+    DISK_GEOMETRY                      dg;
+    GET_LENGTH_INFORMATION             gli;
     PSTORAGE_ADAPTER_DESCRIPTOR         adpDesc;
     PSTORAGE_DEVICE_DESCRIPTOR          devDesc;
-    HANDLE                              hDevice = INVALID_HANDLE_VALUE;
+    int gli_ok;
     BOOL                                status;
-    PUCHAR                              p;
-    UCHAR                               outBuf[20000];
     ULONG                               length = 0,
                                        returned = 0,
                                        returnedLength;
-    DWORD                               interfaceDetailDataSize = 0,
-                                       reqSize,
-                                       errorCode,
-                                       i, j;
-    DRIVE_LAYOUT_INFORMATION           *dli;
-    DISK_GEOMETRY                      dg;
-    GET_LENGTH_INFORMATION             gli;
-    int gli_ok;
-    int ret = -1;
-    struct uae_driveinfo *udi;
-    char orgname[1024];
-
-    interfaceData.cbSize = sizeof (SP_INTERFACE_DEVICE_DATA);
-
-    status = SetupDiEnumDeviceInterfaces (
-               IntDevInfo,             // Interface Device Info handle
-               0,                      // Device Info data
-               &GUID_DEVINTERFACE_DISK, // Interface registered by driver
-               Index,                  // Member
-               &interfaceData          // Device Interface Data
-               );
-
-    if (status == FALSE) {
-       errorCode = GetLastError();
-       if (errorCode != ERROR_NO_MORE_ITEMS) {
-           write_log ("SetupDiEnumDeviceInterfaces failed with error: %d\n", errorCode);
-       }
-       ret = 0;
-       goto end;
-    }
-
-    //
-    // Find out required buffer size, so pass NULL
-    //
-
-    status = SetupDiGetDeviceInterfaceDetail (
-               IntDevInfo,         // Interface Device info handle
-               &interfaceData,     // Interface data for the event class
-               NULL,               // Checking for buffer size
-               0,                  // Checking for buffer size
-               &reqSize,           // Buffer size required to get the detail data
-               NULL                // Checking for buffer size
-               );
-
-    //
-    // This call returns ERROR_INSUFFICIENT_BUFFER with reqSize
-    // set to the required buffer size. Ignore the above error and
-    // pass a bigger buffer to get the detail data
-    //
-
-    if (status == FALSE) {
-       errorCode = GetLastError();
-       if (errorCode != ERROR_INSUFFICIENT_BUFFER) {
-           write_log ("SetupDiGetDeviceInterfaceDetail failed with error: %d\n", errorCode);
-           ret = 0;
-           goto end;
-       }
-    }
-
-    //
-    // Allocate memory to get the interface detail data
-    // This contains the devicepath we need to open the device
-    //
-
-    interfaceDetailDataSize = reqSize;
-    interfaceDetailData = malloc (interfaceDetailDataSize);
-    if (interfaceDetailData == NULL) {
-       write_log ("Unable to allocate memory to get the interface detail data.\n");
-       ret = 0;
-       goto end;
-    }
-    interfaceDetailData->cbSize = sizeof (SP_INTERFACE_DEVICE_DETAIL_DATA);
-
-    status = SetupDiGetDeviceInterfaceDetail (
-                 IntDevInfo,               // Interface Device info handle
-                 &interfaceData,           // Interface data for the event class
-                 interfaceDetailData,      // Interface detail data
-                 interfaceDetailDataSize,  // Interface detail data size
-                 &reqSize,                 // Buffer size required to get the detail data
-                 NULL);                    // Interface device info
-
-    if (status == FALSE) {
-       write_log ("Error in SetupDiGetDeviceInterfaceDetail failed with error: %d\n", GetLastError());
-       ret = 0;
-       goto end;
-    }
 
     //
     // Now we have the device path. Open the device interface
     // to send Pass Through command
 
     udi = &uae_drives[*index2];
-    strcpy (udi->device_path, interfaceDetailData->DevicePath);
+    memset (udi, 0, sizeof (struct uae_driveinfo));
+    strcpy (udi->device_path, DevicePath);
     write_log ("opening device '%s'\n", udi->device_path);
     hDevice = CreateFile(
-               interfaceDetailData->DevicePath,    // device interface name
+               udi->device_path,    // device interface name
                GENERIC_READ | GENERIC_WRITE,       // dwDesiredAccess
                FILE_SHARE_READ | FILE_SHARE_WRITE, // dwShareMode
                NULL,                               // lpSecurityAttributes
@@ -785,8 +686,6 @@ Return Value:
     // So we can release the interfaceDetailData buffer
     //
 
-    free (interfaceDetailData);
-    interfaceDetailData = NULL;
 
     if (hDevice == INVALID_HANDLE_VALUE) {
        write_log ("CreateFile failed with error: %d\n", GetLastError());
@@ -825,62 +724,74 @@ Return Value:
                        sizeof (outBuf),
                        &returnedLength,
                        NULL);
-       if (!status) {
-           write_log ("IOCTL_STORAGE_QUERY_PROPERTY failed with error code %d.\n", GetLastError());
+    if (!status) {
+        write_log ("IOCTL_STORAGE_QUERY_PROPERTY failed with error code %d.\n", GetLastError());
+        ret = 1;
+        goto end;
+    }
+    devDesc = (PSTORAGE_DEVICE_DESCRIPTOR) outBuf;
+    p = (PUCHAR) outBuf;
+    if (devDesc->DeviceType != INQ_DASD && devDesc->DeviceType != INQ_ROMD && devDesc->DeviceType != INQ_OPTD) {
+        ret = 1;
+        write_log ("not a direct access device, ignored (type=%d)\n", devDesc->DeviceType);
+        goto end;
+    }
+    if (devDesc->VendorIdOffset && p[devDesc->VendorIdOffset]) {
+        j = 0;
+        for (i = devDesc->VendorIdOffset; p[i] != (UCHAR) NULL && i < returnedLength; i++)
+           udi->vendor_id[j++] = p[i];
+    }
+    if (devDesc->ProductIdOffset && p[devDesc->ProductIdOffset]) {
+       j = 0;
+       for (i = devDesc->ProductIdOffset; p[i] != (UCHAR) NULL && i < returnedLength; i++)
+           udi->product_id[j++] = p[i];
+    }
+    if (devDesc->ProductRevisionOffset && p[devDesc->ProductRevisionOffset]) {
+        j = 0;
+        for (i = devDesc->ProductRevisionOffset; p[i] != (UCHAR) NULL && i < returnedLength; i++)
+           udi->product_rev[j++] = p[i];
+    }
+    if (devDesc->SerialNumberOffset && p[devDesc->SerialNumberOffset]) {
+        j = 0;
+        for (i = devDesc->SerialNumberOffset; p[i] != (UCHAR) NULL && i < returnedLength; i++)
+           udi->product_serial[j++] = p[i];
+    }
+    if (udi->vendor_id[0])
+        strcat (udi->device_name, udi->vendor_id);
+    if (udi->product_id[0]) {
+        if (udi->device_name[0])
+           strcat (udi->device_name, " ");
+       strcat (udi->device_name, udi->product_id);
+    }
+    if (udi->product_rev[0]) {
+        if (udi->device_name[0])
+           strcat (udi->device_name, " ");
+       strcat (udi->device_name, udi->product_rev);
+    }
+    if (udi->product_serial[0]) {
+        if (udi->device_name[0])
+           strcat (udi->device_name, " ");
+       strcat (udi->device_name, udi->product_serial);
+    }
+    if (!udi->device_name[0]) {
+        write_log ("empty device id?!?, replacing with device path\n");
+        strcpy (udi->device_name, udi->device_path);
+    }
+    udi->removablemedia = devDesc->RemovableMedia;
+    write_log ("device id string: '%s'\n", udi->device_name);
+    if (ignoreduplicates) {
+       sprintf (orgname, "HD_%s", udi->device_name);
+       if (isharddrive (orgname) >= 0) {
+           write_log ("duplicate device, ignored\n");
            ret = 1;
            goto end;
        }
-       devDesc = (PSTORAGE_DEVICE_DESCRIPTOR) outBuf;
-       p = (PUCHAR) outBuf;
-       if (devDesc->DeviceType != INQ_DASD && devDesc->DeviceType != INQ_ROMD && devDesc->DeviceType != INQ_OPTD) {
+       if (!udi->removablemedia) {
+           write_log ("drive letter not removable, ignored\n");
            ret = 1;
-           write_log ("not a direct access device, ignored (type=%d)\n", devDesc->DeviceType);
            goto end;
        }
-       if (devDesc->VendorIdOffset && p[devDesc->VendorIdOffset]) {
-           j = 0;
-           for (i = devDesc->VendorIdOffset; p[i] != (UCHAR) NULL && i < returnedLength; i++)
-               udi->vendor_id[j++] = p[i];
-       }
-       if (devDesc->ProductIdOffset && p[devDesc->ProductIdOffset]) {
-           j = 0;
-           for (i = devDesc->ProductIdOffset; p[i] != (UCHAR) NULL && i < returnedLength; i++)
-               udi->product_id[j++] = p[i];
-       }
-       if (devDesc->ProductRevisionOffset && p[devDesc->ProductRevisionOffset]) {
-           j = 0;
-           for (i = devDesc->ProductRevisionOffset; p[i] != (UCHAR) NULL && i < returnedLength; i++)
-               udi->product_rev[j++] = p[i];
-       }
-       if (devDesc->SerialNumberOffset && p[devDesc->SerialNumberOffset]) {
-           j = 0;
-           for (i = devDesc->SerialNumberOffset; p[i] != (UCHAR) NULL && i < returnedLength; i++)
-               udi->product_serial[j++] = p[i];
-       }
-       if (udi->vendor_id[0])
-           strcat (udi->device_name, udi->vendor_id);
-       if (udi->product_id[0]) {
-           if (udi->device_name[0])
-               strcat (udi->device_name, " ");
-           strcat (udi->device_name, udi->product_id);
-       }
-       if (udi->product_rev[0]) {
-           if (udi->device_name[0])
-               strcat (udi->device_name, " ");
-           strcat (udi->device_name, udi->product_rev);
-       }
-       if (udi->product_serial[0]) {
-           if (udi->device_name[0])
-               strcat (udi->device_name, " ");
-           strcat (udi->device_name, udi->product_serial);
-       }
-       if (!udi->device_name[0]) {
-           write_log ("empty device id?!?, replacing with device path\n");
-           strcpy (udi->device_name, udi->device_path);
-       }
-       udi->removablemedia = devDesc->RemovableMedia;
-
-       write_log ("device id string: '%s'\n", udi->device_name);
+    }
     strcpy (orgname, udi->device_name);
     if (!DeviceIoControl (hDevice, IOCTL_DISK_GET_DRIVE_GEOMETRY, NULL, 0, (void*)&dg, sizeof (dg), &returnedLength, NULL)) {
        DWORD err = GetLastError();
@@ -977,15 +888,138 @@ Return Value:
        goto end;
 amipartfound:
     sprintf (udi->device_name, "HD_%s", orgname);
-    while (isharddrive (udi->device_name) >= 0)
-       strcat (udi->device_name, "_");
+    {
+       int cnt = 1;
+       int off = strlen (udi->device_name);
+       while (isharddrive (udi->device_name) >= 0) {
+           udi->device_name[off] = '_';
+           udi->device_name[off + 1] = cnt + '0';
+           udi->device_name[off + 2] = 0;
+           cnt++;
+       }
+    }  
     (*index2)++;
 end:
-    free (interfaceDetailData);
     if (hDevice != INVALID_HANDLE_VALUE)
        CloseHandle (hDevice);
     return ret;
 }
+
+/* see MS KB article Q264203 more more information */
+
+static BOOL GetDeviceProperty(HDEVINFO IntDevInfo, DWORD Index, DWORD *index2, uae_u8 *buffer)
+/*++
+
+Routine Description:
+
+    This routine enumerates the disk devices using the Device interface
+    GUID DiskClassGuid. Gets the Adapter & Device property from the port
+    driver. Then sends IOCTL through SPTI to get the device Inquiry data.
+
+Arguments:
+
+    IntDevInfo - Handles to the interface device information list
+
+    Index      - Device member
+
+Return Value:
+
+  TRUE / FALSE. This decides whether to continue or not
+
+--*/
+{
+    SP_DEVICE_INTERFACE_DATA            interfaceData;
+    PSP_DEVICE_INTERFACE_DETAIL_DATA    interfaceDetailData = NULL;
+    BOOL                                status;
+    DWORD                               interfaceDetailDataSize = 0,
+                                       reqSize,
+                                       errorCode;
+    int ret = -1;
+
+    interfaceData.cbSize = sizeof (SP_INTERFACE_DEVICE_DATA);
+
+    status = SetupDiEnumDeviceInterfaces (
+               IntDevInfo,             // Interface Device Info handle
+               0,                      // Device Info data
+               &GUID_DEVINTERFACE_DISK, // Interface registered by driver
+               Index,                  // Member
+               &interfaceData          // Device Interface Data
+               );
+
+    if (status == FALSE) {
+       errorCode = GetLastError();
+       if (errorCode != ERROR_NO_MORE_ITEMS) {
+           write_log ("SetupDiEnumDeviceInterfaces failed with error: %d\n", errorCode);
+       }
+       ret = 0;
+       goto end;
+    }
+
+    //
+    // Find out required buffer size, so pass NULL
+    //
+
+    status = SetupDiGetDeviceInterfaceDetail (
+               IntDevInfo,         // Interface Device info handle
+               &interfaceData,     // Interface data for the event class
+               NULL,               // Checking for buffer size
+               0,                  // Checking for buffer size
+               &reqSize,           // Buffer size required to get the detail data
+               NULL                // Checking for buffer size
+               );
+
+    //
+    // This call returns ERROR_INSUFFICIENT_BUFFER with reqSize
+    // set to the required buffer size. Ignore the above error and
+    // pass a bigger buffer to get the detail data
+    //
+
+    if (status == FALSE) {
+       errorCode = GetLastError();
+       if (errorCode != ERROR_INSUFFICIENT_BUFFER) {
+           write_log ("SetupDiGetDeviceInterfaceDetail failed with error: %d\n", errorCode);
+           ret = 0;
+           goto end;
+       }
+    }
+
+    //
+    // Allocate memory to get the interface detail data
+    // This contains the devicepath we need to open the device
+    //
+
+    interfaceDetailDataSize = reqSize;
+    interfaceDetailData = malloc (interfaceDetailDataSize);
+    if (interfaceDetailData == NULL) {
+       write_log ("Unable to allocate memory to get the interface detail data.\n");
+       ret = 0;
+       goto end;
+    }
+    interfaceDetailData->cbSize = sizeof (SP_INTERFACE_DEVICE_DETAIL_DATA);
+
+    status = SetupDiGetDeviceInterfaceDetail (
+                 IntDevInfo,               // Interface Device info handle
+                 &interfaceData,           // Interface data for the event class
+                 interfaceDetailData,      // Interface detail data
+                 interfaceDetailDataSize,  // Interface detail data size
+                 &reqSize,                 // Buffer size required to get the detail data
+                 NULL);                    // Interface device info
+
+    if (status == FALSE) {
+       write_log ("Error in SetupDiGetDeviceInterfaceDetail failed with error: %d\n", GetLastError());
+       ret = 0;
+       goto end;
+    }
+    
+    ret = GetDevicePropertyFromName (interfaceDetailData->DevicePath, Index, index2, buffer, 0);
+
+end:
+    free (interfaceDetailData);
+
+    return ret;
+}
+
+
 #endif
 
 
@@ -996,8 +1030,10 @@ static int hdf_init2 (int force)
 #ifdef WINDDK
     HDEVINFO hIntDevInfo;
 #endif
-    DWORD index = 0, index2 = 0;
+    DWORD index = 0, index2 = 0, drive;
     uae_u8 *buffer;
+    UINT errormode;
+    DWORD dwDriveMask;
     static int done;
 
     if (done && !force)
@@ -1020,6 +1056,23 @@ static int hdf_init2 (int force)
            }
            SetupDiDestroyDeviceInfoList(hIntDevInfo);
        }
+       errormode = SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX);
+       dwDriveMask = GetLogicalDrives();
+        for(drive = 'A'; drive <= 'Z'; drive++) {
+           if((dwDriveMask & 1) && drive >= 'C') {
+               char tmp1[20], tmp2[20];
+               DWORD drivetype;
+               sprintf (tmp1, "%c:\\", drive);
+               drivetype = GetDriveType(tmp1);
+               if (drivetype != DRIVE_REMOTE) {
+                   sprintf (tmp2, "\\\\.\\%c:", drive);
+                   GetDevicePropertyFromName (tmp2, index, &index2, buffer, 1);
+                   num_drives = index2;
+               }
+           }
+           dwDriveMask >>= 1;
+       }
+       SetErrorMode(errormode);
 #if 0
        hIntDevInfo = SetupDiGetClassDevs (&GUID_DEVCLASS_MTD, NULL, NULL, DIGCF_PRESENT);
        if (hIntDevInfo != INVALID_HANDLE_VALUE) {
@@ -1086,7 +1139,7 @@ char *hdf_getnameharddrive (int index, int flags, int *sectorsize)
            else
                sprintf (tmp, "%.1fM", ((double)(uae_u32)(size / (1024))) / 1024.0);
        }
-       sprintf (name, "%10s [%s] %s", dang, tmp, uae_drives[index].device_name);
+       sprintf (name, "%10s [%s] %s", dang, tmp, uae_drives[index].device_name + 3);
        return name;
     }
     if (flags & 2)
index 9a725692b6ba6bb6dd0356250cb98435ae32ffde..4383f1b312aade7eeeb959309a577827b258ce92 100755 (executable)
@@ -8,9 +8,11 @@
   * Copyright 1996 Bernd Schmidt
   */
 
+#define ALIGN_POINTER_TO32(p) ((~(unsigned long)(p)) & 3)
+
 STATIC_INLINE uae_u32 do_get_mem_long(uae_u32 *a)
 {
-#if !defined(X86_MSVC_ASSEMBLY)
+#if !defined(X86_MSVC_ASSEMBLY_MEMACCESS)
     uae_u8 *b = (uae_u8 *)a;
     return (*b << 24) | (*(b+1) << 16) | (*(b+2) << 8) | (*(b+3));
 #else
@@ -37,7 +39,7 @@ STATIC_INLINE uae_u16 do_get_mem_word(uae_u16 *a)
 
 STATIC_INLINE void do_put_mem_long(uae_u32 *a, uae_u32 v)
 {
-#if !defined(X86_MSVC_ASSEMBLY)
+#if !defined(X86_MSVC_ASSEMBLY_MEMACCESS)
     uae_u8 *b = (uae_u8 *)a;
 
     *b = v >> 24;
index d467a128ff084fec2837d52403c87cfebf0c65ee..3b02ca8c86109394fea0f04ffefa892547960231 100755 (executable)
@@ -193,8 +193,8 @@ int init_shm (void)
            natmemsize, natmemsize >> 20);
        if (p96mode)
            write_log ("NATMEM: P96 special area: 0x%p-0x%p (%08x %dM)\n",
-           p96mem_offset, (uae_u8*)p96mem_offset + currprefs.gfxmem_size,
-           currprefs.gfxmem_size, currprefs.gfxmem_size >> 20);
+               p96mem_offset, (uae_u8*)p96mem_offset + currprefs.gfxmem_size,
+               currprefs.gfxmem_size, currprefs.gfxmem_size >> 20);
        canbang = 1;
     }
 
index 8e1ab6cdba929249f569393d9300c80de4117532..47515a517e85f33ca9ee8eb7cbec6b6b257aef2b 100755 (executable)
@@ -46,6 +46,8 @@
 
 #if defined(PICASSO96)
 
+#define USEDX 1
+
 #include "registry.h"
 #include "dxwrap.h"
 #include "rp.h"
@@ -53,7 +55,7 @@
 #include "win32gfx.h"
 
 extern int p96mode;
-#define P96TRACING_ENABLED 1
+//#define P96TRACING_ENABLED 1
 
 int p96hack_vpos, p96hack_vpos2, p96refresh_active;
 int have_done_picasso; /* For the JIT compiler */
@@ -113,6 +115,8 @@ static struct ScreenResolution hicolour = { 640, 480 };
 static struct ScreenResolution truecolour = { 640, 480 };
 static struct ScreenResolution alphacolour = { 640, 480 };
 
+uae_u32 p96_rgbx16[65536];
+
 #include "win32gui.h"
 #include "resource.h"
 #define UAE_RTG_LIBRARY_VERSION 40
@@ -423,7 +427,7 @@ static int CopyBitMapStructureA2U (uaecptr amigamemptr, struct BitMap *bm)
        bm->Depth = 8;
 
     for (i = 0; i < bm->Depth; i++) {
-       uaecptr plane = get_long (amigamemptr + PSSO_BitMap_Planes + i*4);
+       uaecptr plane = get_long (amigamemptr + PSSO_BitMap_Planes + i * 4);
        switch (plane) {
        case 0:
            bm->Planes[i] = &all_zeros_bitmap;
@@ -511,10 +515,12 @@ static void do_fillrect (uae_u8 *src, unsigned int x, unsigned int y,
 
     /* Try OS specific fillrect function here; and return if successful.  Make sure we adjust for
      * the pen values if we're doing 8-bit display-emulation on a 16-bit or higher screen. */
+
 #ifdef PIXEL_LOCK
      flushpixels();
 #endif
 
+#if USEDX
     if(picasso_vidinfo.rgbformat == picasso96_state.RGBFormat) {
        if(DX_Fill(x, y, width, height, pen, rgbtype))
            return;
@@ -522,8 +528,8 @@ static void do_fillrect (uae_u8 *src, unsigned int x, unsigned int y,
        if(DX_Fill(x, y, width, height, picasso_vidinfo.clut[src[0]], rgbtype))
           return;
     }
-
     P96TRACE(("P96_WARNING: do_fillrect() using fall-back routine!\n"));
+#endif
 
     if(y + height > picasso_vidinfo.height)
        height = picasso_vidinfo.height - y;
@@ -599,14 +605,14 @@ out:;
 * must do it by hand using the data in the frame-buffer, calculated using
 * the RenderInfo data and our coordinates.
 */
-static void do_blit(struct RenderInfo *ri, int Bpp,
+static void do_blit (struct RenderInfo *ri, int Bpp,
            unsigned int srcx, unsigned int srcy, unsigned int dstx, unsigned int dsty,
            unsigned int width, unsigned int height, BLIT_OPCODE opcode, int can_do_blit)
 {
     uae_u8 *dstp, *srcp;
     int orig_height = height;
 
-    if(picasso96_state.BigAssBitmap && can_do_blit) {
+    if (picasso96_state.BigAssBitmap && can_do_blit) {
        srcx = dstx;
        srcy = dsty;
        can_do_blit = 0;
@@ -616,11 +622,11 @@ static void do_blit(struct RenderInfo *ri, int Bpp,
 
     dstx=dstx - picasso96_state.XOffset;
     dsty=dsty - picasso96_state.YOffset;
-    if((int)dstx <= 0) {
+    if ((int)dstx <= 0) {
        srcx = srcx - dstx;
        dstx = 0;
     }
-    if((int)dsty <= 0) {
+    if ((int)dsty <= 0) {
        srcy = srcy-dsty;
        dsty = 0;
     }
@@ -648,8 +654,10 @@ static void do_blit(struct RenderInfo *ri, int Bpp,
        // Call OS blitting function that can do it in video memory.
        // Should return if it was successful
        //
+#if USEDX
        if(DX_Blit(srcx, srcy, dstx, dsty, width, height, opcode))
            return;
+#endif
        srcx = dstx;
        srcy = dsty;
     }
@@ -744,81 +752,6 @@ static void do_invertrect( struct RenderInfo *ri, int Bpp, int x, int y, int wid
     do_blit (ri, Bpp, x, y, x, y, width, height, BLIT_SRC, 0);
 }
 
-static uaecptr wgfx_linestart;
-static uaecptr wgfx_lineend;
-static uaecptr wgfx_min, wgfx_max;
-static unsigned long wgfx_y;
-
-static void wgfx_do_flushline (void)
-{
-    uae_u8 *src, *dstp;
-
-    /* Mark these lines as "dirty" */
-    DX_Invalidate (0, wgfx_y, picasso_vidinfo.width, 1);
-
-    if (! picasso_vidinfo.extra_mem) /* The "out" will flush the dirty lines directly */
-       goto out;
-
-#ifdef LOCK_UNLOCK_MADNESS
-    dstp = picasso96_state.HostAddress;
-
-#else
-    dstp = gfx_lock_picasso ();
-#endif
-     if (dstp == 0)
-       goto out;
-#if P96TRACING_LEVEL > 0
-    P96TRACE(("flushing %d\n", wgfx_y));
-#endif
-    src = gfxmemory + wgfx_min;
-
-    if(picasso_vidinfo.rgbformat == picasso96_state.RGBFormat) {
-#if P96TRACING_LEVEL > 0
-       P96TRACE(("flushing type-a\n"));
-#endif
-       dstp += wgfx_y * picasso_vidinfo.rowbytes + wgfx_min - wgfx_linestart;
-               memcpy (dstp, src, wgfx_max - wgfx_min);
-    } else {
-       int width = wgfx_max - wgfx_min;
-       int i;
-       int psiz = GetBytesPerPixel (picasso_vidinfo.rgbformat);
-       P96TRACE(("flushing type-b\n"));
-       if (picasso96_state.RGBFormat != RGBFB_CHUNKY) {
-           write_log ("ERROR - wgfx_do_flushline() failure, %d!\n", picasso96_state.RGBFormat);
-           goto out;
-       }
-
-       dstp += wgfx_y * picasso_vidinfo.rowbytes + (wgfx_min - wgfx_linestart) * psiz;
-       switch (psiz) {
-       case 2:
-           for (i = 0; i < width; i++)
-               *((uae_u16 *)dstp + i) = picasso_vidinfo.clut[src[i]];
-           break;
-       case 4:
-           for (i = 0; i < width; i++)
-               *((uae_u32 *)dstp + i) = picasso_vidinfo.clut[src[i]];
-           break;
-       default:
-           write_log ("ERROR - wgfx_do_flushline() failure2, %d!\n", psiz);
-           goto out;
-       }
-    }
-
-out:
-#ifndef LOCK_UNLOCK_MADNESS
-    gfx_unlock_picasso ();
-#endif
-
-    wgfx_linestart = 0xFFFFFFFF;
-}
-
-STATIC_INLINE void wgfx_flushline (void)
-{
-    if (wgfx_linestart == 0xFFFFFFFF || ! picasso_on)
-       return;
-    wgfx_do_flushline ();
-}
-
 static int renderinfo_is_current_screen (struct RenderInfo *ri)
 {
     if (! picasso_on)
@@ -850,22 +783,23 @@ STATIC_INLINE void do_fillrect_frame_buffer(struct RenderInfo *ri, int X, int Y,
        break;
     case 2:
        for (cols = 0; cols < Width; cols++) {
-           do_put_mem_word ((uae_u16 *)start, (uae_u16)Pen);
-           start += 2;
+           *start++ = Pen >> 8;
+           *start++ = Pen;
        }
        break;
     case 3:
        for (cols = 0; cols < Width; cols++) {
-           do_put_mem_byte (start, (uae_u8)Pen);
-           start++;
-           *(uae_u16 *)(start) = (Pen & 0x00FFFF00) >> 8;
-           start+=2;
+           *start++ = Pen >> 16;
+           *start++ = Pen >> 8;
+           *start++ = Pen;
        }
        break;
     case 4:
        for (cols = 0; cols < Width; cols++) {
-           do_put_mem_long ((uae_u32 *)start, Pen);
-           start += 4;
+           *start++ = Pen >> 24;
+           *start++ = Pen >> 16;
+           *start++ = Pen >> 8;
+           *start++ = Pen;
        }
        break;
     }
@@ -877,18 +811,13 @@ STATIC_INLINE void do_fillrect_frame_buffer(struct RenderInfo *ri, int X, int Y,
            memcpy (dst, src, Width * Bpp);
     } else {
        for (lines = 0; lines < Height - 1; lines++, dst += ri->BytesPerRow)
-           memset(dst, Pen, Width);
+           memset (dst, Pen, Width);
     }
 }
 
 void picasso_handle_vsync (void)
 {
-    DX_Invalidate(-1, -1, -1, -1); //so a flushpixel is done every vsync if pixel are in buffer
     PICASSO96_Unlock();
-    if (palette_changed) {
-       DX_SetPalette (0,256);
-       palette_changed = 0;
-    }
 
     if (vsyncgfxwrite == 1) {
        static long blitcount;
@@ -900,7 +829,7 @@ void picasso_handle_vsync (void)
                    static frame_time_t cycles;
                    blitcount++;
                    cycles = read_processor_time();
-                   picasso_refresh(1);
+                   picasso_refresh();
                    vsyncgfxcount = 0;
                    write_log ("%d Blitnum %.3fms\n", blitcount,
                        (read_processor_time() - cycles) * 1000 / (double)syncbase);
@@ -920,7 +849,7 @@ static int set_panning_called = 0;
 * 3. whenever the graphics code notifies us that the screen contents have been lost.
 */
 extern unsigned int new_beamcon0;
-void picasso_refresh (int call_setpalette)
+void picasso_refresh (void)
 {
     struct RenderInfo ri;
     static int beamcon0_before, p96refresh_was;
@@ -946,6 +875,7 @@ void picasso_refresh (int call_setpalette)
                /* HACK until ntsc timing is fixed.. */
     } //end for higher P96 mousedraw rate
     have_done_picasso = 1;
+    palette_changed = 1;
 
     /* Make sure that the first time we show a Picasso video mode, we don't blit any crap.
     * We can do this by checking if we have an Address yet.  */
@@ -957,29 +887,83 @@ void picasso_refresh (int call_setpalette)
        ri.BytesPerRow = picasso96_state.BytesPerRow;
        ri.RGBFormat = picasso96_state.RGBFormat;
 
-       if(set_panning_called)
-       {
+       if (set_panning_called) {
            width = (picasso96_state.VirtualWidth < picasso96_state.Width) ?
                picasso96_state.VirtualWidth : picasso96_state.Width;
            height = (picasso96_state.VirtualHeight < picasso96_state.Height) ?
                picasso96_state.VirtualHeight : picasso96_state.Height;
            // Let's put a black-border around the case where we've got a sub-screen...
-           if(!picasso96_state.BigAssBitmap)
-           {
+           if (!picasso96_state.BigAssBitmap) {
                if (picasso96_state.XOffset || picasso96_state.YOffset)
-                   DX_Fill(0, 0, picasso96_state.Width, picasso96_state.Height, 0,
+                   DX_Fill (0, 0, picasso96_state.Width, picasso96_state.Height, 0,
                        picasso96_state.RGBFormat);
            }
        } else {
            width = picasso96_state.Width;
            height = picasso96_state.Height;
        }
-       do_blit(&ri, picasso96_state.BytesPerPixel, 0, 0, 0, 0, width, height, BLIT_SRC, 0);
+       flushpixels ();
+       if (!p96mode)
+           do_blit (&ri, picasso96_state.BytesPerPixel, 0, 0, 0, 0, width, height, BLIT_SRC, 0);
     } else {
        write_log ("ERROR - picasso_refresh() can't refresh!\n");
     }
 }
 
+#if 0
+#define BLT_NAME BLIT_32
+#define BLT_FUNC(s,d)
+#include "p96_blit.c"
+#endif
+
+#define BLT_SIZE 32
+#define BLT_NAME BLIT_FALSE_32
+#define BLT_FUNC(s,d) *d = 0
+#include "p96_blit.c"
+#define BLT_NAME BLIT_NOR_32
+#define BLT_FUNC(s,d) *d = ~(*s | * d)
+#include "p96_blit.c"
+#define BLT_NAME BLIT_ONLYDST_32
+#define BLT_FUNC(s,d) *d = (*d) & ~(*s)
+#include "p96_blit.c"
+#define BLT_NAME BLIT_NOTSRC_32
+#define BLT_FUNC(s,d) *d = ~(*s)
+#include "p96_blit.c" 
+#define BLT_NAME BLIT_ONLYSRC_32
+#define BLT_FUNC(s,d) *d = (*s) & ~(*d)
+#include "p96_blit.c"
+#define BLT_NAME BLIT_NOTDST_32
+#define BLT_FUNC(s,d) *d = ~(*d)
+#include "p96_blit.c"
+#define BLT_NAME BLIT_EOR_32
+#define BLT_FUNC(s,d) *d = (*s) ^ (*d)
+#include "p96_blit.c"
+#define BLT_NAME BLIT_NAND_32
+#define BLT_FUNC(s,d) *d = ~((*s) & (*d))
+#include "p96_blit.c"
+#define BLT_NAME BLIT_AND_32
+#define BLT_FUNC(s,d) *d = (*s) & (*d)
+#include "p96_blit.c"
+#define BLT_NAME BLIT_NEOR_32
+#define BLT_FUNC(s,d) *d = ~((*s) ^ (*d))
+#include "p96_blit.c"
+#define BLT_NAME BLIT_NOTONLYSRC_32
+#define BLT_FUNC(s,d) *d = ~(*s) | (*d)
+#include "p96_blit.c"
+#define BLT_NAME BLIT_NOTONLYDST_32
+#define BLT_FUNC(s,d) *d = ~(*d) | (*s)
+#include "p96_blit.c"
+#define BLT_NAME BLIT_OR_32
+#define BLT_FUNC(s,d) *d = (*s) | (*d)
+#include "p96_blit.c"
+#define BLT_NAME BLIT_TRUE_32
+#define BLT_FUNC(s,d) *d = 0xffffffff
+#include "p96_blit.c"
+#define BLT_NAME BLIT_30_32
+#define BLT_FUNC(s,d) tmp = *d ; *d = *s; *s = tmp;
+#include "p96_blit.c"
+
+#define PARMS width, height, src, dst, ri->BytesPerRow, dstri->BytesPerRow
 
 /*
 * Functions to perform an action on the frame-buffer
@@ -1023,6 +1007,27 @@ long height, uae_u8 mask, BLIT_OPCODE opcode)
            }
            return;
 
+       } else if (Bpp == 32) {
+           /* 32-bit optimized */
+           switch (opcode)
+           {
+               case BLIT_FALSE: BLIT_FALSE_32 (PARMS); break;
+               case BLIT_NOR: BLIT_NOR_32 (PARMS); break;
+               case BLIT_ONLYDST: BLIT_ONLYDST_32 (PARMS); break;
+               case BLIT_NOTSRC: BLIT_NOTSRC_32 (PARMS); break;
+               case BLIT_ONLYSRC: BLIT_ONLYSRC_32 (PARMS); break;
+               case BLIT_NOTDST: BLIT_NOTDST_32 (PARMS); break;
+               case BLIT_EOR: BLIT_EOR_32 (PARMS); break;
+               case BLIT_NAND: BLIT_NAND_32 (PARMS); break;
+               case BLIT_AND: BLIT_AND_32 (PARMS); break;
+               case BLIT_NEOR: BLIT_NEOR_32 (PARMS); break;
+               case BLIT_NOTONLYSRC: BLIT_NOTONLYSRC_32 (PARMS); break;
+               case BLIT_NOTONLYDST: BLIT_NOTONLYDST_32 (PARMS); break;
+               case BLIT_OR: BLIT_OR_32 (PARMS); break;
+               case BLIT_TRUE: BLIT_TRUE_32 (PARMS); break;
+               case 30: BLIT_30_32 (PARMS); break;
+           }
+       
        } else {
 
            uae_u8 *src2 = src;
@@ -1192,152 +1197,6 @@ long height, uae_u8 mask, BLIT_OPCODE opcode)
     free (tmp3);
 }
 
-#if 0
-/*
-* Functions to perform an action on the frame-buffer
-*/
-STATIC_INLINE void do_blitrect_frame_buffer( struct RenderInfo *ri, struct RenderInfo *dstri, unsigned long srcx, unsigned long srcy,
-    unsigned long dstx, unsigned long dsty, unsigned long width, unsigned long height, uae_u8 mask, BLIT_OPCODE opcode )
-{
-
-    uae_u8 *src, *dst, *tmp, *tmp2, *tmp3;
-    uae_u8 Bpp = GetBytesPerPixel(ri->RGBFormat);
-    unsigned long total_width = width * Bpp;
-    unsigned long linewidth = (total_width + 15) & ~15;
-    unsigned long lines;
-    int can_do_visible_blit = 0;
-
-    src = ri->Memory + srcx*Bpp + srcy*ri->BytesPerRow;
-    dst = dstri->Memory + dstx*Bpp + dsty*dstri->BytesPerRow;
-    if (mask != 0xFF && Bpp > 1)
-    {
-       write_log ("WARNING - BlitRect() has mask 0x%x with Bpp %d.\n", mask, Bpp);
-    }
-
-    if (mask == 0xFF || Bpp > 1)
-    {
-       if( opcode == BLIT_SRC )
-       {
-           /* handle normal case efficiently */
-           if (ri->Memory == dstri->Memory && dsty == srcy)
-           {
-               unsigned long i;
-               for (i = 0; i < height; i++, src += ri->BytesPerRow, dst += dstri->BytesPerRow)
-                   memmove (dst, src, total_width);
-           }
-           else if (dsty < srcy)
-           {
-               unsigned long i;
-               for (i = 0; i < height; i++, src += ri->BytesPerRow, dst += dstri->BytesPerRow)
-                   memcpy (dst, src, total_width);
-           }
-           else
-           {
-               unsigned long i;
-               src += (height-1) * ri->BytesPerRow;
-               dst += (height-1) * dstri->BytesPerRow;
-               for (i = 0; i < height; i++, src -= ri->BytesPerRow, dst -= dstri->BytesPerRow)
-                   memcpy (dst, src, total_width);
-           }
-           return;
-       }
-       else
-       {
-           uae_u8 *src2 = src;
-           uae_u8 *dst2 = dst;
-           unsigned int y;
-
-           for( y = 0; y < height; y++ ) /* Vertical lines */
-           {
-               for( src2 = src, dst2 = dst; src2 < src + total_width; src2++, dst2++ ) /* Horizontal bytes */
-               {
-                   switch( opcode )
-                   {
-                   case BLIT_FALSE:
-                       *dst2 = 0;
-                       break;
-                   case BLIT_NOR:
-                       *dst2 = ~(*src2 | *dst2);
-                       break;
-                   case BLIT_ONLYDST:
-                       *dst2 = *dst2 & ~(*src2);
-                       break;
-                   case BLIT_NOTSRC:
-                       *dst2 = ~(*src2);
-                       break;
-                   case BLIT_ONLYSRC:
-                       *dst2 = *src2 & ~(*dst2);
-                       break;
-                   case BLIT_NOTDST:
-                       *dst2 = ~(*dst2);
-                       break;
-                   case BLIT_EOR:
-                       *dst2 = *src2 ^ *dst2;
-                       break;
-                   case BLIT_NAND:
-                       *dst2 = ~(*src2 & *dst2);
-                       break;
-                   case BLIT_AND:
-                       *dst2 = *src2 & *dst2;
-                       break;
-                   case BLIT_NEOR:
-                       *dst2 = ~(*src2 ^ *dst2);
-                       break;
-                   case BLIT_DST:
-                       write_log ( "do_blitrect_frame_buffer shouldn't get BLIT_DST!\n" );
-                       break;
-                   case BLIT_NOTONLYSRC:
-                       *dst2 = ~(*src2) | *dst2;
-                       break;
-                   case BLIT_SRC:
-                       write_log ( "do_blitrect_frame_buffer shouldn't get BLIT_SRC!\n" );
-                       break;
-                   case BLIT_NOTONLYDST:
-                       *dst2 = ~(*dst2) | *src2;
-                       break;
-                   case BLIT_OR:
-                       *dst2 = *src2 | *dst2;
-                       break;
-                   case BLIT_TRUE:
-                       *dst2 = 0xFF;
-                       break;
-                   case BLIT_LAST:
-                       write_log ( "do_blitrect_frame_buffer shouldn't get BLIT_LAST!\n" );
-                       break;
-                   } /* switch opcode */
-               } /* for width */
-               src += ri->BytesPerRow;
-               dst += dstri->BytesPerRow;
-           } /* for height */
-       }
-       return;
-       }
-
-    tmp3 = tmp2 = tmp = xmalloc (linewidth * height); /* allocate enough memory for the src-rect */
-    if (!tmp)
-       return;
-
-    /* copy the src-rect into our temporary buffer space */
-    for (lines = 0; lines < height; lines++, src += ri->BytesPerRow, tmp2 += linewidth)
-    {
-       memcpy (tmp2, src, total_width);
-    }
-
-    /* copy the temporary buffer to the destination */
-    for (lines = 0; lines < height; lines++, dst += dstri->BytesPerRow, tmp += linewidth)
-    {
-       unsigned long cols;
-       for (cols = 0; cols < width; cols++)
-       {
-           dst[cols] &= ~mask;
-           dst[cols] |= tmp[cols] & mask;
-       }
-    }
-    /* free the temp-buf */
-    free (tmp3);
-}
-#endif
-
 /*
 DrawLine:
 Synopsis: DrawLine(bi, ri, line, Mask, RGBFormat);
@@ -1661,10 +1520,15 @@ static void CopyLibResolutionStructureU2A (struct LibResolution *libres, uaecptr
 
 static int missmodes[] = { 320, 200, 320, 240, 640, 400, 640, 480, -1 };
 
+static void **gwwbuf;
+static int gwwbufsize, gwwpagesize, gwwpagemask;
+extern uae_u8 *natmem_offset;
+
 void picasso96_alloc (TrapContext *ctx)
 {
     int i, j, size, cnt;
     int misscnt;
+    SYSTEM_INFO si;
 
     xfree (newmodes);
     newmodes = NULL;
@@ -1761,6 +1625,19 @@ void picasso96_alloc (TrapContext *ctx)
     picasso96_amem = CallLib (ctx, get_long (4), -0xC6); /* AllocMem */
     picasso96_amemend = picasso96_amem + size;
     write_log("P96 RESINFO: %08X-%08X (%d,%d)\n", picasso96_amem, picasso96_amemend, cnt, size);
+
+    if (p96mode) {
+       xfree (gwwbuf);
+       GetSystemInfo (&si);
+       gwwpagesize = si.dwPageSize;
+       gwwbufsize = allocated_gfxmem / gwwpagesize + 1;
+       gwwpagemask = gwwpagesize - 1;
+       gwwbuf = xmalloc (gwwbufsize * sizeof (void*));
+       vsyncgfxwrite = -1;
+    } else {
+       vsyncgfxwrite = 0;
+    }
+    write_log ("P96 VRAM MODE: %s\n", p96mode ? "Direct" : "Indirect");
 }
 
 /****************************************
@@ -1890,8 +1767,8 @@ void picasso_enablescreen (int on)
 {
     if (!init_picasso_screen_called)
        init_picasso_screen();
-    wgfx_linestart = 0xFFFFFFFF;
-    picasso_refresh (1);
+
+    picasso_refresh ();
     write_log ("SetSwitch() from threadid %d - showing %s screen\n", GetCurrentThreadId(), on ? "picasso96": "amiga");
     checkrtglibrary();
 }
@@ -1968,8 +1845,7 @@ static void init_picasso_screen(void)
        (picasso_vidinfo.depth == (picasso96_state.GC_Depth >> 3)) &&
        (picasso_vidinfo.selected_rgbformat == picasso96_state.RGBFormat))
     {
-       DX_SetPalette (0, 256);
-       picasso_refresh (1);
+       picasso_refresh ();
     }
     init_picasso_screen_called = 1;
 }
@@ -2080,33 +1956,24 @@ uae_u32 REGPARAM2 picasso_SetPanning (struct regstruct *regs)
     return 1;
 }
 
-static void do_xor8 (uae_u8 *ptr, long len, uae_u32 val)
+static void do_xor8 (uae_u8 *p, int w, uae_u32 v)
 {
-    int i;
-#if 0 && defined ALIGN_POINTER_TO32
-    int align_adjust = ALIGN_POINTER_TO32(ptr);
-    int len2;
-
-    len -= align_adjust;
-    while (align_adjust) {
-       *ptr ^= val;
-       ptr++;
-       align_adjust--;
-    }
-    len2 = len >> 2;
-    len -= len2 << 2;
-    for (i = 0; i < len2; i++, ptr += 4) {
-       *(uae_u32 *)ptr ^= val;
-    }
-    while (len) {
-       *ptr ^= val;
-       ptr++;
-       len--;
+    while (ALIGN_POINTER_TO32 (p) != 3 && w) {
+       *p ^= v;
+       p++;
+       w--;
     }
-    return;
-#endif
-    for (i = 0; i < len; i++, ptr++) {
-       do_put_mem_byte (ptr, (uae_u8)(do_get_mem_byte (ptr) ^ val));
+    while (w >= 2 * 4) {
+       *((uae_u32*)p) ^= v;
+       p += 4;
+       *((uae_u32*)p) ^= v;
+       p += 4;
+       w -= 2 * 4;
+    }
+    while (w) {
+       *p ^= v;
+       p++;
+       w--;
     }
 }
 
@@ -2156,8 +2023,9 @@ uae_u32 REGPARAM2 picasso_InvertRect (struct regstruct *regs)
        width_in_bytes = Bpp * Width;
        rectstart = uae_mem = ri.Memory + Y*ri.BytesPerRow + X*Bpp;
 
-       for (lines = 0; lines < Height; lines++, uae_mem += ri.BytesPerRow)
+       for (lines = 0; lines < Height; lines++, uae_mem += ri.BytesPerRow) {
            do_xor8 (uae_mem, width_in_bytes, xorval);
+       }
 
        if (vsyncgfxwrite == 0) {
            if (renderinfo_is_current_screen (&ri)) {
@@ -2202,8 +2070,6 @@ uae_u32 REGPARAM2 picasso_FillRect (struct regstruct *regs)
     struct RenderInfo ri;
     uae_u32 result = 0;
 
-    if (Width * Height <= 2500)
-       return 0;
     P96_SM_RW;
 
 #ifndef LOCK_UNLOCK_MADNESS
@@ -2223,57 +2089,12 @@ uae_u32 REGPARAM2 picasso_FillRect (struct regstruct *regs)
            Mask = 0xFF;
 
        if (Mask == 0xFF) {
-           if(Width == 1 || Height == 1) {
-               int i;
-               uaecptr addr;
-               if(renderinfo_is_current_screen(&ri)) {
-                   uae_u32 diff = gfxmem_start - (uae_u32)gfxmemory;
-                   addr = ri.Memory + X * Bpp + Y * ri.BytesPerRow + diff;
-                   if(Width == 1) {
-                       for(i = 0; i < Height; i++) {
-                           if (p96mode) {
-                               if(Bpp == 4)
-                                   gfxmem_lputx(addr + (i * picasso96_state.BytesPerRow), Pen);
-                               else if(Bpp == 2)
-                                   gfxmem_wputx(addr + (i * picasso96_state.BytesPerRow), Pen);
-                               else
-                                   gfxmem_bputx(addr + (i * picasso96_state.BytesPerRow), Pen);
-                           } else {
-                               if(Bpp == 4)
-                                   gfxmem_lput(addr + (i * picasso96_state.BytesPerRow), Pen);
-                               else if(Bpp == 2)
-                                   gfxmem_wput(addr + (i * picasso96_state.BytesPerRow), Pen);
-                               else
-                                   gfxmem_bput(addr + (i * picasso96_state.BytesPerRow), Pen);
-                           }
-                       }
-                   } else if(Height == 1) {
-                       for(i = 0; i < Width; i++) {
-                           if (p96mode) {
-                               if(Bpp == 4)
-                                   gfxmem_lputx(addr + (i * Bpp), Pen);
-                               else if(Bpp == 2)
-                                   gfxmem_wputx(addr + (i * Bpp), Pen);
-                               else
-                                   gfxmem_bputx(addr + (i * Bpp), Pen);
-                           } else {
-                               if(Bpp == 4)
-                                   gfxmem_lput(addr + (i * Bpp), Pen);
-                               else if(Bpp == 2)
-                                   gfxmem_wput(addr + (i * Bpp), Pen);
-                               else
-                                   gfxmem_bput(addr + (i * Bpp), Pen);
-                           }
-                       }
-                   }
-                   return 1;
-               }
-           }
 
            /* Do the fill-rect in the frame-buffer */
            do_fillrect_frame_buffer (&ri, X, Y, Width, Height, Pen, Bpp, RGBFormat);
+
            /* Now we do the on-screen display, if renderinfo points to it */
-           if (renderinfo_is_current_screen (&ri)) {
+           if (vsyncgfxwrite == 0 && renderinfo_is_current_screen (&ri)) {
                src = ri.Memory + X * Bpp + Y * ri.BytesPerRow;
                X = X - picasso96_state.XOffset;
                Y = Y - picasso96_state.YOffset;
@@ -2287,11 +2108,11 @@ uae_u32 REGPARAM2 picasso_FillRect (struct regstruct *regs)
                        Width = picasso96_state.Width - X;
                    if(Y + Height > picasso96_state.Height)
                        Height = picasso96_state.Height - Y;
-                   if (vsyncgfxwrite == 0)
-                       do_fillrect(src, X, Y, Width, Height, Pen, Bpp, RGBFormat);
+                   do_fillrect(src, X, Y, Width, Height, Pen, Bpp, RGBFormat);
                }
            }
            result = 1;
+
        } else {
            /* We get here only if Mask != 0xFF */
            if (Bpp != 1) {
@@ -2312,15 +2133,12 @@ uae_u32 REGPARAM2 picasso_FillRect (struct regstruct *regs)
                        }
                    }
                }
-               if (vsyncgfxwrite == 0) {
-                   if (renderinfo_is_current_screen (&ri))
-                       do_blit(&ri, Bpp, X, Y, X, Y, Width, Height, BLIT_SRC, 0);
-               }
+               if (vsyncgfxwrite == 0 && renderinfo_is_current_screen (&ri))
+                   do_blit(&ri, Bpp, X, Y, X, Y, Width, Height, BLIT_SRC, 0);
                result = 1;
            }
        }
     }
-    flushpixels();
     return result;
 }
 
@@ -2546,8 +2364,8 @@ STATIC_INLINE void PixelWrite2(uae_u8 *mem, int bits, uae_u32 fgpen)
 
 STATIC_INLINE void PixelWrite3(uae_u8 *mem, int bits, uae_u32 fgpen)
 {
-    do_put_mem_byte (mem + bits*3, fgpen & 0x000000FF);
-    *(uae_u16 *)(mem + bits*3+1) = (fgpen & 0x00FFFF00) >> 8;
+    do_put_mem_byte (mem + bits * 3, fgpen & 0x000000FF);
+    *(uae_u16 *)(mem + bits * 3 + 1) = (fgpen & 0x00FFFF00) >> 8;
 }
 
 STATIC_INLINE void PixelWrite4(uae_u8 *mem, int bits, uae_u32 fgpen)
@@ -2557,22 +2375,23 @@ STATIC_INLINE void PixelWrite4(uae_u8 *mem, int bits, uae_u32 fgpen)
 
 STATIC_INLINE void PixelWrite(uae_u8 *mem, int bits, uae_u32 fgpen, uae_u8 Bpp, uae_u32 mask)
 {
-    switch (Bpp) {
-    case 1:
-       if (mask != 0xFF)
-           fgpen = (fgpen & mask) | (do_get_mem_byte (mem + bits) & ~mask);
-       do_put_mem_byte (mem + bits, (uae_u8)fgpen);
-       break;
-    case 2:
-       do_put_mem_word (((uae_u16 *)mem) + bits, (uae_u16)fgpen);
-       break;
-    case 3:
-       do_put_mem_byte (mem + bits*3, (uae_u8)fgpen);
-       *(uae_u16 *)(mem + bits*3+1) = (fgpen & 0x00FFFF00) >> 8;
-       break;
-    case 4:
-       do_put_mem_long (((uae_u32 *)mem) + bits, fgpen);
-       break;
+    switch (Bpp)
+    {
+       case 1:
+           if (mask != 0xFF)
+               fgpen = (fgpen & mask) | (do_get_mem_byte (mem + bits) & ~mask);
+           do_put_mem_byte (mem + bits, (uae_u8)fgpen);
+           break;
+       case 2:
+           do_put_mem_word (((uae_u16 *)mem) + bits, (uae_u16)fgpen);
+           break;
+       case 3:
+           do_put_mem_byte (mem + bits * 3, (uae_u8)fgpen);
+           *(uae_u16 *)(mem + bits * 3 + 1) = (fgpen & 0x00FFFF00) >> 8;
+           break;
+       case 4:
+           do_put_mem_long (((uae_u32 *)mem) + bits, fgpen);
+           break;
     }
 }
 
@@ -2625,8 +2444,7 @@ uae_u32 REGPARAM2 picasso_BlitPattern (struct regstruct *regs)
     wgfx_flushline ();
 #endif
 
-    if(CopyRenderInfoStructureA2U (rinf, &ri) && CopyPatternStructureA2U (pinf, &pattern))
-    {
+    if(CopyRenderInfoStructureA2U (rinf, &ri) && CopyPatternStructureA2U (pinf, &pattern)) {
        Bpp = GetBytesPerPixel(ri.RGBFormat);
        uae_mem = ri.Memory + Y * ri.BytesPerRow + X * Bpp; /* offset with address */
 
@@ -2634,29 +2452,21 @@ uae_u32 REGPARAM2 picasso_BlitPattern (struct regstruct *regs)
            inversion = 1;
 
        pattern.DrawMode &= 0x03;
-       if (Mask != 0xFF)
-       {
+       if (Mask != 0xFF) {
            if(Bpp > 1)
                Mask = 0xFF;
-
-           if(pattern.DrawMode == COMP)
-           {
+           if(pattern.DrawMode == COMP) {
                write_log ("WARNING - BlitPattern() has unhandled mask 0x%x with COMP DrawMode. Using fall-back routine.\n", Mask);
-           }
-           else
-           {
+           } else {
                result = 1;
            }
-       }
-       else
-       {
+       } else {
            result = 1;
        }
 
-       if(result)
-       {
-           /* write_log ("BlitPattern() xy(%d,%d), wh(%d,%d) draw 0x%x, off(%d,%d), ph %d\n",
-           X, Y, W, H, pattern.DrawMode, pattern.XOffset, pattern.YOffset, 1 << pattern.Size); */
+       if(result) {
+           P96TRACE(("BlitPattern() xy(%d,%d), wh(%d,%d) draw 0x%x, off(%d,%d), ph %d\n",
+           X, Y, W, H, pattern.DrawMode, pattern.XOffset, pattern.YOffset, 1 << pattern.Size));
     #ifdef P96TRACING_ENABLED
            DumpPattern(&pattern);
     #endif
@@ -2672,8 +2482,7 @@ uae_u32 REGPARAM2 picasso_BlitPattern (struct regstruct *regs)
                if (xshift != 0)
                    d = (d << xshift) | (d >> (16 - xshift));
 
-               for (cols = 0; cols < W; cols += 16, uae_mem2 += Bpp << 4)
-               {
+               for (cols = 0; cols < W; cols += 16, uae_mem2 += Bpp << 4) {
                    long bits;
                    long max = W - cols;
                    unsigned int data = d;
@@ -2681,8 +2490,7 @@ uae_u32 REGPARAM2 picasso_BlitPattern (struct regstruct *regs)
                    if (max > 16)
                        max = 16;
 
-                   for (bits = 0; bits < max; bits++)
-                   {
+                   for (bits = 0; bits < max; bits++) {
                        int bit_set = data & 0x8000;
                        data <<= 1;
                        switch (pattern.DrawMode) {
@@ -2738,10 +2546,8 @@ uae_u32 REGPARAM2 picasso_BlitPattern (struct regstruct *regs)
            }
 
            /* If we need to update a second-buffer (extra_mem is set), then do it only if visible! */
-           if (picasso_vidinfo.extra_mem && renderinfo_is_current_screen (&ri)) {
-               if (vsyncgfxwrite == 0)
-                   do_blit(&ri, Bpp, X, Y, X, Y, W, H, BLIT_SRC, 0);
-           }
+           if (vsyncgfxwrite == 0 && picasso_vidinfo.extra_mem && renderinfo_is_current_screen (&ri))
+               do_blit(&ri, Bpp, X, Y, X, Y, W, H, BLIT_SRC, 0);
 
            result = 1;
        }
@@ -2788,16 +2594,13 @@ uae_u32 REGPARAM2 picasso_BlitTemplate (struct regstruct *regs)
     uae_u8 *tmpl_base;
     uae_u32 result = 0;
 
-//  if (W * H <= 2500)
-//     return 0;
     P96_SM_RW;
 
 #ifndef LOCK_UNLOCK_MADNESS
     wgfx_flushline ();
 #endif
 
-    if (CopyRenderInfoStructureA2U (rinf, &ri) && CopyTemplateStructureA2U (tmpl, &tmp))
-    {
+    if (CopyRenderInfoStructureA2U (rinf, &ri) && CopyTemplateStructureA2U (tmpl, &tmp)) {
        Bpp = GetBytesPerPixel(ri.RGBFormat);
        uae_mem = ri.Memory + Y*ri.BytesPerRow + X*Bpp; /* offset into address */
 
@@ -2806,35 +2609,27 @@ uae_u32 REGPARAM2 picasso_BlitTemplate (struct regstruct *regs)
 
        tmp.DrawMode &= 0x03;
 
-       if (Mask != 0xFF)
-       {
+       if (Mask != 0xFF) {
            if(Bpp > 1)
                Mask = 0xFF;
 
-           if(tmp.DrawMode == COMP)
-           {
+           if(tmp.DrawMode == COMP) {
                write_log ("WARNING - BlitTemplate() has unhandled mask 0x%x with COMP DrawMode. Using fall-back routine.\n", Mask);
                flushpixels();  //only need in the windows Version
                return 0;
-           }
-           else
-           {
+           } else {
                result = 1;
            }
-       }
-       else
-       {
+       } else {
            result = 1;
        }
 #if 1
        if (tmp.DrawMode == COMP) {
            /* workaround, let native blitter handle COMP mode */
-           flushpixels();
            return 0;
        }
 #endif
-       if(result)
-       {
+       if(result) {
            P96TRACE(("BlitTemplate() xy(%d,%d), wh(%d,%d) draw 0x%x fg 0x%x bg 0x%x \n",
                X, Y, W, H, tmp.DrawMode, tmp.FgPen, tmp.BgPen));
 
@@ -2924,10 +2719,8 @@ uae_u32 REGPARAM2 picasso_BlitTemplate (struct regstruct *regs)
            }
 
            /* If we need to update a second-buffer (extra_mem is set), then do it only if visible! */
-           if(picasso_vidinfo.extra_mem && renderinfo_is_current_screen(&ri)) {
-               if (vsyncgfxwrite == 0)
-                   do_blit(&ri, Bpp, X, Y, X, Y, W, H, BLIT_SRC, 0);
-           }
+           if(vsyncgfxwrite == 0 && picasso_vidinfo.extra_mem && renderinfo_is_current_screen(&ri))
+               do_blit(&ri, Bpp, X, Y, X, Y, W, H, BLIT_SRC, 0);
 
            result = 1;
        }
@@ -2948,10 +2741,7 @@ uae_u32 REGPARAM2 picasso_CalculateBytesPerRow (struct regstruct *regs)
 {
     uae_u16 width = m68k_dreg (regs, 0);
     uae_u32 type = m68k_dreg (regs, 7);
-
     width = GetBytesPerPixel(type) * width;
-    P96TRACE(("CalculateBytesPerRow() = %d\n",width));
-
     return width;
 }
 
@@ -3123,10 +2913,8 @@ uae_u32 REGPARAM2 picasso_BlitPlanar2Chunky (struct regstruct *regs)
            srcx, srcy, dstx, dsty, width, height, minterm, mask, local_bm.Depth));
        P96TRACE(("P2C - BitMap has %d BPR, %d rows\n", local_bm.BytesPerRow, local_bm.Rows));
        PlanarToChunky (&local_ri, &local_bm, srcx, srcy, dstx, dsty, width, height, mask);
-       if (renderinfo_is_current_screen (&local_ri)) {
-           if (vsyncgfxwrite == 0)
-               do_blit(&local_ri, GetBytesPerPixel(local_ri.RGBFormat), dstx, dsty, dstx, dsty, width, height, BLIT_SRC, 0);
-       }
+       if (vsyncgfxwrite == 0 && renderinfo_is_current_screen (&local_ri))
+           do_blit(&local_ri, GetBytesPerPixel(local_ri.RGBFormat), dstx, dsty, dstx, dsty, width, height, BLIT_SRC, 0);
        result = 1;
     }
 
@@ -3276,9 +3064,8 @@ uae_u32 REGPARAM2 picasso_BlitPlanar2Direct (struct regstruct *regs)
        P96TRACE(("BlitPlanar2Direct(%d, %d, %d, %d, %d, %d) Minterm 0x%x, Mask 0x%x, Depth %d\n",
            srcx, srcy, dstx, dsty, width, height, minterm, Mask, local_bm.Depth));
        PlanarToDirect (&local_ri, &local_bm, srcx, srcy, dstx, dsty, width, height, Mask, &local_cim);
-       if (renderinfo_is_current_screen (&local_ri))
-           if (vsyncgfxwrite == 0)
-               do_blit(&local_ri, GetBytesPerPixel(local_ri.RGBFormat), dstx, dsty, dstx, dsty, width, height, BLIT_SRC, 0);
+       if (vsyncgfxwrite == 0 && renderinfo_is_current_screen (&local_ri))
+           do_blit(&local_ri, GetBytesPerPixel(local_ri.RGBFormat), dstx, dsty, dstx, dsty, width, height, BLIT_SRC, 0);
        result = 1;
     }
     return result;
@@ -3391,86 +3178,176 @@ static void flushpixels_paletted(uae_u8 *dst)
     }
 }
 
-static void **gwwbuf;
-static int gwwbufsize;
-extern uae_u8 *natmem_offset;
-
-static void flushpixels_rgbx (uae_u8 *dst)
+static void flushpixels_x (void)
 {
-    int i, j;
-    int rowwidth_src = picasso_vidinfo.width * picasso_vidinfo.pixbytes;
-    int rowwidth_dst = picasso96_state.Width * picasso96_state.BytesPerPixel;
-    ULONG ps;
+    int i;
+    int rowwidth_dst = picasso_vidinfo.width * picasso_vidinfo.pixbytes;
+    int rowwidth_src = picasso96_state.Width * picasso96_state.BytesPerPixel;
     ULONG_PTR gwwcnt;
     uae_u8 *src = p96ram_start + natmem_offset;
     int off = picasso96_state.XYOffset - gfxmem_start;
-    uae_u8 *src_start = src + off - (4096 - 1);
-    uae_u8 *src_end = src + off + rowwidth_dst * picasso96_state.Height + (4096 - 1);
+    uae_u8 *src_start = src + (off & ~gwwpagemask);
+    uae_u8 *src_end = src + ((off + rowwidth_src * picasso96_state.Height + gwwpagesize - 1) & ~gwwpagemask);
+    int maxy = -1;
+    int miny = picasso96_state.Height - 1;
+    int lock = 0;
 
-    if (!picasso_vidinfo.extra_mem)
+    if (!picasso_vidinfo.extra_mem || !gwwbuf)
        return;
-    if (!gwwbuf) {
-       gwwbufsize = allocated_gfxmem / 4096 + 1;
-       gwwbuf = xmalloc (gwwbufsize * sizeof (void*));
-    }
+
     for (;;) {
-       gwwcnt = gwwbufsize;
-       if (GetWriteWatch(WRITE_WATCH_FLAG_RESET, src, allocated_gfxmem, gwwbuf, &gwwcnt, &ps))
-           return;
+       uae_u8 *dst;
+
+       if (palette_changed) {
+           picasso_palette ();
+           gwwcnt = allocated_gfxmem / gwwpagesize;
+           for (i = 0; i < gwwcnt; i++)
+               gwwbuf[i] = src + i * gwwpagesize;
+           palette_changed = 0;
+       } else {
+           ULONG ps;
+           gwwcnt = gwwbufsize;
+           if (GetWriteWatch(WRITE_WATCH_FLAG_RESET, src, allocated_gfxmem, gwwbuf, &gwwcnt, &ps))
+               break;;
+       }
+
        if (gwwcnt == 0)
-           return;
+           break;
+
+        if(DirectDraw_IsLocked() == FALSE) {
+           if (!lock)
+               dst = gfx_lock_picasso ();
+           lock = 1;
+       } else {
+           dst = picasso96_state.HostAddress;
+       }
+       if (!dst)
+           break;
+
        for (i = 0; i < gwwcnt; i++) {
-           int pscnt = ps;
+           int pscnt = gwwpagesize;
            uae_u8 *p = gwwbuf[i];
 
            if (p >= src_start && p < src_end) {
-               uaecptr addr = (p - src) - off;
-               int y = addr / picasso96_state.BytesPerRow;
-               uae_u8 *src2 = src + y * picasso96_state.BytesPerRow + off;
-               uae_u8 *dst2 = dst + y * picasso_vidinfo.rowbytes;
-               int yend;
+               int y, yend, realoffset;
+               uae_u8 *src2, *dst2;
+
+               if (p >= src + off) {
+                   realoffset = p - (src + off);
+               } else {
+                   realoffset = 0;
+               }
+
+               y = realoffset / picasso96_state.BytesPerRow;
+               src2 = src + y * picasso96_state.BytesPerRow + off;
+               dst2 = dst + y * picasso_vidinfo.rowbytes;
 
                /* merge nearby pieces */
-               while (i + 1 < gwwcnt && (uae_u8*)gwwbuf[i + 1] <= p + 2 * ps) {
-                   pscnt += ps;
-                   p += ps;
+               while (i + 1 < gwwcnt && (uae_u8*)gwwbuf[i + 1] <= p + 2 * gwwpagesize) {
+                   pscnt += gwwpagesize;
+                   p += gwwpagesize;
                    i++;
                }
 
-               yend = (addr + pscnt + picasso96_state.BytesPerRow - 1) / picasso96_state.BytesPerRow;
-               while (y <= yend && y < picasso96_state.Height) {
-    #if 0
-                   for (j = 0; j < rowwidth_dst; j+=4) {
-                       dst2[j] = src2[j];
-                       dst2[j + 1] = src2[j + 1];
-                       dst2[j + 2] = src2[j + 2] ^ 0xff;
-                       dst2[j + 3] = src2[j + 3];
+               yend = (realoffset + pscnt + picasso96_state.BytesPerRow - 1) / picasso96_state.BytesPerRow;
+               if (yend >= picasso96_state.Height)
+                  yend = picasso96_state.Height - 1;
+
+               if (yend > maxy)
+                   maxy = yend;
+               if (y < miny)
+                   miny = y;
+
+               if (picasso_vidinfo.pixbytes == picasso96_state.BytesPerPixel) {
+                   while (y <= yend) {
+                       memcpy (dst2, src2, rowwidth_dst);
+                       src2 += picasso96_state.BytesPerRow;
+                       dst2 += picasso_vidinfo.rowbytes;
+                       y++;
+                   }
+               } else if (picasso_vidinfo.pixbytes == 4 && picasso96_state.BytesPerPixel == 2) { /* 16->32 */
+                   int x;
+                   while (y <= yend) {
+                       for (x = 0; x < picasso96_state.Width;) {
+                           ((uae_u32*)dst2)[x] = p96_rgbx16[((uae_u16*)src2)[x]];
+                           x++;
+                           ((uae_u32*)dst2)[x] = p96_rgbx16[((uae_u16*)src2)[x]];
+                           x++;
+                           ((uae_u32*)dst2)[x] = p96_rgbx16[((uae_u16*)src2)[x]];
+                           x++;
+                           ((uae_u32*)dst2)[x] = p96_rgbx16[((uae_u16*)src2)[x]];
+                           x++;
+                       }
+                       src2 += picasso96_state.BytesPerRow;
+                       dst2 += picasso_vidinfo.rowbytes;
+                       y++;
+                   }
+               } else if (picasso_vidinfo.pixbytes == 4 && picasso96_state.BytesPerPixel == 1) { /* 8->32 */
+                   int x;
+                   while (y <= yend) {
+                       for (x = 0; x < picasso96_state.Width;) {
+                           ((uae_u32*)dst2)[x] = picasso_vidinfo.clut[src2[x]];
+                           x++;
+                           ((uae_u32*)dst2)[x] = picasso_vidinfo.clut[src2[x]];
+                           x++;
+                           ((uae_u32*)dst2)[x] = picasso_vidinfo.clut[src2[x]];
+                           x++;
+                           ((uae_u32*)dst2)[x] = picasso_vidinfo.clut[src2[x]];
+                           x++;
+                       }
+                       src2 += picasso96_state.BytesPerRow;
+                       dst2 += picasso_vidinfo.rowbytes;
+                       y++;
+                   }
+               } else if (picasso_vidinfo.pixbytes == 2 && picasso96_state.BytesPerPixel == 4) { /* 32->16 */
+                   int x;
+                   while (y <= yend) {
+                       for (x = 0; x < picasso96_state.Width;) {
+                           uae_u32 v;
+                           v = ((uae_u32*)src2)[x];
+                           ((uae_u16*)dst2)[x] = p96_rgbx16[(((v >> (16 + 3)) & 0x1f) << 11) | (((v >> (8 + 2)) & 0x3f) << 5) | (((v >> (0 + 3)) & 0x1f) << 0)];
+                           x++;
+                           v = ((uae_u32*)src2)[x];
+                           ((uae_u16*)dst2)[x] = p96_rgbx16[(((v >> (16 + 3)) & 0x1f) << 11) | (((v >> (8 + 2)) & 0x3f) << 5) | (((v >> (0 + 3)) & 0x1f) << 0)];
+                           x++;
+                           v = ((uae_u32*)src2)[x];
+                           ((uae_u16*)dst2)[x] = p96_rgbx16[(((v >> (16 + 3)) & 0x1f) << 11) | (((v >> (8 + 2)) & 0x3f) << 5) | (((v >> (0 + 3)) & 0x1f) << 0)];
+                           x++;
+                           v = ((uae_u32*)src2)[x];
+                           ((uae_u16*)dst2)[x] = p96_rgbx16[(((v >> (16 + 3)) & 0x1f) << 11) | (((v >> (8 + 2)) & 0x3f) << 5) | (((v >> (0 + 3)) & 0x1f) << 0)];
+                           x++;
+                       }
+                       src2 += picasso96_state.BytesPerRow;
+                       dst2 += picasso_vidinfo.rowbytes;
+                       y++;
+                   }
+               } else if (picasso_vidinfo.pixbytes == 2 && picasso96_state.BytesPerPixel == 1) { /* 8->16 */
+                   int x;
+                   while (y <= yend) {
+                       for (x = 0; x < picasso96_state.Width;) {
+                           ((uae_u16*)dst2)[x] = picasso_vidinfo.clut[src2[x]];
+                           x++;
+                           ((uae_u16*)dst2)[x] = picasso_vidinfo.clut[src2[x]];
+                           x++;
+                           ((uae_u16*)dst2)[x] = picasso_vidinfo.clut[src2[x]];
+                           x++;
+                           ((uae_u16*)dst2)[x] = picasso_vidinfo.clut[src2[x]];
+                           x++;
+                       }
+                       src2 += picasso96_state.BytesPerRow;
+                       dst2 += picasso_vidinfo.rowbytes;
+                       y++;
                    }
-    #else
-                   memcpy (dst2, src2, rowwidth_dst);
-    #endif
-                   src2 += picasso96_state.BytesPerRow;
-                   dst2 += picasso_vidinfo.rowbytes;
-                   y++;
                }
            }
 
-#if 0
-           for (j = 0; j < ps / 4; j++) {
-               int xbytes, y;
-               uae_u32 *dst2;
-               y = addr / picasso96_state.BytesPerRow;
-               xbytes = addr % picasso96_state.BytesPerRow;
-               if (xbytes < rowwidth_dst && y < picasso96_state.Height) {
-                   dst2 = (uae_u32*)(dst + y * picasso_vidinfo.rowbytes + xbytes);
-                   *dst2 = ((uae_u32*)p)[0];
-               }
-               addr += 4;
-               p += 4;
-           }
-#endif
        }
     }
+
+    if(lock)
+       gfx_unlock_picasso();
+    if (maxy >= 0)
+       DX_Invalidate (0, miny, picasso96_state.Width, maxy - miny + 1);
 }
 
 static void flushpixels_rgb(uae_u8 *dst)
@@ -3547,14 +3424,18 @@ static void flushpixels(void)
 {
     uae_u8 *dst;
     int lock = 0;
+    static int cnt;
 
-    if (pixelcount == 0 && p96mode == 0)
-       return;
     if (!picasso_on) {
        pixelcount = 0;
        return;
     }
-    DX_Invalidate (-1, -1, -1, -1);
+    if (p96mode) {
+       flushpixels_x ();
+       return;
+    }
+    if (pixelcount == 0)
+       return;
 #ifndef        _DEBUG
     if(DirectDraw_IsLocked() == FALSE) {
        dst = gfx_lock_picasso ();
@@ -3563,21 +3444,15 @@ static void flushpixels(void)
 #endif
        dst = picasso96_state.HostAddress;
     if (dst) {
-       if (p96mode) {
-           if(picasso_vidinfo.rgbformat == picasso96_state.RGBFormat)
-               flushpixels_rgbx(dst);
-           else
-               write_log("!");
-       } else {
-           if(picasso_vidinfo.rgbformat == picasso96_state.RGBFormat)
-               flushpixels_rgb(dst);
-           else
-               flushpixels_paletted(dst);
-       }
+       DX_Invalidate (-1, -1, -1, -1);
+       if(picasso_vidinfo.rgbformat == picasso96_state.RGBFormat)
+           flushpixels_rgb(dst);
+       else
+           flushpixels_paletted(dst);
     }
     if(lock)
        gfx_unlock_picasso();
-    pixelcount=0;
+    pixelcount = 0;
 }
 #endif
 
index 138d85636556478344c28d6f48459933c02ee8d4..1ef41111729c8d4b57b79ac53629df2dd80105aa 100755 (executable)
@@ -523,10 +523,11 @@ extern int  DX_Fill(int dstx, int dsty, int width, int height, uae_u32 color, RG
 extern uae_u32 DX_ShowCursor(uae_u32 activate);
 extern uae_u32 DX_MoveCursor(uae_u32 x, uae_u32 y);
 extern void picasso_enablescreen (int on);
-extern void picasso_refresh (int);
+extern void picasso_refresh (void);
 extern void picasso_handle_vsync (void);
 extern void init_hz_p96 (void);
 extern void picasso_handle_hsync (void);
+extern void picasso_palette (void);
 
 extern uae_u8 *gfxmemory;
 
@@ -552,6 +553,7 @@ extern void picasso_clip_mouse (int *, int *);
 
 extern int p96refresh_active;
 extern int p96hsync_counter;
+extern int p96mode;
 
 #endif
 
index 05fa1123f9495357d55f6cd75df05c4a5c208792..ebdbbe88f8b68549a582eb5b170ed8e2c7d22d49 100755 (executable)
 #define IDS_NUMSG_KS68030               331
 #define IDS_NUMSG_EXPROMNEED            332
 #define IDS_HARDDRIVESAFETYWARNING2     333
+#define IDM_DBGCONTEXTMENU              334
+#define IDD_DBGMEMINPUT                 335
 #define IDS_QS_MODELS                   1000
 #define IDS_QS_MODEL_A500               1001
 #define IDS_QS_MODEL_A500P              1002
 #define IDC_PORT1_JOYS                  1027
 #define IDC_SCREENMODE_RTG              1027
 #define IDC_MBMEM1                      1028
+#define IDC_P96MODE                     1029
 #define IDC_SLOWMEM                     1030
 #define IDC_MBMEM2                      1031
 #define IDC_PARALLEL                    1033
 #define IDC_FILTERVO                    1619
 #define IDC_AVIOUTPUT_8BIT              1620
 #define IDC_INPREC_PLAY                 1620
-#define IDC_FILTERENABLE2               1620
 #define IDC_FILTERUPSCALE               1620
 #define IDC_AVIOUTPUT_24BIT             1621
 #define IDC_AVIOUTPUT_WIDTH             1622
 #define IDC_DF3ENABLE                   1778
 #define IDC_HDF_RW                      1778
 #define IDC_HDFINFO                     1779
+#define IDC_DBG_AUTOSET                 1780
+#define IDC_DBG_DASM2                   1781
+#define IDC_DBG_MEM2                    1782
+#define IDC_DBG_MEMINPUT2               1783
+#define IDC_DBG_ADDRINPUTTXT            1784
 #define ID__FLOPPYDRIVES                40004
 #define ID_FLOPPYDRIVES_DF0             40005
 #define ID_ST_CONFIGURATION             40010
 #define ID_DBG_PAGE7                    40026
 #define ID_DBG_PAGE8                    40027
 #define ID_DBG_PAGE9                    40028
+#define ID_DBG_STEP_OVER                40029
+#define ID_DBG_STEP_INTO                40030
+#define ID_DBG_SETTOA0                  40031
+#define ID_DBG_SETTOA1                  40032
+#define ID_DBG_SETTOA2                  40033
+#define ID_DBG_SETTOA3                  40034
+#define ID_DBG_SETTOA4                  40035
+#define ID_DBG_SETTOA5                  40036
+#define ID_DBG_SETTOA6                  40037
+#define ID_DBG_SETTOA7                  40038
+#define ID_DBG_ENTERADDR                40039
+#define ID_DBG_COPYLBLINE               40040
+#define ID_DBG_COPYLB                   40041
+#define ID_DBG_TOGGLEBP                 40042
+#define ID_DBG_DELETEBPS                40043
 
 // Next default values for new objects
 // 
 #ifndef APSTUDIO_READONLY_SYMBOLS
 #define _APS_NO_MFC                     1
 #define _APS_3D_CONTROLS                     1
-#define _APS_NEXT_RESOURCE_VALUE        334
-#define _APS_NEXT_COMMAND_VALUE         40029
-#define _APS_NEXT_CONTROL_VALUE         1779
+#define _APS_NEXT_RESOURCE_VALUE        336
+#define _APS_NEXT_COMMAND_VALUE         40044
+#define _APS_NEXT_CONTROL_VALUE         1785
 #define _APS_NEXT_SYMED_VALUE           101
 #endif
 #endif
index 4b9e1d0bb5ad67adbbd76947db6575ac10ac9707..ebdbbe88f8b68549a582eb5b170ed8e2c7d22d49 100755 (executable)
 #define IDC_PORT1_JOYS                  1027
 #define IDC_SCREENMODE_RTG              1027
 #define IDC_MBMEM1                      1028
+#define IDC_P96MODE                     1029
 #define IDC_SLOWMEM                     1030
 #define IDC_MBMEM2                      1031
 #define IDC_PARALLEL                    1033
index fc0e4514ac06260874c2b96b18db9950339101f6..7292cbad1abcda27756351ea7ff5a61fac1c2fbf 100755 (executable)
@@ -132,11 +132,10 @@ BEGIN
     EDITTEXT        IDC_SLOWRAM,243,25,30,12,ES_CENTER | ES_READONLY
     RTEXT           "Fast:",IDC_FASTTEXT,24,51,20,10,SS_CENTERIMAGE
     CONTROL         "Slider1",IDC_FASTMEM,"msctls_trackbar32",TBS_AUTOTICKS | TBS_TOP | WS_TABSTOP,54,47,50,20
-    EDITTEXT        IDC_FASTRAM,105,50,30,12,ES_CENTER | ES_READONLY
     RTEXT           "Z3 Fast:",IDC_Z3TEXT,139,51,30,10,SS_CENTERIMAGE
     CONTROL         "Slider1",IDC_Z3FASTMEM,"msctls_trackbar32",TBS_AUTOTICKS | TBS_TOP | WS_TABSTOP,179,47,60,20
     EDITTEXT        IDC_Z3FASTRAM,243,50,30,12,ES_CENTER | ES_READONLY
-    RTEXT           "RTG: [] Graphics card memory. Required for RTG (Picasso96) emulation.",IDC_GFXCARDTEXT,79,76,90,10,SS_NOTIFY | SS_CENTERIMAGE
+    RTEXT           "RTG: [] Graphics card memory. Required for RTG (Picasso96) emulation.",IDC_GFXCARDTEXT,136,76,33,10,SS_NOTIFY | SS_CENTERIMAGE
     CONTROL         "Slider1",IDC_P96MEM,"msctls_trackbar32",TBS_AUTOTICKS | TBS_TOP | WS_TABSTOP,179,72,60,20
     EDITTEXT        IDC_P96RAM,243,75,30,12,ES_CENTER | ES_READONLY
     GROUPBOX        "Advanced Memory Settings",-1,13,104,275,65
@@ -146,6 +145,7 @@ BEGIN
     RTEXT           "Motherboard RAM (High area):",-1,39,148,129,10,SS_CENTERIMAGE
     CONTROL         "",IDC_MBMEM2,"msctls_trackbar32",TBS_AUTOTICKS | TBS_TOP | WS_TABSTOP,180,144,59,20
     EDITTEXT        IDC_MBRAM2,243,147,30,12,ES_CENTER | ES_READONLY
+    COMBOBOX        IDC_P96MODE,80,74,52,150,CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP
 END
 
 IDD_CPU DIALOGEX 0, 0, 300, 226
@@ -876,7 +876,7 @@ BEGIN
     LISTBOX         IDC_DBG_MCUSTOM,372,79,81,138,LBS_OWNERDRAWFIXED | LBS_HASSTRINGS | LBS_NOINTEGRALHEIGHT
     LISTBOX         IDC_DBG_MISC,1,79,370,262,LBS_OWNERDRAWFIXED | LBS_HASSTRINGS | LBS_NOINTEGRALHEIGHT | LBS_DISABLENOSCROLL | WS_VSCROLL
     LISTBOX         IDC_DBG_CUSTOM,1,79,370,262,LBS_OWNERDRAWFIXED | LBS_HASSTRINGS | LBS_NOINTEGRALHEIGHT | LBS_DISABLENOSCROLL | WS_VSCROLL
-    CONTROL         "Auto set",IDC_DBG_AUTOSET,"Button",BS_AUTOCHECKBOX | NOT WS_TABSTOP,84,79,50,12
+    CONTROL         "Auto set",IDC_DBG_AUTOSET,"Button",BS_AUTOCHECKBOX,84,79,50,12
     LISTBOX         IDC_DBG_DASM2,1,79,370,87,LBS_OWNERDRAWFIXED | LBS_HASSTRINGS | LBS_NOINTEGRALHEIGHT
     LISTBOX         IDC_DBG_MEM2,1,167,370,87,LBS_OWNERDRAWFIXED | LBS_HASSTRINGS | LBS_NOINTEGRALHEIGHT
 END
@@ -892,6 +892,7 @@ BEGIN
     CTEXT           "Enter address",IDC_DBG_ADDRINPUTTXT,20,1,100,10,SS_CENTERIMAGE | WS_TABSTOP
 END
 
+
 /////////////////////////////////////////////////////////////////////////////
 //
 // Icon
@@ -996,33 +997,33 @@ BEGIN
     BEGIN
         POPUP "Copy"
         BEGIN
-            MENUITEM "Copy line"                 ID_DBG_COPYLBLINE
-            MENUITEM "Copy all"                  ID_DBG_COPYLB
+            MENUITEM "Copy line",                   ID_DBG_COPYLBLINE
+            MENUITEM "Copy all",                    ID_DBG_COPYLB
         END
         POPUP "Set top address"
         BEGIN
-            MENUITEM "Set to A0",                ID_DBG_SETTOA0
-            MENUITEM "Set to A1",                ID_DBG_SETTOA1
-            MENUITEM "Set to A2",                ID_DBG_SETTOA2
-            MENUITEM "Set to A3",                ID_DBG_SETTOA3
-            MENUITEM "Set to A4",                ID_DBG_SETTOA4
-            MENUITEM "Set to A5",                ID_DBG_SETTOA5
-            MENUITEM "Set to A6",                ID_DBG_SETTOA6
-            MENUITEM "Set to A7",                ID_DBG_SETTOA7
-            MENUITEM "Enter address",            ID_DBG_ENTERADDR
+            MENUITEM "Set to A0",                   ID_DBG_SETTOA0
+            MENUITEM "Set to A1",                   ID_DBG_SETTOA1
+            MENUITEM "Set to A2",                   ID_DBG_SETTOA2
+            MENUITEM "Set to A3",                   ID_DBG_SETTOA3
+            MENUITEM "Set to A4",                   ID_DBG_SETTOA4
+            MENUITEM "Set to A5",                   ID_DBG_SETTOA5
+            MENUITEM "Set to A6",                   ID_DBG_SETTOA6
+            MENUITEM "Set to A7",                   ID_DBG_SETTOA7
+            MENUITEM "Enter address",               ID_DBG_ENTERADDR
         END
     END
     POPUP "Disassembly"
     BEGIN
         POPUP "Copy"
         BEGIN
-            MENUITEM "Copy line"                 ID_DBG_COPYLBLINE
-            MENUITEM "Copy all"                  ID_DBG_COPYLB
+            MENUITEM "Copy line",                   ID_DBG_COPYLBLINE
+            MENUITEM "Copy all",                    ID_DBG_COPYLB
         END
         POPUP "Breakpoints"
         BEGIN
-            MENUITEM "Toggle breakpoint"         ID_DBG_TOGGLEBP
-            MENUITEM "Clear all breakpoints"     ID_DBG_DELETEBPS
+            MENUITEM "Toggle breakpoint",           ID_DBG_TOGGLEBP
+            MENUITEM "Clear all breakpoints",       ID_DBG_DELETEBPS
         END
     END
 END
index 74237a70f46d583219d4cabf519b8a34329af35a..db5ef3f3b5ba4d81e19bbdd5743952c84d9a5421 100755 (executable)
@@ -10,6 +10,7 @@
 #define DRIVESOUND
 #define GFXFILTER
 #define X86_MSVC_ASSEMBLY
+//#define X86_MSVC_ASSEMBLY_MEMACCESS
 #define OPTIMIZED_FLAGS
 #define __i386__
 
index 658bff5df53819d890cacfef3c9f61803d716873..31e05b9d2d706c73b9c3f082c93ebfd34d66de2e 100755 (executable)
@@ -2481,6 +2481,7 @@ static void WIN32_HandleRegistryStuff(void)
     regclosetree (read_disk_history ());
     read_rom_list ();
     load_keyring(NULL, NULL);
+    regqueryint (NULL, "p96mode", &p96mode);
 }
 
 #if WINUAEPUBLICBETA > 0
index 7fa5f6f0db118acab5a5439d6bc11d51c0b526ee..61c113216279d1bf62029556b18335161595f1ac 100755 (executable)
@@ -15,9 +15,9 @@
 #define GETBDM(x) (((x) - ((x / 10000) * 10000)) / 100)
 #define GETBDD(x) ((x) % 100)
 
-#define WINUAEBETA 1
+#define WINUAEBETA 3
 #define WINUAEPUBLICBETA 1
-#define WINUAEDATE MAKEBD(2008, 2, 17)
+#define WINUAEDATE MAKEBD(2008, 2, 23)
 #define WINUAEEXTRA ""
 #define WINUAEREV ""
 
index 0ee78b3b26e6aebf510be817d58b77d674d49596..211b361f05e2c3a843c7f110d021d5d9ae9a329a 100755 (executable)
@@ -296,42 +296,6 @@ static int rgbformat_bits (RGBFTYPE t)
            : 0);
 }
 
-#if 0
-static DEVMODE dmScreenSettings;
-static volatile cdsthread_ret;
-
-static void cdsthread (void *dummy)
-{
-    int ret = ChangeDisplaySettings (&dmScreenSettings, CDS_FULLSCREEN);
-    if (ret != DISP_CHANGE_SUCCESSFUL && dmScreenSettings.dmDisplayFrequency > 0) {
-       dmScreenSettings.dmFields &= ~DM_DISPLAYFREQUENCY;
-       ret = ChangeDisplaySettings (&dmScreenSettings, CDS_FULLSCREEN);
-    }
-    if (ret != DISP_CHANGE_SUCCESSFUL) {
-       cdsthread_ret = 0;
-       return;
-    }
-    cdsthread_ret = 1;
-}
-
-#include <process.h>
-static int do_changedisplaysettings (int width, int height, int bits, int freq)
-{
-    memset (&dmScreenSettings, 0, sizeof(dmScreenSettings));
-    dmScreenSettings.dmSize = sizeof(dmScreenSettings);
-    dmScreenSettings.dmPelsWidth = width;
-    dmScreenSettings.dmPelsHeight = height;
-    dmScreenSettings.dmBitsPerPel = bits;
-    dmScreenSettings.dmDisplayFrequency = freq;
-    dmScreenSettings.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | (freq > 0 ? DM_DISPLAYFREQUENCY : 0);
-    cdsthread_ret = -1;
-    _beginthread (&cdsthread, 0, 0);
-    while (cdsthread_ret < 0)
-       Sleep (10);
-    return cdsthread_ret;
-}
-#endif
-
 static int set_ddraw (void)
 {
     HRESULT ddrval;
@@ -425,26 +389,6 @@ oops2:
     return 0;
 }
 
-/*
-static void dhack(void)
-{
-    int i = 0;
-    while (DisplayModes[i].depth >= 0)
-       i++;
-    if (i >= MAX_PICASSO_MODES - 1)
-       return;
-    DisplayModes[i].res.width = 480;
-    DisplayModes[i].res.height = 640;
-    DisplayModes[i].depth = DisplayModes[i - 1].depth;
-    DisplayModes[i].refresh[0] = 0;
-    DisplayModes[i].refresh[1] = 0;
-    DisplayModes[i].colormodes = DisplayModes[i - 1].colormodes;
-    DisplayModes[i + 1].depth = -1;
-    sprintf(DisplayModes[i].name, "%dx%d, %d-bit",
-       DisplayModes[i].res.width, DisplayModes[i].res.height, DisplayModes[i].depth * 8);
-}
-*/
-
 static HRESULT CALLBACK modesCallback(LPDDSURFACEDESC2 modeDesc, LPVOID context)
 {
     RGBFTYPE colortype;
@@ -1053,23 +997,25 @@ static int open_windows (void)
        if (ret < -1) {
 #ifdef PICASSO96
            if (screen_is_picasso) {
-               currentmode->current_width = picasso_vidinfo.width;
-               currentmode->current_height = picasso_vidinfo.height;
+               currentmode->current_width = picasso96_state.Width;
+               currentmode->current_height = picasso96_state.Height;
                currentmode->current_depth = rgbformat_bits (picasso_vidinfo.selected_rgbformat);
                currentmode->frequency = abs (currprefs.gfx_refreshrate > default_freq ? currprefs.gfx_refreshrate : default_freq);
            } else {
 #endif
                currentmode->current_width = currprefs.gfx_size.width;
                currentmode->current_height = currprefs.gfx_size.height;
-               currentmode->current_depth = (currprefs.color_mode == 0 ? 8
-                               : currprefs.color_mode == 1 ? 15
-                               : currprefs.color_mode == 2 ? 16
-                               : currprefs.color_mode == 3 ? 8
-                               : currprefs.color_mode == 4 ? 8 : 32);
                currentmode->frequency = abs (currprefs.gfx_refreshrate);
 #ifdef PICASSO96
            }
 #endif
+           if (!screen_is_picasso || p96mode) {
+               currentmode->current_depth = (currprefs.color_mode == 0 ? 8
+                       : currprefs.color_mode == 1 ? 15
+                       : currprefs.color_mode == 2 ? 16
+                       : currprefs.color_mode == 3 ? 8
+                       : currprefs.color_mode == 4 ? 8 : 32);
+           }
            currentmode->amiga_width = currentmode->current_width;
            currentmode->amiga_height = currentmode->current_height;
        }
@@ -1403,6 +1349,7 @@ void init_colors (void)
        AVIOutput_RGBinfo (red_bits, green_bits, blue_bits, red_shift, green_shift, blue_shift);
 #endif
     }
+    alloc_colors_picasso (red_bits, green_bits, blue_bits, red_shift,green_shift, blue_shift, alpha_bits, alpha_shift, alpha, 0);
 }
 
 #ifdef PICASSO96
@@ -1410,6 +1357,20 @@ void DX_SetPalette_vsync (void)
 {
 }
 
+void picasso_palette (void)
+{
+    int i;
+
+    for (i = 0; i < 256; i++) {
+        int r = picasso96_state.CLUT[i].Red;
+        int g = picasso96_state.CLUT[i].Green;
+        int b = picasso96_state.CLUT[i].Blue;
+        picasso_vidinfo.clut[i] = (doMask256 (r, red_bits, red_shift)
+           | doMask256 (g, green_bits, green_shift)
+           | doMask256 (b, blue_bits, blue_shift));
+    }
+}
+
 void DX_SetPalette (int start, int count)
 {
     HRESULT ddrval;
@@ -1417,25 +1378,8 @@ void DX_SetPalette (int start, int count)
     if (!screen_is_picasso)
        return;
 
-    if( picasso96_state.RGBFormat != RGBFB_CHUNKY )
-       return;
-
     if (picasso_vidinfo.pixbytes != 1)
-    {
-       /* write_log ("DX Setpalette emulation\n"); */
-       /* This is the case when we're emulating a 256 color display.  */
-       while (count-- > 0)
-       {
-           int r = picasso96_state.CLUT[start].Red;
-           int g = picasso96_state.CLUT[start].Green;
-           int b = picasso96_state.CLUT[start].Blue;
-           picasso_vidinfo.clut[start++] = (doMask256 (r, red_bits, red_shift)
-               | doMask256 (g, green_bits, green_shift)
-               | doMask256 (b, blue_bits, blue_shift));
-       }
-       notice_screen_contents_lost();
        return;
-    }
 
     /* Set our DirectX palette here */
     if(currentmode->current_depth == 8)
@@ -1543,60 +1487,6 @@ static COLORREF BuildColorRef(int color, RGBFTYPE pixelformat)
     else
        result = do_get_mem_long(&color);
     return result;
-#if 0
-    int r,g,b;
-    write_log ( "DX_Blit() called to fill with color of 0x%x, rgbtype of 0x%x\n", color, pixelformat );
-
-    switch( pixelformat )
-    {
-       case RGBFB_R5G6B5PC:
-           r = color & 0xF800 >> 11;
-           g = color & 0x07E0 >> 5;
-           b = color & 0x001F;
-       break;
-       case RGBFB_R5G5B5PC:
-           r = color & 0x7C00 >> 10;
-           g = color & 0x03E0 >> 5;
-           b = color & 0x001F;
-       break;
-       case RGBFB_B5G6R5PC:
-           r = color & 0x001F;
-           g = color & 0x07E0 >> 5;
-           b = color & 0xF800 >> 11;
-       break;
-       case RGBFB_B5G5R5PC:
-           r = color & 0x001F;
-           g = color & 0x03E0 >> 5;
-           b = color & 0x7C00 >> 10;
-       break;
-       case RGBFB_B8G8R8:
-           r = color & 0x00FF0000 >> 16;
-           g = color & 0x0000FF00 >> 8;
-           b = color & 0x000000FF;
-       break;
-       case RGBFB_A8B8G8R8:
-           r = color & 0xFF000000 >> 24;
-           g = color & 0x00FF0000 >> 16;
-           b = color & 0x0000FF00 >> 8;
-       break;
-       case RGBFB_R8G8B8:
-           r = color & 0x000000FF;
-           g = color & 0x0000FF00 >> 8;
-           b = color & 0x00FF0000 >> 16;
-       break;
-       case RGBFB_A8R8G8B8:
-           r = color & 0x0000FF00 >> 8;
-           g = color & 0x00FF0000 >> 16;
-           b = color & 0xFF000000 >> 24;
-       break;
-       default:
-           write_log ( "Uknown 0x%x pixel-format\n", pixelformat );
-       break;
-    }
-    result = RGB(r,g,b);
-    write_log ( "R = 0x%02x, G = 0x%02x, B = 0x%02x - result = 0x%08x\n", r, g, b, result );
-    return result;
-#endif
 }
 
 static void centerrect(RECT *r)
@@ -1761,31 +1651,49 @@ static void open_screen(void)
 }
 
 #ifdef PICASSO96
+
+static int modeswitchneeded (void)
+{
+    if (!p96mode)
+       return 1;
+    if (picasso96_state.Width != currentmode->current_width ||
+       picasso96_state.Height != currentmode->current_height)
+       return 1;
+    return 0;
+}
+
 void gfx_set_picasso_state(int on)
 {
     if (screen_is_picasso == on)
        return;
     screen_is_picasso = on;
+    if (currprefs.gfx_afullscreen == currprefs.gfx_pfullscreen && !modeswitchneeded())
+       return;
     open_screen();
 }
 
 void gfx_set_picasso_modeinfo(uae_u32 w, uae_u32 h, uae_u32 depth, RGBFTYPE rgbfmt)
 {
-    depth >>= 3;
-    if(((unsigned)picasso_vidinfo.width == w) &&
-           ((unsigned)picasso_vidinfo.height == h) &&
-           ((unsigned)picasso_vidinfo.depth == depth) &&
-           (picasso_vidinfo.selected_rgbformat == rgbfmt))
-       return;
+    if (p96mode) {
+       if (screen_is_picasso && modeswitchneeded())
+           open_screen ();
+    } else {
+       depth >>= 3;
+       if(((unsigned)picasso_vidinfo.width == w) &&
+               ((unsigned)picasso_vidinfo.height == h) &&
+               ((unsigned)picasso_vidinfo.depth == depth) &&
+               (picasso_vidinfo.selected_rgbformat == rgbfmt))
+           return;
 
-    picasso_vidinfo.selected_rgbformat = rgbfmt;
-    picasso_vidinfo.width = w;
-    picasso_vidinfo.height = h;
-    picasso_vidinfo.depth = depth;
-    picasso_vidinfo.extra_mem = 1;
+       picasso_vidinfo.selected_rgbformat = rgbfmt;
+       picasso_vidinfo.width = w;
+       picasso_vidinfo.height = h;
+       picasso_vidinfo.depth = depth;
+       picasso_vidinfo.extra_mem = 1;
 
-    if(screen_is_picasso) {
-       open_screen();
+       if(screen_is_picasso && modeswitchneeded()) {
+           open_screen();
+       }
     }
 }
 #endif
@@ -2212,7 +2120,7 @@ static BOOL doInit (void)
            if (!console_logging)
                fs_warning = IDS_UNSUPPORTEDSCREENMODE_3;
 #ifdef PICASSO96
-       } else if (screen_is_picasso && !currprefs.gfx_pfullscreen &&
+       } else if (screen_is_picasso && !p96mode && !currprefs.gfx_pfullscreen &&
                  (picasso_vidinfo.selected_rgbformat != RGBFB_CHUNKY) &&
                  (picasso_vidinfo.selected_rgbformat != colortype) &&
                    !(currentmode->flags & DM_OVERLAY) )
@@ -2316,6 +2224,18 @@ static BOOL doInit (void)
 #endif
     }
 
+#ifdef PICASSO96
+    if (p96mode) {
+       picasso_vidinfo.rowbytes = DirectDraw_GetSurfacePitch();
+       picasso_vidinfo.pixbytes = DirectDraw_GetBytesPerPixel();
+       picasso_vidinfo.rgbformat = DirectDraw_GetPixelFormat();
+       picasso_vidinfo.extra_mem = 1;
+       picasso_vidinfo.height = currentmode->current_height;
+       picasso_vidinfo.width = currentmode->current_width;
+       picasso_vidinfo.depth = currentmode->current_depth;
+    }
+#endif
+
     if ((currentmode->flags & DM_DDRAW) && !(currentmode->flags & (DM_D3D | DM_SWSCALE))) {
 
        int flags;
index 150c49798d2fd103ce464d2968dbe02b6dfd92be..05e4d3233f317bf7b46fa8b52e403d4aad874629 100755 (executable)
@@ -4543,6 +4543,7 @@ static void enable_for_memorydlg (HWND hDlg)
     ew (hDlg, IDC_MBMEM1, z3);
     ew (hDlg, IDC_MBRAM2, z3);
     ew (hDlg, IDC_MBMEM2, z3);
+    ew (hDlg, IDC_P96MODE, full_property_sheet);
 }
 
 static void values_to_memorydlg (HWND hDlg)
@@ -4648,6 +4649,12 @@ static void values_to_memorydlg (HWND hDlg)
     }
     SendDlgItemMessage (hDlg, IDC_MBMEM2, TBM_SETPOS, TRUE, mem_size);
     SetDlgItemText (hDlg, IDC_MBRAM2, memsize_names[msi_gfx[mem_size]]);
+
+    SendDlgItemMessage(hDlg, IDC_P96MODE, CB_RESETCONTENT, 0, 0);
+    SendDlgItemMessage (hDlg, IDC_P96MODE, CB_ADDSTRING, 0, (LPARAM)"P96-OLD");
+    SendDlgItemMessage (hDlg, IDC_P96MODE, CB_ADDSTRING, 0, (LPARAM)"P96-NEW");
+    SendDlgItemMessage (hDlg, IDC_P96MODE, CB_SETCURSEL, p96mode, 0);
+
 }
 
 static void fix_values_memorydlg (void)
@@ -4699,6 +4706,10 @@ static INT_PTR CALLBACK MemoryDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARA
        if (recursive > 0)
            break;
        recursive++;
+       if (LOWORD (wParam) == IDC_P96MODE && full_property_sheet) {
+           p96mode = SendDlgItemMessage (hDlg, IDC_P96MODE, CB_GETCURSEL, 0, 0);
+           regsetint (NULL, "p96mode", p96mode);
+       }
        values_to_memorydlg (hDlg);
        recursive--;
        break;
index 32fdac3e83b82c9495e7beb721ee8207df5ab88a..88f52debbe811c1fa30e37d8706dff91b5037320 100755 (executable)
@@ -1,7 +1,31 @@
 
+Beta 3:
+
+- "P96 new"-mode only: RTG display depth is now completely virtual.
+  Emulation converts to real color space (configured in display panel)
+  16->32, 8->32, 32->16 and 8->16 supported. 8-bit and 16-bit (without
+  overlay) now possible in windowed mode. I guess real 8-bit support
+  can be removed because it is not very well supported anymore..
+  24-bit and 16-bit RGB (instead of 16-bit BGR) can be also implemented
+  if some weird program don't support other modes..
+- "new mode" fixes and optimizations
+- chipset<>RTG switching is now instant (no closing and reopening) if
+  both modes have same dimensions. (to do: different dimensions)
+- "old p96 mode" will be removed soon because it is incompatible with
+  above new features. Other new possible features will be RTG filter
+  support (for example 2x support for small resolutions like 320x200)
+
 Beta 2:
 
+- experimental Picasso96 speedup code. Default enabled, temporary
+  option added to RAM-panel (stored to registry, not config file)
+  May be slower on older PCs, I get up to 8x speedup in P96Speed
+  benchmark (both desktop and laptop) Post your results here.
+  Including PC specs, "old" and "new" P96Speed or other test results.
+- harddrive detection now also includes more devices, even CDROMs..
+  (perhaps this allows PCMCIA SRAM direct access)
 - Weird Dreams sound problem (hospital scene when game is starting)
+- GUI debugger patch I forgot to merge
 
 
 Beta 1: (possible big changes in future betas)
diff --git a/p96_blit.c b/p96_blit.c
new file mode 100755 (executable)
index 0000000..44e509b
--- /dev/null
@@ -0,0 +1,59 @@
+
+static void NOINLINE BLT_NAME (unsigned int w, unsigned int h, uae_u8 *src, uae_u8 *dst, int srcpitch, int dstpitch)
+{
+    uae_u8 *src2 = src;
+    uae_u8 *dst2 = dst;
+    uae_u8 *src2e = src + w;
+    uae_u32 *src2_32 = (uae_u32*)src;
+    uae_u32 *dst2_32 = (uae_u32*)dst;
+    unsigned int y, x, ww, xxd;
+    uae_u32 tmp;
+
+    if (w < 8) {
+       for(y = 0; y < h; y++) {
+           uae_u32 *src_32 = (uae_u32*)src2;
+           uae_u32 *dst_32 = (uae_u32*)dst2;
+           for (x = 0; x < w; x++) {
+               BLT_FUNC (src_32, dst_32);
+               src_32++; dst_32++;
+           }
+           dst2 += dstpitch;
+           src2 += srcpitch;
+       }
+       return;
+    }
+
+    ww = w / 8;
+    xxd = w - ww * 8;
+    for(y = 0; y < h; y++) {
+       uae_u32 *src_32 = (uae_u32*)src2;
+       uae_u32 *dst_32 = (uae_u32*)dst2;
+       for (x = 0; x < ww; x++) {
+           BLT_FUNC (src_32, dst_32);
+           src_32++; dst_32++;
+           BLT_FUNC (src_32, dst_32);
+           src_32++; dst_32++;
+           BLT_FUNC (src_32, dst_32);
+           src_32++; dst_32++;
+           BLT_FUNC (src_32, dst_32);
+           src_32++; dst_32++;
+           BLT_FUNC (src_32, dst_32);
+           src_32++; dst_32++;
+           BLT_FUNC (src_32, dst_32);
+           src_32++; dst_32++;
+           BLT_FUNC (src_32, dst_32);
+           src_32++; dst_32++;
+           BLT_FUNC (src_32, dst_32);
+           src_32++; dst_32++;
+       }
+       for (x = 0; x < xxd; x++) {
+           BLT_FUNC (src_32, dst_32);
+           src_32++; dst_32++;
+       }
+       dst2 += dstpitch;
+       src2 += srcpitch;
+    }
+}
+#undef BLT_NAME
+#undef BLT_FUNC
+               
\ No newline at end of file