[Scummvm-cvs-logs] SF.net SVN: scummvm: [24507] scummvm/trunk/backends/platform/gp2x
djwillis at users.sourceforge.net
djwillis at users.sourceforge.net
Wed Oct 25 21:51:55 CEST 2006
Revision: 24507
http://svn.sourceforge.net/scummvm/?rev=24507&view=rev
Author: djwillis
Date: 2006-10-25 12:51:47 -0700 (Wed, 25 Oct 2006)
Log Message:
-----------
Update GP2X port to support Fingolfin's ongoing implementation of the Modular Backends ideas :). Also add a few updates from my local tree (Batt level checking and STDOUT/STDERR file mapping code stolen from the Symbian backend (thanks)).
Modified Paths:
--------------
scummvm/trunk/backends/platform/gp2x/build/bundle.sh
scummvm/trunk/backends/platform/gp2x/gp2x-common.h
scummvm/trunk/backends/platform/gp2x/gp2x-hw.cpp
scummvm/trunk/backends/platform/gp2x/gp2x-hw.h
scummvm/trunk/backends/platform/gp2x/gp2x.cpp
Modified: scummvm/trunk/backends/platform/gp2x/build/bundle.sh
===================================================================
--- scummvm/trunk/backends/platform/gp2x/build/bundle.sh 2006-10-25 19:37:43 UTC (rev 24506)
+++ scummvm/trunk/backends/platform/gp2x/build/bundle.sh 2006-10-25 19:51:47 UTC (rev 24507)
@@ -11,20 +11,25 @@
echo Collecting files.
mkdir "scummvm-gp2x-`date '+%Y-%m-%d'`"
+mkdir "scummvm-gp2x-`date '+%Y-%m-%d'`\saves"
+echo "Please put your save games in this dir" >> "scummvm-gp2x-`date '+%Y-%m-%d'`\saves\PUT_SAVES_IN_THIS_DIR"
+
+cp ./scummvm.gpe ./scummvm-gp2x-`date '+%Y-%m-%d'`/
cp ./scummvm.png ./scummvm-gp2x-`date '+%Y-%m-%d'`/
cp ./README-GP2X.html ./scummvm-gp2x-`date '+%Y-%m-%d'`/
cp ./README-GP2X ./scummvm-gp2x-`date '+%Y-%m-%d'`/
-cp ../../../../scummvm.gpe ./scummvm-gp2x-`date '+%Y-%m-%d'`/
+cp ../../../../scummvm.gp2x ./scummvm-gp2x-`date '+%Y-%m-%d'`/
cp ../../../../AUTHORS ./scummvm-gp2x-`date '+%Y-%m-%d'`/
cp ../../../../README ./scummvm-gp2x-`date '+%Y-%m-%d'`/
cp ../../../../COPYING ./scummvm-gp2x-`date '+%Y-%m-%d'`/
+cp ../../../../NEWS ./scummvm-gp2x-`date '+%Y-%m-%d'`/
cp ../../../../gui/themes/modern.ini ./scummvm-gp2x-`date '+%Y-%m-%d'`/
cp ../../../../gui/themes/modern.zip ./scummvm-gp2x-`date '+%Y-%m-%d'`/
echo Making Stripped GPE.
-arm-open2x-linux-strip ./scummvm-gp2x-`date '+%Y-%m-%d'`/scummvm.gpe
+arm-open2x-linux-strip ./scummvm-gp2x-`date '+%Y-%m-%d'`/scummvm.gp2x
echo Building ZIP bundle.
echo You should have a "scummvm-gp2x-`date '+%Y-%m-%d'`.zip" for the GP2X port ready to go.
\ No newline at end of file
Modified: scummvm/trunk/backends/platform/gp2x/gp2x-common.h
===================================================================
--- scummvm/trunk/backends/platform/gp2x/gp2x-common.h 2006-10-25 19:37:43 UTC (rev 24506)
+++ scummvm/trunk/backends/platform/gp2x/gp2x-common.h 2006-10-25 19:51:47 UTC (rev 24507)
@@ -37,6 +37,15 @@
#include <SDL.h>
#include <SDL_gp2x.h>
+namespace Audio {
+ class Mixer;
+}
+
+namespace Common {
+ class SaveFileManager;
+ class TimerManager;
+}
+
//#define DISABLE_SCALERS
enum {
@@ -123,7 +132,9 @@
virtual bool pollEvent(Event &event); // overloaded by CE backend
// Set function that generates samples
+ typedef void (*SoundProc)(void *param, byte *buf, int len);
virtual bool setSoundCallback(SoundProc proc, void *param); // overloaded by CE backend
+ virtual Audio::Mixer *getMixer();
void clearSoundCallback();
@@ -143,10 +154,8 @@
// Quit
virtual void quit(); // overloaded by CE backend
+ virtual Common::TimerManager *getTimerManager();
- // Add a callback timer
- void setTimerCallback(TimerProc callback, int timer);
-
// Mutex handling
MutexRef createMutex();
void lockMutex(MutexRef mutex);
@@ -184,6 +193,8 @@
void displayMessageOnOSD(const char *msg);
+ virtual Common::SaveFileManager *getSavefileManager();
+
protected:
bool _inited;
@@ -326,11 +337,8 @@
byte *_mouseData;
SDL_Rect _mouseBackup;
MousePos _mouseCurState;
- //int16 _mouseHotspotX;
- //int16 _mouseHotspotY;
byte _mouseKeyColor;
int _cursorTargetScale;
- //bool _cursorHasOwnPalette;
bool _cursorPaletteDisabled;
SDL_Surface *_mouseOrigSurface;
SDL_Surface *_mouseSurface;
@@ -359,7 +367,12 @@
*/
MutexRef _graphicsMutex;
+ Common::SaveFileManager *_savefile;
+ Audio::Mixer *_mixer;
+ SDL_TimerID _timerID;
+ Common::TimerManager *_timer;
+
void addDirtyRgnAuto(const byte *buf);
void makeChecksums(const byte *buf);
Modified: scummvm/trunk/backends/platform/gp2x/gp2x-hw.cpp
===================================================================
--- scummvm/trunk/backends/platform/gp2x/gp2x-hw.cpp 2006-10-25 19:37:43 UTC (rev 24506)
+++ scummvm/trunk/backends/platform/gp2x/gp2x-hw.cpp 2006-10-25 19:51:47 UTC (rev 24507)
@@ -37,6 +37,9 @@
#include <sys/mman.h>
#include <sys/ioctl.h>
#include <sys/soundcard.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
static unsigned long gp2x_dev[8]={0,0,0,0,0,0,0,0};//, gp2x_ticks_per_second;
static volatile unsigned short *gp2x_memregs;
@@ -138,6 +141,15 @@
set_920_Div(0);
}
+int GP2X_getBattLevel() {
+ int devbatt;
+ unsigned short currentval=0;
+ devbatt = open("/dev/batt", O_RDONLY);
+ read (devbatt, ¤tval, 2);
+ close (devbatt);
+ return (currentval);
+}
+
void set_display_clock_div(unsigned div)
{
div=((div & 63) | 64)<<8;
Modified: scummvm/trunk/backends/platform/gp2x/gp2x-hw.h
===================================================================
--- scummvm/trunk/backends/platform/gp2x/gp2x-hw.h 2006-10-25 19:37:43 UTC (rev 24506)
+++ scummvm/trunk/backends/platform/gp2x/gp2x-hw.h 2006-10-25 19:51:47 UTC (rev 24507)
@@ -62,7 +62,9 @@
extern int GP2X_mixer_get_volume();
extern void GP2X_mixer_move_volume(int);
extern void GP2X_setCpuspeed(unsigned int cpuspeed);
+extern int GP2X_getBattLevel();
+
extern void save_system_regs(void); /* save some registers */
extern void set_display_clock_div(unsigned div);
extern void set_FCLK(unsigned MHZ); /* adjust the clock frequency (in Mhz units) */
Modified: scummvm/trunk/backends/platform/gp2x/gp2x.cpp
===================================================================
--- scummvm/trunk/backends/platform/gp2x/gp2x.cpp 2006-10-25 19:37:43 UTC (rev 24506)
+++ scummvm/trunk/backends/platform/gp2x/gp2x.cpp 2006-10-25 19:51:47 UTC (rev 24507)
@@ -34,6 +34,11 @@
#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 "sound/mixer.h"
+
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@@ -41,10 +46,18 @@
#include <errno.h>
#include <sys/stat.h>
+// Disable for normal serial logging.
+#define DUMP_STDOUT
+
#if defined(HAVE_CONFIG_H)
#include "config.h"
#endif
+static Uint32 timer_handler(Uint32 interval, void *param) {
+ ((DefaultTimerManager *)param)->handler();
+ return interval;
+}
+
int main(int argc, char *argv[]) {
// Setup GP2X upper 32MB caching
@@ -82,8 +95,6 @@
error("Could not initialize SDL: %s", SDL_GetError());
}
- // TODO: Clean way of flushing the file on every write without resorting to this or hacking the POSIX FS code.
- //system("/bin/mount -t vfat -o remount,sync,iocharset=utf8 /dev/mmcsd/disc0/part1 /mnt/sd");
// Setup default save path to be workingdir/saves
#ifndef PATH_MAX
@@ -109,6 +120,49 @@
ConfMan.registerDefault("savepath", savePath);
+ // Note: Review and clean this, it's OTT at the moment.
+
+ #if defined(DUMP_STDOUT)
+ // The GP2X has a serial console 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) { /* 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 */
+ #endif // DUMP_STDOUT
+
// Setup other defaults.
ConfMan.registerDefault("aspect_ratio", true);
@@ -145,6 +199,33 @@
SDL_ShowCursor(SDL_DISABLE);
+ // Create the savefile manager, if none exists yet (we check for this to
+ // allow subclasses to provide their own).
+ if (_savefile == 0) {
+ _savefile = new DefaultSaveFileManager();
+ }
+
+ // Create and hook up the mixer, if none exists yet (we check for this to
+ // allow subclasses to provide their own).
+ if (_mixer == 0) {
+ _mixer = new Audio::Mixer();
+ setSoundCallback(Audio::Mixer::mixCallback, _mixer);
+ }
+
+ // Create and hook up the timer manager, if none exists yet (we check for
+ // this to allow subclasses to provide their own).
+ if (_timer == 0) {
+ // TODO: We could implement a custom SDLTimerManager by using
+ // SDL_AddTimer. That might yield better timer resolution, but it would
+ // also change the semantics of a timer: Right now, ScummVM timers
+ // *never* run in parallel, due to the way they are implemented. If we
+ // switched to SDL_AddTimer, each timer might run in a separate thread.
+ // Unfortunately, not all our code is prepared for that, so we can't just
+ // switch. But it's a long term goal to do just that!
+ _timer = new DefaultTimerManager();
+ _timerID = SDL_AddTimer(10, &timer_handler, _timer);
+ }
+
OSystem::initBackend();
_inited = true;
@@ -164,6 +245,9 @@
_joystick(0),
_currentShakePos(0), _newShakePos(0),
_paletteDirtyStart(0), _paletteDirtyEnd(0),
+ _savefile(0),
+ _mixer(0),
+ _timer(0),
_graphicsMutex(0), _transactionMode(kTransactionNone) {
// allocate palette storage
@@ -180,10 +264,17 @@
}
OSystem_GP2X::~OSystem_GP2X() {
+ SDL_RemoveTimer(_timerID);
+ SDL_CloseAudio();
+
free(_dirtyChecksums);
free(_currentPalette);
free(_cursorPalette);
free(_mouseData);
+
+ delete _savefile;
+ delete _mixer;
+ delete _timer;
}
uint32 OSystem_GP2X::getMillis() {
@@ -194,10 +285,20 @@
SDL_Delay(msecs);
}
-void OSystem_GP2X::setTimerCallback(TimerProc callback, int timer) {
- SDL_SetTimer(timer, (SDL_TimerCallback) callback);
+Common::TimerManager *OSystem_GP2X::getTimerManager() {
+ assert(_timer);
+ return _timer;
}
+Common::SaveFileManager *OSystem_GP2X::getSavefileManager() {
+ assert(_savefile);
+ return _savefile;
+}
+
+//void OSystem_GP2X::setTimerCallback(TimerProc callback, int timer) {
+// SDL_SetTimer(timer, (SDL_TimerCallback) callback);
+//}
+
bool OSystem_GP2X::hasFeature(Feature f) {
return
(f == kFeatureFullscreenMode) ||
@@ -250,8 +351,9 @@
//CloseRam();
GP2X_device_deinit();
SDL_Quit();
- chdir("/usr/gp2x");
- execl("/usr/gp2x/gp2xmenu", "/usr/gp2x/gp2xmenu", NULL);
+ //chdir("/usr/gp2x");
+ //execl("/usr/gp2x/gp2xmenu", "/usr/gp2x/gp2xmenu", NULL);
+ exit(0);
}
OSystem::MutexRef OSystem_GP2X::createMutex(void) {
@@ -315,6 +417,11 @@
return _samplesPerSec;
}
+Audio::Mixer *OSystem_GP2X::getMixer() {
+ assert(_mixer);
+ return _mixer;
+}
+
#pragma mark -
#pragma mark --- CD Audio ---
#pragma mark -
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