From 835e9ee6f081c2b8d2f645f4258423d707614851 Mon Sep 17 00:00:00 2001 From: shockrahwow Date: Wed, 16 Jan 2019 15:51:02 -0800 Subject: [PATCH] adding some basic frame buffer testing functions --- framebuffer.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++ framebuffer.h | 7 +++++++ 2 files changed, 59 insertions(+) create mode 100644 framebuffer.c create mode 100644 framebuffer.h diff --git a/framebuffer.c b/framebuffer.c new file mode 100644 index 0000000..2324266 --- /dev/null +++ b/framebuffer.c @@ -0,0 +1,52 @@ +// 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(const unsigned cell, const char c, const char fg_bg) { + Frame_Buffer[cell] = c; + Frame_Buffer[cell+1] = fg_bg; +} + +void colors() { + // finding what the fucking colors are that we can draw + unsigned char color = 0x00; + for(int i =0;i<0x20;i++) { + Frame_Buffer[i] = 'a'; + Frame_Buffer[i+1] = color; + color++; + } +} \ No newline at end of file diff --git a/framebuffer.h b/framebuffer.h new file mode 100644 index 0000000..0ac75f7 --- /dev/null +++ b/framebuffer.h @@ -0,0 +1,7 @@ +#define COLUMNS 80 +#define ROWS 25 +#define AREA ( COLUMNS * ROWS ) + +void write_cell(const unsigned cell, const char c , const char fg_bg); + +void hello(); \ No newline at end of file