From b0ca953af252f9314c5a0be1d0a02b8e4caff3c3 Mon Sep 17 00:00:00 2001 From: tmk Date: Fri, 17 Feb 2023 11:56:09 +0900 Subject: [PATCH] ibmpc_usb: Fix keyboard ID for XT The converter doesn't read keyboard ID for XT now. ibmpc.protocol should be set at WAIT_AA before calling read_keybaord_id(). --- converter/ibmpc_usb/ibmpc_usb.cpp | 18 ++++++++++++++---- converter/ibmpc_usb/ibmpc_usb.hpp | 9 ++++++--- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/converter/ibmpc_usb/ibmpc_usb.cpp b/converter/ibmpc_usb/ibmpc_usb.cpp index 831abf69..28895444 100644 --- a/converter/ibmpc_usb/ibmpc_usb.cpp +++ b/converter/ibmpc_usb/ibmpc_usb.cpp @@ -132,9 +132,11 @@ int16_t IBMPCConverter::read_wait(uint16_t wait_ms) * Keyboard ID * * 0000: IBM 84-key keyboard - * FFFF: XT keyobard + * FFFF: No keyboard or XT * FFFE: Broken AT or PS/2 keyboard? * FFFD: Zenith Z-150 AT + * FFFC: IBM XT + * FFFB: Clone XT * AB83: AT or PS/2 keyboard * BFBF: IBM Terminal keyboard * 00FF: Mouse @@ -149,17 +151,21 @@ uint16_t IBMPCConverter::read_keyboard_id(void) // https://deskthority.net/viewtopic.php?p=495196#p495196 if (ibmpc.protocol == IBMPC_PROTOCOL_AT_Z150) return 0xFFFD; + // XT doesn't response + if (ibmpc.protocol == IBMPC_PROTOCOL_XT_IBM) return 0xFFFC; + if (ibmpc.protocol == IBMPC_PROTOCOL_XT_CLONE) return 0xFFFB; + // Disable //code = ibmpc_host_send(0xF5); // Read ID code = ibmpc.host_send(0xF2); - if (code == -1) { id = 0xFFFF; goto DONE; } // XT or No keyboard + if (code == -1) { id = 0xFFFF; goto DONE; } // No keyboard or XT if (code != 0xFA) { id = 0xFFFE; goto DONE; } // Broken PS/2? // ID takes 500ms max TechRef [8] 4-41 code = read_wait(500); - if (code == -1) { id = 0x0000; goto DONE; } // AT + if (code == -1) { id = 0x0000; goto DONE; } // AT IBM 84-key id = (code & 0xFF)<<8; // Mouse responds with one-byte 00, this returns 00FF [y] p.14 @@ -322,12 +328,16 @@ uint8_t IBMPCConverter::process_interface(void) if (0x0000 == keyboard_id) { // CodeSet2 AT(IBM PC AT 84-key) keyboard_kind = PC_AT; - } else if (0xFFFF == keyboard_id) { // CodeSet1 XT + } else if (0xFFFF == keyboard_id) { // No keyboard or XT keyboard_kind = PC_XT; } else if (0xFFFE == keyboard_id) { // CodeSet2 PS/2 fails to response? keyboard_kind = PC_AT; } else if (0xFFFD == keyboard_id) { // Zenith Z-150 AT keyboard_kind = PC_AT; + } else if (0xFFFC == keyboard_id) { // IBM XT + keyboard_kind = PC_XT; + } else if (0xFFFB == keyboard_id) { // Clone XT + keyboard_kind = PC_XT; } else if (0x00FF == keyboard_id) { // Mouse is not supported keyboard_kind = PC_MOUSE; } else if (0xAB85 == keyboard_id || // IBM 122-key Model M, NCD N-97 diff --git a/converter/ibmpc_usb/ibmpc_usb.hpp b/converter/ibmpc_usb/ibmpc_usb.hpp index 552bec8f..068f694c 100644 --- a/converter/ibmpc_usb/ibmpc_usb.hpp +++ b/converter/ibmpc_usb/ibmpc_usb.hpp @@ -16,10 +16,13 @@ typedef enum { NONE, PC_XT, PC_AT, PC_TERMINAL, PC_MOUSE } keyboard_kind_t; kind == PC_MOUSE ? "MOUSE" : \ "NONE") -#define ID_STR(id) (id == 0xFFFE ? "_????" : \ +#define ID_STR(id) (id == 0xFFFF ? "_NONE" : \ + (id == 0xFFFE ? "_ERROR" : \ (id == 0xFFFD ? "_Z150" : \ - (id == 0x0000 ? "_AT84" : \ - ""))) + (id == 0xFFFC ? "_IBM" : \ + (id == 0xFFFB ? "_CLONE" : \ + (id == 0x0000 ? "_IBM84" : \ + "")))))) #define ROW(code) ((code>>4)&0x07) #define COL(code) (code&0x0F)