Exemple #1
0
static void dctest_surf(IDirectDrawSurface *surf, int ddsdver) {
    HRESULT hr;
    HDC dc, dc2 = (HDC) 0x1234;
    DDSURFACEDESC ddsd;
    DDSURFACEDESC2 ddsd2;

    memset(&ddsd, 0, sizeof(ddsd));
    ddsd.dwSize = sizeof(ddsd);
    memset(&ddsd2, 0, sizeof(ddsd2));
    ddsd2.dwSize = sizeof(ddsd2);

    hr = IDirectDrawSurface_GetDC(surf, &dc);
    ok(hr == DD_OK, "IDirectDrawSurface_GetDC failed: 0x%08x\n", hr);

    hr = IDirectDrawSurface_GetDC(surf, &dc);
    ok(hr == DDERR_DCALREADYCREATED, "IDirectDrawSurface_GetDC failed: 0x%08x\n", hr);
    ok(dc2 == (HDC) 0x1234, "The failed GetDC call changed the dc: %p\n", dc2);

    hr = IDirectDrawSurface_Lock(surf, NULL, ddsdver == 1 ? &ddsd : ((DDSURFACEDESC *) &ddsd2), 0, NULL);
    ok(hr == DDERR_SURFACEBUSY, "IDirectDrawSurface_Lock returned 0x%08x, expected DDERR_SURFACEBUSY\n", hr);

    hr = IDirectDrawSurface_ReleaseDC(surf, dc);
    ok(hr == DD_OK, "IDirectDrawSurface_ReleaseDC failed: 0x%08x\n", hr);
    hr = IDirectDrawSurface_ReleaseDC(surf, dc);
    ok(hr == DDERR_NODC, "IDirectDrawSurface_ReleaseDC returned 0x%08x, expected DDERR_NODC\n", hr);
}
Exemple #2
0
static void testsurface(void)
{
    const char* testMsg = "ddraw device context test";
    HDC hdc;
    HRESULT rc;
    
    rc = IDirectDrawSurface_GetDC(lpDDSBack, &hdc);
    ok(rc==DD_OK, "IDirectDrawSurface_GetDC returned: %x\n",rc);
    SetBkColor(hdc, RGB(0, 0, 255));
    SetTextColor(hdc, RGB(255, 255, 0));
    TextOut(hdc, 0, 0, testMsg, lstrlen(testMsg));
    IDirectDrawSurface_ReleaseDC(lpDDSBack, hdc);
    ok(rc==DD_OK, "IDirectDrawSurface_ReleaseDC returned: %x\n",rc);
    
    while (1)
    {
        rc = IDirectDrawSurface_Flip(lpDDSPrimary, NULL, DDFLIP_WAIT);
        ok(rc==DD_OK || rc==DDERR_SURFACELOST, "IDirectDrawSurface_BltFast returned: %x\n",rc);

        if (rc == DD_OK)
        {
            break;
        }
        else if (rc == DDERR_SURFACELOST)
        {
            rc = IDirectDrawSurface_Restore(lpDDSPrimary);
            ok(rc==DD_OK, "IDirectDrawSurface_Restore returned: %x\n",rc);
        }
    }
}
Exemple #3
0
void DisplayMovMode(void)
{
#ifdef _WINDOWS
	HDC hdc;
	HFONT hFO;

	IDirectDrawSurface_GetDC(DX.DDSRender,&hdc);

	hFO=(HFONT)SelectObject(hdc,StatusFont);

	if (modeFlags&MODE_FLAG_RECORD)
		SetTextColor(hdc,RGB(255,0,0));
	else if (modeFlags&MODE_FLAG_REPLAY)
		SetTextColor(hdc,RGB(255,255,255));
	else
		SetTextColor(hdc,RGB(0,255,0));

	SetBkMode(hdc,TRANSPARENT);
	SetTextAlign(hdc, TA_TOP | TA_RIGHT);

	ExtTextOut(hdc,PSXDisplay.DisplayMode.x-3,2,0,NULL,cCurrentMode,lstrlen(cCurrentMode),NULL);

	SelectObject(hdc,hFO);
	IDirectDrawSurface_ReleaseDC(DX.DDSRender,hdc);
#endif
}
Exemple #4
0
void DisplayFrames(void)
{
#ifdef _WINDOWS
	HDC hdc;
	HFONT hFO;

	IDirectDrawSurface_GetDC(DX.DDSRender,&hdc);
	hFO=(HFONT)SelectObject(hdc,hGFont);

	if (ThereIsLag)
	{
		SetTextColor(hdc,RGB(255,0,0));
	}
	else SetTextColor(hdc,RGB(255,255,255));

	if (bTransparent)
		SetBkMode(hdc,TRANSPARENT);
	else SetBkColor(hdc,RGB(0,0,0));

	ExtTextOut(hdc,3,2,0,NULL,cCurrentFrame,lstrlen(cCurrentFrame),NULL);

	SelectObject(hdc,hFO);
	IDirectDrawSurface_ReleaseDC(DX.DDSRender,hdc);
#endif
}
Exemple #5
0
void DisplayText(void)                                 // DISPLAY TEXT
{
#ifdef _WINDOWS
	HDC hdc;
	HFONT hFO;

	IDirectDrawSurface_GetDC(DX.DDSRender,&hdc);
	hFO=(HFONT)SelectObject(hdc,hGFont);

	SetTextColor(hdc,RGB(0,255,0));
	if (bTransparent)
		SetBkMode(hdc,TRANSPARENT);
	else SetBkColor(hdc,RGB(0,0,0));

	if (szDebugText[0] && ((time(NULL) - tStart) < 2))    // special debug text? show it
	{
		RECT r={2,PSXDisplay.DisplayMode.y-12,1022,1024};
		DrawText(hdc,szDebugText,lstrlen(szDebugText),&r,DT_LEFT|DT_NOCLIP);
	}
	else                                                  // else standard gpu menu
	{
		szDebugText[0]=0;
		lstrcat(szDispBuf,szMenuBuf);
		ExtTextOut(hdc,2,PSXDisplay.DisplayMode.y-12,0,NULL,szDispBuf,lstrlen(szDispBuf),NULL);
	}

	SelectObject(hdc,hFO);
	IDirectDrawSurface_ReleaseDC(DX.DDSRender,hdc);
#endif
}
Exemple #6
0
void DisplayRecording(int RecNum, int MaxPlayer)
{
	#ifdef _WINDOWS
	HDC hdc;
	HFONT hFO;
	char *text;
	text = new char[10];
	IDirectDrawSurface_GetDC(DX.DDSRender,&hdc);
	hFO=(HFONT)SelectObject(hdc,hGFont);

	SetTextColor(hdc,RGB(0,255,0));
	if (bTransparent)
		SetBkMode(hdc,TRANSPARENT);
	else SetBkColor(hdc,RGB(0,0,0));
	if (RecNum <= MaxPlayer)
	{	
		sprintf(text,"Player %d\0",RecNum);
		ExtTextOut(hdc,2,PSXDisplay.DisplayMode.y-24,0,NULL,text,8,NULL);
	}
	else if (RecNum == MaxPlayer+1)
		ExtTextOut(hdc,2,PSXDisplay.DisplayMode.y-24,0,NULL,"None\0",4,NULL);
	else
		ExtTextOut(hdc,2,PSXDisplay.DisplayMode.y-24,0,NULL,"All\0",3,NULL);			
	SelectObject(hdc,hFO);
	IDirectDrawSurface_ReleaseDC(DX.DDSRender,hdc);
	delete text;
	#endif
}
Exemple #7
0
void DisplayAnalog(PadDataS padd1, PadDataS padd2)
{
	#ifdef _WINDOWS
	HDC hdc;
	HFONT hFO;
	char tempstr[128];
	IDirectDrawSurface_GetDC(DX.DDSRender,&hdc);
	hFO=(HFONT)SelectObject(hdc,hGFont);

	SetTextColor(hdc,RGB(0,255,0));
	if (bTransparent)
		SetBkMode(hdc,TRANSPARENT);
	else SetBkColor(hdc,RGB(0,0,0));
	int n = 1;
	if (padd2.controllerType !=4)
	{
		sprintf(tempstr,"%03d %03d %03d %03d",padd2.leftJoyX, padd2.leftJoyY, padd2.rightJoyX, padd2.rightJoyY);
		ExtTextOut(hdc,PSXDisplay.DisplayMode.x-90,PSXDisplay.DisplayMode.y-12,0,NULL,tempstr,lstrlen(tempstr),NULL);
		n++;
	}	
	if (padd1.controllerType !=4)
	{
		sprintf(tempstr,"%03d %03d %03d %03d",padd1.leftJoyX, padd1.leftJoyY, padd1.rightJoyX, padd1.rightJoyY);
		ExtTextOut(hdc,PSXDisplay.DisplayMode.x-90,PSXDisplay.DisplayMode.y-(n*12),0,NULL,tempstr,lstrlen(tempstr),NULL);
	}	
	SelectObject(hdc,hFO);
	IDirectDrawSurface_ReleaseDC(DX.DDSRender,hdc);
	#endif
}
Exemple #8
0
void DisplayInput(short P1, short P2)
{
	#ifdef _WINDOWS	
	const unsigned short Order[] = {0x80, 0x10, 0x20, 0x40, 0x8, 0x1, 0x8000, 0x4000, 0x2000, 0x1000, 0x400, 0x400, 0x800, 0x800, 0x100, 0x100, 0x200, 0x200};	
	HDC hdc;
	HFONT hFO;	
	IDirectDrawSurface_GetDC(DX.DDSRender,&hdc);
	hFO=(HFONT)SelectObject(hdc,hGFont);

	SetTextColor(hdc,RGB(0,255,0));
	if (bTransparent)
		SetBkMode(hdc,TRANSPARENT);
	else SetBkColor(hdc,RGB(0,0,0));
	ExtTextOut(hdc,2,PSXDisplay.DisplayMode.y-12,0,NULL,szInputBuf,36,NULL);	
	for (int i = 0; i < 18; i++)
	{
		if (P1&Order[i])
		{NULL;} else szInputBuf[i] = ' ';
	}
	for (int i = 0; i < 18; i++)
	{
		if (P2&Order[i])
		{} else szInputBuf[i+18] = ' ';
	}
	SetTextColor(hdc,RGB(0,255,255));
	SetBkMode(hdc,TRANSPARENT);
	ExtTextOut(hdc,2,PSXDisplay.DisplayMode.y-12,0,NULL,szInputBuf,36,NULL);
	SelectObject(hdc,hFO);
	IDirectDrawSurface_ReleaseDC(DX.DDSRender,hdc);
	#endif
}
Exemple #9
0
static void print(int x, int y, CONST char *text)
{
    HDC hDC;
    static char current[256];
    char s[256];
#ifdef DDRAW_DRIVER
    if (directX == DXFULLSCREEN) {
	HGLOBAL oldFont;
	if (IDirectDrawSurface_GetDC(lpSurfaces[0], &hDC) != DD_OK)
	    return;
	SetTextColor(hDC, 0xffffff);
	SetBkColor(hDC, 0x000000);
	oldFont = SelectObject(hDC, hFont);
	ExtTextOut(hDC, x, y, 0, NULL, text, strlen(text), NULL);
	SelectObject(hDC, oldFont);
	IDirectDrawSurface_ReleaseDC(lpSurfaces[0], hDC);
	return;
    }
#endif
    if (!text[0])
	strcpy(s, "XaoS");
    else
	sprintf(s, "XaoS - %s", text);
    if (strcmp(current, s))
	strcpy(current, s), SetWindowText(hWnd, s);
}
Exemple #10
0
static LPDIRECTDRAWSURFACE CreateBMP( win32_driver_t * win32_driver, int resource )
{
  LPDIRECTDRAWSURFACE	bmp_surf;
  DDSURFACEDESC	bmp_ddsd;
  HBITMAP		bmp_hndl;
  BITMAP		bmp_head;
  HDC			hdc_dds;
  HDC			hdc_mem;

  /* load our bitmap from a resource */

  if( !( bmp_hndl = LoadBitmap( win32_driver->win32_visual->HInst, MAKEINTRESOURCE( resource ) ) ) )
    {
      Error( 0, "CreateBitmap : could not load bmp resource" );
      return 0;
    }

  /* create an off screen surface with
   * the same dimentions as our bitmap */

  GetObject( bmp_hndl, sizeof( bmp_head ), &bmp_head );

  memset( &bmp_ddsd, 0, sizeof( bmp_ddsd ) );
  bmp_ddsd.dwSize         = sizeof( bmp_ddsd );
  bmp_ddsd.dwFlags        = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
  bmp_ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_VIDEOMEMORY;
  bmp_ddsd.dwWidth        = bmp_head.bmWidth;
  bmp_ddsd.dwHeight       = bmp_head.bmHeight;

  if( IDirectDraw_CreateSurface( win32_driver->ddobj, &bmp_ddsd, &bmp_surf, 0 ) != DD_OK )
    {
      Error( 0, "CreateSurface ( bitmap ) : could not create dd surface" );
      return 0;
    }

  /* get a handle to our surface dc,
   * create a compat dc and load
   * our bitmap into the compat dc */

  IDirectDrawSurface_GetDC( bmp_surf, &hdc_dds );
  hdc_mem = CreateCompatibleDC( hdc_dds );
  SelectObject( hdc_mem, bmp_hndl );

  /* copy our bmp from the compat dc
   * into our dd surface */

  BitBlt( hdc_dds, 0, 0, bmp_head.bmWidth, bmp_head.bmHeight,
	  hdc_mem, 0, 0, SRCCOPY );

  /* clean up */

  DeleteDC( hdc_mem );
  DeleteObject( bmp_hndl );
  IDirectDrawSurface_ReleaseDC( bmp_surf, hdc_dds );

  return bmp_surf;
}
Exemple #11
0
static void dctest_sysvidmem(IDirectDrawSurface *surf, int ddsdver) {
    HRESULT hr;
    HDC dc, dc2 = (HDC) 0x1234;
    DDSURFACEDESC ddsd;
    DDSURFACEDESC2 ddsd2;

    memset(&ddsd, 0, sizeof(ddsd));
    ddsd.dwSize = sizeof(ddsd);
    memset(&ddsd2, 0, sizeof(ddsd2));
    ddsd2.dwSize = sizeof(ddsd2);

    hr = IDirectDrawSurface_GetDC(surf, &dc);
    ok(hr == DD_OK, "IDirectDrawSurface_GetDC failed: 0x%08x\n", hr);

    hr = IDirectDrawSurface_GetDC(surf, &dc2);
    ok(hr == DD_OK, "IDirectDrawSurface_GetDC failed: 0x%08x\n", hr);
    ok(dc == dc2, "Got two different DCs\n");

    hr = IDirectDrawSurface_Lock(surf, NULL, ddsdver == 1 ? &ddsd : ((DDSURFACEDESC *) &ddsd2), 0, NULL);
    ok(hr == DD_OK, "IDirectDrawSurface_Lock returned 0x%08x, expected DD_OK\n", hr);

    hr = IDirectDrawSurface_Lock(surf, NULL, ddsdver == 1 ? &ddsd : ((DDSURFACEDESC *) &ddsd2), 0, NULL);
    ok(hr == DDERR_SURFACEBUSY, "IDirectDrawSurface_Lock returned 0x%08x, expected DDERR_SURFACEBUSY\n", hr);

    hr = IDirectDrawSurface_Unlock(surf, NULL);
    ok(hr == DD_OK, "IDirectDrawSurface_Unlock returned 0x%08x, expected DD_OK\n", hr);
    hr = IDirectDrawSurface_Unlock(surf, NULL);
    ok(hr == DDERR_NOTLOCKED, "IDirectDrawSurface_Unlock returned 0x%08x, expected DDERR_NOTLOCKED\n", hr);

    hr = IDirectDrawSurface_ReleaseDC(surf, dc);
    ok(hr == DD_OK, "IDirectDrawSurface_ReleaseDC failed: 0x%08x\n", hr);
    hr = IDirectDrawSurface_ReleaseDC(surf, dc);
    ok(hr == DD_OK, "IDirectDrawSurface_ReleaseDC failed: 0x%08x\n", hr);
    /* That works any number of times... */
    hr = IDirectDrawSurface_ReleaseDC(surf, dc);
    ok(hr == DD_OK, "IDirectDrawSurface_ReleaseDC failed: 0x%08x\n", hr);
}
Exemple #12
0
HBITMAP win95_screen_shot()
{
	HDC hdcscreen;
	HDC hdccapture;
	HBITMAP screen_bitmap;
	HBITMAP old_bitmap;

//@@	hdcscreen = CreateDC("DISPLAY", NULL, NULL, NULL);
	IDirectDrawSurface_GetDC(dd_grd_screencanv->lpdds, &hdcscreen);
	hdccapture = CreateCompatibleDC(hdcscreen);
	
	screen_bitmap = CreateCompatibleBitmap(hdcscreen, GRMODEINFO(w), GRMODEINFO(h));

	if (!screen_bitmap) {
		DeleteDC(hdccapture);
		IDirectDrawSurface_ReleaseDC(dd_grd_screencanv->lpdds, hdcscreen);
	//@@	DeleteDC(hdcscreen);
		return NULL;
	}

	old_bitmap = SelectObject(hdccapture, screen_bitmap);
	if (!old_bitmap) {
		DeleteObject(screen_bitmap);
		DeleteDC(hdccapture);
		IDirectDrawSurface_ReleaseDC(dd_grd_screencanv->lpdds, hdcscreen);
		//@@	DeleteDC(hdcscreen);
		return NULL;
	}
	
	if (!BitBlt(hdccapture, 0,0,GRMODEINFO(w), GRMODEINFO(h), hdcscreen, 0, 0,
			SRCCOPY)) {
		SelectObject(hdccapture, old_bitmap);
		DeleteObject(screen_bitmap);
		DeleteDC(hdccapture);
		IDirectDrawSurface_ReleaseDC(dd_grd_screencanv->lpdds, hdcscreen);
	//@@	DeleteDC(hdcscreen);
		return NULL;
	}

	screen_bitmap = SelectObject(hdccapture, old_bitmap);
	DeleteDC(hdccapture);

	IDirectDrawSurface_ReleaseDC(dd_grd_screencanv->lpdds, hdcscreen);
//@@	DeleteDC(hdcscreen);

	return screen_bitmap;
}		
Exemple #13
0
//
// Print a text to the surface
//
VOID TextPrint(int x, int y, LPCSTR message)
{
	HRESULT hr;
	HDC hdc = NULL;

	// Get the device context handle.
	hr = IDirectDrawSurface_GetDC(ScreenVirtual,&hdc);
	if (hr != DD_OK)
		return;

	// Write the message.
	SetBkMode(hdc, TRANSPARENT);
	SetTextColor(hdc, RGB(255, 255, 255));
	TextOutA(hdc, x, y, message, (int)strlen(message));

	// Release the device context.
	hr = IDirectDrawSurface_ReleaseDC(ScreenVirtual,hdc);
}
Exemple #14
0
void DisplayInput(void)
{
#ifdef _WINDOWS
	HDC hdc;
	HFONT hFO;

	IDirectDrawSurface_GetDC(DX.DDSRender,&hdc);
	hFO=(HFONT)SelectObject(hdc,hGFont);

	SetTextColor(hdc,RGB(0,255,0));
	if (bTransparent)
		SetBkMode(hdc,TRANSPARENT);
	else SetBkColor(hdc,RGB(0,0,0));

	ExtTextOut(hdc,3,PSXDisplay.DisplayMode.y-22,0,NULL,cCurrentInput,36,NULL);

	SelectObject(hdc,hFO);
	IDirectDrawSurface_ReleaseDC(DX.DDSRender,hdc);
#endif
}
Exemple #15
0
HANDLE win95_dib_from_bitmap(HBITMAP hbm)
{
	HANDLE hMem,hX;
	BITMAP bm;
	BITMAPINFOHEADER bi;
	BITMAPINFOHEADER *pbi;
	RGBQUAD *rgbp;
	HDC hdc;
	char grpal[768];
	int i;
	HRESULT hRes;

	GetObject(hbm, sizeof(bm), &bm);

	memset(&bi, 0, sizeof(bi));
	
	bi.biSize = sizeof(BITMAPINFOHEADER);
	bi.biWidth = bm.bmWidth;
	bi.biHeight = bm.bmHeight;
	bi.biPlanes = 1;
	bi.biBitCount = bm.bmPlanes * bm.bmBitsPixel;
	bi.biCompression = BI_RGB;

	hMem = GlobalAlloc(GHND, bi.biSize + 256 * sizeof(RGBQUAD));
	if (!hMem) {
		mprintf((1, "WINAPP: Unable to allocate memory for DIB.\n"));
		return NULL;
	}

	pbi = (BITMAPINFOHEADER *)GlobalLock(hMem);
	*pbi = bi;

	hRes = IDirectDrawSurface_GetDC(dd_grd_screencanv->lpdds, &hdc);
	if (hRes != DD_OK) {
		GlobalFree(hMem);
		mprintf((1, "WINAPP: Unable to get GDI DC for DIB creation.\n"));
		return NULL;
	}
	GetDIBits(hdc, hbm, 0, bi.biHeight, NULL, (BITMAPINFO *)pbi, DIB_RGB_COLORS);
	bi = *pbi;
	GlobalUnlock(hMem); 
	
	if (!bi.biSizeImage) {
		bi.biSizeImage = bi.biWidth * bi.biHeight;
	}		
	
	hX = GlobalReAlloc(hMem, bi.biSize + 256*sizeof(RGBQUAD) + bi.biSizeImage,0);
	if (!hX) {
		GlobalFree(hMem);
		IDirectDrawSurface_ReleaseDC(dd_grd_screencanv->lpdds, hdc);
		mprintf((1, "WINAPP: Unable to reallocate mem for DIB.\n"));
		return NULL;
	}
	hMem = hX;

	pbi = GlobalLock(hMem);
	
	if (!GetDIBits(hdc, hbm, 0, 
			pbi->biHeight, 
			(LPSTR)pbi + pbi->biSize + 256*sizeof(RGBQUAD),
			(BITMAPINFO *)pbi, DIB_RGB_COLORS)) {
		GlobalUnlock(hMem);
		GlobalFree(hMem);
		IDirectDrawSurface_ReleaseDC(dd_grd_screencanv->lpdds, hdc);
		mprintf((1, "WINAPP: GetDIBits was unable to get needed info.\n"));
		return NULL;
	}
	bi = *pbi;

	IDirectDrawSurface_ReleaseDC(dd_grd_screencanv->lpdds, hdc);
	
	rgbp = (RGBQUAD *)(((LPSTR)pbi + pbi->biSize));

	gr_palette_read(grpal);
	for (i = 0; i < 256; i++) 
	{
		rgbp[i].rgbRed = grpal[i*3]<<2;
		rgbp[i].rgbGreen = grpal[i*3+1]<<2;
		rgbp[i].rgbBlue = grpal[i*3+2]<<2;
		rgbp[i].rgbReserved = 0;
	}			

	GlobalUnlock(hMem);

	return hMem;
}