LIB2 / FILE VIEW

USER_MANUAL.md

DOWNLOAD ORIGINAL ↓

# KEYBOARD / generation 3 — User manual

**Library:** `src/lib2/keyboard/3/`  
**Edition:** 2026-11-18, source/document review (documentation only)  
**Qualification:** Accepted CLARITAS source/native parity including public K540_RAW symbol repair; SHIFT/CAPS/editor runtime and physical-machine qualification remain separate.

## What this member does

K540 keyboard matrix event service with CAPS latch, one-shot SHIFT, and a four-entry keyboard session adapter.

## Public interfaces

| Entry point or group | Inputs, outputs and behavior |
|---|---|
| `K540_INIT / K540_RESET` | Initialize/clear borrowed keyboard mode RAM. |
| `K540_GET` | Blocking press/release; `$17` event, `$0` key, `$13` mode. |
| `K540_MODE` | Read current CAPS/SHIFT mode from RAM to `$13`. |
| `K540_RAW` | Exposed raw scan entry used by consumers. |
| `KBD_INIT / KBD_EVENT / KBD_RESET / KBD_RELEASE` | Card-local keyboard-session wrappers. |

## How to integrate

Include `keyv540.inc` once, then `keyv540.s`; optionally `keyboard.s` for session wrapper. `CAL KBD_INIT`, repeat `CAL KBD_EVENT`, inspect `$17/$0/$13`, then `CAL KBD_RESET` before host keyboard resumes.

**Composition sketch (not an independently assembled client):**

```asm
#INCLUDE (lib2/keyboard/3/keyv540.inc)
; Supply the dependencies, RAM, bank context and symbols described above.
        CAL     K540_INIT
```

## Environment, dependencies and memory

Borrowed RAM1 `09E4h`, valid stack, correct ROM placement and no concurrent host CRTKY. Events include `K540_EV_CHAR`, `MENU`, `BRK`, `CAPS`, `SHIFT`; CAPS=40h, SHIFT=80h. Clobbers documented in keyv540.inc.

## Limits and evidence

`K540_RAW` is intentionally public; `_K540_*` internals are not. Verify SHIFT one-shot and editor interaction on the actual consumer before claiming runtime PASS.

**This documentation does not introduce a new build or runtime PASS.** Source equivalence, native assembler parity, emulator execution and physical-machine evidence remain distinct.

## Actual source and further reference

- [This exact member folder in Google Drive](https://drive.google.com/drive/folders/1ywSaHsJCCOwI1e03GSc_1GhQMdgKkp0R)
- Source modules: `keyv540.inc`, `keyv540.s`, `keyboard.s`.
- Further contracts/source notes: keyv540.inc. These may include dated donor paths or older acceptance statements.
- For a new consumer, pin exact source files and hashes, verify full include closure, inspect register/bank/resource conflicts and test the resulting application on each claimed target.

*Praeteritum ad futurum servamus.*