2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
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>
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
37 extern int driver_init (struct GfxBase
*);
38 extern void driver_expunge (struct GfxBase
*);
40 AROS_INTP(TOF_VBlank
);
43 # define SYSFONTNAME "topaz.font"
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
)
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)))
89 NEWLIST(&PrivGBase(GfxBase
)->ChunkPoolList
);
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
;
106 sysTA
.ta_Style
= FS_NORMAL
;
109 def
= OpenFont (&sysTA
);
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 if (!GfxBase
->gb_LayersBase
)
133 GfxBase
->gb_LayersBase
= (ULONG
*)OpenLibrary("layers.library", 0);
138 ADD2INITLIB(GfxInit
, 0);
139 ADD2OPENLIB(GfxOpen
, 0);
143 AROS_INTH1(TOF_VBlank
, struct GfxBase
*, GfxBase
)
149 GfxBase
->VBCounter
++;
150 if(!IsListEmpty(&GfxBase
->TOF_WaitQ
))
152 ForeachNode(&GfxBase
->TOF_WaitQ
, tNode
)
154 Signal((struct Task
*)tNode
->ln_Name
, SIGF_SINGLE
);