Page 1 of 1
reading cursor pos. and cur. on/off
Posted: Mon Mar 15, 2004 11:48 am
by bubach
How do i read the cursor position and how do i turn the cursor on/off? I can?t seem to find any info on this.
All documents on the cursor is on how to move it..
/ Christoffer
Re:reading cursor pos. and cur. on/off
Posted: Mon Mar 15, 2004 11:59 am
by Neo
Code: Select all
outb(0x3D4,14);
outb(0x3D5,0);
outb(0x3D4,15);
outb(0x3D5,0);
this code positions the cursor at the top,left corner of the screen.
as you can see the ports 0x3d4 and 0x3d5 are used for cursor manipulation (this is text mode isn't it?)
to read in the cursor position you can use something like this
Code: Select all
outb(0x3D4,14);
offset = inb(0x3d5) << 8;
outb(0x3D4,15);
offset |= inb(0x3d5);
to get the position into var 'offset'
to reposition the cursor you may use soemthing like this
Code: Select all
outb(0x3D5,(unsigned char)offset);
outb(0x3D4,14);
outb(0x3D5,(unsigned char)(offset >> 8));
HTH'
I think you can find more info at [url=http://www.osdever.net"]http://www.osdever.net[/url]
Re:reading cursor pos. and cur. on/off
Posted: Mon Mar 15, 2004 2:01 pm
by Pype.Clicker
keep in mind that changing the cursor position is a slow operation (compared to your CPU power) and that deferring it or caching the last set position rather than reading it again and again from the VGA hardware will certainly boost your console driver.
Re:reading cursor pos. and cur. on/off
Posted: Tue Mar 16, 2004 3:16 am
by bubach
Pype.Clicker: But the cursor position may have changed by a user program or something...
PS. Don?t need that much CPU power in text mode..
Neo: Thanks!
Re:reading cursor pos. and cur. on/off
Posted: Tue Mar 16, 2004 3:43 am
by bubach
One more thing. What is >> or << in C?
Is it shift right/left by x bytes?
/ Christoffer
Re:reading cursor pos. and cur. on/off
Posted: Tue Mar 16, 2004 3:54 am
by Solar
Shift by bits.
Re:reading cursor pos. and cur. on/off
Posted: Tue Mar 16, 2004 4:17 am
by Pype.Clicker
bubach wrote:
But the cursor position may have changed by a user program or something...
If you're in real mode, yes ... though it would be a decent design choice to force the program that wants to move the cursor by direct hardware access to inform the driver it did so before using the driver to output text. Reading the current hardware cursor position to know where the next char is to be displayed would be (imho) confusing.
If you're in pmode, the user program will not have access to the hardware cursor anyway.
PS. Don?t need that much CPU power in text mode..
That depends on what you're doing. Imagine a kernel compilation that produces lot of output on the console (because in verbose mode), you wouldn't like the compilation to slow down because the console driver does 5 times more VGA I/O cycles, would you ?
Re:reading cursor pos. and cur. on/off
Posted: Tue Mar 16, 2004 4:25 am
by bubach
Solar: Ops, sorry i mean bits..

Pype.Clicker: I always forget that i am in pmode.. :-[
But i think that the driver should have the possibility to check it from the vga registers anyway.. (argh, d*mn my spelling)
/ Christoffer