mirror of
https://github.com/nzp-team/fteqw.git
synced 2024-11-10 14:42:13 +00:00
con_ocranaleds preliminary (should obsolete rid# 1215521)
conwidth/conheight set to CVAR_ARCHIVE git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@1119 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
parent
d63bedbad1
commit
ed8f285738
5 changed files with 102 additions and 14 deletions
|
@ -14,6 +14,13 @@ cvar_t r_dodgytgafiles = {"r_dodgytgafiles", "0"}; //Certain tgas are upside dow
|
|||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
//the eye doesn't see different colours in the same proportion.
|
||||
//must add to slightly less than 1
|
||||
#define NTSC_RED 0.299
|
||||
#define NTSC_GREEN 0.587
|
||||
#define NTSC_BLUE 0.114
|
||||
#define NTSC_SUM (NTSC_RED + NTSC_GREEN + NTSC_BLUE)
|
||||
|
||||
typedef struct { //cm = colourmap
|
||||
char id_len; //0
|
||||
char cm_type; //1
|
||||
|
@ -135,12 +142,6 @@ char *ReadGreyTargaFile (qbyte *data, int flen, tgaheader_t *tgahead, int asgrey
|
|||
//remember to free it
|
||||
qbyte *ReadTargaFile(qbyte *buf, int length, int *width, int *height, int asgrey)
|
||||
{
|
||||
//the eye doesn't see different colours in the same proportion.
|
||||
//must add to slightly less than 1
|
||||
#define NTSC_RED 0.299
|
||||
#define NTSC_GREEN 0.587
|
||||
#define NTSC_BLUE 0.114
|
||||
|
||||
unsigned char *data;
|
||||
|
||||
qboolean flipped;
|
||||
|
@ -1570,7 +1571,7 @@ void SaturateR8G8B8(qbyte *data, int size, float sat)
|
|||
g = data[i+1];
|
||||
b = data[i+2];
|
||||
|
||||
v = r * 0.30 + g * 0.59 + b * 0.11;
|
||||
v = r * NTSC_RED + g * NTSC_GREEN + b * NTSC_BLUE;
|
||||
r = v + (r - v) * sat;
|
||||
g = v + (g - v) * sat;
|
||||
b = v + (b - v) * sat;
|
||||
|
@ -1592,9 +1593,9 @@ void SaturateR8G8B8(qbyte *data, int size, float sat)
|
|||
b = 255;
|
||||
|
||||
// scale down to avoid overbright lightmaps
|
||||
v = v / (r * 0.30 + g * 0.59 + b * 0.11);
|
||||
if (v > 1)
|
||||
v = 1;
|
||||
v = v / (r * NTSC_RED + g * NTSC_GREEN + b * NTSC_BLUE);
|
||||
if (v > NTSC_SUM)
|
||||
v = NTSC_SUM;
|
||||
else
|
||||
v *= v;
|
||||
|
||||
|
@ -1614,7 +1615,7 @@ void SaturateR8G8B8(qbyte *data, int size, float sat)
|
|||
g = data[i+1];
|
||||
b = data[i+2];
|
||||
|
||||
v = r * 0.30 + g * 0.59 + b * 0.11;
|
||||
v = r * NTSC_RED + g * NTSC_GREEN + b * NTSC_BLUE;
|
||||
|
||||
data[i] = v + (r - v) * sat;
|
||||
data[i+1] = v + (g - v) * sat;
|
||||
|
@ -1869,5 +1870,63 @@ int Mod_LoadBumpmapTexture(char *name, char *subpath)
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
// ocrana led functions
|
||||
static int ledcolors[8][3] =
|
||||
{
|
||||
// green
|
||||
{ 0, 255, 0 },
|
||||
{ 0, 127, 0 },
|
||||
// red
|
||||
{ 255, 0, 0 },
|
||||
{ 127, 0, 0 },
|
||||
// yellow
|
||||
{ 255, 255, 0 },
|
||||
{ 127, 127, 0 },
|
||||
// blue
|
||||
{ 0, 0, 255 },
|
||||
{ 0, 0, 127 }
|
||||
};
|
||||
|
||||
void AddOcranaLEDsIndexed (qbyte *image, int h, int w)
|
||||
{
|
||||
int tridx[8]; // transition indexes
|
||||
qbyte *point;
|
||||
int i, idx, x, y, rs;
|
||||
int r, g, b, rd, gd, bd;
|
||||
|
||||
rs = w;
|
||||
h /= 16;
|
||||
w /= 16;
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
// get palette
|
||||
r = ledcolors[i*2][0];
|
||||
g = ledcolors[i*2][1];
|
||||
b = ledcolors[i*2][2];
|
||||
rd = (r - ledcolors[i*2+1][0]) / 8;
|
||||
gd = (g - ledcolors[i*2+1][1]) / 8;
|
||||
bd = (b - ledcolors[i*2+1][2]) / 8;
|
||||
for (idx = 0; idx < 8; idx++)
|
||||
{
|
||||
tridx[idx] = GetPalette(r, g, b);
|
||||
r -= rd;
|
||||
g -= gd;
|
||||
b -= bd;
|
||||
}
|
||||
|
||||
// generate LED into image
|
||||
point = image + (8 * rs * h) + ((6 + i) * w);
|
||||
for (y = 1; y <= h; y++)
|
||||
{
|
||||
for (x = 1; x <= w; x++)
|
||||
{
|
||||
idx = (8 * x * y) / ((w - 1) * (h - 1));
|
||||
idx = bound(0, idx, 7);
|
||||
*point++ = tridx[idx];
|
||||
}
|
||||
point += rs - w;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -317,6 +317,7 @@ qbyte *ReadPCXPalette(qbyte *buf, int len, qbyte *out);
|
|||
|
||||
void BoostGamma(qbyte *rgba, int width, int height);
|
||||
void SaturateR8G8B8(qbyte *data, int size, float sat);
|
||||
void AddOcranaLEDsIndexed (qbyte *image, int h, int w);
|
||||
|
||||
void CL_NewDlightRGB (int key, float x, float y, float z, float radius, float time,
|
||||
float r, float g, float b);
|
||||
|
|
|
@ -105,8 +105,8 @@ cvar_t r_fb_bmodels = {"gl_fb_bmodels", "1", NULL, CVAR_SEMICHEAT|CVAR_RENDERERL
|
|||
|
||||
cvar_t gl_nocolors = {"gl_nocolors","0"};
|
||||
cvar_t gl_load24bit = {"gl_load24bit", "1"};
|
||||
cvar_t vid_conwidth = {"vid_conwidth", "640"};
|
||||
cvar_t vid_conheight = {"vid_conheight", "480"};
|
||||
cvar_t vid_conwidth = {"vid_conwidth", "640", NULL, CVAR_ARCHIVE};
|
||||
cvar_t vid_conheight = {"vid_conheight", "480", NULL, CVAR_ARCHIVE};
|
||||
cvar_t gl_nobind = {"gl_nobind", "0"};
|
||||
cvar_t gl_max_size = {"gl_max_size", "1024"};
|
||||
cvar_t gl_picmip = {"gl_picmip", "0"};
|
||||
|
@ -148,6 +148,7 @@ cvar_t scr_showturtle = {"showturtle","0"};
|
|||
cvar_t scr_showpause = {"showpause","1"};
|
||||
cvar_t scr_printspeed = {"scr_printspeed","8"};
|
||||
cvar_t scr_allowsnap = {"scr_allowsnap", "1", NULL, CVAR_NOTFROMSERVER}; //otherwise it would defeat the point.
|
||||
cvar_t con_ocranaleds = {"con_ocranaleds", "2"};
|
||||
|
||||
cvar_t scr_chatmodecvar = {"scr_chatmode", "0"};
|
||||
|
||||
|
@ -515,6 +516,9 @@ void Renderer_Init(void)
|
|||
Cvar_Register(&bul_text2, BULLETENVARS);
|
||||
Cvar_Register(&bul_text1, BULLETENVARS);
|
||||
|
||||
// misc
|
||||
Cvar_Register(&con_ocranaleds, "Console controls");
|
||||
|
||||
Cvar_Register(&bul_norender, BULLETENVARS); //find this one first...
|
||||
|
||||
Cmd_AddCommand("bul_make", R_BulletenForce_f);
|
||||
|
|
|
@ -63,6 +63,8 @@ extern cvar_t gl_savecompressedtex;
|
|||
|
||||
extern cvar_t gl_load24bit;
|
||||
|
||||
extern cvar_t con_ocranaleds;
|
||||
|
||||
qbyte *draw_chars; // 8*8 graphic characters
|
||||
mpic_t *draw_disc;
|
||||
mpic_t *draw_backtile;
|
||||
|
@ -733,9 +735,18 @@ TRACE(("dbg: GLDraw_ReInit: Allocating upload buffers\n"));
|
|||
draw_chars = W_SafeGetLumpName ("conchars");
|
||||
if (draw_chars)
|
||||
{
|
||||
x = CRC_Block(draw_chars, 128*128); // take CRC before we change anything
|
||||
|
||||
for (i=0 ; i<128*128 ; i++)
|
||||
if (draw_chars[i] == 0)
|
||||
draw_chars[i] = 255; // proper transparent color
|
||||
|
||||
// add ocrana leds
|
||||
if (con_ocranaleds.value)
|
||||
{
|
||||
if (con_ocranaleds.value != 2 || x == 798)
|
||||
AddOcranaLEDsIndexed (draw_chars, 128, 128);
|
||||
}
|
||||
}
|
||||
|
||||
// now turn them into textures
|
||||
|
|
|
@ -31,6 +31,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
extern unsigned int *d_8to32table;
|
||||
|
||||
extern cvar_t con_ocranaleds;
|
||||
|
||||
typedef struct {
|
||||
vrect_t rect;
|
||||
int width;
|
||||
|
@ -384,6 +386,7 @@ Draw_Init
|
|||
//we have a memory leak
|
||||
void SWDraw_Init (void)
|
||||
{
|
||||
int concrc = 0;
|
||||
draw_chars = W_SafeGetLumpName ("conchars"); //q1
|
||||
if (!draw_chars)
|
||||
{
|
||||
|
@ -401,6 +404,9 @@ void SWDraw_Init (void)
|
|||
draw_chars[i] = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
concrc = CRC_Block(draw_chars, 128*128); // get CRC here because it hasn't been replaced
|
||||
|
||||
if (!draw_chars)
|
||||
{ //now go for hexen2
|
||||
int i, x;
|
||||
|
@ -475,6 +481,13 @@ void SWDraw_Init (void)
|
|||
}
|
||||
if (!draw_chars)
|
||||
Sys_Error("Failed to find suitable console charactures\n");
|
||||
|
||||
// add ocrana leds
|
||||
if (con_ocranaleds.value)
|
||||
{
|
||||
if (con_ocranaleds.value != 2 || concrc == 798)
|
||||
AddOcranaLEDsIndexed (draw_chars, 128, 128);
|
||||
}
|
||||
draw_disc = W_SafeGetLumpName ("disc");
|
||||
draw_backtile = W_SafeGetLumpName ("backtile");
|
||||
if (!draw_backtile)
|
||||
|
|
Loading…
Reference in a new issue