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.

154 lines
4.0 KiB

  1. /****************************************************************************
  2. DVA surface provider for Chicago DIBENG
  3. ***************************************************************************/
  4. #include <windows.h>
  5. #include "dva.h"
  6. #include "dibeng.inc"
  7. #include "lockbm.h"
  8. #define RP_TYPE 0x5250 // 'RP'
  9. // stuff in DVAVGA.C
  10. extern HDC hdcScreen;
  11. extern BOOL FAR PASCAL _loadds vga_open_surface(LPVOID pv);
  12. extern void FAR PASCAL _loadds vga_close_surface(LPVOID pv);
  13. /****************************************************************************
  14. ***************************************************************************/
  15. BOOL CALLBACK dib_open_surface(LPVOID pv)
  16. {
  17. return TRUE;
  18. }
  19. /****************************************************************************
  20. ***************************************************************************/
  21. void CALLBACK dib_close_surface(LPVOID pv)
  22. {
  23. }
  24. /****************************************************************************
  25. ***************************************************************************/
  26. BOOL CALLBACK dib_begin_access(LPVOID pv, int x, int y, int AccessDX, int AccessDY)
  27. {
  28. //
  29. // on some SVGAs with 8514 like accelerators, a command Que may need to
  30. // be flushed before touching video memory.
  31. //
  32. // mini drivers should not need this "handholding" but the S3 driver
  33. // does
  34. //
  35. if (hdcScreen)
  36. GetPixel(hdcScreen, x, y);
  37. _asm {
  38. push ds
  39. ; push si
  40. ; push di
  41. lds bx,pv
  42. xor ax,ax
  43. test [bx].deFlags,DISABLED
  44. jnz exit
  45. mov cx,x
  46. mov dx,y
  47. mov si,cx
  48. add si,AccessDX
  49. mov di,y
  50. add di,AccessDY
  51. call dword ptr [bx].deCursorExclude
  52. mov ax,1
  53. exit:
  54. ; pop di
  55. ; pop si
  56. pop ds
  57. }
  58. }
  59. /****************************************************************************
  60. ***************************************************************************/
  61. void FAR PASCAL dib_end_access(LPVOID pv)
  62. {
  63. _asm {
  64. push ds
  65. lds bx,pv
  66. call dword ptr [bx].deCursorUnexclude
  67. pop ds
  68. }
  69. }
  70. /****************************************************************************
  71. ***************************************************************************/
  72. BOOL dib_get_surface(HDC hdc, int nSurface, DVASURFACEINFO FAR *pdva)
  73. {
  74. DIBENGINE FAR *pde;
  75. LPBITMAPINFOHEADER lpbi;
  76. if (nSurface != 0)
  77. return FALSE;
  78. pde = (DIBENGINE FAR *)GetPDevice(hdc);
  79. if (pde == NULL ||
  80. pde->deType != RP_TYPE ||
  81. pde->dePlanes != 1 ||
  82. pde->deVersion != 0x0400)
  83. return FALSE;
  84. lpbi = &pdva->BitmapInfo;
  85. hmemcpy(lpbi, pde->deBitmapInfo, sizeof(BITMAPINFOHEADER));
  86. if (lpbi->biCompression != 0 &&
  87. lpbi->biCompression != BI_BITFIELDS)
  88. return FALSE;
  89. pdva->selSurface = pde->deBitsSelector;
  90. pdva->offSurface = pde->deBitsOffset;
  91. pdva->Flags = 0;
  92. pdva->Version = 0x0100;
  93. pdva->lpSurface = (LPVOID)pde;
  94. (FARPROC)pdva->OpenSurface = (FARPROC)vga_open_surface;
  95. (FARPROC)pdva->CloseSurface = (FARPROC)vga_close_surface;
  96. (FARPROC)pdva->BeginAccess = (FARPROC)dib_begin_access;
  97. (FARPROC)pdva->EndAccess = (FARPROC)dib_end_access;
  98. (FARPROC)pdva->ShowSurface = (FARPROC)NULL;
  99. if (!(pde->deFlags & CURSOREXCLUDE))
  100. {
  101. pdva->BeginAccess = NULL;
  102. pdva->EndAccess = NULL;
  103. }
  104. if (pde->deDeltaScan > 0)
  105. {
  106. lpbi->biWidth = (int)pde->deDeltaScan * 8 / (int)pde->deBitsPixel;
  107. lpbi->biHeight =-(int)pde->deHeight;
  108. lpbi->biSizeImage = pde->deDeltaScan * pde->deHeight;
  109. }
  110. else
  111. {
  112. lpbi->biWidth = -(int)pde->deDeltaScan * 8 / (int)pde->deBitsPixel;
  113. lpbi->biHeight = (int)pde->deHeight;
  114. lpbi->biSizeImage = -(int)pde->deDeltaScan * pde->deHeight;
  115. pdva->offSurface += (long)pde->deDeltaScan * (long)pde->deHeight-1;
  116. }
  117. //
  118. // mark the surface as 16:32 pointer access ONLY!
  119. //
  120. if (pde->deFlags & BANKEDVRAM)
  121. pdva->Flags |= DVAF_1632_ACCESS;
  122. return TRUE;
  123. }