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 <string.h>
|
|
|
|
#include "build.h"
|
|
|
|
#include "common_game.h"
|
|
|
|
|
2019-06-27 04:33:22 +00:00
|
|
|
#include "globals.h"
|
2019-09-19 22:42:45 +00:00
|
|
|
#include "config.h"
|
|
|
|
#include "resource.h"
|
|
|
|
#include "screen.h"
|
2019-12-23 18:37:40 +00:00
|
|
|
#include "rendering/v_video.h"
|
2019-09-19 22:42:45 +00:00
|
|
|
|
2019-09-22 06:39:22 +00:00
|
|
|
BEGIN_BLD_NS
|
|
|
|
|
2019-09-19 22:42:45 +00:00
|
|
|
LOADITEM PLU[15] = {
|
|
|
|
{ 0, "NORMAL" },
|
|
|
|
{ 1, "SATURATE" },
|
|
|
|
{ 2, "BEAST" },
|
|
|
|
{ 3, "TOMMY" },
|
|
|
|
{ 4, "SPIDER3" },
|
|
|
|
{ 5, "GRAY" },
|
|
|
|
{ 6, "GRAYISH" },
|
|
|
|
{ 7, "SPIDER1" },
|
|
|
|
{ 8, "SPIDER2" },
|
|
|
|
{ 9, "FLAME" },
|
|
|
|
{ 10, "COLD" },
|
|
|
|
{ 11, "P1" },
|
|
|
|
{ 12, "P2" },
|
|
|
|
{ 13, "P3" },
|
|
|
|
{ 14, "P4" }
|
|
|
|
};
|
|
|
|
|
|
|
|
LOADITEM PAL[5] = {
|
|
|
|
{ 0, "BLOOD" },
|
|
|
|
{ 1, "WATER" },
|
|
|
|
{ 2, "BEAST" },
|
|
|
|
{ 3, "SEWER" },
|
|
|
|
{ 4, "INVULN1" }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static RGB toRGB;
|
|
|
|
static RGB *palTable[5];
|
|
|
|
static int curPalette;
|
|
|
|
bool gFogMode = false;
|
|
|
|
|
|
|
|
void scrResetPalette(void)
|
|
|
|
{
|
|
|
|
paletteSetColorTable(0, (uint8_t*)palTable[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
void scrLoadPLUs(void)
|
|
|
|
{
|
2019-12-05 20:42:35 +00:00
|
|
|
// load default palookups
|
|
|
|
for (int i = 0; i < 15; i++) {
|
2019-09-19 22:42:45 +00:00
|
|
|
DICTNODE *pPlu = gSysRes.Lookup(PLU[i].name, "PLU");
|
|
|
|
if (!pPlu)
|
|
|
|
ThrowError("%s.PLU not found", PLU[i].name);
|
2019-10-30 23:50:45 +00:00
|
|
|
if (pPlu->Size() / 256 != 64)
|
2019-09-19 22:42:45 +00:00
|
|
|
ThrowError("Incorrect PLU size");
|
2020-04-12 05:48:23 +00:00
|
|
|
lookuptables[PLU[i].id] = (char*)gSysRes.Lock(pPlu);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
2019-12-05 20:42:35 +00:00
|
|
|
|
|
|
|
// by NoOne: load user palookups
|
|
|
|
for (int i = kUserPLUStart; i < MAXPALOOKUPS; i++) {
|
|
|
|
DICTNODE* pPlu = gSysRes.Lookup(i, "PLU");
|
|
|
|
if (!pPlu) continue;
|
2020-01-02 18:11:09 +00:00
|
|
|
else if (pPlu->Size() / 256 != 64) { consoleSysMsg("Incorrect filesize of PLU#%d", i); }
|
2020-04-12 05:48:23 +00:00
|
|
|
else lookuptables[i] = (char*)gSysRes.Lock(pPlu);
|
2019-12-05 20:42:35 +00:00
|
|
|
}
|
|
|
|
|
2019-09-19 22:42:45 +00:00
|
|
|
#ifdef USE_OPENGL
|
|
|
|
palookupfog[1].r = 255;
|
|
|
|
palookupfog[1].g = 255;
|
|
|
|
palookupfog[1].b = 255;
|
2019-11-10 20:11:17 +00:00
|
|
|
palookupfog[1].f = 1;
|
2019-09-19 22:42:45 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef USE_OPENGL
|
|
|
|
glblend_t const bloodglblend =
|
|
|
|
{
|
|
|
|
{
|
|
|
|
{ 1.f/3.f, BLENDFACTOR_SRC_ALPHA, BLENDFACTOR_ONE_MINUS_SRC_ALPHA, 0 },
|
|
|
|
{ 2.f/3.f, BLENDFACTOR_SRC_ALPHA, BLENDFACTOR_ONE_MINUS_SRC_ALPHA, 0 },
|
|
|
|
},
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void scrLoadPalette(void)
|
|
|
|
{
|
2019-11-10 14:15:14 +00:00
|
|
|
#ifdef USE_OPENGL
|
|
|
|
for (auto& x : glblend)
|
|
|
|
x = bloodglblend;
|
|
|
|
#endif
|
|
|
|
|
2019-09-19 22:42:45 +00:00
|
|
|
paletteloaded = 0;
|
2020-04-11 21:45:45 +00:00
|
|
|
Printf("Loading palettes\n");
|
2019-09-19 22:42:45 +00:00
|
|
|
for (int i = 0; i < 5; i++)
|
|
|
|
{
|
|
|
|
DICTNODE *pPal = gSysRes.Lookup(PAL[i].name, "PAL");
|
|
|
|
if (!pPal)
|
|
|
|
ThrowError("%s.PAL not found (RFF files may be wrong version)", PAL[i].name);
|
|
|
|
palTable[PAL[i].id] = (RGB*)gSysRes.Lock(pPal);
|
|
|
|
paletteSetColorTable(PAL[i].id, (uint8_t*)palTable[PAL[i].id]);
|
|
|
|
}
|
|
|
|
memcpy(palette, palTable[0], sizeof(palette));
|
|
|
|
numshades = 64;
|
|
|
|
paletteloaded |= PALETTE_MAIN;
|
|
|
|
scrLoadPLUs();
|
|
|
|
paletteloaded |= PALETTE_SHADE;
|
2020-04-11 21:45:45 +00:00
|
|
|
Printf("Loading translucency table\n");
|
2019-09-19 22:42:45 +00:00
|
|
|
DICTNODE *pTrans = gSysRes.Lookup("TRANS", "TLU");
|
|
|
|
if (!pTrans)
|
|
|
|
ThrowError("TRANS.TLU not found");
|
|
|
|
paletteloaded |= PALETTE_TRANSLUC;
|
|
|
|
|
|
|
|
palettePostLoadTables();
|
2020-04-12 05:46:53 +00:00
|
|
|
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void scrSetPalette(int palId)
|
|
|
|
{
|
|
|
|
curPalette = palId;
|
|
|
|
}
|
|
|
|
|
|
|
|
void scrInit(void)
|
|
|
|
{
|
|
|
|
glrendmode = REND_POLYMOST;
|
|
|
|
engineInit();
|
|
|
|
curPalette = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void scrSetGameMode(int vidMode, int XRes, int YRes, int nBits)
|
|
|
|
{
|
2019-12-23 18:37:40 +00:00
|
|
|
V_Init2();
|
2019-09-19 22:42:45 +00:00
|
|
|
videoClearViewableArea(0);
|
|
|
|
videoNextPage();
|
2020-04-11 22:20:21 +00:00
|
|
|
scrSetPalette(curPalette);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
2019-09-22 06:39:22 +00:00
|
|
|
|
|
|
|
END_BLD_NS
|