2 * A program for drawing Hénon pictures.
3 * Written by Stefan Zeiger in May '91
5 * © 1992 by ! Wizard Works !
6 * Compiler : SAS/C 5.10
10 #include <exec/types.h>
11 #include <graphics/gfxbase.h>
12 #include <graphics/gfx.h>
13 #include <intuition/intuitionbase.h>
14 #include <intuition/intuition.h>
15 #include <intuition/iobsolete.h>
16 #include <proto/exec.h>
17 #include <proto/dos.h>
18 #include <proto/intuition.h>
19 #include <proto/graphics.h>
20 #include <proto/mathieeedoubtrans.h>
26 #define TOPAZ_EIGHTY 8
29 int CXBRK(void) { return(0); } /* Disable Lattice CTRL-C handling */
30 int chkabort(void) { return(0); } /* really */
37 struct IntuitionBase
*IntuitionBase
;
38 struct GfxBase
*GfxBase
=NULL
;
39 struct Library
* MathIeeeDoubTransBase
= NULL
;
42 struct Screen
*my_screen
=NULL
;
43 struct NewScreen my_new_screen
=
52 HIRES
, /* ViewModes */
53 CUSTOMSCREEN
, /* Type */
55 "Hénon v1.00", /* Title */
61 struct Window
*my_window
=NULL
;
62 struct NewWindow my_new_window
=
70 CLOSEWINDOW
, /* IDCMPFlags */
72 SMART_REFRESH
| /* Flags */
75 NULL
, /* FirstGadget */
77 "The Hénon picture :",
84 CUSTOMSCREEN
/* Type */
88 struct TextAttr my_font
=
90 "topaz.font",TOPAZ_EIGHTY
,0,FPF_ROMFONT
93 struct IntuiText black_text
=
103 void cleanexit(void);
106 int main(int argc
,char **argv
)
108 unsigned char buf
[20];
109 double xx
,x
,y
,xa
,a
,xymin
,xymax
,xystep
,cosinus
,sinus
,precalc
;
113 struct IntuiMessage
*my_message
;
115 UWORD PenData
[]={~0};
117 /****** INTERPRET ARGUMENTS ******/
121 if(strcmp(argv
[1],"?")==0)
123 Write(Output(),"Hénon v1.00 by ! WIZARD WORKS !\nUsage : ",40);
124 Write(Output(),argv
[0],strlen(argv
[0]));
125 Write(Output()," <a> <xymin> <xymax> <xystep> <itera>\n",38);
138 sscanf(argv
[1],"%lf",&a
);
139 sscanf(argv
[2],"%lf",&xymin
);
140 sscanf(argv
[3],"%lf",&xymax
);
141 sscanf(argv
[4],"%lf",&xystep
);
142 sscanf(argv
[5],"%ld",&itera
);
144 /****** PREPARE EVERYTHING ******/
146 IntuitionBase
=(struct IntuitionBase
*) OpenLibrary("intuition.library",37);
147 if(IntuitionBase
==NULL
)
149 IntuitionBase
=(struct IntuitionBase
*) OpenLibrary("intuition.library",0);
151 if(IntuitionBase
==NULL
)
153 puts("Can't open Intuition !");
159 GfxBase
=(struct GfxBase
*) OpenLibrary("graphics.library",0);
162 puts("Can't open Graphics !");
167 MathIeeeDoubTransBase
=(struct Library
*)
168 OpenLibrary("mathieeedoubtrans.library",0);
169 if(MathIeeeDoubTransBase
==NULL
)
171 puts("Can't open IEEE library !");
177 my_screen
=(struct Screen
*) OpenScreenTags(&my_new_screen
,SA_Pens
,PenData
,TAG_DONE
,0);
179 my_screen
=(struct Screen
*) OpenScreen(&my_new_screen
);
183 puts("Can't open Screen");
188 my_new_window
.Screen
=my_screen
;
189 my_window
=(struct Window
*) OpenWindow(&my_new_window
);
192 puts("Can't open Window");
197 SetAPen(my_window
->RPort
,1);
198 black_text
.IText
=buf
;
200 //cosinus=IEEEDPCos(a);
201 //sinus=IEEEDPSin(a);
205 /****** DRAW PICTURE ******/
206 SetAPen(my_window
->RPort
,1);
208 for(xa
=xymin
;xa
<=xymax
;xa
+=xystep
)
213 for(i
=0;i
<=itera
;i
++)
216 xx
=x
*cosinus
-precalc
*sinus
;
217 y
=x
*sinus
+precalc
*cosinus
;
219 WritePixel(my_window
->RPort
,(ULONG
)((XSIZE
*x
)+370.0),(ULONG
)(105-(SIZE
*y
)));
221 my_message
=(struct IntuiMessage
*)GetMsg(my_window
->UserPort
);
224 class=my_message
->Class
;
225 ReplyMsg((struct Message
*)my_message
);
226 if(class==CLOSEWINDOW
) close_me
=TRUE
;
228 if(close_me
==TRUE
) break;
231 /****** PRINT INFO ******/
232 sprintf(buf
,"A : %lf",a
);
233 PrintIText(my_window
->RPort
,&black_text
,8,15);
234 sprintf(buf
,"XYMin : %lf",xymin
);
235 PrintIText(my_window
->RPort
,&black_text
,8,23);
236 sprintf(buf
,"XYMax : %lf",xymax
);
237 PrintIText(my_window
->RPort
,&black_text
,8,31);
238 sprintf(buf
,"XYStep : %lf",xystep
);
239 PrintIText(my_window
->RPort
,&black_text
,8,39);
240 sprintf(buf
,"Itera : %ld",(long)itera
);
241 PrintIText(my_window
->RPort
,&black_text
,8,47);
243 /****** TERMINATE PROGRAM ******/
245 while(close_me
==FALSE
)
247 Wait(1<<my_window
->UserPort
->mp_SigBit
);
248 my_message
=(struct IntuiMessage
*)GetMsg(my_window
->UserPort
);
251 class=my_message
->Class
;
252 ReplyMsg((struct Message
*)my_message
);
253 if(class==CLOSEWINDOW
)
265 if(my_window
) CloseWindow(my_window
);
266 if(my_screen
) CloseScreen(my_screen
);
267 if(GfxBase
) CloseLibrary((struct Library
*)GfxBase
);
268 if(IntuitionBase
) CloseLibrary((struct Library
*)IntuitionBase
);