diff --git a/src/86box.c b/src/86box.c index d96a571c0..cd573d98f 100644 --- a/src/86box.c +++ b/src/86box.c @@ -174,7 +174,7 @@ int force_43 = 0; /* (C) video * int video_filter_method = 1; /* (C) video */ int video_vsync = 0; /* (C) video */ int video_framerate = -1; /* (C) video */ -bool serial_passthrough_enabled[SERIAL_MAX] = { 0, 0, 0, 0, 0, 0, 0 }; /* (C) activation and kind of +bool serial_passthrough_enabled[SERIAL_MAX - 1] = { 0, 0, 0, 0, 0, 0, 0 }; /* (C) activation and kind of pass-through for serial ports */ int bugger_enabled = 0; /* (C) enable ISAbugger */ int novell_keycard_enabled = 0; /* (C) enable Novell NetWare 2.x key card emulation. */ diff --git a/src/config.c b/src/config.c index 98923d9cf..52a80763a 100644 --- a/src/config.c +++ b/src/config.c @@ -746,7 +746,7 @@ load_ports(void) char temp[512]; memset(temp, 0, sizeof(temp)); - for (int c = 0; c < SERIAL_MAX; c++) { + for (int c = 0; c < (SERIAL_MAX - 1); c++) { sprintf(temp, "serial%d_enabled", c + 1); com_ports[c].enabled = !!ini_section_get_int(cat, temp, (c >= 2) ? 0 : 1); @@ -1839,7 +1839,7 @@ config_load(void) com_ports[0].enabled = 1; com_ports[1].enabled = 1; - for (i = 2; i < SERIAL_MAX; i++) + for (i = 2; i < (SERIAL_MAX - 1); i++) com_ports[i].enabled = 0; lpt_ports[0].enabled = 1; @@ -2459,7 +2459,7 @@ save_ports(void) ini_section_t cat = ini_find_or_create_section(config, "Ports (COM & LPT)"); char temp[512]; - for (int c = 0; c < SERIAL_MAX; c++) { + for (int c = 0; c < (SERIAL_MAX - 1); c++) { sprintf(temp, "serial%d_enabled", c + 1); if (((c < 2) && com_ports[c].enabled) || ((c >= 2) && !com_ports[c].enabled)) ini_section_delete_var(cat, temp); diff --git a/src/device/mouse_serial.c b/src/device/mouse_serial.c index 24d7ae853..7505cf3a3 100644 --- a/src/device/mouse_serial.c +++ b/src/device/mouse_serial.c @@ -843,10 +843,13 @@ sermouse_init(const device_t *info) mouse_t *dev; void (*rcr_callback)(struct serial_s *serial, void *priv); void (*dev_write)(struct serial_s *serial, void *priv, uint8_t data); - void (*transmit_period_callback)(struct serial_s *serial, void *priv, double transmit_period); + void (*transmit_period_callback)(struct serial_s *serial, void *priv, + double transmit_period); if (info->local == MOUSE_TYPE_MSYSTEMSB) { - uintptr_t irqbase = ((device_get_config_int("irq") << 16) | (device_get_config_hex16("addr") << 20)) | ns16450_device.local; + uintptr_t irqbase = ((device_get_config_int("irq") << 16) | + (device_get_config_hex16("addr") << 20)) | + ns16450_device.local; device_add_params(&ns16450_device, (void*)irqbase); } @@ -894,7 +897,7 @@ sermouse_init(const device_t *info) } } - dev->port = (info->local == MOUSE_TYPE_MSYSTEMSB) ? SERIAL_MAX : device_get_config_int("port"); + dev->port = (info->local == MOUSE_TYPE_MSYSTEMSB) ? (SERIAL_MAX - 1) : device_get_config_int("port"); /* Attach a serial port to the mouse. */ rcr_callback = dev->rts_toggle ? sermouse_callback : NULL; @@ -982,6 +985,8 @@ static const device_config_t mssbusmouse_config[] = { .selection = { { .description = "0x338", .value = 0x338 }, { .description = "0x238", .value = 0x238 }, + { .description = "0x3f8", .value = 0x3f8 }, + { .description = "0x2f8", .value = 0x2f8 }, { .description = "" } }, .bios = { { 0 } } diff --git a/src/device/serial.c b/src/device/serial.c index c00cfad10..71be924c1 100644 --- a/src/device/serial.c +++ b/src/device/serial.c @@ -38,7 +38,7 @@ #include <86box/serial.h> #include <86box/mouse.h> -serial_port_t com_ports[SERIAL_MAX + 1]; +serial_port_t com_ports[SERIAL_MAX]; enum { SERIAL_INT_LSR = 1, @@ -53,7 +53,7 @@ enum { void serial_update_ints(serial_t *dev); static int next_inst = 0; -static serial_device_t serial_devices[SERIAL_MAX + 1]; +static serial_device_t serial_devices[SERIAL_MAX]; static void serial_xmit_d_empty_evt(void *priv); @@ -932,9 +932,8 @@ serial_init(const device_t *info) serial_t *dev = (serial_t *) calloc(1, sizeof(serial_t)); int orig_inst = next_inst; - if (info->local & 0xFFF00000) { - next_inst = SERIAL_MAX; - } + if (info->local & 0xFFF00000) + next_inst = SERIAL_MAX - 1; dev->inst = next_inst; @@ -945,13 +944,12 @@ serial_init(const device_t *info) dev->sd = &(serial_devices[next_inst]); dev->sd->serial = dev; - if (info->local & 0xFFF00000) { + if (info->local & 0xfff00000) { dev->base_address = info->local >> 20; dev->irq = (info->local >> 16) & 0xF; io_sethandler(dev->base_address, 0x0008, serial_read, NULL, NULL, serial_write, NULL, NULL, dev); next_inst = orig_inst; - } - else if (next_inst == 6) + } else if (next_inst == 6) serial_setup(dev, COM7_ADDR, COM7_IRQ); else if (next_inst == 5) serial_setup(dev, COM6_ADDR, COM6_IRQ); @@ -996,7 +994,7 @@ serial_init(const device_t *info) serial_reset_port(dev); } - if (!(info->local & 0xFFF00000)) + if (!(info->local & 0xfff00000)) next_inst++; return dev; @@ -1011,7 +1009,7 @@ serial_set_next_inst(int ni) void serial_standalone_init(void) { - while (next_inst < SERIAL_MAX) + while (next_inst < (SERIAL_MAX - 1)) device_add_inst(&ns8250_device, next_inst + 1); }; diff --git a/src/device/serial_passthrough.c b/src/device/serial_passthrough.c index 3ad969006..25db29096 100644 --- a/src/device/serial_passthrough.c +++ b/src/device/serial_passthrough.c @@ -54,7 +54,7 @@ serial_passthrough_log(const char *fmt, ...) void serial_passthrough_init(void) { - for (uint8_t c = 0; c < SERIAL_MAX; c++) { + for (uint8_t c = 0; c < (SERIAL_MAX - 1); c++) { if (serial_passthrough_enabled[c]) { /* Instance n for COM n */ device_add_inst(&serial_passthrough_device, c + 1); diff --git a/src/include/86box/86box.h b/src/include/86box/86box.h index 7f7723bba..e19665535 100644 --- a/src/include/86box/86box.h +++ b/src/include/86box/86box.h @@ -27,7 +27,7 @@ /* Configuration values. */ #define GFXCARD_MAX 2 -#define SERIAL_MAX 7 +#define SERIAL_MAX 8 #define PARALLEL_MAX 4 #define SCREEN_RES_X 640 #define SCREEN_RES_Y 480 diff --git a/src/include/86box/serial.h b/src/include/86box/serial.h index c6259d7bc..31c77ce5a 100644 --- a/src/include/86box/serial.h +++ b/src/include/86box/serial.h @@ -116,7 +116,7 @@ typedef struct serial_port_s { uint8_t enabled; } serial_port_t; -extern serial_port_t com_ports[SERIAL_MAX + 1]; +extern serial_port_t com_ports[SERIAL_MAX]; extern serial_t *serial_attach_ex(int port, void (*rcr_callback)(struct serial_s *serial, void *priv), diff --git a/src/include/86box/serial_passthrough.h b/src/include/86box/serial_passthrough.h index 7ca6479d6..c5454194a 100644 --- a/src/include/86box/serial_passthrough.h +++ b/src/include/86box/serial_passthrough.h @@ -55,7 +55,7 @@ typedef struct serial_passthrough_s { void *backend_priv; /* Private platform backend data */ } serial_passthrough_t; -extern bool serial_passthrough_enabled[SERIAL_MAX]; +extern bool serial_passthrough_enabled[SERIAL_MAX - 1]; extern const device_t serial_passthrough_device; extern void serial_passthrough_init(void); diff --git a/src/qt/qt_settingsports.cpp b/src/qt/qt_settingsports.cpp index f68106dc9..2b57a683c 100644 --- a/src/qt/qt_settingsports.cpp +++ b/src/qt/qt_settingsports.cpp @@ -58,7 +58,7 @@ SettingsPorts::save() lpt_ports[i].enabled = checkBox->isChecked() ? 1 : 0; } - for (int i = 0; i < SERIAL_MAX; i++) { + for (int i = 0; i < (SERIAL_MAX - 1); i++) { auto *checkBox = findChild(QString("checkBoxSerial%1").arg(i + 1)); auto *checkBoxPass = findChild(QString("checkBoxSerialPassThru%1").arg(i + 1)); if (checkBox != NULL) @@ -118,7 +118,7 @@ SettingsPorts::onCurrentMachineChanged(int machineId) cbox[i]->setEnabled(lpt_ports[i].enabled > 0); } - for (int i = 0; i < SERIAL_MAX; i++) { + for (int i = 0; i < (SERIAL_MAX - 1); i++) { auto *checkBox = findChild(QString("checkBoxSerial%1").arg(i + 1)); auto *checkBoxPass = findChild(QString("checkBoxSerialPassThru%1").arg(i + 1)); auto *buttonPass = findChild(QString("pushButtonSerialPassThru%1").arg(i + 1));