[Oberon] FPGA - Bitmap.Mod optimising

Tomas Kral thomas.kral at email.cz
Tue Sep 19 13:24:59 CEST 2017


Hi,

I have managed to optimise code, its shorter now, cannot judge
if at all faster. 

The following procedure proved useful.

(* Shift & clip source word into pix sets according to x coordinate and
w width *)

PROCEDURE Src2Pix(x, w, src: INTEGER; VAR pix1, pix2: SET);
  VAR x0, w0: INTEGER;
BEGIN
 
  (* (pix * {maskleft*8..31} * {0..maskright*8-1}) *)

  w0 :=  w MOD 32; x0 := x MOD 32;

  SYSTEM.GET(src, pix2);
  IF w < 0 THEN pix2 := pix2*{0..w0} END;
  pix1 := LSL(pix2, x0);
    
  IF x0 > 0 THEN pix2 := ASR(pix2, -x0)*{0..x0-1}
  ELSE pix2 := {}
  END

END Src2Pix;

Copying bitmap lines now appears only on a few lines of code.

(* CopyBLine1 - Copy bitmap line in paint mode *)

PROCEDURE CopyBLine1(x, src, dst, w: INTEGER);
  VAR pix1, pix2, pix: SET;   
BEGIN

  WHILE w > 0 DO

    DEC(w, 32); Src2Pix(x, w, src, pix1, pix2); INC(src, 4);
    SYSTEM.GET(dst, pix); SYSTEM.PUT(dst, pix1+pix); 
    INC(dst, 4); SYSTEM.GET(dst, pix); SYSTEM.PUT(dst, pix2+pix)
    
  END
END CopyBLine1;

Pushing updated sources to my GIT repository.

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


More information about the Oberon mailing list