Background colour codes

Programming, for all ages and all languages.
Post Reply
Stijn
Posts: 10
Joined: Tue Feb 07, 2012 6:55 pm

Background colour codes

Post by Stijn »

Hi,

I used the table at http://en.wikipedia.org/wiki/BIOS_color_attributes as a reference for text colour.
When I tried to use it for the background colour, I found out that there are some differences. So I made up an image, top row is text colour and bottom row is background colour.
Image

Is there a reference somewhere describing the background colours?

In case it matters, the code switches to mode 0x12 (VGA 640x480 with 16 colours).
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: Background colour codes

Post by Combuster »

There's a problem with that - there are 16 colours possible in that mode and your image lists more than 16 colours. Therefore your observations are not correct.

Please demonstrate how you got those results, maybe we can figure out what went wrong.
"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 ]
User avatar
brain
Member
Member
Posts: 234
Joined: Thu Nov 05, 2009 5:04 pm
Location: UK
Contact:

Re: Background colour codes

Post by brain »

Stijn wrote:Hi,

I used the table at http://en.wikipedia.org/wiki/BIOS_color_attributes as a reference for text colour.
When I tried to use it for the background colour, I found out that there are some differences. So I made up an image, top row is text colour and bottom row is background colour.
Image

Is there a reference somewhere describing the background colours?

In case it matters, the code switches to mode 0x12 (VGA 640x480 with 16 colours).
Arent these colour attributes for text modes only, as opposed to the 640x480 graphics mode you said you selected? ... that is unless you have your own code that maps the behaviour of a text mode screen onto a graphical interface in which case how the colours appear would be entirely up to you...
Stijn
Posts: 10
Joined: Tue Feb 07, 2012 6:55 pm

Re: Background colour codes

Post by Stijn »

I've commented my code and put it up at http://pastebin.com/uj1uKjLu
If you require more comments just let me know.

I got the results displayed in the colour chart by trying all colours one by one, taking screenshots and copying the colour.
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: Background colour codes

Post by Combuster »

Since I haven't been using bios interrupts in graphics modes much (mainly because they are epicly slow), I modified the code a bit to render all foreground colours to check the actual effect - which is that that BIOS call simply replaces colour zero with a new colour. Which means that you lose black for a different colour, in several cases a duplicate of one of the other fifteen colours.

It's an effective way of changing colours, but it's usually not what you want.

You can find your colours back in the EGA palette as 0-7 and 16-23.
"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 ]
Stijn
Posts: 10
Joined: Tue Feb 07, 2012 6:55 pm

Re: Background colour codes

Post by Stijn »

I've done the modification you said and can see the effect it has now.

Thanks for the explanation.
Post Reply