place-holder for restructure
[AROS.git] / arch / arm-raspi / hidd.videocoregfx / videocoregfx_bitmap_common.c
blob00646fd65f21fc286a52ea9d42ba5118fda70d10
1 /*
2 Copyright © 2013, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #define DEBUG 0
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"
16 #ifdef OnBitmap
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);
21 IPTR width, height;
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"
32 #endif
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;
38 HIDDT_Pixel red;
39 HIDDT_Pixel green;
40 HIDDT_Pixel blue;
41 ULONG xc_i;
42 ULONG col_i;
44 pf = BM_PIXFMT(o);
45 if (
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))
51 return FALSE;
52 if ((msg->firstColor + msg->numColors) > (1 << data->bpp))
53 return FALSE;
55 #ifdef OnBitmap
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;
62 #endif
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);
69 #ifdef OnBitmap
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]));
73 #endif
74 msg->colors[col_i].pixval = xc_i;
76 #ifdef OnBitmap
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]));
85 #endif
86 return TRUE;
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);
94 ULONG idx;
96 if (IS_VideoCoreGfxBM_ATTR(msg->attrID, idx))
98 switch (idx)
100 case aoHidd_VideoCoreGfxBitMap_Drawable:
101 *msg->storage = (IPTR)data->VideoData;
102 break;
103 default:
104 OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
107 else
109 OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);