2020-06-11 07:22:16 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
/*
|
2020-06-23 19:56:42 +00:00
|
|
|
Copyright (C) 1996, 2003 - 3D Realms Entertainment
|
2020-06-11 07:22:16 +00:00
|
|
|
|
2020-06-23 19:56:42 +00:00
|
|
|
This file is part of Duke Nukem 3D version 1.5 - Atomic Edition
|
2020-06-11 07:22:16 +00:00
|
|
|
|
2020-06-23 19:56:42 +00:00
|
|
|
Duke Nukem 3D 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.
|
2020-06-11 07:22:16 +00:00
|
|
|
|
|
|
|
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
|
2020-06-23 19:56:42 +00:00
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
|
|
|
Original Source: 1996 - Todd Replogle
|
|
|
|
Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms
|
|
|
|
Modifications for JonoF's port by Jonathon Fowler (jf@jonof.id.au)
|
2020-06-11 07:22:16 +00:00
|
|
|
*/
|
2020-06-23 19:56:42 +00:00
|
|
|
//-------------------------------------------------------------------------
|
2020-06-11 07:22:16 +00:00
|
|
|
|
|
|
|
#include "ns.h" // Must come before everything else!
|
|
|
|
|
2020-06-21 20:18:12 +00:00
|
|
|
#include "duke3d.h"
|
2020-06-11 07:22:16 +00:00
|
|
|
#include "demo.h"
|
|
|
|
#include "screens.h"
|
|
|
|
#include "baselayer.h"
|
|
|
|
#include "m_argv.h"
|
2020-06-23 22:40:22 +00:00
|
|
|
#include "mapinfo.h"
|
|
|
|
#include "texturemanager.h"
|
2020-06-11 07:22:16 +00:00
|
|
|
|
|
|
|
BEGIN_DUKE_NS
|
|
|
|
|
2020-06-23 22:40:22 +00:00
|
|
|
FFont* IndexFont;
|
|
|
|
FFont* DigiFont;
|
|
|
|
|
2020-06-23 19:56:42 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// game specific command line args go here.
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
2020-06-11 07:22:16 +00:00
|
|
|
|
2020-06-23 19:56:42 +00:00
|
|
|
void checkcommandline()
|
2020-06-11 07:22:16 +00:00
|
|
|
{
|
|
|
|
auto val = Args->CheckValue("-skill");
|
2020-06-23 19:56:42 +00:00
|
|
|
if (!val) val = Args->CheckValue("-s");
|
2020-06-11 07:22:16 +00:00
|
|
|
if (val)
|
|
|
|
{
|
|
|
|
ud.m_player_skill = ud.player_skill = clamp((int)strtol(val, nullptr, 0), 0, 5);
|
|
|
|
if (ud.m_player_skill == 4) ud.m_respawn_monsters = ud.respawn_monsters = 1;
|
|
|
|
}
|
|
|
|
val = Args->CheckValue("-respawn");
|
2020-06-23 19:56:42 +00:00
|
|
|
if (!val) val = Args->CheckValue("-t");
|
2020-06-11 07:22:16 +00:00
|
|
|
if (val)
|
|
|
|
{
|
|
|
|
if (*val == '1') ud.m_respawn_monsters = 1;
|
|
|
|
else if (*val == '2') ud.m_respawn_items = 1;
|
|
|
|
else if (*val == '3') ud.m_respawn_inventory = 1;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ud.m_respawn_monsters = 1;
|
|
|
|
ud.m_respawn_items = 1;
|
|
|
|
ud.m_respawn_inventory = 1;
|
|
|
|
}
|
|
|
|
Printf("Respawn on.\n");
|
|
|
|
}
|
|
|
|
}
|
2020-06-23 19:56:42 +00:00
|
|
|
|
2020-06-23 20:51:37 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void genspriteremaps(void)
|
|
|
|
{
|
|
|
|
int j;
|
|
|
|
|
|
|
|
auto fr = fileSystem.OpenFileReader("lookup.dat");
|
|
|
|
if (!fr.isOpen())
|
|
|
|
return;
|
|
|
|
|
|
|
|
j = lookups.loadTable(fr);
|
|
|
|
|
|
|
|
if (j < 0)
|
|
|
|
{
|
|
|
|
if (j == -1)
|
|
|
|
Printf("ERROR loading \"lookup.dat\": failed reading enough data.\n");
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint8_t paldata[768];
|
|
|
|
|
|
|
|
for (j=1; j<=5; j++)
|
|
|
|
{
|
|
|
|
if (fr.Read(paldata, 768) != 768)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (int k = 0; k < 768; k++) // Build uses 6 bit VGA palettes.
|
|
|
|
paldata[k] = (paldata[k] << 2) | (paldata[k] >> 6);
|
|
|
|
|
|
|
|
paletteSetColorTable(j, paldata, j == DREALMSPAL || j == ENDINGPAL, j < DREALMSPAL);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < 256; i++)
|
|
|
|
{
|
|
|
|
// swap red and blue channels.
|
|
|
|
paldata[i * 3] = GPalette.BaseColors[i].b;
|
|
|
|
paldata[i * 3+1] = GPalette.BaseColors[i].g;
|
|
|
|
paldata[i * 3+2] = GPalette.BaseColors[i].r;
|
|
|
|
}
|
|
|
|
paletteSetColorTable(DRUGPAL, paldata, false, false); // todo: implement this as a shader effect (swap R and B in postprocessing.)
|
|
|
|
|
|
|
|
if (isRR())
|
|
|
|
{
|
|
|
|
uint8_t table[256];
|
|
|
|
for (j = 0; j < 768; j++)
|
|
|
|
table[j] = j;
|
|
|
|
for (j = 0; j < 32; j++)
|
|
|
|
table[j] = j + 32;
|
|
|
|
|
|
|
|
lookups.makeTable(7, table, 0, 0, 0, 0);
|
|
|
|
|
|
|
|
for (j = 0; j < 768; j++)
|
|
|
|
table[j] = j;
|
|
|
|
lookups.makeTable(30, table, 0, 0, 0, 0);
|
|
|
|
lookups.makeTable(31, table, 0, 0, 0, 0);
|
|
|
|
lookups.makeTable(32, table, 0, 0, 0, 0);
|
|
|
|
lookups.makeTable(33, table, 0, 0, 0, 0);
|
|
|
|
if (isRRRA())
|
|
|
|
lookups.makeTable(105, table, 0, 0, 0, 0);
|
|
|
|
|
|
|
|
int unk = 63;
|
|
|
|
for (j = 64; j < 80; j++)
|
|
|
|
{
|
|
|
|
unk--;
|
|
|
|
table[j] = unk;
|
|
|
|
table[j + 16] = j - 24;
|
|
|
|
}
|
|
|
|
table[80] = 80;
|
|
|
|
table[81] = 81;
|
|
|
|
for (j = 0; j < 32; j++)
|
|
|
|
{
|
|
|
|
table[j] = j + 32;
|
|
|
|
}
|
|
|
|
lookups.makeTable(34, table, 0, 0, 0, 0);
|
|
|
|
for (j = 0; j < 768; j++)
|
|
|
|
table[j] = j;
|
|
|
|
for (j = 0; j < 16; j++)
|
|
|
|
table[j] = j + 129;
|
|
|
|
for (j = 16; j < 32; j++)
|
|
|
|
table[j] = j + 192;
|
|
|
|
lookups.makeTable(35, table, 0, 0, 0, 0);
|
|
|
|
if (isRRRA())
|
|
|
|
{
|
|
|
|
lookups.makeTable(50, nullptr, 12 * 4, 12 * 4, 12 * 4, 0);
|
|
|
|
lookups.makeTable(51, nullptr, 12 * 4, 12 * 4, 12 * 4, 0);
|
|
|
|
lookups.makeTable(54, lookups.getTable(8), 32 * 4, 32 * 4, 32 * 4, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-23 22:40:22 +00:00
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// Sets up the game fonts.
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
void InitFonts()
|
|
|
|
{
|
|
|
|
GlyphSet fontdata;
|
|
|
|
|
|
|
|
// Small font
|
|
|
|
for (int i = 0; i < 95; i++)
|
|
|
|
{
|
|
|
|
auto tile = tileGetTexture(TILE_STARTALPHANUM + i);
|
|
|
|
if (tile && tile->GetTexelWidth() > 0 && tile->GetTexelHeight() > 0)
|
|
|
|
fontdata.Insert('!' + i, tile);
|
|
|
|
}
|
|
|
|
SmallFont = new ::FFont("SmallFont", nullptr, "defsmallfont", 0, 0, 0, -1, -1, false, false, false, &fontdata);
|
|
|
|
fontdata.Clear();
|
|
|
|
|
|
|
|
// Big font
|
|
|
|
|
|
|
|
// This font is VERY messy...
|
|
|
|
fontdata.Insert('_', tileGetTexture(TILE_BIGALPHANUM - 11));
|
|
|
|
fontdata.Insert('-', tileGetTexture(TILE_BIGALPHANUM - 11));
|
|
|
|
for (int i = 0; i < 10; i++) fontdata.Insert('0' + i, tileGetTexture(TILE_BIGALPHANUM - 10 + i));
|
|
|
|
for (int i = 0; i < 26; i++) fontdata.Insert('A' + i, tileGetTexture(TILE_BIGALPHANUM + i));
|
|
|
|
fontdata.Insert('.', tileGetTexture(TILE_BIGPERIOD));
|
|
|
|
fontdata.Insert(',', tileGetTexture(TILE_BIGCOMMA));
|
|
|
|
fontdata.Insert('!', tileGetTexture(TILE_BIGX_));
|
|
|
|
fontdata.Insert('?', tileGetTexture(TILE_BIGQ));
|
|
|
|
fontdata.Insert(';', tileGetTexture(TILE_BIGSEMI));
|
|
|
|
fontdata.Insert(':', tileGetTexture(TILE_BIGCOLIN));
|
|
|
|
fontdata.Insert('\\', tileGetTexture(TILE_BIGALPHANUM + 68));
|
|
|
|
fontdata.Insert('/', tileGetTexture(TILE_BIGALPHANUM + 68));
|
|
|
|
fontdata.Insert('%', tileGetTexture(TILE_BIGALPHANUM + 69));
|
|
|
|
fontdata.Insert('`', tileGetTexture(TILE_BIGAPPOS));
|
|
|
|
fontdata.Insert('"', tileGetTexture(TILE_BIGAPPOS));
|
|
|
|
fontdata.Insert('\'', tileGetTexture(TILE_BIGAPPOS));
|
|
|
|
BigFont = new ::FFont("BigFont", nullptr, "defbigfont", 0, 0, 0, -1, -1, false, false, false, &fontdata);
|
|
|
|
fontdata.Clear();
|
|
|
|
|
|
|
|
// Tiny font
|
|
|
|
for (int i = 0; i < 95; i++)
|
|
|
|
{
|
|
|
|
auto tile = tileGetTexture(TILE_MINIFONT + i);
|
|
|
|
if (tile && tile->GetTexelWidth() > 0 && tile->GetTexelHeight() > 0)
|
|
|
|
fontdata.Insert('!' + i, tile);
|
|
|
|
}
|
|
|
|
fontdata.Insert(1, TexMan.FindGameTexture("TINYBLAK")); // this is only here to widen the color range of the font to produce a better translation.
|
|
|
|
SmallFont2 = new ::FFont("SmallFont2", nullptr, "defsmallfont2", 0, 0, 0, -1, -1, false, false, false, &fontdata);
|
|
|
|
fontdata.Clear();
|
|
|
|
|
|
|
|
// SBAR index font
|
|
|
|
for (int i = 0; i < 10; i++) fontdata.Insert('0' + i, tileGetTexture(TILE_THREEBYFIVE + i));
|
|
|
|
fontdata.Insert(':', tileGetTexture(TILE_THREEBYFIVE + 10));
|
|
|
|
fontdata.Insert('/', tileGetTexture(TILE_THREEBYFIVE + 11));
|
|
|
|
fontdata.Insert('%', tileGetTexture(TILE_MINIFONT + '%' - '!'));
|
|
|
|
fontdata.Insert(1, TexMan.FindGameTexture("TINYBLAK")); // this is only here to widen the color range of the font to produce a better translation.
|
|
|
|
IndexFont = new ::FFont("IndexFont", nullptr, nullptr, 0, 0, 0, -1, -1, false, false, false, &fontdata);
|
|
|
|
|
|
|
|
fontdata.Clear();
|
|
|
|
|
|
|
|
// digital font
|
|
|
|
for (int i = 0; i < 10; i++) fontdata.Insert('0' + i, tileGetTexture(TILE_DIGITALNUM + i));
|
|
|
|
fontdata.Insert(1, TexMan.FindGameTexture("TINYBLAK")); // this is only here to widen the color range of the font to produce a better translation.
|
|
|
|
DigiFont = new ::FFont("DigiFont", nullptr, nullptr, 0, 0, 0, -1, -1, false, false, false, &fontdata);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-06-23 20:51:37 +00:00
|
|
|
|
2020-06-11 07:22:16 +00:00
|
|
|
END_DUKE_NS
|
2020-06-23 19:56:42 +00:00
|
|
|
|