win32 - fix crash in some display methods when emulator boots up

This commit is contained in:
zeromus 2015-11-06 01:57:46 +00:00
parent 40fd9c2385
commit dc3d1945af
1 changed files with 20 additions and 8 deletions

View File

@ -360,6 +360,7 @@ struct DDRAW
bool lock(); bool lock();
bool unlock(); bool unlock();
bool blt(LPRECT dst, LPRECT src); bool blt(LPRECT dst, LPRECT src);
bool OK();
LPDIRECTDRAW7 handle; LPDIRECTDRAW7 handle;
struct struct
@ -1816,14 +1817,17 @@ static void DD_DoDisplay()
int bottom = r.bottom; int bottom = r.bottom;
//printf("%d %d %d %d / %d %d %d %d\n",fullScreen.left,fullScreen.top,fullScreen.right,fullScreen.bottom,left,top,right,bottom); //printf("%d %d %d %d / %d %d %d %d\n",fullScreen.left,fullScreen.top,fullScreen.right,fullScreen.bottom,left,top,right,bottom);
//printf("%d %d %d %d / %d %d %d %d\n",MainScreenRect.left,MainScreenRect.top,MainScreenRect.right,MainScreenRect.bottom,SubScreenRect.left,SubScreenRect.top,SubScreenRect.right,SubScreenRect.bottom); //printf("%d %d %d %d / %d %d %d %d\n",MainScreenRect.left,MainScreenRect.top,MainScreenRect.right,MainScreenRect.bottom,SubScreenRect.left,SubScreenRect.top,SubScreenRect.right,SubScreenRect.bottom);
DD_FillRect(ddraw.surface.primary,0,0,left,top,RGB(255,0,0)); //topleft if(ddraw.OK())
DD_FillRect(ddraw.surface.primary,left,0,right,top,RGB(128,0,0)); //topcenter {
DD_FillRect(ddraw.surface.primary,right,0,wr.right,top,RGB(0,255,0)); //topright DD_FillRect(ddraw.surface.primary,0,0,left,top,RGB(255,0,0)); //topleft
DD_FillRect(ddraw.surface.primary,0,top,left,bottom,RGB(0,128,0)); //left DD_FillRect(ddraw.surface.primary,left,0,right,top,RGB(128,0,0)); //topcenter
DD_FillRect(ddraw.surface.primary,right,top,wr.right,bottom,RGB(0,0,255)); //right DD_FillRect(ddraw.surface.primary,right,0,wr.right,top,RGB(0,255,0)); //topright
DD_FillRect(ddraw.surface.primary,0,bottom,left,wr.bottom,RGB(0,0,128)); //bottomleft DD_FillRect(ddraw.surface.primary,0,top,left,bottom,RGB(0,128,0)); //left
DD_FillRect(ddraw.surface.primary,left,bottom,right,wr.bottom,RGB(255,0,255)); //bottomcenter DD_FillRect(ddraw.surface.primary,right,top,wr.right,bottom,RGB(0,0,255)); //right
DD_FillRect(ddraw.surface.primary,right,bottom,wr.right,wr.bottom,RGB(0,255,255)); //bottomright DD_FillRect(ddraw.surface.primary,0,bottom,left,wr.bottom,RGB(0,0,128)); //bottomleft
DD_FillRect(ddraw.surface.primary,left,bottom,right,wr.bottom,RGB(255,0,255)); //bottomcenter
DD_FillRect(ddraw.surface.primary,right,bottom,wr.right,wr.bottom,RGB(0,255,255)); //bottomright
}
} }
for(int i = 0; i < 2; i++) for(int i = 0; i < 2; i++)
@ -7285,6 +7289,14 @@ bool DDRAW::unlock()
return true; return true;
} }
bool DDRAW::OK()
{
if (!handle) return false;
if (!surface.primary) return false;
if (!surface.back) return false;
return true;
}
bool DDRAW::blt(LPRECT dst, LPRECT src) bool DDRAW::blt(LPRECT dst, LPRECT src)
{ {
if (!handle) return true; if (!handle) return true;