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


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

MFOctantsImpl3: PROGRAM IMPORTS PascalBasic, MFProcArray, MFMath, MFOctants EXPORTS MFOctants = PUBLIC
BEGIN OPEN PascalBasic, PascalWizardFiles, MFTypes, MFProcArray, MFMath, MFOctants;
 QuadrantSubdivide: PROCEDURE = 
BEGIN 
 P, Q, R, S, Pp, Qq:Halfword;FirstX, FirstY:Scaled;
Del1, Del2, Del3, Del, Dmax:Scaled;T:Fraction;DestX, DestY:Scaled;
ConstantX:PascalBoolean; Subdiv1: PROCEDURE = 
BEGIN--407:
IF Q=CurSpec  THEN BEGIN DestX←FirstX;DestY←FirstY;
 END  ELSE BEGIN DestX←Mem[ INT[Q]+1]↑.Int;DestY←Mem[ INT[Q]+2]↑.Int; 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;--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 ConstantX←TRUE  ELSE BEGIN ConstantX←FALSE;
IF Del<0  THEN--409:--BEGIN Mem[ INT[P]+1]↑.Int←-Mem[ INT[P]+1]↑.Int;
Mem[ INT[P]+5]↑.Int←-Mem[ INT[P]+5]↑.Int;Mem[ INT[Q]+3]↑.Int←-Mem[ INT[Q]+3]↑.Int;Del1←-Del1;
Del2←-Del2;Del3←-Del3;DestX←-DestX;Mem[P]↑.Hh.B1←2; END--:409--;
T←CrossingPoint[Del1,Del2,Del3];IF T<268435456  THEN--411:
BEGIN SplitCubic[P,T,DestX,DestY];R←Mem[P]↑.Hh.Rh;
IF  INT[Mem[R]↑.Hh.B1]>1  THEN Mem[R]↑.Hh.B1←1  ELSE Mem[R]↑.Hh.B1←2;
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]+1]↑.Int←-Mem[ INT[R]+1]↑.Int;
Mem[ INT[R]+5]↑.Int←Mem[ INT[R]+1]↑.Int;Mem[ INT[Q]+3]↑.Int←-Mem[ INT[Q]+3]↑.Int;DestX←-DestX;
Del2←Del2-TakeFraction[Del2-Del3,T];IF Del2>0  THEN Del2←0;
T←CrossingPoint[0,-Del2,-Del3];IF T<268435456  THEN--412:
BEGIN SplitCubic[R,T,DestX,DestY];S←Mem[R]↑.Hh.Rh;
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]+1]↑.Int←-Mem[ INT[S]+1]↑.Int;Mem[ INT[S]+5]↑.Int←Mem[ INT[S]+1]↑.Int;
Mem[ INT[Q]+3]↑.Int←-Mem[ INT[Q]+3]↑.Int; END--:412
 ELSE IF Mem[ INT[R]+1]↑.Int>DestX  THEN Mem[ INT[R]+1]↑.Int←DestX; END--:411--;
 END--:407--; END; P←CurSpec;FirstX←Mem[ INT[CurSpec]+1]↑.Int;
FirstY←Mem[ INT[CurSpec]+2]↑.Int;{DO DO {--Label22:--Q←Mem[P]↑.Hh.Rh;Subdiv1[];--413:
Pp←P;DO Qq←Mem[Pp]↑.Hh.Rh;
Abnegate[Mem[ INT[Qq]+1]↑.Int,Mem[ INT[Qq]+2]↑.Int,Mem[Qq]↑.Hh.B1,Mem[Pp]↑.Hh.B1];
DestX←CurX;DestY←CurY;Del1←Mem[ INT[Pp]+6]↑.Int-Mem[ INT[Pp]+2]↑.Int;
Del2←Mem[ INT[Qq]+4]↑.Int-Mem[ INT[Pp]+6]↑.Int;Del3←DestY-Mem[ INT[Qq]+4]↑.Int;--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--414:
BEGIN Mem[ INT[Pp]+2]↑.Int←-Mem[ INT[Pp]+2]↑.Int;Mem[ INT[Pp]+6]↑.Int←-Mem[ INT[Pp]+6]↑.Int;
Mem[ INT[Qq]+4]↑.Int←-Mem[ INT[Qq]+4]↑.Int;Del1←-Del1;Del2←-Del2;Del3←-Del3;
DestY←-DestY;Mem[Pp]↑.Hh.B1←Mem[Pp]↑.Hh.B1+2; END--:414--;
T←CrossingPoint[Del1,Del2,Del3];IF T<268435456  THEN--415:
BEGIN SplitCubic[Pp,T,DestX,DestY];R←Mem[Pp]↑.Hh.Rh;
IF  INT[Mem[R]↑.Hh.B1]>2  THEN Mem[R]↑.Hh.B1←Mem[R]↑.Hh.B1-2  ELSE Mem[R]↑.Hh.B1←
Mem[R]↑.Hh.B1+2;
IF Mem[ INT[R]+1]↑.Int>DestX  THEN Mem[ INT[R]+1]↑.Int←DestX  ELSE IF 
Mem[ INT[R]+1]↑.Int<Mem[ INT[Pp]+1]↑.Int  THEN Mem[ INT[R]+1]↑.Int←Mem[ INT[Pp]+1]↑.Int;
IF Mem[ INT[R]+2]↑.Int<Mem[ INT[Pp]+2]↑.Int  THEN Mem[ INT[R]+2]↑.Int←Mem[ INT[Pp]+2]↑.Int;
Mem[ INT[R]+4]↑.Int←Mem[ INT[R]+2]↑.Int;Mem[ INT[R]+2]↑.Int←-Mem[ INT[R]+2]↑.Int;
Mem[ INT[R]+6]↑.Int←Mem[ INT[R]+2]↑.Int;Mem[ INT[Qq]+4]↑.Int←-Mem[ INT[Qq]+4]↑.Int;
DestY←-DestY;Del2←Del2-TakeFraction[Del2-Del3,T];
IF Del2>0  THEN Del2←0;T←CrossingPoint[0,-Del2,-Del3];
IF T<268435456  THEN--416:--BEGIN SplitCubic[R,T,DestX,DestY];
S←Mem[R]↑.Hh.Rh;
IF Mem[ INT[S]+1]↑.Int>DestX  THEN Mem[ INT[S]+1]↑.Int←DestX  ELSE IF 
Mem[ INT[S]+1]↑.Int<Mem[ INT[R]+1]↑.Int  THEN Mem[ INT[S]+1]↑.Int←Mem[ INT[R]+1]↑.Int;
IF Mem[ INT[S]+2]↑.Int<DestY  THEN Mem[ INT[S]+2]↑.Int←DestY;
IF Mem[ INT[S]+2]↑.Int<Mem[ INT[R]+2]↑.Int  THEN Mem[ INT[S]+2]↑.Int←Mem[ INT[R]+2]↑.Int;
Mem[S]↑.Hh.B1←Mem[Pp]↑.Hh.B1;Mem[ INT[S]+4]↑.Int←Mem[ INT[S]+2]↑.Int;
Mem[ INT[S]+2]↑.Int←-Mem[ INT[S]+2]↑.Int;Mem[ INT[S]+6]↑.Int←Mem[ INT[S]+2]↑.Int;
Mem[ INT[Qq]+4]↑.Int←-Mem[ INT[Qq]+4]↑.Int; END--:416
 ELSE IF Mem[ INT[R]+2]↑.Int>DestY  THEN Mem[ INT[R]+2]↑.Int←DestY; END--:415--;
 END  ELSE--417:
IF ConstantX  THEN BEGIN IF Q#P  THEN BEGIN RemoveCubic[P];
IF CurSpec#Q  THEN  GOTO Label22  ELSE BEGIN CurSpec←P; GOTO Label10; END; END;
 END  ELSE IF  NOT PascalODD[Mem[Pp]↑.Hh.B1] THEN--414:
BEGIN Mem[ INT[Pp]+2]↑.Int←-Mem[ INT[Pp]+2]↑.Int;Mem[ INT[Pp]+6]↑.Int←-Mem[ INT[Pp]+6]↑.Int;
Mem[ INT[Qq]+4]↑.Int←-Mem[ INT[Qq]+4]↑.Int;Del1←-Del1;Del2←-Del2;Del3←-Del3;
DestY←-DestY;Mem[Pp]↑.Hh.B1←Mem[Pp]↑.Hh.B1+2; END--:414----:417--;Pp←Qq;
 IF Pp=Q THEN EXIT; ENDLOOP;IF ConstantX  THEN--418:--BEGIN Pp←P;DO Qq←Mem[Pp]↑.Hh.Rh;
IF  INT[Mem[Pp]↑.Hh.B1]>2  THEN BEGIN Mem[Pp]↑.Hh.B1←Mem[Pp]↑.Hh.B1+1;
Mem[ INT[Pp]+1]↑.Int←-Mem[ INT[Pp]+1]↑.Int;Mem[ INT[Pp]+5]↑.Int←-Mem[ INT[Pp]+5]↑.Int;
Mem[ INT[Qq]+3]↑.Int←-Mem[ INT[Qq]+3]↑.Int; END;Pp←Qq; IF Pp=Q THEN EXIT; ENDLOOP; END--:418----:413--;
P←Q;EXIT; EXITS Label22 => NULL} ENDLOOP; IF P=CurSpec THEN EXIT; ENDLOOP;EXITS Label10 => NULL}; END;--:406----419:--
END.