Setup a graphics 'driver' of sorts that can display a banner at the top of the screen.
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
#include "../includes/screen.h"
|
||||
#include "../build_numbers.c"
|
||||
|
||||
unsigned char row = 1;
|
||||
unsigned char column = 0;
|
||||
unsigned char screen_width = 80;
|
||||
|
||||
|
||||
void print_banner(){
|
||||
unsigned short *buffer = 0x000B8000;
|
||||
unsigned short attr = 0x1800;
|
||||
|
||||
unsigned char* banner = "Project Code Name: kernel3";
|
||||
char* version = KERNEL_VERSION_NUMBER;
|
||||
unsigned char banner_length = (80 - strlen(banner)) / 2;
|
||||
// Add 14 for the string "Kernel Version: ".
|
||||
unsigned char version_length = (80 - (strlen(version) + 16)) / 2;
|
||||
|
||||
for(unsigned char i = 0; i < screen_width; i++){
|
||||
*buffer++ = ' ';
|
||||
*buffer++ = attr;
|
||||
}
|
||||
|
||||
for(unsigned char i = 0; i < screen_width; i++){
|
||||
if(i == banner_length){
|
||||
for(unsigned short j = 0; j < strlen(banner); j++){
|
||||
unsigned short *where = (unsigned short*) 0x000B8000 + j + i;
|
||||
*where = banner[j] | attr;
|
||||
}
|
||||
}
|
||||
|
||||
if(i == version_length){
|
||||
unsigned short offset = 0;
|
||||
char* tmp = "Kernel Version: ";
|
||||
for(unsigned char j = 0; j < strlen(tmp); j++){
|
||||
unsigned short *where = (unsigned short*) 0x000B8000 + j + 80 + i;
|
||||
*where = tmp[j] | attr;
|
||||
offset++;
|
||||
}
|
||||
|
||||
for(unsigned char j = 0; j < strlen(version); j++){
|
||||
unsigned short *where = (unsigned short*) 0x000B8000 + j + 80 + offset + i;
|
||||
*where = version[j] | attr;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void draw_s(char* string, unsigned char fg, unsigned char bg)
|
||||
{
|
||||
char *video_buffer = 0x000B8000;
|
||||
|
||||
for(int i = 0; i < strlen(string); i++)
|
||||
{
|
||||
char current_char = string[i];
|
||||
|
||||
if(current_char == '\n'){
|
||||
//row++;
|
||||
column = row * column;
|
||||
row++;
|
||||
continue;
|
||||
}
|
||||
|
||||
video_buffer[i*2 + (row * column)] = string[i];
|
||||
video_buffer[i * 2 + 1 + (row * column)] = ((fg & 0x0f) << 4) | (bg & 0x0F);
|
||||
//column++;
|
||||
}
|
||||
}
|
||||
|
||||
void clear_screen(){
|
||||
char *video_buffer = 0x000B8000;
|
||||
|
||||
for(unsigned char i = 0; i < 25; i++){
|
||||
for(unsigned char j = 0; j < 80; j++){
|
||||
*video_buffer++ = ' ';//0x20 | (0x0F << 8);
|
||||
*video_buffer++ = 0x82;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int strlen(char* string)
|
||||
{
|
||||
int len = 0;
|
||||
|
||||
for(int i = 0; string[i] != '\0'; i++) len++;
|
||||
|
||||
return len;
|
||||
}
|
||||
Reference in New Issue
Block a user