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:
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
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;
"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)"
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"
|| 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)
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;
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;
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);
#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
int fast_copper;
int scsi;
int uaeserial;
- int catweasel_io;
+ int catweasel;
int cpu_idle;
int cpu_cycle_exact;
int blitter_cycle_exact;
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)
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;
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) {
return 0;
case 20:
- return enforcer_enable();
+ return enforcer_enable(m68k_dreg (regs, 1));
case 21:
return enforcer_disable();
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);
#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
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
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);
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) {
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;