aboutsummaryrefslogtreecommitdiff
path: root/backends
diff options
context:
space:
mode:
authorAlejandro Marzini2010-06-26 23:05:37 +0000
committerAlejandro Marzini2010-06-26 23:05:37 +0000
commit62ac3982aa5ba81a29ff4bf5b1ac1e3d2647eb9b (patch)
treecea9f5a28bede5139193fe7738cfe173b4051e80 /backends
parent32b5f5e4ae80a498cf09577765ac7bde6686a079 (diff)
downloadscummvm-rg350-62ac3982aa5ba81a29ff4bf5b1ac1e3d2647eb9b.tar.gz
scummvm-rg350-62ac3982aa5ba81a29ff4bf5b1ac1e3d2647eb9b.tar.bz2
scummvm-rg350-62ac3982aa5ba81a29ff4bf5b1ac1e3d2647eb9b.zip
Modularized Symbian port.
svn-id: r50356
Diffstat (limited to 'backends')
-rw-r--r--backends/events/symbiansdl/symbiansdl-events.cpp204
-rw-r--r--backends/events/symbiansdl/symbiansdl-events.h57
-rw-r--r--backends/graphics/symbiansdl/symbiansdl-graphics.cpp83
-rw-r--r--backends/graphics/symbiansdl/symbiansdl-graphics.h45
-rw-r--r--backends/mixer/symbiansdl/symbiansdl-mixer.cpp102
-rw-r--r--backends/mixer/symbiansdl/symbiansdl-mixer.h46
-rw-r--r--backends/module.mk3
-rw-r--r--backends/platform/symbian/src/SymbianOS.cpp461
-rw-r--r--backends/platform/symbian/src/SymbianOS.h92
-rw-r--r--backends/platform/symbian/src/main.cpp99
10 files changed, 695 insertions, 497 deletions
diff --git a/backends/events/symbiansdl/symbiansdl-events.cpp b/backends/events/symbiansdl/symbiansdl-events.cpp
new file mode 100644
index 0000000000..3c8648fe8c
--- /dev/null
+++ b/backends/events/symbiansdl/symbiansdl-events.cpp
@@ -0,0 +1,204 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifdef __SYMBIAN32__
+
+#include "backends/events/symbiansdl/symbiansdl-events.h"
+#include "backends/platform/symbian/src/SymbianActions.h"
+#include "gui/message.h"
+
+#include <bautils.h>
+
+SymbianSdlEventManager::zoneDesc SymbianSdlEventManager::_zones[TOTAL_ZONES] = {
+ { 0, 0, 320, 145 },
+ { 0, 145, 150, 55 },
+ { 150, 145, 170, 55 }
+};
+
+SymbianSdlEventManager::SymbianSdlEventManager(Common::EventSource *boss)
+ :
+ _currentZone(0),
+ SdlEventManager(boss) {
+ for (int i = 0; i < TOTAL_ZONES; i++) {
+ _mouseXZone[i] = (_zones[i].x + (_zones[i].width / 2));
+ _mouseYZone[i] = (_zones[i].y + (_zones[i].height / 2));
+ }
+}
+
+SymbianSdlEventManager::~SymbianSdlEventManager() {
+
+}
+
+bool SymbianSdlEventManager::remapKey(SDL_Event &ev, Common::Event &event) {
+ if (GUI::Actions::Instance()->mappingActive() || ev.key.keysym.sym <= SDLK_UNKNOWN)
+ return false;
+
+ for (TInt loop = 0; loop < GUI::ACTION_LAST; loop++) {
+ if (GUI::Actions::Instance()->getMapping(loop) == (uint)ev.key.keysym.sym &&
+ GUI::Actions::Instance()->isEnabled(loop)) {
+ // Create proper event instead
+ switch (loop) {
+ case GUI::ACTION_UP:
+ if (ev.type == SDL_KEYDOWN) {
+ _km.y_vel = -1;
+ _km.y_down_count = 1;
+ } else {
+ _km.y_vel = 0;
+ _km.y_down_count = 0;
+ }
+ event.type = Common::EVENT_MOUSEMOVE;
+ fillMouseEvent(event, _km.x, _km.y);
+
+ return true;
+
+ case GUI::ACTION_DOWN:
+ if (ev.type == SDL_KEYDOWN) {
+ _km.y_vel = 1;
+ _km.y_down_count = 1;
+ } else {
+ _km.y_vel = 0;
+ _km.y_down_count = 0;
+ }
+ event.type = Common::EVENT_MOUSEMOVE;
+ fillMouseEvent(event, _km.x, _km.y);
+
+ return true;
+
+ case GUI::ACTION_LEFT:
+ if (ev.type == SDL_KEYDOWN) {
+ _km.x_vel = -1;
+ _km.x_down_count = 1;
+ } else {
+ _km.x_vel = 0;
+ _km.x_down_count = 0;
+ }
+ event.type = Common::EVENT_MOUSEMOVE;
+ fillMouseEvent(event, _km.x, _km.y);
+
+ return true;
+
+ case GUI::ACTION_RIGHT:
+ if (ev.type == SDL_KEYDOWN) {
+ _km.x_vel = 1;
+ _km.x_down_count = 1;
+ } else {
+ _km.x_vel = 0;
+ _km.x_down_count = 0;
+ }
+ event.type = Common::EVENT_MOUSEMOVE;
+ fillMouseEvent(event, _km.x, _km.y);
+
+ return true;
+
+ case GUI::ACTION_LEFTCLICK:
+ event.type = (ev.type == SDL_KEYDOWN ? Common::EVENT_LBUTTONDOWN : Common::EVENT_LBUTTONUP);
+ fillMouseEvent(event, _km.x, _km.y);
+
+ return true;
+
+ case GUI::ACTION_RIGHTCLICK:
+ event.type = (ev.type == SDL_KEYDOWN ? Common::EVENT_RBUTTONDOWN : Common::EVENT_RBUTTONUP);
+ fillMouseEvent(event, _km.x, _km.y);
+
+ return true;
+
+ case GUI::ACTION_ZONE:
+ if (ev.type == SDL_KEYDOWN) {
+ for (int i = 0; i < TOTAL_ZONES; i++)
+ if (_km.x >= _zones[i].x && _km.y >= _zones[i].y &&
+ _km.x <= _zones[i].x + _zones[i].width && _km.y <= _zones[i].y + _zones[i].height
+ ) {
+ _mouseXZone[i] = _km.x;
+ _mouseYZone[i] = _km.y;
+ break;
+ }
+ _currentZone++;
+ if (_currentZone >= TOTAL_ZONES)
+ _currentZone = 0;
+ event.type = Common::EVENT_MOUSEMOVE;
+ fillMouseEvent(event, _mouseXZone[_currentZone], _mouseYZone[_currentZone]);
+ SDL_WarpMouse(event.mouse.x, event.mouse.y);
+ }
+
+ return true;
+ case GUI::ACTION_MULTI: {
+ GUI::Key &key = GUI::Actions::Instance()->getKeyAction(loop);
+ // if key code is pause, then change event to interactive or just fall through
+ if (key.keycode() == SDLK_PAUSE) {
+ event.type = Common::EVENT_PREDICTIVE_DIALOG;
+ return true;
+ }
+ }
+ case GUI::ACTION_SAVE:
+ case GUI::ACTION_SKIP:
+ case GUI::ACTION_SKIP_TEXT:
+ case GUI::ACTION_PAUSE:
+ case GUI::ACTION_SWAPCHAR:
+ case GUI::ACTION_FASTMODE:
+ case GUI::ACTION_DEBUGGER:
+ case GUI::ACTION_MAINMENU:
+ case GUI::ACTION_VKB:
+ case GUI::ACTION_KEYMAPPER:{
+ GUI::Key &key = GUI::Actions::Instance()->getKeyAction(loop);
+ ev.key.keysym.sym = (SDLKey) key.keycode();
+ ev.key.keysym.scancode = 0;
+ ev.key.keysym.mod = (SDLMod) key.flags();
+
+ // Translate from SDL keymod event to Scummvm Key Mod Common::Event.
+ // This codes is also present in GP32 backend and in SDL backend as a static function
+ // Perhaps it should be shared.
+ if (key.flags() != 0) {
+ event.kbd.flags = 0;
+
+ if (ev.key.keysym.mod & KMOD_SHIFT)
+ event.kbd.flags |= Common::KBD_SHIFT;
+
+ if (ev.key.keysym.mod & KMOD_ALT)
+ event.kbd.flags |= Common::KBD_ALT;
+
+ if (ev.key.keysym.mod & KMOD_CTRL)
+ event.kbd.flags |= Common::KBD_CTRL;
+ }
+
+ return false;
+ }
+
+ case GUI::ACTION_QUIT:
+ {
+ GUI::MessageDialog alert("Do you want to quit ?", "Yes", "No");
+ if (alert.runModal() == GUI::kMessageOK)
+ g_system->quit();
+
+ return true;
+ }
+ }
+ }
+ }
+
+ return false;
+}
+
+#endif
+
diff --git a/backends/events/symbiansdl/symbiansdl-events.h b/backends/events/symbiansdl/symbiansdl-events.h
new file mode 100644
index 0000000000..cf94ce09e1
--- /dev/null
+++ b/backends/events/symbiansdl/symbiansdl-events.h
@@ -0,0 +1,57 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#if !defined(BACKEND_EVENTS_SYMBIAN_SDL_H) && !defined(DISABLE_DEFAULT_EVENTMANAGER)
+#define BACKEND_EVENTS_SYMBIAN_SDL_H
+
+#include "backends/events/sdl/sdl-events.h"
+
+#define TOTAL_ZONES 3
+
+class SymbianSdlEventManager : public SdlEventManager {
+public:
+ SymbianSdlEventManager(Common::EventSource *boss);
+ ~SymbianSdlEventManager();
+
+ bool remapKey(SDL_Event &ev, Common::Event &event);
+
+protected:
+ // Used to handle joystick navi zones
+ int _mouseXZone[TOTAL_ZONES];
+ int _mouseYZone[TOTAL_ZONES];
+ int _currentZone;
+
+ struct zoneDesc {
+ int x;
+ int y;
+ int width;
+ int height;
+ };
+
+ static zoneDesc _zones[TOTAL_ZONES];
+};
+
+#endif
+
diff --git a/backends/graphics/symbiansdl/symbiansdl-graphics.cpp b/backends/graphics/symbiansdl/symbiansdl-graphics.cpp
new file mode 100644
index 0000000000..9dc691f38b
--- /dev/null
+++ b/backends/graphics/symbiansdl/symbiansdl-graphics.cpp
@@ -0,0 +1,83 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifdef __SYMBIAN32__
+
+#include "backends/graphics/symbiansdl/symbiansdl-graphics.h"
+#include "backends/platform/symbian/src/SymbianActions.h"
+
+SdlGraphicsManager::SdlGraphicsManager() {
+}
+
+SdlGraphicsManager::~SdlGraphicsManager() {
+}
+
+int SymbianSdlGraphicsManager::getDefaultGraphicsMode() const {
+ return GFX_NORMAL;
+}
+
+static const OSystem::GraphicsMode s_supportedGraphicsModes[] = {
+ {"1x", "Fullscreen", GFX_NORMAL},
+ {0, 0, 0}
+};
+
+const OSystem::GraphicsMode *SymbianSdlGraphicsManager::getSupportedGraphicsModes() const {
+ return s_supportedGraphicsModes;
+}
+
+// make sure we always go to normal, even if the string might be set wrong!
+bool SymbianSdlGraphicsManager::setGraphicsMode(int /*name*/) {
+ // let parent OSystem_SDL handle it
+ return SdlGraphicsManager::setGraphicsMode(getDefaultGraphicsMode());
+}
+
+bool SymbianSdlGraphicsManager::hasFeature(OSystem::Feature f) {
+ switch (f) {
+ case OSystem::kFeatureFullscreenMode:
+ case OSystem::kFeatureAspectRatioCorrection:
+ case OSystem::kFeatureCursorHasPalette:
+#ifdef USE_VIBRA_SE_PXXX
+ case OSystem::kFeatureVibration:
+#endif
+ return true;
+ default:
+ return false;
+ }
+}
+
+void SymbianSdlGraphicsManager::setFeatureState(OSystem::Feature f, bool enable) {
+ switch (f) {
+ case OSystem::kFeatureVirtualKeyboard:
+ break;
+ case OSystem::kFeatureDisableKeyFiltering:
+ GUI::Actions::Instance()->beginMapping(enable);
+ break;
+ default:
+ SdlGraphicsManager::setFeatureState(f, enable);
+ }
+}
+
+#endif
+
diff --git a/backends/graphics/symbiansdl/symbiansdl-graphics.h b/backends/graphics/symbiansdl/symbiansdl-graphics.h
new file mode 100644
index 0000000000..563f7f1a1c
--- /dev/null
+++ b/backends/graphics/symbiansdl/symbiansdl-graphics.h
@@ -0,0 +1,45 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef BACKENDS_GRAPHICS_SYMBIAN_SDL_H
+#define BACKENDS_GRAPHICS_SYMBIAN_SDL_H
+
+#include "backends/graphics/sdl/sdl-graphics.h"
+
+class SymbianSdlGraphicsManager : public SdlGraphicsManager {
+public:
+ SymbianSdlGraphicsManager ();
+ ~SymbianSdlGraphicsManager ();
+
+ bool hasFeature(OSystem::Feature f);
+ void setFeatureState(OSystem::Feature f, bool enable);
+
+ const OSystem::GraphicsMode *getSupportedGraphicsModes() const;
+ int getDefaultGraphicsMode() const;
+ bool setGraphicsMode(int mode);
+};
+
+#endif
+
diff --git a/backends/mixer/symbiansdl/symbiansdl-mixer.cpp b/backends/mixer/symbiansdl/symbiansdl-mixer.cpp
new file mode 100644
index 0000000000..0cbae85cb9
--- /dev/null
+++ b/backends/mixer/symbiansdl/symbiansdl-mixer.cpp
@@ -0,0 +1,102 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifdef __SYMBIAN32__
+
+#include "backends/mixer/symbiansdl/symbiansdl-mixer.h"
+#include "common/system.h"
+
+#ifdef SAMPLES_PER_SEC_8000 // the GreanSymbianMMP format cannot handle values for defines :(
+ #define SAMPLES_PER_SEC 8000
+#else
+ #define SAMPLES_PER_SEC 16000
+#endif
+
+SymbianSdlMixerManager::SymbianSdlMixerManager()
+ :
+ _stereo_mix_buffer(0) {
+
+}
+
+SymbianSdlMixerManager::~SymbianSdlMixerManager() {
+ delete[] _stereo_mix_buffer;
+}
+
+void SymbianSdlMixerManager::init() {
+ // Start SDL Audio subsystem
+ if (SDL_InitSubSystem(SDL_INIT_AUDIO) == -1) {
+ error("Could not initialize SDL: %s", SDL_GetError());
+ }
+
+ // Get the desired audio specs
+ SDL_AudioSpec desired = getAudioSpec();
+
+ // Start SDL audio with the desired specs
+ if (SDL_OpenAudio(&desired, &_obtainedRate) != 0) {
+ warning("Could not open audio device: %s", SDL_GetError());
+
+ _mixer = new Audio::MixerImpl(g_system, desired.freq);
+ assert(_mixer);
+ _mixer->setReady(false);
+ } else {
+ debug(1, "Output sample rate: %d Hz", _obtainedRate.freq);
+
+ _channels = _obtainedRate.channels;
+
+ // Need to create mixbuffer for stereo mix to downmix
+ if (_channels != 2) {
+ _stereo_mix_buffer = new byte [_obtainedRate.size * 2]; // * 2 for stereo values
+ }
+
+ _mixer = new Audio::MixerImpl(g_system, _obtainedRate.freq);
+ assert(_mixer);
+ _mixer->setReady(true);
+
+ startAudio();
+ }
+}
+
+void SymbianSdlMixerManager::callbackHandler(byte *samples, int len) {
+#if defined (S60) && !defined(S60V3)
+ // If not stereo then we need to downmix
+ if (_mixer->_channels != 2) {
+ _mixer->mixCallback(_stereo_mix_buffer, len * 2);
+
+ int16 *bitmixDst = (int16 *)samples;
+ int16 *bitmixSrc = (int16 *)_stereo_mix_buffer;
+
+ for (int loop = len / 2; loop >= 0; loop --) {
+ *bitmixDst = (*bitmixSrc + *(bitmixSrc + 1)) >> 1;
+ bitmixDst++;
+ bitmixSrc += 2;
+ }
+ } else
+#else
+ _mixer->mixCallback(samples, len);
+#endif
+}
+
+#endif
+
diff --git a/backends/mixer/symbiansdl/symbiansdl-mixer.h b/backends/mixer/symbiansdl/symbiansdl-mixer.h
new file mode 100644
index 0000000000..e809bd4cd0
--- /dev/null
+++ b/backends/mixer/symbiansdl/symbiansdl-mixer.h
@@ -0,0 +1,46 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef BACKENDS_MIXER_SYMBIAN_SDL_H
+#define BACKENDS_MIXER_SYMBIAN_SDL_H
+
+#include "backends/mixer/sdl/sdl-mixer.h"
+
+class SymbianSdlMixerManager : public SdlMixerManager {
+public:
+ SymbianSdlMixerManager();
+ ~SymbianSdlMixerManager();
+
+ void init();
+
+protected:
+ int _channels;
+ byte *_stereo_mix_buffer;
+
+ void callbackHandler(byte *samples, int len);
+};
+
+#endif
+
diff --git a/backends/module.mk b/backends/module.mk
index a739d4666d..5efb3f235a 100644
--- a/backends/module.mk
+++ b/backends/module.mk
@@ -8,6 +8,7 @@ MODULE_OBJS := \
events/default/default-events.o \
events/samsungtv/samsungtv-events.o \
events/sdl/sdl-events.o \
+ events/symbiansdl/symbiansdl-events.o \
fs/abstract-fs.o \
fs/stdiostream.o \
fs/amigaos4/amigaos4-fs-factory.o \
@@ -23,6 +24,7 @@ MODULE_OBJS := \
fs/n64/n64-fs-factory.o \
fs/n64/romfsstream.o \
graphics/sdl/sdl-graphics.o \
+ graphics/symbiansdl/symbiansdl-graphics.o \
keymapper/action.o \
keymapper/keymap.o \
keymapper/keymapper.o \
@@ -38,6 +40,7 @@ MODULE_OBJS := \
midi/windows.o \
mixer/bufferingsdl/bufferingsdl-mixer.o \
mixer/sdl/sdl-mixer.o \
+ mixer/symbiansdl/symbiansdl-mixer.o \
mutex/sdl/sdl-mutex.o \
plugins/dc/dc-provider.o \
plugins/posix/posix-provider.o \
diff --git a/backends/platform/symbian/src/SymbianOS.cpp b/backends/platform/symbian/src/SymbianOS.cpp
index 2ae47b07a8..2195b897d1 100644
--- a/backends/platform/symbian/src/SymbianOS.cpp
+++ b/backends/platform/symbian/src/SymbianOS.cpp
@@ -26,25 +26,17 @@
#include <sdlapp.h> // for CSDLApp::GetExecutablePathCStr() @ Symbian::GetExecutablePath()
#include <bautils.h>
-#include "backends/fs/symbian/symbian-fs-factory.h"
#include "backends/platform/symbian/src/SymbianOS.h"
#include "backends/platform/symbian/src/SymbianActions.h"
-#include "backends/saves/default/default-saves.h"
-
-#include "base/main.h"
-
#include "common/config-manager.h"
#include "common/scummsys.h"
-
#include "gui/message.h"
-#include "sound/mixer_intern.h"
-
-#ifdef SAMPLES_PER_SEC_8000 // the GreanSymbianMMP format cannot handle values for defines :(
- #define SAMPLES_PER_SEC 8000
-#else
- #define SAMPLES_PER_SEC 16000
-#endif
+#include "backends/fs/symbian/symbian-fs-factory.h"
+#include "backends/saves/default/default-saves.h"
+#include "backends/events/symbiansdl/symbiansdl-events.h"
+#include "backends/graphics/symbiansdl/symbiansdl-graphics.h"
+#include "backends/mixer/symbiansdl/symbiansdl-mixer.h"
#define DEFAULT_CONFIG_FILE "scummvm.ini"
#define DEFAULT_SAVE_PATH "Savegames"
@@ -57,8 +49,7 @@ void FatalError(const char *msg) {
TPtrC8 msgPtr((const TUint8 *)msg);
TBuf<512> msg16Bit;
msg16Bit.Copy(msgPtr);
-#ifdef S60
-#else
+#ifndef S60
CEikonEnv::Static()->InfoWinL(_L("ScummVM Fatal Error"), msg16Bit);
#endif
if (g_system)
@@ -66,7 +57,7 @@ void FatalError(const char *msg) {
}
// make this easily available everywhere
-char* GetExecutablePath() {
+char *GetExecutablePath() {
return CSDLApp::GetExecutablePathCStr();
}
@@ -74,66 +65,16 @@ char* GetExecutablePath() {
////////// OSystem_SDL_Symbian //////////////////////////////////////////
-static const OSystem::GraphicsMode s_supportedGraphicsModes[] = {
- {"1x", "Fullscreen", GFX_NORMAL},
- {0, 0, 0}
-};
-
-bool OSystem_SDL_Symbian::hasFeature(Feature f) {
- switch (f) {
- case kFeatureFullscreenMode:
- case kFeatureAspectRatioCorrection:
- case kFeatureCursorHasPalette:
-#ifdef USE_VIBRA_SE_PXXX
- case kFeatureVibration:
-#endif
- return true;
-
- default:
- return false;
- }
-}
-
-void OSystem_SDL_Symbian::setFeatureState(Feature f, bool enable) {
- switch (f) {
- case kFeatureVirtualKeyboard:
- if (enable) {
- }
- else {
-
- }
- break;
- case kFeatureDisableKeyFiltering:
- GUI::Actions::Instance()->beginMapping(enable);
- break;
- default:
- OSystem_SDL::setFeatureState(f, enable);
- }
+OSystem_SDL_Symbian::OSystem_SDL_Symbian()
+ :
+ _RFs(0) {
+
}
-static Common::String getDefaultConfigFileName() {
- char configFile[MAXPATHLEN];
- strcpy(configFile, Symbian::GetExecutablePath());
- strcat(configFile, DEFAULT_CONFIG_FILE);
- return configFile;
-}
-
-Common::SeekableReadStream *OSystem_SDL_Symbian::createConfigReadStream() {
- Common::FSNode file(getDefaultConfigFileName());
- return file.createReadStream();
-}
-
-Common::WriteStream *OSystem_SDL_Symbian::createConfigWriteStream() {
- Common::FSNode file(getDefaultConfigFileName());
- return file.createWriteStream();
+OSystem_SDL_Symbian::~OSystem_SDL_Symbian() {
}
-OSystem_SDL_Symbian::zoneDesc OSystem_SDL_Symbian::_zones[TOTAL_ZONES] = {
- { 0, 0, 320, 145 },
- { 0, 145, 150, 55 },
- { 150, 145, 170, 55 }
-};
-OSystem_SDL_Symbian::OSystem_SDL_Symbian() :_channels(0),_stereo_mix_buffer(0) {
+void OSystem_SDL_Symbian::init() {
_RFs = &CEikonEnv::Static()->FsSession();
_fsFactory = new SymbianFilesystemFactory();
}
@@ -146,20 +87,19 @@ void OSystem_SDL_Symbian::initBackend() {
Common::String savePath;
savePath = Symbian::GetExecutablePath();
savePath += DEFAULT_SAVE_PATH "\\";
- _savefile = new DefaultSaveFileManager(savePath);
+ _savefileManager = new DefaultSaveFileManager(savePath);
// If savepath has not already been set then set it
if (!ConfMan.hasKey("savepath")) {
ConfMan.set("savepath", savePath);
-
}
// Ensure that the current set path (might have been altered by the user) exists
Common::String currentPath = ConfMan.get("savepath");
TFileName fname;
- TPtrC8 ptr((const unsigned char*)currentPath.c_str(),currentPath.size());
+ TPtrC8 ptr((const unsigned char*)currentPath.c_str(), currentPath.size());
fname.Copy(ptr);
- BaflUtils::EnsurePathExistsL(static_cast<OSystem_SDL_Symbian*>(g_system)->FsSession(), fname);
+ BaflUtils::EnsurePathExistsL(static_cast<OSystem_SDL_Symbian *>(g_system)->FsSession(), fname);
ConfMan.setBool("FM_high_quality", false);
#if !defined(S60) || defined(S60V3) // S60 has low quality as default
@@ -167,11 +107,26 @@ void OSystem_SDL_Symbian::initBackend() {
#else
ConfMan.setBool("FM_medium_quality", false);
#endif
- ConfMan.setInt("joystick_num", 0); // Symbian OS should have joystick_num set to 0 in the ini file , but uiq devices might refuse opening the joystick
+ // Symbian OS should have joystick_num set to 0 in the ini file,
+ // but uiq devices might refuse opening the joystick
+ ConfMan.setInt("joystick_num", 0);
ConfMan.flushToDisk();
GUI::Actions::init();
+ // Creates the backend managers
+ if (_eventManager == 0)
+ _eventManager = new SymbianSdlEventManager(this);
+ if (_mixerManager == 0) {
+ _mixerManager = new SymbianSdlMixerManager();
+
+ // Setup and start mixer
+ _mixerManager->init();
+ }
+ if (_graphicsManager == 0)
+ _graphicsManager = new SymbianSdlGraphicsManager();
+
+ // Call parent implementation of this method
OSystem_SDL::initBackend();
// Initialize global key mapping for Smartphones
@@ -179,289 +134,25 @@ void OSystem_SDL_Symbian::initBackend() {
actions->initInstanceMain(this);
actions->loadMapping();
- initZones();
-}
-
-OSystem_SDL_Symbian::~OSystem_SDL_Symbian() {
- delete[] _stereo_mix_buffer;
-}
-
-int OSystem_SDL_Symbian::getDefaultGraphicsMode() const {
- return GFX_NORMAL;
-}
-
-const OSystem::GraphicsMode *OSystem_SDL_Symbian::getSupportedGraphicsModes() const {
- return s_supportedGraphicsModes;
-}
-
-// make sure we always go to normal, even if the string might be set wrong!
-bool OSystem_SDL_Symbian::setGraphicsMode(const char * /*name*/) {
- // let parent OSystem_SDL handle it
- return OSystem_SDL::setGraphicsMode(getDefaultGraphicsMode());
}
void OSystem_SDL_Symbian::quitWithErrorMsg(const char * /*aMsg*/) {
-
CEikonEnv::Static()->AlertWin(_L("quitWithErrorMsg()")) ;
if (g_system)
g_system->quit();
}
-// Overloaded from SDL_Commmon
void OSystem_SDL_Symbian::quit() {
delete GUI_Actions::Instance();
- OSystem_SDL::quit();
-}
-void OSystem_SDL_Symbian::setupMixer() {
-
- SDL_AudioSpec desired;
- SDL_AudioSpec obtained;
-
- // Determine the desired output sampling frequency.
- uint32 samplesPerSec = 0;
- if (ConfMan.hasKey("output_rate"))
- samplesPerSec = ConfMan.getInt("output_rate");
- if (samplesPerSec <= 0)
- samplesPerSec = SAMPLES_PER_SEC;
-
- // Determine the sample buffer size. We want it to store enough data for
- // at least 1/16th of a second (though at most 8192 samples). Note
- // that it must be a power of two. So e.g. at 22050 Hz, we request a
- // sample buffer size of 2048.
- uint32 samples = 8192;
- while (samples * 16 > samplesPerSec * 2)
- samples >>= 1;
-
- memset(&desired, 0, sizeof(desired));
- desired.freq = samplesPerSec;
- desired.format = AUDIO_S16SYS;
- desired.channels = 2;
- desired.samples = (uint16)samples;
- desired.callback = symbianMixCallback;
- desired.userdata = this;
-
- assert(!_mixer);
- if (SDL_OpenAudio(&desired, &obtained) != 0) {
- warning("Could not open audio device: %s", SDL_GetError());
- _mixer = new Audio::MixerImpl(this, samplesPerSec);
- assert(_mixer);
- _mixer->setReady(false);
- } else {
- // Note: This should be the obtained output rate, but it seems that at
- // least on some platforms SDL will lie and claim it did get the rate
- // even if it didn't. Probably only happens for "weird" rates, though.
- samplesPerSec = obtained.freq;
- _channels = obtained.channels;
-
- // Need to create mixbuffer for stereo mix to downmix
- if (_channels != 2) {
- _stereo_mix_buffer = new byte [obtained.size*2];//*2 for stereo values
- }
-
- // Create the mixer instance and start the sound processing
- _mixer = new Audio::MixerImpl(this, samplesPerSec);
- assert(_mixer);
- _mixer->setReady(true);
- SDL_PauseAudio(0);
- }
-}
-
-/**
- * The mixer callback function.
- */
-void OSystem_SDL_Symbian::symbianMixCallback(void *sys, byte *samples, int len) {
- OSystem_SDL_Symbian *this_ = (OSystem_SDL_Symbian *)sys;
- assert(this_);
-
- if (!this_->_mixer)
- return;
-
-#if defined (S60) && !defined(S60V3)
- // If not stereo then we need to downmix
- if (this_->_mixer->_channels != 2) {
- this_->_mixer->mixCallback(_stereo_mix_buffer, len * 2);
-
- int16 *bitmixDst = (int16 *)samples;
- int16 *bitmixSrc = (int16 *)_stereo_mix_buffer;
-
- for (int loop = len / 2; loop >= 0; loop --) {
- *bitmixDst = (*bitmixSrc + *(bitmixSrc + 1)) >> 1;
- bitmixDst++;
- bitmixSrc += 2;
- }
- } else
-#else
- this_->_mixer->mixCallback(samples, len);
-#endif
-}
-
-
-/**
- * This is an implementation by the remapKey function
- * @param SDL_Event to remap
- * @param ScumVM event to modify if special result is requested
- * @return true if Common::Event has a valid return status
- */
-bool OSystem_SDL_Symbian::remapKey(SDL_Event &ev, Common::Event &event) {
- if (GUI::Actions::Instance()->mappingActive() || ev.key.keysym.sym <= SDLK_UNKNOWN)
- return false;
-
- for (TInt loop = 0; loop < GUI::ACTION_LAST; loop++) {
- if (GUI::Actions::Instance()->getMapping(loop) == ev.key.keysym.sym &&
- GUI::Actions::Instance()->isEnabled(loop)) {
- // Create proper event instead
- switch (loop) {
- case GUI::ACTION_UP:
- if (ev.type == SDL_KEYDOWN) {
- _km.y_vel = -1;
- _km.y_down_count = 1;
- } else {
- _km.y_vel = 0;
- _km.y_down_count = 0;
- }
- event.type = Common::EVENT_MOUSEMOVE;
- fillMouseEvent(event, _km.x, _km.y);
-
- return true;
-
- case GUI::ACTION_DOWN:
- if (ev.type == SDL_KEYDOWN) {
- _km.y_vel = 1;
- _km.y_down_count = 1;
- } else {
- _km.y_vel = 0;
- _km.y_down_count = 0;
- }
- event.type = Common::EVENT_MOUSEMOVE;
- fillMouseEvent(event, _km.x, _km.y);
-
- return true;
-
- case GUI::ACTION_LEFT:
- if (ev.type == SDL_KEYDOWN) {
- _km.x_vel = -1;
- _km.x_down_count = 1;
- } else {
- _km.x_vel = 0;
- _km.x_down_count = 0;
- }
- event.type = Common::EVENT_MOUSEMOVE;
- fillMouseEvent(event, _km.x, _km.y);
-
- return true;
-
- case GUI::ACTION_RIGHT:
- if (ev.type == SDL_KEYDOWN) {
- _km.x_vel = 1;
- _km.x_down_count = 1;
- } else {
- _km.x_vel = 0;
- _km.x_down_count = 0;
- }
- event.type = Common::EVENT_MOUSEMOVE;
- fillMouseEvent(event, _km.x, _km.y);
-
- return true;
-
- case GUI::ACTION_LEFTCLICK:
- event.type = (ev.type == SDL_KEYDOWN ? Common::EVENT_LBUTTONDOWN : Common::EVENT_LBUTTONUP);
- fillMouseEvent(event, _km.x, _km.y);
-
- return true;
-
- case GUI::ACTION_RIGHTCLICK:
- event.type = (ev.type == SDL_KEYDOWN ? Common::EVENT_RBUTTONDOWN : Common::EVENT_RBUTTONUP);
- fillMouseEvent(event, _km.x, _km.y);
-
- return true;
-
- case GUI::ACTION_ZONE:
- if (ev.type == SDL_KEYDOWN) {
- int i;
-
- for (i=0; i < TOTAL_ZONES; i++)
- if (_km.x >= _zones[i].x && _km.y >= _zones[i].y &&
- _km.x <= _zones[i].x + _zones[i].width && _km.y <= _zones[i].y + _zones[i].height
- ) {
- _mouseXZone[i] = _km.x;
- _mouseYZone[i] = _km.y;
- break;
- }
- _currentZone++;
- if (_currentZone >= TOTAL_ZONES)
- _currentZone = 0;
- event.type = Common::EVENT_MOUSEMOVE;
- fillMouseEvent(event, _mouseXZone[_currentZone], _mouseYZone[_currentZone]);
- SDL_WarpMouse(event.mouse.x, event.mouse.y);
- }
-
- return true;
- case GUI::ACTION_MULTI: {
- GUI::Key &key = GUI::Actions::Instance()->getKeyAction(loop);
- // if key code is pause, then change event to interactive or just fall through
- if (key.keycode() == SDLK_PAUSE) {
- event.type = Common::EVENT_PREDICTIVE_DIALOG;
- return true;
- }
- }
- case GUI::ACTION_SAVE:
- case GUI::ACTION_SKIP:
- case GUI::ACTION_SKIP_TEXT:
- case GUI::ACTION_PAUSE:
- case GUI::ACTION_SWAPCHAR:
- case GUI::ACTION_FASTMODE:
- case GUI::ACTION_DEBUGGER:
- case GUI::ACTION_MAINMENU:
- case GUI::ACTION_VKB:
- case GUI::ACTION_KEYMAPPER:{
- GUI::Key &key = GUI::Actions::Instance()->getKeyAction(loop);
- ev.key.keysym.sym = (SDLKey) key.keycode();
- ev.key.keysym.scancode = 0;
- ev.key.keysym.mod = (SDLMod) key.flags();
-
- // Translate from SDL keymod event to Scummvm Key Mod Common::Event.
- // This codes is also present in GP32 backend and in SDL backend as a static function
- // Perhaps it should be shared.
- if (key.flags() != 0) {
- event.kbd.flags = 0;
-
- if (ev.key.keysym.mod & KMOD_SHIFT)
- event.kbd.flags |= Common::KBD_SHIFT;
-
- if (ev.key.keysym.mod & KMOD_ALT)
- event.kbd.flags |= Common::KBD_ALT;
-
- if (ev.key.keysym.mod & KMOD_CTRL)
- event.kbd.flags |= Common::KBD_CTRL;
- }
-
- return false;
- }
-
- case GUI::ACTION_QUIT:
- {
- GUI::MessageDialog alert("Do you want to quit ?", "Yes", "No");
- if (alert.runModal() == GUI::kMessageOK)
- quit();
-
- return true;
- }
- }
- }
- }
-
- return false;
-}
-
-void OSystem_SDL_Symbian::setWindowCaption(const char *caption) {
- OSystem_SDL::setWindowCaption(caption);
+ // Call parent implementation of this method
+ OSystem_SDL::quit();
}
void OSystem_SDL_Symbian::engineInit() {
// Check mappings for the engine just started
- check_mappings();
+ checkMappings();
}
void OSystem_SDL_Symbian::engineDone() {
@@ -469,22 +160,22 @@ void OSystem_SDL_Symbian::engineDone() {
GUI::Actions::Instance()->initInstanceMain(this);
}
-void OSystem_SDL_Symbian::check_mappings() {
+void OSystem_SDL_Symbian::checkMappings() {
if (ConfMan.get("gameid").empty() || GUI::Actions::Instance()->initialized())
return;
GUI::Actions::Instance()->initInstanceGame();
}
-void OSystem_SDL_Symbian::initZones() {
- int i;
-
- _currentZone = 0;
+bool OSystem_SDL_Symbian::setGraphicsMode(const char * /*name*/) {
+ return _graphicsManager->setGraphicsMode(0);
+}
- for (i = 0; i < TOTAL_ZONES; i++) {
- _mouseXZone[i] = (_zones[i].x + (_zones[i].width / 2));
- _mouseYZone[i] = (_zones[i].y + (_zones[i].height / 2));
- }
+Common::String OSystem_SDL_Symbian::getDefaultConfigFileName() {
+ char configFile[MAXPATHLEN];
+ strcpy(configFile, Symbian::GetExecutablePath());
+ strcat(configFile, DEFAULT_CONFIG_FILE);
+ return configFile;
}
RFs& OSystem_SDL_Symbian::FsSession() {
@@ -510,67 +201,3 @@ void* scumm_bsearch(const void *key, const void *base, size_t nmemb, size_t size
return NULL;
}
-
-extern "C"
-{
-// Include the snprintf and vsnprintf implementations as 'C' code
-#include "vsnprintf.h"
-}
-
-// Symbian SDL_Main implementation
-// Redirects standard io, creates Symbian specific SDL backend (inherited from main SDL)
-int main(int argc, char *argv[]) {
- //
- // Set up redirects for stdout/stderr under Symbian.
- // Code copied from SDL_main.
- //
-
- // Symbian does not like any output to the console through any *print* function
- char STDOUT_FILE[256], STDERR_FILE[256]; // shhh, don't tell anybody :)
- strcpy(STDOUT_FILE, Symbian::GetExecutablePath());
- strcpy(STDERR_FILE, Symbian::GetExecutablePath());
- strcat(STDOUT_FILE, "scummvm.stdout.txt");
- strcat(STDERR_FILE, "scummvm.stderr.txt");
-
- /* Flush the output in case anything is queued */
- fclose(stdout);
- fclose(stderr);
-
- /* Redirect standard input and standard output */
- FILE *newfp = freopen(STDOUT_FILE, "w", stdout);
- if (newfp == NULL) { /* This happens on NT */
-#if !defined(stdout)
- stdout = fopen(STDOUT_FILE, "w");
-#else
- newfp = fopen(STDOUT_FILE, "w");
- if (newfp) {
- *stdout = *newfp;
- }
-#endif
- }
- newfp = freopen(STDERR_FILE, "w", stderr);
- if (newfp == NULL) { /* This happens on NT */
-#if !defined(stderr)
- stderr = fopen(STDERR_FILE, "w");
-#else
- newfp = fopen(STDERR_FILE, "w");
- if (newfp) {
- *stderr = *newfp;
- }
-#endif
- }
- setbuf(stderr, NULL); /* No buffering */
-
- // Create our OSystem instance
- g_system = new OSystem_SDL_Symbian();
- assert(g_system);
-
-#ifdef DYNAMIC_MODULES
- PluginManager::instance().addPluginProvider(new SDLPluginProvider());
-#endif
-
- // Invoke the actual ScummVM main entry point:
- int res = scummvm_main(argc, argv);
- g_system->quit(); // TODO: Consider removing / replacing this!
- return res;
-}
diff --git a/backends/platform/symbian/src/SymbianOS.h b/backends/platform/symbian/src/SymbianOS.h
index 42929f8029..4faec71865 100644
--- a/backends/platform/symbian/src/SymbianOS.h
+++ b/backends/platform/symbian/src/SymbianOS.h
@@ -22,55 +22,32 @@
* $Id$
*/
-#ifndef SDLSYMBIANH
-#define SDLSYMBIANH
+#ifndef PLATFORM_SDL_SYMBIAN_H
+#define PLATFORM_SDL_SYMBIAN_H
#include "backends/platform/sdl/sdl.h"
-#define TOTAL_ZONES 3
class RFs;
class OSystem_SDL_Symbian : public OSystem_SDL {
public:
OSystem_SDL_Symbian();
- virtual ~OSystem_SDL_Symbian();
+ ~OSystem_SDL_Symbian();
-public:
- /**
- * The following method is called once, from main.cpp, after all
- * config data (including command line params etc.) are fully loaded.
- */
- virtual void initBackend();
-
- int getDefaultGraphicsMode() const;
- const OSystem::GraphicsMode *getSupportedGraphicsModes() const;
- bool setGraphicsMode(const char *name);
- void quitWithErrorMsg(const char *msg);
- virtual bool hasFeature(Feature f);
- void setFeatureState(Feature f, bool enable);
-
- // Set function that generates samples
- //
- // This function is overridden by the symbian port in order to provide MONO audio
- // downmix is done by supplying our own audiocallback
- //
- virtual void setupMixer(); // overloaded by CE backend
-
- // Overloaded from SDL_Commmon
+ // Overloaded from OSystem_SDL
+ void init();
+ void initBackend();
void quit();
+ void engineInit();
+ void engineDone();
+ bool setGraphicsMode(const char *name);
+ Common::String getDefaultConfigFileName();
// Returns reference to File session
RFs& FsSession();
-protected:
- //
- // The mixer callback function.
- //
- static void symbianMixCallback(void *s, byte *samples, int len);
+ void quitWithErrorMsg(const char *msg);
- virtual Common::SeekableReadStream *createConfigReadStream();
- virtual Common::WriteStream *createConfigWriteStream();
-public:
// vibration support
#ifdef USE_VIBRA_SE_PXXX
//
@@ -94,54 +71,9 @@ protected:
#endif // USE_VIBRA_SE_PXXX
protected:
-
- //
- // This is an implementation by the remapKey function
- // @param SDL_Event to remap
- // @param ScumVM event to modify if special result is requested
- // @return true if Common::Event has a valid return status
- //
- bool remapKey(SDL_Event &ev, Common::Event &event);
-
- void setWindowCaption(const char *caption);
-
- /**
- * Allows the backend to perform engine specific init.
- * Called just before the engine is run.
- */
- virtual void engineInit();
-
- /**
- * Allows the backend to perform engine specific de-init.
- * Called after the engine finishes.
- */
- virtual void engineDone();
-
- //
// Used to intialized special game mappings
- //
- void check_mappings();
-
- void initZones();
-
- // Audio
- int _channels;
-
- byte *_stereo_mix_buffer;
-
- // Used to handle joystick navi zones
- int _mouseXZone[TOTAL_ZONES];
- int _mouseYZone[TOTAL_ZONES];
- int _currentZone;
-
- struct zoneDesc {
- int x;
- int y;
- int width;
- int height;
- };
+ void checkMappings();
- static zoneDesc _zones[TOTAL_ZONES];
RFs* _RFs;
};
diff --git a/backends/platform/symbian/src/main.cpp b/backends/platform/symbian/src/main.cpp
new file mode 100644
index 0000000000..4aaa05926f
--- /dev/null
+++ b/backends/platform/symbian/src/main.cpp
@@ -0,0 +1,99 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "base/main.h"
+#include "backends/platform/symbian/src/SymbianOS.h"
+#include "backends/platform/symbian/src/portdefs.h"
+
+extern "C"
+{
+// Include the snprintf and vsnprintf implementations as 'C' code
+#include "vsnprintf.h"
+}
+
+// Symbian SDL_Main implementation
+// Redirects standard io, creates Symbian specific SDL backend (inherited from main SDL)
+int main(int argc, char *argv[]) {
+ //
+ // Set up redirects for stdout/stderr under Symbian.
+ // Code copied from SDL_main.
+ //
+
+ // Symbian does not like any output to the console through any *print* function
+ char STDOUT_FILE[256], STDERR_FILE[256]; // shhh, don't tell anybody :)
+ strcpy(STDOUT_FILE, Symbian::GetExecutablePath());
+ strcpy(STDERR_FILE, Symbian::GetExecutablePath());
+ strcat(STDOUT_FILE, "scummvm.stdout.txt");
+ strcat(STDERR_FILE, "scummvm.stderr.txt");
+
+ /* Flush the output in case anything is queued */
+ fclose(stdout);
+ fclose(stderr);
+
+ /* Redirect standard input and standard output */
+ FILE *newfp = freopen(STDOUT_FILE, "w", stdout);
+ if (newfp == NULL) { /* This happens on NT */
+#if !defined(stdout)
+ stdout = fopen(STDOUT_FILE, "w");
+#else
+ newfp = fopen(STDOUT_FILE, "w");
+ if (newfp) {
+ *stdout = *newfp;
+ }
+#endif
+ }
+ newfp = freopen(STDERR_FILE, "w", stderr);
+ if (newfp == NULL) { /* This happens on NT */
+#if !defined(stderr)
+ stderr = fopen(STDERR_FILE, "w");
+#else
+ newfp = fopen(STDERR_FILE, "w");
+ if (newfp) {
+ *stderr = *newfp;
+ }
+#endif
+ }
+ setbuf(stderr, NULL); /* No buffering */
+
+ // Create our OSystem instance
+ g_system = new OSystem_SDL_Symbian();
+ assert(g_system);
+
+ // Pre initialize the backend
+ ((OSystem_SDL_Symbian *)g_system)->init();
+
+#ifdef DYNAMIC_MODULES
+ PluginManager::instance().addPluginProvider(new SDLPluginProvider());
+#endif
+
+ // Invoke the actual ScummVM main entry point:
+ int res = scummvm_main(argc, argv);
+
+ // Free OSystem
+ delete (OSystem_SDL_Symbian *)g_system;
+
+ return res;
+}
+