; ======================================================================
; XANDRIAN LABS  /  CS617 CHAPTER 02
; ======================================================================
; Program    : Chapter 02 Sorting
; Source     : app/workspace.inc
; Revision   : x0.31a-dev / comment-harmonization pass
; Target     : Casio PB-2000C / HD61700
; Role       : Reserve all app-owned RAM, DATA and VT canvas state.
; Interface  : RN_*, WS_*, PG_*, RCS_RAM, RS_SCRATCH_RAM, VT_* RAM.
; Maintainer : Xandrian Labs
; ----------------------------------------------------------------------
; Distinct scratch allocations prevent serial/code aliasing.
; ======================================================================

RN_BUF:
        DS      5
RN_BASE:
        DS      2
RN_LEN:
        DS      2
RN_CAP:
        DS      2
RN_POS:
        DS      2
RN_DBASE:
        DS      1
RN_REASON:
        DS      1

WS_NBUF:
        DS      5
WS_MBUF:
        DS      5
WS_NLEN:
        DS      1
WS_MLEN:
        DS      1
WS_PAT:
        DS      1
WS_CUR:
        DS      1
WS_TICK:
        DS      1
WS_EDIT:
        DS      1
WS_EPOS:
        DS      1
WS_NEW:
        DS      1
WS_NVAL:
        DS      4
WS_MVAL:
        DS      4
WS_ERR:
        DS      1

WS_KCMP:
        DS      4
WS_ICMP:
        DS      4
WS_DWR:
        DS      4
WS_BEND:
        DS      2
WS_BSWAP:
        DS      1
WS_SGAP:
        DS      2
WS_DEC10:
        DS      10

WS_VTOP:
        DS      2
WS_VPTR:
        DS      2
WS_VLINE:
        DS      32

DATA:
        DS      DATA_BYTES

DATA_END:

; Active VT26 state: separate from DATA and sorting metrics.
; 24 x 80 read-only canvas; separate from sort data.
VT_CANVAS:
        DS      &H0780
VT_SEL_RAM:
        DS      1
VT_TOP_RAM:
        DS      1
VT_LEFT_RAM:
        DS      1
VT_PTR_RAM:
        DS      2
VT_IDX_RAM:
        DS      1
VT_VAL_RAM:
        DS      1
VT_LEN_RAM:
        DS      1
VT_BASE_RAM:
        DS      2
VT_KIND_RAM:
        DS      1
; VT export cursor state is caller RAM, separate from RS scratch.
VTX_PTR_RAM:
        DS      2
VTX_COLS_RAM:
        DS      1
VTX_ROWS_RAM:
        DS      1
; Read-only ROM signature diagnostic LCD scratch (not VT canvas).
VTX_DIAG_RAM:
        DS      32
; DATA logical-page state belongs to the app, not to VT26.
PG_REC_RAM:
        DS      2
PG_COL_RAM:
        DS      2
PG_OFF_RAM:
        DS      2
PG_OWNER_RAM:
        DS      1                   ; 1 report, 2 data; app-only
; Next page state produced from exactly 20 filled document data lines.
PG_NEXT_REC_RAM:
        DS      2
PG_NEXT_COL_RAM:
        DS      2
PG_NEXT_OFF_RAM:
        DS      2
PG_MORE_RAM:
        DS      1                   ; 1 if another logical page exists
; Last successfully verified sort whose counters are reportable:
; 0/1/2/3.
WS_LAST_ALGO:
        DS      1                   ; none / Bubble / Shell / Selection
; Dedicated 45-byte bank1 firmware trampoline; does not overlap code/UI.
RCS_RAM:
        DS      &H2D                ; 0C4D-0C20: exact 45-byte code stub
; RS232C private bank1 scratch (7 bytes), separate from RCS and VT.
; Old fixed 27F0h..27F9h scratch collided with executable VT.
RS_SCRATCH_RAM:
        DS      7                   ; PTR2, COUNT2, BAUD1, FLOW1, ACTIVE1

; VT26-only, caller-owned UI state (never aliases code or RS232C).
VT_INV_RAM:
        DS      1                   ; 0 normal, 1 inverse viewport
VT_LC_TICK_RAM:
        DS      1                   ; last TM sample for :l cursor
VT_LC_VIS_RAM:
        DS      1                   ; cursor overlay currently visible
VT_RAM_END:

COPY_END:

; end of include
