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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.