diff --git a/include/view.h b/include/view.h index 83c4090..1028ac7 100644 --- a/include/view.h +++ b/include/view.h @@ -33,7 +33,8 @@ #include "mathlib.h" #include "cvar.h" -extern cvar_t *v_gamma; +extern cvar_t *brightness; +extern cvar_t *contrast; extern cvar_t *lcd_x; void V_Init (void); diff --git a/source/gl_screen.c b/source/gl_screen.c index fe7d094..e979169 100644 --- a/source/gl_screen.c +++ b/source/gl_screen.c @@ -1264,20 +1264,19 @@ void SCR_UpdateScreen (void) glEnd (); } glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - contrast->value = bound(0.2, contrast->value, 1.0); + contrast->value = bound(0.1, contrast->value, 1.0); if ((gl_polyblend->value && v_blend[3]) || contrast->value < 1) { glBegin (GL_QUADS); - if (contrast->value < 1) - { - glColor4f (1, 1, 1, 1-contrast->value); + if (contrast->value < 1) { + glColor4f (1, 1, 1, (1 - contrast->value)); glVertex2f (0,0); glVertex2f (vid.width, 0); glVertex2f (vid.width, vid.height); glVertex2f (0, vid.height); } - if (gl_polyblend->value && v_blend[3]) - { + + if (gl_polyblend->value && v_blend[3]) { glColor4fv (v_blend); glVertex2f (0,0); glVertex2f (vid.width, 0); diff --git a/source/menu.c b/source/menu.c index 38fdd8a..90e0358 100644 --- a/source/menu.c +++ b/source/menu.c @@ -386,7 +386,7 @@ void M_Main_Key (int key) //============================================================================= /* OPTIONS MENU */ -#define OPTIONS_ITEMS 16 +#define OPTIONS_ITEMS 17 #define SLIDER_RANGE 10 @@ -406,60 +406,60 @@ void M_AdjustSliders (int dir) switch (options_cursor) { case 3: // screen size - Cvar_SetValue(scr_viewsize, bound(30, (int)scr_viewsize->value + (dir * 10), 120)); + Cvar_SetValue (scr_viewsize, bound (30, (int)scr_viewsize->value + (dir * 10), 120)); break; - case 4: // gamma - Cvar_SetValue(v_gamma, bound(0.5, v_gamma->value - (dir * 0.05), 1)); + case 4: // Brightness + Cvar_SetValue (brightness, bound (1, brightness->value + (dir * 0.25), 5)); break; - case 5: // mouse speed - Cvar_SetValue(sensitivity, bound(1, sensitivity->value + dir, 25)); + case 5: // Contrast + Cvar_SetValue (contrast, bound (0.0, contrast->value + (dir * 0.05), 1)); break; - case 6: // music volume - Cvar_SetValue(bgmvolume, + case 6: // mouse speed + Cvar_SetValue (sensitivity, bound (1, sensitivity->value + dir, 25)); + break; + case 7: // music volume #ifdef _WIN32 - bound(0, bgmvolume->value + dir, 1)); + Cvar_SetValue (bgmvolume, bound (0, bgmvolume->value + dir, 1)); #else - bound(0, bgmvolume->value + (dir * 0.1), 1)); + Cvar_SetValue (bgmvolume, bound (0, bgmvolume->value + (dir * 0.1), 1)); #endif break; - case 7: // sfx volume - Cvar_SetValue(volume, bound(0, volume->value + (dir * 0.1), 1)); + case 8: // sfx volume + Cvar_SetValue (volume, bound (0, volume->value + (dir * 0.1), 1)); break; - case 8: // allways run + case 9: // allways run if (cl_forwardspeed->value > 200) { - Cvar_SetValue(cl_forwardspeed, 200); - Cvar_SetValue(cl_backspeed, 200); + Cvar_SetValue (cl_forwardspeed, 200); + Cvar_SetValue (cl_backspeed, 200); } else { - Cvar_SetValue(cl_forwardspeed, 400); - Cvar_SetValue(cl_backspeed, 400); + Cvar_SetValue (cl_forwardspeed, 400); + Cvar_SetValue (cl_backspeed, 400); } break; - case 9: // invert mouse - Cvar_SetValue(m_pitch, -m_pitch->value); + case 10: // invert mouse + Cvar_SetValue (m_pitch, -m_pitch->value); break; - case 10: // lookspring - Cvar_SetValue(lookspring, !lookspring->value); + case 11: // lookspring + Cvar_SetValue (lookspring, !lookspring->value); break; - case 11: // lookstrafe - Cvar_SetValue(lookstrafe, !lookstrafe->value); + case 12: // lookstrafe + Cvar_SetValue (lookstrafe, !lookstrafe->value); break; - case 12: // Use old-style sbar - Cvar_SetValue(cl_sbar, !cl_sbar->value); + case 13: // Use old-style sbar + Cvar_SetValue (cl_sbar, !cl_sbar->value); break; - case 13: // HUD on left side + case 14: // HUD on left side Cvar_SetValue (cl_hudswap, !cl_hudswap->value); break; - case 15: // _windowed_mouse - if (_windowed_mouse->value) { - Cvar_SetValue (_windowed_mouse, !_windowed_mouse->value); - } + case 16: // _windowed_mouse + Cvar_SetValue (_windowed_mouse, !_windowed_mouse->value); break; } } @@ -512,49 +512,52 @@ void M_Options_Draw (void) M_DrawSlider (220, 56, r); M_Print (16, 64, " Brightness"); - r = (1.0 - v_gamma->value) / 0.5; + r = (brightness->value - 1) / 4; M_DrawSlider (220, 64, r); - M_Print (16, 72, " Mouse Speed"); - r = (sensitivity->value - 1)/10; + M_Print (16, 72, " Contrast"); + r = contrast->value; M_DrawSlider (220, 72, r); - M_Print (16, 80, " CD Music Volume"); - r = bgmvolume->value; + M_Print (16, 80, " Mouse Speed"); + r = (sensitivity->value - 1) / 24; M_DrawSlider (220, 80, r); - M_Print (16, 88, " Sound Volume"); - r = volume->value; + M_Print (16, 88, " CD Music Volume"); + r = bgmvolume->value; M_DrawSlider (220, 88, r); - M_Print (16, 96, " Always Run"); - M_DrawCheckbox (220, 96, cl_forwardspeed->value > 200); + M_Print (16, 96, " Sound Volume"); + r = volume->value; + M_DrawSlider (220, 96, r); - M_Print (16, 104, " Invert Mouse"); - M_DrawCheckbox (220, 104, m_pitch->value < 0); + M_Print (16, 104, " Always Run"); + M_DrawCheckbox (220, 104, cl_forwardspeed->value > 200); - M_Print (16, 112, " Lookspring"); - M_DrawCheckbox (220, 112, lookspring->value); + M_Print (16, 112, " Invert Mouse"); + M_DrawCheckbox (220, 112, m_pitch->value < 0); - M_Print (16, 120, " Lookstrafe"); - M_DrawCheckbox (220, 120, lookstrafe->value); + M_Print (16, 120, " Lookspring"); + M_DrawCheckbox (220, 120, lookspring->value); - M_Print (16, 128, " Use old status bar"); - M_DrawCheckbox (220, 128, cl_sbar->value); + M_Print (16, 128, " Lookstrafe"); + M_DrawCheckbox (220, 128, lookstrafe->value); - M_Print (16, 136, " HUD on left side"); - M_DrawCheckbox (220, 136, cl_hudswap->value); + M_Print (16, 136, " Use old status bar"); + M_DrawCheckbox (220, 136, cl_sbar->value); + + M_Print (16, 144, " HUD on left side"); + M_DrawCheckbox (220, 144, cl_hudswap->value); if (vid_menudrawfn) - M_Print (16, 144, " Video Options"); + M_Print (16, 152, " Video Options"); #ifdef _WIN32 - if (modestate == MS_WINDOWED) - { + if (modestate == MS_WINDOWED) { #endif if (_windowed_mouse) { - M_Print (16, 152, " Use Mouse"); - M_DrawCheckbox (220, 152, _windowed_mouse->value); + M_Print (16, 160, " Use Mouse"); + M_DrawCheckbox (220, 160, _windowed_mouse->value); } #ifdef _WIN32 } @@ -602,27 +605,23 @@ void M_Options_Key (int k) options_cursor--; if (options_cursor < 0) options_cursor = OPTIONS_ITEMS-1; - if (options_cursor == 15 && (!(_windowed_mouse) #ifdef _WIN32 - || (modestate != MS_WINDOWED) -#endif - )) // bleh + if (options_cursor == 16 && (!(_windowed_mouse) || (modestate != MS_WINDOWED))) options_cursor--; - if (options_cursor == 14 && !(vid_menudrawfn)) +#endif + if (options_cursor == 15 && !(vid_menudrawfn)) options_cursor--; break; case K_DOWNARROW: S_LocalSound ("misc/menu1.wav"); options_cursor++; - if (options_cursor == 14 && !(vid_menudrawfn)) + if (options_cursor == 15 && !(vid_menudrawfn)) options_cursor++; - if (options_cursor == 15 && (!(_windowed_mouse) #ifdef _WIN32 - || (modestate != MS_WINDOWED) -#endif - )) // ARGH!!!!! + if (options_cursor == 16 && (!(_windowed_mouse) || (modestate != MS_WINDOWED))) // ARGH!!!!! options_cursor++; +#endif if (options_cursor >= OPTIONS_ITEMS) options_cursor = 0; break; diff --git a/source/r_view.c b/source/r_view.c index 5793d0f..0347aeb 100644 --- a/source/r_view.c +++ b/source/r_view.c @@ -81,8 +81,6 @@ cvar_t *cl_crossy; cvar_t *v_contentblend; -cvar_t *gl_cshiftpercent; - float v_dmg_time, v_dmg_roll, v_dmg_pitch; extern int in_forward, in_forward2, in_back; @@ -262,10 +260,6 @@ void V_DriftPitch (void) } } - - - - /* ============================================================================== @@ -273,31 +267,40 @@ void V_DriftPitch (void) ============================================================================== */ - - + +cvar_t *gl_cshiftpercent; + cshift_t cshift_empty = { {130,80,50}, 0 }; cshift_t cshift_water = { {130,80,50}, 128 }; cshift_t cshift_slime = { {0,25,5}, 150 }; cshift_t cshift_lava = { {255,80,0}, 150 }; -cvar_t *v_gamma; +cvar_t *brightness; +cvar_t *contrast; byte gammatable[256]; // palette is sent through this -void BuildGammaTable (float g) +void BuildGammaTable (float b, float c) { - int i, inf; + int i, j, inf = 0; - if (g == 1.0) - { - for (i=0 ; i<256 ; i++) + if ((b == 1.0) && (c == 1.0)) { + for (i = 0; i < 256; i++) gammatable[i] = i; return; } - for (i=0 ; i<256 ; i++) - { - inf = 255 * pow ( (i+0.5)/255.5, g) + 0.5; + for (i=0 ; i<256 ; i++) { + if (!(i == 128)) { + if (i < 128) { + j = i + (int) ((128 - i) * (1 - c)); + } else { + j = i + (int) ((i - 128) * (1 - c)); + } + } else { + j = i; + } + inf = (j * b); // gamma is brightness now, and positive inf = bound(0, inf, 255); gammatable[i] = inf; } @@ -310,13 +313,15 @@ V_CheckGamma */ qboolean V_CheckGamma (void) { - static float oldgammavalue; + static float oldbrightness; + static float oldcontrast; - if (v_gamma->value == oldgammavalue) + if ((brightness->value == oldbrightness) && contrast->value == oldcontrast) return false; - oldgammavalue = v_gamma->value; + oldbrightness = brightness->value; + oldcontrast = contrast->value; - BuildGammaTable (v_gamma->value); + BuildGammaTable (brightness->value, contrast->value); vid.recalc_refdef = 1; // force a surface cache flush return true; @@ -355,20 +360,15 @@ void V_ParseDamage (void) if (cl.cshifts[CSHIFT_DAMAGE].percent > 150) cl.cshifts[CSHIFT_DAMAGE].percent = 150; - if (armor > blood) - { + if (armor > blood) { cl.cshifts[CSHIFT_DAMAGE].destcolor[0] = 200; cl.cshifts[CSHIFT_DAMAGE].destcolor[1] = 100; cl.cshifts[CSHIFT_DAMAGE].destcolor[2] = 100; - } - else if (armor) - { + } else if (armor) { cl.cshifts[CSHIFT_DAMAGE].destcolor[0] = 220; cl.cshifts[CSHIFT_DAMAGE].destcolor[1] = 50; cl.cshifts[CSHIFT_DAMAGE].destcolor[2] = 50; - } - else - { + } else { cl.cshifts[CSHIFT_DAMAGE].destcolor[0] = 255; cl.cshifts[CSHIFT_DAMAGE].destcolor[1] = 0; cl.cshifts[CSHIFT_DAMAGE].destcolor[2] = 0; @@ -435,8 +435,7 @@ void V_SetContentsColor (int contents) return; } - switch (contents) - { + switch (contents) { case CONTENTS_EMPTY: cl.cshifts[CSHIFT_CONTENTS] = cshift_empty; break; @@ -459,35 +458,27 @@ V_CalcPowerupCshift */ void V_CalcPowerupCshift (void) { - if (cl.stats[STAT_ITEMS] & IT_QUAD) - { + if (cl.stats[STAT_ITEMS] & IT_QUAD) { cl.cshifts[CSHIFT_POWERUP].destcolor[0] = 0; cl.cshifts[CSHIFT_POWERUP].destcolor[1] = 0; cl.cshifts[CSHIFT_POWERUP].destcolor[2] = 255; cl.cshifts[CSHIFT_POWERUP].percent = 30; - } - else if (cl.stats[STAT_ITEMS] & IT_SUIT) - { + } else if (cl.stats[STAT_ITEMS] & IT_SUIT) { cl.cshifts[CSHIFT_POWERUP].destcolor[0] = 0; cl.cshifts[CSHIFT_POWERUP].destcolor[1] = 255; cl.cshifts[CSHIFT_POWERUP].destcolor[2] = 0; cl.cshifts[CSHIFT_POWERUP].percent = 20; - } - else if (cl.stats[STAT_ITEMS] & IT_INVISIBILITY) - { + } else if (cl.stats[STAT_ITEMS] & IT_INVISIBILITY) { cl.cshifts[CSHIFT_POWERUP].destcolor[0] = 100; cl.cshifts[CSHIFT_POWERUP].destcolor[1] = 100; cl.cshifts[CSHIFT_POWERUP].destcolor[2] = 100; cl.cshifts[CSHIFT_POWERUP].percent = 100; - } - else if (cl.stats[STAT_ITEMS] & IT_INVULNERABILITY) - { + } else if (cl.stats[STAT_ITEMS] & IT_INVULNERABILITY) { cl.cshifts[CSHIFT_POWERUP].destcolor[0] = 255; cl.cshifts[CSHIFT_POWERUP].destcolor[1] = 255; cl.cshifts[CSHIFT_POWERUP].destcolor[2] = 0; cl.cshifts[CSHIFT_POWERUP].percent = 30; - } - else + } else cl.cshifts[CSHIFT_POWERUP].percent = 0; } @@ -522,15 +513,10 @@ void CalcGunAngle (void) pitch = -r_refdef.viewangles[PITCH]; yaw = angledelta(yaw - r_refdef.viewangles[YAW]) * 0.4; - if (yaw > 10) - yaw = 10; - if (yaw < -10) - yaw = -10; + yaw = bound (-10, yaw, 10); pitch = angledelta(-pitch - r_refdef.viewangles[PITCH]) * 0.4; - if (pitch > 10) - pitch = 10; - if (pitch < -10) - pitch = -10; + pitch = bound (-10, pitch, 10); + move = host_frametime*20; if (yaw > oldyaw) { @@ -861,6 +847,7 @@ void V_Init (void) gl_cshiftpercent = Cvar_Get("gl_cshiftpercent", "100", CVAR_NONE, "None"); - BuildGammaTable (1.0); // no gamma yet - v_gamma = Cvar_Get("gamma", "1", CVAR_ARCHIVE, "None"); + BuildGammaTable (1.0, 1.0); // no gamma yet + brightness = Cvar_Get("brightness", "1", CVAR_ARCHIVE, "None"); + contrast = Cvar_Get("contrast", "1", CVAR_ARCHIVE, "None"); } diff --git a/source/sw_view.c b/source/sw_view.c index d9adae3..809b183 100644 --- a/source/sw_view.c +++ b/source/sw_view.c @@ -31,8 +31,10 @@ #endif #include "quakedef.h" #include "r_local.h" +#include "sys.h" -extern byte gammatable[256]; +extern byte gammatable[256]; +extern cvar_t *contrast; void V_CalcPowerupCshift (void); qboolean V_CheckGamma (void); @@ -44,67 +46,63 @@ V_UpdatePalette */ void V_UpdatePalette (void) { - int i, j; - qboolean new; - byte *basepal, *newpal; - byte pal[768]; - int r,g,b; - qboolean force; + int i, j; + qboolean new; + byte *basepal, *newpal; + byte pal[768]; + int r,g,b; + qboolean force; - V_CalcPowerupCshift (); + V_CalcPowerupCshift (); - new = false; + new = false; - for (i=0 ; i>8; - g += (cl.cshifts[j].percent*(cl.cshifts[j].destcolor[1]-g))>>8; - b += (cl.cshifts[j].percent*(cl.cshifts[j].destcolor[2]-b))>>8; - } + for (i=0 ; i<256 ; i++) { + r = basepal[0]; + g = basepal[1]; + b = basepal[2]; + basepal += 3; - newpal[0] = gammatable[r]; - newpal[1] = gammatable[g]; - newpal[2] = gammatable[b]; - newpal += 3; - } + for (j=0 ; j>8; + g += (cl.cshifts[j].percent*(cl.cshifts[j].destcolor[1]-g))>>8; + b += (cl.cshifts[j].percent*(cl.cshifts[j].destcolor[2]-b))>>8; + } - VID_ShiftPalette (pal); + newpal[0] = gammatable[r]; + newpal[1] = gammatable[g]; + newpal[2] = gammatable[b]; + newpal += 3; + } + VID_ShiftPalette (pal); }