1 
2 /*
3  * intro.c
4  *
5  * FRACTINT intro screen (authors & credits)
6  *
7  *
8  */
9 
10 #include <time.h>
11 
12   /* see Fractint.c for a description of the "include"  hierarchy */
13 #include "port.h"
14 #include "prototyp.h"
15 #include "helpdefs.h"
16 
17 /* stuff from fractint */
18 
19 #ifdef XFRACT
20 extern int slowdisplay;
21 #endif
22 
intro(void)23 void intro(void)
24    {
25    /* following overlayed data safe if "putstrings" are resident */
26    static FCODE PRESS_ENTER[] = {"Press ESC for main menu, F1 for help."};
27    int       toprow, botrow, i, j, delaymax;
28    char      oldchar;
29    int       authors[100];              /* this should be enough for awhile */
30    char far *credits;
31    char far *screen_text;
32    int       oldlookatmouse;
33    int       oldhelpmode;
34 
35    timer_start -= clock_ticks();                /* "time out" during help */
36    oldlookatmouse = lookatmouse;
37    oldhelpmode = helpmode;
38    lookatmouse = 0;                     /* de-activate full mouse checking */
39 
40    screen_text = MK_FP(extraseg, 0);
41 
42    i = 32767 + read_help_topic(INTRO_AUTHORS, 0, 32767, screen_text);
43    screen_text[i++] = '\0';
44    credits = screen_text + i;
45    i = 32767 + read_help_topic(INTRO_CREDITS, 0, 32767, credits);
46    credits[i++] = '\0';
47 
48    j = 0;
49    authors[j] = 0;              /* find the start of each credit-line */
50    for (i = 0; credits[i] != 0; i++)
51       if (credits[i] == 10)
52          authors[++j] = i+1;
53    authors[j+1] = i;
54 
55    helptitle();
56 #define END_MAIN_AUTHOR 5
57    toprow = END_MAIN_AUTHOR+1;
58 #ifndef XFRACT
59    botrow = 21;
60 #else
61    botrow = 20;
62    putstringcenter(botrow+1,0,80,C_TITLE,
63    "Unix/X port of fractint by Ken Shirriff");
64 #endif
65    putstringcenter(1,0,80,C_TITLE, PRESS_ENTER);
66    putstring(2,0,C_CONTRIB,screen_text);
67    setattr(2,0,C_AUTHDIV1,80);
68    setattr(END_MAIN_AUTHOR,0,C_AUTHDIV1,80);
69    setattr(3,0,C_PRIMARY,80*(END_MAIN_AUTHOR-3));
70    for (i = 3; i < END_MAIN_AUTHOR; ++i)
71       setattr(i,21,C_CONTRIB,58);
72    setattr(toprow,0,C_CONTRIB,(botrow-END_MAIN_AUTHOR)*80);
73    setattr(botrow+1,0,C_AUTHDIV2,80);
74    setattr(botrow+2,0,C_PROMPT_BKGRD,80);
75    setattr(botrow+3,0,C_TITLE_LOW,160);
76    i = botrow - toprow;
77    srand((unsigned int)clock_ticks());
78    j = rand()%(j-(botrow-toprow)); /* first to use */
79    i = j+botrow-toprow; /* last to use */
80    oldchar = credits[authors[i+1]];
81    credits[authors[i+1]] = 0;
82    putstring(toprow,0,C_CONTRIB,credits+authors[j]);
83    credits[authors[i+1]] = oldchar;
84    delaymax = 10;
85    movecursor(25,80); /* turn it off */
86    helpmode = HELPMENU;
87 
88 #ifdef XFRACT
89    if (slowdisplay) delaymax *= 15;
90 #endif
91 loop_intro:
92    for (j = 0; j < delaymax && !(keypressed()); j++)
93       delay(100);
94    if ((j = keypressed())) /* set j to returned key */
95       getakey();
96    if (menu_checkkey(j,0) || j == 109) /* menu key or 'm' */
97       goto intro_end;
98    if (j == 32) { /* spacebar pauses */
99 wait_again:
100 #ifndef XFRACT
101       while (!keypressed()) ;
102 #else
103       waitkeypressed(0);
104 #endif
105       if ((j = keypressed())) /* set j to returned key */
106          getakey();
107       if (menu_checkkey(j,0) || j == 109) /* menu key or 'm' */
108          goto intro_end;
109       if (j!= 32) /* spacebar */
110          goto wait_again;
111    }
112 
113    scrollup(toprow, botrow);
114    i++;
115    if (credits[authors[i]] == 0)
116       i = 0;
117    oldchar = credits[authors[i+1]];
118    credits[authors[i+1]] = 0;
119    putstring(botrow,0,C_CONTRIB,&credits[authors[i]]);
120    credits[authors[i+1]] = oldchar;
121    movecursor(25,80); /* turn it off */
122    goto loop_intro;
123 
124 intro_end:
125    ungetakey(j);
126    lookatmouse = oldlookatmouse;                /* restore the mouse-checking */
127    helpmode = oldhelpmode;
128    return ;
129    }
130