mesa: simplify dependencies in mmakefiles
[AROS.git] / workbench / hidds / vmwaresvga / vmwaresvgaclass.c
blob27e5521304c4b2b2bc8813d2e95c80a9df219cd6
1 /*
2 Copyright © 1995-2015, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Class for VMWare.
6 Lang: English.
7 */
9 #define DEBUG 0
10 #include <aros/debug.h>
12 #define __OOP_NOATTRBASES__
14 #include <proto/exec.h>
15 #include <proto/oop.h>
16 #include <proto/utility.h>
17 #include <aros/symbolsets.h>
18 #include <devices/inputevent.h>
19 #include <exec/alerts.h>
20 #include <exec/memory.h>
21 #include <hardware/custom.h>
22 #include <hidd/hidd.h>
23 #include <hidd/graphics.h>
24 #include <oop/oop.h>
25 #include <clib/alib_protos.h>
26 #include <string.h>
27 #include <stdio.h>
29 #include "vmwaresvgaclass.h"
30 #include "vmwaresvgabitmap.h"
31 #include "vmwaresvgahardware.h"
33 #include LC_LIBDEFS_FILE
35 static OOP_AttrBase HiddBitMapAttrBase;
36 static OOP_AttrBase HiddPixFmtAttrBase;
37 static OOP_AttrBase HiddGfxAttrBase;
38 static OOP_AttrBase HiddSyncAttrBase;
39 static OOP_AttrBase HiddVMWareSVGAAttrBase;
40 static OOP_AttrBase HiddVMWareSVGABitMapAttrBase;
42 static struct OOP_ABDescr attrbases[] =
44 {IID_Hidd_BitMap, &HiddBitMapAttrBase },
45 {IID_Hidd_VMWareSVGABitMap, &HiddVMWareSVGABitMapAttrBase },
46 {IID_Hidd_VMWareSVGA, &HiddVMWareSVGAAttrBase },
47 {IID_Hidd_PixFmt, &HiddPixFmtAttrBase },
48 {IID_Hidd_Sync, &HiddSyncAttrBase },
49 {IID_Hidd_Gfx, &HiddGfxAttrBase },
50 {NULL, NULL }
53 STATIC ULONG mask_to_shift(ULONG mask)
55 ULONG i;
57 for (i = 32; mask; i --) {
58 mask >>= 1;
61 if (mask == 32) {
62 i = 0;
65 return i;
68 OOP_Object *VMWareSVGA__Root__New(OOP_Class *cl, OOP_Object *o, struct pRoot_New *msg)
70 unsigned int sync_count, sync_modes, sync_curr, sync_displayid, sync_modeid;
72 struct TagItem pftags[] =
74 {aHidd_PixFmt_RedShift, 0 }, /* 0 */
75 {aHidd_PixFmt_GreenShift, 0 }, /* 1 */
76 {aHidd_PixFmt_BlueShift, 0 }, /* 2 */
77 {aHidd_PixFmt_AlphaShift, 0 }, /* 3 */
78 {aHidd_PixFmt_RedMask, 0 }, /* 4 */
79 {aHidd_PixFmt_GreenMask, 0 }, /* 5 */
80 {aHidd_PixFmt_BlueMask, 0 }, /* 6 */
81 {aHidd_PixFmt_AlphaMask, 0 }, /* 7 */
82 {aHidd_PixFmt_ColorModel, 0 }, /* 8 */
83 {aHidd_PixFmt_Depth, 0 }, /* 9 */
84 {aHidd_PixFmt_BytesPerPixel, 0 }, /* 10 */
85 {aHidd_PixFmt_BitsPerPixel, 0 }, /* 11 */
86 {aHidd_PixFmt_StdPixFmt, 0 }, /* 12 */
87 {aHidd_PixFmt_CLUTShift, 0 }, /* 13 */
88 {aHidd_PixFmt_CLUTMask, 0x0f }, /* 14 */
89 {aHidd_PixFmt_BitMapType, 0 }, /* 15 */
90 {TAG_DONE, 0UL }
92 /* TODO: Probe available sync modes */
93 #define VMWARESVGA_SYNCMODES 5
94 sync_modes = VMWARESVGA_SYNCMODES;
95 sync_count = sync_modes * XSD(cl)->data.displaycount;
97 struct TagItem *modetags = AllocVec((sync_count + 2) * sizeof(struct TagItem), MEMF_CLEAR);
99 modetags[0].ti_Tag = aHidd_Gfx_PixFmtTags;
100 modetags[0].ti_Data = (IPTR)pftags;
101 modetags[sync_count + 1].ti_Tag = TAG_DONE;
103 sync_curr = 0;
105 while (sync_curr < sync_count)
107 sync_modeid = sync_curr % sync_modes;
108 sync_displayid = sync_curr/sync_modes;
110 ULONG sync_Width =0;
111 ULONG sync_Height=0;
112 D(bug("[VMWareSVGA] %s: Setting Sync Mode %d for Display %d\n", __PRETTY_FUNCTION__, sync_modeid, sync_displayid));
114 char *sync_Description = AllocVec(24 , MEMF_CLEAR);
116 switch (sync_modeid)
118 case 1:
119 sync_Width =800;
120 sync_Height=600;
121 break;
122 case 2:
123 sync_Width =1024;
124 sync_Height=768;
125 break;
126 case 3:
127 sync_Width =1280;
128 sync_Height=1024;
129 break;
130 case 4:
131 sync_Width =1600;
132 sync_Height=1200;
133 break;
134 default:
135 sync_Width =640;
136 sync_Height=480;
137 break;
140 if (sync_displayid == 0)
142 sprintf(sync_Description, "VMWareSVGA:%dx%d", sync_Width, sync_Height);
144 else
146 sprintf(sync_Description, "VMWareSVGA.%d:%dx%d", sync_displayid, sync_Width, sync_Height);
148 D(bug("[VMWareSVGA] %s: Description '%s'\n", __PRETTY_FUNCTION__, sync_Description));
150 struct TagItem *sync_mode = AllocVec(11 * sizeof(struct TagItem), MEMF_CLEAR);
152 sync_mode[0].ti_Tag = aHidd_Sync_Description;
153 sync_mode[0].ti_Data = (IPTR)sync_Description;
154 sync_mode[1].ti_Tag = aHidd_Sync_PixelClock;
155 sync_mode[2].ti_Tag = aHidd_Sync_HDisp;
156 sync_mode[2].ti_Data = sync_Width;
157 sync_mode[3].ti_Tag = aHidd_Sync_VDisp;
158 sync_mode[3].ti_Data = sync_Height;
159 sync_mode[4].ti_Tag = aHidd_Sync_HSyncStart;
160 sync_mode[5].ti_Tag = aHidd_Sync_HSyncEnd;
161 sync_mode[6].ti_Tag = aHidd_Sync_HTotal;
162 sync_mode[7].ti_Tag = aHidd_Sync_VSyncStart;
163 sync_mode[8].ti_Tag = aHidd_Sync_VSyncEnd;
164 sync_mode[9].ti_Tag = aHidd_Sync_VTotal;
165 sync_mode[10].ti_Tag = TAG_DONE;
167 modetags[1 + sync_curr].ti_Tag = aHidd_Gfx_SyncTags;
168 modetags[1 + sync_curr].ti_Data = (IPTR)sync_mode;
170 sync_curr++;
173 struct TagItem yourtags[] =
175 {aHidd_Gfx_ModeTags, (IPTR)modetags },
176 {TAG_MORE, 0UL }
178 struct pRoot_New yourmsg;
180 /* set pftags = 0 */
181 if (!XSD(cl)->data.pseudocolor)
183 pftags[0].ti_Data = mask_to_shift(XSD(cl)->data.redmask);
184 pftags[1].ti_Data = mask_to_shift(XSD(cl)->data.greenmask);
185 pftags[2].ti_Data = mask_to_shift(XSD(cl)->data.bluemask);
187 else
189 pftags[0].ti_Data = 0;
190 pftags[1].ti_Data = 0;
191 pftags[2].ti_Data = 0;
193 pftags[3].ti_Data = 0;
194 pftags[4].ti_Data = XSD(cl)->data.redmask;
195 pftags[5].ti_Data = XSD(cl)->data.greenmask;
196 pftags[6].ti_Data = XSD(cl)->data.bluemask;
197 pftags[7].ti_Data = 0;
198 D(bug("[VMWareSVGA] New: Masks red=%08x<<%d,green=%08x<<%d,blue%08x<<%d\n",
199 pftags[4].ti_Data, pftags[0].ti_Data,
200 pftags[5].ti_Data, pftags[1].ti_Data,
201 pftags[6].ti_Data, pftags[2].ti_Data));
203 if (XSD(cl)->data.pseudocolor)
204 pftags[8].ti_Data = vHidd_ColorModel_Palette;
205 else
206 pftags[8].ti_Data = vHidd_ColorModel_TrueColor;
208 pftags[9].ti_Data = XSD(cl)->data.depth;
209 pftags[10].ti_Data = XSD(cl)->data.bytesperpixel;
210 pftags[11].ti_Data = XSD(cl)->data.bitsperpixel;
211 pftags[12].ti_Data = vHidd_StdPixFmt_Native;
212 pftags[15].ti_Data = vHidd_BitMapType_Chunky;
214 yourtags[1].ti_Data = (IPTR)msg->attrList;
216 yourmsg.mID = msg->mID;
217 yourmsg.attrList = yourtags;
218 msg = &yourmsg;
219 EnterFunc(bug("VMWareSVGA::New()\n"));
220 o = (OOP_Object *)OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
221 if (o)
223 D(bug("[VMWareSVGA] Got object from super\n"));
224 XSD(cl)->vmwaresvgahidd = o;
225 XSD(cl)->mouse.shape = NULL;
226 ReturnPtr("VMWareSVGA::New", OOP_Object *, o);
228 ReturnPtr("VMWareSVGA::New", OOP_Object *, NULL);
231 VOID VMWareSVGA__Root__Dispose(OOP_Class *cl, OOP_Object *o, OOP_Msg msg)
233 FreeVec(XSD(cl)->mouse.shape);
234 OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
237 VOID VMWareSVGA__Root__Get(OOP_Class *cl, OOP_Object *o, struct pRoot_Get *msg)
239 ULONG idx;
240 BOOL found = FALSE;
242 if (IS_GFX_ATTR(msg->attrID, idx))
244 switch (idx)
246 case aoHidd_Gfx_SupportsHWCursor:
247 *msg->storage = (IPTR)TRUE;
248 found = TRUE;
249 break;
252 if (!found)
253 OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
256 OOP_Object *VMWareSVGA__Hidd_Gfx__CreateObject(OOP_Class *cl, OOP_Object *o, struct pHidd_Gfx_CreateObject *msg)
258 OOP_Object *object = NULL;
260 EnterFunc(bug("VMWareSVGA::CreateObject()\n"));
262 if (msg->cl == XSD(cl)->basebm)
264 BOOL displayable;
265 BOOL framebuffer;
266 OOP_Class *classptr = NULL;
267 struct TagItem tags[] =
269 { TAG_IGNORE, TAG_IGNORE }, /* Placeholder for aHidd_BitMap_ClassPtr */
270 { TAG_MORE, (IPTR)msg->attrList }
273 struct pHidd_Gfx_CreateObject yourmsg;
275 displayable = GetTagData(aHidd_BitMap_Displayable, FALSE, msg->attrList);
276 framebuffer = GetTagData(aHidd_BitMap_FrameBuffer, FALSE, msg->attrList);
277 if (framebuffer)
278 classptr = XSD(cl)->vmwaresvgaonbmclass;
279 else if (displayable)
280 classptr = XSD(cl)->vmwaresvgaoffbmclass;
281 else
283 HIDDT_ModeID modeid;
284 modeid = (HIDDT_ModeID)GetTagData(aHidd_BitMap_ModeID, vHidd_ModeID_Invalid, msg->attrList);
285 if (modeid != vHidd_ModeID_Invalid)
286 classptr = XSD(cl)->vmwaresvgaoffbmclass;
287 else
289 HIDDT_StdPixFmt stdpf;
290 stdpf = (HIDDT_StdPixFmt)GetTagData(aHidd_BitMap_StdPixFmt, vHidd_StdPixFmt_Unknown, msg->attrList);
291 if (stdpf == vHidd_StdPixFmt_Unknown)
293 OOP_Object *friend;
294 friend = (OOP_Object *)GetTagData(aHidd_BitMap_Friend, (IPTR)NULL, msg->attrList);
295 if (friend != NULL)
297 OOP_Class *friend_class = NULL;
298 OOP_GetAttr(friend, aHidd_BitMap_ClassPtr, (IPTR *)&friend_class);
299 if (friend_class == XSD(cl)->vmwaresvgaonbmclass)
301 classptr = XSD(cl)->vmwaresvgaoffbmclass;
307 if (classptr != NULL)
309 tags[0].ti_Tag = aHidd_BitMap_ClassPtr;
310 tags[0].ti_Data = (IPTR)classptr;
312 yourmsg.mID = msg->mID;
313 yourmsg.cl = msg->cl;
314 yourmsg.attrList = tags;
316 object = (OOP_Object *)OOP_DoSuperMethod(cl, o, (OOP_Msg)&yourmsg);
318 else
319 object = (OOP_Object *)OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
321 ReturnPtr("VMWareSVGA::CreateObject", OOP_Object *, object);
324 VOID VMWareSVGA__Hidd_Gfx__CopyBox(OOP_Class *cl, OOP_Object *o, struct pHidd_Gfx_CopyBox *msg)
326 UBYTE *src = NULL;
327 UBYTE *dst = NULL;
328 HIDDT_DrawMode mode;
329 struct Box box;
331 EnterFunc(bug("VMWareSVGA.BitMap::CopyBox\n"));
332 mode = GC_DRMD(msg->gc);
333 OOP_GetAttr(msg->src, aHidd_VMWareSVGABitMap_Drawable, (IPTR *)&src);
334 OOP_GetAttr(msg->dest, aHidd_VMWareSVGABitMap_Drawable, (IPTR *)&dst);
335 if (((dst == NULL) || (src == NULL))) /* no vmwaregfx bitmap */
337 OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
339 else if (dst == src)
341 struct BitmapData *data;
342 data = OOP_INST_DATA(OOP_OCLASS(msg->src), msg->src);
343 switch (mode)
345 case vHidd_GC_DrawMode_Clear:
346 clearCopyVMWareSVGA(data->data, msg->srcX, msg->srcY, msg->destX, msg->destY, msg->width, msg->height);
347 break;
348 case vHidd_GC_DrawMode_And:
349 andCopyVMWareSVGA(data->data, msg->srcX, msg->srcY, msg->destX, msg->destY, msg->width, msg->height);
350 break;
351 case vHidd_GC_DrawMode_AndReverse:
352 andReverseCopyVMWareSVGA(data->data, msg->srcX, msg->srcY, msg->destX, msg->destY, msg->width, msg->height);
353 break;
354 case vHidd_GC_DrawMode_Copy:
355 copyCopyVMWareSVGA(data->data, msg->srcX, msg->srcY, msg->destX, msg->destY, msg->width, msg->height);
356 break;
357 case vHidd_GC_DrawMode_AndInverted:
358 andInvertedCopyVMWareSVGA(data->data, msg->srcX, msg->srcY, msg->destX, msg->destY, msg->width, msg->height);
359 break;
360 case vHidd_GC_DrawMode_NoOp:
361 noOpCopyVMWareSVGA(data->data, msg->srcX, msg->srcY, msg->destX, msg->destY, msg->width, msg->height);
362 break;
363 case vHidd_GC_DrawMode_Xor:
364 xorCopyVMWareSVGA(data->data, msg->srcX, msg->srcY, msg->destX, msg->destY, msg->width, msg->height);
365 break;
366 case vHidd_GC_DrawMode_Or:
367 orCopyVMWareSVGA(data->data, msg->srcX, msg->srcY, msg->destX, msg->destY, msg->width, msg->height);
368 break;
369 case vHidd_GC_DrawMode_Nor:
370 norCopyVMWareSVGA(data->data, msg->srcX, msg->srcY, msg->destX, msg->destY, msg->width, msg->height);
371 break;
372 case vHidd_GC_DrawMode_Equiv:
373 equivCopyVMWareSVGA(data->data, msg->srcX, msg->srcY, msg->destX, msg->destY, msg->width, msg->height);
374 break;
375 case vHidd_GC_DrawMode_Invert:
376 invertCopyVMWareSVGA(data->data, msg->srcX, msg->srcY, msg->destX, msg->destY, msg->width, msg->height);
377 break;
378 case vHidd_GC_DrawMode_OrReverse:
379 orReverseCopyVMWareSVGA(data->data, msg->srcX, msg->srcY, msg->destX, msg->destY, msg->width, msg->height);
380 break;
381 case vHidd_GC_DrawMode_CopyInverted:
382 copyInvertedCopyVMWareSVGA(data->data, msg->srcX, msg->srcY, msg->destX, msg->destY, msg->width, msg->height);
383 break;
384 case vHidd_GC_DrawMode_OrInverted:
385 orInvertedCopyVMWareSVGA(data->data, msg->srcX, msg->srcY, msg->destX, msg->destY, msg->width, msg->height);
386 break;
387 case vHidd_GC_DrawMode_Nand:
388 nandCopyVMWareSVGA(data->data, msg->srcX, msg->srcY, msg->destX, msg->destY, msg->width, msg->height);
389 break;
390 case vHidd_GC_DrawMode_Set:
391 setCopyVMWareSVGA(data->data, msg->srcX, msg->srcY, msg->destX, msg->destY, msg->width, msg->height);
392 break;
393 default:
394 OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
397 else
399 struct BitmapData *srcbd = OOP_INST_DATA(OOP_OCLASS(msg->src), msg->src);
400 struct BitmapData *dstbd = OOP_INST_DATA(OOP_OCLASS(msg->dest), msg->dest);
401 UBYTE *sbuffer;
402 ULONG srestadd;
403 UBYTE *dbuffer;
404 ULONG drestadd;
405 ULONG ycnt = msg->height;
406 ULONG xcnt;
407 LONG offset;
408 /* get src/dest video data start addresses and skip sizes */
409 if (srcbd->VideoData == srcbd->data->vrambase)
411 offset = (msg->srcX*srcbd->bytesperpix)+(msg->srcY*srcbd->data->bytesperline);
412 srestadd = (srcbd->data->bytesperline - (msg->width*srcbd->bytesperpix));
413 displayCursorVMWareSVGA(&XSD(cl)->data, 0);
414 XSD(cl)->mouse.visible = 0;
416 else
418 offset = (msg->srcX+(msg->srcY*srcbd->width))*srcbd->bytesperpix;
419 srestadd = (srcbd->width - msg->width)*srcbd->bytesperpix;
421 sbuffer = srcbd->VideoData+offset;
422 if (dstbd->VideoData == dstbd->data->vrambase)
424 offset = (msg->destX*dstbd->bytesperpix)+(msg->destY*dstbd->data->bytesperline);
425 drestadd = (dstbd->data->bytesperline - (msg->width*dstbd->bytesperpix));
426 displayCursorVMWareSVGA(&XSD(cl)->data, 0);
427 XSD(cl)->mouse.visible = 0;
429 else
431 offset = (msg->destX+(msg->destY*dstbd->width))*dstbd->bytesperpix;
432 drestadd = (dstbd->width - msg->width)*dstbd->bytesperpix;
434 dbuffer = dstbd->VideoData+offset;
435 switch (mode)
437 case vHidd_GC_DrawMode_Copy:
438 while (ycnt--)
440 ULONG pixel;
441 xcnt = msg->width;
442 while (xcnt)
444 /* get pixel from source */
445 switch (srcbd->bytesperpix)
447 case 1:
448 pixel = (ULONG)*((UBYTE *)sbuffer);
449 sbuffer++;
450 break;
451 case 2:
452 pixel = (ULONG)*((UWORD *)sbuffer);
453 sbuffer += 2;
454 break;
455 case 4:
456 pixel = (ULONG)*((ULONG *)sbuffer);
457 sbuffer += 4;
458 break;
459 default:
460 D(bug("[VMWareSVGA] Copy: Unknown number of bytes per pixel (%d) in source!\n",srcbd->bytesperpix));
461 pixel = 0;
462 break;
464 /* write pixel to destination */
465 switch (dstbd->bytesperpix)
467 case 1:
468 *((UBYTE *)dbuffer) = (UBYTE)pixel;
469 dbuffer++;
470 break;
471 case 2:
472 *((UWORD *)dbuffer) = (UWORD)pixel;
473 dbuffer += 2;
474 break;
475 case 4:
476 *((ULONG *)dbuffer) = (ULONG)pixel;
477 dbuffer += 4;
478 break;
479 default:
480 D(bug("[VMWareSVGA] Copy: Unknown number of bytes per pixel (%d) in destination!\n",dstbd->bytesperpix));
481 break;
483 xcnt--;
485 sbuffer += srestadd;
486 dbuffer += drestadd;
488 if (dstbd->VideoData == dstbd->data->vrambase)
490 box.x1 = msg->destX;
491 box.y1 = msg->destY;
492 box.x2 = box.x1+msg->width-1;
493 box.y2 = box.y1+msg->height-1;
494 refreshAreaVMWareSVGA(dstbd->data, &box);
496 break;
497 default:
498 kprintf("[VMWareSVGA] mode = %ld src=%lx dst=%lx\n", mode, src, dst);
499 OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
501 if (XSD(cl)->mouse.visible == 0)
503 displayCursorVMWareSVGA(&XSD(cl)->data, 1);
504 XSD(cl)->mouse.visible = 1;
507 ReturnVoid("VMWareSVGA.BitMap::CopyBox");
510 BOOL VMWareSVGA__Hidd_Gfx__SetCursorShape(OOP_Class *cl, OOP_Object *o, struct pHidd_Gfx_SetCursorShape *msg)
512 struct VMWareSVGA_staticdata *data = XSD(cl);
514 if (msg->shape == NULL)
516 displayCursorVMWareSVGA(&XSD(cl)->data, 0);
517 data->mouse.oopshape = NULL;
518 FreeVec(data->mouse.shape);
519 data->mouse.shape = NULL;
520 return TRUE;
522 else
524 OOP_Object *pfmt;
525 OOP_Object *colmap;
526 HIDDT_StdPixFmt pixfmt;
527 HIDDT_Color color;
528 IPTR tmp;
529 OOP_GetAttr(msg->shape, aHidd_BitMap_Width, &tmp);
530 data->mouse.width = tmp;
531 OOP_GetAttr(msg->shape, aHidd_BitMap_Height, &tmp);
532 data->mouse.height = tmp;
533 OOP_GetAttr(msg->shape, aHidd_BitMap_PixFmt, (IPTR *)&pfmt);
534 OOP_GetAttr(pfmt, aHidd_PixFmt_StdPixFmt, (IPTR *)&pixfmt);
535 OOP_GetAttr(msg->shape, aHidd_BitMap_ColorMap, (IPTR *)&colmap);
536 data->mouse.oopshape = msg->shape;
537 #if 0
538 data->mouse.shape = cursor_shape;
539 data->mouse.width = 11;
540 data->mouse.height = 11;
541 defineCursorVMWareSVGA(&XSD(cl)->data, &data->mouse);
542 return TRUE;
543 #else
544 /* convert shape to vmware needs */
545 FreeVec(data->mouse.shape);
546 data->mouse.shape = AllocVec(SVGA_PIXMAP_SIZE(data->mouse.width, data->mouse.height, data->data.bitsperpixel)*4, MEMF_PUBLIC);
547 if (data->mouse.shape != NULL)
549 LONG xcnt;
550 LONG ycnt;
551 LONG linebytes;
552 LONG bytecnt;
553 LONG pixelbytes;
554 UBYTE *shape;
555 linebytes = SVGA_PIXMAP_SCANLINE_SIZE(data->mouse.width, data->data.bitsperpixel)*4;
556 pixelbytes = (data->data.bitsperpixel+3)/8;
557 shape = data->mouse.shape;
558 for (ycnt=0;ycnt<data->mouse.height;ycnt++)
560 for (xcnt=0;xcnt<data->mouse.width;xcnt++)
562 HIDDT_Pixel pixel;
563 pixel = HIDD_BM_GetPixel(msg->shape, xcnt, ycnt);
564 if (pixfmt == vHidd_StdPixFmt_LUT8)
566 if (HIDD_CM_GetColor(colmap, pixel, &color))
568 pixel =
570 (((color.red <<16)>>mask_to_shift(data->data.redmask)) & data->data.redmask )+
571 (((color.green<<16)>>mask_to_shift(data->data.greenmask)) & data->data.greenmask)+
572 (((color.blue <<16)>>mask_to_shift(data->data.bluemask)) & data->data.bluemask )
576 if (pixelbytes == 1)
578 *((UBYTE *)shape) = (UBYTE)pixel;
579 shape++;
581 else if (pixelbytes == 2)
583 *((UWORD *)shape) = (UWORD)pixel;
584 shape += 2;
586 else if (pixelbytes == 4)
588 *((ULONG *)shape) = (ULONG)pixel;
589 shape += 4;
592 for (bytecnt=linebytes-(data->mouse.width*pixelbytes);bytecnt;bytecnt--)
594 *((UBYTE *)shape) = 0; /* fill up to long boundary */
595 shape++;
598 defineCursorVMWareSVGA(&XSD(cl)->data, &data->mouse);
599 return TRUE;
601 #endif
603 return FALSE;
606 BOOL VMWareSVGA__Hidd_Gfx__SetCursorPos(OOP_Class *cl, OOP_Object *o, struct pHidd_Gfx_SetCursorPos *msg)
608 XSD(cl)->mouse.x = msg->x;
609 XSD(cl)->mouse.y = msg->y;
610 if (XSD(cl)->mouse.x<0)
611 XSD(cl)->mouse.x=0;
612 if (XSD(cl)->mouse.y<0)
613 XSD(cl)->mouse.y=0;
614 /* TODO: check visible width/height */
615 moveCursorVMWareSVGA(&XSD(cl)->data, msg->x, msg->y);
616 return TRUE;
619 VOID VMWareSVGA__Hidd_Gfx__SetCursorVisible(OOP_Class *cl, OOP_Object *o, struct pHidd_Gfx_SetCursorVisible *msg)
621 XSD(cl)->mouse.visible = msg->visible;
622 displayCursorVMWareSVGA(&XSD(cl)->data, msg->visible ? 1 : 0);
626 static int VMWareSVGA_InitStatic(LIBBASETYPEPTR LIBBASE)
628 EnterFunc(bug("[VMWareSVGA] VMWareSVGA_InitStatic()\n"));
630 LIBBASE->vsd.mouse.x=0;
631 LIBBASE->vsd.mouse.y=0;
632 LIBBASE->vsd.mouse.shape = NULL;
634 if (!OOP_ObtainAttrBases(attrbases))
636 D(bug("[VMWareSVGA] VMWareSVGA_InitStatic: attrbases init failed\n"));
637 return FALSE;
640 D(bug("[VMWareSVGA] VMWareSVGA_InitStatic: ok\n"));
642 ReturnInt("VMWareSVGA_InitStatic", int, TRUE);
645 static int VMWareSVGA_ExpungeStatic(LIBBASETYPEPTR LIBBASE)
647 EnterFunc(bug("[VMWareSVGA] VMWareSVGA_ExpungeStatic()\n"));
649 OOP_ReleaseAttrBases(attrbases);
650 ReturnInt("VMWareSVGA_ExpungeStatic", int, TRUE);
653 ADD2INITLIB(VMWareSVGA_InitStatic, 0)
654 ADD2EXPUNGELIB(VMWareSVGA_ExpungeStatic, 0)