jankos/framebuffer.c
2019-01-23 01:12:36 -08:00

35 lines
941 B
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
#include "framebuffer.h"
static char* Frame_Buffer = (char*)FRAME_BUFFER_ADDR;
static char* Frame_Buffer_End = (char*)(FRAME_BUFFER_ADDR + AREA);
// Writes character to a given cell in the framebuffer
// Safety handled by caller function
// also proper location is caller's responsibility
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 clear_buffer() {
char* fp = Frame_Buffer;
while(fp!=Frame_Buffer_End) {
*fp = 0x00;
}
}
void print(char* str) {
for(unsigned i =0;i<strlen(str);i+=2) {
write_cell(i, str[i], Green, White);
}
}
void yote() {
print("asdf");
}