Permalink
Browse files

. 修正 setmenu 函数,并且增加下列参数:(issues #159)。

  1. --draw-box=[索引]=[起始x]=[起始y]=[水平长度]=[垂直长度]=[线宽]=[颜色]
	  划线或画框。其中:索引=1-16;颜色=24色;线宽=1-255;尺寸单位是像素。
	  --draw-box=[索引]  清除指定的线或框。
	  --draw-box=        清除所有的线或框。
	2. --string=  清除所有的字符串。
  • Loading branch information...
yaya
yaya committed Nov 28, 2017
1 parent b912f30 commit 2b6d24389bcc1138b68ae18437a1f4ff78f6da43
Showing with 164 additions and 45 deletions.
  1. +8 −0 ChangeLog_chenall.txt
  2. +88 −15 stage2/builtins.c
  3. +19 −4 stage2/graphics.c
  4. +20 −0 stage2/shared.h
  5. +29 −26 stage2/stage2.c
View
@@ -1,4 +1,12 @@
更新说明:
2017-11-28(yaya)
修正 setmenu 函数,并且增加下列参数:
1. --draw-box=[索引]=[起始x]=[起始y]=[水平长度]=[垂直长度]=[线宽]=[颜色]
划线或画框。其中:索引=1-16;颜色=24色;线宽=1-255;尺寸单位是像素。
--draw-box=[索引] 清除指定的线或框。
--draw-box= 清除所有的线或框。
2. --string= 清除所有的字符串。
2017-10-14(yaya)
修正udf引导代码。
可启动U盘制作:把 grldr.pbr 的 udf 引导代码(0x1400起始)复制到U盘启动分区,
View
@@ -16248,11 +16248,14 @@ unsigned short graphic_wide;
unsigned short graphic_high;
unsigned short row_space;
char graphic_file[128];
struct box DrawBox[16];
struct string strings[16];
char *p_string= (char *)MENU_TITLE;
unsigned long string_total = 0;
static int
setmenu_func(char *arg, int flags)
{
char *p = (char *)MENU_TITLE;
char *tem;
unsigned long long val;
struct border tmp_broder = {218,191,192,217,196,179,2,0,2,0,0,2,0,0,0};
@@ -16262,27 +16265,80 @@ setmenu_func(char *arg, int flags)
if (grub_memcmp (arg, "--string=", 9) == 0)
{
unsigned char i;
char *p1;
i = num_string;
if (i > 15)
return 0;
arg += 9;
errorcheck_func ("off",0);
if (safe_parse_maxint (&arg, &val))
*(unsigned long *)(p + i*0x10c) = val; //x
strings[i].start_x = val; //x
else
{
num_string = 0;
errorcheck_func ("on",0);
continue;
}
errorcheck_func ("on",0);
arg++;
if (safe_parse_maxint (&arg, &val))
*(unsigned long *)(p + i*0x10c + 4) = val; //y
strings[i].start_y = val; //y
arg++;
if (safe_parse_maxint (&arg, &val))
*(unsigned long *)(p + i*0x10c + 8) = val; //color
else
*(unsigned long *)(p + i*0x10c + 8) = -1;
strings[i].color = val; //color
arg += 2;
p1 = p + i*0x10c + 0xc;
strings[i].addr = (int)p_string; //addr
i = parse_string(arg);
string_total += i;
if (string_total > 0x800)
return 0;
arg[i] = 0;
for (; *arg && *arg != '"'; p1++,arg++)
*p1 = *arg;
*p1 = 0;
for (; *arg && *arg != '"'; p_string++,arg++)
*p_string = *arg;
*p_string++ = 0;
num_string++;
}
if (grub_memcmp (arg, "--draw-box=", 11) == 0)
{
unsigned char i;
arg += 11;
errorcheck_func ("off",0);
if (safe_parse_maxint (&arg, &val))
i = val;
else
{
for (i=0; i<16; i++)
DrawBox[i].index = 0;
errorcheck_func ("on",0);
continue;
}
errorcheck_func ("on",0);
if (*arg != '=')
{
DrawBox[i].index = 0;
continue;
}
if (i > 16)
return 0;
DrawBox[i].index = i;
arg++;
if (safe_parse_maxint (&arg, &val))
DrawBox[i].start_x = val;
arg++;
if (safe_parse_maxint (&arg, &val))
DrawBox[i].start_y = val;
arg++;
if (safe_parse_maxint (&arg, &val))
DrawBox[i].horiz = val;
arg++;
if (safe_parse_maxint (&arg, &val))
DrawBox[i].vert = val;
arg++;
if (safe_parse_maxint (&arg, &val))
DrawBox[i].linewidth = val;
arg++;
if (safe_parse_maxint (&arg, &val))
DrawBox[i].color = val;
}
else if (grub_memcmp (arg, "--timeout=", 10) == 0)
{
@@ -16298,17 +16354,23 @@ setmenu_func(char *arg, int flags)
}
else if (grub_memcmp (arg, "--u", 3) == 0)
{
int i;
menu_tab = 0;
num_string = 0;
menu_font_spacing = 0;
menu_line_spacing = 0;
font_spacing = 0;
line_spacing = 0;
current_term->max_lines = current_y_resolution / font_h;
current_term->chars_per_line = current_x_resolution / font_w;
if (current_x_resolution && current_y_resolution)
{
current_term->max_lines = current_y_resolution / font_h;
current_term->chars_per_line = current_x_resolution / font_w;
}
*(unsigned char *)0x8274 = 0;
memmove ((char *)&menu_border,(char *)&tmp_broder,sizeof(tmp_broder));
graphic_type = 0;
for (i=0; i<16; i++)
DrawBox[i].index = 0;
return 1;
}
else if (grub_memcmp (arg, "--ver-on", 8) == 0)
@@ -16434,7 +16496,12 @@ setmenu_func(char *arg, int flags)
menu_border.menu_help_x = val;
arg++;
if (safe_parse_maxint (&arg, &val))
menu_border.menu_help_w = val;
{
if (menu_border.menu_help_x + val > current_term->chars_per_line)
menu_border.menu_help_w = current_term->chars_per_line - menu_border.menu_help_x;
else
menu_border.menu_help_w = val;
}
arg++;
if (safe_parse_maxint (&arg, &val))
menu_border.menu_box_b = val; //y
@@ -16486,7 +16553,8 @@ static struct builtin builtin_setmenu =
"--left-align* --right-align --auto-num-off* --auto-num-on\n"
"--highlight-short* --highlight-full\n"
"--font-spacing=[font]:[line]. default 0\n"
"--string=[x]=[y]=[color]=[\"string\"]\n"
"--string=[x]=[y]=[color]=[\"string\"] max 16 commands.\n"
" --string= to delete all strings.\n"
"--box x=[x] y=[y] w=[w] h=[h] l=[l]\n"
"Note: [w]=0 in the middle. [l]=0 no display border\n"
"--help=[x]=[w]=[y]\n"
@@ -16503,6 +16571,11 @@ static struct builtin builtin_setmenu =
"setmenu --graphic-entry=type=row=list=wide=high=row_space START_FILE\n"
"type: bit0:highlight bit1:flip bit2:box bit7:transparent background\n"
"naming rules for START_FILE: *n.??? n: 00-99\n"
"--u clear all.\n"
"--draw-box=[index]=[start_x]=[start_y]=[horiz]=[vert]=[linewidth]=[color].\n"
" [index]:1-16; [color]:24-bit color; [linewidth]:1-255; all dimensions in pixels.\n"
" --draw-box=[index] to delete the specified index.\n"
" --draw-box= to delete all indexes."
};
View
@@ -2384,10 +2384,16 @@ void rectangle(int left, int top, int length, int width, int line)
if (!graphics_inited || graphics_mode < 0xff || !line)
return;
y = current_bytes_per_scanline * (width - line);
if (width)
y = current_bytes_per_scanline * (width - line);
else
y = 0;
z = current_bytes_per_pixel;
lfb = (unsigned char *)(current_phys_base + top * current_bytes_per_scanline + left * z);
if (!length)
goto vert;
for (i=0;i<line;++i)
{
p = lfb + current_bytes_per_scanline*i;
@@ -2407,13 +2413,22 @@ void rectangle(int left, int top, int length, int width, int line)
p += z;
}
}
vert:
if (!width)
return;
if (length)
{
y = z * (length - line);
lfb += line*current_bytes_per_scanline;
}
else
y = 0;
y = z * (length - line);
lfb += line*current_bytes_per_scanline;
for (i=0;i<line;++i)
{
p = lfb + z * i;
for (x=line*2;x<width;++x)
for (x=(length ? (line*2) : 0);x<width;++x)
{
if (z == 3)
{
View
@@ -483,6 +483,26 @@ extern void rectangle(int left, int top, int length, int width, int line);
extern int hex (int v);
extern unsigned long splashimage_loaded;
extern unsigned long X_offset,Y_offset;
struct box
{
unsigned char index;
unsigned short start_x;
unsigned short start_y;
unsigned short horiz;
unsigned short vert;
unsigned char linewidth;
unsigned long color;
} __attribute__ ((packed));
extern struct box DrawBox[16];
struct string
{
unsigned char start_x;
unsigned char start_y;
unsigned long long color;
int addr;
} __attribute__ ((packed));
extern struct string strings[16];
extern unsigned long string_total;
#define MENU_TITLE 0x3A8000
#define MENU_TITLE_LENGTH 0x800
/* The Chinese patch will begin at here */
View
@@ -123,7 +123,7 @@ static void print_help_message (const char *message,int flags)
if (MENU_BOX_B + 1 + j > current_term->max_lines)
return;
gotoxy (MENU_HELP_X, MENU_BOX_B + 1 + j);
for (x = MENU_HELP_X; x < MENU_HELP_E + 1; x++)
for (x = MENU_HELP_X; x < MENU_HELP_E; x++)
grub_putchar (' ', 255);
}
}
@@ -166,13 +166,19 @@ static void print_help_message (const char *message,int flags)
{
if (c && c != '\n' && fontx >= start_offcet)
{
if (fontx == MENU_HELP_E - 1)
if (c > 0x7F && !(menu_tab & 0x40))
{
grub_putchar (' ', 255);
continue;
}
grub_putchar (c, 255);
c = *(++message);
}
else
grub_putchar (' ', 255);
}
for (x = fontx; x < current_term->chars_per_line/* - 1*/; x++)
for (x = fontx; x < MENU_HELP_E; x++)
grub_putchar (' ', 255);
}
}
@@ -807,39 +813,36 @@ run_menu (char *menu_entries, char *config_entries, /*int num_entries,*/ char *h
init_page ();
//setcursor (0);
if (graphics_inited && graphics_mode > 0xff)/*vbe mode call rectangle_func*/
{
int i,j;
unsigned long long col = current_color_64bit;
for (i=0; i<16; i++)
{
if (DrawBox[i].index == 0)
continue;
current_color_64bit = DrawBox[i].color;
rectangle(DrawBox[i].start_x, DrawBox[i].start_y, DrawBox[i].horiz, DrawBox[i].vert, DrawBox[i].linewidth);
}
if (num_string)
{
unsigned char *p = (unsigned char *)MENU_TITLE;
unsigned char i,j;
int start_offcet = 0;
i = num_string;
unsigned long long col = current_color_64bit;
for (j=0; j<i;j++)
for (j=0; j<i+1;j++)
{
if((menu_tab & 0x40))
start_offcet = current_term->chars_per_line - *(unsigned long *)((char *)p + j*0x10c) - num_text_char((char *)p + j*0x10c + 0xc);
start_offcet = current_term->chars_per_line - strings[j].start_x - num_text_char((char *)strings[j].addr);
else
start_offcet = *(unsigned long *)(p + j*0x10c);
gotoxy (start_offcet, *(unsigned long *)(p + j*0x10c + 4));
if((current_color_64bit = *(unsigned long *)(p + j*0x10c + 8)) == 0xffffffff)
{
if(*(unsigned long *)(p + j*0x10c + 4) < MENU_BOX_Y)
{
if (current_term->setcolorstate)
current_term->setcolorstate (COLOR_STATE_HEADING);
}
else if(*(unsigned long *)(p + j*0x10c + 4) > MENU_BOX_B)
{
if (current_term->setcolorstate)
current_term->setcolorstate (COLOR_STATE_HELPTEXT);
}
}
grub_printf("%-*.*s",current_term->chars_per_line,current_term->chars_per_line,p + j*0x10c + 0xc);
start_offcet = strings[j].start_x;
gotoxy (start_offcet, strings[j].start_y);
current_color_64bit = strings[j].color;
grub_printf("%s",strings[j].addr);
}
current_color_64bit = col;
}
current_color_64bit = col;
}
if (current_term->flags & TERM_DUMB)
print_entries_raw (num_entries, first_entry, menu_entries);

0 comments on commit 2b6d243

Please sign in to comment.