Term.cursor = (Term.rows - 1) * Term.cols;
while (src < max)
{
- PutGlyph((dst % Term.cols) * 8, (dst / Term.rows) * 16, Term.cells[src]);
+ PutGlyph((dst % Term.cols) * 8, (dst / Term.cols) * 16, Term.cells[src]);
Term.cells[dst++] = Term.cells[src++];
}
- for (int i = Term.cursor; i < Term.cols; i++)
+ for (int i = Term.cursor; i < (Term.cursor + Term.cols); i++)
{
- PutGlyph((i % Term.cols) * 8, (i / Term.rows) * 16, ' ');
+ PutGlyph((i % Term.cols) * 8, (i / Term.cols) * 16, ' ');
Term.cells[i] = ' ';
}
}
break;
case '\n':
- Term.cursor = (Term.cursor / Term.cols) * Term.cols;
- Term.cursor += Term.cols;
+ {
+ int next = (Term.cursor / Term.cols) * Term.cols + Term.cols;
+ while (Term.cursor < next)
+ {
+ PutCell(' ');
+ }
+
+// Term.cursor = (Term.cursor / Term.cols) * Term.cols;
+// Term.cursor += Term.cols;
break;
+ }
default:
PutCell(c);
}
}
+void Term_Print(char* fmt, ...)
+{
+ va_list arg;
+ va_start (arg, fmt);
+ for (; *fmt; fmt++)
+ {
+ if (*fmt == '%')
+ {
+ int ndigits = sizeof(intptr_t);
+ fmt++;
+ if (*fmt >= '0' && *fmt <= '9')
+ {
+ ndigits = *(fmt++) - '0';
+ }
+ switch(*fmt)
+ {
+ case 'd':
+ Term_PutInt(va_arg(arg, int));
+ break;
+
+ case 'u':
+ Term_PutInt(va_arg(arg, unsigned int));
+ break;
+
+// case 'f':
+// TODO
+// break;
+
+ case 'c':
+ Term_PutChar((char)va_arg(arg, int));
+ break;
+
+ case 's':
+ for (char* s = va_arg(arg, char*); *s; s++)
+ {
+ Term_PutChar(*s);
+ }
+ break;
+
+ case 'p':
+ case 'x':
+ {
+ uint64_t val = va_arg(arg, uint64_t);
+ if (ndigits > 6u)
+ {
+ Term_PutHex64(val);
+ }
+ else if (ndigits > 4u)
+ {
+ Term_PutHex32(val);
+ }
+ else if (ndigits > 2u)
+ {
+ Term_PutHex16(val);
+ }
+ else
+ {
+ Term_PutHex8(val);
+ }
+ break;
+ }
+
+ case '%':
+ Term_PutChar('%');
+ break;
+//
+// default:
+// Term_PutChar(*fmt);
+// break;
+ }
+ }
+ else
+ {
+ Term_PutChar(*fmt);
+ }
+ }
+ va_end (arg);
+}
+
+
void Term_PutString(char* s)
{
for (; *s; s++)
#define min(x,y) ((x)<(y)?(x):(y))
#define max(x,y) ((x)>(y)?(x):(y))
+typedef __builtin_va_list va_list;
+#define va_start(v,l) __builtin_va_start(v,l)
+#define va_end(v) __builtin_va_end(v)
+#define va_arg(v,l) __builtin_va_arg(v,l)
+
/* video memory configuration info */
typedef struct {
uint32_t* buffer;