Author: wmb
Date: 2008-12-04 10:17:25 +0100 (Thu, 04 Dec 2008)
New Revision: 1009
Modified:
cpu/x86/fb8-ops.fth
cpu/x86/pc/olpc/devices.fth
dev/geode/display/gp.fth
dev/geode/display/gxfb.fth
dev/olpc/touchpad/touchpad.fth
ofw/termemu/fb8.fth
ofw/termemu/framebuf.fth
ofw/termemu/loadfb.fth
Log:
Merged 16-bit framebuffer ops into the fb8 code to reduce duplication,
and added support for 32-bit framebuffers too.
Modified: cpu/x86/fb8-ops.fth
===================================================================
--- cpu/x86/fb8-ops.fth 2008-11-17 23:50:36 UTC (rev 1008)
+++ cpu/x86/fb8-ops.fth 2008-12-04 09:17:25 UTC (rev 1009)
@@ -60,7 +60,7 @@
di push \ save up
\ Stack: 0 di 1 si 2 bp
- \ 3 bg 4 fg 5 bytes/line 9 scradr 7 height 8 width 9 fontby a fntadr
+ \ 3 bg 4 fg 5 bytes/line 6 scradr 7 height 8 width 9 fontby a fntadr
8 /n* [sp] ax mov \ Width in pixels
7 # ax add \ Round up ..
@@ -126,7 +126,7 @@
\ (break-lo)(cursor-y) (winbot-breaklo) (") (emu-bytes/line)
\ src > dst, so move from start towards end
-code fb8-window-move ( src-start dst-start size bytes/line #move/line -- )
+code fb-window-move ( src-start dst-start size bytes/line #move/line -- )
\ tos=#move/line
cld ds ax mov ax es mov \ Setup for stos
@@ -173,6 +173,239 @@
2 /n* # sp add \ Pop 2 cells
c;
+\ ax bx cx dx si di bp
+\ Invert foreground and background colors within a rectangular region
+code fb16-invert ( adr width height bytes/line fg-color bg-color -- )
+ cld ds ax mov ax es mov \ Setup for stos
+ ax pop \ background color
+ bx pop \ foreground color
+ si push \ Save si
+ di push \ Save di
+ bp push \ Save bp
+ ax bp mov \ backround in bp
+ 3 /n* [sp] si mov \ bytes/line in si
+ 4 /n* [sp] dx mov \ height in dx
+ 5 /n* [sp] cx mov \ width in cx
+ 6 /n* [sp] di mov \ adr in di
+
+ cx si sub \ Account for increment of pointer during inner loop
+ cx si sub \ (2 bytes per pixel)
+
+ \ Execute word-by-word
+
+ begin \ Outer loop over scan lines
+ begin \ Inner loop across width of character
+ 0 [di] ax op: mov \ Read word
+ ax bx op: cmp \ Foreground?
+ = if
+ bp ax mov \ Set to background
+ else
+ ax bp op: cmp \ Background?
+ = if
+ bx ax mov \ Set to foreground
+ then
+ then
+ ax op: stos \ Write it back
+ cx dec \ Decrement pixel counter
+ 0= until \ End inner loop
+ si di add \ increment adr to next line
+ 5 /n* [sp] cx mov \ restore starting width value
+ dx dec \ decrement height
+ 0= until \ End outer loop when height=0
+
+ bp pop \ Restore bp
+ di pop \ Restore di
+ si pop \ Restore si
+ 4 /n* # sp add \ Remove stuff from stack
+c;
+
+\ Draws a character from a 1-bit-deep font into an 8-bit-deep frame buffer
+code fb16-paint
+( fontadr fontbytes width height screenadr bytes/line foreground background -- )
+ cld ds ax mov ax es mov \ Setup for stos
+ bp push \ save rp
+ si push \ save ip
+ di push \ save up
+
+ \ Stack: 0 di 1 si 2 bp
+ \ 3 bg 4 fg 5 bytes/line 6 scradr 7 height 8 width 9 fontby a fntadr
+
+ 8 /n* [sp] ax mov \ Width in pixels
+ 7 # ax add \ Round up ..
+ ax 3 # shr \ Convert to bytes
+ ax 9 /n* [sp] sub \ Account for incrementing of byte pointer
+ \ item 9 is now the excess to add for the next scan line
+
+\ 4 /n* [sp] bl mov \ Foreground
+ 3 /n* [sp] bx mov \ Background
+ 6 /n* [sp] di mov \ Screenadr - start address in frame buffer
+ 7 /n* [sp] bp mov \ Height - character height in pixels
+ h# 0a /n* [sp] si mov
+\ Fontadr - start address (of this char) in font table
+
+
+ 8 /n* [sp] dx mov \ Width - character width in pixels
+ dx dx add \ Character width in bytes
+ dx 5 /n* [sp] sub \ Account for pointer incrementing in inner loop
+
+ begin \ Outer loop - for all scan lines in char
+ 8 /n* [sp] dx mov \ Width - character width in pixels
+ begin \ Middle loop - over the font scan line pixels
+ dx dx or
+ 0<> while
+ 8 # dx cmp
+ > if
+ 8 # cx mov
+ else
+ dx cx mov
+ then
+ cx dx sub \ Reduce master width
+
+ al lodsb \ Get 8 font bits into al
+ al bl mov \ Move them into bl
+
+ \ The inner loop handles the 1-8 pixels contained in one byte of
+ \ the font data.
+ begin \ Inner loop - up to 8 pixel at a time
+ bl shl \ Select and test font bit
+ carry? if
+ 4 /n* [sp] ax mov \ Use foreground color
+ else
+ 3 /n* [sp] ax mov \ Use background color
+ then
+ ax op: stos \ Write to frame buffer
+ cx dec \ Increment width pixel count
+ 0= until \ Repeat until width count = 0
+ repeat
+
+ 9 /n* [sp] si add \ Next scan line in font table
+ 5 /n* [sp] di add \ Increment frame buffer addr to next line
+ bp dec \ Decrement height counter
+ 0= until \ Repeat until height count = 0
+
+ di pop si pop bp pop \ Restore Forth virtual machine registers
+ 8 /n* # sp add
+c;
+
+\ ax bx cx dx si di bp
+\ Invert foreground and background colors within a rectangular region
+code fb32-invert ( adr width height bytes/line fg-color bg-color -- )
+ cld ds ax mov ax es mov \ Setup for stos
+ ax pop \ background color
+ bx pop \ foreground color
+ si push \ Save si
+ di push \ Save di
+ bp push \ Save bp
+ ax bp mov \ backround in bp
+ 3 /n* [sp] si mov \ bytes/line in si
+ 4 /n* [sp] dx mov \ height in dx
+ 5 /n* [sp] cx mov \ width in cx
+ 6 /n* [sp] di mov \ adr in di
+
+ cx si sub \ Account for increment of pointer during inner loop
+ cx si sub \ (4 bytes per pixel)
+ cx si sub \ (4 bytes per pixel)
+ cx si sub \ (4 bytes per pixel)
+
+ \ Execute word-by-word
+
+ begin \ Outer loop over scan lines
+ begin \ Inner loop across width of character
+ 0 [di] ax mov \ Read word
+ ax bx cmp \ Foreground?
+ = if
+ bp ax mov \ Set to background
+ else
+ ax bp cmp \ Background?
+ = if
+ bx ax mov \ Set to foreground
+ then
+ then
+ ax stos \ Write it back
+ cx dec \ Decrement pixel counter
+ 0= until \ End inner loop
+ si di add \ increment adr to next line
+ 5 /n* [sp] cx mov \ restore starting width value
+ dx dec \ decrement height
+ 0= until \ End outer loop when height=0
+
+ bp pop \ Restore bp
+ di pop \ Restore di
+ si pop \ Restore si
+ 4 /n* # sp add \ Remove stuff from stack
+c;
+
+\ Draws a character from a 1-bit-deep font into a 32bpp frame buffer
+code fb32-paint
+( fontadr fontbytes width height screenadr bytes/line foreground background -- )
+ cld ds ax mov ax es mov \ Setup for stos
+ bp push \ save rp
+ si push \ save ip
+ di push \ save up
+
+ \ Stack: 0 di 1 si 2 bp
+ \ 3 bg 4 fg 5 bytes/line 6 scradr 7 height 8 width 9 fontby a fntadr
+
+ 8 /n* [sp] ax mov \ Width in pixels
+ 7 # ax add \ Round up ..
+ ax 3 # shr \ Convert to bytes
+ ax 9 /n* [sp] sub \ Account for incrementing of byte pointer
+ \ item 9 is now the excess to add for the next scan line
+
+\ 4 /n* [sp] bl mov \ Foreground
+ 3 /n* [sp] bx mov \ Background
+ 6 /n* [sp] di mov \ Screenadr - start address in frame buffer
+ 7 /n* [sp] bp mov \ Height - character height in pixels
+ h# 0a /n* [sp] si mov
+\ Fontadr - start address (of this char) in font table
+
+
+ 8 /n* [sp] dx mov \ Width - character width in pixels
+
+ dx dx add \ Character width in bytes
+ dx dx add \ Character width in bytes
+
+ dx 5 /n* [sp] sub \ Account for pointer incrementing in inner loop
+
+ begin \ Outer loop - for all scan lines in char
+ 8 /n* [sp] dx mov \ Width - character width in pixels
+ begin \ Middle loop - over the font scan line pixels
+ dx dx or
+ 0<> while
+ 8 # dx cmp
+ > if
+ 8 # cx mov
+ else
+ dx cx mov
+ then
+ cx dx sub \ Reduce master width
+
+ al lodsb \ Get 8 font bits into al
+ al bl mov \ Move them into bl
+
+ \ The inner loop handles the 1-8 pixels contained in one byte of
+ \ the font data.
+ begin \ Inner loop - up to 8 pixel at a time
+ bl shl \ Select and test font bit
+ carry? if
+ 4 /n* [sp] ax mov \ Use foreground color
+ else
+ 3 /n* [sp] ax mov \ Use background color
+ then
+ ax stos \ Write to frame buffer
+ cx dec \ Increment width pixel count
+ 0= until \ Repeat until width count = 0
+ repeat
+
+ 9 /n* [sp] si add \ Next scan line in font table
+ 5 /n* [sp] di add \ Increment frame buffer addr to next line
+ bp dec \ Decrement height counter
+ 0= until \ Repeat until height count = 0
+
+ di pop si pop bp pop \ Restore Forth virtual machine registers
+ 8 /n* # sp add
+c;
+
headers
\ LICENSE_BEGIN
\ Copyright (c) 2006 FirmWorks
Modified: cpu/x86/pc/olpc/devices.fth
===================================================================
--- cpu/x86/pc/olpc/devices.fth 2008-11-17 23:50:36 UTC (rev 1008)
+++ cpu/x86/pc/olpc/devices.fth 2008-12-04 09:17:25 UTC (rev 1009)
@@ -310,8 +310,6 @@
fload ${BP}/cpu/x86/pc/olpc/chipinit.fth
[then]
-fload ${BP}/cpu/x86/fb16-ops.fth
-fload ${BP}/ofw/termemu/fb16.fth
0 0 " 1,1" " /pci" begin-package
fload ${BP}/dev/olpc/dcon/dconsmb.fth \ SMB access to DCON chip
fload ${BP}/dev/olpc/dcon/dcon.fth \ DCON control
Modified: dev/geode/display/gp.fth
===================================================================
--- dev/geode/display/gp.fth 2008-11-17 23:50:36 UTC (rev 1008)
+++ dev/geode/display/gp.fth 2008-12-04 09:17:25 UTC (rev 1009)
@@ -3,8 +3,8 @@
alias depth+ wa+
-: dst! ( x y -- ) bytes/line16 * swap depth+ 0 gp! ;
-: src! ( x y -- ) bytes/line16 * swap depth+ 4 gp! ;
+: dst! ( x y -- ) bytes/line * swap depth+ 0 gp! ;
+: src! ( x y -- ) bytes/line * swap depth+ 4 gp! ;
: stride! ( dst-stride src-stride -- ) wljoin 8 gp! ;
: wh! ( width height -- ) swap wljoin h# c gp! ;
\ : fg! ( foreground-color -- ) h# 10 gp! ;
@@ -25,10 +25,18 @@
\ Finished with all the queued-up commands
: gp-wait-done ( -- ) begin h# 44 gp@ 1 and 0= until ;
+0 instance value rop-high
+
\ Do this once
: gp-setup ( -- )
frame-buffer-adr >physical dup dup offset!
- bytes/line16 dup stride!
+ bytes/line dup stride!
+ bytes/pixel case
+ 1 of 0 endof \ 8-bpp 3:3:2
+ 2 of h# 6000.0000 endof \ 16-bpp 5:6:5
+ 4 of h# 8000.0000 endof \ 32-bpp 8:8:8:8
+ endcase
+ to rop-high
;
\ This one is a big win compared to doing it with the CPU
@@ -36,7 +44,7 @@
: gp-move ( src-x,y dst-x,y w,h -- )
gp-wait-ready
wh! dst! src!
- h# 6000.00cc ropmode! \ RGB565, Output = source
+ h# cc rop-high or ropmode! \ Output = source
1 blt! \ Source data from framebuffer
gp-wait-done
;
@@ -46,7 +54,7 @@
: gp-fill ( color dst-x,y w,h -- )
gp-wait-ready
wh! dst! 0 pattern!
- h# 6000.00f0 ropmode! \ RGB565, Output = pattern
+ h# f0 rop-high or ropmode! \ Output = pattern
h# 0 blt! \ No source or destination data from framebuffer
gp-wait-done
;
@@ -61,7 +69,7 @@
screen-height char-height - gp-move
;
: gp-fill-last-line ( color -- )
- bg16 0 screen-height char-height - screen-width char-height gp-fill
+ bg 0 screen-height char-height - screen-width char-height gp-fill
;
[then]
@@ -75,14 +83,13 @@
0 line# rc>window ( src-x,y dst-x,y r: delta )
#columns #lines r@ - rc>pixels ( src-x,y dst-x,y w,h r: delta )
gp-move ( r: delta )
- screen-background16 ( color r: delta )
+ screen-background ( color r: delta )
0 #lines r@ - rc>window ( color dst-x,y r: delta )
#columns r> rc>pixels ( color dst-x,y w,h )
gp-fill
;
-: gp-fb16-install ( -- )
- fb16-install
+: gp-install ( -- )
gp-setup
['] fbgeode-delete-lines is delete-lines
;
@@ -92,10 +99,7 @@
default-font set-font
/scanline bytes/pixel / #scanlines ( width height )
over char-width / over char-height / ( width height rows cols )
- bytes/pixel case ( width height rows cols )
- 1 of fb8-install endof ( )
- 2 of gp-fb16-install endof ( )
- endcase ( )
+ bytes/pixel fb-install gp-install ( )
init-hook
;
Modified: dev/geode/display/gxfb.fth
===================================================================
--- dev/geode/display/gxfb.fth 2008-11-17 23:50:36 UTC (rev 1008)
+++ dev/geode/display/gxfb.fth 2008-12-04 09:17:25 UTC (rev 1009)
@@ -21,7 +21,7 @@
then
;
-: /fb ( -- ) /scanline #scanlines * bytes/pixel * ; \ Size of framebuffer
+: /fb ( -- ) /scanline #scanlines * ; \ Size of framebuffer
0 instance value dc-base
0 instance value gp-base
@@ -278,7 +278,13 @@
\ TGEN, GDEN, VDEN, PALB, A20M, A18M, (8BPP=0 16BPP=100)
\ The "c" part (A20M, A18M) is unnecessary for LX, but harmless
\ The "2" part (PALB) is unnecessary for GX, but harmless
- h# c200.0019 bytes/pixel 2 = if h# 0100 or then 8 dc!
+ h# c200.0019
+ bytes/pixel case
+ 1 of 0 endof
+ 2 of h# 100 endof
+ 4 of h# 300 endof
+ endcase
+ or 8 dc!
\ Turn on FIFO
4 dc@ h# 180000 invert and h# 6501 or 4 dc!
Modified: dev/olpc/touchpad/touchpad.fth
===================================================================
--- dev/olpc/touchpad/touchpad.fth 2008-11-17 23:50:36 UTC (rev 1008)
+++ dev/olpc/touchpad/touchpad.fth 2008-12-04 09:17:25 UTC (rev 1009)
@@ -354,7 +354,7 @@
;
: track-init ( -- )
screen-ih package(
- frame-buffer-adr screen-width screen-height bytes/line16
+ frame-buffer-adr screen-width screen-height bytes/line
)package to /line 2- to maxy 2- to maxx to fbadr
load-base ptr !
;
Modified: ofw/termemu/fb8.fth
===================================================================
--- ofw/termemu/fb8.fth 2008-11-17 23:50:36 UTC (rev 1008)
+++ ofw/termemu/fb8.fth 2008-12-04 09:17:25 UTC (rev 1009)
@@ -42,9 +42,7 @@
purpose: High-level part of fb8 8-bit framebuffer support package
copyright: Copyright 1990 Sun Microsystems, Inc. All Rights Reserved
-\ 8-bit generic frame-buffer driver
-\ Uses 8 bits (1 byte) per pixel. Code is similar to fb1.fth, but
-\ simpler.
+\ Now supports 8bpp, 16bpp, and 32bpp frame buffer
\ Uses the following routines:
\ #lines ( -- n ) Number of text line positions in the window
@@ -74,41 +72,78 @@
headerless
decimal
+hex
+: rgb>565 ( r g b -- w )
+ 3 rshift
+ swap 2 rshift 5 lshift or
+ swap 3 rshift d# 11 lshift or
+;
-\ Moved to framebuf.fth
-\ 0 value emu-bytes/line \ Later set to "#columns char-width *"
-\ \ this is the window width
-: bytes/line screen-width ;
-: lines/screen screen-height ;
-: bytes/screen ( -- n ) bytes/line lines/screen * ;
+create colors-8bpp
+ 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , a , b , c , d , e , f ,
-: screen-background ( -- n )
- 16-color? if
- inverse? if foreground-color else background-color then
- else
- inverse-screen? if h# ff else 0 then
- then
+create colors-565
+ 00 00 00 rgb>565 , \ Black
+ 00 00 aa rgb>565 , \ Dark blue
+ 00 aa 00 rgb>565 , \ Dark green
+ 00 aa aa rgb>565 , \ Dark cyan
+ aa 00 00 rgb>565 , \ Dark red
+ aa 00 aa rgb>565 , \ Dark magenta
+ aa 55 aa rgb>565 , \ Brown
+\ aa aa aa rgb>565 , \ Light gray
+ c0 c0 c0 rgb>565 , \ Light gray (OLPC background)
+ 55 55 55 rgb>565 , \ Dark gray
+ 55 55 ff rgb>565 , \ Light blue
+ 55 ff 55 rgb>565 , \ Light green
+ 55 ff ff rgb>565 , \ Light cyan
+ ff 55 55 rgb>565 , \ Light red (pink)
+ ff 55 ff rgb>565 , \ Light magenta
+ ff ff 55 rgb>565 , \ Light yellow
+ ff ff ff rgb>565 , \ White
+
+create colors-32bpp
+ 000000 l, \ Black
+ 0000aa l, \ Dark blue
+ 00aa00 l, \ Dark green
+ 00aaaa l, \ Dark cyan
+ aa0000 l, \ Dark red
+ aa00aa l, \ Dark magenta
+ aa55aa l, \ Brown
+\ aaaaaa l, \ Light gray
+ c0c0c0 l, \ Light gray (OLPC background)
+ 555555 l, \ Dark gray
+ 5555ff l, \ Light blue
+ 55ff55 l, \ Light green
+ 55ffff l, \ Light cyan
+ ff5555 l, \ Light red (pink)
+ ff55ff l, \ Light magenta
+ ffff55 l, \ Light yellow
+ ffffff l, \ White
+decimal
+
+: >16-map ( fg/bg- -- color )
+ if foreground-color else background-color then
+ h# f and fb-16map swap na+ @
;
-: text-background ( -- n )
- 16-color? if
- inverse? if foreground-color else background-color then
- else
- inverse? if h# ff else 0 then
- then
-;
-: text-foreground ( -- n )
- 16-color? if
- inverse? if background-color else foreground-color then
- else
- inverse? if 0 else h# ff then
- then
-;
-: logo-foreground ( -- n ) 16-color? if text-foreground else 1 then ;
+: fg ( -- n ) true >16-map ;
+: bg ( -- n ) false >16-map ;
+: screen-background ( -- n ) inverse? >16-map ;
+: text-background ( -- n ) inverse? >16-map ;
+: text-foreground ( -- n ) inverse? 0= >16-map ;
+: logo-foreground ( -- n ) text-foreground ;
+\ defer pix* ' noop to pix*
+\ defer fb-invert ' fb8-invert to fb-invert
+\ defer fb-paint ' fb8-paint to fb-paint
+
headers
+: bytes/line ( -- n ) screen-width pix* ;
+: bytes/char ( -- n ) char-width pix* ;
+: bytes/screen ( -- n ) bytes/line screen-height * ;
+
: fb8-invert-screen ( -- )
frame-buffer-adr screen-width screen-height bytes/line
- text-foreground screen-background fb8-invert
+ text-foreground screen-background fb-invert
;
: fb8-erase-screen ( -- )
frame-buffer-adr bytes/screen screen-background fb-fill
@@ -121,7 +156,7 @@
: screen-adr ( column# line# -- adr )
char-height * window-top + ( column# ypixels )
- swap char-width * window-left + swap ( xpixels ypixels )
+ swap bytes/char * window-left + swap ( xpixels ypixels )
bytes/line * + frame-buffer-adr +
;
: line-adr ( line# -- adr ) 0 swap screen-adr ;
@@ -133,23 +168,23 @@
>font fontbytes char-width char-height
cursor-adr bytes/line text-foreground text-background
( fontadr fontbytes width height screenadr bytes/line fg-color bg-color )
- fb8-paint
+ fb-paint
;
: fb8-toggle-cursor ( -- )
cursor-adr char-width char-height bytes/line
- text-foreground text-background fb8-invert
+ text-foreground text-background fb-invert
;
: fb8-draw-logo ( line# logoadr logowidth logoheight -- )
2swap swap line-adr >r -rot ( logoadr width height ) ( r: scrn-adr )
swap dup 7 + 8 / ( logoadr height width linebytes )
swap rot ( logoadr linebytes width height )
- r> bytes/line logo-foreground screen-background fb8-paint
+ r> bytes/line logo-foreground screen-background fb-paint
;
headerless
-: move-line ( src-line-adr dst-line-adr -- ) emu-bytes/line fb-move ;
+: move-line ( src-line-adr dst-line-adr -- ) emu-bytes/line fb-window-move ;
: erase-line ( line-adr -- ) emu-bytes/line screen-background fb-fill ;
: erase-lines ( last-line first-line -- )
?do i erase-line bytes/line +loop
@@ -171,7 +206,7 @@
: fb8-delete-lines ( delta-#lines -- )
dup break-high swap break-low ( break-high break-low )
cursor-y over window-bottom swap - ( b-hi b-lo cursor-y bottom-blo )
- bytes/line emu-bytes/line fb8-window-move ( break-hi )
+ bytes/line emu-bytes/line fb-window-move ( break-hi )
window-bottom swap erase-lines
;
@@ -191,20 +226,20 @@
headerless
: move-chars ( source-col# dest-col# -- )
- 2dup max #columns swap - ( src dst #chars )
- char-width * -rot \ count is linelength-maxcol#
- swap column-adr swap column-adr ( count src-adr dst-adr )
- char-height 0 do
- 3dup rot move ( count src-adr dst-adr )
- swap bytes/line + swap bytes/line +
- loop 2drop drop
+ 2dup max #columns swap - ( src dst #chars )
+ bytes/char * -rot ( #bytes src dst )
+ swap column-adr swap column-adr ( #bytes src dst )
+ char-height 0 do ( #bytes src dst )
+ 3dup rot move ( #bytes src dst )
+ swap bytes/line + swap bytes/line + ( #bytes src' dst' )
+ loop 3drop ( )
;
: erase-chars ( #chars start-col# -- )
- swap char-width * swap
- column-adr char-height 0 do ( count adr )
- 2dup swap text-background fb-fill ( count adr )
- bytes/line +
- loop 2drop
+ swap bytes/char * swap ( #bytes start-col# )
+ column-adr char-height 0 do ( #bytes adr )
+ 2dup swap text-background fb-fill ( #bytes adr )
+ bytes/line + ( #bytes adr' )
+ loop 2drop ( )
;
headers
: fb8-insert-characters ( #chars -- )
@@ -221,23 +256,46 @@
: center-display ( -- )
screen-height #lines char-height * - 2/ is window-top
- screen-width #columns char-width * - 2/ -32 and is window-left
+ screen-width #columns char-width * - 2/ 8 pix* negate and is window-left
;
headers
-: fb8-install ( screen-width screen-height #columns #lines -- )
+: fb-install ( screen-width screen-height #columns #lines bytes/pixel -- )
+ case
+ 1 of
+ ['] noop to pix*
+ ['] fb8-invert to fb-invert
+ ['] fill to fb-fill
+ ['] fb8-paint to fb-paint
+ ['] colors-8bpp to fb-16map
+ endof
- " iso6429-1983-colors" get-my-property 0= dup to 16-color? if
- ['] not-dark to light
- \ Discard the property value (adr,len)
- 2drop ( screen-width screen-height #columns #lines )
- then ( screen-width screen-height #columns #lines )
+ 2 of
+ ['] /w* to pix*
+ ['] fb16-invert to fb-invert
+ ['] wfill to fb-fill
+ ['] fb16-paint to fb-paint
+ ['] colors-565 to fb-16map
+ endof
+ 4 of
+ ['] /l* to pix*
+ ['] fb32-invert to fb-invert
+ ['] lfill to fb-fill
+ ['] fb32-paint to fb-paint
+ ['] colors-32bpp to fb-16map
+ endof
+ endcase
+
+ \ Assume that the driver supports the 16-color extension
+ true to 16-color?
+ ['] not-dark to light
+
\ my-self is display device's ihandle
screen-#rows min is #lines
screen-#columns min is #columns
is screen-height is screen-width
- #columns char-width * is emu-bytes/line
+ #columns bytes/char * is emu-bytes/line
center-display
['] fb8-reset-screen is reset-screen
['] fb8-toggle-cursor is toggle-cursor
@@ -247,10 +305,11 @@
['] fb8-insert-characters is insert-characters
['] fb8-delete-characters is delete-characters
['] fb8-insert-lines is insert-lines
- bytes/line 8 mod
+ bytes/line 8 pix* mod
if ['] fb8-delete-lines-slow
else ['] fb8-delete-lines
then is delete-lines
['] fb8-draw-character is draw-character
['] fb8-draw-logo is draw-logo
;
+: fb8-install ( width height #cols #lines -- ) 1 fb-install ;
Modified: ofw/termemu/framebuf.fth
===================================================================
--- ofw/termemu/framebuf.fth 2008-11-17 23:50:36 UTC (rev 1008)
+++ ofw/termemu/framebuf.fth 2008-12-04 09:17:25 UTC (rev 1009)
@@ -69,6 +69,13 @@
d# 34 termemu-value #lines
d# 80 termemu-value #columns
+\ Things that change for different pixel depths
+termemu-defer pix*
+termemu-defer fb-invert
+termemu-defer fb-fill
+termemu-defer fb-paint
+termemu-defer fb-16map
+
termemu-defer draw-character
termemu-defer insert-characters
termemu-defer delete-characters
Modified: ofw/termemu/loadfb.fth
===================================================================
--- ofw/termemu/loadfb.fth 2008-11-17 23:50:36 UTC (rev 1008)
+++ ofw/termemu/loadfb.fth 2008-12-04 09:17:25 UTC (rev 1009)
@@ -60,9 +60,6 @@
finish-device
device-end
-defer fb-move ' move is fb-move
-defer fb-fill ' fill is fb-fill
-
[ifdef] include-fb1
fload ${BP}/ofw/termemu/fb1.fth \ Generic 1-bit raster ops
[then]