2015-05-19 21:54:34 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
/*
|
|
|
|
Copyright (C) 1997, 2005 - 3D Realms Entertainment
|
|
|
|
|
|
|
|
This file is part of Shadow Warrior version 1.2
|
|
|
|
|
|
|
|
Shadow Warrior 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
|
|
|
Original Source: 1997 - Frank Maddin and Jim Norwood
|
|
|
|
Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
|
|
|
|
*/
|
|
|
|
//-------------------------------------------------------------------------
|
2019-10-09 16:09:05 +00:00
|
|
|
|
|
|
|
#include "ns.h"
|
2015-05-19 21:54:34 +00:00
|
|
|
#include "build.h"
|
2019-12-17 22:25:07 +00:00
|
|
|
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
#include "keys.h"
|
|
|
|
#include "mytypes.h"
|
|
|
|
#include "gamedefs.h"
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "sounds.h"
|
2019-10-25 22:32:49 +00:00
|
|
|
#include "gamecontrol.h"
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
#include "game.h"
|
|
|
|
#include "colormap.h"
|
2019-03-21 02:24:19 +00:00
|
|
|
#include "network.h"
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
#include "animlib.h"
|
|
|
|
#include "anim.h"
|
2019-12-25 13:13:15 +00:00
|
|
|
#include "../glbackend/glbackend.h"
|
2019-12-31 18:25:49 +00:00
|
|
|
#include "v_2ddrawer.h"
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2019-10-30 05:51:58 +00:00
|
|
|
#include "common_game.h"
|
|
|
|
|
2019-10-09 16:09:05 +00:00
|
|
|
BEGIN_SW_NS
|
|
|
|
|
2015-05-19 21:54:34 +00:00
|
|
|
#define MAX_ANMS 10
|
|
|
|
anim_t *anm_ptr[MAX_ANMS];
|
|
|
|
|
|
|
|
int ANIMnumframes;
|
|
|
|
unsigned char ANIMpal[3*256];
|
|
|
|
unsigned char ANIMnum = 0;
|
|
|
|
short SoundState;
|
2019-10-14 22:54:14 +00:00
|
|
|
static TArray<uint8_t> buffer;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2019-04-08 06:25:22 +00:00
|
|
|
const char *ANIMname[] =
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
"sw.anm",
|
|
|
|
"swend.anm",
|
|
|
|
"sumocinm.anm",
|
|
|
|
"zfcin.anm",
|
|
|
|
};
|
|
|
|
|
|
|
|
#define ANIM_TILE(num) (MAXTILES-11 + (num))
|
|
|
|
|
2015-05-19 21:58:29 +00:00
|
|
|
void AnimShareIntro(int frame, int numframes)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
int zero=0;
|
|
|
|
|
|
|
|
if (frame == numframes-1)
|
|
|
|
ototalclock += 120;
|
|
|
|
else if (frame == 1)
|
|
|
|
{
|
2020-02-17 18:12:05 +00:00
|
|
|
PlaySound(DIGI_NOMESSWITHWANG, v3df_none, CHAN_BODY, CHANF_UI);
|
2015-05-19 21:54:34 +00:00
|
|
|
ototalclock += 120*3;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ototalclock += 8;
|
|
|
|
|
|
|
|
if (frame == 5)
|
|
|
|
{
|
2020-02-17 18:12:05 +00:00
|
|
|
PlaySound(DIGI_INTRO_SLASH, v3df_none, CHAN_BODY, CHANF_UI);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
else if (frame == 15)
|
|
|
|
{
|
2020-02-17 18:12:05 +00:00
|
|
|
PlaySound(DIGI_INTRO_WHIRL, v3df_none, CHAN_BODY, CHANF_UI);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-19 21:58:29 +00:00
|
|
|
void AnimSerp(int frame, int numframes)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
int zero=0;
|
|
|
|
ototalclock += 16;
|
|
|
|
|
|
|
|
if (frame == numframes-1)
|
|
|
|
ototalclock += 1*120;
|
|
|
|
|
|
|
|
if (frame == 1)
|
|
|
|
{
|
2020-02-17 18:12:05 +00:00
|
|
|
PlaySound(DIGI_SERPTAUNTWANG, v3df_none, CHAN_BODY, CHANF_UI);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
else if (frame == 16)
|
|
|
|
{
|
2020-02-17 18:12:05 +00:00
|
|
|
PlaySound(DIGI_SHAREND_TELEPORT, v3df_none, CHAN_BODY, CHANF_UI);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
else if (frame == 35)
|
|
|
|
{
|
|
|
|
SoundState++;
|
2020-02-17 18:12:05 +00:00
|
|
|
PlaySound(DIGI_WANGTAUNTSERP1, v3df_none, CHAN_BODY, CHANF_UI);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
else if (frame == 51)
|
|
|
|
{
|
|
|
|
SoundState++;
|
2020-02-17 18:12:05 +00:00
|
|
|
PlaySound(DIGI_SHAREND_UGLY1, v3df_none, CHAN_BODY, CHANF_UI);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
else if (frame == 64)
|
|
|
|
{
|
|
|
|
SoundState++;
|
2020-02-17 18:12:05 +00:00
|
|
|
PlaySound(DIGI_SHAREND_UGLY2, v3df_none, CHAN_BODY, CHANF_UI);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-19 21:58:29 +00:00
|
|
|
void AnimSumo(int frame, int numframes)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
int zero=0;
|
|
|
|
ototalclock += 10;
|
|
|
|
|
|
|
|
if (frame == numframes-1)
|
|
|
|
ototalclock += 1*120;
|
|
|
|
|
|
|
|
if (frame == 1)
|
|
|
|
ototalclock += 30;
|
|
|
|
|
|
|
|
if (frame == 2)
|
|
|
|
{
|
|
|
|
// hungry
|
2020-02-17 18:12:05 +00:00
|
|
|
PlaySound(DIGI_JG41012, v3df_none, CHAN_BODY, CHANF_UI);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
else if (frame == 30)
|
|
|
|
{
|
2020-02-17 18:12:05 +00:00
|
|
|
PlaySound(DIGI_HOTHEADSWITCH, v3df_none, CHAN_BODY, CHANF_UI);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
else if (frame == 42)
|
|
|
|
{
|
2020-02-17 18:12:05 +00:00
|
|
|
PlaySound(DIGI_HOTHEADSWITCH, v3df_none, CHAN_BODY, CHANF_UI);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
else if (frame == 59)
|
|
|
|
{
|
2020-02-17 18:12:05 +00:00
|
|
|
PlaySound(DIGI_JG41028, v3df_none, CHAN_BODY, CHANF_UI);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-19 21:58:29 +00:00
|
|
|
void AnimZilla(int frame, int numframes)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
int zero=0;
|
|
|
|
ototalclock += 16;
|
|
|
|
|
|
|
|
if (frame == numframes-1)
|
|
|
|
ototalclock += 1*120;
|
|
|
|
|
|
|
|
if (frame == 1)
|
|
|
|
{
|
2020-02-17 18:12:05 +00:00
|
|
|
PlaySound(DIGI_ZC1, v3df_none, CHAN_BODY, CHANF_UI);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
else if (frame == 5)
|
|
|
|
{
|
2020-02-17 18:12:05 +00:00
|
|
|
PlaySound(DIGI_JG94024, v3df_none, CHAN_BODY, CHANF_UI);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
else if (frame == 14)
|
|
|
|
{
|
2020-02-17 18:12:05 +00:00
|
|
|
PlaySound(DIGI_ZC2, v3df_none, CHAN_BODY, CHANF_UI);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
else if (frame == 30)
|
|
|
|
{
|
2020-02-17 18:12:05 +00:00
|
|
|
PlaySound(DIGI_ZC3, v3df_none, CHAN_BODY, CHANF_UI);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
else if (frame == 32)
|
|
|
|
{
|
2020-02-17 18:12:05 +00:00
|
|
|
PlaySound(DIGI_ZC4, v3df_none, CHAN_BODY, CHANF_UI);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
else if (frame == 37)
|
|
|
|
{
|
2020-02-17 18:12:05 +00:00
|
|
|
PlaySound(DIGI_ZC5, v3df_none, CHAN_BODY, CHANF_UI);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
else if (frame == 63)
|
|
|
|
{
|
2020-02-17 18:12:05 +00:00
|
|
|
PlaySound(DIGI_Z16043, v3df_none, CHAN_BODY, CHANF_UI);
|
|
|
|
PlaySound(DIGI_ZC6, v3df_none, CHAN_BODY, CHANF_UI);
|
|
|
|
PlaySound(DIGI_ZC7, v3df_none, CHAN_BODY, CHANF_UI);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
else if (frame == 72)
|
|
|
|
{
|
2020-02-17 18:12:05 +00:00
|
|
|
PlaySound(DIGI_ZC7, v3df_none, CHAN_BODY, CHANF_UI);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
else if (frame == 73)
|
|
|
|
{
|
2020-02-17 18:12:05 +00:00
|
|
|
PlaySound(DIGI_ZC4, v3df_none, CHAN_BODY, CHANF_UI);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
else if (frame == 77)
|
|
|
|
{
|
2020-02-17 18:12:05 +00:00
|
|
|
PlaySound(DIGI_ZC5, v3df_none, CHAN_BODY, CHANF_UI);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
else if (frame == 87)
|
|
|
|
{
|
2020-02-17 18:12:05 +00:00
|
|
|
PlaySound(DIGI_ZC8, v3df_none, CHAN_BODY, CHANF_UI);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
else if (frame == 103)
|
|
|
|
{
|
2020-02-17 18:12:05 +00:00
|
|
|
PlaySound(DIGI_ZC7, v3df_none, CHAN_BODY, CHANF_UI);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
else if (frame == 108)
|
|
|
|
{
|
2020-02-17 18:12:05 +00:00
|
|
|
PlaySound(DIGI_ZC9, v3df_none, CHAN_BODY, CHANF_UI);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
else if (frame == 120)
|
|
|
|
{
|
2020-02-17 18:12:05 +00:00
|
|
|
PlaySound(DIGI_JG94039, v3df_none, CHAN_BODY, CHANF_UI);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
playanm(short anim_num)
|
|
|
|
{
|
2019-10-30 05:51:58 +00:00
|
|
|
unsigned char *animbuf;
|
2020-03-06 15:49:49 +00:00
|
|
|
int i, length = 0, numframes = 0;
|
2015-05-19 21:58:29 +00:00
|
|
|
int32_t handle = -1;
|
2019-11-20 21:01:44 +00:00
|
|
|
|
2015-05-19 21:54:34 +00:00
|
|
|
ANIMnum = anim_num;
|
|
|
|
|
2020-01-01 10:35:47 +00:00
|
|
|
inputState.ClearAllInput();
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
DSPRINTF(ds,"PlayAnm");
|
|
|
|
MONO_PRINT(ds);
|
|
|
|
|
|
|
|
DSPRINTF(ds,"PlayAnm");
|
|
|
|
MONO_PRINT(ds);
|
|
|
|
|
2019-12-19 09:18:05 +00:00
|
|
|
TArray<uint8_t> buffer;
|
|
|
|
auto fr = fileSystem.OpenFileReader(ANIMname[ANIMnum], 0);
|
|
|
|
|
|
|
|
if (!fr.isOpen())
|
|
|
|
goto ENDOFANIMLOOP;
|
|
|
|
|
|
|
|
buffer = fr.ReadPadded(1);
|
|
|
|
fr.Close();
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
DSPRINTF(ds,"PlayAnm - Palette Stuff");
|
|
|
|
MONO_PRINT(ds);
|
|
|
|
|
2019-12-19 09:18:05 +00:00
|
|
|
ANIM_LoadAnim(buffer.Data(), buffer.Size()-1);
|
2015-05-19 21:54:34 +00:00
|
|
|
ANIMnumframes = ANIM_NumFrames();
|
|
|
|
numframes = ANIMnumframes;
|
|
|
|
|
|
|
|
|
2019-04-08 06:26:36 +00:00
|
|
|
videoClearViewableArea(0L);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2019-10-30 05:51:58 +00:00
|
|
|
paletteSetColorTable(ANIMPAL, ANIM_GetPalette());
|
2020-01-26 09:58:00 +00:00
|
|
|
videoSetPalette(0, ANIMPAL, Pal_Fullscreen);
|
2015-05-19 21:54:34 +00:00
|
|
|
if (ANIMnum == 1)
|
|
|
|
{
|
|
|
|
// draw the first frame
|
2019-10-15 21:18:52 +00:00
|
|
|
TileFiles.tileSetExternal(ANIM_TILE(ANIMnum), 200, 320, ANIM_DrawFrame(1));
|
2019-04-08 06:26:36 +00:00
|
|
|
tileInvalidate(ANIM_TILE(ANIMnum), 0, 1<<4);
|
2015-05-19 21:54:34 +00:00
|
|
|
rotatesprite(0 << 16, 0 << 16, 65536L, 512, ANIM_TILE(ANIMnum), 0, 0, 2 + 4 + 8 + 16 + 64, 0, 0, xdim - 1, ydim - 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
SoundState = 0;
|
|
|
|
//ototalclock = totalclock + 120*2;
|
2019-08-27 13:39:54 +00:00
|
|
|
ototalclock = (int32_t) totalclock;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
for (i = 1; i < numframes; i++)
|
|
|
|
{
|
|
|
|
while (totalclock < ototalclock)
|
|
|
|
{
|
|
|
|
handleevents();
|
|
|
|
switch (ANIMnum)
|
|
|
|
{
|
|
|
|
case ANIM_INTRO:
|
|
|
|
case ANIM_SERP:
|
2019-12-24 11:59:26 +00:00
|
|
|
if (inputState.CheckAllInput())
|
2019-12-19 09:18:05 +00:00
|
|
|
{
|
2015-05-19 21:54:34 +00:00
|
|
|
goto ENDOFANIMLOOP;
|
2019-12-19 09:18:05 +00:00
|
|
|
}
|
2015-05-19 21:54:34 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
getpackets();
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (ANIMnum)
|
|
|
|
{
|
|
|
|
case ANIM_INTRO:
|
|
|
|
AnimShareIntro(i,numframes);
|
|
|
|
break;
|
|
|
|
case ANIM_SERP:
|
|
|
|
AnimSerp(i,numframes);
|
|
|
|
break;
|
|
|
|
case ANIM_SUMO:
|
|
|
|
AnimSumo(i,numframes);
|
|
|
|
break;
|
|
|
|
case ANIM_ZILLA:
|
|
|
|
AnimZilla(i,numframes);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2019-12-19 09:18:05 +00:00
|
|
|
TileFiles.tileSetExternal(ANIM_TILE(ANIMnum), 200, 320, ANIM_DrawFrame(i));
|
2019-10-11 19:04:31 +00:00
|
|
|
tileInvalidate(ANIM_TILE(ANIMnum), 0, 1<<4);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
rotatesprite(0 << 16, 0 << 16, 65536L, 512, ANIM_TILE(ANIMnum), 0, 0, 2 + 4 + 8 + 16 + 64, 0, 0, xdim - 1, ydim - 1);
|
2019-04-08 06:26:36 +00:00
|
|
|
videoNextPage();
|
2020-01-27 16:11:21 +00:00
|
|
|
handleevents();
|
|
|
|
if (inputState.CheckAllInput())
|
|
|
|
break;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// pause on final frame
|
|
|
|
while (totalclock < ototalclock)
|
|
|
|
{
|
|
|
|
handleevents();
|
|
|
|
getpackets();
|
|
|
|
}
|
|
|
|
|
|
|
|
ENDOFANIMLOOP:
|
|
|
|
|
2020-01-05 09:48:44 +00:00
|
|
|
twod->ClearScreen();
|
2019-04-08 06:26:36 +00:00
|
|
|
videoNextPage();
|
|
|
|
|
2020-01-26 09:58:00 +00:00
|
|
|
videoSetPalette(0, BASEPAL, 0);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2020-01-01 10:35:47 +00:00
|
|
|
inputState.ClearAllInput();
|
2015-05-19 21:54:34 +00:00
|
|
|
ANIM_FreeAnim();
|
|
|
|
}
|
2019-10-09 16:09:05 +00:00
|
|
|
END_SW_NS
|