-- File CIFExtUtils.mesa -- Written by Dan Fitzpatrick and Martin Newell, June 1980 -- Last updated: November 13, 1980 1:22 AM DIRECTORY CIFDevicesDefs: FROM "CIFDevicesDefs" USING [MaxLENGTHLayerArray], CIFExtIODefs: FROM "CIFExtIODefs" USING [ReadStringDirect, ReadLong, WriteStringDirect, WriteLong, WriteLineDirect], CIFExtScanDefs: FROM "CIFExtScanDefs" USING [Edge], CIFExtUtilsDefs: FROM "CIFExtUtilsDefs", Graphics: FROM "Graphics" USING [Texture], IODefs: FROM "IODefs" USING [WriteString, WriteLine], SegmentDefs: FROM "SegmentDefs" USING[Read, Write, Append], StreamDefs: FROM "StreamDefs" USING[DiskHandle, NewByteStream], SystemDefs: FROM "SystemDefs" USING[AllocateHeapString, AllocateHeapNode, FreeHeapString, FreeHeapNode], StringDefs: FROM "StringDefs" USING[AppendLongDecimal, AppendString]; CIFExtUtils: PROGRAM IMPORTS CIFExtIODefs, IODefs, StreamDefs, StringDefs, SystemDefs EXPORTS CIFExtUtilsDefs = BEGIN OPEN CIFDevicesDefs, CIFExtIODefs, CIFExtScanDefs, Graphics, IODefs, StringDefs, SegmentDefs, StreamDefs, SystemDefs; SetExtLayer: PUBLIC PROCEDURE[layer:CARDINAL, v0,v1,v2,v3: CARDINAL] = BEGIN Stipple[layer] _ v0; END; DrawNumber: PUBLIC PROCEDURE[layer: CARDINAL, n: LONG POINTER, x,y: REAL] = --draw node number on screen for debugging --x,y are in screen coords BEGIN s: STRING _ [20]; AppendLongDecimal[s,LOOPHOLE[n,LONG CARDINAL]]; DrawString[s,x,y]; END; DrawString: PUBLIC PROCEDURE[s: STRING, x,y: REAL] = --draw string on screen for debugging --x,y are in screen coords BEGIN -- xc,yc,x0,y0,w,h: REAL; -- saveOutputTrapezoid: PROCEDURE [t:POINTER TO TrapezoidBlock] _ GetOutputTrapezoid[]; -- SetOutputTrapezoid[ScreenTrapezoid]; -- PushBaseContext[]; -- BEGIN -- ENABLE ANY => BEGIN CONTINUE END; -- [xc,yc] _ InverseTransform[x,y]; -- w _ GetStringWidth[s]; -- h _ GetFontDimensions[].ascent; -- x0 _ xc-w/2; -- y0 _ yc-h/2; -- SetAreaPaint[erase]; -- DrawBoxArea[[x0,y0,x0+w,y0+h]]; -- SetAreaPaint[paint]; -- MoveTo[x0,y0]; -- DisplayString[s]; -- END; -- PopDisplayContext[]; -- SetOutputTrapezoid[saveOutputTrapezoid]; END; DrawTrap: PUBLIC PROCEDURE[left: Edge, ystart: REAL, right: Edge, yend: REAL, layer: CARDINAL] = BEGIN --draw left and right edges on screen for debugging -- t: TrapezoidBlock _ [ -- ystart: ystart, -- yend: yend, -- xsleft: XatY[left,ystart], -- xsright: XatY[right,ystart], -- xeleft: XatY[left,yend], -- xeright: XatY[right,yend], -- function: paint, -- xbase: ScreenBase, -- xwords: ScreenWords, -- texture: @Stipple[layer] -- ]; -- ScreenTrapezoid[@t]; END; WriteLongDecimal: PUBLIC PROCEDURE[n: LONG CARDINAL] = BEGIN s: STRING _ [20]; AppendLongDecimal[s,n]; WriteString[s]; END; Tag: PUBLIC PROCEDURE[this,that: STRING] RETURNS [STRING] = -- Tags this with that and returns a string BEGIN s: STRING; s _ AllocateHeapString[this.length+that.length+2]; AppendString[s,this]; AppendString[s,"."]; AppendString[s,that]; RETURN[s]; END; SortNames: PUBLIC PROCEDURE[fileName: STRING] = BEGIN s: STRING _ [50]; LabelLocationFile: DiskHandle; Name: TYPE = POINTER TO NameRecord; NameRecord: TYPE = RECORD [ next: Name, label: STRING, x,y: LONG INTEGER, key: REAL ]; label, nameList, sortedList, ptr: Name; NoNameFile: BOOLEAN _ FALSE; -- Open the file; if it doesn't exist return LabelLocationFile _ NewByteStream[fileName,Read ! ANY => BEGIN WriteString[fileName]; WriteLine[": cannot open"]; NoNameFile _ TRUE; CONTINUE; END ]; IF NoNameFile THEN RETURN; LabelLocationFile.reset[LabelLocationFile]; -- Read the file and put it onto a sorted list nameList _ sortedList _ NIL; UNTIL LabelLocationFile.endof[LabelLocationFile] DO label _ AllocateHeapNode[SIZE[NameRecord]]; ReadStringDirect[s, LabelLocationFile]; IF LabelLocationFile.endof[LabelLocationFile] THEN BEGIN -- in case last line ends FreeHeapNode[label]; -- with white space EXIT; END; label.label _ AllocateHeapString[s.length]; AppendString[label.label, s]; label.x _ ReadLong[LabelLocationFile]; label.y _ ReadLong[LabelLocationFile]; -- insert the new element (label) into the list, leaving the list -- in ascending order IF nameList = NIL OR nameList.y > label.y THEN BEGIN label.next _ nameList; nameList _ label; LOOP; END; FOR ptr _ nameList, ptr.next UNTIL ptr.next = NIL DO IF ptr.next.y > label.y THEN EXIT; ENDLOOP; label.next _ ptr.next; ptr.next _ label; ENDLOOP; LabelLocationFile.destroy[LabelLocationFile]; -- Flip around pointers so list is in decending order FOR label _ nameList, nameList UNTIL label = NIL DO nameList _ label.next; label.next _ sortedList; sortedList _ label; ENDLOOP; -- Write the list back onto the file LabelLocationFile _ NewByteStream[fileName,Write+Append]; LabelLocationFile.reset[LabelLocationFile]; FOR label _ sortedList, sortedList UNTIL label = NIL DO sortedList _ label.next; WriteStringDirect[label.label, LabelLocationFile]; WriteStringDirect[" ", LabelLocationFile]; WriteLong[label.x, LabelLocationFile]; WriteStringDirect[" ", LabelLocationFile]; WriteLong[label.y, LabelLocationFile]; WriteLineDirect["",LabelLocationFile]; FreeHeapString[label.label]; FreeHeapNode[label]; ENDLOOP; LabelLocationFile.destroy[LabelLocationFile]; END; --ScreenTrapezoid: PROCEDURE [t:POINTER TO TrapezoidBlock] _ GetDefaultOutputTrapezoid[]; Stipple: ARRAY [0..MaxLENGTHLayerArray) OF Texture _ ALL[177777B]; --undef --Set up default stipples Stipple[0] _ 000020B; --implant Stipple[1] _ 040501B; --diffusion Stipple[2] _ 014102B; --poly Stipple[3] _ 165627B; --contact Stipple[4] _ 000050B; --metal Stipple[5] _ 001110B; --buried Stipple[6] _ 001122B; --glass Stipple[7] _ 177777B; --undef END. e12(635)\129b9B677b11B227b11B96b10B237b11B683b8B469b16B113b3B259b9B692v17V7v17V98v17V7v17V