Text preview for : SystemDisplay.mesa_Oct77.pdf part of xerox SystemDisplay.mesa Oct77 xerox mesa 3.0_1977 listing SystemDisplay.mesa_Oct77.pdf
Back to : SystemDisplay.mesa_Oct77. | Home
systemdisplay.mESA 24-0CT-77 18:55:07 Page 1
SystemDisplay.mesa; edited by Johnsson; October 14, 1977 4:17 PM
DIRECTORY
AltoDefs: FROM "altodefs",
DisplayDefs: FROM "displaydefs",
FontDefs: FROM "fontdefs",
ImageDefs: FROM "imagedefs",
InlineOefs: FROM "inlinedefs",
SegmentDefs: FROM "segmentdefs",
StreamDefs: FROM "streamdefs";
SystemDisplay: PROGRAM
IMPORTS ImageDefs. SegmentDefs, StreamDefs
EXPORTS DisplayOefs, StreamDefs
SHARES StreamDefs =
BEGIN
StreamHandle: TYPE = StreamDefs.StreamHandle;
OrderedPOINTER: TYPE = ORDERED POINTER:
OrderedNIL: OrderedPOINTER = LOOPHOLE[NIL]:
TAB: CHARACTER = l1C;
CR: CHARACTER = 15C:
NUL: CHARACTER = OC;
SP: CHARACTER = '
-- Display Hardware
DCBchainHead: DCBptr = LOOPHOLE[420B]:
OCBnil: DCBptr = LOOPHOLE[O]:
DCBptr: TYPE = POINTER TO DCB:
DCB: TYPE = RECORD [
next: DCBptr.
resolution: {high. low}.
background: DisplayDefs.Background,
indenting: [O .. 77B]. in units of 16 bits
width: [0 .. 377B], in units of 16 bits. must be even
bitmap: OrderedPOINTER. -- must be even
height: CARDINAL]: in double scan lines
LeftMargin: CARDINAL = 8:
RightMargin: CARDINAL = 606:
MaxWordsPerLine: CARDINAL = 38:
DSP: Display StreamDefs.StreamObject ~ StreamDefs.StreamObject [
reset: ClearDS,
get: GetNop.
put: DPutChar.
putback: PutbackNop,
endof: EndofNop,
destroy: DestroyNop,
body: Display[ ...... ",]];
systemDS: StreamDefs.flisplayllandle = @DSP:
displayOn: BOOLEAN ~ FALSE:
bmSegment: SegmentDefs.DataSegmentllandle;
bmFirst, bmTail. bmNext. bmLastLine: OrderedPOINTER:
lineHeight. lastLineSize: CARDINAL:
dummyflCB: DCBptr;
firstDCB. lastDCB. currentDCB: DCBptr ~ DCBnil;
1ayo u t 0 fbi tmap is:
DCBs: ARRAY [firstDCB .. lastDCB] OF DCB.
bmFirst: ARRAY OF UNSprCIFIED.
bmLasU.ine: ARRAY [O .. linelieight*MaxWordsPerline) OF UNSP[CIrIED.
bmNext points to next word to allocate.
bmTail points to oldest allocated bitmap.
bmState: rontDefs.Bi~napState;
tabWldth: CARDINAL;
TARint1ex: [0 .. 9];
TARs: ARRAY [0 .. 9] or CARDINAl;
font: rontflefs.FonLilandle .. NIL;
-- Typescript data
systemdisplay.mESA 24-0CT-77 18:56:07 Page 2
typescript: PUBLIC StreamDefs.DiskHandle ~ NIL;
startLine: StreamDefs.StreamIndex ~ [0, 0];
GetDefaultDisplayStream: PUBLIC PROCEDURE RETURNS[StreamDefs.DisplayHandle]
BEGIN
RETURN[systemDS];
END;
SetupBitmap: PROCEDURE [bitmap: POINTER, nLines, nWords: CARDINAL] =
BEGIN
dcb: DCBptr;
WHILE nLines*SIZE[DCB] + lastLineSize > nWords DO
nLines ~ nLines - 1;
ENDLOOP;
firstDCB ~ dcb ~ bitmap:
THROUGH [O .. nLines) DO
dcb.next ~ deb + SIZE[DCB];
deb. height ~ lineHe1ght/2;
deb ~ deb.next;
ENDLOOP;
lastDCB ~ deb-SIZE[DCB];
lastDCB.next ~ DCBnil;
bmFirst ~ LOOPHOLE[deb, OrderedPOINTER];
bmLastLine ~ LOOPIIOLE[bitmap+nWords-lastLineSize, OrderedPOINTER];
bmState ~ [origin: bmLastLine, wordsPerLine: MaxWordsPerLine, x:, y:O]:
END;
eurrentPages, currentLines, currentDummySize: CARDINAL;
DisplayOff: PUBLIC PROCEDURE [color: DisplayDefs.Background]
BEGIN
IF -displayOn THEN RETURN;
SetSystemDisplaySize[O,O];
font.elose[font];
dummyDCB.baekground ~ color:
dummyDCB.height ~ 1:
END;
DisplayOn: PUBLIC PROCEDURE
BEGIN
IF displayOn THEN RETURN;
dummyDCB.baekground ~ white;
SetDummyDisplaySize[eurrentDummySize];
SetSystemDisplaySize[eurrentLines, currentPages];
END;
SetSystemDisplaySize: PUBLIC PROCEDURE [nTextLines, nPages: CARDINAL] =
BEGIN OPEN SegmentDefs;
IF displayOn THEN
BEGIN
firstDCB.next ~ lastDCB.next;
RemoveDCB[firstDCB];
firstDCB ~ lastDCB ~ currentDCB ~ DCBnil;
DeleteOataSegment[bmSegment];
displayOn ~ FALSE:
END:
IF nPages = 0 THEN RETURN:
currentPages ~ nPages: for Display Off IOn
currentLines ~ nfexlLines: -- for Display Off/On
bmSegment ~ NewDataSegment[DefaultBase. nPages]:
SetupBilmap[DataSegmentAddress[bmSegment], nTextLines. nPages*AltoDefs.PageSile]:
displayOn ~ TRUE:
ClearDS[systemOS];
InserLDCB[new: firstDCB. before: dummyDCB.next];
RrTURN
[NO;
SeLDummyDisplaySi,.e: PURIIC PROC[oUR[ [nScanLines: CARDINAL]
BfGIN
curl'enLDummySile" nScanl ines; -- for Display Off/On
Ir nScanl ines/2 = dummyDCR.height TII[N RfTURN;
rr dUl1l111yDCB.heigl1t II a lllfN RemoveDCB[dul11myDCR];
dummyDCB.height ~ nScant ines/2;
If dUl11myDCB.heighl II a TtlfN InsertDCB[new: duml11yDCB. before: firslDCB];
RfTURN
rND;
systemdisplay.mESA 24-0CT-77 18:55:07 Page 3
ClearDS: PROCEDURE [stream: StreamHandle] =
BEGIN
deb: DCBptr:
IF stream II systemDS THEN
SIGNAL StreamDefs.StreamError[stream.StreamType]:
IF typescript II NIL THEN typeseript.reset[typeseript]:
IF -displayOn THEN RETURN:
FOR deb ~ firstDCB. deb.next DO
deb. resolution ~ high;
deb. background ~ white;
deb. indenting ~ deb.width ~ 0;
deb.bitmap ~ bmLastLine;
IF deb = lastDCB THEN EXIT;
ENDLOOP:
bmNext ~ bmFirst;
bmTail ~ bmLastLine;
eurrentDCB ~ firstDCB;
ClearCurrentLine[stream];
RETURN
END;
ClearCurrentLine: PUBLIC PROCEDURE [stream: StreamHandle]
BEGIN
IF stream II systemDS THEN
SIGNAL StreamDefs.StreamError[stream.StreamType];
IF typescript II NIL THEN
StreamDefs.SetIndex[typeseript. startLine];
IF -displayOn THEN RETURN;
bmLastLine1' ~ 0;
InlineDefs.COPY[from: bmLastLine. to: bmLastLine+l. nwords: lastLineSize-l];
eurrentDCB.indenting ~ 0;
currentDCB.bitmap ~ bmLastLine;
currentDCB.width ~ MaxWordsPerLine;
bmState.x ~ LeftMargin;
TABindex ~ 0;
RETURN
END;
Scroll: PROCEDURE [char: CHARACTER] =
BEGIN
deb: DCBptr;
pos: CARDINAL;
SELECT char FROM
CR =) NULL;
TAB =)
BEGIN
TABs[TABindex] ~ bmState.x;
TABindex ~ TARindex + 1;
pos ~ (bmState.x/tabWidth+l)*tabWidth;
IF pos < RightMargin THEN bmState.x ~ pos
ELSE DPutChar[systemDS. SP];
RETURN
END;
NUL =) RETURN;
ENOCASE =)
IF char < 40C THEN
BEGIN
DPutChar[sys temDS, '1'];
DPulChar[systemDS.
LOOPIIOI [[LOOPIIOLE[char ,CARDINAL]+100B .CIIARACHR]];
RETURN
END;
-- Do the scroll. assuming last (current) line is in bmlastl ine.
-- scroll all olhers by BI Ting their DCBs. move old last 1 ine to
-- new bitmap and free bmlastLine for reuse.
UNTTI Compact[currentOCB.bmSlale.x] DO
If -DeleleTopl ine[] THrN RETURN; -- not enough space
[NOIOOP:
If currenLDCB II lastDCB TllfN currentOCB" currentDCB.next
FI S[
B[G TN
rr firsLDCB.widlh II 0 TllfN
[] ~ OeleleTopL ine[]:
systemdisplay.mESA 24-0CT-77 18:55:07 Page 4
FOR deb ~ firstDCB, deb. next UNTIL deb = lastDCB DO
InlineDefs.COPY[from: deb.next+1, to: deb+1. nwords: SIZE[DCB]-l]:
-- assumes "next" is in word zero
ENDLOOP:
END:
IF typescript # NIL THEN startLine ~ StreamDefs.GetIndex[typeseript]:
ClearCurrentLine[systemDS]:
IF char # CR THEN DPutChar[systemDS, char]:
END:
DeleteTopLine: PROCEDURE RETURNS [BOOLEAN] =
BEGIN
deb: DCBptr:
-- find first line with bitmap allocated
FOR deb ~ firstDCB, deb.next DO
IF deb.width # 0 THEN EXIT:
IF deb = lastDCB THEN RETURN[FALSE]: -- found no top line to delete
ENDLOOP:
deb.width ~ deb.indenting ~ 0:
-- find next line with bitmap allocated
UNTIL deb = lastDCB DO
deb" deb.next:
IF deb.width # 0 THEN
BEGIN bmTail .. deb.bitmap: EXIT END:
REPEAT FINISHED =) -- all linex deleted
BEGIN bmTail .. bmLastLine: bmNext .. bmFirst END:
ENDLOOP:
RETURN[TRUE] :
END:
Compact: PROCEDURE [deb: DCBptr, x: CARDINAL] RETURNS [BOOLEAN]
BEGIN
newWidth: CARDINAL" (x+15)/16:
oldWidth: CARDINAL ~ deb.width:
old: OrderedPCtNTER .. deb.bitmap:
lineHeight: CARDINAL .. deb.height*Z:
p, new: OrderedPOINTER:
d: CARDINAL:
IF x (= LeftMargin THEN d ~ 0
ELSE
FOR d IN [O .. newWidth) DO
p .. old + d:
THROUGH [0 .. lineHeight) DO
IF pt # 0 THEN GO TO foundit:
p .. p + oldWidth:
ENDlOOP;
REPEAT foundit => NULL:
ENDlOOP:
IF d > 0 THEN
BEGIN
newWidth .. newWidth-d:
old .. old+d:
END;
newWidth .. Even[newWidth]:
IF newWidth > 0 THEN
BEGIN
Ir (p .. new" GetMapSpaee[newWidth*l ineHeight]) = OrderedNIl THEN RETURN[FALSE]:
THROUGH [O .. lineHeight) DO
Inl ineOefs.COPV[from: old, to: p, nwords: newWidth];
old .. old + oldWidlh:
p .. p + newWidlh:
[NOLOOP;
deb. indenting" d:
deb.width .. newWidlh:
deb.bitmap .. new:
rNO
nSf deb.indenting .. deb.width" 0:
RrTURN [ TRur ]:
rNO;
GetMapSpaee: PROCroURf [nwords: [0 .. 77777B]] RrTURNS [p: Ordel'edPOINHR]
BfGIN
l: INHGrR;
00
systemdisplay.mESA 24-0CT-77 18:66:07 Page 5
t ~ bmTail - bmNext;
IF t < 0 THEN
IF bmLastLine >= bmNext+nwords THEN EXIT
ELSE bmNext ~ bmFirst
ELSE
IF t >= nwords THEN EXIT
ELSE RETURN[OrderedNIL];
ENDLOOP;
p ~ bmNext:
bmNext ~ bmNext + nwords;
RETURN
END:
DPutChar: PROCEDURE [stream: StreamHandle. char: UNSPECIFIED] =
BEGIN
IF stream # systemDS THEN SIGNAL StreamDefs.StreamError[stream.StreamType]:
IF -displayOn THEN RETURN:
IF char> 377B THEN RETURN:
IF char < 40B OR
bmState.x + font.charWidth[font. char] > RightMargin THEN Scroll[char]
ELSE font.painlChar[font.char.@bmState]:
RETURN
END:
DPutCharTS: PROCEDURE [stream: StreamHandle. char: UNSPECIFIED]
BEGIN
DPutChar[stream. char]:
IF typescript # NIL THEN typescript.put[typescript, char]:
RETURN
END:
ClearChar: PROCEDURE [stream: StreamHandle, char: UNSPECIFIED] =
BEGIN
IF stream # systemDS THEN SIGNAL StreamDefs.StreamError[stream.StreamType]:
IF displayOn THEN
BEGIN
SELECT char FROM
NUL. CR. > 377B => RETURN:
TAB =>
BEGIN
IF TABindex > 0 THEN
BEGIN
TABindex ~ TABindex -1:
bmState.x ~ TABs[TABindex]:
END:
RETURN
END:
< 40B =>
BEGIN
ClearDisplayChar[stream. char+l00B]:
char ~ ''I':
END:
ENDCASE => NULL;
font.clearChar[font.char,@bmState];
END;
RETURN
END;
ClearDisplayChar: PUBLIC PROCEDURE [stream: SireamHandle. char: UNSPECIFIED] =
BEGIN
ClearChar[stream, char);
IF typescr ipt # NIL THEN
BfGIN OPEN SlreamDefs;
Setlndex[lypescripl. ModifyI~dex[GetIndex[typescript].-l]];
END;
RETURN
END;
GetNop: PROC[OURr [stream: StI'eamllandle] RrTURNS [UNSP[CtrIED]
BrGIN
ERROR StreamOefs.Streamfrror[stream.StreamAccess]
ENO;
PutbackNop: PROCroURf [stream: SlI'eamHandle, char: UNSP[CIrHO]
BrGIN
ERROR StreamOefs.StreamFrror[stream,StreamAccess]
systemdisplay.mESA 24-0CT-77 1B:55:07 Page 6
END;
EndofNop: PROCEDURE [stream: StreamHandle] RETURNS [BOOLEAN]