-- PackPilotEnviron.mesa
-- Defines PackEnviron for Pilot
-- Last edited by Lewis on 21-Jan-81 16:10:33

DIRECTORY
  BcdDefs USING [BCD, PackedString],
  Environment USING [Byte, charsPerWord, wordsPerPage],
  Inline USING [LongCOPY],
  Segments USING [DefaultANYBase, PageCount, PageNumber],
  Stream USING [PutByteProcedure],
  SymbolSegment USING [STHeader];

PackEnviron: DEFINITIONS
    IMPORTS Inline, Segments =
  BEGIN

 -- Types
 
  Byte: TYPE = Environment.Byte;

  StreamPosition: TYPE = LONG CARDINAL;
  PutByteProcedure: TYPE = Stream.PutByteProcedure;

  BcdStringHandle: TYPE = LONG POINTER TO BcdDefs.PackedString;
  BcdHandle: TYPE = LONG POINTER TO BcdDefs.BCD;
  SymSegHandle: TYPE = LONG POINTER TO SymbolSegment.STHeader;


 -- Useful constants

  PageSize: CARDINAL = Environment.wordsPerPage; 
  CharsPerWord: CARDINAL = Environment.charsPerWord;
  CharsPerPage: CARDINAL = PageSize * CharsPerWord;
  BytesPerPage: CARDINAL = CharsPerPage;


 -- Segment bases

  SourceBcdSegmentBase: Segments.PageNumber = Segments.DefaultANYBase;
  SymbolSegmentBase: Segments.PageNumber = Segments.DefaultANYBase;


 -- Table storage size

  TablePages: Segments.PageCount = 170;


 -- Procedures

  Copy: PROC [from: LONG POINTER, nwords: CARDINAL, to: LONG POINTER] =
    Inline.LongCOPY;

  Zero: PROC [p: LONG POINTER, l: CARDINAL] = INLINE
    BEGIN
    IF l # 0 THEN
      {p↑ ← 0;  Inline.LongCOPY[from: p, to: (p+1), nwords: (l-1)]};
    END;

  SetBlock: PROC [p: LONG POINTER, v: UNSPECIFIED, n: UNSPECIFIED] = INLINE
    BEGIN
    IF n # 0 THEN
      {p↑ ← v;  Inline.LongCOPY[from: p, to: (p+1), nwords: (n-1)]};
    END;

  END.