2019-09-19 22:42:45 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
/*
|
|
|
|
Copyright (C) 2010-2019 EDuke32 developers and contributors
|
|
|
|
Copyright (C) 2019 Nuke.YKT
|
|
|
|
|
|
|
|
This file is part of NBlood.
|
|
|
|
|
|
|
|
NBlood is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License version 2
|
|
|
|
as published by the Free Software Foundation.
|
|
|
|
|
|
|
|
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
//-------------------------------------------------------------------------
|
2019-09-21 18:59:54 +00:00
|
|
|
|
|
|
|
#include "ns.h" // Must come before everything else!
|
|
|
|
|
2019-09-19 22:42:45 +00:00
|
|
|
#include "build.h"
|
|
|
|
#include "compat.h"
|
|
|
|
#include "SmackerDecoder.h"
|
|
|
|
#include "fx_man.h"
|
|
|
|
#include "keyboard.h"
|
|
|
|
#include "common_game.h"
|
|
|
|
#include "blood.h"
|
|
|
|
#include "config.h"
|
|
|
|
#include "controls.h"
|
|
|
|
#include "globals.h"
|
|
|
|
#include "resource.h"
|
|
|
|
#include "screen.h"
|
|
|
|
#include "sound.h"
|
|
|
|
#include "view.h"
|
|
|
|
|
2019-09-22 06:39:22 +00:00
|
|
|
BEGIN_BLD_NS
|
|
|
|
|
2019-09-19 22:42:45 +00:00
|
|
|
char exitCredits = 0;
|
|
|
|
|
|
|
|
char Wait(int nTicks)
|
|
|
|
{
|
2019-09-07 13:15:39 +00:00
|
|
|
totalclock = 0;
|
|
|
|
while (totalclock < nTicks)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2019-10-24 14:51:55 +00:00
|
|
|
gameHandleEvents();
|
2019-09-19 22:42:45 +00:00
|
|
|
char key = keyGetScan();
|
|
|
|
if (key)
|
|
|
|
{
|
|
|
|
if (key == sc_Escape) // sc_Escape
|
|
|
|
exitCredits = 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
char DoFade(char r, char g, char b, int nTicks)
|
|
|
|
{
|
2019-09-22 21:55:45 +00:00
|
|
|
#if 0
|
2019-09-19 22:42:45 +00:00
|
|
|
dassert(nTicks > 0);
|
|
|
|
scrSetupFade(r, g, b);
|
2019-09-07 13:15:39 +00:00
|
|
|
totalclock = gFrameClock = 0;
|
2019-09-19 22:42:45 +00:00
|
|
|
do
|
|
|
|
{
|
2019-10-24 14:51:55 +00:00
|
|
|
while (totalclock < gFrameClock) { gameHandleEvents();};
|
2019-09-19 22:42:45 +00:00
|
|
|
gFrameClock += 2;
|
|
|
|
scrNextPage();
|
2019-09-07 13:15:39 +00:00
|
|
|
scrFadeAmount(divscale16(ClipHigh((int)totalclock, nTicks), nTicks));
|
2019-09-19 22:42:45 +00:00
|
|
|
if (keyGetScan())
|
|
|
|
return 0;
|
2019-09-07 13:15:39 +00:00
|
|
|
} while (totalclock <= nTicks);
|
2019-09-22 21:55:45 +00:00
|
|
|
#endif
|
2019-09-19 22:42:45 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
char DoUnFade(int nTicks)
|
|
|
|
{
|
2019-09-22 21:55:45 +00:00
|
|
|
#if 0
|
2019-09-19 22:42:45 +00:00
|
|
|
dassert(nTicks > 0);
|
|
|
|
scrSetupUnfade();
|
2019-09-07 13:15:39 +00:00
|
|
|
totalclock = gFrameClock = 0;
|
2019-09-19 22:42:45 +00:00
|
|
|
do
|
|
|
|
{
|
2019-10-24 14:51:55 +00:00
|
|
|
while (totalclock < gFrameClock) { gameHandleEvents(); };
|
|
|
|
gFrameClock += 2;
|
2019-09-19 22:42:45 +00:00
|
|
|
scrNextPage();
|
2019-09-07 13:15:39 +00:00
|
|
|
scrFadeAmount(0x10000-divscale16(ClipHigh((int)totalclock, nTicks), nTicks));
|
2019-09-19 22:42:45 +00:00
|
|
|
if (keyGetScan())
|
|
|
|
return 0;
|
2019-09-07 13:15:39 +00:00
|
|
|
} while (totalclock <= nTicks);
|
2019-09-22 21:55:45 +00:00
|
|
|
#endif
|
2019-09-19 22:42:45 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void credLogosDos(void)
|
|
|
|
{
|
|
|
|
char bShift = keystatus[sc_LeftShift] | keystatus[sc_RightShift];
|
|
|
|
videoSetViewableArea(0, 0, xdim-1, ydim-1);
|
|
|
|
DoUnFade(1);
|
|
|
|
videoClearScreen(0);
|
|
|
|
if (bShift)
|
|
|
|
return;
|
|
|
|
{
|
|
|
|
//CSMKPlayer smkPlayer;
|
|
|
|
//if (smkPlayer.PlaySMKWithWAV("LOGO.SMK", 300) == 1)
|
|
|
|
//{
|
|
|
|
rotatesprite(160<<16, 100<<16, 65536, 0, 2050, 0, 0, 0x4a, 0, 0, xdim-1, ydim-1);
|
|
|
|
sndStartSample("THUNDER2", 128, -1);
|
|
|
|
scrNextPage();
|
|
|
|
if (!Wait(360))
|
|
|
|
return;
|
|
|
|
if (!DoFade(0, 0, 0, 60))
|
|
|
|
return;
|
|
|
|
//}
|
|
|
|
//if (smkPlayer.PlaySMKWithWAV("GTI.SMK", 301) == 1)
|
|
|
|
//{
|
|
|
|
videoClearScreen(0);
|
|
|
|
rotatesprite(160<<16, 100<<16, 65536, 0, 2052, 0, 0, 0x0a, 0, 0, xdim-1, ydim-1);
|
|
|
|
scrNextPage();
|
|
|
|
DoUnFade(1);
|
|
|
|
sndStartSample("THUNDER2", 128, -1);
|
|
|
|
if (!Wait(360))
|
|
|
|
return;
|
|
|
|
//}
|
|
|
|
}
|
|
|
|
sndPlaySpecialMusicOrNothing(MUS_INTRO);
|
|
|
|
sndStartSample("THUNDER2", 128, -1);
|
|
|
|
if (!DoFade(0, 0, 0, 60))
|
|
|
|
return;
|
|
|
|
videoClearScreen(0);
|
|
|
|
scrNextPage();
|
|
|
|
if (!DoUnFade(1))
|
|
|
|
return;
|
|
|
|
videoClearScreen(0);
|
|
|
|
rotatesprite(160<<16, 100<<16, 65536, 0, 2518, 0, 0, 0x4a, 0, 0, xdim-1, ydim-1);
|
|
|
|
scrNextPage();
|
|
|
|
Wait(360);
|
|
|
|
sndFadeSong(4000);
|
|
|
|
}
|
|
|
|
|
|
|
|
void credReset(void)
|
|
|
|
{
|
|
|
|
videoClearScreen(0);
|
|
|
|
scrNextPage();
|
|
|
|
DoFade(0,0,0,1);
|
|
|
|
scrSetupUnfade();
|
|
|
|
DoUnFade(1);
|
|
|
|
}
|
|
|
|
|
2019-10-21 15:16:08 +00:00
|
|
|
FileReader credKOpen4Load(char *&pzFile)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
|
|
|
int nLen = strlen(pzFile);
|
|
|
|
for (int i = 0; i < nLen; i++)
|
|
|
|
{
|
|
|
|
if (pzFile[i] == '\\')
|
|
|
|
pzFile[i] = '/';
|
|
|
|
}
|
2019-10-21 15:16:08 +00:00
|
|
|
auto nHandle = kopenFileReader(pzFile, 0);
|
|
|
|
if (!nHandle.isOpen())
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
|
|
|
// Hack
|
|
|
|
if (nLen >= 3 && isalpha(pzFile[0]) && pzFile[1] == ':' && pzFile[2] == '/')
|
|
|
|
{
|
|
|
|
pzFile += 3;
|
2019-10-21 15:16:08 +00:00
|
|
|
nHandle = kopenFileReader(pzFile, 0);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return nHandle;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define kSMKPal 5
|
|
|
|
#define kSMKTile (MAXTILES-1)
|
|
|
|
|
|
|
|
void credPlaySmk(const char *_pzSMK, const char *_pzWAV, int nWav)
|
|
|
|
{
|
2019-09-21 11:02:17 +00:00
|
|
|
return;
|
2019-09-19 22:42:45 +00:00
|
|
|
#if 0
|
|
|
|
CSMKPlayer smkPlayer;
|
|
|
|
if (dword_148E14 >= 0)
|
|
|
|
{
|
|
|
|
if (toupper(*pzSMK) == 'A'+dword_148E14)
|
|
|
|
{
|
|
|
|
if (Redbook.sub_82258() == 0 || Redbook.sub_82258() > 20)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
Redbook.sub_82554();
|
|
|
|
}
|
|
|
|
smkPlayer.sub_82E6C(pzSMK, pzWAV);
|
|
|
|
#endif
|
|
|
|
if (Bstrlen(_pzSMK) == 0)
|
|
|
|
return;
|
|
|
|
char *pzSMK = Xstrdup(_pzSMK);
|
|
|
|
char *pzWAV = Xstrdup(_pzWAV);
|
|
|
|
char *pzSMK_ = pzSMK;
|
|
|
|
char *pzWAV_ = pzWAV;
|
2019-10-21 15:16:08 +00:00
|
|
|
auto nHandleSMK = credKOpen4Load(pzSMK);
|
|
|
|
if (!nHandleSMK.isOpen())
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
|
|
|
Bfree(pzSMK_);
|
|
|
|
Bfree(pzWAV_);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
SmackerHandle hSMK = Smacker_Open(pzSMK);
|
|
|
|
if (!hSMK.isValid)
|
|
|
|
{
|
|
|
|
Bfree(pzSMK_);
|
|
|
|
Bfree(pzWAV_);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
uint32_t nWidth, nHeight;
|
|
|
|
Smacker_GetFrameSize(hSMK, nWidth, nHeight);
|
|
|
|
uint8_t palette[768];
|
2019-10-11 19:04:31 +00:00
|
|
|
tileDelete(kSMKTile);
|
2019-10-15 21:18:52 +00:00
|
|
|
auto pFrame = TileFiles.tileCreate(kSMKTile, nWidth, nHeight);
|
2019-09-19 22:42:45 +00:00
|
|
|
if (!pFrame)
|
|
|
|
{
|
|
|
|
Smacker_Close(hSMK);
|
|
|
|
Bfree(pzSMK_);
|
|
|
|
Bfree(pzWAV_);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
int nFrameRate = Smacker_GetFrameRate(hSMK);
|
|
|
|
int nFrames = Smacker_GetNumFrames(hSMK);
|
|
|
|
|
|
|
|
Smacker_GetPalette(hSMK, palette);
|
2019-10-06 17:32:35 +00:00
|
|
|
paletteSetColorTable(kSMKPal, palette, true);
|
2019-10-27 12:40:24 +00:00
|
|
|
videoSetPalette(0, kSMKPal, 8+2);
|
2019-09-19 22:42:45 +00:00
|
|
|
|
|
|
|
int nScale;
|
|
|
|
|
|
|
|
if ((nWidth / (nHeight * 1.2f)) > (1.f * xdim / ydim))
|
|
|
|
nScale = divscale16(320 * xdim * 3, nWidth * ydim * 4);
|
|
|
|
else
|
|
|
|
nScale = divscale16(200, nHeight);
|
|
|
|
|
|
|
|
if (nWav)
|
2019-10-22 00:01:05 +00:00
|
|
|
sndStartWavID(nWav, snd_fxvolume);
|
2019-09-19 22:42:45 +00:00
|
|
|
else
|
|
|
|
{
|
2019-10-21 15:16:08 +00:00
|
|
|
auto nHandleWAV = credKOpen4Load(pzWAV);
|
|
|
|
if (nHandleWAV.isOpen())
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2019-10-22 00:01:05 +00:00
|
|
|
sndStartWavDisk(pzWAV, snd_fxvolume);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
UpdateDacs(0, true);
|
|
|
|
|
2019-10-24 14:51:55 +00:00
|
|
|
gameHandleEvents();
|
2019-09-07 13:15:39 +00:00
|
|
|
ClockTicks nStartTime = totalclock;
|
2019-09-19 22:42:45 +00:00
|
|
|
|
|
|
|
ctrlClearAllInput();
|
|
|
|
|
|
|
|
int nFrame = 0;
|
|
|
|
do
|
|
|
|
{
|
2019-10-24 13:25:34 +00:00
|
|
|
gameHandleEvents();
|
2019-09-07 13:15:39 +00:00
|
|
|
if (scale((int)(totalclock-nStartTime), nFrameRate, kTicRate) < nFrame)
|
2019-09-19 22:42:45 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
if (ctrlCheckAllInput())
|
|
|
|
break;
|
|
|
|
|
|
|
|
videoClearScreen(0);
|
|
|
|
Smacker_GetPalette(hSMK, palette);
|
2019-10-06 17:32:35 +00:00
|
|
|
paletteSetColorTable(kSMKPal, palette, true);
|
2019-10-27 12:40:24 +00:00
|
|
|
videoSetPalette(0, kSMKPal, 0);
|
2019-09-19 22:42:45 +00:00
|
|
|
tileInvalidate(kSMKTile, 0, 1 << 4); // JBF 20031228
|
|
|
|
Smacker_GetFrame(hSMK, pFrame);
|
|
|
|
rotatesprite_fs(160<<16, 100<<16, nScale, 512, kSMKTile, 0, 0, 2|4|8|64);
|
|
|
|
|
|
|
|
videoNextPage();
|
|
|
|
|
|
|
|
ctrlClearAllInput();
|
|
|
|
nFrame++;
|
|
|
|
Smacker_GetNextFrame(hSMK);
|
|
|
|
} while(nFrame < nFrames);
|
|
|
|
|
|
|
|
Smacker_Close(hSMK);
|
|
|
|
ctrlClearAllInput();
|
|
|
|
FX_StopAllSounds();
|
2019-10-27 12:40:24 +00:00
|
|
|
videoSetPalette(0, 0, 8+2);
|
2019-10-11 19:04:31 +00:00
|
|
|
tileDelete(kSMKTile);
|
2019-09-19 22:42:45 +00:00
|
|
|
Bfree(pzSMK_);
|
|
|
|
Bfree(pzWAV_);
|
|
|
|
}
|
2019-09-22 06:39:22 +00:00
|
|
|
|
|
|
|
END_BLD_NS
|