-- file: MFOpsImpl6.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,
  MFEdges,
  MFEquations,
  MFParsing,
  MFOps,
  MFEnvelopes;

MFOpsImpl6: PROGRAM IMPORTS PascalBasic, MFProcArray, MFInteraction, MFMath, MFMemory, MFSymbols, MFEdges, MFEquations, MFParsing, MFOps, MFEnvelopes EXPORTS MFOps = PUBLIC
BEGIN OPEN PascalBasic, PascalWizardFiles, MFTypes, MFProcArray, MFInteraction, MFMath, MFMemory, MFSymbols, MFEdges, MFEquations, MFParsing, MFOps, MFEnvelopes;
--922:-- BadBinary: PROCEDURE[P: Halfword,C: Quarterword]
 = 
BEGIN DispErr[P,157];DispErr[0,703];IF  INT[C]>=94  THEN PrintOp[C];
PrintKnownOrUnknownType[Mem[P]↑.Hh.B0,P];
IF  INT[C]>=94  THEN Print[348] ELSE PrintOp[C];
PrintKnownOrUnknownType[CurType,CurExp];BEGIN HelpPtr←3;
HelpLine↑[2]←704;HelpLine↑[1]←713;HelpLine↑[0]←714; END;PutGetError[];
 END;--:922----927:-- Tarnished: PROCEDURE[P: Halfword] RETURNS[TarnishedResult: Halfword] = 
BEGIN 
 Q:Halfword;R:Halfword; Q←Mem[ INT[P]+1]↑.Int;
R← INT[Q]+BigNodeSize↑[Mem[P]↑.Hh.B0];{DO R← INT[R]-2;
IF Mem[R]↑.Hh.B0=19  THEN BEGIN TarnishedResult←1; GOTO Label10; END; IF R=Q THEN EXIT; ENDLOOP;
TarnishedResult←0;EXITS Label10 => NULL}; END;--:927----929:----934:-- DepFinish: PROCEDURE[V,Q: Halfword,
T: SmallNumber] = 
BEGIN P:Halfword;Vv:Scaled;
 IF Q=0  THEN P←CurExp  ELSE P←Q;Mem[ INT[P]+1]↑.Hh.Rh←V;
Mem[P]↑.Hh.B0←T;IF Mem[V]↑.Hh.Lh=0  THEN BEGIN Vv←Mem[ INT[V]+1]↑.Int;
IF Q=0  THEN FlushCurExp[Vv] ELSE BEGIN RecycleValue[P];
Mem[Q]↑.Hh.B0←16;Mem[ INT[Q]+1]↑.Int←Vv; END; END  ELSE IF Q=0  THEN CurType←T;
IF FixNeeded  THEN FixDependencies[]; END;--:934
 AddOrSubtract: PROCEDURE[P,Q: Halfword,C: Quarterword] = 
BEGIN 
 S, T:SmallNumber;R:Halfword;V:PascalInteger;
 IF Q=0  THEN BEGIN T←CurType;
IF  INT[T]<17  THEN V←CurExp  ELSE V←Mem[CurExp+1]↑.Hh.Rh;
 END  ELSE BEGIN T←Mem[Q]↑.Hh.B0;
IF  INT[T]<17  THEN V←Mem[ INT[Q]+1]↑.Int  ELSE V←Mem[ INT[Q]+1]↑.Hh.Rh; END;
{IF T=16  THEN BEGIN  IF C=70  THEN V←-V;
IF Mem[P]↑.Hh.B0=16  THEN BEGIN V←SlowAdd[Mem[ INT[P]+1]↑.Int,V];
IF Q=0  THEN CurExp←V  ELSE Mem[ INT[Q]+1]↑.Int←V; GOTO Label10; END;--930:
R←Mem[ INT[P]+1]↑.Hh.Rh;WHILE Mem[R]↑.Hh.Lh#0 DO R←Mem[R]↑.Hh.Rh ENDLOOP ;
Mem[ INT[R]+1]↑.Int←SlowAdd[Mem[ INT[R]+1]↑.Int,V];IF Q=0  THEN BEGIN Q←GetNode[2];
CurExp←Q;CurType←Mem[P]↑.Hh.B0;Mem[Q]↑.Hh.B1←11; END;
Mem[ INT[Q]+1]↑.Hh.Rh←Mem[ INT[P]+1]↑.Hh.Rh;Mem[Q]↑.Hh.B0←Mem[P]↑.Hh.B0;
Mem[ INT[Q]+1]↑.Hh.Lh←Mem[ INT[P]+1]↑.Hh.Lh;Mem[Mem[ INT[P]+1]↑.Hh.Lh]↑.Hh.Rh←Q;
Mem[P]↑.Hh.B0←16;--:930-- END  ELSE BEGIN IF C=70  THEN NegateDepList[V];
--931:--IF Mem[P]↑.Hh.B0=16  THEN--932:
BEGIN WHILE Mem[V]↑.Hh.Lh#0 DO V←Mem[V]↑.Hh.Rh ENDLOOP ;
Mem[V+1]↑.Int←SlowAdd[Mem[ INT[P]+1]↑.Int,Mem[V+1]↑.Int]; END--:932
 ELSE BEGIN S←Mem[P]↑.Hh.B0;R←Mem[ INT[P]+1]↑.Hh.Rh;
{IF T=17  THEN BEGIN IF S=17  THEN IF MaxCoef[R]+MaxCoef[V]<626349397
 THEN BEGIN V←PPlusQ[V,R,17]; GOTO Label30; END;T←18;
V←POverV[V,65536,17,18]; END;
IF S=18  THEN V←PPlusQ[V,R,18] ELSE V←PPlusFq[V,65536,R,18,17];
EXITS Label30 => NULL};--933:--IF Q#0  THEN DepFinish[V,Q,T] ELSE BEGIN CurType←T;
DepFinish[V,0,T]; END--:933--; END--:931--; END;EXITS Label10 => NULL}; END;--:929----942:
 DepMult: PROCEDURE[P: Halfword,V: PascalInteger,VIsScaled: PascalBoolean] = 
BEGIN 
 Q:Halfword;S, T:SmallNumber;
 {IF P=0  THEN Q←CurExp  ELSE IF Mem[P]↑.Hh.B0#16  THEN Q←P  ELSE
BEGIN IF VIsScaled  THEN Mem[ INT[P]+1]↑.Int←TakeScaled[Mem[ INT[P]+1]↑.Int,V] ELSE
Mem[ INT[P]+1]↑.Int←TakeFraction[Mem[ INT[P]+1]↑.Int,V]; GOTO Label10; END;T←Mem[Q]↑.Hh.B0;
Q←Mem[ INT[Q]+1]↑.Hh.Rh;S←T;
IF T=17  THEN IF VIsScaled  THEN IF AbVsCd[MaxCoef[Q],ABS[V],
626349396,65536]>=0  THEN T←18;Q←PTimesV[Q,V,S,T,VIsScaled];
DepFinish[Q,P,T];EXITS Label10 => NULL}; END;--:942----945:-- HardTimes: PROCEDURE[P: Halfword]
 = 
BEGIN Q:Halfword;R:Halfword;U, V:Scaled;
 IF Mem[P]↑.Hh.B0=14  THEN BEGIN Q←StashCurExp[];UnstashCurExp[P];
P←Q; END;R←Mem[CurExp+1]↑.Int;U←Mem[ INT[R]+1]↑.Int;V←Mem[ INT[R]+3]↑.Int;--946:
Mem[ INT[R]+2]↑.Hh.B0←Mem[P]↑.Hh.B0;NewDep[ INT[R]+2,CopyDepList[Mem[ INT[P]+1]↑.Hh.Rh]];
Mem[R]↑.Hh.B0←Mem[P]↑.Hh.B0;Mem[ INT[R]+1]↑←Mem[ INT[P]+1]↑;
Mem[Mem[ INT[P]+1]↑.Hh.Lh]↑.Hh.Rh←R;FreeNode[P,2]--:946--;DepMult[R,U,TRUE];
DepMult[ INT[R]+2,V,TRUE]; END;--:945----948:-- DepDiv: PROCEDURE[P: Halfword,
V: Scaled] = 
BEGIN  Q:Halfword;S, T:SmallNumber;
 {IF P=0  THEN Q←CurExp  ELSE IF Mem[P]↑.Hh.B0#16  THEN Q←P  ELSE
BEGIN Mem[ INT[P]+1]↑.Int←MakeScaled[Mem[ INT[P]+1]↑.Int,V]; GOTO Label10; END;
T←Mem[Q]↑.Hh.B0;Q←Mem[ INT[Q]+1]↑.Hh.Rh;S←T;
IF T=17  THEN IF AbVsCd[MaxCoef[Q],65536,626349396,ABS[V]]>=0  THEN T←
18;Q←POverV[Q,V,S,T];DepFinish[Q,P,T];EXITS Label10 => NULL}; END;--:948----952:
 SetUpTrans: PROCEDURE[C: Quarterword] = 
BEGIN  P, Q, R:Halfword;
 IF(C#88)OR (CurType#13) THEN--954:--BEGIN P←StashCurExp[];
CurExp←IdTransform[];CurType←13;Q←Mem[CurExp+1]↑.Int;{SELECT C FROM--956:
84 =>IF Mem[P]↑.Hh.B0=16  THEN--957:
BEGIN NSinCos[( Mem[ INT[P]+1]↑.Int MOD 23592960)*16];
Mem[ INT[Q]+5]↑.Int←RoundFraction[NCos];Mem[ INT[Q]+9]↑.Int←RoundFraction[NSin];
Mem[ INT[Q]+7]↑.Int←-Mem[ INT[Q]+9]↑.Int;Mem[ INT[Q]+11]↑.Int←Mem[ INT[Q]+5]↑.Int; GOTO Label30;
 END--:957--;85 =>IF  INT[Mem[P]↑.Hh.B0]>14  THEN BEGIN Install[ INT[Q]+6,P]; GOTO Label30; END;
86 =>IF  INT[Mem[P]↑.Hh.B0]>14  THEN BEGIN Install[ INT[Q]+4,P];Install[ INT[Q]+10,P]; GOTO Label30;
 END;87 =>IF Mem[P]↑.Hh.B0=14  THEN BEGIN R←Mem[ INT[P]+1]↑.Int;Install[Q,R];
Install[ INT[Q]+2, INT[R]+2]; GOTO Label30; END;
89 =>IF  INT[Mem[P]↑.Hh.B0]>14  THEN BEGIN Install[ INT[Q]+4,P]; GOTO Label30; END;
90 =>IF  INT[Mem[P]↑.Hh.B0]>14  THEN BEGIN Install[ INT[Q]+10,P]; GOTO Label30; END;
91 =>IF Mem[P]↑.Hh.B0=14  THEN--958:--BEGIN R←Mem[ INT[P]+1]↑.Int;Install[ INT[Q]+4,R];
Install[ INT[Q]+10,R];Install[ INT[Q]+8, INT[R]+2];
IF Mem[ INT[R]+2]↑.Hh.B0=16  THEN Mem[ INT[R]+3]↑.Int←-Mem[ INT[R]+3]↑.Int  ELSE
NegateDepList[Mem[ INT[R]+3]↑.Hh.Rh];Install[ INT[Q]+6, INT[R]+2]; GOTO Label30; END--:958--;88 => NULL;
--:956-- ENDCASE;DispErr[P,723];BEGIN HelpPtr←3;HelpLine↑[2]←724;
HelpLine↑[1]←725;HelpLine↑[0]←406; END;PutGetError[];
EXITS Label30 => NULL};RecycleValue[P];FreeNode[P,2]; END--:954--;--955:
Q←Mem[CurExp+1]↑.Int;R← INT[Q]+12;{DO R← INT[R]-2;
IF Mem[R]↑.Hh.B0#16  THEN  GOTO Label10; IF R=Q THEN EXIT; ENDLOOP;Txx←Mem[ INT[Q]+5]↑.Int;
Txy←Mem[ INT[Q]+7]↑.Int;Tyx←Mem[ INT[Q]+9]↑.Int;Tyy←Mem[ INT[Q]+11]↑.Int;Tx←Mem[ INT[Q]+1]↑.Int;
Ty←Mem[ INT[Q]+3]↑.Int;FlushCurExp[0]--:955--;EXITS Label10 => NULL}; END;--:952----959:
 SetUpKnownTrans: PROCEDURE[C: Quarterword] = 
BEGIN SetUpTrans[C];
IF CurType#16  THEN BEGIN DispErr[0,726];BEGIN HelpPtr←3;
HelpLine↑[2]←727;HelpLine↑[1]←728;HelpLine↑[0]←406; END;
PutGetFlushError[0];Txx←65536;Txy←0;Tyx←0;Tyy←65536;Tx←0;Ty←0;
 END; END;--:959----960:-- Trans: PROCEDURE[P,Q: Halfword] = 
BEGIN V:Scaled;
 V←TakeScaled[Mem[P]↑.Int,Txx]+TakeScaled[Mem[Q]↑.Int,Txy]+Tx;
Mem[Q]↑.Int←TakeScaled[Mem[P]↑.Int,Tyx]+TakeScaled[Mem[Q]↑.Int,Tyy]+Ty;
Mem[P]↑.Int←V; END;--:960----961:-- PathTrans: PROCEDURE[P: Halfword,
C: Quarterword] = 
BEGIN  Q:Halfword; SetUpKnownTrans[C];
UnstashCurExp[P];
{IF CurType=6  THEN BEGIN IF Mem[CurExp+9]↑.Int=0  THEN IF Tx=0  THEN IF Ty
=0  THEN  GOTO Label10;FlushCurExp[MakePath[CurExp]];CurType←8; END;
Q←CurExp;DO IF Mem[Q]↑.Hh.B0#0  THEN Trans[ INT[Q]+3, INT[Q]+4];Trans[ INT[Q]+1, INT[Q]+2];
IF Mem[Q]↑.Hh.B1#0  THEN Trans[ INT[Q]+5, INT[Q]+6];Q←Mem[Q]↑.Hh.Rh; IF Q=CurExp THEN EXIT; ENDLOOP;
EXITS Label10 => NULL}; END;--:961----962:-- EdgesTrans: PROCEDURE[P: Halfword,C: Quarterword]
 = 
BEGIN  SetUpKnownTrans[C];UnstashCurExp[P];
CurEdges←CurExp;{IF Mem[CurEdges]↑.Hh.Rh=CurEdges  THEN  GOTO Label10;
IF Txx=0  THEN IF Tyy=0  THEN IF  PascalMODPower2Mask[Txy ,65535]=0  THEN IF  PascalMODPower2Mask[Tyx ,65535]=0
 THEN BEGIN XySwapEdges[];Txx←Txy;Tyy←Tyx;Txy←0;Tyx←0;
IF Mem[CurEdges]↑.Hh.Rh=CurEdges  THEN  GOTO Label10; END;
IF Txy=0  THEN IF Tyx=0  THEN IF  PascalMODPower2Mask[Txy ,65535]=0  THEN IF  PascalMODPower2Mask[Tyy ,65535]=0
 THEN--963:--BEGIN IF(Txx=0)OR (Tyy=0) THEN BEGIN TossEdges[CurEdges];
CurExp←GetNode[6];InitEdges[CurExp];
 END  ELSE BEGIN IF Txx<0  THEN BEGIN XReflectEdges[];Txx←-Txx; END;
IF Tyy<0  THEN BEGIN YReflectEdges[];Tyy←-Tyy; END;
IF Txx#65536  THEN XScaleEdges[ PascalDIVPower2[Txx ,16]];
IF Tyy#65536  THEN YScaleEdges[ PascalDIVPower2[Tyy ,16]];--964:
Tx←RoundUnscaled[Tx];Ty←RoundUnscaled[Ty];
IF(Mem[ INT[CurEdges]+2]↑.Hh.Lh+Tx<=0)OR (Mem[ INT[CurEdges]+2]↑.Hh.Rh+Tx>=8192)OR (
Mem[ INT[CurEdges]+1]↑.Hh.Lh+Ty<=0)OR (Mem[ INT[CurEdges]+1]↑.Hh.Rh+Ty>=8191)OR (
ABS[Tx]>=4096)OR (ABS[Ty]>=4096) THEN BEGIN BEGIN IF Interaction=3  THEN NULL;
PrintNl[133];Print[732]; END;BEGIN HelpPtr←3;HelpLine↑[2]←733;
HelpLine↑[1]←405;HelpLine↑[0]←406; END;PutGetError[];
 END  ELSE BEGIN IF Tx#0  THEN BEGIN IF NOT (ABS[Mem[ INT[CurEdges]+3]↑.Hh.Lh-Tx
-4096]<4096) THEN FixOffset[];
Mem[ INT[CurEdges]+2]↑.Hh.Lh←Mem[ INT[CurEdges]+2]↑.Hh.Lh+Tx;
Mem[ INT[CurEdges]+2]↑.Hh.Rh←Mem[ INT[CurEdges]+2]↑.Hh.Rh+Tx;
Mem[ INT[CurEdges]+3]↑.Hh.Lh←Mem[ INT[CurEdges]+3]↑.Hh.Lh-Tx;
Mem[ INT[CurEdges]+4]↑.Int←0; END;
IF Ty#0  THEN BEGIN Mem[ INT[CurEdges]+1]↑.Hh.Lh←Mem[ INT[CurEdges]+1]↑.Hh.Lh+Ty;
Mem[ INT[CurEdges]+1]↑.Hh.Rh←Mem[ INT[CurEdges]+1]↑.Hh.Rh+Ty;
Mem[ INT[CurEdges]+5]↑.Hh.Lh←Mem[ INT[CurEdges]+5]↑.Hh.Lh+Ty;
Mem[ INT[CurEdges]+4]↑.Int←0; END; END--:964--; END; GOTO Label10; END--:963--;
BEGIN IF Interaction=3  THEN NULL;PrintNl[133];Print[729]; END;
BEGIN HelpPtr←3;HelpLine↑[2]←730;HelpLine↑[1]←731;HelpLine↑[0]←406;
 END;PutGetError[];EXITS Label10 => NULL}; END;--:962----965:----967:--
END.