From e6f208ef3318ee973c3ca79289ad29ddd3e1dc69 Mon Sep 17 00:00:00 2001 From: OBattler Date: Fri, 28 Oct 2022 02:23:08 +0200 Subject: [PATCH] And applied the same change to the Vendex (and all other XT clones) by separating the XT clone keyboard/PPI from the IBM XT 1986 one, and giving the clone one the PC-style port D read out on port 60h when keyboard is disabled, fixes #2213. --- src/device/keyboard_xt.c | 36 ++++++++++++++++++++++++++---------- src/include/86box/keyboard.h | 1 + src/machine/m_xt.c | 2 +- 3 files changed, 28 insertions(+), 11 deletions(-) diff --git a/src/device/keyboard_xt.c b/src/device/keyboard_xt.c index 4a7015ec3..bd9a9e1c7 100644 --- a/src/device/keyboard_xt.c +++ b/src/device/keyboard_xt.c @@ -66,6 +66,7 @@ #define KBD_TYPE_OLIVETTI 8 #define KBD_TYPE_ZENITH 9 #define KBD_TYPE_PRAVETZ 10 +#define KBD_TYPE_XTCLONE 11 typedef struct { int want_irq; @@ -584,8 +585,9 @@ kbd_read(uint16_t port, void *priv) switch (port) { case 0x60: /* Keyboard Data Register (aka Port A) */ - if ((kbd->pb & 0x80) && ((kbd->type == KBD_TYPE_PC81) || (kbd->type == KBD_TYPE_PC82) || (kbd->type == KBD_TYPE_PRAVETZ) || (kbd->type == KBD_TYPE_XT82) || (kbd->type == KBD_TYPE_XT86) || (kbd->type == KBD_TYPE_COMPAQ) || (kbd->type == KBD_TYPE_ZENITH))) { - if ((kbd->type == KBD_TYPE_PC81) || (kbd->type == KBD_TYPE_PC82) || (kbd->type == KBD_TYPE_COMPAQ) || (kbd->type == KBD_TYPE_PRAVETZ)) + if ((kbd->pb & 0x80) && ((kbd->type == KBD_TYPE_PC81) || (kbd->type == KBD_TYPE_PC82) || (kbd->type == KBD_TYPE_PRAVETZ) || (kbd->type == KBD_TYPE_XT82) || + (kbd->type == KBD_TYPE_XT86) || (kbd->type == KBD_TYPE_XTCLONE) || (kbd->type == KBD_TYPE_COMPAQ) || (kbd->type == KBD_TYPE_ZENITH))) { + if ((kbd->type == KBD_TYPE_PC81) || (kbd->type == KBD_TYPE_PC82) || (kbd->type == KBD_TYPE_XTCLONE) || (kbd->type == KBD_TYPE_COMPAQ) || (kbd->type == KBD_TYPE_PRAVETZ)) ret = (kbd->pd & ~0x02) | (hasfpu ? 0x02 : 0x00); else if ((kbd->type == KBD_TYPE_XT82) || (kbd->type == KBD_TYPE_XT86)) ret = 0xff; /* According to Ruud on the PCem forum, this is supposed to return 0xFF on the XT. */ @@ -669,9 +671,9 @@ kbd_read(uint16_t port, void *priv) break; case 0x63: /* Keyboard Configuration Register (aka Port D) */ - if ((kbd->type == KBD_TYPE_XT82) || (kbd->type == KBD_TYPE_XT86) - || (kbd->type == KBD_TYPE_COMPAQ) - || (kbd->type == KBD_TYPE_TOSHIBA)) + if ((kbd->type == KBD_TYPE_XT82) || (kbd->type == KBD_TYPE_XT86) || + (kbd->type == KBD_TYPE_XTCLONE) || (kbd->type == KBD_TYPE_COMPAQ) || + (kbd->type == KBD_TYPE_TOSHIBA)) ret = kbd->pd; break; @@ -732,8 +734,9 @@ kbd_init(const device_t *info) if ((kbd->type == KBD_TYPE_PC81) || (kbd->type == KBD_TYPE_PC82) || (kbd->type == KBD_TYPE_PRAVETZ) || (kbd->type == KBD_TYPE_XT82) || - (kbd->type <= KBD_TYPE_XT86) || (kbd->type == KBD_TYPE_COMPAQ) || - (kbd->type == KBD_TYPE_TOSHIBA) || (kbd->type == KBD_TYPE_OLIVETTI)) { + (kbd->type <= KBD_TYPE_XT86) || (kbd->type == KBD_TYPE_XTCLONE) || + (kbd->type == KBD_TYPE_COMPAQ) || (kbd->type == KBD_TYPE_TOSHIBA) || + (kbd->type == KBD_TYPE_OLIVETTI)) { /* DIP switch readout: bit set = OFF, clear = ON. */ if (kbd->type == KBD_TYPE_OLIVETTI) @@ -752,9 +755,8 @@ kbd_init(const device_t *info) kbd->pd |= get_videomode_switch_settings(); /* Switches 3, 4 - memory size. */ - if ((kbd->type == KBD_TYPE_XT86) - || (kbd->type == KBD_TYPE_COMPAQ) - || (kbd->type == KBD_TYPE_TOSHIBA)) { + if ((kbd->type == KBD_TYPE_XT86) || (kbd->type == KBD_TYPE_XTCLONE) || + (kbd->type == KBD_TYPE_COMPAQ) || (kbd->type == KBD_TYPE_TOSHIBA)) { switch (mem_size) { case 256: kbd->pd |= 0x00; @@ -1048,3 +1050,17 @@ const device_t keyboard_xt_zenith_device = { .force_redraw = NULL, .config = NULL }; + +const device_t keyboard_xtclone_device = { + .name = "XT (Clone) Keyboard", + .internal_name = "keyboard_xtclone", + .flags = 0, + .local = KBD_TYPE_XTCLONE, + .init = kbd_init, + .close = kbd_close, + .reset = kbd_reset, + { .available = NULL }, + .speed_changed = NULL, + .force_redraw = NULL, + .config = NULL +}; diff --git a/src/include/86box/keyboard.h b/src/include/86box/keyboard.h index b310e1553..3919ba5e3 100644 --- a/src/include/86box/keyboard.h +++ b/src/include/86box/keyboard.h @@ -156,6 +156,7 @@ extern const device_t keyboard_xt_lxt3_device; # endif extern const device_t keyboard_xt_olivetti_device; extern const device_t keyboard_xt_zenith_device; +extern const device_t keyboard_xtclone_device; extern const device_t keyboard_at_device; extern const device_t keyboard_at_ami_device; extern const device_t keyboard_at_samsung_device; diff --git a/src/machine/m_xt.c b/src/machine/m_xt.c index e36da3208..167d2ec51 100644 --- a/src/machine/m_xt.c +++ b/src/machine/m_xt.c @@ -175,7 +175,7 @@ machine_xt86_init(const machine_t *model) static void machine_xt_clone_init(const machine_t *model) { - device_add(&keyboard_xt86_device); + device_add(&keyboard_xtclone_device); machine_xt_common_init(model); }