Page 1 of 1

Disable VGA Text-mode Cursor Blinking

Posted: Sun Apr 21, 2013 9:12 am
by mghis
Hello.

This is indeed a silly idiosyncrasy of mine, but I can't stand the blinking of text-mode cursor.
I'd like to change it to get the same behaviour FreeBSD uses by default (that is, a white, non-flashing
block).

I got the block shape by changing some VGA registers, but I cannot figure out how to restrain
the cursor from blinking. A useful article on Osdever states that it's quite difficult to change
blinking rate from VGA, but I hope there is a way to disable it. As far as I know, FreeBSD boots in text
mode, but has the cursor behaviour I like. I tried to look up involved code in its kernel. It should be
somewhere around syscons.c, but I couldn't find anything useful.

Thanks for any help,

-- mghis

P.S.: please forgive me for my poor English. I am not a native speaker.

Re: Disable VGA Text-mode Cursor Blinking

Posted: Sun Apr 21, 2013 10:10 am
by Brendan
Hi,
mghis wrote:This is indeed a silly idiosyncrasy of mine, but I can't stand the blinking of text-mode cursor.
I'd like to change it to get the same behaviour FreeBSD uses by default (that is, a white, non-flashing
block).
You can't make the cursor solid using VGA registers. Instead, disable the hardware's cursor completely and draw your own "white block" character. Ironically, the BIOS function for disabling the hardware's cursor is the same function for changing how often it flashes.

Note: I'd assume that FreeBSD doesn't draw a white solid block, but actually swaps the foreground and background colours (e.g. so you get black text on a white background where the cursor is). This would look like a solid block when the cursor is at the end of the line (or over white space), but if you move the cursor left until a (non-whitespace) character is under the cursor you'd be able to see that character.


Cheers,

Brendan

Re: Disable VGA Text-mode Cursor Blinking

Posted: Mon Apr 22, 2013 7:36 am
by mghis
Brendan wrote:Hi,

You can't make the cursor solid using VGA registers. Instead, disable the hardware's cursor completely and draw your own "white block" character. Ironically, the BIOS function for disabling the hardware's cursor is the same function for changing how often it flashes.

Note: I'd assume that FreeBSD doesn't draw a white solid block, but actually swaps the foreground and background colours (e.g. so you get black text on a white background where the cursor is). This would look like a solid block when the cursor is at the end of the line (or over white space), but if you move the cursor left until a (non-whitespace) character is under the cursor you'd be able to see that character.


Cheers,

Brendan
Thank you very much for your helpful response, Brendan. Disabling the cursor and writing a white block or a space with swapped colours is indeed an useful approach. Probably FreeBSD does this way.

However, I'd like to point out that, as I said in the post before, you can get block-shaped hardware cursor by setting some VGA registers. (I just couldn't figure out how to disable the blink). The following code works for me: (I'm using pmode set by GRUB, and Bochs emulator)

Code: Select all

          /* Set a block-shaped cursor */
        mov     $0x0a, %al
        mov     $0x3d4,%dx
        outb    %al, %dx
        
        xor     %ax, %ax
        inc     %dx
        outb    %al, %dx
The ports and the offsets are taken from the interesting website I mentioned. Here are a few links:
http://www.stanford.edu/class/cs140/pro ... extcur.htm
http://www.stanford.edu/class/cs140/pro ... reg.htm#0E

I'm changing index 0x0A, that corresponds to the "Cursor Start Register". As you can see in the second link, it defines the top-most scanline of the cursor. Fifth bit of that register allows to disable the cursor.

But I will indeed use the way explained in your post, if it's not possible to disable the blink of the hardware cursor.

Thank you again! :-)

--mghis

Re: Disable VGA Text-mode Cursor Blinking

Posted: Mon Apr 22, 2013 9:02 am
by Combuster
mghis wrote:if it's not possible to disable the blink of the hardware cursor.
You can only hide the hardware cursor. Blinking is fixed according to the documentation:
FreeVGA wrote:On the standard VGA, the blink rate is dependent on the vertical frame rate. The on/off state of the cursor changes every 16 vertical frames, which amounts to 1.875 blinks per second at 60 vertical frames per second. The cursor blink rate is thus fixed and cannot be software controlled on the standard VGA.

Re: Disable VGA Text-mode Cursor Blinking

Posted: Tue Apr 23, 2013 6:44 am
by mghis
Well, then I'll disable it and I'll follow Brendan's advice.

Thank you both!