/***
 * write char to vmem
 */
void vga_putchar(const char c) {
    vga_d_char_t *pos;
    // write character and set color
    pos = VGA_BUF + VGA_STATE.cursor_x + (VGA_STATE.cursor_y * VGA_WIDTH);
    (*pos).c = c;
    (*pos).color = FORMAT_COLORS(VGA_STATE.fg, VGA_STATE.bg);
    // update cursor position
    if (++VGA_STATE.cursor_x >= VGA_WIDTH) vga_newline();
    vga_sync_cursor();
}
Exemple #2
0
void vga_putc(char c)
{
  uint16_t *addr;
  
  if (c == '\r') {
    curx = 0;
  } else if (VGA_PRINTABLE(c)) {
    addr = (uint16_t*)VGA_MEMSTART + cury * VGA_COLS + curx;
    *addr = VGA_CHAR(c);
    ++curx;
  }

  if (c == '\n' || curx == VGA_COLS)
    vga_newline();

  if (cury == VGA_ROWS) {
    vga_scroll();
    --cury;
  }
}