-- file: MFMovesImpl.mesa -- Pascal-to-Mesa translator output, translated at October 31, 1985 4:28:01 pm PST DIRECTORY PascalBasic, PascalWizardFiles, MFTypes, MFInteraction, MFMath, MFMoves; MFMovesImpl: PROGRAM IMPORTS PascalBasic, MFInteraction, MFMath EXPORTS MFMoves = PUBLIC BEGIN OPEN PascalBasic, PascalWizardFiles, MFTypes, MFInteraction, MFMath, MFMoves; --:298----308: Move: LONG POINTER TO ARRAY PascalInteger[0..5000] OF PascalInteger ← PascalStaticZone.NEW[ARRAY PascalInteger[0..5000] OF PascalInteger]; MovePtr: PascalInteger[0..MoveSize]; --:308----309: BisectStack: LONG POINTER TO ARRAY PascalInteger[0..785] OF PascalInteger ← PascalStaticZone.NEW[ARRAY PascalInteger[0..785] OF PascalInteger]; BisectPtr: PascalInteger[0..BistackSize]; --:269----311:-- MakeMoves: PROCEDURE[Xx0,Xx1,Xx2,Xx3,Yy0,Yy1,Yy2,Yy3: Scaled, XiCorr,EtaCorr: SmallNumber] = BEGIN X1, X2, X3, M, R, Y1, Y2, Y3, N, S, L:PascalInteger;Q, T, U, X2a, X3a, Y2a, Y3a:PascalInteger; IF(Xx3<Xx0)OR (Yy3<Yy0) THEN Confusion[109];L←16;BisectPtr←0; X1←Xx1-Xx0;X2←Xx2-Xx1;X3←Xx3-Xx2; IF Xx0>=XiCorr THEN R← PascalMODPower2Mask[(Xx0-XiCorr),65535] ELSE R←65535-( PascalMODPower2Mask[( -Xx0+XiCorr-1),65535]);M← PascalDIVPower2[(Xx3-Xx0+R),16];Y1←Yy1-Yy0;Y2←Yy2-Yy1; Y3←Yy3-Yy2; IF Yy0>=EtaCorr THEN S← PascalMODPower2Mask[(Yy0-EtaCorr),65535] ELSE S←65535-( PascalMODPower2Mask[( -Yy0+EtaCorr-1),65535]);N← PascalDIVPower2[(Yy3-Yy0+S),16]; IF(Xx3-Xx0>=268435456)OR (Yy3-Yy0>=268435456) THEN--313: BEGIN X1← PascalDIVPower2[(X1+XiCorr),1];X2← PascalDIVPower2[(X2+XiCorr),1];X3← PascalDIVPower2[(X3+XiCorr),1]; R← PascalDIVPower2[(R+XiCorr),1];Y1← PascalDIVPower2[(Y1+EtaCorr),1];Y2← PascalDIVPower2[(Y2+EtaCorr),1]; Y3← PascalDIVPower2[(Y3+EtaCorr),1];S← PascalDIVPower2[(S+EtaCorr),1];L←15; END--:313--; {WHILE TRUE DO BEGIN DO {--Label22:----314:--IF M=0 THEN--315: WHILE N>0 DO BEGIN MovePtr←MovePtr+1;Move↑[MovePtr]←1;N←N-1; END--:315-- ENDLOOP ELSE IF N=0 THEN--316:--Move↑[MovePtr]←Move↑[MovePtr]+M--:316 ELSE IF M+N=2 THEN--317:--BEGIN R←TwoToThe↑[L]-R;S←TwoToThe↑[L]-S; {WHILE L<30 DO BEGIN X3a←X3;X2a← PascalDIVPower2[(X2+X3+XiCorr),1]; X2← PascalDIVPower2[(X1+X2+XiCorr),1];X3← PascalDIVPower2[(X2+X2a+XiCorr),1];T←X1+X2+X3; R←R+R-XiCorr;Y3a←Y3;Y2a← PascalDIVPower2[(Y2+Y3+EtaCorr),1]; Y2← PascalDIVPower2[(Y1+Y2+EtaCorr),1];Y3← PascalDIVPower2[(Y2+Y2a+EtaCorr),1];U←Y1+Y2+Y3; S←S+S-EtaCorr;IF T<R THEN IF U<S THEN--318:--BEGIN X1←X3;X2←X2a; X3←X3a;R←R-T;Y1←Y3;Y2←Y2a;Y3←Y3a;S←S-U; END--:318-- ELSE BEGIN--320: BEGIN MovePtr←MovePtr+1;Move↑[MovePtr]←2; END--:320--; GOTO Label30; END ELSE IF U<S THEN BEGIN--319:--BEGIN Move↑[MovePtr]←Move↑[MovePtr]+1; MovePtr←MovePtr+1;Move↑[MovePtr]←1; END--:319--; GOTO Label30; END;L←L+1; END ENDLOOP ; R←R-XiCorr;S←S-EtaCorr; IF AbVsCd[X1+X2+X3,S,Y1+Y2+Y3,R]-XiCorr>=0 THEN--319: BEGIN Move↑[MovePtr]←Move↑[MovePtr]+1;MovePtr←MovePtr+1; Move↑[MovePtr]←1; END--:319-- ELSE--320:--BEGIN MovePtr←MovePtr+1; Move↑[MovePtr]←2; END--:320--;EXITS Label30 => NULL}; END--:317-- ELSE BEGIN L←L+1; BisectStack↑[BisectPtr+10]←L;BisectStack↑[BisectPtr+2]←X3; BisectStack↑[BisectPtr+1]← PascalDIVPower2[(X2+X3+XiCorr),1]; X2← PascalDIVPower2[(X1+X2+XiCorr),1]; X3← PascalDIVPower2[(X2+BisectStack↑[BisectPtr+1]+XiCorr),1]; BisectStack↑[BisectPtr]←X3;R←R+R+XiCorr;T←X1+X2+X3+R; Q← T /TwoToThe↑[L];BisectStack↑[BisectPtr+3]← T MOD TwoToThe↑[L]; BisectStack↑[BisectPtr+4]←M-Q;M←Q;BisectStack↑[BisectPtr+7]←Y3; BisectStack↑[BisectPtr+6]← PascalDIVPower2[(Y2+Y3+EtaCorr),1]; Y2← PascalDIVPower2[(Y1+Y2+EtaCorr),1]; Y3← PascalDIVPower2[(Y2+BisectStack↑[BisectPtr+6]+EtaCorr),1]; BisectStack↑[BisectPtr+5]←Y3;S←S+S+EtaCorr;U←Y1+Y2+Y3+S; Q← U /TwoToThe↑[L];BisectStack↑[BisectPtr+8]← U MOD TwoToThe↑[L]; BisectStack↑[BisectPtr+9]←N-Q;N←Q;BisectPtr←BisectPtr+11; GOTO Label22; END--:314--;IF BisectPtr=0 THEN GOTO Label10;--312:--BisectPtr←BisectPtr-11; X1←BisectStack↑[BisectPtr];X2←BisectStack↑[BisectPtr+1]; X3←BisectStack↑[BisectPtr+2];R←BisectStack↑[BisectPtr+3]; M←BisectStack↑[BisectPtr+4];Y1←BisectStack↑[BisectPtr+5]; Y2←BisectStack↑[BisectPtr+6];Y3←BisectStack↑[BisectPtr+7]; S←BisectStack↑[BisectPtr+8];N←BisectStack↑[BisectPtr+9]; L←BisectStack↑[BisectPtr+10]--:312--;EXIT; EXITS Label22 => NULL} ENDLOOP; END ENDLOOP ;EXITS Label10 => NULL}; END;--:311----321: SmoothMoves: PROCEDURE[B,T: PascalInteger] = BEGIN K:PascalInteger[1..MoveSize];A, Aa, Aaa:PascalInteger; IF T-B>=3 THEN BEGIN K←B+2;Aa←Move↑[K-1];Aaa←Move↑[K-2]; DO A←Move↑[K];IF ABS[A-Aa]>1 THEN--322: IF A>Aa THEN BEGIN IF Aaa>=Aa THEN IF A>=Move↑[K+1] THEN BEGIN Move↑[K-1]← Move↑[K-1]+1;Move↑[K]←A-1; END; END ELSE BEGIN IF Aaa<=Aa THEN IF A<=Move↑[K+1] THEN BEGIN Move↑[K-1]←Move ↑[K-1]-1;Move↑[K]←A+1; END; END--:322--;K←K+1;Aaa←Aa;Aa←A; IF K=T THEN EXIT; ENDLOOP; END; END;--:321----326:-- END.