Garabage Characters From K_PrintF
Posted: Wed Jun 11, 2003 1:09 pm
I am having problems with my k_printf function which is:
Here is my the part of k_main that calls it:
It is polling and receiving input from the keyboard.
When I run this, what I type is displayed perfectly, but after it are three garbage characters. What is the cause of this?
Code: Select all
unsigned int k_printf(char *message, unsigned int line) // PrintF for green on black.
{
char *vidmem = (char *) 0xb8000; // Address in memory where Video RAM begins.
unsigned int i=0;
i=(line*80*2); // 80 Characters in Current Line, 2 Bytes per Character
while(*message!='\0') // Stop at null.
{
if(*message=='\n') // Check for a new line.
{
line++; // Increase current line.
i=(line*80*2); // Reset i.
*message++; // Walk through the message variable with pointer.
} else {
vidmem[i]=*message; // Adjust current address in video memory to store current character.
*message++; // Walk through the message variable with pointer.
i++; // Increase current byte by one.
vidmem[i]=GREEN_TXT; // Adjust current address in video memory to store current hex color code.
i++; // Increase current byte by one.
};
};
return(1); // Executed successfully.
};
Code: Select all
unsigned char i;
for(;;)
{
i = getch();
k_printf(&i,3);
};
When I run this, what I type is displayed perfectly, but after it are three garbage characters. What is the cause of this?