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);
43 if (doesclrscrafterexit ()) {
53 static void DoWarning (void)
54 /* Warn the user that the dynamic TGI driver is needed for this program */
56 printf ("Warning: This program needs the TGI\n"
57 "driver on disk! Press 'y' if you have\n"
58 "it - any other key exits.\n");
59 if (tolower (cgetc ()) != 'y') {
62 printf ("OK. Please wait patiently...\n");
68 static void DoCircles (void)
70 static const unsigned char Palette[2] = { TGI_COLOR_WHITE, TGI_COLOR_ORANGE };
72 unsigned char Color = COLOR_FORE;
73 unsigned X = MaxX / 2;
74 unsigned Y = MaxY / 2;
76 tgi_setpalette (Palette);
78 tgi_setcolor (COLOR_FORE);
79 tgi_line (0, 0, MaxX, MaxY);
80 tgi_line (0, MaxY, MaxX, 0);
82 for (I = 10; I < 240; I += 10) {
83 tgi_ellipse (X, Y, I, tgi_imulround (I, AspectRatio));
85 Color = Color == COLOR_FORE ? COLOR_BACK : COLOR_FORE;
94 static void DoCheckerboard (void)
96 static const unsigned char Palette[2] = { TGI_COLOR_WHITE, TGI_COLOR_BLACK };
100 tgi_setpalette (Palette);
103 for (Y = 0; Y <= MaxY; Y += 10) {
104 for (X = 0; X <= MaxX; X += 10) {
105 tgi_setcolor (Color);
106 tgi_bar (X, Y, X+9, Y+9);
107 Color = Color == COLOR_FORE ? COLOR_BACK : COLOR_FORE;
114 Color = Color == COLOR_FORE ? COLOR_BACK : COLOR_FORE;
116 Color = Color == COLOR_FORE ? COLOR_BACK : COLOR_FORE;
122 static void DoDiagram (void)
124 static const unsigned char Palette[2] = { TGI_COLOR_WHITE, TGI_COLOR_BLACK };
125 int XOrigin, YOrigin;
130 tgi_setpalette (Palette);
131 tgi_setcolor (COLOR_FORE);
133 /* Determine zero and aplitude */
136 Amp = (MaxY - 19) / 2;
139 tgi_line (XOrigin, 10, XOrigin, MaxY-10);
140 tgi_line (XOrigin-2, 12, XOrigin, 10);
141 tgi_lineto (XOrigin+2, 12);
144 tgi_line (XOrigin, YOrigin, MaxX-10, YOrigin);
145 tgi_line (MaxX-12, YOrigin-2, MaxX-10, YOrigin);
146 tgi_lineto (MaxX-12, YOrigin+2);
149 tgi_gotoxy (XOrigin, YOrigin);
150 for (I = 0; I <= 360; I += 5) {
152 /* Calculate the next points */
153 X = (int) (((long) (MaxX - 19) * I) / 360);
154 Y = (int) (((long) Amp * -_sin (I)) / 256);
157 tgi_lineto (XOrigin + X, YOrigin + Y);
166 static void DoLines (void)
168 static const unsigned char Palette[2] = { TGI_COLOR_WHITE, TGI_COLOR_BLACK };
171 tgi_setpalette (Palette);
172 tgi_setcolor (COLOR_FORE);
174 for (X = 0; X <= MaxY; X += 10) {
175 tgi_line (0, 0, MaxY, X);
176 tgi_line (0, 0, X, MaxY);
177 tgi_line (MaxY, MaxY, 0, MaxY-X);
178 tgi_line (MaxY, MaxY, MaxY-X, 0);
189 unsigned char Border;
192 /* Warn the user that the tgi driver is needed */
195 /* Load and initialize the driver */
196 tgi_load_driver (tgi_stddrv);
197 CheckError ("tgi_load_driver");
199 /* Install the driver */
200 tgi_install (tgi_static_stddrv);
201 CheckError ("tgi_install");
205 CheckError ("tgi_init");
208 /* Get stuff from the driver */
209 MaxX = tgi_getmaxx ();
210 MaxY = tgi_getmaxy ();
211 AspectRatio = tgi_getaspectratio ();
213 /* Set the palette, set the border color */
214 Border = bordercolor (COLOR_BLACK);
216 /* Do graphics stuff */
223 /* Unload the driver */
226 /* Uninstall the driver */
230 /* Reset the border */
231 (void) bordercolor (Border);