Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

129 lines
3.8 KiB

  1. /****************************************************************************
  2. DVA surface provider for a ATI Mach32 card.
  3. assumes a linear frame buffer
  4. assumes a hardware cursor
  5. ***************************************************************************/
  6. #include <windows.h>
  7. #include "dva.h"
  8. #include "lockbm.h"
  9. extern NEAR PASCAL DetectATI(void);
  10. /****************************************************************************
  11. ***************************************************************************/
  12. BOOL CALLBACK ati_open_surface(LPVOID pv)
  13. {
  14. return TRUE;
  15. }
  16. /****************************************************************************
  17. ***************************************************************************/
  18. void CALLBACK ati_close_surface(LPVOID pv)
  19. {
  20. }
  21. /****************************************************************************
  22. ***************************************************************************/
  23. BOOL CALLBACK ati_begin_access(LPVOID pv, int x, int y, int dx, int dy)
  24. {
  25. //
  26. // ATI Mach32 has a HW cursor so we dont do anything
  27. // !!!we may need to check for the sysVM in background
  28. //
  29. return TRUE;
  30. }
  31. /****************************************************************************
  32. ***************************************************************************/
  33. void CALLBACK ati_end_access(LPVOID pv)
  34. {
  35. }
  36. /****************************************************************************
  37. ***************************************************************************/
  38. BOOL ati_get_surface(HDC hdc, int nSurface, DVASURFACEINFO FAR *pdva)
  39. {
  40. DWORD SizeImage;
  41. IBITMAP FAR *pbm;
  42. UINT sel;
  43. DWORD off;
  44. LPBITMAPINFOHEADER lpbi;
  45. if (nSurface != 0)
  46. return FALSE;
  47. pbm = GetPDevice(hdc);
  48. if (pbm == NULL || pbm->bmType == 0)
  49. return FALSE;
  50. if (pbm->bmType != 0x2000)
  51. return FALSE;
  52. if (!DetectATI())
  53. return FALSE;
  54. sel = ((WORD FAR *)&pbm->bmBits)[2];
  55. off = ((DWORD FAR *)&pbm->bmBits)[0];
  56. SizeImage = (DWORD)(UINT)pbm->bmWidthBytes * (DWORD)(UINT)pbm->bmHeight;
  57. if (GetSelectorLimit(sel) != 0xFFFFFFFF || off < 4*1024*1024l)
  58. return FALSE;
  59. sel = 0; // off is the linear offset.
  60. lpbi = &pdva->BitmapInfo;
  61. lpbi->biSize = sizeof(BITMAPINFOHEADER);
  62. lpbi->biWidth = pbm->bmWidthBytes*8/pbm->bmBitsPixel;
  63. lpbi->biHeight = -(int)pbm->bmHeight;
  64. lpbi->biPlanes = pbm->bmPlanes;
  65. lpbi->biBitCount = pbm->bmBitsPixel;
  66. lpbi->biCompression = 0;
  67. lpbi->biSizeImage = SizeImage;
  68. lpbi->biXPelsPerMeter = pbm->bmWidthBytes;
  69. lpbi->biYPelsPerMeter = 0;
  70. lpbi->biClrUsed = 0;
  71. lpbi->biClrImportant = 0;
  72. pdva->selSurface = sel;
  73. pdva->offSurface = off;
  74. pdva->Version = 0x0100;
  75. pdva->Flags = 0;
  76. pdva->lpSurface = (LPVOID)42;
  77. #ifdef DEBUG
  78. {
  79. //
  80. // in DEBUG use the VGA's begin/end access routines so the mouse will flicker!
  81. //
  82. extern BOOL FAR PASCAL _loadds vga_open_surface(LPVOID pv);
  83. extern void FAR PASCAL _loadds vga_close_surface(LPVOID pv);
  84. extern BOOL FAR PASCAL _loadds vga_begin_access(LPVOID pv, int x, int y, int dx, int dy);
  85. extern BOOL FAR PASCAL _loadds vga_end_access(LPVOID pv);
  86. (FARPROC)pdva->OpenSurface = (FARPROC)vga_open_surface;
  87. (FARPROC)pdva->CloseSurface = (FARPROC)vga_close_surface;
  88. (FARPROC)pdva->BeginAccess = (FARPROC)vga_begin_access;
  89. (FARPROC)pdva->EndAccess = (FARPROC)vga_end_access;
  90. }
  91. #else
  92. (FARPROC)pdva->OpenSurface = (FARPROC)ati_open_surface;
  93. (FARPROC)pdva->CloseSurface = (FARPROC)ati_close_surface;
  94. (FARPROC)pdva->BeginAccess = (FARPROC)ati_begin_access;
  95. (FARPROC)pdva->EndAccess = (FARPROC)ati_end_access;
  96. #endif
  97. (FARPROC)pdva->ShowSurface = (FARPROC)NULL;
  98. return TRUE;
  99. }