[Oberon] FPGA - Bitmap Replace Horizontal Line
Tomas Kral
thomas.kral at email.cz
Tue May 23 09:15:39 CEST 2017
Hi,
Improved and slightly optimised version.
It shows all modes in action (paint | invert) = replace
Prerequisite: w and x are word aligned!
PROCEDURE ReplaceHLine(x, src, dst, w: INTEGER);
VAR bt: BYTE; w0, x0, wd: INTEGER; pix: SET;
BEGIN
(* (pix * {maskleft*8..31} * {0..maskright*8-1}) *)
w0 := w MOD 32; x0 := x MOD 32;
WHILE w > 0 DO
(* PaintHLine - Black line *)
DEC(w, 32); wd := -1;
IF w < 0 THEN wd := SYSTEM.VAL(INTEGER, SYSTEM.VAL(SET,
wd)*{0..w0}) END;
SYSTEM.GET(dst, pix);
SYSTEM.PUT(dst, SYSTEM.VAL(SET, LSL(wd, x0)) + pix);
IF x MOD 32 > 0 THEN
SYSTEM.GET(dst+4, pix); wd := ASR(wd, -(x0));
SYSTEM.PUT(dst+4, SYSTEM.VAL(SET, wd)*{0..x0-1} + pix)
END;
(* InvertHLine - White line *)
wd := -1;
IF w < 0 THEN wd := SYSTEM.VAL(INTEGER, SYSTEM.VAL(SET,
wd)*{0..w0}) END;
SYSTEM.GET(dst, pix);
SYSTEM.PUT(dst, SYSTEM.VAL(SET, LSL(wd, x0)) / pix);
IF x MOD 32 > 0 THEN
SYSTEM.GET(dst+4, pix); wd := ASR(wd, -(x0));
SYSTEM.PUT(dst+4, SYSTEM.VAL(SET, wd)*{0..x0-1} / pix)
END;
(* PaintHLine - Bitmap line *)
SYSTEM.GET(src, wd); INC(src, 4);
IF w < 0 THEN wd := SYSTEM.VAL(INTEGER, SYSTEM.VAL(SET,
wd)*{0..w0}) END;
SYSTEM.GET(dst, pix);
SYSTEM.PUT(dst, SYSTEM.VAL(SET, LSL(wd, x0)) + pix);
INC(dst, 4);
IF x MOD 32 > 0 THEN
SYSTEM.GET(dst, pix); wd := ASR(wd, -(x0));
SYSTEM.PUT(dst, SYSTEM.VAL(SET, wd)*{0..x0-1} + pix)
END
END
END ReplaceHLine;
On Mon, 22 May 2017 11:14:05 +0200
Jörg <joerg.straube at iaeth.ch> wrote:
> Hi Tomas
>
> These are the definitions Oberon uses
> 0 = background = black
> 1 = foreground = white
>
> Paint = src AND pat (1 in pattern is interpreted as "white")
> Invert = src XOR pat
> Replace = draw pattern with "col"
> black: src AND ~pat
> white: src AND pat (= paint)
>
> br
> Jörg
> -----Original Message-----
> From: Oberon [mailto:oberon-bounces at lists.inf.ethz.ch] On Behalf Of
> Tomas Kral
> Sent: Montag, 22. Mai 2017 10:34
> To: Oberon@ <lists.inf.ethz.ch.Oberon at lists.inf.ethz.ch>
> Subject: [Oberon] FPGA - Bitmap Replace Horizontal Line
>
> Hi,
>
> I was scratching my head over how to implement the `replace'
> mode. Seems more complicated than `invert' mode, which only applies
> `/' set operator in place of `+' in the PaintHLine.Mod (see earlier
> post)
>
> I thought to erase destination rectangle with $0000$ first than paint
> bitmap in the cleared area.
>
> To erase destination rectangle, appears to be done in two steps, paint
> black rectangle, then invert it.
>
> The replace mode can be done in three steps:
> [a] paint black rectangle
> [b] invert black rectangle
> [c] paint bitmap in the cleared area
>
> The above replace mode performs 3 times worse to Paint/Invert modes.
>
> What do you think?
>
--
Tomas Kral <thomas.kral at email.cz>
More information about the Oberon
mailing list