aboutsummaryrefslogtreecommitdiff
path: root/backends
diff options
context:
space:
mode:
authorCameron Cawley2019-11-27 22:29:38 +0000
committerFilippos Karapetis2019-12-10 08:35:13 +0200
commit099ef8db300fc776539694c766dcb58a4a948952 (patch)
treee48def42571181f7488bb539da3dfd5e312e2b12 /backends
parent9dcfe2c09ece2248986af4547e878a07d8ba950f (diff)
downloadscummvm-rg350-099ef8db300fc776539694c766dcb58a4a948952.tar.gz
scummvm-rg350-099ef8db300fc776539694c766dcb58a4a948952.tar.bz2
scummvm-rg350-099ef8db300fc776539694c766dcb58a4a948952.zip
PSP: Make the PspTimer class a subclass of DefaultTimerManager
Diffstat (limited to 'backends')
-rw-r--r--backends/platform/psp/osys_psp.cpp18
-rw-r--r--backends/platform/psp/osys_psp.h6
-rw-r--r--backends/timer/psp/timer.cpp21
-rw-r--r--backends/timer/psp/timer.h15
4 files changed, 16 insertions, 44 deletions
diff --git a/backends/platform/psp/osys_psp.cpp b/backends/platform/psp/osys_psp.cpp
index 2febf91b04..f09e8498d2 100644
--- a/backends/platform/psp/osys_psp.cpp
+++ b/backends/platform/psp/osys_psp.cpp
@@ -39,7 +39,7 @@
#include "backends/platform/psp/rtc.h"
#include "backends/saves/default/default-saves.h"
-#include "backends/timer/default/default-timer.h"
+#include "backends/timer/psp/timer.h"
#include "graphics/surface.h"
#include "audio/mixer_intern.h"
@@ -50,12 +50,6 @@
#define SAMPLES_PER_SEC 44100
-static int timer_handler(int t) {
- DefaultTimerManager *tm = (DefaultTimerManager *)g_system->getTimerManager();
- tm->handler();
- return t;
-}
-
OSystem_PSP::~OSystem_PSP() {}
#define PSP_SCREEN_WIDTH 480
@@ -97,13 +91,11 @@ void OSystem_PSP::initBackend() {
_savefileManager = new DefaultSaveFileManager(PSP_DEFAULT_SAVE_PATH);
- _timerManager = new DefaultTimerManager();
+ _timerManager = new PspTimerManager();
PSP_DEBUG_PRINT("calling keyboard.load()\n");
_keyboard.load(); // Load virtual keyboard files into memory
- setTimerCallback(&timer_handler, 10);
-
setupMixer();
EventsBaseBackend::initBackend();
@@ -358,12 +350,6 @@ void OSystem_PSP::delayMillis(uint msecs) {
PspThread::delayMillis(msecs);
}
-void OSystem_PSP::setTimerCallback(TimerProc callback, int interval) {
- _pspTimer.setCallback((PspTimer::CallbackFunc)callback);
- _pspTimer.setIntervalMs(interval);
- _pspTimer.start();
-}
-
OSystem::MutexRef OSystem_PSP::createMutex(void) {
return (MutexRef) new PspMutex(true); // start with a full mutex
}
diff --git a/backends/platform/psp/osys_psp.h b/backends/platform/psp/osys_psp.h
index ff9dd101d2..80f68329d8 100644
--- a/backends/platform/psp/osys_psp.h
+++ b/backends/platform/psp/osys_psp.h
@@ -39,7 +39,6 @@
#include "backends/platform/psp/display_manager.h"
#include "backends/platform/psp/input.h"
#include "backends/platform/psp/audio.h"
-#include "backends/timer/psp/timer.h"
#include "backends/platform/psp/thread.h"
class OSystem_PSP : public EventsBaseBackend, public PaletteManager {
@@ -57,7 +56,6 @@ private:
PSPKeyboard _keyboard;
InputHandler _inputHandler;
PspAudio _audio;
- PspTimer _pspTimer;
ImageViewer _imageViewer;
public:
@@ -127,10 +125,6 @@ public:
uint32 getMillis(bool skipRecord = false);
void delayMillis(uint msecs);
- // Timer
- typedef int (*TimerProc)(int interval);
- void setTimerCallback(TimerProc callback, int interval);
-
// Mutex
MutexRef createMutex(void);
void lockMutex(MutexRef mutex);
diff --git a/backends/timer/psp/timer.cpp b/backends/timer/psp/timer.cpp
index 278f50581c..b1479baecf 100644
--- a/backends/timer/psp/timer.cpp
+++ b/backends/timer/psp/timer.cpp
@@ -49,47 +49,42 @@
#include "backends/platform/psp/trace.h"
-bool PspTimer::start() {
+PspTimerManager::PspTimerManager(uint32 interval) : _interval(interval * 1000), _threadId(-1), _init(false) {
DEBUG_ENTER_FUNC();
- if (!_interval || !_callback)
- return false;
-
_threadId = sceKernelCreateThread("timerThread", thread, PRIORITY_TIMER_THREAD, STACK_TIMER_THREAD, THREAD_ATTR_USER, 0);
if (_threadId < 0) { // error
PSP_ERROR("failed to create timer thread. Error code %d\n", _threadId);
- return false;
+ return;
}
- PspTimer *_this = this; // trick to get into context when the thread starts
+ PspTimerManager *_this = this; // trick to get into context when the thread starts
_init = true;
if (sceKernelStartThread(_threadId, sizeof(uint32 *), &_this) < 0) {
PSP_ERROR("failed to start thread %d\n", _threadId);
- return false;
+ return;
}
PSP_DEBUG_PRINT("created timer thread[%x]\n", _threadId);
-
- return true;
}
-int PspTimer::thread(SceSize, void *__this) {
+int PspTimerManager::thread(SceSize, void *__this) {
DEBUG_ENTER_FUNC();
- PspTimer *_this = *(PspTimer **)__this; // get our this for the context
+ PspTimerManager *_this = *(PspTimerManager **)__this; // get our this for the context
_this->timerThread();
return 0;
};
-void PspTimer::timerThread() {
+void PspTimerManager::timerThread() {
DEBUG_ENTER_FUNC();
while (_init) {
sceKernelDelayThread(_interval);
PSP_DEBUG_PRINT("calling callback!\n");
- _callback();
+ handler();
}
};
diff --git a/backends/timer/psp/timer.h b/backends/timer/psp/timer.h
index 45b32e0e14..a7871009c4 100644
--- a/backends/timer/psp/timer.h
+++ b/backends/timer/psp/timer.h
@@ -23,19 +23,16 @@
#ifndef PSP_TIMER_H
#define PSP_TIMER_H
-class PspTimer {
+#include "backends/timer/default/default-timer.h"
+
+class PspTimerManager : public DefaultTimerManager {
public:
- typedef void (* CallbackFunc)(void);
- PspTimer() : _callback(0), _interval(0), _threadId(-1), _init(false) {}
- void stop() { _init = false; }
- bool start();
- ~PspTimer() { stop(); }
- void setCallback(CallbackFunc cb) { _callback = cb; }
- void setIntervalMs(uint32 interval) { _interval = interval * 1000; }
+ PspTimerManager(uint32 interval = 10);
+ ~PspTimerManager() { _init = false; }
+
static int thread(SceSize, void *__this); // static thread to use as bridge
void timerThread();
private:
- CallbackFunc _callback; // pointer to timer callback
uint32 _interval;
int _threadId;
bool _init;