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 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(); }
HRESULT CLR_RT_HeapBlock_XmlNameTable::Grow() { TINYCLR_HEADER(); CLR_RT_HeapBlock_Array* oldEntries; CLR_RT_HeapBlock newEntriesHB; CLR_RT_HeapBlock_Array* newEntries; CLR_RT_HeapBlock_XmlNameTable_Entry* entry; CLR_RT_HeapBlock_XmlNameTable_Entry* next; CLR_RT_HeapBlock* newEntryHB; CLR_UINT32 i; CLR_INT32 newIndex; CLR_INT32 newMask; newMask = GetMask() * 2 + 1; // allocate a new instance of Entry array TINYCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Array::CreateInstance( newEntriesHB, newMask + 1, g_CLR_RT_WellKnownTypes.m_XmlNameTable_Entry )); newEntries = newEntriesHB.DereferenceArray(); oldEntries = GetEntries(); // Go through the old buckets, and resort them for(i = 0; i < oldEntries->m_numOfElements; i++) { entry = (CLR_RT_HeapBlock_XmlNameTable_Entry*)((CLR_RT_HeapBlock*)oldEntries->GetElement( i ))->Dereference(); while(entry != NULL) { newIndex = entry->GetHashCode() & newMask; next = entry->GetNext(); newEntryHB = (CLR_RT_HeapBlock*)newEntries->GetElement( newIndex ); entry->SetNext( (CLR_RT_HeapBlock_XmlNameTable_Entry*)newEntryHB->Dereference() ); newEntryHB->SetObjectReference( entry ); entry = next; } } SetEntries( newEntries ); SetMask ( newMask ); TINYCLR_NOCLEANUP(); }
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; }
void reset_debug_video_mode() { ColorSpec color[2]; GDHandle old_device; color[0].value = 255; color[0].rgb.red = 0xffff; color[0].rgb.blue = 0xffff; color[0].rgb.green = 0xffff; color[1].value = 0; color[1].rgb.red = 0x0; color[1].rgb.blue = 0x0; color[1].rgb.green = 0x0; SetGDevice(GameMonitor); old_device = GetGDevice(); SetEntries(-1, 1, color); SetGDevice(old_device); gr_debug_mode = 0; }
static int ROM_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors) { CTabHandle cTab; int i; /* Get the colortable from the either the display or window */ if ( (this->screen->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) { cTab = (**(**SDL_Display).gdPMap).pmTable; } else { cTab = SDL_CTab; } /* Verify the range of colors */ if ( (firstcolor+ncolors) > ((**cTab).ctSize+1) ) { return(0); } /* Set the screen palette and update the display */ for ( i=0; i< ncolors; ++i ) { int j = firstcolor + i; (**cTab).ctTable[j].value = j; (**cTab).ctTable[j].rgb.red = colors[i].r << 8 | colors[i].r; (**cTab).ctTable[j].rgb.green = colors[i].g << 8 | colors[i].g; (**cTab).ctTable[j].rgb.blue = colors[i].b << 8 | colors[i].b; } #if 0 if ( (this->screen->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) #endif { GDevice **odisplay; odisplay = GetGDevice(); SetGDevice(SDL_Display); SetEntries(0, (**cTab).ctSize, (ColorSpec *)&(**cTab).ctTable); SetGDevice(odisplay); } return(1); }
int gr_palette_fade_in(ubyte *pal, int nsteps, int allow_keys) { int i,j, k; ubyte c; fix fade_palette[768]; fix fade_palette_delta[768]; ColorSpec colors[256]; GDHandle old_device; // PaletteHandle palette; // RGBColor color; // CTabHandle ctable; allow_keys = allow_keys; if (!gr_palette_faded_out) return 0; // palette = GetPalette(GameWindow); for (i=0; i<768; i++ ) { gr_current_pal[i] = pal[i]; fade_palette[i] = 0; fade_palette_delta[i] = i2f(pal[i]) / nsteps; } for (j=0; j<nsteps; j++ ) { for (i=0, k = 0; k<256; k++ ) { colors[k].value = k; fade_palette[i] += fade_palette_delta[i]; if (fade_palette[i] > i2f(pal[i]) ) fade_palette[i] = i2f(pal[i]); // c = f2i(fade_palette[i])+gr_palette_gamma; c = f2i(fade_palette[i]); if (c > 63) c = 63; colors[k].rgb.red = gr_mac_gamma[c]; i++; fade_palette[i] += fade_palette_delta[i]; if (fade_palette[i] > i2f(pal[i]) ) fade_palette[i] = i2f(pal[i]); // c = f2i(fade_palette[i])+gr_palette_gamma; c = f2i(fade_palette[i]); if (c > 63) c = 63; colors[k].rgb.green = gr_mac_gamma[c]; i++; fade_palette[i] += fade_palette_delta[i]; if (fade_palette[i] > i2f(pal[i]) ) fade_palette[i] = i2f(pal[i]); // c = f2i(fade_palette[i])+gr_palette_gamma; c = f2i(fade_palette[i]); if (c > 63) c = 63; colors[k].rgb.blue = gr_mac_gamma[c]; i++; } old_device = GetGDevice(); SetGDevice(GameMonitor); SetEntries(0, 255, colors); SetGDevice(old_device); } #if 0 for (i=0; i<768; i++ ) { gr_current_pal[i] = pal[i]; fade_palette[i] = 0; fade_palette_delta[i] = i2f(pal[i]) / nsteps; } for (j=0; j<nsteps; j++ ) { for (i=0; i<768; ) { fade_palette[i] += fade_palette_delta[i]; if (fade_palette[i] > i2f(pal[i]) ) fade_palette[i] = i2f(pal[i]); c = f2i(fade_palette[i])+gr_palette_gamma; if (c > 63) c = 63; color.red = c << 9; i++; fade_palette[i] += fade_palette_delta[i]; if (fade_palette[i] > i2f(pal[i]) ) fade_palette[i] = i2f(pal[i]); c = f2i(fade_palette[i])+gr_palette_gamma; if (c > 63) c = 63; color.green = c << 9; i++; fade_palette[i] += fade_palette_delta[i]; if (fade_palette[i] > i2f(pal[i]) ) fade_palette[i] = i2f(pal[i]); c = f2i(fade_palette[i])+gr_palette_gamma; if (c > 63) c = 63; color.blue = c << 9; i++; SetEntryColor(palette, (i / 3) - 1, &color); } ctable = (CTabHandle)NewHandle(sizeof(ColorTable)); Palette2CTab(palette, ctable); AnimatePalette(GameWindow, ctable, 0, 0, 256); ActivatePalette(GameWindow); DisposeHandle((Handle)ctable); } #endif gr_palette_faded_out = 0; return 0; }
StructDesc::StructDesc(StructDescEntry *tuples, unsigned int nTuples) { SetEntries(tuples, nTuples); }