mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-12-27 18:24:40 +00:00
Merge branch 'gifs-port' into 'master'
OpenGL GIF/Flashpal/Color Profile port See merge request KartKrew/Kart!223
This commit is contained in:
commit
f8905982dc
19 changed files with 602 additions and 211 deletions
|
|
@ -1474,32 +1474,32 @@ static void CON_DrawInput(void)
|
|||
if (input_sel < c)
|
||||
V_DrawFill(x, y, charwidth*3, (10 * con_scalefactor), 77 | V_NOSCALESTART);
|
||||
for (i = 0; i < 3; ++i, x += charwidth)
|
||||
V_DrawCharacter(x, y, '.' | cv_constextsize.value | V_GRAYMAP | V_NOSCALESTART, !cv_allcaps.value);
|
||||
V_DrawCharacter(x, y, '.' | cv_constextsize.value | V_GRAYMAP | V_NOSCALESTART, true);
|
||||
}
|
||||
else
|
||||
V_DrawCharacter(x-charwidth, y, CON_PROMPTCHAR | cv_constextsize.value | V_GRAYMAP | V_NOSCALESTART, !cv_allcaps.value);
|
||||
V_DrawCharacter(x-charwidth, y, CON_PROMPTCHAR | cv_constextsize.value | V_GRAYMAP | V_NOSCALESTART, true);
|
||||
|
||||
for (cend = c + clen; c < cend; ++c, x += charwidth)
|
||||
{
|
||||
if ((input_sel > c && input_cur <= c) || (input_sel <= c && input_cur > c))
|
||||
{
|
||||
V_DrawFill(x, y, charwidth, (10 * con_scalefactor), 77 | V_NOSCALESTART);
|
||||
V_DrawCharacter(x, y, p[c] | cv_constextsize.value | V_YELLOWMAP | V_NOSCALESTART, !cv_allcaps.value);
|
||||
V_DrawCharacter(x, y, p[c] | cv_constextsize.value | V_YELLOWMAP | V_NOSCALESTART, true);
|
||||
}
|
||||
else
|
||||
V_DrawCharacter(x, y, p[c] | cv_constextsize.value | V_NOSCALESTART, !cv_allcaps.value);
|
||||
V_DrawCharacter(x, y, p[c] | cv_constextsize.value | V_NOSCALESTART, true);
|
||||
|
||||
if (c == input_cur && con_tick >= 4)
|
||||
V_DrawCharacter(x, y + (con_scalefactor*2), '_' | cv_constextsize.value | V_NOSCALESTART, !cv_allcaps.value);
|
||||
V_DrawCharacter(x, y + (con_scalefactor*2), '_' | cv_constextsize.value | V_NOSCALESTART, true);
|
||||
}
|
||||
if (cend == input_cur && con_tick >= 4)
|
||||
V_DrawCharacter(x, y + (con_scalefactor*2), '_' | cv_constextsize.value | V_NOSCALESTART, !cv_allcaps.value);
|
||||
V_DrawCharacter(x, y + (con_scalefactor*2), '_' | cv_constextsize.value | V_NOSCALESTART, true);
|
||||
if (rellip)
|
||||
{
|
||||
if (input_sel > cend)
|
||||
V_DrawFill(x, y, charwidth*3, (10 * con_scalefactor), 77 | V_NOSCALESTART);
|
||||
for (i = 0; i < 3; ++i, x += charwidth)
|
||||
V_DrawCharacter(x, y, '.' | cv_constextsize.value | V_GRAYMAP | V_NOSCALESTART, !cv_allcaps.value);
|
||||
V_DrawCharacter(x, y, '.' | cv_constextsize.value | V_GRAYMAP | V_NOSCALESTART, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1545,11 +1545,11 @@ static void CON_DrawHudlines(void)
|
|||
else
|
||||
{
|
||||
//charwidth = SHORT(hu_font['A'-HU_FONTSTART]->width) * con_scalefactor;
|
||||
V_DrawCharacter(x, y, (INT32)(*p) | charflags | cv_constextsize.value | V_NOSCALESTART, !cv_allcaps.value);
|
||||
V_DrawCharacter(x, y, (INT32)(*p) | charflags | cv_constextsize.value | V_NOSCALESTART, true);
|
||||
}
|
||||
}
|
||||
|
||||
//V_DrawCharacter(x, y, (p[c]&0xff) | cv_constextsize.value | V_NOSCALESTART, !cv_allcaps.value);
|
||||
//V_DrawCharacter(x, y, (p[c]&0xff) | cv_constextsize.value | V_NOSCALESTART, true);
|
||||
y += charheight;
|
||||
}
|
||||
|
||||
|
|
@ -1620,7 +1620,7 @@ static void CON_DrawConsole(void)
|
|||
charflags = (*p & 0x7f) << V_CHARCOLORSHIFT;
|
||||
p++;
|
||||
}
|
||||
V_DrawCharacter(x, y, (INT32)(*p) | charflags | cv_constextsize.value | V_NOSCALESTART, !cv_allcaps.value);
|
||||
V_DrawCharacter(x, y, (INT32)(*p) | charflags | cv_constextsize.value | V_NOSCALESTART, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -811,6 +811,7 @@ void D_RegisterClientCommands(void)
|
|||
|
||||
CV_RegisterVar(&cv_screenshot_option);
|
||||
CV_RegisterVar(&cv_screenshot_folder);
|
||||
CV_RegisterVar(&cv_screenshot_colorprofile);
|
||||
CV_RegisterVar(&cv_moviemode);
|
||||
CV_RegisterVar(&cv_movie_option);
|
||||
CV_RegisterVar(&cv_movie_folder);
|
||||
|
|
@ -828,6 +829,7 @@ void D_RegisterClientCommands(void)
|
|||
// GIF variables
|
||||
CV_RegisterVar(&cv_gif_optimize);
|
||||
CV_RegisterVar(&cv_gif_downscale);
|
||||
CV_RegisterVar(&cv_gif_localcolortable);
|
||||
|
||||
#ifdef WALLSPLATS
|
||||
CV_RegisterVar(&cv_splats);
|
||||
|
|
@ -880,7 +882,29 @@ void D_RegisterClientCommands(void)
|
|||
CV_RegisterVar(&cv_netdemosyncquality);
|
||||
|
||||
// FIXME: not to be here.. but needs be done for config loading
|
||||
CV_RegisterVar(&cv_usegamma);
|
||||
CV_RegisterVar(&cv_globalgamma);
|
||||
CV_RegisterVar(&cv_globalsaturation);
|
||||
|
||||
CV_RegisterVar(&cv_rhue);
|
||||
CV_RegisterVar(&cv_yhue);
|
||||
CV_RegisterVar(&cv_ghue);
|
||||
CV_RegisterVar(&cv_chue);
|
||||
CV_RegisterVar(&cv_bhue);
|
||||
CV_RegisterVar(&cv_mhue);
|
||||
|
||||
CV_RegisterVar(&cv_rgamma);
|
||||
CV_RegisterVar(&cv_ygamma);
|
||||
CV_RegisterVar(&cv_ggamma);
|
||||
CV_RegisterVar(&cv_cgamma);
|
||||
CV_RegisterVar(&cv_bgamma);
|
||||
CV_RegisterVar(&cv_mgamma);
|
||||
|
||||
CV_RegisterVar(&cv_rsaturation);
|
||||
CV_RegisterVar(&cv_ysaturation);
|
||||
CV_RegisterVar(&cv_gsaturation);
|
||||
CV_RegisterVar(&cv_csaturation);
|
||||
CV_RegisterVar(&cv_bsaturation);
|
||||
CV_RegisterVar(&cv_msaturation);
|
||||
|
||||
// m_menu.c
|
||||
//CV_RegisterVar(&cv_compactscoreboard);
|
||||
|
|
|
|||
|
|
@ -157,7 +157,7 @@ static fademask_t *F_GetFadeMask(UINT8 masknum, UINT8 scrnnum) {
|
|||
while (lsize--)
|
||||
{
|
||||
// Determine pixel to use from fademask
|
||||
pcolor = &pLocalPalette[*lump++];
|
||||
pcolor = &pMasterPalette[*lump++];
|
||||
*mask++ = FixedDiv((pcolor->s.red+1)<<FRACBITS, paldiv)>>FRACBITS;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1196,21 +1196,24 @@ UINT8 *HWR_GetScreenshot(void)
|
|||
return buf;
|
||||
}
|
||||
|
||||
boolean HWR_Screenshot(const char *lbmname)
|
||||
boolean HWR_Screenshot(const char *pathname)
|
||||
{
|
||||
boolean ret;
|
||||
UINT8 *buf = malloc(vid.width * vid.height * 3 * sizeof (*buf));
|
||||
|
||||
if (!buf)
|
||||
{
|
||||
CONS_Debug(DBG_RENDER, "HWR_Screenshot: Failed to allocate memory\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
// returns 24bit 888 RGB
|
||||
HWD.pfnReadRect(0, 0, vid.width, vid.height, vid.width * 3, (void *)buf);
|
||||
|
||||
#ifdef USE_PNG
|
||||
ret = M_SavePNG(lbmname, buf, vid.width, vid.height, NULL);
|
||||
ret = M_SavePNG(pathname, buf, vid.width, vid.height, NULL);
|
||||
#else
|
||||
ret = saveTGA(lbmname, buf, vid.width, vid.height);
|
||||
ret = saveTGA(pathname, buf, vid.width, vid.height);
|
||||
#endif
|
||||
free(buf);
|
||||
return ret;
|
||||
|
|
|
|||
|
|
@ -582,7 +582,7 @@ static void HWR_RenderPlane(sector_t *sector, extrasubsector_t *xsub, boolean is
|
|||
if (nrPlaneVerts < 3) //not even a triangle ?
|
||||
return;
|
||||
|
||||
if ((UINT32)nrPlaneVerts > UINT16_MAX) // FIXME: exceeds plVerts size
|
||||
if (nrPlaneVerts > INT16_MAX) // FIXME: exceeds plVerts size
|
||||
{
|
||||
CONS_Debug(DBG_RENDER, "polygon size of %d exceeds max value of %d vertices\n", nrPlaneVerts, UINT16_MAX);
|
||||
return;
|
||||
|
|
@ -3229,7 +3229,7 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling,
|
|||
if (nrPlaneVerts < 3) //not even a triangle ?
|
||||
return;
|
||||
|
||||
if (nrPlaneVerts > UINT16_MAX) // FIXME: exceeds plVerts size
|
||||
if (nrPlaneVerts > INT16_MAX) // FIXME: exceeds plVerts size
|
||||
{
|
||||
CONS_Debug(DBG_RENDER, "polygon size of %s exceeds max value of %d vertices\n", sizeu1(nrPlaneVerts), UINT16_MAX);
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -38,8 +38,6 @@ void HWR_RenderSkyboxView(INT32 viewnumber, player_t *player);
|
|||
void HWR_RenderPlayerView(INT32 viewnumber, player_t *player);
|
||||
void HWR_DrawViewBorder(INT32 clearlines);
|
||||
void HWR_DrawFlatFill(INT32 x, INT32 y, INT32 w, INT32 h, lumpnum_t flatlumpnum);
|
||||
UINT8 *HWR_GetScreenshot(void);
|
||||
boolean HWR_Screenshot(const char *lbmname);
|
||||
void HWR_InitTextureMapping(void);
|
||||
void HWR_SetViewSize(void);
|
||||
void HWR_DrawPatch(GLPatch_t *gpatch, INT32 x, INT32 y, INT32 option);
|
||||
|
|
@ -54,6 +52,9 @@ void HWR_DrawConsoleFill(INT32 x, INT32 y, INT32 w, INT32 h, UINT32 color, INT32
|
|||
void HWR_DrawDiag(INT32 x, INT32 y, INT32 wh, INT32 color);
|
||||
void HWR_DrawPic(INT32 x,INT32 y,lumpnum_t lumpnum);
|
||||
|
||||
UINT8 *HWR_GetScreenshot(void);
|
||||
boolean HWR_Screenshot(const char *pathname);
|
||||
|
||||
void HWR_AddCommands(void);
|
||||
void HWR_CorrectSWTricks(void);
|
||||
void transform(float *cx, float *cy, float *cz);
|
||||
|
|
|
|||
|
|
@ -1586,7 +1586,7 @@ static void HU_drawMiniChat(void)
|
|||
if (cv_chatbacktint.value) // on request of wolfy
|
||||
V_DrawFillConsoleMap(x + dx + 2, y+dy, charwidth, charheight, 159|V_SNAPTOBOTTOM|V_SNAPTOLEFT);
|
||||
|
||||
V_DrawChatCharacter(x + dx + 2, y+dy, msg[j++] |V_SNAPTOBOTTOM|V_SNAPTOLEFT|transflag, !cv_allcaps.value, colormap);
|
||||
V_DrawChatCharacter(x + dx + 2, y+dy, msg[j++] |V_SNAPTOBOTTOM|V_SNAPTOLEFT|transflag, true, colormap);
|
||||
}
|
||||
|
||||
dx += charwidth;
|
||||
|
|
@ -1680,7 +1680,7 @@ static void HU_drawChatLog(INT32 offset)
|
|||
else
|
||||
{
|
||||
if ((y+dy+2 >= chat_topy) && (y+dy < (chat_bottomy)))
|
||||
V_DrawChatCharacter(x + dx + 2, y+dy+2, msg[j++] |V_SNAPTOBOTTOM|V_SNAPTOLEFT, !cv_allcaps.value, colormap);
|
||||
V_DrawChatCharacter(x + dx + 2, y+dy+2, msg[j++] |V_SNAPTOBOTTOM|V_SNAPTOLEFT, true, colormap);
|
||||
else
|
||||
j++; // don't forget to increment this or we'll get stuck in the limbo.
|
||||
}
|
||||
|
|
@ -1781,7 +1781,7 @@ static void HU_DrawChat(void)
|
|||
++i;
|
||||
else
|
||||
{
|
||||
V_DrawChatCharacter(chatx + c + 2, y, talk[i] |V_SNAPTOBOTTOM|V_SNAPTOLEFT|cflag, !cv_allcaps.value, V_GetStringColormap(talk[i]|cflag));
|
||||
V_DrawChatCharacter(chatx + c + 2, y, talk[i] |V_SNAPTOBOTTOM|V_SNAPTOLEFT|cflag, true, V_GetStringColormap(talk[i]|cflag));
|
||||
i++;
|
||||
}
|
||||
|
||||
|
|
@ -1799,7 +1799,7 @@ static void HU_DrawChat(void)
|
|||
typelines = 1;
|
||||
|
||||
if ((strlen(w_chat) == 0 || c_input == 0) && hu_tick < 4)
|
||||
V_DrawChatCharacter(chatx + 2 + c, y+1, '_' |V_SNAPTOBOTTOM|V_SNAPTOLEFT|t, !cv_allcaps.value, NULL);
|
||||
V_DrawChatCharacter(chatx + 2 + c, y+1, '_' |V_SNAPTOBOTTOM|V_SNAPTOLEFT|t, true, NULL);
|
||||
|
||||
while (w_chat[i])
|
||||
{
|
||||
|
|
@ -1809,7 +1809,7 @@ static void HU_DrawChat(void)
|
|||
INT32 cursorx = (c+charwidth < boxw-charwidth) ? (chatx + 2 + c+charwidth) : (chatx+1); // we may have to go down.
|
||||
INT32 cursory = (cursorx != chatx+1) ? (y) : (y+charheight);
|
||||
if (hu_tick < 4)
|
||||
V_DrawChatCharacter(cursorx, cursory+1, '_' |V_SNAPTOBOTTOM|V_SNAPTOLEFT|t, !cv_allcaps.value, NULL);
|
||||
V_DrawChatCharacter(cursorx, cursory+1, '_' |V_SNAPTOBOTTOM|V_SNAPTOLEFT|t, true, NULL);
|
||||
|
||||
if (cursorx == chatx+1 && saylen == i) // a weirdo hack
|
||||
{
|
||||
|
|
@ -1822,7 +1822,7 @@ static void HU_DrawChat(void)
|
|||
if (w_chat[i] < HU_FONTSTART)
|
||||
++i;
|
||||
else
|
||||
V_DrawChatCharacter(chatx + c + 2, y, w_chat[i++] | V_SNAPTOBOTTOM|V_SNAPTOLEFT | t, !cv_allcaps.value, NULL);
|
||||
V_DrawChatCharacter(chatx + c + 2, y, w_chat[i++] | V_SNAPTOBOTTOM|V_SNAPTOLEFT | t, true, NULL);
|
||||
|
||||
c += charwidth;
|
||||
if (c > boxw-(charwidth*2) && !skippedline)
|
||||
|
|
@ -1948,13 +1948,13 @@ static void HU_DrawChat_Old(void)
|
|||
else
|
||||
{
|
||||
//charwidth = SHORT(hu_font[talk[i]-HU_FONTSTART]->width) * con_scalefactor;
|
||||
V_DrawCharacter(HU_INPUTX + c, y, talk[i++] | cv_constextsize.value | V_NOSCALESTART, !cv_allcaps.value);
|
||||
V_DrawCharacter(HU_INPUTX + c, y, talk[i++] | cv_constextsize.value | V_NOSCALESTART, true);
|
||||
}
|
||||
c += charwidth;
|
||||
}
|
||||
|
||||
if ((strlen(w_chat) == 0 || c_input == 0) && hu_tick < 4)
|
||||
V_DrawCharacter(HU_INPUTX+c, y+2*con_scalefactor, '_' |cv_constextsize.value | V_NOSCALESTART|t, !cv_allcaps.value);
|
||||
V_DrawCharacter(HU_INPUTX+c, y+2*con_scalefactor, '_' |cv_constextsize.value | V_NOSCALESTART|t, true);
|
||||
|
||||
i = 0;
|
||||
while (w_chat[i])
|
||||
|
|
@ -1964,7 +1964,7 @@ static void HU_DrawChat_Old(void)
|
|||
{
|
||||
INT32 cursorx = (HU_INPUTX+c+charwidth < vid.width) ? (HU_INPUTX + c + charwidth) : (HU_INPUTX); // we may have to go down.
|
||||
INT32 cursory = (cursorx != HU_INPUTX) ? (y) : (y+charheight);
|
||||
V_DrawCharacter(cursorx, cursory+2*con_scalefactor, '_' |cv_constextsize.value | V_NOSCALESTART|t, !cv_allcaps.value);
|
||||
V_DrawCharacter(cursorx, cursory+2*con_scalefactor, '_' |cv_constextsize.value | V_NOSCALESTART|t, true);
|
||||
}
|
||||
|
||||
//Hurdler: isn't it better like that?
|
||||
|
|
@ -1976,7 +1976,7 @@ static void HU_DrawChat_Old(void)
|
|||
else
|
||||
{
|
||||
//charwidth = SHORT(hu_font[w_chat[i]-HU_FONTSTART]->width) * con_scalefactor;
|
||||
V_DrawCharacter(HU_INPUTX + c, y, w_chat[i++] | cv_constextsize.value | V_NOSCALESTART | t, !cv_allcaps.value);
|
||||
V_DrawCharacter(HU_INPUTX + c, y, w_chat[i++] | cv_constextsize.value | V_NOSCALESTART | t, true);
|
||||
}
|
||||
|
||||
c += charwidth;
|
||||
|
|
|
|||
150
src/m_anigif.c
150
src/m_anigif.c
|
|
@ -18,17 +18,30 @@
|
|||
#include "z_zone.h"
|
||||
#include "v_video.h"
|
||||
#include "i_video.h"
|
||||
#include "m_misc.h"
|
||||
#include "st_stuff.h" // st_palette
|
||||
|
||||
#ifdef HWRENDER
|
||||
#include "hardware/hw_main.h"
|
||||
#endif
|
||||
|
||||
// GIFs are always little-endian
|
||||
#include "byteptr.h"
|
||||
|
||||
consvar_t cv_gif_optimize = {"gif_optimize", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_gif_downscale = {"gif_downscale", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_gif_localcolortable = {"gif_localcolortable", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
#ifdef HAVE_ANIGIF
|
||||
static boolean gif_optimize = false; // So nobody can do something dumb
|
||||
static boolean gif_downscale = false; // like changing cvars mid output
|
||||
|
||||
// Palette handling
|
||||
static boolean gif_localcolortable = false;
|
||||
static boolean gif_colorprofile = false;
|
||||
static RGBA_t *gif_headerpalette = NULL;
|
||||
static RGBA_t *gif_framepalette = NULL;
|
||||
|
||||
static FILE *gif_out = NULL;
|
||||
static INT32 gif_frames = 0;
|
||||
static UINT8 gif_writeover = 0;
|
||||
|
|
@ -387,17 +400,47 @@ const UINT8 gifhead_nsid[19] = {0x21,0xFF,0x0B, // extension block + size
|
|||
0x4E,0x45,0x54,0x53,0x43,0x41,0x50,0x45,0x32,0x2E,0x30, // NETSCAPE2.0
|
||||
0x03,0x01,0xFF,0xFF,0x00}; // sub-block, repetitions
|
||||
|
||||
|
||||
//
|
||||
// GIF_getpalette
|
||||
// determine the palette for the current frame.
|
||||
//
|
||||
static RGBA_t *GIF_getpalette(size_t palnum)
|
||||
{
|
||||
// In hardware mode, uses the master palette
|
||||
return ((gif_colorprofile
|
||||
#ifdef HWRENDER
|
||||
&& (rendermode == render_soft)
|
||||
#endif
|
||||
) ? &pLocalPalette[palnum*256]
|
||||
: &pMasterPalette[palnum*256]);
|
||||
}
|
||||
|
||||
//
|
||||
// GIF_palwrite
|
||||
// writes the gif palette.
|
||||
// used both for the header and local color tables.
|
||||
//
|
||||
static UINT8 *GIF_palwrite(UINT8 *p, RGBA_t *pal)
|
||||
{
|
||||
INT32 i;
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
WRITEUINT8(p, pal[i].s.red);
|
||||
WRITEUINT8(p, pal[i].s.green);
|
||||
WRITEUINT8(p, pal[i].s.blue);
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
//
|
||||
// GIF_headwrite
|
||||
// writes the gif header to the currently open output file.
|
||||
// NOTE that this code does not accomodate for palette changes.
|
||||
//
|
||||
static void GIF_headwrite(void)
|
||||
{
|
||||
UINT8 *gifhead = Z_Malloc(800, PU_STATIC, NULL);
|
||||
UINT8 *p = gifhead;
|
||||
RGBA_t *c;
|
||||
INT32 i;
|
||||
UINT16 rwidth, rheight;
|
||||
|
||||
if (!gif_out)
|
||||
|
|
@ -418,22 +461,21 @@ static void GIF_headwrite(void)
|
|||
rwidth = vid.width;
|
||||
rheight = vid.height;
|
||||
}
|
||||
|
||||
WRITEUINT16(p, rwidth);
|
||||
WRITEUINT16(p, rheight);
|
||||
|
||||
// colors, aspect, etc
|
||||
WRITEUINT8(p, 0xFF); // TRANSPARENTPIXEL
|
||||
/*
|
||||
also these are magical values, check out
|
||||
https://tronche.com/computer-graphics/gif/gif89a.html#screen-descriptor
|
||||
*/
|
||||
WRITEUINT8(p, 0xF7); // (0xF7 = 1111 0111)
|
||||
WRITEUINT8(p, 0x00);
|
||||
WRITEUINT8(p, 0x00);
|
||||
|
||||
// write color table
|
||||
for (i = 0; i < 256; ++i)
|
||||
{
|
||||
c = &pLocalPalette[i];
|
||||
WRITEUINT8(p, c->s.red);
|
||||
WRITEUINT8(p, c->s.green);
|
||||
WRITEUINT8(p, c->s.blue);
|
||||
}
|
||||
p = GIF_palwrite(p, gif_headerpalette);
|
||||
|
||||
// write extension block
|
||||
WRITEMEM(p, gifhead_nsid, sizeof(gifhead_nsid));
|
||||
|
|
@ -452,6 +494,32 @@ const UINT8 gifframe_gchead[4] = {0x21,0xF9,0x04,0x04}; // GCE, bytes, packed by
|
|||
static UINT8 *gifframe_data = NULL;
|
||||
static size_t gifframe_size = 8192;
|
||||
|
||||
#ifdef HWRENDER
|
||||
static void hwrconvert(void)
|
||||
{
|
||||
UINT8 *linear = HWR_GetScreenshot();
|
||||
UINT8 *dest = screens[2];
|
||||
UINT8 r, g, b;
|
||||
INT32 x, y;
|
||||
size_t i = 0;
|
||||
|
||||
InitColorLUT(gif_framepalette);
|
||||
|
||||
for (y = 0; y < vid.height; y++)
|
||||
{
|
||||
for (x = 0; x < vid.width; x++, i += 3)
|
||||
{
|
||||
r = (UINT8)linear[i];
|
||||
g = (UINT8)linear[i + 1];
|
||||
b = (UINT8)linear[i + 2];
|
||||
dest[(y * vid.width) + x] = colorlookup[r >> SHIFTCOLORBITS][g >> SHIFTCOLORBITS][b >> SHIFTCOLORBITS];
|
||||
}
|
||||
}
|
||||
|
||||
free(linear);
|
||||
}
|
||||
#endif
|
||||
|
||||
//
|
||||
// GIF_framewrite
|
||||
// writes a frame into the file.
|
||||
|
|
@ -461,6 +529,7 @@ static void GIF_framewrite(void)
|
|||
UINT8 *p;
|
||||
UINT8 *movie_screen = screens[2];
|
||||
INT32 blitx, blity, blitw, blith;
|
||||
boolean palchanged;
|
||||
|
||||
if (!gifframe_data)
|
||||
gifframe_data = Z_Malloc(gifframe_size, PU_STATIC, NULL);
|
||||
|
|
@ -469,15 +538,30 @@ static void GIF_framewrite(void)
|
|||
if (!gif_out)
|
||||
return;
|
||||
|
||||
// Lactozilla: Compare the header's palette with the current frame's palette and see if it changed.
|
||||
if (gif_localcolortable)
|
||||
{
|
||||
gif_framepalette = GIF_getpalette(max(st_palette, 0));
|
||||
palchanged = memcmp(gif_headerpalette, gif_framepalette, sizeof(RGBA_t) * 256);
|
||||
}
|
||||
else
|
||||
palchanged = false;
|
||||
|
||||
// Compare image data (for optimizing GIF)
|
||||
if (gif_optimize && gif_frames > 0)
|
||||
// If the palette has changed, the entire frame is considered to be different.
|
||||
if (gif_optimize && gif_frames > 0 && (!palchanged))
|
||||
{
|
||||
// before blit movie_screen points to last frame, cur_screen points to this frame
|
||||
UINT8 *cur_screen = screens[0];
|
||||
GIF_optimizeregion(cur_screen, movie_screen, &blitx, &blity, &blitw, &blith);
|
||||
|
||||
// blit to temp screen
|
||||
I_ReadScreen(movie_screen);
|
||||
if (rendermode == render_soft)
|
||||
I_ReadScreen(movie_screen);
|
||||
#ifdef HWRENDER
|
||||
else if (rendermode == render_opengl)
|
||||
hwrconvert();
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -486,7 +570,18 @@ static void GIF_framewrite(void)
|
|||
blith = vid.height;
|
||||
|
||||
if (gif_frames == 0)
|
||||
I_ReadScreen(movie_screen);
|
||||
{
|
||||
if (rendermode == render_soft)
|
||||
I_ReadScreen(movie_screen);
|
||||
#ifdef HWRENDER
|
||||
else if (rendermode == render_opengl)
|
||||
{
|
||||
hwrconvert();
|
||||
VID_BlitLinearScreen(screens[2], screens[0], vid.width*vid.bpp, vid.height, vid.width*vid.bpp, vid.rowbytes);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
movie_screen = screens[0];
|
||||
}
|
||||
|
||||
|
|
@ -517,7 +612,20 @@ static void GIF_framewrite(void)
|
|||
WRITEUINT16(p, (UINT16)(blity / scrbuf_downscaleamt));
|
||||
WRITEUINT16(p, (UINT16)(blitw / scrbuf_downscaleamt));
|
||||
WRITEUINT16(p, (UINT16)(blith / scrbuf_downscaleamt));
|
||||
WRITEUINT8(p, 0); // no local table of colors
|
||||
|
||||
if (!gif_localcolortable)
|
||||
WRITEUINT8(p, 0); // no local table of colors
|
||||
else
|
||||
{
|
||||
if (palchanged)
|
||||
{
|
||||
// The palettes are different, so write the Local Color Table!
|
||||
WRITEUINT8(p, 0x87); // (0x87 = 1000 0111)
|
||||
p = GIF_palwrite(p, gif_framepalette);
|
||||
}
|
||||
else
|
||||
WRITEUINT8(p, 0); // They are equal, no Local Color Table needed.
|
||||
}
|
||||
|
||||
scrbuf_pos = movie_screen + blitx + (blity * vid.width);
|
||||
scrbuf_writeend = scrbuf_pos + (blitw - 1) + ((blith - 1) * vid.width);
|
||||
|
|
@ -575,20 +683,16 @@ static void GIF_framewrite(void)
|
|||
//
|
||||
INT32 GIF_open(const char *filename)
|
||||
{
|
||||
#ifdef HWRENDER
|
||||
if (rendermode != render_soft)
|
||||
{
|
||||
CONS_Alert(CONS_WARNING, M_GetText("GIFs cannot be taken in non-software modes!\n"));
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
gif_out = fopen(filename, "wb");
|
||||
if (!gif_out)
|
||||
return 0;
|
||||
|
||||
gif_optimize = (!!cv_gif_optimize.value);
|
||||
gif_downscale = (!!cv_gif_downscale.value);
|
||||
gif_localcolortable = (!!cv_gif_localcolortable.value);
|
||||
gif_colorprofile = (!!cv_screenshot_colorprofile.value);
|
||||
gif_headerpalette = GIF_getpalette(0);
|
||||
|
||||
GIF_headwrite();
|
||||
gif_frames = 0;
|
||||
return 1;
|
||||
|
|
|
|||
|
|
@ -27,6 +27,6 @@ void GIF_frame(void);
|
|||
INT32 GIF_close(void);
|
||||
#endif
|
||||
|
||||
extern consvar_t cv_gif_optimize, cv_gif_downscale;
|
||||
extern consvar_t cv_gif_optimize, cv_gif_downscale, cv_gif_localcolortable;
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1252,7 +1252,7 @@ static menuitem_t OP_VideoOptionsMenu[] =
|
|||
{IT_STRING|IT_CVAR, NULL, "Fullscreen", &cv_fullscreen, 20},
|
||||
#endif
|
||||
{IT_STRING | IT_CVAR | IT_CV_SLIDER,
|
||||
NULL, "Gamma", &cv_usegamma, 30},
|
||||
NULL, "Gamma", &cv_globalgamma, 30},
|
||||
|
||||
{IT_STRING | IT_CVAR, NULL, "Draw Distance", &cv_drawdist, 45},
|
||||
//{IT_STRING | IT_CVAR, NULL, "NiGHTS Draw Dist", &cv_drawdist_nights, 55},
|
||||
|
|
@ -2675,7 +2675,7 @@ boolean M_Responder(event_t *ev)
|
|||
return true;
|
||||
|
||||
case KEY_F11: // Gamma Level
|
||||
CV_AddValue(&cv_usegamma, 1);
|
||||
CV_AddValue(&cv_globalgamma, 1);
|
||||
return true;
|
||||
|
||||
// Spymode on F12 handled in game logic
|
||||
|
|
@ -3321,9 +3321,6 @@ void M_Init(void)
|
|||
#ifndef NONET
|
||||
CV_RegisterVar(&cv_serversort);
|
||||
#endif
|
||||
|
||||
//todo put this somewhere better...
|
||||
CV_RegisterVar(&cv_allcaps);
|
||||
}
|
||||
|
||||
void M_InitCharacterTables(void)
|
||||
|
|
|
|||
96
src/m_misc.c
96
src/m_misc.c
|
|
@ -32,6 +32,7 @@
|
|||
#include "g_game.h"
|
||||
#include "m_misc.h"
|
||||
#include "hu_stuff.h"
|
||||
#include "st_stuff.h"
|
||||
#include "v_video.h"
|
||||
#include "z_zone.h"
|
||||
#include "g_input.h"
|
||||
|
|
@ -106,6 +107,8 @@ static CV_PossibleValue_t screenshot_cons_t[] = {{0, "Default"}, {1, "HOME"}, {2
|
|||
consvar_t cv_screenshot_option = {"screenshot_option", "Default", CV_SAVE|CV_CALL, screenshot_cons_t, Screenshot_option_Onchange, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_screenshot_folder = {"screenshot_folder", "", CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
consvar_t cv_screenshot_colorprofile = {"screenshot_colorprofile", "Yes", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
static CV_PossibleValue_t moviemode_cons_t[] = {{MM_GIF, "GIF"}, {MM_APNG, "aPNG"}, {MM_SCREENSHOT, "Screenshots"}, {0, NULL}};
|
||||
consvar_t cv_moviemode = {"moviemode_mode", "GIF", CV_SAVE|CV_CALL, moviemode_cons_t, Moviemode_mode_Onchange, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
|
|
@ -591,6 +594,21 @@ void M_SaveConfig(const char *filename)
|
|||
fclose(f);
|
||||
}
|
||||
|
||||
// ==========================================================================
|
||||
// SCREENSHOTS
|
||||
// ==========================================================================
|
||||
static UINT8 screenshot_palette[768];
|
||||
static void M_CreateScreenShotPalette(void)
|
||||
{
|
||||
size_t i, j;
|
||||
for (i = 0, j = 0; i < 768; i += 3, j++)
|
||||
{
|
||||
RGBA_t locpal = pLocalPalette[(max(st_palette,0)*256)+j];
|
||||
screenshot_palette[i] = locpal.s.red;
|
||||
screenshot_palette[i+1] = locpal.s.green;
|
||||
screenshot_palette[i+2] = locpal.s.blue;
|
||||
}
|
||||
}
|
||||
|
||||
#if NUMSCREENS > 2
|
||||
static const char *Newsnapshotfile(const char *pathname, const char *ext)
|
||||
|
|
@ -665,14 +683,17 @@ static void M_PNGhdr(png_structp png_ptr, png_infop png_info_ptr, PNG_CONST png_
|
|||
if (palette)
|
||||
{
|
||||
png_colorp png_PLTE = png_malloc(png_ptr, sizeof(png_color)*256); //palette
|
||||
const png_byte *pal = palette;
|
||||
png_uint_16 i;
|
||||
|
||||
const png_byte *pal = palette;
|
||||
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
png_PLTE[i].red = *pal; pal++;
|
||||
png_PLTE[i].green = *pal; pal++;
|
||||
png_PLTE[i].blue = *pal; pal++;
|
||||
}
|
||||
|
||||
png_set_IHDR(png_ptr, png_info_ptr, width, height, 8, PNG_COLOR_TYPE_PALETTE,
|
||||
png_interlace, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
|
||||
png_write_info_before_PLTE(png_ptr, png_info_ptr);
|
||||
|
|
@ -1022,6 +1043,7 @@ static boolean M_SetupaPNG(png_const_charp filename, png_bytep pal)
|
|||
static inline moviemode_t M_StartMovieAPNG(const char *pathname)
|
||||
{
|
||||
#ifdef USE_APNG
|
||||
UINT8 *palette;
|
||||
const char *freename = NULL;
|
||||
boolean ret = false;
|
||||
|
||||
|
|
@ -1037,10 +1059,8 @@ static inline moviemode_t M_StartMovieAPNG(const char *pathname)
|
|||
return MM_OFF;
|
||||
}
|
||||
|
||||
if (rendermode == render_soft)
|
||||
ret = M_SetupaPNG(va(pandf,pathname,freename), W_CacheLumpName(GetPalette(), PU_CACHE));
|
||||
else
|
||||
ret = M_SetupaPNG(va(pandf,pathname,freename), NULL);
|
||||
if (rendermode == render_soft) M_CreateScreenShotPalette();
|
||||
ret = M_SetupaPNG(va(pandf,pathname,freename), (palette = screenshot_palette));
|
||||
|
||||
if (!ret)
|
||||
{
|
||||
|
|
@ -1111,12 +1131,8 @@ void M_StartMovie(void)
|
|||
switch (cv_moviemode.value)
|
||||
{
|
||||
case MM_GIF:
|
||||
if (rendermode == render_soft)
|
||||
{
|
||||
moviemode = M_StartMovieGIF(pathname);
|
||||
break;
|
||||
}
|
||||
/* FALLTHRU */
|
||||
moviemode = M_StartMovieGIF(pathname);
|
||||
break;
|
||||
case MM_APNG:
|
||||
moviemode = M_StartMovieAPNG(pathname);
|
||||
break;
|
||||
|
|
@ -1249,14 +1265,13 @@ void M_StopMovie(void)
|
|||
* \param data The image data.
|
||||
* \param width Width of the picture.
|
||||
* \param height Height of the picture.
|
||||
* \param palette Palette of image data
|
||||
* \param palette Palette of image data.
|
||||
* \note if palette is NULL, BGR888 format
|
||||
*/
|
||||
boolean M_SavePNG(const char *filename, void *data, int width, int height, const UINT8 *palette)
|
||||
{
|
||||
png_structp png_ptr;
|
||||
png_infop png_info_ptr;
|
||||
PNG_CONST png_byte *PLTE = (const png_byte *)palette;
|
||||
#ifdef PNG_SETJMP_SUPPORTED
|
||||
#ifdef USE_FAR_KEYWORD
|
||||
jmp_buf jmpbuf;
|
||||
|
|
@ -1271,8 +1286,7 @@ boolean M_SavePNG(const char *filename, void *data, int width, int height, const
|
|||
return false;
|
||||
}
|
||||
|
||||
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL,
|
||||
PNG_error, PNG_warn);
|
||||
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, PNG_error, PNG_warn);
|
||||
if (!png_ptr)
|
||||
{
|
||||
CONS_Debug(DBG_RENDER, "M_SavePNG: Error on initialize libpng\n");
|
||||
|
|
@ -1319,7 +1333,7 @@ boolean M_SavePNG(const char *filename, void *data, int width, int height, const
|
|||
png_set_compression_strategy(png_ptr, cv_zlib_strategy.value);
|
||||
png_set_compression_window_bits(png_ptr, cv_zlib_window_bits.value);
|
||||
|
||||
M_PNGhdr(png_ptr, png_info_ptr, width, height, PLTE);
|
||||
M_PNGhdr(png_ptr, png_info_ptr, width, height, palette);
|
||||
|
||||
M_PNGText(png_ptr, png_info_ptr, false);
|
||||
|
||||
|
|
@ -1366,7 +1380,7 @@ typedef struct
|
|||
* \param palette Palette of image data
|
||||
*/
|
||||
#if NUMSCREENS > 2
|
||||
static boolean WritePCXfile(const char *filename, const UINT8 *data, int width, int height, const UINT8 *palette)
|
||||
static boolean WritePCXfile(const char *filename, const UINT8 *data, int width, int height)
|
||||
{
|
||||
int i;
|
||||
size_t length;
|
||||
|
|
@ -1407,8 +1421,20 @@ static boolean WritePCXfile(const char *filename, const UINT8 *data, int width,
|
|||
|
||||
// write the palette
|
||||
*pack++ = 0x0c; // palette ID byte
|
||||
for (i = 0; i < 768; i++)
|
||||
*pack++ = *palette++;
|
||||
|
||||
// write color table
|
||||
{
|
||||
RGBA_t *pal = ((cv_screenshot_colorprofile.value)
|
||||
? pLocalPalette
|
||||
: pMasterPalette);
|
||||
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
*pack++ = pal[i].s.red;
|
||||
*pack++ = pal[i].s.green;
|
||||
*pack++ = pal[i].s.blue;
|
||||
}
|
||||
}
|
||||
|
||||
// write output file
|
||||
length = pack - (UINT8 *)pcx;
|
||||
|
|
@ -1426,9 +1452,8 @@ void M_ScreenShot(void)
|
|||
}
|
||||
|
||||
/** Takes a screenshot.
|
||||
* The screenshot is saved as "kartxxxx.pcx" (or "kartxxxx.tga" in hardware
|
||||
* rendermode) where xxxx is the lowest four-digit number for which a file
|
||||
* does not already exist.
|
||||
* The screenshot is saved as "srb2xxxx.png" where xxxx is the lowest
|
||||
* four-digit number for which a file does not already exist.
|
||||
*
|
||||
* \sa HWR_ScreenShot
|
||||
*/
|
||||
|
|
@ -1443,6 +1468,10 @@ void M_DoScreenShot(void)
|
|||
// Don't take multiple screenshots, obviously
|
||||
takescreenshot = false;
|
||||
|
||||
// how does one take a screenshot without a render system?
|
||||
if (rendermode == render_none)
|
||||
return;
|
||||
|
||||
if (cv_screenshot_option.value == 0)
|
||||
strcpy(pathname, usehome ? srb2home : srb2path);
|
||||
else if (cv_screenshot_option.value == 1)
|
||||
|
|
@ -1459,16 +1488,13 @@ void M_DoScreenShot(void)
|
|||
}
|
||||
|
||||
#ifdef USE_PNG
|
||||
if (rendermode != render_none)
|
||||
freename = Newsnapshotfile(pathname,"png");
|
||||
freename = Newsnapshotfile(pathname,"png");
|
||||
#else
|
||||
if (rendermode == render_soft)
|
||||
freename = Newsnapshotfile(pathname,"pcx");
|
||||
else if (rendermode != render_none)
|
||||
else if (rendermode == render_opengl)
|
||||
freename = Newsnapshotfile(pathname,"tga");
|
||||
#endif
|
||||
else
|
||||
I_Error("Can't take a screenshot without a render system");
|
||||
|
||||
if (rendermode == render_soft)
|
||||
{
|
||||
|
|
@ -1482,18 +1508,16 @@ void M_DoScreenShot(void)
|
|||
|
||||
// save the pcx file
|
||||
#ifdef HWRENDER
|
||||
if (rendermode != render_soft)
|
||||
if (rendermode == render_opengl)
|
||||
ret = HWR_Screenshot(va(pandf,pathname,freename));
|
||||
else
|
||||
#endif
|
||||
if (rendermode != render_none)
|
||||
{
|
||||
M_CreateScreenShotPalette();
|
||||
#ifdef USE_PNG
|
||||
ret = M_SavePNG(va(pandf,pathname,freename), linear, vid.width, vid.height,
|
||||
W_CacheLumpName(GetPalette(), PU_CACHE));
|
||||
ret = M_SavePNG(va(pandf,pathname,freename), linear, vid.width, vid.height, screenshot_palette);
|
||||
#else
|
||||
ret = WritePCXfile(va(pandf,pathname,freename), linear, vid.width, vid.height,
|
||||
W_CacheLumpName(GetPalette(), PU_CACHE));
|
||||
ret = WritePCXfile(va(pandf,pathname,freename), linear, vid.width, vid.height, screenshot_palette);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -1501,14 +1525,14 @@ failure:
|
|||
if (ret)
|
||||
{
|
||||
if (moviemode != MM_SCREENSHOT)
|
||||
CONS_Printf(M_GetText("screen shot %s saved in %s\n"), freename, pathname);
|
||||
CONS_Printf(M_GetText("Screen shot %s saved in %s\n"), freename, pathname);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (freename)
|
||||
CONS_Printf(M_GetText("Couldn't create screen shot %s in %s\n"), freename, pathname);
|
||||
CONS_Alert(CONS_ERROR, M_GetText("Couldn't create screen shot %s in %s\n"), freename, pathname);
|
||||
else
|
||||
CONS_Printf(M_GetText("Couldn't create screen shot (all 10000 slots used!) in %s\n"), pathname);
|
||||
CONS_Alert(CONS_ERROR, M_GetText("Couldn't create screen shot in %s (all 10000 slots used!)\n"), pathname);
|
||||
|
||||
if (moviemode == MM_SCREENSHOT)
|
||||
M_StopMovie();
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ typedef enum {
|
|||
} moviemode_t;
|
||||
extern moviemode_t moviemode;
|
||||
|
||||
extern consvar_t cv_screenshot_option, cv_screenshot_folder;
|
||||
extern consvar_t cv_screenshot_option, cv_screenshot_folder, cv_screenshot_colorprofile;
|
||||
extern consvar_t cv_moviemode, cv_movie_folder, cv_movie_option;
|
||||
extern consvar_t cv_zlib_memory, cv_zlib_level, cv_zlib_strategy, cv_zlib_window_bits;
|
||||
extern consvar_t cv_zlib_memorya, cv_zlib_levela, cv_zlib_strategya, cv_zlib_window_bitsa;
|
||||
|
|
|
|||
49
src/r_data.c
49
src/r_data.c
|
|
@ -22,7 +22,7 @@
|
|||
#include "w_wad.h"
|
||||
#include "z_zone.h"
|
||||
#include "p_setup.h" // levelflats
|
||||
#include "v_video.h" // pLocalPalette
|
||||
#include "v_video.h" // pMasterPalette
|
||||
#include "dehacked.h"
|
||||
|
||||
#if defined (_WIN32) || defined (_WIN32_WCE)
|
||||
|
|
@ -1192,7 +1192,7 @@ void R_MakeInvertmap(void)
|
|||
INT32 R_CreateColormap(char *p1, char *p2, char *p3)
|
||||
{
|
||||
double cmaskr, cmaskg, cmaskb, cdestr, cdestg, cdestb;
|
||||
double maskamt = 0, othermask = 0;
|
||||
double r, g, b, cbrightness, maskamt = 0, othermask = 0;
|
||||
int mask, fog = 0;
|
||||
size_t mapnum = num_extra_colormaps;
|
||||
size_t i;
|
||||
|
|
@ -1300,6 +1300,32 @@ INT32 R_CreateColormap(char *p1, char *p2, char *p3)
|
|||
|
||||
num_extra_colormaps++;
|
||||
|
||||
if (rendermode == render_soft)
|
||||
{
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
r = pMasterPalette[i].s.red;
|
||||
g = pMasterPalette[i].s.green;
|
||||
b = pMasterPalette[i].s.blue;
|
||||
cbrightness = sqrt((r*r) + (g*g) + (b*b));
|
||||
|
||||
map[i][0] = (cbrightness * cmaskr) + (r * othermask);
|
||||
if (map[i][0] > 255.0l)
|
||||
map[i][0] = 255.0l;
|
||||
deltas[i][0] = (map[i][0] - cdestr) / (double)fadedist;
|
||||
|
||||
map[i][1] = (cbrightness * cmaskg) + (g * othermask);
|
||||
if (map[i][1] > 255.0l)
|
||||
map[i][1] = 255.0l;
|
||||
deltas[i][1] = (map[i][1] - cdestg) / (double)fadedist;
|
||||
|
||||
map[i][2] = (cbrightness * cmaskb) + (b * othermask);
|
||||
if (map[i][2] > 255.0l)
|
||||
map[i][2] = 255.0l;
|
||||
deltas[i][2] = (map[i][2] - cdestb) / (double)fadedist;
|
||||
}
|
||||
}
|
||||
|
||||
foundcolormaps[mapnum] = LUMPERROR;
|
||||
|
||||
// aligned on 8 bit for asm code
|
||||
|
|
@ -1313,7 +1339,6 @@ INT32 R_CreateColormap(char *p1, char *p2, char *p3)
|
|||
|
||||
if (rendermode == render_soft)
|
||||
{
|
||||
double r, g, b, cbrightness;
|
||||
int p;
|
||||
lighttable_t *colormap_p;
|
||||
|
||||
|
|
@ -1324,9 +1349,9 @@ INT32 R_CreateColormap(char *p1, char *p2, char *p3)
|
|||
// map[i]'s values are decremented by after each use
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
r = pLocalPalette[i].s.red;
|
||||
g = pLocalPalette[i].s.green;
|
||||
b = pLocalPalette[i].s.blue;
|
||||
r = pMasterPalette[i].s.red;
|
||||
g = pMasterPalette[i].s.green;
|
||||
b = pMasterPalette[i].s.blue;
|
||||
cbrightness = sqrt((r*r) + (g*g) + (b*b));
|
||||
|
||||
map[i][0] = (cbrightness * cmaskr) + (r * othermask);
|
||||
|
|
@ -1402,16 +1427,20 @@ INT32 R_CreateColormap(char *p1, char *p2, char *p3)
|
|||
|
||||
// Thanks to quake2 source!
|
||||
// utils3/qdata/images.c
|
||||
UINT8 NearestColor(UINT8 r, UINT8 g, UINT8 b)
|
||||
UINT8 NearestPaletteColor(UINT8 r, UINT8 g, UINT8 b, RGBA_t *palette)
|
||||
{
|
||||
int dr, dg, db;
|
||||
int distortion, bestdistortion = 256 * 256 * 4, bestcolor = 0, i;
|
||||
|
||||
// Use master palette if none specified
|
||||
if (palette == NULL)
|
||||
palette = pMasterPalette;
|
||||
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
dr = r - pLocalPalette[i].s.red;
|
||||
dg = g - pLocalPalette[i].s.green;
|
||||
db = b - pLocalPalette[i].s.blue;
|
||||
dr = r - palette[i].s.red;
|
||||
dg = g - palette[i].s.green;
|
||||
db = b - palette[i].s.blue;
|
||||
distortion = dr*dr + dg*dg + db*db;
|
||||
if (distortion < bestdistortion)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -99,6 +99,9 @@ void R_MakeInvertmap(void);
|
|||
#endif
|
||||
const char *R_ColormapNameForNum(INT32 num);
|
||||
|
||||
UINT8 NearestPaletteColor(UINT8 r, UINT8 g, UINT8 b, RGBA_t *palette);
|
||||
#define NearestColor(r, g, b) NearestPaletteColor(r, g, b, NULL)
|
||||
|
||||
extern INT32 numtextures;
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1647,6 +1647,7 @@ INT32 VID_SetMode(INT32 modeNum)
|
|||
//Impl_SetWindowName("SRB2Kart "VERSIONSTRING);
|
||||
|
||||
SDLSetMode(vid.width, vid.height, USE_FULLSCREEN);
|
||||
Impl_VideoSetupBuffer();
|
||||
|
||||
if (rendermode == render_soft)
|
||||
{
|
||||
|
|
@ -1655,8 +1656,6 @@ INT32 VID_SetMode(INT32 modeNum)
|
|||
SDL_FreeSurface(bufSurface);
|
||||
bufSurface = NULL;
|
||||
}
|
||||
|
||||
Impl_VideoSetupBuffer();
|
||||
}
|
||||
|
||||
return SDL_TRUE;
|
||||
|
|
@ -1779,7 +1778,7 @@ static void Impl_VideoSetupSDLBuffer(void)
|
|||
static void Impl_VideoSetupBuffer(void)
|
||||
{
|
||||
// Set up game's software render buffer
|
||||
if (rendermode == render_soft)
|
||||
//if (rendermode == render_soft)
|
||||
{
|
||||
vid.rowbytes = vid.width * vid.bpp;
|
||||
vid.direct = NULL;
|
||||
|
|
|
|||
|
|
@ -203,7 +203,7 @@ void ST_Ticker(void)
|
|||
}
|
||||
|
||||
// 0 is default, any others are special palettes.
|
||||
static INT32 st_palette = 0;
|
||||
INT32 st_palette = 0;
|
||||
|
||||
void ST_doPaletteStuff(void)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ boolean ST_SameTeam(player_t *a, player_t *b);
|
|||
//--------------------
|
||||
|
||||
extern boolean st_overlay; // sb overlay on or off when fullscreen
|
||||
extern INT32 st_palette; // 0 is default, any others are special palettes.
|
||||
|
||||
extern lumpnum_t st_borderpatchnum;
|
||||
// patches, also used in intermission
|
||||
|
|
|
|||
393
src/v_video.c
393
src/v_video.c
|
|
@ -38,13 +38,39 @@ UINT8 *screens[5];
|
|||
// screens[3] = fade screen start
|
||||
// screens[4] = fade screen end, postimage tempoarary buffer
|
||||
|
||||
static CV_PossibleValue_t gamma_cons_t[] = {{0, "MIN"}, {4, "MAX"}, {0, NULL}};
|
||||
static void CV_usegamma_OnChange(void);
|
||||
consvar_t cv_ticrate = {"showfps", "No", 0, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
consvar_t cv_ticrate = {"showfps", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_usegamma = {"gamma", "0", CV_SAVE|CV_CALL, gamma_cons_t, CV_usegamma_OnChange, 0, NULL, NULL, 0, 0, NULL};
|
||||
static void CV_palette_OnChange(void);
|
||||
|
||||
consvar_t cv_allcaps = {"allcaps", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
static CV_PossibleValue_t gamma_cons_t[] = {{-15, "MIN"}, {5, "MAX"}, {0, NULL}};
|
||||
consvar_t cv_globalgamma = {"gamma", "0", CV_SAVE|CV_CALL, gamma_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
static CV_PossibleValue_t saturation_cons_t[] = {{0, "MIN"}, {10, "MAX"}, {0, NULL}};
|
||||
consvar_t cv_globalsaturation = {"saturation", "10", CV_SAVE|CV_CALL, saturation_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
#define huecoloursteps 4
|
||||
|
||||
static CV_PossibleValue_t hue_cons_t[] = {{0, "MIN"}, {(huecoloursteps*6)-1, "MAX"}, {0, NULL}};
|
||||
consvar_t cv_rhue = {"rhue", "0", CV_SAVE|CV_CALL, hue_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_yhue = {"yhue", "4", CV_SAVE|CV_CALL, hue_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_ghue = {"ghue", "8", CV_SAVE|CV_CALL, hue_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_chue = {"chue", "12", CV_SAVE|CV_CALL, hue_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_bhue = {"bhue", "16", CV_SAVE|CV_CALL, hue_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_mhue = {"mhue", "20", CV_SAVE|CV_CALL, hue_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
consvar_t cv_rgamma = {"rgamma", "0", CV_SAVE|CV_CALL, gamma_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_ygamma = {"ygamma", "0", CV_SAVE|CV_CALL, gamma_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_ggamma = {"ggamma", "0", CV_SAVE|CV_CALL, gamma_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_cgamma = {"cgamma", "0", CV_SAVE|CV_CALL, gamma_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_bgamma = {"bgamma", "0", CV_SAVE|CV_CALL, gamma_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_mgamma = {"mgamma", "0", CV_SAVE|CV_CALL, gamma_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
consvar_t cv_rsaturation = {"rsaturation", "10", CV_SAVE|CV_CALL, saturation_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_ysaturation = {"ysaturation", "10", CV_SAVE|CV_CALL, saturation_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_gsaturation = {"gsaturation", "10", CV_SAVE|CV_CALL, saturation_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_csaturation = {"csaturation", "10", CV_SAVE|CV_CALL, saturation_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_bsaturation = {"bsaturation", "10", CV_SAVE|CV_CALL, saturation_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_msaturation = {"msaturation", "10", CV_SAVE|CV_CALL, saturation_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
static CV_PossibleValue_t constextsize_cons_t[] = {
|
||||
{V_NOSCALEPATCH, "Small"}, {V_SMALLSCALEPATCH, "Medium"}, {V_MEDSCALEPATCH, "Large"}, {0, "Huge"},
|
||||
|
|
@ -84,112 +110,261 @@ consvar_t cv_grfallbackplayermodel = {"gr_fallbackplayermodel", "Off", CV_SAVE,
|
|||
consvar_t cv_grspritebillboarding = {"gr_spritebillboarding", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
#endif
|
||||
|
||||
const UINT8 gammatable[5][256] =
|
||||
{
|
||||
{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,
|
||||
17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,
|
||||
33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,
|
||||
49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,
|
||||
65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,
|
||||
81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,
|
||||
97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,
|
||||
113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,
|
||||
128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,
|
||||
144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,
|
||||
160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,
|
||||
176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,
|
||||
192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,
|
||||
208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,
|
||||
224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,
|
||||
240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255},
|
||||
|
||||
{2,4,5,7,8,10,11,12,14,15,16,18,19,20,21,23,24,25,26,27,29,30,31,
|
||||
32,33,34,36,37,38,39,40,41,42,44,45,46,47,48,49,50,51,52,54,55,
|
||||
56,57,58,59,60,61,62,63,64,65,66,67,69,70,71,72,73,74,75,76,77,
|
||||
78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,
|
||||
99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,
|
||||
115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,129,
|
||||
130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,
|
||||
146,147,148,148,149,150,151,152,153,154,155,156,157,158,159,160,
|
||||
161,162,163,163,164,165,166,167,168,169,170,171,172,173,174,175,
|
||||
175,176,177,178,179,180,181,182,183,184,185,186,186,187,188,189,
|
||||
190,191,192,193,194,195,196,196,197,198,199,200,201,202,203,204,
|
||||
205,205,206,207,208,209,210,211,212,213,214,214,215,216,217,218,
|
||||
219,220,221,222,222,223,224,225,226,227,228,229,230,230,231,232,
|
||||
233,234,235,236,237,237,238,239,240,241,242,243,244,245,245,246,
|
||||
247,248,249,250,251,252,252,253,254,255},
|
||||
|
||||
{4,7,9,11,13,15,17,19,21,22,24,26,27,29,30,32,33,35,36,38,39,40,42,
|
||||
43,45,46,47,48,50,51,52,54,55,56,57,59,60,61,62,63,65,66,67,68,69,
|
||||
70,72,73,74,75,76,77,78,79,80,82,83,84,85,86,87,88,89,90,91,92,93,
|
||||
94,95,96,97,98,100,101,102,103,104,105,106,107,108,109,110,111,112,
|
||||
113,114,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,
|
||||
129,130,131,132,133,133,134,135,136,137,138,139,140,141,142,143,144,
|
||||
144,145,146,147,148,149,150,151,152,153,153,154,155,156,157,158,159,
|
||||
160,160,161,162,163,164,165,166,166,167,168,169,170,171,172,172,173,
|
||||
174,175,176,177,178,178,179,180,181,182,183,183,184,185,186,187,188,
|
||||
188,189,190,191,192,193,193,194,195,196,197,197,198,199,200,201,201,
|
||||
202,203,204,205,206,206,207,208,209,210,210,211,212,213,213,214,215,
|
||||
216,217,217,218,219,220,221,221,222,223,224,224,225,226,227,228,228,
|
||||
229,230,231,231,232,233,234,235,235,236,237,238,238,239,240,241,241,
|
||||
242,243,244,244,245,246,247,247,248,249,250,251,251,252,253,254,254,
|
||||
255},
|
||||
|
||||
{8,12,16,19,22,24,27,29,31,34,36,38,40,41,43,45,47,49,50,52,53,55,
|
||||
57,58,60,61,63,64,65,67,68,70,71,72,74,75,76,77,79,80,81,82,84,85,
|
||||
86,87,88,90,91,92,93,94,95,96,98,99,100,101,102,103,104,105,106,107,
|
||||
108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,
|
||||
125,126,127,128,129,130,131,132,133,134,135,135,136,137,138,139,140,
|
||||
141,142,143,143,144,145,146,147,148,149,150,150,151,152,153,154,155,
|
||||
155,156,157,158,159,160,160,161,162,163,164,165,165,166,167,168,169,
|
||||
169,170,171,172,173,173,174,175,176,176,177,178,179,180,180,181,182,
|
||||
183,183,184,185,186,186,187,188,189,189,190,191,192,192,193,194,195,
|
||||
195,196,197,197,198,199,200,200,201,202,202,203,204,205,205,206,207,
|
||||
207,208,209,210,210,211,212,212,213,214,214,215,216,216,217,218,219,
|
||||
219,220,221,221,222,223,223,224,225,225,226,227,227,228,229,229,230,
|
||||
231,231,232,233,233,234,235,235,236,237,237,238,238,239,240,240,241,
|
||||
242,242,243,244,244,245,246,246,247,247,248,249,249,250,251,251,252,
|
||||
253,253,254,254,255},
|
||||
|
||||
{16,23,28,32,36,39,42,45,48,50,53,55,57,60,62,64,66,68,69,71,73,75,76,
|
||||
78,80,81,83,84,86,87,89,90,92,93,94,96,97,98,100,101,102,103,105,106,
|
||||
107,108,109,110,112,113,114,115,116,117,118,119,120,121,122,123,124,
|
||||
125,126,128,128,129,130,131,132,133,134,135,136,137,138,139,140,141,
|
||||
142,143,143,144,145,146,147,148,149,150,150,151,152,153,154,155,155,
|
||||
156,157,158,159,159,160,161,162,163,163,164,165,166,166,167,168,169,
|
||||
169,170,171,172,172,173,174,175,175,176,177,177,178,179,180,180,181,
|
||||
182,182,183,184,184,185,186,187,187,188,189,189,190,191,191,192,193,
|
||||
193,194,195,195,196,196,197,198,198,199,200,200,201,202,202,203,203,
|
||||
204,205,205,206,207,207,208,208,209,210,210,211,211,212,213,213,214,
|
||||
214,215,216,216,217,217,218,219,219,220,220,221,221,222,223,223,224,
|
||||
224,225,225,226,227,227,228,228,229,229,230,230,231,232,232,233,233,
|
||||
234,234,235,235,236,236,237,237,238,239,239,240,240,241,241,242,242,
|
||||
243,243,244,244,245,245,246,246,247,247,248,248,249,249,250,250,251,
|
||||
251,252,252,253,254,254,255,255}
|
||||
};
|
||||
|
||||
// local copy of the palette for V_GetColor()
|
||||
RGBA_t *pLocalPalette = NULL;
|
||||
RGBA_t *pMasterPalette = NULL;
|
||||
|
||||
/*
|
||||
The following was an extremely helpful resource when developing my Colour Cube LUT.
|
||||
http://http.developer.nvidia.com/GPUGems2/gpugems2_chapter24.html
|
||||
Please check it out if you're trying to maintain this.
|
||||
toast 18/04/17
|
||||
*/
|
||||
|
||||
float Cubepal[2][2][2][3];
|
||||
|
||||
// returns whether to apply cube, selectively avoiding expensive operations
|
||||
static boolean InitCube(void)
|
||||
{
|
||||
boolean apply = false;
|
||||
UINT8 q;
|
||||
float working[2][2][2][3] = // the initial positions of the corners of the colour cube!
|
||||
{
|
||||
{
|
||||
{
|
||||
{0.0, 0.0, 0.0}, // black corner
|
||||
{0.0, 0.0, 1.0} // blue corner
|
||||
},
|
||||
{
|
||||
{0.0, 1.0, 0.0}, // green corner
|
||||
{0.0, 1.0, 1.0} // cyan corner
|
||||
}
|
||||
},
|
||||
{
|
||||
{
|
||||
{1.0, 0.0, 0.0}, // red corner
|
||||
{1.0, 0.0, 1.0} // magenta corner
|
||||
},
|
||||
{
|
||||
{1.0, 1.0, 0.0}, // yellow corner
|
||||
{1.0, 1.0, 1.0} // white corner
|
||||
}
|
||||
}
|
||||
};
|
||||
float desatur[3]; // grey
|
||||
float globalgammamul, globalgammaoffs;
|
||||
boolean doinggamma;
|
||||
|
||||
#define diffcons(cv) (cv.value != atoi(cv.defaultvalue))
|
||||
|
||||
doinggamma = diffcons(cv_globalgamma);
|
||||
|
||||
#define gammascale 8
|
||||
globalgammamul = (cv_globalgamma.value ? ((255 - (gammascale*abs(cv_globalgamma.value)))/255.0) : 1.0);
|
||||
globalgammaoffs = ((cv_globalgamma.value > 0) ? ((gammascale*cv_globalgamma.value)/255.0) : 0.0);
|
||||
desatur[0] = desatur[1] = desatur[2] = globalgammaoffs + (0.33*globalgammamul);
|
||||
|
||||
if (doinggamma
|
||||
|| diffcons(cv_rhue)
|
||||
|| diffcons(cv_yhue)
|
||||
|| diffcons(cv_ghue)
|
||||
|| diffcons(cv_chue)
|
||||
|| diffcons(cv_bhue)
|
||||
|| diffcons(cv_mhue)
|
||||
|| diffcons(cv_rgamma)
|
||||
|| diffcons(cv_ygamma)
|
||||
|| diffcons(cv_ggamma)
|
||||
|| diffcons(cv_cgamma)
|
||||
|| diffcons(cv_bgamma)
|
||||
|| diffcons(cv_mgamma)) // set the gamma'd/hued positions (saturation is done later)
|
||||
{
|
||||
float mod, tempgammamul, tempgammaoffs;
|
||||
|
||||
apply = true;
|
||||
|
||||
working[0][0][0][0] = working[0][0][0][1] = working[0][0][0][2] = globalgammaoffs;
|
||||
working[1][1][1][0] = working[1][1][1][1] = working[1][1][1][2] = globalgammaoffs+globalgammamul;
|
||||
|
||||
#define dohue(hue, gamma, loc) \
|
||||
tempgammamul = (gamma ? ((255 - (gammascale*abs(gamma)))/255.0)*globalgammamul : globalgammamul);\
|
||||
tempgammaoffs = ((gamma > 0) ? ((gammascale*gamma)/255.0) + globalgammaoffs : globalgammaoffs);\
|
||||
mod = ((hue % huecoloursteps)*(tempgammamul)/huecoloursteps);\
|
||||
switch (hue/huecoloursteps)\
|
||||
{\
|
||||
case 0:\
|
||||
default:\
|
||||
loc[0] = tempgammaoffs+tempgammamul;\
|
||||
loc[1] = tempgammaoffs+mod;\
|
||||
loc[2] = tempgammaoffs;\
|
||||
break;\
|
||||
case 1:\
|
||||
loc[0] = tempgammaoffs+tempgammamul-mod;\
|
||||
loc[1] = tempgammaoffs+tempgammamul;\
|
||||
loc[2] = tempgammaoffs;\
|
||||
break;\
|
||||
case 2:\
|
||||
loc[0] = tempgammaoffs;\
|
||||
loc[1] = tempgammaoffs+tempgammamul;\
|
||||
loc[2] = tempgammaoffs+mod;\
|
||||
break;\
|
||||
case 3:\
|
||||
loc[0] = tempgammaoffs;\
|
||||
loc[1] = tempgammaoffs+tempgammamul-mod;\
|
||||
loc[2] = tempgammaoffs+tempgammamul;\
|
||||
break;\
|
||||
case 4:\
|
||||
loc[0] = tempgammaoffs+mod;\
|
||||
loc[1] = tempgammaoffs;\
|
||||
loc[2] = tempgammaoffs+tempgammamul;\
|
||||
break;\
|
||||
case 5:\
|
||||
loc[0] = tempgammaoffs+tempgammamul;\
|
||||
loc[1] = tempgammaoffs;\
|
||||
loc[2] = tempgammaoffs+tempgammamul-mod;\
|
||||
break;\
|
||||
}
|
||||
dohue(cv_rhue.value, cv_rgamma.value, working[1][0][0]);
|
||||
dohue(cv_yhue.value, cv_ygamma.value, working[1][1][0]);
|
||||
dohue(cv_ghue.value, cv_ggamma.value, working[0][1][0]);
|
||||
dohue(cv_chue.value, cv_cgamma.value, working[0][1][1]);
|
||||
dohue(cv_bhue.value, cv_bgamma.value, working[0][0][1]);
|
||||
dohue(cv_mhue.value, cv_mgamma.value, working[1][0][1]);
|
||||
#undef dohue
|
||||
}
|
||||
|
||||
#define dosaturation(a, e) a = ((1 - work)*e + work*a)
|
||||
#define docvsat(cv_sat, hue, gamma, r, g, b) \
|
||||
if diffcons(cv_sat)\
|
||||
{\
|
||||
float work, mod, tempgammamul, tempgammaoffs;\
|
||||
apply = true;\
|
||||
work = (cv_sat.value/10.0);\
|
||||
mod = ((hue % huecoloursteps)*(1.0)/huecoloursteps);\
|
||||
if (hue & huecoloursteps)\
|
||||
mod = 2-mod;\
|
||||
else\
|
||||
mod += 1;\
|
||||
tempgammamul = (gamma ? ((255 - (gammascale*abs(gamma)))/255.0)*globalgammamul : globalgammamul);\
|
||||
tempgammaoffs = ((gamma > 0) ? ((gammascale*gamma)/255.0) + globalgammaoffs : globalgammaoffs);\
|
||||
for (q = 0; q < 3; q++)\
|
||||
dosaturation(working[r][g][b][q], (tempgammaoffs+(desatur[q]*mod*tempgammamul)));\
|
||||
}
|
||||
|
||||
docvsat(cv_rsaturation, cv_rhue.value, cv_rgamma.value, 1, 0, 0);
|
||||
docvsat(cv_ysaturation, cv_yhue.value, cv_ygamma.value, 1, 1, 0);
|
||||
docvsat(cv_gsaturation, cv_ghue.value, cv_ggamma.value, 0, 1, 0);
|
||||
docvsat(cv_csaturation, cv_chue.value, cv_cgamma.value, 0, 1, 1);
|
||||
docvsat(cv_bsaturation, cv_bhue.value, cv_bgamma.value, 0, 0, 1);
|
||||
docvsat(cv_msaturation, cv_mhue.value, cv_mgamma.value, 1, 0, 1);
|
||||
|
||||
#undef gammascale
|
||||
|
||||
if diffcons(cv_globalsaturation)
|
||||
{
|
||||
float work = (cv_globalsaturation.value/10.0);
|
||||
|
||||
apply = true;
|
||||
|
||||
for (q = 0; q < 3; q++)
|
||||
{
|
||||
dosaturation(working[1][0][0][q], desatur[q]);
|
||||
dosaturation(working[0][1][0][q], desatur[q]);
|
||||
dosaturation(working[0][0][1][q], desatur[q]);
|
||||
|
||||
dosaturation(working[1][1][0][q], 2*desatur[q]);
|
||||
dosaturation(working[0][1][1][q], 2*desatur[q]);
|
||||
dosaturation(working[1][0][1][q], 2*desatur[q]);
|
||||
}
|
||||
}
|
||||
|
||||
#undef dosaturation
|
||||
|
||||
#undef diffcons
|
||||
|
||||
if (!apply)
|
||||
return false;
|
||||
|
||||
#define dowork(i, j, k, l) \
|
||||
if (working[i][j][k][l] > 1.0)\
|
||||
working[i][j][k][l] = 1.0;\
|
||||
else if (working[i][j][k][l] < 0.0)\
|
||||
working[i][j][k][l] = 0.0;\
|
||||
Cubepal[i][j][k][l] = working[i][j][k][l]
|
||||
for (q = 0; q < 3; q++)
|
||||
{
|
||||
dowork(0, 0, 0, q);
|
||||
dowork(1, 0, 0, q);
|
||||
dowork(0, 1, 0, q);
|
||||
dowork(1, 1, 0, q);
|
||||
dowork(0, 0, 1, q);
|
||||
dowork(1, 0, 1, q);
|
||||
dowork(0, 1, 1, q);
|
||||
dowork(1, 1, 1, q);
|
||||
}
|
||||
#undef dowork
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// keep a copy of the palette so that we can get the RGB value for a color index at any time.
|
||||
static void LoadPalette(const char *lumpname)
|
||||
{
|
||||
const UINT8 *usegamma = gammatable[cv_usegamma.value];
|
||||
boolean cube = InitCube();
|
||||
lumpnum_t lumpnum = W_GetNumForName(lumpname);
|
||||
size_t i, palsize = W_LumpLength(lumpnum)/3;
|
||||
UINT8 *pal;
|
||||
|
||||
Z_Free(pLocalPalette);
|
||||
Z_Free(pMasterPalette);
|
||||
|
||||
pLocalPalette = Z_Malloc(sizeof (*pLocalPalette)*palsize, PU_STATIC, NULL);
|
||||
pMasterPalette = Z_Malloc(sizeof (*pMasterPalette)*palsize, PU_STATIC, NULL);
|
||||
|
||||
pal = W_CacheLumpNum(lumpnum, PU_CACHE);
|
||||
for (i = 0; i < palsize; i++)
|
||||
{
|
||||
pLocalPalette[i].s.red = usegamma[*pal++];
|
||||
pLocalPalette[i].s.green = usegamma[*pal++];
|
||||
pLocalPalette[i].s.blue = usegamma[*pal++];
|
||||
pLocalPalette[i].s.alpha = 0xFF;
|
||||
pMasterPalette[i].s.red = pLocalPalette[i].s.red = *pal++;
|
||||
pMasterPalette[i].s.green = pLocalPalette[i].s.green = *pal++;
|
||||
pMasterPalette[i].s.blue = pLocalPalette[i].s.blue = *pal++;
|
||||
pMasterPalette[i].s.alpha = pLocalPalette[i].s.alpha = 0xFF;
|
||||
|
||||
// lerp of colour cubing!
|
||||
if (cube)
|
||||
{
|
||||
float working[4][3];
|
||||
float linear;
|
||||
UINT8 q;
|
||||
|
||||
linear = (pLocalPalette[i].s.red/255.0);
|
||||
#define dolerp(e1, e2) ((1 - linear)*e1 + linear*e2)
|
||||
for (q = 0; q < 3; q++)
|
||||
{
|
||||
working[0][q] = dolerp(Cubepal[0][0][0][q], Cubepal[1][0][0][q]);
|
||||
working[1][q] = dolerp(Cubepal[0][1][0][q], Cubepal[1][1][0][q]);
|
||||
working[2][q] = dolerp(Cubepal[0][0][1][q], Cubepal[1][0][1][q]);
|
||||
working[3][q] = dolerp(Cubepal[0][1][1][q], Cubepal[1][1][1][q]);
|
||||
}
|
||||
linear = (pLocalPalette[i].s.green/255.0);
|
||||
for (q = 0; q < 3; q++)
|
||||
{
|
||||
working[0][q] = dolerp(working[0][q], working[1][q]);
|
||||
working[1][q] = dolerp(working[2][q], working[3][q]);
|
||||
}
|
||||
linear = (pLocalPalette[i].s.blue/255.0);
|
||||
for (q = 0; q < 3; q++)
|
||||
{
|
||||
working[0][q] = 255*dolerp(working[0][q], working[1][q]);
|
||||
if (working[0][q] > 255.0)
|
||||
working[0][q] = 255.0;
|
||||
else if (working[0][q] < 0.0)
|
||||
working[0][q] = 0.0;
|
||||
}
|
||||
#undef dolerp
|
||||
|
||||
pLocalPalette[i].s.red = (UINT8)(working[0][0]);
|
||||
pLocalPalette[i].s.green = (UINT8)(working[0][1]);
|
||||
pLocalPalette[i].s.blue = (UINT8)(working[0][2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -254,7 +429,7 @@ void V_SetPaletteLump(const char *pal)
|
|||
#endif
|
||||
}
|
||||
|
||||
static void CV_usegamma_OnChange(void)
|
||||
static void CV_palette_OnChange(void)
|
||||
{
|
||||
// reload palette
|
||||
LoadMapPalette();
|
||||
|
|
@ -2668,6 +2843,28 @@ Unoptimized version
|
|||
#endif
|
||||
}
|
||||
|
||||
// Generates a color look-up table
|
||||
// which has up to 64 colors at each channel
|
||||
// (see the defines in v_video.h)
|
||||
|
||||
UINT8 colorlookup[CLUTSIZE][CLUTSIZE][CLUTSIZE];
|
||||
|
||||
void InitColorLUT(RGBA_t *palette)
|
||||
{
|
||||
UINT8 r, g, b;
|
||||
static boolean clutinit = false;
|
||||
static RGBA_t *lastpalette = NULL;
|
||||
if ((!clutinit) || (lastpalette != palette))
|
||||
{
|
||||
for (r = 0; r < CLUTSIZE; r++)
|
||||
for (g = 0; g < CLUTSIZE; g++)
|
||||
for (b = 0; b < CLUTSIZE; b++)
|
||||
colorlookup[r][g][b] = NearestPaletteColor(r << SHIFTCOLORBITS, g << SHIFTCOLORBITS, b << SHIFTCOLORBITS, palette);
|
||||
clutinit = true;
|
||||
lastpalette = palette;
|
||||
}
|
||||
}
|
||||
|
||||
// V_Init
|
||||
// old software stuff, buffers are allocated at video mode setup
|
||||
// here we set the screens[x] pointers accordingly
|
||||
|
|
@ -2679,13 +2876,9 @@ void V_Init(void)
|
|||
const INT32 screensize = vid.rowbytes * vid.height;
|
||||
|
||||
LoadMapPalette();
|
||||
// hardware modes do not use screens[] pointers
|
||||
|
||||
for (i = 0; i < NUMSCREENS; i++)
|
||||
screens[i] = NULL;
|
||||
if (rendermode != render_soft)
|
||||
{
|
||||
return; // be sure to cause a NULL read/write error so we detect it, in case of..
|
||||
}
|
||||
|
||||
// start address of NUMSCREENS * width*height vidbuffers
|
||||
if (base)
|
||||
|
|
|
|||
|
|
@ -27,12 +27,24 @@
|
|||
|
||||
extern UINT8 *screens[5];
|
||||
|
||||
extern const UINT8 gammatable[5][256];
|
||||
extern consvar_t cv_ticrate, cv_usegamma, cv_allcaps, cv_constextsize;
|
||||
extern consvar_t cv_ticrate, cv_constextsize,\
|
||||
cv_globalgamma, cv_globalsaturation, \
|
||||
cv_rhue, cv_yhue, cv_ghue, cv_chue, cv_bhue, cv_mhue,\
|
||||
cv_rgamma, cv_ygamma, cv_ggamma, cv_cgamma, cv_bgamma, cv_mgamma, \
|
||||
cv_rsaturation, cv_ysaturation, cv_gsaturation, cv_csaturation, cv_bsaturation, cv_msaturation;
|
||||
|
||||
// Allocates buffer screens, call before R_Init.
|
||||
void V_Init(void);
|
||||
|
||||
// Color look-up table
|
||||
#define COLORBITS 6
|
||||
#define SHIFTCOLORBITS (8-COLORBITS)
|
||||
#define CLUTSIZE (1<<COLORBITS)
|
||||
|
||||
extern UINT8 colorlookup[CLUTSIZE][CLUTSIZE][CLUTSIZE];
|
||||
|
||||
void InitColorLUT(RGBA_t *palette);
|
||||
|
||||
// Set the current RGB palette lookup to use for palettized graphics
|
||||
void V_SetPalette(INT32 palettenum);
|
||||
|
||||
|
|
@ -42,6 +54,7 @@ const char *R_GetPalname(UINT16 num);
|
|||
const char *GetPalette(void);
|
||||
|
||||
extern RGBA_t *pLocalPalette;
|
||||
extern RGBA_t *pMasterPalette;
|
||||
|
||||
extern UINT8 hudtrans;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue