2 Copyright © 2013, The AROS Development Team. All rights reserved.
7 #include <aros/debug.h>
9 #include <proto/vcmbox.h>
11 #include <exec/alerts.h>
12 #include <string.h> // memset() prototype
14 #include "videocoregfx_hardware.h"
17 /********* BitMap::Clear() *************************************/
18 VOID
MNAME_BM(Clear
)(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_Clear
*msg
)
20 struct BitmapData
*data
= OOP_INST_DATA(cl
, o
);
23 D(bug("[VideoCoreGfx] VideoCoreGfx.BitMap::Clear()\n"));
25 /* Get width & height from bitmap */
27 OOP_GetAttr(o
, aHidd_BitMap_Width
, &width
);
28 OOP_GetAttr(o
, aHidd_BitMap_Height
, &height
);
30 #warning "TODO: Implement HW accelerated bitmap clear"
34 BOOL
MNAME_BM(SetColors
)(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_SetColors
*msg
)
36 struct BitmapData
*data
= OOP_INST_DATA(cl
, o
);
37 HIDDT_PixelFormat
*pf
;
46 (vHidd_ColorModel_StaticPalette
== HIDD_PF_COLMODEL(pf
)) ||
47 (vHidd_ColorModel_TrueColor
== HIDD_PF_COLMODEL(pf
))
49 return OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
50 if (!OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
))
52 if ((msg
->firstColor
+ msg
->numColors
) > (1 << data
->bpp
))
56 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_VCMBoxMessage
[0] = 5 + (msg
->numColors
- msg
->firstColor
) * 4;
57 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_VCMBoxMessage
[1] = VCTAG_REQ
;
58 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_VCMBoxMessage
[2] = VCTAG_SETPALETTE
;
59 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_VCMBoxMessage
[3] = (msg
->numColors
- msg
->firstColor
) * 4;
60 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_VCMBoxMessage
[4] = msg
->firstColor
;
61 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_VCMBoxMessage
[5] = msg
->numColors
;
63 for (xc_i
= msg
->firstColor
, col_i
= 0; col_i
< msg
->numColors
; xc_i
++, col_i
++)
65 red
= msg
->colors
[col_i
].red
>> 8;
66 green
= msg
->colors
[col_i
].green
>> 8;
67 blue
= msg
->colors
[col_i
].blue
>> 8;
68 data
->cmap
[xc_i
] = 0x01000000 | red
| (green
<< 8) | (blue
<< 16);
71 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_VCMBoxMessage
[6 + col_i
] = (red
<< 24) | (green
<< 16) | (blue
<< 8);
72 D(bug("[VideoCoreGfx] VideoCoreGfx.BitMap::SetColors: color #%d = %08x\n", xc_i
, (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_VCMBoxMessage
[6 + col_i
]));
74 msg
->colors
[col_i
].pixval
= xc_i
;
77 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_VCMBoxMessage
[7 + col_i
] = 0;
78 (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_VCMBoxMessage
[7 + col_i
+ 1] = 0; // terminate tag
80 VCMBoxWrite(VCMB_BASE
, VCMB_PROPCHAN
, (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_VCMBoxMessage
);
81 if (VCMBoxRead(VCMB_BASE
, VCMB_PROPCHAN
) == (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_VCMBoxMessage
)
83 D(bug("[VideoCoreGfx] %s: Palette set [status %08x]\n", __PRETTY_FUNCTION__
, (&((struct VideoCoreGfxBase
*)cl
->UserData
)->vsd
)->vcsd_VCMBoxMessage
[7 + col_i
]));
89 /*** BitMap::Get() *******************************************/
91 VOID
MNAME_ROOT(Get
)(OOP_Class
*cl
, OOP_Object
*o
, struct pRoot_Get
*msg
)
93 struct BitmapData
*data
= OOP_INST_DATA(cl
, o
);
96 if (IS_VideoCoreGfxBM_ATTR(msg
->attrID
, idx
))
100 case aoHidd_VideoCoreGfxBitMap_Drawable
:
101 *msg
->storage
= (IPTR
)data
->VideoData
;
104 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
109 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);