From 8447a3650e7de2fc780c1c354f70bf0d119622b3 Mon Sep 17 00:00:00 2001 From: Jody Northup Date: Wed, 3 Jun 2009 23:36:23 +0000 Subject: Applying the temporary 16-bit SDL hack. svn-id: r41152 --- backends/platform/sdl/graphics.cpp | 96 +++++++++++++++++++++++++++++++++++++- backends/platform/sdl/sdl.cpp | 3 ++ backends/platform/sdl/sdl.h | 3 ++ 3 files changed, 100 insertions(+), 2 deletions(-) (limited to 'backends') diff --git a/backends/platform/sdl/graphics.cpp b/backends/platform/sdl/graphics.cpp index 78b8bd8c63..389a7a0735 100644 --- a/backends/platform/sdl/graphics.cpp +++ b/backends/platform/sdl/graphics.cpp @@ -407,6 +407,20 @@ bool OSystem_SDL::loadGFXMode() { } } +#ifdef ENABLE_16BIT + // + // Create the surface that contains the 16 bit game data + // + _screen16 = SDL_CreateRGBSurface(SDL_SWSURFACE, _videoMode.screenWidth, _videoMode.screenHeight, + 16, + 0x7C00, + 0x3E0, + 0x1F, + 0); //555, not 565 + if (_screen16 == NULL) + error("allocating _screen16 failed"); +#endif + // // Create the surface used for the graphics in 16 bit before scaling, and also the overlay // @@ -484,10 +498,17 @@ bool OSystem_SDL::loadGFXMode() { } void OSystem_SDL::unloadGFXMode() { +#ifdef ENABLE_16BIT + if (_screen16) { + SDL_FreeSurface(_screen16); + _screen16 = NULL; + } +#else if (_screen) { SDL_FreeSurface(_screen); _screen = NULL; } +#endif if (_hwscreen) { SDL_FreeSurface(_hwscreen); @@ -519,14 +540,23 @@ void OSystem_SDL::unloadGFXMode() { } bool OSystem_SDL::hotswapGFXMode() { +#ifdef ENABLE_16BIT + if (!_screen16) +#else if (!_screen) +#endif return false; // Keep around the old _screen & _overlayscreen so we can restore the screen data // after the mode switch. +#ifdef ENABLE_16BIT + SDL_Surface *old_screen = _screen16; + _screen16 = NULL; +#else SDL_Surface *old_screen = _screen; - SDL_Surface *old_overlayscreen = _overlayscreen; _screen = NULL; +#endif + SDL_Surface *old_overlayscreen = _overlayscreen; _overlayscreen = NULL; // Release the HW screen surface @@ -544,7 +574,11 @@ bool OSystem_SDL::hotswapGFXMode() { if (!loadGFXMode()) { unloadGFXMode(); +#ifdef ENABLE_16BIT + _screen16 = old_screen; +#else _screen = old_screen; +#endif _overlayscreen = old_overlayscreen; return false; @@ -554,7 +588,11 @@ bool OSystem_SDL::hotswapGFXMode() { SDL_SetColors(_screen, _currentPalette, 0, 256); // Restore old screen content +#ifdef ENABLE_16BIT + SDL_BlitSurface(old_screen, NULL, _screen16, NULL); +#else SDL_BlitSurface(old_screen, NULL, _screen, NULL); +#endif SDL_BlitSurface(old_overlayscreen, NULL, _overlayscreen, NULL); // Free the old surfaces @@ -636,7 +674,11 @@ void OSystem_SDL::internUpdateScreen() { #endif if (!_overlayVisible) { +#ifdef ENABLE_16BIT + origSurf = _screen16; +#else origSurf = _screen; +#endif srcSurf = _tmpscreen; width = _videoMode.screenWidth; height = _videoMode.screenHeight; @@ -781,6 +823,12 @@ void OSystem_SDL::copyRectToScreen(const byte *src, int pitch, int x, int y, int assert (_transactionMode == kTransactionNone); assert(src); +#ifdef ENABLE_16BIT + if (_screen16 == NULL) { + warning("OSystem_SDL::copyRectToScreen: _screen16 == NULL"); + return; + } +#endif if (_screen == NULL) { warning("OSystem_SDL::copyRectToScreen: _screen == NULL"); return; @@ -829,11 +877,29 @@ void OSystem_SDL::copyRectToScreen(const byte *src, int pitch, int x, int y, int } // Try to lock the screen surface +#ifdef ENABLE_16BIT + if (SDL_LockSurface(_screen16) == -1) +#else if (SDL_LockSurface(_screen) == -1) +#endif error("SDL_LockSurface failed: %s", SDL_GetError()); - byte *dst = (byte *)_screen->pixels + y * _videoMode.screenWidth + x; +#ifdef ENABLE_16BIT + byte *dst = (byte *)_screen16->pixels + y * _videoMode.screenWidth * 2 + x * 2; + if (_videoMode.screenWidth == w && pitch == w * 2) { + memcpy(dst, src, h*w*2); + } else { + do { + memcpy(dst, src, w * 2); + src += pitch; + dst += _videoMode.screenWidth * 2; + } while (--h); + } + // Unlock the screen surface + SDL_UnlockSurface(_screen16); +#else + byte *dst = (byte *)_screen->pixels + y * _videoMode.screenWidth + x; if (_videoMode.screenWidth == pitch && pitch == w) { memcpy(dst, src, h*w); } else { @@ -846,6 +912,7 @@ void OSystem_SDL::copyRectToScreen(const byte *src, int pitch, int x, int y, int // Unlock the screen surface SDL_UnlockSurface(_screen); +#endif } Graphics::Surface *OSystem_SDL::lockScreen() { @@ -859,14 +926,26 @@ Graphics::Surface *OSystem_SDL::lockScreen() { _screenIsLocked = true; // Try to lock the screen surface +#ifdef ENABLE_16BIT + if (SDL_LockSurface(_screen16) == -1) +#else if (SDL_LockSurface(_screen) == -1) +#endif error("SDL_LockSurface failed: %s", SDL_GetError()); +#ifdef ENABLE_16BIT + _framebuffer.pixels = _screen16->pixels; + _framebuffer.w = _screen16->w; + _framebuffer.h = _screen16->h; + _framebuffer.pitch = _screen16->pitch; + _framebuffer.bytesPerPixel = 2; +#else _framebuffer.pixels = _screen->pixels; _framebuffer.w = _screen->w; _framebuffer.h = _screen->h; _framebuffer.pitch = _screen->pitch; _framebuffer.bytesPerPixel = 1; +#endif return &_framebuffer; } @@ -879,7 +958,11 @@ void OSystem_SDL::unlockScreen() { _screenIsLocked = false; // Unlock the screen surface +#ifdef ENABLE_16BIT + SDL_UnlockSurface(_screen16); +#else SDL_UnlockSurface(_screen); +#endif // Trigger a full screen update _forceFull = true; @@ -1054,8 +1137,13 @@ void OSystem_SDL::setPalette(const byte *colors, uint start, uint num) { // since we don't actually set the palette until the screen is updated. // But it could indicate a programming error, so let's warn about it. +#ifdef ENABLE_16BIT + if (!_screen16) + warning("OSystem_SDL::setPalette: _screen16 == NULL"); +#else if (!_screen) warning("OSystem_SDL::setPalette: _screen == NULL"); +#endif const byte *b = colors; uint i; @@ -1179,7 +1267,11 @@ void OSystem_SDL::clearOverlay() { dst.x = dst.y = 1; src.w = dst.w = _videoMode.screenWidth; src.h = dst.h = _videoMode.screenHeight; +#ifdef ENABLE_16BIT + if (SDL_BlitSurface(_screen16, &src, _tmpscreen, &dst) != 0) +#else if (SDL_BlitSurface(_screen, &src, _tmpscreen, &dst) != 0) +#endif error("SDL_BlitSurface failed: %s", SDL_GetError()); SDL_LockSurface(_tmpscreen); diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp index c11c97c041..b91d6938a2 100644 --- a/backends/platform/sdl/sdl.cpp +++ b/backends/platform/sdl/sdl.cpp @@ -196,6 +196,9 @@ OSystem_SDL::OSystem_SDL() _osdSurface(0), _osdAlpha(SDL_ALPHA_TRANSPARENT), _osdFadeStartTime(0), #endif _hwscreen(0), _screen(0), _tmpscreen(0), +#ifdef ENABLE_16BIT + _screen16(0), +#endif _overlayVisible(false), _overlayscreen(0), _tmpscreen2(0), _samplesPerSec(0), diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h index 7498f48b08..f843066749 100644 --- a/backends/platform/sdl/sdl.h +++ b/backends/platform/sdl/sdl.h @@ -227,6 +227,9 @@ protected: // unseen game screen SDL_Surface *_screen; +#ifdef ENABLE_16BIT + SDL_Surface *_screen16; +#endif // temporary screen (for scalers) SDL_Surface *_tmpscreen; -- cgit v1.2.3 From f8361b5c53b96faddb56024bb932ce46b7005dbf Mon Sep 17 00:00:00 2001 From: Jody Northup Date: Fri, 5 Jun 2009 06:41:04 +0000 Subject: Converted cursor code to use 16-bit. svn-id: r41191 --- backends/platform/sdl/graphics.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'backends') diff --git a/backends/platform/sdl/graphics.cpp b/backends/platform/sdl/graphics.cpp index 389a7a0735..1a80b9be19 100644 --- a/backends/platform/sdl/graphics.cpp +++ b/backends/platform/sdl/graphics.cpp @@ -1438,8 +1438,13 @@ void OSystem_SDL::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, free(_mouseData); +#ifdef ENABLE_16BIT + _mouseData = (byte *)malloc(w * h * 2); + memcpy(_mouseData, buf, w * h * 2); +#else _mouseData = (byte *)malloc(w * h); memcpy(_mouseData, buf, w * h); +#endif blitCursor(); } @@ -1481,12 +1486,24 @@ void OSystem_SDL::blitCursor() { for (i = 0; i < h; i++) { for (j = 0; j < w; j++) { color = *srcPtr; +#ifdef ENABLE_16BIT + if (color != _mouseKeyColor) { // transparent, don't draw + int8 r = ((*(uint16 *)srcPtr >> 10) & 0x1F) << 3; + int8 g = ((*(uint16 *)srcPtr >> 5) & 0x1F) << 3; + int8 b = (*(uint16 *)srcPtr & 0x1F) << 3; + *(uint16 *)dstPtr = SDL_MapRGB(_mouseOrigSurface->format, + r, g, b); + } + dstPtr += 2; + srcPtr += 2; +#else if (color != _mouseKeyColor) { // transparent, don't draw *(uint16 *)dstPtr = SDL_MapRGB(_mouseOrigSurface->format, palette[color].r, palette[color].g, palette[color].b); } dstPtr += 2; srcPtr++; +#endif } dstPtr += _mouseOrigSurface->pitch - w * 2; } -- cgit v1.2.3 From 9789ba7f28d2c0a093adda01435306f28e91fede Mon Sep 17 00:00:00 2001 From: Jody Northup Date: Fri, 5 Jun 2009 08:09:37 +0000 Subject: Corrected backend to be able to accept a 16-bit mouseKeyColor without overflow svn-id: r41194 --- backends/platform/sdl/graphics.cpp | 47 ++++++++++++++++++++++++++++++++++---- backends/platform/sdl/sdl.h | 4 ++++ 2 files changed, 47 insertions(+), 4 deletions(-) (limited to 'backends') diff --git a/backends/platform/sdl/graphics.cpp b/backends/platform/sdl/graphics.cpp index 1a80b9be19..fadd7a376c 100644 --- a/backends/platform/sdl/graphics.cpp +++ b/backends/platform/sdl/graphics.cpp @@ -1403,7 +1403,8 @@ void OSystem_SDL::warpMouse(int x, int y) { } } -void OSystem_SDL::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, byte keycolor, int cursorTargetScale) { +#ifdef ENABLE_16BIT +void OSystem_SDL::setMouseCursor16(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint16 keycolor, int cursorTargetScale) { if (w == 0 || h == 0) return; @@ -1438,13 +1439,51 @@ void OSystem_SDL::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, free(_mouseData); -#ifdef ENABLE_16BIT _mouseData = (byte *)malloc(w * h * 2); memcpy(_mouseData, buf, w * h * 2); -#else + + blitCursor(); +} +#endif + +void OSystem_SDL::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, byte keycolor, int cursorTargetScale) { + if (w == 0 || h == 0) + return; + + _mouseCurState.hotX = hotspot_x; + _mouseCurState.hotY = hotspot_y; + + _mouseKeyColor = keycolor; + + _cursorTargetScale = cursorTargetScale; + + if (_mouseCurState.w != (int)w || _mouseCurState.h != (int)h) { + _mouseCurState.w = w; + _mouseCurState.h = h; + + if (_mouseOrigSurface) + SDL_FreeSurface(_mouseOrigSurface); + + // Allocate bigger surface because AdvMame2x adds black pixel at [0,0] + _mouseOrigSurface = SDL_CreateRGBSurface(SDL_SWSURFACE | SDL_RLEACCEL | SDL_SRCCOLORKEY | SDL_SRCALPHA, + _mouseCurState.w + 2, + _mouseCurState.h + 2, + 16, + _hwscreen->format->Rmask, + _hwscreen->format->Gmask, + _hwscreen->format->Bmask, + _hwscreen->format->Amask); + + if (_mouseOrigSurface == NULL) + error("allocating _mouseOrigSurface failed"); + SDL_SetColorKey(_mouseOrigSurface, SDL_RLEACCEL | SDL_SRCCOLORKEY | SDL_SRCALPHA, kMouseColorKey); + } + + free(_mouseData); + _mouseData = (byte *)malloc(w * h); memcpy(_mouseData, buf, w * h); -#endif + blitCursor(); } diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h index f843066749..3e0bf19f8f 100644 --- a/backends/platform/sdl/sdl.h +++ b/backends/platform/sdl/sdl.h @@ -112,6 +112,10 @@ public: virtual void warpMouse(int x, int y); // overloaded by CE backend (FIXME) // Set the bitmap that's used when drawing the cursor. +#ifdef ENABLE_16BIT + //HACK Made a second method as a quick and dirty workaround to avoid linker errors with engine libs + virtual void setMouseCursor16(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint16 keycolor, int cursorTargetScale); // overloaded by CE backend (FIXME) +#endif virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, byte keycolor, int cursorTargetScale); // overloaded by CE backend (FIXME) // Set colors of cursor palette -- cgit v1.2.3 From 56e5920bba753820c457c078237a8c06241302ed Mon Sep 17 00:00:00 2001 From: Jody Northup Date: Sat, 6 Jun 2009 01:16:04 +0000 Subject: Corrected cursor display errors introduced by revision 41204, reimplemented 16-bit cursor support in a less hacky, but still temporary way. svn-id: r41209 --- backends/platform/sdl/graphics.cpp | 92 ++++++++++++++++---------------------- backends/platform/sdl/sdl.h | 10 +++-- 2 files changed, 45 insertions(+), 57 deletions(-) (limited to 'backends') diff --git a/backends/platform/sdl/graphics.cpp b/backends/platform/sdl/graphics.cpp index fadd7a376c..8ecf4ecda1 100644 --- a/backends/platform/sdl/graphics.cpp +++ b/backends/platform/sdl/graphics.cpp @@ -1404,49 +1404,19 @@ void OSystem_SDL::warpMouse(int x, int y) { } #ifdef ENABLE_16BIT -void OSystem_SDL::setMouseCursor16(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint16 keycolor, int cursorTargetScale) { - if (w == 0 || h == 0) - return; - - _mouseCurState.hotX = hotspot_x; - _mouseCurState.hotY = hotspot_y; - - _mouseKeyColor = keycolor; - - _cursorTargetScale = cursorTargetScale; - - if (_mouseCurState.w != (int)w || _mouseCurState.h != (int)h) { - _mouseCurState.w = w; - _mouseCurState.h = h; - - if (_mouseOrigSurface) - SDL_FreeSurface(_mouseOrigSurface); - - // Allocate bigger surface because AdvMame2x adds black pixel at [0,0] - _mouseOrigSurface = SDL_CreateRGBSurface(SDL_SWSURFACE | SDL_RLEACCEL | SDL_SRCCOLORKEY | SDL_SRCALPHA, - _mouseCurState.w + 2, - _mouseCurState.h + 2, - 16, - _hwscreen->format->Rmask, - _hwscreen->format->Gmask, - _hwscreen->format->Bmask, - _hwscreen->format->Amask); - - if (_mouseOrigSurface == NULL) - error("allocating _mouseOrigSurface failed"); - SDL_SetColorKey(_mouseOrigSurface, SDL_RLEACCEL | SDL_SRCCOLORKEY | SDL_SRCALPHA, kMouseColorKey); +void OSystem_SDL::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, int cursorTargetScale, uint8 bitDepth) { + uint32 colmask = 0xFF; + uint8 byteDepth = bitDepth >> 3; + for (int i = byteDepth; i > 1; i--) { + colmask <<= 8; + colmask |= 0xFF; } + keycolor &= colmask; - free(_mouseData); - - _mouseData = (byte *)malloc(w * h * 2); - memcpy(_mouseData, buf, w * h * 2); - - blitCursor(); -} +#else +void OSystem_SDL::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, byte keycolor, int cursorTargetScale) { #endif -void OSystem_SDL::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, byte keycolor, int cursorTargetScale) { if (w == 0 || h == 0) return; @@ -1480,14 +1450,24 @@ void OSystem_SDL::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, } free(_mouseData); +#ifdef ENABLE_16BIT + _mouseData = (byte *)malloc(w * h * byteDepth); + memcpy(_mouseData, buf, w * h * byteDepth); + blitCursor(bitDepth); +#else _mouseData = (byte *)malloc(w * h); memcpy(_mouseData, buf, w * h); blitCursor(); +#endif } +#ifdef ENABLE_16BIT +void OSystem_SDL::blitCursor(uint8 bitDepth) { +#else void OSystem_SDL::blitCursor() { +#endif byte *dstPtr; const byte *srcPtr = _mouseData; byte color; @@ -1526,22 +1506,26 @@ void OSystem_SDL::blitCursor() { for (j = 0; j < w; j++) { color = *srcPtr; #ifdef ENABLE_16BIT - if (color != _mouseKeyColor) { // transparent, don't draw - int8 r = ((*(uint16 *)srcPtr >> 10) & 0x1F) << 3; - int8 g = ((*(uint16 *)srcPtr >> 5) & 0x1F) << 3; - int8 b = (*(uint16 *)srcPtr & 0x1F) << 3; - *(uint16 *)dstPtr = SDL_MapRGB(_mouseOrigSurface->format, - r, g, b); - } - dstPtr += 2; - srcPtr += 2; -#else - if (color != _mouseKeyColor) { // transparent, don't draw - *(uint16 *)dstPtr = SDL_MapRGB(_mouseOrigSurface->format, - palette[color].r, palette[color].g, palette[color].b); + if (bitDepth == 16) { + if (color != _mouseKeyColor) { // transparent, don't draw + int8 r = ((*(uint16 *)srcPtr >> 10) & 0x1F) << 3; + int8 g = ((*(uint16 *)srcPtr >> 5) & 0x1F) << 3; + int8 b = (*(uint16 *)srcPtr & 0x1F) << 3; + *(uint16 *)dstPtr = SDL_MapRGB(_mouseOrigSurface->format, + r, g, b); + } + dstPtr += 2; + srcPtr += 2; + } else { +#endif + if (color != _mouseKeyColor) { // transparent, don't draw + *(uint16 *)dstPtr = SDL_MapRGB(_mouseOrigSurface->format, + palette[color].r, palette[color].g, palette[color].b); + } + dstPtr += 2; + srcPtr++; +#ifdef ENABLE_16BIT } - dstPtr += 2; - srcPtr++; #endif } dstPtr += _mouseOrigSurface->pitch - w * 2; diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h index 3e0bf19f8f..7d71ecb6ab 100644 --- a/backends/platform/sdl/sdl.h +++ b/backends/platform/sdl/sdl.h @@ -113,10 +113,10 @@ public: // Set the bitmap that's used when drawing the cursor. #ifdef ENABLE_16BIT - //HACK Made a second method as a quick and dirty workaround to avoid linker errors with engine libs - virtual void setMouseCursor16(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint16 keycolor, int cursorTargetScale); // overloaded by CE backend (FIXME) -#endif + virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, int cursorTargetScale, uint8 bitDepth = 8); // overloaded by CE backend (FIXME) +#else virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, byte keycolor, int cursorTargetScale); // overloaded by CE backend (FIXME) +#endif // Set colors of cursor palette void setCursorPalette(const byte *colors, uint start, uint num); @@ -413,7 +413,11 @@ protected: virtual void drawMouse(); // overloaded by CE backend virtual void undrawMouse(); // overloaded by CE backend (FIXME) +#ifdef ENABLE_16BIT + virtual void blitCursor(uint8 bitDepth = 8); // overloaded by CE backend (FIXME) +#else virtual void blitCursor(); // overloaded by CE backend (FIXME) +#endif /** Set the position of the virtual mouse cursor. */ void setMousePos(int x, int y); -- cgit v1.2.3 From 4087a3e6e8ebc0b519fc4c178a29696bd64fdd6f Mon Sep 17 00:00:00 2001 From: Jody Northup Date: Sat, 6 Jun 2009 08:02:45 +0000 Subject: Corrected 16-bit cursor blit errors on GFX mode change. svn-id: r41212 --- backends/platform/sdl/graphics.cpp | 18 +++++++++++++++++- backends/platform/sdl/sdl.cpp | 2 +- backends/platform/sdl/sdl.h | 7 +++++++ 3 files changed, 25 insertions(+), 2 deletions(-) (limited to 'backends') diff --git a/backends/platform/sdl/graphics.cpp b/backends/platform/sdl/graphics.cpp index 8ecf4ecda1..81e137e19c 100644 --- a/backends/platform/sdl/graphics.cpp +++ b/backends/platform/sdl/graphics.cpp @@ -332,7 +332,11 @@ void OSystem_SDL::setGraphicsModeIntern() { // Even if the old and new scale factors are the same, we may have a // different scaler for the cursor now. +#ifdef ENABLE_16BIT + blitCursor(_cursorBitDepth); +#else blitCursor(); +#endif } int OSystem_SDL::getGraphicsMode() const { @@ -600,7 +604,11 @@ bool OSystem_SDL::hotswapGFXMode() { SDL_FreeSurface(old_overlayscreen); // Update cursor to new scale +#ifdef ENABLE_16BIT + blitCursor(_cursorBitDepth); +#else blitCursor(); +#endif // Blit everything to the screen internUpdateScreen(); @@ -1163,7 +1171,11 @@ void OSystem_SDL::setPalette(const byte *colors, uint start, uint num) { // Some games blink cursors with palette if (_cursorPaletteDisabled) +#ifdef ENABLE_16BIT + blitCursor(_cursorBitDepth); +#else blitCursor(); +#endif } void OSystem_SDL::grabPalette(byte *colors, uint start, uint num) { @@ -1192,7 +1204,11 @@ void OSystem_SDL::setCursorPalette(const byte *colors, uint start, uint num) { _cursorPaletteDisabled = false; +#ifdef ENABLE_16BIT + blitCursor(_cursorBitDepth); +#else blitCursor(); +#endif } void OSystem_SDL::setShakePos(int shake_pos) { @@ -1412,7 +1428,7 @@ void OSystem_SDL::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, colmask |= 0xFF; } keycolor &= colmask; - + _cursorBitDepth = bitDepth; #else void OSystem_SDL::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, byte keycolor, int cursorTargetScale) { #endif diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp index b91d6938a2..3e8cefc86a 100644 --- a/backends/platform/sdl/sdl.cpp +++ b/backends/platform/sdl/sdl.cpp @@ -197,7 +197,7 @@ OSystem_SDL::OSystem_SDL() #endif _hwscreen(0), _screen(0), _tmpscreen(0), #ifdef ENABLE_16BIT - _screen16(0), + _screen16(0), _cursorBitDepth(8), #endif _overlayVisible(false), _overlayscreen(0), _tmpscreen2(0), diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h index 7d71ecb6ab..b6b7a8b284 100644 --- a/backends/platform/sdl/sdl.h +++ b/backends/platform/sdl/sdl.h @@ -124,7 +124,11 @@ public: // Disables or enables cursor palette void disableCursorPalette(bool disable) { _cursorPaletteDisabled = disable; +#ifdef ENABLE_16BIT + blitCursor(_cursorBitDepth); +#else blitCursor(); +#endif } // Shaking is used in SCUMM. Set current shake position. @@ -354,6 +358,9 @@ protected: MousePos _mouseCurState; byte _mouseKeyColor; int _cursorTargetScale; +#ifdef ENABLE_16BIT + uint8 _cursorBitDepth; +#endif bool _cursorPaletteDisabled; SDL_Surface *_mouseOrigSurface; SDL_Surface *_mouseSurface; -- cgit v1.2.3 From 0323638ce933e1dea7dd81b35a6646a9773a01ea Mon Sep 17 00:00:00 2001 From: Jody Northup Date: Sat, 6 Jun 2009 08:41:03 +0000 Subject: Streamlined the cursor blitting changes introduced in revision 41412 svn-id: r41213 --- backends/platform/sdl/graphics.cpp | 26 ++------------------------ backends/platform/sdl/sdl.h | 8 -------- 2 files changed, 2 insertions(+), 32 deletions(-) (limited to 'backends') diff --git a/backends/platform/sdl/graphics.cpp b/backends/platform/sdl/graphics.cpp index 81e137e19c..2872c71f44 100644 --- a/backends/platform/sdl/graphics.cpp +++ b/backends/platform/sdl/graphics.cpp @@ -332,11 +332,7 @@ void OSystem_SDL::setGraphicsModeIntern() { // Even if the old and new scale factors are the same, we may have a // different scaler for the cursor now. -#ifdef ENABLE_16BIT - blitCursor(_cursorBitDepth); -#else blitCursor(); -#endif } int OSystem_SDL::getGraphicsMode() const { @@ -604,11 +600,7 @@ bool OSystem_SDL::hotswapGFXMode() { SDL_FreeSurface(old_overlayscreen); // Update cursor to new scale -#ifdef ENABLE_16BIT - blitCursor(_cursorBitDepth); -#else blitCursor(); -#endif // Blit everything to the screen internUpdateScreen(); @@ -1171,11 +1163,7 @@ void OSystem_SDL::setPalette(const byte *colors, uint start, uint num) { // Some games blink cursors with palette if (_cursorPaletteDisabled) -#ifdef ENABLE_16BIT - blitCursor(_cursorBitDepth); -#else blitCursor(); -#endif } void OSystem_SDL::grabPalette(byte *colors, uint start, uint num) { @@ -1204,11 +1192,7 @@ void OSystem_SDL::setCursorPalette(const byte *colors, uint start, uint num) { _cursorPaletteDisabled = false; -#ifdef ENABLE_16BIT - blitCursor(_cursorBitDepth); -#else blitCursor(); -#endif } void OSystem_SDL::setShakePos(int shake_pos) { @@ -1469,21 +1453,15 @@ void OSystem_SDL::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, #ifdef ENABLE_16BIT _mouseData = (byte *)malloc(w * h * byteDepth); memcpy(_mouseData, buf, w * h * byteDepth); - - blitCursor(bitDepth); #else _mouseData = (byte *)malloc(w * h); memcpy(_mouseData, buf, w * h); +#endif blitCursor(); -#endif } -#ifdef ENABLE_16BIT -void OSystem_SDL::blitCursor(uint8 bitDepth) { -#else void OSystem_SDL::blitCursor() { -#endif byte *dstPtr; const byte *srcPtr = _mouseData; byte color; @@ -1522,7 +1500,7 @@ void OSystem_SDL::blitCursor() { for (j = 0; j < w; j++) { color = *srcPtr; #ifdef ENABLE_16BIT - if (bitDepth == 16) { + if (_cursorBitDepth == 16) { if (color != _mouseKeyColor) { // transparent, don't draw int8 r = ((*(uint16 *)srcPtr >> 10) & 0x1F) << 3; int8 g = ((*(uint16 *)srcPtr >> 5) & 0x1F) << 3; diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h index b6b7a8b284..6fe871fa83 100644 --- a/backends/platform/sdl/sdl.h +++ b/backends/platform/sdl/sdl.h @@ -124,11 +124,7 @@ public: // Disables or enables cursor palette void disableCursorPalette(bool disable) { _cursorPaletteDisabled = disable; -#ifdef ENABLE_16BIT - blitCursor(_cursorBitDepth); -#else blitCursor(); -#endif } // Shaking is used in SCUMM. Set current shake position. @@ -420,11 +416,7 @@ protected: virtual void drawMouse(); // overloaded by CE backend virtual void undrawMouse(); // overloaded by CE backend (FIXME) -#ifdef ENABLE_16BIT - virtual void blitCursor(uint8 bitDepth = 8); // overloaded by CE backend (FIXME) -#else virtual void blitCursor(); // overloaded by CE backend (FIXME) -#endif /** Set the position of the virtual mouse cursor. */ void setMousePos(int x, int y); -- cgit v1.2.3 From c426dd99a4c4149418fa16996e38f0995ddcaea5 Mon Sep 17 00:00:00 2001 From: Jody Northup Date: Tue, 9 Jun 2009 07:55:43 +0000 Subject: Laying the foundation for preliminary bitdepth negotiation. (No functionality changes yet) svn-id: r41396 --- backends/platform/sdl/sdl.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'backends') diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h index 6fe871fa83..22d3d41b00 100644 --- a/backends/platform/sdl/sdl.h +++ b/backends/platform/sdl/sdl.h @@ -178,6 +178,12 @@ public: // Overlay virtual Graphics::PixelFormat getOverlayFormat() const { return _overlayFormat; } + +#ifdef ENABLE_16BIT + // Game screen + virtual Graphics::PixelFormat getScreenFormat() const { return _screenFormat; } +#endif + virtual void showOverlay(); virtual void hideOverlay(); virtual void clearOverlay(); @@ -232,7 +238,12 @@ protected: // unseen game screen SDL_Surface *_screen; #ifdef ENABLE_16BIT - SDL_Surface *_screen16; + Graphics::PixelFormat _screenFormat; + + //HACK This is a temporary hack to get 16-bit graphics + //displaying quickly, which will be removed in favor of + //configuring the format of _screen on a per-game basis + SDL_Surface *_screen16; #endif // temporary screen (for scalers) -- cgit v1.2.3 From 0a793f08a4d198f3f766214ed4ce85ac51ccea5e Mon Sep 17 00:00:00 2001 From: Jody Northup Date: Wed, 10 Jun 2009 05:35:18 +0000 Subject: SDL backend now dynamically generates 8 or 16-bit color surface depending on engine request (using ad-hoc format). svn-id: r41416 --- backends/platform/sdl/graphics.cpp | 244 ++++++++++++++++++++++++------------- backends/platform/sdl/sdl.cpp | 3 +- backends/platform/sdl/sdl.h | 32 +++-- 3 files changed, 182 insertions(+), 97 deletions(-) (limited to 'backends') diff --git a/backends/platform/sdl/graphics.cpp b/backends/platform/sdl/graphics.cpp index 2872c71f44..142fa94dba 100644 --- a/backends/platform/sdl/graphics.cpp +++ b/backends/platform/sdl/graphics.cpp @@ -97,6 +97,9 @@ void OSystem_SDL::beginGFXTransaction(void) { _transactionDetails.needUpdatescreen = false; _transactionDetails.normal1xScaler = false; +#ifdef ENABLE_16BIT + _transactionDetails.formatChanged = false; +#endif _oldVideoMode = _videoMode; } @@ -127,6 +130,12 @@ OSystem::TransactionError OSystem_SDL::endGFXTransaction(void) { _videoMode.screenHeight = _oldVideoMode.screenHeight; _videoMode.overlayWidth = _oldVideoMode.overlayWidth; _videoMode.overlayHeight = _oldVideoMode.overlayHeight; +#ifdef ENABLE_16BIT + } else if (_videoMode.format != _oldVideoMode.format) { + errors |= kTransactionPixelFormatNotSupported; + + _videoMode.format = _oldVideoMode.format; +#endif } if (_videoMode.fullscreen == _oldVideoMode.fullscreen && @@ -143,6 +152,32 @@ OSystem::TransactionError OSystem_SDL::endGFXTransaction(void) { } } +#ifdef ENABLE_16BIT + if (_transactionDetails.formatChanged) { + _screenFormat = getPixelFormat(_videoMode.format); + if (!_transactionDetails.sizeChanged) { + unloadGFXMode(); + if (!loadGFXMode()) { + if (_oldVideoMode.setup) { + _transactionMode = kTransactionRollback; + errors |= endGFXTransaction(); + } + } else { + setGraphicsModeIntern(); + clearOverlay(); + + _videoMode.setup = true; + _modeChanged = true; + // OSystem_SDL::pollEvent used to update the screen change count, + // but actually it gives problems when a video mode was changed + // but OSystem_SDL::pollEvent was not called. This for example + // caused a crash under certain circumstances when doing an RTL. + // To fix this issue we update the screen change count right here. + _screenChangeCount++; + } + } + } +#endif if (_transactionDetails.sizeChanged) { unloadGFXMode(); if (!loadGFXMode()) { @@ -186,7 +221,7 @@ OSystem::TransactionError OSystem_SDL::endGFXTransaction(void) { } else if (_transactionDetails.needUpdatescreen) { setGraphicsModeIntern(); internUpdateScreen(); - } + } _transactionMode = kTransactionNone; return (TransactionError)errors; @@ -339,6 +374,102 @@ int OSystem_SDL::getGraphicsMode() const { assert (_transactionMode == kTransactionNone); return _videoMode.mode; } +#ifdef ENABLE_16BIT +Graphics::ColorFormat OSystem_SDL::findCompatibleFormat(Common::List formatList) +{ + bool typeAccepted = false; + Graphics::ColorFormat format; + + while (!formatList.empty() && !typeAccepted) + { + typeAccepted = false; + format = formatList.front(); + + //no need to keep searching if the screen + //is already in one of the desired formats + if (format == _videoMode.format) + return format; + + formatList.pop_front(); + switch (format & Graphics::kFormatTypeMask) + { + case Graphics::kFormat8Bit: + if (format == Graphics::kFormat8Bit) + return format; + break; + case Graphics::kFormatRGB555: + case Graphics::kFormatARGB1555: + case Graphics::kFormatRGB565: + typeAccepted = true; + break; + } + + if (!typeAccepted) + continue; + + switch (format & Graphics::kFormatOrderMask) { + case Graphics::kFormatRGB: + case Graphics::kFormatRGBA: + return format; + default: + break; + } + } + return Graphics::kFormat8Bit; +} + +void OSystem_SDL::initFormat(Graphics::ColorFormat format) { + assert(_transactionMode == kTransactionActive); + + //avoid redundant format changes + if (format == _videoMode.format) + return; + + _videoMode.format = format; + _transactionDetails.formatChanged = true; + +} + +//This should only ever be called with a format that is known supported. +Graphics::PixelFormat OSystem_SDL::getPixelFormat(Graphics::ColorFormat format) { + Graphics::PixelFormat result; + switch (format & Graphics::kFormatTypeMask) { + case Graphics::kFormatARGB1555: + result.aLoss = 7; + result.bytesPerPixel = 2; + result.rLoss = result.gLoss = result.bLoss = 3; + case Graphics::kFormatRGB555: + result.aLoss = 8; + result.bytesPerPixel = 2; + result.rLoss = result.gLoss = result.bLoss = 3; + break; + case Graphics::kFormatRGB565: + result.bytesPerPixel = 2; + result.aLoss = 8; + result.gLoss = 2; + result.rLoss = result.bLoss = 3; + break; + case Graphics::kFormat8Bit: + default: + result.bytesPerPixel = 1; + result.rShift = result.gShift = result.bShift = result.aShift = 0; + result.rLoss = result.gLoss = result.bLoss = result.aLoss = 8; + return result; + } + switch (format & Graphics::kFormatOrderMask) + { + default: + case Graphics::kFormatRGBA: + result.aShift = 0; + case Graphics::kFormatRGB: + result.bShift = result.aBits(); + result.gShift = result.bShift + result.bBits(); + result.rShift = result.gShift + result.gBits(); + break; + } + return result; +} +#endif void OSystem_SDL::initSize(uint w, uint h) { assert(_transactionMode == kTransactionActive); @@ -384,9 +515,21 @@ bool OSystem_SDL::loadGFXMode() { // // Create the surface that contains the 8 bit game data // +#ifdef ENABLE_16BIT + _screen = SDL_CreateRGBSurface(SDL_SWSURFACE, _videoMode.screenWidth, _videoMode.screenHeight, + _screenFormat.bytesPerPixel << 3, + ((1 << _screenFormat.rBits()) - 1) << _screenFormat.rShift , + ((1 << _screenFormat.gBits()) - 1) << _screenFormat.gShift , + ((1 << _screenFormat.bBits()) - 1) << _screenFormat.bShift , + ((1 << _screenFormat.aBits()) - 1) << _screenFormat.aShift ); + if (_screen == NULL) + error("allocating _screen failed"); + +#else _screen = SDL_CreateRGBSurface(SDL_SWSURFACE, _videoMode.screenWidth, _videoMode.screenHeight, 8, 0, 0, 0, 0); if (_screen == NULL) error("allocating _screen failed"); +#endif // // Create the surface that contains the scaled graphics in 16 bit mode @@ -407,20 +550,6 @@ bool OSystem_SDL::loadGFXMode() { } } -#ifdef ENABLE_16BIT - // - // Create the surface that contains the 16 bit game data - // - _screen16 = SDL_CreateRGBSurface(SDL_SWSURFACE, _videoMode.screenWidth, _videoMode.screenHeight, - 16, - 0x7C00, - 0x3E0, - 0x1F, - 0); //555, not 565 - if (_screen16 == NULL) - error("allocating _screen16 failed"); -#endif - // // Create the surface used for the graphics in 16 bit before scaling, and also the overlay // @@ -498,17 +627,10 @@ bool OSystem_SDL::loadGFXMode() { } void OSystem_SDL::unloadGFXMode() { -#ifdef ENABLE_16BIT - if (_screen16) { - SDL_FreeSurface(_screen16); - _screen16 = NULL; - } -#else if (_screen) { SDL_FreeSurface(_screen); _screen = NULL; } -#endif if (_hwscreen) { SDL_FreeSurface(_hwscreen); @@ -540,22 +662,13 @@ void OSystem_SDL::unloadGFXMode() { } bool OSystem_SDL::hotswapGFXMode() { -#ifdef ENABLE_16BIT - if (!_screen16) -#else if (!_screen) -#endif return false; // Keep around the old _screen & _overlayscreen so we can restore the screen data // after the mode switch. -#ifdef ENABLE_16BIT - SDL_Surface *old_screen = _screen16; - _screen16 = NULL; -#else SDL_Surface *old_screen = _screen; _screen = NULL; -#endif SDL_Surface *old_overlayscreen = _overlayscreen; _overlayscreen = NULL; @@ -574,11 +687,7 @@ bool OSystem_SDL::hotswapGFXMode() { if (!loadGFXMode()) { unloadGFXMode(); -#ifdef ENABLE_16BIT - _screen16 = old_screen; -#else _screen = old_screen; -#endif _overlayscreen = old_overlayscreen; return false; @@ -588,11 +697,7 @@ bool OSystem_SDL::hotswapGFXMode() { SDL_SetColors(_screen, _currentPalette, 0, 256); // Restore old screen content -#ifdef ENABLE_16BIT - SDL_BlitSurface(old_screen, NULL, _screen16, NULL); -#else SDL_BlitSurface(old_screen, NULL, _screen, NULL); -#endif SDL_BlitSurface(old_overlayscreen, NULL, _overlayscreen, NULL); // Free the old surfaces @@ -674,11 +779,7 @@ void OSystem_SDL::internUpdateScreen() { #endif if (!_overlayVisible) { -#ifdef ENABLE_16BIT - origSurf = _screen16; -#else origSurf = _screen; -#endif srcSurf = _tmpscreen; width = _videoMode.screenWidth; height = _videoMode.screenHeight; @@ -823,12 +924,6 @@ void OSystem_SDL::copyRectToScreen(const byte *src, int pitch, int x, int y, int assert (_transactionMode == kTransactionNone); assert(src); -#ifdef ENABLE_16BIT - if (_screen16 == NULL) { - warning("OSystem_SDL::copyRectToScreen: _screen16 == NULL"); - return; - } -#endif if (_screen == NULL) { warning("OSystem_SDL::copyRectToScreen: _screen == NULL"); return; @@ -877,27 +972,20 @@ void OSystem_SDL::copyRectToScreen(const byte *src, int pitch, int x, int y, int } // Try to lock the screen surface -#ifdef ENABLE_16BIT - if (SDL_LockSurface(_screen16) == -1) -#else if (SDL_LockSurface(_screen) == -1) -#endif error("SDL_LockSurface failed: %s", SDL_GetError()); #ifdef ENABLE_16BIT - byte *dst = (byte *)_screen16->pixels + y * _videoMode.screenWidth * 2 + x * 2; - if (_videoMode.screenWidth == w && pitch == w * 2) { - memcpy(dst, src, h*w*2); + byte *dst = (byte *)_screen->pixels + y * _videoMode.screenWidth * _screenFormat.bytesPerPixel + x * _screenFormat.bytesPerPixel; + if (_videoMode.screenWidth == w && pitch == w * _screenFormat.bytesPerPixel) { + memcpy(dst, src, h*w*_screenFormat.bytesPerPixel); } else { do { - memcpy(dst, src, w * 2); + memcpy(dst, src, w * _screenFormat.bytesPerPixel); src += pitch; - dst += _videoMode.screenWidth * 2; + dst += _videoMode.screenWidth * _screenFormat.bytesPerPixel; } while (--h); } - - // Unlock the screen surface - SDL_UnlockSurface(_screen16); #else byte *dst = (byte *)_screen->pixels + y * _videoMode.screenWidth + x; if (_videoMode.screenWidth == pitch && pitch == w) { @@ -909,10 +997,10 @@ void OSystem_SDL::copyRectToScreen(const byte *src, int pitch, int x, int y, int dst += _videoMode.screenWidth; } while (--h); } +#endif // Unlock the screen surface SDL_UnlockSurface(_screen); -#endif } Graphics::Surface *OSystem_SDL::lockScreen() { @@ -926,24 +1014,16 @@ Graphics::Surface *OSystem_SDL::lockScreen() { _screenIsLocked = true; // Try to lock the screen surface -#ifdef ENABLE_16BIT - if (SDL_LockSurface(_screen16) == -1) -#else if (SDL_LockSurface(_screen) == -1) -#endif error("SDL_LockSurface failed: %s", SDL_GetError()); -#ifdef ENABLE_16BIT - _framebuffer.pixels = _screen16->pixels; - _framebuffer.w = _screen16->w; - _framebuffer.h = _screen16->h; - _framebuffer.pitch = _screen16->pitch; - _framebuffer.bytesPerPixel = 2; -#else _framebuffer.pixels = _screen->pixels; _framebuffer.w = _screen->w; _framebuffer.h = _screen->h; _framebuffer.pitch = _screen->pitch; +#ifdef ENABLE_16BIT + _framebuffer.bytesPerPixel = _screenFormat.bytesPerPixel; +#else _framebuffer.bytesPerPixel = 1; #endif @@ -958,11 +1038,7 @@ void OSystem_SDL::unlockScreen() { _screenIsLocked = false; // Unlock the screen surface -#ifdef ENABLE_16BIT - SDL_UnlockSurface(_screen16); -#else SDL_UnlockSurface(_screen); -#endif // Trigger a full screen update _forceFull = true; @@ -1133,17 +1209,17 @@ int16 OSystem_SDL::getWidth() { void OSystem_SDL::setPalette(const byte *colors, uint start, uint num) { assert(colors); +#ifdef ENABLE_16BIT + if (_screenFormat.bytesPerPixel > 1) + return; //not using a paletted pixel format +#endif + // Setting the palette before _screen is created is allowed - for now - // since we don't actually set the palette until the screen is updated. // But it could indicate a programming error, so let's warn about it. -#ifdef ENABLE_16BIT - if (!_screen16) - warning("OSystem_SDL::setPalette: _screen16 == NULL"); -#else if (!_screen) warning("OSystem_SDL::setPalette: _screen == NULL"); -#endif const byte *b = colors; uint i; @@ -1267,11 +1343,7 @@ void OSystem_SDL::clearOverlay() { dst.x = dst.y = 1; src.w = dst.w = _videoMode.screenWidth; src.h = dst.h = _videoMode.screenHeight; -#ifdef ENABLE_16BIT - if (SDL_BlitSurface(_screen16, &src, _tmpscreen, &dst) != 0) -#else if (SDL_BlitSurface(_screen, &src, _tmpscreen, &dst) != 0) -#endif error("SDL_BlitSurface failed: %s", SDL_GetError()); SDL_LockSurface(_tmpscreen); diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp index 3e8cefc86a..3ec4da1196 100644 --- a/backends/platform/sdl/sdl.cpp +++ b/backends/platform/sdl/sdl.cpp @@ -197,7 +197,8 @@ OSystem_SDL::OSystem_SDL() #endif _hwscreen(0), _screen(0), _tmpscreen(0), #ifdef ENABLE_16BIT - _screen16(0), _cursorBitDepth(8), + _screenFormat(getPixelFormat(Graphics::kFormat8Bit)), + _cursorBitDepth(8), #endif _overlayVisible(false), _overlayscreen(0), _tmpscreen2(0), diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h index 22d3d41b00..513ad73934 100644 --- a/backends/platform/sdl/sdl.h +++ b/backends/platform/sdl/sdl.h @@ -81,6 +81,22 @@ public: void beginGFXTransaction(void); TransactionError endGFXTransaction(void); +#ifdef ENABLE_16BIT + // Find a compatible format from the list of formats supported by the engine + // Fallback to CLUT8 if none found + virtual Graphics::ColorFormat findCompatibleFormat(Common::List formatList); + + // Set the depth and format of the video bitmap + // Typically, CLUT8 + virtual void initFormat(Graphics::ColorFormat format); + + // Game screen + virtual Graphics::PixelFormat getScreenFormat() const { return _screenFormat; } + + //Create a Graphics::PixelFormat to describe the requested color mode + virtual Graphics::PixelFormat getPixelFormat(Graphics::ColorFormat format); +#endif + // Set the size of the video bitmap. // Typically, 320x200 virtual void initSize(uint w, uint h); // overloaded by CE backend @@ -179,11 +195,6 @@ public: // Overlay virtual Graphics::PixelFormat getOverlayFormat() const { return _overlayFormat; } -#ifdef ENABLE_16BIT - // Game screen - virtual Graphics::PixelFormat getScreenFormat() const { return _screenFormat; } -#endif - virtual void showOverlay(); virtual void hideOverlay(); virtual void clearOverlay(); @@ -239,11 +250,6 @@ protected: SDL_Surface *_screen; #ifdef ENABLE_16BIT Graphics::PixelFormat _screenFormat; - - //HACK This is a temporary hack to get 16-bit graphics - //displaying quickly, which will be removed in favor of - //configuring the format of _screen on a per-game basis - SDL_Surface *_screen16; #endif // temporary screen (for scalers) @@ -278,6 +284,9 @@ protected: bool needHotswap; bool needUpdatescreen; bool normal1xScaler; +#ifdef ENABLE_16BIT + bool formatChanged; +#endif }; TransactionDetails _transactionDetails; @@ -292,6 +301,9 @@ protected: int screenWidth, screenHeight; int overlayWidth, overlayHeight; +#ifdef ENABLE_16BIT + Graphics::ColorFormat format; +#endif }; VideoState _videoMode, _oldVideoMode; -- cgit v1.2.3 From b4c44a018b636a9805c725f9a286e58be554afc2 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Wed, 10 Jun 2009 08:41:33 +0000 Subject: Code formatting svn-id: r41420 --- backends/platform/sdl/graphics.cpp | 99 ++++++++++++++++++-------------------- 1 file changed, 48 insertions(+), 51 deletions(-) (limited to 'backends') diff --git a/backends/platform/sdl/graphics.cpp b/backends/platform/sdl/graphics.cpp index 142fa94dba..4035bdb661 100644 --- a/backends/platform/sdl/graphics.cpp +++ b/backends/platform/sdl/graphics.cpp @@ -375,13 +375,11 @@ int OSystem_SDL::getGraphicsMode() const { return _videoMode.mode; } #ifdef ENABLE_16BIT -Graphics::ColorFormat OSystem_SDL::findCompatibleFormat(Common::List formatList) -{ +Graphics::ColorFormat OSystem_SDL::findCompatibleFormat(Common::List formatList) { bool typeAccepted = false; Graphics::ColorFormat format; - while (!formatList.empty() && !typeAccepted) - { + while (!formatList.empty() && !typeAccepted) { typeAccepted = false; format = formatList.front(); @@ -391,28 +389,27 @@ Graphics::ColorFormat OSystem_SDL::findCompatibleFormat(Common::List formatList) { +Graphics::ColorMode OSystem_SDL::findCompatibleFormat(Common::List formatList) { bool typeAccepted = false; - Graphics::ColorFormat format; + Graphics::ColorMode format; - while (!formatList.empty() && !typeAccepted) { + while (!formatList.empty()) { typeAccepted = false; format = formatList.front(); @@ -389,33 +366,21 @@ Graphics::ColorFormat OSystem_SDL::findCompatibleFormat(Common::List> 3; - for (int i = byteDepth; i > 1; i--) { - colmask <<= 8; - colmask |= 0xFF; - } - keycolor &= colmask; - _cursorBitDepth = bitDepth; +void OSystem_SDL::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, int cursorTargetScale) { + keycolor &= (1 << (_screenFormat.bytesPerPixel << 3)) - 1; #else void OSystem_SDL::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, byte keycolor, int cursorTargetScale) { #endif @@ -1520,8 +1467,8 @@ void OSystem_SDL::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, free(_mouseData); #ifdef ENABLE_16BIT - _mouseData = (byte *)malloc(w * h * byteDepth); - memcpy(_mouseData, buf, w * h * byteDepth); + _mouseData = (byte *)malloc(w * h * _screenFormat.bytesPerPixel); + memcpy(_mouseData, buf, w * h * _screenFormat.bytesPerPixel); #else _mouseData = (byte *)malloc(w * h); memcpy(_mouseData, buf, w * h); @@ -1533,7 +1480,12 @@ void OSystem_SDL::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, void OSystem_SDL::blitCursor() { byte *dstPtr; const byte *srcPtr = _mouseData; +#ifdef ENABLE_16BIT + uint32 color; + uint32 colormask = (1 << (_screenFormat.bytesPerPixel << 3)) - 1; +#else byte color; +#endif int w, h, i, j; if (!_mouseOrigSurface || !_mouseData) @@ -1567,20 +1519,20 @@ void OSystem_SDL::blitCursor() { for (i = 0; i < h; i++) { for (j = 0; j < w; j++) { - color = *srcPtr; #ifdef ENABLE_16BIT - if (_cursorBitDepth == 16) { + if (_screenFormat.bytesPerPixel > 1) { + color = (*(uint32 *) srcPtr) & colormask; if (color != _mouseKeyColor) { // transparent, don't draw - int8 r = ((*(uint16 *)srcPtr >> 10) & 0x1F) << 3; - int8 g = ((*(uint16 *)srcPtr >> 5) & 0x1F) << 3; - int8 b = (*(uint16 *)srcPtr & 0x1F) << 3; + uint8 r,g,b; + _screenFormat.colorToRGB(color,r,g,b); *(uint16 *)dstPtr = SDL_MapRGB(_mouseOrigSurface->format, r, g, b); } dstPtr += 2; - srcPtr += 2; + srcPtr += _screenFormat.bytesPerPixel; } else { #endif + color = *srcPtr; if (color != _mouseKeyColor) { // transparent, don't draw *(uint16 *)dstPtr = SDL_MapRGB(_mouseOrigSurface->format, palette[color].r, palette[color].g, palette[color].b); diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp index 3ec4da1196..5bcd91d566 100644 --- a/backends/platform/sdl/sdl.cpp +++ b/backends/platform/sdl/sdl.cpp @@ -197,7 +197,7 @@ OSystem_SDL::OSystem_SDL() #endif _hwscreen(0), _screen(0), _tmpscreen(0), #ifdef ENABLE_16BIT - _screenFormat(getPixelFormat(Graphics::kFormat8Bit)), + _screenFormat(getPixelFormat(Graphics::kFormatCLUT8)), _cursorBitDepth(8), #endif _overlayVisible(false), diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h index 513ad73934..4d5ea3f548 100644 --- a/backends/platform/sdl/sdl.h +++ b/backends/platform/sdl/sdl.h @@ -84,17 +84,17 @@ public: #ifdef ENABLE_16BIT // Find a compatible format from the list of formats supported by the engine // Fallback to CLUT8 if none found - virtual Graphics::ColorFormat findCompatibleFormat(Common::List formatList); + virtual Graphics::ColorMode findCompatibleFormat(Common::List formatList); // Set the depth and format of the video bitmap // Typically, CLUT8 - virtual void initFormat(Graphics::ColorFormat format); + virtual void initFormat(Graphics::ColorMode format); // Game screen virtual Graphics::PixelFormat getScreenFormat() const { return _screenFormat; } //Create a Graphics::PixelFormat to describe the requested color mode - virtual Graphics::PixelFormat getPixelFormat(Graphics::ColorFormat format); + virtual Graphics::PixelFormat getPixelFormat(Graphics::ColorMode format); #endif // Set the size of the video bitmap. @@ -129,7 +129,7 @@ public: // Set the bitmap that's used when drawing the cursor. #ifdef ENABLE_16BIT - virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, int cursorTargetScale, uint8 bitDepth = 8); // overloaded by CE backend (FIXME) + virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, int cursorTargetScale); // overloaded by CE backend (FIXME) #else virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, byte keycolor, int cursorTargetScale); // overloaded by CE backend (FIXME) #endif @@ -302,7 +302,7 @@ protected: int screenWidth, screenHeight; int overlayWidth, overlayHeight; #ifdef ENABLE_16BIT - Graphics::ColorFormat format; + Graphics::ColorMode format; #endif }; VideoState _videoMode, _oldVideoMode; -- cgit v1.2.3 From 2ee51a8fa189fc7817fd6d78533664ec870fca48 Mon Sep 17 00:00:00 2001 From: Jody Northup Date: Fri, 12 Jun 2009 08:49:45 +0000 Subject: Unfinished proof of concept regarding my compromise with LordHoto in IRC. svn-id: r41464 --- backends/platform/sdl/graphics.cpp | 41 +++++++++++++++++++++++++++++++++----- backends/platform/sdl/sdl.h | 4 ++-- 2 files changed, 38 insertions(+), 7 deletions(-) (limited to 'backends') diff --git a/backends/platform/sdl/graphics.cpp b/backends/platform/sdl/graphics.cpp index 51f63a364a..e5d8ba4fbc 100644 --- a/backends/platform/sdl/graphics.cpp +++ b/backends/platform/sdl/graphics.cpp @@ -128,7 +128,7 @@ OSystem::TransactionError OSystem_SDL::endGFXTransaction(void) { errors |= kTransactionPixelFormatNotSupported; _videoMode.format = _oldVideoMode.format; - _screenFormat = getPixelFormat(_videoMode.format); + _screenFormat = _videoMode.format; #endif } else if (_videoMode.screenWidth != _oldVideoMode.screenWidth || _videoMode.screenHeight != _oldVideoMode.screenHeight) { errors |= kTransactionSizeChangeFailed; @@ -362,7 +362,7 @@ Graphics::ColorMode OSystem_SDL::findCompatibleFormat(Common::List 1) { + if (_cursorFormat.bytesPerPixel > 1) { color = (*(uint32 *) srcPtr) & colormask; if (color != _mouseKeyColor) { // transparent, don't draw uint8 r,g,b; - _screenFormat.colorToRGB(color,r,g,b); + _cursorFormat.colorToRGB(color,r,g,b); *(uint16 *)dstPtr = SDL_MapRGB(_mouseOrigSurface->format, r, g, b); } dstPtr += 2; - srcPtr += _screenFormat.bytesPerPixel; + srcPtr += _cursorFormat.bytesPerPixel; } else { #endif color = *srcPtr; diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h index 69b85c7959..a25f697c80 100644 --- a/backends/platform/sdl/sdl.h +++ b/backends/platform/sdl/sdl.h @@ -130,6 +130,7 @@ public: // Set the bitmap that's used when drawing the cursor. #ifdef ENABLE_16BIT virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, int cursorTargetScale); // overloaded by CE backend (FIXME) + virtual void setCursorFormat(Graphics::PixelFormat format); #else virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, byte keycolor, int cursorTargetScale); // overloaded by CE backend (FIXME) #endif @@ -250,6 +251,7 @@ protected: SDL_Surface *_screen; #ifdef ENABLE_16BIT Graphics::PixelFormat _screenFormat; + Graphics::PixelFormat _cursorFormat; #endif // temporary screen (for scalers) -- cgit v1.2.3 From 8d306ebccfa7e88b2e4f4635bff3987e550f98d3 Mon Sep 17 00:00:00 2001 From: Jody Northup Date: Mon, 15 Jun 2009 09:45:19 +0000 Subject: Added kUnsupportedColorMode error code brought Scumm engine and SDL backend into compliance with API outlined in http://scummvmupthorn09.wordpress.com/2009/06/14/how-this-is-going-to-work/ Provided convenient Graphics::PixelFormat constructors for ColorMode enums, and bitformat integers. Removed last vestiges (I think) of initial cursor hack. svn-id: r41539 --- backends/platform/sdl/graphics.cpp | 88 -------------------------------------- backends/platform/sdl/sdl.cpp | 4 +- backends/platform/sdl/sdl.h | 10 ----- 3 files changed, 2 insertions(+), 100 deletions(-) (limited to 'backends') diff --git a/backends/platform/sdl/graphics.cpp b/backends/platform/sdl/graphics.cpp index 0d1b3fb8aa..f550621a28 100644 --- a/backends/platform/sdl/graphics.cpp +++ b/backends/platform/sdl/graphics.cpp @@ -352,34 +352,6 @@ int OSystem_SDL::getGraphicsMode() const { return _videoMode.mode; } #ifdef ENABLE_16BIT -Graphics::ColorMode OSystem_SDL::findCompatibleFormat(Common::List formatList) { - bool typeAccepted = false; - Graphics::ColorMode format; - - while (!formatList.empty()) { - typeAccepted = false; - format = formatList.front(); - - //no need to keep searching if the screen - //is already in one of the desired formats - if (getPixelFormat(format) == _videoMode.format) - return format; - - formatList.pop_front(); - switch (format) { - case Graphics::kFormatCLUT8: - if (format == Graphics::kFormatCLUT8) - return format; - break; - case Graphics::kFormatRGB555: - case Graphics::kFormatRGB565: - return format; - break; - } - } - return Graphics::kFormatCLUT8; -} - void OSystem_SDL::initFormat(Graphics::PixelFormat format) { assert(_transactionMode == kTransactionActive); @@ -391,66 +363,6 @@ void OSystem_SDL::initFormat(Graphics::PixelFormat format) { _transactionDetails.formatChanged = true; _screenFormat = format; } - -//TODO: Move this out of OSystem and into Graphics, where engine can access it. -//TODO: ABGR support -Graphics::PixelFormat OSystem_SDL::getPixelFormat(Graphics::ColorMode format) { - Graphics::PixelFormat result; - switch (format) { - case Graphics::kFormatRGB555: - result.aLoss = 8; - result.bytesPerPixel = 2; - result.rLoss = result.gLoss = result.bLoss = 3; - break; - case Graphics::kFormatRGB565: - result.bytesPerPixel = 2; - result.aLoss = 8; - result.gLoss = 2; - result.rLoss = result.bLoss = 3; - break; - case Graphics::kFormatXRGB1555: - //Special case, alpha bit is always high in this mode. - result.aLoss = 7; - result.bytesPerPixel = 2; - result.rLoss = result.gLoss = result.bLoss = 3; - result.bShift = 0; - result.gShift = result.bShift + result.bBits(); - result.rShift = result.gShift + result.gBits(); - result.aShift = result.rShift + result.rBits(); - //HACK: there should be a clean way to handle setting - //up the color order without prematurely returning - return result; - case Graphics::kFormatRGBA4444: - result.bytesPerPixel = 2; - result.aLoss = result.gLoss = result.rLoss = result.bLoss = 4; - break; - case Graphics::kFormatRGB888: - result.bytesPerPixel = 3; - result.aLoss = 8; - result.gLoss = result.rLoss = result.bLoss = 0; - break; - case Graphics::kFormatRGBA6666: - result.bytesPerPixel = 3; - result.aLoss = result.gLoss = result.rLoss = result.bLoss = 2; - break; - case Graphics::kFormatRGBA8888: - result.bytesPerPixel = 4; - result.aLoss = result.gLoss = result.rLoss = result.bLoss = 0; - break; - case Graphics::kFormatCLUT8: - default: - result.bytesPerPixel = 1; - result.rShift = result.gShift = result.bShift = result.aShift = 0; - result.rLoss = result.gLoss = result.bLoss = result.aLoss = 8; - return result; - } - - result.aShift = 0; - result.bShift = result.aBits(); - result.gShift = result.bShift + result.bBits(); - result.rShift = result.gShift + result.gBits(); - return result; -} #endif void OSystem_SDL::initSize(uint w, uint h) { diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp index 5bcd91d566..81b5fcc3eb 100644 --- a/backends/platform/sdl/sdl.cpp +++ b/backends/platform/sdl/sdl.cpp @@ -197,8 +197,8 @@ OSystem_SDL::OSystem_SDL() #endif _hwscreen(0), _screen(0), _tmpscreen(0), #ifdef ENABLE_16BIT - _screenFormat(getPixelFormat(Graphics::kFormatCLUT8)), - _cursorBitDepth(8), + _screenFormat(Graphics::kFormatCLUT8), + _cursorFormat(Graphics::kFormatCLUT8), #endif _overlayVisible(false), _overlayscreen(0), _tmpscreen2(0), diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h index a25f697c80..b36139f24b 100644 --- a/backends/platform/sdl/sdl.h +++ b/backends/platform/sdl/sdl.h @@ -82,19 +82,12 @@ public: TransactionError endGFXTransaction(void); #ifdef ENABLE_16BIT - // Find a compatible format from the list of formats supported by the engine - // Fallback to CLUT8 if none found - virtual Graphics::ColorMode findCompatibleFormat(Common::List formatList); - // Set the depth and format of the video bitmap // Typically, CLUT8 virtual void initFormat(Graphics::PixelFormat format); // Game screen virtual Graphics::PixelFormat getScreenFormat() const { return _screenFormat; } - - //Create a Graphics::PixelFormat to describe the requested color mode - virtual Graphics::PixelFormat getPixelFormat(Graphics::ColorMode format); #endif // Set the size of the video bitmap. @@ -379,9 +372,6 @@ protected: MousePos _mouseCurState; byte _mouseKeyColor; int _cursorTargetScale; -#ifdef ENABLE_16BIT - uint8 _cursorBitDepth; -#endif bool _cursorPaletteDisabled; SDL_Surface *_mouseOrigSurface; SDL_Surface *_mouseSurface; -- cgit v1.2.3 From 0ca17a7f8c79940873a4dc82537310584f03e439 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Mon, 15 Jun 2009 11:46:28 +0000 Subject: Fix compilation when 16BIT code is disabled. svn-id: r41543 --- backends/platform/sdl/graphics.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'backends') diff --git a/backends/platform/sdl/graphics.cpp b/backends/platform/sdl/graphics.cpp index f550621a28..2cee0ea83d 100644 --- a/backends/platform/sdl/graphics.cpp +++ b/backends/platform/sdl/graphics.cpp @@ -155,6 +155,8 @@ OSystem::TransactionError OSystem_SDL::endGFXTransaction(void) { #ifdef ENABLE_16BIT if (_transactionDetails.sizeChanged || _transactionDetails.formatChanged) { +#else + if (_transactionDetails.sizeChanged) { #endif unloadGFXMode(); if (!loadGFXMode()) { -- cgit v1.2.3 From fb96e826f27b071d6696731f43cb5fa0d8760205 Mon Sep 17 00:00:00 2001 From: Jody Northup Date: Tue, 16 Jun 2009 05:33:11 +0000 Subject: Simplified cursor related 16-bit code. svn-id: r41577 --- backends/platform/sdl/graphics.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'backends') diff --git a/backends/platform/sdl/graphics.cpp b/backends/platform/sdl/graphics.cpp index 2cee0ea83d..f4269b55b2 100644 --- a/backends/platform/sdl/graphics.cpp +++ b/backends/platform/sdl/graphics.cpp @@ -1379,11 +1379,11 @@ void OSystem_SDL::warpMouse(int x, int y) { } } -#ifdef ENABLE_16BIT void OSystem_SDL::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, int cursorTargetScale) { +#ifdef ENABLE_16BIT keycolor &= (1 << (_cursorFormat.bytesPerPixel << 3)) - 1; #else -void OSystem_SDL::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, byte keycolor, int cursorTargetScale) { + keycolor &= 0xFF; #endif if (w == 0 || h == 0) -- cgit v1.2.3 From cb56169a2770c25ce27256db339353011158998f Mon Sep 17 00:00:00 2001 From: Jody Northup Date: Tue, 16 Jun 2009 09:04:37 +0000 Subject: Declared getBestFormat in OSystem base class, and implemented in SDL backend. svn-id: r41580 --- backends/platform/sdl/sdl.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'backends') diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h index b36139f24b..b788022d57 100644 --- a/backends/platform/sdl/sdl.h +++ b/backends/platform/sdl/sdl.h @@ -88,6 +88,18 @@ public: // Game screen virtual Graphics::PixelFormat getScreenFormat() const { return _screenFormat; } + + // Highest supported + virtual Graphics::PixelFormat getBestFormat() const { + //TODO scale down 16/32 bit based on hardware support +#ifdef ENABLE_32BIT + return Graphics::PixelFormat(Graphics::kFormatRGBA8888); +#elif defined ENABLE_16BIT + return Graphics::PixelFormat(Graphics::kFormatRGB565); +#else + return Graphics::PixelFormat(Graphics::kFormatCLUT8); +#endif + } #endif // Set the size of the video bitmap. -- cgit v1.2.3 From db9cfc6f962790a270b357c3d47a5dc0e15a37b0 Mon Sep 17 00:00:00 2001 From: Jody Northup Date: Tue, 16 Jun 2009 09:15:06 +0000 Subject: Corrected oversight in earlier ifdef simplification which leads to compilation failure if ENABLE_16BIT is not defined. svn-id: r41581 --- backends/platform/sdl/sdl.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'backends') diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h index b788022d57..074a55069d 100644 --- a/backends/platform/sdl/sdl.h +++ b/backends/platform/sdl/sdl.h @@ -133,11 +133,9 @@ public: virtual void warpMouse(int x, int y); // overloaded by CE backend (FIXME) // Set the bitmap that's used when drawing the cursor. -#ifdef ENABLE_16BIT virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, int cursorTargetScale); // overloaded by CE backend (FIXME) +#ifdef ENABLE_16BIT virtual void setCursorFormat(Graphics::PixelFormat format); -#else - virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, byte keycolor, int cursorTargetScale); // overloaded by CE backend (FIXME) #endif // Set colors of cursor palette -- cgit v1.2.3 From f55419ee451070dbe07014bc7d747507e431edf6 Mon Sep 17 00:00:00 2001 From: Jody Northup Date: Wed, 17 Jun 2009 10:03:59 +0000 Subject: OSystem_SDL::GetBestFormat will no longer return modes greater than that which hardware supports. svn-id: r41606 --- backends/platform/sdl/sdl.h | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'backends') diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h index 074a55069d..598b943e4b 100644 --- a/backends/platform/sdl/sdl.h +++ b/backends/platform/sdl/sdl.h @@ -92,13 +92,26 @@ public: // Highest supported virtual Graphics::PixelFormat getBestFormat() const { //TODO scale down 16/32 bit based on hardware support -#ifdef ENABLE_32BIT - return Graphics::PixelFormat(Graphics::kFormatRGBA8888); -#elif defined ENABLE_16BIT - return Graphics::PixelFormat(Graphics::kFormatRGB565); -#else +#if (defined ENABLE_32BIT) || (defined ENABLE_16BIT) + { + SDL_PixelFormat *HWFormat = SDL_GetVideoInfo()->vfmt; +#ifdef ENABLE_32BIT + if (HWFormat->BitsPerPixel > 32) + return Graphics::PixelFormat(Graphics::kFormatRGBA8888); + return Graphics::PixelFormat(HWFormat->BytesPerPixel, + HWFormat->Rloss, HWFormat->Gloss, HWFormat->Bloss, HWFormat->Aloss, + HWFormat->Rshift, HWFormat->Gshift, HWFormat->Bshift, HWFormat->Ashift); +#else //16 + if (HWFormat->BitsPerPixel > 16) + return Graphics::PixelFormat(Graphics::kFormatRGB565); + return Graphics::PixelFormat(HWFormat->BytesPerPixel, + HWFormat->Rloss, HWFormat->Gloss, HWFormat->Bloss, HWFormat->Aloss, + HWFormat->Rshift, HWFormat->Gshift, HWFormat->Bshift, HWFormat->Ashift); + } +#endif //ENABLE_32BIT +#else //8BIT only return Graphics::PixelFormat(Graphics::kFormatCLUT8); -#endif +#endif //ENABLE_32BIT or ENABLE_16BIT } #endif -- cgit v1.2.3 From 704386d3b09b68f96b6d4160a1a261e3e754f461 Mon Sep 17 00:00:00 2001 From: Jody Northup Date: Fri, 19 Jun 2009 09:28:55 +0000 Subject: Removed replaced Graphics::ColorMode enum type with factory methods for Graphics::PixelFormat. svn-id: r41662 --- backends/platform/sdl/sdl.cpp | 4 ++-- backends/platform/sdl/sdl.h | 23 +++++++++-------------- 2 files changed, 11 insertions(+), 16 deletions(-) (limited to 'backends') diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp index 81b5fcc3eb..17ee5941a4 100644 --- a/backends/platform/sdl/sdl.cpp +++ b/backends/platform/sdl/sdl.cpp @@ -197,8 +197,8 @@ OSystem_SDL::OSystem_SDL() #endif _hwscreen(0), _screen(0), _tmpscreen(0), #ifdef ENABLE_16BIT - _screenFormat(Graphics::kFormatCLUT8), - _cursorFormat(Graphics::kFormatCLUT8), + _screenFormat(Graphics::PixelFormat::createFormatCLUT8()), + _cursorFormat(Graphics::PixelFormat::createFormatCLUT8()), #endif _overlayVisible(false), _overlayscreen(0), _tmpscreen2(0), diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h index 598b943e4b..2cb9451a0d 100644 --- a/backends/platform/sdl/sdl.h +++ b/backends/platform/sdl/sdl.h @@ -96,22 +96,17 @@ public: { SDL_PixelFormat *HWFormat = SDL_GetVideoInfo()->vfmt; #ifdef ENABLE_32BIT - if (HWFormat->BitsPerPixel > 32) - return Graphics::PixelFormat(Graphics::kFormatRGBA8888); - return Graphics::PixelFormat(HWFormat->BytesPerPixel, - HWFormat->Rloss, HWFormat->Gloss, HWFormat->Bloss, HWFormat->Aloss, - HWFormat->Rshift, HWFormat->Gshift, HWFormat->Bshift, HWFormat->Ashift); -#else //16 - if (HWFormat->BitsPerPixel > 16) - return Graphics::PixelFormat(Graphics::kFormatRGB565); - return Graphics::PixelFormat(HWFormat->BytesPerPixel, - HWFormat->Rloss, HWFormat->Gloss, HWFormat->Bloss, HWFormat->Aloss, - HWFormat->Rshift, HWFormat->Gshift, HWFormat->Bshift, HWFormat->Ashift); + if (HWFormat->BitsPerPixel >= 32) + return Graphics::PixelFormat::createFormatRGBA8888(); + if (HWFormat->BitsPerPixel >= 24) + return Graphics:: + FormatRGB888(); +#endif //ENABLE_32BIT + if (HWFormat->BitsPerPixel >= 16) + return Graphics::PixelFormat::createFormatRGB565(); } -#endif //ENABLE_32BIT -#else //8BIT only - return Graphics::PixelFormat(Graphics::kFormatCLUT8); #endif //ENABLE_32BIT or ENABLE_16BIT + return Graphics::PixelFormat::createFormatCLUT8(); } #endif -- cgit v1.2.3 From f7dd1c15ed38418a0371032966144eb6c2e004cb Mon Sep 17 00:00:00 2001 From: Jody Northup Date: Sat, 20 Jun 2009 05:23:09 +0000 Subject: renamed ENABLE_16BIT define to more accurate ENABLE_RGB_COLOR svn-id: r41696 --- backends/platform/sdl/graphics.cpp | 28 ++++++++++++++-------------- backends/platform/sdl/sdl.cpp | 2 +- backends/platform/sdl/sdl.h | 12 +++++------- 3 files changed, 20 insertions(+), 22 deletions(-) (limited to 'backends') diff --git a/backends/platform/sdl/graphics.cpp b/backends/platform/sdl/graphics.cpp index f4269b55b2..a08239d472 100644 --- a/backends/platform/sdl/graphics.cpp +++ b/backends/platform/sdl/graphics.cpp @@ -97,7 +97,7 @@ void OSystem_SDL::beginGFXTransaction(void) { _transactionDetails.needUpdatescreen = false; _transactionDetails.normal1xScaler = false; -#ifdef ENABLE_16BIT +#ifdef ENABLE_RGB_COLOR _transactionDetails.formatChanged = false; #endif @@ -123,7 +123,7 @@ OSystem::TransactionError OSystem_SDL::endGFXTransaction(void) { _videoMode.mode = _oldVideoMode.mode; _videoMode.scaleFactor = _oldVideoMode.scaleFactor; -#ifdef ENABLE_16BIT +#ifdef ENABLE_RGB_COLOR } else if (_videoMode.format != _oldVideoMode.format) { errors |= kTransactionPixelFormatNotSupported; @@ -153,7 +153,7 @@ OSystem::TransactionError OSystem_SDL::endGFXTransaction(void) { } } -#ifdef ENABLE_16BIT +#ifdef ENABLE_RGB_COLOR if (_transactionDetails.sizeChanged || _transactionDetails.formatChanged) { #else if (_transactionDetails.sizeChanged) { @@ -353,7 +353,7 @@ int OSystem_SDL::getGraphicsMode() const { assert (_transactionMode == kTransactionNone); return _videoMode.mode; } -#ifdef ENABLE_16BIT +#ifdef ENABLE_RGB_COLOR void OSystem_SDL::initFormat(Graphics::PixelFormat format) { assert(_transactionMode == kTransactionActive); @@ -411,7 +411,7 @@ bool OSystem_SDL::loadGFXMode() { // // Create the surface that contains the 8 bit game data // -#ifdef ENABLE_16BIT +#ifdef ENABLE_RGB_COLOR _screen = SDL_CreateRGBSurface(SDL_SWSURFACE, _videoMode.screenWidth, _videoMode.screenHeight, _screenFormat.bytesPerPixel << 3, ((1 << _screenFormat.rBits()) - 1) << _screenFormat.rShift , @@ -871,7 +871,7 @@ void OSystem_SDL::copyRectToScreen(const byte *src, int pitch, int x, int y, int if (SDL_LockSurface(_screen) == -1) error("SDL_LockSurface failed: %s", SDL_GetError()); -#ifdef ENABLE_16BIT +#ifdef ENABLE_RGB_COLOR byte *dst = (byte *)_screen->pixels + y * _videoMode.screenWidth * _screenFormat.bytesPerPixel + x * _screenFormat.bytesPerPixel; if (_videoMode.screenWidth == w && pitch == w * _screenFormat.bytesPerPixel) { memcpy(dst, src, h*w*_screenFormat.bytesPerPixel); @@ -917,7 +917,7 @@ Graphics::Surface *OSystem_SDL::lockScreen() { _framebuffer.w = _screen->w; _framebuffer.h = _screen->h; _framebuffer.pitch = _screen->pitch; -#ifdef ENABLE_16BIT +#ifdef ENABLE_RGB_COLOR _framebuffer.bytesPerPixel = _screenFormat.bytesPerPixel; #else _framebuffer.bytesPerPixel = 1; @@ -1105,7 +1105,7 @@ int16 OSystem_SDL::getWidth() { void OSystem_SDL::setPalette(const byte *colors, uint start, uint num) { assert(colors); -#ifdef ENABLE_16BIT +#ifdef ENABLE_RGB_COLOR if (_screenFormat.bytesPerPixel > 1) return; //not using a paletted pixel format #endif @@ -1163,7 +1163,7 @@ void OSystem_SDL::setCursorPalette(const byte *colors, uint start, uint num) { } _cursorPaletteDisabled = false; -#ifdef ENABLE_16BIT +#ifdef ENABLE_RGB_COLOR } void OSystem_SDL::setCursorFormat(Graphics::PixelFormat format) { @@ -1380,7 +1380,7 @@ void OSystem_SDL::warpMouse(int x, int y) { } void OSystem_SDL::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, int cursorTargetScale) { -#ifdef ENABLE_16BIT +#ifdef ENABLE_RGB_COLOR keycolor &= (1 << (_cursorFormat.bytesPerPixel << 3)) - 1; #else keycolor &= 0xFF; @@ -1419,7 +1419,7 @@ void OSystem_SDL::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, } free(_mouseData); -#ifdef ENABLE_16BIT +#ifdef ENABLE_RGB_COLOR _mouseData = (byte *)malloc(w * h * _cursorFormat.bytesPerPixel); memcpy(_mouseData, buf, w * h * _cursorFormat.bytesPerPixel); #else @@ -1433,7 +1433,7 @@ void OSystem_SDL::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, void OSystem_SDL::blitCursor() { byte *dstPtr; const byte *srcPtr = _mouseData; -#ifdef ENABLE_16BIT +#ifdef ENABLE_RGB_COLOR uint32 color; uint32 colormask = (1 << (_cursorFormat.bytesPerPixel << 3)) - 1; #else @@ -1472,7 +1472,7 @@ void OSystem_SDL::blitCursor() { for (i = 0; i < h; i++) { for (j = 0; j < w; j++) { -#ifdef ENABLE_16BIT +#ifdef ENABLE_RGB_COLOR if (_cursorFormat.bytesPerPixel > 1) { color = (*(uint32 *) srcPtr) & colormask; if (color != _mouseKeyColor) { // transparent, don't draw @@ -1492,7 +1492,7 @@ void OSystem_SDL::blitCursor() { } dstPtr += 2; srcPtr++; -#ifdef ENABLE_16BIT +#ifdef ENABLE_RGB_COLOR } #endif } diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp index 17ee5941a4..3f9b81a912 100644 --- a/backends/platform/sdl/sdl.cpp +++ b/backends/platform/sdl/sdl.cpp @@ -196,7 +196,7 @@ OSystem_SDL::OSystem_SDL() _osdSurface(0), _osdAlpha(SDL_ALPHA_TRANSPARENT), _osdFadeStartTime(0), #endif _hwscreen(0), _screen(0), _tmpscreen(0), -#ifdef ENABLE_16BIT +#ifdef ENABLE_RGB_COLOR _screenFormat(Graphics::PixelFormat::createFormatCLUT8()), _cursorFormat(Graphics::PixelFormat::createFormatCLUT8()), #endif diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h index 2cb9451a0d..aee15fcbd0 100644 --- a/backends/platform/sdl/sdl.h +++ b/backends/platform/sdl/sdl.h @@ -81,7 +81,7 @@ public: void beginGFXTransaction(void); TransactionError endGFXTransaction(void); -#ifdef ENABLE_16BIT +#ifdef ENABLE_RGB_COLOR // Set the depth and format of the video bitmap // Typically, CLUT8 virtual void initFormat(Graphics::PixelFormat format); @@ -92,7 +92,6 @@ public: // Highest supported virtual Graphics::PixelFormat getBestFormat() const { //TODO scale down 16/32 bit based on hardware support -#if (defined ENABLE_32BIT) || (defined ENABLE_16BIT) { SDL_PixelFormat *HWFormat = SDL_GetVideoInfo()->vfmt; #ifdef ENABLE_32BIT @@ -105,7 +104,6 @@ public: if (HWFormat->BitsPerPixel >= 16) return Graphics::PixelFormat::createFormatRGB565(); } -#endif //ENABLE_32BIT or ENABLE_16BIT return Graphics::PixelFormat::createFormatCLUT8(); } #endif @@ -142,7 +140,7 @@ public: // Set the bitmap that's used when drawing the cursor. virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, int cursorTargetScale); // overloaded by CE backend (FIXME) -#ifdef ENABLE_16BIT +#ifdef ENABLE_RGB_COLOR virtual void setCursorFormat(Graphics::PixelFormat format); #endif @@ -260,7 +258,7 @@ protected: // unseen game screen SDL_Surface *_screen; -#ifdef ENABLE_16BIT +#ifdef ENABLE_RGB_COLOR Graphics::PixelFormat _screenFormat; Graphics::PixelFormat _cursorFormat; #endif @@ -297,7 +295,7 @@ protected: bool needHotswap; bool needUpdatescreen; bool normal1xScaler; -#ifdef ENABLE_16BIT +#ifdef ENABLE_RGB_COLOR bool formatChanged; #endif }; @@ -314,7 +312,7 @@ protected: int screenWidth, screenHeight; int overlayWidth, overlayHeight; -#ifdef ENABLE_16BIT +#ifdef ENABLE_RGB_COLOR Graphics::PixelFormat format; #endif }; -- cgit v1.2.3 From 7c622423157e29b7206ba0c39a7756443ed1e70d Mon Sep 17 00:00:00 2001 From: Jody Northup Date: Tue, 23 Jun 2009 02:02:51 +0000 Subject: Merged format initialization into InitSize to allow for backends not supporting gfx transactions. svn-id: r41801 --- backends/platform/sdl/graphics.cpp | 21 ++++++++++----------- backends/platform/sdl/sdl.h | 10 +++------- 2 files changed, 13 insertions(+), 18 deletions(-) (limited to 'backends') diff --git a/backends/platform/sdl/graphics.cpp b/backends/platform/sdl/graphics.cpp index a08239d472..b5ec9b9db8 100644 --- a/backends/platform/sdl/graphics.cpp +++ b/backends/platform/sdl/graphics.cpp @@ -353,23 +353,22 @@ int OSystem_SDL::getGraphicsMode() const { assert (_transactionMode == kTransactionNone); return _videoMode.mode; } -#ifdef ENABLE_RGB_COLOR -void OSystem_SDL::initFormat(Graphics::PixelFormat format) { + +void OSystem_SDL::initSize(uint w, uint h, Graphics::PixelFormat format) { assert(_transactionMode == kTransactionActive); +#ifdef ENABLE_RGB_COLOR //avoid redundant format changes - if (format == _videoMode.format) - return; + assert(format.bytesPerPixel > 0); - _videoMode.format = format; - _transactionDetails.formatChanged = true; - _screenFormat = format; -} + if (format != _videoMode.format) + { + _videoMode.format = format; + _transactionDetails.formatChanged = true; + _screenFormat = format; + } #endif -void OSystem_SDL::initSize(uint w, uint h) { - assert(_transactionMode == kTransactionActive); - // Avoid redundant res changes if ((int)w == _videoMode.screenWidth && (int)h == _videoMode.screenHeight) return; diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h index aee15fcbd0..db855094cb 100644 --- a/backends/platform/sdl/sdl.h +++ b/backends/platform/sdl/sdl.h @@ -82,10 +82,6 @@ public: TransactionError endGFXTransaction(void); #ifdef ENABLE_RGB_COLOR - // Set the depth and format of the video bitmap - // Typically, CLUT8 - virtual void initFormat(Graphics::PixelFormat format); - // Game screen virtual Graphics::PixelFormat getScreenFormat() const { return _screenFormat; } @@ -108,9 +104,9 @@ public: } #endif - // Set the size of the video bitmap. - // Typically, 320x200 - virtual void initSize(uint w, uint h); // overloaded by CE backend + // Set the size and format of the video bitmap. + // Typically, 320x200 CLUT8 + virtual void initSize(uint w, uint h, Graphics::PixelFormat format); // overloaded by CE backend virtual int getScreenChangeID() const { return _screenChangeCount; } -- cgit v1.2.3 From 865129a5630017f05d08e778ba1ef430c23cd55a Mon Sep 17 00:00:00 2001 From: Jody Northup Date: Wed, 24 Jun 2009 06:44:30 +0000 Subject: made the cursor's pixel format a member of the cursor object, merged ____CursorFormat functions into equivalent ____Cursor functions. svn-id: r41825 --- backends/platform/sdl/graphics.cpp | 4 +++- backends/platform/sdl/sdl.h | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'backends') diff --git a/backends/platform/sdl/graphics.cpp b/backends/platform/sdl/graphics.cpp index b5ec9b9db8..d7cabd00cc 100644 --- a/backends/platform/sdl/graphics.cpp +++ b/backends/platform/sdl/graphics.cpp @@ -1378,8 +1378,10 @@ void OSystem_SDL::warpMouse(int x, int y) { } } -void OSystem_SDL::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, int cursorTargetScale) { +void OSystem_SDL::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, int cursorTargetScale, Graphics::PixelFormat format) { #ifdef ENABLE_RGB_COLOR + if (format.bytesPerPixel <= _screenFormat.bytesPerPixel) + _cursorFormat = format; keycolor &= (1 << (_cursorFormat.bytesPerPixel << 3)) - 1; #else keycolor &= 0xFF; diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h index db855094cb..7aeebf9264 100644 --- a/backends/platform/sdl/sdl.h +++ b/backends/platform/sdl/sdl.h @@ -135,7 +135,7 @@ public: virtual void warpMouse(int x, int y); // overloaded by CE backend (FIXME) // Set the bitmap that's used when drawing the cursor. - virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, int cursorTargetScale); // overloaded by CE backend (FIXME) + virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, int cursorTargetScale, Graphics::PixelFormat format); // overloaded by CE backend (FIXME) #ifdef ENABLE_RGB_COLOR virtual void setCursorFormat(Graphics::PixelFormat format); #endif -- cgit v1.2.3 From 53eb83dc95b825b2bf4f5f3943e8f10d9add3aa6 Mon Sep 17 00:00:00 2001 From: Jody Northup Date: Thu, 25 Jun 2009 08:55:16 +0000 Subject: API modification -- replaced "Graphics::PixelFormat getBestFormat()" with "Common::List getSupportedFormats()" svn-id: r41854 --- backends/platform/sdl/sdl.h | 41 +++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-) (limited to 'backends') diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h index 7aeebf9264..efe1984446 100644 --- a/backends/platform/sdl/sdl.h +++ b/backends/platform/sdl/sdl.h @@ -86,21 +86,38 @@ public: virtual Graphics::PixelFormat getScreenFormat() const { return _screenFormat; } // Highest supported - virtual Graphics::PixelFormat getBestFormat() const { - //TODO scale down 16/32 bit based on hardware support - { - SDL_PixelFormat *HWFormat = SDL_GetVideoInfo()->vfmt; + virtual Common::List getSupportedFormats() const { + //TODO determine hardware color component order + Common::List list; + SDL_PixelFormat *HWFormat = SDL_GetVideoInfo()->vfmt; #ifdef ENABLE_32BIT - if (HWFormat->BitsPerPixel >= 32) - return Graphics::PixelFormat::createFormatRGBA8888(); - if (HWFormat->BitsPerPixel >= 24) - return Graphics:: - FormatRGB888(); + if (HWFormat->BitsPerPixel >= 32) + { + list.push_back(Graphics::PixelFormat::createFormatRGBA8888()); + list.push_back(Graphics::PixelFormat::createFormatARGB8888()); + list.push_back(Graphics::PixelFormat::createFormatABGR8888()); + list.push_back(Graphics::PixelFormat::createFormatBGRA8888()); } + if (HWFormat->BitsPerPixel >= 24) + { + list.push_back(Graphics::PixelFormat::createFormatRGB888()); + list.push_back(Graphics::PixelFormat::createFormatBGR888()); + } #endif //ENABLE_32BIT - if (HWFormat->BitsPerPixel >= 16) - return Graphics::PixelFormat::createFormatRGB565(); + if (HWFormat->BitsPerPixel >= 16) + { + list.push_back(Graphics::PixelFormat::createFormatRGB565()); + list.push_back(Graphics::PixelFormat::createFormatXRGB1555()); + list.push_back(Graphics::PixelFormat::createFormatRGB555()); + list.push_back(Graphics::PixelFormat::createFormatRGBA4444()); + list.push_back(Graphics::PixelFormat::createFormatARGB4444()); + list.push_back(Graphics::PixelFormat::createFormatBGR565()); + list.push_back(Graphics::PixelFormat::createFormatXBGR1555()); + list.push_back(Graphics::PixelFormat::createFormatBGR555()); + list.push_back(Graphics::PixelFormat::createFormatABGR4444()); + list.push_back(Graphics::PixelFormat::createFormatBGRA4444()); } - return Graphics::PixelFormat::createFormatCLUT8(); + list.push_back(Graphics::PixelFormat::createFormatCLUT8()); + return list; } #endif -- cgit v1.2.3 From 27e50db5d7cdbed498d6a61b1ee1ad5405ce33a2 Mon Sep 17 00:00:00 2001 From: Jody Northup Date: Fri, 26 Jun 2009 10:37:00 +0000 Subject: Converted OSystem::SetMouseCursor to take pointer to PixelFormat, instead of full PixelFormat. Removed OSystem::setCursorFormat (since I forgot to do so several commits ago) svn-id: r41901 --- backends/platform/sdl/graphics.cpp | 18 ++++++------------ backends/platform/sdl/sdl.h | 5 +---- 2 files changed, 7 insertions(+), 16 deletions(-) (limited to 'backends') diff --git a/backends/platform/sdl/graphics.cpp b/backends/platform/sdl/graphics.cpp index d7cabd00cc..f6b4d76418 100644 --- a/backends/platform/sdl/graphics.cpp +++ b/backends/platform/sdl/graphics.cpp @@ -1162,15 +1162,7 @@ void OSystem_SDL::setCursorPalette(const byte *colors, uint start, uint num) { } _cursorPaletteDisabled = false; -#ifdef ENABLE_RGB_COLOR -} - -void OSystem_SDL::setCursorFormat(Graphics::PixelFormat format) { - assert(format.bytesPerPixel); - _cursorFormat = format; - -#endif -// blitCursor(); + blitCursor(); } @@ -1378,10 +1370,12 @@ void OSystem_SDL::warpMouse(int x, int y) { } } -void OSystem_SDL::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, int cursorTargetScale, Graphics::PixelFormat format) { +void OSystem_SDL::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, int cursorTargetScale, Graphics::PixelFormat *format) { #ifdef ENABLE_RGB_COLOR - if (format.bytesPerPixel <= _screenFormat.bytesPerPixel) - _cursorFormat = format; + if (!format) + format = new Graphics::PixelFormat(1,8,8,8,8,0,0,0,0); + if (format->bytesPerPixel <= _screenFormat.bytesPerPixel) + _cursorFormat = *format; keycolor &= (1 << (_cursorFormat.bytesPerPixel << 3)) - 1; #else keycolor &= 0xFF; diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h index efe1984446..2048b7f536 100644 --- a/backends/platform/sdl/sdl.h +++ b/backends/platform/sdl/sdl.h @@ -152,10 +152,7 @@ public: virtual void warpMouse(int x, int y); // overloaded by CE backend (FIXME) // Set the bitmap that's used when drawing the cursor. - virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, int cursorTargetScale, Graphics::PixelFormat format); // overloaded by CE backend (FIXME) -#ifdef ENABLE_RGB_COLOR - virtual void setCursorFormat(Graphics::PixelFormat format); -#endif + virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, int cursorTargetScale, Graphics::PixelFormat *format); // overloaded by CE backend (FIXME) // Set colors of cursor palette void setCursorPalette(const byte *colors, uint start, uint num); -- cgit v1.2.3 From 853aec05ba4485f0bfc90e7515322dfd56a8d4af Mon Sep 17 00:00:00 2001 From: Jody Northup Date: Sat, 27 Jun 2009 05:58:44 +0000 Subject: changed initGraphics, and OSystem::initSize to take Graphics::PixelFormat * parameters instead of Graphics::PixelFormat parameters, to save unnecessary pixelformat initialization if ENABLE_RGB_COLOR is not set. svn-id: r41909 --- backends/platform/sdl/graphics.cpp | 13 ++++++++----- backends/platform/sdl/sdl.h | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) (limited to 'backends') diff --git a/backends/platform/sdl/graphics.cpp b/backends/platform/sdl/graphics.cpp index f6b4d76418..a45f31108b 100644 --- a/backends/platform/sdl/graphics.cpp +++ b/backends/platform/sdl/graphics.cpp @@ -354,18 +354,21 @@ int OSystem_SDL::getGraphicsMode() const { return _videoMode.mode; } -void OSystem_SDL::initSize(uint w, uint h, Graphics::PixelFormat format) { +void OSystem_SDL::initSize(uint w, uint h, Graphics::PixelFormat *format) { assert(_transactionMode == kTransactionActive); #ifdef ENABLE_RGB_COLOR //avoid redundant format changes - assert(format.bytesPerPixel > 0); + if (!format) + format = new Graphics::PixelFormat(1,8,8,8,8,0,0,0,0); + + assert(format->bytesPerPixel > 0); - if (format != _videoMode.format) + if (*format != _videoMode.format) { - _videoMode.format = format; + _videoMode.format = *format; _transactionDetails.formatChanged = true; - _screenFormat = format; + _screenFormat = *format; } #endif diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h index 2048b7f536..befb82cc89 100644 --- a/backends/platform/sdl/sdl.h +++ b/backends/platform/sdl/sdl.h @@ -123,7 +123,7 @@ public: // Set the size and format of the video bitmap. // Typically, 320x200 CLUT8 - virtual void initSize(uint w, uint h, Graphics::PixelFormat format); // overloaded by CE backend + virtual void initSize(uint w, uint h, Graphics::PixelFormat *format); // overloaded by CE backend virtual int getScreenChangeID() const { return _screenChangeCount; } -- cgit v1.2.3 From 9e1916bcad3cc33a870bdbff5bd01b39e523492d Mon Sep 17 00:00:00 2001 From: Jody Northup Date: Tue, 30 Jun 2009 07:30:57 +0000 Subject: renamed kTransactionPixelFormatNotSupported to kTransactionFormatNotSupported, retyped all Graphics::PixelFormat * parameters to const Graphics::PixelFormat *, (hopefully) repaired all memory leaks on screen and cursor format changes, provided OSystem::getScreenFormat and OSystem::getSupportedFormats methods for when ENABLE_RGB_COLOR is not set, completely forgot the "commit early, commit often" mantra. svn-id: r41972 --- backends/platform/sdl/graphics.cpp | 23 +++++++++++++---------- backends/platform/sdl/sdl.h | 4 ++-- 2 files changed, 15 insertions(+), 12 deletions(-) (limited to 'backends') diff --git a/backends/platform/sdl/graphics.cpp b/backends/platform/sdl/graphics.cpp index a45f31108b..27f32ee8d2 100644 --- a/backends/platform/sdl/graphics.cpp +++ b/backends/platform/sdl/graphics.cpp @@ -125,7 +125,7 @@ OSystem::TransactionError OSystem_SDL::endGFXTransaction(void) { _videoMode.scaleFactor = _oldVideoMode.scaleFactor; #ifdef ENABLE_RGB_COLOR } else if (_videoMode.format != _oldVideoMode.format) { - errors |= kTransactionPixelFormatNotSupported; + errors |= kTransactionFormatNotSupported; _videoMode.format = _oldVideoMode.format; _screenFormat = _videoMode.format; @@ -354,21 +354,24 @@ int OSystem_SDL::getGraphicsMode() const { return _videoMode.mode; } -void OSystem_SDL::initSize(uint w, uint h, Graphics::PixelFormat *format) { +void OSystem_SDL::initSize(uint w, uint h, const Graphics::PixelFormat *format) { assert(_transactionMode == kTransactionActive); #ifdef ENABLE_RGB_COLOR //avoid redundant format changes + Graphics::PixelFormat newFormat; if (!format) - format = new Graphics::PixelFormat(1,8,8,8,8,0,0,0,0); + newFormat = Graphics::PixelFormat::createFormatCLUT8(); + else + newFormat = *format; - assert(format->bytesPerPixel > 0); + assert(newFormat.bytesPerPixel > 0); - if (*format != _videoMode.format) + if (newFormat != _videoMode.format) { - _videoMode.format = *format; + _videoMode.format = newFormat; _transactionDetails.formatChanged = true; - _screenFormat = *format; + _screenFormat = newFormat; } #endif @@ -1373,11 +1376,11 @@ void OSystem_SDL::warpMouse(int x, int y) { } } -void OSystem_SDL::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, int cursorTargetScale, Graphics::PixelFormat *format) { +void OSystem_SDL::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format) { #ifdef ENABLE_RGB_COLOR if (!format) - format = new Graphics::PixelFormat(1,8,8,8,8,0,0,0,0); - if (format->bytesPerPixel <= _screenFormat.bytesPerPixel) + _cursorFormat = Graphics::PixelFormat(1,8,8,8,8,0,0,0,0); + else if (format->bytesPerPixel <= _screenFormat.bytesPerPixel) _cursorFormat = *format; keycolor &= (1 << (_cursorFormat.bytesPerPixel << 3)) - 1; #else diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h index befb82cc89..68dfe64d53 100644 --- a/backends/platform/sdl/sdl.h +++ b/backends/platform/sdl/sdl.h @@ -123,7 +123,7 @@ public: // Set the size and format of the video bitmap. // Typically, 320x200 CLUT8 - virtual void initSize(uint w, uint h, Graphics::PixelFormat *format); // overloaded by CE backend + virtual void initSize(uint w, uint h, const Graphics::PixelFormat *format); // overloaded by CE backend virtual int getScreenChangeID() const { return _screenChangeCount; } @@ -152,7 +152,7 @@ public: virtual void warpMouse(int x, int y); // overloaded by CE backend (FIXME) // Set the bitmap that's used when drawing the cursor. - virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, int cursorTargetScale, Graphics::PixelFormat *format); // overloaded by CE backend (FIXME) + virtual 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 (FIXME) // Set colors of cursor palette void setCursorPalette(const byte *colors, uint start, uint num); -- cgit v1.2.3 From 2c5d11b67b35f93b2292c1ca56d0c9fc89608921 Mon Sep 17 00:00:00 2001 From: Jody Northup Date: Tue, 7 Jul 2009 07:50:40 +0000 Subject: Removed PixelFormat convenience constructors at behest of Max and Eugene. svn-id: r42207 --- backends/platform/sdl/graphics.cpp | 2 +- backends/platform/sdl/sdl.cpp | 4 ++-- backends/platform/sdl/sdl.h | 47 +++++++++++++++++++++++++------------- 3 files changed, 34 insertions(+), 19 deletions(-) (limited to 'backends') diff --git a/backends/platform/sdl/graphics.cpp b/backends/platform/sdl/graphics.cpp index 27f32ee8d2..95a3276fa5 100644 --- a/backends/platform/sdl/graphics.cpp +++ b/backends/platform/sdl/graphics.cpp @@ -361,7 +361,7 @@ void OSystem_SDL::initSize(uint w, uint h, const Graphics::PixelFormat *format) //avoid redundant format changes Graphics::PixelFormat newFormat; if (!format) - newFormat = Graphics::PixelFormat::createFormatCLUT8(); + newFormat = Graphics::PixelFormat(1, 8, 8, 8, 8, 0, 0, 0, 0); else newFormat = *format; diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp index 105206ec07..f7bd71361f 100644 --- a/backends/platform/sdl/sdl.cpp +++ b/backends/platform/sdl/sdl.cpp @@ -197,8 +197,8 @@ OSystem_SDL::OSystem_SDL() #endif _hwscreen(0), _screen(0), _tmpscreen(0), #ifdef ENABLE_RGB_COLOR - _screenFormat(Graphics::PixelFormat::createFormatCLUT8()), - _cursorFormat(Graphics::PixelFormat::createFormatCLUT8()), + _screenFormat(Graphics::PixelFormat(1, 8, 8, 8, 8, 0, 0, 0, 0)), + _cursorFormat(Graphics::PixelFormat(1, 8, 8, 8, 8, 0, 0, 0, 0)), #endif _overlayVisible(false), _overlayscreen(0), _tmpscreen2(0), diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h index 68dfe64d53..b8ab2f6d97 100644 --- a/backends/platform/sdl/sdl.h +++ b/backends/platform/sdl/sdl.h @@ -94,29 +94,44 @@ public: if (HWFormat->BitsPerPixel >= 32) { list.push_back(Graphics::PixelFormat::createFormatRGBA8888()); - list.push_back(Graphics::PixelFormat::createFormatARGB8888()); - list.push_back(Graphics::PixelFormat::createFormatABGR8888()); - list.push_back(Graphics::PixelFormat::createFormatBGRA8888()); } + list.push_back(Graphics::PixelFormat(4, 0, 0, 0, 0, 16, 8, 0, 24) +); + list.push_back(Graphics::PixelFormat(4, 0, 0, 0, 0, 0, 8, 16, 24) +); + list.push_back(Graphics::PixelFormat(4, 0, 0, 0, 0, 8, 16, 24, 0) +); } if (HWFormat->BitsPerPixel >= 24) { - list.push_back(Graphics::PixelFormat::createFormatRGB888()); - list.push_back(Graphics::PixelFormat::createFormatBGR888()); + list.push_back(Graphics::PixelFormat(3, 0, 0, 0, 8, 16, 8, 0, 0) +); + list.push_back(Graphics::PixelFormat(3, 0, 0, 0, 8, 0, 8, 16, 0) +); } #endif //ENABLE_32BIT if (HWFormat->BitsPerPixel >= 16) { - list.push_back(Graphics::PixelFormat::createFormatRGB565()); - list.push_back(Graphics::PixelFormat::createFormatXRGB1555()); - list.push_back(Graphics::PixelFormat::createFormatRGB555()); - list.push_back(Graphics::PixelFormat::createFormatRGBA4444()); - list.push_back(Graphics::PixelFormat::createFormatARGB4444()); - list.push_back(Graphics::PixelFormat::createFormatBGR565()); - list.push_back(Graphics::PixelFormat::createFormatXBGR1555()); - list.push_back(Graphics::PixelFormat::createFormatBGR555()); - list.push_back(Graphics::PixelFormat::createFormatABGR4444()); - list.push_back(Graphics::PixelFormat::createFormatBGRA4444()); + list.push_back(Graphics::PixelFormat(2, 3, 2, 3, 8, 11, 5, 0, 0) +); + list.push_back(Graphics::PixelFormat(2, 3, 3, 3, 7, 10, 5, 0, 15) +); + list.push_back(Graphics::PixelFormat(2, 3, 3, 3, 8, 10, 5, 0, 0) +); + list.push_back(Graphics::PixelFormat(2, 4, 4, 4, 4, 12, 8, 4, 0) +); + list.push_back(Graphics::PixelFormat(2, 4, 4, 4, 4, 8, 4, 0, 12) +); + list.push_back(Graphics::PixelFormat(2, 3, 2, 3, 8, 0, 5, 11, 0) +); + list.push_back(Graphics::PixelFormat(2, 3, 3, 3, 7, 0, 5, 10, 15) +); + list.push_back(Graphics::PixelFormat(2, 3, 3, 3, 8, 0, 5, 10, 0) +); + list.push_back(Graphics::PixelFormat(2, 4, 4, 4, 4, 0, 4, 8, 12) +); + list.push_back(Graphics::PixelFormat(2, 4, 4, 4, 4, 4, 8, 12, 0) +); } - list.push_back(Graphics::PixelFormat::createFormatCLUT8()); + list.push_back(Graphics::PixelFormat(1, 8, 8, 8, 8, 0, 0, 0, 0)); return list; } #endif -- cgit v1.2.3 From 828ed66555b99363fed62b4cbb83c36de68c3024 Mon Sep 17 00:00:00 2001 From: Jody Northup Date: Wed, 8 Jul 2009 16:07:58 +0000 Subject: Reinstated static inline Graphics::PixelFormat::createFormatCLUT8(), which I am told was not supposed to be removed with the others. svn-id: r42268 --- backends/platform/sdl/graphics.cpp | 2 +- backends/platform/sdl/sdl.cpp | 4 +-- backends/platform/sdl/sdl.h | 51 ++++++++++++++------------------------ 3 files changed, 21 insertions(+), 36 deletions(-) (limited to 'backends') diff --git a/backends/platform/sdl/graphics.cpp b/backends/platform/sdl/graphics.cpp index 95a3276fa5..27f32ee8d2 100644 --- a/backends/platform/sdl/graphics.cpp +++ b/backends/platform/sdl/graphics.cpp @@ -361,7 +361,7 @@ void OSystem_SDL::initSize(uint w, uint h, const Graphics::PixelFormat *format) //avoid redundant format changes Graphics::PixelFormat newFormat; if (!format) - newFormat = Graphics::PixelFormat(1, 8, 8, 8, 8, 0, 0, 0, 0); + newFormat = Graphics::PixelFormat::createFormatCLUT8(); else newFormat = *format; diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp index f7bd71361f..105206ec07 100644 --- a/backends/platform/sdl/sdl.cpp +++ b/backends/platform/sdl/sdl.cpp @@ -197,8 +197,8 @@ OSystem_SDL::OSystem_SDL() #endif _hwscreen(0), _screen(0), _tmpscreen(0), #ifdef ENABLE_RGB_COLOR - _screenFormat(Graphics::PixelFormat(1, 8, 8, 8, 8, 0, 0, 0, 0)), - _cursorFormat(Graphics::PixelFormat(1, 8, 8, 8, 8, 0, 0, 0, 0)), + _screenFormat(Graphics::PixelFormat::createFormatCLUT8()), + _cursorFormat(Graphics::PixelFormat::createFormatCLUT8()), #endif _overlayVisible(false), _overlayscreen(0), _tmpscreen2(0), diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h index b8ab2f6d97..c2648e8ed7 100644 --- a/backends/platform/sdl/sdl.h +++ b/backends/platform/sdl/sdl.h @@ -94,44 +94,29 @@ public: if (HWFormat->BitsPerPixel >= 32) { list.push_back(Graphics::PixelFormat::createFormatRGBA8888()); - list.push_back(Graphics::PixelFormat(4, 0, 0, 0, 0, 16, 8, 0, 24) -); - list.push_back(Graphics::PixelFormat(4, 0, 0, 0, 0, 0, 8, 16, 24) -); - list.push_back(Graphics::PixelFormat(4, 0, 0, 0, 0, 8, 16, 24, 0) -); } + list.push_back(Graphics::PixelFormat(4, 0, 0, 0, 0, 16, 8, 0, 24)); + list.push_back(Graphics::PixelFormat(4, 0, 0, 0, 0, 0, 8, 16, 24)); + list.push_back(Graphics::PixelFormat(4, 0, 0, 0, 0, 8, 16, 24, 0)); + } if (HWFormat->BitsPerPixel >= 24) { - list.push_back(Graphics::PixelFormat(3, 0, 0, 0, 8, 16, 8, 0, 0) -); - list.push_back(Graphics::PixelFormat(3, 0, 0, 0, 8, 0, 8, 16, 0) -); + list.push_back(Graphics::PixelFormat(3, 0, 0, 0, 8, 16, 8, 0, 0)); + list.push_back(Graphics::PixelFormat(3, 0, 0, 0, 8, 0, 8, 16, 0)); } #endif //ENABLE_32BIT - if (HWFormat->BitsPerPixel >= 16) - { - list.push_back(Graphics::PixelFormat(2, 3, 2, 3, 8, 11, 5, 0, 0) -); - list.push_back(Graphics::PixelFormat(2, 3, 3, 3, 7, 10, 5, 0, 15) -); - list.push_back(Graphics::PixelFormat(2, 3, 3, 3, 8, 10, 5, 0, 0) -); - list.push_back(Graphics::PixelFormat(2, 4, 4, 4, 4, 12, 8, 4, 0) -); - list.push_back(Graphics::PixelFormat(2, 4, 4, 4, 4, 8, 4, 0, 12) -); - list.push_back(Graphics::PixelFormat(2, 3, 2, 3, 8, 0, 5, 11, 0) -); - list.push_back(Graphics::PixelFormat(2, 3, 3, 3, 7, 0, 5, 10, 15) -); - list.push_back(Graphics::PixelFormat(2, 3, 3, 3, 8, 0, 5, 10, 0) -); - list.push_back(Graphics::PixelFormat(2, 4, 4, 4, 4, 0, 4, 8, 12) -); - list.push_back(Graphics::PixelFormat(2, 4, 4, 4, 4, 4, 8, 12, 0) -); + if (HWFormat->BitsPerPixel >= 16) { + list.push_back(Graphics::PixelFormat(2, 3, 2, 3, 8, 11, 5, 0, 0)); + list.push_back(Graphics::PixelFormat(2, 3, 3, 3, 7, 10, 5, 0, 15)); + list.push_back(Graphics::PixelFormat(2, 3, 3, 3, 8, 10, 5, 0, 0)); + list.push_back(Graphics::PixelFormat(2, 4, 4, 4, 4, 12, 8, 4, 0)); + list.push_back(Graphics::PixelFormat(2, 4, 4, 4, 4, 8, 4, 0, 12)); + list.push_back(Graphics::PixelFormat(2, 3, 2, 3, 8, 0, 5, 11, 0)); + list.push_back(Graphics::PixelFormat(2, 3, 3, 3, 7, 0, 5, 10, 15)); + list.push_back(Graphics::PixelFormat(2, 3, 3, 3, 8, 0, 5, 10, 0)); + list.push_back(Graphics::PixelFormat(2, 4, 4, 4, 4, 0, 4, 8, 12)); + list.push_back(Graphics::PixelFormat(2, 4, 4, 4, 4, 4, 8, 12, 0)); } - list.push_back(Graphics::PixelFormat(1, 8, 8, 8, 8, 0, 0, 0, 0)); + list.push_back(Graphics::PixelFormat::createFormatCLUT8()); return list; } #endif -- cgit v1.2.3 From a4f3a8390068fc372a96d4473b91eb09158353ef Mon Sep 17 00:00:00 2001 From: Jody Northup Date: Thu, 9 Jul 2009 09:10:05 +0000 Subject: corrected creation of one Graphics::PixelFormat to reflect the resurrection of Graphics::PixelFormat::createFormatCLUT8 svn-id: r42282 --- backends/platform/sdl/graphics.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'backends') diff --git a/backends/platform/sdl/graphics.cpp b/backends/platform/sdl/graphics.cpp index 27f32ee8d2..3029f43d87 100644 --- a/backends/platform/sdl/graphics.cpp +++ b/backends/platform/sdl/graphics.cpp @@ -1379,7 +1379,7 @@ void OSystem_SDL::warpMouse(int x, int y) { void OSystem_SDL::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format) { #ifdef ENABLE_RGB_COLOR if (!format) - _cursorFormat = Graphics::PixelFormat(1,8,8,8,8,0,0,0,0); + _cursorFormat = Graphics::PixelFormat::createFormatCLUT8; else if (format->bytesPerPixel <= _screenFormat.bytesPerPixel) _cursorFormat = *format; keycolor &= (1 << (_cursorFormat.bytesPerPixel << 3)) - 1; -- cgit v1.2.3 From ff208c5387a8566546a384afa9ab48c0a1f356a0 Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Thu, 9 Jul 2009 17:25:06 +0000 Subject: fix compile svn-id: r42308 --- backends/platform/sdl/graphics.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'backends') diff --git a/backends/platform/sdl/graphics.cpp b/backends/platform/sdl/graphics.cpp index 3029f43d87..fa162a6348 100644 --- a/backends/platform/sdl/graphics.cpp +++ b/backends/platform/sdl/graphics.cpp @@ -1379,7 +1379,7 @@ void OSystem_SDL::warpMouse(int x, int y) { void OSystem_SDL::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format) { #ifdef ENABLE_RGB_COLOR if (!format) - _cursorFormat = Graphics::PixelFormat::createFormatCLUT8; + _cursorFormat = Graphics::PixelFormat::createFormatCLUT8(); else if (format->bytesPerPixel <= _screenFormat.bytesPerPixel) _cursorFormat = *format; keycolor &= (1 << (_cursorFormat.bytesPerPixel << 3)) - 1; -- cgit v1.2.3 From a5d374bded6204c9250155d572d23b0caef636a5 Mon Sep 17 00:00:00 2001 From: Jody Northup Date: Fri, 10 Jul 2009 06:46:50 +0000 Subject: Moved OSystem_SDL::getSupportedFormats function body from platforms/sdl/sdl.h to platforms/sdl/graphics.cpp, Improved and simplified list-generation method for OSystem_SDL::getSupportedFormats. svn-id: r42325 --- backends/platform/sdl/graphics.cpp | 70 ++++++++++++++++++++++++++++++++++++++ backends/platform/sdl/sdl.h | 34 +----------------- 2 files changed, 71 insertions(+), 33 deletions(-) (limited to 'backends') diff --git a/backends/platform/sdl/graphics.cpp b/backends/platform/sdl/graphics.cpp index fa162a6348..61f33569af 100644 --- a/backends/platform/sdl/graphics.cpp +++ b/backends/platform/sdl/graphics.cpp @@ -26,6 +26,9 @@ #include "backends/platform/sdl/sdl.h" #include "common/mutex.h" #include "common/util.h" +#ifdef ENABLE_RGB_COLOR +#include "common/list.h" +#endif #include "graphics/font.h" #include "graphics/fontman.h" #include "graphics/scaler.h" @@ -206,6 +209,73 @@ OSystem::TransactionError OSystem_SDL::endGFXTransaction(void) { return (TransactionError)errors; } +#ifdef ENABLE_RGB_COLOR +const Graphics::PixelFormat RGBList[] = { +#ifdef ENABLE_32BIT + // RGBA8888, ARGB8888, RGB888 + Graphics::PixelFormat(4, 0, 0, 0, 0, 24, 16, 8, 0), + Graphics::PixelFormat(4, 0, 0, 0, 0, 16, 8, 0, 24), + Graphics::PixelFormat(3, 0, 0, 0, 8, 16, 8, 0, 0), +#endif + // RGB565, XRGB1555, RGB555, RGBA4444, ARGB4444 + Graphics::PixelFormat(2, 3, 2, 3, 8, 11, 5, 0, 0), + Graphics::PixelFormat(2, 3, 3, 3, 7, 10, 5, 0, 15), + Graphics::PixelFormat(2, 3, 3, 3, 8, 10, 5, 0, 0), + Graphics::PixelFormat(2, 4, 4, 4, 4, 12, 8, 4, 0), + Graphics::PixelFormat(2, 4, 4, 4, 4, 8, 4, 0, 12) +}; +const Graphics::PixelFormat BGRList[] = { +#ifdef ENABLE_32BIT + // ABGR8888, BGRA8888, BGR888 + Graphics::PixelFormat(4, 0, 0, 0, 0, 0, 8, 16, 24), + Graphics::PixelFormat(4, 0, 0, 0, 0, 8, 16, 24, 0), + Graphics::PixelFormat(3, 0, 0, 0, 8, 0, 8, 16, 0), +#endif + // BGR565, XBGR1555, BGR555, ABGR4444, BGRA4444 + Graphics::PixelFormat(2, 3, 2, 3, 8, 0, 5, 11, 0), + Graphics::PixelFormat(2, 3, 3, 3, 7, 0, 5, 10, 15), + Graphics::PixelFormat(2, 3, 3, 3, 8, 0, 5, 10, 0), + Graphics::PixelFormat(2, 4, 4, 4, 4, 0, 4, 8, 12), + Graphics::PixelFormat(2, 3, 3, 3, 8, 4, 8, 12, 0) +}; + +// TODO: prioritize matching alpha masks +Common::List OSystem_SDL::getSupportedFormats() { + static Common::List list; + if (!list.empty()) + return list; + bool BGR = false; + int listLength = ARRAYSIZE(RGBList); + + // Get our currently set format + Graphics::PixelFormat format(_hwscreen->format->BytesPerPixel, + _hwscreen->format->Rloss, _hwscreen->format->Gloss, + _hwscreen->format->Bloss, _hwscreen->format->Aloss, + _hwscreen->format->Rshift, _hwscreen->format->Gshift, + _hwscreen->format->Bshift, _hwscreen->format->Ashift); + + // Push it first, as the prefered format. + list.push_back(format); + if (format.bShift > format.rShift) + BGR = true; + for (int i = 0; i < listLength; i++) { + if (RGBList[i].bytesPerPixel > format.bytesPerPixel) + continue; + if (BGR) { + if (BGRList[i] != format) + list.push_back(BGRList[i]); + list.push_back(RGBList[i]); + } else { + if (RGBList[i] != format) + list.push_back(RGBList[i]); + list.push_back(BGRList[i]); + } + } + list.push_back(Graphics::PixelFormat::createFormatCLUT8()); + return list; +} +#endif + bool OSystem_SDL::setGraphicsMode(int mode) { Common::StackLock lock(_graphicsMutex); diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h index c2648e8ed7..3e074a884a 100644 --- a/backends/platform/sdl/sdl.h +++ b/backends/platform/sdl/sdl.h @@ -86,39 +86,7 @@ public: virtual Graphics::PixelFormat getScreenFormat() const { return _screenFormat; } // Highest supported - virtual Common::List getSupportedFormats() const { - //TODO determine hardware color component order - Common::List list; - SDL_PixelFormat *HWFormat = SDL_GetVideoInfo()->vfmt; -#ifdef ENABLE_32BIT - if (HWFormat->BitsPerPixel >= 32) - { - list.push_back(Graphics::PixelFormat::createFormatRGBA8888()); - list.push_back(Graphics::PixelFormat(4, 0, 0, 0, 0, 16, 8, 0, 24)); - list.push_back(Graphics::PixelFormat(4, 0, 0, 0, 0, 0, 8, 16, 24)); - list.push_back(Graphics::PixelFormat(4, 0, 0, 0, 0, 8, 16, 24, 0)); - } - if (HWFormat->BitsPerPixel >= 24) - { - list.push_back(Graphics::PixelFormat(3, 0, 0, 0, 8, 16, 8, 0, 0)); - list.push_back(Graphics::PixelFormat(3, 0, 0, 0, 8, 0, 8, 16, 0)); - } -#endif //ENABLE_32BIT - if (HWFormat->BitsPerPixel >= 16) { - list.push_back(Graphics::PixelFormat(2, 3, 2, 3, 8, 11, 5, 0, 0)); - list.push_back(Graphics::PixelFormat(2, 3, 3, 3, 7, 10, 5, 0, 15)); - list.push_back(Graphics::PixelFormat(2, 3, 3, 3, 8, 10, 5, 0, 0)); - list.push_back(Graphics::PixelFormat(2, 4, 4, 4, 4, 12, 8, 4, 0)); - list.push_back(Graphics::PixelFormat(2, 4, 4, 4, 4, 8, 4, 0, 12)); - list.push_back(Graphics::PixelFormat(2, 3, 2, 3, 8, 0, 5, 11, 0)); - list.push_back(Graphics::PixelFormat(2, 3, 3, 3, 7, 0, 5, 10, 15)); - list.push_back(Graphics::PixelFormat(2, 3, 3, 3, 8, 0, 5, 10, 0)); - list.push_back(Graphics::PixelFormat(2, 4, 4, 4, 4, 0, 4, 8, 12)); - list.push_back(Graphics::PixelFormat(2, 4, 4, 4, 4, 4, 8, 12, 0)); - } - list.push_back(Graphics::PixelFormat::createFormatCLUT8()); - return list; - } + virtual Common::List getSupportedFormats(); #endif // Set the size and format of the video bitmap. -- cgit v1.2.3 From 02e639ea0ceaa4b6a530847dbb043a5c2352e4a2 Mon Sep 17 00:00:00 2001 From: Jody Northup Date: Fri, 10 Jul 2009 19:55:06 +0000 Subject: Fixed a couple of errors in the new getSupportedFormats implementation. svn-id: r42350 --- backends/platform/sdl/graphics.cpp | 39 ++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) (limited to 'backends') diff --git a/backends/platform/sdl/graphics.cpp b/backends/platform/sdl/graphics.cpp index 61f33569af..ea9c285a44 100644 --- a/backends/platform/sdl/graphics.cpp +++ b/backends/platform/sdl/graphics.cpp @@ -242,22 +242,37 @@ const Graphics::PixelFormat BGRList[] = { // TODO: prioritize matching alpha masks Common::List OSystem_SDL::getSupportedFormats() { static Common::List list; - if (!list.empty()) + static bool inited = false; + + if (inited) return list; + bool BGR = false; int listLength = ARRAYSIZE(RGBList); - // Get our currently set format - Graphics::PixelFormat format(_hwscreen->format->BytesPerPixel, - _hwscreen->format->Rloss, _hwscreen->format->Gloss, - _hwscreen->format->Bloss, _hwscreen->format->Aloss, - _hwscreen->format->Rshift, _hwscreen->format->Gshift, - _hwscreen->format->Bshift, _hwscreen->format->Ashift); - - // Push it first, as the prefered format. - list.push_back(format); - if (format.bShift > format.rShift) - BGR = true; + Graphics::PixelFormat format = Graphics::PixelFormat::createFormatCLUT8(); + if (_hwscreen) { + // Get our currently set hardware format + format = Graphics::PixelFormat(_hwscreen->format->BytesPerPixel, + _hwscreen->format->Rloss, _hwscreen->format->Gloss, + _hwscreen->format->Bloss, _hwscreen->format->Aloss, + _hwscreen->format->Rshift, _hwscreen->format->Gshift, + _hwscreen->format->Bshift, _hwscreen->format->Ashift); + + // Workaround to MacOSX SDL not providing an accurate Aloss value. + if (_hwscreen->format->Amask == 0) + format.aLoss = 8; + + // Push it first, as the prefered format. + list.push_back(format); + + if (format.bShift > format.rShift) + BGR = true; + + // Mark that we don't need to do this any more. + inited = true; + } + for (int i = 0; i < listLength; i++) { if (RGBList[i].bytesPerPixel > format.bytesPerPixel) continue; -- cgit v1.2.3 From 70c138651dc71f886a4314943c4e9a753dc44607 Mon Sep 17 00:00:00 2001 From: Jody Northup Date: Fri, 10 Jul 2009 19:56:40 +0000 Subject: Whoops, and one more. svn-id: r42351 --- backends/platform/sdl/graphics.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'backends') diff --git a/backends/platform/sdl/graphics.cpp b/backends/platform/sdl/graphics.cpp index ea9c285a44..a090db01b6 100644 --- a/backends/platform/sdl/graphics.cpp +++ b/backends/platform/sdl/graphics.cpp @@ -274,7 +274,7 @@ Common::List OSystem_SDL::getSupportedFormats() { } for (int i = 0; i < listLength; i++) { - if (RGBList[i].bytesPerPixel > format.bytesPerPixel) + if (inited && (RGBList[i].bytesPerPixel > format.bytesPerPixel)) continue; if (BGR) { if (BGRList[i] != format) -- cgit v1.2.3 From cdf751accda346f5d96e3fdfa2fd4a1b92ed4d19 Mon Sep 17 00:00:00 2001 From: Jody Northup Date: Tue, 14 Jul 2009 08:27:36 +0000 Subject: changed generic Graphics::PixelFormat constructor to take xBits instead of xLoss. Modified OSystem_SDL::getSupportedFormats and ScummEngine::init to account for this change. svn-id: r42467 --- backends/platform/sdl/graphics.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'backends') diff --git a/backends/platform/sdl/graphics.cpp b/backends/platform/sdl/graphics.cpp index a090db01b6..4e47db0827 100644 --- a/backends/platform/sdl/graphics.cpp +++ b/backends/platform/sdl/graphics.cpp @@ -213,30 +213,30 @@ OSystem::TransactionError OSystem_SDL::endGFXTransaction(void) { const Graphics::PixelFormat RGBList[] = { #ifdef ENABLE_32BIT // RGBA8888, ARGB8888, RGB888 - Graphics::PixelFormat(4, 0, 0, 0, 0, 24, 16, 8, 0), - Graphics::PixelFormat(4, 0, 0, 0, 0, 16, 8, 0, 24), - Graphics::PixelFormat(3, 0, 0, 0, 8, 16, 8, 0, 0), + Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0), + Graphics::PixelFormat(4, 8, 8, 8, 8, 16, 8, 0, 24), + Graphics::PixelFormat(3, 8, 8, 8, 0, 16, 8, 0, 0), #endif // RGB565, XRGB1555, RGB555, RGBA4444, ARGB4444 - Graphics::PixelFormat(2, 3, 2, 3, 8, 11, 5, 0, 0), - Graphics::PixelFormat(2, 3, 3, 3, 7, 10, 5, 0, 15), - Graphics::PixelFormat(2, 3, 3, 3, 8, 10, 5, 0, 0), + Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0), + Graphics::PixelFormat(2, 5, 5, 5, 1, 10, 5, 0, 15), + Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0), Graphics::PixelFormat(2, 4, 4, 4, 4, 12, 8, 4, 0), Graphics::PixelFormat(2, 4, 4, 4, 4, 8, 4, 0, 12) }; const Graphics::PixelFormat BGRList[] = { #ifdef ENABLE_32BIT // ABGR8888, BGRA8888, BGR888 - Graphics::PixelFormat(4, 0, 0, 0, 0, 0, 8, 16, 24), - Graphics::PixelFormat(4, 0, 0, 0, 0, 8, 16, 24, 0), - Graphics::PixelFormat(3, 0, 0, 0, 8, 0, 8, 16, 0), + Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24), + Graphics::PixelFormat(4, 8, 8, 8, 8, 8, 16, 24, 0), + Graphics::PixelFormat(3, 8, 8, 8, 0, 0, 8, 16, 0), #endif // BGR565, XBGR1555, BGR555, ABGR4444, BGRA4444 - Graphics::PixelFormat(2, 3, 2, 3, 8, 0, 5, 11, 0), - Graphics::PixelFormat(2, 3, 3, 3, 7, 0, 5, 10, 15), - Graphics::PixelFormat(2, 3, 3, 3, 8, 0, 5, 10, 0), + Graphics::PixelFormat(2, 5, 6, 5, 0, 0, 5, 11, 0), + Graphics::PixelFormat(2, 5, 5, 5, 1, 0, 5, 10, 15), + Graphics::PixelFormat(2, 5, 5, 5, 0, 0, 5, 10, 0), Graphics::PixelFormat(2, 4, 4, 4, 4, 0, 4, 8, 12), - Graphics::PixelFormat(2, 3, 3, 3, 8, 4, 8, 12, 0) + Graphics::PixelFormat(2, 4, 4, 4, 4, 4, 8, 12, 0) }; // TODO: prioritize matching alpha masks -- cgit v1.2.3 From 52a160657f4db676e30b6d52abbf513154aad662 Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Sun, 19 Jul 2009 15:00:39 +0000 Subject: Fix 16bit color when using the hardware screen's pixel format. The call was never updated after r42467. svn-id: r42617 --- backends/platform/sdl/graphics.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'backends') diff --git a/backends/platform/sdl/graphics.cpp b/backends/platform/sdl/graphics.cpp index 4e47db0827..6d9f3fc6eb 100644 --- a/backends/platform/sdl/graphics.cpp +++ b/backends/platform/sdl/graphics.cpp @@ -254,8 +254,8 @@ Common::List OSystem_SDL::getSupportedFormats() { if (_hwscreen) { // Get our currently set hardware format format = Graphics::PixelFormat(_hwscreen->format->BytesPerPixel, - _hwscreen->format->Rloss, _hwscreen->format->Gloss, - _hwscreen->format->Bloss, _hwscreen->format->Aloss, + 8 - _hwscreen->format->Rloss, 8 - _hwscreen->format->Gloss, + 8 - _hwscreen->format->Bloss, 8 - _hwscreen->format->Aloss, _hwscreen->format->Rshift, _hwscreen->format->Gshift, _hwscreen->format->Bshift, _hwscreen->format->Ashift); -- cgit v1.2.3 From 8062d37283bcf8390d8fb66cce99c2bfd65668d8 Mon Sep 17 00:00:00 2001 From: Jody Northup Date: Wed, 5 Aug 2009 21:32:42 +0000 Subject: Some groundwork for a better implementation of modifier keys. (incomplete, and breaks previous implementation) svn-id: r43078 --- backends/keymapper/hardware-key.h | 40 +++++ backends/keymapper/types.h | 1 + backends/platform/sdl/hardwarekeys.cpp | 302 +++++++++++++++++---------------- 3 files changed, 194 insertions(+), 149 deletions(-) (limited to 'backends') diff --git a/backends/keymapper/hardware-key.h b/backends/keymapper/hardware-key.h index 8ddeada51e..c8c1d3c145 100644 --- a/backends/keymapper/hardware-key.h +++ b/backends/keymapper/hardware-key.h @@ -64,6 +64,29 @@ struct HardwareKey { } }; +/** +* Describes an available hardware modifier +*/ +struct HardwareMod { + /** unique id used for saving/loading to config */ + char hwModId[HWKEY_ID_SIZE]; + + /** Human readable description */ + String description; + + /** + * The modifier flags that are generated by the + * back-end when this modifier key is pressed. + */ + byte modFlags; + + HardwareMod(const char *i, byte mf, String desc = "") + : modFlags(mf), description(desc) { + assert(i); + strncpy(hwModId, i, HWKEY_ID_SIZE); + } +}; + /** * Simple class to encapsulate a device's set of HardwareKeys. @@ -80,6 +103,11 @@ public: delete *it; } + void addHardwareMod(HardwareMod *mod) { + checkForMod(mod); + _mods.push_back(mod); + } + void addHardwareKey(HardwareKey *key) { checkForKey(key); _keys.push_back(key); @@ -127,7 +155,19 @@ private: } } + void checkForMod(HardwareMod *mod) { + List::iterator it; + + for (it = _mods.begin(); it != _mods.end(); it++) { + if (strncmp((*it)->hwModId, mod->hwModId, HWKEY_ID_SIZE) == 0) + error("Error adding HardwareMod '%s' - id of %s already in use!", mod->description.c_str(), mod->hwModId); + else if ((*it)->modFlags == mod->modFlags) + error("Error adding HardwareMod '%s' - modFlags already in use!", mod->description.c_str()); + } + } + List _keys; + List _mods; }; diff --git a/backends/keymapper/types.h b/backends/keymapper/types.h index 7ad4c0e538..004a90bfcd 100644 --- a/backends/keymapper/types.h +++ b/backends/keymapper/types.h @@ -43,6 +43,7 @@ enum KeyType { kTriggerRightKeyType, kStartKeyType, kSelectKeyType, +// kModiferKeyType, /* ... */ kKeyTypeMax diff --git a/backends/platform/sdl/hardwarekeys.cpp b/backends/platform/sdl/hardwarekeys.cpp index 1a8124bbf3..bba48286f0 100644 --- a/backends/platform/sdl/hardwarekeys.cpp +++ b/backends/platform/sdl/hardwarekeys.cpp @@ -37,161 +37,170 @@ struct Key { uint16 ascii; const char *desc; KeyType preferredAction; - bool shiftable; + int32 modableMask; }; static const Key keys[] = { - {"BACKSPACE", KEYCODE_BACKSPACE, ASCII_BACKSPACE, "Backspace", kActionKeyType, false}, - {"TAB", KEYCODE_TAB, ASCII_TAB, "Tab", kActionKeyType, false}, - {"CLEAR", KEYCODE_CLEAR, 0, "Clear", kActionKeyType, false}, - {"RETURN", KEYCODE_RETURN, ASCII_RETURN, "Return", kActionKeyType, false}, - {"PAUSE", KEYCODE_PAUSE, 0, "Pause", kActionKeyType, false}, - {"ESCAPE", KEYCODE_ESCAPE, ASCII_ESCAPE, "Esc", kStartKeyType, false}, - {"SPACE", KEYCODE_SPACE, ASCII_SPACE, "Space", kActionKeyType, false}, - {"EXCLAIM", KEYCODE_EXCLAIM, '!', "!", kActionKeyType, false}, - {"QUOTEDBL", KEYCODE_QUOTEDBL, '"', "\"", kActionKeyType, false}, - {"HASH", KEYCODE_HASH, '#', "#", kActionKeyType, false}, - {"DOLLAR", KEYCODE_DOLLAR, '$', "$", kActionKeyType, false}, - {"AMPERSAND", KEYCODE_AMPERSAND, '&', "&", kActionKeyType, false}, - {"QUOTE", KEYCODE_QUOTE, '\'', "'", kActionKeyType, false}, - {"LEFTPAREN", KEYCODE_LEFTPAREN, '(', "(", kActionKeyType, false}, - {"RIGHTPAREN", KEYCODE_RIGHTPAREN, ')', ")", kActionKeyType, false}, - {"ASTERISK", KEYCODE_ASTERISK, '*', "*", kActionKeyType, false}, - {"PLUS", KEYCODE_PLUS, '+', "+", kActionKeyType, false}, - {"COMMA", KEYCODE_COMMA, ',', ",", kActionKeyType, false}, - {"MINUS", KEYCODE_MINUS, '-', "-", kActionKeyType, false}, - {"PERIOD", KEYCODE_PERIOD, '.', ".", kActionKeyType, false}, - {"SLASH", KEYCODE_SLASH, '/', "/", kActionKeyType, false}, - {"0", KEYCODE_0, '0', "0", kActionKeyType, false}, - {"1", KEYCODE_1, '1', "1", kActionKeyType, false}, - {"2", KEYCODE_2, '2', "2", kActionKeyType, false}, - {"3", KEYCODE_3, '3', "3", kActionKeyType, false}, - {"4", KEYCODE_4, '4', "4", kActionKeyType, false}, - {"5", KEYCODE_5, '5', "5", kActionKeyType, false}, - {"6", KEYCODE_6, '6', "6", kActionKeyType, false}, - {"7", KEYCODE_7, '7', "7", kActionKeyType, false}, - {"8", KEYCODE_8, '8', "8", kActionKeyType, false}, - {"9", KEYCODE_9, '9', "9", kActionKeyType, false}, - {"COLON", KEYCODE_COLON, ':', ":", kActionKeyType, false}, - {"SEMICOLON", KEYCODE_SEMICOLON, ';', ";", kActionKeyType, false}, - {"LESS", KEYCODE_LESS, '<', "<", kActionKeyType, false}, - {"EQUALS", KEYCODE_EQUALS, '=', "=", kActionKeyType, false}, - {"GREATER", KEYCODE_GREATER, '>', ">", kActionKeyType, false}, - {"QUESTION", KEYCODE_QUESTION, '?', "?", kActionKeyType, false}, - {"AT", KEYCODE_AT, '@', "@", kActionKeyType, false}, - - {"LEFTBRACKET", KEYCODE_LEFTBRACKET, '[', "[", kActionKeyType, false}, - {"BACKSLASH", KEYCODE_BACKSLASH, '\\', "\\", kActionKeyType, false}, - {"RIGHTBRACKET", KEYCODE_RIGHTBRACKET, ']', "]", kActionKeyType, false}, - {"CARET", KEYCODE_CARET, '^', "^", kActionKeyType, false}, - {"UNDERSCORE", KEYCODE_UNDERSCORE, '_', "_", kActionKeyType, false}, - {"BACKQUOTE", KEYCODE_BACKQUOTE, '`', "`", kActionKeyType, false}, - {"a", KEYCODE_a, 'a', "a", kActionKeyType, true}, - {"b", KEYCODE_b, 'b', "b", kActionKeyType, true}, - {"c", KEYCODE_c, 'c', "c", kActionKeyType, true}, - {"d", KEYCODE_d, 'd', "d", kActionKeyType, true}, - {"e", KEYCODE_e, 'e', "e", kActionKeyType, true}, - {"f", KEYCODE_f, 'f', "f", kActionKeyType, true}, - {"g", KEYCODE_g, 'g', "g", kActionKeyType, true}, - {"h", KEYCODE_h, 'h', "h", kActionKeyType, true}, - {"i", KEYCODE_i, 'i', "i", kActionKeyType, true}, - {"j", KEYCODE_j, 'j', "j", kActionKeyType, true}, - {"k", KEYCODE_k, 'k', "k", kActionKeyType, true}, - {"l", KEYCODE_l, 'l', "l", kActionKeyType, true}, - {"m", KEYCODE_m, 'm', "m", kActionKeyType, true}, - {"n", KEYCODE_n, 'n', "n", kActionKeyType, true}, - {"o", KEYCODE_o, 'o', "o", kActionKeyType, true}, - {"p", KEYCODE_p, 'p', "p", kActionKeyType, true}, - {"q", KEYCODE_q, 'q', "q", kActionKeyType, true}, - {"r", KEYCODE_r, 'r', "r", kActionKeyType, true}, - {"s", KEYCODE_s, 's', "s", kActionKeyType, true}, - {"t", KEYCODE_t, 't', "t", kActionKeyType, true}, - {"u", KEYCODE_u, 'u', "u", kActionKeyType, true}, - {"v", KEYCODE_v, 'v', "v", kActionKeyType, true}, - {"w", KEYCODE_w, 'w', "w", kActionKeyType, true}, - {"x", KEYCODE_x, 'x', "x", kActionKeyType, true}, - {"y", KEYCODE_y, 'y', "y", kActionKeyType, true}, - {"z", KEYCODE_z, 'z', "z", kActionKeyType, true}, - {"DELETE", KEYCODE_DELETE, 0, "Del", kActionKeyType, false}, + {"BACKSPACE", KEYCODE_BACKSPACE, ASCII_BACKSPACE, "Backspace", kActionKeyType, ~0}, + {"TAB", KEYCODE_TAB, ASCII_TAB, "Tab", kActionKeyType, ~0}, + {"CLEAR", KEYCODE_CLEAR, 0, "Clear", kActionKeyType, ~0}, + {"RETURN", KEYCODE_RETURN, ASCII_RETURN, "Return", kActionKeyType, ~0}, + {"PAUSE", KEYCODE_PAUSE, 0, "Pause", kActionKeyType, ~0}, + {"ESCAPE", KEYCODE_ESCAPE, ASCII_ESCAPE, "Esc", kStartKeyType, ~0}, + {"SPACE", KEYCODE_SPACE, ASCII_SPACE, "Space", kActionKeyType, ~0}, + {"EXCLAIM", KEYCODE_EXCLAIM, '!', "!", kActionKeyType, ~0}, + {"QUOTEDBL", KEYCODE_QUOTEDBL, '"', "\"", kActionKeyType, ~0}, + {"HASH", KEYCODE_HASH, '#', "#", kActionKeyType, ~0}, + {"DOLLAR", KEYCODE_DOLLAR, '$', "$", kActionKeyType, ~0}, + {"AMPERSAND", KEYCODE_AMPERSAND, '&', "&", kActionKeyType, ~0}, + {"QUOTE", KEYCODE_QUOTE, '\'', "'", kActionKeyType, ~0}, + {"LEFTPAREN", KEYCODE_LEFTPAREN, '(', "(", kActionKeyType, ~0}, + {"RIGHTPAREN", KEYCODE_RIGHTPAREN, ')', ")", kActionKeyType, ~0}, + {"ASTERISK", KEYCODE_ASTERISK, '*', "*", kActionKeyType, ~0}, + {"PLUS", KEYCODE_PLUS, '+', "+", kActionKeyType, ~0}, + {"COMMA", KEYCODE_COMMA, ',', ",", kActionKeyType, ~0}, + {"MINUS", KEYCODE_MINUS, '-', "-", kActionKeyType, ~0}, + {"PERIOD", KEYCODE_PERIOD, '.', ".", kActionKeyType, ~0}, + {"SLASH", KEYCODE_SLASH, '/', "/", kActionKeyType, ~0}, + {"0", KEYCODE_0, '0', "0", kActionKeyType, ~0}, + {"1", KEYCODE_1, '1', "1", kActionKeyType, ~0}, + {"2", KEYCODE_2, '2', "2", kActionKeyType, ~0}, + {"3", KEYCODE_3, '3', "3", kActionKeyType, ~0}, + {"4", KEYCODE_4, '4', "4", kActionKeyType, ~0}, + {"5", KEYCODE_5, '5', "5", kActionKeyType, ~0}, + {"6", KEYCODE_6, '6', "6", kActionKeyType, ~0}, + {"7", KEYCODE_7, '7', "7", kActionKeyType, ~0}, + {"8", KEYCODE_8, '8', "8", kActionKeyType, ~0}, + {"9", KEYCODE_9, '9', "9", kActionKeyType, ~0}, + {"COLON", KEYCODE_COLON, ':', ":", kActionKeyType, ~0}, + {"SEMICOLON", KEYCODE_SEMICOLON, ';', ";", kActionKeyType, ~0}, + {"LESS", KEYCODE_LESS, '<', "<", kActionKeyType, ~0}, + {"EQUALS", KEYCODE_EQUALS, '=', "=", kActionKeyType, ~0}, + {"GREATER", KEYCODE_GREATER, '>', ">", kActionKeyType, ~0}, + {"QUESTION", KEYCODE_QUESTION, '?', "?", kActionKeyType, ~0}, + {"AT", KEYCODE_AT, '@', "@", kActionKeyType, ~0}, + + {"LEFTBRACKET", KEYCODE_LEFTBRACKET, '[', "[", kActionKeyType, ~0}, + {"BACKSLASH", KEYCODE_BACKSLASH, '\\', "\\", kActionKeyType, ~0}, + {"RIGHTBRACKET", KEYCODE_RIGHTBRACKET, ']', "]", kActionKeyType, ~0}, + {"CARET", KEYCODE_CARET, '^', "^", kActionKeyType, ~0}, + {"UNDERSCORE", KEYCODE_UNDERSCORE, '_', "_", kActionKeyType, ~0}, + {"BACKQUOTE", KEYCODE_BACKQUOTE, '`', "`", kActionKeyType, ~0}, + {"a", KEYCODE_a, 'A', "A", kActionKeyType, ~0}, + {"b", KEYCODE_b, 'B', "B", kActionKeyType, ~0}, + {"c", KEYCODE_c, 'C', "C", kActionKeyType, ~0}, + {"d", KEYCODE_d, 'D', "D", kActionKeyType, ~0}, + {"e", KEYCODE_e, 'E', "E", kActionKeyType, ~0}, + {"f", KEYCODE_f, 'F', "F", kActionKeyType, ~0}, + {"g", KEYCODE_g, 'G', "G", kActionKeyType, ~0}, + {"h", KEYCODE_h, 'H', "H", kActionKeyType, ~0}, + {"i", KEYCODE_i, 'I', "I", kActionKeyType, ~0}, + {"j", KEYCODE_j, 'J', "J", kActionKeyType, ~0}, + {"k", KEYCODE_k, 'K', "K", kActionKeyType, ~0}, + {"l", KEYCODE_l, 'L', "L", kActionKeyType, ~0}, + {"m", KEYCODE_m, 'M', "M", kActionKeyType, ~0}, + {"n", KEYCODE_n, 'N', "N", kActionKeyType, ~0}, + {"o", KEYCODE_o, 'O', "O", kActionKeyType, ~0}, + {"p", KEYCODE_p, 'P', "P", kActionKeyType, ~0}, + {"q", KEYCODE_q, 'Q', "Q", kActionKeyType, ~0}, + {"r", KEYCODE_r, 'R', "R", kActionKeyType, ~0}, + {"s", KEYCODE_s, 'S', "S", kActionKeyType, ~0}, + {"t", KEYCODE_t, 'T', "T", kActionKeyType, ~0}, + {"u", KEYCODE_u, 'U', "U", kActionKeyType, ~0}, + {"v", KEYCODE_v, 'V', "V", kActionKeyType, ~0}, + {"w", KEYCODE_w, 'W', "W", kActionKeyType, ~0}, + {"x", KEYCODE_x, 'X', "X", kActionKeyType, ~0}, + {"y", KEYCODE_y, 'Y', "Y", kActionKeyType, ~0}, + {"z", KEYCODE_z, 'Z', "Z", kActionKeyType, ~0}, + {"DELETE", KEYCODE_DELETE, 0, "Del", kActionKeyType, ~0}, // Numeric keypad - {"KP0", KEYCODE_KP0, 0, "KP0", kActionKeyType, false}, - {"KP1", KEYCODE_KP1, 0, "KP1", kActionKeyType, false}, - {"KP2", KEYCODE_KP2, 0, "KP2", kActionKeyType, false}, - {"KP3", KEYCODE_KP3, 0, "KP3", kActionKeyType, false}, - {"KP4", KEYCODE_KP4, 0, "KP4", kActionKeyType, false}, - {"KP5", KEYCODE_KP5, 0, "KP5", kActionKeyType, false}, - {"KP6", KEYCODE_KP6, 0, "KP6", kActionKeyType, false}, - {"KP7", KEYCODE_KP7, 0, "KP7", kActionKeyType, false}, - {"KP8", KEYCODE_KP8, 0, "KP8", kActionKeyType, false}, - {"KP9", KEYCODE_KP9, 0, "KP9", kActionKeyType, false}, - {"KP_PERIOD", KEYCODE_KP_PERIOD, 0, "KP.", kActionKeyType, false}, - {"KP_DIVIDE", KEYCODE_KP_DIVIDE, 0, "KP/", kActionKeyType, false}, - {"KP_MULTIPLY", KEYCODE_KP_MULTIPLY, 0, "KP*", kActionKeyType, false}, - {"KP_MINUS", KEYCODE_KP_MINUS, 0, "KP-", kActionKeyType, false}, - {"KP_PLUS", KEYCODE_KP_PLUS, 0, "KP+", kActionKeyType, false}, - {"KP_ENTER", KEYCODE_KP_ENTER, 0, "KP Enter", kActionKeyType, false}, - {"KP_EQUALS", KEYCODE_KP_EQUALS, 0, "KP=", kActionKeyType, false}, + {"KP0", KEYCODE_KP0, 0, "KP0", kActionKeyType, ~0}, + {"KP1", KEYCODE_KP1, 0, "KP1", kActionKeyType, ~0}, + {"KP2", KEYCODE_KP2, 0, "KP2", kActionKeyType, ~0}, + {"KP3", KEYCODE_KP3, 0, "KP3", kActionKeyType, ~0}, + {"KP4", KEYCODE_KP4, 0, "KP4", kActionKeyType, ~0}, + {"KP5", KEYCODE_KP5, 0, "KP5", kActionKeyType, ~0}, + {"KP6", KEYCODE_KP6, 0, "KP6", kActionKeyType, ~0}, + {"KP7", KEYCODE_KP7, 0, "KP7", kActionKeyType, ~0}, + {"KP8", KEYCODE_KP8, 0, "KP8", kActionKeyType, ~0}, + {"KP9", KEYCODE_KP9, 0, "KP9", kActionKeyType, ~0}, + {"KP_PERIOD", KEYCODE_KP_PERIOD, 0, "KP.", kActionKeyType, ~0}, + {"KP_DIVIDE", KEYCODE_KP_DIVIDE, 0, "KP/", kActionKeyType, ~0}, + {"KP_MULTIPLY", KEYCODE_KP_MULTIPLY, 0, "KP*", kActionKeyType, ~0}, + {"KP_MINUS", KEYCODE_KP_MINUS, 0, "KP-", kActionKeyType, ~0}, + {"KP_PLUS", KEYCODE_KP_PLUS, 0, "KP+", kActionKeyType, ~0}, + {"KP_ENTER", KEYCODE_KP_ENTER, 0, "KP Enter", kActionKeyType, ~0}, + {"KP_EQUALS", KEYCODE_KP_EQUALS, 0, "KP=", kActionKeyType, ~0}, // Arrows + Home/End pad - {"UP", KEYCODE_UP, 0, "Up", kDirUpKeyType, false}, - {"DOWN", KEYCODE_DOWN, 0, "Down", kDirDownKeyType, false}, - {"RIGHT", KEYCODE_RIGHT, 0, "Right", kDirRightKeyType, false}, - {"LEFT", KEYCODE_LEFT, 0, "Left", kDirLeftKeyType, false}, - {"INSERT", KEYCODE_INSERT, 0, "Insert", kActionKeyType, false}, - {"HOME", KEYCODE_HOME, 0, "Home", kActionKeyType, false}, - {"END", KEYCODE_END, 0, "End", kActionKeyType, false}, - {"PAGEUP", KEYCODE_PAGEUP, 0, "PgUp", kActionKeyType, false}, - {"PAGEDOWN", KEYCODE_PAGEDOWN, 0, "PgDn", kActionKeyType, false}, + {"UP", KEYCODE_UP, 0, "Up", kDirUpKeyType, ~0}, + {"DOWN", KEYCODE_DOWN, 0, "Down", kDirDownKeyType, ~0}, + {"RIGHT", KEYCODE_RIGHT, 0, "Right", kDirRightKeyType, ~0}, + {"LEFT", KEYCODE_LEFT, 0, "Left", kDirLeftKeyType, ~0}, + {"INSERT", KEYCODE_INSERT, 0, "Insert", kActionKeyType, ~0}, + {"HOME", KEYCODE_HOME, 0, "Home", kActionKeyType, ~0}, + {"END", KEYCODE_END, 0, "End", kActionKeyType, ~0}, + {"PAGEUP", KEYCODE_PAGEUP, 0, "PgUp", kActionKeyType, ~0}, + {"PAGEDOWN", KEYCODE_PAGEDOWN, 0, "PgDn", kActionKeyType, ~0}, // Function keys - {"F1", KEYCODE_F1, ASCII_F1, "F1", kActionKeyType, false}, - {"F2", KEYCODE_F2, ASCII_F2, "F2", kActionKeyType, false}, - {"F3", KEYCODE_F3, ASCII_F3, "F3", kActionKeyType, false}, - {"F4", KEYCODE_F4, ASCII_F4, "F4", kActionKeyType, false}, - {"F5", KEYCODE_F5, ASCII_F5, "F5", kActionKeyType, false}, - {"F6", KEYCODE_F6, ASCII_F6, "F6", kActionKeyType, false}, - {"F7", KEYCODE_F7, ASCII_F7, "F7", kActionKeyType, false}, - {"F8", KEYCODE_F8, ASCII_F8, "F8", kActionKeyType, false}, - {"F9", KEYCODE_F9, ASCII_F9, "F9", kActionKeyType, false}, - {"F10", KEYCODE_F10, ASCII_F10, "F10", kActionKeyType, false}, - {"F11", KEYCODE_F11, ASCII_F11, "F11", kActionKeyType, false}, - {"F12", KEYCODE_F12, ASCII_F12, "F12", kActionKeyType, false}, - {"F13", KEYCODE_F13, 0, "F13", kActionKeyType, false}, - {"F14", KEYCODE_F14, 0, "F14", kActionKeyType, false}, - {"F15", KEYCODE_F15, 0, "F15", kActionKeyType, false}, + {"F1", KEYCODE_F1, ASCII_F1, "F1", kActionKeyType, ~0}, + {"F2", KEYCODE_F2, ASCII_F2, "F2", kActionKeyType, ~0}, + {"F3", KEYCODE_F3, ASCII_F3, "F3", kActionKeyType, ~0}, + {"F4", KEYCODE_F4, ASCII_F4, "F4", kActionKeyType, ~0}, + {"F5", KEYCODE_F5, ASCII_F5, "F5", kActionKeyType, ~0}, + {"F6", KEYCODE_F6, ASCII_F6, "F6", kActionKeyType, ~0}, + {"F7", KEYCODE_F7, ASCII_F7, "F7", kActionKeyType, ~0}, + {"F8", KEYCODE_F8, ASCII_F8, "F8", kActionKeyType, ~0}, + {"F9", KEYCODE_F9, ASCII_F9, "F9", kActionKeyType, ~0}, + {"F10", KEYCODE_F10, ASCII_F10, "F10", kActionKeyType, ~0}, + {"F11", KEYCODE_F11, ASCII_F11, "F11", kActionKeyType, ~0}, + {"F12", KEYCODE_F12, ASCII_F12, "F12", kActionKeyType, ~0}, + {"F13", KEYCODE_F13, 0, "F13", kActionKeyType, ~0}, + {"F14", KEYCODE_F14, 0, "F14", kActionKeyType, ~0}, + {"F15", KEYCODE_F15, 0, "F15", kActionKeyType, ~0}, + + +// // Modifier keys pressed alone +// {"RSHIFT", KEYCODE_RSHIFT, 0, "Right Shift", kModiferKeyType, ~KBD_SHIFT}, +// {"LSHIFT", KEYCODE_LSHIFT, 0, "Left Shift", kModiferKeyType, ~KBD_SHIFT}, +// {"RCTRL", KEYCODE_RCTRL, 0, "Right Ctrl", kModiferKeyType, ~KBD_CTRL}, +// {"LCTRL", KEYCODE_LCTRL, 0, "Left Ctrl", kModiferKeyType, ~KBD_CTRL}, +// {"RALT", KEYCODE_RALT, 0, "Right Alt", kModiferKeyType, ~KBD_ALT}, +// {"LALT", KEYCODE_LALT, 0, "Left Alt", kModiferKeyType, ~KBD_ALT}, + // Miscellaneous function keys - {"HELP", KEYCODE_HELP, 0, "Help", kActionKeyType, false}, - {"PRINT", KEYCODE_PRINT, 0, "Print", kActionKeyType, false}, - {"SYSREQ", KEYCODE_SYSREQ, 0, "SysRq", kActionKeyType, false}, - {"BREAK", KEYCODE_BREAK, 0, "Break", kActionKeyType, false}, - {"MENU", KEYCODE_MENU, 0, "Menu", kActionKeyType, false}, + {"HELP", KEYCODE_HELP, 0, "Help", kActionKeyType, ~0}, + {"PRINT", KEYCODE_PRINT, 0, "Print", kActionKeyType, ~0}, + {"SYSREQ", KEYCODE_SYSREQ, 0, "SysRq", kActionKeyType, ~0}, + {"BREAK", KEYCODE_BREAK, 0, "Break", kActionKeyType, ~0}, + {"MENU", KEYCODE_MENU, 0, "Menu", kActionKeyType, ~0}, // Power Macintosh power key - {"POWER", KEYCODE_POWER, 0, "Power", kActionKeyType, false}, + {"POWER", KEYCODE_POWER, 0, "Power", kActionKeyType, ~0}, // Some european keyboards - {"EURO", KEYCODE_EURO, 0, "Euro", kActionKeyType, false}, + {"EURO", KEYCODE_EURO, 0, "Euro", kActionKeyType, ~0}, // Atari keyboard has Undo - {"UNDO", KEYCODE_UNDO, 0, "Undo", kActionKeyType, false}, - {0, KEYCODE_INVALID, 0, 0, kGenericKeyType, false} + {"UNDO", KEYCODE_UNDO, 0, "Undo", kActionKeyType, ~0}, + {0, KEYCODE_INVALID, 0, 0, kGenericKeyType, ~0} }; struct Mod { byte flag; const char *id; const char *desc; - bool shiftable; }; static const Mod modifiers[] = { - { 0, "", "", false }, - { KBD_CTRL, "C+", "Ctrl+", false }, - { KBD_ALT, "A+", "Alt+", false }, - { KBD_SHIFT, "", "", true }, - { KBD_CTRL | KBD_ALT, "C+A+", "Ctrl+Alt+", false }, - { KBD_SHIFT | KBD_CTRL, "S+C+", "Shift+Ctrl+", true }, - { KBD_SHIFT | KBD_CTRL | KBD_ALT, "C+A+", "Ctrl+Alt+", true }, - { 0, 0, 0, false } + { 0, "", "" }, + { KBD_CTRL, "C+", "Ctrl+" }, + { KBD_ALT, "A+", "Alt+" }, + { KBD_SHIFT, "S+", "Shift+" }, + { KBD_CTRL | KBD_ALT, "C+A+", "Ctrl+Alt+" }, + { KBD_SHIFT | KBD_CTRL, "S+C+", "Shift+Ctrl+" }, + { KBD_SHIFT | KBD_CTRL | KBD_ALT, "S+C+A+", "Shift+Ctrl+Alt+" }, + { 0, 0, 0 } }; #endif @@ -206,23 +215,18 @@ Common::HardwareKeySet *OSystem_SDL::getHardwareKeySet() { uint16 ascii; for (mod = modifiers; mod->id; mod++) { - for (key = keys; key->hwId; key++) { - ascii = key->ascii; - - if (mod->shiftable && key->shiftable) { - snprintf(fullKeyId, 50, "%s%c", mod->id, toupper(key->hwId[0])); - snprintf(fullKeyDesc, 100, "%s%c", mod->desc, toupper(key->desc[0])); - ascii = toupper(key->ascii); - } else if (mod->shiftable) { - snprintf(fullKeyId, 50, "S+%s%s", mod->id, key->hwId); - snprintf(fullKeyDesc, 100, "Shift+%s%s", mod->desc, key->desc); - } else { - snprintf(fullKeyId, 50, "%s%s", mod->id, key->hwId); - snprintf(fullKeyDesc, 100, "%s%s", mod->desc, key->desc); - } - - keySet->addHardwareKey(new HardwareKey(fullKeyId, KeyState(key->keycode, ascii, mod->flag), fullKeyDesc, key->preferredAction )); - } + snprintf(fullKeyId, 50, "S+%s", mod->id); + snprintf(fullKeyDesc, 100, "Shift+%s", mod->desc); + + keySet->addHardwareMod(new HardwareMod(fullKeyId, mod->flag, fullKeyDesc)); + } + for (key = keys; key->hwId; key++) { + ascii = key->ascii; + + snprintf(fullKeyId, 50, "%s", key->hwId); + snprintf(fullKeyDesc, 100, "%s", key->desc); + + keySet->addHardwareKey(new HardwareKey(fullKeyId, KeyState(key->keycode, ascii, 0), fullKeyDesc, key->preferredAction)); } return keySet; -- cgit v1.2.3 From e0e09e43b84cf9637fb289bd466235116674c1f2 Mon Sep 17 00:00:00 2001 From: Jody Northup Date: Fri, 7 Aug 2009 01:17:57 +0000 Subject: key remap dialog correctly reads keystrokes again, and can tell modified keys from unmodified keys (but does not yet print modifier prefixes, and actions mapped to modified keys still do not trigger) svn-id: r43091 --- backends/keymapper/hardware-key.h | 22 +++++++++++++- backends/keymapper/keymapper.cpp | 4 +++ backends/keymapper/keymapper.h | 5 ++++ backends/keymapper/remap-dialog.cpp | 6 +++- backends/platform/sdl/hardwarekeys.cpp | 52 +++++++++++++++++----------------- 5 files changed, 61 insertions(+), 28 deletions(-) (limited to 'backends') diff --git a/backends/keymapper/hardware-key.h b/backends/keymapper/hardware-key.h index c8c1d3c145..34631a9484 100644 --- a/backends/keymapper/hardware-key.h +++ b/backends/keymapper/hardware-key.h @@ -127,7 +127,27 @@ public: List::const_iterator it; for (it = _keys.begin(); it != _keys.end(); it++) { - if ((*it)->key == keystate) + if ((*it)->key.keycode == keystate.keycode) + return (*it); + } + return 0; + } + + const HardwareMod *findHardwareMod(const char *id) const { + List::const_iterator it; + + for (it = _mods.begin(); it != _mods.end(); it++) { + if (strncmp((*it)->hwModId, id, HWKEY_ID_SIZE) == 0) + return (*it); + } + return 0; + } + + const HardwareMod *findHardwareMod(const KeyState& keystate) const { + List::const_iterator it; + + for (it = _mods.begin(); it != _mods.end(); it++) { + if ((*it)->modFlags == keystate.flags) return (*it); } return 0; diff --git a/backends/keymapper/keymapper.cpp b/backends/keymapper/keymapper.cpp index c0c454168c..a121ebafee 100644 --- a/backends/keymapper/keymapper.cpp +++ b/backends/keymapper/keymapper.cpp @@ -272,6 +272,10 @@ const HardwareKey *Keymapper::findHardwareKey(const KeyState& key) { return (_hardwareKeys) ? _hardwareKeys->findHardwareKey(key) : 0; } +const HardwareMod *Keymapper::findHardwareMod(const KeyState& key) { + return (_hardwareKeys) ? _hardwareKeys->findHardwareMod(key) : 0; +} + } // end of namespace Common #endif // #ifdef ENABLE_KEYMAPPER diff --git a/backends/keymapper/keymapper.h b/backends/keymapper/keymapper.h index f492882ca2..af3314f8f5 100644 --- a/backends/keymapper/keymapper.h +++ b/backends/keymapper/keymapper.h @@ -170,6 +170,11 @@ public: */ const HardwareKey *findHardwareKey(const KeyState& key); + /** + * Return a HardwareMod pointer for the given key state + */ + const HardwareMod *findHardwareMod(const KeyState& key); + Domain& getGlobalDomain() { return _globalDomain; } Domain& getGameDomain() { return _gameDomain; } const Stack& getActiveStack() const { return _activeMaps; } diff --git a/backends/keymapper/remap-dialog.cpp b/backends/keymapper/remap-dialog.cpp index 0440acdd0a..9341c82747 100644 --- a/backends/keymapper/remap-dialog.cpp +++ b/backends/keymapper/remap-dialog.cpp @@ -239,11 +239,15 @@ void RemapDialog::handleKeyDown(Common::KeyState state) { void RemapDialog::handleKeyUp(Common::KeyState state) { if (_activeRemapAction) { const HardwareKey *hwkey = _keymapper->findHardwareKey(state); + const HardwareMod *hwmod = _keymapper->findHardwareMod(state); debug(0, "Key: %d, %d (%c), %x", state.keycode, state.ascii, (state.ascii ? state.ascii : ' '), state.flags); if (hwkey) { - _activeRemapAction->mapKey(hwkey); + HardwareKey *temphwkey = new HardwareKey(*hwkey); + temphwkey->description = hwkey->description; + temphwkey->key.flags = hwmod->modFlags; + _activeRemapAction->mapKey(temphwkey); _activeRemapAction->getParent()->saveMappings(); _changes = true; stopRemapping(); diff --git a/backends/platform/sdl/hardwarekeys.cpp b/backends/platform/sdl/hardwarekeys.cpp index bba48286f0..c063ea5bff 100644 --- a/backends/platform/sdl/hardwarekeys.cpp +++ b/backends/platform/sdl/hardwarekeys.cpp @@ -86,32 +86,32 @@ static const Key keys[] = { {"CARET", KEYCODE_CARET, '^', "^", kActionKeyType, ~0}, {"UNDERSCORE", KEYCODE_UNDERSCORE, '_', "_", kActionKeyType, ~0}, {"BACKQUOTE", KEYCODE_BACKQUOTE, '`', "`", kActionKeyType, ~0}, - {"a", KEYCODE_a, 'A', "A", kActionKeyType, ~0}, - {"b", KEYCODE_b, 'B', "B", kActionKeyType, ~0}, - {"c", KEYCODE_c, 'C', "C", kActionKeyType, ~0}, - {"d", KEYCODE_d, 'D', "D", kActionKeyType, ~0}, - {"e", KEYCODE_e, 'E', "E", kActionKeyType, ~0}, - {"f", KEYCODE_f, 'F', "F", kActionKeyType, ~0}, - {"g", KEYCODE_g, 'G', "G", kActionKeyType, ~0}, - {"h", KEYCODE_h, 'H', "H", kActionKeyType, ~0}, - {"i", KEYCODE_i, 'I', "I", kActionKeyType, ~0}, - {"j", KEYCODE_j, 'J', "J", kActionKeyType, ~0}, - {"k", KEYCODE_k, 'K', "K", kActionKeyType, ~0}, - {"l", KEYCODE_l, 'L', "L", kActionKeyType, ~0}, - {"m", KEYCODE_m, 'M', "M", kActionKeyType, ~0}, - {"n", KEYCODE_n, 'N', "N", kActionKeyType, ~0}, - {"o", KEYCODE_o, 'O', "O", kActionKeyType, ~0}, - {"p", KEYCODE_p, 'P', "P", kActionKeyType, ~0}, - {"q", KEYCODE_q, 'Q', "Q", kActionKeyType, ~0}, - {"r", KEYCODE_r, 'R', "R", kActionKeyType, ~0}, - {"s", KEYCODE_s, 'S', "S", kActionKeyType, ~0}, - {"t", KEYCODE_t, 'T', "T", kActionKeyType, ~0}, - {"u", KEYCODE_u, 'U', "U", kActionKeyType, ~0}, - {"v", KEYCODE_v, 'V', "V", kActionKeyType, ~0}, - {"w", KEYCODE_w, 'W', "W", kActionKeyType, ~0}, - {"x", KEYCODE_x, 'X', "X", kActionKeyType, ~0}, - {"y", KEYCODE_y, 'Y', "Y", kActionKeyType, ~0}, - {"z", KEYCODE_z, 'Z', "Z", kActionKeyType, ~0}, + {"a", KEYCODE_a, 'a', "A", kActionKeyType, ~0}, + {"b", KEYCODE_b, 'b', "B", kActionKeyType, ~0}, + {"c", KEYCODE_c, 'c', "C", kActionKeyType, ~0}, + {"d", KEYCODE_d, 'd', "D", kActionKeyType, ~0}, + {"e", KEYCODE_e, 'e', "E", kActionKeyType, ~0}, + {"f", KEYCODE_f, 'f', "F", kActionKeyType, ~0}, + {"g", KEYCODE_g, 'g', "G", kActionKeyType, ~0}, + {"h", KEYCODE_h, 'h', "H", kActionKeyType, ~0}, + {"i", KEYCODE_i, 'i', "I", kActionKeyType, ~0}, + {"j", KEYCODE_j, 'j', "J", kActionKeyType, ~0}, + {"k", KEYCODE_k, 'k', "K", kActionKeyType, ~0}, + {"l", KEYCODE_l, 'l', "L", kActionKeyType, ~0}, + {"m", KEYCODE_m, 'm', "M", kActionKeyType, ~0}, + {"n", KEYCODE_n, 'n', "N", kActionKeyType, ~0}, + {"o", KEYCODE_o, 'o', "O", kActionKeyType, ~0}, + {"p", KEYCODE_p, 'p', "P", kActionKeyType, ~0}, + {"q", KEYCODE_q, 'q', "Q", kActionKeyType, ~0}, + {"r", KEYCODE_r, 'r', "R", kActionKeyType, ~0}, + {"s", KEYCODE_s, 's', "S", kActionKeyType, ~0}, + {"t", KEYCODE_t, 't', "T", kActionKeyType, ~0}, + {"u", KEYCODE_u, 'u', "U", kActionKeyType, ~0}, + {"v", KEYCODE_v, 'v', "V", kActionKeyType, ~0}, + {"w", KEYCODE_w, 'w', "W", kActionKeyType, ~0}, + {"x", KEYCODE_x, 'x', "X", kActionKeyType, ~0}, + {"y", KEYCODE_y, 'y', "Y", kActionKeyType, ~0}, + {"z", KEYCODE_z, 'z', "Z", kActionKeyType, ~0}, {"DELETE", KEYCODE_DELETE, 0, "Del", kActionKeyType, ~0}, // Numeric keypad -- cgit v1.2.3 From 77594f46b1db7ed6bde4413f74d12a48e720cbfa Mon Sep 17 00:00:00 2001 From: Jody Northup Date: Wed, 12 Aug 2009 09:26:00 +0000 Subject: Laying some groundwork for hopefully getting modifiers working in a less hacked-on manner svn-id: r43316 --- backends/keymapper/hardware-key.h | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'backends') diff --git a/backends/keymapper/hardware-key.h b/backends/keymapper/hardware-key.h index 34631a9484..8c286288ae 100644 --- a/backends/keymapper/hardware-key.h +++ b/backends/keymapper/hardware-key.h @@ -37,6 +37,22 @@ namespace Common { #define HWKEY_ID_SIZE (30) + +// Structure for describing specific key+modifier combos mapped to actions, +// to allow for modifiers to work properly without having to define the whole +// hardware key set an additional time for each possible modifier combination +struct ActionKey { + KeyCode keycode; + byte flags; + /** unique id used for saving/loading to config */ + char actKeyId[HWKEY_ID_SIZE]; + + /** Human readable description */ + String description; + +}; + + /** * Describes an available hardware key */ @@ -56,9 +72,12 @@ struct HardwareKey { KeyType type; ActionType preferredAction; + // Mask of modifiers that can possibly apply to this key. + uint32 modMask; + HardwareKey(const char *i, KeyState ky = KeyState(), String desc = "", - KeyType typ = kGenericKeyType, ActionType prefAct = kGenericActionType) - : key(ky), description(desc), type(typ), preferredAction(prefAct) { + KeyType typ = kGenericKeyType, ActionType prefAct = kGenericActionType, uint32 mods = ~0) + : key(ky), description(desc), type(typ), preferredAction(prefAct), modMask(mods) { assert(i); strncpy(hwKeyId, i, HWKEY_ID_SIZE); } -- cgit v1.2.3 From 44e79803648ba7704e97031752506ad42176990d Mon Sep 17 00:00:00 2001 From: Jody Northup Date: Fri, 14 Aug 2009 08:11:18 +0000 Subject: Added proper saving/loading of mapped key modifiers. Fixed modifier recognition in a much less hackish manner, (but still using a minor hack as a stopgap until KeyState can be replaced as the primary lookup type for the keymapper). svn-id: r43363 --- backends/keymapper/keymap.cpp | 22 +++++++++++++++++----- backends/keymapper/keymapper.cpp | 14 ++++++++++++-- backends/keymapper/remap-dialog.cpp | 28 ++++++++++++++++++++-------- 3 files changed, 49 insertions(+), 15 deletions(-) (limited to 'backends') diff --git a/backends/keymapper/keymap.cpp b/backends/keymapper/keymap.cpp index 95b64f88e7..fe6f133254 100644 --- a/backends/keymapper/keymap.cpp +++ b/backends/keymapper/keymap.cpp @@ -127,6 +127,10 @@ void Keymap::loadMappings(const HardwareKeySet *hwKeys) { ConfigManager::Domain::iterator it; String prefix = KEYMAP_KEY_PREFIX + _name + "_"; + uint32 modId = 0; + char hwId[HWKEY_ID_SIZE+1]; + memset(hwId,0,HWKEY_ID_SIZE+1); + for (it = _configDomain->begin(); it != _configDomain->end(); it++) { const String& key = it->_key; @@ -145,15 +149,17 @@ void Keymap::loadMappings(const HardwareKeySet *hwKeys) { continue; } - const HardwareKey *hwKey = hwKeys->findHardwareKey(it->_value.c_str()); + sscanf(it->_value.c_str(),"%d,%s",&modId,hwId); + const HardwareKey *hwKey = hwKeys->findHardwareKey(hwId); if (!hwKey) { warning("HardwareKey with ID %s not known", it->_value.c_str()); _configDomain->erase(key); continue; } - - ua->mapKey(hwKey); + HardwareKey *mappedKey = new HardwareKey(*hwKey); + mappedKey->key.flags = modId; + ua->mapKey(mappedKey); } } @@ -171,13 +177,19 @@ void Keymap::saveMappings() { String actId((*it)->id, (*it)->id + actIdLen); char hwId[HWKEY_ID_SIZE+1]; - memset(hwId, 0, HWKEY_ID_SIZE+1); + char modId[4]; + memset(modId, 0, 4); + if ((*it)->getMappedKey()) { memcpy(hwId, (*it)->getMappedKey()->hwKeyId, HWKEY_ID_SIZE); + sprintf(modId,"%d",(*it)->getMappedKey()->key.flags); } - _configDomain->setVal(prefix + actId, hwId); + String val = modId; + val += ','; + val += hwId; + _configDomain->setVal(prefix + actId, val); } } diff --git a/backends/keymapper/keymapper.cpp b/backends/keymapper/keymapper.cpp index a121ebafee..24b4d7e5f8 100644 --- a/backends/keymapper/keymapper.cpp +++ b/backends/keymapper/keymapper.cpp @@ -192,18 +192,28 @@ bool Keymapper::mapKey(const KeyState& key, bool keyDown) { Action *action = 0; if (keyDown) { + // HACK: Temporary fix for modifier recognition, get the hwkey's keystate + // to correct for keydown and keyup generating different ascii codes in SDL + // to be solved more permanently by using a structure other than KeyState + const HardwareKey *hwkey = findHardwareKey(key); + if (!hwkey) + return false; + + KeyState k = hwkey->key; + k.flags = key.flags; + // Search for key in active keymap stack for (int i = _activeMaps.size() - 1; i >= 0; --i) { MapRecord mr = _activeMaps[i]; - action = mr.keymap->getMappedAction(key); + action = mr.keymap->getMappedAction(k); if (action || mr.inherit == false) break; } if (action) - _keysDown[key] = action; + _keysDown[k] = action; } else { HashMap::iterator it = _keysDown.find(key); diff --git a/backends/keymapper/remap-dialog.cpp b/backends/keymapper/remap-dialog.cpp index 9341c82747..aca2630d6d 100644 --- a/backends/keymapper/remap-dialog.cpp +++ b/backends/keymapper/remap-dialog.cpp @@ -239,15 +239,14 @@ void RemapDialog::handleKeyDown(Common::KeyState state) { void RemapDialog::handleKeyUp(Common::KeyState state) { if (_activeRemapAction) { const HardwareKey *hwkey = _keymapper->findHardwareKey(state); - const HardwareMod *hwmod = _keymapper->findHardwareMod(state); - debug(0, "Key: %d, %d (%c), %x", state.keycode, state.ascii, (state.ascii ? state.ascii : ' '), state.flags); + debug( "Key: %d, %d (%c), %x", state.keycode, state.ascii, (state.ascii ? state.ascii : ' '), state.flags); if (hwkey) { - HardwareKey *temphwkey = new HardwareKey(*hwkey); - temphwkey->description = hwkey->description; - temphwkey->key.flags = hwmod->modFlags; - _activeRemapAction->mapKey(temphwkey); + HardwareKey *mappedkey = new HardwareKey(*hwkey); + mappedkey->description = hwkey->description; + mappedkey->key.flags = (state.flags & hwkey->modMask); + _activeRemapAction->mapKey(mappedkey); _activeRemapAction->getParent()->saveMappings(); _changes = true; stopRemapping(); @@ -363,8 +362,21 @@ void RemapDialog::refreshKeymap() { const HardwareKey *mappedKey = info.action->getMappedKey(); if (mappedKey) - widg.keyButton->setLabel(mappedKey->description); - else + { + Common::String description = ""; + if (mappedKey->key.flags) + { + byte flags = mappedKey->key.flags; + if (flags & KBD_CTRL) + description += "Ctrl+"; + if (flags & KBD_SHIFT) + description += "Shift+"; + if (flags & KBD_ALT) + description += "Alt+"; + } + description += mappedKey->description; + widg.keyButton->setLabel(description); + } else widg.keyButton->setLabel("-"); widg.actionText->setVisible(true); -- cgit v1.2.3 From 7ea0646a49a848d2cfa1f18162dba66fc6ddef0b Mon Sep 17 00:00:00 2001 From: Jody Northup Date: Sat, 15 Aug 2009 08:48:13 +0000 Subject: Removed excessive modifier definitions, prevented excessive memory consumption if getHardwareKeyset is called multiple times. svn-id: r43395 --- backends/platform/sdl/hardwarekeys.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'backends') diff --git a/backends/platform/sdl/hardwarekeys.cpp b/backends/platform/sdl/hardwarekeys.cpp index c063ea5bff..623e8b50cf 100644 --- a/backends/platform/sdl/hardwarekeys.cpp +++ b/backends/platform/sdl/hardwarekeys.cpp @@ -162,7 +162,7 @@ static const Key keys[] = { {"F15", KEYCODE_F15, 0, "F15", kActionKeyType, ~0}, -// // Modifier keys pressed alone + // Modifier keys pressed alone // {"RSHIFT", KEYCODE_RSHIFT, 0, "Right Shift", kModiferKeyType, ~KBD_SHIFT}, // {"LSHIFT", KEYCODE_LSHIFT, 0, "Left Shift", kModiferKeyType, ~KBD_SHIFT}, // {"RCTRL", KEYCODE_RCTRL, 0, "Right Ctrl", kModiferKeyType, ~KBD_CTRL}, @@ -197,9 +197,6 @@ static const Mod modifiers[] = { { KBD_CTRL, "C+", "Ctrl+" }, { KBD_ALT, "A+", "Alt+" }, { KBD_SHIFT, "S+", "Shift+" }, - { KBD_CTRL | KBD_ALT, "C+A+", "Ctrl+Alt+" }, - { KBD_SHIFT | KBD_CTRL, "S+C+", "Shift+Ctrl+" }, - { KBD_SHIFT | KBD_CTRL | KBD_ALT, "S+C+A+", "Shift+Ctrl+Alt+" }, { 0, 0, 0 } }; #endif @@ -207,7 +204,11 @@ static const Mod modifiers[] = { Common::HardwareKeySet *OSystem_SDL::getHardwareKeySet() { #ifdef ENABLE_KEYMAPPER - HardwareKeySet *keySet = new HardwareKeySet(); + static HardwareKeySet *keySet = new HardwareKeySet(); + static bool keySetInited = false; + if (keySet && keySetInited) + return keySet; + const Key *key; const Mod *mod; char fullKeyId[50]; @@ -226,9 +227,11 @@ Common::HardwareKeySet *OSystem_SDL::getHardwareKeySet() { snprintf(fullKeyId, 50, "%s", key->hwId); snprintf(fullKeyDesc, 100, "%s", key->desc); - keySet->addHardwareKey(new HardwareKey(fullKeyId, KeyState(key->keycode, ascii, 0), fullKeyDesc, key->preferredAction)); + keySet->addHardwareKey(new HardwareKey(fullKeyId, KeyState(key->keycode, ascii, 0), fullKeyDesc, key->modableMask, key->preferredAction)); } + keySetInited = true; + return keySet; #else -- cgit v1.2.3 From 0af775717e30af665c973283c7df69209525a69a Mon Sep 17 00:00:00 2001 From: Jody Northup Date: Sat, 15 Aug 2009 08:52:40 +0000 Subject: Added mandatory includes into hardware-key.h (so it can be included without compile error, without having to separately include several other header files), reworked ActionKey structure, changed HardwareKey::modMask from uint32 into byte. svn-id: r43396 --- backends/keymapper/hardware-key.h | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'backends') diff --git a/backends/keymapper/hardware-key.h b/backends/keymapper/hardware-key.h index 8c286288ae..94e6589a17 100644 --- a/backends/keymapper/hardware-key.h +++ b/backends/keymapper/hardware-key.h @@ -31,6 +31,10 @@ #ifdef ENABLE_KEYMAPPER #include "backends/keymapper/types.h" +#include "common/str.h" +#include "common/keyboard.h" +#include "common/list.h" +#include "common/util.h" namespace Common { @@ -44,11 +48,15 @@ namespace Common { struct ActionKey { KeyCode keycode; byte flags; - /** unique id used for saving/loading to config */ - char actKeyId[HWKEY_ID_SIZE]; - /** Human readable description */ - String description; + ActionKey (KeyCode ky, byte f) { + keycode = ky; + flags = f; + } + + bool operator ==(const ActionKey &x) const { + return keycode == x.keycode && flags == x.flags; + } }; @@ -73,10 +81,10 @@ struct HardwareKey { ActionType preferredAction; // Mask of modifiers that can possibly apply to this key. - uint32 modMask; + byte modMask; - HardwareKey(const char *i, KeyState ky = KeyState(), String desc = "", - KeyType typ = kGenericKeyType, ActionType prefAct = kGenericActionType, uint32 mods = ~0) + HardwareKey(const char *i, KeyState ky = KeyState(), String desc = "", byte mods = ~0, + KeyType typ = kGenericKeyType, ActionType prefAct = kGenericActionType) : key(ky), description(desc), type(typ), preferredAction(prefAct), modMask(mods) { assert(i); strncpy(hwKeyId, i, HWKEY_ID_SIZE); -- cgit v1.2.3 From 6ede8310932ab8a79310ebd6b0a14eaf687c1708 Mon Sep 17 00:00:00 2001 From: Jody Northup Date: Sat, 15 Aug 2009 08:55:22 +0000 Subject: Added hash function for ActionKey in preparation for replacing KeyStates in the main keymapper hashtable with ActionKeys, removed a duplicated comment line. svn-id: r43397 --- backends/keymapper/keymap.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'backends') diff --git a/backends/keymapper/keymap.h b/backends/keymapper/keymap.h index 615fd9097d..5bb277c924 100644 --- a/backends/keymapper/keymap.h +++ b/backends/keymapper/keymap.h @@ -36,6 +36,7 @@ #include "common/keyboard.h" #include "common/list.h" #include "backends/keymapper/action.h" +#include "backends/keymapper/hardware-key.h" namespace Common { @@ -53,6 +54,17 @@ template<> struct Hash } }; +/** + * Hash function for ActionKey + */ +template<> struct Hash + : public UnaryFunction { + + uint operator()(const ActionKey &val) const { + return (uint)val.keycode | ((uint)val.flags << 24); + } +}; + class Keymap { public: Keymap(const String& name, Keymap *parent = 0) : _name(name), _parent(parent) {} @@ -90,7 +102,6 @@ public: /** * Save this keymap's mappings to the config manager * @note Changes are *not* flushed to disk, to do so call ConfMan.flushToDisk() - * @note Changes are *not* flushed to disk, to do so call ConfMan.flushToDisk() */ void saveMappings(); -- cgit v1.2.3 From 8d051e24feeb2e7410d7676328ad66fbf04a95c8 Mon Sep 17 00:00:00 2001 From: Jody Northup Date: Sat, 15 Aug 2009 09:12:36 +0000 Subject: Added support for mapping keys to ctrl, alt, shift, or combinations thereof (though ctrl+alt will never trigger for some reason) svn-id: r43398 --- backends/keymapper/keymapper.cpp | 3 ++- backends/keymapper/types.h | 2 +- backends/platform/sdl/hardwarekeys.cpp | 12 ++++++------ 3 files changed, 9 insertions(+), 8 deletions(-) (limited to 'backends') diff --git a/backends/keymapper/keymapper.cpp b/backends/keymapper/keymapper.cpp index 24b4d7e5f8..d101e8e0d2 100644 --- a/backends/keymapper/keymapper.cpp +++ b/backends/keymapper/keymapper.cpp @@ -195,12 +195,13 @@ bool Keymapper::mapKey(const KeyState& key, bool keyDown) { // HACK: Temporary fix for modifier recognition, get the hwkey's keystate // to correct for keydown and keyup generating different ascii codes in SDL // to be solved more permanently by using a structure other than KeyState + const HardwareKey *hwkey = findHardwareKey(key); if (!hwkey) return false; KeyState k = hwkey->key; - k.flags = key.flags; + k.flags = key.flags & hwkey->modMask; // Search for key in active keymap stack for (int i = _activeMaps.size() - 1; i >= 0; --i) { diff --git a/backends/keymapper/types.h b/backends/keymapper/types.h index 004a90bfcd..3cce79ee9a 100644 --- a/backends/keymapper/types.h +++ b/backends/keymapper/types.h @@ -43,7 +43,7 @@ enum KeyType { kTriggerRightKeyType, kStartKeyType, kSelectKeyType, -// kModiferKeyType, + kModiferKeyType, /* ... */ kKeyTypeMax diff --git a/backends/platform/sdl/hardwarekeys.cpp b/backends/platform/sdl/hardwarekeys.cpp index 623e8b50cf..506e71d092 100644 --- a/backends/platform/sdl/hardwarekeys.cpp +++ b/backends/platform/sdl/hardwarekeys.cpp @@ -163,12 +163,12 @@ static const Key keys[] = { // Modifier keys pressed alone -// {"RSHIFT", KEYCODE_RSHIFT, 0, "Right Shift", kModiferKeyType, ~KBD_SHIFT}, -// {"LSHIFT", KEYCODE_LSHIFT, 0, "Left Shift", kModiferKeyType, ~KBD_SHIFT}, -// {"RCTRL", KEYCODE_RCTRL, 0, "Right Ctrl", kModiferKeyType, ~KBD_CTRL}, -// {"LCTRL", KEYCODE_LCTRL, 0, "Left Ctrl", kModiferKeyType, ~KBD_CTRL}, -// {"RALT", KEYCODE_RALT, 0, "Right Alt", kModiferKeyType, ~KBD_ALT}, -// {"LALT", KEYCODE_LALT, 0, "Left Alt", kModiferKeyType, ~KBD_ALT}, + {"RSHIFT", KEYCODE_RSHIFT, 0, "Right Shift", kModiferKeyType, ~KBD_SHIFT}, + {"LSHIFT", KEYCODE_LSHIFT, 0, "Left Shift", kModiferKeyType, ~KBD_SHIFT}, + {"RCTRL", KEYCODE_RCTRL, 0, "Right Ctrl", kModiferKeyType, ~KBD_CTRL}, + {"LCTRL", KEYCODE_LCTRL, 0, "Left Ctrl", kModiferKeyType, ~KBD_CTRL}, + {"RALT", KEYCODE_RALT, 0, "Right Alt", kModiferKeyType, ~KBD_ALT}, + {"LALT", KEYCODE_LALT, 0, "Left Alt", kModiferKeyType, ~KBD_ALT}, // Miscellaneous function keys -- cgit v1.2.3 From 7ff9bb3a6b543777891d90a645c669b975e64445 Mon Sep 17 00:00:00 2001 From: Jody Northup Date: Sat, 15 Aug 2009 09:15:09 +0000 Subject: Commented a memory leak whose fix requires a fundamental modification to the Action structure (replacing KeyState with ActionKey should do it) svn-id: r43399 --- backends/keymapper/remap-dialog.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'backends') diff --git a/backends/keymapper/remap-dialog.cpp b/backends/keymapper/remap-dialog.cpp index aca2630d6d..323790a700 100644 --- a/backends/keymapper/remap-dialog.cpp +++ b/backends/keymapper/remap-dialog.cpp @@ -243,9 +243,12 @@ void RemapDialog::handleKeyUp(Common::KeyState state) { debug( "Key: %d, %d (%c), %x", state.keycode, state.ascii, (state.ascii ? state.ascii : ' '), state.flags); if (hwkey) { + //FIXME: this leaks memory and there's no good way to get this pointer again as + //a non-const. this should be done differently when we switch to actionKeys. HardwareKey *mappedkey = new HardwareKey(*hwkey); mappedkey->description = hwkey->description; mappedkey->key.flags = (state.flags & hwkey->modMask); + _activeRemapAction->mapKey(mappedkey); _activeRemapAction->getParent()->saveMappings(); _changes = true; -- cgit v1.2.3 From cbffcb609f752edcc3f086521c9e0c75b5ee4cc4 Mon Sep 17 00:00:00 2001 From: Jody Northup Date: Sun, 16 Aug 2009 07:40:13 +0000 Subject: Replaced KeyStates with ActionKeys in the keymapper, removed SDL ASCII code mismatch workaround hacks, fixed the memory leaks I had previously created. svn-id: r43430 --- backends/keymapper/action.cpp | 17 ++++++++++++----- backends/keymapper/action.h | 4 ++-- backends/keymapper/hardware-key.h | 19 +++++++++++++++---- backends/keymapper/keymap.cpp | 12 +++++------- backends/keymapper/keymap.h | 6 +++--- backends/keymapper/keymapper.cpp | 22 +++++----------------- backends/keymapper/keymapper.h | 6 +++--- backends/keymapper/remap-dialog.cpp | 9 ++------- backends/platform/sdl/hardwarekeys.cpp | 2 +- 9 files changed, 48 insertions(+), 49 deletions(-) (limited to 'backends') diff --git a/backends/keymapper/action.cpp b/backends/keymapper/action.cpp index 3feb593f19..1f4efbf457 100644 --- a/backends/keymapper/action.cpp +++ b/backends/keymapper/action.cpp @@ -43,14 +43,21 @@ Action::Action(Keymap *boss, const char *i, String des, ActionType typ, _boss->addAction(this); } -void Action::mapKey(const HardwareKey *key) { +void Action::mapKey(const HardwareKey *key, byte flags) { if (_hwKey) + { _boss->unregisterMapping(this); + delete _hwKey; + } - _hwKey = key; - - if (_hwKey) - _boss->registerMapping(this, _hwKey); + if (key) { + _hwKey = new HardwareKey(*key); + if (flags) + _hwKey->key.flags = flags & _hwKey->modMask; + if (_hwKey) + _boss->registerMapping(this, _hwKey); + } else + _hwKey = NULL; } const HardwareKey *Action::getMappedKey() const { diff --git a/backends/keymapper/action.h b/backends/keymapper/action.h index 31576e2960..c49518b605 100644 --- a/backends/keymapper/action.h +++ b/backends/keymapper/action.h @@ -59,7 +59,7 @@ struct Action { private: /** Hardware key that is mapped to this Action */ - const HardwareKey *_hwKey; + HardwareKey *_hwKey; Keymap *_boss; public: @@ -105,7 +105,7 @@ public: return _boss; } - void mapKey(const HardwareKey *key); + void mapKey(const HardwareKey *key, byte flags = 0); const HardwareKey *getMappedKey() const; }; diff --git a/backends/keymapper/hardware-key.h b/backends/keymapper/hardware-key.h index 94e6589a17..70168def2d 100644 --- a/backends/keymapper/hardware-key.h +++ b/backends/keymapper/hardware-key.h @@ -49,6 +49,17 @@ struct ActionKey { KeyCode keycode; byte flags; + ActionKey () { + keycode = KEYCODE_INVALID; + flags = 0; + } + + ActionKey (const KeyState &key) { + keycode = key.keycode; + flags = key.flags; + } + + ActionKey (KeyCode ky, byte f) { keycode = ky; flags = f; @@ -75,7 +86,7 @@ struct HardwareKey { * The KeyState that is generated by the back-end * when this hardware key is pressed. */ - KeyState key; + ActionKey key; KeyType type; ActionType preferredAction; @@ -83,7 +94,7 @@ struct HardwareKey { // Mask of modifiers that can possibly apply to this key. byte modMask; - HardwareKey(const char *i, KeyState ky = KeyState(), String desc = "", byte mods = ~0, + HardwareKey(const char *i, ActionKey ky = ActionKey(), String desc = "", byte mods = ~0, KeyType typ = kGenericKeyType, ActionType prefAct = kGenericActionType) : key(ky), description(desc), type(typ), preferredAction(prefAct), modMask(mods) { assert(i); @@ -150,7 +161,7 @@ public: return 0; } - const HardwareKey *findHardwareKey(const KeyState& keystate) const { + const HardwareKey *findHardwareKey(const ActionKey& keystate) const { List::const_iterator it; for (it = _keys.begin(); it != _keys.end(); it++) { @@ -170,7 +181,7 @@ public: return 0; } - const HardwareMod *findHardwareMod(const KeyState& keystate) const { + const HardwareMod *findHardwareMod(const ActionKey& keystate) const { List::const_iterator it; for (it = _mods.begin(); it != _mods.end(); it++) { diff --git a/backends/keymapper/keymap.cpp b/backends/keymapper/keymap.cpp index fe6f133254..9d8b6046cd 100644 --- a/backends/keymapper/keymap.cpp +++ b/backends/keymapper/keymap.cpp @@ -60,7 +60,7 @@ void Keymap::addAction(Action *action) { } void Keymap::registerMapping(Action *action, const HardwareKey *hwKey) { - HashMap::iterator it; + HashMap::iterator it; it = _keymap.find(hwKey->key); @@ -105,8 +105,8 @@ const Action *Keymap::findAction(const char *id) const { return 0; } -Action *Keymap::getMappedAction(const KeyState& ks) const { - HashMap::iterator it; +Action *Keymap::getMappedAction(const ActionKey& ks) const { + HashMap::iterator it; it = _keymap.find(ks); @@ -157,9 +157,7 @@ void Keymap::loadMappings(const HardwareKeySet *hwKeys) { _configDomain->erase(key); continue; } - HardwareKey *mappedKey = new HardwareKey(*hwKey); - mappedKey->key.flags = modId; - ua->mapKey(mappedKey); + ua->mapKey(hwKey,modId); } } @@ -335,7 +333,7 @@ void Keymap::automaticMapping(HardwareKeySet *hwKeys) { } } -Action *Keymap::getParentMappedAction(KeyState key) { +Action *Keymap::getParentMappedAction(const ActionKey &key) { if (_parent) { Action *act = _parent->getMappedAction(key); diff --git a/backends/keymapper/keymap.h b/backends/keymapper/keymap.h index 5bb277c924..f4ad8d110d 100644 --- a/backends/keymapper/keymap.h +++ b/backends/keymapper/keymap.h @@ -89,7 +89,7 @@ public: * @param key the key that is mapped to the required Action * @return a pointer to the Action or 0 if no */ - Action *getMappedAction(const KeyState& ks) const; + Action *getMappedAction(const ActionKey& ks) const; void setConfigDomain(ConfigManager::Domain *dom); @@ -147,12 +147,12 @@ private: void internalMapKey(Action *action, HardwareKey *hwKey); - Action *getParentMappedAction(KeyState key); + Action *getParentMappedAction(const ActionKey &key); String _name; Keymap *_parent; List _actions; - HashMap _keymap; + HashMap _keymap; ConfigManager::Domain *_configDomain; }; diff --git a/backends/keymapper/keymapper.cpp b/backends/keymapper/keymapper.cpp index d101e8e0d2..704affb3fe 100644 --- a/backends/keymapper/keymapper.cpp +++ b/backends/keymapper/keymapper.cpp @@ -190,33 +190,21 @@ bool Keymapper::mapKey(const KeyState& key, bool keyDown) { return false; Action *action = 0; - if (keyDown) { - // HACK: Temporary fix for modifier recognition, get the hwkey's keystate - // to correct for keydown and keyup generating different ascii codes in SDL - // to be solved more permanently by using a structure other than KeyState - - const HardwareKey *hwkey = findHardwareKey(key); - if (!hwkey) - return false; - - KeyState k = hwkey->key; - k.flags = key.flags & hwkey->modMask; - // Search for key in active keymap stack for (int i = _activeMaps.size() - 1; i >= 0; --i) { MapRecord mr = _activeMaps[i]; - action = mr.keymap->getMappedAction(k); + action = mr.keymap->getMappedAction(key); if (action || mr.inherit == false) break; } if (action) - _keysDown[k] = action; + _keysDown[key] = action; } else { - HashMap::iterator it = _keysDown.find(key); + HashMap::iterator it = _keysDown.find(key); if (it != _keysDown.end()) { action = it->_value; @@ -279,11 +267,11 @@ void Keymapper::executeAction(const Action *action, bool keyDown) { } } -const HardwareKey *Keymapper::findHardwareKey(const KeyState& key) { +const HardwareKey *Keymapper::findHardwareKey(const ActionKey& key) { return (_hardwareKeys) ? _hardwareKeys->findHardwareKey(key) : 0; } -const HardwareMod *Keymapper::findHardwareMod(const KeyState& key) { +const HardwareMod *Keymapper::findHardwareMod(const ActionKey& key) { return (_hardwareKeys) ? _hardwareKeys->findHardwareMod(key) : 0; } diff --git a/backends/keymapper/keymapper.h b/backends/keymapper/keymapper.h index af3314f8f5..24c76fb09f 100644 --- a/backends/keymapper/keymapper.h +++ b/backends/keymapper/keymapper.h @@ -168,12 +168,12 @@ public: /** * Return a HardwareKey pointer for the given key state */ - const HardwareKey *findHardwareKey(const KeyState& key); + const HardwareKey *findHardwareKey(const ActionKey& key); /** * Return a HardwareMod pointer for the given key state */ - const HardwareMod *findHardwareMod(const KeyState& key); + const HardwareMod *findHardwareMod(const ActionKey& key); Domain& getGlobalDomain() { return _globalDomain; } Domain& getGameDomain() { return _gameDomain; } @@ -198,7 +198,7 @@ private: bool _enabled; Stack _activeMaps; - HashMap _keysDown; + HashMap _keysDown; }; diff --git a/backends/keymapper/remap-dialog.cpp b/backends/keymapper/remap-dialog.cpp index 323790a700..0a93785c08 100644 --- a/backends/keymapper/remap-dialog.cpp +++ b/backends/keymapper/remap-dialog.cpp @@ -243,14 +243,9 @@ void RemapDialog::handleKeyUp(Common::KeyState state) { debug( "Key: %d, %d (%c), %x", state.keycode, state.ascii, (state.ascii ? state.ascii : ' '), state.flags); if (hwkey) { - //FIXME: this leaks memory and there's no good way to get this pointer again as - //a non-const. this should be done differently when we switch to actionKeys. - HardwareKey *mappedkey = new HardwareKey(*hwkey); - mappedkey->description = hwkey->description; - mappedkey->key.flags = (state.flags & hwkey->modMask); - - _activeRemapAction->mapKey(mappedkey); + _activeRemapAction->mapKey(hwkey,state.flags); _activeRemapAction->getParent()->saveMappings(); + _changes = true; stopRemapping(); } diff --git a/backends/platform/sdl/hardwarekeys.cpp b/backends/platform/sdl/hardwarekeys.cpp index 506e71d092..af9b0ba319 100644 --- a/backends/platform/sdl/hardwarekeys.cpp +++ b/backends/platform/sdl/hardwarekeys.cpp @@ -227,7 +227,7 @@ Common::HardwareKeySet *OSystem_SDL::getHardwareKeySet() { snprintf(fullKeyId, 50, "%s", key->hwId); snprintf(fullKeyDesc, 100, "%s", key->desc); - keySet->addHardwareKey(new HardwareKey(fullKeyId, KeyState(key->keycode, ascii, 0), fullKeyDesc, key->modableMask, key->preferredAction)); + keySet->addHardwareKey(new HardwareKey(fullKeyId, ActionKey(key->keycode, 0), fullKeyDesc, key->modableMask, key->preferredAction)); } keySetInited = true; -- cgit v1.2.3 From 62bcb2e51b45e744d0b27b124179cb6ec435188d Mon Sep 17 00:00:00 2001 From: Joost Peters Date: Mon, 17 Aug 2009 12:57:37 +0000 Subject: Commit (slightly) modified version of patch #2831248: Allow suspend/resume for PSP svn-id: r43477 --- backends/fs/psp/psp-fs-factory.cpp | 8 +- backends/fs/psp/psp-fs.cpp | 62 ++++++-- backends/fs/psp/psp-stream.cpp | 230 ++++++++++++++++++++++++++++ backends/fs/psp/psp-stream.h | 70 +++++++++ backends/module.mk | 1 + backends/platform/psp/Makefile | 5 +- backends/platform/psp/module.mk | 1 + backends/platform/psp/osys_psp.cpp | 1 + backends/platform/psp/osys_psp.h | 5 + backends/platform/psp/powerman.cpp | 297 +++++++++++++++++++++++++++++++++++++ backends/platform/psp/powerman.h | 87 +++++++++++ backends/platform/psp/psp.spec | 2 +- backends/platform/psp/psp_main.cpp | 29 +++- 13 files changed, 784 insertions(+), 14 deletions(-) create mode 100644 backends/fs/psp/psp-stream.cpp create mode 100644 backends/fs/psp/psp-stream.h create mode 100644 backends/platform/psp/powerman.cpp create mode 100644 backends/platform/psp/powerman.h (limited to 'backends') diff --git a/backends/fs/psp/psp-fs-factory.cpp b/backends/fs/psp/psp-fs-factory.cpp index 27bee4de86..7ed84de034 100644 --- a/backends/fs/psp/psp-fs-factory.cpp +++ b/backends/fs/psp/psp-fs-factory.cpp @@ -34,7 +34,13 @@ AbstractFSNode *PSPFilesystemFactory::makeRootFileNode() const { AbstractFSNode *PSPFilesystemFactory::makeCurrentDirectoryFileNode() const { char buf[MAXPATHLEN]; - return getcwd(buf, MAXPATHLEN) ? new PSPFilesystemNode(buf) : NULL; + char * ret = 0; + + PowerMan.beginCriticalSection(); + ret = getcwd(buf, MAXPATHLEN); + PowerMan.endCriticalSection(); + + return (ret ? new PSPFilesystemNode(buf) : NULL); } AbstractFSNode *PSPFilesystemFactory::makeFileNodePath(const Common::String &path) const { diff --git a/backends/fs/psp/psp-fs.cpp b/backends/fs/psp/psp-fs.cpp index f5ff65c9fa..03247e86ad 100644 --- a/backends/fs/psp/psp-fs.cpp +++ b/backends/fs/psp/psp-fs.cpp @@ -26,7 +26,8 @@ #include "engines/engine.h" #include "backends/fs/abstract-fs.h" -#include "backends/fs/stdiostream.h" +#include "backends/fs/psp/psp-stream.h" +#include "backends/platform/psp/powerman.h" #include #include @@ -35,6 +36,9 @@ #define ROOT_PATH "ms0:/" +#include "backends/platform/psp/trace.h" + + /** * Implementation of the ScummVM file system API based on PSPSDK API. * @@ -61,13 +65,13 @@ public: */ PSPFilesystemNode(const Common::String &p, bool verify = true); - virtual bool exists() const { return access(_path.c_str(), F_OK) == 0; } + virtual bool exists() const; virtual Common::String getDisplayName() const { return _displayName; } virtual Common::String getName() const { return _displayName; } virtual Common::String getPath() const { return _path; } virtual bool isDirectory() const { return _isDirectory; } - virtual bool isReadable() const { return access(_path.c_str(), R_OK) == 0; } - virtual bool isWritable() const { return access(_path.c_str(), W_OK) == 0; } + virtual bool isReadable() const; + virtual bool isWritable() const; virtual AbstractFSNode *getChild(const Common::String &n) const; virtual bool getChildren(AbstractFSList &list, ListMode mode, bool hidden) const; @@ -94,11 +98,44 @@ PSPFilesystemNode::PSPFilesystemNode(const Common::String &p, bool verify) { if (verify) { struct stat st; + PowerMan.beginCriticalSection(); _isValid = (0 == stat(_path.c_str(), &st)); + PowerMan.endCriticalSection(); _isDirectory = S_ISDIR(st.st_mode); } } +bool PSPFilesystemNode::exists() const { + int ret = 0; + + PowerMan.beginCriticalSection(); // Make sure to block in case of suspend + ret = access(_path.c_str(), F_OK); + PowerMan.endCriticalSection(); + + return ret == 0; +} + +bool PSPFilesystemNode::isReadable() const { + int ret = 0; + + PowerMan.beginCriticalSection(); // Make sure to block in case of suspend + ret = access(_path.c_str(), R_OK); + PowerMan.endCriticalSection(); + + return ret == 0; +} + +bool PSPFilesystemNode::isWritable() const { + int ret = 0; + + PowerMan.beginCriticalSection(); // Make sure to block in case of suspend + ret = access(_path.c_str(), W_OK); + PowerMan.endCriticalSection(); + + return ret == 0; +} + + AbstractFSNode *PSPFilesystemNode::getChild(const Common::String &n) const { // FIXME: Pretty lame implementation! We do no error checking to speak // of, do not check if this is a special node, etc. @@ -117,6 +154,10 @@ bool PSPFilesystemNode::getChildren(AbstractFSList &myList, ListMode mode, bool //TODO: honor the hidden flag + bool ret = true; + + PowerMan.beginCriticalSection(); // Make sure to block in case of suspend + int dfd = sceIoDopen(_path.c_str()); if (dfd > 0) { SceIoDirent dir; @@ -149,10 +190,13 @@ bool PSPFilesystemNode::getChildren(AbstractFSList &myList, ListMode mode, bool } sceIoDclose(dfd); - return true; - } else { - return false; + ret = true; + } else { // dfd <= 0 + ret = false; } + + PowerMan.endCriticalSection(); + return ret; } AbstractFSNode *PSPFilesystemNode::getParent() const { @@ -166,11 +210,11 @@ AbstractFSNode *PSPFilesystemNode::getParent() const { } Common::SeekableReadStream *PSPFilesystemNode::createReadStream() { - return StdioStream::makeFromPath(getPath().c_str(), false); + return PSPIoStream::makeFromPath(getPath(), false); } Common::WriteStream *PSPFilesystemNode::createWriteStream() { - return StdioStream::makeFromPath(getPath().c_str(), true); + return PSPIoStream::makeFromPath(getPath(), true); } #endif //#ifdef __PSP__ diff --git a/backends/fs/psp/psp-stream.cpp b/backends/fs/psp/psp-stream.cpp new file mode 100644 index 0000000000..fac4067f46 --- /dev/null +++ b/backends/fs/psp/psp-stream.cpp @@ -0,0 +1,230 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ +#ifdef __PSP__ + +#include "backends/fs/psp/psp-stream.h" +#include "backends/platform/psp/trace.h" +#include + +PSPIoStream::PSPIoStream(const Common::String &path, bool writeMode) +: StdioStream((void *)1), _path(path), _writeMode(writeMode) { + + assert(!path.empty()); + + _handle = (void *)0; // Need to do this since base class asserts not 0. + + PowerMan.registerSuspend(this); // Register with the powermanager to be suspended + +} + +PSPIoStream::~PSPIoStream() { + PowerMan.unregisterSuspend(this); // Unregister with powermanager to be suspended + // Must do this before fclose() or resume() will reopen. + + fclose((FILE *)_handle); +} + +// Function to open the file pointed to by the path. +// +// +void * PSPIoStream::open() { + if (PowerMan.beginCriticalSection()==PowerManager::Blocked) { + // No need to open. Just return the _handle resume() already opened. + PSPDebugTrace("Suspended in PSPIoStream::open\n"); + } else { + _handle = fopen(_path.c_str(), _writeMode ? "wb" : "rb"); // open + } + + PowerMan.endCriticalSection(); + + return _handle; +} + +bool PSPIoStream::err() const { + bool ret; + + if (PowerMan.beginCriticalSection() == PowerManager::Blocked) + PSPDebugTrace("Suspended in PSPIoStream::err()\n"); + + ret = ferror((FILE *)_handle) != 0; + + PowerMan.endCriticalSection(); + + return ret; +} + +void PSPIoStream::clearErr() { + if (PowerMan.beginCriticalSection() == PowerManager::Blocked) + PSPDebugTrace("Suspended in PSPIoStream::clearErr()\n"); + + clearerr((FILE *)_handle); + + PowerMan.endCriticalSection(); +} + +bool PSPIoStream::eos() const { + bool ret; + + if (PowerMan.beginCriticalSection() == PowerManager::Blocked) + PSPDebugTrace("Suspended in PSPIoStream::eos()\n"); + + ret = feof((FILE *)_handle) != 0; + + PowerMan.endCriticalSection(); + + return ret; +} + +int32 PSPIoStream::pos() const { + int32 ret; + + if (PowerMan.beginCriticalSection() == PowerManager::Blocked) + PSPDebugTrace("Suspended in PSPIoStream::pos()\n"); + + ret = ftell((FILE *)_handle); + + PowerMan.endCriticalSection(); + + return ret; +} + + +int32 PSPIoStream::size() const { + if (PowerMan.beginCriticalSection() == PowerManager::Blocked) + PSPDebugTrace("Suspended in PSPIoStream::size()\n"); + + int32 oldPos = ftell((FILE *)_handle); + fseek((FILE *)_handle, 0, SEEK_END); + int32 length = ftell((FILE *)_handle); + fseek((FILE *)_handle, oldPos, SEEK_SET); + + PowerMan.endCriticalSection(); + + return length; +} + +bool PSPIoStream::seek(int32 offs, int whence) { + int ret = 0; + + // Check if we can access the file + if (PowerMan.beginCriticalSection() == PowerManager::Blocked) + PSPDebugTrace("Suspended in PSPIoStream::seek()\n"); + + ret = fseek((FILE *)_handle, offs, whence); + + PowerMan.endCriticalSection(); + + return ret == 0; +} + +uint32 PSPIoStream::read(void *ptr, uint32 len) { + int ret = 0; + + // Check if we can access the file + if (PowerMan.beginCriticalSection() == PowerManager::Blocked) + PSPDebugTrace("Suspended in PSPIoStream::read()\n"); + + ret = fread((byte *)ptr, 1, len, (FILE *)_handle); + + PowerMan.endCriticalSection(); + + return ret; +} + +uint32 PSPIoStream::write(const void *ptr, uint32 len) { + int ret = 0; + + // Check if we can access the file + if (PowerMan.beginCriticalSection() == PowerManager::Blocked) + PSPDebugTrace("Suspended in PSPIoStream::read()\n"); + + ret = fwrite(ptr, 1, len, (FILE *)_handle); + + PowerMan.endCriticalSection(); + + return ret; +} + +bool PSPIoStream::flush() { + int ret = 0; + + // Check if we can access the file + if (PowerMan.beginCriticalSection() == PowerManager::Blocked) + PSPDebugTrace("Suspended in PSPIoStream::read()\n"); + + ret = fflush((FILE *)_handle); + + PowerMan.endCriticalSection(); + + return ret == 0; +} + +// For the PSP, since we're building in suspend support, we moved opening +// the actual file to an open function since we need an actual PSPIoStream object to suspend. +// +PSPIoStream *PSPIoStream::makeFromPath(const Common::String &path, bool writeMode) { + PSPIoStream *stream = new PSPIoStream(path, writeMode); + + if (stream->open() > 0) { + return stream; + } else { + delete stream; + return 0; + } +} + +/* + * Function to suspend the IO stream (called by PowerManager) + */ +int PSPIoStream::suspend() { + if (_handle > 0) { + _pos = ftell((FILE *)_handle); // Save our position + fclose((FILE *)_handle); // close our file descriptor + _handle = 0; // Set handle to null + } + + return 0; +} + +/* + * Function to resume the IO stream (called by Power Manager) + */ +int PSPIoStream::resume() { + int ret = 0; + + // We reopen our file descriptor + _handle = fopen(_path.c_str(), _writeMode ? "wb" : "rb"); + if (_handle <= 0) { + PSPDebugTrace("PSPIoStream::resume(): Couldn't reopen file %s\n", _path.c_str()); + ret = -1;; + } + + // Resume our previous position + if(_handle > 0) fseek((FILE *)_handle, _pos, SEEK_SET); + + return ret; +} + +#endif /* __PSP__ */ diff --git a/backends/fs/psp/psp-stream.h b/backends/fs/psp/psp-stream.h new file mode 100644 index 0000000000..0363c92416 --- /dev/null +++ b/backends/fs/psp/psp-stream.h @@ -0,0 +1,70 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#ifndef PSPSTREAM_H_ +#define PSPSTREAM_H_ + +#include "backends/fs/stdiostream.h" +#include "backends/platform/psp/powerman.h" +#include "common/list.h" + +/* + * Class to handle special suspend/resume needs of PSP IO Streams + */ +class PSPIoStream : public StdioStream, public Suspendable { +protected: + Common::String _path; /* Need to maintain for reopening after suspend */ + bool _writeMode; /* "" */ + unsigned int _pos; /* "" */ + +public: + /** + * Given a path, invoke fopen on that path and wrap the result in a + * PSPIoStream instance. + */ + static PSPIoStream *makeFromPath(const Common::String &path, bool writeMode); + + PSPIoStream(const Common::String &path, bool writeMode); + virtual ~PSPIoStream(); + + void * open(); // open the file pointed to by the file path + + bool err() const; + void clearErr(); + bool eos() const; + + virtual uint32 write(const void *dataPtr, uint32 dataSize); + virtual bool flush(); + + virtual int32 pos() const; + virtual int32 size() const; + virtual bool seek(int32 offs, int whence = SEEK_SET); + virtual uint32 read(void *dataPtr, uint32 dataSize); + + int suspend(); /* Suspendable interface (power manager) */ + int resume(); /* " " */ +}; + +#endif /* PSPSTREAM_H_ */ diff --git a/backends/module.mk b/backends/module.mk index f3294c5dc6..42fbeb07eb 100644 --- a/backends/module.mk +++ b/backends/module.mk @@ -11,6 +11,7 @@ MODULE_OBJS := \ fs/posix/posix-fs-factory.o \ fs/ps2/ps2-fs-factory.o \ fs/psp/psp-fs-factory.o \ + fs/psp/psp-stream.o \ fs/symbian/symbian-fs-factory.o \ fs/windows/windows-fs-factory.o \ fs/wii/wii-fs-factory.o \ diff --git a/backends/platform/psp/Makefile b/backends/platform/psp/Makefile index 91a0c60bd6..ad22a853e1 100644 --- a/backends/platform/psp/Makefile +++ b/backends/platform/psp/Makefile @@ -75,12 +75,13 @@ LIBS += -lmad CXXFLAGS+= -DUSE_VORBIS -DUSE_TREMOR LIBS += -lvorbisidec -LIBS += `$(PSPBIN)/sdl-config --libs` -lz -lstdc++ -lc -lpspdisplay -lpspgu -lpspctrl -lpspsdk -lpspnet -lpspnet_inet -lpsputility -lpspsdk -lpspuser +LIBS += `$(PSPBIN)/sdl-config --libs` -lz -lstdc++ -lc -lpspdisplay -lpspgu -lpspctrl -lpspsdk -lpspnet -lpspnet_inet -lpsputility -lpspuser -lpsppower CXXFLAGS := $(CXXFLAGS) -fno-exceptions -fno-rtti TARGET = scummvm-psp -OBJS := psp_main.o \ +OBJS := powerman.o \ + psp_main.o \ osys_psp.o \ osys_psp_gu.o \ kbd_ss_c.o \ diff --git a/backends/platform/psp/module.mk b/backends/platform/psp/module.mk index afe9a23f58..8f083c5dfa 100644 --- a/backends/platform/psp/module.mk +++ b/backends/platform/psp/module.mk @@ -1,6 +1,7 @@ MODULE := backends/platform/psp MODULE_OBJS := \ + powerman.o \ psp_main.o \ osys_psp.o \ osys_psp_gu.o \ diff --git a/backends/platform/psp/osys_psp.cpp b/backends/platform/psp/osys_psp.cpp index 45be0a0cd3..8a7a0af0ed 100644 --- a/backends/platform/psp/osys_psp.cpp +++ b/backends/platform/psp/osys_psp.cpp @@ -430,6 +430,7 @@ bool OSystem_PSP::pollEvent(Common::Event &event) { } else if (buttonsChanged & PSP_CTRL_START) { event.kbd.keycode = Common::KEYCODE_F5; event.kbd.ascii = Common::ASCII_F5; + event.kbd.flags = Common::KBD_CTRL; // Main menu to allow RTL /* } else if (buttonsChanged & PSP_CTRL_SELECT) { event.kbd.keycode = Common::KEYCODE_0; event.kbd.ascii = '0'; diff --git a/backends/platform/psp/osys_psp.h b/backends/platform/psp/osys_psp.h index 34957b293c..46607dac34 100644 --- a/backends/platform/psp/osys_psp.h +++ b/backends/platform/psp/osys_psp.h @@ -23,6 +23,9 @@ * */ +#ifndef OSYS_PSP_H +#define OSYS_PSP_H + #include "common/scummsys.h" #include "graphics/surface.h" #include "graphics/colormasks.h" @@ -144,3 +147,5 @@ public: virtual Common::WriteStream *createConfigWriteStream(); }; + +#endif /* OSYS_PSP_H */ diff --git a/backends/platform/psp/powerman.cpp b/backends/platform/psp/powerman.cpp new file mode 100644 index 0000000000..c553669fc3 --- /dev/null +++ b/backends/platform/psp/powerman.cpp @@ -0,0 +1,297 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#include "./powerman.h" +#include "./trace.h" + +DECLARE_SINGLETON(PowerManager); + + /******************************************* +* +* Constructor +* +********************************************/ +PowerManager::PowerManager() { + _flagMutex = NULL; /* Init mutex handle */ + _listMutex = NULL; /* Init mutex handle */ + _condSuspendable = NULL; /* Init condition variable */ + _condPM = NULL; + + _condSuspendable = SDL_CreateCond(); + if (_condSuspendable <= 0) { + PSPDebugTrace("PowerManager::PowerManager(): Couldn't create condSuspendable\n"); + } + + _condPM = SDL_CreateCond(); + if (_condPM <= 0) { + PSPDebugTrace("PowerManager::PowerManager(): Couldn't create condPM\n"); + } + + _flagMutex = SDL_CreateMutex(); + if (_flagMutex <= 0) { + PSPDebugTrace("PowerManager::PowerManager(): Couldn't create flagMutex\n"); + } + + _listMutex = SDL_CreateMutex(); + if (_listMutex <= 0) { + PSPDebugTrace("PowerManager::PowerManager(): Couldn't create listMutex\n"); + } + + _suspendFlag = false; + _criticalCounter = 0; + } + +/******************************************* +* +* Function to register to be notified when suspend/resume time comes +* +********************************************/ +int PowerManager::registerSuspend(Suspendable *item) { + // Register in list + PSPDebugTrace("In registerSuspend\n"); + + if (SDL_mutexP(_listMutex) != 0) { + PSPDebugTrace("PowerManager::registerSuspend(): Couldn't lock _listMutex %d\n", _listMutex); + } + + _suspendList.push_front(item); + + if (SDL_mutexV(_listMutex) != 0) { + PSPDebugTrace("PowerManager::registerSuspend(): Couldn't unlock _listMutex %d\n", _listMutex); + } + + PSPDebugTrace("Out of registerSuspend\n"); + + return 0; +} + +/******************************************* +* +* Function to unregister to be notified when suspend/resume time comes +* +********************************************/ +int PowerManager::unregisterSuspend(Suspendable *item) { + + PSPDebugTrace("In unregisterSuspend\n"); + + // Unregister from stream list + if (SDL_mutexP(_listMutex) != 0) { + PSPDebugTrace("PowerManager::unregisterSuspend(): Couldn't unlock _listMutex %d\n", _listMutex); + } + + _suspendList.remove(item); + + if (SDL_mutexV(_listMutex) != 0) { + PSPDebugTrace("PowerManager::unregisterSuspend(): Couldn't unlock _listMutex %d\n", _listMutex); + } + + PSPDebugTrace("Out of unregisterSuspend\n"); + + return 0; + } + + /******************************************* +* +* Destructor +* +********************************************/ + PowerManager::~PowerManager() { + SDL_DestroyCond(_condSuspendable); + _condSuspendable = 0; + + SDL_DestroyCond(_condPM); + _condPM = 0; + + SDL_DestroyMutex(_flagMutex); + _flagMutex = 0; + + SDL_DestroyMutex(_listMutex); + _listMutex = 0; + } + + + /******************************************* +* +* Function to be called by threads wanting to block on the PSP entering suspend +* +********************************************/ + int PowerManager::blockOnSuspend() { + return beginCriticalSection(true); +} + + /* + * Function to block on a suspend, then start a non-suspendable critical section + */ +int PowerManager::beginCriticalSection(bool justBlock) { + int ret = PowerManager::NotBlocked; + + if (SDL_mutexP(_flagMutex) != 0) { + PSPDebugTrace("PowerManager::blockOnSuspend(): Couldn't lock flagMutex %d\n", _flagMutex); + ret = PowerManager::Error; + } + + // Check the access flag + if (_suspendFlag == true) { + PSPDebugTrace("Blocking!!\n"); + ret = PowerManager::Blocked; + + // If it's true, we wait for a signal to continue + if( SDL_CondWait(_condSuspendable, _flagMutex) != 0) { + PSPDebugTrace("PowerManager::blockOnSuspend(): Couldn't wait on cond %d\n", _condSuspendable); + } + + PSPDebugTrace("We got blocked!!\n"); + } + + // Now put the pm to sleep + if (justBlock == false) + _criticalCounter++; + + if (SDL_mutexV(_flagMutex) != 0) { + PSPDebugTrace("PowerManager::blockOnSuspend(): Couldn't unlock flagMutex %d\n", _flagMutex); + ret = PowerManager::Error; + } + + return ret; +} + +int PowerManager::endCriticalSection() { + int ret = 0; + + if (SDL_mutexP(_flagMutex) != 0) { + PSPDebugTrace("PowerManager::endCriticalSection(): Couldn't lock flagMutex %d\n", _flagMutex); + ret = PowerManager::Error; + } + + // We're done with our critical section + _criticalCounter--; + + if (_criticalCounter <= 0) { + if(_suspendFlag == true) PSPDebugTrace("Waking up the PM and suspendFlag is true\n"); + + SDL_CondBroadcast(_condPM); + + if (_criticalCounter < 0) { + PSPDebugTrace("PowerManager::endCriticalSection(): Error! Critical counter is %d\n", _criticalCounter); + } + } + + if (SDL_mutexV(_flagMutex) != 0) { + PSPDebugTrace("PowerManager::endCriticalSection(): Couldn't unlock flagMutex %d\n", _flagMutex); + ret = PowerManager::Error; + } + + return ret; +} + + /******************************************* +* +* Callback function to be called to put every Suspendable to suspend +* +********************************************/ +int PowerManager::suspend() { + int ret = 0; + + // First we set the suspend flag to true + if (SDL_mutexP(_flagMutex) != 0) { + PSPDebugTrace("PowerManager::suspend(): Couldn't lock flagMutex %d\n", _flagMutex); + ret = -1; + } + + _suspendFlag = true; + + if (_criticalCounter > 0) + SDL_CondWait(_condPM, _flagMutex); + + if (SDL_mutexV(_flagMutex) != 0) { + PSPDebugTrace("PowerManager::suspend(): Couldn't unlock flagMutex %d\n", _flagMutex); + ret = -1; + } + + // Loop over list, calling suspend() + if (SDL_mutexP(_listMutex) != 0) { + PSPDebugTrace("PowerManager::suspend(): Couldn't lock listMutex %d\n", _listMutex); + ret = -1; + } + + Common::List::iterator i = _suspendList.begin(); + + for (; i != _suspendList.end(); i++) { + (*i)->suspend(); + } + + if (SDL_mutexV(_listMutex) != 0) { + PSPDebugTrace("PowerManager::suspend(): Couldn't unlock listMutex %d\n", _listMutex); + ret = -1; + } + + return ret; +} + +/******************************************* +* +* Callback function to resume every Suspendable +* +********************************************/ +int PowerManager::resume() { + int ret = 0; + + // First we notify our Suspendables. Loop over list, calling resume() + if (SDL_mutexP(_listMutex) != 0) { + PSPDebugTrace("PowerManager::resume(): Couldn't lock listMutex %d\n", _listMutex); + ret = -1; + } + + Common::List::iterator i = _suspendList.begin(); + + for (; i != _suspendList.end(); i++) { + (*i)->resume(); + } + + if (SDL_mutexV(_listMutex) != 0) { + PSPDebugTrace("PowerManager::resume(): Couldn't unlock listMutex %d\n", _listMutex); + ret = -1; + } + + // Now we set the suspend flag to false + if (SDL_mutexP(_flagMutex) != 0) { + PSPDebugTrace("PowerManager::resume(): Couldn't lock flagMutex %d\n", _flagMutex); + ret = -1; + } + _suspendFlag = false; + + // Signal the other threads to wake up + if (SDL_CondBroadcast(_condSuspendable) != 0) { + PSPDebugTrace("PowerManager::resume(): Couldn't broadcast condition %d\n", _condSuspendable); + ret = -1; + } + + if (SDL_mutexV(_flagMutex) != 0) { + PSPDebugTrace("PowerManager::resume(): Couldn't unlock flagMutex %d\n", _flagMutex); + ret = -1; + } + + return ret; +} diff --git a/backends/platform/psp/powerman.h b/backends/platform/psp/powerman.h new file mode 100644 index 0000000000..0a5f7a2361 --- /dev/null +++ b/backends/platform/psp/powerman.h @@ -0,0 +1,87 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#ifndef POWERMAN_H +#define POWERMAN_H + +#include +#include +#include "common/singleton.h" +#include "common/list.h" + + /* + * Implement this class (interface) if you want to use PowerManager's suspend callback functionality + * + */ + class Suspendable { + public: + virtual ~Suspendable() {} + virtual int suspend() = 0; + virtual int resume() = 0; + }; + + /****************************************************************************************************** + * + * This class will call a Suspendable when the PSP goes to suspend/resumes. It also provides the ability to block + * a thread when the PSP is going to suspend/suspending, and to wake it up when the PSP is resumed. + * This ability is very useful for managing the PSPIoStream class, but may be found useful by other classes as well. + * + *******************************************************************************************************/ + class PowerManager: public Common::Singleton { +private: + friend class Common::Singleton; + PowerManager(); + ~PowerManager(); + + Common::List _suspendList; /* list to register in */ + + bool _suspendFlag; /* protected variable */ + SDL_mutex *_flagMutex; /* mutex to access access flag */ + SDL_mutex *_listMutex; /* mutex to access Suspendable list */ + SDL_cond *_condSuspendable; /* signal to synchronize accessing threads */ + SDL_cond *_condPM; /* signal to wake up the PM from a critical section */ + int _criticalCounter; /* Counter of how many threads are in a critical section */ + +public: + int blockOnSuspend(); /* block if suspending */ + int beginCriticalSection(bool justBlock = false); /* Use a critical section to block (if suspend was already pressed) */ + int endCriticalSection(); /* and to prevent the PSP from suspending in a particular section */ + int registerSuspend(Suspendable *item); /* register to be called to suspend/resume */ + int unregisterSuspend(Suspendable *item); /* remove from suspend/resume list */ + int suspend(); /* callback to have all items in list suspend */ + int resume(); /* callback to have all items in list resume */ + + enum { + Error = -1, + NotBlocked = 0, + Blocked = 1 + }; + + }; + + // For easy access +#define PowerMan PowerManager::instance() + + #endif /* POWERMAN_H */ diff --git a/backends/platform/psp/psp.spec b/backends/platform/psp/psp.spec index 807b8f93b7..e319b022f7 100644 --- a/backends/platform/psp/psp.spec +++ b/backends/platform/psp/psp.spec @@ -1,3 +1,3 @@ %rename lib old_lib *lib: -%(old_lib) -lpspdebug -lpspgu -lpspctrl -lpspge -lpspdisplay -lpsphprm -lpspsdk -lpsprtc -lpspaudio -lc -lpspuser -lpsputility -lpspkernel -lpspnet_inet -lz -lstdc++ -lc -lpspdisplay -lpspgu -lpspctrl -lpspsdk -lpspnet -lpspnet_inet -lpsputility -lpspsdk -lpspuser +%(old_lib) -lpspdebug -lpspgu -lpspctrl -lpspge -lpspdisplay -lpsphprm -lpspsdk -lpsprtc -lpspaudio -lc -lpspuser -lpsputility -lpspkernel -lpspnet_inet -lz -lstdc++ -lc -lpspdisplay -lpspgu -lpspctrl -lpspsdk -lpspnet -lpspnet_inet -lpsputility -lpspuser -lpsppower diff --git a/backends/platform/psp/psp_main.cpp b/backends/platform/psp/psp_main.cpp index 0af7ebf269..37080c7bf9 100644 --- a/backends/platform/psp/psp_main.cpp +++ b/backends/platform/psp/psp_main.cpp @@ -31,10 +31,14 @@ #include #endif +#include + #include #include #include #include +#include "backends/platform/psp/powerman.h" + #include "osys_psp_gu.h" #include "./trace.h" @@ -91,17 +95,36 @@ void loaderInit() { #endif /* Exit callback */ -SceKernelCallbackFunction exit_callback(int /*arg1*/, int /*arg2*/, void * /*common*/) { +int exit_callback(void) { sceKernelExitGame(); return 0; } +/* Function for handling suspend/resume */ +void power_callback(int , int powerinfo) { + if (powerinfo & PSP_POWER_CB_POWER_SWITCH || powerinfo & PSP_POWER_CB_SUSPENDING) { + PowerMan.suspend(); + } else if (powerinfo & PSP_POWER_CB_RESUME_COMPLETE) { + PowerMan.resume(); + } +} + /* Callback thread */ int CallbackThread(SceSize /*size*/, void *arg) { int cbid; cbid = sceKernelCreateCallback("Exit Callback", (SceKernelCallbackFunction)exit_callback, NULL); sceKernelRegisterExitCallback(cbid); + /* Set up callbacks for PSPIoStream */ + + cbid = sceKernelCreateCallback("Power Callback", (SceKernelCallbackFunction)power_callback, 0); + if (cbid >= 0) { + if(scePowerRegisterCallback(-1, cbid) < 0) { + PSPDebugTrace("SetupCallbacks(): Couldn't register callback for power_callback\n"); + } + } else { + PSPDebugTrace("SetupCallbacks(): Couldn't create a callback for power_callback\n"); + } sceKernelSleepThreadCB(); return 0; @@ -119,6 +142,8 @@ int SetupCallbacks(void) { #undef main int main(void) { + PowerManager::instance(); // Setup power manager + SetupCallbacks(); static const char *argv[] = { "scummvm", NULL }; @@ -131,6 +156,8 @@ int main(void) { g_system->quit(); // TODO: Consider removing / replacing this! + PowerManager::destroy(); // get rid of PowerManager + sceKernelSleepThread(); return res; -- cgit v1.2.3 From eb11cca7888c01256550d4aac429cc73eb0330e2 Mon Sep 17 00:00:00 2001 From: Joost Peters Date: Mon, 17 Aug 2009 23:54:40 +0000 Subject: PSP: increase optimization level and change clock rate to 333mhz svn-id: r43498 --- backends/platform/psp/Makefile | 2 +- backends/platform/psp/psp_main.cpp | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'backends') diff --git a/backends/platform/psp/Makefile b/backends/platform/psp/Makefile index ad22a853e1..0190cdf8c9 100644 --- a/backends/platform/psp/Makefile +++ b/backends/platform/psp/Makefile @@ -62,7 +62,7 @@ endif INCDIR := $(srcdir) . $(srcdir)/engines/ . $(PSPSDK)/include LIBDIR := $(LIBDIR) . $(PSPSDK)/lib -CXXFLAGS = -O2 -Wall -D__PSP__ -DNONSTANDARD_PORT -DDISABLE_TEXT_CONSOLE -DDISABLE_COMMAND_LINE -DUSE_ZLIB -Wno-multichar `$(PSPBIN)/sdl-config --cflags` +CXXFLAGS = -O3 -Wall -D__PSP__ -DNONSTANDARD_PORT -DDISABLE_TEXT_CONSOLE -DDISABLE_COMMAND_LINE -DUSE_ZLIB -Wno-multichar `$(PSPBIN)/sdl-config --cflags` CXXFLAGS:= $(addprefix -I,$(INCDIR)) $(CXXFLAGS) LDFLAGS := $(addprefix -L,$(LIBDIR)) $(LDFLAGS) LIBS = diff --git a/backends/platform/psp/psp_main.cpp b/backends/platform/psp/psp_main.cpp index 37080c7bf9..3ea6c55368 100644 --- a/backends/platform/psp/psp_main.cpp +++ b/backends/platform/psp/psp_main.cpp @@ -146,6 +146,9 @@ int main(void) { SetupCallbacks(); + //change clock rate to 333mhz + scePowerSetClockFrequency(333, 333, 166); + static const char *argv[] = { "scummvm", NULL }; static int argc = sizeof(argv)/sizeof(char *)-1; -- cgit v1.2.3 From dfaa5acbee5766e59b35697ea1b03122aa4ea2aa Mon Sep 17 00:00:00 2001 From: Jody Northup Date: Tue, 18 Aug 2009 08:00:24 +0000 Subject: Starting to simplify the Action structure, and rework it to facilitate making the automatic mapper smarter, at least when there is a keyboard present. Fixed a minor whitespace issue in a comment. svn-id: r43502 --- backends/keymapper/action.cpp | 4 ++-- backends/keymapper/action.h | 4 +--- backends/keymapper/keymap.cpp | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) (limited to 'backends') diff --git a/backends/keymapper/action.cpp b/backends/keymapper/action.cpp index 1f4efbf457..4633f20df3 100644 --- a/backends/keymapper/action.cpp +++ b/backends/keymapper/action.cpp @@ -32,9 +32,9 @@ namespace Common { Action::Action(Keymap *boss, const char *i, String des, ActionType typ, - KeyType prefKey, int pri, int flg) + KeyType prefKey, int pri) : _boss(boss), description(des), type(typ), preferredKey(prefKey), - priority(pri), flags(flg), _hwKey(0) { + priority(pri), _hwKey(0) { assert(i); assert(_boss); diff --git a/backends/keymapper/action.h b/backends/keymapper/action.h index c49518b605..c78a526414 100644 --- a/backends/keymapper/action.h +++ b/backends/keymapper/action.h @@ -54,8 +54,6 @@ struct Action { ActionType type; KeyType preferredKey; int priority; - int group; - int flags; private: /** Hardware key that is mapped to this Action */ @@ -66,7 +64,7 @@ public: Action(Keymap *boss, const char *id, String des = "", ActionType typ = kGenericActionType, KeyType prefKey = kGenericKeyType, - int pri = 0, int flg = 0 ); + int pri = 0); void addEvent(const Event &evt) { events.push_back(evt); diff --git a/backends/keymapper/keymap.cpp b/backends/keymapper/keymap.cpp index 9d8b6046cd..f082640f2c 100644 --- a/backends/keymapper/keymap.cpp +++ b/backends/keymapper/keymap.cpp @@ -240,7 +240,7 @@ void Keymap::automaticMapping(HardwareKeySet *hwKeys) { // First mapping pass: // - Match if a key's preferred action type is the same as the action's - // type, or vice versa. + // type, or vice versa. // - Priority is given to: // - keys that match action types over key types. // - keys that have not been used by parent maps. -- cgit v1.2.3 From 426dd7d24149d7d60e9e20d0babe38d08e114b4a Mon Sep 17 00:00:00 2001 From: Joost Peters Date: Tue, 18 Aug 2009 15:39:47 +0000 Subject: PSP: disable dosbox OPL svn-id: r43514 --- backends/platform/psp/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'backends') diff --git a/backends/platform/psp/Makefile b/backends/platform/psp/Makefile index 0190cdf8c9..d18e6ac82c 100644 --- a/backends/platform/psp/Makefile +++ b/backends/platform/psp/Makefile @@ -62,7 +62,7 @@ endif INCDIR := $(srcdir) . $(srcdir)/engines/ . $(PSPSDK)/include LIBDIR := $(LIBDIR) . $(PSPSDK)/lib -CXXFLAGS = -O3 -Wall -D__PSP__ -DNONSTANDARD_PORT -DDISABLE_TEXT_CONSOLE -DDISABLE_COMMAND_LINE -DUSE_ZLIB -Wno-multichar `$(PSPBIN)/sdl-config --cflags` +CXXFLAGS = -O3 -Wall -D__PSP__ -DNONSTANDARD_PORT -DDISABLE_TEXT_CONSOLE -DDISABLE_COMMAND_LINE -DUSE_ZLIB -DDISABLE_DOSBOX_OPL -Wno-multichar `$(PSPBIN)/sdl-config --cflags` CXXFLAGS:= $(addprefix -I,$(INCDIR)) $(CXXFLAGS) LDFLAGS := $(addprefix -L,$(LIBDIR)) $(LDFLAGS) LIBS = -- cgit v1.2.3 From ed2a733b2a9841f00e8ea2559193044cc4fca8b0 Mon Sep 17 00:00:00 2001 From: Joost Peters Date: Tue, 18 Aug 2009 17:12:01 +0000 Subject: PSP: Make R-trigger act as a context sensitive modifier key, remap ENTER to triangle svn-id: r43517 --- backends/platform/psp/README.PSP.in | 9 ++++----- backends/platform/psp/osys_psp.cpp | 17 +++++++++++------ 2 files changed, 15 insertions(+), 11 deletions(-) (limited to 'backends') diff --git a/backends/platform/psp/README.PSP.in b/backends/platform/psp/README.PSP.in index 2a2b53e721..7eeba7d391 100644 --- a/backends/platform/psp/README.PSP.in +++ b/backends/platform/psp/README.PSP.in @@ -13,15 +13,17 @@ Controls ======== Left trigger - ESC -Right trigger - Enter +Right trigger - Modifier key (see below for uses) Analog - Mouse movement +Right trigger + Analog - Fine control mouse Directionals - Mouse movement -Analog + triangle - Fine control mouse +Triangle - Enter Cross - Mouse button 1 Circle - Mouse button 2 Square - '.' (skip dialogue in some games) Select - Show/Hide Virtual Keyboard Start - F5 +Right trigger + Start - Return-To-Launcher menu Notes ===== @@ -32,9 +34,6 @@ Notes As such, it is recommended to play games in their original, uncompressed, form whenever possible. -- Sleep/Suspend mode currently isn't supported, so don't use it when - running ScummVM. - - This README may be outdated, for more up-to-date instructions and notes see the PSP Port Wiki: http://wiki.scummvm.org/index.php/PlayStation_Portable diff --git a/backends/platform/psp/osys_psp.cpp b/backends/platform/psp/osys_psp.cpp index 8a7a0af0ed..d1886c253f 100644 --- a/backends/platform/psp/osys_psp.cpp +++ b/backends/platform/psp/osys_psp.cpp @@ -411,7 +411,7 @@ bool OSystem_PSP::pollEvent(Common::Event &event) { */ uint32 buttonsChanged = pad.Buttons ^ _prevButtons; - if (buttonsChanged & (PSP_CTRL_CROSS | PSP_CTRL_CIRCLE | PSP_CTRL_LTRIGGER | PSP_CTRL_RTRIGGER | PSP_CTRL_START | PSP_CTRL_SELECT | PSP_CTRL_SQUARE)) { + if (buttonsChanged & (PSP_CTRL_CROSS | PSP_CTRL_CIRCLE | PSP_CTRL_LTRIGGER | PSP_CTRL_RTRIGGER | PSP_CTRL_START | PSP_CTRL_SELECT | PSP_CTRL_SQUARE | PSP_CTRL_TRIANGLE)) { if (buttonsChanged & PSP_CTRL_CROSS) { event.type = (pad.Buttons & PSP_CTRL_CROSS) ? Common::EVENT_LBUTTONDOWN : Common::EVENT_LBUTTONUP; } else if (buttonsChanged & PSP_CTRL_CIRCLE) { @@ -419,24 +419,29 @@ bool OSystem_PSP::pollEvent(Common::Event &event) { } else { //any of the other buttons. event.type = buttonsChanged & pad.Buttons ? Common::EVENT_KEYDOWN : Common::EVENT_KEYUP; + event.kbd.ascii = 0; event.kbd.flags = 0; if (buttonsChanged & PSP_CTRL_LTRIGGER) { event.kbd.keycode = Common::KEYCODE_ESCAPE; event.kbd.ascii = 27; - } else if (buttonsChanged & PSP_CTRL_RTRIGGER) { - event.kbd.keycode = Common::KEYCODE_RETURN; - event.kbd.ascii = 13; } else if (buttonsChanged & PSP_CTRL_START) { event.kbd.keycode = Common::KEYCODE_F5; event.kbd.ascii = Common::ASCII_F5; - event.kbd.flags = Common::KBD_CTRL; // Main menu to allow RTL + if (pad.Buttons & PSP_CTRL_RTRIGGER) { + event.kbd.flags = Common::KBD_CTRL; // Main menu to allow RTL + } /* } else if (buttonsChanged & PSP_CTRL_SELECT) { event.kbd.keycode = Common::KEYCODE_0; event.kbd.ascii = '0'; */ } else if (buttonsChanged & PSP_CTRL_SQUARE) { event.kbd.keycode = Common::KEYCODE_PERIOD; event.kbd.ascii = '.'; + } else if (buttonsChanged & PSP_CTRL_TRIANGLE) { + event.kbd.keycode = Common::KEYCODE_RETURN; + event.kbd.ascii = 13; + } else if (pad.Buttons & PSP_CTRL_RTRIGGER) { + event.kbd.flags |= Common::KBD_SHIFT; } } @@ -485,7 +490,7 @@ bool OSystem_PSP::pollEvent(Common::Event &event) { newY += _padAccel >> 2; // If no movement then this has no effect - if (pad.Buttons & PSP_CTRL_TRIANGLE) { + if (pad.Buttons & PSP_CTRL_RTRIGGER) { // Fine control mode for analog if (analogStepAmountX != 0) { if (analogStepAmountX > 0) -- cgit v1.2.3 From a35056b55531edcd384c3fa0dafc9a4ee6bfb6ee Mon Sep 17 00:00:00 2001 From: Joost Peters Date: Tue, 18 Aug 2009 18:06:50 +0000 Subject: Implement setCursorPalette(), correct hasFeature() <-> getFeatureState() mixup. svn-id: r43519 --- backends/platform/psp/osys_psp.cpp | 6 ++++-- backends/platform/psp/osys_psp.h | 1 + backends/platform/psp/osys_psp_gu.cpp | 21 ++++++++++++++++++++- backends/platform/psp/osys_psp_gu.h | 2 ++ 4 files changed, 27 insertions(+), 3 deletions(-) (limited to 'backends') diff --git a/backends/platform/psp/osys_psp.cpp b/backends/platform/psp/osys_psp.cpp index d1886c253f..566db3014b 100644 --- a/backends/platform/psp/osys_psp.cpp +++ b/backends/platform/psp/osys_psp.cpp @@ -79,6 +79,8 @@ OSystem_PSP::OSystem_PSP() : _screenWidth(0), _screenHeight(0), _overlayWidth(0) memset(_palette, 0, sizeof(_palette)); + _cursorPaletteDisabled = true; + _samplesPerSec = 0; //init SDL @@ -110,14 +112,14 @@ void OSystem_PSP::initBackend() { bool OSystem_PSP::hasFeature(Feature f) { - return false; + return (f == kFeatureOverlaySupportsAlpha || f == kFeatureCursorHasPalette); } void OSystem_PSP::setFeatureState(Feature f, bool enable) { } bool OSystem_PSP::getFeatureState(Feature f) { - return (f == kFeatureOverlaySupportsAlpha); + return false; } const OSystem::GraphicsMode* OSystem_PSP::getSupportedGraphicsModes() const { diff --git a/backends/platform/psp/osys_psp.h b/backends/platform/psp/osys_psp.h index 46607dac34..310efdc7d4 100644 --- a/backends/platform/psp/osys_psp.h +++ b/backends/platform/psp/osys_psp.h @@ -68,6 +68,7 @@ protected: int _mouseHotspotX, _mouseHotspotY; byte _mouseKeyColour; byte *_mouseBuf; + bool _cursorPaletteDisabled; uint32 _prevButtons; uint32 _lastPadCheck; diff --git a/backends/platform/psp/osys_psp_gu.cpp b/backends/platform/psp/osys_psp_gu.cpp index 76f6b42e37..0fb1b4aded 100644 --- a/backends/platform/psp/osys_psp_gu.cpp +++ b/backends/platform/psp/osys_psp_gu.cpp @@ -41,6 +41,7 @@ unsigned int __attribute__((aligned(16))) list[262144]; unsigned short __attribute__((aligned(16))) clut256[256]; unsigned short __attribute__((aligned(16))) mouseClut[256]; +unsigned short __attribute__((aligned(16))) cursorPalette[256]; unsigned short __attribute__((aligned(16))) kbClut[256]; //unsigned int __attribute__((aligned(16))) offscreen256[640*480]; //unsigned int __attribute__((aligned(16))) overlayBuffer256[640*480*2]; @@ -225,6 +226,24 @@ void OSystem_PSP_GU::setPalette(const byte *colors, uint start, uint num) { sceKernelDcacheWritebackAll(); } +void OSystem_PSP_GU::setCursorPalette(const byte *colors, uint start, uint num) { + const byte *b = colors; + + for (uint i = 0; i < num; ++i) { + cursorPalette[start + i] = RGBToColour(b[0], b[1], b[2]); + b += 4; + } + + cursorPalette[0] = 0; + + _cursorPaletteDisabled = false; + + sceKernelDcacheWritebackAll(); +} + +void OSystem_PSP_GU::disableCursorPalette(bool disable) { + _cursorPaletteDisabled = disable; +} void OSystem_PSP_GU::copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h) { //Clip the coordinates @@ -364,7 +383,7 @@ void OSystem_PSP_GU::updateScreen() { if (_mouseVisible) { sceGuTexMode(GU_PSM_T8, 0, 0, 0); // 8-bit image sceGuClutMode(GU_PSM_5551, 0, 0xff, 0); - sceGuClutLoad(32, mouseClut); // upload 32*8 entries (256) + sceGuClutLoad(32, _cursorPaletteDisabled ? mouseClut : cursorPalette); // upload 32*8 entries (256) sceGuAlphaFunc(GU_GREATER,0,0xff); sceGuEnable(GU_ALPHA_TEST); sceGuTexImage(0, MOUSE_SIZE, MOUSE_SIZE, MOUSE_SIZE, _mouseBuf); diff --git a/backends/platform/psp/osys_psp_gu.h b/backends/platform/psp/osys_psp_gu.h index e828a36b7d..c221971fc8 100644 --- a/backends/platform/psp/osys_psp_gu.h +++ b/backends/platform/psp/osys_psp_gu.h @@ -47,6 +47,8 @@ public: void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor, int cursorTargetScale); void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h) ; void setPalette(const byte *colors, uint start, uint num); + void setCursorPalette(const byte *colors, uint start, uint num); + void disableCursorPalette(bool disable); bool pollEvent(Common::Event &event); int _graphicMode; struct Vertex *_vertices; -- cgit v1.2.3 From 2ea0df7b2e14264b828b5d7fe7e55565a6c0bfa8 Mon Sep 17 00:00:00 2001 From: Joost Peters Date: Wed, 19 Aug 2009 01:40:22 +0000 Subject: Take advantage of extra memory on newer PSP models svn-id: r43525 --- backends/platform/psp/Makefile | 2 +- backends/platform/psp/psp.mk | 2 +- backends/platform/psp/psp_main.cpp | 9 ++++----- 3 files changed, 6 insertions(+), 7 deletions(-) (limited to 'backends') diff --git a/backends/platform/psp/Makefile b/backends/platform/psp/Makefile index d18e6ac82c..64ce8a0161 100644 --- a/backends/platform/psp/Makefile +++ b/backends/platform/psp/Makefile @@ -49,7 +49,7 @@ STRIP = psp-strip MKDIR = mkdir -p RM = rm -f RM_REC = rm -rf -MKSFO = mksfo +MKSFO = mksfoex -d MEMSIZE=1 PACK_PBP = pack-pbp FIXUP = psp-fixup-imports diff --git a/backends/platform/psp/psp.mk b/backends/platform/psp/psp.mk index 10e272a593..998a420ffc 100644 --- a/backends/platform/psp/psp.mk +++ b/backends/platform/psp/psp.mk @@ -9,7 +9,7 @@ PSP_EBOOT_SFO = param.sfo PSP_EBOOT_TITLE = ScummVM-PSP DATE = $(shell date +%Y%m%d) -MKSFO = mksfo +MKSFO = mksfoex -d MEMSIZE=1 PACK_PBP = pack-pbp $(PSP_EXE_STRIPPED): $(PSP_EXE) diff --git a/backends/platform/psp/psp_main.cpp b/backends/platform/psp/psp_main.cpp index 3ea6c55368..357c502dbc 100644 --- a/backends/platform/psp/psp_main.cpp +++ b/backends/platform/psp/psp_main.cpp @@ -62,9 +62,8 @@ PSP_MODULE_INFO("SCUMMVM-PSP", 0, 1, 1); * code (crt0.c) starts this program in to be in usermode * even though the module was started in kernelmode */ -#ifndef USERSPACE_ONLY PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER | THREAD_ATTR_VFPU); -#endif +PSP_HEAP_SIZE_KB(-128); //Leave 128kb for thread stacks, etc. #ifndef USERSPACE_ONLY @@ -142,13 +141,13 @@ int SetupCallbacks(void) { #undef main int main(void) { + //change clock rate to 333mhz + scePowerSetClockFrequency(333, 333, 166); + PowerManager::instance(); // Setup power manager SetupCallbacks(); - //change clock rate to 333mhz - scePowerSetClockFrequency(333, 333, 166); - static const char *argv[] = { "scummvm", NULL }; static int argc = sizeof(argv)/sizeof(char *)-1; -- cgit v1.2.3 From bbac75bc1c4e45bcdcb6fecd9f0f99d916ca80ef Mon Sep 17 00:00:00 2001 From: Joost Peters Date: Wed, 19 Aug 2009 16:23:44 +0000 Subject: PSP: throttle the number of updateScreen() calls svn-id: r43539 --- backends/platform/psp/osys_psp.cpp | 2 +- backends/platform/psp/osys_psp.h | 1 + backends/platform/psp/osys_psp_gu.cpp | 9 +++++++++ 3 files changed, 11 insertions(+), 1 deletion(-) (limited to 'backends') diff --git a/backends/platform/psp/osys_psp.cpp b/backends/platform/psp/osys_psp.cpp index 566db3014b..5e461f45e0 100644 --- a/backends/platform/psp/osys_psp.cpp +++ b/backends/platform/psp/osys_psp.cpp @@ -75,7 +75,7 @@ const OSystem::GraphicsMode OSystem_PSP::s_supportedGraphicsModes[] = { }; -OSystem_PSP::OSystem_PSP() : _screenWidth(0), _screenHeight(0), _overlayWidth(0), _overlayHeight(0), _offscreen(0), _overlayBuffer(0), _overlayVisible(false), _shakePos(0), _mouseBuf(0), _prevButtons(0), _lastPadCheck(0), _padAccel(0), _mixer(0) { +OSystem_PSP::OSystem_PSP() : _screenWidth(0), _screenHeight(0), _overlayWidth(0), _overlayHeight(0), _offscreen(0), _overlayBuffer(0), _overlayVisible(false), _shakePos(0), _lastScreenUpdate(0), _mouseBuf(0), _prevButtons(0), _lastPadCheck(0), _padAccel(0), _mixer(0) { memset(_palette, 0, sizeof(_palette)); diff --git a/backends/platform/psp/osys_psp.h b/backends/platform/psp/osys_psp.h index 310efdc7d4..94488a92ce 100644 --- a/backends/platform/psp/osys_psp.h +++ b/backends/platform/psp/osys_psp.h @@ -59,6 +59,7 @@ protected: uint16 _palette[256]; bool _overlayVisible; uint32 _shakePos; + uint32 _lastScreenUpdate; Graphics::Surface _framebuffer; diff --git a/backends/platform/psp/osys_psp_gu.cpp b/backends/platform/psp/osys_psp_gu.cpp index 0fb1b4aded..1c83aa4abf 100644 --- a/backends/platform/psp/osys_psp_gu.cpp +++ b/backends/platform/psp/osys_psp_gu.cpp @@ -38,6 +38,8 @@ #define MOUSE_SIZE 128 #define KBD_DATA_SIZE 130560 +#define MAX_FPS 30 + unsigned int __attribute__((aligned(16))) list[262144]; unsigned short __attribute__((aligned(16))) clut256[256]; unsigned short __attribute__((aligned(16))) mouseClut[256]; @@ -295,6 +297,13 @@ void OSystem_PSP_GU::copyRectToScreen(const byte *buf, int pitch, int x, int y, } void OSystem_PSP_GU::updateScreen() { + u32 now = getMillis(); + if (now - _lastScreenUpdate < 1000 / MAX_FPS) + return; + + _lastScreenUpdate = now; + + sceGuStart(0,list); sceGuClearColor(0xff000000); -- cgit v1.2.3 From 7561704414025392a4c9bba6e487ce0f06040d15 Mon Sep 17 00:00:00 2001 From: Jody Northup Date: Fri, 21 Aug 2009 10:01:16 +0000 Subject: fixed GP2X (I hope) svn-id: r43580 --- backends/platform/gp2x/graphics.cpp | 72 ++++++++++++++++++++++++++++++++----- 1 file changed, 63 insertions(+), 9 deletions(-) (limited to 'backends') diff --git a/backends/platform/gp2x/graphics.cpp b/backends/platform/gp2x/graphics.cpp index 229f840d11..402aea4c14 100644 --- a/backends/platform/gp2x/graphics.cpp +++ b/backends/platform/gp2x/graphics.cpp @@ -240,9 +240,27 @@ int OSystem_GP2X::getGraphicsMode() const { return _videoMode.mode; } -void OSystem_GP2X::initSize(uint w, uint h){ +void OSystem_SDL::initSize(uint w, uint h, const Graphics::PixelFormat *format) { assert(_transactionMode == kTransactionActive); +#ifdef ENABLE_RGB_COLOR + //avoid redundant format changes + Graphics::PixelFormat newFormat; + if (!format) + newFormat = Graphics::PixelFormat::createFormatCLUT8(); + else + newFormat = *format; + + assert(newFormat.bytesPerPixel > 0); + + if (newFormat != _videoMode.format) + { + _videoMode.format = newFormat; + _transactionDetails.formatChanged = true; + _screenFormat = newFormat; + } +#endif + // Avoid redundant res changes if ((int)w == _videoMode.screenWidth && (int)h == _videoMode.screenHeight) return; @@ -1212,7 +1230,17 @@ void OSystem_GP2X::warpMouse(int x, int y) { } } -void OSystem_GP2X::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, byte keycolor, int cursorTargetScale) { +void OSystem_SDL::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format) { +#ifdef ENABLE_RGB_COLOR + if (!format) + _cursorFormat = Graphics::PixelFormat::createFormatCLUT8(); + else if (format->bytesPerPixel <= _screenFormat.bytesPerPixel) + _cursorFormat = *format; + keycolor &= (1 << (_cursorFormat.bytesPerPixel << 3)) - 1; +#else + keycolor &= 0xFF; +#endif + if (w == 0 || h == 0) return; @@ -1246,16 +1274,26 @@ void OSystem_GP2X::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x } free(_mouseData); - +#ifdef ENABLE_RGB_COLOR + _mouseData = (byte *)malloc(w * h * _cursorFormat.bytesPerPixel); + memcpy(_mouseData, buf, w * h * _cursorFormat.bytesPerPixel); +#else _mouseData = (byte *)malloc(w * h); memcpy(_mouseData, buf, w * h); +#endif + blitCursor(); } void OSystem_GP2X::blitCursor() { byte *dstPtr; const byte *srcPtr = _mouseData; +#ifdef ENABLE_RGB_COLOR + uint32 color; + uint32 colormask = (1 << (_cursorFormat.bytesPerPixel << 3)) - 1; +#else byte color; +#endif int w, h, i, j; if (!_mouseOrigSurface || !_mouseData) @@ -1289,13 +1327,29 @@ void OSystem_GP2X::blitCursor() { for (i = 0; i < h; i++) { for (j = 0; j < w; j++) { - color = *srcPtr; - if (color != _mouseKeyColor) { // transparent, don't draw - *(uint16 *)dstPtr = SDL_MapRGB(_mouseOrigSurface->format, - palette[color].r, palette[color].g, palette[color].b); +#ifdef ENABLE_RGB_COLOR + if (_cursorFormat.bytesPerPixel > 1) { + color = (*(uint32 *) srcPtr) & colormask; + if (color != _mouseKeyColor) { // transparent, don't draw + uint8 r,g,b; + _cursorFormat.colorToRGB(color,r,g,b); + *(uint16 *)dstPtr = SDL_MapRGB(_mouseOrigSurface->format, + r, g, b); + } + dstPtr += 2; + srcPtr += _cursorFormat.bytesPerPixel; + } else { +#endif + color = *srcPtr; + if (color != _mouseKeyColor) { // transparent, don't draw + *(uint16 *)dstPtr = SDL_MapRGB(_mouseOrigSurface->format, + palette[color].r, palette[color].g, palette[color].b); + } + dstPtr += 2; + srcPtr++; +#ifdef ENABLE_RGB_COLOR } - dstPtr += 2; - srcPtr++; +#endif } dstPtr += _mouseOrigSurface->pitch - w * 2; } -- cgit v1.2.3 From 5ac20829b0db110e9a0a418ed9dc733484e75c67 Mon Sep 17 00:00:00 2001 From: Jody Northup Date: Fri, 21 Aug 2009 10:10:14 +0000 Subject: correct idiotic error in first gp2x fix attempt. svn-id: r43581 --- backends/platform/gp2x/graphics.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'backends') diff --git a/backends/platform/gp2x/graphics.cpp b/backends/platform/gp2x/graphics.cpp index 402aea4c14..d948cb82d3 100644 --- a/backends/platform/gp2x/graphics.cpp +++ b/backends/platform/gp2x/graphics.cpp @@ -240,7 +240,7 @@ int OSystem_GP2X::getGraphicsMode() const { return _videoMode.mode; } -void OSystem_SDL::initSize(uint w, uint h, const Graphics::PixelFormat *format) { +void OSystem_GP2X::initSize(uint w, uint h, const Graphics::PixelFormat *format) { assert(_transactionMode == kTransactionActive); #ifdef ENABLE_RGB_COLOR @@ -1230,7 +1230,7 @@ void OSystem_GP2X::warpMouse(int x, int y) { } } -void OSystem_SDL::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format) { +void OSystem_GP2X::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format) { #ifdef ENABLE_RGB_COLOR if (!format) _cursorFormat = Graphics::PixelFormat::createFormatCLUT8(); -- cgit v1.2.3 From 007f68366fd55a519753bf533c7c3a80db3754f0 Mon Sep 17 00:00:00 2001 From: Andre Heider Date: Fri, 21 Aug 2009 18:16:37 +0000 Subject: Renamed ENABLE_RGB_COLOR to USE_RGB_COLOR, and added it to config.h to guarantee a consistent build. svn-id: r43604 --- backends/platform/gp2x/graphics.cpp | 12 ++++++------ backends/platform/sdl/graphics.cpp | 30 +++++++++++++++--------------- backends/platform/sdl/sdl.cpp | 2 +- backends/platform/sdl/sdl.h | 8 ++++---- 4 files changed, 26 insertions(+), 26 deletions(-) (limited to 'backends') diff --git a/backends/platform/gp2x/graphics.cpp b/backends/platform/gp2x/graphics.cpp index d948cb82d3..cf874323e0 100644 --- a/backends/platform/gp2x/graphics.cpp +++ b/backends/platform/gp2x/graphics.cpp @@ -243,7 +243,7 @@ int OSystem_GP2X::getGraphicsMode() const { void OSystem_GP2X::initSize(uint w, uint h, const Graphics::PixelFormat *format) { assert(_transactionMode == kTransactionActive); -#ifdef ENABLE_RGB_COLOR +#ifdef USE_RGB_COLOR //avoid redundant format changes Graphics::PixelFormat newFormat; if (!format) @@ -1231,7 +1231,7 @@ void OSystem_GP2X::warpMouse(int x, int y) { } void OSystem_GP2X::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format) { -#ifdef ENABLE_RGB_COLOR +#ifdef USE_RGB_COLOR if (!format) _cursorFormat = Graphics::PixelFormat::createFormatCLUT8(); else if (format->bytesPerPixel <= _screenFormat.bytesPerPixel) @@ -1274,7 +1274,7 @@ void OSystem_GP2X::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x } free(_mouseData); -#ifdef ENABLE_RGB_COLOR +#ifdef USE_RGB_COLOR _mouseData = (byte *)malloc(w * h * _cursorFormat.bytesPerPixel); memcpy(_mouseData, buf, w * h * _cursorFormat.bytesPerPixel); #else @@ -1288,7 +1288,7 @@ void OSystem_GP2X::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x void OSystem_GP2X::blitCursor() { byte *dstPtr; const byte *srcPtr = _mouseData; -#ifdef ENABLE_RGB_COLOR +#ifdef USE_RGB_COLOR uint32 color; uint32 colormask = (1 << (_cursorFormat.bytesPerPixel << 3)) - 1; #else @@ -1327,7 +1327,7 @@ void OSystem_GP2X::blitCursor() { for (i = 0; i < h; i++) { for (j = 0; j < w; j++) { -#ifdef ENABLE_RGB_COLOR +#ifdef USE_RGB_COLOR if (_cursorFormat.bytesPerPixel > 1) { color = (*(uint32 *) srcPtr) & colormask; if (color != _mouseKeyColor) { // transparent, don't draw @@ -1347,7 +1347,7 @@ void OSystem_GP2X::blitCursor() { } dstPtr += 2; srcPtr++; -#ifdef ENABLE_RGB_COLOR +#ifdef USE_RGB_COLOR } #endif } diff --git a/backends/platform/sdl/graphics.cpp b/backends/platform/sdl/graphics.cpp index 3bfe8f5c98..d3a37f4de7 100644 --- a/backends/platform/sdl/graphics.cpp +++ b/backends/platform/sdl/graphics.cpp @@ -26,7 +26,7 @@ #include "backends/platform/sdl/sdl.h" #include "common/mutex.h" #include "common/util.h" -#ifdef ENABLE_RGB_COLOR +#ifdef USE_RGB_COLOR #include "common/list.h" #endif #include "graphics/font.h" @@ -100,7 +100,7 @@ void OSystem_SDL::beginGFXTransaction(void) { _transactionDetails.needUpdatescreen = false; _transactionDetails.normal1xScaler = false; -#ifdef ENABLE_RGB_COLOR +#ifdef USE_RGB_COLOR _transactionDetails.formatChanged = false; #endif @@ -126,7 +126,7 @@ OSystem::TransactionError OSystem_SDL::endGFXTransaction(void) { _videoMode.mode = _oldVideoMode.mode; _videoMode.scaleFactor = _oldVideoMode.scaleFactor; -#ifdef ENABLE_RGB_COLOR +#ifdef USE_RGB_COLOR } else if (_videoMode.format != _oldVideoMode.format) { errors |= kTransactionFormatNotSupported; @@ -156,7 +156,7 @@ OSystem::TransactionError OSystem_SDL::endGFXTransaction(void) { } } -#ifdef ENABLE_RGB_COLOR +#ifdef USE_RGB_COLOR if (_transactionDetails.sizeChanged || _transactionDetails.formatChanged) { #else if (_transactionDetails.sizeChanged) { @@ -209,7 +209,7 @@ OSystem::TransactionError OSystem_SDL::endGFXTransaction(void) { return (TransactionError)errors; } -#ifdef ENABLE_RGB_COLOR +#ifdef USE_RGB_COLOR const Graphics::PixelFormat RGBList[] = { #ifdef ENABLE_32BIT // RGBA8888, ARGB8888, RGB888 @@ -442,7 +442,7 @@ int OSystem_SDL::getGraphicsMode() const { void OSystem_SDL::initSize(uint w, uint h, const Graphics::PixelFormat *format) { assert(_transactionMode == kTransactionActive); -#ifdef ENABLE_RGB_COLOR +#ifdef USE_RGB_COLOR //avoid redundant format changes Graphics::PixelFormat newFormat; if (!format) @@ -543,7 +543,7 @@ bool OSystem_SDL::loadGFXMode() { // // Create the surface that contains the 8 bit game data // -#ifdef ENABLE_RGB_COLOR +#ifdef USE_RGB_COLOR _screen = SDL_CreateRGBSurface(SDL_SWSURFACE, _videoMode.screenWidth, _videoMode.screenHeight, _screenFormat.bytesPerPixel << 3, ((1 << _screenFormat.rBits()) - 1) << _screenFormat.rShift , @@ -1007,7 +1007,7 @@ void OSystem_SDL::copyRectToScreen(const byte *src, int pitch, int x, int y, int if (SDL_LockSurface(_screen) == -1) error("SDL_LockSurface failed: %s", SDL_GetError()); -#ifdef ENABLE_RGB_COLOR +#ifdef USE_RGB_COLOR byte *dst = (byte *)_screen->pixels + y * _videoMode.screenWidth * _screenFormat.bytesPerPixel + x * _screenFormat.bytesPerPixel; if (_videoMode.screenWidth == w && pitch == w * _screenFormat.bytesPerPixel) { memcpy(dst, src, h*w*_screenFormat.bytesPerPixel); @@ -1053,7 +1053,7 @@ Graphics::Surface *OSystem_SDL::lockScreen() { _framebuffer.w = _screen->w; _framebuffer.h = _screen->h; _framebuffer.pitch = _screen->pitch; -#ifdef ENABLE_RGB_COLOR +#ifdef USE_RGB_COLOR _framebuffer.bytesPerPixel = _screenFormat.bytesPerPixel; #else _framebuffer.bytesPerPixel = 1; @@ -1241,7 +1241,7 @@ int16 OSystem_SDL::getWidth() { void OSystem_SDL::setPalette(const byte *colors, uint start, uint num) { assert(colors); -#ifdef ENABLE_RGB_COLOR +#ifdef USE_RGB_COLOR if (_screenFormat.bytesPerPixel > 1) return; //not using a paletted pixel format #endif @@ -1508,7 +1508,7 @@ void OSystem_SDL::warpMouse(int x, int y) { } void OSystem_SDL::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format) { -#ifdef ENABLE_RGB_COLOR +#ifdef USE_RGB_COLOR if (!format) _cursorFormat = Graphics::PixelFormat::createFormatCLUT8(); else if (format->bytesPerPixel <= _screenFormat.bytesPerPixel) @@ -1551,7 +1551,7 @@ void OSystem_SDL::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, } free(_mouseData); -#ifdef ENABLE_RGB_COLOR +#ifdef USE_RGB_COLOR _mouseData = (byte *)malloc(w * h * _cursorFormat.bytesPerPixel); memcpy(_mouseData, buf, w * h * _cursorFormat.bytesPerPixel); #else @@ -1565,7 +1565,7 @@ void OSystem_SDL::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, void OSystem_SDL::blitCursor() { byte *dstPtr; const byte *srcPtr = _mouseData; -#ifdef ENABLE_RGB_COLOR +#ifdef USE_RGB_COLOR uint32 color; uint32 colormask = (1 << (_cursorFormat.bytesPerPixel << 3)) - 1; #else @@ -1604,7 +1604,7 @@ void OSystem_SDL::blitCursor() { for (i = 0; i < h; i++) { for (j = 0; j < w; j++) { -#ifdef ENABLE_RGB_COLOR +#ifdef USE_RGB_COLOR if (_cursorFormat.bytesPerPixel > 1) { color = (*(uint32 *) srcPtr) & colormask; if (color != _mouseKeyColor) { // transparent, don't draw @@ -1624,7 +1624,7 @@ void OSystem_SDL::blitCursor() { } dstPtr += 2; srcPtr++; -#ifdef ENABLE_RGB_COLOR +#ifdef USE_RGB_COLOR } #endif } diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp index b6b46af9d7..7c1107582b 100644 --- a/backends/platform/sdl/sdl.cpp +++ b/backends/platform/sdl/sdl.cpp @@ -222,7 +222,7 @@ OSystem_SDL::OSystem_SDL() _osdSurface(0), _osdAlpha(SDL_ALPHA_TRANSPARENT), _osdFadeStartTime(0), #endif _hwscreen(0), _screen(0), _tmpscreen(0), -#ifdef ENABLE_RGB_COLOR +#ifdef USE_RGB_COLOR _screenFormat(Graphics::PixelFormat::createFormatCLUT8()), _cursorFormat(Graphics::PixelFormat::createFormatCLUT8()), #endif diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h index 09213ad417..3da9a433b7 100644 --- a/backends/platform/sdl/sdl.h +++ b/backends/platform/sdl/sdl.h @@ -93,7 +93,7 @@ public: void beginGFXTransaction(void); TransactionError endGFXTransaction(void); -#ifdef ENABLE_RGB_COLOR +#ifdef USE_RGB_COLOR // Game screen virtual Graphics::PixelFormat getScreenFormat() const { return _screenFormat; } @@ -248,7 +248,7 @@ protected: // unseen game screen SDL_Surface *_screen; -#ifdef ENABLE_RGB_COLOR +#ifdef USE_RGB_COLOR Graphics::PixelFormat _screenFormat; Graphics::PixelFormat _cursorFormat; #endif @@ -285,7 +285,7 @@ protected: bool needHotswap; bool needUpdatescreen; bool normal1xScaler; -#ifdef ENABLE_RGB_COLOR +#ifdef USE_RGB_COLOR bool formatChanged; #endif }; @@ -304,7 +304,7 @@ protected: int screenWidth, screenHeight; int overlayWidth, overlayHeight; int hardwareWidth, hardwareHeight; -#ifdef ENABLE_RGB_COLOR +#ifdef USE_RGB_COLOR Graphics::PixelFormat format; #endif }; -- cgit v1.2.3 From d6f3e28c2db6dd31e17cf304586de2f91d489791 Mon Sep 17 00:00:00 2001 From: Andre Heider Date: Fri, 21 Aug 2009 18:53:28 +0000 Subject: Fixed OSystem_Wii for the 16bit API changes svn-id: r43605 --- backends/platform/wii/osystem.h | 10 ++++++---- backends/platform/wii/osystem_gfx.cpp | 14 ++++++++++---- 2 files changed, 16 insertions(+), 8 deletions(-) (limited to 'backends') diff --git a/backends/platform/wii/osystem.h b/backends/platform/wii/osystem.h index e4176e8415..2eb53f26a3 100644 --- a/backends/platform/wii/osystem.h +++ b/backends/platform/wii/osystem.h @@ -120,7 +120,8 @@ public: virtual int getDefaultGraphicsMode() const; virtual bool setGraphicsMode(int mode); virtual int getGraphicsMode() const; - virtual void initSize(uint width, uint height); + virtual void initSize(uint width, uint height, + const Graphics::PixelFormat *format); virtual int16 getWidth(); virtual int16 getHeight(); virtual void setPalette(const byte *colors, uint start, uint num); @@ -142,14 +143,15 @@ public: int x, int y, int w, int h); virtual int16 getOverlayWidth(); virtual int16 getOverlayHeight(); - virtual Graphics::PixelFormat getOverlayFormat() const { return Graphics::createPixelFormat<565>(); } + virtual Graphics::PixelFormat getOverlayFormat() const; 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, byte keycolor = 255, - int cursorTargetScale = 1); + int hotspotY, uint32 keycolor, + int cursorTargetScale, + const Graphics::PixelFormat *format); virtual bool pollEvent(Common::Event &event); virtual uint32 getMillis(); diff --git a/backends/platform/wii/osystem_gfx.cpp b/backends/platform/wii/osystem_gfx.cpp index 4454acb318..9c875eaa85 100644 --- a/backends/platform/wii/osystem_gfx.cpp +++ b/backends/platform/wii/osystem_gfx.cpp @@ -143,7 +143,8 @@ int OSystem_Wii::getGraphicsMode() const { return _activeGraphicsMode; } -void OSystem_Wii::initSize(uint width, uint height) { +void OSystem_Wii::initSize(uint width, uint height, + const Graphics::PixelFormat *format) { if (_gameWidth != width || _gameHeight != height) { printf("initSize %u %u\n", width, height); @@ -429,6 +430,10 @@ int16 OSystem_Wii::getOverlayHeight() { return _overlayHeight; } +Graphics::PixelFormat OSystem_Wii::getOverlayFormat() const { + return Graphics::createPixelFormat<565>(); +} + bool OSystem_Wii::showMouse(bool visible) { bool last = _mouseVisible; _mouseVisible = visible; @@ -442,15 +447,16 @@ void OSystem_Wii::warpMouse(int x, int y) { } void OSystem_Wii::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, - int hotspotY, byte keycolor, - int cursorTargetScale) { + int hotspotY, uint32 keycolor, + int cursorTargetScale, + const Graphics::PixelFormat *format) { (void) cursorTargetScale; // TODO _mouseWidth = w; _mouseHeight = h; _mouseHotspotX = hotspotX; _mouseHotspotY = hotspotY; - _mouseKeyColor = keycolor; + _mouseKeyColor = keycolor & 0xff; if (_mouseCursor) free(_mouseCursor); -- cgit v1.2.3 From 7d350b215c62f6d08c9bc33da9648fd72ee5599e Mon Sep 17 00:00:00 2001 From: Joost Peters Date: Fri, 21 Aug 2009 19:11:02 +0000 Subject: fix compilation after RGB API changes svn-id: r43606 --- backends/platform/psp/osys_psp.cpp | 6 +++--- backends/platform/psp/osys_psp.h | 4 ++-- backends/platform/psp/osys_psp_gu.cpp | 6 +++--- backends/platform/psp/osys_psp_gu.h | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) (limited to 'backends') diff --git a/backends/platform/psp/osys_psp.cpp b/backends/platform/psp/osys_psp.cpp index 5e461f45e0..d4b1c61537 100644 --- a/backends/platform/psp/osys_psp.cpp +++ b/backends/platform/psp/osys_psp.cpp @@ -143,7 +143,7 @@ int OSystem_PSP::getGraphicsMode() const { return -1; } -void OSystem_PSP::initSize(uint width, uint height) { +void OSystem_PSP::initSize(uint width, uint height, const Graphics::PixelFormat *format) { _overlayWidth = _screenWidth = width; _overlayHeight = _screenHeight = height; @@ -382,7 +382,7 @@ void OSystem_PSP::warpMouse(int x, int y) { _mouseY = y; } -void OSystem_PSP::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor, int cursorTargetScale) { +void OSystem_PSP::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format) { //TODO: handle cursorTargetScale _mouseWidth = w; _mouseHeight = h; @@ -390,7 +390,7 @@ void OSystem_PSP::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, _mouseHotspotX = hotspotX; _mouseHotspotY = hotspotY; - _mouseKeyColour = keycolor; + _mouseKeyColour = keycolor & 0xFF; free(_mouseBuf); diff --git a/backends/platform/psp/osys_psp.h b/backends/platform/psp/osys_psp.h index 94488a92ce..68e1a7da22 100644 --- a/backends/platform/psp/osys_psp.h +++ b/backends/platform/psp/osys_psp.h @@ -97,7 +97,7 @@ public: virtual bool setGraphicsMode(int mode); bool setGraphicsMode(const char *name); virtual int getGraphicsMode() const; - virtual void initSize(uint width, uint height); + virtual void initSize(uint width, uint height, const Graphics::PixelFormat *format); virtual int16 getWidth(); virtual int16 getHeight(); virtual void setPalette(const byte *colors, uint start, uint num); @@ -120,7 +120,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, byte keycolor = 255, int cursorTargetScale = 1); + virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format); virtual bool pollEvent(Common::Event &event); virtual uint32 getMillis(); diff --git a/backends/platform/psp/osys_psp_gu.cpp b/backends/platform/psp/osys_psp_gu.cpp index 1c83aa4abf..c13c5bc21f 100644 --- a/backends/platform/psp/osys_psp_gu.cpp +++ b/backends/platform/psp/osys_psp_gu.cpp @@ -141,7 +141,7 @@ OSystem_PSP_GU::~OSystem_PSP_GU() { sceGuTerm(); } -void OSystem_PSP_GU::initSize(uint width, uint height) { +void OSystem_PSP_GU::initSize(uint width, uint height, const Graphics::PixelFormat *format) { PSPDebugTrace("initSize\n"); _screenWidth = width; _screenHeight = height; @@ -192,7 +192,7 @@ int OSystem_PSP_GU::getGraphicsMode() const { return _graphicMode; } -void OSystem_PSP_GU::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor, int cursorTargetScale) { +void OSystem_PSP_GU::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format) { //TODO: handle cursorTargetScale _mouseWidth = w; _mouseHeight = h; @@ -200,7 +200,7 @@ void OSystem_PSP_GU::setMouseCursor(const byte *buf, uint w, uint h, int hotspot _mouseHotspotX = hotspotX; _mouseHotspotY = hotspotY; - _mouseKeyColour = keycolor; + _mouseKeyColour = keycolor & 0xFF; memcpy(mouseClut, _palette, 256*sizeof(unsigned short)); mouseClut[_mouseKeyColour] = 0; diff --git a/backends/platform/psp/osys_psp_gu.h b/backends/platform/psp/osys_psp_gu.h index c221971fc8..106b73b308 100644 --- a/backends/platform/psp/osys_psp_gu.h +++ b/backends/platform/psp/osys_psp_gu.h @@ -39,12 +39,12 @@ public: OSystem_PSP_GU(); ~OSystem_PSP_GU(); void updateScreen(); - void initSize(uint width, uint height); + void initSize(uint width, uint height, const Graphics::PixelFormat *format); int getDefaultGraphicsMode() const; bool setGraphicsMode(int mode); bool setGraphicsMode(const char *name); int getGraphicsMode() const; - void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor, int cursorTargetScale); + void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format); void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h) ; void setPalette(const byte *colors, uint start, uint num); void setCursorPalette(const byte *colors, uint start, uint num); -- cgit v1.2.3 From 4155e8eebf6aeb4ba90ff4901328a2bb9414eaa9 Mon Sep 17 00:00:00 2001 From: Andre Heider Date: Fri, 21 Aug 2009 19:45:49 +0000 Subject: This hopefully fixes the GP2x build (and kicks off buildbot) svn-id: r43607 --- backends/platform/gp2x/gp2x-common.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'backends') diff --git a/backends/platform/gp2x/gp2x-common.h b/backends/platform/gp2x/gp2x-common.h index 4e6421f353..c8bbd93de0 100644 --- a/backends/platform/gp2x/gp2x-common.h +++ b/backends/platform/gp2x/gp2x-common.h @@ -58,7 +58,7 @@ public: // Set the size of the video bitmap. // Typically, 320x200 - void initSize(uint w, uint h); + void initSize(uint w, uint h, const Graphics::PixelFormat *format); int getScreenChangeID() const { return _screenChangeCount; } @@ -87,7 +87,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, byte keycolor, int cursorTargetScale); + void setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format); // Set colors of cursor palette void setCursorPalette(const byte *colors, uint start, uint num); -- cgit v1.2.3 From 894635e91d7bdaa4517618a957441db016b2798b Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Fri, 21 Aug 2009 22:29:28 +0000 Subject: Attempt to fix builds that use the ARM screen column clear code; add new bitdepth argument that was missing in ARM builds previously. Also fix a few warnings. Also fix the WinCE build which fails in the SDL init call with a missing bitdepth field. Untested at this point (build certainly gets further than before). Committing this seems reasonable, as it can't make it any worse :) svn-id: r43614 --- backends/platform/wince/wince-sdl.cpp | 4 ++-- backends/platform/wince/wince-sdl.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'backends') diff --git a/backends/platform/wince/wince-sdl.cpp b/backends/platform/wince/wince-sdl.cpp index 65082014da..ab7860dd85 100644 --- a/backends/platform/wince/wince-sdl.cpp +++ b/backends/platform/wince/wince-sdl.cpp @@ -1084,7 +1084,7 @@ void OSystem_WINCE3::update_game_settings() { _noDoubleTapRMB = ConfMan.getBool("no_doubletap_rightclick"); } -void OSystem_WINCE3::initSize(uint w, uint h) { +void OSystem_WINCE3::initSize(uint w, uint h, const Graphics::PixelFormat *format) { if (_hasSmartphoneResolution && h == 240) h = 200; // mainly for the launcher @@ -1120,7 +1120,7 @@ void OSystem_WINCE3::initSize(uint w, uint h) { _videoMode.overlayWidth = w; _videoMode.overlayHeight = h; - OSystem_SDL::initSize(w, h); + OSystem_SDL::initSize(w, h, format); if (_scalersChanged) { unloadGFXMode(); diff --git a/backends/platform/wince/wince-sdl.h b/backends/platform/wince/wince-sdl.h index deafde6d80..7b4d0f2b25 100644 --- a/backends/platform/wince/wince-sdl.h +++ b/backends/platform/wince/wince-sdl.h @@ -66,7 +66,7 @@ public: void internUpdateScreen(); void setGraphicsModeIntern(); - void initSize(uint w, uint h); + void initSize(uint w, uint h, const Graphics::PixelFormat *format); void initBackend(); // Overloaded from SDL backend (toolbar handling) -- cgit v1.2.3 From 9a3218e67302e825b3df4e2f26df5601fb48f0db Mon Sep 17 00:00:00 2001 From: Joost Peters Date: Fri, 21 Aug 2009 22:30:35 +0000 Subject: unify OSystem_PSP_GU and OSystem_PSP (which was hopelessly outdated and mostly useless) svn-id: r43615 --- backends/platform/psp/Makefile | 1 - backends/platform/psp/module.mk | 1 - backends/platform/psp/osys_psp.cpp | 564 ++++++++++++++++++++++++++---- backends/platform/psp/osys_psp.h | 16 + backends/platform/psp/osys_psp_gu.cpp | 629 ---------------------------------- backends/platform/psp/osys_psp_gu.h | 61 ---- backends/platform/psp/psp_main.cpp | 4 +- 7 files changed, 520 insertions(+), 756 deletions(-) delete mode 100644 backends/platform/psp/osys_psp_gu.cpp delete mode 100644 backends/platform/psp/osys_psp_gu.h (limited to 'backends') diff --git a/backends/platform/psp/Makefile b/backends/platform/psp/Makefile index 64ce8a0161..8be3937ff2 100644 --- a/backends/platform/psp/Makefile +++ b/backends/platform/psp/Makefile @@ -83,7 +83,6 @@ TARGET = scummvm-psp OBJS := powerman.o \ psp_main.o \ osys_psp.o \ - osys_psp_gu.o \ kbd_ss_c.o \ kbd_s_c.o \ kbd_ls_c.o \ diff --git a/backends/platform/psp/module.mk b/backends/platform/psp/module.mk index 8f083c5dfa..a5c17ffa57 100644 --- a/backends/platform/psp/module.mk +++ b/backends/platform/psp/module.mk @@ -4,7 +4,6 @@ MODULE_OBJS := \ powerman.o \ psp_main.o \ osys_psp.o \ - osys_psp_gu.o \ kbd_ss_c.o \ kbd_s_c.o \ kbd_ls_c.o \ diff --git a/backends/platform/psp/osys_psp.cpp b/backends/platform/psp/osys_psp.cpp index d4b1c61537..a9e9aeb7d8 100644 --- a/backends/platform/psp/osys_psp.cpp +++ b/backends/platform/psp/osys_psp.cpp @@ -23,12 +23,19 @@ * */ +#include +#include + +#include +#include + #include "common/config-manager.h" #include "common/events.h" #include "common/rect.h" #include "common/scummsys.h" #include "osys_psp.h" +#include "trace.h" #include "backends/saves/psp/psp-saves.h" #include "backends/timer/default/default-timer.h" @@ -36,30 +43,62 @@ #include "graphics/scaler.h" #include "sound/mixer_intern.h" -#include -#include - -#include - -#include "./trace.h" #define SAMPLES_PER_SEC 44100 #define SCREEN_WIDTH 480 #define SCREEN_HEIGHT 272 +#define PIXEL_SIZE (4) +#define BUF_WIDTH (512) +#define PSP_SCREEN_WIDTH 480 +#define PSP_SCREEN_HEIGHT 272 +#define PSP_FRAME_SIZE (BUF_WIDTH * PSP_SCREEN_HEIGHT * PIXEL_SIZE) +#define MOUSE_SIZE 128 +#define KBD_DATA_SIZE 130560 + +#define MAX_FPS 30 + +unsigned int __attribute__((aligned(16))) displayList[262144]; +unsigned short __attribute__((aligned(16))) clut256[256]; +unsigned short __attribute__((aligned(16))) mouseClut[256]; +unsigned short __attribute__((aligned(16))) cursorPalette[256]; +unsigned short __attribute__((aligned(16))) kbClut[256]; +//unsigned int __attribute__((aligned(16))) offscreen256[640*480]; +//unsigned int __attribute__((aligned(16))) overlayBuffer256[640*480*2]; +unsigned int __attribute__((aligned(16))) mouseBuf256[MOUSE_SIZE*MOUSE_SIZE]; + +extern unsigned long RGBToColour(unsigned long r, unsigned long g, unsigned long b); + +extern unsigned int size_keyboard_symbols_compressed; +extern unsigned char keyboard_symbols_compressed[]; +extern unsigned int size_keyboard_symbols_shift_compressed; +extern unsigned char keyboard_symbols_shift_compressed[]; +extern unsigned int size_keyboard_letters_compressed; +extern unsigned char keyboard_letters_compressed[]; +extern unsigned int size_keyboard_letters_shift_compressed; +extern unsigned char keyboard_letters_shift_compressed[]; +unsigned char *keyboard_symbols; +unsigned char *keyboard_symbols_shift; +unsigned char *keyboard_letters; +unsigned char *keyboard_letters_shift; + +unsigned char kbd_ascii[] = {'1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', '[', ']', '\\', ';', '\'', ',', '.', '/', '`'}; +Common::KeyCode kbd_code[] = {Common::KEYCODE_1, Common::KEYCODE_2, Common::KEYCODE_3, Common::KEYCODE_4, Common::KEYCODE_5, Common::KEYCODE_6, Common::KEYCODE_7, Common::KEYCODE_8, Common::KEYCODE_9, Common::KEYCODE_0, Common::KEYCODE_MINUS, Common::KEYCODE_EQUALS, Common::KEYCODE_LEFTBRACKET, Common::KEYCODE_RIGHTBRACKET, + Common::KEYCODE_BACKSLASH, Common::KEYCODE_SEMICOLON, Common::KEYCODE_QUOTE, Common::KEYCODE_COMMA, Common::KEYCODE_PERIOD, Common::KEYCODE_SLASH, Common::KEYCODE_BACKQUOTE}; +unsigned char kbd_ascii_cl[] = {'!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', '{', '}', '|', ':', '"', '<', '>', '?', '~'}; +Common::KeyCode kbd_code_cl[] = {Common::KEYCODE_EXCLAIM, Common::KEYCODE_AT, Common::KEYCODE_HASH, Common::KEYCODE_DOLLAR, (Common::KeyCode)37, Common::KEYCODE_CARET, Common::KEYCODE_AMPERSAND, Common::KEYCODE_ASTERISK, Common::KEYCODE_LEFTPAREN, Common::KEYCODE_RIGHTPAREN, Common::KEYCODE_UNDERSCORE, + Common::KEYCODE_PLUS, (Common::KeyCode)123, (Common::KeyCode)125, (Common::KeyCode)124, Common::KEYCODE_COLON, Common::KEYCODE_QUOTEDBL, Common::KEYCODE_LESS, Common::KEYCODE_GREATER, Common::KEYCODE_QUESTION, (Common::KeyCode)126}; +#define CAPS_LOCK (1 << 0) +#define SYMBOLS (1 << 1) + + -unsigned short *DrawBuffer = (unsigned short *)0x44044000; -unsigned short *DisplayBuffer = (unsigned short *)0x44000000; unsigned long RGBToColour(unsigned long r, unsigned long g, unsigned long b) { return (((b >> 3) << 10) | ((g >> 3) << 5) | ((r >> 3) << 0)) | 0x8000; } -void putPixel(uint16 x, uint16 y, unsigned long colour) { - *(unsigned short *)(DrawBuffer + (y << 9) + x ) = colour; -} - static int timer_handler(int t) { DefaultTimerManager *tm = (DefaultTimerManager *)g_system->getTimerManager(); tm->handler(); @@ -76,7 +115,6 @@ const OSystem::GraphicsMode OSystem_PSP::s_supportedGraphicsModes[] = { OSystem_PSP::OSystem_PSP() : _screenWidth(0), _screenHeight(0), _overlayWidth(0), _overlayHeight(0), _offscreen(0), _overlayBuffer(0), _overlayVisible(false), _shakePos(0), _lastScreenUpdate(0), _mouseBuf(0), _prevButtons(0), _lastPadCheck(0), _padAccel(0), _mixer(0) { - memset(_palette, 0, sizeof(_palette)); _cursorPaletteDisabled = true; @@ -87,15 +125,75 @@ OSystem_PSP::OSystem_PSP() : _screenWidth(0), _screenHeight(0), _overlayWidth(0) uint32 sdlFlags = SDL_INIT_AUDIO | SDL_INIT_TIMER; SDL_Init(sdlFlags); - sceDisplaySetMode(0, SCREEN_WIDTH, SCREEN_HEIGHT); - sceDisplaySetFrameBuf((char *)DisplayBuffer, 512, 1, 1); + + //sceKernelDcacheWritebackAll(); + + // setup + sceGuInit(); + sceGuStart(0, displayList); + sceGuDrawBuffer(GU_PSM_8888, (void *)0, BUF_WIDTH); + sceGuDispBuffer(PSP_SCREEN_WIDTH, PSP_SCREEN_HEIGHT, (void*)PSP_FRAME_SIZE, BUF_WIDTH); + sceGuDepthBuffer((void*)(PSP_FRAME_SIZE * 2), BUF_WIDTH); + sceGuOffset(2048 - (PSP_SCREEN_WIDTH/2), 2048 - (PSP_SCREEN_HEIGHT/2)); + sceGuViewport(2048, 2048, PSP_SCREEN_WIDTH, PSP_SCREEN_HEIGHT); + sceGuDepthRange(0xC350, 0x2710); + sceGuScissor(0, 0, PSP_SCREEN_WIDTH, PSP_SCREEN_HEIGHT); + sceGuEnable(GU_SCISSOR_TEST); + sceGuFrontFace(GU_CW); + sceGuEnable(GU_TEXTURE_2D); + sceGuClear(GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT); + sceGuFinish(); + sceGuSync(0,0); + sceDisplayWaitVblankStart(); + sceGuDisplay(1); + + //decompress keyboard data + uLongf kbdSize = KBD_DATA_SIZE; + keyboard_letters = (unsigned char *)memalign(16, KBD_DATA_SIZE); + if (Z_OK != uncompress((Bytef *)keyboard_letters, &kbdSize, (const Bytef *)keyboard_letters_compressed, size_keyboard_letters_compressed)) + error("OSystem_PSP: uncompressing keyboard_letters failed"); + + kbdSize = KBD_DATA_SIZE; + keyboard_letters_shift = (unsigned char *)memalign(16, KBD_DATA_SIZE); + if (Z_OK != uncompress((Bytef *)keyboard_letters_shift, &kbdSize, (const Bytef *)keyboard_letters_shift_compressed, size_keyboard_letters_shift_compressed)) + error("OSystem_PSP: uncompressing keyboard_letters_shift failed"); + + kbdSize = KBD_DATA_SIZE; + keyboard_symbols = (unsigned char *)memalign(16, KBD_DATA_SIZE); + if (Z_OK != uncompress((Bytef *)keyboard_symbols, &kbdSize, (const Bytef *)keyboard_symbols_compressed, size_keyboard_symbols_compressed)) + error("OSystem_PSP: uncompressing keyboard_symbols failed"); + + kbdSize = KBD_DATA_SIZE; + keyboard_symbols_shift = (unsigned char *)memalign(16, KBD_DATA_SIZE); + if (Z_OK != uncompress((Bytef *)keyboard_symbols_shift, &kbdSize, (const Bytef *)keyboard_symbols_shift_compressed, size_keyboard_symbols_shift_compressed)) + error("OSystem_PSP: uncompressing keyboard_symbols_shift failed"); + + _keyboardVisible = false; + _clut = (unsigned short *)(((unsigned int)clut256) | 0x40000000); + _kbdClut = (unsigned short *)(((unsigned int)kbClut) | 0x40000000); + _mouseBuf = (byte *)mouseBuf256; + _graphicMode = STRETCHED_480X272; + _keySelected = 1; + _keyboardMode = 0; + _mouseX = PSP_SCREEN_WIDTH >> 1; + _mouseY = PSP_SCREEN_HEIGHT >> 1; } OSystem_PSP::~OSystem_PSP() { + free(keyboard_symbols_shift); + free(keyboard_symbols); + free(keyboard_letters_shift); + free(keyboard_letters); + free(_offscreen); free(_overlayBuffer); free(_mouseBuf); + + _offscreen = 0; + _overlayBuffer = 0; + _mouseBuf = 0; + sceGuTerm(); } @@ -128,36 +226,54 @@ const OSystem::GraphicsMode* OSystem_PSP::getSupportedGraphicsModes() const { int OSystem_PSP::getDefaultGraphicsMode() const { - return -1; + return STRETCHED_480X272; } bool OSystem_PSP::setGraphicsMode(int mode) { + _graphicMode = mode; return true; } bool OSystem_PSP::setGraphicsMode(const char *name) { - return true; + int i = 0; + + while (s_supportedGraphicsModes[i].name) { + if (!strcmpi(s_supportedGraphicsModes[i].name, name)) { + _graphicMode = s_supportedGraphicsModes[i].id; + return true; + } + i++; + } + + return false; } int OSystem_PSP::getGraphicsMode() const { - return -1; + return _graphicMode; } void OSystem_PSP::initSize(uint width, uint height, const Graphics::PixelFormat *format) { - _overlayWidth = _screenWidth = width; - _overlayHeight = _screenHeight = height; - - free(_offscreen); + PSPDebugTrace("initSize\n"); + _screenWidth = width; + _screenHeight = height; - _offscreen = (byte *)malloc(width * height); + _overlayWidth = PSP_SCREEN_WIDTH; //width; + _overlayHeight = PSP_SCREEN_HEIGHT; //height; - free(_overlayBuffer); +// _offscreen = (byte *)offscreen256; + _overlayBuffer = (OverlayColor *)0x44000000 + PSP_FRAME_SIZE; - _overlayBuffer = (OverlayColor *)malloc(_overlayWidth * _overlayHeight * sizeof(OverlayColor)); + _offscreen = (byte *)_overlayBuffer + _overlayWidth * _overlayHeight * sizeof(OverlayColor); bzero(_offscreen, width * height); clearOverlay(); - + memset(_palette, 0xFFFF, 256 * sizeof(unsigned short)); + _kbdClut[0] = 0xFFFF; + _kbdClut[246] = 0x4CCC; + _kbdClut[247] = 0x0000; + for (int i = 1; i < 31; i++) + _kbdClut[i] = 0xF888; _mouseVisible = false; + sceKernelDcacheWritebackAll(); } int16 OSystem_PSP::getWidth() { @@ -175,6 +291,34 @@ void OSystem_PSP::setPalette(const byte *colors, uint start, uint num) { _palette[start + i] = RGBToColour(b[0], b[1], b[2]); b += 4; } + + //copy to CLUT + memcpy(_clut, _palette, 256*sizeof(unsigned short)); + + //force update of mouse CLUT as well, as it may have been set up before this palette was set + memcpy(mouseClut, _palette, 256*sizeof(unsigned short)); + mouseClut[_mouseKeyColour] = 0; + + sceKernelDcacheWritebackAll(); +} + +void OSystem_PSP::setCursorPalette(const byte *colors, uint start, uint num) { + const byte *b = colors; + + for (uint i = 0; i < num; ++i) { + cursorPalette[start + i] = RGBToColour(b[0], b[1], b[2]); + b += 4; + } + + cursorPalette[0] = 0; + + _cursorPaletteDisabled = false; + + sceKernelDcacheWritebackAll(); +} + +void OSystem_PSP::disableCursorPalette(bool disable) { + _cursorPaletteDisabled = disable; } void OSystem_PSP::copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h) { @@ -204,10 +348,21 @@ void OSystem_PSP::copyRectToScreen(const byte *buf, int pitch, int x, int y, int byte *dst = _offscreen + y * _screenWidth + x; - if (_screenWidth == pitch && pitch == w) { + + if (_screenWidth == pitch && pitch == w) + { memcpy(dst, buf, h * w); - } else { - do { +/* + sceGuStart(0, displayList); + sceGuCopyImage( 3, 0, 0, w/2, h, w/2, (void *)buf, x/2, y, _screenWidth /2, _offscreen); + sceGuFinish(); + sceGuSync(0,0); +*/ + } + else + { + do + { memcpy(dst, buf, w); buf += pitch; dst += _screenWidth; @@ -230,52 +385,205 @@ void OSystem_PSP::unlockScreen() { } void OSystem_PSP::updateScreen() { - unsigned short *temp; + u32 now = getMillis(); + if (now - _lastScreenUpdate < 1000 / MAX_FPS) + return; - uint xStart = (SCREEN_WIDTH >> 1) - (_screenWidth >> 1); - uint yStart = (SCREEN_HEIGHT >> 1) - (_screenHeight >> 1); + _lastScreenUpdate = now; - for (int i = 0; i < _screenHeight; ++i) { - for (int j = 0; j < _screenWidth; ++j) { - putPixel(xStart + j, yStart + i, _palette[_offscreen[i * _screenWidth +j]]); - } + + sceGuStart(0, displayList); + + sceGuClearColor(0xFF000000); + sceGuClear(GU_COLOR_BUFFER_BIT); + + sceGuClutMode(GU_PSM_5551, 0, 0xFF, 0); + sceGuClutLoad(32, clut256); // upload 32*8 entries (256) + sceGuTexMode(GU_PSM_T8, 0, 0, 0); // 8-bit image + if (_screenWidth == 320) + sceGuTexImage(0, 512, 256, _screenWidth, _offscreen); + else + sceGuTexImage(0, 512, 512, _screenWidth, _offscreen); + sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGB); + sceGuTexFilter(GU_LINEAR, GU_LINEAR); + sceGuTexOffset(0,0); + sceGuAmbientColor(0xFFFFFFFF); + sceGuColor(0xFFFFFFFF); + + struct Vertex* vertices = (struct Vertex*)sceGuGetMemory(2 * sizeof(struct Vertex)); + vertices[0].u = 0.5; vertices[0].v = 0.5; + vertices[1].u = _screenWidth - 0.5; vertices[1].v = _screenHeight - 0.5; + switch(_graphicMode) { + case CENTERED_320X200: + vertices[0].x = (PSP_SCREEN_WIDTH - 320) / 2; vertices[0].y = (PSP_SCREEN_HEIGHT - 200) / 2; vertices[0].z = 0; + vertices[1].x = PSP_SCREEN_WIDTH - (PSP_SCREEN_WIDTH - 320) / 2; vertices[1].y = PSP_SCREEN_HEIGHT - (PSP_SCREEN_HEIGHT - 200) / 2; vertices[1].z = 0; + break; + case CENTERED_435X272: + vertices[0].x = (PSP_SCREEN_WIDTH - 435) / 2; vertices[0].y = 0; vertices[0].z = 0; + vertices[1].x = PSP_SCREEN_WIDTH - (PSP_SCREEN_WIDTH - 435) / 2; vertices[1].y = PSP_SCREEN_HEIGHT; vertices[1].z = 0; + break; + case STRETCHED_480X272: + vertices[0].x = 0; vertices[0].y = 0; vertices[0].z = 0; + vertices[1].x = PSP_SCREEN_WIDTH; vertices[1].y = PSP_SCREEN_HEIGHT; vertices[1].z = 0; + break; + case CENTERED_362X272: + vertices[0].x = (PSP_SCREEN_WIDTH - 362) / 2; vertices[0].y = 0; vertices[0].z = 0; + vertices[1].x = PSP_SCREEN_WIDTH - (PSP_SCREEN_WIDTH - 362) / 2; vertices[1].y = PSP_SCREEN_HEIGHT; vertices[1].z = 0; + break; } - if (_overlayVisible) { - for (int i = 0; i < _screenHeight; ++i) { - for (int j = 0; j < _screenWidth; ++j) { + if (_shakePos) { + vertices[0].y += _shakePos; + vertices[1].y += _shakePos; + } - OverlayColor pixel = _overlayBuffer[(i * _overlayWidth +j)]; + sceGuDrawArray(GU_SPRITES, GU_TEXTURE_32BITF|GU_VERTEX_32BITF|GU_TRANSFORM_2D, 2, 0, vertices); + if (_screenWidth == 640) { + sceGuTexImage(0, 512, 512, _screenWidth, _offscreen+512); + vertices[0].u = 512 + 0.5; vertices[1].v = _screenHeight - 0.5; + vertices[0].x += (vertices[1].x - vertices[0].x) * 511 / 640; vertices[0].y = 0; vertices[0].z = 0; + sceGuDrawArray(GU_SPRITES, GU_TEXTURE_32BITF|GU_VERTEX_32BITF|GU_TRANSFORM_2D, 2, 0, vertices); + } - if (pixel & 0x8000) - putPixel(xStart + j, yStart + i, pixel); - } + + // draw overlay + if (_overlayVisible) { + vertices[0].x = 0; vertices[0].y = 0; vertices[0].z = 0; + vertices[1].x = PSP_SCREEN_WIDTH; vertices[1].y = PSP_SCREEN_HEIGHT; vertices[1].z = 0; + vertices[0].u = 0.5; vertices[0].v = 0.5; + vertices[1].u = _overlayWidth - 0.5; vertices[1].v = _overlayHeight - 0.5; + sceGuTexMode(GU_PSM_4444, 0, 0, 0); // 16-bit image + sceGuDisable(GU_ALPHA_TEST); + sceGuEnable(GU_BLEND); + + //sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0); + sceGuBlendFunc(GU_ADD, GU_FIX, GU_ONE_MINUS_SRC_ALPHA, 0xFFFFFFFF, 0); + + if (_overlayWidth > 320) + sceGuTexImage(0, 512, 512, _overlayWidth, _overlayBuffer); + else + sceGuTexImage(0, 512, 256, _overlayWidth, _overlayBuffer); + + sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGBA); + sceGuDrawArray(GU_SPRITES,GU_TEXTURE_32BITF|GU_VERTEX_32BITF|GU_TRANSFORM_2D,2,0,vertices); + // need to render twice for textures > 512 + if ( _overlayWidth > 512) { + sceGuTexImage(0, 512, 512, _overlayWidth, _overlayBuffer + 512); + vertices[0].u = 512 + 0.5; vertices[1].v = _overlayHeight - 0.5; + vertices[0].x = PSP_SCREEN_WIDTH * 512 / 640; vertices[0].y = 0; vertices[0].z = 0; + sceGuDrawArray(GU_SPRITES, GU_TEXTURE_32BITF|GU_VERTEX_32BITF|GU_TRANSFORM_2D, 2, 0, vertices); } + sceGuDisable(GU_BLEND); } - //draw mouse on top + // draw mouse if (_mouseVisible) { - for (int y = 0; y < _mouseHeight; ++y) { - for (int x = 0; x < _mouseWidth; ++x) { - if (_mouseBuf[y * _mouseHeight + x] != _mouseKeyColour) { - int my = _mouseY + y; // + _mouseHotspotY; - int mx = _mouseX + x; // + _mouseHotspotX; - - if (mx >= 0 && mx < _screenWidth && my >= 0 && my < _screenHeight) - putPixel(xStart + mx, yStart + my, _palette[_mouseBuf[y * _mouseHeight + x]]); - } + sceGuTexMode(GU_PSM_T8, 0, 0, 0); // 8-bit image + sceGuClutMode(GU_PSM_5551, 0, 0xFF, 0); + sceGuClutLoad(32, _cursorPaletteDisabled ? mouseClut : cursorPalette); // upload 32*8 entries (256) + sceGuAlphaFunc(GU_GREATER, 0, 0xFF); + sceGuEnable(GU_ALPHA_TEST); + sceGuTexImage(0, MOUSE_SIZE, MOUSE_SIZE, MOUSE_SIZE, _mouseBuf); + sceGuTexFunc(GU_TFX_MODULATE, GU_TCC_RGBA); + + vertices[0].u = 0.5; vertices[0].v = 0.5; + vertices[1].u = _mouseWidth - 0.5; vertices[1].v = _mouseHeight - 0.5; + + //adjust cursor position + int mX = _mouseX - _mouseHotspotX; + int mY = _mouseY - _mouseHotspotY; + + if (_overlayVisible) { + float scalex, scaley; + + scalex = (float)PSP_SCREEN_WIDTH /_overlayWidth; + scaley = (float)PSP_SCREEN_HEIGHT /_overlayHeight; + + vertices[0].x = mX * scalex; vertices[0].y = mY * scaley; vertices[0].z = 0; + vertices[1].x = vertices[0].x + _mouseWidth * scalex; vertices[1].y = vertices[0].y + _mouseHeight * scaley; vertices[0].z = 0; + } else + switch(_graphicMode) { + case CENTERED_320X200: + vertices[0].x = (PSP_SCREEN_WIDTH - 320) / 2 + mX; vertices[0].y = (PSP_SCREEN_HEIGHT - 200) / 2 + mY; vertices[0].z = 0; + vertices[1].x = vertices[0].x+_mouseWidth; vertices[1].y = vertices[0].y + _mouseHeight; vertices[1].z = 0; + break; + case CENTERED_435X272: + { + float scalex, scaley; + + scalex = 435.0f / _screenWidth; + scaley = 272.0f / _screenHeight; + + vertices[0].x = (PSP_SCREEN_WIDTH - 435) / 2 + mX * scalex; vertices[0].y = mY * scaley; vertices[0].z = 0; + vertices[1].x = vertices[0].x + _mouseWidth * scalex; vertices[1].y = vertices[0].y + _mouseHeight * scaley; vertices[0].z = 0; + + } + break; + case CENTERED_362X272: + { + float scalex, scaley; + + scalex = 362.0f / _screenWidth; + scaley = 272.0f / _screenHeight; + + vertices[0].x = (PSP_SCREEN_WIDTH - 362) / 2 + mX * scalex; vertices[0].y = mY * scaley; vertices[0].z = 0; + vertices[1].x = vertices[0].x + _mouseWidth * scalex; vertices[1].y = vertices[0].y + _mouseHeight * scaley; vertices[0].z = 0; + } + break; + case STRETCHED_480X272: + { + float scalex, scaley; + + scalex = (float)PSP_SCREEN_WIDTH / _screenWidth; + scaley = (float)PSP_SCREEN_HEIGHT / _screenHeight; + + vertices[0].x = mX * scalex; vertices[0].y = mY * scaley; vertices[0].z = 0; + vertices[1].x = vertices[0].x + _mouseWidth * scalex; vertices[1].y = vertices[0].y + _mouseHeight * scaley; vertices[0].z = 0; } + break; } + sceGuDrawArray(GU_SPRITES, GU_TEXTURE_32BITF|GU_VERTEX_32BITF|GU_TRANSFORM_2D, 2, 0, vertices); } + if (_keyboardVisible) { + sceGuTexMode(GU_PSM_T8, 0, 0, 0); // 8-bit image + sceGuClutMode(GU_PSM_4444, 0, 0xFF, 0); + sceGuClutLoad(32, kbClut); // upload 32*8 entries (256) + sceGuDisable(GU_ALPHA_TEST); + sceGuEnable(GU_BLEND); + sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0); + switch(_keyboardMode) { + case 0: + sceGuTexImage(0, 512, 512, 480, keyboard_letters); + break; + case CAPS_LOCK: + sceGuTexImage(0, 512, 512, 480, keyboard_letters_shift); + break; + case SYMBOLS: + sceGuTexImage(0, 512, 512, 480, keyboard_symbols); + break; + case (CAPS_LOCK | SYMBOLS): + sceGuTexImage(0, 512, 512, 480, keyboard_symbols_shift); + break; + } + sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGBA); + + vertices[0].u = 0.5; vertices[0].v = 0.5; + vertices[1].u = PSP_SCREEN_WIDTH-0.5; vertices[1].v = PSP_SCREEN_HEIGHT-0.5; + vertices[0].x = 0; vertices[0].y = 0; vertices[0].z = 0; + vertices[1].x = PSP_SCREEN_WIDTH; vertices[1].y = PSP_SCREEN_HEIGHT; vertices[0].z = 0; + sceGuDrawArray(GU_SPRITES,GU_TEXTURE_32BITF|GU_VERTEX_32BITF|GU_TRANSFORM_2D,2,0,vertices); + sceGuDisable(GU_BLEND); + } + sceKernelDcacheWritebackAll(); + + sceGuFinish(); + sceGuSync(0,0); - // switch buffers - temp = DrawBuffer; - DrawBuffer = DisplayBuffer; - DisplayBuffer = temp; sceDisplayWaitVblankStart(); - sceDisplaySetFrameBuf((char *)DisplayBuffer, 512, 1, 1); + sceGuSwapBuffers(); + //sceKernelDcacheWritebackAll(); } void OSystem_PSP::setShakePos(int shakeOffset) { @@ -392,16 +700,18 @@ void OSystem_PSP::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, _mouseKeyColour = keycolor & 0xFF; - free(_mouseBuf); + memcpy(mouseClut, _palette, 256 * sizeof(unsigned short)); + mouseClut[_mouseKeyColour] = 0; + sceKernelDcacheWritebackAll(); - _mouseBuf = (byte *)malloc(w * h); - memcpy(_mouseBuf, buf, w * h); + for (unsigned int i = 0; i < h; i++) + memcpy(_mouseBuf + i * MOUSE_SIZE, buf + i * w, w); } #define PAD_CHECK_TIME 40 #define PAD_DIR_MASK (PSP_CTRL_UP | PSP_CTRL_DOWN | PSP_CTRL_LEFT | PSP_CTRL_RIGHT) -bool OSystem_PSP::pollEvent(Common::Event &event) { +bool OSystem_PSP::processInput(Common::Event &event) { s8 analogStepAmountX = 0; s8 analogStepAmountY = 0; /* @@ -543,6 +853,136 @@ bool OSystem_PSP::pollEvent(Common::Event &event) { return false; } +bool OSystem_PSP::pollEvent(Common::Event &event) { + float nub_angle = -1; + int x, y; + + sceCtrlSetSamplingCycle(0); + sceCtrlSetSamplingMode(1); + sceCtrlReadBufferPositive(&pad, 1); + + uint32 buttonsChanged = pad.Buttons ^ _prevButtons; + + if ((buttonsChanged & PSP_CTRL_SELECT) || (pad.Buttons & PSP_CTRL_SELECT)) { + if ( !(pad.Buttons & PSP_CTRL_SELECT) ) + _keyboardVisible = !_keyboardVisible; + _prevButtons = pad.Buttons; + return false; + } + + if (!_keyboardVisible) + return processInput(event); + + if ( (buttonsChanged & PSP_CTRL_RTRIGGER) && !(pad.Buttons & PSP_CTRL_RTRIGGER)) + _keyboardMode ^= CAPS_LOCK; + + if ( (buttonsChanged & PSP_CTRL_LTRIGGER) && !(pad.Buttons & PSP_CTRL_LTRIGGER)) + _keyboardMode ^= SYMBOLS; + + if ( (buttonsChanged & PSP_CTRL_LEFT) && !(pad.Buttons & PSP_CTRL_LEFT)) { + event.kbd.flags = 0; + event.kbd.ascii = 0; + event.kbd.keycode = Common::KEYCODE_LEFT; + _prevButtons = pad.Buttons; + return true; + } + + if ( (buttonsChanged & PSP_CTRL_RIGHT) && !(pad.Buttons & PSP_CTRL_RIGHT)) { + event.kbd.flags = 0; + event.kbd.ascii = 0; + event.kbd.keycode = Common::KEYCODE_RIGHT; + _prevButtons = pad.Buttons; + return true; + } + + if ( (buttonsChanged & PSP_CTRL_UP) && !(pad.Buttons & PSP_CTRL_UP)) { + event.kbd.flags = 0; + event.kbd.ascii = 0; + event.kbd.keycode = Common::KEYCODE_UP; + _prevButtons = pad.Buttons; + return true; + } + + if ( (buttonsChanged & PSP_CTRL_DOWN) && !(pad.Buttons & PSP_CTRL_DOWN)) { + event.kbd.flags = 0; + event.kbd.ascii = 0; + event.kbd.keycode = Common::KEYCODE_DOWN; + _prevButtons = pad.Buttons; + return true; + } + + // compute nub direction + x = pad.Lx-128; + y = pad.Ly-128; + _kbdClut[_keySelected] = 0xf888; + if (x*x + y*y > 10000) { + nub_angle = atan2(y, x); + _keySelected = (int)(1 + (M_PI + nub_angle) * 30 / (2 * M_PI)); + _keySelected -= 2; + if (_keySelected < 1) + _keySelected += 30; + _kbdClut[_keySelected] = 0xFFFF; + + if (buttonsChanged & PSP_CTRL_CROSS) { + event.type = (pad.Buttons & PSP_CTRL_CROSS) ? Common::EVENT_KEYDOWN : Common::EVENT_KEYUP; + if (_keySelected > 26) { + event.kbd.flags = 0; + switch(_keySelected) { + case 27: + event.kbd.ascii = ' '; + event.kbd.keycode = Common::KEYCODE_SPACE; + break; + case 28: + event.kbd.ascii = 127; + event.kbd.keycode = Common::KEYCODE_DELETE; + break; + case 29: + event.kbd.ascii = 8; + event.kbd.keycode = Common::KEYCODE_BACKSPACE; + break; + case 30: + event.kbd.ascii = 13; + event.kbd.keycode = Common::KEYCODE_RETURN; + break; + } + } else { + switch( _keyboardMode) { + case 0: + event.kbd.flags = 0; + event.kbd.ascii = 'a'+_keySelected-1; + event.kbd.keycode = (Common::KeyCode)(Common::KEYCODE_a + _keySelected-1); + break; + case CAPS_LOCK: + event.kbd.ascii = 'A'+_keySelected-1; + event.kbd.keycode = (Common::KeyCode)(Common::KEYCODE_a + _keySelected-1); + event.kbd.flags = Common::KBD_SHIFT; + break; + case SYMBOLS: + if (_keySelected < 21) { + event.kbd.flags = 0; + event.kbd.ascii = kbd_ascii[_keySelected-1]; + event.kbd.keycode = kbd_code[ _keySelected-1]; + } + break; + case (SYMBOLS|CAPS_LOCK): + if (_keySelected < 21) { + event.kbd.flags = 0; + event.kbd.ascii = kbd_ascii_cl[_keySelected-1]; + event.kbd.keycode = kbd_code_cl[ _keySelected-1]; + } + break; + } + } + _prevButtons = pad.Buttons; + return true; + } + } + + _prevButtons = pad.Buttons; + return false; +} + + uint32 OSystem_PSP::getMillis() { return SDL_GetTicks(); } diff --git a/backends/platform/psp/osys_psp.h b/backends/platform/psp/osys_psp.h index 68e1a7da22..353561cced 100644 --- a/backends/platform/psp/osys_psp.h +++ b/backends/platform/psp/osys_psp.h @@ -50,6 +50,11 @@ public: static OSystem *instance(); protected: + struct Vertex { + float u,v; + float x,y,z; + }; + uint16 _screenWidth; uint16 _screenHeight; uint16 _overlayWidth; @@ -71,6 +76,14 @@ protected: byte *_mouseBuf; bool _cursorPaletteDisabled; + int _graphicMode; + Vertex *_vertices; + unsigned short* _clut; + unsigned short* _kbdClut; + bool _keyboardVisible; + int _keySelected; + int _keyboardMode; + uint32 _prevButtons; uint32 _lastPadCheck; uint32 _padAccel; @@ -101,6 +114,8 @@ public: virtual int16 getWidth(); virtual int16 getHeight(); virtual void setPalette(const byte *colors, uint start, uint num); + virtual void setCursorPalette(const byte *colors, uint start, uint num); + virtual void disableCursorPalette(bool disable); virtual void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h); virtual Graphics::Surface *lockScreen(); virtual void unlockScreen(); @@ -123,6 +138,7 @@ public: virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format); virtual bool pollEvent(Common::Event &event); + virtual bool processInput(Common::Event &event); virtual uint32 getMillis(); virtual void delayMillis(uint msecs); diff --git a/backends/platform/psp/osys_psp_gu.cpp b/backends/platform/psp/osys_psp_gu.cpp deleted file mode 100644 index c13c5bc21f..0000000000 --- a/backends/platform/psp/osys_psp_gu.cpp +++ /dev/null @@ -1,629 +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. - * - * $URL$ - * $Id$ - */ - -#include "osys_psp_gu.h" -#include "trace.h" -#include "common/events.h" - -#include - -#include - -#define PIXEL_SIZE (4) -#define BUF_WIDTH (512) -#define PSP_SCREEN_WIDTH 480 -#define PSP_SCREEN_HEIGHT 272 -#define PSP_FRAME_SIZE (BUF_WIDTH * PSP_SCREEN_HEIGHT * PIXEL_SIZE) -#define MOUSE_SIZE 128 -#define KBD_DATA_SIZE 130560 - -#define MAX_FPS 30 - -unsigned int __attribute__((aligned(16))) list[262144]; -unsigned short __attribute__((aligned(16))) clut256[256]; -unsigned short __attribute__((aligned(16))) mouseClut[256]; -unsigned short __attribute__((aligned(16))) cursorPalette[256]; -unsigned short __attribute__((aligned(16))) kbClut[256]; -//unsigned int __attribute__((aligned(16))) offscreen256[640*480]; -//unsigned int __attribute__((aligned(16))) overlayBuffer256[640*480*2]; -unsigned int __attribute__((aligned(16))) mouseBuf256[MOUSE_SIZE*MOUSE_SIZE]; - -extern unsigned long RGBToColour(unsigned long r, unsigned long g, unsigned long b); - -extern unsigned int size_keyboard_symbols_compressed; -extern unsigned char keyboard_symbols_compressed[]; -extern unsigned int size_keyboard_symbols_shift_compressed; -extern unsigned char keyboard_symbols_shift_compressed[]; -extern unsigned int size_keyboard_letters_compressed; -extern unsigned char keyboard_letters_compressed[]; -extern unsigned int size_keyboard_letters_shift_compressed; -extern unsigned char keyboard_letters_shift_compressed[]; -unsigned char *keyboard_symbols; -unsigned char *keyboard_symbols_shift; -unsigned char *keyboard_letters; -unsigned char *keyboard_letters_shift; - -unsigned char kbd_ascii[] = {'1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', '[', ']', '\\', ';', '\'', ',', '.', '/', '`'}; -Common::KeyCode kbd_code[] = {Common::KEYCODE_1, Common::KEYCODE_2, Common::KEYCODE_3, Common::KEYCODE_4, Common::KEYCODE_5, Common::KEYCODE_6, Common::KEYCODE_7, Common::KEYCODE_8, Common::KEYCODE_9, Common::KEYCODE_0, Common::KEYCODE_MINUS, Common::KEYCODE_EQUALS, Common::KEYCODE_LEFTBRACKET, Common::KEYCODE_RIGHTBRACKET, - Common::KEYCODE_BACKSLASH, Common::KEYCODE_SEMICOLON, Common::KEYCODE_QUOTE, Common::KEYCODE_COMMA, Common::KEYCODE_PERIOD, Common::KEYCODE_SLASH, Common::KEYCODE_BACKQUOTE}; -unsigned char kbd_ascii_cl[] = {'!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', '{', '}', '|', ':', '"', '<', '>', '?', '~'}; -Common::KeyCode kbd_code_cl[] = {Common::KEYCODE_EXCLAIM, Common::KEYCODE_AT, Common::KEYCODE_HASH, Common::KEYCODE_DOLLAR, (Common::KeyCode)37, Common::KEYCODE_CARET, Common::KEYCODE_AMPERSAND, Common::KEYCODE_ASTERISK, Common::KEYCODE_LEFTPAREN, Common::KEYCODE_RIGHTPAREN, Common::KEYCODE_UNDERSCORE, - Common::KEYCODE_PLUS, (Common::KeyCode)123, (Common::KeyCode)125, (Common::KeyCode)124, Common::KEYCODE_COLON, Common::KEYCODE_QUOTEDBL, Common::KEYCODE_LESS, Common::KEYCODE_GREATER, Common::KEYCODE_QUESTION, (Common::KeyCode)126}; -#define CAPS_LOCK (1 << 0) -#define SYMBOLS (1 << 1) - - -OSystem_PSP_GU::OSystem_PSP_GU() { - //sceKernelDcacheWritebackAll(); - - // setup - sceGuInit(); - sceGuStart(0, list); - sceGuDrawBuffer(GU_PSM_8888, (void *)0, BUF_WIDTH); - sceGuDispBuffer(PSP_SCREEN_WIDTH, PSP_SCREEN_HEIGHT, (void*)PSP_FRAME_SIZE, BUF_WIDTH); - sceGuDepthBuffer((void*)(PSP_FRAME_SIZE * 2), BUF_WIDTH); - sceGuOffset(2048 - (PSP_SCREEN_WIDTH/2), 2048 - (PSP_SCREEN_HEIGHT/2)); - sceGuViewport(2048, 2048, PSP_SCREEN_WIDTH, PSP_SCREEN_HEIGHT); - sceGuDepthRange(0xc350, 0x2710); - sceGuScissor(0, 0, PSP_SCREEN_WIDTH, PSP_SCREEN_HEIGHT); - sceGuEnable(GU_SCISSOR_TEST); - sceGuFrontFace(GU_CW); - sceGuEnable(GU_TEXTURE_2D); - sceGuClear(GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT); - sceGuFinish(); - sceGuSync(0,0); - - sceDisplayWaitVblankStart(); - sceGuDisplay(1); - - //decompress keyboard data - uLongf kbdSize = KBD_DATA_SIZE; - keyboard_letters = (unsigned char *)memalign(16, KBD_DATA_SIZE); - if (Z_OK != uncompress((Bytef *)keyboard_letters, &kbdSize, (const Bytef *)keyboard_letters_compressed, size_keyboard_letters_compressed)) - error("OSystem_PSP_GU: uncompressing keyboard_letters failed"); - - kbdSize = KBD_DATA_SIZE; - keyboard_letters_shift = (unsigned char *)memalign(16, KBD_DATA_SIZE); - if (Z_OK != uncompress((Bytef *)keyboard_letters_shift, &kbdSize, (const Bytef *)keyboard_letters_shift_compressed, size_keyboard_letters_shift_compressed)) - error("OSystem_PSP_GU: uncompressing keyboard_letters_shift failed"); - - kbdSize = KBD_DATA_SIZE; - keyboard_symbols = (unsigned char *)memalign(16, KBD_DATA_SIZE); - if (Z_OK != uncompress((Bytef *)keyboard_symbols, &kbdSize, (const Bytef *)keyboard_symbols_compressed, size_keyboard_symbols_compressed)) - error("OSystem_PSP_GU: uncompressing keyboard_symbols failed"); - - kbdSize = KBD_DATA_SIZE; - keyboard_symbols_shift = (unsigned char *)memalign(16, KBD_DATA_SIZE); - if (Z_OK != uncompress((Bytef *)keyboard_symbols_shift, &kbdSize, (const Bytef *)keyboard_symbols_shift_compressed, size_keyboard_symbols_shift_compressed)) - error("OSystem_PSP_GU: uncompressing keyboard_symbols_shift failed"); - - _keyboardVisible = false; - _clut = (unsigned short*)(((unsigned int)clut256)|0x40000000); - _kbdClut = (unsigned short*)(((unsigned int)kbClut)|0x40000000); - _mouseBuf = (byte *)mouseBuf256; - _graphicMode = STRETCHED_480X272; - _keySelected = 1; - _keyboardMode = 0; - _mouseX = PSP_SCREEN_WIDTH >> 1; - _mouseY = PSP_SCREEN_HEIGHT >> 1; -} - -OSystem_PSP_GU::~OSystem_PSP_GU() { - free(keyboard_symbols_shift); - free(keyboard_symbols); - free(keyboard_letters_shift); - free(keyboard_letters); - - _offscreen = 0; - _overlayBuffer = 0; - _mouseBuf = 0; - sceGuTerm(); -} - -void OSystem_PSP_GU::initSize(uint width, uint height, const Graphics::PixelFormat *format) { - PSPDebugTrace("initSize\n"); - _screenWidth = width; - _screenHeight = height; - - _overlayWidth = PSP_SCREEN_WIDTH; //width; - _overlayHeight = PSP_SCREEN_HEIGHT; //height; - -// _offscreen = (byte *)offscreen256; - _overlayBuffer = (OverlayColor *)0x44000000 + PSP_FRAME_SIZE; - - _offscreen = (byte *)_overlayBuffer + _overlayWidth * _overlayHeight * sizeof(OverlayColor); - bzero(_offscreen, width * height); - clearOverlay(); - memset(_palette, 0xffff, 256 * sizeof(unsigned short)); - _kbdClut[0] = 0xffff; - _kbdClut[246] = 0x4ccc; - _kbdClut[247] = 0x0000; - for (int i=1;i<31;i++) - _kbdClut[i] = 0xf888; - _mouseVisible = false; - sceKernelDcacheWritebackAll(); -} - -int OSystem_PSP_GU::getDefaultGraphicsMode() const { - return STRETCHED_480X272; -} - -bool OSystem_PSP_GU::setGraphicsMode(int mode) { - _graphicMode = mode; - return true; -} - -bool OSystem_PSP_GU::setGraphicsMode(const char *name) { - int i = 0; - - while (s_supportedGraphicsModes[i].name) { - if (!strcmpi(s_supportedGraphicsModes[i].name, name)) { - _graphicMode = s_supportedGraphicsModes[i].id; - return true; - } - i++; - } - - return false; -} - -int OSystem_PSP_GU::getGraphicsMode() const { - return _graphicMode; -} - -void OSystem_PSP_GU::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format) { - //TODO: handle cursorTargetScale - _mouseWidth = w; - _mouseHeight = h; - - _mouseHotspotX = hotspotX; - _mouseHotspotY = hotspotY; - - _mouseKeyColour = keycolor & 0xFF; - - memcpy(mouseClut, _palette, 256*sizeof(unsigned short)); - mouseClut[_mouseKeyColour] = 0; - sceKernelDcacheWritebackAll(); - - for (unsigned int i=0;i _screenWidth - x) { - w = _screenWidth - x; - } - - if (h > _screenHeight - y) { - h = _screenHeight - y; - } - - if (w <= 0 || h <= 0) - return; - - - byte *dst = _offscreen + y * _screenWidth + x; - - if (_screenWidth == pitch && pitch == w) - { - memcpy(dst, buf, h * w); -/* - sceGuStart(0,list); - sceGuCopyImage( 3, 0, 0, w/2, h, w/2, (void *)buf, x/2, y, _screenWidth /2, _offscreen); - sceGuFinish(); - sceGuSync(0,0); -*/ - } - else - { - do - { - memcpy(dst, buf, w); - buf += pitch; - dst += _screenWidth; - } while (--h); - } -} - -void OSystem_PSP_GU::updateScreen() { - u32 now = getMillis(); - if (now - _lastScreenUpdate < 1000 / MAX_FPS) - return; - - _lastScreenUpdate = now; - - - sceGuStart(0,list); - - sceGuClearColor(0xff000000); - sceGuClear(GU_COLOR_BUFFER_BIT); - - sceGuClutMode(GU_PSM_5551, 0, 0xff, 0); - sceGuClutLoad(32, clut256); // upload 32*8 entries (256) - sceGuTexMode(GU_PSM_T8, 0, 0, 0); // 8-bit image - if (_screenWidth == 320) - sceGuTexImage(0, 512, 256, _screenWidth, _offscreen); - else - sceGuTexImage(0, 512, 512, _screenWidth, _offscreen); - sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGB); - sceGuTexFilter(GU_LINEAR, GU_LINEAR); - sceGuTexOffset(0,0); - sceGuAmbientColor(0xffffffff); - sceGuColor(0xffffffff); - - struct Vertex* vertices = (struct Vertex*)sceGuGetMemory(2 * sizeof(struct Vertex)); - vertices[0].u = 0.5; vertices[0].v = 0.5; - vertices[1].u = _screenWidth - 0.5; vertices[1].v = _screenHeight - 0.5; - switch(_graphicMode) { - case CENTERED_320X200: - vertices[0].x = (PSP_SCREEN_WIDTH - 320) / 2; vertices[0].y = (PSP_SCREEN_HEIGHT - 200) / 2; vertices[0].z = 0; - vertices[1].x = PSP_SCREEN_WIDTH - (PSP_SCREEN_WIDTH - 320) / 2; vertices[1].y = PSP_SCREEN_HEIGHT - (PSP_SCREEN_HEIGHT - 200) / 2; vertices[1].z = 0; - break; - case CENTERED_435X272: - vertices[0].x = (PSP_SCREEN_WIDTH - 435) / 2; vertices[0].y = 0; vertices[0].z = 0; - vertices[1].x = PSP_SCREEN_WIDTH - (PSP_SCREEN_WIDTH - 435) / 2; vertices[1].y = PSP_SCREEN_HEIGHT; vertices[1].z = 0; - break; - case STRETCHED_480X272: - vertices[0].x = 0; vertices[0].y = 0; vertices[0].z = 0; - vertices[1].x = PSP_SCREEN_WIDTH; vertices[1].y = PSP_SCREEN_HEIGHT; vertices[1].z = 0; - break; - case CENTERED_362X272: - vertices[0].x = (PSP_SCREEN_WIDTH - 362) / 2; vertices[0].y = 0; vertices[0].z = 0; - vertices[1].x = PSP_SCREEN_WIDTH - (PSP_SCREEN_WIDTH - 362) / 2; vertices[1].y = PSP_SCREEN_HEIGHT; vertices[1].z = 0; - break; - } - - if (_shakePos) { - vertices[0].y += _shakePos; - vertices[1].y += _shakePos; - } - - sceGuDrawArray(GU_SPRITES, GU_TEXTURE_32BITF|GU_VERTEX_32BITF|GU_TRANSFORM_2D, 2, 0, vertices); - if (_screenWidth == 640) { - sceGuTexImage(0, 512, 512, _screenWidth, _offscreen+512); - vertices[0].u = 512 + 0.5; vertices[1].v = _screenHeight - 0.5; - vertices[0].x += (vertices[1].x - vertices[0].x) * 511 / 640; vertices[0].y = 0; vertices[0].z = 0; - sceGuDrawArray(GU_SPRITES, GU_TEXTURE_32BITF|GU_VERTEX_32BITF|GU_TRANSFORM_2D, 2, 0, vertices); - } - - - // draw overlay - if (_overlayVisible) { - vertices[0].x = 0; vertices[0].y = 0; vertices[0].z = 0; - vertices[1].x = PSP_SCREEN_WIDTH; vertices[1].y = PSP_SCREEN_HEIGHT; vertices[1].z = 0; - vertices[0].u = 0.5; vertices[0].v = 0.5; - vertices[1].u = _overlayWidth - 0.5; vertices[1].v = _overlayHeight - 0.5; - sceGuTexMode(GU_PSM_4444, 0, 0, 0); // 16-bit image - sceGuDisable(GU_ALPHA_TEST); - sceGuEnable(GU_BLEND); - - //sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0); - sceGuBlendFunc(GU_ADD, GU_FIX, GU_ONE_MINUS_SRC_ALPHA, 0xFFFFFFFF, 0); - - if (_overlayWidth > 320) - sceGuTexImage(0, 512, 512, _overlayWidth, _overlayBuffer); - else - sceGuTexImage(0, 512, 256, _overlayWidth, _overlayBuffer); - - sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGBA); - sceGuDrawArray(GU_SPRITES,GU_TEXTURE_32BITF|GU_VERTEX_32BITF|GU_TRANSFORM_2D,2,0,vertices); - // need to render twice for textures > 512 - if ( _overlayWidth > 512) { - sceGuTexImage(0, 512, 512, _overlayWidth, _overlayBuffer + 512); - vertices[0].u = 512 + 0.5; vertices[1].v = _overlayHeight - 0.5; - vertices[0].x = PSP_SCREEN_WIDTH * 512 / 640; vertices[0].y = 0; vertices[0].z = 0; - sceGuDrawArray(GU_SPRITES, GU_TEXTURE_32BITF|GU_VERTEX_32BITF|GU_TRANSFORM_2D, 2, 0, vertices); - } - sceGuDisable(GU_BLEND); - } - - // draw mouse - if (_mouseVisible) { - sceGuTexMode(GU_PSM_T8, 0, 0, 0); // 8-bit image - sceGuClutMode(GU_PSM_5551, 0, 0xff, 0); - sceGuClutLoad(32, _cursorPaletteDisabled ? mouseClut : cursorPalette); // upload 32*8 entries (256) - sceGuAlphaFunc(GU_GREATER,0,0xff); - sceGuEnable(GU_ALPHA_TEST); - sceGuTexImage(0, MOUSE_SIZE, MOUSE_SIZE, MOUSE_SIZE, _mouseBuf); - sceGuTexFunc(GU_TFX_MODULATE, GU_TCC_RGBA); - - vertices[0].u = 0.5; vertices[0].v = 0.5; - vertices[1].u = _mouseWidth - 0.5; vertices[1].v = _mouseHeight - 0.5; - - //adjust cursor position - int mX = _mouseX - _mouseHotspotX; - int mY = _mouseY - _mouseHotspotY; - - if (_overlayVisible) { - float scalex, scaley; - - scalex = (float)PSP_SCREEN_WIDTH /_overlayWidth; - scaley = (float)PSP_SCREEN_HEIGHT /_overlayHeight; - - vertices[0].x = mX * scalex; vertices[0].y = mY * scaley; vertices[0].z = 0; - vertices[1].x = vertices[0].x + _mouseWidth * scalex; vertices[1].y = vertices[0].y + _mouseHeight * scaley; vertices[0].z = 0; - } else - switch(_graphicMode) { - case CENTERED_320X200: - vertices[0].x = (PSP_SCREEN_WIDTH - 320) / 2 + mX; vertices[0].y = (PSP_SCREEN_HEIGHT - 200) / 2 + mY; vertices[0].z = 0; - vertices[1].x = vertices[0].x+_mouseWidth; vertices[1].y = vertices[0].y + _mouseHeight; vertices[1].z = 0; - break; - case CENTERED_435X272: - { - float scalex, scaley; - - scalex = 435.0f / _screenWidth; - scaley = 272.0f / _screenHeight; - - vertices[0].x = (PSP_SCREEN_WIDTH - 435) / 2 + mX * scalex; vertices[0].y = mY * scaley; vertices[0].z = 0; - vertices[1].x = vertices[0].x + _mouseWidth * scalex; vertices[1].y = vertices[0].y + _mouseHeight * scaley; vertices[0].z = 0; - - } - break; - case CENTERED_362X272: - { - float scalex, scaley; - - scalex = 362.0f / _screenWidth; - scaley = 272.0f / _screenHeight; - - vertices[0].x = (PSP_SCREEN_WIDTH - 362) / 2 + mX * scalex; vertices[0].y = mY * scaley; vertices[0].z = 0; - vertices[1].x = vertices[0].x + _mouseWidth * scalex; vertices[1].y = vertices[0].y + _mouseHeight * scaley; vertices[0].z = 0; - } - break; - case STRETCHED_480X272: - { - float scalex, scaley; - - scalex = (float)PSP_SCREEN_WIDTH / _screenWidth; - scaley = (float)PSP_SCREEN_HEIGHT / _screenHeight; - - vertices[0].x = mX * scalex; vertices[0].y = mY * scaley; vertices[0].z = 0; - vertices[1].x = vertices[0].x + _mouseWidth * scalex; vertices[1].y = vertices[0].y + _mouseHeight * scaley; vertices[0].z = 0; - } - break; - } - sceGuDrawArray(GU_SPRITES, GU_TEXTURE_32BITF|GU_VERTEX_32BITF|GU_TRANSFORM_2D, 2, 0, vertices); - } - - if (_keyboardVisible) { - sceGuTexMode(GU_PSM_T8, 0, 0, 0); // 8-bit image - sceGuClutMode(GU_PSM_4444, 0, 0xff, 0); - sceGuClutLoad(32, kbClut); // upload 32*8 entries (256) - sceGuDisable(GU_ALPHA_TEST); - sceGuEnable(GU_BLEND); - sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0); - switch(_keyboardMode) { - case 0: - sceGuTexImage(0, 512, 512, 480, keyboard_letters); - break; - case CAPS_LOCK: - sceGuTexImage(0, 512, 512, 480, keyboard_letters_shift); - break; - case SYMBOLS: - sceGuTexImage(0, 512, 512, 480, keyboard_symbols); - break; - case (CAPS_LOCK | SYMBOLS): - sceGuTexImage(0, 512, 512, 480, keyboard_symbols_shift); - break; - } - sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGBA); - - vertices[0].u = 0.5; vertices[0].v = 0.5; - vertices[1].u = PSP_SCREEN_WIDTH-0.5; vertices[1].v = PSP_SCREEN_HEIGHT-0.5; - vertices[0].x = 0; vertices[0].y = 0; vertices[0].z = 0; - vertices[1].x = PSP_SCREEN_WIDTH; vertices[1].y = PSP_SCREEN_HEIGHT; vertices[0].z = 0; - sceGuDrawArray(GU_SPRITES,GU_TEXTURE_32BITF|GU_VERTEX_32BITF|GU_TRANSFORM_2D,2,0,vertices); - sceGuDisable(GU_BLEND); - } - sceKernelDcacheWritebackAll(); - - sceGuFinish(); - sceGuSync(0,0); - - sceDisplayWaitVblankStart(); - sceGuSwapBuffers(); - - //sceKernelDcacheWritebackAll(); -} - -bool OSystem_PSP_GU::pollEvent(Common::Event &event) { - float nub_angle = -1; - int x, y; - - sceCtrlSetSamplingCycle(0); - sceCtrlSetSamplingMode(1); - sceCtrlReadBufferPositive(&pad, 1); - - uint32 buttonsChanged = pad.Buttons ^ _prevButtons; - - if ((buttonsChanged & PSP_CTRL_SELECT) || (pad.Buttons & PSP_CTRL_SELECT)) { - if ( !(pad.Buttons & PSP_CTRL_SELECT) ) - _keyboardVisible = !_keyboardVisible; - _prevButtons = pad.Buttons; - return false; - } - - if (!_keyboardVisible) - return OSystem_PSP::pollEvent(event); - - if ( (buttonsChanged & PSP_CTRL_RTRIGGER) && !(pad.Buttons & PSP_CTRL_RTRIGGER)) - _keyboardMode ^= CAPS_LOCK; - - if ( (buttonsChanged & PSP_CTRL_LTRIGGER) && !(pad.Buttons & PSP_CTRL_LTRIGGER)) - _keyboardMode ^= SYMBOLS; - - if ( (buttonsChanged & PSP_CTRL_LEFT) && !(pad.Buttons & PSP_CTRL_LEFT)) { - event.kbd.flags = 0; - event.kbd.ascii = 0; - event.kbd.keycode = Common::KEYCODE_LEFT; - _prevButtons = pad.Buttons; - return true; - } - - if ( (buttonsChanged & PSP_CTRL_RIGHT) && !(pad.Buttons & PSP_CTRL_RIGHT)) { - event.kbd.flags = 0; - event.kbd.ascii = 0; - event.kbd.keycode = Common::KEYCODE_RIGHT; - _prevButtons = pad.Buttons; - return true; - } - - if ( (buttonsChanged & PSP_CTRL_UP) && !(pad.Buttons & PSP_CTRL_UP)) { - event.kbd.flags = 0; - event.kbd.ascii = 0; - event.kbd.keycode = Common::KEYCODE_UP; - _prevButtons = pad.Buttons; - return true; - } - - if ( (buttonsChanged & PSP_CTRL_DOWN) && !(pad.Buttons & PSP_CTRL_DOWN)) { - event.kbd.flags = 0; - event.kbd.ascii = 0; - event.kbd.keycode = Common::KEYCODE_DOWN; - _prevButtons = pad.Buttons; - return true; - } - - // compute nub direction - x = pad.Lx-128; - y = pad.Ly-128; - _kbdClut[_keySelected] = 0xf888; - if (x*x + y*y > 10000) { - nub_angle = atan2(y, x); - _keySelected = (int)(1 + (M_PI + nub_angle) * 30 / (2 * M_PI)); - _keySelected -= 2; - if (_keySelected < 1) - _keySelected += 30; - _kbdClut[_keySelected] = 0xffff; - - if (buttonsChanged & PSP_CTRL_CROSS) { - event.type = (pad.Buttons & PSP_CTRL_CROSS) ? Common::EVENT_KEYDOWN : Common::EVENT_KEYUP; - if (_keySelected > 26) { - event.kbd.flags = 0; - switch(_keySelected) { - case 27: - event.kbd.ascii = ' '; - event.kbd.keycode = Common::KEYCODE_SPACE; - break; - case 28: - event.kbd.ascii = 127; - event.kbd.keycode = Common::KEYCODE_DELETE; - break; - case 29: - event.kbd.ascii = 8; - event.kbd.keycode = Common::KEYCODE_BACKSPACE; - break; - case 30: - event.kbd.ascii = 13; - event.kbd.keycode = Common::KEYCODE_RETURN; - break; - } - } else { - switch( _keyboardMode) { - case 0: - event.kbd.flags = 0; - event.kbd.ascii = 'a'+_keySelected-1; - event.kbd.keycode = (Common::KeyCode)(Common::KEYCODE_a + _keySelected-1); - break; - case CAPS_LOCK: - event.kbd.ascii = 'A'+_keySelected-1; - event.kbd.keycode = (Common::KeyCode)(Common::KEYCODE_a + _keySelected-1); - event.kbd.flags = Common::KBD_SHIFT; - break; - case SYMBOLS: - if (_keySelected < 21) { - event.kbd.flags = 0; - event.kbd.ascii = kbd_ascii[_keySelected-1]; - event.kbd.keycode = kbd_code[ _keySelected-1]; - } - break; - case (SYMBOLS|CAPS_LOCK): - if (_keySelected < 21) { - event.kbd.flags = 0; - event.kbd.ascii = kbd_ascii_cl[_keySelected-1]; - event.kbd.keycode = kbd_code_cl[ _keySelected-1]; - } - break; - } - } - _prevButtons = pad.Buttons; - return true; - } - } - - _prevButtons = pad.Buttons; - return false; -} - diff --git a/backends/platform/psp/osys_psp_gu.h b/backends/platform/psp/osys_psp_gu.h deleted file mode 100644 index 106b73b308..0000000000 --- a/backends/platform/psp/osys_psp_gu.h +++ /dev/null @@ -1,61 +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 -#include "common/scummsys.h" - -#include "common/rect.h" -#include "osys_psp.h" - -class OSystem_PSP_GU : public OSystem_PSP -{ -public: - struct Vertex - { - float u,v; - float x,y,z; - }; - - OSystem_PSP_GU(); - ~OSystem_PSP_GU(); - void updateScreen(); - void initSize(uint width, uint height, const Graphics::PixelFormat *format); - int getDefaultGraphicsMode() const; - bool setGraphicsMode(int mode); - bool setGraphicsMode(const char *name); - int getGraphicsMode() const; - void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format); - void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h) ; - void setPalette(const byte *colors, uint start, uint num); - void setCursorPalette(const byte *colors, uint start, uint num); - void disableCursorPalette(bool disable); - bool pollEvent(Common::Event &event); - int _graphicMode; - struct Vertex *_vertices; - unsigned short* _clut; - unsigned short* _kbdClut; - bool _keyboardVisible; - int _keySelected; - int _keyboardMode; -}; - diff --git a/backends/platform/psp/psp_main.cpp b/backends/platform/psp/psp_main.cpp index 357c502dbc..74363e4ac9 100644 --- a/backends/platform/psp/psp_main.cpp +++ b/backends/platform/psp/psp_main.cpp @@ -40,7 +40,7 @@ #include "backends/platform/psp/powerman.h" -#include "osys_psp_gu.h" +#include "osys_psp.h" #include "./trace.h" @@ -151,7 +151,7 @@ int main(void) { static const char *argv[] = { "scummvm", NULL }; static int argc = sizeof(argv)/sizeof(char *)-1; - g_system = new OSystem_PSP_GU(); + g_system = new OSystem_PSP(); assert(g_system); int res = scummvm_main(argc, argv); -- cgit v1.2.3 From 978d9dfd10c8290a6123bd96dba84a5563c0f9c2 Mon Sep 17 00:00:00 2001 From: Joost Peters Date: Fri, 21 Aug 2009 22:44:49 +0000 Subject: some cleanup svn-id: r43618 --- backends/platform/psp/osys_psp.cpp | 58 ++++++++++++++++++-------------------- backends/platform/psp/osys_psp.h | 8 ++++-- 2 files changed, 33 insertions(+), 33 deletions(-) (limited to 'backends') diff --git a/backends/platform/psp/osys_psp.cpp b/backends/platform/psp/osys_psp.cpp index a9e9aeb7d8..023ec0cc82 100644 --- a/backends/platform/psp/osys_psp.cpp +++ b/backends/platform/psp/osys_psp.cpp @@ -31,7 +31,6 @@ #include "common/config-manager.h" #include "common/events.h" -#include "common/rect.h" #include "common/scummsys.h" #include "osys_psp.h" @@ -40,14 +39,11 @@ #include "backends/saves/psp/psp-saves.h" #include "backends/timer/default/default-timer.h" #include "graphics/surface.h" -#include "graphics/scaler.h" #include "sound/mixer_intern.h" #define SAMPLES_PER_SEC 44100 -#define SCREEN_WIDTH 480 -#define SCREEN_HEIGHT 272 #define PIXEL_SIZE (4) #define BUF_WIDTH (512) @@ -68,8 +64,6 @@ unsigned short __attribute__((aligned(16))) kbClut[256]; //unsigned int __attribute__((aligned(16))) overlayBuffer256[640*480*2]; unsigned int __attribute__((aligned(16))) mouseBuf256[MOUSE_SIZE*MOUSE_SIZE]; -extern unsigned long RGBToColour(unsigned long r, unsigned long g, unsigned long b); - extern unsigned int size_keyboard_symbols_compressed; extern unsigned char keyboard_symbols_compressed[]; extern unsigned int size_keyboard_symbols_shift_compressed; @@ -126,28 +120,6 @@ OSystem_PSP::OSystem_PSP() : _screenWidth(0), _screenHeight(0), _overlayWidth(0) SDL_Init(sdlFlags); - //sceKernelDcacheWritebackAll(); - - // setup - sceGuInit(); - sceGuStart(0, displayList); - sceGuDrawBuffer(GU_PSM_8888, (void *)0, BUF_WIDTH); - sceGuDispBuffer(PSP_SCREEN_WIDTH, PSP_SCREEN_HEIGHT, (void*)PSP_FRAME_SIZE, BUF_WIDTH); - sceGuDepthBuffer((void*)(PSP_FRAME_SIZE * 2), BUF_WIDTH); - sceGuOffset(2048 - (PSP_SCREEN_WIDTH/2), 2048 - (PSP_SCREEN_HEIGHT/2)); - sceGuViewport(2048, 2048, PSP_SCREEN_WIDTH, PSP_SCREEN_HEIGHT); - sceGuDepthRange(0xC350, 0x2710); - sceGuScissor(0, 0, PSP_SCREEN_WIDTH, PSP_SCREEN_HEIGHT); - sceGuEnable(GU_SCISSOR_TEST); - sceGuFrontFace(GU_CW); - sceGuEnable(GU_TEXTURE_2D); - sceGuClear(GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT); - sceGuFinish(); - sceGuSync(0,0); - - sceDisplayWaitVblankStart(); - sceGuDisplay(1); - //decompress keyboard data uLongf kbdSize = KBD_DATA_SIZE; keyboard_letters = (unsigned char *)memalign(16, KBD_DATA_SIZE); @@ -178,6 +150,30 @@ OSystem_PSP::OSystem_PSP() : _screenWidth(0), _screenHeight(0), _overlayWidth(0) _keyboardMode = 0; _mouseX = PSP_SCREEN_WIDTH >> 1; _mouseY = PSP_SCREEN_HEIGHT >> 1; + + + //sceKernelDcacheWritebackAll(); + + // setup + sceGuInit(); + sceGuStart(0, displayList); + sceGuDrawBuffer(GU_PSM_8888, (void *)0, BUF_WIDTH); + sceGuDispBuffer(PSP_SCREEN_WIDTH, PSP_SCREEN_HEIGHT, (void*)PSP_FRAME_SIZE, BUF_WIDTH); + sceGuDepthBuffer((void*)(PSP_FRAME_SIZE * 2), BUF_WIDTH); + sceGuOffset(2048 - (PSP_SCREEN_WIDTH/2), 2048 - (PSP_SCREEN_HEIGHT/2)); + sceGuViewport(2048, 2048, PSP_SCREEN_WIDTH, PSP_SCREEN_HEIGHT); + sceGuDepthRange(0xC350, 0x2710); + sceGuScissor(0, 0, PSP_SCREEN_WIDTH, PSP_SCREEN_HEIGHT); + sceGuEnable(GU_SCISSOR_TEST); + sceGuFrontFace(GU_CW); + sceGuEnable(GU_TEXTURE_2D); + sceGuClear(GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT); + sceGuFinish(); + sceGuSync(0,0); + + sceDisplayWaitVblankStart(); + sceGuDisplay(1); + } OSystem_PSP::~OSystem_PSP() { @@ -270,8 +266,10 @@ void OSystem_PSP::initSize(uint width, uint height, const Graphics::PixelFormat _kbdClut[0] = 0xFFFF; _kbdClut[246] = 0x4CCC; _kbdClut[247] = 0x0000; + for (int i = 1; i < 31; i++) _kbdClut[i] = 0xF888; + _mouseVisible = false; sceKernelDcacheWritebackAll(); } @@ -293,10 +291,10 @@ void OSystem_PSP::setPalette(const byte *colors, uint start, uint num) { } //copy to CLUT - memcpy(_clut, _palette, 256*sizeof(unsigned short)); + memcpy(_clut, _palette, 256 * sizeof(unsigned short)); //force update of mouse CLUT as well, as it may have been set up before this palette was set - memcpy(mouseClut, _palette, 256*sizeof(unsigned short)); + memcpy(mouseClut, _palette, 256 * sizeof(unsigned short)); mouseClut[_mouseKeyColour] = 0; sceKernelDcacheWritebackAll(); diff --git a/backends/platform/psp/osys_psp.h b/backends/platform/psp/osys_psp.h index 353561cced..047fbff97e 100644 --- a/backends/platform/psp/osys_psp.h +++ b/backends/platform/psp/osys_psp.h @@ -96,7 +96,6 @@ protected: Common::TimerManager *_timer; public: - OSystem_PSP(); virtual ~OSystem_PSP(); @@ -105,15 +104,19 @@ public: virtual bool hasFeature(Feature f); virtual void setFeatureState(Feature f, bool enable); virtual bool getFeatureState(Feature f); + virtual const GraphicsMode *getSupportedGraphicsModes() const; virtual int getDefaultGraphicsMode() const; virtual bool setGraphicsMode(int mode); bool setGraphicsMode(const char *name); virtual int getGraphicsMode() const; + virtual void initSize(uint width, uint height, const Graphics::PixelFormat *format); virtual int16 getWidth(); virtual int16 getHeight(); + virtual void setPalette(const byte *colors, uint start, uint num); + virtual void grabPalette(byte *colors, uint start, uint num); virtual void setCursorPalette(const byte *colors, uint start, uint num); virtual void disableCursorPalette(bool disable); virtual void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h); @@ -129,16 +132,15 @@ public: virtual void copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h); virtual int16 getOverlayHeight(); virtual int16 getOverlayWidth(); - virtual void grabPalette(byte *colors, uint start, uint num); virtual Graphics::PixelFormat getOverlayFormat() const { return Graphics::createPixelFormat<4444>(); } 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 bool pollEvent(Common::Event &event); virtual bool processInput(Common::Event &event); + virtual uint32 getMillis(); virtual void delayMillis(uint msecs); -- cgit v1.2.3 From 70ccc47accf0563ca793f9d0d03fa6908afbfd99 Mon Sep 17 00:00:00 2001 From: Andre Heider Date: Fri, 21 Aug 2009 23:04:06 +0000 Subject: Removed redundant checks, the asserts() earlier do exactly the same. svn-id: r43622 --- backends/platform/sdl/graphics.cpp | 24 ------------------------ 1 file changed, 24 deletions(-) (limited to 'backends') diff --git a/backends/platform/sdl/graphics.cpp b/backends/platform/sdl/graphics.cpp index d3a37f4de7..a67e35cf73 100644 --- a/backends/platform/sdl/graphics.cpp +++ b/backends/platform/sdl/graphics.cpp @@ -975,30 +975,6 @@ void OSystem_SDL::copyRectToScreen(const byte *src, int pitch, int x, int y, int * and just updates those, on the actual display. */ addDirtyRgnAuto(src); } else { - /* Clip the coordinates */ - if (x < 0) { - w += x; - src -= x; - x = 0; - } - - if (y < 0) { - h += y; - src -= y * pitch; - y = 0; - } - - if (w > _videoMode.screenWidth - x) { - w = _videoMode.screenWidth - x; - } - - if (h > _videoMode.screenHeight - y) { - h = _videoMode.screenHeight - y; - } - - if (w <= 0 || h <= 0) - return; - _cksumValid = false; addDirtyRect(x, y, w, h); } -- cgit v1.2.3 From cb56c27b9a2f3a4b3f0fb487cbc62205855062ea Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sat, 22 Aug 2009 00:41:22 +0000 Subject: Add FIXME about DefaultTimerManager implementation. svn-id: r43627 --- backends/timer/default/default-timer.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'backends') diff --git a/backends/timer/default/default-timer.cpp b/backends/timer/default/default-timer.cpp index bd2222bbbc..dd468bbe09 100644 --- a/backends/timer/default/default-timer.cpp +++ b/backends/timer/default/default-timer.cpp @@ -124,6 +124,12 @@ bool DefaultTimerManager::installTimerProc(TimerProc callback, int32 interval, v slot->nextFireTimeMicro = interval % 1000; slot->next = 0; + // FIXME: It seems we do allow the client to add one callback multiple times over here, + // but "removeTimerProc" will remove *all* added instances. We should either prevent + // multiple additions of a timer proc OR we should change removeTimerProc to only remove + // a specific timer proc entry. + // Probably we can safely just allow a single addition of a specific function once + // and just update our Timer documentation accordingly. insertPrioQueue(_head, slot); return true; -- cgit v1.2.3 From 5b2a1a766212d44ef4bc7329bd2e59f9f7f0b5ce Mon Sep 17 00:00:00 2001 From: Andre Heider Date: Sat, 22 Aug 2009 08:49:23 +0000 Subject: 16bit support for the Wii port svn-id: r43631 --- backends/platform/wii/osystem.cpp | 5 + backends/platform/wii/osystem.h | 11 +- backends/platform/wii/osystem_gfx.cpp | 211 ++++++++++++++++++++++++++-------- 3 files changed, 177 insertions(+), 50 deletions(-) (limited to 'backends') diff --git a/backends/platform/wii/osystem.cpp b/backends/platform/wii/osystem.cpp index ae1eb11f4f..3f53605e85 100644 --- a/backends/platform/wii/osystem.cpp +++ b/backends/platform/wii/osystem.cpp @@ -52,6 +52,11 @@ OSystem_Wii::OSystem_Wii() : _currentHeight(0), _activeGraphicsMode(0), +#ifdef USE_RGB_COLOR + _texturePF(Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0)), + _screenPF(Graphics::PixelFormat::createFormatCLUT8()), + _cursorPF(Graphics::PixelFormat::createFormatCLUT8()), +#endif _fullscreen(false), diff --git a/backends/platform/wii/osystem.h b/backends/platform/wii/osystem.h index 2eb53f26a3..72263af5a8 100644 --- a/backends/platform/wii/osystem.h +++ b/backends/platform/wii/osystem.h @@ -75,6 +75,11 @@ private: u16 _currentWidth, _currentHeight; s32 _activeGraphicsMode; +#ifdef USE_RGB_COLOR + const Graphics::PixelFormat _texturePF; + Graphics::PixelFormat _screenPF; + Graphics::PixelFormat _cursorPF; +#endif bool _fullscreen; @@ -82,7 +87,7 @@ private: s32 _mouseX, _mouseY; u32 _mouseWidth, _mouseHeight; s32 _mouseHotspotX, _mouseHotspotY; - u8 _mouseKeyColor; + u16 _mouseKeyColor; u8 *_mouseCursor; bool _kbd_active; @@ -119,6 +124,10 @@ public: virtual const GraphicsMode *getSupportedGraphicsModes() const; virtual int getDefaultGraphicsMode() const; virtual bool setGraphicsMode(int mode); +#ifdef USE_RGB_COLOR + virtual Graphics::PixelFormat getScreenFormat() const; + virtual Common::List getSupportedFormats(); +#endif virtual int getGraphicsMode() const; virtual void initSize(uint width, uint height, const Graphics::PixelFormat *format); diff --git a/backends/platform/wii/osystem_gfx.cpp b/backends/platform/wii/osystem_gfx.cpp index 9c875eaa85..ed10a407dd 100644 --- a/backends/platform/wii/osystem_gfx.cpp +++ b/backends/platform/wii/osystem_gfx.cpp @@ -21,6 +21,8 @@ #include +#include "graphics/conversion.h" + #include "osystem.h" #include "gx_supp.h" @@ -143,22 +145,72 @@ int OSystem_Wii::getGraphicsMode() const { return _activeGraphicsMode; } +#ifdef USE_RGB_COLOR +Graphics::PixelFormat OSystem_Wii::getScreenFormat() const { + return _screenPF; +} + +Common::List OSystem_Wii::getSupportedFormats() { + Common::List res; + res.push_back(_texturePF); + res.push_back(Graphics::PixelFormat::createFormatCLUT8()); + + return res; +} +#endif + void OSystem_Wii::initSize(uint width, uint height, const Graphics::PixelFormat *format) { - if (_gameWidth != width || _gameHeight != height) { - printf("initSize %u %u\n", width, height); + bool update = false; + +#ifdef USE_RGB_COLOR + Graphics::PixelFormat newFormat; + if (format) + newFormat = *format; + else + newFormat = Graphics::PixelFormat::createFormatCLUT8(); + if (newFormat.bytesPerPixel > 2) + newFormat = Graphics::PixelFormat::createFormatCLUT8(); + + if (_screenPF != newFormat) { + _screenPF = newFormat; + update = true; + } +#endif + + if (_gameWidth != width || _gameHeight != height) { assert((width <= 640) && (height <= 480)); _gameWidth = width; _gameHeight = height; + update = true; + } + + if (update) { +#ifdef USE_RGB_COLOR + printf("initSize %u*%u*%u (%u,%u,%u)\n", + _gameWidth, _gameHeight, + _screenPF.bytesPerPixel * 8, + _screenPF.rShift, _screenPF.gShift, _screenPF.bShift); +#else + printf("initSize %u*%u\n", _gameWidth, _gameHeight); +#endif if(_gamePixels) free(_gamePixels); + size_t bufsize; + +#ifdef USE_RGB_COLOR + _gamePixels = (u8 *) memalign(32, _gameWidth * _gameHeight * + _screenPF.bytesPerPixel); + memset(_gamePixels, 0, _gameWidth * _gameHeight * + _screenPF.bytesPerPixel); +#else _gamePixels = (u8 *) memalign(32, _gameWidth * _gameHeight); memset(_gamePixels, 0, _gameWidth * _gameHeight); - +#endif if (!_overlayVisible) { _currentWidth = _gameWidth; _currentHeight = _gameHeight; @@ -178,6 +230,10 @@ int16 OSystem_Wii::getHeight() { } void OSystem_Wii::setPalette(const byte *colors, uint start, uint num) { +#ifdef USE_RGB_COLOR + assert(_screenPF.bytesPerPixel == 1); +#endif + const byte *p = colors; for (uint i = 0; i < num; ++i) { _palette[start + i] = Graphics::RGBToColor >(p[0], p[1], p[2]); @@ -214,37 +270,36 @@ void OSystem_Wii::disableCursorPalette(bool disable) { void OSystem_Wii::copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h) { - if (x < 0) { - w += x; - buf -= x; - x = 0; - } - - if (y < 0) { - h += y; - buf -= y * pitch; - y = 0; - } - - if (w > _gameWidth - x) - w = _gameWidth - x; - - if (h > _gameHeight - y) - h = _gameHeight - y; - - if (w <= 0 || h <= 0) - return; - - byte *dst = _gamePixels + y * _gameWidth + x; - if (_gameWidth == pitch && pitch == w) { - memcpy(dst, buf, h * w); + assert(x >= 0 && x < _gameWidth); + assert(y >= 0 && y < _gameHeight); + assert(w > 0 && x + w <= _gameWidth); + assert(h > 0 && y + h <= _gameHeight); + +#ifdef USE_RGB_COLOR + if (_screenPF.bytesPerPixel > 1) { + if (!Graphics::crossBlit(_gamePixels + + y * _gameWidth * _screenPF.bytesPerPixel + + x * _screenPF.bytesPerPixel, + buf, _gameWidth * _screenPF.bytesPerPixel, + pitch, w, h, _texturePF, _screenPF)) { + printf("crossBlit failed\n"); + ::abort(); + } } else { - do { - memcpy(dst, buf, w); - buf += pitch; - dst += _gameWidth; - } while (--h); +#endif + byte *dst = _gamePixels + y * _gameWidth + x; + if (_gameWidth == pitch && pitch == w) { + memcpy(dst, buf, h * w); + } else { + do { + memcpy(dst, buf, w); + buf += pitch; + dst += _gameWidth; + } while (--h); + } +#ifdef USE_RGB_COLOR } +#endif } void OSystem_Wii::updateScreen() { @@ -252,6 +307,9 @@ void OSystem_Wii::updateScreen() { static s16 msx, msy, mox, moy, mskip; static u16 mpx, mpy; static u8 *s; +#ifdef USE_RGB_COLOR + static u16 *s2; +#endif static u16 *d, *p; u32 now = getMillis(); @@ -268,12 +326,21 @@ void OSystem_Wii::updateScreen() { if (_overlayVisible) { memcpy(_texture, _overlayPixels, _overlaySize); } else { - for (y = 0; y < _gameHeight; ++y) { - for (x = 0; x < _gameWidth; ++x) - _texture[h + x] = _palette[_gamePixels[h + x]]; +#ifdef USE_RGB_COLOR + if (_screenPF.bytesPerPixel > 1) { + memcpy(_texture, _gamePixels, + _gameWidth * _gameHeight * _screenPF.bytesPerPixel); + } else { +#endif + for (y = 0; y < _gameHeight; ++y) { + for (x = 0; x < _gameWidth; ++x) + _texture[h + x] = _palette[_gamePixels[h + x]]; - h += _gameWidth; + h += _gameWidth; + } +#ifdef USE_RGB_COLOR } +#endif } if (_mouseVisible) { @@ -309,25 +376,51 @@ void OSystem_Wii::updateScreen() { skip = _currentWidth - mpx; mskip = _mouseWidth - mpx; - s = _mouseCursor + moy * _mouseWidth + mox; - d = _texture + (msy * _currentWidth + msx); +#ifdef USE_RGB_COLOR + if (_cursorPF.bytesPerPixel > 1) { + s2 = (u16 *) _mouseCursor + moy * _mouseWidth + mox; + d = _texture + (msy * _currentWidth + msx); - for (y = 0; y < mpy; ++y) { - for (x = 0; x < mpx; ++x) { - if (*s == _mouseKeyColor) { - s++; - d++; + for (y = 0; y < mpy; ++y) { + for (x = 0; x < mpx; ++x) { + if (*s2 == _mouseKeyColor) { + s2++; + d++; - continue; + continue; + } + + *d++ = *s2; + s2++; } - *d++ = p[*s]; - s++; + d += skip; + s2 += mskip; } + } else { +#endif + s = _mouseCursor + moy * _mouseWidth + mox; + d = _texture + (msy * _currentWidth + msx); + + for (y = 0; y < mpy; ++y) { + for (x = 0; x < mpx; ++x) { + if (*s == _mouseKeyColor) { + s++; + d++; + + continue; + } + + *d++ = p[*s]; + s++; + } - d += skip; - s += mskip; + d += skip; + s += mskip; + } +#ifdef USE_RGB_COLOR } +#endif } GX_Render(_currentWidth, _currentHeight, (u8 *) _texture, @@ -339,7 +432,11 @@ Graphics::Surface *OSystem_Wii::lockScreen() { _surface.w = _gameWidth; _surface.h = _gameHeight; _surface.pitch = _gameWidth; +#ifdef USE_RGB_COLOR + _surface.bytesPerPixel = _screenPF.bytesPerPixel; +#else _surface.bytesPerPixel = 1; +#endif return &_surface; } @@ -452,16 +549,32 @@ void OSystem_Wii::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, const Graphics::PixelFormat *format) { (void) cursorTargetScale; // TODO +#ifdef USE_RGB_COLOR + if (!format) + _cursorPF = Graphics::PixelFormat::createFormatCLUT8(); + else + _cursorPF = *format; + + if (_cursorPF.bytesPerPixel > 1) + _mouseKeyColor = keycolor & 0xffff; + else +#endif + _mouseKeyColor = keycolor & 0xff; + _mouseWidth = w; _mouseHeight = h; _mouseHotspotX = hotspotX; _mouseHotspotY = hotspotY; - _mouseKeyColor = keycolor & 0xff; if (_mouseCursor) free(_mouseCursor); +#ifdef USE_RGB_COLOR + _mouseCursor = (u8 *) memalign(32, w * h * _cursorPF.bytesPerPixel); + memcpy(_mouseCursor, buf, w * h * _cursorPF.bytesPerPixel); +#else _mouseCursor = (u8 *) memalign(32, w * h); memcpy(_mouseCursor, buf, w * h); +#endif } -- cgit v1.2.3 From 70b7ebb33901d3dff5426c1c2fa12bc5087b721a Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sat, 22 Aug 2009 12:35:49 +0000 Subject: Patch #2826508: "Motorola A1200/E6/A1600 (motoezx) patch" svn-id: r43636 --- backends/platform/linuxmoto/hardwarekeys.cpp | 100 ++++++++++++ backends/platform/linuxmoto/linuxmoto-events.cpp | 190 +++++++++++++++++++++++ backends/platform/linuxmoto/linuxmoto-sdl.cpp | 69 ++++++++ backends/platform/linuxmoto/linuxmoto-sdl.h | 46 ++++++ backends/platform/linuxmoto/main.cpp | 45 ++++++ backends/platform/linuxmoto/module.mk | 29 ++++ backends/platform/sdl/events.cpp | 2 + backends/platform/sdl/main.cpp | 2 +- backends/platform/sdl/sdl.cpp | 5 +- backends/platform/sdl/sdl.h | 2 + 10 files changed, 486 insertions(+), 4 deletions(-) create mode 100644 backends/platform/linuxmoto/hardwarekeys.cpp create mode 100644 backends/platform/linuxmoto/linuxmoto-events.cpp create mode 100644 backends/platform/linuxmoto/linuxmoto-sdl.cpp create mode 100644 backends/platform/linuxmoto/linuxmoto-sdl.h create mode 100644 backends/platform/linuxmoto/main.cpp create mode 100644 backends/platform/linuxmoto/module.mk (limited to 'backends') diff --git a/backends/platform/linuxmoto/hardwarekeys.cpp b/backends/platform/linuxmoto/hardwarekeys.cpp new file mode 100644 index 0000000000..2f64e7dbae --- /dev/null +++ b/backends/platform/linuxmoto/hardwarekeys.cpp @@ -0,0 +1,100 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + + +#include "backends/platform/linuxmoto/linuxmoto-sdl.h" +#include "backends/keymapper/keymapper.h" +#include "common/keyboard.h" + +#ifdef ENABLE_KEYMAPPER + +using namespace Common; + +struct Key { + const char *hwId; + KeyCode keycode; + uint16 ascii; + const char *desc; + KeyType preferredAction; + bool shiftable; +}; + +static const Key keys[] = { + {"FIRE", KEYCODE_RETURN, ASCII_RETURN, "Fire", kActionKeyType, false}, + {"CAMERA", KEYCODE_PAUSE, 0, "Camera", kActionKeyType, false}, + {"HANGUP", KEYCODE_ESCAPE, ASCII_ESCAPE, "Hangup", kStartKeyType, false}, + {"CALL", KEYCODE_SPACE, ASCII_SPACE, "Call", kActionKeyType, false}, + {"PLUS", KEYCODE_PLUS, '+', "+", kActionKeyType, false}, + {"MINUS", KEYCODE_MINUS, '-', "-", kActionKeyType, false}, + + {"a", KEYCODE_a, 'a', "a", kActionKeyType, true}, + {"b", KEYCODE_b, 'b', "b", kActionKeyType, true}, + {"c", KEYCODE_c, 'c', "c", kActionKeyType, true}, + {"d", KEYCODE_d, 'd', "d", kActionKeyType, true}, + {"e", KEYCODE_e, 'e', "e", kActionKeyType, true}, + {"f", KEYCODE_f, 'f', "f", kActionKeyType, true}, + {"g", KEYCODE_g, 'g', "g", kActionKeyType, true}, + {"h", KEYCODE_h, 'h', "h", kActionKeyType, true}, + {"i", KEYCODE_i, 'i', "i", kActionKeyType, true}, + {"j", KEYCODE_j, 'j', "j", kActionKeyType, true}, + + // Numeric keypad + + // Arrows + Home/End pad + {"UP", KEYCODE_UP, 0, "Up", kDirUpKeyType, false}, + {"DOWN", KEYCODE_DOWN, 0, "Down", kDirDownKeyType, false}, + {"RIGHT", KEYCODE_RIGHT, 0, "Right", kDirRightKeyType, false}, + {"LEFT", KEYCODE_LEFT, 0, "Left", kDirLeftKeyType, false}, + + // Function keys + + // Miscellaneous function keys + + {0, KEYCODE_INVALID, 0, 0, kGenericKeyType, false} +}; + +struct Mod { + byte flag; + const char *id; + const char *desc; + bool shiftable; +}; + +static const Mod modifiers[] = { + { 0, "", "", false }, + { KBD_CTRL, "C+", "Ctrl+", false }, + { KBD_ALT, "A+", "Alt+", false }, + { KBD_SHIFT, "", "", true }, + { KBD_CTRL | KBD_ALT, "C+A+", "Ctrl+Alt+", false }, + { KBD_SHIFT | KBD_CTRL, "S+C+", "Shift+Ctrl+", true }, + { KBD_SHIFT | KBD_CTRL | KBD_ALT, "C+A+", "Ctrl+Alt+", true }, + { 0, 0, 0, false } +}; +#endif + + +Common::HardwareKeySet *OSystem_LINUXMOTO::getHardwareKeySet() { + OSystem_SDL::getHardwareKeySet(); +} diff --git a/backends/platform/linuxmoto/linuxmoto-events.cpp b/backends/platform/linuxmoto/linuxmoto-events.cpp new file mode 100644 index 0000000000..2a40d734b0 --- /dev/null +++ b/backends/platform/linuxmoto/linuxmoto-events.cpp @@ -0,0 +1,190 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + + +#include "backends/platform/linuxmoto/linuxmoto-sdl.h" +#include "backends/platform/sdl/sdl.h" + +static int mapKey(SDLKey key, SDLMod mod, Uint16 unicode) { + if (key >= SDLK_F1 && key <= SDLK_F9) { + return key - SDLK_F1 + Common::ASCII_F1; + } else if (key >= SDLK_KP0 && key <= SDLK_KP9) { + return key - SDLK_KP0 + '0'; + } else if (key >= SDLK_UP && key <= SDLK_PAGEDOWN) { + return key; + } else if (unicode) { + return unicode; + } else if (key >= 'a' && key <= 'z' && (mod & KMOD_SHIFT)) { + return key & ~0x20; + } else if (key >= SDLK_NUMLOCK && key <= SDLK_EURO) { + return 0; + } + return key; +} + +bool OSystem_LINUXMOTO::remapKey(SDL_Event &ev, Common::Event &event) { + // Motorol A1200/E6/A1600 remapkey by Lubomyr +#ifdef MOTOEZX + // Quit on MOD+Camera Key on A1200 + if (ev.key.keysym.sym == SDLK_e) { + event.type = Common::EVENT_QUIT; + return true; + } + // '1' Bypass security protection - MOD+Call key + if (ev.key.keysym.sym == SDLK_f) { + ev.key.keysym.sym=SDLK_1; + } + // F5 Game Menu - Call key + else if (ev.key.keysym.sym == SDLK_SPACE) { + ev.key.keysym.sym=SDLK_F5; + } + // Camera to VirtualKeyboard + else if (ev.key.keysym.sym == SDLK_PAUSE) { + ev.key.keysym.sym=SDLK_F7; + } + // mod+fire to enter + else if (ev.key.keysym.sym == SDLK_b) { + ev.key.keysym.sym=SDLK_RETURN; + } +#endif + // Motorola Z6/V8 remapkey by Ant-On +#ifdef MOTOMAGX + // Quit on cancel + if (ev.key.keysym.sym == SDLK_ESCAPE) { + event.type = Common::EVENT_QUIT; + return true; + } else + // F5 Game Menu - Call key + if (ev.key.keysym.sym == SDLK_SPACE) { + ev.key.keysym.sym=SDLK_F5; + } + // 'y' - Mod+Right key + // 'y' - Left soft + else if (ev.key.keysym.sym == SDLK_F9) { + ev.key.keysym.sym=SDLK_y; + } + // 'n' - Mod+Left key + // 'n' - rigth soft + else if (ev.key.keysym.sym == SDLK_F11) { + ev.key.keysym.sym=SDLK_n; + } +#endif + +// Joystick to Mouse + else if (ev.key.keysym.sym == SDLK_LEFT) { + if (ev.type == SDL_KEYDOWN) { + _km.x_vel = -1; + _km.x_down_count = 1; + } else { + _km.x_vel = 0; + _km.x_down_count = 0; + } + + event.type = Common::EVENT_MOUSEMOVE; + fillMouseEvent(event, _km.x, _km.y); + return true; + } else if (ev.key.keysym.sym == SDLK_RIGHT) { + if (ev.type == SDL_KEYDOWN) { + _km.x_vel = 1; + _km.x_down_count = 1; + } else { + _km.x_vel = 0; + _km.x_down_count = 0; + } + + event.type = Common::EVENT_MOUSEMOVE; + fillMouseEvent(event, _km.x, _km.y); + return true; + } else if (ev.key.keysym.sym == SDLK_DOWN) { + if (ev.type == SDL_KEYDOWN) { + _km.y_vel = 1; + _km.y_down_count = 1; + } else { + _km.y_vel = 0; + _km.y_down_count = 0; + } + + event.type = Common::EVENT_MOUSEMOVE; + fillMouseEvent(event, _km.x, _km.y); + return true; + } else if (ev.key.keysym.sym == SDLK_UP) { + if (ev.type == SDL_KEYDOWN) { + _km.y_vel = -1; + _km.y_down_count = 1; + } else { + _km.y_vel = 0; + _km.y_down_count = 0; + } + + event.type = Common::EVENT_MOUSEMOVE; + fillMouseEvent(event, _km.x, _km.y); + return true; + } + // Joystick center to pressing Left Mouse + else if (ev.key.keysym.sym == SDLK_RETURN) { + // _km.y_vel = 0; + // _km.y_down_count = 0; + if (ev.key.type == SDL_KEYDOWN) { + event.type = Common::EVENT_LBUTTONDOWN; + } else { + event.type = Common::EVENT_LBUTTONUP; + } + fillMouseEvent(event, _km.x, _km.y); + return true; + } + // Volume Up to pressing Right Mouse + else if (ev.key.keysym.sym == SDLK_PLUS) { + // _km.y_vel = 0; + // _km.y_down_count = 0; + if (ev.key.type == SDL_KEYDOWN ) { + event.type = Common::EVENT_RBUTTONDOWN; + } else { + event.type = Common::EVENT_RBUTTONUP; + } + fillMouseEvent(event, _km.x, _km.y); + return true; + } + // Volume Down to pressing Left Mouse + else if (ev.key.keysym.sym == SDLK_MINUS) { + //_km.y_vel = 0; + //_km.y_down_count = 0; + if (ev.key.type == SDL_KEYDOWN) { + event.type = Common::EVENT_LBUTTONDOWN; + } else { + event.type = Common::EVENT_LBUTTONUP; + } + fillMouseEvent(event, _km.x, _km.y); + return true; + } else { + // Let the events fall through if we didn't change them, this may not be the best way to + // set it up, but i'm not sure how sdl would like it if we let if fall through then redid it though. + // and yes i have an huge terminal size so i dont wrap soon enough. + event.type = Common::EVENT_KEYDOWN; + event.kbd.keycode = (Common::KeyCode)ev.key.keysym.sym; + event.kbd.ascii = mapKey(ev.key.keysym.sym, ev.key.keysym.mod, ev.key.keysym.unicode); + } + + return false; +} diff --git a/backends/platform/linuxmoto/linuxmoto-sdl.cpp b/backends/platform/linuxmoto/linuxmoto-sdl.cpp new file mode 100644 index 0000000000..bc163c807c --- /dev/null +++ b/backends/platform/linuxmoto/linuxmoto-sdl.cpp @@ -0,0 +1,69 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + + +#include "backends/platform/linuxmoto/linuxmoto-sdl.h" + +void OSystem_LINUXMOTO::preprocessEvents(SDL_Event *event) { + if (event->type == SDL_ACTIVEEVENT) { + if (event->active.state == SDL_APPINPUTFOCUS && !event->active.gain) { + suspendAudio(); + for (;;) { + if (!SDL_WaitEvent(event)) { + SDL_Delay(10); + continue; + } + if (event->type == SDL_QUIT) + return; + if (event->type != SDL_ACTIVEEVENT) + continue; + if (event->active.state == SDL_APPINPUTFOCUS && event->active.gain) { + resumeAudio(); + return; + } + } + } + } +} + +void OSystem_LINUXMOTO::suspendAudio() { + SDL_CloseAudio(); + _audioSuspended = true; +} + +int OSystem_LINUXMOTO::resumeAudio() { + if (!_audioSuspended) + return -2; + if (SDL_OpenAudio(&_obtained, NULL) < 0){ + return -1; + } + SDL_PauseAudio(0); + _audioSuspended = false; + return 0; +} + +void OSystem_LINUXMOTO::setupMixer() { + OSystem_SDL::setupMixer(); +} diff --git a/backends/platform/linuxmoto/linuxmoto-sdl.h b/backends/platform/linuxmoto/linuxmoto-sdl.h new file mode 100644 index 0000000000..27c423b071 --- /dev/null +++ b/backends/platform/linuxmoto/linuxmoto-sdl.h @@ -0,0 +1,46 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + + +#ifndef LINUXMOTO_SDL +#define LINUXMOTO_SDL + +#include "backends/platform/sdl/sdl.h" + +#include + +class OSystem_LINUXMOTO : public OSystem_SDL { +private: + bool _audioSuspended; +public: + virtual bool remapKey(SDL_Event &ev, Common::Event &event); + virtual void preprocessEvents(SDL_Event *event); + virtual void setupMixer(); + virtual Common::HardwareKeySet *getHardwareKeySet(); + void suspendAudio(); + int resumeAudio(); +}; + +#endif diff --git a/backends/platform/linuxmoto/main.cpp b/backends/platform/linuxmoto/main.cpp new file mode 100644 index 0000000000..1e37fe617a --- /dev/null +++ b/backends/platform/linuxmoto/main.cpp @@ -0,0 +1,45 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#include +#include + +#include +#include + +#include "backends/platform/linuxmoto/linuxmoto-sdl.h" +#include "base/main.h" +#include "base/internal_version.h" + +int main(int argc, char *argv[]) { + + g_system = new OSystem_LINUXMOTO(); + assert(g_system); + // Invoke the actual ScummVM main entry point: + int res = scummvm_main(argc, argv); + g_system->quit(); // TODO: Consider removing / replacing this! + + return res; +} diff --git a/backends/platform/linuxmoto/module.mk b/backends/platform/linuxmoto/module.mk new file mode 100644 index 0000000000..4d816eb227 --- /dev/null +++ b/backends/platform/linuxmoto/module.mk @@ -0,0 +1,29 @@ +MODULE := backends/platform/linuxmoto + +MODULE_OBJS := \ + main.o \ + hardwarekeys.o \ + linuxmoto-events.o \ + linuxmoto-sdl.o + +MODULE_DIRS += \ + backends/platform/linuxmoto/ + +# We don't use the rules.mk here on purpose +OBJS := $(addprefix $(MODULE)/, $(MODULE_OBJS)) $(OBJS) + +MODULE := backends/platform/sdl + +MODULE_OBJS := \ + events.o \ + graphics.o \ + hardwarekeys.o \ + main.o \ + sdl.o + +MODULE_DIRS += \ + backends/platform/sdl/ + +# We don't use the rules.mk here on purpose +OBJS := $(addprefix $(MODULE)/, $(MODULE_OBJS)) $(OBJS) + diff --git a/backends/platform/sdl/events.cpp b/backends/platform/sdl/events.cpp index feb2c9a9c5..e6c8d716e3 100644 --- a/backends/platform/sdl/events.cpp +++ b/backends/platform/sdl/events.cpp @@ -186,6 +186,8 @@ bool OSystem_SDL::pollEvent(Common::Event &event) { } while (SDL_PollEvent(&ev)) { + preprocessEvents(&ev); + switch (ev.type) { case SDL_KEYDOWN:{ b = event.kbd.flags = SDLModToOSystemKeyFlags(SDL_GetModState()); diff --git a/backends/platform/sdl/main.cpp b/backends/platform/sdl/main.cpp index 021bda155c..fa8f6ededb 100644 --- a/backends/platform/sdl/main.cpp +++ b/backends/platform/sdl/main.cpp @@ -37,7 +37,7 @@ #include "SymbianOs.h" #endif -#if !defined(__MAEMO__) && !defined(_WIN32_WCE) && !defined(GP2XWIZ) +#if !defined(__MAEMO__) && !defined(_WIN32_WCE) && !defined(GP2XWIZ)&& !defined(LINUXMOTO) #if defined (WIN32) int __stdcall WinMain(HINSTANCE /*hInst*/, HINSTANCE /*hPrevInst*/, LPSTR /*lpCmdLine*/, int /*iShowCmd*/) { diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp index 7c1107582b..a4f4114d10 100644 --- a/backends/platform/sdl/sdl.cpp +++ b/backends/platform/sdl/sdl.cpp @@ -695,7 +695,6 @@ void OSystem_SDL::mixCallback(void *sys, byte *samples, int len) { void OSystem_SDL::setupMixer() { SDL_AudioSpec desired; - SDL_AudioSpec obtained; // Determine the desired output sampling frequency. _samplesPerSec = 0; @@ -725,7 +724,7 @@ void OSystem_SDL::setupMixer() { _mixer = new Audio::MixerImpl(this); assert(_mixer); - if (SDL_OpenAudio(&desired, &obtained) != 0) { + if (SDL_OpenAudio(&desired, &_obtained) != 0) { warning("Could not open audio device: %s", SDL_GetError()); _samplesPerSec = 0; _mixer->setReady(false); @@ -733,7 +732,7 @@ void OSystem_SDL::setupMixer() { // Note: This should be the obtained output rate, but it seems that at // least on some platforms SDL will lie and claim it did get the rate // even if it didn't. Probably only happens for "weird" rates, though. - _samplesPerSec = obtained.freq; + _samplesPerSec = _obtained.freq; debug(1, "Output sample rate: %d Hz", _samplesPerSec); // Tell the mixer that we are ready and start the sound processing diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h index 3da9a433b7..e5c41e6611 100644 --- a/backends/platform/sdl/sdl.h +++ b/backends/platform/sdl/sdl.h @@ -216,6 +216,7 @@ public: virtual bool hasFeature(Feature f); virtual void setFeatureState(Feature f, bool enable); virtual bool getFeatureState(Feature f); + virtual void preprocessEvents(SDL_Event *event) {}; #ifdef USE_OSD void displayMessageOnOSD(const char *msg); @@ -230,6 +231,7 @@ public: protected: bool _inited; + SDL_AudioSpec _obtained; #ifdef USE_OSD SDL_Surface *_osdSurface; -- cgit v1.2.3 From 529dc3e3f89b9a73307659f53a9322a957bbbb12 Mon Sep 17 00:00:00 2001 From: Andre Heider Date: Sat, 22 Aug 2009 12:53:37 +0000 Subject: Fix OSX builds svn-id: r43637 --- backends/platform/sdl/sdl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'backends') diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp index a4f4114d10..7bfab26a86 100644 --- a/backends/platform/sdl/sdl.cpp +++ b/backends/platform/sdl/sdl.cpp @@ -740,7 +740,7 @@ void OSystem_SDL::setupMixer() { _mixer->setReady(true); #ifdef MIXER_DOUBLE_BUFFERING - initThreadedMixer(_mixer, obtained.samples * 4); + initThreadedMixer(_mixer, _obtained.samples * 4); #endif // start the sound system -- cgit v1.2.3 From 1cedb6577111bca746628b0d3f4b0e8b232338c5 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sat, 22 Aug 2009 13:18:26 +0000 Subject: Give meaningful name to variable svn-id: r43647 --- backends/platform/linuxmoto/linuxmoto-sdl.cpp | 2 +- backends/platform/sdl/sdl.cpp | 6 +++--- backends/platform/sdl/sdl.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'backends') diff --git a/backends/platform/linuxmoto/linuxmoto-sdl.cpp b/backends/platform/linuxmoto/linuxmoto-sdl.cpp index bc163c807c..82c69bc7d7 100644 --- a/backends/platform/linuxmoto/linuxmoto-sdl.cpp +++ b/backends/platform/linuxmoto/linuxmoto-sdl.cpp @@ -56,7 +56,7 @@ void OSystem_LINUXMOTO::suspendAudio() { int OSystem_LINUXMOTO::resumeAudio() { if (!_audioSuspended) return -2; - if (SDL_OpenAudio(&_obtained, NULL) < 0){ + if (SDL_OpenAudio(&_obtainedRate, NULL) < 0){ return -1; } SDL_PauseAudio(0); diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp index 7bfab26a86..547720d435 100644 --- a/backends/platform/sdl/sdl.cpp +++ b/backends/platform/sdl/sdl.cpp @@ -724,7 +724,7 @@ void OSystem_SDL::setupMixer() { _mixer = new Audio::MixerImpl(this); assert(_mixer); - if (SDL_OpenAudio(&desired, &_obtained) != 0) { + if (SDL_OpenAudio(&desired, &_obtainedRate) != 0) { warning("Could not open audio device: %s", SDL_GetError()); _samplesPerSec = 0; _mixer->setReady(false); @@ -732,7 +732,7 @@ void OSystem_SDL::setupMixer() { // Note: This should be the obtained output rate, but it seems that at // least on some platforms SDL will lie and claim it did get the rate // even if it didn't. Probably only happens for "weird" rates, though. - _samplesPerSec = _obtained.freq; + _samplesPerSec = _obtainedRate.freq; debug(1, "Output sample rate: %d Hz", _samplesPerSec); // Tell the mixer that we are ready and start the sound processing @@ -740,7 +740,7 @@ void OSystem_SDL::setupMixer() { _mixer->setReady(true); #ifdef MIXER_DOUBLE_BUFFERING - initThreadedMixer(_mixer, _obtained.samples * 4); + initThreadedMixer(_mixer, _obtainedRate.samples * 4); #endif // start the sound system diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h index e5c41e6611..82c1e7bf1b 100644 --- a/backends/platform/sdl/sdl.h +++ b/backends/platform/sdl/sdl.h @@ -231,7 +231,7 @@ public: protected: bool _inited; - SDL_AudioSpec _obtained; + SDL_AudioSpec _obtainedRate; #ifdef USE_OSD SDL_Surface *_osdSurface; -- cgit v1.2.3 From ad507d3387bc54206a4df5137012c90c6a93aba6 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sat, 22 Aug 2009 13:34:38 +0000 Subject: Attempt to fix DC and iPhone backends compilation svn-id: r43650 --- backends/platform/dc/dc.h | 4 ++-- backends/platform/dc/display.cpp | 4 ++-- backends/platform/iphone/osys_main.h | 4 ++-- backends/platform/iphone/osys_video.cpp | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) (limited to 'backends') diff --git a/backends/platform/dc/dc.h b/backends/platform/dc/dc.h index b67bbb51a1..f1d3c7af28 100644 --- a/backends/platform/dc/dc.h +++ b/backends/platform/dc/dc.h @@ -84,7 +84,7 @@ class OSystem_Dreamcast : private DCHardware, public BaseBackend, public Filesys // Set the size of the video bitmap. // Typically, 320x200 - void initSize(uint w, uint h); + void initSize(uint w, uint h, const Graphics::PixelFormat *format); int16 getHeight() { return _screen_h; } int16 getWidth() { return _screen_w; } @@ -105,7 +105,7 @@ class OSystem_Dreamcast : private DCHardware, public BaseBackend, public Filesys 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, byte keycolor, int cursorTargetScale); + void setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, byte keycolor, int cursorTargetScale, const Graphics::PixelFormat *format); // Replace the specified range of cursor the palette with new colors. void setCursorPalette(const byte *colors, uint start, uint num); diff --git a/backends/platform/dc/display.cpp b/backends/platform/dc/display.cpp index d1e95c6a91..9a2510f8fc 100644 --- a/backends/platform/dc/display.cpp +++ b/backends/platform/dc/display.cpp @@ -193,7 +193,7 @@ void OSystem_Dreamcast::setScaling() } } -void OSystem_Dreamcast::initSize(uint w, uint h) +void OSystem_Dreamcast::initSize(uint w, uint h, const Graphics::PixelFormat *format) { assert(w <= SCREEN_W && h <= SCREEN_H); @@ -263,7 +263,7 @@ void OSystem_Dreamcast::warpMouse(int x, int y) void OSystem_Dreamcast::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, - byte keycolor, int cursorTargetScale) + byte keycolor, int cursorTargetScale, const Graphics::PixelFormat *format) { _ms_cur_w = w; _ms_cur_h = h; diff --git a/backends/platform/iphone/osys_main.h b/backends/platform/iphone/osys_main.h index 705f89319a..25cfbcd276 100644 --- a/backends/platform/iphone/osys_main.h +++ b/backends/platform/iphone/osys_main.h @@ -126,7 +126,7 @@ public: bool setGraphicsMode(const char *name); virtual bool setGraphicsMode(int mode); virtual int getGraphicsMode() const; - virtual void initSize(uint width, uint height); + virtual void initSize(uint width, uint height, const Graphics::PixelFormat *format); virtual int16 getHeight(); virtual int16 getWidth(); virtual void setPalette(const byte *colors, uint start, uint num); @@ -149,7 +149,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, byte keycolor = 255, int cursorTargetScale = 1); + virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor = 255, int cursorTargetScale = 1, const Graphics::PixelFormat *format = NULL); virtual bool pollEvent(Common::Event &event); virtual uint32 getMillis(); diff --git a/backends/platform/iphone/osys_video.cpp b/backends/platform/iphone/osys_video.cpp index 641c341f50..3926299223 100644 --- a/backends/platform/iphone/osys_video.cpp +++ b/backends/platform/iphone/osys_video.cpp @@ -46,7 +46,7 @@ int OSystem_IPHONE::getGraphicsMode() const { return -1; } -void OSystem_IPHONE::initSize(uint width, uint height) { +void OSystem_IPHONE::initSize(uint width, uint height, const Graphics::PixelFormat *format) { //printf("initSize(%i, %i)\n", width, height); _screenWidth = width; @@ -438,7 +438,7 @@ void OSystem_IPHONE::dirtyFullOverlayScreen() { } } -void OSystem_IPHONE::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor, int cursorTargetScale) { +void OSystem_IPHONE::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor, int cursorTargetScale, const Graphics::PixelFormat *format) { //printf("setMouseCursor(%i, %i)\n", hotspotX, hotspotY); if (_mouseBuf != NULL && (_mouseWidth != w || _mouseHeight != h)) { -- cgit v1.2.3 From 95c5d240447879397b74a65490644a3ac7e3d461 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sat, 22 Aug 2009 14:52:26 +0000 Subject: Second attempt to fix DC and iPhone backends compilation svn-id: r43651 --- backends/platform/dc/dc.h | 2 +- backends/platform/dc/display.cpp | 4 ++-- backends/platform/iphone/osys_main.h | 2 +- backends/platform/iphone/osys_video.cpp | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) (limited to 'backends') diff --git a/backends/platform/dc/dc.h b/backends/platform/dc/dc.h index f1d3c7af28..f5d200968e 100644 --- a/backends/platform/dc/dc.h +++ b/backends/platform/dc/dc.h @@ -105,7 +105,7 @@ class OSystem_Dreamcast : private DCHardware, public BaseBackend, public Filesys 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, byte keycolor, int cursorTargetScale, const Graphics::PixelFormat *format); + void setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format); // Replace the specified range of cursor the palette with new colors. void setCursorPalette(const byte *colors, uint start, uint num); diff --git a/backends/platform/dc/display.cpp b/backends/platform/dc/display.cpp index 9a2510f8fc..c6be514e36 100644 --- a/backends/platform/dc/display.cpp +++ b/backends/platform/dc/display.cpp @@ -263,7 +263,7 @@ void OSystem_Dreamcast::warpMouse(int x, int y) void OSystem_Dreamcast::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, - byte keycolor, int cursorTargetScale, const Graphics::PixelFormat *format) + uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format) { _ms_cur_w = w; _ms_cur_h = h; @@ -271,7 +271,7 @@ void OSystem_Dreamcast::setMouseCursor(const byte *buf, uint w, uint h, _ms_hotspot_x = hotspot_x; _ms_hotspot_y = hotspot_y; - _ms_keycolor = keycolor; + _ms_keycolor = (byte)keycolor; if (_ms_buf) free(_ms_buf); diff --git a/backends/platform/iphone/osys_main.h b/backends/platform/iphone/osys_main.h index 25cfbcd276..c4c1a8b080 100644 --- a/backends/platform/iphone/osys_main.h +++ b/backends/platform/iphone/osys_main.h @@ -149,7 +149,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, byte keycolor = 255, int cursorTargetScale = 1, const Graphics::PixelFormat *format = NULL); + 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 bool pollEvent(Common::Event &event); virtual uint32 getMillis(); diff --git a/backends/platform/iphone/osys_video.cpp b/backends/platform/iphone/osys_video.cpp index 3926299223..6cb5e18d95 100644 --- a/backends/platform/iphone/osys_video.cpp +++ b/backends/platform/iphone/osys_video.cpp @@ -438,7 +438,7 @@ void OSystem_IPHONE::dirtyFullOverlayScreen() { } } -void OSystem_IPHONE::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor, int cursorTargetScale, const Graphics::PixelFormat *format) { +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)\n", hotspotX, hotspotY); if (_mouseBuf != NULL && (_mouseWidth != w || _mouseHeight != h)) { @@ -455,7 +455,7 @@ void OSystem_IPHONE::setMouseCursor(const byte *buf, uint w, uint h, int hotspot _mouseHotspotX = hotspotX; _mouseHotspotY = hotspotY; - _mouseKeyColour = keycolor; + _mouseKeyColour = (byte)keycolor; memcpy(_mouseBuf, buf, w * h); -- cgit v1.2.3 From 5f0e495a4a6df9a5f299a2c156ed84eba7f3c814 Mon Sep 17 00:00:00 2001 From: Andre Heider Date: Sat, 22 Aug 2009 17:20:55 +0000 Subject: Removed unused var svn-id: r43659 --- backends/platform/wii/osystem_gfx.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'backends') diff --git a/backends/platform/wii/osystem_gfx.cpp b/backends/platform/wii/osystem_gfx.cpp index ed10a407dd..b0e3f112c1 100644 --- a/backends/platform/wii/osystem_gfx.cpp +++ b/backends/platform/wii/osystem_gfx.cpp @@ -200,8 +200,6 @@ void OSystem_Wii::initSize(uint width, uint height, if(_gamePixels) free(_gamePixels); - size_t bufsize; - #ifdef USE_RGB_COLOR _gamePixels = (u8 *) memalign(32, _gameWidth * _gameHeight * _screenPF.bytesPerPixel); -- cgit v1.2.3 From 0ef33c86d557857cd80d376befdc9cf517012eff Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Sat, 22 Aug 2009 22:41:31 +0000 Subject: Attempt to remove some warnings in the wince build that occur on the buildbot's version of gcc (5.1) but don't occur on my local copy (4.1.0). svn-id: r43661 --- backends/platform/wince/CEScaler.cpp | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) (limited to 'backends') diff --git a/backends/platform/wince/CEScaler.cpp b/backends/platform/wince/CEScaler.cpp index d26db3190f..a7910cbdcc 100644 --- a/backends/platform/wince/CEScaler.cpp +++ b/backends/platform/wince/CEScaler.cpp @@ -28,18 +28,17 @@ template void PocketPCPortraitTemplate(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height) { uint8 *work; - int i; while (height--) { - i = 0; work = dstPtr; for (int i=0; i(color1, color2); *(((uint16 *)work) + 1) = interpolate32_1_1(color2, color3); @@ -65,7 +64,8 @@ void PocketPCLandscapeAspect(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr int i,j; unsigned int p1, p2; - uint8 *inbuf, *outbuf, *instart, *outstart; + const uint8 *inbuf, *instart; + uint8 *outbuf, *outstart; #define RB(x) ((x & RBM)<<8) #define G(x) ((x & GM)<<3) @@ -77,7 +77,7 @@ void PocketPCLandscapeAspect(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr #define MAKEPIXEL(rb,g) ((((rb)>>8) & RBM | ((g)>>3) & GM)) - inbuf = (uint8 *)srcPtr; + inbuf = (const uint8 *)srcPtr; outbuf = (uint8 *)dstPtr; height /= 5; @@ -86,22 +86,22 @@ void PocketPCLandscapeAspect(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr outstart = outbuf; for (j=0; j < width; j++) { - p1 = *(uint16*)inbuf; inbuf += srcPitch; + p1 = *(const uint16*)inbuf; inbuf += srcPitch; *(uint16*)outbuf = p1; outbuf += dstPitch; - p2 = *(uint16*)inbuf; inbuf += srcPitch; + p2 = *(const uint16*)inbuf; inbuf += srcPitch; *(uint16*)outbuf = MAKEPIXEL(P20(RB(p1))+P80(RB(p2)),P20(G(p1))+P80(G(p2))); outbuf += dstPitch; p1 = p2; - p2 = *(uint16*)inbuf; inbuf += srcPitch; + p2 = *(const uint16*)inbuf; inbuf += srcPitch; *(uint16*)outbuf = MAKEPIXEL(P40(RB(p1))+P60(RB(p2)),P40(G(p1))+P60(G(p2))); outbuf += dstPitch; p1 = p2; - p2 = *(uint16*)inbuf; inbuf += srcPitch; + p2 = *(const uint16*)inbuf; inbuf += srcPitch; *(uint16*)outbuf = MAKEPIXEL(P60(RB(p1))+P40(RB(p2)),P60(G(p1))+P40(G(p2))); outbuf += dstPitch; p1 = p2; - p2 = *(uint16*)inbuf; + p2 = *(const uint16*)inbuf; *(uint16*)outbuf = MAKEPIXEL(P80(RB(p1))+P20(RB(p2)),P80(G(p1))+P20(G(p2))); outbuf += dstPitch; *(uint16*)outbuf = p2; @@ -127,11 +127,9 @@ extern "C" { template void PocketPCHalfTemplate(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height) { uint8 *work; - int i; uint16 srcPitch16 = (uint16)(srcPitch / sizeof(uint16)); while ((height -= 2) >= 0) { - i = 0; work = dstPtr; for (int i=0; i void PocketPCHalfZoomTemplate(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height) { uint8 *work; - int i; - uint16 srcPitch16 = (uint16)(srcPitch / sizeof(uint16)); if (!height) return; while (height--) { - i = 0; work = dstPtr; for (int i = 0; i < width; i += 2) { @@ -190,11 +185,9 @@ MAKE_WRAPPER(PocketPCHalfZoom) template void SmartphoneLandscapeTemplate(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height) { uint8 *work; - int i; int line = 0; while (height--) { - i = 0; work = dstPtr; for (int i = 0; i < width; i += 3) { -- cgit v1.2.3 From 4a33ef34a347568008d0d0da01e1fc4af360460f Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Sat, 22 Aug 2009 23:00:08 +0000 Subject: Eliminate more warnings for buildbot. svn-id: r43662 --- backends/platform/wince/CEScaler.cpp | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'backends') diff --git a/backends/platform/wince/CEScaler.cpp b/backends/platform/wince/CEScaler.cpp index a7910cbdcc..517c86e3b9 100644 --- a/backends/platform/wince/CEScaler.cpp +++ b/backends/platform/wince/CEScaler.cpp @@ -27,24 +27,25 @@ template void PocketPCPortraitTemplate(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height) { - uint8 *work; + uint16 *work; + // Various casts below go via (void *) to avoid warning. This is + // safe as these are all even addresses. while (height--) { - work = dstPtr; + work = (uint16 *)(void *)dstPtr; for (int i=0; i(color1, color2); - *(((uint16 *)work) + 1) = interpolate32_1_1(color2, color3); - *(((uint16 *)work) + 2) = interpolate32_3_1(color4, color3); + work[0] = interpolate32_3_1(color1, color2); + work[1] = interpolate32_1_1(color2, color3); + work[2] = interpolate32_3_1(color4, color3); - work += 3 * sizeof(uint16); + work += 3; } srcPtr += srcPitch; dstPtr += dstPitch; @@ -161,20 +162,20 @@ void PocketPCHalf(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 ds template void PocketPCHalfZoomTemplate(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height) { - uint8 *work; + uint16 *work; if (!height) return; + // Various casts below go via (void *) to avoid warning. This is + // safe as these are all even addresses. while (height--) { - work = dstPtr; + work = (uint16 *)(void *)dstPtr; for (int i = 0; i < width; i += 2) { - uint16 color1 = *(((const uint16 *)srcPtr) + i); - uint16 color2 = *(((const uint16 *)srcPtr) + (i + 1)); - *(((uint16 *)work) + 0) = interpolate32_1_1(color1, color2); - - work += sizeof(uint16); + uint16 color1 = *(((const uint16 *)(const void *)srcPtr) + i); + uint16 color2 = *(((const uint16 *)(const void *)srcPtr) + (i + 1)); + *work++ = interpolate32_1_1(color1, color2); } srcPtr += srcPitch; dstPtr += dstPitch; -- cgit v1.2.3 From cef52305951b99d49f71c6f8d410d09db73e726d Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Sat, 22 Aug 2009 23:09:43 +0000 Subject: Remove more warnings from wince build. svn-id: r43663 --- backends/platform/wince/CEScaler.cpp | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'backends') diff --git a/backends/platform/wince/CEScaler.cpp b/backends/platform/wince/CEScaler.cpp index 517c86e3b9..0a71fda167 100644 --- a/backends/platform/wince/CEScaler.cpp +++ b/backends/platform/wince/CEScaler.cpp @@ -82,30 +82,32 @@ void PocketPCLandscapeAspect(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr outbuf = (uint8 *)dstPtr; height /= 5; + // Various casts below go via (void *) to avoid warning. This is + // safe as these are all even addresses. for (i = 0; i < height; i++) { instart = inbuf; outstart = outbuf; for (j=0; j < width; j++) { - p1 = *(const uint16*)inbuf; inbuf += srcPitch; - *(uint16*)outbuf = p1; outbuf += dstPitch; + p1 = *(const uint16*)(const void *)inbuf; inbuf += srcPitch; + *(uint16*)(void *)outbuf = p1; outbuf += dstPitch; - p2 = *(const uint16*)inbuf; inbuf += srcPitch; - *(uint16*)outbuf = MAKEPIXEL(P20(RB(p1))+P80(RB(p2)),P20(G(p1))+P80(G(p2))); outbuf += dstPitch; + p2 = *(const uint16*)(const void *)inbuf; inbuf += srcPitch; + *(uint16*)(void *)outbuf = MAKEPIXEL(P20(RB(p1))+P80(RB(p2)),P20(G(p1))+P80(G(p2))); outbuf += dstPitch; p1 = p2; - p2 = *(const uint16*)inbuf; inbuf += srcPitch; - *(uint16*)outbuf = MAKEPIXEL(P40(RB(p1))+P60(RB(p2)),P40(G(p1))+P60(G(p2))); outbuf += dstPitch; + p2 = *(const uint16*)(const void *)inbuf; inbuf += srcPitch; + *(uint16*)(void *)outbuf = MAKEPIXEL(P40(RB(p1))+P60(RB(p2)),P40(G(p1))+P60(G(p2))); outbuf += dstPitch; p1 = p2; - p2 = *(const uint16*)inbuf; inbuf += srcPitch; - *(uint16*)outbuf = MAKEPIXEL(P60(RB(p1))+P40(RB(p2)),P60(G(p1))+P40(G(p2))); outbuf += dstPitch; + p2 = *(const uint16*)(const void *)inbuf; inbuf += srcPitch; + *(uint16*)(void *)outbuf = MAKEPIXEL(P60(RB(p1))+P40(RB(p2)),P60(G(p1))+P40(G(p2))); outbuf += dstPitch; p1 = p2; - p2 = *(const uint16*)inbuf; - *(uint16*)outbuf = MAKEPIXEL(P80(RB(p1))+P20(RB(p2)),P80(G(p1))+P20(G(p2))); outbuf += dstPitch; + p2 = *(const uint16*)(const void *)inbuf; + *(uint16*)(void *)outbuf = MAKEPIXEL(P80(RB(p1))+P20(RB(p2)),P80(G(p1))+P20(G(p2))); outbuf += dstPitch; - *(uint16*)outbuf = p2; + *(uint16*)(void *)outbuf = p2; inbuf = inbuf - srcPitch*4 + sizeof(uint16); outbuf = outbuf - dstPitch*5 + sizeof(uint16); -- cgit v1.2.3 From 080eaef76cb4051802a41c58155f7bb004ab9d1a Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sun, 23 Aug 2009 20:40:09 +0000 Subject: Formatting svn-id: r43675 --- backends/platform/linuxmoto/hardwarekeys.cpp | 34 ++++++++--------- backends/platform/linuxmoto/linuxmoto-events.cpp | 48 ++++++++++++------------ 2 files changed, 42 insertions(+), 40 deletions(-) (limited to 'backends') diff --git a/backends/platform/linuxmoto/hardwarekeys.cpp b/backends/platform/linuxmoto/hardwarekeys.cpp index 2f64e7dbae..e65d2bec2b 100644 --- a/backends/platform/linuxmoto/hardwarekeys.cpp +++ b/backends/platform/linuxmoto/hardwarekeys.cpp @@ -42,23 +42,23 @@ struct Key { }; static const Key keys[] = { - {"FIRE", KEYCODE_RETURN, ASCII_RETURN, "Fire", kActionKeyType, false}, - {"CAMERA", KEYCODE_PAUSE, 0, "Camera", kActionKeyType, false}, - {"HANGUP", KEYCODE_ESCAPE, ASCII_ESCAPE, "Hangup", kStartKeyType, false}, - {"CALL", KEYCODE_SPACE, ASCII_SPACE, "Call", kActionKeyType, false}, - {"PLUS", KEYCODE_PLUS, '+', "+", kActionKeyType, false}, - {"MINUS", KEYCODE_MINUS, '-', "-", kActionKeyType, false}, - - {"a", KEYCODE_a, 'a', "a", kActionKeyType, true}, - {"b", KEYCODE_b, 'b', "b", kActionKeyType, true}, - {"c", KEYCODE_c, 'c', "c", kActionKeyType, true}, - {"d", KEYCODE_d, 'd', "d", kActionKeyType, true}, - {"e", KEYCODE_e, 'e', "e", kActionKeyType, true}, - {"f", KEYCODE_f, 'f', "f", kActionKeyType, true}, - {"g", KEYCODE_g, 'g', "g", kActionKeyType, true}, - {"h", KEYCODE_h, 'h', "h", kActionKeyType, true}, - {"i", KEYCODE_i, 'i', "i", kActionKeyType, true}, - {"j", KEYCODE_j, 'j', "j", kActionKeyType, true}, + { "FIRE", KEYCODE_RETURN, ASCII_RETURN, "Fire", kActionKeyType, false }, + { "CAMERA", KEYCODE_PAUSE, 0, "Camera", kActionKeyType, false }, + { "HANGUP", KEYCODE_ESCAPE, ASCII_ESCAPE, "Hangup", kStartKeyType, false }, + { "CALL", KEYCODE_SPACE, ASCII_SPACE, "Call", kActionKeyType, false }, + { "PLUS", KEYCODE_PLUS, '+', "+", kActionKeyType, false }, + { "MINUS", KEYCODE_MINUS, '-', "-", kActionKeyType, false }, + + { "a", KEYCODE_a, 'a', "a", kActionKeyType, true }, + { "b", KEYCODE_b, 'b', "b", kActionKeyType, true }, + { "c", KEYCODE_c, 'c', "c", kActionKeyType, true }, + { "d", KEYCODE_d, 'd', "d", kActionKeyType, true }, + { "e", KEYCODE_e, 'e', "e", kActionKeyType, true }, + { "f", KEYCODE_f, 'f', "f", kActionKeyType, true }, + { "g", KEYCODE_g, 'g', "g", kActionKeyType, true }, + { "h", KEYCODE_h, 'h', "h", kActionKeyType, true }, + { "i", KEYCODE_i, 'i', "i", kActionKeyType, true }, + { "j", KEYCODE_j, 'j', "j", kActionKeyType, true }, // Numeric keypad diff --git a/backends/platform/linuxmoto/linuxmoto-events.cpp b/backends/platform/linuxmoto/linuxmoto-events.cpp index 2a40d734b0..be5eec5c7e 100644 --- a/backends/platform/linuxmoto/linuxmoto-events.cpp +++ b/backends/platform/linuxmoto/linuxmoto-events.cpp @@ -53,20 +53,20 @@ bool OSystem_LINUXMOTO::remapKey(SDL_Event &ev, Common::Event &event) { return true; } // '1' Bypass security protection - MOD+Call key - if (ev.key.keysym.sym == SDLK_f) { - ev.key.keysym.sym=SDLK_1; + if (ev.key.keysym.sym == SDLK_f) { + ev.key.keysym.sym = SDLK_1; } // F5 Game Menu - Call key else if (ev.key.keysym.sym == SDLK_SPACE) { - ev.key.keysym.sym=SDLK_F5; + ev.key.keysym.sym = SDLK_F5; } // Camera to VirtualKeyboard else if (ev.key.keysym.sym == SDLK_PAUSE) { - ev.key.keysym.sym=SDLK_F7; + ev.key.keysym.sym = SDLK_F7; } // mod+fire to enter else if (ev.key.keysym.sym == SDLK_b) { - ev.key.keysym.sym=SDLK_RETURN; + ev.key.keysym.sym = SDLK_RETURN; } #endif // Motorola Z6/V8 remapkey by Ant-On @@ -78,17 +78,17 @@ bool OSystem_LINUXMOTO::remapKey(SDL_Event &ev, Common::Event &event) { } else // F5 Game Menu - Call key if (ev.key.keysym.sym == SDLK_SPACE) { - ev.key.keysym.sym=SDLK_F5; + ev.key.keysym.sym = SDLK_F5; } // 'y' - Mod+Right key // 'y' - Left soft else if (ev.key.keysym.sym == SDLK_F9) { - ev.key.keysym.sym=SDLK_y; + ev.key.keysym.sym = SDLK_y; } // 'n' - Mod+Left key // 'n' - rigth soft else if (ev.key.keysym.sym == SDLK_F11) { - ev.key.keysym.sym=SDLK_n; + ev.key.keysym.sym = SDLK_n; } #endif @@ -116,6 +116,7 @@ bool OSystem_LINUXMOTO::remapKey(SDL_Event &ev, Common::Event &event) { event.type = Common::EVENT_MOUSEMOVE; fillMouseEvent(event, _km.x, _km.y); + return true; } else if (ev.key.keysym.sym == SDLK_DOWN) { if (ev.type == SDL_KEYDOWN) { @@ -128,6 +129,7 @@ bool OSystem_LINUXMOTO::remapKey(SDL_Event &ev, Common::Event &event) { event.type = Common::EVENT_MOUSEMOVE; fillMouseEvent(event, _km.x, _km.y); + return true; } else if (ev.key.keysym.sym == SDLK_UP) { if (ev.type == SDL_KEYDOWN) { @@ -140,47 +142,47 @@ bool OSystem_LINUXMOTO::remapKey(SDL_Event &ev, Common::Event &event) { event.type = Common::EVENT_MOUSEMOVE; fillMouseEvent(event, _km.x, _km.y); + return true; - } - // Joystick center to pressing Left Mouse - else if (ev.key.keysym.sym == SDLK_RETURN) { + } else if (ev.key.keysym.sym == SDLK_RETURN) { // Joystick center to pressing Left Mouse // _km.y_vel = 0; // _km.y_down_count = 0; if (ev.key.type == SDL_KEYDOWN) { event.type = Common::EVENT_LBUTTONDOWN; } else { - event.type = Common::EVENT_LBUTTONUP; + event.type = Common::EVENT_LBUTTONUP; } + fillMouseEvent(event, _km.x, _km.y); + return true; - } - // Volume Up to pressing Right Mouse - else if (ev.key.keysym.sym == SDLK_PLUS) { + } else if (ev.key.keysym.sym == SDLK_PLUS) { // Volume Up to pressing Right Mouse // _km.y_vel = 0; // _km.y_down_count = 0; if (ev.key.type == SDL_KEYDOWN ) { event.type = Common::EVENT_RBUTTONDOWN; } else { - event.type = Common::EVENT_RBUTTONUP; + event.type = Common::EVENT_RBUTTONUP; } fillMouseEvent(event, _km.x, _km.y); + return true; - } - // Volume Down to pressing Left Mouse - else if (ev.key.keysym.sym == SDLK_MINUS) { + } else if (ev.key.keysym.sym == SDLK_MINUS) { // Volume Down to pressing Left Mouse //_km.y_vel = 0; //_km.y_down_count = 0; if (ev.key.type == SDL_KEYDOWN) { event.type = Common::EVENT_LBUTTONDOWN; } else { - event.type = Common::EVENT_LBUTTONUP; + event.type = Common::EVENT_LBUTTONUP; } + fillMouseEvent(event, _km.x, _km.y); + return true; } else { - // Let the events fall through if we didn't change them, this may not be the best way to - // set it up, but i'm not sure how sdl would like it if we let if fall through then redid it though. - // and yes i have an huge terminal size so i dont wrap soon enough. + // Let the events fall through if we didn't change them, this may not be the best way to + // set it up, but i'm not sure how sdl would like it if we let if fall through then redid it though. + // and yes i have an huge terminal size so i dont wrap soon enough. event.type = Common::EVENT_KEYDOWN; event.kbd.keycode = (Common::KeyCode)ev.key.keysym.sym; event.kbd.ascii = mapKey(ev.key.keysym.sym, ev.key.keysym.mod, ev.key.keysym.unicode); -- cgit v1.2.3 From a041ba4f48ae6a58cc795467c37fabb11bfd4163 Mon Sep 17 00:00:00 2001 From: Andre Heider Date: Sun, 23 Aug 2009 22:51:57 +0000 Subject: Whitespace fix for buildbot svn-id: r43679 --- backends/platform/linuxmoto/main.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'backends') diff --git a/backends/platform/linuxmoto/main.cpp b/backends/platform/linuxmoto/main.cpp index 1e37fe617a..7f015faff4 100644 --- a/backends/platform/linuxmoto/main.cpp +++ b/backends/platform/linuxmoto/main.cpp @@ -34,7 +34,6 @@ #include "base/internal_version.h" int main(int argc, char *argv[]) { - g_system = new OSystem_LINUXMOTO(); assert(g_system); // Invoke the actual ScummVM main entry point: -- cgit v1.2.3