wip prep commit in lieu of gfx subsystem update changes.
[AROS.git] / rom / hidds / vesa / vesagfx_hiddclass.c
blob641e7d28f9544b815e1711c7ad2f2d0dc04f4977
1 /*
2 Copyright © 1995-2017, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Class for VESA.
6 Lang: English.
7 */
9 #define __OOP_NOATTRBASES__
11 #include <aros/asmcall.h>
12 #include <proto/exec.h>
13 #include <proto/oop.h>
14 #include <proto/utility.h>
15 #include <aros/symbolsets.h>
16 #include <devices/inputevent.h>
17 #include <exec/alerts.h>
18 #include <exec/memory.h>
19 #include <hardware/custom.h>
20 #include <hidd/hidd.h>
21 #include <hidd/gfx.h>
22 #include <oop/oop.h>
23 #include <clib/alib_protos.h>
24 #include <string.h>
26 #define DEBUG 0
27 #include <aros/debug.h>
29 #include "vesagfx_hidd.h"
30 #include "vesagfx_support.h"
32 #include LC_LIBDEFS_FILE
34 AROS_INTH1(ResetHandler, struct HWData *, hwdata)
36 AROS_INTFUNC_INIT
38 ClearBuffer(hwdata);
40 return FALSE;
42 AROS_INTFUNC_EXIT
45 OOP_Object *VESAGfx__Root__New(OOP_Class *cl, OOP_Object *o, struct pRoot_New *msg)
47 struct TagItem pftags[] =
49 {aHidd_PixFmt_RedShift, 0}, /* 0 */
50 {aHidd_PixFmt_GreenShift, 0}, /* 1 */
51 {aHidd_PixFmt_BlueShift, 0}, /* 2 */
52 {aHidd_PixFmt_AlphaShift, 0}, /* 3 */
53 {aHidd_PixFmt_RedMask, 0}, /* 4 */
54 {aHidd_PixFmt_GreenMask, 0}, /* 5 */
55 {aHidd_PixFmt_BlueMask, 0}, /* 6 */
56 {aHidd_PixFmt_AlphaMask, 0}, /* 7 */
57 {aHidd_PixFmt_ColorModel, 0}, /* 8 */
58 {aHidd_PixFmt_Depth, 0}, /* 9 */
59 {aHidd_PixFmt_BytesPerPixel,0}, /* 10 */
60 {aHidd_PixFmt_BitsPerPixel, 0}, /* 11 */
61 {aHidd_PixFmt_StdPixFmt, vHidd_StdPixFmt_Native}, /* 12 */
62 {aHidd_PixFmt_CLUTShift, 0}, /* 13 */
63 {aHidd_PixFmt_CLUTMask, 0}, /* 14 */
64 {aHidd_PixFmt_BitMapType, vHidd_BitMapType_Chunky}, /* 15 */
65 {TAG_DONE, 0UL }
67 struct TagItem sync_mode[] =
69 {aHidd_Sync_HDisp, 0},
70 {aHidd_Sync_VDisp, 0},
71 {aHidd_Sync_HMax, 16384},
72 {aHidd_Sync_VMax, 16384},
73 {aHidd_Sync_Description, (IPTR)"VESA:%hx%v"},
74 {TAG_DONE, 0UL}
76 struct TagItem modetags[] =
78 {aHidd_Gfx_PixFmtTags, (IPTR)pftags},
79 {aHidd_Gfx_SyncTags, (IPTR)sync_mode},
80 {TAG_DONE, 0UL}
82 struct TagItem yourtags[] =
84 {aHidd_Gfx_ModeTags, (IPTR)modetags},
85 {TAG_MORE, 0UL}
87 struct pRoot_New yourmsg;
89 EnterFunc(bug("VESAGfx::New()\n"));
91 /* Protect against some stupid programmer wishing to
92 create one more VESA driver */
93 if (XSD(cl)->vesagfxhidd)
94 return NULL;
96 pftags[0].ti_Data = XSD(cl)->data.redshift;
97 pftags[1].ti_Data = XSD(cl)->data.greenshift;
98 pftags[2].ti_Data = XSD(cl)->data.blueshift;
99 pftags[4].ti_Data = XSD(cl)->data.redmask;
100 pftags[5].ti_Data = XSD(cl)->data.greenmask;
101 pftags[6].ti_Data = XSD(cl)->data.bluemask;
102 pftags[8].ti_Data = (XSD(cl)->data.depth > 8) ? vHidd_ColorModel_TrueColor : vHidd_ColorModel_Palette;
103 pftags[9].ti_Data = (XSD(cl)->data.depth > 24) ? 24 : XSD(cl)->data.depth;
104 pftags[10].ti_Data = XSD(cl)->data.bytesperpixel;
105 pftags[11].ti_Data = (XSD(cl)->data.bitsperpixel > 24) ? 24 : XSD(cl)->data.bitsperpixel;
106 pftags[14].ti_Data = (1 << XSD(cl)->data.depth) - 1;
108 sync_mode[0].ti_Data = XSD(cl)->data.width;
109 sync_mode[1].ti_Data = XSD(cl)->data.height;
111 yourtags[1].ti_Data = (IPTR)msg->attrList;
112 yourmsg.mID = msg->mID;
113 yourmsg.attrList = yourtags;
115 o = (OOP_Object *)OOP_DoSuperMethod(cl, o, (OOP_Msg)&yourmsg);
116 if (o)
118 struct VESAGfxHiddData *data = OOP_INST_DATA(cl, o);
120 D(bug("Got object from super\n"));
121 XSD(cl)->vesagfxhidd = o;
123 data->ResetInterrupt.is_Code = (VOID_FUNC)ResetHandler;
124 data->ResetInterrupt.is_Data = &XSD(cl)->data;
125 AddResetCallback(&data->ResetInterrupt);
127 ReturnPtr("VESAGfx::New", OOP_Object *, o);
130 VOID VESAGfx__Root__Dispose(OOP_Class *cl, OOP_Object *o, OOP_Msg msg)
132 struct VESAGfxHiddData *data = OOP_INST_DATA(cl, o);
134 RemResetCallback(&data->ResetInterrupt);
135 OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
136 XSD(cl)->vesagfxhidd = NULL;
139 VOID VESAGfx__Root__Get(OOP_Class *cl, OOP_Object *o, struct pRoot_Get *msg)
141 ULONG idx;
143 if (IS_GFX_ATTR(msg->attrID, idx))
145 switch (idx)
147 case aoHidd_Gfx_NoFrameBuffer:
148 *msg->storage = TRUE;
149 return;
152 OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
155 OOP_Object *VESAGfx__Hidd_Gfx__CreateObject(OOP_Class *cl, OOP_Object *o, struct pHidd_Gfx_CreateObject *msg)
157 OOP_Object *object = NULL;
159 D(bug("[VESA] %s()\n", __PRETTY_FUNCTION__));
160 D(bug("[VESA] %s: requested class 0x%p\n", __PRETTY_FUNCTION__, msg->cl));
161 D(bug("[VESA] %s: base bitmap class 0x%p\n", __PRETTY_FUNCTION__, XSD(cl)->basebm));
163 if (msg->cl == XSD(cl)->basebm)
165 BOOL displayable;
166 struct TagItem tags[2] =
168 {TAG_IGNORE, 0 },
169 {TAG_MORE , (IPTR)msg->attrList}
171 struct pHidd_Gfx_CreateObject p;
173 displayable = GetTagData(aHidd_BitMap_Displayable, FALSE, msg->attrList);
174 if (displayable)
176 /* Only displayable bitmaps are bitmaps of our class */
177 tags[0].ti_Tag = aHidd_BitMap_ClassPtr;
178 tags[0].ti_Data = (IPTR)XSD(cl)->bmclass;
180 else
182 /* Non-displayable friends of our bitmaps are plain chunky bitmaps */
183 OOP_Object *friend = (OOP_Object *)GetTagData(aHidd_BitMap_Friend, 0, msg->attrList);
185 if (friend && (OOP_OCLASS(friend) == XSD(cl)->bmclass))
187 tags[0].ti_Tag = aHidd_BitMap_ClassID;
188 tags[0].ti_Data = (IPTR)CLID_Hidd_ChunkyBM;
192 p.mID = msg->mID;
193 p.cl = msg->cl;
194 p.attrList = tags;
196 object = (OOP_Object *)OOP_DoSuperMethod(cl, o, (OOP_Msg)&p);
198 else
199 object = (OOP_Object *)OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
201 ReturnPtr("VESAGfx::CreateObject", OOP_Object *, object);
204 /********* GfxHidd::Show() ***************************/
206 OOP_Object *VESAGfx__Hidd_Gfx__Show(OOP_Class *cl, OOP_Object *o, struct pHidd_Gfx_Show *msg)
208 struct VESAGfx_staticdata *data = XSD(cl);
209 struct TagItem tags[] = {
210 {aHidd_BitMap_Visible, FALSE},
211 {TAG_DONE , 0 }
214 D(bug("[VESAGfx] Show(0x%p), old visible 0x%p\n", msg->bitMap, data->visible));
216 LOCK_FRAMEBUFFER(data);
218 /* Remove old bitmap from the screen */
219 if (data->visible)
221 D(bug("[VESAGfx] Hiding old bitmap\n"));
222 OOP_SetAttrs(data->visible, tags);
225 if (msg->bitMap)
227 /* If we have a bitmap to show, set it as visible */
228 D(bug("[VESAGfx] Showing new bitmap\n"));
229 tags[0].ti_Data = TRUE;
230 OOP_SetAttrs(msg->bitMap, tags);
232 else
234 D(bug("[VESAGfx] Blanking screen\n"));
235 /* Otherwise simply clear the framebuffer */
236 ClearBuffer(&data->data);
239 data->visible = msg->bitMap;
240 UNLOCK_FRAMEBUFFER(data);
242 D(bug("[VESAGfx] Show() done\n"));
243 return msg->bitMap;