graphics.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/* graphics.c - graphics mode support for GRUB */
/* Implemented as a terminal type by Jeremy Katz <katzj@redhat.com> based
* on a patch by Paulo C�sar Pereira de Andrade <pcpa@conectiva.com.br>
*/
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2001,2002 Red Hat, Inc.
* Portions copyright (C) 2000 Conectiva, Inc.
*
* 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., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifdef SUPPORT_GRAPHICS
#include <term.h>
#include <shared.h>
#include <graphics.h>
int saved_videomode;
unsigned char *font8x16;
int graphics_inited = 0;
static char splashimage[64];
unsigned char VSHADOW1[38400];
unsigned char VSHADOW2[38400];
unsigned char VSHADOW4[38400];
unsigned char VSHADOW8[38400];
/* constants to define the viewable area */
const int x0 = 0;
const int x1 = 80;
const int y0 = 0;
const int y1 = 30;
/* text buffer has to be kept around so that we can write things as we
* scroll and the like */
/* why do these have to be kept here? */
/* current position */
static int fontx = 0;
static int fonty = 0;
/* global state so that we don't try to recursively scroll or cursor */
static int no_scroll = 0;
/* color state */
static int graphics_standard_color = A_NORMAL;
static int graphics_normal_color = A_NORMAL;
static int graphics_highlight_color = A_REVERSE;
static int graphics_current_color = A_NORMAL;
/* graphics local functions */
static void graphics_scroll();
/* FIXME: where do these really belong? */
{
}
}
/* bit mask register */
}
/* Set the splash image */
void graphics_set_splash(char *splashfile) {
}
/* Get the current splash image */
char *graphics_get_splash(void) {
return splashimage;
}
/* Initialize a vga16 graphics display with the palette based off of
* the image in splashimage. If the image doesn't exist, leave graphics
* mode. */
int graphics_init()
{
if (!graphics_inited) {
}
if (!read_image(splashimage)) {
grub_printf("failed to read image\n");
return 0;
}
font8x16 = (unsigned char*)graphics_get_font();
graphics_inited = 1;
/* make sure that the highlight color is set correctly */
return 1;
}
/* Leave graphics mode */
void graphics_end(void)
{
if (graphics_inited) {
graphics_inited = 0;
}
}
/* Print ch on the screen. Handle any needed scrolling or the like */
void graphics_putchar(int ch) {
ch &= 0xff;
graphics_cursor(0);
if (ch == '\n') {
else
graphics_cursor(1);
return;
} else if (ch == '\r') {
graphics_cursor(1);
return;
}
graphics_cursor(0);
if (graphics_current_color & 0xf0)
graphics_cursor(0);
else
} else {
}
graphics_cursor(1);
}
/* get the current location of the cursor */
int graphics_getxy(void) {
}
void graphics_gotoxy(int x, int y) {
graphics_cursor(0);
graphics_setxy(x, y);
graphics_cursor(1);
}
void graphics_cls(void) {
int i;
graphics_cursor(0);
for (i = 0; i < 80 * 30; i++)
text[i] = ' ';
graphics_cursor(1);
BitMask(0xff);
/* plano 1 */
MapMask(1);
/* plano 2 */
MapMask(2);
/* plano 3 */
MapMask(4);
/* plano 4 */
MapMask(8);
MapMask(15);
}
switch (state) {
case COLOR_STATE_STANDARD:
break;
case COLOR_STATE_NORMAL:
break;
case COLOR_STATE_HIGHLIGHT:
break;
default:
break;
}
}
}
int graphics_setcursor (int on) {
/* FIXME: we don't have a cursor in graphics */
return 1;
}
/* Read in the splashscreen image and set the palette up appropriately.
* Format of splashscreen is an xpm (can be gzipped) with 16 colors and
* 640x480. */
int read_image(char *s)
{
if (!grub_open(s))
return 0;
/* read header */
grub_close();
return 0;
}
/* parse info */
while (grub_read(&c, 1)) {
if (c == '"')
break;
}
;
i = 0;
width = c - '0';
while (grub_read(&c, 1)) {
if (c >= '0' && c <= '9')
else
break;
}
;
height = c - '0';
while (grub_read(&c, 1)) {
if (c >= '0' && c <= '9')
else
break;
}
;
colors = c - '0';
while (grub_read(&c, 1)) {
if (c >= '0' && c <= '9')
else
break;
}
base = 0;
;
/* palette */
len = 0;
;
base = c;
}
graphics_set_palette(idx, r, g, b);
++idx;
}
}
x = y = len = 0;
for (i = 0; i < 38400; i++)
/* parse xpm data */
while (y < height) {
while (1) {
if (!grub_read(&c, 1)) {
grub_close();
return 0;
}
if (c == '"')
break;
}
for (i = 1; i < 15; i++)
if (pal[i] == c) {
c = i;
break;
}
if (c & 1)
if (c & 2)
if (c & 4)
if (c & 8)
if (++x >= 640) {
x = 0;
if (y < 480)
len += 80;
++y;
}
}
}
grub_close();
background & 63);
foreground & 63);
border & 63);
return 1;
}
/* Convert a character which is a hex digit to the appropriate integer */
int hex(int v)
{
if (v >= 'A' && v <= 'F')
return (v - 'A' + 10);
if (v >= 'a' && v <= 'f')
return (v - 'a' + 10);
return (v - '0');
}
/* move the graphics cursor location to col, row */
}
}
}
/* scroll the screen */
static void graphics_scroll() {
int i, j;
/* we don't want to scroll recursively... that would be bad */
if (no_scroll)
return;
no_scroll = 1;
/* move everything up a line */
}
}
/* last line should be blank */
graphics_putchar(' ');
no_scroll = 0;
}
void graphics_cursor(int set) {
return;
if (!set) {
for (i = 0; i < 16; i++) {
if (!invert) {
/* FIXME: if (shade) */
if (1) {
}
}
}
}
offset += 80;
}
else {
}
}
}
else {
MapMask(15);
}
return;
}
offset = 0;
int j;
MapMask(i);
}
MapMask(15);
}
#endif /* SUPPORT_GRAPHICS */