Thread: reading the palette

  1. #1
    Registered User
    Join Date
    Apr 2002
    Posts
    129

    reading the palette

    How can I read the values of each palette entry? I suppose I could set it myself and store the values in an array so I can look them up, but it would suck because I might wanna use the default palette.
    flashdaddee.com rocks!!!

  2. #2
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    You can only use one palette at a time...
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  3. #3
    Registered User
    Join Date
    Apr 2002
    Posts
    129
    no, I meant like make an array, and make my own set_palette() function so every time it put a palette entry into the vga whatever stuff, it also put it into my custom array so I would know exactly what is where, but that would suck because I usually like using the standard palette entries.
    flashdaddee.com rocks!!!

  4. #4
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    On my site I have a DOS program handling my own palettes. It's called Spriter. You could check that out, the source is included.

    Basically, to set a new palette you do this:
    Code:
    //Palette structure, contains the RGB data for the palette
    typedef struct
    {
       unsigned char Data[256*3];
    } PALETTE;
    
    
    //Sets RGB colors of a palette. Use this in a 256 iterations loop to build your own palette.
    void SetPart(int Nr, unsigned char R, unsigned char G, unsigned char B)
    {
       Palette.Data[(Nr*3)]=R;
       Palette.Data[(Nr*3)+1]=G;
       Palette.Data[(Nr*3)+2]=B;
    }
    
    
    //Sets a new palette. Call this when you want to switch to your palette. It must be done when in mode 13, not else.
    outp(0x03c8, 0);
    for(int i=0; i<256*3; i++)
    {
       outp(0x03c9, Palette.Data[i]);
    }
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  5. #5
    Registered User
    Join Date
    Apr 2002
    Posts
    129
    No, I can do that just fine, I want to read the palette. I want to get the rgb values of an entry, not set it to a certain value.
    flashdaddee.com rocks!!!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 03-05-2009, 03:14 AM
  2. Replies: 7
    Last Post: 02-02-2009, 07:27 AM
  3. Replies: 2
    Last Post: 01-28-2008, 03:07 AM
  4. help with reading from stream
    By movl0x1 in forum C Programming
    Replies: 7
    Last Post: 05-31-2007, 10:36 PM
  5. problems reading data into an array and printing output
    By serino78 in forum C Programming
    Replies: 4
    Last Post: 04-28-2003, 08:39 AM