summaryrefslogtreecommitdiff
path: root/kernel/Helpers
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/Helpers')
-rw-r--r--kernel/Helpers/memPrint.cpp60
-rw-r--r--kernel/Helpers/memPrint.hpp27
2 files changed, 87 insertions, 0 deletions
diff --git a/kernel/Helpers/memPrint.cpp b/kernel/Helpers/memPrint.cpp
index bde4702..f6cc397 100644
--- a/kernel/Helpers/memPrint.cpp
+++ b/kernel/Helpers/memPrint.cpp
@@ -3,9 +3,69 @@
//Constructor
memPrint::memPrint(){
+ //Initialise position
+ this->m_cursorX=0;
+ this->m_cursorY=0;
+
+ //Initialise color
+ this->setBackground(BLACK);
+ this->setForeground(WHITE);
+
}
//Destructor
memPrint::~memPrint(){
}
+
+
+//Move cursor
+void memPrint::updateCursor(){
+ this->m_cursorX++;
+
+ if(this->m_cursorX > MAXCURSORX){
+ this->m_cursorX=0;
+ this->m_cursorY++;
+
+ if(this->m_cursorY > MAXCURSORY){
+ //Scroll screen
+ }
+
+
+ }
+
+
+}
+
+void memPrint::setBackground(colorBios color){
+ u8 newColor= (color << 4);
+ this->m_colors= newColor | ((this->m_colors << 4) >> 4);
+}
+
+void memPrint::setForeground(colorBios color){
+ u8 newColor= color;
+ this->m_colors= newColor | ((this->m_colors >> 4) << 4);
+}
+
+//Print a char
+
+void memPrint::putChar(u8 character){
+
+ char *adress= ((char *) MEMPRINTSTARTADR) + (this->m_cursorX * 2) + (this->m_cursorY * 80 * 2);
+
+ *adress=character;
+
+ adress++;
+
+ *adress=this->m_colors;
+
+ this->updateCursor();
+
+}
+
+void memPrint::print(char *str){
+ while(*str!=0x0){
+ this->putChar(*str);
+ str++;
+ }
+}
diff --git a/kernel/Helpers/memPrint.hpp b/kernel/Helpers/memPrint.hpp
index 841be86..437d6cb 100644
--- a/kernel/Helpers/memPrint.hpp
+++ b/kernel/Helpers/memPrint.hpp
@@ -1,6 +1,13 @@
#ifndef __memPrint__
#define __memPrint__
+#include "./types.hpp"
+
+
+#define MEMPRINTSTARTADR 0xB8000
+#define MAXCURSORX 80
+#define MAXCURSORY 25
+
//Define the bios color
enum colorBios{
@@ -32,6 +39,15 @@ class memPrint{
private:
+ //Cursor position
+ u8 m_cursorX;
+ u8 m_cursorY;
+
+ //Current colors (background and foreground):
+ u8 m_colors;
+
+ //Methods
+ void updateCursor();
public:
@@ -40,6 +56,17 @@ class memPrint{
//Destructor
~memPrint();
+
+ //Set color
+ void setBackground(colorBios color);
+ void setForeground(colorBios color);
+
+ //Putchar
+ void putChar(u8 character);
+
+ //Print
+ void print(char *str);
+
};
#endif