Blinking Text

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
shikhin
Member
Member
Posts: 274
Joined: Sat Oct 09, 2010 3:35 am
Libera.chat IRC: shikhin
Contact:

Blinking Text

Post 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.
Attachments
Monitor.c
(3.75 KiB) Downloaded 229 times
http://shikhin.in/

Current status: Gandr.
User avatar
Creature
Member
Member
Posts: 548
Joined: Sat Dec 27, 2008 2:34 pm
Location: Belgium

Re: Blinking Text

Post 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).
When the chance of succeeding is 99%, there is still a 50% chance of that success happening.
shikhin
Member
Member
Posts: 274
Joined: Sat Oct 09, 2010 3:35 am
Libera.chat IRC: shikhin
Contact:

Re: Blinking Text

Post 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).
http://shikhin.in/

Current status: Gandr.
User avatar
Owen
Member
Member
Posts: 1700
Joined: Fri Jun 13, 2008 3:21 pm
Location: Cambridge, United Kingdom
Contact:

Re: Blinking Text

Post 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)
User avatar
Coty
Member
Member
Posts: 286
Joined: Thu Feb 12, 2009 5:12 pm

Re: Blinking Text

Post 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  
My hero, is Mel.
User avatar
IanSeyler
Member
Member
Posts: 326
Joined: Mon Jul 28, 2008 9:46 am
Location: Ontario, Canada
Contact:

Re: Blinking Text

Post by IanSeyler »

Exactly! The code above tweaks the VGA registers to disable blinking.
BareMetal OS - http://www.returninfinity.com/
Mono-tasking 64-bit OS for x86-64 based computers, written entirely in Assembly
jal
Member
Member
Posts: 1385
Joined: Wed Oct 31, 2007 9:09 am

Re: Blinking Text

Post 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
Gaidheal
Member
Member
Posts: 51
Joined: Mon Oct 04, 2010 6:23 pm

Re: Blinking Text

Post 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! ;¬)
jal
Member
Member
Posts: 1385
Joined: Wed Oct 31, 2007 9:09 am

Re: Blinking Text

Post 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
User avatar
StrangeBrew
Posts: 7
Joined: Tue Feb 01, 2011 6:37 pm

Re: Blinking Text

Post 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...
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Re: Blinking Text

Post 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.
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: Blinking Text

Post 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
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
StrangeBrew
Posts: 7
Joined: Tue Feb 01, 2011 6:37 pm

Re: Blinking Text

Post 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:
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Re: Blinking Text

Post 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.
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Blinking Text

Post 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.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Post Reply