aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYotam Barnoy2010-08-17 09:45:14 +0000
committerYotam Barnoy2010-08-17 09:45:14 +0000
commitaa16c9e04699e9f441db071d7e27ebfcad17074c (patch)
tree99b6d877a76b827b8e9bd10859df0bdd24cf6c4b
parent06960d33e15bc80f9912fa92f11dd82388199bd6 (diff)
downloadscummvm-rg350-aa16c9e04699e9f441db071d7e27ebfcad17074c.tar.gz
scummvm-rg350-aa16c9e04699e9f441db071d7e27ebfcad17074c.tar.bz2
scummvm-rg350-aa16c9e04699e9f441db071d7e27ebfcad17074c.zip
PSP: changed display options to Full Screen, Keep Aspect Ratio and Original Resolution
This greatly simplifies the display options and makes them more practical. Original resolution will try to fit the game to the screen pixel-to-pixel, and will revert to full screen if it fails. Keep AR maximizes height and adjusts the width accordingly. This works very well with 320x200 games (AR of 1.6) which is close to the PSP's 1.7, but not so well with 320x240/640x480 (AR of 1.3). Full Screen is still default. svn-id: r52138
-rw-r--r--backends/platform/psp/display_manager.cpp67
-rw-r--r--backends/platform/psp/display_manager.h9
2 files changed, 43 insertions, 33 deletions
diff --git a/backends/platform/psp/display_manager.cpp b/backends/platform/psp/display_manager.cpp
index 5037543f12..9f58a64ee3 100644
--- a/backends/platform/psp/display_manager.cpp
+++ b/backends/platform/psp/display_manager.cpp
@@ -53,10 +53,9 @@
uint32 __attribute__((aligned(16))) MasterGuRenderer::_displayList[2048];
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 },
- { "362x272 (4:3, centered)", "362x272 16-bit centered", CENTERED_362X272 },
+ { "Original Resolution", "Original Resolution", ORIGINAL_RESOLUTION },
+ { "Keep Aspect Ratio", "Keep Aspect Ratio", KEEP_ASPECT_RATIO },
+ { "Full Screen", "Full Screen", STRETCHED_FULL_SCREEN },
{0, 0, 0}
};
@@ -263,38 +262,50 @@ bool DisplayManager::setGraphicsMode(int mode) {
_graphicsMode = mode;
+ calculateScaleParams();
+
+ return true;
+}
+
+void DisplayManager::calculateScaleParams() {
+
+ if (!_displayParams.screenSource.width || !_displayParams.screenSource.height)
+ return; // we can't calculate anything without these
+
switch (_graphicsMode) {
- case CENTERED_320X200:
- _displayParams.screenOutput.width = 320;
- _displayParams.screenOutput.height = 200;
- break;
- case CENTERED_435X272:
- _displayParams.screenOutput.width = 435;
- _displayParams.screenOutput.height = 272;
+ case ORIGINAL_RESOLUTION:
+ // check if we can fit the original resolution inside the screen
+ if ((_displayParams.screenSource.width < PSP_SCREEN_WIDTH) &&
+ (_displayParams.screenSource.height < PSP_SCREEN_HEIGHT)) {
+ _displayParams.screenOutput.width = _displayParams.screenSource.width;
+ _displayParams.screenOutput.height = _displayParams.screenSource.height;
+ } else { // revert to stretch to fit
+ _displayParams.screenOutput.width = PSP_SCREEN_WIDTH;
+ _displayParams.screenOutput.height = PSP_SCREEN_HEIGHT;
+ }
break;
- case STRETCHED_480X272:
- _displayParams.screenOutput.width = 480;
- _displayParams.screenOutput.height = 272;
+ case KEEP_ASPECT_RATIO: { // maximize the height while keeping aspect ratio
+ float aspectRatio = (float)_displayParams.screenSource.width / (float)_displayParams.screenSource.height;
+
+ _displayParams.screenOutput.height = PSP_SCREEN_HEIGHT; // always full height
+ _displayParams.screenOutput.width = (uint32)(PSP_SCREEN_HEIGHT * aspectRatio);
+
+ if (_displayParams.screenOutput.width > PSP_SCREEN_WIDTH) // we can't have wider than the screen
+ _displayParams.screenOutput.width = PSP_SCREEN_WIDTH;
+ }
break;
- case CENTERED_362X272:
- _displayParams.screenOutput.width = 362;
- _displayParams.screenOutput.height = 272;
+ case STRETCHED_FULL_SCREEN: // we simply stretch to the whole screen
+ _displayParams.screenOutput.width = PSP_SCREEN_WIDTH;
+ _displayParams.screenOutput.height = PSP_SCREEN_HEIGHT;
break;
default:
PSP_ERROR("Unsupported graphics mode[%d].\n", _graphicsMode);
}
+
+ // calculate scale factors for X and Y
+ _displayParams.scaleX = ((float)_displayParams.screenOutput.width) / _displayParams.screenSource.width;
+ _displayParams.scaleY = ((float)_displayParams.screenOutput.height) / _displayParams.screenSource.height;
- calculateScaleParams();
-
- return true;
-}
-
-void DisplayManager::calculateScaleParams() {
- if (_displayParams.screenOutput.width && _displayParams.screenSource.width &&
- _displayParams.screenOutput.height && _displayParams.screenSource.height) {
- _displayParams.scaleX = ((float)_displayParams.screenOutput.width) / _displayParams.screenSource.width;
- _displayParams.scaleY = ((float)_displayParams.screenOutput.height) / _displayParams.screenSource.height;
- }
}
// return true if we really rendered or no dirty. False otherwise
diff --git a/backends/platform/psp/display_manager.h b/backends/platform/psp/display_manager.h
index 1f7320902c..f52541e615 100644
--- a/backends/platform/psp/display_manager.h
+++ b/backends/platform/psp/display_manager.h
@@ -61,10 +61,9 @@ class PSPKeyboard;
class DisplayManager {
public:
enum GraphicsModeID { ///> Possible output formats onscreen
- CENTERED_320X200,
- CENTERED_435X272,
- STRETCHED_480X272,
- CENTERED_362X272
+ ORIGINAL_RESOLUTION,
+ KEEP_ASPECT_RATIO,
+ STRETCHED_FULL_SCREEN
};
DisplayManager() : _screen(0), _cursor(0), _overlay(0), _keyboard(0), _lastUpdateTime(0), _graphicsMode(0) {}
~DisplayManager();
@@ -74,7 +73,7 @@ public:
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_FULL_SCREEN; }
const OSystem::GraphicsMode* getSupportedGraphicsModes() const { return _supportedModes; }
// Setters