-- file: MFGFImpl.mesa
-- Pascal-to-Mesa translator output, translated at October 31, 1985 4:28:02 pm PST


DIRECTORY
  PascalBasic,
  PascalWizardFiles,
  MFTypes,
  MFExternals,
  MFInteraction,
  MFMath,
  MFSymbols,
  MFFileNames,
  MFGF,
  MFOps;

MFGFImpl: PROGRAM IMPORTS PascalBasic, PascalWizardFiles, MFExternals, MFInteraction, MFMath, MFSymbols, MFFileNames, MFOps EXPORTS MFGF = PUBLIC
BEGIN OPEN PascalBasic, PascalWizardFiles, MFTypes, MFExternals, MFInteraction, MFMath, MFSymbols, MFFileNames, MFGF, MFOps;
--:781----784:--
GfExt: StrNumber;
--:1129----1148:

GfMinM: PascalInteger;

GfMaxM: PascalInteger;

GfMinN: PascalInteger;

GfMaxN: PascalInteger;

GfPrevPtr: PascalInteger;


TotalChars: PascalInteger;
CharPtr: LONG POINTER TO ARRAY EightBits OF PascalInteger ← PascalStaticZone.NEW[ARRAY EightBits OF PascalInteger];

GfDx: LONG POINTER TO ARRAY EightBits OF PascalInteger ← PascalStaticZone.NEW[ARRAY EightBits OF PascalInteger];
GfDy: LONG POINTER TO ARRAY EightBits OF PascalInteger ← PascalStaticZone.NEW[ARRAY EightBits OF PascalInteger];
--:1148----1151:
GfBuf: LONG POINTER TO ARRAY GfIndex OF EightBits ← PascalStaticZone.NEW[ARRAY GfIndex OF EightBits];

HalfBuf: GfIndex;

GfLimit: GfIndex;


GfPtr: GfIndex;

GfOffset: PascalInteger;
 WriteGf: PROCEDURE[A,B: GfIndex]
 = 
BEGIN K:GfIndex; FOR i:INT    IN [ INT[A ].. INT[B ]] DO  K ← i; {grossExprHack:EightBits ← GfBuf↑[K]; PascalWriteLong[file: @GfFile.baseFile, length: SIZE[EightBits, 2], element: @GfFile.element, item: @grossExprHack]} ENDLOOP; END;
--:1153----1154:-- GfSwap: PROCEDURE
 = 
BEGIN IF GfLimit=GfBufSize  THEN BEGIN WriteGf[0,HalfBuf-1];
GfLimit←HalfBuf;GfOffset←GfOffset+GfBufSize;GfPtr←0;
 END  ELSE BEGIN WriteGf[HalfBuf,GfBufSize-1];GfLimit←GfBufSize;
 END; END;--:1154----1156:-- GfFour: PROCEDURE[X: PascalInteger]
 = 
BEGIN IF X>=0  THEN BEGIN GfBuf↑[GfPtr]← PascalDIVPower2[X ,24];
GfPtr←GfPtr+1;IF GfPtr=GfLimit  THEN GfSwap[];
 END  ELSE BEGIN X←X+1073741824;X←X+1073741824;
BEGIN GfBuf↑[GfPtr]←( PascalDIVPower2[X ,24])+128;GfPtr←GfPtr+1;
IF GfPtr=GfLimit  THEN GfSwap[]; END; END;X← PascalMODPower2Mask[X ,16777215];
BEGIN GfBuf↑[GfPtr]← PascalDIVPower2[X ,16];GfPtr←GfPtr+1;
IF GfPtr=GfLimit  THEN GfSwap[]; END;X← PascalMODPower2Mask[X ,65535];
BEGIN GfBuf↑[GfPtr]← PascalDIVPower2[X ,8];GfPtr←GfPtr+1;
IF GfPtr=GfLimit  THEN GfSwap[]; END;BEGIN GfBuf↑[GfPtr]← PascalMODPower2Mask[X ,255];
GfPtr←GfPtr+1;IF GfPtr=GfLimit  THEN GfSwap[]; END; END;--:1156----1157:
 GfTwo: PROCEDURE[X: PascalInteger] = 
BEGIN BEGIN GfBuf↑[GfPtr]← PascalDIVPower2[X ,8];
GfPtr←GfPtr+1;IF GfPtr=GfLimit  THEN GfSwap[]; END;
BEGIN GfBuf↑[GfPtr]← PascalMODPower2Mask[X ,255];GfPtr←GfPtr+1;
IF GfPtr=GfLimit  THEN GfSwap[]; END; END; GfThree: PROCEDURE[X: PascalInteger]
 = 
BEGIN BEGIN GfBuf↑[GfPtr]← PascalDIVPower2[X ,16];GfPtr←GfPtr+1;
IF GfPtr=GfLimit  THEN GfSwap[]; END;
BEGIN GfBuf↑[GfPtr]← PascalDIVPower2[( PascalMODPower2Mask[X ,65535]),8];GfPtr←GfPtr+1;
IF GfPtr=GfLimit  THEN GfSwap[]; END;BEGIN GfBuf↑[GfPtr]← PascalMODPower2Mask[X ,255];
GfPtr←GfPtr+1;IF GfPtr=GfLimit  THEN GfSwap[]; END; END;--:1157----1158:
 GfPaint: PROCEDURE[D: PascalInteger]
 = 
BEGIN IF D<64  THEN BEGIN GfBuf↑[GfPtr]←0+D;GfPtr←GfPtr+1;
IF GfPtr=GfLimit  THEN GfSwap[];
 END  ELSE IF D<256  THEN BEGIN BEGIN GfBuf↑[GfPtr]←64;GfPtr←GfPtr+1;
IF GfPtr=GfLimit  THEN GfSwap[]; END;BEGIN GfBuf↑[GfPtr]←D;
GfPtr←GfPtr+1;IF GfPtr=GfLimit  THEN GfSwap[]; END;
 END  ELSE BEGIN BEGIN GfBuf↑[GfPtr]←65;GfPtr←GfPtr+1;
IF GfPtr=GfLimit  THEN GfSwap[]; END;GfTwo[D]; END; END;--:1158----1159:
 GfString: PROCEDURE[S,T: StrNumber] = 
BEGIN K:PoolPointer;L:PascalInteger;
 IF S#0  THEN BEGIN L←(StrStart↑[S+1]-StrStart↑[S]);
IF T#0  THEN L←L+(StrStart↑[T+1]-StrStart↑[T]);
IF L<=255  THEN BEGIN BEGIN GfBuf↑[GfPtr]←239;GfPtr←GfPtr+1;
IF GfPtr=GfLimit  THEN GfSwap[]; END;BEGIN GfBuf↑[GfPtr]←L;
GfPtr←GfPtr+1;IF GfPtr=GfLimit  THEN GfSwap[]; END;
 END  ELSE BEGIN BEGIN GfBuf↑[GfPtr]←241;GfPtr←GfPtr+1;
IF GfPtr=GfLimit  THEN GfSwap[]; END;GfThree[L]; END;
FOR i:INT    IN [ INT[StrStart↑[S]].. INT[StrStart↑[S+1]-1 ]] DO  K ← i;  GfBuf↑[GfPtr]←StrPool
↑[K];GfPtr←GfPtr+1;IF GfPtr=GfLimit  THEN GfSwap[]; ENDLOOP; END;
IF T#0  THEN FOR i:INT    IN [ INT[StrStart↑[T]].. INT[StrStart↑[T+1]-1 ]] DO  K ← i;  GfBuf↑
[GfPtr]←StrPool↑[K];GfPtr←GfPtr+1;IF GfPtr=GfLimit  THEN GfSwap[];
 ENDLOOP; END;--:1159----1160:-- GfBoc: PROCEDURE[MinM,MaxM,MinN,MaxN: PascalInteger]
 = 
BEGIN  IF MinM<GfMinM  THEN GfMinM←MinM;
IF MaxN>GfMaxN  THEN GfMaxN←MaxN;
{IF BocP=-1  THEN IF BocC>=0  THEN IF BocC<256  THEN IF MaxM-MinM>=0
 THEN IF MaxM-MinM<256  THEN IF MaxM>=0  THEN IF MaxM<256  THEN IF MaxN
-MinN>=0  THEN IF MaxN-MinN<256  THEN IF MaxN>=0  THEN IF MaxN<256
 THEN BEGIN BEGIN GfBuf↑[GfPtr]←68;GfPtr←GfPtr+1;
IF GfPtr=GfLimit  THEN GfSwap[]; END;BEGIN GfBuf↑[GfPtr]←BocC;
GfPtr←GfPtr+1;IF GfPtr=GfLimit  THEN GfSwap[]; END;
BEGIN GfBuf↑[GfPtr]←MaxM-MinM;GfPtr←GfPtr+1;
IF GfPtr=GfLimit  THEN GfSwap[]; END;BEGIN GfBuf↑[GfPtr]←MaxM;
GfPtr←GfPtr+1;IF GfPtr=GfLimit  THEN GfSwap[]; END;
BEGIN GfBuf↑[GfPtr]←MaxN-MinN;GfPtr←GfPtr+1;
IF GfPtr=GfLimit  THEN GfSwap[]; END;BEGIN GfBuf↑[GfPtr]←MaxN;
GfPtr←GfPtr+1;IF GfPtr=GfLimit  THEN GfSwap[]; END; GOTO Label10; END;
BEGIN GfBuf↑[GfPtr]←67;GfPtr←GfPtr+1;
IF GfPtr=GfLimit  THEN GfSwap[]; END;GfFour[BocC];GfFour[BocP];
GfFour[MinM];GfFour[MaxM];GfFour[MinN];GfFour[MaxN];EXITS Label10 => NULL}; END;
--:1160----1162:-- InitGf: PROCEDURE = 
BEGIN K:EightBits;T:PascalInteger;
 GfMinM←4096;GfMaxM←-4096;GfMinN←4096;GfMaxN←-4096;
FOR i:INT    IN [ INT[0 ].. INT[255 ]] DO  K ← i; CharPtr↑[K]←-1 ENDLOOP;--1163:
IF Internal↑[27]<=0  THEN GfExt←909  ELSE BEGIN OldSetting←Selector;
Selector←5;PrintChar[46];
PrintInt[MakeScaled[Internal↑[27],59429463]];Print[910];
GfExt←MakeString[];Selector←OldSetting; END--:1163--;
BEGIN IF JobName=0  THEN OpenLogFile[];PackJobName[GfExt];
WHILE  NOT BOpenOut[@GfFile]DO PromptFileName[621,GfExt] ENDLOOP ;
OutputFileName←BMakeNameString[@GfFile]; END;
BEGIN GfBuf↑[GfPtr]←247;GfPtr←GfPtr+1;
IF GfPtr=GfLimit  THEN GfSwap[]; END;BEGIN GfBuf↑[GfPtr]←131;
GfPtr←GfPtr+1;IF GfPtr=GfLimit  THEN GfSwap[]; END;
OldSetting←Selector;Selector←5;Print[908];
PrintInt[RoundUnscaled[Internal↑[14]]];PrintChar[46];
PrintDd[RoundUnscaled[Internal↑[15]]];PrintChar[46];
PrintDd[RoundUnscaled[Internal↑[16]]];PrintChar[58];
T←RoundUnscaled[Internal↑[17]];PrintDd[ T /60];PrintDd[ T MOD 60];
Selector←OldSetting;
BEGIN GfBuf↑[GfPtr]←(PoolPtr-StrStart↑[StrPtr]);GfPtr←GfPtr+1;
IF GfPtr=GfLimit  THEN GfSwap[]; END;StrStart↑[StrPtr+1]←PoolPtr;
GfString[0,StrPtr];PoolPtr←StrStart↑[StrPtr];
GfPrevPtr←GfOffset+GfPtr; END;--:1162----1164:

END.