X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=bootcensus;a=blobdiff_plain;f=src%2Fcontty.c;h=6601ce81a5af9bcd00d3a3a05462b2067144356e;hp=9a78ca2a7bf53be4a4129823d9a7886cb72e6562;hb=5e8cc93aaf1173688852acaa0825698c2dc0cb3f;hpb=d1e8a437c1fab4535f82c4c214ec3330ac32e48d diff --git a/src/contty.c b/src/contty.c index 9a78ca2..6601ce8 100644 --- a/src/contty.c +++ b/src/contty.c @@ -1,5 +1,23 @@ +/* +pcboot - bootable PC demo/game kernel +Copyright (C) 2018 John Tsiombikas + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY, without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ #include #include +#include #include "contty.h" #include "serial.h" #include "asmops.h" @@ -128,8 +146,7 @@ void con_putchar(int c) break; default: - ptr = (uint16_t*)TEXT_ADDR; - ptr[(cursor_y + start_line) * NCOLS + cursor_x] = VMEM_CHAR(c, txattr); + con_putchar_scr(cursor_x, cursor_y, c); if(++cursor_x >= NCOLS) { linefeed(); @@ -144,6 +161,27 @@ void con_putchar(int c) #endif } +void con_putchar_scr(int x, int y, int c) +{ + uint16_t *ptr = (uint16_t*)TEXT_ADDR; + ptr[(y + start_line) * NCOLS + x] = VMEM_CHAR(c, txattr); +} + +void con_printf(int x, int y, const char *fmt, ...) +{ + va_list ap; + char buf[81]; + char *ptr = buf; + + va_start(ap, fmt); + vsnprintf(buf, 80, fmt, ap); + va_end(ap); + + while(*ptr && x < 80) { + con_putchar_scr(x++, y, *ptr++); + } +} + static void scroll(void) { int new_line; @@ -158,7 +196,7 @@ static void scroll(void) /* clear the next line that will be revealed by scrolling */ new_line = start_line + NROWS - 1; - memset16(TEXT_ADDR + new_line * NCOLS, VMEM_CHAR(' ', txattr), NCOLS); + memset16(TEXT_ADDR + new_line * NCOLS * 2, VMEM_CHAR(' ', txattr), NCOLS); crtc_setstart(start_line); }