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