Mail Archives: djgpp/1997/08/29/21:21:04
At 01:11 8/29/1997 -0700, Mike Darrett wrote:
>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, ...
But only for certain INT 21h functions. You have to put your palette into
conventional memory in order to get a real-mode pointer to it.
(Incidentally, DJ didn't write the FAQ's all by himself. Eli Zaretskii is
the maintainer, and there's a long list of contributors, of whom DJ is one.)
>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 );
>}
Try this instead. It uses the transfer buffer for simplicity.
#include <go32.h>
#include <dpmi.h>
#include <sys/movedata.h>
void SetPalette(void)
{
__dpmi_regs r;
dosmemput(palette,sizeof(palette),__tb); /* __tb is the transfer buffer */
/* I assume the transfer buffer is big enough; it's normally 4K */
r.x.es = __tb >> 4; /* the segment part */
r.x.dx = r.x.di = __tb & ~0x0f; /* the offset part */
r.x.ax = 0x1012
r.x.bx = 0;
r.x.cx = 256;
__dpmi_int(0x10,&r);
}
I haven't tested this but I suspect it'll work.
Also: You might check to see whether the compiler is keeping your `palette'
array packed appropriately. Sometimes it pads it, which I think is not the
right thing here. If sizeof(point) == 3, you should be fine.
Nate Eldredge
eldredge AT ap DOT net
- Raw text -