Changeset 503 for trunk/src


Ignore:
Timestamp:
Aug 16, 1999, 2:40:48 AM (26 years ago)
Author:
hugh
Message:

Changed to use ODINCRT macros to preserve FS, but still does crash

Location:
trunk/src/ddraw
Files:
10 edited

Legend:

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

    r210 r503  
    88#include "misc.h"
    99#include <winerror.h>
     10#include <odincrt.h>
    1011
    1112//******************************************************************************
     
    8384    if(me->Referenced == 0)
    8485    {
    85       delete me;
     86      ODIN_delete( me);
    8687      return(0);
    8788    }
  • trunk/src/ddraw/OS2D3D.CPP

    r210 r503  
    1111#include <winerror.h>
    1212#include <builtin.h>
     13#include <odincrt.h>
    1314#undef THIS
    1415#define THIS VOID*
     
    2223
    2324  if(IID_IDirect3D != (GUID &)&riid)
    24   return E_NOINTERFACE;
     25    return E_NOINTERFACE;
    2526
    2627  *ppvObj = This;
     
    4647  dprintf(("OS2IDirectDraw::Release %d\n", me->Referenced-1));
    4748  dprintf(("OS2IDirectDraw::%X \n", me));
    48   if(me->Referenced) {
    49   me->Referenced--;
    50   if(me->Referenced == 0) {
    51     delete me;
     49  if(me->Referenced)
     50  {
     51    me->Referenced--;
     52    if(me->Referenced == 0)
     53    {
     54      ODIN_delete(me);
     55      return(0);
     56    }
     57    else
     58      return me->Referenced;
     59  }
     60  else
    5261    return(0);
    53   }
    54   else    return me->Referenced;
    55   }
    56   else  return(0);
    5762}
    5863//******************************************************************************
  • trunk/src/ddraw/OS2DDRAW.CPP

    r423 r503  
    2121#include "os2ddrawmodes.h"
    2222#include "os2DDWindow.h"
    23 
     23#include "os2palset.h"
     24#include <odincrt.h>
    2425#define KEY_DIRECT2 "\\Software\\Win32OS2\\Direct2"
    2526#define KEY_DIRECT2DRAW "\\Software\\Win32OS2\\Direct2\\Draw"
     
    3637  HKEY  hkDirectDraw2;
    3738  DWORD dwVSize, dwVType;
     39  ULONG rc;
    3840
    3941  // Setup table for 3d devices
     
    126128  }
    127129
    128   ULONG rc = DiveOpen( &hDive,
    129                        FALSE,
    130                        &pFrameBuffer);
     130  ODIN_FS_BEGIN
     131    rc = DiveOpen( &hDive,
     132                   FALSE,
     133                   &pFrameBuffer);
     134  ODIN_FS_END
    131135  if(rc)
    132136  {
     
    160164  if(hDive)
    161165    DiveClose(hDive);
     166  if(hDiveColorConv)
     167    DiveClose(hDiveColorConv);
     168
     169  // Safty call in case the program did set the pal to all black
     170  // so if the destructor gets called we might be able change this back
     171  OS2ResetPhysPalette();
    162172}
    163173//******************************************************************************
     
    199209  *ppvObj = This;
    200210  DrawAddRef(This);
     211
    201212  return(DD_OK);
    202213}
     
    218229{
    219230 OS2IDirectDraw *me = (OS2IDirectDraw *)This;
     231 ULONG rc;
    220232
    221233  #ifdef DEBUG
     
    230242    if(me->Referenced == 0)
    231243    {
    232       delete me;
    233       return(0);
     244      ODIN_delete(me);
     245      rc = 0;
    234246    }
    235247    else
    236       return me->Referenced;
     248      rc = me->Referenced;
    237249  }
    238250  else
    239     return(0);
     251    rc = 0;
     252
     253  return rc;
    240254}
    241255//******************************************************************************
     
    254268{
    255269 OS2IDirectDraw        *me = (OS2IDirectDraw *)This;
    256  OS2IDirectDrawClipper *newclip = new OS2IDirectDrawClipper(me);
     270 OS2IDirectDrawClipper *newclip;
    257271 HRESULT                rc;
    258272
     273 ODIN_FS_BEGIN
     274
     275  newclip = new OS2IDirectDrawClipper(me);
     276
    259277  #ifdef DEBUG
    260278    WriteLog("CreateClipper\n");
     
    262280
    263281  if(newclip == NULL)
    264     return(DDERR_OUTOFMEMORY);
    265 
    266   newclip->Vtbl.AddRef((IDirectDrawClipper *)newclip);
    267   rc = newclip->GetLastError();
    268   if(rc != DD_OK)
    269   {
    270     *lplpDD = NULL;
    271     delete newclip;
     282  {
     283    rc = DDERR_OUTOFMEMORY;
    272284  }
    273285  else
    274     *lplpDD = (IDirectDrawClipper *)newclip;
     286  {
     287    newclip->Vtbl.AddRef((IDirectDrawClipper *)newclip);
     288    rc = newclip->GetLastError();
     289    if(rc != DD_OK)
     290    {
     291      *lplpDD = NULL;
     292      delete newclip;
     293    }
     294    else
     295      *lplpDD = (IDirectDrawClipper *)newclip;
     296  }
     297
     298  ODIN_FS_END
    275299
    276300  return(rc);
     
    285309  OS2IDirectDraw        *me = (OS2IDirectDraw *)This;
    286310  OS2IDirectDrawPalette *newpal;
    287   HRESULT                rc;
     311  HRESULT                rc = DD_OK;
    288312  int                    palsize = 0;
    289313
     314  ODIN_FS_BEGIN
     315
    290316  if(dwFlags & DDPCAPS_8BITENTRIES)
    291317  {
    292318    // We Don't support Indexed palettes...
    293319
    294     return DDERR_INVALIDPARAMS;
     320    rc = DDERR_INVALIDPARAMS;
    295321  }
    296322
     
    305331
    306332  if(palsize == 0)
    307     return DDERR_INVALIDPARAMS;
    308 
    309   #ifdef DEBUG
    310     WriteLog("CreatePalette with %d colors\n", palsize);
    311   #endif
    312 
    313   newpal = new OS2IDirectDrawPalette(me, palsize, lpColorTable, dwFlags);
    314   if(newpal == NULL)
    315     return(DDERR_OUTOFMEMORY);
    316 
    317   newpal->Vtbl.AddRef((IDirectDrawPalette *)newpal);
    318   rc = newpal->GetLastError();
    319   if(rc != DD_OK)
    320   {
    321     *lplpDD = NULL;
    322     delete newpal;
    323   }
    324   else
    325     *lplpDD = (IDirectDrawPalette *)newpal;
     333    rc = DDERR_INVALIDPARAMS;
     334
     335  if(DD_OK == rc)
     336  {
     337    #ifdef DEBUG
     338      WriteLog("CreatePalette with %d colors\n", palsize);
     339    #endif
     340
     341    newpal = new OS2IDirectDrawPalette(me, palsize, lpColorTable, dwFlags);
     342
     343    if(newpal == NULL)
     344    {
     345      rc = DDERR_OUTOFMEMORY;
     346    }
     347    else
     348    {
     349      newpal->Vtbl.AddRef((IDirectDrawPalette *)newpal);
     350      rc = newpal->GetLastError();
     351
     352      if(DD_OK != rc)
     353      {
     354        *lplpDD = NULL;
     355        delete newpal;
     356      }
     357      else
     358        *lplpDD = (IDirectDrawPalette *)newpal;
     359    }
     360  }
     361
     362  ODIN_FS_END
    326363
    327364  return(rc);
     
    336373 OS2IDirectDrawSurface *newsurf;
    337374 HRESULT                rc;
     375
     376  ODIN_FS_BEGIN
    338377
    339378  #ifdef DEBUG
     
    351390
    352391  newsurf = new OS2IDirectDrawSurface(me, (LPDDSURFACEDESC2)lpDDSurfaceDesc);
    353 
    354392  if(newsurf == NULL)
    355     return(DDERR_OUTOFMEMORY);
    356 
    357   newsurf->Vtbl.AddRef((IDirectDrawSurface *)newsurf);
    358   rc = newsurf->GetLastError();
    359   if(rc != DD_OK)
    360   {
    361     WriteLog("Error createing Surface\n\n");
    362     *lplpDD = NULL;
    363     delete newsurf;
     393  {
     394    rc = DDERR_OUTOFMEMORY;
    364395  }
    365396  else
    366     *lplpDD = (IDirectDrawSurface *)newsurf;
    367 
    368   WriteLog("New Surface created at %08X\n\n", newsurf);
     397  {
     398    newsurf->Vtbl.AddRef((IDirectDrawSurface *)newsurf);
     399    rc = newsurf->GetLastError();
     400    if(rc != DD_OK)
     401    {
     402      WriteLog("Error createing Surface\n\n");
     403      *lplpDD = NULL;
     404      delete newsurf;
     405    }
     406    else
     407      *lplpDD = (IDirectDrawSurface *)newsurf;
     408
     409    WriteLog("New Surface created at %08X\n\n", newsurf);
     410  }
     411
     412  ODIN_FS_END
     413
    369414  return(rc);
    370415}
     
    379424 HRESULT                rc;
    380425
    381 #ifdef DEBUG
    382   WriteLog("CreateSurface4\n");
    383   WriteLog("dwSize %d\n", lpDDSurfaceDesc2->dwSize);
    384   WriteLog("dwHeight %d\n", lpDDSurfaceDesc2->dwHeight);
    385   WriteLog("dwWidth %d\n", lpDDSurfaceDesc2->dwWidth);
    386   WriteLog("lPitch %d\n", lpDDSurfaceDesc2->lPitch);
    387   WriteLog("dwBackBufferCount %d\n", lpDDSurfaceDesc2->dwBackBufferCount);
    388   WriteLog("dwMipMapCount %d\n", lpDDSurfaceDesc2->dwMipMapCount);
    389   WriteLog("dwAlphaBitDepth %d\n", lpDDSurfaceDesc2->dwAlphaBitDepth);
    390   WriteLog("ddsCaps.dwCaps %X\n", lpDDSurfaceDesc2->ddsCaps.dwCaps);
    391 #endif
     426  ODIN_FS_BEGIN
     427
     428  #ifdef DEBUG
     429    WriteLog("CreateSurface4\n");
     430    WriteLog("dwSize %d\n", lpDDSurfaceDesc2->dwSize);
     431    WriteLog("dwHeight %d\n", lpDDSurfaceDesc2->dwHeight);
     432    WriteLog("dwWidth %d\n", lpDDSurfaceDesc2->dwWidth);
     433    WriteLog("lPitch %d\n", lpDDSurfaceDesc2->lPitch);
     434    WriteLog("dwBackBufferCount %d\n", lpDDSurfaceDesc2->dwBackBufferCount);
     435    WriteLog("dwMipMapCount %d\n", lpDDSurfaceDesc2->dwMipMapCount);
     436    WriteLog("dwAlphaBitDepth %d\n", lpDDSurfaceDesc2->dwAlphaBitDepth);
     437    WriteLog("ddsCaps.dwCaps %X\n", lpDDSurfaceDesc2->ddsCaps.dwCaps);
     438  #endif
    392439
    393440  newsurf = new OS2IDirectDrawSurface(me, lpDDSurfaceDesc2);
    394441
    395442  if(newsurf == NULL)
    396     return(DDERR_OUTOFMEMORY);
    397 
    398   newsurf->Vtbl.AddRef((IDirectDrawSurface *)newsurf);
    399   rc = newsurf->GetLastError();
    400   if(rc != DD_OK)
    401   {
    402     WriteLog("Error createing Surface\n\n");
    403     *lplpDD = NULL;
    404     delete newsurf;
     443  {
     444    rc =DDERR_OUTOFMEMORY;
    405445  }
    406446  else
    407     *lplpDD = (IDirectDrawSurface4 *)newsurf;
    408 
    409   WriteLog("New Surface created at %08X\n\n", newsurf);
     447  {
     448    newsurf->Vtbl.AddRef((IDirectDrawSurface *)newsurf);
     449    rc = newsurf->GetLastError();
     450    if(rc != DD_OK)
     451    {
     452      WriteLog("Error createing Surface\n\n");
     453      *lplpDD = NULL;
     454
     455      delete newsurf;
     456    }
     457    else
     458      *lplpDD = (IDirectDrawSurface4 *)newsurf;
     459
     460    WriteLog("New Surface created at %08X\n\n", newsurf);
     461  }
     462
     463  ODIN_FS_END
    410464
    411465  return(rc);
     
    416470{
    417471  #ifdef DEBUG
    418     WriteLog("DuplicateSurface\n");
     472    WriteLog("DuplicateSurface NIY\n");
    419473  #endif
    420474  return(DD_OK);
     
    425479{
    426480  #ifdef DEBUG
    427     WriteLog("DuplicateSurface\n");
     481    WriteLog("DuplicateSurface4 NIY\n");
    428482  #endif
    429483
     
    454508  }
    455509
     510
     511  ODIN_FS_BEGIN
    456512
    457513  // Setting up the surface
     
    481537        DDSurfAct.ddpfPixelFormat.dwRGBBitCount = ModesDive[0].iBits;
    482538        if(!lpDDEnumModesCallback(&DDSurfAct,lpContext))
     539        {
     540          {ODIN_FS_END
    483541          return (DD_OK);
     542        }
    484543      }
    485544      // Don't know the flag for Mode X so we skip reporting it
     
    550609        DDSurfAct.ddpfPixelFormat.dwRGBBitCount = ModesDive[0].iBits;
    551610        if(!lpDDEnumModesCallback(&DDSurfAct,lpContext))
     611        {
     612          {ODIN_FS_END
    552613          return (DD_OK);
     614        }
    553615      }
    554616      // Don't know the flag for Mode X so we skip reporting it
     
    619681
    620682      if (lpDDSurfaceDesc->dwFlags & !(DDSD_WIDTH|DDSD_HEIGHT|DDSD_PIXELFORMAT))
     683      {
     684        {ODIN_FS_END
    621685        return(DDERR_INVALIDPARAMS);
     686      }
    622687
    623688      iMode = 2;
     
    652717  }
    653718
     719  ODIN_FS_END
     720
    654721  return(DD_OK);
    655722}
     
    665732
    666733  #ifdef DEBUG
    667     WriteLog("EnumDisplayModes4\n");
     734    WriteLog("EnumDisplayModes4 NIY\n");
    668735  #endif
    669736  return(DD_OK);
     
    674741{
    675742  #ifdef DEBUG
    676     WriteLog("EnumSurfaces\n");
     743    WriteLog("EnumSurfaces NIY\n");
    677744  #endif
    678745
     
    684751{
    685752  #ifdef DEBUG
    686     WriteLog("EnumSurfaces4\n");
     753    WriteLog("EnumSurfaces4 NIY\n");
    687754  #endif
    688755
     
    694761{
    695762  #ifdef DEBUG
    696     WriteLog("FlipToGDISurface\n");
     763    WriteLog("FlipToGDISurface NIY\n");
    697764  #endif
    698765
     
    718785
    719786    // Clear structure so we only have to set the supported flags
     787
     788    ODIN_FS_BEGIN
    720789    memset(lpDDDriverCaps,0,sizeof(DDCAPS));
     790    ODIN_FS_END
    721791
    722792    // Reset the size
     
    10631133{
    10641134  #ifdef DEBUG
    1065     WriteLog("GetGDISurface\n");
     1135    WriteLog("GetGDISurface NYI\n");
    10661136  #endif
    10671137
     
    10731143{
    10741144  #ifdef DEBUG
    1075     WriteLog("GetGDISurface\n");
     1145    WriteLog("GetGDISurface NYI\n");
    10761146  #endif
    10771147
     
    10891159  if(NULL==lpdwFreq)
    10901160    return(DDERR_INVALIDPARAMS);
     1161
     1162  ODIN_FS_BEGIN
    10911163
    10921164  if(DD_OK==DrawWaitForVerticalBlank(This, dwFlags, 0))
     
    11101182    *lpdwFreq = 70;
    11111183  }
     1184
     1185  ODIN_FS_END
     1186
    11121187  return(DD_OK);
    11131188}
     
    11401215HRESULT __stdcall DrawGetVerticalBlankStatus(THIS , LPBOOL lpbIsInVB)
    11411216{
     1217  int rc;
    11421218  #ifdef DEBUG
    11431219    WriteLog("GetVerticalBlankStatus\n");
     
    11451221  if(NULL==lpbIsInVB)
    11461222    return(DDERR_INVALIDPARAMS);
    1147   if(0==io_init1())  // try to get IOPL for the thread
     1223
     1224  ODIN_FS_BEGIN
     1225    rc = io_init1();
     1226  ODIN_FS_END
     1227
     1228  if(0==rc)  // try to get IOPL for the thread
    11481229  {
    11491230    *lpbIsInVB = (c_inb1(0x3da)&0x08)!=0;
    1150     io_exit1(); // reset IOPL
     1231    ODIN_FS_BEGIN
     1232      io_exit1(); // reset IOPL
     1233    ODIN_FS_END
    11511234    return(DD_OK);
    11521235  }
     
    11861269  me->hwndClient = hwndClient;
    11871270  #if 0
    1188   OS2DDSubclassWindow(hwndClient);
     1271    OS2DDSubclassWindow(hwndClient);
    11891272  #endif
    11901273  return(DD_OK);
     
    12001283 OS2IDirectDraw        *me = (OS2IDirectDraw *)This;
    12011284
    1202 #ifdef DEBUG
    1203   WriteLog("SetDisplayMode2 to %dx%d with %d bits colors\n", dwWidth, dwHeight, dwBPP);
    1204 #endif
     1285  #ifdef DEBUG
     1286    WriteLog("SetDisplayMode2 to %dx%d with %d bits colors\n", dwWidth, dwHeight, dwBPP);
     1287  #endif
     1288
    12051289  me->screenwidth  = dwWidth;
    12061290  me->screenheight = dwHeight;
     
    12471331{
    12481332  HRESULT rc;
     1333  int rci;
     1334
    12491335  #ifdef DEBUG
    12501336    WriteLog("WaitForVerticalBlank\n");
     
    12541340    return (DDERR_UNSUPPORTED);
    12551341
    1256   if(io_init1())  // try to get IOPL for the thread
     1342  ODIN_FS_BEGIN
     1343    rci = io_init1();
     1344  ODIN_FS_END
     1345
     1346  if(rci)  // try to get IOPL for the thread
    12571347    return (DDERR_UNSUPPORTED);  // we failed so return error that we don't support this
    12581348
     
    12831373  }
    12841374
    1285   io_exit1();
     1375  ODIN_FS_BEGIN
     1376    io_exit1();
     1377  ODIN_FS_END
    12861378
    12871379  return (rc);
     
    13441436{
    13451437  #ifdef DEBUG
    1346     WriteLog("GetSurfaceFromDC Unimplemented Stub\n");
     1438    WriteLog("GetSurfaceFromDC NYI\n");
    13471439  #endif
    13481440
     
    13791471  if(NULL==lpdddi)
    13801472    return DDERR_INVALIDPARAMS;
     1473
     1474  ODIN_FS_BEGIN
    13811475
    13821476  memset( lpdddi,
     
    13881482  strcpy( lpdddi->szDescription,
    13891483          "ODIN DD Emulation Driver");
     1484
     1485  ODIN_FS_END
     1486
    13901487  return(DD_OK);
    13911488}
     
    13961493  DWORD dwVType, dwVSize;
    13971494  HKEY hkDirectDraw2;
     1495
     1496  ODIN_FS_BEGIN
    13981497
    13991498  if (bScale)
     
    14101509      bScale = FALSE;
    14111510  }
    1412 }
    1413 //******************************************************************************
    1414 //******************************************************************************
    1415 
     1511
     1512  ODIN_FS_END
     1513}
     1514//******************************************************************************
     1515//******************************************************************************
     1516
  • trunk/src/ddraw/OS2PALETTE.CPP

    r210 r503  
    1010#include "os2palset.h"
    1111#include <winerror.h>
     12#include <odincrt.h>
    1213
    1314//******************************************************************************
     
    9697    if(me->Referenced == 0)
    9798    {
    98       delete me;
     99      ODIN_delete(me);
    99100      return(0);
    100101    }
     
    141142    return(DDERR_INVALIDPARAMS);
    142143
     144  ODIN_FS_BEGIN
     145
    143146  memcpy( (char *)lpEntries,
    144147          (char *)(me->os2pal + dwBase),
    145148          dwNumEntries*sizeof(PALETTEENTRY));
     149
     150  ODIN_FS_END
     151
    146152  return(DD_OK);
    147153}
     
    169175  if( (NULL== lpNewEntries) ||(0!=dwFlags) ||(dwBase<0) ||((dwBase + dwNumEntries)>me->dwSize) )
    170176    return(DDERR_INVALIDPARAMS);
     177
     178  ODIN_FS_BEGIN
     179
    171180  memcpy((char *)(me->os2pal + dwBase),
    172181         (char *)lpNewEntries,
    173182         dwNumEntries*sizeof(PALETTEENTRY));
     183
     184  ODIN_FS_END
    174185
    175186  if(me->fAttachedToPrimary)
  • trunk/src/ddraw/OS2PALSET.CPP

    r210 r503  
    77#include <string.h>
    88#include "os2palset.h"
    9 #define FAR
    10 #include "misc.h"
    11 
     9#include <odincrt.h>
    1210//******************************************************************************
    1311//******************************************************************************
     
    1917 RGB2 os2rgb[256];
    2018 int  i;
     19
     20  ODIN_FS_BEGIN
    2121
    2222  hps = WinGetPS(HWND_DESKTOP);
     
    4444                     TRUE);
    4545  WinReleasePS(hps);
     46
     47  ODIN_FS_END
     48
    4649}
    4750//******************************************************************************
     
    5154 HPS hps;
    5255 HDC hdc;
     56
     57  ODIN_FS_BEGIN
    5358
    5459  hps = WinGetPS( HWND_DESKTOP);
     
    6570
    6671  WinReleasePS(hps);
     72
     73  ODIN_FS_END
     74
    6775}
    6876//******************************************************************************
  • trunk/src/ddraw/OS2SURFACE.CPP

    r423 r503  
    1313#include "asmutil.h"
    1414#include <winerror.h>
     15#include <odincrt.h>
     16
    1517#ifndef __WATCOMC__
    16 #include <builtin.h>
     18  #include <builtin.h>
    1719#endif
    1820
     
    992994  pFillPos = pLine + dwPitchDB;
    993995
     996  #ifndef USE_ASM
     997    ODIN_FS_BEGIN
     998  #endif
    994999  for( y=0;y<FillHeight;y++,pFillPos+=dwPitchDB)
    9951000  {
     
    10031008    #endif
    10041009  }
     1010  #ifndef USE_ASM
     1011    ODIN_FS_END
     1012  #endif
    10051013
    10061014  return(DD_OK);
     
    12251233int  DestroyRects(LPVOID lpItem, DWORD dwRes)
    12261234{
    1227   delete (DDRectangle*) lpItem;
     1235  DDRectangle *pItem = (DDRectangle*) lpItem;
     1236  ODIN_delete(pItem);
    12281237  return 1;
    12291238}
     
    12431252  OS2IDirectDrawSurface  *AttachedSurface;
    12441253
     1254  ODIN_FS_BEGIN
     1255
    12451256  if(DDSurfaceDesc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
    12461257  {
     
    13171328
    13181329  lpDraw->Vtbl.Release(lpDraw);
     1330
     1331  ODIN_FS_END
     1332
    13191333}
    13201334//******************************************************************************
     
    14061420    if(me->Referenced == 0)
    14071421    {
    1408       delete me;
     1422      ODIN_delete( me);
    14091423      #ifndef __WATCOMC__
    14101424        //_interrupt(3);
     
    14351449  OS2IDirectDrawSurface *BBCursor;
    14361450  OS2IDirectDrawSurface *me = (OS2IDirectDrawSurface *)This;
     1451  int rc;
     1452
    14371453  #ifdef DEBUG
    14381454    WriteLog("SurfAddAttachedSurface4\n");
     
    14661482      if(me->DDSurfaceDesc.ddsCaps.dwCaps & DDSCAPS_MIPMAP)
    14671483      {
    1468         if( DPA_InsertPtr( me->DPA_SurfaceMipMaps,
    1469                            DPA_GetPtrCount(me->DPA_SurfaceMipMaps),
    1470                            AttachedSurface) >=0)
     1484        ODIN_FS_BEGIN
     1485          rc = DPA_InsertPtr( me->DPA_SurfaceMipMaps,
     1486                              DPA_GetPtrCount(me->DPA_SurfaceMipMaps),
     1487                              AttachedSurface);
     1488        ODIN_FS_END
     1489
     1490        if( rc>=0)
    14711491        {
    14721492          me->DDSurfaceDesc.dwFlags |= DDSD_MIPMAPCOUNT;
     
    14931513    else
    14941514    {
    1495       if( DPA_InsertPtr( me->DPA_SurfaceAttached,
    1496                          DPA_GetPtrCount(me->DPA_SurfaceAttached),
    1497                          AttachedSurface) >=0)
     1515      ODIN_FS_BEGIN
     1516        rc = DPA_InsertPtr( me->DPA_SurfaceAttached,
     1517                            DPA_GetPtrCount(me->DPA_SurfaceAttached),
     1518                            AttachedSurface);
     1519      ODIN_FS_END
     1520
     1521      if(rc>=0)
    14981522      {
    14991523        AttachedSurface->Vtbl.AddRef(AttachedSurface);
     
    16871711  #endif
    16881712
     1713  ODIN_FS_BEGIN
     1714
    16891715  if (NULL!=lpDestRect)
    16901716  {
     
    17341760        WriteLog("Blt: Dest Surface partly locked\n");
    17351761      #endif
     1762      {ODIN_FS_END
    17361763      return(DDERR_SURFACEBUSY);
    17371764    }
    17381765  }
     1766
     1767  ODIN_FS_END
    17391768
    17401769  DestSurfaceDesc.dwSize = sizeof(DDSURFACEDESC2);
     
    18241853  }
    18251854
     1855  ODIN_FS_BEGIN
     1856
    18261857  if (NULL!=lpSrcRect)
    18271858  {
     
    18721903        WriteLog("Blt: Src Surface partly locked\n");
    18731904      #endif
     1905      {ODIN_FS_END
    18741906      return(DDERR_SURFACEBUSY);
    18751907    }
    18761908  }
     1909
     1910  ODIN_FS_END
    18771911
    18781912  if( ( (NULL==lpDestRect) && (NULL!=lpSrcRect) ) ||
     
    19571991        #else
    19581992        // Solid Blit
     1993        ODIN_FS_BEGIN
    19591994        while(1)
    19601995        {
     
    19652000            break;
    19662001        }
     2002        ODIN_FS_END
    19672003        #endif
    19682004      }
     
    19722008        if( (dwFlags &DDBLT_KEYSRC) || (dwFlags & DDBLT_KEYSRCOVERRIDE) )
    19732009        {
     2010          WriteLog("Transparent src blit not done yet for primary!!");
    19742011        }
    19752012        else
     
    20182055          #else
    20192056          // Solid Blit
     2057          ODIN_FS_BEGIN
    20202058          while(1)
    20212059          {
     
    20262064              break;
    20272065          }
     2066          ODIN_FS_END
    20282067          #endif
    20292068        }
    20302069        else
    20312070        {
     2071          WriteLog("Transblt not done yet");
    20322072          if(dwFlags & DDBLT_KEYSRC)
    20332073          {
     
    20882128        #else
    20892129        // Solid Blit
     2130        ODIN_FS_BEGIN
    20902131        while(1)
    20912132        {
     
    20962137            break;
    20972138        }
     2139        ODIN_FS_END
    20982140        #endif
    20992141      }
     
    25022544{
    25032545  #ifdef DEBUG
    2504     WriteLog("SurfBltFast\n");
     2546    WriteLog("SurfBltFast NIY\n");
    25052547  #endif
    25062548
     
    25342576    return DDERR_INVALIDPARAMS;
    25352577  }
     2578
     2579  ODIN_FS_BEGIN
    25362580
    25372581  if (NULL!=lpSrcRect)
     
    28352879  dest->lpVtbl->ChangeUniquenessValue(dest);
    28362880
     2881  ODIN_FS_END
     2882
    28372883  return(DD_OK);
    28382884}
     
    29543000  }
    29553001
     3002  ODIN_FS_BEGIN
     3003
    29563004  if ( (!Found) && (AttachedSurface->DDSurfaceDesc.ddsCaps.dwCaps &  DDSCAPS_MIPMAP ) )
    29573005  {
     
    29923040  }
    29933041
     3042  ODIN_FS_END
     3043
    29943044  return(Found?DD_OK:DDERR_SURFACENOTATTACHED);
    29953045}
     
    30123062  OS2IDirectDrawSurface *EnumSurface;
    30133063  DDSURFACEDESC2         EnumDesc;
    3014   int i;
     3064  int i,count;
    30153065  HRESULT rc;
    30163066
     
    30233073  rc = DDENUMRET_OK;
    30243074
     3075
    30253076  if(me->BackBuffer != NULL)
    30263077  {
    3027     memcpy(&EnumDesc,&(me->DDSurfaceDesc),sizeof(DDSURFACEDESC2));
     3078    ODIN_FS_BEGIN
     3079      memcpy(&EnumDesc,&(me->DDSurfaceDesc),sizeof(DDSURFACEDESC2));
     3080    ODIN_FS_END
    30283081    rc = lpCallBack((LPDIRECTDRAWSURFACE4)me->BackBuffer,&EnumDesc,lpContext);
    30293082  }
    30303083
    3031   if(DPA_GetPtrCount(me->DPA_SurfaceMipMaps)>0)
     3084  ODIN_FS_BEGIN
     3085    count = DPA_GetPtrCount(me->DPA_SurfaceMipMaps);
     3086  ODIN_FS_END
     3087
     3088  if(count>0)
    30323089  {
    30333090    i=0;
    3034     while( (DDENUMRET_OK == rc) && i<DPA_GetPtrCount(me->DPA_SurfaceMipMaps) )
    3035     {
    3036       EnumSurface = (OS2IDirectDrawSurface*) DPA_FastGetPtr(me->DPA_SurfaceMipMaps,i);
    3037       memcpy(&EnumDesc,&(EnumSurface->DDSurfaceDesc),sizeof(DDSURFACEDESC2));
     3091    while( (DDENUMRET_OK == rc) && i<count )
     3092    {
     3093      ODIN_FS_BEGIN
     3094        EnumSurface = (OS2IDirectDrawSurface*) DPA_FastGetPtr(me->DPA_SurfaceMipMaps,i);
     3095        memcpy( &EnumDesc,
     3096                &(EnumSurface->DDSurfaceDesc),
     3097                sizeof(DDSURFACEDESC2));
     3098      ODIN_FS_END
     3099      // Calling back into WIN32 app so we had to reset FS
    30383100      rc = lpCallBack((LPDIRECTDRAWSURFACE4)EnumSurface,&EnumDesc,lpContext);
    30393101      i++;
     
    30413103  }
    30423104
    3043   if(DPA_GetPtrCount(me->DPA_SurfaceAttached)>0)
     3105  ODIN_FS_BEGIN
     3106    count = DPA_GetPtrCount(me->DPA_SurfaceAttached);
     3107  ODIN_FS_END
     3108
     3109  if(count>0)
    30443110  {
    30453111    i=0;
    3046     while( (DDENUMRET_OK == rc) && i<DPA_GetPtrCount(me->DPA_SurfaceAttached) )
    3047     {
    3048       EnumSurface = (OS2IDirectDrawSurface*) DPA_FastGetPtr(me->DPA_SurfaceAttached,i);
    3049       memcpy(&EnumDesc,&(EnumSurface->DDSurfaceDesc),sizeof(DDSURFACEDESC2));
     3112    while( (DDENUMRET_OK == rc) && i<count )
     3113    {
     3114      ODIN_FS_BEGIN
     3115        EnumSurface = (OS2IDirectDrawSurface*) DPA_FastGetPtr(me->DPA_SurfaceAttached,i);
     3116        memcpy( &EnumDesc,
     3117                &(EnumSurface->DDSurfaceDesc),
     3118                sizeof(DDSURFACEDESC2));
     3119      ODIN_FS_END
    30503120      rc = lpCallBack((LPDIRECTDRAWSURFACE4)EnumSurface,&EnumDesc,lpContext);
    30513121      i++;
     
    32203290  OS2IDirectDrawSurface *EnumSurface = NULL;
    32213291  OS2IDirectDrawSurface *AttachedSurface = NULL;
     3292  HRESULT rc;
    32223293  int i;
    32233294
     
    32343305  }
    32353306
    3236   if( (me->BackBuffer!=NULL) && (me->BackBuffer->DDSurfaceDesc.ddsCaps.dwCaps & lpDDCaps->dwCaps) )
     3307  ODIN_FS_BEGIN
     3308
     3309  rc = DD_OK;
     3310
     3311  if( (me->BackBuffer!=NULL) &&
     3312      (me->BackBuffer->DDSurfaceDesc.ddsCaps.dwCaps & lpDDCaps->dwCaps) )
    32373313  {
    32383314    WriteLog("Return Backbuffer\n");
     
    32513327          AttachedSurface = EnumSurface;
    32523328        else
    3253           return(DDERR_NOTFOUND); // Not sure if this is the right return value,
     3329          rc = DDERR_NOTFOUND; // Not sure if this is the right return value,
    32543330                                  // but function must fail if more then one surface fits
    32553331
     
    32703346          AttachedSurface = EnumSurface;
    32713347        else
    3272           return(DDERR_NOTFOUND); // Not sure if this is the right return value,
     3348          rc = DDERR_NOTFOUND; // Not sure if this is the right return value,
    32733349                                  // but function must fail if more then one surface fits
    32743350
     
    32783354  }
    32793355
    3280   if(NULL!=AttachedSurface)
     3356  if( (DD_OK==rc) &&
     3357      (NULL!=AttachedSurface) )
    32813358  {
    32823359    *lpDDSurf = (IDirectDrawSurface4*)AttachedSurface;
    32833360    // not sure but as we returned an reference rains usage count
    32843361    AttachedSurface->lpVtbl->AddRef(AttachedSurface);
    3285     return(DD_OK);
    32863362  }
    32873363  else
     3364  {
    32883365    *lpDDSurf = NULL;
    3289 
    3290   return(DDERR_NOTFOUND);
     3366    rc = DDERR_NOTFOUND;
     3367  }
     3368
     3369  ODIN_FS_END
     3370
     3371  return rc;
    32913372}
    32923373//******************************************************************************
     
    33293410    return(DDERR_INVALIDPARAMS);
    33303411
    3331   memcpy(lpDDCaps, &(me->DDSurfaceDesc.ddsCaps), sizeof(DDSCAPS2) );
     3412  ODIN_FS_BEGIN
     3413    memcpy(lpDDCaps, &(me->DDSurfaceDesc.ddsCaps), sizeof(DDSCAPS2) );
     3414  ODIN_FS_END
    33323415
    33333416  return(DD_OK);
     
    33723455    if(DDCKEY_SRCBLT & dwFlags)
    33733456    {
    3374       memcpy(lpDDColKey,&(me->DDSurfaceDesc.ddckCKSrcBlt),sizeof(DDCOLORKEY) );
     3457      ODIN_FS_BEGIN
     3458        memcpy(lpDDColKey,&(me->DDSurfaceDesc.ddckCKSrcBlt),sizeof(DDCOLORKEY) );
     3459      ODIN_FS_END
    33753460    }
    33763461    else
     
    33883473 OS2IDirectDrawSurface *me = (OS2IDirectDrawSurface *)This;
    33893474 DDSURFACEDESC2        LockedSurfaceDesc;
    3390 
     3475 HRESULT rc;
    33913476 struct
    33923477 {
     
    34093494  }
    34103495
     3496  ODIN_FS_BEGIN
     3497
     3498  rc = DD_OK;
     3499
    34113500  if(me->hdcImage == NULL)
    34123501  {
     
    34193508      #endif
    34203509      me->Vtbl.Unlock(me,NULL);
    3421       return(DDERR_GENERIC);
    3422     }
    3423   }
    3424 
    3425   if(me->hbmImage == NULL)
     3510      rc = DDERR_GENERIC;
     3511    }
     3512  }
     3513
     3514  if( (DD_OK==rc) &&
     3515      (me->hbmImage == NULL) )
    34263516  {
    34273517    memset(&BitmapInfo, 0, sizeof(BitmapInfo));
     
    34753565      me->hdcImage = NULL;
    34763566      me->Vtbl.Unlock(me,NULL);
    3477       return(DDERR_GENERIC);
     3567      rc = DDERR_GENERIC;
    34783568    }
    34793569  }
    34803570  else
    34813571  {
    3482     if(me->dwLastDCUnique != me->dwUniqueValue)
     3572    if( (DD_OK==rc) &&
     3573        (me->dwLastDCUnique != me->dwUniqueValue) )
    34833574    {
    34843575      #ifdef DEBUG
     
    35283619  }
    35293620
    3530   // Allways selct the bitmap into the DC! No matter if the old or a new one
    3531 
    3532   if((me->hgdiOld = SelectObject(me->hdcImage, me->hbmImage)) == NULL)
    3533   {
    3534     #ifdef DEBUG
    3535       WriteLog("Can't select bitmap into dc!\n");
    3536     #endif
    3537     DeleteDC(me->hdcImage);
    3538     me->hdcImage = NULL;
    3539     DeleteObject(me->hbmImage);
    3540     me->hbmImage = NULL;
    3541     me->Vtbl.Unlock(me,NULL);
    3542     return(DDERR_GENERIC);
    3543   }
    3544 
    3545   *hdc = me->hdcImage;
    3546 
    3547   return(DD_OK);
     3621  // Allways select the bitmap into the DC! No matter if the old or a new one
     3622
     3623  if(DD_OK==rc)
     3624  {
     3625    if((me->hgdiOld = SelectObject(me->hdcImage, me->hbmImage)) == NULL)
     3626    {
     3627      #ifdef DEBUG
     3628        WriteLog("Can't select bitmap into dc!\n");
     3629      #endif
     3630      DeleteDC(me->hdcImage);
     3631      me->hdcImage = NULL;
     3632      DeleteObject(me->hbmImage);
     3633      me->hbmImage = NULL;
     3634      me->Vtbl.Unlock(me,NULL);
     3635      rc = DDERR_GENERIC;
     3636    }
     3637    else
     3638    {
     3639      *hdc = me->hdcImage;
     3640    }
     3641  }
     3642
     3643  ODIN_FS_END
     3644
     3645  return rc;
    35483646}
    35493647//******************************************************************************
     
    36193717    return DDERR_INVALIDPARAMS;
    36203718
    3621   memcpy((char*)lpPixelFormat,(char*)&(me->DDSurfaceDesc.ddpfPixelFormat), sizeof(DDPIXELFORMAT));
     3719  ODIN_FS_BEGIN
     3720    memcpy( (char*)lpPixelFormat,
     3721            (char*)&(me->DDSurfaceDesc.ddpfPixelFormat),
     3722            sizeof(DDPIXELFORMAT));
     3723  ODIN_FS_END
     3724
    36223725
    36233726  return(DD_OK);
     
    36363739    return(DDERR_INVALIDPARAMS);
    36373740
    3638   memcpy((char *)lpSurface, (char *)&me->DDSurfaceDesc, sizeof(DDSURFACEDESC));
     3741  ODIN_FS_BEGIN
     3742    memcpy( (char *)lpSurface,
     3743            (char *)&me->DDSurfaceDesc,
     3744            sizeof(DDSURFACEDESC));
     3745  ODIN_FS_END
    36393746
    36403747  return(DD_OK);
     
    36533760    return(DDERR_INVALIDPARAMS);
    36543761
    3655   memcpy((char *)lpSurface, (char *)&me->DDSurfaceDesc, sizeof(DDSURFACEDESC2));
     3762  ODIN_FS_BEGIN
     3763    memcpy( (char *)lpSurface,
     3764            (char *)&me->DDSurfaceDesc,
     3765            sizeof(DDSURFACEDESC2));
     3766  ODIN_FS_END
    36563767
    36573768  return(DD_OK);
     
    37143825  SurfaceDesc4.dwSize = sizeof(DDSURFACEDESC2);
    37153826
    3716   rc = SurfLock4(This, lpRect, &SurfaceDesc4, dwFlags, hEvent);
     3827  rc = SurfLock4( This,
     3828                  lpRect,
     3829                  &SurfaceDesc4,
     3830                  dwFlags,
     3831                  hEvent);
    37173832  if (DD_OK==rc)
    37183833  {
    3719     memcpy((char*)lpSurfaceDesc,(char*)&SurfaceDesc4, sizeof(DDSURFACEDESC) );
     3834    ODIN_FS_BEGIN
     3835      memcpy( (char*)lpSurfaceDesc,
     3836              (char*)&SurfaceDesc4,
     3837              sizeof(DDSURFACEDESC) );
     3838    ODIN_FS_END
    37203839  }
    37213840
     
    37353854
    37363855  BOOL Found;
    3737   ULONG  nrScanLines, rc;
     3856  ULONG  nrScanLines;
    37383857  char *pBuffer;
    37393858  DDRectangle *pIRectCurrent,*pIRectNew;
    37403859  static int times = 0;
     3860  HRESULT rc;
    37413861
    37423862  #ifdef DEBUG
     
    37483868    )
    37493869    return DDERR_INVALIDPARAMS;
     3870
     3871  ODIN_FS_BEGIN
    37503872
    37513873  if (NULL!=lpRect)
     
    37603882            pIRectNew->Bottom(),
    37613883            pIRectNew->Right() );
     3884
     3885  rc = DD_OK;
    37623886
    37633887  if(me->fLocked)
     
    37993923        WriteLog("SurfLock4: Surface already locked\n\n");
    38003924      #endif
    3801       return(DDERR_SURFACEBUSY);
    3802     }
    3803   }
    3804 
    3805   memcpy((char *)lpSurfaceDesc, (char *)&me->DDSurfaceDesc, sizeof(DDSURFACEDESC2));
    3806 
    3807   if(lpRect != NULL)
    3808   {
    3809     lpSurfaceDesc->lpSurface =  (LPVOID)((char*)me->pFrameBuffer +
    3810                                 (lpRect->top * me->dwPitchFB) +
    3811                                 (lpRect->left * (lpSurfaceDesc->ddpfPixelFormat.dwRGBBitCount>>3)));
    3812     #ifdef DEBUG
    3813       WriteLog("SurfLock4 %08X (x,y) = (%d,%d)\n\n", lpSurfaceDesc->lpSurface, lpRect->top, lpRect->left);
    3814     #endif
    3815   }
    3816   else
    3817   {
    3818     #ifdef DEBUG
    3819       WriteLog("SurfLock4 %08X \n\n", lpSurfaceDesc->lpSurface);
    3820     #endif
    3821   }
    3822   // Add the rectangle to the list of locked rectangles
    3823 
    3824   pIRectNew->SetMemPtr(lpSurfaceDesc->lpSurface);
    3825 
    3826   DPA_InsertPtr( me->DPA_LockedRects,
    3827                  DPA_GetPtrCount(me->DPA_LockedRects),
    3828                  pIRectNew);
    3829 
    3830   me->fLocked = TRUE;
    3831 
    3832   return(DD_OK);
     3925      rc = DDERR_SURFACEBUSY;
     3926    }
     3927
     3928  }
     3929
     3930  if(DD_OK == rc)
     3931  {
     3932    memcpy((char *)lpSurfaceDesc, (char *)&me->DDSurfaceDesc, sizeof(DDSURFACEDESC2));
     3933
     3934    if(lpRect != NULL)
     3935    {
     3936      lpSurfaceDesc->lpSurface =  (LPVOID)((char*)me->pFrameBuffer +
     3937                                  (lpRect->top * me->dwPitchFB) +
     3938                                  (lpRect->left * (lpSurfaceDesc->ddpfPixelFormat.dwRGBBitCount>>3)));
     3939      #ifdef DEBUG
     3940        WriteLog("SurfLock4 %08X (x,y) = (%d,%d)\n\n", lpSurfaceDesc->lpSurface, lpRect->top, lpRect->left);
     3941      #endif
     3942    }
     3943    else
     3944    {
     3945      #ifdef DEBUG
     3946        WriteLog("SurfLock4 %08X \n\n", lpSurfaceDesc->lpSurface);
     3947      #endif
     3948    }
     3949    // Add the rectangle to the list of locked rectangles
     3950
     3951    pIRectNew->SetMemPtr(lpSurfaceDesc->lpSurface);
     3952
     3953    DPA_InsertPtr( me->DPA_LockedRects,
     3954                   DPA_GetPtrCount(me->DPA_LockedRects),
     3955                   pIRectNew);
     3956
     3957    me->fLocked = TRUE;
     3958  }
     3959
     3960  ODIN_FS_END
     3961
     3962  return rc;
    38333963}
    38343964//******************************************************************************
     
    38503980  if(hdc != me->hdcImage)
    38513981    return(DDERR_INVALIDOBJECT);
     3982
     3983  ODIN_FS_BEGIN
    38523984
    38533985  //unselect our bitmap
     
    38974029  me->dwLastDCUnique = me->dwUniqueValue; // Store this to see if the surface was locked after we released the DC
    38984030
     4031  ODIN_FS_END
     4032
    38994033  return(DD_OK);
    39004034}
     
    39514085{
    39524086  OS2IDirectDrawSurface *me = (OS2IDirectDrawSurface *)This;
    3953 
     4087  HRESULT rc;
    39544088  #ifdef DEBUG
    39554089    WriteLog("SurfSetColorKey\n");
     
    39634097    return(DDERR_UNSUPPORTED);
    39644098
     4099  ODIN_FS_BEGIN
     4100
    39654101  if(DDCKEY_SRCBLT & dwFlags)
    39664102  {
     
    39784114      me->DDSurfaceDesc.dwFlags &= ~DDCKEY_SRCBLT;
    39794115    }
     4116    rc = DD_OK;
    39804117  }
    39814118  else
    3982     return (DDERR_INVALIDPARAMS); // some other flags where set => error
    3983 
    3984   return(DD_OK);
     4119    rc = DDERR_INVALIDPARAMS; // some other flags where set => error
     4120
     4121  ODIN_FS_END
     4122
     4123  return rc;
    39854124}
    39864125//******************************************************************************
     
    40784217  BOOL Found = FALSE;
    40794218  OS2RECTL CCRect;
     4219  HRESULT rc;
    40804220
    40814221  #ifdef DEBUG
     
    40904230    return(DDERR_NOTLOCKED);
    40914231  }
     4232
     4233  ODIN_FS_BEGIN
    40924234
    40934235  #ifdef DEBUG
     
    41724314      WriteLog("Rectangle not locked, wrong Rect!\n\n");
    41734315    #endif
    4174     return(DDERR_INVALIDRECT);
    4175   }
    4176 
    4177   #ifdef DEBUG
    4178     WriteLog("Remove Rect %d from Seq.\n",i);
    4179   #endif
    4180 
    4181   DPA_DeletePtr(me->DPA_LockedRects,i);
    4182 
    4183   #ifdef DEBUG
    4184     WriteLog("Test if locked Rects main\n");
    4185   #endif
    4186 
    4187   if(0==DPA_GetPtrCount(me->DPA_LockedRects))  // Do we have unlocked last rectangle
     4316    rc = DDERR_INVALIDRECT;
     4317  }
     4318  else
    41884319  {
    41894320    #ifdef DEBUG
    4190       WriteLog("No Locked Rects left for surface\n");
     4321      WriteLog("Remove Rect %d from Seq.\n",i);
    41914322    #endif
    4192     me->fLocked = FALSE;
    4193   }
    4194   #ifdef DEBUG
    4195   else
    4196     WriteLog( "%d Rects in Seq\n",
    4197               DPA_GetPtrCount(me->DPA_LockedRects));
    4198   #endif
    4199 
    4200   if(me->pFrameBuffer != me->pDiveBuffer)
    4201   {
     4323
     4324    DPA_DeletePtr(me->DPA_LockedRects,i);
     4325
    42024326    #ifdef DEBUG
    4203       WriteLog( "ColorConversion Needed %08X != %08X\n",
    4204                 me->pFrameBuffer,
    4205                 me->pDiveBuffer);
     4327      WriteLog("Test if locked Rects main\n");
    42064328    #endif
    4207     if(NULL!=lpSurfaceData)
    4208     {
    4209       CCRect.yTop    = pIRectEnum->Top();
    4210       CCRect.xLeft   = pIRectEnum->Left();
    4211       CCRect.xRight  = pIRectEnum->Right();
    4212       CCRect.yBottom = pIRectEnum->Bottom();
    4213 
    4214       me->ColorConversion( (LPRECT)&CCRect);
    4215     }
     4329
     4330    if(0==DPA_GetPtrCount(me->DPA_LockedRects))  // Do we have unlocked last rectangle
     4331    {
     4332      #ifdef DEBUG
     4333        WriteLog("No Locked Rects left for surface\n");
     4334      #endif
     4335      me->fLocked = FALSE;
     4336    }
     4337    #ifdef DEBUG
    42164338    else
    4217     {
    4218       me->ColorConversion(NULL);
    4219     }
    4220   }
    4221   #ifdef DEBUG
    4222   else
    4223     WriteLog( "No ColorConversion Needed");
    4224   #endif
    4225 
    4226   // delete tne DDRectobject of the found rectangle
    4227   delete pIRectEnum;
    4228 
    4229   me->lpVtbl->ChangeUniquenessValue(me);
    4230 
    4231   WriteLog("Unlock OK\n\n");
    4232 
    4233   return(DD_OK);
     4339      WriteLog( "%d Rects in Seq\n",
     4340                DPA_GetPtrCount(me->DPA_LockedRects));
     4341    #endif
     4342
     4343    if(me->pFrameBuffer != me->pDiveBuffer)
     4344    {
     4345      #ifdef DEBUG
     4346        WriteLog( "ColorConversion Needed %08X != %08X\n",
     4347                  me->pFrameBuffer,
     4348                  me->pDiveBuffer);
     4349      #endif
     4350      if(NULL!=lpSurfaceData)
     4351      {
     4352        CCRect.yTop    = pIRectEnum->Top();
     4353        CCRect.xLeft   = pIRectEnum->Left();
     4354        CCRect.xRight  = pIRectEnum->Right();
     4355        CCRect.yBottom = pIRectEnum->Bottom();
     4356
     4357        me->ColorConversion( (LPRECT)&CCRect);
     4358      }
     4359      else
     4360      {
     4361        me->ColorConversion(NULL);
     4362      }
     4363    }
     4364    #ifdef DEBUG
     4365    else
     4366      WriteLog( "No ColorConversion Needed");
     4367    #endif
     4368
     4369    // delete tne DDRectobject of the found rectangle
     4370    delete pIRectEnum;
     4371
     4372    me->lpVtbl->ChangeUniquenessValue(me);
     4373
     4374    WriteLog("Unlock OK\n\n");
     4375
     4376    rc = DD_OK;
     4377  }
     4378
     4379  ODIN_FS_END
     4380
     4381  return rc;
    42344382}
    42354383//******************************************************************************
     
    42494397  DDRectangle *pIRectUnlock, *pIRectEnum;
    42504398  BOOL Found = FALSE;
     4399  HRESULT rc;
    42514400
    42524401  #ifdef DEBUG
     
    42614410    return(DDERR_NOTLOCKED);
    42624411  }
     4412
     4413  ODIN_FS_BEGIN
    42634414
    42644415  if(NULL!=lpSurfaceRect)
     
    43234474    }
    43244475    else
    4325       return SurfUnlock(This, (LPVOID)lpSurfaceRect);
    4326   }
    4327 
    4328   #ifdef DEBUG
    4329     WriteLog("Remove Rect from Seq.\n");
    4330   #endif
    4331 
    4332   DPA_DeletePtr(me->DPA_LockedRects,i);
    4333 
    4334   if(0==DPA_GetPtrCount(me->DPA_LockedRects))  // Do we have unlocked last rectangle
     4476      rc = SurfUnlock(This, (LPVOID)lpSurfaceRect);
     4477  }
     4478  else
    43354479  {
    43364480    #ifdef DEBUG
    4337       WriteLog("No Locked Rects left for surface\n");
     4481      WriteLog("Remove Rect from Seq.\n");
    43384482    #endif
    4339     me->fLocked = FALSE;
    4340   }
    4341 
    4342   if(me->pFrameBuffer != me->pDiveBuffer)
    4343   {
    4344     #ifdef DEBUG
    4345       WriteLog( "ColorConversion Needed %08X != %08X\n",
    4346                 me->pFrameBuffer,
    4347                 me->pDiveBuffer);
    4348     #endif
    4349     me->ColorConversion(lpSurfaceRect);
    4350   }
    4351 
    4352   me->lpVtbl->ChangeUniquenessValue(me);
    4353 
    4354   WriteLog("Unlock OK\n\n");
    4355 
    4356   return(DD_OK);
     4483
     4484    DPA_DeletePtr(me->DPA_LockedRects,i);
     4485
     4486    if(0==DPA_GetPtrCount(me->DPA_LockedRects))  // Do we have unlocked last rectangle
     4487    {
     4488      #ifdef DEBUG
     4489        WriteLog("No Locked Rects left for surface\n");
     4490      #endif
     4491      me->fLocked = FALSE;
     4492    }
     4493
     4494    if(me->pFrameBuffer != me->pDiveBuffer)
     4495    {
     4496      #ifdef DEBUG
     4497        WriteLog( "ColorConversion Needed %08X != %08X\n",
     4498                  me->pFrameBuffer,
     4499                  me->pDiveBuffer);
     4500      #endif
     4501      me->ColorConversion(lpSurfaceRect);
     4502    }
     4503
     4504    me->lpVtbl->ChangeUniquenessValue(me);
     4505
     4506    WriteLog("Unlock OK\n\n");
     4507    rc = DD_OK;
     4508  }
     4509
     4510  ODIN_FS_END
     4511
     4512  return rc;
    43574513}
    43584514//******************************************************************************
     
    44554611    return DDERR_INVALIDSURFACETYPE; // only work for system alloced surfaces
    44564612
     4613  ODIN_FS_BEGIN
     4614
    44574615  if (!me->Updated)
    44584616  {
     
    44654623  memcpy((char *)&(me->DDSurfaceDesc), (char *)lpSurfDesc, sizeof(DDSURFACEDESC));
    44664624
     4625  ODIN_FS_END
    44674626
    44684627  return DD_OK;
     
    44874646    return DDERR_INVALIDSURFACETYPE; // only work for system alloced surfaces
    44884647
     4648  ODIN_FS_BEGIN
     4649
    44894650  if (!me->Updated)
    44904651  {
     
    44964657  me->lpVtbl->ChangeUniquenessValue(me);
    44974658  memcpy((char *)&(me->DDSurfaceDesc), (char *)lpSurfDesc, sizeof(DDSURFACEDESC2));
     4659
     4660  ODIN_FS_END
    44984661
    44994662  return DD_OK;
     
    45114674  void *pBuffer;
    45124675  BOOL bFound = FALSE;
     4676  HRESULT rc;
    45134677
    45144678  #ifdef DEBUG
     
    45224686     (dwFlags & ~(DDSPD_IUNKNOWNPOINTER|DDSPD_VOLATILE)))
    45234687    return(DDERR_INVALIDPARAMS);
     4688
     4689  ODIN_FS_BEGIN
    45244690
    45254691  // first check if the refGUID is stored as then the content will be updated
     
    45674733        {
    45684734          delete pSData;
    4569           return (DDERR_OUTOFMEMORY);
     4735          rc = DDERR_OUTOFMEMORY;
    45704736        }
    45714737      }
     
    46004766          }
    46014767          else
    4602             return(DDERR_OUTOFMEMORY);
     4768            rc = DDERR_OUTOFMEMORY;
    46034769        }
    46044770      }
     
    46314797          }
    46324798          else
    4633             return(DDERR_OUTOFMEMORY);
     4799            rc = DDERR_OUTOFMEMORY;
    46344800        }
    46354801      }
     
    46624828          pSData->dwFlags = dwFlags;
    46634829          pSData->isValid = TRUE;
     4830
     4831          if( DPA_InsertPtr( me->DPA_SurfacePrivateData,
     4832                             DPA_GetPtrCount(me->DPA_SurfacePrivateData),
     4833                             pSData) <0)
     4834          {
     4835            delete(pSData);
     4836            rc = DDERR_OUTOFMEMORY;
     4837          }
    46644838        }
    46654839        else
    46664840        {
    4667           delete pSData;
    4668           return (DDERR_OUTOFMEMORY);
     4841          delete(pSData);
     4842          rc = DDERR_OUTOFMEMORY;
    46694843        }
    46704844      }
    46714845
    4672       if( DPA_InsertPtr( me->DPA_SurfacePrivateData,
    4673                          DPA_GetPtrCount(me->DPA_SurfacePrivateData),
    4674                          pSData) <0)
    4675       {
    4676         delete pSData;
    4677         return (DDERR_OUTOFMEMORY);
    4678       }
    4679 
    46804846    }
    46814847    else
    4682       return (DDERR_OUTOFMEMORY);
    4683   }
    4684   return(DD_OK);
     4848      rc = DDERR_OUTOFMEMORY;
     4849  }
     4850
     4851  ODIN_FS_END
     4852
     4853  return rc;
    46854854}
    46864855//******************************************************************************
    46874856//******************************************************************************
    46884857HRESULT __stdcall SurfGetPrivateData(THIS This, REFGUID refGUID, LPVOID lpData, LPDWORD lpDataSize)
     4858{
     4859  OS2IDirectDrawSurface *me = (OS2IDirectDrawSurface *)This;
     4860  int i;
     4861  PSURFPRIVATEDATA pSData;
     4862  HRESULT rc;
     4863  BOOL bFound = FALSE;
     4864
     4865  #ifdef DEBUG
     4866    WriteLog("SurfGetPrivateData\n");
     4867  #endif
     4868
     4869  if(NULL==me)
     4870    return(DDERR_INVALIDOBJECT);
     4871
     4872  if((NULL==lpData)||(NULL==lpDataSize))
     4873    return(DDERR_INVALIDPARAMS);
     4874
     4875  ODIN_FS_BEGIN
     4876
     4877  if(DPA_GetPtrCount(me->DPA_SurfacePrivateData)>0)
     4878  {
     4879    i=0;
     4880    while(i<DPA_GetPtrCount(me->DPA_SurfacePrivateData) && !bFound)
     4881    {
     4882      pSData = (PSURFPRIVATEDATA) DPA_FastGetPtr(me->DPA_SurfacePrivateData,i);
     4883
     4884      if (IsEqualGUID(pSData->guidTag,refGUID))
     4885        bFound = TRUE;
     4886
     4887      i++;
     4888    }
     4889  }
     4890
     4891  if(bFound)
     4892  {
     4893    if(!pSData->isValid)
     4894    {
     4895      rc =DDERR_EXPIRED;
     4896    }
     4897    else
     4898    {
     4899      if(pSData->dwSize > *lpDataSize)
     4900      {
     4901        // Buffer to small return needed Size
     4902        *lpDataSize = pSData->dwSize;
     4903        rc = DDERR_MOREDATA;
     4904      }
     4905      else
     4906      {
     4907        memcpy(lpData,pSData->pData,pSData->dwSize);
     4908        rc = DD_OK;
     4909      }
     4910    }
     4911  }
     4912  else
     4913   rc = DDERR_NOTFOUND;
     4914
     4915  ODIN_FS_END
     4916
     4917  return rc;
     4918}
     4919//******************************************************************************
     4920//******************************************************************************
     4921HRESULT __stdcall SurfFreePrivateData(THIS This, REFGUID refGUID)
    46894922{
    46904923  OS2IDirectDrawSurface *me = (OS2IDirectDrawSurface *)This;
     
    46944927
    46954928  #ifdef DEBUG
    4696     WriteLog("SurfGetPrivateData\n");
     4929    WriteLog("SurfFreePrivateData\n");
    46974930  #endif
    46984931
     
    47004933    return(DDERR_INVALIDOBJECT);
    47014934
    4702   if((NULL==lpData)||(NULL==lpDataSize))
    4703     return(DDERR_INVALIDPARAMS);
    4704 
    4705   if(DPA_GetPtrCount(me->DPA_SurfacePrivateData)>0)
    4706   {
    4707     i=0;
    4708     while(i<DPA_GetPtrCount(me->DPA_SurfacePrivateData) && !bFound)
    4709     {
    4710       pSData = (PSURFPRIVATEDATA) DPA_FastGetPtr(me->DPA_SurfacePrivateData,i);
    4711 
    4712       if (IsEqualGUID(pSData->guidTag,refGUID))
    4713         bFound = TRUE;
    4714 
    4715       i++;
    4716     }
    4717   }
    4718 
    4719   if(bFound)
    4720   {
    4721     if(!pSData->isValid)
    4722       return(DDERR_EXPIRED);
    4723 
    4724     if(pSData->dwSize > *lpDataSize)
    4725     {
    4726       // Buffer to small return needed Size
    4727       *lpDataSize = pSData->dwSize;
    4728       return(DDERR_MOREDATA);
    4729     }
    4730 
    4731     memcpy(lpData,pSData->pData,pSData->dwSize);
    4732     return(DD_OK);
    4733   }
    4734 
    4735   return (DDERR_NOTFOUND);
    4736 }
    4737 //******************************************************************************
    4738 //******************************************************************************
    4739 HRESULT __stdcall SurfFreePrivateData(THIS This, REFGUID refGUID)
    4740 {
    4741   OS2IDirectDrawSurface *me = (OS2IDirectDrawSurface *)This;
    4742   int i;
    4743   PSURFPRIVATEDATA pSData;
    4744   BOOL bFound = FALSE;
    4745 
    4746   #ifdef DEBUG
    4747     WriteLog("SurfFreePrivateData\n");
    4748   #endif
    4749 
    4750   if(NULL==me)
    4751     return(DDERR_INVALIDOBJECT);
     4935  ODIN_FS_BEGIN
    47524936
    47534937  if(DPA_GetPtrCount(me->DPA_SurfacePrivateData)>0)
     
    47824966    }
    47834967  }
     4968
     4969  ODIN_FS_END
     4970
    47844971  return (bFound?DD_OK:DDERR_NOTFOUND);
    47854972}
     
    48064993  PSURFPRIVATEDATA pSData;
    48074994
     4995  ODIN_FS_BEGIN
     4996
    48084997  #ifdef DEBUG
    48094998    WriteLog("SurfChangeUniquenessValue\n");
     
    48225011        if (pSData->dwFlags & DDSPD_IUNKNOWNPOINTER)
    48235012        {
    4824           // pointer to com stored so calll its release
     5013          // pointer to com stored so call its release
    48255014          ((OS2IDirectDrawSurface *) pSData->pData)->lpVtbl->Release(pSData->pData);
    48265015        }
     
    48375026  }
    48385027
     5028  ODIN_FS_END
     5029
    48395030  return (DD_OK);
    48405031}
     
    48485039void __cdecl MoveRects(char* pBuffer, LPRECT lpDestRect, LPRECT lpSrcRect, int bpp, LONG lPitch)
    48495040{
     5041
    48505042  char *pBltPos, *pSrcPos;
    48515043  int BlitWidth,BlitHeight;
    48525044  static char Scanline[6400];  // sufficient for 1600 at 32 bit
     5045
     5046  ODIN_FS_BEGIN
     5047
    48535048  // Bridge, we may got a problem ;)
    48545049  // Check for Overlapping Rects
     
    49125107  }
    49135108
     5109  ODIN_FS_END
    49145110}
    49155111
  • trunk/src/ddraw/OS2UTIL.CPP

    r97 r503  
    1 /* $Id: OS2UTIL.CPP,v 1.3 1999-06-10 17:10:57 phaller Exp $ */
     1/* $Id: OS2UTIL.CPP,v 1.4 1999-08-16 00:40:48 hugh Exp $ */
    22
    33/*
     
    4343void OS2MaximizeWindow(HWND hwndClient)
    4444{
     45  ODIN_FS_BEGIN
    4546  WinSetWindowPos(hwndClient, HWND_TOP, 0, 0, 0, 0, SWP_MAXIMIZE);
     47  ODIN_FS_END
    4648}
    4749
  • trunk/src/ddraw/ddraw.CPP

    r210 r503  
    22
    33#include <builtin.h>
     4#include <odincrt.h>
    45#define INITGUID
    56#include "os2ddraw.h"
     
    1819  HRESULT         rc;
    1920
     21  ODIN_FS_BEGIN
     22
    2023  WriteLog("DirectDrawCreate %X %X %X\n", lpGUID, lplpDD, pUnkOuter);
     24
    2125  newdraw = new OS2IDirectDraw(lpGUID);
    2226
    2327  if(newdraw == NULL)
    24     return(DDERR_NODIRECTDRAWHW);
    25 
    26 //  newdraw->Vtbl.AddRef((IDirectDraw *)newdraw);
    27   rc = newdraw->GetLastError();
    28   if(rc != DD_OK)
    2928  {
    30     *lplpDD = NULL;
    31     delete newdraw;
     29    rc = DDERR_NODIRECTDRAWHW;
    3230  }
    3331  else
    34     *lplpDD = (LPDIRECTDRAW)newdraw;
     32  {
     33    //  newdraw->Vtbl.AddRef((IDirectDraw *)newdraw);
     34    rc = newdraw->GetLastError();
     35    if(rc != DD_OK)
     36    {
     37      *lplpDD = NULL;
     38
     39      delete newdraw;
     40    }
     41    else
     42      *lplpDD = (LPDIRECTDRAW)newdraw;
     43  }
     44  ODIN_FS_END
    3545
    3646  return(rc);
     
    4555  //call it twice for the DirectDraw & Direct3D classes
    4656 if(lpCallback(NULL, "DIVE DirectDraw for OS/2",
    47                 "DirectDraw/2 v0.1", lpContext) == DDENUMRET_CANCEL)
     57                "DirectDraw/2 v0.2", lpContext) == DDENUMRET_CANCEL)
    4858  {
    4959    WriteLog("Cancel Callback\n");
     
    5464    WriteLog("Callback for 3Dfx Voodoo");
    5565    if(lpCallback((GUID *)&IID_IDirect3D, "3Dfx Voodoo Direct3D/2",
    56       "Direct3D/2 v0.1", lpContext) == DDENUMRET_CANCEL)
     66      "Direct3D/2 v0.2", lpContext) == DDENUMRET_CANCEL)
    5767    {
    5868      WriteLog("Cancel Callback\n");
     
    6474  return(DD_OK);
    6575}
     76
    6677//******************************************************************************
    6778typedef struct
  • trunk/src/ddraw/makefile

    r450 r503  
    1313ASFLAGS = -Sc -Sv:ALP
    1414
    15 CFLAGS = $(CFLAGS) -I$(PDWIN32_INCLUDE);
    16 CXXFLAGS = $(CXXFLAGS) -I$(PDWIN32_INCLUDE);
     15CFLAGS = $(CFLAGS) /Gn+-I$(PDWIN32_INCLUDE);
     16CXXFLAGS = $(CXXFLAGS) /Gn+ -I$(PDWIN32_INCLUDE);
    1717
    1818TARGET = ddraw
     
    2020OBJS =  ddraw.obj os2ddraw.obj os2clipper.obj os2d3d.obj iccio1.obj asmutil.obj\
    2121        os2surface.obj os2palette.obj os2palset.obj misc.obj rectangle.obj initterm.obj
     22       
    2223
    2324LIBS =  ..\..\lib\pmwinx.lib mmpm2.lib ..\..\lib\comctl32.lib $(PDWIN32_LIB)\advapi32.lib $(PDWIN32_LIB)\kernel32.lib $(PDWIN32_LIB)\gdi32.lib $(PDWIN32_LIB)\comctl32.lib $(PDWIN32_LIB)/odincrt.lib OS2386.LIB
  • trunk/src/ddraw/os2DDWindow.cpp

    r210 r503  
    11#define INCL_WIN
    22#include <os2wrap.h>
     3#include <odincrt.h>
     4#include <odinwrap.h>
    35#include "os2DDWindow.h"
    46
     
    810extern VOID SwitchDisplay(HWND hwnd);
    911
    10 BOOL OS2DdSubClassWindow(HWND hwndClient)
     12ODINFUNCTION1(BOOL , OS2DdSubClassWindow ,HWND, hwndClient)
    1113{
    1214  HWND hwndParent;
     
    3537{
    3638  USHORT usFlags;
     39
     40  ODIN_FS_BEGIN
     41
    3742  switch(ulMsg)
    3843  {
     
    5964      break;
    6065  }
     66
     67  ODIN_FS_END
     68
    6169  return pfnOrgClientProc(hwnd, ulMsg, mp1,mp2);
    6270}
Note: See TracChangeset for help on using the changeset viewer.