aboutsummaryrefslogtreecommitdiff
path: root/backends/dc
diff options
context:
space:
mode:
authorMarcus Comstedt2003-03-02 20:17:21 +0000
committerMarcus Comstedt2003-03-02 20:17:21 +0000
commita29fb89e53741af9b09f48c87d51e048c789339e (patch)
tree2f9347af295e5d06bc42b0148bc329c29d957467 /backends/dc
parent738be5adeb369665912cf81df69669e385e7d724 (diff)
downloadscummvm-rg350-a29fb89e53741af9b09f48c87d51e048c789339e.tar.gz
scummvm-rg350-a29fb89e53741af9b09f48c87d51e048c789339e.tar.bz2
scummvm-rg350-a29fb89e53741af9b09f48c87d51e048c789339e.zip
Timer implemented.
svn-id: r6667
Diffstat (limited to 'backends/dc')
-rw-r--r--backends/dc/dc.h4
-rw-r--r--backends/dc/dcmain.cpp4
-rw-r--r--backends/dc/input.cpp6
-rw-r--r--backends/dc/time.cpp12
4 files changed, 22 insertions, 4 deletions
diff --git a/backends/dc/dc.h b/backends/dc/dc.h
index c1f3aa09e4..8291bc7c34 100644
--- a/backends/dc/dc.h
+++ b/backends/dc/dc.h
@@ -104,6 +104,10 @@ class OSystem_Dreamcast : public OSystem {
int _screen_buffer, _overlay_buffer, _mouse_buffer;
float _overlay_fade;
+ uint32 _timer_duration, _timer_next_expiry;
+ bool _timer_active;
+ int (*_timer_callback) (int);
+
unsigned char *screen;
unsigned short *mouse;
unsigned short *overlay;
diff --git a/backends/dc/dcmain.cpp b/backends/dc/dcmain.cpp
index d576701cbb..78768a79d2 100644
--- a/backends/dc/dcmain.cpp
+++ b/backends/dc/dcmain.cpp
@@ -122,10 +122,6 @@ void *OSystem_Dreamcast::create_thread(ThreadProc *proc, void *param) {
warning("Creating a thread! (not supported.)\n");
}
-void OSystem_Dreamcast::set_timer(int timer, int (*callback)(int))
-{
- warning("Setting a timer! (not supported.)\n");
-}
/* Mutex handling */
void *OSystem_Dreamcast::create_mutex(void)
diff --git a/backends/dc/input.cpp b/backends/dc/input.cpp
index c12731fe01..9505f22983 100644
--- a/backends/dc/input.cpp
+++ b/backends/dc/input.cpp
@@ -140,6 +140,12 @@ int handleInput(struct mapledev *pad, int &mouse_x, int &mouse_y,
bool OSystem_Dreamcast::poll_event(Event *event)
{
unsigned int t = Timer();
+
+ if(_timer_active && ((int)(t-_timer_next_expiry))>=0) {
+ _timer_duration = _timer_callback(_timer_duration);
+ _timer_next_expiry = t+USEC_TO_TIMER(1000*_timer_duration);
+ }
+
if(((int)(t-_devpoll))<0)
return false;
_devpoll += USEC_TO_TIMER(17000);
diff --git a/backends/dc/time.cpp b/backends/dc/time.cpp
index 9892e0c621..453b62fdc5 100644
--- a/backends/dc/time.cpp
+++ b/backends/dc/time.cpp
@@ -53,6 +53,18 @@ void OSystem_Dreamcast::delay_msecs(uint msecs)
get_msecs();
}
+void OSystem_Dreamcast::set_timer(int timer, int (*callback)(int))
+{
+ if (callback != NULL) {
+ _timer_duration = timer;
+ _timer_next_expiry = Timer() + USEC_TO_TIMER(1000*timer);
+ _timer_callback = callback;
+ _timer_active = true;
+ } else {
+ _timer_active = false;
+ }
+}
+
/*
void waitForTimer(Scumm *s, int time)