Add game port device with 6 I/O ports for the Crystal CS4237/8B

This commit is contained in:
RichardG867
2021-06-03 01:14:48 -03:00
parent 80fb5775e4
commit dfd6d4e2df
3 changed files with 23 additions and 10 deletions

View File

@@ -45,6 +45,7 @@ typedef struct {
typedef struct _gameport_ {
uint16_t addr;
uint8_t len;
struct _joystick_instance_ *joystick;
struct _gameport_ *next;
} gameport_t;
@@ -314,7 +315,7 @@ gameport_remap(void *priv, uint16_t address)
}
}
io_removehandler(dev->addr, (dev->addr & 1) ? 1 : 8,
io_removehandler(dev->addr, dev->len,
gameport_read, NULL, NULL, gameport_write, NULL, NULL, dev);
}
@@ -334,7 +335,7 @@ gameport_remap(void *priv, uint16_t address)
other_dev->next = dev;
}
io_sethandler(dev->addr, (dev->addr & 1) ? 1 : 8,
io_sethandler(dev->addr, dev->len,
gameport_read, NULL, NULL, gameport_write, NULL, NULL, dev);
}
}
@@ -358,7 +359,7 @@ gameport_add(const device_t *gameport_type)
{
/* 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))
if (!(gameport_type->local & 0x1000000) || (machines[machine].flags & MACHINE_GAMEPORT))
standalone_gameport_type = NULL;
/* Add game port device. */
@@ -401,6 +402,7 @@ gameport_init(const device_t *info)
dev->joystick = joystick_instance;
/* Map game port to the default address. Not applicable on PnP-only ports. */
dev->len = (info->local >> 16) & 0xff;
gameport_remap(dev, info->local & 0xffff);
/* Register ISAPnP if this is a standard game port card. */
@@ -433,7 +435,7 @@ gameport_close(void *priv)
const device_t gameport_device = {
"Game port",
0, 0x200,
0, 0x080200,
gameport_init,
gameport_close,
NULL, { NULL }, NULL,
@@ -442,7 +444,7 @@ const device_t gameport_device = {
const device_t gameport_201_device = {
"Game port (port 201h only)",
0, 0x201,
0, 0x010201,
gameport_init,
gameport_close,
NULL, { NULL }, NULL,
@@ -451,7 +453,16 @@ const device_t gameport_201_device = {
const device_t gameport_pnp_device = {
"Game port (Plug and Play only)",
0, 0,
0, 0x080000,
gameport_init,
gameport_close,
NULL, { NULL }, NULL,
NULL
};
const device_t gameport_pnp_6io_device = {
"Game port (Plug and Play only, 6 I/O ports)",
0, 0x060000,
gameport_init,
gameport_close,
NULL, { NULL }, NULL,
@@ -460,7 +471,7 @@ const device_t gameport_pnp_device = {
const device_t gameport_sio_device = {
"Game port (Super I/O)",
0, 0x10000,
0, 0x1080000,
gameport_init,
gameport_close,
NULL, { NULL }, NULL,

View File

@@ -108,6 +108,7 @@ 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_pnp_6io_device;
extern const device_t gameport_sio_device;
extern const device_t *standalone_gameport_type;

View File

@@ -720,6 +720,10 @@ cs423x_init(const device_t *info)
break;
}
/* Initialize game port. The '7B and '8B game port only responds to 6 I/O ports; the remaining
2 ports are reserved on those chips, and probably connected to the Digital Assist feature. */
dev->gameport = gameport_add((dev->type == CRYSTAL_CS4236B) ? &gameport_pnp_device : &gameport_pnp_6io_device);
break;
}
@@ -731,9 +735,6 @@ cs423x_init(const device_t *info)
cs423x_reset(dev);
sound_add_handler(cs423x_get_buffer, dev);
/* Initialize game port. */
dev->gameport = gameport_add(&gameport_pnp_device);
/* Initialize I2C bus for the EEPROM. */
dev->i2c = i2c_gpio_init("nvr_cs423x");