-- file: MFTFMImpl.mesa -- Pascal-to-Mesa translator output, translated at October 31, 1985 4:28:02 pm PST DIRECTORY PascalBasic, PascalWizardFiles, MFTypes, MFProcArray, MFInteraction, MFMath, MFMemory, MFSymbols, MFTFM; MFTFMImpl: PROGRAM IMPORTS PascalBasic, PascalWizardFiles, MFProcArray, MFInteraction, MFMath, MFMemory, MFSymbols EXPORTS MFTFM = PUBLIC BEGIN OPEN PascalBasic, PascalWizardFiles, MFTypes, MFProcArray, MFInteraction, MFMath, MFMemory, MFSymbols, MFTFM; --:1083----1086:-- TfmFile: ByteFile; MetricFileName: StrNumber; --:1086----1095:-- Bc: EightBits; Ec: EightBits; TfmWidth: LONG POINTER TO ARRAY EightBits OF Scaled ← PascalStaticZone.NEW[ARRAY EightBits OF Scaled]; TfmHeight: LONG POINTER TO ARRAY EightBits OF Scaled ← PascalStaticZone.NEW[ARRAY EightBits OF Scaled]; TfmDepth: LONG POINTER TO ARRAY EightBits OF Scaled ← PascalStaticZone.NEW[ARRAY EightBits OF Scaled]; TfmItalCorr: LONG POINTER TO ARRAY EightBits OF Scaled ← PascalStaticZone.NEW[ARRAY EightBits OF Scaled]; CharExists: LONG POINTER TO ARRAY EightBits OF PascalBoolean ← PascalStaticZone.NEW[ARRAY EightBits OF PascalBoolean]; CharTag: LONG POINTER TO ARRAY EightBits OF PascalInteger[0..3] ← PascalStaticZone.NEW[ARRAY EightBits OF PascalInteger[0..3]]; CharRemainder: LONG POINTER TO ARRAY EightBits OF EightBits ← PascalStaticZone.NEW[ARRAY EightBits OF EightBits]; HeaderByte: LONG POINTER TO ARRAY PascalInteger[1..100] OF PascalInteger[-1..255] ← PascalStaticZone.NEW[ARRAY PascalInteger[1..100] OF PascalInteger[-1..255]]; LigKern: LONG POINTER TO ARRAY PascalInteger[0..300] OF FourQuarters ← PascalStaticZone.NEW[ARRAY PascalInteger[0..300] OF FourQuarters]; Nl: PascalInteger[0..LigTableSize]; Kern: LONG POINTER TO ARRAY EightBits OF Scaled ← PascalStaticZone.NEW[ARRAY EightBits OF Scaled]; Nk: PascalInteger[0..256]; Exten: LONG POINTER TO ARRAY EightBits OF FourQuarters ← PascalStaticZone.NEW[ARRAY EightBits OF FourQuarters]; Ne: PascalInteger[0..256]; Param: LONG POINTER TO ARRAY PascalInteger[1..50] OF Scaled ← PascalStaticZone.NEW[ARRAY PascalInteger[1..50] OF Scaled]; Np: PascalInteger[0..MaxFontDimen]; Nw: PascalInteger[0..256]; Nh: PascalInteger[0..256]; Nd: PascalInteger[0..256]; Ni: PascalInteger[0..256]; --:1095----1118:-- Perturbation: Scaled; --:1118----1124: DimenHead: LONG POINTER TO ARRAY PascalInteger[1..4] OF Halfword ← PascalStaticZone.NEW[ARRAY PascalInteger[1..4] OF Halfword]; --:1124----1129:-- MaxTfmDimen: Scaled; TfmChanged: PascalInteger; SortIn: PROCEDURE[V: Scaled] RETURNS[SortInResult: Halfword] = BEGIN P, Q, R:Halfword; P←49999;{WHILE TRUE DO BEGIN Q←Mem[P]↑.Hh.Rh; IF V<=Mem[ INT[Q]+1]↑.Int THEN GOTO Label40;P←Q; END ENDLOOP ; EXITS Label40 => NULL};IF V<Mem[ INT[Q]+1]↑.Int THEN BEGIN R←GetNode[2];Mem[ INT[R]+1]↑.Int←V; Mem[R]↑.Hh.Rh←Q;Mem[P]↑.Hh.Rh←R; END;SortInResult←Mem[P]↑.Hh.Rh; END;--:1116 --1117:-- MinCover: PROCEDURE[D: Scaled] RETURNS[MinCoverResult: PascalInteger] = BEGIN P:Halfword;L:Scaled; M:PascalInteger; M←0;P←Mem[49999]↑.Hh.Rh;Perturbation←2147483647; WHILE P#19 DO BEGIN M←M+1;L←Mem[ INT[P]+1]↑.Int;DO P←Mem[P]↑.Hh.Rh; IF Mem[ INT[P]+1]↑.Int>L+D THEN EXIT; ENDLOOP; IF Mem[ INT[P]+1]↑.Int-L<Perturbation THEN Perturbation←Mem[ INT[P]+1]↑.Int-L; END ENDLOOP ; MinCoverResult←M; END;--:1117----1119:-- Threshold: PROCEDURE[M: PascalInteger] RETURNS[ThresholdResult: Scaled] = BEGIN D:Scaled; IF MinCover[0]<=M THEN ThresholdResult←0 ELSE BEGIN DO D← Perturbation; IF MinCover[D+D]<=M THEN EXIT; ENDLOOP; WHILE MinCover[D]>M DO D←Perturbation ENDLOOP ;ThresholdResult←D; END; END;--:1119 --1120:-- Skimp: PROCEDURE[M: PascalInteger] RETURNS[SkimpResult: PascalInteger] = BEGIN D:Scaled;P, Q, R:Halfword; L:Scaled;V:Scaled; D←Threshold[M];Perturbation←0;Q←49999;M←0; P←Mem[49999]↑.Hh.Rh;WHILE P#19 DO BEGIN M←M+1;L←Mem[ INT[P]+1]↑.Int; Mem[P]↑.Hh.Lh←M;IF Mem[ INT[Mem[P]↑.Hh.Rh]+1]↑.Int<=L+D THEN--1121: BEGIN DO P←Mem[P]↑.Hh.Rh;Mem[P]↑.Hh.Lh←M; IF Mem[ INT[Mem[P]↑.Hh.Rh]+1]↑.Int>L+D THEN EXIT; ENDLOOP;V← PascalDIVPower2[(L+Mem[ INT[P]+1]↑.Int),1]; IF Mem[ INT[P]+1]↑.Int-V>Perturbation THEN Perturbation←Mem[ INT[P]+1]↑.Int-V;R←Q; DO R←Mem[R]↑.Hh.Rh;Mem[ INT[R]+1]↑.Int←V; IF R=P THEN EXIT; ENDLOOP;Mem[Q]↑.Hh.Rh←P; END--:1121--;Q←P;P←Mem[P]↑.Hh.Rh; END ENDLOOP ;SkimpResult←M; END;--:1120----1122: TfmWarning: PROCEDURE[M: SmallNumber] = BEGIN PrintNl[898]; Print[IntName↑[M]];Print[899];PrintScaled[Perturbation];Print[900]; END; --:1122----1127:-- FixDesignSize: PROCEDURE = BEGIN D:Scaled; D←Internal↑[26]; IF(D<65536)OR (D>=134217728) THEN BEGIN IF D#0 THEN PrintNl[901]; D←8388608;Internal↑[26]←D; END; IF INT[HeaderByte↑[5]]<0 THEN IF INT[HeaderByte↑[6]]<0 THEN IF INT[HeaderByte↑[7]]<0 THEN IF INT[HeaderByte↑[8]]<0 THEN BEGIN HeaderByte↑[5]← PascalDIVPower2[D ,20]; HeaderByte↑[6]← PascalMODPower2Mask[( PascalDIVPower2[D ,12]),255];HeaderByte↑[7]← PascalMODPower2Mask[( PascalDIVPower2[D ,4]),255]; HeaderByte↑[8]←( PascalMODPower2Mask[D ,15])*16; END; MaxTfmDimen← 16*Internal↑[26]-PascalDIVPower2[Internal↑[26],21]; IF MaxTfmDimen>=134217728 THEN MaxTfmDimen←134217727; END;--:1127 --1128:-- DimenOut: PROCEDURE[X: Scaled] RETURNS[DimenOutResult: PascalInteger] = BEGIN IF ABS[X]>MaxTfmDimen THEN BEGIN TfmChanged←TfmChanged+1; IF X>0 THEN X←16777215 ELSE X←-16777215; END ELSE X←MakeScaled[X*16,Internal↑[26]];DimenOutResult←X; END;--:1128 --1130:-- FixCheckSum: PROCEDURE = BEGIN K:EightBits; B1, B2, B3, B4:EightBits;X:PascalInteger; {IF INT[HeaderByte↑[1]]<0 THEN IF INT[HeaderByte↑[2]]<0 THEN IF INT[HeaderByte↑[3 ]]<0 THEN IF INT[HeaderByte↑[4]]<0 THEN BEGIN--1131:--B1←Bc;B2←Ec;B3←Bc; B4←Ec;TfmChanged←0; FOR i:INT IN [ INT[Bc ].. INT[Ec ]] DO K ← i; IF CharExists↑[K] THEN BEGIN X←DimenOut[Mem[ TfmWidth↑[K]+1]↑.Int]+(K+4)*4194304;B1← (B1+B1+X)MOD 255; B2← (B2+B2+X)MOD 253;B3← (B3+B3+X)MOD 251;B4← (B4+B4+X)MOD 247; END--:1131-- ENDLOOP;HeaderByte↑[1]←B1;HeaderByte↑[2]←B2;HeaderByte↑[3]←B3; HeaderByte↑[4]←B4; GOTO Label10; END; FOR i:INT IN [ INT[1 ].. INT[4 ]] DO K ← i; IF INT[HeaderByte↑[K]]<0 THEN HeaderByte↑[K]←0 ENDLOOP;EXITS Label10 => NULL}; END; --:1130----1132:-- TfmTwo: PROCEDURE[X: PascalInteger] = BEGIN {grossExprHack:EightBits ← PascalDIVPower2[X ,8]; PascalWriteLong[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element, item: @grossExprHack]}; {grossExprHack:EightBits ← PascalMODPower2Mask[X ,255]; PascalWriteLong[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element, item: @grossExprHack]}; END; TfmFour: PROCEDURE[X: PascalInteger] = BEGIN IF X>=0 THEN {grossExprHack:EightBits ← PascalDIVPower2[X ,24]; PascalWriteLong[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element, item: @grossExprHack]} ELSE BEGIN X←X +1073741824;X←X+1073741824;{grossExprHack:EightBits ← ( PascalDIVPower2[X ,24])+128; PascalWriteLong[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element, item: @grossExprHack]}; END; X← PascalMODPower2Mask[X ,16777215]; {grossExprHack:EightBits ← PascalDIVPower2[X ,16]; PascalWriteLong[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element, item: @grossExprHack]};X← PascalMODPower2Mask[X ,65535]; {grossExprHack:EightBits ← PascalDIVPower2[X ,8]; PascalWriteLong[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element, item: @grossExprHack]}; {grossExprHack:EightBits ← PascalMODPower2Mask[X ,255]; PascalWriteLong[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element, item: @grossExprHack]}; END; TfmQqqq: PROCEDURE[X: FourQuarters] = BEGIN {grossExprHack:EightBits ← X.B0; PascalWriteLong[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element, item: @grossExprHack]}; {grossExprHack:EightBits ← X.B1; PascalWriteLong[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element, item: @grossExprHack]};{grossExprHack:EightBits ← X.B2; PascalWriteLong[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element, item: @grossExprHack]};{grossExprHack:EightBits ← X.B3; PascalWriteLong[file: @TfmFile.baseFile, length: SIZE[EightBits, 2], element: @TfmFile.element, item: @grossExprHack]}; END; END.