From b5a295e91dad42b934ded20527fe21c9b4fecb26 Mon Sep 17 00:00:00 2001 From: RichardG867 Date: Thu, 3 Jun 2021 00:53:52 -0300 Subject: [PATCH] Continuing the game port overhaul: added support for Super I/O game ports not being broken out --- src/game/gameport.c | 19 +++++++++++++++---- src/include/86box/gameport.h | 2 ++ src/include/86box/machine.h | 1 + src/machine/machine.c | 1 + src/machine/machine_table.c | 2 +- src/sio/sio_um8669f.c | 4 ++-- 6 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/game/gameport.c b/src/game/gameport.c index d7f399ab3..2c56f13b8 100644 --- a/src/game/gameport.c +++ b/src/game/gameport.c @@ -119,7 +119,7 @@ static const isapnp_device_config_t gameport_pnp_defaults[] = { const device_t *standalone_gameport_type; -static int gameport_instance_id = 0; +int gameport_instance_id = 0; /* Linked list of active game ports. Only the top port responds to reads or writes, and ports at the standard 200h location are prioritized. */ static gameport_t *active_gameports = NULL; @@ -356,8 +356,10 @@ gameport_pnp_config_changed(uint8_t ld, isapnp_device_config_t *config, void *pr void * gameport_add(const device_t *gameport_type) { - /* Prevent a standalone game port from being added later on. */ - standalone_gameport_type = NULL; + /* Prevent a standalone game port from being added later on, unless this + is an unused Super I/O game port (no MACHINE_GAMEPORT machine flag). */ + if (!(gameport_type->local & 0x10000) || (machines[machine].flags & MACHINE_GAMEPORT)) + standalone_gameport_type = NULL; /* Add game port device. */ return device_add_inst(gameport_type, gameport_instance_id++); @@ -399,7 +401,7 @@ gameport_init(const device_t *info) dev->joystick = joystick_instance; /* Map game port to the default address. Not applicable on PnP-only ports. */ - gameport_remap(dev, info->local); + gameport_remap(dev, info->local & 0xffff); /* Register ISAPnP if this is a standard game port card. */ if (info->local == 0x200) @@ -455,3 +457,12 @@ const device_t gameport_pnp_device = { NULL, { NULL }, NULL, NULL }; + +const device_t gameport_sio_device = { + "Game port (Super I/O)", + 0, 0x10000, + gameport_init, + gameport_close, + NULL, { NULL }, NULL, + NULL +}; diff --git a/src/include/86box/gameport.h b/src/include/86box/gameport.h index 406234f45..9f5da7f00 100644 --- a/src/include/86box/gameport.h +++ b/src/include/86box/gameport.h @@ -108,9 +108,11 @@ extern "C" { extern const device_t gameport_device; extern const device_t gameport_201_device; extern const device_t gameport_pnp_device; +extern const device_t gameport_sio_device; extern const device_t *standalone_gameport_type; #endif +extern int gameport_instance_id; extern plat_joystick_t plat_joystick_state[MAX_PLAT_JOYSTICKS]; extern joystick_t joystick_state[MAX_JOYSTICKS]; extern int joysticks_present; diff --git a/src/include/86box/machine.h b/src/include/86box/machine.h index 9e627a7e7..677dc7027 100644 --- a/src/include/86box/machine.h +++ b/src/include/86box/machine.h @@ -61,6 +61,7 @@ #define MACHINE_SOUND 0x00008000 /* sys has int sound */ #define MACHINE_FDC 0x00010000 /* sys has int FDC */ #define MACHINE_NIC 0x00020000 /* sys has int NIC */ +#define MACHINE_GAMEPORT 0x00040000 /* sys has int game port */ /* Combined flags. */ #define MACHINE_VIDEO_FIXED 0x00003000 /* sys has fixed int video */ /* Feature flags for internal storage controllers. */ diff --git a/src/machine/machine.c b/src/machine/machine.c index e3f2ef600..ae731e522 100644 --- a/src/machine/machine.c +++ b/src/machine/machine.c @@ -76,6 +76,7 @@ machine_init_ex(int m) is_vpc = 0; standalone_gameport_type = NULL; + gameport_instance_id = 0; /* Set up the architecture flags. */ AT = IS_AT(machine); diff --git a/src/machine/machine_table.c b/src/machine/machine_table.c index d33ffd2a3..117afc4d4 100644 --- a/src/machine/machine_table.c +++ b/src/machine/machine_table.c @@ -340,7 +340,7 @@ const machine_t machines[] = { { "[i430VX] HP Brio 80xx", "brio80xx", MACHINE_TYPE_SOCKET7, CPU_PKG_SOCKET5_7, 0, 66666667, 66666667, 2200, 3520, 1.5, 3.0, MACHINE_PCI | MACHINE_BUS_PS2 | MACHINE_IDE_DUAL, 8192, 131072, 8192, 127, machine_at_brio80xx_init, NULL }, { "[i430VX] Packard Bell PB680", "pb680", MACHINE_TYPE_SOCKET7, CPU_PKG_SOCKET5_7, 0, 50000000, 66666667, 2800, 3520, 1.5, 3.0, MACHINE_PCI | MACHINE_BUS_PS2 | MACHINE_IDE_DUAL, 8192, 131072, 8192, 127, machine_at_pb680_init, NULL }, { "[i430VX] PC Partner MB520N", "mb520n", MACHINE_TYPE_SOCKET7, CPU_PKG_SOCKET5_7, 0, 50000000, 66666667, 2600, 3520, 1.5, 3.0, MACHINE_PCI | MACHINE_BUS_PS2 | MACHINE_IDE_DUAL, 8192, 131072, 8192, 127, machine_at_mb520n_init, NULL }, - { "[i430VX] Shuttle HOT-557", "430vx", MACHINE_TYPE_SOCKET7, CPU_PKG_SOCKET5_7, 0, 50000000, 66666667, 2500, 3520, 1.5, 3.0, MACHINE_PCI | MACHINE_BUS_PS2 | MACHINE_IDE_DUAL, 8192, 131072, 8192, 127, machine_at_i430vx_init, NULL }, + { "[i430VX] Shuttle HOT-557", "430vx", MACHINE_TYPE_SOCKET7, CPU_PKG_SOCKET5_7, 0, 50000000, 66666667, 2500, 3520, 1.5, 3.0, MACHINE_PCI | MACHINE_BUS_PS2 | MACHINE_IDE_DUAL | MACHINE_GAMEPORT, 8192, 131072, 8192, 127, machine_at_i430vx_init, NULL }, /* 430TX */ { "[i430TX] ADLink NuPRO-592", "nupro592", MACHINE_TYPE_SOCKET7, CPU_PKG_SOCKET5_7, 0, 66666667, 66666667, 1900, 2800, 1.5, 5.5, MACHINE_PCI | MACHINE_BUS_PS2 | MACHINE_IDE_DUAL, 8192, 262144, 8192, 255, machine_at_nupro592_init, NULL }, diff --git a/src/sio/sio_um8669f.c b/src/sio/sio_um8669f.c index 5087c7439..516685629 100644 --- a/src/sio/sio_um8669f.c +++ b/src/sio/sio_um8669f.c @@ -89,7 +89,7 @@ static const isapnp_device_config_t um8669f_pnp_defaults[] = { }, { .activate = 0 }, { - .activate = 1, + .activate = 0, .io = { { .base = 0x200 }, } } }; @@ -287,7 +287,7 @@ um8669f_init(const device_t *info) dev->uart[0] = device_add_inst(&ns16550_device, 1); dev->uart[1] = device_add_inst(&ns16550_device, 2); - dev->gameport = gameport_add(&gameport_pnp_device); + dev->gameport = gameport_add(&gameport_sio_device); io_sethandler(0x0108, 0x0002, um8669f_read, NULL, NULL, um8669f_write, NULL, NULL, dev);