1: /* Copyright 1985 Massachusetts Institute of Technology */ 2: 3: /* ddxcursor.c various stuff with the mouse & cursor 4: * 5: * StoreCursor Creates a cursor 6: * FreeCursor Frees the storage taken by a cursor 7: * LoadCursor Loads a bitmap to use as cursor 8: * InitMouse Initialize the mouse 9: * SetCursorPosition Forces cursor to a particular position 10: * SetMouseCharacteristics Controls speed of cursor relative to mouse 11: * 12: */ 13: 14: #include "ddxqvss.h" 15: #include <vaxuba/qvioctl.h> 16: #include "qvss.h" 17: 18: extern vsIoAddr *VSAddr; 19: extern BITMAP vbm; 20: extern int vsdev; 21: 22: char *Xalloc(); 23: /* someday this routine needs to be thought through and redone */ 24: 25: CURSOR *StoreCursor (func, image, fore, back, mask, xoff, yoff) 26: register BITMAP *image; 27: BITMAP *mask; 28: int func, fore, back, xoff, yoff; 29: { 30: register CURSOR *cursor; 31: register short *im = (short *)image->data; 32: register short *cmask = (short *)mask->data; 33: register CursPriv *data; 34: register int i, wmsk; 35: extern char FBMap[]; 36: static short bmask[] = { 0x0000, 0x0001, 0x0003, 0x0007, 37: 0x000f, 0x001f, 0x003f, 0x007f, 38: 0x00ff, 0x01ff, 0x03ff, 0x07ff, 39: 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff }; 40: 41: static short defmask[] = { 0xffff, 0xffff, 0xffff, 0xffff, 42: 0xffff, 0xffff, 0xffff, 0xffff, 43: 0xffff, 0xffff, 0xffff, 0xffff, 44: 0xffff, 0xffff, 0xffff, 0xffff }; 45: 46: if (mask == NULL) cmask = defmask; 47: 48: cursor = (CURSOR *) Xalloc (sizeof (CURSOR)); 49: cursor->width = min(image->width, CURSOR_WIDTH); 50: cursor->height = min(image->height, CURSOR_HEIGHT); 51: cursor->xmin = xoff; 52: cursor->ymin = yoff; 53: cursor->xoff = xoff; 54: cursor->yoff = yoff; 55: cursor->xmax = vbm.width - (image->width - xoff); 56: cursor->ymax = vbm.height - (image->height - yoff); 57: cursor->refcnt = 1; 58: data = (CursPriv *) Xalloc (sizeof (CursPriv)); 59: cursor->data = (caddr_t) data; 60: if (fore & 1) 61: func += 0x20; 62: if (back & 1) 63: func += 0x10; 64: func = FBMap[func]; 65: 66: wmsk = bmask[cursor->width]; 67: 68: if (fore == 0 || func == GXxor || func == GXequiv) { 69: for ( i = 0; i < cursor->height; i++) 70: data->cbits[i] = (*im++ & *cmask++) & wmsk; 71: } 72: else { 73: for ( i = 0; i < cursor->height; i++) 74: data->cbits[i] = (~*im++ & *cmask++) & wmsk; 75: } 76: 77: for (i = cursor->height; i < 16; i++); 78: data->cbits[i] = 0; 79: return (cursor); 80: } 81: 82: FreeCursor (cursor) 83: register CURSOR *cursor; 84: { 85: free ((caddr_t) CDATA(cursor)); 86: free ((caddr_t) cursor); 87: } 88: 89: LoadCursor (cursor) 90: register CURSOR *cursor; 91: { 92: register short *cbits = VSAddr->cursorbits; 93: register short *nbits; 94: register int i; 95: int nrows = cursor->height; 96: int ncols = cursor->width; 97: 98: nbits = (short *) CDATA(cursor)->cbits; 99: if (ncols > 16) ncols = 16; 100: if (nrows > 16) nrows = 16; 101: 102: for(i = 0; i < nrows; i++) 103: *cbits++ = *nbits++; 104: 105: for(i = nrows; i < 16; i++) 106: *cbits++ = 0; 107: return(0); 108: } 109: 110: InitMouse () 111: { 112: } 113: 114: SetCursorPosition(pos) 115: register vsCursor *pos; 116: { 117: return(ioctl(vsdev, QIOCSMSTATE,pos)); 118: } 119: 120: SetMouseCharacteristics (threshold, accelaration) 121: int threshold, accelaration; 122: { 123: VSAddr->mscale = accelaration; 124: VSAddr->mthreshold = threshold; 125: }