diff options
author | brunzelchen <brunzelchen@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2010-02-19 17:18:42 +0000 |
---|---|---|
committer | brunzelchen <brunzelchen@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2010-02-19 17:18:42 +0000 |
commit | 51ed8fe6f2ea9892e905e81cf5bad3960537eb40 (patch) | |
tree | a4dcb099343762dcb7bd7988f73de68c1959d3a5 /Game/Code/Classes/UTime.pas | |
download | usdx-51ed8fe6f2ea9892e905e81cf5bad3960537eb40.tar.gz usdx-51ed8fe6f2ea9892e905e81cf5bad3960537eb40.tar.xz usdx-51ed8fe6f2ea9892e905e81cf5bad3960537eb40.zip |
Challenge MOD r7 alpha based on Ultrastar Deluxe v1.0.1a
for changes read Changelog.txt in folder Game
git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/branches/1.0.1 Challenge MOD@2107 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to '')
-rw-r--r-- | Game/Code/Classes/UTime.pas | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/Game/Code/Classes/UTime.pas b/Game/Code/Classes/UTime.pas new file mode 100644 index 00000000..29e972ae --- /dev/null +++ b/Game/Code/Classes/UTime.pas @@ -0,0 +1,81 @@ +unit UTime;
+
+interface
+
+type
+ TTime = class
+ constructor Create;
+ function GetTime: real;
+ end;
+
+procedure CountSkipTimeSet;
+procedure CountSkipTime;
+procedure CountMidTime;
+procedure TimeSleep(ms: real);
+
+var
+ USTime: TTime;
+
+ TimeFreq: int64;
+ TimeNew: int64;
+ TimeOld: int64;
+ TimeSkip: real;
+ TimeMid: real;
+ TimeMidTemp: int64;
+
+implementation
+
+uses Windows;
+
+constructor TTime.Create;
+begin
+ CountSkipTimeSet;
+end;
+
+procedure CountSkipTimeSet;
+begin
+ QueryPerformanceFrequency(TimeFreq);
+ QueryPerformanceCounter(TimeNew);
+end;
+
+procedure CountSkipTime;
+begin
+ TimeOld := TimeNew;
+ QueryPerformanceCounter(TimeNew);
+ TimeSkip := (TimeNew-TimeOld)/TimeFreq;
+end;
+
+procedure CountMidTime;
+begin
+ QueryPerformanceCounter(TimeMidTemp);
+ TimeMid := (TimeMidTemp-TimeNew)/TimeFreq;
+end;
+
+procedure TimeSleep(ms: real);
+var
+ TimeStart: int64;
+ TimeHalf: int64;
+ Time: real;
+ Stop: boolean;
+begin
+ QueryPerformanceCounter(TimeStart);
+
+ Stop := false;
+ while (not Stop) do begin
+ QueryPerformanceCounter(TimeHalf);
+ Time := 1000 * (TimeHalf-TimeStart)/TimeFreq;
+ if Time > ms then Stop := true;
+ end;
+
+end;
+
+function TTime.GetTime: real;
+var
+ TimeTemp: int64;
+begin
+ QueryPerformanceCounter(TimeTemp);
+ Result := TimeTemp/TimeFreq;
+end;
+
+
+end.
|