summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Howard2005-12-30 18:50:53 +0000
committerSimon Howard2005-12-30 18:50:53 +0000
commit694292fa55e926ca4d7be4a26bd55a9faa41a589 (patch)
treeeb5537e7612ef977fb925d865376528251ac0202 /src
parentf459280f965b6e737466e2e250226aa809627c13 (diff)
downloadchocolate-doom-694292fa55e926ca4d7be4a26bd55a9faa41a589.tar.gz
chocolate-doom-694292fa55e926ca4d7be4a26bd55a9faa41a589.tar.bz2
chocolate-doom-694292fa55e926ca4d7be4a26bd55a9faa41a589.zip
Millisecond clock function
Subversion-branch: /trunk/chocolate-doom Subversion-revision: 234
Diffstat (limited to 'src')
-rw-r--r--src/i_system.c29
-rw-r--r--src/i_system.h8
2 files changed, 32 insertions, 5 deletions
diff --git a/src/i_system.c b/src/i_system.c
index 7176f863..ad40d532 100644
--- a/src/i_system.c
+++ b/src/i_system.c
@@ -1,7 +1,7 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
-// $Id: i_system.c 230 2005-11-17 09:41:24Z fraggle $
+// $Id: i_system.c 234 2005-12-30 18:50:53Z fraggle $
//
// Copyright(C) 1993-1996 Id Software, Inc.
// Copyright(C) 2005 Simon Howard
@@ -22,6 +22,9 @@
// 02111-1307, USA.
//
// $Log$
+// Revision 1.15 2005/12/30 18:50:53 fraggle
+// Millisecond clock function
+//
// Revision 1.14 2005/11/17 09:41:24 fraggle
// Catch SDL_QUIT event on ENDOOM display
//
@@ -72,7 +75,7 @@
//-----------------------------------------------------------------------------
static const char
-rcsid[] = "$Id: i_system.c 230 2005-11-17 09:41:24Z fraggle $";
+rcsid[] = "$Id: i_system.c 234 2005-12-30 18:50:53Z fraggle $";
#include <stdlib.h>
@@ -137,11 +140,13 @@ byte* I_ZoneBase (int* size)
//
// I_GetTime
-// returns time in 1/70th second tics
+// returns time in 1/35th second tics
//
+
+static Uint32 basetime = 0;
+
int I_GetTime (void)
{
- static Uint32 basetime = 0;
Uint32 ticks;
ticks = SDL_GetTicks();
@@ -154,6 +159,22 @@ int I_GetTime (void)
return (ticks * 35) / 1000;
}
+//
+// Same as I_GetTime, but returns time in milliseconds
+//
+
+int I_GetTimeMS(void)
+{
+ Uint32 ticks;
+
+ ticks = SDL_GetTicks();
+
+ if (basetime == 0)
+ basetime = ticks;
+
+ return ticks - basetime;
+}
+
//
diff --git a/src/i_system.h b/src/i_system.h
index 10766d01..02a8c862 100644
--- a/src/i_system.h
+++ b/src/i_system.h
@@ -1,7 +1,7 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
-// $Id: i_system.h 97 2005-09-11 16:39:29Z fraggle $
+// $Id: i_system.h 234 2005-12-30 18:50:53Z fraggle $
//
// Copyright(C) 1993-1996 Id Software, Inc.
// Copyright(C) 2005 Simon Howard
@@ -48,6 +48,9 @@ byte* I_ZoneBase (int *size);
// returns current time in tics.
int I_GetTime (void);
+// returns current time in ms
+int I_GetTimeMS (void);
+
// Pause for a specified number of ms
void I_Sleep(int ms);
@@ -99,6 +102,9 @@ void I_Error (char *error, ...);
//-----------------------------------------------------------------------------
//
// $Log$
+// Revision 1.5 2005/12/30 18:50:53 fraggle
+// Millisecond clock function
+//
// Revision 1.4 2005/09/11 16:39:29 fraggle
// Fix declaration of I_Sleep (not I_Delay) and move to right header
//