Reputation: 662
I am developing an Operating System as a hobby project. I interfaced VGA display by using address 0xB8000, and number of rows are set to 25, and columns are set to 80. I have used following clear screen function :
void vga_init(void) {
// Initialise the VGA variables and clear the screen : :
vga_buffer_pointer = (uint16_t *) VGA_MEMORY_LOCATION;
//start clear using 2 pass loop :
uint8_t iter_i = 0;
uint8_t iter_j = 0;
for(iter_i = 0; iter_i < VGA_ROWS; iter_i ++) {
for(iter_j = 0; iter_j < VGA_COLS; iter_j++) {
uint8_t index = (VGA_COLS * iter_i) + iter_j;
vga_buffer_pointer[index] = ((uint16_t)color << 8) | ' ';
}
}
enable_cursor(14,15);
}
I am initialising the screen with green color. The display occupies only a porting of the qemu terminal screen, As shown below :
But I want, the entire terminal to be green. And the display should use the entire terminal. Any help is most appreciated. Thank you
I have attached a gist of my code.
Upvotes: 1
Views: 463
Reputation: 47573
Change:
uint8_t index = (VGA_COLS * iter_i) + iter_j;
to:
uint16_t index = (VGA_COLS * iter_i) + iter_j;
A uint8_t
isn't big enough to hold the calculation for the index so it is being truncated causing only part of the display to be erased.
Upvotes: 4