Advertisement
Guest User

Untitled

a guest
Mar 1st, 2015
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 5.95 KB | None | 0 0
  1. /*******************************************************************************
  2.     FILE:           CREDITS.CPP
  3.  
  4.     DESCRIPTION:
  5.  
  6.     AUTHOR:         Peter M. Freese
  7.     CREATED:        12-05-95
  8.     COPYRIGHT:      Copyright (c) 1995 Q Studios Corporation
  9. *******************************************************************************/
  10.  
  11. #include "credits.h"
  12. #include "key.h"
  13. #include "sound.h"
  14. #include "screen.h"
  15. #include "globals.h"
  16. #include "misc.h"
  17. #include "view.h"
  18. #include "gfx.h"
  19. #include "trig.h"
  20. #include "debug4g.h"
  21.  
  22. #define kDACWaitTicks   2   // ticks between DAC updates
  23.  
  24. char *credits[] =
  25. {
  26.     "Game By",
  27.     "Q Studios",
  28.     "",
  29.     "Project Director",
  30.     "Nick Newhard",
  31.     "",
  32.     "Executive Producer",
  33.     "George Broussard",
  34.     "",
  35.     "Lead Programmer",
  36.     "Peter Freese",
  37.     "",
  38.     "3D Engine",
  39.     "Ken Silverman",
  40.     NULL,
  41.     "Level Design",
  42.     "Jay Wilson",
  43.     "Nick Newhard",
  44.     "Terry Hamel",
  45.     "Kevin Kilstrom",
  46.     "Richard Gray",
  47.     "Vance Andrew Blevins",
  48.     NULL,
  49.     "Artists",
  50.     "Kevin Kilstrom",
  51.     "Terry Hamel",
  52.     "",
  53.     "Creature Models",
  54.     "Kevin Kilstrom",
  55.     "",
  56.     "Additional Art",
  57.     "Rick Welsh",
  58.     "David Brinkley",
  59.     NULL,
  60.     "Music and Sound",
  61.     "LoudMouth",
  62.     "",
  63.     "3D Sound System",
  64.     "Peter Freese",
  65.     "",
  66.     "Audio Technology",
  67.     "Jim Dose",
  68.     "",
  69.     "Network Programming",
  70.     "Mark Dochterman",
  71.     NULL,
  72.     "Special Thanks",
  73.     "Chris Rush",
  74.     "Erik Klokstad",
  75.     "Helen Newhard",
  76.     "Cynthia Freese",
  77.     "Francine Kilstrom",
  78. };
  79.  
  80. static BOOL Wait( int nTicks )
  81. {
  82.     gGameClock = 0;
  83.     while ( gGameClock < nTicks )
  84.         if ( keyGet() != 0 )
  85.             return FALSE;
  86.     return TRUE;
  87. }
  88.  
  89.  
  90. static BOOL DoFade( BYTE r, BYTE g, BYTE b, int nTicks )
  91. {
  92.     dassert(nTicks > 0);
  93.     scrSetupFade(r, g, b);
  94.     gGameClock = gFrameClock = 0;
  95.     do
  96.     {
  97.         while (gGameClock < gFrameClock);
  98.         gFrameClock += kDACWaitTicks;
  99.  
  100.         WaitVSync();
  101.         scrFadeAmount(divscale16(ClipHigh(gGameClock, nTicks), nTicks));
  102.  
  103.         if ( keyGet() != 0 )
  104.             return FALSE;
  105.     } while ( gGameClock <= nTicks );
  106.     return TRUE;
  107. }
  108.  
  109. static BOOL DoUnFade( int nTicks )
  110. {
  111.     dassert(nTicks > 0);
  112.     scrSetupUnfade();
  113.     gGameClock = gFrameClock = 0;
  114.     do
  115.     {
  116.         while (gGameClock < gFrameClock);
  117.         gFrameClock += kDACWaitTicks;
  118.  
  119.         WaitVSync();
  120.         scrFadeAmount(0x10000 - divscale16(ClipHigh(gGameClock, nTicks), nTicks));
  121.  
  122.         if ( keyGet() != 0 )
  123.             return FALSE;
  124.     } while ( gGameClock <= nTicks );
  125.     return TRUE;
  126. }
  127.  
  128. // show logos
  129. void credLogos( void )
  130. {
  131.     int nEffect = 0;
  132.  
  133. //  sndPlaySong("INTRO", FALSE);
  134.  
  135.     // black out dac
  136.     if ( !DoFade(0, 0, 0, 1) ) return;
  137.  
  138.     // castle background
  139.     rotatesprite(320 << 15, 200 << 15, 0x10000, 0, 2046, 0, 0,
  140.         kRotateScale | kRotateNoMask, 0, 0, 319, 199);
  141.     scrNextPage();
  142.  
  143.     if ( !DoUnFade(2 * kTimerRate) ) return;
  144.     if ( !Wait(1 * kTimerRate) ) return;
  145.  
  146.     if ( !DoFade(255, 255, 255, 2) ) return;
  147.  
  148. /*
  149.     // flash the subliminal babe
  150.     rotatesprite(320 << 15, 200 << 15, 0x10000, 0, 2323, 0, 0,
  151.         kRotateScale | kRotateNoMask, 0, 0, 319, 199);
  152.     scrNextPage();
  153.     DoUnFade(1);
  154.     DoFade(255, 255, 255, 1);
  155. */
  156.  
  157.     // castle again
  158.     rotatesprite(320 << 15, 200 << 15, 0x10000, 0, 2046, 0, 0,
  159.         kRotateScale | kRotateNoMask, 0, 0, 319, 199);
  160.     // Q Studios logo
  161.     rotatesprite(320 << 15, 200 << 15, 0x10000, 0, 2047, 0, 0,
  162.         kRotateScale | kRotateNoMask, 0, 0, 319, 199);
  163.     scrNextPage();
  164.  
  165.     sndStartSample("THUNDER2", 255);
  166.  
  167.     if ( !DoUnFade(60) ) return;
  168.  
  169.     if ( !Wait(1 * kTimerRate) ) return;
  170.     sndStartSample("THUNDER", 255);
  171.     if ( !Wait(1 * kTimerRate) ) return;
  172.     if ( !DoFade(0, 0, 0, 60) ) return;
  173.  
  174.     // menu background
  175.     rotatesprite(320 << 15, 200 << 15, 0x10000, 0, 2049, 0, 0,
  176.         kRotateScale | kRotateNoMask, 0, 0, 319, 199);
  177.     scrNextPage();
  178.  
  179.     if ( !DoUnFade(60) ) return;
  180.     sndStartSample("DOORSLID", 255);
  181.     if ( !Wait(2 * kTimerRate) ) return;
  182.     if ( !DoFade(0, 0, 0, 60) ) return;
  183.  
  184.     while ( sndIsSongPlaying() )
  185.     {
  186.         if (keyGet() != 0 )
  187.             return;
  188.     }
  189. }
  190.  
  191.  
  192. static QFONT *pFont;
  193. static int fuseX, fuseY;
  194.  
  195.  
  196. static void DrawCreditText( char *string, int x, int y, int nAlign )
  197. {
  198.     char *s;
  199.     dassert(string != NULL);
  200.  
  201.     setupmvlineasm(16);
  202.  
  203.     if ( nAlign != TA_LEFT )
  204.     {
  205.         int nWidth = -pFont->charSpace;
  206.         for ( s = string; *s; s++ )
  207.             nWidth += pFont->info[*s].hspace + pFont->charSpace;
  208.  
  209.         if ( nAlign == TA_CENTER )
  210.             nWidth >>= 1;
  211.  
  212.         x -= nWidth;
  213.     }
  214.  
  215.     for ( s = string; *s; s++ )
  216.     {
  217.         int nShade = ClipRange(qdist(x - fuseX, y - fuseY) - 16, 0, 56);
  218.         BYTE *pPalookup = palookup[kPLUNormal] + (getpalookup(0, nShade) << 8);
  219.         viewDrawChar(pFont, *s, x, y, pPalookup);
  220.         x += pFont->info[*s].hspace + pFont->charSpace;
  221.     }
  222. }
  223.  
  224.  
  225. #define kLineSpace  14
  226.  
  227.  
  228. // show credits
  229. void credCredits( void )
  230. {
  231.     int n = 0;
  232.     int x, y;
  233.  
  234.     fuseX = -256;
  235.     fuseY = -256;
  236.  
  237.     RESHANDLE hFont = gSysRes.Lookup((long)kFontMessage, ".QFN");
  238.     dassert(hFont != NULL);
  239.     pFont = (QFONT *)gSysRes.Lock(hFont);
  240.  
  241.     sndPlaySong("BLOOD5", FALSE);
  242.  
  243.     // black out dac
  244.     if ( !DoFade(0, 0, 0, 1) ) return;
  245.  
  246.     while ( n < LENGTH(credits) )
  247.     {
  248.         // calculate number of lines to display
  249.         int nLines = 0;
  250.         while ( credits[n + nLines] != NULL )
  251.             nLines++;
  252.  
  253.         // draw the screen
  254.         clearview(0);
  255.         y = (200 - nLines * kLineSpace) / 2;
  256.         for ( int i = 0; i < nLines; i++ )
  257.         {
  258.             DrawCreditText(credits[n + i], 160, y, TA_CENTER);
  259.             y += kLineSpace;
  260.         }
  261.         scrNextPage();
  262.  
  263.         DoUnFade(60);
  264.  
  265.         int y0 = Random(200);
  266.         int y1 = Random(200);
  267.         int nFrame = 0;
  268.         for ( x = -32; x < 320 + 32; x += 1 )
  269.         {
  270.             fuseX = x;
  271.             fuseY = y0 + muldiv(y1 - y0, x, 320);
  272.  
  273.             clearview(0);
  274.             y = (200 - nLines * kLineSpace) / 2;
  275.             for ( int i = 0; i < nLines; i++ )
  276.             {
  277.                 DrawCreditText(credits[n + i], 160, y, TA_CENTER);
  278.                 y += kLineSpace;
  279.             }
  280.  
  281. /*
  282.             nFrame = IncRotate(nFrame, 3);
  283.  
  284.             rotatesprite(fuseX << 16, fuseY << 16, 0x10000 + BiRandom(0x1000),
  285.             (short)BiRandom(kAngle30), (short)(3195 + nFrame),
  286.             -128, kPLUNormal, kRotateStatus, 0, 0, xdim - 1, ydim - 1);
  287. */
  288.             scrNextPage();
  289.  
  290.             Wait(3);
  291.         }
  292.  
  293.         DoFade(0, 0, 0, 60);
  294.  
  295.         n += nLines + 1;
  296.     }
  297.     sndFadeSong(400);
  298.  
  299.     gSysRes.Unlock(hFont);
  300. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement