]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
imported winuaesrc1600b20.zip
authorToni Wilen <twilen@winuae.net>
Mon, 30 Mar 2009 14:07:30 +0000 (17:07 +0300)
committerToni Wilen <twilen@winuae.net>
Mon, 22 Feb 2010 19:45:36 +0000 (21:45 +0200)
22 files changed:
cfgfile.c
custom.c
include/inputdevice.h
include/keybuf.h
include/options.h
include/zfile.h
inputdevice.c
inputevents.def
keybuf.c
memory.c
od-win32/dinput.c
od-win32/fsdb_win32.c
od-win32/resources/resource
od-win32/resources/winuae.rc
od-win32/rp.c
od-win32/win32.c
od-win32/win32.h
od-win32/win32gui.c
od-win32/winuaechangelog.txt
od-win32/writelog.c
uaelib.c
zfile.c

index ecda35ad2ddea86aeef6d05b5d5416988cd8fc94..347303a7499df2fa234965e6628f44d019679998 100644 (file)
--- a/cfgfile.c
+++ b/cfgfile.c
@@ -164,6 +164,7 @@ static const TCHAR *maxvert[] = { L"nointerlace", L"interlace", 0 };
 static const TCHAR *abspointers[] = { L"none", L"mousehack", L"tablet", 0 };
 static const TCHAR *magiccursors[] = { L"both", L"native", L"host", 0 };
 static const TCHAR *autoscale[] = { L"none", L"scale", L"resize", 0 };
+static const TCHAR *joyportmodes[] = { NULL, L"mouse", L"djoy", L"ajoy", L"cdtvjoy", L"cd32joy", L"lightpen", 0 };
 
 static const TCHAR *obsolete[] = {
     L"accuracy", L"gfx_opengl", L"gfx_32bit_blits", L"32bit_blits",
@@ -282,41 +283,41 @@ end:
     xfree (tmp1);
 }
 
-void cfgfile_write_bool (struct zfile *f, TCHAR *option, int b)
+void cfgfile_write_bool (struct zfile *f, const TCHAR *option, int b)
 {
     cfg_dowrite (f, option, b ? L"true" : L"false", 0, 0);
 }
-void cfgfile_dwrite_bool (struct zfile *f, TCHAR *option, int b)
+void cfgfile_dwrite_bool (struct zfile *f, const TCHAR *option, int b)
 {
     cfg_dowrite (f, option, b ? L"true" : L"false", 1, 0);
 }
-void cfgfile_write_str (struct zfile *f, TCHAR *option, const TCHAR *value)
+void cfgfile_write_str (struct zfile *f, const TCHAR *option, const TCHAR *value)
 {
     cfg_dowrite (f, option, value, 0, 0);
 }
-void cfgfile_dwrite_str (struct zfile *f, TCHAR *option, const TCHAR *value)
+void cfgfile_dwrite_str (struct zfile *f, const TCHAR *option, const TCHAR *value)
 {
     cfg_dowrite (f, option, value, 1, 0);
 }
 
-void cfgfile_target_write_bool (struct zfile *f, TCHAR *option, int b)
+void cfgfile_target_write_bool (struct zfile *f, const TCHAR *option, int b)
 {
     cfg_dowrite (f, option, b ? L"true" : L"false", 0, 1);
 }
-void cfgfile_target_dwrite_bool (struct zfile *f, TCHAR *option, int b)
+void cfgfile_target_dwrite_bool (struct zfile *f, const TCHAR *option, int b)
 {
     cfg_dowrite (f, option, b ? L"true" : L"false", 1, 1);
 }
-void cfgfile_target_write_str (struct zfile *f, TCHAR *option, const TCHAR *value)
+void cfgfile_target_write_str (struct zfile *f, const TCHAR *option, const TCHAR *value)
 {
     cfg_dowrite (f, option, value, 0, 1);
 }
-void cfgfile_target_dwrite_str (struct zfile *f, TCHAR *option, const TCHAR *value)
+void cfgfile_target_dwrite_str (struct zfile *f, const TCHAR *option, const TCHAR *value)
 {
     cfg_dowrite (f, option, value, 1, 1);
 }
 
-void cfgfile_write (struct zfile *f, TCHAR *option, TCHAR *format,...)
+void cfgfile_write (struct zfile *f, const TCHAR *option, const TCHAR *format,...)
 {
     va_list parms;
     TCHAR tmp[CONFIG_BLEN];
@@ -326,7 +327,7 @@ void cfgfile_write (struct zfile *f, TCHAR *option, TCHAR *format,...)
     cfg_dowrite (f, option, tmp, 0, 0);
     va_end (parms);
 }
-void cfgfile_dwrite (struct zfile *f, TCHAR *option, TCHAR *format,...)
+void cfgfile_dwrite (struct zfile *f, const TCHAR *option, const TCHAR *format,...)
 {
     va_list parms;
     TCHAR tmp[CONFIG_BLEN];
@@ -336,7 +337,7 @@ void cfgfile_dwrite (struct zfile *f, TCHAR *option, TCHAR *format,...)
     cfg_dowrite (f, option, tmp, 1, 0);
     va_end (parms);
 }
-void cfgfile_target_write (struct zfile *f, TCHAR *option, TCHAR *format,...)
+void cfgfile_target_write (struct zfile *f, const TCHAR *option, const TCHAR *format,...)
 {
     va_list parms;
     TCHAR tmp[CONFIG_BLEN];
@@ -346,7 +347,7 @@ void cfgfile_target_write (struct zfile *f, TCHAR *option, TCHAR *format,...)
     cfg_dowrite (f, option, tmp, 0, 1);
     va_end (parms);
 }
-void cfgfile_target_dwrite (struct zfile *f, TCHAR *option, TCHAR *format,...)
+void cfgfile_target_dwrite (struct zfile *f, const TCHAR *option, const TCHAR *format,...)
 {
     va_list parms;
     TCHAR tmp[CONFIG_BLEN];
@@ -556,7 +557,7 @@ void cfgfile_save_options (struct zfile *f, struct uae_prefs *p, int type)
     if (p->override_dga_address)
        cfgfile_write (f, L"override_dga_address", L"0x%08x", p->override_dga_address);
 
-    for (i = 0; i < 2; i++) {
+    for (i = 0; i < MAX_JPORTS; i++) {
        struct jport *jp = &p->jports[i];
        int v = jp->id;
        TCHAR tmp1[MAX_DPATH], tmp2[MAX_DPATH];
@@ -571,15 +572,21 @@ void cfgfile_save_options (struct zfile *f, struct uae_prefs *p, int type)
            if (v - JSEM_MICE > 0)
                _stprintf (tmp2, L"mouse%d", v - JSEM_MICE);
        }
-       _stprintf (tmp1, L"joyport%d", i);
-       cfgfile_write (f, tmp1, tmp2);
-       if (jp->name) {
-           _stprintf (tmp1, L"joyportfriendlyname%d", i);
-           cfgfile_write (f, tmp1, jp->name);
-       }
-       if (jp->configname) {
-           _stprintf (tmp1, L"joyportname%d", i);
-           cfgfile_write (f, tmp1, jp->configname);
+       if (i < 2 || jp->id >= 0) {
+           _stprintf (tmp1, L"joyport%d", i);
+           cfgfile_write (f, tmp1, tmp2);
+           if (i < 2 && jp->mode > 0) {
+               _stprintf (tmp1, L"joyport%dmode", i);
+               cfgfile_write (f, tmp1, joyportmodes[jp->mode]);
+           }
+           if (jp->name) {
+               _stprintf (tmp1, L"joyportfriendlyname%d", i);
+               cfgfile_write (f, tmp1, jp->name);
+           }
+           if (jp->configname) {
+               _stprintf (tmp1, L"joyportname%d", i);
+               cfgfile_write (f, tmp1, jp->configname);
+           }
        }
     }
 
@@ -1173,15 +1180,34 @@ static int cfgfile_parse_host (struct uae_prefs *p, TCHAR *option, TCHAR *value)
        inputdevice_joyport_config (p, value, _tcscmp (option, L"joyportfriendlyname0") == 0 ? 0 : 1, 2);
        return 1;
     }
+    if (_tcscmp (option, L"joyportfriendlyname2") == 0 || _tcscmp (option, L"joyportfriendlyname3") == 0) {
+       inputdevice_joyport_config (p, value, _tcscmp (option, L"joyportfriendlyname2") == 0 ? 2 : 3, 2);
+       return 1;
+    }
     if (_tcscmp (option, L"joyportname0") == 0 || _tcscmp (option, L"joyportname1") == 0) {
        inputdevice_joyport_config (p, value, _tcscmp (option, L"joyportname0") == 0 ? 0 : 1, 1);
        return 1;
     }
-
+    if (_tcscmp (option, L"joyportname2") == 0 || _tcscmp (option, L"joyportname3") == 0) {
+       inputdevice_joyport_config (p, value, _tcscmp (option, L"joyportname2") == 0 ? 2 : 3, 1);
+       return 1;
+    }
     if (_tcscmp (option, L"joyport0") == 0 || _tcscmp (option, L"joyport1") == 0) {
        inputdevice_joyport_config (p, value, _tcscmp (option, L"joyport0") == 0 ? 0 : 1, 0);
        return 1;
     }
+    if (_tcscmp (option, L"joyport2") == 0 || _tcscmp (option, L"joyport3") == 0) {
+       inputdevice_joyport_config (p, value, _tcscmp (option, L"joyport2") == 0 ? 2 : 3, 0);
+       return 1;
+    }
+    if (cfgfile_strval (option, value, L"joyport0mode", &p->jports[0].mode, joyportmodes, 0))
+       return 1;
+    if (cfgfile_strval (option, value, L"joyport1mode", &p->jports[1].mode, joyportmodes, 0))
+       return 1;
+    if (cfgfile_strval (option, value, L"joyport2mode", &p->jports[2].mode, joyportmodes, 0))
+       return 1;
+    if (cfgfile_strval (option, value, L"joyport3mode", &p->jports[3].mode, joyportmodes, 0))
+       return 1;
 
     if (cfgfile_string (option, value, L"statefile", tmpbuf, sizeof (tmpbuf) / sizeof (TCHAR))) {
        _tcscpy (savestate_fname, tmpbuf);
@@ -2106,7 +2132,7 @@ static int cfgfile_load_2 (struct uae_prefs *p, const TCHAR *filename, int real,
     }
 
     for (i = 0; i < 4; i++)
-       subst (p->path_floppy, p->df[i], sizeof p->df[i]);
+       subst (p->path_floppy, p->df[i], sizeof p->df[i] / sizeof (TCHAR));
     subst (p->path_rom, p->romfile, sizeof p->romfile / sizeof (TCHAR));
     subst (p->path_rom, p->romextfile, sizeof p->romextfile / sizeof (TCHAR));
 
@@ -3052,8 +3078,12 @@ void default_prefs (struct uae_prefs *p, int type)
 
     memset (&p->jports[0], 0, sizeof (struct jport));
     memset (&p->jports[1], 0, sizeof (struct jport));
+    memset (&p->jports[2], 0, sizeof (struct jport));
+    memset (&p->jports[3], 0, sizeof (struct jport));
     p->jports[0].id = JSEM_MICE;
     p->jports[1].id = JSEM_KBDLAYOUT;
+    p->jports[2].id = -1;
+    p->jports[3].id = -1;
     p->keyboard_lang = KBD_LANG_US;
 
     p->produce_sound = 3;
index 7b0a5f83e752c397a901b963e4efb98a63806a34..b3f5aa9b605766dfa72abcea5e637a6f77e0ba5d 100644 (file)
--- a/custom.c
+++ b/custom.c
@@ -956,7 +956,7 @@ STATIC_INLINE void fetch (int nr, int fm)
 {
     if (nr < toscr_nr_planes) {
 #if NEW_BPL
-       uaecptr p = f_bplpt[nr];
+       uaecptr p = f_bplpt[nr] + bpl_off[nr];
 #else
        uaecptr p = bplpt[nr];
        bplpt[nr] += 2 << fm;
@@ -5266,7 +5266,8 @@ void customreset (int hardreset)
     hsync_counter = 0;
     vsync_counter = 0;
     ciavsync_counter = 0;
-    lightpen_x = lightpen_y = lightpen_triggered = 0;
+    lightpen_x = lightpen_y = -1;
+    lightpen_triggered = 0;
     lightpen_cx = lightpen_cy = -1;
     if (! savestate_state) {
        currprefs.chipset_mask = changed_prefs.chipset_mask;
index dd52e48e0a3e6aea9b9a8b392026cecc323ce5c2..8c6a295d6c796f49fd2ec65a519ecbd15a078c5c 100644 (file)
@@ -68,7 +68,9 @@ extern int inputdevice_get_widget_num (int devnum);
 extern int inputdevice_get_widget_type (int devnum, int num, TCHAR *name);
 
 extern int input_get_default_mouse (struct uae_input_device *uid, int num, int port);
-extern int input_get_default_joystick (struct uae_input_device *uid, int num, int port);
+extern int input_get_default_lightpen (struct uae_input_device *uid, int num, int port);
+extern int input_get_default_joystick (struct uae_input_device *uid, int num, int port, int cd32);
+extern int input_get_default_joystick_analog (struct uae_input_device *uid, int num, int port);
 
 #define DEFEVENT(A, B, C, D, E, F) INPUTEVENT_ ## A,
 enum inputevents {
@@ -153,6 +155,14 @@ extern void inputdevice_tablet_info (int maxx, int maxy, int maxz, int maxax, in
 extern void inputdevice_tablet_strobe (void);
 
 
+#define JSEM_MODE_DEFAULT 0
+#define JSEM_MODE_MOUSE 1
+#define JSEM_MODE_JOYSTICK 2
+#define JSEM_MODE_JOYSTICK_ANALOG 3
+#define JSEM_MODE_MOUSE_CDTV 4
+#define JSEM_MODE_JOYSTICK_CD32 5
+#define JSEM_MODE_LIGHTPEN 6
+
 #define JSEM_KBDLAYOUT 0
 #define JSEM_JOYS 100
 #define JSEM_MICE 200
index 16e541f35869f42c2667a4ea3dcb13c6547450cf..410765e57ea460f70ccf1ef0e05e2aaf5916e7cc 100644 (file)
@@ -9,8 +9,8 @@
 
 extern int get_next_key (void);
 extern int keys_available (void);
-extern void record_key (int);
-extern void record_key_direct (int);
+extern int record_key (int);
+extern int record_key_direct (int);
 extern void keybuf_init (void);
 extern void joystick_setting_changed (void);
 extern int getcapslockstate (void);
index 3dc0257e0e215cbed5aed205fa8e1b3f91e15055..ef1193c8af470ee19132ab892520b67d059b96b8 100644 (file)
@@ -37,12 +37,14 @@ struct uae_input_device {
     TCHAR *custom[MAX_INPUT_DEVICE_EVENTS][MAX_INPUT_SUB_EVENT];
     uae_u16 flags[MAX_INPUT_DEVICE_EVENTS][MAX_INPUT_SUB_EVENT];
     uae_s16 extra[MAX_INPUT_DEVICE_EVENTS][MAX_INPUT_SIMULTANEOUS_KEYS];
-    uae_u8 enabled;
+    uae_s8 enabled;
 };
 
+#define MAX_JPORTS 4
 #define MAX_JPORTNAME 128
 struct jport {
     int id;
+    int mode; // 0=def,1=mouse,2=joy,3=anajoy,4=lightpen
     TCHAR name[MAX_JPORTNAME];
     TCHAR configname[MAX_JPORTNAME];
 };
@@ -348,7 +350,7 @@ struct uae_prefs {
     /* input */
 
     TCHAR inputname[256];
-    struct jport jports[2];
+    struct jport jports[MAX_JPORTS];
     int input_selected_setting;
     int input_joymouse_multiplier;
     int input_joymouse_deadzone;
@@ -370,20 +372,20 @@ struct uae_prefs {
 extern TCHAR optionsfile[];
 extern void save_options (struct zfile *, struct uae_prefs *, int);
 
-extern void cfgfile_write (struct zfile *, TCHAR *option, TCHAR *format,...);
-extern void cfgfile_dwrite (struct zfile *, TCHAR *option, TCHAR *format,...);
-extern void cfgfile_target_write (struct zfile *, TCHAR *option, TCHAR *format,...);
-extern void cfgfile_target_dwrite (struct zfile *, TCHAR *option, TCHAR *format,...);
+extern void cfgfile_write (struct zfile *, const TCHAR *option, const TCHAR *format,...);
+extern void cfgfile_dwrite (struct zfile *, const TCHAR *option, const TCHAR *format,...);
+extern void cfgfile_target_write (struct zfile *, const TCHAR *option, const TCHAR *format,...);
+extern void cfgfile_target_dwrite (struct zfile *, const TCHAR *option, const TCHAR *format,...);
 
-extern void cfgfile_write_bool (struct zfile *f, TCHAR *option, int b);
-extern void cfgfile_dwrite_bool (struct zfile *f, TCHAR *option, int b);
-extern void cfgfile_target_write_bool (struct zfile *f, TCHAR *option, int b);
-extern void cfgfile_target_dwrite_bool (struct zfile *f, TCHAR *option, int b);
+extern void cfgfile_write_bool (struct zfile *f, const TCHAR *option, int b);
+extern void cfgfile_dwrite_bool (struct zfile *f,const  TCHAR *option, int b);
+extern void cfgfile_target_write_bool (struct zfile *f, const TCHAR *option, int b);
+extern void cfgfile_target_dwrite_bool (struct zfile *f, const TCHAR *option, int b);
 
-extern void cfgfile_write_str (struct zfile *f, TCHAR *option, const TCHAR *value);
-extern void cfgfile_dwrite_str (struct zfile *f, TCHAR *option, const TCHAR *value);
-extern void cfgfile_target_write_str (struct zfile *f, TCHAR *option, const TCHAR *value);
-extern void cfgfile_target_dwrite_str (struct zfile *f, TCHAR *option, const TCHAR *value);
+extern void cfgfile_write_str (struct zfile *f, const TCHAR *option, const TCHAR *value);
+extern void cfgfile_dwrite_str (struct zfile *f, const TCHAR *option, const TCHAR *value);
+extern void cfgfile_target_write_str (struct zfile *f, const TCHAR *option, const TCHAR *value);
+extern void cfgfile_target_dwrite_str (struct zfile *f, const TCHAR *option, const TCHAR *value);
 
 extern void cfgfile_backup (const TCHAR *path);
 extern struct uaedev_config_info *add_filesys_config (struct uae_prefs *p, int index,
index c3d85a3f26072a58c5846ae1134e2b832309a5db..32351922dd6a6bea3b044598e783db04c3cf2583 100644 (file)
@@ -41,6 +41,7 @@ extern struct zfile *zfile_dup (struct zfile *f);
 extern struct zfile *zfile_gunzip (struct zfile *z);
 extern int zfile_isdiskimage (const TCHAR *name);
 extern int iszip (struct zfile *z);
+extern int zfile_convertimage (const TCHAR *src, const TCHAR *dst);
 
 #define ZFILE_UNKNOWN 0
 #define ZFILE_CONFIGURATION 1
index 24f36b049e5d1e86863d6e412fdc006c6df8495a..b1db645e5e20de55dabd232ad86e37ab617f0705 100644 (file)
@@ -60,6 +60,9 @@ int inputdevice_logging = 0;
 #define DIR_UP 4
 #define DIR_DOWN 8
 
+#define IE_INVERT 0x80
+#define IE_CDTV 0x100
+
 struct inputevent {
     const TCHAR *confname;
     const TCHAR *name;
@@ -69,7 +72,6 @@ struct inputevent {
     int data;
 };
 
-#define IE_INVERT 0x80
 
 #define JOYBUTTON_1 0 /* fire/left mousebutton */
 #define JOYBUTTON_2 1 /* 2nd/right mousebutton */
@@ -99,6 +101,8 @@ struct inputevent {
 #define AM_CUSTOM 256 /* custom event */
 #define AM_K (AM_KEY|AM_JOY_BUT|AM_MOUSE_BUT|AM_AF) /* generic button/switch */
 
+#define JOYMOUSE_CDTV 8
+
 /* event flags */
 #define ID_FLAG_AUTOFIRE 1
 
@@ -432,6 +436,7 @@ static void copyjport (const struct uae_prefs *src, struct uae_prefs *dst, int n
     _tcscpy (dst->jports[num].configname, src->jports[num].configname);
     _tcscpy (dst->jports[num].name, src->jports[num].name);
     dst->jports[num].id = src->jports[num].id;
+    dst->jports[num].mode = src->jports[num].mode;
 }
 
 static void out_config (struct zfile *f, int id, int num, TCHAR *s1, TCHAR *s2)
@@ -574,7 +579,8 @@ static void write_kbr_config (struct zfile *f, int idnum, int devnum, struct uae
            evt = kbr->eventid[i][j];
            if (custom == NULL && evt <= 0) {
                for (k = j + 1; k < MAX_INPUT_SUB_EVENT; k++) {
-                   if (kbr->eventid[i][k] > 0 || kbr->custom[i][k] != NULL) break;
+                   if (kbr->eventid[i][k] > 0 || kbr->custom[i][k] != NULL)
+                       break;
                }
                if (k == MAX_INPUT_SUB_EVENT)
                    break;
@@ -1983,7 +1989,8 @@ static int check_input_queue (int event)
     int i;
     for (i = 0; i < INPUT_QUEUE_SIZE; i++) {
        iq = &input_queue[i];
-       if (iq->event == event) return i;
+       if (iq->event == event)
+           return i;
     }
     return -1;
 }
@@ -2005,7 +2012,8 @@ static void queue_input_event (int event, int state, int max, int framecnt, int
     } else if (i < 0) {
        for (i = 0; i < INPUT_QUEUE_SIZE; i++) {
            iq = &input_queue[i];
-           if (iq->framecnt < 0) break;
+           if (iq->framecnt < 0)
+               break;
        }
        if (i == INPUT_QUEUE_SIZE) {
            write_log (L"input queue overflow\n");
@@ -2056,9 +2064,10 @@ void inputdevice_do_keyboard (int code, int state)
            memset (keybuf, 0, sizeof (keybuf));
            uae_reset (r);
        }
-       record_key ((uae_u8)((key << 1) | (key >> 7)));
-       if (inputdevice_logging & 1)
-           write_log (L"Amiga key %02X %d\n", key & 0x7f, key >> 7);
+       if (record_key ((uae_u8)((key << 1) | (key >> 7)))) {
+           if (inputdevice_logging & 1)
+               write_log (L"Amiga key %02X %d\n", key & 0x7f, key >> 7);
+       }
        return;
     }
     inputdevice_add_inputcode (code, state);
@@ -2316,11 +2325,33 @@ int handle_input_event (int nr, int state, int max, int autofire)
     {
        case 5: /* lightpen/gun */
        {
-           int delta = state * currprefs.input_mouse_speed / 100;
-           if (ie->data)
-               lightpen_y += delta;
-           else
-               lightpen_x += delta;
+           if (lightpen_x < 0 && lightpen_y < 0) {
+               lightpen_x = gfxvidinfo.width / 2;
+               lightpen_y = gfxvidinfo.height / 2;
+           }
+           if (ie->type == 0) {
+               int delta = 0;
+               if (max == 0)
+                   delta = state * currprefs.input_mouse_speed / 100;
+               else if (state > 0)
+                   delta = currprefs.input_joymouse_speed;
+               else if (state < 0)
+                   delta = -currprefs.input_joymouse_speed;
+               if (ie->data)
+                   lightpen_y += delta;
+               else
+                   lightpen_x += delta;
+           } else {
+               int delta = currprefs.input_joymouse_speed;
+               if (ie->data & DIR_LEFT)
+                   lightpen_x -= delta;
+               if (ie->data & DIR_RIGHT)
+                   lightpen_x += delta;
+               if (ie->data & DIR_UP)
+                   lightpen_y -= delta;
+               if (ie->data & DIR_DOWN)
+                   lightpen_y += delta;
+           }
        }
        break;
        case 1: /* ->JOY1 */
@@ -2358,11 +2389,19 @@ int handle_input_event (int nr, int state, int max, int autofire)
                    delta = state;
                    mouse_deltanoreset[joy][unit] = 0;
                }
+               if (ie->data & IE_CDTV) {
+                   delta = 0;
+                   if (state > 0)
+                       delta = JOYMOUSE_CDTV;
+                   else if (state < 0)
+                       delta = -JOYMOUSE_CDTV;
+               }
                mouse_delta[joy][unit] += delta * ((ie->data & IE_INVERT) ? -1 : 1);
 
            } else if (ie->type & 32) { /* button mouse emulation vertical */
 
-               int speed = currprefs.input_joymouse_speed;
+               int speed = (ie->data & IE_CDTV) ? JOYMOUSE_CDTV : currprefs.input_joymouse_speed;
+
                if (state && (ie->data & DIR_UP)) {
                    mouse_delta[joy][1] = -speed;
                    mouse_deltanoreset[joy][1] = 1;
@@ -2374,7 +2413,8 @@ int handle_input_event (int nr, int state, int max, int autofire)
 
            } else if (ie->type & 64) { /* button mouse emulation horizontal */
 
-               int speed = currprefs.input_joymouse_speed;
+               int speed = (ie->data & IE_CDTV) ? JOYMOUSE_CDTV : currprefs.input_joymouse_speed;
+
                if (state && (ie->data & DIR_LEFT)) {
                    mouse_delta[joy][0] = -speed;
                    mouse_deltanoreset[joy][0] = 1;
@@ -2384,7 +2424,7 @@ int handle_input_event (int nr, int state, int max, int autofire)
                } else
                    mouse_deltanoreset[joy][0] = 0;
 
-           } else if (ie->type & 128) { /* analog (paddle) */
+           } else if (ie->type & 128) { /* analog joystick / paddle */
 
                int deadzone = currprefs.input_joymouse_deadzone * max / 100;
                int unit = ie->data & 0x7f;
@@ -2400,9 +2440,12 @@ int handle_input_event (int nr, int state, int max, int autofire)
                }
                if (ie->data & IE_INVERT)
                    state = -state;
-               state = state / (312 * 100 / currprefs.input_analog_joystick_mult) + (128 * currprefs.input_analog_joystick_mult / 100) + currprefs.input_analog_joystick_offset;
+               state = state * currprefs.input_analog_joystick_mult / max;
+               state += (128 * currprefs.input_analog_joystick_mult / 100) + currprefs.input_analog_joystick_offset;
                if (state < 0)
                    state = 0;
+               if (state > 255)
+                   state = 255;
                joydirpot[joy][unit] = state;
 
            } else {
@@ -2446,6 +2489,8 @@ static void inputdevice_checkconfig (void)
 {
     if (currprefs.jports[0].id != changed_prefs.jports[0].id ||
        currprefs.jports[1].id != changed_prefs.jports[1].id ||
+       currprefs.jports[2].id != changed_prefs.jports[2].id ||
+       currprefs.jports[3].id != changed_prefs.jports[3].id ||
        currprefs.input_selected_setting != changed_prefs.input_selected_setting ||
        currprefs.input_joymouse_multiplier != changed_prefs.input_joymouse_multiplier ||
        currprefs.input_joymouse_deadzone != changed_prefs.input_joymouse_deadzone ||
@@ -2837,7 +2882,7 @@ static void scanevents (struct uae_prefs *p)
        for (k = 0; k < MAX_INPUT_SUB_EVENT; k++) {
            for (j = 0; j < ID_BUTTON_TOTAL; j++) {
 
-               if (joysticks[i].enabled && i < n_joy) {
+               if ((joysticks[i].enabled && i < n_joy) || joysticks[i].enabled < 0) {
                    ei = joysticks[i].eventid[ID_BUTTON_OFFSET + j][k];
                    e = &events[ei];
                    iscd32 (ei);
@@ -2847,7 +2892,7 @@ static void scanevents (struct uae_prefs *p)
                    if (joysticks[i].eventid[ID_BUTTON_OFFSET + j][k] > 0)
                        use_joysticks[i] = 1;
                }
-               if (mice[i].enabled && i < n_mouse) {
+               if ((mice[i].enabled && i < n_mouse) || mice[i].enabled < 0) {
                    ei = mice[i].eventid[ID_BUTTON_OFFSET + j][k];
                    e = &events[ei];
                    iscd32 (ei);
@@ -2862,7 +2907,7 @@ static void scanevents (struct uae_prefs *p)
 
            for (j = 0; j < ID_AXIS_TOTAL; j++) {
 
-               if (joysticks[i].enabled && i < n_joy) {
+               if ((joysticks[i].enabled && i < n_joy) || joysticks[i].enabled < 0) {
                    ei = joysticks[i].eventid[ID_AXIS_OFFSET + j][k];
                    iscd32 (ei);
                    isparport (ei);
@@ -2872,7 +2917,7 @@ static void scanevents (struct uae_prefs *p)
                    if (ei > 0)
                        use_joysticks[i] = 1;
                }
-               if (mice[i].enabled && i < n_mouse) {
+               if ((mice[i].enabled && i < n_mouse) || mice[i].enabled < 0) {
                    ei = mice[i].eventid[ID_AXIS_OFFSET + j][k];
                    iscd32 (ei);
                    isparport (ei);
@@ -2917,78 +2962,138 @@ static void setcd32 (int joy, int n)
 }
 #endif
 
-int compatibility_device[2];
+int compatibility_device[MAX_JPORTS];
 
 static void compatibility_mode (struct uae_prefs *prefs)
 {
     int joy, i;
-    int used[4] = { 0, 0, 0, 0};
+    int used[MAX_INPUT_DEVICES] = { 0 };
 
     prefs->jports[0].name[0] = prefs->jports[1].name[0] = 0;
     prefs->jports[0].configname[0] = prefs->jports[1].configname[0] = 0;
+    prefs->jports[2].name[0] = prefs->jports[3].name[0] = 0;
+    prefs->jports[2].configname[0] = prefs->jports[3].configname[0] = 0;
     compatibility_device[0] = -1;
     compatibility_device[1] = -1;
+    compatibility_device[2] = -1;
+    compatibility_device[3] = -1;
     for (i = 0; i < MAX_INPUT_DEVICES; i++) {
        clear_id (&mice[i]);
        clear_id (&joysticks[i]);
     }
 
-    if ((joy = jsem_ismouse (0, prefs)) >= 0) {
-       input_get_default_mouse (mice, joy, 0);
-       mice[joy].enabled = 1;
-       _tcsncpy (prefs->jports[0].name, idev[IDTYPE_MOUSE].get_friendlyname (joy), MAX_JPORTNAME - 1);
-       _tcsncpy (prefs->jports[0].configname, idev[IDTYPE_MOUSE].get_uniquename (joy), MAX_JPORTNAME - 1);
-    }
-    if ((joy = jsem_ismouse (1, prefs)) >= 0) {
-       input_get_default_mouse (mice, joy, 1);
-       mice[joy].enabled = 1;
-       _tcsncpy (prefs->jports[1].name, idev[IDTYPE_MOUSE].get_friendlyname (joy), MAX_JPORTNAME - 1);
-       _tcsncpy (prefs->jports[1].configname, idev[IDTYPE_MOUSE].get_uniquename (joy), MAX_JPORTNAME - 1);
-    }
-
-    joy = jsem_isjoy (1, prefs);
-    if (joy >= 0) {
-       used[joy] = 1;
-       input_get_default_joystick (joysticks, joy, 1);
-       joysticks[joy].enabled = 1;
-       _tcsncpy (prefs->jports[1].name, idev[IDTYPE_JOYSTICK].get_friendlyname (joy), MAX_JPORTNAME - 1);
-       _tcsncpy (prefs->jports[1].configname, idev[IDTYPE_JOYSTICK].get_uniquename (joy), MAX_JPORTNAME - 1);
-    }
-
-    joy = jsem_isjoy (0, prefs);
-    if (joy >= 0) {
-       used[joy] = 1;
-       input_get_default_joystick (joysticks, joy, 0);
-       joysticks[joy].enabled = 1;
-       _tcsncpy (prefs->jports[0].name, idev[IDTYPE_JOYSTICK].get_friendlyname (joy), MAX_JPORTNAME - 1);
-       _tcsncpy (prefs->jports[0].configname, idev[IDTYPE_JOYSTICK].get_uniquename (joy), MAX_JPORTNAME - 1);
-   }
-
-    for (joy = 0; used[joy]; joy++);
-    if (JSEM_ISANYKBD (0, prefs)) {
-       joysticks[joy].eventid[ID_AXIS_OFFSET +  0][0] = INPUTEVENT_JOY1_HORIZ;
-       joysticks[joy].eventid[ID_AXIS_OFFSET +  1][0] = INPUTEVENT_JOY1_VERT;
-       joysticks[joy].eventid[ID_BUTTON_OFFSET + 0][0] = INPUTEVENT_JOY1_FIRE_BUTTON;
-       joysticks[joy].eventid[ID_BUTTON_OFFSET + 1][0] = INPUTEVENT_JOY1_2ND_BUTTON;
-       joysticks[joy].eventid[ID_BUTTON_OFFSET + 2][0] = INPUTEVENT_JOY1_3RD_BUTTON;
-       joysticks[joy].enabled = 1;
-       used[joy] = 1;
-       compatibility_device[0] = joy;
-    }
-    for (joy = 0; used[joy]; joy++);
-    if (JSEM_ISANYKBD (1, prefs)) {
-       joysticks[joy].eventid[ID_AXIS_OFFSET +  0][0] = INPUTEVENT_JOY2_HORIZ;
-       joysticks[joy].eventid[ID_AXIS_OFFSET +  1][0] = INPUTEVENT_JOY2_VERT;
-       joysticks[joy].eventid[ID_BUTTON_OFFSET + 0][0] = INPUTEVENT_JOY2_FIRE_BUTTON;
-       joysticks[joy].eventid[ID_BUTTON_OFFSET + 1][0] = INPUTEVENT_JOY2_2ND_BUTTON;
-       joysticks[joy].eventid[ID_BUTTON_OFFSET + 2][0] = INPUTEVENT_JOY2_3RD_BUTTON;
-#ifdef CD32
-       if (currprefs.cs_cd32cd)
-           setcd32 (joy, 1);
-#endif
-       joysticks[joy].enabled = 1;
-       used[joy] = 1;
-       compatibility_device[1] = joy;
+    for (i = 0; i < 2; i++) {
+       int mode = prefs->jports[i].mode;
+       if ((joy = jsem_ismouse (i, prefs)) >= 0) {
+           switch (mode)
+           {
+               case JSEM_MODE_DEFAULT:
+               case JSEM_MODE_MOUSE:
+               default:
+               input_get_default_mouse (mice, joy, i);
+               break;
+               case JSEM_MODE_LIGHTPEN:
+               input_get_default_lightpen (mice, joy, i);
+               break;
+           }
+           _tcsncpy (prefs->jports[i].name, idev[IDTYPE_MOUSE].get_friendlyname (joy), MAX_JPORTNAME - 1);
+           _tcsncpy (prefs->jports[i].configname, idev[IDTYPE_MOUSE].get_uniquename (joy), MAX_JPORTNAME - 1);
+           mice[joy].enabled = 1;
+       }
+    }
+    for (i = 1; i >= 0; i--) {
+       int mode = prefs->jports[i].mode;
+       joy = jsem_isjoy (i, prefs);
+       if (joy >= 0) {
+           switch (mode)
+           {
+               case JSEM_MODE_DEFAULT:
+               case JSEM_MODE_JOYSTICK:
+               case JSEM_MODE_JOYSTICK_CD32:
+               default:
+               input_get_default_joystick (joysticks, joy, i, (mode == JSEM_MODE_JOYSTICK_CD32 || (mode == JSEM_MODE_DEFAULT && prefs->cs_cd32cd)));
+               break;
+               case JSEM_MODE_JOYSTICK_ANALOG:
+               input_get_default_joystick_analog (joysticks, joy, i);
+               break;
+               case JSEM_MODE_MOUSE:
+               input_get_default_mouse (joysticks, joy, i);
+               break;
+               case JSEM_MODE_LIGHTPEN:
+               input_get_default_lightpen (joysticks, joy, i);
+               break;
+           }
+           _tcsncpy (prefs->jports[i].name, idev[IDTYPE_JOYSTICK].get_friendlyname (joy), MAX_JPORTNAME - 1);
+           _tcsncpy (prefs->jports[i].configname, idev[IDTYPE_JOYSTICK].get_uniquename (joy), MAX_JPORTNAME - 1);
+           joysticks[joy].enabled = 1;
+           used[joy] = 1;
+       }
+    }
+    for (i = 2; i < 4; i++) {
+       joy = jsem_isjoy (i, prefs);
+       if (joy >= 0) {
+           input_get_default_joystick (joysticks, joy, i, 0);
+           _tcsncpy (prefs->jports[i].name, idev[IDTYPE_JOYSTICK].get_friendlyname (joy), MAX_JPORTNAME - 1);
+           _tcsncpy (prefs->jports[i].configname, idev[IDTYPE_JOYSTICK].get_uniquename (joy), MAX_JPORTNAME - 1);
+           joysticks[joy].enabled = 1;
+           used[joy] = 1;
+       }
+    }
+
+    for (i = 0; i < 2; i++) {
+       int mode = prefs->jports[i].mode;
+       for (joy = 0; used[joy]; joy++);
+       if (JSEM_ISANYKBD (i, prefs)) {
+           switch (mode)
+           {
+               case JSEM_MODE_JOYSTICK:
+               case JSEM_MODE_JOYSTICK_CD32:
+               case JSEM_MODE_DEFAULT:
+               default:
+               joysticks[joy].eventid[ID_AXIS_OFFSET +  0][0] = i ? INPUTEVENT_JOY2_HORIZ : INPUTEVENT_JOY1_HORIZ;
+               joysticks[joy].eventid[ID_AXIS_OFFSET +  1][0] = i ? INPUTEVENT_JOY2_VERT : INPUTEVENT_JOY1_VERT;
+               joysticks[joy].eventid[ID_BUTTON_OFFSET + 0][0] = i ? INPUTEVENT_JOY2_FIRE_BUTTON : INPUTEVENT_JOY1_FIRE_BUTTON;
+               joysticks[joy].eventid[ID_BUTTON_OFFSET + 1][0] = i ? INPUTEVENT_JOY2_2ND_BUTTON : INPUTEVENT_JOY1_2ND_BUTTON;
+               joysticks[joy].eventid[ID_BUTTON_OFFSET + 2][0] = i ? INPUTEVENT_JOY2_3RD_BUTTON : INPUTEVENT_JOY1_3RD_BUTTON;
+               if (mode == JSEM_MODE_JOYSTICK_CD32 || (mode == JSEM_MODE_DEFAULT && prefs->cs_cd32cd))
+                   setcd32 (joy, i);
+               break;
+               case JSEM_MODE_MOUSE_CDTV:
+               joysticks[joy].eventid[ID_AXIS_OFFSET + 0][0] = INPUTEVENT_MOUSE_CDTV_HORIZ;
+               joysticks[joy].eventid[ID_AXIS_OFFSET + 1][0] = INPUTEVENT_MOUSE_CDTV_VERT;
+               joysticks[joy].eventid[ID_BUTTON_OFFSET + 0][0] = INPUTEVENT_JOY1_FIRE_BUTTON;
+               joysticks[joy].eventid[ID_BUTTON_OFFSET + 1][0] = INPUTEVENT_JOY1_2ND_BUTTON;
+               joysticks[joy].eventid[ID_BUTTON_OFFSET + 2][0] = INPUTEVENT_JOY1_3RD_BUTTON;
+               break;
+               case JSEM_MODE_MOUSE:
+               joysticks[joy].eventid[ID_AXIS_OFFSET + 0][0] = i ? INPUTEVENT_MOUSE2_HORIZ : INPUTEVENT_MOUSE1_HORIZ;
+               joysticks[joy].eventid[ID_AXIS_OFFSET + 1][0] = i ? INPUTEVENT_MOUSE2_VERT : INPUTEVENT_MOUSE1_VERT;
+               joysticks[joy].eventid[ID_BUTTON_OFFSET + 0][0] = i ? INPUTEVENT_JOY2_FIRE_BUTTON : INPUTEVENT_JOY1_FIRE_BUTTON;
+               joysticks[joy].eventid[ID_BUTTON_OFFSET + 1][0] = i ? INPUTEVENT_JOY2_2ND_BUTTON : INPUTEVENT_JOY1_2ND_BUTTON;
+               joysticks[joy].eventid[ID_BUTTON_OFFSET + 2][0] = i ? INPUTEVENT_JOY2_3RD_BUTTON : INPUTEVENT_JOY1_3RD_BUTTON;
+               break;
+               case JSEM_MODE_LIGHTPEN:
+               joysticks[joy].eventid[ID_AXIS_OFFSET + 0][0] = INPUTEVENT_LIGHTPEN_HORIZ;
+               joysticks[joy].eventid[ID_AXIS_OFFSET + 1][0] = INPUTEVENT_LIGHTPEN_VERT;
+               joysticks[joy].eventid[ID_BUTTON_OFFSET + 0][0] = i ? INPUTEVENT_JOY2_3RD_BUTTON : INPUTEVENT_JOY1_3RD_BUTTON;
+               break;
+
+           }
+           joysticks[joy].enabled = -1;
+           used[joy] = 1;
+           compatibility_device[i] = joy;
+       }
+    }
+    for (i = 2; i < 4; i++) {
+       for (joy = 0; used[joy]; joy++);
+       if (JSEM_ISANYKBD (i, prefs)) {
+           joysticks[joy].eventid[ID_AXIS_OFFSET +  0][0] = i == 3 ? INPUTEVENT_PAR_JOY2_HORIZ : INPUTEVENT_PAR_JOY1_HORIZ;
+           joysticks[joy].eventid[ID_AXIS_OFFSET +  1][0] = i == 3 ? INPUTEVENT_PAR_JOY2_VERT : INPUTEVENT_PAR_JOY1_VERT;
+           joysticks[joy].eventid[ID_BUTTON_OFFSET + 0][0] = i == 3 ? INPUTEVENT_PAR_JOY2_FIRE_BUTTON : INPUTEVENT_PAR_JOY1_FIRE_BUTTON;
+           joysticks[joy].enabled = -1;
+           used[joy] = 1;
+           compatibility_device[i] = joy;
+       }
     }
 }
 
@@ -3071,15 +3176,15 @@ void inputdevice_updateconfig (struct uae_prefs *prefs)
 {
     int i;
 
-    int j = jsem_isjoy (1, &currprefs);
-    int m = jsem_ismouse (1, &currprefs);
-    int k = jsem_iskbdjoy (1, &currprefs);
-
     copyjport (&changed_prefs, &currprefs, 0);
     copyjport (&changed_prefs, &currprefs, 1);
+    copyjport (&changed_prefs, &currprefs, 2);
+    copyjport (&changed_prefs, &currprefs, 3);
 #ifdef RETROPLATFORM
     rp_input_change (0);
     rp_input_change (1);
+    rp_input_change (2);
+    rp_input_change (3);
 #endif
 
     joybutton[0] = joybutton[1] = 0;
@@ -3124,11 +3229,12 @@ void inputdevice_updateconfig (struct uae_prefs *prefs)
 
     scanevents (prefs);
 
+#if 0
 #ifdef CD32
     if (currprefs.input_selected_setting == 0 && currprefs.cs_cd32cd)
        cd32_pad_enabled[1] = 1;
 #endif
-
+#endif
 }
 
 /* called when devices get inserted or removed */
@@ -3136,9 +3242,9 @@ void inputdevice_devicechange (struct uae_prefs *prefs)
 {
     int acc = input_acquired;
     int i, idx;
-    TCHAR *jports[2];
+    TCHAR *jports[MAX_JPORTS];
 
-    for (i = 0; i < 2; i++) {
+    for (i = 0; i < MAX_JPORTS; i++) {
        jports[i] = 0;
        idx = inputdevice_getjoyportdevice (prefs->jports[i].id) - JSEM_LASTKBD;
        if (idx >= 0) {
@@ -3159,7 +3265,7 @@ void inputdevice_devicechange (struct uae_prefs *prefs)
     matchdevices (&idev[IDTYPE_JOYSTICK], joysticks);
     matchdevices (&idev[IDTYPE_KEYBOARD], keyboards);
 
-    for (i = 0; i < 2; i++) {
+    for (i = 0; i < MAX_JPORTS; i++) {
        freejport (prefs, i);
        if (jports[i])
            inputdevice_joyport_config (prefs, jports[i], i, 2);
@@ -3223,8 +3329,8 @@ void inputdevice_default_prefs (struct uae_prefs *p)
     p->input_joymouse_deadzone = 33;
     p->input_joystick_deadzone = 33;
     p->input_joymouse_speed = 10;
-    p->input_analog_joystick_mult = 100;
-    p->input_analog_joystick_offset = 0;
+    p->input_analog_joystick_mult = 15;
+    p->input_analog_joystick_offset = -1;
     p->input_mouse_speed = 100;
     p->input_autofire_framecnt = 10;
     for (i = 0; i <= MAX_INPUT_SETTINGS; i++) {
@@ -3232,7 +3338,7 @@ void inputdevice_default_prefs (struct uae_prefs *p)
        for (j = 0; j < MAX_INPUT_DEVICES; j++) {
            if (input_get_default_mouse (p->mouse_settings[i], j, j & 1))
                p->mouse_settings[i]->enabled = 1;
-           if (input_get_default_joystick (p->joystick_settings[i], j, j & 1))
+           if (input_get_default_joystick (p->joystick_settings[i], j, j & 1, 0))
                p->joystick_settings[i]->enabled = 1;
        }
     }
@@ -3770,7 +3876,8 @@ static int ignoreoldinput (int joy)
     if (!use_joysticks[joy])
        return 0;
     if (currprefs.input_selected_setting == 0) {
-       if (jsem_isjoy (0, &currprefs) != joy && jsem_isjoy (1, &currprefs) != joy)
+       if (jsem_isjoy (0, &currprefs) != joy && jsem_isjoy (1, &currprefs) != joy &&
+           jsem_isjoy (2, &currprefs) != joy && jsem_isjoy (3, &currprefs) != joy)
            return 1;
     }
     return 0;
@@ -3787,16 +3894,16 @@ void do_fake_joystick (int nr, int *fake)
     id2 = &joysticks2[nr];
 
     axis = 0;
-    state = fake[1] ? -100 : (fake[2] ? 100 : 0);
+    state = fake[1] ? -1 : (fake[2] ? 1 : 0);
     for (i = 0; i < MAX_INPUT_SUB_EVENT; i++)
-       handle_input_event (id1->eventid[ID_AXIS_OFFSET + axis][i], state, 100,
+       handle_input_event (id1->eventid[ID_AXIS_OFFSET + axis][i], state, 1,
            id1->flags[ID_AXIS_OFFSET + axis][i]);
     id2->states[axis] = state;
 
     axis = 1;
-    state = fake[0] ? -100 : (fake[3] ? 100 : 0);
+    state = fake[0] ? -1 : (fake[3] ? 1 : 0);
     for (i = 0; i < MAX_INPUT_SUB_EVENT; i++)
-       handle_input_event (id1->eventid[ID_AXIS_OFFSET + axis][i], state, 100,
+       handle_input_event (id1->eventid[ID_AXIS_OFFSET + axis][i], state, 1,
            id1->flags[ID_AXIS_OFFSET + axis][i]);
     id2->states[axis] = state;
 
@@ -3967,8 +4074,6 @@ void warpmode (int mode)
 {
     int fr, fr2;
     
-    write_log (L"%d %d %d\n", currprefs.gfx_framerate, turbo_emulation, mode);
-
     fr = currprefs.gfx_framerate;
     if (fr == 0)
        fr = -1;
@@ -4052,7 +4157,7 @@ int inputdevice_joyport_config (struct uae_prefs *p, TCHAR *value, int portnum,
        case 2:
        {
            int i, j;
-           for (j = 0; j < 2; j++) {
+           for (j = 0; j < MAX_JPORTS; j++) {
                struct inputdevice_functions *idf;
                int type = IDTYPE_MOUSE;
                int idnum = JSEM_MICE;
@@ -4066,6 +4171,7 @@ int inputdevice_joyport_config (struct uae_prefs *p, TCHAR *value, int portnum,
                    TCHAR *name2 = idf->get_uniquename (i);
                    if ((name1 && !_tcscmp (name1, value)) || (name2 && !_tcscmp (name2, value))) {
                        p->jports[portnum].id = idnum + i;
+                       p->jports[portnum].mode = 0;
                        return 1;
                    }
                }
@@ -4105,6 +4211,7 @@ int inputdevice_joyport_config (struct uae_prefs *p, TCHAR *value, int portnum,
                }
                if (got == 2) {
                    p->jports[portnum].id = start;
+                   p->jports[portnum].mode = 0;
                    return 1;
                }
            }
index cd47279f53778dc58e18d96f98a73801854bf0c9..198e0046a73ed4efdb1517c22ca67010edd53cee 100644 (file)
@@ -18,6 +18,13 @@ DEFEVENT(MOUSE1_RIGHT,L"Mouse1 Right",AM_KEY|AM_JOY_BUT|AM_MOUSE_BUT,64,1,DIR_RI
 
 DEFEVENT(MOUSE1_WHEEL,L"Mouse1 Wheel",AM_MOUSE_AXIS|AM_JOY_AXIS,8,1,2)
 
+DEFEVENT(MOUSE_CDTV_HORIZ,L"CDTV Mouse Horizontal",AM_JOY_AXIS,8,1,0|IE_CDTV)
+DEFEVENT(MOUSE_CDTV_VERT,L"CDTV Mouse Vertical",AM_JOY_AXIS,8,1,1|IE_CDTV)
+DEFEVENT(MOUSE_CDTV_UP,L"CDTV Mouse Up",AM_KEY|AM_JOY_BUT|AM_MOUSE_BUT,32,1,DIR_UP|IE_CDTV)
+DEFEVENT(MOUSE_CDTV_DOWN,L"CDTV Mouse Down",AM_KEY|AM_JOY_BUT|AM_MOUSE_BUT,32,1,DIR_DOWN|IE_CDTV)
+DEFEVENT(MOUSE_CDTV_LEFT,L"CDTV Mouse Left",AM_KEY|AM_JOY_BUT|AM_MOUSE_BUT,64,1,DIR_LEFT|IE_CDTV)
+DEFEVENT(MOUSE_CDTV_RIGHT,L"CDTV Mouse Right",AM_KEY|AM_JOY_BUT|AM_MOUSE_BUT,64,1,DIR_RIGHT|IE_CDTV)
+
 DEFEVENT(JOY1_HORIZ,L"Joy1 Horizontal",AM_JOY_AXIS,0,1,DIR_LEFT|DIR_RIGHT)
 DEFEVENT(JOY1_VERT,L"Joy1 Vertical",AM_JOY_AXIS,0,1,DIR_UP|DIR_DOWN)
 DEFEVENT(JOY1_HORIZ_POT,L"Joy1 Horizontal (Analog)",AM_JOY_AXIS,128,1,1)
@@ -90,8 +97,12 @@ DEFEVENT(JOY2_CD32_YELLOW,L"Joy2 CD32 Yellow",AM_K,4,2,JOYBUTTON_CD32_YELLOW)
 DEFEVENT(JOY2_CD32_RED,L"Joy2 CD32 Red",AM_K,4,2,JOYBUTTON_CD32_RED)
 DEFEVENT(JOY2_CD32_BLUE,L"Joy2 CD32 Blue",AM_K,4,2,JOYBUTTON_CD32_BLUE)
 
-DEFEVENT(LIGHTPEN_HORIZ,L"Lightpen Horizontal",AM_MOUSE_AXIS,0,5,0)
-DEFEVENT(LIGHTPEN_VERT,L"Lightpen Vertical",AM_MOUSE_AXIS,0,5,1)
+DEFEVENT(LIGHTPEN_HORIZ,L"Lightpen Horizontal",AM_MOUSE_AXIS|AM_JOY_AXIS,0,5,0)
+DEFEVENT(LIGHTPEN_VERT,L"Lightpen Vertical",AM_MOUSE_AXIS|AM_JOY_AXIS,0,5,1)
+DEFEVENT(LIGHTPEN_LEFT,L"Lightpen Left",AM_K,1,5,DIR_LEFT)
+DEFEVENT(LIGHTPEN_RIGHT,L"Lightpen Right",AM_K,1,5,DIR_RIGHT)
+DEFEVENT(LIGHTPEN_UP,L"Lightpen Up",AM_K,1,5,DIR_UP)
+DEFEVENT(LIGHTPEN_DOWN,L"Lightpen Down",AM_K,1,5,DIR_DOWN)
 
 /* parallel port joystick adapter */
 
index f705fa12c742848a5b2c53f408887bb072f75c35..1fad546747eb9433f05e8101dd6c5ed329887999 100644 (file)
--- a/keybuf.c
+++ b/keybuf.c
 #include "custom.h"
 #include "savestate.h"
 
-static int fakestate[2][7] = { {0},{0} };
+static int fakestate[MAX_JPORTS][7] = { {0},{0} };
 
 static int *fs_np, *fs_ck, *fs_se;
 #ifdef ARCADIA
 static int *fs_xa1, *fs_xa2;
 #endif
 
-/* Not static so the DOS code can mess with them */
-int kpb_first, kpb_last;
+static int kpb_first, kpb_last;
 
 static int keybuf[256];
 
@@ -56,17 +55,17 @@ int get_next_key (void)
 static void do_fake (int nr)
 {
     int *fake = fakestate[nr];
-    do_fake_joystick(nr, fake);
+    do_fake_joystick (nr, fake);
 }
 
-void record_key (int kc)
+int record_key (int kc)
 {
     if (input_recording < 0 || pause_emulation)
-       return;
-    record_key_direct (kc);
+       return 0;
+    return record_key_direct (kc);
 }
 
-void record_key_direct (int kc)
+int record_key_direct (int kc)
 {
     int fs = 0;
     int kpb_next = kpb_first + 1;
@@ -78,7 +77,7 @@ void record_key_direct (int kc)
        kpb_next = 0;
     if (kpb_next == kpb_last) {
        write_log (L"Keyboard buffer overrun. Congratulations.\n");
-       return;
+       return 0;
     }
 
     if (fs_np != 0) {
@@ -140,7 +139,11 @@ void record_key_direct (int kc)
            do_fake (0);
        if (JSEM_ISANYKBD (1, &currprefs))
            do_fake (1);
-       return;
+       if (JSEM_ISANYKBD (2, &currprefs))
+           do_fake (2);
+       if (JSEM_ISANYKBD (3, &currprefs))
+           do_fake (3);
+       return 0;
     } else {
        if ((kc >> 1) == AK_RCTRL) {
            kc ^= AK_RCTRL << 1;
@@ -185,41 +188,32 @@ void record_key_direct (int kc)
 
     keybuf[kpb_first] = kc;
     kpb_first = kpb_next;
+    return 1;
 }
 
 void joystick_setting_changed (void)
 {
+    int i;
+
     fs_np = fs_ck = fs_se = 0;
 #ifdef ARCADIA
     fs_xa1 = fs_xa2 = 0;
 #endif
 
-    if (JSEM_ISNUMPAD (0, &currprefs))
-       fs_np = fakestate[0];
-    else if (JSEM_ISNUMPAD (1, &currprefs))
-       fs_np = fakestate[1];
-
-    if (JSEM_ISCURSOR (0, &currprefs))
-       fs_ck = fakestate[0];
-    else if (JSEM_ISCURSOR (1, &currprefs))
-       fs_ck = fakestate[1];
-
-    if (JSEM_ISSOMEWHEREELSE (0, &currprefs))
-       fs_se = fakestate[0];
-    else if (JSEM_ISSOMEWHEREELSE (1, &currprefs))
-       fs_se = fakestate[1];
-
+    for (i = 0; i < MAX_JPORTS; i++) {
+       if (JSEM_ISNUMPAD (i, &currprefs))
+           fs_np = fakestate[i];
+        if (JSEM_ISCURSOR (i, &currprefs))
+           fs_ck = fakestate[i];
+       if (JSEM_ISSOMEWHEREELSE (i, &currprefs))
+           fs_se = fakestate[i];
 #ifdef ARCADIA
-    if (JSEM_ISXARCADE1 (0, &currprefs))
-       fs_xa1 = fakestate[0];
-    else if (JSEM_ISXARCADE1 (1, &currprefs))
-       fs_xa1 = fakestate[1];
-
-    if (JSEM_ISXARCADE2 (0, &currprefs))
-       fs_xa2 = fakestate[0];
-    else if (JSEM_ISXARCADE2 (1, &currprefs))
-       fs_xa2 = fakestate[1];
+       if (JSEM_ISXARCADE1 (i, &currprefs))
+           fs_xa1 = fakestate[i];
+       if (JSEM_ISXARCADE2 (i, &currprefs))
+           fs_xa2 = fakestate[i];
 #endif
+    }
 }
 
 void keybuf_init (void)
index 179dfb826871ef2eb1d29673bae67782da853f4d..88e4702d224f2fadababf56b17ccbfc5c33e16df 100644 (file)
--- a/memory.c
+++ b/memory.c
@@ -3891,43 +3891,50 @@ void restore_a3000hram (int len, size_t filepos)
 uae_u8 *restore_rom (uae_u8 *src)
 {
     uae_u32 crc32, mem_start, mem_size, mem_type, version;
-    TCHAR *s;
-    int i;
+    TCHAR *s, *romn;
+    int i, crcdet;
 
     mem_start = restore_u32 ();
     mem_size = restore_u32 ();
     mem_type = restore_u32 ();
     version = restore_u32 ();
     crc32 = restore_u32 ();
-    s = restore_string ();
+    romn = restore_string ();
+    crcdet = 0;
     for (i = 0; i < romlist_cnt; i++) {
        if (rl[i].rd->crc32 == crc32 && crc32) {
            switch (mem_type)
            {
                case 0:
-               _tcsncmp (changed_prefs.romfile, rl[i].path, 255);
+               _tcsncpy (changed_prefs.romfile, rl[i].path, 255);
                break;
                case 1:
-               _tcsncmp (changed_prefs.romextfile, rl[i].path, 255);
+               _tcsncpy (changed_prefs.romextfile, rl[i].path, 255);
                break;
            }
+           write_log (L"ROM '%s' = '%s'\n", romn, rl[i].path);
+           crcdet = 1;
            break;
        }
     }
-    xfree (s);
     s = restore_string ();
-    if (zfile_exists (s)) {
+    if (!crcdet && zfile_exists (s)) {
        switch (mem_type)
        {
            case 0:
-           _tcsncmp (changed_prefs.romfile, s, 255);
+           _tcsncpy (changed_prefs.romfile, s, 255);
            break;
            case 1:
-           _tcsncmp (changed_prefs.romextfile, s, 255);
+           _tcsncpy (changed_prefs.romextfile, s, 255);
            break;
        }
+       write_log (L"ROM detected (path) as '%s'\n", s);
+       crcdet = 1;
     }
     xfree (s);
+    if (!crcdet)
+       write_log (L"WARNING: ROM '%s' not found!\n", romn);
+    xfree (romn);
     return src;
 }
 
index f88412b860af23420b22bb28e2265376f22bf49a..67f5bbd1580e9ecba723b66cb7d5286387e3d371 100644 (file)
@@ -2528,30 +2528,61 @@ int input_get_default_mouse (struct uae_input_device *uid, int i, int port)
     return 0;
 }
 
-int input_get_default_joystick (struct uae_input_device *uid, int i, int port)
+int input_get_default_lightpen (struct uae_input_device *uid, int i, int port)
+{
+    struct didata *did;
+
+    if (i >= num_mouse)
+       return 0;
+    did = &di_mouse[i];
+    if (did->wininput)
+       port = 0;
+    uid[i].eventid[ID_AXIS_OFFSET + 0][0] = INPUTEVENT_LIGHTPEN_HORIZ;
+    uid[i].eventid[ID_AXIS_OFFSET + 1][0] = INPUTEVENT_LIGHTPEN_VERT;
+    uid[i].eventid[ID_BUTTON_OFFSET + 0][0] = port ? INPUTEVENT_JOY2_3RD_BUTTON : INPUTEVENT_JOY1_3RD_BUTTON;
+    if (i == 0)
+       return 1;
+    return 0;
+}
+
+int input_get_default_joystick (struct uae_input_device *uid, int i, int port, int cd32)
 {
     int j;
     struct didata *did;
+    int h, v;
 
     if (i >= num_joystick)
        return 0;
     did = &di_joystick[i];
-    uid[i].eventid[ID_AXIS_OFFSET + 0][0] = port ? INPUTEVENT_JOY2_HORIZ : INPUTEVENT_JOY1_HORIZ;
-    uid[i].eventid[ID_AXIS_OFFSET + 1][0] = port ? INPUTEVENT_JOY2_VERT : INPUTEVENT_JOY1_VERT;
-    uid[i].eventid[ID_BUTTON_OFFSET + 0][0] = port ? INPUTEVENT_JOY2_FIRE_BUTTON : INPUTEVENT_JOY1_FIRE_BUTTON;
-    if (isrealbutton (did, 1))
-       uid[i].eventid[ID_BUTTON_OFFSET + 1][0] = port ? INPUTEVENT_JOY2_2ND_BUTTON : INPUTEVENT_JOY1_2ND_BUTTON;
-    if (isrealbutton (did, 2))
-       uid[i].eventid[ID_BUTTON_OFFSET + 2][0] = port ? INPUTEVENT_JOY2_3RD_BUTTON : INPUTEVENT_JOY1_3RD_BUTTON;
+    if (port >= 2) {
+       h = port == 3 ? INPUTEVENT_PAR_JOY2_HORIZ : INPUTEVENT_PAR_JOY1_HORIZ;
+       v = port == 3 ? INPUTEVENT_PAR_JOY2_VERT : INPUTEVENT_PAR_JOY1_VERT;
+    } else {
+       h = port ? INPUTEVENT_JOY2_HORIZ : INPUTEVENT_JOY1_HORIZ;;
+       v = port ? INPUTEVENT_JOY2_VERT : INPUTEVENT_JOY1_VERT;
+    }
+    uid[i].eventid[ID_AXIS_OFFSET + 0][0] = h;
+    uid[i].eventid[ID_AXIS_OFFSET + 1][0] = v;
+
+    if (port >= 2) {
+       uid[i].eventid[ID_BUTTON_OFFSET + 0][0] = port == 3 ? INPUTEVENT_PAR_JOY2_FIRE_BUTTON : INPUTEVENT_PAR_JOY1_FIRE_BUTTON;
+    } else {
+       uid[i].eventid[ID_BUTTON_OFFSET + 0][0] = port ? INPUTEVENT_JOY2_FIRE_BUTTON : INPUTEVENT_JOY1_FIRE_BUTTON;
+       if (isrealbutton (did, 1))
+           uid[i].eventid[ID_BUTTON_OFFSET + 1][0] = port ? INPUTEVENT_JOY2_2ND_BUTTON : INPUTEVENT_JOY1_2ND_BUTTON;
+       if (isrealbutton (did, 2))
+           uid[i].eventid[ID_BUTTON_OFFSET + 2][0] = port ? INPUTEVENT_JOY2_3RD_BUTTON : INPUTEVENT_JOY1_3RD_BUTTON;
+    }
+
     for (j = 2; j < MAX_MAPPINGS - 1; j++) {
        int am = did->axismappings[j];
        if (am == DIJOFS_POV(0) || am == DIJOFS_POV(1) || am == DIJOFS_POV(2) || am == DIJOFS_POV(3)) {
-           uid[i].eventid[ID_AXIS_OFFSET + j + 0][0] = port ? INPUTEVENT_JOY2_HORIZ : INPUTEVENT_JOY1_HORIZ;
-           uid[i].eventid[ID_AXIS_OFFSET + j + 1][0] = port ? INPUTEVENT_JOY2_VERT : INPUTEVENT_JOY1_VERT;
+           uid[i].eventid[ID_AXIS_OFFSET + j + 0][0] = h;
+           uid[i].eventid[ID_AXIS_OFFSET + j + 1][0] = v;
            j++;
        }
     }
-    if (currprefs.cs_cd32cd) {
+    if (cd32) {
        uid[i].eventid[ID_BUTTON_OFFSET + 0][0] = port ? INPUTEVENT_JOY2_CD32_RED : INPUTEVENT_JOY1_CD32_RED;
        if (isrealbutton (did, 1))
            uid[i].eventid[ID_BUTTON_OFFSET + 1][0] = port ? INPUTEVENT_JOY2_CD32_BLUE : INPUTEVENT_JOY1_CD32_BLUE;
@@ -2570,3 +2601,34 @@ int input_get_default_joystick (struct uae_input_device *uid, int i, int port)
        return 1;
     return 0;
 }
+
+int input_get_default_joystick_analog (struct uae_input_device *uid, int i, int port)
+{
+    int j;
+    struct didata *did;
+
+    if (i >= num_joystick)
+       return 0;
+    did = &di_joystick[i];
+    uid[i].eventid[ID_AXIS_OFFSET + 0][0] = port ? INPUTEVENT_JOY2_HORIZ_POT : INPUTEVENT_JOY1_HORIZ_POT;
+    uid[i].eventid[ID_AXIS_OFFSET + 1][0] = port ? INPUTEVENT_JOY2_VERT_POT : INPUTEVENT_JOY1_VERT_POT;
+    uid[i].eventid[ID_BUTTON_OFFSET + 0][0] = port ? INPUTEVENT_JOY2_LEFT : INPUTEVENT_JOY1_LEFT;
+    if (isrealbutton (did, 1))
+       uid[i].eventid[ID_BUTTON_OFFSET + 1][0] = port ? INPUTEVENT_JOY2_RIGHT : INPUTEVENT_JOY1_RIGHT;
+    if (isrealbutton (did, 2))
+       uid[i].eventid[ID_BUTTON_OFFSET + 2][0] = port ? INPUTEVENT_JOY2_UP : INPUTEVENT_JOY1_UP;
+    if (isrealbutton (did, 3))
+       uid[i].eventid[ID_BUTTON_OFFSET + 3][0] = port ? INPUTEVENT_JOY2_DOWN : INPUTEVENT_JOY1_DOWN;
+    for (j = 2; j < MAX_MAPPINGS - 1; j++) {
+       int am = did->axismappings[j];
+       if (am == DIJOFS_POV(0) || am == DIJOFS_POV(1) || am == DIJOFS_POV(2) || am == DIJOFS_POV(3)) {
+           uid[i].eventid[ID_AXIS_OFFSET + j + 0][0] = port ? INPUTEVENT_JOY2_HORIZ_POT : INPUTEVENT_JOY1_HORIZ_POT;
+           uid[i].eventid[ID_AXIS_OFFSET + j + 1][0] = port ? INPUTEVENT_JOY2_VERT_POT : INPUTEVENT_JOY1_VERT_POT;
+           j++;
+       }
+    }
+    if (i == 0)
+       return 1;
+    return 0;
+}
+
index 6aa654a0cc16a850b9d90d651a6bf02fbde32f1e..38045c3af3a00d6d9b951c95a89b6601494ca5c0 100644 (file)
@@ -598,6 +598,7 @@ static int recycle (const TCHAR *name)
        {
            case 0xb7: //DE_ERROR_MAX
            case 0x7c: //DE_INVALIDFILES
+           case 0x402: // "unknown error"
            v = ERROR_FILE_NOT_FOUND;
            break;
            case 0x75: //DE_OPCANCELLED:
index 1cfb6a198766766142a072046ffe9481c554c419..a8f4d5d1cd9db3ee43c7311194b2bfba8b10f7fc 100644 (file)
 #define IDS_SB_CUSTOMEVENT              335
 #define IDS_FLOPPYTYPE35DDPC            336
 #define IDS_FLOPPYTYPE35HDPC            337
+#define IDS_JOYMODE_DEFAULT             338
+#define IDS_JOYMODE_MOUSE               339
+#define IDS_JOYMODE_JOYSTICK            340
+#define IDS_JOYMODE_JOYSTICKANALOG      341
+#define IDS_JOYMODE_LIGHTPEN            342
+#define IDS_JOYMODE_MOUSE_CDTV          343
+#define IDS_JOYMODE_JOYSTICK_CD32       344
+#define IDS_TABLET_BOTH_CURSORS         345
+#define IDS_TABLET_NATIVE_CURSOR        346
+#define IDS_TABLET_HOST_CURSOR          347
 #define IDS_QS_MODELS                   1000
 #define IDS_QS_MODEL_A500               1001
 #define IDS_QS_MODEL_A500P              1002
 #define IDC_SCREENMODE_RTG              1027
 #define IDC_MBMEM1                      1028
 #define IDC_PORT_TABLET_CURSOR          1028
+#define IDC_PORT0_JOYSMODE              1029
 #define IDC_SLOWMEM                     1030
+#define IDC_PORT1_JOYSMODE              1030
 #define IDC_MBMEM2                      1031
+#define IDC_PORT2_JOYS                  1031
+#define IDC_PORT4_JOYS                  1032
+#define IDC_PORT3_JOYS                  1032
 #define IDC_PARALLEL                    1033
 #define IDC_JULIAN                      1040
 #define IDC_FASTTEXT                    1043
 #ifndef APSTUDIO_READONLY_SYMBOLS
 #define _APS_NO_MFC                     1
 #define _APS_3D_CONTROLS                     1
-#define _APS_NEXT_RESOURCE_VALUE        335
+#define _APS_NEXT_RESOURCE_VALUE        345
 #define _APS_NEXT_COMMAND_VALUE         40045
 #define _APS_NEXT_CONTROL_VALUE         1790
 #define _APS_NEXT_SYMED_VALUE           101
index ce35a260b9460a14309ee5dc60c71c44124a50fb..ef57b00daee22b233ecc6458da93346ba34788fc 100644 (file)
@@ -369,26 +369,31 @@ BEGIN
     CONTROL         "uaeserial.device",IDC_UAESERIAL,"Button",BS_AUTOCHECKBOX | BS_VCENTER | WS_TABSTOP,200,123,78,12\r
 END\r
 \r
-IDD_GAMEPORTS DIALOGEX 0, 0, 300, 178\r
+IDD_GAMEPORTS DIALOGEX 0, 0, 300, 236\r
 STYLE DS_LOCALEDIT | DS_SETFONT | DS_3DLOOK | DS_CONTROL | WS_CHILD\r
 FONT 8, "MS Sans Serif", 0, 0, 0x1\r
 BEGIN\r
     COMBOBOX        IDC_PORT0_JOYS,45,29,241,130,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP\r
-    COMBOBOX        IDC_PORT1_JOYS,45,50,241,130,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP\r
-    PUSHBUTTON      "Swap ports",IDC_SWAP,211,69,75,14\r
+    COMBOBOX        IDC_PORT1_JOYS,45,65,241,130,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP\r
+    PUSHBUTTON      "Swap port 0 and 1",IDC_SWAP,194,101,93,14\r
     RTEXT           "Port 0:",IDC_STATIC,11,28,25,15,SS_CENTERIMAGE\r
-    RTEXT           "Port 1:",IDC_STATIC,11,49,25,15,SS_CENTERIMAGE\r
-    LTEXT           "X-Arcade layout information []#1",IDC_STATIC,16,68,106,15,SS_NOTIFY | SS_CENTERIMAGE\r
-    GROUPBOX        "Mouse and Joystick settings",IDC_STATIC,4,15,292,76\r
-    GROUPBOX        "Mouse extra settings",IDC_STATIC,4,92,292,76\r
-    RTEXT           "Mouse speed:",IDC_STATIC,17,106,56,10,SS_CENTERIMAGE\r
-    EDITTEXT        IDC_INPUTSPEEDM,87,106,25,12,ES_NUMBER\r
-    CONTROL         "Install virtual mouse driver",IDC_PORT_TABLET,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,167,118,120,10\r
+    RTEXT           "Port 1:",IDC_STATIC,11,64,25,15,SS_CENTERIMAGE\r
+    LTEXT           "X-Arcade layout information []#1",IDC_STATIC,64,87,106,15,SS_NOTIFY | SS_CENTERIMAGE\r
+    GROUPBOX        "Mouse and Joystick settings",IDC_STATIC,4,15,292,148\r
+    GROUPBOX        "Mouse extra settings",IDC_STATIC,4,165,292,69\r
+    RTEXT           "Mouse speed:",IDC_STATIC,17,180,56,10,SS_CENTERIMAGE\r
+    EDITTEXT        IDC_INPUTSPEEDM,87,180,25,12,ES_NUMBER\r
+    CONTROL         "Install virtual mouse driver",IDC_PORT_TABLET,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,167,187,120,10\r
     CONTROL         "Full tablet input emulation",IDC_PORT_TABLET_FULL,\r
-                    "Button",BS_AUTOCHECKBOX | WS_TABSTOP,167,151,121,10\r
-    CONTROL         "Magic Mouse",IDC_PORT_MOUSETRICK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,167,106,119,10\r
-    COMBOBOX        IDC_PORT_TABLET_CURSOR,167,132,119,130,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP\r
-    RTEXT           "Magic Mouse cursor mode:",IDC_STATIC,17,135,138,10,SS_CENTERIMAGE\r
+                    "Button",BS_AUTOCHECKBOX | WS_TABSTOP,167,220,121,10\r
+    CONTROL         "Magic Mouse",IDC_PORT_MOUSETRICK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,167,175,119,10\r
+    COMBOBOX        IDC_PORT_TABLET_CURSOR,167,201,119,130,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP\r
+    RTEXT           "Magic Mouse cursor mode:",IDC_STATIC,17,204,138,10,SS_CENTERIMAGE\r
+    COMBOBOX        IDC_PORT0_JOYSMODE,195,47,91,130,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP\r
+    COMBOBOX        IDC_PORT1_JOYSMODE,195,82,91,130,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP\r
+    COMBOBOX        IDC_PORT2_JOYS,45,125,241,130,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP\r
+    LTEXT           "Parallel port joystick adapter",IDC_STATIC,10,105,147,15,SS_CENTERIMAGE\r
+    COMBOBOX        IDC_PORT3_JOYS,45,143,241,130,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP\r
 END\r
 \r
 IDD_CONTRIBUTORS DIALOGEX 0, 0, 411, 242\r
@@ -1429,6 +1434,16 @@ STRINGTABLE
 BEGIN\r
     IDS_FLOPPYTYPE35DDPC    "3.5"" DD (PC)"\r
     IDS_FLOPPYTYPE35HDPC    "3.5"" HD (PC)"\r
+    IDS_JOYMODE_DEFAULT     "Default"\r
+    IDS_JOYMODE_MOUSE       "Mouse"\r
+    IDS_JOYMODE_JOYSTICK    "Joystick"\r
+    IDS_JOYMODE_JOYSTICKANALOG "Analog joystick"\r
+    IDS_JOYMODE_LIGHTPEN    "Light pen"\r
+    IDS_JOYMODE_MOUSE_CDTV  "CDTV remote mouse"\r
+    IDS_JOYMODE_JOYSTICK_CD32 "CD32 pad"\r
+    IDS_TABLET_BOTH_CURSORS "Show both cursors"\r
+    IDS_TABLET_NATIVE_CURSOR "Show native cursor only"\r
+    IDS_TABLET_HOST_CURSOR  "Show host cursor only"\r
 END\r
 \r
 #endif    // English (U.S.) resources\r
index 219d87a26e7631b5bb3dce384f656eb303db6720..089b4248f7c7b9376aa159c6ab3c7b78197ad061 100644 (file)
@@ -129,7 +129,7 @@ static int port_insert2 (int num, const TCHAR *name)
 
     type = 1;
     _tcscpy (tmp2, name);
-    for (i = 1; i <= 4; i++) {
+    for (i = 1; i <= MAX_JPORTS; i++) {
        TCHAR tmp1[1000];
        _stprintf (tmp1, L"Mouse%d", i);
        if (!_tcscmp (name, tmp1)) {
@@ -163,7 +163,7 @@ static int port_insert (int num, const TCHAR *name)
 {
     TCHAR tmp1[1000];
 
-    if (num < 0 || num > 1)
+    if (num < 0 || num >= MAX_JPORTS)
        return FALSE;
     if (_tcslen (name) == 0) {
        inputdevice_joyport_config (&changed_prefs, L"none", num, 0);
@@ -733,9 +733,11 @@ void rp_fixup_options (struct uae_prefs *p)
     }
     RPSendMessagex (RPIPCGM_DEVICES, RP_DEVICE_FLOPPY, floppy_mask, NULL, 0, &guestinfo, NULL);
 
-    RPSendMessagex (RPIPCGM_DEVICES, RP_DEVICE_INPUTPORT, 3, NULL, 0, &guestinfo, NULL);
+    RPSendMessagex (RPIPCGM_DEVICES, RP_DEVICE_INPUTPORT, (1 << MAX_JPORTS) - 1, NULL, 0, &guestinfo, NULL);
     rp_input_change (0);
     rp_input_change (1);
+    rp_input_change (2);
+    rp_input_change (3);
 
     hd_mask = 0;
     cd_mask = 0;
index 5be3248aadc39823f4f63a9f4dcdb6f445fcf4c3..4722cdcf63fa4ae6497deea9116a18661424a7c4 100644 (file)
@@ -94,6 +94,7 @@ OSVERSIONINFO osVersion;
 static SYSTEM_INFO SystemInfo;
 static int logging_started;
 static DWORD minidumpmode = MiniDumpNormal;
+static int doquit;
 void *globalipc, *serialipc;
 
 int qpcdivisor = 0;
@@ -2665,7 +2666,7 @@ static int shell_associate_2 (const TCHAR *extension, const TCHAR *shellcommand,
     DWORD disposition;
     const TCHAR *progid = L"WinUAE";
     int def = !_tcscmp (extension, L".uae");
-    TCHAR *defprogid;
+    const TCHAR *defprogid;
     UAEREG *fkey;
 
     _tcscpy (progid2, progid);
@@ -3393,8 +3394,12 @@ static void makeverstr (TCHAR *s)
     }
 }
 
-static int parseargs (const TCHAR *arg, const TCHAR *np)
+static int parseargs (const TCHAR *arg, const TCHAR *np, const TCHAR *np2)
 {
+    if (!_tcscmp (arg, L"-convert") && np && np2) {
+       zfile_convertimage (np, np2);
+       return -1;
+    }
 
     if (!_tcscmp (arg, L"-log")) {
         console_logging = 1;
@@ -3625,11 +3630,16 @@ static TCHAR **parseargstrings (TCHAR *s, TCHAR **xargv)
     for (i = 0; i < cnt; i++) {
        TCHAR *arg = args[i];
        TCHAR *next = i + 1 < cnt ? args[i + 1] : NULL;
-       int v = parseargs (arg, next);
-       if (!v)
+       TCHAR *next2 = i + 2 < cnt ? args[i + 2] : NULL;
+       int v = parseargs (arg, next, next2);
+       if (!v) {
            xargv[xargc++] = my_strdup (arg);
-       else if (v == 2)
+       } else if (v == 2) {
            i++;
+       } else if (v < 0) {
+           doquit = 1;
+           return NULL;
+       }
     }
     return args;
 }
@@ -3693,11 +3703,16 @@ static int process_arg (TCHAR *cmdline, TCHAR **xargv, TCHAR ***xargv3)
     for (i = 0; argv[i]; i++) {
        TCHAR *arg = argv[i];
        TCHAR *next = argv[i + 1];
-       int v = parseargs (arg, next);
-       if (!v)
+       TCHAR *next2 = next != NULL ? argv[i + 2] : NULL;
+       int v = parseargs (arg, next, next2);
+       if (!v) {
            xargv[xargc++] = my_strdup (arg);
-       else if (v == 2)
+       } else if (v == 2) {
            i++;
+       } else if (v < 0) {
+           doquit = 1;
+           return 0;
+       }
     }
 #if 0
     argv = 0;
@@ -3753,13 +3768,13 @@ static int PASCAL WinMain2 (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR
 
     hInst = hInstance;
     hMutex = CreateMutex (NULL, FALSE, L"WinUAE Instantiated"); // To tell the installer we're running
-#ifdef AVIOUTPUT
-    AVIOutput_Initialize ();
-#endif
+
 
     argv = xcalloc (sizeof (TCHAR*), 32);
     argv3 = NULL;
     argc = process_arg (lpCmdLine, argv, &argv3);
+    if (doquit)
+       return 0;
 
     argv2 = WIN32_InitRegistry (argv);
     getstartpaths ();
@@ -3808,7 +3823,9 @@ static int PASCAL WinMain2 (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR
            else
                default_freq = 60;
        }
-       WIN32_HandleRegistryStuff ();
+#ifdef AVIOUTPUT
+       AVIOutput_Initialize ();
+#endif WIN32_HandleRegistryStuff ();
        WIN32_InitLang ();
        WIN32_InitHtmlHelp ();
        DirectDraw_Release ();
index ba9e893cac0bda5f0bafa8f8afbfaa6e711ac082..61c2a33dff551cc1bb34f6dce57be7a2f9a712f0 100644 (file)
@@ -17,8 +17,8 @@
 
 #define WINUAEPUBLICBETA 1
 
-#define WINUAEBETA L"19"
-#define WINUAEDATE MAKEBD(2009, 3, 28)
+#define WINUAEBETA L"20"
+#define WINUAEDATE MAKEBD(2009, 3, 30)
 #define WINUAEEXTRA L""
 #define WINUAEREV L""
 
index 4fb91a94d3b0c1ea06a2db368cbc70b84b1cad7e..8ce1b410bce26147c217b04edda9c126759d013f 100644 (file)
@@ -1722,10 +1722,10 @@ int DiskSelection_2 (HWND hDlg, WPARAM wParam, int flag, struct uae_prefs *prefs
        openFileName.Flags |= OFN_ALLOWMULTISELECT;
     if (flag == 1 || flag == 3 || flag == 5 || flag == 9 || flag == 11 || flag == 16) {
        if (!(result = GetSaveFileName_2 (&openFileName, guid)))
-           write_log (L"GetSaveFileNameX() failed, err=%d.\n", GetLastError());
+           write_log (L"GetSaveFileNameX() failed, err=%d.\n", GetLastError ());
     } else {
        if (!(result = GetOpenFileName_2 (&openFileName, guid)))
-           write_log (L"GetOpenFileNameX() failed, err=%d.\n", GetLastError());
+           write_log (L"GetOpenFileNameX() failed, err=%d.\n", GetLastError ());
     }
     previousfilter[flag] = openFileName.nFilterIndex;
 
@@ -8947,7 +8947,7 @@ static DWORD dwEnumeratedPrinters = 0;
 struct serialportinfo comports[MAX_SERIAL_PORTS];
 static int ghostscript_available;
 
-static int joy0previous, joy1previous;
+static int joyxprevious[4];
 static BOOL bNoMidiIn = FALSE;
 
 static void enable_for_gameportsdlg (HWND hDlg)
@@ -8993,6 +8993,9 @@ static void enable_for_portsdlg (HWND hDlg)
 #endif
 }
 
+static int joys[] = { IDC_PORT0_JOYS, IDC_PORT1_JOYS, IDC_PORT2_JOYS, IDC_PORT3_JOYS };
+static int joysm[] = { IDC_PORT0_JOYSMODE, IDC_PORT1_JOYSMODE, -1, -1 };
+
 static void updatejoyport (HWND hDlg)
 {
     int i, j;
@@ -9004,17 +9007,23 @@ static void updatejoyport (HWND hDlg)
     CheckDlgButton (hDlg, IDC_PORT_TABLET, workprefs.input_tablet > 0);
     CheckDlgButton (hDlg, IDC_PORT_TABLET_FULL, workprefs.input_tablet == TABLET_REAL);
 
-    if (joy0previous < 0)
-       joy0previous = inputdevice_get_device_total (IDTYPE_JOYSTICK) + 1;
-    if (joy1previous < 0)
-       joy1previous = JSEM_LASTKBD + 1;
-    for (i = 0; i < 2; i++) {
+    if (joyxprevious[0] < 0)
+       joyxprevious[0] = inputdevice_get_device_total (IDTYPE_JOYSTICK) + 1;
+    if (joyxprevious[1] < 0)
+       joyxprevious[1] = JSEM_LASTKBD + 1;
+
+    for (i = 0; i < MAX_JPORTS; i++) {
        int total = 2;
-       int idx = i == 0 ? joy0previous : joy1previous;
-       int id = i == 0 ? IDC_PORT0_JOYS : IDC_PORT1_JOYS;
+       int idx = joyxprevious[i];
+       int id = joys[i];
+       int idm = joysm[i];
        int v = workprefs.jports[i].id;
+       int vm = workprefs.jports[i].mode;
        TCHAR *p1, *p2;
 
+       if (idm > 0)
+           SendDlgItemMessage (hDlg, idm, CB_SETCURSEL, vm, 0);
+
        SendDlgItemMessage (hDlg, id, CB_RESETCONTENT, 0, 0L);
        SendDlgItemMessage (hDlg, id, CB_ADDSTRING, 0, (LPARAM)L"");
        WIN32GUI_LoadUIString (IDS_NONE, tmp, sizeof (tmp) / sizeof (TCHAR) - 3);
@@ -9079,9 +9088,8 @@ static void fixjport (struct jport *port, int v)
 
 static void values_from_gameportsdlg (HWND hDlg, int d)
 {
-    int i, success;
+    int i, j, success;
     int changed = 0;
-    int lastside = 0;
 
     if (d) {
        i  = GetDlgItemInt (hDlg, IDC_INPUTSPEEDM, &success, FALSE);
@@ -9099,14 +9107,16 @@ static void values_from_gameportsdlg (HWND hDlg, int d)
        return;
     }
 
-    for (i = 0; i < 2; i++) {
+    for (i = 0; i < MAX_JPORTS; i++) {
        int idx = 0;
        int *port = &workprefs.jports[i].id;
+       int *portm = &workprefs.jports[i].mode;
        int prevport = *port;
-       int id = i == 0 ? IDC_PORT0_JOYS : IDC_PORT1_JOYS;
+       int id = joys[i];
+       int idm = joysm[i];
        LRESULT v = SendDlgItemMessage (hDlg, id, CB_GETCURSEL, 0, 0L);
        if (v != CB_ERR && v > 0) {
-           v-=2;
+           v -= 2;
            if (v < 0)
                *port = -1;
            else if (v < JSEM_LASTKBD)
@@ -9116,18 +9126,21 @@ static void values_from_gameportsdlg (HWND hDlg, int d)
            else
                *port = JSEM_JOYS + (int)v - JSEM_LASTKBD;
        }
-       if (*port != prevport) {
-           lastside = i;
+       v = SendDlgItemMessage (hDlg, idm, CB_GETCURSEL, 0, 0L);
+       if (v != CB_ERR && v > 0)
+           *portm = v;
+       if (*port != prevport)
            changed = 1;
-       }
     }
     if (changed) {
-       if (lastside)
-           fixjport (&workprefs.jports[0], workprefs.jports[1].id);
-       else
-           fixjport (&workprefs.jports[1], workprefs.jports[0].id);
+       for (i = 0; i < MAX_JPORTS; i++) {
+           for (j = 0; j < MAX_JPORTS; j++) {
+               if (j != i)
+                   fixjport (&workprefs.jports[i], workprefs.jports[j].id);
+           }
+       }
     }
-    
+       
 }
 
 static void values_from_portsdlg (HWND hDlg)
@@ -9292,7 +9305,6 @@ static void init_portsdlg (HWND hDlg)
            unload_ghostscript ();
            ghostscript_available = 1;
        }
-       joy0previous = joy1previous = -1;
     }
     if (!ghostscript_available) {
        workprefs.parallel_postscript_emulation = 0;
@@ -9372,8 +9384,10 @@ static void init_portsdlg (HWND hDlg)
 /* Handle messages for the Joystick Settings page of our property-sheet */
 static INT_PTR CALLBACK GamePortsDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
 {
+    TCHAR tmp[MAX_DPATH];
     static int recursive = 0;
-    int temp;
+    static int first;
+    int temp, i;
 
     switch (msg)
     {
@@ -9381,10 +9395,42 @@ static INT_PTR CALLBACK GamePortsDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LP
        recursive++;
        pages[GAMEPORTS_ID] = hDlg;
        currentpage = GAMEPORTS_ID;
+    
+       if (!first) {
+           first = 1;
+           joyxprevious[0] = -1;
+           joyxprevious[1] = -1;
+           joyxprevious[2] = -1;
+           joyxprevious[3] = -1;
+       }
+
        SendDlgItemMessage (hDlg, IDC_PORT_TABLET_CURSOR, CB_RESETCONTENT, 0, 0L);
-        SendDlgItemMessage (hDlg, IDC_PORT_TABLET_CURSOR, CB_ADDSTRING, 0, (LPARAM)L"Show both cursors");
-        SendDlgItemMessage (hDlg, IDC_PORT_TABLET_CURSOR, CB_ADDSTRING, 0, (LPARAM)L"Show native cursor only");
-        SendDlgItemMessage (hDlg, IDC_PORT_TABLET_CURSOR, CB_ADDSTRING, 0, (LPARAM)L"Show host cursor only");
+        WIN32GUI_LoadUIString (IDS_TABLET_BOTH_CURSORS, tmp, MAX_DPATH);
+        SendDlgItemMessage (hDlg, IDC_PORT_TABLET_CURSOR, CB_ADDSTRING, 0, (LPARAM)tmp);
+        WIN32GUI_LoadUIString (IDS_TABLET_NATIVE_CURSOR, tmp, MAX_DPATH);
+        SendDlgItemMessage (hDlg, IDC_PORT_TABLET_CURSOR, CB_ADDSTRING, 0, (LPARAM)tmp);
+        WIN32GUI_LoadUIString (IDS_TABLET_HOST_CURSOR, tmp, MAX_DPATH);
+        SendDlgItemMessage (hDlg, IDC_PORT_TABLET_CURSOR, CB_ADDSTRING, 0, (LPARAM)tmp);
+
+       for (i = 0; i < 2; i++) {
+           int id = i == 0 ? IDC_PORT0_JOYSMODE : IDC_PORT1_JOYSMODE;
+           SendDlgItemMessage (hDlg, id, CB_RESETCONTENT, 0, 0L);
+           WIN32GUI_LoadUIString (IDS_JOYMODE_DEFAULT, tmp, MAX_DPATH);
+           SendDlgItemMessage (hDlg, id, CB_ADDSTRING, 0, (LPARAM)tmp);
+           WIN32GUI_LoadUIString (IDS_JOYMODE_MOUSE, tmp, MAX_DPATH);
+           SendDlgItemMessage (hDlg, id, CB_ADDSTRING, 0, (LPARAM)tmp);
+           WIN32GUI_LoadUIString (IDS_JOYMODE_JOYSTICK, tmp, MAX_DPATH);
+           SendDlgItemMessage (hDlg, id, CB_ADDSTRING, 0, (LPARAM)tmp);
+           WIN32GUI_LoadUIString (IDS_JOYMODE_JOYSTICKANALOG, tmp, MAX_DPATH);
+           SendDlgItemMessage (hDlg, id, CB_ADDSTRING, 0, (LPARAM)tmp);
+           WIN32GUI_LoadUIString (IDS_JOYMODE_MOUSE_CDTV, tmp, MAX_DPATH);
+           SendDlgItemMessage (hDlg, id, CB_ADDSTRING, 0, (LPARAM)tmp);
+           WIN32GUI_LoadUIString (IDS_JOYMODE_JOYSTICK_CD32, tmp, MAX_DPATH);
+           SendDlgItemMessage (hDlg, id, CB_ADDSTRING, 0, (LPARAM)tmp);
+           WIN32GUI_LoadUIString (IDS_JOYMODE_LIGHTPEN, tmp, MAX_DPATH);
+           SendDlgItemMessage (hDlg, id, CB_ADDSTRING, 0, (LPARAM)tmp);
+       }
+
        inputdevice_updateconfig (&workprefs);
        enable_for_gameportsdlg (hDlg);
        updatejoyport (hDlg);
@@ -9406,9 +9452,9 @@ static INT_PTR CALLBACK GamePortsDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LP
            memcpy (&tmp, &workprefs.jports[0], sizeof (struct jport));
            memcpy (&workprefs.jports[0], &workprefs.jports[1], sizeof (struct jport));
            memcpy (&workprefs.jports[1], &tmp, sizeof (struct jport));
-           temp = joy0previous;
-           joy0previous = joy1previous;
-           joy1previous = temp;
+           temp = joyxprevious[0];
+           joyxprevious[0] = joyxprevious[1];
+           joyxprevious[1] = temp;
            enable_for_gameportsdlg (hDlg);
            updatejoyport (hDlg);
            inputdevice_updateconfig (&workprefs);
@@ -9418,6 +9464,10 @@ static INT_PTR CALLBACK GamePortsDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LP
            {
                case IDC_PORT0_JOYS:
                case IDC_PORT1_JOYS:
+               case IDC_PORT2_JOYS:
+               case IDC_PORT3_JOYS:
+               case IDC_PORT0_JOYSMODE:
+               case IDC_PORT1_JOYSMODE:
                    values_from_gameportsdlg (hDlg, 0);
                    enable_for_gameportsdlg (hDlg);
                    updatejoyport (hDlg);
index af4b3d11915b4067dfe54533aeee393528ccbb38..7ce87a48eed025a4167376b725340d5fd37e00c4 100644 (file)
@@ -1,4 +1,37 @@
 
+Beta 20: (feature complete now. I think..)
+
+- added controller type to gameports panel, easier way to enable
+  more complex standard controller configurations without need for
+  input panel (analog joystick, lightpen, joystick mouse emulation..)
+  Note that impossible configurations like emulating joystick with
+  mouse aren't supported even if GUI seems to allow it, also
+  non-mouse lightpen isn't really supported, it works but moves
+  badly (not worth the trouble really, maybe)
+- added "CDTV Mouse" which is CDTV remote controller mouse emulation,
+  only difference between normal and CDTV mouse is speed setting,
+  normal mouse speed is adjustable in input-panel, CDTV mouse speed
+  is not adjustable and is same as real CDTV mouse emulation (there
+  are CDTV programs that expect CDTV remote controller -like mouse
+  speed and they do not work very well with normal mouse)
+  NOTE: speed not yet calibrated!
+- added CD32 controller type to gameports GUI, enables CD32 controller
+  emulation. Now it is possible to emulate normal joysticks in CD32
+  emulation mode (without using input panel)
+- parallel port joystick adapter configuration added to gameports panel
+  (GUI lists all devices but only joystick/keyboard supported)
+- light pen cursor is centered when used for the first time
+- added more compatible default analog joystick parameters
+- digital joystick/buttons mapped to analog stick axis work correctly
+- state restore rom detection fixed (b15), added logging
+- support "0x402 An unknown error occurred" when deleting non-existing
+  directory with recycle bin enabled
+- drives 1 to 3 config load didn't work (b15)
+- added possibly pointless command line image conversion option,
+  "winuae -convert <src> <dst>" where src can be any supported archive
+  and/or disk image (even archive.lha\fileinsidearchive.dms should
+  unpack to adf) Separate command line unpacker maybe in future..
+
 Beta 19:
 
 - missing command line unicode support added
index 06821ca57198a7cf5b380ddea9dd52811e38cfe2..1f46696167b43f399a12e2cbf2ba4d58092f6e2b 100644 (file)
@@ -279,6 +279,8 @@ void write_log (const TCHAR *format, ...)
     TCHAR *bufp;
     va_list parms;
 
+    if (!cs_init)
+       return;
     EnterCriticalSection (&cs);
     va_start (parms, format);
     bufp = buffer;
index 2e323f7a714158662f4d2090f2d13393fc2d1987..48145d7f57101c548a253ce07d10c34f6a1ee672 100644 (file)
--- a/uaelib.c
+++ b/uaelib.c
@@ -218,7 +218,7 @@ static uae_u32 emulib_ExitEmu (void)
  */
 static uae_u32 emulib_GetUaeConfig (uaecptr place)
 {
-    int i;
+    int i, j;
 
     put_long (place, version);
     put_long (place + 4, allocated_chipmem);
@@ -245,11 +245,11 @@ static uae_u32 emulib_GetUaeConfig (uaecptr place)
     else
        put_byte (place + 35, 1);
 
-    for (i = 0; i < 256; i++) {
-       put_byte ((place + 36 + i), currprefs.df[0][i]);
-       put_byte ((place + 36 + i + 256), currprefs.df[1][i]);
-       put_byte ((place + 36 + i + 512), currprefs.df[2][i]);
-       put_byte ((place + 36 + i + 768), currprefs.df[3][i]);
+    for (j = 0; j < 4; j++) {
+       char *s = ua (currprefs.df[j]);
+       for (i = 0; i < 256; i++)
+           put_byte (place + 36 + i + j * 256, s[i]);
+       xfree (s);
     }
     return 1;
 }
diff --git a/zfile.c b/zfile.c
index 8cc0caec9e2f7d8a11189aebad5e008ea0c185d1..5f9101f3a5bd10a2e66474bc8a7ebaf337a2013d 100644 (file)
--- a/zfile.c
+++ b/zfile.c
@@ -1479,3 +1479,31 @@ int zfile_exists_archive (const TCHAR *path, const TCHAR *rel)
     return zn ? 1 : 0;
 }
 
+int zfile_convertimage (const TCHAR *src, const TCHAR *dst)
+{
+    struct zfile *s, *d;
+    int ret = 0;
+
+    s = zfile_fopen (src, L"rb");
+    if (s) {
+       uae_u8 *b;
+       int size;
+       zfile_fseek (s, 0, SEEK_END);
+       size = zfile_ftell (s);
+       zfile_fseek (s, 0, SEEK_SET);
+       b = xcalloc (size, 1);
+       if (b) {
+           if (zfile_fread (b, size, 1, s) == 1) {
+               d = zfile_fopen (dst, L"wb");
+               if (d) {
+                   if (zfile_fwrite (b, size, 1, d) == 1)
+                       ret = 1;
+                   zfile_fclose (d);
+               }
+           }
+           xfree (b);
+       }
+       zfile_fclose (s);
+    }
+    return ret;
+}
\ No newline at end of file