On Sat, 03 Mar 2001, Andris Pavenis wrote: [...]
Plain GRX (without BGI functions) mostly works under X11 with 32bpp (I'm have i810 and when I set color depth to 24, I'm getting 32bpp in GRX)
Now about BGI:
- 1st problem is that getmaxcol() should return value that doesn't
fit in int. As result I'm getting call to random(0) with following crash. Setting it to something different from 0 from debugger avoid crash. Maybe we should introduce some typedef like typedef unsigned long long maxcolor_t; in libbcc.h for this purpose
in BGI all colors are integer, we canŽt change this. Look at getmaxcol():
int getmaxcolor(void) { return GrNumColors()-1; }
GrnumColors returns ŽncolorsŽ set up in src/setup/colors.c (note the GrNOCOLOR inits for GrBlack&GrWhite):
void GrResetColors(void) { .... CLRINFO->ncolors = 1L << DRVINFO->actmode.bpp; CLRINFO->black = GrNOCOLOR; CLRINFO->white = GrNOCOLOR; setbits( DRVINFO->actmode.extinfo->cprec, DRVINFO->actmode.extinfo->cpos ); .... }
ncolors should be calculated using the cprec/cpos info so it correctly reports 1<<24 even in 32bpp mode and fails if more than 24bpp required. See below for a patch.
- The next problem is that GrColorInfo->black and GrColorInfo->white are
both equal to 0x01000000. After setting from debugger GrColorInfo->black to 0 I was finally able to get at least something displayed on the screen. But it seems that we still have much to do.
Both have BrNOCOLOR, see GrResetColors() above. You just checked it a little early: /* grx20.h*/ #define GrBlack() ((GrColorInfo->black==GrNOCOLOR)?(GrBlack)():GrColorInfo->black)
/* src/setup/colorbw.c */ GrColor GrBlack(void) { GRX_ENTER(); if(CLRINFO->black == GrNOCOLOR) CLRINFO->black = GrAllocColor(0,0,0); GRX_RETURN(CLRINFO->black); }
The correct value will be set on first call, same for GrWhite().
If any graphics system uses the GrCMODEMASK bits in 32bpp mode GRX will apply the wrong drawing mode, will change colors, ... The GR_frameXWIN32H driver is a candidates to fail. The RAM driver GR_frameRAM32H seems to work around this by shifting the color by 8.
Hope this helps, Hartmut
diff --recursive -c grx234-u1/src/include/libgrx.h grx234/src/include/libgrx.h *** grx234-u1/src/include/libgrx.h Sun Jan 21 02:31:48 2001 --- grx234/src/include/libgrx.h Sun Mar 4 15:47:09 2001 *************** *** 279,284 **** --- 279,285 ---- */ extern int _GR_firstFreeColor; /* can't access all colors on all systems */ extern int _GR_lastFreeColor; /* eg. X11 and other windowing systems */ + int _GrResetColors(void); /* like GrResetColors but return true on success */
#ifdef __TURBOC__ # define C_OPER(color) (unsigned int)(((unsigned char *)(&(color)))[3]) diff --recursive -c grx234-u1/src/setup/colors.c grx234/src/setup/colors.c *** grx234-u1/src/setup/colors.c Tue Jan 16 23:36:22 2001 --- grx234/src/setup/colors.c Sun Mar 4 15:47:09 2001 *************** *** 69,75 **** #else #define _GR_firstFreeColor 0 #endif ! void GrResetColors(void) { # define NSAVED 16 static char infosave[offsetof(struct _GR_colorInfo,ctable[NSAVED])]; --- 69,76 ---- #else #define _GR_firstFreeColor 0 #endif ! ! int _GrResetColors(void) { # define NSAVED 16 static char infosave[offsetof(struct _GR_colorInfo,ctable[NSAVED])]; *************** *** 82,93 **** sttzero(CLRINFO); if(DRVINFO->actmode.extinfo->mode == GR_frameText) { memcpy(CLRINFO,infosave,sizeof(infosave)); ! return; } DACload = DRVINFO->actmode.extinfo->loadcolor; - CLRINFO->ncolors = 1L << DRVINFO->actmode.bpp; CLRINFO->black = GrNOCOLOR; CLRINFO->white = GrNOCOLOR; setbits( DRVINFO->actmode.extinfo->cprec, DRVINFO->actmode.extinfo->cpos --- 83,107 ---- sttzero(CLRINFO); if(DRVINFO->actmode.extinfo->mode == GR_frameText) { memcpy(CLRINFO,infosave,sizeof(infosave)); ! return TRUE; } DACload = DRVINFO->actmode.extinfo->loadcolor; CLRINFO->black = GrNOCOLOR; CLRINFO->white = GrNOCOLOR; + CLRINFO->ncolors = 1L << DRVINFO->actmode.bpp; + if ( (CLRINFO->ncolors&GrCVALUEMASK) != CLRINFO->ncolors ) { + /* can happen on 32bpp systems. Now try to calculate + the minimum number of colors from cprec & cpos info */ + int i, cbpp, c; + cbpp = 0; + for (i=0; i < 3; ++i) { + c = DRVINFO->actmode.extinfo->cprec[i] + + DRVINFO->actmode.extinfo->cpos[i]; + if ( c > cbpp ) + cbpp = c; + } + CLRINFO->ncolors = 1L << cbpp; + } setbits( DRVINFO->actmode.extinfo->cprec, DRVINFO->actmode.extinfo->cpos *************** *** 115,121 **** --- 129,143 ---- CLRINFO->RGBmode = TRUE; break; } + return (CLRINFO->ncolors&GrCVALUEMASK) == CLRINFO->ncolors; + } + + + void GrResetColors(void) + { + _GrResetColors(); } +
void GrSetRGBcolorMode(void) { diff --recursive -c grx234-u1/src/setup/setmode.c grx234/src/setup/setmode.c *** grx234-u1/src/setup/setmode.c Tue Feb 27 00:03:06 2001 --- grx234/src/setup/setmode.c Sun Mar 4 15:47:09 2001 *************** *** 418,424 **** DRVINFO->vposx = 0; DRVINFO->vposy = 0; DBGPRINTF(DBG_SETMD,("GrResetColors ...\n")); ! GrResetColors(); DBGPRINTF(DBG_SETMD,("GrResetColors done\n")); if(fdr.init) { DBGPRINTF(DBG_SETMD,("fdr.init ...\n")); --- 418,427 ---- DRVINFO->vposx = 0; DRVINFO->vposy = 0; DBGPRINTF(DBG_SETMD,("GrResetColors ...\n")); ! if ( !_GrResetColors() ) { ! res = errhdlr("could not set color mode"); ! goto done; ! } DBGPRINTF(DBG_SETMD,("GrResetColors done\n")); if(fdr.init) { DBGPRINTF(DBG_SETMD,("fdr.init ...\n")); diff --recursive -c grx234-u1/src/vdrivers/vd_xwin.c grx234/src/vdrivers/vd_xwin.c *** grx234-u1/src/vdrivers/vd_xwin.c Fri Jan 19 23:13:58 2001 --- grx234/src/vdrivers/vd_xwin.c Sun Mar 4 15:47:09 2001 *************** *** 413,419 **** case 16: grxwinext.mode = GR_frameXWIN16; break; case 24: switch (bpp) { ! case 24: grxwinext.mode = GR_frameXWIN24; break; case 32: grxwinext.mode = (visual->red_mask & 0xff000000) ? GR_frameXWIN32H : GR_frameXWIN32L; break; } --- 413,419 ---- case 16: grxwinext.mode = GR_frameXWIN16; break; case 24: switch (bpp) { ! case 24: grxwinext.mode = GR_frameXWIN24; break; case 32: grxwinext.mode = (visual->red_mask & 0xff000000) ? GR_frameXWIN32H : GR_frameXWIN32L; break; }