[Scummvm-cvs-logs] SF.net SVN: scummvm: [24559] scummvm/trunk/backends/platform/PalmOS/Src

chrilith at users.sourceforge.net chrilith at users.sourceforge.net
Sat Oct 28 16:30:54 CEST 2006


Revision: 24559
          http://svn.sourceforge.net/scummvm/?rev=24559&view=rev
Author:   chrilith
Date:     2006-10-28 07:30:42 -0700 (Sat, 28 Oct 2006)

Log Message:
-----------
New modular backend implementation

Modified Paths:
--------------
    scummvm/trunk/backends/platform/PalmOS/Src/be_base.cpp
    scummvm/trunk/backends/platform/PalmOS/Src/be_base.h
    scummvm/trunk/backends/platform/PalmOS/Src/be_os5.h
    scummvm/trunk/backends/platform/PalmOS/Src/be_save.cpp
    scummvm/trunk/backends/platform/PalmOS/Src/os5ex_sound.cpp

Modified: scummvm/trunk/backends/platform/PalmOS/Src/be_base.cpp
===================================================================
--- scummvm/trunk/backends/platform/PalmOS/Src/be_base.cpp	2006-10-28 14:11:27 UTC (rev 24558)
+++ scummvm/trunk/backends/platform/PalmOS/Src/be_base.cpp	2006-10-28 14:30:42 UTC (rev 24559)
@@ -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 @@
 	_batCheckTicks = SysTicksPerSecond() * 15;
 	_batCheckLast = TimGetTicks();
 	
+	_saveMgr = 0;
+	_timerMgr = 0;
+	_mixerMgr = 0;
+	
 	_mouseDataP = NULL;
 	_mouseVisible = false;
 	_mouseDrawn = false;
@@ -70,6 +78,12 @@
 	_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 @@
 	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 @@
 	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;
+}

Modified: scummvm/trunk/backends/platform/PalmOS/Src/be_base.h
===================================================================
--- scummvm/trunk/backends/platform/PalmOS/Src/be_base.h	2006-10-28 14:11:27 UTC (rev 24558)
+++ scummvm/trunk/backends/platform/PalmOS/Src/be_base.h	2006-10-28 14:30:42 UTC (rev 24559)
@@ -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 @@
 
 #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 @@
 	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 @@
 	TimerType _timer;
 	SoundType _sound;
 
+	Common::SaveFileManager *_saveMgr;
+	Audio::Mixer *_mixerMgr;
+	Common::TimerManager *_timerMgr;
+
 	RGBColorType _currentPalette[256];
 	uint _paletteDirtyStart, _paletteDirtyEnd;
 	
@@ -233,14 +253,14 @@
 	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

Modified: scummvm/trunk/backends/platform/PalmOS/Src/be_os5.h
===================================================================
--- scummvm/trunk/backends/platform/PalmOS/Src/be_os5.h	2006-10-28 14:11:27 UTC (rev 24558)
+++ scummvm/trunk/backends/platform/PalmOS/Src/be_os5.h	2006-10-28 14:30:42 UTC (rev 24559)
@@ -132,6 +132,8 @@
 
 	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 @@
 	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);
 
 };

Modified: scummvm/trunk/backends/platform/PalmOS/Src/be_save.cpp
===================================================================
--- scummvm/trunk/backends/platform/PalmOS/Src/be_save.cpp	2006-10-28 14:11:27 UTC (rev 24558)
+++ scummvm/trunk/backends/platform/PalmOS/Src/be_save.cpp	2006-10-28 14:30:42 UTC (rev 24559)
@@ -157,7 +157,3 @@
 	}
 	return sf;
 }
-
-Common::SaveFileManager *OSystem_PalmBase::getSavefileManager() {
-	return new PalmSaveFileManager();
-}

Modified: scummvm/trunk/backends/platform/PalmOS/Src/os5ex_sound.cpp
===================================================================
--- scummvm/trunk/backends/platform/PalmOS/Src/os5ex_sound.cpp	2006-10-28 14:11:27 UTC (rev 24558)
+++ scummvm/trunk/backends/platform/PalmOS/Src/os5ex_sound.cpp	2006-10-28 14:30:42 UTC (rev 24559)
@@ -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;
 }


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list