?? grub-0.97-patch5-splash
字號:
++ while (grub_read((char *)&c, 1) && (c == ' ' || c == '\t'))+ ;++ i = 0;+ width = c - '0';+ while (grub_read((char *)&c, 1)) {+ if (c >= '0' && c <= '9')+ width = width * 10 + c - '0';+ else+ break;+ }+ while (grub_read((char *)&c, 1) && (c == ' ' || c == '\t'))+ ;++ height = c - '0';+ while (grub_read((char *)&c, 1)) {+ if (c >= '0' && c <= '9')+ height = height * 10 + c - '0';+ else+ break;+ }+ while (grub_read((char *)&c, 1) && (c == ' ' || c == '\t'))+ ;++ colors = c - '0';+ while (grub_read((char *)&c, 1)) {+ if (c >= '0' && c <= '9')+ colors = colors * 10 + c - '0';+ else+ break;+ }++ base = 0;+ while (grub_read((char *)&c, 1) && c != '"')+ ;++ /* palette */+ for (i = 0, idx = 1; i < colors; i++) {+ len = 0;++ while (grub_read((char *)&c, 1) && c != '"')+ ;+ grub_read((char *)&c, 1); /* char */+ base = c;+ grub_read(buf, 4); /* \t c # */++ while (grub_read((char *)&c, 1) && c != '"') {+ if (len < sizeof(buf))+ buf[len++] = c;+ }++ if (len == 6 && idx < 15) {+ int r = ((hex(buf[0]) << 4) | hex(buf[1])) >> 2;+ int g = ((hex(buf[2]) << 4) | hex(buf[3])) >> 2;+ int b = ((hex(buf[4]) << 4) | hex(buf[5])) >> 2;++ pal[idx] = base;+ graphics_set_palette(idx, r, g, b);+ ++idx;+ }+ }++ x = y = len = 0;++ s1 = (unsigned char*)VSHADOW1;+ s2 = (unsigned char*)VSHADOW2;+ s4 = (unsigned char*)VSHADOW4;+ s8 = (unsigned char*)VSHADOW8;++ for (i = 0; i < 38400; i++)+ s1[i] = s2[i] = s4[i] = s8[i] = 0;++ /* parse xpm data */+ while (y < height) {+ while (1) {+ if (!grub_read((char *)&c, 1)) {+ grub_close();+ return 0;+ }+ if (c == '"')+ break;+ }++ while (grub_read((char *)&c, 1) && c != '"') {+ for (i = 1; i < 15; i++)+ if (pal[i] == c) {+ c = i;+ break;+ }++ mask = 0x80 >> (x & 7);+ if (c & 1)+ s1[len + (x >> 3)] |= mask;+ if (c & 2)+ s2[len + (x >> 3)] |= mask;+ if (c & 4)+ s4[len + (x >> 3)] |= mask;+ if (c & 8)+ s8[len + (x >> 3)] |= mask;++ if (++x >= 640) {+ x = 0;++ if (y < 480)+ len += 80;+ ++y;+ }+ }+ }++ grub_close();++set_palette:++ graphics_set_palette(0, (background >> 16), (background >> 8) & 63, + background & 63);+ graphics_set_palette(15, (foreground >> 16), (foreground >> 8) & 63, + foreground & 63);+ graphics_set_palette(0x11, (border >> 16), (border >> 8) & 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 */+static void graphics_setxy(int col, int row) {+ if (col >= x0 && col < x1) {+ fontx = col;+ cursorX = col << 3;+ }+ if (row >= y0 && row < y1) {+ fonty = row;+ cursorY = row << 4;+ }+}++/* scroll the screen */+static void graphics_scroll(void) {+ 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 */+ for (j = y0 + 1; j < y1; j++) {+ graphics_gotoxy(x0, j - 1);+ for (i = x0; i < x1; i++) {+ graphics_putchar(text[j * 80 + i]);+ }+ }++ /* last line should be blank */+ graphics_gotoxy(x0, y1 - 1);+ for (i = x0; i < x1; i++)+ graphics_putchar(' ');+ graphics_setxy(x0, y1 - 1);++ no_scroll = 0;+}+++void graphics_cursor(int set) {+ unsigned char *pat, *mem, *ptr, chr[16 << 2];+ int i, ch, invert, offset;++ if (set && no_scroll)+ return;++ offset = cursorY * 80 + fontx;+ ch = text[fonty * 80 + fontx] & 0xff;+ invert = (text[fonty * 80 + fontx] & 0xff00) != 0;+ pat = font8x16 + (ch << 4);++ mem = (unsigned char*)VIDEOMEM + offset;++ if (!set) {+ for (i = 0; i < 16; i++) {+ unsigned char mask = pat[i];++ if (!invert) {+ chr[i ] = ((unsigned char*)VSHADOW1)[offset];+ chr[16 + i] = ((unsigned char*)VSHADOW2)[offset];+ chr[32 + i] = ((unsigned char*)VSHADOW4)[offset];+ chr[48 + i] = ((unsigned char*)VSHADOW8)[offset];++ /* FIXME: if (shade) */+ if (1) {+ if (ch == DISP_VERT || ch == DISP_LL ||+ ch == DISP_UR || ch == DISP_LR) {+ unsigned char pmask = ~(pat[i] >> 1);++ chr[i ] &= pmask;+ chr[16 + i] &= pmask;+ chr[32 + i] &= pmask;+ chr[48 + i] &= pmask;+ }+ if (i > 0 && ch != DISP_VERT) {+ unsigned char pmask = ~(pat[i - 1] >> 1);++ chr[i ] &= pmask;+ chr[16 + i] &= pmask;+ chr[32 + i] &= pmask;+ chr[48 + i] &= pmask;+ if (ch == DISP_HORIZ || ch == DISP_UR || ch == DISP_LR) {+ pmask = ~pat[i - 1];++ chr[i ] &= pmask;+ chr[16 + i] &= pmask;+ chr[32 + i] &= pmask;+ chr[48 + i] &= pmask;+ }+ }+ }+ chr[i ] |= mask;+ chr[16 + i] |= mask;+ chr[32 + i] |= mask;+ chr[48 + i] |= mask;++ offset += 80;+ }+ else {+ chr[i ] = mask;+ chr[16 + i] = mask;+ chr[32 + i] = mask;+ chr[48 + i] = mask;+ }+ }+ }+ else {+ MapMask(15);+ ptr = mem;+ for (i = 0; i < 16; i++, ptr += 80) {+ cursorBuf[i] = pat[i];+ *ptr = ~pat[i];+ }+ return;+ }++ offset = 0;+ for (i = 1; i < 16; i <<= 1, offset += 16) {+ int j;++ MapMask(i);+ ptr = mem;+ for (j = 0; j < 16; j++, ptr += 80)+ *ptr = chr[j + offset];+ }++ MapMask(15);+}++#endif /* SUPPORT_GRAPHICS */diff -Naur grub-0.97_emulation/stage2/graphics.h grub-0.97_splash/stage2/graphics.h--- grub-0.97_emulation/stage2/graphics.h 1970-01-01 08:00:00.000000000 +0800+++ grub-0.97_splash/stage2/graphics.h 2006-10-24 12:28:51.000000000 +0800@@ -0,0 +1,42 @@+/* graphics.h - graphics console interface */+/*+ * GRUB -- GRand Unified Bootloader+ * Copyright (C) 2002 Free Software Foundation, Inc.+ *+ * 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., 675 Mass Ave, Cambridge, MA 02139, USA.+ */++#ifndef GRAPHICS_H+#define GRAPHICS_H++/* magic constant */+#define VIDEOMEM 0xA0000++/* function prototypes */+char *graphics_get_splash(void);++//static int read_image(char *s);+void graphics_cursor(int set);++/* function prototypes for asm functions */+void * graphics_get_font();+void graphics_set_palette(int idx, int red, int green, int blue);+void set_int1c_handler();+void unset_int1c_handler();++extern short cursorX, cursorY;+extern char cursorBuf[16];++#endif /* GRAPHICS_H */diff -Naur grub-0.97_emulation/stage2/Makefile.am grub-0.97_splash/stage2/Makefile.am--- grub-0.97_emulation/stage2/Makefile.am 2006-10-24 12:28:51.000000000 +0800+++ grub-0.97_splash/stage2/Makefile.am 2006-10-24 12:28:51.000000000 +0800@@ -7,7 +7,7 @@ ntfs.h fat.h filesys.h freebsd.h fs.h hercules.h i386-elf.h \ imgact_aout.h iso9660.h jfs.h mb_header.h mb_info.h md5.h \ nbi.h pc_slice.h serial.h shared.h smp-imps.h term.h \- terminfo.h tparm.h nbi.h ufs2.h vstafs.h xfs.h+ terminfo.h tparm.h nbi.h ufs2.h vstafs.h xfs.h graphics.h EXTRA_DIST = setjmp.S apm.S $(noinst_SCRIPTS) # For <stage1.h>.@@ -19,7 +19,7 @@ disk_io.c fsys_ext2fs.c fsys_fat.c fsys_ntfs.c fsys_ffs.c fsys_iso9660.c \ fsys_jfs.c fsys_minix.c fsys_reiserfs.c fsys_ufs2.c \ fsys_vstafs.c fsys_xfs.c gunzip.c md5.c serial.c stage2.c \- terminfo.c tparm.c+ terminfo.c tparm.c graphics.c libgrub_a_CFLAGS = $(GRUB_CFLAGS) -I$(top_srcdir)/lib \ -DGRUB_UTIL=1 -DFSYS_EXT2FS=1 -DFSYS_FAT=1 -DFSYS_NTFS=1 -DFSYS_FFS=1 \ -DFSYS_ISO9660=1 -DFSYS_JFS=1 -DFSYS_MINIX=1 -DFSYS_REISERFS=1 \@@ -79,8 +79,14 @@ HERCULES_FLAGS = endif +if GRAPHICS_SUPPORT+GRAPHICS_FLAGS = -DSUPPORT_GRAPHICS=1+else+GRAPHICS_FLAGS =+endif+ STAGE2_COMPILE = $(STAGE2_CFLAGS) -fno-builtin -nostdinc \- $(NETBOOT_FLAGS) $(SERIAL_FLAGS) $(HERCULES_FLAGS)+ $(NETBOOT_FLAGS) $(SERIAL_FLAGS) $(HERCULES_FLAGS) $(GRAPHICS_FLAGS) STAGE1_5_LINK = -nostdlib -Wl,-N -Wl,-Ttext -Wl,2000 STAGE1_5_COMPILE = $(STAGE2_COMPILE) -DNO_DECOMPRESSION=1 -DSTAGE1_5=1@@ -90,7 +96,7 @@ cmdline.c common.c console.c disk_io.c fsys_ext2fs.c \ fsys_fat.c fsys_ntfs.c fsys_ffs.c fsys_iso9660.c fsys_jfs.c fsys_minix.c \ fsys_reiserfs.c fsys_ufs2.c fsys_vstafs.c fsys_xfs.c gunzip.c \- hercules.c md5.c serial.c smp-imps.c stage2.c terminfo.c tparm.c+ hercules.c md5.c serial.c smp-imps.c stage2.c terminfo.c tparm.c graphics.c pre_stage2_exec_CFLAGS = $(STAGE2_COMPILE) $(FSYS_CFLAGS) pre_stage2_exec_CCASFLAGS = $(STAGE2_COMPILE) $(FSYS_CFLAGS) pre_stage2_exec_LDFLAGS = $(PRE_STAGE2_LINK)diff -Naur grub-0.97_emulation/stage2/shared.h grub-0.97_splash/stage2/shared.h--- grub-0.97_emulation/stage2/shared.h 2006-10-24 12:28:51.000000000 +0800+++ grub-0.97_splash/stage2/shared.h 2006-10-24 12:28:51.000000000 +0800@@ -948,6 +948,7 @@ int grub_tolower (int c); int grub_isspace (int c); int grub_strncat (char *s1, const char *s2, int n);+void *grub_memcpy (void *to, const void *from, unsigned int n); void *grub_memmove (void *to, const void *from, int len); void *grub_memset (void *start, int c, int len); int grub_strncat (char *s1, const char *s2, int n);diff -Naur grub-0.97_emulation/stage2/stage2.c grub-0.97_splash/stage2/stage2.c--- grub-0.97_emulation/stage2/stage2.c 2006-10-24 12:28:51.000000000 +0800+++ grub-0.97_splash/stage2/stage2.c 2006-10-24 12:28:51.000000000 +0800@@ -244,6 +244,7 @@ { int c, time1, time2 = -1, first_entry = 0; char *cur_entry = 0;+ struct term_entry *prev_term = NULL; /* * Main loop for menu UI.@@ -733,6 +734,15 @@ cls (); setcursor (1);+ /* if our terminal needed initialization, we should shut it down+ * before booting the kernel, but we want to save what it was so+ * we can come back if needed */+ prev_term = current_term;+ if (current_term->shutdown) + {+ (*current_term->shutdown)();+ current_term = term_table; /* assumption: console is first */+ } while (1) {@@ -767,6 +777,13 @@ break; } + /* if we get back here, we should go back to what our term was before */+ current_term = prev_term;+ if (current_term->startup)+ /* if our terminal fails to initialize, fall back to console since+ * it should always work */+ if ((*current_term->startup)() == 0)+ current_term = term_table; /* we know that console is first */ show_menu = 1; goto restart; }@@ -1222,6 +1239,10 @@ #endif /* GRUB_UTIL */ } + /* go ahead and make sure the terminal is setup */+ if (current_term->startup)+ (*current_term->startup)();+ if (! num_entries) { /* If no acceptable config file, goto command-line, startingdiff -Naur grub-0.97_emulation/stage2/term.h grub-0.97_splash/stage2/term.h--- grub-0.97_emulation/stage2/term.h 2003-07-09 19:45:53.000000000 +0800+++ grub-0.97_splash/stage2/term.h 2006-10-24 12:28:51.000000000 +0800@@ -60,6 +60,8 @@ const char *name; /* The feature flags defined above. */ unsigned long flags;+ /* Default for maximum number of lines if not specified */+ unsigned short max_lines; /* Put a character. */ void (*putchar) (int c); /* Check if any input character is available. */@@ -79,6 +81,11 @@ void (*setcolor) (int normal_color, int highlight_color); /* Turn on/off the cursor. */ int (*setcursor) (int on);++ /* function to start a terminal */+ int (*startup) (void);+ /* function to use to shutdown a terminal */+ void (*shutdown) (void); }; /* This lists up available terminals. */@@ -124,4 +131,23 @@ int hercules_setcursor (int on); #endif +#ifdef SUPPORT_GRAPHICS+extern int foreground, background, border, graphics_inited;++void graphics_set_splash(char *splashfile);+int set_videomode (int mode);+void graphics_putchar (int c);+int graphics_getxy(void);+void graphics_gotoxy(int x, int y);+void graphics_cls(void);+void graphics_setcolorstate (color_state state);+void graphics_setcolor (int normal_color, int highlight_color);+int graphics_setcursor (int on);+int graphics_init(void);+void graphics_end(void);++int hex(int v);+void graphics_set_palette(int idx, int red, int green, int blue);+#endif /* SUPPORT_GRAPHICS */+ #endif /* ! GRUB_TERM_HEADER */
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -