3 #include <intuition/intuition.h>
4 #include <graphics/gfx.h>
5 #include <graphics/rpattr.h>
6 #include <cybergraphx/cybergraphics.h>
7 #include <gadgets/colorwheel.h>
8 #include <proto/exec.h>
10 #include <proto/graphics.h>
11 #include <proto/cybergraphics.h>
12 #include <proto/colorwheel.h>
13 #include <proto/intuition.h>
19 #define SCREENWIDTH 300
20 #define SCREENHEIGHT 200
21 #define SCREENCY (SCREENHEIGHT / 2)
23 /***********************************************************************************/
25 struct IntuitionBase
*IntuitionBase
;
26 struct GfxBase
*GfxBase
;
27 struct Library
*CyberGfxBase
;
28 struct Library
*ColorWheelBase
;
33 ULONG cgfx_coltab
[256];
36 /***********************************************************************************/
38 static void cleanup(char *msg
)
42 printf("TrueColorPens: %s\n",msg
);
45 if (win
) CloseWindow(win
);
47 if (scr
) UnlockPubScreen(0, scr
);
49 if (ColorWheelBase
) CloseLibrary(ColorWheelBase
);
50 if (CyberGfxBase
) CloseLibrary(CyberGfxBase
);
51 if (GfxBase
) CloseLibrary((struct Library
*)GfxBase
);
52 if (IntuitionBase
) CloseLibrary((struct Library
*)IntuitionBase
);
57 /***********************************************************************************/
59 static void openlibs(void)
61 if (!(IntuitionBase
= (struct IntuitionBase
*)OpenLibrary("intuition.library", 39)))
63 cleanup("Can't open intuition.library V39!");
66 if (!(GfxBase
= (struct GfxBase
*)OpenLibrary("graphics.library", 39)))
68 cleanup("Can't open graphics.library V39!");
71 if (!(CyberGfxBase
= OpenLibrary("cybergraphics.library",0)))
73 cleanup("Can't open cybergraphics.library!");
76 if (!(ColorWheelBase
= OpenLibrary("gadgets/colorwheel.gadget",0)))
78 cleanup("Can't open colorwheel.gadget!");
83 /***********************************************************************************/
85 static void getvisual(void)
87 if (!(scr
= LockPubScreen(NULL
)))
89 cleanup("Can't lock pub screen!");
92 if (GetBitMapAttr(scr
->RastPort
.BitMap
, BMA_DEPTH
) <= 8)
94 cleanup("Need hi or true color screen!");
98 /***********************************************************************************/
100 static void makewin(void)
102 win
= OpenWindowTags(NULL
, WA_CustomScreen
, (IPTR
)scr
,
103 WA_InnerWidth
, SCREENWIDTH
,
104 WA_InnerHeight
, SCREENHEIGHT
,
105 WA_Title
, (IPTR
)"TrueColorPens: Press SPACE!",
107 WA_DepthGadget
, TRUE
,
108 WA_CloseGadget
, TRUE
,
110 WA_GimmeZeroZero
, TRUE
,
111 WA_IDCMP
, IDCMP_CLOSEWINDOW
|
115 if (!win
) cleanup("Can't open window");
120 /***********************************************************************************/
123 #define KC_RIGHT 0x4E
127 #define KC_SPACE 0x40
129 /***********************************************************************************/
131 static void getevents(void)
133 struct IntuiMessage
*msg
;
135 while ((msg
= (struct IntuiMessage
*)GetMsg(win
->UserPort
)))
139 case IDCMP_CLOSEWINDOW
:
145 WORD code
= msg
->Code
& ~IECODE_UP_PREFIX
;
147 Keys
[code
] = (code
== msg
->Code
) ? 1 : 0;
153 ReplyMsg((struct Message
*)msg
);
158 /***********************************************************************************/
160 static void action(void)
169 struct ColorWheelHSB cwhsb
= {hue
, 0xFFFFFFFF, 0xFFFFFFFF};
170 struct ColorWheelRGB cwrgb
;
174 ConvertHSBToRGB(&cwhsb
, &cwrgb
);
176 rgb
= (cwrgb
.cw_Red
& 0xFF000000) >> 8;
177 rgb
+= (cwrgb
.cw_Green
& 0xFF000000) >> 16;
178 rgb
+= (cwrgb
.cw_Blue
& 0xFF000000) >> 24;
180 SetRPAttrs(rp
, RPTAG_FgColor
, rgb
,
181 RPTAG_BgColor
, 0xFFFFFF - rgb
,
188 WritePixel(rp
, x
, y
);
189 WritePixel(rp
, x
+ 1, y
);
190 WritePixel(rp
, x
, y
+ 1);
191 WritePixel(rp
, x
+ 1, y
+ 1);
197 Text(rp
, "Text JAM1", 4);
203 Text(rp
, "Text JAM2", 4);
208 RectFill(rp
, x
, y
, x
+ 30, y
+ 30);
215 Draw(rp
, x
+ 30, y
+ 30);
222 DrawEllipse(rp
, x
, y
, 30, 30);
232 mode
= (mode
+ 1) % 6;
236 x
+= dx
; if ((x
> SCREENWIDTH
) || (x
< 0)) dx
= -dx
;
237 y
+= dy
; if ((y
> SCREENHEIGHT
) || (y
< 0)) dy
= -dy
;
241 } /* while(!Keys[KC_ESC]) */
244 /***********************************************************************************/
254 return 0; /* keep compiler happy */
257 /***********************************************************************************/