aboutsummaryrefslogtreecommitdiff
path: root/backends
diff options
context:
space:
mode:
authorMax Horn2010-04-12 07:28:54 +0000
committerMax Horn2010-04-12 07:28:54 +0000
commit87028c546fe5bdd8e5c08e47a551f15f9c257bb5 (patch)
tree8c9c70a153d0c3ae7a701c114ebc7b21e440e911 /backends
parent98d7ba281ca70af8d3a1ed1e84aa01dddbc5bccc (diff)
downloadscummvm-rg350-87028c546fe5bdd8e5c08e47a551f15f9c257bb5.tar.gz
scummvm-rg350-87028c546fe5bdd8e5c08e47a551f15f9c257bb5.tar.bz2
scummvm-rg350-87028c546fe5bdd8e5c08e47a551f15f9c257bb5.zip
PSP: Fix code formatting using astyle
svn-id: r48634
Diffstat (limited to 'backends')
-rw-r--r--backends/fs/psp/psp-fs.cpp34
-rw-r--r--backends/fs/psp/psp-stream.cpp27
-rw-r--r--backends/fs/psp/psp-stream.h2
-rw-r--r--backends/platform/psp/cursor.cpp150
-rw-r--r--backends/platform/psp/cursor.h26
-rw-r--r--backends/platform/psp/default_display_client.cpp49
-rw-r--r--backends/platform/psp/default_display_client.h20
-rw-r--r--backends/platform/psp/display_client.cpp358
-rw-r--r--backends/platform/psp/display_client.h44
-rw-r--r--backends/platform/psp/display_manager.cpp100
-rw-r--r--backends/platform/psp/display_manager.h12
-rw-r--r--backends/platform/psp/elf32.h103
-rw-r--r--backends/platform/psp/input.cpp90
-rw-r--r--backends/platform/psp/input.h8
-rw-r--r--backends/platform/psp/memory.cpp66
-rw-r--r--backends/platform/psp/memory.h16
-rw-r--r--backends/platform/psp/osys_psp.cpp66
-rw-r--r--backends/platform/psp/osys_psp.h20
-rw-r--r--backends/platform/psp/powerman.cpp37
-rw-r--r--backends/platform/psp/powerman.h40
-rw-r--r--backends/platform/psp/psp_main.cpp10
-rw-r--r--backends/platform/psp/pspkeyboard.cpp133
-rw-r--r--backends/platform/psp/pspkeyboard.h8
-rw-r--r--backends/platform/psp/psploader.cpp5
-rw-r--r--backends/platform/psp/psppixelformat.cpp78
-rw-r--r--backends/platform/psp/psppixelformat.h112
-rw-r--r--backends/platform/psp/trace.cpp8
-rw-r--r--backends/platform/psp/trace.h48
28 files changed, 839 insertions, 831 deletions
diff --git a/backends/fs/psp/psp-fs.cpp b/backends/fs/psp/psp-fs.cpp
index 0d824846e3..64983f7144 100644
--- a/backends/fs/psp/psp-fs.cpp
+++ b/backends/fs/psp/psp-fs.cpp
@@ -100,10 +100,10 @@ PSPFilesystemNode::PSPFilesystemNode(const Common::String &p, bool verify) {
_isDirectory = true;
PSP_DEBUG_PRINT_FUNC("path [%s]\n", _path.c_str());
-
+
if (verify) {
struct stat st;
- if (PowerMan.beginCriticalSection()==PowerManager::Blocked)
+ if (PowerMan.beginCriticalSection() == PowerManager::Blocked)
PSP_DEBUG_PRINT_FUNC("Suspended\n");
_isValid = (0 == stat(_path.c_str(), &st));
PowerMan.endCriticalSection();
@@ -120,7 +120,7 @@ bool PSPFilesystemNode::exists() const {
PSP_DEBUG_PRINT_FUNC("Suspended\n"); // Make sure to block in case of suspend
PSP_DEBUG_PRINT_FUNC("path [%s]\n", _path.c_str());
-
+
ret = access(_path.c_str(), F_OK);
PowerMan.endCriticalSection();
@@ -135,8 +135,8 @@ bool PSPFilesystemNode::isReadable() const {
if (PowerMan.beginCriticalSection() == PowerManager::Blocked)
PSP_DEBUG_PRINT_FUNC("Suspended\n"); // Make sure to block in case of suspend
- PSP_DEBUG_PRINT_FUNC("path [%s]\n", _path.c_str());
-
+ PSP_DEBUG_PRINT_FUNC("path [%s]\n", _path.c_str());
+
ret = access(_path.c_str(), R_OK);
PowerMan.endCriticalSection();
@@ -152,7 +152,7 @@ bool PSPFilesystemNode::isWritable() const {
PSP_DEBUG_PRINT_FUNC("Suspended\n"); // Make sure to block in case of suspend
PSP_DEBUG_PRINT_FUNC("path [%s]\n", _path.c_str());
-
+
ret = access(_path.c_str(), W_OK);
PowerMan.endCriticalSection();
@@ -173,9 +173,9 @@ AbstractFSNode *PSPFilesystemNode::getChild(const Common::String &n) const {
newPath += n;
PSP_DEBUG_PRINT_FUNC("child [%s]\n", newPath.c_str());
-
+
AbstractFSNode *node = new PSPFilesystemNode(newPath, true);
-
+
DEBUG_EXIT_FUNC();
return node;
}
@@ -191,8 +191,8 @@ bool PSPFilesystemNode::getChildren(AbstractFSList &myList, ListMode mode, bool
if (PowerMan.beginCriticalSection() == PowerManager::Blocked)
PSP_DEBUG_PRINT_FUNC("Suspended\n"); // Make sure to block in case of suspend
- PSP_DEBUG_PRINT_FUNC("Current path[%s]\n", _path.c_str());
-
+ PSP_DEBUG_PRINT_FUNC("Current path[%s]\n", _path.c_str());
+
int dfd = sceIoDopen(_path.c_str());
if (dfd > 0) {
SceIoDirent dir;
@@ -215,12 +215,12 @@ bool PSPFilesystemNode::getChildren(AbstractFSList &myList, ListMode mode, bool
entry._path = newPath;
entry._isDirectory = dir.d_stat.st_attr & FIO_SO_IFDIR;
-
- PSP_DEBUG_PRINT_FUNC("Child[%s], %s\n", entry._path.c_str(), entry._isDirectory ? "dir" : "file");
-
+
+ PSP_DEBUG_PRINT_FUNC("Child[%s], %s\n", entry._path.c_str(), entry._isDirectory ? "dir" : "file");
+
// Honor the chosen mode
if ((mode == Common::FSNode::kListFilesOnly && entry._isDirectory) ||
- (mode == Common::FSNode::kListDirectoriesOnly && !entry._isDirectory))
+ (mode == Common::FSNode::kListDirectoriesOnly && !entry._isDirectory))
continue;
myList.push_back(new PSPFilesystemNode(entry));
@@ -233,7 +233,7 @@ bool PSPFilesystemNode::getChildren(AbstractFSList &myList, ListMode mode, bool
}
PowerMan.endCriticalSection();
-
+
DEBUG_EXIT_FUNC();
return ret;
}
@@ -243,8 +243,8 @@ AbstractFSNode *PSPFilesystemNode::getParent() const {
if (_path == ROOT_PATH)
return 0;
- PSP_DEBUG_PRINT_FUNC("current[%s]\n", _path.c_str());
-
+ PSP_DEBUG_PRINT_FUNC("current[%s]\n", _path.c_str());
+
const char *start = _path.c_str();
const char *end = lastPathComponent(_path, '/');
diff --git a/backends/fs/psp/psp-stream.cpp b/backends/fs/psp/psp-stream.cpp
index 5b955beee6..2b99554182 100644
--- a/backends/fs/psp/psp-stream.cpp
+++ b/backends/fs/psp/psp-stream.cpp
@@ -38,9 +38,9 @@
#include "backends/platform/psp/trace.h"
PSPIoStream::PSPIoStream(const Common::String &path, bool writeMode)
-: StdioStream((void *)1), _path(path), _writeMode(writeMode) {
+ : StdioStream((void *)1), _path(path), _writeMode(writeMode) {
DEBUG_ENTER_FUNC();
-
+
assert(!path.empty());
_handle = (void *)0; // Need to do this since base class asserts not 0.
@@ -54,23 +54,23 @@ PSPIoStream::PSPIoStream(const Common::String &path, bool writeMode)
_errorPos = 0;
_errorHandle = 0;
_suspendCount = 0;
-
+
DEBUG_EXIT_FUNC();
}
PSPIoStream::~PSPIoStream() {
DEBUG_ENTER_FUNC();
-
+
if (PowerMan.beginCriticalSection() == PowerManager::Blocked)
PSP_DEBUG_PRINT_FUNC("Suspended\n");
PowerMan.unregisterSuspend(this); // Unregister with powermanager to be suspended
- // Must do this before fclose() or resume() will reopen.
+ // Must do this before fclose() or resume() will reopen.
fclose((FILE *)_handle); // We don't need a critical section(?). Worst case, the handle gets closed on its own
PowerMan.endCriticalSection();
-
+
DEBUG_EXIT_FUNC();
}
@@ -98,7 +98,7 @@ bool PSPIoStream::err() const {
DEBUG_ENTER_FUNC();
if (_ferror)
PSP_ERROR("mem_ferror[%d], source[%d], suspend error[%d], pos[%d], _errorPos[%d], _errorHandle[%p], suspendCount[%d]\n",
- _ferror, _errorSource, _errorSuspend, _pos, _errorPos, _errorHandle, _suspendCount);
+ _ferror, _errorSource, _errorSuspend, _pos, _errorPos, _errorHandle, _suspendCount);
DEBUG_EXIT_FUNC();
return _ferror;
@@ -142,7 +142,7 @@ int32 PSPIoStream::size() const {
bool PSPIoStream::seek(int32 offs, int whence) {
DEBUG_ENTER_FUNC();
-
+
// Check if we can access the file
if (PowerMan.beginCriticalSection() == PowerManager::Blocked)
PSP_DEBUG_PRINT_FUNC("Suspended\n");
@@ -155,8 +155,7 @@ bool PSPIoStream::seek(int32 offs, int whence) {
clearerr((FILE *)_handle);
_feof = feof((FILE *)_handle);
_errorSource = 3;
- }
- else { // everything ok
+ } else { // everything ok
_feof = false; // Reset eof flag since we know it was ok
}
@@ -173,7 +172,7 @@ uint32 PSPIoStream::read(void *ptr, uint32 len) {
// Check if we can access the file
if (PowerMan.beginCriticalSection() == PowerManager::Blocked)
PSP_DEBUG_PRINT_FUNC("Suspended\n");
-
+
PSP_DEBUG_PRINT_FUNC("filename[%s], len[%d]\n", _path.c_str(), len);
size_t ret = fread((byte *)ptr, 1, len, (FILE *)_handle);
@@ -203,8 +202,8 @@ uint32 PSPIoStream::write(const void *ptr, uint32 len) {
if (PowerMan.beginCriticalSection() == PowerManager::Blocked)
PSP_DEBUG_PRINT_FUNC("Suspended\n");
- PSP_DEBUG_PRINT_FUNC("filename[%s], len[%d]\n", _path.c_str(), len);
-
+ PSP_DEBUG_PRINT_FUNC("filename[%s], len[%d]\n", _path.c_str(), len);
+
size_t ret = fwrite(ptr, 1, len, (FILE *)_handle);
_pos += ret;
@@ -255,7 +254,7 @@ PSPIoStream *PSPIoStream::makeFromPath(const Common::String &path, bool writeMod
delete stream;
stream = 0;
}
-
+
DEBUG_EXIT_FUNC();
return stream;
}
diff --git a/backends/fs/psp/psp-stream.h b/backends/fs/psp/psp-stream.h
index 20836ddf32..9fcdd6d606 100644
--- a/backends/fs/psp/psp-stream.h
+++ b/backends/fs/psp/psp-stream.h
@@ -55,7 +55,7 @@ protected:
int _suspendCount;
public:
-
+
const char *getObjectName() const { return "PSPIoStream"; }
/**
* Given a path, invoke fopen on that path and wrap the result in a
diff --git a/backends/platform/psp/cursor.cpp b/backends/platform/psp/cursor.cpp
index b6b9a70458..8d1f6fec86 100644
--- a/backends/platform/psp/cursor.cpp
+++ b/backends/platform/psp/cursor.cpp
@@ -29,33 +29,33 @@
#include "backends/platform/psp/cursor.h"
//#define __PSP_DEBUG_FUNCS__ /* For debugging the stack */
-//#define __PSP_DEBUG_PRINT__
+//#define __PSP_DEBUG_PRINT__
+
+#include "backends/platform/psp/trace.h"
-#include "backends/platform/psp/trace.h"
-
void Cursor::init() {
DEBUG_ENTER_FUNC();
-
+
_renderer.setBuffer(&_buffer); // We do this explicitly
_renderer.setPalette(&_screenPalette); // because we want to choose screenpalette by default
_renderer.setUseGlobalScaler(true);
setRendererModePalettized(true); // Assume we start in 8bit mode
-
+
// Default modes
_palette.setPixelFormats(PSPPixelFormat::Type_5551, PSPPixelFormat::Type_Palette_8bit); // default
_screenPalette.setPixelFormats(PSPPixelFormat::Type_5551, PSPPixelFormat::Type_Palette_8bit);
_buffer.setPixelFormat(PSPPixelFormat::Type_5551);
-
+
DEBUG_EXIT_FUNC();
}
void Cursor::deallocate() {
DEBUG_ENTER_FUNC();
-
+
_buffer.deallocate();
_palette.deallocate();
_screenPalette.deallocate();
-
+
DEBUG_EXIT_FUNC();
}
@@ -65,17 +65,17 @@ void Cursor::setCursorPalette(const byte *colors, uint start, uint num) {
if (!_palette.isAllocated()) {
_palette.allocate();
}
-
+
// Workaround: This is wrong, but we seem to not be getting setScreenPalette
if (!_screenPalette.isAllocated()) {
_screenPalette.allocate();
- }
-
+ }
+
_palette.setPartial(colors, start, num);
setDirty();
-
+
DEBUG_EXIT_FUNC();
-}
+}
void Cursor::setScreenPalette(const byte *colors, uint start, uint num) {
DEBUG_ENTER_FUNC();
@@ -83,17 +83,17 @@ void Cursor::setScreenPalette(const byte *colors, uint start, uint num) {
if (!_screenPalette.isAllocated()) {
_screenPalette.allocate();
}
-
+
_screenPalette.setPartial(colors, start, num);
setDirty();
-
+
DEBUG_EXIT_FUNC();
}
void Cursor::setKeyColor(uint32 color) {
DEBUG_ENTER_FUNC();
PSP_DEBUG_PRINT("new color[%u], old color[%u]\n", color, _keyColor);
-
+
// If it's a different color, undo the last keycolor
if (_buffer.hasPalette() && color != _keyColor) {
if (_screenPalette.isAllocated())
@@ -103,7 +103,7 @@ void Cursor::setKeyColor(uint32 color) {
}
// Don't need anything special for 16-bit
_keyColor = color;
-
+
DEBUG_EXIT_FUNC();
}
@@ -114,29 +114,29 @@ void Cursor::clearKeyColor() {
// We need 2 mechanisms: one for palettized and one for 16 bit
if (_buffer.hasPalette()) {
if (_screenPalette.isAllocated())
- _screenPalette.setColorPositionAlpha(_keyColor, false); // set keycolor to 0
+ _screenPalette.setColorPositionAlpha(_keyColor, false); // set keycolor to 0
if (_palette.isAllocated())
- _palette.setColorPositionAlpha(_keyColor, false);
+ _palette.setColorPositionAlpha(_keyColor, false);
} else { // 16bit
_renderer.setKeyColor(_keyColor);
}
setDirty();
-
+
DEBUG_EXIT_FUNC();
}
void Cursor::enableCursorPalette(bool enable) {
DEBUG_ENTER_FUNC();
PSP_DEBUG_PRINT("enable[%s]\n", enable ? "true" : "false");
-
+
_useCursorPalette = enable;
if (enable)
_renderer.setPalette(&_palette); // very important that we do this switch
else
_renderer.setPalette(&_screenPalette);
-
+
setDirty();
- DEBUG_EXIT_FUNC();
+ DEBUG_EXIT_FUNC();
}
inline void Cursor::setSize(uint32 width, uint32 height) {
@@ -145,21 +145,21 @@ inline void Cursor::setSize(uint32 width, uint32 height) {
_buffer.setSize(width, height, Buffer::kSizeByTextureSize); // we'll use texture size for mouse
_renderer.setDrawWholeBuffer(); // We need to let the renderer know how much to draw
-
+
DEBUG_EXIT_FUNC();
}
void Cursor::copyFromArray(const byte *array) {
DEBUG_ENTER_FUNC();
-
+
if (!_buffer.isAllocated()) {
_buffer.allocate();
}
_buffer.copyFromArray(array, _buffer.getSourceWidthInBytes()); // pitch is source width
setDirty();
-
- // debug
+
+ // debug
//PSP_DEBUG_DO(_buffer.print(0xF));
DEBUG_EXIT_FUNC();
@@ -179,16 +179,16 @@ void Cursor::setHotspot(int32 x, int32 y) {
// Returns true if change in x or y
bool Cursor::increaseXY(int32 incX, int32 incY) {
- DEBUG_ENTER_FUNC();
+ DEBUG_ENTER_FUNC();
int32 oldX = _x, oldY = _y;
// adjust for differences in X and Y
adjustXYForScreenSize(incX, incY);
-
+
_x += incX;
_y += incY;
-
+
// Clamp mouse
if (_x < 0)
_x = 0;
@@ -198,62 +198,62 @@ bool Cursor::increaseXY(int32 incX, int32 incY) {
_x = (int)_mouseLimitWidth - 1;
if (_y >= (int)_mouseLimitHeight)
_y = (int)_mouseLimitHeight - 1;
-
+
PSP_DEBUG_PRINT("X[%d], Y[%d]\n", _x, _y);
-
+
if (oldX != _x || oldY != _y) {
updateRendererOffset();
setDirty();
DEBUG_EXIT_FUNC();
return true;
}
-
+
DEBUG_EXIT_FUNC();
return false;
}
// Set limits on the movement of the cursor ie. screen size
-void Cursor::setLimits(uint32 width, uint32 height) {
- #define PSP_SCREEN_WIDTH 480
- #define PSP_SCREEN_HEIGHT 272
+void Cursor::setLimits(uint32 width, uint32 height) {
+#define PSP_SCREEN_WIDTH 480
+#define PSP_SCREEN_HEIGHT 272
DEBUG_ENTER_FUNC();
-
+
PSP_DEBUG_PRINT("width[%u], height[%u]\n", width, height);
- _mouseLimitWidth = width;
- _mouseLimitHeight = height;
-
+ _mouseLimitWidth = width;
+ _mouseLimitHeight = height;
+
DEBUG_EXIT_FUNC();
}
-
-// Adjust X,Y movement for the screen size to keep it consistent
+
+// Adjust X,Y movement for the screen size to keep it consistent
inline void Cursor::adjustXYForScreenSize(int32 &x, int32 &y) {
DEBUG_ENTER_FUNC();
// We have our speed calibrated for the y axis at 480x272. The idea is to adjust this for other
// resolutions and for x, which is wider.
int32 newX = x, newY = y;
-
+
// adjust width movement to match height (usually around 1.5)
if (_mouseLimitWidth >= _mouseLimitHeight + (_mouseLimitHeight >> 1))
newX = newX + (newX >> 1);
-
+
if (_mouseLimitWidth >= 600) { // multiply by 2
- newX <<= 1;
+ newX <<= 1;
newY <<= 1;
} else if (_mouseLimitWidth >= 480) { // multiply by 1.5
newX = newX + (newX >> 1);
newY = newY + (newY >> 1);
}
-
+
// Divide all movements by 8
newX >>= 3;
newY >>= 3;
-
- // Make sure we didn't destroy minimum movement
- if (!((x && !newX) || (y && !newY))) {
+
+ // Make sure we didn't destroy minimum movement
+ if (!((x && !newX) || (y && !newY))) {
x = newX;
y = newY;
}
-
+
DEBUG_EXIT_FUNC();
}
@@ -264,55 +264,55 @@ void Cursor::setScreenPaletteScummvmPixelFormat(const Graphics::PixelFormat *for
uint32 oldPaletteSize = 0;
if (_screenPalette.isAllocated())
oldPaletteSize = _screenPalette.getSizeInBytes();
-
+
PSPPixelFormat::Type bufferType = PSPPixelFormat::Type_Unknown;
PSPPixelFormat::Type paletteType = PSPPixelFormat::Type_Unknown;
bool swapRedBlue = false;
-
+
// Convert Scummvm Pixel Format to PSPPixelFormat
PSPPixelFormat::convertFromScummvmPixelFormat(format, bufferType, paletteType, swapRedBlue);
-
+
if (paletteType == PSPPixelFormat::Type_None) {
//_screenPalette.deallocate(); // leave palette for default CLUT8
setRendererModePalettized(false); // use 16-bit mechanism
} else { // We have a palette
- _screenPalette.setPixelFormats(paletteType, bufferType);
- _palette.setPixelFormats(paletteType, bufferType);
+ _screenPalette.setPixelFormats(paletteType, bufferType);
+ _palette.setPixelFormats(paletteType, bufferType);
setRendererModePalettized(true); // use palettized mechanism
}
-
+
DEBUG_EXIT_FUNC();
}
// This is called many many times
void Cursor::setSizeAndScummvmPixelFormat(uint32 width, uint32 height, const Graphics::PixelFormat *format) {
DEBUG_ENTER_FUNC();
-
+
PSP_DEBUG_PRINT("useCursorPalette[%s]\n", _useCursorPalette ? "true" : "false");
-
+
uint32 oldBufferSize = 0, oldPaletteSize = 0;
-
- if (_buffer.isAllocated())
+
+ if (_buffer.isAllocated())
oldBufferSize = _buffer.getSizeInBytes();
-
+
if (_palette.isAllocated())
oldPaletteSize = _palette.getSizeInBytes();
-
+
setSize(width, height);
-
+
PSPPixelFormat::Type bufferType = PSPPixelFormat::Type_Unknown;
PSPPixelFormat::Type paletteType = PSPPixelFormat::Type_Unknown;
bool swapRedBlue = false;
-
+
PSPPixelFormat::convertFromScummvmPixelFormat(format, bufferType, paletteType, swapRedBlue);
PSP_DEBUG_PRINT("bufferType[%u], paletteType[%u]\n", bufferType, paletteType);
-
+
// Check if we need to set new pixel format
if (_buffer.getPixelFormat() != bufferType) {
PSP_DEBUG_PRINT("new buffer pixel format[%u] is different from [%u]. Setting it.\n", bufferType, _buffer.getPixelFormat());
_buffer.setPixelFormat(bufferType);
}
-
+
// Check if we need to reallocate
if (_buffer.getSizeInBytes() != oldBufferSize) {
_buffer.allocate();
@@ -320,29 +320,29 @@ void Cursor::setSizeAndScummvmPixelFormat(uint32 width, uint32 height, const Gra
}
PSP_DEBUG_PRINT("palette pixel format[%u]\n", paletteType);
-
+
if (paletteType == PSPPixelFormat::Type_None) {
setRendererModePalettized(false); // use palettized mechanism
} else { // We have a palette
- _palette.setPixelFormats(paletteType, bufferType);
+ _palette.setPixelFormats(paletteType, bufferType);
setRendererModePalettized(true); // use palettized mechanism
- }
+ }
// debug
// PSP_DEBUG_DO(_palette.print(10));
// PSP_DEBUG_DO(_screenPalette.print(10));
-
+
DEBUG_EXIT_FUNC();
}
void Cursor::setXY(int x, int y) {
- DEBUG_ENTER_FUNC();
-
- _x = x;
- _y = y;
+ DEBUG_ENTER_FUNC();
+
+ _x = x;
+ _y = y;
updateRendererOffset(); // Very important to let renderer know things changed
setDirty();
-
+
DEBUG_EXIT_FUNC();
}
diff --git a/backends/platform/psp/cursor.h b/backends/platform/psp/cursor.h
index 49f58cd3f9..d68859e9ad 100644
--- a/backends/platform/psp/cursor.h
+++ b/backends/platform/psp/cursor.h
@@ -22,7 +22,7 @@
* $Id: osys_psp.h 46120 2009-11-24 10:33:30Z Bluddy $
*
*/
-
+
#ifndef MOUSE_H
#define MOUSE_H
@@ -37,16 +37,16 @@ private:
uint32 _mouseLimitHeight;
int32 _x, _y;
Palette _screenPalette; // separate palette for screen. default 'palette' is cursor palette.
-
+
void updateRendererOffset();
public:
- Cursor() : _hotspotX(0), _hotspotY(0), _keyColor(0), _cursorTargetScale(0),
- _useCursorPalette(false), _hasCursorPalette(false), _mouseLimitWidth(0),
- _mouseLimitHeight(0), _x(0), _y(0) { }
+ Cursor() : _hotspotX(0), _hotspotY(0), _keyColor(0), _cursorTargetScale(0),
+ _useCursorPalette(false), _hasCursorPalette(false), _mouseLimitWidth(0),
+ _mouseLimitHeight(0), _x(0), _y(0) { }
virtual ~Cursor() { deallocate(); }
-
- void setKeyColor(uint32 color);
+
+ void setKeyColor(uint32 color);
void setCursorTargetScale(int scale) { _cursorTargetScale = scale; }
void setScreenPalette(const byte *colors, uint start, uint num);
void copyFromArray(const byte *array);
@@ -54,7 +54,7 @@ public:
Buffer &buffer() { return _buffer; }
void setCursorPalette(const byte *colors, uint start, uint num);
void enableCursorPalette(bool enable);
- void setLimits(uint32 width, uint32 height);
+ void setLimits(uint32 width, uint32 height);
void setXY(int x, int y);
int32 getX() { return _x; }
int32 getY() { return _y; }
@@ -68,14 +68,14 @@ public:
void useGlobalScaler(bool val) { _renderer.setUseGlobalScaler(val); }
bool allocate();
void deallocate();
-
+
private:
void setSize(uint32 width, uint32 height);
void getPixelFormatsFromScummvmPixelFormat(const Graphics::PixelFormat *format,
- PSPPixelFormat::Type &bufferFormat,
- PSPPixelFormat::Type &paletteFormat,
- uint32 &numOfEntries);
- void setRendererModePalettized(bool palettized);
+ PSPPixelFormat::Type &bufferFormat,
+ PSPPixelFormat::Type &paletteFormat,
+ uint32 &numOfEntries);
+ void setRendererModePalettized(bool palettized);
};
#endif /* MOUSE_H */
diff --git a/backends/platform/psp/default_display_client.cpp b/backends/platform/psp/default_display_client.cpp
index eb20980315..7f2529483c 100644
--- a/backends/platform/psp/default_display_client.cpp
+++ b/backends/platform/psp/default_display_client.cpp
@@ -36,15 +36,14 @@
bool DefaultDisplayClient::allocate(bool bufferInVram /* = false */, bool paletteInVram /* = false */) {
DEBUG_ENTER_FUNC();
-
+
if (!_buffer.allocate(bufferInVram)) {
- PSP_ERROR("Couldn't allocate buffer.\n");
- DEBUG_EXIT_FUNC();
- return false;
- }
+ PSP_ERROR("Couldn't allocate buffer.\n");
+ DEBUG_EXIT_FUNC();
+ return false;
+ }
- if (_buffer.hasPalette())
- {
+ if (_buffer.hasPalette()) {
PSP_DEBUG_PRINT("_palette[%p]\n", &_palette);
if (!_palette.allocate()) {
@@ -53,7 +52,7 @@ bool DefaultDisplayClient::allocate(bool bufferInVram /* = false */, bool palett
return false;
}
}
-
+
DEBUG_EXIT_FUNC();
return true;
}
@@ -88,12 +87,12 @@ void DefaultDisplayClient::init() {
void DefaultDisplayClient::copyFromRect(const byte *buf, int pitch, int destX, int destY, int recWidth, int recHeight) {
DEBUG_ENTER_FUNC();
- _buffer.copyFromRect(buf, pitch, destX, destY, recWidth, recHeight);
+ _buffer.copyFromRect(buf, pitch, destX, destY, recWidth, recHeight);
setDirty();
DEBUG_EXIT_FUNC();
}
-void DefaultDisplayClient::copyToArray(byte *dst, int pitch) {
+void DefaultDisplayClient::copyToArray(byte *dst, int pitch) {
DEBUG_ENTER_FUNC();
_buffer.copyToArray(dst, pitch);
DEBUG_EXIT_FUNC();
@@ -115,7 +114,7 @@ void Overlay::init() {
void Overlay::setBytesPerPixel(uint32 size) {
DEBUG_ENTER_FUNC();
-
+
switch (size) {
case 1:
_buffer.setPixelFormat(PSPPixelFormat::Type_Palette_8bit);
@@ -128,7 +127,7 @@ void Overlay::setBytesPerPixel(uint32 size) {
_buffer.setPixelFormat(PSPPixelFormat::Type_8888);
break;
}
-
+
DEBUG_EXIT_FUNC();
}
@@ -147,7 +146,7 @@ void Overlay::copyToArray(OverlayColor *buf, int pitch) {
void Overlay::copyFromRect(const OverlayColor *buf, int pitch, int x, int y, int w, int h) {
DEBUG_ENTER_FUNC();
-
+
_buffer.copyFromRect((byte *)buf, pitch * sizeof(OverlayColor), x, y, w, h); // Change to bytes
// debug
//_buffer.print(0xFF);
@@ -157,9 +156,9 @@ void Overlay::copyFromRect(const OverlayColor *buf, int pitch, int x, int y, int
bool Overlay::allocate() {
DEBUG_ENTER_FUNC();
-
+
bool ret = DefaultDisplayClient::allocate(true, false); // buffer in VRAM
-
+
DEBUG_EXIT_FUNC();
return ret;
}
@@ -179,7 +178,7 @@ void Screen::init() {
}
void Screen::setShakePos(int pos) {
- _shakePos = pos;
+ _shakePos = pos;
_renderer.setOffsetOnScreen(0, pos);
setDirty();
}
@@ -189,7 +188,7 @@ void Screen::setSize(uint32 width, uint32 height) {
_buffer.setSize(width, height, Buffer::kSizeBySourceSize);
_renderer.setDrawWholeBuffer(); // We need to let the renderer know how much to draw
-
+
DEBUG_EXIT_FUNC();
}
@@ -203,36 +202,36 @@ void Screen::setScummvmPixelFormat(const Graphics::PixelFormat *format) {
} else {
_pixelFormat = *format;
}
-
+
PSPPixelFormat::Type bufferFormat, paletteFormat;
bool swapRedBlue = false;
-
+
PSPPixelFormat::convertFromScummvmPixelFormat(format, bufferFormat, paletteFormat, swapRedBlue);
_buffer.setPixelFormat(bufferFormat, swapRedBlue);
_palette.setPixelFormats(paletteFormat, bufferFormat, swapRedBlue);
-
+
DEBUG_EXIT_FUNC();
}
Graphics::Surface *Screen::lockAndGetForEditing() {
DEBUG_ENTER_FUNC();
-
+
_frameBuffer.pixels = _buffer.getPixels();
_frameBuffer.w = _buffer.getSourceWidth();
_frameBuffer.h = _buffer.getSourceHeight();
_frameBuffer.pitch = _buffer.getBytesPerPixel() * _buffer.getWidth();
_frameBuffer.bytesPerPixel = _buffer.getBytesPerPixel();
// We'll set to dirty once we unlock the screen
-
+
DEBUG_EXIT_FUNC();
-
+
return &_frameBuffer;
}
bool Screen::allocate() {
DEBUG_ENTER_FUNC();
-
+
return DefaultDisplayClient::allocate(true, false); // buffer in VRAM
-
+
DEBUG_EXIT_FUNC();
}
diff --git a/backends/platform/psp/default_display_client.h b/backends/platform/psp/default_display_client.h
index e83b0bf04d..9fea1a3027 100644
--- a/backends/platform/psp/default_display_client.h
+++ b/backends/platform/psp/default_display_client.h
@@ -24,7 +24,7 @@
*/
#ifndef PSP_DEF_DISPLAY_CLIENT_H
-#define PSP_DEF_DISPLAY_CLIENT_H
+#define PSP_DEF_DISPLAY_CLIENT_H
/**
* Default display client that is useful for most purposes.
@@ -32,7 +32,7 @@
class DefaultDisplayClient : public DisplayClient {
public:
DefaultDisplayClient() : _visible(false), _dirty(true) {}
-
+
bool isVisible() { return _visible; }
void setVisible(bool v) { _visible = v; setDirty(); }
Buffer &buffer() { return _buffer; }
@@ -46,8 +46,8 @@ public:
uint32 getWidth() { return _buffer.getSourceWidth(); }
uint32 getHeight() { return _buffer.getSourceHeight(); }
void setPartialPalette(const byte *colors, uint start, uint num) { setDirty(); return _palette.setPartial(colors, start, num); }
- void getPartialPalette(byte *colors, uint start, uint num) {
- return _palette.getPartial(colors, start, num);
+ void getPartialPalette(byte *colors, uint start, uint num) {
+ return _palette.getPartial(colors, start, num);
}
void copyFromRect(const byte *buf, int pitch, int destX, int destY, int recWidth, int recHeight);
void copyToArray(byte *dst, int pitch);
@@ -70,13 +70,13 @@ class Overlay : public DefaultDisplayClient {
public:
Overlay() {}
~Overlay() { }
-
+
void init();
bool allocate();
void setBytesPerPixel(uint32 size);
void setSize(uint32 width, uint32 height);
void copyToArray(OverlayColor *buf, int pitch);
- void copyFromRect(const OverlayColor *buf, int pitch, int x, int y, int w, int h);
+ void copyFromRect(const OverlayColor *buf, int pitch, int x, int y, int w, int h);
};
/**
@@ -89,16 +89,16 @@ public:
memset(&_frameBuffer, 0, sizeof(_frameBuffer));
}
~Screen() {}
-
+
void init();
bool allocate();
void setShakePos(int pos);
void setScummvmPixelFormat(const Graphics::PixelFormat *format);
const Graphics::PixelFormat &getScummvmPixelFormat() const { return _pixelFormat; }
Graphics::Surface *lockAndGetForEditing();
- void unlock() { setDirty(); } // set dirty here because of changes
- void setSize(uint32 width, uint32 height);
-
+ void unlock() { setDirty(); } // set dirty here because of changes
+ void setSize(uint32 width, uint32 height);
+
private:
uint32 _shakePos;
Graphics::PixelFormat _pixelFormat;
diff --git a/backends/platform/psp/display_client.cpp b/backends/platform/psp/display_client.cpp
index 73a3fefe5b..44998e4969 100644
--- a/backends/platform/psp/display_client.cpp
+++ b/backends/platform/psp/display_client.cpp
@@ -27,7 +27,7 @@
#include <pspdisplay.h>
#include <psputils.h>
-#include "common/scummsys.h"
+#include "common/scummsys.h"
#include "backends/platform/psp/display_client.h"
#include "backends/platform/psp/display_manager.h"
#include "backends/platform/psp/memory.h"
@@ -51,9 +51,9 @@ void Palette::clear() {
if (_values && _numOfEntries)
memset(_values, 0, getSizeInBytes());
-
+
PSP_DEBUG_PRINT("_values[%p]\n", _values);
-
+
DEBUG_EXIT_FUNC();
}
@@ -61,33 +61,33 @@ void Palette::clear() {
//
void Palette::setColorPositionAlpha(uint32 position, bool alpha) {
DEBUG_ENTER_FUNC();
-
+
assert(_values);
assert(position < _numOfEntries);
-
+
PSP_DEBUG_PRINT("position[%d], numofEntries[%u], bpp[%u], values[%p]\n", position, _numOfEntries,
- _pixelFormat.bitsPerPixel, _values);
+ _pixelFormat.bitsPerPixel, _values);
if (_numOfEntries <= 16)
position &= 0xF;
else if (_numOfEntries <= 256)
position &= 0xFF;
-
+
switch (_pixelFormat.bitsPerPixel) {
- case 16: {
- uint16 *shortVal = (uint16 *)&_values[_pixelFormat.pixelsToBytes(position)];
- *shortVal = _pixelFormat.setColorAlpha((uint32)*shortVal, alpha ? 255 : 0);
- }
- break;
+ case 16: {
+ uint16 *shortVal = (uint16 *) & _values[_pixelFormat.pixelsToBytes(position)];
+ *shortVal = _pixelFormat.setColorAlpha((uint32) * shortVal, alpha ? 255 : 0);
+ }
+ break;
case 32: {
- uint32 *wordVal = (uint32 *)&_values[_pixelFormat.pixelsToBytes(position)];
- *wordVal = _pixelFormat.setColorAlpha((uint32)*wordVal, alpha ? 255 : 0);
- }
- break;
+ uint32 *wordVal = (uint32 *) & _values[_pixelFormat.pixelsToBytes(position)];
+ *wordVal = _pixelFormat.setColorAlpha((uint32) * wordVal, alpha ? 255 : 0);
+ }
+ break;
default:
PSP_ERROR("Incorrect bits per pixel value[%u]\n", _pixelFormat.bitsPerPixel);
}
-
+
DEBUG_EXIT_FUNC();
}
@@ -98,43 +98,42 @@ void Palette::setPartial(const byte *colors, uint32 start, uint32 num, bool supp
assert(_values);
assert(_numOfEntries);
-
+
const byte *src = colors;
-
+
if (start + num > _numOfEntries) // Check boundary
num = _numOfEntries - start;
if (_pixelFormat.bitsPerPixel == 16) {
uint16 *palette = (uint16 *)_values;
palette += start;
-
+
for (uint32 i = 0; i < num; ++i) {
byte alphaVal = supportsAlpha ? src[3] : 0xFF;
*palette = (uint16)_pixelFormat.rgbaToColor(src[0], src[1], src[2], alphaVal);
- src += 4;
+ src += 4;
palette++;
}
- }
- else if (_pixelFormat.bitsPerPixel == 32) {
+ } else if (_pixelFormat.bitsPerPixel == 32) {
uint32 *palette = (uint32 *)_values;
palette += start;
-
+
for (uint32 i = 0; i < num; ++i) {
byte alphaVal = supportsAlpha ? src[3] : 0xFF;
*palette = _pixelFormat.rgbaToColor(src[0], src[1], src[2], alphaVal);
- src += 4;
+ src += 4;
palette++;
}
}
-
+
DEBUG_EXIT_FUNC();
}
// Sets pixel format and number of entries by the buffer's pixel format */
void Palette::setPixelFormats(PSPPixelFormat::Type paletteType, PSPPixelFormat::Type bufferType, bool swapRedBlue /* = false */) {
DEBUG_ENTER_FUNC();
-
- if (paletteType == PSPPixelFormat::Type_Unknown)
+
+ if (paletteType == PSPPixelFormat::Type_Unknown)
PSP_ERROR("Unknown paletteType[%u]\n", paletteType);
switch (bufferType) {
@@ -152,9 +151,9 @@ void Palette::setPixelFormats(PSPPixelFormat::Type paletteType, PSPPixelFormat::
_numOfEntries = 0;
break;
}
-
+
_pixelFormat.set(paletteType, swapRedBlue);
-
+
DEBUG_EXIT_FUNC();
}
@@ -164,40 +163,40 @@ bool Palette::allocate() {
PSP_DEBUG_PRINT("_pixelFormat: format[%u], bpp[%u]\n", _pixelFormat.format, _pixelFormat.bitsPerPixel);
if (_values) {
- free (CACHED(_values));
+ free(CACHED(_values));
_values = 0;
}
// We allocate on 64bytes to get a cache line, and round up to 64bytes to get the full line
uint32 amountInBytes = getSizeInBytes();
- if (amountInBytes < 64)
+ if (amountInBytes < 64)
amountInBytes = 64;
_values = (byte *)memalign(64, amountInBytes);
// Use uncached memory
GuRenderer::cacheInvalidate(_values, amountInBytes);
_values = UNCACHED(_values);
-
+
if (!_values) {
PSP_ERROR("Couldn't allocate palette.\n");
DEBUG_EXIT_FUNC();
return false;
}
-
+
PSP_DEBUG_PRINT("_values[%p]\n", _values);
clear();
-
+
DEBUG_EXIT_FUNC();
return true;
}
void Palette::deallocate() {
DEBUG_ENTER_FUNC();
-
- free (CACHED(_values));
+
+ free(CACHED(_values));
_values = 0;
_numOfEntries = 0;
-
+
DEBUG_EXIT_FUNC();
}
@@ -208,32 +207,32 @@ void Palette::getPartial(byte *colors, uint start, uint num) {
assert(_values);
assert(_numOfEntries);
-
+
uint32 r, g, b, a;
if (start + num > _numOfEntries) // Check boundary
num = _numOfEntries - start;
-
- if (_pixelFormat.bitsPerPixel == 16) {
+
+ if (_pixelFormat.bitsPerPixel == 16) {
uint16 *palette = (uint16 *)_values;
palette += start;
-
+
for (uint32 i = start; i < start + num; i++) {
_pixelFormat.colorToRgba(*palette, r, g, b, a);
-
+
*colors++ = (byte)r;
*colors++ = (byte)g;
*colors++ = (byte)b;
*colors++ = (byte)a;
palette++;
}
- } else if (_pixelFormat.bitsPerPixel == 32) {
+ } else if (_pixelFormat.bitsPerPixel == 32) {
uint32 *palette = (uint32 *)_values;
palette += start;
-
+
for (uint32 i = start; i < start + num; i++) {
_pixelFormat.colorToRgba(*palette, r, g, b, a);
-
+
*colors++ = (byte)r;
*colors++ = (byte)g;
*colors++ = (byte)b;
@@ -241,26 +240,26 @@ void Palette::getPartial(byte *colors, uint start, uint num) {
palette++;
}
}
-
+
DEBUG_EXIT_FUNC();
}
-void Palette::setSingleColorRGBA(uint32 num, byte r, byte g, byte b, byte a) {
+void Palette::setSingleColorRGBA(uint32 num, byte r, byte g, byte b, byte a) {
// DEBUG_ENTER_FUNC();
uint16 *shortValues;
uint32 *wordValues;
-
- assert (_values);
- assert (num < _numOfEntries);
-
+
+ assert(_values);
+ assert(num < _numOfEntries);
+
switch (_pixelFormat.bitsPerPixel) {
- case 16:
+ case 16:
shortValues = (uint16 *)_values;
shortValues[num] = _pixelFormat.rgbaToColor(r, g, b, a);
break;
- case 32:
+ case 32:
wordValues = (uint32 *)_values;
- wordValues[num] = _pixelFormat.rgbaToColor(r, g, b, a);
+ wordValues[num] = _pixelFormat.rgbaToColor(r, g, b, a);
break;
default:
PSP_ERROR("Incorrect bitsPerPixel[%d]\n", _pixelFormat.bitsPerPixel);
@@ -272,20 +271,20 @@ void Palette::setSingleColorRGBA(uint32 num, byte r, byte g, byte b, byte a) {
// Print to screen
void Palette::print(uint32 numToPrint /* = 0 */) {
if (_numOfEntries > 0) {
- assert (_values);
-
- if (numToPrint > _numOfEntries || numToPrint == 0)
+ assert(_values);
+
+ if (numToPrint > _numOfEntries || numToPrint == 0)
numToPrint = _numOfEntries;
-
+
PSP_INFO_PRINT("cursor palette:\n");
-
- for (unsigned int i=0; i<numToPrint; i++) {
+
+ for (unsigned int i = 0; i < numToPrint; i++) {
byte *pcolor = &_values[_pixelFormat.pixelsToBytes(i)];
uint32 color = _pixelFormat.getColorValueAt(pcolor);
-
+
PSP_INFO_PRINT("[%u=%x] ", i, color);
}
-
+
PSP_INFO_PRINT("\n");
}
}
@@ -305,17 +304,17 @@ uint32 Palette::getRGBAColorAt(uint32 position) {
// class Buffer ---------------------------------------------------
-void Buffer::setPixelFormat(PSPPixelFormat::Type type, bool swapRedBlue) {
+void Buffer::setPixelFormat(PSPPixelFormat::Type type, bool swapRedBlue) {
if (type == PSPPixelFormat::Type_None ||
- type == PSPPixelFormat::Type_Unknown)
+ type == PSPPixelFormat::Type_Unknown)
PSP_ERROR("Unhandled buffer format[%u]\n", type);
-
- _pixelFormat.set(type, swapRedBlue);
+
+ _pixelFormat.set(type, swapRedBlue);
}
bool Buffer::hasPalette() {
if (_pixelFormat.format == PSPPixelFormat::Type_Palette_8bit ||
- _pixelFormat.format == PSPPixelFormat::Type_Palette_4bit)
+ _pixelFormat.format == PSPPixelFormat::Type_Palette_4bit)
return true;
return false;
@@ -324,10 +323,10 @@ bool Buffer::hasPalette() {
/* pitch is in bytes */
void Buffer::copyFromArray(const byte *buffer, int pitch) {
DEBUG_ENTER_FUNC();
-
+
// We use sourceSize because outside, they won't know what the true size is
copyFromRect(buffer, pitch, 0, 0, _sourceSize.width, _sourceSize.height);
-
+
DEBUG_EXIT_FUNC();
}
@@ -335,8 +334,8 @@ void Buffer::copyFromArray(const byte *buffer, int pitch) {
void Buffer::copyFromRect(const byte *buf, uint32 pitch, int destX, int destY, uint32 recWidth, uint32 recHeight) {
// Removed silly clipping code
DEBUG_ENTER_FUNC();
- assert (_pixels);
-
+ assert(_pixels);
+
if (recWidth > _sourceSize.width - destX) {
recWidth = _sourceSize.width - destX;
}
@@ -351,7 +350,7 @@ void Buffer::copyFromRect(const byte *buf, uint32 pitch, int destX, int destY, u
}
byte *dst = _pixels + _pixelFormat.pixelsToBytes((destY * _width) + destX);
-
+
uint32 recWidthInBytes = _pixelFormat.pixelsToBytes(recWidth);
uint32 realWidthInBytes = _pixelFormat.pixelsToBytes(_width);
@@ -366,15 +365,15 @@ void Buffer::copyFromRect(const byte *buf, uint32 pitch, int destX, int destY, u
dst += realWidthInBytes;
} while (--recHeight);
}
-
+
DEBUG_EXIT_FUNC();
}
/* pitch is in bytes */
void Buffer::copyToArray(byte *dst, int pitch) {
DEBUG_ENTER_FUNC();
- assert (_pixels);
-
+ assert(_pixels);
+
uint32 h = _height;
byte *src = _pixels;
uint32 sourceWidthInBytes = _pixelFormat.pixelsToBytes(_sourceSize.width);
@@ -386,7 +385,7 @@ void Buffer::copyToArray(byte *dst, int pitch) {
src += realWidthInBytes;
dst += pitch;
} while (--h);
-
+
DEBUG_EXIT_FUNC();
}
@@ -395,7 +394,7 @@ void Buffer::copyToArray(byte *dst, int pitch) {
void Buffer::setSize(uint32 width, uint32 height, HowToSize textureOrSource/*=kSizeByTextureSize*/) {
DEBUG_ENTER_FUNC();
PSP_DEBUG_PRINT("w[%u], h[%u], %s\n", width, height, textureOrSource ? "size by source" : "size by texture");
-
+
_sourceSize.width = width;
_sourceSize.height = height;
@@ -405,18 +404,17 @@ void Buffer::setSize(uint32 width, uint32 height, HowToSize textureOrSource/*=kS
if (textureOrSource == kSizeByTextureSize) {
_width = _textureSize.width;
_height = _textureSize.height;
- }
- else { /* kSizeBySourceSize */
+ } else { /* kSizeBySourceSize */
_width = _sourceSize.width;
_height = _sourceSize.height;
}
-
+
DEBUG_EXIT_FUNC();
}
/* Scale a dimension (width/height) up to power of 2 for the texture */
uint32 Buffer::scaleUpToPowerOfTwo(uint32 size) {
-
+
uint32 textureDimension = 0;
if (size <= 16)
textureDimension = 16;
@@ -430,7 +428,7 @@ uint32 Buffer::scaleUpToPowerOfTwo(uint32 size) {
textureDimension = 256;
else
textureDimension = 512;
-
+
PSP_DEBUG_PRINT("power of 2 = %u\n", textureDimension);
return textureDimension;
@@ -438,7 +436,7 @@ uint32 Buffer::scaleUpToPowerOfTwo(uint32 size) {
bool Buffer::allocate(bool inVram/*=false*/) {
DEBUG_ENTER_FUNC();
-
+
PSP_DEBUG_PRINT("_width[%u], _height[%u]\n", _width, _height);
PSP_DEBUG_PRINT("_pixelFormat: format[%u], bpp[%u]\n", _pixelFormat.format, _pixelFormat.bitsPerPixel);
@@ -446,17 +444,17 @@ bool Buffer::allocate(bool inVram/*=false*/) {
if (VramAllocator::isAddressInVram(_pixels)) // Check if in VRAM
VramAllocator::instance().deallocate(_pixels);
else // not in VRAM
- free (CACHED(_pixels));
-
- _pixels = 0;
+ free(CACHED(_pixels));
+
+ _pixels = 0;
}
uint32 size = getSizeInBytes();
-
+
if (inVram) {
_pixels = (byte *)VramAllocator::instance().allocate(size);
- }
-
+ }
+
if (!_pixels) { // Either we are not in vram or we didn't manage to allocate in vram
// Align to 64 bytes. All normal buffer sizes are multiples of 64 anyway
_pixels = (byte *)memalign(64, size);
@@ -467,7 +465,7 @@ bool Buffer::allocate(bool inVram/*=false*/) {
DEBUG_EXIT_FUNC();
return false;
}
-
+
// Use uncached memory
GuRenderer::cacheInvalidate(_pixels, size);
_pixels = UNCACHED(_pixels);
@@ -482,35 +480,35 @@ void Buffer::deallocate() {
if (!_pixels)
return;
-
+
if (VramAllocator::isAddressInVram(_pixels)) // Check if in VRAM
VramAllocator::instance().deallocate(_pixels);
else
free(CACHED(_pixels));
-
+
_pixels = 0;
-
+
DEBUG_EXIT_FUNC();
}
void Buffer::clear() {
DEBUG_ENTER_FUNC();
-
+
if (_pixels)
memset(_pixels, 0, getSizeInBytes());
-
+
DEBUG_EXIT_FUNC();
}
/* Convert 4 bit images to match weird PSP format */
void Buffer::flipNibbles() {
DEBUG_ENTER_FUNC();
-
- if (_pixelFormat.bitsPerPixel != 4)
+
+ if (_pixelFormat.bitsPerPixel != 4)
return;
-
- assert(_pixels);
-
+
+ assert(_pixels);
+
uint32 *dest = (uint32 *)_pixels;
for (uint32 i = 0; i < getSourceHeight(); i++) {
@@ -526,24 +524,24 @@ void Buffer::flipNibbles() {
// Print buffer contents to screen (only source size is printed out)
void Buffer::print(uint32 mask, uint32 numToPrint /*=0*/) {
assert(_pixels);
-
+
if (numToPrint > _sourceSize.width * _sourceSize.height || numToPrint == 0)
numToPrint = _sourceSize.width * _sourceSize.height;
-
+
PSP_INFO_PRINT("buffer: \n");
PSP_INFO_PRINT("width[%u], height[%u]\n\n", _sourceSize.width, _sourceSize.height);
-
- for (unsigned int i=0; i < _sourceSize.height; i++) {
- for (unsigned int j=0; j < _sourceSize.width; j++) {
+
+ for (unsigned int i = 0; i < _sourceSize.height; i++) {
+ for (unsigned int j = 0; j < _sourceSize.width; j++) {
if (numToPrint <= 0) // check if done
break;
-
+
byte *pcolor = &_pixels[_pixelFormat.pixelsToBytes((i * _width) + j)];
uint32 color = _pixelFormat.getColorValueAt(pcolor);
-
+
//if (color != 0) PSP_INFO_PRINT("[%x] ", color);
PSP_INFO_PRINT("[%x] ", mask & color);
-
+
numToPrint--;
}
PSP_INFO_PRINT("\n");
@@ -563,16 +561,16 @@ void GuRenderer::render() {
PSP_DEBUG_PRINT("Buffer[%p] Palette[%p]\n", _buffer->getPixels(), _palette->getRawValues());
setMaxTextureOffsetByIndex(0, 0);
-
+
guProgramDrawBehavior();
-
+
if (_buffer->hasPalette())
guLoadPalette();
-
+
guProgramTextureFormat();
guLoadTexture();
-
- Vertex *vertices = guGetVertices();
+
+ Vertex *vertices = guGetVertices();
fillVertices(vertices);
guDrawVertices(vertices);
@@ -581,17 +579,17 @@ void GuRenderer::render() {
setMaxTextureOffsetByIndex(1, 0);
guLoadTexture();
-
+
vertices = guGetVertices();
fillVertices(vertices);
guDrawVertices(vertices);
}
-
+
DEBUG_EXIT_FUNC();
}
-inline void GuRenderer::setMaxTextureOffsetByIndex(uint32 x, uint32 y) {
+inline void GuRenderer::setMaxTextureOffsetByIndex(uint32 x, uint32 y) {
DEBUG_ENTER_FUNC();
const uint32 maxTextureSizeShift = 9; /* corresponds to 512 = max texture size*/
@@ -603,18 +601,18 @@ inline void GuRenderer::setMaxTextureOffsetByIndex(uint32 x, uint32 y) {
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", _alphaReverse ? "on" : "off", _keyColor);
-
+
if (_blending) {
sceGuEnable(GU_BLEND);
if (_alphaReverse) // Reverse the alpha value (0 is 1)
sceGuBlendFunc(GU_ADD, GU_ONE_MINUS_SRC_ALPHA, GU_SRC_ALPHA, 0, 0);
else // Normal alpha values
- sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0);
+ sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0);
- } else
+ } else
sceGuDisable(GU_BLEND);
-
+
if (_colorTest) {
sceGuEnable(GU_COLOR_TEST);
sceGuColorFunc(GU_NOTEQUAL, _keyColor, 0x00ffffff);
@@ -626,9 +624,9 @@ inline void GuRenderer::guProgramDrawBehavior() {
inline void GuRenderer::guLoadPalette() {
DEBUG_ENTER_FUNC();
-
+
uint32 mask;
-
+
if (_buffer->getBitsPerPixel() == 4)
mask = 0x0F;
else if (_buffer->getBitsPerPixel() == 8)
@@ -637,70 +635,70 @@ inline void GuRenderer::guLoadPalette() {
assert(0); /* error */
PSP_DEBUG_PRINT("numOfEntries[%d]\n", _palette->getNumOfEntries());
- PSP_DEBUG_PRINT("bpp[%d], pixelformat[%d], mask[%x]\n", _buffer->getBitsPerPixel(), _palette->getPixelFormat(), mask);
-
+ PSP_DEBUG_PRINT("bpp[%d], pixelformat[%d], mask[%x]\n", _buffer->getBitsPerPixel(), _palette->getPixelFormat(), mask);
+
sceGuClutMode(convertToGuPixelFormat(_palette->getPixelFormat()), 0, mask, 0);
sceGuClutLoad(_palette->getNumOfEntries() >> 3, _palette->getRawValues());
-
+
DEBUG_EXIT_FUNC();
}
inline void GuRenderer::guProgramTextureFormat() {
DEBUG_ENTER_FUNC();
PSP_DEBUG_PRINT("pixelFormat[%d]\n", _buffer->getPixelFormat());
-
+
sceGuTexMode(convertToGuPixelFormat(_buffer->getPixelFormat()), 0, 0, 0);
DEBUG_EXIT_FUNC();
}
-inline uint32 GuRenderer::convertToGuPixelFormat(PSPPixelFormat::Type format) {
- DEBUG_ENTER_FUNC();
-
- uint32 guFormat = 0;
-
- switch (format) {
- case PSPPixelFormat::Type_4444:
- guFormat = GU_PSM_4444;
- break;
- case PSPPixelFormat::Type_5551:
- guFormat = GU_PSM_5551;
- break;
- case PSPPixelFormat::Type_5650:
- guFormat = GU_PSM_5650;
- break;
- case PSPPixelFormat::Type_8888:
- guFormat = GU_PSM_8888;
- break;
- case PSPPixelFormat::Type_Palette_8bit:
- guFormat = GU_PSM_T8;
- break;
- case PSPPixelFormat::Type_Palette_4bit:
- guFormat = GU_PSM_T4;
- break;
- default:
- break;
+inline uint32 GuRenderer::convertToGuPixelFormat(PSPPixelFormat::Type format) {
+ DEBUG_ENTER_FUNC();
+
+ uint32 guFormat = 0;
+
+ switch (format) {
+ case PSPPixelFormat::Type_4444:
+ guFormat = GU_PSM_4444;
+ break;
+ case PSPPixelFormat::Type_5551:
+ guFormat = GU_PSM_5551;
+ break;
+ case PSPPixelFormat::Type_5650:
+ guFormat = GU_PSM_5650;
+ break;
+ case PSPPixelFormat::Type_8888:
+ guFormat = GU_PSM_8888;
+ break;
+ case PSPPixelFormat::Type_Palette_8bit:
+ guFormat = GU_PSM_T8;
+ break;
+ case PSPPixelFormat::Type_Palette_4bit:
+ guFormat = GU_PSM_T4;
+ break;
+ default:
+ break;
}
-
+
PSP_DEBUG_PRINT("Pixelformat[%d], guFormat[%d]\n", format, guFormat);
-
+
DEBUG_EXIT_FUNC();
return guFormat;
-
+
}
inline void GuRenderer::guLoadTexture() {
DEBUG_ENTER_FUNC();
-
+
sceGuTexImage(0, _buffer->getTextureWidth(), _buffer->getTextureHeight(), _buffer->getWidth(), _buffer->getPixels() + _buffer->_pixelFormat.pixelsToBytes(_maxTextureOffset.x));
-
+
DEBUG_EXIT_FUNC();
}
inline Vertex *GuRenderer::guGetVertices() {
DEBUG_ENTER_FUNC();
-
+
Vertex *ret = (Vertex *)sceGuGetMemory(2 * sizeof(Vertex));
-
+
DEBUG_EXIT_FUNC();
return ret;
}
@@ -708,19 +706,19 @@ inline Vertex *GuRenderer::guGetVertices() {
// Fills the vertices. Most of the logic is here.
void GuRenderer::fillVertices(Vertex *vertices) {
DEBUG_ENTER_FUNC();
-
+
uint32 outputWidth = _displayManager->getOutputWidth();
uint32 outputHeight = _displayManager->getOutputHeight();
float textureStartX, textureStartY, textureEndX, textureEndY;
-
+
// Texture adjustments for eliminating half-pixel artifacts from scaling
// Not necessary if we don't scale
float textureAdjustment = 0.0f;
- if (_useGlobalScaler &&
- (_displayManager->getScaleX() != 1.0f || _displayManager->getScaleX() != 1.0f))
- textureAdjustment = 0.5f;
-
+ if (_useGlobalScaler &&
+ (_displayManager->getScaleX() != 1.0f || _displayManager->getScaleX() != 1.0f))
+ textureAdjustment = 0.5f;
+
textureStartX = textureAdjustment + _offsetInBuffer.x; //debug
textureStartY = textureAdjustment + _offsetInBuffer.y;
// We subtract maxTextureOffset because our shifted texture starts at 512 and will go to 640
@@ -730,15 +728,15 @@ void GuRenderer::fillVertices(Vertex *vertices) {
// For scaling to the final image size, calculate the gaps on both sides
uint32 gapX = _useGlobalScaler ? (PSP_SCREEN_WIDTH - outputWidth) >> 1 : 0;
uint32 gapY = _useGlobalScaler ? (PSP_SCREEN_HEIGHT - outputHeight) >> 1 : 0;
-
+
float imageStartX, imageStartY, imageEndX, imageEndY;
- imageStartX = gapX + ( scaleSourceToOutputX(_maxTextureOffset.x) );
+ imageStartX = gapX + (scaleSourceToOutputX(_maxTextureOffset.x));
imageStartY = gapY;
imageStartX += scaleSourceToOutputX(_offsetOnScreen.x);
imageStartY += scaleSourceToOutputY(_offsetOnScreen.y);
-
+
if (_fullScreen) { // shortcut
imageEndX = PSP_SCREEN_WIDTH - gapX;
imageEndY = PSP_SCREEN_HEIGHT - gapY;
@@ -751,52 +749,52 @@ void GuRenderer::fillVertices(Vertex *vertices) {
vertices[0].v = textureStartY;
vertices[1].u = textureEndX;
vertices[1].v = textureEndY;
-
+
vertices[0].x = imageStartX;
vertices[0].y = imageStartY;
vertices[0].z = 0;
vertices[1].x = imageEndX;
vertices[1].y = imageEndY;
vertices[1].z = 0;
-
+
PSP_DEBUG_PRINT("TextureStart: X[%f] Y[%f] TextureEnd: X[%.1f] Y[%.1f]\n", textureStartX, textureStartY, textureEndX, textureEndY);
PSP_DEBUG_PRINT("ImageStart: X[%f] Y[%f] ImageEnd: X[%.1f] Y[%.1f]\n", imageStartX, imageStartY, imageEndX, imageEndY);
-
+
DEBUG_EXIT_FUNC();
}
/* Scale the input X offset to appear in proper position on the screen */
inline float GuRenderer::scaleSourceToOutputX(float offset) {
float result;
-
+
if (!_useGlobalScaler)
result = offset;
else if (!offset)
- result = 0.0f;
+ result = 0.0f;
else
result = offset * _displayManager->getScaleX();
-
+
return result;
}
/* Scale the input Y offset to appear in proper position on the screen */
inline float GuRenderer::scaleSourceToOutputY(float offset) {
float result;
-
+
if (!_useGlobalScaler)
result = offset;
else if (!offset)
result = 0.0f;
- else
+ else
result = offset * _displayManager->getScaleY();
-
+
return result;
}
inline void GuRenderer::guDrawVertices(Vertex *vertices) {
DEBUG_ENTER_FUNC();
-
- sceGuDrawArray(GU_SPRITES, GU_TEXTURE_32BITF|GU_VERTEX_32BITF|GU_TRANSFORM_2D, 2, 0, vertices);
+
+ sceGuDrawArray(GU_SPRITES, GU_TEXTURE_32BITF | GU_VERTEX_32BITF | GU_TRANSFORM_2D, 2, 0, vertices);
DEBUG_EXIT_FUNC();
}
diff --git a/backends/platform/psp/display_client.h b/backends/platform/psp/display_client.h
index d96504ad04..8d0f827415 100644
--- a/backends/platform/psp/display_client.h
+++ b/backends/platform/psp/display_client.h
@@ -22,7 +22,7 @@
* $Id: osys_psp.cpp 46126 2009-11-24 14:18:46Z fingolfin $
*
*/
-
+
#ifndef PSP_GRAPHICS_H
#define PSP_GRAPHICS_H
@@ -31,8 +31,8 @@
#include "common/system.h"
#include "backends/platform/psp/psppixelformat.h"
#include "backends/platform/psp/memory.h"
-
-#define MAX_TEXTURE_SIZE 512
+
+#define MAX_TEXTURE_SIZE 512
class DisplayManager;
class GuRenderer;
@@ -50,13 +50,13 @@ public:
void render() {}
virtual ~DisplayClient() {}
};
-
+
/**
* Vertex used for GU rendering
*/
struct Vertex {
- float u,v;
- float x,y,z;
+ float u, v;
+ float x, y, z;
};
struct Point {
@@ -101,7 +101,7 @@ public:
bool isAllocated() { return (_values != 0); }
PSPPixelFormat::Type getPixelFormat() { return _pixelFormat.format; }
void print(uint32 numToPrint = 0); // print to screen
-
+
protected:
byte *_values; ///< array of palette data
uint32 _numOfEntries; ///< number of palette entries
@@ -122,9 +122,9 @@ public:
Buffer() : _pixels(0), _width(0), _height(0) {}
virtual ~Buffer() { deallocate(); }
-
+
// setters
- void setSize(uint32 width, uint32 height, HowToSize textureOrSource=kSizeByTextureSize);
+ void setSize(uint32 width, uint32 height, HowToSize textureOrSource = kSizeByTextureSize);
void setBitsPerPixel(uint32 bits) { _pixelFormat.bitsPerPixel = bits; }
void setBytesPerPixel(uint32 bytes) { setBitsPerPixel(bytes << 3); }
void setPixelFormat(PSPPixelFormat::Type type, bool swapRedBlue = false);
@@ -135,7 +135,7 @@ public:
uint32 getHeight() { return _height; }
uint32 getSourceWidth() { return _sourceSize.width; }
uint32 getSourceWidthInBytes() { return _pixelFormat.pixelsToBytes(_sourceSize.width); }
- uint32 getSourceHeight() { return _sourceSize.height; }
+ uint32 getSourceHeight() { return _sourceSize.height; }
uint32 getTextureWidth() { return _textureSize.width; }
uint32 getTextureHeight() { return _textureSize.height; }
PSPPixelFormat::Type getPixelFormat() { return _pixelFormat.format; }
@@ -143,7 +143,7 @@ public:
uint32 getBytesPerPixel() { return getBitsPerPixel() >> 3; } /* won't work for 4-bit */
byte *getPixels() { return _pixels; }
uint32 getSizeInBytes() { return _pixelFormat.pixelsToBytes(_width * _height); }
-
+
bool hasPalette();
void copyFromArray(const byte *buffer, int pitch);
void copyFromRect(const byte *buf, uint32 pitch, int destX, int destY, uint32 recWidth, uint32 recHeight);
@@ -155,7 +155,7 @@ public:
void flipNibbles(); // To handle peculiarities of PSP's 4 bit textures
static uint32 scaleUpToPowerOfTwo(uint32 size);
void print(uint32 mask, uint32 numToPrint = 0);
-
+
protected:
friend class GuRenderer;
byte *_pixels;
@@ -163,7 +163,7 @@ protected:
uint32 _height; ///< True allocated height
Dimensions _textureSize; ///< Size rounded up to power of 2. Used for drawing
Dimensions _sourceSize; ///< Original size of the buffer
- PSPPixelFormat _pixelFormat; ///< Format of the buffer
+ PSPPixelFormat _pixelFormat; ///< Format of the buffer
};
/**
@@ -177,19 +177,19 @@ public:
GuRenderer() : _useGlobalScaler(false), _buffer(0), _palette(0), _blending(false), _alphaReverse(false), _colorTest(false), _keyColor(0), _fullScreen(false) {}
GuRenderer(Buffer *buffer, Palette *palette) : _useGlobalScaler(false), _buffer(buffer), _palette(palette), _blending(false), _alphaReverse(false), _colorTest(false), _keyColor(0), _fullScreen(false) {}
static void setDisplayManager(DisplayManager *dm) { _displayManager = dm; } // Called by the Display Manager
-
+
// Setters
void setDrawSize(uint32 width, uint32 height) { // How big of an area to draw
- _drawSize.width = width;
- _drawSize.height = height;
+ _drawSize.width = width;
+ _drawSize.height = height;
}
void setDrawWholeBuffer() { // Draw the full size of the current buffer
assert(_buffer);
_drawSize.width = _buffer->getSourceWidth();
_drawSize.height = _buffer->getSourceHeight();
}
- void setBuffer(Buffer *buffer) { _buffer = buffer; }
- void setPalette(Palette *palette) { _palette = palette; }
+ void setBuffer(Buffer *buffer) { _buffer = buffer; }
+ void setPalette(Palette *palette) { _palette = palette; }
void setMaxTextureOffsetByIndex(uint32 x, uint32 y); // For drawing multiple textures
void setOffsetOnScreen(uint32 x, uint32 y) { _offsetOnScreen.x = x; _offsetOnScreen.y = y; }
void setOffsetInBuffer(uint32 x, uint32 y) { _offsetInBuffer.x = x; _offsetInBuffer.y = y; }
@@ -199,9 +199,9 @@ public:
void setAlphaReverse(bool value) { _alphaReverse = value; }
void setFullScreen(bool value) { _fullScreen = value; } // Shortcut for rendering
void setUseGlobalScaler(bool value) { _useGlobalScaler = value; } // Scale to screen
-
+
static void cacheInvalidate(void *pointer, uint32 size);
-
+
void render(); // Default rendering function. This should be good enough for most purposes
protected:
@@ -209,7 +209,7 @@ protected:
void fillVertices(Vertex *vertices); // Fill in vertices with coordinates
void guProgramDrawBehavior();
Vertex *guGetVertices();
- void guLoadTexture();
+ void guLoadTexture();
void guLoadPalette();
void guProgramTextureFormat();
void guProgramTextureBitDepth();
@@ -218,7 +218,7 @@ protected:
uint32 convertToGuPixelFormat(PSPPixelFormat::Type format);
float scaleSourceToOutputX(float offset);
float scaleSourceToOutputY(float offset);
-
+
friend class MasterGuRenderer;
Point _maxTextureOffset; ///> For rendering textures > 512 pixels
Point _offsetOnScreen; ///> Where on screen to draw
diff --git a/backends/platform/psp/display_manager.cpp b/backends/platform/psp/display_manager.cpp
index a556a6e65f..0bec1c6278 100644
--- a/backends/platform/psp/display_manager.cpp
+++ b/backends/platform/psp/display_manager.cpp
@@ -48,7 +48,7 @@
uint32 __attribute__((aligned(16))) MasterGuRenderer::_displayList[2048];
- const OSystem::GraphicsMode DisplayManager::_supportedModes[] = {
+const OSystem::GraphicsMode DisplayManager::_supportedModes[] = {
{ "320x200 (centered)", "320x200 16-bit centered", CENTERED_320X200 },
{ "435x272 (best-fit, centered)", "435x272 16-bit centered", CENTERED_435X272 },
{ "480x272 (full screen)", "480x272 16-bit stretched", STRETCHED_480X272 },
@@ -61,13 +61,13 @@ uint32 __attribute__((aligned(16))) MasterGuRenderer::_displayList[2048];
void MasterGuRenderer::guInit() {
DEBUG_ENTER_FUNC();
-
+
sceGuInit();
sceGuStart(0, _displayList);
-
+
guProgramDisplayBufferSizes();
-
- sceGuOffset(2048 - (PSP_SCREEN_WIDTH/2), 2048 - (PSP_SCREEN_HEIGHT/2));
+
+ sceGuOffset(2048 - (PSP_SCREEN_WIDTH / 2), 2048 - (PSP_SCREEN_HEIGHT / 2));
sceGuViewport(2048, 2048, PSP_SCREEN_WIDTH, PSP_SCREEN_HEIGHT);
sceGuDepthRange(0xC350, 0x2710);
sceGuDisable(GU_DEPTH_TEST); // We'll use depth buffer area
@@ -77,13 +77,13 @@ void MasterGuRenderer::guInit() {
sceGuFrontFace(GU_CW);
sceGuEnable(GU_TEXTURE_2D);
- sceGuClear(GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT);
+ sceGuClear(GU_COLOR_BUFFER_BIT | GU_DEPTH_BUFFER_BIT);
sceGuFinish();
- sceGuSync(0,0);
+ sceGuSync(0, 0);
sceDisplayWaitVblankStart();
sceGuDisplay(1);
-
+
DEBUG_EXIT_FUNC();
}
@@ -91,7 +91,7 @@ void MasterGuRenderer::guProgramDisplayBufferSizes() {
DEBUG_ENTER_FUNC();
PSP_DEBUG_PRINT("Outputbits[%u]\n", GuRenderer::_displayManager->getOutputBitsPerPixel());
-
+
switch (GuRenderer::_displayManager->getOutputBitsPerPixel()) {
case 16:
sceGuDrawBuffer(GU_PSM_4444, (void *)0, PSP_BUFFER_WIDTH);
@@ -106,7 +106,7 @@ void MasterGuRenderer::guProgramDisplayBufferSizes() {
VramAllocator::instance().allocate(PSP_FRAME_SIZE * sizeof(uint32) * 2);
break;
}
-
+
DEBUG_EXIT_FUNC();
}
@@ -116,38 +116,38 @@ inline void MasterGuRenderer::guPreRender() {
#ifdef ENABLE_RENDER_MEASURE
_lastRenderTime = g_system->getMillis();
-#endif /* ENABLE_RENDER_MEASURE */
-
+#endif /* ENABLE_RENDER_MEASURE */
+
sceGuStart(0, _displayList);
sceGuClearColor(0xFF000000);
sceGuClear(GU_COLOR_BUFFER_BIT);
-
+
sceGuAmbientColor(0xFFFFFFFF);
sceGuColor(0xFFFFFFFF);
- sceGuTexOffset(0,0);
+ sceGuTexOffset(0, 0);
sceGuTexFilter(GU_LINEAR, GU_LINEAR);
-
+
sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGBA); // Also good enough for all purposes
sceGuAlphaFunc(GU_GREATER, 0, 0xFF); // Also good enough for all purposes
-
+
DEBUG_EXIT_FUNC();
}
inline void MasterGuRenderer::guPostRender() {
DEBUG_ENTER_FUNC();
-
+
sceGuFinish();
- sceGuSync(0,0);
+ sceGuSync(0, 0);
#ifdef ENABLE_RENDER_MEASURE
uint32 now = g_system->getMillis();
PSP_INFO_PRINT("Render took %d milliseconds\n", now - _lastRenderTime);
#endif /* ENABLE_RENDER_MEASURE */
-
+
sceDisplayWaitVblankStart();
sceGuSwapBuffers();
-
+
DEBUG_EXIT_FUNC();
}
@@ -164,16 +164,16 @@ DisplayManager::~DisplayManager() {
void DisplayManager::init() {
DEBUG_ENTER_FUNC();
-
+
_displayParams.outputBitsPerPixel = 32; // can be changed to produce 16-bit output
-
+
GuRenderer::setDisplayManager(this);
_screen->init();
_overlay->init();
_cursor->init();
-
+
_masterGuRenderer.guInit(); // start up the renderer
-
+
DEBUG_EXIT_FUNC();
}
@@ -184,21 +184,21 @@ void DisplayManager::setSizeAndPixelFormat(uint width, uint height, const Graphi
_overlay->deallocate();
_screen->deallocate();
-
+
_screen->setScummvmPixelFormat(format);
_screen->setSize(width, height);
_screen->allocate();
-
+
_cursor->setScreenPaletteScummvmPixelFormat(format);
_overlay->setBytesPerPixel(sizeof(OverlayColor));
_overlay->setSize(PSP_SCREEN_WIDTH, PSP_SCREEN_HEIGHT);
_overlay->allocate();
-
+
_displayParams.screenSource.width = width;
_displayParams.screenSource.height = height;
calculateScaleParams();
-
+
DEBUG_EXIT_FUNC();
}
@@ -245,16 +245,16 @@ bool DisplayManager::setGraphicsMode(int mode) {
default:
PSP_ERROR("Unsupported graphics mode[%d].\n", _graphicsMode);
}
-
+
calculateScaleParams();
-
+
DEBUG_EXIT_FUNC();
return true;
}
void DisplayManager::calculateScaleParams() {
if (_displayParams.screenOutput.width && _displayParams.screenSource.width &&
- _displayParams.screenOutput.height && _displayParams.screenSource.height) {
+ _displayParams.screenOutput.height && _displayParams.screenSource.height) {
_displayParams.scaleX = ((float)_displayParams.screenOutput.width) / _displayParams.screenSource.width;
_displayParams.scaleY = ((float)_displayParams.screenOutput.height) / _displayParams.screenSource.height;
}
@@ -268,43 +268,43 @@ void DisplayManager::renderAll() {
return;
}
- if (!_screen->isDirty() &&
- (!_overlay->isDirty()) &&
- (!_cursor->isDirty()) &&
- (!_keyboard->isDirty())) {
+ if (!_screen->isDirty() &&
+ (!_overlay->isDirty()) &&
+ (!_cursor->isDirty()) &&
+ (!_keyboard->isDirty())) {
PSP_DEBUG_PRINT("Nothing dirty\n");
DEBUG_EXIT_FUNC();
return;
}
-
+
PSP_DEBUG_PRINT("screen[%s], overlay[%s], cursor[%s], keyboard[%s]\n",
- _screen->isDirty() ? "true" : "false",
- _overlay->isDirty() ? "true" : "false",
- _cursor->isDirty() ? "true" : "false",
- _keyboard->isDirty() ? "true" : "false"
- );
+ _screen->isDirty() ? "true" : "false",
+ _overlay->isDirty() ? "true" : "false",
+ _cursor->isDirty() ? "true" : "false",
+ _keyboard->isDirty() ? "true" : "false"
+ );
_masterGuRenderer.guPreRender(); // Set up rendering
_screen->render();
-
+
_screen->setClean(); // clean out dirty bit
if (_overlay->isVisible())
_overlay->render();
-
+
_overlay->setClean();
-
+
if (_cursor->isVisible())
_cursor->render();
-
+
_cursor->setClean();
if (_keyboard->isVisible())
_keyboard->render();
-
+
_keyboard->setClean();
-
+
_masterGuRenderer.guPostRender();
DEBUG_EXIT_FUNC();
@@ -321,16 +321,16 @@ inline bool DisplayManager::isTimeToUpdate() {
_lastUpdateTime = now;
return true;
}
-
+
Common::List<Graphics::PixelFormat> DisplayManager::getSupportedPixelFormats() {
Common::List<Graphics::PixelFormat> list;
-
+
// In order of preference
list.push_back(PSPPixelFormat::convertToScummvmPixelFormat(PSPPixelFormat::Type_5650));
list.push_back(PSPPixelFormat::convertToScummvmPixelFormat(PSPPixelFormat::Type_5551));
list.push_back(PSPPixelFormat::convertToScummvmPixelFormat(PSPPixelFormat::Type_4444));
list.push_back(Graphics::PixelFormat::createFormatCLUT8());
-
+
return list;
}
diff --git a/backends/platform/psp/display_manager.h b/backends/platform/psp/display_manager.h
index de5fcf94c8..54b4b78938 100644
--- a/backends/platform/psp/display_manager.h
+++ b/backends/platform/psp/display_manager.h
@@ -24,7 +24,7 @@
*/
#ifndef PSP_DISPLAY_MAN_H
-#define PSP_DISPLAY_MAN_H
+#define PSP_DISPLAY_MAN_H
/**
* Class used only by DisplayManager to start/stop GU rendering
@@ -60,13 +60,13 @@ public:
};
DisplayManager() : _screen(0), _cursor(0), _overlay(0), _keyboard(0), _lastUpdateTime(0), _graphicsMode(0) {}
~DisplayManager();
-
+
void init();
void renderAll();
bool setGraphicsMode(int mode);
bool setGraphicsMode(const char *name);
int getGraphicsMode() const { return _graphicsMode; }
- uint32 getDefaultGraphicsMode() const { return STRETCHED_480X272; }
+ uint32 getDefaultGraphicsMode() const { return STRETCHED_480X272; }
const OSystem::GraphicsMode* getSupportedGraphicsModes() const { return _supportedModes; }
// Setters
@@ -99,15 +99,15 @@ private:
Cursor *_cursor;
Overlay *_overlay;
PSPKeyboard *_keyboard;
-
+
MasterGuRenderer _masterGuRenderer;
uint32 _lastUpdateTime; // For limiting FPS
int _graphicsMode;
GlobalDisplayParams _displayParams;
static const OSystem::GraphicsMode _supportedModes[];
-
+
void calculateScaleParams(); // calculates scaling factor
- bool isTimeToUpdate(); // should we update the screen now
+ bool isTimeToUpdate(); // should we update the screen now
};
diff --git a/backends/platform/psp/elf32.h b/backends/platform/psp/elf32.h
index a7cebe37dd..616cc4b4d2 100644
--- a/backends/platform/psp/elf32.h
+++ b/backends/platform/psp/elf32.h
@@ -23,10 +23,10 @@
*
*/
- #ifndef BACKENDS_ELF_H
- #define BACKENDS_ELF_H
+#ifndef BACKENDS_ELF_H
+#define BACKENDS_ELF_H
- /* ELF stuff */
+/* ELF stuff */
typedef unsigned short Elf32_Half, Elf32_Section;
typedef unsigned int Elf32_Word, Elf32_Addr, Elf32_Off;
@@ -39,22 +39,21 @@ typedef Elf32_Half Elf32_Versym;
/* ELF File format structures. Look up ELF structure for more details */
// ELF header (contains info about the file)
-typedef struct
-{
- unsigned char e_ident[EI_NIDENT]; /* Magic number and other info */
- Elf32_Half e_type; /* Object file type */
- Elf32_Half e_machine; /* Architecture */
- Elf32_Word e_version; /* Object file version */
- Elf32_Addr e_entry; /* Entry point virtual address */
- Elf32_Off e_phoff; /* Program header table file offset */
- Elf32_Off e_shoff; /* Section header table file offset */
- Elf32_Word e_flags; /* Processor-specific flags */
- Elf32_Half e_ehsize; /* ELF header size in bytes */
- Elf32_Half e_phentsize; /* Program header table entry size */
- Elf32_Half e_phnum; /* Program header table entry count */
- Elf32_Half e_shentsize; /* Section header table entry size */
- Elf32_Half e_shnum; /* Section header table entry count */
- Elf32_Half e_shstrndx; /* Section header string table index */
+typedef struct {
+ unsigned char e_ident[EI_NIDENT]; /* Magic number and other info */
+ Elf32_Half e_type; /* Object file type */
+ Elf32_Half e_machine; /* Architecture */
+ Elf32_Word e_version; /* Object file version */
+ Elf32_Addr e_entry; /* Entry point virtual address */
+ Elf32_Off e_phoff; /* Program header table file offset */
+ Elf32_Off e_shoff; /* Section header table file offset */
+ Elf32_Word e_flags; /* Processor-specific flags */
+ Elf32_Half e_ehsize; /* ELF header size in bytes */
+ Elf32_Half e_phentsize; /* Program header table entry size */
+ Elf32_Half e_phnum; /* Program header table entry count */
+ Elf32_Half e_shentsize; /* Section header table entry size */
+ Elf32_Half e_shnum; /* Section header table entry count */
+ Elf32_Half e_shstrndx; /* Section header string table index */
} Elf32_Ehdr;
// Should be in e_ident
@@ -72,16 +71,15 @@ typedef struct
// Program header (contains info about segment)
-typedef struct
-{
- Elf32_Word p_type; /* Segment type */
- Elf32_Off p_offset; /* Segment file offset */
- Elf32_Addr p_vaddr; /* Segment virtual address */
- Elf32_Addr p_paddr; /* Segment physical address */
- Elf32_Word p_filesz; /* Segment size in file */
- Elf32_Word p_memsz; /* Segment size in memory */
- Elf32_Word p_flags; /* Segment flags */
- Elf32_Word p_align; /* Segment alignment */
+typedef struct {
+ Elf32_Word p_type; /* Segment type */
+ Elf32_Off p_offset; /* Segment file offset */
+ Elf32_Addr p_vaddr; /* Segment virtual address */
+ Elf32_Addr p_paddr; /* Segment physical address */
+ Elf32_Word p_filesz; /* Segment size in file */
+ Elf32_Word p_memsz; /* Segment size in memory */
+ Elf32_Word p_flags; /* Segment flags */
+ Elf32_Word p_align; /* Segment alignment */
} Elf32_Phdr;
// p_type values
@@ -100,18 +98,17 @@ typedef struct
#define PF_R 4 /* read */
// Section header (contains info about section)
-typedef struct
-{
- Elf32_Word sh_name; /* Section name (string tbl index) */
- Elf32_Word sh_type; /* Section type */
- Elf32_Word sh_flags; /* Section flags */
- Elf32_Addr sh_addr; /* Section virtual addr at execution */
- Elf32_Off sh_offset; /* Section file offset */
- Elf32_Word sh_size; /* Section size in bytes */
- Elf32_Word sh_link; /* Link to another section */
- Elf32_Word sh_info; /* Additional section information */
- Elf32_Word sh_addralign; /* Section alignment */
- Elf32_Word sh_entsize; /* Entry size if section holds table */
+typedef struct {
+ Elf32_Word sh_name; /* Section name (string tbl index) */
+ Elf32_Word sh_type; /* Section type */
+ Elf32_Word sh_flags; /* Section flags */
+ Elf32_Addr sh_addr; /* Section virtual addr at execution */
+ Elf32_Off sh_offset; /* Section file offset */
+ Elf32_Word sh_size; /* Section size in bytes */
+ Elf32_Word sh_link; /* Link to another section */
+ Elf32_Word sh_info; /* Additional section information */
+ Elf32_Word sh_addralign; /* Section alignment */
+ Elf32_Word sh_entsize; /* Entry size if section holds table */
} Elf32_Shdr;
// sh_type values
@@ -139,14 +136,13 @@ typedef struct
// Symbol entry (contain info about a symbol)
-typedef struct
-{
- Elf32_Word st_name; /* Symbol name (string tbl index) */
- Elf32_Addr st_value; /* Symbol value */
- Elf32_Word st_size; /* Symbol size */
- unsigned char st_info; /* Symbol type and binding */
- unsigned char st_other; /* Symbol visibility */
- Elf32_Section st_shndx; /* Section index */
+typedef struct {
+ Elf32_Word st_name; /* Symbol name (string tbl index) */
+ Elf32_Addr st_value; /* Symbol value */
+ Elf32_Word st_size; /* Symbol size */
+ unsigned char st_info; /* Symbol type and binding */
+ unsigned char st_other; /* Symbol visibility */
+ Elf32_Section st_shndx; /* Section index */
} Elf32_Sym;
// Extract from the st_info
@@ -175,10 +171,9 @@ typedef struct
#define SHN_HIRESERVE 0xFFFF
// Relocation entry (info about how to relocate)
-typedef struct
-{
- Elf32_Addr r_offset; /* Address */
- Elf32_Word r_info; /* Relocation type and symbol index */
+typedef struct {
+ Elf32_Addr r_offset; /* Address */
+ Elf32_Word r_info; /* Relocation type and symbol index */
} Elf32_Rel;
// Access macros for the relocation info
@@ -211,4 +206,4 @@ typedef struct
__valgp; \
})
- #endif /* BACKENDS_ELF_H */
+#endif /* BACKENDS_ELF_H */
diff --git a/backends/platform/psp/input.cpp b/backends/platform/psp/input.cpp
index bd33175f03..be0530ecf1 100644
--- a/backends/platform/psp/input.cpp
+++ b/backends/platform/psp/input.cpp
@@ -21,14 +21,14 @@
* $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/trunk/backends/platform/psp/osys_psp.cpp $
* $Id: osys_psp.cpp 43618 2009-08-21 22:44:49Z joostp $
*
- */
+ */
-// Todo: handle events that should fire because of shift going off
+// Todo: handle events that should fire because of shift going off
// Solution: handle shift on a button-by-button basis, only allowing it when the button is up. Also a inputmap-wide button. At buttonup, shiftstate is inspected per button.
-
+
//#define __PSP_DEBUG_FUNCS__ /* Uncomment for debugging the stack */
//#define __PSP_DEBUG_PRINT__ /* Uncomment for debug prints */
-
+
#include "backends/platform/psp/trace.h"
#include "backends/platform/psp/input.h"
@@ -52,7 +52,7 @@ void InputHandler::init() {
bool InputHandler::getAllInputs(Common::Event &event) {
DEBUG_ENTER_FUNC();
-
+
uint32 time = g_system->getMillis(); // may not be necessary with read
if (time - _lastPadCheckTime < PAD_CHECK_TIME) {
DEBUG_EXIT_FUNC();
@@ -70,17 +70,16 @@ bool InputHandler::getAllInputs(Common::Event &event) {
if (_keyboard->isVisible())
haveEvent = _keyboard->processInput(event, pad);
- else
+ else
haveEvent = getEvent(event, pad);
- if (haveEvent)
- {
+ if (haveEvent) {
PSP_DEBUG_PRINT("Have event[%s]\n", haveEvent ? "true" : "false");
PSP_DEBUG_PRINT("event.type[%d]\n", event.type);
- }
+ }
DEBUG_EXIT_FUNC();
-
+
return haveEvent;
}
@@ -92,22 +91,22 @@ bool InputHandler::getEvent(Common::Event &event, SceCtrlData &pad) {
// Collect events from different sources
haveEvent = getDpadEvent(event, pad);
-
+
if (!haveEvent)
haveEvent = getButtonEvent(event, pad);
-
+
if (!haveEvent)
- haveEvent = getNubEvent(event, pad);
+ haveEvent = getNubEvent(event, pad);
_prevButtons = pad.Buttons;
-
+
DEBUG_EXIT_FUNC();
return haveEvent;
}
bool InputHandler::getDpadEvent(Common::Event &event, SceCtrlData &pad) {
DEBUG_ENTER_FUNC();
-
+
int newDpadX = 0, newDpadY = 0;
bool haveEvent = false;
@@ -131,7 +130,7 @@ bool InputHandler::getDpadEvent(Common::Event &event, SceCtrlData &pad) {
if (DOWN(PSP_CTRL_RTRIGGER))
newDpadY++;
}
-
+
if (newDpadX != _dpadX || newDpadY != _dpadY) {
if (_dpadX == 0 && _dpadY == 0) { // We were in the middle so we pressed dpad
event.type = Common::EVENT_KEYDOWN;
@@ -139,8 +138,7 @@ bool InputHandler::getDpadEvent(Common::Event &event, SceCtrlData &pad) {
event.kbd.ascii = event.kbd.keycode - Common::KEYCODE_KP0 + '0'; // Get ascii
_dpadX = newDpadX;
_dpadY = newDpadY;
- }
- else if (newDpadX == 0 && newDpadY == 0) {// We're now centered so we unpressed dpad
+ } else if (newDpadX == 0 && newDpadY == 0) {// We're now centered so we unpressed dpad
event.type = Common::EVENT_KEYUP;
event.kbd.keycode = translateDpad(_dpadX, _dpadY);
event.kbd.ascii = event.kbd.keycode - Common::KEYCODE_KP0 + '0';
@@ -153,7 +151,7 @@ bool InputHandler::getDpadEvent(Common::Event &event, SceCtrlData &pad) {
_dpadX = 0; // so that we'll pick up a new dpad movement the next round
_dpadY = 0;
}
-
+
PSP_DEBUG_PRINT("Keypad event. DpadX[%d], DpadY[%d]\n", _dpadX, _dpadY);
haveEvent = true;
}
@@ -204,7 +202,7 @@ bool InputHandler::getButtonEvent(Common::Event &event, SceCtrlData &pad) {
event.type = DOWN(PSP_CTRL_CROSS) ? Common::EVENT_LBUTTONDOWN : Common::EVENT_LBUTTONUP;
event.mouse.x = _cursor->getX(); // Could this have to do with SCI enter problem?
event.mouse.y = _cursor->getY();
- PSP_DEBUG_PRINT("%s\n", event.type == Common::EVENT_LBUTTONDOWN ? "LButtonDown" : "LButtonUp");
+ PSP_DEBUG_PRINT("%s\n", event.type == Common::EVENT_LBUTTONDOWN ? "LButtonDown" : "LButtonUp");
} else if (CHANGED(PSP_CTRL_CIRCLE)) {
event.type = DOWN(PSP_CTRL_CIRCLE) ? Common::EVENT_RBUTTONDOWN : Common::EVENT_RBUTTONUP;
event.mouse.x = _cursor->getX();
@@ -234,12 +232,12 @@ bool InputHandler::getButtonEvent(Common::Event &event, SceCtrlData &pad) {
} else if (DOWN(PSP_CTRL_RTRIGGER)) { // An event
event.kbd.flags |= Common::KBD_SHIFT;
}
- PSP_DEBUG_PRINT("Ascii[%d]. Key %s.\n", event.kbd.ascii, event.type == Common::EVENT_KEYDOWN ? "down" : "up" );
+ PSP_DEBUG_PRINT("Ascii[%d]. Key %s.\n", event.kbd.ascii, event.type == Common::EVENT_KEYDOWN ? "down" : "up");
}
-
+
haveEvent = true;
}
-
+
DEBUG_EXIT_FUNC();
return haveEvent;
}
@@ -248,7 +246,7 @@ bool InputHandler::getNubEvent(Common::Event &event, SceCtrlData &pad) {
DEBUG_ENTER_FUNC();
bool haveEvent = false;
- int32 analogStepX = pad.Lx; // Goes up to 255.
+ int32 analogStepX = pad.Lx; // Goes up to 255.
int32 analogStepY = pad.Ly;
int32 oldX = _cursor->getX();
@@ -256,27 +254,27 @@ bool InputHandler::getNubEvent(Common::Event &event, SceCtrlData &pad) {
analogStepX = modifyNubAxisMotion(analogStepX);
analogStepY = modifyNubAxisMotion(analogStepY);
-
+
if (analogStepX != 0 || analogStepY != 0) {
-
+
PSP_DEBUG_PRINT("raw x[%d], y[%d]\n", analogStepX, analogStepY);
-
+
// If no movement then this has no effect
if (DOWN(PSP_CTRL_RTRIGGER)) {
// Fine control mode for analog
- if (analogStepX != 0) {
- if (analogStepX > 0)
- _cursor->increaseXY(2, 0);
- else
- _cursor->increaseXY(-2, 0);
- }
+ if (analogStepX != 0) {
+ if (analogStepX > 0)
+ _cursor->increaseXY(2, 0);
+ else
+ _cursor->increaseXY(-2, 0);
+ }
- if (analogStepY != 0) {
- if (analogStepY > 0)
- _cursor->increaseXY(0, 2);
- else
- _cursor->increaseXY(0, -2);
- }
+ if (analogStepY != 0) {
+ if (analogStepY > 0)
+ _cursor->increaseXY(0, 2);
+ else
+ _cursor->increaseXY(0, -2);
+ }
} else { // Regular speed movement
_cursor->increaseXY(analogStepX, 0);
_cursor->increaseXY(0, analogStepY);
@@ -290,7 +288,7 @@ bool InputHandler::getNubEvent(Common::Event &event, SceCtrlData &pad) {
event.mouse.x = newX;
event.mouse.y = newY;
haveEvent = true;
-
+
PSP_DEBUG_PRINT("Nub event. X[%d], Y[%d]\n", newX, newY);
}
}
@@ -301,17 +299,17 @@ bool InputHandler::getNubEvent(Common::Event &event, SceCtrlData &pad) {
inline int32 InputHandler::modifyNubAxisMotion(int32 input) {
DEBUG_ENTER_FUNC();
const int MIN_NUB_MOTION = 30;
-
+
input -= 128; // Center on 0.
-
+
if (input < -MIN_NUB_MOTION - 1)
input += MIN_NUB_MOTION + 1; // reduce the velocity
else if (input > MIN_NUB_MOTION)
input -= MIN_NUB_MOTION; // same
- else // between these points, dampen the response to 0
+ else // between these points, dampen the response to 0
input = 0;
-
-
+
+
DEBUG_EXIT_FUNC();
- return input;
+ return input;
}
diff --git a/backends/platform/psp/input.h b/backends/platform/psp/input.h
index 64775b9b1d..cd686d9e02 100644
--- a/backends/platform/psp/input.h
+++ b/backends/platform/psp/input.h
@@ -21,7 +21,7 @@
* $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/trunk/backends/platform/psp/osys_psp.cpp $
* $Id: osys_psp.cpp 43618 2009-08-21 22:44:49Z joostp $
*
- */
+ */
#ifndef PSP_INPUT_H
#define PSP_INPUT_H
@@ -37,7 +37,7 @@
class InputHandler {
public:
InputHandler() : _cursor(0), _keyboard(0), _prevButtons(0), _lastPadCheckTime(0), _buttonsChanged(0), _dpadX(0), _dpadY(0) {}
-
+
void init();
bool getAllInputs(Common::Event &event);
void setKeyboard(PSPKeyboard *keyboard) { _keyboard = keyboard; }
@@ -51,11 +51,11 @@ private:
uint32 _buttonsChanged;
int32 _dpadX, _dpadY;
int32 _accelX, _accelY;
-
+
bool getEvent(Common::Event &event, SceCtrlData &pad);
bool getDpadEvent(Common::Event &event, SceCtrlData &pad);
bool getButtonEvent(Common::Event &event, SceCtrlData &pad);
- bool getNubEvent(Common::Event &event, SceCtrlData &pad);
+ bool getNubEvent(Common::Event &event, SceCtrlData &pad);
int32 modifyNubAxisMotion(int32 input);
Common::KeyCode translateDpad(int x, int y);
};
diff --git a/backends/platform/psp/memory.cpp b/backends/platform/psp/memory.cpp
index 9cf7ba7c6c..ba7645cf56 100644
--- a/backends/platform/psp/memory.cpp
+++ b/backends/platform/psp/memory.cpp
@@ -23,12 +23,12 @@
*
*/
-#include "common/scummsys.h"
+#include "common/scummsys.h"
#include "common/singleton.h"
#include "common/list.h"
#include "backends/platform/psp/psppixelformat.h"
#include "backends/platform/psp/memory.h"
-
+
// Class Copier --------------------------------------------------------------------------
//#define __PSP_DEBUG_FUNCS__ /* For debugging the stack */
//#define __PSP_DEBUG_PRINT__
@@ -37,7 +37,7 @@
void Copier::copy(byte *dst, const byte *src, uint32 bytes, PSPPixelFormat *format /* = NULL */) {
DEBUG_ENTER_FUNC();
-
+
uint32 prefixDst = (((uint32)dst) & 0x3);
prefixDst = prefixDst ? 4 - prefixDst : 0; // prefix only if we have address % 4 != 0
uint32 prefixSrc = (((uint32)src) & 0x3);
@@ -47,11 +47,11 @@ void Copier::copy(byte *dst, const byte *src, uint32 bytes, PSPPixelFormat *form
#ifdef __PSP_DEBUG_PRINT__
uint32 debugBytes = bytes;
const byte *debugDst = dst, *debugSrc = src;
-#endif
+#endif
uint32 words, remainingBytes;
-
+
//PSP_DEBUG_PRINT("dst[%p], src[%p], bytes[%d], swap[%s], prefixDst[%u], prefixSrc[%u]\n", dst, src, bytes, swapRB ? "true" : "false", prefixDst, prefixSrc);
-
+
if (prefixDst || prefixSrc) { // we're not aligned to word boundaries
if (prefixDst != prefixSrc) { // worst case: we can never be aligned. this mode is highly inefficient. try to get engines not to use this mode too much
PSP_DEBUG_PRINT("misaligned copy of %u bytes from %p to %p\n", bytes, src, dst);
@@ -59,10 +59,10 @@ void Copier::copy(byte *dst, const byte *src, uint32 bytes, PSPPixelFormat *form
copy8(dst, src, bytes); // no swap is possible on 8 bit
else
copy16((uint16 *)dst, (uint16 *)src, bytes, format);
-
- goto test;
+
+ goto test;
}
-
+
// Do the prefix: the part to get us aligned
if (prefixDst & 1) { // byte
copy8(dst, src, prefixDst); // no swap available
@@ -72,7 +72,7 @@ void Copier::copy(byte *dst, const byte *src, uint32 bytes, PSPPixelFormat *form
if (bytes > prefixDst) // check that we can afford to subtract from bytes
bytes -= prefixDst;
else {
- DEBUG_EXIT_FUNC();
+ DEBUG_EXIT_FUNC();
return;
}
dst32 = (uint32 *)(dst + prefixDst);
@@ -80,11 +80,11 @@ void Copier::copy(byte *dst, const byte *src, uint32 bytes, PSPPixelFormat *form
} else { // We're aligned to word boundaries
dst32 = (uint32 *)dst;
src32 = (uint32 *)src;
- }
-
+ }
+
words = bytes >> 2;
remainingBytes = bytes & 0x3;
-
+
if (swapRB) { // need to swap
for (; words > 0; words--) {
*dst32 = format->swapRedBlue32(*src32);
@@ -107,13 +107,13 @@ void Copier::copy(byte *dst, const byte *src, uint32 bytes, PSPPixelFormat *form
copy16((uint16*)dst32, (uint16 *)src32, remainingBytes, format);
}
-test:
+test:
// debug
#ifdef __PSP_DEBUG_PRINT__
bool mismatch = false;
- for (uint32 i=0; i<debugBytes; i++) {
- if (debugDst[i] != debugSrc[i]) {
+ for (uint32 i = 0; i < debugBytes; i++) {
+ if (debugDst[i] != debugSrc[i]) {
if (mismatch == false) {
PSP_DEBUG_PRINT_SAMELN("mismatch in copy:\n");
PSP_DEBUG_PRINT("dst[%p], src[%p], bytes[%u], swap[%s], prefixDst[%u], prefixSrc[%u]\n", debugDst, debugSrc, debugBytes, swapRB ? "true" : "false", prefixDst, prefixSrc);
@@ -122,7 +122,7 @@ test:
PSP_DEBUG_PRINT_SAMELN("%x!=%x ", debugSrc[i], debugDst[i]);
}
}
- if (mismatch)
+ if (mismatch)
PSP_DEBUG_PRINT("\n");
#endif
@@ -134,7 +134,7 @@ inline void Copier::copy8(byte *dst, const byte *src, uint32 bytes) {
*dst = *src;
dst++;
src++;
- }
+ }
}
inline void Copier::copy16(uint16 *dst, const uint16 *src, uint32 bytes, PSPPixelFormat *format /* = NULL */) {
@@ -147,7 +147,7 @@ inline void Copier::copy16(uint16 *dst, const uint16 *src, uint32 bytes, PSPPixe
*dst = format->swapRedBlue16(*src);
dst++;
src++;
- }
+ }
} else {
for (; shorts > 0 ; shorts--) {
*dst = *src;
@@ -158,8 +158,8 @@ inline void Copier::copy16(uint16 *dst, const uint16 *src, uint32 bytes, PSPPixe
if (remainingBytes)
*(byte *)dst = *(byte *)src;
}
-
-
+
+
// Class VramAllocator -----------------------------------
DECLARE_SINGLETON(VramAllocator)
@@ -172,34 +172,34 @@ DECLARE_SINGLETON(VramAllocator)
void *VramAllocator::allocate(int32 size, bool smallAllocation /* = false */) {
DEBUG_ENTER_FUNC();
- assert (size > 0);
-
+ assert(size > 0);
+
byte *lastAddress = smallAllocation ? (byte *)VRAM_SMALL_ADDRESS : (byte *)VRAM_START_ADDRESS;
Common::List<Allocation>::iterator i;
// Find a block that fits, starting from the beginning
for (i = _allocList.begin(); i != _allocList.end(); ++i) {
byte *currAddress = (*i).address;
-
+
if (currAddress - lastAddress >= size) // We found a match
break;
-
+
if ((*i).getEnd() > lastAddress)
lastAddress = (byte *)(*i).getEnd();
}
if (lastAddress + size > (byte *)VRAM_END_ADDRESS) {
PSP_DEBUG_PRINT("No space for allocation of %d bytes. %d bytes already allocated.\n",
- size, _bytesAllocated);
+ size, _bytesAllocated);
return NULL;
}
_allocList.insert(i, Allocation(lastAddress, size));
_bytesAllocated += size;
-
+
PSP_DEBUG_PRINT("Allocated in VRAM, size %u at %p.\n", size, lastAddress);
PSP_DEBUG_PRINT("Total allocated %u, remaining %u.\n", _bytesAllocated, (2 * 1024 * 1024) - _bytesAllocated);
-
+
DEBUG_EXIT_FUNC();
return lastAddress;
}
@@ -208,9 +208,9 @@ void *VramAllocator::allocate(int32 size, bool smallAllocation /* = false */) {
void VramAllocator::deallocate(void *address) {
DEBUG_ENTER_FUNC();
address = (byte *)CACHED(address); // Make sure all addresses are the same
-
+
Common::List<Allocation>::iterator i;
-
+
// Find the Allocator to deallocate
for (i = _allocList.begin(); i != _allocList.end(); ++i) {
if ((*i).address == address) {
@@ -220,8 +220,8 @@ void VramAllocator::deallocate(void *address) {
DEBUG_EXIT_FUNC();
return;
}
- }
-
+ }
+
PSP_DEBUG_PRINT("Address[%p] not allocated.\n", address);
DEBUG_EXIT_FUNC();
-}
+}
diff --git a/backends/platform/psp/memory.h b/backends/platform/psp/memory.h
index 79af46c68b..a198095090 100644
--- a/backends/platform/psp/memory.h
+++ b/backends/platform/psp/memory.h
@@ -25,11 +25,11 @@
*/
#ifndef PSP_MEMORY_H
-#define PSP_MEMORY_H
+#define PSP_MEMORY_H
#define UNCACHED(x) ((byte *)(((uint32)(x)) | 0x40000000)) /* make an uncached access */
#define CACHED(x) ((byte *)(((uint32)(x)) & 0xBFFFFFFF)) /* make an uncached access into a cached one */
-
+
/**
* Class that does memory copying and swapping if needed
*/
@@ -50,10 +50,10 @@ public:
void deallocate(void *pointer);
static inline bool isAddressInVram(void *address) {
- if ((uint32)(CACHED(address)) >= VRAM_START_ADDRESS && (uint32)(CACHED(address)) < VRAM_END_ADDRESS)
- return true;
- return false;
-}
+ if ((uint32)(CACHED(address)) >= VRAM_START_ADDRESS && (uint32)(CACHED(address)) < VRAM_END_ADDRESS)
+ return true;
+ return false;
+ }
private:
@@ -71,10 +71,10 @@ private:
enum {
VRAM_START_ADDRESS = 0x04000000,
VRAM_END_ADDRESS = 0x04200000,
- VRAM_SMALL_ADDRESS = VRAM_END_ADDRESS - (4*1024) // 4K in the end for small allocations
+ VRAM_SMALL_ADDRESS = VRAM_END_ADDRESS - (4 * 1024) // 4K in the end for small allocations
};
Common::List <Allocation> _allocList; // List of allocations
uint32 _bytesAllocated;
};
-
+
#endif /* PSP_MEMORY_H */
diff --git a/backends/platform/psp/osys_psp.cpp b/backends/platform/psp/osys_psp.cpp
index 022c10f5a8..bd81c14072 100644
--- a/backends/platform/psp/osys_psp.cpp
+++ b/backends/platform/psp/osys_psp.cpp
@@ -23,7 +23,7 @@
*
*/
-#include <pspuser.h>
+#include <pspuser.h>
#include <pspgu.h>
#include <pspdisplay.h>
@@ -70,7 +70,7 @@ void OSystem_PSP::initBackend() {
_cursor.enableCursorPalette(false);
_cursor.setXY(PSP_SCREEN_WIDTH >> 1, PSP_SCREEN_HEIGHT >> 1); // Mouse in the middle of the screen
-
+
// Set pointers for display manager
_displayManager.setCursor(&_cursor);
_displayManager.setScreen(&_screen);
@@ -83,7 +83,7 @@ void OSystem_PSP::initBackend() {
_inputHandler.setKeyboard(&_keyboard);
_inputHandler.init();
- initSDL();
+ initSDL();
_savefile = new PSPSaveFileManager;
@@ -91,13 +91,13 @@ void OSystem_PSP::initBackend() {
PSP_DEBUG_PRINT("calling keyboard.load()\n");
_keyboard.load(); // Load virtual keyboard files into memory
-
+
setTimerCallback(&timer_handler, 10);
setupMixer();
OSystem::initBackend();
-
+
DEBUG_EXIT_FUNC();
}
@@ -127,27 +127,27 @@ int OSystem_PSP::getDefaultGraphicsMode() const {
bool OSystem_PSP::setGraphicsMode(int mode) {
DEBUG_ENTER_FUNC();
-
+
int ret = _displayManager.setGraphicsMode(mode);
-
+
DEBUG_EXIT_FUNC();
return ret;
}
bool OSystem_PSP::setGraphicsMode(const char *name) {
DEBUG_ENTER_FUNC();
-
+
int ret = _displayManager.setGraphicsMode(name);
-
+
DEBUG_EXIT_FUNC();
return ret;
}
int OSystem_PSP::getGraphicsMode() const {
DEBUG_ENTER_FUNC();
-
+
int ret = _displayManager.getGraphicsMode();
-
+
DEBUG_EXIT_FUNC();
return ret;
}
@@ -166,7 +166,7 @@ Common::List<Graphics::PixelFormat> OSystem_PSP::getSupportedFormats() {
void OSystem_PSP::initSize(uint width, uint height, const Graphics::PixelFormat *format) {
DEBUG_ENTER_FUNC();
-
+
_displayManager.setSizeAndPixelFormat(width, height, format);
_cursor.setVisible(false);
@@ -179,7 +179,7 @@ int16 OSystem_PSP::getWidth() {
DEBUG_ENTER_FUNC();
int16 ret = (int16)_screen.getWidth();
-
+
DEBUG_EXIT_FUNC();
return ret;
}
@@ -188,14 +188,14 @@ int16 OSystem_PSP::getHeight() {
DEBUG_ENTER_FUNC();
int16 ret = (int16)_screen.getHeight();
-
+
DEBUG_EXIT_FUNC();
return ret;
}
void OSystem_PSP::setPalette(const byte *colors, uint start, uint num) {
DEBUG_ENTER_FUNC();
-
+
_screen.setPartialPalette(colors, start, num);
_cursor.setScreenPalette(colors, start, num);
_cursor.clearKeyColor();
@@ -217,7 +217,7 @@ void OSystem_PSP::disableCursorPalette(bool disable) {
DEBUG_ENTER_FUNC();
_cursor.enableCursorPalette(!disable);
-
+
DEBUG_EXIT_FUNC();
}
@@ -232,8 +232,8 @@ void OSystem_PSP::copyRectToScreen(const byte *buf, int pitch, int x, int y, int
Graphics::Surface *OSystem_PSP::lockScreen() {
DEBUG_ENTER_FUNC();
- Graphics::Surface *ret = _screen.lockAndGetForEditing();
-
+ Graphics::Surface *ret = _screen.lockAndGetForEditing();
+
DEBUG_EXIT_FUNC();
return ret;
}
@@ -242,7 +242,7 @@ void OSystem_PSP::unlockScreen() {
DEBUG_ENTER_FUNC();
// The screen is always completely updated anyway, so we don't have to force a full update here.
_screen.unlock();
-
+
DEBUG_EXIT_FUNC();
}
@@ -250,16 +250,16 @@ void OSystem_PSP::updateScreen() {
DEBUG_ENTER_FUNC();
_displayManager.renderAll();
-
+
DEBUG_EXIT_FUNC();
}
void OSystem_PSP::setShakePos(int shakeOffset) {
- DEBUG_ENTER_FUNC();
+ DEBUG_ENTER_FUNC();
_screen.setShakePos(shakeOffset);
-
- DEBUG_EXIT_FUNC();
+
+ DEBUG_EXIT_FUNC();
}
void OSystem_PSP::showOverlay() {
@@ -268,7 +268,7 @@ void OSystem_PSP::showOverlay() {
_overlay.setVisible(true);
_cursor.setLimits(_overlay.getWidth(), _overlay.getHeight());
_cursor.useGlobalScaler(false); // mouse with overlay is 1:1
-
+
DEBUG_EXIT_FUNC();
}
@@ -278,7 +278,7 @@ void OSystem_PSP::hideOverlay() {
_overlay.setVisible(false);
_cursor.setLimits(_screen.getWidth(), _screen.getHeight());
_cursor.useGlobalScaler(true); // mouse needs to be scaled with screen
-
+
DEBUG_EXIT_FUNC();
}
@@ -318,7 +318,7 @@ void OSystem_PSP::grabPalette(byte *colors, uint start, uint num) {
DEBUG_ENTER_FUNC();
_screen.getPartialPalette(colors, start, num);
-
+
DEBUG_EXIT_FUNC();
}
@@ -328,17 +328,17 @@ bool OSystem_PSP::showMouse(bool v) {
PSP_DEBUG_PRINT("%s\n", v ? "true" : "false");
bool last = _cursor.isVisible();
_cursor.setVisible(v);
-
+
DEBUG_EXIT_FUNC();
-
+
return last;
}
void OSystem_PSP::warpMouse(int x, int y) {
DEBUG_ENTER_FUNC();
- _cursor.setXY(x,y);
-
+ _cursor.setXY(x, y);
+
DEBUG_EXIT_FUNC();
}
@@ -349,14 +349,14 @@ void OSystem_PSP::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX,
if (format) {
PSP_DEBUG_PRINT("format: bpp[%d], rLoss[%d], gLoss[%d], bLoss[%d], aLoss[%d], rShift[%d], gShift[%d], bShift[%d], aShift[%d]\n", format->bytesPerPixel, format->rLoss, format->gLoss, format->bLoss, format->aLoss, format->rShift, format->gShift, format->bShift, format->aShift);
}
-
- _cursor.setKeyColor(keycolor);
+
+ _cursor.setKeyColor(keycolor);
_cursor.setCursorTargetScale(cursorTargetScale);
_cursor.setSizeAndScummvmPixelFormat(w, h, format);
_cursor.setHotspot(hotspotX, hotspotY);
_cursor.clearKeyColor();
_cursor.copyFromArray(buf);
-
+
DEBUG_EXIT_FUNC();
}
diff --git a/backends/platform/psp/osys_psp.h b/backends/platform/psp/osys_psp.h
index 23eba870e9..8c5b40dcdf 100644
--- a/backends/platform/psp/osys_psp.h
+++ b/backends/platform/psp/osys_psp.h
@@ -43,7 +43,7 @@
class OSystem_PSP : public BaseBackend {
private:
-
+
Common::SaveFileManager *_savefile;
Audio::MixerImpl *_mixer;
Common::TimerManager *_timer;
@@ -63,14 +63,14 @@ public:
~OSystem_PSP();
static OSystem *instance();
-
+
void initBackend();
-
+
// Feature related
bool hasFeature(Feature f);
void setFeatureState(Feature f, bool enable);
bool getFeatureState(Feature f);
-
+
// Graphics related
const GraphicsMode *getSupportedGraphicsModes() const;
int getDefaultGraphicsMode() const;
@@ -81,25 +81,25 @@ public:
virtual Graphics::PixelFormat getScreenFormat() const;
virtual Common::List<Graphics::PixelFormat> getSupportedFormats();
#endif
-
+
// Screen size
void initSize(uint width, uint height, const Graphics::PixelFormat *format);
int16 getWidth();
int16 getHeight();
-
+
// Palette related
void setPalette(const byte *colors, uint start, uint num);
void grabPalette(byte *colors, uint start, uint num);
void setCursorPalette(const byte *colors, uint start, uint num);
void disableCursorPalette(bool disable);
-
+
// Screen related
void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h);
Graphics::Surface *lockScreen();
void unlockScreen();
void updateScreen();
void setShakePos(int shakeOffset);
-
+
// Overlay related
void showOverlay();
void hideOverlay();
@@ -109,7 +109,7 @@ public:
int16 getOverlayHeight();
int16 getOverlayWidth();
Graphics::PixelFormat getOverlayFormat() const { return Graphics::createPixelFormat<4444>(); }
-
+
// Mouse related
bool showMouse(bool visible);
void warpMouse(int x, int y);
@@ -138,7 +138,7 @@ public:
static void mixCallback(void *sys, byte *samples, int len);
void setupMixer(void);
Audio::Mixer *getMixer() { return _mixer; }
-
+
// Misc
Common::SaveFileManager *getSavefileManager() { return _savefile; }
FilesystemFactory *getFilesystemFactory() { return &PSPFilesystemFactory::instance(); }
diff --git a/backends/platform/psp/powerman.cpp b/backends/platform/psp/powerman.cpp
index b4391b0b8d..25afba4881 100644
--- a/backends/platform/psp/powerman.cpp
+++ b/backends/platform/psp/powerman.cpp
@@ -26,7 +26,7 @@
//#define __PSP_DEBUG_FUNCS__ /* can put this locally too */
//#define __PSP_DEBUG_PRINT__
#include "backends/platform/psp/trace.h"
-
+
#include <psppower.h>
#include <pspthreadman.h>
@@ -37,19 +37,19 @@ DECLARE_SINGLETON(PowerManager)
// Function to debug the Power Manager (we have no output to screen)
inline void PowerManager::debugPM() {
- PSP_DEBUG_PRINT("PM status[%d]. Listcount[%d]. CriticalCount[%d]. ThreadId[%x]. Error[%d]\n",
- _PMStatus, _listCounter, _criticalCounter, sceKernelGetThreadId(), _error);
+ PSP_DEBUG_PRINT("PM status[%d]. Listcount[%d]. CriticalCount[%d]. ThreadId[%x]. Error[%d]\n",
+ _PMStatus, _listCounter, _criticalCounter, sceKernelGetThreadId(), _error);
}
- /*******************************************
+/*******************************************
*
* Constructor
*
********************************************/
PowerManager::PowerManager() {
DEBUG_ENTER_FUNC();
-
+
_flagMutex = NULL; /* Init mutex handle */
_listMutex = NULL; /* Init mutex handle */
_condSuspendable = NULL; /* Init condition variable */
@@ -78,14 +78,14 @@ PowerManager::PowerManager() {
_suspendFlag = false;
_criticalCounter = 0; // How many are in the critical section
_pauseFlag = 0;
- _pauseFlagOld = 0;
+ _pauseFlagOld = 0;
_pauseClientState = 0;
_listCounter = 0;
PMStatusSet(kInitDone);
_error = 0;
DEBUG_EXIT_FUNC();
- }
+}
/*******************************************
*
@@ -107,7 +107,7 @@ int PowerManager::registerSuspend(Suspendable *item) {
if (SDL_mutexV(_listMutex) != 0) {
PSP_ERROR("Couldn't unlock _listMutex[%p]\n", _listMutex);
}
-
+
debugPM();
DEBUG_EXIT_FUNC();
@@ -123,7 +123,7 @@ int PowerManager::unregisterSuspend(Suspendable *item) {
DEBUG_ENTER_FUNC();
debugPM();
- // Unregister from stream list
+ // Unregister from stream list
if (SDL_mutexP(_listMutex) != 0) {
PSP_ERROR("Couldn't unlock _listMutex[%p]\n", _listMutex);
}
@@ -140,16 +140,16 @@ int PowerManager::unregisterSuspend(Suspendable *item) {
DEBUG_EXIT_FUNC();
return 0;
- }
+}
- /*******************************************
+/*******************************************
*
* Destructor
*
********************************************/
- PowerManager::~PowerManager() {
+PowerManager::~PowerManager() {
DEBUG_ENTER_FUNC();
-
+
PMStatusSet(kDestroyPM);
SDL_DestroyCond(_condSuspendable);
@@ -163,9 +163,9 @@ int PowerManager::unregisterSuspend(Suspendable *item) {
SDL_DestroyMutex(_listMutex);
_listMutex = 0;
-
+
DEBUG_EXIT_FUNC();
- }
+}
/*******************************************
*
@@ -186,8 +186,7 @@ void PowerManager::pollPauseEngine() {
g_engine->pauseEngine(true);
PSP_DEBUG_PRINT_FUNC("Pausing engine\n");
_pauseClientState = PowerManager::Paused; // Tell PM we're done pausing
- }
- else if (!pause && _pauseClientState == PowerManager::Paused) {
+ } else if (!pause && _pauseClientState == PowerManager::Paused) {
g_engine->pauseEngine(false);
PSP_DEBUG_PRINT_FUNC("Unpausing for resume\n");
_pauseClientState = PowerManager::Unpaused; // Tell PM we're in the middle of pausing
@@ -216,7 +215,7 @@ int PowerManager::blockOnSuspend() {
int PowerManager::beginCriticalSection(bool justBlock) {
DEBUG_ENTER_FUNC();
-
+
int ret = NotBlocked;
if (SDL_mutexP(_flagMutex) != 0) {
@@ -290,7 +289,7 @@ int PowerManager::endCriticalSection() {
return ret;
}
- /*******************************************
+/*******************************************
*
* Callback function to be called to put every Suspendable to suspend
*
diff --git a/backends/platform/psp/powerman.h b/backends/platform/psp/powerman.h
index 4a9167f2bf..03a873647b 100644
--- a/backends/platform/psp/powerman.h
+++ b/backends/platform/psp/powerman.h
@@ -31,25 +31,25 @@
#include "common/singleton.h"
#include "common/list.h"
- /*
- * Implement this class (interface) if you want to use PowerManager's suspend callback functionality
- *
- */
- class Suspendable {
- public:
+/*
+ * Implement this class (interface) if you want to use PowerManager's suspend callback functionality
+ *
+ */
+class Suspendable {
+public:
virtual ~Suspendable() {}
virtual int suspend() = 0;
virtual int resume() = 0;
- };
+};
- /******************************************************************************************************
- *
- * This class will call a Suspendable when the PSP goes to suspend/resumes. It also provides the ability to block
- * a thread when the PSP is going to suspend/suspending, and to wake it up when the PSP is resumed.
- * This ability is very useful for managing the PSPIoStream class, but may be found useful by other classes as well.
- *
- *******************************************************************************************************/
- class PowerManager: public Common::Singleton<PowerManager> {
+/******************************************************************************************************
+*
+* This class will call a Suspendable when the PSP goes to suspend/resumes. It also provides the ability to block
+* a thread when the PSP is going to suspend/suspending, and to wake it up when the PSP is resumed.
+* This ability is very useful for managing the PSPIoStream class, but may be found useful by other classes as well.
+*
+*******************************************************************************************************/
+class PowerManager: public Common::Singleton<PowerManager> {
public:
int blockOnSuspend(); /* block if suspending */
@@ -76,7 +76,7 @@ public:
Paused
};
- private:
+private:
friend class Common::Singleton<PowerManager>;
PowerManager();
~PowerManager();
@@ -125,12 +125,12 @@ public:
void PMStatusSet(PMState s) { _PMStatus = s; }
volatile int _PMStatus; /* What the PM is doing */
- public:
- int getPMStatus() { return _PMStatus; }
+public:
+ int getPMStatus() { return _PMStatus; }
- };
+};
- // For easy access
+// For easy access
#define PowerMan PowerManager::instance()
#endif /* POWERMAN_H */
diff --git a/backends/platform/psp/psp_main.cpp b/backends/platform/psp/psp_main.cpp
index c3770cb41f..15e8d5a856 100644
--- a/backends/platform/psp/psp_main.cpp
+++ b/backends/platform/psp/psp_main.cpp
@@ -26,10 +26,10 @@
#define USERSPACE_ONLY //don't use kernel mode features
#ifndef USERSPACE_ONLY
- #include <pspkernel.h>
- #include <pspdebug.h>
+#include <pspkernel.h>
+#include <pspdebug.h>
#else
- #include <pspuser.h>
+#include <pspuser.h>
#endif
#include <psppower.h>
@@ -87,7 +87,7 @@ void MyExceptionHandler(PspDebugRegBlock *regs) {
* Function that is called from _init in kernelmode before the
* main thread is started in usermode.
*/
-__attribute__ ((constructor))
+__attribute__((constructor))
void loaderInit() {
pspKernelSetKernelPC();
pspDebugInstallErrorHandler(MyExceptionHandler);
@@ -150,7 +150,7 @@ int main(void) {
SetupCallbacks();
static const char *argv[] = { "scummvm", NULL };
- static int argc = sizeof(argv)/sizeof(char *)-1;
+ static int argc = sizeof(argv) / sizeof(char *) - 1;
g_system = new OSystem_PSP();
assert(g_system);
diff --git a/backends/platform/psp/pspkeyboard.cpp b/backends/platform/psp/pspkeyboard.cpp
index d6fa0621b9..d349b514e2 100644
--- a/backends/platform/psp/pspkeyboard.cpp
+++ b/backends/platform/psp/pspkeyboard.cpp
@@ -26,7 +26,7 @@
//#define PSP_KB_SHELL /* Need a hack to properly load the keyboard from the PSP shell */
#ifdef PSP_KB_SHELL
- #define PSP_KB_SHELL_PATH "ms0:/psp/game4xx/scummvm-solid/" /* path to kbd.zip */
+#define PSP_KB_SHELL_PATH "ms0:/psp/game4xx/scummvm-solid/" /* path to kbd.zip */
#endif
//#define __PSP_DEBUG_FUNCS__ /* For debugging the stack */
@@ -80,7 +80,7 @@ short PSPKeyboard::_modeChar[MODE_COUNT][5][6] = {
},
{ //symbols
{ K('!'), K(')'), K('?'), K('('), K('<'), K('>') },
- { K('+'), K('/'), K('='), K('\\'),K('\''),K('"') },
+ { K('+'), K('/'), K('='), K('\\'), K('\''), K('"') },
{ K(':'), K(']'), K(';'), K('['), K('@'), K('#') },
{ K('-'), K('}'), K('_'), K('{'), K('*'), K('$') },
{ K('\b'), K('.'), K(' '), K(','), K(0), K(0) }
@@ -108,7 +108,7 @@ const char *PSPKeyboard::_guiStrings[] = {
// Constructor
PSPKeyboard::PSPKeyboard() {
DEBUG_ENTER_FUNC();
-
+
_init = false; // we're not initialized yet
_prevButtons = 0; // Reset previous buttons
_dirty = false; // keyboard needs redrawing
@@ -119,19 +119,19 @@ PSPKeyboard::PSPKeyboard() {
_moved = false; // Keyboard wasn't moved recently
_state = kInvisible; // We start invisible
_lastState = kInvisible;
-
+
// Constant renderer settings
_renderer.setAlphaBlending(true);
_renderer.setColorTest(false);
- _renderer.setUseGlobalScaler(false);
-
+ _renderer.setUseGlobalScaler(false);
+
DEBUG_EXIT_FUNC();
}
// Destructor
PSPKeyboard::~PSPKeyboard() {
DEBUG_ENTER_FUNC();
-
+
if (!_init) {
DEBUG_EXIT_FUNC();
return;
@@ -142,18 +142,17 @@ PSPKeyboard::~PSPKeyboard() {
_palettes[i].deallocate();
}
_init = false;
-
+
DEBUG_EXIT_FUNC();
}
-void PSPKeyboard::setVisible(bool val) {
+void PSPKeyboard::setVisible(bool val) {
if (val && _state == kInvisible && _init) { // Check also that were loaded correctly
_lastState = _state;
- _state = kMove;
- }
- else if ( !val && _state != kInvisible) {
+ _state = kMove;
+ } else if (!val && _state != kInvisible) {
_lastState = _state;
- _state = kInvisible;
+ _state = kInvisible;
}
setDirty();
}
@@ -161,34 +160,34 @@ void PSPKeyboard::setVisible(bool val) {
/* move the position the keyboard is currently drawn at */
void PSPKeyboard::moveTo(const int newX, const int newY) {
DEBUG_ENTER_FUNC();
-
+
_movedX = newX;
_movedY = newY;
setDirty();
-
+
DEBUG_EXIT_FUNC();
}
/* move the position the keyboard is currently drawn at */
void PSPKeyboard::increaseKeyboardLocationX(int amount) {
DEBUG_ENTER_FUNC();
-
+
int newX = _movedX + amount;
if (newX > PSP_SCREEN_WIDTH - 5 || newX < 0 - 140) { // clamp
DEBUG_EXIT_FUNC();
return;
- }
+ }
_movedX = newX;
setDirty();
-
+
DEBUG_EXIT_FUNC();
}
/* move the position the keyboard is currently drawn at */
void PSPKeyboard::increaseKeyboardLocationY(int amount) {
DEBUG_ENTER_FUNC();
-
+
int newY = _movedY + amount;
if (newY > PSP_SCREEN_HEIGHT - 5 || newY < 0 - 140) { // clamp
@@ -197,7 +196,7 @@ void PSPKeyboard::increaseKeyboardLocationY(int amount) {
}
_movedY = newY;
setDirty();
-
+
DEBUG_EXIT_FUNC();
}
@@ -205,8 +204,8 @@ void PSPKeyboard::increaseKeyboardLocationY(int amount) {
void PSPKeyboard::render() {
DEBUG_ENTER_FUNC();
- unsigned int currentBuffer = _mode<<1;
-
+ unsigned int currentBuffer = _mode << 1;
+
// Draw the background letters
// Set renderer to current buffer & palette
_renderer.setBuffer(&_buffers[currentBuffer]);
@@ -215,14 +214,14 @@ void PSPKeyboard::render() {
_renderer.setOffsetInBuffer(0, 0);
_renderer.setDrawWholeBuffer();
_renderer.render();
-
+
// Get X and Y coordinates for the orange block
int x, y;
convertCursorToXY(_oldCursor, x, y);
-
+
const int OrangeBlockSize = 64;
const int GrayBlockSize = 43;
-
+
// Draw the current Highlighted Selector (orange block)
_renderer.setBuffer(&_buffers[currentBuffer + 1]);
_renderer.setPalette(&_palettes[currentBuffer + 1]);
@@ -230,12 +229,12 @@ void PSPKeyboard::render() {
_renderer.setOffsetInBuffer(x * OrangeBlockSize, y * OrangeBlockSize);
_renderer.setDrawSize(OrangeBlockSize, OrangeBlockSize);
_renderer.render();
-
- DEBUG_EXIT_FUNC();
+
+ DEBUG_EXIT_FUNC();
}
inline void PSPKeyboard::convertCursorToXY(CursorDirections cur, int &x, int &y) {
- switch(cur) {
+ switch (cur) {
case kUp:
x = 1;
y = 0;
@@ -291,7 +290,7 @@ bool PSPKeyboard::load() {
}
int i;
-
+
// Loop through all png images
for (i = 0; i < guiStringsSize; i++) {
uint32 height = 0, width = 0, paletteSize = 0;
@@ -326,13 +325,13 @@ bool PSPKeyboard::load() {
// Allocate memory for image
PSP_DEBUG_PRINT("width[%d], height[%d], paletteSize[%d]\n", width, height, paletteSize);
_buffers[i].setSize(width, height, Buffer::kSizeByTextureSize);
-
+
if (paletteSize) { // 8 or 4-bit image
if (paletteSize <= 16) { // 4 bit
_buffers[i].setPixelFormat(PSPPixelFormat::Type_Palette_4bit);
_palettes[i].setPixelFormats(PSPPixelFormat::Type_4444, PSPPixelFormat::Type_Palette_4bit);
- paletteSize = 16;
- } else if (paletteSize <= 256){ // 8-bit image
+ paletteSize = 16;
+ } else if (paletteSize <= 256) { // 8-bit image
paletteSize = 256;
_buffers[i].setPixelFormat(PSPPixelFormat::Type_Palette_8bit);
_palettes[i].setPixelFormats(PSPPixelFormat::Type_4444, PSPPixelFormat::Type_Palette_8bit);
@@ -340,11 +339,11 @@ bool PSPKeyboard::load() {
PSP_ERROR("palette of %d too big!\n", paletteSize);
goto ERROR;
}
-
+
} else { // 32-bit image
_buffers[i].setPixelFormat(PSPPixelFormat::Type_8888);
}
-
+
_buffers[i].allocate();
_palettes[i].allocate();
@@ -361,13 +360,12 @@ bool PSPKeyboard::load() {
delete file;
}
- }
- else {
+ } else {
PSP_ERROR("couldn't obtain PNG image size\n");
goto ERROR;
}
} /* for loop */
-
+
_init = true;
delete fileArchive;
@@ -387,7 +385,7 @@ ERROR:
_palettes[j].deallocate();
}
_init = false;
-
+
DEBUG_EXIT_FUNC();
return false;
}
@@ -399,7 +397,7 @@ static void user_warning_fn(png_structp png_ptr, png_const_charp warning_msg) {
/* Get the width and height of a png image */
int PSPKeyboard::getPngImageSize(Common::SeekableReadStream *file, uint32 *png_width, uint32 *png_height, u32 *paletteSize) {
DEBUG_ENTER_FUNC();
-
+
png_structp png_ptr;
png_infop info_ptr;
unsigned int sig_read = 0;
@@ -433,7 +431,7 @@ int PSPKeyboard::getPngImageSize(Common::SeekableReadStream *file, uint32 *png_w
*png_width = width;
*png_height = height;
-
+
DEBUG_EXIT_FUNC();
return 0;
}
@@ -442,7 +440,7 @@ int PSPKeyboard::getPngImageSize(Common::SeekableReadStream *file, uint32 *png_w
//
int PSPKeyboard::loadPngImage(Common::SeekableReadStream *file, Buffer &buffer, Palette &palette) {
DEBUG_ENTER_FUNC();
-
+
png_structp png_ptr;
png_infop info_ptr;
unsigned int sig_read = 0;
@@ -480,7 +478,7 @@ int PSPKeyboard::loadPngImage(Common::SeekableReadStream *file, Buffer &buffer,
if (color_type == PNG_COLOR_TYPE_PALETTE) {
// Copy the palette
png_colorp srcPal = info_ptr->palette;
- for(int i=0; i < info_ptr->num_palette; i++) {
+ for (int i = 0; i < info_ptr->num_palette; i++) {
unsigned char alphaVal = (i < info_ptr->num_trans) ? info_ptr->trans[i] : 0xFF; // Load alpha if it's there
palette.setSingleColorRGBA(i, srcPal->red, srcPal->green, srcPal->blue, alphaVal);
srcPal++;
@@ -492,7 +490,7 @@ int PSPKeyboard::loadPngImage(Common::SeekableReadStream *file, Buffer &buffer,
if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) png_set_tRNS_to_alpha(png_ptr);
// Filler for alpha?
png_set_filler(png_ptr, 0xff, PNG_FILLER_AFTER);
- }
+ }
unsigned char *line = (unsigned char*) malloc(info_ptr->rowbytes);
if (!line) {
@@ -509,7 +507,7 @@ int PSPKeyboard::loadPngImage(Common::SeekableReadStream *file, Buffer &buffer,
}
free(line);
-
+
png_read_end(png_ptr, info_ptr);
png_destroy_read_struct(&png_ptr, &info_ptr, png_infopp_NULL);
@@ -533,21 +531,20 @@ int PSPKeyboard::loadPngImage(Common::SeekableReadStream *file, Buffer &buffer,
*/
bool PSPKeyboard::processInput(Common::Event &event, SceCtrlData &pad) {
DEBUG_ENTER_FUNC();
-
+
bool haveEvent = false; // Whether we have an event for the event manager to process
event.kbd.flags = 0;
-
+
_buttonsChanged = _prevButtons ^ pad.Buttons;
if (!_init) // In case we never had init
return false;
if (_state == kInvisible) // Return if we're invisible
- return false;
+ return false;
if (_state != kMove && PRESSED(PSP_CTRL_SELECT)) {
_lastState = _state;
_state = kMove; // Check for move or visible state
- }
- else if (CHANGED(PSP_CTRL_START)) { // Handle start button: enter, make KB invisible
+ } else if (CHANGED(PSP_CTRL_START)) { // Handle start button: enter, make KB invisible
event.kbd.ascii = '\r';
event.kbd.keycode = Common::KEYCODE_RETURN;
event.type = DOWN(PSP_CTRL_START) ? Common::EVENT_KEYDOWN : Common::EVENT_KEYUP;
@@ -555,7 +552,7 @@ bool PSPKeyboard::processInput(Common::Event &event, SceCtrlData &pad) {
_dirty = true;
if (UP(PSP_CTRL_START))
_state = kInvisible; // Make us invisible if unpressed
- }
+ }
// Check for being in state of moving the keyboard onscreen or pressing select
else if (_state == kMove)
handleMoveState(pad);
@@ -569,7 +566,7 @@ bool PSPKeyboard::processInput(Common::Event &event, SceCtrlData &pad) {
handleLTriggerDownState(pad); // Deal with trigger states
_prevButtons = pad.Buttons;
-
+
DEBUG_EXIT_FUNC();
return haveEvent;
}
@@ -578,7 +575,7 @@ void PSPKeyboard::handleMoveState(SceCtrlData &pad) {
DEBUG_ENTER_FUNC();
if (UP(PSP_CTRL_SELECT)) {
// Toggle between visible and invisible
- _state = (_lastState == kInvisible) ? kDefault : kInvisible;
+ _state = (_lastState == kInvisible) ? kDefault : kInvisible;
_dirty = true;
if (_moved) { // We moved the keyboard. Keep the keyboard onscreen anyway
@@ -598,22 +595,22 @@ void PSPKeyboard::handleMoveState(SceCtrlData &pad) {
else /* DOWN(PSP_CTRL_RIGHT) */
increaseKeyboardLocationX(5);
}
- DEBUG_EXIT_FUNC();
+ DEBUG_EXIT_FUNC();
}
bool PSPKeyboard::handleDefaultState(Common::Event &event, SceCtrlData &pad) {
DEBUG_ENTER_FUNC();
bool haveEvent = false;
-
+
if (PRESSED(PSP_CTRL_LTRIGGER)) // Don't say we used up the input
- _state = kLTriggerDown;
+ _state = kLTriggerDown;
else if (PRESSED(PSP_CTRL_RTRIGGER)) // Don't say we used up the input
- _state = kRTriggerDown;
+ _state = kRTriggerDown;
else if (CHANGED(PSP_4BUTTONS)) // We only care about the 4 buttons
haveEvent = getInputChoice(event, pad);
else if (!DOWN(PSP_4BUTTONS)) // Must be up to move cursor
getCursorMovement(pad);
-
+
DEBUG_EXIT_FUNC();
return haveEvent;
}
@@ -622,13 +619,13 @@ bool PSPKeyboard::handleCornersSelectedState(Common::Event &event, SceCtrlData &
DEBUG_ENTER_FUNC();
// We care about 4 buttons + triggers (for letter selection)
bool haveEvent = false;
-
+
if (CHANGED(PSP_4BUTTONS | PSP_CTRL_RTRIGGER | PSP_CTRL_LTRIGGER))
haveEvent = getInputChoice(event, pad);
if (!DOWN(PSP_4BUTTONS | PSP_CTRL_RTRIGGER | PSP_CTRL_LTRIGGER)) // Must be up to move cursor
getCursorMovement(pad)
-
- DEBUG_EXIT_FUNC();
+
+ DEBUG_EXIT_FUNC();
return haveEvent;
}
@@ -670,13 +667,13 @@ bool PSPKeyboard::getInputChoice(Common::Event &event, SceCtrlData &pad) {
} else if (PRESSED(PSP_CTRL_LTRIGGER) && _state == kCornersSelected) {
innerChoice = 4;
event.type = Common::EVENT_KEYDOWN; // We give priority to key_up
- } else /* (PRESSED(PSP_CTRL_RTRIGGER)) && _state == kCornersSelected */ {
+ } else { /* (PRESSED(PSP_CTRL_RTRIGGER)) && _state == kCornersSelected */
innerChoice = 5;
event.type = Common::EVENT_KEYDOWN; // We give priority to key_up
}
- #define IS_UPPERCASE(x) ((x) >= (unsigned short)'A' && (x) <= (unsigned short)'Z')
- #define TO_LOWER(x) ((x) += 'a'-'A')
+#define IS_UPPERCASE(x) ((x) >= (unsigned short)'A' && (x) <= (unsigned short)'Z')
+#define TO_LOWER(x) ((x) += 'a'-'A')
//Now grab the value out of the array
short choice = _modeChar[_mode][_oldCursor][innerChoice];
@@ -699,13 +696,13 @@ bool PSPKeyboard::getInputChoice(Common::Event &event, SceCtrlData &pad) {
void PSPKeyboard::getCursorMovement(SceCtrlData &pad) {
DEBUG_ENTER_FUNC();
CursorDirections cursor;
-
+
// Find where the cursor is pointing
cursor = kCenter;
_state = kDefault;
if (DOWN(PSP_DPAD)) {
- _state = kCornersSelected;
+ _state = kCornersSelected;
if (DOWN(PSP_CTRL_UP))
cursor = kUp;
@@ -716,7 +713,7 @@ void PSPKeyboard::getCursorMovement(SceCtrlData &pad) {
else if (DOWN(PSP_CTRL_LEFT))
cursor = kLeft;
}
-
+
if (cursor != _oldCursor) { //If we've moved, update dirty and return
_dirty = true;
_oldCursor = cursor;
@@ -729,7 +726,7 @@ void PSPKeyboard::handleLTriggerDownState(SceCtrlData &pad) {
if (UNPRESSED(PSP_CTRL_LTRIGGER)) {
_dirty = true;
- if(_mode < 2)
+ if (_mode < 2)
_mode = 2;
else
_mode = (_mode == 2) ? 3 : 2;
@@ -744,7 +741,7 @@ void PSPKeyboard::handleRTriggerDownState(SceCtrlData &pad) {
if (UNPRESSED(PSP_CTRL_RTRIGGER)) {
_dirty = true;
- if(_mode > 1)
+ if (_mode > 1)
_mode = 0;
else
_mode = (_mode == 0) ? 1 : 0;
diff --git a/backends/platform/psp/pspkeyboard.h b/backends/platform/psp/pspkeyboard.h
index 457476e844..08c5bc4505 100644
--- a/backends/platform/psp/pspkeyboard.h
+++ b/backends/platform/psp/pspkeyboard.h
@@ -50,7 +50,7 @@ private:
public:
PSPKeyboard();
~PSPKeyboard();
-
+
bool load(); // Load keyboard into memory
bool isInit() { return _init; } // Check for initialization
bool isDirty() { return _dirty; } // Check if needs redrawing
@@ -89,19 +89,19 @@ private:
void getCursorMovement(SceCtrlData &pad);
void handleRTriggerDownState(SceCtrlData &pad);
void handleLTriggerDownState(SceCtrlData &pad);
-
+
static short _modeChar[MODE_COUNT][5][6];
static const char *_guiStrings[];
bool _init;
uint32 _prevButtons; // A bit pattern.
uint32 _buttonsChanged;
-
+
bool _dirty; // keyboard needs redrawing
int _mode; // charset selected. (0 - letters or 1 - numbers)
int _movedX; // location we've moved the KB to onscreen
int _movedY;
bool _moved; // whether the keyboard was moved
-
+
State _state; // State of keyboard Keyboard state machine
State _lastState;
diff --git a/backends/platform/psp/psploader.cpp b/backends/platform/psp/psploader.cpp
index 94310936f6..68e51c1a50 100644
--- a/backends/platform/psp/psploader.cpp
+++ b/backends/platform/psp/psploader.cpp
@@ -134,7 +134,7 @@ bool DLObject::relocate(int fd, unsigned long offset, unsigned long size, void *
case R_MIPS_HI16: // Absolute addressing.
if (sym->st_shndx < SHN_LOPROC && // Only shift for plugin section (ie. has a real section index)
- firstHi16 < 0 ) { // Only process first in block of HI16s
+ firstHi16 < 0) { // Only process first in block of HI16s
firstHi16 = i; // Keep the first Hi16 we saw
seenHi16 = true;
ahl = (*target & 0xffff) << 16; // Take lower 16 bits shifted up
@@ -174,8 +174,7 @@ bool DLObject::relocate(int fd, unsigned long offset, unsigned long size, void *
// Fix: we can have LO16 access to the short segment sometimes
if (lo16InShorts) {
relocation = ahl + _shortsSegment->getOffset(); // Add in the short segment offset
- }
- else // It's in the regular segment
+ } else // It's in the regular segment
relocation = ahl + (Elf32_Addr)_segment; // Add in the new offset for the segment
if (firstHi16 >= 0) { // We haven't treated the HI16s yet so do it now
diff --git a/backends/platform/psp/psppixelformat.cpp b/backends/platform/psp/psppixelformat.cpp
index 7758f2c26b..10b5aa5a7f 100644
--- a/backends/platform/psp/psppixelformat.cpp
+++ b/backends/platform/psp/psppixelformat.cpp
@@ -23,8 +23,8 @@
*
*/
-#include "common/scummsys.h"
-#include "backends/platform/psp/psppixelformat.h"
+#include "common/scummsys.h"
+#include "backends/platform/psp/psppixelformat.h"
//#define __PSP_DEBUG_FUNCS__ /* For debugging function calls */
//#define __PSP_DEBUG_PRINT__ /* For debug printouts */
@@ -36,10 +36,10 @@
void PSPPixelFormat::set(Type type, bool swap /* = false */) {
DEBUG_ENTER_FUNC();
PSP_DEBUG_PRINT("type = %d\n", type);
-
+
format = type;
swapRB = swap;
-
+
switch (type) {
case Type_4444:
case Type_5551:
@@ -71,12 +71,12 @@ void PSPPixelFormat::set(Type type, bool swap /* = false */) {
// Convert from ScummVM general PixelFormat to our pixel format
// For buffer and palette.
void PSPPixelFormat::convertFromScummvmPixelFormat(const Graphics::PixelFormat *pf,
- PSPPixelFormat::Type &bufferType,
- PSPPixelFormat::Type &paletteType,
- bool &swapRedBlue) {
+ PSPPixelFormat::Type &bufferType,
+ PSPPixelFormat::Type &paletteType,
+ bool &swapRedBlue) {
swapRedBlue = false; // no red-blue swap by default
PSPPixelFormat::Type *target = 0; // which one we'll be filling
-
+
if (!pf) { // Default, pf is NULL
bufferType = Type_Palette_8bit;
paletteType = Type_5551;
@@ -92,7 +92,7 @@ void PSPPixelFormat::convertFromScummvmPixelFormat(const Graphics::PixelFormat *
bufferType = Type_Palette_8bit;
target = &paletteType; // The type describes the palette
}
-
+
// Find out the exact type of the target
if (pf->rLoss == 3 && pf->bLoss == 3) {
if (pf->gLoss == 3)
@@ -104,13 +104,13 @@ void PSPPixelFormat::convertFromScummvmPixelFormat(const Graphics::PixelFormat *
} else if (pf->gLoss == 0 && pf->gShift == 8) {
*target = Type_8888;
} else if ((pf->gLoss == 0 && pf->gShift == 0) ||
- (pf->gLoss == 8 && pf->gShift == 0)) { // Default CLUT8 can have weird values
+ (pf->gLoss == 8 && pf->gShift == 0)) { // Default CLUT8 can have weird values
*target = Type_5551;
} else {
PSP_ERROR("Unknown Scummvm pixel format.\n");
PSP_ERROR("\trLoss[%d], gLoss[%d], bLoss[%d], aLoss[%d]\n\trShift[%d], gShift[%d], bShift[%d], aShift[%d]\n",
- pf->rLoss, pf->gLoss, pf->bLoss, pf->aLoss,
- pf->rShift, pf->gShift, pf->bShift, pf->aShift);
+ pf->rLoss, pf->gLoss, pf->bLoss, pf->aLoss,
+ pf->rShift, pf->gShift, pf->bShift, pf->aShift);
*target = Type_Unknown;
}
@@ -123,44 +123,68 @@ void PSPPixelFormat::convertFromScummvmPixelFormat(const Graphics::PixelFormat *
Graphics::PixelFormat PSPPixelFormat::convertToScummvmPixelFormat(PSPPixelFormat::Type type) {
Graphics::PixelFormat pf;
-
- switch(type) {
+
+ switch (type) {
case Type_4444:
pf.bytesPerPixel = 2;
- pf.aLoss = 4; pf.rLoss = 4; pf.gLoss = 4; pf.bLoss = 4;
- pf.aShift = 12; pf.rShift = 0; pf.gShift = 4; pf.bShift = 8;
+ pf.aLoss = 4;
+ pf.rLoss = 4;
+ pf.gLoss = 4;
+ pf.bLoss = 4;
+ pf.aShift = 12;
+ pf.rShift = 0;
+ pf.gShift = 4;
+ pf.bShift = 8;
break;
case Type_5551:
pf.bytesPerPixel = 2;
- pf.aLoss = 7; pf.rLoss = 3; pf.gLoss = 3; pf.bLoss = 3;
- pf.aShift = 15; pf.rShift = 0; pf.gShift = 5; pf.bShift = 10;
+ pf.aLoss = 7;
+ pf.rLoss = 3;
+ pf.gLoss = 3;
+ pf.bLoss = 3;
+ pf.aShift = 15;
+ pf.rShift = 0;
+ pf.gShift = 5;
+ pf.bShift = 10;
break;
case Type_5650:
pf.bytesPerPixel = 2;
- pf.aLoss = 8; pf.rLoss = 3; pf.gLoss = 2; pf.bLoss = 3;
- pf.aShift = 0; pf.rShift = 0; pf.gShift = 5; pf.bShift = 11;
+ pf.aLoss = 8;
+ pf.rLoss = 3;
+ pf.gLoss = 2;
+ pf.bLoss = 3;
+ pf.aShift = 0;
+ pf.rShift = 0;
+ pf.gShift = 5;
+ pf.bShift = 11;
break;
case Type_8888:
pf.bytesPerPixel = 4;
- pf.aLoss = 0; pf.rLoss = 0; pf.gLoss = 0; pf.bLoss = 0;
- pf.aShift = 24; pf.rShift = 0; pf.gShift = 8; pf.bShift = 16;
- break;
+ pf.aLoss = 0;
+ pf.rLoss = 0;
+ pf.gLoss = 0;
+ pf.bLoss = 0;
+ pf.aShift = 24;
+ pf.rShift = 0;
+ pf.gShift = 8;
+ pf.bShift = 16;
+ break;
default:
PSP_ERROR("Unhandled PSPPixelFormat[%u]\n", type);
break;
}
-
+
return pf;
}
uint32 PSPPixelFormat::convertTo32BitColor(uint32 color) {
DEBUG_ENTER_FUNC();
- uint32 r,g,b,a, output;
-
+ uint32 r, g, b, a, output;
+
colorToRgba(color, r, g, b, a);
output = ((b << 16) | (g << 8) | (r << 0) | (a << 24));
PSP_DEBUG_PRINT_FUNC("input color[%x], output[%x]\n", color, output);
-
+
DEBUG_EXIT_FUNC();
return output;
}
diff --git a/backends/platform/psp/psppixelformat.h b/backends/platform/psp/psppixelformat.h
index 8a7283df43..2c74469f95 100644
--- a/backends/platform/psp/psppixelformat.h
+++ b/backends/platform/psp/psppixelformat.h
@@ -23,19 +23,19 @@
*
*/
-#ifndef PSP_PIXEL_FORMAT_H
+#ifndef PSP_PIXEL_FORMAT_H
#define PSP_PIXEL_FORMAT_H
-
+
#include "graphics/pixelformat.h"
#include "backends/platform/psp/trace.h"
-
+
/**
* Specialized PixelFormat class
* Supports only those formats which the PSP allows, including 4 bit palettes.
* Also provides accurate color conversion (needed for color masking)
* As well as swapping of red and blue channels (needed by HE games, for example)
*/
-struct PSPPixelFormat{
+struct PSPPixelFormat {
enum Type {
Type_None,
Type_4444,
@@ -44,9 +44,9 @@ struct PSPPixelFormat{
Type_8888,
Type_Palette_8bit,
Type_Palette_4bit,
- Type_Unknown
+ Type_Unknown
};
-
+
Type format;
uint32 bitsPerPixel; ///< Must match bpp of selected type
bool swapRB; ///< Swap red and blue values when reading and writing
@@ -54,16 +54,16 @@ struct PSPPixelFormat{
PSPPixelFormat() : format(Type_Unknown), bitsPerPixel(0), swapRB(false) {}
void set(Type type, bool swap = false);
static void convertFromScummvmPixelFormat(const Graphics::PixelFormat *pf,
- PSPPixelFormat::Type &bufferType,
- PSPPixelFormat::Type &paletteType,
- bool &swapRedBlue);
+ PSPPixelFormat::Type &bufferType,
+ PSPPixelFormat::Type &paletteType,
+ bool &swapRedBlue);
static Graphics::PixelFormat convertToScummvmPixelFormat(PSPPixelFormat::Type type);
uint32 convertTo32BitColor(uint32 color);
inline uint32 rgbaToColor(uint32 r, uint32 g, uint32 b, uint32 a) {
uint32 color;
-
- switch(format) {
+
+ switch (format) {
case Type_4444:
color = (((b >> 4) << 8) | ((g >> 4) << 4) | ((r >> 4) << 0) | ((a >> 4) << 12));
break;
@@ -84,7 +84,7 @@ struct PSPPixelFormat{
}
inline void colorToRgba(uint32 color, uint32 &r, uint32 &g, uint32 &b, uint32 &a) {
- switch(format) {
+ switch (format) {
case Type_4444:
a = (color >> 12) & 0xF; // Interpolate to get true colors
b = (color >> 8) & 0xF;
@@ -126,7 +126,7 @@ struct PSPPixelFormat{
}
inline uint32 setColorAlpha(uint32 color, byte alpha) {
- switch(format) {
+ switch (format) {
case Type_4444:
color = (color & 0x0FFF) | (((uint32)alpha >> 4) << 12);
break;
@@ -134,7 +134,7 @@ struct PSPPixelFormat{
color = (color & 0x7FFF) | (((uint32)alpha >> 7) << 15);
break;
case Type_8888:
- color = (color & 0x00FFFFFF) | ((uint32)alpha << 24);
+ color = (color & 0x00FFFFFF) | ((uint32)alpha << 24);
break;
case Type_5650:
default:
@@ -142,7 +142,7 @@ struct PSPPixelFormat{
}
return color;
}
-
+
inline uint32 pixelsToBytes(uint32 pixels) {
switch (bitsPerPixel) {
case 4:
@@ -165,51 +165,51 @@ struct PSPPixelFormat{
inline uint16 swapRedBlue16(uint16 color) {
uint16 output;
-
+
switch (format) {
- case Type_4444:
- output = (color & 0xf0f0) | ((color & 0x000f)<<8) | ((color & 0x0f00)>>8);
- break;
- case Type_5551:
- output = (color & 0x83e0) | ((color & 0x001f)<<10) | ((color & 0x7c00)>>10);
- break;
- case Type_5650:
- output = (color & 0x07e0) | ((color & 0x001f)<<11) | ((color & 0xf800)>>11);
- break;
- default:
- PSP_ERROR("invalid format[%u] for swapping\n", format);
- output = 0;
- break;
+ case Type_4444:
+ output = (color & 0xf0f0) | ((color & 0x000f) << 8) | ((color & 0x0f00) >> 8);
+ break;
+ case Type_5551:
+ output = (color & 0x83e0) | ((color & 0x001f) << 10) | ((color & 0x7c00) >> 10);
+ break;
+ case Type_5650:
+ output = (color & 0x07e0) | ((color & 0x001f) << 11) | ((color & 0xf800) >> 11);
+ break;
+ default:
+ PSP_ERROR("invalid format[%u] for swapping\n", format);
+ output = 0;
+ break;
}
return output;
}
inline uint32 swapRedBlue32(uint32 color) {
uint32 output;
-
+
switch (format) {
- case Type_4444:
- output = (color & 0xf0f0f0f0) |
- ((color & 0x000f000f)<<8) | ((color & 0x0f000f00)>>8);
- break;
- case Type_5551:
- output = (color & 0x83e083e0) |
- ((color & 0x001f001f)<<10) | ((color & 0x7c007c00)>>10);
- break;
- case Type_5650:
- output = (color & 0x07e007e0) |
- ((color & 0x001f001f)<<11) | ((color & 0xf800f800)>>11);
- break;
- case Type_8888:
- output = (color & 0xff00ff00) |
- ((color & 0x000000ff)<<16) | ((color & 0x00ff0000)>>16);
- break;
- default:
- PSP_ERROR("invalid format[%u] for swapping\n", format);
- output = 0;
- break;
+ case Type_4444:
+ output = (color & 0xf0f0f0f0) |
+ ((color & 0x000f000f) << 8) | ((color & 0x0f000f00) >> 8);
+ break;
+ case Type_5551:
+ output = (color & 0x83e083e0) |
+ ((color & 0x001f001f) << 10) | ((color & 0x7c007c00) >> 10);
+ break;
+ case Type_5650:
+ output = (color & 0x07e007e0) |
+ ((color & 0x001f001f) << 11) | ((color & 0xf800f800) >> 11);
+ break;
+ case Type_8888:
+ output = (color & 0xff00ff00) |
+ ((color & 0x000000ff) << 16) | ((color & 0x00ff0000) >> 16);
+ break;
+ default:
+ PSP_ERROR("invalid format[%u] for swapping\n", format);
+ output = 0;
+ break;
}
-
+
return output;
}
@@ -220,10 +220,10 @@ struct PSPPixelFormat{
switch (bitsPerPixel) {
case 4: // We can't distinguish a 4 bit color with a pointer
case 8:
- result = (uint32)*pointer;
+ result = (uint32) * pointer;
break;
case 16:
- result = (uint32)*(uint16 *)pointer;
+ result = (uint32) * (uint16 *)pointer;
break;
case 32:
result = *(uint32 *)pointer;
@@ -234,7 +234,7 @@ struct PSPPixelFormat{
break;
}
return result;
- }
+ }
};
-
-#endif /* PSP_PIXEL_FORMAT_H */
+
+#endif /* PSP_PIXEL_FORMAT_H */
diff --git a/backends/platform/psp/trace.cpp b/backends/platform/psp/trace.cpp
index 030dafdf1d..872e1aabf4 100644
--- a/backends/platform/psp/trace.cpp
+++ b/backends/platform/psp/trace.cpp
@@ -31,25 +31,25 @@
int psp_debug_indent = 0;
-void PSPDebugTrace (bool alsoToScreen, const char *format, ...) {
+void PSPDebugTrace(bool alsoToScreen, const char *format, ...) {
va_list opt;
char buffer[2048];
int bufsz;
FILE *fd = 0;
va_start(opt, format);
- bufsz = vsnprintf( buffer, (size_t) sizeof(buffer), format, opt);
+ bufsz = vsnprintf(buffer, (size_t) sizeof(buffer), format, opt);
va_end(opt);
//fd = fopen("MS0:/SCUMMTRACE.TXT", "ab");
fd = fopen("SCUMMTRACE.TXT", "ab");
-
+
if (fd == 0)
return;
fwrite(buffer, 1, bufsz, fd);
fclose(fd);
-
+
if (alsoToScreen)
fprintf(stderr, buffer);
}
diff --git a/backends/platform/psp/trace.h b/backends/platform/psp/trace.h
index b77ecb4732..024da11373 100644
--- a/backends/platform/psp/trace.h
+++ b/backends/platform/psp/trace.h
@@ -38,7 +38,7 @@
//#define __PSP_DEBUG_FUNCS__ /* can put this locally too */
//#define __PSP_DEBUG_PRINT__
-void PSPDebugTrace (bool alsoToScreen, const char *format, ...);
+void PSPDebugTrace(bool alsoToScreen, const char *format, ...);
#ifndef TRACE_C
extern int psp_debug_indent;
@@ -62,19 +62,19 @@ extern int psp_debug_indent;
/* Choose to print to file/screen/both */
#ifdef __PSP_PRINT_TO_FILE__
- #define __PSP_PRINT__(format,...) PSPDebugTrace(false, format, ## __VA_ARGS__)
+#define __PSP_PRINT__(format,...) PSPDebugTrace(false, format, ## __VA_ARGS__)
#elif defined __PSP_PRINT_TO_FILE_AND_SCREEN__
- #define __PSP_PRINT__(format,...) PSPDebugTrace(true, format, ## __VA_ARGS__)
+#define __PSP_PRINT__(format,...) PSPDebugTrace(true, format, ## __VA_ARGS__)
#else /* default - print to screen */
- #define __PSP_PRINT__(format,...) fprintf(stderr, format, ## __VA_ARGS__)
+#define __PSP_PRINT__(format,...) fprintf(stderr, format, ## __VA_ARGS__)
#endif /* PSP_PRINT_TO_FILE/SCREEN */
-
+
/* Error function */
#define PSP_ERROR(format,...) __PSP_PRINT__("Error in %s: " format, __PRETTY_FUNCTION__, ## __VA_ARGS__)
/* Do the indent */
#define __PSP_INDENT__ for(int _i=psp_debug_indent; _i>0; _i--) \
- __PSP_PRINT__( " ")
+ __PSP_PRINT__( " ")
/* always print */
#define PSP_INFO_PRINT(format,...) __PSP_PRINT__(format, ## __VA_ARGS__)
@@ -83,36 +83,36 @@ extern int psp_debug_indent;
__PSP_PRINT__(format, ## __VA_ARGS__); }
#ifdef __PSP_DEBUG_PRINT__
- /* printf with indents */
- #define PSP_DEBUG_PRINT_SAMELN(format,...) __PSP_PRINT__(format, ## __VA_ARGS__)
- #define PSP_DEBUG_PRINT(format,...) { __PSP_INDENT__; \
+/* printf with indents */
+#define PSP_DEBUG_PRINT_SAMELN(format,...) __PSP_PRINT__(format, ## __VA_ARGS__)
+#define PSP_DEBUG_PRINT(format,...) { __PSP_INDENT__; \
__PSP_PRINT__(format, ## __VA_ARGS__); }
- #define PSP_DEBUG_PRINT_FUNC(format,...) { __PSP_INDENT__; \
+#define PSP_DEBUG_PRINT_FUNC(format,...) { __PSP_INDENT__; \
__PSP_PRINT__("In %s: " format, __PRETTY_FUNCTION__, ## __VA_ARGS__); }
- #define PSP_DEBUG_DO(x) (x)
+#define PSP_DEBUG_DO(x) (x)
#else /* no debug print */
- #define PSP_DEBUG_PRINT_SAMELN(format,...)
- #define PSP_DEBUG_PRINT(format,...)
- #define PSP_DEBUG_PRINT_FUNC(format,...)
- #define PSP_DEBUG_DO(x)
+#define PSP_DEBUG_PRINT_SAMELN(format,...)
+#define PSP_DEBUG_PRINT(format,...)
+#define PSP_DEBUG_PRINT_FUNC(format,...)
+#define PSP_DEBUG_DO(x)
#endif /* __PSP_DEBUG_PRINT__ */
/* Debugging function calls */
#ifdef __PSP_DEBUG_FUNCS__
- #define DEBUG_ENTER_FUNC() PSP_INFO_PRINT_INDENT("++ %s\n", __PRETTY_FUNCTION__); \
- psp_debug_indent++
-
- #define DEBUG_EXIT_FUNC() psp_debug_indent--; \
+#define DEBUG_ENTER_FUNC() PSP_INFO_PRINT_INDENT("++ %s\n", __PRETTY_FUNCTION__); \
+ psp_debug_indent++
+
+#define DEBUG_EXIT_FUNC() psp_debug_indent--; \
if (psp_debug_indent < 0) PSP_ERROR("debug indent < 0\n"); \
PSP_INFO_PRINT_INDENT("-- %s\n", __PRETTY_FUNCTION__)
- #define INLINE /* don't want to inline so we get function names properly */
-
+#define INLINE /* don't want to inline so we get function names properly */
+
#else /* Don't debug function calls */
- #define DEBUG_ENTER_FUNC()
- #define DEBUG_EXIT_FUNC()
- #define INLINE inline
+#define DEBUG_ENTER_FUNC()
+#define DEBUG_EXIT_FUNC()
+#define INLINE inline
#endif /* __PSP_DEBUG_FUNCS__ */
// Undef the main defines for next time