TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Rob Basler
from: Peter Fitzsimmons
date: 1995-01-04 15:32:26
subject: Can`t set VIO palette

RB> the palette in an OS/2 full screen session in mode 13 (320x200x256) and
 RB> every time I make the VioSetState call, I get the return

There is an error in one of the os2 *.h files.  I just checked and the
error is STILL on the warp toolkit.  Here's a sample (note that the Borland
compiler did not produce functioning code for this no matter what I did, 
and since it can't debug full screen apps I didn't try any harder):

 // before this function will work with a 32 bit compiler,  you must
 // fix bsesub.h:
 #if 0
    typedef struct _VIOCOLORREG    /* viocreg */
    {
       USHORT  cb;
       USHORT  type;
       USHORT  firstcolorreg;
       USHORT  numcolorregs;
       //PCH     colorregaddr;
       PUCHAR16     colorregaddr;    /*PLF Sun  94-02-13 16:01:29*/
    } VIOCOLORREG;
    typedef VIOCOLORREG *PVIOCOLORREG;
 #endif

 static void rotate(void)       // rotate pallette.
 {
     USHORT rc;
     int i;
     static VIOCOLORREG vcr;
     static int init = FALSE;
     static BYTE pal[768];

     if(!init){
         vcr.cb   = sizeof(vcr);
         vcr.type = 3;
         vcr.firstcolorreg = 0;
         vcr.numcolorregs  = 256;
         vcr.colorregaddr  = pal;
         rc = VioGetState(&vcr, 0);
         if(rc){
             printf( "SYS%04u: Error getting palette registers.\n", rc);
             exit(1);
         }
         init = TRUE;
     }
     for(i=0; i<255; i++){
         pal[(i * 3) + 0] = pal[(1+i)*3 + 0];
         pal[(i * 3) + 1] = pal[(1+i)*3 + 1];
         pal[(i * 3) + 2] = pal[(1+i)*3 + 2];
     }
     pal[255 * 3 + 0] = pal[0];
     pal[255 * 3 + 1] = pal[1];
     pal[255 * 3 + 2] = pal[2];
     rc = VioSetState(&vcr, 0);
     if(rc){
         printf( "SYS%04u: Error setting palette registers.\n", rc);
         exit(1);
     }
 }

--- Maximus/2 2.01
* Origin: Sol 3/Toronto (905)858-8488 (1:259/414)
SEEN-BY: 12/2442 620/243 624/50 632/348 640/820 690/660 711/409 410 413 430
SEEN-BY: 711/807 808 809 934 942 949 712/353 515 713/888 800/1 7877/2809
@PATH: 259/414 400 99 250/99 3615/50 229/2 12/2442 711/409 808 809 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.