Ignore:
Timestamp:
Aug 19, 1999, 8:08:48 PM (26 years ago)
Author:
hugh
Message:

Implemented new colorconversion routine and fixed bug in fastblt function.
Changed the palettehandling code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/ddraw/OS2PALETTE.CPP

    r522 r587  
    44#include <memory.h>
    55#define INITGUID
     6#include "os2ddraw.h"
     7#include "os2clipper.h"
    68#include "os2palette.h"
     9#include "os2surface.h"
    710#define _OS2WIN_H
    811#define FAR
     
    1114#include <winerror.h>
    1215
    13 //******************************************************************************
    14 //******************************************************************************
    15 OS2IDirectDrawPalette::OS2IDirectDrawPalette( OS2IDirectDraw *lpDirectDraw,
     16#undef THIS
     17#define THIS IDirectDrawPalette*
     18
     19//******************************************************************************
     20//******************************************************************************
     21OS2IDirectDrawPalette::OS2IDirectDrawPalette( VOID *lpDirectDraw,
    1622                                              int palsize,
    1723                                              LPPALETTEENTRY lpColorTable,
     
    1925                                              Referenced(0), os2pal(NULL),
    2026                                              lastError(DD_OK), lpDraw(NULL)
     27
    2128{
    2229  lpVtbl              = &Vtbl;
     
    3037
    3138  lpDraw                        = lpDirectDraw;
    32   lpDraw->Vtbl.AddRef(lpDraw);
    33   hDive                         = lpDirectDraw->GetDiveInstance();
     39  ((OS2IDirectDraw*)lpDraw)->Vtbl.AddRef(lpDraw);
     40  hDive                         = ((OS2IDirectDraw*)lpDirectDraw)->GetDiveInstance();
    3441  dwCaps                        = dwPalFlags;
     42  hDiveCC                       = ((OS2IDirectDraw*)lpDirectDraw)->GetCCDiveInstance();
    3543
    3644  dwSize = palsize;
     
    4149  os2pal = (LPPALETTEENTRY)malloc(palsize*sizeof(PALETTEENTRY));
    4250  memcpy((char *)os2pal, (char *)lpColorTable, palsize*sizeof(PALETTEENTRY));
     51
     52  for(DWORD i=0;i<dwSize;i++)
     53  {
     54    aPal16[i] = (lpColorTable[i].peBlue>>3) +
     55                ((lpColorTable[i].peGreen>>2) <<5) +
     56                ((lpColorTable[i].peRed>>3) << 11);
     57    aPal24[i] = (lpColorTable[i].peBlue <<8) +
     58                (lpColorTable[i].peGreen<<16) +
     59                (lpColorTable[i].peRed<<24);
     60  }
    4361}
    4462//******************************************************************************
     
    4866  if(os2pal)
    4967    free(os2pal);
    50   lpDraw->Vtbl.Release(lpDraw);
     68  ((OS2IDirectDraw*)lpDraw)->Vtbl.Release((OS2IDirectDraw*)lpDraw);
    5169}
    5270//******************************************************************************
     
    175193         dwNumEntries*sizeof(PALETTEENTRY));
    176194
    177   if(me->fAttachedToPrimary)
    178     me->SetPhysPalette();
    179 
     195  for(DWORD i=0;i<dwNumEntries;i++)
     196  {
     197    me->aPal16[dwBase+i] = (lpNewEntries[i].peBlue>>3) +
     198                           ((lpNewEntries[i].peGreen>>2) <<5) +
     199                           ((lpNewEntries[i].peRed>>3) << 11);
     200    me->aPal24[dwBase+i] = (lpNewEntries[i].peBlue <<8) +
     201                           (lpNewEntries[i].peGreen<<16) +
     202                           (lpNewEntries[i].peRed<<24);
     203  }
     204
     205  if(8==((OS2IDirectDraw*)me->lpDraw)->dCaps.ulDepth)
     206  {
     207    if(me->fAttachedToPrimary)
     208      me->SetPhysPalette();
     209  }
     210  else
     211  {
     212    if(NULL!=((OS2IDirectDraw*)me->lpDraw)->pPrimSurf)
     213      ((OS2IDirectDrawSurface*)((OS2IDirectDraw*)me->lpDraw)->pPrimSurf)->ColorConversion(NULL);;
     214  }
     215  /*
     216  if(NULL!=me->hDiveCC)
     217  {
     218    DiveSetSourcePalette( me->hDiveCC,
     219                          dwBase,
     220                          dwNumEntries,
     221                          (PBYTE)lpNewEntries);
     222
     223  }
     224  else
     225  {
     226    // Only usefull if system and game are in 8bit mode
     227    // 16bit games don't use palettes and setting the Phys palette
     228    // in >8Bit Modes has no effect.
     229
     230    if(me->fAttachedToPrimary)
     231      me->SetPhysPalette();
     232  }
     233  */
    180234  return(DD_OK);
    181235}
     
    199253    return;
    200254  fAttachedToPrimary = fNewVal;
     255
     256  /*
    201257  if(fAttachedToPrimary)
    202     SetPhysPalette();
    203 
    204 }
    205 //******************************************************************************
    206 //******************************************************************************
    207 
     258  {
     259    if(NULL!=hDiveCC)
     260      DiveSetSourcePalette( hDiveCC,
     261                            0,
     262                            255,
     263                            (PBYTE)os2pal);
     264    else
     265      SetPhysPalette();
     266  }
     267  */
     268}
     269//******************************************************************************
     270//******************************************************************************
     271
Note: See TracChangeset for help on using the changeset viewer.