TESTVB.CPP 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  2. ** Command & Conquer Red Alert(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /****************************************************************************
  19. *
  20. * C O N F I D E N T I A L -- W E S T W O O D S T U D I O S
  21. *
  22. *----------------------------------------------------------------------------
  23. *
  24. * FILE
  25. * testvb.c
  26. *
  27. * DESCRIPTION
  28. * Video mode setting. (32-Bit protected mode)
  29. *
  30. * PROGRAMMER
  31. * Denzil E. Long, Jr.
  32. *
  33. * DATE
  34. * Febuary 3, 1995
  35. *
  36. *----------------------------------------------------------------------------
  37. *
  38. * PUBLIC
  39. * TestVBIBit - Test the polarity of the vertical blank bit.
  40. *
  41. ****************************************************************************/
  42. #include <sys\timeb.h>
  43. #ifdef __BORLANDC__
  44. #include "portio.h"
  45. #else
  46. #include <conio.h>
  47. #endif
  48. /****************************************************************************
  49. *
  50. * NAME
  51. * TestVBIBit - Test the polarity of the vertical blank bit.
  52. *
  53. * SYNOPSIS
  54. * Polarity = TestVBIBit()
  55. *
  56. * long TestVBIBit(void);
  57. *
  58. * FUNCTION
  59. *
  60. * INPUTS
  61. * NONE
  62. *
  63. * RESULT
  64. * Polarity - Polarity of the vertical blank bit.
  65. *
  66. ****************************************************************************/
  67. long TestVBIBit(void)
  68. {
  69. static struct timeb mytime;
  70. long curtime;
  71. long endtime;
  72. unsigned long high = 0;
  73. unsigned long low = 0;
  74. /* Set the check time for .25 (1/4) of a second. */
  75. ftime(&mytime);
  76. curtime = ((mytime.time * 1000) + mytime.millitm);
  77. endtime = (curtime + (1000 / 4));
  78. /* Sample the vertical blank bit for the specified period of time.
  79. * The state in which it is in the least is the vertical blank state,
  80. * the state in which it is in the most is the active scan state.
  81. */
  82. while (endtime >= curtime) {
  83. ftime(&mytime);
  84. curtime = ((mytime.time * 1000) + mytime.millitm);
  85. if (inp(0x3DA) & 0x08) {
  86. high++;
  87. } else {
  88. low++;
  89. }
  90. }
  91. return (high > low);
  92. }