New modular backend implementation
svn-id: r24559
This commit is contained in:
parent
9d7920e017
commit
0d62e964ec
5 changed files with 77 additions and 11 deletions
|
@ -26,6 +26,10 @@
|
|||
#include "common/config-file.h"
|
||||
#include "common/config-manager.h"
|
||||
|
||||
#include "backends/saves/default/default-saves.h"
|
||||
#include "backends/timer/default/default-timer.h"
|
||||
#include "sound/mixer.h"
|
||||
|
||||
OSystem_PalmBase::OSystem_PalmBase() {
|
||||
_overlayVisible = false;
|
||||
|
||||
|
@ -57,6 +61,10 @@ OSystem_PalmBase::OSystem_PalmBase() {
|
|||
_batCheckTicks = SysTicksPerSecond() * 15;
|
||||
_batCheckLast = TimGetTicks();
|
||||
|
||||
_saveMgr = 0;
|
||||
_timerMgr = 0;
|
||||
_mixerMgr = 0;
|
||||
|
||||
_mouseDataP = NULL;
|
||||
_mouseVisible = false;
|
||||
_mouseDrawn = false;
|
||||
|
@ -70,6 +78,12 @@ OSystem_PalmBase::OSystem_PalmBase() {
|
|||
_keyMouseDelay = (gVars->arrowKeys) ? computeMsecs(125) : computeMsecs(25);
|
||||
}
|
||||
|
||||
static int timer_handler(int t) {
|
||||
DefaultTimerManager *tm = (DefaultTimerManager *)g_system->getTimerManager();
|
||||
tm->handler();
|
||||
return t;
|
||||
}
|
||||
|
||||
void OSystem_PalmBase::initBackend() {
|
||||
if (gVars->autoSave != -1)
|
||||
ConfMan.setInt("autosave_period", gVars->autoSave);
|
||||
|
@ -84,6 +98,26 @@ void OSystem_PalmBase::initBackend() {
|
|||
int_initBackend();
|
||||
_keyMouseMask = (_keyMouse.bitUp | _keyMouse.bitDown | _keyMouse.bitLeft | _keyMouse.bitRight | _keyMouse.bitButLeft);
|
||||
|
||||
// Create the savefile manager, if none exists yet (we check for this to
|
||||
// allow subclasses to provide their own).
|
||||
if (_saveMgr == 0) {
|
||||
_saveMgr = new DefaultSaveFileManager();
|
||||
}
|
||||
|
||||
// Create and hook up the mixer, if none exists yet (we check for this to
|
||||
// allow subclasses to provide their own).
|
||||
if (_mixerMgr == 0) {
|
||||
_mixerMgr = new Audio::Mixer();
|
||||
setSoundCallback(Audio::Mixer::mixCallback, _mixerMgr);
|
||||
}
|
||||
|
||||
// Create and hook up the timer manager, if none exists yet (we check for
|
||||
// this to allow subclasses to provide their own).
|
||||
if (_timerMgr == 0) {
|
||||
_timerMgr = new DefaultTimerManager();
|
||||
setTimerCallback(::timer_handler, 10);
|
||||
}
|
||||
|
||||
OSystem::initBackend();
|
||||
}
|
||||
|
||||
|
@ -113,5 +147,22 @@ void OSystem_PalmBase::quit() {
|
|||
int_quit();
|
||||
clearSoundCallback();
|
||||
unload_gfx_mode();
|
||||
|
||||
delete _saveMgr;
|
||||
delete _timerMgr;
|
||||
delete _mixerMgr;
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
||||
Common::SaveFileManager *OSystem_PalmBase::getSavefileManager() {
|
||||
return _saveMgr;
|
||||
}
|
||||
|
||||
Audio::Mixer * OSystem_PalmBase::getMixer() {
|
||||
return _mixerMgr;
|
||||
}
|
||||
|
||||
Common::TimerManager * OSystem_PalmBase::getTimerManager() {
|
||||
return _timerMgr;
|
||||
}
|
||||
|
|
|
@ -29,6 +29,15 @@
|
|||
#include "common/scummsys.h"
|
||||
#include "common/system.h"
|
||||
|
||||
namespace Audio {
|
||||
class Mixer;
|
||||
}
|
||||
|
||||
namespace Common {
|
||||
class SaveFileManager;
|
||||
class TimerManager;
|
||||
}
|
||||
|
||||
enum {
|
||||
GFX_NORMAL = 0,
|
||||
GFX_WIDE,
|
||||
|
@ -51,10 +60,14 @@ enum {
|
|||
|
||||
#define computeMsecs(x) ((SysTicksPerSecond() * x) / 1000)
|
||||
|
||||
|
||||
typedef void (*SoundProc)(void *param, byte *buf, int len);
|
||||
typedef int (*TimerProc)(int interval);
|
||||
|
||||
typedef struct {
|
||||
UInt32 duration, nextExpiry;
|
||||
Boolean active;
|
||||
OSystem::TimerProc callback;
|
||||
TimerProc callback;
|
||||
} TimerType, *TimerPtr;
|
||||
|
||||
typedef struct {
|
||||
|
@ -88,7 +101,10 @@ private:
|
|||
void battery_handler();
|
||||
virtual void get_coordinates(EventPtr ev, Coord &x, Coord &y) = 0;
|
||||
void simulate_mouse(Event &event, Int8 iHoriz, Int8 iVert, Coord *xr, Coord *yr);
|
||||
|
||||
virtual void sound_handler() = 0;
|
||||
virtual bool setSoundCallback(SoundProc proc, void *param) = 0;
|
||||
virtual void clearSoundCallback() = 0;
|
||||
|
||||
protected:
|
||||
virtual void draw_osd(UInt16 id, Int32 x, Int32 y, Boolean show, UInt8 color = 0);
|
||||
|
@ -112,6 +128,10 @@ protected:
|
|||
TimerType _timer;
|
||||
SoundType _sound;
|
||||
|
||||
Common::SaveFileManager *_saveMgr;
|
||||
Audio::Mixer *_mixerMgr;
|
||||
Common::TimerManager *_timerMgr;
|
||||
|
||||
RGBColorType _currentPalette[256];
|
||||
uint _paletteDirtyStart, _paletteDirtyEnd;
|
||||
|
||||
|
@ -233,14 +253,14 @@ public:
|
|||
virtual void unlockMutex(MutexRef mutex) {}
|
||||
virtual void deleteMutex(MutexRef mutex) {}
|
||||
|
||||
virtual bool setSoundCallback(SoundProc proc, void *param) = 0;
|
||||
virtual void clearSoundCallback() = 0;
|
||||
int getOutputSampleRate() const { return _samplesPerSec; }
|
||||
virtual Audio::Mixer *getMixer();
|
||||
|
||||
void quit();
|
||||
virtual void setWindowCaption(const char *caption) = 0;
|
||||
|
||||
Common::SaveFileManager *getSavefileManager();
|
||||
Common::TimerManager *getTimerManager();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -132,6 +132,8 @@ private:
|
|||
|
||||
virtual SndStreamVariableBufferCallback sound_callback();
|
||||
virtual void sound_handler();
|
||||
virtual bool setSoundCallback(SoundProc proc, void *param);
|
||||
void clearSoundCallback();
|
||||
|
||||
protected:
|
||||
UInt16 _sysOldCoord, _sysOldOrientation;
|
||||
|
@ -158,9 +160,6 @@ public:
|
|||
virtual OverlayColor RGBToColor(uint8 r, uint8 g, uint8 b);
|
||||
virtual void colorToRGB(OverlayColor color, uint8 &r, uint8 &g, uint8 &b);
|
||||
|
||||
virtual bool setSoundCallback(SoundProc proc, void *param);
|
||||
void clearSoundCallback();
|
||||
|
||||
void setWindowCaption(const char *caption);
|
||||
|
||||
};
|
||||
|
|
|
@ -157,7 +157,3 @@ Common::SaveFile *PalmSaveFileManager::makeSaveFile(const char *filename, bool s
|
|||
}
|
||||
return sf;
|
||||
}
|
||||
|
||||
Common::SaveFileManager *OSystem_PalmBase::getSavefileManager() {
|
||||
return new PalmSaveFileManager();
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
static SYSTEM_CALLBACK Err sndCallbackEx(void* UserDataP, SndStreamRef stream, void* bufferP, UInt32 *bufferSizeP) {
|
||||
CALLBACK_PROLOGUE
|
||||
SoundType *_sound = ((SoundExType *)UserDataP)->sound;
|
||||
((OSystem::SoundProc)_sound->proc)(_sound->param, (byte *)bufferP, *bufferSizeP);
|
||||
((SoundProc)_sound->proc)(_sound->param, (byte *)bufferP, *bufferSizeP);
|
||||
CALLBACK_EPILOGUE
|
||||
return errNone;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue