Exemple #1
0
static void check_bounds(uint_t* column, uint_t* row)
{
        uint_t r;
        uint_t c;

        r = *row;
        c = *column;

        if (c >= VGA_COLUMNS) {
                /* We reached the right margin ... */
                c = 0;
                r = r + 1;
        }
#if 0
        /* Huh ... c is an unit_t */
        else if (c < 0) {
                c = VGA_COLUMNS - 1;
                r = r - 1;
        }
#endif
        if (r >= VGA_ROWS) {
                /* We reached the bottom margin */
                r = VGA_ROWS - 1;

                /* And we need to scroll up the screen */
                vga_scroll_up();
        }
#if 0
        /* Huh ... r is an unit_t */
        else if (r < 0) {
                r = 0;
        }
#endif

        *column = c;
        *row    = r;
}
Exemple #2
0
void vga_putc (const char c)
{
  unsigned short *vptr = (unsigned short *)VMEM_BASE;
  unsigned char backcolor = 0;
  unsigned char forecolor = 15;
  unsigned char vattr = (u8)((backcolor << 4) | (forecolor));

  unsigned short vval = (u16)((vattr << 8) | (c));

  unsigned int location_offset; 

  if (cursor_y == max_y){
    vga_scroll_up ();
  }

  location_offset = (unsigned)((cursor_y * 80) + cursor_x);


  switch (c){
  case '\n':
    cursor_x = 0;
    cursor_y++;
    if (cursor_y != max_y)
      move_cursor (cursor_x, cursor_y);
    break;
  case '\t':
      cursor_x = (u8)(cursor_x + KTabWidth);
    if (cursor_x >= 80){
      cursor_x = 0;
      cursor_y++;
    }
    if (cursor_y >= max_y)
      vga_scroll_up ();
    else
      move_cursor (cursor_x, cursor_y);
    break;
  case '\r': // carriage return
    cursor_x = 0;
    cursor_y++;
    move_cursor (cursor_x, cursor_y);
    break;
  case '\b':
      if(cursor_x > 0) {
	  cursor_x--;
	  move_cursor(cursor_x, cursor_y);
      }
    break;
  default:
    *(volatile unsigned short*)(vptr + location_offset) = vval;
    cursor_x++;
    if (cursor_x == max_x){
      cursor_x = 0;
      cursor_y++;
    }
    /*
    if (cursor_y >= max_y)
      vga_scroll_up ();
      else*/
    if (cursor_y != max_y)
      move_cursor (cursor_x, cursor_y);
    break;
  }
}
Exemple #3
0
void vga_cursor_down() {
	if (++vga_state.vga_pos_y >= vga_state.vga_height) {
		vga_state.vga_pos_y = vga_state.vga_height - 1;
		vga_scroll_up(1);
	}
}