; Copyright 1996 Acorn Computers Ltd
;
; Licensed under the Apache License, Version 2.0 (the "License");
; you may not use this file except in compliance with the License.
; You may obtain a copy of the License at
;
;     http://www.apache.org/licenses/LICENSE-2.0
;
; Unless required by applicable law or agreed to in writing, software
; distributed under the License is distributed on an "AS IS" BASIS,
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
; See the License for the specific language governing permissions and
; limitations under the License.
;
; > &.Source.VduGrafDec
;
; ARTHUR OPERATING SYSTEM - Vdu Drivers
; =======================
;
; Graphics workspace and macro declarations
;
; Author R C Manby
; Date   5.9.86
;

        GBLL UseNewerHLine
UseNewerHLine SETL 1=1


;
; Graphics work space, overlaid in main vdu w/s area
;


  ^ GraphicWs

Line1Blk # 4*9  ;Parameter block for a crudeline
        ASSERT @ < EndGraphicWs


  ^ GraphicWs

LineBlk # 4*5  ;Parameter block for a crudeline

LineEcfBase # 4                                         ; --
LineEcfIndx # 4                                         ;   |
LineDeltaY  # 4                                         ;   |
LineScanStp # 4                                         ; --

LineEndPtFlags # 4      ;Bit0 set - plot start pt, bit1 set - plot end pt
LineDotPtr     # 4      ;Holds 0/Adr(LineDotCnt) for Solid/Dotted lines

DotCycleStartX # 4
DotCycleStartY # 4
DotCycleEndX   # 4
DotCycleEndY   # 4
DotCycleCount  # 4
PostCycleCount # 4

;The following are defined in Hdr.System
; LineDotCnt     # 4      ;Count down to restarting pattern
; LineDotPatLSW  # 4      ;Current state of pattern LSWord
; LineDotPatMSW  # 4      ;   "      "   "     "    MSWord
        ASSERT @ < EndGraphicWs


  ^ GraphicWs

TLine1  # 4*9   ;Line parameters used by Tri & Par fill
TLine2  # 4*9
TEndY   # 4
Vertex1X # 4    ;                                        --
Vertex1Y # 4    ;                                          |
Vertex2X # 4    ;                                          |
Vertex2Y # 4    ;                                          |
Vertex3X # 4    ;                                          |
Vertex3Y # 4    ;                                          |
Vertex4X # 4    ;                                          |
Vertex4Y # 4    ;                                        --
        ASSERT @ < EndGraphicWs


  ^ GraphicWs

CircleBlk # 4*8 ;Parameter block for circle arc segments etc   --
CLine0  # 4*9   ;Line parameters used by Arc, Segment & Sector   |
CLine1  # 4*9   ;                                              --
CLine2  # 4*9   ;CLine2 & CLine3 used only for segments
CLine3  # 4*9   ;

UpperSegLinePtr # 4     ;Address of CLine2 or 0 - used only for segments
LowerSegLinePtr # 4     ;Address of CLine3 or 0 - used only for segments

CircleRadSquare # 4     ;Square of radius of circle

CLine0EndX * CLine0+7*4
CLine0EndY * CLine0+8*4
CLine1EndX * CLine1+7*4
CLine1EndY * CLine1+8*4
CLine0Far  * CLine0
CLine0Near * CLine0EndX
CLine1Far  * CLine1
CLine1Near * CLine1EndX

Quad0Control # 1        ;Control bytes for each quadrant for   --
Quad1Control # 1        ; Arc, Segment & Sector plotting         |
Quad2Control # 1        ;                                        |
Quad3Control # 1        ;                                        |
                        ;                                        |
Quad0StateChange # 1    ;Flag to indicate line/circle            |
Quad1StateChange # 1    ; intersection                           |
Quad2StateChange # 1    ;                                        |
Quad3StateChange # 1    ;                                        |
                        ;                                        |
Quad0Draw # 1           ;Controls point/line plotting            |
Quad1Draw # 1           ;                                        |
Quad2Draw # 1           ;                                        |
Quad3Draw # 1           ;                                      --

ArcPoint0X   # 4        ;                                      --
ArcPoint0Y   # 4        ;                                        |
ArcPoint1X   # 4        ;                                        |
ArcPoint1Y   # 4        ;                                        |
ArcPoint2X   # 4        ;                                        |
ArcPoint2Y   # 4        ;                                        |
ArcPoint3X   # 4        ;                                        |
ArcPoint3Y   # 4        ;                                      --

        ASSERT @ < EndGraphicWs


  ^ GraphicWs

EllBlk     # 4*8        ;Parameter block for ellipses

EllBlkSliceCnt * EllBlk
EllBlkEllY     * EllBlk + 4*4


EllPrevL   # 4          ;Slice limits for previous line        --
EllPrevR   # 4          ;                                        |
EllThisL   # 4          ;                 current line           |
EllThisR   # 4          ;                                        |
EllNextL   # 4          ;                 next line              |
EllNextR   # 4          ;                                      --

EllHLineWs # 4*5        ;This could be pushed to the stack
EllDoubleHLineWs # 4*5  ;This could be pushed to the stack
        ASSERT @ < EndGraphicWs


  ^ GraphicWs

CMSrc       # 4*4       ;Unclipped source area                 --
CMDest      # 4*4       ;Unclipped destination area              |
CMCopyFlag  # 4         ; 0/2 means Move/Copy area             --

CMDest2L    # 4         ; destination coords clipped at dest
CMDest2B    # 4
CMDest2R    # 4
CMDest2T    # 4
CMDest3L    # 4         ; destination coords clipped both ways
CMDest3B    # 4
CMDest3R    # 4
CMDest3T    # 4

CMStuff # 0             ; these 7 loaded together
CMSourceAddr # 4        ; source screen address
CMDestAddr # 4          ; destination screen address
CMDestCount # 4         ; no. of destination words per line -1
CMRShift # 4            ; LSR shift factor
CMLShift # 4            ; LSL shift factor
CMRMask # 4             ; right mask
CMLMask # 4             ; left mask

CMVertCount # 4         ; no. of lines to do -1
CMVertDir # 4           ; offset to add to source/dest on each line

        ASSERT @ < EndGraphicWs


  ^ GraphicWs

LineFillBlk # 4 * 11

FldLeftXLimit  # 4                              ;--
FldY           # 4                              ;  |
FldRightXLimit # 4                              ;--

FldBoundaryCol  # 4
FldBoundaryFlag # 4
FldYWindLimit   # 4

QueuePtrs       # 4*4   ; head, tail, end, start

FldSaveArea     # 5*4   ; saved Y, target colour, NPix, zgora, zgeor
FldSaveY * FldSaveArea +0

FldStackLevel   # 4
                [ med_00001_userma
flood_cda_rma   # 4     ; amount we've changed the rma size by
                ]

        ASSERT @ < EndGraphicWs


  ^ GraphicWs

RetnReg0  # 4           ;Save area for SWI SpriteOp    --
RetnReg1  # 4           ;                                |
RetnReg2  # 4           ;                                |
RetnReg3  # 4           ;                                |
RetnReg4  # 4           ;                                |
RetnReg5  # 4           ;                                |
RetnReg6  # 4           ;                                |
RetnReg7  # 4           ;                                |
RetnReg8  # 4           ;                                |
RetnReg9  # 4           ;                                |
RetnLink  # 4           ;                              --

SprReadNColour  # 4     ;Vdu vars for the mode the     --
SprWriteNColour # 4     ; the sprite is in               |
SprBytesPerChar # 4     ;                                |
SprXShftFactor  # 4     ;                                |
SprNPix         # 4     ;                                |
SprLog2BPC      # 4     ;                                |
SprLog2BPP      # 4     ;                                |
SprModeFlags    # 4     ;                              --

NameBuf   # 16          ; 12 char name + gap for good measure

SpriteWs # 0



  ^ SpriteWs            ;Sprite plot & ScreenLoad

SPltWidth   # 4         ;Don't try re-arranging this lot unless
SPltHeight  # 4         ; you fully understand the code!!
SPltScrOff  # 4
SPltMemOff  # 4
SPltScrAdr  # 4
SPltColCnt  # 4
SPltMemAdr  # 4
SPltShftR   # 4
SPltShftL   # 4
SPltMskAdr  # 4
SPltLMask   # 4
SPltRMask   # 4
; SPltzgooPtr # 4
SPltEcfPtr  # 4
SPltEcfIndx # 4
SPltPixPerWord # 4
SPltBPP     # 4
SPltMaskBit # 4
SPltMaskPtr # 4
SPltMaskRowBit # 4
SPltMaskRowPtr # 4
SPltMaskRowLen # 4

SPltzgooMasks # 16      ; zgoo, zgeo, zgoe, zgee

ScrLoaHandle  # 4       ;     --
ScrLoaBufAdr  # 4       ;       |
ScrLoaBytes   # 4       ;       |
ScrLoaFilPtr  # 4       ;       |
ScrLoaFilOfst # 4       ;     --

ScrLoaAreaCB   # SpriteAreaCBsize

SPltAction # 4                          ; Plot action used (0 => store)

SloadModeSel # 56                       ; Mode selector for screenloading new sprites

        ASSERT @ < EndGraphicWs


  ^ SpriteWs            ;SGet,SCreate & ScreenSave

SGetTopLeft # 8         ; top and left of 'on screen' area

SGetTopMargin     # 4
SGetBotMargin     # 4
SGetLWrdMargin    # 4
SGetLBitMargin    # 4
SGetRWrdMargin    # 4
SGetRBitMargin    # 4

SGetColWCnt  # 4
SGetRowOfst  # 4
SGetEcfIndx  # 4

SGetNext          # 4                               ; --
SGetName          # 12  ;Name is 3 words (12 chars) ;   |
SGetWidth         # 4                               ;   |
SGetHeight        # 4                               ;   |
SGetLBit          # 4                               ;   |
SGetRBit          # 4                               ;   |
SGetImage         # 4                               ;   |
SGetTrans         # 4                               ;   |
SGetMode          # 4                               ;   |
SGetPalette       # 0                               ; --

        ASSERT @ < EndGraphicWs

        ^       ScrSavCommon
ScrSavAreaCB      # SpriteAreaCBsize
ScrSavSpriteCB    # SpriteCBsize + MaxSpritePaletteSize

        END