delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/09/02/02:49:42

From: SerDevian <scriven AT CS DOT ColoState DOT edu>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: software interrupts
Date: Fri, 29 Aug 1997 10:28:39 -0600
Organization: XYZZ Software Co.
Lines: 58
Message-ID: <3406F8B6.2781@CS.ColoState.edu>
References: <Pine DOT GSO DOT 3 DOT 95 DOT 970829010635 DOT 4265B-100000 AT dilbert DOT ucdavis DOT edu>
NNTP-Posting-Host: dali.vis.colostate.edu
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Mike Darrett wrote:
>         I'm sure there is a very simple solution to this problem, but I've
> been working on this for the last three days and it has me stumped. I had
> a PCX decoding routine I was porting from Turbo C++ to DJGPP, and I found
> the source of the bug was in the Palette Updating routine. In a nutshell,
> it goes like this, but the colors are the WRONG ONES. I know it has
> something to do with the way I'm issuing a software interrupt from
> the 32-bit code, but I tried everything, from __dpmi_int() to int86() for
> the int 10 function (this function takes a pointer in ES:DX pointing to
> palette data and updates the video palette). The FAQ's DJ wrote said just
> use int86() and forget about ES, ...

I'd suggest using a different method to set the palette.  It's pretty
easy to do directly (without needing an interrupt).

Try this:

void SetPalette(point *palette)
{
  int i;

  outportb(0x03C8, 0);	// Which color to start on (0-255)

  for(i=0; i<256; i++)
  {
    outportb(0x03C9, palette[i]->r);	// Send color triplets
    outportb(0x03C9, palette[i]->g);
    outportb(0x03C9, palette[i]->b);
  }
}

> typedef struct{
>   byte r, g, b;
> } point;
> 
> point palette[256];
> 
> void SetPalette(void)
> {
>   union REGS r;
>   int i;
> 
>   r.x.dx = r.x.di = (unsigned long)palette;
>   r.x.ax = 0x1012;
>   r.x.bx = 0;
>   r.x.cx = 256;
>   int86( 0x10, &r, &r );
> }

However, if you want to use the interrupt method, you need to first copy
the palette to DOS memory (under 1MB).  More info is in the FAQ.


 _  _ _  _ ___ ___  -----------"Use the source, Luke!"---------
( \/ ( \/ (__ (__ ) | ~  Scott Scriven (SerDevian / XYZZ)     |
 \  / \  /  //  //  | mailto:scriven AT CS DOT ColoState DOT edu         |
 /  \ / /  //_ //_  | mailto:scriven AT VIS DOT ColoState DOT edu        |
(_/\_(_/  (___(___) | http://www.vis.colostate.edu/~scriven/  |

- Raw text -


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