I used the Tutorial from
www.osdever.net labeled Kernel in C++.
after following it (and noticing there is only 2 of the 4 parts) I started to implement my own code. I added a newline function but when I execute it all it does is move the next printed string one spot to the right. the tutorial says that the:
undefined int off;
should move the cursor or message down a line. but when I use my function it does not do so. It does the same thing as the pos integer (undefined int pos;)
here is ALL of my code:
Kernel.cpp
Code:
#include "Video.h"
int main(void)
{
Video Vid;
Vid.write("Welcome, To Orion OS");
Vid.cout("Orion>>");
}
Video.cpp
Code:
#include "Video.h"
Video::Video()
{
pos=0; off=0;
videomem = (unsigned short*) 0xb8000 ;
}
Video::~Video()
{
}
void Video::clear()
{
unsigned int i;
for(i=0; i<(80*25); i++)
{
videomem[i] = (unsigned char) ' ' | 0x0700 ;
}
pos=0; off=0;
}
void Video::write(char *cp)
{
char *str = cp, *ch;
clear() ;
pos=0; off=0;
for (ch = str; *ch; ch++)
{
put(*ch) ;
pos+=1; //off+=1;
}
pos; off;
}
int Video::newline()
{
pos=0; off++;
}
void Video::cout(char *cp)
{
char *str = cp, *ch;
newline() ;
for (ch = str; *ch; ch++)
{
put(*ch) ;
pos+=1; //off+=1;
}
pos; off;
}
void Video::put(char c)
{
if(pos>=80)
{
pos=0;
off += 80;
}
if(off>=(80*25))
{
clear() ; //clear the screen
}
videomem[off + pos] = (unsigned char) c | 0x0700 ;
}
Video.h
Code:
#ifndef VIDEO_H
#define VIDEO_H //only one definition of Video
class Video
{
public:
Video();
~Video();
int newline();
void clear();
void write(char *cp);
void cout(char *cp);
void put(char c);
private:
unsigned short *videomem ;
unsigned int off ;
unsigned int pos ;
};
#endif
linker and asm available if needed