--Interface to low level display stuff 
--M. Stone December 4, 1980  4:22 PM

DIRECTORY
	SegmentDefs: FROM "SegmentDefs",
	PointDefs: FROM "PointDefs" USING[ScrPt],
	BitBltDefs: FROM "BitBltDefs";

ScreenDefs: DEFINITIONS =
BEGIN OPEN PointDefs;

BlockPtr: TYPE = POINTER TO Block;
ScreenPtr: TYPE = POINTER TO Screen;
BitmapPtr: TYPE =LONG POINTER TO Bitmap;
Bitmap: TYPE = RECORD
	[bank: SegmentDefs.BankIndex,
	nWords: [0..377B],
	nBits,nLines: CARDINAL,
	bits: POINTER
	];
Block: TYPE = RECORD	--mostly for source blocks
	[bitmap: BitmapPtr,
	 lx,ty,w,h: INTEGER	--since usually source, not really a screen point
	];
Screen: TYPE = RECORD
	[bitmap: Bitmap,	--defined on a plane of bits
	 ty,by,lx,rx: INTEGER	--clipping edges
	];

GreyType: TYPE = POINTER TO ARRAY [0..3] OF CARDINAL;
ColorMapIndex: TYPE = CARDINAL;
JunctionType: TYPE = {round,square,angled};
EndType: TYPE = RECORD
	[type: SELECT xx: * FROM
		round,flat => NULL,
		angled => [From,To: ScrPt],	--clipping edge, keep on right
		ENDCASE
	];

--routines exported by ScreenFns
RestoreDCBBank: PROCEDURE;
SetScreen: PROCEDURE [screen: ScreenPtr];	--defines the current screen
GetCurrentScreen: PROCEDURE RETURNS[ScreenPtr] ;	--returns the current screen	
ClearScreen: PROCEDURE;	
SetClipEdges: PROCEDURE [tl,br: ScrPt];
--return a box clipped to screen
ClipToScreen: PROCEDURE [tl,br: ScrPt] RETURNS [ScrPt, ScrPt];
ClipPointToScreen: PUBLIC PROC [pt: ScrPt] RETURNS [ScrPt];
ResetClipEdges: PROCEDURE;--changes clipping edges of current screen to size at init

--clip options are because someone higher up might do some culling
ClipperState: TYPE = {clip,cull,inside};
PrimeClipper: PROC [tl,br: PointDefs.ScrPt] RETURNS [ClipperState];
ClipOn: PROCEDURE;	--resets PrimeClipper

SetFunction: PROCEDURE [fnc: BitBltDefs.BBoperation];

--All of these assume the current Display state
SetLineParms: PROCEDURE
	[junction: JunctionType,
	width: INTEGER,
	grey: GreyType,
	color: ColorMapIndex,
	firstEnd,lastEnd: EndType
	];
StartLine: PROCEDURE[pt: ScrPt];
DrawTo: PROCEDURE[pt: ScrPt];	--uses junction type
DrawToShort: PROCEDURE[pt: ScrPt];		--splines use this one alot, uses round jnc
EndLine: PROCEDURE;
DrawSingleDot: PROCEDURE[pt: ScrPt];
				--draws a round dot	
DrawNextDot: PROCEDURE[pt: ScrPt];
		-- draws a dot which is part of a line.
		-- EndLine must be called for completion	

BLTBlockInScreen: PROCEDURE
	[src: BlockPtr,
	tl: PointDefs.ScrPt,
	fnc: BitBltDefs.BBoperation
	];

MoveScreenBox: PROCEDURE[tl,br: ScrPt,dx,dy: INTEGER];
EraseBox: PUBLIC PROCEDURE[tl,br: ScrPt];
EraseBoxBW: PUBLIC PROCEDURE[tl,br: PointDefs.ScrPt];
InvertBox: PUBLIC PROCEDURE[tl,br: ScrPt];

--for scan conversion.  
SetFillParms: PROCEDURE [grey: GreyType, color: ColorMapIndex];
HFill: PROCEDURE[y,lx,dx: INTEGER];
VFill: PROCEDURE[x,ty,by: INTEGER];
BoxFill: PROCEDURE[tl,br: ScrPt];

GetGridParameters: PROCEDURE
	RETURNS[center: ScrPt,hgridlx,hgridrx,vgridty,vgridby,gridt: INTEGER];
BltVGrid: PROCEDURE[lx: INTEGER];
BltHGrid: PROCEDURE[ty: INTEGER];
END.