summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--kernel/Helpers/globalVars.hpp0
-rw-r--r--kernel/Helpers/memPrint.cpp66
-rw-r--r--kernel/Helpers/memPrint.hpp9
-rw-r--r--kernel/main.cpp21
4 files changed, 76 insertions, 20 deletions
diff --git a/kernel/Helpers/globalVars.hpp b/kernel/Helpers/globalVars.hpp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/kernel/Helpers/globalVars.hpp
diff --git a/kernel/Helpers/memPrint.cpp b/kernel/Helpers/memPrint.cpp
index f6cc397..179b821 100644
--- a/kernel/Helpers/memPrint.cpp
+++ b/kernel/Helpers/memPrint.cpp
@@ -1,5 +1,7 @@
#include "./memPrint.hpp"
+
+
//Constructor
memPrint::memPrint(){
@@ -21,14 +23,28 @@ memPrint::~memPrint(){
//Move cursor
void memPrint::updateCursor(){
+
+
+ //Update X axis
this->m_cursorX++;
- if(this->m_cursorX > MAXCURSORX){
+ //Check X value
+ if(this->m_cursorX >= MAXCURSORX){
+
+ //If X is out of the screen
this->m_cursorX=0;
+
+ //Update Y
this->m_cursorY++;
- if(this->m_cursorY > MAXCURSORY){
- //Scroll screen
+ //Check Y value
+ if(this->m_cursorY >= MAXCURSORY){
+
+ //If Y is out of the screen
+ this->scrollUp(1);
+
+ //Decrease Y value
+ this->m_cursorY--;
}
@@ -37,35 +53,73 @@ void memPrint::updateCursor(){
}
+//Change character background color
void memPrint::setBackground(colorBios color){
u8 newColor= (color << 4);
this->m_colors= newColor | ((this->m_colors << 4) >> 4);
}
+//Change character color
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);
+ //Get the adresse with the cursor position
+ char *adress= ((char *) MEMPRINTSTARTADR) + (this->m_cursorX * 2) + (this->m_cursorY * MAXCURSORX * 2);
+ //Copy the character
*adress=character;
+ //Copy his attribute
adress++;
-
*adress=this->m_colors;
+ //Update cursor position
this->updateCursor();
}
+
+//Print a char*
void memPrint::print(char *str){
while(*str!=0x0){
this->putChar(*str);
str++;
}
}
+
+//Clear the screen
+void memPrint::clear(){
+ this->scrollUp(MAXCURSORY);
+}
+
+//Scroll up "number" times
+void memPrint::scrollUp(u8 number){
+
+ //Get number of adress (char & his attribute) to scroll
+ int nbAdrToScroll=number*MAXCURSORX*2;
+
+
+ //Scroll all of the characters and attributes
+ for(int i=0;i!=MAXCURSORX*2*MAXCURSORY;i++){
+
+ //Get source character or attribute
+ char* source=(((char *)MEMPRINTSTARTADR) + i);
+
+ //Get destination character or attribute
+ char* dest=source-nbAdrToScroll;
+
+ //Check if destination is out of the screen
+ if(dest >= (char *)MEMPRINTSTARTADR)
+ *dest=*source;
+
+ //Remove data from source
+ *source=0x0;
+
+ }
+
+}
diff --git a/kernel/Helpers/memPrint.hpp b/kernel/Helpers/memPrint.hpp
index 437d6cb..19a6708 100644
--- a/kernel/Helpers/memPrint.hpp
+++ b/kernel/Helpers/memPrint.hpp
@@ -8,6 +8,9 @@
#define MAXCURSORX 80
#define MAXCURSORY 25
+
+
+
//Define the bios color
enum colorBios{
@@ -67,6 +70,12 @@ class memPrint{
//Print
void print(char *str);
+ //Scroll up
+ void scrollUp(u8 number);
+
+ //Clear screen
+ void clear();
+
};
#endif
diff --git a/kernel/main.cpp b/kernel/main.cpp
index 9cd9875..0dec7e0 100644
--- a/kernel/main.cpp
+++ b/kernel/main.cpp
@@ -3,24 +3,17 @@
#include "./Helpers/memPrint.hpp"
-//----- PiegOS kernel main -----
-int main(){
+//----- Global Definition -----
+memPrint VideoRam; //Used to print data on screen
+//-----------------------------
- //Test print a char
- /*char* letter=(char*)0xB8A00;
- *letter='H';
- letter++;
- *letter=(GREEN << 4) | BLUE;*/
- memPrint VideoRam;
+//----- PiegOS kernel main -----
+int main(){
- VideoRam.print("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
- VideoRam.print("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
- VideoRam.print("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
- VideoRam.print("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
- VideoRam.print("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
- VideoRam.print("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
+ //Welcome
+ VideoRam.print("Welcome to PiegOS");
//Infinite loop
while(1);