aboutsummaryrefslogtreecommitdiff
path: root/saga
diff options
context:
space:
mode:
authorJonathan Gray2004-08-02 12:41:40 +0000
committerJonathan Gray2004-08-02 12:41:40 +0000
commite4c813670f4eb003505d72b6cc0f18f1f4bb1137 (patch)
treea0c693cfb62ecf036d7243a8663bb30a2b845914 /saga
parent910a390ae7065eb3f54e5f378eefec8f1f8746e0 (diff)
downloadscummvm-rg350-e4c813670f4eb003505d72b6cc0f18f1f4bb1137.tar.gz
scummvm-rg350-e4c813670f4eb003505d72b6cc0f18f1f4bb1137.tar.bz2
scummvm-rg350-e4c813670f4eb003505d72b6cc0f18f1f4bb1137.zip
remove timer wrapper functions
svn-id: r14437
Diffstat (limited to 'saga')
-rw-r--r--saga/module.mk1
-rw-r--r--saga/render.cpp2
-rw-r--r--saga/saga.cpp22
-rw-r--r--saga/saga.h1
-rw-r--r--saga/timer.cpp93
-rw-r--r--saga/timer.h40
6 files changed, 15 insertions, 144 deletions
diff --git a/saga/module.mk b/saga/module.mk
index 2dddc1ba44..1a3d423c3c 100644
--- a/saga/module.mk
+++ b/saga/module.mk
@@ -36,7 +36,6 @@ MODULE_OBJS = \
saga/transitions.o \
saga/ys_dl_list.o \
saga/input.o \
- saga/timer.o \
saga/music.o \
saga/sound.o
diff --git a/saga/render.cpp b/saga/render.cpp
index 31fb51ab56..c4c3b6e21a 100644
--- a/saga/render.cpp
+++ b/saga/render.cpp
@@ -25,7 +25,6 @@
#include "saga.h"
#include "gfx.h"
-#include "timer.h"
#include "actor_mod.h"
#include "console_mod.h"
#include "cvar_mod.h"
@@ -40,6 +39,7 @@
#include "objectmap_mod.h"
#include "render.h"
+#include <common/timer.h>
namespace Saga {
diff --git a/saga/saga.cpp b/saga/saga.cpp
index b6c75cfd95..425040c4b9 100644
--- a/saga/saga.cpp
+++ b/saga/saga.cpp
@@ -32,7 +32,6 @@
#include "saga.h"
-#include "timer.h"
#include "gfx.h"
#include "rscfile_mod.h"
#include "render.h"
@@ -170,10 +169,7 @@ void SagaEngine::go() {
// System initialization
- // Must initialize system timer module first
- if (SYSTIMER_InitMSCounter() != R_SUCCESS) {
- return;
- }
+ _previousTicks = _system->get_msecs();
// On some platforms, graphics initialization also initializes sound
// ( Win32 DirectX )... Music must be initialized before sound for
@@ -212,18 +208,26 @@ void SagaEngine::go() {
_anim->reg();
_actionMap->reg();
- SYSTIMER_ResetMSCounter();
+ _previousTicks = _system->get_msecs();
// Begin Main Engine Loop
SCENE_Start();
+ uint32 currentTicks;
for (;;) {
if (_render->getFlags() & RF_RENDERPAUSE) {
// Freeze time while paused
- SYSTIMER_ResetMSCounter();
+ _previousTicks = _system->get_msecs();
} else {
- msec = SYSTIMER_ReadMSCounter();
+ currentTicks = _system->get_msecs();
+ // Timer has rolled over after 49 days
+ if (currentTicks < _previousTicks)
+ msec = 0;
+ else {
+ msec = currentTicks - _previousTicks;
+ _previousTicks = currentTicks;
+ }
if (msec > R_MAX_TIME_DELTA) {
msec = R_MAX_TIME_DELTA;
}
@@ -233,7 +237,7 @@ void SagaEngine::go() {
}
// Per frame processing
_render->drawScene();
- SYSTIMER_Sleep(0);
+ _system->delay_msecs(0);
}
}
diff --git a/saga/saga.h b/saga/saga.h
index d57ea91425..a683f3c55d 100644
--- a/saga/saga.h
+++ b/saga/saga.h
@@ -102,6 +102,7 @@ private:
int decodeBGImageRLE(const byte *inbuf, size_t inbuf_len, byte *outbuf, size_t outbuf_len);
int flipImage(byte *img_buf, int columns, int scanlines);
int unbankBGImage(byte *dest_buf, const byte *src_buf, int columns, int scanlines);
+ uint32 _previousTicks;
public:
int decodeBGImage(const byte *image_data, size_t image_size,
diff --git a/saga/timer.cpp b/saga/timer.cpp
deleted file mode 100644
index eeaaf7b07f..0000000000
--- a/saga/timer.cpp
+++ /dev/null
@@ -1,93 +0,0 @@
-/* ScummVM - Scumm Interpreter
- * Copyright (C) 2004 The ScummVM project
- *
- * The ReInherit Engine is (C)2000-2003 by Daniel Balsom.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * $Header$
- *
- */
-
-#include "saga.h"
-#include "timer.h"
-
-// FIXME: replace calls to this with direct OSystem calls
-
-namespace Saga {
-
-struct R_SYSTIMER {
- int t_running;
- unsigned long t_interval;
- void *t_param;
-};
-
-struct R_SYSTIMER_DATA {
- int initialized;
- uint32 t_start_ticks;
- uint32 t_current_ticks;
- uint32 t_previous_ticks;
-};
-
-static R_SYSTIMER_DATA R_TimerData;
-
-int SYSTIMER_InitMSCounter() {
- if (R_TimerData.initialized) {
- return R_FAILURE;
- }
-
- R_TimerData.t_previous_ticks = g_system->get_msecs();
- R_TimerData.initialized = 1;
-
- return R_SUCCESS;
-}
-
-unsigned long SYSTIMER_ReadMSCounter() {
- uint32 ms_elapsed = 0;
-
- if (!R_TimerData.initialized) {
- return 0;
- }
-
- R_TimerData.t_current_ticks = g_system->get_msecs();
-
- if (R_TimerData.t_current_ticks < R_TimerData.t_previous_ticks) {
- // Timer has rolled over after 49 days
- } else {
- ms_elapsed = R_TimerData.t_current_ticks - R_TimerData.t_previous_ticks;
- R_TimerData.t_previous_ticks = R_TimerData.t_current_ticks;
- }
-
- return ms_elapsed;
-}
-
-int SYSTIMER_ResetMSCounter() {
- if (!R_TimerData.initialized) {
- return R_FAILURE;
- }
-
- R_TimerData.t_previous_ticks = g_system->get_msecs();
-
- return R_SUCCESS;
-}
-
-int SYSTIMER_Sleep(uint16 msec) {
- g_system->delay_msecs(msec);
-
- return R_SUCCESS;
-}
-
-
-} // End of namespace Saga
diff --git a/saga/timer.h b/saga/timer.h
deleted file mode 100644
index 5d927452fd..0000000000
--- a/saga/timer.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/* ScummVM - Scumm Interpreter
- * Copyright (C) 2004 The ScummVM project
- *
- * The ReInherit Engine is (C)2000-2003 by Daniel Balsom.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * $Header$
- *
- */
-#ifndef SAGA_SYSTIMER_H__
-#define SAGA_SYSTIMER_H__
-
-#include <common/timer.h>
-
-namespace Saga {
-
-struct R_SYSTIMER;
-
-int SYSTIMER_InitMSCounter();
-unsigned long SYSTIMER_ReadMSCounter();
-int SYSTIMER_ResetMSCounter();
-int SYSTIMER_Sleep(uint16 msec);
-
-
-} // End of namespace Saga
-
-#endif