Debian Codegraph @

prboom2/src/heretic/f_finale.c

raw
1 //
2 // Copyright(C) 1993-1996 Id Software, Inc.
3 // Copyright(C) 1993-2008 Raven Software
4 // Copyright(C) 2005-2014 Simon Howard
5 //
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // F_finale.c
17
18 #include "doomstat.h"
19 #include "w_wad.h"
20 #include "v_video.h"
21 #include "m_menu.h"
22 #include "s_sound.h"
23 #include "sounds.h"
24
25 #include "dsda/palette.h"
26
27 #include "heretic/def.h"
28 #include "heretic/dstrings.h"
29
30 #include "heretic/f_finale.h"
31
32 static int finalestage; // 0 = text, 1 = art screen
33 static int finalecount;
34
35 #define TEXTSPEED 3
36 #define TEXTWAIT 250
37
38 static const char *finaletext;
39 static const char *finaleflat;
40
41 static int FontABaseLump;
42
43 /*
44 =======================
45 =
46 = F_StartFinale
47 =
48 =======================
49 */
50
51 void Heretic_F_StartFinale(void)
52 {
53 gameaction = ga_nothing;
54 gamestate = GS_FINALE;
55 automap_active = false;
56
57 switch (gameepisode)
58 {
59 case 1:
60 finaleflat = "FLOOR25";
61 finaletext = HERETIC_E1TEXT;
62 break;
63 case 2:
64 finaleflat = "FLATHUH1";
65 finaletext = HERETIC_E2TEXT;
66 break;
67 case 3:
68 finaleflat = "FLTWAWA2";
69 finaletext = HERETIC_E3TEXT;
70 break;
71 case 4:
72 finaleflat = "FLOOR28";
73 finaletext = HERETIC_E4TEXT;
74 break;
75 case 5:
76 finaleflat = "FLOOR08";
77 finaletext = HERETIC_E5TEXT;
78 break;
79 }
80
81 finalestage = 0;
82 finalecount = 0;
83 FontABaseLump = W_GetNumForName("FONTA_S") + 1;
84 S_ChangeMusic(heretic_mus_cptd, true);
85 }
86
87 static dboolean F_BlockingInput(void) // Avoid bringing up menu when loading Heretic's custom E2 palette
88 {
89 return finalestage == 1 && gameepisode == 2;
90 }
91
92 dboolean Heretic_F_Responder(event_t * event)
93 {
94 if (F_BlockingInput())
95 { // we're showing the water pic, make any key kick to demo mode
96 V_SetPlayPal(playpal_default);
97 finalestage++;
98 return true;
99 }
100
101 if (event->type != ev_keydown)
102 {
103 return false;
104 }
105
106 return false;
107 }
108
109 /*
110 =======================
111 =
112 = F_Ticker
113 =
114 =======================
115 */
116
117 void Heretic_F_Ticker(void)
118 {
119 finalecount++;
120 if (!finalestage && finalecount > strlen(finaletext) * TEXTSPEED + TEXTWAIT)
121 {
122 finalecount = 0;
123 if (!finalestage)
124 {
125 finalestage = 1;
126 }
127 }
128 }
129
130 /*
131 =======================
132 =
133 = F_TextWrite
134 =
135 =======================
136 */
137
138 void Heretic_F_TextWrite(void)
139 {
140 int count;
141 const char *ch;
142 int c;
143 int cx, cy;
144 int lump;
145 int width;
146
147 // e6y: wide-res
148 V_ClearBorder();
149
150 //
151 // erase the entire screen to a tiled background
152 //
153 V_DrawBackground(finaleflat, 0);
154
155 //
156 // draw some of the text onto the screen
157 //
158 cx = 20;
159 cy = 5;
160 ch = finaletext;
161
162 count = (finalecount - 10) / TEXTSPEED;
163 if (count < 0)
164 count = 0;
165 for (; count; count--)
166 {
167 c = *ch++;
168 if (!c)
169 break;
170 if (c == '\n')
171 {
172 cx = 20;
173 cy += 9;
174 continue;
175 }
176
177 c = toupper(c);
178 if (c < 33)
179 {
180 cx += 5;
181 continue;
182 }
183
184 lump = FontABaseLump + c - 33;
185 width = R_NumPatchWidth(lump);
186 if (cx + width > SCREENWIDTH)
187 break;
188 V_DrawNumPatch(cx, cy, 0, lump, CR_DEFAULT, VPT_STRETCH);
189 cx += width;
190 }
191 }
192
193 /*
194 ==================
195 =
196 = F_DemonScroll
197 =
198 ==================
199 */
200
201 void F_DemonScroll(void)
202 {
203 static int yval = 0;
204 static int nextscroll = 0;
205 int lump_width = W_LumpLength(W_CheckNumForName("FINAL2")) / 200;
206
207 if (finalecount < 70)
208 {
209 V_DrawRawScreen("FINAL1");
210 nextscroll = finalecount;
211 }
212 else if (yval < 200)
213 {
214 V_DrawRawScreenSection("FINAL2", (200 - yval) * lump_width, 0, yval);
215 V_DrawRawScreenSection("FINAL1", 0, yval, 200 - yval);
216 if (finalecount >= nextscroll)
217 {
218 yval++;
219 nextscroll = finalecount + 3;
220 }
221 }
222 else
223 { //else, we'll just sit here and wait, for now
224 V_DrawRawScreen("FINAL2");
225 }
226 }
227
228 /*
229 ==================
230 =
231 = F_DrawUnderwater
232 =
233 ==================
234 */
235
236 void F_DrawUnderwater(void)
237 {
238 switch (finalestage)
239 {
240 case 1:
241 if (menuactive) // Force menu off to avoid bad palette on menu
242 {
243 M_LeaveSetupMenu();
244 M_ClearMenus();
245 S_StartVoidSound(g_sfx_swtchx);
246 }
247 V_SetPlayPal(playpal_heretic_e2end);
248 V_DrawRawScreen("E2END");
249
250 break;
251 case 2:
252 V_DrawRawScreen("TITLE");
253 }
254 }
255
256 /*
257 =======================
258 =
259 = F_Drawer
260 =
261 =======================
262 */
263
264 void Heretic_F_Drawer(void)
265 {
266 if (!finalestage)
267 Heretic_F_TextWrite();
268 else
269 {
270 switch (gameepisode)
271 {
272 case 1:
273 if (gamemode == shareware)
274 {
275 V_DrawRawScreen("ORDER");
276 }
277 else
278 {
279 V_DrawRawScreen("CREDIT");
280 }
281 break;
282 case 2:
283 F_DrawUnderwater();
284 break;
285 case 3:
286 F_DemonScroll();
287 break;
288 case 4: // Just show credits screen for extended episodes
289 case 5:
290 V_DrawRawScreen("CREDIT");
291 break;
292 }
293 }
294 }