Jump to content
  • Advertisement
Sign in to follow this  
wendigo23

VGA palette colors

This topic is 5416 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm writing a simple harness to let me easily convert all my old DOS mode 13h apps into windows apps. Ok, easy enough. But I need to set the palette! I just need the first 16 colors of the standard vga palette. For some reason this is hard for me to find on the web. I found some references, but they're wrong. I can tell because my graphics come out the wrong color.

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Well, according to the VGA standard for IBM-compatible computers, you write the index of the color entry you are trying to read into the I/0 port at 3c7h. Otherwise, if you're trying to change a palette entry, you write the index of that color entry into port 3c8h.

Next, 3 consecutive reads/writes (depending on what you want to do) at I/O port 3c9h will increment the palette entry selector automatically.

Hope this helps.

Share this post


Link to post
Share on other sites
Also note that the palette is not always laid out consecutively for CGA and EGA modes, something I had to discover through trial and error.
In 16-color EGA modes the first eight colors are placed at hardware entries 0-7 while you'll find the next eight at 8-15.
So make sure you rip from mode 13h and not from text mode.

Share this post


Link to post
Share on other sites
Thanks for the replies.. maybe I wasn't clear, I was looking for the actual default palette colors, not how to set the palette. It turns out I did find the right numbers on the web, I just didn't realize that the struct I pass to windows to set the palette uses BGR instead of RGB...

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!