Problem With Text Output
Posted: Mon Jun 04, 2007 4:04 pm
Recently (last night, in fact), I got back into OS development. I'm working on a simple OS that will (hopefully) have a GUI by November. Right now. there's a GDT, IDT and IRQ implementation in C. But, now that those are in, I've tried to create text I/O routines. They work 99%, but at the end of every line, an inverted degree sign will be displayed. I've made at least 15 little changes to the source code that haven't fixed it, so by now I'm stumped. Hopefully you guys can help me!
Thanks for any help that you can provide...
- Jeremiah
Code: Select all
/* Includes */
#include <video.h>
/* Variables */
unsigned char videoColor;
unsigned videoX = 0, videoY = 0;
/**
* Description:
* Changes the value of videoColor.
*
* Parameters:
* newVideoColor - New value for videoColor.
*
* Result:
*
*/
void SetVideoColor(unsigned char newVideoColor)
{
videoColor = newVideoColor;
}
/**
* Description:
* Prints a character to the screen.
*
* Parameters:
* character - Character to print.
*
* Result:
*
*/
void PrintChr(const unsigned char character)
{
unsigned char *where = (unsigned char *)(0xB8000 + (videoY * 80 + videoX) * 2);
*where++ = character;
*where++ = videoColor;
if(character >= ' ')
{
*where++ = character;
*where++ = videoColor;
videoX++;
if(videoX == 80)
{
videoY++;
videoX = 0;
}
}
else
{
switch(character)
{
case('\n'):
{
videoX = 0;
videoY++;
}
break;
case('\r'):
{
videoX = 0;
}
break;
}
}
}
/**
* Description:
* Prints a string to the screen.
*
* Parameters:
* string - String to print.
*
* Result:
*
*/
void PrintStr(char *string)
{
for(; *string != '\0'; string++)
PrintChr(*string);
}
- Jeremiah