1 // -*- Mode: C++; tab-width:2; indent-tabs-mode: nil; c-basic-offset: 2 -*- 2 // vi:tw=80:et:ts=2:sts=2 3 // 4 // ----------------------------------------------------------------------- 5 // 6 // This file is part of RLVM, a RealLive virtual machine clone. 7 // 8 // ----------------------------------------------------------------------- 9 // 10 // Copyright (C) 2006 Elliot Glaysher 11 // 12 // This program is free software; you can redistribute it and/or modify 13 // it under the terms of the GNU General Public License as published by 14 // the Free Software Foundation; either version 3 of the License, or 15 // (at your option) any later version. 16 // 17 // This program is distributed in the hope that it will be useful, 18 // but WITHOUT ANY WARRANTY; without even the implied warranty of 19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 // GNU General Public License for more details. 21 // 22 // You should have received a copy of the GNU General Public License 23 // along with this program; if not, write to the Free Software 24 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. 25 // 26 // ----------------------------------------------------------------------- 27 28 #ifndef SRC_SYSTEMS_BASE_RLTIMER_H_ 29 #define SRC_SYSTEMS_BASE_RLTIMER_H_ 30 31 class EventSystem; 32 33 // "Timers are simple counters: when initialized, they start counting from 0, 34 // and can be queried at any point to return the number of milliseconds that 35 // have elapsed since their initialization. 36 // 37 // "RealLive provides two sets of 255 timers, the basic counters (カウント) and 38 // the extended counters (EXカウント); the difference between them is unclear, 39 // other than that different sets of functions operate on each. Of the functions 40 // documented below, those with an `Ex' infix operate on the extended counters, 41 // and those without operate on the basic counters. 42 // 43 // "The number of the timer to use, counter, is optional in all these functions; 44 // in all cases, if it is not given, it will default to 0. 45 // 46 // "All timers run continuously; they cannot be stopped. The implementation 47 // appears to be based on the time since the interpreter was started, as this is 48 // what you get if you query a timer that has not been initialized to any other 49 // value. “Setting” a timer merely stores the time at which the timer was set, 50 // and future queries subtract this from the time since the interpreter was 51 // started and then add the value to which the timer was initialized." 52 class RLTimer { 53 public: 54 RLTimer(); 55 ~RLTimer(); 56 57 // Returns the current value of this frame counter. This value represents the 58 // number of milliseconds since the timer was initialized. 59 unsigned int Read(EventSystem& events); 60 61 void Set(EventSystem& events, unsigned int value = 0); 62 63 private: 64 unsigned int time_at_last_set_; 65 }; 66 67 #endif // SRC_SYSTEMS_BASE_RLTIMER_H_ 68