hide cursor using vga registers

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.
Post Reply
User avatar
matias_beretta
Member
Member
Posts: 101
Joined: Mon Feb 26, 2007 3:39 pm

hide cursor using vga registers

Post 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?
Matías Beretta
rd1101
Posts: 2
Joined: Sat Dec 15, 2007 7:37 pm
Location: Chicago, USA

Post 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 :wink:, 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.
~R
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: hide cursor using vga registers

Post 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
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
User avatar
MDM
Member
Member
Posts: 57
Joined: Wed Jul 21, 2010 9:05 pm

Re: hide cursor using vga registers

Post 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?
egos
Member
Member
Posts: 612
Joined: Fri Nov 16, 2007 1:59 pm

Re: hide cursor using vga registers

Post by egos »

Code: Select all

	SetMiscOutputRegister(m);
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);
If you have seen bad English in my words, tell me what's wrong, please.
User avatar
MDM
Member
Member
Posts: 57
Joined: Wed Jul 21, 2010 9:05 pm

Re: hide cursor using vga registers

Post by MDM »

Im trying to make the cursor invisible.
egos
Member
Member
Posts: 612
Joined: Fri Nov 16, 2007 1:59 pm

Re: hide cursor using vga registers

Post by egos »

Code: Select all

  outw(0x3D4,0x200A);

  /* In many sources end line register is reset too. */
  outw(0x3D4,0xB);
If you have seen bad English in my words, tell me what's wrong, please.
User avatar
MDM
Member
Member
Posts: 57
Joined: Wed Jul 21, 2010 9:05 pm

Re: hide cursor using vga registers

Post by MDM »

That did it, thank you!
Post Reply