5 ** © 1998/99 by Stephan Rupprecht
10 #include <exec/resident.h>
11 #include <exec/initializers.h>
12 #include <exec/execbase.h>
13 #include <exec/libraries.h>
14 #include <datatypes/soundclass.h>
17 #include <pragma/exec_lib.h>
18 #include <pragma/intuition_lib.h>
19 #include <pragma/dos_lib.h>
20 #include <pragma/utility_lib.h>
21 #include <pragma/datatypes_lib.h>
23 #include <inline/exec.h>
24 #include <inline/intuition.h>
25 #include <inline/dos.h>
26 #include <inline/utility.h>
27 #include <inline/datatypes.h>
30 #include "classbase.h"
33 #include "CompilerSpecific.h"
36 /****************************************************************************/
41 #define REG(r, a) register __## r a
47 #define VERSIONSTR "41.11"
48 #define DATE "11.08.00"
50 /****************************************************************************/
52 STATIC
struct Library
*LibInit(REG(a0
, ULONG Segment
), REG(d0
, struct ClassBase
*ClassBase
), REG(a6
, struct Library
*) );
53 STATIC
struct Library
*LibOpen( REG(a6
, struct ClassBase
*ClassBase
) );
54 STATIC ULONG
LibExpunge( REG(a6
, struct ClassBase
*ClassBase
) );
55 STATIC ULONG
LibClose( REG(a6
, struct ClassBase
*ClassBase
) );
56 STATIC LONG
LibExtFunc(void);
58 BOOL __regargs
L_OpenLibs(struct ClassBase
*);
59 void __regargs
L_CloseLibs(struct ClassBase
*);
60 Class
* __regargs
initClass (struct ClassBase
*);
61 Class
* ObtainClass( REG(a6
, struct ClassBase
*) );
63 extern ULONG
Dispatch( REG(a0
, Class
*), REG(a2
, Object
*), REG(a1
, Msg
) );
65 /****************************************************************************/
67 UBYTE LibName
[] = "v41sound.datatype",
68 LibID
[] = "v41sound.datatype "VERSIONSTR
" ("DATE
") © 1998-2000 by Stephan Rupprecht";
70 LONG LibVersion
= VERSION
,
71 LibRevision
= REVISION
;
85 (ULONG
) sizeof(struct ClassBase
),
91 struct Resident ROMTag
= /* do not change */
105 /****************************************************************************/
112 /****************************************************************************/
114 LONG
LibExtFunc(void)
119 /****************************************************************************/
122 #define IntuitionBase cb->cb_IntuitionBase
123 #define GfxBase cb->cb_GfxBase
124 #define DOSBase cb->cb_DOSBase
125 #define SysBase cb->cb_SysBase
126 #define DataTypesBase cb->cb_DataTypesBase
127 #define UtilityBase cb->cb_UtilityBase
128 #define IFFParseBase cb->cb_IFFParseBase
129 #define TapeDeckBase cb->cb_TapeDeckBase
131 struct Library
*DOSBase
, *SysBase
, *DataTypesBase
, *TapeDeckBase
,
132 *IntuitionBase
, *GfxBase
, *UtilityBase
, *IFFParseBase
;
135 /****************************************************************************/
138 LibInit( REG(a0
, ULONG Segment
), REG(d0
, struct ClassBase
*cb
), REG(a6
, struct Library
*ExecBase
) )
142 InitSemaphore( &cb
->cb_LibLock
);
143 ObtainSemaphore( &cb
->cb_LibLock
);
145 cb
->LibSegment
= Segment
;
146 cb
->LibNode
.lib_Revision
= REVISION
;
148 if( ((struct ExecBase
*)ExecBase
)->AttnFlags
& AFF_68020
)
152 if(cb
->cb_Class
= initClass(cb
))
154 ReleaseSemaphore( &cb
->cb_LibLock
);
155 return((struct Library
*)cb
);
162 ReleaseSemaphore( &cb
->cb_LibLock
);
164 FreeMem((BYTE
*)cb
-cb
->LibNode
.lib_NegSize
,
165 cb
->LibNode
.lib_NegSize
+ cb
->LibNode
.lib_PosSize
);
170 /****************************************************************************/
172 struct Library
*LibOpen( REG(a6
, struct ClassBase
*cb
) )
174 ObtainSemaphore( &cb
->cb_LibLock
);
175 cb
->LibNode
.lib_Flags
&= ~LIBF_DELEXP
;
176 cb
->LibNode
.lib_OpenCnt
++;
177 ReleaseSemaphore( &cb
->cb_LibLock
);
178 return((struct Library
*)cb
);
181 /****************************************************************************/
183 ULONG
LibExpunge( REG(a6
, struct ClassBase
*cb
) )
187 ObtainSemaphore( &cb
->cb_LibLock
);
189 if(!cb
->LibNode
.lib_OpenCnt
)
193 if( ! FreeClass(cb
->cb_Class
) )
195 AddClass( cb
->cb_Class
);
196 ReleaseSemaphore( &cb
->cb_LibLock
);
201 if( DataTypesBase
->lib_Version
>= 45L )
203 FreeDTMethods( cb
->cb_Methods
);
206 FreeVec( cb
->cb_Methods
);
211 Remove((struct Node
*)cb
);
213 FreeMem((BYTE
*)cb
-cb
->LibNode
.lib_NegSize
,
214 cb
->LibNode
.lib_NegSize
+ cb
->LibNode
.lib_PosSize
);
216 retval
= cb
->LibSegment
;
220 cb
->LibNode
.lib_Flags
|= LIBF_DELEXP
;
223 ReleaseSemaphore( &cb
->cb_LibLock
);
228 /****************************************************************************/
230 ULONG
LibClose( REG(a6
, struct ClassBase
*cb
) )
234 ObtainSemaphore( &cb
->cb_LibLock
);
236 if( ! cb
->LibNode
.lib_OpenCnt
|| ! --cb
->LibNode
.lib_OpenCnt
)
238 if( cb
->LibNode
.lib_Flags
& LIBF_DELEXP
)
240 retval
= LibExpunge( cb
);
244 ReleaseSemaphore( &cb
->cb_LibLock
);
249 /****************************************************************************/
251 BOOL __regargs
L_OpenLibs( struct ClassBase
*cb
)
253 if( ( DOSBase
= OpenLibrary( "dos.library", 0L ) ) &&
254 ( IntuitionBase
= OpenLibrary( "intuition.library", 0L ) ) &&
255 ( GfxBase
= OpenLibrary( "graphics.library", 0L ) ) &&
256 ( DataTypesBase
= OpenLibrary( "datatypes.library", 0L ) ) &&
257 ( UtilityBase
= OpenLibrary( "utility.library", 0L ) ) &&
258 ( IFFParseBase
= OpenLibrary( "iffparse.library", 0L ) ) )
260 TapeDeckBase
= OpenLibrary( "gadgets/tapedeck.gadget", 39L );
267 /****************************************************************************/
269 Class
* __regargs
initClass ( struct ClassBase
*cb
)
273 if(cl
= MakeClass(LibName
, DATATYPESCLASS
, NULL
, sizeof( struct InstanceData
), 0L))
275 cl
->cl_Dispatcher
.h_Entry
= (HOOKFUNC
) Dispatch
;
276 cl
->cl_UserData
= (ULONG
) cb
;
283 /****************************************************************************/
285 void __regargs
L_CloseLibs( struct ClassBase
*cb
)
287 CloseLibrary( DOSBase
);
288 CloseLibrary( IntuitionBase
);
289 CloseLibrary( GfxBase
);
290 CloseLibrary( DataTypesBase
);
291 CloseLibrary( UtilityBase
);
292 CloseLibrary( IFFParseBase
);
293 CloseLibrary( TapeDeckBase
);
296 /****************************************************************************/
298 Class
*ObtainClass( REG(a6
, struct ClassBase
*cb
) )
302 ObtainSemaphoreShared( &cb
->cb_LibLock
);
304 ReleaseSemaphore( &cb
->cb_LibLock
);
309 /****************************************************************************/