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 ()) {
52 static void DoWarning (void)
53 /* Warn the user that the TGI driver is needed for this program */
55 printf ("Warning: This program needs the TGI\n"
56 "driver on disk! Press 'y' if you have\n"
57 "it - any other key exits.\n");
58 if (tolower (cgetc ()) != 'y') {
61 printf ("Ok. Please wait patiently...\n");
66 static void DoCircles (void)
68 static const unsigned char Palette[2] = { TGI_COLOR_WHITE, TGI_COLOR_ORANGE };
70 unsigned char Color = COLOR_FORE;
71 unsigned X = MaxX / 2;
72 unsigned Y = MaxY / 2;
74 tgi_setpalette (Palette);
76 tgi_setcolor (COLOR_FORE);
77 tgi_line (0, 0, MaxX, MaxY);
78 tgi_line (0, MaxY, MaxX, 0);
80 for (I = 10; I < 240; I += 10) {
81 tgi_ellipse (X, Y, I, tgi_imulround (I, AspectRatio));
83 Color = Color == COLOR_FORE ? COLOR_BACK : COLOR_FORE;
92 static void DoCheckerboard (void)
94 static const unsigned char Palette[2] = { TGI_COLOR_WHITE, TGI_COLOR_BLACK };
98 tgi_setpalette (Palette);
101 for (Y = 0; Y <= MaxY; Y += 10) {
102 for (X = 0; X <= MaxX; X += 10) {
103 tgi_setcolor (Color);
104 tgi_bar (X, Y, X+9, Y+9);
105 Color = Color == COLOR_FORE ? COLOR_BACK : COLOR_FORE;
112 Color = Color == COLOR_FORE ? COLOR_BACK : COLOR_FORE;
114 Color = Color == COLOR_FORE ? COLOR_BACK : COLOR_FORE;
120 static void DoDiagram (void)
122 static const unsigned char Palette[2] = { TGI_COLOR_WHITE, TGI_COLOR_BLACK };
123 int XOrigin, YOrigin;
128 tgi_setpalette (Palette);
129 tgi_setcolor (COLOR_FORE);
131 /* Determine zero and aplitude */
134 Amp = (MaxY - 19) / 2;
137 tgi_line (XOrigin, 10, XOrigin, MaxY-10);
138 tgi_line (XOrigin-2, 12, XOrigin, 10);
139 tgi_lineto (XOrigin+2, 12);
142 tgi_line (XOrigin, YOrigin, MaxX-10, YOrigin);
143 tgi_line (MaxX-12, YOrigin-2, MaxX-10, YOrigin);
144 tgi_lineto (MaxX-12, YOrigin+2);
147 tgi_gotoxy (XOrigin, YOrigin);
148 for (I = 0; I <= 360; I += 5) {
150 /* Calculate the next points */
151 X = (int) (((long) (MaxX - 19) * I) / 360);
152 Y = (int) (((long) Amp * -cc65_sin (I)) / 256);
155 tgi_lineto (XOrigin + X, YOrigin + Y);
164 static void DoLines (void)
166 static const unsigned char Palette[2] = { TGI_COLOR_WHITE, TGI_COLOR_BLACK };
169 tgi_setpalette (Palette);
170 tgi_setcolor (COLOR_FORE);
172 for (X = 0; X <= MaxY; X += 10) {
173 tgi_line (0, 0, MaxY, X);
174 tgi_line (0, 0, X, MaxY);
175 tgi_line (MaxY, MaxY, 0, MaxY-X);
176 tgi_line (MaxY, MaxY, MaxY-X, 0);
187 unsigned char Border;
190 /* Warn the user that the tgi driver is needed */
193 /* Load and initialize the driver */
194 tgi_load_driver (tgi_stddrv);
195 CheckError ("tgi_load_driver");
197 /* Install the driver */
198 tgi_install (tgi_static_stddrv);
199 CheckError ("tgi_install");
203 CheckError ("tgi_init");
206 /* Get stuff from the driver */
207 MaxX = tgi_getmaxx ();
208 MaxY = tgi_getmaxy ();
209 AspectRatio = tgi_getaspectratio ();
211 /* Set the palette, set the border color */
212 Border = bordercolor (COLOR_BLACK);
214 /* Do graphics stuff */
221 /* Unload the driver */
224 /* Uninstall the driver */
228 /* Reset the border */
229 (void) bordercolor (Border);