We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

256 Color in 'char Image[]' array

tppramod
tppramod asked
on
Medium Priority
972 Views
Last Modified: 2013-12-26
i have a sprite (4 x 4 pixels) defined in a char array "char Image[]" as given below for example, having colors Red (Value 12) and Yellow (Value 14).  I am writing directly to VGA memory in Mode 13h which can support upto 256 colors.  I know the colors having values from 1 to 16 which can be used in this array.  The question is if i want to choose any other color (other than 16 colours) from the range of 256 colors, then what value should i give it in the array so that i can get that displayed on the screen.  any lookup table? or something. pls. note that all of my sprites are defined using char arrays.  I am using Turbo C 3.0 DOS complier.

char Image[] =
{
  12,12,12,12,
  12,12,12,12,
 14,14,,14,14,
 14,14,,14,14,
};

T. P. Pramod Kumar
New Delhi
INDIA
Comment
Watch Question

Well,
There are actually 18 bit DAC registers, the values in the registers is set and mapped to the basic 16 registers. It is all done by the interrupts. So you can not simply show the color by giving its number.

One suggestion is that you better get rid of this kind of color programming in DOS and use some advance tools for graphics adventures..

Further questions?
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview
SetPaletteEntries should be

void SetPaletteEntries( Byte start, unsigned short count, Color far *pPalette )
{
     asm {
          mov ax, word ptr pPalette[ 2 ]
          mov es, ax
          mov dx, word ptr pPalette
          mov cx, count
          mov bl, start
          xor bh, bh
          mov ax, 01012h
          int 010h
     }
}

just in case 255 colors aren't enough.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.