summaryrefslogtreecommitdiff
path: root/src/hexen/f_finale.c
diff options
context:
space:
mode:
authorSimon Howard2008-09-05 00:02:14 +0000
committerSimon Howard2008-09-05 00:02:14 +0000
commitc7ddc423f67236a99956960cf9fe89abf077839b (patch)
tree61322034e9d75f1c1a409d1e14ca21ee5c6025c2 /src/hexen/f_finale.c
parent0774dce204c2c01622c59819e2a29590a1b50e46 (diff)
downloadchocolate-doom-c7ddc423f67236a99956960cf9fe89abf077839b.tar.gz
chocolate-doom-c7ddc423f67236a99956960cf9fe89abf077839b.tar.bz2
chocolate-doom-c7ddc423f67236a99956960cf9fe89abf077839b.zip
Reformat (beautify) Raven sources and add GPL headers.
Subversion-branch: /branches/raven-branch Subversion-revision: 1197
Diffstat (limited to 'src/hexen/f_finale.c')
-rw-r--r--src/hexen/f_finale.c475
1 files changed, 245 insertions, 230 deletions
diff --git a/src/hexen/f_finale.c b/src/hexen/f_finale.c
index 53820868..644efb5d 100644
--- a/src/hexen/f_finale.c
+++ b/src/hexen/f_finale.c
@@ -1,14 +1,26 @@
+// Emacs style mode select -*- C++ -*-
+//-----------------------------------------------------------------------------
+//
+// Copyright(C) 1993-1996 Id Software, Inc.
+// Copyright(C) 1993-2008 Raven Software
+//
+// This program 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 2
+// of the License, or (at your option) any later version.
+//
+// This program 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 this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+// 02111-1307, USA.
+//
+//-----------------------------------------------------------------------------
-//**************************************************************************
-//**
-//** f_finale.c : Heretic 2 : Raven Software, Corp.
-//**
-//** $RCSfile: f_finale.c,v $
-//** $Revision: 1.7 $
-//** $Date: 96/01/05 23:33:26 $
-//** $Author: bgokey $
-//**
-//**************************************************************************
// HEADER FILES ------------------------------------------------------------
@@ -65,24 +77,24 @@ static byte *RealPalette;
//
//===========================================================================
-void F_StartFinale (void)
+void F_StartFinale(void)
{
- gameaction = ga_nothing;
- gamestate = GS_FINALE;
- viewactive = false;
- automapactive = false;
- P_ClearMessage(&players[consoleplayer]);
-
- FinaleStage = 0;
- FinaleCount = 0;
- FinaleText = GetFinaleText(0);
- FinaleEndCount = 70;
- FinaleLumpNum = W_GetNumForName("FINALE1");
- FontABaseLump = W_GetNumForName("FONTA_S")+1;
- InitializeFade(1);
-
-// S_ChangeMusic(mus_victor, true);
- S_StartSongName("hall", false); // don't loop the song
+ gameaction = ga_nothing;
+ gamestate = GS_FINALE;
+ viewactive = false;
+ automapactive = false;
+ P_ClearMessage(&players[consoleplayer]);
+
+ FinaleStage = 0;
+ FinaleCount = 0;
+ FinaleText = GetFinaleText(0);
+ FinaleEndCount = 70;
+ FinaleLumpNum = W_GetNumForName("FINALE1");
+ FontABaseLump = W_GetNumForName("FONTA_S") + 1;
+ InitializeFade(1);
+
+// S_ChangeMusic(mus_victor, true);
+ S_StartSongName("hall", false); // don't loop the song
}
//===========================================================================
@@ -91,9 +103,9 @@ void F_StartFinale (void)
//
//===========================================================================
-boolean F_Responder(event_t *event)
+boolean F_Responder(event_t * event)
{
- return false;
+ return false;
}
//===========================================================================
@@ -102,49 +114,49 @@ boolean F_Responder(event_t *event)
//
//===========================================================================
-void F_Ticker (void)
+void F_Ticker(void)
{
- FinaleCount++;
- if(FinaleStage < 5 && FinaleCount >= FinaleEndCount)
- {
- FinaleCount = 0;
- FinaleStage++;
- switch(FinaleStage)
- {
- case 1: // Text 1
- FinaleEndCount = strlen(FinaleText)*TEXTSPEED+TEXTWAIT;
- break;
- case 2: // Pic 2, Text 2
- FinaleText = GetFinaleText(1);
- FinaleEndCount = strlen(FinaleText)*TEXTSPEED+TEXTWAIT;
- FinaleLumpNum = W_GetNumForName("FINALE2");
- S_StartSongName("orb", false);
- break;
- case 3: // Pic 2 -- Fade out
- FinaleEndCount = 70;
- DeInitializeFade();
- InitializeFade(0);
- break;
- case 4: // Pic 3 -- Fade in
- FinaleLumpNum = W_GetNumForName("FINALE3");
- FinaleEndCount = 71;
- DeInitializeFade();
- InitializeFade(1);
- S_StartSongName("chess", true);
- break;
- case 5: // Pic 3 , Text 3
- FinaleText = GetFinaleText(2);
- DeInitializeFade();
- break;
- default:
- break;
- }
- return;
- }
- if(FinaleStage == 0 || FinaleStage == 3 || FinaleStage == 4)
- {
- FadePic();
- }
+ FinaleCount++;
+ if (FinaleStage < 5 && FinaleCount >= FinaleEndCount)
+ {
+ FinaleCount = 0;
+ FinaleStage++;
+ switch (FinaleStage)
+ {
+ case 1: // Text 1
+ FinaleEndCount = strlen(FinaleText) * TEXTSPEED + TEXTWAIT;
+ break;
+ case 2: // Pic 2, Text 2
+ FinaleText = GetFinaleText(1);
+ FinaleEndCount = strlen(FinaleText) * TEXTSPEED + TEXTWAIT;
+ FinaleLumpNum = W_GetNumForName("FINALE2");
+ S_StartSongName("orb", false);
+ break;
+ case 3: // Pic 2 -- Fade out
+ FinaleEndCount = 70;
+ DeInitializeFade();
+ InitializeFade(0);
+ break;
+ case 4: // Pic 3 -- Fade in
+ FinaleLumpNum = W_GetNumForName("FINALE3");
+ FinaleEndCount = 71;
+ DeInitializeFade();
+ InitializeFade(1);
+ S_StartSongName("chess", true);
+ break;
+ case 5: // Pic 3 , Text 3
+ FinaleText = GetFinaleText(2);
+ DeInitializeFade();
+ break;
+ default:
+ break;
+ }
+ return;
+ }
+ if (FinaleStage == 0 || FinaleStage == 3 || FinaleStage == 4)
+ {
+ FadePic();
+ }
}
//===========================================================================
@@ -153,75 +165,76 @@ void F_Ticker (void)
//
//===========================================================================
-static void TextWrite (void)
+static void TextWrite(void)
{
- int count;
- char *ch;
- int c;
- int cx, cy;
- patch_t *w;
-
- memcpy(screen, W_CacheLumpNum(FinaleLumpNum, PU_CACHE),
- SCREENWIDTH*SCREENHEIGHT);
- if(FinaleStage == 5)
- { // Chess pic, draw the correct character graphic
- if(netgame)
- {
- V_DrawPatch(20, 0, W_CacheLumpName("chessall", PU_CACHE));
- }
- else if(PlayerClass[consoleplayer])
- {
- V_DrawPatch(60, 0, W_CacheLumpNum(W_GetNumForName("chessc")
- +PlayerClass[consoleplayer]-1, PU_CACHE));
- }
- }
- // Draw the actual text
- if(FinaleStage == 5)
- {
- cy = 135;
- }
- else
- {
- cy = 5;
- }
- cx = 20;
- ch = FinaleText;
- count = (FinaleCount-10)/TEXTSPEED;
- if (count < 0)
- {
- count = 0;
- }
- for(; count; count--)
- {
- c = *ch++;
- if(!c)
- {
- break;
- }
- if(c == '\n')
- {
- cx = 20;
- cy += 9;
- continue;
- }
- if(c < 32)
- {
- continue;
- }
- c = toupper(c);
- if(c == 32)
- {
- cx += 5;
- continue;
- }
- w = W_CacheLumpNum(FontABaseLump+c-33, PU_CACHE);
- if(cx+w->width > SCREENWIDTH)
- {
- break;
- }
- V_DrawPatch(cx, cy, w);
- cx += w->width;
- }
+ int count;
+ char *ch;
+ int c;
+ int cx, cy;
+ patch_t *w;
+
+ memcpy(screen, W_CacheLumpNum(FinaleLumpNum, PU_CACHE),
+ SCREENWIDTH * SCREENHEIGHT);
+ if (FinaleStage == 5)
+ { // Chess pic, draw the correct character graphic
+ if (netgame)
+ {
+ V_DrawPatch(20, 0, W_CacheLumpName("chessall", PU_CACHE));
+ }
+ else if (PlayerClass[consoleplayer])
+ {
+ V_DrawPatch(60, 0, W_CacheLumpNum(W_GetNumForName("chessc")
+ + PlayerClass[consoleplayer] -
+ 1, PU_CACHE));
+ }
+ }
+ // Draw the actual text
+ if (FinaleStage == 5)
+ {
+ cy = 135;
+ }
+ else
+ {
+ cy = 5;
+ }
+ cx = 20;
+ ch = FinaleText;
+ count = (FinaleCount - 10) / TEXTSPEED;
+ if (count < 0)
+ {
+ count = 0;
+ }
+ for (; count; count--)
+ {
+ c = *ch++;
+ if (!c)
+ {
+ break;
+ }
+ if (c == '\n')
+ {
+ cx = 20;
+ cy += 9;
+ continue;
+ }
+ if (c < 32)
+ {
+ continue;
+ }
+ c = toupper(c);
+ if (c == 32)
+ {
+ cx += 5;
+ continue;
+ }
+ w = W_CacheLumpNum(FontABaseLump + c - 33, PU_CACHE);
+ if (cx + w->width > SCREENWIDTH)
+ {
+ break;
+ }
+ V_DrawPatch(cx, cy, w);
+ cx += w->width;
+ }
}
//===========================================================================
@@ -232,32 +245,34 @@ static void TextWrite (void)
static void InitializeFade(boolean fadeIn)
{
- unsigned i;
-
- Palette = Z_Malloc(768*sizeof(fixed_t), PU_STATIC, 0);
- PaletteDelta = Z_Malloc(768*sizeof(fixed_t), PU_STATIC, 0);
- RealPalette = Z_Malloc(768*sizeof(byte), PU_STATIC, 0);
-
- if(fadeIn)
- {
- memset(RealPalette, 0, 768*sizeof(byte));
- for(i = 0; i < 768; i++)
- {
- Palette[i] = 0;
- PaletteDelta[i] = FixedDiv((*((byte *)W_CacheLumpName("playpal",
- PU_CACHE)+i))<<FRACBITS, 70*FRACUNIT);
- }
- }
- else
- {
- for(i = 0; i < 768; i++)
- {
- RealPalette[i] = *((byte *)W_CacheLumpName("playpal", PU_CACHE)+i);
- Palette[i] = RealPalette[i]<<FRACBITS;
- PaletteDelta[i] = FixedDiv(Palette[i], -70*FRACUNIT);
- }
- }
- I_SetPalette(RealPalette);
+ unsigned i;
+
+ Palette = Z_Malloc(768 * sizeof(fixed_t), PU_STATIC, 0);
+ PaletteDelta = Z_Malloc(768 * sizeof(fixed_t), PU_STATIC, 0);
+ RealPalette = Z_Malloc(768 * sizeof(byte), PU_STATIC, 0);
+
+ if (fadeIn)
+ {
+ memset(RealPalette, 0, 768 * sizeof(byte));
+ for (i = 0; i < 768; i++)
+ {
+ Palette[i] = 0;
+ PaletteDelta[i] = FixedDiv((*((byte *) W_CacheLumpName("playpal",
+ PU_CACHE) +
+ i)) << FRACBITS, 70 * FRACUNIT);
+ }
+ }
+ else
+ {
+ for (i = 0; i < 768; i++)
+ {
+ RealPalette[i] =
+ *((byte *) W_CacheLumpName("playpal", PU_CACHE) + i);
+ Palette[i] = RealPalette[i] << FRACBITS;
+ PaletteDelta[i] = FixedDiv(Palette[i], -70 * FRACUNIT);
+ }
+ }
+ I_SetPalette(RealPalette);
}
//===========================================================================
@@ -268,9 +283,9 @@ static void InitializeFade(boolean fadeIn)
static void DeInitializeFade(void)
{
- Z_Free(Palette);
- Z_Free(PaletteDelta);
- Z_Free(RealPalette);
+ Z_Free(Palette);
+ Z_Free(PaletteDelta);
+ Z_Free(RealPalette);
}
//===========================================================================
@@ -281,14 +296,14 @@ static void DeInitializeFade(void)
static void FadePic(void)
{
- unsigned i;
-
- for(i = 0; i < 768; i++)
- {
- Palette[i] += PaletteDelta[i];
- RealPalette[i] = Palette[i]>>FRACBITS;
- }
- I_SetPalette(RealPalette);
+ unsigned i;
+
+ for (i = 0; i < 768; i++)
+ {
+ Palette[i] += PaletteDelta[i];
+ RealPalette[i] = Palette[i] >> FRACBITS;
+ }
+ I_SetPalette(RealPalette);
}
//===========================================================================
@@ -299,20 +314,21 @@ static void FadePic(void)
static void DrawPic(void)
{
- memcpy(screen, W_CacheLumpNum(FinaleLumpNum, PU_CACHE),
- SCREENWIDTH*SCREENHEIGHT);
- if(FinaleStage == 4 || FinaleStage == 5)
- { // Chess pic, draw the correct character graphic
- if(netgame)
- {
- V_DrawPatch(20, 0, W_CacheLumpName("chessall", PU_CACHE));
- }
- else if(PlayerClass[consoleplayer])
- {
- V_DrawPatch(60, 0, W_CacheLumpNum(W_GetNumForName("chessc")
- +PlayerClass[consoleplayer]-1, PU_CACHE));
- }
- }
+ memcpy(screen, W_CacheLumpNum(FinaleLumpNum, PU_CACHE),
+ SCREENWIDTH * SCREENHEIGHT);
+ if (FinaleStage == 4 || FinaleStage == 5)
+ { // Chess pic, draw the correct character graphic
+ if (netgame)
+ {
+ V_DrawPatch(20, 0, W_CacheLumpName("chessall", PU_CACHE));
+ }
+ else if (PlayerClass[consoleplayer])
+ {
+ V_DrawPatch(60, 0, W_CacheLumpNum(W_GetNumForName("chessc")
+ + PlayerClass[consoleplayer] -
+ 1, PU_CACHE));
+ }
+ }
}
//===========================================================================
@@ -323,26 +339,26 @@ static void DrawPic(void)
void F_Drawer(void)
{
- switch(FinaleStage)
- {
- case 0: // Fade in initial finale screen
- DrawPic();
- break;
- case 1:
- case 2:
- TextWrite();
- break;
- case 3: // Fade screen out
- DrawPic();
- break;
- case 4: // Fade in chess screen
- DrawPic();
- break;
- case 5:
- TextWrite();
- break;
- }
- UpdateState |= I_FULLSCRN;
+ switch (FinaleStage)
+ {
+ case 0: // Fade in initial finale screen
+ DrawPic();
+ break;
+ case 1:
+ case 2:
+ TextWrite();
+ break;
+ case 3: // Fade screen out
+ DrawPic();
+ break;
+ case 4: // Fade in chess screen
+ DrawPic();
+ break;
+ case 5:
+ TextWrite();
+ break;
+ }
+ UpdateState |= I_FULLSCRN;
}
//==========================================================================
@@ -353,24 +369,23 @@ void F_Drawer(void)
static char *GetFinaleText(int sequence)
{
- char *msgLumpName;
- int msgSize;
- int msgLump;
- static char *winMsgLumpNames[] =
- {
- "win1msg",
- "win2msg",
- "win3msg"
- };
-
- msgLumpName = winMsgLumpNames[sequence];
- msgLump = W_GetNumForName(msgLumpName);
- msgSize = W_LumpLength(msgLump);
- if(msgSize >= MAX_INTRMSN_MESSAGE_SIZE)
- {
- I_Error("Finale message too long (%s)", msgLumpName);
- }
- W_ReadLump(msgLump, ClusterMessage);
- ClusterMessage[msgSize] = 0; // Append terminator
- return ClusterMessage;
+ char *msgLumpName;
+ int msgSize;
+ int msgLump;
+ static char *winMsgLumpNames[] = {
+ "win1msg",
+ "win2msg",
+ "win3msg"
+ };
+
+ msgLumpName = winMsgLumpNames[sequence];
+ msgLump = W_GetNumForName(msgLumpName);
+ msgSize = W_LumpLength(msgLump);
+ if (msgSize >= MAX_INTRMSN_MESSAGE_SIZE)
+ {
+ I_Error("Finale message too long (%s)", msgLumpName);
+ }
+ W_ReadLump(msgLump, ClusterMessage);
+ ClusterMessage[msgSize] = 0; // Append terminator
+ return ClusterMessage;
}