duskos

dusk os fork
git clone git://git.alexwennerberg.com/duskos
Log | Files | Refs | README | LICENSE

commit 1a724a02a83fe007c349dd9cac1b35f02734d75c
parent 4a14081337b37338ed78f5f44582fa0008b8e2cb
Author: Virgil Dupras <hsoft@hardcoded.net>
Date:   Sun,  1 Jan 2023 12:12:28 -0500

gr/plane: add :pos! :tx+ :ty+ :fill

Also, remove gr/draw which has no utility anymore.

Diffstat:
Mfs/doc/gr/plane.txt | 11++++++++++-
Mfs/emul/uxn/gui.fs | 5++---
Dfs/gr/draw.fs | 16----------------
Mfs/gr/plane.fs | 14++++++++++++++
Mfs/sys/screen.fs | 6++++++
5 files changed, 32 insertions(+), 20 deletions(-)

diff --git a/fs/doc/gr/plane.txt b/fs/doc/gr/plane.txt @@ -37,5 +37,14 @@ Methods: :pixel! ( self -- ) Set a pixel at tx,ty to the value of field "color". -:fill ( width height self -- ) \ TODO +:pos! ( x y self -- ) + Set current target position. + +:x+ ( n self -- ) + Increase tx by n, wrapping around if necessary. + +:y+ ( n self -- ) + Increase ty by n, wrapping around if necessary. + +:fill ( width height self -- ) Fill the area in the rect tx,ty,width,height with field "color". diff --git a/fs/emul/uxn/gui.fs b/fs/emul/uxn/gui.fs @@ -1,7 +1,6 @@ \ Varvara GUI devices implementation require /sys/screen.fs ?f<< /lib/bit.fs -?f<< /gr/draw.fs ?f<< /emul/uxn/varvara.fs \ FG Mask: to properly handle FG/BG logic, we need to know which pixels are @@ -101,8 +100,8 @@ create _fgmask FGMASKSZ allot : screendeo ( dev port -- ) 0 to@! rgbchanged if \ we need to fill the screen with the new color - 0 screencolor to screen color - screen width screen height 0 0 drawrect then + 0 screencolor to screen color 0 0 screen :pos! + screen width screen height screen :fill then case ( dev ) \ V1=case $e of = _pixel endof $f of = _sprite endof diff --git a/fs/gr/draw.fs b/fs/gr/draw.fs @@ -1,16 +0,0 @@ -require /sys/screen.fs -?f<< /gr/color.fs - -: drawrect ( w h x y -- ) - to screen ty ( w h x ) - swap >r begin ( w x ) - dup to screen tx over >r begin ( w x ) - screen :pixel! 1 to+ screen tx next - 1 to+ screen ty next ( w x ) - 2drop ; - -: recttest - 255 0 0 r8g8b8>rgb24 to screen color - 42 42 ( w h ) - screen width >> 21 - - screen height >> 21 - ( w h x y ) drawrect ; diff --git a/fs/gr/plane.fs b/fs/gr/plane.fs @@ -30,4 +30,18 @@ extends Rect struct[ Plane : :pixel! ( self -- ) >r \ V1=self r@ color r@ _addr 16b !+ r> color 16 rshift swap c! ; + : :pos! ( x y self -- ) tuck to ty to tx ; + + : :ty+ ( n self -- ) >r \ V1=self + r@ ty + dup r@ height >= if r@ height - then r> to ty ; + + : :tx+ ( n self -- ) >r \ V1=self + r@ tx + dup r@ width >= if r@ width - then r> to tx ; + + : :fill ( width height self -- ) >r \ V1=self + >r V1 tx begin ( w x ) + dup V1 to tx over >r begin ( w x ) + V1 :pixel! 1 V1 :tx+ next + 1 V1 :ty+ next ( w x ) + 2drop rdrop ; ]struct diff --git a/fs/sys/screen.fs b/fs/sys/screen.fs @@ -7,3 +7,9 @@ extends Plane struct[ Screen ]struct 0 structbind Screen screen + +: recttest + screen :activate + 255 0 0 r8g8b8>rgb24 to screen color + screen width >> 21 - screen height >> 21 - screen :pos! + 42 42 ( w h ) screen :fill ;