first pass of some test functions

This commit is contained in:
shockrahwow 2019-01-23 00:53:28 -08:00
parent 3aaed95484
commit de036ce327
2 changed files with 45 additions and 8 deletions

View File

@ -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);
}
}
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 ");
}

View File

@ -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();
void clear_buffer();
static void print(char* str);
void yote();