rename the directory
[AROS.git] / rom / hidds / vesa / vesagfxclass.c
blob9e4ff4fd48513a89e0bbb957035fa1538086e1a8
1 /*
2 Copyright © 1995-2015, 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/graphics.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 "vesagfxclass.h"
30 #include "bitmap.h"
31 #include "hardware.h"
33 #include LC_LIBDEFS_FILE
35 AROS_INTH1(ResetHandler, struct HWData *, hwdata)
37 AROS_INTFUNC_INIT
39 ClearBuffer(hwdata);
41 return FALSE;
43 AROS_INTFUNC_EXIT
46 OOP_Object *PCVesa__Root__New(OOP_Class *cl, OOP_Object *o, struct pRoot_New *msg)
48 struct TagItem pftags[] =
50 {aHidd_PixFmt_RedShift, 0}, /* 0 */
51 {aHidd_PixFmt_GreenShift, 0}, /* 1 */
52 {aHidd_PixFmt_BlueShift, 0}, /* 2 */
53 {aHidd_PixFmt_AlphaShift, 0}, /* 3 */
54 {aHidd_PixFmt_RedMask, 0}, /* 4 */
55 {aHidd_PixFmt_GreenMask, 0}, /* 5 */
56 {aHidd_PixFmt_BlueMask, 0}, /* 6 */
57 {aHidd_PixFmt_AlphaMask, 0}, /* 7 */
58 {aHidd_PixFmt_ColorModel, 0}, /* 8 */
59 {aHidd_PixFmt_Depth, 0}, /* 9 */
60 {aHidd_PixFmt_BytesPerPixel,0}, /* 10 */
61 {aHidd_PixFmt_BitsPerPixel, 0}, /* 11 */
62 {aHidd_PixFmt_StdPixFmt, vHidd_StdPixFmt_Native}, /* 12 */
63 {aHidd_PixFmt_CLUTShift, 0}, /* 13 */
64 {aHidd_PixFmt_CLUTMask, 0}, /* 14 */
65 {aHidd_PixFmt_BitMapType, vHidd_BitMapType_Chunky}, /* 15 */
66 {TAG_DONE, 0UL }
68 struct TagItem sync_mode[] =
70 {aHidd_Sync_HDisp, 0},
71 {aHidd_Sync_VDisp, 0},
72 {aHidd_Sync_HMax, 16384},
73 {aHidd_Sync_VMax, 16384},
74 {aHidd_Sync_Description, (IPTR)"VESA:%hx%v"},
75 {TAG_DONE, 0UL}
77 struct TagItem modetags[] =
79 {aHidd_Gfx_PixFmtTags, (IPTR)pftags},
80 {aHidd_Gfx_SyncTags, (IPTR)sync_mode},
81 {TAG_DONE, 0UL}
83 struct TagItem yourtags[] =
85 {aHidd_Gfx_ModeTags, (IPTR)modetags},
86 {TAG_MORE, 0UL}
88 struct pRoot_New yourmsg;
90 EnterFunc(bug("VesaGfx::New()\n"));
92 /* Protect against some stupid programmer wishing to
93 create one more VESA driver */
94 if (XSD(cl)->vesagfxhidd)
95 return NULL;
97 pftags[0].ti_Data = XSD(cl)->data.redshift;
98 pftags[1].ti_Data = XSD(cl)->data.greenshift;
99 pftags[2].ti_Data = XSD(cl)->data.blueshift;
100 pftags[4].ti_Data = XSD(cl)->data.redmask;
101 pftags[5].ti_Data = XSD(cl)->data.greenmask;
102 pftags[6].ti_Data = XSD(cl)->data.bluemask;
103 pftags[8].ti_Data = (XSD(cl)->data.depth > 8) ? vHidd_ColorModel_TrueColor : vHidd_ColorModel_Palette;
104 pftags[9].ti_Data = (XSD(cl)->data.depth > 24) ? 24 : XSD(cl)->data.depth;
105 pftags[10].ti_Data = XSD(cl)->data.bytesperpixel;
106 pftags[11].ti_Data = (XSD(cl)->data.bitsperpixel > 24) ? 24 : XSD(cl)->data.bitsperpixel;
107 pftags[14].ti_Data = (1 << XSD(cl)->data.depth) - 1;
109 sync_mode[0].ti_Data = XSD(cl)->data.width;
110 sync_mode[1].ti_Data = XSD(cl)->data.height;
112 yourtags[1].ti_Data = (IPTR)msg->attrList;
113 yourmsg.mID = msg->mID;
114 yourmsg.attrList = yourtags;
116 o = (OOP_Object *)OOP_DoSuperMethod(cl, o, (OOP_Msg)&yourmsg);
117 if (o)
119 struct VesaGfx_data *data = OOP_INST_DATA(cl, o);
121 D(bug("Got object from super\n"));
122 XSD(cl)->vesagfxhidd = o;
124 data->ResetInterrupt.is_Code = (VOID_FUNC)ResetHandler;
125 data->ResetInterrupt.is_Data = &XSD(cl)->data;
126 AddResetCallback(&data->ResetInterrupt);
128 ReturnPtr("VesaGfx::New", OOP_Object *, o);
131 VOID PCVesa__Root__Dispose(OOP_Class *cl, OOP_Object *o, OOP_Msg msg)
133 struct VesaGfx_data *data = OOP_INST_DATA(cl, o);
135 RemResetCallback(&data->ResetInterrupt);
136 OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
137 XSD(cl)->vesagfxhidd = NULL;
140 VOID PCVesa__Root__Get(OOP_Class *cl, OOP_Object *o, struct pRoot_Get *msg)
142 ULONG idx;
144 if (IS_GFX_ATTR(msg->attrID, idx))
146 switch (idx)
148 case aoHidd_Gfx_NoFrameBuffer:
149 *msg->storage = TRUE;
150 return;
153 OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
156 OOP_Object *PCVesa__Hidd_Gfx__CreateObject(OOP_Class *cl, OOP_Object *o, struct pHidd_Gfx_CreateObject *msg)
158 OOP_Object *object = NULL;
160 D(bug("[VESA] %s()\n", __PRETTY_FUNCTION__));
161 D(bug("[VESA] %s: requested class 0x%p\n", __PRETTY_FUNCTION__, msg->cl));
162 D(bug("[VESA] %s: base bitmap class 0x%p\n", __PRETTY_FUNCTION__, XSD(cl)->basebm));
164 if (msg->cl == XSD(cl)->basebm)
166 BOOL displayable;
167 struct TagItem tags[2] =
169 {TAG_IGNORE, 0 },
170 {TAG_MORE , (IPTR)msg->attrList}
172 struct pHidd_Gfx_CreateObject p;
174 displayable = GetTagData(aHidd_BitMap_Displayable, FALSE, msg->attrList);
175 if (displayable)
177 /* Only displayable bitmaps are bitmaps of our class */
178 tags[0].ti_Tag = aHidd_BitMap_ClassPtr;
179 tags[0].ti_Data = (IPTR)XSD(cl)->bmclass;
181 else
183 /* Non-displayable friends of our bitmaps are plain chunky bitmaps */
184 OOP_Object *friend = (OOP_Object *)GetTagData(aHidd_BitMap_Friend, 0, msg->attrList);
186 if (friend && (OOP_OCLASS(friend) == XSD(cl)->bmclass))
188 tags[0].ti_Tag = aHidd_BitMap_ClassID;
189 tags[0].ti_Data = (IPTR)CLID_Hidd_ChunkyBM;
193 p.mID = msg->mID;
194 p.cl = msg->cl;
195 p.attrList = tags;
197 object = (OOP_Object *)OOP_DoSuperMethod(cl, o, (OOP_Msg)&p);
199 else
200 object = (OOP_Object *)OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
202 ReturnPtr("VesaGfx::CreateObject", OOP_Object *, object);
205 /********* GfxHidd::Show() ***************************/
207 OOP_Object *PCVesa__Hidd_Gfx__Show(OOP_Class *cl, OOP_Object *o, struct pHidd_Gfx_Show *msg)
209 struct VesaGfx_staticdata *data = XSD(cl);
210 struct TagItem tags[] = {
211 {aHidd_BitMap_Visible, FALSE},
212 {TAG_DONE , 0 }
215 D(bug("[VesaGfx] Show(0x%p), old visible 0x%p\n", msg->bitMap, data->visible));
217 LOCK_FRAMEBUFFER(data);
219 /* Remove old bitmap from the screen */
220 if (data->visible)
222 D(bug("[VesaGfx] Hiding old bitmap\n"));
223 OOP_SetAttrs(data->visible, tags);
226 if (msg->bitMap)
228 /* If we have a bitmap to show, set it as visible */
229 D(bug("[VesaGfx] Showing new bitmap\n"));
230 tags[0].ti_Data = TRUE;
231 OOP_SetAttrs(msg->bitMap, tags);
233 else
235 D(bug("[VesaGfx] Blanking screen\n"));
236 /* Otherwise simply clear the framebuffer */
237 ClearBuffer(&data->data);
240 data->visible = msg->bitMap;
241 UNLOCK_FRAMEBUFFER(data);
243 D(bug("[VesaGfx] Show() done\n"));
244 return msg->bitMap;