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