/////////////////////////////////////////////////////////// // Palette stuff. // static void I_UploadNewPalette(int pal) { // This is used to replace the current 256 colour cmap with a new one // Used by 256 colour PseudoColor modes // Array of XColor structs used for setting the 256-colour palette static XColor* colours; static int cachedgamma; static size_t num_pals; if ((colours == NULL) || (cachedgamma != usegamma)) { int lump = W_GetNumForName("PLAYPAL"); const byte *palette = W_CacheLumpNum(lump); register const byte *const gtable = gammatable[cachedgamma = usegamma]; register int i; num_pals = W_LumpLength(lump) / (3*256); num_pals *= 256; if (!colours) { // First call - allocate and prepare colour array colours = malloc(sizeof(*colours)*num_pals); for (i=0 ; i<num_pals ; i++) { colours[i].pixel = i & 0xff; colours[i].flags = DoRed|DoGreen|DoBlue; } } // set the X colormap entries for (i=0 ; i<num_pals ; i++) { register int c; c = gtable[palette[0]]; colours[i].red = (c<<8) + c; c = gtable[palette[1]]; colours[i].green = (c<<8) + c; c = gtable[palette[2]]; colours[i].blue = (c<<8) + c; palette += 3; } W_UnlockLumpNum(lump); num_pals/=256; } #ifdef RANGECHECK if (pal >= num_pals) I_Error("I_UploadNewPalette: Palette number out of range (%d>=%d)", pal, num_pals); #endif // store the colors to the current colormap XStoreColors(X_display, X_cmap, colours + 256*pal, 256); #ifdef HAVE_LIBXXF86DGA /* install DGA colormap */ if(doDga) XF86DGAInstallColormap(X_display, X_screen, X_cmap); #endif }
static void DX_SetPalette_real (int start, int count) { if (! screen_is_picasso || picasso96_state.RGBFormat != RGBFB_CHUNKY) return; if (picasso_vidinfo.pixbytes != 1) { /* This is the case when we're emulating a 256 color display. */ while (count-- > 0) { int r = picasso96_state.CLUT[start].Red; int g = picasso96_state.CLUT[start].Green; int b = picasso96_state.CLUT[start].Blue; picasso_vidinfo.clut[start++] = (doMask256 (r, red_bits, red_shift) | doMask256 (g, green_bits, green_shift) | doMask256 (b, blue_bits, blue_shift)); } return; } while (count-- > 0) { XColor col = parsed_xcolors[start]; col.red = picasso96_state.CLUT[start].Red * 0x0101; col.green = picasso96_state.CLUT[start].Green * 0x0101; col.blue = picasso96_state.CLUT[start].Blue * 0x0101; XStoreColor (display, cmap, &col); XStoreColor (display, cmap2, &col); start++; } #ifdef USE_DGA_EXTENSION if (dgamode) { dga_colormap_installed ^= 1; if (dga_colormap_installed == 1) XF86DGAInstallColormap (display, screen, cmap2); else XF86DGAInstallColormap (display, screen, cmap); } #endif }
void S9xSetPalette () { int Brightness; if (ourvideo.bitdepth != 8) return; Brightness = IPPU.MaxBrightness *138; for (int i = 0; i < 256; i++) { colors[i].red = ((PPU.CGDATA[i] >> 0) & 0x1F) * Brightness; colors[i].green = ((PPU.CGDATA[i] >> 5) & 0x1F) * Brightness; colors[i].blue = ((PPU.CGDATA[i] >> 10) & 0x1F) * Brightness; } XStoreColors (ourdisp, cmap, colors, 256); XF86DGAInstallColormap (ourdisp, ourscreen, cmap); }
static void graphics_subinit (void) { XSetWindowAttributes wattr; XClassHint classhint; XWMHints *hints; unsigned long valuemask; dgamode = screen_is_picasso ? currprefs.gfx_pfullscreen : currprefs.gfx_afullscreen; dgamode = dgamode && dgaavail; wattr.background_pixel = /*black.pixel*/0; wattr.backing_store = Always; wattr.backing_planes = bitdepth; wattr.border_pixmap = None; wattr.border_pixel = /*black.pixel*/0; wattr.colormap = cmap; valuemask = (CWEventMask | CWBackPixel | CWBorderPixel | CWBackingStore | CWBackingPlanes | CWColormap); if (dgamode) { wattr.event_mask = DGA_EVENTMASK; wattr.override_redirect = 1; valuemask |= CWOverrideRedirect; } else wattr.event_mask = EVENTMASK; XSync (display, 0); delete_win = XInternAtom(display, "WM_DELETE_WINDOW", False); mywin = XCreateWindow (display, rootwin, 0, 0, current_width, current_height, 0, bitdepth, InputOutput, vis, valuemask, &wattr); XSetWMProtocols (display, mywin, &delete_win, 1); XSync (display, 0); XStoreName (display, mywin, PACKAGE_NAME); XSetIconName (display, mywin, PACKAGE_NAME); /* set class hint */ classhint.res_name = (char *)"UAE"; classhint.res_class = (char *)"UAEScreen"; XSetClassHint(display, mywin, &classhint); hints = XAllocWMHints(); /* Set window group leader to self to become an application * that can be hidden by e.g. WindowMaker. * Would be more useful if we could find out what the * (optional) GTK+ window ID is :-/ */ hints->window_group = mywin; hints->flags = WindowGroupHint; XSetWMHints(display, mywin, hints); XMapRaised (display, mywin); XSync (display, 0); mygc = XCreateGC (display, mywin, 0, 0); if (dgamode) { #ifdef USE_DGA_EXTENSION enter_dga_mode (); /*setuid(getuid());*/ picasso_vidinfo.rowbytes = fb_width * picasso_vidinfo.pixbytes; #endif } else { get_image (current_width, current_height, &ami_dinfo); if (screen_is_picasso) { get_image (current_width, current_height, &pic_dinfo); picasso_vidinfo.rowbytes = pic_dinfo.ximg->bytes_per_line; } } picasso_vidinfo.extra_mem = 1; gfxvidinfo.flush_screen = x11_flush_screen; gfxvidinfo.lockscr = x11_lock; gfxvidinfo.unlockscr = x11_unlock; if (need_dither) { gfxvidinfo.maxblocklines = 0; gfxvidinfo.rowbytes = gfxvidinfo.pixbytes * currprefs.gfx_width_win; gfxvidinfo.linemem = malloc (gfxvidinfo.rowbytes); gfxvidinfo.flush_line = x11_flush_line_dither; } else if (! dgamode) { gfxvidinfo.emergmem = 0; gfxvidinfo.linemem = 0; gfxvidinfo.bufmem = (uae_u8 *)ami_dinfo.image_mem; gfxvidinfo.rowbytes = ami_dinfo.ximg->bytes_per_line; if (currprefs.x11_use_low_bandwidth) { write_log ("Doing low-bandwidth output.\n"); gfxvidinfo.maxblocklines = 0; gfxvidinfo.rowbytes = ami_dinfo.ximg->bytes_per_line; gfxvidinfo.linemem = malloc (gfxvidinfo.rowbytes); if (shmavail && currprefs.x11_use_mitshm) { switch (gfxvidinfo.pixbytes) { case 4 : gfxvidinfo.flush_line = x11_flush_line_lbw_32bit_mitshm; break; case 2 : gfxvidinfo.flush_line = x11_flush_line_lbw_16bit_mitshm; break; default : gfxvidinfo.flush_line = x11_flush_line_lbw_8bit_mitshm; break; } } else { switch (gfxvidinfo.pixbytes) { case 4 : gfxvidinfo.flush_line = x11_flush_line_lbw_32bit; break; case 2 : gfxvidinfo.flush_line = x11_flush_line_lbw_16bit; break; default : gfxvidinfo.flush_line = x11_flush_line_lbw_8bit; break; } } } else { gfxvidinfo.maxblocklines = MAXBLOCKLINES_MAX; if (shmavail && currprefs.x11_use_mitshm) gfxvidinfo.flush_block = x11_flush_block_mitshm; else gfxvidinfo.flush_block = x11_flush_block; } } if (visualInfo.VI_CLASS != TrueColor && ! screen_is_picasso) { int i; for (i = 0; i < 256; i++) XStoreColor (display, cmap, parsed_xcolors + i); } #ifdef USE_DGA_EXTENSION if (dgamode) { dga_colormap_installed = 0; XF86DGAInstallColormap (display, screen, cmap2); XF86DGAInstallColormap (display, screen, cmap); } #endif if (! dgamode) { if (!currprefs.hide_cursor) XDefineCursor (display, mywin, xhairCursor); else XDefineCursor (display, mywin, blankCursor); cursorOn = 1; } mousehack = !dgamode; if (screen_is_picasso) { picasso_has_invalid_lines = 0; picasso_invalid_start = picasso_vidinfo.height + 1; picasso_invalid_stop = -1; memset (picasso_invalid_lines, 0, sizeof picasso_invalid_lines); } else reset_drawing (); inwindow = 0; inputdevice_release_all_keys (); reset_hotkeys (); }