Hopefully final update to Logitech Bus Mouse - now works on DOS(MS 2.0/9.1), Win3, WfW311, Win95, Win98, NT 3.1, NT 3.51.

This commit is contained in:
waltje
2017-11-23 17:42:00 -05:00
parent 7aeaabeee0
commit 397c693170
7 changed files with 111 additions and 120 deletions

View File

@@ -62,9 +62,14 @@ extern "C" {
extern int dump_on_exit; /* (O) dump regs on exit*/ extern int dump_on_exit; /* (O) dump regs on exit*/
extern int do_dump_config; /* (O) dump cfg after load */ extern int do_dump_config; /* (O) dump cfg after load */
extern int start_in_fullscreen; /* (O) start in fullscreen */ extern int start_in_fullscreen; /* (O) start in fullscreen */
#ifdef _WIN32
extern int force_debug; /* (O) force debug output */
#endif
#ifdef USE_WX #ifdef USE_WX
extern int video_fps; /* (O) render speed in fps */ extern int video_fps; /* (O) render speed in fps */
#endif #endif
extern wchar_t log_path[1024]; /* (O) full path of logfile */
extern int window_w, window_h, /* (C) window size and */ extern int window_w, window_h, /* (C) window size and */
window_x, window_y, /* position info */ window_x, window_y, /* position info */
@@ -109,6 +114,7 @@ extern int nic_do_log;
extern wchar_t exe_path[1024]; /* path (dir) of executable */ extern wchar_t exe_path[1024]; /* path (dir) of executable */
extern wchar_t cfg_path[1024]; /* path (dir) of user data */ extern wchar_t cfg_path[1024]; /* path (dir) of user data */
extern FILE *stdlog; /* file to log output to */
extern int scrnsz_x, /* current screen size, X */ extern int scrnsz_x, /* current screen size, X */
scrnsz_y; /* current screen size, Y */ scrnsz_y; /* current screen size, Y */
extern int config_changed; /* config has changed */ extern int config_changed; /* config has changed */

View File

@@ -8,7 +8,7 @@
* *
* Configuration file handler. * Configuration file handler.
* *
* Version: @(#)config.c 1.0.31 2017/11/04 * Version: @(#)config.c 1.0.32 2017/11/23
* *
* Authors: Sarah Walker, * Authors: Sarah Walker,
* Miran Grca, <mgrca8@gmail.com> * Miran Grca, <mgrca8@gmail.com>
@@ -739,14 +739,6 @@ load_other_peripherals(void)
} }
bugger_enabled = !!config_get_int(cat, "bugger_enabled", 0); bugger_enabled = !!config_get_int(cat, "bugger_enabled", 0);
/* Remove these after a while. */
serial_enabled[0] = !!config_get_int(cat, "serial1_enabled", 1);
config_delete_var(cat, "serial1_enabled");
serial_enabled[1] = !!config_get_int(cat, "serial2_enabled", 1);
config_delete_var(cat, "serial2_enabled");
lpt_enabled = !!config_get_int(cat, "lpt_enabled", 1);
config_delete_var(cat, "lpt_enabled");
} }

View File

@@ -29,10 +29,21 @@
* then makes up its mind. Maybe an effort to 'debounce' the * then makes up its mind. Maybe an effort to 'debounce' the
* reading of the DIP switches? Oh-well. * reading of the DIP switches? Oh-well.
* *
* NOTES: Verified with:
* AMI WinBIOS 486 (OK, IRQ5 only)
* Microsoft Mouse V2.00 (DOS V6.22)
* Microsoft Mouse V9.1 (DOS V6.22)
* Microsoft WfW V3.11 on DOS V6.22
* GEOS V1.0: does not seem to work
* GEOS V2.0: does not seem to work
* Microsoft Windows 95 OSR2
* Microsoft Windows 98 SE
* Microsoft Windows NT 3.1
*
* Based on an early driver for MINIX 1.5. * Based on an early driver for MINIX 1.5.
* Based on the 86Box PS/2 mouse driver as a framework. * Based on the 86Box PS/2 mouse driver as a framework.
* *
* Version: @(#)mouse_bus.c 1.0.22 2017/11/15 * Version: @(#)mouse_bus.c 1.0.23 2017/11/22
* *
* Authors: Fred N. van Kempen, <decwiz@yahoo.com> * Authors: Fred N. van Kempen, <decwiz@yahoo.com>
* *
@@ -52,7 +63,8 @@
#define BUSMOUSE_PORT 0x023c /* default */ #define BUSMOUSE_PORT 0x023c /* default */
#define BUSMOUSE_IRQ 2 /* default (DOS,NT31) */ #define BUSMOUSE_IRQ 5 /* default (DOS,NT31) */
#define BUSMOUSE_DEBUG 0
#define ENABLE_3BTN 1 /* enable 3-button mode */ #define ENABLE_3BTN 1 /* enable 3-button mode */
@@ -106,7 +118,7 @@ lt_write(mouse_bus_t *ms, uint16_t port, uint8_t val)
{ {
uint8_t b; uint8_t b;
#if 1 #if BUSMOUSE_DEBUG
pclog("BUSMOUSE: lt_write(%d,%02x)\n", port, val); pclog("BUSMOUSE: lt_write(%d,%02x)\n", port, val);
#endif #endif
@@ -117,13 +129,10 @@ lt_write(mouse_bus_t *ms, uint16_t port, uint8_t val)
case MOUSE_MAGIC: /* [01] magic data register */ case MOUSE_MAGIC: /* [01] magic data register */
switch(val) { switch(val) {
case MAGIC_BYTE1: case MAGIC_BYTE1:
ms->r_ctrl = (CTRL_IDIS);
ms->r_magic = val;
break;
case MAGIC_BYTE2: case MAGIC_BYTE2:
ms->r_ctrl = (CTRL_IENB); ms->r_ctrl = (CTRL_IENB);
ms->r_magic = val; ms->r_magic = val;
ms->r_intr = 0x00;
break; break;
} }
break; break;
@@ -237,64 +246,29 @@ lt_read(mouse_bus_t *ms, uint16_t port)
break; break;
case MOUSE_CTRL: /* [02] control register */ case MOUSE_CTRL: /* [02] control register */
/* r = 0x0f;
* This is the weird stuff mentioned in the file header. switch(ms->irq) {
* The Microsoft "mouse" drivers (at least versions 2.0 case 2:
* through 9.1 for DOS) do some whacky things to extract r &= ~0x08;
* the configured IRQ channel from the board. break;
*
* First, it reads the current value, and then re-reads
* it another 10,000 (yes, really) times. It keeps track
* of whether or not the data has changed (to allow for
* de-bouncing the value.)
*
* Drivers that use 5A then expect the value to be a
* simple bitmask of the DIP switch settings, where bits
* 0 through 3 mean IRQ2 through IRQ5.
*
* Drivers that use A5 expect this first value to be the
* 2's complement of the actual IRQ value. Next, it does
* this a second time, but now with the IDIS bit clear
* (so, interrupts enabled), which is our cue to return
* the regular (not complemented) value to them.
*
* Since we have to fake the initial value and the settling
* of the data a bit later on, we first return a bunch of
* invalid ("random") data, and then the real value.
*
* Yes, this is weird. --FvK
*/
if (ms->r_magic == MAGIC_BYTE2) {
/*
* Drivers using 5A expect a bitmask
* of the DIP switch here, where bits
* 0..3 mean IRQ2..IRQ5.
*/
switch(ms->irq) {
case 2:
r = 0x01;
break;
case 3: case 3:
r = 0x02; r &= ~0x04;
break; break;
case 4: case 4:
r = 0x04; r &= ~0x02;
break; break;
case 5: case 5:
r = 0x08; r &= ~0x01;
break; break;
} }
if (ms->r_intr++ < 250) {
/* Still settling, return invalid data. */
r = (ms->r_ctrl & 0x10) ? r : 0x0f;
} else { } else {
if (ms->r_intr++ < 250) ms->r_intr = 0;
/* Still settling, return invalid data. */
r = (ms->r_ctrl&CTRL_IDIS) ? 0xff : 0x00;
else {
r = (ms->r_ctrl&CTRL_IDIS)?-ms->irq:ms->irq;
ms->r_intr = 0;
}
} }
break; break;
@@ -306,8 +280,8 @@ lt_read(mouse_bus_t *ms, uint16_t port)
break; break;
} }
#if 0 #if BUSMOUSE_DEBUG > 1
pclog("BUSMOUSE: lt_read(%d): %02x\n", port); pclog("BUSMOUSE: lt_read(%d): %02x\n", port, r);
#endif #endif
return(r); return(r);
@@ -358,20 +332,6 @@ bm_read(uint16_t port, void *priv)
} }
/* Called at 30hz */
static void
bm_timer(void *priv)
{
mouse_bus_t *ms = (mouse_bus_t *)priv;
ms->timer += ((1000000.0 / 30.0) * TIMER_USEC);
/* All set, generate an interrupt. */
if (! (ms->r_ctrl & CTRL_IDIS))
picint(1 << ms->irq);
}
/* The emulator calls us with an update on the host mouse device. */ /* The emulator calls us with an update on the host mouse device. */
static uint8_t static uint8_t
bm_poll(int x, int y, int z, int b, void *priv) bm_poll(int x, int y, int z, int b, void *priv)
@@ -411,11 +371,10 @@ bm_poll(int x, int y, int z, int b, void *priv)
ms->but = b; ms->but = b;
#if 1
/* All set, generate an interrupt. */ /* All set, generate an interrupt. */
if (! (ms->r_ctrl & CTRL_IDIS)) if (! (ms->r_ctrl & CTRL_IDIS))
picint(1 << ms->irq); picint(1 << ms->irq);
#endif
return(0); return(0);
} }
@@ -468,11 +427,6 @@ bm_init(mouse_t *info)
io_sethandler(BUSMOUSE_PORT, 4, io_sethandler(BUSMOUSE_PORT, 4,
bm_read, NULL, NULL, bm_write, NULL, NULL, ms); bm_read, NULL, NULL, bm_write, NULL, NULL, ms);
#if 0
/* Start the mouse interrupt timer. */
timer_add(bm_timer, &ms->timer, TIMER_ALWAYS_ENABLED, ms);
#endif
/* Return our private data to the I/O layer. */ /* Return our private data to the I/O layer. */
return(ms); return(ms);
} }

View File

@@ -8,7 +8,7 @@
* *
* Main emulator module where most things are controlled. * Main emulator module where most things are controlled.
* *
* Version: @(#)pc.c 1.0.45 2017/11/22 * Version: @(#)pc.c 1.0.45 2017/11/23
* *
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/> * Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com> * Miran Grca, <mgrca8@gmail.com>
@@ -82,9 +82,13 @@
int dump_on_exit = 0; /* (O) dump regs on exit */ int dump_on_exit = 0; /* (O) dump regs on exit */
int do_dump_config = 0; /* (O) dump config on load */ int do_dump_config = 0; /* (O) dump config on load */
int start_in_fullscreen = 0; /* (O) start in fullscreen */ int start_in_fullscreen = 0; /* (O) start in fullscreen */
#ifdef _WIN32
int force_debug = 0; /* (O) force debug output */
#endif
#ifdef USE_WX #ifdef USE_WX
int video_fps = RENDER_FPS; /* (O) render speed in fps */ int video_fps = RENDER_FPS; /* (O) render speed in fps */
#endif #endif
wchar_t log_path[1024] = { L'\0'}; /* (O) full path of logfile */
/* Configuration values. */ /* Configuration values. */
int window_w, window_h, /* (C) window size and */ int window_w, window_h, /* (C) window size and */
@@ -146,6 +150,7 @@ int gfx_present[GFX_MAX]; /* should not be here */
wchar_t exe_path[1024]; /* path (dir) of executable */ wchar_t exe_path[1024]; /* path (dir) of executable */
wchar_t cfg_path[1024]; /* path (dir) of user data */ wchar_t cfg_path[1024]; /* path (dir) of user data */
FILE *stdlog = NULL; /* file to log output to */
int scrnsz_x = SCREEN_RES_X, /* current screen size, X */ int scrnsz_x = SCREEN_RES_X, /* current screen size, X */
scrnsz_y = SCREEN_RES_Y; /* current screen size, Y */ scrnsz_y = SCREEN_RES_Y; /* current screen size, Y */
int config_changed; /* config has changed */ int config_changed; /* config has changed */
@@ -167,9 +172,20 @@ pclog(const char *format, ...)
va_list ap; va_list ap;
va_start(ap, format); va_start(ap, format);
vprintf(format, ap);
if (stdlog == NULL) {
if (log_path[0] != L'\0') {
stdlog = plat_fopen(log_path, L"w");
if (stdlog == NULL)
stdlog = stdout;
} else {
stdlog = stdout;
}
}
vfprintf(stdlog, format, ap);
va_end(ap); va_end(ap);
fflush(stdout); fflush(stdlog);
#endif #endif
} }
@@ -183,9 +199,20 @@ fatal(const char *format, ...)
char *sp; char *sp;
va_start(ap, format); va_start(ap, format);
if (stdlog == NULL) {
if (log_path[0] != L'\0') {
stdlog = plat_fopen(log_path, L"w");
if (stdlog == NULL)
stdlog = stdout;
} else {
stdlog = stdout;
}
}
vsprintf(temp, format, ap); vsprintf(temp, format, ap);
fprintf(stdout, "%s", temp); fprintf(stdlog, "%s", temp);
fflush(stdout); fflush(stdlog);
va_end(ap); va_end(ap);
nvr_save(); nvr_save();
@@ -347,25 +374,38 @@ pc_init(int argc, wchar_t *argv[])
usage: usage:
printf("\nUsage: 86box [options] [cfg-file]\n\n"); printf("\nUsage: 86box [options] [cfg-file]\n\n");
printf("Valid options are:\n\n"); printf("Valid options are:\n\n");
printf("-? or --help - show this information\n"); printf("-? or --help - show this information\n");
printf("-C or --dumpcfg - dump config file after loading\n"); printf("-C or --dumpcfg - dump config file after loading\n");
printf("-D or --dump - dump memory on exit\n"); #ifdef _WIN32
printf("-F or --fullscreen - start in fullscreen mode\n"); printf("-D or --debug - force debug output logging\n");
printf("-P or --vmpath path - set 'path' to be root for vm\n"); #endif
printf("-F or --fullscreen - start in fullscreen mode\n");
printf("-M or --memdump - dump memory on exit\n");
printf("-L or --logfile path - set 'path' to be the logfile\n");
printf("-P or --vmpath path - set 'path' to be root for vm\n");
#ifdef USE_WX #ifdef USE_WX
printf("-R or --fps num - set render speed to 'num' fps\n"); printf("-R or --fps num - set render speed to 'num' fps\n");
#endif #endif
printf("\nA config file can be specified. If none is, the default file will be used.\n"); printf("\nA config file can be specified. If none is, the default file will be used.\n");
return(0); return(0);
} else if (!wcscasecmp(argv[c], L"--dumpcfg") || } else if (!wcscasecmp(argv[c], L"--dumpcfg") ||
!wcscasecmp(argv[c], L"-C")) { !wcscasecmp(argv[c], L"-C")) {
do_dump_config = 1; do_dump_config = 1;
} else if (!wcscasecmp(argv[c], L"--dump") || #ifdef _WIN32
} else if (!wcscasecmp(argv[c], L"--debug") ||
!wcscasecmp(argv[c], L"-D")) { !wcscasecmp(argv[c], L"-D")) {
dump_on_exit = 1; force_debug = 1;
#endif
} else if (!wcscasecmp(argv[c], L"--fullscreen") || } else if (!wcscasecmp(argv[c], L"--fullscreen") ||
!wcscasecmp(argv[c], L"-F")) { !wcscasecmp(argv[c], L"-F")) {
start_in_fullscreen = 1; start_in_fullscreen = 1;
} else if (!wcscasecmp(argv[c], L"--logfile") ||
!wcscasecmp(argv[c], L"-L")) {
if ((c+1) == argc) goto usage;
wcscpy(log_path, argv[++c]);
} else if (!wcscasecmp(argv[c], L"--memdump") ||
!wcscasecmp(argv[c], L"-M")) {
} else if (!wcscasecmp(argv[c], L"--vmpath") || } else if (!wcscasecmp(argv[c], L"--vmpath") ||
!wcscasecmp(argv[c], L"-P")) { !wcscasecmp(argv[c], L"-P")) {
if ((c+1) == argc) goto usage; if ((c+1) == argc) goto usage;
@@ -708,9 +748,11 @@ pc_reset_hard_close(void)
suppress_overscan = 0; suppress_overscan = 0;
nvr_save(); nvr_save();
machine_close(); machine_close();
device_close_all(); device_close_all();
midi_close(); midi_close();
mouse_emu_close(); mouse_emu_close();
closeal(); closeal();

View File

@@ -8,7 +8,7 @@
* *
* Platform main support module for Windows. * Platform main support module for Windows.
* *
* Version: @(#)win.c 1.0.36 2017/11/18 * Version: @(#)win.c 1.0.37 2017/11/20
* *
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/> * Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com> * Miran Grca, <mgrca8@gmail.com>
@@ -20,6 +20,7 @@
*/ */
#define UNICODE #define UNICODE
#include <windows.h> #include <windows.h>
#include <fcntl.h>
#include <stdio.h> #include <stdio.h>
#include <stdint.h> #include <stdint.h>
#include <string.h> #include <string.h>
@@ -158,7 +159,6 @@ plat_get_string(int i)
#ifndef USE_WX #ifndef USE_WX
# ifdef USE_CONSOLE
/* Create a console if we don't already have one. */ /* Create a console if we don't already have one. */
static void static void
CreateConsole(int init) CreateConsole(int init)
@@ -205,7 +205,6 @@ CreateConsole(int init)
*stdin = *fp; *stdin = *fp;
#endif #endif
} }
# endif
/* Process the commandline, and create standard argc/argv array. */ /* Process the commandline, and create standard argc/argv array. */
@@ -277,7 +276,7 @@ ProcessCommandLine(wchar_t ***argw)
* For the Windows platform, this is the start of the application. * For the Windows platform, this is the start of the application.
*/ */
int WINAPI int WINAPI
WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpszArg, int nFunsterStil) WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpszArg, int nCmdShow)
{ {
wchar_t **argw = NULL; wchar_t **argw = NULL;
int argc, i; int argc, i;
@@ -296,29 +295,27 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpszArg, int nFunsterStil)
/* First, set our (default) language. */ /* First, set our (default) language. */
set_language(0x0409); set_language(0x0409);
#ifdef USE_CONSOLE
/* Create console window. */ /* Create console window. */
CreateConsole(1); CreateConsole(1);
#endif
/* Process the command line for options. */ /* Process the command line for options. */
argc = ProcessCommandLine(&argw); argc = ProcessCommandLine(&argw);
/* Pre-initialize the system, this loads the config file. */ /* Pre-initialize the system, this loads the config file. */
if (! pc_init(argc, argw)) { if (! pc_init(argc, argw)) {
#ifdef USE_CONSOLE
/* Detach from console. */ /* Detach from console. */
CreateConsole(0); CreateConsole(0);
#endif
return(1); return(1);
} }
/* Cleanup: we no longer need the commandline arguments. */ /* Cleanup: we no longer need the commandline arguments. */
if (! force_debug)
CreateConsole(0);
free(argw[0]); free(argw[0]);
free(argw); free(argw);
/* Handle our GUI. */ /* Handle our GUI. */
i = ui_init(nFunsterStil); i = ui_init(nCmdShow);
return(i); return(i);
} }

View File

@@ -8,7 +8,7 @@
* *
* Platform support defintions for Win32. * Platform support defintions for Win32.
* *
* Version: @(#)win.h 1.0.9 2017/11/12 * Version: @(#)win.h 1.0.10 2017/11/20
* *
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/> * Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com> * Miran Grca, <mgrca8@gmail.com>
@@ -99,7 +99,7 @@ extern int hard_disk_was_added(void);
/* Platform UI support functions. */ /* Platform UI support functions. */
extern int ui_init(int nStyle); extern int ui_init(int nCmdShow);
/* Functions in win_about.c: */ /* Functions in win_about.c: */

View File

@@ -8,7 +8,7 @@
* *
* user Interface module for WinAPI on Windows. * user Interface module for WinAPI on Windows.
* *
* Version: @(#)win_ui.c 1.0.3 2017/11/19 * Version: @(#)win_ui.c 1.0.4 2017/11/20
* *
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/> * Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com> * Miran Grca, <mgrca8@gmail.com>
@@ -642,7 +642,7 @@ SubWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
int int
ui_init(int nFunsterStil) ui_init(int nCmdShow)
{ {
WCHAR title[200]; WCHAR title[200];
WNDCLASSEX wincl; /* buffer for main window's class */ WNDCLASSEX wincl; /* buffer for main window's class */
@@ -709,7 +709,7 @@ ui_init(int nFunsterStil)
ResetAllMenus(); ResetAllMenus();
/* Make the window visible on the screen. */ /* Make the window visible on the screen. */
ShowWindow(hwnd, nFunsterStil); ShowWindow(hwnd, nCmdShow);
/* Load the accelerator table */ /* Load the accelerator table */
haccel = LoadAccelerators(hinstance, ACCEL_NAME); haccel = LoadAccelerators(hinstance, ACCEL_NAME);