11 #define COLOR_BACK COLOR_BLACK
12 #define COLOR_FORE COLOR_WHITE
15 /*****************************************************************************/
17 /*****************************************************************************/
27 /*****************************************************************************/
29 /*****************************************************************************/
33 static void CheckError (const char* S)
35 unsigned char Error = tgi_geterror ();
36 if (Error != TGI_ERR_OK) {
37 printf ("%s: %d\n", S, Error);
44 static void DoWarning (void)
45 /* Warn the user that the TGI driver is needed for this program */
47 printf ("Warning: This program needs the TGI\n"
48 "driver on disk! Press 'y' if you have\n"
49 "it - any other key exits.\n");
50 if (tolower (cgetc ()) != 'y') {
53 printf ("Ok. Please wait patiently...\n");
58 static void DoCircles (void)
60 static const unsigned char Palette[2] = { COLOR_WHITE, COLOR_ORANGE };
62 unsigned char Color = COLOR_FORE;
63 unsigned X = MaxX / 2;
64 unsigned Y = MaxY / 2;
66 tgi_setpalette (Palette);
68 tgi_setcolor (COLOR_FORE);
69 tgi_line (0, 0, MaxX, MaxY);
70 tgi_line (0, MaxY, MaxX, 0);
72 for (I = 10; I < 240; I += 10) {
75 Color = Color == COLOR_FORE ? COLOR_BACK : COLOR_FORE;
84 static void DoCheckerboard (void)
86 static const unsigned char Palette[2] = { COLOR_WHITE, COLOR_BLACK };
90 tgi_setpalette (Palette);
93 for (Y = 0; Y <= MaxY; Y += 10) {
94 for (X = 0; X <= MaxX; X += 10) {
96 tgi_bar (X, Y, X+9, Y+9);
97 Color = Color == COLOR_FORE ? COLOR_BACK : COLOR_FORE;
104 Color = Color == COLOR_FORE ? COLOR_BACK : COLOR_FORE;
106 Color = Color == COLOR_FORE ? COLOR_BACK : COLOR_FORE;
112 static void DoDiagram (void)
114 static const unsigned char Palette[2] = { COLOR_WHITE, COLOR_BLACK };
115 int XOrigin, YOrigin;
120 tgi_setpalette (Palette);
121 tgi_setcolor (COLOR_FORE);
123 /* Determine zero and aplitude */
126 Amp = (MaxY - 19) / 2;
129 tgi_line (XOrigin, 10, XOrigin, MaxY-10);
130 tgi_line (XOrigin-2, 12, XOrigin, 10);
131 tgi_lineto (XOrigin+2, 12);
134 tgi_line (XOrigin, YOrigin, MaxX-10, YOrigin);
135 tgi_line (MaxX-12, YOrigin-2, MaxX-10, YOrigin);
136 tgi_lineto (MaxX-12, YOrigin+2);
139 tgi_gotoxy (XOrigin, YOrigin);
140 for (I = 0; I <= 360; I += 5) {
142 /* Calculate the next points */
143 X = (int) (((long) (MaxX - 19) * I) / 360);
144 Y = (int) (((long) Amp * -cc65_sin (I)) / 256);
147 tgi_lineto (XOrigin + X, YOrigin + Y);
156 static void DoLines (void)
158 static const unsigned char Palette[2] = { COLOR_WHITE, COLOR_BLACK };
161 tgi_setpalette (Palette);
162 tgi_setcolor (COLOR_FORE);
164 for (X = 0; X <= MaxY; X += 10) {
165 tgi_line (0, 0, MaxY, X);
166 tgi_line (0, 0, X, MaxY);
167 tgi_line (MaxY, MaxY, 0, MaxY-X);
168 tgi_line (MaxY, MaxY, MaxY-X, 0);
179 unsigned char Border;
181 /* Warn the user that the tgi driver is needed */
184 /* Load and initialize the driver */
185 tgi_load_driver (tgi_stddrv);
186 CheckError ("tgi_load_driver");
188 CheckError ("tgi_init");
190 /* Get stuff from the driver */
191 MaxX = tgi_getmaxx ();
192 MaxY = tgi_getmaxy ();
194 /* Set the palette, set the border color */
195 Border = bordercolor (COLOR_BLACK);
197 /* Do graphics stuff */
203 /* Unload the driver */
206 /* Reset the border */
207 (void) bordercolor (Border);