; > &.Hdr.WorkSpace

; ***********************************
; ***    C h a n g e   L i s t    ***
; ***********************************

; Date       Name  Description
; ----       ----  -----------
; 04-Feb-87  SKS   Added GenErrorFlag
; 09-Feb-87  APT     "   CurrentErrorBuffer, removed RMTempWSpace
; 16-Feb-87  APT   Added sound workspace bits
; 19-Feb-87  RCM   Added spChoosePtr
; 25-Feb-87  APT   HelpBuffer, HelpBufferSize
; 27-Feb-87  TMD   Added MapCursorAddr
; 02-Mar-87  TMD   Removed MapCursorAddr, added TeletextOffset, TeletextCount
; 13-Mar-87  TMD   Removed TextPlain, added teletext workspace
; 16-Mar-87  TMD   GWLCol,GWRCol,GWTRow,GWBRow moved out of mode-variable area
; 18-Mar-87  TMD   Mode variables re-mangled
; 19-Mar-87  TMD   Mode variables re-re-mangled
; 24-Mar-87  TMD   Added CursorStack
; 25-Mar-87  TMD   Moved TotalScreenSize to be in first 1K of VDWS
; 25-Mar-87  TMD   Added WrchNbit
; 09-Apr-87  TMD   Added MaxMode, VDU workspace reformatted, SaveR13 removed
; 28-Apr-87  TMD   Added CentiCounter
; 05-May-87  TMD   Added SoftResetVars, HardResetVars, PowerOnResetVars
; 08-May-87  TMD   Added BeepBlock
; 14-May-87  TMD   Extended PrinterActive to a word (is a handle now!)
; 18-May-87  TMD   Added (and then removed) PrinterPrefix and PrinterTypeName !
; 18-May-87  TMD   ESCHAN changed to EscHan
; 19-May-87  TMD   Added ScreenMemoryClaimed
; 27-May-87  TMD   Added Alphabet, Keyboard
; 24-Jul-87  TMD   Made PalIndex a mode variable again
; 03-Aug-87  TMD   Added mode variable CursorIndex
; 03-Aug-87  TMD   Renamed YWindAddr as YWindLimit, YEigFacAddr as YEigFactor
; 04-Aug-87  TMD   Made XWindLimit, YWindLimit into mode variables
; 04-Aug-87  TMD   Added mode variable ECFIndex
; 11-Aug-87  TMD   Added CursorNbit
; 17-Aug-87  TMD   Moved YEigFactor
; 18-Aug-87  TMD   Moved CursorNbit to be just after CursorFill
; 18-Aug-87  TMD   Added RAMMaskTb, a few more moved around!
; 18-Sep-87  TMD   Moved LineLength
; 22-Sep-87  TMD   Added VduSpriteArea, VduSprite
; 17-Nov-87  TMD   More comments added in vdu driver stuff
; 04-Dec-87  TMD   Added ECFShift, ECFYOffset
; 10-Dec-87  TMD   Added DisplayNColour, DisplayModeFlags
; 15-Dec-87  TMD   Added KeyAlphabet
; 16-Dec-87  TMD   Removed KeyAlphabet (can't extend workspace in this world!)
; 14-Jan-88  TMD   Added VduSaveArea, VduSaveAreaPtr
; 16-Feb-88  TMD   Added DisplayModeNo
; 17-Feb-88  TMD   Converted # n-1 :AND: -@ into AlignSpace n in line with
;                   Hdr.NewSpace
; 19-Feb-88  TMD   Added DisplayScreenStart
; 25-Feb-88  TMD   Reordered mode variables
; 02-Mar-88  TMD   Reordered them again
; 03-Mar-88  TMD   Added VduOutputCurrentState and SpriteMaskSelect
; 07-Mar-88  TMD   Added GCharSizes, GCharSizeX, GCharSizeY
; 08-Mar-88  TMD   Added GCharSpacing, GCharSpaceX, GCharSpaceY
; 08-Mar-88  TMD   Moved GCharSizes..GCharSpaceY into first 1K of workspace
; 10-Mar-88  TMD   Added HLineAddr
; 17-Mar-88  TMD   Added DisplayXWindLimit, DisplayYWindLimit,
;                   DisplayXEigFactor, DisplayYEigFactor, PointerXEigFactor
; 21-Mar-88  TMD   Removed CursorIndex
; 22-Mar-88  TMD   Added TCharSizeX,TCharSizeY,TCharSpaceX,TCharSpaceY
; 29-Mar-88  TMD   Added GcolOraEorAddr
; 31-Mar-88  TMD   Removed WsFontPtr
; 11-Apr-88  TMD   Added OldNVECTORS, sorted out expansion possibilities,
;                   put KeyAlphabet back
; 12-Apr-88  TMD   Added SerialFlags
; 18-Apr-88  TMD   Added XONXOFFChar
; 24-May-88  TMD   Added ClipBoxEnable, ClipBoxLCol..ClipBoxTRow, moved in
;                   ScrLoaSpriteCB, ScrLoaBuffer, SrcSavCommon
; 24-May-88  TMD   Flood fill uses ScratchSpace if AssemblingArthur


OldNVECTORS * &20

; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
; module handler Workspace offset definitions :
; N.B. These rely on Hdr.Heap having been got!!!!

        ^  0,R12
MHHPD      #  24 ; HeapDescSize  really

ModuleList #  4
MHWSpcSize *  @-MHHPD      ; get abs symbol.

; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
; system vector table

        ^  0,R12
FirstVec   #  0

VecSize    *  @-FirstVec

; End of vector space
; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
; system variables

        ^  0,R12

OSBYTEFirstVar  #  0

ByteVars  #  0                 ; The main osbyte variables, accessed
; via calls &A6 to &FF

VarStart  #  2                 ; &A6,&A7
ROMPtr    #  2                 ; &A8,&A9
ROMInfo   #  2                 ; &AA,&AB
KBTran    #  2                 ; &AC,&AD
VDUvars   #  2                 ; &AE,&AF

CFStime   #  1                 ; &B0
InputStream #  1               ; &B1
KeyBdSema #  1                 ; &B2

ROMPollSema #  1               ; &B3
OSHWM     #  1                 ; &B4

RS423mode #  1                 ; &B5
NoIgnore  #  1                 ; &B6
CFSRFS    #  1                 ; &B7
VULAcopy  #  2                 ; &B8,&B9

ROMatBRK  #  1                 ; &BA
BASICROM  #  1                 ; &BB

ADCchanel #  1                 ; &BC
ADCmaxchn #  1                 ; &BD
ADCconv   #  1                 ; &BE

RS423use     #  1              ; &BF
RS423conflag #  1              ; &C0

FlashCount # 1                 ; &C1
SpacPeriod # 1                 ; &C2
MarkPeriod # 1                 ; &C3

KeyRepDelay # 1                ; &C4
KeyRepRate  # 1                ; &C5

ExecFileH   # 1                ; &C6
SpoolFileH  # 1                ; &C7

ESCBREAK    # 1                ; &C8 (200)

KeyBdDisable # 1               ; &C9
KeyBdStatus  # 1               ; &CA

RS423HandShake # 1             ; &CB
RS423InputSupr # 1             ; &CC
RS423CFSFlag   # 1             ; &CD

EconetOScall # 1               ; &CE
EconetOSrdch # 1               ; &CF
EconetOSwrch # 1               ; &D0

SpeechSupr # 1                 ; &D1
SoundSupr # 1                  ; &D2

BELLchannel # 1                ; &D3
BELLinfo    # 1                ; &D4
BELLfreq    # 1                ; &D5
BELLdur     # 1                ; &D6

StartMessSupr # 1              ; &D7

SoftKeyLen # 1                 ; &D8

PageModeLineCount # 1          ; &D9

VDUqueueItems # 1              ; &DA

TABch # 1                      ; &DB
ESCch # 1                      ; &DC

IPbufferCh # 4                 ; &DD,&DE,&DF,&E0
RedKeyCh   # 4                 ; &E1,&E2,&E3,&E4

ESCaction  # 1                 ; &E5
ESCeffect  # 1                 ; &E6

u6522IRQ # 1                   ; &E7
s6850IRQ # 1                   ; &E8
s6522IRQ # 1                   ; &E9

TubeFlag # 1                   ; &EA

SpeechFlag # 1                 ; &EB

WrchDest # 1                   ; &EC
CurEdit  # 1                   ; &ED

SoftResetVars # 0              ; Reset to here on soft reset

KeyBase # 1                    ; &EE
Shadow # 1                     ; &EF
Country # 1                    ; &F0

UserFlag # 1                   ; &F1

SerULAreg # 1                  ; &F2

TimerState # 1                 ; &F3

SoftKeyConsist # 1             ; &F4

PrinterDrivType   # 1          ; &F5
PrinterIgnore     # 1          ; &F6

HardResetVars # 0              ; Reset to here on hard reset

BREAKvector # 3                ; &F7,&F8,&F9

MemDriver  # 1                 ; &FA - where the VDU drivers write to
MemDisplay # 1                 ; &FB - where we display from

LangROM # 1                    ; &FC

LastBREAK # 1                  ; &FD

KeyOpt # 1                     ; &FE

StartOptions # 1               ; &FF

PowerOnResetVars # 0           ; Reset to here on power-on reset

        # 3 :AND: (OSBYTEFirstVar-@)    ; Align it

EventSemaphores # 32            ; One byte for each of 32 events

TimerAlpha # 8                  ; As used by time (bottom 5 bytes)
TimerBeta  # 8                  ; ................................
; both aligned to word boundaries

RealTime # 8                    ; 5-byte fast real-time

PrinterActive # 4               ; Handle/active flag for printer (word aligned)

IntervalTimer # 5               ; Up Counter synchronous with TIME.
; Event generated when Zero is reached
; bottom byte aligned to word boundary

SecondsTime # 1 ; the soft copy (centi-)seconds of the RTC
CentiTime   # 1 ; """"""""""""""""""""""""""""""""""""""""

FlashState # 1 ; which flash colours are we using

SecondsDirty # 1                ; the dirty flag for start up!

MinTick # 1                     ; the minutes odd/even state

TVVertical # 1                  ; *TV first parameter

TVInterlace # 1                 ; *TV second parameter

CentiCounter # 1                ; Counter for VDU CTRL timing

Alphabet # 1                    ; Current alphabet number

Keyboard # 1                    ; Current keyboard number

KeyAlphabet # 1                 ; Alphabet associated with current keyboard

        AlignSpace              ; Align it

SerialFlags # 4                 ; New serial flags

XONXOFFChar # 1                 ; Character to send before rest (0 if none)

        AlignSpace

OSBYTEVarSize * @-OSBYTEFirstVar

; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

; End of variables' space

MacExpWSpSize * 348

; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
; Objects at fixed locations should be as low as possible in this workspace

; Real workspace definition

        ^  256

; Basic kernel space - defined locations for external modules

IRQ1V          # 4
ESC_Status     # 1
LatchBSoftCopy # 1

; Internal definitions

CallBack_Flag # 1
IRQ_CallBack_Flag * CallBack_Flag
GenErrorFlag  # 1

HISERV        # 4
MEMCIMAGE     # 4
RAMLIMIT      # 4
SEXITA        # 4
ERRHAN        # 4
ERRBUF        # 4
EscHan        # 4
EVTHAN        # 4
UNDHAN        # 4
PABHAN        # 4
DABHAN        # 4
ADXHAN        # 4
CALLAD        # 4
START         # 5
BUFFLAG       # 3
CALLBF        # 4
BRKAD         # 4
BRKBF         # 4
CacheLink     # 4
InstallSpace  # 4
SystemModules # 4

; Up to here is initialized on reset


BuffPtr       # 4
SysHeapDesc   # 24 ; HeapDescSize
CamEntries    # 4*127  ; keep CAM entries 0-126 in here
AplWorkSize   # 4
Curr_Active_Object # 4
MemLimit      # 4
ModHandWSpace # MHWSpcSize
SystemVectors # VecSize

; Vector Claim & Release tables etc

VecPtrTab  # OldNVECTORS * 4
OsbyteVars # OSBYTEVarSize

        ASSERT @ <= &4E0

        ^ &4E0
MacExpWSpace # MacExpWSpSize

; Buffers

NBuffers * 10

KeyBuffSize * &20
RS423InBuffSize * &100
RS423OutBuffSize * &C0
PrintBuffSize * &40
Sound0BuffSize * &10
Sound1BuffSize * &10
Sound2BuffSize * &10
Sound3BuffSize * &10
SpeechBuffSize * &40
MouseBuffSize * &40

        #       15 :AND: (-@)           ; Align to 16 bytes

KeyWorkSpaceSize * &200
KeyWorkSpace  # KeyWorkSpaceSize

; These must be in first 4K

BuffInPtrs # 4*NBuffers
BuffOutPtrs # 4*NBuffers

VariableList # 4

; Oscli stuff
OscliCBtopUID # 4
OscliCBbotUID # 4
OscliCBcurrend # 4
RedirectInHandle # 4
RedirectOutHandle # 4

ReturnCode   # 4
RCLimit      # 4

CurrentErrorBuffer # 256

; var to set on hard reset for Tim
ConfiguredScreenSize # 4

; Workspace
ESCCNT * -2       ; from buffer
ESCFLG * ESCCNT+1
STRACC * &F00
BUFFER * &E00
DUMPER * &E40
BRKLST * &E80
IRQSTK * &D80   ; goes down!

; These are defined in Brazil ; most probably don't bother us.
;Level0_currentThread    #       4  ; FE0
;Level0_freedQueue       #       4  ; FE4
;Level0_centisecondTime  #       4  ; FE8
;Level0_GFT              #       4  ; FEC
;Level0_ForceCrash       #       4  ; FF0
;Level0_FloatEmulatorWS  #       4  ; FF4 ; But this may be necessary
;Level0_Inhibit_Scheduler #      4  ; FF8
;MICK has FFC

;-----------------------------------------------------------------------------

        ^ MacExpWSpace

MacroNameBuff  # 256
MacExStartPtrs # 44
MacExEndPtrs   # 44
MacExpErrLink  # 4

        ASSERT MacExpWSpSize = @-MacExpWSpace

; *****************************************************************************
;
; Main Vdu Driver Workspace
; =========================
;

        ^ 0

FgEcf  # 4 * 8  ; Foreground Ecf, set by GCOL(a,0-127)
BgEcf  # 4 * 8  ; Background Ecf, set by GCOL(a,128-255)
GPLFMD # 4      ; Foreground action, set by GCOL(a,0-127)
GPLBMD # 4      ; Background action, set by GCOL(a,128-255)
GFCOL  # 4      ; Foreground colour, set by GCOL(a,0-127)
GBCOL  # 4      ; Background colour, set by GCOL(a,128-255)

GWLCol # 4      ; Graphics window left column  --
GWBRow # 4      ; Graphics window bottom row     |
GWRCol # 4      ; Graphics window right column   |
GWTRow # 4      ; Graphics window top row      --

qqqPad   # 3
QQ       # 17   ;Queue - QQ+1 is on a word boundary
QOffset  # 4    ;Value to add to VDUqueueItems to point to next queue posn.
JVec     # 4    ;Jump vector to internal routines

; Start of MODE table workspace

ScreenSize # 4  ; number of bytes needed for this mode (assumed 1st in list)

XWindLimit # 4  ; Maximum value of GWRCol (internal representation)

; LineLength must be immediately after YWindLimit

YWindLimit # 4  ; Maximum value of GWTRow (internal representation)

LineLength # 4  ; Length of one pixel row in bytes

; End of word mode variables

YShftFactor # 4 ; Number of places to shift YCoord in address generation after
                ; multiplying by 5, holds
                ; 7,6,5 or 4 for 8,4,2 or 1 bits per pixel (640x256 mode) or
                ; 6,5,4 or 3 for 8,4,2 or 1 bits per pixel (320x256 mode).

ModeFlags # 4   ; Bit 0 => non-graphic, Bit 1 => teletext, Bit 2 => gap mode

XEigFactor # 4  ; Number of places to shift XCoord in external to internal
                ; coordinate conversion, holds
                ; 1 for 640x256 mode
                ; 2 for 320x256 mode
                ; 3 for 160x256 (BBC micro mode 2)

YEigFactor # 4  ; number of shifts to convert between internal/external Y

NColour # 4     ; Number of colours minus 1

Log2BPC # 4     ; Log to base 2 of BytesPerChar ie (0,1,2,3,4)

Log2BPP # 4     ; Log to base 2 of BitsPerPix ie (0,1,2,3)

ECFIndex # 4    ; Index into default ECF tables

ScrRCol # 4     ; Maximum column number in this screen mode
ScrBRow # 4     ; Maximum row number in this screen mode

PalIndex # 4    ; Index into palette tables (0,1,2,3)

; End of table-initialised workspace

; Next 3 must be together in this order !

XShftFactor # 4 ; Number of places to shift XCoord in address generation,
                ; holds 2,3,4 or 5 for 8,4,2,1 bits per pixel respectivly
GColAdr # 4     ; Address of Ecf to plot - either FgEcf or BgEcf

ScreenStart # 4         ; Start address of screen (for VDU drivers)

NPix # 4        ; Number of pixels per word minus 1, holds
                ; holds 3,7,15 or 31 for 8,4,2,1 bits per pixel modes

AspectRatio # 4 ; Pixel shape : 0 square, 1 horz rect, 2 vert rect

BitsPerPix # 4  ; Bits per pixel (1,2,4,8)

BytesPerChar # 4        ; Bytes per one line of character
                        ; (same as BitsPerPix except in double pixel modes)

CursorFudgeFactor # 4   ; Factor for horizontal cursor positioning

RowMult # 4     ; Row multiplier for text manipulation

RowLength # 4   ; Bytes per text row in this mode (eg 640,1280,5120)

; The following (up to and including NewPtY) must be together in this order
; (relied upon by DefaultWindows)

TWLCol # 4      ; Text window left column  --
TWBRow # 4      ; Text window bottom row     |
TWRCol # 4      ; Text window right column   |
TWTRow # 4      ; Text window top row      --

OrgX # 4        ; Screen origin (external representation)
OrgY # 4

GCsX # 4        ; Graphics cursor (external representation)
GCsY # 4

OlderCsX # 4    ; Very old X coordinate (internal)
OlderCsY # 4    ; Very old Y coordinate (internal)

OldCsX # 4      ; Old graphics cursor (internal representation) --
OldCsY # 4      ;                                                 |
                ;                                                 |
GCsIX  # 4      ; Graphics cursor (internal representation)       |
GCsIY  # 4      ;                                                 |
                ;                                                 |
NewPtX # 4      ; Newest point (internal representation)          |
NewPtY # 4      ;                                               --

; End of together block

TForeCol # 4    ; Text foreground colour
TBackCol # 4    ; Text background colour

CursorX # 4     ; Text cursor X position ; these 3 must be in same order as ...
CursorY # 4     ; Text cursor Y position
CursorAddr # 4  ; Screen address of (output) cursor

InputCursorX # 4        ; Input cursor X position ; ... these 3
InputCursorY # 4        ; Input cursor Y position
InputCursorAddr # 4     ; Screen address of input cursor

EORtoggle # 4   ; Toggle between gap and non-gap
RowsToDo  # 4   ; in the CLS

VduStatus # 4   ; Vdu2, Window, Shadow bits (others in CursorFlags)

CBWS # 8        ; Clear block (VDU 23,8..) workspace
CBStart # 2
CBEnd # 2

CursorDesiredState # 4
CursorStartOffset # 4
CursorEndOffset # 4
CursorCounter # 4
CursorSpeed # 4
Reg10Copy # 4

CursorFill # 4  ; Word to EOR cursor ; MUST be immediately before CursorNbit

CursorNbit # 4  ; Pointer to cursor code for current mode

DisplayStart # 4        ; Start address of screen (for display)
DriverBankAddr # 4      ; Default start address for VDU drivers
DisplayBankAddr # 4     ; Default start address for display
DisplayNColour # 4      ; No. of colours -1 for displayed mode
DisplayModeFlags # 4    ; ModeFlags for displayed mode
DisplayModeNo # 4       ; ModeNo for displayed mode
DisplayScreenStart # 4  ; Where VDU outputs to when outputting to screen

DisplayXWindLimit # 4   ; Used for pointer programming
DisplayYWindLimit # 4
DisplayXEigFactor # 4
DisplayYEigFactor # 4
PointerXEigFactor # 4

Ecf1 # 8        ; The Ecf patterns
Ecf2 # 8
Ecf3 # 8
Ecf4 # 8

DotLineStyle # 8        ; Dot dash line pattern

ModeNo # 4      ; Current mode number

TFTint # 4      ; Text foreground tint          (in bits 6,7)
TBTint # 4      ; Text background tint
GFTint # 4      ; Graphics foreground tint
GBTint # 4      ; Graphics background tint

TotalScreenSize # 4     ; Amount configured for screen (in bytes)

MaxMode # 4             ; Maximum mode number allowed (20 for now)

VinitCopy # 4   ; Copy of Vinit for VDU 23;12 or 13

CursorFlags # 4 ; Silly Master cursor movement flags

CursorStack # 4 ; Bit stack of nested cursor states (0 => on, 1 => off)
                ; (bit 31 = TOS)

ECFShift # 4    ; number of bits to rotate right ECF OR and EOR masks by
ECFYOffset # 4  ; vertical offset to ECF index

WsVdu5 # 0      ; Vdu 5 workspace
WsScr # 4
WsEcfPtr # 4
; WsFontPtr # 4 ; not needed any more, kept in register
EndVerti # 4
StartMask # 4
EndMask # 4
FontOffset # 4
TempPlain # 16  ; only used for MODE 10

GraphicWs # 300 ; All graphics workspace is overlaid here
EndGraphicWs # 0

   ! 0,"16 ":CC::STR:@
        AlignSpace 16

GCharSizes  # 0
GCharSizeX  # 4         ; width of VDU 5 chars in pixels
GCharSizeY  # 4         ; height of VDU 5 chars in pixels

GCharSpacing # 0
GCharSpaceX  # 4        ; horizontal spacing between VDU 5 chars in pixels
GCharSpaceY  # 4        ; vertical   ------------------""-----------------

TCharSizes  # 0
TCharSizeX  # 4         ; width of VDU 4 chars in pixels
TCharSizeY  # 4         ; height of VDU 4 chars in pixels

TCharSpacing # 0
TCharSpaceX  # 4        ; horizontal spacing between VDU 4 chars in pixels
TCharSpaceY  # 4        ; vertical   ------------------""-----------------

HLineAddr    # 4        ; address of exported HLine
GcolOraEorAddr # 4      ; address of FgEcfOraEor etc

FirPalSetting # 4*28    ; First palette settings
SecPalSetting # 4*28    ; Second palette settings

   ! 0,"64 ":CC::STR:@
        AlignSpace 64

FgEcfOraEor # 4*16      ; Interleaved zgora & zgeor
BgEcfOraEor # 4*16      ; Interleaved zgora & zgeor
BgEcfStore  # 4*16      ; Interleaved zgora & zgeor to store background

;Current state of pattern
LineDotCnt # 4          ; Count down to restarting pattern
LineDotPatLSW # 4       ; Current state of pattern LSWord
LineDotPatMSW # 4       ;    "      "   "     "    MSWord

DotLineLength # 4       ; Dot Pattern repeat length as given in *FX163,242,n

BBCcompatibleECFs # 4   ; 0 => BBC compatible, 1 => native

SpAreaStart # 4         ; Start of sprite area
SpChooseName # 16       ; No comment says Richard
SpChoosePtr # 4

PointerHeights # 4      ; 4 x 1 byte
PointerActiveXs # 4     ; 4 x 1 byte
PointerActiveYs # 4     ; 4 x 1 byte
PointerShapeNumber # 4  ; only bottom byte used
PointerX # 4            ; co-ordinates of pointer (not always = mouse)
PointerY # 4

VIDCControlCopy # 4     ; Soft copy of VIDC control register
VertAdjust # 4          ; offset to add to vertical VIDC registers

TeletextOffset # 4      ; Offset to current teletext flash bank

TeletextCount # 4       ; Number of vsyncs till next teletext flash

WrchNbit # 4            ; Pointer to char code for current mode

BeepBlock # 8           ; OSWORD block for VDU 7

ScreenMemoryClaimed # 1 ; NZ => memory has been claimed or is unusable

   ! 0,"16 ":CC::STR:@
     AlignSpace 16      ; Align workspace to 16 bytes

TTXDoubleCounts # 25    ; Number of double height chars on each line

   ! 0,"16 ":CC::STR:@
     AlignSpace 16      ; Align workspace to 16 bytes

RAMMaskTb # 32*4        ; Copy of MaskTb for this mode (up to 32 words)

   ! 0,"16 ":CC::STR:@
     AlignSpace 16      ; Align workspace to 16 bytes

VduOutputCurrentState # 0 ; values of R0-R3 to return from SwitchOutputToSprite
                        ; or Mask; next 4 must be in this order
SpriteMaskSelect # 4    ; value of R0 to be given to SWI OS_SpriteOp to set up
                        ; current state
VduSpriteArea # 4       ; Pointer to sprite area containing VDU output sprite
                        ; (0 if output is to screen)
VduSprite # 4           ; Pointer to VDU output sprite (0 if output to screen)

VduSaveAreaPtr # 4      ; Pointer to save area for VDU variables

    AlignSpace 16, 12   ; Make ClipBoxCoords a valid immediate,
                        ; with ClipBoxEnable immediately before it
ClipBoxInfo # 0
ClipBoxEnable # 4       ; 0 => clip box disabled, 1 => enabled

ClipBoxCoords # 0       ; Internal coords of modified area of screen
ClipBoxLCol # 4
ClipBoxBRow # 4
ClipBoxRCol # 4
ClipBoxTRow # 4

   ! 0,"16 ":CC::STR:@
     AlignSpace 16      ; Align workspace to 16 bytes

TextExpand # 4*1024     ; Tim's massive text expansion table for whizzy WRCH
; TextPlain is now always hard against the end of TextExpand for this mode

TTXSoftFonts * TextExpand + 2*1024      ; Soft fonts in teletext mode

   ! 0,"64 ":CC::STR:@
     AlignSpace 64      ; Align workspace to 64 bytes

; Teletext map, flood queue and copy/move buffer are overlaid

TTXMapSize * 41*25*4    ; (&1004 bytes)

LargeCommon # TTXMapSize ; the largest area
TTXMap         * LargeCommon

        [ AssemblingArthur
FldQueueSize * ScratchSpaceSize
FldQueueStart * ScratchSpace
        |
FldQueueSize * &1000    ; must be <=TTXMapSize
FldQueueStart  * VduDriverWorkSpace + LargeCommon ; overlaid with TTX Map
        ]

ScrLoaSpriteCB * LargeCommon    ; (size = SpriteCBsize + MaxSpritePaletteSize)
ScrLoaBuffer   * LargeCommon    ; (size = one pixel row)
ScrSavCommon   * LargeCommon    ; (size = SpriteAreaCBsize + SpriteCBsize
                                ;  + MaxSpritePaletteSize)

   ! 0,"64 ":CC::STR:@
     AlignSpace 64      ; Align workspace to 64 bytes

Font # &700             ; 7 pages of (soft) font

SaveAreaSize * 12*1024-@

VduSaveArea # SaveAreaSize      ; save area for switching output to sprites

VDWSSize # 0

; *****************************************************************************
;  Cursor/Sound DMA and scratch workspace..
;

CursorSoundRAM      * &01700000
CursorSoundPhysRAM  * 160 * 1024 ; DMA physical base

SoundWorkSpaceSize  * &1000
SoundDMABufferSize  * &1000
SoundEvtSize        * &1000

CursorDataSize      * &800

        ^ CursorSoundRAM

CursorData          # CursorDataSize
;SoundWorkSpace     # SoundWorkSpaceSize
;SoundDMABufferA    # SoundDMABufferSize
;SoundDMABufferB    # SoundDMABufferSize
;SoundEventQueue    # SoundEvtSize
ScratchSpace        # 0
ScratchSpaceSize    * 32*1024+CursorData-ScratchSpace

; forced constants for temporary co-existence WITH SCRATCHSPACE
SoundWorkSpace      * CursorSoundRAM + 16*1024
SoundDMABufferA     * SoundWorkSpace + SoundWorkSpaceSize
SoundDMABufferB     * SoundDMABufferA + SoundDMABufferSize
SoundEventQueue     * SoundDMABufferB + SoundDMABufferSize

; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
; Users of scratchspace declare yourself here.

; Tidying the RMA uses ScratchSpace backwards from ScratchSpace+Size

; GSTRANS,Variables workspace

GSVarWSpace * ScratchSpace

        ^ 0
GSNameBuff   # 256
GS_Stack     # 512
GS_StackPtr_Lim * 512/4   ; number of words in stack.
GS_StackPtr  # 4
SetVarBuff   # 256
ShowBuff     * SetVarBuff
SettingBuff  # 256        ; used in *set, *setmacro

; Sam's nasty workspace sharing : get 512 byte buffer for *Help
; by using SettingBuff and IFBuffer
HelpBuffer     * SettingBuff+GSVarWSpace
HelpBufferSize * 512

        ^ @+GSVarWSpace
IFBuffer     # 256

ExprWSpace   * @
        ^ 0,R12
ExprBuff    # 256
exprBracDif # 2     ; keep exprSTRACC aligned
tos_op      # 2     ; 1 byte for use as STRACC-1
ExprSVCstack # 4
exprSTRACC  * @-ExprBuff+ExprWSpace

ExprStackLimit * exprSTRACC+256
ExprStackStart * ScratchSpace+ScratchSpaceSize

; *****************************************************************************
; Now the high workspace stuff - please claim in large chunks with space for
; expansion so we don't have to reblow ROMs every time the file changes.

; The next sentence no longer holds : SysHeap has moved!
; Come backwards from 30 Meg, so we can dynamically change sysheap size

                ^  30*1024*1024

HighWorkSpace   #  -1024    ; SVC table is 1K
HighWorkSize  *     64*1024
SvcTable        #  0

        ASSERT VDWSSize <= 12*1024
                #  -12*1024 ; 12K for Tim
VduDriverWorkSpace # 0
        ASSERT (VduDriverWorkSpace :AND: 63) = 0        ; For Tim (VDU5)

                #  -12*1024  ; 12K for Stu
StusWSpace      #    0

; Stu has taken over the following : moved up
;                #  -8*1024  ; 8K for Nick
;ADFSWorkspace   # 0

        # -KeyBuffSize
KeyBuff # 0
        # -RS423InBuffSize
RS423InBuff # 0
        # -RS423OutBuffSize
RS423OutBuff # 0
        # -PrintBuffSize
PrintBuff # 0
        # -Sound0BuffSize
Sound0Buff # 0
        # -Sound1BuffSize
Sound1Buff # 0
        # -Sound2BuffSize
Sound2Buff # 0
        # -Sound3BuffSize
Sound3Buff # 0
        # -SpeechBuffSize
SpeechBuff # 0
        # -MouseBuffSize
MouseBuff # 0
        # -512  ; For Fuschia expansion past this point

; Oscli buffering
OscliBuffSize      * 256
OscliNoBuffs       * 16   ; number of buffers in circular space.
OscliCircBuffLimit # -OscliBuffSize*OscliNoBuffs
OscliCircBuffStart # 0
        #  -256
RedirectBuff # 0

        #    -16*1024
NewADFSWSpace # 0

; Supervisor stack : goes backwards into the boundary

SvcStkSize   * 4*1024
SVCSTK       * HighWorkSpace-HighWorkSize+SvcStkSize

       ASSERT @ > SVCSTK

        END
