-- File: JaMCIF.mesa -- Written by Martin Newell February 1980 -- JaM interface for running CIFControl.mesa -- Last edited: November 5, 1981 10:31 AM DIRECTORY CIFControlDefs: FROM "CIFControlDefs" USING [ParseCIF, EndCIF], CIFDevicesDefs: FROM "CIFDevicesDefs" USING [SelectDevice, OutputDevice, Draw, DrawFrame, SetScale, SetClipRegion, LoadLayer, SetLayerVisible, LookupLayerString], CIFUtilitiesDefs: FROM "CIFUtilitiesDefs" USING [Rectangle, GetClipRectangle, SetUniformView, TrackBox, GetBaseClipRectangle, GetDisplayContext, SetClipRectangle, InitCedarGraphics, ClearClipRectangle], DisplayDefs: FROM "DisplayDefs" USING [SetTypeScript], Graphics: FROM "Graphics" USING [DisplayContext, InitContext, DrawRectangle, SetTexture, grey, Texture, Translate], IcarusInputDefs: FROM "IcarusInputDefs" USING [ParseIcarus], IntDefs: FROM "IntDefs" USING [InitInterpreter, IBoundBox], ParserDefs: FROM "ParserDefs" USING [InitParser], IntTransDefs: FROM "IntTransDefs" USING [Push, Pop, Rotate], IODefs: FROM "IODefs" USING [WriteLine], JaMFnsDefs: FROM "JaMFnsDefs" USING [Register, PopString, PopInteger, PushBoolean, PushReal, GetReal], KeyDefs: FROM "KeyDefs" USING [MouseButton], OutputDefs: FROM "OutputDefs" USING [InitOutput], StreamDefs: FROM "StreamDefs" USING [NewByteStream, Read, Write, Append], StringDefs: FROM "StringDefs" USING [AppendChar, AppendString]; JaMCIF: PROGRAM IMPORTS CIFDevicesDefs, CIFUtilitiesDefs, DisplayDefs, Graphics, IcarusInputDefs, ParserDefs, IntDefs, IntTransDefs, IODefs, JaMFnsDefs, CIFControlDefs, OutputDefs, StreamDefs, StringDefs = BEGIN OPEN CIFDevicesDefs, CIFUtilitiesDefs, DisplayDefs, Graphics, IcarusInputDefs, IntDefs, IODefs, JaMFnsDefs, KeyDefs, CIFControlDefs, OutputDefs, StreamDefs, StringDefs; --Initialization InitView: PROCEDURE = BEGIN --expects nothing cr: Rectangle _ GetBaseClipRectangle[]; InitContext[GetDisplayContext[]]; SetClipRectangle[cr]; END; --I/O CallParseCIF: PROCEDURE = BEGIN --expects (STRING) --returns (BOOLEAN) filename: STRING _ [50]; PopString[filename]; PushBoolean[ParseCIF[DefaultExtension[filename,"cif"]]]; [,,,] _ IBoundBox[]; IntTransDefs.Push[]; --to allow for global transformation END; CallParseIcarus: PROCEDURE = BEGIN --expects --returns (BOOLEAN) cifunits: LONG INTEGER _ PopInteger[]; icunits: LONG INTEGER _ PopInteger[]; filename: STRING _ [50]; ok: BOOLEAN; nDefs: INTEGER; PopString[filename]; [ok,nDefs] _ ParseIcarus[DefaultExtension[filename,"ic"], icunits, cifunits, 1]; PushBoolean[ok]; IntTransDefs.Push[]; --to allow for global transformation END; CallEndCIF: PROCEDURE = BEGIN --expects nothing EndCIF[]; END; CallIBoundBox: PROCEDURE = BEGIN --expects nothing, returns left,right,bottom,top: LONG INTEGER; [left,right,bottom,top] _ IBoundBox[]; PushReal[left]; PushReal[bottom]; PushReal[right]; PushReal[top]; END; --Device selection Select: PROCEDURE = BEGIN --expects <, deviceName> (STRING) deviceName: STRING _ [20]; PopString[deviceName]; [] _ SelectDevice[deviceName]; END; --Device output Output: PROCEDURE = BEGIN --expects OutputDevice[]; END; CallDraw: PROCEDURE = BEGIN Draw[]; END; --Viewing control CallDrawFrame: PROCEDURE = --draw frame around clipping region, partitioned as appropriate for device BEGIN DrawFrame[]; END; CallTrackBox: PROCEDURE = BEGIN --expects (REAL) mouseButtons: KeyDefs.MouseButton; mouse: INTEGER _ PopInteger[]; y: REAL _ GetReal[]; x: REAL _ GetReal[]; SELECT mouse FROM 4 => mouseButtons _ Red; 2 => mouseButtons _ Yellow; 1 => mouseButtons _ Blue; ENDCASE => RETURN; TrackBox[x,y, mouseButtons]; END; Expand: PROCEDURE = BEGIN --expects (REAL) r: Rectangle _ GetClipRectangle[]; top: REAL _ GetReal[]; right: REAL _ GetReal[]; bottom: REAL _ GetReal[]; left: REAL _ GetReal[]; SetUniformView[[MIN[left,right],MIN[bottom,top],MAX[left,right],MAX[bottom,top]], r]; END; Contract: PROCEDURE = BEGIN --expects (REAL) r: Rectangle _ GetClipRectangle[]; top: REAL _ GetReal[]; right: REAL _ GetReal[]; bottom: REAL _ GetReal[]; left: REAL _ GetReal[]; SetUniformView[r, [MIN[left,right],MIN[bottom,top],MAX[left,right],MAX[bottom,top]]]; END; Scroll: PROCEDURE = BEGIN --expects (REAL) dc: DisplayContext _ GetDisplayContext[]; yto: REAL _ GetReal[]; xto: REAL _ GetReal[]; yfrom: REAL _ GetReal[]; xfrom: REAL _ GetReal[]; Translate[dc, [xto-xfrom, yto-yfrom]]; END; SetRotate: PROCEDURE = BEGIN --expects (INTEGER) yRot: LONG INTEGER _ PopInteger[]; xRot: LONG INTEGER _ PopInteger[]; IntTransDefs.Pop[]; IntTransDefs.Push[]; IntTransDefs.Rotate[xRot,yRot]; [] _ IBoundBox[]; --to cause bounding boxes to be rebound END; CallSetScale: PROCEDURE = BEGIN --expects (REAL) --sets scale to map from chip coords to currently selected output device coords factor: REAL _ GetReal[]; SetScale[factor]; END; CallSetClipRegion: PROCEDURE = BEGIN --expects (REAL) rt: Rectangle; rt.ury _ GetReal[]; rt.urx _ GetReal[]; rt.lly _ GetReal[]; rt.llx _ GetReal[]; SetClipRegion[rt]; END; CallGetClipRegion: PROCEDURE = BEGIN --returns (REAL) rt: Rectangle _ GetClipRectangle[]; PushReal[rt.llx]; PushReal[rt.lly]; PushReal[rt.urx]; PushReal[rt.ury]; END; CallSetLayerVisible: PROCEDURE = BEGIN --expects (STRING) layer: STRING _ [10]; PopString[layer]; SetLayerVisible[LookupLayerString[layer], TRUE]; END; CallSetLayerInVisible: PROCEDURE = BEGIN --expects (STRING) layer: STRING _ [10]; PopString[layer]; SetLayerVisible[LookupLayerString[layer], FALSE]; END; --General Device parameters CallLoadStipple: PROCEDURE = BEGIN --expects (STRING, INTEGERs) g3: CARDINAL _ PopInteger[]; g2: CARDINAL _ PopInteger[]; g1: CARDINAL _ PopInteger[]; g0: CARDINAL _ PopInteger[]; layer: STRING _ [10]; PopString[layer]; LoadLayer[LookupLayerString[layer], g0, g1, g2, g3]; END; CallLoadColor: PROCEDURE = BEGIN --expects (STRING, INTEGERs) bri: CARDINAL _ PopInteger[]; sat: CARDINAL _ PopInteger[]; hue: CARDINAL _ PopInteger[]; layer: STRING _ [10]; PopString[layer]; LoadLayer[LookupLayerString[layer], hue, sat, bri, 0]; END; --Misc CallDrawBoxArea: PROCEDURE = BEGIN --expects (REAL) top: REAL _ GetReal[]; right: REAL _ GetReal[]; bottom: REAL _ GetReal[]; left: REAL _ GetReal[]; dc: DisplayContext _ GetDisplayContext[]; SetTexture[dc, grey]; DrawRectangle[dc, [left,bottom],[right,top]]; END; StippleBox: PROCEDURE = BEGIN --expects (REALs, INTEGER) layer: CARDINAL _ PopInteger[]; top: REAL _ GetReal[]; right: REAL _ GetReal[]; bottom: REAL _ GetReal[]; left: REAL _ GetReal[]; dc: DisplayContext _ GetDisplayContext[]; SetTexture[dc, Stipple[layer]]; DrawRectangle[dc, [left,bottom],[right,top]]; END; Erase: PROCEDURE = BEGIN --erase clip region ClearClipRectangle[]; END; --Private procedures-- MakeLog: PROCEDURE = BEGIN WriteLine["Typescript on Magic.log"]; SetTypeScript[NewByteStream["Magic.log", Read+Write+Append]]; END; DefaultExtension: PUBLIC PROCEDURE[name,ext: STRING] RETURNS[STRING] = --set extension if not already present BEGIN i: CARDINAL; FOR i IN [0..name.length) DO IF name[i]='. THEN RETURN[name]; ENDLOOP; AppendChar[name,'.]; AppendString[name,ext]; RETURN[name]; END; Stipple: ARRAY [0..7] OF Texture _ [ 000020B, --implant 040501B, --diffusion 014102B, --poly 165627B, --contact 000050B, --metal 001110B, --buried 001122B, --glass 177777B]; --undef --*** START Code *** InitCedarGraphics[]; InitView[]; MakeLog[]; --Initial initialization of modules IF ~ParserDefs.InitParser[] THEN WriteLine["Initial InitParser Error"]; IF ~IntDefs.InitInterpreter[] THEN WriteLine["Initial InitInterpreter Error"]; IF ~OutputDefs.InitOutput[] THEN WriteLine["Initial InitOutput Error"]; --Initialization Register["initview",InitView]; --I/O Register["parsecif",CallParseCIF]; Register["parseic",CallParseIcarus]; Register["endcif",CallEndCIF]; Register["boundbox",CallIBoundBox]; --Device selection Register["select",Select]; --Device output Register["output",Output]; Register["drawscreen",CallDraw]; --Viewing control Register["drawframe",CallDrawFrame]; Register["trackbox",CallTrackBox]; Register["expand",Expand]; Register["contract",Contract]; Register["scroll",Scroll]; Register["rotate",SetRotate]; Register["setscale",CallSetScale]; Register["setclipregion",CallSetClipRegion]; Register["getclipregion",CallGetClipRegion]; Register["vis",CallSetLayerVisible]; Register["invis",CallSetLayerInVisible]; --General Device parameters Register["loadstipple",CallLoadStipple]; Register["loadcolor",CallLoadColor]; --Misc Register["drawboxarea",CallDrawBoxArea]; Register["stipplebox",StippleBox]; Register["erase",Erase]; END. (635)\152b9B1221b6B394b8B152b12B270b15B410b10B57b13B247b6B192b6B96b8B56b13B118b12B328b6B294b8B294b6B251b9B267b12B180b17B189b17B182b19B147b21B177b15B293b13B277b15B284b10B345b5B96b7B130b16B