aboutsummaryrefslogtreecommitdiff
path: root/src/f_finale.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/f_finale.c')
-rw-r--r--src/f_finale.c668
1 files changed, 668 insertions, 0 deletions
diff --git a/src/f_finale.c b/src/f_finale.c
new file mode 100644
index 0000000..1a96c33
--- /dev/null
+++ b/src/f_finale.c
@@ -0,0 +1,668 @@
1/* Emacs style mode select -*- C++ -*-
2 *-----------------------------------------------------------------------------
3 *
4 *
5 * PrBoom: a Doom port merged with LxDoom and LSDLDoom
6 * based on BOOM, a modified and improved DOOM engine
7 * Copyright (C) 1999 by
8 * id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
9 * Copyright (C) 1999-2000 by
10 * Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
11 * Copyright 2005, 2006 by
12 * Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
27 * 02111-1307, USA.
28 *
29 * DESCRIPTION:
30 * Game completion, final screen animation.
31 *
32 *-----------------------------------------------------------------------------
33 */
34
35#include "doomstat.h"
36#include "d_event.h"
37#include "v_video.h"
38#include "w_wad.h"
39#include "s_sound.h"
40#include "sounds.h"
41#include "d_deh.h" // Ty 03/22/98 - externalizations
42#include "f_finale.h" // CPhipps - hmm...
43
44// Stage of animation:
45// 0 = text, 1 = art screen, 2 = character cast
46static int finalestage; // cph -
47static int finalecount; // made static
48static const char* finaletext; // cph -
49static const char* finaleflat; // made static const
50
51// defines for the end mission display text // phares
52
53#define TEXTSPEED 3 // original value // phares
54#define TEXTWAIT 250 // original value // phares
55#define NEWTEXTSPEED 0.01f // new value // phares
56#define NEWTEXTWAIT 1000 // new value // phares
57
58// CPhipps - removed the old finale screen text message strings;
59// they were commented out for ages already
60// Ty 03/22/98 - ... the new s_WHATEVER extern variables are used
61// in the code below instead.
62
63void F_StartCast (void);
64void F_CastTicker (void);
65boolean F_CastResponder (event_t *ev);
66void F_CastDrawer (void);
67
68void WI_checkForAccelerate(void); // killough 3/28/98: used to
69extern int acceleratestage; // accelerate intermission screens
70static int midstage; // whether we're in "mid-stage"
71
72//
73// F_StartFinale
74//
75void F_StartFinale (void)
76{
77 gameaction = ga_nothing;
78 gamestate = GS_FINALE;
79 automapmode &= ~am_active;
80
81 // killough 3/28/98: clear accelerative text flags
82 acceleratestage = midstage = 0;
83
84 // Okay - IWAD dependend stuff.
85 // This has been changed severly, and
86 // some stuff might have changed in the process.
87 switch ( gamemode )
88 {
89 // DOOM 1 - E1, E3 or E4, but each nine missions
90 case shareware:
91 case registered:
92 case retail:
93 {
94 S_ChangeMusic(mus_victor, true);
95
96 switch (gameepisode)
97 {
98 case 1:
99 finaleflat = bgflatE1; // Ty 03/30/98 - new externalized bg flats
100 finaletext = s_E1TEXT; // Ty 03/23/98 - Was e1text variable.
101 break;
102 case 2:
103 finaleflat = bgflatE2;
104 finaletext = s_E2TEXT; // Ty 03/23/98 - Same stuff for each
105 break;
106 case 3:
107 finaleflat = bgflatE3;
108 finaletext = s_E3TEXT;
109 break;
110 case 4:
111 finaleflat = bgflatE4;
112 finaletext = s_E4TEXT;
113 break;
114 default:
115 // Ouch.
116 break;
117 }
118 break;
119 }
120
121 // DOOM II and missions packs with E1, M34
122 case commercial:
123 {
124 S_ChangeMusic(mus_read_m, true);
125
126 // Ty 08/27/98 - added the gamemission logic
127 switch (gamemap)
128 {
129 case 6:
130 finaleflat = bgflat06;
131 finaletext = (gamemission==pack_tnt) ? s_T1TEXT :
132 (gamemission==pack_plut) ? s_P1TEXT : s_C1TEXT;
133 break;
134 case 11:
135 finaleflat = bgflat11;
136 finaletext = (gamemission==pack_tnt) ? s_T2TEXT :
137 (gamemission==pack_plut) ? s_P2TEXT : s_C2TEXT;
138 break;
139 case 20:
140 finaleflat = bgflat20;
141 finaletext = (gamemission==pack_tnt) ? s_T3TEXT :
142 (gamemission==pack_plut) ? s_P3TEXT : s_C3TEXT;
143 break;
144 case 30:
145 finaleflat = bgflat30;
146 finaletext = (gamemission==pack_tnt) ? s_T4TEXT :
147 (gamemission==pack_plut) ? s_P4TEXT : s_C4TEXT;
148 break;
149 case 15:
150 finaleflat = bgflat15;
151 finaletext = (gamemission==pack_tnt) ? s_T5TEXT :
152 (gamemission==pack_plut) ? s_P5TEXT : s_C5TEXT;
153 break;
154 case 31:
155 finaleflat = bgflat31;
156 finaletext = (gamemission==pack_tnt) ? s_T6TEXT :
157 (gamemission==pack_plut) ? s_P6TEXT : s_C6TEXT;
158 break;
159 default:
160 // Ouch.
161 break;
162 }
163 break;
164 // Ty 08/27/98 - end gamemission logic
165 }
166
167 // Indeterminate.
168 default: // Ty 03/30/98 - not externalized
169 S_ChangeMusic(mus_read_m, true);
170 finaleflat = "F_SKY1"; // Not used anywhere else.
171 finaletext = s_C1TEXT; // FIXME - other text, music?
172 break;
173 }
174
175 finalestage = 0;
176 finalecount = 0;
177}
178
179
180
181boolean F_Responder (event_t *event)
182{
183 if (finalestage == 2)
184 return F_CastResponder (event);
185
186 return false;
187}
188
189// Get_TextSpeed() returns the value of the text display speed // phares
190// Rewritten to allow user-directed acceleration -- killough 3/28/98
191
192static float Get_TextSpeed(void)
193{
194 return midstage ? NEWTEXTSPEED : (midstage=acceleratestage) ?
195 acceleratestage=0, NEWTEXTSPEED : TEXTSPEED;
196}
197
198
199//
200// F_Ticker
201//
202// killough 3/28/98: almost totally rewritten, to use
203// player-directed acceleration instead of constant delays.
204// Now the player can accelerate the text display by using
205// the fire/use keys while it is being printed. The delay
206// automatically responds to the user, and gives enough
207// time to read.
208//
209// killough 5/10/98: add back v1.9 demo compatibility
210//
211
212void F_Ticker(void)
213{
214 int i;
215 if (!demo_compatibility)
216 WI_checkForAccelerate(); // killough 3/28/98: check for acceleration
217 else
218 if (gamemode == commercial && finalecount > 50) // check for skipping
219 for (i=0; i<MAXPLAYERS; i++)
220 if (players[i].cmd.buttons)
221 goto next_level; // go on to the next level
222
223 // advance animation
224 finalecount++;
225
226 if (finalestage == 2)
227 F_CastTicker();
228
229 if (!finalestage)
230 {
231 float speed = demo_compatibility ? TEXTSPEED : Get_TextSpeed();
232 /* killough 2/28/98: changed to allow acceleration */
233 if (finalecount > strlen(finaletext)*speed +
234 (midstage ? NEWTEXTWAIT : TEXTWAIT) ||
235 (midstage && acceleratestage)) {
236 if (gamemode != commercial) // Doom 1 / Ultimate Doom episode end
237 { // with enough time, it's automatic
238 finalecount = 0;
239 finalestage = 1;
240 wipegamestate = -1; // force a wipe
241 if (gameepisode == 3)
242 S_StartMusic(mus_bunny);
243 }
244 else // you must press a button to continue in Doom 2
245 if (!demo_compatibility && midstage)
246 {
247 next_level:
248 if (gamemap == 30)
249 F_StartCast(); // cast of Doom 2 characters
250 else
251 gameaction = ga_worlddone; // next level, e.g. MAP07
252 }
253 }
254 }
255}
256
257//
258// F_TextWrite
259//
260// This program displays the background and text at end-mission // phares
261// text time. It draws both repeatedly so that other displays, // |
262// like the main menu, can be drawn over it dynamically and // V
263// erased dynamically. The TEXTSPEED constant is changed into
264// the Get_TextSpeed function so that the speed of writing the // ^
265// text can be increased, and there's still time to read what's // |
266// written. // phares
267// CPhipps - reformatted
268
269#include "hu_stuff.h"
270extern patchnum_t hu_font[HU_FONTSIZE];
271
272
273static void F_TextWrite (void)
274{
275 V_DrawBackground(finaleflat, 0);
276 { // draw some of the text onto the screen
277 int cx = 10;
278 int cy = 10;
279 const char* ch = finaletext; // CPhipps - const
280 int count = (int)((float)(finalecount - 10)/Get_TextSpeed()); // phares
281 int w;
282
283 if (count < 0)
284 count = 0;
285
286 for ( ; count ; count-- ) {
287 int c = *ch++;
288
289 if (!c)
290 break;
291 if (c == '\n') {
292 cx = 10;
293 cy += 11;
294 continue;
295 }
296
297 c = toupper(c) - HU_FONTSTART;
298 if (c < 0 || c> HU_FONTSIZE) {
299 cx += 4;
300 continue;
301 }
302
303 w = hu_font[c].width;
304 if (cx+w > SCREENWIDTH)
305 break;
306 // CPhipps - patch drawing updated
307 V_DrawNumPatch(cx, cy, 0, hu_font[c].lumpnum, CR_DEFAULT, VPT_STRETCH);
308 cx+=w;
309 }
310 }
311}
312
313//
314// Final DOOM 2 animation
315// Casting by id Software.
316// in order of appearance
317//
318typedef struct
319{
320 const char **name; // CPhipps - const**
321 mobjtype_t type;
322} castinfo_t;
323
324#define MAX_CASTORDER 18 /* Ty - hard coded for now */
325static const castinfo_t castorder[] = { // CPhipps - static const, initialised here
326 { &s_CC_ZOMBIE, MT_POSSESSED },
327 { &s_CC_SHOTGUN, MT_SHOTGUY },
328 { &s_CC_HEAVY, MT_CHAINGUY },
329 { &s_CC_IMP, MT_TROOP },
330 { &s_CC_DEMON, MT_SERGEANT },
331 { &s_CC_LOST, MT_SKULL },
332 { &s_CC_CACO, MT_HEAD },
333 { &s_CC_HELL, MT_KNIGHT },
334 { &s_CC_BARON, MT_BRUISER },
335 { &s_CC_ARACH, MT_BABY },
336 { &s_CC_PAIN, MT_PAIN },
337 { &s_CC_REVEN, MT_UNDEAD },
338 { &s_CC_MANCU, MT_FATSO },
339 { &s_CC_ARCH, MT_VILE },
340 { &s_CC_SPIDER, MT_SPIDER },
341 { &s_CC_CYBER, MT_CYBORG },
342 { &s_CC_HERO, MT_PLAYER },
343 { NULL, 0}
344 };
345
346int castnum;
347int casttics;
348state_t* caststate;
349boolean castdeath;
350int castframes;
351int castonmelee;
352boolean castattacking;
353
354
355//
356// F_StartCast
357//
358
359void F_StartCast (void)
360{
361 wipegamestate = -1; // force a screen wipe
362 castnum = 0;
363 caststate = &states[mobjinfo[castorder[castnum].type].seestate];
364 casttics = caststate->tics;
365 castdeath = false;
366 finalestage = 2;
367 castframes = 0;
368 castonmelee = 0;
369 castattacking = false;
370 S_ChangeMusic(mus_evil, true);
371}
372
373
374//
375// F_CastTicker
376//
377void F_CastTicker (void)
378{
379 int st;
380 int sfx;
381
382 if (--casttics > 0)
383 return; // not time to change state yet
384
385 if (caststate->tics == -1 || caststate->nextstate == S_NULL)
386 {
387 // switch from deathstate to next monster
388 castnum++;
389 castdeath = false;
390 if (castorder[castnum].name == NULL)
391 castnum = 0;
392 if (mobjinfo[castorder[castnum].type].seesound)
393 S_StartSound (NULL, mobjinfo[castorder[castnum].type].seesound);
394 caststate = &states[mobjinfo[castorder[castnum].type].seestate];
395 castframes = 0;
396 }
397 else
398 {
399 // just advance to next state in animation
400 if (caststate == &states[S_PLAY_ATK1])
401 goto stopattack; // Oh, gross hack!
402 st = caststate->nextstate;
403 caststate = &states[st];
404 castframes++;
405
406 // sound hacks....
407 switch (st)
408 {
409 case S_PLAY_ATK1: sfx = sfx_dshtgn; break;
410 case S_POSS_ATK2: sfx = sfx_pistol; break;
411 case S_SPOS_ATK2: sfx = sfx_shotgn; break;
412 case S_VILE_ATK2: sfx = sfx_vilatk; break;
413 case S_SKEL_FIST2: sfx = sfx_skeswg; break;
414 case S_SKEL_FIST4: sfx = sfx_skepch; break;
415 case S_SKEL_MISS2: sfx = sfx_skeatk; break;
416 case S_FATT_ATK8:
417 case S_FATT_ATK5:
418 case S_FATT_ATK2: sfx = sfx_firsht; break;
419 case S_CPOS_ATK2:
420 case S_CPOS_ATK3:
421 case S_CPOS_ATK4: sfx = sfx_shotgn; break;
422 case S_TROO_ATK3: sfx = sfx_claw; break;
423 case S_SARG_ATK2: sfx = sfx_sgtatk; break;
424 case S_BOSS_ATK2:
425 case S_BOS2_ATK2:
426 case S_HEAD_ATK2: sfx = sfx_firsht; break;
427 case S_SKULL_ATK2: sfx = sfx_sklatk; break;
428 case S_SPID_ATK2:
429 case S_SPID_ATK3: sfx = sfx_shotgn; break;
430 case S_BSPI_ATK2: sfx = sfx_plasma; break;
431 case S_CYBER_ATK2:
432 case S_CYBER_ATK4:
433 case S_CYBER_ATK6: sfx = sfx_rlaunc; break;
434 case S_PAIN_ATK3: sfx = sfx_sklatk; break;
435 default: sfx = 0; break;
436 }
437
438 if (sfx)
439 S_StartSound (NULL, sfx);
440 }
441
442 if (castframes == 12)
443 {
444 // go into attack frame
445 castattacking = true;
446 if (castonmelee)
447 caststate=&states[mobjinfo[castorder[castnum].type].meleestate];
448 else
449 caststate=&states[mobjinfo[castorder[castnum].type].missilestate];
450 castonmelee ^= 1;
451 if (caststate == &states[S_NULL])
452 {
453 if (castonmelee)
454 caststate=
455 &states[mobjinfo[castorder[castnum].type].meleestate];
456 else
457 caststate=
458 &states[mobjinfo[castorder[castnum].type].missilestate];
459 }
460 }
461
462 if (castattacking)
463 {
464 if (castframes == 24
465 || caststate == &states[mobjinfo[castorder[castnum].type].seestate] )
466 {
467 stopattack:
468 castattacking = false;
469 castframes = 0;
470 caststate = &states[mobjinfo[castorder[castnum].type].seestate];
471 }
472 }
473
474 casttics = caststate->tics;
475 if (casttics == -1)
476 casttics = 15;
477}
478
479
480//
481// F_CastResponder
482//
483
484boolean F_CastResponder (event_t* ev)
485{
486 if (ev->type != ev_keydown)
487 return false;
488
489 if (castdeath)
490 return true; // already in dying frames
491
492 // go into death frame
493 castdeath = true;
494 caststate = &states[mobjinfo[castorder[castnum].type].deathstate];
495 casttics = caststate->tics;
496 castframes = 0;
497 castattacking = false;
498 if (mobjinfo[castorder[castnum].type].deathsound)
499 S_StartSound (NULL, mobjinfo[castorder[castnum].type].deathsound);
500
501 return true;
502}
503
504
505static void F_CastPrint (const char* text) // CPhipps - static, const char*
506{
507 const char* ch; // CPhipps - const
508 int c;
509 int cx;
510 int w;
511 int width;
512
513 // find width
514 ch = text;
515 width = 0;
516
517 while (ch)
518 {
519 c = *ch++;
520 if (!c)
521 break;
522 c = toupper(c) - HU_FONTSTART;
523 if (c < 0 || c> HU_FONTSIZE)
524 {
525 width += 4;
526 continue;
527 }
528
529 w = hu_font[c].width;
530 width += w;
531 }
532
533 // draw it
534 cx = 160-width/2;
535 ch = text;
536 while (ch)
537 {
538 c = *ch++;
539 if (!c)
540 break;
541 c = toupper(c) - HU_FONTSTART;
542 if (c < 0 || c> HU_FONTSIZE)
543 {
544 cx += 4;
545 continue;
546 }
547
548 w = hu_font[c].width;
549 // CPhipps - patch drawing updated
550 V_DrawNumPatch(cx, 180, 0, hu_font[c].lumpnum, CR_DEFAULT, VPT_STRETCH);
551 cx+=w;
552 }
553}
554
555
556//
557// F_CastDrawer
558//
559
560void F_CastDrawer (void)
561{
562 spritedef_t* sprdef;
563 spriteframe_t* sprframe;
564 int lump;
565 boolean flip;
566
567 // erase the entire screen to a background
568 // CPhipps - patch drawing updated
569 V_DrawNamePatch(0,0,0, bgcastcall, CR_DEFAULT, VPT_STRETCH); // Ty 03/30/98 bg texture extern
570
571 F_CastPrint (*(castorder[castnum].name));
572
573 // draw the current frame in the middle of the screen
574 sprdef = &sprites[caststate->sprite];
575 sprframe = &sprdef->spriteframes[ caststate->frame & FF_FRAMEMASK];
576 lump = sprframe->lump[0];
577 flip = (boolean)sprframe->flip[0];
578
579 // CPhipps - patch drawing updated
580 V_DrawNumPatch(160, 170, 0, lump+firstspritelump, CR_DEFAULT,
581 VPT_STRETCH | (flip ? VPT_FLIP : 0));
582}
583
584//
585// F_BunnyScroll
586//
587static const char pfub2[] = { "PFUB2" };
588static const char pfub1[] = { "PFUB1" };
589
590static void F_BunnyScroll (void)
591{
592 char name[10];
593 int stage;
594 static int laststage;
595
596 {
597 int scrolled = 320 - (finalecount-230)/2;
598 if (scrolled <= 0) {
599 V_DrawNamePatch(0, 0, 0, pfub2, CR_DEFAULT, VPT_STRETCH);
600 } else if (scrolled >= 320) {
601 V_DrawNamePatch(0, 0, 0, pfub1, CR_DEFAULT, VPT_STRETCH);
602 } else {
603 V_DrawNamePatch(320-scrolled, 0, 0, pfub1, CR_DEFAULT, VPT_STRETCH);
604 V_DrawNamePatch(-scrolled, 0, 0, pfub2, CR_DEFAULT, VPT_STRETCH);
605 }
606 }
607
608 if (finalecount < 1130)
609 return;
610 if (finalecount < 1180)
611 {
612 // CPhipps - patch drawing updated
613 V_DrawNamePatch((320-13*8)/2, (200-8*8)/2,0, "END0", CR_DEFAULT, VPT_STRETCH);
614 laststage = 0;
615 return;
616 }
617
618 stage = (finalecount-1180) / 5;
619 if (stage > 6)
620 stage = 6;
621 if (stage > laststage)
622 {
623 S_StartSound (NULL, sfx_pistol);
624 laststage = stage;
625 }
626
627 sprintf (name,"END%i",stage);
628 // CPhipps - patch drawing updated
629 V_DrawNamePatch((320-13*8)/2, (200-8*8)/2, 0, name, CR_DEFAULT, VPT_STRETCH);
630}
631
632
633//
634// F_Drawer
635//
636void F_Drawer (void)
637{
638 if (finalestage == 2)
639 {
640 F_CastDrawer ();
641 return;
642 }
643
644 if (!finalestage)
645 F_TextWrite ();
646 else
647 {
648 switch (gameepisode)
649 {
650 // CPhipps - patch drawing updated
651 case 1:
652 if ( gamemode == retail )
653 V_DrawNamePatch(0, 0, 0, "CREDIT", CR_DEFAULT, VPT_STRETCH);
654 else
655 V_DrawNamePatch(0, 0, 0, "HELP2", CR_DEFAULT, VPT_STRETCH);
656 break;
657 case 2:
658 V_DrawNamePatch(0, 0, 0, "VICTORY2", CR_DEFAULT, VPT_STRETCH);
659 break;
660 case 3:
661 F_BunnyScroll ();
662 break;
663 case 4:
664 V_DrawNamePatch(0, 0, 0, "ENDPIC", CR_DEFAULT, VPT_STRETCH);
665 break;
666 }
667 }
668}