summaryrefslogtreecommitdiff
path: root/kernel/Helpers/memPrint.cpp
blob: f6cc39744e393194b72696dafe6f5a073a2b38bb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include "./memPrint.hpp"

//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++;
    }
}