Skip to content

Commit 7301304

Browse files
authored
[KERNAL] kbd_leds extapi (#220)
* [KERNAL] kbd_leds extapi * minor fixes * fix typo
1 parent e75d1c9 commit 7301304

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

X16 Reference - 05 - KERNAL.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1695,6 +1695,7 @@ Registers affected: Varies
16951695
| `$0B` | [`led_update`](#extapi-function-name-led_update) | Illuminates or clears the SMC activity LED based on disk activity or error status | - | - | - |
16961696
| `$0C` | [`mouse_set_position`](#extapi-function-name-mouse_set_position) | Moves the mouse cursor to a specific X/Y location | .X (.X)-(.X+3) | - | - |
16971697
| `$0D` | [`scnsiz`](#extapi-function-name-scnsiz) | Directly sets the kernal editor text dimensions | .X .Y | - | - |
1698+
| `$0E` | [`kbd_leds`](#extapi-function-name-kbd_leds) | Set or get the state of the PS/2 keyboard LEDs | .X .P | .X | - |
16981699

16991700

17001701
---
@@ -2314,6 +2315,50 @@ do_80x25:
23142315

23152316
---
23162317

2318+
#### extapi Function Name: kbd_leds
2319+
2320+
Purpose: Set or retrieve the PS/2 keyboard LED state
2321+
Minimum ROM version: R48
2322+
Call address: $FEAB, .A=14
2323+
Communication registers: .X .P
2324+
Preparatory routines: None
2325+
Error returns: (none)
2326+
Registers affected: .A .X .Y .P
2327+
2328+
**Description:** This routine is used to send a command to the keyboard to set the state of the Num Lock, Caps Lock, and Scroll Lock LEDs. You can also query the KERNAL for its idea of what the state of the LEDs is.
2329+
2330+
Note: This call does **not** change the state of the kernal's caps lock toggle.
2331+
2332+
**How to Use:**
2333+
2334+
1) To query the state of the LEDs, set carry, otherwise to set the LED state, clear carry and set .X to the desired value of the LED register. Bit 0 is Scroll Lock, bit 1 is Num Lock, and bit 2 is Caps Lock.
2335+
2) Call `kbd_leds`
2336+
3) If carry was set on the call to `kbd_leds`, the routine will return with .X set to the current state, otherwise the routine will send the updated LED state to the keyboard. In this case, there will be no confirmation on whether it was successful.
2337+
2338+
**EXAMPLE:**
2339+
2340+
This example toggles the state of the LEDs to the opposite state that they were initially.
2341+
2342+
```ASM
2343+
2344+
EXTAPI = $FEAB
2345+
E_KBD_LEDS = $0E
2346+
2347+
flip_leds:
2348+
sec
2349+
lda #E_KBD_LEDS
2350+
jsr EXTAPI ; fetch state
2351+
txa
2352+
eor #7 ; invert the LED state
2353+
tax
2354+
clc
2355+
lda #E_KBD_LEDS
2356+
jsr EXTAPI ; set state and send to keyboard
2357+
rts
2358+
```
2359+
2360+
---
2361+
23172362

23182363
#### Function Name: monitor
23192364

0 commit comments

Comments
 (0)