aboutsummaryrefslogtreecommitdiff
path: root/saga
diff options
context:
space:
mode:
authorJonathan Gray2004-05-02 02:11:55 +0000
committerJonathan Gray2004-05-02 02:11:55 +0000
commit88ac74992ca66d561d8770a73bbaaaca5977817e (patch)
tree998d589bbc0084297ab76b8031b76b47cbb08c64 /saga
parent64485a9314e49a7f4da2fffe957c1910edf71642 (diff)
downloadscummvm-rg350-88ac74992ca66d561d8770a73bbaaaca5977817e.tar.gz
scummvm-rg350-88ac74992ca66d561d8770a73bbaaaca5977817e.tar.bz2
scummvm-rg350-88ac74992ca66d561d8770a73bbaaaca5977817e.zip
get rid of the last bits of SDL timer usage, SAGA should now be 100% OSystem
svn-id: r13729
Diffstat (limited to 'saga')
-rw-r--r--saga/render.cpp11
-rw-r--r--saga/render.h3
-rw-r--r--saga/timer.cpp51
-rw-r--r--saga/timer.h7
4 files changed, 8 insertions, 64 deletions
diff --git a/saga/render.cpp b/saga/render.cpp
index 86d1db2240..6cbe8bf340 100644
--- a/saga/render.cpp
+++ b/saga/render.cpp
@@ -66,7 +66,6 @@ int RENDER_Register() {
int RENDER_Init(OSystem *system) {
R_GAME_DISPLAYINFO disp_info;
- int result;
int tmp_w, tmp_h, tmp_bytepp;
// Initialize system graphics
@@ -77,10 +76,7 @@ int RENDER_Init(OSystem *system) {
}
// Initialize FPS timer callback
- result = SYSTIMER_CreateTimer(&RenderModule.r_fps_timer, 1000, NULL, RENDER_FpsTimer);
- if (result != R_SUCCESS) {
- return R_FAILURE;
- }
+ g_timer->installTimerProc(&RENDER_FpsTimer, 1000, _vm);
// Create background buffer
RenderModule.r_bg_buf_w = disp_info.logical_w;
@@ -227,10 +223,7 @@ unsigned int RENDER_ResetFrameCount() {
return framecount;
}
-void RENDER_FpsTimer(unsigned long interval, void *param) {
- YS_IGNORE_PARAM(interval);
- YS_IGNORE_PARAM(param);
-
+void RENDER_FpsTimer(void *refCon) {
RenderModule.r_fps = RenderModule.r_framecount;
RenderModule.r_framecount = 0;
diff --git a/saga/render.h b/saga/render.h
index 0e7a4d9b88..a39972518d 100644
--- a/saga/render.h
+++ b/saga/render.h
@@ -53,7 +53,6 @@ struct R_RENDER_MODULE {
int r_tmp_buf_w;
int r_tmp_buf_h;
- R_SYSTIMER *r_fps_timer;
R_SPRITELIST *r_test_sprite;
unsigned int r_fps;
@@ -62,7 +61,7 @@ struct R_RENDER_MODULE {
int r_mode;
};
-void RENDER_FpsTimer(unsigned long interval, void *param);
+void RENDER_FpsTimer(void *refCon);
} // End of namespace Saga
diff --git a/saga/timer.cpp b/saga/timer.cpp
index c5e5f41156..b46a89776b 100644
--- a/saga/timer.cpp
+++ b/saga/timer.cpp
@@ -23,18 +23,16 @@
#include "reinherit.h"
-#include <SDL.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;
- R_SYSTIMER_CALLBACK t_callback_f;
- SDL_TimerID t_sdl_timerid;
};
struct R_SYSTIMER_DATA {
@@ -46,8 +44,6 @@ struct R_SYSTIMER_DATA {
static R_SYSTIMER_DATA R_TimerData;
-static Uint32 SYSTIMER_Callback(Uint32 interval, void *param);
-
int SYSTIMER_InitMSCounter() {
if (R_TimerData.initialized) {
return R_FAILURE;
@@ -60,7 +56,7 @@ int SYSTIMER_InitMSCounter() {
}
unsigned long SYSTIMER_ReadMSCounter() {
- Uint32 ms_elapsed = 0;
+ uint32 ms_elapsed = 0;
if (!R_TimerData.initialized) {
return 0;
@@ -94,46 +90,5 @@ int SYSTIMER_Sleep(uint16 msec) {
return R_SUCCESS;
}
-int SYSTIMER_CreateTimer(R_SYSTIMER **timer, unsigned long interval, void *param, R_SYSTIMER_CALLBACK callback) {
- R_SYSTIMER *new_timer = (R_SYSTIMER *)malloc(sizeof *new_timer);
- if (new_timer == NULL) {
- return R_MEM;
- }
-
- new_timer->t_interval = interval;
- new_timer->t_param = param;
- new_timer->t_callback_f = callback;
-
- *timer = new_timer;
-
- new_timer->t_sdl_timerid = SDL_AddTimer(interval, SYSTIMER_Callback, new_timer);
-
- if (new_timer->t_sdl_timerid == NULL) {
- free(new_timer);
- *timer = NULL;
- return R_FAILURE;
- }
-
- return R_SUCCESS;
-}
-
-int SYSTIMER_DestroyTimer(R_SYSTIMER *timer) {
- if (timer == NULL) {
- return R_FAILURE;
- }
-
- timer->t_running = 0;
- SDL_RemoveTimer(timer->t_sdl_timerid);
- free(timer);
-
- return R_SUCCESS;
-}
-
-Uint32 SYSTIMER_Callback(Uint32 interval, void *param) {
- R_SYSTIMER *timer_p = (R_SYSTIMER *)param;
- timer_p->t_callback_f(timer_p->t_interval, timer_p->t_param);
-
- return timer_p->t_interval;
-}
} // End of namespace Saga
diff --git a/saga/timer.h b/saga/timer.h
index 5861ba7463..5d927452fd 100644
--- a/saga/timer.h
+++ b/saga/timer.h
@@ -23,9 +23,9 @@
#ifndef SAGA_SYSTIMER_H__
#define SAGA_SYSTIMER_H__
-namespace Saga {
+#include <common/timer.h>
-typedef void (*R_SYSTIMER_CALLBACK) (unsigned long, void *);
+namespace Saga {
struct R_SYSTIMER;
@@ -33,9 +33,6 @@ int SYSTIMER_InitMSCounter();
unsigned long SYSTIMER_ReadMSCounter();
int SYSTIMER_ResetMSCounter();
int SYSTIMER_Sleep(uint16 msec);
-int SYSTIMER_CreateTimer(R_SYSTIMER **,
-unsigned long, void *, R_SYSTIMER_CALLBACK);
-int SYSTIMER_DestroyTimer(R_SYSTIMER *);
} // End of namespace Saga