diff options
Diffstat (limited to 'backends')
128 files changed, 1486 insertions, 1191 deletions
diff --git a/backends/events/gph/gph-events.cpp b/backends/events/gph/gph-events.cpp index b4e106b790..91118d36c1 100644 --- a/backends/events/gph/gph-events.cpp +++ b/backends/events/gph/gph-events.cpp @@ -161,49 +161,6 @@ GPHEventSource::GPHEventSource() : _buttonStateL(false) { } -void GPHEventSource::moveStick() { - bool stickBtn[32]; - - memcpy(stickBtn, _stickBtn, sizeof(stickBtn)); - - if ((stickBtn[0]) || (stickBtn[2]) || (stickBtn[4]) || (stickBtn[6])) - stickBtn[1] = stickBtn[3] = stickBtn[5] = stickBtn[7] = 0; - - if ((stickBtn[1]) || (stickBtn[2]) || (stickBtn[3])) { - if (_km.x_down_count != 2) { - _km.x_vel = -1; - _km.x_down_count = 1; - } else - _km.x_vel = -4; - } else if ((stickBtn[5]) || (stickBtn[6]) || (stickBtn[7])) { - if (_km.x_down_count != 2) { - _km.x_vel = 1; - _km.x_down_count = 1; - } else - _km.x_vel = 4; - } else { - _km.x_vel = 0; - _km.x_down_count = 0; - } - - if ((stickBtn[0]) || (stickBtn[1]) || (stickBtn[7])) { - if (_km.y_down_count != 2) { - _km.y_vel = -1; - _km.y_down_count = 1; - } else - _km.y_vel = -4; - } else if ((stickBtn[3]) || (stickBtn[4]) || (stickBtn[5])) { - if (_km.y_down_count != 2) { - _km.y_vel = 1; - _km.y_down_count = 1; - } else - _km.y_vel = 4; - } else { - _km.y_vel = 0; - _km.y_down_count = 0; - } -} - /* Custom handleMouseButtonDown/handleMouseButtonUp to deal with 'Tap Mode' for the touchscreen */ bool GPHEventSource::handleMouseButtonDown(SDL_Event &ev, Common::Event &event) { @@ -268,19 +225,110 @@ bool GPHEventSource::handleMouseButtonUp(SDL_Event &ev, Common::Event &event) { bool GPHEventSource::handleJoyButtonDown(SDL_Event &ev, Common::Event &event) { - _stickBtn[ev.jbutton.button] = 1; event.kbd.flags = 0; switch (ev.jbutton.button) { case BUTTON_UP: - case BUTTON_UPLEFT: - case BUTTON_LEFT: - case BUTTON_DOWNLEFT: + if (_km.y_down_count != 2) { + _km.y_vel = -1; + _km.y_down_count = 1; + } else { + _km.y_vel = -4; + } + event.type = Common::EVENT_MOUSEMOVE; + processMouseEvent(event, _km.x, _km.y); + break; case BUTTON_DOWN: - case BUTTON_DOWNRIGHT: + if (_km.y_down_count != 2) { + _km.y_vel = 1; + _km.y_down_count = 1; + } else { + _km.y_vel = 4; + } + event.type = Common::EVENT_MOUSEMOVE; + processMouseEvent(event, _km.x, _km.y); + break; + case BUTTON_LEFT: + if (_km.x_down_count != 2) { + _km.x_vel = -1; + _km.x_down_count = 1; + } else { + _km.x_vel = -4; + } + event.type = Common::EVENT_MOUSEMOVE; + processMouseEvent(event, _km.x, _km.y); + break; case BUTTON_RIGHT: + if (_km.x_down_count != 3) { + _km.x_vel = 1; + _km.x_down_count = 1; + } else { + _km.x_vel = 4; + } + event.type = Common::EVENT_MOUSEMOVE; + processMouseEvent(event, _km.x, _km.y); + break; + case BUTTON_UPLEFT: + if (_km.x_down_count != 2) { + _km.x_vel = -1; + _km.x_down_count = 1; + } else { + _km.x_vel = -4; + } + if (_km.y_down_count != 2) { + _km.y_vel = -1; + _km.y_down_count = 1; + } else { + _km.y_vel = -4; + } + event.type = Common::EVENT_MOUSEMOVE; + processMouseEvent(event, _km.x, _km.y); + break; case BUTTON_UPRIGHT: - moveStick(); + if (_km.x_down_count != 2) { + _km.x_vel = 1; + _km.x_down_count = 1; + } else { + _km.x_vel = 4; + } + if (_km.y_down_count != 2) { + _km.y_vel = -1; + _km.y_down_count = 1; + } else { + _km.y_vel = -4; + } + event.type = Common::EVENT_MOUSEMOVE; + processMouseEvent(event, _km.x, _km.y); + break; + case BUTTON_DOWNLEFT: + if (_km.x_down_count != 2) { + _km.x_vel = -1; + _km.x_down_count = 1; + } else { + _km.x_vel = -4; + } + if (_km.y_down_count != 2) { + _km.y_vel = 1; + _km.y_down_count = 1; + } else { + _km.y_vel = 4; + } + event.type = Common::EVENT_MOUSEMOVE; + processMouseEvent(event, _km.x, _km.y); + break; + case BUTTON_DOWNRIGHT: + if (_km.x_down_count != 2) { + _km.x_vel = 1; + _km.x_down_count = 1; + } else { + _km.x_vel = 4; + } + if (_km.y_down_count != 2) { + _km.y_vel = 1; + _km.y_down_count = 1; + } else { + _km.y_vel = 4; + } event.type = Common::EVENT_MOUSEMOVE; processMouseEvent(event, _km.x, _km.y); break; @@ -391,7 +439,6 @@ bool GPHEventSource::handleJoyButtonDown(SDL_Event &ev, Common::Event &event) { bool GPHEventSource::handleJoyButtonUp(SDL_Event &ev, Common::Event &event) { - _stickBtn[ev.jbutton.button] = 0; event.kbd.flags = 0; switch (ev.jbutton.button) { @@ -403,7 +450,10 @@ bool GPHEventSource::handleJoyButtonUp(SDL_Event &ev, Common::Event &event) { case BUTTON_DOWNRIGHT: case BUTTON_RIGHT: case BUTTON_UPRIGHT: - moveStick(); + _km.y_vel = 0; + _km.y_down_count = 0; + _km.x_vel = 0; + _km.x_down_count = 0; event.type = Common::EVENT_MOUSEMOVE; processMouseEvent(event, _km.x, _km.y); break; diff --git a/backends/events/gph/gph-events.h b/backends/events/gph/gph-events.h index 7672bffed2..3b1e6f090a 100644 --- a/backends/events/gph/gph-events.h +++ b/backends/events/gph/gph-events.h @@ -34,18 +34,11 @@ public: GPHEventSource(); protected: - bool _stickBtn[32]; - /** * Button state for L button modifier */ bool _buttonStateL; - /** - * Handles the stick movement - */ - void moveStick(); - bool handleJoyButtonDown(SDL_Event &ev, Common::Event &event); bool handleJoyButtonUp(SDL_Event &ev, Common::Event &event); bool handleMouseButtonDown(SDL_Event &ev, Common::Event &event); diff --git a/backends/events/openpandora/op-events.cpp b/backends/events/openpandora/op-events.cpp index c1d6362fcb..fc63cdf74f 100644 --- a/backends/events/openpandora/op-events.cpp +++ b/backends/events/openpandora/op-events.cpp @@ -44,7 +44,8 @@ enum { /* Touchscreen TapMode */ TAPMODE_LEFT = 0, TAPMODE_RIGHT = 1, - TAPMODE_HOVER = 2 + TAPMODE_HOVER = 2, + TAPMODE_HOVER_DPAD = 3 }; OPEventSource::OPEventSource() @@ -63,6 +64,8 @@ bool OPEventSource::handleMouseButtonDown(SDL_Event &ev, Common::Event &event) { event.type = Common::EVENT_RBUTTONDOWN; else if (OP::tapmodeLevel == TAPMODE_HOVER) /* TAPMODE_HOVER = Hover (No Click) Tap Mode */ event.type = Common::EVENT_MOUSEMOVE; + else if (OP::tapmodeLevel == TAPMODE_HOVER_DPAD) /* TAPMODE_HOVER_DPAD = Hover (DPad Clicks) Tap Mode */ + event.type = Common::EVENT_MOUSEMOVE; else event.type = Common::EVENT_LBUTTONDOWN; /* For normal mice etc. */ } else if (ev.button.button == SDL_BUTTON_RIGHT) @@ -95,6 +98,8 @@ bool OPEventSource::handleMouseButtonUp(SDL_Event &ev, Common::Event &event) { event.type = Common::EVENT_RBUTTONUP; else if (OP::tapmodeLevel == TAPMODE_HOVER) /* TAPMODE_HOVER = Hover (No Click) Tap Mode */ event.type = Common::EVENT_MOUSEMOVE; + else if (OP::tapmodeLevel == TAPMODE_HOVER_DPAD) /* TAPMODE_HOVER_DPAD = Hover (DPad Clicks) Tap Mode */ + event.type = Common::EVENT_MOUSEMOVE; else event.type = Common::EVENT_LBUTTONUP; /* For normal mice etc. */ } else if (ev.button.button == SDL_BUTTON_RIGHT) @@ -117,6 +122,30 @@ bool OPEventSource::handleMouseButtonUp(SDL_Event &ev, Common::Event &event) { bool OPEventSource::remapKey(SDL_Event &ev, Common::Event &event) { + if (OP::tapmodeLevel == TAPMODE_HOVER_DPAD) { + switch (ev.key.keysym.sym) { + case SDLK_LEFT: + event.type = (ev.type == SDL_KEYDOWN) ? Common::EVENT_LBUTTONDOWN : Common::EVENT_LBUTTONUP; + processMouseEvent(event, _km.x, _km.y); + return true; + break; + case SDLK_RIGHT: + event.type = (ev.type == SDL_KEYDOWN) ? Common::EVENT_RBUTTONDOWN : Common::EVENT_RBUTTONUP; + processMouseEvent(event, _km.x, _km.y); + return true; + break; +#if defined(SDL_BUTTON_MIDDLE) + case SDLK_UP: + event.type = (ev.type == SDL_KEYDOWN) ? Common::EVENT_MBUTTONDOWN : Common::EVENT_MBUTTONUP; + processMouseEvent(event, _km.x, _km.y); + return true; + break; +#endif + default: + break; + } + } + if (ev.type == SDL_KEYDOWN) { switch (ev.key.keysym.sym) { case SDLK_HOME: @@ -141,6 +170,8 @@ bool OPEventSource::remapKey(SDL_Event &ev, Common::Event &event) { g_system->displayMessageOnOSD(_("Touchscreen 'Tap Mode' - Right Click")); } else if (OP::tapmodeLevel == TAPMODE_HOVER) { g_system->displayMessageOnOSD(_("Touchscreen 'Tap Mode' - Hover (No Click)")); + } else if (OP::tapmodeLevel == TAPMODE_HOVER_DPAD) { + g_system->displayMessageOnOSD(_("Touchscreen 'Tap Mode' - Hover (DPad Clicks)")); } break; case SDLK_RSHIFT: diff --git a/backends/events/sdl/sdl-events.cpp b/backends/events/sdl/sdl-events.cpp index f94171646a..0ca5bbb059 100644 --- a/backends/events/sdl/sdl-events.cpp +++ b/backends/events/sdl/sdl-events.cpp @@ -191,6 +191,8 @@ void SdlEventSource::SDLModToOSystemKeyFlags(SDLMod mod, Common::Event &event) { #endif if (mod & KMOD_CTRL) event.kbd.flags |= Common::KBD_CTRL; + if (mod & KMOD_META) + event.kbd.flags |= Common::KBD_META; // Sticky flags if (mod & KMOD_NUM) diff --git a/backends/events/sdl/sdl-events.h b/backends/events/sdl/sdl-events.h index 2ba88c702b..ca4835126f 100644 --- a/backends/events/sdl/sdl-events.h +++ b/backends/events/sdl/sdl-events.h @@ -116,7 +116,7 @@ protected: //@} /** - * Assigns the mouse coords to the mouse event. Furthermore notify the + * Assigns the mouse coords to the mouse event. Furthermore notify the * graphics manager about the position change. */ virtual void processMouseEvent(Common::Event &event, int x, int y); diff --git a/backends/events/webossdl/webossdl-events.h b/backends/events/webossdl/webossdl-events.h index 99ed3105f8..1ba5c6fcbf 100644 --- a/backends/events/webossdl/webossdl-events.h +++ b/backends/events/webossdl/webossdl-events.h @@ -73,10 +73,10 @@ protected: // The current mouse position on the screen. int _curX, _curY; - + // The current screen dimensions int _screenX, _screenY; - + // The drag distance for linear gestures int _swipeDistX, _swipeDistY; @@ -107,7 +107,7 @@ protected: virtual bool handleMouseButtonUp(SDL_Event &ev, Common::Event &event); virtual bool handleMouseMotion(SDL_Event &ev, Common::Event &event); virtual bool pollEvent(Common::Event &event); - + // Utility functions void calculateDimensions(); }; diff --git a/backends/fs/symbian/symbian-fs.cpp b/backends/fs/symbian/symbian-fs.cpp index fc78f7580b..7a652fa43c 100644 --- a/backends/fs/symbian/symbian-fs.cpp +++ b/backends/fs/symbian/symbian-fs.cpp @@ -19,7 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#if defined (__SYMBIAN32__) +#if defined(__SYMBIAN32__) #include "backends/fs/symbian/symbian-fs.h" #include "backends/fs/symbian/symbianstream.h" @@ -230,4 +230,4 @@ Common::SeekableReadStream *SymbianFilesystemNode::createReadStream() { Common::WriteStream *SymbianFilesystemNode::createWriteStream() { return SymbianStdioStream::makeFromPath(getPath(), true); } -#endif //#if defined (__SYMBIAN32__) +#endif //#if defined(__SYMBIAN32__) diff --git a/backends/graphics/dinguxsdl/dinguxsdl-graphics.cpp b/backends/graphics/dinguxsdl/dinguxsdl-graphics.cpp index 17a95688f3..bd87c9fafd 100644 --- a/backends/graphics/dinguxsdl/dinguxsdl-graphics.cpp +++ b/backends/graphics/dinguxsdl/dinguxsdl-graphics.cpp @@ -218,7 +218,7 @@ void DINGUXSdlGraphicsManager::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) && ! 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 @@ -432,7 +432,7 @@ bool DINGUXSdlGraphicsManager::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) { + if (_videoMode.screenHeight == 240) { _videoMode.aspectRatioCorrection = false; } @@ -479,7 +479,7 @@ void DINGUXSdlGraphicsManager::setFeatureState(OSystem::Feature f, bool enable) case OSystem::kFeatureCursorPalette: _cursorPaletteDisabled = !enable; blitCursor(); - break; + break; default: break; } diff --git a/backends/graphics/gph/gph-graphics.cpp b/backends/graphics/gph/gph-graphics.cpp index a0c1d9ad2b..92553564bf 100644 --- a/backends/graphics/gph/gph-graphics.cpp +++ b/backends/graphics/gph/gph-graphics.cpp @@ -245,7 +245,7 @@ void GPHGraphicsManager::internUpdateScreen() { ScalerProc *scalerProc; int scale1; -#if defined (DEBUG) +#if defined(DEBUG) assert(_hwscreen != NULL); assert(_hwscreen->map->sw_data != NULL); #endif @@ -486,7 +486,13 @@ bool GPHGraphicsManager::loadGFXMode() { if (_videoMode.aspectRatioCorrection) _videoMode.overlayHeight = real2Aspect(_videoMode.overlayHeight); } - return SurfaceSdlGraphicsManager::loadGFXMode(); + SurfaceSdlGraphicsManager::loadGFXMode(); + + // The old GP2X hacked SDL needs this after any call to SDL_SetVideoMode + // and it does not hurt other devices. + SDL_ShowCursor(SDL_DISABLE); + + return true; } bool GPHGraphicsManager::hasFeature(OSystem::Feature f) { diff --git a/backends/graphics/graphics.h b/backends/graphics/graphics.h index 3f282df587..24397228e6 100644 --- a/backends/graphics/graphics.h +++ b/backends/graphics/graphics.h @@ -60,7 +60,7 @@ public: virtual int16 getWidth() = 0; virtual void setPalette(const byte *colors, uint start, uint num) = 0; virtual void grabPalette(byte *colors, uint start, uint num) = 0; - virtual void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h) = 0; + virtual void copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h) = 0; virtual Graphics::Surface *lockScreen() = 0; virtual void unlockScreen() = 0; virtual void fillScreen(uint32 col) = 0; @@ -73,14 +73,14 @@ public: virtual void hideOverlay() = 0; virtual Graphics::PixelFormat getOverlayFormat() const = 0; virtual void clearOverlay() = 0; - virtual void grabOverlay(OverlayColor *buf, int pitch) = 0; - virtual void copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h)= 0; + virtual void grabOverlay(void *buf, int pitch) = 0; + virtual void copyRectToOverlay(const void *buf, int pitch, int x, int y, int w, int h)= 0; virtual int16 getOverlayHeight() = 0; virtual int16 getOverlayWidth() = 0; virtual bool showMouse(bool visible) = 0; virtual void warpMouse(int x, int y) = 0; - virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int cursorTargetScale = 1, const Graphics::PixelFormat *format = NULL) = 0; + virtual void setMouseCursor(const void *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, bool dontScale = false, const Graphics::PixelFormat *format = NULL) = 0; virtual void setCursorPalette(const byte *colors, uint start, uint num) = 0; virtual void displayMessageOnOSD(const char *msg) {} diff --git a/backends/graphics/linuxmotosdl/linuxmotosdl-graphics.cpp b/backends/graphics/linuxmotosdl/linuxmotosdl-graphics.cpp index de9838a0d7..a005d74919 100644 --- a/backends/graphics/linuxmotosdl/linuxmotosdl-graphics.cpp +++ b/backends/graphics/linuxmotosdl/linuxmotosdl-graphics.cpp @@ -259,7 +259,7 @@ void LinuxmotoSdlGraphicsManager::internUpdateScreen() { ScalerProc *scalerProc; int scale1; -#if defined (DEBUG) // definitions not available for non-DEBUG here. (needed this to compile in SYMBIAN32 & linux?) +#if defined(DEBUG) // definitions not available for non-DEBUG here. (needed this to compile in SYMBIAN32 & linux?) assert(_hwscreen != NULL); assert(_hwscreen->map->sw_data != NULL); #endif diff --git a/backends/graphics/null/null-graphics.h b/backends/graphics/null/null-graphics.h index 2e6b24d147..276be7d3fa 100644 --- a/backends/graphics/null/null-graphics.h +++ b/backends/graphics/null/null-graphics.h @@ -58,7 +58,7 @@ public: int16 getWidth() { return 0; } void setPalette(const byte *colors, uint start, uint num) {} void grabPalette(byte *colors, uint start, uint num) {} - void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h) {} + void copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h) {} Graphics::Surface *lockScreen() { return NULL; } void unlockScreen() {} void fillScreen(uint32 col) {} @@ -71,14 +71,14 @@ public: void hideOverlay() {} Graphics::PixelFormat getOverlayFormat() const { return Graphics::PixelFormat(); } void clearOverlay() {} - void grabOverlay(OverlayColor *buf, int pitch) {} - void copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h) {} + void grabOverlay(void *buf, int pitch) {} + void copyRectToOverlay(const void *buf, int pitch, int x, int y, int w, int h) {} int16 getOverlayHeight() { return 0; } int16 getOverlayWidth() { return 0; } bool showMouse(bool visible) { return !visible; } void warpMouse(int x, int y) {} - void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int cursorTargetScale = 1, const Graphics::PixelFormat *format = NULL) {} + void setMouseCursor(const void *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, bool dontScale = false, const Graphics::PixelFormat *format = NULL) {} void setCursorPalette(const byte *colors, uint start, uint num) {} }; diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp index 45804b5d6e..48e2663d44 100644 --- a/backends/graphics/opengl/opengl-graphics.cpp +++ b/backends/graphics/opengl/opengl-graphics.cpp @@ -49,7 +49,7 @@ OpenGLGraphicsManager::OpenGLGraphicsManager() _transactionMode(kTransactionNone), _cursorNeedsRedraw(false), _cursorPaletteDisabled(true), _cursorVisible(false), _cursorKeyColor(0), - _cursorTargetScale(1), + _cursorDontScale(false), _formatBGR(false), _displayX(0), _displayY(0), _displayWidth(0), _displayHeight(0) { @@ -70,6 +70,11 @@ OpenGLGraphicsManager::~OpenGLGraphicsManager() { free(_gamePalette); free(_cursorPalette); + _screenData.free(); + _overlayData.free(); + _cursorData.free(); + _osdSurface.free(); + delete _gameTexture; delete _overlayTexture; delete _cursorTexture; @@ -344,14 +349,14 @@ void OpenGLGraphicsManager::grabPalette(byte *colors, uint start, uint num) { memcpy(colors, _gamePalette + start * 3, num * 3); } -void OpenGLGraphicsManager::copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h) { +void OpenGLGraphicsManager::copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h) { assert(x >= 0 && x < _screenData.w); assert(y >= 0 && y < _screenData.h); assert(h > 0 && y + h <= _screenData.h); assert(w > 0 && x + w <= _screenData.w); // Copy buffer data to game screen internal buffer - const byte *src = buf; + const byte *src = (const byte *)buf; byte *dst = (byte *)_screenData.pixels + y * _screenData.pitch + x * _screenData.format.bytesPerPixel; for (int i = 0; i < h; i++) { memcpy(dst, src, w * _screenData.format.bytesPerPixel); @@ -462,33 +467,35 @@ void OpenGLGraphicsManager::clearOverlay() { _overlayNeedsRedraw = true; } -void OpenGLGraphicsManager::grabOverlay(OverlayColor *buf, int pitch) { - assert(_overlayData.format.bytesPerPixel == sizeof(buf[0])); +void OpenGLGraphicsManager::grabOverlay(void *buf, int pitch) { const byte *src = (byte *)_overlayData.pixels; + byte *dst = (byte *)buf; for (int i = 0; i < _overlayData.h; i++) { // Copy overlay data to buffer - memcpy(buf, src, _overlayData.pitch); - buf += pitch; + memcpy(dst, src, _overlayData.pitch); + dst += pitch; src += _overlayData.pitch; } } -void OpenGLGraphicsManager::copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h) { +void OpenGLGraphicsManager::copyRectToOverlay(const void *buf, int pitch, int x, int y, int w, int h) { assert(_transactionMode == kTransactionNone); if (_overlayTexture == NULL) return; + const byte *src = (const byte *)buf; + // Clip the coordinates if (x < 0) { w += x; - buf -= x; + src -= x * 2; x = 0; } if (y < 0) { h += y; - buf -= y * pitch; + src -= y * pitch; y = 0; } @@ -502,11 +509,10 @@ void OpenGLGraphicsManager::copyRectToOverlay(const OverlayColor *buf, int pitch return; // Copy buffer data to internal overlay surface - const byte *src = (const byte *)buf; byte *dst = (byte *)_overlayData.pixels + y * _overlayData.pitch; for (int i = 0; i < h; i++) { memcpy(dst + x * _overlayData.format.bytesPerPixel, src, w * _overlayData.format.bytesPerPixel); - src += pitch * sizeof(buf[0]); + src += pitch; dst += _overlayData.pitch; } @@ -586,7 +592,7 @@ void OpenGLGraphicsManager::warpMouse(int x, int y) { setInternalMousePosition(scaledX, scaledY); } -void OpenGLGraphicsManager::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format) { +void OpenGLGraphicsManager::setMouseCursor(const void *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, bool dontScale, const Graphics::PixelFormat *format) { #ifdef USE_RGB_COLOR if (format) _cursorFormat = *format; @@ -611,7 +617,7 @@ void OpenGLGraphicsManager::setMouseCursor(const byte *buf, uint w, uint h, int _cursorState.hotX = hotspotX; _cursorState.hotY = hotspotY; _cursorKeyColor = keycolor; - _cursorTargetScale = cursorTargetScale; + _cursorDontScale = dontScale; _cursorNeedsRedraw = true; refreshCursorScale(); @@ -824,28 +830,19 @@ void OpenGLGraphicsManager::refreshCursor() { } void OpenGLGraphicsManager::refreshCursorScale() { - // Calculate the scale factors of the screen. We limit ourselves to 3 at - // most here to avoid really big (and ugly) cursors for big resolutions. - // It might be noteworthy that 3 is the (current) target scale for the - // modern theme and thus assures the cursor is *never* scaled. + // Calculate the scale factors of the screen. // We also totally ignore the aspect of the overlay cursor, since aspect // ratio correction only applies to the game screen. - uint screenScaleFactorX = MIN(30000, _videoMode.hardwareWidth * 10000 / _videoMode.screenWidth); - uint screenScaleFactorY = MIN(30000, _videoMode.hardwareHeight * 10000 / _videoMode.screenHeight); - - // Apply the target scale factor to the cursor. - // It might be noteworthy we only apply any scaling to the cursor in case - // the current scale factor is bigger than the target scale to match - // SurfaceSdlGraphicsManager's behavior. Otherwise we would downscale the - // GUI cursor of the modern theme for example. - if (screenScaleFactorX > uint(_cursorTargetScale * 10000)) - screenScaleFactorX /= _cursorTargetScale; - else + // TODO: It might make sense to always ignore scaling of the mouse cursor + // when the overlay is visible. + uint screenScaleFactorX = _videoMode.hardwareWidth * 10000 / _videoMode.screenWidth; + uint screenScaleFactorY = _videoMode.hardwareHeight * 10000 / _videoMode.screenHeight; + + // Ignore scaling when the cursor should not be scaled. + if (_cursorDontScale) { screenScaleFactorX = 10000; - if (screenScaleFactorY > uint(_cursorTargetScale * 10000)) - screenScaleFactorY /= _cursorTargetScale; - else screenScaleFactorY = 10000; + } // Apply them (without any possible) aspect ratio correction to the // overlay. @@ -854,16 +851,19 @@ void OpenGLGraphicsManager::refreshCursorScale() { _cursorState.rHotX = (int16)(_cursorState.hotX * screenScaleFactorX / 10000); _cursorState.rHotY = (int16)(_cursorState.hotY * screenScaleFactorY / 10000); - // Make sure we properly scale the cursor according to the desired aspect. - // It might be noteworthy that, unlike with the overlay, we do not limit - // the scale factor here to avoid odd looks if the game uses items as - // mouse cursor, which would otherwise suddenly be smaller. - int width, height; - calculateDisplaySize(width, height); - screenScaleFactorX = (width * 10000 / _videoMode.screenWidth) / _cursorTargetScale; - screenScaleFactorY = (height * 10000 / _videoMode.screenHeight) / _cursorTargetScale; + // Only apply scaling when it's desired. + if (_cursorDontScale) { + screenScaleFactorX = 10000; + screenScaleFactorY = 10000; + } else { + // Make sure we properly scale the cursor according to the desired aspect. + int width, height; + calculateDisplaySize(width, height); + screenScaleFactorX = (width * 10000 / _videoMode.screenWidth); + screenScaleFactorY = (height * 10000 / _videoMode.screenHeight); + } - // Always scale the cursor for the game. + // Apply the scale cursor scaling for the game screen. _cursorState.vW = (int16)(_cursorState.w * screenScaleFactorX / 10000); _cursorState.vH = (int16)(_cursorState.h * screenScaleFactorY / 10000); _cursorState.vHotX = (int16)(_cursorState.hotX * screenScaleFactorX / 10000); @@ -902,7 +902,7 @@ void OpenGLGraphicsManager::getGLPixelFormat(Graphics::PixelFormat pixelFormat, bpp = 4; intFormat = GL_RGBA; glFormat = GL_RGBA; - gltype = GL_UNSIGNED_BYTE; + gltype = GL_UNSIGNED_INT_8_8_8_8; } else if (pixelFormat == Graphics::PixelFormat(3, 8, 8, 8, 0, 16, 8, 0, 0)) { // RGB888 bpp = 3; intFormat = GL_RGB; @@ -918,11 +918,6 @@ void OpenGLGraphicsManager::getGLPixelFormat(Graphics::PixelFormat pixelFormat, intFormat = GL_RGBA; glFormat = GL_RGBA; gltype = GL_UNSIGNED_SHORT_5_5_5_1; - } else if (pixelFormat == Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0)) { // RGB555 - bpp = 2; - intFormat = GL_RGB; - glFormat = GL_BGRA; - gltype = GL_UNSIGNED_SHORT_1_5_5_5_REV; } else if (pixelFormat == Graphics::PixelFormat(2, 4, 4, 4, 4, 12, 8, 4, 0)) { // RGBA4444 bpp = 2; intFormat = GL_RGBA; @@ -936,6 +931,13 @@ void OpenGLGraphicsManager::getGLPixelFormat(Graphics::PixelFormat pixelFormat, glFormat = GL_RGB; gltype = GL_UNSIGNED_BYTE; #ifndef USE_GLES + } else if (pixelFormat == Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0)) { // RGB555 + // GL_BGRA does not exist in every GLES implementation so should not be configured if + // USE_GLES is set. + bpp = 2; + intFormat = GL_RGB; + glFormat = GL_BGRA; + gltype = GL_UNSIGNED_SHORT_1_5_5_5_REV; } else if (pixelFormat == Graphics::PixelFormat(4, 8, 8, 8, 8, 16, 8, 0, 24)) { // ARGB8888 bpp = 4; intFormat = GL_RGBA; diff --git a/backends/graphics/opengl/opengl-graphics.h b/backends/graphics/opengl/opengl-graphics.h index ad8765bab1..9d8d418d11 100644 --- a/backends/graphics/opengl/opengl-graphics.h +++ b/backends/graphics/opengl/opengl-graphics.h @@ -84,7 +84,7 @@ protected: virtual void grabPalette(byte *colors, uint start, uint num); public: - virtual void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h); + virtual void copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h); virtual Graphics::Surface *lockScreen(); virtual void unlockScreen(); virtual void fillScreen(uint32 col); @@ -97,14 +97,14 @@ public: virtual void hideOverlay(); virtual Graphics::PixelFormat getOverlayFormat() const; virtual void clearOverlay(); - virtual void grabOverlay(OverlayColor *buf, int pitch); - virtual void copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h); + virtual void grabOverlay(void *buf, int pitch); + virtual void copyRectToOverlay(const void *buf, int pitch, int x, int y, int w, int h); virtual int16 getOverlayHeight(); virtual int16 getOverlayWidth(); virtual bool showMouse(bool visible); virtual void warpMouse(int x, int y); - virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int cursorTargetScale = 1, const Graphics::PixelFormat *format = NULL); + virtual void setMouseCursor(const void *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, bool dontScale = false, const Graphics::PixelFormat *format = NULL); virtual void setCursorPalette(const byte *colors, uint start, uint num); virtual void displayMessageOnOSD(const char *msg); @@ -283,7 +283,7 @@ protected: MousePos _cursorState; bool _cursorVisible; uint32 _cursorKeyColor; - int _cursorTargetScale; + bool _cursorDontScale; bool _cursorNeedsRedraw; /** diff --git a/backends/graphics/openglsdl/openglsdl-graphics.cpp b/backends/graphics/openglsdl/openglsdl-graphics.cpp index b37d631c6d..fed02ef22e 100644 --- a/backends/graphics/openglsdl/openglsdl-graphics.cpp +++ b/backends/graphics/openglsdl/openglsdl-graphics.cpp @@ -160,7 +160,7 @@ void OpenGLSdlGraphicsManager::detectSupportedFormats() { _hwscreen->format->Rshift, _hwscreen->format->Gshift, _hwscreen->format->Bshift, _hwscreen->format->Ashift); - // Workaround to MacOSX SDL not providing an accurate Aloss value. + // Workaround to SDL not providing an accurate Aloss value on Mac OS X. if (_hwscreen->format->Amask == 0) format.aLoss = 8; @@ -665,7 +665,7 @@ void OpenGLSdlGraphicsManager::notifyResize(const uint width, const uint height) void OpenGLSdlGraphicsManager::transformMouseCoordinates(Common::Point &point) { adjustMousePosition(point.x, point.y); } - + void OpenGLSdlGraphicsManager::notifyMousePos(Common::Point mouse) { setMousePosition(mouse.x, mouse.y); } diff --git a/backends/graphics/openpandora/op-graphics.cpp b/backends/graphics/openpandora/op-graphics.cpp index 5f0301a0c8..f371081fde 100644 --- a/backends/graphics/openpandora/op-graphics.cpp +++ b/backends/graphics/openpandora/op-graphics.cpp @@ -26,28 +26,59 @@ #include "backends/graphics/openpandora/op-graphics.h" #include "backends/events/openpandora/op-events.h" -//#include "backends/platform/openpandora/op-sdl.h" #include "graphics/scaler/aspect.h" #include "common/mutex.h" #include "common/textconsole.h" +static SDL_Cursor *hiddenCursor; + OPGraphicsManager::OPGraphicsManager(SdlEventSource *sdlEventSource) : SurfaceSdlGraphicsManager(sdlEventSource) { } bool OPGraphicsManager::loadGFXMode() { - /* FIXME: For now we just cheat and set the overlay to 640*480 not 800*480 and let SDL - deal with the boarders (it saves cleaning up the overlay when the game screen is - smaller than the overlay ;) + + uint8_t hiddenCursorData = 0; + hiddenCursor = SDL_CreateCursor(&hiddenCursorData, &hiddenCursorData, 8, 1, 0, 0); + + /* On the OpenPandora we need to work around an SDL assumption that + returns relative mouse coordinates when you get to the screen + edges using the touchscreen. The workaround is to set a blank + SDL cursor and not disable it (Hackish I know). + + The root issues likes in the Windows Manager GRAB code in SDL. + That is why the issue is not seen on framebuffer devices like the + GP2X (there is no X window manager ;)). */ - _videoMode.overlayWidth = 640; - _videoMode.overlayHeight = 480; + SDL_ShowCursor(SDL_ENABLE); + SDL_SetCursor(hiddenCursor); + _videoMode.fullscreen = true; + _videoMode.overlayWidth = _videoMode.screenWidth * _videoMode.scaleFactor; + _videoMode.overlayHeight = _videoMode.screenHeight * _videoMode.scaleFactor; + if (_videoMode.screenHeight != 200 && _videoMode.screenHeight != 400) _videoMode.aspectRatioCorrection = false; + if (_videoMode.aspectRatioCorrection) + _videoMode.overlayHeight = real2Aspect(_videoMode.overlayHeight); + + _videoMode.hardwareWidth = _videoMode.screenWidth * _videoMode.scaleFactor; + _videoMode.hardwareHeight = effectiveScreenHeight(); + return SurfaceSdlGraphicsManager::loadGFXMode(); } +void OPGraphicsManager::unloadGFXMode() { + + uint8_t hiddenCursorData = 0; + hiddenCursor = SDL_CreateCursor(&hiddenCursorData, &hiddenCursorData, 8, 1, 0, 0); + + // Free the hidden SDL cursor created in loadGFXMode + SDL_FreeCursor(hiddenCursor); + + SurfaceSdlGraphicsManager::unloadGFXMode(); +} + #endif diff --git a/backends/graphics/openpandora/op-graphics.h b/backends/graphics/openpandora/op-graphics.h index 0b3eeae8ec..2e3d63e3ad 100644 --- a/backends/graphics/openpandora/op-graphics.h +++ b/backends/graphics/openpandora/op-graphics.h @@ -24,7 +24,6 @@ #define BACKENDS_GRAPHICS_OP_H #include "backends/graphics/surfacesdl/surfacesdl-graphics.h" -#include "graphics/scaler/aspect.h" // for aspect2Real #include "graphics/scaler/downscaler.h" enum { @@ -35,28 +34,8 @@ class OPGraphicsManager : public SurfaceSdlGraphicsManager { public: OPGraphicsManager(SdlEventSource *sdlEventSource); -// bool hasFeature(OSystem::Feature f); -// void setFeatureState(OSystem::Feature f, bool enable); -// bool getFeatureState(OSystem::Feature f); -// int getDefaultGraphicsMode() const; - -// void initSize(uint w, uint h, const Graphics::PixelFormat *format = NULL); -// const OSystem::GraphicsMode *getSupportedGraphicsModes() const; -// bool setGraphicsMode(const char *name); -// bool setGraphicsMode(int mode); -// void setGraphicsModeIntern(); -// void internUpdateScreen(); -// void showOverlay(); -// void hideOverlay(); bool loadGFXMode(); -// void drawMouse(); -// void undrawMouse(); -// virtual void warpMouse(int x, int y); - -// SurfaceSdlGraphicsManager::MousePos *getMouseCurState(); -// SurfaceSdlGraphicsManager::VideoState *getVideoMode(); - -// virtual void adjustMouseEvent(const Common::Event &event); + void unloadGFXMode(); }; #endif /* BACKENDS_GRAPHICS_OP_H */ diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp index f3a1cad040..fb964d6951 100644 --- a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp +++ b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp @@ -63,17 +63,12 @@ static const OSystem::GraphicsMode s_supportedGraphicsModes[] = { DECLARE_TRANSLATION_ADDITIONAL_CONTEXT("Normal (no scaling)", "lowres") -// Table of relative scalers magnitudes -// [definedScale - 1][scaleFactor - 1] -static ScalerProc *scalersMagn[3][3] = { +// Table of the cursor scalers [scaleFactor - 1] +static ScalerProc *scalersMagn[3] = { #ifdef USE_SCALERS - { Normal1x, AdvMame2x, AdvMame3x }, - { Normal1x, Normal1x, Normal1o5x }, - { Normal1x, Normal1x, Normal1x } + Normal1x, AdvMame2x, AdvMame3x #else // remove dependencies on other scalers - { Normal1x, Normal1x, Normal1x }, - { Normal1x, Normal1x, Normal1x }, - { Normal1x, Normal1x, Normal1x } + Normal1x, Normal1x, Normal1x #endif }; @@ -135,7 +130,7 @@ SurfaceSdlGraphicsManager::SurfaceSdlGraphicsManager(SdlEventSource *sdlEventSou _overlayscreen(0), _tmpscreen2(0), _scalerProc(0), _screenChangeCount(0), _mouseVisible(false), _mouseNeedsRedraw(false), _mouseData(0), _mouseSurface(0), - _mouseOrigSurface(0), _cursorTargetScale(1), _cursorPaletteDisabled(true), + _mouseOrigSurface(0), _cursorDontScale(false), _cursorPaletteDisabled(true), _currentShakePos(0), _newShakePos(0), _paletteDirtyStart(0), _paletteDirtyEnd(0), _screenIsLocked(false), @@ -458,7 +453,7 @@ void SurfaceSdlGraphicsManager::detectSupportedFormats() { _hwscreen->format->Rshift, _hwscreen->format->Gshift, _hwscreen->format->Bshift, _hwscreen->format->Ashift); - // Workaround to MacOSX SDL not providing an accurate Aloss value. + // Workaround to SDL not providing an accurate Aloss value on Mac OS X. if (_hwscreen->format->Amask == 0) format.aLoss = 8; @@ -965,7 +960,7 @@ void SurfaceSdlGraphicsManager::internUpdateScreen() { int scale1; // definitions not available for non-DEBUG here. (needed this to compile in SYMBIAN32 & linux?) -#if defined (DEBUG) && !defined(WIN32) && !defined(_WIN32_WCE) +#if defined(DEBUG) && !defined(WIN32) && !defined(_WIN32_WCE) assert(_hwscreen != NULL); assert(_hwscreen->map->sw_data != NULL); #endif @@ -1232,9 +1227,9 @@ void SurfaceSdlGraphicsManager::setAspectRatioCorrection(bool enable) { } } -void SurfaceSdlGraphicsManager::copyRectToScreen(const byte *src, int pitch, int x, int y, int w, int h) { +void SurfaceSdlGraphicsManager::copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h) { assert(_transactionMode == kTransactionNone); - assert(src); + assert(buf); if (_screen == NULL) { warning("SurfaceSdlGraphicsManager::copyRectToScreen: _screen == NULL"); @@ -1257,8 +1252,9 @@ void SurfaceSdlGraphicsManager::copyRectToScreen(const byte *src, int pitch, int #ifdef USE_RGB_COLOR byte *dst = (byte *)_screen->pixels + y * _screen->pitch + x * _screenFormat.bytesPerPixel; if (_videoMode.screenWidth == w && pitch == _screen->pitch) { - memcpy(dst, src, h*pitch); + memcpy(dst, buf, h*pitch); } else { + const byte *src = (const byte *)buf; do { memcpy(dst, src, w * _screenFormat.bytesPerPixel); src += pitch; @@ -1268,8 +1264,9 @@ void SurfaceSdlGraphicsManager::copyRectToScreen(const byte *src, int pitch, int #else byte *dst = (byte *)_screen->pixels + y * _screen->pitch + x; if (_screen->pitch == pitch && pitch == w) { - memcpy(dst, src, h*w); + memcpy(dst, buf, h*w); } else { + const byte *src = (const byte *)buf; do { memcpy(dst, src, w); src += pitch; @@ -1600,7 +1597,7 @@ void SurfaceSdlGraphicsManager::clearOverlay() { _forceFull = true; } -void SurfaceSdlGraphicsManager::grabOverlay(OverlayColor *buf, int pitch) { +void SurfaceSdlGraphicsManager::grabOverlay(void *buf, int pitch) { assert(_transactionMode == kTransactionNone); if (_overlayscreen == NULL) @@ -1610,31 +1607,35 @@ void SurfaceSdlGraphicsManager::grabOverlay(OverlayColor *buf, int pitch) { error("SDL_LockSurface failed: %s", SDL_GetError()); byte *src = (byte *)_overlayscreen->pixels; + byte *dst = (byte *)buf; int h = _videoMode.overlayHeight; do { - memcpy(buf, src, _videoMode.overlayWidth * 2); + memcpy(dst, src, _videoMode.overlayWidth * 2); src += _overlayscreen->pitch; - buf += pitch; + dst += pitch; } while (--h); SDL_UnlockSurface(_overlayscreen); } -void SurfaceSdlGraphicsManager::copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h) { +void SurfaceSdlGraphicsManager::copyRectToOverlay(const void *buf, int pitch, int x, int y, int w, int h) { assert(_transactionMode == kTransactionNone); if (_overlayscreen == NULL) return; + const byte *src = (const byte *)buf; + // Clip the coordinates if (x < 0) { w += x; - buf -= x; + src -= x * 2; x = 0; } if (y < 0) { - h += y; buf -= y * pitch; + h += y; + src -= y * pitch; y = 0; } @@ -1657,9 +1658,9 @@ void SurfaceSdlGraphicsManager::copyRectToOverlay(const OverlayColor *buf, int p byte *dst = (byte *)_overlayscreen->pixels + y * _overlayscreen->pitch + x * 2; do { - memcpy(dst, buf, w * 2); + memcpy(dst, src, w * 2); dst += _overlayscreen->pitch; - buf += pitch; + src += pitch; } while (--h); SDL_UnlockSurface(_overlayscreen); @@ -1718,7 +1719,7 @@ void SurfaceSdlGraphicsManager::warpMouse(int x, int y) { } } -void SurfaceSdlGraphicsManager::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format) { +void SurfaceSdlGraphicsManager::setMouseCursor(const void *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, bool dontScale, const Graphics::PixelFormat *format) { #ifdef USE_RGB_COLOR if (!format) _cursorFormat = Graphics::PixelFormat::createFormatCLUT8(); @@ -1739,7 +1740,7 @@ void SurfaceSdlGraphicsManager::setMouseCursor(const byte *buf, uint w, uint h, _mouseKeyColor = keycolor; - _cursorTargetScale = cursorTargetScale; + _cursorDontScale = dontScale; if (_mouseCurState.w != (int)w || _mouseCurState.h != (int)h) { _mouseCurState.w = w; @@ -1847,51 +1848,34 @@ void SurfaceSdlGraphicsManager::blitCursor() { } int rW, rH; + int cursorScale; - if (_cursorTargetScale >= _videoMode.scaleFactor) { - // The cursor target scale is greater or equal to the scale at - // which the rest of the screen is drawn. We do not downscale - // the cursor image, we draw it at its original size. It will - // appear too large on screen. - - rW = w; - rH = h; - _mouseCurState.rHotX = _mouseCurState.hotX; - _mouseCurState.rHotY = _mouseCurState.hotY; - - // The virtual dimensions may be larger than the original. - - _mouseCurState.vW = w * _cursorTargetScale / _videoMode.scaleFactor; - _mouseCurState.vH = h * _cursorTargetScale / _videoMode.scaleFactor; - _mouseCurState.vHotX = _mouseCurState.hotX * _cursorTargetScale / - _videoMode.scaleFactor; - _mouseCurState.vHotY = _mouseCurState.hotY * _cursorTargetScale / - _videoMode.scaleFactor; + if (_cursorDontScale) { + // Don't scale the cursor at all if the user requests this behavior. + cursorScale = 1; } else { - // The cursor target scale is smaller than the scale at which - // the rest of the screen is drawn. We scale up the cursor - // image to make it appear correct. + // Scale the cursor with the game screen scale factor. + cursorScale = _videoMode.scaleFactor; + } - rW = w * _videoMode.scaleFactor / _cursorTargetScale; - rH = h * _videoMode.scaleFactor / _cursorTargetScale; - _mouseCurState.rHotX = _mouseCurState.hotX * _videoMode.scaleFactor / - _cursorTargetScale; - _mouseCurState.rHotY = _mouseCurState.hotY * _videoMode.scaleFactor / - _cursorTargetScale; + // Adapt the real hotspot according to the scale factor. + rW = w * cursorScale; + rH = h * cursorScale; + _mouseCurState.rHotX = _mouseCurState.hotX * cursorScale; + _mouseCurState.rHotY = _mouseCurState.hotY * cursorScale; - // The virtual dimensions will be the same as the original. + // The virtual dimensions will be the same as the original. - _mouseCurState.vW = w; - _mouseCurState.vH = h; - _mouseCurState.vHotX = _mouseCurState.hotX; - _mouseCurState.vHotY = _mouseCurState.hotY; - } + _mouseCurState.vW = w; + _mouseCurState.vH = h; + _mouseCurState.vHotX = _mouseCurState.hotX; + _mouseCurState.vHotY = _mouseCurState.hotY; #ifdef USE_SCALERS int rH1 = rH; // store original to pass to aspect-correction function later #endif - if (_videoMode.aspectRatioCorrection && _cursorTargetScale == 1) { + if (!_cursorDontScale && _videoMode.aspectRatioCorrection) { rH = real2Aspect(rH - 1) + 1; _mouseCurState.rHotY = real2Aspect(_mouseCurState.rHotY); } @@ -1922,21 +1906,25 @@ void SurfaceSdlGraphicsManager::blitCursor() { ScalerProc *scalerProc; - // If possible, use the same scaler for the cursor as for the rest of - // the game. This only works well with the non-blurring scalers so we - // actually only use the 1x, 1.5x, 2x and AdvMame scalers. - - if (_cursorTargetScale == 1 && (_videoMode.mode == GFX_DOUBLESIZE || _videoMode.mode == GFX_TRIPLESIZE)) - scalerProc = _scalerProc; - else - scalerProc = scalersMagn[_cursorTargetScale - 1][_videoMode.scaleFactor - 1]; + // Only apply scaling, when the user allows it. + if (!_cursorDontScale) { + // If possible, use the same scaler for the cursor as for the rest of + // the game. This only works well with the non-blurring scalers so we + // actually only use the 1x, 2x and AdvMame scalers. + if (_videoMode.mode == GFX_DOUBLESIZE || _videoMode.mode == GFX_TRIPLESIZE) + scalerProc = _scalerProc; + else + scalerProc = scalersMagn[_videoMode.scaleFactor - 1]; + } else { + scalerProc = Normal1x; + } scalerProc((byte *)_mouseOrigSurface->pixels + _mouseOrigSurface->pitch + 2, _mouseOrigSurface->pitch, (byte *)_mouseSurface->pixels, _mouseSurface->pitch, _mouseCurState.w, _mouseCurState.h); #ifdef USE_SCALERS - if (_videoMode.aspectRatioCorrection && _cursorTargetScale == 1) + if (!_cursorDontScale && _videoMode.aspectRatioCorrection) cursorStretch200To240((uint8 *)_mouseSurface->pixels, _mouseSurface->pitch, rW, rH1, 0, 0, 0); #endif diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.h b/backends/graphics/surfacesdl/surfacesdl-graphics.h index f71096d43e..21444cc25d 100644 --- a/backends/graphics/surfacesdl/surfacesdl-graphics.h +++ b/backends/graphics/surfacesdl/surfacesdl-graphics.h @@ -111,7 +111,7 @@ protected: virtual void grabPalette(byte *colors, uint start, uint num); public: - virtual void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h); + virtual void copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h); virtual Graphics::Surface *lockScreen(); virtual void unlockScreen(); virtual void fillScreen(uint32 col); @@ -124,14 +124,14 @@ public: virtual void hideOverlay(); virtual Graphics::PixelFormat getOverlayFormat() const { return _overlayFormat; } virtual void clearOverlay(); - virtual void grabOverlay(OverlayColor *buf, int pitch); - virtual void copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h); + virtual void grabOverlay(void *buf, int pitch); + virtual void copyRectToOverlay(const void *buf, int pitch, int x, int y, int w, int h); virtual int16 getOverlayHeight() { return _videoMode.overlayHeight; } virtual int16 getOverlayWidth() { return _videoMode.overlayWidth; } virtual bool showMouse(bool visible); virtual void warpMouse(int x, int y); - virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int cursorTargetScale = 1, const Graphics::PixelFormat *format = NULL); + virtual void setMouseCursor(const void *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, bool dontScale = false, const Graphics::PixelFormat *format = NULL); virtual void setCursorPalette(const byte *colors, uint start, uint num); #ifdef USE_OSD @@ -281,7 +281,7 @@ protected: #else byte _mouseKeyColor; #endif - int _cursorTargetScale; + bool _cursorDontScale; bool _cursorPaletteDisabled; SDL_Surface *_mouseOrigSurface; SDL_Surface *_mouseSurface; diff --git a/backends/graphics/wincesdl/wincesdl-graphics.cpp b/backends/graphics/wincesdl/wincesdl-graphics.cpp index 58b735ef8b..f075f8cf8a 100644 --- a/backends/graphics/wincesdl/wincesdl-graphics.cpp +++ b/backends/graphics/wincesdl/wincesdl-graphics.cpp @@ -1023,22 +1023,24 @@ bool WINCESdlGraphicsManager::saveScreenshot(const char *filename) { return true; } -void WINCESdlGraphicsManager::copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h) { +void WINCESdlGraphicsManager::copyRectToOverlay(const void *buf, int pitch, int x, int y, int w, int h) { assert(_transactionMode == kTransactionNone); if (_overlayscreen == NULL) return; + const byte *src = (const byte *)buf; + // Clip the coordinates if (x < 0) { w += x; - buf -= x; + src -= x * 2; x = 0; } if (y < 0) { h += y; - buf -= y * pitch; + src -= y * pitch; y = 0; } @@ -1063,23 +1065,24 @@ void WINCESdlGraphicsManager::copyRectToOverlay(const OverlayColor *buf, int pit byte *dst = (byte *)_overlayscreen->pixels + y * _overlayscreen->pitch + x * 2; do { - memcpy(dst, buf, w * 2); + memcpy(dst, src, w * 2); dst += _overlayscreen->pitch; - buf += pitch; + src += pitch; } while (--h); SDL_UnlockSurface(_overlayscreen); } -void WINCESdlGraphicsManager::copyRectToScreen(const byte *src, int pitch, int x, int y, int w, int h) { +void WINCESdlGraphicsManager::copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h) { assert(_transactionMode == kTransactionNone); - assert(src); + assert(buf); if (_screen == NULL) return; Common::StackLock lock(_graphicsMutex); // Lock the mutex until this function ends + const byte *src = (const byte *)buf; /* Clip the coordinates */ if (x < 0) { w += x; @@ -1128,7 +1131,7 @@ void WINCESdlGraphicsManager::copyRectToScreen(const byte *src, int pitch, int x SDL_UnlockSurface(_screen); } -void WINCESdlGraphicsManager::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format) { +void WINCESdlGraphicsManager::setMouseCursor(const void *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, bool dontScale, const Graphics::PixelFormat *format) { undrawMouse(); if (w == 0 || h == 0) diff --git a/backends/graphics/wincesdl/wincesdl-graphics.h b/backends/graphics/wincesdl/wincesdl-graphics.h index 2e8c3313b3..2897ca5f40 100644 --- a/backends/graphics/wincesdl/wincesdl-graphics.h +++ b/backends/graphics/wincesdl/wincesdl-graphics.h @@ -73,9 +73,9 @@ public: void internDrawMouse(); void undrawMouse(); bool showMouse(bool visible); - void setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format); // overloaded by CE backend - void copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h); - void copyRectToScreen(const byte *src, int pitch, int x, int y, int w, int h); // overloaded by CE backend (FIXME) + void setMouseCursor(const void *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, bool dontScale, const Graphics::PixelFormat *format); // overloaded by CE backend + void copyRectToOverlay(const void *buf, int pitch, int x, int y, int w, int h); + void copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h); // overloaded by CE backend (FIXME) Graphics::Surface *lockScreen(); void unlockScreen(); void blitCursor(); diff --git a/backends/keymapper/hardware-input.cpp b/backends/keymapper/hardware-input.cpp index a09f0b54fc..d1f8822ac0 100644 --- a/backends/keymapper/hardware-input.cpp +++ b/backends/keymapper/hardware-input.cpp @@ -209,16 +209,33 @@ const HardwareInput *HardwareInputSet::findHardwareInput(String id) const { return 0; } +const HardwareInput *HardwareInputSet::findHardwareInput(const HardwareInputCode code) const { + List<const HardwareInput *>::const_iterator it; + + for (it = _inputs.begin(); it != _inputs.end(); ++it) { + const HardwareInput *entry = *it; + if (entry->type == kHardwareInputTypeGeneric && entry->inputCode == code) + return entry; + } + return 0; +} + const HardwareInput *HardwareInputSet::findHardwareInput(const KeyState& keystate) const { List<const HardwareInput *>::const_iterator it; for (it = _inputs.begin(); it != _inputs.end(); ++it) { - if ((*it)->key == keystate) - return (*it); + const HardwareInput *entry = *it; + if (entry->type == kHardwareInputTypeKeyboard && entry->key == keystate) + return entry; } return 0; } +void HardwareInputSet::addHardwareInputs(const HardwareInputTableEntry inputs[]) { + for (const HardwareInputTableEntry *entry = inputs; entry->hwId; ++entry) + addHardwareInput(new HardwareInput(entry->hwId, entry->code, entry->desc)); +} + void HardwareInputSet::addHardwareInputs(const KeyTableEntry keys[], const ModifierTableEntry modifiers[]) { const KeyTableEntry *key; const ModifierTableEntry *mod; @@ -247,10 +264,6 @@ void HardwareInputSet::addHardwareInputs(const KeyTableEntry keys[], const Modif } } -void HardwareInputSet::addHardwareInputs(const KeyTableEntry keys[]) { - addHardwareInputs(keys, defaultModifiers); -} - void HardwareInputSet::removeHardwareInput(const HardwareInput *input) { if (!input) return; @@ -259,7 +272,16 @@ void HardwareInputSet::removeHardwareInput(const HardwareInput *input) { for (it = _inputs.begin(); it != _inputs.end(); ++it) { const HardwareInput *entry = (*it); - if (entry->id == input->id || entry->key == input->key) { + bool match = false; + if (entry->id == input->id) + match = true; + else if (input->type == entry->type) { + if (input->type == kHardwareInputTypeGeneric && input->inputCode == entry->inputCode) + match = true; + else if (input->type == kHardwareInputTypeKeyboard && input->key == entry->key) + match = true; + } + if (match) { debug(7, "Removing hardware input [%s] (%s) because it matches [%s] (%s)", entry->id.c_str(), entry->description.c_str(), input->id.c_str(), input->description.c_str()); delete entry; _inputs.erase(it); diff --git a/backends/keymapper/hardware-input.h b/backends/keymapper/hardware-input.h index 9396765bbe..51d4accb5b 100644 --- a/backends/keymapper/hardware-input.h +++ b/backends/keymapper/hardware-input.h @@ -34,6 +34,15 @@ namespace Common { +typedef uint32 HardwareInputCode; + +enum HardwareInputType { + /** Input that sends single events */ + kHardwareInputTypeGeneric, + /** Input that usually send -up and -down events */ + kHardwareInputTypeKeyboard +}; + /** * Describes an available hardware input */ @@ -44,14 +53,33 @@ struct HardwareInput { /** Human readable description */ String description; + const HardwareInputType type; + /** - * The KeyState that is generated by the back-end - * when this hardware key is pressed. - */ + * A platform specific unique identifier for an input event + * generated when this input is triggered. + * This is only relevant when type == kHardwareInputTypeGeneric + */ + HardwareInputCode inputCode; + + /** + * The KeyState that is generated by the back-end + * when this hardware key is pressed. + * This is only relevant when type == kHardwareInputTypeKeyboard + */ KeyState key; - HardwareInput(String i, KeyState ky = KeyState(), String desc = "") - : id(i), key(ky), description(desc) { } + HardwareInput(String i, HardwareInputCode ic = 0, String desc = "") + : id(i), inputCode(ic), description(desc), type(kHardwareInputTypeGeneric) { } + + HardwareInput(String i, KeyState ky, String desc = "") + : id(i), key(ky), description(desc), type(kHardwareInputTypeKeyboard) { } +}; + +struct HardwareInputTableEntry { + const char *hwId; + HardwareInputCode code; + const char *desc; }; /** @@ -97,6 +125,8 @@ public: const HardwareInput *findHardwareInput(String id) const; + const HardwareInput *findHardwareInput(const HardwareInputCode code) const; + const HardwareInput *findHardwareInput(const KeyState& keystate) const; const List<const HardwareInput *> &getHardwareInputs() const { return _inputs; } @@ -104,18 +134,17 @@ public: uint size() const { return _inputs.size(); } /** - * Add hardware inputs to the set out of key and modifier tables. - * @param keys table of available keys - * @param modifiers table of available modifiers + * Add hardware inputs to the set out of a table. + * @param inputs table of available inputs */ - void addHardwareInputs(const KeyTableEntry keys[], const ModifierTableEntry modifiers[]); + void addHardwareInputs(const HardwareInputTableEntry inputs[]); /** - * Add hardware inputs to the set out of a key table. - * The default modifiers are applied to the key entries + * Add hardware inputs to the set out of key and modifier tables. * @param keys table of available keys + * @param modifiers table of available modifiers */ - void addHardwareInputs(const KeyTableEntry keys[]); + void addHardwareInputs(const KeyTableEntry keys[], const ModifierTableEntry modifiers[]); void removeHardwareInput(const HardwareInput *input); diff --git a/backends/keymapper/keymap.cpp b/backends/keymapper/keymap.cpp index 8ea975c927..e95dd6afb5 100644 --- a/backends/keymapper/keymap.cpp +++ b/backends/keymapper/keymap.cpp @@ -33,14 +33,17 @@ namespace Common { -Keymap::Keymap(const Keymap& km) : _actions(km._actions), _keymap(), _configDomain(0) { +Keymap::Keymap(const Keymap& km) : _actions(km._actions), _keymap(), _nonkeymap(), _configDomain(0) { List<Action *>::iterator it; for (it = _actions.begin(); it != _actions.end(); ++it) { const HardwareInput *hwInput = (*it)->getMappedInput(); if (hwInput) { - _keymap[hwInput->key] = *it; + if (hwInput->type == kHardwareInputTypeKeyboard) + _keymap[hwInput->key] = *it; + else if (hwInput->type == kHardwareInputTypeGeneric) + _nonkeymap[hwInput->inputCode] = *it; } } } @@ -60,23 +63,31 @@ void Keymap::addAction(Action *action) { } void Keymap::registerMapping(Action *action, const HardwareInput *hwInput) { - HashMap<KeyState, Action *>::iterator it; - - it = _keymap.find(hwInput->key); - - // if key is already mapped to a different action then un-map it - if (it != _keymap.end() && action != it->_value) { - it->_value->mapInput(0); + if (hwInput->type == kHardwareInputTypeKeyboard) { + HashMap<KeyState, Action *>::iterator it = _keymap.find(hwInput->key); + // if input is already mapped to a different action then unmap it from there + if (it != _keymap.end() && action != it->_value) + it->_value->mapInput(0); + // now map it + _keymap[hwInput->key] = action; + } else if (hwInput->type == kHardwareInputTypeGeneric) { + HashMap<HardwareInputCode, Action *>::iterator it = _nonkeymap.find(hwInput->inputCode); + // if input is already mapped to a different action then unmap it from there + if (it != _nonkeymap.end() && action != it->_value) + it->_value->mapInput(0); + // now map it + _nonkeymap[hwInput->inputCode] = action; } - - _keymap[hwInput->key] = action; } void Keymap::unregisterMapping(Action *action) { const HardwareInput *hwInput = action->getMappedInput(); if (hwInput) { - _keymap.erase(hwInput->key); + if (hwInput->type == kHardwareInputTypeKeyboard) + _keymap.erase(hwInput->key); + else if (hwInput->type == kHardwareInputTypeGeneric) + _nonkeymap.erase(hwInput->inputCode); } } @@ -116,6 +127,17 @@ Action *Keymap::getMappedAction(const KeyState& ks) const { return it->_value; } +Action *Keymap::getMappedAction(const HardwareInputCode code) const { + HashMap<HardwareInputCode, Action *>::iterator it; + + it = _nonkeymap.find(code); + + if (it == _nonkeymap.end()) + return 0; + else + return it->_value; +} + void Keymap::setConfigDomain(ConfigManager::Domain *dom) { _configDomain = dom; } diff --git a/backends/keymapper/keymap.h b/backends/keymapper/keymap.h index 4c3e89700f..6eaec7dcaf 100644 --- a/backends/keymapper/keymap.h +++ b/backends/keymapper/keymap.h @@ -33,12 +33,10 @@ #include "common/keyboard.h" #include "common/list.h" #include "backends/keymapper/action.h" +#include "backends/keymapper/hardware-input.h" namespace Common { -struct HardwareInput; -class HardwareInputSet; - /** * Hash function for KeyState */ @@ -76,6 +74,13 @@ public: */ Action *getMappedAction(const KeyState& ks) const; + /** + * Find the Action that a generic input is mapped to + * @param code the input code that is mapped to the required Action + * @return a pointer to the Action or 0 if no + */ + Action *getMappedAction(const HardwareInputCode code) const; + void setConfigDomain(ConfigManager::Domain *dom); /** @@ -130,6 +135,7 @@ private: String _name; List<Action *> _actions; HashMap<KeyState, Action *> _keymap; + HashMap<HardwareInputCode, Action *> _nonkeymap; ConfigManager::Domain *_configDomain; }; diff --git a/backends/keymapper/keymapper.cpp b/backends/keymapper/keymapper.cpp index bda4cd47da..dcb021f2d8 100644 --- a/backends/keymapper/keymapper.cpp +++ b/backends/keymapper/keymapper.cpp @@ -25,9 +25,14 @@ #ifdef ENABLE_KEYMAPPER #include "common/config-manager.h" +#include "common/system.h" namespace Common { +// These magic numbers are provided by fuzzie and WebOS +static const uint32 kDelayKeyboardEventMillis = 250; +static const uint32 kDelayMouseEventMillis = 50; + void Keymapper::Domain::addKeymap(Keymap *map) { iterator it = find(map->getName()); @@ -54,7 +59,7 @@ Keymap *Keymapper::Domain::getKeymap(const String& name) { } Keymapper::Keymapper(EventManager *evtMgr) - : _eventMan(evtMgr), _enabled(true), _hardwareInputs(0) { + : _eventMan(evtMgr), _enabled(true), _remapping(false), _hardwareInputs(0), _actionToRemap(0) { ConfigManager::Domain *confDom = ConfMan.getDomain(ConfigManager::kKeymapperDomain); _globalDomain.setConfigDomain(confDom); @@ -183,13 +188,16 @@ List<Event> Keymapper::mapEvent(const Event &ev, EventSource *source) { if (source && !source->allowMapping()) { return DefaultEventMapper::mapEvent(ev, source); } - List<Event> mappedEvents; - if (ev.type == Common::EVENT_KEYDOWN) + if (_remapping) + mappedEvents = remap(ev); + else if (ev.type == Common::EVENT_KEYDOWN) mappedEvents = mapKeyDown(ev.kbd); else if (ev.type == Common::EVENT_KEYUP) mappedEvents = mapKeyUp(ev.kbd); + else if (ev.type == Common::EVENT_CUSTOM_BACKEND_HARDWARE) + mappedEvents = mapNonKey(ev.customType); if (!mappedEvents.empty()) return mappedEvents; @@ -197,6 +205,13 @@ List<Event> Keymapper::mapEvent(const Event &ev, EventSource *source) { return DefaultEventMapper::mapEvent(ev, source); } +void Keymapper::startRemappingMode(Action *actionToRemap) { + assert(!_remapping); + + _remapping = true; + _actionToRemap = actionToRemap; +} + List<Event> Keymapper::mapKeyDown(const KeyState& key) { return mapKey(key, true); } @@ -236,7 +251,30 @@ List<Event> Keymapper::mapKey(const KeyState& key, bool keyDown) { if (!action) return List<Event>(); - return executeAction(action, keyDown); + return executeAction(action, keyDown ? kIncomingKeyDown : kIncomingKeyUp); +} + + +List<Event> Keymapper::mapNonKey(const HardwareInputCode code) { + if (!_enabled || _activeMaps.empty()) + return List<Event>(); + + Action *action = 0; + + // Search for nonkey in active keymap stack + for (int i = _activeMaps.size() - 1; i >= 0; --i) { + MapRecord mr = _activeMaps[i]; + debug(5, "Keymapper::mapKey keymap: %s", mr.keymap->getName().c_str()); + action = mr.keymap->getMappedAction(code); + + if (action || !mr.transparent) + break; + } + + if (!action) + return List<Event>(); + + return executeAction(action); } Action *Keymapper::getAction(const KeyState& key) { @@ -245,56 +283,108 @@ Action *Keymapper::getAction(const KeyState& key) { return action; } -List<Event> Keymapper::executeAction(const Action *action, bool keyDown) { +List<Event> Keymapper::executeAction(const Action *action, IncomingEventType incomingType) { List<Event> mappedEvents; List<Event>::const_iterator it; - + Event evt; for (it = action->events.begin(); it != action->events.end(); ++it) { - Event evt = *it; - - switch (evt.type) { - case EVENT_KEYDOWN: - if (!keyDown) evt.type = EVENT_KEYUP; - break; - case EVENT_KEYUP: - if (keyDown) evt.type = EVENT_KEYDOWN; - break; - case EVENT_LBUTTONDOWN: - if (!keyDown) evt.type = EVENT_LBUTTONUP; - break; - case EVENT_LBUTTONUP: - if (keyDown) evt.type = EVENT_LBUTTONDOWN; - break; - case EVENT_RBUTTONDOWN: - if (!keyDown) evt.type = EVENT_RBUTTONUP; - break; - case EVENT_RBUTTONUP: - if (keyDown) evt.type = EVENT_RBUTTONDOWN; - break; - case EVENT_MBUTTONDOWN: - if (!keyDown) evt.type = EVENT_MBUTTONUP; - break; - case EVENT_MBUTTONUP: - if (keyDown) evt.type = EVENT_MBUTTONDOWN; - break; - case EVENT_MAINMENU: - if (!keyDown) evt.type = EVENT_MAINMENU; - break; - default: - // don't deliver other events on key up - if (!keyDown) continue; + evt = Event(*it); + EventType convertedType = convertDownToUp(evt.type); + + // hardware keys need to send up instead when they are up + if (incomingType == kIncomingKeyUp) { + if (convertedType == EVENT_INVALID) + continue; // don't send any non-down-converted events on up they were already sent on down + evt.type = convertedType; } evt.mouse = _eventMan->getMousePos(); - mappedEvents.push_back(evt); + + // Check if the event is coming from a non-key hardware event + // that is mapped to a key event + if (incomingType == kIncomingNonKey && convertedType != EVENT_INVALID) + // WORKAROUND: Delay the down events coming from non-key hardware events + // with a zero delay. This is to prevent DOWN1 DOWN2 UP1 UP2. + addDelayedEvent(0, evt); + else + mappedEvents.push_back(evt); + + // non-keys need to send up as well + if (incomingType == kIncomingNonKey && convertedType != EVENT_INVALID) { + // WORKAROUND: Delay the up events coming from non-key hardware events + // This is for engines that run scripts that check on key being down + evt.type = convertedType; + const uint32 delay = (convertedType == EVENT_KEYUP ? kDelayKeyboardEventMillis : kDelayMouseEventMillis); + addDelayedEvent(delay, evt); + } } return mappedEvents; } +EventType Keymapper::convertDownToUp(EventType type) { + EventType result = EVENT_INVALID; + switch (type) { + case EVENT_KEYDOWN: + result = EVENT_KEYUP; + break; + case EVENT_LBUTTONDOWN: + result = EVENT_LBUTTONUP; + break; + case EVENT_RBUTTONDOWN: + result = EVENT_RBUTTONUP; + break; + case EVENT_MBUTTONDOWN: + result = EVENT_MBUTTONUP; + break; + default: + break; + } + return result; +} + const HardwareInput *Keymapper::findHardwareInput(const KeyState& key) { return (_hardwareInputs) ? _hardwareInputs->findHardwareInput(key) : 0; } +const HardwareInput *Keymapper::findHardwareInput(const HardwareInputCode code) { + return (_hardwareInputs) ? _hardwareInputs->findHardwareInput(code) : 0; +} + +List<Event> Keymapper::remap(const Event &ev) { + assert(_remapping); + assert(_actionToRemap); + + List<Event> list; + + const HardwareInput *hwInput = 0; + Event mappedEvent; + + switch (ev.type) { + case EVENT_KEYDOWN: + // eat the event by returning an event invalid + mappedEvent.type = EVENT_INVALID; + list.push_back(mappedEvent); + break; + case EVENT_KEYUP: + hwInput = findHardwareInput(ev.kbd); + break; + case EVENT_CUSTOM_BACKEND_HARDWARE: + hwInput = findHardwareInput(ev.customType); + break; + default: + break; + } + if (hwInput) { + _actionToRemap->mapInput(hwInput); + _actionToRemap->getParent()->saveMappings(); + _remapping = false; + _actionToRemap = 0; + mappedEvent.type = EVENT_GUI_REMAP_COMPLETE_ACTION; + list.push_back(mappedEvent); + } + return list; +} + } // End of namespace Common #endif // #ifdef ENABLE_KEYMAPPER diff --git a/backends/keymapper/keymapper.h b/backends/keymapper/keymapper.h index daa746f379..1e8d1c08c3 100644 --- a/backends/keymapper/keymapper.h +++ b/backends/keymapper/keymapper.h @@ -149,6 +149,7 @@ public: * @return mapped events */ List<Event> mapKey(const KeyState& key, bool keyDown); + List<Event> mapNonKey(const HardwareInputCode code); /** * @brief Map a key down event. @@ -168,16 +169,45 @@ public: void setEnabled(bool enabled) { _enabled = enabled; } /** + * @brief Activate remapping mode + * While this mode is active, any mappable event will be bound to the action + * provided. + * @param actionToRemap Action that is the target of the remap + */ + void startRemappingMode(Action *actionToRemap); + + /** + * @brief Force-stop the remapping mode + */ + void stopRemappingMode() { _remapping = false; } + + /** + * Query whether the keymapper is currently in the remapping mode + */ + bool isRemapping() const { return _remapping; } + + /** * Return a HardwareInput pointer for the given key state */ const HardwareInput *findHardwareInput(const KeyState& key); + /** + * Return a HardwareInput pointer for the given input code + */ + const HardwareInput *findHardwareInput(const HardwareInputCode code); + Domain& getGlobalDomain() { return _globalDomain; } Domain& getGameDomain() { return _gameDomain; } const Stack<MapRecord>& getActiveStack() const { return _activeMaps; } private: + enum IncomingEventType { + kIncomingKeyDown, + kIncomingKeyUp, + kIncomingNonKey + }; + void initKeymap(Domain &domain, Keymap *keymap); Domain _globalDomain; @@ -188,12 +218,16 @@ private: void pushKeymap(Keymap *newMap, bool transparent, bool global); Action *getAction(const KeyState& key); - List<Event> executeAction(const Action *act, bool keyDown); + List<Event> executeAction(const Action *act, IncomingEventType incomingType = kIncomingNonKey); + EventType convertDownToUp(EventType eventType); + List<Event> remap(const Event &ev); EventManager *_eventMan; bool _enabled; + bool _remapping; + Action *_actionToRemap; Stack<MapRecord> _activeMaps; HashMap<KeyState, Action *> _keysDown; diff --git a/backends/keymapper/remap-dialog.cpp b/backends/keymapper/remap-dialog.cpp index dab295219a..009c2201a9 100644 --- a/backends/keymapper/remap-dialog.cpp +++ b/backends/keymapper/remap-dialog.cpp @@ -39,7 +39,7 @@ enum { }; RemapDialog::RemapDialog() - : Dialog("KeyMapper"), _keymapTable(0), _activeRemapAction(0), _topAction(0), _remapTimeout(0), _topKeymapIsGui(false) { + : Dialog("KeyMapper"), _keymapTable(0), _topAction(0), _remapTimeout(0), _topKeymapIsGui(false) { _keymapper = g_system->getEventManager()->getKeymapper(); assert(_keymapper); @@ -243,16 +243,14 @@ void RemapDialog::clearMapping(uint i) { return; debug(3, "clear the mapping %u", i); - _activeRemapAction = _currentActions[_topAction + i].action; - _activeRemapAction->mapInput(0); - _activeRemapAction->getParent()->saveMappings(); + Action *activeRemapAction = _currentActions[_topAction + i].action; + activeRemapAction->mapInput(0); + activeRemapAction->getParent()->saveMappings(); _changes = true; // force refresh - _topAction = -1; + stopRemapping(true); refreshKeymap(); - - _activeRemapAction = 0; } void RemapDialog::startRemapping(uint i) { @@ -260,57 +258,56 @@ void RemapDialog::startRemapping(uint i) { return; _remapTimeout = g_system->getMillis() + kRemapTimeoutDelay; - _activeRemapAction = _currentActions[_topAction + i].action; + Action *activeRemapAction = _currentActions[_topAction + i].action; _keymapWidgets[i].keyButton->setLabel("..."); _keymapWidgets[i].keyButton->draw(); - _keymapper->setEnabled(false); + _keymapper->startRemappingMode(activeRemapAction); } -void RemapDialog::stopRemapping() { +void RemapDialog::stopRemapping(bool force) { _topAction = -1; refreshKeymap(); - _activeRemapAction = 0; - - _keymapper->setEnabled(true); + if (force) + _keymapper->stopRemappingMode(); } void RemapDialog::handleKeyDown(Common::KeyState state) { - if (_activeRemapAction) + if (_keymapper->isRemapping()) return; GUI::Dialog::handleKeyDown(state); } void RemapDialog::handleKeyUp(Common::KeyState state) { - if (_activeRemapAction) { - const HardwareInput *hwInput = _keymapper->findHardwareInput(state); + if (_keymapper->isRemapping()) + return; - debug(4, "RemapDialog::handleKeyUp Key: %d, %d (%c), %x", state.keycode, state.ascii, (state.ascii ? state.ascii : ' '), state.flags); + GUI::Dialog::handleKeyUp(state); +} - if (hwInput) { - _activeRemapAction->mapInput(hwInput); - _activeRemapAction->getParent()->saveMappings(); - _changes = true; - stopRemapping(); - } +void RemapDialog::handleOtherEvent(Event ev) { + if (ev.type == EVENT_GUI_REMAP_COMPLETE_ACTION) { + // _keymapper is telling us that something changed + _changes = true; + stopRemapping(); } else { - GUI::Dialog::handleKeyUp(state); + GUI::Dialog::handleOtherEvent(ev); } } void RemapDialog::handleMouseDown(int x, int y, int button, int clickCount) { - if (_activeRemapAction) + if (_keymapper->isRemapping()) stopRemapping(); else Dialog::handleMouseDown(x, y, button, clickCount); } void RemapDialog::handleTickle() { - if (_activeRemapAction && g_system->getMillis() > _remapTimeout) - stopRemapping(); + if (_keymapper->isRemapping() && g_system->getMillis() > _remapTimeout) + stopRemapping(true); Dialog::handleTickle(); } @@ -354,9 +351,14 @@ void RemapDialog::loadKeymap() { Keymapper::MapRecord mr = activeKeymaps[i]; debug(3, "RemapDialog::loadKeymap keymap: %s", mr.keymap->getName().c_str()); List<const HardwareInput *>::iterator inputIt = freeInputs.begin(); + const HardwareInput *input = *inputIt; while (inputIt != freeInputs.end()) { - Action *act = mr.keymap->getMappedAction((*inputIt)->key); + Action *act = 0; + if (input->type == kHardwareInputTypeKeyboard) + act = mr.keymap->getMappedAction(input->key); + else if (input->type == kHardwareInputTypeGeneric) + act = mr.keymap->getMappedAction(input->inputCode); if (act) { ActionInfo info = {act, true, act->description + " (" + mr.keymap->getName() + ")"}; diff --git a/backends/keymapper/remap-dialog.h b/backends/keymapper/remap-dialog.h index 143deca4cf..82c68405db 100644 --- a/backends/keymapper/remap-dialog.h +++ b/backends/keymapper/remap-dialog.h @@ -50,6 +50,7 @@ public: virtual void handleKeyUp(Common::KeyState state); virtual void handleMouseDown(int x, int y, int button, int clickCount); virtual void handleTickle(); + virtual void handleOtherEvent(Common::Event ev); protected: struct ActionWidgets { @@ -67,7 +68,7 @@ protected: void refreshKeymap(); void clearMapping(uint i); void startRemapping(uint i); - void stopRemapping(); + void stopRemapping(bool force = false); Keymapper *_keymapper; Keymap** _keymapTable; @@ -85,7 +86,6 @@ protected: uint _rowCount; Array<ActionWidgets> _keymapWidgets; - Action *_activeRemapAction; uint32 _remapTimeout; static const uint32 kRemapTimeoutDelay = 3000; diff --git a/backends/midi/coreaudio.cpp b/backends/midi/coreaudio.cpp index 43c801287d..94262d0d92 100644 --- a/backends/midi/coreaudio.cpp +++ b/backends/midi/coreaudio.cpp @@ -172,10 +172,15 @@ int MidiDriver_CORE::open() { // Load custom soundfont, if specified if (ConfMan.hasKey("soundfont")) { - FSRef fsref; - FSSpec fsSpec; const char *soundfont = ConfMan.get("soundfont").c_str(); + // TODO: We should really check whether the file contains an + // actual soundfont... + +#if USE_DEPRECATED_COREAUDIO_API + // Before 10.5, we need to use kMusicDeviceProperty_SoundBankFSSpec + FSRef fsref; + FSSpec fsSpec; err = FSPathMakeRef ((const byte *)soundfont, &fsref, NULL); if (err == noErr) { @@ -183,8 +188,6 @@ int MidiDriver_CORE::open() { } if (err == noErr) { - // TODO: We should really check here whether the file contains an - // actual soundfont... err = AudioUnitSetProperty ( _synth, kMusicDeviceProperty_SoundBankFSSpec, kAudioUnitScope_Global, @@ -192,9 +195,27 @@ int MidiDriver_CORE::open() { &fsSpec, sizeof(fsSpec) ); } +#else + // kMusicDeviceProperty_SoundBankFSSpec is present on 10.6+, but broken + // kMusicDeviceProperty_SoundBankURL was added in 10.5 as a replacement + CFURLRef url = CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault, (const UInt8 *)soundfont, strlen(soundfont), false); + + if (url) { + err = AudioUnitSetProperty ( + _synth, + kMusicDeviceProperty_SoundBankURL, kAudioUnitScope_Global, + 0, + &url, sizeof(url) + ); + + CFRelease(url); + } else { + warning("Failed to allocate CFURLRef from '%s'", soundfont); + } +#endif if (err != noErr) - warning("Failed loading custom sound font '%s' (error %ld)\n", soundfont, (long)err); + error("Failed loading custom sound font '%s' (error %ld)", soundfont, (long)err); } #ifdef COREAUDIO_DISABLE_REVERB diff --git a/backends/midi/sndio.cpp b/backends/midi/sndio.cpp new file mode 100644 index 0000000000..a065a658e1 --- /dev/null +++ b/backends/midi/sndio.cpp @@ -0,0 +1,152 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +// Disable symbol overrides so that we can use system headers. +#define FORBIDDEN_SYMBOL_ALLOW_ALL + +#include "common/scummsys.h" + +#if defined(USE_SNDIO) + +#include "common/error.h" +#include "common/textconsole.h" +#include "common/util.h" +#include "audio/musicplugin.h" +#include "audio/mpu401.h" + +#include <sndio.h> + +//////////////////////////////////////// +// +// sndio MIDI driver +// +//////////////////////////////////////// + +class MidiDriver_Sndio : public MidiDriver_MPU401 { +public: + MidiDriver_Sndio(); + int open(); + bool isOpen() const { return hdl != NULL; } + void close(); + void send(uint32 b); + void sysEx(const byte *msg, uint16 length); + +private: + struct mio_hdl *hdl; +}; + +MidiDriver_Sndio::MidiDriver_Sndio() { + hdl = NULL; +} + +int MidiDriver_Sndio::open() { + if (hdl != NULL) + return MERR_ALREADY_OPEN; + + hdl = ::mio_open(NULL, MIO_OUT, 0); + if (hdl == NULL) + warning("Could open MIDI port (no music)"); + return 0; +} + +void MidiDriver_Sndio::close() { + MidiDriver_MPU401::close(); + if (!hdl) + return; + mio_close(hdl); + hdl = NULL; +} + +void MidiDriver_Sndio::send(uint32 b) { + unsigned char buf[4]; + unsigned int len; + + if (!hdl) + return; + buf[0] = b & 0xff; + buf[1] = (b >> 8) & 0xff; + buf[2] = (b >> 16) & 0xff; + buf[3] = (b >> 24) & 0xff; + switch (buf[0] & 0xf0) { + case 0xf0: + return; + case 0xc0: + case 0xd0: + len = 2; + break; + default: + len = 3; + } + mio_write(hdl, buf, len); +} + +void MidiDriver_Sndio::sysEx(const byte *msg, uint16 length) { + if (!hdl) + return; + + unsigned char buf[266]; + + assert(length + 2 <= ARRAYSIZE(buf)); + + // Add SysEx frame + buf[0] = 0xF0; + memcpy(buf + 1, msg, length); + buf[length + 1] = 0xF7; + + mio_write(hdl, buf, length + 2); +} + + +// Plugin interface + +class SndioMusicPlugin : public MusicPluginObject { +public: + const char *getName() const { + return "Sndio"; + } + + const char *getId() const { + return "sndio"; + } + + MusicDevices getDevices() const; + Common::Error createInstance(MidiDriver **mididriver, MidiDriver::DeviceHandle = 0) const; +}; + +MusicDevices SndioMusicPlugin::getDevices() const { + MusicDevices devices; + devices.push_back(MusicDevice(this, "", MT_GM)); + return devices; +} + +Common::Error SndioMusicPlugin::createInstance(MidiDriver **mididriver, MidiDriver::DeviceHandle) const { + *mididriver = new MidiDriver_Sndio(); + + return Common::kNoError; +} + +//#if PLUGIN_ENABLED_DYNAMIC(Sndio) + //REGISTER_PLUGIN_DYNAMIC(SNDIO, PLUGIN_TYPE_MUSIC, SndioMusicPlugin); +//#else + REGISTER_PLUGIN_STATIC(SNDIO, PLUGIN_TYPE_MUSIC, SndioMusicPlugin); +//#endif + +#endif diff --git a/backends/midi/stmidi.cpp b/backends/midi/stmidi.cpp index 53302f8a80..5a6326877e 100644 --- a/backends/midi/stmidi.cpp +++ b/backends/midi/stmidi.cpp @@ -36,7 +36,7 @@ #include "common/scummsys.h" -#if defined __MINT__ +#if defined(__MINT__) #include <osbind.h> #include "audio/mpu401.h" diff --git a/backends/midi/timidity.cpp b/backends/midi/timidity.cpp index 172d31e799..5cefe668cd 100644 --- a/backends/midi/timidity.cpp +++ b/backends/midi/timidity.cpp @@ -559,4 +559,4 @@ Common::Error TimidityMusicPlugin::createInstance(MidiDriver **mididriver, MidiD REGISTER_PLUGIN_STATIC(TIMIDITY, PLUGIN_TYPE_MUSIC, TimidityMusicPlugin); //#endif -#endif // defined (USE_TIMIDITY) +#endif // defined(USE_TIMIDITY) diff --git a/backends/mixer/sdl13/sdl13-mixer.cpp b/backends/mixer/sdl13/sdl13-mixer.cpp index 84777c8bab..24d3434fde 100644 --- a/backends/mixer/sdl13/sdl13-mixer.cpp +++ b/backends/mixer/sdl13/sdl13-mixer.cpp @@ -69,13 +69,13 @@ void Sdl13MixerManager::init() { warning("Could not open audio device: %s", SDL_GetError()); _mixer = new Audio::MixerImpl(g_system, desired.freq); - assert(_mixer); + assert(_mixer); _mixer->setReady(false); } else { debug(1, "Output sample rate: %d Hz", _obtained.freq); _mixer = new Audio::MixerImpl(g_system, _obtained.freq); - assert(_mixer); + assert(_mixer); _mixer->setReady(true); startAudio(); diff --git a/backends/mixer/symbiansdl/symbiansdl-mixer.cpp b/backends/mixer/symbiansdl/symbiansdl-mixer.cpp index d4637fdd88..e978e9207f 100644 --- a/backends/mixer/symbiansdl/symbiansdl-mixer.cpp +++ b/backends/mixer/symbiansdl/symbiansdl-mixer.cpp @@ -52,7 +52,7 @@ void SymbianSdlMixerManager::startAudio() { void SymbianSdlMixerManager::callbackHandler(byte *samples, int len) { assert(_mixer); -#if defined (S60) && !defined(S60V3) +#if defined(S60) && !defined(S60V3) // If not stereo then we need to downmix if (_obtained.channels != 2) { _mixer->mixCallback(_stereoMixBuffer, len * 2); diff --git a/backends/modular-backend.cpp b/backends/modular-backend.cpp index 525170d685..b46f33a2bc 100644 --- a/backends/modular-backend.cpp +++ b/backends/modular-backend.cpp @@ -124,7 +124,7 @@ PaletteManager *ModularBackend::getPaletteManager() { return _graphicsManager; } -void ModularBackend::copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h) { +void ModularBackend::copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h) { _graphicsManager->copyRectToScreen(buf, pitch, x, y, w, h); } @@ -171,11 +171,11 @@ void ModularBackend::clearOverlay() { _graphicsManager->clearOverlay(); } -void ModularBackend::grabOverlay(OverlayColor *buf, int pitch) { +void ModularBackend::grabOverlay(void *buf, int pitch) { _graphicsManager->grabOverlay(buf, pitch); } -void ModularBackend::copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h) { +void ModularBackend::copyRectToOverlay(const void *buf, int pitch, int x, int y, int w, int h) { _graphicsManager->copyRectToOverlay(buf, pitch, x, y, w, h); } @@ -195,8 +195,8 @@ void ModularBackend::warpMouse(int x, int y) { _graphicsManager->warpMouse(x, y); } -void ModularBackend::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format) { - _graphicsManager->setMouseCursor(buf, w, h, hotspotX, hotspotY, keycolor, cursorTargetScale, format); +void ModularBackend::setMouseCursor(const void *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, bool dontScale, const Graphics::PixelFormat *format) { + _graphicsManager->setMouseCursor(buf, w, h, hotspotX, hotspotY, keycolor, dontScale, format); } void ModularBackend::setCursorPalette(const byte *colors, uint start, uint num) { diff --git a/backends/modular-backend.h b/backends/modular-backend.h index 072ee805b6..b43769c716 100644 --- a/backends/modular-backend.h +++ b/backends/modular-backend.h @@ -80,7 +80,7 @@ public: virtual int16 getHeight(); virtual int16 getWidth(); virtual PaletteManager *getPaletteManager(); - virtual void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h); + virtual void copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h); virtual Graphics::Surface *lockScreen(); virtual void unlockScreen(); virtual void fillScreen(uint32 col); @@ -93,14 +93,14 @@ public: virtual void hideOverlay(); virtual Graphics::PixelFormat getOverlayFormat() const; virtual void clearOverlay(); - virtual void grabOverlay(OverlayColor *buf, int pitch); - virtual void copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h); + virtual void grabOverlay(void *buf, int pitch); + virtual void copyRectToOverlay(const void *buf, int pitch, int x, int y, int w, int h); virtual int16 getOverlayHeight(); virtual int16 getOverlayWidth(); virtual bool showMouse(bool visible); virtual void warpMouse(int x, int y); - virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int cursorTargetScale = 1, const Graphics::PixelFormat *format = NULL); + virtual void setMouseCursor(const void *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, bool dontScale = false, const Graphics::PixelFormat *format = NULL); virtual void setCursorPalette(const byte *colors, uint start, uint num); //@} diff --git a/backends/module.mk b/backends/module.mk index 95725d9d87..a4f525d21d 100644 --- a/backends/module.mk +++ b/backends/module.mk @@ -11,6 +11,7 @@ MODULE_OBJS := \ midi/alsa.o \ midi/dmedia.o \ midi/seq.o \ + midi/sndio.o \ midi/stmidi.o \ midi/timidity.o \ saves/savefile.o \ diff --git a/backends/platform/android/android.cpp b/backends/platform/android/android.cpp index 902599d50f..0b31ee717c 100644 --- a/backends/platform/android/android.cpp +++ b/backends/platform/android/android.cpp @@ -554,6 +554,7 @@ void OSystem_Android::getTimeAndDate(TimeDate &td) const { td.tm_mday = tm.tm_mday; td.tm_mon = tm.tm_mon; td.tm_year = tm.tm_year; + td.tm_wday = tm.tm_wday; } void OSystem_Android::addSysArchivesToSearchSet(Common::SearchSet &s, diff --git a/backends/platform/android/android.h b/backends/platform/android/android.h index 47a6515a2a..4b13ca4b0f 100644 --- a/backends/platform/android/android.h +++ b/backends/platform/android/android.h @@ -244,7 +244,7 @@ protected: virtual void grabPalette(byte *colors, uint start, uint num); public: - virtual void copyRectToScreen(const byte *buf, int pitch, int x, int y, + virtual void copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h); virtual void updateScreen(); virtual Graphics::Surface *lockScreen(); @@ -257,8 +257,8 @@ public: virtual void showOverlay(); virtual void hideOverlay(); virtual void clearOverlay(); - virtual void grabOverlay(OverlayColor *buf, int pitch); - virtual void copyRectToOverlay(const OverlayColor *buf, int pitch, + virtual void grabOverlay(void *buf, int pitch); + virtual void copyRectToOverlay(const void *buf, int pitch, int x, int y, int w, int h); virtual int16 getOverlayHeight(); virtual int16 getOverlayWidth(); @@ -267,9 +267,9 @@ public: virtual bool showMouse(bool visible); virtual void warpMouse(int x, int y); - virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, + virtual void setMouseCursor(const void *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, - int cursorTargetScale, + bool dontScale, const Graphics::PixelFormat *format); virtual void setCursorPalette(const byte *colors, uint start, uint num); diff --git a/backends/platform/android/android.mk b/backends/platform/android/android.mk index 2e8fd62152..9292a16595 100644 --- a/backends/platform/android/android.mk +++ b/backends/platform/android/android.mk @@ -130,7 +130,18 @@ $(PATH_STAGE_PREFIX).%/res/drawable/scummvm.png: $(PATH_RESOURCES)/drawable/scum $(FILE_RESOURCES_MAIN): $(FILE_MANIFEST) $(RESOURCES) $(ANDROID_JAR8) $(DIST_FILES_THEMES) $(DIST_FILES_ENGINEDATA) $(INSTALL) -d $(PATH_BUILD_ASSETS) $(INSTALL) -c -m 644 $(DIST_FILES_THEMES) $(DIST_FILES_ENGINEDATA) $(PATH_BUILD_ASSETS)/ - $(AAPT) package -f -M $< -S $(PATH_RESOURCES) -A $(PATH_BUILD_ASSETS) -I $(ANDROID_JAR8) -F $@ + work_dir=`pwd`; \ + for i in $(PATH_BUILD_ASSETS)/*.zip; do \ + echo "recompress $$i"; \ + cd $$work_dir; \ + $(RM) -rf $(PATH_BUILD_ASSETS)/tmp; \ + $(MKDIR) $(PATH_BUILD_ASSETS)/tmp; \ + unzip -q $$i -d $(PATH_BUILD_ASSETS)/tmp; \ + cd $(PATH_BUILD_ASSETS)/tmp; \ + zip -r ../`basename $$i` *; \ + done + @$(RM) -rf $(PATH_BUILD_ASSETS)/tmp + $(AAPT) package -f -0 zip -M $< -S $(PATH_RESOURCES) -A $(PATH_BUILD_ASSETS) -I $(ANDROID_JAR8) -F $@ $(PATH_BUILD)/%/$(FILE_RESOURCES): $(PATH_BUILD)/%/AndroidManifest.xml $(PATH_STAGE_PREFIX).%/res/values/strings.xml $(PATH_STAGE_PREFIX).%/res/drawable/scummvm.png plugins/lib%.so $(ANDROID_JAR8) $(AAPT) package -f -M $< -S $(PATH_STAGE_PREFIX).$*/res -I $(ANDROID_JAR8) -F $@ diff --git a/backends/platform/android/gfx.cpp b/backends/platform/android/gfx.cpp index 8bc914f567..cd0fd88484 100644 --- a/backends/platform/android/gfx.cpp +++ b/backends/platform/android/gfx.cpp @@ -421,7 +421,7 @@ void OSystem_Android::grabPalette(byte *colors, uint start, uint num) { pf.colorToRGB(READ_UINT16(p), colors[0], colors[1], colors[2]); } -void OSystem_Android::copyRectToScreen(const byte *buf, int pitch, +void OSystem_Android::copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h) { ENTER("%p, %d, %d, %d, %d, %d", buf, pitch, x, y, w, h); @@ -636,33 +636,32 @@ void OSystem_Android::clearOverlay() { _overlay_texture->fillBuffer(0); } -void OSystem_Android::grabOverlay(OverlayColor *buf, int pitch) { +void OSystem_Android::grabOverlay(void *buf, int pitch) { ENTER("%p, %d", buf, pitch); GLTHREADCHECK; const Graphics::Surface *surface = _overlay_texture->surface_const(); - assert(surface->format.bytesPerPixel == sizeof(buf[0])); + assert(surface->format.bytesPerPixel == sizeof(uint16)); + byte *dst = (byte *)buf; const byte *src = (const byte *)surface->pixels; uint h = surface->h; do { - memcpy(buf, src, surface->w * surface->format.bytesPerPixel); + memcpy(dst, src, surface->w * surface->format.bytesPerPixel); src += surface->pitch; - // This 'pitch' is pixels not bytes - buf += pitch; + dst += pitch; } while (--h); } -void OSystem_Android::copyRectToOverlay(const OverlayColor *buf, int pitch, +void OSystem_Android::copyRectToOverlay(const void *buf, int pitch, int x, int y, int w, int h) { ENTER("%p, %d, %d, %d, %d, %d", buf, pitch, x, y, w, h); GLTHREADCHECK; - // This 'pitch' is pixels not bytes - _overlay_texture->updateBuffer(x, y, w, h, buf, pitch * sizeof(buf[0])); + _overlay_texture->updateBuffer(x, y, w, h, buf, pitch); } int16 OSystem_Android::getOverlayHeight() { @@ -685,12 +684,12 @@ bool OSystem_Android::showMouse(bool visible) { return true; } -void OSystem_Android::setMouseCursor(const byte *buf, uint w, uint h, +void OSystem_Android::setMouseCursor(const void *buf, uint w, uint h, int hotspotX, int hotspotY, - uint32 keycolor, int cursorTargetScale, + uint32 keycolor, bool dontScale, const Graphics::PixelFormat *format) { ENTER("%p, %u, %u, %d, %d, %u, %d, %p", buf, w, h, hotspotX, hotspotY, - keycolor, cursorTargetScale, format); + keycolor, dontScale, format); GLTHREADCHECK; @@ -741,7 +740,7 @@ void OSystem_Android::setMouseCursor(const byte *buf, uint w, uint h, byte *tmp = new byte[pitch * h]; // meh, a 16bit cursor without alpha bits... this is so silly - if (!crossBlit(tmp, buf, pitch, w * 2, w, h, + if (!crossBlit(tmp, (const byte *)buf, pitch, w * 2, w, h, _mouse_texture->getPixelFormat(), *format)) { LOGE("crossblit failed"); @@ -766,7 +765,8 @@ void OSystem_Android::setMouseCursor(const byte *buf, uint w, uint h, } _mouse_hotspot = Common::Point(hotspotX, hotspotY); - _mouse_targetscale = cursorTargetScale; + // TODO: Adapt to the new "do not scale" cursor logic. + _mouse_targetscale = 1; } void OSystem_Android::setCursorPaletteInternal(const byte *colors, diff --git a/backends/platform/android/texture.cpp b/backends/platform/android/texture.cpp index 95c96e0d25..b174e93191 100644 --- a/backends/platform/android/texture.cpp +++ b/backends/platform/android/texture.cpp @@ -52,9 +52,6 @@ // Supported GL extensions static bool npot_supported = false; -#ifdef GL_OES_draw_texture -static bool draw_tex_supported = false; -#endif static inline GLfixed xdiv(int numerator, int denominator) { assert(numerator < (1 << 16)); @@ -85,11 +82,6 @@ void GLESBaseTexture::initGLExtensions() { if (token == "GL_ARB_texture_non_power_of_two") npot_supported = true; - -#ifdef GL_OES_draw_texture - if (token == "GL_OES_draw_texture") - draw_tex_supported = true; -#endif } } @@ -180,45 +172,28 @@ void GLESBaseTexture::allocBuffer(GLuint w, GLuint h) { void GLESBaseTexture::drawTexture(GLshort x, GLshort y, GLshort w, GLshort h) { GLCALL(glBindTexture(GL_TEXTURE_2D, _texture_name)); -#ifdef GL_OES_draw_texture - // Great extension, but only works under specific conditions. - // Still a work-in-progress - disabled for now. - if (false && draw_tex_supported && !hasPalette()) { - //GLCALL(glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE)); - const GLint crop[4] = { 0, _surface.h, _surface.w, -_surface.h }; + const GLfixed tex_width = xdiv(_surface.w, _texture_width); + const GLfixed tex_height = xdiv(_surface.h, _texture_height); + const GLfixed texcoords[] = { + 0, 0, + tex_width, 0, + 0, tex_height, + tex_width, tex_height, + }; - GLCALL(glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, crop)); + GLCALL(glTexCoordPointer(2, GL_FIXED, 0, texcoords)); - // Android GLES bug? - GLCALL(glColor4ub(0xff, 0xff, 0xff, 0xff)); + const GLshort vertices[] = { + x, y, + x + w, y, + x, y + h, + x + w, y + h, + }; - GLCALL(glDrawTexiOES(x, y, 0, w, h)); - } else -#endif - { - const GLfixed tex_width = xdiv(_surface.w, _texture_width); - const GLfixed tex_height = xdiv(_surface.h, _texture_height); - const GLfixed texcoords[] = { - 0, 0, - tex_width, 0, - 0, tex_height, - tex_width, tex_height, - }; - - GLCALL(glTexCoordPointer(2, GL_FIXED, 0, texcoords)); - - const GLshort vertices[] = { - x, y, - x + w, y, - x, y + h, - x + w, y + h, - }; - - GLCALL(glVertexPointer(2, GL_SHORT, 0, vertices)); - - assert(ARRAYSIZE(vertices) == ARRAYSIZE(texcoords)); - GLCALL(glDrawArrays(GL_TRIANGLE_STRIP, 0, ARRAYSIZE(vertices) / 2)); - } + GLCALL(glVertexPointer(2, GL_SHORT, 0, vertices)); + + assert(ARRAYSIZE(vertices) == ARRAYSIZE(texcoords)); + GLCALL(glDrawArrays(GL_TRIANGLE_STRIP, 0, ARRAYSIZE(vertices) / 2)); clearDirty(); } diff --git a/backends/platform/bada/application.cpp b/backends/platform/bada/application.cpp index ba8e544983..e761649245 100644 --- a/backends/platform/bada/application.cpp +++ b/backends/platform/bada/application.cpp @@ -103,7 +103,7 @@ void BadaScummVM::pauseGame(bool pause) { if (pause && g_engine && !g_engine->isPaused()) { _appForm->pushKey(Common::KEYCODE_SPACE); } - + if (g_system) { ((BadaSystem *)g_system)->setMute(pause); } diff --git a/backends/platform/bada/sscanf.cpp b/backends/platform/bada/sscanf.cpp index b5e5b88cb5..aa846698f6 100644 --- a/backends/platform/bada/sscanf.cpp +++ b/backends/platform/bada/sscanf.cpp @@ -56,7 +56,7 @@ bool scanInt(const char **in, va_list *ap, int max) { bool err = false; if (end == *in || (max > 0 && (end - *in) > max)) { - err = true; + err = true; } else { *arg = (int)n; *in = end; diff --git a/backends/platform/bada/system.cpp b/backends/platform/bada/system.cpp index d284688068..3f862c2571 100644 --- a/backends/platform/bada/system.cpp +++ b/backends/platform/bada/system.cpp @@ -21,6 +21,7 @@ */ #include <FUiCtrlMessageBox.h> +#include <FLocales.h> #include "common/config-manager.h" #include "common/file.h" @@ -42,7 +43,9 @@ using namespace Osp::Base; using namespace Osp::Base::Runtime; +using namespace Osp::Locales; using namespace Osp::Ui::Controls; +using namespace Osp::System; #define DEFAULT_CONFIG_FILE "/Home/scummvm.ini" #define RESOURCE_PATH "/Res" @@ -305,7 +308,7 @@ void BadaSystem::initBackend() { ConfMan.registerDefault("aspect_ratio", false); ConfMan.setBool("confirm_exit", false); - Osp::System::SystemTime::GetTicks(_epoch); + SystemTime::GetTicks(_epoch); if (E_SUCCESS != initModules()) { AppLog("initModules failed"); @@ -372,7 +375,7 @@ bool BadaSystem::pollEvent(Common::Event &event) { uint32 BadaSystem::getMillis() { long long result, ticks = 0; - Osp::System::SystemTime::GetTicks(ticks); + SystemTime::GetTicks(ticks); result = ticks - _epoch; return result; } @@ -392,13 +395,18 @@ void BadaSystem::updateScreen() { void BadaSystem::getTimeAndDate(TimeDate &td) const { DateTime currentTime; - if (E_SUCCESS == Osp::System::SystemTime::GetCurrentTime(currentTime)) { + if (E_SUCCESS == SystemTime::GetCurrentTime(WALL_TIME, currentTime)) { td.tm_sec = currentTime.GetSecond(); td.tm_min = currentTime.GetMinute(); td.tm_hour = currentTime.GetHour(); td.tm_mday = currentTime.GetDay(); td.tm_mon = currentTime.GetMonth(); td.tm_year = currentTime.GetYear(); + + Calendar *calendar = Calendar::CreateInstanceN(CALENDAR_GREGORIAN); + calendar->SetTime(currentTime); + td.tm_wday = calendar->GetTimeField(TIME_FIELD_DAY_OF_WEEK) - 1; + delete calendar; } } diff --git a/backends/platform/dc/dc.h b/backends/platform/dc/dc.h index 8ca48bf19e..d41839d961 100644 --- a/backends/platform/dc/dc.h +++ b/backends/platform/dc/dc.h @@ -127,7 +127,7 @@ public: // Draw a bitmap to screen. // The screen will not be updated to reflect the new bitmap - void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h); + void copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h); virtual Graphics::Surface *lockScreen(); virtual void unlockScreen(); @@ -142,7 +142,7 @@ public: void warpMouse(int x, int y); // Set the bitmap that's used when drawing the cursor. - void setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format); + void setMouseCursor(const void *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, bool dontScale, const Graphics::PixelFormat *format); // Replace the specified range of cursor the palette with new colors. void setCursorPalette(const byte *colors, uint start, uint num); @@ -172,8 +172,8 @@ public: void showOverlay(); void hideOverlay(); void clearOverlay(); - void grabOverlay(OverlayColor *buf, int pitch); - void copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h); + void grabOverlay(void *buf, int pitch); + void copyRectToOverlay(const void *buf, int pitch, int x, int y, int w, int h); virtual Graphics::PixelFormat getOverlayFormat() const { return Graphics::createPixelFormat<4444>(); } // Mutex handling diff --git a/backends/platform/dc/dcmain.cpp b/backends/platform/dc/dcmain.cpp index 3e3279f9c3..bec1fdae3a 100644 --- a/backends/platform/dc/dcmain.cpp +++ b/backends/platform/dc/dcmain.cpp @@ -213,6 +213,7 @@ void OSystem_Dreamcast::getTimeAndDate(TimeDate &td) const { td.tm_mday = t.tm_mday; td.tm_mon = t.tm_mon; td.tm_year = t.tm_year; + td.tm_wday = t.tm_wday; } Common::SeekableReadStream *OSystem_Dreamcast::createConfigReadStream() { diff --git a/backends/platform/dc/display.cpp b/backends/platform/dc/display.cpp index e886b55869..cc5798fc10 100644 --- a/backends/platform/dc/display.cpp +++ b/backends/platform/dc/display.cpp @@ -260,7 +260,7 @@ void OSystem_Dreamcast::initSize(uint w, uint h, const Graphics::PixelFormat *fo _devpoll = Timer(); } -void OSystem_Dreamcast::copyRectToScreen(const byte *buf, int pitch, int x, int y, +void OSystem_Dreamcast::copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h) { if (w<1 || h<1) @@ -269,10 +269,11 @@ void OSystem_Dreamcast::copyRectToScreen(const byte *buf, int pitch, int x, int x<<=1; w<<=1; } unsigned char *dst = screen + y*SCREEN_W*2 + x; + const byte *src = (const byte *)buf; do { - memcpy(dst, buf, w); + memcpy(dst, src, w); dst += SCREEN_W*2; - buf += pitch; + src += pitch; } while (--h); _screen_dirty = true; } @@ -291,9 +292,9 @@ void OSystem_Dreamcast::warpMouse(int x, int y) _ms_cur_y = y; } -void OSystem_Dreamcast::setMouseCursor(const byte *buf, uint w, uint h, +void OSystem_Dreamcast::setMouseCursor(const void *buf, uint w, uint h, int hotspot_x, int hotspot_y, - uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format) + uint32 keycolor, bool dontScale, const Graphics::PixelFormat *format) { _ms_cur_w = w; _ms_cur_h = h; @@ -652,27 +653,29 @@ void OSystem_Dreamcast::clearOverlay() _overlay_dirty = true; } -void OSystem_Dreamcast::grabOverlay(OverlayColor *buf, int pitch) +void OSystem_Dreamcast::grabOverlay(void *buf, int pitch) { int h = OVL_H; unsigned short *src = overlay; + unsigned char *dst = (unsigned char *)buf; do { - memcpy(buf, src, OVL_W*sizeof(int16)); + memcpy(dst, src, OVL_W*sizeof(int16)); src += OVL_W; - buf += pitch; + dst += pitch; } while (--h); } -void OSystem_Dreamcast::copyRectToOverlay(const OverlayColor *buf, int pitch, +void OSystem_Dreamcast::copyRectToOverlay(const void *buf, int pitch, int x, int y, int w, int h) { if (w<1 || h<1) return; unsigned short *dst = overlay + y*OVL_W + x; + const unsigned char *src = (const unsigned char *)buf; do { - memcpy(dst, buf, w*sizeof(int16)); + memcpy(dst, src, w*sizeof(int16)); dst += OVL_W; - buf += pitch; + src += pitch; } while (--h); _overlay_dirty = true; } diff --git a/backends/platform/dc/vmsave.cpp b/backends/platform/dc/vmsave.cpp index e06dd7fa43..ba3b787942 100644 --- a/backends/platform/dc/vmsave.cpp +++ b/backends/platform/dc/vmsave.cpp @@ -316,8 +316,9 @@ public: class VMSaveManager : public Common::SaveFileManager { public: - virtual Common::OutSaveFile *openForSaving(const Common::String &filename) { - return Common::wrapCompressedWriteStream(new OutVMSave(filename.c_str())); + virtual Common::OutSaveFile *openForSaving(const Common::String &filename, bool compress = true) { + OutVMSave *s = new OutVMSave(filename.c_str()); + return compress ? Common::wrapCompressedWriteStream(s) : s; } virtual Common::InSaveFile *openForLoading(const Common::String &filename) { diff --git a/backends/platform/dingux/README.DINGUX b/backends/platform/dingux/README.DINGUX index 04f0d30844..9e65d4c36d 100644 --- a/backends/platform/dingux/README.DINGUX +++ b/backends/platform/dingux/README.DINGUX @@ -29,10 +29,27 @@ file included into the scummvm directory you copied to the SD card, and then lau Building from binaries ============================== -* ToDO * +It's pretty simple if you are running Linux on an x86/amd64 machine: +1. Download and install the OpenDingux toolchain (http://www.treewalker.org/opendingux/) +2. Download ScummVM sources and uncompress them +3. Create a build directory and run configure specifying the correct library path. Eg. + mkdir build_dingux + LDFLAGS="-L/path-to-toolchain/usr/lib" ../path-to-scummvm-sources/configure --host=dingux --enable-plugins --default-dynamic + make +4. Prepare the distribution directory + make dingux-dist +5. Copy the distribution directory located in dingux-dist/scummvm to your SD card +6. Enjoy Kernel and rootfs WARNINGS ============================== + +*** A WARNING about the WARNING! *** +The info below should no longer be valid relating to the new OpenDingux (http://www.treewalker.org/opendingux/) +toolchain. When using OpenDingux you don't need custom kernels or libraries, +after some checking I will remove the following warnings and keep OpenDingux +as the only supported toolchain. + All the dingux root images (rootfs) i found floating on the net have broken tremor libraries, which make scummvm crash in a bad way. One solution is to replace the libraries in your rootfs by injecting these fixed ones: diff --git a/backends/platform/dingux/dingux.mk b/backends/platform/dingux/dingux.mk index 882078fe46..e0aca42856 100644 --- a/backends/platform/dingux/dingux.mk +++ b/backends/platform/dingux/dingux.mk @@ -28,3 +28,4 @@ endif $(CP) $(srcdir)/backends/vkeybd/packs/vkeybd_default.zip $(bundle_name)/ $(CP) $(srcdir)/backends/platform/dingux/scummvm.gpe $(bundle_name)/ $(CP) $(srcdir)/backends/platform/dingux/README.DINGUX $(bundle_name)/ + $(CP) $(srcdir)/backends/platform/dingux/scummvm.png $(bundle_name)/ diff --git a/backends/platform/dingux/scummvm.png b/backends/platform/dingux/scummvm.png Binary files differnew file mode 100644 index 0000000000..128e59efc4 --- /dev/null +++ b/backends/platform/dingux/scummvm.png diff --git a/backends/platform/ds/arm9/source/gbampsave.cpp b/backends/platform/ds/arm9/source/gbampsave.cpp index 03729c5e6e..3192e2d277 100644 --- a/backends/platform/ds/arm9/source/gbampsave.cpp +++ b/backends/platform/ds/arm9/source/gbampsave.cpp @@ -45,7 +45,7 @@ static Common::String getSavePath() { // GBAMP Save File Manager ////////////////////////// -Common::OutSaveFile *GBAMPSaveFileManager::openForSaving(const Common::String &filename) { +Common::OutSaveFile *GBAMPSaveFileManager::openForSaving(const Common::String &filename, bool compress) { Common::String fileSpec = getSavePath(); if (fileSpec.lastChar() != '/') fileSpec += '/'; diff --git a/backends/platform/ds/arm9/source/gbampsave.h b/backends/platform/ds/arm9/source/gbampsave.h index 492054dc52..0d9d9aca8c 100644 --- a/backends/platform/ds/arm9/source/gbampsave.h +++ b/backends/platform/ds/arm9/source/gbampsave.h @@ -27,7 +27,7 @@ class GBAMPSaveFileManager : public Common::SaveFileManager { public: - virtual Common::OutSaveFile *openForSaving(const Common::String &filename); + virtual Common::OutSaveFile *openForSaving(const Common::String &filename, bool compress = true); virtual Common::InSaveFile *openForLoading(const Common::String &filename); virtual bool removeSavefile(const Common::String &filename); diff --git a/backends/platform/ds/arm9/source/osystem_ds.cpp b/backends/platform/ds/arm9/source/osystem_ds.cpp index 73340ed18a..a4b9c842fc 100644 --- a/backends/platform/ds/arm9/source/osystem_ds.cpp +++ b/backends/platform/ds/arm9/source/osystem_ds.cpp @@ -280,7 +280,7 @@ void OSystem_DS::grabPalette(unsigned char *colors, uint start, uint num) { #define MISALIGNED16(ptr) (((u32) (ptr) & 1) != 0) -void OSystem_DS::copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h) { +void OSystem_DS::copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h) { if (!_graphicsEnable) return; if (w <= 1) return; if (h < 0) return; @@ -509,13 +509,13 @@ void OSystem_DS::clearOverlay() { // consolePrintf("clearovl\n"); } -void OSystem_DS::grabOverlay(OverlayColor *buf, int pitch) { +void OSystem_DS::grabOverlay(void *buf, int pitch) { // consolePrintf("grabovl\n") u16 *start = DS::get16BitBackBuffer(); for (int y = 0; y < 200; y++) { u16 *src = start + (y * 320); - u16 *dest = ((u16 *) (buf)) + (y * pitch); + u16 *dest = (u16 *)((u8 *)buf + (y * pitch)); for (int x = 0; x < 320; x++) { *dest++ = *src++; @@ -524,9 +524,9 @@ void OSystem_DS::grabOverlay(OverlayColor *buf, int pitch) { } -void OSystem_DS::copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h) { +void OSystem_DS::copyRectToOverlay(const void *buf, int pitch, int x, int y, int w, int h) { u16 *bg = (u16 *) DS::get16BitBackBuffer(); - const u16 *src = (const u16 *) buf; + const u8 *source = (const u8 *)buf; // if (x + w > 256) w = 256 - x; //if (x + h > 256) h = 256 - y; @@ -536,7 +536,7 @@ void OSystem_DS::copyRectToOverlay(const OverlayColor *buf, int pitch, int x, in for (int dy = y; dy < y + h; dy++) { - + const u16 *src = (const u16 *)source; // Slow but save copy: for (int dx = x; dx < x + w; dx++) { @@ -546,7 +546,7 @@ void OSystem_DS::copyRectToOverlay(const OverlayColor *buf, int pitch, int x, in //consolePrintf("%d,", *src); src++; } - src += (pitch - w); + source += pitch; // Fast but broken copy: (why?) /* @@ -580,7 +580,7 @@ bool OSystem_DS::showMouse(bool visible) { void OSystem_DS::warpMouse(int x, int y) { } -void OSystem_DS::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, u32 keycolor, int targetCursorScale, const Graphics::PixelFormat *format) { +void OSystem_DS::setMouseCursor(const void *buf, uint w, uint h, int hotspotX, int hotspotY, u32 keycolor, bool dontScale, const Graphics::PixelFormat *format) { if ((w > 0) && (w < 64) && (h > 0) && (h < 64)) { memcpy(_cursorImage, buf, w * h); _cursorW = w; @@ -588,7 +588,9 @@ void OSystem_DS::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, i _cursorHotX = hotspotX; _cursorHotY = hotspotY; _cursorKey = keycolor; - _cursorScale = targetCursorScale; + // TODO: The old target scales was saved, but never used. Should the + // new "do not scale" logic be implemented? + //_cursorScale = targetCursorScale; refreshCursor(); } } @@ -688,6 +690,7 @@ void OSystem_DS::getTimeAndDate(TimeDate &td) const { td.tm_mday = t.tm_mday; td.tm_mon = t.tm_mon; td.tm_year = t.tm_year; + td.tm_wday = t.tm_wday; } FilesystemFactory *OSystem_DS::getFilesystemFactory() { diff --git a/backends/platform/ds/arm9/source/osystem_ds.h b/backends/platform/ds/arm9/source/osystem_ds.h index 6aa3731916..a6001da764 100644 --- a/backends/platform/ds/arm9/source/osystem_ds.h +++ b/backends/platform/ds/arm9/source/osystem_ds.h @@ -98,15 +98,15 @@ protected: public: void restoreHardwarePalette(); - virtual void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h); + virtual void copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h); virtual void updateScreen(); virtual void setShakePos(int shakeOffset); virtual void showOverlay(); virtual void hideOverlay(); virtual void clearOverlay(); - virtual void grabOverlay(OverlayColor *buf, int pitch); - virtual void copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h); + virtual void grabOverlay(void *buf, int pitch); + virtual void copyRectToOverlay(const void *buf, int pitch, int x, int y, int w, int h); virtual int16 getOverlayHeight(); virtual int16 getOverlayWidth(); virtual Graphics::PixelFormat getOverlayFormat() const { return Graphics::createPixelFormat<1555>(); } @@ -114,7 +114,7 @@ public: virtual bool showMouse(bool visible); virtual void warpMouse(int x, int y); - virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, u32 keycolor, int targetCursorScale, const Graphics::PixelFormat *format); + virtual void setMouseCursor(const void *buf, uint w, uint h, int hotspotX, int hotspotY, u32 keycolor, bool dontScale, const Graphics::PixelFormat *format); virtual bool pollEvent(Common::Event &event); virtual uint32 getMillis(); diff --git a/backends/platform/gph/caanoo-bundle.mk b/backends/platform/gph/caanoo-bundle.mk index 2cf8e62b37..2cf8e62b37 100755..100644 --- a/backends/platform/gph/caanoo-bundle.mk +++ b/backends/platform/gph/caanoo-bundle.mk diff --git a/backends/platform/gph/gp2xwiz-bundle.mk b/backends/platform/gph/gp2xwiz-bundle.mk index 4f49850813..4f49850813 100755..100644 --- a/backends/platform/gph/gp2xwiz-bundle.mk +++ b/backends/platform/gph/gp2xwiz-bundle.mk diff --git a/backends/platform/gph/gph-backend.cpp b/backends/platform/gph/gph-backend.cpp index 49a1edf411..485780b472 100644 --- a/backends/platform/gph/gph-backend.cpp +++ b/backends/platform/gph/gph-backend.cpp @@ -20,6 +20,8 @@ * */ +#if defined(GPH_DEVICE) + // Disable symbol overrides so that we can use system headers. #define FORBIDDEN_SYMBOL_ALLOW_ALL @@ -32,8 +34,6 @@ #include "backends/saves/default/default-saves.h" #include "backends/timer/default/default-timer.h" -#include "base/main.h" - #include "common/archive.h" #include "common/config-manager.h" #include "common/debug.h" @@ -64,23 +64,6 @@ void OSystem_GPH::initBackend() { assert(!_inited); - // Create the events manager - if (_eventSource == 0) - _eventSource = new GPHEventSource(); - - // Create the graphics manager - if (_graphicsManager == 0) { - _graphicsManager = new GPHGraphicsManager(_eventSource); - } - - // Create the mixer manager - if (_mixer == 0) { - _mixerManager = new DoubleBufferSDLMixerManager(); - - // Setup and start mixer - _mixerManager->init(); - } - /* Setup default save path to be workingdir/saves */ char savePath[PATH_MAX+1]; @@ -165,16 +148,42 @@ void OSystem_GPH::initBackend() { /* Make sure that aspect ratio correction is enabled on the 1st run to stop users asking me what the 'wasted space' at the bottom is ;-). */ ConfMan.registerDefault("aspect_ratio", true); + ConfMan.registerDefault("fullscreen", true); /* Make sure SDL knows that we have a joystick we want to use. */ ConfMan.setInt("joystick_num", 0); + // Create the events manager + if (_eventSource == 0) + _eventSource = new GPHEventSource(); + + // Create the graphics manager + if (_graphicsManager == 0) { + _graphicsManager = new GPHGraphicsManager(_eventSource); + } + /* Pass to POSIX method to do the heavy lifting */ OSystem_POSIX::initBackend(); _inited = true; } +void OSystem_GPH::initSDL() { + // Check if SDL has not been initialized + if (!_initedSDL) { + + uint32 sdlFlags = SDL_INIT_EVENTTHREAD; + if (ConfMan.hasKey("disable_sdl_parachute")) + sdlFlags |= SDL_INIT_NOPARACHUTE; + + // Initialize SDL (SDL Subsystems are initiliazed in the corresponding sdl managers) + if (SDL_Init(sdlFlags) == -1) + error("Could not initialize SDL: %s", SDL_GetError()); + + _initedSDL = true; + } +} + void OSystem_GPH::addSysArchivesToSearchSet(Common::SearchSet &s, int priority) { /* Setup default extra data paths for engine data files and plugins */ @@ -222,3 +231,5 @@ void OSystem_GPH::quit() { OSystem_POSIX::quit(); } + +#endif diff --git a/backends/platform/gph/gph-main.cpp b/backends/platform/gph/gph-main.cpp index 2c43af151f..876de0f358 100644 --- a/backends/platform/gph/gph-main.cpp +++ b/backends/platform/gph/gph-main.cpp @@ -21,7 +21,7 @@ */ #include "backends/platform/gph/gph.h" -#include "backends/plugins/posix/posix-provider.h" +#include "backends/plugins/sdl/sdl-provider.h" #include "base/main.h" #if defined(GPH_DEVICE) @@ -36,7 +36,7 @@ int main(int argc, char *argv[]) { ((OSystem_GPH *)g_system)->init(); #ifdef DYNAMIC_MODULES - PluginManager::instance().addPluginProvider(new POSIXPluginProvider()); + PluginManager::instance().addPluginProvider(new SDLPluginProvider()); #endif // Invoke the actual ScummVM main entry point: diff --git a/backends/platform/gph/gph.h b/backends/platform/gph/gph.h index 80f43f0bab..90a798154f 100644 --- a/backends/platform/gph/gph.h +++ b/backends/platform/gph/gph.h @@ -26,13 +26,11 @@ #if defined(GPH_DEVICE) #include "backends/base-backend.h" -#include "backends/platform/sdl/sdl.h" +#include "backends/platform/sdl/sdl-sys.h" #include "backends/platform/sdl/posix/posix.h" #include "backends/events/gph/gph-events.h" #include "backends/graphics/gph/gph-graphics.h" -#define __GP2XWIZ__ - #ifndef PATH_MAX #define PATH_MAX 255 #endif @@ -45,6 +43,11 @@ public: void addSysArchivesToSearchSet(Common::SearchSet &s, int priority); void initBackend(); void quit(); + +protected: + bool _inited; + bool _initedSDL; + virtual void initSDL(); }; #endif diff --git a/backends/platform/iphone/iphone_common.h b/backends/platform/iphone/iphone_common.h index 19e4f2ce9b..9c45a240cb 100644 --- a/backends/platform/iphone/iphone_common.h +++ b/backends/platform/iphone/iphone_common.h @@ -86,9 +86,17 @@ struct VideoContext { int shakeOffsetY; }; +struct InternalEvent { + InternalEvent() : type(), value1(), value2() {} + InternalEvent(InputEvent t, int v1, int v2) : type(t), value1(v1), value2(v2) {} + + InputEvent type; + int value1, value2; +}; + // On the ObjC side void iPhone_updateScreen(); -bool iPhone_fetchEvent(int *outEvent, int *outX, int *outY); +bool iPhone_fetchEvent(InternalEvent *event); const char *iPhone_getDocumentsDir(); bool iPhone_isHighResDevice(); diff --git a/backends/platform/iphone/iphone_video.h b/backends/platform/iphone/iphone_video.h index 1405fe35f1..6b8c25ebcf 100644 --- a/backends/platform/iphone/iphone_video.h +++ b/backends/platform/iphone/iphone_video.h @@ -34,10 +34,13 @@ #include "iphone_keyboard.h" #include "iphone_common.h" +#include "common/list.h" + @interface iPhoneView : UIView { VideoContext _videoContext; - NSMutableArray *_events; + Common::List<InternalEvent> _events; + NSLock *_eventLock; SoftKeyboard *_keyboardView; EAGLContext *_context; @@ -94,14 +97,14 @@ - (void)updateMouseCursorScaling; - (void)updateMouseCursor; -- (id)getEvent; - - (void)deviceOrientationChanged:(UIDeviceOrientation)orientation; - (void)applicationSuspend; - (void)applicationResume; +- (bool)fetchEvent:(InternalEvent *)event; + @end extern iPhoneView *g_iPhoneViewInstance; diff --git a/backends/platform/iphone/iphone_video.mm b/backends/platform/iphone/iphone_video.mm index 5b78237ff7..2ae1b0e692 100644 --- a/backends/platform/iphone/iphone_video.mm +++ b/backends/platform/iphone/iphone_video.mm @@ -65,23 +65,8 @@ void iPhone_updateScreen() { } } -bool iPhone_fetchEvent(int *outEvent, int *outX, int *outY) { - id event = [g_iPhoneViewInstance getEvent]; - if (event == nil) { - return false; - } - - id type = [event objectForKey:@"type"]; - - if (type == nil) { - printf("fetchEvent says: No type!\n"); - return false; - } - - *outEvent = [type intValue]; - *outX = [[event objectForKey:@"x"] intValue]; - *outY = [[event objectForKey:@"y"] intValue]; - return true; +bool iPhone_fetchEvent(InternalEvent *event) { + return [g_iPhoneViewInstance fetchEvent:event]; } uint getSizeNextPOT(uint size) { @@ -197,6 +182,8 @@ const char *iPhone_getDocumentsDir() { _firstTouch = NULL; _secondTouch = NULL; + _eventLock = [[NSLock alloc] init]; + _gameScreenVertCoords[0] = _gameScreenVertCoords[1] = _gameScreenVertCoords[2] = _gameScreenVertCoords[3] = _gameScreenVertCoords[4] = _gameScreenVertCoords[5] = @@ -242,6 +229,7 @@ const char *iPhone_getDocumentsDir() { _videoContext.overlayTexture.free(); _videoContext.mouseTexture.free(); + [_eventLock dealloc]; [super dealloc]; } @@ -280,6 +268,11 @@ const char *iPhone_getDocumentsDir() { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter); printOpenGLError(); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter); printOpenGLError(); + // We use GL_CLAMP_TO_EDGE here to avoid artifacts when linear filtering + // is used. If we would not use this for example the cursor in Loom would + // have a line/border artifact on the right side of the covered rect. + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); printOpenGLError(); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); printOpenGLError(); } - (void)setGraphicsMode { @@ -488,7 +481,7 @@ const char *iPhone_getDocumentsDir() { else if (_videoContext.screenWidth == 640 && _videoContext.screenHeight == 400) adjustedHeight = 480; } - + float overlayPortraitRatio; if (_orientation == UIDeviceOrientationLandscapeLeft || _orientation == UIDeviceOrientationLandscapeRight) { @@ -575,23 +568,23 @@ const char *iPhone_getDocumentsDir() { } } -- (id)getEvent { - if (_events == nil || [_events count] == 0) { - return nil; - } - - id event = [_events objectAtIndex: 0]; - - [_events removeObjectAtIndex: 0]; - - return event; +- (void)addEvent:(InternalEvent)event { + [_eventLock lock]; + _events.push_back(event); + [_eventLock unlock]; } -- (void)addEvent:(NSDictionary *)event { - if (_events == nil) - _events = [[NSMutableArray alloc] init]; +- (bool)fetchEvent:(InternalEvent *)event { + [_eventLock lock]; + if (_events.empty()) { + [_eventLock unlock]; + return false; + } - [_events addObject: event]; + *event = *_events.begin(); + _events.pop_front(); + [_eventLock unlock]; + return true; } /** @@ -664,14 +657,7 @@ const char *iPhone_getDocumentsDir() { return; } - [self addEvent: - [[NSDictionary alloc] initWithObjectsAndKeys: - [NSNumber numberWithInt:kInputOrientationChanged], @"type", - [NSNumber numberWithInt:orientation], @"x", - [NSNumber numberWithInt:0], @"y", - nil - ] - ]; + [self addEvent:InternalEvent(kInputOrientationChanged, orientation, 0)]; } - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { @@ -686,14 +672,7 @@ const char *iPhone_getDocumentsDir() { return; _firstTouch = touch; - [self addEvent: - [[NSDictionary alloc] initWithObjectsAndKeys: - [NSNumber numberWithInt:kInputMouseDown], @"type", - [NSNumber numberWithInt:x], @"x", - [NSNumber numberWithInt:y], @"y", - nil - ] - ]; + [self addEvent:InternalEvent(kInputMouseDown, x, y)]; break; } @@ -704,14 +683,7 @@ const char *iPhone_getDocumentsDir() { return; _secondTouch = touch; - [self addEvent: - [[NSDictionary alloc] initWithObjectsAndKeys: - [NSNumber numberWithInt:kInputMouseSecondDown], @"type", - [NSNumber numberWithInt:x], @"x", - [NSNumber numberWithInt:y], @"y", - nil - ] - ]; + [self addEvent:InternalEvent(kInputMouseSecondDown, x, y)]; break; } } @@ -727,27 +699,13 @@ const char *iPhone_getDocumentsDir() { if (![self getMouseCoords:point eventX:&x eventY:&y]) return; - [self addEvent: - [[NSDictionary alloc] initWithObjectsAndKeys: - [NSNumber numberWithInt:kInputMouseDragged], @"type", - [NSNumber numberWithInt:x], @"x", - [NSNumber numberWithInt:y], @"y", - nil - ] - ]; + [self addEvent:InternalEvent(kInputMouseDragged, x, y)]; } else if (touch == _secondTouch) { CGPoint point = [touch locationInView:self]; if (![self getMouseCoords:point eventX:&x eventY:&y]) return; - [self addEvent: - [[NSDictionary alloc] initWithObjectsAndKeys: - [NSNumber numberWithInt:kInputMouseSecondDragged], @"type", - [NSNumber numberWithInt:x], @"x", - [NSNumber numberWithInt:y], @"y", - nil - ] - ]; + [self addEvent:InternalEvent(kInputMouseSecondDragged, x, y)]; } } } @@ -763,14 +721,7 @@ const char *iPhone_getDocumentsDir() { if (![self getMouseCoords:point eventX:&x eventY:&y]) return; - [self addEvent: - [[NSDictionary alloc] initWithObjectsAndKeys: - [NSNumber numberWithInt:kInputMouseUp], @"type", - [NSNumber numberWithInt:x], @"x", - [NSNumber numberWithInt:y], @"y", - nil - ] - ]; + [self addEvent:InternalEvent(kInputMouseUp, x, y)]; break; } @@ -780,14 +731,7 @@ const char *iPhone_getDocumentsDir() { if (![self getMouseCoords:point eventX:&x eventY:&y]) return; - [self addEvent: - [[NSDictionary alloc] initWithObjectsAndKeys: - [NSNumber numberWithInt:kInputMouseSecondUp], @"type", - [NSNumber numberWithInt:x], @"x", - [NSNumber numberWithInt:y], @"y", - nil - ] - ]; + [self addEvent:InternalEvent(kInputMouseSecondUp, x, y)]; break; } } @@ -797,14 +741,7 @@ const char *iPhone_getDocumentsDir() { } - (void)handleKeyPress:(unichar)c { - [self addEvent: - [[NSDictionary alloc] initWithObjectsAndKeys: - [NSNumber numberWithInt:kInputKeyPressed], @"type", - [NSNumber numberWithInt:c], @"x", - [NSNumber numberWithInt:0], @"y", - nil - ] - ]; + [self addEvent:InternalEvent(kInputKeyPressed, c, 0)]; } - (BOOL)canHandleSwipes { @@ -814,38 +751,16 @@ const char *iPhone_getDocumentsDir() { - (int)swipe:(int)num withEvent:(struct __GSEvent *)event { //printf("swipe: %i\n", num); - [self addEvent: - [[NSDictionary alloc] initWithObjectsAndKeys: - [NSNumber numberWithInt:kInputSwipe], @"type", - [NSNumber numberWithInt:num], @"x", - [NSNumber numberWithInt:0], @"y", - nil - ] - ]; - + [self addEvent:InternalEvent(kInputSwipe, num, 0)]; return 0; } - (void)applicationSuspend { - [self addEvent: - [[NSDictionary alloc] initWithObjectsAndKeys: - [NSNumber numberWithInt:kInputApplicationSuspended], @"type", - [NSNumber numberWithInt:0], @"x", - [NSNumber numberWithInt:0], @"y", - nil - ] - ]; + [self addEvent:InternalEvent(kInputApplicationSuspended, 0, 0)]; } - (void)applicationResume { - [self addEvent: - [[NSDictionary alloc] initWithObjectsAndKeys: - [NSNumber numberWithInt:kInputApplicationResumed], @"type", - [NSNumber numberWithInt:0], @"x", - [NSNumber numberWithInt:0], @"y", - nil - ] - ]; + [self addEvent:InternalEvent(kInputApplicationResumed, 0, 0)]; } @end diff --git a/backends/platform/iphone/osys_events.cpp b/backends/platform/iphone/osys_events.cpp index 85efbda208..9cfca0836e 100644 --- a/backends/platform/iphone/osys_events.cpp +++ b/backends/platform/iphone/osys_events.cpp @@ -46,41 +46,40 @@ bool OSystem_IPHONE::pollEvent(Common::Event &event) { return true; } - int eventType; - int x, y; + InternalEvent internalEvent; - if (iPhone_fetchEvent(&eventType, &x, &y)) { - switch ((InputEvent)eventType) { + if (iPhone_fetchEvent(&internalEvent)) { + switch (internalEvent.type) { case kInputMouseDown: - if (!handleEvent_mouseDown(event, x, y)) + if (!handleEvent_mouseDown(event, internalEvent.value1, internalEvent.value2)) return false; break; case kInputMouseUp: - if (!handleEvent_mouseUp(event, x, y)) + if (!handleEvent_mouseUp(event, internalEvent.value1, internalEvent.value2)) return false; break; case kInputMouseDragged: - if (!handleEvent_mouseDragged(event, x, y)) + if (!handleEvent_mouseDragged(event, internalEvent.value1, internalEvent.value2)) return false; break; case kInputMouseSecondDragged: - if (!handleEvent_mouseSecondDragged(event, x, y)) + if (!handleEvent_mouseSecondDragged(event, internalEvent.value1, internalEvent.value2)) return false; break; case kInputMouseSecondDown: _secondaryTapped = true; - if (!handleEvent_secondMouseDown(event, x, y)) + if (!handleEvent_secondMouseDown(event, internalEvent.value1, internalEvent.value2)) return false; break; case kInputMouseSecondUp: _secondaryTapped = false; - if (!handleEvent_secondMouseUp(event, x, y)) + if (!handleEvent_secondMouseUp(event, internalEvent.value1, internalEvent.value2)) return false; break; case kInputOrientationChanged: - handleEvent_orientationChanged(x); + handleEvent_orientationChanged(internalEvent.value1); return false; break; @@ -90,11 +89,11 @@ bool OSystem_IPHONE::pollEvent(Common::Event &event) { break; case kInputKeyPressed: - handleEvent_keyPressed(event, x); + handleEvent_keyPressed(event, internalEvent.value1); break; case kInputSwipe: - if (!handleEvent_swipe(event, x)) + if (!handleEvent_swipe(event, internalEvent.value1)) return false; break; diff --git a/backends/platform/iphone/osys_main.cpp b/backends/platform/iphone/osys_main.cpp index 9a33cd8968..f9b2a81ce6 100644 --- a/backends/platform/iphone/osys_main.cpp +++ b/backends/platform/iphone/osys_main.cpp @@ -145,15 +145,14 @@ bool OSystem_IPHONE::getFeatureState(Feature f) { void OSystem_IPHONE::suspendLoop() { bool done = false; - int eventType; - int x, y; uint32 startTime = getMillis(); stopSoundsystem(); + InternalEvent event; while (!done) { - if (iPhone_fetchEvent(&eventType, &x, &y)) - if ((InputEvent)eventType == kInputApplicationResumed) + if (iPhone_fetchEvent(&event)) + if (event.type == kInputApplicationResumed) done = true; usleep(100000); } @@ -236,6 +235,7 @@ void OSystem_IPHONE::getTimeAndDate(TimeDate &td) const { td.tm_mday = t.tm_mday; td.tm_mon = t.tm_mon; td.tm_year = t.tm_year; + td.tm_wday = t.tm_wday; } Audio::Mixer *OSystem_IPHONE::getMixer() { diff --git a/backends/platform/iphone/osys_main.h b/backends/platform/iphone/osys_main.h index b443e22f56..037125490d 100644 --- a/backends/platform/iphone/osys_main.h +++ b/backends/platform/iphone/osys_main.h @@ -143,7 +143,7 @@ protected: virtual void grabPalette(byte *colors, uint start, uint num); public: - virtual void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h); + virtual void copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h); virtual void updateScreen(); virtual Graphics::Surface *lockScreen(); virtual void unlockScreen(); @@ -152,8 +152,8 @@ public: virtual void showOverlay(); virtual void hideOverlay(); virtual void clearOverlay(); - virtual void grabOverlay(OverlayColor *buf, int pitch); - virtual void copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h); + virtual void grabOverlay(void *buf, int pitch); + virtual void copyRectToOverlay(const void *buf, int pitch, int x, int y, int w, int h); virtual int16 getOverlayHeight(); virtual int16 getOverlayWidth(); virtual Graphics::PixelFormat getOverlayFormat() const { return Graphics::createPixelFormat<5551>(); } @@ -161,7 +161,7 @@ public: virtual bool showMouse(bool visible); virtual void warpMouse(int x, int y); - virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor = 255, int cursorTargetScale = 1, const Graphics::PixelFormat *format = NULL); + virtual void setMouseCursor(const void *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor = 255, bool dontScale = false, const Graphics::PixelFormat *format = NULL); virtual void setCursorPalette(const byte *colors, uint start, uint num); virtual bool pollEvent(Common::Event &event); diff --git a/backends/platform/iphone/osys_video.mm b/backends/platform/iphone/osys_video.mm index 6f80a6cba3..ebe435cb25 100644 --- a/backends/platform/iphone/osys_video.mm +++ b/backends/platform/iphone/osys_video.mm @@ -137,6 +137,7 @@ int16 OSystem_IPHONE::getWidth() { } void OSystem_IPHONE::setPalette(const byte *colors, uint start, uint num) { + //printf("setPalette(%p, %u, %u)\n", colors, start, num); assert(start + num <= 256); const byte *b = colors; @@ -150,6 +151,7 @@ void OSystem_IPHONE::setPalette(const byte *colors, uint start, uint num) { } void OSystem_IPHONE::grabPalette(byte *colors, uint start, uint num) { + //printf("grabPalette(%p, %u, %u)\n", colors, start, num); assert(start + num <= 256); byte *b = colors; @@ -159,18 +161,19 @@ void OSystem_IPHONE::grabPalette(byte *colors, uint start, uint num) { } } -void OSystem_IPHONE::copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h) { - //printf("copyRectToScreen(%i, %i, %i, %i)\n", x, y, w, h); +void OSystem_IPHONE::copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h) { + //printf("copyRectToScreen(%p, %d, %i, %i, %i, %i)\n", buf, pitch, x, y, w, h); //Clip the coordinates + const byte *src = (const byte *)buf; if (x < 0) { w += x; - buf -= x; + src -= x; x = 0; } if (y < 0) { h += y; - buf -= y * pitch; + src -= y * pitch; y = 0; } @@ -191,22 +194,22 @@ void OSystem_IPHONE::copyRectToScreen(const byte *buf, int pitch, int x, int y, byte *dst = (byte *)_framebuffer.getBasePtr(x, y); if (_framebuffer.pitch == pitch && _framebuffer.w == w) { - memcpy(dst, buf, h * pitch); + memcpy(dst, src, h * pitch); } else { do { - memcpy(dst, buf, w * _framebuffer.format.bytesPerPixel); - buf += pitch; + memcpy(dst, src, w * _framebuffer.format.bytesPerPixel); + src += pitch; dst += _framebuffer.pitch; } while (--h); } } void OSystem_IPHONE::updateScreen() { - //printf("updateScreen(): %i dirty rects.\n", _dirtyRects.size()); - if (_dirtyRects.size() == 0 && _dirtyOverlayRects.size() == 0 && !_mouseDirty) return; + //printf("updateScreen(): %i dirty rects.\n", _dirtyRects.size()); + internUpdateScreen(); _mouseDirty = false; _fullScreenIsDirty = false; @@ -306,31 +309,33 @@ void OSystem_IPHONE::clearOverlay() { dirtyFullOverlayScreen(); } -void OSystem_IPHONE::grabOverlay(OverlayColor *buf, int pitch) { +void OSystem_IPHONE::grabOverlay(void *buf, int pitch) { //printf("grabOverlay()\n"); int h = _videoContext->overlayHeight; + byte *dst = (byte *)buf; const byte *src = (const byte *)_videoContext->overlayTexture.getBasePtr(0, 0); do { - memcpy(buf, src, _videoContext->overlayWidth * sizeof(OverlayColor)); + memcpy(dst, src, _videoContext->overlayWidth * sizeof(uint16)); src += _videoContext->overlayTexture.pitch; - buf += pitch; + dst += pitch; } while (--h); } -void OSystem_IPHONE::copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h) { - //printf("copyRectToOverlay(buf, pitch=%i, x=%i, y=%i, w=%i, h=%i)\n", pitch, x, y, w, h); +void OSystem_IPHONE::copyRectToOverlay(const void *buf, int pitch, int x, int y, int w, int h) { + //printf("copyRectToOverlay(%p, pitch=%i, x=%i, y=%i, w=%i, h=%i)\n", (const void *)buf, pitch, x, y, w, h); + const byte *src = (const byte *)buf; //Clip the coordinates if (x < 0) { w += x; - buf -= x; + src -= x * sizeof(uint16); x = 0; } if (y < 0) { h += y; - buf -= y * pitch; + src -= y * pitch; y = 0; } @@ -348,9 +353,9 @@ void OSystem_IPHONE::copyRectToOverlay(const OverlayColor *buf, int pitch, int x } byte *dst = (byte *)_videoContext->overlayTexture.getBasePtr(x, y); - do { - memcpy(dst, buf, w * sizeof(OverlayColor)); - buf += pitch; + do { + memcpy(dst, src, w * sizeof(uint16)); + src += pitch; dst += _videoContext->overlayTexture.pitch; } while (--h); } @@ -364,6 +369,7 @@ int16 OSystem_IPHONE::getOverlayWidth() { } bool OSystem_IPHONE::showMouse(bool visible) { + //printf("showMouse(%d)\n", visible); bool last = _videoContext->mouseIsVisible; _videoContext->mouseIsVisible = visible; _mouseDirty = true; @@ -372,7 +378,7 @@ bool OSystem_IPHONE::showMouse(bool visible) { } void OSystem_IPHONE::warpMouse(int x, int y) { - //printf("warpMouse()\n"); + //printf("warpMouse(%d, %d)\n", x, y); _videoContext->mouseX = x; _videoContext->mouseY = y; [g_iPhoneViewInstance performSelectorOnMainThread:@selector(notifyMouseMove) withObject:nil waitUntilDone: YES]; @@ -395,8 +401,8 @@ void OSystem_IPHONE::dirtyFullOverlayScreen() { } } -void OSystem_IPHONE::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format) { - //printf("setMouseCursor(%i, %i, scale %u)\n", hotspotX, hotspotY, cursorTargetScale); +void OSystem_IPHONE::setMouseCursor(const void *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, bool dontScale, const Graphics::PixelFormat *format) { + //printf("setMouseCursor(%p, %u, %u, %i, %i, %u, %d, %p)\n", (const void *)buf, w, h, hotspotX, hotspotY, keycolor, dontScale, (const void *)format); const Graphics::PixelFormat pixelFormat = format ? *format : Graphics::PixelFormat::createFormatCLUT8(); #if 0 @@ -424,11 +430,12 @@ void OSystem_IPHONE::setMouseCursor(const byte *buf, uint w, uint h, int hotspot } void OSystem_IPHONE::setCursorPalette(const byte *colors, uint start, uint num) { + //printf("setCursorPalette(%p, %u, %u)\n", (const void *)colors, start, num); assert(start + num <= 256); for (uint i = start; i < start + num; ++i, colors += 3) _mouseCursorPalette[i] = Graphics::RGBToColor<Graphics::ColorMasks<5551> >(colors[0], colors[1], colors[2]); - + // FIXME: This is just stupid, our client code seems to assume that this // automatically enables the cursor palette. _mouseCursorPaletteEnabled = true; diff --git a/backends/platform/maemo/debian/changelog b/backends/platform/maemo/debian/changelog index 8a9d8ee3c3..ea44574e96 100644 --- a/backends/platform/maemo/debian/changelog +++ b/backends/platform/maemo/debian/changelog @@ -1,8 +1,20 @@ -scummvm (1.5.0~git) unstable; urgency=low +scummvm (1.6.0~git) unstable; urgency=low * Development snapshot - -- Tarek Soliman <tsoliman@scummvm.org> Tue, 15 Nov 2011 14:56:57 -0600 + -- Tarek Soliman <tsoliman@scummvm.org> Tue, 10 Jul 2012 23:02:00 -0500 + +scummvm (1.5.0) unstable; urgency=low + + * 1.5.0 release + + -- Tarek Soliman <tsoliman@scummvm.org> Fri, 20 Jul 2012 14:48:44 -0500 + +scummvm (1.4.1) unstable; urgency=low + + * 1.4.1 release + + -- Tarek Soliman <tsoliman@scummvm.org> Wed, 11 Jan 2012 17:17:26 -0600 scummvm (1.4.0) unstable; urgency=low diff --git a/backends/platform/maemo/debian/control b/backends/platform/maemo/debian/control index 6e1dfe2fd4..bdaccd2359 100644 --- a/backends/platform/maemo/debian/control +++ b/backends/platform/maemo/debian/control @@ -2,7 +2,7 @@ Source: scummvm Section: user/games Priority: optional Maintainer: Tarek Soliman <tsoliman@scummvm.org> -Build-Depends: debhelper (>> 4.0.0), libsdl1.2-dev, libmad0-dev, libasound2-dev, libvorbisidec-dev, libmpeg2-4-dev, libflac-dev (>= 1.1.2), libz-dev, quilt +Build-Depends: debhelper (>> 4.0.0), libsdl1.2-dev, libmad0-dev, libasound2-dev, libvorbisidec-dev, libmpeg2-4-dev, libflac-dev (>= 1.1.2), libfreetype6-dev, libz-dev, quilt Standards-Version: 3.6.1.1 Package: scummvm diff --git a/backends/platform/maemo/debian/rules b/backends/platform/maemo/debian/rules index 64add08de8..c713403876 100755 --- a/backends/platform/maemo/debian/rules +++ b/backends/platform/maemo/debian/rules @@ -47,10 +47,10 @@ install: build install -m0644 gui/themes/scummclassic.zip gui/themes/scummmodern.zip debian/scummvm/opt/scummvm/share install -m0644 backends/vkeybd/packs/vkeybd_default.zip debian/scummvm/opt/scummvm/share # for optified version we can also add engine datafiles - install -m0644 dists/engine-data/drascula.dat dists/engine-data/hugo.dat dists/engine-data/kyra.dat dists/engine-data/lure.dat dists/engine-data/queen.tbl dists/engine-data/sky.cpt dists/engine-data/teenagent.dat dists/engine-data/toon.dat debian/scummvm/opt/scummvm/share + install -m0644 dists/engine-data/drascula.dat dists/engine-data/hugo.dat dists/engine-data/kyra.dat dists/engine-data/lure.dat dists/engine-data/queen.tbl dists/engine-data/sky.cpt dists/engine-data/teenagent.dat dists/engine-data/tony.dat dists/engine-data/toon.dat debian/scummvm/opt/scummvm/share install -m0644 -d debian/scummvm/usr/share/doc/scummvm - install -m0644 NEWS README COPYRIGHT debian/scummvm/usr/share/doc/scummvm + install -m0644 AUTHORS COPYING COPYING.BSD COPYING.FREEFONT COPYING.LGPL COPYRIGHT NEWS README debian/scummvm/usr/share/doc/scummvm binary: binary-arch binary-arch: build install diff --git a/backends/platform/maemo/maemo.cpp b/backends/platform/maemo/maemo.cpp index e296d4787c..6bd229177b 100644 --- a/backends/platform/maemo/maemo.cpp +++ b/backends/platform/maemo/maemo.cpp @@ -43,6 +43,7 @@ namespace Maemo { OSystem_SDL_Maemo::OSystem_SDL_Maemo() : + _eventObserver(0), OSystem_POSIX() { } @@ -84,6 +85,9 @@ static void registerDefaultKeyBindings(Common::KeymapperDefaultBindings *_keymap #endif void OSystem_SDL_Maemo::initBackend() { + ConfMan.registerDefault("fullscreen", true); + ConfMan.registerDefault("aspect_ratio", true); + // Create the events manager if (_eventSource == 0) _eventSource = new MaemoSdlEventSource(); @@ -180,6 +184,7 @@ void OSystem_SDL_Maemo::setupIcon() { // http://bugzilla.libsdl.org/show_bug.cgi?id=586 } +#ifdef ENABLE_KEYMAPPER static const Common::KeyTableEntry maemoKeys[] = { // Function keys {"MENU", Common::KEYCODE_F11, 0, "Menu", false}, @@ -191,7 +196,6 @@ static const Common::KeyTableEntry maemoKeys[] = { {0, Common::KEYCODE_INVALID, 0, 0, false} }; -#ifdef ENABLE_KEYMAPPER Common::HardwareInputSet *OSystem_SDL_Maemo::getHardwareInputSet() { return new Common::HardwareInputSet(true, maemoKeys); } diff --git a/backends/platform/n64/framfs_save_manager.h b/backends/platform/n64/framfs_save_manager.h index da553e423a..0a88c8666b 100644 --- a/backends/platform/n64/framfs_save_manager.h +++ b/backends/platform/n64/framfs_save_manager.h @@ -100,10 +100,10 @@ public: class FRAMSaveManager : public Common::SaveFileManager { public: - virtual Common::OutSaveFile *openForSaving(const Common::String &filename) { + virtual Common::OutSaveFile *openForSaving(const Common::String &filename, bool compress = true) { OutFRAMSave *s = new OutFRAMSave(filename.c_str()); if (!s->err()) { - return Common::wrapCompressedWriteStream(s); + return compress ? Common::wrapCompressedWriteStream(s) : s; } else { delete s; return 0; diff --git a/backends/platform/n64/osys_n64.h b/backends/platform/n64/osys_n64.h index 4788beb1ca..249f72d8fc 100644 --- a/backends/platform/n64/osys_n64.h +++ b/backends/platform/n64/osys_n64.h @@ -81,7 +81,7 @@ protected: uint16 *_offscreen_hic; // Offscreen converted to 16bit surface uint8 *_offscreen_pal; // Offscreen with palette indexes - OverlayColor *_overlayBuffer; // Offscreen for the overlay (16 bit) + uint16 *_overlayBuffer; // Offscreen for the overlay (16 bit) uint16 *_screenPalette; // Array for palette entries (256 colors max) @@ -162,7 +162,7 @@ protected: virtual void grabPalette(byte *colors, uint start, uint num); public: - virtual void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h); + virtual void copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h); virtual void updateScreen(); virtual Graphics::Surface *lockScreen(); virtual void unlockScreen(); @@ -171,8 +171,8 @@ public: virtual void showOverlay(); virtual void hideOverlay(); virtual void clearOverlay(); - virtual void grabOverlay(OverlayColor *buf, int pitch); - virtual void copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h); + virtual void grabOverlay(void *buf, int pitch); + virtual void copyRectToOverlay(const void *buf, int pitch, int x, int y, int w, int h); virtual int16 getOverlayHeight(); virtual int16 getOverlayWidth(); virtual Graphics::PixelFormat getOverlayFormat() const { @@ -182,7 +182,7 @@ public: virtual bool showMouse(bool visible); virtual void warpMouse(int x, int y); - virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format); + virtual void setMouseCursor(const void *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, bool dontScale, const Graphics::PixelFormat *format); virtual void setCursorPalette(const byte *colors, uint start, uint num); virtual bool pollEvent(Common::Event &event); diff --git a/backends/platform/n64/osys_n64_base.cpp b/backends/platform/n64/osys_n64_base.cpp index c3adb9691c..7d6f8f0b5c 100644 --- a/backends/platform/n64/osys_n64_base.cpp +++ b/backends/platform/n64/osys_n64_base.cpp @@ -95,7 +95,7 @@ OSystem_N64::OSystem_N64() { // Allocate memory for offscreen buffers _offscreen_hic = (uint16 *)memalign(8, _screenWidth * _screenHeight * 2); _offscreen_pal = (uint8 *)memalign(8, _screenWidth * _screenHeight); - _overlayBuffer = (uint16 *)memalign(8, _overlayWidth * _overlayHeight * sizeof(OverlayColor)); + _overlayBuffer = (uint16 *)memalign(8, _overlayWidth * _overlayHeight * sizeof(uint16)); _cursor_pal = NULL; _cursor_hic = NULL; @@ -108,7 +108,7 @@ OSystem_N64::OSystem_N64() { // Clean offscreen buffers memset(_offscreen_hic, 0, _screenWidth * _screenHeight * 2); memset(_offscreen_pal, 0, _screenWidth * _screenHeight); - memset(_overlayBuffer, 0, _overlayWidth * _overlayHeight * sizeof(OverlayColor)); + memset(_overlayBuffer, 0, _overlayWidth * _overlayHeight * sizeof(uint16)); // Default graphic mode _graphicMode = OVERS_NTSC_340X240; @@ -442,17 +442,18 @@ void OSystem_N64::setCursorPalette(const byte *colors, uint start, uint num) { _dirtyOffscreen = true; } -void OSystem_N64::copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h) { +void OSystem_N64::copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h) { //Clip the coordinates + const byte *src = (const byte *)buf; if (x < 0) { w += x; - buf -= x; + src -= x; x = 0; } if (y < 0) { h += y; - buf -= y * pitch; + src -= y * pitch; y = 0; } @@ -472,14 +473,14 @@ void OSystem_N64::copyRectToScreen(const byte *buf, int pitch, int x, int y, int do { for (int hor = 0; hor < w; hor++) { - if (dst_pal[hor] != buf[hor]) { - uint16 color = _screenPalette[buf[hor]]; + if (dst_pal[hor] != src[hor]) { + uint16 color = _screenPalette[src[hor]]; dst_hicol[hor] = color; // Save image converted to 16-bit - dst_pal[hor] = buf[hor]; // Save palettized display + dst_pal[hor] = src[hor]; // Save palettized display } } - buf += pitch; + src += pitch; dst_pal += _screenWidth; dst_hicol += _screenWidth; } while (--h); @@ -666,7 +667,7 @@ void OSystem_N64::hideOverlay() { } void OSystem_N64::clearOverlay() { - memset(_overlayBuffer, 0, _overlayWidth * _overlayHeight * sizeof(OverlayColor)); + memset(_overlayBuffer, 0, _overlayWidth * _overlayHeight * sizeof(uint16)); uint8 skip_lines = (_screenHeight - _gameHeight) / 4; uint8 skip_pixels = (_screenWidth - _gameWidth) / 2; // Center horizontally the image @@ -682,28 +683,30 @@ void OSystem_N64::clearOverlay() { _dirtyOffscreen = true; } -void OSystem_N64::grabOverlay(OverlayColor *buf, int pitch) { +void OSystem_N64::grabOverlay(void *buf, int pitch) { int h = _overlayHeight; - OverlayColor *src = _overlayBuffer; + uint16 *src = _overlayBuffer; + byte *dst = (byte *)buf; do { - memcpy(buf, src, _overlayWidth * sizeof(OverlayColor)); + memcpy(dst, src, _overlayWidth * sizeof(uint16)); src += _overlayWidth; - buf += pitch; + dst += pitch; } while (--h); } -void OSystem_N64::copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h) { +void OSystem_N64::copyRectToOverlay(const void *buf, int pitch, int x, int y, int w, int h) { + const byte *src = (const byte *)buf; //Clip the coordinates if (x < 0) { w += x; - buf -= x; + src -= x * sizeof(uint16); x = 0; } if (y < 0) { h += y; - buf -= y * pitch; + src -= y * pitch; y = 0; } @@ -719,14 +722,14 @@ void OSystem_N64::copyRectToOverlay(const OverlayColor *buf, int pitch, int x, i return; - OverlayColor *dst = _overlayBuffer + (y * _overlayWidth + x); + uint16 *dst = _overlayBuffer + (y * _overlayWidth + x); - if (_overlayWidth == pitch && pitch == w) { - memcpy(dst, buf, h * w * sizeof(OverlayColor)); + if (_overlayWidth == w && pitch == _overlayWidth * sizeof(uint16)) { + memcpy(dst, src, h * pitch); } else { do { - memcpy(dst, buf, w * sizeof(OverlayColor)); - buf += pitch; + memcpy(dst, src, w * sizeof(uint16)); + src += pitch; dst += _overlayWidth; } while (--h); } @@ -773,7 +776,7 @@ void OSystem_N64::warpMouse(int x, int y) { _dirtyOffscreen = true; } -void OSystem_N64::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format) { +void OSystem_N64::setMouseCursor(const void *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, bool dontScale, const Graphics::PixelFormat *format) { if (!w || !h) return; _mouseHotspotX = hotspotX; @@ -866,6 +869,7 @@ void OSystem_N64::getTimeAndDate(TimeDate &t) const { t.tm_mday = 1; t.tm_mon = 0; t.tm_year = 110; + t.tm_wday = 0; return; } diff --git a/backends/platform/n64/pakfs_save_manager.h b/backends/platform/n64/pakfs_save_manager.h index e0fcbc1e2d..6e67fb0f5f 100644 --- a/backends/platform/n64/pakfs_save_manager.h +++ b/backends/platform/n64/pakfs_save_manager.h @@ -101,10 +101,10 @@ public: class PAKSaveManager : public Common::SaveFileManager { public: - virtual Common::OutSaveFile *openForSaving(const Common::String &filename) { + virtual Common::OutSaveFile *openForSaving(const Common::String &filename, bool compress = true) { OutPAKSave *s = new OutPAKSave(filename.c_str()); if (!s->err()) { - return Common::wrapCompressedWriteStream(s); + return compress ? Common::wrapCompressedWriteStream(s) : s; } else { delete s; return NULL; diff --git a/backends/platform/openpandora/module.mk b/backends/platform/openpandora/module.mk index 5bd568e1c4..5bd568e1c4 100755..100644 --- a/backends/platform/openpandora/module.mk +++ b/backends/platform/openpandora/module.mk diff --git a/backends/platform/openpandora/op-backend.cpp b/backends/platform/openpandora/op-backend.cpp index dcec387f97..354aa24b24 100644 --- a/backends/platform/openpandora/op-backend.cpp +++ b/backends/platform/openpandora/op-backend.cpp @@ -54,53 +54,15 @@ /* Dump console info to files. */ #define DUMP_STDOUT -static SDL_Cursor *hiddenCursor; - OSystem_OP::OSystem_OP() : OSystem_POSIX() { } -//static Uint32 timer_handler(Uint32 interval, void *param) { -// ((DefaultTimerManager *)param)->handler(); -// return interval; -//} - void OSystem_OP::initBackend() { assert(!_inited); - // Create the events manager - if (_eventSource == 0) - _eventSource = new OPEventSource(); - - // Create the graphics manager - if (_graphicsManager == 0) { - _graphicsManager = new OPGraphicsManager(_eventSource); - } - -// int joystick_num = ConfMan.getInt("joystick_num"); -// uint32 sdlFlags = SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER; -// -// if (ConfMan.hasKey("disable_sdl_parachute")) -// sdlFlags |= SDL_INIT_NOPARACHUTE; -// -// if (joystick_num > -1) -// sdlFlags |= SDL_INIT_JOYSTICK; -// -// if (SDL_Init(sdlFlags) == -1) { -// error("Could not initialize SDL: %s", SDL_GetError()); -// } -// - - // Create the mixer manager -// if (_mixer == 0) { -// _mixerManager = new DoubleBufferSDLMixerManager(); - - // Setup and start mixer -// _mixerManager->init(); -// } - /* Setup default save path to be workingdir/saves */ char savePath[PATH_MAX+1]; @@ -179,7 +141,14 @@ void OSystem_OP::initBackend() { /* Make sure SDL knows that we have a joystick we want to use. */ ConfMan.setInt("joystick_num", 0); -// _graphicsMutex = createMutex(); + // Create the events manager + if (_eventSource == 0) + _eventSource = new OPEventSource(); + + // Create the graphics manager + if (_graphicsManager == 0) { + _graphicsManager = new OPGraphicsManager(_eventSource); + } /* Pass to POSIX method to do the heavy lifting */ OSystem_POSIX::initBackend(); @@ -187,24 +156,6 @@ void OSystem_OP::initBackend() { _inited = true; } -// enable joystick -// if (joystick_num > -1 && SDL_NumJoysticks() > 0) { -// printf("Using joystick: %s\n", SDL_JoystickName(0)); -// _joystick = SDL_JoystickOpen(joystick_num); -// } -// -// setupMixer(); - -// Note: 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. -// However, not all our code is prepared for that, so we can't just -// switch. Still, it's a potential future change to keep in mind. -// _timer = new DefaultTimerManager(); -// _timerID = SDL_AddTimer(10, &timer_handler, _timer); - void OSystem_OP::initSDL() { // Check if SDL has not been initialized if (!_initedSDL) { @@ -217,38 +168,7 @@ void OSystem_OP::initSDL() { if (SDL_Init(sdlFlags) == -1) error("Could not initialize SDL: %s", SDL_GetError()); - uint8_t hiddenCursorData = 0; - - hiddenCursor = SDL_CreateCursor(&hiddenCursorData, &hiddenCursorData, 8, 1, 0, 0); - - /* On the OpenPandora we need to work around an SDL assumption that - returns relative mouse coordinates when you get to the screen - edges using the touchscreen. The workaround is to set a blank - SDL cursor and not disable it (Hackish I know). - - The root issues likes in the Windows Manager GRAB code in SDL. - That is why the issue is not seen on framebuffer devices like the - GP2X (there is no X window manager ;)). - */ - SDL_ShowCursor(SDL_ENABLE); - SDL_SetCursor(hiddenCursor); - SDL_EnableUNICODE(1); - -// memset(&_oldVideoMode, 0, sizeof(_oldVideoMode)); -// memset(&_videoMode, 0, sizeof(_videoMode)); -// memset(&_transactionDetails, 0, sizeof(_transactionDetails)); - -// _videoMode.mode = GFX_DOUBLESIZE; -// _videoMode.scaleFactor = 2; -// _videoMode.aspectRatioCorrection = ConfMan.getBool("aspect_ratio"); -// _scalerProc = Normal2x; -// _scalerType = 0; - -// _videoMode.fullscreen = true; - _initedSDL = true; - -// OSystem_POSIX::initSDL(); } } @@ -275,8 +195,6 @@ void OSystem_OP::addSysArchivesToSearchSet(Common::SearchSet &s, int priority) { void OSystem_OP::quit() { - SDL_FreeCursor(hiddenCursor); - #ifdef DUMP_STDOUT printf("%s\n", "Debug: STDOUT and STDERR text files closed."); fclose(stdout); diff --git a/backends/platform/openpandora/op-bundle.mk b/backends/platform/openpandora/op-bundle.mk index 284a0497a8..284a0497a8 100755..100644 --- a/backends/platform/openpandora/op-bundle.mk +++ b/backends/platform/openpandora/op-bundle.mk diff --git a/backends/platform/openpandora/op-options.cpp b/backends/platform/openpandora/op-options.cpp index 58f0fb7188..005a76b76c 100644 --- a/backends/platform/openpandora/op-options.cpp +++ b/backends/platform/openpandora/op-options.cpp @@ -33,7 +33,8 @@ enum { /* Touchscreen TapMode */ TAPMODE_LEFT = 0, TAPMODE_RIGHT = 1, - TAPMODE_HOVER = 2 + TAPMODE_HOVER = 2, + TAPMODE_HOVER_DPAD = 3 }; int tapmodeLevel = TAPMODE_LEFT; @@ -44,6 +45,8 @@ void ToggleTapMode() { } else if (tapmodeLevel == TAPMODE_RIGHT) { tapmodeLevel = TAPMODE_HOVER; } else if (tapmodeLevel == TAPMODE_HOVER) { + tapmodeLevel = TAPMODE_HOVER_DPAD; + } else if (tapmodeLevel == TAPMODE_HOVER_DPAD) { tapmodeLevel = TAPMODE_LEFT; } else { tapmodeLevel = TAPMODE_LEFT; diff --git a/backends/platform/openpandora/op-sdl.h b/backends/platform/openpandora/op-sdl.h index 8cccbb5f86..1eddad5c4a 100644 --- a/backends/platform/openpandora/op-sdl.h +++ b/backends/platform/openpandora/op-sdl.h @@ -31,8 +31,6 @@ #include "backends/events/openpandora/op-events.h" #include "backends/graphics/openpandora/op-graphics.h" -//#define MIXER_DOUBLE_BUFFERING 1 - #ifndef PATH_MAX #define PATH_MAX 255 #endif diff --git a/backends/platform/ps2/Gs2dScreen.cpp b/backends/platform/ps2/Gs2dScreen.cpp index 8df6198c38..f93166ef67 100644 --- a/backends/platform/ps2/Gs2dScreen.cpp +++ b/backends/platform/ps2/Gs2dScreen.cpp @@ -564,7 +564,7 @@ void Gs2dScreen::clearPrintfOverlay(void) { free(tmpBuf); } -void Gs2dScreen::copyOverlayRect(const uint16 *buf, uint16 pitch, uint16 x, uint16 y, uint16 w, uint16 h) { +void Gs2dScreen::copyOverlayRect(const byte *buf, uint16 pitch, uint16 x, uint16 y, uint16 w, uint16 h) { WaitSema(g_DmacSema); // warning("_overlayBuf [dst] = %x", _overlayBuf); @@ -601,7 +601,7 @@ void Gs2dScreen::clearOverlay(void) { SignalSema(g_DmacSema); } -void Gs2dScreen::grabOverlay(uint16 *buf, uint16 pitch) { +void Gs2dScreen::grabOverlay(byte *buf, uint16 pitch) { uint16 *src = _overlayBuf; for (uint32 cnt = 0; cnt < _height; cnt++) { memcpy(buf, src, _width * 2); diff --git a/backends/platform/ps2/Gs2dScreen.h b/backends/platform/ps2/Gs2dScreen.h index 4fbb3fdef8..005dabc809 100644 --- a/backends/platform/ps2/Gs2dScreen.h +++ b/backends/platform/ps2/Gs2dScreen.h @@ -62,8 +62,8 @@ public: void updateScreen(void); void grabPalette(uint8 *pal, uint8 start, uint16 num); //- overlay routines - void copyOverlayRect(const uint16 *buf, uint16 pitch, uint16 x, uint16 y, uint16 w, uint16 h); - void grabOverlay(uint16 *buf, uint16 pitch); + void copyOverlayRect(const byte *buf, uint16 pitch, uint16 x, uint16 y, uint16 w, uint16 h); + void grabOverlay(byte *buf, uint16 pitch); void clearOverlay(void); void showOverlay(void); void hideOverlay(void); diff --git a/backends/platform/ps2/icon.h b/backends/platform/ps2/icon.h index bc614bf70b..3ad19910d3 100644 --- a/backends/platform/ps2/icon.h +++ b/backends/platform/ps2/icon.h @@ -22,10 +22,6 @@ class PS2Icon { public: - PS2Icon() {}; - - ~PS2Icon() {}; - uint16 decompressData(uint16 **data); void setup(mcIcon *icon); }; diff --git a/backends/platform/ps2/ps2time.cpp b/backends/platform/ps2/ps2time.cpp index 2c3275b2b2..1cddd230a0 100644 --- a/backends/platform/ps2/ps2time.cpp +++ b/backends/platform/ps2/ps2time.cpp @@ -105,8 +105,14 @@ void OSystem_PS2::readRtcTime(void) { g_day, g_month, g_year + 2000); } -void OSystem_PS2::getTimeAndDate(TimeDate &t) const { +// Tomohiko Sakamoto's 1993 algorithm for any Gregorian date +static int dayOfWeek(int y, int m, int d) { + static const int t[] = { 0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4 }; + y -= m < 3; + return (y + y / 4 - y / 100 + y / 400 + t[m - 1] + d) % 7; +} +void OSystem_PS2::getTimeAndDate(TimeDate &t) const { uint32 currentSecs = g_timeSecs + (msecCount - g_lastTimeCheck) / 1000; if (currentSecs >= SECONDS_PER_DAY) { buildNewDate(+1); @@ -120,4 +126,5 @@ void OSystem_PS2::getTimeAndDate(TimeDate &t) const { t.tm_year = g_year + 100; t.tm_mday = g_day; t.tm_mon = g_month - 1; + t.tm_wday = dayOfWeek(t.tm_year, t.tm_mon, t.tm_mday); } diff --git a/backends/platform/ps2/savefilemgr.cpp b/backends/platform/ps2/savefilemgr.cpp index 421edc3e2e..46af42e193 100644 --- a/backends/platform/ps2/savefilemgr.cpp +++ b/backends/platform/ps2/savefilemgr.cpp @@ -145,7 +145,7 @@ Common::InSaveFile *Ps2SaveFileManager::openForLoading(const Common::String &fil return Common::wrapCompressedReadStream(sf); } -Common::OutSaveFile *Ps2SaveFileManager::openForSaving(const Common::String &filename) { +Common::OutSaveFile *Ps2SaveFileManager::openForSaving(const Common::String &filename, bool compress) { Common::FSNode savePath(ConfMan.get("savepath")); // TODO: is this fast? Common::WriteStream *sf; @@ -193,7 +193,7 @@ Common::OutSaveFile *Ps2SaveFileManager::openForSaving(const Common::String &fil } _screen->wantAnim(false); - return Common::wrapCompressedWriteStream(sf); + return compress ? Common::wrapCompressedWriteStream(sf) : sf; } bool Ps2SaveFileManager::removeSavefile(const Common::String &filename) { diff --git a/backends/platform/ps2/savefilemgr.h b/backends/platform/ps2/savefilemgr.h index a25fb063ae..163706eace 100644 --- a/backends/platform/ps2/savefilemgr.h +++ b/backends/platform/ps2/savefilemgr.h @@ -35,7 +35,7 @@ public: virtual ~Ps2SaveFileManager(); virtual Common::InSaveFile *openForLoading(const Common::String &filename); - virtual Common::OutSaveFile *openForSaving(const Common::String &filename); + virtual Common::OutSaveFile *openForSaving(const Common::String &filename, bool compress = true); virtual Common::StringArray listSavefiles(const Common::String &pattern); virtual bool removeSavefile(const Common::String &filename); diff --git a/backends/platform/ps2/systemps2.cpp b/backends/platform/ps2/systemps2.cpp index d4e993da63..5628658381 100644 --- a/backends/platform/ps2/systemps2.cpp +++ b/backends/platform/ps2/systemps2.cpp @@ -554,7 +554,7 @@ void OSystem_PS2::grabPalette(byte *colors, uint start, uint num) { _screen->grabPalette(colors, (uint8)start, (uint16)num); } -void OSystem_PS2::copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h) { +void OSystem_PS2::copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h) { _screen->copyScreenRect((const uint8*)buf, pitch, x, y, w, h); } @@ -618,8 +618,8 @@ void OSystem_PS2::warpMouse(int x, int y) { _screen->setMouseXy(x, y); } -void OSystem_PS2::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format) { - _screen->setMouseOverlay(buf, w, h, hotspot_x, hotspot_y, keycolor); +void OSystem_PS2::setMouseCursor(const void *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, bool dontScale, const Graphics::PixelFormat *format) { + _screen->setMouseOverlay((const byte *)buf, w, h, hotspot_x, hotspot_y, keycolor); } void OSystem_PS2::showOverlay(void) { @@ -634,12 +634,12 @@ void OSystem_PS2::clearOverlay(void) { _screen->clearOverlay(); } -void OSystem_PS2::grabOverlay(OverlayColor *buf, int pitch) { - _screen->grabOverlay((uint16 *)buf, (uint16)pitch); +void OSystem_PS2::grabOverlay(void *buf, int pitch) { + _screen->grabOverlay((byte *)buf, (uint16)pitch); } -void OSystem_PS2::copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h) { - _screen->copyOverlayRect((const uint16*)buf, (uint16)pitch, (uint16)x, (uint16)y, (uint16)w, (uint16)h); +void OSystem_PS2::copyRectToOverlay(const void *buf, int pitch, int x, int y, int w, int h) { + _screen->copyOverlayRect((const byte *)buf, (uint16)pitch, (uint16)x, (uint16)y, (uint16)w, (uint16)h); } Graphics::PixelFormat OSystem_PS2::getOverlayFormat(void) const { diff --git a/backends/platform/ps2/systemps2.h b/backends/platform/ps2/systemps2.h index 3a0e247737..99482d4da4 100644 --- a/backends/platform/ps2/systemps2.h +++ b/backends/platform/ps2/systemps2.h @@ -62,7 +62,7 @@ protected: virtual void grabPalette(byte *colors, uint start, uint num); public: - virtual void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h); + virtual void copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h); virtual void setShakePos(int shakeOffset); virtual Graphics::Surface *lockScreen(); virtual void unlockScreen(); @@ -72,15 +72,15 @@ public: virtual void showOverlay(); virtual void hideOverlay(); virtual void clearOverlay(); - virtual void grabOverlay(OverlayColor *buf, int pitch); - virtual void copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h); + virtual void grabOverlay(void *buf, int pitch); + virtual void copyRectToOverlay(const void *buf, int pitch, int x, int y, int w, int h); virtual int16 getOverlayWidth(void); virtual int16 getOverlayHeight(void); virtual bool showMouse(bool visible); virtual void warpMouse(int x, int y); - virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, int cursorTargetScale = 1, const Graphics::PixelFormat *format = 0); + virtual void setMouseCursor(const void *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, bool dontScale = false, const Graphics::PixelFormat *format = 0); virtual uint32 getMillis(); virtual void delayMillis(uint msecs); diff --git a/backends/platform/psp/README.PSP b/backends/platform/psp/README.PSP index bc0bd35a6e..969459dc5b 100644 --- a/backends/platform/psp/README.PSP +++ b/backends/platform/psp/README.PSP @@ -1,4 +1,4 @@ -ScummVM-PSP 1.5.0git README +ScummVM-PSP 1.6.0git README ============================================================================== Installation diff --git a/backends/platform/psp/default_display_client.cpp b/backends/platform/psp/default_display_client.cpp index 2ee7ff5b74..bc252144fa 100644 --- a/backends/platform/psp/default_display_client.cpp +++ b/backends/platform/psp/default_display_client.cpp @@ -123,15 +123,15 @@ void Overlay::setSize(uint32 width, uint32 height) { _renderer.setDrawWholeBuffer(); // We need to let the renderer know how much to draw } -void Overlay::copyToArray(OverlayColor *buf, int pitch) { +void Overlay::copyToArray(void *buf, int pitch) { DEBUG_ENTER_FUNC(); - _buffer.copyToArray((byte *)buf, pitch * sizeof(OverlayColor)); // Change to bytes + _buffer.copyToArray((byte *)buf, pitch); // Change to bytes } -void Overlay::copyFromRect(const OverlayColor *buf, int pitch, int x, int y, int w, int h) { +void Overlay::copyFromRect(const void *buf, int pitch, int x, int y, int w, int h) { DEBUG_ENTER_FUNC(); - _buffer.copyFromRect((byte *)buf, pitch * sizeof(OverlayColor), x, y, w, h); // Change to bytes + _buffer.copyFromRect((byte *)buf, pitch, x, y, w, h); // Change to bytes // debug //_buffer.print(0xFF); setDirty(); diff --git a/backends/platform/psp/default_display_client.h b/backends/platform/psp/default_display_client.h index e1cd8e7e72..95c52e2352 100644 --- a/backends/platform/psp/default_display_client.h +++ b/backends/platform/psp/default_display_client.h @@ -65,15 +65,12 @@ protected: */ class Overlay : public DefaultDisplayClient { public: - Overlay() {} - ~Overlay() {} - void init(); bool allocate(); void setBytesPerPixel(uint32 size); void setSize(uint32 width, uint32 height); - void copyToArray(OverlayColor *buf, int pitch); - void copyFromRect(const OverlayColor *buf, int pitch, int x, int y, int w, int h); + void copyToArray(void *buf, int pitch); + void copyFromRect(const void *buf, int pitch, int x, int y, int w, int h); }; /** @@ -85,7 +82,6 @@ public: memset(&_pixelFormat, 0, sizeof(_pixelFormat)); memset(&_frameBuffer, 0, sizeof(_frameBuffer)); } - ~Screen() {} void init(); bool allocate(); diff --git a/backends/platform/psp/display_manager.cpp b/backends/platform/psp/display_manager.cpp index 10a732b1e3..c2ff84c7f5 100644 --- a/backends/platform/psp/display_manager.cpp +++ b/backends/platform/psp/display_manager.cpp @@ -302,7 +302,7 @@ void DisplayManager::init() { // Init overlay since we never change the size _overlay->deallocate(); - _overlay->setBytesPerPixel(sizeof(OverlayColor)); + _overlay->setBytesPerPixel(sizeof(uint16)); _overlay->setSize(PSP_SCREEN_WIDTH, PSP_SCREEN_HEIGHT); _overlay->allocate(); } diff --git a/backends/platform/psp/osys_psp.cpp b/backends/platform/psp/osys_psp.cpp index 5fa5110684..fb8c1c60bf 100644 --- a/backends/platform/psp/osys_psp.cpp +++ b/backends/platform/psp/osys_psp.cpp @@ -204,11 +204,11 @@ void OSystem_PSP::setCursorPalette(const byte *colors, uint start, uint num) { _cursor.clearKeyColor(); // Do we need this? } -void OSystem_PSP::copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h) { +void OSystem_PSP::copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h) { DEBUG_ENTER_FUNC(); _displayManager.waitUntilRenderFinished(); _pendingUpdate = false; - _screen.copyFromRect(buf, pitch, x, y, w, h); + _screen.copyFromRect((const byte *)buf, pitch, x, y, w, h); } Graphics::Surface *OSystem_PSP::lockScreen() { @@ -260,12 +260,12 @@ void OSystem_PSP::clearOverlay() { _overlay.clearBuffer(); } -void OSystem_PSP::grabOverlay(OverlayColor *buf, int pitch) { +void OSystem_PSP::grabOverlay(void *buf, int pitch) { DEBUG_ENTER_FUNC(); _overlay.copyToArray(buf, pitch); } -void OSystem_PSP::copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h) { +void OSystem_PSP::copyRectToOverlay(const void *buf, int pitch, int x, int y, int w, int h) { DEBUG_ENTER_FUNC(); _displayManager.waitUntilRenderFinished(); _pendingUpdate = false; @@ -303,7 +303,7 @@ void OSystem_PSP::warpMouse(int x, int y) { _cursor.setXY(x, y); } -void OSystem_PSP::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format) { +void OSystem_PSP::setMouseCursor(const void *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, bool dontScale, const Graphics::PixelFormat *format) { DEBUG_ENTER_FUNC(); _displayManager.waitUntilRenderFinished(); _pendingUpdate = false; @@ -314,11 +314,13 @@ void OSystem_PSP::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, } _cursor.setKeyColor(keycolor); - _cursor.setCursorTargetScale(cursorTargetScale); + // TODO: The old target scale was saved but never used. Should the new + // "do not scale" logic be implemented? + //_cursor.setCursorTargetScale(cursorTargetScale); _cursor.setSizeAndScummvmPixelFormat(w, h, format); _cursor.setHotspot(hotspotX, hotspotY); _cursor.clearKeyColor(); - _cursor.copyFromArray(buf); + _cursor.copyFromArray((const byte *)buf); } bool OSystem_PSP::pollEvent(Common::Event &event) { @@ -444,6 +446,7 @@ void OSystem_PSP::getTimeAndDate(TimeDate &td) const { td.tm_mday = t.tm_mday; td.tm_mon = t.tm_mon; td.tm_year = t.tm_year; + td.tm_wday = t.tm_wday; } Common::String OSystem_PSP::getDefaultConfigFileName() { diff --git a/backends/platform/psp/osys_psp.h b/backends/platform/psp/osys_psp.h index e6b445e232..2afdabd0fc 100644 --- a/backends/platform/psp/osys_psp.h +++ b/backends/platform/psp/osys_psp.h @@ -99,7 +99,7 @@ public: void setCursorPalette(const byte *colors, uint start, uint num); // Screen related - void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h); + void copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h); Graphics::Surface *lockScreen(); void unlockScreen(); void updateScreen(); @@ -109,8 +109,8 @@ public: void showOverlay(); void hideOverlay(); void clearOverlay(); - void grabOverlay(OverlayColor *buf, int pitch); - void copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h); + void grabOverlay(void *buf, int pitch); + void copyRectToOverlay(const void *buf, int pitch, int x, int y, int w, int h); int16 getOverlayHeight(); int16 getOverlayWidth(); Graphics::PixelFormat getOverlayFormat() const { return Graphics::createPixelFormat<4444>(); } @@ -118,7 +118,7 @@ public: // Mouse related bool showMouse(bool visible); void warpMouse(int x, int y); - void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format); + void setMouseCursor(const void *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, bool dontScale, const Graphics::PixelFormat *format); // Events and input bool pollEvent(Common::Event &event); diff --git a/backends/platform/psp/psp_main.cpp b/backends/platform/psp/psp_main.cpp index f45000fea4..a83a5bae71 100644 --- a/backends/platform/psp/psp_main.cpp +++ b/backends/platform/psp/psp_main.cpp @@ -182,7 +182,7 @@ int main(void) { #endif /* unit/speed tests */ -#if defined (PSP_ENABLE_UNIT_TESTS) || defined (PSP_ENABLE_SPEED_TESTS) +#if defined(PSP_ENABLE_UNIT_TESTS) || defined(PSP_ENABLE_SPEED_TESTS) PSP_INFO_PRINT("running tests\n"); psp_tests(); sceKernelSleepThread(); // that's it. That's all we're doing diff --git a/backends/platform/psp/tests.cpp b/backends/platform/psp/tests.cpp index 4d326f30bd..5c5ebb7a80 100644 --- a/backends/platform/psp/tests.cpp +++ b/backends/platform/psp/tests.cpp @@ -25,7 +25,7 @@ #include "backends/platform/psp/tests.h" -#if defined (PSP_ENABLE_UNIT_TESTS) || defined (PSP_ENABLE_SPEED_TESTS) +#if defined(PSP_ENABLE_UNIT_TESTS) || defined(PSP_ENABLE_SPEED_TESTS) #include "common/scummsys.h" #include <pspiofilemgr_fcntl.h> @@ -729,4 +729,4 @@ void psp_tests() { #endif } -#endif /* (PSP_ENABLE_UNIT_TESTS) || defined (PSP_ENABLE_SPEED_TESTS) */ +#endif /* (PSP_ENABLE_UNIT_TESTS) || defined(PSP_ENABLE_SPEED_TESTS) */ diff --git a/backends/platform/psp/tests.h b/backends/platform/psp/tests.h index 9d158812f9..3779cb6bb2 100644 --- a/backends/platform/psp/tests.h +++ b/backends/platform/psp/tests.h @@ -26,7 +26,7 @@ //#define PSP_ENABLE_UNIT_TESTS // run unit tests //#define PSP_ENABLE_SPEED_TESTS // run speed tests -#if defined (PSP_ENABLE_UNIT_TESTS) || defined (PSP_ENABLE_SPEED_TESTS) +#if defined(PSP_ENABLE_UNIT_TESTS) || defined(PSP_ENABLE_SPEED_TESTS) void psp_tests(); #endif diff --git a/backends/platform/psp/trace.h b/backends/platform/psp/trace.h index dda258f2cb..e27d06d8d3 100644 --- a/backends/platform/psp/trace.h +++ b/backends/platform/psp/trace.h @@ -32,7 +32,7 @@ /* Choose to print to file/screen/both */ #ifdef __PSP_PRINT_TO_FILE__ #define __PSP_PRINT__(format,...) PspDebugTrace(false, format, ## __VA_ARGS__) -#elif defined __PSP_PRINT_TO_FILE_AND_SCREEN__ +#elif defined(__PSP_PRINT_TO_FILE_AND_SCREEN__) #define __PSP_PRINT__(format,...) PspDebugTrace(true, format, ## __VA_ARGS__) #else /* default - print to screen */ #define __PSP_PRINT__(format,...) fprintf(stderr, format, ## __VA_ARGS__) diff --git a/backends/platform/sdl/macosx/appmenu_osx.h b/backends/platform/sdl/macosx/appmenu_osx.h index 005414b789..005414b789 100755..100644 --- a/backends/platform/sdl/macosx/appmenu_osx.h +++ b/backends/platform/sdl/macosx/appmenu_osx.h diff --git a/backends/platform/sdl/macosx/appmenu_osx.mm b/backends/platform/sdl/macosx/appmenu_osx.mm index 97c7edba3e..97c7edba3e 100755..100644 --- a/backends/platform/sdl/macosx/appmenu_osx.mm +++ b/backends/platform/sdl/macosx/appmenu_osx.mm diff --git a/backends/platform/sdl/macosx/macosx.cpp b/backends/platform/sdl/macosx/macosx.cpp index 639bd980f6..fb76c111f2 100644 --- a/backends/platform/sdl/macosx/macosx.cpp +++ b/backends/platform/sdl/macosx/macosx.cpp @@ -156,7 +156,7 @@ Common::String OSystem_MacOSX::getSystemLanguage() const { } CFRelease(preferredLocalizations); } - + } // Falback to POSIX implementation return OSystem_POSIX::getSystemLanguage(); diff --git a/backends/platform/sdl/macosx/macosx.h b/backends/platform/sdl/macosx/macosx.h index 4837e643b3..d9cb28b973 100644 --- a/backends/platform/sdl/macosx/macosx.h +++ b/backends/platform/sdl/macosx/macosx.h @@ -32,7 +32,7 @@ public: virtual bool hasFeature(Feature f); virtual bool displayLogFile(); - + virtual Common::String getSystemLanguage() const; virtual void initBackend(); diff --git a/backends/platform/sdl/main.cpp b/backends/platform/sdl/main.cpp deleted file mode 100644 index 040028079d..0000000000 --- a/backends/platform/sdl/main.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/* 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. - * - */ - -#include "common/scummsys.h" - -// 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(POSIX) && \ - !defined(WIN32) && \ - !defined(MAEMO) && \ - !defined(__SYMBIAN32__) && \ - !defined(_WIN32_WCE) && \ - !defined(__amigaos4__) && \ - !defined(DINGUX) && \ - !defined(CAANOO) && \ - !defined(LINUXMOTO) && \ - !defined(SAMSUNGTV) && \ - !defined(PLAYSTATION3) && \ - !defined(OPENPANDORA) - -#include "backends/platform/sdl/sdl.h" -#include "backends/plugins/sdl/sdl-provider.h" -#include "base/main.h" - -int main(int argc, char *argv[]) { - - // Create our OSystem instance - g_system = new OSystem_SDL(); - assert(g_system); - - // Pre initialize the backend - ((OSystem_SDL *)g_system)->init(); - -#ifdef DYNAMIC_MODULES - PluginManager::instance().addPluginProvider(new SDLPluginProvider()); -#endif - - // Invoke the actual ScummVM main entry point: - int res = scummvm_main(argc, argv); - - // Free OSystem - delete (OSystem_SDL *)g_system; - - return res; -} - -#endif diff --git a/backends/platform/sdl/module.mk b/backends/platform/sdl/module.mk index 98a8265301..a17a326889 100644 --- a/backends/platform/sdl/module.mk +++ b/backends/platform/sdl/module.mk @@ -1,7 +1,6 @@ MODULE := backends/platform/sdl MODULE_OBJS := \ - main.o \ sdl.o ifdef POSIX diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp index 8dff5cec05..d54854352d 100644 --- a/backends/platform/sdl/sdl.cpp +++ b/backends/platform/sdl/sdl.cpp @@ -486,6 +486,7 @@ void OSystem_SDL::getTimeAndDate(TimeDate &td) const { td.tm_mday = t.tm_mday; td.tm_mon = t.tm_mon; td.tm_year = t.tm_year; + td.tm_wday = t.tm_wday; } Audio::Mixer *OSystem_SDL::getMixer() { diff --git a/backends/platform/symbian/src/ScummApp.cpp b/backends/platform/symbian/src/ScummApp.cpp index 405fb5c3c2..b952177f9a 100644 --- a/backends/platform/symbian/src/ScummApp.cpp +++ b/backends/platform/symbian/src/ScummApp.cpp @@ -24,7 +24,7 @@ #define _PAGESIZE_ 0x1000 -#if defined (__WINS__) && !defined (S60V3) && !defined (UIQ3) +#if defined(__WINS__) && !defined(S60V3) && !defined(UIQ3) extern "C" int _chkstk(int /*a*/) { _asm { push ecx @@ -62,7 +62,7 @@ _asm { #ifdef EPOC_AS_APP // this function is called automatically by the SymbianOS to deliver the new CApaApplication object -#if !defined (UIQ3) && !defined (S60V3) +#if !defined(UIQ3) && !defined(S60V3) EXPORT_C #endif CApaApplication* NewApplication() { @@ -70,7 +70,7 @@ CApaApplication* NewApplication() { return new CScummApp; } -#if defined (UIQ3) || defined (S60V3) +#if defined(UIQ3) || defined(S60V3) #include <eikstart.h> // E32Main() contains the program's start up code, the entry point for an EXE. GLDEF_C TInt E32Main() { @@ -80,7 +80,7 @@ GLDEF_C TInt E32Main() { #endif // EPOC_AS_APP -#if !defined (UIQ3) && !defined (S60V3) +#if !defined(UIQ3) && !defined(S60V3) GLDEF_C TInt E32Dll(TDllReason) { return KErrNone; } @@ -92,7 +92,7 @@ CScummApp::CScummApp() { CScummApp::~CScummApp() { } -#if defined (UIQ3) +#if defined(UIQ3) #include <scummvm.rsg> /** * Returns the resource id to be used to declare the views supported by this UIQ3 app diff --git a/backends/platform/symbian/src/ScummApp.h b/backends/platform/symbian/src/ScummApp.h index 0b9ebcdf53..00d03e6d7b 100644 --- a/backends/platform/symbian/src/ScummApp.h +++ b/backends/platform/symbian/src/ScummApp.h @@ -26,7 +26,7 @@ #include <e32base.h> #include <sdlapp.h> -#if defined (EPOC_AS_APP) && !defined (UIQ3) && !defined (S60V3) +#if defined(EPOC_AS_APP) && !defined(UIQ3) && !defined(S60V3) #include "ECompXL.h" #endif @@ -34,7 +34,7 @@ class CScummApp : public CSDLApp { public: CScummApp(); ~CScummApp(); -#if defined (UIQ3) +#if defined(UIQ3) /** * Returns the resource id to be used to declare the views supported by this UIQ3 app * @return TInt, resource id @@ -43,7 +43,7 @@ public: #endif TUid AppDllUid() const; void GetDataFolder(TDes& aDataFolder); -#if defined (EPOC_AS_APP) && !defined (UIQ3) && !defined (S60V3) +#if defined(EPOC_AS_APP) && !defined(UIQ3) && !defined(S60V3) TECompXL iECompXL; #endif }; diff --git a/backends/platform/symbian/src/SymbianActions.cpp b/backends/platform/symbian/src/SymbianActions.cpp index 5de386b1da..c47bd93772 100644 --- a/backends/platform/symbian/src/SymbianActions.cpp +++ b/backends/platform/symbian/src/SymbianActions.cpp @@ -58,9 +58,9 @@ const Common::String actionNames[] = { #ifdef UIQ static const int ACTIONS_DEFAULT[ACTION_LAST] = { SDLK_UP, SDLK_DOWN, SDLK_LEFT, SDLK_RIGHT, SDLK_F1, SDLK_F2, SDLK_F5, SDLK_PAGEDOWN, '9', 0, 0, SDLK_PAGEUP, 0, 0, 0, 0, 0, 0, 0}; -#elif defined (S60) +#elif defined(S60) const int ACTIONS_DEFAULT[ACTION_LAST] = { 0, 0, 0, 0, 0, 0, '*', '#', '9', 0, 0, 0, 0, 0, 0, 0, '0', 0, 0}; -#elif defined (S90) +#elif defined(S90) const int ACTIONS_DEFAULT[ACTION_LAST] = { SDLK_UP, SDLK_DOWN, SDLK_LEFT, SDLK_RIGHT, 0, 0, SDLK_MENU, SDLK_ESCAPE, 0, 0 , 0, 0, 0, 0, 0, 0, 0, 0 ,0}; #else const int ACTIONS_DEFAULT[ACTION_LAST] = { SDLK_UP, SDLK_DOWN, SDLK_LEFT, SDLK_RIGHT, SDLK_F1, SDLK_F2, SDLK_MENU, SDLK_ESCAPE, 0, 0, 0, 0, 0, 0, 0, 0, '1', 0 ,0}; diff --git a/backends/platform/symbian/src/portdefs.h b/backends/platform/symbian/src/portdefs.h index dd81080afe..1f9128a54f 100644 --- a/backends/platform/symbian/src/portdefs.h +++ b/backends/platform/symbian/src/portdefs.h @@ -125,7 +125,7 @@ typedef signed long int int32; PS2. http://gcc.gnu.org/ml/gcc-bugs/2004-01/msg01596.html might have found out the same problem there */ -#elif defined (__WINS__) // WINS +#elif defined(__WINS__) // WINS extern "C" int symbian_snprintf(char *text, size_t maxlen, const char *fmt, ...); extern "C" int symbian_vsnprintf(char *text, size_t maxlen, const char *fmt, va_list ap); #define snprintf(buf,len,args...) symbian_snprintf(buf,len,args) diff --git a/backends/platform/webos/webos.cpp b/backends/platform/webos/webos.cpp index 4ec153a7e9..fc18628235 100644 --- a/backends/platform/webos/webos.cpp +++ b/backends/platform/webos/webos.cpp @@ -45,24 +45,4 @@ void OSystem_SDL_WebOS::initBackend() { OSystem_SDL::initBackend(); } -/** - * Gets the original SDL hardware key set, adds WebOS specific keys and - * returns the new key set. - * - * @return The hardware key set with added webOS specific keys. - */ -#ifdef ENABLE_KEYMAPPER -HardwareInputSet *OSystem_SDL_WebOS::getHardwareInputSet() { - // Get the original SDL hardware key set - HardwareInputSet *inputSet = OSystem_SDL::getHardwareInputSet(); - - // Add WebOS specific keys - inputSet->addHardwareInput(new HardwareInput("FORWARD", - KeyState((KeyCode) 229, 229, 0), "Forward")); - - // Return the modified hardware key set - return inputSet; -} -#endif - #endif diff --git a/backends/platform/webos/webos.h b/backends/platform/webos/webos.h index 8dfa43239c..dda56a70da 100644 --- a/backends/platform/webos/webos.h +++ b/backends/platform/webos/webos.h @@ -31,9 +31,6 @@ public: OSystem_SDL_WebOS(); virtual void initBackend(); -#ifdef ENABLE_KEYMAPPER - virtual Common::HardwareInputSet *getHardwareInputSet(); -#endif }; #endif diff --git a/backends/platform/wii/osystem.cpp b/backends/platform/wii/osystem.cpp index 258a782cc4..22a6495f8f 100644 --- a/backends/platform/wii/osystem.cpp +++ b/backends/platform/wii/osystem.cpp @@ -39,7 +39,7 @@ OSystem_Wii::OSystem_Wii() : _startup_time(0), - _cursorScale(1), + _cursorDontScale(true), _cursorPaletteDisabled(true), _cursorPalette(NULL), _cursorPaletteDirty(false), @@ -269,6 +269,7 @@ void OSystem_Wii::getTimeAndDate(TimeDate &td) const { td.tm_mday = t.tm_mday; td.tm_mon = t.tm_mon; td.tm_year = t.tm_year; + td.tm_wday = t.tm_wday; } void OSystem_Wii::showOptionsDialog() { diff --git a/backends/platform/wii/osystem.h b/backends/platform/wii/osystem.h index 64197f913a..5d6998d0b6 100644 --- a/backends/platform/wii/osystem.h +++ b/backends/platform/wii/osystem.h @@ -56,7 +56,7 @@ class OSystem_Wii : public EventsBaseBackend, public PaletteManager { private: s64 _startup_time; - int _cursorScale; + bool _cursorDontScale; bool _cursorPaletteDisabled; u16 *_cursorPalette; bool _cursorPaletteDirty; @@ -72,7 +72,7 @@ private: bool _overlayVisible; u16 _overlayWidth, _overlayHeight; u32 _overlaySize; - OverlayColor *_overlayPixels; + uint16 *_overlayPixels; gfx_screen_coords_t _coordsOverlay; gfx_tex_t _texOverlay; bool _overlayDirty; @@ -167,7 +167,7 @@ protected: virtual void grabPalette(byte *colors, uint start, uint num); public: virtual void setCursorPalette(const byte *colors, uint start, uint num); - virtual void copyRectToScreen(const byte *buf, int pitch, int x, int y, + virtual void copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h); virtual void updateScreen(); virtual Graphics::Surface *lockScreen(); @@ -177,8 +177,8 @@ public: virtual void showOverlay(); virtual void hideOverlay(); virtual void clearOverlay(); - virtual void grabOverlay(OverlayColor *buf, int pitch); - virtual void copyRectToOverlay(const OverlayColor *buf, int pitch, + virtual void grabOverlay(void *buf, int pitch); + virtual void copyRectToOverlay(const void *buf, int pitch, int x, int y, int w, int h); virtual int16 getOverlayWidth(); virtual int16 getOverlayHeight(); @@ -187,9 +187,9 @@ public: virtual bool showMouse(bool visible); virtual void warpMouse(int x, int y); - virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, + virtual void setMouseCursor(const void *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, - int cursorTargetScale, + bool dontScale, const Graphics::PixelFormat *format); virtual bool pollEvent(Common::Event &event); diff --git a/backends/platform/wii/osystem_gfx.cpp b/backends/platform/wii/osystem_gfx.cpp index 83607984cc..fc0802dd4c 100644 --- a/backends/platform/wii/osystem_gfx.cpp +++ b/backends/platform/wii/osystem_gfx.cpp @@ -74,7 +74,7 @@ void OSystem_Wii::initGfx() { #endif _overlaySize = _overlayWidth * _overlayHeight * 2; - _overlayPixels = (OverlayColor *) memalign(32, _overlaySize); + _overlayPixels = (uint16 *) memalign(32, _overlaySize); memset(&_texMouse, 0, sizeof(gfx_tex_t)); memset(&_texOverlay, 0, sizeof(gfx_tex_t)); @@ -395,7 +395,7 @@ void OSystem_Wii::setCursorPalette(const byte *colors, uint start, uint num) { _cursorPaletteDirty = true; } -void OSystem_Wii::copyRectToScreen(const byte *buf, int pitch, int x, int y, +void OSystem_Wii::copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h) { assert(x >= 0 && x < _gameWidth); assert(y >= 0 && y < _gameHeight); @@ -407,7 +407,7 @@ void OSystem_Wii::copyRectToScreen(const byte *buf, int pitch, int x, int y, if (!Graphics::crossBlit(_gamePixels + y * _gameWidth * _pfGame.bytesPerPixel + x * _pfGame.bytesPerPixel, - buf, _gameWidth * _pfGame.bytesPerPixel, + (const byte *)buf, _gameWidth * _pfGame.bytesPerPixel, pitch, w, h, _pfGameTexture, _pfGame)) { printf("crossBlit failed\n"); ::abort(); @@ -418,9 +418,10 @@ void OSystem_Wii::copyRectToScreen(const byte *buf, int pitch, int x, int y, if (_gameWidth == pitch && pitch == w) { memcpy(dst, buf, h * w); } else { + const byte *src = (const byte *)buf; do { - memcpy(dst, buf, w); - buf += pitch; + memcpy(dst, src, w); + src += pitch; dst += _gameWidth; } while (--h); } @@ -450,7 +451,7 @@ bool OSystem_Wii::needsScreenUpdate() { void OSystem_Wii::updateScreen() { static f32 ar; static gfx_screen_coords_t cc; - static int cs; + static f32 csx, csy; u32 now = getMillis(); if (now - _lastScreenUpdate < 1000 / MAX_FPS) @@ -465,7 +466,6 @@ void OSystem_Wii::updateScreen() { wii_memstats(); #endif - cs = _cursorScale; _lastScreenUpdate = now; if (_overlayVisible || _consoleVisible) @@ -487,12 +487,6 @@ void OSystem_Wii::updateScreen() { if (_gameRunning) ar = gfx_set_ar(4.0 / 3.0); - // ugly, but the modern theme sets a factor of 3, only god knows why - if (cs > 2) - cs = 1; - else - cs *= 2; - if (_overlayDirty) { gfx_tex_convert(&_texOverlay, _overlayPixels); _overlayDirty = false; @@ -502,10 +496,18 @@ void OSystem_Wii::updateScreen() { } if (_mouseVisible) { - cc.x = f32(_mouseX - cs * _mouseHotspotX) * _currentXScale; - cc.y = f32(_mouseY - cs * _mouseHotspotY) * _currentYScale; - cc.w = f32(_texMouse.width) * _currentXScale * cs; - cc.h = f32(_texMouse.height) * _currentYScale * cs; + if (_cursorDontScale) { + csx = 1.0f / _currentXScale; + csy = 1.0f / _currentYScale; + } else { + csx = 1.0f; + csy = 1.0f; + } + + cc.x = f32(_mouseX - csx * _mouseHotspotX) * _currentXScale; + cc.y = f32(_mouseY - csy * _mouseHotspotY) * _currentYScale; + cc.w = f32(_texMouse.width) * _currentXScale * csx; + cc.h = f32(_texMouse.height) * _currentYScale * csy; if (_texMouse.palette && _cursorPaletteDirty) { _texMouse.palette[_mouseKeyColor] = 0; @@ -570,28 +572,30 @@ void OSystem_Wii::clearOverlay() { _overlayDirty = true; } -void OSystem_Wii::grabOverlay(OverlayColor *buf, int pitch) { +void OSystem_Wii::grabOverlay(void *buf, int pitch) { int h = _overlayHeight; - OverlayColor *src = _overlayPixels; + uint16 *src = _overlayPixels; + byte *dst = (byte *)buf; do { - memcpy(buf, src, _overlayWidth * sizeof(OverlayColor)); + memcpy(dst, src, _overlayWidth * sizeof(uint16)); src += _overlayWidth; - buf += pitch; + dst += pitch; } while (--h); } -void OSystem_Wii::copyRectToOverlay(const OverlayColor *buf, int pitch, int x, +void OSystem_Wii::copyRectToOverlay(const void *buf, int pitch, int x, int y, int w, int h) { + const byte *src = (const byte *)buf; if (x < 0) { w += x; - buf -= x; + src -= x * sizeof(uint16); x = 0; } if (y < 0) { h += y; - buf -= y * pitch; + src -= y * pitch; y = 0; } @@ -604,13 +608,13 @@ void OSystem_Wii::copyRectToOverlay(const OverlayColor *buf, int pitch, int x, if (w <= 0 || h <= 0) return; - OverlayColor *dst = _overlayPixels + (y * _overlayWidth + x); - if (_overlayWidth == pitch && pitch == w) { - memcpy(dst, buf, h * w * sizeof(OverlayColor)); + uint16 *dst = _overlayPixels + (y * _overlayWidth + x); + if (_overlayWidth == w && pitch == _overlayWidth * sizeof(uint16)) { + memcpy(dst, src, h * pitch); } else { do { - memcpy(dst, buf, w * sizeof(OverlayColor)); - buf += pitch; + memcpy(dst, src, w * sizeof(uint16)); + src += pitch; dst += _overlayWidth; } while (--h); } @@ -642,9 +646,9 @@ void OSystem_Wii::warpMouse(int x, int y) { _mouseY = y; } -void OSystem_Wii::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, +void OSystem_Wii::setMouseCursor(const void *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, - int cursorTargetScale, + bool dontScale, const Graphics::PixelFormat *format) { gfx_tex_format_t tex_format = GFX_TF_PALETTE_RGB5A3; uint tw, th; @@ -685,7 +689,7 @@ void OSystem_Wii::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, tmpBuf = true; if (!tmpBuf) { - gfx_tex_convert(&_texMouse, buf); + gfx_tex_convert(&_texMouse, (const byte *)buf); } else { u8 bpp = _texMouse.bpp >> 3; byte *tmp = (byte *) malloc(tw * th * bpp); @@ -702,7 +706,7 @@ void OSystem_Wii::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, #ifdef USE_RGB_COLOR if (bpp > 1) { - if (!Graphics::crossBlit(tmp, buf, + if (!Graphics::crossBlit(tmp, (const byte *)buf, tw * _pfRGB3444.bytesPerPixel, w * _pfCursor.bytesPerPixel, tw, th, _pfRGB3444, _pfCursor)) { @@ -726,10 +730,10 @@ void OSystem_Wii::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, } else { #endif byte *dst = tmp; - + const byte *src = (const byte *)buf; do { - memcpy(dst, buf, w * bpp); - buf += w * bpp; + memcpy(dst, src, w * bpp); + src += w * bpp; dst += tw * bpp; } while (--h); #ifdef USE_RGB_COLOR @@ -742,7 +746,7 @@ void OSystem_Wii::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, _mouseHotspotX = hotspotX; _mouseHotspotY = hotspotY; - _cursorScale = cursorTargetScale; + _cursorDontScale = dontScale; if ((_texMouse.palette) && (oldKeycolor != _mouseKeyColor)) _cursorPaletteDirty = true; diff --git a/backends/platform/wince/wince-sdl.cpp b/backends/platform/wince/wince-sdl.cpp index a57fcb9628..3897731db4 100644 --- a/backends/platform/wince/wince-sdl.cpp +++ b/backends/platform/wince/wince-sdl.cpp @@ -622,6 +622,7 @@ void OSystem_WINCE3::getTimeAndDate(TimeDate &t) const { t.tm_hour = systime.wHour; t.tm_min = systime.wMinute; t.tm_sec = systime.wSecond; + t.tm_wday = systime.wDayOfWeek; } Common::String OSystem_WINCE3::getSystemLanguage() const { diff --git a/backends/saves/default/default-saves.cpp b/backends/saves/default/default-saves.cpp index 237c50a1ba..64e7e778b6 100644 --- a/backends/saves/default/default-saves.cpp +++ b/backends/saves/default/default-saves.cpp @@ -97,7 +97,7 @@ Common::InSaveFile *DefaultSaveFileManager::openForLoading(const Common::String return Common::wrapCompressedReadStream(sf); } -Common::OutSaveFile *DefaultSaveFileManager::openForSaving(const Common::String &filename) { +Common::OutSaveFile *DefaultSaveFileManager::openForSaving(const Common::String &filename, bool compress) { // Ensure that the savepath is valid. If not, generate an appropriate error. Common::String savePathName = getSavePath(); checkPath(Common::FSNode(savePathName)); @@ -112,7 +112,7 @@ Common::OutSaveFile *DefaultSaveFileManager::openForSaving(const Common::String // Open the file for saving Common::WriteStream *sf = file.createWriteStream(); - return Common::wrapCompressedWriteStream(sf); + return compress ? Common::wrapCompressedWriteStream(sf) : sf; } bool DefaultSaveFileManager::removeSavefile(const Common::String &filename) { diff --git a/backends/saves/default/default-saves.h b/backends/saves/default/default-saves.h index 1ea87efc67..c7fca279bc 100644 --- a/backends/saves/default/default-saves.h +++ b/backends/saves/default/default-saves.h @@ -38,7 +38,7 @@ public: virtual Common::StringArray listSavefiles(const Common::String &pattern); virtual Common::InSaveFile *openForLoading(const Common::String &filename); - virtual Common::OutSaveFile *openForSaving(const Common::String &filename); + virtual Common::OutSaveFile *openForSaving(const Common::String &filename, bool compress = true); virtual bool removeSavefile(const Common::String &filename); protected: diff --git a/backends/saves/windows/windows-saves.cpp b/backends/saves/windows/windows-saves.cpp index 87348c3416..d520632394 100644 --- a/backends/saves/windows/windows-saves.cpp +++ b/backends/saves/windows/windows-saves.cpp @@ -26,8 +26,12 @@ #if defined(WIN32) && !defined(_WIN32_WCE) && !defined(DISABLE_DEFAULT_SAVEFILEMANAGER) +#if defined(ARRAYSIZE) +#undef ARRAYSIZE +#endif #define WIN32_LEAN_AND_MEAN #include <windows.h> +#undef ARRAYSIZE // winnt.h defines ARRAYSIZE, but we want our own one... #include "common/config-manager.h" #include "common/savefile.h" diff --git a/backends/taskbar/win32/mingw-compat.h b/backends/taskbar/win32/mingw-compat.h index 55105407c6..f6151936f1 100644 --- a/backends/taskbar/win32/mingw-compat.h +++ b/backends/taskbar/win32/mingw-compat.h @@ -70,7 +70,7 @@ DECLARE_INTERFACE_(IPropertyStore, IUnknown) { STDMETHOD (GetValue) (REFPROPERTYKEY key, PROPVARIANT *pv) PURE; STDMETHOD (SetValue) (REFPROPERTYKEY key, REFPROPVARIANT propvar) PURE; STDMETHOD (Commit) (void) PURE; - + private: ~IPropertyStore(); }; @@ -137,7 +137,7 @@ DECLARE_INTERFACE_(ITaskbarList3, IUnknown) { STDMETHOD (SetOverlayIcon) (THIS_ HWND hwnd, HICON hIcon, LPCWSTR pszDescription) PURE; STDMETHOD (SetThumbnailTooltip) (THIS_ HWND hwnd, LPCWSTR pszTip) PURE; STDMETHOD (SetThumbnailClip) (THIS_ HWND hwnd, RECT *prcClip) PURE; - + private: ~ITaskbarList3(); }; diff --git a/backends/timer/bada/timer.cpp b/backends/timer/bada/timer.cpp index faddacb3c3..e41ecd4864 100755..100644 --- a/backends/timer/bada/timer.cpp +++ b/backends/timer/bada/timer.cpp @@ -1,115 +1,115 @@ -/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#if defined (BADA)
-
-#include "backends/timer/bada/timer.h"
-
-//
-// TimerSlot
-//
-TimerSlot::TimerSlot(Common::TimerManager::TimerProc callback,
- uint32 interval, void *refCon) :
- _timer(0),
- _callback(callback),
- _interval(interval),
- _refCon(refCon) {
-}
-
-TimerSlot::~TimerSlot() {
-}
-
-bool TimerSlot::OnStart() {
- _timer = new Osp::Base::Runtime::Timer();
- if (!_timer || IsFailed(_timer->Construct(*this))) {
- AppLog("Failed to create timer");
- return false;
- }
-
- if (IsFailed(_timer->Start(_interval))) {
- AppLog("failed to start timer");
- return false;
- }
-
- AppLog("started timer %d", _interval);
- return true;
-}
-
-void TimerSlot::OnStop() {
- AppLog("timer stopped");
- if (_timer) {
- _timer->Cancel();
- delete _timer;
- _timer = NULL;
- }
-}
-
-void TimerSlot::OnTimerExpired(Timer &timer) {
- _callback(_refCon);
- timer.Start(_interval);
-}
-
-//
-// BadaTimerManager
-//
-BadaTimerManager::BadaTimerManager() {
-}
-
-BadaTimerManager::~BadaTimerManager() {
- for (Common::List<TimerSlot>::iterator slot = _timers.begin();
- slot != _timers.end(); ) {
- slot->Stop();
- slot = _timers.erase(slot);
- }
-}
-
-bool BadaTimerManager::installTimerProc(TimerProc proc, int32 interval, void *refCon,
- const Common::String &id) {
- TimerSlot *slot = new TimerSlot(proc, interval / 1000, refCon);
-
- if (IsFailed(slot->Construct(THREAD_TYPE_EVENT_DRIVEN))) {
- AppLog("Failed to create timer thread");
- delete slot;
- return false;
- }
-
- if (IsFailed(slot->Start())) {
- delete slot;
- AppLog("Failed to start timer thread");
- return false;
- }
-
- _timers.push_back(*slot);
- return true;
-}
-
-void BadaTimerManager::removeTimerProc(TimerProc proc) {
- for (Common::List<TimerSlot>::iterator slot = _timers.begin();
- slot != _timers.end(); ++slot) {
- if (slot->_callback == proc) {
- slot->Stop();
- slot = _timers.erase(slot);
- }
- }
-}
-
-#endif
+/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#if defined(BADA) + +#include "backends/timer/bada/timer.h" + +// +// TimerSlot +// +TimerSlot::TimerSlot(Common::TimerManager::TimerProc callback, + uint32 interval, void *refCon) : + _timer(0), + _callback(callback), + _interval(interval), + _refCon(refCon) { +} + +TimerSlot::~TimerSlot() { +} + +bool TimerSlot::OnStart() { + _timer = new Osp::Base::Runtime::Timer(); + if (!_timer || IsFailed(_timer->Construct(*this))) { + AppLog("Failed to create timer"); + return false; + } + + if (IsFailed(_timer->Start(_interval))) { + AppLog("failed to start timer"); + return false; + } + + AppLog("started timer %d", _interval); + return true; +} + +void TimerSlot::OnStop() { + AppLog("timer stopped"); + if (_timer) { + _timer->Cancel(); + delete _timer; + _timer = NULL; + } +} + +void TimerSlot::OnTimerExpired(Timer &timer) { + _callback(_refCon); + timer.Start(_interval); +} + +// +// BadaTimerManager +// +BadaTimerManager::BadaTimerManager() { +} + +BadaTimerManager::~BadaTimerManager() { + for (Common::List<TimerSlot>::iterator slot = _timers.begin(); + slot != _timers.end(); ) { + slot->Stop(); + slot = _timers.erase(slot); + } +} + +bool BadaTimerManager::installTimerProc(TimerProc proc, int32 interval, void *refCon, + const Common::String &id) { + TimerSlot *slot = new TimerSlot(proc, interval / 1000, refCon); + + if (IsFailed(slot->Construct(THREAD_TYPE_EVENT_DRIVEN))) { + AppLog("Failed to create timer thread"); + delete slot; + return false; + } + + if (IsFailed(slot->Start())) { + delete slot; + AppLog("Failed to start timer thread"); + return false; + } + + _timers.push_back(*slot); + return true; +} + +void BadaTimerManager::removeTimerProc(TimerProc proc) { + for (Common::List<TimerSlot>::iterator slot = _timers.begin(); + slot != _timers.end(); ++slot) { + if (slot->_callback == proc) { + slot->Stop(); + slot = _timers.erase(slot); + } + } +} + +#endif diff --git a/backends/timer/bada/timer.h b/backends/timer/bada/timer.h index 04ca771c26..826064d7ff 100755..100644 --- a/backends/timer/bada/timer.h +++ b/backends/timer/bada/timer.h @@ -1,62 +1,62 @@ -/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef BADA_TIMER_H
-#define BADA_TIMER_H
-
-#include <FBase.h>
-
-#include "common/timer.h"
-#include "common/list.h"
-
-using namespace Osp::Base::Runtime;
-
-struct TimerSlot: public ITimerEventListener, public Thread {
- TimerSlot(Common::TimerManager::TimerProc callback,
- uint32 interval,
- void *refCon);
- ~TimerSlot();
-
- bool OnStart(void);
- void OnStop(void);
- void OnTimerExpired(Timer &timer);
-
- Timer *_timer;
- Common::TimerManager::TimerProc _callback;
- uint32 _interval; // in microseconds
- void *_refCon;
-};
-
-class BadaTimerManager : public Common::TimerManager {
-public:
- BadaTimerManager();
- ~BadaTimerManager();
-
- bool installTimerProc(TimerProc proc, int32 interval, void *refCon,
- const Common::String &id);
- void removeTimerProc(TimerProc proc);
-
-private:
- Common::List<TimerSlot> _timers;
-};
-
-#endif
+/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef BADA_TIMER_H +#define BADA_TIMER_H + +#include <FBase.h> + +#include "common/timer.h" +#include "common/list.h" + +using namespace Osp::Base::Runtime; + +struct TimerSlot: public ITimerEventListener, public Thread { + TimerSlot(Common::TimerManager::TimerProc callback, + uint32 interval, + void *refCon); + ~TimerSlot(); + + bool OnStart(void); + void OnStop(void); + void OnTimerExpired(Timer &timer); + + Timer *_timer; + Common::TimerManager::TimerProc _callback; + uint32 _interval; // in microseconds + void *_refCon; +}; + +class BadaTimerManager : public Common::TimerManager { +public: + BadaTimerManager(); + ~BadaTimerManager(); + + bool installTimerProc(TimerProc proc, int32 interval, void *refCon, + const Common::String &id); + void removeTimerProc(TimerProc proc); + +private: + Common::List<TimerSlot> _timers; +}; + +#endif diff --git a/backends/timer/default/default-timer.cpp b/backends/timer/default/default-timer.cpp index 8681102cd0..9f56d58b12 100644 --- a/backends/timer/default/default-timer.cpp +++ b/backends/timer/default/default-timer.cpp @@ -59,7 +59,6 @@ void insertPrioQueue(TimerSlot *head, TimerSlot *newSlot) { DefaultTimerManager::DefaultTimerManager() : - _timerHandler(0), _head(0) { _head = new TimerSlot(); @@ -157,7 +156,7 @@ void DefaultTimerManager::removeTimerProc(TimerProc callback) { } // We need to remove all names referencing the timer proc here. - // + // // Else we run into troubles, when the client code removes and readds timer // callbacks. // diff --git a/backends/timer/default/default-timer.h b/backends/timer/default/default-timer.h index e5a9dada79..5884979da0 100644 --- a/backends/timer/default/default-timer.h +++ b/backends/timer/default/default-timer.h @@ -34,7 +34,6 @@ private: typedef Common::HashMap<Common::String, TimerProc, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> TimerSlotMap; Common::Mutex _mutex; - void *_timerHandler; TimerSlot *_head; TimerSlotMap _callbacks; diff --git a/backends/timer/psp/timer.cpp b/backends/timer/psp/timer.cpp index ce998436e0..6f8e4b6643 100644 --- a/backends/timer/psp/timer.cpp +++ b/backends/timer/psp/timer.cpp @@ -36,7 +36,7 @@ #include "common/scummsys.h" -#if defined (__PSP__) +#if defined(__PSP__) #include <pspthreadman.h> #include "common/scummsys.h" diff --git a/backends/vkeybd/virtual-keyboard-gui.cpp b/backends/vkeybd/virtual-keyboard-gui.cpp index 42f9707ddc..75de86472f 100644 --- a/backends/vkeybd/virtual-keyboard-gui.cpp +++ b/backends/vkeybd/virtual-keyboard-gui.cpp @@ -161,7 +161,7 @@ void VirtualKeyboardGUI::run() { _system->clearOverlay(); } _overlayBackup.create(_screenW, _screenH, _system->getOverlayFormat()); - _system->grabOverlay((OverlayColor *)_overlayBackup.pixels, _overlayBackup.w); + _system->grabOverlay(_overlayBackup.pixels, _overlayBackup.pitch); setupCursor(); @@ -171,7 +171,7 @@ void VirtualKeyboardGUI::run() { removeCursor(); - _system->copyRectToOverlay((OverlayColor *)_overlayBackup.pixels, _overlayBackup.w, 0, 0, _overlayBackup.w, _overlayBackup.h); + _system->copyRectToOverlay(_overlayBackup.pixels, _overlayBackup.pitch, 0, 0, _overlayBackup.w, _overlayBackup.h); if (!g_gui.isActive()) _system->hideOverlay(); _overlayBackup.free(); @@ -262,7 +262,7 @@ void VirtualKeyboardGUI::screenChanged() { _screenH = newScreenH; _overlayBackup.create(_screenW, _screenH, _system->getOverlayFormat()); - _system->grabOverlay((OverlayColor *)_overlayBackup.pixels, _overlayBackup.w); + _system->grabOverlay(_overlayBackup.pixels, _overlayBackup.pitch); if (!_kbd->checkModeResolutions()) { _displaying = false; @@ -371,7 +371,7 @@ void VirtualKeyboardGUI::redraw() { blit(&surf, &_dispSurface, _dispX - _dirtyRect.left, _dispY - _dirtyRect.top, _dispBackColor); } - _system->copyRectToOverlay((OverlayColor *)surf.pixels, surf.w, + _system->copyRectToOverlay(surf.pixels, surf.pitch, _dirtyRect.left, _dirtyRect.top, surf.w, surf.h); surf.free(); diff --git a/backends/vkeybd/virtual-keyboard-parser.cpp b/backends/vkeybd/virtual-keyboard-parser.cpp index 1958113578..bb8286d1f5 100644 --- a/backends/vkeybd/virtual-keyboard-parser.cpp +++ b/backends/vkeybd/virtual-keyboard-parser.cpp @@ -34,7 +34,7 @@ #include "common/tokenizer.h" #include "common/stream.h" -#include "graphics/imagedec.h" +#include "graphics/decoders/bmp.h" namespace Common { @@ -266,11 +266,15 @@ bool VirtualKeyboardParser::parserCallback_layout(ParserNode *node) { const Graphics::PixelFormat format = g_system->getOverlayFormat(); - _mode->image = Graphics::ImageDecoder::loadFile(*file, format); - delete file; + { + Graphics::BitmapDecoder bmp; + if (!bmp.loadStream(*file)) + return parserError("Error loading bitmap '" + _mode->bitmapName + "'"); + + _mode->image = bmp.getSurface()->convertTo(format); + } - if (!_mode->image) - return parserError("Error loading bitmap '" + _mode->bitmapName + "'"); + delete file; int r, g, b; if (node->values.contains("transparent_color")) { |