Page 1 of 1

Blinking Text

Posted: Thu Oct 14, 2010 9:06 am
by shikhin
Hi,
I am again posting a problem I am having. Maybe you all maybe thinking how many questions would I post, but I think maybe their are some hurdles, so I am asking for a solution again from you. So the problem is that I am making a kernel booting from GRUB. Now the kernel is booting up properly, is displaying the text which it shall, with all the correct attributes, except that the text is blinking. Now I dont think the text should blink.


I searched everywhere for the solution but cant find any. Hope you can help.

P.S. Source code is attached.

Re: Blinking Text

Posted: Thu Oct 14, 2010 9:08 am
by Creature
IIRC, text tends to blink if you use invalid foreground colors on background colors (or the other way around). Some combinations just can't be done and will result in 'blinking'. I believe there is also a VGA register somewhere that controls blinking (but I don't know if it is related to your problem).

Re: Blinking Text

Posted: Thu Oct 14, 2010 9:11 am
by shikhin
I dont know whether I am using invalid colors. I am using a background of 9 (Light blue) with a text color of 15 (White).

Re: Blinking Text

Posted: Thu Oct 14, 2010 9:30 am
by Owen
The bit which would be used to control "lightness" of background colours is instead used to control whether they blink or not.

(I believe there may be a VGA register setting which controls this, however)

Re: Blinking Text

Posted: Thu Oct 14, 2010 9:54 am
by Coty
Bit 7 is the "Blinking bit" if the 7th bit == 1 then it will blink. (Remember the 7th bit is the one farthest to the left.)

[1]111 0001 == 0xF1 == Blue on white, since bit 7 = 1, then it will blink. There is a way to disable this.

I believe Baremetal OS does it like this.

Code: Select all

        ; Disable blink
        mov dx, 0x3DA
        in al, dx
        mov dx, 0x3C0
        mov al, 0x30
        out dx, al
        inc dx
        in al, dx
        and al, 0xF7
        dec dx
        out dx, al  

Re: Blinking Text

Posted: Thu Oct 14, 2010 11:40 am
by IanSeyler
Exactly! The code above tweaks the VGA registers to disable blinking.

Re: Blinking Text

Posted: Fri Oct 15, 2010 5:21 am
by jal
Heh, I'm suddenly feeling very old for thinking "what the ****? don't they know how to properly program a VGA card?", and even older for knowing that on CGA, it's a different bit :)


JAL

Re: Blinking Text

Posted: Fri Oct 15, 2010 6:25 am
by Gaidheal
Hehe! Not just you, jal!

This has already been well answered but I must admit, I read the first few words and went "Oh, I know this one." LOL

Welcome to vagaries of the old video modes! ;¬)

Re: Blinking Text

Posted: Fri Oct 15, 2010 7:34 am
by jal
Gaidheal wrote:Welcome to vagaries of the old video modes! ;¬)
Indeed. Anyone remembers 160x100x16 colour semi-graphical textmode on CGA? Round 42 ftw!

Image


JAL

Re: Blinking Text

Posted: Tue Feb 01, 2011 7:09 pm
by StrangeBrew
Coty wrote:Bit 7 is the "Blinking bit" if the 7th bit == 1 then it will blink. (Remember the 7th bit is the one farthest to the left.)

[1]111 0001 == 0xF1 == Blue on white, since bit 7 = 1, then it will blink. There is a way to disable this.

I believe Baremetal OS does it like this.

Code: Select all

        ; Disable blink
        mov dx, 0x3DA
        in al, dx
        mov dx, 0x3C0
        mov al, 0x30
        out dx, al
        inc dx
        in al, dx
        and al, 0xF7
        dec dx
        out dx, al  
I apologize for bumping an old thread but how come the attribute index is at 0x30 and not 0x10 as FreeVGA, among other docs, states? This is a horrible bug to track down. I guess I'm asking where I can get a reliable updated specification from if I need to, or if this is just because of my Nvidia video card...

Re: Blinking Text

Posted: Tue Feb 01, 2011 9:14 pm
by neon
Hm, the book I have refers to index 0x10 as the Mode Control Register, where bit 3 enables or disables blinking. The code doesnt look right although havnt tried it. Perhaps someone can explain the provided code?

*edit: Oh, woops, 0x30 selects attribute index 0x10 with PAS bit set in the Attribute Address Register.

Re: Blinking Text

Posted: Wed Feb 02, 2011 6:41 am
by Brendan
Hi,
neon wrote:Hm, the book I have refers to index 0x10 as the Mode Control Register, where bit 3 enables or disables blinking. The code doesnt look right although havnt tried it. Perhaps someone can explain the provided code?
The correct way it to use the int 10, ax = 0x1003" BIOS function instead; so that you don't need to rely on (potentially incorrect) assumptions about the video hardware (including the potentially incorrect assumption that the video card tried to be "VGA compatible" and actually succeeded).


Cheers,

Brendan

Re: Blinking Text

Posted: Wed Feb 02, 2011 8:17 am
by StrangeBrew
I'm confused, so what's the meaning of 0x10 if one must use 0x30 to get to it?

http://www.osdever.net/FreeVGA/vga/attrreg.htm
makes no mention of 0x30.

Edit: also...
http://www.mcamafia.de/pdf/ibm_vgaxga_trm2.pdf
PDF page 98
The following is the sequence for accessing the attribute data
registers:
1. Disable interrupts.
2. Reset the flip-flop for the Attribute Address register.
3. Write the index.
4. Access the data register.
5. Enable interrupts.
... and the index should be 0x10 and not 0x30, right?

Sorry if I seem pedantic but I need to know what I'm doing, and that I can trust the docs. :mrgreen:

Re: Blinking Text

Posted: Wed Feb 02, 2011 8:58 am
by neon
Hello,
StrangeBrew wrote:I'm confused, so what's the meaning of 0x10 if one must use 0x30 to get to it?
There is none - its the same index register (0x10.) The address register that you write the index into follows the format:

Code: Select all

[PAS][ Index Register ]
Bit 5      Bits 0-4
Using 0x10 (10000 binary) stores 0x10 as the index, with bit 5 cleared. 0x30 (110000 binary) does the same, but notice it just sets Bit 5 as well.

FreeVGA might have information on bit 5.. if it doesnt Ill post it here later.

Re: Blinking Text

Posted: Wed Feb 02, 2011 11:59 am
by Combuster
This bit [bit 5] is set to 0 to load color values to the registers in the internal palette. It is set to 1 for normal operation of the attribute controller
Writing 0x10 works as expected, only you disable the hardware's palette access in the process which has the (unfortunate) side-effect of disabling the video output. You can write all registers as documented, and if you finish the sequence with writing 0x20 to port 0x3C0, the net effect is the same. It is also exactly how my VGA driver code operates.