Documented GVF_SAVE_VAR alongside other flags, and removed a query/doubt
[AROS.git] / rom / graphics / graphics_init.c
blobffaf1d6d7911d40c561183ee6e651c69535ab341
1 /*
2 Copyright © 1995-2015, 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_NOMINAL_WIDTH;
74 LIBBASE->NormalDisplayRows = AROS_NOMINAL_HEIGHT;
75 LIBBASE->MaxDisplayColumn = AROS_NOMINAL_WIDTH;
76 LIBBASE->MaxDisplayRow = AROS_NOMINAL_HEIGHT;
78 PrivGBase(LIBBASE)->basebm = OOP_FindClass(CLID_Hidd_BitMap);
79 D(bug("[Gfx] BitMap class @ 0x%p\n", PrivGBase(LIBBASE)->basebm));
81 #if REGIONS_USE_MEMPOOL
82 InitSemaphore( &PrivGBase(GfxBase)->regionsem );
83 if (!(PrivGBase(GfxBase)->regionpool = CreatePool(MEMF_PUBLIC | MEMF_CLEAR,
84 sizeof(struct Region) * 20,
85 sizeof(struct Region) * 20)))
87 return FALSE;
90 NEWLIST(&PrivGBase(GfxBase)->ChunkPoolList);
91 #endif
93 if (!InitROMFont(LIBBASE)) return FALSE;
95 return driver_init (LIBBASE);
98 static int GfxOpen(struct GfxBase *LIBBASE)
100 struct TextFont * def;
102 if (!LIBBASE->DefaultFont)
104 struct TextAttr sysTA;
105 sysTA.ta_Name = (STRPTR)SYSFONTNAME;
106 sysTA.ta_YSize = 8;
107 sysTA.ta_Style = FS_NORMAL;
108 sysTA.ta_Flags = 0;
110 def = OpenFont (&sysTA);
112 if (!def)
113 return 0;
115 LIBBASE->DefaultFont = def;
116 sysTA.ta_YSize = def->tf_YSize;
119 if(! LIBBASE->VBlank)
121 NEWLIST(&LIBBASE->TOF_WaitQ);
122 LIBBASE->vbsrv.is_Code = (VOID_FUNC)TOF_VBlank;
123 LIBBASE->vbsrv.is_Data = LIBBASE;
124 LIBBASE->vbsrv.is_Node.ln_Name = "Graphics TOF server";
125 LIBBASE->vbsrv.is_Node.ln_Pri = 10;
126 LIBBASE->vbsrv.is_Node.ln_Type = NT_INTERRUPT;
128 /* Add a VBLANK server to take care of TOF waiting tasks. */
129 AddIntServer(INTB_VERTB, &LIBBASE->vbsrv);
130 LIBBASE->VBlank = 50;
133 return TRUE;
136 ADD2INITLIB(GfxInit, 0);
137 ADD2OPENLIB(GfxOpen, 0);
139 #undef SysBase
141 AROS_INTH1(TOF_VBlank, struct GfxBase *, GfxBase)
143 AROS_INTFUNC_INIT
145 struct Node *tNode;
147 GfxBase->VBCounter++;
148 if(!IsListEmpty(&GfxBase->TOF_WaitQ))
150 ForeachNode(&GfxBase->TOF_WaitQ, tNode)
152 Signal((struct Task *)tNode->ln_Name, SIGF_SINGLE);
156 return 0;
158 AROS_INTFUNC_EXIT