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"
|
2019-08-26 03:59:14 +00:00
|
|
|
#include "engine.h"
|
|
|
|
|
2019-11-13 20:06:48 +00:00
|
|
|
//#include <io.h>
|
|
|
|
//#include <fcntl.h>
|
2019-11-23 23:04:15 +00:00
|
|
|
#include "gamecvars.h"
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
// static int globhiz, globloz, globhihit, globlohit;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-11-22 23:11:37 +00:00
|
|
|
BEGIN_PS_NS
|
|
|
|
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2020-05-23 12:36:35 +00:00
|
|
|
void overwritesprite(int thex, int they, short tilenum, signed char shade, char stat, char dapalnum, int basepal)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
|
|
|
#if 0
|
2019-08-31 07:47:15 +00:00
|
|
|
rotatesprite(thex << 16, they << 16, 0x10000, (short)((flags & 8) << 7), tilenum, shade, dapalnum,
|
|
|
|
(char)(((flags & 1 ^ 1) << 4) + (flags & 2) + ((flags & 4) >> 2) + ((flags & 16) >> 2) ^ ((flags & 8) >> 1)),
|
|
|
|
windowx1, windowy1, windowx2, windowy2);
|
2019-08-26 03:59:14 +00:00
|
|
|
#endif
|
2019-08-31 19:05:16 +00:00
|
|
|
// no animation
|
|
|
|
uint8_t animbak = picanm[tilenum].sf;
|
|
|
|
picanm[tilenum].sf = 0;
|
|
|
|
int offx = 0, offy = 0;
|
|
|
|
if (stat & 1)
|
|
|
|
{
|
|
|
|
offx -= tilesiz[tilenum].x>>1;
|
|
|
|
if (stat & 8)
|
2020-05-24 10:31:38 +00:00
|
|
|
offx += tileLeftOffset(tilenum);
|
2019-08-31 19:05:16 +00:00
|
|
|
else
|
2020-05-24 10:31:38 +00:00
|
|
|
offx -= tileLeftOffset(tilenum);
|
|
|
|
offy -= (tilesiz[tilenum].y>>1)+tileTopOffset(tilenum);
|
2019-08-31 19:05:16 +00:00
|
|
|
}
|
|
|
|
if (stat&8)
|
|
|
|
offx += tilesiz[tilenum].x;
|
|
|
|
if (stat&16)
|
|
|
|
offy += tilesiz[tilenum].y;
|
|
|
|
thex += offx;
|
|
|
|
they += offy;
|
2019-08-31 07:47:15 +00:00
|
|
|
rotatesprite(thex << 16, they << 16, 65536L, (stat & 8) << 7, tilenum, shade, dapalnum,
|
2019-08-31 19:05:16 +00:00
|
|
|
16 + (stat & 2) + ((stat & 4) >> 2) + (((stat & 16) >> 2) ^ ((stat & 8) >> 1)),
|
2020-05-23 12:36:35 +00:00
|
|
|
windowxy1.x, windowxy1.y, windowxy2.x, windowxy2.y, nullptr, basepal);
|
2019-08-31 19:05:16 +00:00
|
|
|
picanm[tilenum].sf = animbak;
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void resettiming()
|
|
|
|
{
|
2019-08-31 07:47:15 +00:00
|
|
|
numframes = 0L;
|
|
|
|
totalclock = 0L;
|
2019-08-26 03:59:14 +00:00
|
|
|
// TODO totalclocklock = 0L;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-11-28 13:37:19 +00:00
|
|
|
static int32_t xdim_to_320_16(int32_t x)
|
|
|
|
{
|
|
|
|
const int32_t screenwidth = scale(240<<16, xdim, ydim);
|
|
|
|
return scale(x, screenwidth, xdim) + (160<<16) - (screenwidth>>1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int32_t ydim_to_200_16(int32_t y)
|
|
|
|
{
|
2020-07-16 11:23:26 +00:00
|
|
|
return scale(y, 200<<16, ydim);
|
2019-11-28 13:37:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int32_t xdim_from_320_16(int32_t x)
|
|
|
|
{
|
|
|
|
const int32_t screenwidth = scale(240<<16, xdim, ydim);
|
|
|
|
return scale(x + (screenwidth>>1) - (160<<16), xdim, screenwidth);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int32_t ydim_from_200_16(int32_t y)
|
|
|
|
{
|
|
|
|
return scale(y, ydim, 200<<16);
|
|
|
|
}
|
|
|
|
|
2019-12-02 16:34:59 +00:00
|
|
|
void printext(int x, int y, const char *buffer, short tilenum, char UNUSED(invisiblecol))
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2019-08-31 07:47:15 +00:00
|
|
|
int i;
|
|
|
|
unsigned char ch;
|
2019-12-02 16:34:59 +00:00
|
|
|
// const int32_t screenwidth = scale(240<<16, xdim, ydim);
|
2019-11-28 13:37:19 +00:00
|
|
|
|
2019-11-28 13:54:36 +00:00
|
|
|
x = xdim_to_320_16(x);
|
|
|
|
y = ydim_to_200_16(y);
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-08-31 07:47:15 +00:00
|
|
|
for (i = 0; buffer[i] != 0; i++)
|
|
|
|
{
|
|
|
|
ch = (unsigned char)buffer[i];
|
2019-11-28 13:37:19 +00:00
|
|
|
rotatesprite(x - ((ch & 15) << (3+16)), y - ((ch >> 4) << (3+16)), 65536L, 0, tilenum, 0, 0, 2 + 8 + 16 + 128, xdim_from_320_16(x), ydim_from_200_16(y),
|
|
|
|
xdim_from_320_16(x + (8<<16))-1, ydim_from_200_16(y + (8<<16))-1);
|
|
|
|
x += (8<<16);
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
2019-11-23 23:04:15 +00:00
|
|
|
void doTileLoad(int i)
|
|
|
|
{
|
|
|
|
tileLoad(i);
|
|
|
|
|
|
|
|
#ifdef USE_OPENGL
|
|
|
|
if (r_precache) PrecacheHardwareTextures(i);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-08-26 03:59:14 +00:00
|
|
|
void precache()
|
|
|
|
{
|
2019-08-31 07:47:15 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < numsectors; i++)
|
|
|
|
{
|
|
|
|
short j = sector[i].ceilingpicnum;
|
2019-11-23 23:04:15 +00:00
|
|
|
doTileLoad(j);
|
2019-08-31 07:47:15 +00:00
|
|
|
j = sector[i].floorpicnum;
|
2019-11-23 23:04:15 +00:00
|
|
|
doTileLoad(j);
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < numwalls; i++)
|
|
|
|
{
|
|
|
|
short j = wall[i].picnum;
|
2019-11-23 23:04:15 +00:00
|
|
|
doTileLoad(j);
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < kMaxSprites; i++)
|
|
|
|
{
|
|
|
|
if (sprite[i].statnum < kMaxStatus)
|
|
|
|
{
|
|
|
|
short j = sprite[i].picnum;
|
2019-11-23 23:04:15 +00:00
|
|
|
doTileLoad(j);
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
2019-11-22 23:11:37 +00:00
|
|
|
END_PS_NS
|