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];
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