add place-holder directory for the a3000 wd533c93 scsi controller implementation.
[AROS.git] / arch / .unmaintained / m68k-pp-native / Drivers / display.hidd / onbitmap.c
blobe97131b57856c9d87e13d23b104f6e7f9ca8c8e2
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Bitmap class for Display hidd.
6 Lang: English.
7 */
10 #include <proto/oop.h>
11 #include <proto/utility.h>
13 #include <exec/memory.h>
14 #include <exec/lists.h>
16 #include <graphics/rastport.h>
17 #include <graphics/gfx.h>
18 #include <oop/oop.h>
20 #include <hidd/graphics.h>
22 #include "displayhw.h"
23 #include "display.h"
24 #include "displayclass.h"
26 #include "bitmap.h"
27 #include "assert.h"
29 /* Don't initialize static variables with "=0", otherwise they go into DATA segment */
31 #if 0
32 static OOP_AttrBase HiddBitMapAttrBase;
33 static OOP_AttrBase HiddPixFmtAttrBase;
34 static OOP_AttrBase HiddGfxAttrBase;
35 static OOP_AttrBase HiddSyncAttrBase;
36 static OOP_AttrBase HiddDisplayGfxAB;
37 static OOP_AttrBase HiddDisplayBitMapAB;
39 static struct OOP_ABDescr attrbases[] =
41 { IID_Hidd_BitMap, &HiddBitMapAttrBase },
42 { IID_Hidd_PixFmt, &HiddPixFmtAttrBase },
43 { IID_Hidd_Gfx, &HiddGfxAttrBase },
44 { IID_Hidd_Sync, &HiddSyncAttrBase },
45 /* Private bases */
46 { IID_Hidd_Displaygfx, &HiddDisplayGfxAB },
47 { IID_Hidd_DisplayBitMap, &HiddDisplayBitMapAB },
48 { NULL, NULL }
50 #endif
52 void DisplayRestore(struct DisplayHWRec *, BOOL onlyDAC);
53 void * DisplaySave(struct DisplayHWRec *);
54 int DisplayInitMode(struct DisplayModeDesc *, struct DisplayHWRec *);
55 void DisplayLoadPalette(struct DisplayHWRec *, unsigned char *);
57 void free_onbmclass(struct display_staticdata *);
59 #define MNAME(x) onbitmap_ ## x
61 #define SDEBUG 0
62 #define DEBUG 0
63 #include <aros/debug.h>
65 #define OnBitmap 1
66 #include "bitmap_common.c"
68 #if 0
70 void clr();
71 void scr_RawPutChars(char *, int);
73 char tab[127];
75 #define rkprintf(x...) scr_RawPutChars(tab, sprintf(tab, x))
77 #else
79 #define clr() /* eps */
80 #ifdef rkprintf
81 #undef rkprintf
82 #endif
83 #define rkprintf(x...) /* eps */
85 #endif
87 /*********** BitMap::New() *************************************/
89 static OOP_Object *onbitmap_new(OOP_Class *cl, OOP_Object *o, struct pRoot_New *msg)
91 EnterFunc(bug("DisplayGfx.BitMap::New()\n"));
93 o = (OOP_Object *)OOP_DoSuperMethod(cl, o, (OOP_Msg) msg);
94 if (o)
96 struct bitmap_data *data;
98 OOP_Object *pf;
100 IPTR width, height, depth;
102 data = OOP_INST_DATA(cl, o);
104 /* clear all data */
105 memset(data, 0, sizeof(struct bitmap_data));
106 #define xsd XSD(cl)
107 /* Get attr values */
108 OOP_GetAttr(o, aHidd_BitMap_Width, &width);
109 OOP_GetAttr(o, aHidd_BitMap_Height, &height);
110 OOP_GetAttr(o, aHidd_BitMap_PixFmt, (IPTR *)&pf);
111 OOP_GetAttr(pf, aHidd_PixFmt_Depth, &depth);
112 #undef xsd
113 // assert (width != 0 && height != 0 && depth != 0);
116 We must only create depths that are supported by the friend drawable
117 Currently we only support the default depth
120 width=(width+15) & ~15;
122 data->width = width;
123 data->height = height;
124 data->bpp = depth;
125 data->Regs = AllocVec(sizeof(struct DisplayHWRec),MEMF_PUBLIC|MEMF_CLEAR);
126 data->disp = -1;
129 Here there is brand new method of getting pixelclock data.
130 It was introduced here to make the code more portable. Besides
131 it may now be used as a base for creating other low level
132 video drivers
135 if (data->Regs)
137 data->VideoData = AllocVec(width*height,MEMF_PUBLIC|MEMF_CLEAR);
139 if (data->VideoData)
141 struct DisplayModeDesc mode;
142 HIDDT_ModeID modeid;
143 OOP_Object *sync;
144 OOP_Object *pf;
145 ULONG pixelc;
147 /* We should be able to get modeID from the bitmap */
148 #define xsd XSD(cl)
149 OOP_GetAttr(o, aHidd_BitMap_ModeID, &modeid);
150 #undef xsd
151 if (modeid != vHidd_ModeID_Invalid)
153 struct Box box = {0, 0, width-1, height-1};
155 /* Get Sync and PixelFormat properties */
156 HIDD_Gfx_GetMode(XSD(cl)->displayhidd, modeid, &sync, &pf);
158 mode.Width = width;
159 mode.Height = height;
160 mode.Depth = depth;
161 #define xsd XSD(cl)
162 OOP_GetAttr(sync, aHidd_Sync_PixelClock, &pixelc);
164 mode.clock = (pixelc > 26000000) ? 1 : 0;
165 mode.Flags = 0;
166 mode.HSkew = 0;
168 OOP_GetAttr(sync, aHidd_Sync_HDisp, &mode.HDisplay);
169 OOP_GetAttr(sync, aHidd_Sync_VDisp, &mode.VDisplay);
170 OOP_GetAttr(sync, aHidd_Sync_HSyncStart, &mode.HSyncStart);
171 OOP_GetAttr(sync, aHidd_Sync_VSyncStart, &mode.VSyncStart);
174 OOP_GetAttr(sync, aHidd_Sync_HSyncEnd, &mode.HSyncEnd);
175 OOP_GetAttr(sync, aHidd_Sync_VSyncEnd, &mode.VSyncEnd);
177 OOP_GetAttr(sync, aHidd_Sync_HTotal, &mode.HTotal);
178 OOP_GetAttr(sync, aHidd_Sync_VTotal, &mode.VTotal);
181 #undef xsd
182 ObtainSemaphore(&XSD(cl)->HW_acc);
184 /* Now, when the best display mode is chosen, we can build it */
185 DisplayInitMode(&mode, (struct DisplayHWRec *)data->Regs);
186 DisplayLoadPalette((struct DisplayHWRec *)data->Regs,(unsigned char *)NULL);
189 Because of not defined BitMap_Show method show
190 bitmap immediately
193 DisplayRestore((struct DisplayHWRec *)data->Regs, FALSE);
194 DisplayRefreshArea(data, 1, &box);
196 ReleaseSemaphore(&XSD(cl)->HW_acc);
198 XSD(cl)->visible = data; /* Set created object as visible */
200 return o;
202 // ReturnPtr("DisplayGfx.BitMap::New()", Object *, o);
205 } /* if got data->VideoData */
207 FreeVec(data->Regs);
208 } /* if got data->Regs */
211 OOP_MethodID disp_mid = OOP_GetMethodID(IID_Root, moRoot_Dispose);
212 OOP_CoerceMethod(cl, o, (OOP_Msg) &disp_mid);
215 o = NULL;
216 } /* if created object */
218 ReturnPtr("DisplayGfx.BitMap::New()", OOP_Object *, o);
221 /********** Bitmap::Dispose() ***********************************/
223 static VOID onbitmap_dispose(OOP_Class *cl, OOP_Object *o, OOP_Msg msg)
225 struct bitmap_data *data = OOP_INST_DATA(cl, o);
226 EnterFunc(bug("DisplayGfx.BitMap::Dispose()\n"));
228 if (data->VideoData)
229 FreeVec(data->VideoData);
230 if (data->Regs)
231 FreeVec(data->Regs);
233 OOP_DoSuperMethod(cl, o, msg);
235 ReturnVoid("DisplayGfx.BitMap::Dispose");
238 /*** init_onbmclass *********************************************************/
240 #undef XSD
241 #define XSD(cl) xsd
243 #define NUM_ROOT_METHODS 3
244 #define NUM_BITMAP_METHODS 10
246 OOP_Class *init_onbmclass(struct display_staticdata *xsd)
248 struct OOP_MethodDescr root_descr[NUM_ROOT_METHODS + 1] =
250 {(IPTR (*)())MNAME(new) , moRoot_New },
251 {(IPTR (*)())MNAME(dispose), moRoot_Dispose},
252 #if 0
253 {(IPTR (*)())MNAME(set) , moRoot_Set},
254 #endif
255 {(IPTR (*)())MNAME(get) , moRoot_Get},
256 {NULL, 0UL}
259 struct OOP_MethodDescr bitMap_descr[NUM_BITMAP_METHODS + 1] =
261 {(IPTR (*)())MNAME(setcolors), moHidd_BitMap_SetColors},
262 {(IPTR (*)())MNAME(putpixel), moHidd_BitMap_PutPixel},
263 {(IPTR (*)())MNAME(clear), moHidd_BitMap_Clear},
264 {(IPTR (*)())MNAME(getpixel), moHidd_BitMap_GetPixel},
265 /* {(IPTR (*)())MNAME(drawpixel), moHidd_BitMap_DrawPixel},*/
266 {(IPTR (*)())MNAME(fillrect), moHidd_BitMap_FillRect},
267 {(IPTR (*)())MNAME(getimage), moHidd_BitMap_GetImage},
268 {(IPTR (*)())MNAME(putimage), moHidd_BitMap_PutImage},
269 {(IPTR (*)())MNAME(blitcolorexpansion), moHidd_BitMap_BlitColorExpansion},
270 {(IPTR (*)())MNAME(putimagelut), moHidd_BitMap_PutImageLUT},
271 {(IPTR (*)())MNAME(getimagelut), moHidd_BitMap_GetImageLUT},
272 {NULL, 0UL}
275 struct OOP_InterfaceDescr ifdescr[] =
277 {root_descr, IID_Root , NUM_ROOT_METHODS},
278 {bitMap_descr, IID_Hidd_BitMap, NUM_BITMAP_METHODS},
279 {NULL, NULL, 0}
282 OOP_AttrBase MetaAttrBase = OOP_ObtainAttrBase(IID_Meta);
284 struct TagItem tags[] =
286 {aMeta_SuperID, (IPTR) CLID_Hidd_BitMap},
287 {aMeta_InterfaceDescr, (IPTR) ifdescr},
288 {aMeta_InstSize, (IPTR) sizeof(struct bitmap_data)},
289 {TAG_DONE, 0UL}
292 OOP_Class *cl = NULL;
294 EnterFunc(bug("init_bitmapclass(xsd=%p)\n", xsd));
296 D(bug("Metattrbase: %x\n", MetaAttrBase));
298 if(MetaAttrBase)
300 D(bug("Got attrbase\n"));
302 cl = OOP_NewObject(NULL, CLID_HiddMeta, tags);
303 if(cl)
305 D(bug("BitMap class ok\n"));
306 xsd->onbmclass = cl;
307 cl->UserData = (APTR) xsd;
309 __IHidd_BitMap = OOP_ObtainAttrBase(IID_Hidd_BitMap);
310 __IHidd_PixFmt = OOP_ObtainAttrBase(IID_Hidd_PixFmt);
311 __IHidd_Gfx = OOP_ObtainAttrBase(IID_Hidd_Gfx);
312 __IHidd_Sync = OOP_ObtainAttrBase(IID_Hidd_Sync);
313 __IHidd_DisplayGfx = OOP_ObtainAttrBase(IID_Hidd_Displaygfx);
314 __IHidd_DisplayBitMap = OOP_ObtainAttrBase(IID_Hidd_DisplayBitMap);
316 /* Get attrbase for the BitMap interface */
317 if (NULL != __IHidd_BitMap &&
318 NULL != __IHidd_PixFmt &&
319 NULL != __IHidd_Gfx &&
320 NULL != __IHidd_Sync &&
321 NULL != __IHidd_DisplayGfx &&
322 NULL != __IHidd_DisplayBitMap)
324 OOP_AddClass(cl);
326 else
328 free_onbmclass( xsd );
329 cl = NULL;
333 /* We don't need this anymore */
334 OOP_ReleaseAttrBase(IID_Meta);
335 } /* if(MetaAttrBase) */
337 ReturnPtr("init_onbmclass", OOP_Class *, cl);
340 /*** free_bitmapclass *********************************************************/
342 void free_onbmclass(struct display_staticdata *xsd)
344 EnterFunc(bug("free_onbmclass(xsd=%p)\n", xsd));
346 if(xsd)
348 OOP_RemoveClass(xsd->onbmclass);
349 if(xsd->onbmclass) OOP_DisposeObject((OOP_Object *) xsd->onbmclass);
350 xsd->onbmclass = NULL;
352 #warning Change this!
353 if (NULL != __IHidd_BitMap)
354 OOP_ReleaseAttrBase(IID_Hidd_BitMap);
355 if (NULL != __IHidd_PixFmt)
356 OOP_ReleaseAttrBase(IID_Hidd_PixFmt);
357 if (NULL != __IHidd_Gfx)
358 OOP_ReleaseAttrBase(IID_Hidd_Gfx);
359 if (NULL != __IHidd_Sync)
360 OOP_ReleaseAttrBase(IID_Hidd_Sync);
361 if (NULL != __IHidd_DisplayGfx)
362 OOP_ReleaseAttrBase(IID_Hidd_Displaygfx);
363 if (NULL != __IHidd_DisplayBitMap)
364 OOP_ReleaseAttrBase(IID_Hidd_DisplayBitMap);
367 ReturnVoid("free_onbmclass");