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>
16 #include <inline/exec.h>
17 #include <inline/intuition.h>
18 #include <inline/dos.h>
20 #include <pragma/exec_lib.h>
21 #include <pragma/intuition_lib.h>
22 #include <pragma/dos_lib.h>
24 #define REG( x, a ) register __## x a
29 #include "BoopsiStubs.h"
32 #define ColorWheelBase ColorWheelBase_intern
34 #include "colorwheel_intern.h"
36 /****************************************************************************/
42 /****************************************************************************/
44 STATIC
struct Library
*LibInit(REG(a0
, ULONG seglist
), REG(d0
, struct ColorWheelBase_intern
*ClassBase
), REG(a6
, struct Library
*) );
45 STATIC
struct Library
*LibOpen( REG(a6
, struct ColorWheelBase_intern
*ClassBase
) );
46 STATIC ULONG
LibExpunge( REG(a6
, struct ColorWheelBase_intern
*ClassBase
) );
47 STATIC ULONG
LibClose( REG(a6
, struct ColorWheelBase_intern
*ClassBase
) );
48 STATIC LONG
LibExtFunc(void);
51 BOOL __regargs
L_OpenLibs(struct ColorWheelBase_intern
*);
52 void __regargs
L_CloseLibs(struct ColorWheelBase_intern
*);
53 Class
* __regargs
initClass (struct ColorWheelBase_intern
*);
54 Class
* ObtainClass(REG(a6
, struct ColorWheelBase_intern
*) );
56 extern ULONG
dispatch_colorwheelclass(REG(a0
, Class
*), REG(a2
, Object
*), REG(a1
, Msg
) );
58 /****************************************************************************/
60 UBYTE LibName
[] = NAME_STRING
,
61 LibID
[] = VERSION_STRING
;
63 LONG LibVersion
= VERSION_NUMBER
,
64 LibRevision
= REVISION_NUMBER
;
66 extern void ConvertHSBToRGB( void ), ConvertRGBToHSB( void );
74 (APTR
) ConvertHSBToRGB
,
75 (APTR
) ConvertRGBToHSB
,
81 (ULONG
) sizeof(struct ColorWheelBase_intern
),
87 struct Resident ROMTag
= /* do not change */
91 &ROMTag
+ sizeof(ROMTag
),
101 /****************************************************************************/
103 LONG
LibExtFunc(void)
108 /****************************************************************************/
111 __saveds
LibInit( REG(a0
, ULONG seglist
), REG(d0
, struct ColorWheelBase_intern
*ColorWheelBase
), REG(a6
, struct Library
*ExecBase
) )
113 SysBase
= (struct ExecBase
*) ExecBase
;
114 ColorWheelBase
->seglist
= seglist
;
115 ColorWheelBase
->library
.lib_Revision
= REVISION_NUMBER
;
117 if( ( ExecBase
->lib_Version
>= 39L ) && ( ((struct ExecBase
*)SysBase
)->AttnFlags
& AFF_68020
) )
119 if(L_OpenLibs(ColorWheelBase
))
121 if(ColorWheelBase
->classptr
= InitColorWheelClass(ColorWheelBase
))
123 return((struct Library
*)ColorWheelBase
);
127 L_CloseLibs( ColorWheelBase
);
130 FreeMem((BYTE
*)ColorWheelBase
-ColorWheelBase
->library
.lib_NegSize
,
131 ColorWheelBase
->library
.lib_NegSize
+ ColorWheelBase
->library
.lib_PosSize
);
136 /****************************************************************************/
138 struct Library
* __saveds
LibOpen(REG(a6
, struct ColorWheelBase_intern
*ColorWheelBase
) )
140 ColorWheelBase
->library
.lib_Flags
&= ~LIBF_DELEXP
;
141 ColorWheelBase
->library
.lib_OpenCnt
++;
143 return((struct Library
*)ColorWheelBase
);
146 /****************************************************************************/
148 ULONG __saveds
LibExpunge(REG(a6
, struct ColorWheelBase_intern
*ColorWheelBase
) )
150 if(!ColorWheelBase
->library
.lib_OpenCnt
)
152 if(ColorWheelBase
->classptr
)
154 if( ! FreeClass(ColorWheelBase
->classptr
) )
156 AddClass( ColorWheelBase
->classptr
);
161 L_CloseLibs(ColorWheelBase
);
163 Remove((struct Node
*)ColorWheelBase
);
165 FreeMem((BYTE
*)ColorWheelBase
-ColorWheelBase
->library
.lib_NegSize
,
166 ColorWheelBase
->library
.lib_NegSize
+ ColorWheelBase
->library
.lib_PosSize
);
168 return( ColorWheelBase
->seglist
);
172 ColorWheelBase
->library
.lib_Flags
|= LIBF_DELEXP
;
178 /****************************************************************************/
180 ULONG __saveds
LibClose(REG(a6
, struct ColorWheelBase_intern
*ColorWheelBase
) )
182 if(ColorWheelBase
->library
.lib_OpenCnt
)
184 ColorWheelBase
->library
.lib_OpenCnt
--;
187 return((!ColorWheelBase
->library
.lib_OpenCnt
&&
188 ColorWheelBase
->library
.lib_Flags
& LIBF_DELEXP
)?LibExpunge(ColorWheelBase
):NULL
);
191 /****************************************************************************/
193 struct GfxBase
*GfxBase
;
194 struct IntuitionBase
*IntuitionBase
;
195 struct Library
*LayersBase
;
196 struct UtilityBase
*UtilityBase
;
197 struct Library
*CyberGfxBase
;
199 BOOL __regargs
L_OpenLibs( struct ColorWheelBase_intern
*ColorWheelBase
)
201 if( ( GfxBase
= OpenLibrary( "graphics.library", 39L ) ) &&
202 ( IntuitionBase
= OpenLibrary( "intuition.library", 39L ) ) &&
203 ( LayersBase
= OpenLibrary( "layers.library", 39L ) ) &&
204 ( UtilityBase
= OpenLibrary( "utility.library", 39L ) ) )
206 CyberGfxBase
= OpenLibrary( "cybergraphics.library", 40L );
214 /****************************************************************************/
216 void __regargs
L_CloseLibs( struct ColorWheelBase_intern
*ColorWheelBase
)
218 CloseLibrary( (struct Library
*)GfxBase
);
219 CloseLibrary( (struct Library
*)IntuitionBase
);
220 CloseLibrary( UtilityBase
);
221 CloseLibrary( CyberGfxBase
);
222 CloseLibrary( LayersBase
);
225 /***************************************************************************************************/
227 IPTR
dispatch_colorwheelclass( REG(a0
, Class
*cl
), REG(a2
, Object
*o
), REG(a1
, Msg msg
) )
231 switch(msg
->MethodID
)
234 retval
= colorwheel_handleinput(cl
, o
, (struct gpInput
*)msg
);
238 colorwheel_render(cl
, o
, (struct gpRender
*)msg
);
243 retval
= colorwheel_set(cl
, o
, (struct opSet
*)msg
);
247 retval
= colorwheel_hittest(cl
, o
, (struct gpHitTest
*)msg
);
251 retval
= colorwheel_goactive(cl
, o
, (struct gpInput
*)msg
);
255 retval
= colorwheel_get(cl
, o
, (struct opGet
*)msg
);
259 retval
= colorwheel_domain(cl
, o
, (struct gpDomain
*)msg
);
263 retval
= (IPTR
)colorwheel_new(cl
, o
, (struct opSet
*)msg
);
267 colorwheel_dispose(cl
, o
, msg
);
271 retval
= DoSuperMethodA(cl
, o
, (Msg
)msg
);
277 } /* dispatch_colorwheelclass */
279 /***************************************************************************************************/
281 struct IClass
*InitColorWheelClass (struct ColorWheelBase_intern
* ColorWheelBase
)
283 struct IClass
*cl
= NULL
;
285 if ((cl
= MakeClass("colorwheel.gadget", GADGETCLASS
, NULL
, sizeof(struct ColorWheelData
), 0)))
287 cl
->cl_Dispatcher
.h_Entry
= (HOOKFUNC
) dispatch_colorwheelclass
;
288 cl
->cl_Dispatcher
.h_SubEntry
= NULL
;
289 cl
->cl_UserData
= (IPTR
)ColorWheelBase
;
297 /****************************************************************************/