guest@ssc-vax.UUCP (Temporary Guest Account) (11/02/90)
In article <69408@lll-winken.LLNL.GOV>, mking@lll-crg.llnl.gov (Marianne King) writes: > When I go to reset the palette using _remapallpalette it doesn't seem > to work. I have tried calling Microsoft, but they haven't been able to > help. Has anybody had success using _remapallpalette? If so, could > you please give me some pointers on getting _remapallpalette to work? I've had problems with _remapallpalette() also. Setting the colors one at a time with _remappalette works but can get kind of slow. Below I've included a posting from about a year ago which contains code to set the palette that works great. > I don't normally read this newsgroup. So please send your replies to me > by e-mail or give me a call. Bummer. I don't normally respond to people who are too busy to look for a reply but thought that this info might be of use to the regular readers of this group. > Marianne King > Lawrence Livermore National Laboratory > mking@lll-crg.llnl.gov > (415) 423-4116 Stephen Coy uw-beaver!ssc-vax!coy From uw-beaver!rice!cs.utexas.edu!uunet!mcsun!sunic!dkuug!freja!lurifax Wed Nov 15 04:45:15 1989 Path: ssc-vax!uw-beaver!rice!cs.utexas.edu!uunet!mcsun!sunic!dkuug!freja!lurifax From: lurifax@freja.diku.dk (Michael Brian Moustgaard) Newsgroups: comp.graphics Subject: Re: VGA 360x480x256 mode usage code examples Message-ID: <4973@freja.diku.dk> Date: 15 Nov 89 12:45:15 GMT References: <23502@cup.portal.com> Organization: DIKU, U of Copenhagen, DK Lines: 191 ------------ cut here ------------ /* This is a revised version of vgapals.c for those * who don't like assembler, or doesn't have an assembler. * * It has compiled with TC 2.0, it would probably * too with MSC 5.1 * * I have changed the program just a little. * * * Greetings, Michael B. Moustgaard * * */ /* vgapals.c * * (c) 1989 Michael K. Finegan, Jr. * * Simplistic, and inefficient, way to display * unsigned char image on 320x200 vga display, * but illustrates use of LoadPals() with display * of centered 200 x 256 image - a grey scale ramp. * */ #include <stdio.h> #include <dos.h> #define FALSE 0 #define TRUE 1 /* used by LoadPals */ unsigned char NewLut[800], OldLut[800]; main() { int i, x, y; void LoadPals(); void WaitKey(); void setvmode(), writepix(); /* Load palette with reduced (64 level) gray scale (R = G = B). * * Only the 6 least signifigant bits of R,G,B bytes are * used for the output Look Up Table. * * NOTE: you could load your LUT (256*3 bytes), maybe * previously saved to file, into NewLut, instead ... */ for(i=0;i<256;i++) { NewLut[3*i + 0] = (unsigned char)(i/4); /* R */ NewLut[3*i + 1] = (unsigned char)(i/4); /* G */ NewLut[3*i + 2] = (unsigned char)(i/4); /* B */ } setvmode(0x13); /* 0x13 <==> 256 color 320 by 200 VGA */ LoadPals(1); /* * draw a grey scale 'ramp' * * "x + 32" shifts 256 column image to center of screen. */ for(y=0;y<200;y++) { for(x=0;x<256;x++) writepix(x + 32,y,(unsigned char)x); } WaitKey(); /* i.e. wait for keystroke before quitting ... */ LoadPals(0); setvmode(0x3); /* 0x3 <==> text; should restore previous mode ... */ } void setvmode(mode) int mode; { union REGS inregs, outregs; inregs.h.ah = 0; inregs.h.al = mode; int86(0x10,&inregs,&outregs); } void writepix(x,y,value) int x, y; unsigned char value; { union REGS inregs, outregs; /* simple video bios call, could write directly to memory ... * * image processing coordinate system - 0,0 @ upper left corner */ inregs.h.al = value; inregs.h.ah = 0x0C; /* write dot */ inregs.h.bh = 0; /* assume page 0 */ inregs.x.cx = (unsigned)x; inregs.x.dx = (unsigned)y; int86(0x10,&inregs,&outregs); } /* ; ; LoadPals Load VGA 256 color palette ; ; Call LoadPals(AX) ; Where AX : ; 3 ==> Just Load pals ; 1 ==> Save current pals, then Load new pals ; 2 ==> Just Restore pals ; 0 ==> Save current pals, then Restore old pals ; Assume: ; NewLut filled with new LUT; OldLut holds saved LUT, ; depending on calling sequence. ; ; LoadPals(1) followed by LoadPals(2) leaves palette unchanged ... ; */ void LoadPals(ax) int ax; { union REGS inregs, outregs; struct SREGS sreg; if (ax & 1 == 1) { if (ax==1) { /* save old */ inregs.h.ah = 0x10; /* set palette reg.s/intensity/blink function */ inregs.h.al = 0x17; /* read a block of DAC color registers */ inregs.x.bx = 0; /* start with register 0 */ inregs.x.cx = 0x100; /* and read all 256 */ segread(&sreg); sreg.es = sreg.ds; inregs.x.dx = (unsigned)&OldLut; int86x(0x10,&inregs,&outregs,&sreg); } /* load new */ inregs.h.ah = 0x10; /* set palette reg.s/intensity/blink function */ inregs.h.al = 0x12; /* update a block of DAC color registers */ inregs.x.bx = 0; /* start with register 0 */ inregs.x.cx = 0x100; /* and change all 256 */ segread(&sreg); sreg.es = sreg.ds; inregs.x.dx = (unsigned)&NewLut; int86x(0x10,&inregs,&outregs,&sreg); } else { /* save new */ if (ax==0) { inregs.h.ah = 0x10; /* set palette reg.s/intensity/blink function */ inregs.h.al = 0x17; /* read a block of DAC color registers */ inregs.x.bx = 0; /* start with register 0 */ inregs.x.cx = 0x100; /* and read all 256 */ segread(&sreg); sreg.es = sreg.ds; inregs.x.dx = (unsigned)&NewLut; int86x(0x10,&inregs,&outregs,&sreg); } /* restore old */ inregs.h.ah = 0x10; /* set palette reg.s/intensity/blink function */ inregs.h.al = 0x12; /* update a block of DAC color registers */ inregs.x.bx = 0; /* start with register 0 */ inregs.x.cx = 0x100; /* and change all 256 */ segread(&sreg); sreg.es = sreg.ds; inregs.x.dx = (unsigned)&OldLut; int86x(0x10,&inregs,&outregs,&sreg); } } /* ; WaitKey read a char from keyboard, with no Cntrl-Brk ; check, no echo, and the <scan code,char> . */ void WaitKey() { union REGS inregs, outregs; inregs.h.ah = 0; int86(0x16,&inregs,&outregs); } ------------------- cut here too -------------