免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2747 | 回复: 2
打印 上一主题 下一主题

图形模式 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2015-10-30 12:56 |只看该作者 |倒序浏览
本帖最后由 626788149 于 2015-10-30 14:02 编辑

当屏幕满的时候 我需要向上滚动一行以显示新的内容

比如,我想打印10000行的信息,在qeum虚拟机下大概需要几秒钟的时间
但是在boch下或者在真实的机器下需要大概十分钟的时间才能全部打印完

如何才能加速呢?
当屏幕满的时候 我需要向上滚动一样以显示新的内容

比如,我想打印10000行的信息,在qeum虚拟机下大概需要几秒钟的时间
但是在boch下或者在真实的机器下需要大概十分钟的时间才能全部打印完

如何才能加速呢?

  1. void init_vbe(uint32_t *p){
  2. //初始化VGA 获得一些VGA的信息
  3.    multiboot_info_t* minf = (multiboot_info_t*)p;
  4.    

  5.    //find if there have info about vbe
  6.         //
  7.    if((minf == NULL) || (minf->flags & 0x800) != 0x800)
  8.       return;
  9.    
  10.    VbeInfoBlock* vbeib = (VbeInfoBlock*)minf->vbe_info.vbe_control_info;
  11.    ModeInfoBlock* vebmb = (ModeInfoBlock*)minf->vbe_info.vbe_mode_info;
  12.    
  13.    //D7 = Linear frame buffer mode is available
  14.    //0 = No
  15.    //1 = Yes
  16.    
  17.    if((vebmb == NULL) || (vebmb->attributes & 0x80) != 0x80){
  18.       //Linear frame buffer mode is unavailable
  19.       return;
  20.    }
  21.    if((vebmb->attributes & 0x10) == 0x10){
  22.       //text mode
  23.       video.mode = 0;   
  24.    }else{
  25.       video.mode = 1;
  26.    }
  27.    extern char _binary_font_bin_start[];

  28.     video.screen = (unsigned char*)vebmb->physbase;// Linear frame buffer 基地址
  29.    video.Xres = vebmb->Xres;
  30.    video.Yres = vebmb->Yres;
  31.    video.bpp = vebmb->bpp;
  32.    video.pitch = vebmb->pitch;
  33.    video.font_address = _binary_font_bin_start;
  34.    video.buff_size = video.Xres * video.Yres * (video.bpp/8);
  35.    video.crt_pos = 0;
  36.    video.fonth = 16;   //font pixel height
  37.    video.fontw = 8;
  38.    video.xpos = video.ypos = 0;
  39.    
  40.    
  41.    if(video.mode)
  42.       video.numchars = video.Xres * video.Yres / video.fonth /video.fontw;
  43.    else
  44.       video.numchars = video.Xres * video.Yres;

  45.    video.nchars_colum = video.Xres / video.fontw;
  46.    video.nchars_line = video.Yres / video.fonth;

  47.    cprintf("video.bpp:%d\n",video.bpp);
  48.    cprintf("video.pitch:%d\n",video.pitch);
  49.    cprintf("vbeib->TotalMemory:%dMB\n",vbeib->TotalMemory*64/1024);
  50.    cprintf("vbeib.buff_size:%dkb\n",video.buff_size/1024);
  51.    cprintf("vbeib->screen:%x\n",video.screen);

  52. }
复制代码

  1. void vga_putc(int c){
  2.    // if no attribute given, then use black on white
  3.    if (!(c & ~0xFF))
  4.       c |= 0xFFFFFF00;
  5.    
  6.    switch (c & 0xff) {
  7.    case '\n':
  8.       video.ypos++;
  9.       /* fallthru */
  10.    case '\r':
  11.       video.xpos = 0;
  12.       break;
  13.    case '\t':
  14.       cons_putc(' ');
  15.       cons_putc(' ');
  16.       cons_putc(' ');
  17.       cons_putc(' ');
  18.       cons_putc(' ');
  19.       break;
  20.    default:
  21.       //x * video.fontw, y * video.fontw
  22.       draw_char((c & 0xFF),video.xpos * video.fontw, video.ypos * video.fonth ,(c>>8) & 0xFF, (c>>16) & 0xFF,(c>>24) & 0xFF);
  23.       video.xpos++;
  24.       break;
  25.    }
  26.    if (video.xpos >= video.nchars_colum ){
  27.       video.xpos = 0;
  28.       video.ypos++;
  29.    }
  30.    if(video.ypos >= video.nchars_line){
  31. //这一步用于滚屏
  32.       //video.fonth is height of font
  33.       memmove(video.screen, video.screen + video.Xres * video.bpp/8 * video.fonth,
  34.              (video.buff_size - video.Xres * video.bpp/8* video.fonth));
  35.       video.ypos--;
  36.       int i;
  37.       for (i = 0; i < video.nchars_colum; i++){
  38.          draw_char(' ',(video.xpos + i) * video.fontw, video.ypos * video.fonth ,(c>>8) & 0xFF, (c>>16) & 0xFF,(c>>24) & 0xFF);
  39.          
  40.       }
  41.    }

  42. }
复制代码
  1. void draw_char(char ch, int x, int y,unsigned char r,unsigned char g,unsigned char b)  
  2. {  
  3. //这个函数用于画字符
  4.    int bar = video.bpp/8;
  5.    char* font = video.font_address + ch*16;
  6.    unsigned char *where = video.screen + x*bar + y*video.Xres*bar;
  7.    int i, j;
  8.    
  9.    
  10.    for (i = 0; i < 16; i++) {
  11.       uint8_t bit = 0x80;
  12.       for (j = 0; j < 8; j++) {
  13.          if(*font & bit){
  14.             
  15.             where[j*bar] = b;
  16.             where[j*bar + 1] = g;
  17.             where[j*bar + 2] = r;
  18.          }
  19.          else{
  20.             where[j*bar] = 0x00;
  21.             where[j*bar + 1] = 0x00;
  22.             where[j*bar + 2] = 0x00;
  23.          }
  24.          bit = bit >> 1;
  25.       }
  26.       where+=video.bpp*video.Xres/8;
  27.       font ++;
  28.    }
  29. }
复制代码
  1. static void putpixel(unsigned char* screen, int x,int y, int color) {
  2. //这个函数用于画点
  3.    int i = video.bpp/8;
  4.    unsigned where = x*i + y*i*video.Xres;
  5.    screen[where] = color & 255;              // BLUE
  6.    screen[where + 1] = (color >> 8) & 255;   // GREEN
  7.    screen[where + 2] = (color >> 16) & 255;  // RED
  8. }
复制代码
刷新的速度很慢

论坛徽章:
2
IT运维版块每日发帖之星
日期:2015-11-14 06:20:00IT运维版块每周发帖之星
日期:2016-01-07 23:04:26
2 [报告]
发表于 2015-11-11 21:43 |只看该作者
看看 aaa 1

论坛徽章:
12
射手座
日期:2014-10-02 11:31:29程序设计版块每日发帖之星
日期:2016-05-28 06:20:00每日论坛发贴之星
日期:2016-05-27 06:20:00程序设计版块每日发帖之星
日期:2016-05-27 06:20:00程序设计版块每日发帖之星
日期:2016-05-25 06:20:00每日论坛发贴之星
日期:2016-05-24 06:20:00程序设计版块每日发帖之星
日期:2016-05-24 06:20:0015-16赛季CBA联赛之深圳
日期:2016-05-23 15:33:59程序设计版块每日发帖之星
日期:2016-05-20 06:20:00程序设计版块每日发帖之星
日期:2016-04-26 06:20:00神斗士
日期:2015-12-03 09:27:3215-16赛季CBA联赛之八一
日期:2016-12-29 09:56:05
3 [报告]
发表于 2015-12-29 15:57 |只看该作者
看看刷新的速度很慢呢?
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP