disable debug
[AROS.git] / workbench / libs / cgfx / cybergraphics_init.c
blob4b0958ae6de3cb64365a4cf3fe6c72de6aa06553
1 /*
2 Copyright © 1995-2017, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <aros/debug.h>
7 #include <aros/symbolsets.h>
8 #include <hidd/gfx.h>
9 #include <proto/oop.h>
11 #include "cybergraphics_intern.h"
13 static void ReleaseAttrBases(struct IntCGFXBase *CyberGfxBase)
15 if (__IHidd_BitMap)
16 OOP_ReleaseAttrBase(IID_Hidd_BitMap);
17 if (__IHidd_GC)
18 OOP_ReleaseAttrBase(IID_Hidd_GC);
19 if (__IHidd_Sync)
20 OOP_ReleaseAttrBase(IID_Hidd_Sync);
21 if (__IHidd_PixFmt)
22 OOP_ReleaseAttrBase(IID_Hidd_PixFmt);
23 if (__IHidd_Gfx)
24 OOP_ReleaseAttrBase(IID_Hidd_Gfx);
27 static int cgfx_init(struct IntCGFXBase *CyberGfxBase)
29 EnterFunc(bug("[CGX] cgfx_init()\n"));
31 /* Initialize the semaphore used for the chunky buffer */
32 InitSemaphore(&CyberGfxBase->pixbuf_sema);
34 /* Init the needed attrbases */
36 __IHidd_BitMap = OOP_ObtainAttrBase(IID_Hidd_BitMap);
37 __IHidd_GC = OOP_ObtainAttrBase(IID_Hidd_GC);
38 __IHidd_Sync = OOP_ObtainAttrBase(IID_Hidd_Sync);
39 __IHidd_PixFmt = OOP_ObtainAttrBase(IID_Hidd_PixFmt);
40 __IHidd_Gfx = OOP_ObtainAttrBase(IID_Hidd_Gfx);
42 CyberGfxBase->basegc = OOP_FindClass(CLID_Hidd_GC);
43 CyberGfxBase->basebm = OOP_FindClass(CLID_Hidd_BitMap);
45 if (__IHidd_BitMap &&
46 __IHidd_GC &&
47 __IHidd_Sync &&
48 __IHidd_PixFmt &&
49 __IHidd_Gfx)
51 CyberGfxBase->pixel_buf=AllocMem(PIXELBUF_SIZE,MEMF_ANY);
52 if (CyberGfxBase->pixel_buf)
54 WORD i;
56 for (i = 0; i < 256; i++)
58 CyberGfxBase->greytab[i] = i * 0x010101;
61 ReturnInt("[CGX] cgfx_init", int, TRUE);
66 ReleaseAttrBases(CyberGfxBase);
67 ReturnInt("[CGX] cgfx_init", int, FALSE);
70 static int cgfx_expunge (struct IntCGFXBase *CyberGfxBase)
72 FreeMem(CyberGfxBase->pixel_buf, PIXELBUF_SIZE);
73 ReleaseAttrBases(CyberGfxBase);
75 return TRUE;
78 ADD2INITLIB(cgfx_init, 0);
79 ADD2EXPUNGELIB(cgfx_expunge, 0);