void V_PrepBlend (void) { int i, j; if (cl_cshift_powerup->int_val || (cl.sv_cshifts & INFO_CSHIFT_POWERUP)) V_CalcPowerupCshift (); r_data->vid->cshift_changed = false; for (i = 0; i < NUM_CSHIFTS; i++) { if (cl.cshifts[i].percent != cl.prev_cshifts[i].percent) { r_data->vid->cshift_changed = true; cl.prev_cshifts[i].percent = cl.cshifts[i].percent; } for (j = 0; j < 3; j++) { if (cl.cshifts[i].destcolor[j] != cl.prev_cshifts[i].destcolor[j]) { r_data->vid->cshift_changed = true; cl.prev_cshifts[i].destcolor[j] = cl.cshifts[i].destcolor[j]; } } } // drop the damage value V_DropCShift (&cl.cshifts[CSHIFT_DAMAGE], 150); // drop the bonus value V_DropCShift (&cl.cshifts[CSHIFT_BONUS], 100); if (!r_data->vid->cshift_changed && !r_data->vid->recalc_refdef) return; V_CalcBlend (); }
void V_UpdatePalette(void) { int i; qboolean force; V_CalcPowerupCshift(); /* drop the damage value */ cl.cshifts[CSHIFT_DAMAGE].percent -= host_frametime * 150; if (cl.cshifts[CSHIFT_DAMAGE].percent < 0) cl.cshifts[CSHIFT_DAMAGE].percent = 0; /* drop the bonus value */ cl.cshifts[CSHIFT_BONUS].percent -= host_frametime * 100; if (cl.cshifts[CSHIFT_BONUS].percent < 0) cl.cshifts[CSHIFT_BONUS].percent = 0; force = V_CheckGamma(); if (force) { for (i = 0; i < 256; i++) { ramps[0][i] = gammatable[i] << 8; ramps[1][i] = gammatable[i] << 8; ramps[2][i] = gammatable[i] << 8; } #ifndef __LIBRETRO__ if (VID_IsFullScreen() && VID_SetGammaRamp) VID_SetGammaRamp(ramps); //VID_ShiftPalette(NULL); #endif } }
void V_CalcBlend (void) { float r, g, b, a, a2; int j; r = g = b = a= 0; if (cls.state != ca_active) { cl.cshifts[CSHIFT_CONTENTS] = cshift_empty; cl.cshifts[CSHIFT_POWERUP].percent = 0; } else { V_CalcPowerupCshift (); } // drop the damage value cl.cshifts[CSHIFT_DAMAGE].percent -= cls.frametime * 150; if (cl.cshifts[CSHIFT_DAMAGE].percent <= 0) cl.cshifts[CSHIFT_DAMAGE].percent = 0; // drop the bonus value cl.cshifts[CSHIFT_BONUS].percent -= cls.frametime * 100; if (cl.cshifts[CSHIFT_BONUS].percent <= 0) cl.cshifts[CSHIFT_BONUS].percent = 0; for (j = 0; j < NUM_CSHIFTS; j++) { if ((!gl_cshiftpercent.value || !gl_polyblend.value) && j != CSHIFT_CONTENTS) continue; if (j == CSHIFT_CONTENTS) a2 = cl.cshifts[j].percent / 100.0 / 255.0; else a2 = ((cl.cshifts[j].percent * gl_cshiftpercent.value) / 100.0) / 255.0; if (!a2) continue; a = a + a2 * (1-a); a2 = a2 / a; r = r * (1 - a2) + cl.cshifts[j].destcolor[0] * a2; g = g * (1 - a2) + cl.cshifts[j].destcolor[1] * a2; b = b * (1 - a2) + cl.cshifts[j].destcolor[2 ]* a2; } v_blend[0] = r / 255.0; v_blend[1] = g / 255.0; v_blend[2] = b / 255.0; v_blend[3] = a; v_blend[3] = bound(0, v_blend[3], 1); }
/* ============= V_PrepBlend ============= */ void V_PrepBlend (void) { if (cls.state != ca_active) { cl.cshifts[CSHIFT_CONTENTS].percent = 0; cl.cshifts[CSHIFT_POWERUP].percent = 0; cl.cshifts[CSHIFT_CUSTOM].percent = 0; } else { V_CalcPowerupCshift (); } // drop the damage value V_DropCShift (&cl.cshifts[CSHIFT_DAMAGE], 150); // drop the bonus value V_DropCShift (&cl.cshifts[CSHIFT_BONUS], 100); V_CalcBlend (); }
/* ============= V_UpdateBlend -- johnfitz -- V_UpdatePalette cleaned up and renamed ============= */ void V_UpdateBlend (void) { int i, j; qboolean blend_changed; V_CalcPowerupCshift (); blend_changed = false; for (i=0 ; i<NUM_CSHIFTS ; i++) { if (cl.cshifts[i].percent != cl.prev_cshifts[i].percent) { blend_changed = true; cl.prev_cshifts[i].percent = cl.cshifts[i].percent; } for (j=0 ; j<3 ; j++) if (cl.cshifts[i].destcolor[j] != cl.prev_cshifts[i].destcolor[j]) { blend_changed = true; cl.prev_cshifts[i].destcolor[j] = cl.cshifts[i].destcolor[j]; } } // drop the damage value cl.cshifts[CSHIFT_DAMAGE].percent -= host_frametime*150; if (cl.cshifts[CSHIFT_DAMAGE].percent <= 0) cl.cshifts[CSHIFT_DAMAGE].percent = 0; // drop the bonus value cl.cshifts[CSHIFT_BONUS].percent -= host_frametime*100; if (cl.cshifts[CSHIFT_BONUS].percent <= 0) cl.cshifts[CSHIFT_BONUS].percent = 0; if (blend_changed) V_CalcBlend (); }
void V_UpdatePalette(void) { int i, j; qboolean newobj; byte *basepal; #ifdef __LIBRETRO__ unsigned short *pal_data; #else byte pal[768]; byte *newpal; #endif int r, g, b; qboolean force; V_CalcPowerupCshift(); newobj = false; for (i = 0; i < NUM_CSHIFTS; i++) { if (cl.cshifts[i].percent != cl.prev_cshifts[i].percent) { newobj = true; cl.prev_cshifts[i].percent = cl.cshifts[i].percent; } for (j = 0; j < 3; j++) if (cl.cshifts[i].destcolor[j] != cl.prev_cshifts[i].destcolor[j]) { newobj = true; cl.prev_cshifts[i].destcolor[j] = cl.cshifts[i].destcolor[j]; } } // drop the damage value cl.cshifts[CSHIFT_DAMAGE].percent -= host_frametime * 150; if (cl.cshifts[CSHIFT_DAMAGE].percent <= 0) cl.cshifts[CSHIFT_DAMAGE].percent = 0; // drop the bonus value cl.cshifts[CSHIFT_BONUS].percent -= host_frametime * 100; if (cl.cshifts[CSHIFT_BONUS].percent <= 0) cl.cshifts[CSHIFT_BONUS].percent = 0; force = V_CheckGamma(); if (!newobj && !force) return; basepal = host_basepal; #ifdef __LIBRETRO__ pal_data = &palette_data[0]; #else newpal = pal; #endif for (i = 0; i < 256; i++) { r = basepal[0]; g = basepal[1]; b = basepal[2]; basepal += 3; for (j = 0; j < NUM_CSHIFTS; j++) { r += (cl.cshifts[j].percent * (cl.cshifts[j].destcolor[0] - r)) >> 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; } #ifdef __LIBRETRO__ *pal_data++ = PACK_RGB565(gammatable[r], gammatable[g], gammatable[b]); #else newpal[0] = r = gammatable[r]; newpal[1] = g = gammatable[g]; newpal[2] = b = gammatable[b]; newpal += 3; #endif } #ifndef __LIBRETRO__ VID_ShiftPalette(pal); #endif }
void V_UpdatePalette (void) { int i, j; qboolean new_ptr; byte *basepal, *newpal; byte pal[768]; int r,g,b; qboolean force; V_CalcPowerupCshift (); new_ptr = false; for (i=0 ; i<NUM_CSHIFTS ; i++) { if (cl.cshifts[i].percent != cl.prev_cshifts[i].percent) { new_ptr = true; cl.prev_cshifts[i].percent = cl.cshifts[i].percent; } for (j=0 ; j<3 ; j++) if (cl.cshifts[i].destcolor[j] != cl.prev_cshifts[i].destcolor[j]) { new_ptr = true; cl.prev_cshifts[i].destcolor[j] = cl.cshifts[i].destcolor[j]; } } // drop the damage value cl.cshifts[CSHIFT_DAMAGE].percent -= host_frametime*150; if (cl.cshifts[CSHIFT_DAMAGE].percent <= 0) cl.cshifts[CSHIFT_DAMAGE].percent = 0; // drop the bonus value cl.cshifts[CSHIFT_BONUS].percent -= host_frametime*100; if (cl.cshifts[CSHIFT_BONUS].percent <= 0) cl.cshifts[CSHIFT_BONUS].percent = 0; force = V_CheckGamma (); if (!new_ptr && !force) return; basepal = host_basepal; newpal = pal; for (i=0 ; i<256 ; i++) { r = basepal[0]; g = basepal[1]; b = basepal[2]; basepal += 3; for (j=0 ; j<NUM_CSHIFTS ; j++) { r += (cl.cshifts[j].percent*(cl.cshifts[j].destcolor[0]-r))>>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; } newpal[0] = gammatable[r]; newpal[1] = gammatable[g]; newpal[2] = gammatable[b]; newpal += 3; } VID_ShiftPalette (pal); }
void V_UpdatePalette (void) { int i, j; qboolean new_ptr; byte *basepal, *newpal; byte pal[768]; float r,g,b,a; int ir, ig, ib; qboolean force; V_CalcPowerupCshift (); new_ptr = false; for (i=0 ; i<NUM_CSHIFTS ; i++) { if (cl.cshifts[i].percent != cl.prev_cshifts[i].percent) { new_ptr = true; cl.prev_cshifts[i].percent = cl.cshifts[i].percent; } for (j=0 ; j<3 ; j++) if (cl.cshifts[i].destcolor[j] != cl.prev_cshifts[i].destcolor[j]) { new_ptr = true; cl.prev_cshifts[i].destcolor[j] = cl.cshifts[i].destcolor[j]; } } // drop the damage value cl.cshifts[CSHIFT_DAMAGE].percent -= host_frametime*150; if (cl.cshifts[CSHIFT_DAMAGE].percent <= 0) cl.cshifts[CSHIFT_DAMAGE].percent = 0; // drop the bonus value cl.cshifts[CSHIFT_BONUS].percent -= host_frametime*100; if (cl.cshifts[CSHIFT_BONUS].percent <= 0) cl.cshifts[CSHIFT_BONUS].percent = 0; force = V_CheckGamma (); if (!new_ptr && !force) return; V_CalcBlend (); a = v_blend[3]; r = 255*v_blend[0]*a; g = 255*v_blend[1]*a; b = 255*v_blend[2]*a; a = 1-a; for (i=0 ; i<256 ; i++) { ir = i*a + r; ig = i*a + g; ib = i*a + b; if (ir > 255) ir = 255; if (ig > 255) ig = 255; if (ib > 255) ib = 255; ramps[0][i] = gammatable[ir]; ramps[1][i] = gammatable[ig]; ramps[2][i] = gammatable[ib]; } basepal = host_basepal; newpal = pal; for (i=0 ; i<256 ; i++) { ir = basepal[0]; ig = basepal[1]; ib = basepal[2]; basepal += 3; newpal[0] = ramps[0][ir]; newpal[1] = ramps[1][ig]; newpal[2] = ramps[2][ib]; newpal += 3; } render.ShiftPalette (pal); }