Hi,
I'm designing my toy operating system and I'm kinda confused on the whole console output issue. I know that if i "physically" put chars at 0xB8000 it'll show it on the screen (in vga), but how would that work for GUI environments or multi-tty? Is there a site or anything I could look at to see how other people have implemented these functions?
Thanks for the help!
Erik Davidson
printk() and printf()
-
mercury
RE:printk() and printf()
You'd have to design that functionality when you design your GUI. As for multi TTY's I suppose you could set up a buffer the same size as the video memory, then when you write a character to the screen, write it to the buffer as well. Have a buffer for each TTY, and when you want to switch TTYs, copy the memory from that buffer, to the video memory. I'm sure there are a lot of other options.
Oh, by the way, with the GUI, you'd probably have to design your own character output functions. Meaning, design your own fonts, and use graphics rather than character output. Up to you how you do this when you design your GUI I guess.
Oh, by the way, with the GUI, you'd probably have to design your own character output functions. Meaning, design your own fonts, and use graphics rather than character output. Up to you how you do this when you design your GUI I guess.
-
aphistic
RE:printk() and printf()
Thanks for the suggestions on the TTY's. That's the idea I had for doing 'em, but I wasn't sure if that was the best way to do it or if there were other ways to do it.
As for the GUI stuff I guess I'll just have to work that out when I get to it.
As for the GUI stuff I guess I'll just have to work that out when I get to it.
-
mercury
RE:printk() and printf()
I'm sure there are other ways. I'm most DEFINATELY not an expert, but that seemed like the logical way. What type OS are you designing?
-
markus
thats the cprintf function of my operating system [cprintf()
|||||||||||console_io.h||||||||||||||||||||||||||||||||||||
/**********************************************************/
/* MOS v2.0 */
/* operating system */
/* by Markus Pollak */
/**********************************************************/
int curx=0;
int curc=0;
void cprintf(int colour, char *string)
{
char *video=(char*)0xB8000;
video = video + curc;
while(*string!=0)
{
*video=*string;
string++;
video++;
*video=colour;
video++;
curc=curc+2;
curx++;
if(curx==80)
{
console_new_line();
}
}
}
void console_cls()
{
char *video=(char*)0xB8000;
char *x=' ';
int i;
for(i=0;i<2000;i++)
{
*video=*x;
video++;
*video=0;
video++;
}
}
void console_new_line()
{
char *video=(char*)0xB8000;
int x,i;
char *m=' ';
x = 80 - curx;
for(i=0;i<x;i++)
{
*video=*m;
video++;
*video=0;
video++;
curc=curc+2;
curx++;
}
curx=0;
}
/**********************************************************/
/* MOS v2.0 */
/* operating system */
/* by Markus Pollak */
/**********************************************************/
int curx=0;
int curc=0;
void cprintf(int colour, char *string)
{
char *video=(char*)0xB8000;
video = video + curc;
while(*string!=0)
{
*video=*string;
string++;
video++;
*video=colour;
video++;
curc=curc+2;
curx++;
if(curx==80)
{
console_new_line();
}
}
}
void console_cls()
{
char *video=(char*)0xB8000;
char *x=' ';
int i;
for(i=0;i<2000;i++)
{
*video=*x;
video++;
*video=0;
video++;
}
}
void console_new_line()
{
char *video=(char*)0xB8000;
int x,i;
char *m=' ';
x = 80 - curx;
for(i=0;i<x;i++)
{
*video=*m;
video++;
*video=0;
video++;
curc=curc+2;
curx++;
}
curx=0;
}
-
markus
^^^^ some informations to the MOS output functions ^^^^
If you use this code in your operating system please insert my name into your credit list.
to print text to the screen use following code:
cprintf(7,"example text!");
7 is the standard colour white for the font
other colours:
here are my defines for the colours:
|||||||||console_gfx.h||||||||||||||
#define Col_BLACK 0
#define Col_BLUE 1
#define Col_GREEN 2
#define Col_CYAN 3
#define Col_RED 4
#define Col_MAGENTA 5
#define Col_ORANGE 6
#define Col_WHITE 7
#define Col_GRAY 8
#define Col_BLUELIGHT 9
#define Col_GREENLIGHT 10
#define Col_CYANLIGHT 11
#define Col_PINK 12
#define Col_MAGENTALIGHT 13
#define Col_YELLOW 14
#define Col_WHITELIGHT 15
but you can't use "\n" in the cprintf function!
for this problem i wrote the function console_new_line()
i wrote too a clear screen function named console_cls()
Thanks for your interests in my Code
sorry for my bad english (i come from Austria in Europe)
for help mail to [email protected]
greets ,Markus
to print text to the screen use following code:
cprintf(7,"example text!");
7 is the standard colour white for the font
other colours:
here are my defines for the colours:
|||||||||console_gfx.h||||||||||||||
#define Col_BLACK 0
#define Col_BLUE 1
#define Col_GREEN 2
#define Col_CYAN 3
#define Col_RED 4
#define Col_MAGENTA 5
#define Col_ORANGE 6
#define Col_WHITE 7
#define Col_GRAY 8
#define Col_BLUELIGHT 9
#define Col_GREENLIGHT 10
#define Col_CYANLIGHT 11
#define Col_PINK 12
#define Col_MAGENTALIGHT 13
#define Col_YELLOW 14
#define Col_WHITELIGHT 15
but you can't use "\n" in the cprintf function!
for this problem i wrote the function console_new_line()
i wrote too a clear screen function named console_cls()
Thanks for your interests in my Code
sorry for my bad english (i come from Austria in Europe)
for help mail to [email protected]
greets ,Markus