2 Copyright © 1995-2006, 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 <hardware/intbits.h>
19 #include <exec/execbase.h>
20 #include <exec/memory.h>
21 #include <exec/lists.h>
22 #include <graphics/gfxbase.h>
23 #include <graphics/text.h>
24 #include <graphics/regions.h>
25 #include <proto/graphics.h>
26 #include <utility/utility.h>
27 #include "graphics_intern.h"
28 #include "default_font.h"
29 #include LC_LIBDEFS_FILE
33 extern int driver_init (struct GfxBase
*);
34 extern int driver_open (struct GfxBase
*);
35 extern void driver_close (struct GfxBase
*);
36 extern void driver_expunge (struct GfxBase
*);
38 AROS_UFP4(ULONG
, TOF_VBlank
,
39 AROS_UFHA(ULONG
, dummy
, A0
),
40 AROS_UFHA(void *, data
, A1
),
41 AROS_UFHA(ULONG
, dummy2
, A5
),
42 AROS_UFHA(struct ExecBase
*, SysBase
, A6
));
45 # define SYSFONTNAME "topaz.font"
48 static struct TextAttr sysTA
;
49 BOOL
InitROMFont(struct GfxBase
*);
51 static int GfxInit(struct GfxBase
*LIBBASE
)
55 NEWLIST(&LIBBASE
->TextFonts
);
56 InitSemaphore( &PrivGBase(GfxBase
)->tfe_hashtab_sema
);
57 InitSemaphore( &PrivGBase(GfxBase
)->fontsem
);
59 #if REGIONS_USE_MEMPOOL
60 InitSemaphore( &PrivGBase(GfxBase
)->regionsem
);
61 if (!(PrivGBase(GfxBase
)->regionpool
= CreatePool(MEMF_PUBLIC
| MEMF_CLEAR
,
62 sizeof(struct Region
) * 20,
63 sizeof(struct Region
) * 20)))
68 NEWLIST(&PrivGBase(GfxBase
)->ChunkPoolList
);
71 InitSemaphore( &PrivGBase(GfxBase
)->driverdatasem
);
72 if (!(PrivGBase(GfxBase
)->driverdatapool
= CreatePool(MEMF_PUBLIC
| MEMF_SEM_PROTECTED
,
79 for(i
= 0; i
< DRIVERDATALIST_HASHSIZE
; i
++)
81 NEWLIST((struct List
*)&PrivGBase(GfxBase
)->driverdatalist
[i
]);
84 if (!InitROMFont(LIBBASE
)) return FALSE
;
87 if (!driver_init (LIBBASE
))
97 static int GfxOpen(struct GfxBase
*LIBBASE
)
99 struct TextFont
* def
;
101 if (!LIBBASE
->DefaultFont
)
103 sysTA
.ta_Name
= (STRPTR
)SYSFONTNAME
;
105 sysTA
.ta_Style
= FS_NORMAL
;
108 def
= OpenFont (&sysTA
);
113 LIBBASE
->DefaultFont
= def
;
114 sysTA
.ta_YSize
= def
->tf_YSize
;
118 if (!driver_open (LIBBASE
))
125 /* Allocate 8 IPTR's for a hash list needed by
126 GfxAssociate(), GfxLookUp() */
128 if (!LIBBASE
->hash_table
)
129 LIBBASE
->hash_table
= (LONG
*)AllocMem(8*sizeof(LONG
*),
130 MEMF_CLEAR
|MEMF_PUBLIC
);
131 if (!LIBBASE
->hash_table
)
135 if(LIBBASE
->LibNode
.lib_OpenCnt
== 0)
137 NEWLIST(&LIBBASE
->TOF_WaitQ
);
138 LIBBASE
->vbsrv
.is_Code
= (APTR
)TOF_VBlank
;
139 LIBBASE
->vbsrv
.is_Data
= LIBBASE
;
140 LIBBASE
->vbsrv
.is_Node
.ln_Name
= "Graphics TOF server";
141 LIBBASE
->vbsrv
.is_Node
.ln_Pri
= 10;
142 LIBBASE
->vbsrv
.is_Node
.ln_Type
= NT_INTERRUPT
;
144 /* Add a VBLANK server to take care of TOF waiting tasks. */
145 AddIntServer(INTB_VERTB
, &LIBBASE
->vbsrv
);
151 static int GfxExpunge(struct GfxBase
*LIBBASE
)
153 driver_expunge(LIBBASE
);
157 ADD2INITLIB(GfxInit
, 0);
158 ADD2OPENLIB(GfxOpen
, 0);
159 ADD2CLOSELIB(driver_close
, 0);
160 ADD2EXPUNGELIB(GfxExpunge
, 0);
164 AROS_UFH4(ULONG
, TOF_VBlank
,
165 AROS_UFHA(ULONG
, dummy
, A0
),
166 AROS_UFHA(void *, data
, A1
),
167 AROS_UFHA(ULONG
, dummy2
, A5
),
168 AROS_UFHA(struct ExecBase
*, SysBase
, A6
))
173 struct GfxBase
* GfxBase
= (struct GfxBase
*)data
;
175 if(!IsListEmpty(&GfxBase
->TOF_WaitQ
))
177 ForeachNode(&GfxBase
->TOF_WaitQ
, tNode
)
179 Signal((struct Task
*)tNode
->ln_Name
, SIGF_SINGLE
);