DC: Use OSystem's 'slots' for timer/savefile manager & fsFactory

This commit is contained in:
Max Horn 2011-06-06 23:26:09 +02:00
parent 04afdf7c7d
commit c30018ef37
4 changed files with 8 additions and 12 deletions

View file

@ -185,24 +185,19 @@ public:
void setWindowCaption(const char *caption); void setWindowCaption(const char *caption);
// Modulatized backend // Modulatized backend
Common::SaveFileManager *getSavefileManager() { return _savefile; }
Audio::Mixer *getMixer() { return _mixer; } 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;
// Filesystem // Filesystem
FilesystemFactory *getFilesystemFactory() { return this; }
AbstractFSNode *makeRootFileNode() const; AbstractFSNode *makeRootFileNode() const;
AbstractFSNode *makeCurrentDirectoryFileNode() const; AbstractFSNode *makeCurrentDirectoryFileNode() const;
AbstractFSNode *makeFileNodePath(const Common::String &path) const; AbstractFSNode *makeFileNodePath(const Common::String &path) const;
private: private:
Common::SaveFileManager *_savefile;
Audio::MixerImpl *_mixer; Audio::MixerImpl *_mixer;
DefaultTimerManager *_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

@ -41,20 +41,21 @@ const char *gGameName;
OSystem_Dreamcast::OSystem_Dreamcast() OSystem_Dreamcast::OSystem_Dreamcast()
: _devpoll(0), screen(NULL), mouse(NULL), overlay(NULL), _softkbd(this), : _devpoll(0), screen(NULL), mouse(NULL), overlay(NULL), _softkbd(this),
_ms_buf(NULL), _timer(NULL), _mixer(NULL), _savefile(NULL), _ms_buf(NULL), _mixer(NULL),
_current_shake_pos(0), _aspect_stretch(false), _softkbd_on(false), _current_shake_pos(0), _aspect_stretch(false), _softkbd_on(false),
_softkbd_motion(0), _enable_cursor_palette(false), _screenFormat(0) _softkbd_motion(0), _enable_cursor_palette(false), _screenFormat(0)
{ {
memset(screen_tx, 0, sizeof(screen_tx)); memset(screen_tx, 0, sizeof(screen_tx));
memset(mouse_tx, 0, sizeof(mouse_tx)); memset(mouse_tx, 0, sizeof(mouse_tx));
memset(ovl_tx, 0, sizeof(ovl_tx)); memset(ovl_tx, 0, sizeof(ovl_tx));
_fsFactory = this;
} }
void OSystem_Dreamcast::initBackend() void OSystem_Dreamcast::initBackend()
{ {
ConfMan.setInt("autosave_period", 0); ConfMan.setInt("autosave_period", 0);
_savefile = createSavefileManager(); _savefileManager = createSavefileManager();
_timer = new DefaultTimerManager(); _timerManager = new DefaultTimerManager();
uint sampleRate = initSound(); uint sampleRate = initSound();
_mixer = new Audio::MixerImpl(this, sampleRate); _mixer = new Audio::MixerImpl(this, sampleRate);

View file

@ -192,8 +192,8 @@ bool OSystem_Dreamcast::pollEvent(Common::Event &event)
{ {
unsigned int t = Timer(); unsigned int t = Timer();
if (_timer != NULL) if (_timerManager != NULL)
_timer->handler(); ((DefaultTimerManager *)_timerManager)->handler();
if (((int)(t-_devpoll))<0) if (((int)(t-_devpoll))<0)
return false; return false;

View file

@ -48,8 +48,8 @@ void OSystem_Dreamcast::delayMillis(uint msecs)
unsigned int t, start = Timer(); unsigned int t, start = Timer();
int time = (((unsigned int)msecs)*3125U)>>6; int time = (((unsigned int)msecs)*3125U)>>6;
while (((int)((t = Timer())-start))<time) { while (((int)((t = Timer())-start))<time) {
if (_timer != NULL) if (_timerManager != NULL)
_timer->handler(); ((DefaultTimerManager *)_timerManager)->handler();
checkSound(); checkSound();
} }
getMillis(); getMillis();