CDSilImpl.mesa
Copyright © 1983, 1985 by Xerox Corporation. All rights reserved.
by Ch. Jacobi August 11, 1983 3:56 pm
Last Edited by: Ch. Jacobi, March 19, 1986 5:10:29 pm PST
gbb April 11, 1986 7:57:41 pm PST
DIRECTORY
CD USING [backgroundLayer, CreateDrawRef, Design, DrawProc, DrawRectProc, DrawRef, errorLayer, Instance, Layer, NewLayer, Number, Position, Rect, RegisterTechnology, shadeLayer, Technology],
CDBasics USING [BaseOfAnyRect, SizeOfRect],
CDColors USING [Brick, DefineColor],
CDCommandOps USING [BoundingBox, CallWithResource],
CDIO USING [MakeName],
CDOps USING [CreateDesign, DrawDesign],
CDOrient USING [OrientateContext],
CDPanel USING [DefineButton, DefineIntEntry, DefineLayerEntry, DefineNewLine],
CDPanelFonts USING [ImplementIt],
CDSequencer USING [Command, CommandProc, ImplementCommand],
CDSil USING [],
CDTexts USING [TextPtr],
CDTipEtc USING [SetTipTable],
CDValue USING [Fetch, StoreInt],
CDViewer USING [CreateViewer],
ColorMaps USING [RegisterMenu],
Commander USING [CommandProc, Register],
FileNames USING [CurrentWorkingDirectory],
FS USING [ComponentPositions, ExpandName, Position],
Imager USING [black, ColorOperator, Context, DoSave, MaskRectangle, Rectangle, ScaleT, SetColor, SetFont, SetXY, ShowRope, TranslateT],
ImagerColorOperator USING [BlackColorModel, ColorOperator, RGBLinearColorModel],
ImagerInterpress USING [Close, Create, DeclareColorOperator, DoPage, Ref],
IO USING [PutRope],
PrincOpsUtils USING [],
Process USING [priorityBackground, SetPriority],
Rope USING [Cat, Replace, ROPE],
TerminalIO USING [WriteRope];
CDSilImpl: CEDAR PROGRAM
IMPORTS CD, CDBasics, CDColors, CDCommandOps, CDIO, CDOps, CDOrient, CDPanel, CDPanelFonts, CDSequencer, CDTipEtc, CDValue, CDViewer, ColorMaps, Commander, FileNames, FS, Imager, ImagerColorOperator, ImagerInterpress, IO, Process, Rope, TerminalIO
EXPORTS CDSil =
BEGIN
lambda: CD.Number = 2;
cdsil: PUBLIC CD.Technology ~ CD.RegisterTechnology [$chipnsil, "chipnsil", lambda];
The colours are the same as on Alto Sil with the addition of blue.
xneutral: PUBLIC CD.Layer ← CD.NewLayer [cdsil, $xneutral]; -- 00
xred: PUBLIC CD.Layer ← CD.NewLayer [cdsil, $xred]; -- 01
xyellow: PUBLIC CD.Layer ← CD.NewLayer [cdsil, $xyellow]; -- 02
xgreen: PUBLIC CD.Layer ← CD.NewLayer [cdsil, $xgreen]; -- 03
xcyan: PUBLIC CD.Layer ← CD.NewLayer [cdsil, $xcyan]; -- 04
xviolet: PUBLIC CD.Layer ← CD.NewLayer [cdsil, $xviolet];  -- 05
xmagenta: PUBLIC CD.Layer ← CD.NewLayer [cdsil, $xmagenta]; -- 06
xwhite: PUBLIC CD.Layer ← CD.NewLayer [cdsil, $xwhite]; -- 07
xbrown: PUBLIC CD.Layer ← CD.NewLayer [cdsil, $xbrown]; -- 08
xorange: PUBLIC CD.Layer ← CD.NewLayer [cdsil, $xorange]; -- 09
xlime: PUBLIC CD.Layer ← CD.NewLayer [cdsil, $xlime]; -- 10
xturquise: PUBLIC CD.Layer ← CD.NewLayer [cdsil, $xturquise]; -- 11
xaqua: PUBLIC CD.Layer ← CD.NewLayer [cdsil, $xaqua]; -- 12
xultraviolet: PUBLIC CD.Layer ← CD.NewLayer [cdsil, $xultraviolet];-- 13
xpink: PUBLIC CD.Layer ← CD.NewLayer [cdsil, $xpink]; -- 14
xsmoke: PUBLIC CD.Layer ← CD.NewLayer [cdsil, $xsmoke]; -- 15
xblue: PUBLIC CD.Layer ← CD.NewLayer [cdsil, $xblue]; -- not a Sil color
tipTable: Rope.ROPENIL;
Load: Commander.CommandProc = BEGIN
cmd.out.PutRope ["ChipNSil loaded.\n"];
END;
NewSWorld: Commander.CommandProc = BEGIN
design: CD.Design ~ CDOps.CreateDesign [cdsil];
[] ← CDViewer.CreateViewer [design];
END;
IPcmd: PROC [comm: CDSequencer.Command] ~ BEGIN
Produces an Interpress master of the design.
interpress: ImagerInterpress.Ref;
ipName: Rope.ROPE;
rgbLinear: Imager.ColorOperator ~ ImagerColorOperator.RGBLinearColorModel [255];
bw: Imager.ColorOperator ~ ImagerColorOperator.BlackColorModel [TRUE];
pageHeight: REAL ~ 0.253; pageWidth: REAL ~ 0.156; -- in meters
DoIt: PROC [comm: CDSequencer.Command] ~ BEGIN
Does it at background priority.
TRUSTED {Process.SetPriority [Process.priorityBackground]};
interpress ← OpenIPMaster [];
TerminalIO.WriteRope [Rope.Cat ["Producing Interpress master ", ipName, "\n"]];
ImagerInterpress.DeclareColorOperator [interpress, rgbLinear];
ImagerInterpress.DoPage [interpress, DrawToIP];
ImagerInterpress.Close [interpress];
TerminalIO.WriteRope [Rope.Cat ["Interpress master ", ipName, " written.\n"]]
END; -- DoIt
OpenIPMaster: PROC [] RETURNS [ImagerInterpress.Ref] ~ BEGIN
Creates the interpress master.
pos: FS.ComponentPositions;
ipName ← NARROW [CDValue.Fetch [comm.design, $CDxLastFile], Rope.ROPE];
[fullFName: ipName, cp: pos] ← FS.ExpandName [ipName];
IF (pos.server.length > 0) OR (pos.dir.length > 0) THEN
[fullFName: ipName, cp: pos] ← FS.ExpandName ["ChipNSil"];
ipName ← ipName.Replace [pos.ext.start, pos.ext.length, "Interpress"];
RETURN [ImagerInterpress.Create [ipName]]
END; -- OpenIPMaster
DrawToIP: PROC [context: Imager.Context] ~ BEGIN
Called back by the Interpress machinery.
dr: CD.DrawRef = CD.CreateDrawRef [[]];
bb: Imager.Rectangle = ImagerRect [CDCommandOps.BoundingBox [comm.design]];
EnumerateDesign: PROC ~ BEGIN CDOps.DrawDesign [comm.design, dr] END;
dr.drawRect ← DrawRect;
dr.drawChild ← DrawObject;
dr.devicePrivate ← context;
IF bb.w > bb.h THEN Imager.RotateT [context, 90.0];
Imager.TranslateT [context, [-bb.w, -bb.h]];
Imager.ScaleT [context, MIN [pageWidth/bb.w, pageHeight/bb.h]];
Imager.DoSave [context, EnumerateDesign]
END; -- DrawToIP
[] ← CDCommandOps.CallWithResource [DoIt, comm, $CDSilIP]
END; -- IPcmd
ImagerRect: PROC [r: CD.Rect] RETURNS [Imager.Rectangle] ~ BEGIN
base: CD.Position ~ CDBasics.BaseOfAnyRect [r];
size: CD.Position ~ CDBasics.SizeOfRect [r];
RETURN [[base.x, base.y, size.x, size.y]]
END; -- ImagerRect
DrawRect: CD.DrawRectProc ~ BEGIN
[r: Rect, l: Layer, pr: DrawRef]
context: Imager.Context ~ NARROW [pr.devicePrivate];
Imager.SetColor [context, Imager.black];
Imager.MaskRectangle [context, ImagerRect[r]]
END; -- DrawRect
DrawText: CD.DrawProc ~ BEGIN
[inst: CD.Instance, pos: CD.Position, orient: CD.Orientation, pr: CD.DrawRef]
context: Imager.Context ~ NARROW [pr.devicePrivate];
text: CDTexts.TextPtr ~ NARROW [inst.ob.specificRef];
Imager.TranslateT [context, [pos.x, pos.y]];
CDOrient.OrientateContext [context, inst.ob.size, orient];
Imager.SetColor [context, Imager.black];
Imager.SetXY [context, text.cdFont.xy];
Imager.SetFont [context, text.cdFont.font];
Imager.ShowRope [context, text.text]
END; -- DrawRect
DrawObject: CD.DrawProc ~ BEGIN
[inst: Instance, pos: Position, orient: Orientation, pr: REF DrawInformation]
SELECT inst.ob.class.objectType FROM
$Rect => NULL;
$Text => DrawText [inst, pos, orient, pr];
$Cell => inst.ob.class.drawMe [inst, pos, orient, pr];
ENDCASE => inst.ob.class.drawMe [inst, pos, orient, pr] -- temporary. expand hard
END; -- DrawObject
Init: PROC [] = BEGIN
s1: CARDINAL = 1;
s2: CARDINAL = 16;
s3: CARDINAL = 16*16;
s4: CARDINAL = 16*16*16;
ss: CARDINAL = s1+s2+s3+s4;
Init8Patterns: PROC [] = BEGIN
red: CARDINAL = 1;
green: CARDINAL = 2;
blue: CARDINAL = 4;
cyan: CARDINAL = 8;
magenta: CARDINAL = 16;
yellow: CARDINAL = 32;
white: CARDINAL = 64;
fakeAqua: CARDINAL = green+cyan;  -- 10
fakeTurquoise: CARDINAL = blue + cyan; -- 12
fakeBrown: CARDINAL = green+magenta; -- 18
fakeViolet: CARDINAL = cyan+magenta; -- 24
fakeUltraviolet: CARDINAL = blue + cyan + magenta; -- 28
orange: CARDINAL = red+yellow; -- 33 this orange is better than the one used by Sil
fakeSmoke: CARDINAL = blue+yellow;  -- 36
fakeLime: CARDINAL = cyan+yellow;  -- 40
fakePink: CARDINAL = magenta + white; -- 80
fakeBlack: CARDINAL = white-1;
Pixels in a dither:
1 2
3 4
5 6
7 8
Each pixel has 8 bits, one for every element in the table cDefaults.
pixel1: CARDINAL = 1;
pixel3: CARDINAL = 256;
Mixture: PROC [col: CARDINAL] RETURNS [REF CDColors.Brick] ~ BEGIN
Full colour
RETURN [Dither1to1 [col, col]]
END;
Dither1to1: PROC [col1, col2: CARDINAL ← white] RETURNS [REF CDColors.Brick] ~ BEGIN
Dither 1 to 1
RETURN [NEW [CDColors.Brick ← [col1*pixel1+col2*pixel3, col2*pixel1+col1*pixel3, col1*pixel1+col2*pixel3, col2*pixel1+col1*pixel3]]]
END;
Lighten: PROC [l: CD.Layer, color: CARDINAL] = BEGIN
CDColors.DefineColor [l, Dither1to1[color], bit8, pushedOut];
END;
CDColors.DefineColor [xneutral, Mixture[fakeBlack], bit8];
CDColors.DefineColor [xred, Mixture[red], bit8];
CDColors.DefineColor [xyellow, Mixture[yellow], bit8];
CDColors.DefineColor [xgreen, Mixture[green], bit8];
CDColors.DefineColor [xcyan, Mixture[cyan], bit8];
CDColors.DefineColor [xviolet, Mixture[fakeViolet], bit8];
CDColors.DefineColor [xmagenta, Mixture[magenta], bit8];
CDColors.DefineColor [xwhite, Mixture[white], bit8];
CDColors.DefineColor [xbrown, Mixture[fakeBrown], bit8];
CDColors.DefineColor [xorange, Mixture[orange], bit8];
CDColors.DefineColor [xlime, Mixture[fakeLime], bit8];
CDColors.DefineColor [xturquise, Mixture[fakeTurquoise], bit8];
CDColors.DefineColor [xaqua, Mixture[fakeAqua], bit8];
CDColors.DefineColor [xultraviolet, Mixture[fakeUltraviolet], bit8];
CDColors.DefineColor [xpink, Mixture[fakePink], bit8];
CDColors.DefineColor [xsmoke, Mixture[fakeSmoke], bit8];
CDColors.DefineColor [xblue, Mixture[blue], bit8];
CDColors.DefineColor [CD.backgroundLayer, NEW[CDColors.Brick ← [8, 0, 256*8, 0]], bit8];
CDColors.DefineColor [CD.errorLayer, NEW[CDColors.Brick ← [255, 0, 0, 0]], bit8];
CDColors.DefineColor [CD.shadeLayer, NEW[CDColors.Brick←[0, 255,0 , 255]], bit8];
Lighten [xneutral, fakeBlack];
Lighten [xred, red];
Lighten [xyellow, yellow];
Lighten [xgreen, green];
Lighten [xcyan, cyan];
Lighten [xviolet, fakeViolet];
Lighten [xmagenta, magenta];
Lighten [xwhite, white];
Lighten [xbrown, fakeBrown];
Lighten [xorange, orange];
Lighten [xlime, fakeLime];
Lighten [xturquise, fakeTurquoise];
Lighten [xaqua, fakeAqua];
Lighten [xultraviolet, fakeUltraviolet];
Lighten [xpink, fakePink];
Lighten [xsmoke, fakeBlack];
Lighten [xblue, blue];
HackContextColors[];
END; -- Init8Patterns
4 bit colors
blue: CARDINAL = 1;
green: CARDINAL = 2;
red: CARDINAL = 4;
yellow: CARDINAL = 14;
black: CARDINAL = 0FFFFH;
CDTipEtc.SetTipTable[cdsil, "Standard"];
the 1 bit pattern are fair but not great
the 4 bit pattern are nice with cmos-chipmonk
the 8 bit pattern don't fit anywhere
CDColors.DefineColor[xneutral,
NEW[CDColors.Brick←[8*s1, 0, 0, 0]], bit4];
CDColors.DefineColor[xneutral,
NEW[CDColors.Brick←[05H*1111H, 0AH*1111H, 05H*1111H, 0AH*1111H]], bw]; -- 00
CDColors.DefineColor[xneutral,
NEW[CDColors.Brick←[black, black, black, black]], bw]; -- 00
CDColors.DefineColor[xred,
NEW[CDColors.Brick←[7*ss, 11*ss, 7*ss, 11*ss]], bit4];
CDColors.DefineColor[xred,
NEW[CDColors.Brick←[8*ss, 4*ss, 2*ss, 1*ss]], bw]; -- 01
CDColors.DefineColor[xyellow,
NEW[CDColors.Brick←[yellow*ss, yellow*ss, yellow*ss, yellow*ss]], bit4];
CDColors.DefineColor[xyellow,
NEW[CDColors.Brick←[2*ss, 0, 2*ss, 0]], bw]; -- 02
CDColors.DefineColor[xgreen,
NEW[CDColors.Brick←[green*ss, green*ss, green*ss, green*ss]], bit4];
CDColors.DefineColor[xgreen,
NEW[CDColors.Brick←[4*ss, ss, 4*ss, ss]], bw]; -- 03
CDColors.DefineColor[xcyan,
NEW[CDColors.Brick←[2*(s1+s2+s3), 2*ss, 2*(s1+s2+s3)+15*s4, 2*ss]], bit4];
CDColors.DefineColor[xcyan,
NEW[CDColors.Brick←[0EH*1111H, 0DH*1111H, 0BH*1111H, 07H*1111H]], bw]; -- 04
CDColors.DefineColor[xviolet,
NEW[CDColors.Brick←[10*1111H, 10*1111H, 10*1111H, 10*1111H]], bit4];
CDColors.DefineColor[xviolet,
NEW[CDColors.Brick←[0EH*1111H, 0DH*1111H, 0BH*1111H, 07H*1111H]], bw]; -- 05
CDColors.DefineColor[xmagenta,
NEW[CDColors.Brick←[10*1111H, 10*1111H, 10*1111H, 10*1111H]], bit4];
CDColors.DefineColor[xmagenta,
NEW[CDColors.Brick←[8*ss, 8*ss, 2*ss, 2*ss]], bw]; -- 06
CDColors.DefineColor[xwhite,
NEW[CDColors.Brick←[11*ss, 11*ss, 11*ss, 11*ss]], bit4];
CDColors.DefineColor[xwhite,
NEW[CDColors.Brick←[4*ss, 0, 0, 0]], bw]; -- 07
CDColors.DefineColor[xbrown,
NEW[CDColors.Brick←[10*1111H, 10*1111H, 10*1111H, 10*1111H]], bit4];
CDColors.DefineColor[xbrown,
NEW[CDColors.Brick←[0EH*1111H, 0DH*1111H, 0BH*1111H, 07H*1111H]], bw]; -- 08
CDColors.DefineColor[xorange,
NEW[CDColors.Brick←[10*1111H, 10*1111H, 10*1111H, 10*1111H]], bit4];
CDColors.DefineColor[xorange,
NEW[CDColors.Brick←[0EH*1111H, 0DH*1111H, 0BH*1111H, 07H*1111H]], bw]; -- 09
CDColors.DefineColor[xlime,
NEW[CDColors.Brick←[10*1111H, 10*1111H, 10*1111H, 10*1111H]], bit4];
CDColors.DefineColor[xlime,
NEW[CDColors.Brick←[0EH*1111H, 0DH*1111H, 0BH*1111H, 07H*1111H]], bw]; -- 10
CDColors.DefineColor[xturquise,
NEW[CDColors.Brick←[10*1111H, 10*1111H, 10*1111H, 10*1111H]], bit4];
CDColors.DefineColor[xturquise,
NEW[CDColors.Brick←[0EH*1111H, 0DH*1111H, 0BH*1111H, 07H*1111H]], bw]; -- 11
CDColors.DefineColor[xaqua,
NEW[CDColors.Brick←[10*1111H, 10*1111H, 10*1111H, 10*1111H]], bit4];
CDColors.DefineColor[xaqua,
NEW[CDColors.Brick←[0EH*1111H, 0DH*1111H, 0BH*1111H, 07H*1111H]], bw]; -- 12
CDColors.DefineColor[xultraviolet,
NEW[CDColors.Brick←[10*1111H, 10*1111H, 10*1111H, 10*1111H]], bit4];
CDColors.DefineColor[xultraviolet,
NEW[CDColors.Brick←[0EH*1111H, 0DH*1111H, 0BH*1111H, 07H*1111H]], bw]; -- 13
CDColors.DefineColor[xpink,
NEW[CDColors.Brick←[10*1111H, 10*1111H, 10*1111H, 10*1111H]] , bit4];
CDColors.DefineColor[xpink,
NEW[CDColors.Brick←[8*ss, 2*ss, 0, 0]], bw]; -- 14
CDColors.DefineColor[xsmoke,
NEW[CDColors.Brick←[red*ss, red*ss, red*ss, red*ss]], bit4];
CDColors.DefineColor[xsmoke,
NEW[CDColors.Brick←[4*ss, 14*ss, 4*ss, 0*ss]], bw]; -- 15
CDColors.DefineColor[xblue,
NEW[CDColors.Brick←[blue*ss, blue*ss, blue*ss, blue*ss]], bit4];
CDColors.DefineColor[xblue,
NEW [CDColors.Brick←[7*ss, 11*ss, 7*ss, 11*ss]], bw]; -- not Sil
Init8Patterns[];
CDPanel.DefineButton [tech: cdsil, name: "Interpress", command: $CDSilIP, topLine: TRUE];
CDSequencer.ImplementCommand[$CDSilIP, IPcmd,, doQueue];
CDPanel.DefineLayerEntry [cdsil, xneutral, "black", 0, lambda];
CDPanel.DefineLayerEntry [cdsil, xwhite, "white", 0, lambda];
CDPanel.DefineLayerEntry [cdsil, xsmoke, "grey", 0, lambda];
CDPanel.DefineLayerEntry [cdsil, xred, "red", 0, lambda];
CDPanel.DefineLayerEntry [cdsil, xblue, "blue", 0, lambda];
CDPanel.DefineLayerEntry [cdsil, xgreen, "green", 0, lambda];
CDPanel.DefineLayerEntry [cdsil, xcyan, "cyan", 0, lambda];
CDPanel.DefineLayerEntry [cdsil, xmagenta, "magenta", 0, lambda];
CDPanel.DefineLayerEntry [cdsil, xyellow, "yellow", 0, lambda];
CDPanel.DefineLayerEntry [cdsil, xpink, "pink", 0, lambda];
CDPanel.DefineLayerEntry [cdsil, xorange, "orange", 0, lambda];
CDPanel.DefineLayerEntry [cdsil, xbrown, "brown", 0, lambda];
CDPanel.DefineLayerEntry [cdsil, xlime, "lime", 0, lambda];
CDPanel.DefineLayerEntry [cdsil, xaqua, "aqua", 0, lambda];
CDPanel.DefineLayerEntry [cdsil, xturquise, "turquise", 0, lambda];
CDPanel.DefineLayerEntry [cdsil, xviolet, "violet", 0, lambda];
CDPanel.DefineLayerEntry [cdsil, xultraviolet, "UV", 0, lambda];
CDPanel.DefineIntEntry [cdValueKey: $CDxSelectNewMode, tech: cdsil, text: "select new:", min: 0, max: 1, default: 1];
CDPanel.DefineNewLine [cdsil];
CDPanel.DefineIntEntry [cdValueKey: $CDxStepValue, tech: cdsil, text: "step moves size:", min: 1, default: 8];
CDPanel.DefineIntEntry [cdValueKey: $CDxStretchyMove, tech: cdsil, text: "stretchy:", min: 0, max: 1, default: 0];
CDPanel.DefineNewLine [cdsil];
CDValue.StoreInt [boundTo: cdsil, key: $CDxInitScale, value: 9];
CDValue.StoreInt [boundTo: cdsil, key: $CDxInitGrid, value: 8];
ColorMaps.RegisterMenu ["ChipNSil", CDIO.MakeName["ChipNSil", "ColorMap", FileNames.CurrentWorkingDirectory[]]];
CDPanelFonts.ImplementIt [cdsil];
Commander.Register [key: "///Commands/CDSil", proc: Load, doc: "Loads ChipNSil"];
Commander.Register [key: "///Commands/CDNewSil", proc: NewSWorld, doc: "Creates new chipndale 'sil' design"];
TerminalIO.WriteRope ["ChipNSil loaded [version of April 10, 1986].\n"];
END; -- Init
Init []
END.