+ key_consoleactive &= ~KEY_CONSOLEACTIVE_FORCED;
+
+// decide on the height of the console
+ if (key_consoleactive & KEY_CONSOLEACTIVE_FORCED)
+ scr_conlines = vid.conheight; // full screen
+ else if (key_consoleactive & KEY_CONSOLEACTIVE_USER)
+ scr_conlines = vid.conheight/2; // half screen
+ else
+ scr_conlines = 0; // none visible
+
+ if (scr_conspeed.value)
+ {
+ if (scr_conlines < scr_con_current)
+ {
+ scr_con_current -= scr_conspeed.value*host_realframetime;
+ if (scr_conlines > scr_con_current)
+ scr_con_current = scr_conlines;
+
+ }
+ else if (scr_conlines > scr_con_current)
+ {
+ scr_con_current += scr_conspeed.value*host_realframetime;
+ if (scr_conlines < scr_con_current)
+ scr_con_current = scr_conlines;
+ }
+ }
+ else
+ scr_con_current = scr_conlines;
+}
+
+/*
+==================
+SCR_DrawConsole
+==================
+*/
+void SCR_DrawConsole (void)
+{
+ if (scr_con_current)
+ {
+ Con_DrawConsole (scr_con_current);
+ clearconsole = 0;
+ }
+ else
+ {
+ if (key_dest == key_game || key_dest == key_message)
+ Con_DrawNotify (); // only draw notify in game
+ }
+}
+
+/*
+===============
+SCR_BeginLoadingPlaque
+
+================
+*/
+void SCR_BeginLoadingPlaque (void)
+{
+ if (scr_drawloading)
+ return;
+
+ S_StopAllSounds (true);
+
+ scr_drawloading = true;
+ CL_UpdateScreen ();
+ scr_drawloading = true;
+ CL_UpdateScreen ();
+}
+
+//=============================================================================
+
+char r_speeds_string[1024];
+int speedstringcount, r_timereport_active;
+double r_timereport_temp = 0, r_timereport_current = 0, r_timereport_start = 0;
+
+void R_TimeReport(char *desc)
+{
+ char tempbuf[256];
+ int length;
+ int t;
+
+ if (!r_timereport_active)
+ return;
+
+ r_timereport_temp = r_timereport_current;
+ r_timereport_current = Sys_DoubleTime();
+ t = (int) ((r_timereport_current - r_timereport_temp) * 1000000.0);
+
+ sprintf(tempbuf, "%8i %s", t, desc);
+ length = strlen(tempbuf);
+ while (length < 20)
+ tempbuf[length++] = ' ';
+ tempbuf[length] = 0;
+ if (speedstringcount + length > (vid.conwidth / 8))
+ {
+ strcat(r_speeds_string, "\n");
+ speedstringcount = 0;
+ }
+ // skip the space at the beginning if it's the first on the line
+ if (speedstringcount == 0)
+ {
+ strcat(r_speeds_string, tempbuf + 1);
+ speedstringcount = length - 1;
+ }
+ else
+ {
+ strcat(r_speeds_string, tempbuf);
+ speedstringcount += length;
+ }
+}
+
+extern int c_rt_lights, c_rt_clears, c_rt_scissored;
+extern int c_rt_shadowmeshes, c_rt_shadowtris, c_rt_lightmeshes, c_rt_lighttris;
+extern int c_rtcached_shadowmeshes, c_rtcached_shadowtris;
+void R_TimeReport_Start(void)
+{
+ r_timereport_active = r_speeds.integer && cls.signon == SIGNONS && cls.state == ca_connected;
+ r_speeds_string[0] = 0;
+ if (r_timereport_active)
+ {
+ speedstringcount = 0;
+ sprintf(r_speeds_string,
+ "org:'%+8.2f %+8.2f %+8.2f' dir:'%+2.3f %+2.3f %+2.3f'\n"
+ "world:%6i faces%6i nodes%6i leafs%6i dlitwalls\n"
+ "%5i models%5i bmodels%5i sprites%6i particles%4i dlights\n"
+ "%6i modeltris%6i meshs%6i meshtris\n",
+ r_vieworigin[0], r_vieworigin[1], r_vieworigin[2], r_viewforward[0], r_viewforward[1], r_viewforward[2],
+ c_faces, c_nodes, c_leafs, c_light_polys,
+ c_models, c_bmodels, c_sprites, c_particles, c_dlights,
+ c_alias_polys, c_meshs, c_meshelements / 3);
+
+ sprintf(r_speeds_string + strlen(r_speeds_string),
+ "realtime lighting:%4i lights%4i clears%4i scissored\n"
+ "dynamic: %6i shadowmeshes%6i shadowtris%6i lightmeshes%6i lighttris\n"
+ "precomputed: %6i shadowmeshes%6i shadowtris\n",
+ c_rt_lights, c_rt_clears, c_rt_scissored,
+ c_rt_shadowmeshes, c_rt_shadowtris, c_rt_lightmeshes, c_rt_lighttris,
+ c_rtcached_shadowmeshes, c_rtcached_shadowtris);
+
+ c_alias_polys = 0;
+ c_light_polys = 0;
+ c_faces = 0;
+ c_nodes = 0;
+ c_leafs = 0;
+ c_models = 0;
+ c_bmodels = 0;
+ c_sprites = 0;
+ c_particles = 0;
+ c_meshs = 0;
+ c_meshelements = 0;
+
+ r_timereport_start = Sys_DoubleTime();
+ }
+}
+
+void R_TimeReport_End(void)
+{
+ r_timereport_current = r_timereport_start;
+ R_TimeReport("total");
+
+ if (r_timereport_active)
+ {
+ int i, j, lines, y;
+ lines = 1;
+ for (i = 0;r_speeds_string[i];i++)
+ if (r_speeds_string[i] == '\n')
+ lines++;
+ y = vid.conheight - sb_lines - lines * 8;
+ i = j = 0;
+ DrawQ_Fill(0, y, vid.conwidth, lines * 8, 0, 0, 0, 0.5, 0);
+ while (r_speeds_string[i])
+ {
+ j = i;
+ while (r_speeds_string[i] && r_speeds_string[i] != '\n')
+ i++;
+ if (i - j > 0)
+ DrawQ_String(0, y, r_speeds_string + j, i - j, 8, 8, 1, 1, 1, 1, 0);
+ if (r_speeds_string[i] == '\n')
+ i++;
+ y += 8;
+ }
+ }
+}
+
+/*
+=================
+SCR_SizeUp_f
+
+Keybinding command
+=================
+*/
+void SCR_SizeUp_f (void)
+{
+ Cvar_SetValue ("viewsize",scr_viewsize.value+10);
+}
+
+
+/*
+=================
+SCR_SizeDown_f
+
+Keybinding command
+=================
+*/
+void SCR_SizeDown_f (void)
+{
+ Cvar_SetValue ("viewsize",scr_viewsize.value-10);
+}
+
+void CL_Screen_Init(void)
+{
+ Cvar_RegisterVariable (&scr_fov);
+ Cvar_RegisterVariable (&scr_viewsize);
+ Cvar_RegisterVariable (&scr_conspeed);
+ Cvar_RegisterVariable (&scr_conalpha);
+ Cvar_RegisterVariable (&scr_conbrightness);
+ Cvar_RegisterVariable (&scr_conforcewhiledisconnected);
+ Cvar_RegisterVariable (&scr_showram);
+ Cvar_RegisterVariable (&scr_showturtle);
+ Cvar_RegisterVariable (&scr_showpause);
+ Cvar_RegisterVariable (&scr_centertime);
+ Cvar_RegisterVariable (&scr_printspeed);
+ Cvar_RegisterVariable (&vid_conwidth);
+ Cvar_RegisterVariable (&vid_conheight);
+ Cvar_RegisterVariable (&scr_screenshot_jpeg);
+ Cvar_RegisterVariable (&scr_screenshot_jpeg_quality);
+ Cvar_RegisterVariable (&cl_avidemo);
+
+ Cmd_AddCommand ("sizeup",SCR_SizeUp_f);
+ Cmd_AddCommand ("sizedown",SCR_SizeDown_f);
+ Cmd_AddCommand ("screenshot",SCR_ScreenShot_f);
+ Cmd_AddCommand ("envmap", R_Envmap_f);
+
+ scr_initialized = true;