2019-11-20 16:21:32 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
/*
|
|
|
|
Copyright (C) 2010-2019 EDuke32 developers and contributors
|
|
|
|
Copyright (C) 2019 sirlemonhead, Nuke.YKT
|
|
|
|
This file is part of PCExhumed.
|
|
|
|
PCExhumed 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-11-22 23:11:37 +00:00
|
|
|
#include "ns.h"
|
2020-08-23 12:55:19 +00:00
|
|
|
#include "glbackend/glbackend.h"
|
2019-08-26 03:59:14 +00:00
|
|
|
#include "sequence.h"
|
|
|
|
#include "engine.h"
|
|
|
|
#include "exhumed.h"
|
|
|
|
#include "sound.h"
|
|
|
|
#include "player.h"
|
2020-08-18 07:52:08 +00:00
|
|
|
#include "aistuff.h"
|
2019-08-26 03:59:14 +00:00
|
|
|
#include "view.h"
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
// TEMP
|
|
|
|
#include <assert.h>
|
|
|
|
|
2019-11-22 23:11:37 +00:00
|
|
|
BEGIN_PS_NS
|
|
|
|
|
2019-08-26 03:59:14 +00:00
|
|
|
#define kMaxSequences 4096
|
|
|
|
#define kMaxSEQFiles 78
|
|
|
|
#define kMaxSEQFrames 18000
|
|
|
|
#define kMaxSEQChunks 21000
|
|
|
|
|
|
|
|
short sequences = 0;
|
|
|
|
short frames = 0;
|
|
|
|
short chunks = 0;
|
|
|
|
short nPilotLightFrame;
|
|
|
|
short nPilotLightCount;
|
|
|
|
|
|
|
|
short nPilotLightBase;
|
|
|
|
|
|
|
|
short nShadowWidth = 1;
|
|
|
|
short nFlameHeight = 1;
|
|
|
|
|
|
|
|
short SeqBase[kMaxSequences];
|
|
|
|
short SeqSize[kMaxSequences];
|
|
|
|
short SeqFlag[kMaxSequences];
|
|
|
|
|
|
|
|
short FrameSound[kMaxSEQFrames];
|
|
|
|
short FrameSize[kMaxSEQFrames];
|
|
|
|
short FrameBase[kMaxSEQFrames];
|
|
|
|
short FrameFlag[kMaxSEQFrames];
|
|
|
|
|
|
|
|
short ChunkYpos[kMaxSEQChunks];
|
|
|
|
short ChunkXpos[kMaxSEQChunks];
|
|
|
|
short ChunkPict[kMaxSEQChunks];
|
|
|
|
short ChunkFlag[kMaxSEQChunks];
|
|
|
|
|
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
const char *SeqNames[kMaxSEQFiles] =
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
|
|
|
"rothands",
|
|
|
|
"sword",
|
|
|
|
"pistol",
|
|
|
|
"m_60",
|
|
|
|
"flamer", // 4
|
|
|
|
"grenade",
|
|
|
|
"cobra",
|
|
|
|
"bonesaw",
|
|
|
|
"scramble",
|
|
|
|
"glove",
|
|
|
|
"mummy", // 10
|
|
|
|
"skull",
|
|
|
|
"poof",
|
|
|
|
"kapow",
|
|
|
|
"fireball",
|
|
|
|
"bubble",
|
|
|
|
"spider", // 16
|
|
|
|
"anubis",
|
|
|
|
"anuball",
|
|
|
|
"fish",
|
|
|
|
"snakehed", // 20?
|
|
|
|
"snakbody",
|
|
|
|
"wasp",
|
|
|
|
"cobrapow",
|
|
|
|
"scorp",
|
|
|
|
"joe", // 25
|
|
|
|
"status",
|
|
|
|
"dead",
|
|
|
|
"deadex",
|
|
|
|
"anupoof",
|
|
|
|
"skulpoof", // 30
|
|
|
|
"bullet",
|
|
|
|
"shadow",
|
|
|
|
"grenroll",
|
|
|
|
"grenboom",
|
|
|
|
"splash",
|
|
|
|
"grenpow",
|
|
|
|
"skulstrt",
|
|
|
|
"firepoof",
|
|
|
|
"bloodhit",
|
|
|
|
"lion", // 40
|
|
|
|
"items",
|
|
|
|
"lavag", // 42
|
|
|
|
"lsplash",
|
|
|
|
"lavashot",
|
|
|
|
"smokebal",
|
|
|
|
"firepot",
|
|
|
|
"rex",
|
|
|
|
"set", // 48
|
|
|
|
"queen",
|
|
|
|
"roach", // 50
|
|
|
|
"hawk",
|
|
|
|
"setghost",
|
|
|
|
"setgblow",
|
|
|
|
"bizztail",
|
|
|
|
"bizzpoof",
|
|
|
|
"queenegg",
|
|
|
|
"roacshot",
|
|
|
|
"backgrnd",
|
|
|
|
"screens", // 59
|
|
|
|
"arrow",
|
|
|
|
"fonts",
|
|
|
|
"drips",
|
|
|
|
"firetrap",
|
|
|
|
"magic2",
|
|
|
|
"creepy",
|
|
|
|
"slider", // 66
|
|
|
|
"ravolt",
|
|
|
|
"eyehit",
|
|
|
|
"font2", // 69
|
|
|
|
"seebubbl",
|
|
|
|
"blood",
|
|
|
|
"drum",
|
|
|
|
"poof2",
|
|
|
|
"deadbrn",
|
|
|
|
"grenbubb",
|
|
|
|
"rochfire",
|
|
|
|
"rat"
|
|
|
|
};
|
|
|
|
|
|
|
|
short SeqOffsets[kMaxSEQFiles];
|
|
|
|
|
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
int seq_ReadSequence(const char *seqName)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2019-08-31 07:47:15 +00:00
|
|
|
int i;
|
|
|
|
char buffer[200];
|
|
|
|
buffer[0] = '\0';
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
strcat(buffer, seqName);
|
|
|
|
strcat(buffer, ".seq");
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2020-02-24 20:59:04 +00:00
|
|
|
auto hFile = fileSystem.ReopenFileReader(fileSystem.FindFile(buffer), true);
|
2019-11-24 12:59:36 +00:00
|
|
|
if (!hFile.isOpen())
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2020-04-11 21:45:45 +00:00
|
|
|
Printf("Unable to open '%s'!\n", buffer);
|
2019-08-31 07:47:15 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
short tag;
|
2019-11-24 12:59:36 +00:00
|
|
|
hFile.Read(&tag, sizeof(tag));
|
2020-01-08 00:00:57 +00:00
|
|
|
if (tag < MAKE_ID('I', 'H', 0, 0) || (tag > MAKE_ID('I', 'H', 0, 0) && tag != MAKE_ID('D', 'S', 0, 0)))
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2020-04-11 21:45:45 +00:00
|
|
|
Printf("Unsupported sequence version!\n");
|
2019-08-31 07:47:15 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
short centerx, centery; // TODO - are global vars?
|
2019-11-20 16:21:32 +00:00
|
|
|
short nSeqs;
|
2019-11-24 12:59:36 +00:00
|
|
|
hFile.Read(¢erx, sizeof(centerx));
|
|
|
|
hFile.Read(¢ery, sizeof(centery));
|
|
|
|
hFile.Read(&nSeqs, sizeof(nSeqs));
|
2019-08-31 07:47:15 +00:00
|
|
|
|
|
|
|
if (nSeqs <= 0 || sequences + nSeqs >= kMaxSequences)
|
|
|
|
{
|
2019-11-20 16:21:32 +00:00
|
|
|
if (nSeqs < 0)
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2020-04-11 21:45:45 +00:00
|
|
|
Printf("Invalid sequence count!\n");
|
2019-08-31 07:47:15 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else {
|
2019-11-24 09:03:19 +00:00
|
|
|
I_Error("Not enough sequences available! Increase array!\n");
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-24 12:59:36 +00:00
|
|
|
hFile.Read(&SeqBase[sequences], nSeqs * sizeof(SeqBase[0]));
|
|
|
|
hFile.Read(&SeqSize[sequences], nSeqs * sizeof(SeqSize[0]));
|
|
|
|
hFile.Read(&SeqFlag[sequences], nSeqs * sizeof(SeqFlag[0]));
|
2019-08-31 07:47:15 +00:00
|
|
|
|
|
|
|
for (i = 0; i < nSeqs; i++)
|
|
|
|
{
|
|
|
|
SeqBase[sequences + i] += frames;
|
|
|
|
}
|
|
|
|
|
2019-09-19 13:38:28 +00:00
|
|
|
short vdi = frames;
|
|
|
|
|
2019-08-31 09:08:38 +00:00
|
|
|
int16_t nFrames;
|
2019-11-24 12:59:36 +00:00
|
|
|
hFile.Read(&nFrames, sizeof(nFrames));
|
2019-08-31 07:47:15 +00:00
|
|
|
|
|
|
|
if (nFrames <= 0 || frames + nFrames >= kMaxSEQFrames)
|
|
|
|
{
|
|
|
|
if (nFrames < 0 )
|
|
|
|
{
|
2020-04-11 21:45:45 +00:00
|
|
|
Printf("Invalid frame count!\n");
|
2019-08-31 07:47:15 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else {
|
2019-11-24 09:03:19 +00:00
|
|
|
I_Error("Not enough frames available! Increase FRAMEMAX!\n");
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-24 12:59:36 +00:00
|
|
|
hFile.Read(&FrameBase[frames], nFrames * sizeof(FrameBase[0]));
|
|
|
|
hFile.Read(&FrameSize[frames], nFrames * sizeof(FrameSize[0]));
|
|
|
|
hFile.Read(&FrameFlag[frames], nFrames * sizeof(FrameFlag[0]));
|
2019-08-31 07:47:15 +00:00
|
|
|
memset(&FrameSound[frames], -1, nFrames * sizeof(FrameSound[0]));
|
|
|
|
|
|
|
|
for (i = 0; i < nFrames; i++)
|
|
|
|
{
|
|
|
|
FrameBase[frames + i] += chunks;
|
|
|
|
}
|
|
|
|
|
2019-08-31 09:08:38 +00:00
|
|
|
int16_t nChunks;
|
2019-11-24 12:59:36 +00:00
|
|
|
hFile.Read(&nChunks, sizeof(nChunks));
|
2019-08-31 07:47:15 +00:00
|
|
|
|
|
|
|
if (nChunks < 0 || chunks + nChunks >= kMaxSEQChunks)
|
|
|
|
{
|
|
|
|
if (nChunks < 0 )
|
|
|
|
{
|
2020-04-11 21:45:45 +00:00
|
|
|
Printf("Invalid chunk count!\n");
|
2019-08-31 07:47:15 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else {
|
2019-11-24 09:03:19 +00:00
|
|
|
I_Error("Not enough chunks available! Increase CHUNKMAX!\n");
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-24 12:59:36 +00:00
|
|
|
hFile.Read(&ChunkXpos[chunks], nChunks * sizeof(ChunkXpos[0]));
|
|
|
|
hFile.Read(&ChunkYpos[chunks], nChunks * sizeof(ChunkYpos[0]));
|
|
|
|
hFile.Read(&ChunkPict[chunks], nChunks * sizeof(ChunkPict[0]));
|
|
|
|
hFile.Read(&ChunkFlag[chunks], nChunks * sizeof(ChunkFlag[0]));
|
2019-08-31 07:47:15 +00:00
|
|
|
|
|
|
|
for (i = 0; i < nChunks; i++)
|
|
|
|
{
|
|
|
|
ChunkXpos[chunks + i] -= centerx;
|
|
|
|
ChunkYpos[chunks + i] -= centery;
|
|
|
|
}
|
|
|
|
|
|
|
|
sequences += nSeqs;
|
|
|
|
FrameBase[frames + nFrames] = chunks + nChunks;
|
|
|
|
frames += nFrames;
|
|
|
|
SeqBase[sequences] = frames;
|
|
|
|
chunks += nChunks;
|
|
|
|
|
2020-01-08 00:00:57 +00:00
|
|
|
if (tag == MAKE_ID('D', 'S', 0, 0))
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
|
|
|
short var_20;
|
2019-11-24 12:59:36 +00:00
|
|
|
hFile.Read(&var_20, sizeof(var_20));
|
2019-11-20 16:21:32 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
for (i = 0; i < var_20; i++)
|
|
|
|
{
|
2019-11-24 12:59:36 +00:00
|
|
|
hFile.Read(&buffer[i * 10], 8);
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
short var_24;
|
2019-11-24 12:59:36 +00:00
|
|
|
hFile.Read(&var_24, sizeof(var_24));
|
2019-08-31 07:47:15 +00:00
|
|
|
|
|
|
|
for (i = 0; i < var_24; i++)
|
|
|
|
{
|
|
|
|
short var_28, var_2C;
|
2019-11-24 12:59:36 +00:00
|
|
|
hFile.Read(&var_28, sizeof(var_28));
|
|
|
|
hFile.Read(&var_2C, sizeof(var_2C));
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2019-09-19 13:38:28 +00:00
|
|
|
int hSound = LoadSound(&buffer[(var_2C&0x1FF)*10]);
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2020-02-24 20:59:04 +00:00
|
|
|
assert(vdi + var_28 < 18000);
|
2019-09-19 13:38:28 +00:00
|
|
|
FrameSound[vdi + var_28] = hSound | (var_2C & 0xFE00);
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nSeqs;
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int seq_GetFirstSeqPicnum(int nSeq)
|
|
|
|
{
|
2019-08-31 07:47:15 +00:00
|
|
|
int i = SeqOffsets[nSeq];
|
|
|
|
i = SeqBase[i];
|
|
|
|
i = FrameBase[i];
|
|
|
|
i = ChunkPict[i];
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
return i;
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void seq_LoadSequences()
|
|
|
|
{
|
2019-08-31 07:47:15 +00:00
|
|
|
int i;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
for (i = 0; i < kMaxSEQFiles; i++)
|
|
|
|
{
|
|
|
|
SeqOffsets[i] = sequences;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
if (seq_ReadSequence(SeqNames[i]) == 0) {
|
2020-04-11 21:45:45 +00:00
|
|
|
Printf("Error loading '%s'\n", SeqNames[i]);
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2020-08-30 10:49:21 +00:00
|
|
|
#if 0
|
2020-02-24 20:59:04 +00:00
|
|
|
FILE* f = fopen("seq.dump", "wb");
|
|
|
|
|
|
|
|
fwrite(SeqBase, 1, sizeof(SeqBase), f);
|
|
|
|
fwrite(SeqSize, 1, sizeof(SeqSize), f);
|
|
|
|
fwrite(SeqFlag, 1, sizeof(SeqFlag), f);
|
|
|
|
fwrite("++++++++++++++++", 1, 16, f);
|
|
|
|
fwrite(FrameSound, 1, sizeof(FrameSound), f);
|
|
|
|
fwrite("++++++++++++++++", 1, 16, f);
|
|
|
|
fwrite(FrameSize, 1, sizeof(FrameSize), f);
|
|
|
|
fwrite(FrameBase, 1, sizeof(FrameBase), f);
|
|
|
|
fwrite(FrameFlag, 1, sizeof(FrameFlag), f);
|
|
|
|
fwrite(ChunkYpos, 1, sizeof(ChunkYpos), f);
|
|
|
|
fwrite(ChunkXpos, 1, sizeof(ChunkXpos), f);
|
|
|
|
fwrite(ChunkPict, 1, sizeof(ChunkPict), f);
|
|
|
|
fwrite(ChunkFlag, 1, sizeof(ChunkFlag), f);
|
|
|
|
fclose(f);
|
2020-08-30 10:49:21 +00:00
|
|
|
#endif
|
2020-02-24 20:59:04 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
nShadowPic = seq_GetFirstSeqPicnum(kSeqShadow);
|
|
|
|
nShadowWidth = tilesiz[nShadowPic].x;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
nFlameHeight = tilesiz[seq_GetFirstSeqPicnum(kSeqFirePoof)].y;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
nBackgroundPic = seq_GetFirstSeqPicnum(kSeqBackgrnd);
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
nPilotLightBase = SeqBase[SeqOffsets[kSeqFlamer] + 3];
|
|
|
|
nPilotLightCount = SeqSize[SeqOffsets[kSeqFlamer] + 3];
|
|
|
|
nPilotLightFrame = 0;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
nFontFirstChar = seq_GetFirstSeqPicnum(kSeqFont2);
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
short nSize = SeqSize[SeqOffsets[kSeqFont2]];
|
2019-11-20 16:21:32 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
for (i = 0; i < nSize; i++)
|
|
|
|
{
|
2020-05-24 10:31:38 +00:00
|
|
|
auto tex = tileGetTexture(nFontFirstChar + i);
|
|
|
|
tex->SetOffsets(0, 0);
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
short seq_GetFrameFlag(short val, short nFrame)
|
|
|
|
{
|
2019-08-31 07:47:15 +00:00
|
|
|
return FrameFlag[SeqBase[val] + nFrame];
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
2020-08-24 03:22:52 +00:00
|
|
|
void seq_DrawPilotLightSeq(double xOffset, double yOffset)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2019-08-31 07:47:15 +00:00
|
|
|
short nSect = nPlayerViewSect[nLocalPlayer];
|
|
|
|
|
|
|
|
if (!(SectFlag[nSect] & kSectUnderwater))
|
|
|
|
{
|
|
|
|
short nFrame = nPilotLightBase + nPilotLightFrame;
|
|
|
|
short nFrameBase = FrameBase[nFrame];
|
|
|
|
short nFrameSize = FrameSize[nFrame];
|
|
|
|
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
nFrameSize--;
|
|
|
|
if (nFrameSize < 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
short nTile = ChunkPict[nFrameBase];
|
2020-08-24 03:22:52 +00:00
|
|
|
double x = ChunkXpos[nFrameBase] + (160 + xOffset);
|
|
|
|
double y = ChunkYpos[nFrameBase] + (100 + yOffset);
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2020-09-21 10:37:09 +00:00
|
|
|
hud_drawsprite(x, y, 65536, fmod(-2 * FixedToFloat(PlayerList[nLocalPlayer].q16angle), kAngleMask + 1), nTile, 0, 0, 1);
|
2019-08-31 07:47:15 +00:00
|
|
|
nFrameBase++;
|
|
|
|
}
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2019-08-31 07:47:15 +00:00
|
|
|
6 parameters
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
arg0 - shade?
|
2019-08-26 03:59:14 +00:00
|
|
|
|
|
|
|
*/
|
|
|
|
|
2020-08-24 03:22:52 +00:00
|
|
|
int seq_DrawGunSequence(int nSeqOffset, short dx, double xOffs, double yOffs, int nShade, int nPal)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2020-08-23 12:55:19 +00:00
|
|
|
int nFrame = SeqBase[nSeqOffset] + dx;
|
|
|
|
int nFrameBase = FrameBase[nFrame];
|
|
|
|
int nFrameSize = FrameSize[nFrame];
|
|
|
|
int frameFlag = FrameFlag[nFrame];
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
nFrameSize--;
|
|
|
|
if (nFrameSize < 0)
|
|
|
|
break;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
int x = ChunkXpos[nFrameBase] + 160;
|
|
|
|
int y = ChunkYpos[nFrameBase] + 100;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2020-08-23 12:55:19 +00:00
|
|
|
int stat = 0;
|
|
|
|
if (ChunkFlag[nFrameBase] & 1)
|
|
|
|
stat |= RS_XFLIPHUD;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2020-08-23 12:55:19 +00:00
|
|
|
if (ChunkFlag[nFrameBase] & 2)
|
|
|
|
stat |= RS_YFLIPHUD;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
short nTile = ChunkPict[nFrameBase];
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2020-08-23 12:55:19 +00:00
|
|
|
if (frameFlag & 4)
|
2019-08-31 07:47:15 +00:00
|
|
|
nShade = -100;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2020-08-23 12:55:19 +00:00
|
|
|
double alpha = 1;
|
2019-08-31 07:47:15 +00:00
|
|
|
if (nPlayerInvisible[nLocalPlayer]) {
|
2020-08-23 12:55:19 +00:00
|
|
|
alpha = 0.3;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2020-08-23 12:55:19 +00:00
|
|
|
hud_drawsprite(x + xOffs, y + yOffs, 65536, 0, nTile, nShade, nPal, stat, alpha);
|
2019-08-31 07:47:15 +00:00
|
|
|
nFrameBase++;
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
return frameFlag;
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int seq_GetFrameSound(int val, int edx)
|
|
|
|
{
|
2019-08-31 07:47:15 +00:00
|
|
|
return FrameSound[SeqBase[val] + edx];
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void seq_MoveSequence(short nSprite, short nSeq, short bx)
|
|
|
|
{
|
2019-08-31 07:47:15 +00:00
|
|
|
assert(nSeq >= 0); // TEMP
|
|
|
|
|
|
|
|
int nSound = FrameSound[SeqBase[nSeq] + bx];
|
|
|
|
if (nSound == -1) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nSprite > -1) {
|
|
|
|
D3PlayFX(nSound, nSprite);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
PlayLocalSound(nSound, 0);
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int seq_GetSeqPicnum2(short nSeq, short nFrame)
|
|
|
|
{
|
2019-08-31 07:47:15 +00:00
|
|
|
short nBase = FrameBase[SeqBase[nSeq] + nFrame];
|
|
|
|
return ChunkPict[nBase];
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int seq_GetSeqPicnum(short nSeq, short edx, short ebx)
|
|
|
|
{
|
2019-08-31 07:47:15 +00:00
|
|
|
edx += SeqOffsets[nSeq];
|
|
|
|
ebx += SeqBase[edx];
|
|
|
|
short c = FrameBase[ebx];
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
return ChunkPict[c];
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int seq_PlotArrowSequence(short nSprite, short nSeq, int nVal)
|
|
|
|
{
|
2020-01-03 04:20:56 +00:00
|
|
|
tspriteptr_t pTSprite = &tsprite[nSprite];
|
|
|
|
int nAngle = GetMyAngle(nCamerax - pTSprite->x, nCameray - pTSprite->y);
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2020-01-03 04:20:56 +00:00
|
|
|
int nSeqOffset = ((((pTSprite->ang + 512) - nAngle) + 128) & kAngleMask) >> 8;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
short nFrame = SeqBase[nSeqOffset + nSeq] + nVal;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
short nFrameBase = FrameBase[nFrame];
|
|
|
|
short nFrameSize = FrameSize[nFrame];
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2020-01-03 04:20:56 +00:00
|
|
|
uint8_t nShade = pTSprite->shade;
|
|
|
|
short nStat = pTSprite->cstat;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
nStat |= 0x80;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
if (nSeqOffset & 3) {
|
|
|
|
nStat |= 0x18;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
nStat &= 0x0E7;
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
if (FrameFlag[nFrame] & 4) {
|
|
|
|
nShade -= 100;
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2020-01-03 04:20:56 +00:00
|
|
|
pTSprite->cstat = nStat;
|
|
|
|
pTSprite->shade = nShade;
|
|
|
|
pTSprite->statnum = nFrameSize;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
if (ChunkFlag[nFrameBase] & 1)
|
|
|
|
{
|
2020-01-03 04:20:56 +00:00
|
|
|
pTSprite->xoffset = ChunkXpos[nFrameBase];
|
|
|
|
pTSprite->cstat |= 4;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-01-03 04:20:56 +00:00
|
|
|
pTSprite->xoffset = -ChunkXpos[nFrameBase];
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2020-01-03 04:20:56 +00:00
|
|
|
pTSprite->yoffset = -ChunkYpos[nFrameBase];
|
|
|
|
pTSprite->picnum = ChunkPict[nFrameBase];
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
return ChunkPict[nFrameBase];
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int seq_PlotSequence(short nSprite, short edx, short nFrame, short ecx)
|
|
|
|
{
|
2020-01-03 04:20:56 +00:00
|
|
|
tspriteptr_t pTSprite = &tsprite[nSprite];
|
|
|
|
int nAngle = GetMyAngle(nCamerax - pTSprite->x, nCameray - pTSprite->y);
|
2019-08-31 07:47:15 +00:00
|
|
|
|
|
|
|
int val;
|
|
|
|
|
|
|
|
if (ecx & 1)
|
|
|
|
{
|
|
|
|
val = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-01-03 04:20:56 +00:00
|
|
|
val = (((pTSprite->ang - nAngle) + 128) & kAngleMask) >> 8;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int eax = SeqBase[edx] + nFrame;
|
|
|
|
int edi = SeqBase[edx + val] + nFrame;
|
|
|
|
|
|
|
|
short nBase = FrameBase[edi];
|
|
|
|
short nSize = FrameSize[edi];
|
|
|
|
|
2020-01-03 04:20:56 +00:00
|
|
|
int8_t shade = pTSprite->shade;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
|
|
|
if (FrameFlag[eax] & 4)
|
|
|
|
{
|
|
|
|
shade -= 100;
|
|
|
|
}
|
|
|
|
|
|
|
|
short nPict = ChunkPict[nBase];
|
|
|
|
|
|
|
|
if (ecx & 0x100)
|
|
|
|
{
|
|
|
|
edx = -3;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
edx = 100;
|
|
|
|
}
|
|
|
|
|
|
|
|
int esi = nSize + 1;
|
|
|
|
esi += edx;
|
|
|
|
|
|
|
|
int var_14 = edx + 1;
|
2020-01-03 04:20:56 +00:00
|
|
|
short nOwner = pTSprite->owner;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
esi--;
|
|
|
|
nSize--;
|
|
|
|
|
|
|
|
if (esi < var_14) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-01-03 04:20:56 +00:00
|
|
|
tspriteptr_t tsp = &tsprite[spritesortcnt++];
|
|
|
|
tsp->x = pTSprite->x;
|
|
|
|
tsp->y = pTSprite->y;
|
|
|
|
tsp->z = pTSprite->z;
|
|
|
|
tsp->shade = shade;
|
|
|
|
tsp->pal = pTSprite->pal;
|
|
|
|
tsp->xrepeat = pTSprite->xrepeat;
|
|
|
|
tsp->yrepeat = pTSprite->yrepeat;
|
|
|
|
tsp->ang = pTSprite->ang;
|
|
|
|
tsp->owner = pTSprite->owner;
|
|
|
|
tsp->sectnum = pTSprite->sectnum;
|
|
|
|
tsp->cstat = pTSprite->cstat |= 0x80;
|
|
|
|
tsp->statnum = esi;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
|
|
|
if (ChunkFlag[nBase] & 1)
|
|
|
|
{
|
2020-01-03 04:20:56 +00:00
|
|
|
tsp->xoffset = ChunkXpos[nBase];
|
|
|
|
tsp->cstat |= 4; // x-flipped
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-01-03 04:20:56 +00:00
|
|
|
tsp->xoffset = -ChunkXpos[nBase];
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
|
2020-01-03 04:20:56 +00:00
|
|
|
tsp->yoffset = -ChunkYpos[nBase];
|
|
|
|
tsp->picnum = ChunkPict[nBase];
|
2019-08-31 07:47:15 +00:00
|
|
|
|
|
|
|
nBase++;
|
|
|
|
}
|
|
|
|
|
2020-01-03 04:20:56 +00:00
|
|
|
if (!(pTSprite->cstat & 0x101) || (sprite[nOwner].statnum == 100 && nNetPlayerCount))
|
2019-08-31 07:47:15 +00:00
|
|
|
{
|
2020-01-03 04:20:56 +00:00
|
|
|
pTSprite->owner = -1;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-01-03 04:20:56 +00:00
|
|
|
short nSector = pTSprite->sectnum;
|
2019-08-31 07:47:15 +00:00
|
|
|
int nFloorZ = sector[nSector].floorz;
|
|
|
|
|
|
|
|
if (nFloorZ <= eyelevel[nLocalPlayer] + initz) {
|
2020-01-03 04:20:56 +00:00
|
|
|
pTSprite->owner = -1;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-01-03 04:20:56 +00:00
|
|
|
pTSprite->picnum = nShadowPic;
|
2019-08-31 07:47:15 +00:00
|
|
|
|
2020-01-03 04:20:56 +00:00
|
|
|
int edx = ((tilesiz[nPict].x << 5) / nShadowWidth) - ((nFloorZ - pTSprite->z) >> 10);
|
2019-08-31 07:47:15 +00:00
|
|
|
if (edx < 1) {
|
|
|
|
edx = 1;
|
|
|
|
}
|
|
|
|
|
2020-01-03 04:20:56 +00:00
|
|
|
pTSprite->cstat = 0x22; // transluscence, floor sprite
|
|
|
|
pTSprite->z = videoGetRenderMode() >= REND_POLYMOST ? nFloorZ : nFloorZ + 1;
|
|
|
|
pTSprite->yrepeat = (uint8_t)edx;
|
|
|
|
pTSprite->xrepeat = (uint8_t)edx;
|
|
|
|
pTSprite->statnum = -3;
|
|
|
|
pTSprite->pal = 0;
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nPict;
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
2019-12-26 21:00:04 +00:00
|
|
|
|
|
|
|
static SavegameHelper sgh("sequence",
|
|
|
|
SV(nPilotLightFrame),
|
|
|
|
SV(nPilotLightCount),
|
|
|
|
SV(nPilotLightBase),
|
|
|
|
SV(nShadowWidth),
|
|
|
|
SV(nFlameHeight),
|
|
|
|
nullptr);
|
|
|
|
|
2019-11-22 23:11:37 +00:00
|
|
|
END_PS_NS
|