diff options
author | Max Horn | 2011-06-20 00:59:48 +0200 |
---|---|---|
committer | Max Horn | 2011-06-20 00:59:48 +0200 |
commit | 88913c0139ac6d1dfb356d3048702b7bc8ef4079 (patch) | |
tree | a7436d20333c28f87f2ed0bc15c743b5eb8144ee /backends | |
parent | 3853e76202b132e769ae149720eca931cd87104a (diff) | |
download | scummvm-rg350-88913c0139ac6d1dfb356d3048702b7bc8ef4079.tar.gz scummvm-rg350-88913c0139ac6d1dfb356d3048702b7bc8ef4079.tar.bz2 scummvm-rg350-88913c0139ac6d1dfb356d3048702b7bc8ef4079.zip |
ALL: Remove trailing whitespaces
This tries to make our code a bit more compliant with our code formatting
conventions. For future use, this is the command I used:
git ls-files "*.cpp" "*.h" | xargs sed -i -e 's/[ \t]*$//'
Diffstat (limited to 'backends')
44 files changed, 267 insertions, 267 deletions
diff --git a/backends/audiocd/audiocd.h b/backends/audiocd/audiocd.h index 92b7598cb5..0afc6af991 100644 --- a/backends/audiocd/audiocd.h +++ b/backends/audiocd/audiocd.h @@ -113,7 +113,7 @@ public: * @return true if the CD drive was inited succesfully */ virtual bool openCD(int drive) = 0; - + /** * Poll CD status. * @return true if CD audio is playing diff --git a/backends/events/sdl/sdl-events.h b/backends/events/sdl/sdl-events.h index 9b9d265970..805b76b108 100644 --- a/backends/events/sdl/sdl-events.h +++ b/backends/events/sdl/sdl-events.h @@ -32,7 +32,7 @@ * The SDL event source. */ class SdlEventSource : public Common::EventSource { -public: +public: SdlEventSource(); virtual ~SdlEventSource(); @@ -69,7 +69,7 @@ protected: /** Scroll lock state - since SDL doesn't track it */ bool _scrollLock; - + /** Joystick */ SDL_Joystick *_joystick; diff --git a/backends/events/webossdl/webossdl-events.cpp b/backends/events/webossdl/webossdl-events.cpp index 4a17bc2066..102eb5802e 100644 --- a/backends/events/webossdl/webossdl-events.cpp +++ b/backends/events/webossdl/webossdl-events.cpp @@ -89,7 +89,7 @@ void WebOSSdlEventSource::SDLModToOSystemKeyFlags(SDLMod mod, event.kbd.flags |= Common::KBD_SHIFT; if (mod & KMOD_CTRL) event.kbd.flags |= Common::KBD_CTRL; - + // Holding down the gesture area emulates the ALT key if (gestureDown) event.kbd.flags |= Common::KBD_ALT; diff --git a/backends/graphics/dinguxsdl/dinguxsdl-graphics.h b/backends/graphics/dinguxsdl/dinguxsdl-graphics.h index d24e72f63e..84a784b771 100644 --- a/backends/graphics/dinguxsdl/dinguxsdl-graphics.h +++ b/backends/graphics/dinguxsdl/dinguxsdl-graphics.h @@ -25,7 +25,7 @@ #include "backends/graphics/surfacesdl/surfacesdl-graphics.h" -#include "graphics/scaler/aspect.h" // for aspect2Real +#include "graphics/scaler/aspect.h" // for aspect2Real #include "graphics/scaler/downscaler.h" enum { diff --git a/backends/graphics/opengl/gltexture.cpp b/backends/graphics/opengl/gltexture.cpp index 3d1027b44f..b7f5c90105 100644 --- a/backends/graphics/opengl/gltexture.cpp +++ b/backends/graphics/opengl/gltexture.cpp @@ -108,7 +108,7 @@ void GLTexture::refresh() { void GLTexture::allocBuffer(GLuint w, GLuint h) { _realWidth = w; _realHeight = h; - + if (w <= _textureWidth && h <= _textureHeight && !_refresh) // Already allocated a sufficiently large buffer return; diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp index 4c2c70daf2..046be4c669 100644 --- a/backends/graphics/opengl/opengl-graphics.cpp +++ b/backends/graphics/opengl/opengl-graphics.cpp @@ -642,7 +642,7 @@ void OpenGLGraphicsManager::setMouseCursor(const byte *buf, uint w, uint h, int void OpenGLGraphicsManager::setCursorPalette(const byte *colors, uint start, uint num) { assert(colors); - + // Save the cursor palette memcpy(_cursorPalette + start * 3, colors, num * 3); @@ -1315,7 +1315,7 @@ bool OpenGLGraphicsManager::notifyEvent(const Common::Event &event) { bool OpenGLGraphicsManager::saveScreenshot(const char *filename) { int width = _videoMode.hardwareWidth; int height = _videoMode.hardwareHeight; - + // A line of a BMP image must have a size divisible by 4. // We calculate the padding bytes needed here. // Since we use a 3 byte per pixel mode, we can use width % 4 here, since @@ -1358,7 +1358,7 @@ bool OpenGLGraphicsManager::saveScreenshot(const char *filename) { out.writeUint32LE(0); out.writeUint32LE(0); out.writeUint32LE(0); - out.writeUint32LE(0); + out.writeUint32LE(0); // Write pixel data to BMP out.write(pixels, lineSize * height); @@ -1423,9 +1423,9 @@ void OpenGLGraphicsManager::updateOSD() { dstX, dstY + i * lineHeight + vOffset + lineSpacing, width, 0xFFFF, Graphics::kTextAlignCenter); } - + // Update the texture - _osdTexture->updateBuffer(_osdSurface.pixels, _osdSurface.pitch, 0, 0, + _osdTexture->updateBuffer(_osdSurface.pixels, _osdSurface.pitch, 0, 0, _osdSurface.w, _osdSurface.h); } #endif diff --git a/backends/graphics/opengl/opengl-graphics.h b/backends/graphics/opengl/opengl-graphics.h index 463715aad8..56f7d92a12 100644 --- a/backends/graphics/opengl/opengl-graphics.h +++ b/backends/graphics/opengl/opengl-graphics.h @@ -185,7 +185,7 @@ protected: /** * Set the scale factor. - * + * * This can only be used in a GFX transaction. * * @param newScale New scale factor. @@ -332,7 +332,7 @@ protected: GLTexture *_osdTexture; Graphics::Surface _osdSurface; uint8 _osdAlpha; - uint32 _osdFadeStartTime; + uint32 _osdFadeStartTime; bool _requireOSDUpdate; enum { kOSDFadeOutDelay = 2 * 1000, diff --git a/backends/graphics/openglsdl/openglsdl-graphics.cpp b/backends/graphics/openglsdl/openglsdl-graphics.cpp index eefba59089..bd7dd32e3b 100644 --- a/backends/graphics/openglsdl/openglsdl-graphics.cpp +++ b/backends/graphics/openglsdl/openglsdl-graphics.cpp @@ -306,7 +306,7 @@ bool OpenGLSdlGraphicsManager::loadGFXMode() { int screenAspectRatio = _videoMode.screenWidth * 10000 / _videoMode.screenHeight; int desiredAspectRatio = getAspectRatio(); - + // Do not downscale dimensions, only enlarge them if needed if (screenAspectRatio > desiredAspectRatio) _videoMode.hardwareHeight = (_videoMode.overlayWidth * 10000 + 5000) / desiredAspectRatio; @@ -389,7 +389,7 @@ void OpenGLSdlGraphicsManager::internUpdateScreen() { OpenGLGraphicsManager::internUpdateScreen(); // Swap OpenGL buffers - SDL_GL_SwapBuffers(); + SDL_GL_SwapBuffers(); } #ifdef USE_OSD @@ -561,7 +561,7 @@ bool OpenGLSdlGraphicsManager::notifyEvent(const Common::Event &event) { // Check if the desktop resolution has been detected if (_desktopWidth > 0 && _desktopHeight > 0) // If the new scale factor is too big, do not scale - if (_videoMode.screenWidth * factor > _desktopWidth || + if (_videoMode.screenWidth * factor > _desktopWidth || _videoMode.screenHeight * factor > _desktopHeight) return false; @@ -611,7 +611,7 @@ bool OpenGLSdlGraphicsManager::notifyEvent(const Common::Event &event) { break; case Common::EVENT_KEYUP: return isHotkey(event); - // HACK: Handle special SDL event + // HACK: Handle special SDL event // The new screen size is saved on the mouse event as part of HACK, // there is no common resize event. case OSystem_SDL::kSdlEventResize: diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.h b/backends/graphics/surfacesdl/surfacesdl-graphics.h index 96ba103f14..cd8710d443 100644 --- a/backends/graphics/surfacesdl/surfacesdl-graphics.h +++ b/backends/graphics/surfacesdl/surfacesdl-graphics.h @@ -100,7 +100,7 @@ public: virtual void beginGFXTransaction(); virtual OSystem::TransactionError endGFXTransaction(); - + virtual int16 getHeight(); virtual int16 getWidth(); @@ -132,7 +132,7 @@ public: virtual void warpMouse(int x, int y); virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int cursorTargetScale = 1, const Graphics::PixelFormat *format = NULL); virtual void setCursorPalette(const byte *colors, uint start, uint num); - + #ifdef USE_OSD virtual void displayMessageOnOSD(const char *msg); #endif @@ -149,7 +149,7 @@ protected: /** Transparency level of the OSD */ uint8 _osdAlpha; /** When to start the fade out */ - uint32 _osdFadeStartTime; + uint32 _osdFadeStartTime; /** Enum with OSD options */ enum { kOSDFadeOutDelay = 2 * 1000, /** < Delay before the OSD is faded out (in milliseconds) */ diff --git a/backends/mixer/doublebuffersdl/doublebuffersdl-mixer.cpp b/backends/mixer/doublebuffersdl/doublebuffersdl-mixer.cpp index 001389b1c0..3e5b9940e0 100644 --- a/backends/mixer/doublebuffersdl/doublebuffersdl-mixer.cpp +++ b/backends/mixer/doublebuffersdl/doublebuffersdl-mixer.cpp @@ -28,7 +28,7 @@ DoubleBufferSDLMixerManager::DoubleBufferSDLMixerManager() : _soundMutex(0), _soundCond(0), _soundThread(0), _soundThreadIsRunning(false), _soundThreadShouldQuit(false) { - + } DoubleBufferSDLMixerManager::~DoubleBufferSDLMixerManager() { diff --git a/backends/mixer/sdl/sdl-mixer.cpp b/backends/mixer/sdl/sdl-mixer.cpp index 979b18e264..001309a777 100644 --- a/backends/mixer/sdl/sdl-mixer.cpp +++ b/backends/mixer/sdl/sdl-mixer.cpp @@ -70,7 +70,7 @@ void SdlMixerManager::init() { warning("Could not open audio device: %s", SDL_GetError()); _mixer = new Audio::MixerImpl(g_system, desired.freq); - assert(_mixer); + assert(_mixer); _mixer->setReady(false); } else { debug(1, "Output sample rate: %d Hz", _obtained.freq); diff --git a/backends/mixer/sdl/sdl-mixer.h b/backends/mixer/sdl/sdl-mixer.h index 82ffa4f901..6fee26bd1f 100644 --- a/backends/mixer/sdl/sdl-mixer.h +++ b/backends/mixer/sdl/sdl-mixer.h @@ -73,7 +73,7 @@ protected: bool _audioSuspended; /** - * Returns the desired audio specification + * Returns the desired audio specification */ virtual SDL_AudioSpec getAudioSpec(uint32 rate); diff --git a/backends/modular-backend.h b/backends/modular-backend.h index 3593130bf5..b864da0df5 100644 --- a/backends/modular-backend.h +++ b/backends/modular-backend.h @@ -30,17 +30,17 @@ class MutexManager; /** * Base class for modular backends. - * + * * It wraps most functions to their manager equivalent, but not * all OSystem functions are implemented here. - * + * * A backend derivated from this class, will need to implement * these functions on its own: * OSystem::pollEvent() * OSystem::getMillis() * OSystem::delayMillis() * OSystem::getTimeAndDate() - * + * * And, it should also initialize all the managers variables * declared in this class, or override their related functions. */ @@ -107,11 +107,11 @@ public: /** @name Events and Time */ //@{ - + virtual Common::HardwareKeySet *getHardwareKeySet() { return 0; } //@} - + /** @name Mutex handling */ //@{ diff --git a/backends/platform/dc/dcmain.cpp b/backends/platform/dc/dcmain.cpp index 3faf0185ad..06738a687d 100644 --- a/backends/platform/dc/dcmain.cpp +++ b/backends/platform/dc/dcmain.cpp @@ -234,7 +234,7 @@ void OSystem_Dreamcast::logMessage(LogMessageType::Type type, const char *messag namespace DC_Flash { static int syscall_info_flash(int sect, int *info) { - return (*(int (**)(int, void*, int, int))0x8c0000b8)(sect,info,0,0); + return (*(int (**)(int, void*, int, int))0x8c0000b8)(sect,info,0,0); } static int syscall_read_flash(int offs, void *buf, int cnt) @@ -255,24 +255,24 @@ namespace DC_Flash { } return (unsigned short)~n; } - + static int flash_read_sector(int partition, int sec, unsigned char *dst) { int s, r, n, b, bmb, got=0; int info[2]; char buf[64]; char bm[64]; - + if((r = syscall_info_flash(partition, info))<0) return r; - + if((r = syscall_read_flash(info[0], buf, 64))<0) return r; - + if(memcmp(buf, "KATANA_FLASH", 12) || buf[16] != partition || buf[17] != 0) return -2; - + n = (info[1]>>6)-1-((info[1] + 0x7fff)>>15); bmb = n+1; for(b = 0; b < n; b++) { diff --git a/backends/platform/dc/plugins.cpp b/backends/platform/dc/plugins.cpp index fff3c147ec..2942a4f155 100644 --- a/backends/platform/dc/plugins.cpp +++ b/backends/platform/dc/plugins.cpp @@ -51,7 +51,7 @@ static void drawPluginProgress(const Common::String &filename) ta_begin_frame(); draw_solid_quad(80.0, 270.0, 560.0, 300.0, 0xff808080, 0xff808080, 0xff808080, 0xff808080); - draw_solid_quad(85.0, 275.0, 555.0, 295.0, + draw_solid_quad(85.0, 275.0, 555.0, 295.0, 0xff202020, 0xff202020, 0xff202020, 0xff202020); draw_solid_quad(85.0, 275.0, 85.0+470.0*ffree, 295.0, fcol, fcol, fcol, fcol); diff --git a/backends/platform/dingux/dingux.cpp b/backends/platform/dingux/dingux.cpp index 1af53aeae1..674c2ea780 100644 --- a/backends/platform/dingux/dingux.cpp +++ b/backends/platform/dingux/dingux.cpp @@ -33,7 +33,7 @@ void OSystem_SDL_Dingux::initBackend() { // Create the graphics manager if (_graphicsManager == 0) { - _graphicsManager = new DINGUXSdlGraphicsManager(_eventSource); + _graphicsManager = new DINGUXSdlGraphicsManager(_eventSource); } // Call parent implementation of this method diff --git a/backends/platform/ds/arm9/source/gbampsave.cpp b/backends/platform/ds/arm9/source/gbampsave.cpp index db9b1c2609..03729c5e6e 100644 --- a/backends/platform/ds/arm9/source/gbampsave.cpp +++ b/backends/platform/ds/arm9/source/gbampsave.cpp @@ -52,7 +52,7 @@ Common::OutSaveFile *GBAMPSaveFileManager::openForSaving(const Common::String &f fileSpec += filename; // consolePrintf("Opening the file: %s\n", fileSpec.c_str()); - + Common::WriteStream *stream = DS::DSFileStream::makeFromPath(fileSpec, true); // Use a write buffer stream = Common::wrapBufferedWriteStream(stream, SAVE_BUFFER_SIZE); @@ -66,7 +66,7 @@ Common::InSaveFile *GBAMPSaveFileManager::openForLoading(const Common::String &f fileSpec += filename; // consolePrintf("Opening the file: %s\n", fileSpec.c_str()); - + return DS::DSFileStream::makeFromPath(fileSpec, false); } diff --git a/backends/platform/n64/osys_n64.h b/backends/platform/n64/osys_n64.h index 285e2afa55..354f25a1cf 100644 --- a/backends/platform/n64/osys_n64.h +++ b/backends/platform/n64/osys_n64.h @@ -107,7 +107,7 @@ protected: // FIXME: This must be left as "int" for now, to fix the sign-comparison problem // there is a little more work involved than an int->uint change int _cursorWidth, _cursorHeight; - + int _cursorKeycolor; uint16 _overlayHeight, _overlayWidth; diff --git a/backends/platform/n64/osys_n64_events.cpp b/backends/platform/n64/osys_n64_events.cpp index 2645cfea2a..62f11aef64 100644 --- a/backends/platform/n64/osys_n64_events.cpp +++ b/backends/platform/n64/osys_n64_events.cpp @@ -162,7 +162,7 @@ bool OSystem_N64::pollEvent(Common::Event &event) { uint16 newButtons = 0; if (_controllerPort >= 0) newButtons = _ctrlData.c[_controllerPort].buttons; // Read from controller - + uint16 newMouseButtons = 0; if (_mousePort >= 0) newMouseButtons = _ctrlData.c[_mousePort].buttons; diff --git a/backends/platform/psp/cursor.cpp b/backends/platform/psp/cursor.cpp index 18a61f3df4..b295507de1 100644 --- a/backends/platform/psp/cursor.cpp +++ b/backends/platform/psp/cursor.cpp @@ -324,18 +324,18 @@ inline void Cursor::setRendererModePalettized(bool palettized) { _renderer.setAlphaReverse(false); _renderer.setColorTest(false); } else { // 16 bits, no palette - // Color test is an easy way for the hardware to make our keycolor + // Color test is an easy way for the hardware to make our keycolor // transparent. - _renderer.setColorTest(true); - + _renderer.setColorTest(true); + // Alpha blending is not strictly required, but makes the cursor look // much better _renderer.setAlphaBlending(true); - + // Pixel formats without alpha (5650) are considered to have their alpha set. // Since pixel formats with alpha don't have their alpha bits set, we reverse // the alpha format for them so that 0 alpha is 1. - if (_buffer.getPixelFormat() != PSPPixelFormat::Type_5650) + if (_buffer.getPixelFormat() != PSPPixelFormat::Type_5650) _renderer.setAlphaReverse(true); else _renderer.setAlphaReverse(false); diff --git a/backends/platform/psp/display_client.cpp b/backends/platform/psp/display_client.cpp index 14b96d9cae..bc29166895 100644 --- a/backends/platform/psp/display_client.cpp +++ b/backends/platform/psp/display_client.cpp @@ -389,31 +389,31 @@ void Buffer::copyToArray(byte *dst, int pitch) { void Buffer::setSize(uint32 width, uint32 height, HowToSize textureOrSource/*=kSizeByTextureSize*/) { DEBUG_ENTER_FUNC(); - + // We can size the buffer either by texture size (multiple of 2^n) or source size. // At higher sizes, increasing the texture size to 2^n is a waste of space. At these sizes kSizeBySourceSize should be used. - + _sourceSize.width = width; _sourceSize.height = height; _textureSize.width = scaleUpToPowerOfTwo(width); // can only scale up to 512 _textureSize.height = scaleUpToPowerOfTwo(height); - + if (textureOrSource == kSizeByTextureSize) { _width = _textureSize.width; _height = _textureSize.height; } else { // sizeBySourceSize _width = _sourceSize.width; _height = _sourceSize.height; - - // adjust allocated width to be divisible by 32. + + // adjust allocated width to be divisible by 32. // The GU can only handle multiples of 16 bytes. A 4 bit image x 32 will give us 16 bytes // We don't necessarily know the depth of the pixels here. So just make it divisible by 32. uint32 checkDiv = _width & 31; if (checkDiv) _width += 32 - checkDiv; } - + PSP_DEBUG_PRINT("width[%u], height[%u], texW[%u], texH[%u], sourceW[%d], sourceH[%d] %s\n", _width, _height, _textureSize.width, _textureSize.height, _sourceSize.width, _sourceSize.height, textureOrSource ? "size by source" : "size by texture"); } @@ -558,10 +558,10 @@ void GuRenderer::render() { // Loop over patches of 512x512 pixel textures and draw them for (uint32 j = 0; j < _buffer->getSourceHeight(); j += 512) { _textureLoadOffset.y = j; - + for (uint32 i = 0; i < _buffer->getSourceWidth(); i += 512) { _textureLoadOffset.x = i; - + guLoadTexture(); Vertex *vertices = guGetVertices(); fillVertices(vertices); @@ -573,8 +573,8 @@ void GuRenderer::render() { inline void GuRenderer::guProgramDrawBehavior() { DEBUG_ENTER_FUNC(); - PSP_DEBUG_PRINT("blending[%s] colorTest[%s] reverseAlpha[%s] keyColor[%u]\n", - _blending ? "on" : "off", _colorTest ? "on" : "off", + PSP_DEBUG_PRINT("blending[%s] colorTest[%s] reverseAlpha[%s] keyColor[%u]\n", + _blending ? "on" : "off", _colorTest ? "on" : "off", _alphaReverse ? "on" : "off", _keyColor); if (_blending) { @@ -591,7 +591,7 @@ inline void GuRenderer::guProgramDrawBehavior() { if (_colorTest) { sceGuEnable(GU_COLOR_TEST); sceGuColorFunc(GU_NOTEQUAL, // show only colors not equal to this color - _keyColor, + _keyColor, 0x00ffffff); // match everything but alpha } else sceGuDisable(GU_COLOR_TEST); @@ -663,10 +663,10 @@ inline void GuRenderer::guLoadTexture() { byte *startPoint = _buffer->getPixels(); if (_textureLoadOffset.x) startPoint += _buffer->_pixelFormat.pixelsToBytes(_textureLoadOffset.x); - if (_textureLoadOffset.y) + if (_textureLoadOffset.y) startPoint += _buffer->getWidthInBytes() * _textureLoadOffset.y; - - sceGuTexImage(0, + + sceGuTexImage(0, _buffer->getTextureWidth(), // texture width (must be power of 2) _buffer->getTextureHeight(), // texture height (must be power of 2) _buffer->getWidth(), // width of a line of the image (to get to the next line) @@ -698,7 +698,7 @@ void GuRenderer::fillVertices(Vertex *vertices) { // These coordinates describe an area within the texture. ie. we already loaded a square of texture, // now the coordinates within it are 0 to the edge of the area of the texture we want to draw float textureStartX = textureFix + _offsetInBuffer.x; - float textureStartY = textureFix + _offsetInBuffer.y; + float textureStartY = textureFix + _offsetInBuffer.y; int textureLeftX = _drawSize.width - _textureLoadOffset.x; if (textureLeftX > 512) @@ -720,7 +720,7 @@ void GuRenderer::fillVertices(Vertex *vertices) { float imageStartY = gapY + scaledOffsetOnScreenY + (scaleSourceToOutput(false, stretch(false, _textureLoadOffset.y))); float imageEndX, imageEndY; - + imageEndX = imageStartX + scaleSourceToOutput(true, stretch(true, textureLeftX)); imageEndY = imageStartY + scaleSourceToOutput(false, stretch(false, textureLeftY)); diff --git a/backends/platform/psp/display_client.h b/backends/platform/psp/display_client.h index f190658a26..e384bfb82b 100644 --- a/backends/platform/psp/display_client.h +++ b/backends/platform/psp/display_client.h @@ -171,12 +171,12 @@ protected: class GuRenderer { public: // Constructors - GuRenderer() : _useGlobalScaler(false), _buffer(0), _palette(0), - _blending(false), _alphaReverse(false), _colorTest(false), + GuRenderer() : _useGlobalScaler(false), _buffer(0), _palette(0), + _blending(false), _alphaReverse(false), _colorTest(false), _keyColor(0), _fullScreen(false), _stretch(false), _stretchX(1.0f), _stretchY(1.0f) {} - GuRenderer(Buffer *buffer, Palette *palette) : - _useGlobalScaler(false), _buffer(buffer), _palette(palette), - _blending(false), _alphaReverse(false), _colorTest(false), + GuRenderer(Buffer *buffer, Palette *palette) : + _useGlobalScaler(false), _buffer(buffer), _palette(palette), + _blending(false), _alphaReverse(false), _colorTest(false), _keyColor(0), _fullScreen(false), _stretch(false), _stretchX(1.0f), _stretchY(1.0f) {} static void setDisplayManager(DisplayManager *dm) { _displayManager = dm; } // Called by the Display Manager diff --git a/backends/platform/psp/display_manager.cpp b/backends/platform/psp/display_manager.cpp index 899b79727f..e945dca4a8 100644 --- a/backends/platform/psp/display_manager.cpp +++ b/backends/platform/psp/display_manager.cpp @@ -299,7 +299,7 @@ void DisplayManager::init() { #endif // Init overlay since we never change the size - _overlay->deallocate(); + _overlay->deallocate(); _overlay->setBytesPerPixel(sizeof(OverlayColor)); _overlay->setSize(PSP_SCREEN_WIDTH, PSP_SCREEN_HEIGHT); _overlay->allocate(); @@ -432,13 +432,13 @@ bool DisplayManager::renderAll() { _screen->render(); _screen->setClean(); // clean out dirty bit - + if (_imageViewer->isVisible()) _imageViewer->render(); _imageViewer->setClean(); if (_overlay->isVisible()) - _overlay->render(); + _overlay->render(); _overlay->setClean(); if (_cursor->isVisible()) @@ -448,7 +448,7 @@ bool DisplayManager::renderAll() { if (_keyboard->isVisible()) _keyboard->render(); _keyboard->setClean(); - + _masterGuRenderer.guPostRender(); return true; // rendered successfully diff --git a/backends/platform/psp/display_manager.h b/backends/platform/psp/display_manager.h index 5176bee3fe..38c43d60a3 100644 --- a/backends/platform/psp/display_manager.h +++ b/backends/platform/psp/display_manager.h @@ -72,7 +72,7 @@ private: */ class MasterGuRenderer : public PspThreadable { public: - MasterGuRenderer() : _lastRenderTime(0), _renderFinished(true), + MasterGuRenderer() : _lastRenderTime(0), _renderFinished(true), _renderSema(1, 1), _callbackId(-1) {} void guInit(); void guPreRender(); @@ -108,7 +108,7 @@ public: KEEP_ASPECT_RATIO, STRETCHED_FULL_SCREEN }; - DisplayManager() : _screen(0), _cursor(0), _overlay(0), _keyboard(0), + DisplayManager() : _screen(0), _cursor(0), _overlay(0), _keyboard(0), _imageViewer(0), _lastUpdateTime(0), _graphicsMode(0) {} ~DisplayManager(); @@ -127,7 +127,7 @@ public: void setOverlay(Overlay *overlay) { _overlay = overlay; } void setKeyboard(PSPKeyboard *keyboard) { _keyboard = keyboard; } void setImageViewer(ImageViewer *imageViewer) { _imageViewer = imageViewer; } - + void setSizeAndPixelFormat(uint width, uint height, const Graphics::PixelFormat *format); // Getters diff --git a/backends/platform/psp/dummy.cpp b/backends/platform/psp/dummy.cpp index 86ab30b3e2..748ac8cbf3 100644 --- a/backends/platform/psp/dummy.cpp +++ b/backends/platform/psp/dummy.cpp @@ -26,31 +26,31 @@ #include <stdio.h> #include <png.h> #include <sys/socket.h> - + //void userWriteFn(png_structp png_ptr, png_bytep data, png_size_t length) { //} //void userFlushFn(png_structp png_ptr) { //} - + // Dummy functions are pulled in so that we don't need to build the plugins with certain libs - + int dummyFunc() { // For Broken Sword 2.5 volatile int i; i = clock(); rename("dummyA", "dummyB"); - + png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); png_set_write_fn(png_ptr, NULL, NULL, NULL); png_infop info_ptr; png_write_png(png_ptr, info_ptr, PNG_TRANSFORM_IDENTITY, NULL); png_destroy_write_struct(&png_ptr, &info_ptr); - + // For lua's usage of libc: very heavy usage so it pulls in sockets? setsockopt(0, 0, 0, NULL, 0); getsockopt(0, 0, 0, NULL, NULL); - + return i; }
\ No newline at end of file diff --git a/backends/platform/psp/image_viewer.cpp b/backends/platform/psp/image_viewer.cpp index 97d582b63a..1ed7698bc8 100644 --- a/backends/platform/psp/image_viewer.cpp +++ b/backends/platform/psp/image_viewer.cpp @@ -34,45 +34,45 @@ #include "backends/platform/psp/input.h" #include "backends/platform/psp/display_manager.h" #include "backends/platform/psp/display_client.h" -#include "backends/platform/psp/image_viewer.h" -#include "backends/platform/psp/png_loader.h" +#include "backends/platform/psp/image_viewer.h" +#include "backends/platform/psp/png_loader.h" #include "backends/platform/psp/thread.h" static const char *imageName = "psp_image"; #define PSP_SCREEN_HEIGHT 272 #define PSP_SCREEN_WIDTH 480 - + bool ImageViewer::load(int imageNum) { if (_init) unload(); - + // build string char number[8]; sprintf(number, "%d", imageNum); - Common::String imageNameStr(imageName); + Common::String imageNameStr(imageName); Common::String specificImageName = imageNameStr + Common::String(number) + Common::String(".png"); - + // search for image file if (!SearchMan.hasFile(specificImageName)) { PSP_ERROR("file %s not found\n", specificImageName.c_str()); return false; } - + Common::ScopedPtr<Common::SeekableReadStream> file(SearchMan.createReadStreamForMember(specificImageName)); - + _buffer = new Buffer(); _palette = new Palette(); _renderer = new GuRenderer(); - + assert(_buffer); assert(_palette); assert(_renderer); - + // Load a PNG into our buffer and palette. Size it by the actual size of the image PngLoader image(file, *_buffer, *_palette, Buffer::kSizeBySourceSize); - + PngLoader::Status status = image.allocate(); // allocate the buffers for the file - + char error[100]; if (status == PngLoader::BAD_FILE) { sprintf(error, "Cannot display %s. Not a proper PNG file", specificImageName.c_str()); @@ -89,29 +89,29 @@ bool ImageViewer::load(int imageNum) { if (!image.load()) { sprintf(error, "Cannot display %s. Not a proper PNG file", specificImageName.c_str()); GUI::TimedMessageDialog dialog(error, 4000); - dialog.runModal(); + dialog.runModal(); return false; } - + setConstantRendererOptions(); setFullScreenImageParams(); // prepare renderer for full screen view - + _imageNum = imageNum; // now we can say we displayed this image _init = true; - + return true; } void ImageViewer::setConstantRendererOptions() { _renderer->setBuffer(_buffer); _renderer->setPalette(_palette); - + _renderer->setAlphaBlending(false); _renderer->setColorTest(false); _renderer->setUseGlobalScaler(false); _renderer->setStretch(true); _renderer->setOffsetInBuffer(0, 0); - _renderer->setDrawWholeBuffer(); + _renderer->setDrawWholeBuffer(); } void ImageViewer::unload() { @@ -130,32 +130,32 @@ void ImageViewer::resetOnEngineDone() { void ImageViewer::setVisible(bool visible) { DEBUG_ENTER_FUNC(); - + if (_visible == visible) return; - + // from here on, we're making the loader visible if (visible && g_engine) { // we can only run the image viewer when there's an engine g_engine->pauseEngine(true); - + load(_imageNum ? _imageNum : 1); // load the 1st image or the current } if (visible && _init) { // we managed to load _visible = true; setViewerButtons(true); - + { // so dialog goes out of scope, destroying all allocations GUI::TimedMessageDialog dialog("Image Viewer", 1000); dialog.runModal(); } - + runLoop(); // only listen to viewer events } else { // we were asked to make invisible or failed to load _visible = false; unload(); setViewerButtons(false); - + if (g_engine && g_engine->isPaused()) g_engine->pauseEngine(false); } @@ -175,7 +175,7 @@ void ImageViewer::runLoop() { void ImageViewer::setViewerButtons(bool active) { _inputHandler->setImageViewerMode(active); -} +} void ImageViewer::loadNextImage() { if (!load(_imageNum+1)) { // try to load the next image @@ -190,21 +190,21 @@ void ImageViewer::loadLastImage() { if (!load(_imageNum-1)) if (!load(_imageNum)) setVisible(false); // we can't even show the old image so hide - } + } setDirty(); } void ImageViewer::setFullScreenImageParams() { // we try to fit the image fullscreen at least in one dimension uint32 width = _buffer->getSourceWidth(); - uint32 height = _buffer->getSourceHeight(); + uint32 height = _buffer->getSourceHeight(); _centerX = PSP_SCREEN_WIDTH / 2.0f; _centerY = PSP_SCREEN_HEIGHT / 2.0f; - + // see if we fit width wise if (PSP_SCREEN_HEIGHT >= (int)((height * PSP_SCREEN_WIDTH) / (float)width)) { - setZoom(PSP_SCREEN_WIDTH / (float)width); + setZoom(PSP_SCREEN_WIDTH / (float)width); } else { setZoom(PSP_SCREEN_HEIGHT / (float)height); } @@ -233,32 +233,32 @@ void ImageViewer::render() { break; } _renderer->render(); - } + } } void ImageViewer::modifyZoom(bool up) { float factor = _zoomFactor; - if (up) + if (up) factor += 0.1f; else // down factor -= 0.1f; - - setZoom(factor); + + setZoom(factor); } -void ImageViewer::setZoom(float value) { +void ImageViewer::setZoom(float value) { if (value <= 0.0f) // don't want 0 or negative zoom return; _zoomFactor = value; - _renderer->setStretchXY(value, value); + _renderer->setStretchXY(value, value); setOffsetParams(); } void ImageViewer::moveImageX(float val) { float newVal = _centerX + val; - - if (newVal - (_visibleWidth / 2) > PSP_SCREEN_WIDTH - 4 || newVal + (_visibleWidth / 2) < 4) + + if (newVal - (_visibleWidth / 2) > PSP_SCREEN_WIDTH - 4 || newVal + (_visibleWidth / 2) < 4) return; _centerX = newVal; setOffsetParams(); @@ -266,22 +266,22 @@ void ImageViewer::moveImageX(float val) { void ImageViewer::moveImageY(float val) { float newVal = _centerY + val; - - if (newVal - (_visibleHeight / 2) > PSP_SCREEN_HEIGHT - 4 || newVal + (_visibleHeight / 2) < 4) + + if (newVal - (_visibleHeight / 2) > PSP_SCREEN_HEIGHT - 4 || newVal + (_visibleHeight / 2) < 4) return; _centerY = newVal; setOffsetParams(); } -// Set the renderer with the proper offset on the screen +// Set the renderer with the proper offset on the screen // void ImageViewer::setOffsetParams() { _visibleWidth = _zoomFactor * _buffer->getSourceWidth(); - _visibleHeight = _zoomFactor * _buffer->getSourceHeight(); - + _visibleHeight = _zoomFactor * _buffer->getSourceHeight(); + int offsetX = _centerX - (int)(_visibleWidth * 0.5f); int offsetY = _centerY - (int)(_visibleHeight * 0.5f); - + _renderer->setOffsetOnScreen(offsetX, offsetY); setDirty(); } @@ -290,8 +290,8 @@ void ImageViewer::setOffsetParams() { // void ImageViewer::handleEvent(uint32 event) { DEBUG_ENTER_FUNC(); - - switch (event) { + + switch (event) { case EVENT_HIDE: setVisible(false); break; diff --git a/backends/platform/psp/image_viewer.h b/backends/platform/psp/image_viewer.h index 4c3eaf7b4a..ad188536a3 100644 --- a/backends/platform/psp/image_viewer.h +++ b/backends/platform/psp/image_viewer.h @@ -54,10 +54,10 @@ private: float _visibleHeight, _visibleWidth; float _centerX, _centerY; Event _movement; - + InputHandler *_inputHandler; DisplayManager *_displayManager; - + void setFullScreenImageParams(); void loadNextImage(); void loadLastImage(); @@ -66,19 +66,19 @@ private: void moveImageX(float val); void moveImageY(float val); bool load(int imageNum); - void unload(); + void unload(); void runLoop(); // to get total pausing we have to do our own loop - + void setZoom(float value); void setOffsetParams(); void modifyZoom(bool up); // up or down void setVisible(bool visible); - + public: - ImageViewer() : _buffer(0), _palette(0), _visible(false), - _dirty(false), _init(false), _imageNum(0), - _zoomFactor(0.0f), _visibleHeight(0.0f), _visibleWidth(0.0f), + ImageViewer() : _buffer(0), _palette(0), _visible(false), + _dirty(false), _init(false), _imageNum(0), + _zoomFactor(0.0f), _visibleHeight(0.0f), _visibleWidth(0.0f), _centerX(0.0f), _centerY(0.0f), _movement(EVENT_MOVE_STOP), _inputHandler(0), _displayManager(0) {} ~ImageViewer() { unload(); } // deallocate images @@ -88,15 +88,15 @@ public: bool isDirty() { return _dirty; } void setDirty() { _dirty = true; } void setClean() { if (!_visible) // otherwise we want to keep rendering - _dirty = false; - } + _dirty = false; + } void resetOnEngineDone(); - + void handleEvent(uint32 event); - + // pointer setters - void setInputHandler(InputHandler *inputHandler) { _inputHandler = inputHandler; } + void setInputHandler(InputHandler *inputHandler) { _inputHandler = inputHandler; } void setDisplayManager(DisplayManager *displayManager) { _displayManager = displayManager; } }; -#endif /* PSP_IMAGE_VIEWER_H */
\ No newline at end of file +#endif /* PSP_IMAGE_VIEWER_H */
\ No newline at end of file diff --git a/backends/platform/psp/input.cpp b/backends/platform/psp/input.cpp index 17f8954e3b..a9ad441b4d 100644 --- a/backends/platform/psp/input.cpp +++ b/backends/platform/psp/input.cpp @@ -198,7 +198,7 @@ bool ButtonPad::getEvent(Common::Event &event, PspEvent &pspEvent, SceCtrlData & uint32 curButtonState = PSP_ALL_BUTTONS & pad.Buttons; // we only care about these if (_combosEnabled) - modifyButtonsForCombos(pad); // change buttons for combos + modifyButtonsForCombos(pad); // change buttons for combos return getEventFromButtonState(event, pspEvent, curButtonState); } @@ -460,7 +460,7 @@ bool InputHandler::handlePspEvent(Common::Event &event, PspEvent &pspEvent) { /*case PSP_EVENT_CHANGE_SPEED: handleSpeedChange(pspEvent.data); break;*/ - case PSP_EVENT_IMAGE_VIEWER: + case PSP_EVENT_IMAGE_VIEWER: _imageViewer->handleEvent(pspEvent.data); break; case PSP_EVENT_IMAGE_VIEWER_SET_BUTTONS: @@ -530,7 +530,7 @@ void InputHandler::setImageViewerMode(bool active) { _nub.init(); _buttonPad.enableCombos(true); // re-enable combos _buttonPad.initButtons(); - } + } } void InputHandler::setButtonsForImageViewer() { @@ -538,32 +538,32 @@ void InputHandler::setButtonsForImageViewer() { // Dpad _buttonPad.clearButtons(); - _buttonPad.getButton(ButtonPad::BTN_UP, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_ZOOM_IN, + _buttonPad.getButton(ButtonPad::BTN_UP, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_ZOOM_IN, + PSP_EVENT_NONE, false); + _buttonPad.getButton(ButtonPad::BTN_DOWN, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_ZOOM_OUT, PSP_EVENT_NONE, false); - _buttonPad.getButton(ButtonPad::BTN_DOWN, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_ZOOM_OUT, + _buttonPad.getButton(ButtonPad::BTN_LEFT, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_LAST_IMAGE, PSP_EVENT_NONE, false); - _buttonPad.getButton(ButtonPad::BTN_LEFT, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_LAST_IMAGE, + _buttonPad.getButton(ButtonPad::BTN_RIGHT, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_NEXT_IMAGE, PSP_EVENT_NONE, false); - _buttonPad.getButton(ButtonPad::BTN_RIGHT, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_NEXT_IMAGE, - PSP_EVENT_NONE, false); - _buttonPad.getButton(ButtonPad::BTN_LTRIGGER, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_HIDE, + _buttonPad.getButton(ButtonPad::BTN_LTRIGGER, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_HIDE, PSP_EVENT_NONE, false); - _buttonPad.getButton(ButtonPad::BTN_RTRIGGER, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_HIDE, + _buttonPad.getButton(ButtonPad::BTN_RTRIGGER, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_HIDE, PSP_EVENT_NONE, false); - _buttonPad.getButton(ButtonPad::BTN_START, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_HIDE, + _buttonPad.getButton(ButtonPad::BTN_START, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_HIDE, PSP_EVENT_NONE, false); - _buttonPad.getButton(ButtonPad::BTN_SELECT, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_HIDE, + _buttonPad.getButton(ButtonPad::BTN_SELECT, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_HIDE, PSP_EVENT_NONE, false); //Nub _nub.getPad().clearButtons(); - _nub.getPad().getButton(ButtonPad::BTN_UP, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_MOVE_UP, + _nub.getPad().getButton(ButtonPad::BTN_UP, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_MOVE_UP, PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_MOVE_STOP); - _nub.getPad().getButton(ButtonPad::BTN_DOWN, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_MOVE_DOWN, + _nub.getPad().getButton(ButtonPad::BTN_DOWN, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_MOVE_DOWN, PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_MOVE_STOP); - _nub.getPad().getButton(ButtonPad::BTN_LEFT, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_MOVE_LEFT, + _nub.getPad().getButton(ButtonPad::BTN_LEFT, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_MOVE_LEFT, PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_MOVE_STOP); - _nub.getPad().getButton(ButtonPad::BTN_RIGHT, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_MOVE_RIGHT, + _nub.getPad().getButton(ButtonPad::BTN_RIGHT, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_MOVE_RIGHT, PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_MOVE_STOP); } diff --git a/backends/platform/psp/input.h b/backends/platform/psp/input.h index 8315a3766c..ef2e1b84a4 100644 --- a/backends/platform/psp/input.h +++ b/backends/platform/psp/input.h @@ -122,16 +122,16 @@ public: ButtonPad(); void initButtons(); // set the buttons to the mode that's selected void clearButtons(); // empty the buttons of all events - + bool getEvent(Common::Event &event, PspEvent &pspEvent, SceCtrlData &pad); bool getEventFromButtonState(Common::Event &event, PspEvent &pspEvent, uint32 buttonState); - + void setShifted(ShiftMode shifted) { _shifted = shifted; } void setPadMode(PspPadMode mode) { _padMode = mode; } bool isButtonDown() { return _prevButtonState; } - + void enableCombos(bool value) { _combosEnabled = value; } - Button &getButton(ButtonType type, ShiftMode mode) { return _button[type][mode]; } + Button &getButton(ButtonType type, ShiftMode mode) { return _button[type][mode]; } }; class Nub { @@ -140,17 +140,17 @@ private: ShiftMode _shifted; bool _dpadMode; - + ButtonPad _buttonPad; // private buttonpad for dpad mode - + int32 modifyNubAxisMotion(int32 input); void translateToDpadState(int dpadX, int dpadY, uint32 &buttonState); // convert nub data to dpad data public: Nub() : _shifted(UNSHIFTED), _dpadMode(false) { } - void init() { _buttonPad.initButtons(); } + void init() { _buttonPad.initButtons(); } void setCursor(Cursor *cursor) { _cursor = cursor; } - + // setters void setDpadMode(bool active) { _dpadMode = active; } void setShifted(ShiftMode shifted) { _shifted = shifted; } @@ -163,7 +163,7 @@ public: class InputHandler { public: - InputHandler() : _keyboard(0), _cursor(0), _imageViewer(0), _padMode(PAD_MODE_NORMAL), + InputHandler() : _keyboard(0), _cursor(0), _imageViewer(0), _padMode(PAD_MODE_NORMAL), _lastPadCheckTime(0) {} // pointer setters void setKeyboard(PSPKeyboard *keyboard) { _keyboard = keyboard; } @@ -175,7 +175,7 @@ public: void setImageViewerMode(bool active); private: - Nub _nub; + Nub _nub; ButtonPad _buttonPad; // Pointers to relevant other classes diff --git a/backends/platform/psp/osys_psp.cpp b/backends/platform/psp/osys_psp.cpp index 8c8180d04e..5fa5110684 100644 --- a/backends/platform/psp/osys_psp.cpp +++ b/backends/platform/psp/osys_psp.cpp @@ -83,7 +83,7 @@ void OSystem_PSP::initBackend() { _inputHandler.setKeyboard(&_keyboard); _inputHandler.setImageViewer(&_imageViewer); _inputHandler.init(); - + // Set pointers for image viewer _imageViewer.setInputHandler(&_inputHandler); _imageViewer.setDisplayManager(&_displayManager); diff --git a/backends/platform/psp/png_loader.cpp b/backends/platform/psp/png_loader.cpp index 2f4857569e..16377539c8 100644 --- a/backends/platform/psp/png_loader.cpp +++ b/backends/platform/psp/png_loader.cpp @@ -36,7 +36,7 @@ PngLoader::Status PngLoader::allocate() { DEBUG_ENTER_FUNC(); - + if (!findImageDimensions()) { PSP_ERROR("failed to get image dimensions\n"); return BAD_FILE; @@ -45,7 +45,7 @@ PngLoader::Status PngLoader::allocate() { _buffer->setSize(_width, _height, _sizeBy); uint32 bitsPerPixel = _bitDepth * _channels; - + if (_paletteSize) { // 8 or 4-bit image if (bitsPerPixel == 4) { _buffer->setPixelFormat(PSPPixelFormat::Type_Palette_4bit); @@ -130,7 +130,7 @@ bool PngLoader::basicImageLoad() { png_get_IHDR(_pngPtr, _infoPtr, (png_uint_32 *)&_width, (png_uint_32 *)&_height, &_bitDepth, &_colorType, &interlaceType, int_p_NULL, int_p_NULL); _channels = png_get_channels(_pngPtr, _infoPtr); - + if (_colorType & PNG_COLOR_MASK_PALETTE) _paletteSize = _infoPtr->num_palette; @@ -141,7 +141,7 @@ bool PngLoader::basicImageLoad() { bool PngLoader::findImageDimensions() { DEBUG_ENTER_FUNC(); - bool status = basicImageLoad(); + bool status = basicImageLoad(); PSP_DEBUG_PRINT("width[%d], height[%d], paletteSize[%d], bitDepth[%d], channels[%d], rowBytes[%d]\n", _width, _height, _paletteSize, _bitDepth, _channels, _infoPtr->rowbytes); png_destroy_read_struct(&_pngPtr, &_infoPtr, png_infopp_NULL); @@ -157,7 +157,7 @@ bool PngLoader::loadImageIntoBuffer() { if (!basicImageLoad()) { png_destroy_read_struct(&_pngPtr, &_infoPtr, png_infopp_NULL); return false; - } + } png_set_strip_16(_pngPtr); // Strip off 16 bit channels in case they occur if (_paletteSize) { @@ -178,16 +178,16 @@ bool PngLoader::loadImageIntoBuffer() { } uint32 rowBytes = png_get_rowbytes(_pngPtr, _infoPtr); - - // there seems to be a bug in libpng where it doesn't increase the rowbytes or the + + // there seems to be a bug in libpng where it doesn't increase the rowbytes or the // channel even after we add the alpha channel if (_channels == 3 && (rowBytes / _width) == 3) { _channels = 4; - rowBytes = _width * _channels; - } - + rowBytes = _width * _channels; + } + PSP_DEBUG_PRINT("rowBytes[%d], channels[%d]\n", rowBytes, _channels); - + unsigned char *line = (unsigned char*) malloc(rowBytes); if (!line) { png_destroy_read_struct(&_pngPtr, png_infopp_NULL, png_infopp_NULL); diff --git a/backends/platform/psp/png_loader.h b/backends/platform/psp/png_loader.h index 616a79405e..0ff9d8a65d 100644 --- a/backends/platform/psp/png_loader.h +++ b/backends/platform/psp/png_loader.h @@ -61,7 +61,7 @@ public: Buffer::HowToSize sizeBy = Buffer::kSizeByTextureSize) : _file(file), _buffer(&buffer), _palette(&palette), _width(0), _height(0), _paletteSize(0), - _bitDepth(0), _sizeBy(sizeBy), _pngPtr(0), + _bitDepth(0), _sizeBy(sizeBy), _pngPtr(0), _infoPtr(0), _colorType(0), _channels(0) {} PngLoader::Status allocate(); diff --git a/backends/platform/psp/trace.cpp b/backends/platform/psp/trace.cpp index 373e00415b..b799b4e870 100644 --- a/backends/platform/psp/trace.cpp +++ b/backends/platform/psp/trace.cpp @@ -75,38 +75,38 @@ void PspDebugTrace(bool alsoToScreen, const char *format, ...) { #define GET_RET(retAddr) \ asm volatile ("move %0,$ra\n\t" \ : "=&r" (retAddr) : ) - + #define GET_SP(stackPtr) \ asm volatile ("move %0,$sp\n\t" \ : "=&r" (stackPtr) : ) // Function to retrieve a backtrace for the MIPS processor -// This is not trivial since the MIPS doesn't use a frame pointer. +// This is not trivial since the MIPS doesn't use a frame pointer. // Takes the number of levels wanted above the calling function (included) and an array of void * -// +// void mipsBacktrace(uint32 levels, void **addresses) { - // get the current return address + // get the current return address register byte *retAddr; register byte *stackPointer; - GET_RET(retAddr); + GET_RET(retAddr); GET_SP(stackPointer); char string[100]; - + if (!levels) return; - + memset(addresses, 0, sizeof(void *) * levels); - + uint32 curLevel = 0; - + const uint32 SP_SUBTRACT = 0x27bd8000; // The instruction to subtract from the SP looks like this const uint32 SP_SUB_HIGH_MASK = 0xffff8000; // The mask to check for the subtract SP instruction const uint32 SP_SUB_LOW_MASK = 0x0000ffff; // The mask that gives us how much was subtracted - + // make sure we go out of the stack of this current level // we already have the return address for this level from the register if (curLevel < levels) { - void *thisFunc = (void *)mipsBacktrace; + void *thisFunc = (void *)mipsBacktrace; for (uint32 *seekPtr = (uint32 *)thisFunc; ; seekPtr++) { if ((*seekPtr & SP_SUB_HIGH_MASK) == SP_SUBTRACT) { // we found the $sp subtraction at the beginning of the function @@ -120,10 +120,10 @@ void mipsBacktrace(uint32 levels, void **addresses) { fputs(string, stderr); } break; - } - } + } + } } - + // keep scanning while more levels are requested while (curLevel < levels) { // now scan backwards from the return address to find the size of the stack @@ -139,13 +139,13 @@ void mipsBacktrace(uint32 levels, void **addresses) { sprintf(string, "invalid retAddr %p\n", retAddr); fputs(string, stderr); return; - } + } //sprintf(string, "retAddr[%p]\n", retAddr); //fputs(string, stderr); addresses[curLevel++] = retAddr; break; - } - } + } + } } -} +} diff --git a/backends/platform/sdl/macosx/macosx.cpp b/backends/platform/sdl/macosx/macosx.cpp index 9b11eb2c09..817f61e864 100644 --- a/backends/platform/sdl/macosx/macosx.cpp +++ b/backends/platform/sdl/macosx/macosx.cpp @@ -74,7 +74,7 @@ void OSystem_MacOSX::addSysArchivesToSearchSet(Common::SearchSet &s, int priorit } void OSystem_MacOSX::setupIcon() { - // Don't set icon on OS X, as we use a nicer external icon there. + // Don't set icon on OS X, as we use a nicer external icon there. } bool OSystem_MacOSX::hasFeature(Feature f) { diff --git a/backends/platform/sdl/sdl-sys.h b/backends/platform/sdl/sdl-sys.h index 77515ff4e5..63bfc58617 100644 --- a/backends/platform/sdl/sdl-sys.h +++ b/backends/platform/sdl/sdl-sys.h @@ -47,7 +47,7 @@ typedef struct { int FAKE; } FAKE_FILE; // Finally forbid FILE again (if it was forbidden to start with) #if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_FILE) -#undef FILE +#undef FILE #define FILE FORBIDDEN_SYMBOL_REPLACEMENT #endif diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp index 4cca5792cb..ecaeabf4e1 100644 --- a/backends/platform/sdl/sdl.cpp +++ b/backends/platform/sdl/sdl.cpp @@ -376,7 +376,7 @@ void OSystem_SDL::setupIcon() { if (sscanf(scummvm_icon[0], "%d %d %d %d", &w, &h, &ncols, &nbytes) != 4) { warning("Wrong format of scummvm_icon[0] (%s)", scummvm_icon[0]); - + return; } if ((w > 512) || (h > 512) || (ncols > 255) || (nbytes > 1)) { diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h index 9c08752054..707ad8bc55 100644 --- a/backends/platform/sdl/sdl.h +++ b/backends/platform/sdl/sdl.h @@ -30,7 +30,7 @@ #include "backends/events/sdl/sdl-events.h" #include "backends/log/log.h" -/** +/** * Base OSystem class for all SDL ports. */ class OSystem_SDL : public ModularBackend { @@ -38,7 +38,7 @@ public: OSystem_SDL(); virtual ~OSystem_SDL(); - /** + /** * Pre-initialize backend. It should be called after * instantiating the backend. Early needed managers are * created here. diff --git a/backends/platform/symbian/src/SymbianOS.cpp b/backends/platform/symbian/src/SymbianOS.cpp index 9cccc81d19..b1bd976f9e 100644 --- a/backends/platform/symbian/src/SymbianOS.cpp +++ b/backends/platform/symbian/src/SymbianOS.cpp @@ -57,7 +57,7 @@ char *GetExecutablePath() { OSystem_SDL_Symbian::OSystem_SDL_Symbian() : _RFs(0) { - + } void OSystem_SDL_Symbian::init() { @@ -171,7 +171,7 @@ Common::String OSystem_SDL_Symbian::getDefaultConfigFileName() { } void OSystem_SDL_Symbian::setupIcon() { - // Don't for Symbian: it uses the EScummVM.aif file for the icon. + // Don't for Symbian: it uses the EScummVM.aif file for the icon. } RFs& OSystem_SDL_Symbian::FsSession() { diff --git a/backends/platform/wince/wince-sdl.cpp b/backends/platform/wince/wince-sdl.cpp index 54fa71cfd2..9b1ffe817c 100644 --- a/backends/platform/wince/wince-sdl.cpp +++ b/backends/platform/wince/wince-sdl.cpp @@ -621,7 +621,7 @@ Common::String OSystem_WINCE3::getSystemLanguage() const { GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVCTRYNAME, ctryNameW, sizeof(ctryNameW)) != 0) { WideCharToMultiByte(CP_ACP, 0, langNameW, -1, langName, (wcslen(langNameW) + 1), NULL, NULL); WideCharToMultiByte(CP_ACP, 0, ctryNameW, -1, ctryName, (wcslen(ctryNameW) + 1), NULL, NULL); - + debug(1, "Trying to find posix locale name for %s_%s", langName, ctryName); while (posixMappingTable[i][0] && !localeFound) { if ( (!strcmp(posixMappingTable[i][0], langName) || !strcmp(posixMappingTable[i][0], "*")) && diff --git a/backends/plugins/elf/elf-loader.cpp b/backends/plugins/elf/elf-loader.cpp index b25bcf835b..4335ea6108 100644 --- a/backends/plugins/elf/elf-loader.cpp +++ b/backends/plugins/elf/elf-loader.cpp @@ -169,7 +169,7 @@ bool DLObject::loadSegment(Elf32_Phdr *phdr) { warning("elfloader: Out of memory."); return false; } - + debug(2, "elfloader: Allocated segment @ %p", _segment); // Get offset to load segment into @@ -222,7 +222,7 @@ Elf32_Shdr * DLObject::loadSectionHeaders(Elf32_Ehdr *ehdr) { int DLObject::findSymbolTableSection(Elf32_Ehdr *ehdr, Elf32_Shdr *shdr) { int SymbolTableSection = -1; - + // Loop over sections, looking for symbol table linked to a string table for (uint32 i = 0; i < ehdr->e_shnum; i++) { if (shdr[i].sh_type == SHT_SYMTAB && @@ -233,7 +233,7 @@ int DLObject::findSymbolTableSection(Elf32_Ehdr *ehdr, Elf32_Shdr *shdr) { break; } } - + return SymbolTableSection; } @@ -315,12 +315,12 @@ void DLObject::relocateSymbols(ptrdiff_t offset) { } // Track the size of the plugin through memory manager without loading -// the plugin into memory. +// the plugin into memory. // void DLObject::trackSize(const char *path) { - + _file = Common::FSNode(path).createReadStream(); - + if (!_file) { warning("elfloader: File %s not found.", path); return; @@ -334,11 +334,11 @@ void DLObject::trackSize(const char *path) { _file = 0; return; } - + ELFMemMan.trackPlugin(true); // begin tracking the plugin size - + // Load the segments - for (uint32 i = 0; i < ehdr.e_phnum; i++) { + for (uint32 i = 0; i < ehdr.e_phnum; i++) { debug(2, "elfloader: Loading segment %d", i); if (!readProgramHeaders(&ehdr, &phdr, i)) { @@ -351,7 +351,7 @@ void DLObject::trackSize(const char *path) { ELFMemMan.trackAlloc(phdr.p_align, phdr.p_memsz); } } - + ELFMemMan.trackPlugin(false); // we're done tracking the plugin size delete _file; @@ -367,7 +367,7 @@ bool DLObject::load() { return false; //Load the segments - for (uint32 i = 0; i < ehdr.e_phnum; i++) { + for (uint32 i = 0; i < ehdr.e_phnum; i++) { debug(2, "elfloader: Loading segment %d", i); if (readProgramHeaders(&ehdr, &phdr, i) == false) @@ -386,12 +386,12 @@ bool DLObject::load() { free(shdr); return false; } - + if (!loadStringTable(shdr)) { free(shdr); return false; } - + // Offset by our segment allocated address // must use _segmentVMA here for multiple segments (MIPS) _segmentOffset = ptrdiff_t(_segment) - _segmentVMA; diff --git a/backends/plugins/elf/elf-provider.cpp b/backends/plugins/elf/elf-provider.cpp index 480f7068c4..84054f44cb 100644 --- a/backends/plugins/elf/elf-provider.cpp +++ b/backends/plugins/elf/elf-provider.cpp @@ -100,7 +100,7 @@ DynamicPlugin::VoidFunc ELFPlugin::findSymbol(const char *symbol) { void ELFPlugin::trackSize() { // All we need to do is create our object, track its size, then delete it DLObject *obj = makeDLObject(); - + obj->trackSize(_filename.c_str()); delete obj; } @@ -180,7 +180,7 @@ void ELFPlugin::unloadPlugin() { PluginList ELFPluginProvider::getPlugins() { PluginList pl = FilePluginProvider::getPlugins(); -#if defined(UNCACHED_PLUGINS) && !defined(ELF_NO_MEM_MANAGER) +#if defined(UNCACHED_PLUGINS) && !defined(ELF_NO_MEM_MANAGER) // This static downcast is safe because all of the plugins must // be ELF plugins for (PluginList::iterator p = pl.begin(); p != pl.end(); ++p) { @@ -190,8 +190,8 @@ PluginList ELFPluginProvider::getPlugins() { // The Memory Manager should now allocate space based on the information // it collected ELFMemMan.allocateHeap(); -#endif - +#endif + return pl; } diff --git a/backends/plugins/elf/memory-manager.cpp b/backends/plugins/elf/memory-manager.cpp index 39f5e9071d..02669b3647 100644 --- a/backends/plugins/elf/memory-manager.cpp +++ b/backends/plugins/elf/memory-manager.cpp @@ -20,7 +20,7 @@ * */ -#include "common/scummsys.h" +#include "common/scummsys.h" #if defined(DYNAMIC_MODULES) && defined(USE_ELF_LOADER) @@ -28,12 +28,12 @@ #include "common/debug.h" #include "common/util.h" #include <malloc.h> - -DECLARE_SINGLETON(ELFMemoryManager); -ELFMemoryManager::ELFMemoryManager() : - _heap(0), _heapSize(0), _heapAlign(0), - _trackAllocs(false), _measuredSize(0), _measuredAlign(0), +DECLARE_SINGLETON(ELFMemoryManager); + +ELFMemoryManager::ELFMemoryManager() : + _heap(0), _heapSize(0), _heapAlign(0), + _trackAllocs(false), _measuredSize(0), _measuredAlign(0), _bytesAllocated(0) {} ELFMemoryManager::~ELFMemoryManager() { @@ -46,23 +46,23 @@ void ELFMemoryManager::trackPlugin(bool value) { if (value == _trackAllocs) return; - + _trackAllocs = value; - + if (_trackAllocs) { // start measuring // start tracking allocations _measuredAlign = 0; - + } else { // we're done measuring // get the total allocated size uint32 measuredSize = _allocList.back().end() - _allocList.front().start; _heapSize = MAX(_heapSize, measuredSize); _heapAlign = MAX(_heapAlign, _measuredAlign); - + _allocList.clear(); _bytesAllocated = 0; // reset - + debug(2, "measured a plugin of size %d. Max size %d. Max align %d", measuredSize, _heapSize, _heapAlign); } } @@ -70,7 +70,7 @@ void ELFMemoryManager::trackPlugin(bool value) { void ELFMemoryManager::trackAlloc(uint32 align, uint32 size) { if (!_measuredAlign) _measuredAlign = align; - + // use the allocate function to simulate allocation allocateOnHeap(align, size); } @@ -79,20 +79,20 @@ void ELFMemoryManager::allocateHeap() { // The memory manager should only allocate once assert (!_heap); assert (_heapSize); - + // clear the list _allocList.clear(); _bytesAllocated = 0; - + debug(2, "ELFMemoryManager: allocating %d bytes aligned at %d as the \ plugin heap", _heapSize, _heapAlign); - + // prepare the heap - if (_heapAlign) + if (_heapAlign) _heap = ::memalign(_heapAlign, _heapSize); else _heap = ::malloc(_heapSize); - + assert(_heap); } @@ -106,7 +106,7 @@ void *ELFMemoryManager::pluginAllocate(uint32 size) { void *ELFMemoryManager::pluginAllocate(uint32 align, uint32 size) { if (_heap) { return allocateOnHeap(align, size); - } + } return ::memalign(align, size); } @@ -120,16 +120,16 @@ void ELFMemoryManager::pluginDeallocate(void *ptr) { // Allocate space for the request in our heap void *ELFMemoryManager::allocateOnHeap(uint32 align, uint32 size) { byte *lastAddress = (byte *)_heap; - + // We can't allow allocations smaller than sizeof(Allocation). This could - // only be from non-plugin allocations and would cause infinite recursion + // only be from non-plugin allocations and would cause infinite recursion // when allocating our Allocation in the list. if (size <= sizeof(Allocation)) return 0; - + Common::List<Allocation>::iterator i; for (i = _allocList.begin(); i != _allocList.end(); i++) { - if (i->start - lastAddress > (int)size) + if (i->start - lastAddress > (int)size) break; lastAddress = i->end(); // align to desired alignment @@ -137,20 +137,20 @@ void *ELFMemoryManager::allocateOnHeap(uint32 align, uint32 size) { lastAddress = (byte *)( ((uint32)lastAddress + align - 1) & ~(align - 1) ); } } - + // Check if we exceeded our heap limit // We skip this case if we're only tracking allocations if (!_trackAllocs && ((uint32)lastAddress + size > (uint32)_heap + _heapSize)) { debug(2, "failed to find space to allocate %d bytes", size); return 0; } - + _allocList.insert(i, Allocation(lastAddress, size)); _bytesAllocated += size; - - debug(7, "ELFMemoryManager: allocated %d bytes at %p. Total %d bytes", + + debug(7, "ELFMemoryManager: allocated %d bytes at %p. Total %d bytes", size, lastAddress, _bytesAllocated); - + return lastAddress; } @@ -159,14 +159,14 @@ void ELFMemoryManager::deallocateFromHeap(void *ptr) { for (i = _allocList.begin(); i != _allocList.end(); i++) { if (i->start == ptr) { _bytesAllocated -= (*i).size; - - debug(7, "ELFMemoryManager: freed %d bytes at %p. Total %d bytes", + + debug(7, "ELFMemoryManager: freed %d bytes at %p. Total %d bytes", (*i).size, (*i).start, _bytesAllocated); - + _allocList.erase(i); break; } - } + } } #endif /* defined(DYNAMIC_MODULES) && defined(USE_ELF_LOADER) */ diff --git a/backends/plugins/elf/memory-manager.h b/backends/plugins/elf/memory-manager.h index ac70e5e3bb..032ecb2be5 100644 --- a/backends/plugins/elf/memory-manager.h +++ b/backends/plugins/elf/memory-manager.h @@ -30,17 +30,17 @@ #include "common/singleton.h" #include "common/list.h" #include "common/mutex.h" - + /** - * A 'foolproof' way to prevent memory fragmentation. This class is used to - * serve as a permanent allocation to prevent the process of loading and + * A 'foolproof' way to prevent memory fragmentation. This class is used to + * serve as a permanent allocation to prevent the process of loading and * unloading plugins from causing heavy fragmentation. **/ - + #define ELFMemMan ELFMemoryManager::instance() - + class ELFMemoryManager : public Common::Singleton<ELFMemoryManager> { -public: +public: void trackPlugin(bool value); void trackAlloc(uint32 align, uint32 size); @@ -49,7 +49,7 @@ public: void *pluginAllocate(uint32 size); void *pluginAllocate(uint32 align, uint32 size); void pluginDeallocate(void *ptr); - + private: friend class Common::Singleton<ELFMemoryManager>; @@ -58,7 +58,7 @@ private: void *allocateOnHeap(uint32 align, uint32 size); void deallocateFromHeap(void *ptr); - + struct Allocation { byte *start; uint32 size; @@ -70,17 +70,17 @@ private: void *_heap; uint32 _heapAlign; // alignment of the heap uint32 _heapSize; // size of the heap - + // tracking allocations bool _trackAllocs; // whether we are currently tracking - uint32 _measuredSize; - uint32 _measuredAlign; - + uint32 _measuredSize; + uint32 _measuredAlign; + // real allocations Common::List<Allocation> _allocList; uint32 _bytesAllocated; }; - + #endif /* defined(DYNAMIC_MODULES) && defined(USE_ELF_LOADER) */ #endif /* ELF_MEMORY_MANAGER_H */ diff --git a/backends/plugins/elf/mips-loader.cpp b/backends/plugins/elf/mips-loader.cpp index 8ce1a69583..e043c9647f 100644 --- a/backends/plugins/elf/mips-loader.cpp +++ b/backends/plugins/elf/mips-loader.cpp @@ -53,7 +53,7 @@ bool MIPSDLObject::relocate(Elf32_Off offset, Elf32_Word size, byte *relSegment) debug(2, "elfloader: Loaded relocation table. %d entries. base address=%p", cnt, relSegment); Elf32_Addr adjustedMainSegment = Elf32_Addr(_segment) - _segmentVMA; // adjust for VMA offset - + bool seenHi16 = false; // For treating HI/LO16 commands int32 firstHi16 = -1; // Mark the point of the first hi16 seen Elf32_Addr ahl = 0; // Calculated addend @@ -259,7 +259,7 @@ void MIPSDLObject::relocateSymbols(ptrdiff_t offset) { if (!ShortsMan.inGeneralSegment((char *)s->st_value)) { if (s->st_value < _segmentVMA) s->st_value = _segmentVMA; // deal with symbols referring to sections, which start before the VMA - + s->st_value += offset; if (s->st_value < Elf32_Addr(_segment) || s->st_value > Elf32_Addr(_segment) + _segmentSize) @@ -287,7 +287,7 @@ bool MIPSDLObject::loadSegment(Elf32_Phdr *phdr) { } debug(2, "elfloader: Allocated segment @ %p", _segment); - + // Get offset to load segment into baseAddress = _segment; _segmentSize = phdr->p_memsz; |