Skip to content
Permalink
Browse files

. 修正动态 VHD 不再能够支持的问题。

. 条件菜单项目(iftitle )支持图形菜单。
. 图形菜单改进:支持背景高亮、支持图文混排。
  • Loading branch information...
yaya
yaya committed Mar 25, 2019
1 parent fe3c857 commit 1069d58eb54d798c8bf58ee9a6565fac97e74e3d
Showing with 116 additions and 31 deletions.
  1. +12 −0 ChangeLog_chenall.txt
  2. +5 −3 stage2/builtins.c
  3. +3 −3 stage2/dec_vhd.c
  4. +55 −18 stage2/graphics.c
  5. +3 −0 stage2/shared.h
  6. +38 −7 stage2/stage2.c
@@ -1,4 +1,16 @@
更新说明:
2019-03-25(yaya)
修正动态 VHD 不再能够支持的问题。
条件菜单项目(iftitle )支持图形菜单。
图形菜单改进:支持背景高亮、支持图文混排。

setmenu --graphic-entry=图形类型=图形菜单行数=图形菜单列数=图形宽=图形高=图形行间隙 图形文件
图文混排时,图形与文本选中项(高亮项)的设置,是各种独立的,可以单独设置。
如果高亮只需要通过文本实现,图形类型可设置为0x90.
图形类型:
位0:前景高亮 位1:前景色翻转 位2:图形加框 位3:背景高亮 位4:图文混排 位7:背景透明
图形行间隙在图文混排模式,不能实现随意调整。如果间隙不理想,可以设置图形间隙为零。然后使用增加字符间距实现。(setmenu --font-spacing=0:n)

2018-12-23(yaya)
修正读磁盘越界不报警。

@@ -4152,7 +4152,6 @@ static int terminal_func (char *arg, int flags);
extern char splashimage[128];
int graphicsmode_func (char *arg, int flags);
unsigned long X_offset,Y_offset;
int vbe_fill_color (unsigned long color);
unsigned char animated_type=0; //bit 0-3:times bit 4:repeat forever bit 7:transparent background type=00:disable
unsigned short animated_delay;
unsigned char animated_last_num;
@@ -4288,7 +4287,7 @@ static struct builtin builtin_splashimage =
"type: bit 7:transparent background\n"
"splashimage --fill-color=[0xrrggbb]\n"
"splashimage --animated=[type]=[duration]=[last_num]=[x]=[y] START_FILE\n"
"type: bit 0-3:times bit 4:repeat forever bit 5:wait time \n"
"type: bit 0-3:times(0=repeat play) bit 5:alone\n"
" bit 7:transparent background type=00:disable\n"
"duration: [10] unit is a tick. [10:ms] units are milliseconds,\n"
"naming rules for START_FILE: *n.??? n: 1-9 or 01-99 or 001-999\n"
@@ -16313,6 +16312,7 @@ unsigned char timeout_y = 0;
unsigned long long timeout_color = 0;
unsigned long long keyhelp_color = 0;
unsigned char graphic_type = 0;
unsigned char graphic_enable = 0;
unsigned char graphic_row;
unsigned char graphic_list;
unsigned short graphic_wide;
@@ -16656,6 +16656,7 @@ setmenu_func(char *arg, int flags)
arg++;
strcpy(graphic_file, arg);
menu_border.menu_box_h = graphic_row * graphic_list;
menu_border.border_w = 0;
}
else
return 0;
@@ -16697,7 +16698,8 @@ static struct builtin builtin_setmenu =
"Note: COLOR=0* default 'color highlight'.\n"
"* indicates default. Use 0xRRGGBB to represent colors.\n"
"setmenu --graphic-entry=type=row=list=wide=high=row_space START_FILE\n"
"type: bit0:highlight bit1:flip bit2:box bit7:transparent background\n"
"type: bit0:highlight bit1:flip bit2:box bit3:highlight background\n"
" bit4:Picture and text mixing 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"
@@ -182,8 +182,8 @@ dec_vhd_open(void)
memset(&footer, 0, sizeof(footer));
memset(&dynaheader, 0, sizeof(dynaheader));

//int bytesread = (int)grub_read((unsigned long)&footer, 0x200, 0xedde0d90);

int bytesread = (int)grub_read((unsigned long)&footer, 0x200, 0xedde0d90);
bytesread = bytesread;
//if (bytesread < 511) {
// grub_printf("bytesread %d < 511\n",bytesread);
// goto quit;
@@ -206,7 +206,7 @@ dec_vhd_open(void)
goto quit;
}
filepos = footer.dataOffset;
//bytesread = (int)grub_read((unsigned long)&dynaheader, sizeof(dynaheader), 0xedde0d90);
bytesread = (int)grub_read((unsigned long)&dynaheader, sizeof(dynaheader), 0xedde0d90);
// }

vhdfc = (VHDFileControl*) grub_malloc(sizeof(VHDFileControl));
@@ -1012,6 +1012,22 @@ graphics_cls (void)
#endif
}

void clear_entry (int x, int y, int w, int h);
void
clear_entry (int x, int y, int w, int h)
{
int i;
unsigned char *source;
unsigned char *objective;

for (i=0;i<h;i++)
{
source = (unsigned char *)IMAGE_BUFFER + x*current_bytes_per_pixel + y*current_bytes_per_scanline + i*current_bytes_per_scanline;
objective = (unsigned char *)current_phys_base + x*current_bytes_per_pixel + y*current_bytes_per_scanline + i*current_bytes_per_scanline;
grub_memmove (objective,source,w*current_bytes_per_pixel);
}
}

void vbe_fill_color (unsigned long color);

void
@@ -1155,7 +1171,7 @@ static int read_image_bmp(int type)
} __attribute__ ((packed)) bmih;
unsigned long bftmp,bfbit;
int x,y;
unsigned long source;
unsigned long source = 0;
unsigned char R,G,B;
only = 0;
if (type == 0)
@@ -1229,15 +1245,25 @@ static int read_image_bmp(int type)
B = (bftmp & 0xff0000)>>16;
G = (bftmp & 0xff00)>>8;
R = bftmp & 0xff;
if(background_transparent && (R>=R0) && (R<=R1) && (G>=G0) && (G<=G1) && (B>=B0) && (B<=B1))
source = *(unsigned long *)((unsigned char *)SPLASH_IMAGE+(x+X_offset)*current_bytes_per_pixel+(y+Y_offset)*current_bytes_per_scanline);
else if ((graphic_type & 1) && is_highlight)
source = current_color_64bit & 0xffffffff;
else if ((graphic_type & 2) && is_highlight)
source = bftmp ^ 0xffffffff;
if ((R>=R0) && (R<=R1) && (G>=G0) && (G<=G1) && (B>=B0) && (B<=B1))
{
if (background_transparent || (graphic_enable && (graphic_type & 0x80) && !(is_highlight && (graphic_type & 8))))
source = *(unsigned long *)((unsigned char *)SPLASH_IMAGE+(x+X_offset)*current_bytes_per_pixel+(y+Y_offset)*current_bytes_per_scanline);
else if (graphic_enable && is_highlight && (graphic_type & 8))
source = current_color_64bit & 0xffffffff;
else if (!graphic_enable || (graphic_enable && !(graphic_type & 0x80) && !(is_highlight && (graphic_type & 8))))
source = bftmp;
}
else
source = bftmp;

{
if (graphic_enable && is_highlight && (graphic_type & 1))
source = current_color_64bit & 0xffffffff;
else if (graphic_enable && is_highlight && (graphic_type & 2))
source = bftmp ^ 0xffffffff;
else
source = bftmp;
}

if(current_bits_per_pixel == 24 || current_bits_per_pixel == 32)
// bmp[x] = bftmp; //
*(unsigned long *)bmp = source;
@@ -1343,7 +1369,7 @@ static void StoreBuffer()
unsigned char R,G,B;
int y,u,v,rr,gg,bb;
unsigned long color;
unsigned long source;
unsigned long source = 0;

for(i=0;i<SampRate_Y_V*8;i++)
{
@@ -1424,15 +1450,26 @@ static void StoreBuffer()
lfb = (unsigned char *)current_phys_base + (sizei+i+Y_offset)*current_bytes_per_scanline + (sizej+j+X_offset)*current_bytes_per_pixel;

color = (((unsigned long)R)<<16) | (((unsigned long)G)<<8) | (unsigned long)B;
if(background_transparent && (R>=R0) && (R<=R1) && (G>=G0) && (G<=G1) && (B>=B0) && (B<=B1))
source = *(unsigned long *)((unsigned char *)SPLASH_IMAGE + (sizei+i+Y_offset)*current_bytes_per_scanline + (sizej+j+X_offset)*current_bytes_per_pixel);
else if ((graphic_type & 1) && is_highlight)
source = current_color_64bit & 0xffffffff;
else if ((graphic_type & 2) && is_highlight)
source = color ^ 0xffffffff;
else
source = color;

if ((R>=R0) && (R<=R1) && (G>=G0) && (G<=G1) && (B>=B0) && (B<=B1))
{
if (background_transparent || (graphic_enable && (graphic_type & 0x80) && !(is_highlight && (graphic_type & 8))))
source = *(unsigned long *)((unsigned char *)SPLASH_IMAGE + (sizei+i+Y_offset)*current_bytes_per_scanline + (sizej+j+X_offset)*current_bytes_per_pixel);
else if (graphic_enable && is_highlight && (graphic_type & 8))
source = current_color_64bit & 0xffffffff;
else if (!graphic_enable || (graphic_enable && !(graphic_type & 0x80) && !(is_highlight && (graphic_type & 8))))
source = color;
}
else
{
if (graphic_enable && is_highlight && (graphic_type & 1))
source = current_color_64bit & 0xffffffff;
else if (graphic_enable && is_highlight && (graphic_type & 2))
source = color ^ 0xffffffff;
else
source = color;
}

if(current_bits_per_pixel == 24 || current_bits_per_pixel == 32)
*(unsigned long *)lfb = source;
else
@@ -790,13 +790,16 @@ extern unsigned long long keyhelp_color;
//extern unsigned char font_type;
//extern unsigned char scan_mode;
//extern unsigned char store_mode;
extern unsigned char graphic_enable;
extern unsigned char graphic_type;
extern unsigned char graphic_row;
extern unsigned char graphic_list;
extern unsigned short graphic_wide;
extern unsigned short graphic_high;
extern unsigned short row_space;
extern char graphic_file[128];
extern void clear_entry (int x, int y, int w, int h);
extern void vbe_fill_color (unsigned long color);

#ifdef SUPPORT_GRAPHICS
extern unsigned long current_x_resolution;
@@ -348,6 +348,8 @@ num_text_char(char *p)
extern char menu_cfg[];
extern unsigned char menu_num_ctrl[];
int use_phys_base;
char graphic_file_shift[32];

static void
print_entry (int y, int highlight,int entryno, char *config_entries)
{
@@ -366,16 +368,41 @@ print_entry (int y, int highlight,int entryno, char *config_entries)
char tmp[128];
int file_len=grub_strlen(graphic_file);
int www = (font_w * MENU_BOX_W) / graphic_list;
graphic_file[file_len-6] = ((entryno%num_entries) / 10) | 0x30;
graphic_file[file_len-5] = ((entryno%num_entries) % 10) | 0x30;
sprintf(tmp,"--offset=%d=%d=%d %s",(graphic_type & 0x80),(font_w*MENU_BOX_X+((y-MENU_BOX_Y)%graphic_list)*(www)),(font_h*MENU_BOX_Y+((y-MENU_BOX_Y)/graphic_list)*(graphic_high+row_space)),graphic_file);
int graphic_x_offset, graphic_y_offset;
int text_y_offset = MENU_BOX_Y+((y-MENU_BOX_Y)*((graphic_high+row_space+font_h+line_spacing-1)/(font_h+line_spacing))/graphic_list);

graphic_x_offset = font_w*MENU_BOX_X+((y-MENU_BOX_Y)%graphic_list)*(www);

if (graphic_type & 0x10)
graphic_y_offset = (font_h+line_spacing)*text_y_offset-(graphic_high/2-(font_h+line_spacing)/2);
else
graphic_y_offset = font_h*MENU_BOX_Y+((y-MENU_BOX_Y)/graphic_list)*(graphic_high+row_space);

if (entryno >= num_entries)
{
clear_entry (graphic_x_offset,graphic_y_offset,graphic_wide,graphic_high);
entry++;
}
else
{
graphic_file[file_len-6] = ((entryno + graphic_file_shift[entryno]) / 10) | 0x30;
graphic_file[file_len-5] = ((entryno + graphic_file_shift[entryno]) % 10) | 0x30;
sprintf(tmp,"--offset=%d=%d=%d %s",0,graphic_x_offset,graphic_y_offset,graphic_file);
use_phys_base=1;
graphic_enable = 1;
splashimage_func(tmp,1);
// use_phys_base=0;
graphic_enable = 0;
if ((graphic_type & 4) && highlight)
rectangle((font_w*MENU_BOX_X+((y-MENU_BOX_Y)%graphic_list)*(www)),(font_h*MENU_BOX_Y+((y-MENU_BOX_Y)/graphic_list)*(graphic_high+row_space)),graphic_wide,graphic_high,3);
rectangle(graphic_x_offset,graphic_y_offset,graphic_wide,graphic_high,3);
}
c = *entry;
goto graphic_end;
if (graphic_type & 0x10)
{
gotoxy ((graphic_x_offset + graphic_wide + font_w -1)/font_w, text_y_offset);
goto graphic_mixing;
}
else
goto graphic_end;
}

gotoxy (MENU_BOX_X, y);
@@ -394,7 +421,7 @@ print_entry (int y, int highlight,int entryno, char *config_entries)
grub_putchar(highlight ? (menu_num_ctrl[2] = entryno,menu_cfg[1]) : ' ', 255);
}
}

graphic_mixing:
if (entry)
{
if (config_entries == (char*)titles)
@@ -2457,6 +2484,7 @@ cmain (void)
unsigned long debug_in_menu_init = 0;
//char *cmdline;
int is_preset;
grub_memset (graphic_file_shift, 0, 32);
menu_init_script_file[0] = 0;
{
int is_opened;
@@ -2584,6 +2612,9 @@ cmain (void)
}
else
{
int i;
for (i = num_entries + ((state & 0xf) ? 1 : 0); i < 32; i++)
graphic_file_shift[i] += 1;
state |= 0x10;
continue;
}

0 comments on commit 1069d58

Please sign in to comment.
You can’t perform that action at this time.