[Oberon] PO2013 - CopyBlock

Tomas Kral thomas.kral at email.cz
Fri Jul 3 23:28:32 CEST 2020


> - Define „simpler“ (less code, faster code..)

I have coded this, which is part of me modified PO2013 CopyBlock(), I am revising
now again.
It does things as per picture, where I can drag a dialog frame all directions.
Tested 1 bit, 4 bit colour frame.
`len' is defined as target word span in bytes, `m0,m1,m2,m3' sets as in original.

When I optimise it using ROR as commented in the code (requires also [-*]m1),
I got by two words shorter rsc code, cannot tell how much faster it is with ROR???
The `IF's inside loops make the code shorter, but not faster, I know, but seems symetric.
      
      (* BitBlit TK 22.10.2018 1|4 bit colour *)

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

-- 
Tomas Kral <thomas.kral at email.cz>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bitblit.png
Type: image/png
Size: 36826 bytes
Desc: not available
URL: <http://lists.inf.ethz.ch/pipermail/oberon/attachments/20200703/7b109afe/attachment.png>


More information about the Oberon mailing list