[Oberon] PO2013 - CopyBlock

Tomas Kral thomas.kral at email.cz
Tue Jul 7 20:01:44 CEST 2020


Recoded, there is now less code inside loops, so possibly faster to
earlier code.
Cannot get it scroll horizontally, though :-(

     IF dx = sx THEN (*vertical scroll w/ SYSTEM.COPY*)
     ELSIF n <= 0 THEN (*shift diagonal right*)
        SYSTEM.GET(sa0, src); SYSTEM.GET(sa0+d, dst);
        right := ROR(src, n)(**m1*);
        IF len > 0 THEN SYSTEM.PUT(sa0+d, (dst-m0)+(right*m0));
          left := (*ROR(src, n)*) right-m1;
          FOR sa1 := sa0+4 TO sa0 + len-4 BY 4 DO
            SYSTEM.GET(sa1, src); right:= ROR(src, n);
            SYSTEM.PUT(sa1+d, left+right*m1);
            left := right-m1
          END ;
          SYSTEM.GET(sa0+len, src); SYSTEM.GET(sa0+len+d, dst);
          right := ROR(src, n)*m1;
          SYSTEM.PUT(sa0+len+d, (dst*m2)+((left+right)-m2))
        ELSE SYSTEM.PUT(sa0+d, (dst-m3)+(right*m3))
        END
      ELSE (*n > 0 shift diagonal left*)
        SYSTEM.GET(sa0+len, src); SYSTEM.GET(sa0+len+d, dst);
        left:= ROR(src, n)(*-m1*); SYSTEM.GET(sa0+len+4, src); right := ROR(src, n)*m1;
        IF len > 0 THEN SYSTEM.PUT(sa0+len+d, (dst*m2)+(left-m1+right-m2));
          right := (*ROR(src, n)*) left*m1;
          FOR sa1 := sa0 + len-4 TO sa0+4 BY -4 DO
            SYSTEM.GET(sa1, src); left:= ROR(src, n);
            SYSTEM.PUT(sa1+d, left-m1+right);
            right := left*m1
          END ;
          SYSTEM.GET(sa0, src); SYSTEM.GET(sa0+d, dst);
          left := ROR(src, n)-m1;
          SYSTEM.PUT(sa0+d, (dst-m0)+((left+right)*m0))
        ELSE SYSTEM.GET(sa0+4, src); left:= left-m1; right := ROR(src, n)*m1;
          SYSTEM.PUT(sa0+d, (dst-m3)+((left+right)*m3))
        END
      END ;
      INC(sa0, step)
    END

-- 
Tomas Kral <thomas.kral at email.cz>


More information about the Oberon mailing list