Page 1 of 1
Text function doesn't work
Posted: Mon Jun 25, 2007 6:30 pm
by Pyrofan1
Code: Select all
void Putch(unsigned char c,unsigned char forecolor,unsigned char backcolor)
{
unsigned short attrib=((backcolor<<4)|(forecolor&0x0F))<<8;
unsigned short *where;
if(c=='\n')
{
x_pos=0;
y_pos++;
}
else
if(c=='\r')
{
x_pos=0;
}
else
if(c=='\t')
{
Putch(' ',BLACK,BLACK);
Putch(' ',BLACK,BLACK);
Putch(' ',BLACK,BLACK);
Putch(' ',BLACK,BLACK);
Putch(' ',BLACK,BLACK);
}
else
{
where=((unsigned short*)0xB8000)+(y_pos*80+x_pos);
*where=c|attrib;
x_pos++;
}
}
when i try to use this function i get no text displayed.
Posted: Mon Jun 25, 2007 8:47 pm
by frank
The only thing that I can think of would be to make sure that x_pos and y_pos are correct.
Posted: Mon Jun 25, 2007 9:08 pm
by Pyrofan1
make sure that x_pos and y_pos are correct.
thank you, i hate it when it's something simple.
Posted: Tue Jun 26, 2007 1:48 am
by os64dev
your tab case seems akward should i not some thing like this for 4 spaces tab. Your code doesn't do tab justice
Posted: Tue Jun 26, 2007 6:51 am
by t0xic
@Pyrofan1
Just a suggestion:
At the point you are at, I would say that you should create a console structure so that you can easily keep track of foreground, bground, x and y easily. Use something like this:
Code: Select all
struct console_t
{
int x, y;
char color;
};
And if you really need to get the foreground and background colors out, just do a mask
Code: Select all
foreground = color & 0xF0;
background = color & 0x0F;
(^^^ That should be right, not sure though )
--t0xic