--m.stone October 2, 1980 12:35 PM
DIRECTORY
GraphicsDefs: FROM "GraphicsDefs",
Real: FROM "Real",
RealFns: FROM "RealFns",
IODefs: FROM "IODefs",
ImageDefs: FROM "ImageDefs" USING [StopMesa],
StreamDefs: FROM "StreamDefs";
SetCRT: PROGRAM IMPORTS GraphicsDefs, ImageDefs, StreamDefs, RealFns, Real, IODefs =
BEGIN
Screen: POINTER TO GraphicsDefs.Bitmap ←
GraphicsDefs.TurnOnGraphics[8,FALSE,80];
MonitorControlBlock: POINTER TO POINTER = LOOPHOLE[417B];
keys: StreamDefs.KeyboardHandle ← StreamDefs.GetDefaultKey[];
SetColor: PROCEDURE [gray,red,green,blue: CARDINAL] =
BEGIN
GraphicsDefs.SetRed[gray,red];
GraphicsDefs.SetGreen[gray,green];
GraphicsDefs.SetBlue[gray,blue];
END;
twoToThe: PROCEDURE [n: CARDINAL] RETURNS [twoToTheN: CARDINAL] = INLINE
BEGIN
twoToTheN ← SELECT n FROM 0=>1,1=>2,2=>4,3=>8,4=>16,5=>32,6=>64,7=>128,ENDCASE=>256;
END;
All: PROCEDURE =
BEGIN
r,g,b,magenta,cyan,yellow,white: CARDINAL;
nsteps: CARDINAL = 16;
base: REAL ← 2;
value: REAL;
bwidth: CARDINAL ← 30;
width: CARDINAL ← (nsteps+1)*bwidth;
leftX: CARDINAL ← (606-width)/2;
lx,ty,h,x,v: CARDINAL;
base ← RealFns.SqRt[base];--2↑1/2
SetColor[0,background,background,background];
white ← 255;
SetColor[white,255,255,255];
r ← nsteps+2;
g ← r+1;
b ← r+2;
magenta ← r+3;
cyan ← r+4;
yellow ← r+5;
--make the colormap logrithmic grey plus the primaries and secondaries
value ← base;
FOR x IN [1..nsteps] DO
v ← Real.RoundI[Comp[value]];
SetColor[x,v,v,v];
IODefs.WriteDecimal[v];
IODefs.WriteLine[" "];
value ← value*base;
ENDLOOP;
SetColor[r,255,0,0];
SetColor[g,0,255,0];
SetColor[b,0,0,255];
SetColor[magenta,255,0,255];
SetColor[cyan,255,255,0];
SetColor[yellow,0,255,255];
lx ← leftX; ty ← 22; h ← 200;
--draw the white bar
GraphicsDefs.SetGrayLevel[white];
GraphicsDefs.ReplaceGray[lx,ty,lx+width,ty+h];
--draw the log grey scale
lx ← leftX; ty ← ty+h+20; h ← 140;
FOR x IN [0..nsteps) DO
GraphicsDefs.SetGrayLevel[x];
GraphicsDefs.ReplaceGray[lx,ty,lx+bwidth,ty+h];
lx ← lx+bwidth;
ENDLOOP;
--draw the primaries
lx ← leftX; ty ← ty+h+20; h ← 170; bwidth ← 150;
FOR x IN [r..b] DO
GraphicsDefs.SetGrayLevel[x];
GraphicsDefs.ReplaceGray[lx,ty,lx+bwidth,ty+h];
lx ← lx+bwidth;
ENDLOOP;
--draw the secondaries
lx ← leftX; ty ← ty+h+20;
FOR x IN [magenta..yellow] DO
GraphicsDefs.SetGrayLevel[x];
GraphicsDefs.ReplaceGray[lx,ty,lx+bwidth,ty+h];
lx ← lx+bwidth;
ENDLOOP;
END;
white: INTEGER ← 255;
dark: INTEGER ← 32;
light: INTEGER ← 255;
HiLo: PROCEDURE =
BEGIN
r,g,b,dr,dg,db: CARDINAL;
bwidth: CARDINAL ← 150;
leftX: CARDINAL ← (606-3*bwidth)/2;
lx,ty,h,x: CARDINAL;
SetColor[0,background,background,background];
SetColor[255,white,white,white];
r ← 1;
g ← r+1;
b ← r+2;
dr ← r+3;
dg ← r+4;
db ← r+5;
SetColor[r,light,0,0];
SetColor[g,0,light,0];
SetColor[b,0,0,light];
SetColor[dr,dark,0,0];
SetColor[dg,0,dark,0];
SetColor[db,0,0,dark];
lx ← leftX; ty ← 22; h ← 200;
--draw the white bar
GraphicsDefs.SetGrayLevel[white];
GraphicsDefs.ReplaceGray[lx,ty,lx+bwidth*3,ty+h];
--draw the light primaries
lx ← leftX; ty ← ty+h+20; h ← 170;
FOR x IN [r..b] DO
GraphicsDefs.SetGrayLevel[x];
GraphicsDefs.ReplaceGray[lx,ty,lx+bwidth,ty+h];
lx ← lx+bwidth;
ENDLOOP;
--draw the dark primaries
lx ← leftX; ty ← ty+h+20;
FOR x IN [dr..db] DO
GraphicsDefs.SetGrayLevel[x];
GraphicsDefs.ReplaceGray[lx,ty,lx+bwidth,ty+h];
lx ← lx+bwidth;
ENDLOOP;
END;
gamma: REAL ← 1.0/2.3;
Comp: PROCEDURE[intensity: REAL] RETURNS[REAL] =
BEGIN
intensity ← intensity/255;
intensity ← RealFns.Power[intensity,gamma];
RETURN[intensity*255];
END;
SetBackground: PROCEDURE [v: INTEGER] =
BEGIN
background ← v;
SetColor[0,v,v,v];
END;
background: INTEGER ← 255;
ClearScreen: PROCEDURE =
BEGIN
SetColor[0,background,background,background];
GraphicsDefs.EraseArea[0,0,Screen.nBits,Screen.nLines];
END;
WaitAWhile: PROCEDURE[millisecs: CARDINAL] =
BEGIN
i,j: CARDINAL;
FOR i IN [0..millisecs] DO
FOR j IN [0..2000] DO ENDLOOP;
ENDLOOP;
END;
WaitAWhile[40];
Real.InitReals[];
HiLo[];
DO
IF NOT keys.endof[keys] THEN
BEGIN
ch: CHARACTER ← keys.get[keys];
IODefs.WriteChar[ch];
IF ch = ’h THEN HiLo[];
IF ch = ’d THEN dark ← IODefs.ReadDecimal[];
IF ch = ’l THEN light ← IODefs.ReadDecimal[];
IF ch = ’w THEN white ← IODefs.ReadDecimal[];
IF ch = ’a THEN All[];
IF ch = ’b THEN SetBackground[IODefs.ReadDecimal[]];
IF ch = ’e THEN ClearScreen[];
IF ch = ’q THEN
BEGIN
MonitorControlBlock↑ ← NIL;
WaitAWhile[500];
ImageDefs.StopMesa[];
END;
END;
ENDLOOP;
END.