Modularization.

svn-id: r24453
This commit is contained in:
Marcus Comstedt 2006-10-22 17:58:38 +00:00
parent 43fac9ab3d
commit fbb5a2d773
3 changed files with 39 additions and 11 deletions

View file

@ -38,9 +38,23 @@ class Interactive
class OSystem_Dreamcast : public OSystem { class OSystem_Dreamcast : public OSystem {
private:
// Set function that generates samples
typedef void (*SoundProc)(void *param, byte *buf, int len);
bool setSoundCallback(SoundProc proc, void *param);
void clearSoundCallback();
// Add a callback timer
typedef int (*TimerProc)(int interval);
void setTimerCallback(TimerProc callback, int timer);
Common::SaveFileManager *createSavefileManager();
public: public:
OSystem_Dreamcast(); OSystem_Dreamcast();
virtual void initBackend();
// Determine whether the backend supports the specified feature. // Determine whether the backend supports the specified feature.
bool hasFeature(Feature f); bool hasFeature(Feature f);
@ -114,10 +128,6 @@ class OSystem_Dreamcast : public OSystem {
// Returns true if an event was retrieved. // Returns true if an event was retrieved.
bool pollEvent(Event &event); bool pollEvent(Event &event);
// Set function that generates samples
bool setSoundCallback(SoundProc proc, void *param);
void clearSoundCallback();
// Determine the output sample rate. Audio data provided by the sound // Determine the output sample rate. Audio data provided by the sound
// callback will be played using this rate. // callback will be played using this rate.
int getOutputSampleRate() const; int getOutputSampleRate() const;
@ -167,9 +177,6 @@ class OSystem_Dreamcast : public OSystem {
b = ((color<<4)&0xf0)|(color&0x0f); b = ((color<<4)&0xf0)|(color&0x0f);
} }
// Add a callback timer
void setTimerCallback(TimerProc callback, int timer);
// Mutex handling // Mutex handling
MutexRef createMutex(); MutexRef createMutex();
void lockMutex(MutexRef mutex); void lockMutex(MutexRef mutex);
@ -180,9 +187,10 @@ class OSystem_Dreamcast : public OSystem {
// given value. // given value.
void setWindowCaption(const char *caption); void setWindowCaption(const char *caption);
// Savefile handling // Modulatized backend
Common::SaveFileManager *getSavefileManager(); Common::SaveFileManager *getSavefileManager() { return _savefile; }
Audio::Mixer *getMixer() { return _mixer; }
Common::TimerManager *getTimerManager() { return _timer; }
// Extra SoftKbd support // Extra SoftKbd support
void mouseToSoftKbd(int x, int y, int &rx, int &ry) const; void mouseToSoftKbd(int x, int y, int &rx, int &ry) const;
@ -190,6 +198,9 @@ class OSystem_Dreamcast : public OSystem {
private: private:
Common::SaveFileManager *_savefile;
Audio::Mixer *_mixer;
Common::TimerManager *_timer;
SoftKeyboard _softkbd; SoftKeyboard _softkbd;
int _ms_cur_x, _ms_cur_y, _ms_cur_w, _ms_cur_h, _ms_old_x, _ms_old_y; int _ms_cur_x, _ms_cur_y, _ms_cur_w, _ms_cur_h, _ms_old_x, _ms_old_y;

View file

@ -32,6 +32,8 @@
#include <common/config-manager.h> #include <common/config-manager.h>
#include "backends/plugins/dc/dc-provider.h" #include "backends/plugins/dc/dc-provider.h"
#include "backends/timer/default/default-timer.h"
#include "sound/mixer.h"
Icon icon; Icon icon;
@ -49,6 +51,21 @@ OSystem_Dreamcast::OSystem_Dreamcast()
memset(ovl_tx, 0, sizeof(ovl_tx)); memset(ovl_tx, 0, sizeof(ovl_tx));
} }
static int timer_handler(int t) {
DefaultTimerManager *tm = (DefaultTimerManager *)g_system->getTimerManager();
tm->handler();
return t;
}
void OSystem_Dreamcast::initBackend()
{
_savefile = createSavefileManager();
_mixer = new Audio::Mixer();
_timer = new DefaultTimerManager();
setSoundCallback(Audio::Mixer::mixCallback, _mixer);
setTimerCallback(&timer_handler, 10);
}
/* CD Audio */ /* CD Audio */
static bool find_track(int track, int &first_sec, int &last_sec) static bool find_track(int track, int &first_sec, int &last_sec)

View file

@ -401,7 +401,7 @@ void VMSaveManager::listSavefiles(const char *prefix, bool *marks, int num)
tryList(prefix, marks, num, i); tryList(prefix, marks, num, i);
} }
Common::SaveFileManager *OSystem_Dreamcast::getSavefileManager() Common::SaveFileManager *OSystem_Dreamcast::createSavefileManager()
{ {
return new VMSaveManager(); return new VMSaveManager();
} }