]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
imported winuaesrc1500b13.zip
authorToni Wilen <twilen@winuae.net>
Sun, 20 Apr 2008 08:35:01 +0000 (11:35 +0300)
committerToni Wilen <twilen@winuae.net>
Mon, 22 Feb 2010 19:39:49 +0000 (21:39 +0200)
28 files changed:
cfgfile.c
drawing.c
enforcer.c
expansion.c
genlinetoscr.c
include/inputdevice.h
include/options.h
include/sysdeps.h
inputdevice.c
main.c
memory.c
od-win32/blkdev_win32_spti.c
od-win32/cloanto/RetroPlatformIPC.h
od-win32/dxwrap.c
od-win32/dxwrap.h
od-win32/hardfile_win32.c
od-win32/resources/resource
od-win32/resources/resource.h
od-win32/resources/winuae.rc
od-win32/rp.c
od-win32/rp.h
od-win32/win32.c
od-win32/win32.h
od-win32/win32_scale2x.c
od-win32/win32gfx.c
od-win32/win32gfx.h
od-win32/win32gui.c
od-win32/winuaechangelog.txt

index 88812de724506a040dc2680e1c0332a131b92b87..02613d9f1f113b60d64934498fd09b3d74cd4966 100755 (executable)
--- a/cfgfile.c
+++ b/cfgfile.c
@@ -163,7 +163,7 @@ static const char *obsolete[] = {
     "sound_pri_cutoff", "sound_pri_time", "sound_min_buff",
     "gfx_test_speed", "gfxlib_replacement", "enforcer", "catweasel_io",
     "kickstart_key_file", "fast_copper", "sound_adjust",
-    "serial_hardware_dtrdsr",
+    "serial_hardware_dtrdsr", "gfx_filter_upscale",
     0
 };
 
@@ -497,6 +497,7 @@ void cfgfile_save_options (struct zfile *f, struct uae_prefs *p, int type)
     cfgfile_write (f, "parallel_postscript_detection=%s\n", p->parallel_postscript_detection ? "yes" : "no");
     cfgfile_write (f, "ghostscript_parameters=%s\n", p->ghostscript_parameters);
     cfgfile_write (f, "parallel_autoflush=%d\n", p->parallel_autoflush_time);
+    cfgfile_dwrite (f, "uae_hide=%d\n", p->uae_hide);
 
     cfgfile_dwrite (f, "gfx_display=%d\n", p->gfx_display);
     cfgfile_dwrite (f, "gfx_display_name=%s\n", p->gfx_display_name);
@@ -566,7 +567,7 @@ void cfgfile_save_options (struct zfile *f, struct uae_prefs *p, int type)
     cfgfile_dwrite (f, "gfx_filter_gamma=%d\n", p->gfx_filter_gamma);
     cfgfile_dwrite (f, "gfx_filter_blur=%d\n", p->gfx_filter_blur);
     cfgfile_dwrite (f, "gfx_filter_noise=%d\n", p->gfx_filter_noise);
-    cfgfile_dwrite (f, "gfx_filter_upscale=%s\n", p->gfx_filter_upscale ? "true" : "false");
+    cfgfile_dwrite (f, "gfx_filter_keep_aspect=%s\n", p->gfx_filter_aspect ? "true" : "false");
 
     cfgfile_dwrite (f, "gfx_luminance=%d\n", p->gfx_luminance);
     cfgfile_dwrite (f, "gfx_contrast=%d\n", p->gfx_contrast);
@@ -887,7 +888,7 @@ static int cfgfile_parse_host (struct uae_prefs *p, char *option, char *value)
        || cfgfile_intval (option, value, "gfx_filter_gamma", &p->gfx_filter_gamma, 1)
        || cfgfile_intval (option, value, "gfx_filter_blur", &p->gfx_filter_blur, 1)
        || cfgfile_intval (option, value, "gfx_filter_noise", &p->gfx_filter_noise, 1)
-       || cfgfile_yesno (option, value, "gfx_filter_upscale", &p->gfx_filter_upscale)
+       || cfgfile_yesno (option, value, "gfx_filter_keep_aspect", &p->gfx_filter_aspect)
        || cfgfile_intval (option, value, "gfx_luminance", &p->gfx_luminance, 1)
        || cfgfile_intval (option, value, "gfx_contrast", &p->gfx_contrast, 1)
        || cfgfile_intval (option, value, "gfx_gamma", &p->gfx_gamma, 1)
@@ -1362,6 +1363,7 @@ static int cfgfile_parse_hardware (struct uae_prefs *p, char *option, char *valu
        || cfgfile_intval (option, value, "floppy3type", &p->dfxtype[3], 1)
        || cfgfile_intval (option, value, "maprom", &p->maprom, 1)
        || cfgfile_intval (option, value, "parallel_autoflush", &p->parallel_autoflush_time, 1)
+       || cfgfile_intval (option, value, "uae_hide", &p->uae_hide, 1)
        || cfgfile_intval (option, value, "catweasel", &p->catweasel, 1))
        return 1;
 
@@ -2809,6 +2811,7 @@ void default_prefs (struct uae_prefs *p, int type)
     p->parallel_postscript_detection = 0;
     p->parallel_autoflush_time = 5;
     p->ghostscript_parameters[0] = 0;
+    p->uae_hide = 0;
 
     p->jports[0].id = JSEM_MICE;
     p->jports[1].id = JSEM_KBDLAYOUT;
index 759ec301d97d30a2a56ad9632e9e8761559037c9..b2af4fa589ca26d277a2b377ba18d2ef961d9634 100755 (executable)
--- a/drawing.c
+++ b/drawing.c
@@ -196,7 +196,7 @@ static int first_block_line, last_block_line;
    each line that needs to be drawn.  These are basically extracted out of
    bit fields in the hardware registers.  */
 static int bplehb, bplham, bpldualpf, bpldualpfpri, bpldualpf2of, bplplanecnt, bplres, ecsshres, issprites;
-static int plf1pri, plf2pri;
+static int plf1pri, plf2pri, bplxor;
 static uae_u32 plf_sprite_mask;
 static int sbasecol[2] = { 16, 16 };
 static int brdsprt, brdblank, brdblank_changed;
@@ -1023,9 +1023,6 @@ STATIC_INLINE void draw_sprites_2 (struct sprite_entry *e, int ham, int dualpf,
     uae_u16 *buf = spixels + e->first_pixel;
     uae_u8 *stbuf = spixstate.bytes + e->first_pixel;
     int pos, window_pos, spr_level, spr_level_max;
-#ifdef AGA
-    uae_u8 xor_val = (uae_u8)(dp_for_drawing->bplcon4 >> 8);
-#endif
 
     buf -= e->pos;
     stbuf -= e->pos;
@@ -1646,6 +1643,7 @@ static void pfield_expand_dp_bplcon (void)
     sbasecol[0] = ((dp_for_drawing->bplcon4 >> 4) & 15) << 4;
     sbasecol[1] = ((dp_for_drawing->bplcon4 >> 0) & 15) << 4;
     brdsprt = !brdblank && (currprefs.chipset_mask & CSMASK_AGA) && (dp_for_drawing->bplcon0 & 1) && (dp_for_drawing->bplcon3 & 0x02);
+    bplxor = dp_for_drawing->bplcon4 >> 8;
 #endif
 }
 
@@ -1669,7 +1667,7 @@ static void pfield_expand_dp_bplcon2 (int regno, int v)
        break;
 #endif
 #ifdef AGA
-       case 0x108:
+       case 0x10c:
        dp_for_drawing->bplcon4 = v;
        break;
 #endif
index 3051ebced630963b5a3515bc3b7486912965fd79..8415c3bd755fd2cc764a7f9ee00581a503a42484 100755 (executable)
@@ -232,7 +232,7 @@ static void enforcer_display_hit (const char *addressmode, uae_u32 pc, uaecptr a
     /* Stack */
     a7 = m68k_areg (&regs, 7);
     for (i = 0; i < 8 * STACKLINES; i++) {
-       a7 -= 4;
+       a7 += 4;
        if (!(i % 8)) {
            strcpy (enforcer_buf_ptr, "Stck:");
            enforcer_buf_ptr += strlen (enforcer_buf_ptr);
@@ -254,7 +254,7 @@ static void enforcer_display_hit (const char *addressmode, uae_u32 pc, uaecptr a
     }
 
     for (i = 0; i < 8 * STACKLINES; i++) {
-       a7 -= 4;
+       a7 += 4;
        if (enforcer_decode_hunk_and_offset (buf, get_long (a7))) {
            int l = strlen (buf);
 
index 4b3db836f287e11096027f10598e642c11843b05..0b3f5fc574b8950c55f049d6bf7ff483f8e7d0a1 100755 (executable)
@@ -27,8 +27,6 @@
 #include "ncr_scsi.h"
 #include "debug.h"
 
-static int scrambled_autoconfig = 0;
-
 #define MAX_EXPANSION_BOARDS 8
 
 /* ********************************************************** */
@@ -781,8 +779,8 @@ static void expamem_map_fastcard (void)
 
 static void expamem_init_fastcard (void)
 {
-    uae_u16 mid = currprefs.cs_a2091 ? commodore : uae_id;
-    uae_u8 pid = currprefs.cs_a2091 ? commodore_a2091_ram : 1;
+    uae_u16 mid = (currprefs.cs_a2091 || currprefs.uae_hide) ? commodore : uae_id;
+    uae_u8 pid = (currprefs.cs_a2091 || currprefs.uae_hide) ? commodore_a2091_ram : 1;
 
     expamem_init_clear ();
     if (allocated_fastmem == 0x100000)
@@ -1094,7 +1092,7 @@ static uaecptr check_boot_rom (void)
     uaecptr b = RTAREA_DEFAULT;
     addrbank *ab;
 
-    if (currprefs.cs_cdtvcd || currprefs.cs_cdtvscsi)
+    if (currprefs.cs_cdtvcd || currprefs.cs_cdtvscsi || currprefs.uae_hide > 1)
        b = RTAREA_BACKUP;
     ab = &get_mem_bank (RTAREA_DEFAULT);
     if (ab) {
@@ -1175,8 +1173,8 @@ void expamem_reset (void)
     int cardno = 0;
     ecard = 0;
 
-    if (scrambled_autoconfig)
-       uae_id = rand () & 2047 + 100;
+    if (currprefs.uae_hide)
+       uae_id = commodore;
     else
        uae_id = hackers_id;
 
index c89af7ca0bc6f44a2a9b573f96dc9ecd86da02de..69211fba9b732bac654e959a307cbb2c3e185ff9 100755 (executable)
@@ -346,7 +346,7 @@ static void out_linetoscr (DEPTH_T bpp, HMODE_T hmode, int aga, int spr)
 
     outlnf (   "    %s *buf = (%s *) xlinebuffer;", get_depth_type_str (bpp), get_depth_type_str (bpp));
     if (aga)
-       outln ( "    uae_u8 xor_val = (uae_u8)(dp_for_drawing->bplcon4 >> 8);");
+       outln ( "    uae_u8 xor_val = bplxor;");
     outln  (   "");
 
     outln  (   "    if (dp_for_drawing->ham_seen) {");
index 1cf5e7e7dd1aeced292cea5661b4a440eb5c4499..4f88b6f0e158ccc22b0bffcd5049838d5d6c9893 100755 (executable)
@@ -125,7 +125,7 @@ extern void inputdevice_reset (void);
 extern void write_inputdevice_config (struct uae_prefs *p, struct zfile *f);
 extern void read_inputdevice_config (struct uae_prefs *p, char *option, char *value);
 extern void reset_inputdevice_config (struct uae_prefs *pr);
-extern void inputdevice_joyport_config (struct uae_prefs *p, char *value, int portnum, int type);
+extern int inputdevice_joyport_config (struct uae_prefs *p, char *value, int portnum, int type);
 
 extern void inputdevice_init (void);
 extern void inputdevice_close (void);
index d1d4841d7f47f32c9d2ecead6ba451b10eeefaa9..6a567e8056e98827758da5f9cfd0ae9a95c4c93c 100755 (executable)
@@ -181,7 +181,7 @@ struct uae_prefs {
     int gfx_filter_filtermode;
     int gfx_filter_noise, gfx_filter_blur;
     int gfx_filter_saturation, gfx_filter_luminance, gfx_filter_contrast, gfx_filter_gamma;
-    int gfx_filter_upscale;
+    int gfx_filter_aspect;
 
     int immediate_blits;
     unsigned int chipset_mask;
@@ -278,6 +278,7 @@ struct uae_prefs {
     int filesys_no_uaefsdb;
     int filesys_custom_uaefsdb;
     int mmkeyboard;
+    int uae_hide;
 
     int mountitems;
     struct uaedev_config_info mountconfig[MOUNT_CONFIG_SIZE];
index ac3b014f376731482c7f1def52cc6507a161b5d9..307500d6821ea36cb32adad36dd68ea3dae4b405 100755 (executable)
@@ -455,6 +455,7 @@ extern void write_log (const char *, ...);
 #endif
 extern void write_dlog (const char *, ...);
 
+extern void flush_log (void);
 extern void close_console (void);
 extern void reopen_console (void);
 extern void console_out (const char *);
index aaed2ff7e9ef9866d5fc248758e8531a274bd426..bfa2516eca8b2b6dc971caccae1892b0f080501d 100755 (executable)
@@ -3290,7 +3290,7 @@ int jsem_iskbdjoy (int port, const struct uae_prefs *p)
     return v;
 }
 
-void inputdevice_joyport_config (struct uae_prefs *p, char *value, int portnum, int type)
+int inputdevice_joyport_config (struct uae_prefs *p, char *value, int portnum, int type)
 {
     switch (type)
     {
@@ -3312,7 +3312,7 @@ void inputdevice_joyport_config (struct uae_prefs *p, char *value, int portnum,
                    char *name2 = idf->get_uniquename (i);
                    if ((name1 && !strcmp (name1, value)) || (name2 && !strcmp (name2, value))) {
                        p->jports[portnum].id = idnum + i;
-                       return;
+                       return 1;
                    }
                }
            }
@@ -3351,9 +3351,11 @@ void inputdevice_joyport_config (struct uae_prefs *p, char *value, int portnum,
                }
                if (got == 2) {
                    p->jports[portnum].id = start;
+                   return 1;
                }
            }
        }
        break;
     }
+    return 0;
 }
\ No newline at end of file
diff --git a/main.c b/main.c
index bed2470d7554d68d7d95a477deccbe21c3f1d81b..92e8d668ec2be76e8aadebcbb943f597b685dab5 100755 (executable)
--- a/main.c
+++ b/main.c
@@ -122,9 +122,9 @@ static void fixup_prefs_dim2 (struct wh *wh)
 void fixup_prefs_dimensions (struct uae_prefs *prefs)
 {
     if (prefs->gfx_xcenter_size > 0)
-        prefs->gfx_size_win.width = prefs->gfx_xcenter_size << prefs->gfx_resolution;
+        prefs->gfx_size_win.width = prefs->gfx_xcenter_size >> (RES_MAX - prefs->gfx_resolution);
     if (prefs->gfx_ycenter_size > 0)
-        prefs->gfx_size_win.height = prefs->gfx_ycenter_size << (prefs->gfx_linedbl ? 1 : 0);
+       prefs->gfx_size_win.height = (prefs->gfx_ycenter_size * 2) >> (RES_MAX - (prefs->gfx_resolution == RES_SUPERHIRES ? 2 : (prefs->gfx_linedbl ? 1 : 0)));
     fixup_prefs_dim2 (&prefs->gfx_size_fs);
     fixup_prefs_dim2 (&prefs->gfx_size_win);
 }
index 9ed8a0b0f76ce52d1e075474f05b747d9ce89b7f..2b3b681e4c4619e0313e26d801d5a07f65387557 100755 (executable)
--- a/memory.c
+++ b/memory.c
@@ -2260,7 +2260,7 @@ void a3000_fakekick (int map)
                memcpy (kickmemory, fkickmemory, fkickmem_size / 2);
                memcpy (kickmemory + fkickmem_size / 2, fkickmemory, fkickmem_size / 2);
                if (!extendedkickmemory) {
-                   if (need_uae_boot_rom() != 0xf00000) {
+                   if (need_uae_boot_rom () != 0xf00000) {
                        extendedkickmem_size = 65536;
                        extendedkickmem_mask = extendedkickmem_size - 1;
                        extendedkickmemory = mapped_malloc (extendedkickmem_size, "rom_f0");
index 82f4c214f1ca15cc1855eba6bd720304556ca6f9..f49c3a237d5f946193156cea40509df666dac436 100755 (executable)
@@ -230,9 +230,10 @@ static int total_devices;
 
 static void close_scsi_device (int unitnum)
 {
-    write_log ("SPTI: unit %d closed\n", unitnum);
-    if (dev_info[unitnum].handle != INVALID_HANDLE_VALUE)
+    if (dev_info[unitnum].handle != INVALID_HANDLE_VALUE) {
+       write_log ("SPTI: unit %d closed\n", unitnum);
        CloseHandle (dev_info[unitnum].handle);
+    }
     dev_info[unitnum].handle = INVALID_HANDLE_VALUE;
 }
 
@@ -272,6 +273,24 @@ static void close_scsi_bus (void)
        free_scsi_device(i);
 }
 
+static void checkcapabilities (int unitnum)
+{
+    struct dev_info_spti *di = &dev_info[unitnum];
+    STORAGE_ADAPTER_DESCRIPTOR desc;
+    STORAGE_PROPERTY_QUERY query = { 0 };
+    DWORD ret, status;
+
+    query.PropertyId = StorageAdapterProperty;
+    query.QueryType = PropertyStandardQuery;
+    status = DeviceIoControl (di->handle, IOCTL_STORAGE_QUERY_PROPERTY,
+       &query, sizeof query, &desc, sizeof desc, &ret, NULL);
+    if (status) {
+       if (desc.Version > offsetof (STORAGE_ADAPTER_DESCRIPTOR, BusType))
+           write_log ("CAPS: BusType=%d, MaxTransfer=0x%08X, Mask=0x%08X\n",
+               desc.BusType, desc.MaximumTransferLength, desc.AlignmentMask);
+    }
+}
+
 static int inquiry (int unitnum, struct dev_info_spti *di, uae_u8 *inquirydata)
 {
     uae_u8 cmd[6] = { 0x12,0,0,0,36,0 }; /* INQUIRY */
@@ -328,7 +347,7 @@ static int mediacheck_full (int unitnum, struct device_info *di)
     if (dev_info[unitnum].handle == INVALID_HANDLE_VALUE)
        return 0;
     outlen = 32;
-    p = execscsicmd_in(unitnum, cmd1, sizeof cmd1, &outlen);
+    p = execscsicmd_in (unitnum, cmd1, sizeof cmd1, &outlen);
     if (p && outlen >= 8) {
        di->bytespersector = (p[4] << 24) | (p[5] << 16) | (p[6] << 8) | p[7];
         di->sectorspertrack = (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3];
@@ -338,7 +357,7 @@ static int mediacheck_full (int unitnum, struct device_info *di)
     if (di->type == INQ_DASD) {
        uae_u8 cmd2[10] = { 0x5a,0x08,0,0,0,0,0,0,0xf0,0 }; /* MODE SENSE */
        outlen = 32;
-       p = execscsicmd_in(unitnum, cmd2, sizeof cmd2, &outlen);
+       p = execscsicmd_in (unitnum, cmd2, sizeof cmd2, &outlen);
        if (p && outlen >= 4) {
            di->write_protected = (p[3] & 0x80) ? 1 : 0;
        }
@@ -371,6 +390,7 @@ int open_scsi_device (int unitnum)
        write_log ("SPTI: failed to open unit %d err=%d ('%s')\n", unitnum, GetLastError(), dev);
     } else {
        uae_u8 inqdata[INQUIRY_SIZE + 1] = { 0 };
+       checkcapabilities (unitnum);
        if (!inquiry (unitnum, di, inqdata)) {
            write_log ("SPTI: inquiry failed unit %d ('%s':%d:%d:%d:%d)\n", unitnum, dev,
                di->bus, di->path, di->target, di->lun);
@@ -421,7 +441,7 @@ static int adddrive (char *drvpath, int bus, int pathid, int targetid, int lunid
     di->lun = lunid;
     di->scanmode = scanmode;
     total_devices++;
-    if (open_scsi_device(cnt)) {
+    if (open_scsi_device (cnt)) {
        for (i = 0; i < cnt; i++) {
            if (!memcmp(di->inquirydata, dev_info[i].inquirydata, INQUIRY_SIZE) && di->scanmode != dev_info[i].scanmode) {
                write_log ("duplicate device, skipped..\n");
index 98a6810a21865e4fe3eb004382056c997bc08e2a..d2290d155606ddf39e0e79f2ed028a5eaa749d80 100755 (executable)
@@ -93,6 +93,7 @@
 #define RP_SCREENMODE_FULLSCREEN_1     0x00000100 // full screen on primary (default) display
 #define RP_SCREENMODE_FULLSCREEN_2     0x00000200 // full screen on secondary display (fallback to 1 if unavailable)
 #define RP_SCREENMODE_FULLWINDOW       0x00010000 // use "full window" when in fullscreen (no gfx card full screen)
+#define RP_SCREENMODE_XX            0x000000FF
 #define RP_SCREENMODE_MODE(m)       ((m) & 0x000000FF) // given a mode 'm' returns the #X mode
 #define RP_SCREENMODE_DISPLAY(m)    (((m) >> 8) & 0x000000FF) // given a mode 'm' returns the display number (1-255) or 0 if full screen is not active
 
index bec41a82c3bd9cf46b49417d3cc3551b2f3800ff..c63fa5afaa84033c8d28e83f52991f74f2fa3af4 100755 (executable)
@@ -49,6 +49,20 @@ static void freemainsurface (void)
     dxdata.backbuffers = 0;
 }
 
+static HRESULT restoresurface_2 (LPDIRECTDRAWSURFACE7 surf)
+{
+    HRESULT ddrval;
+    
+    if (surf == dxdata.flipping[0] || surf == dxdata.flipping[1])
+       surf = dxdata.primary;
+    ddrval = IDirectDrawSurface7_Restore (surf);
+    if (SUCCEEDED (ddrval)) {
+       if (surf == dxdata.primary && dxdata.palette)
+           IDirectDrawSurface7_SetPalette (dxdata.primary, dxdata.palette);
+    }
+    return ddrval;
+}
+
 HRESULT restoresurface (LPDIRECTDRAWSURFACE7 surf)
 {
     HRESULT ddrval;
@@ -56,10 +70,12 @@ HRESULT restoresurface (LPDIRECTDRAWSURFACE7 surf)
     if (surf == dxdata.flipping[0] || surf == dxdata.flipping[1])
        surf = dxdata.primary;
     ddrval = IDirectDrawSurface7_Restore (surf);
-    if (FAILED (ddrval))
+    if (FAILED (ddrval)) {
        write_log ("IDirectDrawSurface7_Restore: %s\n", DXError (ddrval));
-    if (surf == dxdata.primary && dxdata.palette)
-       IDirectDrawSurface7_SetPalette (dxdata.primary, dxdata.palette);
+    } else {
+       if (surf == dxdata.primary && dxdata.palette)
+           IDirectDrawSurface7_SetPalette (dxdata.primary, dxdata.palette);
+    }
     return ddrval;
 }
 
@@ -98,7 +114,7 @@ int locksurface (LPDIRECTDRAWSURFACE7 surf, LPDDSURFACEDESC2 desc)
     desc->dwSize = sizeof (*desc);
     while (FAILED (ddrval = IDirectDrawSurface7_Lock (surf, NULL, desc, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL))) {
        if (ddrval == DDERR_SURFACELOST) {
-           ddrval = restoresurface (surf);
+           ddrval = restoresurface_2 (surf);
            if (FAILED (ddrval))
                return 0;
        } else if (ddrval != DDERR_SURFACEBUSY) {
@@ -269,15 +285,21 @@ HRESULT DirectDraw_SetDisplayMode (int width, int height, int bits, int freq)
     return ddrval;
 }
 
-HRESULT DirectDraw_SetCooperativeLevel (HWND window, int fullscreen)
+HRESULT DirectDraw_SetCooperativeLevel (HWND window, int fullscreen, int doset)
 {
     HRESULT ddrval;
     
-    dxdata.hwnd = window;
-    ddrval = IDirectDraw7_SetCooperativeLevel (dxdata.maindd, window, fullscreen ?
-       DDSCL_ALLOWREBOOT | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN : DDSCL_NORMAL);
-    if (FAILED (ddrval))
-       write_log ("IDirectDraw7_SetCooperativeLevel: %s\n", DXError (ddrval));
+    if (doset) {
+       dxdata.hwnd = window;
+       ddrval = IDirectDraw7_SetCooperativeLevel (dxdata.maindd, window, fullscreen ?
+           DDSCL_ALLOWREBOOT | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN : DDSCL_NORMAL);
+       if (FAILED (ddrval))
+           write_log ("IDirectDraw7_SetCooperativeLevel: SET %s\n", DXError (ddrval));
+    } else {
+        ddrval = IDirectDraw7_SetCooperativeLevel (dxdata.maindd, dxdata.hwnd, DDSCL_NORMAL);
+       if (FAILED (ddrval))
+           write_log ("IDirectDraw7_SetCooperativeLevel: RESET %s\n", DXError (ddrval));
+    }
     return ddrval;
 }
 
index 950d012d82e3a0af6763ede6a42213dcb9fe60b0..c6458916c621efbefb1577b89fd092cdbff127e0 100755 (executable)
@@ -82,7 +82,7 @@ void freesurface (LPDIRECTDRAWSURFACE7 surf);
 void DirectDraw_FreeMainSurface (void);
 HRESULT DirectDraw_CreateMainSurface (int width, int height);
 HRESULT DirectDraw_SetDisplayMode(int width, int height, int bits, int freq);
-HRESULT DirectDraw_SetCooperativeLevel (HWND window, int fullscreen);
+HRESULT DirectDraw_SetCooperativeLevel (HWND window, int fullscreen, int doset);
 HRESULT DirectDraw_CreateClipper (void);
 HRESULT DirectDraw_SetClipper(HWND hWnd);
 RGBFTYPE DirectDraw_GetSurfacePixelFormat(LPDDSURFACEDESC2 surface);
index 271acea587dab8d6be6388f5d52a100468b1c739..975bb9ffdefee1c83a579038b4497f8d70e4563e 100755 (executable)
@@ -1254,7 +1254,7 @@ static void hmc_check (struct hardfiledata *hfd, struct uaedev_config_info *uci,
 {
     int ret;
 
-    if (!hfd->emptyname)
+    if (!hfd || !hfd->emptyname)
        return;
     if (*rescanned == 0) {
        hdf_init2 (1);
index a36fbbd4026cd52a7e12ed9e615760d25d3b7353..60dae73902c50f30b4dbf622975346458a4b0bbd 100755 (executable)
 #define IDC_AVIOUTPUT_8BIT              1620
 #define IDC_INPREC_PLAY                 1620
 #define IDC_FILTERUPSCALE               1620
+#define IDC_FILTERASPECT                1620
 #define IDC_AVIOUTPUT_24BIT             1621
 #define IDC_AVIOUTPUT_WIDTH             1622
 #define IDC_AVIOUTPUT_HEIGHT            1623
index a36fbbd4026cd52a7e12ed9e615760d25d3b7353..268585c9075681ede080746dd4d5740b0640d036 100755 (executable)
 #define IDC_FILTERVO                    1619
 #define IDC_AVIOUTPUT_8BIT              1620
 #define IDC_INPREC_PLAY                 1620
-#define IDC_FILTERUPSCALE               1620
+#define IDC_FILTERASPECT                1620
 #define IDC_AVIOUTPUT_24BIT             1621
 #define IDC_AVIOUTPUT_WIDTH             1622
 #define IDC_AVIOUTPUT_HEIGHT            1623
index 4bf0fb5129fe21f28623d000fc1d41637ef16499..5fbab4395d73840a02c5a2dd7ce4541181857c22 100755 (executable)
@@ -697,7 +697,7 @@ BEGIN
     COMBOBOX        IDC_FILTERVZMULT,67,63,27,150,CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP\r
     CONTROL         "Autoscale",IDC_FILTERAUTORES,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_GROUP | WS_TABSTOP,9,168,63,10\r
     COMBOBOX        IDC_FILTERXTRA,105,130,138,150,CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP\r
-    CONTROL         "Full screen filter",IDC_FILTERUPSCALE,"Button",BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_TABSTOP,9,153,87,10\r
+    CONTROL         "Keep aspect ratio",IDC_FILTERASPECT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,9,153,87,10\r
 END\r
 \r
 IDD_HARDDRIVE DIALOGEX 0, 0, 380, 76\r
index 424c8306ac0a194bbbf829cb259dd9e60ef91865..934f14b17c787437ca2909f5bf6d48756c959fd8 100755 (executable)
@@ -25,6 +25,7 @@
 #include "win32.h"
 #include "win32gfx.h"
 #include "filesys.h"
+#include "gfxfilter.h"
 
 static int initialized;
 static RPGUESTINFO guestinfo;
@@ -41,8 +42,16 @@ static int hwndset;
 static int minimized;
 static DWORD hd_mask, cd_mask;
 static int mousecapture, mousemagic;
+static int rp_filter, rp_filter_default;
 
-static int recursive_device;
+static int recursive_device, recursive;
+
+static int cando (void)
+{
+    if (!initialized)
+       return 0;
+    return 1;
+}
 
 static void outhex (const uae_u8 *s)
 {
@@ -115,22 +124,23 @@ static const char *getmsg (int msg)
     }
 }
 
-static int port_insert (int num, const char *name)
+static void trimws (char *s)
+{
+    /* Delete trailing whitespace.  */
+    int len = strlen (s);
+    while (len > 0 && strcspn (s + len - 1, "\t \r\n") == 0)
+        s[--len] = '\0';
+}
+
+static int port_insert2 (int num, const char *name)
 {
-    char tmp1[100], tmp2[200];
+    char tmp2[1000];
     int i, type;
 
-    if (num < 0 || num > 1)
-       return FALSE;
-    if (strlen (name) == 0) {
-       inputdevice_joyport_config (&changed_prefs, "none", num, 0);
-       return TRUE;
-    }
-    if (strlen (name) >= sizeof (tmp2) - 1)
-       return FALSE;
     type = 1;
     strcpy (tmp2, name);
     for (i = 1; i <= 4; i++) {
+       char tmp1[1000];
        sprintf (tmp1, "Mouse%d", i);
        if (!strcmp (name, tmp1)) {
            sprintf (tmp2, "mouse%d", i - 1);
@@ -150,15 +160,44 @@ static int port_insert (int num, const char *name)
            break;
        }
     }
-    inputdevice_joyport_config (&changed_prefs, tmp2, num, type);
-    return TRUE;
+    trimws (tmp2);
+    return inputdevice_joyport_config (&changed_prefs, tmp2, num, type);
+}
+
+static int port_insert (int num, const char *name)
+{
+    char tmp1[1000];
+
+    if (num < 0 || num > 1)
+       return FALSE;
+    if (strlen (name) == 0) {
+       inputdevice_joyport_config (&changed_prefs, "none", num, 0);
+       return TRUE;
+    }
+    if (strlen (name) >= sizeof (tmp1) - 1)
+       return FALSE;
+
+    strcpy (tmp1, name);
+    for (;;) {
+       char *p = strrchr (tmp1, '\\');
+       if (p) {
+           int v = port_insert2 (num, p + 1);
+           if (v)
+               return TRUE;
+           *p = 0;
+           continue;
+       }
+       return port_insert2 (num, tmp1);
+    }
 }
 
 static BOOL RPSendMessagex (UINT uMessage, WPARAM wParam, LPARAM lParam,
                    LPCVOID pData, DWORD dwDataSize, const RPGUESTINFO *pInfo, LRESULT *plResult)
 {
-    BOOL v;
-    
+    BOOL v = FALSE;
+    static int cnt;
+    int ncnt;
+
     if (!pInfo) {
        write_log ("RPSEND: pInfo == NULL!\n");
         return FALSE;
@@ -167,9 +206,15 @@ static BOOL RPSendMessagex (UINT uMessage, WPARAM wParam, LPARAM lParam,
        write_log ("RPSEND: pInfo->hHostMessageWindow == NULL!\n");
         return FALSE;
     }
+    recursive++;
+    cnt++;
+    ncnt = cnt;
+    if (log_rp)
+       write_log ("RPSEND_%d->\n", ncnt);
     v = RPSendMessage (uMessage, wParam, lParam, pData, dwDataSize, pInfo, plResult);
+    recursive--;
     if (log_rp) {
-       write_log ("RPSEND(%s [%d], %08x, %08x, %08x, %d)\n",
+       write_log ("RPSEND_%d(%s [%d], %08x, %08x, %08x, %d)\n", ncnt,
            getmsg (uMessage), uMessage - WM_APP, wParam, lParam, pData, dwDataSize);
        if (v == FALSE)
            write_log("ERROR %d\n", GetLastError ());
@@ -188,79 +233,155 @@ static int winok(void)
 
 #define LORES_WIDTH 360
 #define LORES_HEIGHT 284
-static void get_screenmode (struct RPScreenMode *sm)
+static void get_screenmode (struct RPScreenMode *sm, struct uae_prefs *p)
 {
-    int res = currprefs.gfx_resolution;
+    int res = p->gfx_resolution;
     int m = RP_SCREENMODE_1X;
     int full = 0;
     int dbl = 0;
 
     if (WIN32GFX_IsPicassoScreen ()) {
-       full = currprefs.gfx_pfullscreen;
+       full = p->gfx_pfullscreen;
        sm->lClipTop = 0;
        sm->lClipLeft = 0;
        sm->lClipHeight = picasso96_state.Height;
        sm->lClipWidth = picasso96_state.Width;
     } else {
-       full = currprefs.gfx_afullscreen;
-       if (res == 1)
+       full = p->gfx_afullscreen;
+       dbl = res >= 1 ? 1 : 0;
+       if (res == RES_HIRES)
            m = RP_SCREENMODE_2X;
-       if (res == 2)
+       if (res == RES_SUPERHIRES) {
            m = RP_SCREENMODE_4X;
-       dbl = res >= 1 ? 1 : 0;
-       sm->lClipLeft = currprefs.gfx_xcenter_pos;
-       sm->lClipTop = currprefs.gfx_ycenter_pos;
+           dbl = 2;
+       }
+       if (log_rp)
+           write_log ("GET_RPSM: res=%d dbl=%d full=%d xcpos=%d ycpos=%d w=%d h=%d\n",
+               res, dbl, full,
+               p->gfx_xcenter_pos,  p->gfx_ycenter_pos,
+               p->gfx_size_win.width, p->gfx_size_win.height);
+       sm->lClipLeft = p->gfx_xcenter_pos <= 0 ? -1 : p->gfx_xcenter_pos;
+       sm->lClipTop = p->gfx_ycenter_pos <= 0 ? -1 : p->gfx_ycenter_pos;
        if (full) {
-           sm->lClipWidth = LORES_WIDTH << currprefs.gfx_resolution;
-           sm->lClipHeight = LORES_HEIGHT << (currprefs.gfx_linedbl ? 1 : 0);
+           sm->lClipWidth = LORES_WIDTH << RES_MAX;
+           sm->lClipHeight = LORES_HEIGHT << dbl;
        } else {
-           sm->lClipWidth = currprefs.gfx_size_win.width << (RES_MAX - res);
-           sm->lClipHeight = currprefs.gfx_size_win.height << (1 - dbl);
+           sm->lClipWidth = p->gfx_size_win.width << (RES_MAX - res);
+           sm->lClipHeight = (p->gfx_size_win.height * 2) >> (2 - dbl);
        }
     }
     if (full) {
-       int d = (currprefs.gfx_display + 1) << 8;
        m &= ~0x0000ff00;
-       m |= d;
+       m |= p->gfx_display << 8;
     }
+    if (full > 1)
+       m |= RP_SCREENMODE_FULLWINDOW;
     sm->dwScreenMode = m;
+
+    if (log_rp)
+       write_log ("GET_RPSM: %08X %dx%d %dx%d res=%d disp=%d fs=%d\n",
+           sm->dwScreenMode, sm->lClipLeft, sm->lClipTop, sm->lClipWidth, sm->lClipHeight,
+           res, p->gfx_display, full);
 }
 
-static void set_screenmode (struct RPScreenMode *sm)
+static void set_screenmode (struct RPScreenMode *sm, struct uae_prefs *p)
 {
     int res = RP_SCREENMODE_MODE (sm->dwScreenMode);
-    int fs = RP_SCREENMODE_DISPLAY (sm->dwScreenMode);
+    int display = RP_SCREENMODE_DISPLAY (sm->dwScreenMode);
+    int fs = 0;
     int dbl = 1;
+    struct MultiDisplay *disp;
 
     minimized = 0;
-    if (fs)
-       changed_prefs.gfx_display = fs - 1;
-    if (WIN32GFX_IsPicassoScreen ()) {
-       changed_prefs.gfx_pfullscreen = fs;
-    } else {
-       changed_prefs.gfx_afullscreen = fs;
-       changed_prefs.gfx_resolution = res;
-       if (res == 0)
-           dbl = changed_prefs.gfx_linedbl = 0;
+    if (display) {
+       p->gfx_display = display;
+       if (sm->dwScreenMode & RP_SCREENMODE_FULLWINDOW)
+           fs = 2;
        else
-           dbl = changed_prefs.gfx_linedbl = 1;
+           fs = 1;
+       if (res > RP_SCREENMODE_2X)
+           res = RP_SCREENMODE_2X;
+    }
+    disp = getdisplay (p);
+
+    if (log_rp)
+       write_log ("SET_RPSM: %08X %dx%d %dx%d res=%d disp=%d fs=%d\n",
+           sm->dwScreenMode, sm->lClipLeft, sm->lClipTop, sm->lClipWidth, sm->lClipHeight,
+           res, display, fs);
+
+    if (!WIN32GFX_IsPicassoScreen ()) {
+       p->gfx_resolution = res == RP_SCREENMODE_4X ? RES_SUPERHIRES : res;
+       if (res == 0) {
+           dbl = dbl = p->gfx_linedbl = 0;
+       } else {
+           dbl = p->gfx_linedbl = 1;
+           if (res == RP_SCREENMODE_4X)
+               dbl = 2;
+       }
        if (sm->lClipWidth <= 0)
-           changed_prefs.gfx_size_win.width = LORES_WIDTH << res;
+           p->gfx_size_win.width = LORES_WIDTH << p->gfx_resolution;
        else
-           changed_prefs.gfx_size_win.width = sm->lClipWidth >> (RES_MAX - res);
+           p->gfx_size_win.width = sm->lClipWidth >> (RES_MAX - p->gfx_resolution);
        if (sm->lClipHeight <= 0)
-           changed_prefs.gfx_size_win.height = LORES_HEIGHT << dbl;
+           p->gfx_size_win.height = LORES_HEIGHT << dbl;
        else
-           changed_prefs.gfx_size_win.height = sm->lClipHeight >> (1 - dbl);
+           p->gfx_size_win.height = (sm->lClipHeight * 2) >> (2 - dbl);
+       if (fs == 1) {
+           p->gfx_size_fs.width = p->gfx_size_win.width;
+           p->gfx_size_fs.height = p->gfx_size_win.height;
+       } else if (fs == 2) {
+           p->gfx_size_fs.width = disp->rect.right - disp->rect.left;
+           p->gfx_size_fs.height = disp->rect.bottom - disp->rect.top;
+       }
+       p->gfx_filter = rp_filter_default;
+       p->gfx_filter_horiz_zoom_mult = 1000;
+       p->gfx_filter_vert_zoom_mult = 1000;
+       if (log_rp)
+           write_log ("WW=%d WH=%d FW=%d FH=%d\n",
+               p->gfx_size_win.width, p->gfx_size_win.height,
+               p->gfx_size_fs.width, p->gfx_size_fs.height);
        if (fs) {
-           changed_prefs.gfx_size_fs.width = changed_prefs.gfx_size_win.width;
-           changed_prefs.gfx_size_fs.height = changed_prefs.gfx_size_win.height;
+           if (res == RP_SCREENMODE_XX) {
+               p->gfx_filter_horiz_zoom_mult = 0;
+               p->gfx_filter_vert_zoom_mult = 0;
+               p->gfx_filter = rp_filter;
+           } else {
+               int mult;
+               int prevmult = 1;
+               for (mult = 2; mult <= 4; mult+=2) {
+                   int w = p->gfx_size_win.width;
+                   int h = p->gfx_size_win.height;
+                   if (p->gfx_size_fs.width < w * mult || p->gfx_size_fs.height < h * mult) {
+                       mult = prevmult;
+                       break;
+                   }
+                   prevmult = mult;
+               }
+               if (mult > 1 || fs == 2) {
+                   p->gfx_filter = rp_filter;
+                   p->gfx_filter_horiz_zoom_mult = 1000 / mult;
+                   p->gfx_filter_vert_zoom_mult = 1000 / mult;
+               }
+           }
+       } else {
+           if (res == RP_SCREENMODE_4X) {
+               p->gfx_filter = rp_filter;
+               p->gfx_filter_horiz_zoom_mult = 1000;
+               p->gfx_filter_vert_zoom_mult = 500;
+           }
        }
+
     }
-    changed_prefs.gfx_xcenter_pos = sm->lClipLeft;
-    changed_prefs.gfx_ycenter_pos = sm->lClipTop;
-    updatewinfsmode (&changed_prefs);
-    WIN32GFX_DisplayChangeRequested ();
+#if 0
+    p->gfx_filter = UAE_FILTER_NULL;
+    p->gfx_filter_horiz_zoom_mult = 1000;
+    p->gfx_filter_vert_zoom_mult = 1000;
+#endif
+    p->gfx_pfullscreen = fs;
+    p->gfx_afullscreen = fs;
+    p->gfx_xcenter_pos = sm->lClipLeft;
+    p->gfx_ycenter_pos = sm->lClipTop;
+    updatewinfsmode (p);
     hwndset = 0;
 }
 
@@ -334,7 +455,7 @@ static LRESULT CALLBACK RPHostMsgFunction2 (UINT uMessage, WPARAM wParam, LPARAM
        case RPIPCHM_SCREENMODE:
        {
            struct RPScreenMode *sm = (struct RPScreenMode*)pData;
-           set_screenmode (sm);
+           set_screenmode (sm, &changed_prefs);
            return (LRESULT)INVALID_HANDLE_VALUE;
        }
        case RPIPCHM_EVENT:
@@ -398,8 +519,10 @@ HRESULT rp_init (void)
 
 void rp_free (void)
 {
-    if (!initialized)
+    if (!cando ())
        return;
+    if (hwndset)
+       rp_set_hwnd (NULL);
     initialized = 0;
     RPSendMessagex (RPIPCGM_CLOSED, 0, 0, NULL, 0, &guestinfo, NULL);
     RPUninitializeGuest (&guestinfo);
@@ -409,7 +532,7 @@ HWND rp_getparent (void)
 {
     LRESULT lr;
     if (!initialized)
-       return 0;
+       return NULL;
     RPSendMessagex (RPIPCGM_PARENT, 0, 0, NULL, 0, &guestinfo, &lr);
     return (HWND)lr;
 }
@@ -421,19 +544,30 @@ static void sendfeatures (void)
     feat = RP_FEATURE_POWERLED | RP_FEATURE_SCREEN1X | RP_FEATURE_FULLSCREEN;
     feat |= RP_FEATURE_PAUSE | RP_FEATURE_TURBO | RP_FEATURE_VOLUME | RP_FEATURE_SCREENCAPTURE;
     if (!WIN32GFX_IsPicassoScreen ())
-       feat |= RP_FEATURE_SCREEN2X;
+       feat |= RP_FEATURE_SCREEN2X | RP_FEATURE_SCREEN4X;
     RPSendMessagex (RPIPCGM_FEATURES, feat, 0, NULL, 0, &guestinfo, NULL);
 }
 
 void rp_fixup_options (struct uae_prefs *p)
 {
     int i, v;
+    struct RPScreenMode sm;
 
     if (!initialized)
        return;
-    write_log ("rp_fixup_options(rpescapekey=%d,rpescapeholdtime=%d,screenmode=%d,inputmode=%d)\n",
+    write_log ("rp_fixup_options(escapekey=%d,escapeholdtime=%d,screenmode=%d,inputmode=%d)\n",
        rp_rpescapekey, rp_rpescapeholdtime, rp_screenmode, rp_inputmode);
 
+    changed_prefs.win32_borderless = currprefs.win32_borderless = 1;
+    rp_filter_default = rp_filter = currprefs.gfx_filter;
+    if (rp_filter == 0)
+       rp_filter = UAE_FILTER_NULL;
+
+    get_screenmode (&sm, p);
+    sm.dwScreenMode = rp_screenmode;
+    set_screenmode (&sm, &currprefs);
+    set_screenmode (&sm, &changed_prefs);
+
     sendfeatures ();
 
     /* floppy drives */
@@ -458,6 +592,11 @@ void rp_fixup_options (struct uae_prefs *p)
        }
     }
     RPSendMessagex (RPIPCGM_DEVICES, RP_DEVICE_HD, hd_mask, NULL, 0, &guestinfo, NULL);
+
+    rp_update_volume (&currprefs);
+    rp_turbo (turbo_emulation);
+    for (i = 0; i <= 4; i++)
+       rp_update_leds (i, 0);
 }
 
 static void rp_device_change (int dev, int num, const char *name)
@@ -466,7 +605,7 @@ static void rp_device_change (int dev, int num, const char *name)
     int dc_size;
     char np[MAX_DPATH];
 
-    if (!initialized)
+    if (!cando ())
        return;
     if (recursive_device)
        return;
@@ -493,6 +632,8 @@ void rp_input_change (int num, const char *name)
 
 void rp_hd_change (int num, int removed)
 {
+    if (!cando ())
+       return;
     if (removed)
        hd_mask &= ~(1 << num);
     else
@@ -502,6 +643,8 @@ void rp_hd_change (int num, int removed)
 
 void rp_cd_change (int num, int removed)
 {
+    if (!cando ())
+       return;
     if (removed)
        cd_mask &= ~(1 << num);
     else
@@ -511,14 +654,14 @@ void rp_cd_change (int num, int removed)
 
 void rp_floppy_track (int floppy, int track)
 {
-    if (!initialized)
+    if (!cando ())
        return;
     RPSendMessagex (RPIPCGM_DEVICESEEK, MAKEWORD (RP_DEVICE_FLOPPY, floppy), track, NULL, 0, &guestinfo, NULL);
 }
 
 void rp_update_leds (int led, int onoff)
 {
-    if (!initialized)
+    if (!cando ())
        return;
     if (led < 0 || led > 4)
        return;
@@ -538,7 +681,7 @@ void rp_update_leds (int led, int onoff)
 
 void rp_hd_activity (int num, int onoff)
 {
-    if (!initialized)
+    if (!cando ())
        return;
     if (num < 0)
        return;
@@ -548,7 +691,7 @@ void rp_hd_activity (int num, int onoff)
 
 void rp_cd_activity (int num, int onoff)
 {
-    if (!initialized)
+    if (!cando ())
        return;
     if (num < 0)
        return;
@@ -561,9 +704,9 @@ void rp_cd_activity (int num, int onoff)
     }
 }
 
-void rp_update_status (struct uae_prefs *p)
+void rp_update_volume (struct uae_prefs *p)
 {
-    if (!initialized)
+    if (!cando ())
        return;
     RPSendMessagex (RPIPCGM_VOLUME, (WPARAM)(100 - p->sound_volume), 0, NULL, 0, &guestinfo, NULL);
 }
@@ -572,7 +715,7 @@ static void rp_mouse (void)
 {
     int flags = 0;
 
-    if (!initialized)
+    if (!cando ())
        return;
     if (mousemagic)
        flags |= RP_MOUSECAPTURE_MAGICMOUSE;
@@ -595,23 +738,14 @@ void rp_mouse_magic (int magic)
 
 void rp_activate (int active, LPARAM lParam)
 {
-    if (!initialized)
+    if (!cando ())
        return;
     RPSendMessagex (active ? RPIPCGM_ACTIVATED : RPIPCGM_DEACTIVATED, 0, lParam, NULL, 0, &guestinfo, NULL);
 }
 
-#if 0
-void rp_minimize (int minimize)
-{
-    if (!initialized)
-       return;
-    RPSendMessagex(minimize ? RPIPCGM_MINIMIZED : RPIPCGM_RESTORED, 0, 0, NULL, 0, &guestinfo, NULL);
-}
-#endif
-
 void rp_turbo (int active)
 {
-    if (!initialized)
+    if (!cando ())
        return;
     RPSendMessagex (RPIPCGM_TURBO, RP_TURBO_CPU, active, NULL, 0, &guestinfo, NULL);
 }
@@ -622,22 +756,23 @@ void rp_set_hwnd (HWND hWnd)
 
     if (!initialized)
        return;
-    get_screenmode (&sm);
+    get_screenmode (&sm, &currprefs);
     sm.hGuestWindow = hWnd;
-    hwndset = 1;
+    if (hWnd != NULL)
+       hwndset = 1;
     RPSendMessagex (RPIPCGM_SCREENMODE, 0, 0, &sm, sizeof sm, &guestinfo, NULL); 
 }
 
 void rp_set_enabledisable (int enabled)
 {
-    if (!initialized)
+    if (!cando ())
        return;
     RPSendMessagex (enabled ? RPIPCGM_ENABLED : RPIPCGM_DISABLED, 0, 0, NULL, 0, &guestinfo, NULL);
 }
 
 void rp_rtg_switch (void)
 {
-    if (!initialized)
+    if (!cando ())
        return;
     sendfeatures ();
 }
index 056f780fcdf021e1f520c78b6838d0a2b4064dbf..94e3a93d86262f3d863538ab779ce1b822d2c265 100755 (executable)
@@ -2,7 +2,7 @@
 extern HRESULT rp_init (void);
 extern void rp_free (void);
 extern void rp_fixup_options (struct uae_prefs*);
-extern void rp_update_status (struct uae_prefs*);
+extern void rp_update_volume (struct uae_prefs*);
 extern void rp_update_leds (int, int);
 extern void rp_floppy_track (int floppy, int track);
 extern void rp_hd_activity (int, int);
index 5dab085cab1ee909068a32cd617f44696ec3f28f..595535d6f213e4b2f9f851e5b99f24d66c317ad3 100755 (executable)
@@ -363,7 +363,7 @@ void setmouseactive (int active)
            }
        }
 #ifdef RETROPLATFORM
-       if (rp_isactive ())
+       if (rp_isactive () && isfullscreen () == 0)
            donotfocus = 0;
 #endif
        if (donotfocus) {
@@ -1176,6 +1176,7 @@ void handle_events (void)
     cnt--;
     if (cnt <= 0) {
        figure_processor_speed ();
+       flush_log ();
        cnt = 100;
     }
 }
index 45466e4267fdb6bb4a72f9f8cce4f96d997e0975..fe9ff2cd20066a0ebd4ce7cd72ab2f6867a6df14 100755 (executable)
@@ -15,9 +15,9 @@
 #define GETBDM(x) (((x) - ((x / 10000) * 10000)) / 100)
 #define GETBDD(x) ((x) % 100)
 
-#define WINUAEBETA 12
+#define WINUAEBETA 13
 #define WINUAEPUBLICBETA 1
-#define WINUAEDATE MAKEBD(2008, 4, 5)
+#define WINUAEDATE MAKEBD(2008, 4, 20)
 #define WINUAEEXTRA ""
 #define WINUAEREV ""
 
index bb705f58581d2eb3d74586c76f8f4568036966d4..54bc8c20a0671c9033465705287f32d9f38fab14 100755 (executable)
@@ -24,7 +24,7 @@ struct uae_filter uaefilters[] =
 
     { UAE_FILTER_SCALE2X, 0, "Scale2X", "scale2x", 0, 0, UAE_FILTER_MODE_16_16 | UAE_FILTER_MODE_32_32, 0, 0 },
 
-    { UAE_FILTER_HQ, 0, "hq2x", "hqx", 0, 0, UAE_FILTER_MODE_16_16 | UAE_FILTER_MODE_16_32, UAE_FILTER_MODE_16_16 | UAE_FILTER_MODE_16_32, UAE_FILTER_MODE_16_16 | UAE_FILTER_MODE_16_32 },
+    { UAE_FILTER_HQ, 0, "hq2x/3x/4x", "hqx", 0, 0, UAE_FILTER_MODE_16_16 | UAE_FILTER_MODE_16_32, UAE_FILTER_MODE_16_16 | UAE_FILTER_MODE_16_32, UAE_FILTER_MODE_16_16 | UAE_FILTER_MODE_16_32 },
 
     { UAE_FILTER_SUPEREAGLE, 0, "SuperEagle", "supereagle", 0, 0, UAE_FILTER_MODE_16_16, 0, 0 },
 
@@ -83,7 +83,13 @@ void getfilterrect2 (RECT *sr, RECT *dr, int dst_width, int dst_height, int aw,
         ymult = ahs * 1000 / dst_height;
     else
         ymult = ymult + ymult * currprefs.gfx_filter_vert_zoom / 2000;
-    
+
+    if (currprefs.gfx_filter_horiz_zoom_mult <= 0 && currprefs.gfx_filter_vert_zoom_mult <= 0 && currprefs.gfx_filter_aspect) {
+       int mult = xmult > ymult ? xmult : ymult;
+       xmult = mult;
+       ymult = mult;
+    }
+
     xs = dst_width - dst_width * xmult / 1000;
     dr->left += xs / 2;
     dr->right -= xs / 2;
@@ -148,6 +154,7 @@ void S2X_free (void)
 void S2X_init (int dw, int dh, int aw, int ah, int mult, int ad, int dd)
 {
     int flags = 0;
+    int res_shift;
 
     if (currprefs.leds_on_screen == STATUSLINE_BUILTIN)
        changed_prefs.leds_on_screen = currprefs.leds_on_screen = STATUSLINE_TARGET;
@@ -169,6 +176,14 @@ void S2X_init (int dw, int dh, int aw, int ah, int mult, int ad, int dd)
            changed_prefs.gfx_filter = usedfilter->type;
        }
     }
+
+    res_shift = RES_MAX - currprefs.gfx_resolution;
+    if (currprefs.gfx_xcenter_size > 0 && (currprefs.gfx_xcenter_size >> res_shift) < aw)
+       aw = currprefs.gfx_xcenter_size >> res_shift;
+    res_shift = currprefs.gfx_linedbl ? 0 : 1;
+    if (currprefs.gfx_ycenter_size > 0 && (currprefs.gfx_ycenter_size >> res_shift) < ah)
+       ah = currprefs.gfx_ycenter_size >> res_shift;
+
     dst_width = dw;
     dst_height = dh;
     dst_depth = dd;
index abb3221bce963e4bd8a06e64c37c65f3db899c4c..32c3cc94b14eca316029f309632b36db597d312e 100755 (executable)
@@ -169,7 +169,7 @@ HWND hStatusWnd = NULL;
 static uae_u8 scrlinebuf[4096 * 4]; /* this is too large, but let's rather play on the safe side here */
 
 
-static struct MultiDisplay *getdisplay (struct uae_prefs *p)
+struct MultiDisplay *getdisplay (struct uae_prefs *p)
 {
     int i;
     int display = p->gfx_display;
@@ -197,7 +197,7 @@ void centerdstrect (RECT *dr)
     if(!(currentmode->flags & (DM_DX_FULLSCREEN | DM_W_FULLSCREEN)))
        OffsetRect(dr, amigawin_rect.left, amigawin_rect.top);
     if (currentmode->flags & DM_W_FULLSCREEN) {
-       if (currentmode->fullfill)
+       if (currentmode->fullfill && (currentmode->current_width > currentmode->native_width || currentmode->current_height > currentmode->native_height))
            return;
        OffsetRect (dr, (currentmode->native_width - currentmode->current_width) / 2,
            (currentmode->native_height - currentmode->current_height) / 2);
@@ -227,8 +227,7 @@ static int rgbformat_bits (RGBFTYPE t)
            : 0);
 }
 
-
-static int set_ddraw (void)
+static int set_ddraw_2 (void)
 {
     HRESULT ddrval;
     int bits = (currentmode->current_depth + 7) & ~7;
@@ -242,18 +241,26 @@ static int set_ddraw (void)
     dd = (currentmode->flags & DM_DDRAW) ? TRUE : FALSE;
 
     DirectDraw_FreeMainSurface ();
-    ddrval = DirectDraw_SetCooperativeLevel (hAmigaWnd, dxfullscreen);
+    ddrval = DirectDraw_SetCooperativeLevel (hAmigaWnd, dxfullscreen, TRUE);
     if (FAILED(ddrval))
        goto oops;
 
     if (dxfullscreen)  {
-       write_log ("set_ddraw: Trying %dx%d, bits=%d, refreshrate=%d\n", width, height, bits, freq);
-       ddrval = DirectDraw_SetDisplayMode (width, height, bits, freq);
-       if (FAILED(ddrval)) {
-           write_log ("set_ddraw: failed, trying without forced refresh rate\n");
-           ddrval = DirectDraw_SetDisplayMode (width, height, bits, 0);
-           if (FAILED(ddrval))
-               goto oops;
+       int rounds = 3;
+       for (;;) {
+           write_log ("set_ddraw: Trying %dx%d, bits=%d, refreshrate=%d\n", width, height, bits, freq);
+           ddrval = DirectDraw_SetDisplayMode (width, height, bits, freq);
+           if (SUCCEEDED (ddrval))
+               break;
+           if (ddrval != 0x80004001 && freq != 0) { // "The function called is not supported at this time" (wtf?)
+               write_log ("set_ddraw: failed, trying without forced refresh rate\n");
+               ddrval = DirectDraw_SetDisplayMode (width, height, bits, 0);
+               if (SUCCEEDED (ddrval))
+                   break;
+           }
+           if (ddrval != DDERR_INVALIDMODE  && ddrval != 0x80004001 && ddrval != DDERR_UNSUPPORTEDMODE)
+               goto oops;
+           return -1;
        }
     }
 
@@ -437,7 +444,7 @@ void enumeratedisplays (int multi)
     if (multi) {
        int cnt = 1;
        DirectDraw_EnumDisplays (displaysCallback);
-       EnumDisplayMonitors(NULL, NULL, monitorEnumProc, (LPARAM)&cnt);
+       EnumDisplayMonitors (NULL, NULL, monitorEnumProc, (LPARAM)&cnt);
     } else {
        write_log ("Multimonitor detection disabled\n");
        Displays[0].primary = 1;
@@ -721,6 +728,9 @@ static void close_hwnds (void)
     AVIOutput_Restart ();
 #endif
     setmouseactive (0);
+#ifdef RETROPLATFORM
+    rp_set_hwnd (NULL);
+#endif
     if (hStatusWnd) {
        ShowWindow (hStatusWnd, SW_HIDE);
        DestroyWindow (hStatusWnd);
@@ -799,6 +809,11 @@ static int open_windows (void)
        ret = doInit ();
     } while (ret < 0);
 
+    if (!ret) {
+       DirectDraw_Release ();
+       return ret;
+    }
+
     setpriority(&priorities[currprefs.win32_active_priority]);
     if (!rp_isactive ())
        setmouseactive (-1);
@@ -838,7 +853,7 @@ int check_prefs_changed_gfx (void)
     c |= currprefs.gfx_filter_scanlines != changed_prefs.gfx_filter_scanlines ? (1|8) : 0;
     c |= currprefs.gfx_filter_scanlinelevel != changed_prefs.gfx_filter_scanlinelevel ? (1|8) : 0;
     c |= currprefs.gfx_filter_scanlineratio != changed_prefs.gfx_filter_scanlineratio ? (1|8) : 0;
-    c |= currprefs.gfx_filter_upscale != changed_prefs.gfx_filter_upscale ? (1|8) : 0;
+    c |= currprefs.gfx_filter_aspect != changed_prefs.gfx_filter_aspect ? (1|8) : 0;
     c |= currprefs.gfx_filter_luminance != changed_prefs.gfx_filter_luminance ? (1|8) : 0;
     c |= currprefs.gfx_filter_contrast != changed_prefs.gfx_filter_contrast ? (1|8) : 0;
     c |= currprefs.gfx_filter_saturation != changed_prefs.gfx_filter_saturation ? (1|8) : 0;
@@ -874,7 +889,7 @@ int check_prefs_changed_gfx (void)
        currprefs.gfx_filter_scanlines = changed_prefs.gfx_filter_scanlines;
        currprefs.gfx_filter_scanlinelevel = changed_prefs.gfx_filter_scanlinelevel;
        currprefs.gfx_filter_scanlineratio = changed_prefs.gfx_filter_scanlineratio;
-       currprefs.gfx_filter_upscale = changed_prefs.gfx_filter_upscale;
+       currprefs.gfx_filter_aspect = changed_prefs.gfx_filter_aspect;
        currprefs.gfx_filter_luminance = changed_prefs.gfx_filter_luminance;
        currprefs.gfx_filter_contrast = changed_prefs.gfx_filter_contrast;
        currprefs.gfx_filter_saturation = changed_prefs.gfx_filter_saturation;
@@ -1211,7 +1226,8 @@ static int reopen (int full)
        full = 1;
     if (changed_prefs.gfx_pfullscreen != currprefs.gfx_pfullscreen && screen_is_picasso)
        full = 1;
-    if (!screen_is_picasso && changed_prefs.gfx_afullscreen) {
+    /* fullscreen to fullscreen? */
+    if (!screen_is_picasso && changed_prefs.gfx_afullscreen && currprefs.gfx_afullscreen == changed_prefs.gfx_afullscreen) {
        if (currprefs.gfx_size_fs.width != changed_prefs.gfx_size_fs.width ||
            currprefs.gfx_size_fs.height != changed_prefs.gfx_size_fs.height) {
                quick = 1;
@@ -1257,6 +1273,7 @@ static int modeswitchneeded (struct winuae_currentmode *wc)
            if (picasso96_state.Width != wc->current_width ||
                picasso96_state.Height != wc->current_height)
                return -1;
+           return 1;
        } else {
            if (currentmode->current_width != wc->current_width ||
                currentmode->current_height != wc->current_height ||
@@ -1408,8 +1425,8 @@ void close_windows (void)
 #endif
     free (gfxvidinfo.realbufmem);
     gfxvidinfo.realbufmem = 0;
-    DirectDraw_Release();
-    close_hwnds();
+    DirectDraw_Release ();
+    close_hwnds ();
 }
 
 void WIN32GFX_ToggleFullScreen (void)
@@ -1501,7 +1518,38 @@ static int createnotification (HWND hwnd)
 }
 #endif
 
-static int create_windows (void)
+static int getbestmode (int nextbest)
+{
+    int i, disp;
+
+    disp = currprefs.gfx_display;
+    for (i = 0; DisplayModes[i].depth >= 0; i++) {
+        struct PicassoResolution *pr = &DisplayModes[i];
+        if (pr->res.width == currentmode->native_width && pr->res.height == currentmode->native_height)
+           break;
+    }
+    if (DisplayModes[i].depth >= 0) {
+       if (!nextbest)
+           return 1;
+       while (DisplayModes[i].res.width == currentmode->native_width && DisplayModes[i].res.height == currentmode->native_height)
+           i++;
+    } else {
+       i = 0;
+    }
+    for (; DisplayModes[i].depth >= 0; i++) {
+       struct PicassoResolution *pr = &DisplayModes[i];
+       if (pr->res.width >= currentmode->native_width && pr->res.height >= currentmode->native_height) {
+           write_log ("FS: %dx%d -> %dx%d\n", currentmode->native_width, currentmode->native_height,
+               pr->res.width, pr->res.height);
+           currentmode->native_width = pr->res.width;
+           currentmode->native_height = pr->res.height;
+           return 1;
+       }
+    }
+    return 0;
+}
+
+static int create_windows_2 (void)
 {
     int dxfs = currentmode->flags & (DM_DX_FULLSCREEN | DM_D3D_FULLSCREEN);
     int fsw = currentmode->flags & (DM_W_FULLSCREEN);
@@ -1602,26 +1650,7 @@ static int create_windows (void)
        }
 
     } else {
-       int i;
-
-       for (i = 0; DisplayModes[i].depth >= 0; i++) {
-           struct PicassoResolution *pr = &DisplayModes[i];
-           if (pr->res.width == currentmode->native_width && pr->res.height == currentmode->native_height)
-               break;
-       }
-       if (DisplayModes[i].depth < 0) {
-           for (i = 0; DisplayModes[i].depth >= 0; i++) {
-               struct PicassoResolution *pr = &DisplayModes[i];
-               if (pr->res.width >= currentmode->native_width && pr->res.height >= currentmode->native_height) {
-                   write_log ("FS: %dx%d -> %dx%d\n", currentmode->native_width, currentmode->native_height,
-                       pr->res.width, pr->res.height);
-                   currentmode->native_width = pr->res.width;
-                   currentmode->native_height = pr->res.height;
-                   break;
-               }
-           }
-       }
-
+       getbestmode (0);
     }
 
     if (rp_isactive ()) {
@@ -1654,9 +1683,42 @@ static int create_windows (void)
     }
     ShowWindow (hAmigaWnd, SW_SHOWNORMAL);
     UpdateWindow (hAmigaWnd);
+
+    return 1;
+}
+
+static int set_ddraw (void)
+{
+    int cnt, ret;
+
+    if (picasso_on)
+       currentmode->pal = (LPPALETTEENTRY) & picasso96_state.CLUT;
+    else
+       currentmode->pal = colors256;
+
+    cnt = 3;
+    for (;;) {
+       ret = set_ddraw_2 ();
+       if (cnt-- <= 0)
+           return 0;
+       if (ret < 0) {
+           getbestmode (1);
+           continue;
+       }
+       if (ret == 0)
+           return 0;
+       break;
+    }
     return 1;
 }
 
+static int create_windows (void)
+{
+    if (!create_windows_2 ())
+       return 0;
+    return set_ddraw ();
+}
+
 static void updatemodes (void)
 {
     DWORD flags;
@@ -1701,8 +1763,14 @@ static BOOL doInit (void)
        updatemodes ();
        currentmode->native_depth = 0;
        tmp_depth = currentmode->current_depth;
-        currentmode->native_width = currentmode->current_width;
+
+       currentmode->native_width = currentmode->current_width;
         currentmode->native_height = currentmode->current_height;
+       if (currentmode->flags & DM_W_FULLSCREEN) {
+           RECT rc = getdisplay (&currprefs)->rect;
+           currentmode->native_width = rc.right - rc.left;
+           currentmode->native_height = rc.bottom - rc.top;
+       }
 
        write_log ("W=%d H=%d B=%d CT=%d\n",
            DirectDraw_CurrentWidth (), DirectDraw_CurrentHeight (), DirectDraw_GetCurrentDepth (), colortype);
@@ -1759,20 +1827,12 @@ static BOOL doInit (void)
            goto oops;
 #ifdef PICASSO96
        if (screen_is_picasso) {
-           currentmode->pal = (LPPALETTEENTRY) & picasso96_state.CLUT;
-           if (!set_ddraw ()) {
-               goto oops;
-           }
            picasso_vidinfo.rowbytes = DirectDraw_GetSurfacePitch();
            picasso_vidinfo.pixbytes = DirectDraw_GetBytesPerPixel();
            picasso_vidinfo.rgbformat = DirectDraw_GetPixelFormat();
            break;
        } else {
 #endif
-           currentmode->pal = colors256;
-           if (! set_ddraw ()) {
-               goto oops;
-           }
            currentmode->native_depth = currentmode->current_depth;
 #if defined (GFXFILTER)
            if (currentmode->flags & (DM_OPENGL | DM_D3D | DM_SWSCALE)) {
index c759a10ced88a40cc804099a84b70436d31d7648..c96828f19a97f24a8421e7c46b4b683895074ee0 100755 (executable)
@@ -37,6 +37,6 @@ extern int is3dmode (void);
 void DX_Fill (int dstx, int dsty, int width, int height, uae_u32 color);
 void DX_Blit (int x, int y, int w, int h);
 void centerdstrect (RECT *);
-
+struct MultiDisplay *getdisplay (struct uae_prefs *p);
 
 #endif
index a5603cfb3945dd0699015256ad11fdf214866efc..08a541678cca4e12993532386382a83eabaa696f 100755 (executable)
@@ -7,6 +7,7 @@
  *
  ***************************************************************************/
 
+#define CONFIGCACHE 1
 #define FRONTEND 0
 
 #define _WIN32_WINNT 0x600
@@ -1155,6 +1156,8 @@ void gui_display (int shortcut)
            write_log ("FlipToGDISurface failed, %s\n", DXError (hr));
     }
 
+    flush_log ();
+
     if (shortcut == -1) {
        int ret;
        ret = GetSettings (0, hAmigaWnd);
@@ -1861,6 +1864,165 @@ struct ConfigStruct *AllocConfigStruct (void)
     return config;
 }
 
+static void FreeConfigStore (void)
+{
+    int i;
+    for (i = 0; i < configstoresize; i++)
+       FreeConfigStruct (configstore[i]);
+    free (configstore);
+    configstore = 0;
+    configstoresize = configstoreallocated = 0;
+}
+
+static void getconfigcache (char *dst, const char *path)
+{
+    strcpy (dst, path);
+    strncat (dst, "configuration.cache", MAX_DPATH);
+}
+
+static char *fgetsx (char *dst, FILE *f)
+{
+    char *s = fgets (dst, MAX_DPATH, f);
+    if (!s)
+       return s;
+    if (strlen (dst) == 0)
+       return s;
+    if (dst[strlen (dst) - 1] == '\n')
+       dst[strlen (dst) - 1] = 0;
+    if (dst[strlen (dst) - 1] == '\r')
+       dst[strlen (dst) - 1] = 0;
+    return s;
+}
+
+static char configcachever[] = "0.1";
+
+static struct ConfigStruct *readconfigcache (const char *path)
+{
+    FILE *zcache;
+    char cachepath[MAX_DPATH];
+    char buf[MAX_DPATH];
+    char rootpath[MAX_DPATH];
+    char path2[MAX_DPATH];
+    struct ConfigStruct *cs, *first;
+    int err, i;
+
+    err = 0;
+    first = NULL;
+    getconfigcache (cachepath, path);
+    zcache = fopen (cachepath, "r");
+    if (!zcache)
+       return NULL;
+    fgetsx (buf, zcache);
+    if (!feof (zcache) && !strcmp (buf, configcachever)) {
+       GetFullPathName (path, sizeof path2, path2, NULL);
+       strcpy (rootpath, path2);
+       fgetsx (buf, zcache);
+       if (!strcmp (buf, rootpath)) {
+           fgetsx (buf, zcache);
+           if (!feof (zcache) && strlen (buf) == 0) {
+               while (fgetsx (buf, zcache)) {
+                   cs = AllocConfigStruct ();
+                   if (configstore == NULL || configstoreallocated == configstoresize) {
+                       configstoreallocated += 100;
+                       configstore = realloc (configstore, sizeof (struct ConfigStruct*) * configstoreallocated);
+                   }
+                   configstore[configstoresize++] = cs;
+                   if (!first)
+                        first = cs;
+                   if (buf[0] == '1')
+                       cs->Directory = 1;
+
+                   fgetsx (buf, zcache);
+                   if (strlen (buf) > strlen (rootpath)) {
+                       for (i = 0; i < configstoresize; i++) {
+                           GetFullPathName (configstore[i]->Fullpath, sizeof path2, path2, NULL);
+                           if (!strcmp (path2, buf) && strcmp (path2, rootpath)) {
+                               cs->Parent = configstore[i];
+                               break;
+                           }
+                       }
+                   }
+
+                   fgetsx (cs->Name, zcache);
+                   fgetsx (cs->Path, zcache);
+                   fgetsx (cs->Fullpath, zcache);
+                   fgetsx (cs->Description, zcache);
+                   fgetsx (cs->HardwareLink, zcache);
+                   fgetsx (cs->HostLink, zcache);
+                   fgetsx (buf, zcache);
+                   cs->Type = 3;
+
+                   fgetsx (buf, zcache);
+                   if (strlen (buf) > 0)
+                       break;
+               }
+           }
+       }
+    }
+    if (!feof (zcache))
+       err = 1;
+    fclose (zcache);
+    if (err || first == NULL) {
+       zcache = fopen (cachepath, "w+");
+       if (zcache)
+           fclose (zcache);
+       FreeConfigStore ();
+       return NULL;
+    }
+    return first;
+}
+
+static void writeconfigcache (const char *path)
+{
+    int i;
+    char lf = 10;
+    FILE *zcache;
+    char cachepath[MAX_DPATH];
+    char path2[MAX_DPATH];
+
+    getconfigcache (cachepath, path);
+    zcache = fopen (cachepath, "r");
+    if (!zcache)
+       return;
+    fclose (zcache);
+    zcache = fopen (cachepath, "w");
+    if (!zcache)
+       return;
+    GetFullPathName (path, sizeof path2, path2, NULL);
+    fwrite (configcachever, strlen (configcachever), 1, zcache);
+    fwrite (&lf, 1, 1, zcache);
+    fwrite (path2, strlen (path2), 1, zcache);
+    fwrite (&lf, 1, 1, zcache);
+    fwrite (&lf, 1, 1, zcache);
+    for (i = configstoresize - 1; i >= 0; i--) {
+       struct ConfigStruct *cs = configstore[i];
+        sprintf (path2, "%d", cs->Directory);
+        fwrite (path2, strlen (path2), 1, zcache);
+        fwrite (&lf, 1, 1, zcache);
+        GetFullPathName (cs->Fullpath, sizeof path2, path2, NULL);
+        fwrite (path2, strlen (path2), 1, zcache);
+        fwrite (&lf, 1, 1, zcache);
+        fwrite (cs->Name, strlen (cs->Name), 1, zcache);
+        fwrite (&lf, 1, 1, zcache);
+        fwrite (cs->Fullpath, strlen (cs->Fullpath), 1, zcache);
+        fwrite (&lf, 1, 1, zcache);
+        fwrite (cs->Path, strlen (cs->Path), 1, zcache);
+        fwrite (&lf, 1, 1, zcache);
+        fwrite (cs->Description, strlen (cs->Description), 1, zcache);
+        fwrite (&lf, 1, 1, zcache);
+        fwrite (cs->HardwareLink, strlen (cs->HardwareLink), 1, zcache);
+        fwrite (&lf, 1, 1, zcache);
+        fwrite (cs->HostLink, strlen (cs->HostLink), 1, zcache);
+        fwrite (&lf, 1, 1, zcache);
+        sprintf (path2, "%d", cs->Type);
+        fwrite (path2, strlen (path2), 1, zcache);
+        fwrite (&lf, 1, 1, zcache);
+
+        fwrite (&lf, 1, 1, zcache);
+    }
+    fclose (zcache);
+}
+
 static struct ConfigStruct *GetConfigs (struct ConfigStruct *configparent, int usedirs, int *level)
 {
     DWORD num_bytes = 0;
@@ -1871,12 +2033,21 @@ static struct ConfigStruct *GetConfigs (struct ConfigStruct *configparent, int u
     struct ConfigStruct *config, *first;
     HANDLE handle;
 
+    if (*level == 0)
+       FreeConfigStore ();
     first = NULL;
     GetConfigPath (path, configparent, FALSE);
     GetConfigPath (shortpath, configparent, TRUE);
     strcpy (path2, path);
     strncat (path2, "*.*", MAX_DPATH);
-    handle = FindFirstFile(path2, &find_data );
+
+    if (*level == 0) {
+       first = readconfigcache (path);
+       if (first)
+           return first; 
+    }
+
+    handle = FindFirstFile (path2, &find_data );
     if (handle == INVALID_HANDLE_VALUE) {
 #ifndef SINGLEFILE
        // Either the directory has no .CFG files, or doesn't exist.
@@ -1949,23 +2120,16 @@ static struct ConfigStruct *GetConfigs (struct ConfigStruct *configparent, int u
            if (first == NULL)
                first = config;
        }
-       if(FindNextFile (handle, &find_data) == 0) {
+       if (FindNextFile (handle, &find_data) == 0) {
            FindClose(handle);
            break;
        }
     }
+    if (*level == 0 && CONFIGCACHE)
+       writeconfigcache (path);
     return first;
 }
 
-static void FreeConfigStore (void)
-{
-    int i;
-    for (i = 0; i < configstoresize; i++)
-       FreeConfigStruct (configstore[i]);
-    free (configstore);
-    configstore = 0;
-    configstoresize = configstoreallocated = 0;
-}
 static struct ConfigStruct *CreateConfigStore (struct ConfigStruct *oldconfig)
 {
     int level = 0, i;
@@ -1976,7 +2140,6 @@ static struct ConfigStruct *CreateConfigStore (struct ConfigStruct *oldconfig)
        strcpy (path, oldconfig->Path);
        strcpy (name, oldconfig->Name);
     }
-    FreeConfigStore ();
     GetConfigs (NULL, 1, &level);
     if (oldconfig) {
        for (i = 0; i < configstoresize; i++) {
@@ -9069,7 +9232,7 @@ static void enable_for_hw3ddlg (HWND hDlg)
     ew (hDlg, IDC_FILTERXTRA, vv2);
     ew (hDlg, IDC_FILTERDEFAULT, v);
     ew (hDlg, IDC_FILTERFILTER, vv);
-    ew (hDlg, IDC_FILTERUPSCALE, vv && !vv2);
+    ew (hDlg, IDC_FILTERASPECT, vv && !vv2);
     ew (hDlg, IDC_FILTERAUTORES, vv && !vv2);
 
     ew (hDlg, IDC_FILTERPRESETSAVE, filterpreset_builtin < 0);
@@ -9126,7 +9289,7 @@ static int *filtervars[] = {
        &workprefs.gfx_xcenter, &workprefs.gfx_ycenter,
        &workprefs.gfx_filter_luminance, &workprefs.gfx_filter_contrast, &workprefs.gfx_filter_saturation,
        &workprefs.gfx_filter_gamma, &workprefs.gfx_filter_blur, &workprefs.gfx_filter_noise,
-       &workprefs.gfx_filter_upscale,
+       &workprefs.gfx_filter_aspect,
        NULL
     };
 
@@ -9147,7 +9310,7 @@ static void values_to_hw3ddlg (HWND hDlg)
     struct uae_filter *uf;
     UAEREG *fkey;
 
-    CheckDlgButton(hDlg, IDC_FILTERUPSCALE, workprefs.gfx_filter_upscale);
+    CheckDlgButton(hDlg, IDC_FILTERASPECT, workprefs.gfx_filter_aspect);
     CheckDlgButton(hDlg, IDC_FILTERAUTORES, workprefs.gfx_autoresolution);
 
     SendDlgItemMessage(hDlg, IDC_FILTERHZ, TBM_SETRANGE, TRUE, MAKELONG (-999, +999));
@@ -9457,114 +9620,140 @@ static INT_PTR CALLBACK hw3dDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM l
 
     switch (msg)
     {
-    case WM_INITDIALOG:
-#if WINUAEBETA == 0
-       ShowWindow (GetDlgItem(hDlg, IDC_FILTERAUTORES), SW_HIDE);
-#endif
-       pages[HW3D_ID] = hDlg;
-       currentpage = HW3D_ID;
-       enable_for_hw3ddlg (hDlg);
+       case WM_INITDIALOG:
+    #if WINUAEBETA == 0
+           ShowWindow (GetDlgItem(hDlg, IDC_FILTERAUTORES), SW_HIDE);
+    #endif
+           pages[HW3D_ID] = hDlg;
+           currentpage = HW3D_ID;
+           enable_for_hw3ddlg (hDlg);
 
-    case WM_USER:
-       if(recursive > 0)
-           break;
-       recursive++;
-       enable_for_hw3ddlg( hDlg );
-       values_to_hw3ddlg (hDlg);
-       recursive--;
-       return TRUE;
-    case WM_COMMAND:
-       if(recursive > 0)
-           break;
-       recursive++;
-       switch (wParam)
-       {
-           case IDC_FILTERDEFAULT:
-           currprefs.gfx_filter_horiz_zoom = workprefs.gfx_filter_horiz_zoom = 0;
-           currprefs.gfx_filter_vert_zoom = workprefs.gfx_filter_vert_zoom = 0;
-           currprefs.gfx_filter_horiz_offset = workprefs.gfx_filter_horiz_offset = 0;
-           currprefs.gfx_filter_vert_offset = workprefs.gfx_filter_vert_offset = 0;
+       case WM_USER:
+           if(recursive > 0)
+               break;
+           recursive++;
+           enable_for_hw3ddlg( hDlg );
            values_to_hw3ddlg (hDlg);
-           updatedisplayarea ();
-           WIN32GFX_WindowMove ();
-           break;
-           case IDC_FILTERPRESETLOAD:
-           case IDC_FILTERPRESETSAVE:
-           case IDC_FILTERPRESETDELETE:
-           filter_preset (hDlg, wParam);
-           break;
-           case IDC_FILTERENABLE:
-           filter_handle (hDlg);
-           break;
-           case IDC_FILTERAUTORES:
-           workprefs.gfx_autoresolution = IsDlgButtonChecked (hDlg, IDC_FILTERAUTORES);
-           break;
-           case IDC_FILTERUPSCALE:
-           currprefs.gfx_filter_upscale = workprefs.gfx_filter_upscale = IsDlgButtonChecked (hDlg, IDC_FILTERUPSCALE);
-           updatedisplayarea ();
-           WIN32GFX_WindowMove ();
-           break;
-           default:
-           if (HIWORD (wParam) == CBN_SELCHANGE || HIWORD (wParam) == CBN_KILLFOCUS)  {
-               switch (LOWORD (wParam))
-               {
-                   case IDC_FILTERXTRA:
-                   values_to_hw3ddlg (hDlg);
-                   break;
-                   case IDC_FILTERPRESETS:
-                   filter_preset (hDlg, LOWORD (wParam));
-                   break;
-                   case IDC_FILTERSLR:
-                   item = SendDlgItemMessage (hDlg, IDC_FILTERSLR, CB_GETCURSEL, 0, 0L);
-                   if (item != CB_ERR) {
-                       currprefs.gfx_filter_scanlineratio = workprefs.gfx_filter_scanlineratio = scanlineindexes[item];
+           recursive--;
+           return TRUE;
+       case WM_COMMAND:
+           if(recursive > 0)
+               break;
+           recursive++;
+           switch (wParam)
+           {
+               case IDC_FILTERDEFAULT:
+               currprefs.gfx_filter_horiz_zoom = workprefs.gfx_filter_horiz_zoom = 0;
+               currprefs.gfx_filter_vert_zoom = workprefs.gfx_filter_vert_zoom = 0;
+               currprefs.gfx_filter_horiz_offset = workprefs.gfx_filter_horiz_offset = 0;
+               currprefs.gfx_filter_vert_offset = workprefs.gfx_filter_vert_offset = 0;
+               values_to_hw3ddlg (hDlg);
+               updatedisplayarea ();
+               WIN32GFX_WindowMove ();
+               break;
+               case IDC_FILTERPRESETLOAD:
+               case IDC_FILTERPRESETSAVE:
+               case IDC_FILTERPRESETDELETE:
+               filter_preset (hDlg, wParam);
+               break;
+               case IDC_FILTERENABLE:
+               filter_handle (hDlg);
+               break;
+               case IDC_FILTERAUTORES:
+               workprefs.gfx_autoresolution = IsDlgButtonChecked (hDlg, IDC_FILTERAUTORES);
+               break;
+               case IDC_FILTERASPECT:
+               currprefs.gfx_filter_aspect = workprefs.gfx_filter_aspect = IsDlgButtonChecked (hDlg, IDC_FILTERASPECT);
+               updatedisplayarea ();
+               WIN32GFX_WindowMove ();
+               break;
+               default:
+               if (HIWORD (wParam) == CBN_SELCHANGE || HIWORD (wParam) == CBN_KILLFOCUS)  {
+                   switch (LOWORD (wParam))
+                   {
+                       case IDC_FILTERXTRA:
+                       values_to_hw3ddlg (hDlg);
+                       break;
+                       case IDC_FILTERPRESETS:
+                       filter_preset (hDlg, LOWORD (wParam));
+                       break;
+                       case IDC_FILTERSLR:
+                       item = SendDlgItemMessage (hDlg, IDC_FILTERSLR, CB_GETCURSEL, 0, 0L);
+                       if (item != CB_ERR) {
+                           currprefs.gfx_filter_scanlineratio = workprefs.gfx_filter_scanlineratio = scanlineindexes[item];
+                           updatedisplayarea ();
+                       }
+                       break;
+                       case IDC_FILTERMODE:
+                       case IDC_FILTERFILTER:
+                       filter_handle (hDlg);
+                       break;
+                       case IDC_FILTERHZMULT:
+                       currprefs.gfx_filter_horiz_zoom_mult = workprefs.gfx_filter_horiz_zoom_mult = getfiltermult(hDlg, IDC_FILTERHZMULT);
+                       updatedisplayarea ();
+                       WIN32GFX_WindowMove ();
+                       break;
+
+                       case IDC_FILTERVZMULT:
+                       currprefs.gfx_filter_vert_zoom_mult = workprefs.gfx_filter_vert_zoom_mult = getfiltermult(hDlg, IDC_FILTERVZMULT);
                        updatedisplayarea ();
+                       WIN32GFX_WindowMove ();
+                       break;
                    }
-                   break;
-                   case IDC_FILTERMODE:
-                   case IDC_FILTERFILTER:
-                   filter_handle (hDlg);
-                   break;
-                   case IDC_FILTERHZMULT:
-                   case IDC_FILTERVZMULT:
-                   currprefs.gfx_filter_horiz_zoom_mult = workprefs.gfx_filter_horiz_zoom_mult = getfiltermult(hDlg, IDC_FILTERHZMULT);
-                   currprefs.gfx_filter_vert_zoom_mult = workprefs.gfx_filter_vert_zoom_mult = getfiltermult(hDlg, IDC_FILTERVZMULT);
-                   updatedisplayarea ();
-                   WIN32GFX_WindowMove ();
-                   break;
                }
+               break;
            }
+           recursive--;
+           break;
+       case WM_HSCROLL:
+       {
+           HWND hz = GetDlgItem (hDlg, IDC_FILTERHZ);
+           HWND vz = GetDlgItem (hDlg, IDC_FILTERVZ);
+           HWND h = (HWND)lParam;
+
+           if (recursive)
+               break;
+           recursive++;
+           if (h == hz) {
+               currprefs.gfx_filter_horiz_zoom = workprefs.gfx_filter_horiz_zoom = (int)SendMessage (hz, TBM_GETPOS, 0, 0);
+               if (workprefs.gfx_filter_aspect) {
+                   currprefs.gfx_filter_vert_zoom = workprefs.gfx_filter_vert_zoom = currprefs.gfx_filter_horiz_zoom;
+                   SendDlgItemMessage (hDlg, IDC_FILTERVZ, TBM_SETPOS, TRUE, workprefs.gfx_filter_vert_zoom);
+               }
+           } else if (h == vz) {
+               currprefs.gfx_filter_vert_zoom = workprefs.gfx_filter_vert_zoom = (int)SendMessage (vz, TBM_GETPOS, 0, 0);
+               if (workprefs.gfx_filter_aspect) {
+                   currprefs.gfx_filter_horiz_zoom = workprefs.gfx_filter_horiz_zoom = currprefs.gfx_filter_vert_zoom;
+                   SendDlgItemMessage (hDlg, IDC_FILTERHZ, TBM_SETPOS, TRUE, workprefs.gfx_filter_horiz_zoom);
+               }
+           } else {
+               currprefs.gfx_filter_horiz_offset = workprefs.gfx_filter_horiz_offset = (int)SendMessage (GetDlgItem (hDlg, IDC_FILTERHO), TBM_GETPOS, 0, 0);
+               currprefs.gfx_filter_vert_offset = workprefs.gfx_filter_vert_offset = (int)SendMessage (GetDlgItem (hDlg, IDC_FILTERVO), TBM_GETPOS, 0, 0);
+           }
+           if (filter_selected) {
+               int *pw = filter_selected->varw;
+               int *pc = filter_selected->varc;
+               int v = (int)SendMessage(GetDlgItem(hDlg, IDC_FILTERXL), TBM_GETPOS, 0, 0);
+               if (v < filter_selected->min)
+                   v = filter_selected->min;
+               if (v > filter_selected->max)
+                   v = filter_selected->max;
+               *pw = v;
+               *pc = v;
+               SetDlgItemInt (hDlg, IDC_FILTERXLV, v, TRUE);
+           }
+           SetDlgItemInt (hDlg, IDC_FILTERHZV, workprefs.gfx_filter_horiz_zoom, TRUE);
+           SetDlgItemInt (hDlg, IDC_FILTERVZV, workprefs.gfx_filter_vert_zoom, TRUE);
+           SetDlgItemInt (hDlg, IDC_FILTERHOV, workprefs.gfx_filter_horiz_offset, TRUE);
+           SetDlgItemInt (hDlg, IDC_FILTERVOV, workprefs.gfx_filter_vert_offset, TRUE);
+           init_colors();
+           notice_new_xcolors();
+           reset_drawing();
+           updatedisplayarea ();
+           WIN32GFX_WindowMove ();
+           recursive--;
            break;
        }
-       recursive--;
-       break;
-    case WM_HSCROLL:
-       currprefs.gfx_filter_horiz_zoom = workprefs.gfx_filter_horiz_zoom = (int)SendMessage(GetDlgItem(hDlg, IDC_FILTERHZ), TBM_GETPOS, 0, 0 );
-       currprefs.gfx_filter_vert_zoom = workprefs.gfx_filter_vert_zoom = (int)SendMessage(GetDlgItem(hDlg, IDC_FILTERVZ), TBM_GETPOS, 0, 0 );
-       currprefs.gfx_filter_horiz_offset = workprefs.gfx_filter_horiz_offset = (int)SendMessage(GetDlgItem(hDlg, IDC_FILTERHO), TBM_GETPOS, 0, 0);
-       currprefs.gfx_filter_vert_offset = workprefs.gfx_filter_vert_offset = (int)SendMessage(GetDlgItem(hDlg, IDC_FILTERVO), TBM_GETPOS, 0, 0);
-       if (filter_selected) {
-           int *pw = filter_selected->varw;
-           int *pc = filter_selected->varc;
-           int v = (int)SendMessage(GetDlgItem(hDlg, IDC_FILTERXL), TBM_GETPOS, 0, 0);
-           if (v < filter_selected->min)
-               v = filter_selected->min;
-           if (v > filter_selected->max)
-               v = filter_selected->max;
-           *pw = v;
-           *pc = v;
-           SetDlgItemInt (hDlg, IDC_FILTERXLV, v, TRUE);
-       }
-       SetDlgItemInt (hDlg, IDC_FILTERHZV, workprefs.gfx_filter_horiz_zoom, TRUE);
-       SetDlgItemInt (hDlg, IDC_FILTERVZV, workprefs.gfx_filter_vert_zoom, TRUE);
-       SetDlgItemInt (hDlg, IDC_FILTERHOV, workprefs.gfx_filter_horiz_offset, TRUE);
-       SetDlgItemInt (hDlg, IDC_FILTERVOV, workprefs.gfx_filter_vert_offset, TRUE);
-       init_colors();
-       notice_new_xcolors();
-       reset_drawing();
-       updatedisplayarea ();
-       WIN32GFX_WindowMove ();
-       break;
     }
     return FALSE;
 }
index caa21f2e75e63fb08cf355315d477d18d2e1b912..5f8414aa9569c7f0a61373e51948aa52f648c8a9 100755 (executable)
@@ -1,4 +1,20 @@
 
+Beta 13:
+
+- more screen mode switching problems fixed
+- automatically select next bigger resolution if fullscreen mode fails
+  to open (for example 50Hz-only modes without 50Hz compatible display)
+- added "keep aspect ratio" checkbox to filter panel, syncronizes
+  vertical and horizontal zoom sliders (OGL/D3D are still broken!)
+- both vertical and horizontal filter multiplier set to "FS" and aspect
+  ratio checkbox checked -> keep aspect ratio
+- midscreen BPLCON4 modifications fixed (broken since 1200b2, stupid bug,
+  wrong register address..) fixes Gloom (and other programs using same
+  copper C2P method) graphics problems
+- winuaeenforcer stack debug output fix (BR)
+- PCMCIA SRAM emulation eject crash fix
+- fullwindow Picasso96 mode is centered again
+
 Beta 12:
 
 - hardfile creation: sparse file option added (sparse file = non-written