aboutsummaryrefslogtreecommitdiffstats
path: root/Game/Code/Classes/UTime.pas
diff options
context:
space:
mode:
authorjaybinks <jaybinks@b956fd51-792f-4845-bead-9b4dfca2ff2c>2007-10-11 12:02:20 +0000
committerjaybinks <jaybinks@b956fd51-792f-4845-bead-9b4dfca2ff2c>2007-10-11 12:02:20 +0000
commit44554c7908f7e2405a249331f00a35703f5939c2 (patch)
treebd1a5d2be22e4b4494e0b66331dbfb16dcceb3c5 /Game/Code/Classes/UTime.pas
parent0d997f8433e982584a0ab67a6d630d12f4314759 (diff)
downloadusdx-44554c7908f7e2405a249331f00a35703f5939c2.tar.gz
usdx-44554c7908f7e2405a249331f00a35703f5939c2.tar.xz
usdx-44554c7908f7e2405a249331f00a35703f5939c2.zip
Added IAudioPlayback Interface and implementation for BASS.
Created "AudioPlayback" Global Singleton, which removed the need for the "Music" Global variable. This was done because global singleton objects are a recognized better "design pattern" achieving the same thing as global variables, but in a nicer way. I will be working to a) separate IAudioPlayback in to separate "Playback" and "Input" Interfaces b) build a FFMpeg class that implements IAudioPlayback git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@504 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to '')
-rw-r--r--Game/Code/Classes/UTime.pas81
1 files changed, 10 insertions, 71 deletions
diff --git a/Game/Code/Classes/UTime.pas b/Game/Code/Classes/UTime.pas
index edd65b7e..87d17ee5 100644
--- a/Game/Code/Classes/UTime.pas
+++ b/Game/Code/Classes/UTime.pas
@@ -6,7 +6,6 @@ interface
{$MODE Delphi}
{$ENDIF}
-{$DEFINE SDLTimer}
{$UNDEF DebugDisplay}
type
@@ -22,7 +21,6 @@ procedure CountMidTime;
var
USTime: TTime;
- TimeFreq: int64;
TimeNew: int64;
TimeOld: int64;
TimeSkip: real;
@@ -32,16 +30,8 @@ var
implementation
uses
- {$IFDEF win32}
- windows,
- {$ELSE}
- libc,
- time,
- {$ENDIF}
- sysutils,
- {$IFDEF SDLTimer}
+// sysutils,
sdl,
- {$ENDIF}
ucommon;
const
@@ -65,18 +55,7 @@ end;
procedure CountSkipTimeSet;
begin
- {$IFDEF SDLTimer}
- TimeNew := SDL_GetTicks(); // / cSDLCorrectionRatio
- TimeFreq := 0;
- {$ELSE}
- {$IFDEF win32}
- QueryPerformanceFrequency(TimeFreq);
- QueryPerformanceCounter(TimeNew);
- {$ELSE}
- TimeNew := CurrentSec100OfDay(); // TODO - JB_Linux will prob need looking at
- TimeFreq := 0;
- {$ENDIF}
- {$ENDIF}
+ TimeNew := SDL_GetTicks();
{$IFDEF DebugDisplay}
Writeln( 'CountSkipTimeSet : ' + inttostr(trunc(TimeNew)) );
@@ -86,26 +65,9 @@ end;
procedure CountSkipTime;
begin
- TimeOld := TimeNew;
-
- {$IFDEF SDLTimer}
- TimeNew := SDL_GetTicks();
- TimeSkip := (TimeNew-TimeOld) / cSDLCorrectionRatio;
- {$ELSE}
- {$IFDEF win32}
- QueryPerformanceCounter(TimeNew);
-
- if ( TimeNew-TimeOld > 0 ) AND
- ( TimeFreq > 0 ) THEN
- begin
- TimeSkip := (TimeNew-TimeOld)/TimeFreq;
- end;
-
- {$ELSE}
- TimeNew := CurrentSec100OfDay(); // TODO - JB_Linux will prob need looking at
- TimeSkip := (TimeNew-TimeOld);
- {$ENDIF}
- {$ENDIF}
+ TimeOld := TimeNew;
+ TimeNew := SDL_GetTicks();
+ TimeSkip := (TimeNew-TimeOld) / cSDLCorrectionRatio;
{$IFDEF DebugDisplay}
Writeln( 'TimeNew : ' + inttostr(trunc(TimeNew)) );
@@ -116,43 +78,20 @@ end;
procedure CountMidTime;
begin
- {$IFDEF SDLTimer}
- TimeMidTemp := SDL_GetTicks();
- TimeMid := (TimeMidTemp - TimeNew) / cSDLCorrectionRatio;
- {$ELSE}
- {$IFDEF win32}
- QueryPerformanceCounter(TimeMidTemp);
- TimeMid := (TimeMidTemp-TimeNew)/TimeFreq;
- {$ELSE}
- TimeMidTemp := CurrentSec100OfDay();
- TimeMid := (TimeMidTemp-TimeNew); // TODO - JB_Linux will prob need looking at
- {$ENDIF}
- {$ENDIF}
+ TimeMidTemp := SDL_GetTicks();
+ TimeMid := (TimeMidTemp - TimeNew) / cSDLCorrectionRatio;
{$IFDEF DebugDisplay}
- Writeln( 'TimeNew : ' + inttostr(trunc(TimeNew)) );
+ Writeln( 'TimeNew : ' + inttostr(trunc(TimeNew)) );
Writeln( 'CountMidTime : ' + inttostr(trunc(TimeMid)) );
{$ENDIF}
end;
function TTime.GetTime: real;
-var
- TimeTemp: int64;
begin
- {$IFDEF SDLTimer}
- TimeTemp := SDL_GetTicks();
- Result := TimeTemp / cSDLCorrectionRatio; // TODO - JB_Linux will prob need looking at
- {$ELSE}
- {$IFDEF win32}
- QueryPerformanceCounter(TimeTemp);
- Result := TimeTemp / TimeFreq;
- {$ELSE}
- TimeTemp := CurrentSec100OfDay();
- Result := TimeTemp; // TODO - JB_Linux will prob need looking at
- {$ENDIF}
- {$ENDIF}
-
+ Result := SDL_GetTicks() / cSDLCorrectionRatio;
+
{$IFDEF DebugDisplay}
Writeln( 'GetTime : ' + inttostr(trunc(Result)) );
{$ENDIF}