u08 chunk_handle_char(u08 ch) { // something to process in raw chunk? if(bytes_left > 0) { // chunk with color? if((type=='B')&&(cell==0)) { cur_col = ch; cell = 1; } // text char else { if(type == 0) { screen_putc(cur_x, cur_y, ch); } else { screen_putch(cur_x, cur_y, ch, cur_col, cur_flags); } span--; if(span == 0) { cur_x = pos_x; span = width; cur_y ++; // answer each span with a hash as a handshake uart_send('#'); } else { cur_x ++; } cell = 0; } bytes_left--; return 1; } else { return 0; } }
/* move cursor and putch */ void screen_pos_putch(char c, int new_x, int new_y) { int old_x = _l_scr_px; int old_y = _l_scr_py; _l_scr_px = new_x; _l_scr_py = new_y; screen_putch(c); _l_scr_px = old_x; _l_scr_py = old_y; }
unsigned int screen_write(struct FileHandle* handle, char* buffer, unsigned int size) { unsigned int i; /*lock(screen_mutex); */ for(i = 0; i < size; i++) screen_putch(buffer[i]); /* unlock(screen_mutex); */ return i; }
int console_gets(char *s) { int cnt = 0; char c; while ((c = console_getc()) != CR) { if (c != BS) { cnt++; *s++ = c; screen_putch(c); //echo } else { if (cnt > 0) { cnt--; *--s = '\0'; console_puts("\b \b"); } } } *s = 0; return cnt; }
/* Uses the above routine to output a string... */ void screen_puts(const char *text) { while(*text) screen_putch(*text++); }
void console_putch(char c) { screen_putch(c); }