aboutsummaryrefslogtreecommitdiff
path: root/backends
diff options
context:
space:
mode:
authorJohn Willis2008-04-16 12:51:56 +0000
committerJohn Willis2008-04-16 12:51:56 +0000
commit888eb26f8b372b355dc34a231a2d2dcf9e6e8dd4 (patch)
treeef652f2ba32bb27a4e6e271bc673327b9feb277c /backends
parentee89c3000bbc7cc762edcc9abd9412703e464fbf (diff)
downloadscummvm-rg350-888eb26f8b372b355dc34a231a2d2dcf9e6e8dd4.tar.gz
scummvm-rg350-888eb26f8b372b355dc34a231a2d2dcf9e6e8dd4.tar.bz2
scummvm-rg350-888eb26f8b372b355dc34a231a2d2dcf9e6e8dd4.zip
Small cleanup of the GP2X backend. Still a few odd things I need to glance at (like it is not working ;-)).
svn-id: r31515
Diffstat (limited to 'backends')
-rw-r--r--backends/platform/gp2x/events.cpp56
-rw-r--r--backends/platform/gp2x/gp2x-common.h26
-rw-r--r--backends/platform/gp2x/gp2x.cpp67
3 files changed, 84 insertions, 65 deletions
diff --git a/backends/platform/gp2x/events.cpp b/backends/platform/gp2x/events.cpp
index b68c2619cc..bf3e331edd 100644
--- a/backends/platform/gp2x/events.cpp
+++ b/backends/platform/gp2x/events.cpp
@@ -308,33 +308,6 @@ bool OSystem_GP2X::pollEvent(Common::Event &event) {
case SDL_KEYDOWN:{
b = event.kbd.flags = SDLModToOSystemKeyFlags(SDL_GetModState());
- // Alt-Return and Alt-Enter toggle full screen mode
- if (b == Common::KBD_ALT && (ev.key.keysym.sym == SDLK_RETURN
- || ev.key.keysym.sym == SDLK_KP_ENTER)) {
- setFullscreenMode(!_fullscreen);
- break;
- }
-
- // Alt-S: Create a screenshot
- if (b == Common::KBD_ALT && ev.key.keysym.sym == 's') {
- char filename[20];
-
- for (int n = 0;; n++) {
- SDL_RWops *file;
-
- sprintf(filename, "scummvm%05d.bmp", n);
- file = SDL_RWFromFile(filename, "r");
- if (!file)
- break;
- SDL_RWclose(file);
- }
- if (saveScreenshot(filename))
- printf("Saved '%s'\n", filename);
- else
- printf("Could not save screenshot!\n");
- break;
- }
-
const bool event_complete = remapKey(ev,event);
if (event_complete)
@@ -452,9 +425,6 @@ bool OSystem_GP2X::pollEvent(Common::Event &event) {
event.kbd.keycode = Common::KEYCODE_PERIOD;
event.kbd.ascii = mapKey(SDLK_PERIOD, ev.key.keysym.mod, 0);
}
-// event.kbd.keycode = Common::KEYCODE_PERIOD;
-// event.kbd.ascii = mapKey(SDLK_PERIOD, ev.key.keysym.mod, 0);
-
break;
case GP2X_BUTTON_Y:
if (GP2X_BUTTON_STATE_L == TRUE) {
@@ -491,27 +461,29 @@ bool OSystem_GP2X::pollEvent(Common::Event &event) {
// }
// break;
case GP2X_BUTTON_VOLUP:
- if (GP2X_BUTTON_STATE_L == TRUE) {
- displayMessageOnOSD("Setting CPU Speed at 230MHz");
- GP2X_setCpuspeed(200);
+ //if (GP2X_BUTTON_STATE_L == TRUE) {
+ // displayMessageOnOSD("Setting CPU Speed at 230MHz");
+ // GP2X_setCpuspeed(200);
//event.kbd.keycode = Common::KEYCODE_PLUS;
//event.kbd.ascii = mapKey(SDLK_PLUS, ev.key.keysym.mod, 0);
- } else {
+ //} else {
GP2X_mixer_move_volume(1);
displayMessageOnOSD("Increasing Volume");
- }
+ //}
break;
+
case GP2X_BUTTON_VOLDOWN:
- if (GP2X_BUTTON_STATE_L == TRUE) {
- displayMessageOnOSD("Setting CPU Speed at 60MHz");
- GP2X_setCpuspeed(60);
+ //if (GP2X_BUTTON_STATE_L == TRUE) {
+ // displayMessageOnOSD("Setting CPU Speed at 60MHz");
+ // GP2X_setCpuspeed(60);
//event.kbd.keycode = Common::KEYCODE_MINUS;
//event.kbd.ascii = mapKey(SDLK_MINUS, ev.key.keysym.mod, 0);
- } else {
+ //} else {
GP2X_mixer_move_volume(0);
displayMessageOnOSD("Decreasing Volume");
- }
+ //}
break;
+
}
}
return true;
@@ -541,8 +513,8 @@ bool OSystem_GP2X::pollEvent(Common::Event &event) {
event.kbd.ascii = mapKey(SDLK_PERIOD, ev.key.keysym.mod, 0);
break;
case GP2X_BUTTON_Y:
-// event.kbd.keycode = Common::KEYCODE_SPACE;
-// event.kbd.ascii = mapKey(SDLK_SPACE, ev.key.keysym.mod, 0);
+ event.kbd.keycode = Common::KEYCODE_SPACE;
+ event.kbd.ascii = mapKey(SDLK_SPACE, ev.key.keysym.mod, 0);
break;
case GP2X_BUTTON_START:
event.kbd.keycode = Common::KEYCODE_RETURN;
diff --git a/backends/platform/gp2x/gp2x-common.h b/backends/platform/gp2x/gp2x-common.h
index 7f70f2d301..e8e128a249 100644
--- a/backends/platform/gp2x/gp2x-common.h
+++ b/backends/platform/gp2x/gp2x-common.h
@@ -148,9 +148,9 @@ public:
void updateCD();
// Quit
- virtual void quit(); // overloaded by CE backend
+ void quit();
- virtual void getTimeAndDate(struct tm &t) const;
+ void getTimeAndDate(struct tm &t) const;
virtual Common::TimerManager *getTimerManager();
// Mutex handling
@@ -175,17 +175,17 @@ public:
void colorToRGB(OverlayColor color, uint8 &r, uint8 &g, uint8 &b);
- virtual const GraphicsMode *getSupportedGraphicsModes() const;
- virtual int getDefaultGraphicsMode() const;
- virtual bool setGraphicsMode(int mode);
- virtual int getGraphicsMode() const;
+ const GraphicsMode *getSupportedGraphicsModes() const;
+ int getDefaultGraphicsMode() const;
+ bool setGraphicsMode(int mode);
+ int getGraphicsMode() const;
- virtual bool openCD(int drive);
- virtual int getOutputSampleRate() const;
+ bool openCD(int drive);
+ int getOutputSampleRate() const;
- virtual bool hasFeature(Feature f);
- virtual void setFeatureState(Feature f, bool enable);
- virtual bool getFeatureState(Feature f);
+ bool hasFeature(Feature f);
+ void setFeatureState(Feature f, bool enable);
+ bool getFeatureState(Feature f);
void displayMessageOnOSD(const char *msg);
@@ -367,6 +367,8 @@ protected:
MutexRef _graphicsMutex;
Common::SaveFileManager *_savefile;
+ FilesystemFactory *getFilesystemFactory();
+
Audio::Mixer *_mixer;
SDL_TimerID _timerID;
@@ -396,7 +398,7 @@ protected:
void setZoomOnMouse(); // GP2X: On > 240 high games zooms on the mouse + radius.
- virtual bool saveScreenshot(const char *filename);
+ bool saveScreenshot(const char *filename);
int effectiveScreenHeight() const { return (_adjustAspectRatio ? 240 : _screenHeight) * _scaleFactor; }
diff --git a/backends/platform/gp2x/gp2x.cpp b/backends/platform/gp2x/gp2x.cpp
index 3ebb982921..06c28d8f99 100644
--- a/backends/platform/gp2x/gp2x.cpp
+++ b/backends/platform/gp2x/gp2x.cpp
@@ -32,12 +32,14 @@
#include "backends/platform/gp2x/gp2x-hw.h"
#include "backends/platform/gp2x/gp2x-mem.h"
#include "common/config-manager.h"
+#include "common/file.h"
#include "common/util.h"
#include "base/main.h"
#include "backends/saves/default/default-saves.h"
#include "backends/timer/default/default-timer.h"
#include "backends/plugins/posix/posix-provider.h"
+#include "backends/fs/posix/posix-fs-factory.h" // for getFilesystemFactory()
#include "sound/mixer.h"
#include <stdio.h>
@@ -46,7 +48,7 @@
#include <limits.h>
#include <errno.h>
#include <sys/stat.h>
-#include <time.h>
+#include <time.h> // for getTimeAndDate()
// Disable for normal serial logging.
#define DUMP_STDOUT
@@ -55,7 +57,11 @@
#include "config.h"
#endif
-#define SAMPLES_PER_SEC 11025
+#define SAMPLES_PER_SEC 11025
+//#define SAMPLES_PER_SEC 22050
+//#define SAMPLES_PER_SEC 44100
+
+
static Uint32 timer_handler(Uint32 interval, void *param) {
((DefaultTimerManager *)param)->handler();
@@ -63,10 +69,16 @@ static Uint32 timer_handler(Uint32 interval, void *param) {
}
int main(int argc, char *argv[]) {
- extern OSystem *OSystem_GP2X_create();
- g_system = OSystem_GP2X_create();
+ //extern OSystem *OSystem_GP2X_create();
+ //g_system = OSystem_GP2X_create();
+ g_system = new OSystem_GP2X();
assert(g_system);
+ // Check if Plugins are enabled (Using the hacked up GP2X provider)
+ #ifdef DYNAMIC_MODULES
+ PluginManager::instance().addPluginProvider(new GP2XPluginProvider());
+ #endif
+
// Invoke the actual ScummVM main entry point:
int res = scummvm_main(argc, argv);
g_system->quit();
@@ -82,13 +94,13 @@ void OSystem_GP2X::initBackend() {
ConfMan.setInt("joystick_num", 0);
int joystick_num = ConfMan.getInt("joystick_num");
- uint32 sdlFlags = SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER;
+ uint32 sdlFlags = SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER | SDL_INIT_EVENTTHREAD;
- if (ConfMan.hasKey("disable_sdl_parachute"))
- sdlFlags |= SDL_INIT_NOPARACHUTE;
+ //if (ConfMan.hasKey("disable_sdl_parachute"))
+ // sdlFlags |= SDL_INIT_NOPARACHUTE;
- if (joystick_num > -1)
- sdlFlags |= SDL_INIT_JOYSTICK;
+ //if (joystick_num > -1)
+ // sdlFlags |= SDL_INIT_JOYSTICK;
if (SDL_Init(sdlFlags) == -1) {
error("Could not initialize SDL: %s", SDL_GetError());
@@ -120,6 +132,21 @@ void OSystem_GP2X::initBackend() {
ConfMan.registerDefault("savepath", savePath);
+ // Setup default extra data path for engine data files to be workingdir/engine-data
+
+ char enginedataPath[PATH_MAX+1];
+
+ strcpy(enginedataPath, workDirName);
+ strcat(enginedataPath, "/engine-data");
+ printf("Current engine-data directory: %s\n", enginedataPath);
+ //struct stat sb;
+ if (stat(enginedataPath, &sb) == -1)
+ if (errno == ENOENT) // Create the dir if it does not exist
+ if (mkdir(enginedataPath, 0755) != 0)
+ warning("mkdir for '%s' failed!", enginedataPath);
+
+ Common::File::addDefaultDirectory(enginedataPath);
+
// Note: Review and clean this, it's OTT at the moment.
#if defined(DUMP_STDOUT)
@@ -316,6 +343,10 @@ Common::SaveFileManager *OSystem_GP2X::getSavefileManager() {
return _savefile;
}
+FilesystemFactory *OSystem_GP2X::getFilesystemFactory() {
+ return &POSIXFilesystemFactory::instance();
+}
+
//void OSystem_GP2X::setTimerCallback(TimerProc callback, int timer) {
// SDL_SetTimer(timer, (SDL_TimerCallback) callback);
//}
@@ -374,9 +405,23 @@ void OSystem_GP2X::quit() {
SDL_JoystickClose(_joystick);
//CloseRam();
GP2X_device_deinit();
+
+ SDL_RemoveTimer(_timerID);
+ SDL_CloseAudio();
+
+ free(_dirtyChecksums);
+ free(_currentPalette);
+ free(_cursorPalette);
+ free(_mouseData);
+
+ delete _savefile;
+ delete _mixer;
+ delete _timer;
+
SDL_Quit();
- //chdir("/usr/gp2x");
- //execl("/usr/gp2x/gp2xmenu", "/usr/gp2x/gp2xmenu", NULL);
+
+ delete getEventManager();
+
exit(0);
}