mirror of
https://github.com/yquake2/ref_vk.git
synced 2024-11-10 06:41:45 +00:00
Merge pull request #46 from yquake2/rerelease
Add Re-Release initial support
This commit is contained in:
commit
f1b00d6f84
11 changed files with 369 additions and 143 deletions
1
Makefile
1
Makefile
|
@ -357,6 +357,7 @@ REFVK_OBJS_ := \
|
||||||
src/files/wal.o \
|
src/files/wal.o \
|
||||||
src/files/pvs.o \
|
src/files/pvs.o \
|
||||||
src/common/shared.o \
|
src/common/shared.o \
|
||||||
|
src/common/utils.o \
|
||||||
src/common/md4.o
|
src/common/md4.o
|
||||||
|
|
||||||
ifeq ($(YQ2_OSTYPE), Windows)
|
ifeq ($(YQ2_OSTYPE), Windows)
|
||||||
|
|
|
@ -38,14 +38,50 @@
|
||||||
#error YQ2OSTYPE should be defined by the build system
|
#error YQ2OSTYPE should be defined by the build system
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef YQ2ARCH
|
|
||||||
#error YQ2ARCH should be defined by the build system
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef BUILD_DATE
|
#ifndef BUILD_DATE
|
||||||
#define BUILD_DATE __DATE__
|
#define BUILD_DATE __DATE__
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#define CFGDIR "YamagiQ2"
|
||||||
|
#else
|
||||||
|
#ifndef __HAIKU__
|
||||||
|
#define CFGDIR ".yq2"
|
||||||
|
#else
|
||||||
|
#define CFGDIR "yq2"
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef YQ2ARCH
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
// Setting YQ2ARCH for VisualC++ from CMake doesn't work when using VS integrated CMake
|
||||||
|
// so set it in code instead
|
||||||
|
#ifdef YQ2ARCH
|
||||||
|
#undef YQ2ARCH
|
||||||
|
#endif
|
||||||
|
#ifdef _M_X64
|
||||||
|
// this matches AMD64 and ARM64EC (but not regular ARM64), but they're supposed to be binary-compatible somehow, so whatever
|
||||||
|
#define YQ2ARCH "x86_64"
|
||||||
|
#elif defined(_M_ARM64)
|
||||||
|
#define YQ2ARCH "arm64"
|
||||||
|
#elif defined(_M_ARM)
|
||||||
|
#define YQ2ARCH "arm"
|
||||||
|
#elif defined(_M_IX86)
|
||||||
|
#define YQ2ARCH "x86"
|
||||||
|
#else
|
||||||
|
// if you're not targeting one of the aforementioned architectures,
|
||||||
|
// check https://learn.microsoft.com/en-us/cpp/preprocessor/predefined-macros
|
||||||
|
// to find out how to detect yours and add it here - and please send a patch :)
|
||||||
|
#error "Unknown CPU architecture!"
|
||||||
|
// (for a quick and dirty solution, comment out the previous line, but keep in mind
|
||||||
|
// that savegames may not be compatible with other builds of Yamagi Quake II)
|
||||||
|
#define YQ2ARCH "UNKNOWN"
|
||||||
|
#endif // _M_X64 etc
|
||||||
|
#else // other compilers than MSVC
|
||||||
|
#error YQ2ARCH should be defined by the build system
|
||||||
|
#endif // _MSC_VER
|
||||||
|
#endif // YQ2ARCH
|
||||||
|
|
||||||
/* ================================================================== */
|
/* ================================================================== */
|
||||||
|
|
||||||
typedef struct sizebuf_s
|
typedef struct sizebuf_s
|
||||||
|
@ -708,17 +744,18 @@ void Com_Printf(char *fmt, ...) PRINTF_ATTR(1, 2);
|
||||||
void Com_DPrintf(char *fmt, ...) PRINTF_ATTR(1, 2);
|
void Com_DPrintf(char *fmt, ...) PRINTF_ATTR(1, 2);
|
||||||
void Com_VPrintf(int print_level, const char *fmt, va_list argptr); /* print_level is PRINT_ALL or PRINT_DEVELOPER */
|
void Com_VPrintf(int print_level, const char *fmt, va_list argptr); /* print_level is PRINT_ALL or PRINT_DEVELOPER */
|
||||||
void Com_MDPrintf(char *fmt, ...) PRINTF_ATTR(1, 2);
|
void Com_MDPrintf(char *fmt, ...) PRINTF_ATTR(1, 2);
|
||||||
YQ2_ATTR_NORETURN void Com_Error(int code, char *fmt, ...) PRINTF_ATTR(2, 3);
|
YQ2_ATTR_NORETURN_FUNCPTR void Com_Error(int code, char *fmt, ...) PRINTF_ATTR(2, 3);
|
||||||
YQ2_ATTR_NORETURN void Com_Quit(void);
|
YQ2_ATTR_NORETURN void Com_Quit(void);
|
||||||
|
|
||||||
/* Ugly work around for unsupported
|
/* Ugly work around for unsupported
|
||||||
* format specifiers unter mingw. */
|
* format specifiers unter mingw. */
|
||||||
#define YQ2_COM_PRId64 PRId64
|
|
||||||
#define YQ2_COM_PRIu64 PRIu64
|
#define YQ2_COM_PRIu64 PRIu64
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
|
#define YQ2_COM_PRId64 "%I64d"
|
||||||
#define YQ2_COM_PRIdS "%Id"
|
#define YQ2_COM_PRIdS "%Id"
|
||||||
#else
|
#else
|
||||||
|
#define YQ2_COM_PRId64 "%ld"
|
||||||
#define YQ2_COM_PRIdS "%zd"
|
#define YQ2_COM_PRIdS "%zd"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -74,7 +74,7 @@ typedef enum
|
||||||
} modtype_t;
|
} modtype_t;
|
||||||
|
|
||||||
#define MAX_LBM_HEIGHT 480
|
#define MAX_LBM_HEIGHT 480
|
||||||
|
#define DEFAULT_NOLERP_LIST "pics/conchars.* pics/ch1.* pics/ch2. pics/ch3.*"
|
||||||
extern void R_Printf(int level, const char* msg, ...) PRINTF_ATTR(2, 3);
|
extern void R_Printf(int level, const char* msg, ...) PRINTF_ATTR(2, 3);
|
||||||
|
|
||||||
/* Shared images load */
|
/* Shared images load */
|
||||||
|
@ -85,6 +85,7 @@ extern struct image_s* LoadM8(const char *origname, imagetype_t type, loadimage_
|
||||||
extern struct image_s* LoadM32(const char *origname, imagetype_t type, loadimage_t load_image);
|
extern struct image_s* LoadM32(const char *origname, imagetype_t type, loadimage_t load_image);
|
||||||
extern void FixFileExt(const char *origname, const char *ext, char *filename, size_t size);
|
extern void FixFileExt(const char *origname, const char *ext, char *filename, size_t size);
|
||||||
extern void GetPCXPalette(byte **colormap, unsigned *d_8to24table);
|
extern void GetPCXPalette(byte **colormap, unsigned *d_8to24table);
|
||||||
|
extern void GetPCXPalette24to8(byte *d_8to24table, byte** d_16to8table);
|
||||||
extern void LoadPCX(const char *origname, byte **pic, byte **palette, int *width, int *height);
|
extern void LoadPCX(const char *origname, byte **pic, byte **palette, int *width, int *height);
|
||||||
extern void GetPCXInfo(const char *origname, int *width, int *height);
|
extern void GetPCXInfo(const char *origname, int *width, int *height);
|
||||||
extern void GetWalInfo(const char *name, int *width, int *height);
|
extern void GetWalInfo(const char *name, int *width, int *height);
|
||||||
|
|
|
@ -61,16 +61,17 @@ typedef unsigned char byte;
|
||||||
// must be used as prefix (YQ2_ATTR_NORETURN void bla();)!
|
// must be used as prefix (YQ2_ATTR_NORETURN void bla();)!
|
||||||
#define YQ2_ATTR_NORETURN _Noreturn
|
#define YQ2_ATTR_NORETURN _Noreturn
|
||||||
#define YQ2_STATIC_ASSERT(C, M) _Static_assert((C), M)
|
#define YQ2_STATIC_ASSERT(C, M) _Static_assert((C), M)
|
||||||
# if defined(__GNUC__)
|
#if defined(__GNUC__)
|
||||||
#define YQ2_ATTR_MALLOC __attribute__ ((__malloc__))
|
#define YQ2_ATTR_MALLOC __attribute__ ((__malloc__))
|
||||||
#define YQ2_ATTR_INLINE __attribute__((always_inline)) inline
|
#define YQ2_ATTR_INLINE __attribute__((always_inline)) inline
|
||||||
# elif defined(_MSC_VER)
|
#elif defined(_MSC_VER)
|
||||||
#define YQ2_ATTR_MALLOC __declspec(restrict)
|
#define YQ2_ATTR_MALLOC __declspec(restrict)
|
||||||
# else
|
#define YQ2_ATTR_INLINE __forceinline
|
||||||
|
#else
|
||||||
// no equivalent per see
|
// no equivalent per see
|
||||||
#define YQ2_ATTR_MALLOC
|
#define YQ2_ATTR_MALLOC
|
||||||
#define YQ2_ATTR_INLINE inline
|
#define YQ2_ATTR_INLINE inline
|
||||||
# endif
|
#endif
|
||||||
#elif defined(__GNUC__) // GCC and clang should support this attribute
|
#elif defined(__GNUC__) // GCC and clang should support this attribute
|
||||||
#define YQ2_ALIGNAS_SIZE(SIZE) __attribute__(( __aligned__(SIZE) ))
|
#define YQ2_ALIGNAS_SIZE(SIZE) __attribute__(( __aligned__(SIZE) ))
|
||||||
#define YQ2_ALIGNAS_TYPE(TYPE) __attribute__(( __aligned__(__alignof__(TYPE)) ))
|
#define YQ2_ALIGNAS_TYPE(TYPE) __attribute__(( __aligned__(__alignof__(TYPE)) ))
|
||||||
|
@ -372,6 +373,9 @@ float frandk(void);
|
||||||
float crandk(void);
|
float crandk(void);
|
||||||
void randk_seed(void);
|
void randk_seed(void);
|
||||||
|
|
||||||
|
/* Addition code utilities */
|
||||||
|
qboolean Utils_FilenameFiltered(const char *name, const char *filter, char sepator);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ==============================================================
|
* ==============================================================
|
||||||
*
|
*
|
||||||
|
|
|
@ -1410,121 +1410,3 @@ Info_SetValueForKey(char *s, char *key, char *value)
|
||||||
|
|
||||||
*s = 0;
|
*s = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* TODO: Sync with yquake
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* name: file name
|
|
||||||
* filter: file name line rule with '*'
|
|
||||||
* return false for empty filter
|
|
||||||
*/
|
|
||||||
static qboolean
|
|
||||||
File_Filtered_Line(const char *name, const char *filter)
|
|
||||||
{
|
|
||||||
const char *current_filter = filter;
|
|
||||||
|
|
||||||
// skip empty filter
|
|
||||||
if (!*current_filter)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (*current_filter)
|
|
||||||
{
|
|
||||||
char part_filter[MAX_QPATH];
|
|
||||||
const char *name_part;
|
|
||||||
const char *str_end;
|
|
||||||
|
|
||||||
str_end = strchr(current_filter, '*');
|
|
||||||
if (!str_end)
|
|
||||||
{
|
|
||||||
if (!strstr(name, current_filter))
|
|
||||||
{
|
|
||||||
// no such part in string
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// have such part
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// copy filter line
|
|
||||||
if ((str_end - current_filter) >= MAX_QPATH)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
memcpy(part_filter, current_filter, str_end - current_filter);
|
|
||||||
part_filter[str_end - current_filter] = 0;
|
|
||||||
// place part in name
|
|
||||||
name_part = strstr(name, part_filter);
|
|
||||||
if (!name_part)
|
|
||||||
{
|
|
||||||
// no such part in string
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// have such part
|
|
||||||
name = name_part + strlen(part_filter);
|
|
||||||
// move to next filter
|
|
||||||
current_filter = str_end + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* name: file name
|
|
||||||
* filter: file names separated by sepator, and '!' for skip file
|
|
||||||
*/
|
|
||||||
qboolean
|
|
||||||
File_Filtered(const char *name, const char *filter, char sepator)
|
|
||||||
{
|
|
||||||
const char *current_filter = filter;
|
|
||||||
|
|
||||||
while (*current_filter)
|
|
||||||
{
|
|
||||||
char line_filter[MAX_QPATH];
|
|
||||||
const char *str_end;
|
|
||||||
|
|
||||||
str_end = strchr(current_filter, sepator);
|
|
||||||
// its end of filter
|
|
||||||
if (!str_end)
|
|
||||||
{
|
|
||||||
// check rules inside line
|
|
||||||
if (File_Filtered_Line(name, current_filter))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// copy filter line
|
|
||||||
if ((str_end - current_filter) >= MAX_QPATH)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
memcpy(line_filter, current_filter, str_end - current_filter);
|
|
||||||
line_filter[str_end - current_filter] = 0;
|
|
||||||
// check rules inside line
|
|
||||||
if (*line_filter == '!')
|
|
||||||
{
|
|
||||||
// has invert rule
|
|
||||||
if (File_Filtered_Line(name, line_filter + 1))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (File_Filtered_Line(name, line_filter))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// move to next filter
|
|
||||||
current_filter = str_end + 1;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* End of unsynced code
|
|
||||||
*/
|
|
||||||
|
|
137
src/common/utils.c
Normal file
137
src/common/utils.c
Normal file
|
@ -0,0 +1,137 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 1997-2001 Id Software, Inc.
|
||||||
|
*
|
||||||
|
* This program 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., 59 Temple Place - Suite 330, Boston, MA
|
||||||
|
* 02111-1307, USA.
|
||||||
|
*
|
||||||
|
* =======================================================================
|
||||||
|
*
|
||||||
|
* Additional functions shared between client and renders
|
||||||
|
*
|
||||||
|
* =======================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "header/shared.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* name: file name
|
||||||
|
* filter: file name line rule with '*'
|
||||||
|
* return false for empty filter
|
||||||
|
*/
|
||||||
|
static qboolean
|
||||||
|
Utils_FilenameFiltered_Line(const char *name, const char *filter)
|
||||||
|
{
|
||||||
|
const char *current_filter = filter;
|
||||||
|
|
||||||
|
// skip empty filter
|
||||||
|
if (!*current_filter)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (*current_filter)
|
||||||
|
{
|
||||||
|
char part_filter[MAX_QPATH];
|
||||||
|
const char *name_part;
|
||||||
|
const char *str_end;
|
||||||
|
|
||||||
|
str_end = strchr(current_filter, '*');
|
||||||
|
if (!str_end)
|
||||||
|
{
|
||||||
|
if (!strstr(name, current_filter))
|
||||||
|
{
|
||||||
|
// no such part in string
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// have such part
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// copy filter line
|
||||||
|
if ((str_end - current_filter) >= MAX_QPATH)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
memcpy(part_filter, current_filter, str_end - current_filter);
|
||||||
|
part_filter[str_end - current_filter] = 0;
|
||||||
|
// place part in name
|
||||||
|
name_part = strstr(name, part_filter);
|
||||||
|
if (!name_part)
|
||||||
|
{
|
||||||
|
// no such part in string
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// have such part
|
||||||
|
name = name_part + strlen(part_filter);
|
||||||
|
// move to next filter
|
||||||
|
current_filter = str_end + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* name: file name
|
||||||
|
* filter: file names separated by sepator, and '!' for skip file
|
||||||
|
*/
|
||||||
|
qboolean
|
||||||
|
Utils_FilenameFiltered(const char *name, const char *filter, char sepator)
|
||||||
|
{
|
||||||
|
const char *current_filter = filter;
|
||||||
|
|
||||||
|
while (*current_filter)
|
||||||
|
{
|
||||||
|
char line_filter[MAX_QPATH];
|
||||||
|
const char *str_end;
|
||||||
|
|
||||||
|
str_end = strchr(current_filter, sepator);
|
||||||
|
// its end of filter
|
||||||
|
if (!str_end)
|
||||||
|
{
|
||||||
|
// check rules inside line
|
||||||
|
if (Utils_FilenameFiltered_Line(name, current_filter))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// copy filter line
|
||||||
|
if ((str_end - current_filter) >= MAX_QPATH)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
memcpy(line_filter, current_filter, str_end - current_filter);
|
||||||
|
line_filter[str_end - current_filter] = 0;
|
||||||
|
// check rules inside line
|
||||||
|
if (*line_filter == '!')
|
||||||
|
{
|
||||||
|
// has invert rule
|
||||||
|
if (Utils_FilenameFiltered_Line(name, line_filter + 1))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (Utils_FilenameFiltered_Line(name, line_filter))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// move to next filter
|
||||||
|
current_filter = str_end + 1;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
167
src/files/pcx.c
167
src/files/pcx.c
|
@ -312,23 +312,180 @@ GetPCXInfo(const char *origname, int *width, int *height)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static byte
|
||||||
|
Convert24to8(const byte *d_8to24table, const int rgb[3])
|
||||||
|
{
|
||||||
|
int i, best, diff;
|
||||||
|
|
||||||
|
best = 255;
|
||||||
|
diff = 1 << 20;
|
||||||
|
|
||||||
|
for (i = 0; i < 256; i ++)
|
||||||
|
{
|
||||||
|
int j, curr_diff;
|
||||||
|
|
||||||
|
curr_diff = 0;
|
||||||
|
|
||||||
|
for (j = 0; j < 3; j++)
|
||||||
|
{
|
||||||
|
int v;
|
||||||
|
|
||||||
|
v = d_8to24table[i * 4 + j] - rgb[j];
|
||||||
|
curr_diff += v * v;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (curr_diff < diff)
|
||||||
|
{
|
||||||
|
diff = curr_diff;
|
||||||
|
best = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return best;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
GenerateColormap(const byte *palette, byte *out_colormap)
|
||||||
|
{
|
||||||
|
// https://quakewiki.org/wiki/Quake_palette
|
||||||
|
int num_fullbrights = 32; /* the last 32 colours will be full bright */
|
||||||
|
int x;
|
||||||
|
|
||||||
|
for (x = 0; x < 256; x++)
|
||||||
|
{
|
||||||
|
int y;
|
||||||
|
|
||||||
|
for (y = 0; y < 64; y++)
|
||||||
|
{
|
||||||
|
if (x < 256 - num_fullbrights)
|
||||||
|
{
|
||||||
|
int rgb[3], i;
|
||||||
|
|
||||||
|
for (i = 0; i < 3; i++)
|
||||||
|
{
|
||||||
|
/* divide by 32, rounding to nearest integer */
|
||||||
|
rgb[i] = (palette[x * 4 + i] * (63 - y) + 16) >> 5;
|
||||||
|
if (rgb[i] > 255)
|
||||||
|
{
|
||||||
|
rgb[i] = 255;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
out_colormap[y*256+x] = Convert24to8(palette, rgb);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* this colour is a fullbright, just keep the original colour */
|
||||||
|
out_colormap[y*256+x] = x;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
GetPCXPalette24to8(byte *d_8to24table, byte** d_16to8table)
|
||||||
|
{
|
||||||
|
unsigned char * table16to8;
|
||||||
|
char tablefile[] = "pics/16to8.dat";
|
||||||
|
|
||||||
|
*d_16to8table = NULL;
|
||||||
|
ri.FS_LoadFile(tablefile, (void **)&table16to8);
|
||||||
|
|
||||||
|
if (!table16to8)
|
||||||
|
{
|
||||||
|
R_Printf(PRINT_ALL, "%s: Couldn't load %s\n", __func__, tablefile);
|
||||||
|
}
|
||||||
|
|
||||||
|
*d_16to8table = malloc(0x10000);
|
||||||
|
if (!(*d_16to8table))
|
||||||
|
{
|
||||||
|
ri.Sys_Error(ERR_FATAL, "%s: Couldn't allocate memory for d_16to8table", __func__);
|
||||||
|
// code never returns after ERR_FATAL
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (table16to8)
|
||||||
|
{
|
||||||
|
// Use predefined convert map
|
||||||
|
memcpy(*d_16to8table, table16to8, 0x10000);
|
||||||
|
ri.FS_FreeFile((void *)table16to8);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// create new one
|
||||||
|
unsigned int r;
|
||||||
|
|
||||||
|
R_Printf(PRINT_ALL, "%s: Generate 16 to 8 bit table\n", __func__);
|
||||||
|
|
||||||
|
for (r = 0; r < 32; r++)
|
||||||
|
{
|
||||||
|
int g;
|
||||||
|
|
||||||
|
for (g = 0; g < 64; g++)
|
||||||
|
{
|
||||||
|
int b;
|
||||||
|
|
||||||
|
for (b = 0; b < 32; b++)
|
||||||
|
{
|
||||||
|
int c, rgb[3];
|
||||||
|
|
||||||
|
rgb[0] = r << 3;
|
||||||
|
rgb[1] = g << 2;
|
||||||
|
rgb[2] = b << 3;
|
||||||
|
|
||||||
|
c = r | ( g << 5 ) | ( b << 11 );
|
||||||
|
|
||||||
|
// set color with minimal difference
|
||||||
|
(*d_16to8table)[c & 0xFFFF] = Convert24to8(d_8to24table, rgb);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
===============
|
===============
|
||||||
GetPCXPalette
|
GetPCXPalette
|
||||||
===============
|
===============
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
GetPCXPalette (byte **colormap, unsigned *d_8to24table)
|
GetPCXPalette(byte **colormap, unsigned *d_8to24table)
|
||||||
{
|
{
|
||||||
|
char filename[] = "pics/colormap.pcx";
|
||||||
byte *pal;
|
byte *pal;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* get the palette and colormap */
|
/* get the palette and colormap */
|
||||||
LoadPCX ("pics/colormap.pcx", colormap, &pal, NULL, NULL);
|
LoadPCX(filename, colormap, &pal, NULL, NULL);
|
||||||
if (!*colormap || !pal)
|
if (!*colormap || !pal)
|
||||||
{
|
{
|
||||||
ri.Sys_Error (ERR_FATAL, "%s: Couldn't load pics/colormap.pcx",
|
R_Printf(PRINT_ALL, "%s: Couldn't load %s, use generated palette\n",
|
||||||
__func__);
|
__func__, filename);
|
||||||
|
|
||||||
|
/* palette r:2bit, g:3bit, b:3bit */
|
||||||
|
for (i=0 ; i < 256; i++)
|
||||||
|
{
|
||||||
|
unsigned v;
|
||||||
|
|
||||||
|
v = (255U<<24) + (((i >> 0) & 0x3) << (6 + 0)) +
|
||||||
|
(((i >> 2) & 0x7) << (5 + 8)) +
|
||||||
|
(((i >> 5) & 0x7) << (5 + 16));
|
||||||
|
d_8to24table[i] = LittleLong(v);
|
||||||
|
}
|
||||||
|
|
||||||
|
d_8to24table[255] &= LittleLong(0xffffff); // 255 is transparent
|
||||||
|
|
||||||
|
/* generate colormap */
|
||||||
|
*colormap = malloc(256 * 320);
|
||||||
|
if (!(*colormap))
|
||||||
|
{
|
||||||
|
ri.Sys_Error(ERR_FATAL, "%s: Couldn't allocate memory for colormap", __func__);
|
||||||
|
// code never returns after ERR_FATAL
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
GenerateColormap((const byte *)d_8to24table, *colormap);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i=0 ; i<256 ; i++)
|
for (i=0 ; i<256 ; i++)
|
||||||
|
@ -340,7 +497,7 @@ GetPCXPalette (byte **colormap, unsigned *d_8to24table)
|
||||||
g = pal[i*3+1];
|
g = pal[i*3+1];
|
||||||
b = pal[i*3+2];
|
b = pal[i*3+2];
|
||||||
|
|
||||||
v = (255<<24) + (r<<0) + (g<<8) + (b<<16);
|
v = (255U<<24) + (r<<0) + (g<<8) + (b<<16);
|
||||||
d_8to24table[i] = LittleLong(v);
|
d_8to24table[i] = LittleLong(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -640,6 +640,13 @@ R_FindPic(const char *name, findimage_t find_image)
|
||||||
Com_sprintf(pathname, sizeof(pathname), "pics/%s.pcx", name);
|
Com_sprintf(pathname, sizeof(pathname), "pics/%s.pcx", name);
|
||||||
image = find_image(pathname, it_pic);
|
image = find_image(pathname, it_pic);
|
||||||
|
|
||||||
|
/* Quake 2 Re-Release */
|
||||||
|
if (!image)
|
||||||
|
{
|
||||||
|
Com_sprintf(pathname, sizeof(pathname), "pics/%s.png", name);
|
||||||
|
image = find_image(pathname, it_pic);
|
||||||
|
}
|
||||||
|
|
||||||
/* Heretic 2 */
|
/* Heretic 2 */
|
||||||
if (!image)
|
if (!image)
|
||||||
{
|
{
|
||||||
|
|
|
@ -34,7 +34,7 @@ void Draw_InitLocal (void)
|
||||||
draw_chars = R_FindPic ("conchars", (findimage_t)Vk_FindImage);
|
draw_chars = R_FindPic ("conchars", (findimage_t)Vk_FindImage);
|
||||||
if (!draw_chars)
|
if (!draw_chars)
|
||||||
{
|
{
|
||||||
ri.Sys_Error(ERR_FATAL, "%s: Couldn't load pics/conchars.pcx",
|
ri.Sys_Error(ERR_FATAL, "%s: Couldn't load pics/conchars",
|
||||||
__func__);
|
__func__);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -693,9 +693,9 @@ void Vk_TextureMode( char *string )
|
||||||
if (unfiltered2D && image->type == it_pic)
|
if (unfiltered2D && image->type == it_pic)
|
||||||
{
|
{
|
||||||
// exception to that exception: stuff on the r_lerp_list
|
// exception to that exception: stuff on the r_lerp_list
|
||||||
nolerp = (lerplist == NULL) || File_Filtered(image->name, lerplist, ' ');
|
nolerp = (lerplist == NULL) || Utils_FilenameFiltered(image->name, lerplist, ' ');
|
||||||
}
|
}
|
||||||
else if (nolerplist != NULL && File_Filtered(image->name, nolerplist, ' '))
|
else if (nolerplist != NULL && Utils_FilenameFiltered(image->name, nolerplist, ' '))
|
||||||
{
|
{
|
||||||
nolerp = true;
|
nolerp = true;
|
||||||
}
|
}
|
||||||
|
@ -1106,11 +1106,11 @@ Vk_LoadPic(const char *name, byte *pic, int width, int realwidth,
|
||||||
{
|
{
|
||||||
// if r_2D_unfiltered is true(ish), nolerp should usually be true,
|
// if r_2D_unfiltered is true(ish), nolerp should usually be true,
|
||||||
// *unless* the texture is on the r_lerp_list
|
// *unless* the texture is on the r_lerp_list
|
||||||
nolerp = (lerplist == NULL) || File_Filtered(name, lerplist, ' ');
|
nolerp = (lerplist == NULL) || Utils_FilenameFiltered(name, lerplist, ' ');
|
||||||
}
|
}
|
||||||
else if (nolerplist != NULL)
|
else if (nolerplist != NULL)
|
||||||
{
|
{
|
||||||
nolerp = File_Filtered(name, nolerplist, ' ');
|
nolerp = Utils_FilenameFiltered(name, nolerplist, ' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
|
@ -1169,7 +1169,7 @@ R_Register( void )
|
||||||
r_scale8bittextures = ri.Cvar_Get("r_scale8bittextures", "0", CVAR_ARCHIVE);
|
r_scale8bittextures = ri.Cvar_Get("r_scale8bittextures", "0", CVAR_ARCHIVE);
|
||||||
vk_underwater = ri.Cvar_Get("vk_underwater", "1", CVAR_ARCHIVE);
|
vk_underwater = ri.Cvar_Get("vk_underwater", "1", CVAR_ARCHIVE);
|
||||||
/* don't bilerp characters and crosshairs */
|
/* don't bilerp characters and crosshairs */
|
||||||
r_nolerp_list = ri.Cvar_Get("r_nolerp_list", "pics/conchars.pcx pics/ch1.pcx pics/ch2.pcx pics/ch3.pcx", CVAR_ARCHIVE);
|
r_nolerp_list = ri.Cvar_Get("r_nolerp_list", DEFAULT_NOLERP_LIST, CVAR_ARCHIVE);
|
||||||
/* textures that should always be filtered, even if r_2D_unfiltered or an unfiltered gl mode is used */
|
/* textures that should always be filtered, even if r_2D_unfiltered or an unfiltered gl mode is used */
|
||||||
r_lerp_list = ri.Cvar_Get("r_lerp_list", "", CVAR_ARCHIVE);
|
r_lerp_list = ri.Cvar_Get("r_lerp_list", "", CVAR_ARCHIVE);
|
||||||
/* don't bilerp any 2D elements */
|
/* don't bilerp any 2D elements */
|
||||||
|
|
Loading…
Reference in a new issue