diff --git a/src/hardware/keyboard.cpp b/src/hardware/keyboard.cpp index 7ec8cf29b..a05f0cb3a 100644 --- a/src/hardware/keyboard.cpp +++ b/src/hardware/keyboard.cpp @@ -302,18 +302,6 @@ void KEYBOARD_SetLEDs(Bit8u bits) { LOG(LOG_KEYBOARD,LOG_DEBUG)("Keyboard LEDs: SCR=%u NUM=%u CAPS=%u",bits&1,(bits>>1)&1,(bits>>2)&1); } -// believe it or not most BIOSes will also periodically check the BIOS data area -// and send updated keyboard LED state from it if it changes, from within IRQ 0 (INT 8h). -// This is not documented anywhere I know, but it's been my experience with DOS -// programming and Windows 3.1/9x keyboard handling seems to rely on it. -void KEYBOARD_BIOS_CheckLEDs_From_DataArea(Bitu bits) { - if ((bits & 7) != (keyb.led_state & 7)) { - keyb.led_state = bits; - UpdateKeyboardLEDState(bits); - LOG(LOG_KEYBOARD, LOG_DEBUG)("Keyboard LEDs (from BIOS data area update): SCR=%u NUM=%u CAPS=%u", bits & 1, (bits >> 1) & 1, (bits >> 2) & 1); - } -} - static Bitu read_p60(Bitu port,Bitu iolen) { keyb.p60changed=false; keyb.auxchanged=false; diff --git a/src/ints/bios.cpp b/src/ints/bios.cpp index a7a9a1510..95c88373e 100644 --- a/src/ints/bios.cpp +++ b/src/ints/bios.cpp @@ -1894,7 +1894,16 @@ static void BIOS_HostTimeSync() { // TODO: make option bool enable_bios_timer_synchronize_keyboard_leds = true; -void KEYBOARD_BIOS_CheckLEDs_From_DataArea(Bitu x); +void KEYBOARD_SetLEDs(Bit8u bits); + +void BIOS_KEYBOARD_SetLEDs(Bitu state) { + Bitu x = mem_readb(BIOS_KEYBOARD_LEDS); + + x &= ~7; + x |= (state & 7); + mem_writeb(BIOS_KEYBOARD_LEDS,x); + KEYBOARD_SetLEDs(state); +} static Bitu INT8_Handler(void) { /* Increase the bios tick counter */ @@ -1913,8 +1922,13 @@ static Bitu INT8_Handler(void) { it when handling the keyboard from it's own driver. Their driver does hook the keyboard and handles keyboard I/O by itself, but it still allows the BIOS to do the keyboard magic from IRQ 0 (INT 8h). Yech. */ - if (enable_bios_timer_synchronize_keyboard_leds) - KEYBOARD_BIOS_CheckLEDs_From_DataArea((mem_readb(BIOS_KEYBOARD_STATE) >> 4) & 7); + if (enable_bios_timer_synchronize_keyboard_leds) { + Bitu should_be = (mem_readb(BIOS_KEYBOARD_STATE) >> 4) & 7; + Bitu led_state = (mem_readb(BIOS_KEYBOARD_LEDS) & 7); + + if (should_be != led_state) + BIOS_KEYBOARD_SetLEDs(should_be); + } #if DOSBOX_CLOCKSYNC static bool check = false; diff --git a/vs2015/.vs/dosbox-x/v14/.suo b/vs2015/.vs/dosbox-x/v14/.suo index a6d0fe9e7..d1bc42444 100644 Binary files a/vs2015/.vs/dosbox-x/v14/.suo and b/vs2015/.vs/dosbox-x/v14/.suo differ