From 17c25a1029ef00ea6fd63455b51fe58b28552f78 Mon Sep 17 00:00:00 2001 From: stefan-b-jakobsson <70063525+stefan-b-jakobsson@users.noreply.github.com> Date: Thu, 22 Aug 2024 23:02:06 +0300 Subject: [PATCH] [KERNAL] Num Lock as first keystroke fix (#354) * [KERNAL] enable control and persisting of ps2kbd LED state, respond to numlock * extapi setter must use .X, and for consistency change getter * Check command status before sending set LED status command --------- Co-authored-by: mooinglemur --- kernal/drivers/x16/ps2kbd.s | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/kernal/drivers/x16/ps2kbd.s b/kernal/drivers/x16/ps2kbd.s index 95bda023..d7376cc8 100644 --- a/kernal/drivers/x16/ps2kbd.s +++ b/kernal/drivers/x16/ps2kbd.s @@ -39,7 +39,9 @@ I2C_ADDRESS = $42 I2C_KBD_ADDRESS = $43 I2C_GET_SCANCODE_OFFSET = $07 +I2C_GET_KBD_CMD_STATUS = $18 I2C_KBD_CMD2 = $1a +I2C_CMD_PENDING = $01 MODIFIER_SHIFT = 1 ; C64: Shift MODIFIER_ALT = 2 ; C64: Commodore @@ -594,6 +596,12 @@ kbd_leds: _set_kbd_leds: ldx #I2C_ADDRESS + ldy #I2C_GET_KBD_CMD_STATUS +: jsr i2c_read_byte + cmp #I2C_CMD_PENDING + beq :- + + ; Set LED state command ldy #I2C_KBD_CMD2 lda #$ed jsr i2c_write_first_byte