Leaked source code of windows server 2003
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.

1647 lines
47 KiB

  1. /**************************************************************************
  2. ***************************************************************************
  3. *
  4. * Copyright (c) 1996, Cirrus Logic, Inc.
  5. * All Rights Reserved
  6. *
  7. * FILE: blt_dir.c
  8. *
  9. * DESCRIPTION: Direct blts for the 546x
  10. *
  11. * REVISION HISTORY:
  12. *
  13. * $Log: X:/log/laguna/ddraw/src/blt_dir.c $
  14. *
  15. * Rev 1.21 Mar 04 1998 15:07:10 frido
  16. * Added new shadow macros.
  17. *
  18. * Rev 1.20 06 Jan 1998 11:40:56 xcong
  19. * Change pDriverData into local lpDDHALData for multi-monitor support.
  20. *
  21. * Rev 1.19 Nov 04 1997 09:36:16 frido
  22. * Argh! This file is shared with WIndows 95 and it breaks there because I added
  23. * the REQUIRE macro. So I have defined it for non Windows NT as the WaitForRoom
  24. * macro.
  25. *
  26. * Rev 1.18 Nov 03 1997 12:48:22 frido
  27. * Added REQUIRE macros.
  28. * Removed redundant WaitForRoom macros.
  29. *
  30. * Rev 1.17 03 Oct 1997 14:29:50 RUSSL
  31. * Initial changes for use of hw clipped blts
  32. * All changes wrapped in #if ENABLE_CLIPPEDBLTS/#endif blocks and
  33. * ENABLE_CLIPPEDBLTS defaults to 0 (so the code is disabled)
  34. *
  35. * Rev 1.16 19 Aug 1997 09:18:42 RUSSL
  36. * Updated require counts in DIR_DrvStrBlt & DIR_DrvStrBlt65
  37. *
  38. * Rev 1.15 30 Jul 1997 20:55:52 RANDYS
  39. * Added code to check for zero extent blts
  40. *
  41. * Rev 1.14 24 Jul 1997 12:32:02 RUSSL
  42. * Botched the overlap check, changed || to &&
  43. *
  44. * Rev 1.13 24 Jul 1997 11:19:02 RUSSL
  45. * Added DIR_DrvStrBlt_OverlapCheck & DIR_DrvStrMBlt_OverlapCheck
  46. * inline functions
  47. *
  48. * Rev 1.12 14 Jul 1997 14:55:50 RUSSL
  49. * For Win95, split DIR_DrvStrBlt into two versions, one version for 62/64
  50. * and one version for 65+. BltInit points pfnDrvStrBlt to the appropriate
  51. * version.
  52. *
  53. * Rev 1.11 08 Jul 1997 11:17:28 RUSSL
  54. * Modified chip check in DIR_DrvStrBlt to a one bit test rather a two dword
  55. * compare (for Win95 only)
  56. *
  57. * Rev 1.10 19 May 1997 14:02:02 bennyn
  58. * Removed all #ifdef NT for WaitForRoom macro
  59. *
  60. * Rev 1.9 03 Apr 1997 15:04:48 RUSSL
  61. * Added DIR_DrvDstMBlt function
  62. *
  63. * Rev 1.8 26 Mar 1997 13:54:24 RUSSL
  64. * Added DIR_DrvSrcMBlt function
  65. * Changed ACCUM_X workaround to just write 0 to LNCNTL
  66. *
  67. * Rev 1.7 21 Mar 1997 18:05:04 RUSSL
  68. * Added workaround writing ACCUM_X in DIR_DrvStrBlt
  69. *
  70. * Rev 1.6 12 Mar 1997 15:00:38 RUSSL
  71. * replaced a block of includes with include of precomp.h for
  72. * precompiled headers
  73. *
  74. * Rev 1.5 07 Mar 1997 12:49:16 RUSSL
  75. * Modified DDRAW_COMPAT usage
  76. *
  77. * Rev 1.4 27 Jan 1997 17:28:34 BENNYN
  78. * Added Win95 support
  79. *
  80. * Rev 1.3 23 Jan 1997 16:55:56 bennyn
  81. * Added 5465 DD support
  82. *
  83. * Rev 1.2 25 Nov 1996 16:52:20 RUSSL
  84. * NT change broke Win95 build
  85. *
  86. * Rev 1.1 25 Nov 1996 16:13:54 bennyn
  87. * Fixed misc compiling error for NT
  88. *
  89. * Rev 1.0 25 Nov 1996 15:11:12 RUSSL
  90. * Initial revision.
  91. *
  92. * Rev 1.3 18 Nov 1996 16:20:12 RUSSL
  93. * Added file logging for DDraw entry points and register writes
  94. *
  95. * Rev 1.2 10 Nov 1996 12:36:24 CRAIGN
  96. * Frido's 1111 release.
  97. * Minor parenthesis change - bug fix.
  98. *
  99. * Rev 1.1 01 Nov 1996 13:08:32 RUSSL
  100. * Merge WIN95 & WINNT code for Blt32
  101. *
  102. * Rev 1.0 01 Nov 1996 09:27:42 BENNYN
  103. * Initial revision.
  104. *
  105. * Rev 1.0 25 Oct 1996 11:08:18 RUSSL
  106. * Initial revision.
  107. *
  108. ***************************************************************************
  109. ***************************************************************************/
  110. /***************************************************************************
  111. * I N C L U D E S
  112. ****************************************************************************/
  113. #include "precomp.h"
  114. // If WinNT 3.5 skip all the source code
  115. #if defined WINNT_VER35 // WINNT_VER35
  116. #else
  117. #ifdef WINNT_VER40 // WINNT_VER40
  118. #define DBGLVL 1
  119. #define AFPRINTF(n)
  120. #else
  121. #include "bltP.h"
  122. #endif // !WINNT_VER40
  123. /***************************************************************************
  124. * D E F I N E S
  125. ****************************************************************************/
  126. #ifndef WINNT_VER40
  127. #define REQUIRE( size ) while ( (volatile)pREG->grQFREE < size )
  128. #endif
  129. /***************************************************************************
  130. * S T A T I C V A R I A B L E S
  131. ****************************************************************************/
  132. #ifndef WINNT_VER40
  133. ASSERTFILE("blt_dir.c");
  134. #define LL_DRAWBLTDEF(drawbltdef, r) LL32(grDRAWBLTDEF.DW, drawbltdef)
  135. #define LL_BGCOLOR(color, r) LL32(grOP_opBGCOLOR.DW, color)
  136. #define LL_FGCOLOR(color, r) LL32(grOP_opFGCOLOR.DW, color)
  137. #endif
  138. /***************************************************************************
  139. *
  140. * FUNCTION: DIR_Delay9BitBlt
  141. *
  142. * DESCRIPTION:
  143. *
  144. ****************************************************************************/
  145. void DIR_Delay9BitBlt
  146. (
  147. #ifdef WINNT_VER40
  148. PDEV *ppdev,
  149. DRIVERDATA *lpDDHALData,
  150. #else
  151. LPGLOBALDATA lpDDHALData,
  152. #endif
  153. BOOL ninebit_on
  154. )
  155. {
  156. PVGAR pREG = (PVGAR) lpDDHALData->RegsAddress;
  157. DD_LOG(("DIR_Delay9BitBlt\r\n"));
  158. /* This is to ensure that the last packet of any previous blt */
  159. /* does no go out with 9th bit set incorrectly */
  160. /* The boolean paramter is the 9th bit of the PREVIOUS BLT */
  161. REQUIRE(7);
  162. if (ninebit_on)
  163. {
  164. LL_DRAWBLTDEF(((BD_RES * IS_VRAM + BD_OP1 * IS_SOLID) << 16) |
  165. (DD_PTAG | ROP_OP1_copy), 0);
  166. }
  167. else
  168. {
  169. LL_DRAWBLTDEF(((BD_RES * IS_VRAM + BD_OP1 * IS_SOLID) << 16) |
  170. (ROP_OP1_copy), 0);
  171. }
  172. LL32(grOP0_opRDRAM.DW, lpDDHALData->PTAGFooPixel);
  173. LL32(grBLTEXT_EX.DW, MAKELONG(1,1));
  174. } /* DIR_Delay9BitBlt */
  175. /***************************************************************************
  176. *
  177. * FUNCTION: DIR_EdgeFillBlt
  178. *
  179. * DESCRIPTION: Solid Fill BLT to fill in edges ( Pixel Coords / Extents )
  180. *
  181. ****************************************************************************/
  182. void DIR_EdgeFillBlt
  183. (
  184. #ifdef WINNT_VER40
  185. PDEV *ppdev,
  186. DRIVERDATA *lpDDHALData,
  187. #else
  188. LPGLOBALDATA lpDDHALData,
  189. #endif
  190. int xFill,
  191. int yFill,
  192. int cxFill,
  193. int cyFill,
  194. DWORD FillValue,
  195. BOOL ninebit_on
  196. )
  197. {
  198. PVGAR pREG = (PVGAR) lpDDHALData->RegsAddress;
  199. #ifdef WINNT_VER40
  200. DISPDBG((DBGLVL, "DIR_EdgeFillBlt - dst=%08lX ext=%08lX color=%08lX\r\n",
  201. MAKELONG(xFill,yFill),MAKELONG(cxFill,cyFill),FillValue));
  202. #endif
  203. DD_LOG(("DIR_EdgeFillBlt - dst=%08lX ext=%08lX color=%08lX\r\n",
  204. MAKELONG(xFill,yFill),MAKELONG(cxFill,cyFill),FillValue));
  205. REQUIRE(9);
  206. if (ninebit_on)
  207. {
  208. LL_DRAWBLTDEF(((BD_RES * IS_VRAM + BD_OP1 * IS_SOLID) << 16) |
  209. (DD_PTAG | ROP_OP1_copy), 0);
  210. }
  211. else
  212. {
  213. LL_DRAWBLTDEF(((BD_RES * IS_VRAM + BD_OP1 * IS_SOLID) << 16) |
  214. (ROP_OP1_copy), 0);
  215. }
  216. LL_BGCOLOR(FillValue, 0);
  217. LL32(grOP0_opRDRAM.DW, MAKELONG(xFill,yFill));
  218. LL32(grBLTEXT_EX.DW, MAKELONG(cxFill,cyFill));
  219. #ifndef WINNT_VER40
  220. DBG_MESSAGE((" Direct Edge Fill %d,%d %d x %d %08X %s", xFill, yFill, cxFill, cyFill, FillValue, (ninebit_on ? "TRUE" : "FALSE")));
  221. #endif // WINNT_VER40
  222. } /* DIR_EdgeFillBlt */
  223. /***************************************************************************
  224. *
  225. * FUNCTION: DIR_MEdgeFillBlt
  226. *
  227. * DESCRIPTION: Using BYTE BLT coords / Extents perform EdgeFill BLT
  228. *
  229. ****************************************************************************/
  230. void DIR_MEdgeFillBlt
  231. (
  232. #ifdef WINNT_VER40
  233. PDEV *ppdev,
  234. DRIVERDATA *lpDDHALData,
  235. #else
  236. LPGLOBALDATA lpDDHALData,
  237. #endif
  238. int xFill,
  239. int yFill,
  240. int cxFill,
  241. int cyFill,
  242. DWORD FillValue,
  243. BOOL ninebit_on
  244. )
  245. {
  246. PVGAR pREG = (PVGAR) lpDDHALData->RegsAddress;
  247. DD_LOG(("DIR_MEdgeFillBlt - dst=%08lX ext=%08lX color=%08lX\r\n",
  248. MAKELONG(xFill,yFill),MAKELONG(cxFill,cyFill),FillValue));
  249. REQUIRE(9);
  250. if (ninebit_on)
  251. {
  252. LL_DRAWBLTDEF(((BD_RES * IS_VRAM + BD_OP1 * IS_SOLID) << 16) |
  253. (DD_PTAG | ROP_OP1_copy), 0);
  254. }
  255. else
  256. {
  257. LL_DRAWBLTDEF(((BD_RES * IS_VRAM + BD_OP1 * IS_SOLID) << 16) |
  258. (ROP_OP1_copy), 0);
  259. }
  260. LL_BGCOLOR(FillValue, 0);
  261. LL32(grOP0_opMRDRAM.DW, MAKELONG(xFill,yFill));
  262. LL32(grMBLTEXT_EX.DW, MAKELONG(cxFill,cyFill));
  263. #ifndef WINNT_VER40 // Not WINNT_VER40
  264. DBG_MESSAGE((" (M) Edge Fill %d,%d %d x %d %08X %s", xFill, yFill, cxFill, cyFill, FillValue, (ninebit_on ? "TRUE" : "FALSE")));
  265. #endif // WINNT_VER40
  266. } /* DIR_MEdgeFillBlt */
  267. /***************************************************************************
  268. *
  269. * FUNCTION: DIR_DrvDstBlt
  270. *
  271. * DESCRIPTION:
  272. *
  273. ****************************************************************************/
  274. void DIR_DrvDstBlt
  275. (
  276. #ifdef WINNT_VER40
  277. PDEV *ppdev,
  278. DRIVERDATA *lpDDHALData,
  279. #else
  280. LPGLOBALDATA lpDDHALData,
  281. #endif
  282. DWORD dwDrawBlt,
  283. DWORD dwDstCoord,
  284. DWORD dwBgColor,
  285. DWORD dwExtents
  286. )
  287. {
  288. PVGAR pREG = (PVGAR) lpDDHALData->RegsAddress;
  289. DD_LOG(("DIR_DrvDstBlt - dst=%08lX ext=%08lX color=%08lX\r\n",
  290. dwDstCoord,dwExtents,dwBgColor));
  291. REQUIRE(9);
  292. LL_DRAWBLTDEF(dwDrawBlt, 0);
  293. LL_BGCOLOR(dwBgColor, 0);
  294. LL32(grOP0_opRDRAM.DW, dwDstCoord);
  295. LL32(grBLTEXT_EX.DW, dwExtents);
  296. } /* DIR_DrvDstBlt */
  297. /***************************************************************************
  298. *
  299. * FUNCTION: DIR_DrvDstMBlt
  300. *
  301. * DESCRIPTION:
  302. *
  303. ****************************************************************************/
  304. void DIR_DrvDstMBlt
  305. (
  306. #ifdef WINNT_VER40
  307. PDEV *ppdev,
  308. DRIVERDATA *lpDDHALData,
  309. #else
  310. LPGLOBALDATA lpDDHALData,
  311. #endif
  312. DWORD dwDrawBlt,
  313. DWORD dwDstCoord,
  314. DWORD dwBgColor,
  315. DWORD dwExtents
  316. )
  317. {
  318. PVGAR pREG = (PVGAR) lpDDHALData->RegsAddress;
  319. DD_LOG(("DIR_DrvDstMBlt - dst=%08lX ext=%08lX color=%08lX\r\n",
  320. dwDstCoord,dwExtents,dwBgColor));
  321. REQUIRE(9);
  322. LL_DRAWBLTDEF(dwDrawBlt, 0);
  323. LL_BGCOLOR(dwBgColor, 0);
  324. LL32(grOP0_opMRDRAM.DW, dwDstCoord);
  325. LL32(grMBLTEXT_EX.DW, dwExtents);
  326. } /* DIR_DrvDstMBlt */
  327. /***************************************************************************
  328. *
  329. * FUNCTION: DIR_DrvSrcBlt
  330. *
  331. * DESCRIPTION:
  332. *
  333. ****************************************************************************/
  334. void DIR_DrvSrcBlt
  335. (
  336. #ifdef WINNT_VER40
  337. PDEV *ppdev,
  338. DRIVERDATA *lpDDHALData,
  339. #else
  340. LPGLOBALDATA lpDDHALData,
  341. #endif
  342. DWORD dwDrawBlt,
  343. DWORD dwDstCoord,
  344. DWORD dwSrcCoord,
  345. DWORD dwKeyCoord,
  346. DWORD dwKeyColor,
  347. DWORD dwExtents
  348. )
  349. {
  350. PVGAR pREG = (PVGAR) lpDDHALData->RegsAddress;
  351. // Handle overlapped regions.
  352. const int xDelta = (int)LOWORD(dwDstCoord) - (int)LOWORD(dwSrcCoord);
  353. DD_LOG(("DIR_DrvSrcBlt - dst=%08lX src=%08lX ext=%08lX color=%08lX\r\n",
  354. dwDstCoord,dwSrcCoord,dwExtents,dwKeyColor));
  355. // Check for x overlap.
  356. if ( abs(xDelta) < (int)LOWORD(dwExtents) )
  357. {
  358. const int yDelta = (int)HIWORD(dwDstCoord) - (int)HIWORD(dwSrcCoord);
  359. if ( (yDelta > 0) && (yDelta < (int)HIWORD(dwExtents)) )
  360. {
  361. const DWORD dwDelta = (dwExtents & MAKELONG(0, -1)) - MAKELONG(0, 1);
  362. // Convert to a bottom-up blt.
  363. dwDrawBlt |= MAKELONG(0, BD_YDIR);
  364. dwDstCoord += dwDelta;
  365. dwSrcCoord += dwDelta;
  366. dwKeyCoord += dwDelta;
  367. }
  368. // are we sliding to the right?
  369. else if ( (xDelta > 0) && (yDelta == 0) )
  370. {
  371. const DWORD dwDelta = MAKELONG(xDelta, 0);
  372. // Blt the overlapped piece first.
  373. DIR_DrvSrcBlt(
  374. #ifdef WINNT_VER40
  375. ppdev,
  376. #endif
  377. lpDDHALData,
  378. dwDrawBlt,
  379. dwDstCoord+dwDelta,
  380. dwSrcCoord+dwDelta,
  381. dwKeyCoord+dwDelta,
  382. dwKeyColor,
  383. dwExtents-dwDelta);
  384. // Subtract the overlap from the original extents.
  385. dwExtents = MAKELONG(xDelta, HIWORD(dwExtents));
  386. }
  387. }
  388. // Blt the rest.
  389. REQUIRE(13);
  390. LL_DRAWBLTDEF(dwDrawBlt, 0);
  391. LL_BGCOLOR(dwKeyColor, 0);
  392. LL32(grOP0_opRDRAM.DW, dwDstCoord);
  393. LL32(grOP1_opRDRAM.DW, dwSrcCoord);
  394. LL32(grOP2_opRDRAM.DW, dwKeyCoord);
  395. LL32(grBLTEXT_EX.DW, dwExtents);
  396. } /* DIR_DrvSrcBlt */
  397. /***************************************************************************
  398. *
  399. * FUNCTION: DIR_DrvSrcMBlt
  400. *
  401. * DESCRIPTION:
  402. *
  403. ****************************************************************************/
  404. void DIR_DrvSrcMBlt
  405. (
  406. #ifdef WINNT_VER40
  407. PDEV *ppdev,
  408. DRIVERDATA *lpDDHALData,
  409. #else
  410. LPGLOBALDATA lpDDHALData,
  411. #endif
  412. DWORD dwDrawBlt,
  413. DWORD dwDstCoord,
  414. DWORD dwSrcCoord,
  415. DWORD dwKeyCoord,
  416. DWORD dwKeyColor,
  417. DWORD dwExtents
  418. )
  419. {
  420. PVGAR pREG = (PVGAR) lpDDHALData->RegsAddress;
  421. // Handle overlapped regions.
  422. const int xDelta = (int)LOWORD(dwDstCoord) - (int)LOWORD(dwSrcCoord);
  423. DD_LOG(("DIR_DrvSrcMBlt - dst=%08lX src=%08lX ext=%08lX color=%08lX\r\n",
  424. dwDstCoord,dwSrcCoord,dwExtents,dwKeyColor));
  425. // Check for x overlap.
  426. if ( abs(xDelta) < (int)LOWORD(dwExtents) )
  427. {
  428. const int yDelta = (int)HIWORD(dwDstCoord) - (int)HIWORD(dwSrcCoord);
  429. if ( (yDelta > 0) && (yDelta < (int)HIWORD(dwExtents)) )
  430. {
  431. const DWORD dwDelta = (dwExtents & MAKELONG(0, -1)) - MAKELONG(0, 1);
  432. // Convert to a bottom-up blt.
  433. dwDrawBlt |= MAKELONG(0, BD_YDIR);
  434. dwDstCoord += dwDelta;
  435. dwSrcCoord += dwDelta;
  436. dwKeyCoord += dwDelta;
  437. }
  438. // are we sliding to the right?
  439. else if ( (xDelta > 0) && (yDelta == 0) )
  440. {
  441. const DWORD dwDelta = MAKELONG(xDelta, 0);
  442. // Blt the overlapped piece first.
  443. DIR_DrvSrcMBlt(
  444. #ifdef WINNT_VER40
  445. ppdev,
  446. #endif
  447. lpDDHALData,
  448. dwDrawBlt,
  449. dwDstCoord+dwDelta,
  450. dwSrcCoord+dwDelta,
  451. dwKeyCoord+dwDelta,
  452. dwKeyColor,
  453. dwExtents-dwDelta);
  454. // Subtract the overlap from the original extents.
  455. dwExtents = MAKELONG(xDelta, HIWORD(dwExtents));
  456. }
  457. }
  458. // Blt the rest.
  459. REQUIRE(13);
  460. LL_DRAWBLTDEF(dwDrawBlt, 0);
  461. LL_BGCOLOR(dwKeyColor, 0);
  462. LL32(grOP0_opMRDRAM.DW, dwDstCoord);
  463. LL32(grOP1_opMRDRAM.DW, dwSrcCoord);
  464. LL32(grOP2_opMRDRAM.DW, dwKeyCoord);
  465. LL32(grMBLTEXT_EX.DW, dwExtents);
  466. } /* DIR_DrvSrcMBlt */
  467. #if 0
  468. /***************************************************************************
  469. *
  470. * FUNCTION: DIR_DrvStrBlt_OverlapCheck
  471. *
  472. * DESCRIPTION:
  473. *
  474. ****************************************************************************/
  475. static void INLINE DIR_DrvStrBlt_OverlapCheck
  476. (
  477. #ifdef WINNT_VER40
  478. PDEV *ppdev,
  479. DRIVERDATA *lpDDHALData,
  480. #else
  481. LPGLOBALDATA lpDDHALData,
  482. #endif
  483. autoblt_ptr pblt
  484. )
  485. {
  486. int xdelta,ydelta;
  487. xdelta = abs(pblt->OP0_opRDRAM.pt.X - pblt->OP1_opRDRAM.pt.X);
  488. ydelta = abs(pblt->OP0_opRDRAM.pt.Y - pblt->OP1_opRDRAM.pt.Y);
  489. if ((xdelta < pblt->BLTEXT.pt.X) &&
  490. (ydelta < pblt->BLTEXT.pt.Y))
  491. {
  492. // hack, hack, cough, cough
  493. // pblt->MBLTEXT.DW has src exents (see DrvStretch)
  494. // blt the src to the lower right of the dest
  495. DIR_DrvSrcBlt(
  496. #ifdef WINNT_VER40
  497. ppdev,
  498. #endif
  499. lpDDHALData,
  500. MAKELONG(ROP_OP1_copy, BD_RES * IS_VRAM | BD_OP1 * IS_VRAM),
  501. pblt->OP0_opRDRAM.DW + pblt->BLTEXT.DW - pblt->MBLTEXT.DW,
  502. pblt->OP1_opRDRAM.DW,
  503. 0UL, // don't care
  504. 0UL,
  505. pblt->MBLTEXT.DW);
  506. // update the src ptr to use this copy of the src
  507. pblt->OP1_opRDRAM.DW = pblt->OP0_opRDRAM.DW + pblt->BLTEXT.DW - pblt->MBLTEXT.DW;
  508. }
  509. }
  510. #endif
  511. /***************************************************************************
  512. *
  513. * FUNCTION: DIR_DrvStrMBlt_OverlapCheck
  514. *
  515. * DESCRIPTION:
  516. *
  517. ****************************************************************************/
  518. static void INLINE DIR_DrvStrMBlt_OverlapCheck
  519. (
  520. #ifdef WINNT_VER40
  521. PDEV *ppdev,
  522. DRIVERDATA *lpDDHALData,
  523. #else
  524. LPGLOBALDATA lpDDHALData,
  525. #endif
  526. autoblt_ptr pblt
  527. )
  528. {
  529. int xdelta,ydelta;
  530. xdelta = abs(pblt->OP0_opMRDRAM.pt.X - pblt->OP1_opMRDRAM.pt.X);
  531. ydelta = abs(pblt->OP0_opMRDRAM.pt.Y - pblt->OP1_opMRDRAM.pt.Y);
  532. if ((xdelta < pblt->MBLTEXTR_EX.pt.X) &&
  533. (ydelta < pblt->MBLTEXTR_EX.pt.Y))
  534. {
  535. // hack, hack, cough, cough
  536. // pblt->BLTEXT.DW has src exents (see DrvStretch65)
  537. // blt the src to the lower right of the dest
  538. DIR_DrvSrcMBlt(
  539. #ifdef WINNT_VER40
  540. ppdev,
  541. #endif
  542. lpDDHALData,
  543. MAKELONG(ROP_OP1_copy, BD_RES * IS_VRAM | BD_OP1 * IS_VRAM),
  544. pblt->OP0_opMRDRAM.DW + pblt->MBLTEXTR_EX.DW - pblt->BLTEXT.DW,
  545. pblt->OP1_opMRDRAM.DW,
  546. 0UL, // don't care
  547. 0UL,
  548. pblt->BLTEXT.DW);
  549. // update the src ptr to use this copy of the src
  550. pblt->OP1_opMRDRAM.DW = pblt->OP0_opMRDRAM.DW + pblt->MBLTEXTR_EX.DW - pblt->BLTEXT.DW;
  551. }
  552. }
  553. #ifdef WINNT_VER40
  554. /***************************************************************************
  555. *
  556. * FUNCTION: DIR_DrvStrBlt
  557. *
  558. * DESCRIPTION: NT version
  559. *
  560. ****************************************************************************/
  561. void DIR_DrvStrBlt
  562. (
  563. PDEV *ppdev,
  564. DRIVERDATA *lpDDHALData,
  565. autoblt_ptr pblt
  566. )
  567. {
  568. PVGAR pREG = (PVGAR) lpDDHALData->RegsAddress;
  569. DD_LOG(("DIR_DrvStrBlt - dst=%08lX dstext=%08lX src=%08lX\r\n",
  570. pblt->OP0_opRDRAM.DW,pblt->BLTEXT.DW,pblt->OP1_opRDRAM.DW));
  571. if (ppdev->dwLgDevID >= CL_GD5465)
  572. {
  573. // check for overlap
  574. DIR_DrvStrMBlt_OverlapCheck(
  575. #ifdef WINNT_VER40
  576. ppdev,lpDDHALData,
  577. #endif
  578. pblt);
  579. REQUIRE(19);
  580. LL_DRAWBLTDEF(pblt->DRAWBLTDEF.DW, 0);
  581. // hw clipping currently not used
  582. // LL32(grCLIPULE.DW, pblt->CLIPULE.DW);
  583. // LL32(grCLIPLOR.DW, pblt->CLIPLOR.DW);
  584. LL16(grSRCX, pblt->SRCX);
  585. LL16(grSHRINKINC.W, pblt->SHRINKINC.W);
  586. LL16(grMIN_X, pblt->MIN_X);
  587. LL16(grMAJ_X, pblt->MAJ_X);
  588. #if 0
  589. LL16(grACCUM_X, pblt->ACCUM_X);
  590. #else
  591. // workaround for hw bug when writing to ACCUM_X
  592. // writing LNCNTL changes STRETCH_CNTL so write
  593. // STRETCH_CNTL after this
  594. *(DWORD *)((BYTE *)(pREG)+0x50C) = MAKELONG(pblt->ACCUM_X,0);
  595. LG_LOG(0x50C,MAKELONG(pblt->ACCUM_X,0));
  596. #endif
  597. LL16(grSTRETCH_CNTL.W, pblt->STRETCH_CNTL.W);
  598. LL16(grMAJ_Y, pblt->MAJ_Y);
  599. LL16(grMIN_Y, pblt->MIN_Y);
  600. LL16(grACCUM_Y, pblt->ACCUM_Y);
  601. LL32(grOP0_opMRDRAM.DW, pblt->OP0_opMRDRAM.DW);
  602. LL32(grOP1_opMRDRAM.DW, pblt->OP1_opMRDRAM.DW);
  603. LL32(grMBLTEXTR_EX.DW, pblt->MBLTEXTR_EX.DW);
  604. }
  605. else
  606. {
  607. #if 0
  608. #pragma message("This needs to be checked out on 62/64")
  609. // check for overlap
  610. DIR_DrvStrBlt_OverlapCheck(
  611. #ifdef WINNT_VER40
  612. ppdev,lpDDHALData,
  613. #endif
  614. pblt);
  615. #endif
  616. REQUIRE(18);
  617. LL16(grLNCNTL.W, pblt->LNCNTL.W);
  618. LL16(grSHRINKINC.W, pblt->SHRINKINC.W);
  619. LL16(grSRCX, pblt->SRCX);
  620. LL16(grMAJ_X, pblt->MAJ_X);
  621. LL16(grMIN_X, pblt->MIN_X);
  622. LL16(grACCUM_X, pblt->ACCUM_X);
  623. LL16(grMAJ_Y, pblt->MAJ_Y);
  624. LL16(grMIN_Y, pblt->MIN_Y);
  625. LL16(grACCUM_Y, pblt->ACCUM_Y);
  626. LL32(grOP0_opRDRAM.DW, pblt->OP0_opRDRAM.DW);
  627. LL32(grOP1_opRDRAM.DW, pblt->OP1_opRDRAM.DW);
  628. LL_DRAWBLTDEF(pblt->DRAWBLTDEF.DW, 0);
  629. LL32(grBLTEXTR_EX.DW, pblt->BLTEXT.DW);
  630. } // endif (ppdev->dwLgDevID >= CL_GD5465)
  631. } /* DIR_DrvStrBlt */
  632. #endif
  633. #ifndef WINNT_VER40
  634. /***************************************************************************
  635. *
  636. * FUNCTION: DIR_DrvStrBlt
  637. *
  638. * DESCRIPTION: Win95 62/64 version
  639. *
  640. ****************************************************************************/
  641. void DIR_DrvStrBlt
  642. (
  643. #ifdef WINNT_VER40
  644. PDEV *ppdev,
  645. DRIVERDATA *lpDDHALData,
  646. #else
  647. LPGLOBALDATA lpDDHALData,
  648. #endif
  649. autoblt_ptr pblt
  650. )
  651. {
  652. PVGAR pREG = (PVGAR) lpDDHALData->RegsAddress;
  653. DD_LOG(("DIR_DrvStrBlt - dst=%08lX dstext=%08lX src=%08lX\r\n",
  654. pblt->OP0_opRDRAM.DW,pblt->BLTEXT.DW,pblt->OP1_opRDRAM.DW));
  655. #if 0
  656. #pragma message("This needs to be checked out on 62/64")
  657. // check for overlap
  658. DIR_DrvStrBlt_OverlapCheck(
  659. #ifdef WINNT_VER40
  660. ppdev,
  661. #endif
  662. lpDDHALData,
  663. pblt);
  664. #endif
  665. REQUIRE(18);
  666. LL16(grLNCNTL.W, pblt->LNCNTL.W);
  667. LL16(grSHRINKINC.W, pblt->SHRINKINC.W);
  668. LL16(grSRCX, pblt->SRCX);
  669. LL16(grMAJ_X, pblt->MAJ_X);
  670. LL16(grMIN_X, pblt->MIN_X);
  671. LL16(grACCUM_X, pblt->ACCUM_X);
  672. LL16(grMAJ_Y, pblt->MAJ_Y);
  673. LL16(grMIN_Y, pblt->MIN_Y);
  674. LL16(grACCUM_Y, pblt->ACCUM_Y);
  675. LL32(grOP0_opRDRAM.DW, pblt->OP0_opRDRAM.DW);
  676. LL32(grOP1_opRDRAM.DW, pblt->OP1_opRDRAM.DW);
  677. LL_DRAWBLTDEF(pblt->DRAWBLTDEF.DW, 0);
  678. LL32(grBLTEXTR_EX.DW, pblt->BLTEXT.DW);
  679. } /* DIR_DrvStrBlt */
  680. /***************************************************************************
  681. *
  682. * FUNCTION: DIR_DrvStrBlt65
  683. *
  684. * DESCRIPTION: Win95 65+ version
  685. *
  686. ****************************************************************************/
  687. void DIR_DrvStrBlt65
  688. (
  689. #ifdef WINNT_VER40
  690. PDEV *ppdev,
  691. DRIVERDATA *lpDDHALData,
  692. #else
  693. LPGLOBALDATA lpDDHALData,
  694. #endif
  695. autoblt_ptr pblt
  696. )
  697. {
  698. PVGAR pREG = (PVGAR) lpDDHALData->RegsAddress;
  699. DD_LOG(("DIR_DrvStrBlt65 - dst=%08lX dstext=%08lX src=%08lX\r\n",
  700. pblt->OP0_opMRDRAM.DW,pblt->MBLTEXT.DW,pblt->OP1_opMRDRAM.DW));
  701. // check for overlap
  702. DIR_DrvStrMBlt_OverlapCheck(
  703. #ifdef WINNT_VER40
  704. ppdev,
  705. #endif
  706. lpDDHALData,
  707. pblt);
  708. REQUIRE(19);
  709. LL_DRAWBLTDEF(pblt->DRAWBLTDEF.DW, 0);
  710. LL16(grSRCX, pblt->SRCX);
  711. LL16(grSHRINKINC.W, pblt->SHRINKINC.W);
  712. LL16(grMIN_X, pblt->MIN_X);
  713. LL16(grMAJ_X, pblt->MAJ_X);
  714. #if 0
  715. LL16(grACCUM_X, pblt->ACCUM_X);
  716. #else
  717. // workaround for hw bug when writing to ACCUM_X
  718. // writing LNCNTL changes STRETCH_CNTL so write
  719. // STRETCH_CNTL after this
  720. *(DWORD *)((BYTE *)(pREG)+0x50C) = MAKELONG(pblt->ACCUM_X,0);
  721. LG_LOG(0x50C,MAKELONG(pblt->ACCUM_X,0));
  722. #endif
  723. LL16(grSTRETCH_CNTL.W, pblt->STRETCH_CNTL.W);
  724. LL16(grMAJ_Y, pblt->MAJ_Y);
  725. LL16(grMIN_Y, pblt->MIN_Y);
  726. LL16(grACCUM_Y, pblt->ACCUM_Y);
  727. LL32(grOP0_opMRDRAM.DW, pblt->OP0_opMRDRAM.DW);
  728. LL32(grOP1_opMRDRAM.DW, pblt->OP1_opMRDRAM.DW);
  729. LL32(grMBLTEXTR_EX.DW, pblt->MBLTEXTR_EX.DW);
  730. } /* DIR_DrvStrBlt65 */
  731. #endif
  732. /***************************************************************************
  733. *
  734. * FUNCTION: DIR_DrvStrMBlt
  735. *
  736. * DESCRIPTION:
  737. *
  738. ****************************************************************************/
  739. void DIR_DrvStrMBlt
  740. (
  741. #ifdef WINNT_VER40
  742. PDEV *ppdev,
  743. DRIVERDATA *lpDDHALData,
  744. #else
  745. LPGLOBALDATA lpDDHALData,
  746. #endif
  747. autoblt_ptr pblt
  748. )
  749. {
  750. PVGAR pREG = (PVGAR) lpDDHALData->RegsAddress;
  751. DD_LOG(("DIR_DrvStrMBlt - dst=%08lX dstext=%08lX src=%08lX\r\n",
  752. pblt->OP0_opRDRAM.DW,pblt->BLTEXT.DW,pblt->OP1_opRDRAM.DW));
  753. #ifndef WINNT_VER40
  754. /* Check for a zero extent blt */
  755. if ((pblt->BLTEXT.pt.X == 0) || (pblt->BLTEXT.pt.Y == 0))
  756. return;
  757. DBG_MESSAGE(("DIR_DrvStrMBlt: %4d,%4d -> %4d,%4d %4dx%4d %04x %4d %04x",
  758. pblt->OP1_opRDRAM.PT.X, pblt->OP1_opRDRAM.PT.Y,
  759. pblt->OP0_opRDRAM.PT.X, pblt->OP0_opRDRAM.PT.Y,
  760. pblt->BLTEXT.PT.X, pblt->BLTEXT.PT.Y,
  761. pblt->ACCUM_X, pblt->SRCX, pblt->LNCNTL.W));
  762. APRINTF(("DIR_DrvStrMBlt: %4d,%4d -> %4d,%4d %4dx%4d %04x %4d %04x",
  763. pblt->OP1_opRDRAM.PT.X, pblt->OP1_opRDRAM.PT.Y,
  764. pblt->OP0_opRDRAM.PT.X, pblt->OP0_opRDRAM.PT.Y,
  765. pblt->BLTEXT.PT.X, pblt->BLTEXT.PT.Y,
  766. pblt->ACCUM_X, pblt->SRCX, pblt->LNCNTL.W));
  767. #endif //!WINNT_VER40
  768. REQUIRE(18);
  769. LL16(grLNCNTL.W, pblt->LNCNTL.W);
  770. LL16(grSHRINKINC.W, pblt->SHRINKINC.W);
  771. LL16(grSRCX, pblt->SRCX);
  772. LL16(grMAJ_X, pblt->MAJ_X);
  773. LL16(grMIN_X, pblt->MIN_X);
  774. LL16(grACCUM_X, pblt->ACCUM_X);
  775. LL16(grMAJ_Y, pblt->MAJ_Y);
  776. LL16(grMIN_Y, pblt->MIN_Y);
  777. LL16(grACCUM_Y, pblt->ACCUM_Y);
  778. LL32(grOP0_opMRDRAM.DW, pblt->OP0_opRDRAM.DW);
  779. LL32(grOP1_opMRDRAM.DW, pblt->OP1_opRDRAM.DW);
  780. LL_DRAWBLTDEF(pblt->DRAWBLTDEF.DW, 0);
  781. #ifndef WINNT_VER40
  782. // MBLTEXTR_EX.pt.Y is broken in the 5464.
  783. // We can use BLTEXTR_EX.pt.Y instead.
  784. //pREG->grMBLTEXTR_EX = pblt->BLTEXT;
  785. LL16(grMBLTEXTR_EX.pt.X, pblt->BLTEXT.pt.X);
  786. LL16(grBLTEXTR_EX.pt.Y, pblt->BLTEXT.pt.Y);
  787. #else
  788. LL32(grMBLTEXTR_EX.DW, pblt->BLTEXT.DW);
  789. #endif
  790. } /* DIR_DrvStrMBlt */
  791. /***************************************************************************
  792. *
  793. * FUNCTION: DIR_DrvStrMBltY
  794. *
  795. * DESCRIPTION: Write regs that don't vary over the stripes
  796. * Used in conjunction with DIR_DrvStrMBltX
  797. *
  798. ****************************************************************************/
  799. void DIR_DrvStrMBltY
  800. (
  801. #ifdef WINNT_VER40
  802. PDEV *ppdev,
  803. DRIVERDATA *lpDDHALData,
  804. #else
  805. LPGLOBALDATA lpDDHALData,
  806. #endif
  807. autoblt_ptr pblt
  808. )
  809. {
  810. PVGAR pREG = (PVGAR) lpDDHALData->RegsAddress;
  811. DD_LOG(("DIR_DrvStrMBltY - dst.Y=%04X dstext.Y=%04X src=%04X\r\n",
  812. pblt->OP0_opRDRAM.pt.Y,pblt->BLTEXT.pt.Y,pblt->OP1_opRDRAM.pt.Y));
  813. #ifndef WINNT_VER40
  814. /* Check for a zero extent */
  815. if (pblt->BLTEXT.pt.Y == 0)
  816. return;
  817. DBG_MESSAGE(("DIR_DrvStrMBltY: %4d,%4d -> %4d,%4d %4dx%4d %04x %4d %04x",
  818. pblt->OP1_opRDRAM.PT.X, pblt->OP1_opRDRAM.PT.Y,
  819. pblt->OP0_opRDRAM.PT.X, pblt->OP0_opRDRAM.PT.Y,
  820. pblt->BLTEXT.PT.X, pblt->BLTEXT.PT.Y,
  821. pblt->ACCUM_X, pblt->SRCX, pblt->LNCNTL.W));
  822. APRINTF(("DIR_DrvStrMBltY: %4d,%4d -> %4d,%4d %4dx%4d %04x %4d %04x",
  823. pblt->OP1_opRDRAM.PT.X, pblt->OP1_opRDRAM.PT.Y,
  824. pblt->OP0_opRDRAM.PT.X, pblt->OP0_opRDRAM.PT.Y,
  825. pblt->BLTEXT.PT.X, pblt->BLTEXT.PT.Y,
  826. pblt->ACCUM_X, pblt->SRCX, pblt->LNCNTL.W));
  827. #endif //!WINNT_VER40
  828. REQUIRE(12);
  829. LL16(grLNCNTL.W, pblt->LNCNTL.W);
  830. LL16(grSHRINKINC.W, pblt->SHRINKINC.W);
  831. LL16(grMAJ_X, pblt->MAJ_X);
  832. LL16(grMIN_X, pblt->MIN_X);
  833. LL16(grMAJ_Y, pblt->MAJ_Y);
  834. LL16(grMIN_Y, pblt->MIN_Y);
  835. LL16(grACCUM_Y, pblt->ACCUM_Y);
  836. LL16(grOP0_opMRDRAM.pt.Y, pblt->OP0_opRDRAM.pt.Y);
  837. LL16(grOP1_opMRDRAM.pt.Y, pblt->OP1_opRDRAM.pt.Y);
  838. LL_DRAWBLTDEF(pblt->DRAWBLTDEF.DW, 0);
  839. LL16(grMBLTEXTR_XEX.pt.Y, pblt->BLTEXT.pt.Y);
  840. } /* DIR_DrvStrMBltY */
  841. /***************************************************************************
  842. *
  843. * FUNCTION: DrvStrMBltX
  844. *
  845. * DESCRIPTION: Write stripe specific regs
  846. * Used in conjunction with DIR_DrvStrMBltY
  847. *
  848. ****************************************************************************/
  849. void DIR_DrvStrMBltX
  850. (
  851. #ifdef WINNT_VER40
  852. PDEV *ppdev,
  853. DRIVERDATA *lpDDHALData,
  854. #else
  855. LPGLOBALDATA lpDDHALData,
  856. #endif
  857. autoblt_ptr pblt
  858. )
  859. {
  860. PVGAR pREG = (PVGAR) lpDDHALData->RegsAddress;
  861. DD_LOG(("DIR_DrvStrMBltX - dst.X=%04X dstext.X=%04X src.X=%04X\r\n",
  862. pblt->OP0_opRDRAM.pt.X,pblt->BLTEXT.pt.X,pblt->OP1_opRDRAM.pt.X));
  863. #ifndef WINNT_VER40
  864. /* Check for a zero extent */
  865. if (pblt->BLTEXT.pt.X == 0)
  866. return;
  867. DBG_MESSAGE(("DIR_DrvStrMBltX: %4d,%4d -> %4d,%4d %4dx%4d %04x %4d %04x",
  868. pblt->OP1_opRDRAM.PT.X, pblt->OP1_opRDRAM.PT.Y,
  869. pblt->OP0_opRDRAM.PT.X, pblt->OP0_opRDRAM.PT.Y,
  870. pblt->BLTEXT.PT.X, pblt->BLTEXT.PT.Y,
  871. pblt->ACCUM_X, pblt->SRCX, pblt->LNCNTL.W));
  872. APRINTF(("DIR_DrvStrMBltX: %4d,%4d -> %4d,%4d %4dx%4d %04x %4d %04x",
  873. pblt->OP1_opRDRAM.PT.X, pblt->OP1_opRDRAM.PT.Y,
  874. pblt->OP0_opRDRAM.PT.X, pblt->OP0_opRDRAM.PT.Y,
  875. pblt->BLTEXT.PT.X, pblt->BLTEXT.PT.Y,
  876. pblt->ACCUM_X, pblt->SRCX, pblt->LNCNTL.W));
  877. #endif //!WINNT_VER40
  878. REQUIRE(6);
  879. LL16(grSRCX, pblt->SRCX);
  880. LL16(grACCUM_X, pblt->ACCUM_X);
  881. LL16(grOP0_opMRDRAM.pt.X, pblt->OP0_opRDRAM.pt.X);
  882. LL16(grOP1_opMRDRAM.pt.X, pblt->OP1_opRDRAM.pt.X);
  883. LL16(grMBLTEXTR_XEX.pt.X, pblt->BLTEXT.pt.X);
  884. } /* DIR_DrvStrMBltX */
  885. /***************************************************************************
  886. *
  887. * FUNCTION: DIR_DrvStrBltY
  888. *
  889. * DESCRIPTION: Write regs that don't vary over the stripes
  890. * Used in conjunction with DIR_DrvStrBltX
  891. *
  892. ****************************************************************************/
  893. void DIR_DrvStrBltY
  894. (
  895. #ifdef WINNT_VER40
  896. PDEV *ppdev,
  897. DRIVERDATA *lpDDHALData,
  898. #else
  899. LPGLOBALDATA lpDDHALData,
  900. #endif
  901. autoblt_ptr pblt
  902. )
  903. {
  904. PVGAR pREG = (PVGAR) lpDDHALData->RegsAddress;
  905. DD_LOG(("DIR_DrvStrBltY\r\n"));
  906. #ifndef WINNT_VER40
  907. /* Check for a zero extent */
  908. if (pblt->BLTEXT.pt.Y == 0)
  909. return;
  910. DBG_MESSAGE(("DIR_DrvStrBltY: %4d,%4d -> %4d,%4d %4dx%4d %04x %4d %04x",
  911. pblt->OP1_opRDRAM.PT.X, pblt->OP1_opRDRAM.PT.Y,
  912. pblt->OP0_opRDRAM.PT.X, pblt->OP0_opRDRAM.PT.Y,
  913. pblt->BLTEXT.PT.X, pblt->BLTEXT.PT.Y,
  914. pblt->ACCUM_X, pblt->SRCX, pblt->LNCNTL.W));
  915. APRINTF(("DIR_DrvStrBltY: %4d,%4d -> %4d,%4d %4dx%4d %04x %4d %04x",
  916. pblt->OP1_opRDRAM.PT.X, pblt->OP1_opRDRAM.PT.Y,
  917. pblt->OP0_opRDRAM.PT.X, pblt->OP0_opRDRAM.PT.Y,
  918. pblt->BLTEXT.PT.X, pblt->BLTEXT.PT.Y,
  919. pblt->ACCUM_X, pblt->SRCX, pblt->LNCNTL.W));
  920. #endif //!WINNT_VER40
  921. REQUIRE(10);
  922. LL16(grLNCNTL.W, pblt->LNCNTL.W);
  923. LL16(grSHRINKINC.W, pblt->SHRINKINC.W);
  924. LL16(grSRCX, pblt->SRCX);
  925. LL16(grMAJ_X, pblt->MAJ_X);
  926. LL16(grMIN_X, pblt->MIN_X);
  927. LL16(grMAJ_Y, pblt->MAJ_Y);
  928. LL16(grMIN_Y, pblt->MIN_Y);
  929. LL16(grACCUM_Y, pblt->ACCUM_Y);
  930. LL_DRAWBLTDEF(pblt->DRAWBLTDEF.DW, 0);
  931. } /* DIR_DrvStrBltY */
  932. /***************************************************************************
  933. *
  934. * FUNCTION: DIR_DrvStrBltX
  935. *
  936. * DESCRIPTION: Write stripe specific regs
  937. * Used in conjunction with DIR_DrvStrMBltY
  938. *
  939. ****************************************************************************/
  940. void DIR_DrvStrBltX
  941. (
  942. #ifdef WINNT_VER40
  943. PDEV *ppdev,
  944. DRIVERDATA *lpDDHALData,
  945. #else
  946. LPGLOBALDATA lpDDHALData,
  947. #endif
  948. autoblt_ptr pblt
  949. )
  950. {
  951. PVGAR pREG = (PVGAR) lpDDHALData->RegsAddress;
  952. DD_LOG(("DIR_DrvStrBltX - dst=%08lX dstext=%08lX src=%08lX\r\n",
  953. pblt->OP0_opRDRAM.DW,pblt->BLTEXT.DW,pblt->OP1_opRDRAM.DW));
  954. #ifndef WINNT_VER40
  955. /* Check for a zero extent */
  956. if (pblt->BLTEXT.pt.X == 0)
  957. return;
  958. DBG_MESSAGE(("DIR_DrvStrMBltX: %4d,%4d -> %4d,%4d %4dx%4d %04x %4d %04x",
  959. pblt->OP1_opRDRAM.PT.X, pblt->OP1_opRDRAM.PT.Y,
  960. pblt->OP0_opRDRAM.PT.X, pblt->OP0_opRDRAM.PT.Y,
  961. pblt->BLTEXT.PT.X, pblt->BLTEXT.PT.Y,
  962. pblt->ACCUM_X, pblt->SRCX, pblt->LNCNTL.W));
  963. APRINTF(("DIR_DrvStrMBltX: %4d,%4d -> %4d,%4d %4dx%4d %04x %4d %04x",
  964. pblt->OP1_opRDRAM.PT.X, pblt->OP1_opRDRAM.PT.Y,
  965. pblt->OP0_opRDRAM.PT.X, pblt->OP0_opRDRAM.PT.Y,
  966. pblt->BLTEXT.PT.X, pblt->BLTEXT.PT.Y,
  967. pblt->ACCUM_X, pblt->SRCX, pblt->LNCNTL.W));
  968. #endif //!WINNT_VER40
  969. REQUIRE(8);
  970. LL16(grACCUM_X, pblt->ACCUM_X);
  971. LL32(grOP0_opRDRAM.DW, pblt->OP0_opRDRAM.DW);
  972. LL32(grOP1_opRDRAM.DW, pblt->OP1_opRDRAM.DW);
  973. LL32(grBLTEXTR_EX.DW, pblt->BLTEXT.DW);
  974. } /* DIR_DrvStrBltX */
  975. #if ENABLE_CLIPPEDBLTS
  976. /***************************************************************************
  977. *
  978. * FUNCTION: DIR_HWClippedDrvDstBlt
  979. *
  980. * DESCRIPTION:
  981. *
  982. ****************************************************************************/
  983. void DIR_HWClippedDrvDstBlt
  984. (
  985. #ifdef WINNT_VER40
  986. PDEV *ppdev,
  987. DRIVERDATA *lpDDHALData,
  988. #else
  989. LPGLOBALDATA lpDDHALData,
  990. #endif
  991. DWORD dwDrawBlt,
  992. DWORD dwDstCoord,
  993. DWORD dwBgColor,
  994. DWORD dwExtents,
  995. DWORD dwDstBaseXY,
  996. DWORD dwRectCnt,
  997. LPRECT pDestRects
  998. )
  999. {
  1000. PVGAR pREG = (PVGAR) lpDDHALData->RegsAddress;
  1001. DD_LOG(("DIR_HWClippedDrvDstBlt - dst=%08lX ext=%08lX color=%08lX\r\n",
  1002. dwDstCoord,dwExtents,dwBgColor));
  1003. // check for negative dst coordinates, hw can't deal with negative OP0 values
  1004. if (0 > (short)((REG32 *)&dwDstCoord)->pt.X)
  1005. {
  1006. (short)((REG32 *)&dwExtents)->pt.X += (short)((REG32 *)&dwDstCoord)->pt.X;
  1007. ((REG32 *)&dwDstCoord)->pt.X = 0;
  1008. }
  1009. if (0 > (short)((REG32 *)&dwDstCoord)->pt.Y)
  1010. {
  1011. (short)((REG32 *)&dwExtents)->pt.Y += (short)((REG32 *)&dwDstCoord)->pt.Y;
  1012. ((REG32 *)&dwDstCoord)->pt.Y = 0;
  1013. }
  1014. // setup blt, write BLTEXT reg with extent which doesn't fire off blt
  1015. REQUIRE(8);
  1016. LL_DRAWBLTDEF(dwDrawBlt, 0);
  1017. LL_BGCOLOR(dwBgColor, 0);
  1018. LL32(grOP0_opRDRAM.DW, dwDstCoord);
  1019. LL32(grBLTEXT.DW, dwExtents);
  1020. // loop over clip list
  1021. do
  1022. {
  1023. REG32 UpperLeft;
  1024. REG32 LowerRight;
  1025. // compute cliprect coords
  1026. UpperLeft.DW = dwDstBaseXY + MAKELONG(pDestRects->left, pDestRects->top);
  1027. LowerRight.DW = dwDstBaseXY + MAKELONG(pDestRects->right, pDestRects->bottom);
  1028. // write clipping regs
  1029. REQUIRE(5);
  1030. LL32(grCLIPULE.DW, UpperLeft.DW);
  1031. LL32(grCLIPLOR_EX.DW, LowerRight.DW);
  1032. pDestRects++;
  1033. } while (0 < --dwRectCnt);
  1034. } /* DIR_HWClippedDrvDstBlt */
  1035. /***************************************************************************
  1036. *
  1037. * FUNCTION: DIR_HWClippedDrvDstMBlt
  1038. *
  1039. * DESCRIPTION:
  1040. *
  1041. ****************************************************************************/
  1042. void DIR_HWClippedDrvDstMBlt
  1043. (
  1044. #ifdef WINNT_VER40
  1045. PDEV *ppdev,
  1046. DRIVERDATA *lpDDHALData,
  1047. #else
  1048. LPGLOBLDATA lpDDHALData,
  1049. #endif
  1050. DWORD dwDrawBlt,
  1051. DWORD dwDstCoord,
  1052. DWORD dwBgColor,
  1053. DWORD dwExtents,
  1054. DWORD dwDstBaseXY,
  1055. DWORD dwRectCnt,
  1056. LPRECT pDestRects
  1057. )
  1058. {
  1059. const int nBytesPixel = BYTESPERPIXEL;
  1060. PVGAR pREG = (PVGAR) lpDDHALData->RegsAddress;
  1061. DD_LOG(("DIR_HWClippedDrvDstMBlt - dst=%08lX ext=%08lX color=%08lX\r\n",
  1062. dwDstCoord,dwExtents,dwBgColor));
  1063. // check for negative dst coordinates, hw can't deal with negative OP0 values
  1064. if (0 > (short)((REG32 *)&dwDstCoord)->pt.X)
  1065. {
  1066. (short)((REG32 *)&dwExtents)->pt.X += (short)((REG32 *)&dwDstCoord)->pt.X;
  1067. ((REG32 *)&dwDstCoord)->pt.X = 0;
  1068. }
  1069. if (0 > (short)((REG32 *)&dwDstCoord)->pt.Y)
  1070. {
  1071. (short)((REG32 *)&dwExtents)->pt.Y += (short)((REG32 *)&dwDstCoord)->pt.Y;
  1072. ((REG32 *)&dwDstCoord)->pt.Y = 0;
  1073. }
  1074. // setup blt, write MBLTEXT reg with extent which doesn't fire off blt
  1075. REQUIRE(8);
  1076. LL_DRAWBLTDEF(dwDrawBlt, 0);
  1077. LL_BGCOLOR(dwBgColor, 0);
  1078. LL32(grOP0_opMRDRAM.DW, dwDstCoord);
  1079. LL32(grMBLTEXT.DW, dwExtents);
  1080. // loop over clip list
  1081. do
  1082. {
  1083. REG32 UpperLeft;
  1084. REG32 LowerRight;
  1085. // compute cliprect coords
  1086. UpperLeft.DW = dwDstBaseXY + MAKELONG(pDestRects->left, pDestRects->top);
  1087. LowerRight.DW = dwDstBaseXY + MAKELONG(pDestRects->right, pDestRects->bottom);
  1088. UpperLeft.pt.X *= nBytesPixel;
  1089. LowerRight.pt.X *= nBytesPixel;
  1090. // write clipping regs
  1091. REQUIRE(5);
  1092. LL32(grMCLIPULE.DW, UpperLeft.DW);
  1093. LL32(grMCLIPLOR_EX.DW, LowerRight.DW);
  1094. pDestRects++;
  1095. } while (0 < --dwRectCnt);
  1096. } /* DIR_HWClippedDrvDstMBlt */
  1097. /***************************************************************************
  1098. *
  1099. * FUNCTION: DIR_HWClippedDrvSrcBlt
  1100. *
  1101. * DESCRIPTION:
  1102. *
  1103. ****************************************************************************/
  1104. void DIR_HWClippedDrvSrcBlt
  1105. (
  1106. #ifdef WINNT_VER40
  1107. PDEV *ppdev,
  1108. DRIVERDATA *lpDDHALData,
  1109. #else
  1110. LPGLOBALDATA lpDDHALData,
  1111. #endif
  1112. DWORD dwDrawBlt,
  1113. DWORD dwDstCoord,
  1114. DWORD dwSrcCoord,
  1115. DWORD dwKeyCoord,
  1116. DWORD dwKeyColor,
  1117. DWORD dwExtents,
  1118. DWORD dwDstBaseXY,
  1119. DWORD dwSrcBaseXY,
  1120. DWORD dwRectCnt,
  1121. LPRECT pDestRects
  1122. )
  1123. {
  1124. PVGAR pREG = (PVGAR) lpDDHALData->RegsAddress;
  1125. // Handle overlapped regions
  1126. const int xDelta = (int)LOWORD(dwDstCoord) - (int)LOWORD(dwSrcCoord);
  1127. DD_LOG(("DIR_HWClippedDrvSrcBlt - dst=%08lX src=%08lX ext=%08lX color=%08lX\r\n",
  1128. dwDstCoord,dwSrcCoord,dwExtents,dwKeyColor));
  1129. // check for negative dst coordinates, hw can't deal with negative OP0 values
  1130. if (0 > (short)((REG32 *)&dwDstCoord)->pt.X)
  1131. {
  1132. // reduce extent.X
  1133. (short)((REG32 *)&dwExtents)->pt.X += (short)((REG32 *)&dwDstCoord)->pt.X;
  1134. // bump src.X to right
  1135. (short)((REG32 *)&dwSrcCoord)->pt.X -= (short)((REG32 *)&dwDstCoord)->pt.X;
  1136. if ((DD_TRANS | DD_TRANSOP) & dwDrawBlt)
  1137. // bump key.X to right
  1138. (short)((REG32 *)&dwKeyCoord)->pt.X -= (short)((REG32 *)&dwKeyCoord)->pt.X;
  1139. // clear dst.X
  1140. ((REG32 *)&dwDstCoord)->pt.X = 0;
  1141. }
  1142. if (0 > (short)((REG32 *)&dwDstCoord)->pt.Y)
  1143. {
  1144. // reduce extent.Y
  1145. (short)((REG32 *)&dwExtents)->pt.Y += (short)((REG32 *)&dwDstCoord)->pt.Y;
  1146. // bump src.Y down
  1147. (short)((REG32 *)&dwSrcCoord)->pt.Y -= (short)((REG32 *)&dwDstCoord)->pt.Y;
  1148. if ((DD_TRANS | DD_TRANSOP) & dwDrawBlt)
  1149. // bump key.Y down
  1150. (short)((REG32 *)&dwKeyCoord)->pt.Y -= (short)((REG32 *)&dwKeyCoord)->pt.Y;
  1151. // clear dst.Y
  1152. ((REG32 *)&dwDstCoord)->pt.Y = 0;
  1153. }
  1154. // Check for x overlap
  1155. if ( abs(xDelta) < (int)LOWORD(dwExtents) )
  1156. {
  1157. const int yDelta = (int)HIWORD(dwDstCoord) - (int)HIWORD(dwSrcCoord);
  1158. if ( (yDelta > 0) && (yDelta < (int)HIWORD(dwExtents)) )
  1159. {
  1160. const DWORD dwDelta = (dwExtents & MAKELONG(0, -1)) - MAKELONG(0, 1);
  1161. // Convert to a bottom-up blt.
  1162. dwDrawBlt |= MAKELONG(0, BD_YDIR);
  1163. dwDstCoord += dwDelta;
  1164. dwSrcCoord += dwDelta;
  1165. dwKeyCoord += dwDelta;
  1166. }
  1167. // are we sliding to the right?
  1168. else if ( (xDelta > 0) && (yDelta == 0) )
  1169. {
  1170. const DWORD dwDelta = MAKELONG(xDelta, 0);
  1171. // Blt the overlapped piece first
  1172. DIR_HWClippedDrvSrcBlt(
  1173. #ifdef WINNT_VER40
  1174. ppdev,
  1175. #endif
  1176. lpDDHALData,
  1177. dwDrawBlt,
  1178. dwDstCoord+dwDelta,
  1179. dwSrcCoord+dwDelta,
  1180. dwKeyCoord+dwDelta,
  1181. dwKeyColor,
  1182. dwExtents-dwDelta,
  1183. dwDstBaseXY,
  1184. dwSrcBaseXY,
  1185. dwRectCnt,
  1186. pDestRects);
  1187. // Subtract the overlap from the original extents.
  1188. dwExtents = MAKELONG(xDelta, HIWORD(dwExtents));
  1189. }
  1190. }
  1191. // setup blt, write BLTEXT reg with extent which doesn't fire off blt
  1192. REQUIER(12);
  1193. LL_DRAWBLTDEF(dwDrawBlt, 0);
  1194. LL_BGCOLOR(dwKeyColor, 0);
  1195. LL32(grOP0_opRDRAM.DW, dwDstCoord);
  1196. LL32(grOP1_opRDRAM.DW, dwSrcCoord);
  1197. LL32(grOP2_opRDRAM.DW, dwKeyCoord);
  1198. LL32(grBLTEXT.DW, dwExtents);
  1199. // loop over clip list
  1200. do
  1201. {
  1202. REG32 UpperLeft;
  1203. REG32 LowerRight;
  1204. // compute cliprect coords
  1205. UpperLeft.DW = dwDstBaseXY + MAKELONG(pDestRects->left, pDestRects->top);
  1206. LowerRight.DW = dwDstBaseXY + MAKELONG(pDestRects->right, pDestRects->bottom);
  1207. // write clipping regs
  1208. REQUIRE(5);
  1209. LL32(grCLIPULE.DW, UpperLeft.DW);
  1210. LL32(grCLIPLOR_EX.DW, LowerRight.DW);
  1211. pDestRects++;
  1212. } while (0 < --dwRectCnt);
  1213. } /* DIR_HWClippedDrvSrcBlt */
  1214. /***************************************************************************
  1215. *
  1216. * FUNCTION: DIR_SWClippedDrvDstBlt
  1217. *
  1218. * DESCRIPTION:
  1219. *
  1220. ****************************************************************************/
  1221. void DIR_SWClippedDrvDstBlt
  1222. (
  1223. #ifdef WINNT_VER40
  1224. PDEV *ppdev,
  1225. DRIVERDATA *lpDDHALData,
  1226. #else
  1227. LPGLOBALDATA lpDDHALData,
  1228. #endif
  1229. DWORD dwDrawBlt,
  1230. DWORD dwDstCoord,
  1231. DWORD dwBgColor,
  1232. DWORD dwExtents,
  1233. DWORD dwDstBaseXY,
  1234. DWORD dwRectCnt,
  1235. LPRECT pDestRects
  1236. )
  1237. {
  1238. PVGAR pREG = (PVGAR) lpDDHALData->RegsAddress;
  1239. DD_LOG(("DIR_SWClippedDrvDstBlt - dst=%08lX ext=%08lX color=%08lX\r\n",
  1240. dwDstCoord,dwExtents,dwBgColor));
  1241. // make sure DD_CLIP isn't set in drawdef
  1242. dwDrawBlt &= ~DD_CLIP;
  1243. // write regs that don't vary over rectangles
  1244. REQUIRE(4);
  1245. LL_DRAWBLTDEF(dwDrawBlt, 0);
  1246. LL_BGCOLOR(dwBgColor, 0);
  1247. // loop over clip list
  1248. do
  1249. {
  1250. DDRECTL DstDDRect;
  1251. // compute cliprect coords
  1252. DstDDRect.loc.DW = dwDstBaseXY + MAKELONG(pDestRects->left, pDestRects->top);
  1253. DstDDRect.ext.pt.X = (WORD)(pDestRects->right - pDestRects->left);
  1254. DstDDRect.ext.pt.Y = (WORD)(pDestRects->bottom - pDestRects->top);
  1255. // write OP0 and bltext regs
  1256. REQUIRE(5);
  1257. LL32(grOP0_opRDRAM.DW, DstDDRect.loc.DW);
  1258. LL32(grBLTEXT_EX.DW, DstDDRect.ext.DW);
  1259. pDestRects++;
  1260. } while (0 < --dwRectCnt);
  1261. } /* DIR_SWClippedDrvDstBlt */
  1262. /***************************************************************************
  1263. *
  1264. * FUNCTION: DIR_SWClippedDrvDstMBlt
  1265. *
  1266. * DESCRIPTION:
  1267. *
  1268. ****************************************************************************/
  1269. void DIR_SWClippedDrvDstMBlt
  1270. (
  1271. #ifdef WINNT_VER40
  1272. PDEV *ppdev,
  1273. DRIVERDATA *lpDDHALData,
  1274. #else
  1275. LPGLOBLADATA lpDDHALData,
  1276. #endif
  1277. DWORD dwDrawBlt,
  1278. DWORD dwDstCoord,
  1279. DWORD dwBgColor,
  1280. DWORD dwExtents,
  1281. DWORD dwDstBaseXY,
  1282. DWORD dwRectCnt,
  1283. LPRECT pDestRects
  1284. )
  1285. {
  1286. const int nBytesPixel = BYTESPERPIXEL;
  1287. PVGAR pREG = (PVGAR) lpDDHALData->RegsAddress;
  1288. DD_LOG(("DIR_SWClippedDrvDstMBlt - dst=%08lX ext=%08lX color=%08lX\r\n",
  1289. dwDstCoord,dwExtents,dwBgColor));
  1290. // make sure DD_CLIP isn't set in drawdef
  1291. dwDrawBlt &= ~DD_CLIP;
  1292. // write regs that don't vary over rectangles
  1293. REQUIRE(4);
  1294. LL_DRAWBLTDEF(dwDrawBlt, 0);
  1295. LL_BGCOLOR(dwBgColor, 0);
  1296. // loop over clip list
  1297. do
  1298. {
  1299. DDRECTL DstDDRect;
  1300. // compute cliprect coords
  1301. DstDDRect.loc.DW = dwDstBaseXY + MAKELONG(pDestRects->left, pDestRects->top);
  1302. DstDDRect.loc.pt.X *= nBytesPixel;
  1303. DstDDRect.ext.pt.X = (WORD)(pDestRects->right - pDestRects->left) * nBytesPixel;
  1304. DstDDRect.ext.pt.Y = (WORD)(pDestRects->bottom - pDestRects->top);
  1305. // write OP0 and bltext regs
  1306. REQUIRE(5);
  1307. LL32(grOP0_opMRDRAM.DW, DstDDRect.loc.DW);
  1308. LL32(grMBLTEXT_EX.DW, DstDDRect.ext.DW);
  1309. pDestRects++;
  1310. } while (0 < --dwRectCnt);
  1311. } /* DIR_SWClippedDrvDstMBlt */
  1312. /***************************************************************************
  1313. *
  1314. * FUNCTION: DIR_SWClippedDrvSrcBlt
  1315. *
  1316. * DESCRIPTION:
  1317. *
  1318. ****************************************************************************/
  1319. void DIR_SWClippedDrvSrcBlt
  1320. (
  1321. #ifdef WINNT_VER40
  1322. PDEV *ppdev,
  1323. DRIVERDATA *lpDDHALData,
  1324. #else
  1325. LPGLOBALDATA lpDDHALData,
  1326. #endif
  1327. DWORD dwDrawBlt,
  1328. DWORD dwDstCoord,
  1329. DWORD dwSrcCoord,
  1330. DWORD dwKeyCoord,
  1331. DWORD dwKeyColor,
  1332. DWORD dwExtents,
  1333. DWORD dwDstBaseXY,
  1334. DWORD dwSrcBaseXY,
  1335. DWORD dwRectCnt,
  1336. LPRECT pDestRects
  1337. )
  1338. {
  1339. PVGAR pREG = (PVGAR) lpDDHALData->RegsAddress;
  1340. // Handle overlapped regions
  1341. const int xDelta = (int)LOWORD(dwDstCoord) - (int)LOWORD(dwSrcCoord);
  1342. DD_LOG(("DIR_SWClippedDrvSrcBlt - dst=%08lX src=%08lX ext=%08lX color=%08lX\r\n",
  1343. dwDstCoord,dwSrcCoord,dwExtents,dwKeyColor));
  1344. // make sure DD_CLIP isn't set in drawdef
  1345. dwDrawBlt &= ~DD_CLIP;
  1346. // Check for x overlap
  1347. if ( abs(xDelta) < (int)LOWORD(dwExtents) )
  1348. {
  1349. const int yDelta = (int)HIWORD(dwDstCoord) - (int)HIWORD(dwSrcCoord);
  1350. if ( (yDelta > 0) && (yDelta < (int)HIWORD(dwExtents)) )
  1351. {
  1352. const DWORD dwDelta = (dwExtents & MAKELONG(0, -1)) - MAKELONG(0, 1);
  1353. // Convert to a bottom-up blt.
  1354. dwDrawBlt |= MAKELONG(0, BD_YDIR);
  1355. dwDstCoord += dwDelta;
  1356. dwSrcCoord += dwDelta;
  1357. dwKeyCoord += dwDelta;
  1358. }
  1359. // are we sliding to the right?
  1360. else if ( (xDelta > 0) && (yDelta == 0) )
  1361. {
  1362. const DWORD dwDelta = MAKELONG(xDelta, 0);
  1363. // Blt the overlapped piece first
  1364. DIR_SWClippedDrvSrcBlt(
  1365. #ifdef WINNT_VER40
  1366. ppdev,
  1367. #endif
  1368. lpDDHALData,
  1369. dwDrawBlt,
  1370. dwDstCoord+dwDelta,
  1371. dwSrcCoord+dwDelta,
  1372. dwKeyCoord+dwDelta,
  1373. dwKeyColor,
  1374. dwExtents-dwDelta,
  1375. dwDstBaseXY,
  1376. dwSrcBaseXY,
  1377. dwRectCnt,
  1378. pDestRects);
  1379. // Subtract the overlap from the original extents.
  1380. dwExtents = MAKELONG(xDelta, HIWORD(dwExtents));
  1381. }
  1382. }
  1383. // write regs that don't vary over rectangles
  1384. REQUIRE(4);
  1385. LL_DRAWBLTDEF(dwDrawBlt, 0);
  1386. LL_BGCOLOR(dwKeyColor, 0);
  1387. // loop over clip list
  1388. do
  1389. {
  1390. DDRECTL DstDDRect;
  1391. DDRECTL SrcDDRect;
  1392. // compute dst cliprect coords
  1393. DstDDRect.loc.DW = dwDstBaseXY + MAKELONG(pDestRects->left, pDestRects->top);
  1394. DstDDRect.ext.pt.X = (WORD)(pDestRects->right - pDestRects->left);
  1395. DstDDRect.ext.pt.Y = (WORD)(pDestRects->bottom - pDestRects->top);
  1396. // compute src cliprect coords
  1397. SrcDDRect.loc.DW = dwSrcBaseXY + MAKELONG(pDestRects->left, pDestRects->top);
  1398. // don't care about src extent, it's the same as dst extent
  1399. //SrcDDRect.ext.pt.X = (WORD)(pDestRects->right - pDestRects->left);
  1400. //SrcDDRect.ext.pt.Y = (WORD)(pDestRects->bottom - pDestRects->top);
  1401. // write OP0, OP1, OP2 and bltext regs
  1402. if ((DD_TRANS | DD_TRANSOP) == ((DD_TRANS | DD_TRANSOP) & dwDrawBlt))
  1403. {
  1404. // dst color key
  1405. REQUIRE(9);
  1406. LL32(grOP2_opRDRAM.DW, DstDDRect.loc.DW);
  1407. }
  1408. else if (DD_TRANS == ((DD_TRANS | DD_TRANSOP) & dwDrawBlt))
  1409. {
  1410. // src color key
  1411. REQUIRE(9);
  1412. LL32(grOP2_opRDRAM.DW, SrcDDRect.loc.DW);
  1413. }
  1414. else
  1415. {
  1416. REQUIRE(7);
  1417. //LL32(grOP2_opRDRAM.DW, 0);
  1418. }
  1419. LL32(grOP0_opRDRAM.DW, DstDDRect.loc.DW);
  1420. LL32(grOP1_opRDRAM.DW, SrcDDRect.loc.DW);
  1421. LL32(grBLTEXT_EX.DW, DstDDRect.ext.DW);
  1422. pDestRects++;
  1423. } while (0 < --dwRectCnt);
  1424. } /* DIR_SWClippedDrvSrcBlt */
  1425. #endif // ENABLE_CLIPPEDBLTS
  1426. #endif // WINNT_VER35