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.

156 lines
4.1 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->deBitsSelector == NULL ||
  83. pde->deBitmapInfo == NULL ||
  84. pde->deVersion != 0x0400)
  85. return FALSE;
  86. lpbi = &pdva->BitmapInfo;
  87. hmemcpy(lpbi, pde->deBitmapInfo, sizeof(BITMAPINFOHEADER));
  88. if (lpbi->biCompression != 0 &&
  89. lpbi->biCompression != BI_BITFIELDS)
  90. return FALSE;
  91. pdva->selSurface = pde->deBitsSelector;
  92. pdva->offSurface = pde->deBitsOffset;
  93. pdva->Flags = 0;
  94. pdva->Version = 0x0100;
  95. pdva->lpSurface = (LPVOID)pde;
  96. (FARPROC)pdva->OpenSurface = (FARPROC)vga_open_surface;
  97. (FARPROC)pdva->CloseSurface = (FARPROC)vga_close_surface;
  98. (FARPROC)pdva->BeginAccess = (FARPROC)dib_begin_access;
  99. (FARPROC)pdva->EndAccess = (FARPROC)dib_end_access;
  100. (FARPROC)pdva->ShowSurface = (FARPROC)NULL;
  101. if (!(pde->deFlags & CURSOREXCLUDE))
  102. {
  103. pdva->BeginAccess = NULL;
  104. pdva->EndAccess = NULL;
  105. }
  106. if (pde->deDeltaScan > 0)
  107. {
  108. lpbi->biWidth = (int)pde->deDeltaScan * 8 / (int)pde->deBitsPixel;
  109. lpbi->biHeight =-(int)pde->deHeight;
  110. lpbi->biSizeImage = pde->deDeltaScan * pde->deHeight;
  111. }
  112. else
  113. {
  114. lpbi->biWidth = -(int)pde->deDeltaScan * 8 / (int)pde->deBitsPixel;
  115. lpbi->biHeight = (int)pde->deHeight;
  116. lpbi->biSizeImage = -(int)pde->deDeltaScan * pde->deHeight;
  117. pdva->offSurface += (long)pde->deDeltaScan * (long)pde->deHeight-1;
  118. }
  119. //
  120. // mark the surface as 16:32 pointer access ONLY!
  121. //
  122. if (pde->deFlags & BANKEDVRAM)
  123. pdva->Flags |= DVAF_1632_ACCESS;
  124. return TRUE;
  125. }