-- J.Sandman October 19, 1977 11:25 AM
DIRECTORY
ImageDefs: FROM "ImageDefs",
IODefs: FROM "IODefs",
SegmentDefs: FROM "SegmentDefs",
StringDefs: FROM "StringDefs",
SystemDefs: FROM "SystemDefs",
TeleSilDefs: FROM "TeleSilDefs",
TeleSilProcDefs: FROM "TeleSilProcDefs";

--------------------------------------------------------------------
TeleSilInit: PROGRAM
IMPORTS
IODefs, SegmentDefs, StringDefs, SystemDefs, TeleSilProcDefs
EXPORTS TeleSilProcDefs =
BEGIN
OPEN TeleSilDefs;

--------------------------------------------------------------------

CursorIcons: ARRAY CursorIcon OF CursorBitMap ←
[[177400B, 101000B, 102000B, 101000B, -- arrow
100400B, 120200B, 150100B, 104040B,
002020B, 001010B, 000404B, 000202B,
000101B, 000042B, 000024B, 000010B],
[177400B, 177000B, 176000B, 177000B, -- blackArrow
177400B, 177600B, 157700B, 107740B,
003760B, 001770B, 000774B, 000376B,
000177B, 000076B, 000034B, 000010B],
[177400B, 125000B, 152000B, 125000B, -- greyArrow
152400B, 125200B, 152500B, 105240B,
002520B, 001250B, 000524B, 000252B,
000125B, 000052B, 000024B, 000010B],
[177777B, 100001B, 100001B, 107741B, -- rebuild
107761B, 106061B, 106061B, 107761B,
107741B, 106141B, 106061B, 106061B,
106061B, 100001B, 100001B, 177777B],
[177777B, 100001B, 100001B, 103741B, -- input
103741B, 100601B, 100601B, 100601B,
100601B, 100601B, 100601B, 103741B,
103741B, 100001B, 100001B, 177777B]];

GetCursorIcons: PUBLIC PROCEDURE
RETURNS [DESCRIPTOR FOR ARRAY CursorIcon OF CursorBitMap] =
BEGIN
RETURN[DESCRIPTOR[CursorIcons]];
END;


GrayToneCode: ARRAY GrayTone OF GrayToneMap ←
[[000000B, 000000B, 000000B, 000000B], -- white
[010421B, 000000B, 000000B, 000000B], -- 0
[010421B, 042104B, 000000B, 000000B], -- 1
[010421B, 010421B, 042104B, 042104B], -- 2
[010421B, 021042B, 042104B, 104210B], -- 3
[104210B, 042104B, 021042B, 010421B], -- 4
[114631B, 114631B, 063146B, 063146B], -- 5
[052525B, 125252B, 052525B, 125252B], -- gray
[177777B, 177777B, 177777B, 177777B]]; -- black

GetGrayToneCode: PUBLIC PROCEDURE
RETURNS [DESCRIPTOR FOR ARRAY GrayTone OF GrayToneMap] =
BEGIN
RETURN[DESCRIPTOR[
GrayToneCode]];
END;

--------------------------------------------------------------------
-- Initialization of fonts
--------------------------------------------------------------------
fonts: ARRAY FontNumber OF FontDesc;

GetFonts: PUBLIC PROCEDURE
RETURNS [DESCRIPTOR FOR ARRAY FontNumber OF FontDesc] =
BEGIN
RETURN[DESCRIPTOR[fonts]];
END;

FontRequests: ARRAY FontNumber OF short ImageDefs.FileRequest ← [
[file: NIL, access: SegmentDefs.Read, link:,
body: short[fill:, name: "Helvetica10.al."]],
[file: NIL, access: SegmentDefs.Read, link:,
body: short[fill:, name: "Helvetica8.al."]],
[file: NIL, access: SegmentDefs.Read, link:,
body: short[fill:, name: "Helvetica12.al."]],
[file: NIL, access: SegmentDefs.Read, link:,
body: short[fill:, name: "Arrows10.al."]]];

DefaultFontRequest: short ImageDefs.FileRequest ← [
file: NIL, access: SegmentDefs.Read, link:,
body: short[fill:, name: "SysFont.al."]];

RequestFonts: PUBLIC PROCEDURE =
BEGIN
i: FontNumber;
FOR i IN FontNumber DO ImageDefs.AddFileRequest[@FontRequests[i]]; ENDLOOP;
ImageDefs.AddFileRequest[@DefaultFontRequest];
END;

InitFonts: PUBLIC PROCEDURE =
BEGIN OPEN SegmentDefs; --
NewFileSegment, DefaultBase, DefaultPages, Read
i: FontNumber;
FOR i IN FontNumber DO
IF FontRequests[i].file = NIL THEN
BEGIN
IF DefaultFontRequest.file = NIL THEN ERROR;
FontRequests[i].file ← DefaultFontRequest.file;
FontRequests[i].name ← DefaultFontRequest.name;
END;
fonts[i].fnt ← NIL;
fonts[i].name ← SystemDefs.AllocateHeapString[40];
StringDefs.AppendString[fonts[i].name,FontRequests[i].name];
fonts[i].fsh ←
NewFileSegment[FontRequests[i].file, DefaultBase, DefaultPages, Read];
ENDLOOP;
TeleSilProcDefs.LockFonts[DESCRIPTOR[fonts]]
END;

RequestFonts[];
START IODefs.StreamIO[NIL, NIL]; -- also starts keyboard process
STOP; -- wait for restart after looking up files

START TeleSilProcDefs.TeleSilResident;
InitFonts[];

START TeleSilProcDefs.TeleSilMain;
END.