Answer the question
In order to leave comments, you need to log in
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);
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question