Ignore:
Timestamp:
Feb 4, 2000, 8:31:26 PM (26 years ago)
Author:
hugh
Message:

Bugfixes at many places

File:
1 edited

Legend:

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

    r2192 r2638  
    1 /* $Id: OS2SURFACE.CPP,v 1.22 1999-12-23 00:50:11 hugh Exp $ */
     1/* $Id: OS2SURFACE.CPP,v 1.23 2000-02-04 19:31:24 hugh Exp $ */
    22
    33/*
     
    2222#include "os2palette.h"
    2323#include "os2surface.h"
     24#include "os2util.h"
    2425#include "rectangle.h"
    2526#define _OS2WIN_H
     
    492493  } flags[] = {
    493494#define FE(x) { x, #x},
     495          FE(DDCKEY_COLORSPACE)
     496    FE(DDCKEY_DESTBLT)
     497    FE(DDCKEY_DESTOVERLAY)
     498    FE(DDCKEY_SRCBLT)
     499    FE(DDCKEY_SRCOVERLAY)
     500  };
     501  for (i=0;i<sizeof(flags)/sizeof(flags[0]);i++)
     502    if (flags[i].mask & flagmask)
     503      dprintf(("DDRAW: %s ",flags[i].name));
     504  dprintf(("DDRAW: \n"));
     505}
     506
     507static void _dump_DDPIXELFORMAT(DWORD flagmask) {
     508  int  i;
     509  const struct {
     510    DWORD  mask;
     511    char  *name;
     512  } flags[] = {
     513#define FE(x) { x, #x},
    494514          FE(DDPF_ALPHAPIXELS)
    495515    FE(DDPF_ALPHA)
     
    514534
    515535static void _dump_pixelformat(LPDDPIXELFORMAT pf) {
    516   _dump_DDCOLORKEY(pf->dwFlags);
     536  _dump_DDPIXELFORMAT(pf->dwFlags);
    517537  dprintf(("DDRAW: dwFourCC : %ld\n", pf->dwFourCC));
    518538  dprintf(("DDRAW: RBG bit cbout : %ld\n", pf->dwRGBBitCount));
     
    871891      break;
    872892  }
    873   if( lpDDSurfaceDesc->dwFlags & DDSD_CAPS )
     893  // hack set DDSD_CAPS if the value is other than 0
     894  if( DDSurfaceDesc.ddsCaps.dwCaps)
     895    DDSurfaceDesc.dwFlags |= DDSD_CAPS;
     896
     897  if( DDSurfaceDesc.dwFlags & DDSD_CAPS )
    874898  {
    875899    // First check if we want to create a primary surface while the ddraw object already has one
    876     surfaceType = lpDDSurfaceDesc->ddsCaps.dwCaps;
     900    surfaceType = DDSurfaceDesc.ddsCaps.dwCaps;
    877901
    878902    if( surfaceType & DDSCAPS_PRIMARYSURFACE)
     
    891915      }
    892916
    893       if( (lpDDSurfaceDesc->dwFlags & DDSD_HEIGHT) ||
    894           (lpDDSurfaceDesc->dwFlags & DDSD_WIDTH)  ||
    895           (lpDDSurfaceDesc->dwFlags & DDSD_PIXELFORMAT)
     917      if( (DDSurfaceDesc.dwFlags & DDSD_HEIGHT) ||
     918          (DDSurfaceDesc.dwFlags & DDSD_WIDTH)  ||
     919          (DDSurfaceDesc.dwFlags & DDSD_PIXELFORMAT)
    896920        )
    897921      {
     
    952976      DDSurfaceDesc.dwWidth      = lpDraw->GetScreenWidth();
    953977      DDSurfaceDesc.lpSurface    = pFrameBuffer;
    954       lpDDSurfaceDesc->dwFlags   = DDSurfaceDesc.dwFlags;
    955       lpDDSurfaceDesc->dwHeight  = DDSurfaceDesc.dwHeight;
    956       lpDDSurfaceDesc->dwWidth   = DDSurfaceDesc.dwWidth;
    957       lpDDSurfaceDesc->lpSurface = pFrameBuffer;
    958       lpDDSurfaceDesc->lPitch    = DDSurfaceDesc.lPitch;
    959 
    960       lpDDSurfaceDesc->ddsCaps.dwCaps |= DDSCAPS_VISIBLE;
    961978      DDSurfaceDesc.ddsCaps.dwCaps    |= DDSCAPS_VISIBLE;
    962979      lpDraw->SetPrimarySurface(TRUE);
    963       lpDDSurfaceDesc->ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT);
    964       lpDDSurfaceDesc->ddpfPixelFormat.dwFourCC = (DWORD) lpDraw->GetScreenFourCC();
    965       lpDDSurfaceDesc->ddpfPixelFormat.dwRGBBitCount = lpDraw->GetScreenBpp();
    966980      DDSurfaceDesc.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT);
    967981      DDSurfaceDesc.ddpfPixelFormat.dwFourCC = (DWORD) lpDraw->GetScreenFourCC();
     
    971985      {
    972986        case 4:
    973           lpDDSurfaceDesc->ddpfPixelFormat.dwFlags = DDPF_PALETTEINDEXED4 | DDPF_RGB;
    974987          DDSurfaceDesc.ddpfPixelFormat.dwFlags = DDPF_PALETTEINDEXED4 | DDPF_RGB;
    975988          break;
    976989        case 8:
    977           lpDDSurfaceDesc->ddpfPixelFormat.dwFlags = DDPF_PALETTEINDEXED8 | DDPF_FOURCC | DDPF_RGB;
    978990          DDSurfaceDesc.ddpfPixelFormat.dwFlags = DDPF_PALETTEINDEXED8 | DDPF_FOURCC | DDPF_RGB;
    979991          break;
    980992        case 16:
    981           lpDDSurfaceDesc->ddpfPixelFormat.dwFlags = DDPF_FOURCC | DDPF_RGB;
    982           lpDDSurfaceDesc->ddpfPixelFormat.dwRBitMask = 0x0000F800;
    983           lpDDSurfaceDesc->ddpfPixelFormat.dwGBitMask = 0x000007E0;
    984           lpDDSurfaceDesc->ddpfPixelFormat.dwBBitMask = 0x0000001F;
    985993          DDSurfaceDesc.ddpfPixelFormat.dwFlags = DDPF_FOURCC | DDPF_RGB;
    986994          DDSurfaceDesc.ddpfPixelFormat.dwRBitMask = 0x0000F800;
     
    990998        case 24:
    991999        case 32:
    992           lpDDSurfaceDesc->ddpfPixelFormat.dwFlags = DDPF_FOURCC | DDPF_RGB;
    993           lpDDSurfaceDesc->ddpfPixelFormat.dwRBitMask = 0x00FF0000;
    994           lpDDSurfaceDesc->ddpfPixelFormat.dwGBitMask = 0x0000FF00;
    995           lpDDSurfaceDesc->ddpfPixelFormat.dwBBitMask = 0x000000FF;
    9961000          DDSurfaceDesc.ddpfPixelFormat.dwFlags = DDPF_FOURCC | DDPF_RGB;
    9971001          DDSurfaceDesc.ddpfPixelFormat.dwRBitMask = 0x00FF0000;
     
    10011005        default:
    10021006          // Remove the Pixelformat flag
    1003           lpDDSurfaceDesc->dwFlags &= ~DDSD_PIXELFORMAT;
    10041007          DDSurfaceDesc.dwFlags    &= ~DDSD_PIXELFORMAT;
    1005           #ifdef DEBUG
    1006             dprintf(("DDRAW: Unexpected BitDepth : %d\n",lpDraw->GetScreenBpp()));
    1007           #endif
     1008          dprintf(("DDRAW: Unexpected BitDepth : %d\n",lpDraw->GetScreenBpp()));
    10081009          break;
    10091010      } // end switch
    10101011
    1011       #ifdef DEBUG
    1012         dprintf(("DDRAW: Surface set up, checking other Caps\n"));
    1013       #endif
     1012      dprintf(("DDRAW: Surface set up, checking other Caps\n"));
    10141013
    10151014      if( DDSurfaceDesc.ddsCaps.dwCaps & DDSCAPS_COMPLEX)
    10161015      {
    1017         #ifdef DEBUG
    1018           dprintf(("DDRAW: Complex Surface\n"));
    1019         #endif
    1020 
    1021         if(lpDDSurfaceDesc->dwFlags & DDSD_BACKBUFFERCOUNT)
     1016        dprintf(("DDRAW: Complex Surface\n"));
     1017
     1018        if(DDSurfaceDesc.dwFlags & DDSD_BACKBUFFERCOUNT)
    10221019        {
    1023           #ifdef DEBUG
    1024             dprintf(("DDRAW: Backbuffer # = %d\n",lpDDSurfaceDesc->dwBackBufferCount));
    1025           #endif
     1020          dprintf(("DDRAW: Backbuffer # = %d\n",DDSurfaceDesc.dwBackBufferCount));
    10261021          memset( &ComplexSurfaceDesc,
    10271022                  0,
     
    10421037          ComplexSurfaceDesc.ddpfPixelFormat.dwRGBBitCount = DDSurfaceDesc.ddpfPixelFormat.dwRGBBitCount;
    10431038
    1044           if(lpDDSurfaceDesc->dwBackBufferCount>1)
     1039          if(DDSurfaceDesc.dwBackBufferCount>1)
    10451040          {
    10461041            ComplexSurfaceDesc.dwFlags |=DDSD_BACKBUFFERCOUNT;
    1047             ComplexSurfaceDesc.dwBackBufferCount = lpDDSurfaceDesc->dwBackBufferCount -1;
     1042            ComplexSurfaceDesc.dwBackBufferCount = DDSurfaceDesc.dwBackBufferCount -1;
    10481043            ComplexSurfaceDesc.ddsCaps.dwCaps|= DDSCAPS_COMPLEX;
    10491044          }
     
    10571052            // Our Primary Buffer is also the frontbuffer of a flipchain
    10581053            DDSurfaceDesc.ddsCaps.dwCaps    |= DDSCAPS_FRONTBUFFER | DDSCAPS_FLIP;
    1059             lpDDSurfaceDesc->ddsCaps.dwCaps |= DDSCAPS_FRONTBUFFER | DDSCAPS_FLIP;
    10601054            BackBuffer->SetFrontBuffer(this);
    10611055          }
     
    10671061        else
    10681062        {
     1063          dprintf(("DDRAW: Unsupported Complex Surface\n"));
    10691064          #ifdef DEBUG
    1070             dprintf(("DDRAW: Unsupported Complex Surface\n"));
    1071             _dump_DDSCAPS(lpDDSurfaceDesc->dwFlags);
     1065            _dump_DDSCAPS(DDSurfaceDesc.dwFlags);
    10721066          #endif
    10731067          lastError = DDERR_OUTOFMEMORY;
     
    11201114        dprintf(("DDRAW:  Use Screen Format :"));
    11211115        dwBpp = lpDraw->GetScreenBpp(); // No use Screenformat
    1122         lpDDSurfaceDesc->ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT);
    1123         lpDDSurfaceDesc->ddpfPixelFormat.dwFourCC = (DWORD) lpDraw->GetScreenFourCC();
    1124         lpDDSurfaceDesc->ddpfPixelFormat.dwRGBBitCount = dwBpp;
    11251116        DDSurfaceDesc.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT);
    11261117        DDSurfaceDesc.ddpfPixelFormat.dwFourCC = (DWORD) lpDraw->GetScreenFourCC();
     
    11291120        {
    11301121          case 4:
    1131             lpDDSurfaceDesc->ddpfPixelFormat.dwFlags = DDPF_PALETTEINDEXED4 | DDPF_RGB;
    11321122            DDSurfaceDesc.ddpfPixelFormat.dwFlags = DDPF_PALETTEINDEXED4 | DDPF_RGB;
    11331123            break;
    11341124          case 8:
    1135             lpDDSurfaceDesc->ddpfPixelFormat.dwFlags = DDPF_PALETTEINDEXED8 | DDPF_FOURCC | DDPF_RGB;
    11361125            DDSurfaceDesc.ddpfPixelFormat.dwFlags = DDPF_PALETTEINDEXED8 | DDPF_FOURCC | DDPF_RGB;
    11371126            break;
    11381127          case 16:
    1139             lpDDSurfaceDesc->ddpfPixelFormat.dwFlags = DDPF_FOURCC | DDPF_RGB;
    1140             lpDDSurfaceDesc->ddpfPixelFormat.dwRBitMask = 0x0000F800;
    1141             lpDDSurfaceDesc->ddpfPixelFormat.dwGBitMask = 0x000007E0;
    1142             lpDDSurfaceDesc->ddpfPixelFormat.dwBBitMask = 0x0000001F;
    11431128            DDSurfaceDesc.ddpfPixelFormat.dwFlags = DDPF_FOURCC | DDPF_RGB;
    11441129            DDSurfaceDesc.ddpfPixelFormat.dwRBitMask = 0x0000F800;
     
    11481133          case 24:
    11491134          case 32:
    1150             lpDDSurfaceDesc->ddpfPixelFormat.dwFlags = DDPF_FOURCC | DDPF_RGB;
    1151             lpDDSurfaceDesc->ddpfPixelFormat.dwRBitMask = 0x00FF0000;
    1152             lpDDSurfaceDesc->ddpfPixelFormat.dwGBitMask = 0x0000FF00;
    1153             lpDDSurfaceDesc->ddpfPixelFormat.dwBBitMask = 0x000000FF;
    11541135            DDSurfaceDesc.ddpfPixelFormat.dwFlags = DDPF_FOURCC | DDPF_RGB;
    11551136            DDSurfaceDesc.ddpfPixelFormat.dwRBitMask = 0x00FF0000;
     
    11591140          default:
    11601141            // Remove the Pixelformat flag
    1161             lpDDSurfaceDesc->dwFlags &= ~DDSD_PIXELFORMAT;
    11621142            DDSurfaceDesc.dwFlags    &= ~DDSD_PIXELFORMAT;
    1163             #ifdef DEBUG
    1164               dprintf(("DDRAW: Unexpected BitDepth : %d\n",lpDraw->GetScreenBpp()));
    1165             #endif
     1143            dprintf(("DDRAW: Unexpected BitDepth : %d\n",lpDraw->GetScreenBpp()));
    11661144            break;
    11671145        } // end switch
     
    12141192          // and blit to the real framebuffer on Unlock to do color conversion
    12151193
    1216           dwPitchDB = (lpDDSurfaceDesc->dwWidth * dwBytesPPDive +7) & ~7;
     1194          dwPitchDB = (DDSurfaceDesc.dwWidth * dwBytesPPDive +7) & ~7;
    12171195
    12181196          // 24 byte more to enable alignment and speed up blitting
    12191197
    1220           pDBreal = (char*)malloc( lpDDSurfaceDesc->dwHeight * dwPitchDB + 24);
     1198          pDBreal = (char*)malloc( DDSurfaceDesc.dwHeight * dwPitchDB + 24);
    12211199          pDiveBuffer = (char*)(((int)pDBreal + 7) & ~7); // align to QWORD
    12221200
     
    12511229
    12521230          // This surface isn't allocated yet, but when the texture is loaded
    1253           #ifdef DEBUG
    1254             dprintf(("DDRAW: Warning : Delayed memory allocation on request\n"));
    1255           #endif
     1231          dprintf(("DDRAW: Warning : Delayed memory allocation on request\n"));
    12561232          DDSurfaceDesc.lpSurface = NULL;
    1257           lpDDSurfaceDesc->lpSurface = NULL;
    12581233        }
    12591234        else
     
    12631238          dprintf(("DDRAW:  Alloc now!\n"));
    12641239
    1265           lpDDSurfaceDesc->dwFlags  |= DDSD_PITCH|DDSD_LPSURFACE;
    1266           DDSurfaceDesc.dwFlags      = lpDDSurfaceDesc->dwFlags;
    1267 
    1268           dwPitchFB = lpDDSurfaceDesc->dwWidth * (dwBpp<8?1:dwBpp/8);
     1240          DDSurfaceDesc.dwFlags      = DDSurfaceDesc.dwFlags;
     1241
     1242          dwPitchFB = DDSurfaceDesc.dwWidth * (dwBpp<8?1:dwBpp/8);
    12691243          dwPitchFB = (dwPitchFB +7) & ~7;  // Align on QWords
    1270           DDSurfaceDesc.lPitch    = dwPitchFB;
    1271           lpDDSurfaceDesc->lPitch = dwPitchFB;
    1272 
    12731244          #ifdef DEBUG
    12741245            if(dwBpp<8)
     
    12811252          // 24 byte more to enable alignment and speed up blitting
    12821253
    1283           pFBreal = (char*)malloc( lpDDSurfaceDesc->dwHeight * dwPitchFB + 24);
     1254          pFBreal = (char*)malloc( DDSurfaceDesc.dwHeight * dwPitchFB + 24);
    12841255
    12851256          if(NULL==pFBreal)
     
    12941265                    pFBreal, pFrameBuffer, dwPitchFB));
    12951266
    1296           lpDDSurfaceDesc->lpSurface = pFrameBuffer;
    12971267          DDSurfaceDesc.lpSurface    = pFrameBuffer;
    1298 
    12991268
    13001269          if( (lpDraw->dCaps.ulDepth ) == dwBpp )
     
    13071276          else
    13081277          {
    1309             dprintf(("DDRAW:  Alloc CCBuf "));
    1310             dwPitchDB = (lpDDSurfaceDesc->dwWidth * (lpDraw->dCaps.ulDepth/8) +7) & ~7;
    1311 
    1312             if(Mainchain)
    1313             {
    1314               dprintf(("DDRAW: with DIVE\n"));
    1315               // This surface is part of flipchain with the primary surface use dive to assoc memory
    1316               pDBreal = (char*)malloc( lpDDSurfaceDesc->dwHeight *
    1317                                            dwPitchDB+24);
    1318               pDiveBuffer = (char*)(((int)pDBreal + 7) & ~7); // align to QWORD
    1319               diveBufNr = 0;
    1320               rc = DiveAllocImageBuffer( hDive,
    1321                                          &diveBufNr,
    1322                                          lpDraw->dCaps.fccColorEncoding,
    1323                                          lpDDSurfaceDesc->dwWidth,
    1324                                          lpDDSurfaceDesc->dwHeight,
    1325                                          dwPitchDB,
    1326                                          (PBYTE)pDiveBuffer);
    1327                dprintf(("DDRAW: rc = 0x%08X\n",rc));
    1328             }
    1329             else
    1330             {
    1331               dprintf( ("with malloc (%dx%d) Pitch %d ",
    1332                         lpDDSurfaceDesc->dwHeight,
    1333                         lpDDSurfaceDesc->dwWidth,
    1334                         dwPitchDB));
    1335               // No so we must create the Divebuffer to do the colortranslation
    1336               // and blit to the real framebuffer on Unlock to do color conversion
    1337               pDBreal = (char*)malloc( lpDDSurfaceDesc->dwHeight *
    1338                                        dwPitchDB + 24);
    1339               pDiveBuffer = (char*)(((int)pDBreal + 7) & ~7); // align to QWORD
    1340             }
     1278            dwPitchDB = (DDSurfaceDesc.dwWidth * (lpDraw->dCaps.ulDepth/8) +7) & ~7;
     1279            dprintf( ("DDRAW:  Alloc CCBuf with malloc (%dx%d) Pitch %d ",
     1280                      DDSurfaceDesc.dwHeight,
     1281                      DDSurfaceDesc.dwWidth,
     1282                      dwPitchDB));
     1283            // No so we must create the Divebuffer to do the colortranslation
     1284            // and blit to the real framebuffer on Unlock to do color conversion
     1285            pDBreal = (char*)malloc( DDSurfaceDesc.dwHeight *
     1286                                     dwPitchDB + 24);
     1287            pDiveBuffer = (char*)(((int)pDBreal + 7) & ~7); // align to QWORD
    13411288            dprintf(( " @ %08X\n", pDiveBuffer));
     1289
     1290          }
     1291
     1292          if(Mainchain)
     1293          {
     1294            diveBufNr = 0;
     1295            rc = DiveAllocImageBuffer( hDive,
     1296                                       &diveBufNr,
     1297                                       lpDraw->dCaps.fccColorEncoding,
     1298                                       DDSurfaceDesc.dwWidth,
     1299                                       DDSurfaceDesc.dwHeight,
     1300                                       dwPitchDB,
     1301                                       (PBYTE)pDiveBuffer);
     1302             dprintf(("DDRAW: rc = 0x%08X\n",rc));
    13421303          }
    13431304
     
    13521313        // remove the flag
    13531314        dwCaps &= ~DDSCAPS_COMPLEX;
    1354         #ifdef DEBUG
    1355           dprintf(("DDRAW: Complex Surface\n"));
    1356         #endif
    1357 
    1358         if(lpDDSurfaceDesc->dwFlags & DDSD_BACKBUFFERCOUNT)
     1315        dprintf(("DDRAW: Complex Surface\n"));
     1316
     1317        if(DDSurfaceDesc.dwFlags & DDSD_BACKBUFFERCOUNT)
    13591318        {
    1360           lpDDSurfaceDesc->dwFlags &= ~DDSD_BACKBUFFERCOUNT;
    1361           #ifdef DEBUG
    1362             dprintf(("DDRAW: Backbuffer # = %d\n",lpDDSurfaceDesc->dwBackBufferCount));
    1363           #endif
    1364           memcpy(&ComplexSurfaceDesc,lpDDSurfaceDesc,sizeof(DDSURFACEDESC2));
     1319          dprintf(("DDRAW: Backbuffer # = %d\n",DDSurfaceDesc.dwBackBufferCount));
     1320
     1321          memcpy( &ComplexSurfaceDesc,
     1322                  &DDSurfaceDesc,
     1323                  sizeof(DDSURFACEDESC2));
     1324          ComplexSurfaceDesc.dwFlags        &= ~DDSD_BACKBUFFERCOUNT;
    13651325          ComplexSurfaceDesc.ddsCaps.dwCaps |= DDSCAPS_FLIP;        // set flip
    13661326          ComplexSurfaceDesc.ddsCaps.dwCaps &= ~DDSCAPS_BACKBUFFER; // remove backbuffer
     
    13881348
    13891349        // MipMap Surfaces are handled here
    1390         if( (lpDDSurfaceDesc->dwFlags & DDSD_MIPMAPCOUNT) &&
     1350        if( (DDSurfaceDesc.dwFlags & DDSD_MIPMAPCOUNT) &&
    13911351            (dwCaps & DDSCAPS_TEXTURE) &&
    13921352            (dwCaps & DDSCAPS_MIPMAP) )
     
    13941354          dwCaps &= ~ (DDSCAPS_TEXTURE | DDSCAPS_MIPMAP);
    13951355
    1396           lpDDSurfaceDesc->dwFlags &= ~DDSD_MIPMAPCOUNT;
    1397           #ifdef DEBUG
    1398             dprintf(("DDRAW: Mipmpa # = %d\n",lpDDSurfaceDesc->dwMipMapCount));
    1399           #endif
     1356          dprintf(("DDRAW: Mipmpa # = %d\n",DDSurfaceDesc.dwMipMapCount));
    14001357          memcpy( &ComplexSurfaceDesc,
    1401                   lpDDSurfaceDesc,
     1358                  &DDSurfaceDesc,
    14021359                  sizeof(DDSURFACEDESC2));
    14031360          ComplexSurfaceDesc.dwMipMapCount = 0;
    1404 
    1405           for(int i =0; i < lpDDSurfaceDesc->dwMipMapCount; i++)
     1361          ComplexSurfaceDesc.dwFlags &= ~DDSD_MIPMAPCOUNT;
     1362
     1363          for(int i =0; i < DDSurfaceDesc.dwMipMapCount; i++)
    14061364          {
    1407             #ifdef DEBUG
    1408               dprintf(("DDRAW: Creating MipMap %d\n",i));
    1409             #endif
     1365            dprintf(("DDRAW: Creating MipMap %d\n",i));
    14101366            // Mpmaps shirnk by 2
    14111367            ComplexSurfaceDesc.dwWidth  /= 2;
     
    14221378            {
    14231379              lastError = MipMapSurface->GetLastError();
    1424               #ifdef DEBUG
    1425                 dprintf(("DDRAW: Attached surface creation returned error %d\n",lastError));
    1426               #endif
     1380              dprintf(("DDRAW: Attached surface creation returned error %d\n",lastError));
    14271381              return;
    14281382            } // Endif Errorcheck
    1429           } //End for(i =0; i < lpDDSurfaceDesc->dwMipMapCount; i++)
     1383          } //End for(i =0; i < DDSurfaceDesc.dwMipMapCount; i++)
    14301384        } // End of MipMaps
    14311385
    1432         #ifdef DEBUG
    1433           if(lpDDSurfaceDesc->dwFlags)
     1386        #if 0
     1387          if(DDSurfaceDesc.dwFlags)
    14341388            dprintf(("DDRAW: Unsupported Complex Surface\n"));
    14351389        #endif
     
    14521406    {
    14531407      dprintf(("DDRAW: Some Error Check Flags\n"));
    1454       _dump_DDSCAPS(lpDDSurfaceDesc->dwFlags);
     1408      _dump_DDSCAPS(DDSurfaceDesc.dwFlags);
    14551409    }
    14561410  #endif
     
    14621416
    14631417  int i, FillWidth, FillHeight, Top, Left;
    1464   //char *pLine, *pFillPos;
    1465 
    1466   //DWORD *pColor, dwColor,y;
    14671418  DWORD *pPal24;
    14681419  WORD  *pPal16;
     
    15401491    dprintf(("DDRAW: ColorFill function is NULL!!"));
    15411492  }
    1542 /*
    1543   switch(dwBytesPPDive)
    1544   {
    1545     case 1:
    1546       dprintf(("DDRAW: 8 Bit\n"));
    1547       dwColor = (dwFillColor<<24) + (dwFillColor<<16) +
    1548                 (dwFillColor<<8)  + (dwFillColor);
    1549       for(i=0,pColor = (DWORD*)pLine;i<(FillWidth/4);i++)
    1550         pColor[i] = dwColor;
    1551       if(FillWidth % 4)
    1552       {
    1553          pFillPos = (char*) (&pColor[i-1]);
    1554         for(i=0;i<FillWidth % 4;i++)
    1555            pFillPos[i] = (UCHAR) dwColor;
    1556       }
    1557       break;
    1558     case 2:
    1559       dprintf(("DDRAW: 16 Bit\n"));
    1560       if(pDiveBuffer!=pFrameBuffer)
    1561       {
    1562         if(8==lpDraw->GetScreenBpp())
    1563           dwColor = (pPal16[dwFillColor]<<16) + pPal16[dwFillColor];
    1564       }
    1565       else
    1566       {
    1567         dwColor = (dwFillColor<<16) + (dwFillColor);
    1568       }
    1569       dprintf(("DDRAW: Fill with 0x%08X\n",dwColor));
    1570       for(i=0,pColor = (DWORD*)pLine;i<(FillWidth/2);i++)
    1571         pColor[i] = dwColor;
    1572       if(FillWidth % 2)
    1573       {
    1574          pFillPos = (char*)(&pColor[i-1]);
    1575         *((USHORT*)pFillPos) = (USHORT)dwColor;
    1576       }
    1577       break;
    1578     case 3:
    1579       dprintf(("DDRAW: 24 Bit\n"));
    1580 
    1581       dwColor = (dwFillColor<<8);
    1582       for(i=0 ; i<FillWidth ; i++)
    1583       {
    1584          char* pColor = (char*)pLine+(i*3);
    1585         *pColor = dwColor;
    1586       }
    1587       break;
    1588     case 4:
    1589       dprintf(("DDRAW: 32 Bit\n"));
    1590       dwColor = dwFillColor;
    1591       for(i=0,pColor = (DWORD*)pLine;i<FillWidth;i++)
    1592         pColor[i] = dwColor;
    1593       break;
    1594     default:
    1595       #ifdef DEBUG
    1596         dprintf(("DDRAW: Unexpected Bitdepth\n"));
    1597       #endif
    1598       return DDERR_GENERIC;
    1599   } // end switch(dest->DDSurfaceDesc.ddpfPixelFormat.dwRGBBitCount)
    1600 
    1601   // First Line has been Filled so FillHeight-1 are left by one
    1602   FillHeight--;
    1603   pFillPos = pLine + dwPitchDB;
    1604   FillWidth = FillWidth*dwBytesPPDive;
    1605 
    1606   for( y=0;y<FillHeight;y++,pFillPos+=dwPitchDB)
    1607   {
    1608     #ifdef USE_ASM
    1609       // ToDo get the loop into an asm function as well to speed up filling
    1610       // maybe remove the creation of the first fill line in an all asm
    1611       // function and use MMX regs to set 8 bytes
    1612       MemFlip(pFillPos,pLine,FillWidth);
    1613     #else
    1614       memcpy(pFillPos,pLine,FillWidth);
    1615     #endif
    1616   }
    1617 
    1618   if(pDiveBuffer!=pFrameBuffer)
    1619   {
    1620     dprintf(("DDRAW: CC-Mode Fill FrameBuffer %08X\n",pFrameBuffer));
    1621 
    1622     if(NULL!=lpDestRect)
    1623     {
    1624       dprintf(("DDRAW: Fill only Rect(%d,%d)(%d,%d)\n", lpDestRect->left, lpDestRect->top,
    1625                lpDestRect->right, lpDestRect->bottom));
    1626       FillWidth  = lpDestRect->right - lpDestRect->left;
    1627       FillHeight = lpDestRect->bottom - lpDestRect->top -1;
    1628       pLine = pFrameBuffer +
    1629               (lpDestRect->top*dwPitchFB) +
    1630               (lpDestRect->left*(lpDraw->GetScreenBpp()>>3));
    1631     }
    1632     else
    1633     {
    1634       dprintf(("DDRAW: Fill all at addr "));
    1635       FillWidth  = width;
    1636       FillHeight = height -1;
    1637       pLine = pFrameBuffer;
    1638     }
    1639     dprintf(("DDRAW: 0x%08X width,height(%d/%d) \n", pLine,FillWidth,FillHeight));
    1640 
    1641     // Colorconversion mode we must also fill the other buffer
    1642     switch(lpDraw->GetScreenBpp())
    1643     {
    1644       case 8:
    1645         dprintf(("DDRAW: 8 Bit\n"));
    1646         dwColor = (dwFillColor<<24) + (dwFillColor<<16) +
    1647                   (dwFillColor<<8)  + (dwFillColor);
    1648         dprintf(("DDRAW: Fill with %08X => 0x%08X\n",dwFillColor,dwColor));
    1649         for(i=0,pColor = (DWORD*)pLine;i<(FillWidth/4);i++)
    1650           pColor[i] = dwColor;
    1651         if(FillWidth % 4)
    1652         {
    1653           pFillPos = (char*) (&pColor[i-1]);
    1654           for(i=0;i<FillWidth % 4;i++)
    1655              pFillPos[i] = (UCHAR) dwColor;
    1656         }
    1657         break;
    1658       case 16:
    1659         dprintf(("DDRAW: 16 Bit\n"));
    1660         dwColor = (dwFillColor<<16) + (dwFillColor);
    1661         dprintf(("DDRAW: Fill with 0x%08X\n",dwColor));
    1662         for(i=0,pColor = (DWORD*)pLine;i<(FillWidth/2);i++)
    1663           pColor[i] = dwColor;
    1664         if(FillWidth % 2)
    1665         {
    1666            pFillPos = (char*)(&pColor[i-1]);
    1667           *((USHORT*)pFillPos) = (USHORT)dwColor;
    1668         }
    1669         break;
    1670       case 24:
    1671         dprintf(("DDRAW: 24 Bit\n"));
    1672         dwColor = (dwFillColor<<8);
    1673         for(i=0 ; i<FillWidth ; i++)
    1674         {
    1675            char* pColor = (char*)pLine+(i*3);
    1676           *pColor = dwColor;
    1677         }
    1678         break;
    1679       case 32:
    1680         dprintf(("DDRAW: 32 Bit\n"));
    1681         dwColor = dwFillColor;
    1682         for(i=0,pColor = (DWORD*)pLine;i<FillWidth;i++)
    1683           pColor[i] = dwColor;
    1684         break;
    1685       default:
    1686         dprintf(("DDRAW: Unsupported # of Bits %d",lpDraw->GetScreenBpp()));
    1687     }
    1688 
    1689     // First Line has been Filled so FillHeight-1 are left by one
    1690     FillHeight--;
    1691 
    1692     pFillPos = pLine + dwPitchFB;
    1693     FillWidth = FillWidth*(lpDraw->GetScreenBpp()>>3);
    1694     for( y=0;y<FillHeight;y++,pFillPos+=dwPitchFB)
    1695     {
    1696       #ifdef USE_ASM
    1697         // ToDo get the loop into an asm function as well to speed up filling
    1698         // maybe remove the creation of the first fill line in an all asm
    1699         // function and use MMX regs to set 8 bytes
    1700         MemFlip(pFillPos,pLine,FillWidth);
    1701       #else
    1702         memcpy(pFillPos,pLine,FillWidth);
    1703       #endif
    1704     }
    1705   }
    1706 */
     1493
    17071494  return(DD_OK);
    17081495}
     
    40513838  if(-1 != me->diveBufNr)
    40523839  {
    4053     dprintf(("DDRAW: DIVE Flipchain"));
     3840    dprintf(("DDRAW: DIVE Flipchain DiveBuffer #%d",FlipSurface->diveBufNr));
    40543841
    40553842    // we got some DIVE surfaces
     
    40673854    {
    40683855      // advance in the flipchain if no valid override surface was passed in
    4069       me->NextFlip = FlipSurface->BackBuffer!=NULL?FlipSurface->BackBuffer:me->BackBuffer;
     3856      // if we reached the end of the flipchain The Frontbuffer is the next to flip to
     3857      me->NextFlip = FlipSurface->BackBuffer!=NULL?FlipSurface->BackBuffer:me;//me->FrontBuffer;
    40703858    }
    40713859  }
     
    43714159      rc = DDERR_GENERIC;
    43724160    }
     4161    InverseDC(me->hdcImage, LockedSurfaceDesc.dwHeight);
    43734162  }
    43744163
     
    47474536      (NULL!=hEvent)
    47484537    )
     4538  {
     4539    dprintf(("DDERR_INVALIDPARAMS"));
    47494540    return DDERR_INVALIDPARAMS;
    4750 
     4541  }
    47514542
    47524543  if (NULL!=lpRect)
     
    50004791  OS2IDirectDrawSurface *me = (OS2IDirectDrawSurface *)This;
    50014792  HRESULT rc;
    5002   #ifdef DEBUG
    5003     dprintf(("DDRAW: SurfSetColorKey\n"));
    5004   #endif
     4793
     4794  dprintf(("DDRAW: SurfSetColorKey %d %08X\n", dwFlags, lpDDColKey));
    50054795
    50064796  if (0==dwFlags)
     4797  {
    50074798    return (DDERR_INVALIDPARAMS);
     4799  }
    50084800
    50094801  // as we report only src colorkey in the caps return error on all others flags
    50104802  if( (DDCKEY_DESTBLT|DDCKEY_DESTOVERLAY|DDCKEY_SRCOVERLAY|DDCKEY_COLORSPACE) & dwFlags)
     4803  {
     4804    dprintf(("Unspported colorkey\n"));
    50114805    return(DDERR_UNSUPPORTED);
     4806  }
    50124807
    50134808  if(DDCKEY_SRCBLT & dwFlags)
    50144809  {
     4810
    50154811    //(me->lpVtbl == me->Vtbl4)
    50164812    //  me->Vtbl4->ChangeUniquenessValue(me); // we changed somethin so change this value
    50174813    if(NULL!=lpDDColKey)
    50184814    {
     4815      dprintf(("copy colorkey"));
    50194816      memcpy(&(me->DDSurfaceDesc.ddckCKSrcBlt), lpDDColKey, sizeof(DDCOLORKEY) );
    50204817      me->DDSurfaceDesc.dwFlags |= DDCKEY_SRCBLT;
     
    50244821    else
    50254822    {
     4823      dprintf(("clear colorkey"));
    50264824      memset(&(me->DDSurfaceDesc.ddckCKSrcBlt), 0, sizeof(DDCOLORKEY) );
    50274825      me->DDSurfaceDesc.dwFlags &= ~DDCKEY_SRCBLT;
     
    50304828  }
    50314829  else
     4830  {
     4831    dprintf(("Unsupported flags"));
     4832    #ifdef DEBUG
     4833      _dump_DDCOLORKEY(dwFlags);
     4834    #endif
    50324835    rc = DDERR_INVALIDPARAMS; // some other flags where set => error
    5033 
     4836  }
    50344837  return rc;
    50354838}
     
    50994902  {
    51004903    me->lpPalette->Vtbl.Release((IDirectDrawPalette*)me->lpPalette);  //attach other palette
    5101     return(DD_OK);
     4904    //return(DD_OK);
    51024905  }
    51034906  me->lpPalette = (OS2IDirectDrawPalette *)lpPalette;
Note: See TracChangeset for help on using the changeset viewer.