/* * (C) Copyright 2002 * Hyperion Entertainment, Hans-JoergF@hyperion-entertainment.com * * See file CREDITS for list of people who contributed to this * project. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA */ #include #include #include "memio.h" #include DECLARE_GLOBAL_DATA_PTR; unsigned char *cursor_position; unsigned int cursor_row; unsigned int cursor_col; unsigned char current_attr; unsigned int video_numrows = 25; unsigned int video_numcols = 80; unsigned int video_scrolls = 0; #define VIDEO_BASE (unsigned char *)0xFD0B8000 #define VIDEO_ROWS video_numrows #define VIDEO_COLS video_numcols #define VIDEO_PITCH (2 * video_numcols) #define VIDEO_SIZE (video_numrows * video_numcols * 2) #define VIDEO_NAME "vga" void video_test(void); void video_putc(char ch); void video_puts(char *string); void video_scroll(int rows); void video_banner(void); int video_init(void); int video_start(void); int video_rows(void); int video_cols(void); char *prompt_string = "=>"; unsigned char video_get_attr(void); void video_set_color(unsigned char attr) { unsigned char *fb = (unsigned char *)VIDEO_BASE; int i; current_attr = video_get_attr(); for (i=0; i VIDEO_COLS-1) { cursor_row++; cursor_col=0; } } if (cursor_row > VIDEO_ROWS-1) video_scroll(1); video_set_cursor(cursor_row, cursor_col); } void video_scroll(int rows) { unsigned short clear = ((unsigned short)current_attr) | (' '<<8); unsigned short* addr16 = &((unsigned short *)VIDEO_BASE)[(VIDEO_ROWS-rows)*VIDEO_COLS]; int i; char *s; s = getenv("vga_askscroll"); video_scrolls += rows; if (video_scrolls >= video_numrows) { if (s && strcmp(s, "yes")) { while (-1 == tstc()); } video_scrolls = 0; } memcpy(VIDEO_BASE, VIDEO_BASE+rows*(VIDEO_COLS*2), (VIDEO_ROWS-rows)*(VIDEO_COLS*2)); for (i = 0 ; i < rows * VIDEO_COLS ; i++) addr16[i] = clear; cursor_row-=rows; cursor_col=0; } void video_puts(char *string) { while (*string) { video_putc(*string); string++; } } int video_start(void) { return 0; } unsigned char video_single_box[] = { 218, 196, 191, 179, 179, 192, 196, 217 }; unsigned char video_double_box[] = { 201, 205, 187, 186, 186, 200, 205, 188 }; unsigned char video_single_title[] = { 195, 196, 180, 180, 195 }; unsigned char video_double_title[] = { 204, 205, 185, 181, 198 }; #define SINGLE_BOX 0 #define DOUBLE_BOX 1 unsigned char *video_addr(int x, int y) { return VIDEO_BASE + 2*(VIDEO_COLS*y) + 2*x; } void video_bios_print_string(char *s, int x, int y, int attr, int count) { int cattr = current_attr; if (attr != -1) current_attr = attr; video_set_cursor(x,y); while (count) { char c = *s++; if (attr == -1) current_attr = *s++; video_putc(c); count--; } } void video_draw_box(int style, int attr, char *title, int separate, int x, int y, int w, int h) { unsigned char *fb, *fb2; unsigned char *st = (style == SINGLE_BOX)?video_single_box : video_double_box; unsigned char *ti = (style == SINGLE_BOX)?video_single_title : video_double_title; int i; fb = video_addr(x,y); *(fb) = st[0]; *(fb+1) = attr; fb += 2; fb2 = video_addr(x,y+h-1); *(fb2) = st[5]; *(fb2+1) = attr; fb2 += 2; for (i=0; i 0) *fb = clearchar; fb ++; *save ++ = *fb; if (clearattr > 0) *fb = clearattr; } fb = fbb + 2*VIDEO_COLS; } } void video_restore_rect(int x, int y, int w, int h, void *save_area) { unsigned char *save = (unsigned char *)save_area; unsigned char *fb = video_addr(x,y); int i,j; for (i=0; ibd->bi_memsize/(1024*1024)); printf("FSB: %ld MHz\n", gd->bd->bi_busfreq/1000000); printf("\n---- Disk summary ----\n"); for (i = 0; i < maxdev; i++) { ide = ide_get_dev(i); printf("Device %d: ", i); dev_print(ide); } /* video_draw_box(SINGLE_BOX, 0x0F, "Test 1", 0, 0,18, 72, 4); video_draw_box(DOUBLE_BOX, 0x0F, "Test 2", 1, 4,10, 50, 6); video_draw_box(DOUBLE_BOX, 0x0F, "Test 3", 0, 40, 3, 20, 5); video_draw_text(1, 4, 0x2F, "Highlighted options"); video_draw_text(1, 5, 0x0F, "Non-selected option"); video_draw_text(1, 6, 0x07, "disabled option"); */ #ifdef EASTEREGG } #endif }