4 ** library code colorwheel
9 #include <exec/resident.h>
10 #include <exec/initializers.h>
11 #include <exec/execbase.h>
12 #include <exec/libraries.h>
13 #include <graphics/gfxbase.h>
17 #include <inline/exec.h>
18 #include <inline/intuition.h>
19 #include <inline/dos.h>
22 #include <pragma/exec_lib.h>
23 #include <pragma/intuition_lib.h>
24 #include <pragma/dos_lib.h>
26 #define REG( x, a ) register __## x a
31 #include "BoopsiStubs.h"
34 #define ColorWheelBase ColorWheelBase_intern
36 #include "colorwheel_intern.h"
38 /****************************************************************************/
44 /****************************************************************************/
46 STATIC
struct Library
*LibInit(REG(a0
, ULONG seglist
), REG(d0
, struct ColorWheelBase_intern
*ClassBase
), REG(a6
, struct Library
*) );
47 STATIC
struct Library
*LibOpen( REG(a6
, struct ColorWheelBase_intern
*ClassBase
) );
48 STATIC ULONG
LibExpunge( REG(a6
, struct ColorWheelBase_intern
*ClassBase
) );
49 STATIC ULONG
LibClose( REG(a6
, struct ColorWheelBase_intern
*ClassBase
) );
50 STATIC LONG
LibExtFunc(void);
53 BOOL __regargs
L_OpenLibs(struct ColorWheelBase_intern
*);
54 void __regargs
L_CloseLibs(struct ColorWheelBase_intern
*);
55 Class
* __regargs
initClass (struct ColorWheelBase_intern
*);
56 Class
* ObtainClass(REG(a6
, struct ColorWheelBase_intern
*) );
58 extern ULONG
dispatch_colorwheelclass(REG(a0
, Class
*), REG(a2
, Object
*), REG(a1
, Msg
) );
60 /****************************************************************************/
62 UBYTE LibName
[] = NAME_STRING
,
63 LibID
[] = VERSION_STRING
;
65 LONG LibVersion
= VERSION_NUMBER
,
66 LibRevision
= REVISION_NUMBER
;
68 extern void ConvertHSBToRGB( void ), ConvertRGBToHSB( void );
76 (APTR
) ConvertHSBToRGB
,
77 (APTR
) ConvertRGBToHSB
,
83 (ULONG
) sizeof(struct ColorWheelBase_intern
),
89 struct Resident ROMTag
= /* do not change */
93 &ROMTag
+ sizeof(ROMTag
),
103 /****************************************************************************/
105 LONG
LibExtFunc(void)
110 /****************************************************************************/
113 __saveds
LibInit( REG(a0
, ULONG seglist
), REG(d0
, struct ColorWheelBase_intern
*ColorWheelBase
), REG(a6
, struct Library
*ExecBase
) )
115 SysBase
= (struct ExecBase
*) ExecBase
;
116 ColorWheelBase
->seglist
= seglist
;
117 ColorWheelBase
->library
.lib_Revision
= REVISION_NUMBER
;
119 if( ( ExecBase
->lib_Version
>= 39L ) && ( ((struct ExecBase
*)SysBase
)->AttnFlags
& AFF_68020
) )
121 if(L_OpenLibs(ColorWheelBase
))
123 if(ColorWheelBase
->classptr
= InitColorWheelClass(ColorWheelBase
))
125 return((struct Library
*)ColorWheelBase
);
129 L_CloseLibs( ColorWheelBase
);
132 FreeMem((BYTE
*)ColorWheelBase
-ColorWheelBase
->library
.lib_NegSize
,
133 ColorWheelBase
->library
.lib_NegSize
+ ColorWheelBase
->library
.lib_PosSize
);
138 /****************************************************************************/
140 struct Library
* __saveds
LibOpen(REG(a6
, struct ColorWheelBase_intern
*ColorWheelBase
) )
142 ColorWheelBase
->library
.lib_Flags
&= ~LIBF_DELEXP
;
143 ColorWheelBase
->library
.lib_OpenCnt
++;
145 return((struct Library
*)ColorWheelBase
);
148 /****************************************************************************/
150 ULONG __saveds
LibExpunge(REG(a6
, struct ColorWheelBase_intern
*ColorWheelBase
) )
152 if(!ColorWheelBase
->library
.lib_OpenCnt
)
154 if(ColorWheelBase
->classptr
)
156 if( ! FreeClass(ColorWheelBase
->classptr
) )
158 AddClass( ColorWheelBase
->classptr
);
163 L_CloseLibs(ColorWheelBase
);
165 Remove((struct Node
*)ColorWheelBase
);
167 FreeMem((BYTE
*)ColorWheelBase
-ColorWheelBase
->library
.lib_NegSize
,
168 ColorWheelBase
->library
.lib_NegSize
+ ColorWheelBase
->library
.lib_PosSize
);
170 return( ColorWheelBase
->seglist
);
174 ColorWheelBase
->library
.lib_Flags
|= LIBF_DELEXP
;
180 /****************************************************************************/
182 ULONG __saveds
LibClose(REG(a6
, struct ColorWheelBase_intern
*ColorWheelBase
) )
184 if(ColorWheelBase
->library
.lib_OpenCnt
)
186 ColorWheelBase
->library
.lib_OpenCnt
--;
189 return((!ColorWheelBase
->library
.lib_OpenCnt
&&
190 ColorWheelBase
->library
.lib_Flags
& LIBF_DELEXP
)?LibExpunge(ColorWheelBase
):NULL
);
193 /****************************************************************************/
195 struct GfxBase
*GfxBase
;
196 struct IntuitionBase
*IntuitionBase
;
197 struct Library
*LayersBase
;
198 struct UtilityBase
*UtilityBase
;
199 struct Library
*CyberGfxBase
;
201 BOOL __regargs
L_OpenLibs( struct ColorWheelBase_intern
*ColorWheelBase
)
203 if( ( GfxBase
= OpenLibrary( "graphics.library", 39L ) ) &&
204 ( IntuitionBase
= OpenLibrary( "intuition.library", 39L ) ) &&
205 ( LayersBase
= OpenLibrary( "layers.library", 39L ) ) &&
206 ( UtilityBase
= OpenLibrary( "utility.library", 39L ) ) )
208 CyberGfxBase
= OpenLibrary( "cybergraphics.library", 40L );
216 /****************************************************************************/
218 void __regargs
L_CloseLibs( struct ColorWheelBase_intern
*ColorWheelBase
)
220 CloseLibrary( (struct Library
*)GfxBase
);
221 CloseLibrary( (struct Library
*)IntuitionBase
);
222 CloseLibrary( UtilityBase
);
223 CloseLibrary( CyberGfxBase
);
224 CloseLibrary( LayersBase
);
227 /***************************************************************************************************/
229 IPTR
dispatch_colorwheelclass( REG(a0
, Class
*cl
), REG(a2
, Object
*o
), REG(a1
, Msg msg
) )
233 switch(msg
->MethodID
)
236 retval
= colorwheel_handleinput(cl
, o
, (struct gpInput
*)msg
);
240 colorwheel_render(cl
, o
, (struct gpRender
*)msg
);
245 retval
= colorwheel_set(cl
, o
, (struct opSet
*)msg
);
249 retval
= colorwheel_hittest(cl
, o
, (struct gpHitTest
*)msg
);
253 retval
= colorwheel_goactive(cl
, o
, (struct gpInput
*)msg
);
257 retval
= colorwheel_get(cl
, o
, (struct opGet
*)msg
);
261 retval
= colorwheel_domain(cl
, o
, (struct gpDomain
*)msg
);
265 retval
= (IPTR
)colorwheel_new(cl
, o
, (struct opSet
*)msg
);
269 colorwheel_dispose(cl
, o
, msg
);
273 retval
= DoSuperMethodA(cl
, o
, (Msg
)msg
);
279 } /* dispatch_colorwheelclass */
281 /***************************************************************************************************/
283 struct IClass
*InitColorWheelClass (struct ColorWheelBase_intern
* ColorWheelBase
)
285 struct IClass
*cl
= NULL
;
287 if ((cl
= MakeClass("colorwheel.gadget", GADGETCLASS
, NULL
, sizeof(struct ColorWheelData
), 0)))
289 cl
->cl_Dispatcher
.h_Entry
= (HOOKFUNC
) dispatch_colorwheelclass
;
290 cl
->cl_Dispatcher
.h_SubEntry
= NULL
;
291 cl
->cl_UserData
= (IPTR
)ColorWheelBase
;
299 /****************************************************************************/