; lib-set-01 first native test ROM - provisional LAB IDs, PB scaffold
; New active source has its own owner; donors remain unchanged.
OFFCHK: EQU     &H04EF
WORK1:  EQU     &H0CE6
SETBK:  EQU     &H0276
CRTKY:  EQU     &H0460
SYSCLR: EQU     &H3169
SETLCD: EQU     &H328F
SET4LN: EQU     &H28D8
CROFF:  EQU     &H22FA
EDCSR:  EQU     &H08CB
CSREN:  EQU     &H22E0
KEYMD:  EQU     &H09E4
SSPTP:  EQU     &H0FEF
USPTP:  EQU     &H0CE2
SSPBT:  EQU     &H0EEE
RCS:    EQU     SSPBT+16
LAB_ID: EQU     &H72      ; ch01v2 r001 PROVISIONAL, not a registered allocation
LAB_VER:EQU     &H10      ; first startup/integration probe
KEYEXE:EQU     &H0D
KEYDEL:EQU     &H11     ; r010c physical DEL observed in Keyboard Lab diagnostic
KEYINS:EQU     &H12     ; r010c physical INS observed in Keyboard Lab diagnostic
KEYUP: EQU     &H1E
KEYDN: EQU     &H1F
; VT20 r003: CRTKY arrow aliases corrected from owner emulator observation.
; Physical LEFT previously activated V20_RIGHTKEY; pending r003 native retest.
KEYLEFT:EQU     &H1D
KEYRIGHT:EQU    &H1C
KEYMENU:EQU     &H9C
KEYETC:EQU      &H95     ; Chapter 09 r001b owner-observed ETC success
KEYF1:EQU      &HFC
KEYF2:EQU      &HFD
KEYF3:EQU      &HFE
KEYF4:EQU      &HFF
KEYQ:  EQU      &H51
KEYQLC:EQU     &H71
SRC_ROM:EQU     0
SRC_RAM:EQU     1
; UA=14 bank-one workspace; caller-owned tape canvas occupies 2000..277F.
T22_BASE:EQU    &H2000
V20_TOP:EQU     &H2780
V20_LEFT:EQU    &H2781
V20_DPTR:EQU    &H2782
V20_DIDX:EQU    &H2784
V20_FAIL:EQU    &H2785
V20_STAT:EQU    &H2786
U_PASS:EQU      &H2787
U_FAIL:EQU      &H2788
; VT20 command input and report scratch. RAM beyond 2788 is candidate-owned.
V20_INVAL:EQU    &H2789
V20_INLEN:EQU    &H278A
RPT_CHAR:EQU     &H278B
RPT_INDEX:EQU    &H278C
RPT_FLAGS:EQU    &H2850    ; 72 native result flags: 2850..2897
RPT_ACT:EQU      &H28A0    ; 72*4 primary native U32 values: 28A0..29BF
RPT_REM:EQU      &H29C0    ; 12*4 DIV remainders: 29C0..29EF
RPT_FMT:EQU      &H2A00    ; 12*(left+11 byte text+right) = 156 bytes
RPT_FMTLEN:EQU   &H2AA0    ; 12 actual returned formatter lengths
RPT_DSTAT:EQU    &H2AB0    ; 12 native decimal-append status bytes
RPT_HEX:EQU      &H27B0    ; eight text bytes used during detail rendering


; r005 SPLASH private scratch after r004 Lab report allocations.
SPL_PTR:EQU      &H27C0   ; 16-bit ROM pointer
SPL_WAITN:EQU    &H27C2   ; requested TM-transition count


; r006 MENU candidate state, held in platform UA=14 bank. No VT overlap.
MNU_TABLE:EQU    &H27D0   ; ROM pointer (2)
MNU_COUNT:EQU    &H27D2   ; group count (1)
MNU_GROUP:EQU    &H27D3   ; zero-based group (1)
MNU_SCAN:EQU     &H27D4   ; configuration scan (1)
MNU_ALIAS:EQU    &H27D5   ; 4 normalized effective aliases
MNU_SEL:EQU      &H27D9   ; saved selected FK during key release


; r007 KEYBOARD single-event private snapshot (no other service overlap).
KBD_CODE:EQU     &H27DA   ; last translated key code
KBD_STATUS:EQU   &H27DB   ; 1 normal, 2 raw BRK
LAB_MFK:EQU      &H27DC   ; Lab-only selected default FK ordinal


; r008 Lab-owned diagnostic snapshot. Separate from K540 borrowed KEYMD.
LAB_KVALUE:EQU    &H27DD
LAB_KMODE:EQU     &H27DE


; r010 INPUT private state 27E0..27EC, not caller buffer/VT20.
INP_PTR:EQU      &H27E0   ; caller RAM pointer, little endian (2)
INP_CAP:EQU      &H27E2   ; capacity INCLUDING final NUL
INP_LEN:EQU      &H27E3   ; logical field length
INP_CUR:EQU      &H27E4   ; cursor offset in logical text
INP_LEFT:EQU     &H27E5   ; zero-based viewport origin
INP_WIDTH:EQU    &H27E6   ; visible columns (1..32)
INP_POS:EQU      &H27E7   ; first physical LCD position
INP_CLASS:EQU    &H27E8   ; 0 any, 1 digits, 2 hexadecimal
INP_UPDN:EQU     &H27E9   ; 0 ignore, 1 terminate
INP_MODE:EQU     &H27EA   ; 0 insert, 1 overwrite
INP_KEY:EQU      &H27EB   ; last logical physical event code
INP_EXIT:EQU     &H27EC   ; 0 key, 1 MENU, 2 BRK
; Lab-only caller-owned text buffer, distinct from the reusable Input.
LAB_IBUF:EQU     &H2800   ; 40 content bytes + terminal NUL
LAB_IGUARD:EQU   &H2829   ; first byte after caller field capacity
LAB_ICLASS:EQU   &H282C   ; selected Lab-only input character class
LAB_IMODE:EQU    &H282D   ; initial caller mode
LAB_IPOL:EQU     &H282E   ; caller UP/DOWN policy
LAB_ISTART:EQU   &H282F   ; initial length, 0 or 4
LAB_IEXIT:EQU    &H2830   ; caller's last event code
LAB_ISTAT:EQU    &H2831   ; caller's last exit status
LAB_ILEN:EQU     &H2832   ; caller's last final length


; r011a Lab-only numerical counters (UA=14): separate from Input and VT20.
U_ADD_P:EQU      &H2833
U_ADD_F:EQU      &H2834
U_SUB_P:EQU      &H2835
U_SUB_F:EQU      &H2836
U_MUL_P:EQU      &H2837
U_MUL_F:EQU      &H2838
U_EXEC:EQU       &H2839
U_ABORT:EQU      &H283A
U_D32_P:EQU      &H283B
U_D32_F:EQU      &H283C
U_D16_P:EQU      &H283D
U_D16_F:EQU      &H283E
U_M32_P:EQU      &H283F
U_M32_F:EQU      &H2840
U_M16_P:EQU      &H2841
U_M16_F:EQU      &H2842
LAB_CPAGE:EQU     &H2843 ; 0=ADD/SUB/MUL, 1=DIV/MOD, 2=DECIMAL
U_DAP_P:EQU      &H2844
U_DAP_F:EQU      &H2845
U_FMT_P:EQU      &H2846
U_FMT_F:EQU      &H2847
U_REM_GUARD:EQU  &H29F0  ; immediately after 12*4 division remainders
U_CANARY:EQU     &H2AC0  ; immediately after r011c report memory