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


DIRECTORY
  PascalBasic,
  PascalWizardFiles,
  MFTypes,
  MFProcArray,
  MFMath,
  MFOctants,
  MFContours;

MFOctantsImpl6: PROGRAM IMPORTS MFProcArray, MFMath, MFOctants, MFContours EXPORTS MFOctants = PUBLIC
BEGIN OPEN PascalBasic, PascalWizardFiles, MFTypes, MFProcArray, MFMath, MFOctants, MFContours;
 OctantSubdivide: PROCEDURE
 = 
BEGIN P, Q, R, S:Halfword;Del1, Del2, Del3, Del, Dmax:Scaled;T:Fraction;
DestX, DestY:Scaled; P←CurSpec;DO Q←Mem[P]↑.Hh.Rh;
Mem[ INT[P]+1]↑.Int←Mem[ INT[P]+1]↑.Int-Mem[ INT[P]+2]↑.Int;
Mem[ INT[P]+5]↑.Int←Mem[ INT[P]+5]↑.Int-Mem[ INT[P]+6]↑.Int;
Mem[ INT[Q]+3]↑.Int←Mem[ INT[Q]+3]↑.Int-Mem[ INT[Q]+4]↑.Int;--420:----421:
IF Q=CurSpec  THEN BEGIN Unskew[Mem[ INT[Q]+1]↑.Int,Mem[ INT[Q]+2]↑.Int,Mem[Q]↑.Hh.B1];
Skew[CurX,CurY,Mem[P]↑.Hh.B1];DestX←CurX;DestY←CurY;
 END  ELSE BEGIN Abnegate[Mem[ INT[Q]+1]↑.Int,Mem[ INT[Q]+2]↑.Int,Mem[Q]↑.Hh.B1,Mem[P]↑.Hh
.B1];DestX←CurX-CurY;DestY←CurY; END;
Del1←Mem[ INT[P]+5]↑.Int-Mem[ INT[P]+1]↑.Int;Del2←Mem[ INT[Q]+3]↑.Int-Mem[ INT[P]+5]↑.Int;
Del3←DestX-Mem[ INT[Q]+3]↑.Int--:421--;--408:
IF Del1#0  THEN Del←Del1  ELSE IF Del2#0  THEN Del←Del2  ELSE Del←Del3;
IF Del#0  THEN BEGIN Dmax←ABS[Del1];
IF ABS[Del2]>Dmax  THEN Dmax←ABS[Del2];
IF ABS[Del3]>Dmax  THEN Dmax←ABS[Del3];
WHILE Dmax<134217728 DO BEGIN Dmax←Dmax+Dmax;Del1←Del1+Del1;
Del2←Del2+Del2;Del3←Del3+Del3; END ENDLOOP ; END--:408--;
IF Del#0  THEN BEGIN IF Del<0  THEN--423:
BEGIN Mem[ INT[P]+2]↑.Int←Mem[ INT[P]+1]↑.Int+Mem[ INT[P]+2]↑.Int;
Mem[ INT[P]+1]↑.Int←-Mem[ INT[P]+1]↑.Int;Mem[ INT[P]+6]↑.Int←Mem[ INT[P]+5]↑.Int+Mem[ INT[P]+6]↑.Int;
Mem[ INT[P]+5]↑.Int←-Mem[ INT[P]+5]↑.Int;Mem[ INT[Q]+4]↑.Int←Mem[ INT[Q]+3]↑.Int+Mem[ INT[Q]+4]↑.Int;
Mem[ INT[Q]+3]↑.Int←-Mem[ INT[Q]+3]↑.Int;Del1←-Del1;Del2←-Del2;Del3←-Del3;
DestY←DestX+DestY;DestX←-DestX;Mem[P]↑.Hh.B1←Mem[P]↑.Hh.B1+4;
 END--:423--;T←CrossingPoint[Del1,Del2,Del3];IF T<268435456  THEN--424:
BEGIN SplitCubic[P,T,DestX,DestY];R←Mem[P]↑.Hh.Rh;
IF  INT[Mem[R]↑.Hh.B1]>4  THEN Mem[R]↑.Hh.B1←Mem[R]↑.Hh.B1-4  ELSE Mem[R]↑.Hh.B1←
Mem[R]↑.Hh.B1+4;
IF Mem[ INT[R]+2]↑.Int>DestY  THEN Mem[ INT[R]+2]↑.Int←DestY  ELSE IF 
Mem[ INT[R]+2]↑.Int<Mem[ INT[P]+2]↑.Int  THEN Mem[ INT[R]+2]↑.Int←Mem[ INT[P]+2]↑.Int;
IF Mem[ INT[R]+1]↑.Int<Mem[ INT[P]+1]↑.Int  THEN Mem[ INT[R]+1]↑.Int←Mem[ INT[P]+1]↑.Int;
Mem[ INT[R]+3]↑.Int←Mem[ INT[R]+1]↑.Int;Mem[ INT[R]+2]↑.Int←Mem[ INT[R]+2]↑.Int+Mem[ INT[R]+1]↑.Int;
Mem[ INT[R]+1]↑.Int←-Mem[ INT[R]+1]↑.Int;Mem[ INT[R]+5]↑.Int←Mem[ INT[R]+1]↑.Int;
Mem[ INT[R]+6]↑.Int←Mem[ INT[R]+6]↑.Int-Mem[ INT[R]+5]↑.Int;
Mem[ INT[Q]+4]↑.Int←Mem[ INT[Q]+4]↑.Int+Mem[ INT[Q]+3]↑.Int;Mem[ INT[Q]+3]↑.Int←-Mem[ INT[Q]+3]↑.Int;
DestY←DestY+DestX;DestX←-DestX;
Del2←Del2-TakeFraction[Del2-Del3,T];IF Del2>0  THEN Del2←0;
T←CrossingPoint[0,-Del2,-Del3];IF T<268435456  THEN--425:
BEGIN SplitCubic[R,T,DestX,DestY];S←Mem[R]↑.Hh.Rh;
IF Mem[ INT[S]+2]↑.Int>DestY  THEN Mem[ INT[S]+2]↑.Int←DestY  ELSE IF 
Mem[ INT[S]+2]↑.Int<Mem[ INT[R]+2]↑.Int  THEN Mem[ INT[S]+2]↑.Int←Mem[ INT[R]+2]↑.Int;
IF Mem[ INT[S]+1]↑.Int<DestX  THEN Mem[ INT[S]+1]↑.Int←DestX;
IF Mem[ INT[S]+1]↑.Int<Mem[ INT[R]+1]↑.Int  THEN Mem[ INT[S]+1]↑.Int←Mem[ INT[R]+1]↑.Int;
Mem[S]↑.Hh.B1←Mem[P]↑.Hh.B1;Mem[ INT[S]+3]↑.Int←Mem[ INT[S]+1]↑.Int;
Mem[ INT[S]+2]↑.Int←Mem[ INT[S]+2]↑.Int+Mem[ INT[S]+1]↑.Int;Mem[ INT[S]+1]↑.Int←-Mem[ INT[S]+1]↑.Int;
Mem[ INT[S]+6]↑.Int←Mem[ INT[S]+6]↑.Int-Mem[ INT[S]+1]↑.Int;Mem[ INT[S]+5]↑.Int←Mem[ INT[S]+1]↑.Int;
Mem[ INT[Q]+4]↑.Int←Mem[ INT[Q]+4]↑.Int+Mem[ INT[Q]+3]↑.Int;Mem[ INT[Q]+3]↑.Int←-Mem[ INT[Q]+3]↑.Int;
 END--:425-- ELSE IF Mem[ INT[R]+1]↑.Int>DestX  THEN Mem[ INT[R]+1]↑.Int←DestX ; END--:424
; END--:420--;P←Q; IF P=CurSpec THEN EXIT; ENDLOOP; END;--:419----426:--
END.