Author: wmb Date: 2009-11-13 23:45:00 +0100 (Fri, 13 Nov 2009) New Revision: 1475
Modified: dev/via/unichrome/accel2d.fth dev/via/unichrome/vgamodes.fth dev/video/common/rectangle16.fth ofw/termemu/fb8.fth Log: OLPC trac 9671 - Switch display depth to 32bpp in coordination with the OS's change. Requires os40.
Modified: dev/via/unichrome/accel2d.fth =================================================================== --- dev/via/unichrome/accel2d.fth 2009-11-13 22:43:30 UTC (rev 1474) +++ dev/via/unichrome/accel2d.fth 2009-11-13 22:45:00 UTC (rev 1475) @@ -1,8 +1,6 @@ \ See license at end of file purpose: Via Unichrome graphics acceleration
-alias depth+ wa+ - : mmio@ ( offset -- l ) mmio-base + rl@ ; : mmio! ( l offset -- ) mmio-base + rl! ;
@@ -11,7 +9,7 @@ 0 h# 14 mmio! \ Destination map base - beginning of frame buffer 0 h# 1c mmio! \ Source map base - beginning of frame buffer bytes/line 3 rshift dup wljoin 8 mmio! \ Dest and src pitch - depth case + effective-depth case 8 of 0 endof \ 8-bpp 3:3:2 d# 16 of h# 100 endof \ 16-bpp 5:6:5 d# 32 of h# 300 endof \ 32-bpp 8:8:8:8
Modified: dev/via/unichrome/vgamodes.fth =================================================================== --- dev/via/unichrome/vgamodes.fth 2009-11-13 22:43:30 UTC (rev 1474) +++ dev/via/unichrome/vgamodes.fth 2009-11-13 22:45:00 UTC (rev 1475) @@ -88,5 +88,6 @@ : 640x480x32 ( -- ) olpc-lcd-mode d# 640 d# 480 d# 32 change-resolution h# 112 note-mode ; \ VESA mode 112 : 800x600x32 ( -- ) olpc-lcd-mode d# 800 d# 600 d# 32 change-resolution h# 115 note-mode ; \ VESA mode 115 : 1024x768x32 ( -- ) olpc-lcd-mode d# 1024 d# 768 d# 32 change-resolution h# 118 note-mode ; \ VESA mode 118 -: 1200x900x16 ( -- ) olpc-lcd-mode d# 1024 d# 768 d# 16 change-resolution note-native-mode ; -: 1200x900x32 ( -- ) olpc-lcd-mode d# 1024 d# 768 d# 32 change-resolution native-mode# 1- note-mode ; +: 1200x900x16 ( -- ) olpc-lcd-mode d# 1024 d# 768 d# 16 change-resolution native-mode# 1- note-mode ; +: 1200x900x24 ( -- ) olpc-lcd-mode d# 1024 d# 768 d# 32 change-resolution note-native-mode ; +: 1200x900x32 ( -- ) olpc-lcd-mode d# 1024 d# 768 d# 32 change-resolution note-native-mode ;
Modified: dev/video/common/rectangle16.fth =================================================================== --- dev/video/common/rectangle16.fth 2009-11-13 22:43:30 UTC (rev 1474) +++ dev/video/common/rectangle16.fth 2009-11-13 22:45:00 UTC (rev 1475) @@ -3,13 +3,73 @@
external
+code 565>argb-pixel ( 565 -- argb ) + ax pop + ax bx mov d# 11 # bx shr d# 19 # bx shl \ Red + ax dx mov d# 27 # dx shl d# 24 # dx shr dx bx or \ Blue + d# 21 # ax shl d# 26 # ax shr d# 10 # ax shl bx ax or + h# ff070307 # ax or + ax push +c; +code 565>argb ( src dst #pixels -- ) + cx pop + di 0 [sp] xchg + si 4 [sp] xchg + + begin + ax ax xor + op: ax lods + ax bx mov d# 11 # bx shr d# 19 # bx shl \ Red + ax dx mov d# 27 # dx shl d# 24 # dx shr dx bx or \ Blue + d# 21 # ax shl d# 26 # ax shr d# 10 # ax shl bx ax or + h# ff070307 # ax or + ax stos + loopa + + di pop + si pop +c; +code argb>565-pixel ( argb -- 565 ) + ax pop + ax bx mov d# 19 # bx shr d# 11 # bx shl \ Red + ax dx mov d# 24 # dx shl d# 27 # dx shr dx bx or \ Blue + d# 16 # ax shl d# 26 # ax shr d# 5 # ax shl bx ax or \ Green + ax push +c; + +code argb>565 ( src dst #pixels -- ) + cx pop + di 0 [sp] xchg + si 4 [sp] xchg + + begin + ax lods + ax bx mov d# 19 # bx shr d# 11 # bx shl \ Red + ax dx mov d# 24 # dx shl d# 27 # dx shr dx bx or \ Blue + d# 16 # ax shl d# 26 # ax shr d# 5 # ax shl bx ax or \ Green + op: ax stos + loopa + + di pop + si pop +c; + : rectangle-setup ( x y w h -- wb fbadr h ) swap depth * 3 rshift swap ( x y wbytes h ) 2swap /scanline * frame-buffer-adr + ( wbytes h x line-adr ) swap depth * 3 rshift + ( wbytes h fbadr ) swap ( wbytes fbadr h ) ; +: 565-rectangle-setup ( x y w h -- w fbadr h ) + 2swap /scanline * frame-buffer-adr + ( w h x line-adr ) + swap depth * 3 rshift + ( w h fbadr ) + swap ( w fbadr h ) +; : fill-rectangle ( color x y w h -- ) + depth d# 32 = if ( color x y w h ) + 2>r 2>r 565>argb-pixel 2r> 2r> ( color' x y w h ) + then ( color x y w h ) + rot /scanline * frame-buffer-adr + ( color x w h fbadr ) -rot >r ( color x fbadr w r: h ) \ The loop is inside the case for speed @@ -24,32 +84,47 @@ ;
: draw-rectangle ( adr x y w h -- ) - rectangle-setup 0 ?do ( adr wbytes fbadr ) - 3dup swap move ( adr wbytes fbadr ) - >r tuck + swap r> ( adr' wbytes fbadr ) - /scanline + ( adr' wbytes fbadr' ) - loop ( adr' wbytes fbadr' ) + 565-rectangle-setup 0 ?do ( adr w fbadr ) + 3dup swap ( adr w fbadr adr fbadr w ) + depth d# 32 = if ( adr w fbadr adr fbadr w ) + 565>argb ( adr w fbadr ) + else ( adr w fbadr adr fbadr w ) + /w* move ( adr w fbadr ) + then ( adr w fbadr ) + >r tuck wa+ swap r> ( adr' w fbadr ) + /scanline + ( adr' w fbadr' ) + loop ( adr' w fbadr' ) 3drop ;
+defer pixel! ( color fbadr i -- ) +: 565-pixel! ( color fbadr i -- ) wa+ w! ; +: argb-pixel! ( color fbadr i -- ) rot 565>argb-pixel -rot la+ l! ; + : draw-transparent-rectangle ( adr x y w h -- ) - rectangle-setup ( adr wbytes fbadr h ) - >r rot r> ( wbytes fbadr adr h ) - 0 ?do ( wbytes fbadr adr ) - 2 pick 0 ?do ( wbytes fbadr adr ) - dup w@ >r wa1+ r> ( wbytes fbadr adr' color ) - dup h# ffff = if ( wbytes fbadr adr color ) - drop ( wbytes fbadr adr ) - else ( wbytes fbadr adr color ) - 2 pick i + w! ( wbytes fbadr adr ) - then ( wbytes fbadr adr ) - /w +loop ( wbytes fbadr adr ) - swap /scanline + swap ( wbytes fbadr' adr ) - loop ( wbytes fbadr' adr' ) + depth d# 32 = if + ['] argb-pixel! to pixel! + else + ['] 565-pixel! to pixel! + then + 565-rectangle-setup ( adr w fbadr h ) + >r rot r> ( w fbadr adr h ) + 0 ?do ( w fbadr adr ) + 2 pick 0 ?do ( w fbadr adr ) + dup i wa+ w@ ( w fbadr adr color ) + dup h# ffff = if ( w fbadr adr color ) + drop ( w fbadr adr ) + else ( w fbadr adr color ) + 2 pick i pixel! ( w fbadr adr ) + then ( w fbadr adr ) + loop ( w fbadr adr ) + swap /scanline + swap ( w fbadr' adr ) + third wa+ ( w fbadr adr' ) + loop ( w fbadr' adr' ) 3drop ;
-: read-rectangle ( adr x y w h -- ) +: native-read-rectangle ( adr x y w h -- ) rectangle-setup 0 ?do ( adr wbytes fbadr ) 3dup -rot move ( adr wbytes fbadr ) >r tuck + swap r> ( adr' wbytes fbadr ) @@ -57,6 +132,19 @@ loop ( adr' wbytes fbadr' ) 3drop ; +: read-rectangle ( adr x y w h -- ) + 565-rectangle-setup 0 ?do ( adr w fbadr ) + 3dup -rot ( adr w fbadr fbadr adr w ) + depth d# 32 = if ( adr w fbadr fbadr adr w ) + argb>565 ( adr w fbadr ) + else ( adr w fbadr fbadr adr w ) + /w* move ( adr w fbadr ) + then ( adr w fbadr ) + >r tuck wa+ swap r> ( adr' w fbadr ) + /scanline + ( adr' w fbadr' ) + loop ( adr' w fbadr' ) + 3drop +; : dimensions ( -- width height ) width height ;
: replace-color16 ( old new -- )
Modified: ofw/termemu/fb8.fth =================================================================== --- ofw/termemu/fb8.fth 2009-11-13 22:43:30 UTC (rev 1474) +++ ofw/termemu/fb8.fth 2009-11-13 22:45:00 UTC (rev 1475) @@ -281,6 +281,14 @@ loop 4drop ; +: merge-rect-565 ( color mask-adr dst-adr width height -- ) + 0 ?do ( color mask-adr rect-adr width ) + 2over @ 2over fb16-merge ( color mask-adr rect-adr width ) + rot na1+ -rot ( color mask-adr' rect-adr width ) + tuck wa+ swap ( color mask-adr rect-adr' width ) + loop + 4drop +;
headers : fb8-insert-characters ( #chars -- )