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 D(bug("[graphics.library] %s()\n", __func__
));
50 HWBase
= OOP_GetMethodID(IID_HW
, 0);
51 HiddBitMapBase
= OOP_GetMethodID(IID_Hidd_BitMap
, 0);
52 HiddColorMapBase
= OOP_GetMethodID(IID_Hidd_ColorMap
, 0);
53 HiddGfxBase
= OOP_GetMethodID(IID_Hidd_Gfx
, 0);
54 HiddGCBase
= OOP_GetMethodID(IID_Hidd_GC
, 0);
55 HiddPlanarBMBase
= OOP_GetMethodID(IID_Hidd_PlanarBM
, 0);
57 D(bug("[graphics.library] %s: obtained method bases\n", __func__
));
59 NEWLIST(&LIBBASE
->BlitWaitQ
);
60 NEWLIST(&LIBBASE
->TextFonts
);
61 InitSemaphore( &PrivGBase(GfxBase
)->hashtab_sema
);
62 InitSemaphore( &PrivGBase(GfxBase
)->view_sema
);
63 InitSemaphore( &PrivGBase(GfxBase
)->tfe_hashtab_sema
);
64 InitSemaphore( &PrivGBase(GfxBase
)->fontsem
);
66 NEWLIST(&LIBBASE
->MonitorList
);
67 LIBBASE
->MonitorList
.lh_Type
= MONITOR_SPEC_TYPE
;
68 GfxBase
->MonitorListSemaphore
= &PrivGBase(GfxBase
)->monitors_sema
;
69 InitSemaphore(GfxBase
->MonitorListSemaphore
);
71 D(bug("[graphics.library] %s: semaphores initialized\n", __func__
));
73 LIBBASE
->hash_table
= AllocMem(GFXASSOCIATE_HASHSIZE
* sizeof(APTR
), MEMF_CLEAR
|MEMF_PUBLIC
);
74 if (!LIBBASE
->hash_table
)
77 LIBBASE
->HashTableSemaphore
= &PrivGBase(GfxBase
)->hashtab_sema
;
78 LIBBASE
->ActiViewCprSemaphore
= &PrivGBase(GfxBase
)->view_sema
;
80 LIBBASE
->NormalDisplayColumns
= AROS_NOMINAL_WIDTH
;
81 LIBBASE
->NormalDisplayRows
= AROS_NOMINAL_HEIGHT
;
82 LIBBASE
->MaxDisplayColumn
= AROS_NOMINAL_WIDTH
;
83 LIBBASE
->MaxDisplayRow
= AROS_NOMINAL_HEIGHT
;
85 PrivGBase(LIBBASE
)->basebm
= OOP_FindClass(CLID_Hidd_BitMap
);
86 D(bug("[graphics.library] %s: BitMap class @ 0x%p\n", __func__
, PrivGBase(LIBBASE
)->basebm
));
88 #if REGIONS_USE_MEMPOOL
89 InitSemaphore( &PrivGBase(GfxBase
)->regionsem
);
90 if (!(PrivGBase(GfxBase
)->regionpool
= CreatePool(MEMF_PUBLIC
| MEMF_CLEAR
,
91 sizeof(struct Region
) * 20,
92 sizeof(struct Region
) * 20)))
97 NEWLIST(&PrivGBase(GfxBase
)->ChunkPoolList
);
100 D(bug("[graphics.library] %s: Initialise ROMFont...\n", __func__
));
102 if (!InitROMFont(LIBBASE
)) return FALSE
;
104 D(bug("[graphics.library] %s: Obtaining Gfx HW Root..\n", __func__
));
106 PrivGBase(GfxBase
)->GfxRoot
= OOP_NewObject(NULL
, CLID_HW_Gfx
, NULL
);
108 D(bug("[graphics.library] %s: Gfx HW Root @ 0x%p\n", __func__
, PrivGBase(GfxBase
)->GfxRoot
));
110 D(bug("[graphics.library] %s: Initialise driver...\n", __func__
));
112 return driver_init (LIBBASE
);
115 static int GfxOpen(struct GfxBase
*LIBBASE
)
117 struct TextFont
* def
;
119 if (!LIBBASE
->DefaultFont
)
121 struct TextAttr sysTA
;
122 sysTA
.ta_Name
= (STRPTR
)SYSFONTNAME
;
124 sysTA
.ta_Style
= FS_NORMAL
;
127 def
= OpenFont (&sysTA
);
132 LIBBASE
->DefaultFont
= def
;
133 sysTA
.ta_YSize
= def
->tf_YSize
;
136 if(! LIBBASE
->VBlank
)
138 NEWLIST(&LIBBASE
->TOF_WaitQ
);
139 LIBBASE
->vbsrv
.is_Code
= (VOID_FUNC
)TOF_VBlank
;
140 LIBBASE
->vbsrv
.is_Data
= LIBBASE
;
141 LIBBASE
->vbsrv
.is_Node
.ln_Name
= "Graphics TOF server";
142 LIBBASE
->vbsrv
.is_Node
.ln_Pri
= 10;
143 LIBBASE
->vbsrv
.is_Node
.ln_Type
= NT_INTERRUPT
;
145 /* Add a VBLANK server to take care of TOF waiting tasks. */
146 AddIntServer(INTB_VERTB
, &LIBBASE
->vbsrv
);
147 LIBBASE
->VBlank
= 50;
153 ADD2INITLIB(GfxInit
, 0);
154 ADD2OPENLIB(GfxOpen
, 0);
158 AROS_INTH1(TOF_VBlank
, struct GfxBase
*, GfxBase
)
164 GfxBase
->VBCounter
++;
165 if(!IsListEmpty(&GfxBase
->TOF_WaitQ
))
167 ForeachNode(&GfxBase
->TOF_WaitQ
, tNode
)
169 Signal((struct Task
*)tNode
->ln_Name
, SIGF_SINGLE
);