Exemple #1
0
void terminal_putchar(char c) {
    if(c == '\n'){// this for loop is for the backgroud color!
	    for (size_t x = terminal_column; x < VGA_WIDTH; x++) {
		    const size_t index = terminal_row * VGA_WIDTH + x;
		    terminal_buffer[index] = make_vgaentry(' ', terminal_color);
	    }
        terminal_row++;
        terminal_column=0;
        if(terminal_row==VGA_HEIGHT){
            terminal_scrolling();
			terminal_row--;
        }
           
        return ;
    }
    if(terminal_column < VGA_WIDTH && terminal_row < VGA_HEIGHT)
	    terminal_putentryat(c, terminal_color, terminal_column, terminal_row);
	
	if (++terminal_column == VGA_WIDTH){
		terminal_column = 0;
		if (++terminal_row == VGA_HEIGHT){
			terminal_scrolling();
			terminal_row--;
		}
	}
}
Exemple #2
0
void terminal_putchar(char c)
{

    /* handle newline char */
    if (c == '\n') {

        terminal_clear_row_from(terminal_column, terminal_row);
		terminal_column = 0;
        
        if( ++terminal_row == VGA_HEIGHT) {
			terminal_scroll();
			terminal_row--;
        }
        return;
    }

	uint16_t vga_entry = make_vgaentry(c, terminal_color);
	terminal_putentryat(vga_entry, terminal_column, terminal_row);

	/* handle moving to next line */
	if ( ++terminal_column == VGA_WIDTH )
	{
		terminal_column = 0;
		if ( ++terminal_row == VGA_HEIGHT )
		{
			terminal_scroll();
			terminal_row--;
		}
	}
}
Exemple #3
0
static void terminal_scroll_up() {
  // TODO - extract this
  uint8_t terminal_default_color = make_vgaentry(' ', terminal_color);

  for (size_t y = 0; y < VGA_HEIGHT - 1; y++) {
    for (size_t x = 0; x < VGA_WIDTH; x++) {
      const size_t index = y * VGA_WIDTH + x;
      terminal_buffer[index] = terminal_buffer[index + VGA_WIDTH];
    }
  }

  for (size_t x = 0; x < VGA_WIDTH; ++x) {
    const size_t index = (VGA_HEIGHT - 1) * VGA_WIDTH + x;
    terminal_buffer[index] = make_vgaentry(' ', terminal_default_color);
  }
}
Exemple #4
0
// terminal_putentryat - write a character to screen, with color and position attributes.
// This function directly modifies the terminal buffer.
void terminal_putentryat(char c, char color, size_t x, size_t y)
{
    //__vga_write_lock.lock();
	const size_t index = y * VGA_WIDTH + x;
	terminal_buffer[index] = make_vgaentry(c, color);
    //__vga_write_lock.unlock();
}
Exemple #5
0
static void terminal_clear_row_from(size_t col, size_t row)
{
    size_t i;
    uint16_t vga_entry = make_vgaentry(' ', terminal_color);
    for(i = col; i < VGA_WIDTH; i++)
        terminal_putentryat(vga_entry, i, row);
}
Exemple #6
0
void terminal_clear_line(size_t line_number)
{
	for (size_t index = line_number * VGA_TERMINAL_WIDTH; index < VGA_TERMINAL_WIDTH * (line_number + 1); index++)
	{
		terminal_buffer[index] = make_vgaentry(' ', terminal_color);
	}
}
Exemple #7
0
//void local_echo() {
//    printf("%c", terminal_buffer[terminal_buf_count-1]);
//}
void clear_bottom(){
    for (size_t y = console_row+1; y < VGA_HEIGHT - 1; y++) {
        for (size_t x = 0; x < VGA_WIDTH; x++) {
            const size_t index = y * VGA_WIDTH + x;
            console_buffer[index] = make_vgaentry(' ', console_color);
        }
    }
}
Exemple #8
0
// terminal_scroll - scroll the console
// Positive values scroll down (adding new lines to the bottom); negative values do the inverse.
void terminal_scroll(int num_rows)
{
    __vga_write_lock.lock();
    if(num_rows > 0) { // scroll down
        for(size_t y=0;y<VGA_HEIGHT-1;y++)
            for(size_t x=0;x<VGA_WIDTH;x++)
                terminal_buffer[y*VGA_WIDTH+x] = terminal_buffer[(y+1)*VGA_WIDTH+x];
        for(size_t x=0;x<VGA_WIDTH;x++)
            terminal_buffer[(VGA_HEIGHT-1)*VGA_WIDTH+x] = make_vgaentry(' ', make_color(COLOR_LIGHT_GREY, COLOR_BLACK));
    } else if(num_rows < 0) { // scroll up
        for(size_t y=VGA_HEIGHT-1;y>0;y--)
            for(size_t x=0;x<VGA_WIDTH;x++)
                terminal_buffer[y*VGA_WIDTH+x] = terminal_buffer[(y-1)*VGA_WIDTH+x];
        for(size_t x=0;x<VGA_WIDTH;x++)
            terminal_buffer[x] = make_vgaentry(' ', make_color(COLOR_LIGHT_GREY, COLOR_BLACK));
    }
    __vga_write_lock.unlock();
}
Exemple #9
0
/*
 * ---------------------------------------------------------------------------
 *      Name   : terminal_scroll
 *      Purpose: scroll the buffer up one whole line
 *      Args   :
 *      Returns: void
 * ---------------------------------------------------------------------------
 */
void terminal_scroll()
{
    int i = 0;
    for(; i < VGA_WIDTH * (VGA_HEIGHT - 1); i++)
        terminal_buffer[i] = terminal_buffer[i + VGA_WIDTH];
    for(; i < VGA_WIDTH * VGA_HEIGHT; i++)
        terminal_buffer[i] = make_vgaentry(' ',
                                           make_color(COLOR_LIGHT_GREY, COLOR_BLACK));
    --terminal_row;
}
Exemple #10
0
void tty_handle_scroll() {
    if (tty_y < VGA_HEIGHT)
        return;
    int last_row_offset = (VGA_HEIGHT - 1) * VGA_WIDTH;
    memory_copy((uint8_t*)VGA_MEMORY,
            (uint8_t*)VGA_MEMORY + VGA_WIDTH * 2, last_row_offset * 2);
    for (int i = 0; i < VGA_WIDTH; ++i)
        VGA_MEMORY[last_row_offset + i] = make_vgaentry(' ', tty_color);
    --tty_y;
}
Exemple #11
0
void do_clear() {
    for (size_t y = 0; y < VGA_HEIGHT - 1; y++) {
        for (size_t x = 0; x < VGA_WIDTH; x++) {
            const size_t index = y * VGA_WIDTH + x;
            console_buffer[index] = make_vgaentry(' ', console_color);
        }
    }
    console_row = 0;
    console_column = 0;
}
Exemple #12
0
void MoveTerminalBuffer1Row(TwoBytes* buffer) { 
	for (size_t height = 1; height < VGA_HEIGHT; height++) { 
		size_t rowstart = height * VGA_WIDTH; 
		for (size_t xpos = 0; xpos < VGA_WIDTH; xpos++) {
			size_t curpos = rowstart + xpos; 
			buffer[curpos - VGA_WIDTH] = terminal_buffer[curpos];
			buffer[curpos] = make_vgaentry(' ', terminal_color); 
		}; 
	}; 
};
Exemple #13
0
void terminal_setcolortoall(byte color) { 
	for (size_t height = 0; height < VGA_HEIGHT; height++) { 
		size_t start = height * VGA_HEIGHT; 
		for (size_t xpos = 0; xpos < VGA_WIDTH; xpos++) { 
			size_t pos = start + xpos;
			byte thechar = ((byte*)terminal_buffer[pos])[1];
			terminal_buffer[pos] = make_vgaentry(thechar, color); 
		}; 
	}; 
}; 	
Exemple #14
0
/*
 * ---------------------------------------------------------------------------
 *      Name   : initialize_terminal
 *      Purpose: setup basic global variables and environment conditions
 *      Args   :
 *      Returns: void
 * ---------------------------------------------------------------------------
 */
void initialize_terminal()
{
    terminal_row = 0;
    terminal_column = 0;
    terminal_color = make_color(COLOR_LIGHT_GREY, COLOR_BLACK);
    terminal_buffer = VGA_MEMORY;
    for ( size_t index = 0; index < VGA_HEIGHT * VGA_WIDTH; index++ )
    {
        terminal_buffer[index] = make_vgaentry('\0', terminal_color);
    }
}
Exemple #15
0
void terminal_rowblank(size_t row){

  if(row >= VGA_HEIGHT)
    return;

  for(unsigned int x = 0; x < VGA_WIDTH; ++x){
    int index = (row * VGA_WIDTH) + x;
    terminal_buffer[index] = make_vgaentry('\0', terminal_color);
  }
  
}
Exemple #16
0
void clear_video()
{
	for ( size_t y = 0; y < VGA_HEIGHT; y++ )
	{
		for ( size_t x = 0; x < VGA_WIDTH; x++ )
		{
			const size_t index = y * VGA_WIDTH + x;
			((uint16_t*) video_memory)[index] = make_vgaentry(' ', make_color(current_tty->buffer.fg[current_tty->buffer.index], current_tty->bg));
		}
	}
}
Exemple #17
0
void terminal_scroll(){
    for(size_t i = 1; i < VGA_HEIGHT; i++){
        for(size_t j = 0; j < VGA_WIDTH; j++){
            size_t index = i + j * VGA_WIDTH;
            terminal_buffer[index] = terminal_buffer[index - VGA_WIDTH];
        }
    }
    for(size_t k = 0; k < VGA_WIDTH; k++){
        terminal_buffer[(VGA_HEIGHT - 1) * VGA_WIDTH + k] = make_vgaentry(' ', terminal_color);   
    }
}
Exemple #18
0
void terminal_initialize() { 
	terminal_row = 0; 
	terminal_column = 0; 
	terminal_color = makecolor(COLOR_LIGHT_GREY, COLOR_BLACK); 
	terminal_buffer = (TwoBytes*) 0xB8000; 
	for (size_t y = 0; y < VGA_HEIGHT; y++) { 
		for (size_t x = 0; x < VGA_WIDTH; x++) { 
			terminal_buffer[y * VGA_WIDTH + x] = make_vgaentry(' ', terminal_color); 
		}; 
	}; 
};   	
Exemple #19
0
int terminal_putentryat(char character, uint8_t color, size_t x, size_t y)
{
	if( cursor_x <= VGA_TERMINAL_WIDTH && cursor_y <= VGA_TERMINAL_HEIGHT)
	{
		const size_t index = (VGA_TERMINAL_WIDTH * y) + x;
		terminal_buffer[index] = make_vgaentry(character, color);
		return 0;
	}

	return -1;
}
Exemple #20
0
void terminal_initialize() {
	terminal_row = 0;
	terminal_column = 0;
	terminal_color = make_color(COLOR_LIGHT_GREY, COLOR_BLACK);
	terminal_buffer = (uint16_t*) 0xB8000;
	for (size_t y = 0; y < VGA_HEIGHT; y++) {
		for (size_t x = 0; x < VGA_WIDTH; x++) {
			const size_t index = y * VGA_WIDTH + x;
			terminal_buffer[index] = make_vgaentry(' ', terminal_color);
		}
	}
}
Exemple #21
0
void terminal_clear_screen(void)
{
	for(size_t y = 0; y < VGA_TERMINAL_HEIGHT; y++)
	{
		for (size_t x = 0; x < VGA_TERMINAL_WIDTH; x++)
		{
			terminal_buffer[ (VGA_TERMINAL_WIDTH * y) + x] = make_vgaentry(' ', terminal_color);
		}
	}
	cursor_x = cursor_y = 0;
	update_cursor();
}
Exemple #22
0
/*
 * Writes the contents of the terminal buffer to the screen.
 */
void terminal_flush() {
    //write the character buffer to the screen
    for (size_t y = 0; y < VGA_HEIGHT; y++) {
        for (size_t x = 0; x < VGA_WIDTH; x++) {
            size_t index = buffer_index(x, y);
            t_char c = buffer[index];
            screen[index] = make_vgaentry(c.t, c.colour);
        }
    }

    //update the cursor
    update_cursor(terminal_row, terminal_column);
}
Exemple #23
0
Fichier : vga.c Projet : dzeban/os
static void terminal_scroll()
{
    uint16_t *dst = terminal_buffer;
    uint16_t *src = terminal_buffer + VGA_WIDTH;
    int len = VGA_BUFFER_SIZE - VGA_WIDTH;

    while(len--)
        *dst++ = *src++;

    // Don't forget about last blank row
    len = VGA_WIDTH;
    while (len--)
        *dst++ = make_vgaentry(FILLCHAR, terminal_color);
}
Exemple #24
0
void term_clear(void)
{
  for(size_t y=0;y<=VGA_HEIGHT;++y)
    {
      for(size_t x=0;x<VGA_WIDTH;++x)
	{
	  const size_t idx=y*VGA_WIDTH+x;
	  term_buffer[idx]=make_vgaentry(' ', term_color);
	}
    }
  memset(&last_prompt_char, 0, sizeof(last_prompt_char));
  term_row=0;
  term_column=0;
  update_bios_cursor();
}
Exemple #25
0
void terminal_initialize() {
  terminal_row = 0;
  terminal_column = 0;
  terminal_color = make_color(COLOR_LIGHT_GREY, COLOR_BLACK);
  terminal_buffer = VGA_MEMORY;

  uint8_t terminal_default_color = make_vgaentry(' ', terminal_color);

  for (size_t y = 0; y < VGA_HEIGHT; y++) {
    for (size_t x = 0; x < VGA_WIDTH; x++) {
      const size_t index = y * VGA_WIDTH + x;
      terminal_buffer[index] = terminal_default_color;
    }
  }
}
Exemple #26
0
Fichier : vga.c Projet : dzeban/os
void terminal_initialize()
{
	uint16_t vga_entry;

    terminal_row = 0;
    terminal_column = 0;
	move_csr();

    terminal_color = make_color(COLOR_WHITE, COLOR_BLACK);
    terminal_buffer = (uint16_t *) VGA_BUFFER;

	vga_entry = make_vgaentry(FILLCHAR, terminal_color);
	memset16(terminal_buffer, vga_entry, VGA_WIDTH * VGA_HEIGHT);

    VGA_BUFFER_SIZE = VGA_WIDTH * VGA_HEIGHT;
}
Exemple #27
0
void terminal_scroll()
{
	for(size_t y = 1; y < VGA_HEIGHT; y++)
	{
		for(size_t x = 0; x < VGA_WIDTH; x++)
		{
			const size_t index_new = (y - 1) * VGA_WIDTH + x;
			const size_t index_current = y * VGA_WIDTH + x;
			terminal_buffer[index_new] = terminal_buffer[index_current];
		}
	} 
	const size_t index_helper = 24 * VGA_WIDTH;
	for(size_t x = 0; x < VGA_WIDTH; x++)
	{
		terminal_buffer[index_helper + x] = make_vgaentry(' ', terminal_color);
	}
}
Exemple #28
0
void clear_vga_textmode(void)
{
    term_zero();
    for(unsigned i = 0; i < video_driver_width; i++)
    {
        for(unsigned j = 0; j < video_driver_height; j++)
        {
            const size_t index = (vga_driver.video_row * 80 + vga_driver.video_column);
            uint16_t* VideoMemory = (uint16_t*) 0xB8000;
            uint8_t terminal_color = make_color(vga_driver.fg, vga_driver.bg);

            VideoMemory[index] = (VideoMemory[index] & 0xFF00) | (char) 0;
            VideoMemory[index + 1] = make_vgaentry(' ', terminal_color);

            vga_driver.video_column++;
        }
    }
    term_zero();
}
Exemple #29
0
int terminal_scroll()
{
	uint16_t new_buffer[VGA_HEIGHT * VGA_WIDTH];

	for (int y = VGA_HEIGHT - 1; y > 0; y--) 
	{
		for (int x = VGA_WIDTH -1; x >= 0; x--)
		{
			if((y - 1) < 0)
				return 0;
			new_buffer[(y - 1) * VGA_WIDTH + x] = terminal_buffer[y * VGA_WIDTH + x];
		}
	}
	for (size_t x = 0; x < VGA_WIDTH; x++)
		new_buffer[(VGA_HEIGHT-1) * VGA_WIDTH + x] = make_vgaentry(' ', terminal_color);
	for (size_t y = 0; y < VGA_HEIGHT; y++) {
		for (size_t x = 0; x < VGA_WIDTH; x++) {
			const size_t index = y * VGA_WIDTH + x;
			terminal_buffer[index] = new_buffer[index];
		}
	}
}
Exemple #30
0
static void scroll_if_needed(void) // scroll the terminal 1 line, seems buggy!
{
  if(term_row>VGA_HEIGHT)
    {
      for(uint16_t y=0;y<VGA_HEIGHT;++y)
	{
	  for(uint16_t x=0;x<VGA_WIDTH;++x) // scroll all lines except last one
	    {
	      const uint16_t idx1=y*VGA_WIDTH+x, idx2=(y+1)*VGA_WIDTH+x;
	      term_buffer[idx1]=term_buffer[idx2];
	    }
	  last_prompt_char[y]=last_prompt_char[y+1];
	}
      last_prompt_char[VGA_HEIGHT]=0;
      for(uint16_t x=0;x<VGA_WIDTH;++x) // fill last line with spaces
	{
	  const uint16_t idx=(VGA_HEIGHT)*VGA_WIDTH+x;
	  term_buffer[idx]=make_vgaentry(' ', term_color);
	}
      term_row=VGA_HEIGHT;
      update_bios_cursor();
    }
}