|
|
1.1 root 1: /******************************Module*Header*******************************\
2: * Module Name: pointer.c
3: *
4: * This module contains the hardware pointer support for the XGA dispaly driver.
5: *
6: *
7: * Copyright (c) 1992 Microsoft Corporation
8: \**************************************************************************/
9:
10: #include "driver.h"
11:
12: ULONG DrvSetColorPointerShape(
13: SURFOBJ *pso,
14: SURFOBJ *psoMask,
15: SURFOBJ *psoColor,
16: XLATEOBJ *pxlo,
17: LONG xHot,
18: LONG yHot,
19: LONG x,
20: LONG y,
21: RECTL *prcl,
22: FLONG fl
23: ) ;
24:
25: ULONG DrvSetMonoHwPointerShape(
26: SURFOBJ *pso,
27: SURFOBJ *psoMask,
28: SURFOBJ *psoColor,
29: XLATEOBJ *pxlo,
30: LONG xHot,
31: LONG yHot,
32: LONG x,
33: LONG y,
34: RECTL *prcl,
35: FLONG fl
36: ) ;
37:
38:
39: VOID DrvMoveColorPointer(SURFOBJ *pso,LONG x,LONG y,RECTL *prcl) ;
40: VOID DrvMoveHwPointer(SURFOBJ *pso,LONG x,LONG y,RECTL *prcl) ;
41:
42: /*
43: These globals must be global.
44: Need to look into putting them into the pdev.
45: */
46:
47:
48: LONG gxHot, gyHot,
49: gcxPointer, gcyPointer,
50: gxLast, gyLast ;
51:
52: ULONG gPointerFlags ;
53:
54: #define VALID_SAVE_BUFFER 0x1
55: #define COLOR_POINTER 0x2
56: #define TAKE_DOWN_POINTER 0X4
57:
58:
59:
60: /*****************************************************************************
61: * DrvMovePointer -
62: ****************************************************************************/
63: VOID DrvMovePointer(SURFOBJ *pso,LONG x,LONG y,RECTL *prcl)
64: {
65:
66: if (gPointerFlags & COLOR_POINTER)
67: DrvMoveColorPointer(pso, x, y, prcl) ;
68: else
69: DrvMoveHwPointer(pso, x, y, prcl) ;
70:
71: return ;
72:
73: }
74:
75:
76: /*****************************************************************************
77: * DrvMoveColorPointer -
78: ****************************************************************************/
79: VOID DrvMoveColorPointer(SURFOBJ *pso,LONG x,LONG y,RECTL *prcl)
80: {
81: return ;
82:
83:
84: }
85:
86: /*****************************************************************************
87: * DrvMoveHwPointer -
88: ****************************************************************************/
89: VOID DrvMoveHwPointer(SURFOBJ *pso,LONG x,LONG y,RECTL *prcl)
90: {
91: WORD msb,
92: lsb ;
93:
94: PPDEV ppdev ;
95: INT XgaIndexReg ;
96:
97: // get a local pointer to the pdev and all the registers we plan
98: // to use.
99:
100: ppdev = (PPDEV) pso->dhpdev ;
101: XgaIndexReg = ppdev->ulXgaIoRegsBase + INDEX_REG ;
102:
103: // If x is -1 then take down the cursor.
104:
105: if (x == -1)
106: {
107: outpw (XgaIndexReg, SPRITE_CONTROL) ;
108: return ;
109: }
110:
111: // Adjust the actual pointer position depending upon
112: // the hot spot.
113:
114: x -= gxHot ;
115: y -= gyHot ;
116:
117: if (x <= 0)
118: {
119: outpw (XgaIndexReg, ((-x << 8) | SPRITE_HORZ_PRESET)) ;
120: x = 0 ;
121: }
122: else
123: {
124: outpw (XgaIndexReg, ((0 << 8) | SPRITE_HORZ_PRESET)) ;
125: }
126:
127: if (y <= 0)
128: {
129: outpw (XgaIndexReg, ((-y << 8) | SPRITE_VERT_PRESET)) ;
130: y = 0 ;
131: }
132: else
133: {
134: outpw (XgaIndexReg, ((0 << 8) | SPRITE_VERT_PRESET)) ;
135: }
136:
137: // Set the position of the cursor.
138:
139: msb = HIBYTE (x) ;
140: lsb = LOBYTE (x) ;
141: outpw (XgaIndexReg, ((lsb << 8) | SPRITE_HORZ_START_LOW)) ;
142: outpw (XgaIndexReg, ((msb << 8) | SPRITE_HORZ_START_HIGH)) ;
143:
144: msb = HIBYTE (y) ;
145: lsb = LOBYTE (y) ;
146: outpw (XgaIndexReg, ((lsb << 8) | SPRITE_VERT_START_LOW)) ;
147: outpw (XgaIndexReg, ((msb << 8) | SPRITE_VERT_START_HIGH)) ;
148:
149: return ;
150: }
151:
152:
153: /*****************************************************************************
154: * DrvSetPointerShape -
155: ****************************************************************************/
156: ULONG DrvSetPointerShape(
157: SURFOBJ *pso,
158: SURFOBJ *psoMask,
159: SURFOBJ *psoColor,
160: XLATEOBJ *pxlo,
161: LONG xHot,
162: LONG yHot,
163: LONG x,
164: LONG y,
165: RECTL *prcl,
166: FLONG fl)
167: {
168: ULONG ulRet ;
169:
170: PPDEV ppdev ;
171: INT XgaIndexReg ;
172:
173: DISPDBG((3, "Change hardware pointer shape\n"));
174:
175: // get a local pointer to the pdev and all the registers we plan
176: // to use.
177:
178: ppdev = (PPDEV) pso->dhpdev ;
179: XgaIndexReg = ppdev->ulXgaIoRegsBase + INDEX_REG ;
180:
181: // Save the position and hot spot in globals.
182:
183: gxHot = xHot ;
184: gyHot = yHot ;
185:
186: gcxPointer = psoMask->sizlBitmap.cx ;
187: gcyPointer = psoMask->sizlBitmap.cy / 2;
188:
189: if (psoColor != NULL)
190: {
191: // Disable the mono hardware pointer.
192:
193: outpw (XgaIndexReg, SPRITE_CONTROL) ;
194:
195: gPointerFlags |= COLOR_POINTER ;
196: ulRet = DrvSetColorPointerShape(pso, psoMask, psoColor, pxlo,
197: xHot, yHot, x, y, prcl, fl) ;
198:
199: }
200: else
201: {
202: // Take down the color pointer if it is visible.
203:
204: if ( (gPointerFlags & COLOR_POINTER)
205: && (gPointerFlags & VALID_SAVE_BUFFER)
206: )
207: {
208: ulRet = DrvSetColorPointerShape(NULL, NULL, NULL, NULL,
209: 0, 0, 0, 0, NULL, 0) ;
210: }
211:
212: // Take care of the monochrome pointer.
213:
214: gPointerFlags &= ~COLOR_POINTER ;
215: ulRet = DrvSetMonoHwPointerShape(pso, psoMask, psoColor, pxlo,
216: xHot, yHot, x, y, prcl, fl) ;
217: }
218:
219:
220: return (ulRet) ;
221: }
222:
223:
224: /*****************************************************************************
225: * DrvSetColorPointerShape -
226: ****************************************************************************/
227: ULONG DrvSetColorPointerShape(
228: SURFOBJ *pso,
229: SURFOBJ *psoMask,
230: SURFOBJ *psoColor,
231: XLATEOBJ *pxlo,
232: LONG xHot,
233: LONG yHot,
234: LONG x,
235: LONG y,
236: RECTL *prcl,
237: FLONG fl)
238: {
239: return (SPS_DECLINE) ;
240: }
241:
242: /*****************************************************************************
243: * DrvSetMonoHwPointerShape -
244: ****************************************************************************/
245: ULONG DrvSetMonoHwPointerShape(
246: SURFOBJ *pso,
247: SURFOBJ *psoMask,
248: SURFOBJ *psoColor,
249: XLATEOBJ *pxlo,
250: LONG xHot,
251: LONG yHot,
252: LONG x,
253: LONG y,
254: RECTL *prcl,
255: FLONG fl)
256: {
257:
258: UINT i,
259: j,
260: cxMask,
261: cyMask,
262: cyAND,
263: cxAND,
264: cyXOR,
265: cxXOR ;
266:
267: PBYTE pjAND,
268: pjXOR ;
269:
270: INT lDelta ;
271:
272: PPDEV ppdev ;
273: INT XgaIndexReg ;
274:
275: INT ix,
276: iy,
277: is,
278: ip,
279: iBit,
280: jAndByte,
281: jXorByte,
282: jSpriteBits,
283: jSpriteByte ;
284:
285: BYTE ajAndMask[64][8],
286: ajXorMask[64][8] ;
287:
288: BYTE ajXgaSprite[1024] ;
289:
290:
291: DISPDBG((3, "XGA.DLL:DrvSetPointerShape - Entry\n")) ;
292: DISPDBG((3, "\txHot: %d\n", xHot)) ;
293: DISPDBG((3, "\tyHot: %d\n", yHot)) ;
294:
295: // get a local pointer to the pdev and all the registers we plan
296: // to use.
297:
298: ppdev = (PPDEV) pso->dhpdev ;
299: XgaIndexReg = ppdev->ulXgaIoRegsBase + INDEX_REG ;
300:
301: // If the mask is NULL this implies the pointer is not
302: // visible.
303:
304: if (psoMask == NULL)
305: {
306: outpw (XgaIndexReg, SPRITE_CONTROL) ;
307: return (SPS_ACCEPT_NOEXCLUDE) ;
308: }
309:
310: // Init the AND and XOR masks.
311:
312: memset (ajAndMask, 0xFFFFFFFF, 512) ;
313: memset (ajXorMask, 0, 512) ;
314:
315: // Get the bitmap dimensions.
316:
317: cxMask = psoMask->sizlBitmap.cx ;
318: cyMask = psoMask->sizlBitmap.cy ;
319:
320: cyAND = cyXOR = cyMask / 2 ;
321: cxAND = cxXOR = cxMask / 8 ;
322:
323: // Set up pointers to the AND and XOR masks.
324:
325: pjAND = psoMask->pvScan0 ;
326: lDelta = psoMask->lDelta ;
327: pjXOR = pjAND + (cyAND * lDelta) ;
328:
329: // Copy the AND mask.
330:
331: for (i = 0 ; i < cyAND ; i++)
332: {
333: // Copy over a line of the AND mask.
334:
335: for (j = 0 ; j < cxAND ; j++)
336: {
337: ajAndMask[i][j] = pjAND[j] ;
338: }
339:
340: // point to the next line of the AND mask.
341:
342: pjAND += lDelta ;
343: }
344:
345: // Copy the XOR mask.
346:
347: for (i = 0 ; i < cyXOR ; i++)
348: {
349: // Copy over a line of the XOR mask.
350:
351: for (j = 0 ; j < cxXOR ; j++)
352: {
353: ajXorMask[i][j] = pjXOR[j] ;
354: }
355:
356: // point to the next line of the XOR mask.
357:
358: pjXOR += lDelta ;
359: }
360:
361: // Build up the XGA sprite from NT's And and Xor masks.
362:
363: // Init the indexes into the sprite buffer (is) and the
364: // index for the bit pairs (ip).
365:
366: is = 0 ;
367: ip = 0 ;
368:
369: // Outer most loop goes over NT's And and Xor rows.
370:
371: for (iy = 0 ; iy < 64 ; iy++)
372: {
373: // loop over Nt's columns.
374:
375: for (ix = 0 ; ix < 8 ; ix++)
376: {
377: // pickup a source byte for each mask.
378:
379: jAndByte = ajAndMask[iy][ix] ;
380: jXorByte = ajXorMask[iy][ix] ;
381:
382: // loop over the bits in the byte.
383:
384: for (iBit = 0x80 ; iBit != 0 ; iBit >>= 1)
385: {
386: // init the sprite bitpair.
387:
388: jSpriteBits = 0x0 ;
389:
390: // Set the sprite bit pairs.
391:
392: if (jAndByte & iBit)
393: jSpriteBits |= 0x02 ;
394:
395: if (jXorByte & iBit)
396: jSpriteBits |= 0x01 ;
397:
398: // If all 4 bit pairs in this byte are filled in
399: // flush the sprite byte to the sprite byte array.
400: // and set the first bit pair.
401:
402: if ((ip % 4) == 0)
403: {
404: if (ip != 0)
405: {
406: ajXgaSprite[is++] = jSpriteByte ;
407: }
408: jSpriteByte = jSpriteBits ;
409: }
410:
411: // If the sprite byte is not full, shift the bit pair
412: // into position, and or it into the sprite byte.
413:
414: else
415: {
416: jSpriteBits <<= (ip % 4) * 2 ;
417: jSpriteByte |= jSpriteBits ;
418: }
419:
420: // bump the bit pair counter.
421:
422: ip++ ;
423: }
424: }
425: }
426:
427: // Flush the last byte.
428:
429: ajXgaSprite[is++] = jSpriteByte ;
430:
431:
432: // Disable the pointer.
433:
434: outpw (XgaIndexReg, SPRITE_CONTROL) ;
435:
436: // Set the sprite index to 0.
437:
438: outpw (XgaIndexReg, SPRITE_INDEX_LOW) ;
439: outpw (XgaIndexReg, SPRITE_INDEX_HIGH) ;
440:
441: // Down load the sprite data to the XGA.
442:
443: for (i = 0 ; i < 1024 ; i++)
444: {
445: jSpriteByte = ajXgaSprite[i] ;
446: outpw (XgaIndexReg, ((jSpriteByte << 8) | SPRITE_DATA)) ;
447: }
448:
449: // Set the pointer colors.
450:
451: outpw (XgaIndexReg, SPRITE_COLOR_REG0_RED) ;
452: outpw (XgaIndexReg, SPRITE_COLOR_REG0_GREEN) ;
453: outpw (XgaIndexReg, SPRITE_COLOR_REG0_BLUE) ;
454:
455: outpw (XgaIndexReg, ((0xff << 8) | SPRITE_COLOR_REG1_RED)) ;
456: outpw (XgaIndexReg, ((0xff << 8) | SPRITE_COLOR_REG1_GREEN)) ;
457: outpw (XgaIndexReg, ((0xff << 8) | SPRITE_COLOR_REG1_BLUE)) ;
458:
459: // Set the position of the cursor.
460:
461: DrvMovePointer(pso, x, y, NULL) ;
462:
463: outpw (XgaIndexReg, ((SC << 8) | SPRITE_CONTROL)) ;
464:
465: return (SPS_ACCEPT_NOEXCLUDE) ;
466: }
467:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.