1 // amigaiconobj35-classic.c
6 #include <exec/types.h>
7 #include <exec/initializers.h>
9 #include <exec/resident.h>
11 #include <proto/exec.h>
14 #include "AmigaIconObj35.h"
16 //----------------------------------------------------------------------------
18 extern struct ExecBase
*SysBase
;
20 //----------------------------------------------------------------------------
22 static LIB_SAVEDS(struct Library
*) LIB_ASM LIB_INTERRUPT
Initlib(LIB_REG(d0
, struct Library
*libbase
),
23 LIB_REG(a0
, struct SegList
*seglist
), LIB_REG(a6
, struct ExecBase
*sysbase
));
25 static LIBFUNC_PROTO(Openlib
, libbase
, struct Library
*);
26 static LIBFUNC_PROTO(Closelib
, libbase
, struct SegList
*);
27 static LIBFUNC_PROTO(Expungelib
, libbase
, struct SegList
*);
28 static LIBFUNC_PROTO(Extfunclib
, libbase
, ULONG
);
30 //----------------------------------------------------------------------------
34 static APTR functable
[] =
37 (APTR
) FUNCARRAY_32BIT_NATIVE
,
47 /* Init table used in library initialization. */
48 static ULONG inittab
[] =
50 sizeof(struct AmigaIconObj35DtLibBase
),
58 struct Resident ALIGNED romtag
=
64 RTF_PPC
| RTF_AUTOINIT
,
80 //----------------------------------------------------------------------------
82 static LIB_SAVEDS(struct Library
*) LIB_ASM LIB_INTERRUPT
Initlib(LIB_REG(d0
, struct Library
*libbase
),
83 LIB_REG(a0
, struct SegList
*seglist
), LIB_REG(a6
, struct ExecBase
*sysbase
))
85 struct AmigaIconObj35DtLibBase
*dtLib
= (struct AmigaIconObj35DtLibBase
*) libbase
;
88 dtLib
->nib_ClassLibrary
.cl_Lib
.lib_Revision
= LIB_REVISION
;
89 dtLib
->nib_ClassLibrary
.cl_Lib
.lib_Node
.ln_Pri
= 7;
90 dtLib
->nib_SegList
= seglist
;
92 if (!InitDatatype(dtLib
))
94 CALLLIBFUNC(Expungelib
, &dtLib
->nib_ClassLibrary
.cl_Lib
);
98 return dtLib
? &dtLib
->nib_ClassLibrary
.cl_Lib
: NULL
;
102 static LIBFUNC(Openlib
, libbase
, struct Library
*)
104 struct AmigaIconObj35DtLibBase
*dtLib
= (struct AmigaIconObj35DtLibBase
*) libbase
;
106 dtLib
->nib_ClassLibrary
.cl_Lib
.lib_OpenCnt
++;
107 dtLib
->nib_ClassLibrary
.cl_Lib
.lib_Flags
&= ~LIBF_DELEXP
;
109 if (!OpenDatatype(dtLib
))
111 CALLLIBFUNC(Closelib
, &dtLib
->nib_ClassLibrary
.cl_Lib
);
115 return &dtLib
->nib_ClassLibrary
.cl_Lib
;
120 static LIBFUNC(Closelib
, libbase
, struct SegList
*)
122 struct AmigaIconObj35DtLibBase
*dtLib
= (struct AmigaIconObj35DtLibBase
*) libbase
;
124 dtLib
->nib_ClassLibrary
.cl_Lib
.lib_OpenCnt
--;
126 if (0 == dtLib
->nib_ClassLibrary
.cl_Lib
.lib_OpenCnt
)
128 if (dtLib
->nib_ClassLibrary
.cl_Lib
.lib_Flags
& LIBF_DELEXP
)
130 return CALLLIBFUNC(Expungelib
, &dtLib
->nib_ClassLibrary
.cl_Lib
);
139 static LIBFUNC(Expungelib
, libbase
, struct SegList
*)
141 struct AmigaIconObj35DtLibBase
*dtLib
= (struct AmigaIconObj35DtLibBase
*) libbase
;
143 if (0 == dtLib
->nib_ClassLibrary
.cl_Lib
.lib_OpenCnt
)
145 ULONG size
= dtLib
->nib_ClassLibrary
.cl_Lib
.lib_NegSize
+ dtLib
->nib_ClassLibrary
.cl_Lib
.lib_PosSize
;
146 UBYTE
*ptr
= (UBYTE
*) dtLib
- dtLib
->nib_ClassLibrary
.cl_Lib
.lib_NegSize
;
147 struct SegList
*libseglist
= dtLib
->nib_SegList
;
149 Remove((struct Node
*) dtLib
);
150 CloseDatatype(dtLib
);
156 dtLib
->nib_ClassLibrary
.cl_Lib
.lib_Flags
|= LIBF_DELEXP
;
163 static LIBFUNC(Extfunclib
, libbase
, ULONG
)
167 d1(kprintf(__FUNC__
"/%ld: libbase=%08lx\n", __LINE__
, libbase
));