j
: Next unread message k
: Previous unread message j a
: Jump to all threads
j l
: Jump to MailingList overview
Author: mcayland Date: Sun Jun 9 14:25:20 2013 New Revision: 1147 URL: http://tracker.coreboot.org/trac/openbios/changeset/1147
Log: video_common.c: create low-level video_invert_rect() 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:17 2013 (r1146) +++ trunk/openbios-devel/forth/device/display.fs Sun Jun 9 14:25:20 2013 (r1147) @@ -165,6 +165,7 @@
\ bind to low-level C function later defer fb8-blitmask +defer fb8-invertrect
: fb8-line2addr ( line -- addr ) window-top + @@ -226,15 +227,11 @@ ;
: fb8-toggle-cursor ( -- ) - line# char-height * window-top + screen-width * - column# char-width * window-left + + frame-buffer-adr + - char-height 0 ?do - char-width 0 ?do - dup i + dup c@ invert ff and swap c! - loop - screen-width + - loop - drop + column# char-width * window-left + + line# char-height * window-top + + char-width char-height + foreground-color background-color + fb8-invertrect ;
: fb8-erase-screen ( -- ) @@ -249,20 +246,14 @@ ;
: fb8-invert-screen ( -- ) - frame-buffer-adr - screen-height screen-width * - bounds ?do - i c@ case - foreground-color of background-color endof - background-color of foreground-color endof - dup - endcase - i c! - loop + 0 0 screen-width screen-height + background-color foreground-color + fb8-invertrect ;
: fb8-blink-screen ( -- ) - fb8-invert-screen fb8-invert-screen + fb8-invert-screen 2000 ms + fb8-invert-screen ;
: fb8-insert-characters ( n -- )
Modified: trunk/openbios-devel/include/libopenbios/video.h ============================================================================== --- trunk/openbios-devel/include/libopenbios/video.h Sun Jun 9 14:25:17 2013 (r1146) +++ trunk/openbios-devel/include/libopenbios/video.h Sun Jun 9 14:25:20 2013 (r1147) @@ -8,6 +8,7 @@ void video_scroll(int height); void fill_rect(int col_ind, int x, int y, int w, int h); void video_mask_blit(void); +void video_invert_rect(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:17 2013 (r1146) +++ trunk/openbios-devel/libopenbios/video_common.c Sun Jun 9 14:25:20 2013 (r1147) @@ -184,6 +184,61 @@ } }
+/* ( x y w h fgcolor bgcolor -- ) */ + +void +video_invert_rect( void ) +{ + ucell bgcolor = POP(); + ucell fgcolor = POP(); + int h = POP(); + int w = POP(); + int y = POP(); + int x = POP(); + char *pp; + + bgcolor = get_color(bgcolor); + fgcolor = get_color(fgcolor); + + if (!video.has_video || x < 0 || y < 0 || w <= 0 || h <= 0 || + x + w > video.fb.w || y + h > video.fb.h) + return; + + pp = (char*)video.fb.mvirt + video.fb.rb * y; + for( ; h--; pp += video.fb.rb ) { + int ww = w; + if( video.fb.depth == 24 || video.fb.depth == 32 ) { + unsigned long *p = (unsigned long*)pp + x; + while( ww-- ) { + if (*p == fgcolor) { + *p++ = bgcolor; + } else if (*p == bgcolor) { + *p++ = fgcolor; + } + } + } else if( video.fb.depth == 16 || video.fb.depth == 15 ) { + unsigned short *p = (unsigned short*)pp + x; + while( ww-- ) { + if (*p == (unsigned short)fgcolor) { + *p++ = bgcolor; + } else if (*p == (unsigned short)bgcolor) { + *p++ = fgcolor; + } + } + } else { + char *p = (char *)(pp + x); + + while( ww-- ) { + if (*p == (char)fgcolor) { + *p++ = bgcolor; + } else if (*p == (char)bgcolor) { + *p++ = fgcolor; + } + } + } + } +} + void draw_pixel( int x, int y, int colind ) { @@ -336,6 +391,9 @@ PUSH( pointer2cell(video_mask_blit) ); fword("is-noname-cfunc"); feval("to fb8-blitmask"); + PUSH( pointer2cell(video_invert_rect) ); + fword("is-noname-cfunc"); + feval("to fb8-invertrect");
PUSH((video.fb.depth + 1) >> 3); feval("to depth-bytes");