Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Pyrofan1
Member
Posts: 234 Joined: Sun Apr 29, 2007 1:13 am
Post
by Pyrofan1 » Mon Jun 25, 2007 6:30 pm
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.
frank
Member
Posts: 729 Joined: Sat Dec 30, 2006 2:31 pm
Location: East Coast, USA
Post
by frank » Mon Jun 25, 2007 8:47 pm
The only thing that I can think of would be to make sure that x_pos and y_pos are correct.
Pyrofan1
Member
Posts: 234 Joined: Sun Apr 29, 2007 1:13 am
Post
by Pyrofan1 » Mon Jun 25, 2007 9:08 pm
make sure that x_pos and y_pos are correct.
thank you, i hate it when it's something simple.
os64dev
Member
Posts: 553 Joined: Sat Jan 27, 2007 3:21 pm
Location: Best, Netherlands
Post
by os64dev » Tue Jun 26, 2007 1:48 am
your tab case seems akward should i not some thing like this for 4 spaces tab. Your code doesn't do tab justice
t0xic
Member
Posts: 216 Joined: Sat May 05, 2007 3:16 pm
Location: VA
Contact:
Post
by t0xic » Tue Jun 26, 2007 6:51 am
@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