]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
imported winuaesrc1000b2.zip
authorToni Wilen <twilen@winuae.net>
Sat, 19 Feb 2005 16:08:14 +0000 (18:08 +0200)
committerToni Wilen <twilen@winuae.net>
Mon, 22 Feb 2010 19:25:09 +0000 (21:25 +0200)
13 files changed:
catweasel.c
cfgfile.c
expansion.c
include/enforcer.h
include/options.h
inputevents.def
keybuf.c
newcpu.c
od-win32/ahidsound.c
od-win32/bsdsock.c
od-win32/resources/resource.h
od-win32/resources/winuae.rc
od-win32/win32gui.c

index fab5915fe0022c219757ff8655de4ded2a3abb54..49c3b9a27791edc7404c09d12a4b8902d85189d1 100755 (executable)
@@ -22,103 +22,128 @@ static HANDLE handle = INVALID_HANDLE_VALUE;
 
 void catweasel_hsync (void)
 {
-    if (cwhsync <= 0)
+    int x, y, i;
+
+    if (cwc.type < CATWEASEL_TYPE_MK3)
        return;
     cwhsync--;
-    if (cwhsync == 0) {
-        if (handshake)
-           ioport_write (currprefs.catweasel_io + 0xd0, 0);
+    if (cwhsync > 0)
+       return;
+    cwhsync = 10;
+    if (handshake) {
+        catweasel_do_bput (0xd0, 0);
        handshake = 0;
     }
+    catweasel_do_bput (3, 0x81);
+    for (i = 0; i < 2; i++) {
+       x = catweasel_do_bget (0xc4 + i * 8);
+       y = catweasel_do_bget (0xc0 + i * 8);
+    }
+    catweasel_do_bput (3, 0x41);
 }
 
 int catweasel_read_joystick (uae_u8 *dir, uae_u8 *buttons)
 {
-    if (cwc.type != CATWEASEL_TYPE_MK3)
+    if (cwc.type < CATWEASEL_TYPE_MK3)
        return 0;
-    *dir = ioport_read (currprefs.catweasel_io + 0xc0);
-    *buttons = ioport_read (currprefs.catweasel_io + 0xc8);
+    *dir = catweasel_do_bget (0xc0);
+    *buttons = catweasel_do_bget (0xc8);
+    if (cwc.type == CATWEASEL_TYPE_MK4) {
+       *buttons &= ~0x80;
+       *buttons |= (catweasel_do_bget (0x07) << 4) & 0x80;
+    }
     return 1;
 }
 
 int catweasel_read_keyboard (uae_u8 *keycode)
 {
     uae_u8 v;
-    if (cwc.type != CATWEASEL_TYPE_MK3)
+    if (cwc.type < CATWEASEL_TYPE_MK3)
        return 0;
-    v = ioport_read (currprefs.catweasel_io + 0xd4);
+    v = catweasel_do_bget (0xd4);
     if (!(v & 0x80))
        return 0;
     if (handshake)
        return 0;
-    *keycode = ioport_read (currprefs.catweasel_io + 0xd0);
-    ioport_write (currprefs.catweasel_io + 0xd0, 0);
+    *keycode = catweasel_do_bget (0xd0);
+    catweasel_do_bput (0xd0, 0);
     handshake = 1;
-    cwhsync = 10;
     return 1;
 }
 
 uae_u32 catweasel_do_bget (uaecptr addr)
 {
-    if (cwc.type == CATWEASEL_TYPE_MK3) {
-       if ((currprefs.catweasel_io & 3) == 0 && addr >= 0xc0 && addr <= 0xfc)
-           return ioport_read (currprefs.catweasel_io + addr);
-    } else {
-       if (addr >= currprefs.catweasel_io && addr <= currprefs.catweasel_io + 8) {
-           return ioport_read (addr & 0x3ff);
-       } else if(addr >= 0x10000 + currprefs.catweasel_io && addr <= 0x10000 + currprefs.catweasel_io) {
-           return ioport_read (addr & 0x3ff);
-       } else if ((addr & 0x3ff) < 0x200 || (addr & 0x3ff) >= 0x400) {
-           write_log("catweasel_bget @%08.8X!\n",addr);
-       }
-    }
-    return 0;
+    DWORD did_read = 0;
+    uae_u8 buf1[1], buf2[1];
+
+    if (addr >= 0x100)
+       return 0;
+    buf1[0] = (uae_u8)addr;
+    DeviceIoControl (handle, CW_PEEKREG_FULL, buf1, 1, buf2, 1, &did_read, 0);
+    //write_log ("G %02.2X %02.2X %d\n", buf1[0], buf2[0], did_read);
+    return buf2[0];
 }
 
 void catweasel_do_bput (uaecptr addr, uae_u32 b)
 {
-    if (cwc.type == CATWEASEL_TYPE_MK3) {
-       if ((currprefs.catweasel_io & 3) == 0 && addr >= 0xc0 && addr <= 0xfc)
-           ioport_write (currprefs.catweasel_io + addr, b);
-    } else {
-       if (addr >= currprefs.catweasel_io && addr <= currprefs.catweasel_io + 8) {
-           ioport_write (addr & 0x3ff, b);
-       } else if(addr >= 0x10000 + currprefs.catweasel_io && addr <= 0x10000 + currprefs.catweasel_io) {
-           ioport_write (addr & 0x3ff, b);
-       } else if ((addr & 0x3ff) < 0x200 || (addr & 0x3ff) >= 0x400) {
-           write_log("catweasel_bput @%08.8X=%02.2X!\n",addr,b);
-       }
-    }
+    uae_u8 buf[2];
+    DWORD did_read = 0;
+
+    if (addr >= 0x100)
+       return;
+    buf[0] = (uae_u8)addr;
+    buf[1] = b;
+    DeviceIoControl (handle, CW_POKEREG_FULL, buf, 2, 0, 0, &did_read, 0);
+    //write_log ("P %02.2X %02.2X %d\n", (uae_u8)addr, (uae_u8)b, did_read);
 }
 
 int catweasel_init (void)
 {
     char name[32];
     int i, len;
-    uae_u8 buffer[1000];
+    uae_u8 buffer[10000];
     uae_u32 model, base;
 
-    return 0;
+    if (cwc.type)
+       return 1;
 
+    if (!currprefs.catweasel)
+       return 0;
     for (i = 0; i < 4; i++) {
+       if (currprefs.catweasel > 0)
+           i = currprefs.catweasel;
         sprintf (name, "\\\\.\\CAT%d_F0", i);
        handle = CreateFile (name, GENERIC_READ|GENERIC_WRITE, FILE_SHARE_WRITE|FILE_SHARE_READ, 0,
            OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
-       if (handle != INVALID_HANDLE_VALUE)
+       if (handle != INVALID_HANDLE_VALUE || currprefs.catweasel > 0)
            break;
-       write_log("%s: %d\n", name, GetLastError());
     }
-    if (handle == INVALID_HANDLE_VALUE)
+    if (handle == INVALID_HANDLE_VALUE) {
+       write_log ("No Catweasel detected\n");
+       goto fail;
+    }
+    if (!DeviceIoControl (handle, CW_GET_VERSION, 0, 0, buffer, sizeof (buffer), &len, 0)) {
+       write_log ("CW_GET_VERSION failed %d\n", GetLastError());
        goto fail;
+    }
+    write_log ("CW driver version string '%s'\n", buffer);
+    if (!DeviceIoControl (handle, CW_GET_HWVERSION, 0, 0, buffer, sizeof (buffer), &len, 0)) {
+       write_log ("CW_GET_HWVERSION failed %d\n", GetLastError());
+       goto fail;
+    }
+    write_log ("CW: v=%d 14=%d 28=%d 56=%d joy=%d dpm=%d sid=%d kb=%d sidfifo=%d\n",
+       buffer[0], buffer[1], buffer[2], buffer[3], buffer[4], buffer[5],
+       buffer[6], buffer[7], ((uae_u32*)(buffer + 8))[0]);
     if (!DeviceIoControl (handle, CW_LOCK_EXCLUSIVE, 0, 0, buffer, sizeof (buffer), &len, 0)) {
        write_log ("CW_LOCK_EXCLUSIVE failed %d\n", GetLastError());
        goto fail;
     }
     model = *((uae_u32*)(buffer + 4));
     base = *((uae_u32*)(buffer + 0));
-    write_log ("Catweasel MK%d @%p detected and enabled\n", model, base);
-    cwc.type = model == 0 ? 1 : model == 3 ? 4 : 2;
+    cwc.type = model == 0 ? 1 : model == 2 ? 4 : 2;
     cwc.iobase = base;
+    write_log ("Catweasel MK%d @%p (%s) detected and enabled\n", cwc.type, cwc.iobase, name);
+    catweasel_do_bput (3, 0x41); /* enable MK3-mode */
     catweasel_init_controller (&cwc);
     return 1;
 fail:
@@ -135,8 +160,8 @@ void catweasel_free (void)
     cwc.type = 0;
 }
 
-#define outb(v,port) ioport_write(port,v)
-#define inb(port) ioport_read(port)
+#define outb(v,port) catweasel_do_bput(port,v)
+#define inb(port) catweasel_do_bget(port)
 
 #define LONGEST_TRACK 16000
 
@@ -287,6 +312,7 @@ void catweasel_init_controller(catweasel_contr *c)
        c->io_mem   = c->iobase;
        break;
     case CATWEASEL_TYPE_MK3:
+    case CATWEASEL_TYPE_MK4:
        c->crm_sel0 = 1 << 2;
        c->crm_sel1 = 1 << 3;
        c->crm_mot0 = 1 << 1;
index a7c13c83ac62c6f207b50a212cd5a7b4b54c0b79..8a18f505c8bfb3239fc205ce0e2111e2802d05a6 100755 (executable)
--- a/cfgfile.c
+++ b/cfgfile.c
@@ -147,7 +147,8 @@ static const char *obsolete[] = {
     "accuracy", "gfx_opengl", "gfx_32bit_blits", "32bit_blits",
     "gfx_immediate_blits", "gfx_ntsc", "win32", "gfx_filter_bits",
     "sound_pri_cutoff", "sound_pri_time", "sound_min_buff",
-    "gfx_test_speed", "gfxlib_replacement", "enforcer", 0 };
+    "gfx_test_speed", "gfxlib_replacement", "enforcer", "catweasel_io",
+    0 };
 
 #define UNEXPANDED "$(FILE_PATH)"
 
@@ -408,7 +409,7 @@ static void save_options (struct zfile *f, struct uae_prefs *p, int type)
     cfgfile_write (f, "blitter_cycle_exact=%s\n", p->blitter_cycle_exact ? "true" : "false");
 
     cfgfile_write (f, "log_illegal_mem=%s\n", p->illegal_mem ? "true" : "false");
-    cfgfile_write (f, "catweasel_io=0x%x\n", p->catweasel_io);
+    cfgfile_write (f, "catweasel=%d\n", p->catweasel);
 
     cfgfile_write (f, "kbd_lang=%s\n", (p->keyboard_lang == KBD_LANG_DE ? "de"
                                  : p->keyboard_lang == KBD_LANG_DK ? "dk"
@@ -880,7 +881,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, "catweasel_io", &p->catweasel_io, 1))
+       || cfgfile_intval (option, value, "catweasel", &p->catweasel, 1))
        return 1;
     if (cfgfile_strval (option, value, "comp_trustbyte", &p->comptrustbyte, compmode, 0)
        || cfgfile_strval (option, value, "comp_trustword", &p->comptrustword, compmode, 0)
@@ -2252,7 +2253,7 @@ void default_prefs (struct uae_prefs *p, int type)
     p->fast_copper = 1;
     p->scsi = 0;
     p->cpu_idle = 0;
-    p->catweasel_io = 0;
+    p->catweasel = 0;
     p->tod_hack = 0;
     p->maprom = 0;
     p->filesys_no_uaefsdb = 0;
@@ -2360,7 +2361,7 @@ static void buildin_default_prefs (struct uae_prefs *p)
     p->produce_sound = 3;
     p->scsi = 0;
     p->cpu_idle = 0;
-    p->catweasel_io = 0;
+    p->catweasel = 0;
     p->tod_hack = 0;
     p->maprom = 0;
     p->cachesize = 0;
index 1966b747b9e235633c1e7dc0751e0e54dfa68034..6b4eba75f9d04f1a94d28e28d5f4eeeff9f8df59 100755 (executable)
@@ -512,14 +512,14 @@ static void expamem_map_catweasel (void)
 
 static void expamem_init_catweasel (void)
 {
-    uae_u8 productid = cwc.type == CATWEASEL_TYPE_MK3 ? 66 : 200;
-    uae_u16 vendorid = cwc.type == CATWEASEL_TYPE_MK3 ? 4626 : 5001;
+    uae_u8 productid = cwc.type >= CATWEASEL_TYPE_MK3 ? 66 : 200;
+    uae_u16 vendorid = cwc.type >= CATWEASEL_TYPE_MK3 ? 4626 : 5001;
 
-    catweasel_mask = (cwc.type == CATWEASEL_TYPE_MK3) ? 0xffff : 0x1ffff;
+    catweasel_mask = (cwc.type >= CATWEASEL_TYPE_MK3) ? 0xffff : 0x1ffff;
 
     expamem_init_clear();
 
-    expamem_write (0x00, (cwc.type == CATWEASEL_TYPE_MK3 ? Z2_MEM_64KB : Z2_MEM_128KB) | zorroII);
+    expamem_write (0x00, (cwc.type >= CATWEASEL_TYPE_MK3 ? Z2_MEM_64KB : Z2_MEM_128KB) | zorroII);
 
     expamem_write (0x04, productid);
 
index c54efc02fde3cb0570c585a71cccabfe7583b2dc..60bd51178b277bdba0707f76e57067f520ffad17 100755 (executable)
@@ -1,7 +1,7 @@
 #ifndef UAE__ENFORCER_H
 #define UAE__ENFORCER_H
 
-int enforcer_enable(void);
+int enforcer_enable(int);
 int enforcer_disable(void);
 
 #endif
\ No newline at end of file
index 50c7e8fce8933fad397dfc58f5b80811ab0236d1..65e3cd8c68cc663d46d6b46c9bcceb811086cd9e 100755 (executable)
@@ -146,7 +146,7 @@ struct uae_prefs {
     int fast_copper;
     int scsi;
     int uaeserial;
-    int catweasel_io;
+    int catweasel;
     int cpu_idle;
     int cpu_cycle_exact;
     int blitter_cycle_exact;
index 678a90ea030f4a1b942cc6aab88f0c0f5128c29a..f9ecab5dd07586ac18dc61fc1d1dc00b3198b4d1 100755 (executable)
@@ -72,9 +72,9 @@ DEFEVENT(JOY2_LEFT_DOWN,"Joy2 Left+Down",AM_K,16,2,DIR_LEFT|DIR_DOWN)
 DEFEVENT(JOY2_RIGHT_UP,"Joy2 Right+Up",AM_K,16,2,DIR_RIGHT|DIR_UP)
 DEFEVENT(JOY2_RIGHT_DOWN,"Joy2 Right+Down",AM_K,16,2,DIR_RIGHT|DIR_DOWN)
 
-DEFEVENT(JOY2_FIRE_BUTTON,"Joy2 Fire/Mouse1 Left Button",AM_K,4,2,JOYBUTTON_1)
-DEFEVENT(JOY2_2ND_BUTTON,"Joy2 2nd Button/Mouse1 Right Button",AM_K,4,2,JOYBUTTON_2)
-DEFEVENT(JOY2_3RD_BUTTON,"Joy2 3rd Button/Mouse1 Middle Button",AM_K,4,2,JOYBUTTON_3)
+DEFEVENT(JOY2_FIRE_BUTTON,"Joy2 Fire/Mouse2 Left Button",AM_K,4,2,JOYBUTTON_1)
+DEFEVENT(JOY2_2ND_BUTTON,"Joy2 2nd Button/Mouse2 Right Button",AM_K,4,2,JOYBUTTON_2)
+DEFEVENT(JOY2_3RD_BUTTON,"Joy2 3rd Button/Mouse2 Middle Button",AM_K,4,2,JOYBUTTON_3)
 DEFEVENT(JOY2_CD32_PLAY,"Joy2 CD32 Play",AM_K,4,2,JOYBUTTON_CD32_PLAY)
 DEFEVENT(JOY2_CD32_RWD,"Joy2 CD32 RWD",AM_K,4,2,JOYBUTTON_CD32_RWD)
 DEFEVENT(JOY2_CD32_FFW,"Joy2 CD32 FFW",AM_K,4,2,JOYBUTTON_CD32_FFW)
index 5388bcce7e2cf6f23a6f484517b78751d97d8d24..3d4fef5244c928542c18a8ee59f55c77983b854a 100755 (executable)
--- a/keybuf.c
+++ b/keybuf.c
@@ -113,7 +113,7 @@ void record_key (int kc)
        case AK_NP8: fs = 1; fs_xa1[0] = b; break;
        case AK_NP4: fs = 1; fs_xa1[1] = b; break;
        case AK_NP6: fs = 1; fs_xa1[2] = b; break;
-       case AK_NP2: fs = 1; fs_xa1[3] = b; break;
+       case AK_NP2: case AK_NP5: fs = 1; fs_xa1[3] = b; break;
        case AK_CTRL: fs = 1; fs_xa1[4] = b; break;
        case AK_LALT: fs = 1; fs_xa1[5] = b; break;
        case AK_SPC: fs = 1; fs_xa1[6] = b; break;
index b4b3745d413f73476fd039a65f76cfcef439599c..700f8554a588e91eb6cd95bb2f67c1e5365f20c4 100755 (executable)
--- a/newcpu.c
+++ b/newcpu.c
@@ -1702,7 +1702,7 @@ static int do_specialties (int cycles)
        Exception (9,last_trace_ad);
     if (regs.spcflags & SPCFLAG_TRAP) {
        unset_special (SPCFLAG_TRAP);
-       Exception (32 + 15, 0);
+       Exception (3, 0);
     }
 
     while (regs.spcflags & SPCFLAG_STOP) {
index 46041a8de8839b9b34773948ada2aab0af7495bc..d7912ab8f0451291f2a4582951262b2c5cdcbf90 100755 (executable)
@@ -727,7 +727,7 @@ switch (opcode) {
       return 0;
 
        case 20:
-               return enforcer_enable();
+               return enforcer_enable(m68k_dreg (regs, 1));
 
        case 21:
                return enforcer_disable();
index 9e337c069ea4193b7149985fc5453a8a48dce41c..de4834848232900051149e60542a52cfaeb291e5 100755 (executable)
@@ -2086,15 +2086,14 @@ static unsigned int __stdcall thread_get(void *index2)
                        if (args[1] == 0)
                                { // gethostbyname or gethostbyaddr
                                struct hostent *host;
-                               if (CheckOnline(sb) == TRUE)
-                                       {
-                       
-                                       name = args[2];
-                                       namelen = args[3];
-                                       addrtype = args[4];
-                                       buf = (char*) args[5];
-                                       name_rp = get_real_address(name);
-                                       
+                               name = args[2];
+                               namelen = args[3];
+                               addrtype = args[4];
+                               buf = (char*) args[5];
+                               name_rp = get_real_address(name);
+
+                               if (strchr(name_rp,'.') == 0 || CheckOnline(sb) == TRUE)
+                                       { // Local Address or Internet Online ?
                                        if (addrtype == -1)
                                                {
                                                host = gethostbyname(name_rp);
index 5f1192a553348ecc95ac1be95a711fee0dd08fa5..b5ff88d32b8d04fa31ff2e046c15b9912808f4fc 100755 (executable)
 #define IDC_ALWAYSONTOP                 1610
 #define IDC_AVIOUTPUT_FILE              1611
 #define IDC_INPUTLIST                   1611
+#define IDC_CLOCKSYNC2                  1611
+#define IDC_CATWEASEL                   1611
 #define IDC_AVIOUTPUT_FPS_STATIC        1612
 #define IDC_INPUTAMIGA                  1612
 #define IDC_AVIOUTPUT_VIDEO             1613
index c6c0c771b6002be8e98cda5d2058b9d572c664a0..d8bafe15f44e5f1ae69731fdc62dcfb57d55fbbe 100755 (executable)
@@ -578,6 +578,8 @@ BEGIN
                     WS_VSCROLL | WS_TABSTOP
     CONTROL         "Always on top",IDC_ALWAYSONTOP,"Button",BS_AUTOCHECKBOX | 
                     WS_TABSTOP,29,92,117,10
+    CONTROL         "Catweasel",IDC_CATWEASEL,"Button",BS_AUTOCHECKBOX | 
+                    WS_TABSTOP,159,92,115,10
 END
 
 IDD_HARDFILE DIALOGEX 0, 0, 299, 212
index 06b63cb626f2f1d61522b95270e13ccb64d93c0f..e063dc076029d9302c0c9d5b5fcec55398462148 100755 (executable)
@@ -4170,6 +4170,7 @@ static void enable_for_miscdlg (HWND hDlg)
         EnableWindow (GetDlgItem (hDlg, IDC_ASPI), FALSE);
         EnableWindow (GetDlgItem (hDlg, IDC_SCSIDEVICE), FALSE);
         EnableWindow (GetDlgItem (hDlg, IDC_CLOCKSYNC), FALSE);
+        EnableWindow (GetDlgItem (hDlg, IDC_CATWEASEL), FALSE);
         EnableWindow (GetDlgItem (hDlg, IDC_STATE_CAPTURE), FALSE);
         EnableWindow (GetDlgItem (hDlg, IDC_STATE_RATE), FALSE);
         EnableWindow (GetDlgItem (hDlg, IDC_STATE_BUFFERSIZE), FALSE);
@@ -4256,6 +4257,7 @@ static void values_to_miscdlg (HWND hDlg)
     CheckDlgButton (hDlg, IDC_ALWAYSONTOP, workprefs.win32_alwaysontop);
     CheckDlgButton (hDlg, IDC_ASPI, workprefs.win32_aspi);
     CheckDlgButton (hDlg, IDC_CLOCKSYNC, workprefs.tod_hack);
+    CheckDlgButton (hDlg, IDC_CATWEASEL, workprefs.catweasel);
     CheckDlgButton (hDlg, IDC_STATE_CAPTURE, workprefs.statecapture);
 
     if (!os_winnt || !os_winnt_admin) {
@@ -4399,6 +4401,9 @@ static BOOL MiscDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
        case IDC_CLOCKSYNC:
            workprefs.tod_hack = IsDlgButtonChecked (hDlg, IDC_CLOCKSYNC);
            break;
+       case IDC_CATWEASEL:
+           workprefs.catweasel = IsDlgButtonChecked (hDlg, IDC_CATWEASEL) ? -1 : 0;
+           break;
        case IDC_NOTASKBARBUTTON:
            workprefs.win32_notaskbarbutton = IsDlgButtonChecked (hDlg, IDC_NOTASKBARBUTTON);
            break;