www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/11/29/21:02:43

From: "Steve Patton" <leaphe AT pemail DOT net>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Loading a palette from a datafile
Date: 28 Nov 1997 17:55:17 GMT
Organization: AT&T WorldNet Services
Lines: 38
Message-ID: <65n0i5$q6h@bgtnsc03.worldnet.att.net>
References: <19971128165900 DOT LAA28332 AT ladder01 DOT news DOT aol DOT com>
NNTP-Posting-Host: 12.67.2.170
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp


Funkdog32 <funkdog32 AT aol DOT com> wrote in article
<19971128165900 DOT LAA28332 AT ladder01 DOT news DOT aol DOT com>...
> I need help on how to get a palette from a datafile and make it the
palette
> used to draw in the program
> 

Are you referring to the Allegro Library?

If you are then when you use the load_datafile, it is automatically loaded
and you can reference it using the header              file created for
that datafile, and just use that index.
otherwise, it is really up to you.  I suggest reading from a file into an
array, then using that from then on.  (of course,                      you
should load it into the VGA regs by doing

struct PALETTE
 {
  char r;
  char g;
  char b;
} pal[256];

outportb ( 0x3C8, 0 );      // that will index the first color

for ( int a = 0 ; a < 256 ; a++ )
 {
  outportb (0x3C9, pal[a].r );
  outportb ( 0x3C9, pal[a].g );
  outportb ( 0x3C9, pal[a].b );
 }

of course I don't recommend doing that if you are using the Allegro
graphics routine, because it will give you false results when you "grab" a
palette.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019