Page 1 of 1
hide cursor using vga registers
Posted: Sun Dec 16, 2007 8:32 pm
by matias_beretta
I had been looking for a register to hide the cursor but i didn't find anything. How can i hide my cursor without using bios?
Posted: Sun Dec 16, 2007 9:51 pm
by rd1101
Are you trying to hide a text-mode cursor? If not... disregard, nothing to see here...
I couldn't get writing a value directly to 0x0040:0060 for the cursor scan lines to do anything. I'm sure someone more expert than myself has a better solution.. but if you can't use int 0x10 ah=0x01, I think that you could:
- save the current cursor position in your data section
- set the cursor position to FF, FF or something else 'off screen'
- restore the cursor position when you need to write in teletype mode
Of course once you start doing all of this, you may as well write your chars directly to video memory too

, and just leave the cursor off screen.
Just a suggestion. If I'm not understanding your question correctly, just pretend I'm talking to myself. I'm comfortable with that.
Re: hide cursor using vga registers
Posted: Sun Dec 16, 2007 10:25 pm
by Brendan
Hi,
matias_beretta wrote:I had been looking for a register to hide the cursor but i didn't find anything. How can i hide my cursor without using bios?
There's a few options...
The first method is to clear bit 5 in CRT controller register 0x0A, which is a "cursor enable/disable" flag. The next method is to shift the cursor off the screen (e.g. set the cursor start address to 0xFFFFF) using CRT controller registers 0x0E and 0x0F. Both of these methods assume your video card is VGA compatible at the hardware level (and not just VGA compatible at the BIOS level).
The other option is to disable the hardware cursor completely (e.g. when you set the video mode using the BIOS, also use
the BIOS function to disable the cursor), and then emulate your own cursor in software rather than using the hardware cursor (e.g. do "attribute = old_attribute XOR 0xFF") . This should work, even if your video card is not VGA compatible at the hardware level (and it might make things easier later when your video driver sets up a graphics video mode and emulates text mode for your application, because the video driver won't need to emulate the hardware cursor).
Cheers,
Brendan
Re: hide cursor using vga registers
Posted: Tue Mar 13, 2012 9:26 pm
by MDM
Sorry for the necro, but just to be sure, the method for clearing bit 5 of CRT 0xa would be
Code: Select all
static inline byte GetMiscOutputRegister() {
return inb(0x3CC);
}
static inline void SetMiscOutputRegister(byte b)
{
outb(0x3C2, b);
}
// crt 0xA
static inline void SetCursorStartRegister(byte b)
{
byte m = GetMiscOutputRegister();
m = m | 1;
SetMiscOutputRegister(b);
outb(0x3d4, 0xa);
outb(0x3d5, b);
}
and then you could pass 0 to SetCursorStartRegister (which would clear all the bits including 5) correct?
Re: hide cursor using vga registers
Posted: Wed Mar 14, 2012 2:14 am
by egos
MDM wrote:and then you could pass 0 to SetCursorStartRegister (which would clear all the bits including 5) correct?
What are you want to do? If you want to make cursor visible you should reset start line/end line registers. For example:
Code: Select all
outw(0x3D4,0xE0A);
outw(0x3D4,0xF0B);
Re: hide cursor using vga registers
Posted: Wed Mar 14, 2012 8:06 am
by MDM
Im trying to make the cursor invisible.
Re: hide cursor using vga registers
Posted: Wed Mar 14, 2012 10:08 am
by egos
Code: Select all
outw(0x3D4,0x200A);
/* In many sources end line register is reset too. */
outw(0x3D4,0xB);
Re: hide cursor using vga registers
Posted: Wed Mar 14, 2012 1:57 pm
by MDM
That did it, thank you!