3 #include <fastgraf.h> /* FOR PALETTE AND KEYHIT FUNCTIONS */
\r
5 #include "roads.h" /* FOR ANIMATE FUNCTION */
\r
7 /* FX.C-specific DEFINITIONS */
\r
8 #define FADESTEPS 32 /* Number of gradations in the fade -- KEEP BELOW 256 */
\r
9 #define SETDACS_DELAY 0 /* Number of clock ticks to wait between gradations */
\r
11 /****************************************************************************\
\r
15 * Fade one or more DACs from black to their target colors. *
\r
17 \****************************************************************************/
\r
19 void fade_in (int DACstart, int DACend)
\r
23 char new_palette [VCOLORS*3]; /* Temporarily stores palette */
\r
24 char key1, key2; /* USED FOR FOR KEYCHECK */
\r
26 if (DACend<DACstart) /* PREVENT start/end REVERSALS which could crash us */
\r
33 for (i = 0; i <= FADESTEPS; i++)
\r
35 if (abortfadeonkeyhit)
\r
37 fg_intkey (&key1, &key2);
\r
38 if (key1+key2>0) break;
\r
41 for (k=0, n=DACstart*3, j = DACstart; j <= DACend; j++)
\r
43 new_palette[k++] = (long) (default_palette[n++] * i) / FADESTEPS;
\r
44 new_palette[k++] = (long) (default_palette[n++] * i) / FADESTEPS;
\r
45 new_palette[k++] = (long) (default_palette[n++] * i) / FADESTEPS;
\r
48 fg_setdacs (DACstart, DACend-DACstart+1, new_palette);
\r
49 fg_waitfor (SETDACS_DELAY);
\r
50 if (animatewhilefading) animate();
\r
54 /****************************************************************************\
\r
58 * Fade one or more DACs from their current colors to black. *
\r
60 \****************************************************************************/
\r
62 void fade_out (int DACstart, int DACend)
\r
66 char new_palette [VCOLORS*3]; /* Temporarily stores palette */
\r
67 char key1, key2; /* USED FOR FOR KEYCHECK */
\r
69 if (DACend<DACstart) /* PREVENT start/end REVERSALS */
\r
76 for (i = FADESTEPS; i >= 0; i--)
\r
78 if (abortfadeonkeyhit)
\r
80 fg_intkey (&key1, &key2);
\r
81 if (key1+key2>0) break;
\r
84 for (k=0, n=DACstart*3, j = DACstart; j <= DACend; j++)
\r
86 new_palette[k++] = (long) (default_palette[n++] * i) / FADESTEPS;
\r
87 new_palette[k++] = (long) (default_palette[n++] * i) / FADESTEPS;
\r
88 new_palette[k++] = (long) (default_palette[n++] * i) / FADESTEPS;
\r
90 fg_setdacs (DACstart, DACend-DACstart+1, new_palette);
\r
91 fg_waitfor (SETDACS_DELAY);
\r
92 if (animatewhilefading) animate();
\r