screen.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992
  1. /*
  2. Copyright (C) 1996-1997 Id Software, Inc.
  3. This program is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU General Public License
  5. as published by the Free Software Foundation; either version 2
  6. of the License, or (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. See the GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  14. */
  15. // screen.c -- master for refresh, status bar, console, chat, notify, etc
  16. #include "quakedef.h"
  17. #include "r_local.h"
  18. // only the refresh window will be updated unless these variables are flagged
  19. int scr_copytop;
  20. int scr_copyeverything;
  21. float scr_con_current;
  22. float scr_conlines; // lines of console to display
  23. float oldscreensize, oldfov;
  24. cvar_t scr_viewsize = {"viewsize","100", true};
  25. cvar_t scr_fov = {"fov","90"}; // 10 - 170
  26. cvar_t scr_conspeed = {"scr_conspeed","300"};
  27. cvar_t scr_centertime = {"scr_centertime","2"};
  28. cvar_t scr_showram = {"showram","1"};
  29. cvar_t scr_showturtle = {"showturtle","0"};
  30. cvar_t scr_showpause = {"showpause","1"};
  31. cvar_t scr_printspeed = {"scr_printspeed","8"};
  32. qboolean scr_initialized; // ready to draw
  33. qpic_t *scr_ram;
  34. qpic_t *scr_net;
  35. qpic_t *scr_turtle;
  36. int scr_fullupdate;
  37. int clearconsole;
  38. int clearnotify;
  39. viddef_t vid; // global video state
  40. vrect_t *pconupdate;
  41. vrect_t scr_vrect;
  42. qboolean scr_disabled_for_loading;
  43. qboolean scr_drawloading;
  44. float scr_disabled_time;
  45. qboolean scr_skipupdate;
  46. qboolean block_drawing;
  47. void SCR_ScreenShot_f (void);
  48. /*
  49. ===============================================================================
  50. CENTER PRINTING
  51. ===============================================================================
  52. */
  53. char scr_centerstring[1024];
  54. float scr_centertime_start; // for slow victory printing
  55. float scr_centertime_off;
  56. int scr_center_lines;
  57. int scr_erase_lines;
  58. int scr_erase_center;
  59. /*
  60. ==============
  61. SCR_CenterPrint
  62. Called for important messages that should stay in the center of the screen
  63. for a few moments
  64. ==============
  65. */
  66. void SCR_CenterPrint (char *str)
  67. {
  68. strncpy (scr_centerstring, str, sizeof(scr_centerstring)-1);
  69. scr_centertime_off = scr_centertime.value;
  70. scr_centertime_start = cl.time;
  71. // count the number of lines for centering
  72. scr_center_lines = 1;
  73. while (*str)
  74. {
  75. if (*str == '\n')
  76. scr_center_lines++;
  77. str++;
  78. }
  79. }
  80. void SCR_EraseCenterString (void)
  81. {
  82. int y;
  83. if (scr_erase_center++ > vid.numpages)
  84. {
  85. scr_erase_lines = 0;
  86. return;
  87. }
  88. if (scr_center_lines <= 4)
  89. y = vid.height*0.35;
  90. else
  91. y = 48;
  92. scr_copytop = 1;
  93. Draw_TileClear (0, y,vid.width, 8*scr_erase_lines);
  94. }
  95. void SCR_DrawCenterString (void)
  96. {
  97. char *start;
  98. int l;
  99. int j;
  100. int x, y;
  101. int remaining;
  102. // the finale prints the characters one at a time
  103. if (cl.intermission)
  104. remaining = scr_printspeed.value * (cl.time - scr_centertime_start);
  105. else
  106. remaining = 9999;
  107. scr_erase_center = 0;
  108. start = scr_centerstring;
  109. if (scr_center_lines <= 4)
  110. y = vid.height*0.35;
  111. else
  112. y = 48;
  113. do
  114. {
  115. // scan the width of the line
  116. for (l=0 ; l<40 ; l++)
  117. if (start[l] == '\n' || !start[l])
  118. break;
  119. x = (vid.width - l*8)/2;
  120. for (j=0 ; j<l ; j++, x+=8)
  121. {
  122. Draw_Character (x, y, start[j]);
  123. if (!remaining--)
  124. return;
  125. }
  126. y += 8;
  127. while (*start && *start != '\n')
  128. start++;
  129. if (!*start)
  130. break;
  131. start++; // skip the \n
  132. } while (1);
  133. }
  134. void SCR_CheckDrawCenterString (void)
  135. {
  136. scr_copytop = 1;
  137. if (scr_center_lines > scr_erase_lines)
  138. scr_erase_lines = scr_center_lines;
  139. scr_centertime_off -= host_frametime;
  140. if (scr_centertime_off <= 0 && !cl.intermission)
  141. return;
  142. if (key_dest != key_game)
  143. return;
  144. SCR_DrawCenterString ();
  145. }
  146. //=============================================================================
  147. /*
  148. ====================
  149. CalcFov
  150. ====================
  151. */
  152. float CalcFov (float fov_x, float width, float height)
  153. {
  154. float a;
  155. float x;
  156. if (fov_x < 1 || fov_x > 179)
  157. Sys_Error ("Bad fov: %f", fov_x);
  158. x = width/tan(fov_x/360*M_PI);
  159. a = atan (height/x);
  160. a = a*360/M_PI;
  161. return a;
  162. }
  163. /*
  164. =================
  165. SCR_CalcRefdef
  166. Must be called whenever vid changes
  167. Internal use only
  168. =================
  169. */
  170. static void SCR_CalcRefdef (void)
  171. {
  172. vrect_t vrect;
  173. float size;
  174. scr_fullupdate = 0; // force a background redraw
  175. vid.recalc_refdef = 0;
  176. // force the status bar to redraw
  177. Sbar_Changed ();
  178. //========================================
  179. // bound viewsize
  180. if (scr_viewsize.value < 30)
  181. Cvar_Set ("viewsize","30");
  182. if (scr_viewsize.value > 120)
  183. Cvar_Set ("viewsize","120");
  184. // bound field of view
  185. if (scr_fov.value < 10)
  186. Cvar_Set ("fov","10");
  187. if (scr_fov.value > 170)
  188. Cvar_Set ("fov","170");
  189. r_refdef.fov_x = scr_fov.value;
  190. r_refdef.fov_y = CalcFov (r_refdef.fov_x, r_refdef.vrect.width, r_refdef.vrect.height);
  191. // intermission is always full screen
  192. if (cl.intermission)
  193. size = 120;
  194. else
  195. size = scr_viewsize.value;
  196. if (size >= 120)
  197. sb_lines = 0; // no status bar at all
  198. else if (size >= 110)
  199. sb_lines = 24; // no inventory
  200. else
  201. sb_lines = 24+16+8;
  202. // these calculations mirror those in R_Init() for r_refdef, but take no
  203. // account of water warping
  204. vrect.x = 0;
  205. vrect.y = 0;
  206. vrect.width = vid.width;
  207. vrect.height = vid.height;
  208. R_SetVrect (&vrect, &scr_vrect, sb_lines);
  209. // guard against going from one mode to another that's less than half the
  210. // vertical resolution
  211. if (scr_con_current > vid.height)
  212. scr_con_current = vid.height;
  213. // notify the refresh of the change
  214. R_ViewChanged (&vrect, sb_lines, vid.aspect);
  215. }
  216. /*
  217. =================
  218. SCR_SizeUp_f
  219. Keybinding command
  220. =================
  221. */
  222. void SCR_SizeUp_f (void)
  223. {
  224. Cvar_SetValue ("viewsize",scr_viewsize.value+10);
  225. vid.recalc_refdef = 1;
  226. }
  227. /*
  228. =================
  229. SCR_SizeDown_f
  230. Keybinding command
  231. =================
  232. */
  233. void SCR_SizeDown_f (void)
  234. {
  235. Cvar_SetValue ("viewsize",scr_viewsize.value-10);
  236. vid.recalc_refdef = 1;
  237. }
  238. //============================================================================
  239. /*
  240. ==================
  241. SCR_Init
  242. ==================
  243. */
  244. void SCR_Init (void)
  245. {
  246. Cvar_RegisterVariable (&scr_fov);
  247. Cvar_RegisterVariable (&scr_viewsize);
  248. Cvar_RegisterVariable (&scr_conspeed);
  249. Cvar_RegisterVariable (&scr_showram);
  250. Cvar_RegisterVariable (&scr_showturtle);
  251. Cvar_RegisterVariable (&scr_showpause);
  252. Cvar_RegisterVariable (&scr_centertime);
  253. Cvar_RegisterVariable (&scr_printspeed);
  254. //
  255. // register our commands
  256. //
  257. Cmd_AddCommand ("screenshot",SCR_ScreenShot_f);
  258. Cmd_AddCommand ("sizeup",SCR_SizeUp_f);
  259. Cmd_AddCommand ("sizedown",SCR_SizeDown_f);
  260. scr_ram = Draw_PicFromWad ("ram");
  261. scr_net = Draw_PicFromWad ("net");
  262. scr_turtle = Draw_PicFromWad ("turtle");
  263. scr_initialized = true;
  264. }
  265. /*
  266. ==============
  267. SCR_DrawRam
  268. ==============
  269. */
  270. void SCR_DrawRam (void)
  271. {
  272. if (!scr_showram.value)
  273. return;
  274. if (!r_cache_thrash)
  275. return;
  276. Draw_Pic (scr_vrect.x+32, scr_vrect.y, scr_ram);
  277. }
  278. /*
  279. ==============
  280. SCR_DrawTurtle
  281. ==============
  282. */
  283. void SCR_DrawTurtle (void)
  284. {
  285. static int count;
  286. if (!scr_showturtle.value)
  287. return;
  288. if (host_frametime < 0.1)
  289. {
  290. count = 0;
  291. return;
  292. }
  293. count++;
  294. if (count < 3)
  295. return;
  296. Draw_Pic (scr_vrect.x, scr_vrect.y, scr_turtle);
  297. }
  298. /*
  299. ==============
  300. SCR_DrawNet
  301. ==============
  302. */
  303. void SCR_DrawNet (void)
  304. {
  305. if (realtime - cl.last_received_message < 0.3)
  306. return;
  307. if (cls.demoplayback)
  308. return;
  309. Draw_Pic (scr_vrect.x+64, scr_vrect.y, scr_net);
  310. }
  311. /*
  312. ==============
  313. DrawPause
  314. ==============
  315. */
  316. void SCR_DrawPause (void)
  317. {
  318. qpic_t *pic;
  319. if (!scr_showpause.value) // turn off for screenshots
  320. return;
  321. if (!cl.paused)
  322. return;
  323. pic = Draw_CachePic ("gfx/pause.lmp");
  324. Draw_Pic ( (vid.width - pic->width)/2,
  325. (vid.height - 48 - pic->height)/2, pic);
  326. }
  327. /*
  328. ==============
  329. SCR_DrawLoading
  330. ==============
  331. */
  332. void SCR_DrawLoading (void)
  333. {
  334. qpic_t *pic;
  335. if (!scr_drawloading)
  336. return;
  337. pic = Draw_CachePic ("gfx/loading.lmp");
  338. Draw_Pic ( (vid.width - pic->width)/2,
  339. (vid.height - 48 - pic->height)/2, pic);
  340. }
  341. //=============================================================================
  342. /*
  343. ==================
  344. SCR_SetUpToDrawConsole
  345. ==================
  346. */
  347. void SCR_SetUpToDrawConsole (void)
  348. {
  349. Con_CheckResize ();
  350. if (scr_drawloading)
  351. return; // never a console with loading plaque
  352. // decide on the height of the console
  353. con_forcedup = !cl.worldmodel || cls.signon != SIGNONS;
  354. if (con_forcedup)
  355. {
  356. scr_conlines = vid.height; // full screen
  357. scr_con_current = scr_conlines;
  358. }
  359. else if (key_dest == key_console)
  360. scr_conlines = vid.height/2; // half screen
  361. else
  362. scr_conlines = 0; // none visible
  363. if (scr_conlines < scr_con_current)
  364. {
  365. scr_con_current -= scr_conspeed.value*host_frametime;
  366. if (scr_conlines > scr_con_current)
  367. scr_con_current = scr_conlines;
  368. }
  369. else if (scr_conlines > scr_con_current)
  370. {
  371. scr_con_current += scr_conspeed.value*host_frametime;
  372. if (scr_conlines < scr_con_current)
  373. scr_con_current = scr_conlines;
  374. }
  375. if (clearconsole++ < vid.numpages)
  376. {
  377. scr_copytop = 1;
  378. Draw_TileClear (0,(int)scr_con_current,vid.width, vid.height - (int)scr_con_current);
  379. Sbar_Changed ();
  380. }
  381. else if (clearnotify++ < vid.numpages)
  382. {
  383. scr_copytop = 1;
  384. Draw_TileClear (0,0,vid.width, con_notifylines);
  385. }
  386. else
  387. con_notifylines = 0;
  388. }
  389. /*
  390. ==================
  391. SCR_DrawConsole
  392. ==================
  393. */
  394. void SCR_DrawConsole (void)
  395. {
  396. if (scr_con_current)
  397. {
  398. scr_copyeverything = 1;
  399. Con_DrawConsole (scr_con_current, true);
  400. clearconsole = 0;
  401. }
  402. else
  403. {
  404. if (key_dest == key_game || key_dest == key_message)
  405. Con_DrawNotify (); // only draw notify in game
  406. }
  407. }
  408. /*
  409. ==============================================================================
  410. SCREEN SHOTS
  411. ==============================================================================
  412. */
  413. typedef struct
  414. {
  415. char manufacturer;
  416. char version;
  417. char encoding;
  418. char bits_per_pixel;
  419. unsigned short xmin,ymin,xmax,ymax;
  420. unsigned short hres,vres;
  421. unsigned char palette[48];
  422. char reserved;
  423. char color_planes;
  424. unsigned short bytes_per_line;
  425. unsigned short palette_type;
  426. char filler[58];
  427. unsigned char data; // unbounded
  428. } pcx_t;
  429. /*
  430. ==============
  431. WritePCXfile
  432. ==============
  433. */
  434. void WritePCXfile (char *filename, byte *data, int width, int height,
  435. int rowbytes, byte *palette)
  436. {
  437. int i, j, length;
  438. pcx_t *pcx;
  439. byte *pack;
  440. pcx = Hunk_TempAlloc (width*height*2+1000);
  441. if (pcx == NULL)
  442. {
  443. Con_Printf("SCR_ScreenShot_f: not enough memory\n");
  444. return;
  445. }
  446. pcx->manufacturer = 0x0a; // PCX id
  447. pcx->version = 5; // 256 color
  448. pcx->encoding = 1; // uncompressed
  449. pcx->bits_per_pixel = 8; // 256 color
  450. pcx->xmin = 0;
  451. pcx->ymin = 0;
  452. pcx->xmax = LittleShort((short)(width-1));
  453. pcx->ymax = LittleShort((short)(height-1));
  454. pcx->hres = LittleShort((short)width);
  455. pcx->vres = LittleShort((short)height);
  456. Q_memset (pcx->palette,0,sizeof(pcx->palette));
  457. pcx->color_planes = 1; // chunky image
  458. pcx->bytes_per_line = LittleShort((short)width);
  459. pcx->palette_type = LittleShort(2); // not a grey scale
  460. Q_memset (pcx->filler,0,sizeof(pcx->filler));
  461. // pack the image
  462. pack = &pcx->data;
  463. for (i=0 ; i<height ; i++)
  464. {
  465. for (j=0 ; j<width ; j++)
  466. {
  467. if ( (*data & 0xc0) != 0xc0)
  468. *pack++ = *data++;
  469. else
  470. {
  471. *pack++ = 0xc1;
  472. *pack++ = *data++;
  473. }
  474. }
  475. data += rowbytes - width;
  476. }
  477. // write the palette
  478. *pack++ = 0x0c; // palette ID byte
  479. for (i=0 ; i<768 ; i++)
  480. *pack++ = *palette++;
  481. // write output file
  482. length = pack - (byte *)pcx;
  483. COM_WriteFile (filename, pcx, length);
  484. }
  485. /*
  486. ==================
  487. SCR_ScreenShot_f
  488. ==================
  489. */
  490. void SCR_ScreenShot_f (void)
  491. {
  492. int i;
  493. char pcxname[80];
  494. char checkname[MAX_OSPATH];
  495. //
  496. // find a file name to save it to
  497. //
  498. strcpy(pcxname,"quake00.pcx");
  499. for (i=0 ; i<=99 ; i++)
  500. {
  501. pcxname[5] = i/10 + '0';
  502. pcxname[6] = i%10 + '0';
  503. sprintf (checkname, "%s/%s", com_gamedir, pcxname);
  504. if (Sys_FileTime(checkname) == -1)
  505. break; // file doesn't exist
  506. }
  507. if (i==100)
  508. {
  509. Con_Printf ("SCR_ScreenShot_f: Couldn't create a PCX file\n");
  510. return;
  511. }
  512. //
  513. // save the pcx file
  514. //
  515. D_EnableBackBufferAccess (); // enable direct drawing of console to back
  516. // buffer
  517. WritePCXfile (pcxname, vid.buffer, vid.width, vid.height, vid.rowbytes,
  518. host_basepal);
  519. D_DisableBackBufferAccess (); // for adapters that can't stay mapped in
  520. // for linear writes all the time
  521. Con_Printf ("Wrote %s\n", pcxname);
  522. }
  523. //=============================================================================
  524. /*
  525. ===============
  526. SCR_BeginLoadingPlaque
  527. ================
  528. */
  529. void SCR_BeginLoadingPlaque (void)
  530. {
  531. S_StopAllSounds (true);
  532. if (cls.state != ca_connected)
  533. return;
  534. if (cls.signon != SIGNONS)
  535. return;
  536. // redraw with no console and the loading plaque
  537. Con_ClearNotify ();
  538. scr_centertime_off = 0;
  539. scr_con_current = 0;
  540. scr_drawloading = true;
  541. scr_fullupdate = 0;
  542. Sbar_Changed ();
  543. SCR_UpdateScreen ();
  544. scr_drawloading = false;
  545. scr_disabled_for_loading = true;
  546. scr_disabled_time = realtime;
  547. scr_fullupdate = 0;
  548. }
  549. /*
  550. ===============
  551. SCR_EndLoadingPlaque
  552. ================
  553. */
  554. void SCR_EndLoadingPlaque (void)
  555. {
  556. scr_disabled_for_loading = false;
  557. scr_fullupdate = 0;
  558. Con_ClearNotify ();
  559. }
  560. //=============================================================================
  561. char *scr_notifystring;
  562. qboolean scr_drawdialog;
  563. void SCR_DrawNotifyString (void)
  564. {
  565. char *start;
  566. int l;
  567. int j;
  568. int x, y;
  569. start = scr_notifystring;
  570. y = vid.height*0.35;
  571. do
  572. {
  573. // scan the width of the line
  574. for (l=0 ; l<40 ; l++)
  575. if (start[l] == '\n' || !start[l])
  576. break;
  577. x = (vid.width - l*8)/2;
  578. for (j=0 ; j<l ; j++, x+=8)
  579. Draw_Character (x, y, start[j]);
  580. y += 8;
  581. while (*start && *start != '\n')
  582. start++;
  583. if (!*start)
  584. break;
  585. start++; // skip the \n
  586. } while (1);
  587. }
  588. /*
  589. ==================
  590. SCR_ModalMessage
  591. Displays a text string in the center of the screen and waits for a Y or N
  592. keypress.
  593. ==================
  594. */
  595. int SCR_ModalMessage (char *text)
  596. {
  597. if (cls.state == ca_dedicated)
  598. return true;
  599. scr_notifystring = text;
  600. // draw a fresh screen
  601. scr_fullupdate = 0;
  602. scr_drawdialog = true;
  603. SCR_UpdateScreen ();
  604. scr_drawdialog = false;
  605. S_ClearBuffer (); // so dma doesn't loop current sound
  606. do
  607. {
  608. key_count = -1; // wait for a key down and up
  609. Sys_SendKeyEvents ();
  610. } while (key_lastpress != 'y' && key_lastpress != 'n' && key_lastpress != K_ESCAPE);
  611. scr_fullupdate = 0;
  612. SCR_UpdateScreen ();
  613. return key_lastpress == 'y';
  614. }
  615. //=============================================================================
  616. /*
  617. ===============
  618. SCR_BringDownConsole
  619. Brings the console down and fades the palettes back to normal
  620. ================
  621. */
  622. void SCR_BringDownConsole (void)
  623. {
  624. int i;
  625. scr_centertime_off = 0;
  626. for (i=0 ; i<20 && scr_conlines != scr_con_current ; i++)
  627. SCR_UpdateScreen ();
  628. cl.cshifts[0].percent = 0; // no area contents palette on next frame
  629. VID_SetPalette (host_basepal);
  630. }
  631. /*
  632. ==================
  633. SCR_UpdateScreen
  634. This is called every frame, and can also be called explicitly to flush
  635. text to the screen.
  636. WARNING: be very careful calling this from elsewhere, because the refresh
  637. needs almost the entire 256k of stack space!
  638. ==================
  639. */
  640. void SCR_UpdateScreen (void)
  641. {
  642. static float oldscr_viewsize;
  643. static float oldlcd_x;
  644. vrect_t vrect;
  645. if (scr_skipupdate || block_drawing)
  646. return;
  647. scr_copytop = 0;
  648. scr_copyeverything = 0;
  649. if (scr_disabled_for_loading)
  650. {
  651. if (realtime - scr_disabled_time > 60)
  652. {
  653. scr_disabled_for_loading = false;
  654. Con_Printf ("load failed.\n");
  655. }
  656. else
  657. return;
  658. }
  659. if (cls.state == ca_dedicated)
  660. return; // stdout only
  661. if (!scr_initialized || !con_initialized)
  662. return; // not initialized yet
  663. if (scr_viewsize.value != oldscr_viewsize)
  664. {
  665. oldscr_viewsize = scr_viewsize.value;
  666. vid.recalc_refdef = 1;
  667. }
  668. //
  669. // check for vid changes
  670. //
  671. if (oldfov != scr_fov.value)
  672. {
  673. oldfov = scr_fov.value;
  674. vid.recalc_refdef = true;
  675. }
  676. if (oldlcd_x != lcd_x.value)
  677. {
  678. oldlcd_x = lcd_x.value;
  679. vid.recalc_refdef = true;
  680. }
  681. if (oldscreensize != scr_viewsize.value)
  682. {
  683. oldscreensize = scr_viewsize.value;
  684. vid.recalc_refdef = true;
  685. }
  686. if (vid.recalc_refdef)
  687. {
  688. // something changed, so reorder the screen
  689. SCR_CalcRefdef ();
  690. }
  691. //
  692. // do 3D refresh drawing, and then update the screen
  693. //
  694. D_EnableBackBufferAccess (); // of all overlay stuff if drawing directly
  695. if (scr_fullupdate++ < vid.numpages)
  696. { // clear the entire screen
  697. scr_copyeverything = 1;
  698. Draw_TileClear (0,0,vid.width,vid.height);
  699. Sbar_Changed ();
  700. }
  701. pconupdate = NULL;
  702. SCR_SetUpToDrawConsole ();
  703. SCR_EraseCenterString ();
  704. D_DisableBackBufferAccess (); // for adapters that can't stay mapped in
  705. // for linear writes all the time
  706. VID_LockBuffer ();
  707. V_RenderView ();
  708. VID_UnlockBuffer ();
  709. D_EnableBackBufferAccess (); // of all overlay stuff if drawing directly
  710. if (scr_drawdialog)
  711. {
  712. Sbar_Draw ();
  713. Draw_FadeScreen ();
  714. SCR_DrawNotifyString ();
  715. scr_copyeverything = true;
  716. }
  717. else if (scr_drawloading)
  718. {
  719. SCR_DrawLoading ();
  720. Sbar_Draw ();
  721. }
  722. else if (cl.intermission == 1 && key_dest == key_game)
  723. {
  724. Sbar_IntermissionOverlay ();
  725. }
  726. else if (cl.intermission == 2 && key_dest == key_game)
  727. {
  728. Sbar_FinaleOverlay ();
  729. SCR_CheckDrawCenterString ();
  730. }
  731. else if (cl.intermission == 3 && key_dest == key_game)
  732. {
  733. SCR_CheckDrawCenterString ();
  734. }
  735. else
  736. {
  737. SCR_DrawRam ();
  738. SCR_DrawNet ();
  739. SCR_DrawTurtle ();
  740. SCR_DrawPause ();
  741. SCR_CheckDrawCenterString ();
  742. Sbar_Draw ();
  743. SCR_DrawConsole ();
  744. M_Draw ();
  745. }
  746. D_DisableBackBufferAccess (); // for adapters that can't stay mapped in
  747. // for linear writes all the time
  748. if (pconupdate)
  749. {
  750. D_UpdateRects (pconupdate);
  751. }
  752. V_UpdatePalette ();
  753. //
  754. // update one of three areas
  755. //
  756. if (scr_copyeverything)
  757. {
  758. vrect.x = 0;
  759. vrect.y = 0;
  760. vrect.width = vid.width;
  761. vrect.height = vid.height;
  762. vrect.pnext = 0;
  763. VID_Update (&vrect);
  764. }
  765. else if (scr_copytop)
  766. {
  767. vrect.x = 0;
  768. vrect.y = 0;
  769. vrect.width = vid.width;
  770. vrect.height = vid.height - sb_lines;
  771. vrect.pnext = 0;
  772. VID_Update (&vrect);
  773. }
  774. else
  775. {
  776. vrect.x = scr_vrect.x;
  777. vrect.y = scr_vrect.y;
  778. vrect.width = scr_vrect.width;
  779. vrect.height = scr_vrect.height;
  780. vrect.pnext = 0;
  781. VID_Update (&vrect);
  782. }
  783. }
  784. /*
  785. ==================
  786. SCR_UpdateWholeScreen
  787. ==================
  788. */
  789. void SCR_UpdateWholeScreen (void)
  790. {
  791. scr_fullupdate = 0;
  792. SCR_UpdateScreen ();
  793. }