Annotation of doom/f_finale.c, revision 1.1.1.2

1.1       root        1: 
1.1.1.2 ! root        2: //**************************************************************************
        !             3: //**
        !             4: //** f_finale.c : Heretic 2 : Raven Software, Corp.
        !             5: //**
        !             6: //** $RCSfile: f_finale.c,v $
        !             7: //** $Revision: 1.7 $
        !             8: //** $Date: 96/01/05 23:33:26 $
        !             9: //** $Author: bgokey $
        !            10: //**
        !            11: //**************************************************************************
        !            12: 
        !            13: // HEADER FILES ------------------------------------------------------------
        !            14: 
        !            15: #include "h2def.h"
1.1       root       16: #include "soundst.h"
1.1.1.2 ! root       17: #include "p_local.h"
1.1       root       18: #include <ctype.h>
                     19: 
1.1.1.2 ! root       20: // MACROS ------------------------------------------------------------------
        !            21: 
        !            22: #define        TEXTSPEED       3
        !            23: #define        TEXTWAIT        250
        !            24: 
        !            25: // TYPES -------------------------------------------------------------------
        !            26: 
        !            27: // EXTERNAL FUNCTION PROTOTYPES --------------------------------------------
1.1       root       28: 
1.1.1.2 ! root       29: // PUBLIC FUNCTION PROTOTYPES ----------------------------------------------
1.1       root       30: 
1.1.1.2 ! root       31: // PRIVATE FUNCTION PROTOTYPES ---------------------------------------------
1.1       root       32: 
1.1.1.2 ! root       33: static void TextWrite(void);
        !            34: static void DrawPic(void);
        !            35: static void InitializeFade(boolean fadeIn);
        !            36: static void DeInitializeFade(void);
        !            37: static void FadePic(void);
        !            38: static char *GetFinaleText(int sequence);
        !            39: 
        !            40: // EXTERNAL DATA DECLARATIONS ----------------------------------------------
1.1       root       41: 
                     42: extern boolean automapactive;
                     43: extern boolean viewactive;
                     44: 
1.1.1.2 ! root       45: // PUBLIC DATA DECLARATIONS ------------------------------------------------
        !            46: 
        !            47: // PRIVATE DATA DEFINITIONS ------------------------------------------------
        !            48: 
        !            49: static int FinaleStage;
        !            50: static int FinaleCount;
        !            51: static int FinaleEndCount;
        !            52: static int FinaleLumpNum;
        !            53: static int FontABaseLump;
        !            54: static char *FinaleText;
1.1       root       55: 
1.1.1.2 ! root       56: static fixed_t *Palette;
        !            57: static fixed_t *PaletteDelta;
        !            58: static byte *RealPalette;
        !            59: 
        !            60: // CODE --------------------------------------------------------------------
        !            61: 
        !            62: //===========================================================================
        !            63: //
        !            64: // F_StartFinale
        !            65: //
        !            66: //===========================================================================
1.1       root       67: 
                     68: void F_StartFinale (void)
                     69: {
                     70:        gameaction = ga_nothing;
                     71:        gamestate = GS_FINALE;
                     72:        viewactive = false;
                     73:        automapactive = false;
1.1.1.2 ! root       74:        P_ClearMessage(&players[consoleplayer]);
1.1       root       75: 
1.1.1.2 ! root       76:        FinaleStage = 0;
        !            77:        FinaleCount = 0;
        !            78:        FinaleText = GetFinaleText(0);
        !            79:        FinaleEndCount = 70;
        !            80:        FinaleLumpNum = W_GetNumForName("FINALE1");
1.1       root       81:        FontABaseLump = W_GetNumForName("FONTA_S")+1;
1.1.1.2 ! root       82:        InitializeFade(1);
1.1       root       83: 
1.1.1.2 ! root       84: //     S_ChangeMusic(mus_victor, true);
        !            85:        S_StartSongName("hall", false); // don't loop the song
1.1       root       86: }
                     87: 
1.1.1.2 ! root       88: //===========================================================================
        !            89: //
        !            90: // F_Responder
        !            91: //
        !            92: //===========================================================================
1.1       root       93: 
1.1.1.2 ! root       94: boolean F_Responder(event_t *event)
1.1       root       95: {
                     96:        return false;
                     97: }
                     98: 
1.1.1.2 ! root       99: //===========================================================================
        !           100: //
        !           101: // F_Ticker
        !           102: //
        !           103: //===========================================================================
1.1       root      104: 
                    105: void F_Ticker (void)
                    106: {
1.1.1.2 ! root      107:        FinaleCount++;
        !           108:        if(FinaleStage < 5 && FinaleCount >= FinaleEndCount)
1.1       root      109:        {
1.1.1.2 ! root      110:                FinaleCount = 0;
        !           111:                FinaleStage++;
        !           112:                switch(FinaleStage)
1.1       root      113:                {
1.1.1.2 ! root      114:                        case 1: // Text 1
        !           115:                                FinaleEndCount = strlen(FinaleText)*TEXTSPEED+TEXTWAIT;
        !           116:                                break;
        !           117:                        case 2: // Pic 2, Text 2
        !           118:                                FinaleText = GetFinaleText(1);
        !           119:                                FinaleEndCount = strlen(FinaleText)*TEXTSPEED+TEXTWAIT;
        !           120:                                FinaleLumpNum = W_GetNumForName("FINALE2");
        !           121:                                S_StartSongName("orb", false);
        !           122:                                break;
        !           123:                        case 3: // Pic 2 -- Fade out
        !           124:                                FinaleEndCount = 70;
        !           125:                                DeInitializeFade();
        !           126:                                InitializeFade(0);
        !           127:                                break;
        !           128:                        case 4: // Pic 3 -- Fade in
        !           129:                                FinaleLumpNum = W_GetNumForName("FINALE3");
        !           130:                                FinaleEndCount = 71;
        !           131:                                DeInitializeFade();
        !           132:                                InitializeFade(1);
        !           133:                                S_StartSongName("chess", true);
        !           134:                                break;
        !           135:                        case 5: // Pic 3 , Text 3
        !           136:                                FinaleText = GetFinaleText(2);
        !           137:                                DeInitializeFade();
        !           138:                                break;
        !           139:                        default:
        !           140:                                 break;
1.1       root      141:                }
1.1.1.2 ! root      142:                return;
        !           143:        }
        !           144:        if(FinaleStage == 0 || FinaleStage == 3 || FinaleStage == 4)
        !           145:        {
        !           146:                FadePic();
1.1       root      147:        }
                    148: }
                    149: 
1.1.1.2 ! root      150: //===========================================================================
        !           151: //
        !           152: // TextWrite
        !           153: //
        !           154: //===========================================================================
1.1       root      155: 
1.1.1.2 ! root      156: static void TextWrite (void)
1.1       root      157: {
1.1.1.2 ! root      158:        int             count;
        !           159:        char    *ch;
        !           160:        int             c;
        !           161:        int             cx, cy;
1.1       root      162:        patch_t *w;
                    163: 
1.1.1.2 ! root      164:        memcpy(screen, W_CacheLumpNum(FinaleLumpNum, PU_CACHE), 
        !           165:                SCREENWIDTH*SCREENHEIGHT);
        !           166:        if(FinaleStage == 5)
        !           167:        { // Chess pic, draw the correct character graphic
        !           168:                if(netgame)
1.1       root      169:                {
1.1.1.2 ! root      170:                        V_DrawPatch(20, 0, W_CacheLumpName("chessall", PU_CACHE));
1.1       root      171:                }
1.1.1.2 ! root      172:                else if(PlayerClass[consoleplayer])
1.1       root      173:                {
1.1.1.2 ! root      174:                        V_DrawPatch(60, 0, W_CacheLumpNum(W_GetNumForName("chessc")
        !           175:                                +PlayerClass[consoleplayer]-1, PU_CACHE));
1.1       root      176:                }
                    177:        }
1.1.1.2 ! root      178:        // Draw the actual text
        !           179:        if(FinaleStage == 5)
        !           180:        {
        !           181:                cy = 135;
        !           182:        }
        !           183:        else
        !           184:        {
        !           185:                cy = 5;
        !           186:        }
1.1       root      187:        cx = 20;
1.1.1.2 ! root      188:        ch = FinaleText;
        !           189:        count = (FinaleCount-10)/TEXTSPEED;
1.1       root      190:        if (count < 0)
1.1.1.2 ! root      191:        {
1.1       root      192:                count = 0;
1.1.1.2 ! root      193:        }
        !           194:        for(; count; count--)
1.1       root      195:        {
                    196:                c = *ch++;
1.1.1.2 ! root      197:                if(!c)
        !           198:                {
1.1       root      199:                        break;
1.1.1.2 ! root      200:                }
        !           201:                if(c == '\n')
1.1       root      202:                {
                    203:                        cx = 20;
                    204:                        cy += 9;
                    205:                        continue;
                    206:                }
1.1.1.2 ! root      207:                if(c < 32)
        !           208:                {
        !           209:                        continue;
        !           210:                }
1.1       root      211:                c = toupper(c);
1.1.1.2 ! root      212:                if(c == 32)
1.1       root      213:                {
                    214:                        cx += 5;
                    215:                        continue;
                    216:                }
                    217:                w = W_CacheLumpNum(FontABaseLump+c-33, PU_CACHE);
1.1.1.2 ! root      218:                if(cx+w->width > SCREENWIDTH)
        !           219:                {
1.1       root      220:                        break;
1.1.1.2 ! root      221:                }
1.1       root      222:                V_DrawPatch(cx, cy, w);
                    223:                cx += w->width;
                    224:        }
                    225: }
                    226: 
1.1.1.2 ! root      227: //===========================================================================
        !           228: //
        !           229: // InitializeFade
        !           230: //
        !           231: //===========================================================================
1.1       root      232: 
1.1.1.2 ! root      233: static void InitializeFade(boolean fadeIn)
1.1       root      234: {
1.1.1.2 ! root      235:        unsigned i;
1.1       root      236: 
1.1.1.2 ! root      237:        Palette = Z_Malloc(768*sizeof(fixed_t), PU_STATIC, 0);
        !           238:        PaletteDelta = Z_Malloc(768*sizeof(fixed_t), PU_STATIC, 0);
        !           239:        RealPalette = Z_Malloc(768*sizeof(byte), PU_STATIC, 0);
1.1       root      240: 
1.1.1.2 ! root      241:        if(fadeIn)
1.1       root      242:        {
1.1.1.2 ! root      243:                memset(RealPalette, 0, 768*sizeof(byte));
        !           244:                for(i = 0; i < 768; i++)
1.1       root      245:                {
1.1.1.2 ! root      246:                        Palette[i] = 0;
        !           247:                        PaletteDelta[i] = FixedDiv((*((byte *)W_CacheLumpName("playpal", 
        !           248:                                PU_CACHE)+i))<<FRACBITS, 70*FRACUNIT);
1.1       root      249:                }
                    250:        }
1.1.1.2 ! root      251:        else
1.1       root      252:        {
1.1.1.2 ! root      253:                for(i = 0; i < 768; i++)
1.1       root      254:                {
1.1.1.2 ! root      255:                        RealPalette[i] = *((byte *)W_CacheLumpName("playpal", PU_CACHE)+i);
        !           256:                        Palette[i] = RealPalette[i]<<FRACBITS;
        !           257:                        PaletteDelta[i] = FixedDiv(Palette[i], -70*FRACUNIT);
1.1       root      258:                }
                    259:        }
1.1.1.2 ! root      260:        I_SetPalette(RealPalette);
1.1       root      261: }
                    262: 
1.1.1.2 ! root      263: //===========================================================================
        !           264: //
        !           265: // DeInitializeFade
        !           266: //
        !           267: //===========================================================================
1.1       root      268: 
1.1.1.2 ! root      269: static void DeInitializeFade(void)
1.1       root      270: {
1.1.1.2 ! root      271:        Z_Free(Palette);
        !           272:        Z_Free(PaletteDelta);
        !           273:        Z_Free(RealPalette);
1.1       root      274: }
                    275: 
1.1.1.2 ! root      276: //===========================================================================
        !           277: //
        !           278: // FadePic
        !           279: //
        !           280: //===========================================================================
1.1       root      281: 
1.1.1.2 ! root      282: static void FadePic(void)
1.1       root      283: {
1.1.1.2 ! root      284:        unsigned i;
1.1       root      285: 
1.1.1.2 ! root      286:        for(i = 0; i < 768; i++)
1.1       root      287:        {
1.1.1.2 ! root      288:                Palette[i] += PaletteDelta[i];
        !           289:                RealPalette[i] = Palette[i]>>FRACBITS;
1.1       root      290:        }
1.1.1.2 ! root      291:        I_SetPalette(RealPalette);
1.1       root      292: }
                    293: 
1.1.1.2 ! root      294: //===========================================================================
        !           295: //
        !           296: // DrawPic
        !           297: //
        !           298: //===========================================================================
1.1       root      299: 
1.1.1.2 ! root      300: static void DrawPic(void)
1.1       root      301: {
1.1.1.2 ! root      302:        memcpy(screen, W_CacheLumpNum(FinaleLumpNum, PU_CACHE), 
        !           303:                SCREENWIDTH*SCREENHEIGHT);
        !           304:        if(FinaleStage == 4 || FinaleStage == 5)
        !           305:        { // Chess pic, draw the correct character graphic
        !           306:                if(netgame)
        !           307:                {
        !           308:                        V_DrawPatch(20, 0, W_CacheLumpName("chessall", PU_CACHE));
        !           309:                }
        !           310:                else if(PlayerClass[consoleplayer])
        !           311:                {
        !           312:                        V_DrawPatch(60, 0, W_CacheLumpNum(W_GetNumForName("chessc")
        !           313:                                +PlayerClass[consoleplayer]-1, PU_CACHE));
        !           314:                }
1.1       root      315:        }
1.1.1.2 ! root      316: }
1.1       root      317: 
1.1.1.2 ! root      318: //===========================================================================
        !           319: //
        !           320: // F_Drawer
        !           321: //
        !           322: //===========================================================================
1.1       root      323: 
1.1.1.2 ! root      324: void F_Drawer(void)
        !           325: {
        !           326:        switch(FinaleStage)
1.1       root      327:        {
1.1.1.2 ! root      328:                case 0: // Fade in initial finale screen
        !           329:                        DrawPic();
        !           330:                        break;
        !           331:                case 1:
        !           332:                case 2:
        !           333:                        TextWrite();
        !           334:                        break;
        !           335:                case 3: // Fade screen out
        !           336:                        DrawPic();
        !           337:                        break;
        !           338:                case 4: // Fade in chess screen
        !           339:                        DrawPic();
        !           340:                        break;
        !           341:                case 5:
        !           342:                        TextWrite();
        !           343:                        break;
1.1       root      344:        }
1.1.1.2 ! root      345:        UpdateState |= I_FULLSCRN;      
1.1       root      346: }
                    347: 
1.1.1.2 ! root      348: //==========================================================================
        !           349: //
        !           350: // GetFinaleText
        !           351: //
        !           352: //==========================================================================
1.1       root      353: 
1.1.1.2 ! root      354: static char *GetFinaleText(int sequence)
1.1       root      355: {
1.1.1.2 ! root      356:        char *msgLumpName;
        !           357:        int msgSize;
        !           358:        int msgLump;
        !           359:        static char *winMsgLumpNames[] =
        !           360:        {
        !           361:                "win1msg",
        !           362:                "win2msg",
        !           363:                "win3msg"
        !           364:        };
        !           365: 
        !           366:        msgLumpName = winMsgLumpNames[sequence];
        !           367:        msgLump = W_GetNumForName(msgLumpName);
        !           368:        msgSize = W_LumpLength(msgLump);
        !           369:        if(msgSize >= MAX_INTRMSN_MESSAGE_SIZE)
        !           370:        {
        !           371:                I_Error("Finale message too long (%s)", msgLumpName);
        !           372:        }
        !           373:        W_ReadLump(msgLump, ClusterMessage);
        !           374:        ClusterMessage[msgSize] = 0; // Append terminator
        !           375:        return ClusterMessage;
1.1       root      376: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.