2 Copyright © 1995-2015, The AROS Development Team. All rights reserved.
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>
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
35 extern int driver_init (struct GfxBase
*);
36 extern void driver_expunge (struct GfxBase
*);
38 AROS_INTP(TOF_VBlank
);
41 # define SYSFONTNAME "topaz.font"
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
)
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)))
90 NEWLIST(&PrivGBase(GfxBase
)->ChunkPoolList
);
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
;
107 sysTA
.ta_Style
= FS_NORMAL
;
110 def
= OpenFont (&sysTA
);
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;
136 ADD2INITLIB(GfxInit
, 0);
137 ADD2OPENLIB(GfxOpen
, 0);
141 AROS_INTH1(TOF_VBlank
, struct GfxBase
*, GfxBase
)
147 GfxBase
->VBCounter
++;
148 if(!IsListEmpty(&GfxBase
->TOF_WaitQ
))
150 ForeachNode(&GfxBase
->TOF_WaitQ
, tNode
)
152 Signal((struct Task
*)tNode
->ln_Name
, SIGF_SINGLE
);