Minor fixes to comments.
[AROS.git] / rom / graphics / graphics_init.c
blob3cb6831c67a2bcffeed95b31085eec3a2560544e
1 /*
2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Graphics library
6 Lang: english
7 */
9 #define DEBUG 0
11 #include <aros/debug.h>
13 #include <exec/resident.h>
14 #include <proto/exec.h>
15 #include <aros/libcall.h>
16 #include <aros/symbolsets.h>
17 #include <aros/config.h>
18 #include <hardware/intbits.h>
19 #include <dos/dos.h>
20 #include <exec/execbase.h>
21 #include <exec/memory.h>
22 #include <exec/lists.h>
23 #include <graphics/gfxbase.h>
24 #include <graphics/text.h>
25 #include <graphics/regions.h>
26 #include <proto/graphics.h>
27 #include <utility/utility.h>
29 #include "graphics_intern.h"
30 #include "default_font.h"
31 #include "fakegfxhidd.h"
33 #include LC_LIBDEFS_FILE
35 #include <stdio.h>
37 extern int driver_init (struct GfxBase *);
38 extern void driver_expunge (struct GfxBase *);
40 AROS_INTP(TOF_VBlank);
42 #ifndef SYSFONTNAME
43 # define SYSFONTNAME "topaz.font"
44 #endif
46 BOOL InitROMFont(struct GfxBase *);
48 static int GfxInit(struct GfxBase *LIBBASE)
50 HiddBitMapBase = OOP_GetMethodID(IID_Hidd_BitMap, 0);
51 HiddColorMapBase = OOP_GetMethodID(IID_Hidd_ColorMap, 0);
52 HiddGfxBase = OOP_GetMethodID(IID_Hidd_Gfx, 0);
53 HiddGCBase = OOP_GetMethodID(IID_Hidd_GC, 0);
54 HiddPlanarBMBase = OOP_GetMethodID(IID_Hidd_PlanarBM, 0);
56 NEWLIST(&LIBBASE->BlitWaitQ);
57 NEWLIST(&LIBBASE->TextFonts);
58 InitSemaphore( &PrivGBase(GfxBase)->hashtab_sema );
59 InitSemaphore( &PrivGBase(GfxBase)->view_sema );
60 InitSemaphore( &PrivGBase(GfxBase)->tfe_hashtab_sema );
61 InitSemaphore( &PrivGBase(GfxBase)->fontsem );
63 NEWLIST(&LIBBASE->MonitorList);
64 LIBBASE->MonitorList.lh_Type = MONITOR_SPEC_TYPE;
65 GfxBase->MonitorListSemaphore = &PrivGBase(GfxBase)->monitors_sema;
66 InitSemaphore(GfxBase->MonitorListSemaphore);
68 LIBBASE->hash_table = AllocMem(GFXASSOCIATE_HASHSIZE * sizeof(APTR), MEMF_CLEAR|MEMF_PUBLIC);
69 if (!LIBBASE->hash_table)
70 return FALSE;
72 LIBBASE->HashTableSemaphore = &PrivGBase(GfxBase)->hashtab_sema;
73 LIBBASE->ActiViewCprSemaphore = &PrivGBase(GfxBase)->view_sema;
75 LIBBASE->NormalDisplayColumns = AROS_DEFAULT_WBWIDTH;
76 LIBBASE->NormalDisplayRows = AROS_DEFAULT_WBHEIGHT;
77 LIBBASE->MaxDisplayColumn = AROS_DEFAULT_WBWIDTH;
78 LIBBASE->MaxDisplayRow = AROS_DEFAULT_WBHEIGHT;
80 #if REGIONS_USE_MEMPOOL
81 InitSemaphore( &PrivGBase(GfxBase)->regionsem );
82 if (!(PrivGBase(GfxBase)->regionpool = CreatePool(MEMF_PUBLIC | MEMF_CLEAR,
83 sizeof(struct Region) * 20,
84 sizeof(struct Region) * 20)))
86 return FALSE;
89 NEWLIST(&PrivGBase(GfxBase)->ChunkPoolList);
90 #endif
92 if (!InitROMFont(LIBBASE)) return FALSE;
94 return driver_init (LIBBASE);
97 static int GfxOpen(struct GfxBase *LIBBASE)
99 struct TextFont * def;
101 if (!LIBBASE->DefaultFont)
103 struct TextAttr sysTA;
104 sysTA.ta_Name = (STRPTR)SYSFONTNAME;
105 sysTA.ta_YSize = 8;
106 sysTA.ta_Style = FS_NORMAL;
107 sysTA.ta_Flags = 0;
109 def = OpenFont (&sysTA);
111 if (!def)
112 return 0;
114 LIBBASE->DefaultFont = def;
115 sysTA.ta_YSize = def->tf_YSize;
118 if(! LIBBASE->VBlank)
120 NEWLIST(&LIBBASE->TOF_WaitQ);
121 LIBBASE->vbsrv.is_Code = (VOID_FUNC)TOF_VBlank;
122 LIBBASE->vbsrv.is_Data = LIBBASE;
123 LIBBASE->vbsrv.is_Node.ln_Name = "Graphics TOF server";
124 LIBBASE->vbsrv.is_Node.ln_Pri = 10;
125 LIBBASE->vbsrv.is_Node.ln_Type = NT_INTERRUPT;
127 /* Add a VBLANK server to take care of TOF waiting tasks. */
128 AddIntServer(INTB_VERTB, &LIBBASE->vbsrv);
129 LIBBASE->VBlank = 50;
132 return TRUE;
135 ADD2INITLIB(GfxInit, 0);
136 ADD2OPENLIB(GfxOpen, 0);
138 #undef SysBase
140 AROS_INTH1(TOF_VBlank, struct GfxBase *, GfxBase)
142 AROS_INTFUNC_INIT
144 struct Node *tNode;
146 GfxBase->VBCounter++;
147 if(!IsListEmpty(&GfxBase->TOF_WaitQ))
149 ForeachNode(&GfxBase->TOF_WaitQ, tNode)
151 Signal((struct Task *)tNode->ln_Name, SIGF_SINGLE);
155 return 0;
157 AROS_INTFUNC_EXIT