TIMERDWN.CPP 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. //
  2. // Copyright 2020 Electronic Arts Inc.
  3. //
  4. // TiberianDawn.DLL and RedAlert.dll and corresponding source code is free
  5. // software: you can redistribute it and/or modify it under the terms of
  6. // the GNU General Public License as published by the Free Software Foundation,
  7. // either version 3 of the License, or (at your option) any later version.
  8. // TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
  9. // in the hope that it will be useful, but with permitted additional restrictions
  10. // under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
  11. // distributed with this program. You should have received a copy of the
  12. // GNU General Public License along with permitted additional restrictions
  13. // with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
  14. /***************************************************************************
  15. ** 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 **
  16. ***************************************************************************
  17. * *
  18. * Project Name : Temp timer for 32bit lib *
  19. * *
  20. * File Name : TIMER.CPP *
  21. * *
  22. * Programmer : Scott K. Bowen *
  23. * *
  24. * Start Date : July 6, 1994 *
  25. * *
  26. * Last Update : July 12, 1994 [SKB] *
  27. * *
  28. *-------------------------------------------------------------------------*
  29. * Functions: *
  30. * CDTC::Time -- Return the time on the timer. *
  31. * CDTC::Stop -- Stop the timer. *
  32. * CDTC::Start -- Start a timer. *
  33. * CDTC::DownTimerClass -- Construct a timer class object. *
  34. * CDTC::Set -- Set the time of a timer. *
  35. * CDTC::Reset -- Clear the timer. *
  36. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  37. #include <wwstd.h>
  38. #include "timer.H"
  39. /////////////////////////////////////////////////////////////////////////////////
  40. /////////////////////////////////// Defines /////////////////////////////////////
  41. /////////////////////////////////////////////////////////////////////////////////
  42. /////////////////////////////////// Code ////////////////////////////////////////
  43. /***************************************************************************
  44. * TC::CountDownTimerClass -- Construct a timer class object. *
  45. * *
  46. * *
  47. * INPUT: *
  48. * *
  49. * OUTPUT: *
  50. * *
  51. * WARNINGS: *
  52. * *
  53. * HISTORY: *
  54. * 07/12/1994 SKB : Created. *
  55. *=========================================================================*/
  56. CountDownTimerClass::CountDownTimerClass(BaseTimerEnum timer, long set, int on)
  57. :TimerClass(timer, on)
  58. {
  59. Set(set, on);
  60. }
  61. CountDownTimerClass::CountDownTimerClass(BaseTimerEnum timer, int on)
  62. :TimerClass(timer, FALSE)
  63. {
  64. DelayTime = 0;
  65. if (on) Start();
  66. }
  67. /***************************************************************************
  68. * CDTC::TIME -- Return the time on the timer. *
  69. * *
  70. * *
  71. * INPUT: *
  72. * *
  73. * OUTPUT: *
  74. * *
  75. * WARNINGS: *
  76. * *
  77. * HISTORY: *
  78. * 07/12/1994 SKB : Created. *
  79. *=========================================================================*/
  80. long CountDownTimerClass::Time()
  81. {
  82. long ticks = DelayTime - TimerClass::Time();
  83. if (ticks < 0) {
  84. ticks = 0;
  85. }
  86. return(ticks);
  87. }
  88. /***************************************************************************
  89. * CDTC::SET -- Set the time of a timer. *
  90. * *
  91. * *
  92. * *
  93. * INPUT: ULONG value to set timer at. *
  94. * *
  95. * OUTPUT: *
  96. * *
  97. * WARNINGS: *
  98. * *
  99. * HISTORY: *
  100. * 07/12/1994 SKB : Created. *
  101. *=========================================================================*/
  102. long CountDownTimerClass::Set(long value, BOOL start)
  103. {
  104. DelayTime = value;
  105. TimerClass::Reset(start);
  106. return(Time());
  107. }