void gr_palette_step_up( int r, int g, int b ) { int i; ubyte *p; int temp; ColorSpec colors[256]; GDHandle old_device; // PaletteHandle palette; // RGBColor color; // CTabHandle ctab; if (gr_palette_faded_out) return; if ( (r==last_r) && (g==last_g) && (b==last_b) ) return; last_r = r; last_g = g; last_b = b; p=gr_palette; // palette = GetPalette(GameWindow); for (i=0; i<256; i++ ) { colors[i].value = i; // temp = (int)(*p++) + r + gr_palette_gamma; temp = (int)(*p++) + r; if (temp<0) temp=0; else if (temp>63) temp=63; colors[i].rgb.red = gr_mac_gamma[temp]; // temp = (int)(*p++) + g + gr_palette_gamma; temp = (int)(*p++) + g; if (temp<0) temp=0; else if (temp>63) temp=63; colors[i].rgb.green = gr_mac_gamma[temp]; // temp = (int)(*p++) + b + gr_palette_gamma; temp = (int)(*p++) + b; if (temp<0) temp=0; else if (temp>63) temp=63; colors[i].rgb.blue = gr_mac_gamma[temp]; // SetEntryColor(palette, i, &color); } old_device = GetGDevice(); SetGDevice(GameMonitor); SetEntries(0, 255, colors); SetGDevice(old_device); #if 0 ctab = (CTabHandle)NewHandle(sizeof(ColorTable)); Palette2CTab(palette, ctab); AnimatePalette(GameWindow, ctab, 0, 0, 256); ActivatePalette(GameWindow); DisposeHandle((Handle)ctab); if (GameGWorld != NULL) { ctab = (**GetGWorldPixMap(GameGWorld)).pmTable; // get the color table for the gWorld. CTabChanged(ctab); (**ctab).ctSeed = (**(**(*(CGrafPtr)GameWindow).portPixMap).pmTable).ctSeed; } #endif }
void ShiftClut(CTabHandle theClut,long rShift,long gShift,long bShift) { short count; for (count=0; count<=(**theClut).ctSize; count++) ShiftColour(&(**theClut).ctTable[count].rgb,rShift,gShift,bShift); // Tell QD the CLUT has changed CTabChanged(theClut); }
void ApplyOpacityClut(CTabHandle theClut,RGBColour *opacityOverlay,double opacity) { short count; for (count=0; count<=(**theClut).ctSize; count++) ApplyOpacityColour(&AccessColour(theClut,count),opacityOverlay,opacity); // Tell QD the CLUT has changed CTabChanged(theClut); }
void gr_palette_load( ubyte *pal ) { int i, j; GDHandle old_device; ColorSpec colors[256]; // PaletteHandle palette; // RGBColor color; // CTabHandle ctable; for (i=0; i<768; i++ ) { // gr_current_pal[i] = pal[i] + gr_palette_gamma; gr_current_pal[i] = pal[i]; if (gr_current_pal[i] > 63) gr_current_pal[i] = 63; } for (i = 0, j = 0; j < 256; j++) { colors[j].value = j; colors[j].rgb.red = gr_mac_gamma[gr_current_pal[i++]]; colors[j].rgb.green = gr_mac_gamma[gr_current_pal[i++]]; colors[j].rgb.blue = gr_mac_gamma[gr_current_pal[i++]]; } old_device = GetGDevice(); SetGDevice(GameMonitor); SetEntries(0, 255, colors); SetGDevice(old_device); #if 0 palette = GetPalette(GameWindow); for (i = 0; i < 768; i += 3) { color.red = gr_current_pal[i] << 9; color.green = gr_current_pal[i+1] << 9; color.blue = gr_current_pal[i+2] << 9; SetEntryColor(palette, i / 3, &color); } ctable = (CTabHandle)NewHandle(sizeof(ColorTable)); Palette2CTab(palette, ctable); AnimatePalette(GameWindow, ctable, 0, 0, 256); ActivatePalette(GameWindow); DisposeHandle((Handle)ctable); if (GameGWorld != NULL) { ctable = (**GetGWorldPixMap(GameGWorld)).pmTable; // get the color table for the gWorld. CTabChanged(ctable); (**ctable).ctSeed = (**(**(*(CGrafPtr)GameWindow).portPixMap).pmTable).ctSeed; } #endif gr_palette_faded_out = 0; init_computed_colors(); }
void gr_palette_clear() { int i; ColorSpec colors[256]; GDHandle old_device; // PaletteHandle palette; // RGBColor color; // CTabHandle ctable; for (i = 0; i < 256; i++) { colors[i].value = i; colors[i].rgb.red = 0; colors[i].rgb.green = 0; colors[i].rgb.blue = 0; } old_device = GetGDevice(); SetGDevice(GameMonitor); SetEntries(0, 255, colors); SetGDevice(old_device); #if 0 palette = GetPalette(GameWindow); for (i=0; i<256; i++) { color.red = 0x0; color.green = 0x0; color.blue = 0x0; SetEntryColor(palette, i, &color); } ctable = (CTabHandle)NewHandle(sizeof(ColorTable)); Palette2CTab(palette, ctable); AnimatePalette(GameWindow, ctable, 0, 0, 256); ActivatePalette(GameWindow); DisposeHandle((Handle)ctable); // make the seeds match for the gworld clut and the window palette. I don't know if // this is necessary, but it doesn't hurt. if (GameGWorld != NULL) { ctable = (**GetGWorldPixMap(GameGWorld)).pmTable; CTabChanged(ctable); (**ctable).ctSeed = (**(**(*(CGrafPtr)GameWindow).portPixMap).pmTable).ctSeed; } #endif gr_palette_faded_out = 1; }
// This routine takes a CTab and generates a mapping array which will map one colour onto the best // tinted colour in the palette. It makes no attempt to change the colours in the palette, they // are mapped to the closest match. void MakeTintMapShifted(CTabHandle theClut,TintPtr theTint,long rShift,long gShift,long bShift) { char origState=HGetState((Handle)theClut); RGBColor theCol; short count,index; Boolean openedWorld=false; HLock((Handle)theClut); CTabChanged(theClut); // important, otherwise the remapping goes : "fsd;jhgflkasrhgflkdsavbn.asdkjrhvliuabhdv.kjhopsd; jrg;osnalkgvsa;rlfjhlkhbeoirlh" if (!gBL_TintWorld) { OpenTintWorld(theClut); openedWorld=true; } if (gBL_TintWorld) { for(count=0; count<=(**theClut).ctSize; count++) { theCol=(**theClut).ctTable[count].rgb; ShiftColour(&theCol,rShift,gShift,bShift); index=RGB2IndexGW(theClut,&theCol); if (index!=-1) // if a match could not be found then put the original colour in theTint[count]=index; else theTint[count]=count; } if (openedWorld) CloseTintWorld(); } HSetState((Handle)theClut,origState); }
static int ROM_VideoInit(_THIS, SDL_PixelFormat *vformat) { long info; /* Check out some things about the system */ Gestalt(gestaltQuickdrawVersion, &info); if ( info == gestaltOriginalQD ) { SDL_SetError("Color Quickdraw not available"); return(-1); } /* Start ROMintosh events */ Mac_InitEvents(this); /* Get a handle to the main monitor */ SDL_Display = GetMainDevice(); /* Determine the current screen size */ this->info.current_w = (**SDL_Display).gdRect.right; this->info.current_h = (**SDL_Display).gdRect.bottom; /* Determine pixel format */ vformat->BitsPerPixel = (**(**SDL_Display).gdPMap).pixelSize; switch (vformat->BitsPerPixel) { case 16: /* 5-5-5 RGB */ vformat->Rmask = 0x00007c00; vformat->Gmask = 0x000003e0; vformat->Bmask = 0x0000001f; break; default: break; } /* Create our palette */ SDL_CTab = (CTabHandle)NewHandle(sizeof(ColorSpec)*256 + 8); if ( SDL_CTab == nil ) { SDL_OutOfMemory(); return(-1); } (**SDL_CTab).ctSeed = GetCTSeed(); (**SDL_CTab).ctFlags = 0; (**SDL_CTab).ctSize = 255; CTabChanged(SDL_CTab); SDL_CPal = NewPalette(256, SDL_CTab, pmExplicit+pmTolerant, 0); /* Get a list of available fullscreen modes */ SDL_modelist = (SDL_Rect **)SDL_malloc((1+1)*sizeof(SDL_Rect *)); if ( SDL_modelist ) { SDL_modelist[0] = (SDL_Rect *)SDL_malloc(sizeof(SDL_Rect)); if ( SDL_modelist[0] ) { SDL_modelist[0]->x = 0; SDL_modelist[0]->y = 0; SDL_modelist[0]->w = (**SDL_Display).gdRect.right; SDL_modelist[0]->h = (**SDL_Display).gdRect.bottom; } SDL_modelist[1] = NULL; } /* Fill in some window manager capabilities */ this->info.wm_available = 1; /* We're done! */ return(0); }