Colours

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
Whatever5k

Colours

Post by Whatever5k »

I want to print a text on the screen with a different colour than white text on black screen...
For example, red would be nice :)
I know that 0x07 is for white-on-black, but where do I find the bytes for other colours?
Nils

Re:Colours

Post by Nils »

:D

--->

| cli | back | i | foreground |

cli : ?(clignotement)
back: background color
i : ?(intensit?)
fore: foreground color

Colors:

   000 black
   001 blue
   010 green
   011 cyan
   100 red
   101 magenta
   110 yellow
   111 white

Example:
   0x07 = 0 000 0 111
| |
black |
white

Red on black
    0x04 = 0 000 0 100
Slasher

Re:Colours

Post by Slasher »

Hi, the colors are all encoded in the attribute byte!
B F F F I T T T thats what it looks like.
B bit = 1 will make character blink
F F F = defines the background color
I bit = is the intensisty bit, 1 will make the character bright
T T T = defines the TEXT color.
so as numbers
128 (10000000) is for blink on
0 (00000000) is the 1st background color (black)
16 (00010000) is the 2nd background color(blue)
32 (00100000) is the 3rd backgroung color

and so on they are 8 background colors(0 to 7*16) and 16 text (colors 0 to 15)
0 being Black and 15 being White
so to get what you want, after defining constants for each background color and text color and the blink bit
if you want a blinking white character on a blue background you will have to OR the constants together to get the desired attribute byte
ie
in C code will be
attribute=BLINK |TEXT_WHITE |BACK_BLUE;
in asm
mov ax,BLINK
or ax,TEXT_WHITE
or ax,BACK_BLUE
hope this helps! ;)
Whatever5k

Re:Colours

Post by Whatever5k »

Thanks
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Colours

Post by Pype.Clicker »

there's something you can configure in VGA cards to use the "blinking" bit as a "background intensity" bit... but i'm not sure of where it resides in the VGA controllers :(
Post Reply