-- file: TexScan4Impl.mesa
-- Pascal-to-Mesa translator output, translated at September 27, 1985 10:21:37 am PDT


DIRECTORY
  PascalBasic,
  PascalWizardFiles,
  TexSysdep,
  TexTypes,
  TexInteraction,
  TexMemory,
  TexSymbols,
  TexScan,
  TexOps,
  TexRest;

TexScan4Impl: PROGRAM IMPORTS PascalBasic, PascalWizardFiles, TexSysdep, TexTypes, TexInteraction, TexSymbols, TexScan, TexOps EXPORTS TexScan = PUBLIC
BEGIN OPEN PascalBasic, PascalWizardFiles, TexSysdep, TexTypes, TexInteraction, TexMemory, TexSymbols, TexScan, TexOps, TexRest;
--560:-- ReadFontInfo: PROCEDURE[U: Halfword,Nom,Aire: StrNumber,
S: Scaled] RETURNS[ReadFontInfoResult: InternalFontNumber] = 
BEGIN  K:PascalInteger[0..FontMemSize];
FileOpened:PascalBoolean;Lf, Lh, Bc, Ec, Nw, Nh, Nd, Ni, Nl, Nk, Ne, Np:Halfword;
I, FamLen:Halfword;F:InternalFontNumber;G:InternalFontNumber;
A, B, C, D:EightBits;Qw:FourQuarters;Sw:Scaled;Z:Scaled;Alpha:PascalInteger;
Beta:PascalInteger[1..16]; ReadTheTfmHeader: PROCEDURE--568:
 = 
BEGIN IF  INT[Lh]<18  THEN  ERROR Error11;BEGIN PascalGET[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element];A←TfmFile.element;Qw.B0←A;
PascalGET[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element];B←TfmFile.element;Qw.B1←B;PascalGET[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element];C←TfmFile.element;Qw.B2←C;
PascalGET[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element];D←TfmFile.element;Qw.B3←D;FontCheck↑[F]←Qw; END;PascalGET[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element];
BEGIN Z←TfmFile.element;IF Z>127  THEN  ERROR Error11;PascalGET[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element];
Z←Z*256+TfmFile.element; END;PascalGET[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element];Z←Z*256+TfmFile.element;PascalGET[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element];
Z←(Z*16)+( PascalDIVPower2[TfmFile.element,4]);IF Z<65536  THEN  ERROR Error11;
FOR i:INT    IN [ INT[1 ].. INT[10 ]] DO  I ← i;  PascalGET[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element];PascalGET[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element];PascalGET[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element];
PascalGET[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element]; ENDLOOP;PascalGET[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element];FamLen←TfmFile.element;
BEGIN IF  INT[PoolPtr]+FamLen>PoolSize  THEN Overflow[129,
PoolSize-InitPoolPtr]; END;FOR i:INT    IN [ INT[1 ].. INT[FamLen ]] DO  I ← i;  PascalGET[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element];
BEGIN StrPool↑[PoolPtr]←TfmFile.element;PoolPtr←PoolPtr+1; END ; ENDLOOP;
FOR i:INT    IN [ INT[FamLen+1 ].. INT[19 ]] DO  I ← i; PascalGET[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element] ENDLOOP;FontFamily↑[F]←MakeString[];
PascalGET[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element];PascalGET[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element];PascalGET[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element];PascalGET[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element];
FontFace↑[F]←TfmFile.element;WHILE  INT[Lh]>18 DO BEGIN PascalGET[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element];
PascalGET[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element];PascalGET[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element];PascalGET[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element];Lh← INT[Lh]-1; END ENDLOOP ;FontDsize↑[F]←Z;
IF S#-1000  THEN IF S>=0  THEN Z←S  ELSE Z←XnOverD[Z,-S,1000];
FontSize↑[F]←Z;--:568-- END;Error11: ERROR = CODE;
 {{ENABLE Error11 => GOTO Label11;G←0;--562:----563:--FileOpened←FALSE;
IF Aire=210  THEN PackFileName[Nom,TexFontArea,668] ELSE
PackFileName[Nom,Aire,668];IF  NOT BOpenIn[@TfmFile] THEN  GOTO Label11;
FileOpened←TRUE--:563--;--565:--BEGIN BEGIN Lf←TfmFile.element;
IF  INT[Lf]>127  THEN  GOTO Label11;PascalGET[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element];Lf← INT[Lf]*256+TfmFile.element; END;
PascalGET[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element];BEGIN Lh←TfmFile.element;IF  INT[Lh]>127  THEN  GOTO Label11;PascalGET[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element];
Lh← INT[Lh]*256+TfmFile.element; END;PascalGET[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element];BEGIN Bc←TfmFile.element;
IF  INT[Bc]>127  THEN  GOTO Label11;PascalGET[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element];Bc← INT[Bc]*256+TfmFile.element; END;
PascalGET[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element];BEGIN Ec←TfmFile.element;IF  INT[Ec]>127  THEN  GOTO Label11;PascalGET[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element];
Ec← INT[Ec]*256+TfmFile.element; END;IF( INT[Bc]>Ec+1)OR ( INT[Ec]>255) THEN  GOTO Label11;
PascalGET[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element];BEGIN Nw←TfmFile.element;IF  INT[Nw]>127  THEN  GOTO Label11;PascalGET[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element];
Nw← INT[Nw]*256+TfmFile.element; END;PascalGET[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element];BEGIN Nh←TfmFile.element;
IF  INT[Nh]>127  THEN  GOTO Label11;PascalGET[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element];Nh← INT[Nh]*256+TfmFile.element; END;
PascalGET[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element];BEGIN Nd←TfmFile.element;IF  INT[Nd]>127  THEN  GOTO Label11;PascalGET[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element];
Nd← INT[Nd]*256+TfmFile.element; END;PascalGET[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element];BEGIN Ni←TfmFile.element;
IF  INT[Ni]>127  THEN  GOTO Label11;PascalGET[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element];Ni← INT[Ni]*256+TfmFile.element; END;
PascalGET[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element];BEGIN Nl←TfmFile.element;IF  INT[Nl]>127  THEN  GOTO Label11;PascalGET[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element];
Nl← INT[Nl]*256+TfmFile.element; END;PascalGET[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element];BEGIN Nk←TfmFile.element;
IF  INT[Nk]>127  THEN  GOTO Label11;PascalGET[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element];Nk← INT[Nk]*256+TfmFile.element; END;
PascalGET[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element];BEGIN Ne←TfmFile.element;IF  INT[Ne]>127  THEN  GOTO Label11;PascalGET[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element];
Ne← INT[Ne]*256+TfmFile.element; END;PascalGET[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element];BEGIN Np←TfmFile.element;
IF  INT[Np]>127  THEN  GOTO Label11;PascalGET[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element];Np← INT[Np]*256+TfmFile.element; END;
IF Lf#6+Lh+( INT[Ec]-Bc+1)+Nw+Nh+Nd+Ni+Nl+Nk+Ne+Np  THEN  GOTO Label11; END--:565--;
--566:--Lf← INT[Lf]-6-Lh;IF  INT[Np]<7  THEN Lf← INT[Lf+7]-Np;
IF(FontPtr=FontMax)OR ( INT[FmemPtr]+Lf>FontMemSize) THEN--567:
BEGIN BEGIN IF Interaction=3  THEN NULL;PrintNl[134];Print[659]; END;
SprintCs[U];PrintChar[61];PrintFileName[Nom,Aire,210];
IF S>=0  THEN BEGIN Print[601];PrintScaled[S];Print[265];
 END  ELSE IF S#-1000  THEN BEGIN Print[660];PrintInt[-S]; END;Print[669];
BEGIN HelpPtr←4;HelpLine↑[3]←670;HelpLine↑[2]←671;HelpLine↑[1]←672;
HelpLine↑[0]←673; END;Error[]; GOTO Label30; END--:567--;F←FontPtr+1;
CharBase↑[F]← INT[FmemPtr]-Bc;WidthBase↑[F]←CharBase↑[F]+Ec+1;
HeightBase↑[F]←WidthBase↑[F]+Nw;DepthBase↑[F]←HeightBase↑[F]+Nh;
ItalicBase↑[F]←DepthBase↑[F]+Nd;LigKernBase↑[F]←ItalicBase↑[F]+Ni;
KernBase↑[F]←LigKernBase↑[F]+Nl;ExtenBase↑[F]←KernBase↑[F]+Nk;
ParamBase↑[F]←ExtenBase↑[F]+Ne--:566--;ReadTheTfmHeader[];--569:
FOR i:INT    IN [ INT[FmemPtr ].. INT[WidthBase↑[F]-1 ]] DO  K ← i;  BEGIN PascalGET[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element];
A←TfmFile.element;Qw.B0←A;PascalGET[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element];B←TfmFile.element;Qw.B1←B;PascalGET[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element];
C←TfmFile.element;Qw.B2←C;PascalGET[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element];D←TfmFile.element;Qw.B3←D;
FontInfo↑[K].Qqqq←Qw; END;
IF( INT[A]>=Nw)OR ( PascalDIVPower2[B ,4]>=Nh)OR ( PascalMODPower2Mask[B ,15]>=Nd)OR ( PascalDIVPower2[C ,2]>=Ni) THEN  GOTO Label11;
SELECT  PascalMODPower2Mask[C ,3]FROM 1 =>IF  INT[D]>=Nl  THEN  GOTO Label11;3 =>IF  INT[D]>=Ne  THEN  GOTO Label11;2 =>--570:
BEGIN BEGIN IF( INT[D]<Bc)OR ( INT[D]>Ec) THEN  GOTO Label11 ; END;
{WHILE D< INT[K]+Bc-FmemPtr DO BEGIN Qw←FontInfo↑[CharBase↑[F]+D].Qqqq;
IF( PascalMODPower2Mask[(Qw.B2),3])#2  THEN  GOTO Label45;D←Qw.B3; END ENDLOOP ;
IF D= INT[K]+Bc-FmemPtr  THEN  GOTO Label11;EXITS Label45 => NULL}; END--:570--; ENDCASE => NULL;--:569-- ENDLOOP;--571:
BEGIN--572:--BEGIN Alpha←16*Z;Beta←16;
WHILE Z>=8388608 DO BEGIN Z← PascalDIVPower2[Z ,1];Beta← PascalDIVPower2[Beta ,1]; END ENDLOOP ; END--:572--;
FOR i:INT    IN [ INT[WidthBase↑[F]].. INT[LigKernBase↑[F]-1 ]] DO  K ← i;  PascalGET[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element];
A←TfmFile.element;PascalGET[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element];B←TfmFile.element;PascalGET[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element];C←TfmFile.element;
PascalGET[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element];D←TfmFile.element;
Sw← (( PascalDIVPower2[(( PascalDIVPower2[(D*Z),8])+(C*Z)),8])+(B*Z))/Beta;
IF A=0  THEN FontInfo↑[K].Int←Sw  ELSE IF A=255  THEN FontInfo↑[K].Int←Sw
-Alpha  ELSE  GOTO Label11; ENDLOOP;IF FontInfo↑[WidthBase↑[F]].Int#0  THEN  GOTO Label11;
IF FontInfo↑[HeightBase↑[F]].Int#0  THEN  GOTO Label11;
IF FontInfo↑[DepthBase↑[F]].Int#0  THEN  GOTO Label11;
IF FontInfo↑[ItalicBase↑[F]].Int#0  THEN  GOTO Label11; END--:571--;--573:
BEGIN FOR i:INT    IN [ INT[LigKernBase↑[F]].. INT[KernBase↑[F]-1 ]] DO  K ← i;  BEGIN 
PascalGET[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element];A←TfmFile.element;Qw.B0←A;PascalGET[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element];B←TfmFile.element;Qw.B1←B;
PascalGET[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element];C←TfmFile.element;Qw.B2←C;PascalGET[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element];D←TfmFile.element;Qw.B3←D;
FontInfo↑[K].Qqqq←Qw; END;BEGIN IF( INT[B]<Bc)OR ( INT[B]>Ec) THEN  GOTO Label11 ; END;
IF  INT[C]<128  THEN BEGIN IF( INT[D]<Bc)OR ( INT[D]>Ec) THEN  GOTO Label11 ; END  ELSE IF  INT[D]>=Nk  THEN
 GOTO Label11; ENDLOOP;IF( INT[Nl]>0)AND ( INT[A]<128) THEN  GOTO Label11;
FOR i:INT    IN [ INT[KernBase↑[F]].. INT[ExtenBase↑[F]-1 ]] DO  K ← i;  PascalGET[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element];
A←TfmFile.element;PascalGET[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element];B←TfmFile.element;PascalGET[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element];C←TfmFile.element;
PascalGET[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element];D←TfmFile.element;
Sw← (( PascalDIVPower2[(( PascalDIVPower2[(D*Z),8])+(C*Z)),8])+(B*Z))/Beta;
IF A=0  THEN FontInfo↑[K].Int←Sw  ELSE IF A=255  THEN FontInfo↑[K].Int←Sw
-Alpha  ELSE  GOTO Label11; ENDLOOP; END--:573--;--574:
FOR i:INT    IN [ INT[ExtenBase↑[F]].. INT[ParamBase↑[F]-1 ]] DO  K ← i;  BEGIN PascalGET[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element];
A←TfmFile.element;Qw.B0←A;PascalGET[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element];B←TfmFile.element;Qw.B1←B;PascalGET[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element];
C←TfmFile.element;Qw.B2←C;PascalGET[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element];D←TfmFile.element;Qw.B3←D;
FontInfo↑[K].Qqqq←Qw; END;
IF A#0  THEN BEGIN IF( INT[A]<Bc)OR ( INT[A]>Ec) THEN  GOTO Label11 ; END;
IF B#0  THEN BEGIN IF( INT[B]<Bc)OR ( INT[B]>Ec) THEN  GOTO Label11 ; END;
IF C#0  THEN BEGIN IF( INT[C]<Bc)OR ( INT[C]>Ec) THEN  GOTO Label11 ; END;
BEGIN IF( INT[D]<Bc)OR ( INT[D]>Ec) THEN  GOTO Label11 ; END;--:574-- ENDLOOP;--575:
BEGIN FOR i:INT    IN [ INT[1 ].. INT[Np ]] DO  K ← i; IF K=1  THEN BEGIN PascalGET[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element];Sw←TfmFile.element;
IF Sw>127  THEN Sw←Sw-256;PascalGET[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element];Sw←Sw*256+TfmFile.element;
PascalGET[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element];Sw←Sw*256+TfmFile.element;PascalGET[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element];
FontInfo↑[ParamBase↑[F]].Int←(Sw*16)+( PascalDIVPower2[TfmFile.element,4]);
 END  ELSE BEGIN PascalGET[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element];A←TfmFile.element;PascalGET[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element];B←TfmFile.element;
PascalGET[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element];C←TfmFile.element;PascalGET[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element];D←TfmFile.element;
Sw← (( PascalDIVPower2[(( PascalDIVPower2[(D*Z),8])+(C*Z)),8])+(B*Z))/Beta;
IF A=0  THEN FontInfo↑[ParamBase↑[F]+K-1].Int←Sw  ELSE IF A=255  THEN
FontInfo↑[ParamBase↑[F]+K-1].Int←Sw-Alpha  ELSE  GOTO Label11; END ENDLOOP;
IF PascalEOF[file: @TfmFile.baseFile] THEN  GOTO Label11;
FOR i:INT    IN [ INT[Np+1 ].. INT[7 ]] DO  K ← i; FontInfo↑[ParamBase↑[F]+K-1].Int←0 ENDLOOP; END--:575--;--576:
IF  INT[Np]>=7  THEN FontParams↑[F]←Np  ELSE FontParams↑[F]←7;
HyphenChar↑[F]←Eqtb↑[4813].Int;SkewChar↑[F]←Eqtb↑[4814].Int;
FontName↑[F]←Nom;FontArea↑[F]←Aire;FontBc↑[F]←Bc;FontEc↑[F]←Ec;
FontGlue↑[F]←0;CharBase↑[F]←CharBase↑[F];WidthBase↑[F]←WidthBase↑[F];
LigKernBase↑[F]←LigKernBase↑[F];KernBase↑[F]←KernBase↑[F];
ExtenBase↑[F]←ExtenBase↑[F];ParamBase↑[F]←ParamBase↑[F]-1;
FmemPtr← INT[FmemPtr]+Lf;FontPtr←F;G←F; GOTO Label30--:576----:562--;EXITS Label11 => NULL};--561:
BEGIN IF Interaction=3  THEN NULL;PrintNl[134];Print[659]; END;SprintCs[U];
PrintChar[61];PrintFileName[Nom,Aire,210];
IF S>=0  THEN BEGIN Print[601];PrintScaled[S];Print[265];
 END  ELSE IF S#-1000  THEN BEGIN Print[660];PrintInt[-S]; END;
IF FileOpened  THEN Print[661] ELSE Print[662];BEGIN HelpPtr←5;
HelpLine↑[4]←663;HelpLine↑[3]←664;HelpLine↑[2]←665;HelpLine↑[1]←666;
HelpLine↑[0]←667; END;Error--:561--[];EXITS Label30 => NULL};BClose[@TfmFile];
ReadFontInfoResult←G; END;--:560----581:

END.