aboutsummaryrefslogtreecommitdiff
path: root/backends
diff options
context:
space:
mode:
Diffstat (limited to 'backends')
-rw-r--r--backends/events/gph/gph-events.cpp (renamed from backends/platform/gph/gph-events.cpp)114
-rw-r--r--backends/events/gph/gph-events.h61
-rw-r--r--backends/graphics/gph/gph-graphics.cpp (renamed from backends/platform/gph/gph-graphics.cpp)176
-rw-r--r--backends/graphics/gph/gph-graphics.h62
-rw-r--r--backends/platform/gph/gph-backend.cpp211
-rw-r--r--backends/platform/gph/gph-main.cpp191
-rw-r--r--backends/platform/gph/gph-sdl.h53
-rw-r--r--backends/platform/gph/module.mk7
8 files changed, 534 insertions, 341 deletions
diff --git a/backends/platform/gph/gph-events.cpp b/backends/events/gph/gph-events.cpp
index 2a6237c794..8a5bee9b4a 100644
--- a/backends/platform/gph/gph-events.cpp
+++ b/backends/events/gph/gph-events.cpp
@@ -18,19 +18,19 @@
* 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 "common/scummsys.h"
+
/*
* GPH: Device Specific Event Handling.
- *
*/
-#include "backends/platform/gph/gph-sdl.h"
+#if defined(GP2XWIZ) || defined(CAANOO)
+
+#include "backends/events/gph/gph-events.h"
+#include "backends/graphics/gph/gph-graphics.h"
#include "backends/platform/gph/gph-hw.h"
-#include "graphics/scaler/aspect.h"
#include "common/util.h"
#include "common/events.h"
@@ -122,48 +122,34 @@ enum {
TAPMODE_HOVER = 2
};
-static int mapKey(SDLKey key, SDLMod mod, Uint16 unicode) {
- if (key >= SDLK_F1 && key <= SDLK_F9) {
- return key - SDLK_F1 + Common::ASCII_F1;
- } else if (key >= SDLK_KP0 && key <= SDLK_KP9) {
- return key - SDLK_KP0 + '0';
- } else if (key >= SDLK_UP && key <= SDLK_PAGEDOWN) {
- return key;
- } else if (unicode) {
- return unicode;
- } else if (key >= 'a' && key <= 'z' && (mod & KMOD_SHIFT)) {
- return key & ~0x20;
- } else if (key >= SDLK_NUMLOCK && key <= SDLK_EURO) {
- return 0;
- }
- return key;
-}
-
-
-void OSystem_GPH::fillMouseEvent(Common::Event &event, int x, int y) {
- if (_videoMode.mode == GFX_HALF && !_overlayVisible){
- event.mouse.x = x*2;
- event.mouse.y = y*2;
- } else {
- event.mouse.x = x;
- event.mouse.y = y;
- }
-
- // Update the "keyboard mouse" coords
- _km.x = x;
- _km.y = y;
-
- // Adjust for the screen scaling
- if (!_overlayVisible) {
- event.mouse.x /= _videoMode.scaleFactor;
- event.mouse.y /= _videoMode.scaleFactor;
- if (_videoMode.aspectRatioCorrection)
- event.mouse.y = aspect2Real(event.mouse.y);
- }
-}
-
-
-void OSystem_GPH::moveStick() {
+//GPHEventSource::GPHEventSource()
+// : _buttonStateL(false){
+//}
+
+//void GPHEventSource::fillMouseEvent(Common::Event &event, int x, int y) {
+// if (GPHGraphicsManager::_videoMode.mode == GFX_HALF && !GPHGraphicsManager::_overlayVisible){
+// event.mouse.x = x*2;
+// event.mouse.y = y*2;
+// } else {
+// event.mouse.x = x;
+// event.mouse.y = y;
+// }
+//
+// // Update the "keyboard mouse" coords
+// _km.x = x;
+// _km.y = y;
+//
+// // Adjust for the screen scaling
+// if (!_overlayVisible) {
+// event.mouse.x /= _videoMode.scaleFactor;
+// event.mouse.y /= _videoMode.scaleFactor;
+// if (_videoMode.aspectRatioCorrection)
+// event.mouse.y = aspect2Real(event.mouse.y);
+// }
+//}
+
+
+void GPHEventSource::moveStick() {
bool stickBtn[32];
memcpy(stickBtn, _stickBtn, sizeof(stickBtn));
@@ -208,7 +194,7 @@ void OSystem_GPH::moveStick() {
/* Custom handleMouseButtonDown/handleMouseButtonUp to deal with 'Tap Mode' for the touchscreen */
-bool OSystem_GPH::handleMouseButtonDown(SDL_Event &ev, Common::Event &event) {
+bool GPHEventSource::handleMouseButtonDown(SDL_Event &ev, Common::Event &event) {
if (ev.button.button == SDL_BUTTON_LEFT){
if (BUTTON_STATE_L == true) /* BUTTON_STATE_L = Left Trigger Held, force Right Click */
event.type = Common::EVENT_RBUTTONDOWN;
@@ -241,7 +227,7 @@ bool OSystem_GPH::handleMouseButtonDown(SDL_Event &ev, Common::Event &event) {
return true;
}
-bool OSystem_GPH::handleMouseButtonUp(SDL_Event &ev, Common::Event &event) {
+bool GPHEventSource::handleMouseButtonUp(SDL_Event &ev, Common::Event &event) {
if (ev.button.button == SDL_BUTTON_LEFT){
if (BUTTON_STATE_L == true) /* BUTTON_STATE_L = Left Trigger Held, force Right Click */
event.type = Common::EVENT_RBUTTONUP;
@@ -270,7 +256,7 @@ bool OSystem_GPH::handleMouseButtonUp(SDL_Event &ev, Common::Event &event) {
/* Custom handleJoyButtonDown/handleJoyButtonUp to deal with the joystick buttons on GPH devices */
-bool OSystem_GPH::handleJoyButtonDown(SDL_Event &ev, Common::Event &event) {
+bool GPHEventSource::handleJoyButtonDown(SDL_Event &ev, Common::Event &event) {
_stickBtn[ev.jbutton.button] = 1;
event.kbd.flags = 0;
@@ -339,11 +325,11 @@ bool OSystem_GPH::handleJoyButtonDown(SDL_Event &ev, Common::Event &event) {
if (BUTTON_STATE_L == true) {
GPH::ToggleTapMode();
if (GPH::tapmodeLevel == TAPMODE_LEFT) {
- displayMessageOnOSD("Touchscreen 'Tap Mode' - Left Click");
+ g_system->displayMessageOnOSD("Touchscreen 'Tap Mode' - Left Click");
} else if (GPH::tapmodeLevel == TAPMODE_RIGHT) {
- displayMessageOnOSD("Touchscreen 'Tap Mode' - Right Click");
+ g_system->displayMessageOnOSD("Touchscreen 'Tap Mode' - Right Click");
} else if (GPH::tapmodeLevel == TAPMODE_HOVER) {
- displayMessageOnOSD("Touchscreen 'Tap Mode' - Hover (No Click)");
+ g_system->displayMessageOnOSD("Touchscreen 'Tap Mode' - Hover (No Click)");
}
} else {
event.kbd.keycode = Common::KEYCODE_SPACE;
@@ -363,17 +349,17 @@ bool OSystem_GPH::handleJoyButtonDown(SDL_Event &ev, Common::Event &event) {
case BUTTON_VOLUP:
WIZ_HW::mixerMoveVolume(2);
if (WIZ_HW::volumeLevel == 100) {
- displayMessageOnOSD("Maximum Volume");
+ g_system->displayMessageOnOSD("Maximum Volume");
} else {
- displayMessageOnOSD("Increasing Volume");
+ g_system->displayMessageOnOSD("Increasing Volume");
}
break;
case BUTTON_VOLDOWN:
WIZ_HW::mixerMoveVolume(1);
if (WIZ_HW::volumeLevel == 0) {
- displayMessageOnOSD("Minimal Volume");
+ g_system->displayMessageOnOSD("Minimal Volume");
} else {
- displayMessageOnOSD("Decreasing Volume");
+ g_system->displayMessageOnOSD("Decreasing Volume");
}
break;
case BUTTON_HOLD:
@@ -382,18 +368,18 @@ bool OSystem_GPH::handleJoyButtonDown(SDL_Event &ev, Common::Event &event) {
case BUTTON_HELP2:
GPH::ToggleTapMode();
if (GPH::tapmodeLevel == TAPMODE_LEFT) {
- displayMessageOnOSD("Touchscreen 'Tap Mode': Left Click");
+ g_system->displayMessageOnOSD("Touchscreen 'Tap Mode': Left Click");
} else if (GPH::tapmodeLevel == TAPMODE_RIGHT) {
- displayMessageOnOSD("Touchscreen 'Tap Mode': Right Click");
+ g_system->displayMessageOnOSD("Touchscreen 'Tap Mode': Right Click");
} else if (GPH::tapmodeLevel == TAPMODE_HOVER) {
- displayMessageOnOSD("Touchscreen 'Tap Mode': Hover (No Click)");
+ g_system->displayMessageOnOSD("Touchscreen 'Tap Mode': Hover (No Click)");
}
break;
}
return true;
}
-bool OSystem_GPH::handleJoyButtonUp(SDL_Event &ev, Common::Event &event) {
+bool GPHEventSource::handleJoyButtonUp(SDL_Event &ev, Common::Event &event) {
_stickBtn[ev.jbutton.button] = 0;
event.kbd.flags = 0;
@@ -476,6 +462,8 @@ bool OSystem_GPH::handleJoyButtonUp(SDL_Event &ev, Common::Event &event) {
return true;
}
-bool OSystem_GPH::remapKey(SDL_Event &ev,Common::Event &event) {
+bool GPHEventSource::remapKey(SDL_Event &ev,Common::Event &event) {
return false;
}
+
+#endif
diff --git a/backends/events/gph/gph-events.h b/backends/events/gph/gph-events.h
new file mode 100644
index 0000000000..f929a14113
--- /dev/null
+++ b/backends/events/gph/gph-events.h
@@ -0,0 +1,61 @@
+/* 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.
+ *
+ */
+
+#if !defined(BACKEND_EVENTS_GPH_H) && !defined(DISABLE_DEFAULT_EVENTMANAGER)
+#define BACKEND_EVENTS_GPH_H
+
+#include "backends/events/sdl/sdl-events.h"
+
+/*
+ * SDL Events manager for GPH devices.
+ */
+
+class GPHEventSource : public SdlEventSource {
+//public:
+// GPHEventSource();
+
+protected:
+ bool _stickBtn[32];
+
+ /**
+ * Button state for L button modifier
+ */
+ bool _buttonStateL;
+
+ /**
+ * Handles the stick movement
+ */
+ void moveStick();
+
+ virtual bool handleKeyDown(SDL_Event &ev, Common::Event &event);
+ virtual bool handleJoyButtonDown(SDL_Event &ev, Common::Event &event);
+ virtual bool handleJoyButtonUp(SDL_Event &ev, Common::Event &event);
+ virtual bool handleMouseButtonDown(SDL_Event &ev, Common::Event &event);
+ virtual bool handleMouseButtonUp(SDL_Event &ev, Common::Event &event);
+ virtual bool handleJoyAxisMotion(SDL_Event &ev, Common::Event &event);
+
+// void fillMouseEvent(Common::Event &event, int x, int y);
+ virtual bool remapKey(SDL_Event &ev, Common::Event &event);
+ virtual void SDLModToOSystemKeyFlags(SDLMod mod, Common::Event &event);
+};
+
+#endif /* BACKEND_EVENTS_GPH_H */
diff --git a/backends/platform/gph/gph-graphics.cpp b/backends/graphics/gph/gph-graphics.cpp
index 8fada7e40a..2f971f8da1 100644
--- a/backends/platform/gph/gph-graphics.cpp
+++ b/backends/graphics/gph/gph-graphics.cpp
@@ -18,35 +18,35 @@
* 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 "backends/platform/gph/gph-sdl.h"
+#include "common/scummsys.h"
-#include "common/mutex.h"
-#include "graphics/font.h"
-#include "graphics/fontman.h"
-#include "graphics/scaler.h"
+#if defined(GP2XWIZ) || defined(CAANOO)
+
+#include "backends/graphics/gph/gph-graphics.h"
+#include "backends/events/gph/gph-events.h"
#include "graphics/scaler/aspect.h"
-#include "graphics/scaler/downscaler.h"
-#include "graphics/surface.h"
+#include "common/mutex.h"
static const OSystem::GraphicsMode s_supportedGraphicsModes[] = {
- {"1x", "Fullscreen", GFX_NORMAL},
+ {"1x", "Standard", GFX_NORMAL},
{0, 0, 0}
};
-const OSystem::GraphicsMode *OSystem_GPH::getSupportedGraphicsModes() const {
+GPHGraphicsManager::GPHGraphicsManager(SdlEventSource *boss)
+ : SdlGraphicsManager(boss) {
+}
+
+const OSystem::GraphicsMode *GPHGraphicsManager::getSupportedGraphicsModes() const {
return s_supportedGraphicsModes;
}
-int OSystem_GPH::getDefaultGraphicsMode() const {
+int GPHGraphicsManager::getDefaultGraphicsMode() const {
return GFX_NORMAL;
}
-bool OSystem_GPH::setGraphicsMode(int mode) {
+bool GPHGraphicsManager::setGraphicsMode(int mode) {
Common::StackLock lock(_graphicsMutex);
assert(_transactionMode == kTransactionActive);
@@ -80,7 +80,7 @@ bool OSystem_GPH::setGraphicsMode(int mode) {
return true;
}
-void OSystem_GPH::setGraphicsModeIntern() {
+void GPHGraphicsManager::setGraphicsModeIntern() {
Common::StackLock lock(_graphicsMutex);
ScalerProc *newScalerProc = 0;
@@ -109,7 +109,7 @@ void OSystem_GPH::setGraphicsModeIntern() {
blitCursor();
}
-void OSystem_GPH::initSize(uint w, uint h) {
+void GPHGraphicsManager::initSize(uint w, uint h) {
assert(_transactionMode == kTransactionActive);
// Avoid redundant res changes
@@ -121,41 +121,13 @@ void OSystem_GPH::initSize(uint w, uint h) {
if (w > 320 || h > 240){
setGraphicsMode(GFX_HALF);
setGraphicsModeIntern();
- toggleMouseGrab();
+ _sdlEventSource->toggleMouseGrab();
}
_transactionDetails.sizeChanged = true;
}
-bool OSystem_GPH::loadGFXMode() {
- if (_videoMode.screenWidth > 320 || _videoMode.screenHeight > 240) {
- _videoMode.aspectRatioCorrection = false;
- setGraphicsMode(GFX_HALF);
- printf("GFX_HALF\n");
- } else {
- setGraphicsMode(GFX_NORMAL);
- printf("GFX_NORMAL\n");
- }
-
- if ((_videoMode.mode == GFX_HALF) && !_overlayVisible) {
- _videoMode.overlayWidth = _videoMode.screenWidth / 2;
- _videoMode.overlayHeight = _videoMode.screenHeight / 2;
- _videoMode.fullscreen = true;
- } else {
-
- _videoMode.overlayWidth = _videoMode.screenWidth * _videoMode.scaleFactor;
- _videoMode.overlayHeight = _videoMode.screenHeight * _videoMode.scaleFactor;
-
- if (_videoMode.aspectRatioCorrection)
- _videoMode.overlayHeight = real2Aspect(_videoMode.overlayHeight);
-
- _videoMode.hardwareWidth = _videoMode.screenWidth * _videoMode.scaleFactor;
- _videoMode.hardwareHeight = effectiveScreenHeight();
- }
- return OSystem_SDL::loadGFXMode();
-}
-
-void OSystem_GPH::drawMouse() {
+void GPHGraphicsManager::drawMouse() {
if (!_mouseVisible || !_mouseSurface) {
_mouseBackup.x = _mouseBackup.y = _mouseBackup.w = _mouseBackup.h = 0;
return;
@@ -226,7 +198,7 @@ void OSystem_GPH::drawMouse() {
addDirtyRect(dst.x, dst.y, dst.w, dst.h, true);
}
-void OSystem_GPH::undrawMouse() {
+void GPHGraphicsManager::undrawMouse() {
const int x = _mouseBackup.x;
const int y = _mouseBackup.y;
@@ -244,7 +216,7 @@ void OSystem_GPH::undrawMouse() {
}
}
-void OSystem_GPH::internUpdateScreen() {
+void GPHGraphicsManager::internUpdateScreen() {
SDL_Surface *srcSurf, *origSurf;
int height, width;
ScalerProc *scalerProc;
@@ -443,28 +415,124 @@ void OSystem_GPH::internUpdateScreen() {
_mouseNeedsRedraw = false;
}
-void OSystem_GPH::showOverlay() {
+void GPHGraphicsManager::showOverlay() {
if (_videoMode.mode == GFX_HALF){
_mouseCurState.x = _mouseCurState.x / 2;
_mouseCurState.y = _mouseCurState.y / 2;
}
- OSystem_SDL::showOverlay();
+ SdlGraphicsManager::showOverlay();
}
-void OSystem_GPH::hideOverlay() {
+void GPHGraphicsManager::hideOverlay() {
if (_videoMode.mode == GFX_HALF){
_mouseCurState.x = _mouseCurState.x * 2;
_mouseCurState.y = _mouseCurState.y * 2;
}
- OSystem_SDL::hideOverlay();
+ SdlGraphicsManager::hideOverlay();
}
-void OSystem_GPH::warpMouse(int x, int y) {
+
+bool GPHGraphicsManager::loadGFXMode() {
+
+ /* Forcefully disable aspect ratio correction for games
+ that start with a native 240px height resolution
+ This corrects games with non-standard resolutions
+ such as MM Nes (256x240).
+ */
+
+ if(_videoMode.screenHeight == 240) {
+ _videoMode.aspectRatioCorrection = false;
+ }
+
+ fprintf(stdout, "Game ScreenMode = %d*%d\n", _videoMode.screenWidth, _videoMode.screenHeight);
+ if (_videoMode.screenWidth > 320 || _videoMode.screenHeight > 240) {
+ _videoMode.aspectRatioCorrection = false;
+ setGraphicsMode(GFX_HALF);
+ fprintf(stdout, "GraphicsMode set to HALF\n");
+ } else {
+ setGraphicsMode(GFX_NORMAL);
+ fprintf(stdout, "GraphicsMode set to NORMAL\n");
+ }
+
+ if ((_videoMode.mode == GFX_HALF) && !_overlayVisible) {
+ _videoMode.overlayWidth = _videoMode.screenWidth / 2;
+ _videoMode.overlayHeight = _videoMode.screenHeight / 2;
+ _videoMode.fullscreen = true;
+ } else {
+
+ _videoMode.overlayWidth = _videoMode.screenWidth * _videoMode.scaleFactor;
+ _videoMode.overlayHeight = _videoMode.screenHeight * _videoMode.scaleFactor;
+
+ if (_videoMode.aspectRatioCorrection)
+ _videoMode.overlayHeight = real2Aspect(_videoMode.overlayHeight);
+
+ _videoMode.hardwareWidth = _videoMode.screenWidth * _videoMode.scaleFactor;
+ _videoMode.hardwareHeight = effectiveScreenHeight();
+ }
+ return SdlGraphicsManager::loadGFXMode();
+}
+
+bool GPHGraphicsManager::hasFeature(OSystem::Feature f) {
+ return
+ (f == OSystem::kFeatureAspectRatioCorrection) ||
+ (f == OSystem::kFeatureCursorHasPalette);
+}
+
+void GPHGraphicsManager::setFeatureState(OSystem::Feature f, bool enable) {
+ switch (f) {
+ case OSystem::kFeatureAspectRatioCorrection:
+ setAspectRatioCorrection(enable);
+ break;
+ default:
+ break;
+ }
+}
+
+bool GPHGraphicsManager::getFeatureState(OSystem::Feature f) {
+ assert(_transactionMode == kTransactionNone);
+
+ switch (f) {
+ case OSystem::kFeatureAspectRatioCorrection:
+ return _videoMode.aspectRatioCorrection;
+ default:
+ return false;
+ }
+}
+
+SdlGraphicsManager::MousePos* GPHGraphicsManager::getMouseCurState() {
+ return &_mouseCurState;
+}
+
+SdlGraphicsManager::VideoState* GPHGraphicsManager::getVideoMode() {
+ return &_videoMode;
+}
+
+void GPHGraphicsManager::warpMouse(int x, int y) {
if (_mouseCurState.x != x || _mouseCurState.y != y) {
if (_videoMode.mode == GFX_HALF && !_overlayVisible){
x = x / 2;
y = y / 2;
}
}
- OSystem_SDL::warpMouse(x, y);
+ SdlGraphicsManager::warpMouse(x, y);
+}
+
+void GPHGraphicsManager::adjustMouseEvent(const Common::Event &event) {
+ if (!event.synthetic) {
+ Common::Event newEvent(event);
+ newEvent.synthetic = true;
+ if (!_overlayVisible) {
+ if (_videoMode.mode == GFX_HALF) {
+ newEvent.mouse.x *= 2;
+ newEvent.mouse.y *= 2;
+ }
+ newEvent.mouse.x /= _videoMode.scaleFactor;
+ newEvent.mouse.y /= _videoMode.scaleFactor;
+ if (_videoMode.aspectRatioCorrection)
+ newEvent.mouse.y = aspect2Real(newEvent.mouse.y);
+ }
+ g_system->getEventManager()->pushEvent(newEvent);
+ }
}
+
+#endif
diff --git a/backends/graphics/gph/gph-graphics.h b/backends/graphics/gph/gph-graphics.h
new file mode 100644
index 0000000000..6ba2b344a6
--- /dev/null
+++ b/backends/graphics/gph/gph-graphics.h
@@ -0,0 +1,62 @@
+/* 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.
+ *
+ */
+
+#ifndef BACKENDS_GRAPHICS_GPH_H
+#define BACKENDS_GRAPHICS_GPH_H
+
+#include "backends/graphics/sdl/sdl-graphics.h"
+#include "graphics/scaler/aspect.h" // for aspect2Real
+#include "graphics/scaler/downscaler.h"
+
+enum {
+ GFX_HALF = 12
+};
+
+class GPHGraphicsManager : public SdlGraphicsManager {
+public:
+ GPHGraphicsManager(SdlEventSource *boss);
+
+ bool hasFeature(OSystem::Feature f);
+ void setFeatureState(OSystem::Feature f, bool enable);
+ bool getFeatureState(OSystem::Feature f);
+ int getDefaultGraphicsMode() const;
+
+ void initSize(uint w, uint h);
+ const OSystem::GraphicsMode *getSupportedGraphicsModes() const;
+ bool setGraphicsMode(const char *name);
+ bool setGraphicsMode(int mode);
+ void setGraphicsModeIntern();
+ void internUpdateScreen();
+ void showOverlay();
+ void hideOverlay();
+ bool loadGFXMode();
+ void drawMouse();
+ void undrawMouse();
+ virtual void warpMouse(int x, int y);
+
+ SdlGraphicsManager::MousePos *getMouseCurState();
+ SdlGraphicsManager::VideoState *getVideoMode();
+
+ virtual void adjustMouseEvent(const Common::Event &event);
+};
+
+#endif /* BACKENDS_GRAPHICS_GPH_H */
diff --git a/backends/platform/gph/gph-backend.cpp b/backends/platform/gph/gph-backend.cpp
new file mode 100644
index 0000000000..0432974246
--- /dev/null
+++ b/backends/platform/gph/gph-backend.cpp
@@ -0,0 +1,211 @@
+/* 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.
+ *
+ */
+
+// Disable symbol overrides so that we can use system headers.
+#define FORBIDDEN_SYMBOL_ALLOW_ALL
+
+#include "backends/platform/sdl/sdl-sys.h"
+
+// #include "backends/platform/gph/gph-options.h"
+#include "backends/platform/gph/gph-sdl.h"
+#include "backends/platform/gph/gph-hw.h"
+#include "backends/plugins/posix/posix-provider.h"
+#include "base/main.h"
+
+#include "common/archive.h"
+#include "common/config-manager.h"
+#include "common/debug.h"
+#include "common/events.h"
+#include "common/util.h"
+
+#include "common/file.h"
+#include "base/main.h"
+
+#include "backends/saves/default/default-saves.h"
+
+#include "backends/timer/default/default-timer.h"
+#include "audio/mixer_intern.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <limits.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <time.h> // for getTimeAndDate()
+
+/* Dump console info to files. */
+#define DUMP_STDOUT
+
+void OSystem_GPH::initBackend() {
+
+ // Create the events manager
+ if (_eventSource == 0)
+ _eventSource = new GPHEventSource();
+
+ // Create the graphics manager
+ if (_graphicsManager == 0) {
+ _graphicsManager = new GPHGraphicsManager(_eventSource);
+ }
+
+ /* Setup default save path to be workingdir/saves */
+
+ char savePath[PATH_MAX+1];
+ char workDirName[PATH_MAX+1];
+
+ if (getcwd(workDirName, PATH_MAX) == NULL) {
+ error("Could not obtain current working directory");
+ } else {
+ printf("Current working directory: %s\n", workDirName);
+ }
+
+ strcpy(savePath, workDirName);
+ strcat(savePath, "/saves");
+ printf("Current save directory: %s\n", savePath);
+ struct stat sb;
+ if (stat(savePath, &sb) == -1)
+ if (errno == ENOENT) // Create the dir if it does not exist
+ if (mkdir(savePath, 0755) != 0)
+ warning("mkdir for '%s' failed!", savePath);
+
+ _savefileManager = new DefaultSaveFileManager(savePath);
+
+ #ifdef DUMP_STDOUT
+ // The GP2X Wiz has a serial console on the breakout board but most users do not use this so we
+ // output all our STDOUT and STDERR to files for debug purposes.
+ char STDOUT_FILE[PATH_MAX+1];
+ char STDERR_FILE[PATH_MAX+1];
+
+ strcpy(STDOUT_FILE, workDirName);
+ strcpy(STDERR_FILE, workDirName);
+ 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) {
+ #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) {
+ #if !defined(stderr)
+ stderr = fopen(STDERR_FILE, "w");
+ #else
+ newfp = fopen(STDERR_FILE, "w");
+ if (newfp) {
+ *stderr = *newfp;
+ }
+ #endif
+ }
+
+ setbuf(stderr, NULL);
+ printf("%s\n", "Debug: STDOUT and STDERR redirected to text files.");
+ #endif /* DUMP_STDOUT */
+
+ /* Initialise any GP2X Wiz specific stuff we may want (Batt Status, scaler etc.) */
+ WIZ_HW::deviceInit();
+
+ /* Set Default hardware mixer volume to a preset level (VOLUME_INITIAL). This is done to 'reset' volume level if set by other apps. */
+ WIZ_HW::mixerMoveVolume(0);
+
+ /* Up default volume values as we use a seperate system level volume anyway. */
+ ConfMan.registerDefault("music_volume", 192);
+ ConfMan.registerDefault("sfx_volume", 192);
+ ConfMan.registerDefault("speech_volume", 192);
+
+ /* Trigger autosave every 4 minutes - On low batts 5 mins is about your warning time. */
+ ConfMan.registerDefault("autosave_period", 4 * 60);
+
+ /* Make sure that aspect ratio correction is enabled on the 1st run to stop users asking me what the 'wasted space' is ;-). */
+ ConfMan.registerDefault("aspect_ratio", true);
+
+ /* Make sure SDL knows that we have a joystick we want to use. */
+ ConfMan.setInt("joystick_num", 0);
+
+ /* Now setup any device specific user options (Left handed mode, that sort of thing). */
+ // GPH::setOptions();
+
+ printf("%s\n", "Passing to OSystem::SDL initBackend.");
+
+ /* Pass to POSIX method to do the heavy lifting */
+ OSystem_POSIX::initBackend();
+}
+
+void OSystem_GPH::addSysArchivesToSearchSet(Common::SearchSet &s, int priority) {
+
+ /* Setup default extra data paths for engine data files and plugins */
+ char workDirName[PATH_MAX+1];
+
+ if (getcwd(workDirName, PATH_MAX) == NULL) {
+ error("Error: Could not obtain current working directory");
+ }
+
+ Common::FSNode workdirNode(workDirName);
+ if (workdirNode.exists() && workdirNode.isDirectory()) {
+ s.add("__GP2XWIZ_WORKDIR__", new Common::FSDirectory(workDirName), priority);
+ }
+
+ char enginedataPath[PATH_MAX+1];
+
+ strcpy(enginedataPath, workDirName);
+ strcat(enginedataPath, "/engine-data");
+
+ Common::FSNode engineNode(enginedataPath);
+ if (engineNode.exists() && engineNode.isDirectory()) {
+ s.add("__GP2XWIZ_ENGDATA__", new Common::FSDirectory(enginedataPath), priority);
+ }
+
+ char pluginsPath[PATH_MAX+1];
+
+ strcpy(pluginsPath, workDirName);
+ strcat(pluginsPath, "/plugins");
+
+ Common::FSNode pluginsNode(pluginsPath);
+ if (pluginsNode.exists() && pluginsNode.isDirectory()) {
+ s.add("__GP2XWIZ_PLUGINS__", new Common::FSDirectory(pluginsPath), priority);
+ }
+}
+
+void OSystem_GPH::quit() {
+
+ WIZ_HW::deviceDeinit();
+
+ #ifdef DUMP_STDOUT
+ printf("%s\n", "Debug: STDOUT and STDERR text files closed.");
+ fclose(stdout);
+ fclose(stderr);
+ #endif /* DUMP_STDOUT */
+
+ OSystem_SDL::quit();
+}
diff --git a/backends/platform/gph/gph-main.cpp b/backends/platform/gph/gph-main.cpp
index e711135c15..c7d691fc66 100644
--- a/backends/platform/gph/gph-main.cpp
+++ b/backends/platform/gph/gph-main.cpp
@@ -18,199 +18,34 @@
* 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 "backends/platform/sdl/sdl-sys.h"
-
-// #include "backends/platform/gph/gph-options.h"
#include "backends/platform/gph/gph-sdl.h"
-#include "backends/platform/gph/gph-hw.h"
-#include "backends/plugins/posix/posix-provider.h"
+#include "backends/plugins/sdl/sdl-provider.h"
#include "base/main.h"
-#include "common/archive.h"
-#include "common/config-manager.h"
-#include "common/debug.h"
-#include "common/events.h"
-#include "common/util.h"
-
-#include "common/file.h"
-#include "base/main.h"
-
-#include "backends/saves/default/default-saves.h"
-
-#include "backends/timer/default/default-timer.h"
-#include "audio/mixer_intern.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <limits.h>
-#include <errno.h>
-#include <sys/stat.h>
-#include <time.h> // for getTimeAndDate()
-
-/* Dump console info to files. */
-#define DUMP_STDOUT
+#if defined(GP2XWIZ) || defined(CAANOO)
int main(int argc, char *argv[]) {
+
+ // Create our OSystem instance
g_system = new OSystem_GPH();
assert(g_system);
+
+ // Pre initialize the backend
+ ((OSystem_GPH *)g_system)->init();
+
#ifdef DYNAMIC_MODULES
- PluginManager::instance().addPluginProvider(new POSIXPluginProvider());
+ PluginManager::instance().addPluginProvider(new SDLPluginProvider());
#endif
// Invoke the actual ScummVM main entry point:
int res = scummvm_main(argc, argv);
- g_system->quit();
-
- return res;
-}
-
-void OSystem_GPH::initBackend() {
-
- /* Setup default save path to be workingdir/saves */
-
- char savePath[PATH_MAX+1];
- char workDirName[PATH_MAX+1];
-
- if (getcwd(workDirName, PATH_MAX) == NULL) {
- error("Could not obtain current working directory");
- } else {
- printf("Current working directory: %s\n", workDirName);
- }
-
- strcpy(savePath, workDirName);
- strcat(savePath, "/saves");
- printf("Current save directory: %s\n", savePath);
- struct stat sb;
- if (stat(savePath, &sb) == -1)
- if (errno == ENOENT) // Create the dir if it does not exist
- if (mkdir(savePath, 0755) != 0)
- warning("mkdir for '%s' failed!", savePath);
-
- _savefile = new DefaultSaveFileManager(savePath);
-
- #ifdef DUMP_STDOUT
- // The GP2X Wiz has a serial console on the breakout board but most users do not use this so we
- // output all our STDOUT and STDERR to files for debug purposes.
- char STDOUT_FILE[PATH_MAX+1];
- char STDERR_FILE[PATH_MAX+1];
-
- strcpy(STDOUT_FILE, workDirName);
- strcpy(STDERR_FILE, workDirName);
- 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) {
- #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) {
- #if !defined(stderr)
- stderr = fopen(STDERR_FILE, "w");
- #else
- newfp = fopen(STDERR_FILE, "w");
- if (newfp) {
- *stderr = *newfp;
- }
- #endif
- }
- setbuf(stderr, NULL);
- printf("%s\n", "Debug: STDOUT and STDERR redirected to text files.");
- #endif /* DUMP_STDOUT */
+ // Free OSystem
+ delete (OSystem_GPH *)g_system;
- /* Initialise any GP2X Wiz specific stuff we may want (Batt Status, scaler etc.) */
- WIZ_HW::deviceInit();
-
- /* Set Default hardware mixer volume to a preset level (VOLUME_INITIAL). This is done to 'reset' volume level if set by other apps. */
- WIZ_HW::mixerMoveVolume(0);
-
- /* Up default volume values as we use a seperate system level volume anyway. */
- ConfMan.registerDefault("music_volume", 192);
- ConfMan.registerDefault("sfx_volume", 192);
- ConfMan.registerDefault("speech_volume", 192);
-
- /* Trigger autosave every 4 minutes - On low batts 5 mins is about your warning time. */
- ConfMan.registerDefault("autosave_period", 4 * 60);
-
- /* Make sure that aspect ratio correction is enabled on the 1st run to stop users asking me what the 'wasted space' is ;-). */
- ConfMan.registerDefault("aspect_ratio", true);
-
- /* Make sure SDL knows that we have a joystick we want to use. */
- ConfMan.setInt("joystick_num", 0);
-
- /* Now setup any device specific user options (Left handed mode, that sort of thing). */
- // GPH::setOptions();
-
- printf("%s\n", "Passing to OSystem::SDL initBackend.");
-
- /* Pass to SDL backend to do the heavy lifting */
- OSystem_SDL::initBackend();
-}
-
-void OSystem_GPH::addSysArchivesToSearchSet(Common::SearchSet &s, int priority) {
-
- /* Setup default extra data paths for engine data files and plugins */
- char workDirName[PATH_MAX+1];
-
- if (getcwd(workDirName, PATH_MAX) == NULL) {
- error("Error: Could not obtain current working directory");
- }
-
- Common::FSNode workdirNode(workDirName);
- if (workdirNode.exists() && workdirNode.isDirectory()) {
- s.add("__GP2XWIZ_WORKDIR__", new Common::FSDirectory(workDirName), priority);
- }
-
- char enginedataPath[PATH_MAX+1];
-
- strcpy(enginedataPath, workDirName);
- strcat(enginedataPath, "/engine-data");
-
- Common::FSNode engineNode(enginedataPath);
- if (engineNode.exists() && engineNode.isDirectory()) {
- s.add("__GP2XWIZ_ENGDATA__", new Common::FSDirectory(enginedataPath), priority);
- }
-
- char pluginsPath[PATH_MAX+1];
-
- strcpy(pluginsPath, workDirName);
- strcat(pluginsPath, "/plugins");
-
- Common::FSNode pluginsNode(pluginsPath);
- if (pluginsNode.exists() && pluginsNode.isDirectory()) {
- s.add("__GP2XWIZ_PLUGINS__", new Common::FSDirectory(pluginsPath), priority);
- }
+ return res;
}
-void OSystem_GPH::quit() {
-
- WIZ_HW::deviceDeinit();
-
- #ifdef DUMP_STDOUT
- printf("%s\n", "Debug: STDOUT and STDERR text files closed.");
- fclose(stdout);
- fclose(stderr);
- #endif /* DUMP_STDOUT */
-
- OSystem_SDL::quit();
-}
+#endif
diff --git a/backends/platform/gph/gph-sdl.h b/backends/platform/gph/gph-sdl.h
index 136363f9a0..ef696bc3d8 100644
--- a/backends/platform/gph/gph-sdl.h
+++ b/backends/platform/gph/gph-sdl.h
@@ -18,20 +18,18 @@
* 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 GPH_SDL_H
-#define GPH_SDL_H
+#ifndef GPH_H
+#define GPH_H
-#include "backends/platform/sdl/sdl.h"
+#if defined(GP2XWIZ) || defined(CAANOO)
-// FIXME: For now keep hacks in this header to save polluting the SDL backend.
-enum {
- GFX_HALF = 12
-};
+#include "backends/base-backend.h"
+#include "backends/platform/sdl/sdl.h"
+#include "backends/platform/sdl/posix/posix.h"
+#include "backends/graphics/gph/gph-graphics.h"
+#include "backends/events/gph/gph-events.h"
#define __GP2XWIZ__
#define MIXER_DOUBLE_BUFFERING 1
@@ -40,42 +38,13 @@ enum {
#define PATH_MAX 255
#endif
-class OSystem_GPH : public OSystem_SDL {
+class OSystem_GPH : public OSystem_POSIX {
public:
- OSystem_GPH() {}
-
- /* Graphics */
- void initSize(uint w, uint h);
- void setGraphicsModeIntern();
- bool setGraphicsMode(int mode);
- void internUpdateScreen();
- const OSystem::GraphicsMode *getSupportedGraphicsModes() const;
- bool setGraphicsMode(const char *name);
- int getDefaultGraphicsMode() const;
- bool loadGFXMode();
- void drawMouse();
- void undrawMouse();
- void showOverlay();
- void hideOverlay();
-
- /* Event Stuff */
- void moveStick();
- void fillMouseEvent(Common::Event&, int, int);
- void warpMouse(int, int);
- bool remapKey(SDL_Event&, Common::Event&);
-
/* Platform Setup Stuff */
void addSysArchivesToSearchSet(Common::SearchSet &s, int priority);
void initBackend();
void quit();
-
-protected:
- bool _stickBtn[32];
-
- bool handleMouseButtonDown(SDL_Event &ev, Common::Event &event);
- bool handleMouseButtonUp(SDL_Event &ev, Common::Event &event);
- bool handleJoyButtonDown(SDL_Event &ev, Common::Event &event);
- bool handleJoyButtonUp(SDL_Event &ev, Common::Event &event);
};
-#endif //GPH_SDL_H
+#endif
+#endif //GPH_H
diff --git a/backends/platform/gph/module.mk b/backends/platform/gph/module.mk
index f5567f581e..a9951494d1 100644
--- a/backends/platform/gph/module.mk
+++ b/backends/platform/gph/module.mk
@@ -1,10 +1,9 @@
MODULE := backends/platform/gph
MODULE_OBJS := \
- gph-events.o \
- gph-graphics.o \
- gph-hw.o \
- gph-main.o
+ gph-main.o \
+ gph-backend.o \
+ gph-hw.o
# We don't use rules.mk but rather manually update OBJS and MODULE_DIRS.
MODULE_OBJS := $(addprefix $(MODULE)/, $(MODULE_OBJS))