-static void lcd_initcolregs (void);
-#endif
-static int lcd_getbgcolor (void);
-static void lcd_setfgcolor (int color);
-static void lcd_setbgcolor (int color);
-
-#ifdef NOT_USED_SO_FAR
-static void lcd_disable (void);
-static void lcd_getcolreg (ushort regno,
- ushort *red, ushort *green, ushort *blue);
-static int lcd_getfgcolor (void);
-#endif /* NOT_USED_SO_FAR */
-
-/************************************************************************/
-
-/*----------------------------------------------------------------------*/
-
-static void console_scrollup (void)
-{
-#if 1
- /* Copy up rows ignoring the first one */
- memcpy (CONSOLE_ROW_FIRST, CONSOLE_ROW_SECOND, CONSOLE_SCROLL_SIZE);
-
- /* Clear the last one */
- memset (CONSOLE_ROW_LAST, COLOR_MASK(lcd_color_bg), CONSOLE_ROW_SIZE);
-#else
- /*
- * Poor attempt to optimize speed by moving "long"s.
- * But the code is ugly, and not a bit faster :-(
- */
- ulong *t = (ulong *)CONSOLE_ROW_FIRST;
- ulong *s = (ulong *)CONSOLE_ROW_SECOND;
- ulong l = CONSOLE_SCROLL_SIZE / sizeof(ulong);
- uchar c = lcd_color_bg & 0xFF;
- ulong val= (c<<24) | (c<<16) | (c<<8) | c;
-
- while (l--)
- *t++ = *s++;
-
- t = (ulong *)CONSOLE_ROW_LAST;
- l = CONSOLE_ROW_SIZE / sizeof(ulong);
-
- while (l-- > 0)
- *t++ = val;
-#endif
-}
-
-/*----------------------------------------------------------------------*/
-
-static inline void console_back (void)
-{
- if (--console_col < 0) {
- console_col = CONSOLE_COLS-1 ;
- if (--console_row < 0) {
- console_row = 0;
- }
- }
-
- lcd_putc_xy (console_col * VIDEO_FONT_WIDTH,
- console_row * VIDEO_FONT_HEIGHT,
- ' ');
-}
-
-/*----------------------------------------------------------------------*/
-
-static inline void console_newline (void)
-{
- ++console_row;
- console_col = 0;
-
- /* Check if we need to scroll the terminal */
- if (console_row >= CONSOLE_ROWS) {
- /* Scroll everything up */
- console_scrollup () ;
- --console_row;
- }
-}
-
-/*----------------------------------------------------------------------*/
-
-void lcd_putc (const char c)
-{
- if (!lcd_is_enabled) {
- serial_putc(c);
- return;
- }
-
- switch (c) {
- case '\r': console_col = 0;
- return;
-
- case '\n': console_newline();
- return;
-
- case '\t': /* Tab (8 chars alignment) */
- console_col |= 8;
- console_col &= ~7;
-
- if (console_col >= CONSOLE_COLS) {
- console_newline();
- }
- return;
-
- case '\b': console_back();
- return;
-
- default: lcd_putc_xy (console_col * VIDEO_FONT_WIDTH,
- console_row * VIDEO_FONT_HEIGHT,
- c);
- if (++console_col >= CONSOLE_COLS) {
- console_newline();
- }
- return;
- }
- /* NOTREACHED */
-}
-
-/*----------------------------------------------------------------------*/
-
-void lcd_puts (const char *s)
-{
- if (!lcd_is_enabled) {
- serial_puts (s);
- return;
- }
-
- while (*s) {
- lcd_putc (*s++);
- }
-}
-
-/************************************************************************/
-/* ** Low-Level Graphics Routines */
-/************************************************************************/
-
-static void lcd_drawchars (ushort x, ushort y, uchar *str, int count)
-{
- uchar *dest;
- ushort off, row;
-
- dest = (uchar *)(lcd_base + y * lcd_line_length + x * (1 << LCD_BPP) / 8);
- off = x * (1 << LCD_BPP) % 8;
-
- for (row=0; row < VIDEO_FONT_HEIGHT; ++row, dest += lcd_line_length) {
- uchar *s = str;
- uchar *d = dest;
- int i;
-
-#if LCD_BPP == LCD_MONOCHROME
- uchar rest = *d & -(1 << (8-off));
- uchar sym;
-#endif
- for (i=0; i<count; ++i) {
- uchar c, bits;
-
- c = *s++;
- bits = video_fontdata[c * VIDEO_FONT_HEIGHT + row];
-
-#if LCD_BPP == LCD_MONOCHROME
- sym = (COLOR_MASK(lcd_color_fg) & bits) |
- (COLOR_MASK(lcd_color_bg) & ~bits);
-
- *d++ = rest | (sym >> off);
- rest = sym << (8-off);
-#elif LCD_BPP == LCD_COLOR8
- for (c=0; c<8; ++c) {
- *d++ = (bits & 0x80) ?
- lcd_color_fg : lcd_color_bg;
- bits <<= 1;
- }
-#endif
- }
-
-#if LCD_BPP == LCD_MONOCHROME
- *d = rest | (*d & ((1 << (8-off)) - 1));