jankos/framebuffer.c
2019-01-18 12:47:13 -08:00

38 lines
1.1 KiB
C

// Driver implementation for Jank's text frame buffer
// Buffer can display 80 columns by 25 Rows
// Start of buffer is at (real)address 0x000B8000
// Memory at this section is divided into 16-bit cells
// | 15-8 | 7-4 | 0-3
// | Asci | FG | BG
// The following colors are available(from 0x0 to 0xF):
// Black Blue Green Cyan Red Magenta
// Brown LightGrey DarkGrey LightBlue LightGreen
// LightCyan LightRed LightMagenta LightBrown White
/*
enum typedef Colors{
Black, Blue, Green,
Cyan, Red, Magenta,
Brown, LightGrey, DarkGrey,
LightBlue, LightGreen, LightCyan,
LightRed, LightMagenta, LightBrown,
White,
};
*/
#include "framebuffer.h"
// page 24
static char* Frame_Buffer = (char*)0x000B8000;
// Writes character to a given cell in the framebuffer
// Safety handled by caller function
void write_cell(unsigned cell, char c, char fg, char bg) {
Frame_Buffer[cell] = c;
Frame_Buffer[cell+1] = (fg & 0x0f << 4) | (bg & 0x0f);
}
void colors() {
for(int i =0;i<0x10;i++) {
write_cell(i, 'a', 8, 8);
}
}