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(); }
// Write the contents of a buffer of length len to the screen. Should // automatically advance the cursor after a character has been written, and // scroll if necessary. void fb_puts(char *buf, unsigned int len) { unsigned int i; for (i = 0; i < len; ++i) { fb_write_cell(cursor_pos, buf[i], curr_color & 0xF0, curr_color & 0x0F); cursor_pos = (cursor_pos + 1) % FB_NUM_CELLS; } fb_move_cursor(); }
int fb_write(char *buf) { while(*buf != 0) { fb_move_cursor(currPos); fb_write_cell(2 * currPos++, *buf, FB_GREEN, FB_DARK_GREY); buf++; } return currPos; }
// Write a null-terminated string to the monitor. void fb_write(char *str) { unsigned int i; i = 0; while (str[i] != '\0') { fb_write_cell(cursor_pos, str[i++], curr_color & 0xF0, curr_color & 0x0F); cursor_pos = (cursor_pos + 1) % FB_NUM_CELLS; } fb_move_cursor(); }
void kmain() { fb_clear(BLACK); char version[64] = "rhinocer/os 0.1"; fb_write_string(0, version, BLACK, WHITE); fb_move_cursor(0); while (1) { } }
int write(char*buf,unsigned int len) { unsigned int index = 0; unsigned short fb_index = 0; while(index < len) { print_a_letter(index*2, buf[index], 0, 2); fb_move_cursor(fb_index); index++; fb_index++; } return 0; }
int fb_write(char *buf, unsigned int len) { unsigned int i; for(i=0; i<len; i++) { /* Write character at position i */ fb_write_cell(2*__fb_present_pos, buf[i], (unsigned char)0, (unsigned char)15); fb_move_cursor(__fb_present_pos + 1); /* If __fb_present_pos goes off the screen, move everything one line up */ if(__fb_present_pos == FRAMEBUFFER_WIDTH * FRAMEBUFFER_HEIGHT) { fb_move_cursor((FRAMEBUFFER_HEIGHT-1)*FRAMEBUFFER_WIDTH); int j; for(j=0; j<2*FRAMEBUFFER_WIDTH*(FRAMEBUFFER_HEIGHT-1); j++) { __fb[j] = __fb[j + FRAMEBUFFER_WIDTH*2]; } for(j=j; j<2*FRAMEBUFFER_WIDTH*FRAMEBUFFER_HEIGHT; j++) { __fb[j] = 0; } } } return len; }
// Write a single character to the screen from wherever the cursor is. void fb_putc(char c) { fb_write_cell(cursor_pos, c, curr_color & 0xF0, curr_color & 0x0F); cursor_pos = (cursor_pos + 1) % FB_NUM_CELLS; fb_move_cursor(); }
void fb_write_cell(unsigned int i, char c, unsigned char fg, unsigned char bg){ fb[i]=c; fb[i+1]= ((fg & 0x0F) << 4) | (bg & 0x0F); fb_move_cursor(i/2+1); }