[Scummvm-cvs-logs] SF.net SVN: scummvm: [31515] scummvm/trunk/backends/platform/gp2x

djwillis at users.sourceforge.net djwillis at users.sourceforge.net
Wed Apr 16 14:51:56 CEST 2008


Revision: 31515
          http://scummvm.svn.sourceforge.net/scummvm/?rev=31515&view=rev
Author:   djwillis
Date:     2008-04-16 05:51:56 -0700 (Wed, 16 Apr 2008)

Log Message:
-----------
Small cleanup of the GP2X backend. Still a few odd things I need to glance at (like it is not working ;-)).

Modified Paths:
--------------
    scummvm/trunk/backends/platform/gp2x/events.cpp
    scummvm/trunk/backends/platform/gp2x/gp2x-common.h
    scummvm/trunk/backends/platform/gp2x/gp2x.cpp

Modified: scummvm/trunk/backends/platform/gp2x/events.cpp
===================================================================
--- scummvm/trunk/backends/platform/gp2x/events.cpp	2008-04-16 12:24:09 UTC (rev 31514)
+++ scummvm/trunk/backends/platform/gp2x/events.cpp	2008-04-16 12:51:56 UTC (rev 31515)
@@ -308,33 +308,6 @@
 		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 @@
 						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 @@
 					//	}
 					//	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 @@
 						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;

Modified: scummvm/trunk/backends/platform/gp2x/gp2x-common.h
===================================================================
--- scummvm/trunk/backends/platform/gp2x/gp2x-common.h	2008-04-16 12:24:09 UTC (rev 31514)
+++ scummvm/trunk/backends/platform/gp2x/gp2x-common.h	2008-04-16 12:51:56 UTC (rev 31515)
@@ -148,9 +148,9 @@
 	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 @@
 	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 @@
 	MutexRef _graphicsMutex;
 
 	Common::SaveFileManager *_savefile;
+	FilesystemFactory *getFilesystemFactory();
+
 	Audio::Mixer *_mixer;
 
 	SDL_TimerID _timerID;
@@ -396,7 +398,7 @@
 
 	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; }
 

Modified: scummvm/trunk/backends/platform/gp2x/gp2x.cpp
===================================================================
--- scummvm/trunk/backends/platform/gp2x/gp2x.cpp	2008-04-16 12:24:09 UTC (rev 31514)
+++ scummvm/trunk/backends/platform/gp2x/gp2x.cpp	2008-04-16 12:51:56 UTC (rev 31515)
@@ -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,18 +57,28 @@
 #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();
 	return interval;
 }
 
 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 @@
 
 	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 @@
 
 	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 @@
 	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 @@
 		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);
 }
 


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