Author: mcayland Date: Sun Jun 9 14:25:17 2013 New Revision: 1146 URL: http://tracker.coreboot.org/trac/openbios/changeset/1146
Log: video_common.c: create low-level video_mask_blit() function.
Switch display.fs over to use it.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk
Modified: trunk/openbios-devel/forth/device/display.fs trunk/openbios-devel/include/libopenbios/video.h trunk/openbios-devel/libopenbios/video_common.c
Modified: trunk/openbios-devel/forth/device/display.fs ============================================================================== --- trunk/openbios-devel/forth/device/display.fs Sun Jun 9 14:25:14 2013 (r1145) +++ trunk/openbios-devel/forth/device/display.fs Sun Jun 9 14:25:17 2013 (r1146) @@ -163,45 +163,8 @@
\ 5.3.6.3.3 Generic eight-bit frame-buffer support
-\ The following two functions are unrolled for speed. - - -\ blit 8 continuous pixels described by the 8bit -\ value in bitmask8. The most significant bit is -\ painted first. - -\ this function should honour fg and bg colors - -: fb8-write-mask8 ( bitmask8 faddr -- ) - over 1 and 0<> over 7 + c! - over 2 and 0<> over 6 + c! - over 4 and 0<> over 5 + c! - over 8 and 0<> over 4 + c! - over 10 and 0<> over 3 + c! - over 20 and 0<> over 2 + c! - over 40 and 0<> over 1 + c! - over 80 and 0<> over 0 + c! - 2drop - ; - -: fb8-blitmask ( fbaddr mask-addr width height -- ) - over >r \ save width ( -- R: width ) - * 3 >> \ fbaddr mask-addr width*height/8 - bounds \ fbaddr mask-end mask - r> 0 2swap \ fbaddr width 0 mask-end mask - ?do \ ( fbaddr width l-cnt ) - 2 pick over + \ fbaddr-current - i c@ \ bitmask8 - swap fb8-write-mask8 - ( fbaddr width l-cnt ) - 8 + 2dup = if - drop swap screen-width + - swap 0 - then - ( fbaddr width l-cnt ) - loop - 2drop drop - ; +\ bind to low-level C function later +defer fb8-blitmask
: fb8-line2addr ( line -- addr ) window-top + @@ -229,6 +192,11 @@ line# char-height * window-top + screen-width * column# char-width * window-left + + frame-buffer-adr + swap char-width char-height + \ normal or inverse? + foreground-color background-color + inverse? if + swap + then fb8-blitmask \ now advance the position column# 1+
Modified: trunk/openbios-devel/include/libopenbios/video.h ============================================================================== --- trunk/openbios-devel/include/libopenbios/video.h Sun Jun 9 14:25:14 2013 (r1145) +++ trunk/openbios-devel/include/libopenbios/video.h Sun Jun 9 14:25:17 2013 (r1146) @@ -7,6 +7,7 @@ void draw_pixel(int x, int y, int colind); void video_scroll(int height); void fill_rect(int col_ind, int x, int y, int w, int h); +void video_mask_blit(void);
typedef struct osi_fb_info { unsigned long mphys;
Modified: trunk/openbios-devel/libopenbios/video_common.c ============================================================================== --- trunk/openbios-devel/libopenbios/video_common.c Sun Jun 9 14:25:14 2013 (r1145) +++ trunk/openbios-devel/libopenbios/video_common.c Sun Jun 9 14:25:17 2013 (r1146) @@ -134,6 +134,56 @@ return 0; }
+/* ( fbaddr maskaddr width height fgcolor bgcolor -- ) */ + +void +video_mask_blit(void) +{ + ucell bgcolor = POP(); + ucell fgcolor = POP(); + ucell height = POP(); + ucell width = POP(); + unsigned char *mask = (unsigned char *)POP(); + unsigned char *fbaddr = (unsigned char *)POP(); + + ucell color; + unsigned char *dst, *rowdst; + int x, y, m, b, d, depthbytes; + + fgcolor = get_color(fgcolor); + bgcolor = get_color(bgcolor); + d = video.fb.depth; + depthbytes = (video.fb.depth + 1) >> 3; + + dst = fbaddr; + for( y = 0; y < height; y++) { + rowdst = dst; + for( x = 0; x < (width + 1) >> 3; x++ ) { + for (b = 0; b < 8; b++) { + m = (1 << (7 - b)); + + if (*mask & m) { + color = fgcolor; + } else { + color = bgcolor; + } + + if( d >= 24 ) + *((unsigned long*)dst) = color; + else if( d >= 15 ) + *((short*)dst) = color; + else + *dst = color; + + dst += depthbytes; + } + mask++; + } + dst = rowdst; + dst += video.fb.rb; + } +} + void draw_pixel( int x, int y, int colind ) { @@ -283,6 +333,10 @@ feval("to frame-buffer-adr");
/* Set global variables ready for fb8-install */ + PUSH( pointer2cell(video_mask_blit) ); + fword("is-noname-cfunc"); + feval("to fb8-blitmask"); + PUSH((video.fb.depth + 1) >> 3); feval("to depth-bytes"); PUSH(video.fb.rb);