TIMERDWN.CPP 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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. ** 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 **
  20. ***************************************************************************
  21. * *
  22. * Project Name : Temp timer for 32bit lib *
  23. * *
  24. * File Name : TIMER.CPP *
  25. * *
  26. * Programmer : Scott K. Bowen *
  27. * *
  28. * Start Date : July 6, 1994 *
  29. * *
  30. * Last Update : July 12, 1994 [SKB] *
  31. * *
  32. *-------------------------------------------------------------------------*
  33. * Functions: *
  34. * CDTC::Time -- Return the time on the timer. *
  35. * CDTC::Stop -- Stop the timer. *
  36. * CDTC::Start -- Start a timer. *
  37. * CDTC::DownTimerClass -- Construct a timer class object. *
  38. * CDTC::Set -- Set the time of a timer. *
  39. * CDTC::Reset -- Clear the timer. *
  40. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  41. #include <wwstd.h>
  42. #include "timer.H"
  43. /////////////////////////////////////////////////////////////////////////////////
  44. /////////////////////////////////// Defines /////////////////////////////////////
  45. /////////////////////////////////////////////////////////////////////////////////
  46. /////////////////////////////////// Code ////////////////////////////////////////
  47. /***************************************************************************
  48. * TC::CountDownTimerClass -- Construct a timer class object. *
  49. * *
  50. * *
  51. * INPUT: *
  52. * *
  53. * OUTPUT: *
  54. * *
  55. * WARNINGS: *
  56. * *
  57. * HISTORY: *
  58. * 07/12/1994 SKB : Created. *
  59. *=========================================================================*/
  60. CountDownTimerClass::CountDownTimerClass(BaseTimerEnum timer, long set, int on)
  61. :TimerClass(timer, on)
  62. {
  63. Set(set, on);
  64. }
  65. CountDownTimerClass::CountDownTimerClass(BaseTimerEnum timer, int on)
  66. :TimerClass(timer, FALSE)
  67. {
  68. DelayTime = 0;
  69. if (on) Start();
  70. }
  71. /***************************************************************************
  72. * CDTC::TIME -- Return the time on the timer. *
  73. * *
  74. * *
  75. * INPUT: *
  76. * *
  77. * OUTPUT: *
  78. * *
  79. * WARNINGS: *
  80. * *
  81. * HISTORY: *
  82. * 07/12/1994 SKB : Created. *
  83. *=========================================================================*/
  84. long CountDownTimerClass::Time()
  85. {
  86. long ticks = DelayTime - TimerClass::Time();
  87. if (ticks < 0) {
  88. ticks = 0;
  89. }
  90. return(ticks);
  91. }
  92. /***************************************************************************
  93. * CDTC::SET -- Set the time of a timer. *
  94. * *
  95. * *
  96. * *
  97. * INPUT: ULONG value to set timer at. *
  98. * *
  99. * OUTPUT: *
  100. * *
  101. * WARNINGS: *
  102. * *
  103. * HISTORY: *
  104. * 07/12/1994 SKB : Created. *
  105. *=========================================================================*/
  106. long CountDownTimerClass::Set(long value, BOOL start)
  107. {
  108. DelayTime = value;
  109. TimerClass::Reset(start);
  110. return(Time());
  111. }