; keyv540.inc -- public keyv540 v0.2 KEYMD candidate (PCB-V540-1)
; Alex Barragan & ChatGPT (Sol), 2026-10-14.
; HD61 Rev 0.45, LEVEL 0; include ONCE per final ROM assembly.
; No executable bytes. keyv540.s supplies the implementation and table.
; Hardware scope: PB-2000C / AI-1000; NOT generic HD61700/PB-1000.
K540_EV_NONE: EQU &H00
K540_EV_CHAR: EQU &H01
K540_EV_MENU: EQU &H02
K540_EV_BRK: EQU &H03
K540_EV_CAPS: EQU &H04
K540_MODE_CAPS: EQU &H40
; API: CAL K540_INIT, CAL K540_GET, CAL K540_MODE, CAL K540_RESET.
; INIT/RESET clear borrowed RAM1:09E4h KEYMD to 00h.
; GET blocks until a complete physical press/release:
; $17 = event; $0 = key for CHAR or 9Ch for MENU,
; $0 = 00h for CAPS/BRK; $13 = copied current CAPS mode (40h).
; MODE returns the current stored mode in $13 (without changing it).
; NO caller register must preserve CAPS mode across calls.
; MENU/BRK are EVENTS ONLY. No automatic jumps inside this library.
; Integration must not run host CRTKY while keyv540 owns KEYMD.
; On exit call RESET if returning to host firmware expectations.
; Clobbers: $0..$5, $15, $17, IX, IA/KY; condition flags unspecified.
; On return UA=&H14. Requires valid SSP and ROM2/card access.
; Does not restore IX or OTHER scratch registers. Caller saves its own.
; During GET no auto-repeat; key held until release. No polling API yet.
; Borrowing RAM1:09E4h has not been certified on both machines.
; This is an ISOLATED test candidate, not a public v0.2 release.