[Oberon] Fw: FPGA - Bitmaps.Mod

Jörg joerg.straube at iaeth.ch
Fri Apr 7 11:43:45 CEST 2017


Hi Thomas

In chapter 8.2 of this document
https://www.inf.ethz.ch/personal/wirth/ProjectOberon/PO.System.pdf
you'll learn the internals of the memory allocation in ProjectOberon.

In Oberon a pointer you allocate with NEW has a specific TYPE.
Each TYPE is identified by a type tag.
NEW does not only allocate the memory but stores the type tag with it as
well. Part of the type tag is the size of the type and hence the size of the
allocated memory.

"Normal" Oberon-7 does not allow you to allocate memory for a type with
floating/dynamic size.
However, a workaround could look like this:

MODULE Bitmaps;
IMPORT Kernel;
TYPE
  Bitmap = POINTER TO RECORD w, h, size, base: INTEGER END;
PROCEDURE New(W, H: INTEGER): Bitmap;
  VAR b: Bitmap;
  BEGIN
    NEW(b);
    IF b # NIL THEN
      b.w := W; b.h := H; b.size := (W+7) DIV 8 * H; (* nbr of bytes *)
      Kernel.New(b.base, SYSTEM.ADR(b.size));
      IF b.base = NIL THEN b := NIL END
    END
  RETURN b
  END New;

END Bitmaps.

-----Original Message-----
From: Oberon [mailto:oberon-bounces at lists.inf.ethz.ch] On Behalf Of Tomas
Kral
Sent: Donnerstag, 6. April 2017 10:04
To: Oberon@ <lists.inf.ethz.ch Oberon at lists.inf.ethz.ch>
Subject: [Oberon] Fw: FPGA - Bitmaps.Mod

Hi,

I am not getting much response re below forward.
I try now to formulate my question better.

[a]
I realised I cannot use this construct under V07
SYSTEM.NEW(addr, size);
Correct?

[b]
I tried to typecast it with SYSTEM.VAL
NEW(SYSTEM.VAL(addr, size));

But type cast is not allowed, possible reason as this would get
difficult job for the garbage collector?

Perhaps it is right ater all, I can use fix bitmap size flavours, 1/1
or 1/2 or 1/4 size of the left display viewer. As the purpose of a
bitmap is to show it in the viewer in the end anyway, clipped to a
visible area.  

[c]
That brings another question of SYSTEM function procedure
SYSTEM.VAL. Is it a type cast similar to Pascal ^((type) (variable))?
Need to understand better.

Many thanks
Tomas  


Begin forwarded message:

Date: Wed, 5 Apr 2017 17:59:27 +0200
From: Tomas Kral <thomas.kral at email.cz>
To: <oberon at lists.inf.ethz.ch>
Subject: Re: [Oberon] FPGA - Bitmaps.Mod


Hi Wojciech,

Yes, I agree.

But, I do not know, how to allocate dynamic structures on Oberon
V07. As an example I am looking into the `Pictures.Mod' code, taken from
ETH Oberon.

This dynamic allocation.
...
TYPE Addr = POINTER TO RECORD END;
     refr : Addr;
VAR size: LONGINT;
...
size := P.wth * P.height;
SYSTEM.NEW(P.refr, size+10);
P.address := SYSTEM.VAL(ADDRESS,P.refr);
NEW(P.bitmap);
Bitmaps.Define(P.bitmap,P.width,P.height,P.depth,P.address);
...

How I could allocate dynamically in Oberon07, NEW(v) allows for v as
variable?

Tomas 

On Wed, 5 Apr 2017 12:16:29 +0000
"Skulski, Wojciech" <skulski at pas.rochester.edu> wrote:

> > I am looking for a better way, as I believe the size needed can be
> > calculated from Width, Height of the bitmap.
> 
> Yes. The size of the display should not be fixed with inline numbers.
> I am thinking that a usable System can be deployed with 800x600
> display. In general, the size of the display can/ should be changed
> either on the fly or during compilation, which probably is not very
> difficult to implement in a simple design which the FPGA Oberon
> really is.
> 
> W.
> ________________________________________
> From: Oberon [oberon-bounces at lists.inf.ethz.ch] on behalf of Tomas
> Kral [thomas.kral at email.cz] Sent: Wednesday, April 5, 2017 5:26 AM
> To: Oberon at lists.inf.ethz.ch
> Subject: [Oberon] FPGA - Bitmaps.Mod
> 
> Hi,
> 
> As part of my exercise I have converted ETH `Bitmaps.Mod' to V07. It
> should be the basis for a bit map editor - `Paint.Mod' - next exercise
> of mine.
> 
> It is far from perfect, just made it to compile under V07, without
> much thoughts.
> 
> Few notes>>>
> 
> [a] Bitmaps.DisplayBlock* is just copied from Display.CopyBlock*
> with source and destination addresses modified as thus:
> 
> sa := B.address + u0*4 + sy*128; da := Display.Base + v0*4 + dy*128;
> 
> I am looking for a better idea, as I believe bitmap needs to be
> clipped to fit into a visible area of a target frame.
> 
> [b] New bitmap is allocated as a constant buffer
> CONST
>   BufSize = 10000H;
> ...
> BEGIN
>   NEW(buffer)
> END Bitmaps.
> 
> I am looking for a better way, as I believe the size needed can be
> calculated from Width, Height of the bitmap.
> 
> TYPE
>   Bitmap* = POINTER TO BitmapDesc;
>   BitmapDesc* = RECORD  (* cf. Display.DisplayBlock  *)
>     width*, height*, depth*: INTEGER;  (* offset 0, 2, 4 *)
>     wth*, address*: LONGINT;  (* offset 8, 12 *)
>     size: LONGINT
> END;
> 
> [c] Bitmaps are allocated as an array of CHAR's. Is it a good idea to
> use BYTE's instead?
> 
> P.S. I could enclose the whole module, but I am not sure if it is
> allowed by the list server.
> 
> Many thanks
> Tomas
> --
> Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related
> systems
>
https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.inf.ethz.ch_mailm
an_listinfo_oberon&d=DwICAg&c=kbmfwr1Yojg42sGEpaQh5ofMHBeTl9EI2eaqQZhHbOU&r=
uUiA_zLpwaGJIlq-_BM9w1wVOuyqPwHi3XzJRa-ybV0&m=DvMJJZHAOKHy3Hs2z-YZccHRjLN1IH
NBtOGNQLn5RlM&s=F7FNN9bt9xLyOvUo8KvsencklngbrOcpcuN-9SYl_Gk&e=
> -- Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related
> systems https://lists.inf.ethz.ch/mailman/listinfo/oberon

--
Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related systems
https://lists.inf.ethz.ch/mailman/listinfo/oberon
--
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