コード例 #1
0
ファイル: console.c プロジェクト: sequenced/os1
int
write(const void *buf, int count)
{
  int old;
  int row;
  int col;
  char *s;

  old=count;
  s=(char*)buf;

  while (count--)
    {
#ifdef CONFIG_X86_64
      vga_getpos(&row, &col);

      switch (*s)
        {
        case '\r':
          vga_setpos(row, 0);
          break;

        case '\n':
          if (row<VGA_ROWS-1)
            vga_setpos(row+1, col);
          else
            vga_scroll();
          break;

        default:
          vga_drawc(*s);
          if (col<VGA_COLS-1)
            vga_setpos(row, col+1);
          else if (row<VGA_ROWS-1)
            vga_setpos(row+1, 0);
          else
            {
              vga_setpos(row, 0);
              vga_scroll();
            }
        }
#endif
      s++;
    }

  return (old-count);
}
コード例 #2
0
ファイル: video.c プロジェクト: izard/RTBench
/*
 * Update the vga position.
 * depending on the current position we will scroll the screen up.
 */
void vga_update_pos(struct vga_console *vga, u8 nlFlg)
{
    if (nlFlg)
    {
        if (vga->row == 24)
        {
            vga->col = 0;
            vga_scroll((void *)vga, 25);
            vga_movecursor((void *)vga, vga->row, vga->col);
            return;
        }
        else
        {
            vga->col = 0;
            vga->row++;
            vga_movecursor((void *)vga, vga->row, vga->col);
            return;
        }
    }

  /*
   * If we are the last row, column, scroll up by one row.
   * Otherwise we just increment the row and col.
   */
  

  if ((vga->row == 24) && (vga->col == 79))
  {
    vga_scroll ((void *)vga, 25);
    vga->col = 0;
    return;
  }

  if (vga->col == 79)
    {
      vga->col = 0;
      vga->row++;
      return;
    }

  vga->col ++;
  vga_movecursor((void *)vga, vga->row, vga->col);
  return;
}
コード例 #3
0
ファイル: vga.c プロジェクト: tech-projects/kfs
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;
  }
}
コード例 #4
0
ファイル: vga.c プロジェクト: jo-va/toutatis
void vga_print_char(const char c)
{
        /* backspace */
        if (c == '\b') {
                if (xpos > 0) {
                        --xpos;
                } else if (ypos > 0) {
                        xpos = COLS - 1;
                        --ypos;
                }
        }
        /* tab -> increment xpos to a point that will make it
         * divisible by 8. */
        else if (c == '\t') {
                xpos = (xpos + 8) & ~(8 - 1);
        }
        /* carriage return */
        else if (c == '\r') {
                xpos = 0;
        }
        /* newline */
        else if (c == '\n') {
                xpos = 0;
                ++ypos;
        }
        /* any character greater than and including a space is
         * a printable character */
        else if (c >= ' ') {
                uint16_t *pos = video_mem + (ypos * COLS + xpos);
                *pos = (uint16_t)c | attribute;
                ++xpos;
        }

        if (xpos >= COLS) {
                xpos = 0;
                ++ypos;
        }

        vga_scroll();
        set_cursor_pos(xpos, ypos);
}