nuclear@0: #include nuclear@0: #include nuclear@0: #include nuclear@0: #include nuclear@0: #include "logger.h" nuclear@0: nuclear@0: static void putchr(char c); nuclear@0: static void putstr(const char *str); nuclear@0: nuclear@0: static int curx, cury; nuclear@0: static int font_width = 8, font_height = 8; nuclear@0: static int ncols = 20, nrows = 16; nuclear@0: nuclear@0: void logmsg(const char *fmt, ...) nuclear@0: { nuclear@0: va_list ap; nuclear@0: int sz; nuclear@0: char *buf; nuclear@0: nuclear@0: va_start(ap, fmt); nuclear@0: sz = vsnprintf(0, 0, fmt, ap); nuclear@0: va_end(ap); nuclear@0: nuclear@0: buf = alloca(sz + 1); nuclear@0: va_start(ap, fmt); nuclear@0: vsnprintf(buf, sz, fmt, ap); nuclear@0: va_end(ap); nuclear@0: nuclear@0: putstr(buf); nuclear@0: } nuclear@0: nuclear@0: static void putchr(char c) nuclear@0: { nuclear@0: switch(c) { nuclear@0: case '\n': nuclear@0: case '\r': nuclear@0: curx = 0; nuclear@0: cury += font_height; nuclear@0: break; nuclear@0: nuclear@0: default: nuclear@0: if(isprint(c)) { nuclear@0: draw_glyph(c, curx, cury, front_buffer); nuclear@0: } nuclear@0: } nuclear@0: } nuclear@0: nuclear@0: static void putstr(const char *str) nuclear@0: { nuclear@0: while(*str) putchr(*str++); nuclear@0: }