[Oberon] FPGA - Screen.Mod

Paul Reed paulreed at paddedcell.com
Sat Sep 16 19:23:51 CEST 2017


Sorry Tomas, that was more of an exercise than I intended, it appears there's
no SYSTEM.MSK anymore (maybe Prof. Wirth removed it after seeing my
code)... ;-)

I found another implementation for the inner loop, which better corresponds
with the kind of manipulations in Display.Mod:

  FOR x := 0 TO row-4 BY 4 DO
    SYSTEM.GET(a, bits); INC(a, 4); (*reverse bits*)
    bits := ROR(bits, 4) * MASK4 + ROR(bits, 28) * (-MASK4);
    bits := ROR(bits, 2) * MASK2 + ROR(bits, 30) * (-MASK2);
    Files.WriteSet(R, ROR(bits, 1) * MASK1 + ROR(bits, 31) * (-MASK1))
  END

where

CONST MASK4 = {0..3, 8..11, 16..19, 24..27}; (*0F0F0F0F*)
  MASK2 = {0, 1, 4, 5, 8, 9, 12, 13, 16, 17, 20, 21, 24, 25, 28, 29};
(*33333333*)
  MASK1 = {0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30};
(*55555555*)

Apologies,
Paul


> Hi Tomas,
>
>> I am looking for `Screen.Mod' module (mainly its `Screen.Gr[a]b'
>> command)
>> hinted in PO2013 pictures. I have completed early version of
>> `Bitmaps.Mod' supporting basic set of raster operations.
>
> It's an interesting exercise.  The following is a routine I sent to Prof.
> Wirth which I believe is what he used (I had it in System; it seems he
> chose to put it in a separate module called Screen; you may want to add it
> to your Bitmaps.Mod instead).  You should easily be able to change this to
> your needs, e.g. whether you want white-on-black or black-on-white, or any
> other colours for that matter...
>
> With thanks to Florian Negele for the bit-reversal code!
>
> HTH
> Paul
>
> MODULE System;
> ...
>
>   PROCEDURE Grab*;
>     VAR S: Texts.Scanner; F: Files.File; R: Files.Rider;
>       x, y, a, bits: INTEGER;
>   BEGIN GetArg(S);
>     IF S.class = Texts.Name THEN
>       Texts.WriteString(W, "System.Grab "); Texts.WriteString(W, S.s);
>       Texts.Append(Oberon.Log, W.buf);
>       F := Files.New(S.s);
>       IF F # NIL THEN Files.Set(R, F, 0);
>         (*Windows Bitmap File Header*)
>         Files.Write(R, "B"); Files.Write(R, "M");
>         Files.WriteInt(R, 14+40+8+128*768); (*file size*)
>         Files.WriteInt(R, 0); (*reserved*)
>         Files.WriteInt(R, 14+40+8); (*offset of bits*)
>         (*Windows Bitmap WinHeader*)
>         Files.WriteInt(R, 40); (*header size*)
>         Files.WriteInt(R, 1024); Files.WriteInt(R, 768); (*w,h*)
>         Files.WriteInt(R, 00010001H); (*planes, bpp*)
>         Files.WriteInt(R, 0); (*no compression*)
>         Files.WriteInt(R, 0); (*size of bitmap - can be 0 if
> uncompressed*)
>         Files.WriteInt(R, 15000); Files.WriteInt(R, 15000); (*h&vres in
> ppm*)
>         Files.WriteInt(R, 2); Files.WriteInt(R, 2); (*colours used,
> important*)
>         (*colour table*)
>         Files.WriteInt(R, 0); Files.WriteInt(R, 0FFFFFFH); (*padded rgb*)
>         (*bitmap*)
>         a := Display.base;
>         FOR y := 0 TO 767 DO
>           FOR x := 0 TO 124 BY 4 DO
>             SYSTEM.GET(a, bits); INC(a, 4);
>             bits := SYSTEM.MSK(ROR(bits, 4), 00F0F0F0FH)
>               + SYSTEM.MSK(ROR(bits, 28), 0F0F0F0F0H);
>             bits := SYSTEM.MSK(ROR(bits, 2), 033333333H)
>               + SYSTEM.MSK(ROR(bits, 30), 0CCCCCCCCH);
>             bits := SYSTEM.MSK(ROR(bits, 1), 055555555H)
>               + SYSTEM.MSK(ROR(bits, 31), 0AAAAAAAAH);
>             Files.WriteInt(R, bits)
>           END
>         END;
>         Files.Register(F); Texts.WriteString(W, " done.")
>       ELSE Texts.WriteString(W, " failed.")
>       END;
>       EndLine
>     END
>   END Grab;
> ...
>
> System.Grab Screen0.bmp
>
>
>
> --
> Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related systems
> https://lists.inf.ethz.ch/mailman/listinfo/oberon
>




More information about the Oberon mailing list