-- file: PLtoTFMain.mesa
-- Pascal-to-Mesa translator output, translated at October 23, 1985 11:00:04 am PDT


DIRECTORY
  PascalBasic,
  PascalWizardFiles,
  PLtoTFPrivate,
  PLtoTFExternals;

PLtoTFMain: PROGRAM IMPORTS PascalBasic, PascalWizardFiles, PLtoTFPrivate, PLtoTFExternals EXPORTS  = PUBLIC
BEGIN OPEN PascalBasic, PascalWizardFiles, PLtoTFPrivate, PLtoTFExternals;
 --2:-- --135:-- PLtoTFRun: UnsafeCommandProc = BEGIN 
--123:-- --125:-- 
--127:-- 
--130:-- --132:
 TtyRewrite[@Output];Initialize[];NameEnter[];ReadInput[];
{PascalWriteLongString[file: @Output, item: "."]; PascalWriteLn[file: @Output]};CorrAndCheck[];--120:----122:--Lh← PascalDIVPower2[HeaderPtr ,2];
NotFound←TRUE;Bc←0;
WHILE NotFound DO IF( INT[CharWd↑[Bc]]>0)OR (Bc=255) THEN NotFound←FALSE  ELSE
Bc←Bc+1 ENDLOOP ;NotFound←TRUE;Ec←255;
WHILE NotFound DO IF( INT[CharWd↑[Ec]]>0)OR (Ec=0) THEN NotFound←FALSE  ELSE
Ec←Ec-1 ENDLOOP ;IF  INT[Bc]>Ec  THEN Bc←1;Memory↑[1]←Memory↑[1]+1;
Memory↑[2]←Memory↑[2]+1;Memory↑[3]←Memory↑[3]+1;Memory↑[4]←Memory↑[4]+1;
Lf←6+Lh+(Ec-Bc+1)+Memory↑[1]+Memory↑[2]+Memory↑[3]+Memory↑[4]+Nl+Nk+Ne+Np;
--:122--WriteByte[@TfmFile, PascalDIVPower2[(Lf),8]];
WriteByte[@TfmFile, PascalMODPower2Mask[(Lf),255]];WriteByte[@TfmFile, PascalDIVPower2[(Lh),8]];
WriteByte[@TfmFile, PascalMODPower2Mask[(Lh),255]];WriteByte[@TfmFile, PascalDIVPower2[(Bc),8]];
WriteByte[@TfmFile, PascalMODPower2Mask[(Bc),255]];WriteByte[@TfmFile, PascalDIVPower2[(Ec),8]];
WriteByte[@TfmFile, PascalMODPower2Mask[(Ec),255]];
WriteByte[@TfmFile, PascalDIVPower2[(Memory↑[1]),8]];
WriteByte[@TfmFile, PascalMODPower2Mask[(Memory↑[1]),255]];
WriteByte[@TfmFile, PascalDIVPower2[(Memory↑[2]),8]];
WriteByte[@TfmFile, PascalMODPower2Mask[(Memory↑[2]),255]];
WriteByte[@TfmFile, PascalDIVPower2[(Memory↑[3]),8]];
WriteByte[@TfmFile, PascalMODPower2Mask[(Memory↑[3]),255]];
WriteByte[@TfmFile, PascalDIVPower2[(Memory↑[4]),8]];
WriteByte[@TfmFile, PascalMODPower2Mask[(Memory↑[4]),255]];
WriteByte[@TfmFile, PascalDIVPower2[(Nl),8]];WriteByte[@TfmFile, PascalMODPower2Mask[(Nl),255]];
WriteByte[@TfmFile, PascalDIVPower2[(Nk),8]];WriteByte[@TfmFile, PascalMODPower2Mask[(Nk),255]];
WriteByte[@TfmFile, PascalDIVPower2[(Ne),8]];WriteByte[@TfmFile, PascalMODPower2Mask[(Ne),255]];
WriteByte[@TfmFile, PascalDIVPower2[(Np),8]];WriteByte[@TfmFile, PascalMODPower2Mask[(Np),255]];--:123
IF  NOT CheckSumSpecified  THEN--126:--BEGIN CurBytes.B0←Bc;
CurBytes.B1←Ec;CurBytes.B2←Bc;CurBytes.B3←Ec;
FOR i:INT    IN [ INT[Bc ].. INT[Ec ]] DO  C ← i; IF  INT[CharWd↑[C]]>0  THEN BEGIN TempWidth←Memory↑[CharWd
↑[C]];
IF DesignUnits#1048576  THEN TempWidth←PascalTRUNC[(PascalFLOAT[TempWidth]/PascalFLOAT[DesignUnits
])*1048576.0];TempWidth←TempWidth+(C+4)*4194304;
CurBytes.B0← (CurBytes.B0+CurBytes.B0+TempWidth)MOD 255;
CurBytes.B1← (CurBytes.B1+CurBytes.B1+TempWidth)MOD 253;
CurBytes.B2← (CurBytes.B2+CurBytes.B2+TempWidth)MOD 251;
CurBytes.B3← (CurBytes.B3+CurBytes.B3+TempWidth)MOD 247; END ENDLOOP;
HeaderBytes↑[0]←CurBytes.B0;HeaderBytes↑[1]←CurBytes.B1;
HeaderBytes↑[2]←CurBytes.B2;HeaderBytes↑[3]←CurBytes.B3; END--:126--;
HeaderBytes↑[4]← PascalDIVPower2[DesignSize ,24];
HeaderBytes↑[5]← PascalMODPower2Mask[( PascalDIVPower2[DesignSize ,16]),255];
HeaderBytes↑[6]← PascalMODPower2Mask[( PascalDIVPower2[DesignSize ,8]),255];
HeaderBytes↑[7]← PascalMODPower2Mask[DesignSize ,255];
IF  NOT SevenUnsafe  THEN HeaderBytes↑[68]←128;
FOR i:INT    IN [ INT[0 ].. INT[HeaderPtr-1 ]] DO  J ← i; WriteByte[@TfmFile,HeaderBytes↑[J]] ENDLOOP;--:125--Index↑[0]←0;
FOR i:INT    IN [ INT[Bc ].. INT[Ec ]] DO  C ← i;  WriteByte[@TfmFile,Index↑[CharWd↑[C]]];
WriteByte[@TfmFile,Index↑[CharHt↑[C]]*16+Index↑[CharDp↑[C]]];
WriteByte[@TfmFile,Index↑[CharIc↑[C]]*4+CharTag↑[C]];
WriteByte[@TfmFile,CharRemainder↑[C]];--:127-- ENDLOOP;--129:
FOR i:INT    IN [ INT[1 ].. INT[4 ]] DO  Q ← i;  WriteByte[@TfmFile,0];WriteByte[@TfmFile,0];
WriteByte[@TfmFile,0];WriteByte[@TfmFile,0];P←Link↑[Q];
WHILE  INT[P]>0 DO BEGIN OutScaled[Memory↑[P]];P←Link↑[P]; END ENDLOOP ; ENDLOOP;--:129--IF  INT[Nl]>0  THEN FOR i:INT    IN [ INT[0 ].. INT[Nl-1 ]] DO  LigPtr ← i;  WriteByte[@TfmFile,
LigKern↑[LigPtr].B0];WriteByte[@TfmFile,LigKern↑[LigPtr].B1];
WriteByte[@TfmFile,LigKern↑[LigPtr].B2];
WriteByte[@TfmFile,LigKern↑[LigPtr].B3]; ENDLOOP;
IF  INT[Nk]>0  THEN FOR i:INT    IN [ INT[0 ].. INT[Nk-1 ]] DO  KrnPtr ← i; OutScaled[Kern↑[KrnPtr]]--:130-- ENDLOOP;
--131:
IF  INT[Ne]>0  THEN FOR i:INT    IN [ INT[0 ].. INT[Ne-1 ]] DO  C ← i;  WriteByte[@TfmFile,Exten↑[C].B0];
WriteByte[@TfmFile,Exten↑[C].B1];WriteByte[@TfmFile,Exten↑[C].B2];
WriteByte[@TfmFile,Exten↑[C].B3]; ENDLOOP;--:131--FOR i:INT    IN [ INT[1 ].. INT[Np ]] DO  ParPtr ← i;  IF ParPtr=1  THEN--133:
BEGIN IF Param↑[1]<0  THEN BEGIN Param↑[1]←Param↑[1]+1073741824;
WriteByte[@TfmFile,( PascalDIVPower2[Param↑[1],24])+192];
 END  ELSE WriteByte[@TfmFile, PascalDIVPower2[Param↑[1],24]];
WriteByte[@TfmFile, PascalMODPower2Mask[( PascalDIVPower2[Param↑[1],16]),255]];
WriteByte[@TfmFile, PascalMODPower2Mask[( PascalDIVPower2[Param↑[1],8]),255]];
WriteByte[@TfmFile, PascalMODPower2Mask[Param↑[1],255]]; END--:133
 ELSE OutScaled[Param↑[ParPtr]];--:132----:120-- ENDLOOP;FileClose[@PlFile];
ByteFileClose[@TfmFile];--:135
 END;

PascalRegister["PLtoTF", PLtoTFRun];

END.