Code: Select all
// this works :-)
vga_write(COLOR_BLACK, COLOR_WHITE, 't', 90);
vga_write(COLOR_BLACK, COLOR_WHITE, 'e', 91);
vga_write(COLOR_BLACK, COLOR_WHITE, 's', 92);
vga_write(COLOR_BLACK, COLOR_WHITE, 't', 93);
// this doesn't work :-(
vga_write_str(COLOR_BLACK, COLOR_WHITE, "test", 4, 90);
Code: Select all
uint16_t* vga_buffer = (uint16_t*) 0xb8000;
void vga_clear(uint8_t background, uint8_t foreground){
uint16_t i, data = (background << 12) | (foreground << 8) | ' ';
for(i = 0; i < 2000; i++)
vga_buffer[i] = data;
}
void vga_write(uint8_t background, uint8_t foreground, uint8_t byte, uint16_t offset){
uint16_t data = (background << 12) | (foreground << 8) | byte;
vga_buffer[offset] = data;
}
void vga_write_str(uint8_t background, uint8_t foreground, const uint8_t* string, uint16_t string_len, uint16_t offset){
uint16_t i, data = (background << 12) | (foreground << 8);
for(i = 0; i < string_len; i++){
data |= string[i];
vga_buffer[offset + i] = data;
}
}