My crappy terminal OS

font.c 3.1KB

    #include "font.h" #include "../drivers/screen.h" #include "../libc/string.h" u16 characters[26 * 8 + 31 * 8 + 16*8] = { 24,24,0,24,60,60,126,126, 0,0,0,0,108,108,108,108, 108,254,254,108,108,254,254,108, 16,124,124,16,8,124,124,16, 198,206,28,56,112,224,198,6, 16,124,64,124,64,64,124,16, 0,0,0,0,6,6,6,6, 24,30,14,6,6,14,30,24, 6,30,28,24,24,28,30,6, 146,84,56,254,56,84,146,16, 0,24,24,126,126,24,24,0, 28,56,48,0,0,0,0,0, 0,0,0,252,252,0,0,0, 14,14,14,0,0,0,0,0, 6,14,28,56,112,224,192,0, 254,254,206,222,246,230,254,254, 254,254,48,48,48,62,60,56, 254,254,28,56,118,230,254,254, 254,254,192,254,254,192,254,254, 48,48,48,254,254,54,54,54, 254,254,198,192,254,6,254,254, 254,254,198,254,254,6,254,254, 48,48,48,48,48,48,62,62, 124,238,198,254,124,198,238,124, 192,192,254,254,198,198,254,254, 24,24,0,0,0,0,24,24, 12,28,56,48,0,0,48,48, 48,56,28,14,14,28,56,48, 0,0,254,254,0,254,254,0, 24,56,112,224,224,112,56,24, 24,24,0,120,120,96,120,120, 254,254,6,246,246,198,254,254, 198,198,254,254,198,238,124,56, 62,126,102,126,126,102,126,62, 126,126,6,6,6,6,126,126, 62,126,230,198,198,230,126,62, 254,254,6,30,30,6,254,254, 6,6,126,126,6,6,254,254, 254,254,198,246,246,6,254,254, 198,198,198,254,254,198,198,198, 126,126,24,24,24,24,126,126, 62,62,54,54,48,48,48,48, 102,118,62,30,30,62,118,102, 62,62,6,6,6,6,6,6, 198,198,198,214,254,254,238,198, 198,198,246,246,222,222,198,198, 254,254,198,198,198,198,254,254, 6,6,62,126,102,102,126,62, 62,126,246,246,198,198,254,254, 230,118,62,126,102,102,126,62, 126,126,112,56,28,14,126,126, 24,24,24,24,24,24,126,126, 254,254,198,198,198,198,198,198, 24,60,126,102,102,102,102,102, 198,238,254,254,214,198,198,198, 198,238,124,56,56,124,238,198, 24,24,24,24,60,126,102,102, 126,126,12,28,56,48,126,126, 30,30,6,6,6,6,30,30, 192,224,112,56,28,14,6,0, 30,30,24,24,24,24,30,30, 0,0,0,132,204,252,120,48, 254,254,0,0,0,0,0,0, 0,0,0,0,0,12,14,6, 192,254,254,198,198,254,254,192, 62,126,102,102,126,62,6,6, 62,62,6,62,62,0,0,0, 254,254,246,254,254,192,192,192, 254,254,6,246,246,198,254,254, 24,126,126,24,216,216,248,248, 126,64,126,126,102,102,126,126, 102,102,126,126,6,6,6,6, 6,6,6,6,6,0,6,6 }; void draw_char(int x, int y, char c) { if (c >= 106) { c -= 32; } //We now know c is a letter we have. Subtract 65 to get a number we can use in the above array. c -= 33; for(int r = 0; r < 8; r++) {//Rows uint16 row = characters[c * 8 + r]; for (int i = 0; i < 8; i++) { if (row&(1 << i)) { putpixel(x + i, y - r, 255, 255, 255); //TODO: CHANGE THIS } } } } void print_at(int x, int y, char *c) { int i = 0; while (c[i] != 0) { draw_char(x + i * 8, y, c[i]); i++; } } //X is where the middle character goes void print_centered(int scn_width, int y, char *c) { int x_left = (scn_width - (strlen(c) * 8)) / 2; print_at(x_left, y, c); }