#include #include #include // FIXME: assumes vga font int getcols(void) { int x1, y1, x2, y2; FILE* fp; fp = fopen("/dev/wctl", "r"); fscanf(fp, "%d %d %d %d", &x1, &y1, &x2, &y2); fclose(fp); return (x2 - x1) / 8 / 2 * 2 - 4; } void main(void) { while(1) { int cols = getcols(); char* outbuf1 = calloc(cols + 1, 1); char* outbuf2 = calloc(cols + 1, 1); for (int i = 0; i < (cols / 2); i ++) { if (rand() % 2) { strcat(outbuf1, " /"); strcat(outbuf2, "/ "); } else { strcat(outbuf1, "\\ "); strcat(outbuf2, " \\"); } } print("%s\n%s\n", outbuf1, outbuf2); free(outbuf1); free(outbuf2); } }