From 14af9c98a9361fd336c42dbc190e6365ec51c07a Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Sat, 19 Feb 2005 18:08:14 +0200 Subject: [PATCH] imported winuaesrc1000b2.zip --- catweasel.c | 118 +++++++++++++++++++++------------- cfgfile.c | 11 ++-- expansion.c | 8 +-- include/enforcer.h | 2 +- include/options.h | 2 +- inputevents.def | 6 +- keybuf.c | 2 +- newcpu.c | 2 +- od-win32/ahidsound.c | 2 +- od-win32/bsdsock.c | 17 +++-- od-win32/resources/resource.h | 2 + od-win32/resources/winuae.rc | 2 + od-win32/win32gui.c | 5 ++ 13 files changed, 107 insertions(+), 72 deletions(-) diff --git a/catweasel.c b/catweasel.c index fab5915f..49c3b9a2 100755 --- a/catweasel.c +++ b/catweasel.c @@ -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; diff --git a/cfgfile.c b/cfgfile.c index a7c13c83..8a18f505 100755 --- 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; diff --git a/expansion.c b/expansion.c index 1966b747..6b4eba75 100755 --- a/expansion.c +++ b/expansion.c @@ -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); diff --git a/include/enforcer.h b/include/enforcer.h index c54efc02..60bd5117 100755 --- a/include/enforcer.h +++ b/include/enforcer.h @@ -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 diff --git a/include/options.h b/include/options.h index 50c7e8fc..65e3cd8c 100755 --- a/include/options.h +++ b/include/options.h @@ -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; diff --git a/inputevents.def b/inputevents.def index 678a90ea..f9ecab5d 100755 --- a/inputevents.def +++ b/inputevents.def @@ -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) diff --git a/keybuf.c b/keybuf.c index 5388bcce..3d4fef52 100755 --- 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; diff --git a/newcpu.c b/newcpu.c index b4b3745d..700f8554 100755 --- 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) { diff --git a/od-win32/ahidsound.c b/od-win32/ahidsound.c index 46041a8d..d7912ab8 100755 --- a/od-win32/ahidsound.c +++ b/od-win32/ahidsound.c @@ -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(); diff --git a/od-win32/bsdsock.c b/od-win32/bsdsock.c index 9e337c06..de483484 100755 --- a/od-win32/bsdsock.c +++ b/od-win32/bsdsock.c @@ -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); diff --git a/od-win32/resources/resource.h b/od-win32/resources/resource.h index 5f1192a5..b5ff88d3 100755 --- a/od-win32/resources/resource.h +++ b/od-win32/resources/resource.h @@ -627,6 +627,8 @@ #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 diff --git a/od-win32/resources/winuae.rc b/od-win32/resources/winuae.rc index c6c0c771..d8bafe15 100755 --- a/od-win32/resources/winuae.rc +++ b/od-win32/resources/winuae.rc @@ -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 diff --git a/od-win32/win32gui.c b/od-win32/win32gui.c index 06b63cb6..e063dc07 100755 --- a/od-win32/win32gui.c +++ b/od-win32/win32gui.c @@ -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; -- 2.47.3