K
K
Kop3t32016-01-06 14:05:10
BIOS
Kop3t3, 2016-01-06 14:05:10

How to implement vesa framebuffer scrolling?

Good day!
I read articles on Habré about writing a hobby-OS.
I am writing text output through framebuffer. When the text reaches the bottom of the screen, something needs to be done with it. I decided to move the image up and draw a line of text in the free space.

void fb_set_pix(int x,int y,uint32_t color)
{
  unsigned where = x*(fbbpp/8) + y*fbpitch;
  framebuffer[where + 0] = color;              // BLUE
    framebuffer[where + 1] = (color >> 8);   // GREEN
    framebuffer[where + 2] = (color >> 16);  // RED
}

uint32_t fb_get_pix(int x,int y){
  unsigned where = x*(fbbpp/8) + y*fbpitch;
  uint32_t color=0;
  color = framebuffer[where + 0] + (framebuffer[where + 1] << 8) + (framebuffer[where + 1] << 16);
  return color;
}

void fb_scroll_y(int numpix, uint32_t color) {
  int i,j;
  // смещаем верх
  for(i=numpix; i<768; i++){ // height
    for(j=0; j<1024; j++){ // width
      fb_set_pix(j,i-numpix,fb_get_pix(j,i));
    }
  }
  // красим низ
  for(i=fb_screenH-numpix; i<768; i++){ // height
    for(j=0; j<1024; j++){ // width
      fb_set_pix(j,i,color);
    }
  }
}

However, the above example is too slow - the screen is updated in a little more than a second.
How can I speed up scrolling, or maybe there is a more correct implementation of it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Kop3t3, 2016-05-09
@Kop3t3

In my case, it helped to add -O3 for optimization.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question