Fixed a bug that caused the kernel image to lose it multiboot signature. Added code to test printing a string to the screen.
This commit is contained in:
+32
-6
@@ -1,13 +1,20 @@
|
||||
#include "../includes/io.h"
|
||||
#include "../includes/kernel.h"
|
||||
|
||||
void write_screen(unsigned int, char, unsigned char, unsigned char);
|
||||
void move(unsigned short);
|
||||
//char* msg = "Hello, World!";
|
||||
|
||||
extern void kmain()
|
||||
void kmain()
|
||||
{
|
||||
write_screen(0, 'A', 2, 8);
|
||||
move(80);
|
||||
//asm("hlt");
|
||||
draw_s("Hello, World!", 2, 9);/*
|
||||
write_screen(0, "k", 2, 9);
|
||||
write_screen(2, 'e', 2, 9);
|
||||
write_screen(4, 'r', 2, 9);
|
||||
write_screen(6, 'n', 2, 9);
|
||||
write_screen(8, 'e', 2, 9);
|
||||
write_screen(10, 'l', 2, 9);
|
||||
write_screen(12, ' ', 2, 9);
|
||||
write_screen(14, '3', 2, 9);
|
||||
//asm("hlt");*/
|
||||
}
|
||||
|
||||
void write_screen(unsigned int i, char c, unsigned char fg, unsigned char bg)
|
||||
@@ -24,3 +31,22 @@ void move(unsigned short pos)
|
||||
outb(0x3D4, 15);
|
||||
outb(0x3D5, pos & 0x00FF);
|
||||
}
|
||||
|
||||
void draw_s(char* string, unsigned char fg, unsigned char bg)
|
||||
{
|
||||
char *video_buffer = 0x000B8000;
|
||||
for(int i = 0; i < strlen(string); i++)
|
||||
{
|
||||
video_buffer[i] = string[i];
|
||||
video_buffer[i+1] = ((fg & 0x0f) << 4) | (bg & 0x0F);
|
||||
}
|
||||
}
|
||||
|
||||
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