15 #define COLOR_BACK TGI_COLOR_BLACK
16 #define COLOR_FORE TGI_COLOR_WHITE
19 /*****************************************************************************/
21 /*****************************************************************************/
28 static unsigned AspectRatio;
32 /*****************************************************************************/
34 /*****************************************************************************/
38 static void CheckError (const char* S)
40 unsigned char Error = tgi_geterror ();
41 if (Error != TGI_ERR_OK) {
42 printf ("%s: %d\n", S, Error);
49 static void DoWarning (void)
50 /* Warn the user that the TGI driver is needed for this program */
52 printf ("Warning: This program needs the TGI\n"
53 "driver on disk! Press 'y' if you have\n"
54 "it - any other key exits.\n");
55 if (tolower (cgetc ()) != 'y') {
58 printf ("Ok. Please wait patiently...\n");
63 static void DoCircles (void)
65 static const unsigned char Palette[2] = { TGI_COLOR_WHITE, TGI_COLOR_ORANGE };
67 unsigned char Color = COLOR_FORE;
68 unsigned X = MaxX / 2;
69 unsigned Y = MaxY / 2;
71 tgi_setpalette (Palette);
73 tgi_setcolor (COLOR_FORE);
74 tgi_line (0, 0, MaxX, MaxY);
75 tgi_line (0, MaxY, MaxX, 0);
77 for (I = 10; I < 240; I += 10) {
78 tgi_ellipse (X, Y, I, tgi_imulround (I, AspectRatio));
80 Color = Color == COLOR_FORE ? COLOR_BACK : COLOR_FORE;
89 static void DoCheckerboard (void)
91 static const unsigned char Palette[2] = { TGI_COLOR_WHITE, TGI_COLOR_BLACK };
95 tgi_setpalette (Palette);
98 for (Y = 0; Y <= MaxY; Y += 10) {
99 for (X = 0; X <= MaxX; X += 10) {
100 tgi_setcolor (Color);
101 tgi_bar (X, Y, X+9, Y+9);
102 Color = Color == COLOR_FORE ? COLOR_BACK : COLOR_FORE;
109 Color = Color == COLOR_FORE ? COLOR_BACK : COLOR_FORE;
111 Color = Color == COLOR_FORE ? COLOR_BACK : COLOR_FORE;
117 static void DoDiagram (void)
119 static const unsigned char Palette[2] = { TGI_COLOR_WHITE, TGI_COLOR_BLACK };
120 int XOrigin, YOrigin;
125 tgi_setpalette (Palette);
126 tgi_setcolor (COLOR_FORE);
128 /* Determine zero and aplitude */
131 Amp = (MaxY - 19) / 2;
134 tgi_line (XOrigin, 10, XOrigin, MaxY-10);
135 tgi_line (XOrigin-2, 12, XOrigin, 10);
136 tgi_lineto (XOrigin+2, 12);
139 tgi_line (XOrigin, YOrigin, MaxX-10, YOrigin);
140 tgi_line (MaxX-12, YOrigin-2, MaxX-10, YOrigin);
141 tgi_lineto (MaxX-12, YOrigin+2);
144 tgi_gotoxy (XOrigin, YOrigin);
145 for (I = 0; I <= 360; I += 5) {
147 /* Calculate the next points */
148 X = (int) (((long) (MaxX - 19) * I) / 360);
149 Y = (int) (((long) Amp * -cc65_sin (I)) / 256);
152 tgi_lineto (XOrigin + X, YOrigin + Y);
161 static void DoLines (void)
163 static const unsigned char Palette[2] = { TGI_COLOR_WHITE, TGI_COLOR_BLACK };
166 tgi_setpalette (Palette);
167 tgi_setcolor (COLOR_FORE);
169 for (X = 0; X <= MaxY; X += 10) {
170 tgi_line (0, 0, MaxY, X);
171 tgi_line (0, 0, X, MaxY);
172 tgi_line (MaxY, MaxY, 0, MaxY-X);
173 tgi_line (MaxY, MaxY, MaxY-X, 0);
184 unsigned char Border;
187 /* Warn the user that the tgi driver is needed */
190 /* Load and initialize the driver */
191 tgi_load_driver (tgi_stddrv);
192 CheckError ("tgi_load_driver");
194 /* Install the driver */
195 tgi_install (tgi_static_stddrv);
196 CheckError ("tgi_install");
200 CheckError ("tgi_init");
203 /* Get stuff from the driver */
204 MaxX = tgi_getmaxx ();
205 MaxY = tgi_getmaxy ();
206 AspectRatio = tgi_getaspectratio ();
208 /* Set the palette, set the border color */
209 Border = bordercolor (COLOR_BLACK);
211 /* Do graphics stuff */
218 /* Unload the driver */
221 /* Uninstall the driver */
225 /* Reset the border */
226 (void) bordercolor (Border);