-- PressFormat.mesa; edited by Johnsson, May 23, 1980  2:47 PM
-- Copyright Xerox Corporation 1979
-- Standard PRESS file definitions
-- William Newman 4-24-75
-- modified by Rick Tiberi October 10, 1977  5:23 PM
-- modified by Dan Swinehart May 9, 1978 (date, pages fields in DDV)
-- translated to Mesa by Richard Johnsson December 17, 1979

DIRECTORY
  Mopcodes USING [zEXCH];

PressFormat: DEFINITIONS =
  BEGIN
  
  PressPasswd: CARDINAL = 27183; -- Press password
  
  BYTE: TYPE = [0..377B];
  
  -- BCPL double precision
  
  Double: TYPE = MACHINE DEPENDENT RECORD [high, low: CARDINAL];
  
  LCToDouble: PROCEDURE [LONG CARDINAL] RETURNS [Double] = MACHINE CODE
    BEGIN Mopcodes.zEXCH END;
    
  DoubleToLC: PROCEDURE [Double] RETURNS [LONG CARDINAL] = MACHINE CODE
    BEGIN Mopcodes.zEXCH END;
    
  -- Measurements in Press files are in Micas. A mica is 10 microns
  -- (1/2540 inch). (Full page cooridinates fit in 16 bits.)
  -- There are 72 points to the inch.
  -- By convention, an Alto screen dot is 32 micas square.
  -- The lower left (portrait mode) corner is X=0, Y=0.
  -- Y goes up, X goes right.
  
  micasPerInch: CARDINAL = 2540;
  Mica: TYPE = INTEGER;
  
  -- DDV used to access PRddir - PR file document directory
  
  DDV: TYPE = MACHINE DEPENDENT RECORD [
    Passwd: CARDINAL, -- password=PressPassword
    nRecs: CARDINAL, -- total no of records in PR file
    nParts: CARDINAL, -- no of parts
    pdStart: CARDINAL, -- where part directory begins
    pdRecs: CARDINAL, -- no of records
    Backp: CARDINAL, -- back pointer
    date: Double, -- date of pressing
    fCopy: CARDINAL, -- first copy to print
    lCopy: CARDINAL, -- last copy to print
    fPage: CARDINAL, -- first page to print optional
    lPage: CARDINAL, -- last page to print optional
    spare3: ARRAY [0..116) OF CARDINAL, --To close out first 128 words
    FileStr: ARRAY [0..26) OF CARDINAL, --File name string
    CreatStr: ARRAY [0..16) OF CARDINAL, --Creator string
    DateStr: ARRAY [0..20) OF CARDINAL --Date string
    ];
  
  -- PE is used to read part entries
  
  PE: TYPE = MACHINE DEPENDENT RECORD [
    Type: PartType, --Various types
    pStart: CARDINAL, --Record number where begins
    pRecs: CARDINAL, -- number of Records in this part
    Padding: CARDINAL --Padding amounts
    ];
  
  PartType: TYPE = RECORD [CARDINAL];
  PETypeFont: PartType = [1];
  PETypePage: PartType = [0];
  
  -- FE used to read Font Directory entries
  
  FE: TYPE = MACHINE DEPENDENT RECORD [
    length: CARDINAL, -- length of entry
    set: BYTE,
    fno: BYTE,
    destm: BYTE, -- first char code
    destn: BYTE, -- last
    fam: PACKED ARRAY [0..20) OF BYTE, -- name string
    face: BYTE,
    source: BYTE, -- first char
    siz: CARDINAL, -- points
    rotn: CARDINAL];
  
  -- EH used to access Entity Header (now called Trailer)
  
  EH: TYPE = MACHINE DEPENDENT RECORD [
    Type: EntityType, -- entity type
    Fontset: BYTE, -- font set
    Dstart: Double, -- byte address of data
    Dlength: Double, -- byte length of data
    Xe: Mica, -- origin x
    Ye: Mica, -- y
    Xleft: Mica, -- lh corner
    Ybottom: Mica,
    Width: Mica,
    Height: Mica,
    Length: CARDINAL -- length in words of entity
    ];
  
  EntityType: TYPE = BYTE;
  
  -- Entity (EL) command defs
  
  EShowShort: EntityType = 0B;
  ESkipShort: EntityType = 40B;
  EShowSkip: EntityType = 100B;
  ESpaceXShort: EntityType = 140B;
  ESpaceYShort: EntityType = 150B;
  EFont: EntityType = 160B;
  
  EShortMax: EntityType = 177B; --Max code with short encoding
  
  ESkipControlImmediate: EntityType = 353B;
  EAlternative: EntityType = 354B;
  EOnlyOnCopy: EntityType = 355B;
  ESetX: EntityType = 356B;
  ESetY: EntityType = 357B;
  EShow: EntityType = 360B;
  ESkip: EntityType = 361B;
  ESkipControl: EntityType = 362B;
  EShowImmediate: EntityType = 363B;
  ESpaceX: EntityType = 364B;
  ESpaceY: EntityType = 365B;
  EResetSpace: EntityType = 366B;
  ESpace: EntityType = 367B;
  ESetBright: EntityType = 370B;
  ESetHue: EntityType = 371B;
  ESetSat: EntityType = 372B;
  EShowObject: EntityType = 373B;
  EShowDots: EntityType = 374B;
  EShowDotsOpaque: EntityType = 375B;
  EShowRectangle: EntityType = 376B;
  ENop: EntityType = 377B;
  
  --DL command definitions
  
  DDotCode: CARDINAL = 400; --Dots operators
  
  DDotWindow: CARDINAL = 1;
  DDotMode: CARDINAL = 1000;
  DDotSize: CARDINAL = 2;
  DDotsFollow: CARDINAL = 3;
  DDotsFromFile: CARDINAL = 4;
  DDotsFromPressFile: CARDINAL = 5;
  DSampleProps: CARDINAL = 6;
  SSPInputIntensity: CARDINAL = 0;
  SSPOutputIntensity: CARDINAL = 1;
  SSPScreen: CARDINAL = 2;
  
  DMoveTo: CARDINAL = 0; --Graphics operators
  
  DDrawTo: CARDINAL = 1;
  DDrawCurve: CARDINAL = 2;
  
  END...