CDTechnologyImpl.mesa (part of Chipndale)
by Christian Jacobi August 11, 1983 11:32 am
last edited by Christian Jacobi November 21, 1983 8:36 pm
DIRECTORY
Atom,
CD,
CDTechnology,
CDValue,
CDVPrivate,
Convert,
Graphics USING [Color, black],
PrincOpsUtils,
Rope,
SafeStorage,
TerminalIO,
TIPUser;
CDTechnologyImpl:
CEDAR
MONITOR
IMPORTS Atom, CDValue, CDVPrivate, Convert, PrincOpsUtils, Rope, SafeStorage, TerminalIO, TIPUser
EXPORTS CDTechnology =
BEGIN
SetTipTable:
PUBLIC
ENTRY
PROC [tech:
CD.Technology, tipTable: Rope.
ROPE] =
BEGIN
ENABLE UNWIND => NULL;
tTable: TIPUser.TIPTable ← NIL;
tTable ← TIPUser.InstantiateNewTIPTable[tipTable !
TIPUser.InvalidTable => {
TerminalIO.WriteRope["Tiptable not installed; "];
TerminalIO.WriteRope[errorMsg];
TerminalIO.WriteLn[];
GOTO NotDone
}
];
CDValue.Store[boundTo: tech, key: $TipTable, value: tTable];
END;
GetTipTable:
PUBLIC
PROC [tech:
CD.Technology, allowDefault:
BOOL←
TRUE]
RETURNS [TIPUser.TIPTable] =
BEGIN
x: REF ← CDValue.Fetch[boundTo: tech, key: $TipTable, propagation: global];
IF x=
NIL
THEN {
SetTipTable[NIL, "ChipNDale.TIP"];
x ← CDValue.Fetch[boundTo: tech, key: $TipTable, propagation: global]
};
WITH x
SELECT
FROM
ttr: TIPUser.TIPTable => RETURN [ttr];
ENDCASE => RETURN [NIL];
END;
TeachGraphicsColor:
PUBLIC
PROC [lev:
CD.Level, color: Graphics.Color←Graphics.black] =
BEGIN
TerminalIO.WriteRope["not yet implemented"];
ERROR
END;
Brick: TYPE = CDTechnology.Brick;
TeachColor:
PUBLIC
PROC[lev:
CD.Level, bpp:
CARDINAL, brick: Brick] =
BEGIN
CDVPrivate.TeachColor[lev, bpp, brick];
END;
TeachGrey:
PUBLIC
PROC[lev:
CD.Level, bpp:
CARDINAL, brick: Brick] =
BEGIN
CDVPrivate.TeachGrey[lev, bpp, brick];
END;
TeachColorCode:
PUBLIC PROC[lev:
CD.Level, bpp:
CARDINAL, code:
CARDINAL] =
--sets value into the default Color- and GreyTable
BEGIN
CDVPrivate.TeachColorCode[lev, bpp, code];
END;
Brick4:
PUBLIC PROC[color:
CARDINAL, pattern:
CARDINAL]
RETURNS [b: Brick←
ALL[0]] =
BEGIN
Slice:
PROC [color:
CARDINAL, pattern:
CARDINAL]
RETURNS [c:
CARDINAL𡤀] = {
FOR i:
CARDINAL
IN [0..4)
DO
c ← c*16+(IF pattern>7 THEN color ELSE 0);
pattern ← (pattern MOD 8)*2
ENDLOOP
};
TRUSTED {color ← PrincOpsUtils.BITAND[color, 15]};
FOR i:
CARDINAL
IN [0..4)
DO
b[3-i] ← Slice[color, pattern MOD 16];
pattern ← pattern / 16
ENDLOOP
END;
Brick8:
PUBLIC PROC[color:
CARDINAL, pattern:
CARDINAL]
RETURNS [b: Brick←
ALL[0]] =
BEGIN
Slice:
PROC [color:
CARDINAL, pattern:
CARDINAL]
RETURNS [c:
CARDINAL𡤀] = {
IF pattern MOD 2 =1 THEN c𡤌+color;
IF (pattern/2) MOD 2 =1 THEN c𡤌+color*256
};
TRUSTED{color ← PrincOpsUtils.BITAND[color, 255]};
TRUSTED{pattern ← PrincOpsUtils.BITAND[pattern, 255]};
FOR i:
CARDINAL
IN [0..4)
DO
b[3-i] ← Slice[color, pattern MOD 4];
pattern ← pattern / 4
ENDLOOP
END;
OrBricks:
PUBLIC PROC[b1, b2: Brick]
RETURNS [b: Brick] =
BEGIN
FOR i:
CARDINAL
IN [0..4)
DO
TRUSTED{b[i] ← PrincOpsUtils.BITOR[b1[i], b2[i]]}
ENDLOOP
END;
widthAtomTable:
PUBLIC
--private!--
REF
ARRAY
CD.Level
OF
ATOM
← SafeStorage.GetPermanentZone[].NEW[ARRAY CD.Level OF ATOM];
CDValue.EnregisterKey[key: $TipTable, boundTo: NIL];
CDValue.EnregisterKey[key: $CurrentLevel, boundTo: NIL];
FOR l:
CD.Level
IN [0..
CD.levelNumber)
DO
widthAtomTable[l] ← Atom.MakeAtom[Rope.Concat["CDxLevelNo", Convert.RopeFromInt[l]]];
[] ← CDValue.EnregisterKey[widthAtomTable[l], NIL];
ENDLOOP;
END.