diff options
author | Andre Heider | 2010-09-05 15:26:00 +0000 |
---|---|---|
committer | Andre Heider | 2010-09-05 15:26:00 +0000 |
commit | 09834b8bec5fdaf24719988376debf8671518846 (patch) | |
tree | fd25fc6b22f8935d4ccd30c122c972106b6ca52a /backends | |
parent | 402c71860f0a6f254604b1fbd1a763d470c859c0 (diff) | |
parent | 13e24af0cace8599d31c8bb7381fa9fce49a8e6e (diff) | |
download | scummvm-rg350-09834b8bec5fdaf24719988376debf8671518846.tar.gz scummvm-rg350-09834b8bec5fdaf24719988376debf8671518846.tar.bz2 scummvm-rg350-09834b8bec5fdaf24719988376debf8671518846.zip |
MERGE: Merge trunk to branch.
svn-id: r52564
Diffstat (limited to 'backends')
40 files changed, 1621 insertions, 329 deletions
diff --git a/backends/fs/psp/psp-fs.cpp b/backends/fs/psp/psp-fs.cpp index d72c5108dd..4857a385b7 100644 --- a/backends/fs/psp/psp-fs.cpp +++ b/backends/fs/psp/psp-fs.cpp @@ -247,11 +247,19 @@ AbstractFSNode *PSPFilesystemNode::getParent() const { } Common::SeekableReadStream *PSPFilesystemNode::createReadStream() { - return PSPIoStream::makeFromPath(getPath(), false); + const uint32 READ_BUFFER_SIZE = 1024; + + Common::SeekableReadStream *stream = PspIoStream::makeFromPath(getPath(), false); + + return new PspIoBufferedReadStream(stream, READ_BUFFER_SIZE, DisposeAfterUse::YES); } Common::WriteStream *PSPFilesystemNode::createWriteStream() { - return PSPIoStream::makeFromPath(getPath(), true); + const uint32 WRITE_BUFFER_SIZE = 1024; + + Common::WriteStream *stream = PspIoStream::makeFromPath(getPath(), true); + + return new PspIoBufferedWriteStream(stream, WRITE_BUFFER_SIZE, DisposeAfterUse::YES); } #endif //#ifdef __PSP__ diff --git a/backends/fs/psp/psp-stream.cpp b/backends/fs/psp/psp-stream.cpp index 8843bfd2fb..3b0737ba63 100644 --- a/backends/fs/psp/psp-stream.cpp +++ b/backends/fs/psp/psp-stream.cpp @@ -58,58 +58,53 @@ void printBuffer(byte *ptr, uint32 len) { } #endif +// Class PspIoStream ------------------------------------------------ -PSPIoStream::PSPIoStream(const Common::String &path, bool writeMode) - : _handle(0), _path(path), _writeMode(writeMode), - _ferror(false), _pos(0), - _physicalPos(0), _fileSize(0), _inCache(false), _eos(false), - _cacheStartOffset(-1), _cache(0), - _errorSuspend(0), _errorSource(0), - _errorPos(0), _errorHandle(0), _suspendCount(0) { +PspIoStream::PspIoStream(const Common::String &path, bool writeMode) + : _handle(0), _path(path), _fileSize(0), _writeMode(writeMode), + _physicalPos(0), _pos(0), _eos(false), _error(false), + _errorSuspend(0), _errorSource(0), _errorPos(0), _errorHandle(0), _suspendCount(0) { DEBUG_ENTER_FUNC(); - // assert(!path.empty()); // do we need this? + //assert(!path.empty()); // do we need this? } -PSPIoStream::~PSPIoStream() { +PspIoStream::~PspIoStream() { DEBUG_ENTER_FUNC(); if (PowerMan.beginCriticalSection()) - PSP_DEBUG_PRINT_FUNC("Suspended\n"); - - PowerMan.unregisterForSuspend(this); // Unregister with powermanager to be suspended - // Must do this before fclose() or resume() will reopen. - - sceIoClose(_handle); // We don't need a critical section. Worst case, the handle gets closed on its own + PSP_DEBUG_PRINT_FUNC("suspended\n"); + + PowerMan.unregisterForSuspend(this); // Unregister with powermanager to be suspended + // Must do this before fclose() or resume() will reopen. + sceIoClose(_handle); - if (_cache) - free(_cache); - PowerMan.endCriticalSection(); } /* Function to open the file pointed to by the path. * */ -void *PSPIoStream::open() { +void *PspIoStream::open() { DEBUG_ENTER_FUNC(); + if (PowerMan.beginCriticalSection()) { - // No need to open. Just return the _handle resume() already opened. - PSP_DEBUG_PRINT_FUNC("Suspended\n"); + // No need to open? Just return the _handle resume() already opened + PSP_DEBUG_PRINT_FUNC("suspended\n"); } - _handle = sceIoOpen(_path.c_str(), _writeMode ? PSP_O_RDWR | PSP_O_CREAT : PSP_O_RDONLY, 0777); // open - - if (_handle) { - // Get the file size. This way is much faster than going to the end of the file and back - SceIoStat stat; - sceIoGetstat(_path.c_str(), &stat); - _fileSize = *((uint32 *)(void *)&stat.st_size); // 4GB file is big enough for us - PSP_DEBUG_PRINT("%s filesize = %d\n", _path.c_str(), _fileSize); + _handle = sceIoOpen(_path.c_str(), _writeMode ? PSP_O_WRONLY | PSP_O_CREAT | PSP_O_TRUNC : PSP_O_RDONLY, 0777); + if (!_handle) { + _error = true; + _handle = NULL; + } - // Allocate the cache - _cache = (char *)memalign(64, CACHE_SIZE); - } + // Get the file size. This way is much faster than going to the end of the file and back + SceIoStat stat; + sceIoGetstat(_path.c_str(), &stat); + _fileSize = *((uint32 *)(void *)&stat.st_size); // 4GB file (32 bits) is big enough for us + + PSP_DEBUG_PRINT("%s filesize[%d]\n", _path.c_str(), _fileSize); PowerMan.registerForSuspend(this); // Register with the powermanager to be suspended @@ -118,35 +113,48 @@ void *PSPIoStream::open() { return (void *)_handle; } -bool PSPIoStream::err() const { +bool PspIoStream::err() const { DEBUG_ENTER_FUNC(); - if (_ferror) // We dump since no printing to screen with suspend - PSP_ERROR("mem_ferror[%d], source[%d], suspend error[%d], pos[%d], \ - _errorPos[%d], _errorHandle[%p], suspendCount[%d]\n", - _ferror, _errorSource, _errorSuspend, _pos, + if (_error) // We dump since no printing to screen with suspend callback + PSP_ERROR("mem_error[%d], source[%d], suspend error[%d], pos[%d]," + "_errorPos[%d], _errorHandle[%p], suspendCount[%d]\n", + _error, _errorSource, _errorSuspend, _pos, _errorPos, _errorHandle, _suspendCount); - return _ferror; + return _error; } -void PSPIoStream::clearErr() { - _ferror = false; +void PspIoStream::clearErr() { + _error = false; } -bool PSPIoStream::eos() const { +bool PspIoStream::eos() const { return _eos; } -int32 PSPIoStream::pos() const { +int32 PspIoStream::pos() const { return _pos; } -int32 PSPIoStream::size() const { +int32 PspIoStream::size() const { return _fileSize; } -bool PSPIoStream::seek(int32 offs, int whence) { +bool PspIoStream::physicalSeekFromCur(int32 offset) { + + int ret = sceIoLseek32(_handle, offset, PSP_SEEK_CUR); + + if (ret < 0) { + _error = true; + PSP_ERROR("failed to seek in file[%s] to [%x]. Error[%x]\n", _path.c_str(), offset, ret); + return false; + } + _physicalPos += offset; + return true; +} + +bool PspIoStream::seek(int32 offs, int whence) { DEBUG_ENTER_FUNC(); PSP_DEBUG_PRINT_FUNC("offset[0x%x], whence[%d], _pos[0x%x], _physPos[0x%x]\n", offs, whence, _pos, _physicalPos); _eos = false; @@ -157,195 +165,115 @@ bool PSPIoStream::seek(int32 offs, int whence) { posToSearchFor = _pos; break; case SEEK_END: - posToSearchFor = _fileSize; // unsure. Does it take us here or to EOS - 1? + posToSearchFor = _fileSize; break; } posToSearchFor += offs; - + // Check for bad values if (posToSearchFor < 0) { - _ferror = true; + _error = true; return false; - } - - if (posToSearchFor > _fileSize) { - _ferror = true; + } else if (posToSearchFor > _fileSize) { + _error = true; _eos = true; return false; } - // See if we can find it in cache - if (isOffsetInCache(posToSearchFor)) { - PSP_DEBUG_PRINT("seek offset[0x%x] found in cache. Cache starts[0x%x]\n", posToSearchFor, _cacheStartOffset); - _inCache = true; - } else { // not in cache - _inCache = false; - } _pos = posToSearchFor; + return true; } -uint32 PSPIoStream::read(void *ptr, uint32 len) { +uint32 PspIoStream::read(void *ptr, uint32 len) { DEBUG_ENTER_FUNC(); - PSP_DEBUG_PRINT_FUNC("filename[%s], len[0x%x], ptr[%p]\n", _path.c_str(), len, ptr); + PSP_DEBUG_PRINT_FUNC("filename[%s], len[0x%x], ptr[%p], _pos[%x], _physPos[%x]\n", _path.c_str(), len, ptr, _pos, _physicalPos); - if (_ferror || _eos) + if (_error || _eos || len <= 0) return 0; - - byte *destPtr = (byte *)ptr; - uint32 lenFromFile = len; // how much we read from the actual file - uint32 lenFromCache = 0; // how much we read from cache + uint32 lenRemainingInFile = _fileSize - _pos; - - if (lenFromFile > lenRemainingInFile) { - lenFromFile = lenRemainingInFile; + + // check for getting EOS + if (len > lenRemainingInFile) { + len = lenRemainingInFile; _eos = true; } - - // Are we in cache? - if (_inCache && isCacheValid()) { - uint32 offsetInCache = _pos - _cacheStartOffset; - // We can read at most what's in the cache or the remaining size of the file - lenFromCache = MIN2(lenFromFile, CACHE_SIZE - offsetInCache); // unsure - - PSP_DEBUG_PRINT("reading 0x%x bytes from cache to %p. pos[0x%x] physPos[0x%x] cacheStart[0x%x]\n", lenFromCache, destPtr, _pos, _physicalPos, _cacheStartOffset); - - memcpy(destPtr, &_cache[offsetInCache], lenFromCache); - _pos += lenFromCache; - - if (lenFromCache < lenFromFile) { // there's more to copy from the file - lenFromFile -= lenFromCache; - lenRemainingInFile -= lenFromCache; // since we moved pos - destPtr += lenFromCache; - } else { // we're done -#ifdef DEBUG_BUFFERS - printBuffer((byte *)ptr, len); -#endif - - return lenFromCache; // how much we actually read - } - } if (PowerMan.beginCriticalSection()) - PSP_DEBUG_PRINT_FUNC("Suspended\n"); - + PSP_DEBUG_PRINT_FUNC("suspended\n"); - synchronizePhysicalPos(); // we need to update our physical position + // check if we need to seek + if (_pos != _physicalPos) + PSP_DEBUG_PRINT("seeking from %x to %x\n", _physicalPos, _pos); + if (!physicalSeekFromCur(_pos - _physicalPos)) { + _error = true; + return 0; + } - if (lenFromFile <= MIN_READ_SIZE) { // We load the cache in case the read is small enough - // This optimization is based on the principle that reading 1 byte is as expensive as 1000 bytes - uint32 lenToCopyToCache = MIN2((uint32)MIN_READ_SIZE, lenRemainingInFile); // at most remaining file size - - PSP_DEBUG_PRINT("filling cache with 0x%x bytes from physicalPos[0x%x]. cacheStart[0x%x], pos[0x%x], fileSize[0x%x]\n", lenToCopyToCache, _physicalPos, _cacheStartOffset, _pos, _fileSize); - - int ret = sceIoRead(_handle, _cache, lenToCopyToCache); - if (ret != (int)lenToCopyToCache) { - PSP_ERROR("in filling cache, failed to get 0x%x bytes. Only got 0x%x\n", lenToCopyToCache, ret); - _ferror = true; - } - _cacheStartOffset = _physicalPos; - _inCache = true; - - _physicalPos += ret; - - PSP_DEBUG_PRINT("copying 0x%x bytes from cache to %p\n", lenFromFile, destPtr); - - // Copy to the destination buffer from cache - memcpy(destPtr, _cache, lenFromFile); - _pos += lenFromFile; - - } else { // Too big for cache. No caching - PSP_DEBUG_PRINT("reading 0x%x bytes from file to %p. Pos[0x%x], physPos[0x%x]\n", lenFromFile, destPtr, _pos, _physicalPos); - int ret = sceIoRead(_handle, destPtr, lenFromFile); - - _physicalPos += ret; // Update pos - _pos = _physicalPos; - - if (ret != (int)lenFromFile) { // error - PSP_ERROR("fread returned [0x%x] instead of len[0x%x]\n", ret, lenFromFile); - _ferror = true; - _errorSource = 4; - } - _inCache = false; - } + int ret = sceIoRead(_handle, ptr, len); PowerMan.endCriticalSection(); - -#ifdef DEBUG_BUFFERS - printBuffer((byte *)ptr, len); -#endif - - return lenFromCache + lenFromFile; // total of what was copied -} - -// TODO: Test if seeking backwards/forwards has any effect on performance -inline bool PSPIoStream::synchronizePhysicalPos() { - if (_pos != _physicalPos) { - if (sceIoLseek32(_handle, _pos - _physicalPos, PSP_SEEK_CUR) < 0) { - _ferror = true; - return false; - } - _physicalPos = _pos; - } - return true; -} - -inline bool PSPIoStream::isOffsetInCache(uint32 offset) { - if (_cacheStartOffset != -1 && - offset >= (uint32)_cacheStartOffset && - offset < (uint32)(_cacheStartOffset + CACHE_SIZE)) - return true; - return false; -} + _physicalPos += ret; // Update position + _pos = _physicalPos; + + if (ret != (int)len) { // error + PSP_ERROR("sceIoRead returned [0x%x] instead of len[0x%x]\n", ret, len); + _error = true; + _errorSource = 4; + } + return ret; +} -uint32 PSPIoStream::write(const void *ptr, uint32 len) { +uint32 PspIoStream::write(const void *ptr, uint32 len) { DEBUG_ENTER_FUNC(); - // Check if we can access the file - if (PowerMan.beginCriticalSection()) - PSP_DEBUG_PRINT_FUNC("Suspended\n"); + PSP_DEBUG_PRINT_FUNC("filename[%s], len[0x%x], ptr[%p], _pos[%x], _physPos[%x]\n", _path.c_str(), len, ptr, _pos, _physicalPos); - PSP_DEBUG_PRINT_FUNC("filename[%s], len[0x%x]\n", _path.c_str(), len); - - if (!len || _ferror) // we actually get calls with len=0 + if (!len || _error) // we actually get some calls with len == 0! return 0; + + _eos = false; // we can't have eos with write - _eos = false; // we can't have eos with write - synchronizePhysicalPos(); + if (PowerMan.beginCriticalSection()) + PSP_DEBUG_PRINT_FUNC("suspended\n"); + + // check if we need to seek + if (_pos != _physicalPos) + if (!physicalSeekFromCur(_pos - _physicalPos)) { + _error = true; + return 0; + } int ret = sceIoWrite(_handle, ptr, len); - - // If we're making the file bigger, adjust the size - if (_physicalPos + ret > _fileSize) - _fileSize = _physicalPos + ret; - - _physicalPos += ret; - _pos = _physicalPos; - _inCache = false; - _cacheStartOffset = -1; // invalidate cache - - if (ret != (int)len) { // Set error - _ferror = true; + + PowerMan.endCriticalSection(); + + if (ret != (int)len) { + _error = true; _errorSource = 5; - PSP_ERROR("fwrite returned[0x%x] instead of len[0x%x]\n", ret, len); + PSP_ERROR("sceIoWrite returned[0x%x] instead of len[0x%x]\n", ret, len); } - PowerMan.endCriticalSection(); - + _physicalPos += ret; + _pos = _physicalPos; + + if (_pos > _fileSize) + _fileSize = _pos; + return ret; } -bool PSPIoStream::flush() { - +bool PspIoStream::flush() { return true; } // For the PSP, since we're building in suspend support, we moved opening -// the actual file to an open function since we need an actual PSPIoStream object to suspend. +// the actual file to an open function since we need an actual PspIoStream object to suspend. // -PSPIoStream *PSPIoStream::makeFromPath(const Common::String &path, bool writeMode) { +PspIoStream *PspIoStream::makeFromPath(const Common::String &path, bool writeMode) { DEBUG_ENTER_FUNC(); - PSPIoStream *stream = new PSPIoStream(path, writeMode); + PspIoStream *stream = new PspIoStream(path, writeMode); if (stream->open() <= 0) { delete stream; @@ -359,7 +287,7 @@ PSPIoStream *PSPIoStream::makeFromPath(const Common::String &path, bool writeMod * Function to suspend the IO stream (called by PowerManager) * we can have no output here */ -int PSPIoStream::suspend() { +int PspIoStream::suspend() { DEBUG_ENTER_FUNC(); _suspendCount++; @@ -380,7 +308,7 @@ int PSPIoStream::suspend() { /* * Function to resume the IO stream (called by Power Manager) */ -int PSPIoStream::resume() { +int PspIoStream::resume() { DEBUG_ENTER_FUNC(); int ret = 0; _suspendCount--; @@ -388,15 +316,15 @@ int PSPIoStream::resume() { // We reopen our file descriptor _handle = sceIoOpen(_path.c_str(), _writeMode ? PSP_O_RDWR | PSP_O_CREAT : PSP_O_RDONLY, 0777); // open if (_handle <= 0) { - PSP_ERROR("Couldn't reopen file %s\n", _path.c_str()); + _errorSuspend = ResumeError; + _errorPos = _pos; } - // Resume our previous position + // Resume our previous position if needed if (_handle > 0 && _pos > 0) { ret = sceIoLseek32(_handle, _pos, PSP_SEEK_SET); _physicalPos = _pos; - _inCache = false; if (ret < 0) { // Check for problem _errorSuspend = ResumeError; @@ -407,5 +335,4 @@ int PSPIoStream::resume() { return ret; } - #endif /* __PSP__ */ diff --git a/backends/fs/psp/psp-stream.h b/backends/fs/psp/psp-stream.h index ca9d40c720..be3a1220de 100644 --- a/backends/fs/psp/psp-stream.h +++ b/backends/fs/psp/psp-stream.h @@ -33,18 +33,33 @@ #include "common/stream.h" #include "common/str.h" -/* +class PspIoBufferedReadStream : public Common::BufferedSeekableReadStream { +public: + PspIoBufferedReadStream(SeekableReadStream *parentStream, uint32 bufSize, DisposeAfterUse::Flag disposeParentStream = DisposeAfterUse::YES) : BufferedSeekableReadStream(parentStream, bufSize, disposeParentStream) {} +protected: + virtual void allocBuf(uint32 bufSize) { _buf = (byte *)memalign(64, bufSize); } // want 64 byte alignment for cache + virtual void deallocBuf() { free(_buf); } +}; + +class PspIoBufferedWriteStream : public Common::BufferedWriteStream { +public: + PspIoBufferedWriteStream(WriteStream *parentStream, uint32 bufSize, DisposeAfterUse::Flag disposeParentStream = DisposeAfterUse::YES) : BufferedWriteStream(parentStream, bufSize, disposeParentStream) {} +protected: + virtual void allocBuf(uint32 bufSize) { _buf = (byte *)memalign(64, bufSize); } + virtual void deallocBuf() { free(_buf); } +}; + +/** * Class to handle special suspend/resume needs of PSP IO Streams */ -class PSPIoStream : public Common::SeekableReadStream, public Common::WriteStream, public Common::NonCopyable, public Suspendable { +class PspIoStream : public Common::SeekableReadStream, public Common::WriteStream, public Common::NonCopyable, public Suspendable { protected: SceUID _handle; // file handle Common::String _path; int _fileSize; bool _writeMode; // for resuming in the right mode - int _physicalPos; // position in the real file + int _physicalPos; // physical position in file int _pos; // position. Sometimes virtual - bool _inCache; // whether we're in cache (virtual) mode bool _eos; // EOS flag enum { @@ -52,36 +67,26 @@ protected: ResumeError = 3 }; - enum { - CACHE_SIZE = 1024, - MIN_READ_SIZE = 1024 // reading less than 1024 takes exactly the same time as 1024 - }; - - // For caching - char *_cache; - int _cacheStartOffset; // starting offset of the cache. -1 when cache is invalid - - mutable int _ferror; // file error state + // debug stuff + mutable int _error; // file error state int _errorSuspend; // for debugging mutable int _errorSource; int _errorPos; SceUID _errorHandle; int _suspendCount; - - bool synchronizePhysicalPos(); // synchronize the physical and virtual positions - bool isOffsetInCache(uint32 pos); // check if an offset is found in cache - bool isCacheValid() { return _cacheStartOffset != -1; } + + bool physicalSeekFromCur(int32 offset); public: /** * Given a path, invoke fopen on that path and wrap the result in a - * PSPIoStream instance. + * PspIoStream instance. */ - static PSPIoStream *makeFromPath(const Common::String &path, bool writeMode); + static PspIoStream *makeFromPath(const Common::String &path, bool writeMode); - PSPIoStream(const Common::String &path, bool writeMode); - virtual ~PSPIoStream(); + PspIoStream(const Common::String &path, bool writeMode); + virtual ~PspIoStream(); void * open(); // open the file pointed to by the file path @@ -96,7 +101,8 @@ public: virtual int32 size() const; virtual bool seek(int32 offs, int whence = SEEK_SET); virtual uint32 read(void *dataPtr, uint32 dataSize); - + + // for suspending int suspend(); /* Suspendable interface (power manager) */ int resume(); /* " " */ }; diff --git a/backends/platform/dingux/dingux-events.cpp b/backends/platform/dingux/dingux-events.cpp new file mode 100644 index 0000000000..b6070f68ca --- /dev/null +++ b/backends/platform/dingux/dingux-events.cpp @@ -0,0 +1,215 @@ +/* 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 "backends/platform/dingux/dingux.h" + +#include "graphics/scaler/aspect.h" // for aspect2Real + +#if defined (DINGUX) + +#define PAD_UP SDLK_UP +#define PAD_DOWN SDLK_DOWN +#define PAD_LEFT SDLK_LEFT +#define PAD_RIGHT SDLK_RIGHT +#define BUT_A SDLK_LCTRL +#define BUT_B SDLK_LALT +#define BUT_X SDLK_SPACE +#define BUT_Y SDLK_LSHIFT +#define BUT_SELECT SDLK_ESCAPE +#define BUT_START SDLK_RETURN +#define TRIG_L SDLK_TAB +#define TRIG_R SDLK_BACKSPACE + +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; +} + +bool OSystem_SDL_Dingux::remapKey(SDL_Event &ev, Common::Event &event) { + if (ev.key.keysym.sym == PAD_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; + } else if (ev.key.keysym.sym == PAD_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; + } else if (ev.key.keysym.sym == PAD_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; + } else if (ev.key.keysym.sym == PAD_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; + } else if (ev.key.keysym.sym == BUT_Y) { // left mouse button + if (ev.type == SDL_KEYDOWN) { + event.type = Common::EVENT_LBUTTONDOWN; + } else { + event.type = Common::EVENT_LBUTTONUP; + } + + fillMouseEvent(event, _km.x, _km.y); + + return true; + } else if (ev.key.keysym.sym == BUT_B) { // right mouse button + if (ev.type == SDL_KEYDOWN) { + event.type = Common::EVENT_RBUTTONDOWN; + } else { + event.type = Common::EVENT_RBUTTONUP; + } + + fillMouseEvent(event, _km.x, _km.y); + + return true; + } else if (ev.key.keysym.sym == BUT_X) { // '.' skip dialogue + ev.key.keysym.sym = SDLK_PERIOD; + ev.key.keysym.mod = (SDLMod)0; + ev.key.keysym.unicode = '.'; + } else if (ev.key.keysym.sym == TRIG_L) { // global menu + ev.key.keysym.sym = SDLK_F5; + event.kbd.keycode = Common::KEYCODE_F5; + event.kbd.ascii = Common::ASCII_F5; + event.kbd.flags = Common::KBD_CTRL; + + if (ev.type == SDL_KEYDOWN) { + event.type = Common::EVENT_KEYDOWN; + } else { + event.type = Common::EVENT_KEYUP; + } + + return true; + } else if (ev.key.keysym.sym == BUT_A) { // virtual keyboard + ev.key.keysym.sym = SDLK_0; + + event.kbd.keycode = Common::KEYCODE_0; + event.kbd.ascii = '0'; + event.kbd.flags = 0; + + if (ev.type == SDL_KEYDOWN) { + event.type = Common::EVENT_KEYDOWN; + } else { + event.type = Common::EVENT_KEYUP; + } + + return true; + } else if (ev.key.keysym.sym == BUT_SELECT) { // virtual keyboard + ev.key.keysym.sym = SDLK_F7; + + } else if (ev.key.keysym.sym == BUT_START) { // F5, menu in some games + ev.key.keysym.sym = SDLK_F5; + + } else if (ev.key.keysym.sym == TRIG_R) { // ESC + ev.key.keysym.sym = SDLK_ESCAPE; + } else { + event.kbd.keycode = (Common::KeyCode)ev.key.keysym.sym; + event.kbd.ascii = mapKey(ev.key.keysym.sym, ev.key.keysym.mod, ev.key.keysym.unicode); + } + + return false; +} + +void OSystem_SDL_Dingux::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_SDL_Dingux::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); +} + +#endif + diff --git a/backends/platform/dingux/dingux-graphics.cpp b/backends/platform/dingux/dingux-graphics.cpp new file mode 100644 index 0000000000..bbd4a58636 --- /dev/null +++ b/backends/platform/dingux/dingux-graphics.cpp @@ -0,0 +1,468 @@ +/* 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 "backends/platform/dingux/dingux.h" + +#include "common/mutex.h" +#include "graphics/scaler.h" +#include "graphics/scaler/aspect.h" +#include "graphics/scaler/downscaler.h" +#include "graphics/surface.h" + +#if defined (DINGUX) + +static const OSystem::GraphicsMode s_supportedGraphicsModes[] = { + {"1x", "Standard", GFX_NORMAL}, + {0, 0, 0} +}; + +int OSystem_SDL_Dingux::getDefaultGraphicsMode() const { + return GFX_NORMAL; +} + +const OSystem::GraphicsMode *OSystem_SDL_Dingux::getSupportedGraphicsModes() const { + return s_supportedGraphicsModes; +} + +bool OSystem_SDL_Dingux::setGraphicsMode(int mode) { + Common::StackLock lock(_graphicsMutex); + + assert(_transactionMode == kTransactionActive); + + if (_oldVideoMode.setup && _oldVideoMode.mode == mode) + return true; + + int newScaleFactor = 1; + + switch (mode) { + case GFX_NORMAL: + newScaleFactor = 1; + break; + case GFX_HALF: + newScaleFactor = 1; + break; + default: + warning("unknown gfx mode %d", mode); + return false; + } + + _transactionDetails.normal1xScaler = (mode == GFX_NORMAL); + if (_oldVideoMode.setup && _oldVideoMode.scaleFactor != newScaleFactor) + _transactionDetails.needHotswap = true; + + _transactionDetails.needUpdatescreen = true; + + _videoMode.mode = mode; + _videoMode.scaleFactor = newScaleFactor; + + return true; +} + +void OSystem_SDL_Dingux::setGraphicsModeIntern() { + Common::StackLock lock(_graphicsMutex); + ScalerProc *newScalerProc = 0; + + switch (_videoMode.mode) { + case GFX_NORMAL: + newScalerProc = Normal1x; + break; + case GFX_HALF: + newScalerProc = DownscaleAllByHalf; + break; + + default: + error("Unknown gfx mode %d", _videoMode.mode); + } + + _scalerProc = newScalerProc; + + if (!_screen || !_hwscreen) + return; + + // Blit everything to the screen + _forceFull = true; + + // Even if the old and new scale factors are the same, we may have a + // different scaler for the cursor now. + blitCursor(); +} + +void OSystem_SDL_Dingux::initSize(uint w, uint h) { + assert(_transactionMode == kTransactionActive); + + // Avoid redundant res changes + if ((int)w == _videoMode.screenWidth && (int)h == _videoMode.screenHeight) + return; + + _videoMode.screenWidth = w; + _videoMode.screenHeight = h; + if (w > 320 || h > 240) { + setGraphicsMode(GFX_HALF); + setGraphicsModeIntern(); + toggleMouseGrab(); + } + + _transactionDetails.sizeChanged = true; +} + +void OSystem_SDL_Dingux::drawMouse() { + if (!_mouseVisible || !_mouseSurface) { + _mouseBackup.x = _mouseBackup.y = _mouseBackup.w = _mouseBackup.h = 0; + return; + } + + SDL_Rect dst; + int scale; + int hotX, hotY; + + if (_videoMode.mode == GFX_HALF && !_overlayVisible) { + dst.x = _mouseCurState.x / 2; + dst.y = _mouseCurState.y / 2; + } else { + dst.x = _mouseCurState.x; + dst.y = _mouseCurState.y; + } + + if (!_overlayVisible) { + scale = _videoMode.scaleFactor; + dst.w = _mouseCurState.vW; + dst.h = _mouseCurState.vH; + hotX = _mouseCurState.vHotX; + hotY = _mouseCurState.vHotY; + } else { + scale = 1; + dst.w = _mouseCurState.rW; + dst.h = _mouseCurState.rH; + hotX = _mouseCurState.rHotX; + hotY = _mouseCurState.rHotY; + } + + // The mouse is undrawn using virtual coordinates, i.e. they may be + // scaled and aspect-ratio corrected. + + _mouseBackup.x = dst.x - hotX; + _mouseBackup.y = dst.y - hotY; + _mouseBackup.w = dst.w; + _mouseBackup.h = dst.h; + + // We draw the pre-scaled cursor image, so now we need to adjust for + // scaling, shake position and aspect ratio correction manually. + + if (!_overlayVisible) { + dst.y += _currentShakePos; + } + + if (_videoMode.aspectRatioCorrection && !_overlayVisible) + dst.y = real2Aspect(dst.y); + + dst.x = scale * dst.x - _mouseCurState.rHotX; + dst.y = scale * dst.y - _mouseCurState.rHotY; + dst.w = _mouseCurState.rW; + dst.h = _mouseCurState.rH; + + // Note that SDL_BlitSurface() and addDirtyRect() will both perform any + // clipping necessary + + if (SDL_BlitSurface(_mouseSurface, NULL, _hwscreen, &dst) != 0) + error("SDL_BlitSurface failed: %s", SDL_GetError()); + + // The screen will be updated using real surface coordinates, i.e. + // they will not be scaled or aspect-ratio corrected. + addDirtyRect(dst.x, dst.y, dst.w, dst.h, true); +} + +void OSystem_SDL_Dingux::undrawMouse() { + const int x = _mouseBackup.x; + const int y = _mouseBackup.y; + + // When we switch bigger overlay off mouse jumps. Argh! + // This is intended to prevent undrawing offscreen mouse + if (!_overlayVisible && (x >= _videoMode.screenWidth || y >= _videoMode.screenHeight)) + return; + + if (_mouseBackup.w != 0 && _mouseBackup.h != 0) { + if (_videoMode.mode == GFX_HALF && !_overlayVisible) { + addDirtyRect(x*2, y*2, _mouseBackup.w*2, _mouseBackup.h*2); + } else { + addDirtyRect(x, y, _mouseBackup.w, _mouseBackup.h); + } + } +} + +void OSystem_SDL_Dingux::internUpdateScreen() { + SDL_Surface *srcSurf, *origSurf; + int height, width; + ScalerProc *scalerProc; + int scale1; + +#if defined (DEBUG) && ! defined(_WIN32_WCE) // definitions not available for non-DEBUG here. (needed this to compile in SYMBIAN32 & linux?) + assert(_hwscreen != NULL); + assert(_hwscreen->map->sw_data != NULL); +#endif + + // If the shake position changed, fill the dirty area with blackness + if (_currentShakePos != _newShakePos) { + SDL_Rect blackrect = {0, 0, _videoMode.screenWidth * _videoMode.scaleFactor, _newShakePos * _videoMode.scaleFactor}; + + if (_videoMode.aspectRatioCorrection && !_overlayVisible) + blackrect.h = real2Aspect(blackrect.h - 1) + 1; + + SDL_FillRect(_hwscreen, &blackrect, 0); + + _currentShakePos = _newShakePos; + + _forceFull = true; + } + + // Check whether the palette was changed in the meantime and update the + // screen surface accordingly. + if (_screen && _paletteDirtyEnd != 0) { + SDL_SetColors(_screen, _currentPalette + _paletteDirtyStart, + _paletteDirtyStart, + _paletteDirtyEnd - _paletteDirtyStart); + + _paletteDirtyEnd = 0; + + _forceFull = true; + } + +#ifdef USE_OSD + // OSD visible (i.e. non-transparent)? + if (_osdAlpha != SDL_ALPHA_TRANSPARENT) { + // Updated alpha value + const int diff = SDL_GetTicks() - _osdFadeStartTime; + if (diff > 0) { + if (diff >= kOSDFadeOutDuration) { + // Back to full transparency + _osdAlpha = SDL_ALPHA_TRANSPARENT; + } else { + // Do a linear fade out... + const int startAlpha = SDL_ALPHA_TRANSPARENT + kOSDInitialAlpha * (SDL_ALPHA_OPAQUE - SDL_ALPHA_TRANSPARENT) / 100; + _osdAlpha = startAlpha + diff * (SDL_ALPHA_TRANSPARENT - startAlpha) / kOSDFadeOutDuration; + } + SDL_SetAlpha(_osdSurface, SDL_RLEACCEL | SDL_SRCCOLORKEY | SDL_SRCALPHA, _osdAlpha); + _forceFull = true; + } + } +#endif + + if (!_overlayVisible) { + origSurf = _screen; + srcSurf = _tmpscreen; + width = _videoMode.screenWidth; + height = _videoMode.screenHeight; + scalerProc = _scalerProc; + scale1 = _videoMode.scaleFactor; + } else { + origSurf = _overlayscreen; + srcSurf = _tmpscreen2; + width = _videoMode.overlayWidth; + height = _videoMode.overlayHeight; + scalerProc = Normal1x; + scale1 = 1; + } + + // Add the area covered by the mouse cursor to the list of dirty rects if + // we have to redraw the mouse. + if (_mouseNeedsRedraw) + undrawMouse(); + + // Force a full redraw if requested + if (_forceFull) { + _numDirtyRects = 1; + _dirtyRectList[0].x = 0; + _dirtyRectList[0].y = 0; + _dirtyRectList[0].w = width; + _dirtyRectList[0].h = height; + } + + // Only draw anything if necessary + if (_numDirtyRects > 0 || _mouseNeedsRedraw) { + SDL_Rect *r; + SDL_Rect dst; + uint32 srcPitch, dstPitch; + SDL_Rect *lastRect = _dirtyRectList + _numDirtyRects; + + for (r = _dirtyRectList; r != lastRect; ++r) { + dst = *r; + dst.x++; // Shift rect by one since 2xSai needs to access the data around + dst.y++; // any pixel to scale it, and we want to avoid mem access crashes. + + if (SDL_BlitSurface(origSurf, r, srcSurf, &dst) != 0) + error("SDL_BlitSurface failed: %s", SDL_GetError()); + } + + SDL_LockSurface(srcSurf); + SDL_LockSurface(_hwscreen); + + srcPitch = srcSurf->pitch; + dstPitch = _hwscreen->pitch; + + for (r = _dirtyRectList; r != lastRect; ++r) { + register int dst_y = r->y + _currentShakePos; + register int dst_h = 0; + register int dst_w = r->w; + register int orig_dst_y = 0; + register int dst_x = r->x; + register int src_y; + register int src_x; + + if (dst_y < height) { + dst_h = r->h; + if (dst_h > height - dst_y) + dst_h = height - dst_y; + + orig_dst_y = dst_y; + src_x = dst_x; + src_y = dst_y; + + if (_videoMode.aspectRatioCorrection && !_overlayVisible) + dst_y = real2Aspect(dst_y); + + assert(scalerProc != NULL); + + if ((_videoMode.mode == GFX_HALF) && (scalerProc == DownscaleAllByHalf)) { + if (dst_x % 2 == 1) { + dst_x--; + dst_w++; + } + if (dst_y % 2 == 1) { + dst_y--; + dst_h++; + } + src_x = dst_x; + src_y = dst_y; + dst_x = dst_x / 2; + dst_y = dst_y / 2; + + scalerProc((byte *)srcSurf->pixels + (src_x * 2 + 2) + (src_y + 1) * srcPitch, srcPitch, + (byte *)_hwscreen->pixels + dst_x * 2 + dst_y * dstPitch, dstPitch, dst_w, dst_h); + + } else { + scalerProc((byte *)srcSurf->pixels + (r->x * 2 + 2) + (r->y + 1) * srcPitch, srcPitch, + (byte *)_hwscreen->pixels + r->x * 2 + dst_y * dstPitch, dstPitch, r->w, dst_h); + } + } + + if (_videoMode.mode == GFX_HALF && scalerProc == DownscaleAllByHalf) { + r->w = r->w / 2; + r->h = dst_h / 2; + } else { + r->w = r->w; + r->h = dst_h; + } + + r->x = dst_x; + r->y = dst_y; + + +#ifdef USE_SCALERS + if (_videoMode.aspectRatioCorrection && orig_dst_y < height && !_overlayVisible) + r->h = stretch200To240((uint8 *) _hwscreen->pixels, dstPitch, r->w, r->h, r->x, r->y, orig_dst_y * scale1); +#endif + } + SDL_UnlockSurface(srcSurf); + SDL_UnlockSurface(_hwscreen); + + // Readjust the dirty rect list in case we are doing a full update. + // This is necessary if shaking is active. + if (_forceFull) { + _dirtyRectList[0].y = 0; + _dirtyRectList[0].h = (_videoMode.mode == GFX_HALF) ? effectiveScreenHeight() / 2 : effectiveScreenHeight(); + } + + drawMouse(); + +#ifdef USE_OSD + if (_osdAlpha != SDL_ALPHA_TRANSPARENT) { + SDL_BlitSurface(_osdSurface, 0, _hwscreen, 0); + } +#endif + // Finally, blit all our changes to the screen + SDL_UpdateRects(_hwscreen, _numDirtyRects, _dirtyRectList); + } + + _numDirtyRects = 0; + _forceFull = false; + _mouseNeedsRedraw = false; +} + +void OSystem_SDL_Dingux::showOverlay() { + if (_videoMode.mode == GFX_HALF) { + _mouseCurState.x = _mouseCurState.x / 2; + _mouseCurState.y = _mouseCurState.y / 2; + } + OSystem_SDL::showOverlay(); +} + +void OSystem_SDL_Dingux::hideOverlay() { + if (_videoMode.mode == GFX_HALF) { + _mouseCurState.x = _mouseCurState.x * 2; + _mouseCurState.y = _mouseCurState.y * 2; + } + OSystem_SDL::hideOverlay(); +} + +bool OSystem_SDL_Dingux::loadGFXMode() { + + // Forcefully disable aspect ratio correction for games + // which starts with a native 240px height resolution. + // This fixes games with weird resolutions, like 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 OSystem_SDL::loadGFXMode(); +} + +#endif + diff --git a/backends/platform/dingux/dingux.cpp b/backends/platform/dingux/dingux.cpp new file mode 100644 index 0000000000..cdf10600ce --- /dev/null +++ b/backends/platform/dingux/dingux.cpp @@ -0,0 +1,58 @@ +/* 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 "backends/platform/dingux/dingux.h" + +#if defined(DINGUX) + +bool OSystem_SDL_Dingux::hasFeature(Feature f) { + return + (f == kFeatureAspectRatioCorrection) || + (f == kFeatureCursorHasPalette); +} + +void OSystem_SDL_Dingux::setFeatureState(Feature f, bool enable) { + switch (f) { + case kFeatureAspectRatioCorrection: + setAspectRatioCorrection(enable); + break; + default: + break; + } +} + +bool OSystem_SDL_Dingux::getFeatureState(Feature f) { + assert(_transactionMode == kTransactionNone); + + switch (f) { + case kFeatureAspectRatioCorrection: + return _videoMode.aspectRatioCorrection; + default: + return false; + } +} + +#endif + diff --git a/backends/platform/dingux/dingux.h b/backends/platform/dingux/dingux.h new file mode 100644 index 0000000000..846ad3faf9 --- /dev/null +++ b/backends/platform/dingux/dingux.h @@ -0,0 +1,69 @@ +/* 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 SDL_DINGUX_COMMON_H +#define SDL_DINGUX_COMMON_H + +#include <SDL.h> + +#include "backends/base-backend.h" +#include "backends/platform/sdl/sdl.h" + +#if defined(DINGUX) + +enum { + GFX_HALF = 12 +}; + +class OSystem_SDL_Dingux : public OSystem_SDL { +public: + virtual bool hasFeature(Feature f); + virtual void setFeatureState(Feature f, bool enable); + virtual bool getFeatureState(Feature f); + virtual 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(); + void warpMouse(int, int); + void fillMouseEvent(Common::Event&, int, int); + +protected: + virtual bool remapKey(SDL_Event &ev, Common::Event &event); +}; + + +#endif + +#endif + diff --git a/backends/platform/dingux/main.cpp b/backends/platform/dingux/main.cpp new file mode 100644 index 0000000000..7b02151c1a --- /dev/null +++ b/backends/platform/dingux/main.cpp @@ -0,0 +1,53 @@ +/* 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 "backends/platform/dingux/dingux.h" +#include "backends/plugins/sdl/sdl-provider.h" +//#include "backends/plugins/posix/posix-provider.h" +#include "base/main.h" + +#if defined(DINGUX) + +#include <unistd.h> + +int main(int argc, char* argv[]) { + + g_system = new OSystem_SDL_Dingux(); + assert(g_system); + +#ifdef DYNAMIC_MODULES + PluginManager::instance().addPluginProvider(new SDLPluginProvider()); +// PluginManager::instance().addPluginProvider(new POSIXPluginProvider()); +#endif + + // Invoke the actual ScummVM main entry point: + int res = scummvm_main(argc, argv); + ((OSystem_SDL *)g_system)->deinit(); + return res; + +} + +#endif + diff --git a/backends/platform/dingux/module.mk b/backends/platform/dingux/module.mk new file mode 100644 index 0000000000..309fb94442 --- /dev/null +++ b/backends/platform/dingux/module.mk @@ -0,0 +1,13 @@ +MODULE := backends/platform/dingux + +MODULE_OBJS := \ + main.o \ + dingux.o \ + dingux-events.o \ + dingux-graphics.o \ + +MODULE_DIRS += \ + backends/platform/dingux/ + +# We don't use the rules.mk here on purpose +OBJS := $(addprefix $(MODULE)/, $(MODULE_OBJS)) $(OBJS) diff --git a/backends/platform/gp2xwiz/caanoo/build.sh b/backends/platform/gp2xwiz/caanoo/build.sh new file mode 100755 index 0000000000..8000d2595d --- /dev/null +++ b/backends/platform/gp2xwiz/caanoo/build.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +echo Quick script to make building all the time less painful. + +# Set the paths up here to support the build. + +cd ../../../.. + +echo Building ScummVM for GP2X Caanoo. +make + +echo Build for GP2X Caanoo - complete - Please check build logs. diff --git a/backends/platform/gp2xwiz/caanoo/bundle-debug.sh b/backends/platform/gp2xwiz/caanoo/bundle-debug.sh new file mode 100755 index 0000000000..2d5cefe80e --- /dev/null +++ b/backends/platform/gp2xwiz/caanoo/bundle-debug.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +echo Quick script to make building a distribution of the GP2X Caanoo backend more consistent. + +cd ../../../.. + +echo Building ScummVM for GP2X Caanoo. + +make caanoo-bundle-debug diff --git a/backends/platform/gp2xwiz/caanoo/bundle.sh b/backends/platform/gp2xwiz/caanoo/bundle.sh new file mode 100755 index 0000000000..76fd31cec6 --- /dev/null +++ b/backends/platform/gp2xwiz/caanoo/bundle.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +echo Quick script to make building a distribution of the GP2X Caanoo backend more consistent. + +cd ../../../.. + +echo Building ScummVM for GP2X Caanoo. + +make caanoo-bundle diff --git a/backends/platform/gp2xwiz/caanoo/caanoo-bundle.mk b/backends/platform/gp2xwiz/caanoo/caanoo-bundle.mk new file mode 100755 index 0000000000..f8ac26382d --- /dev/null +++ b/backends/platform/gp2xwiz/caanoo/caanoo-bundle.mk @@ -0,0 +1,67 @@ +# Special target to create bundles for the GP2X Caanoo. + +#bundle_name = release/scummvm-caanoo-`date '+%Y-%m-%d'` +bundle_name = release/scummvm-caanoo +f=$(shell which $(STRIP)) +libloc = $(shell dirname $(f)) + +caanoo-bundle: $(EXECUTABLE) + $(MKDIR) "$(bundle_name)" + $(MKDIR) "$(bundle_name)/scummvm" + $(MKDIR) "$(bundle_name)/scummvm/saves" + $(MKDIR) "$(bundle_name)/scummvm/engine-data" + $(MKDIR) "$(bundle_name)/scummvm/lib" + + echo "Please put your save games in this dir" >> "$(bundle_name)/scummvm/saves/PUT_SAVES_IN_THIS_DIR" + + $(CP) $(srcdir)/backends/platform/gp2xwiz/caanoo/scummvm.gpe $(bundle_name)/scummvm/ + $(CP) $(srcdir)/backends/platform/gp2xwiz/build/scummvm.png $(bundle_name)/scummvm/ + $(CP) $(srcdir)/backends/platform/gp2xwiz/build/README-GP2XWIZ $(bundle_name)/scummvm/README-CAANOO + $(CP) $(srcdir)/backends/platform/gp2xwiz/build/scummvm.ini $(bundle_name)/ + + $(INSTALL) -c -m 644 $(DIST_FILES_DOCS) $(bundle_name)/scummvm/ + $(INSTALL) -c -m 644 $(DIST_FILES_THEMES) $(bundle_name)/scummvm/ + $(INSTALL) -c -m 644 $(DIST_FILES_ENGINEDATA) $(bundle_name)/scummvm/engine-data + $(CP) $(srcdir)/backends/vkeybd/packs/vkeybd_default.zip $(bundle_name)/scummvm/ + + $(STRIP) $(EXECUTABLE) -o $(bundle_name)/scummvm/$(EXECUTABLE) + +ifdef DYNAMIC_MODULES + $(INSTALL) -d "$(bundle_name)/scummvm/plugins" + $(INSTALL) -c -m 644 $(PLUGINS) "$(bundle_name)/scummvm/plugins" + $(STRIP) $(bundle_name)/scummvm/plugins/* +endif + + tar -C $(bundle_name) -cvjf $(bundle_name).tar.bz2 . + rm -R ./$(bundle_name) + +caanoo-bundle-debug: $(EXECUTABLE) + $(MKDIR) "$(bundle_name)" + $(MKDIR) "$(bundle_name)/scummvm" + $(MKDIR) "$(bundle_name)/scummvm/saves" + $(MKDIR) "$(bundle_name)/scummvm/engine-data" + $(MKDIR) "$(bundle_name)/scummvm/lib" + + echo "Please put your save games in this dir" >> "$(bundle_name)/scummvm/saves/PUT_SAVES_IN_THIS_DIR" + + $(CP) $(srcdir)/backends/platform/gp2xwiz/caanoo/scummvm-gdb.gpe $(bundle_name)/scummvm/scummvm.gpe + $(CP) $(srcdir)/backends/platform/gp2xwiz/build/scummvm.png $(bundle_name)/scummvm/ + $(CP) $(srcdir)/backends/platform/gp2xwiz/build/README-GP2XWIZ $(bundle_name)/scummvm/README-CAANOO + $(CP) $(srcdir)/backends/platform/gp2xwiz/build/scummvm.ini $(bundle_name)/ + + $(INSTALL) -c -m 644 $(DIST_FILES_DOCS) $(bundle_name)/scummvm/ + $(INSTALL) -c -m 644 $(DIST_FILES_THEMES) $(bundle_name)/scummvm/ + $(INSTALL) -c -m 644 $(DIST_FILES_ENGINEDATA) $(bundle_name)/scummvm/engine-data + $(CP) $(srcdir)/backends/vkeybd/packs/vkeybd_default.zip $(bundle_name)/scummvm/ + + $(INSTALL) -c -m 777 $(srcdir)/$(EXECUTABLE) $(bundle_name)/scummvm/$(EXECUTABLE) + +ifdef DYNAMIC_MODULES + $(INSTALL) -d "$(bundle_name)/scummvm/plugins" + $(INSTALL) -c -m 644 $(PLUGINS) "$(bundle_name)/scummvm/plugins" +endif + + tar -C $(bundle_name) -cvjf $(bundle_name)-debug.tar.bz2 . + rm -R ./$(bundle_name) + +.PHONY: caanoo-bundle caanoo-bundle-debug diff --git a/backends/platform/gp2xwiz/caanoo/clean.sh b/backends/platform/gp2xwiz/caanoo/clean.sh new file mode 100755 index 0000000000..5ec1b9e62c --- /dev/null +++ b/backends/platform/gp2xwiz/caanoo/clean.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +echo Quick script to make building all the time less painful. + +cd ../../../.. + +echo Cleaning ScummVM for the GP2X Wiz. +make clean diff --git a/backends/platform/gp2xwiz/caanoo/config-alleng.sh b/backends/platform/gp2xwiz/caanoo/config-alleng.sh new file mode 100755 index 0000000000..7a097c268b --- /dev/null +++ b/backends/platform/gp2xwiz/caanoo/config-alleng.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +echo Quick script to make running configure all the time less painful +echo and let all the build work be done from the backend/build folder. + +# Assume Caanoo toolchain/build env. +. /opt/arm-caanoo/environment-setup + +# Export the tool names for cross-compiling +export DEFINES=-DNDEBUG + +# Edit the configure line to suit. +cd ../../../.. +./configure --backend=caanoo --disable-mt32emu --host=caanoo --disable-alsa --disable-flac --disable-nasm --disable-vorbis --disable-hq-scalers --with-sdl-prefix=/usr/local/angstrom/arm/arm-angstrom-linux-gnueabi/usr/bin --with-mpeg2-prefix=/usr/local/angstrom/arm/arm-angstrom-linux-gnueabi/usr --enable-tremor --with-tremor-prefix=/usr/local/angstrom/arm/arm-angstrom-linux-gnueabi/usr --enable-zlib --with-zlib-prefix=/usr/local/angstrom/arm/arm-angstrom-linux-gnueabi/usr --enable-mad --with-mad-prefix=/opt/arm-caanoo/arm-none-linux-gnueabi/usr --enable-all-engines --enable-vkeybd --enable-plugins --default-dynamic + +echo Generating config for GP2X Caanoo complete. Check for errors. diff --git a/backends/platform/gp2xwiz/caanoo/config.sh b/backends/platform/gp2xwiz/caanoo/config.sh new file mode 100755 index 0000000000..73ce5da624 --- /dev/null +++ b/backends/platform/gp2xwiz/caanoo/config.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +echo Quick script to make running configure all the time less painful +echo and let all the build work be done from the backend/build folder. + +# Assume Caanoo toolchain/build env. +. /opt/arm-caanoo/environment-setup + +# Export the tool names for cross-compiling +export DEFINES=-DNDEBUG + +# Edit the configure line to suit. +cd ../../../.. +./configure --backend=caanoo --disable-mt32emu --host=caanoo --disable-alsa --disable-flac --disable-nasm --disable-vorbis --disable-hq-scalers --with-sdl-prefix=/opt/arm-caanoo/arm-none-linux-gnueabi/usr/bin --with-mpeg2-prefix=/opt/arm-caanoo/arm-none-linux-gnueabi/usr --enable-tremor --with-tremor-prefix=/opt/arm-caanoo/arm-none-linux-gnueabi/usr --enable-zlib --with-zlib-prefix=/opt/arm-caanoo/arm-none-linux-gnueabi/usr --enable-mad --with-mad-prefix=/opt/arm-caanoo/arm-none-linux-gnueabi/usr --enable-vkeybd --enable-plugins --default-dynamic + +echo Generating config for GP2X Caanoo complete. Check for errors. diff --git a/backends/platform/gp2xwiz/caanoo/scummvm-gdb.gpe b/backends/platform/gp2xwiz/caanoo/scummvm-gdb.gpe new file mode 100755 index 0000000000..a8f2aae0fe --- /dev/null +++ b/backends/platform/gp2xwiz/caanoo/scummvm-gdb.gpe @@ -0,0 +1,16 @@ +#!/bin/sh + +# Export the location of any libs ScummVM depends on +# (to avoid installing to the NAND and overwriting the broken ones there). +export LD_LIBRARY_PATH=`pwd`/lib:$LD_LIBRARY_PATH + +# Run ScummVM via GDB (so make sure you have a terminal open or serial). +# Oh, and GDB installed of course ;) +gdb --args ./scummvm.caanoo --fullscreen --gfx-mode=1x --config=$(pwd)/.scummvmrc + +# Sync the SD card to check that everything is written. +sync + +# Return to the GPH menu screen +cd /usr/gp2x +exec /usr/gp2x/gp2xmenu diff --git a/backends/platform/gp2xwiz/caanoo/scummvm.gpe b/backends/platform/gp2xwiz/caanoo/scummvm.gpe new file mode 100755 index 0000000000..8341ffc3d7 --- /dev/null +++ b/backends/platform/gp2xwiz/caanoo/scummvm.gpe @@ -0,0 +1,15 @@ +#!/bin/sh + +# Export the location of any libs ScummVM depends on +# (to avoid installing to the NAND and overwriting the broken ones there). +export LD_LIBRARY_PATH=`pwd`/lib:$LD_LIBRARY_PATH + +# Run ScummVM, important this bit. +./scummvm.caanoo --fullscreen --gfx-mode=1x --config=$(pwd)/.scummvmrc + +# Sync the SD card to check that everything is written. +sync + +# Return to the GPH menu screen +cd /usr/gp2x +exec /usr/gp2x/gp2xmenu diff --git a/backends/platform/gp2xwiz/gp2xwiz-graphics.cpp b/backends/platform/gp2xwiz/gp2xwiz-graphics.cpp index f6ad226d42..9b8a41a7cf 100644 --- a/backends/platform/gp2xwiz/gp2xwiz-graphics.cpp +++ b/backends/platform/gp2xwiz/gp2xwiz-graphics.cpp @@ -35,11 +35,9 @@ static const OSystem::GraphicsMode s_supportedGraphicsModes[] = { {"1x", "Fullscreen", GFX_NORMAL}, -// {"½x", "Downscale", GFX_HALF}, {0, 0, 0} }; - const OSystem::GraphicsMode *OSystem_GP2XWIZ::getSupportedGraphicsModes() const { return s_supportedGraphicsModes; } @@ -111,7 +109,6 @@ void OSystem_GP2XWIZ::setGraphicsModeIntern() { blitCursor(); } - void OSystem_GP2XWIZ::initSize(uint w, uint h) { assert(_transactionMode == kTransactionActive); @@ -131,13 +128,30 @@ void OSystem_GP2XWIZ::initSize(uint w, uint h) { } bool OSystem_GP2XWIZ::loadGFXMode() { - _videoMode.overlayWidth = 320; - _videoMode.overlayHeight = 240; - _videoMode.fullscreen = true; - - if (_videoMode.screenHeight != 200 && _videoMode.screenHeight != 400) + 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(); } @@ -149,6 +163,7 @@ void OSystem_GP2XWIZ::drawMouse() { SDL_Rect dst; int scale; + int width, height; int hotX, hotY; if (_videoMode.mode == GFX_HALF && !_overlayVisible){ @@ -161,12 +176,16 @@ void OSystem_GP2XWIZ::drawMouse() { if (!_overlayVisible) { scale = _videoMode.scaleFactor; + width = _videoMode.screenWidth; + height = _videoMode.screenHeight; dst.w = _mouseCurState.vW; dst.h = _mouseCurState.vH; hotX = _mouseCurState.vHotX; hotY = _mouseCurState.vHotY; } else { scale = 1; + width = _videoMode.overlayWidth; + height = _videoMode.overlayHeight; dst.w = _mouseCurState.rW; dst.h = _mouseCurState.rH; hotX = _mouseCurState.rHotX; @@ -231,7 +250,7 @@ void OSystem_GP2XWIZ::internUpdateScreen() { ScalerProc *scalerProc; int scale1; -#if defined (DEBUG) && ! defined(_WIN32_WCE) // definitions not available for non-DEBUG here. (needed this to compile in SYMBIAN32 & linux?) +#if defined (DEBUG) assert(_hwscreen != NULL); assert(_hwscreen->map->sw_data != NULL); #endif @@ -295,7 +314,6 @@ void OSystem_GP2XWIZ::internUpdateScreen() { width = _videoMode.overlayWidth; height = _videoMode.overlayHeight; scalerProc = Normal1x; - scale1 = 1; } @@ -358,7 +376,7 @@ void OSystem_GP2XWIZ::internUpdateScreen() { assert(scalerProc != NULL); - if (_videoMode.mode == GFX_HALF && scalerProc == DownscaleAllByHalf){ + if ((_videoMode.mode == GFX_HALF) && (scalerProc == DownscaleAllByHalf)) { if (dst_x%2==1){ dst_x--; dst_w++; @@ -371,9 +389,13 @@ void OSystem_GP2XWIZ::internUpdateScreen() { src_y = dst_y; dst_x = dst_x / 2; dst_y = dst_y / 2; - } - scalerProc((byte *)srcSurf->pixels + (src_x * 2 + 2) + (src_y + 1) * srcPitch, srcPitch, + + scalerProc((byte *)srcSurf->pixels + (src_x * 2 + 2) + (src_y + 1) * srcPitch, srcPitch, (byte *)_hwscreen->pixels + dst_x * 2 + dst_y * dstPitch, dstPitch, dst_w, dst_h); + } else { + scalerProc((byte *)srcSurf->pixels + (r->x * 2 + 2) + (r->y + 1) * srcPitch, srcPitch, + (byte *)_hwscreen->pixels + r->x * 2 + dst_y * dstPitch, dstPitch, r->w, dst_h); + } } if (_videoMode.mode == GFX_HALF && scalerProc == DownscaleAllByHalf){ diff --git a/backends/platform/gp2xwiz/gp2xwiz-main.cpp b/backends/platform/gp2xwiz/gp2xwiz-main.cpp index 394c3090c3..839afa6a95 100644 --- a/backends/platform/gp2xwiz/gp2xwiz-main.cpp +++ b/backends/platform/gp2xwiz/gp2xwiz-main.cpp @@ -30,7 +30,6 @@ #include "backends/platform/gp2xwiz/gp2xwiz-hw.h" #include "backends/plugins/posix/posix-provider.h" #include "base/main.h" -#include "base/internal_version.h" #include "common/archive.h" #include "common/config-manager.h" @@ -55,13 +54,11 @@ #include <time.h> // for getTimeAndDate() /* Dump console info to files. */ -// #define DUMP_STDOUT +#define DUMP_STDOUT int main(int argc, char *argv[]) { - g_system = new OSystem_GP2XWIZ(); assert(g_system); - #ifdef DYNAMIC_MODULES PluginManager::instance().addPluginProvider(new POSIXPluginProvider()); #endif diff --git a/backends/platform/linuxmoto/linuxmoto-main.cpp b/backends/platform/linuxmoto/linuxmoto-main.cpp index b971a65f7e..97f12e8ce1 100644 --- a/backends/platform/linuxmoto/linuxmoto-main.cpp +++ b/backends/platform/linuxmoto/linuxmoto-main.cpp @@ -31,7 +31,6 @@ #include "backends/platform/linuxmoto/linuxmoto-sdl.h" #include "base/main.h" -#include "base/internal_version.h" int main(int argc, char *argv[]) { g_system = new OSystem_LINUXMOTO(); diff --git a/backends/platform/n64/README.N64 b/backends/platform/n64/README.N64 index 276436b676..c6ae6f021e 100644 --- a/backends/platform/n64/README.N64 +++ b/backends/platform/n64/README.N64 @@ -111,5 +111,6 @@ Notes ** TODO ** ========== + Write the rest of this README. diff --git a/backends/platform/n64/osys_n64.h b/backends/platform/n64/osys_n64.h index f7560eb4d3..707bb1b7ae 100644 --- a/backends/platform/n64/osys_n64.h +++ b/backends/platform/n64/osys_n64.h @@ -98,7 +98,7 @@ protected: uint16 _gameWidth, _gameHeight; uint16 _frameBufferWidth; // Width of framebuffer in N64 memory uint8 _offscrPixels; // Pixels to skip on each line before start drawing, used to center image - uint8 _maxFps; + uint8 _maxFps; // Max frames-per-second which can be shown on screen int _shakeOffset; @@ -123,7 +123,7 @@ protected: uint8 _controllerPort; int8 _mousePort; - bool _controllerHasRumble; + bool _controllerHasRumble; // Gets enabled if rumble-pak is detected bool _dirtyOffscreen; @@ -133,8 +133,8 @@ public: uint16 _audioBufferSize; uint32 _viClockRate; // Clock rate of video system, depending on VI mode - int _timerCallbackNext; - int _timerCallbackTimer; + uint32 _timerCallbackNext; + uint32 _timerCallbackTimer; TimerProc _timerCallback; /* *** */ diff --git a/backends/platform/n64/osys_n64_base.cpp b/backends/platform/n64/osys_n64_base.cpp index 5e4b84ba3f..06ff38e586 100644 --- a/backends/platform/n64/osys_n64_base.cpp +++ b/backends/platform/n64/osys_n64_base.cpp @@ -346,8 +346,7 @@ int16 OSystem_N64::getWidth() { } void OSystem_N64::setPalette(const byte *colors, uint start, uint num) { - for (int i = 0; i < num; ++i) { - uint8 c[4]; + for (uint i = 0; i < num; ++i) { _screenPalette[start + i] = colRGB888toBGR555(colors[2], colors[1], colors[0]); colors += 4; } @@ -413,7 +412,7 @@ void OSystem_N64::grabPalette(byte *colors, uint start, uint num) { } void OSystem_N64::setCursorPalette(const byte *colors, uint start, uint num) { - for (int i = 0; i < num; ++i) { + for (uint i = 0; i < num; ++i) { _cursorPalette[start + i] = colRGB888toBGR555(colors[2], colors[1], colors[0]); colors += 4; } @@ -878,6 +877,8 @@ FilesystemFactory *OSystem_N64::getFilesystemFactory() { } void OSystem_N64::setTimerCallback(TimerProc callback, int interval) { + assert (interval > 0); + if (callback != NULL) { _timerCallbackTimer = interval; _timerCallbackNext = getMillis() + interval; diff --git a/backends/platform/n64/osys_n64_utilities.cpp b/backends/platform/n64/osys_n64_utilities.cpp index bc4661889f..88a2970d7d 100644 --- a/backends/platform/n64/osys_n64_utilities.cpp +++ b/backends/platform/n64/osys_n64_utilities.cpp @@ -42,9 +42,6 @@ void disableAudioPlayback(void) { _audioEnabled = false; - OSystem_N64 *osys = (OSystem_N64 *)g_system; - Audio::MixerImpl *localmixer = (Audio::MixerImpl *)osys->getMixer(); - while (AI_busy()); // Wait for audio to stop } diff --git a/backends/platform/psp/display_manager.cpp b/backends/platform/psp/display_manager.cpp index 544e5a1b25..e65d6f4fd0 100644 --- a/backends/platform/psp/display_manager.cpp +++ b/backends/platform/psp/display_manager.cpp @@ -53,10 +53,9 @@ uint32 __attribute__((aligned(16))) MasterGuRenderer::_displayList[2048]; const OSystem::GraphicsMode DisplayManager::_supportedModes[] = { - { "320x200 (centered)", "320x200 16-bit centered", CENTERED_320X200 }, - { "435x272 (best-fit, centered)", "435x272 16-bit centered", CENTERED_435X272 }, - { "480x272 (full screen)", "480x272 16-bit stretched", STRETCHED_480X272 }, - { "362x272 (4:3, centered)", "362x272 16-bit centered", CENTERED_362X272 }, + { "Original Resolution", "Original Resolution", ORIGINAL_RESOLUTION }, + { "Keep Aspect Ratio", "Keep Aspect Ratio", KEEP_ASPECT_RATIO }, + { "Full Screen", "Full Screen", STRETCHED_FULL_SCREEN }, {0, 0, 0} }; @@ -263,38 +262,50 @@ bool DisplayManager::setGraphicsMode(int mode) { _graphicsMode = mode; + calculateScaleParams(); + + return true; +} + +void DisplayManager::calculateScaleParams() { + + if (!_displayParams.screenSource.width || !_displayParams.screenSource.height) + return; // we can't calculate anything without these + switch (_graphicsMode) { - case CENTERED_320X200: - _displayParams.screenOutput.width = 320; - _displayParams.screenOutput.height = 200; - break; - case CENTERED_435X272: - _displayParams.screenOutput.width = 435; - _displayParams.screenOutput.height = 272; + case ORIGINAL_RESOLUTION: + // check if we can fit the original resolution inside the screen + if ((_displayParams.screenSource.width < PSP_SCREEN_WIDTH) && + (_displayParams.screenSource.height < PSP_SCREEN_HEIGHT)) { + _displayParams.screenOutput.width = _displayParams.screenSource.width; + _displayParams.screenOutput.height = _displayParams.screenSource.height; + } else { // revert to stretch to fit + _displayParams.screenOutput.width = PSP_SCREEN_WIDTH; + _displayParams.screenOutput.height = PSP_SCREEN_HEIGHT; + } break; - case STRETCHED_480X272: - _displayParams.screenOutput.width = 480; - _displayParams.screenOutput.height = 272; + case KEEP_ASPECT_RATIO: { // maximize the height while keeping aspect ratio + float aspectRatio = (float)_displayParams.screenSource.width / (float)_displayParams.screenSource.height; + + _displayParams.screenOutput.height = PSP_SCREEN_HEIGHT; // always full height + _displayParams.screenOutput.width = (uint32)(PSP_SCREEN_HEIGHT * aspectRatio); + + if (_displayParams.screenOutput.width > PSP_SCREEN_WIDTH) // we can't have wider than the screen + _displayParams.screenOutput.width = PSP_SCREEN_WIDTH; + } break; - case CENTERED_362X272: - _displayParams.screenOutput.width = 362; - _displayParams.screenOutput.height = 272; + case STRETCHED_FULL_SCREEN: // we simply stretch to the whole screen + _displayParams.screenOutput.width = PSP_SCREEN_WIDTH; + _displayParams.screenOutput.height = PSP_SCREEN_HEIGHT; break; default: PSP_ERROR("Unsupported graphics mode[%d].\n", _graphicsMode); } + + // calculate scale factors for X and Y + _displayParams.scaleX = ((float)_displayParams.screenOutput.width) / _displayParams.screenSource.width; + _displayParams.scaleY = ((float)_displayParams.screenOutput.height) / _displayParams.screenSource.height; - calculateScaleParams(); - - return true; -} - -void DisplayManager::calculateScaleParams() { - if (_displayParams.screenOutput.width && _displayParams.screenSource.width && - _displayParams.screenOutput.height && _displayParams.screenSource.height) { - _displayParams.scaleX = ((float)_displayParams.screenOutput.width) / _displayParams.screenSource.width; - _displayParams.scaleY = ((float)_displayParams.screenOutput.height) / _displayParams.screenSource.height; - } } // return true if we really rendered or no dirty. False otherwise diff --git a/backends/platform/psp/display_manager.h b/backends/platform/psp/display_manager.h index 72f252faae..626415696a 100644 --- a/backends/platform/psp/display_manager.h +++ b/backends/platform/psp/display_manager.h @@ -61,10 +61,9 @@ class PSPKeyboard; class DisplayManager { public: enum GraphicsModeID { ///> Possible output formats onscreen - CENTERED_320X200, - CENTERED_435X272, - STRETCHED_480X272, - CENTERED_362X272 + ORIGINAL_RESOLUTION, + KEEP_ASPECT_RATIO, + STRETCHED_FULL_SCREEN }; DisplayManager() : _screen(0), _cursor(0), _overlay(0), _keyboard(0), _lastUpdateTime(0), _graphicsMode(0) {} ~DisplayManager(); @@ -74,7 +73,7 @@ public: bool setGraphicsMode(int mode); bool setGraphicsMode(const char *name); int getGraphicsMode() const { return _graphicsMode; } - uint32 getDefaultGraphicsMode() const { return STRETCHED_480X272; } + uint32 getDefaultGraphicsMode() const { return STRETCHED_FULL_SCREEN; } const OSystem::GraphicsMode* getSupportedGraphicsModes() const { return _supportedModes; } // Setters diff --git a/backends/platform/psp/mp3.cpp b/backends/platform/psp/mp3.cpp index e25891396b..98e8a0404b 100644 --- a/backends/platform/psp/mp3.cpp +++ b/backends/platform/psp/mp3.cpp @@ -60,6 +60,21 @@ bool Mp3PspStream::_decoderFail = true; // pretend the decoder failed bool Mp3PspStream::_decoderFail = false; // has the decoder failed to load #endif +// Arranged in groups of 3 (layers), starting with MPEG-1 and ending with MPEG 2.5 +static uint32 mp3SamplesPerFrame[9] = {384, 1152, 1152, 384, 1152, 576, 384, 1152, 576}; + +// The numbering below doesn't correspond to the way they are in the header +enum { + MPEG_VER1 = 0, + MPEG_VER1_HEADER = 0x3, + MPEG_VER2 = 1, + MPEG_VER2_HEADER = 0x2, + MPEG_VER2_5 = 2, + MPEG_VER2_5_HEADER = 0x0 +}; + +#define HEADER_GET_MPEG_VERSION(x) ((((x)[1])>>3) & 0x3) + bool Mp3PspStream::initDecoder() { DEBUG_ENTER_FUNC(); @@ -104,7 +119,7 @@ bool Mp3PspStream::stopDecoder() { return true; // Based on PSP firmware version, we need to do different things to do Media Engine processing - if (sceKernelDevkitVersion() == 0x01050001){ + if (sceKernelDevkitVersion() == 0x01050001){ // TODO: how do we unload? /* if (!unloadAudioModule("flash0:/kd/me_for_vsh.prx", PSP_MEMORY_PARTITION_KERNEL) || !unloadAudioModule("flash0:/kd/audiocodec.prx", PSP_MEMORY_PARTITION_KERNEL) { PSP_ERROR("failed to unload audio module\n"); @@ -172,17 +187,16 @@ Mp3PspStream::Mp3PspStream(Common::SeekableReadStream *inStream, DisposeAfterUse initStream(); // init needed stuff for the stream - while (_state != MP3_STATE_EOS) - findValidHeader(); // get a first header so we can read basic stuff + findValidHeader(); // get a first header so we can read basic stuff _sampleRate = _header.samplerate; // copy it before it gets destroyed + + while (_state != MP3_STATE_EOS) + findValidHeader(); // get a first header so we can read basic stuff _length = Timestamp(mad_timer_count(_totalTime, MAD_UNITS_MILLISECONDS), getRate()); - //initStreamME(); // init the stuff needed for the ME to work - deinitStream(); - //releaseStreamME(); _state = MP3_STATE_INIT; } @@ -213,7 +227,6 @@ int Mp3PspStream::initStream() { bool Mp3PspStream::initStreamME() { // The following will eventually go into the thread - sceAudiocodecReleaseEDRAM(_codecParams); // do we need this? memset(_codecParams, 0, sizeof(_codecParams)); @@ -285,27 +298,23 @@ void Mp3PspStream::decodeMP3Data() { findValidHeader(); // seach for next valid header - while (_state == MP3_STATE_READY) { + while (_state == MP3_STATE_READY) { // not a real 'while'. Just for easy flow _stream.error = MAD_ERROR_NONE; uint32 frame_size = _stream.next_frame - _stream.this_frame; - uint32 samplesPerFrame = _header.layer == MAD_LAYER_III ? 576 : 1152; // Varies by layer - // calculate frame size -- try - //uint32 calc_frame_size = ((144 * _header.bitrate) / 22050) + (_header.flags & MAD_FLAG_PADDING ? 1 : 0); - // Get stereo/mono - uint32 multFactor = 1; - if (_header.mode != MAD_MODE_SINGLE_CHANNEL) // mono - x2 for 16bit - multFactor *= 2; // stereo - x4 for 16bit - - PSP_DEBUG_PRINT("MP3 frame size[%d]. Samples[%d]. Multfactor[%d] pad[%d]\n", frame_size, samplesPerFrame, multFactor, _header.flags & MAD_FLAG_PADDING); + updatePcmLength(); // Retrieve the number of PCM samples. + // We seem to change this, so it needs to be dynamic + + PSP_DEBUG_PRINT("MP3 frame size[%d]. pcmLength[%d]\n", frame_size, _pcmLength); + memcpy(_codecInBuffer, _stream.this_frame, frame_size); // we need it aligned // set up parameters for ME _codecParams[6] = (unsigned long)_codecInBuffer; _codecParams[8] = (unsigned long)_pcmSamples; _codecParams[7] = frame_size; - _codecParams[9] = samplesPerFrame * multFactor; // x2 for stereo + _codecParams[9] = _pcmLength * 2; // x2 for stereo, though this one's not so important // debug #ifdef PRINT_BUFFERS @@ -320,7 +329,6 @@ void Mp3PspStream::decodeMP3Data() { int ret = sceAudiocodecDecode(_codecParams, 0x1002); if (ret < 0) { PSP_INFO_PRINT("failed to decode MP3 data in ME. sceAudiocodecDecode returned 0x%x\n", ret); - // handle error here } #ifdef PRINT_BUFFERS @@ -330,7 +338,6 @@ void Mp3PspStream::decodeMP3Data() { } PSP_DEBUG_PRINT("\n"); #endif - _pcmLength = samplesPerFrame; _posInFrame = 0; break; } @@ -340,6 +347,27 @@ void Mp3PspStream::decodeMP3Data() { _state = MP3_STATE_EOS; } +inline void Mp3PspStream::updatePcmLength() { + uint32 mpegVer = HEADER_GET_MPEG_VERSION(_stream.this_frame); // sadly, MAD can't do this for us + PSP_DEBUG_PRINT("mpeg ver[%x]\n", mpegVer); + switch (mpegVer) { + case MPEG_VER1_HEADER: + mpegVer = MPEG_VER1; + break; + case MPEG_VER2_HEADER: + mpegVer = MPEG_VER2; + break; + case MPEG_VER2_5_HEADER: + mpegVer = MPEG_VER2_5; + break; + default: + PSP_ERROR("Unknown MPEG version %x\n", mpegVer); + break; + } + PSP_DEBUG_PRINT("layer[%d]\n", _header.layer); + _pcmLength = mp3SamplesPerFrame[(mpegVer * 3) + _header.layer - 1]; +} + void Mp3PspStream::readMP3DataIntoBuffer() { DEBUG_ENTER_FUNC(); @@ -393,10 +421,6 @@ bool Mp3PspStream::seek(const Timestamp &where) { initStreamME(); } - // The ME will need clear data no matter what once we seek? - //if (mad_timer_compare(destination, _totalTime) > 0 && _state != MP3_STATE_EOS) - // initStreamME(); - // Skip ahead while (mad_timer_compare(destination, _totalTime) > 0 && _state != MP3_STATE_EOS) findValidHeader(); @@ -463,9 +487,6 @@ int Mp3PspStream::readBuffer(int16 *buffer, const int numSamples) { _posInFrame++; // always skip an extra sample since ME always outputs stereo } - //memcpy(buffer, &_pcmSamples[_posInFrame], len << 1); // 16 bits - //_posInFrame += len; // next time we start from the middle - if (_posInFrame >= _pcmLength) { // We used up all PCM data in the current frame -- read & decode more decodeMP3Data(); @@ -482,6 +503,4 @@ int Mp3PspStream::readBuffer(int16 *buffer, const int numSamples) { return samples; } -} // End of namespace Audio - - +} // End of namespace Audio
\ No newline at end of file diff --git a/backends/platform/psp/mp3.h b/backends/platform/psp/mp3.h index 029b3e498c..983f4cb7f4 100644 --- a/backends/platform/psp/mp3.h +++ b/backends/platform/psp/mp3.h @@ -46,7 +46,7 @@ protected: MP3_STATE_EOS // end of data reached (may need to loop) }; - #define MAX_SAMPLES_PER_FRAME 2048 * 2 + #define MAX_SAMPLES_PER_FRAME 1152 * 2 /* x2 for stereo */ int16 _pcmSamples[MAX_SAMPLES_PER_FRAME] __attribute__((aligned(64))); // samples to output PCM data into byte _codecInBuffer[3072] __attribute__((aligned(64))); // the codec always needs alignment unsigned long _codecParams[65]__attribute__((aligned(64))); // TODO: change to struct @@ -54,7 +54,7 @@ protected: Common::SeekableReadStream *_inStream; DisposeAfterUse::Flag _disposeAfterUse; - uint32 _pcmLength; // how many pcm samples we have (/2 for mono) + uint32 _pcmLength; // how many pcm samples we have for this type of file (x2 this for stereo) uint _posInFrame; // position in frame State _state; // what state the stream is in @@ -83,7 +83,8 @@ protected: int initStream(); void findValidHeader(); void deinitStream(); - + void updatePcmLength(); + // to init and uninit ME decoder static bool initDecoder(); static bool stopDecoder(); diff --git a/backends/platform/psp/tests.cpp b/backends/platform/psp/tests.cpp index d1bdb9e640..f65c13ae83 100644 --- a/backends/platform/psp/tests.cpp +++ b/backends/platform/psp/tests.cpp @@ -43,7 +43,9 @@ #include "backends/platform/psp/rtc.h" #include "backends/platform/psp/thread.h" #include "backends/platform/psp/memory.h" - +#include "common/stream.h" +#include "common/file.h" +#include "common/fs.h" #define UNCACHED(x) ((byte *)(((uint32)(x)) | 0x40000000)) /* make an uncached access */ #define CACHED(x) ((byte *)(((uint32)(x)) & 0xBFFFFFFF)) /* make an uncached access into a cached one */ @@ -445,6 +447,7 @@ void PspSpeedTests::fastCopySpeed() { class PspUnitTests { public: void testFastCopy(); + bool testFileSystem(); private: enum { @@ -453,6 +456,7 @@ private: void fastCopySpecificSize(byte *dst, byte *src, uint32 bytes, bool swap = false); void fastCopyDifferentSizes(byte *dst, byte *src, bool swap = false); + }; void PspUnitTests::testFastCopy() { @@ -537,6 +541,171 @@ void PspUnitTests::fastCopySpecificSize(byte *dst, byte *src, uint32 bytes, bool } } +// This function leaks. For now I don't care +bool PspUnitTests::testFileSystem() { + // create memory + const uint32 BufSize = 32 * 1024; + char* buffer = new char[BufSize]; + int i; + Common::WriteStream *wrStream; + Common::SeekableReadStream *rdStream; + + PSP_INFO_PRINT("testing fileSystem...\n"); + + // fill buffer + for (i=0; i<(int)BufSize; i += 4) { + buffer[i] = 'A'; + buffer[i + 1] = 'B'; + buffer[i + 2] = 'C'; + buffer[i + 3] = 'D'; + } + + // create a file + const char *path = "./file.test"; + Common::FSNode file(path); + + PSP_INFO_PRINT("creating write stream...\n"); + + wrStream = file.createWriteStream(); + if (!wrStream) { + PSP_ERROR("%s couldn't be created.\n", path); + return false; + } + + // write contents + char* index = buffer; + int32 totalLength = BufSize; + int32 curLength = 50; + + PSP_INFO_PRINT("writing...\n"); + + while(totalLength - curLength > 0) { + if ((int)wrStream->write(index, curLength) != curLength) { + PSP_ERROR("couldn't write %d bytes\n", curLength); + return false; + } + totalLength -= curLength; + index += curLength; + //curLength *= 2; + //PSP_INFO_PRINT("write\n"); + } + + // write the rest + if ((int)wrStream->write(index, totalLength) != totalLength) { + PSP_ERROR("couldn't write %d bytes\n", curLength); + return false; + } + + delete wrStream; + + PSP_INFO_PRINT("reading...\n"); + + rdStream = file.createReadStream(); + if (!rdStream) { + PSP_ERROR("%s couldn't be created.\n", path); + return false; + } + + // seek to beginning + if (!rdStream->seek(0, SEEK_SET)) { + PSP_ERROR("couldn't seek to the beginning after writing the file\n"); + return false; + } + + // read the contents + char *readBuffer = new char[BufSize + 4]; + memset(readBuffer, 0, (BufSize + 4)); + index = readBuffer; + while (rdStream->read(index, 100) == 100) { + index += 100; + } + + if (!rdStream->eos()) { + PSP_ERROR("didn't find EOS at end of stream\n"); + return false; + } + + // compare + for (i=0; i<(int)BufSize; i++) + if (buffer[i] != readBuffer[i]) { + PSP_ERROR("reading/writing mistake at %x. Got %x instead of %x\n", i, readBuffer[i], buffer[i]); + return false; + } + + // Check for exceeding limit + for (i=0; i<4; i++) { + if (readBuffer[BufSize + i]) { + PSP_ERROR("read exceeded limits. %d = %x\n", BufSize + i, readBuffer[BufSize + i]); + } + } + + delete rdStream; + + PSP_INFO_PRINT("writing...\n"); + + wrStream = file.createWriteStream(); + if (!wrStream) { + PSP_ERROR("%s couldn't be created.\n", path); + return false; + } + + const char *phrase = "Jello is really fabulous"; + uint32 phraseLen = strlen(phrase); + + int ret; + if ((ret = wrStream->write(phrase, phraseLen)) != (int)phraseLen) { + PSP_ERROR("couldn't write phrase. Got %d instead of %d\n", ret, phraseLen); + return false; + } + + PSP_INFO_PRINT("reading...\n"); + + delete wrStream; + rdStream = file.createReadStream(); + if (!rdStream) { + PSP_ERROR("%s couldn't be created.\n", path); + return false; + } + + char *readPhrase = new char[phraseLen + 2]; + memset(readPhrase, 0, phraseLen + 2); + + if ((ret = rdStream->read(readPhrase, phraseLen) != phraseLen)) { + PSP_ERROR("read error on phrase. Got %d instead of %d\n", ret, phraseLen); + return false; + } + + for (i=0; i<(int)phraseLen; i++) { + if (readPhrase[i] != phrase[i]) { + PSP_ERROR("bad read/write in phrase. At %d, %x != %x\n", i, readPhrase[i], phrase[i]); + return false; + } + } + + // check for exceeding + if (readPhrase[i] != 0) { + PSP_ERROR("found excessive copy in phrase. %c at %d\n", readPhrase[i], i); + return false; + } + + PSP_INFO_PRINT("trying to read end...\n"); + + // seek to end + if (!rdStream->seek(0, SEEK_END)) { + PSP_ERROR("couldn't seek to end for append\n"); + return false; + }; + + // try to read + if (rdStream->read(readPhrase, 2) || !rdStream->eos()) { + PSP_ERROR("was able to read at end of file\n"); + return false; + } + + PSP_INFO_PRINT("ok\n"); + return true; +} + void psp_tests() { PSP_INFO_PRINT("in tests\n"); @@ -558,7 +727,8 @@ void psp_tests() { // Unit tests PspUnitTests unitTests; - unitTests.testFastCopy(); + //unitTests.testFastCopy(); + unitTests.testFileSystem(); #endif } diff --git a/backends/platform/sdl/graphics.cpp b/backends/platform/sdl/graphics.cpp index a97a153f3c..9bf71d1c33 100644 --- a/backends/platform/sdl/graphics.cpp +++ b/backends/platform/sdl/graphics.cpp @@ -56,6 +56,8 @@ static const OSystem::GraphicsMode s_supportedGraphicsModes[] = { {0, 0, 0} }; +DECLARE_TRANSLATION_ADDITIONAL_CONTEXT("Normal (no scaling)", "lowres") + // Table of relative scalers magnitudes // [definedScale - 1][scaleFactor - 1] static ScalerProc *scalersMagn[3][3] = { @@ -537,7 +539,7 @@ bool OSystem_SDL::loadGFXMode() { assert(_inited); _forceFull = true; -#if !defined(__MAEMO__) && !defined(GP2XWIZ) && !defined(LINUXMOTO) +#if !defined(__MAEMO__) && !defined(GP2XWIZ) && !defined(LINUXMOTO) && !defined(DINGUX) _videoMode.overlayWidth = _videoMode.screenWidth * _videoMode.scaleFactor; _videoMode.overlayHeight = _videoMode.screenHeight * _videoMode.scaleFactor; @@ -1393,9 +1395,11 @@ void OSystem_SDL::setMousePos(int x, int y) { void OSystem_SDL::warpMouse(int x, int y) { int y1 = y; - // Don't change mouse position, when mouse is outside of our window (in case of windowed mode) - if (!(SDL_GetAppState( ) & SDL_APPMOUSEFOCUS)) + // Don't change actual mouse position, when mouse is outside of our window (in case of windowed mode) + if (!(SDL_GetAppState( ) & SDL_APPMOUSEFOCUS)) { + setMousePos(x, y); // but change game cursor position return; + } if (_videoMode.aspectRatioCorrection && !_overlayVisible) y1 = real2Aspect(y); diff --git a/backends/platform/sdl/main.cpp b/backends/platform/sdl/main.cpp index 52bbb59165..9d116d325a 100644 --- a/backends/platform/sdl/main.cpp +++ b/backends/platform/sdl/main.cpp @@ -38,7 +38,7 @@ // Several SDL based ports use a custom main, and hence do not want to compile // of this file. The following "#if" ensures that. -#if !defined(__MAEMO__) && !defined(_WIN32_WCE) && !defined(GP2XWIZ)&& !defined(LINUXMOTO) && !defined(__SYMBIAN32__) +#if !defined(__MAEMO__) && !defined(_WIN32_WCE) && !defined(GP2XWIZ)&& !defined(LINUXMOTO) && !defined(__SYMBIAN32__) && !defined(DINGUX) #include "backends/platform/sdl/sdl.h" diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp index 6686249416..22fc561b0f 100644 --- a/backends/platform/sdl/sdl.cpp +++ b/backends/platform/sdl/sdl.cpp @@ -150,7 +150,7 @@ void OSystem_SDL::initBackend() { memset(&_videoMode, 0, sizeof(_videoMode)); memset(&_transactionDetails, 0, sizeof(_transactionDetails)); -#if !defined(_WIN32_WCE) && !defined(__SYMBIAN32__) && defined(USE_SCALERS) +#if !defined(_WIN32_WCE) && !defined(DINGUX) && !defined(__SYMBIAN32__) && defined(USE_SCALERS) _videoMode.mode = GFX_DOUBLESIZE; _videoMode.scaleFactor = 2; _videoMode.aspectRatioCorrection = ConfMan.getBool("aspect_ratio"); diff --git a/backends/platform/symbian/AdaptAllMMPs.pl b/backends/platform/symbian/AdaptAllMMPs.pl index 2fba99b873..8b7151c180 100644 --- a/backends/platform/symbian/AdaptAllMMPs.pl +++ b/backends/platform/symbian/AdaptAllMMPs.pl @@ -33,6 +33,7 @@ chdir("../../../"); "mmp/scummvm_draci.mmp", "mmp/scummvm_teenagent.mmp", "mmp/scummvm_mohawk.mmp", + "mmp/scummvm_hugo.mmp", # Target Platform Project Files "S60/ScummVM_S60.mmp", "S60v3/ScummVM_S60v3.mmp", @@ -79,9 +80,9 @@ my @excludes_snd = ( "fluidsynth.cpp", "i386.cpp", "part.*", - "synth.cpp", "tables.cpp", "freeverb.cpp", + "synth.cpp", "rate.*" # not really needed, USE_ARM_SOUND_ASM currently not parsed correctly, # "rate[_arm|_arm_asm].(cpp|s)" will be added later based on WINS/ARM build! # These #defines for compile time are set in portdefs.h @@ -136,6 +137,7 @@ ParseModule("_sci", "sci", \@section_empty); ParseModule("_draci", "draci", \@section_empty); ParseModule("_teenagent","teenagent", \@section_empty); ParseModule("_mohawk" ,"mohawk", \@section_empty); +ParseModule("_hugo" ,"hugo", \@section_empty); print " ======================================================================================= Done. Enjoy :P diff --git a/backends/platform/symbian/BuildPackageUpload_LocalSettings.pl b/backends/platform/symbian/BuildPackageUpload_LocalSettings.pl index a9e7aa562a..b6ebbafe74 100644 --- a/backends/platform/symbian/BuildPackageUpload_LocalSettings.pl +++ b/backends/platform/symbian/BuildPackageUpload_LocalSettings.pl @@ -4,27 +4,24 @@ @WorkingEngines = qw( scumm agos sky queen gob groovie saga drascula kyra lure agi touche parallaction cine - cruise made m4 tinsel tucker sword1 sword2 draci sci teenagent mohawk + cruise made m4 tinsel tucker sword1 sword2 draci sci teenagent mohawk hugo ); @WorkingEngines_1st = qw( scumm queen groovie saga drascula touche parallaction cine - cruise made m4 tucker +? cruise made m4 tucker ); @WorkingEngines_2nd = qw( agos sky gob kyra lure agi tinsel - sword1 sword2 draci teenagent + sword1 sword2 draci sci teenagent hugo ); @TestingEngines = qw( - ); - - @BrokenEngines = qw( - ); + ); @EnablableEngines = (@WorkingEngines, @TestingEngines); @@ -249,7 +246,7 @@ $SDK_RootDirs{'S60v3'}= "G:\\S60v3"; #$SDK_RootDirs{'S80'}= "D:\\S80"; #$SDK_RootDirs{'S90'}= "D:\\S90"; - $ECompXL_BinDir= "D:\\ECompXL\\"; + #$ECompXL_BinDir= "D:\\ECompXL\\"; if (0) # so we can turn them on/off easily { # $SDK_LibraryDirs{'ALL'}{'zlib.lib'} = "C:\\S\\zlib-1.2.2\\epoc"; @@ -305,7 +302,8 @@ # the first one includes all SDKs & release-ready engines $VariationSets{'ALL'}{'all'} = "$DefaultFeatures @WorkingEngines @EnablableSubEngines"; - + $VariationSets{'ALL'}{'1St'} = "$DefaultFeatures @WorkingEngines_1st @EnablableSubEngines"; + $VariationSets{'ALL'}{'2nd'} = "$DefaultFeatures @WorkingEngines_2nd @EnablableSubEngines"; # now one for each ready-for-release engine if (0) { diff --git a/backends/platform/symbian/mmp/scummvm_base.mmp.in b/backends/platform/symbian/mmp/scummvm_base.mmp.in index c178440fa9..ceb62ec843 100644 --- a/backends/platform/symbian/mmp/scummvm_base.mmp.in +++ b/backends/platform/symbian/mmp/scummvm_base.mmp.in @@ -98,6 +98,8 @@ SOURCEPATH ..\..\..\..\sound // empty base file, will be updated by Perl build scripts //STOP_AUTO_OBJECTS_SOUND_// +SOURCE softsynth\fmtowns_pc98\towns_pc98_fmsynth.cpp // Included since its excluded by filter + #if defined (WINS) SOURCE rate.cpp // WINS emulator version: add regular .cpp #else diff --git a/backends/platform/symbian/mmp/scummvm_hugo.mmp.in b/backends/platform/symbian/mmp/scummvm_hugo.mmp.in new file mode 100644 index 0000000000..4d44ebc944 --- /dev/null +++ b/backends/platform/symbian/mmp/scummvm_hugo.mmp.in @@ -0,0 +1,64 @@ +/* ScummVM - Graphic Adventure Engine + * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL + * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System + * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer + * Copyright (C) 2005-2010 The ScummVM project + * + * 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$ + * + */ + +// +// EPOC MMP makefile project for ScummVM +// + +// *** Definitions + +TARGET scummvm_hugo.lib +TARGETTYPE lib +OPTION MSVC /QIfist /Ob1 /Oy /GF // /QIfist disables use of __ftol2 to avoid linker probs with MS libc: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore/html/vcrefQIfistSuppress_ftol.asp +OPTION GCC -Wno-multichar -Wno-reorder // don't optimize for ARM, platform way too sensitive for that :( just turn off some common warnings +OPTION GCCE -Wno-multichar -Wno-reorder -Wno-unused -Wno-format -fsigned-char +ALWAYS_BUILD_AS_ARM + +//START_AUTO_MACROS_SLAVE// + + // empty base file, will be updated by Perl build scripts + +//STOP_AUTO_MACROS_SLAVE// + +// *** SOURCE files + +SOURCEPATH ..\..\..\..\engines\hugo + +//START_AUTO_OBJECTS_HUGO_// + + // empty base file, will be updated by Perl build scripts + +//STOP_AUTO_OBJECTS_HUGO_// + +// *** Include paths + +USERINCLUDE ..\..\..\..\engines +USERINCLUDE ..\..\..\.. ..\..\..\..\common ..\..\..\..\gui ..\..\..\..\sound ..\src +SYSTEMINCLUDE \epoc32\include\ZLIB // before \epoc32\include because symbian already has older version +SYSTEMINCLUDE \epoc32\include \epoc32\include\libc ..\src diff --git a/backends/platform/wii/osystem.h b/backends/platform/wii/osystem.h index eaaf616538..ed33b43a81 100644 --- a/backends/platform/wii/osystem.h +++ b/backends/platform/wii/osystem.h @@ -117,6 +117,7 @@ private: void deinitGfx(); void updateScreenResolution(); void switchVideoMode(int mode); + bool needsScreenUpdate(); void initSfx(); void deinitSfx(); diff --git a/backends/platform/wii/osystem_events.cpp b/backends/platform/wii/osystem_events.cpp index 488834fc20..5d0bca453f 100644 --- a/backends/platform/wii/osystem_events.cpp +++ b/backends/platform/wii/osystem_events.cpp @@ -300,6 +300,9 @@ bool OSystem_Wii::pollEvent(Common::Event &event) { return true; } + if (needsScreenUpdate()) + updateScreen(); + u32 bd = 0, bh = 0, bu = 0; if (PAD_ScanPads() & 1) { diff --git a/backends/platform/wii/osystem_gfx.cpp b/backends/platform/wii/osystem_gfx.cpp index 3ce6343800..09575bb83d 100644 --- a/backends/platform/wii/osystem_gfx.cpp +++ b/backends/platform/wii/osystem_gfx.cpp @@ -441,6 +441,22 @@ void OSystem_Wii::copyRectToScreen(const byte *buf, int pitch, int x, int y, _gameDirty = true; } +bool OSystem_Wii::needsScreenUpdate() { + if (getMillis() - _lastScreenUpdate < 1000 / MAX_FPS) + return false; + + if (_gameRunning && _gameDirty) + return true; + + if (_overlayVisible && _overlayDirty) + return true; + + if (_mouseVisible && _texMouse.palette && _cursorPaletteDirty) + return true; + + return false; +} + void OSystem_Wii::updateScreen() { static f32 ar; static gfx_screen_coords_t cc; |