void gr_palette_clear() { int i; HRESULT ddresult; Assert(_lpDDPalActive!=0); // Zero out Palette for (i = 0; i < 256; i++) { PalGDIData.ScratchPal[i].peRed = PalGDIData.ScratchPal[i].peBlue = PalGDIData.ScratchPal[i].peGreen = 0; PalGDIData.ScratchPal[i].peFlags = 0; } if (!hPalGDI) { ddresult = IDirectDrawPalette_SetEntries(_lpDDPalActive, 0, 0, 256, PalGDIData.ScratchPal); Assert(ddresult == DD_OK); } else { HDC hdc; hdc = GetDC(GetLibraryWindow()); SetPaletteEntries(hPalGDI, 0, PalGDIData.num, PalGDIData.ScratchPal); RealizePalette(hdc); ReleaseDC(GetLibraryWindow(), hdc); } gr_palette_faded_out = 1; if (GRMODEINFO(emul)) DDClearDisplay(); }
static Bool winStoreColorsShadowDDNL(ColormapPtr pColormap, int ndef, xColorItem * pdefs) { ScreenPtr pScreen = pColormap->pScreen; winScreenPriv(pScreen); winCmapPriv(pColormap); ColormapPtr curpmap = pScreenPriv->pcmapInstalled; HRESULT ddrval = DD_OK; /* Put the X colormap entries into the Windows logical palette */ ddrval = IDirectDrawPalette_SetEntries(pCmapPriv->lpDDPalette, 0, pdefs[0].pixel, ndef, pCmapPriv->peColors + pdefs[0].pixel); if (FAILED(ddrval)) { ErrorF("winStoreColorsShadowDDNL - SetEntries () failed: %08x\n", (unsigned int) ddrval); return FALSE; } /* Don't install the DirectDraw palette if the colormap is not installed */ if (pColormap != curpmap) { return TRUE; } if (!winInstallColormapShadowDDNL(pColormap)) { ErrorF("winStoreColorsShadowDDNL - Failed installing colormap\n"); return FALSE; } return TRUE; }
static void set_palette(ui_palette pal1, int start, int end) { PUCHAR pal = (PUCHAR) pal1; HDC hDC; int i; // store new palette entries locally memcpy(backpalette + 4 * start, pal, (end - start) * 4); for (i = start; i <= end; i++) { bmp->bmiColors[i].rgbRed = *(pal + 4 * (i - start) + 0); bmp->bmiColors[i].rgbGreen = *(pal + 4 * (i - start) + 1); bmp->bmiColors[i].rgbBlue = *(pal + 4 * (i - start) + 2); bmp->bmiColors[i].rgbReserved = 0; } // update window/screen #ifdef DDRAW_DRIVER if (directX) { IDirectDrawPalette_SetEntries(dxPalette, 0, start, end - start + 1, (PALETTEENTRY *) pal); } else #endif { SetPaletteEntries(hPalette, start, end - start + 1, (PALETTEENTRY *) pal); hDC = GetDC(hWnd); UnrealizeObject(hPalette); RealizePalette(hDC); ReleaseDC(hWnd, hDC); win32_display(); } }
void DDSetPaletteEntries( LPDIRECTDRAWPALETTE pPalette, UINT32 uiFlags, UINT32 uiStartingEntry, UINT32 uiCount, LPPALETTEENTRY pEntries ) { Assert( pPalette != NULL ); Assert( pEntries != NULL ); ATTEMPT( IDirectDrawPalette_SetEntries( pPalette, uiFlags, uiStartingEntry, uiCount, pEntries ) ); }
/* set a single [char wide] color in 16 color mode. */ void VGA_SetColor16(int reg,int color) { PALETTEENTRY *pal; if (!lpddraw) return; pal= &vga_def64_palette[color]; IDirectDrawPalette_SetEntries(lpddpal,0,reg,1,pal); vga_16_palette[reg]=(char)color; }
// // Set a a full palette of 256 PALETTEENTRY entries // VOID SetDDPalette(PALETTEENTRY* pal) { // create palette first time if (DDPalette == NULL) CreateDDPalette(pal); else IDirectDrawPalette_SetEntries(DDPalette, 0, 0, 256, pal); // setting the same palette to the same surface again does not increase // the reference count IDirectDrawSurface_SetPalette(ScreenReal, DDPalette); }
void VGA_SetQuadPalette(RGBQUAD*color,int start,int len) { PALETTEENTRY pal[256]; int c; if (!lpddraw) return; for (c=0; c<len; c++) { pal[c].peRed =color[c].rgbRed; pal[c].peGreen=color[c].rgbGreen; pal[c].peBlue =color[c].rgbBlue; pal[c].peFlags=0; } IDirectDrawPalette_SetEntries(lpddpal,0,start,len,pal); }
/* set all 17 [char wide] colors at once in 16 color mode. */ void VGA_Set16Palette(char *Table) { PALETTEENTRY *pal; int c; if (!lpddraw) return; /* return if we're in text only mode */ memcpy( Table, &vga_16_palette, 17 ); /* copy the entries into the table */ for (c=0; c<17; c++) { /* 17 entries */ pal= &vga_def64_palette[(int)vga_16_palette[c]]; /* get color */ IDirectDrawPalette_SetEntries(lpddpal,0,c,1,pal); /* set entry */ TRACE("Palette register %d set to %d\n",c,(int)vga_16_palette[c]); } /* end of the counting loop */ }
void gr_palette_step_up( int r, int g, int b ) { HRESULT ddresult; int i; ubyte *p; int temp; Assert(_lpDDPalActive!=0); 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; for (i=0; i<256; i++ ) { temp = (int)(*p++) + r + gr_palette_gamma; if (temp<0) temp=0; else if (temp>63) temp=63; PalGDIData.ScratchPal[i].peRed = temp << 2; temp = (int)(*p++) + g + gr_palette_gamma; if (temp<0) temp=0; else if (temp>63) temp=63; PalGDIData.ScratchPal[i].peGreen = temp << 2; temp = (int)(*p++) + b + gr_palette_gamma; if (temp<0) temp=0; else if (temp>63) temp=63; PalGDIData.ScratchPal[i].peBlue = temp << 2; PalGDIData.ScratchPal[i].peFlags = PC_NOCOLLAPSE; } if (!PalGDI) { ddresult = IDirectDrawPalette_SetEntries(_lpDDPalActive, 0, 0, 256, PalGDIData.ScratchPal); Assert(ddresult == DD_OK); } else { HDC hdc; hdc = GetDC(GetLibraryWindow()); SetPaletteEntries(hPalGDI, 0, PalGDIData.num, PalGDIData.ScratchPal); RealizePalette(hdc); ReleaseDC(GetLibraryWindow(), hdc); } }
void gr_palette_load( ubyte * pal ) { int i; ubyte c; HRESULT ddresult; Assert(_lpDDPalActive!=0); for (i=0; i<256; i++ ) { c = pal[i*3] + gr_palette_gamma; if ( c > 63 ) c = 63; PalGDIData.ScratchPal[i].peRed = c << 2; gr_current_pal[i*3] = pal[i*3]; c = pal[i*3+1] + gr_palette_gamma; if ( c > 63 ) c = 63; PalGDIData.ScratchPal[i].peGreen = c << 2; gr_current_pal[i*3+1] = pal[i*3+1]; c = pal[i*3+2] + gr_palette_gamma; if ( c > 63 ) c = 63; PalGDIData.ScratchPal[i].peBlue = c << 2; gr_current_pal[i*3+2] = pal[i*3+2]; PalGDIData.ScratchPal[i].peFlags = 0; } if (!hPalGDI) { ddresult = IDirectDrawPalette_SetEntries(_lpDDPalActive, 0, 0, 256, PalGDIData.ScratchPal); Assert(ddresult == DD_OK); } else { HDC hdc; hdc = GetDC(GetLibraryWindow()); SetPaletteEntries(hPalGDI, 0, PalGDIData.num, PalGDIData.ScratchPal); RealizePalette(hdc); ReleaseDC(GetLibraryWindow(), hdc); } gr_palette_faded_out = 0; init_computed_colors(); }
int GGI_directx_DDChangePalette(struct ggi_visual *vis) { directx_priv *priv = LIBGGI_PRIVATE(vis); int start = LIBGGI_PAL(vis)->rw_start; int stop = LIBGGI_PAL(vis)->rw_stop; ggi_color *clut = LIBGGI_PAL(vis)->clut.data; HRESULT hr; int x; static PALETTEENTRY pal[256]; LIB_ASSERT(priv->lpddp, "No palette!\n"); if (start >= stop) return 0; for (x = start; x < stop; x++) { pal[x].peFlags = PC_NOCOLLAPSE; pal[x].peRed = clut[x].r >> 8; pal[x].peGreen = clut[x].g >> 8; pal[x].peBlue = clut[x].b >> 8; } /* for (x = 0; x < 10; x++) { pal[x].peFlags = pal[x+246].peFlags = PC_EXPLICIT; pal[x].peRed = x; pal[x+246].peRed = x+246; pal[x].peGreen = pal[x].peBlue = 0; } */ hr = IDirectDrawPalette_SetEntries( priv->lpddp, 0, start, stop - start, &pal[start]); if (hr != 0) { fprintf(stderr, "DDP_SetEntries Failed RC = %ld. Exiting\n", hr & 0xffff); exit(-1); } return 0; }
/***************************************************************************** * IDirect3DTexture2::Load * * Loads a texture created with the DDSCAPS_ALLOCONLOAD * * This function isn't relayed to WineD3D because the whole interface is * implemented in DDraw only. For speed improvements a implementation which * takes OpenGL more into account could be placed into WineD3D. * * Params: * D3DTexture2: Address of the texture to load * * Returns: * D3D_OK on success * D3DERR_TEXTURE_LOAD_FAILED. * *****************************************************************************/ static HRESULT WINAPI IDirect3DTextureImpl_Load(IDirect3DTexture2 *iface, IDirect3DTexture2 *D3DTexture2) { ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirect3DTexture2, iface); IDirectDrawSurfaceImpl *src_ptr = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirect3DTexture2, D3DTexture2); IWineD3DPalette *wine_pal, *wine_pal_src; IDirectDrawPalette *pal = NULL, *pal_src = NULL; IDirectDrawPaletteImpl *pal_impl, *pal_impl_src; HRESULT ret_value = D3D_OK; TRACE("(%p)->(%p)\n", This, src_ptr); if (((src_ptr->surface_desc.ddsCaps.dwCaps & DDSCAPS_MIPMAP) != (This->surface_desc.ddsCaps.dwCaps & DDSCAPS_MIPMAP)) || (src_ptr->surface_desc.u2.dwMipMapCount != This->surface_desc.u2.dwMipMapCount)) { ERR("Trying to load surfaces with different mip-map counts !\n"); } while(1) { DDSURFACEDESC *src_d, *dst_d; TRACE(" copying surface %p to surface %p (mipmap level %d)\n", src_ptr, This, src_ptr->mipmap_level); if ( This->surface_desc.ddsCaps.dwCaps & DDSCAPS_ALLOCONLOAD ) /* If the surface is not allocated and its location is not yet specified, force it to video memory */ if ( !(This->surface_desc.ddsCaps.dwCaps & (DDSCAPS_SYSTEMMEMORY|DDSCAPS_VIDEOMEMORY)) ) This->surface_desc.ddsCaps.dwCaps |= DDSCAPS_VIDEOMEMORY; /* Suppress the ALLOCONLOAD flag */ This->surface_desc.ddsCaps.dwCaps &= ~DDSCAPS_ALLOCONLOAD; /* Get the palettes */ ret_value = IWineD3DSurface_GetPalette(This->WineD3DSurface, &wine_pal); if( ret_value != D3D_OK) { ERR("IWineD3DSurface::GetPalette failed! This is unexpected\n"); return D3DERR_TEXTURE_LOAD_FAILED; } if(wine_pal) { ret_value = IWineD3DPalette_GetParent(wine_pal, (IUnknown **) &pal); if(ret_value != D3D_OK) { ERR("IWineD3DPalette::GetParent failed! This is unexpected\n"); return D3DERR_TEXTURE_LOAD_FAILED; } pal_impl = ICOM_OBJECT(IDirectDrawPaletteImpl, IDirectDrawPalette, pal); } else { pal_impl = NULL; } ret_value = IWineD3DSurface_GetPalette(src_ptr->WineD3DSurface, &wine_pal_src); if( ret_value != D3D_OK) { ERR("IWineD3DSurface::GetPalette failed! This is unexpected\n"); return D3DERR_TEXTURE_LOAD_FAILED; } if(wine_pal_src) { ret_value = IWineD3DPalette_GetParent(wine_pal_src, (IUnknown **) &pal_src); if(ret_value != D3D_OK) { ERR("IWineD3DPalette::GetParent failed! This is unexpected\n"); return D3DERR_TEXTURE_LOAD_FAILED; } pal_impl_src = ICOM_OBJECT(IDirectDrawPaletteImpl, IDirectDrawPalette, pal_src); } else { pal_impl_src = NULL; } /* After seeing some logs, not sure at all about this... */ if (pal_impl == NULL) { IWineD3DSurface_SetPalette(This->WineD3DSurface, wine_pal); if (pal_impl_src != NULL) IDirectDrawPalette_AddRef(ICOM_INTERFACE(pal_impl_src, IDirectDrawPalette)); } else { if (pal_impl_src != NULL) { PALETTEENTRY palent[256]; IDirectDrawPalette_GetEntries(ICOM_INTERFACE(pal_impl_src, IDirectDrawPalette), 0, 0, 256, palent); IDirectDrawPalette_SetEntries(ICOM_INTERFACE(pal_impl, IDirectDrawPalette), 0, 0, 256, palent); } } /* Copy one surface on the other */ dst_d = (DDSURFACEDESC *)&(This->surface_desc); src_d = (DDSURFACEDESC *)&(src_ptr->surface_desc); if ((src_d->dwWidth != dst_d->dwWidth) || (src_d->dwHeight != dst_d->dwHeight)) { /* Should also check for same pixel format, u1.lPitch, ... */ ERR("Error in surface sizes\n"); return D3DERR_TEXTURE_LOAD_FAILED; } else { WINED3DLOCKED_RECT pSrcRect, pDstRect; /* LPDIRECT3DDEVICE2 d3dd = (LPDIRECT3DDEVICE2) This->D3Ddevice; */ /* I should put a macro for the calculus of bpp */ /* Copy also the ColorKeying stuff */ if (src_d->dwFlags & DDSD_CKSRCBLT) { dst_d->dwFlags |= DDSD_CKSRCBLT; dst_d->ddckCKSrcBlt.dwColorSpaceLowValue = src_d->ddckCKSrcBlt.dwColorSpaceLowValue; dst_d->ddckCKSrcBlt.dwColorSpaceHighValue = src_d->ddckCKSrcBlt.dwColorSpaceHighValue; } /* Copy the main memory texture into the surface that corresponds to the OpenGL texture object. */ ret_value = IWineD3DSurface_LockRect(src_ptr->WineD3DSurface, &pSrcRect, NULL, 0); if(ret_value != D3D_OK) { ERR(" (%p) Locking the source surface failed\n", This); return D3DERR_TEXTURE_LOAD_FAILED; } ret_value = IWineD3DSurface_LockRect(This->WineD3DSurface, &pDstRect, NULL, 0); if(ret_value != D3D_OK) { ERR(" (%p) Locking the destination surface failed\n", This); IWineD3DSurface_UnlockRect(src_ptr->WineD3DSurface); return D3DERR_TEXTURE_LOAD_FAILED; } if (This->surface_desc.u4.ddpfPixelFormat.dwFlags & DDPF_FOURCC) memcpy(pDstRect.pBits, pSrcRect.pBits, src_ptr->surface_desc.u1.dwLinearSize); else memcpy(pDstRect.pBits, pSrcRect.pBits, pSrcRect.Pitch * src_d->dwHeight); IWineD3DSurface_UnlockRect(src_ptr->WineD3DSurface); IWineD3DSurface_UnlockRect(This->WineD3DSurface); } if (src_ptr->surface_desc.ddsCaps.dwCaps & DDSCAPS_MIPMAP) { src_ptr = get_sub_mimaplevel(src_ptr); } else { src_ptr = NULL; } if (This->surface_desc.ddsCaps.dwCaps & DDSCAPS_MIPMAP) { This = get_sub_mimaplevel(This); } else { This = NULL; } if ((src_ptr == NULL) || (This == NULL)) { if (src_ptr != This) { ERR(" Loading surface with different mipmap structure !!!\n"); } break; } } return ret_value; }
static LRESULT CALLBACK WindowProc(HWND hWnd, // handle to window UINT uMsg, // message identifier WPARAM wParam, // first message parameter LPARAM lParam // second message parameter ) { PAINTSTRUCT paintStruct; HDC hDC; if (uMsg == (unsigned int) MyHelpMsg) { win32_help(NULL, helptopic); return 0; } switch (uMsg) { case WM_COMMAND: win32_pressed(wParam); break; case WM_SIZE: // resize window if (directX == DXFULLSCREEN) return 0; if (LOWORD(lParam) == 0 && HIWORD(lParam) == 0) { active = 0; break; } /*Minimized window */ active = 1; if (displayX != LOWORD(lParam) || displayY != HIWORD(lParam)) resized = 1; displayX = LOWORD(lParam); displayY = HIWORD(lParam); break; case WM_DISPLAYCHANGE: if (directX == DXFULLSCREEN) return 0; mouseButtons = 0; resized = 1; hDC = GetDC(hWnd); bitDepth = GetDeviceCaps(hDC, BITSPIXEL); ReleaseDC(hWnd, hDC); break; case WM_CLOSE: // close window closeFlag = TRUE; return 0; case WM_MOUSEMOVE: case WM_LBUTTONUP: case WM_LBUTTONDOWN: case WM_RBUTTONUP: case WM_RBUTTONDOWN: case WM_MBUTTONUP: case WM_MBUTTONDOWN: // handle mouse move and mouse buttons mouseButtons = wParam; if (!captured) { if (mouseButtons && !tmpcaptured) SetCapture(hWnd), tmpcaptured = 1; if (!mouseButtons && tmpcaptured) ReleaseCapture(), tmpcaptured = 0; } mouseX = (short) LOWORD(lParam); mouseY = (short) HIWORD(lParam); #ifdef DDRAW_DRIVER if (directX == DXFULLSCREEN) { POINT p; GetCursorPos(&p); mouseX = p.x; mouseY = p.y; UpdateMouseDD(); } #endif break; case WM_PAINT: // redraw screen if (directX == DXFULLSCREEN) return 0; needredraw = 1; if (GetUpdateRect(hWnd, NULL, FALSE)) { HDC hDC = BeginPaint(hWnd, &paintStruct); if (hDC) { #ifdef DDRAW_DRIVER if (directX) PaintDD(); else #endif Paint(hDC); EndPaint(hWnd, &paintStruct); } } return 0; case WM_QUERYNEWPALETTE: // windows calls this when window is reactivated. if (directX == DXFULLSCREEN) return 0; hDC = GetDC(hWnd); #ifdef DDRAW_DRIVER if (directX == DXWINDOWED) { if (dxPalette) { IDirectDrawSurface_SetPalette(lpSurfaces[0], dxPalette); IDirectDrawPalette_SetEntries(dxPalette, 0, 0, 255, (PALETTEENTRY *) backpalette); } } else #endif { SelectPalette(hDC, hPalette, FALSE); RealizePalette(hDC); } ReleaseDC(hWnd, hDC); return TRUE; case WM_MOVE: if (directX != DXFULLSCREEN) { GetWindowRect(hWnd, &rcWindow); GetClientRect(hWnd, &rcViewport); GetClientRect(hWnd, &rcScreen); ClientToScreen(hWnd, (POINT *) & rcScreen.left); ClientToScreen(hWnd, (POINT *) & rcScreen.right); } break; case WM_SETCURSOR: if (directX == DXFULLSCREEN) { SetCursor(NULL); return TRUE; } break; #ifdef DDRAW_DRIVER case WM_ACTIVATEAPP: { int oldactive = active; mouseButtons = 0; if (directX == DXFULLSCREEN) { needredraw = 1; active = (wParam == WA_ACTIVE) || (wParam == WA_CLICKACTIVE) /*(BOOL) wParam */ ; PaintDD(); if (!oldactive && active && captured) SetCursor(NULL), SetCapture(hWnd); if (oldactive && !active && captured) ReleaseCapture(); return 0L; } } #endif break; } return DefWindowProc(hWnd, uMsg, wParam, lParam); }
void VGA_SetPalette(PALETTEENTRY*pal,int start,int len) { if (!lpddraw) return; IDirectDrawPalette_SetEntries(lpddpal,0,start,len,pal); }
static void WINAPI VGA_DoSetMode(ULONG_PTR arg) { LRESULT res; ModeSet *par = (ModeSet *)arg; par->ret=1; if (lpddraw) VGA_DoExit(0); if (!lpddraw) { if (!pDirectDrawCreate) { HMODULE hmod = LoadLibraryA( "ddraw.dll" ); if (hmod) pDirectDrawCreate = (DirectDrawCreateProc)GetProcAddress( hmod, "DirectDrawCreate" ); if (!pDirectDrawCreate) { ERR("Can't lookup DirectDrawCreate from ddraw.dll.\n"); return; } } res = pDirectDrawCreate(NULL,&lpddraw,NULL); if (!lpddraw) { ERR("DirectDraw is not available (res = %lx)\n",res); return; } if (!vga_hwnd) { vga_hwnd = CreateWindowExA(0,"STATIC","WINEDOS VGA", WS_POPUP|WS_VISIBLE|SS_NOTIFY,0,0, par->Xres,par->Yres,0,0,0,NULL); if (!vga_hwnd) { ERR("Failed to create user window.\n"); IDirectDraw_Release(lpddraw); lpddraw=NULL; return; } } else SetWindowPos(vga_hwnd,0,0,0,par->Xres,par->Yres,SWP_NOMOVE|SWP_NOZORDER); if ((res=IDirectDraw_SetCooperativeLevel(lpddraw,vga_hwnd,DDSCL_FULLSCREEN|DDSCL_EXCLUSIVE))) { ERR("Could not set cooperative level to exclusive (%lx)\n",res); } if ((res=IDirectDraw_SetDisplayMode(lpddraw,par->Xres,par->Yres,par->Depth))) { ERR("DirectDraw does not support requested display mode (%dx%dx%d), res = %lx!\n",par->Xres,par->Yres,par->Depth,res); IDirectDraw_Release(lpddraw); lpddraw=NULL; return; } res=IDirectDraw_CreatePalette(lpddraw,DDPCAPS_8BIT,NULL,&lpddpal,NULL); if (res) { ERR("Could not create palette (res = %lx)\n",res); IDirectDraw_Release(lpddraw); lpddraw=NULL; return; } if ((res=IDirectDrawPalette_SetEntries(lpddpal,0,0,256,vga_def_palette))) { ERR("Could not set default palette entries (res = %lx)\n", res); } memset(&sdesc,0,sizeof(sdesc)); sdesc.dwSize=sizeof(sdesc); sdesc.dwFlags = DDSD_CAPS; sdesc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; if (IDirectDraw_CreateSurface(lpddraw,&sdesc,&lpddsurf,NULL)||(!lpddsurf)) { ERR("DirectDraw surface is not available\n"); IDirectDraw_Release(lpddraw); lpddraw=NULL; return; } IDirectDrawSurface_SetPalette(lpddsurf,lpddpal); vga_retrace_vertical = vga_retrace_horizontal = FALSE; /* poll every 20ms (50fps should provide adequate responsiveness) */ VGA_InstallTimer(20); } par->ret=0; return; }
int gr_palette_fade_in(ubyte *pal, int nsteps, int allow_keys) { HRESULT ddresult; int i,j; ubyte c; fix fade_palette[768]; fix fade_palette_delta[768]; allow_keys = allow_keys; Assert(_lpDDPalActive!=0); if (!gr_palette_faded_out) return 0; #ifndef NDEBUG if (grd_fades_disabled) { gr_palette_load(pal); return 0; } #endif for (i=0; i<768; i++ ) { gr_current_pal[i] = pal[i]; fade_palette[i] = 0; fade_palette_delta[i] = i2f(pal[i]+gr_palette_gamma) / nsteps; } for (j=0; j<nsteps; j++ ) { for (i=0; i<256; i++ ) { fade_palette[i*3] += fade_palette_delta[i*3]; fade_palette[i*3+1] += fade_palette_delta[i*3+1]; fade_palette[i*3+2] += fade_palette_delta[i*3+2]; if (fade_palette[i*3] > i2f(pal[i*3]+gr_palette_gamma) ) fade_palette[i*3] = i2f(pal[i*3]+gr_palette_gamma); if (fade_palette[i*3+1] > i2f(pal[i*3+1]+gr_palette_gamma) ) fade_palette[i*3+1] = i2f(pal[i*3+1]+gr_palette_gamma); if (fade_palette[i*3+2] > i2f(pal[i*3+2]+gr_palette_gamma) ) fade_palette[i*3+2] = i2f(pal[i*3+2]+gr_palette_gamma); c = f2i(fade_palette[i*3]); if ( c > 63 ) c = 63; PalGDIData.ScratchPal[i].peRed = c << 2; c = f2i(fade_palette[i*3+1]); if ( c > 63 ) c = 63; PalGDIData.ScratchPal[i].peGreen = c << 2; c = f2i(fade_palette[i*3+2]); if ( c > 63 ) c = 63; PalGDIData.ScratchPal[i].peBlue = c << 2; PalGDIData.ScratchPal[i].peFlags = 0; } if (!hPalGDI) { IDirectDraw_WaitForVerticalBlank(lpDD, DDWAITVB_BLOCKBEGIN, NULL); ddresult = IDirectDrawPalette_SetEntries(_lpDDPalActive, 0, 0, 256, PalGDIData.ScratchPal); Assert (ddresult == DD_OK); } else { HDC hdc; hdc = GetDC(GetLibraryWindow()); SetPaletteEntries(hPalGDI, 0, PalGDIData.num, PalGDIData.ScratchPal); RealizePalette(hdc); ReleaseDC(GetLibraryWindow(), hdc); } } gr_palette_faded_out = 0; return 0; }