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.

1288 lines
43 KiB

  1. /*/****************************************************************************
  2. * name: mtxcurs.c
  3. *
  4. * description: routines that manage hardware cursor (in RAMDAC)
  5. *
  6. * designed: Christian Toutant
  7. * last modified: $Author: bleblanc $, $Date: 94/11/09 10:50:57 $
  8. *
  9. * version: $Id: MTXCURS.C 1.23 94/11/09 10:50:57 bleblanc Exp $
  10. *
  11. * parameters: -
  12. * modifies: -
  13. * calls: -
  14. * returns: -
  15. ******************************************************************************/
  16. #ifdef OS2 /* nPhung Tue 23-Aug-1994 10:41:33 */
  17. #include <stdlib.h>
  18. #include <string.h>
  19. #include <stdio.h>
  20. #include <dos.h>
  21. #include <time.h>
  22. #endif
  23. #include "switches.h"
  24. #include "mga.h"
  25. #include "bind.h"
  26. #include "defbind.h"
  27. #ifndef __DDK_SRC__
  28. #include "sxci.h"
  29. #endif
  30. #include "mgai_c.h"
  31. #include "mgai.h"
  32. /* Prototypes */
  33. static void wrDacReg(word reg, int dat);
  34. static void rdDacReg(word reg, byte *dat);
  35. static bool toBitPlane(PixMap *pPixMap);
  36. static bool charge482(PixMap *pPixMap);
  37. static bool charge485(PixMap *pPixMap);
  38. bool chargeVIEWPOINT(PixMap *pPixMap);
  39. static bool chargeTVP3026(PixMap *pPixMap);
  40. static bool shiftCursorTVP3026(word o);
  41. bool mtxCursorSetShape(PixMap *pPixMap);
  42. void mtxCursorSetColors(mtxRGB color00, mtxRGB color01, mtxRGB color10, mtxRGB color11);
  43. void mtxCursorEnable(word mode);
  44. void mtxCursorSetHotSpot(word Dx, word Dy);
  45. void mtxCursorMove(word X, word Y);
  46. CursorInfo * mtxCursorGetInfo();
  47. #ifdef WINDOWS_NT
  48. #if defined(ALLOC_PRAGMA)
  49. // #pragma alloc_text(PAGE,wrDacReg)
  50. // #pragma alloc_text(PAGE,rdDacReg)
  51. #pragma alloc_text(PAGE,toBitPlane)
  52. #pragma alloc_text(PAGE,charge482)
  53. #pragma alloc_text(PAGE,charge485)
  54. #pragma alloc_text(PAGE,chargeVIEWPOINT)
  55. #pragma alloc_text(PAGE,chargeTVP3026)
  56. #pragma alloc_text(PAGE,shiftCursorTVP3026)
  57. #pragma alloc_text(PAGE,mtxCursorSetShape)
  58. #pragma alloc_text(PAGE,mtxCursorSetColors)
  59. // #pragma alloc_text(PAGE,mtxCursorEnable)
  60. #pragma alloc_text(PAGE,mtxCursorSetHotSpot)
  61. #pragma alloc_text(PAGE,mtxCursorMove)
  62. #pragma alloc_text(PAGE,mtxCursorGetInfo)
  63. #endif
  64. PVOID AllocateSystemMemory(ULONG NumberOfBytes);
  65. #endif /* #ifdef WINDOWS_NT */
  66. /*------- extern global variables */
  67. extern volatile byte _Far* pMgaBaseAddr;
  68. extern HwData Hw[];
  69. extern byte iBoard;
  70. /*--------------- Static internal variables */
  71. static byte planData[1024] = {0}; /* Maximum cursor 64 X 64 X 2 */
  72. /* The cursor in TVP3026 rev x can not go out of visible display */
  73. static byte* planTVP[NB_BOARD_MAX] = {planData,0,0,0,0,0,0};
  74. static byte revTVP[NB_BOARD_MAX] = {0xff,0xff,0xff,0xff,0xff,0xff,0xff};
  75. static word currentTVPDelta[NB_BOARD_MAX] = {0};
  76. /******** Local Definition ****************/
  77. static void wrDacReg(word reg, int dat)
  78. {
  79. mgaWriteBYTE(*(pMgaBaseAddr + RAMDAC_OFFSET + (reg)), (byte)dat);
  80. }
  81. static void rdDacReg(word reg, byte *dat)
  82. {
  83. mgaReadBYTE(*(pMgaBaseAddr + RAMDAC_OFFSET + (reg)), *dat);
  84. }
  85. /*--------------------------------------------------------------------------*/
  86. static bool toBitPlane(PixMap *pPixMap)
  87. {
  88. word plan1 = (pPixMap->Width == 32) ? 128 : 512;
  89. word i, pos, pixels;
  90. switch(pPixMap->Format)
  91. {
  92. case 0x0102 :
  93. for(i = 0; i < plan1; i++)
  94. {
  95. pixels = ((word *)pPixMap->Data)[i];
  96. planData[i] = pixels & 0x01;
  97. pixels >>= 1;
  98. planData[plan1 + i] = pixels & 0x01;
  99. pixels >>= 1;
  100. for (pos = 1; pos < 8; pos++)
  101. {
  102. planData[i] <<= 1;
  103. planData[plan1 + i] <<= 1;
  104. planData[i] |= pixels & 0x01;
  105. pixels >>= 1;
  106. planData[plan1 + i] |= pixels & 0x01;
  107. pixels >>= 1;
  108. }
  109. }
  110. default:
  111. return mtxFAIL;
  112. }
  113. }
  114. /*----------------------------------------------------
  115. Non documented : If we have a NULL Data buffer,
  116. The initialisation will be done without
  117. modifying the CURSOR RAM DATA.
  118. pPixMap->Height == 0 -> cursor disable
  119. pPixMap->Height != 0 -> cursor enable
  120. -----------------------------------------------------*/
  121. static bool charge482(PixMap *pPixMap)
  122. {
  123. byte reg_cur;
  124. int i;
  125. if (!pPixMap->Data) return mtxOK;
  126. /*--- Prepare access to RAM of cursor */
  127. toBitPlane(pPixMap);
  128. /*-- Permits the access to Extented register */
  129. wrDacReg(BT482_WADR_PAL, BT482_CUR_REG); /* points on Cursor register */
  130. /* Select Cursor RAM */
  131. rdDacReg(BT482_PIX_RD_MSK, &reg_cur);
  132. wrDacReg(BT482_PIX_RD_MSK, reg_cur | BT482_CUR_CR3_RAM);
  133. wrDacReg(BT482_WADR_PAL, 0); /* address RAM cursor to 0 */
  134. /* ----------- Transfer */
  135. for(i = 0; i < 0x100; i++)
  136. wrDacReg(BT482_COL_OVL, planData[i]);
  137. /*------------ */
  138. /* Reset original value in the registers */
  139. wrDacReg(BT482_WADR_PAL, BT482_CUR_REG);/* points to Cursor register */
  140. /* replace original in cursor reg. */
  141. /* reg_cur &= ~(BT482_CUR_CR3_RAM | BT482_CUR_EN_M);*/
  142. wrDacReg(BT482_PIX_RD_MSK, reg_cur); /* restore Cursor register */
  143. return mtxOK;
  144. }
  145. /*----------------------------------------------------
  146. Non documente : Si nous avons un buffer Data Null,
  147. L'initialisation se fera sans modifier
  148. le CURSOR RAM DATA.
  149. pPixMap->Height == 0 -> cursor disable
  150. pPixMap->Height != 0 -> cursor enable
  151. -----------------------------------------------------*/
  152. static bool charge485(PixMap *pPixMap)
  153. {
  154. byte reg_0, reg_3, tmpByte, reg_cur;
  155. bool valeurRetour = mtxOK;
  156. int i;
  157. /* Hide CURSOR */
  158. rdDacReg(BT485_CMD_REG2, &reg_cur);
  159. reg_0 = reg_cur & ~BT485_CUR_MODE_M;
  160. wrDacReg(BT485_CMD_REG2, reg_0 | BT485_CUR_MODE_DIS);
  161. i = ((pPixMap->Width == 32) ? 128 : 512) << 1;
  162. if (pPixMap->Data) toBitPlane(pPixMap);
  163. /* Permits the access to command register 3 */
  164. rdDacReg(BT485_CMD_REG0, &reg_0);
  165. wrDacReg(BT485_CMD_REG0, reg_0 | BT485_IND_REG3_M);
  166. /* read command register 3 */
  167. wrDacReg(BT485_WADR_PAL, 1); /* address RAM cursor to 1 */
  168. rdDacReg(BT485_CMD_REG3, &reg_3);
  169. switch(pPixMap->Width)
  170. {
  171. case 32:
  172. reg_3 &= ~(BT485_CUR_SEL_M | BT485_CUR_MSB_M); /* 32x32 cursor */
  173. /* write to command register 3 */
  174. wrDacReg(BT485_WADR_PAL, 1); /* address RAM cursor to 1 */
  175. wrDacReg(BT485_CMD_REG3, reg_3);
  176. if (!pPixMap->Data) break; /* If Data empty, no Load */
  177. do
  178. {
  179. wrDacReg(BT485_WADR_PAL, 0); /* address RAM cursor to 0 */
  180. for(i = 0; i < 0x100; i++)
  181. wrDacReg(BT485_CUR_RAM, planData[i]);
  182. rdDacReg(BT485_WADR_PAL, &tmpByte);
  183. } while ( tmpByte != 0 ) ;
  184. break;
  185. case 64:
  186. reg_3 |= BT485_CUR_SEL_M; /* 64x64 cursor */
  187. reg_3 &= ~BT485_CUR_MSB_M; /* Adr 10:9 Cur Ram = 0. */
  188. if (!pPixMap->Data) /* If Data empty, no Load */
  189. {
  190. wrDacReg(BT485_CMD_REG3, reg_3);
  191. break;
  192. }
  193. /* Transfer 1st 256 bytes */
  194. if (!pPixMap->Data) /* If Data empty, no Load */
  195. {
  196. wrDacReg(BT485_CMD_REG3, reg_3);
  197. break;
  198. }
  199. /*--- Write to command register 3 */
  200. wrDacReg(BT485_WADR_PAL, 1); /* address RAM cursor to 1 */
  201. wrDacReg(BT485_CMD_REG3, reg_3); /* MSB Adr 10:9 Cur Ram = 0. */
  202. do
  203. {
  204. wrDacReg(BT485_WADR_PAL, 0);/* address RAM cursor to 0 */
  205. for(i = 0; i < 0x100; i++)
  206. wrDacReg(BT485_CUR_RAM, planData[i]);
  207. rdDacReg(BT485_WADR_PAL, &tmpByte);
  208. } while ( tmpByte != 0 ) ;
  209. /* Transfer 2nd 256 bytes */
  210. /* MSB Adr 10:9 Cur Ram = 1. */
  211. /*--- Write to command register 3 */
  212. wrDacReg(BT485_WADR_PAL, 1); /* address RAM cursor to 1 */
  213. wrDacReg(BT485_CMD_REG3, reg_3 | BT485_CUR_MSB_01);
  214. do
  215. {
  216. wrDacReg(BT485_WADR_PAL, 0); /* address RAM cursor to 0 */
  217. for(i = 0; i < 0x100; i++)
  218. wrDacReg(BT485_CUR_RAM, planData[0x100 + i]);
  219. rdDacReg(BT485_WADR_PAL, &tmpByte);
  220. } while ( tmpByte != 0 ) ;
  221. /* Transfer 3rd 256 bytes START second PLAN */
  222. /* MSB Adr 10:9 Cur Ram = 2. */
  223. /*--- Write to command register 3 */
  224. wrDacReg(BT485_WADR_PAL, 1); /* address RAM cursor to 1 */
  225. wrDacReg(BT485_CMD_REG3, reg_3 | BT485_CUR_MSB_10);
  226. do
  227. {
  228. wrDacReg(BT485_WADR_PAL, 0); /* address RAM cursor to 0 */
  229. for(i = 0; i < 0x100; i++)
  230. wrDacReg(BT485_CUR_RAM, planData[0x200 + i]);
  231. rdDacReg(BT485_WADR_PAL, &tmpByte);
  232. } while ( tmpByte != 0 ) ;
  233. /* Transfer 4th 256 bytes */
  234. /* MSB Adr 10:9 Cur Ram = 3. */
  235. /*--- Write to command register 3 */
  236. wrDacReg(BT485_WADR_PAL, 1); /* address RAM cursor to 1 */
  237. wrDacReg(BT485_CMD_REG3, reg_3 | BT485_CUR_MSB_11);
  238. do
  239. {
  240. wrDacReg(BT485_WADR_PAL, 0); /* address RAM cursor to 0 */
  241. for(i = 0; i < 0x100; i++)
  242. wrDacReg(BT485_CUR_RAM, planData[0x300 + i]);
  243. rdDacReg(BT485_WADR_PAL, &tmpByte);
  244. } while ( tmpByte != 0 ) ;
  245. /* access register 3 */
  246. wrDacReg(BT485_WADR_PAL, 1); /* address RAM cursor to 1 */
  247. wrDacReg(BT485_CMD_REG3, reg_3); /* MSB's adr = 00 */
  248. break;
  249. default:
  250. valeurRetour = mtxFAIL;
  251. break;
  252. }
  253. wrDacReg(BT485_CMD_REG0, reg_0); /* Restore command register 3 */
  254. /* Restore CURSOR MODE */
  255. wrDacReg(BT485_CMD_REG2, reg_cur);
  256. return valeurRetour;
  257. }
  258. /*----------------------------------------------------
  259. Non documented : If we have a NULL Data buffer,
  260. The initialisation will be done without
  261. modifying the CURSOR RAM DATA.
  262. pPixMap->Height == 0 -> cursor disable
  263. pPixMap->Height != 0 -> cursor enable
  264. -----------------------------------------------------*/
  265. bool chargeVIEWPOINT(PixMap *pPixMap)
  266. {
  267. word i, j, pixels, pitch;
  268. byte cur_ctl;
  269. if (pPixMap->Data)
  270. {
  271. if ((pPixMap->Height > 64) || (pPixMap->Width > 64))
  272. return mtxFAIL;
  273. wrDacReg(VPOINT_INDEX, VPOINT_CUR_CTL);
  274. rdDacReg(VPOINT_DATA, &cur_ctl);
  275. wrDacReg(VPOINT_DATA, 0x10);
  276. pitch = pPixMap->Width >> 2;
  277. /* Cursor ram adress to 0 */
  278. wrDacReg(VPOINT_INDEX, VPOINT_CUR_RAM_LSB);
  279. wrDacReg(VPOINT_DATA, 0);
  280. wrDacReg(VPOINT_INDEX, VPOINT_CUR_RAM_MSB);
  281. wrDacReg(VPOINT_DATA, 0);
  282. wrDacReg(VPOINT_INDEX, VPOINT_CUR_RAM_DATA);
  283. for (i = 0; i < pPixMap->Height; i++)
  284. {
  285. for (j = 0; j < pitch; j++)
  286. {
  287. pixels = ((byte *)pPixMap->Data)[i * pitch + j];
  288. wrDacReg(VPOINT_DATA, (pixels << 6) |
  289. ((pixels << 2) & 0x30) |
  290. ((pixels >> 2) & 0x0c) |
  291. ((pixels >> 6) & 0x3)
  292. );
  293. }
  294. for (; j < 16; j++)
  295. {
  296. wrDacReg(VPOINT_DATA, 0);
  297. }
  298. }
  299. for (; i < 64; i++)
  300. for (j = 0; j < 16; j++)
  301. {
  302. wrDacReg(VPOINT_DATA, 0);
  303. }
  304. /* Hot Spot Max */
  305. wrDacReg(VPOINT_INDEX, VPOINT_SPRITE_X);
  306. wrDacReg(VPOINT_DATA, pPixMap->Width - 1);
  307. wrDacReg(VPOINT_INDEX, VPOINT_SPRITE_Y);
  308. wrDacReg(VPOINT_DATA, pPixMap->Height - 1);
  309. wrDacReg(VPOINT_INDEX, VPOINT_CUR_CTL);
  310. wrDacReg(VPOINT_DATA, cur_ctl);
  311. }
  312. /* Restore Cursor control */
  313. return mtxFAIL;
  314. }
  315. /*----------------------------------------------------
  316. Non documented : If we have a NULL Data buffer,
  317. The initialisation will be done without
  318. modifying the CURSOR RAM DATA.
  319. pPixMap->Height == 0 -> cursor disable
  320. pPixMap->Height != 0 -> cursor enable
  321. -----------------------------------------------------*/
  322. static bool chargeTVP3026(PixMap *pPixMap)
  323. {
  324. byte reg1, curCtl, curPos[4];
  325. bool valeurRetour = mtxOK;
  326. int i;
  327. if (pPixMap->Data)
  328. toBitPlane(pPixMap);
  329. if (!pPixMap->Data) /* If Data Empty, no Load */
  330. return(mtxFAIL);
  331. /* Hide cursor */
  332. rdDacReg(TVP3026_CUR_XLOW, &curPos[0]);
  333. rdDacReg(TVP3026_CUR_XHI , &curPos[1]);
  334. rdDacReg(TVP3026_CUR_YLOW, &curPos[2]);
  335. rdDacReg(TVP3026_CUR_YHI , &curPos[3]);
  336. wrDacReg(TVP3026_CUR_XLOW, 0x00 );
  337. wrDacReg(TVP3026_CUR_XHI , 0x00 );
  338. wrDacReg(TVP3026_CUR_YLOW, 0x00 );
  339. wrDacReg(TVP3026_CUR_YHI , 0x00 );
  340. /* update TVP Revision */
  341. wrDacReg(TVP3026_INDEX, TVP3026_SILICON_REV);
  342. rdDacReg(TVP3026_DATA, &revTVP[iBoard]);
  343. switch(pPixMap->Width)
  344. {
  345. case 32:
  346. /* Transfer 1st 256 bytes */
  347. wrDacReg(TVP3026_INDEX, TVP3026_CURSOR_CTL);
  348. rdDacReg(TVP3026_DATA, &curCtl);
  349. reg1 = curCtl & 0xf0; /* CCR[3:2] = 00 */
  350. wrDacReg(TVP3026_INDEX, TVP3026_CURSOR_CTL);
  351. wrDacReg(TVP3026_DATA, reg1);
  352. wrDacReg(TVP3026_WADR_PAL, 0); /* address RAM cursor to 0 */
  353. for(i = 0; i < 128; i+=4)
  354. {
  355. wrDacReg(TVP3026_CUR_RAM, planData[i]);
  356. wrDacReg(TVP3026_CUR_RAM, planData[i+1]);
  357. wrDacReg(TVP3026_CUR_RAM, planData[i+2]);
  358. wrDacReg(TVP3026_CUR_RAM, planData[i+3]);
  359. wrDacReg(TVP3026_CUR_RAM, 0);
  360. wrDacReg(TVP3026_CUR_RAM, 0);
  361. wrDacReg(TVP3026_CUR_RAM, 0);
  362. wrDacReg(TVP3026_CUR_RAM, 0);
  363. }
  364. /* Transfer 2nd 256 bytes */
  365. reg1 = reg1 | 0x04; /* CCR[3:2] = 01 */
  366. wrDacReg(TVP3026_INDEX, TVP3026_CURSOR_CTL);
  367. wrDacReg(TVP3026_DATA, reg1);
  368. wrDacReg(TVP3026_WADR_PAL, 0); /* address RAM cursor to 0 */
  369. for(i=0; i<256; i++)
  370. wrDacReg(TVP3026_CUR_RAM, 0);
  371. /* Transfer 3rd 256 bytes (Start of second PLAN) */
  372. reg1 = reg1 & 0xf0;
  373. reg1 = reg1 | 0x08; /* CCR[3:2] = 10 */
  374. wrDacReg(TVP3026_INDEX, TVP3026_CURSOR_CTL);
  375. wrDacReg(TVP3026_DATA, reg1);
  376. wrDacReg(TVP3026_WADR_PAL, 0); /* address RAM cursor to 0 */
  377. for(i = 128; i < 256; i+=4)
  378. {
  379. wrDacReg(TVP3026_CUR_RAM, planData[i]);
  380. wrDacReg(TVP3026_CUR_RAM, planData[i+1]);
  381. wrDacReg(TVP3026_CUR_RAM, planData[i+2]);
  382. wrDacReg(TVP3026_CUR_RAM, planData[i+3]);
  383. wrDacReg(TVP3026_CUR_RAM, 0);
  384. wrDacReg(TVP3026_CUR_RAM, 0);
  385. wrDacReg(TVP3026_CUR_RAM, 0);
  386. wrDacReg(TVP3026_CUR_RAM, 0);
  387. }
  388. /* Transfer 4th 256 bytes */
  389. reg1 = reg1 | 0x0c; /* CCR[3:2] = 11 */
  390. wrDacReg(TVP3026_INDEX, TVP3026_CURSOR_CTL);
  391. wrDacReg(TVP3026_DATA, reg1);
  392. wrDacReg(TVP3026_WADR_PAL, 0); /* address RAM cursor to 0 */
  393. for(i=0; i<256; i++)
  394. wrDacReg(TVP3026_CUR_RAM, 0);
  395. break;
  396. case 64:
  397. /* Transfer 1st 256 bytes */
  398. wrDacReg(TVP3026_INDEX, TVP3026_CURSOR_CTL);
  399. rdDacReg(TVP3026_DATA, &curCtl);
  400. reg1 = curCtl & 0xf0; /* CCR[3:2] = 00 */
  401. wrDacReg(TVP3026_INDEX, TVP3026_CURSOR_CTL);
  402. wrDacReg(TVP3026_DATA, reg1);
  403. wrDacReg(TVP3026_WADR_PAL, 0); /* address RAM cursor to 0 */
  404. for(i = 0; i < 0x100; i++)
  405. wrDacReg(TVP3026_CUR_RAM, planData[i]);
  406. /* Transfer 2nd 256 bytes */
  407. reg1 = reg1 | 0x04; /* CCR[3:2] = 01 */
  408. wrDacReg(TVP3026_INDEX, TVP3026_CURSOR_CTL);
  409. wrDacReg(TVP3026_DATA, reg1);
  410. wrDacReg(TVP3026_WADR_PAL, 0); /* address RAM cursor to 0 */
  411. for(i = 0; i < 0x100; i++)
  412. wrDacReg(TVP3026_CUR_RAM, planData[0x100+i]);
  413. /* Transfer 3rd 256 bytes (Start of second PLAN) */
  414. reg1 = reg1 & 0xf0;
  415. reg1 = reg1 | 0x08; /* CCR[3:2] = 10 */
  416. wrDacReg(TVP3026_INDEX, TVP3026_CURSOR_CTL);
  417. wrDacReg(TVP3026_DATA, reg1);
  418. wrDacReg(TVP3026_WADR_PAL, 0); /* address RAM cursor to 0 */
  419. for(i = 0; i < 0x100; i++)
  420. wrDacReg(TVP3026_CUR_RAM, planData[0x200+i]);
  421. /* Transfer 4th 256 bytes */
  422. reg1 = reg1 | 0x0c; /* CCR[3:2] = 11 */
  423. wrDacReg(TVP3026_INDEX, TVP3026_CURSOR_CTL);
  424. wrDacReg(TVP3026_DATA, reg1);
  425. wrDacReg(TVP3026_WADR_PAL, 0); /* address RAM cursor to 0 */
  426. for(i = 0; i < 0x100; i++)
  427. wrDacReg(TVP3026_CUR_RAM, planData[0x300+i]);
  428. break;
  429. }
  430. /* Fix bug TVP3026 rev x */
  431. if (currentTVPDelta[iBoard])
  432. shiftCursorTVP3026(currentTVPDelta[iBoard]);
  433. /* Display cursor */
  434. wrDacReg(TVP3026_INDEX, TVP3026_CURSOR_CTL);
  435. wrDacReg(TVP3026_DATA, curCtl);
  436. wrDacReg(TVP3026_CUR_XLOW, curPos[0]);
  437. wrDacReg(TVP3026_CUR_XHI , curPos[1]);
  438. wrDacReg(TVP3026_CUR_YLOW, curPos[2]);
  439. wrDacReg(TVP3026_CUR_YHI , curPos[3]);
  440. if (iBoard)
  441. {
  442. if (!planTVP[iBoard])
  443. {
  444. #ifndef WINDOWS_NT
  445. if ( (planTVP[iBoard] = (byte *)malloc( 1024 )) == (byte *)0)
  446. #else
  447. if ( (planTVP[iBoard] = (PUCHAR)AllocateSystemMemory(1024)) == NULL)
  448. #endif
  449. return mtxFAIL;
  450. }
  451. for (i = 0; i < 1024; i++)
  452. (planTVP[iBoard])[i] = planData[i];
  453. }
  454. return valeurRetour;
  455. }
  456. /***************************************************************************
  457. Function : shiftCursorTVP3026
  458. description : shift right Cursor ram data by o.
  459. parametres : word o // shift value
  460. retourne : aucune
  461. *****************************************************************************/
  462. /*
  463. planTVP[board] hold cursor data ram
  464. ---- 32 bits plan 0
  465. _______________________________________________________________
  466. col00 | col01 | col02 | col03 | col04 | col05 | col06 | col07 |
  467. | ---------------------------------------------------------------
  468. row 00 | p[00] | p[01] | p[02] | p[03] | 00 | 00 | 00 | 00 |
  469. row 01 | p[04] | p[05] | p[06] | p[07] | 00 | 00 | 00 | 00 |
  470. . | . | . | . | . | . | . | . | . |
  471. . | . | . | . | . | . | . | . | . |
  472. row 20 | p[7c] | p[7d] | p[7e] | p[7f] | 00 | 00 | 00 | 00 |
  473. row 21 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 |
  474. . | . | . | . | . | . | . | . | . |
  475. . | . | . | . | . | . | . | . | . |
  476. row 3f | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 |
  477. |________________________________________________________________
  478. ---- 32 bits plan 1
  479. _______________________________________________________________
  480. col00 | col01 | col02 | col03 | col04 | col05 | col06 | col07 |
  481. | ---------------------------------------------------------------
  482. row 00 | p[80] | p[81] | p[82] | p[83] | 00 | 00 | 00 | 00 |
  483. row 01 | p[84] | p[85] | p[86] | p[87] | 00 | 00 | 00 | 00 |
  484. . | . | . | . | . | . | . | . | . |
  485. . | . | . | . | . | . | . | . | . |
  486. row 20 | p[fc] | p[fd] | p[fe] | p[ff] | 00 | 00 | 00 | 00 |
  487. row 21 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 |
  488. . | . | . | . | . | . | . | . | . |
  489. . | . | . | . | . | . | . | . | . |
  490. row 3f | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 |
  491. |________________________________________________________________
  492. ---- 64 bits plan 0
  493. _______________________________________________________________
  494. col00 | col01 | col02 | col03 | col04 | col05 | col06 | col07 |
  495. | ---------------------------------------------------------------
  496. row 00 | p[00] | p[01] | p[02] | p[03] | p[04] | p[05] | p[06] | p[07] |
  497. row 01 | p[08] | p[09] | p[0a] | p[0b] | p[0c] | p[0d] | p[0e] | p[0f] |
  498. . | . | . | . | . | . | . | . | . |
  499. . | . | . | . | . | . | . | . | . |
  500. row 3f | p[1f8]| p[1f9]| p[1fa]| p[1fb]| p[1fc]| p[1fd]| p[1fe]| p[1ff]|
  501. |________________________________________________________________
  502. ---- 63 bits plan 1
  503. _______________________________________________________________
  504. | col00 | col01 | col02 | col03 | col04 | col05 | col06 | col07|
  505. | ---------------------------------------------------------------
  506. row 00 | p[200]| p[201]| p[202]| p[203]| p[204]| p[205]| p[206]| p[207]|
  507. row 01 | p[208]| p[209]| p[20a]| p[20b]| p[20c]| p[20d]| p[20e]| p[20f]|
  508. . | . | . | . | . | . | . | . | . |
  509. . | . | . | . | . | . | . | . | . |
  510. row 3f | p[3f8]| p[3f9]| p[3fa]| p[3fb]| p[3fc]| p[3fd]| p[3fe]| p[3ff]|
  511. |________________________________________________________________
  512. */
  513. static bool shiftCursorTVP3026(word o)
  514. {
  515. byte reg1, regCtl, curPos[4];
  516. int i, j, r_o;
  517. dword plan[2];
  518. dword plan32;
  519. byte *planByte = (byte *)plan;
  520. /* If an error occur in memory alloc */
  521. if (!planTVP[iBoard])
  522. return mtxFAIL;
  523. /* Hide cursor */
  524. /* I use this way to minimize noise problem when we acces the index
  525. register
  526. */
  527. rdDacReg(TVP3026_CUR_XLOW, &curPos[0]);
  528. rdDacReg(TVP3026_CUR_XHI , &curPos[1]);
  529. rdDacReg(TVP3026_CUR_YLOW, &curPos[2]);
  530. rdDacReg(TVP3026_CUR_YHI , &curPos[3]);
  531. wrDacReg(TVP3026_CUR_XLOW, 0x00 );
  532. wrDacReg(TVP3026_CUR_XHI , 0x00 );
  533. wrDacReg(TVP3026_CUR_YLOW, 0x00 );
  534. wrDacReg(TVP3026_CUR_YHI , 0x00 );
  535. r_o = (int)32 - (int)o;
  536. /* Transfer 1st 256 bytes */
  537. wrDacReg(TVP3026_INDEX, TVP3026_CURSOR_CTL);
  538. rdDacReg(TVP3026_DATA, &regCtl);
  539. reg1 = regCtl & 0xf0; /* CCR[3:2] = 00 */
  540. wrDacReg(TVP3026_INDEX, TVP3026_CURSOR_CTL);
  541. wrDacReg(TVP3026_DATA, reg1);
  542. wrDacReg(TVP3026_WADR_PAL, 0); /* address RAM cursor to 0 */
  543. for(j = 0; j < 256; j+=8)
  544. {
  545. if (Hw[iBoard].cursorInfo.CurWidth == 32) /* only 128 bytes */
  546. i = j >> 1;
  547. else
  548. i = j;
  549. plan[0] = plan[1] = 0;
  550. /* read first 32 bytes */
  551. /* display
  552. | byte 0 | byte1 | byte2 | byte 3 |
  553. byte 0 have to be the hi part of the dword
  554. */
  555. ((byte *)&plan32)[3] = (planTVP[iBoard])[i];
  556. ((byte *)&plan32)[2] = (planTVP[iBoard])[i+1];
  557. ((byte *)&plan32)[1] = (planTVP[iBoard])[i+2];
  558. ((byte *)&plan32)[0] = (planTVP[iBoard])[i+3];
  559. if (o)
  560. {
  561. if (r_o > 0) /* => o < 32 bits */
  562. {
  563. plan[0] = plan32 >> o; /* left part of slice */
  564. plan[1] = plan32 << r_o; /* right part of slice */
  565. if (Hw[iBoard].cursorInfo.CurWidth == 64) /* complete right slice */
  566. {
  567. ((byte *)&plan32)[3] = (planTVP[iBoard])[i+4];
  568. ((byte *)&plan32)[2] = (planTVP[iBoard])[i+5];
  569. ((byte *)&plan32)[1] = (planTVP[iBoard])[i+6];
  570. ((byte *)&plan32)[0] = (planTVP[iBoard])[i+7];
  571. plan[1] |= plan32 >> o;
  572. }
  573. }
  574. else /* o > 32 bits => left slice is empty */
  575. {
  576. plan[1] = plan32 >> (-r_o); /* right slice */
  577. }
  578. }
  579. else /* no shift, put back data */
  580. {
  581. plan[0] = plan32;
  582. if (Hw[iBoard].cursorInfo.CurWidth == 64)
  583. {
  584. ((byte *)&plan32)[3] = (planTVP[iBoard])[i+4];
  585. ((byte *)&plan32)[2] = (planTVP[iBoard])[i+5];
  586. ((byte *)&plan32)[1] = (planTVP[iBoard])[i+6];
  587. ((byte *)&plan32)[0] = (planTVP[iBoard])[i+7];
  588. plan[1] = plan32;
  589. }
  590. }
  591. /* Write to slice (hi part of each slice first */
  592. wrDacReg(TVP3026_CUR_RAM, planByte[3]);
  593. wrDacReg(TVP3026_CUR_RAM, planByte[2]);
  594. wrDacReg(TVP3026_CUR_RAM, planByte[1]);
  595. wrDacReg(TVP3026_CUR_RAM, planByte[0]);
  596. wrDacReg(TVP3026_CUR_RAM, planByte[7]);
  597. wrDacReg(TVP3026_CUR_RAM, planByte[6]);
  598. wrDacReg(TVP3026_CUR_RAM, planByte[5]);
  599. wrDacReg(TVP3026_CUR_RAM, planByte[4]);
  600. }
  601. /* Transfer 3rd 256 bytes (Start of second PLAN) */
  602. reg1 = reg1 & 0xf0;
  603. reg1 = reg1 | 0x08; /* CCR[3:2] = 10 */
  604. wrDacReg(TVP3026_INDEX, TVP3026_CURSOR_CTL);
  605. wrDacReg(TVP3026_DATA, reg1);
  606. wrDacReg(TVP3026_WADR_PAL, 0); /* address RAM cursor to 0 */
  607. for(j = 256; j < 512; j+=8)
  608. {
  609. if (Hw[iBoard].cursorInfo.CurWidth == 32)
  610. i = j >> 1;
  611. else
  612. i = j + 256;
  613. plan[0] = plan[1] = 0;
  614. ((byte *)&plan32)[3] = (planTVP[iBoard])[i];
  615. ((byte *)&plan32)[2] = (planTVP[iBoard])[i+1];
  616. ((byte *)&plan32)[1] = (planTVP[iBoard])[i+2];
  617. ((byte *)&plan32)[0] = (planTVP[iBoard])[i+3];
  618. if (o)
  619. {
  620. if (r_o > 0)
  621. {
  622. plan[0] = plan32 >> o;
  623. plan[1] = plan32 << r_o;
  624. if (Hw[iBoard].cursorInfo.CurWidth == 64)
  625. {
  626. ((byte *)&plan32)[3] = (planTVP[iBoard])[i+4];
  627. ((byte *)&plan32)[2] = (planTVP[iBoard])[i+5];
  628. ((byte *)&plan32)[1] = (planTVP[iBoard])[i+6];
  629. ((byte *)&plan32)[0] = (planTVP[iBoard])[i+7];
  630. plan[1] |= plan32 >> o;
  631. }
  632. }
  633. else
  634. {
  635. plan[1] = plan32 >> (-r_o);
  636. }
  637. }
  638. else
  639. {
  640. plan[0] = plan32;
  641. if (Hw[iBoard].cursorInfo.CurWidth == 64)
  642. {
  643. ((byte *)&plan32)[3] = (planTVP[iBoard])[i+4];
  644. ((byte *)&plan32)[2] = (planTVP[iBoard])[i+5];
  645. ((byte *)&plan32)[1] = (planTVP[iBoard])[i+6];
  646. ((byte *)&plan32)[0] = (planTVP[iBoard])[i+7];
  647. plan[1] = plan32;
  648. }
  649. }
  650. wrDacReg(TVP3026_CUR_RAM, planByte[3]);
  651. wrDacReg(TVP3026_CUR_RAM, planByte[2]);
  652. wrDacReg(TVP3026_CUR_RAM, planByte[1]);
  653. wrDacReg(TVP3026_CUR_RAM, planByte[0]);
  654. wrDacReg(TVP3026_CUR_RAM, planByte[7]);
  655. wrDacReg(TVP3026_CUR_RAM, planByte[6]);
  656. wrDacReg(TVP3026_CUR_RAM, planByte[5]);
  657. wrDacReg(TVP3026_CUR_RAM, planByte[4]);
  658. }
  659. if (Hw[iBoard].cursorInfo.CurWidth == 64)
  660. {
  661. /* Transfer 2nd 256 bytes */
  662. reg1 = reg1 & 0xf0;
  663. reg1 = reg1 | 0x04; /* CCR[3:2] = 01 */
  664. wrDacReg(TVP3026_INDEX, TVP3026_CURSOR_CTL);
  665. wrDacReg(TVP3026_DATA, reg1);
  666. wrDacReg(TVP3026_WADR_PAL, 0); /* address RAM cursor to 0 */
  667. for(i = 256; i < 512; i+=8)
  668. {
  669. plan[0] = plan[1] = 0;
  670. ((byte *)&plan32)[3] = (planTVP[iBoard])[i];
  671. ((byte *)&plan32)[2] = (planTVP[iBoard])[i+1];
  672. ((byte *)&plan32)[1] = (planTVP[iBoard])[i+2];
  673. ((byte *)&plan32)[0] = (planTVP[iBoard])[i+3];
  674. if (o)
  675. {
  676. if (r_o > 0)
  677. {
  678. plan[0] = plan32 >> o;
  679. plan[1] = plan32 << r_o;
  680. ((byte *)&plan32)[3] = (planTVP[iBoard])[i+4];
  681. ((byte *)&plan32)[2] = (planTVP[iBoard])[i+5];
  682. ((byte *)&plan32)[1] = (planTVP[iBoard])[i+6];
  683. ((byte *)&plan32)[0] = (planTVP[iBoard])[i+7];
  684. plan[1] |= plan32 >> o;
  685. }
  686. else
  687. {
  688. plan[1] = plan32 >> (-r_o);
  689. }
  690. }
  691. else
  692. {
  693. plan[0] = plan32;
  694. ((byte *)&plan32)[3] = (planTVP[iBoard])[i+4];
  695. ((byte *)&plan32)[2] = (planTVP[iBoard])[i+5];
  696. ((byte *)&plan32)[1] = (planTVP[iBoard])[i+6];
  697. ((byte *)&plan32)[0] = (planTVP[iBoard])[i+7];
  698. plan[1] = plan32;
  699. }
  700. wrDacReg(TVP3026_CUR_RAM, planByte[3]);
  701. wrDacReg(TVP3026_CUR_RAM, planByte[2]);
  702. wrDacReg(TVP3026_CUR_RAM, planByte[1]);
  703. wrDacReg(TVP3026_CUR_RAM, planByte[0]);
  704. wrDacReg(TVP3026_CUR_RAM, planByte[7]);
  705. wrDacReg(TVP3026_CUR_RAM, planByte[6]);
  706. wrDacReg(TVP3026_CUR_RAM, planByte[5]);
  707. wrDacReg(TVP3026_CUR_RAM, planByte[4]);
  708. }
  709. /* Transfer 4th 256 bytes */
  710. reg1 = reg1 & 0xf0;
  711. reg1 = reg1 | 0x0c; /* CCR[3:2] = 11 */
  712. wrDacReg(TVP3026_INDEX, TVP3026_CURSOR_CTL);
  713. wrDacReg(TVP3026_DATA, reg1);
  714. wrDacReg(TVP3026_WADR_PAL, 0); /* address RAM cursor to 0 */
  715. for(i = 768; i < 1024; i+=8)
  716. {
  717. plan[0] = plan[1] = 0;
  718. ((byte *)&plan32)[3] = (planTVP[iBoard])[i];
  719. ((byte *)&plan32)[2] = (planTVP[iBoard])[i+1];
  720. ((byte *)&plan32)[1] = (planTVP[iBoard])[i+2];
  721. ((byte *)&plan32)[0] = (planTVP[iBoard])[i+3];
  722. if (o)
  723. {
  724. if (r_o > 0)
  725. {
  726. plan[0] = plan32 >> o;
  727. plan[1] = plan32 << r_o;
  728. ((byte *)&plan32)[3] = (planTVP[iBoard])[i+4];
  729. ((byte *)&plan32)[2] = (planTVP[iBoard])[i+5];
  730. ((byte *)&plan32)[1] = (planTVP[iBoard])[i+6];
  731. ((byte *)&plan32)[0] = (planTVP[iBoard])[i+7];
  732. plan[1] |= plan32 >> o;
  733. }
  734. else
  735. {
  736. plan[1] = plan32 >> (-r_o);
  737. }
  738. }
  739. else
  740. {
  741. plan[0] = plan32;
  742. ((byte *)&plan32)[3] = (planTVP[iBoard])[i+4];
  743. ((byte *)&plan32)[2] = (planTVP[iBoard])[i+5];
  744. ((byte *)&plan32)[1] = (planTVP[iBoard])[i+6];
  745. ((byte *)&plan32)[0] = (planTVP[iBoard])[i+7];
  746. plan[1] = plan32;
  747. }
  748. wrDacReg(TVP3026_CUR_RAM, planByte[3]);
  749. wrDacReg(TVP3026_CUR_RAM, planByte[2]);
  750. wrDacReg(TVP3026_CUR_RAM, planByte[1]);
  751. wrDacReg(TVP3026_CUR_RAM, planByte[0]);
  752. wrDacReg(TVP3026_CUR_RAM, planByte[7]);
  753. wrDacReg(TVP3026_CUR_RAM, planByte[6]);
  754. wrDacReg(TVP3026_CUR_RAM, planByte[5]);
  755. wrDacReg(TVP3026_CUR_RAM, planByte[4]);
  756. }
  757. }
  758. /* Display cursor */
  759. wrDacReg(TVP3026_INDEX, TVP3026_CURSOR_CTL);
  760. wrDacReg(TVP3026_DATA, regCtl);
  761. wrDacReg(TVP3026_CUR_XLOW, curPos[0]);
  762. wrDacReg(TVP3026_CUR_XHI , curPos[1]);
  763. wrDacReg(TVP3026_CUR_YLOW, curPos[2]);
  764. wrDacReg(TVP3026_CUR_YHI , curPos[3]);
  765. return mtxOK;
  766. }
  767. /***************************************************************************
  768. Function : mtxCursorShape
  769. description : Defines the cursor shape and size
  770. parameters : PixMap *pPixMap // pointer to a PixMap structure
  771. returns : mtxFAIL if function fails
  772. mtxGood if function complete
  773. *****************************************************************************/
  774. bool mtxCursorSetShape(PixMap *pPixMap)
  775. {
  776. if (pPixMap->Data)
  777. switch (pPixMap->Width)
  778. {
  779. case 32:
  780. Hw[iBoard].cursorInfo.HotSX = 32 + Hw[iBoard].CurrentOverScanX;
  781. Hw[iBoard].cursorInfo.HotSY = 32 + Hw[iBoard].CurrentOverScanY;
  782. Hw[iBoard].cursorInfo.CurWidth = 32;
  783. Hw[iBoard].cursorInfo.CurHeight = 32;
  784. break;
  785. case 64:
  786. Hw[iBoard].cursorInfo.HotSX = 64 + Hw[iBoard].CurrentOverScanX;
  787. Hw[iBoard].cursorInfo.HotSY = 64 + Hw[iBoard].CurrentOverScanY;
  788. Hw[iBoard].cursorInfo.CurWidth = 64;
  789. Hw[iBoard].cursorInfo.CurHeight = 64;
  790. break;
  791. default: return mtxFAIL;
  792. }
  793. /* Verify if bitmap square (we support 32 x 32 and 64 x 64) */
  794. if ( pPixMap->Data && (pPixMap->Width != pPixMap->Height))
  795. return mtxFAIL;
  796. switch(Hw[iBoard].DacType)
  797. {
  798. case BT482:
  799. if ( pPixMap->Width != 32) return mtxFAIL; /*32 x 32 only */
  800. charge482(pPixMap);
  801. break;
  802. case BT485:
  803. case PX2085:
  804. charge485(pPixMap);
  805. break;
  806. case VIEWPOINT:
  807. chargeVIEWPOINT(pPixMap);
  808. break;
  809. case TVP3026:
  810. chargeTVP3026(pPixMap);
  811. break;
  812. default: return mtxFAIL;
  813. }
  814. /* Hot spot by defaut = 0, 0 */
  815. Hw[iBoard].cursorInfo.cHotSX = 0;
  816. Hw[iBoard].cursorInfo.cHotSY = 0;
  817. return mtxOK;
  818. }
  819. /***************************************************************************
  820. Function : mtxCursorColors
  821. description : Definition of the cursor color
  822. parameters : mtxRGB color1, color2 // Definition of the two colors
  823. returns : none
  824. *****************************************************************************/
  825. void mtxCursorSetColors(mtxRGB color00, mtxRGB color01, mtxRGB color10, mtxRGB color11)
  826. {
  827. word i;
  828. byte reg_cur;
  829. switch(Hw[iBoard].DacType)
  830. {
  831. case BT482:
  832. wrDacReg(BT482_WADR_PAL, BT482_CUR_REG); /* points on Cursor register */
  833. /* Select Cursor RAM */
  834. rdDacReg(BT482_PIX_RD_MSK, &reg_cur);
  835. wrDacReg(BT482_PIX_RD_MSK, 0);
  836. wrDacReg(BT482_WADR_OVL, 0x11); /* address col cursor */
  837. /* color 1 */
  838. for (i = 0; i < 24; i += 8)
  839. wrDacReg(BT482_COL_OVL, (color10 >> i) & 0xff);
  840. /* color 2 */
  841. for (i = 0; i < 24; i += 8)
  842. wrDacReg(BT482_COL_OVL, (color11 >> i) & 0xff);
  843. /* Reset original value in the registers */
  844. wrDacReg(BT482_WADR_PAL, BT482_CUR_REG);/* points to Cursor register */
  845. /* replace originale dans cursor reg. */
  846. /* reg_cur &= ~(BT482_CUR_CR3_RAM | BT482_CUR_EN_M);*/
  847. wrDacReg(BT482_PIX_RD_MSK, reg_cur); /* restore Cursor register */
  848. break;
  849. case BT485:
  850. case PX2085:
  851. wrDacReg(BT485_WADR_OVL, BT485_OFF_CUR_COL); /* address col cursor */
  852. /* color 1 */
  853. for (i = 0; i < 24; i += 8)
  854. wrDacReg(BT485_COL_OVL, (color10 >> i) & 0xff);
  855. /* color 2 */
  856. for (i = 0; i < 24; i += 8)
  857. wrDacReg(BT485_COL_OVL, (color11 >> i) & 0xff);
  858. break;
  859. case VIEWPOINT:
  860. /* Cursor Color 0 */
  861. wrDacReg(VPOINT_INDEX, VPOINT_CUR_COL0_RED);
  862. wrDacReg(VPOINT_DATA, color10 & 0xff);
  863. wrDacReg(VPOINT_INDEX, VPOINT_CUR_COL0_GREEN);
  864. wrDacReg(VPOINT_DATA, (color10 >> 8) & 0xff);
  865. wrDacReg(VPOINT_INDEX, VPOINT_CUR_COL0_BLUE);
  866. wrDacReg(VPOINT_DATA, (color10 >> 16) & 0xff);
  867. /* Cursor Color 1 */
  868. wrDacReg(VPOINT_INDEX, VPOINT_CUR_COL1_RED);
  869. wrDacReg(VPOINT_DATA, color11 & 0xff);
  870. wrDacReg(VPOINT_INDEX, VPOINT_CUR_COL1_GREEN);
  871. wrDacReg(VPOINT_DATA, (color11 >> 8) & 0xff);
  872. wrDacReg(VPOINT_INDEX, VPOINT_CUR_COL1_BLUE);
  873. wrDacReg(VPOINT_DATA, (color11 >> 16) & 0xff);
  874. break;
  875. case TVP3026:
  876. rdDacReg(TVP3026_CUR_COL_ADDR, &reg_cur);
  877. reg_cur = reg_cur & 0xf3;
  878. reg_cur = reg_cur | 0x01; /* [1:0]=01 : cursor color 0 */
  879. /* wrDacReg(TVP3026_CUR_COL_ADDR, reg_cur); */
  880. wrDacReg(TVP3026_CUR_COL_ADDR, 01);
  881. /* Cursor Color 0 */
  882. wrDacReg(TVP3026_CUR_COL_DATA, color10 & 0xff);
  883. wrDacReg(TVP3026_CUR_COL_DATA, (color10 >> 8) & 0xff);
  884. wrDacReg(TVP3026_CUR_COL_DATA, (color10 >> 16) & 0xff);
  885. /* Cursor Color 1 */
  886. wrDacReg(TVP3026_CUR_COL_DATA, color11 & 0xff);
  887. wrDacReg(TVP3026_CUR_COL_DATA, (color11 >> 8) & 0xff);
  888. wrDacReg(TVP3026_CUR_COL_DATA, (color11 >> 16) & 0xff);
  889. break;
  890. }
  891. }
  892. /***************************************************************************
  893. Function : mtxCursorEnable
  894. description : Enable/disable the cursor
  895. parameter : mode 0 = disable, 1 = enable, others = reserved
  896. returns :
  897. *****************************************************************************/
  898. void mtxCursorEnable(word mode)
  899. {
  900. byte reg_cur;
  901. switch(Hw[iBoard].DacType)
  902. {
  903. case BT482:
  904. /*-- Permits access to the Extented register */
  905. wrDacReg(BT482_WADR_PAL, BT482_CUR_REG); /* points to Cursor register */
  906. rdDacReg(BT482_PIX_RD_MSK, &reg_cur);
  907. reg_cur &= ~(BT482_CUR_MODE_M | BT482_CUR_EN_M);
  908. switch(mode)
  909. {
  910. case 0:
  911. /* disable cursor */
  912. wrDacReg(BT482_PIX_RD_MSK, reg_cur | BT482_CUR_MODE_DIS);
  913. break;
  914. case 1:
  915. /* enable cursor */
  916. wrDacReg(BT482_PIX_RD_MSK, reg_cur | BT482_CUR_MODE_3);
  917. break;
  918. }
  919. break;
  920. case BT485:
  921. case PX2085:
  922. rdDacReg(BT485_CMD_REG2, &reg_cur);
  923. reg_cur &= ~BT485_CUR_MODE_M;
  924. switch(mode)
  925. {
  926. case 0:
  927. wrDacReg(BT485_CMD_REG2, reg_cur | BT485_CUR_MODE_DIS);
  928. break;
  929. case 1:
  930. wrDacReg(BT485_CMD_REG2, reg_cur | BT485_CUR_MODE_3);
  931. break;
  932. }
  933. break;
  934. case VIEWPOINT:
  935. wrDacReg(VPOINT_INDEX, VPOINT_CUR_CTL);
  936. if (mode)
  937. wrDacReg(VPOINT_DATA, 0x50);
  938. else
  939. wrDacReg(VPOINT_DATA, 0x10);
  940. break;
  941. case TVP3026:
  942. /* get cursor location */
  943. /*
  944. rdDacReg(TVP3026_CUR_XLOW, &curPos[0]);
  945. rdDacReg(TVP3026_CUR_XHI , &curPos[1]);
  946. rdDacReg(TVP3026_CUR_YLOW, &curPos[2]);
  947. rdDacReg(TVP3026_CUR_YHI , &curPos[3]);
  948. */
  949. /* put cursor out of display */
  950. /*
  951. wrDacReg(TVP3026_CUR_XLOW, 0x00);
  952. wrDacReg(TVP3026_CUR_XHI , 0x00);
  953. wrDacReg(TVP3026_CUR_YLOW, 0x00);
  954. wrDacReg(TVP3026_CUR_YHI , 0x00);
  955. */
  956. wrDacReg(TVP3026_INDEX, TVP3026_CURSOR_CTL);
  957. rdDacReg(TVP3026_DATA, &reg_cur);
  958. if(mode)
  959. {
  960. /*** BEN TEST ***/
  961. reg_cur = reg_cur | 0x03; /* CCR[3:2] = 11 X-Windows cursor */
  962. }
  963. else
  964. reg_cur = reg_cur & 0xfc; /* CCR[1:0] = 00 cursor off */
  965. wrDacReg(TVP3026_DATA, reg_cur);
  966. /* restore cursor location */
  967. /*
  968. wrDacReg(TVP3026_CUR_XLOW, curPos[0]);
  969. wrDacReg(TVP3026_CUR_XHI , curPos[1]);
  970. wrDacReg(TVP3026_CUR_YLOW, curPos[2]);
  971. wrDacReg(TVP3026_CUR_YHI , curPos[3]);
  972. */
  973. break;
  974. }
  975. }
  976. /***************************************************************************
  977. Function : mtxCursorSetHotSpot
  978. description : Defines the position of the cursor with respect to xy
  979. (0,0) corresponding to top left hand corner
  980. parameters : x, y offset with respect to top left hand corner < size of cursor
  981. returns :
  982. *****************************************************************************/
  983. void mtxCursorSetHotSpot(word Dx, word Dy)
  984. {
  985. Hw[iBoard].cursorInfo.cHotSX = Dx;
  986. Hw[iBoard].cursorInfo.cHotSY = Dy;
  987. Hw[iBoard].cursorInfo.HotSX = (Hw[iBoard].cursorInfo.CurWidth + Hw[iBoard].CurrentOverScanX) - Dx;
  988. Hw[iBoard].cursorInfo.HotSY = (Hw[iBoard].cursorInfo.CurHeight + Hw[iBoard].CurrentOverScanY) - Dy;
  989. }
  990. /***************************************************************************
  991. Function : mtxCursorMove
  992. description : move the HotSpot to the position x, y
  993. parameters : x, y new position
  994. returns :
  995. *****************************************************************************/
  996. void mtxCursorMove(word X, word Y)
  997. {
  998. word xp, yp;
  999. xp = X + Hw[iBoard].cursorInfo.HotSX;
  1000. yp = Y + Hw[iBoard].cursorInfo.HotSY;
  1001. switch(Hw[iBoard].DacType)
  1002. {
  1003. case BT482:
  1004. /*-- Permits access to the Extented register */
  1005. /* Cursor X Low Register */
  1006. wrDacReg(BT482_WADR_PAL, BT482_CUR_XLOW);
  1007. wrDacReg(BT482_PIX_RD_MSK, xp & 0xff);
  1008. /* Cursor X High Register */
  1009. wrDacReg(BT482_WADR_PAL, BT482_CUR_XHI);
  1010. wrDacReg(BT482_PIX_RD_MSK, xp >> 8);
  1011. /* Cursor Y Low Register */
  1012. wrDacReg(BT482_WADR_PAL, BT482_CUR_YLOW);
  1013. wrDacReg(BT482_PIX_RD_MSK, yp & 0xff);
  1014. /* Cursor Y High Register */
  1015. wrDacReg(BT482_WADR_PAL, BT482_CUR_YHI);
  1016. wrDacReg(BT482_PIX_RD_MSK, yp >> 8);
  1017. break;
  1018. case BT485:
  1019. case PX2085:
  1020. wrDacReg(BT485_CUR_XLOW, xp & 0xff);
  1021. wrDacReg(BT485_CUR_XHI, xp >> 8);
  1022. wrDacReg(BT485_CUR_YLOW, yp & 0xff);
  1023. wrDacReg(BT485_CUR_YHI, yp >> 8);
  1024. break;
  1025. case VIEWPOINT:
  1026. wrDacReg(VPOINT_INDEX, VPOINT_CUR_XLOW);
  1027. wrDacReg(VPOINT_DATA, xp & 0xff);
  1028. wrDacReg(VPOINT_INDEX, VPOINT_CUR_XHI);
  1029. wrDacReg(VPOINT_DATA, xp >> 8);
  1030. wrDacReg(VPOINT_INDEX, VPOINT_CUR_YLOW);
  1031. wrDacReg(VPOINT_DATA, yp & 0xff);
  1032. wrDacReg(VPOINT_INDEX, VPOINT_CUR_YHI);
  1033. wrDacReg(VPOINT_DATA, yp >> 8);
  1034. break;
  1035. case TVP3026:
  1036. {
  1037. int delta;
  1038. if(Hw[iBoard].cursorInfo.CurWidth == 32)
  1039. {
  1040. yp += 32;
  1041. xp += 32;
  1042. }
  1043. /* Patch for TVP3026 rev 2 the cursor can not go out of */
  1044. /* visible space */
  1045. if ( revTVP[iBoard] <= 2 )
  1046. {
  1047. delta = (int)xp - (int)(Hw[iBoard].pCurrentDisplayMode->DispWidth - 2);
  1048. if (delta < 0) delta = 0;
  1049. if (delta < 64)
  1050. {
  1051. xp -= (word)delta;
  1052. if (delta != currentTVPDelta[iBoard])
  1053. {
  1054. currentTVPDelta[iBoard] = (word)delta;
  1055. shiftCursorTVP3026((word)delta);
  1056. }
  1057. }
  1058. }
  1059. wrDacReg(TVP3026_CUR_XLOW, xp & 0xff);
  1060. wrDacReg(TVP3026_CUR_XHI, xp >> 8);
  1061. wrDacReg(TVP3026_CUR_YLOW, yp & 0xff);
  1062. wrDacReg(TVP3026_CUR_YHI, yp >> 8);
  1063. }
  1064. break;
  1065. }
  1066. }
  1067. /***************************************************************************
  1068. Function : mtxCursorGetInfo
  1069. description : returns a pointer containing the information describing
  1070. the type of cursor that the current RamDac supports
  1071. parameters :
  1072. returns : CursorInfo *
  1073. *****************************************************************************/
  1074. CursorInfo * mtxCursorGetInfo()
  1075. {
  1076. return (CursorInfo *)&Hw[iBoard].cursorInfo;
  1077. }
  1078.