d_modech.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. // d_modech.c: called when mode has just changed
  16. #include "quakedef.h"
  17. #include "d_local.h"
  18. int d_vrectx, d_vrecty, d_vrectright_particle, d_vrectbottom_particle;
  19. int d_y_aspect_shift, d_pix_min, d_pix_max, d_pix_shift;
  20. int d_scantable[MAXHEIGHT];
  21. short *zspantable[MAXHEIGHT];
  22. /*
  23. ================
  24. D_Patch
  25. ================
  26. */
  27. void D_Patch (void)
  28. {
  29. #if id386
  30. static qboolean protectset8 = false;
  31. if (!protectset8)
  32. {
  33. Sys_MakeCodeWriteable ((int)D_PolysetAff8Start,
  34. (int)D_PolysetAff8End - (int)D_PolysetAff8Start);
  35. protectset8 = true;
  36. }
  37. #endif // id386
  38. }
  39. /*
  40. ================
  41. D_ViewChanged
  42. ================
  43. */
  44. void D_ViewChanged (void)
  45. {
  46. int rowbytes;
  47. if (r_dowarp)
  48. rowbytes = WARP_WIDTH;
  49. else
  50. rowbytes = vid.rowbytes;
  51. scale_for_mip = xscale;
  52. if (yscale > xscale)
  53. scale_for_mip = yscale;
  54. d_zrowbytes = vid.width * 2;
  55. d_zwidth = vid.width;
  56. d_pix_min = r_refdef.vrect.width / 320;
  57. if (d_pix_min < 1)
  58. d_pix_min = 1;
  59. d_pix_max = (int)((float)r_refdef.vrect.width / (320.0 / 4.0) + 0.5);
  60. d_pix_shift = 8 - (int)((float)r_refdef.vrect.width / 320.0 + 0.5);
  61. if (d_pix_max < 1)
  62. d_pix_max = 1;
  63. if (pixelAspect > 1.4)
  64. d_y_aspect_shift = 1;
  65. else
  66. d_y_aspect_shift = 0;
  67. d_vrectx = r_refdef.vrect.x;
  68. d_vrecty = r_refdef.vrect.y;
  69. d_vrectright_particle = r_refdef.vrectright - d_pix_max;
  70. d_vrectbottom_particle =
  71. r_refdef.vrectbottom - (d_pix_max << d_y_aspect_shift);
  72. {
  73. int i;
  74. for (i=0 ; i<vid.height; i++)
  75. {
  76. d_scantable[i] = i*rowbytes;
  77. zspantable[i] = d_pzbuffer + i*d_zwidth;
  78. }
  79. }
  80. D_Patch ();
  81. }