- Now splits paragraphs into multiple lines, with each line fitting the
[AROS.git] / workbench / hidds / sm502 / sm502gfxclass.c
blob537b05152ff0125f9f82473612d43df2724bc412
1 /*
2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Class for SM502.
6 Lang: English.
7 */
9 #define __OOP_NOATTRBASES__
11 #include <aros/debug.h>
13 #include <aros/asmcall.h>
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>
28 #include "sm502gfxclass.h"
29 #include "bitmap.h"
30 #include "hardware.h"
32 #include LC_LIBDEFS_FILE
34 static AROS_INTH1(ResetHandler, struct SM502_HWData *, hwdata)
36 AROS_INTFUNC_INIT
38 ClearBuffer(hwdata);
40 return FALSE;
42 AROS_INTFUNC_EXIT
45 OOP_Object *SM502__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)"SM502:%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 /* Protect against some stupid programmer wishing to
90 create one more SM502 driver */
91 if (XSD(cl)->sm502gfxhidd)
92 return NULL;
94 pftags[0].ti_Data = XSD(cl)->data.redshift;
95 pftags[1].ti_Data = XSD(cl)->data.greenshift;
96 pftags[2].ti_Data = XSD(cl)->data.blueshift;
97 pftags[4].ti_Data = XSD(cl)->data.redmask;
98 pftags[5].ti_Data = XSD(cl)->data.greenmask;
99 pftags[6].ti_Data = XSD(cl)->data.bluemask;
100 pftags[8].ti_Data = (XSD(cl)->data.depth > 8) ? vHidd_ColorModel_TrueColor : vHidd_ColorModel_Palette;
101 pftags[9].ti_Data = (XSD(cl)->data.depth > 24) ? 24 : XSD(cl)->data.depth;
102 pftags[10].ti_Data = XSD(cl)->data.bytesperpixel;
103 pftags[11].ti_Data = (XSD(cl)->data.bitsperpixel > 24) ? 24 : XSD(cl)->data.bitsperpixel;
104 pftags[14].ti_Data = (1 << XSD(cl)->data.depth) - 1;
106 sync_mode[0].ti_Data = XSD(cl)->data.width;
107 sync_mode[1].ti_Data = XSD(cl)->data.height;
109 yourtags[1].ti_Data = (IPTR)msg->attrList;
110 yourmsg.mID = msg->mID;
111 yourmsg.attrList = yourtags;
112 msg = &yourmsg;
113 EnterFunc(bug("SM502Gfx::New()\n"));
114 o = (OOP_Object *)OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
115 if (o)
117 struct SM502Gfx_data *data = OOP_INST_DATA(cl, o);
119 D(bug("Got object from super\n"));
120 XSD(cl)->sm502gfxhidd = o;
122 data->ResetInterrupt.is_Code = (APTR)ResetHandler;
123 data->ResetInterrupt.is_Data = &XSD(cl)->data;
124 AddResetCallback(&data->ResetInterrupt);
126 ReturnPtr("SM502Gfx::New", OOP_Object *, o);
129 VOID SM502__Root__Dispose(OOP_Class *cl, OOP_Object *o, OOP_Msg msg)
131 struct SM502Gfx_data *data = OOP_INST_DATA(cl, o);
133 RemResetCallback(&data->ResetInterrupt);
134 OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
135 XSD(cl)->sm502gfxhidd = NULL;
138 VOID SM502__Root__Get(OOP_Class *cl, OOP_Object *o, struct pRoot_Get *msg)
140 ULONG idx;
142 if (IS_GFX_ATTR(msg->attrID, idx))
144 switch (idx)
146 case aoHidd_Gfx_NoFrameBuffer:
147 *msg->storage = TRUE;
148 return;
151 OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
154 OOP_Object *SM502__Hidd_Gfx__NewBitMap(OOP_Class *cl, OOP_Object *o, struct pHidd_Gfx_NewBitMap *msg)
156 BOOL displayable;
157 struct TagItem tags[2] =
159 {TAG_IGNORE, 0 },
160 {TAG_MORE , (IPTR)msg->attrList}
162 struct pHidd_Gfx_NewBitMap yourmsg;
164 EnterFunc(bug("SM502Gfx::NewBitMap()\n"));
166 displayable = GetTagData(aHidd_BitMap_Displayable, FALSE, msg->attrList);
167 if (displayable)
169 /* Only displayable bitmaps are bitmaps of our class */
170 tags[0].ti_Tag = aHidd_BitMap_ClassPtr;
171 tags[0].ti_Data = (IPTR)XSD(cl)->bmclass;
173 else
175 /* Non-displayable friends of our bitmaps are plain chunky bitmaps */
176 OOP_Object *friend = (OOP_Object *)GetTagData(aHidd_BitMap_Friend, 0, msg->attrList);
178 if (friend && (OOP_OCLASS(friend) == XSD(cl)->bmclass))
180 tags[0].ti_Tag = aHidd_BitMap_ClassID;
181 tags[0].ti_Data = (IPTR)CLID_Hidd_ChunkyBM;
185 yourmsg.mID = msg->mID;
186 yourmsg.attrList = tags;
188 ReturnPtr("SM502Gfx::NewBitMap", OOP_Object *, (OOP_Object *)OOP_DoSuperMethod(cl, o, &yourmsg.mID));
191 /********* GfxHidd::Show() ***************************/
193 OOP_Object *SM502__Hidd_Gfx__Show(OOP_Class *cl, OOP_Object *o, struct pHidd_Gfx_Show *msg)
195 struct SM502Gfx_staticdata *data = XSD(cl);
196 struct TagItem tags[] = {
197 {aHidd_BitMap_Visible, FALSE},
198 {TAG_DONE , 0 }
201 D(bug("[SM502Gfx] Show(0x%p), old visible 0x%p\n", msg->bitMap, data->visible));
203 LOCK_FRAMEBUFFER(data);
205 /* Remove old bitmap from the screen */
206 if (data->visible)
208 D(bug("[SM502Gfx] Hiding old bitmap\n"));
209 OOP_SetAttrs(data->visible, tags);
212 if (msg->bitMap)
214 /* If we have a bitmap to show, set it as visible */
215 D(bug("[SM502Gfx] Showing new bitmap\n"));
216 tags[0].ti_Data = TRUE;
217 OOP_SetAttrs(msg->bitMap, tags);
219 else
221 D(bug("[SM502Gfx] Blanking screen\n"));
222 /* Otherwise simply clear the framebuffer */
223 ClearBuffer(&data->data);
226 data->visible = msg->bitMap;
227 UNLOCK_FRAMEBUFFER(data);
229 D(bug("[SM502Gfx] Show() done\n"));
230 return msg->bitMap;