2 Copyright © 2002, The AROS Development Team.
7 Library code for AmigaOS, based on Dirk Stöckers Libary
13 #include <proto/exec.h>
14 #include <exec/resident.h>
15 #include <exec/initializers.h>
16 #include <intuition/intuitionbase.h>
17 #include <exec/execbase.h>
19 struct ExecBase
*SysBase
;
21 LONG
ReturnError2(void)
26 #include "muimaster_intern.h"
30 #define DATETXT "27.06.2003"
33 #define LIBNAME "zunemaster.library"
34 #define IDSTRING "zunemaster.library " VERSTXT " (" DATETXT ")\r\n"
39 typedef BPTR SEGLISTPTR
;
40 #define LC_LIBHEADERTYPEPTR struct Library *
42 /************************************************************************/
44 /* First executable routine of this library; must return an error
45 to the unsuspecting caller */
46 LONG
ReturnError(void)
51 /************************************************************************/
53 /* MUI private functions */
55 __asm
void MUI_Priv1(register __a6
struct Library
*MUIMasterBase
)
57 D(bug("MUI_Priv1() called"));
60 __asm
void MUI_Priv2(register __a6
struct Library
*MUIMasterBase
)
62 D(bug("MUI_Priv2() called"));
65 __asm
void MUI_Priv3(register __a6
struct Library
*MUIMasterBase
)
67 D(bug("MUI_Priv3() called"));
70 __asm
void MUI_Priv4(register __a6
struct Library
*MUIMasterBase
)
72 D(bug("MUI_Priv4() called"));
75 /************************************************************************/
77 /* Some functions which are somewhere else */
79 ULONG SAVEDS STDARGS
LC_BUILDNAME(L_InitLib
) (LC_LIBHEADERTYPEPTR MUIMasterBase
);
80 ULONG SAVEDS STDARGS
LC_BUILDNAME(L_OpenLib
) (LC_LIBHEADERTYPEPTR MUIMasterBase
);
81 void SAVEDS STDARGS
LC_BUILDNAME(L_CloseLib
) (LC_LIBHEADERTYPEPTR MUIMasterBase
);
82 void SAVEDS STDARGS
LC_BUILDNAME(L_ExpungeLib
) (LC_LIBHEADERTYPEPTR MUIMasterBase
);
84 /************************************************************************/
87 UBYTE i_Type
; UBYTE o_Type
; UBYTE d_Type
; UBYTE p_Type
;
88 UBYTE i_Name
; UBYTE o_Name
; STRPTR d_Name
;
89 UBYTE i_Flags
; UBYTE o_Flags
; UBYTE d_Flags
; UBYTE p_Flags
;
90 UBYTE i_Version
; UBYTE o_Version
; UWORD d_Version
;
91 UBYTE i_Revision
; UBYTE o_Revision
; UWORD d_Revision
;
92 UBYTE i_IdString
; UBYTE o_IdString
; STRPTR d_IdString
;
96 /************************************************************************/
97 extern const ULONG LibInitTable
[4]; /* the prototype */
99 /* The library loader looks for this marker in the memory
100 the library code and data will occupy. It is responsible
101 setting up the Library base data structure. */
102 const struct Resident RomTag
= {
103 RTC_MATCHWORD
, /* Marker value. */
104 (struct Resident
*)&RomTag
, /* This points back to itself. */
105 (struct Resident
*)LibInitTable
, /* This points somewhere behind this marker. */
106 RTF_AUTOINIT
, /* The Library should be set up according to the given table. */
107 VERSION
, /* The version of this Library. */
108 NT_LIBRARY
, /* This defines this module as a Library. */
109 0, /* Initialization priority of this Library; unused. */
110 LIBNAME
, /* Points to the name of the Library. */
111 IDSTRING
, /* The identification string of this Library. */
112 (APTR
)&LibInitTable
/* This table is for initializing the Library. */
115 /************************************************************************/
117 /* The mandatory reserved library function */
118 ULONG
LibReserved(void)
123 /* Open the library, as called via OpenLibrary() */
124 ASM
struct Library
*LibOpen(REG(a6
, struct MUIMasterBase_intern
* MUIMasterBase
))
126 /* Prevent delayed expunge and increment opencnt */
127 MUIMasterBase
->library
.lib_Flags
&= ~LIBF_DELEXP
;
128 MUIMasterBase
->library
.lib_OpenCnt
++;
130 return &MUIMasterBase
->library
;
133 /* Expunge the library, remove it from memory */
134 ASM SEGLISTPTR
LibExpunge(REG(a6
, struct MUIMasterBase_intern
*mb
))
136 if (!mb
->library
.lib_OpenCnt
)
140 seglist
= mb
->seglist
;
142 L_ExpungeLib(&mb
->library
);
144 /* Remove the library from the public list */
145 Remove((struct Node
*)mb
);
147 /* Free the vector table and the library data */
148 FreeMem((STRPTR
) mb
- mb
->library
.lib_NegSize
,
149 mb
->library
.lib_NegSize
+
150 mb
->library
.lib_PosSize
);
155 mb
->library
.lib_Flags
|= LIBF_DELEXP
;
157 /* Return the segment pointer, if any */
161 /* Close the library, as called by CloseLibrary() */
162 ASM SEGLISTPTR
LibClose(REG(a6
, struct MUIMasterBase_intern
*mb
))
164 if(!(--mb
->library
.lib_OpenCnt
))
166 if (mb
->library
.lib_Flags
& LIBF_DELEXP
)
167 return LibExpunge(mb
);
173 extern struct ExecBase
*SysBase
;
175 /* Initialize library */
176 ASM
struct Library
*LibInit(REG(a0
, SEGLISTPTR seglist
), REG(d0
, struct MUIMasterBase_intern
*mb
), REG(a6
, struct ExecBase
*sysbase
))
179 if(!(sysbase
->AttnFlags
& AFF_68060
))
181 #elif defined (_M68040)
182 if(!(sysbase
->AttnFlags
& AFF_68040
))
184 #elif defined (_M68030)
185 if(!(sysbase
->AttnFlags
& AFF_68030
))
187 #elif defined (_M68020)
188 if(!(sysbase
->AttnFlags
& AFF_68020
))
193 mb
->seglist
= seglist
;
195 /* Fill some globals */
196 // MUIMasterBase = (struct Library *)mb;
197 mb
->sysbase
= sysbase
;
200 D(bug("Librarybase at 0x%lx\n",mb
));
202 if (L_InitLib(&mb
->library
))
205 /* Free the vector table and the library data */
206 FreeMem((STRPTR
)mb
- mb
->library
.lib_NegSize
,
207 mb
->library
.lib_NegSize
+
208 mb
->library
.lib_PosSize
);
212 /************************************************************************/
213 /* This is the table of functions that make up the library. The first
214 four are mandatory, everything following it are user callable
215 routines. The table is terminated by the value -1. */
217 static const APTR LibVectors
[] = {
222 (APTR
) MUI_NewObjectA
,
223 (APTR
) MUI_DisposeObject
,
225 (APTR
) MUI_AllocAslRequest
,
226 (APTR
) MUI_AslRequest
,
227 (APTR
) MUI_FreeAslRequest
,
231 (APTR
) MUI_FreeClass
,
232 (APTR
) MUI_RequestIDCMP
,
233 (APTR
) MUI_RejectIDCMP
,
235 (APTR
) MUI_CreateCustomClass
,
236 (APTR
) MUI_DeleteCustomClass
,
237 (APTR
) MUI_MakeObjectA
,
243 (APTR
) MUI_ObtainPen
,
244 (APTR
) MUI_ReleasePen
,
245 (APTR
) MUI_AddClipping
,
246 (APTR
) MUI_RemoveClipping
,
247 (APTR
) MUI_AddClipRegion
,
248 (APTR
) MUI_RemoveClipRegion
,
249 (APTR
) MUI_BeginRefresh
,
250 (APTR
) MUI_EndRefresh
,
254 static const struct LibInitData LibInitData
= {
255 #ifdef __VBCC__ /* VBCC does not like OFFSET macro */
256 0xA0, 8, NT_LIBRARY
, 0,
258 0xA0, 14, LIBF_SUMUSED
|LIBF_CHANGED
, 0,
263 0xA0, (UBYTE
) OFFSET(Node
, ln_Type
), NT_LIBRARY
, 0,
264 0x80, (UBYTE
) OFFSET(Node
, ln_Name
), LIBNAME
,
265 0xA0, (UBYTE
) OFFSET(Library
, lib_Flags
), LIBF_SUMUSED
|LIBF_CHANGED
, 0,
266 0x90, (UBYTE
) OFFSET(Library
, lib_Version
), VERSION
,
267 0x90, (UBYTE
) OFFSET(Library
, lib_Revision
), REVISION
,
268 0x80, (UBYTE
) OFFSET(Library
, lib_IdString
), IDSTRING
,
273 /* The following data structures and data are responsible for
274 setting up the Library base data structure and the library
277 const ULONG LibInitTable
[4] = {
278 (ULONG
)sizeof(struct MUIMasterBase_intern
), /* Size of the base data structure */
279 (ULONG
)LibVectors
, /* Points to the function vector */
280 (ULONG
)&LibInitData
, /* Library base data structure setup table */
281 (ULONG
)LibInit
/* The address of the routine to do the setup */