Repository navigation
Expand file tree
/
Copy pathtitlepage.c
More file actions
221 lines (188 loc) · 7.31 KB
/
Copy pathtitlepage.c
File metadata and controls
221 lines (188 loc) · 7.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
/*
* Rog-O-Matic
* Automatically exploring the dungeons of doom.
*
* Copyright (C) 2008 by Anthony Molinaro
* Copyright (C) 1985 by Appel, Jacobson, Hamey, and Mauldin.
*
* This file is part of Rog-O-Matic.
*
* Rog-O-Matic is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Rog-O-Matic is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Rog-O-Matic. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* titlepage.c:
*
* This file contains the functions which display the animated copyright
* notice on the screen. A general movie facility is used to animate
* the screen.
*/
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <limits.h>
#include <setjmp.h>
#include "modern_curses.h"
#include "types.h"
#include "globals.h"
#if defined(TITLEPAGE_MAIN)
# include <unistd.h>
bool terse = false;
bool emacs = false;
bool nohalf = false;
#endif
/* static declarations */
static char *titlepage[] = {/* The static part of the display */
" @ !@ \"@ #@ K@! @!$@!K@!P@\" @\"$@\"(@\")@\"*@\"/@\"0@\"1@\"6@\"7@\"8@",
"\"=@\"?@\"C@\"D@\"E@\"I@\"J@\"K@\"L@\"M@\"U@\"V@\"W@\"X@\"]@\"a@\"c@\"e@",
"\"i@# @#!@#\"@##@#'@#+@#.@#2@#5@#9@#<@#>@#@@#F@#K@#P@#T@#^@#`@#c@#e@#i@$",
" @$$@$'@$+@$.@$2@$5@$9@$<@$@@$C@$D@$E@$F@$K@$P@$T@$_@$c@$e@$i@% @%$@%'@%",
"+@%.@%2@%5@%9@%<@%@@%C@%F@%K@%P@%T@%^@%`@%c@%f@%h@& @&%@&(@&)@&*@&/@&0@&",
"1@&2@&6@&7@&8@&<@&@@&D@&E@&G@&L@&Q@&U@&V@&W@&X@&]@&a@&c@&g@'2@(.@(/@(0@(",
"1@);C)<o)=p)>y)?r)@i)Ag)Bh)Ct)E()Fc)G))I1)J9)K8)L5)Nb)Oy*'A*(n*)d**r*+e*",
",w*.A*/p*0p*1e*2l*3,*5L*6e*7o*8n*9a*:r*;d*=H*>a*?m*@e*Ay*B,*DG*Eu*Fy*HJ*",
"Ia*Jc*Ko*Lb*Ms*No*On*P,*Ra*Sn*Td*VM*Wi*Xc*Yh*Za*[e*\\l*^M*_a*`u*al*bd*ci",
"*dn,)@,*@,+@,,@,[D,\\D,]D,^D,_D-(@-+@--@-[D-`D.(@.*@.-@.[D.`D/(@/*@/+@/,",
"@/-@/[D/`D0)@0*@0+@0,@0[D0\\D0]D0^D0_D1 H1!o1\"n1#o1$r1%a1&b1'l1(e1*m1+e",
"1,m1-b1.e1/r11o12f14t15h16e18F19i1:g1;h1<t1=e1>r1?'1@s1BG1Cu1Di1El1Fd2 T",
"2!o2\"t2#a2$l2&w2'i2(n2)n2*e2+r2-a2.g2/a20i21n22s23t25R26o27g28u29e2;22<",
".2=62>,2@S2Ae2Bp2Ct2De2Em2Fb2Ge2Hr2J22K62L,2N12O92P82Q23 T3!o3\"t3#a3$l3",
"&w3'i3(n3)n3*e3+r3-a3.g3/a30i31n32s33t35R36o37g38u39e3;53<.3=23>,3@O3Ac3",
"Bt3Co3Db3Ee3Fr3H13I03J,3L13M93N83O34 T4!o4\"t4#a4$l4&w4'i4(n4)n4*e4+r4-a",
"4.g4/a40i41n42s43t45R46o47g48u49e4;54<.4=34>,4@F4Ae4Bb4Cr4Du4Ea4Fr4Gy4I1",
"4J64K,4M14N94O84P45 T5!o5\"t5#a5$l5&w5'i5(n5)n5*e5+r5-a5.g5/a50i51n52s53",
"t55R56o57g58u59e5;55<.5=45>.5?55@,5BT5CB5DD", /* wrap string to fill lines */
/* add total winner date against 5.4.5 here when it happens */
"6 c6!h6\"o6#n6$g6%o6& 6'<6(L6)a6*n6+d6,o6-n6. 6/C60u61",
"r62t63 64N65o66l67l68>69 6:/6;\\6<.6=.6>/6?\\~~~~~~~~~~~~~~~~~~~~~~~~~~~",
/* The dynamic part of the display */
"~~~~~~~~~~00/~/1/~.2)~-1\\~,0\\~~~.3>~.4=~.5=~.6=~.7=~.8=~.9>~~~.2>.3=.8",
">.9 ~~~.1>.2=.7>.8 ~~~.0>.1=.6>.7 ~~~./>.0=.5>.6 ~~~..>./=.4>.5 ~~~~~~~~",
"~~~~~.. ./>.4 .4=.5>~./ .0>.5=.6>~.0 .1>.6=.7>~.1 .2>.7=.8>~.2).3>.8=.9>",
"~.3 .4>.9=.:>~.4 .5>.:=.;>~.5 .6>.;=.<>~.6 .7>.<=.=>~.7 .8>.==.>>~.8 .9>",
".>=.?>~.9 .:>.?=.@>~.: .;>.@=.A>~.; .<>.A=.B>~.< .=>.B=.C>~.= .>>.C=.D>~",
".> .?>.D=.E>~.? .@>.E=.F>~.@ .A>.F=.G>~.A .B>.G=.H>~.B .C>.H=.I>~.C .D>.",
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the screen. A movie is a list of strings
* wherein each character is either a bell command '}', a synchronize
* command '~', or a triplet <row+32, col+32, char> indicating a character
* to be placed at a specific place on the screen.
*
* Movies run the same speed regardless of baudrate.
*/
static void
animate(char *movie[])
{
int r, c;
char *cbf = "";
struct timespec rqt = {0, 1e7}; /* short 0.01 seconds */
struct timespec rqt2 = {0, 5e8}; /* longer 0.5 seconds */
if (emacs || terse) {
return; /* No screen ==> no movie */
}
clear(); /* Clear the screen */
while (*movie || *cbf) { /* While more animate commands */
r = NEXTCHAR; /* Get command character */
/* Do NOT Ring the Bell */
if (r == '}') {
/* Update the screen and delay until one timestep is gone */
} else if (r == '~') {
if (!quiet) {
refresh(); /* Write out screen */
}
(void)nanosleep(&rqt, NULL);
/* Write out a single character */
} else {
r -= 32; /* Get screen row */
c = NEXTCHAR - 32; /* Get screen col */
mvaddch(r, c, NEXTCHAR); /* Write out character */
}
}
(void)nanosleep(&rqt2, NULL);
}
/*
* halftimeshow: If its time for a halftime show, call movie. Variable
* 'nohalf' is true if the user does not want to see a halftime show.
*/
void
halftimeshow(int level)
{
static int nextshow = 1;
/* do nothing is halftime shows are disabled */
if (nohalf) {
return;
}
/* determine if the level is deep enough */
if (level >= nextshow) {
/* we are deep enough, display the title page */
animate(titlepage);
/* determine the next halftime show level */
switch (nextshow) {
case 1:
nextshow = 12;
break;
case 12:
nextshow = 25;
break;
case 25:
nextshow = 31;
break;
case 31:
nextshow = INT_MAX;
break;
default:
break;
}
}
return;
}
#if defined(TITLEPAGE_MAIN)
bool quiet = false; /* true ==> quiet mode */
int
main(void)
{
/* initialize the Curses package */
initscr();
cbreak();
noecho();
/* display the title page */
animate(titlepage);
/* move to corner of window */
mvcur(0, C - 1, R - 1, 0);
sleep(4);
/* turn on echo and turn off raw */
(void)echo();
(void)nocbreak();
/* clean up and delete curses */
(void)endwin();
(void)delwin(stdscr);
(void)delwin(curscr);
/* All Done!!! -- Jessica Noll, Age 2 */
exit(0);
}
#endif