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
reading cursor pos. and cur. on/off
Re:reading cursor pos. and cur. on/off
Code: Select all
outb(0x3D4,14);
outb(0x3D5,0);
outb(0x3D4,15);
outb(0x3D5,0);
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 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));
I think you can find more info at [url=http://www.osdever.net"]http://www.osdever.net[/url]
Only Human
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:reading cursor pos. and cur. on/off
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
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!
PS. Don?t need that much CPU power in text mode..
Neo: Thanks!
Re:reading cursor pos. and cur. on/off
One more thing. What is >> or << in C?
Is it shift right/left by x bytes?
/ Christoffer
Is it shift right/left by x bytes?
/ Christoffer
Re:reading cursor pos. and cur. on/off
Shift by bits.
Every good solution is obvious once you've found it.
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:reading cursor pos. and cur. on/off
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.bubach wrote: But the cursor position may have changed by a user program or something...
If you're in pmode, the user program will not have access to the hardware cursor anyway.
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 ?PS. Don?t need that much CPU power in text mode..
Re:reading cursor pos. and cur. on/off
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
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