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/platform/sdl') 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/platform/sdl') 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/platform/sdl') 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/platform/sdl') 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/platform/sdl') 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/platform/sdl') 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/platform/sdl') 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/platform/sdl') 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/platform/sdl') 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/platform/sdl') 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/platform/sdl') 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/platform/sdl') 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/platform/sdl') 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/platform/sdl') 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/platform/sdl') 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/platform/sdl') 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/platform/sdl') 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/platform/sdl') 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/platform/sdl') 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/platform/sdl') 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/platform/sdl') 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/platform/sdl') 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/platform/sdl') 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/platform/sdl') 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/platform/sdl') 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/platform/sdl') 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/platform/sdl') 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/platform/sdl') 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/platform/sdl') 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/platform/sdl') 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/platform/sdl') 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/platform/sdl') 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/platform/sdl') 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/platform/sdl/hardwarekeys.cpp | 302 +++++++++++++++++---------------- 1 file changed, 153 insertions(+), 149 deletions(-) (limited to 'backends/platform/sdl') 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/platform/sdl/hardwarekeys.cpp | 52 +++++++++++++++++----------------- 1 file changed, 26 insertions(+), 26 deletions(-) (limited to 'backends/platform/sdl') 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 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/platform/sdl') 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 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/platform/sdl/hardwarekeys.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'backends/platform/sdl') 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 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/platform/sdl/hardwarekeys.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'backends/platform/sdl') 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 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/sdl/graphics.cpp | 30 +++++++++++++++--------------- backends/platform/sdl/sdl.cpp | 2 +- backends/platform/sdl/sdl.h | 8 ++++---- 3 files changed, 20 insertions(+), 20 deletions(-) (limited to 'backends/platform/sdl') 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 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/platform/sdl') 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 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/sdl/events.cpp | 2 ++ backends/platform/sdl/main.cpp | 2 +- backends/platform/sdl/sdl.cpp | 5 ++--- backends/platform/sdl/sdl.h | 2 ++ 4 files changed, 7 insertions(+), 4 deletions(-) (limited to 'backends/platform/sdl') 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/platform/sdl') 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/sdl/sdl.cpp | 6 +++--- backends/platform/sdl/sdl.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'backends/platform/sdl') 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