From de036ce32729be2ec4441b7a03cf55b6ba04ee8c Mon Sep 17 00:00:00 2001 From: shockrahwow Date: Wed, 23 Jan 2019 00:53:28 -0800 Subject: [PATCH] first pass of some test functions --- framebuffer.c | 28 +++++++++++++++++++++------- framebuffer.h | 25 ++++++++++++++++++++++++- 2 files changed, 45 insertions(+), 8 deletions(-) diff --git a/framebuffer.c b/framebuffer.c index 3144f68..fad5bdb 100644 --- a/framebuffer.c +++ b/framebuffer.c @@ -22,17 +22,31 @@ enum typedef Colors{ */ #include "framebuffer.h" -// page 24 -static char* Frame_Buffer = (char*)0x000B8000; +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 colors() { - for(int i =0;i<0x10;i++) { - write_cell(i, 'a', 8, 8); - } -} \ No newline at end of file +void clear_buffer() { + char* fp = Frame_Buffer; + while(fp!=Frame_Buffer_End) { + *fp = 0x00; + } +} +static void print(char* str) { + unsigned idx = 0; + char* c = str; + while(c != 0x00) { + write_cell(idx, *c, Green, White); + idx += 2; + } +} + +void yote() { + print(" JankOS "); +} diff --git a/framebuffer.h b/framebuffer.h index 515e1bd..5d4e8f8 100644 --- a/framebuffer.h +++ b/framebuffer.h @@ -2,6 +2,29 @@ #define ROWS 25 #define AREA ( COLUMNS * ROWS ) + +#define FRAME_BUFFER_ADDR 0x000B8000 +#define Black 0x01 +#define Blue 0x02 +#define Green 0x03 +#define Cyan 0x04 +#define Red 0x05 +#define Magenta 0x05 +#define Brown 0x06 +#define LightGrey 0x07 +#define DarkGrey 0x08 +#define LightBlue 0x09 +#define LightGreen 0x0a +#define LightCyan 0x0b +#define LightRed 0x0c +#define LightMagenta 0x0d +#define LightBrown 0x0e +#define White 0x0f + void write_cell(unsigned cell, char c , char fg, char bg); -void hello(); \ No newline at end of file +void clear_buffer(); + +static void print(char* str); + +void yote();