-- file: MFEdgesImpl2.mesa -- Pascal-to-Mesa translator output, translated at October 31, 1985 4:28:01 pm PST DIRECTORY PascalBasic, PascalWizardFiles, MFTypes, MFProcArray, MFInteraction, MFMemory, MFMoves, MFEdges, MFParsing; MFEdgesImpl2: PROGRAM IMPORTS PascalBasic, MFProcArray, MFInteraction, MFMemory, MFMoves, MFEdges, MFParsing EXPORTS MFEdges = PUBLIC BEGIN OPEN PascalBasic, PascalWizardFiles, MFTypes, MFProcArray, MFInteraction, MFMemory, MFMoves, MFEdges, MFParsing; YReflectEdges: PROCEDURE = BEGIN P, Q, R:Halfword; P←Mem[ INT[CurEdges]+1]↑.Hh.Lh; Mem[ INT[CurEdges]+1]↑.Hh.Lh← INT[8191]-Mem[ INT[CurEdges]+1]↑.Hh.Rh; Mem[ INT[CurEdges]+1]↑.Hh.Rh← INT[8191]-P; Mem[ INT[CurEdges]+5]↑.Hh.Lh← INT[8191]-Mem[ INT[CurEdges]+5]↑.Hh.Lh; P←Mem[CurEdges]↑.Hh.Rh;Q←CurEdges;DO R←Mem[P]↑.Hh.Rh; Mem[P]↑.Hh.Rh←Q;Mem[Q]↑.Hh.Lh←P;Q←P;P←R; IF Q=CurEdges THEN EXIT; ENDLOOP; Mem[ INT[CurEdges]+4]↑.Int←0; END;--:336----337:-- XReflectEdges: PROCEDURE = BEGIN P, Q, R, S:Halfword;M:PascalInteger; P←Mem[ INT[CurEdges]+2]↑.Hh.Lh; Mem[ INT[CurEdges]+2]↑.Hh.Lh← INT[8192]-Mem[ INT[CurEdges]+2]↑.Hh.Rh; Mem[ INT[CurEdges]+2]↑.Hh.Rh← INT[8192]-P;M←( INT[4096]+Mem[ INT[CurEdges]+3]↑.Hh.Lh)*8+8; Mem[ INT[CurEdges]+3]↑.Hh.Lh←4096;P←Mem[CurEdges]↑.Hh.Rh;DO--339: Q←Mem[ INT[P]+1]↑.Hh.Rh;R←50000;WHILE Q#50000 DO BEGIN S←Mem[Q]↑.Hh.Rh; Mem[Q]↑.Hh.Rh←R;R←Q;Mem[R]↑.Hh.Lh←M-Mem[Q]↑.Hh.Lh;Q←S; END ENDLOOP ; Mem[ INT[P]+1]↑.Hh.Rh←R--:339--;--338:--Q←Mem[ INT[P]+1]↑.Hh.Lh; WHILE INT[Q]>1 DO BEGIN Mem[Q]↑.Hh.Lh←M-Mem[Q]↑.Hh.Lh;Q←Mem[Q]↑.Hh.Rh; END--:338-- ENDLOOP ;P←Mem[P]↑.Hh.Rh; IF P=CurEdges THEN EXIT; ENDLOOP;Mem[ INT[CurEdges]+4]↑.Int←0; END; --:337----340:-- YScaleEdges: PROCEDURE[S: PascalInteger] = BEGIN P, Q, Pp, R, Rr, Ss:Halfword;T:PascalInteger; IF(S*( INT[Mem[ INT[CurEdges]+1]↑.Hh.Rh]-4095)>=4096)OR (S*( INT[Mem[ INT[CurEdges]+1]↑.Hh .Lh]-4096)<=-4096) THEN BEGIN BEGIN IF Interaction=3 THEN NULL;PrintNl[133]; Print[403]; END;BEGIN HelpPtr←3;HelpLine↑[2]←404;HelpLine↑[1]←405; HelpLine↑[0]←406; END;PutGetError[]; END ELSE BEGIN Mem[ INT[CurEdges]+1]↑.Hh.Rh←S*( INT[Mem[ INT[CurEdges]+1]↑.Hh.Rh]-4095) +4095;Mem[ INT[CurEdges]+1]↑.Hh.Lh←S*( INT[Mem[ INT[CurEdges]+1]↑.Hh.Lh]-4096)+4096; --341:--P←CurEdges;DO Q←P;P←Mem[P]↑.Hh.Rh; FOR i:INT IN [ INT[2 ].. INT[S ]] DO T ← i; Pp←GetNode[2];Mem[Q]↑.Hh.Rh←Pp; Mem[P]↑.Hh.Lh←Pp;Mem[Pp]↑.Hh.Rh←P;Mem[Pp]↑.Hh.Lh←Q;Q←Pp;--335: R←Mem[ INT[P]+1]↑.Hh.Rh;Rr← INT[Pp]+1;WHILE R#50000 DO BEGIN Ss←GetAvail[]; Mem[Rr]↑.Hh.Rh←Ss;Rr←Ss;Mem[Rr]↑.Hh.Lh←Mem[R]↑.Hh.Lh;R←Mem[R]↑.Hh.Rh; END ENDLOOP ;Mem[Rr]↑.Hh.Rh←50000;R←Mem[ INT[P]+1]↑.Hh.Lh;Rr←49999; WHILE INT[R]>1 DO BEGIN Ss←GetAvail[];Mem[Rr]↑.Hh.Rh←Ss;Rr←Ss; Mem[Rr]↑.Hh.Lh←Mem[R]↑.Hh.Lh;R←Mem[R]↑.Hh.Rh; END ENDLOOP ;Mem[Rr]↑.Hh.Rh←R; Mem[ INT[Pp]+1]↑.Hh.Lh←Mem[49999]↑.Hh.Rh--:335--; ENDLOOP; IF Mem[P]↑.Hh.Rh=CurEdges--:341-- THEN EXIT; ENDLOOP;Mem[ INT[CurEdges]+4]↑.Int←0; END; END; --:340----342:-- XScaleEdges: PROCEDURE[S: PascalInteger] = BEGIN P, Q:Halfword; T:PascalInteger[0..65535];W:PascalInteger[0..7];Delta:PascalInteger; IF(S*( INT[Mem[ INT[CurEdges]+2]↑.Hh.Rh]-4096)>=4096)OR (S*( INT[Mem[ INT[CurEdges]+2]↑.Hh .Lh]-4096)<=-4096) THEN BEGIN BEGIN IF Interaction=3 THEN NULL;PrintNl[133]; Print[403]; END;BEGIN HelpPtr←3;HelpLine↑[2]←407;HelpLine↑[1]←405; HelpLine↑[0]←406; END;PutGetError[]; END ELSE IF(Mem[ INT[CurEdges]+2]↑.Hh.Rh#4096)OR (Mem[ INT[CurEdges]+2]↑.Hh.Lh#4096 ) THEN BEGIN Mem[ INT[CurEdges]+2]↑.Hh.Rh←S*( INT[Mem[ INT[CurEdges]+2]↑.Hh.Rh]-4096)+4096 ;Mem[ INT[CurEdges]+2]↑.Hh.Lh←S*( INT[Mem[ INT[CurEdges]+2]↑.Hh.Lh]-4096)+4096; Delta←8*(4096-S*Mem[ INT[CurEdges]+3]↑.Hh.Lh)+0;Mem[ INT[CurEdges]+3]↑.Hh.Lh←4096; --343:--Q←Mem[CurEdges]↑.Hh.Rh;DO P←Mem[ INT[Q]+1]↑.Hh.Rh; WHILE P#50000 DO BEGIN T←Mem[P]↑.Hh.Lh;W← PascalMODPower2Mask[T ,7]; Mem[P]↑.Hh.Lh←( INT[T]-W)*S+W+Delta;P←Mem[P]↑.Hh.Rh; END ENDLOOP ;P←Mem[ INT[Q]+1]↑.Hh.Lh; WHILE INT[P]>1 DO BEGIN T←Mem[P]↑.Hh.Lh;W← PascalMODPower2Mask[T ,7]; Mem[P]↑.Hh.Lh←( INT[T]-W)*S+W+Delta;P←Mem[P]↑.Hh.Rh; END ENDLOOP ;Q←Mem[Q]↑.Hh.Rh; IF Q=CurEdges--:343-- THEN EXIT; ENDLOOP;Mem[ INT[CurEdges]+4]↑.Int←0; END; END;--:342----344: XySwapEdges: PROCEDURE = BEGIN MMagic, NMagic:PascalInteger; P, Q, R, S:Halfword;--357:--MSpread:PascalInteger;J, Jj:PascalInteger[0..MoveSize];M, Mm:PascalInteger; Pd, Rd:PascalInteger;Pm, Rm:PascalInteger;W:PascalInteger;Ww:PascalInteger;Dw:PascalInteger;--:357----363: Extras:PascalInteger;Xw:PascalInteger[-3..3];K:PascalInteger;--:363----356: --365: MSpread← INT[Mem[ INT[CurEdges]+2]↑.Hh.Rh]-Mem[ INT[CurEdges]+2]↑.Hh.Lh; IF MSpread>MoveSize THEN Overflow[408,MoveSize]; FOR i:INT IN [ INT[0 ].. INT[MSpread ]] DO J ← i; Move↑[J]←50000--:356-- ENDLOOP;--355:--P←GetNode[2]; Mem[ INT[P]+1]↑.Hh.Rh←50000;Mem[ INT[P]+1]↑.Hh.Lh←0;Mem[P]↑.Hh.Lh←CurEdges; Mem[Mem[CurEdges]↑.Hh.Rh]↑.Hh.Lh←P;P←GetNode[2];Mem[ INT[P]+1]↑.Hh.Rh←50000; Mem[P]↑.Hh.Lh←Mem[CurEdges]↑.Hh.Lh;--:355--MMagic← INT[Mem[ INT[CurEdges]+2]↑.Hh.Lh]+Mem[ INT[CurEdges]+3]↑.Hh.Lh-4096; NMagic← INT[8]*Mem[ INT[CurEdges]+1]↑.Hh.Rh+12--:365--;DO Q←Mem[P]↑.Hh.Lh; IF INT[Mem[ INT[Q]+1]↑.Hh.Lh]>1 THEN SortEdges[Q];--358:--R←Mem[ INT[P]+1]↑.Hh.Rh; FreeNode[P,2];P←R;Pd←Mem[P]↑.Hh.Lh;Pm← PascalDIVPower2[Pd ,3];R←Mem[ INT[Q]+1]↑.Hh.Rh; Rd←Mem[R]↑.Hh.Lh;Rm← PascalDIVPower2[Rd ,3];W←0; {WHILE TRUE DO BEGIN IF Pm<Rm THEN Mm←Pm ELSE Mm←Rm;IF W#0 THEN--362: IF M#Mm THEN BEGIN IF Mm-MMagic>=MoveSize THEN Confusion[378]; Extras← (ABS[W]-1)/3; IF Extras>0 THEN BEGIN IF W>0 THEN Xw←3 ELSE Xw←-3;Ww←W-Extras*Xw; END ELSE Ww←W;DO J←M-MMagic; FOR i:INT IN [ INT[1 ].. INT[Extras ]] DO K ← i; S←GetAvail[];Mem[S]↑.Hh.Lh←NMagic+Xw; Mem[S]↑.Hh.Rh←Move↑[J];Move↑[J]←S; ENDLOOP;S←GetAvail[]; Mem[S]↑.Hh.Lh←NMagic+Ww;Mem[S]↑.Hh.Rh←Move↑[J];Move↑[J]←S;M←M+1; IF M=Mm THEN EXIT; ENDLOOP; END--:362--;IF Pd<Rd THEN BEGIN Dw←( PascalMODPower2Mask[Pd ,7])-4;--360: S←Mem[P]↑.Hh.Rh;BEGIN Mem[P]↑.Hh.Rh←Avail;Avail←P;DynUsed←DynUsed-1; END;P←S;Pd←Mem[P]↑.Hh.Lh;Pm← PascalDIVPower2[Pd ,3]; END ELSE BEGIN IF R=50000 THEN GOTO Label30;Dw←-(( PascalMODPower2Mask[Rd ,7])-4);--359: R←Mem[R]↑.Hh.Rh;Rd←Mem[R]↑.Hh.Lh;Rm← PascalDIVPower2[Rd ,3]; END;M←Mm;W←W+Dw; END ENDLOOP ;EXITS Label30 => NULL};--:358--P←Q;NMagic←NMagic-8; IF Mem[P]↑.Hh.Lh=CurEdges THEN EXIT; ENDLOOP; FreeNode[P,2];--364:--Move↑[MSpread]←0;J←0; WHILE Move↑[J]=50000 DO J←J+1 ENDLOOP ; IF J=MSpread THEN InitEdges[CurEdges] ELSE BEGIN Mm←Mem[ INT[CurEdges]+2]↑. Hh.Lh;Mem[ INT[CurEdges]+2]↑.Hh.Lh←Mem[ INT[CurEdges]+1]↑.Hh.Lh; Mem[ INT[CurEdges]+2]↑.Hh.Rh← INT[Mem[ INT[CurEdges]+1]↑.Hh.Rh]+1; Mem[ INT[CurEdges]+3]↑.Hh.Lh←4096;Jj←MSpread-1; WHILE Move↑[Jj]=50000 DO Jj←Jj-1 ENDLOOP ;Mem[ INT[CurEdges]+1]↑.Hh.Lh←J+Mm; Mem[ INT[CurEdges]+1]↑.Hh.Rh←Jj+Mm;Q←CurEdges;DO P←GetNode[2]; Mem[Q]↑.Hh.Rh←P;Mem[P]↑.Hh.Lh←Q;Mem[ INT[P]+1]↑.Hh.Rh←Move↑[J]; Mem[ INT[P]+1]↑.Hh.Lh←0;J←J+1;Q←P; IF INT[J]>Jj THEN EXIT; ENDLOOP;Mem[Q]↑.Hh.Rh←CurEdges; Mem[CurEdges]↑.Hh.Lh←Q; Mem[ INT[CurEdges]+5]↑.Hh.Lh← INT[Mem[ INT[CurEdges]+1]↑.Hh.Rh]+1; Mem[ INT[CurEdges]+5]↑.Hh.Rh←CurEdges;Mem[ INT[CurEdges]+4]↑.Int←0; END;--:364-- END;--:354----366:-- END.