#include "types.h" uint8_t font[128][8] = { {0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0}, // 0-31 {0,0,0,0,0,0,0,0}, // Space {24,60,60,24,24,0,24,0}, // ! {34,34,34,0,0,0,0,0}, // " {108,108,254,108,254,108,108,0}, // # {24,62,96,60,6,124,24,0}, // $ {0,98,100,8,16,38,70,0}, // % {56,108,56,118,220,204,118,0}, // & {24,24,12,0,0,0,0,0}, // ' {12,24,48,48,48,24,12,0}, // ( {48,24,12,12,12,24,48,0}, // ) {0,102,60,255,60,102,0,0}, // * {0,24,24,126,24,24,0,0}, // + {0,0,0,0,0,24,24,48}, // , {0,0,0,126,0,0,0,0}, // - {0,0,0,0,0,24,24,0}, // . {0,6,12,24,48,96,192,0}, // / {60,102,102,102,102,102,60,0}, // 0 {24,56,24,24,24,24,126,0}, // 1 {60,102,6,12,48,96,126,0}, // 2 {60,102,6,28,6,102,60,0}, // 3 {12,28,60,108,254,12,12,0}, // 4 {126,96,124,6,6,102,60,0}, // 5 {56,96,124,102,102,102,60,0}, // 6 {126,6,12,24,48,48,48,0}, // 7 {60,102,60,60,102,60,0,0}, // 8 {60,102,102,62,6,12,56,0}, // 9 {0,24,24,0,24,24,0,0}, // : {0,24,24,0,24,24,48,0}, // ; {12,24,48,96,48,24,12,0}, // < {0,0,126,0,126,0,0,0}, // = {96,48,24,12,24,48,96,0}, // > {60,102,6,12,24,0,24,0}, // ? {60,102,110,110,96,62,0,0}, // @ {24,60,102,102,126,102,102,0}, // A {124,102,102,124,102,102,124,0}, // B {60,102,96,96,96,102,60,0}, // C {120,108,102,102,102,108,120,0}, // D {126,96,96,124,96,96,126,0}, // E {126,96,96,124,96,96,96,0}, // F {60,102,96,110,102,102,60,0}, // G {102,102,102,126,102,102,102,0}, // H {60,24,24,24,24,24,60,0}, // I {30,12,12,12,12,108,56,0}, // J {102,108,120,112,120,108,102,0}, // K {96,96,96,96,96,96,126,0}, // L {99,119,127,107,99,99,99,0}, // M {102,118,126,126,110,102,102,0}, // N {60,102,102,102,102,102,60,0}, // O {124,102,102,124,96,96,96,0}, // P {60,102,102,102,106,100,58,0}, // Q {124,102,102,124,112,108,102,0}, // R {60,102,96,60,6,102,60,0}, // S {126,24,24,24,24,24,24,0}, // T {102,102,102,102,102,102,60,0}, // U {102,102,102,102,102,60,24,0}, // V {99,99,99,107,127,119,99,0}, // W {102,102,60,24,60,102,102,0}, // X {102,102,102,60,24,24,24,0}, // Y {126,6,12,24,48,96,126,0}, // Z {60,48,48,48,48,48,60,0}, // [ {0,192,96,48,24,12,6,0}, // Backslash {60,12,12,12,12,12,60,0}, // ] {0,0,0,0,0,0,0,0}, // ^ {0,0,0,0,0,0,0,255}, // _ {24,12,0,0,0,0,0,0}, // ` {0,0,56,68,68,68,56,0}, // a {128,128,240,136,136,136,240,0}, // b {0,0,56,64,64,64,56,0}, // c {8,8,120,136,136,136,120,0}, // d {0,0,56,68,124,64,56,0}, // e {16,40,32,124,32,32,32,0}, // f {0,0,120,132,132,124,4,120}, // g {128,128,240,136,136,136,136,0}, // h {24,0,96,32,32,32,112,0}, // i {12,0,12,12,12,12,12,56}, // j {128,128,144,160,192,160,144,0}, // k {96,32,32,32,32,32,112,0}, // l {0,0,240,168,168,168,168,0}, // m {0,0,240,136,136,136,136,0}, // n {0,0,56,68,68,68,56,0}, // o {0,0,240,136,136,240,128,128}, // p {0,0,120,136,136,120,8,8}, // q {0,0,240,136,128,128,128,0}, // r {0,0,56,64,56,4,120,0}, // s {32,124,32,32,32,32,16,0}, // t {0,0,136,136,136,136,120,0}, // u {0,0,136,136,136,80,32,0}, // v {0,0,136,136,168,168,80,0}, // w {0,0,136,80,32,80,136,0}, // x {0,0,136,136,120,8,120,0}, // y {0,0,124,8,16,32,124,0}, // z {0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0} }; class Graphics { static uint32_t* front; static uint32_t* back; static int w, h, size; public: static void Init(multiboot_info* mb) { front = (uint32_t*)(uint32_t)mb->fb_addr; w = mb->fb_width; h = mb->fb_height; size = w * h; back = (uint32_t*)0x1000000; } static void Clear(uint32_t col) { int count = size; uint32_t* d = back; while(count--) *d++ = col; } static void Swap() { fast_memcpy(front, back, size * 4); } static void Put(int x, int y, uint32_t col) { if(x>=0 && x=0 && yw) w=w-x; if(y+h>h) h=h-y; if(w<=0||h<=0) return; for(int j=0; j127) idx=0; for(int r=0; r<8; r++) { for(int k=0; k<8; k++) { if((font[idx][r] >> (7-k)) & 1) Put(x+k, y+r, col); } } } static void Text(int x, int y, const char* s, uint32_t col) { while(*s) { Char(x, y, *s, col); x+=8; s++; } } }; uint32_t* Graphics::front=0; uint32_t* Graphics::back=0; int Graphics::w=0; int Graphics::h=0; int Graphics::size=0;