Exemple #1
0
// Write a character to the framebuffer
void fb_putchar(u8 ascii) {
	//serial_wait();
	// move to the next line if character is a newline
	if (ascii == '\n') {
		// if bottom row
		if (fb.pos >= FB_BOTTOMROW) {
			fb_scroll();
		}
		else {
			fb.pos = ((fb.pos / FB_COLS) + 1) * FB_COLS;
			fb_mov();
		}
	}
	else if (ascii == '\b') {
		if (fb.pos > FB_FIRSTCELL) {
			fb.pos--;
			fb_mov();
			fb.p[fb.pos] = fb_mkchar(FB_BLACK, FB_WHITE, ' ');
		}
	}
	else {
		if (fb.pos == FB_LASTCELL) {
			fb_scroll();
		}
		fb.p[fb.pos] = fb_mkchar(FB_BLACK, FB_WHITE, ascii);
		fb.pos++;
		fb_mov();
	}
}
Exemple #2
0
void fb_put(char c)
{
    uint32_t location = fb_position();

    if (c == 0x08 && s_fbx)
    {
        s_fbx--;
    }
    else if (c == '\r')
    {
        s_fbx = 0;
    }
    else if (c == '\n')
    {
        s_fbx = 0;
        s_fby++;
    }
    else if (c >= ' ')
    {
        FB[location] = c | s_attribute;
        s_fbx++;
    }

    if (s_fbx >= FB_COLUMNS)
    {
        s_fbx = 0;
        s_fby++;
    }
    fb_scroll();
    fb_move_cursor();
}
Exemple #3
0
//--------------------------------------------------------------------------
// fb_putchar()
//
// This routine parses the character and calls fb_writechar if it is a
// printable character
//
void fb_putchar(char c)
{

	if (fb_tst) return;	// can't print if we are testing the frame buffer

	// First parse the character to see if it printable or an acceptable control
    switch (c) {
	    case '\r':
	        fb_col = 0;
	        return;
	    case '\n':
	        fb_scroll();
	        return;
	    case '\b':
	        if (fb_col > 0)
	        {
		        fb_col--;
			}
			else
			{
	            if (fb_row > 0)
	            {
	            	fb_row--;
		            fb_col = COLS_PER_SCREEN - 1;
				}
		    }
			c = CURSOR_ON;		// put the cursor where the character was
			fb_writechar(c);
	        break;
	    default:
	        if (((uchar)c < FIRST_CHAR) || ((uchar)c > LAST_CHAR)) return; // drop anything we can't print
			c -= FIRST_CHAR;	// get aligned to the first printable character
			fb_writechar(c);
			// advance to next column
			fb_col++;
		    if (fb_col == COLS_PER_SCREEN)
		    {
				fb_col = 0;
			    fb_scroll();
			}
			c = CURSOR_ON;	// write the cursor character
			fb_writechar(c);
			break;
    } 

} // fb_putchar()